6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue May 14, 2024 6:56 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Fri Feb 13, 2015 11:34 am 
Offline

Joined: Sat Dec 26, 2009 2:15 am
Posts: 39
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


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 13, 2015 11:48 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 13, 2015 1:05 pm 
Offline

Joined: Sat Dec 26, 2009 2:15 am
Posts: 39
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 ?


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 13, 2015 1:07 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 13, 2015 1:21 pm 
Offline

Joined: Sat Dec 26, 2009 2:15 am
Posts: 39
Ya, about 80 seems to be the delay

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


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 17, 2015 7:34 pm 
Offline

Joined: Tue Jul 24, 2012 2:27 am
Posts: 672
I believe that VICE polls the PC keyboard and updates the CIA keyboard matrix state once per frame, though I'm not certain.

_________________
WFDis Interactive 6502 Disassembler
AcheronVM: A Reconfigurable 16-bit Virtual CPU for the 6502 Microprocessor


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: