This is part 6 of a blog series I’m doing to catalog some of the programs I wrote back in 1988, starting with a disc sector editor I wrote called Disced. I’m doing this because I like doing it, it brings back memories of how I started my career with computers.
Previous parts (including this one) are listed below.
- Disassembling my old code part 6 – Processing disc activities (this part)
- Disassembling my old code part 5 – Get Shift key and set translate
- Disassembling my old code part 4 – Set cursor position and disc cache
- Disassembling my old code part 3 – Text operations
- Disassembling my old code part 2 – Setting screen mode and using Soft 968
- Disassembling my old code part 1 – Getting started with WinAPE
So it turns out the last part I did for some reason I didn’t save my edits to the assembly, doh. But luckily I had screenshots of the edits so it didn’t take long to fix. Let’s resume with the next call in the start of the program and that is call &9440.
And here’s the code before I’ve added comments or labels but with some tabbing to make it easier to read and in addition, I’ve removed a spurious label and excess characters, for example, the original source code was exported from WinAPE as CP &00FC but it should really be CP &FC and I did this by comparing the ‘real’ code in the left disassembly to the source code in notepad++.
So here’s a quick before
Now that that section is cleaned up, what does it actually do ? Well from the labels that are already present I guess it’s doing something with the cursor position, then calling a firmware function called &BB1B which is shown below. This firmware call is KM_READ_KEY.
Just glancing at this code routine, I couldn’t really figure it out so I completely NOP’d out the call, and restarted the program, after doing so I could see the moving from track to track and sector to sector was no longer working, so it’s clearly something to do with that functionality or initialization of it.
While hacking it I also discovered where the current track and current sector values are stored, so I added that info to the source code.
After making those discoveries I looked further into the routine and found it was calling &BCD4 which is a firmware call listed below. Notice how (if found) that the C register contains the ROM value of interest.
So armed with that knowledge I updated the source code…
And some more digging led me to this bit of info:
AMSDOS Hidden RSX Functions
[C006h] INIT ;in/out: DE=LORAM, HL=HIRAM, CY=? chr(81h) MESSAGE_ON_OFF ;in: A=flag(00h=on, >=01h=off) (R,I,C) ;out:A=old chr(82h) SET_DRIVE_SPEED ;in: HL=ptr to 9 bytes chr(83h) SET_DISK_TYPE ;in: A=type (0xh=IBM, 4xh=CPM, Cxh=DATA) chr(84h) READ_SECTOR ;in: E=drv, D=trk, C=sec, HL=dest chr(85h) WRITE_SECTOR ;in: E=drv, D=trk, C=sec, HL=src chr(86h) FORMAT_TRACK ;in: E=drv, D=trk, C=sec1, HL=ptr to 9x4 byte chr(87h) SEEK_TRACK ;in: E=drv, D=trk, out: cy=1=okay chr(88h) TEST_DRIVE ;in: A=drv, out: cy=1=okay chr(89h) SET_RETRY_COUNT ;in: A=retry count (default=10) (01h..(1)00h)
To test this I added breakpoints in WinAPE’s disassembler by right clicking in the disassembled code and choose toggle breakpoint and then I stepped through the code.
By doing this I could clearly see the use of &84 to READ_SECTOR and &85 to WRITE_SECTOR as in this example, notice how when I pressed CTRL+W (to write the sector) it placed &85 in the marked square, and that is to WRITE_SECTOR.
So now I know that this routine deals with the interpretation of reading and writing to the sectors/tracks, so for now I’ll label it as Process_disc_activities.
This leaves me with some labels that I’m still not sure what they are for but I’ll return to them in the next part. For now though, here’s the routine I’ve worked on in this blog post.
So that’s it for this part, see you next time !
- Getting started with WinAPE – https://www.chibiakumas.com/z80/index.php#Lesson1
- Amsdos hidden RSX functions – http://www.cpcwiki.eu/index.php/BIOS_Function_Summary
- RST &18h – http://jgmalcolm.com/z80/intermediate/rstc
- Reading a disc sector – https://www.cpcwiki.eu/index.php/Programming:Reading_a_sector_from_a_disc