In this version Command Codes are emulated to a certain extent, however any existing disc conversions probably won't work. I'm sorry, but due to the actual design of ROM3 an exact emulation would be impossible. But it is easy to adapt programs to work using DISCDOS - and +D programmers can do this too - it won't affect the operation of a +D/DISCiPLE.
In order for Command Codes to work the register sp must be stored somewhere (if you disassemble the standard ROM3 rst 8 code you'll see that sp is lost), the address that I've chosen to store it is at 23411 - in the system variables (the current line being renumbered store). This address must be kept up to date with the sp before every rst 8 call ie immediately before (DISCDOS has to know where to return to in the code right? Well, this is the only way to do it). There's another limitation, the register hl is always corrupted (feature of the rst 8 routine again....).
The following command codes are supported (descriptions are quoted from the +D manual):
HXFER 51 33h
Transfers the users file information area (UFIA) to the Disc File Channel Area (DFCA). IX must point to the first byte for your UFIA.
OFSM 52 34h
Opens a File Sector map using the information in the DFCA. Sets the disc buffer pointer (RPT) to the start of the sector buffer, after setting the header information in the first 9 bytes of the file.
HOFLE 53 35h
Open a file to write. IX must point to the UFIA. This command combines the functions of HXFER and OFSM.
SBYT 54 36h
Write a byte to the file sector buffer. If the sector is full the sector is saved and the RPT reset.
HSVBK 55 37h
Save a block of data to the disc. DE points to the start of the block, and BC holds the length of the data.
CFSM 56 38h
Close a file. This routine empties the disc buffer and writes the directory entry.
HGFLE 59 3Bh
Open a file to read from the disc. IX must point to the start of your UFIA. When returned the RPT points to the first byte of the file (usually the header information).
LBYT 60 3Ch
Load a byte from the sector buffer, and return it in the A register. If the buffer is empty another sector is read from the disc.
HLDBK 61 3Dh
Load a block of data from disc to memory address DE with block length BC.
WSAD 62 3Eh
Write the contents of the buffer to track D, sector E. And reset the RPT to the start of the disc buffer.
RSAD 63 3Fh
As WSAD except reading.
HERAZ 65 41h
Erase the file on the disc using the information in UFIA (as ever pointed to by IX)
PCAT 67 32h
Catalogue the disc using the information in the UFIA (transfer this using the HXFER. Make sure the drive and stream are set up. Byte +0Fh contains the following values:
02h - equivalent to CAT ! 04h - equivalent to CAT 12h - equivalent to CAT ! with a filename 14h - equivalent to CAT with a filename
The filename should be placed in UFIA+5, and may be wild.
HRSAD 68 44h
Read Sector to address (the same as BASIC LOAD @ command)
A = Drive DE = Track/Sector IX = Address to load to
HWSAD 69 45h
As HRSAD but write.
PATCH 71 47h
Simply tells you what system you are using, on a +D/DISCiPLE returns with the shadow ROM paged in, but obviously impossible for DISCDOS(!!). The hl value is set to 0 (+D), 1 (DISCIPLE) or in the case of DISCDOS - 2.
You can return to BASIC after using command code however thereturn value in bc is ignored. Actually I cheat on the return, in order to ensure a crash doesn't result, I scan the stack for 2D2Bh (the return address for USR no) and when I find it it is replaced with 23354 so control will be restored. I only search the previous 10 values on the stack, which if you want to return to BASIC should give you enough stack to play with.
The alternate registers are corrupted on exit. And if an error arises then return is made with carry set and a +D error code in a.
The memory configuration used for loading bytes is the same as that indicated by the address (23388) - keep it up to date!