File: DRIVENUM.TXT - 22/08/1999 Subject: Informative text about drivenumbers in the MSX system By: Jon.DeSchrijder@rug.ac.be / Compjoetania TNG There are 3 different kinds of 'driveletters' or 'drivenumbers': 1. the local drivenumber 2. the physical drivenumber 3. the logical drivenumber Storage media are connected to the MSX by means of a diskinterface in a system slot. The software in such an interface is called a 'diskrom'. There can be a maximum of 4 diskinterfaces connected to one MSX. Each diskinterface can be used to control more than one drive. Example 1: in most MSX2 models there is already an internal diskrom present to control two floppydrives. Example 2: the partitions on a harddisk are treated as separate drives connected to one (hard)diskinterface The drives connected to each diskinterface are identified with their 'local drivenumber'. This is a number counting from 0 without any 'gaps'. If there are 5 drives connected to a diskinterface, their local drivenumbers *must* be 0, 1, 2, 3 and 4. When using the standard diskrom routines like DISKIO (#4010), the local drivenumber is passed in the A register. When the MSX computer is turned on, all diskinterfaces install themselves into the system. There is an 8-byte table at address #FB21: #FB21: number of drives connected to the 1st interface #FB22: slotcode of the 1st interface #FB23: number of drives connected to the 2nd interface #FB24: slotcode of the 2nd interface #FB25: number of drives connected to the 3rd interface #FB26: slotcode of the 3rd interface #FB27: number of drives connected to the 4th interface #FB28: slotcode of the 4th interface Each drive is given a physical drivenumber starting from the first interface. Example: if there are 3 drives connected to the first interface and two drives connected to the second and none to the other interfaces, then the situation is as follows: local drive 0 on the 1st interface = physical drive 1 local drive 1 on the 1st interface = physical drive 2 local drive 2 on the 1st interface = physical drive 3 local drive 0 on the 2nd interface = physical drive 4 local drive 1 on the 2nd interface = physical drive 5 The number of physical drives is limited to 8. (When a diskrom installs itself, it should check that no more than 8 physical drives are created.) Driveletters (e.g. A: B: ...) used in programs represent *always* logical drivenumbers. (There is one exception, see below) A: =always logical drive 1 B: =always logical drive 2 C: =always logical drive 3 ... H: =always logical drive 8 In DOS1 environment there is no difference between the logical and the physical drivenumber. So logical drive 1 corresponds with physical drive 1, etc. (Also in the case of 1 floppydrive with logical drives A: and B:, there are two physical drives 1 and 2.) In native DOS2 environment there can be difference between the logical and the physical drivenumber. This is achieved by using the command ASSIGN or by the DOS function call #6A. With ASSIGN you can remap a logical drive to another physical drive. Example: ASSIGN C: A: This will redirect all access to logical drive C: to the first physical drive. Note that in this case 'A:' represent the first *physical* drive. This is the only exception, in all other cases 'X:' represent a logical drive. When you want to access a drive directly, this is by using the standard diskromroutines like DISKIO (#4010), you need two things: the slotcode of the diskrom the drive is connected to and the local drivenumber of the drive you want to access. The following code can be used to do this: ;input: (drive) contains logical drivenumber (A:=1 B:=2 ...) ;output: (drive) contains physical drivenumber (A:=1 B:=2 ...) ; No Carry=diskrom found ; (local) contains local drivenumber on the interface ; (slot) contains slotcode of corresponding diskrom ; Carry=error diskrom not found LD C,#6F ;get DOS kernel version CALL BDOS LD A,B CP 2 JR C,DOS1 ;in DOS1 physical=logical number LD BC,(drive-1) ;C contains #6A LD D,#FF CALL BDOS ;get physical drivenumber JR NZ,DOS1 ;error ?! LD A,D LD (drive),A DOS1: LD A,(drive) ;get physical drivenumber (1..8) DEC A LD HL,#FB21 LD B,4 GETSLT: SUB (HL) JR C,FOUND INC L INC L DJNZ GETSLT SCF ;no diskrom found RET ;(unexisting logical drive or DOS2 ramdisk) FOUND: ADD A,(HL) LD (local),A INC L LD A,(HL) LD (slot),A OR A RET DB #6A drive DB 0 slot DB 0 local DB 0 Have fun with it!