The Viejo 20 uses one or two Antiquon 5802 disk controllers to interface with its floppy disk drive(s). Each disk controller is accessible in memory at the following addresses:
| Address | Description |
|---|---|
| 0xC010 | Primary controller: Sector Select Register 1 |
| 0xC011 | Primary controller: Sector Select Register 2 |
| 0xC012 | Primary Controller: Drive Status Register |
| 0xC013 | Primary Controller: Main Status Register |
| 0xC014 | Primary Controller: Command Data |
| 0xC015 | Primary Controller: Data |
| 0xC016 | Primary Controller: Interrupt Control Register |
| 0xC017 | Primary Controller: Scratchpad Register |
| 0xC018 | Secondary controller: Sector Select Register 1 |
| 0xC019 | Secondary controller: Sector Select Register 2 |
| 0xC01A | Secondary Controller: Drive Status Register |
| 0xC01B | Secondary Controller: Main Status Register |
| 0xC01C | Secondary Controller: Command Data |
| 0xC01D | Secondary Controller: Data |
| 0xC01E | Secondary Controller: Interrupt Control Register |
| 0xC01F | Secondary Controller: Scratchpad Register |
The primary disk controller is connected to line IR2 of the interrupt controller, and the secondary controller is connected to line IR3. Sectors of 512 bytes are used, so each 5¼" 360-KB floppy disk has the following geometry:
| Sides | 2 |
|---|---|
| Tracks per side | 40 |
| Sectors per track | 9 |
Sector addresses are given as SIDE:TRACK:SECTOR in this documentation, where sides are numbered from 0 to 1, tracks are numbered from 0 to 39, and sectors are numbered from 0 to 8.
To read a sector from a disk, the drive motor must first be turned on by setting bit 0 of the Drive Status Register. If the motor was not already on, the program should wait for up to a second to allow the drive to spin up.
The head, track, and sector indices must be written to the Sector Select Registers, and the Read Sector command issued by sending the command number (0x10) to the Command Data port. If interrupts have been enabled, the program may wait for an interrupt to signal the completion of the command. Otherwise, the program must poll the Main Status Register until the Busy bit becomes 0.
Once the command has completed, the program should check the Main Status Register bits to ensure that no error occurred; if all error bits are 0, 512 bytes of data may be read sequentially from the Data port.
The drive motor may be turned off once the command has completed, or left on for a short period of time to prevent spin-up delays on future commands.
To write a sector to disk, the drive motor must first be turned on by setting bit 0 of the Drive Status Register. If the motor was not already on, the program should wait for up to a second to allow the drive to spin up.
The head, track, and sector indices must be written to the Sector Select Registers, and the Write Sector command issued by sending the command number (0x20) to the Command Data port. 512 bytes of sector data must then be written sequentially to the Data port. If interrupts have been enabled, the program may wait for an interrupt to signal the completion of the command. Otherwise, the program must poll the Main Status Register until the Busy bit becomes 0.
Once the command has completed, the program should check the Main Status Register bits to ensure that no error occurred; if all error bits are 0, the command was successful.
Sector Select Register 1 is used to select the track of the next disk operation, and may be set to any value from 0 to 39. Sector Select Register 2 is used to select the head and sector of the next disk operation, and contains the following fields:
| Bit(s) | Description |
|---|---|
| 0–6 | Sector index (0 to 8) |
| 7 | Head (0 or 1) |
This register is used to check and control the state of the disk drive. It contains the following bits:
| Bits | R/W | Description |
|---|---|---|
| 0 | R/W | 1=Drive motor on |
| 1 | R | 1=Disk present |
| 2 | R | 1=Disk is write-protected |
| 3 | R | 1=Read/write head is on track 0 |
| 4 | R | 1=Read/write head is at beginning of track |
| 5 | R | 1=Head is moving outwards; 0=Head is moving inwards |
| 6 | R | 1=Head is moving |
| 7 | R | 1=Drive is attached |
This register is used to check the state of the controller. It contains the following read-only bits:
| Bit | Description |
|---|---|
| 0 | 1=Busy (currently executing command) |
| 1 | 1=Seek error in last command: Track not found |
| 2 | 1=Seek error in last command: Sector not found |
| 3 | 1=Seek error in last command: Hardware error |
| 4 | 1=Data error in last command |
| 5,6 | Reserved |
| 7 | 1=Drive error in last command (see Drive Status Register) |
This register is set to value 0x01 when a command begins executing, and the individual bits are filled in once the command completes.
Commands are started by issuing a byte to this port. Valid command bytes are:
| Command number | Description |
|---|---|
| 0x00 | Recalibrate drive. (Seeks to track 0.) |
| 0x10 | Read sector. |
| 0x20 | Write sector. |
| 0x30 | Seek to sector. |
| 0x40 | Format track. |
All other command numbers are reserved.
Sector data can be read or written sequentially from this port. At the completion of a read command, contents of the disk read buffer can be read sequentially through this port, and before a write command, contents of the write buffer can be written sequentially through this port.
This register controls interrupt generation, and allows acknowledgement of interrupts. It contains the following bits:
| Bit | Description |
|---|---|
| 0 | 1=Interrupt active (R/W) |
| 1 | 1=Enable interrupts at command completion |
| 2 | 1=Enable interrupts at medium change |
If an interrupt has been generated and is in service, bit 0 will read as 1; clearing this bit acknowledges the interrupt. Setting bit 1 causes an interrupt to be generated at successful or unsuccessful completion of any command, and setting bit 2 causes interrupts to be generated whenever a disk is removed or inserted.