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.

C/C++ > Member Functions and memory

#104972 - Zephyr - Wed Oct 04, 2006 8:35 pm

I'm coding a game witch is a series of minigames.
I'd like all of those minigames' code to be stored in separate classes and I'd like not to run out of the memory.

I wonder where is the class members function code stored.

I it's in RAM, what should I do to tell gcc that it should put it in ROM and copy to RAM only when a new object is initiated, and free the space when the last object is destroyed (or is it done automatically).

If the functions are stored in ROM, is there an easy way to put some of them into EWRAM on initialisation of the first object and free the space after the last one is deleted?

I'd also like to know where are the normal functions placed if i dont use CODE_IN_EWRAM (ROM or are they still copied to RAM )

Do the keywords const and static change much?

If it's up to compiler I'm using Vham 2.4.2(arm-thumb-elf?) or DevKitARM R19b (not shure yet, ARM is more up-to-date, but Vham has Krawall already configured and it's own lib [I know it isn't that much, but I'm a beginner]).

#104995 - sajiimori - Wed Oct 04, 2006 10:57 pm

For GBA games, code is typically stored in ROM, so you needn't worry. For DS games, code is in RAM, but then you have a lot more memory to work with.

#105013 - poslundc - Thu Oct 05, 2006 3:19 am

Also, if your game is compiled with multiboot enabled then the code will be stored in EWRAM (256K max). So be sure to disable multiboot if this is a problem for you.

Dan.

#105087 - gmiller - Thu Oct 05, 2006 9:04 pm

Zephyr wrote:
I'm coding a game witch is a series of minigames.
I'd like all of those minigames' code to be stored in separate classes and I'd like not to run out of the memory.

I wonder where is the class members function code stored.

I it's in RAM, what should I do to tell gcc that it should put it in ROM and copy to RAM only when a new object is initiated, and free the space when the last object is destroyed (or is it done automatically).

If the functions are stored in ROM, is there an easy way to put some of them into EWRAM on initialisation of the first object and free the space after the last one is deleted?

I'd also like to know where are the normal functions placed if i dont use CODE_IN_EWRAM (ROM or are they still copied to RAM )

Do the keywords const and static change much?

If it's up to compiler I'm using Vham 2.4.2(arm-thumb-elf?) or DevKitARM R19b (not shure yet, ARM is more up-to-date, but Vham has Krawall already configured and it's own lib [I know it isn't that much, but I'm a beginner]).


You can easily use the latest dev kit with the IDE Vham. There can be issues with ELF vs EABI that will make some of your libraries unusable without a little work. If you are not that good with makefile you might want to stick with the ones that come with VHam but I have abandoned them.