Page 1 of 1

Using key scan/read code

Posted: Sun Dec 01, 2019 1:39 pm
by Kitsune Mifune
Apologies for what must seem like a really thick question Keith, but I'm getting rid of the last bit of firmware use by incorporating your Key Scanning/Reading code into my program, but I'm a little stuck on how to actually check for a key press.

Like, how do you actually tell the computer if you push, for example "s", then do stuff?

With the firmware I just load the accumulator with the keycode of the key I want to push and then do a skip 'jr' over the "do stuff" code if it's not pushed, so what would be the equivalent of that using the Hardware Keyboard map in the key reading code?

(PS, the transparency code from my last post worked a treat, so cheers for that!)

Re: Using key scan/read code

Posted: Mon Dec 02, 2019 8:27 pm
by akuyou
Here you go... a sample file to read the keys and respond to S or T keys

Basically, the keyscanner routine reads in the lines of the keyboard into a 10 byte array, and you'll need to test those bits somehow to work out which keys are pressed - 1 means the key isn't pressed... 0 means it's pressed down.

The attached file has the layout of the keys in the layout they appear on the hardware (and resulting array) at the bottom... you can also see it here:
https://www.chibiakumas.com/z80/platform.php#LessonP6

Re: Using key scan/read code

Posted: Tue Dec 03, 2019 9:32 am
by Kitsune Mifune
Awesome, that's just what I was looking for!

Cheers!