Disk ROM
This page was last modified 01:47, 29 January 2019 by Gdx. Based on work by NYYRIKKI.
4010H (DISKIO) (See PHYDIO in main BIOS)
Effect:	Physical input/output for disk devices

Input:  F = Carry set for write, carry reset for read
        A = Drive number (0=A:)
        B = Number of sectors to read/write
        C = Media descriptor
        DE = Logical sector number (starts at 0)
        HL = Transfer address

Output: F = Carry set on error, carry reset on success
        A = If error: errorcode
        B = Number of sectors transferred (always)

Error codes can be:
        0       Write protected
        2       Not ready
        4       Data (CRC) error
        6       Seek error
        8       Record not found
        10      Write fault
        12      Bad parameter
        14      Out of memory
        16      Other error
4013H (DSKCHG)
Effect:	Check if disk has been changed.

Input:  A = Drive number (0=A:)
        B = Media descriptor
        C = Media descriptor
        HL = Base address of DPB

Output: F = Carry set on error, carry reset on success
        A = If error: errorcode (see DSKIO)
        B = if success: 1=Disk not changed, 0=Unknown, -1=Disk changed

Note:   If the disk has been changed or may have been changed (unknown) read
        the boot sector or the FAT sector for a disk media descriptor and
        transfer a new DPB as with GETDPB
4016H (GETDPB)
Effect:	Get Drive Parameter Block

Input:  A = Drive number
        B = First byte of FAT (media descriptor)
        C = Media descriptor
        HL = Base address of DPB

Output: HL+1 ... HL+18 = DPB for specified drive

Note:   DPB consists of

Name   Offset Size Description
MEDIA    0     1   Media type (F8..FF)
SECSIZ   1     2   Sector size (must be 2^n)
DIRMSK   3     1   (SECSIZE/32)-1
DIRSHFT  4     1   Number of one bits in DIRMSK
CLUSMSK  5     1   (Sectors per cluster)-1
CLUSSHFT 6     1   (Number of one bits in CLUSMSK)+1
FIRFAT   7     2   Logical sector number of first FAT
FATCNT   8     1   Number of FATs
MAXENT   A     1   Number of directory entries (max 254)
FIRREC   B     2   Logical sector number of first data
MAXCLUS  D     2   (Number of clusters (not including reserved, FAT and
                   directory sectors))+1
FATSIZ   F     1   Number of sectors used
FIRDIR   10    2   FAT logical sector number of start of directory
4019H (CHOICE)
Effect:	Get string that describes disk formatting options.

Input:	None

Output:	HL = Address of zero terminated character string (ASCIIZ) with
                the text with choices for a DSKFMT
                If there is no choice (only 1 format supported) return HL ==0
Effect:	Format disk

Input:  A = Choice specified by user (1-9). See CHOICE
        D = Drive number (0=A:)
        HL = Begin address of work area
        BC = Length of work area
Output: F = Carry flag reset on success, carry flag set on error (see DISKIO for error codes)

Notes:  Also writes a MSX boot sector at sector 0, clears all FATs (media
        descriptor at first byte, 0FFh at second/third byte and rest zero)
        and clears the directory (filling it with zeros)
Effect:	Stop all local drives

Input:	None

Output:	None
Effect:	Start DiskBASIC

Input:	None

Output:	None (Does not return)
Effect:	Format disk using custom buffer

Input:	HL = Start of buffer
	BC = Size of buffer

Output:	None

Note:	This is interactive process with user
Effect:	Stop all drives on all controllers

Input:	None

Output:	None

Note:	Bad idea: This will stop floppy drive motors and power off HDD
	motors. (Do not start again automatically) Devices like CD-ROM 
	and Zip-drives usually handle stop commands as eject requests.
Effect:	Get slotID of disk ROM

Input:	None

Output:	A = SlotID
Effect:	Get MSX-DOS system bottom

Input:	None

Output:	HL = Lowest address used by the base MSX-DOS system