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 > What happens in memory when...??

#8528 - Jakerrzero - Sun Jul 13, 2003 3:18 am

I have a question that is borderline between being a coding question and a hardware question so i just chose the coding forum.

When you include a header file that contains a sprites bitmap in an array form and its pallete what happens in the hardware. I mean before you copy the bitmap data into OAMdata and the pallete into object pallete memory where does that data reside. Is it in the ROM section of the cart or is it in memory?? I'm sorry if this doesn't make sense I'm just trying to wrap my head around all this terminology and everything. Basically what I want to know is how can i store data in ROM so that it isn't in memory when it is not being used??

Thanks for any insight you can offer :)

#8529 - sgeos - Sun Jul 13, 2003 3:42 am

Jakerrzero wrote:
When you include a header file ... where does that data reside.


In either case, the contents of your header file are a global variable. Declare-ing a variable as const is your way of telling the compiler that the data is constant, that it will not change. const variables are put in ROM.

If you do not declare your variable as const then the compiler puts the array in ram so you can change the values.

Code:
const int palette_a[16] = {...}; /* ROM */
const int palette_b[16] = {...}; /* ROM */
int palette_current[16] = {...}; /* RAM */


-Brendan

#8531 - Jakerrzero - Sun Jul 13, 2003 3:55 am

Oh cool THANKS!!!!!

#8542 - sgeos - Sun Jul 13, 2003 3:40 pm

Very welcome.