If I run this directly from the vice monitor, (g 812) it works as expected : useless screen flashing until any key pressed.
If I run it from BASIC (sys 2066), it returns immediately, without any keys pressed (updates screen only once), until I added the "flush" code (my guess at what the problem was),
I.e. SYS 2066 doesn't work, SYS 2061 does.
; *=$80D / 2061
; jmp r1
; -------- BASIC "flush" code --------
r1
jsr keyscan
bne r1
; ---------------------------------------
; $812 2066
SEI
l1 INC $d021 ; screen bk color
jsr keyscan
beq l1
CLI
RTS
keyscan
LDA #$00
STA $DC00 ; test keyboard for any key pressed
LDA $DC01
CMP #$FF ; no key
rts
Winvice emulator behavior or standard C64 Basic ?
Re: Winvice emulator behavior or standard C64 Basic ?
A guess: if you start from Basic, there's already a key registered by the time it checks, because you still have your finger on the Return key.
Re: Winvice emulator behavior or standard C64 Basic ?
Sounds logical.
If I change the code to :
LDA #$7F
STA $DC00
it works.
Eliminates the RETURN column.
But ... this could lead to a discussion of how the CIA ports work
Assuming the Vice emulation is reasonably accurate.
What happens to the CIA when the $DC00 port is changed, as far as updating the DC01 port ?
It would seem there is some latency / delay between DC00 being changed and DC01 is updated.
Enough delay that reading DC01, is still showing the "old" value ?
If I change the code to :
LDA #$7F
STA $DC00
it works.
Eliminates the RETURN column.
But ... this could lead to a discussion of how the CIA ports work
Assuming the Vice emulation is reasonably accurate.
What happens to the CIA when the $DC00 port is changed, as far as updating the DC01 port ?
It would seem there is some latency / delay between DC00 being changed and DC01 is updated.
Enough delay that reading DC01, is still showing the "old" value ?
Re: Winvice emulator behavior or standard C64 Basic ?
You could also test with a little BASIC loop which then jumps to your routine, giving you time to get your finger off the key.
Re: Winvice emulator behavior or standard C64 Basic ?
Ya, about 80 seems to be the delay
5 poke 53281,0
6 for x=0to80 :next
7 rem *******
10 sys2212
5 poke 53281,0
6 for x=0to80 :next
7 rem *******
10 sys2212
-
White Flame
- Posts: 704
- Joined: 24 Jul 2012
Re: Winvice emulator behavior or standard C64 Basic ?
I believe that VICE polls the PC keyboard and updates the CIA keyboard matrix state once per frame, though I'm not certain.