You are not logged in.
Pages: 1
So, I've been working on adding a menu to Pogoshell2GBA. Since I'm lazy, and PocketNES already has a pretty good menuing system, I decided to just copy it. The problem is, I don't understand interrupts on the GBA well enough (apparently), so I've become stuck quite quickly when it comes to mimicking the menuing system. So far, I have the following:
AGB_IRQVECT = 0x3007FFC
REG_BASE = 0x04000000
REG_P1 = 0x130
REG_INTERRUPT = 0x200
REG_IE = 0x00
REG_IF = 0x02
REG_IME = 0x08
...
ldr r5,=REG_BASE
add r5,r5,#REG_INTERRUPT
mov r0,#0
str r0,[r5,#REG_IME]
mov r0,#-1
strh r0,[r5,#REG_IF]
ldr r0,=0x1001
strh r0,[r5,#REG_IE]
ldr r1,=AGB_IRQVECT
adr r2,irqhandler
str r2,[r1]
mov r0,#1
strh r0,[r5,#REG_IME]
mov r0,#0
mov r3,#0
bl waitframe
bl drawmenu
...
waitframe:
stmfd sp!,{r0-r1}
mov r0,#0
mov r1,#1
swi 0x040000
ldmfd sp!,{r0-r1}
bx lr
irqhandler:
mov r2,#REG_BASE
add r2,r2,#REG_INTERRUPT
mov r3,#REG_BASE
ldr r1,[r2,#REG_IE]!
#r1=IE&IF
and r1,r1,r1,lsr#16
ldrh r0,[r3,#-8]
orr r0,r0,r1
strh r0,[r3,#-8]
strh r1,[r2,#REG_IF]
bx lr
I've confirmed that execution gets to the waitframe routine and that the 0x04000200-0x04000208 area looks right. But, when I set a breakpoint on the irqhandler, it doesn't seem to be called at all. I assume I'm missing something pretty major. Any pointers/suggestions?
There are four places for interrupts to be enabled and disabled:
* REG_IE
* REG_IME
* DISPSTAT
* The processor's CPSR register
DISPSTAT has three interrupt enable flags, one for HBLANK interrupts, one for VBLANK interrupts, and one for VCOUNT interrupts. Vblank IRQ enable is bit #3, hblank irq is bit #4, and vcount irq is bit #5.
CPSR has an interrupt disable bit which is bit #7. When set to 1, interrupts are disabled.
The interrupt disable bit can changed in every mode except user mode.
mrs r0,cpsr
bic r0,r0,#0x80 @clear "interrupt disable" bit
msr cpsr,r0
The other alternative:
Use devkitarm + libgba's interrupt functions. Really easy to use.
"We are merely sprites that dance at the beck and call of our button pressing overlord."
Offline
Thanks for the help. I wasn't setting DISPSTAT appropriately.
Pages: 1