| |
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 |
|
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
Adding a little delay to keyscan, like:
LDY #$20
LOOP
DEY
BNE LOOP
...rest of your code...
should fix. |
| |
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 :) |
| |
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... |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
probably there's more delay in case of exiting the monitor. |
| |
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 ? |
| |
Zyron
Registered: Jan 2002 Posts: 2381 |
Maybe start with emptying the keyboard buffer? |
| |
iAN CooG
Registered: May 2002 Posts: 3194 |
keybuffer is irrelevant when checking directly dc01 ;) |
| |
Zyron
Registered: Jan 2002 Posts: 2381 |
Heh, true.
I should maybe start with reading the thread? ;) |
| |
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. |
| |
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. |
... 1 post hidden. Click here to view all posts.... |
Previous - 1 | 2 - Next |