This code works perfectly in Wabbitemu, but it fails on actual hardware. By looking at the calculator's display, it seems that the interrupt isn't even triggered at all. What am I doing wrong?
#include "ti83plus.inc"
.org $9d93
.db t2ByteTok, tAsmCmp
#define dwait in a,($10) \ rla \ jr c,$-3
start:
bcall(_delres)
di
dwait
ld a, 1
out ($10), a
dwait
ld a, 5
out ($10), a
dwait
ld a, $20
out ($10), a
dwait
ld a, $80
out ($10), a
im 2
ld a, $8B
ld i, a
ld hl, $8B00
ld (hl), $8A
ld de, $8B01
ld bc, $FF
ldir
ld hl, intRoutine
ld de, $8A8A
ld bc, intRoutine_End - intRoutine
ldir
ld a, %00001000
out ($03), a
ld a, $44
out ($30), a
ld a, 3
out ($31), a
ld a, 1
out ($32), a
ei
loop:
ld a, $FE
out ($01), a
ld hl, (soundNum) ;do something
nop
nop
in a, ($01)
bit 0, a
jr z, keyDownPress
bit 3, a
jr z, keyUpPress
ld a, $FD
out ($01), a
nop
nop
nop ;how much delay are you supposed to have?
nop
nop
nop
nop
in a, ($01)
bit 6, a
jr z, keyClearPress
jr loop
keyDownPress:
inc hl ;counterintuitive. I know.
ld (soundNum), hl
jr loop
keyUpPress:
dec hl
ld (soundNum), hl
jr loop
keyClearPress:
di
xor a
out ($31), a
out ($30), a
im 1
ld a, %00001011
out ($03), a
ei
ret ;bye bye
intSound:
ld a, $44
out ($30), a
ld a, 3
out ($31), a
ld a, 1
out ($32), a
call fillScreen
push bc
push hl
.db $21 ;ld hl,**
soundStore:
.dw $0100
dec h
jr nz, intSound_ret
.db $01 ;ld bc,**
soundNum:
.dw $1600
add hl, bc
.db $3E ;ld a,*
intSound_aSave:
.db $00
xor %00000011
ld (intSound_aSave), a
out ($00), a
intSound_ret:
ld (soundStore), hl
pop hl
pop bc
pop af
ei
ret
intRoutine:
push af
;int handling
;jump if port 30 interrupt
jp intSound
intRoutine_End:
fillScreen:
push af
push hl
ld hl, fillScreen_rowCount
inc (hl)
ld a, $C0
cp (hl)
jr nz, fillScreen_Draw
ld a, $80
ld (hl), a
out ($11), a
dwait
fillScreen_Draw
ld a, r
cpl
rlca
ld r, a
out ($11), a
pop hl
pop af
ret
fillScreen_rowCount:
.db 80
Thanks for your help!
EDIT1: I need to read port ($04) to acknowledge the interrupt timer. One would normally do this in a program, so most would not encounter the problem. it just seems like an odd hardware quirk to me.
EDIT2: Okay. I have now idea what is going on. I thought the above was a solution, but stuff is still acting weird.