| |
Laxity
Registered: Aug 2005 Posts: 459 |
Detecting ctrl and shift pressed simultaniously
OK.. here goes.
I need to find out if it's possible to detect simultanious key presses of both Ctrl and shift (both left and or right). The code I've written for detecting this works nicely in Vice, but the question is if the key matrix of the real c64 hardware allows this?
Unfortunately my 64 is broken, so I'm unable to investigate this myself. |
|
... 24 posts hidden. Click here to view all posts.... |
| |
zdzisek Account closed
Registered: Apr 2002 Posts: 33 |
It's rather advisable to test routines like this on a real thing - partly because of a different way of simultaneous key presses handling in Windows systems, and partly due to bugs in the emulators. For example, SHIFT handling is fucked up in VICE: hold left SHIFT, then hold the right one, release right SHIFT, and release the left one - VICE will think that the right SHIFT key is still pressed. Anyone up to fixing keyboard.c? ;-)
I reckon some fully reliable emulator detection routine could be written if someone took time to investigate it further, but it would require user interaction, so it's pointless anyway. ;-) |
| |
Hoogo
Registered: Jun 2002 Posts: 105 |
There was a way to distinguish 3 keys. I think this one worked: sei
main
lda#254
sta 2
ldy#0
lda#4
sty adr1a+1
sta adr1a+2
sty adr1b+1
sta adr1b+2
lda#255
ldy#0
sta $dc02
sty $dc03
.loop1a lda 2
sta $dc00
ldx#7
lda $dc01
.loop1b asl
bcs .nokey1
pha
adr1a lda 1024,x
ora#1
adr1b sta 1024,x
pla
.nokey1 dex
bpl .loop1b
lda#40
clc
adc adr1a+1
sta adr1a+1
sta adr1b+1
lda adr1a+2
adc#0
sta adr1a+2
sta adr1b+2
sec
rol 2
bcs .loop1a
lda#254
sta 2
ldy#0
lda#4
sty adr2a+1
sta adr2a+2
sty adr2b+1
sta adr2b+2
ldy#255
lda#0
sta $dc02
sty $dc03
.loop2a lda 2
sta $dc01
ldx#7
lda $dc00
.loop2b lsr
pha
bcs .nokey2
adr2a lda 1024
ora#2
adr2b sta 1024
.nokey2
lda#40
clc
adc adr2a+1
sta adr2a+1
sta adr2b+1
lda#0
adc adr2a+2
sta adr2a+2
sta adr2b+2
pla
dex
bpl .loop2b
lda adr2a+1
sec
sbc#<(8*40-1)
sta adr2a+1
sta adr2b+1
lda adr2a+2
sbc#>(8*40-1)
sta adr2a+2
sta adr2b+2
sec
rol 2
bcs .loop2a
jsr $e544
jmp main
|
| |
Laxity
Registered: Aug 2005 Posts: 459 |
Hmm.. Maybe I haven't done my homework. I'm not really doing anything with $dc02 and $dc03 (CIA1 post A/B data direction registers) in my input routines. Do these really need to be reset to read/write each time I attempt to scan the keyboard matrix, as long as I don't have the kernal changing the state of the CIA?.. As far as I can see CIA2 is used for serial comm, so once the port directions have been setup propertly on CIA1, they ought to remain as such. Or am I mistaken? (Edit: I'm using kernal to read and write to and from disk, nothing else...)
Works in Vice this way, but I do not trust the emulator on that account. |
| |
WVL
Registered: Mar 2002 Posts: 902 |
Quote: Hmm.. Maybe I haven't done my homework. I'm not really doing anything with $dc02 and $dc03 (CIA1 post A/B data direction registers) in my input routines. Do these really need to be reset to read/write each time I attempt to scan the keyboard matrix, as long as I don't have the kernal changing the state of the CIA?.. As far as I can see CIA2 is used for serial comm, so once the port directions have been setup propertly on CIA1, they ought to remain as such. Or am I mistaken? (Edit: I'm using kernal to read and write to and from disk, nothing else...)
Works in Vice this way, but I do not trust the emulator on that account.
with dc02/dc03 you set dc00/dc01 to input or output..
for reading keys, you should do this :
ldx #$ff ;port dc00 = outputs
stx $dc02
inx ;port dc01 = inputs
stx $dc03
|
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Quote: It's rather advisable to test routines like this on a real thing - partly because of a different way of simultaneous key presses handling in Windows systems, and partly due to bugs in the emulators. For example, SHIFT handling is fucked up in VICE: hold left SHIFT, then hold the right one, release right SHIFT, and release the left one - VICE will think that the right SHIFT key is still pressed. Anyone up to fixing keyboard.c? ;-)
I reckon some fully reliable emulator detection routine could be written if someone took time to investigate it further, but it would require user interaction, so it's pointless anyway. ;-)
Oh there are better ways to check for an emulator... ways that don't require user input :D
Anyways, i think you can never fix an emulator to emulate the keyboard 100% since the keyboard matrixes used nowadays should work a little different concerning short-circuits than the c64 one, since there are more lines and the keys are connected differently to that matrix. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
@wvl: you can ofcourse also swap the two ports and use $dc00 as input and $dc01 as output. if you want a truely 100% scanner (which maybe should even still work together with joysticks) you might want to check both directions AND exploit the output/output thing too |
| |
WVL
Registered: Mar 2002 Posts: 902 |
Quote: @wvl: you can ofcourse also swap the two ports and use $dc00 as input and $dc01 as output. if you want a truely 100% scanner (which maybe should even still work together with joysticks) you might want to check both directions AND exploit the output/output thing too
urgh.. i have no idea :)
this is the routine i use for checking CERTAIN keys..
checkforkeys
ldx #5 ;number of keys-1 to check
checkkeyloop
lda keycolumn,x
sta $dc00
lda $dc01
eor #$ff
ldy keyindex,x
and keyrow,x
sta $00,y
dex
bpl checkkeyloop
keycolumn ;6 bytes
.byte $7f,$fd,$bf,$7f,$bf,$df ;runstop,lshift,/,space,poundkey,p
keyrow ;6 bytes
.byte $80,$80,$80,$10,$01,$02
keyindex ;6 bytes
.byte <exitkey,<leftflipper,<rightflipper,<tiltkey,<crsrdown,<pausekey
it will set the zp-adress for each key to 0 if it was not pressed, any other value means it is pressed.
|
| |
zdzisek Account closed
Registered: Apr 2002 Posts: 33 |
Quote: Oh there are better ways to check for an emulator... ways that don't require user input :D
Anyways, i think you can never fix an emulator to emulate the keyboard 100% since the keyboard matrixes used nowadays should work a little different concerning short-circuits than the c64 one, since there are more lines and the keys are connected differently to that matrix.
http://www.hoxs64.com/ <- try out this one. It passes the Emu-Fuxx0r v1/v2 tests and SounDemon's Waveform Composer emulation detection. Any new test routines that can be used to further improve the emulation are very welcome. :) |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
zdzisek: you're not the authfor of hoxs, are you? i have some emu-checks up my sleeve but didnt care to hack them down so far.. :D |
| |
zdzisek Account closed
Registered: Apr 2002 Posts: 33 |
Quote: zdzisek: you're not the authfor of hoxs, are you? i have some emu-checks up my sleeve but didnt care to hack them down so far.. :D
No, I ain't the one behind Hoxs64 - I've been closely following the project since its emulation improved, and reported a couple of flaws to the author. I can pass the checks on to him (admittedly, I would like to have a peek myself ;-) if needed. |
Previous - 1 | 2 | 3 | 4 - Next |