Post

In Pixel Pup, all memory is static. When the game starts, everything in the entire game that needs RAM, grabs it. The entire game is in RAM at all times (the puzzles don't need to be in RAM, they are read from ROM). I know that won't cut it for Eridin, so I created a very simple memory allocator.

The allocator grabs 128kb of memory from the GBA's RAM. Then the different parts of the game call mem_alloc() to get a chunk of that to use. When that phase of the game is done (say moving from title screen into gameplay), the allocator resets back to zero. Very primitive, but it works very well.

Resting back to zero means I never have to worry about memory leaks or freeing. There is a small amount of global memory that keeps track of things that shouldn't reset. Ex: When attacking, the game goes from battle phase to attack phase. Global memory is used to keep track of who is in the fight.

0 reposts3 likes