gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > patatersoft tutorial compilation problems

#116732 - nolentabner - Sun Jan 28, 2007 11:35 pm

I apologize for the "noob"ness of this post, but I'm still new to libnds and I can't figure out why this won't compile.

This is the very first part of the tutorial, after you add the starfield and splash images to the code.

Here is the error message:
Code:

c:/devkitPro/mystuff/spaceShip/source/main.cpp: In function 'void displaySplash()':
c:/devkitPro/mystuff/spaceShip/source/main.cpp:61: error: invalid conversion from 'int' to 'void*'
c:/devkitPro/mystuff/spaceShip/source/main.cpp:61: error:   initializing argument 2 of 'void dmaCopy(const void*, void*, uint32)'
c:/devkitPro/mystuff/spaceShip/source/main.cpp: In function 'void displayStarField()':
c:/devkitPro/mystuff/spaceShip/source/main.cpp:67: error: invalid conversion from 'int' to 'void*'
c:/devkitPro/mystuff/spaceShip/source/main.cpp:67: error:   initializing argument 2 of 'void dmaCopy(const void*, void*, uint32)'
make[1]: *** [main.o] Error 1
"make": *** [build] Error 2

> Process Exit Code: 2
> Time Taken: 00:03


And here is my code for those two lines:

Code:


void displaySplash()
{
   dmaCopy(Splash_bin, BG_BMP_RAM_SUB(0), Splash_bin_size);
      //sub bg is BG_BMP_RAM_SUB(0)
}

void displayStarField()
{
   dmaCopy(StarField_bin, BG_BMP_RAM(0), StarField_bin_size);
   // main bg is BG_BMP_RAM(0)
}



I've typed all this code out exactly as the tutorial shows, and I've even tried just copying the text directly into the editor. Why does it think that it's being converted from int to void? This is exactly what the tutorial shows for me to type in.

#116734 - Mr Snowflake - Mon Jan 29, 2007 12:06 am

I could be wrong, but I believe you should do:
Code:

dmaCopy((void*)Splash_bin, BG_BMP_RAM_SUB(0), Splash_bin_size);

For both of course.
_________________
http://www.mrsnowflake.be

#116735 - nolen - Mon Jan 29, 2007 12:20 am

Mr Snowflake wrote:
I could be wrong, but I believe you should do:
Code:

dmaCopy((void*)Splash_bin, BG_BMP_RAM_SUB(0), Splash_bin_size);

For both of course.



I actually tried that but to no avail :(.

Thanks though :)


edit: I just noticed I have two screen names on these forums. haha.

#116737 - Dark Knight ez - Mon Jan 29, 2007 12:37 am

Put a (void *) before the second argument. That's it.
_________________
AmplituDS website

#116739 - nolen - Mon Jan 29, 2007 12:54 am

Dark Knight ez wrote:
Put a (void *) before the second argument. That's it.


Thank you sir.

Any reason why he hasn't updated his tutorial to correct this or why this is the first I've come across someone having this problem?

#116779 - Mr Snowflake - Mon Jan 29, 2007 1:26 pm

Dark Knight ez wrote:
Put a (void *) before the second argument. That's it.
Oh hehe, I tought I edited my post in that fashion... Though luck :).
_________________
http://www.mrsnowflake.be

#116787 - Lick - Mon Jan 29, 2007 5:46 pm

It's because BG_{BMP/MAP/TILE}_RAM{_SUB}() definitions don't return pointers, they return addresses.

Written all out, it's like this:

u32 address = 0x06000000;
memcpy(address, data, size); // fail

void *ptr = (void *)address;
memcpy(ptr, data, size); // success
_________________
http://licklick.wordpress.com

#116795 - tepples - Mon Jan 29, 2007 8:15 pm

Lick wrote:
It's because BG_{BMP/MAP/TILE}_RAM{_SUB}() definitions don't return pointers, they return addresses.

Then the header has a bug. Storing an address in an int is not portable, and it encourages pointer arithmetic bugs. For the sake of type safety, anything that normally returns an address should return it casted to a (void *), a (u32 *), or a (u16 *) as appropriate.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.