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 > Declarations as const and ROM access

#8504 - sealFin - Sat Jul 12, 2003 2:43 pm

Quick query - I haven't seen it explicitly stated anywhere, but am I right in assuming that declaring a global variable as a 'const' tells the compiler to put it and the value it has been declared as holding into ROM, not RAM?

Also, what is the usual latency for accessing data in the ROM? Ie. would the memory saved by putting a 'sqrt()' look-up table on ROM be outweighed by the loss in speed as compared to putting the look-up table in RAM?
_________________
sealfin

:sigh: Yes, I know seals don't have fins...

#8509 - Sweex - Sat Jul 12, 2003 3:44 pm

Everything that's declared as const goes into ROM indeed.

About the "latency", I reckon it's minor, but if you can spare some memory for it in RAM, that'll probably be a bit quicker.

#8510 - tepples - Sat Jul 12, 2003 4:25 pm

ROM is about as fast as EWRAM (slightly slower for random accesses such as lookup tables, but slightly faster for sequential accesses such as graphics DMA). IWRAM is much faster and 32-bit. VRAM is almost as fast as IWRAM and 16-bit; you may want to store lookup tables in an unused portion of VRAM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.