7 SRA equ 0x3f0 ; Status Register A RO
8 SRB equ 0x3f1 ; Status Register B RO
9 DOR equ 0x3f2 ; Digital Output Register RW
10 TDR equ 0x3f3 ; Tape Drive Register RW
11 MSR equ 0x3f4 ; Main Status Register RO
12 DSR equ 0x3f4 ; Datarate Select Register WO
13 DFF equ 0x3f5 ; Data FIFO RW
14 DIR equ 0x3f7 ; Digital Input Register RO
15 CCR equ 0x3f7 ; Configuration Control Register WO
17 DOR_MOTD equ 0x80 ; Drive Motor 3 ON
18 DOR_MOTC equ 0x40 ; Drive Motor 2 ON
19 DOR_MOTB equ 0x20 ; Drive Motor 1 ON
20 DOR_MOTA equ 0x10 ; Drive Motor 0 ON
21 DOR_IRQ equ 0x08 ; Enable IRQs and DMA
22 DOR_NRESET equ 0x04 ; 0=enter reset mode, 1=normal operation
23 DOR_DSEL equ 0x03 ; Select drive number mask
25 MSR_RQM equ 0x80 ; It's OK (or mandatory) to exchange bytes with the FIFO IO port
26 MSR_DIO equ 0x40 ; FIFO expects an IN opcode
27 MSR_NDMA equ 0x20 ; Set while executing PIO mode read/write commands
28 MSR_BSY equ 0x10 ; Command Busy
29 MSR_ACTD equ 0x08 ; Drive 3 is seeking
30 MSR_ACTC equ 0x04 ; Drive 2 is seeking
31 MSR_ACTB equ 0x02 ; Drive 1 is seeking
32 MSR_ACTA equ 0x01 ; Drive 0 is seeking
34 DSR_288M equ 0x03 ; 2.88M floppy (1Mbps)
35 DSR_144M equ 0x00 ; 1.44M floppy (500Kbps)
37 ; Floppy drive commands
38 CMD_READ_TRACK equ 2 ; IRQ6
39 CMD_SPECIFY equ 3 ; set drive parameters
40 CMD_SENSE_DRIVE_STATUS equ 4
41 CMD_WRITE_DATA equ 5 ; write to disk
42 CMD_READ_DATA equ 6 ; read from disk
43 CMD_RECALIBRATE equ 7 ; seek to cylinder 0
44 CMD_SENSE_INTERRUPT equ 8 ; ack IRQ6, get status of last command
45 CMD_WRITE_DELETED_DATA equ 9
46 CMD_READ_ID equ 10 ; IRQ6
47 CMD_READ_DELETED_DATA equ 12
48 CMD_FORMAT_TRACK equ 13
50 CMD_SEEK equ 15 ; seek both heads to cylinder X
51 CMD_VERSION equ 16 ; used during initialization, once
53 CMD_PERPENDICULAR_MODE equ 18 ; used during initialization, once, maybe
54 CMD_CONFIGURE equ 19 ; set controller parameters
55 CMD_LOCK equ 20 ; protect controller parameters from reset
57 CMD_SCAN_LOW_OR_EQUAL equ 25
58 CMD_SCAN_HIGH_OR_EQUAL equ 29
60 CMD_MT equ 0x80 ; multitrack mode
61 CMD_MF equ 0x40 ; "MFM" magnetic encoding mode. Always set for read/write/format/verify
62 CMD_SK equ 0x20 ; Skip mode. Skips "deleted sectors"
75 ; read what types of floppy drives we have
78 mov byte [floppy_type], al
118 ; wait for the controller
121 and al, (MSR_RQM | MSR_DIO)
125 ; send version command
130 ; wait for version byte
140 ; wait for completion
146 and al, (MSR_RQM | MSR_BSY | MSR_DIO)
193 db "An error occured in the floppy driver", 10, 0
195 db "Floppy drive type: 0x", 0
197 db "Floppy drive version: 0x", 0
199 db "Resetting floppy drive...", 10, 0
201 db "Retrying last operating", 10, 0