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.

Coding > No sprite displays

#71460 - Voelker - Mon Feb 13, 2006 12:40 am

I have written a small programm which uses mode O with background 2 and 3, and normally displays some sprites ... It run well on emulator but when i want a try it on real hardware (xg2 trubo cart) sprites doesn't display. I really need some help.
Thanks

#71465 - shen3 - Mon Feb 13, 2006 12:52 am

It is a hard to answer a question like this without seeing the source code or at least a rom.

Do you have a web site with the rom or the source available?

#71472 - kusma - Mon Feb 13, 2006 1:58 am

have you tried with both vba and no$?
vba tends to accept some stuff that no$ and (/or in some cases) the real hardware doesn't.

#71668 - Voelker - Mon Feb 13, 2006 11:04 pm

I only tried with vba, i changed the way i copy OAM to memory but it hasn't changed anything. I would know if some people could send me a working example of code with sprites using devkitpro.
Thanks

#71674 - Voelker - Mon Feb 13, 2006 11:49 pm

i tried some sprites examples and they worked, so uses the same way of coding, and it doesn't work. I don't understand a thing, i relly need your help, maybe it's devkit pro doesn't compile well.

#71751 - ribrdb2 - Tue Feb 14, 2006 6:37 am

Why don't you show us the code you're having problems with so we can try to help you?

#71764 - Voelker - Tue Feb 14, 2006 9:35 am

the source is available here : http://gbatek.free.fr/testinterface.zip
Thanks for your help ...

#71842 - Voelker - Tue Feb 14, 2006 9:03 pm

I finnaly solved my problem. In fact i used an u8 pointer to write to the OAMData in Vram and it doesn't work si i changed this by using a u16 pointer which work well. The thing i don't understand is that i use a u8 pointer to write my tiles (for background) to Vram and it works well too ...

The truth is out there

#71851 - tepples - Tue Feb 14, 2006 10:07 pm

It's almost always best to use u32 pointers to write to VRAM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#71860 - Cearn - Tue Feb 14, 2006 11:10 pm

Voelker wrote:
I finally solved my problem. In fact I used an u8 pointer to write to the OAMData in Vram and it doesn't work is I changed this by using a u16 pointer which work well.

The truth is out there

Don't use u8 pointers for OAM, VRAM or PALRAM. In fact, don't use u16 pointers too much either unless you have a good reason. For colors would constitute a good reason, because they're 16-bit anyway. Since OAM consists of OBJATTRs, the best type for OAM is an OBJATTR pointer.

The GBA is a 32-bit machine, therefore prefer 32-bit types. Using u32* instead of u16* more than doubles the speed for your copies. Using ints as variables instead of shorts also increases the speed between 20% and 50% depending on their use.

Voelker wrote:
The thing i don't understand is that I use a u8 pointer to write my tiles (for background) to Vram and it works well too ...

Actually, it does not work well. What happens with byte-writes here is that you will fill both bytes of a halfword with the written byte. Since your graphics are still simple you just don't notice it that much, but look closer and you'll see that all the pixels are doubled because of this. The same thing happens in OAM, which is where nothing shows up. Should have happened on emus too, of course.

And, please, please, please don't #include data. Compile them separately then link to the rest of the project. Please. With sugar and a cherry on top, etc, etc.
Sorry for the tone here, but these things have been covered sooo often by now that it gets a little tiring. See the FAQ and probably well over a hundred other threads.