Re: [cc65] Fast multi-key keyboard input on C64?

From: Chiron Bramberger <chiron1bramberger.com>
Date: 2010-11-30 01:48:39
I know for a fact that Cynthcart for the Commmodore 64 allows you to  
play 3-note chords by holding down 3 keys on the keyboard. Not only  
that, but if you hold down 2 keys with the left hand, and play a  
melody with the right hand, it works. This means that the software is  
able to detect a 3rd key-presses while another 2 are being held down.

But it's not perfect, some key combinations produce weird results.  
But most of the time, it's extremely well done considering how the  
keyboard works on CBM machines.

In any case, I think Paul Slocum did a great job is making a simple,  
playable Commodore 64 synth.

Here's the website
http://www.qotile.net/cynthcart.html

the zip file with the source code:
http://www.qotile.net/files/cynth1_2_4.zip

...and here, on line 956 of cynth1_2_4.asm, you'll find the beginning  
of the keyboard reading routine:
;------------------------------------------
; Read the keyboard
;------------------------------------------

for example there's parts like this:
	;------------------------------------------
	; determine which keyset to use
	; (raw/shift/commodorekey/runstop)
	;------------------------------------------

	; handle keytimer
	; (to avoid accidental keypresses on shifted keys)

	; skip key command check is 3 or more piano keys
	; are held to avoid quirks with C64 keyboard
	; matrix hardware.

So there's should be some interesting stuff there for the Commodore  
64. I can't personally comment on this yet, as I'm still focusing on  
PetSynth and the add-on hardware I'm making.

However, After glancing at it quickly, it looks like he's using  
several methods of reading the keyboard. This is what I found on the  
PET, that using more than one technique to read the keyboard works  
better depending on the situation. For example, reading the keyboard  
for playing music works better reading the PIA (I think) directly,  
but because it's not de-bounced, if you want to read a key to do some  
other function, like pressing an "up" or "down" key for selecting  
menu items or something, the de-bouncing becomes an issue because you  
end up overshooting your menu item.

Also from the PET, certain key combinations create special values in  
one part of the PIA (again, I think) so pressing "return" and "run  
stop" together create some new value in this one part of memory,  
whereas there's no other way of detecting this as the PET has no  
modifier keys (other than shift). So I've tried using the 7 special  
keys together to do things like ending the program with "RVS OFF" +  
"RUN STOP".

I don't know if this helps, but I hope it does!
-Chi





On 28-Nov-10, at 7:00 PM, Stefan Wessels wrote:

Hi,

2 Questions:

1)
I want to read the keyboard in a "raw" state.  I also need to be able  
to tell if multiple keys are down or not (direction and jump, for  
example).

Is the only way to do this to use the row/column checks on the CIA  
ports ($DC00 & DC01)?  Using cgetc, as well as looking at location  
197 doesn't work - only 1 key pressed.

Interestingly enough, kbhit() with cgetc() doesn't give a continuos  
stream, even when I put values in 650, 651 & 652.  The following  
illustrates:

#include <conio.h>

int main()
{
	char key;
	int i;
	
	*(char*)650 = 0x80;
	*(char*)651 = 0x01;
	*(char*)652 = 0x01;
	
	while(1)
	{
		key = 0x20;
		if(kbhit())
			key = cgetc() ;
		*(char*)0x400 = key;
		
		for(i = 0; i < 100; i++);
	}
	return 0;
}

This code has the key you are holding down (let's say 'Q') "flash" in  
the corner.  Without the for loop, you don't even see the character  
at all - it's put and replaced with a space before you see it (which  
seems odd - I would have expected a flash in sync with a raster scan  
at least sometimes?  Am I missing something again?).


2)
I once found web pages that had all the 6502 code listed that made up  
the routines like cgetc and showed what pusheax looked like, etc.  It  
was awesome.  I haven't been able to find this again.  Can someone  
please point me in the right direction?  I don't know if it was on  
the cc65 site or if someone else had done it.  Looked like ca65html  
generated pages, if I remember correctly.

Thank you
Stefan

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Nov 30 01:48:46 2010

This archive was generated by hypermail 2.1.8 : 2010-11-30 01:48:50 CET