This is part 5 of a blog series I’m doing to catalog some of the programs I wrote back in 1988. I’m doing this because I like doing it, it brings back memories of how I started my career with computers, and my first attempts at programming using Z80 machine code. I’m also trying to fully understand how I programmed Disced and I’m relearning how things work on the old Amstrad CPC 6128.
Other parts of this series, including this one are listed below.
- Disassembling my old code part 8 – Processing HEX in the left pane
- Disassembling my old code part 7 – Drawing rectangles
- Disassembling my old code part 6 – Processing disc activities
- Disassembling my old code part 5 – Shift key & set translate <—- you are here
- Disassembling my old code part 4 – Cursor position & disc cache
- Disassembling my old code part 3 – Text operations
- Disassembling my old code part 2 – Screen mode & Soft 968
- Disassembling my old code part 1 – Getting started with WinAPE
So let’s resume where we left off, and that was going through the initial calls at the start of the program. Call L9388 is the next call that we need to understand so let’s get stuck in.
And here’s the source code in focus for that label.
From what I can make out it’s loading the C register with a value of &001A (DEC 26), and then it increases C by 1, before storing the value of C in the A register and then compares it to &0048 (DEC 72) and if so return, if not true it will make a call to the &BB30 firmware routine called KM GET SHIFT (KM=Keyboard Manager).
Now I’ll be honest, at this point I’ve no idea why I’m doing this yet but obviously it’s some sort of key press check. It’ll probably become clear later in my investigations.
Ok back to the routine. After making the call to &BB30 it does some additional instructions.
It loads the value of the A register into B, then subtracts &0041 (DEC 65) and then subtracts &001A, before jumping to L938A if C is reset, if not, it loads the C register into A and then calls the firmware &BB27 which is KM SET TRANSLATE which translates what a key should be if CTRL or SHIFT are not pressed at the same time. It then jumps back to L938A.
So based on the above, I’ll assume that this routine is for checking whether shift/ctrl are being pressed and name the routine accordingly, I can always change it later as necessary.
So here’s that routine all updated with new labels.
Resources used in this post
- Z80 Assembly tutorial – http://www.cpcwiki.eu/index.php/Where_to_learn%3F#Z80_Assembly_tutorial
- Z80 Heaven – http://z80-heaven.wikidot.com/instructions-set
- Zilog Z80 User manual – http://www.zilog.com/docs/z80/um0080.pdf
- Flags – http://jgmalcolm.com/z80/beginner/flag
- Soft 968 – https://archive.org/details/SOFT968TheAmstrad6128FirmwareManual/page/n127/mode/2up?q=bb30
That’s it for this part, see you again soon in the next part !