I do not use system VBI routines.
I tried to load SKSTAT during VBI, AND $04 and act on the results of that, i.e. interpreting anything not zero as a keypress. I then check for a specific KBCODE (Space) to enter the pause routine. After a little delay I check for SKSTAT and KBCODE again to end the pause when it is pressed again. That works as well but the game only stays "unpaused" when I keep the space bar pressed. then SKSTAT seems to remain "latched" as the game will end the pause but jump right back unless that key is held.
My understanding is that SKSTAT bit 2 should revert to zero if no key is depressed. In reality it seems to remain set (always?) and as KBCODE does not change when a key is released the next VBI jumps right back into the pause routine.
My code is below. Any ideas what I did wrong?
(The "PAUSECTR" and countdown from 4 in the PAUSING routine were intended to make sure the key is really depressed for a little while. The behaviour of the routine doesn't change when I leave them out, so I assume I am doing something wrong with SKSTAT.)
XITVBV equ $E462 NMIEN equ $D40E DLISTL equ $D402 DLISTH equ $D403 KBCODE equ $D209 SKSTAT equ $D20F SKCTL equ SKSTAT AUDF1 equ $D200 HITCLR equ $D01E CHECKKEYS LDA SKSTAT ;this is where VVBLKI points AND #$04 BEQ EXIT LDA KBCODE CMP #$21 BNE EXIT0 INC PAUSECTR LDA PAUSECTR CMP #$04 BNE EXIT2 PAUSE LDA #$00 STA NMIEN ;no more VBIs while pausing STA PAUSECTR LDA <PAUSEDLIST ;change to dedicated display list STA DLISTL LDA >PAUSEDLIST STA DLISTH LDA #$00 LDY #$03 KILLAUDIO STA AUDF1,Y DEY BPL KILLAUDIO PAUSING LDX #$04 KEYPRESSED LDA SKSTAT AND #$04 BNE PAUSING LDA KBCODE CMP #$21 BNE PAUSING DEX BEQ ENDPAUSE BNE KEYPRESSED ENDPAUSE LDA #$B8 STA DLISTL LDA #$35 STA DLISTH LDA #$C0 STA NMIEN STA HITCLR EXIT0 LDA #$00 EXIT STA PAUSECTR EXIT2 JMP XITVBV PAUSECTR .BY $00