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: 11386
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: 463
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: 5094
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: 3193
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: 463
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: 11386
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
Mike
MWR/Visdom
katon/Lepsi De
t0m3000/hf^boom!^ibx
Chesser/Blazon
iAN CooG/HVSC
Magic/Nah-Kolor
Walt/Bonzai
saimo/RETREAM
Steffan/BOOM!
Andy/AEG
Freeze/Blazon
Scrap/Genesis Project
4gentE/ΤRIΛD
hedning/G★P
LightSide
Guests online: 110
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 No Listen  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

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