public class FloppyDriver
extends java.lang.Object
QL Floppy disks are FAT based. A FAT entry is 3 bytes long: the first 12 bits hold the file number, the last 12 bits the block number within the file. So, to find all blocks belonging to a file : get all FAT entries with the number of the file and order them according to the block number.
The first entry in every FAT is that of the FAT itself. The FAT itself is always file number $F80 in the FAT.
Special file numbers in the FAT are: - $000 - the directory - $F80 - the FAT - $FCF - cluster (block) is marked for deletion - $FDF - cluster (block) is free - $FDx - cluster (block) is free (belonged to a file and was deleted) - $FEF - cluster (block) is bad - $FFF - cluster (block) doesn't exist The root directory is always file zero.
NB the FAT is also called the "map". Most of the nitty-gritty of the floppy interface is handled by SMSQ/E itself, this driver mainly exposes routines to read/write a sector, and to handle formatting a disk.
Constructor and Description |
---|
FloppyDriver(MC68000Cpu cpu,
inifile.IniFile inifile)
Creates the object.
|
Modifier and Type | Method and Description |
---|---|
void |
checkDriveStatus()
Checks whether medium has changed.
|
void |
checkWriteProtect()
Checks whether medium is write protected.
|
void |
formatDrive()
This routine formats a medium.
;
; d0 cr format type / error code
; d1 cr format dependent flag or zero / good sectors
; d2 r total sectors
; d7 c p drive ID / number
; a3 c p linkage block
; a4 c p drive definition
|
void |
getDrive()
gets the native filename back to SMSQ/E
|
java.lang.String[] |
getNames(int deviceID)
Gets the names of the native files used for each drive of the device.
|
void |
readSector()
Reads a sector.
; (a7) sector to read
; d2 cp number of sectors to read
; d7 c p drive ID / number
; a1 c p address to read into
; a3 c p linkage block
; a4 c p drive definition
;
; status return 0 or ERR.MCHK
;
|
void |
setCPU(MC68000Cpu cpu2)
Sets the cpu for this object.
|
void |
setDrive()
Sets the native file name for a drive (called from SMSQ/E)
|
boolean |
setNames(java.lang.String[] names,
boolean doPopup,
int driveToSet)
Sets the names of the native files to be used for each drive of the device.
|
void |
setxCpu(MC68000Cpu cpu)
Sets the cpu used by the device driver.
|
void |
writeSector()
Writes a sector.
|
public static final int QL5A
public static final int QL5B
public FloppyDriver(MC68000Cpu cpu, inifile.IniFile inifile)
cpu
- the cpu used.inifile
- the .ini file with initial option values.public boolean setNames(java.lang.String[] names, boolean doPopup, int driveToSet)
In keeping with standard SMSQE practice, it is presumed throughout that each device may have 8 drives.
names
- an 8 element String array with names for the drives.doPopup
- = true if a popup should be popped up tellling about errorsdriveToSet
- if this is -1, set all drives, else set only the drive with that numbertrue
if names were set, else false
.
algorithm is as follows:
- Check whether a filename already exists. This will not be the case if this is called the very first time
- if a filename already exists, check whether that file is open (i.e. there is a valid channel to it)
- if a new file should NOT be opened
if an old file exists, close the old file,
erase the name in the native files array
- if a new file should be opened and can be opened : substitue new for old
- if a new file should be opened but cannot be opened
- if an old file exists, close it (should I leave it open)openpublic void readSector()
public void writeSector()
public void formatDrive()
public void checkDriveStatus()
public void checkWriteProtect()
public void setDrive()
public void getDrive()
public java.lang.String[] getNames(int deviceID)
In keeping with standard SMSQE practice, it is presumed throughout that each device may have 8 drives.
deviceID
- an int containing the name of the device for which the names are to be returned (eg 'NFA0', i.e. 0x0x4e464130).null
if the device ID wasn't mine.
Individual elements may be null
or empty if the corresponding drive isn't assigned.public void setxCpu(MC68000Cpu cpu)
cpu
- the cpu to be set.public void setCPU(MC68000Cpu cpu2)
cpu2
- the cpu to set.