4EE3SETIT
LD A,(4FAFH)LD A,(DDRV)
Fetch the DRIVE NUMBER (held in memory location 4FAFH) and store it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
4EE6
LD C,A
Copy the DRIVE NUMBER into Register C.
Original Source Code Comment: INTO C
4EE7
GOSUB to 4A67H.
NOTE: 4A67H is the SYS00/SYS routine to read the directory entry into RAM (Buffer at 4300H)
Original Source Code Comment: GET POINTER TO THE FILE
4EEA
RET NZ
If the NZ FLAG (Not Zero) has been set then that CALL returned with an error, so RETurn to the caller.
Original Source Code Comment: EXIT IF DISK ERROR
4EEB
BIT 6,(HL)BIT SYSTEM,(HL)
Check for a SYSTEM FILE by testing Bit Number 6 of Register HL. Z FLAG will be set if that bit is 0, and NZ FLAG will be set if that bit is 1.
Original Source Code Comment: SYSTEM FILE?
4EED
If the file was a SYSTEM FILE then the NZ FLAG (Not Zero) will have been set. JUMP to 4F9CH to zero out all the buffers and return with "FILE ACCESS DENIED" error.
Original Source Code Comment: YES, CLEAR OUT ENTERY AND SET NZ
4EF0
LD (4FB0H),HLLD (DDIR),HL
Store the POINTER TO THE DIRECTORY ENTRY IN RAM (held in Register Pair HL) into memory location 4FB0H.
Original Source Code Comment: SAVE POINTER TO FRONT OF FILE
4EF3
LD DE,0005HLD DE,DNAME
Since the filename starts 5 bytes into a directory entry, set Register Pair DE equal to 0005H.
Original Source Code Comment: OFFSET TO BEGIN OF NAME
4EF6
ADD HL,DE
Point the POINTER TO THE DIRECTORY ENTRY IN RAM (HL) at the FILENAME by adding 5.
Original Source Code Comment: HL => FRONT OF NAME
4EF7
LD DE,(4FADH)LD DE,(RAMM)
Fetch the pointer to the USER BUFFER (held in memory location 4FADH) and store it into Register Pair DE.
Original Source Code Comment: GET THE RAM POINTER
4EFB
LD BC,0008HLD BC,8
Set Register Pair BC equal to 0008H since there are up to 8 bytes in a filename.
Original Source Code Comment: NUMBER OF BYTES IN NAME
4EFE
LD IX,000EHLD IX,14
Set Special Index Register Pair IX equal 000EH (Decimal: 14) since a filespec can be up to 14 bytes (i.e., NNNNNNNN/EEE:D).
Original Source Code Comment: TOTAL NUMBER OF BYTES IN NAME/EXT:D + 1 SPACE
4F02
LD A,20HLD A,' '
Let Register A equal 20H (ASCII: SPACE).
Original Source Code Comment: SPACE
Top of a loop.
4F04SETIT0
CP (HL)
Compare a SPACE (held in Register A) against the character at the memory location pointed to by the POINTER TO THE DIRECTORY ENTRY IN RAM (Register Pair HL). If it's a SPACE ....
Original Source Code Comment: SPACE?
4F05
... exit this loop via a JUMP to 4F0EH.
Original Source Code Comment: YES, EXIT
4F07
DEC IX
DECrement the amount of characters left in the filespec (tracked in Special Index Register IX) by 1.
Original Source Code Comment: DEC THE COUNTER
4F09
LDI
Move to the 2nd character of both HL and DE via LDI command; which copies BC number of characters from (HL) to (DE), dropping BC each time. When BC hits 0, the PE flag is reset.
Original Source Code Comment: NO, MOVE A BYTE
4F0B
If the PARITY/OVERFLOW FLAG has been SET then we are not yet done processing characters, so LOOP BACK to 4F04H.
Original Source Code Comment: LOOP TILL DONE
Bottom of a loop.
4F0ESETIT2
LD HL,(4FB0H)LD HL,(DDIR)
Fetch the POINTER TO THE DIRECTORY ENTRY IN RAM (held in memory location 4FB0H) and store it into Register Pair HL.
Original Source Code Comment: PICK UP THE BEGIN OF DIRECTORY
4F11
LD BC,000DHLD BC,DEXT
Let Register Pair BC equal 000DH (Decimal: 13), which will be an offset to HL to get to the filename extension.
Original Source Code Comment: OFFSET TO EXTENSION
4F14
ADD HL,BC
LET Register Pair HL = Register Pair HL + Register BC, so that HL now points to the extension.
Original Source Code Comment: HL => DIRECTORY EXTENSION
4F15
LD BC,0003HLD BC,3
Since an extension is maximum 3 characters, set Register Pair BC equal 0003H.
Original Source Code Comment: NUMBER OF BYTES IN EXT
4F18
CP (HL)
Compare the value held in Register A (which should be a SPACE) against the FIRST CHARACTER OF THE EXTENSION (held in the memory location pointed to by the value held in Register Pair HL). Results: If Register A equals the value held in Register HL, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: ANY EXTENSION?
4F19
If the Z FLAG (Zero) has been set, then we hit a space and there is no extension, so stop processing extension characters via a JUMP to 4F2BH.
Original Source Code Comment: NO, CONTINUE
4F1B
PUSH AF
If we're here then we know we have at least 1 character of an extension, so save the SPACE (held in Register A) to the top of the stack.
Original Source Code Comment: SAVE THE SPACE
4F1C
LD A,2FHLD A,'/'
Let Register A equal 2FH (ASCII: /).
Original Source Code Comment: SET EXTENSION SPECIFIER
4F1E
LD (DE),A
Store a / into the memory location pointed to by Register Pair DE.
Original Source Code Comment: INTO USER'S RAM
4F1F
INC DE
Since we just filled a character, move the pointer by INCrementing the value stored in Register Pair DE by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
4F20
POP AF
Restore the SPACE from the top of the stack into Register A.
Top of a loop to process the 2nd and 3rd characters of the filename extension, if any.
4F21SETIT3
CP (HL)
Compare the value held in the memory location pointed to by the value held in Register Pair HL against a SPACE. If the byte is a SPACE ...
Original Source Code Comment: SPACE?
4F22
... JUMP to 4F2BH.
Original Source Code Comment: YES, EXIT
4F24
DEC IX
DECrement the amount of space left in the filespec (tracked in Special Index Register IX) by 1.
Original Source Code Comment: DEC THE COUNTER
4F26
LDI
Move to the 2nd character of both HL and DE via LDI command; which copies BC number of characters from (HL) to (DE), dropping BC each time. When BC hits 0, the PE flag is reset.
Original Source Code Comment: TRANSFER A BYTE
4F28
If the PARITY/OVERFLOW FLAG has been SET then there are more characters to test, so LOOP BACK to 4F21H.
Original Source Code Comment: LOOP FOR COUNT
Bottom of the loop to process the 2nd and 3rd characters of the filename extension, if any.
4F2BSETIT4
LD A,3AHLD A,':'
So now the filename, the "/" (if necessary), and the extension (if any) have been placed into RAM (tracked by DE). Move to the DRIVE NUMBER next. Let Register A equal 3AH (ASCII: :).
Original Source Code Comment: DRIVE SPECIFIER
4F2D
LD (DE),A
Store the : into the LOCATION IN THE USER BUFFER pointed to by Register Pair DE.
Original Source Code Comment: INTO USER RAM
4F2E
INC DE
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair DE) by 1 to point after the :
Original Source Code Comment: BUMP TO NEXT SLOT
4F2F
LD A,(4FAFH)LD A,(DDRV)
Fetch the DRIVE NUMBER (held in memory location 4FAFH) and store it into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
4F32
AND 07HAND 7
MASK the value of Register A against 07H (0000 0111) to leave only 2, 1, 0 active.
Original Source Code Comment: FORCE TO BINARY
4F34
ADD A,30H
LET Register A = Register A + 30H. Note: Adding 30H to from Register A will convert decimal number 0-9 into its ASCII equivalent (i.e., 6 + 30H = 36H, which, in ASCII, is 6.
Original Source Code Comment: MAKE IT ASCII
4F36
LD (DE),A
Store the DRIVE NUMBER IN ASCII (held in Register A) into the memory location in the LOCATION IN THE USER BUFFER pointed to by Register Pair DE.
Original Source Code Comment: SET THE DRIVE NUMBER
4F37
INC DE
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair DE) by 1 to point after the DRIVE NUMBER IN ASCII.
So now the complete filespec (filename/ext:drive) is in RAM with DE pointing to the drive number. Time to start processing the other information.
4F38
4F3A
DEC IX
DEC IX
DECrement the amount of space left in the filespec (tracked in Special Index Register IX) by 2 as the ":D" has been added.
Original Source Code Comment: FOR THE ':'
4F3C
4F3E
PUSH IX
POP BC
Let Register Pair BC = the amount of space left in the filespec.
Original Source Code Comment: MOVE COUNTER TO BC
4F3F
LD B,C
Prepare for a DJNZ loop by copying the LSB of the amount of space left unfilled in the filespec (held in BC) into Register B.
Original Source Code Comment: PUT THE COUNT INTO B
4F40
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the LOCATION IN THE DIRECTORY ENTRY IN RAM) with the value stored in Register Pair DE (i.e., the LOCATION IN THE USER BUFFER).
Original Source Code Comment: USER RAM TO HL
Top of a loop to fill the excess characters in the USER BUFFER with SPACES.
4F41SETIT5
LD (HL),20HLD (HL),' '
Store a : into the USER BUFFER at the memory location pointed to by Register Pair HL.
Original Source Code Comment: PAD REST WITH SPACES
4F43
INC HL
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair HL) by 1.
4F44
LOOP back to 4F41H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: LOOP FOR COUNT
Bottom of a loop.
4F46
LD IX,(4FB0H)LD IX,(DDIR)
Fetch the RAM POINTER IN THE DIRECTORY ENTRY (held in memory location 4FB0H) and store it into Special Index Register Pair IX.
Original Source Code Comment: GET THE DIRECTORY POINTER
4F4A
LD A,(IX+00H)LD A,(IX+DATTRB)
Fetch the ATTRIBUTE BYTE (held in the memory location pointed to by Special Index Register Pair IX+00H) and store it into Register A.
Original Source Code Comment: GET THE ATTRIB BYTE
4F4D
AND 07HAND 7
MASK the value of Register A against 07H (0000 0111) to keep only the protection/access level bits active.
Original Source Code Comment: MASK OFF STATUS BITS
4F4F
LD (HL),A
Store the protection level (held in Register A) into the USER BUFFER memory location pointed to by Register Pair HL.
Original Source Code Comment: INTO USERS BUFFER
4F50
INC HL
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair HL) by 1.
4F51
LD A,(IX+03H)LD A,(IX+DEOF)
Fetch the EOF BYTE (held in the memory location pointed to by Special Index Register Pair IX+03H) and store it into Register A.
Original Source Code Comment: GET THE EOF BYTE
4F54
LD (HL),A
Store the EOF BYTE into the USER BUFFER memory location pointed to by Register Pair HL.
Original Source Code Comment: INTO USER RAM
4F55
INC HL
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair HL) by 1.
4F56
LD A,(IX+04H)LD A,(IX+DLRL)
Fetch the LOGICAL RECORD LENGTH (held in the memory location pointed to by Special Index Register Pair IX+04H) and store it into Register A.
Original Source Code Comment: GET THE LRL
4F59
LD (HL),A
Store the LOGICAL RECORD LENGTH into the USER BUFFER memory location pointed to by Register Pair HL.
Original Source Code Comment: INTO USER RAM
4F5A
INC HL
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair HL) by 1.
4F5B
LD A,(IX+14H)LD A,(IX+DERN)
Fetch the LSB of the END OF FILE SECTOR NUMBER (held in the memory location pointed to by Special Index Register Pair IX+14H) and store it into Register A.
Original Source Code Comment: GET THE END RECORD NUMBER (LSB)
4F5E
LD (HL),A
Store the LSB of the END OF FILE SECTOR NUMBER into the USER BUFFER memory location pointed to by Register Pair HL.
4F5F
INC HL
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair HL) by 1.
4F60
LD A,(IX+15H)LD A,(IX+DERN+1)
Fetch the MSB of the END OF FILE SECTOR NUMBER (stored in memory location pointed to by Special Index Register Pair IX+15H) and store it into Register A.
Original Source Code Comment: GET THE MSB
4F63
LD (HL),A
Store the LSB of the END OF FILE SECTOR NUMBER into the USER BUFFER memory location pointed to by Register Pair HL.
Original Source Code Comment: INTO USER BUFFER
4F64
INC HL
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT GUY
4F65
LD (4FADH),HLLD (RAMM),HL
Store the LOCATION IN THE USER BUFFER (held in Register Pair HL) into memory location 4FADH.
Original Source Code Comment: SAVE THE POINTER
4F68
LD IX,(4FB0H)LD IX,(DDIR)
Fetch the RAM POINTER IN THE DIRECTORY ENTRY (held in memory location 4FB0H) and store it into Special Index Register Pair IX.
Original Source Code Comment: GET THE FRONT POINTER AGAIN
4F6C
LD DE,0016HLD DE,DSEG
Let Register Pair DE equal 0016H for a byte offset into the directory entry to point to the file extents.
Original Source Code Comment: OFFSET TO EXTENTS
4F6F
ADD IX,DE
Set Register Pair IX to point to the EXTENTS by letting IX = Register Pair IX + 22 (i.e., Register DE).
Original Source Code Comment: IX => BEGIN OF EXTENTS
4F71
LD B,0DHLD B,MAXEXT
Let Register B equal 0DH (Decimal: 13) to loop through the 13 extents in each directory entry.
Original Source Code Comment: NUMBER OF EXTENTS IN FILE
4F73
LD HL,0000HLD HL,0
Let Register Pair HL equal 0000H to be an accumulator for the number of grans in the extent.
Original Source Code Comment: CLEAR A 16 BIT ACCUMULATOR
Top of a loop to parse all extents and accumulate the number of grans into HL.
4F76SETIT6
INC IX
INCrement IX to point to the next byte in the EXTENTS portion of the directory entry.
Original Source Code Comment: BUMP TO ALLOCATE BYTE
4F78
INC (IX+00H)INC (IX)
Test for a FFH in the current EXTENT by INCrementing the value stored in the memory location pointed to by Special Index Register IX+00H by 1.
Original Source Code Comment: END OF EXTENTS?
4F7B
If the Z FLAG (Zero) has been set, then the EXTENT was FFH (or empty), so JUMP to 4F8AH.
Original Source Code Comment: YES, EXIT
4F7D
LD A,(IX+00H)LD A,(IX)
Fetch a byte of the EXTENT (pointed to by IX+00H) and put it into Register A. THis should be the SIZE byte of the extent.
Original Source Code Comment: PICK UP THE ALLOCATE BYTE
4F80
AND 1FH
MASK the value of Register A against 1FH (0001 1111). This has the effect of turning off bits 7, 6, 5 (i.e., the starting gran), which are not needed for this calculation.
Original Source Code Comment: MASK OFF STARTING GRAN
4F82
4F83
LD E,A
LD D,00H
Let Register Pair DE = the number of grans in the extent (held in Register A).
Original Source Code Comment: INTO DE
4F85
ADD HL,DE
Add the number of grans in the extent (held in Register Pair DE) into the accumulator (held in Register Pair HL).
Original Source Code Comment: ADD TO EXISTING GRANS
4F86
INC IX
Bump Special Index Register IX to the next extent.
Original Source Code Comment: BUMP TO NEXT EXTENT
4F88
LOOP back to 4F76H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: LOOP FOR COUNT
End of loop to parse all extents and accumulate the number of grans into HL.
4F8ASETIT7
EX DE,HL
EXchange the value stored in Register Pair HL (i.e., the total number of grans in the extents) with the value stored in Register Pair DE.
Original Source Code Comment: DE = TOTAL GRANS
4F8B
LD HL,(4FADH)LD HL,(RAMM)
Fetch LOCATION IN THE USER BUFFER (held in memory location 4FADH) and store it into Register Pair HL.
Original Source Code Comment: GET THE USER RAM POINTER
4F8E
LD (HL),E
Store the LSB of the number of grans in the file (held in Register E) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: STORE IT
4F8F
INC HL
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair HL) by 1.
4F90
LD (HL),D
Store the MSB of the number of grans in the file (held in Register D) into the memory location pointed to by Register Pair HL.
4F91
INC HL
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair HL) by 1.
4F92
LD (HL),2BHLD (HL),'+'
Store a + delimiter into the LOCATION IN THE USER BUFFER (stored in Register Pair HL).
Original Source Code Comment: SPECIFY END OF DIR
4F94
LD (4FADH),HLLD (RAMM),HL
Store the LOCATION IN THE USER BUFFER (held in Register Pair HL) into memory location 4FADH.
Original Source Code Comment: SAVE FOR NEXT TIME
4F97
INC HL
INCrement the LOCATION IN THE USER BUFFER (stored in Register Pair HL) by 1.
4F98
LD (HL),2BHLD (HL),'+'
Store a + delimiter into the LOCATION IN THE USER BUFFER (stored in Register Pair HL).
Original Source Code Comment: SET THE SECOND ONE
4F9A
XOR A
Set Register A to ZERO and clear all Flags to show NO ERROR.
Original Source Code Comment: SET Z
4F9B
RET
RETurn to the caller.