I'm having some troubles though.
Enabling the VBlank interrupt with this code
CODE
irqInitHandler(irqDefaultHandler);
irqSet(IRQ_VBLANK, irqVBlank);
irqSet(IRQ_VBLANK, irqVBlank);
seems to always crash the emu.
I can do it the long way:
CODE
IME = 0;
IRQ_HANDLER = &irqVBlank;
IE = IRQ_VBLANK;
IF = ~0;
DISP_SR = DISP_VBLANK_IRQ;
IME = 1;
IRQ_HANDLER = &irqVBlank;
IE = IRQ_VBLANK;
IF = ~0;
DISP_SR = DISP_VBLANK_IRQ;
IME = 1;
but only if I have turned the power to the screen on first
CODE
POWER_CR = POWER_ALL_2D;
and even then dualis crashes after I start excecuting code.
Turning on a timer
CODE
TIMER2_CR = (TIMER_ENABLE | TIMER_DIV_256);
also crashes dualis if I haven't set the power cr yet.
Also I'm having problems with my bitmap backgrounds:
CODE
vramSetMainBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_BG, VRAM_C_SUB_BG, VRAM_D_SUB_SPRITE);
vramSetBankE(VRAM_E_MAIN_SPRITE);
vramSetBankI(VRAM_I_SUB_BG);
SUB_BG3_CR = BG_BMP8_256x256 | BG_BMP_BASE(BMP_BASE) | BG_PRIORITY_1;
for(int i = 0; i < 128*256; i++)
((u16*)BG_BMP_RAM_SUB(BMP_BASE))[i] = (u16)0;
vramSetBankE(VRAM_E_MAIN_SPRITE);
vramSetBankI(VRAM_I_SUB_BG);
SUB_BG3_CR = BG_BMP8_256x256 | BG_BMP_BASE(BMP_BASE) | BG_PRIORITY_1;
for(int i = 0; i < 128*256; i++)
((u16*)BG_BMP_RAM_SUB(BMP_BASE))[i] = (u16)0;
(note this code isn't a straight copy and paste there are other backgrounds being set-up, scaling registers being set etc...)
this crashes when I try to initialise the background, that is, on this line:
CODE
for(int i = 0; i < 128*256; i++)
((u16*)BG_BMP_RAM_SUB(BMP_BASE))[i] = (u16)0;
((u16*)BG_BMP_RAM_SUB(BMP_BASE))[i] = (u16)0;
I assume this is a VRAM thing but I don't really understand VRAM.
I can work up a demo for any of this if you like.
btw, mic, in my struggle to get various bitmap backgrounds going I stumbled upon your graphics notes and found them exTREMELY helpfull. thanks for posting them.