#177351 - MisterLogan - Sun Apr 29, 2012 9:48 pm
I am trying to move a variable (u16 MapBuffer[32*32];) declared in main, into a class (Map). So I'm switching from MapBuffer to Map.Buffer.
When I do this seemingly simple move, my game goes absolutely nuts. Looking through registers in desmume shows the BG3HOFS register is going crazy. The only thing in my code accessing that register is this code:
This function is called from main using this:
When I comment this function call out, the error stops.
MapBuffer/Map.Buffer are being accessed by two functions, but commenting them both out doesn't stop the error.
So yeah, what the heck is going on here?
When I do this seemingly simple move, my game goes absolutely nuts. Looking through registers in desmume shows the BG3HOFS register is going crazy. The only thing in my code accessing that register is this code:
Code: |
bool PlayerClass::CheckPlayerCollision() { return(true); } void PlayerClass::AcceptUserInput(int BG3Main_id) { int gfxOffset=0; ///start of animation (loop=0)========== if(AnimLoop == 0) { //Accept key presses scanKeys(); if (keysHeld() & KEY_RIGHT) {Input.X = 1; InputDirection=1;} else if (keysHeld() & KEY_DOWN) {Input.Y = 1; InputDirection=2;} else if (keysHeld() & KEY_LEFT) {Input.X = -1; InputDirection=3;} else if (keysHeld() & KEY_UP) {Input.Y = -1; InputDirection=4;} gfxOffset = ((InputDirection*2)-1) * 256*2; memcpy(pSpriteBase, GhostlyTiles_bin + gfxOffset, 256*2); } ///mid animation (loop=8)=============== if(AnimLoop == 8){ gfxOffset = ((InputDirection-1)*2) * 256*2; memcpy(pSpriteBase, GhostlyTiles_bin + gfxOffset, 256*2); } AnimLoop+=1; if(CheckPlayerCollision() == true) { c_BGPixels.X += Input.X; c_BGPixels.Y += Input.Y; } else { AnimLoop+=1; } bgScroll(BG3Main_id, Input.X, Input.Y); ///end of animation loop (loop=16)======= if(AnimLoop == 16) { AnimLoop=0; Input.X=0; Input.Y=0; InputDirection=0; } } |
This function is called from main using this:
Code: |
scanKeys(); if(keysHeld() & (KEY_RIGHT | KEY_DOWN | KEY_LEFT | KEY_UP) || Player.AnimLoop !=0) {Player.AcceptUserInput(BG3Main_id); iprintf("direction pressed\n");} |
When I comment this function call out, the error stops.
MapBuffer/Map.Buffer are being accessed by two functions, but commenting them both out doesn't stop the error.
So yeah, what the heck is going on here?