Disk-ROM BIOS
This page was last modified 17:24, 7 April 2022 by Gdx. Based on work by Zeilemaker54.

Contents

Disk Driver table

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

 F8h for 360K floppy disk, 3,5 inch, sigle-side, 9 sector
 F9h for 720K floppy disk, 3,5 inch, double-side, 9 sector
 FAh for 320K floppy disk, 3,5 inch, sigle-side, 8 sector
 FBh for 640K floppy disk, 3,5 inch, double-side, 8 sector
 FCh for 180K floppy disk, 5,25 inch, sigle-side, 9 sector
 FDh for 360K floppy disk, 5,25 inch, double-side, 9 sector
 FEh for 160K floppy disk, 5,25 inch, sigle-side, 8 sector
 FFh for 320K floppy disk, 5,25 inch, double-side, 8 sector

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      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

401CH (DSKFMT)

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

A = If error: errorcode

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
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)

401FH (DSKSTP)

Effect: Stop the drive motor of the corresponding interface.
Input: None
Output: None
Modify: AF, BC, DE, HL, IX et IY.
Notes: Not all diskinterfaces support this entry. Only valid when 401FH <> 00H

Kernel table

4022H (BASENT)

Effect: BASIC cold start. Start the Basic environment and eventually run a file of Basic program from a program in machine language.

Set the variable REBOOT (0F340h) to 0 to run the AUTOEXEC.BAS file (at the root of the disk). Otherwise, there will be a return to Basic. Under MSX-DOS, when the REBOOT variable (0F340h) contains a value other than 0 it is possible to run another Basic program whose file name and length is specified in DTA (0080h).

Input: None
Output: None (Does not return)
Examples: 1/
; Quit your DOS program and launch a BASIC program saved as NAME.BAS

CALSLT	equ	001Ch
DTA	equ	0080h
BASENT	equ	04022h
REBOOT	equ	0F340h
MASTER	equ	0F348h

	org	0100h

	ld	a,1	; Not 0 to ignore the AUTOEXEC.BAS if present
	ld	(REBOOT),a

	ld	hl,NAME
	ld	de,DTA
	ld	bc,END-NAME
	ldir		; Copy the file name

	ld	ix,BASENT
	ld	iy,(MASTER-1)	; Slot of the Master Disk-ROM
	jp	CALSLT
NAME:
	db	END-NAME	; Length
	db	"NAME.BAS",0
END:

2/

; Quit your DOS program and go to BASIC

CALSLT	equ	001Ch
DTA	equ	0080h
BASENT	equ	04022h
REBOOT	equ	0F340h
TEMPST	equ	0F67Ah
MASTER	equ	0F348h

	org	0100h

	ld	a,1	; Not 0 to ignore the AUTOEXEC.BAS if present
	ld	(REBOOT),a

	ld	a,0
	ld	(DTA),a	; No file name

	ld	ix,(TEMPST)	; Erases 3 bytes
	ld	(ix),0	; from the
	ld	(ix+1),0	; area reserved for
	ld	(ix+2),0	; the BASIC program

	ld	ix,BASENT
	ld	iy,(MASTER-1)	; Slot of the Master Disk-ROM
	jp	CALSLT

3/

; Quit your DOS program and launch the AUTOEXEC.BAS under BASIC

CALSLT	equ	001Ch
BASENT	equ	04022h
REBOOT	equ	0F340h
TEMPST	equ	0F67Ah
MASTER	equ	0F348h

	org	0100h

	ld	a,0	; 0 to run the AUTOEXEC.BAS file
	ld	(REBOOT),a

	ld	ix,(TEMPST)	; Erases 3 bytes
	ld	(ix),0	; from the
	ld	(ix+1),0	; area reserved for
	ld	(ix+2),0	; the BASIC program

	ld	ix,BASENT
	ld	iy,(MASTER-1)	; Slot of the Master Disk-ROM
	jp	CALSLT

4025H (FORMTM)

Effect: Format a disk in BASIC by asking the user for settings.
This routine sets the Carry flag to 1 and then calls the FORMTK (04026h) routine below.
Input: None
Output: None
Note: This is interactive process with user (prompts for drive and format choice)

4026H (FORMTM)

Effect: Format a disk from a program with user-specified parameters.
Input: F = Reset the Carry flag
HL = Start of buffer
BC = Size of buffer
Output: None

4029H (MTOFF)

Effect: Stop all drives of all controllers
Input: None
Output: None
Modify: AF, BC, DE, HL, IX et IY.
Note: This routine only exists if the interface manages removable disks. Otherwise, 04029h will contain the zero byte (00h). Some HDD interfaces have wrongly implemented this as a HDD powerdown (HSH/MAK)

402DH (GETSLT)

Effect: Get slot ID of disk ROM
Input: None
Output: A = Slot ID

4030H

Effect: Get MSX-DOS system bottom
Input: None
Output: HL = Lowest address used by the base MSX-DOS system