The Command code routines
THE 'TRANSFER UFIA TO DFCA' SUBROUTINE
This subroutine is called by using command code 51 (#33), it transfers the file
description and header (UFIA) to the Disk File Channel Area (DFCA). On entry IX must
point to the start of the User's File Information Area (UFIA).
2F8B HXFER PUSH IX
2F8D POP HL
2F8E LD DE,#3E01 Start of 'UFIA1'.
2F91 LD BC,24
2F94 LDIR Transfer the UFIA to 'UFIA1'.
2F96 LD IX,#3AC3 IX points to the DFCA.
2F9A CALL #0702,TEST_DRV Check if the specified drive is
2F9D RET defined.
THE 'OPEN FILE SECTOR MAP' SUBROUTINE
This subroutine is called by using command code 52 (#34), it Opens a File Sector Map
with the information contained in the DFCA. On entry IX must point to the UFIA, a call to
'HXFER' above transfers the UFIA to the DFCA. A return is made with the disk buffer
pointer (RPT) set to the start of the disk buffer in the +D RAM. 'OFSM' should be used
for files which don't contain a 9 byte header at the start of the file.
2F9E OFSM CALL #2F8B,HXFER Transfer UFIA to DFCA.
2FA1 JP #0AD9,OFSM_2 Open the file sector map.
THE 'OPEN A FILE' SUBROUTINE
This subroutine is called by using command code 53 (#35), it opens a file for SAVEing.
As with the preceeding subroutines IX must point to the UFIA. By calling 'OFSM' above the
UFIA is transferred to the DFCA and the file sector map is opened. Finally 'SAVE_HEAD1'
is called to transfer the 9 bytes file header to the file. 'HOFLE' can be used for files
which contain the 9 byte header.
2FA4 HOFLE CALL #2F9E,OFSM Transfer UFIA to DFCA and open the file
sector map.
2FA7 CALL #2879,SAVE_HEAD1 Transfer the 9 byte file header to the
2FAA RET file and exit.
THE 'SAVE BLOCK TO DISK' SUBROUTINE
This is called by using command code 55 (#37). The data block starting at address DE
with length BC is SAVEd to disk.
NOTE: A file has to be opened for SAVEing before writing bytes. Use 'HOFLE' or 'OFSM' to
do this.
2FAB HSVBK CALL #2FCB,BCDE_DEHL Transfer BC to DE and DE to HL.
2FAE JP #0850,HSVBK_2 Save the block.
THE 'GET A FILE FROM DISK' SUBROUTINE
This is called by using command code 59 (#3B), it opens a file for LOADing. The IX
register must point to the start of the UFIA. The return is made with the first sector of
the file loaded into the disk buffer and RPT pointing to the first byte (usually the
start of the 9 byte file header).
2FB1 HGFLE CALL #2F8B,HXFER Transfer the UFIA to the DFCA.
2FB4 JP #0BCF,HGFLE_2 Open the file and load the first sector
in the disk buffer.
THE 'LOAD BLOCK FROM DISK' SUBROUTINE
This subroutine is called by using command code 61 (#3D), it does the opposite of
'HSVBK' above. The data block starting at address DE with length BC is LOADed from disk.
NOTE: The file has to be opened by using 'HGFLE' before an attempt can be made to LOAD
bytes. Don't try to LOAD more bytes than available.
2FB7 HLDBK CALL #2FCB,BCDE_DEHL Transfer BC to DE and DE to HL.
2FBA JP #079E,LOAD_FILE Load the block.
THE 'ERASE A FILE' SUBROUTINE
This is called by using command code 65 (#41). It ERASEs one file on the disk (even when
wildcards were used), using the information contained in the UFIA, so make sure that IX
points to the start of it.
2FBD HERAZ CALL #2F8B,HXFER Transfer the UFIA to the DFCA.
2FC0 CALL #2559,FIND_FILE Find the file, HL points to the
directory entry of the file (contained
in the disk buffer).
2FC3 JP NZ,#1678,REP_26 Give error if file not found.
2FC6 LD (HL),0 Directory description 0 means ERASEd.
2FC8 JP #0584,WSAD Write sector DE.
THE 'BC TO DE AND DE TO HL' SUBROUTINE
This routine transfers the contents of BC to DE and that of DE to HL, it also sets IX to
the start of the DFCA.
2FCB BCDE_DEHL PUSH DE
2FCC PUSH BC
2FCD POP DE
2FCE POP HL
2FCF LD IX,#3AC3
2FD3 RET
THE 'READ SECTOR TO ADDRESS' SUBROUTINE
This routine is called by using command code 68 (#44). It reads sector DE from drive A
to the address held in the IX register.
2FD4 HRSAD PUSH BC
2FD5 PUSH IX
2FD7 LD IX,#3AC3
2FDB CALL #0705,TEST_DRV See if the drive held in the A register
is defined.
2FDE CALL #05CC,RSAD Load the sector into the disk buffer.
2FE1 POP HL
2FE2 PUSH DE
2FE3 LD DE,#3BD6 Start of disk buffer.
2FE6 EX DE,HL
2FE7 LD BC,512 Sector length.
2FEA LDIR Move sector to specified address.
2FEC PUSH DE
2FED POP IX Update IX.
2FEF POP DE Restore DE and BC.
2FF0 POP BC
2FF1 RET
THE 'WRITE SECTOR FROM ADDR.' SUBROUTINE
This is called using command code 69 (#45), it writes sector DE to drive A starting from
address IX.
2FF2 HWSAD PUSH BC
2FF3 PUSH IX
2FF5 POP HL
2FF6 LD IX,#3AC3
2FFA CALL #0705,TEST_DRV See if the drive held in the A register
2FFD PUSH DE is defined.
2FFE LD DE,#3BD6
3001 LD BC,512 Sector length.
3004 LDIR Move BC bytes to the disk buffer.
3006 POP DE
3007 PUSH HL
3008 CALL #0584,WSAD Write sector DE to disk.
300B POP IX
300D POP BC
300E RET Finished.
THE 'READ SECTOR DE' SUBROUTINE
This routine is called using command code 63 (#3F), it loads sector DE from the current
drive into the disk buffer.
300F JRSAD LD IX,#3AC3
3013 JP #05CC,RSAD Load the sector.
THE 'WRITE SECTOR DE' SUBROUTINE
This is called using command code 62 (#3E), it saves the contents of the disk buffer
into sector DE on the current drive.
3016 JWSAD LD IX,#3AC3
301A JP #0584,WSAD Save the sector.