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 > How do I make my data complie to ROM?

#52275 - danvx6 - Mon Aug 29, 2005 6:44 am

What I want to do is program an RPG, and there is not enough space in VRAM for all of the sprites (plus i need a place for my maps, dialogue, etc.) so I need to figure out how to make sure my data is stored in ROM. Then I need to know how to access the data from ROM. Can someone please help me with this? I tried searching the forums, but to no avail. Thanks :)

#52276 - yamaneko - Mon Aug 29, 2005 6:52 am

It's simple.

When you declare your data, just put "const" in front:

exemple:
const char var[]={some value..};
_________________
山猫

#52331 - danvx6 - Mon Aug 29, 2005 8:07 pm

Thanks. I think I am going to need to put the data in specific locations though so I can access certain data when it is needed. How can I make sure that a chunk of data is stored in a specific memory location?

#52334 - poslundc - Mon Aug 29, 2005 8:21 pm

danvx6 wrote:
Thanks. I think I am going to need to put the data in specific locations though so I can access certain data when it is needed.


You can access it any time... by referring to its variable name. If it's an array, use the variable name to grab a pointer to the base of it. If it's a literal value, structure, etc. use the address-of operator (&) to get the address of it.

Quote:
How can I make sure that a chunk of data is stored in a specific memory location?


Not very easily. That's why we have linkers to link a variable name with a location in memory: so we don't have to keep track of what address every variable is stored at. Why would you want to do this yourself?

Dan.

#52340 - danvx6 - Mon Aug 29, 2005 9:06 pm

I was just confusing myself, thats all... forget it ever happened. :)