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.

Beginners > Basic Sprite Problems

#72890 - tonkinfash - Wed Feb 22, 2006 11:01 am

After starting out creating a bouncing ball using good old-fashioned blitting I decided to get to grips with OAM. To this end I hacked out a simple program that allows the user to guide a ball around the screen. I got it working, only to find that the sprite has been thrashed.

What should look like this:

[Images not permitted - Click here to view it]

Looks like this:

[Images not permitted - Click here to view it]

The corresponding arrays can be seen here:

Code:

unsigned char ball [] = {   0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00,

                     0x00, 0xFF, 0xFF, 0xAA, 0xAA, 0xFF, 0xFF, 0x00,

                     0x00, 0xFF, 0xAA, 0x55, 0x55, 0xAA, 0xFF, 0x00,

                     0xFF, 0xAA, 0x55, 0x00, 0x00, 0x55, 0xAA, 0xFF,

                     0xFF, 0xAA, 0x55, 0x00, 0x00, 0x55, 0xAA, 0xFF,

                     0x00, 0xFF, 0xAA, 0x55, 0x55, 0xAA, 0xFF, 0x00,

                     0x00, 0xFF, 0xFF, 0xAA, 0xAA, 0xFF, 0xFF, 0x00,

                     0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00 };


And for the OAM version:

Code:

unsigned short ball [] = {   0x0000, 0x00ff, 0xff00, 0x0000,

                     0x00ff, 0xffaa, 0xaaff, 0xff00,

                     0x00ff, 0xaa55, 0x55aa, 0xff00,

                     0xffaa, 0x5500, 0x0055, 0xaaff,

                     0xffaa, 0x5500, 0x0055, 0xaaff,

                     0x00ff, 0xaa55, 0x55aa, 0xff00,

                     0x00ff, 0xffaa, 0xaaff, 0xff00,

                     0x0000, 0x00ff, 0xff00, 0x0000 };


Weird, eh? Surely these arrays are the same?!

#72891 - tonkinfash - Wed Feb 22, 2006 11:02 am

It's just occurred to me that it's probably endian-related.

Sorry 'bout all that! :)

#72894 - tonkinfash - Wed Feb 22, 2006 11:06 am

...which, after a quick re-shuffle, I can say it was.

Whoops!