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!)
Using key scan/read code
-
- Posts: 33
- Joined: Tue Oct 22, 2019 6:46 am
- Location: Glasgow
- Contact:
Using key scan/read code
Programming: 90% failures, 10% victories, and 100% hair loss!
Re: Using key scan/read code
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
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
- Attachments
-
- CPC_KeyTest.7z
- (1.09 KiB) Downloaded 817 times
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens
Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809
Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809
-
- Posts: 33
- Joined: Tue Oct 22, 2019 6:46 am
- Location: Glasgow
- Contact:
Re: Using key scan/read code
Awesome, that's just what I was looking for!
Cheers!
Cheers!
Programming: 90% failures, 10% victories, and 100% hair loss!