Hi, I'm making a game for the Arduboy and I have a question about storing things in program memory.
My game uses graphics stored as const char arrays. These are stored in program storage space using the PROGMEM keyword when declaring the arrays.
I also have a tile map array, which is a 3D array containing only 1s and 0s. The first dimension of the array is the level number, and the second two are the screen positions of tiles:
const unsigned char tileMap[2][8][16] = {
{ // Level 0:
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
},
{ // Level 1:
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
}
};
I use this array to draw a tile wherever a 1 exists, and nothing where a 0 exists. This all works fine, but the problem is that I can only have three one-screen levels before pushing the 2.5k RAM limits of the Arduboy.
I figured that since the level map array is constant, it could be stored in the much larger program space. However when I use the PROGMEM keyword in my array declaration like this:
const unsigned char tileMap[2][8][16] PROGMEM = {...
The memory calculation shown by the compiler is no different than it was without the PROGMEM keyword. Am I doing something wrong?
Thanks!