Winvice emulator behavior or standard C64 Basic ?

Topics pertaining to the emulation or simulation of the 65xx microprocessors and their peripheral chips.
Post Reply
mstram
Posts: 39
Joined: 26 Dec 2009

Winvice emulator behavior or standard C64 Basic ?

Post 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
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Winvice emulator behavior or standard C64 Basic ?

Post 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.
mstram
Posts: 39
Joined: 26 Dec 2009

Re: Winvice emulator behavior or standard C64 Basic ?

Post 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 ?
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Winvice emulator behavior or standard C64 Basic ?

Post 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.
mstram
Posts: 39
Joined: 26 Dec 2009

Re: Winvice emulator behavior or standard C64 Basic ?

Post by mstram »

Ya, about 80 seems to be the delay

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 ?

Post 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.
Post Reply