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 > Sprites not showing up

#178430 - imanironmaiden - Tue Jun 23, 2015 8:56 pm

I have been making my way through the tonc tutorial and have unsuccessfully been trying to get all the sprites to show up on the top left corner of the screen. Here is the code I wrote:
Code:

int main() {
    // set the first palette element to red
    *(unsigned int*)0x05000200 = 0x1f;
    // mode 0, 1d drawing, objects enabled
    *(unsigned int*)0x04000000 = 0x1040;
    while(1);
    return 0;
}

When I compile that and run it in vba/no$gba/gba4ios, nothing shows up. When I took a look at the oam in vba, all the objects were 8x8 red squares at coordinate (0,0), but the whole screen was black. Any help would be greatly appreciated. Thanks.

#178431 - DekuTree64 - Wed Jun 24, 2015 2:58 am

Color 0 is transparent. The BG palette 0 is special because it shows up as the backdrop color if nothing else is present, but sprite palette 0 is never shown.

So try sprite color 1, like
*(unsigned short*)0x05000202 = 0x1f;
Then you need to put some non-zero pixels in the sprite tile VRAM area like
*(unsigned int*)0x06010000 = 0x01010101;
And that should show up at the top left corner of the screen as a row of alternating red and transparent pixels, because all 128 OAM entries default to being visible 4-bit 8x8 sprites at position 0,0.

The tutorial should show you how to set up OAM entries to actually do useful things after that.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#178432 - imanironmaiden - Wed Jun 24, 2015 3:32 am

Thanks so much!!!!!! I was losing my mind trying to figure out what I was doing wrong.