
|
The MSX disk routines A.Siersema, 09-10-94
The MSX disk routines
=====================
Author: Albert Siersema
FidoNet : Albert Siersema at 2:282/517
InterNet : appie@prgbbs.idn.nl (subdue to change)
SnailMail: Sloep 303
9732 CT Groningen
The Netherlands
BBS : Filosoft/PROGRAMMERS BBS
+31-50-412288 or +31-50-426071
Version: 1.0
Date : 9 Oct 1994
Definition: MSX-DOS are the routines in the diskROM, not the MSXDOS.SYS and
COMMAND.COM files to run the MS-DOS clone for MSX.
The MSX has the same file system as MS-DOS. This documentation does not
include a description of the FAT based MS-DOS file system.
Following applies to MSX-DOS version 1.x. ROMs with DOS 2.x work different
as far as we know. We experimented with DOS 2.3x but haven't gotten any
results upto know. All knowledge about DOS 2.x is welcome though !
The routines:
DRIVES Return number of connected drives
DSKIO Sector(s) read/write
DSKCHG Check disk change status
GETDPB Get Drive Parameter Block
CHOICE Get FORMAT choice string
DSKFMT (low level) Format a disk: physically and logically
Not described in here and not necessary for an MSX emulator:
INIHRD Init hardware
INIENV Initialize environment
OEMSTATEMENT New statements
DISKIO (#4010)
--------------
Input: [F] carry set for write
carry reset for read
[A] Drive number (0=A:)
[B] Number of sectors to 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 in [A] can be:
0 Write protected
2 Not ready
4 Data (CRC) error
6 Seek error
8 Record not found
10 Write fault
12 Other errors
DSKCHG (#4013)
--------------
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 unchanged, 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
GETDPB (#4016)
--------------
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
CHOICE (#4019)
--------------
Output: [HL] Address of zero terminated character string with the text
with choices for a DSKFMT
If there is no choice (only 1 format supported) return [HL]=0
DSKFMT (#401C)
--------------
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
Notes: 1) 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)
2) Error codes are:
0 Write protected
2 Not ready
4 Data (CRC) error
6 Seek error
8 Record not found
10 Write fault
12 Bad parameter
14 Insufficient memory
16 Other errors
*********************** BDOS ROUTINES IN MSXDOS1 ROM ***********************
This is a very fast composed list of the addresses of the BDOS routines in
a MSXDOS1 ROM (like those that can be found in nearly all MSX-1 and -2
machines if they have a disk drive).
Check out the MSX-DOS 2 references for a list of all BDOS entries and their
parameters. These references can be found at nic.funet.fi (DOS2FUNC.* etc).
Address BDOS function Meaning
------- ------------- -----------------------------------------------------
05058h 01ah Set DMA address
0504eh 018h Get Login Vector
050D5h 0eh Select Disk
0505Dh 01bh Get Allocation
Below are all routines that have an FCB as input
04FB8h 011h Search First (or Find First)
05006h 012h Search Next (or Find Next)
04462h 0fh Open File
0456Fh 010h Close File
047b2h 027h Random Block Read
050c8h 024h Set Random Record
04788h 021h Random Read
0501eh 023h Get File Size
0436Ch 013h Delete File
04775h 014h Sequential Read
0477Dh 015h Sequential Write
0461Dh 016h Create File
04392h 017h Rename File
04793h 022h Random Write
047BEh 026h Random Block Write
047D1h 02bh Block Write With Zero Fill
|