Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > m.l. keyboard scan - WinVice or Basic behavior?
2015-02-13 11:26
mstram
Account closed

Registered: Dec 2013
Posts: 112
m.l. keyboard scan - WinVice or Basic behavior?

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
 
... 1 post hidden. Click here to view all posts....
 
2015-02-13 12:04
chatGPZ

Registered: Dec 2001
Posts: 11108
it returns immediatly when you run it from basic because you are still pressing the return key when the program checks the keyboard. the solution is indeed to wait for "no key" first :)
2015-02-13 12:19
Flavioweb

Registered: Nov 2011
Posts: 447
Gpz you are right: the "key" need to be debounced...
But there is one thing i can't understand: why "sys 2066" don't works and "g 0812" from monitor does (i tested this in vice with AR6)?
We are still press "return" in both cases...
2015-02-13 12:46
Oswald

Registered: Apr 2002
Posts: 5017
probably there's more delay in case of exiting the monitor.
2015-02-13 13:06
mstram
Account closed

Registered: Dec 2013
Posts: 112
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 ?
2015-02-13 16:20
Zyron

Registered: Jan 2002
Posts: 2381
Maybe start with emptying the keyboard buffer?
2015-02-13 16:22
iAN CooG

Registered: May 2002
Posts: 3132
keybuffer is irrelevant when checking directly dc01 ;)
2015-02-13 16:32
Zyron

Registered: Jan 2002
Posts: 2381
Heh, true.
I should maybe start with reading the thread? ;)
2015-02-13 16:39
TNT
Account closed

Registered: Oct 2004
Posts: 189
Quote: Gpz you are right: the "key" need to be debounced...
But there is one thing i can't understand: why "sys 2066" don't works and "g 0812" from monitor does (i tested this in vice with AR6)?
We are still press "return" in both cases...


When you press enter to exit VICE monitor, it "swallows" the key down event. Emulation part never sees it.
2015-02-13 17:13
Flavioweb

Registered: Nov 2011
Posts: 447
TNT i'm talking about the Action Replay crt monitor.
But yes, maybe the "g" command uses more cycles than SYS, so there is time for cia to detect the "no key pressed" condition... i suppose.
2015-02-14 14:07
chatGPZ

Registered: Dec 2001
Posts: 11108
Quote:
Gpz you are right: the "key" need to be debounced...

this has nothing to do with "debounce" actually. its as simple as that if you want to distinguish between two seperated keypresses, you have to wait for the first keypress to be over before you can check the next.
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Guests online: 121
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Fullscreen Graphicians
1 Carrion  (9.8)
2 Joe  (9.8)
3 Duce  (9.8)
4 Mirage  (9.7)
5 Facet  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.05 sec.