#93832 - LOst? - Fri Jul 21, 2006 4:08 pm
This is for the Nintendo DS, but should probably be the same on GBA.
I have a global variable declared like this:
This variable is accessible through every cpp file that have included the h file by doing this:
This works. Until the evil Vblank interrut reads the variable for the first time. The evil interrupt routine is part of the BLAH namespace and is working! Looks like this:
I get the sprite up. It is where mouse_x was at. But accessing mouse_x again, trying to update it's contents will fail.
Now I have tried a lot of things for a long time (including removing the namespace, saving copies of the variable before it enters the Vblank and restore it after, trying EWRAM_BSS declarations). I only ask for help when I am out of ideas.
Thanks for any help!
_________________
Exceptions are fun
I have a global variable declared like this:
Code: |
// h file: namespace BLAH { extern volatile s32 mouse_x; } // cpp file: namespace BLAH { volatile s32 mouse_x; } |
This variable is accessible through every cpp file that have included the h file by doing this:
Code: |
#include "h file" // You get the idea ok! { BLAH::mouse_x += 30; } |
This works. Until the evil Vblank interrut reads the variable for the first time. The evil interrupt routine is part of the BLAH namespace and is working! Looks like this:
Code: |
namespace BLAH { volatile SpriteEntry sprites [128]; void Vblank () { // Disable interupts REG_IME = 0; sprites [0].attribute [1] = ((sprites [0].attribute [1] & 0xFE00) | (mouse_x - 16) & 0x1FF); DC_FlushAll (); dmaCopy ((SpriteEntry*) sprites, OAM, 128 * sizeof (SpriteEntry)); // Vblank is done REG_IF = REG_IF; VBLANK_INTR_WAIT_FLAGS = REG_IF | REG_IE; // Enable interupts REG_IME = 1; } } |
I get the sprite up. It is where mouse_x was at. But accessing mouse_x again, trying to update it's contents will fail.
Now I have tried a lot of things for a long time (including removing the namespace, saving copies of the variable before it enters the Vblank and restore it after, trying EWRAM_BSS declarations). I only ask for help when I am out of ideas.
Thanks for any help!
_________________
Exceptions are fun