Wait for a NMI [?]
Posted: Tue Jan 26, 2010 8:16 pm
- AFAIK, the JMP $current_pc is used to wait for a NMI.
- Is there another way? I'd like to improve my NSF player.
- Is there another way? I'd like to improve my NSF player.
Code: Select all
nmi_handler:
inc nmis
rti
wait_for_vblank:
lda nmis
:
cmp nmis
beq :-
rts
Code: Select all
vblank equ [some byte in zp]
NMI
~code~
INC vblank
~more code~
RTI
Wait_For_Vblank
LDA #$00
STA vblank
Wait_For_Vblank_Loop
LDA vblank
BEQ Wait_For_Vblank_Loop
RTSCode: Select all
interrupt.nmi int_nmi() {
int_nmi_func()
}
function int_nmi_func() {
ldx #1
stx inVBlank
...Other code
}
inline int_waitVbl() {
vid_getPPU_CTRL_1()
and #CR_NMI
if(true) {
do {
lda inVBlank
} while(zero)
lda #0
sta inVBlank
} else {
vblank_wait()
//Call our nmi routine because interrupts are not set
int_nmi_func()
unvblank_wait()
}
}
inline vblank_wait()
{
do
lda PPU.STATUS
while(is plus)
}
inline unvblank_wait()
{
do
lda PPU.STATUS
while(is minus)
}