Page 1 of 1

Winvice emulator behavior or standard C64 Basic ?

Posted: Fri Feb 13, 2015 11:34 am
by mstram
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

Re: Winvice emulator behavior or standard C64 Basic ?

Posted: Fri Feb 13, 2015 11:48 am
by BigEd
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 ?

Posted: Fri Feb 13, 2015 1:05 pm
by mstram
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 ?

Re: Winvice emulator behavior or standard C64 Basic ?

Posted: Fri Feb 13, 2015 1:07 pm
by BigEd
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 ?

Posted: Fri Feb 13, 2015 1:21 pm
by mstram
Ya, about 80 seems to be the delay

5 poke 53281,0
6 for x=0to80 :next
7 rem *******
10 sys2212

Re: Winvice emulator behavior or standard C64 Basic ?

Posted: Tue Feb 17, 2015 7:34 pm
by White Flame
I believe that VICE polls the PC keyboard and updates the CIA keyboard matrix state once per frame, though I'm not certain.