I'm doing a project using the Microchip C18 compiler. I have a struct called a block that points to other blocks (north east south west). These blocks will make me a map. I then have a pointer that I use to evaluate everything.
Just using RAM it looks like:
struct block{
struct block *north;
struct block *east;
struct block *south;
struct block *west;
};
struct block map[5] =
{ // just a simple line.
{ NULL, &map[1], NULL, NULL },
{ NULL, &map[2], NULL, &map[0]},
{ NULL, &map[3], NULL, &map[2]},
{ NULL, &map[4], NULL, &map[3]},
{ NULL, NULL, NULL, &map[4]}
};
struct block* position = &map[0];
This lets me do stuff like:
void goWest()
{
if(position -> west != NULL) position = position -> west;
}
Problem is that I've run out of RAM in my project and need to use ROM What I have so far is:
struct block{
rom struct block *north;
rom struct block *east;
rom struct block *south;
rom struct block *west;
};
rom struct block map[5] =
{ // just a simple line.
{ NULL, &map[1], NULL, NULL },
{ NULL, &map[2], NULL, &map[0]},
{ NULL, &map[3], NULL, &map[2]},
{ NULL, &map[4], NULL, &map[3]},
{ NULL, NULL, NULL, &map[4]}
};
I've done some debugging and can tell the above part works, but trying to make the position pointer is giving me grief. so I guess my question is:
How do I hold the ROM variable addresses in a pointer which I can edit the values of?
When i try:
struct block *position = &map[0];
I get "Warning [2066] type qualifier mismatch in assignment"
I realize that a ROM variable and RAM variable are two different things, but I have no idea what to do.