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 > Problem with including 64x64 sprite data

#55880 - blacksun - Mon Oct 03, 2005 6:54 pm

I currently have 5 64x64 sprites that I want to load in my game. Only one sprite will be displayed at a time. I have it right now that depending on what mode the user has selected it will load a different sprite into memory so memory shouldnt be an issue. The problem is when I include the .c files that contain the data for the sprites.

I know this probably isnt the most efficient way to get the data in the game but I don't know a different way. As of now if I include 4 sprites, my sprite data will become corrupt. It works fine if I only include 3 of the sprites. I don't think it is overriding any memory. And I have tried just including the .c files in the make file but that didn't work for me. Probably because I was doing it wrong. I am using the gcc compiler to do this.

#55881 - poslundc - Mon Oct 03, 2005 7:13 pm

Are your arrays being declared as const?

Dan.

#55889 - blacksun - Mon Oct 03, 2005 8:49 pm

No, they are being declared as unsigned shorts. Is that a problem?

#55890 - Touchstone - Mon Oct 03, 2005 9:03 pm

If your data is not declared as const it will be copied from ROM into RAM and then accessed from RAM, and it's quite possible that the RAM might not be enough to hold all your data. If your data is declared as const it will not be copied into RAM and when you access it you will read straight from ROM.
_________________
You can't beat our meat

#55901 - blacksun - Mon Oct 03, 2005 10:58 pm

Oh cool thanks for the tip. Made all of the arrays consts and no problems. Will keep that in mind for future reference