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 > Intentionally exceeding array boundaries....cheating?

#19750 - CyberSlag5k - Sat Apr 24, 2004 6:21 pm

Ok, gifs2sprites converts any number of gifs to info for sprites and puts them in a header file. Each frame is given a name (obj0, obj1, 0bj2....). Now, I have a ton of these guys (18) that I am loading into OAM, so I threw them all into one big for loop. The problem is, I cannot incrememnt the 0 in obj0 each time. So I came up with this little dewsie:

Code:

for(int j = 0; j < 15; j++)
   for(int i = 0; i < 2048; i++)
      OAMData[i + (j * 2048)] = obj0[i + (j * 2048)];


Now, as you can see I'm quite exceeding obj0's boundaries (the sprites are 64x64 and so obj as 2048 indices). One would think that all the objects would be stored next to each other, right? Am I like totally cheating? My program is acting kind of funny, so I'm wondering if this is the cause.

Any thoughts?

p.s. I'll supply more code if you guys think it's necessary, but for now I don't think it is.
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...

#19751 - sajiimori - Sat Apr 24, 2004 6:56 pm

There are no guarantees about the locations of the arrays, except the general memory area they are in, such as IWRAM, EWRAM, or ROM.

One quick fix would be to make an array that holds pointers to each of the 16 images, and iterate across that.

#19752 - CyberSlag5k - Sat Apr 24, 2004 7:05 pm

Good idea, thanks.
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...

#19768 - sgeos - Sun Apr 25, 2004 1:00 pm

Quote:
Intentionally exceeding array boundaries....cheating?


It's not cheating, it's just not a very bright thing to do.

-Brendan

#19834 - FluBBa - Mon Apr 26, 2004 2:31 pm

I suppose OAMData points to ObjectVRAM (0x06010000) and not to ObjectAttributeMemory, right?
Edit: Ops, should have read the other threads also...
_________________
I probably suck, my not is a programmer.