#176695 - GLaDOS - Thu Sep 15, 2011 5:16 am
Most of my game is in mode 0, but I want to use mode 3 for the victory screen. However, I can't get mode switching to work. No matter what I do, I get random garbage unless the game starts in mode 3 and never switches away. If I start in mode 0 and later switch to mode 3, it refuses to display anything.
Is this a problem with the emulator (VBA-M)? Is there some caveat to mode switching? What am I doing wrong?
Is this a problem with the emulator (VBA-M)? Is there some caveat to mode switching? What am I doing wrong?
Code: |
#include "GBA/mylib.h"
#include "GBA/bgmanager.h" #include "GBA/spritemanager.h" #include "physics.h" #include "input.h" #include "GBA/dma.h" #include "GBA/victory.h" ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setVictoryScreen() { REG_DISPCNT = Mode(3) | BG2_ENABLE; DMA[3].src = VICTORY; DMA[3].dst = (vu16*)(0x06000000); //Will actually overwrite 96kb worth of memory, not just 1 block DMA[3].cnt = VICTORY_SIZE/2 | DMA_ON | DMA_NOW | DMA_32 | DMA_SOURCE_INCREMENT | DMA_DESTINATION_INCREMENT; REG_DISPCNT = Mode(3) | BG2_ENABLE; } int main() { //REG_DISPCNT = Mode(3) | BG2_ENABLE; //REG_DISPCNT = Mode(0) | BG0_ENABLE | SPRITES_ENABLE | SPRITE_INDEXING_1D | WIN0_ENABLE; REG_DISPCNT = Mode(0) | BG0_ENABLE | SPRITES_ENABLE | SPRITE_INDEXING_1D; //REG_DISPCNT = Mode(1) | BG0_ENABLE | BG1_ENABLE | SPRITES_ENABLE | SPRITE_INDEXING_1D; //Set Background Control Register BG_Init(); LoadSpriteTiles(); HideSprites(0); //Must be called since initially, uninitialized sprites are visible newGame(); //Start game loop //while (!victory()) while (false) { update(pollLR(), pollUD(), pollA(), pressedZ(), pressedX(), pollUp()); if (pressedEnter()) {restartLevel();} if (pressedEsc()) {newGame();} while(SCANLINECOUNTER >= 160); while(SCANLINECOUNTER < 160); draw(); } while(SCANLINECOUNTER >= 160); while(SCANLINECOUNTER < 160); setVictoryScreen(); while (1) {} } |