#153906 - Jinroh - Tue Apr 08, 2008 2:36 am
I have a BG that I'm displaying and I'm trying to scroll it, however when I change my camX and camY and put them in the BG_HOFS and BG_VOFS registers my map scrolls like an Insane Man.
I mean it looks like it's scrolling, but it is just waaaay too fast.
THANKS!
_________________
The lone Wolf howls, driven by pride he presses on. Knowing not where he goes, but only where he wants to be.
~Me~
Code: |
typedef struct
{ u16 *tileData; //Pointer To the Tile Data In VRAM u16 *mapData; //Pointer To the Map Data In VRAM u8 mosaic; //Enable Mosaic Effect u8 colourMode; //16 or 256 u8 number; //The Background Number 0-3 u16 size; //The Size of the Background 128x128 256x256 or 512x512 u8 charBaseBlock; //Tell Which Character Base Block To Use u8 screenBaseBlock; //Tell Which Screen Base Block To Use u8 wrapAround; //Does The Map Wrap At Edges? s16 camX; //Map Camera X s16 camY; //Map Camera Y s32 rotX; //Rotation Cam X s32 rotY; //Rotation Cam Y s16 PA, PB, PC, PD; //Rotation Attributes }Background; Background BG; void enableBG(Background *bg) { u16 temp; bg->tileData = (u16*)CharBaseBlock(bg->charBaseBlock); bg->mapData = (u16*)ScreenBaseBlock(bg->screenBaseBlock); temp = bg->size | (bg->charBaseBlock << CHAR_SHIFT) | (bg->screenBaseBlock << SCREEN_SHIFT) | bg->colourMode | bg->mosaic; switch(bg->number) { case 0: REG_BG0CNT = temp; REG_DISPCNT |= BG0ENABLE; break; case 1: REG_BG1CNT = temp; REG_DISPCNT |= BG1ENABLE; break; case 2: REG_BG2CNT = temp; REG_DISPCNT |= BG2ENABLE; break; case 3: REG_BG3CNT = temp; REG_DISPCNT |= BG3ENABLE; break; } } void updateBG(Background *bg) { //Just Assume It's not Rotational for now switch(bg->number) { case 0: REG_BG0HOFS = bg->camX; REG_BG0VOFS = bg->camY; break; case 1: REG_BG1HOFS = bg->camX; REG_BG1VOFS = bg->camY; break; case 2: REG_BG2HOFS = bg->camX; REG_BG2VOFS = bg->camY; break; case 3: REG_BG3HOFS = bg->camX; REG_BG3VOFS = bg->camY; break; } } .... BG.number = 2; BG.charBaseBlock = 0; BG.screenBaseBlock = 28; BG.colourMode = BG_COLOR256; BG.size = ROTBG_SIZE_256x256; BG.mosaic = BG_MOSAIC_ENABLE; BG.camX = 120; BG.camY = 80; int i = 0; enableBG(&BG); for(i = 0; i < 256; i++) BGPaletteMem[i] = CoolMap_cmap[i]; u16 *tilePtr = (u16*)CoolMap_blockgfx; for(i = 0; i < (sizeof(CoolMap_blockgfx)/2); i++) BG.tileData[i] = tilePtr[i]; for(int y = 0; y < 32; y++) for(int x = 0; x < 32; x++) BG.mapData[(y * 32) + x] = (u16)CoolMap_map[y][x]; |
I mean it looks like it's scrolling, but it is just waaaay too fast.
THANKS!
_________________
The lone Wolf howls, driven by pride he presses on. Knowing not where he goes, but only where he wants to be.
~Me~