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 > Detecting ctrl and shift pressed simultaniously
2006-03-04 08:03
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....
 
2006-03-05 19:11
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. ;-)
2006-03-06 06:25
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
2006-03-06 09:31
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.
2006-03-06 10:06
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
2006-03-06 11:18
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.
2006-03-06 13:05
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
2006-03-06 13:22
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.
2006-03-06 16:33
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. :)
2006-03-06 18:16
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
2006-03-06 18:33
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
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
stephan-a
Guests online: 114
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 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Diskmag Editors
1 Magic  (9.8)
2 hedning  (9.6)
3 Jazzcat  (9.5)
4 Elwix  (9.1)
5 Remix  (9.1)

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