TRS-80 DOS - TRSDOS v1.3 - CONVERT/CMD Disassembled

Page Customization

Description:

CONVERT copies the files of a Model I diskette (single density: 10 sectors of 256 bytes per track, 2 granules of 5 sectors, the directory on track 17) to a TRSDOS 1.3 diskette. The source calls it the MODEL 1 TO MODEL 3 CONVERSION PROGRAM. It reads the Model I diskette with its own disk routines (the source's M1M3READ part, 55A2H-5A05H), which drive the FDC directly in single density, and writes each file with the TRSDOS 1.3 calls INIT, PUT (through the ROM's 001BH) and CLOSE.

Use: CONVERT :s :d converts from drive s to drive d; without them (or with either one missing) it asks 'Source Drive? ' and 'Destination Drive? '. The two drives must differ ('Single Drive Convert is NOT allowed'). A drive number is checked against MAXDRV (4413H); a bad one on the command line ends with the error, a bad reply is asked again. BREAK at any prompt returns to TRSDOS READY.

What it does: it reads the HIT (sector 1) and the GAT (sector 0) of the directory track of the source diskette, then looks at every one of the 64 HIT entries in turn (a column of 8 records at a time). A record that is free, extended, invisible or a system file is skipped. Every other file is converted without asking:

  • A file with an access password of its own (not blank and not the same as the update password) is not converted: its name is shown with 'NOT Converted (Protected File)'.
  • A file with an update password: 'Enter Password for NAME/EXT ?' is asked. The right password is added to the file spec of both files (NAME/EXT.PASSWORD), so the new file gets it; a wrong one is asked again; ENTER alone copies the file without it, and afterwards the update password code of the source record (the code of a blank password changed to the TRSDOS 1.3 one) and its attribute byte are written into the new file's directory record.
  • A file without passwords: its name is shown.
  • The new file is opened with INIT and the record length of the source file. When it is already on the destination diskette, 'Existing File. Use it (Y/N/Q) ? ' is asked: N skips the file, Q returns to TRSDOS READY, anything else writes over it.
  • The file is copied byte by byte until the end of the file (error 28 or 29 from READBT), then the new file is closed.

When every HIT entry has been looked at, 'Conversion Complete' is shown and CONVERT returns to TRSDOS READY (402DH); CFLAG (42B4H) is set to 55H at the start, so TRSDOS READY clears user memory.

CONVERT/CMD loads at 5200H-5AFEH (2271 bytes in three areas: 5200H-55A1H, 55ABH-59EEH and 5A06H-5AFEH; the DEFS areas 55A2H-55AAH and 59EFH-5A05H are not in the file), transfer address 5200H. Its variables and buffers from 5AFFH to 5FFFH are not in the file.

Memory Map

Address RangeLabelContents
5200H-52AFHCONV, ASKSRC, ASKDES, DOCONV, DOCON0-DOCON2The drives, the HIT and GAT of the source, the main loop.
52B0H-536DHCOMPRS, MOVDCB, SETPAS, SETDRV, DRVSETThe file specs of the two files.
536EH-5477HCKPROT, DSPNAM, INPUT, EXST, SETFLG, CKPASS, CKDRIVPasswords, prompts and replies.
5478H-55A1HRWLOOP, GETFIL, BMPFIL, PROCES, PROCE0-PROCE7The copy, the HIT walk, one file.
55A2H-55B1HDUMMY, DRIVE, TRK, SEC, DIRTKVariables of the source diskette routines.
55B2H-56B1HCSEL, CSELCT, SPEEK, CKBSY, delays, READT, OUTRED, MREADSeek and read a sector of the source diskette.
56B2H-576AHREAD0, RDREC, RDSEC, READBT, RBYTE, GETPA, MB5Read a file of the source diskette.
576BH-59EDHDIRED, REDGAT, LFDIR, TRKGT, ROPEN, SETDCB, DOLINK, CRACK, GETFLD, HASH, TRAP, CKHDRV, RDHITTThe directory, open, file specs, hash codes.
59EEH-5A05HDRV, PWORD, NAME, EXT, UPDTDC, ACCTDCThe parts of a file spec (59EFH up not in the file).
5A06H-5AFEHTITLE ... SPCOFFMessages.
5AFFH-5FFFHSDRIVE ... BUFER2Variables, DCBs and buffers (not in the file).

Variables:

AddressLabelDescription
5AFFH
1 byte
SDRIVENot in the file. The source drive.
5B00H
1 byte
DDRIVENot in the file. The destination drive.
5B01H
1 byte
MOVFLGNot in the file. FFH when only ENTER was pressed for the password (PROCE4 then writes the password code into the new record).
5B02H-5B03H
2 bytes
FILPNTNot in the file. The next HIT entry (5E00H-5EFFH).
5B04H
1 byte
FILCNTNot in the file. HIT entries left, from 64.
5B05H
1 byte
LFNCNTNot in the file. The directory record of the entry in FILPNT (bits 0-2 the sector less 2, bits 3-5 the record).
5B06H
1 byte
SVCNTNot in the file. The length of the password typed.
5B07H-5B08H
2 bytes
PWSAVENot in the file. The update password code of the file (record offset 10H).
5B09H-5B26H
30 bytes
FILNAMNot in the file. NAME/EXT and 03H.
5B27H-5B30H
10 bytes
KEYBUFNot in the file. The reply typed.
5B31H-5B62H
50 bytes
DCBRNot in the file. The DCB of the source file (filled by SETDCB).
5B63H-5B94H
50 bytes
DCBWNot in the file. The DCB of the new file (opened by INIT).
5B95H-5C94H
256 bytes
DBUFR1Not in the file. The buffer of DCBR.
5C95H-5D94H
256 bytes
DBUFR2Not in the file. The buffer of DCBW.
5E00H-5EFFH
256 bytes
HITBUFNot in the file. The HIT of the source diskette.
5F00H-5FFFH
256 bytes
BUFER2Not in the file. The GAT, then the directory sectors of the source diskette.
55A2H-55AAH
9 bytes
DUMMYNot in the file. The ID field SPEEK reads.
55ABH
1 byte
DRIVEThe select byte of the drive in use.
55ACH, 55ADH
1 byte each
TRK, SECNot used.
55AEH-55B1H
4 bytes
DIRTKThe directory track of drives 0-3 (17 each).
59EEH
1 byte
DRVThe drive of the file spec (FFH = any).
59EFH-59F6H
8 bytes
PWORDNot in the file. The password of the file spec.
59F7H-5A01H
11 bytes
NAME, EXTNot in the file. The name and extension, padded with spaces.
5A02H-5A05H
4 bytes
UPDTDC, ACCTDCNot in the file. The code of PWORD (not used).
53E9H-53EAH
2 bytes
SAVTXTOperand of LD HL at 53E8H: the prompt INPUT shows again.
552CH
1 byte
CHGLRLOperand of LD B at 552BH: the record length of the new file.
5556H-5557H
2 bytes
SAVDIROperand of LD HL at 5555H: the directory record of the source file.
5587H-5588H
2 bytes
SAVLFNOperand of LD BC at 5586H: the logical file number and drive of the new file.
55FDH
1 byte
SVTRKOperand of LD D at 55FCH: the track SPEEK seeks.
562FH-5630H
2 bytes
RHLLOperand of LD HL at 562EH: the buffer READT reads into.
57EAH
1 byte
HCODEOperand of CP at 57E9H: the hash code of the file ROPEN looks for.
5846H
1 byte
RLRLOperand of LD A at 5845H: the record length given to ROPEN.
5849H
1 byte
PRIVOperand of LD A at 5848H: access bits for DCB+01H (00H).
5857H-5858H
2 bytes
BLKBUFOperand of LD DE at 5856H: the buffer given to ROPEN.
5886H
1 byte
VERSONOperand of LD A at 5885H: the GAT's version byte less 24H.
588FH
1 byte
INCFLGOperand of LD A at 588EH: the EOF byte of the file.
58C0H
1 byte
SAVDRVOperand of LD C at 58BFH: the drive of the file.
58CCH
1 byte
SAVEAOperand of LD A at 58CBH: the link byte of an extended record.
58E1H-58E2H
2 bytes
SAVEDEOperand of LD DE at 58E0H: where in the DCB the next extents go.
42B4H
1 byte
CFLAGIn SYS0: set to 55H, TRSDOS READY clears user memory.
4413H
1 byte
MAXDRVIn SYS0: the highest drive number.
4300H-43FFH
256 bytes
BUFF1In SYS0: the directory sector LFNDIR and WRDIR use in PROCE4.

The Read DCB (filled by SETDCB)

OffsetLabelContents
00HTYPE80H: open.
01HPROTBit 7: byte access (READBT); bit 5: the next record must be read into the buffer.
03H-04HBUFL, BUFHThe buffer (DBUFR1).
05HOFFSETThe offset of the next byte in the buffer.
06HDRVNUMThe drive.
07HLFNThe HIT offset of the file.
08HEOFThe EOF byte (record offset 03H).
09HLRLThe logical record length (record offset 04H).
0AH-0BHNRNThe next record (sector), from 0.
0CH-0DHERNThe ending record number (record offset 14H; corrected unless the version byte is 24H).
0EH upThe extents (record offset 16H up): the track, then the granule byte (bits 7-5 the first granule, bits 4-0 the granules less 1); FFH ends them.

Analysis Notes

Source and file. The release file and the file assembled in the source tree (M1M3CONV) are the same 2271 bytes. The source is M1M3CONV.SRC, which includes M1M3READ.SRC at 55A2H; its pseudo instructions SAV3, EXI3, LD BC,(HL), LD HL,(HL), LD (HL),BC and CD rr assemble to several instructions each.

The HIT walk. FILPNT moves 32 bytes at a time down a column of the HIT and on to the next column when it passes FFH; LFNCNT keeps the record number to match (bits 0-2 the column, which is the directory sector less 2, bits 3-5 the row, which is the record in the sector). LFDIR takes the sector from the record number it is given and the record in the sector from FILPNT, so ROPEN's search, which reads the record of every HIT entry with the right hash code, compares the name of the record in FILPNT's row of that entry's sector.

Not reached. READ0 (56B2H) and OPERR1 (5806H) are not called or jumped to by any instruction of CONVERT. TRK and SEC (55ACH, 55ADH) and UPDTDC and ACCTDC (5A02H-5A05H) are not read.

PROCE4. The attribute byte comes from the source record at SAVDIR in BUFER2; when ROPEN has read an extended record (DOLINK) into BUFER2 since, that place holds another record.

Disassembly:

5200H - CONV - Entry Point: Sign On and the Drive Numbers from the Command Line

 
ORG 5200H
5200CONV
PUSH HL E5
CONV: Save Register Pair HL, which TRSDOS points at the rest of the command line (after CONVERT), to the top of the STACK.
Original Source Code Comment: SAVE THE COMMAND LINE POINTER
5201
LD A,55H 3E 55
LET Register A = 55H, the value of the 'CLEAR RAM' flag.
Original Source Code Comment: SET THE 'CLEAR RAM' FLAG
5203
Store 55H into 42B4H (CFLAG, in SYS0), so that TRSDOS READY clears user memory when CONVERT returns to it.
5206
GOSUB to 01C9H (the ROM's CLS) to clear the screen.
Original Source Code Comment: CLEAR THE SCREEN
5209
LET Register Pair HL = 5A06H (TITLE), the sign on text 'Model 1 to Model 3 Conversion Utility. Ver 1.3' with a line feed and a carriage return.
Original Source Code Comment: HL => 'CONVERSION PGM' MSG
520C
GOSUB to 021BH (the ROM's PRINT), which displays the text at HL up to a 03H or 0DH.
Original Source Code Comment: DISPLAY IT
520F
POP HL E1
Restore the command line pointer into Register Pair HL from the STACK.
Original Source Code Comment: GET COMMAND LINE POINTER BACK

The command line may give both drives as :s :d.

5210
LD A,(HL) 7E
Fetch the first character of the command line into Register A.
Original Source Code Comment: GET THE CHAR FROM THE LINE
5211
CP 20HCP ' ' FE 20
Compare Register A with 20H (space): the CARRY FLAG is set for a control character such as the 0DH at the end of the line.
Original Source Code Comment: END OF LINE?
5213
If the CARRY FLAG is set the command line is empty, so JUMP to 523CH (ASKSRC) to ask for both drive numbers.
Original Source Code Comment: YES, ASK FOR BOTH DRIVE NUMBERS
5215
CP 3AHCP ':' FE 3A
Compare Register A with 3AH (':'), the drive specifier.
Original Source Code Comment: DRIVE SPECIFIER?
5217
If the NZ FLAG is set the line does not start with ':', so JUMP to 523CH (ASKSRC) to ask for both drive numbers.
Original Source Code Comment: NO, ASK FOR SOURCE
5219
INC HL 23
INCrement Register Pair HL to the character after the ':'.
Original Source Code Comment: BUMP TO THE DRIVE NUMBER
521A
LD A,(HL) 7E
Fetch the source drive number (an ASCII digit) into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
521B
GOSUB to 5462H (CKDRIV): Z with the binary drive number in Register A, or NZ with an error code in Register A.
Original Source Code Comment: VALID DRIVE NUMBER?
521E
If the NZ FLAG is set the drive number is not valid, so JUMP to 4409H (ERROR in SYS0) to display the error held in Register A and return to TRSDOS READY.
Original Source Code Comment: NO, EXIT
5221
LD (5AFFH),ALD (SDRIVE),A 32 FF 5A
Store the source drive number into 5AFFH (SDRIVE).
Original Source Code Comment: SAVE IT AS THE SOURCE DRIVE
5224
INC HL 23
INCrement Register Pair HL past the drive digit ...
Original Source Code Comment: BUMP PAST SPACE
5225
INC HL 23
... and past the space after it: the line is expected as :s :d.
Original Source Code Comment: BUMP TO NEXT SLOT
5226
LD A,(HL) 7E
Fetch the next character of the command line into Register A.
Original Source Code Comment: GET THE NEXT BYTE
5227
CP 20HCP ' ' FE 20
Compare Register A with 20H (space): the CARRY FLAG is set at the end of the line.
Original Source Code Comment: END OF LINE?
5229
If the CARRY FLAG is set no destination drive was given, so JUMP to 524EH (ASKDES) to ask for it.
Original Source Code Comment: YES, ASK FOR DESTINATION
522B
CP 3AHCP ':' FE 3A
Compare Register A with 3AH (':').
Original Source Code Comment: DRIVE SPECIFIER?
522D
If the NZ FLAG is set there is no ':', so JUMP to 524EH (ASKDES) to ask for the destination drive.
Original Source Code Comment: NO, ASK FOR DESTINATION
522F
INC HL 23
INCrement Register Pair HL to the destination drive digit.
Original Source Code Comment: BUMP TO THE DRIVE NUMBER
5230
LD A,(HL) 7E
Fetch the destination drive number (ASCII) into Register A.
Original Source Code Comment: GET IT
5231
GOSUB to 5462H (CKDRIV) to check it and make it binary.
Original Source Code Comment: VALID DRIVE NUMBER?
5234
If the NZ FLAG is set the drive number is not valid, so JUMP to 4409H (ERROR) with the error code in Register A.
Original Source Code Comment: NO, EXIT
5237
LD (5B00H),ALD (DDRIVE),A 32 00 5B
Store the destination drive number into 5B00H (DDRIVE).
Original Source Code Comment: SAVE IT AS THE DESTINATION DRIVE NUMBER
523A
JUMP to 5260H (DOCONV): both drives came from the command line.
Original Source Code Comment: AND DO THE CONVERSION

523CH - ASKSRC - Prompt for the Source Drive

523CASKSRC
ASKSRC: LET Register Pair HL = 5A37H (DRIV1), the prompt 'Source Drive? '.
Original Source Code Comment: HL => 'SOURCE DRIVE NO.' MSG
523F
GOSUB to 53D0H (INPUT) to display the prompt and read a one character reply into 5B27H (KEYBUF); Register Pair HL comes back pointing to it, or the CARRY FLAG is set for BREAK.
Original Source Code Comment: DISPLAY AND GET THE ANSWER
5242
If the CARRY FLAG is set the BREAK key was pressed, so JUMP to 4030H (ABORT), back to TRSDOS READY.
Original Source Code Comment: ABORT IT BREAK KEY
5245
LD A,(HL) 7E
Fetch the character typed into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
5246
GOSUB to 5462H (CKDRIV) to check it and make it binary.
Original Source Code Comment: SEE IF VALID DRIVE NUMBER
5249
If the NZ FLAG is set the drive number is not valid, so LOOP BACK to 523CH (ASKSRC) to ask again (no error is shown).
Original Source Code Comment: NOT VALID. DO IT AGAIN
524B
LD (5AFFH),ALD (SDRIVE),A 32 FF 5A
Store the source drive number into 5AFFH (SDRIVE).
Original Source Code Comment: SET AS SOURCE DRIVE

524EH - ASKDES - Prompt for the Destination Drive

524EASKDES
ASKDES: LET Register Pair HL = 5A46H (DRV2), the prompt 'Destination Drive? '.
Original Source Code Comment: HL => 'DESTINATION DRIVE NO.' MSG
5251
GOSUB to 53D0H (INPUT) to display the prompt and read the reply into KEYBUF.
Original Source Code Comment: DISPLAY AND GET THE ANSWER
5254
If the CARRY FLAG is set the BREAK key was pressed, so JUMP to 4030H (ABORT).
Original Source Code Comment: ABORT IF BREAK KEY
5257
LD A,(HL) 7E
Fetch the character typed into Register A.
Original Source Code Comment: GET THE DRIVE NUMBER
5258
GOSUB to 5462H (CKDRIV) to check it and make it binary.
Original Source Code Comment: SEE IF VALID DRIVE NUMBER
525B
If the NZ FLAG is set the drive number is not valid, so LOOP BACK to 524EH (ASKDES) to ask again.
Original Source Code Comment: NO, DO IT AGAIN
525D
LD (5B00H),ALD (DDRIVE),A 32 00 5B
Store the destination drive number into 5B00H (DDRIVE).
Original Source Code Comment: SET AS DESTINATION DRIVE NUMBER

5260H - DOCONV - Check the Drives, Read the HIT and the GAT of the Source Diskette

5260DOCONV
LD A,(5AFFH)LD A,(SDRIVE) 3A FF 5A
DOCONV: Fetch the source drive number from 5AFFH (SDRIVE) into Register A ...
Original Source Code Comment: GET THE SOURCE DRIVE
5263
LD B,A 47
... and copy it into Register B.
Original Source Code Comment: INTO B
5264
LD A,(5B00H)LD A,(DDRIVE) 3A 00 5B
Fetch the destination drive number from 5B00H (DDRIVE) into Register A.
Original Source Code Comment: GET THE DESTINATION DRIVE
5267
SUB B 90
SUBtract the source drive (Register B) from it: the Z FLAG is set when both are the same drive.
Original Source Code Comment: SAME DRIVES?
5268
If the NZ FLAG is set the drives differ, so JUMP to 5272H (DOCON0).
Original Source Code Comment: NO, CONTINUE
526A
LET Register Pair HL = 5AB4H (CANT), the text 'Single Drive Convert is NOT allowed'.
Original Source Code Comment: HL => 'CANT USE SAME DRIVE' MSG
526D
GOSUB to 021BH (the ROM's PRINT) to display it.
Original Source Code Comment: DISPLAY IT
5270
JUMP BACK to 523CH (ASKSRC) to ask for both drives again.
Original Source Code Comment: DO IT ALL OVER AGAIN
5272DOCON0
LD A,(5AFFH)LD A,(SDRIVE) 3A FF 5A
DOCON0: Fetch the source drive number from 5AFFH (SDRIVE) into Register A ...
Original Source Code Comment: GET THE SOURCE DRIVE NUMBER
5275
LD C,A 4F
... and copy it into Register C for RDHITT and REDGAT.
Original Source Code Comment: INTO C
5276
GOSUB to 59D9H (RDHITT) to read the HIT of the source diskette (its directory track, sector 1) into 5E00H (HITBUF); Register Pair HL comes back as 5E00H.
Original Source Code Comment: READ IN THE MODEL 1 HIT TABLE
5279
If the NZ FLAG is set the HIT could not be read, so JUMP to 4409H (ERROR) with the error code in Register A.
Original Source Code Comment: EXIT IF ERROR
527C
LD (5B02H),HLLD (FILPNT),HL 22 02 5B
Store Register Pair HL (5E00H, the first HIT entry) into 5B02H-5B03H (FILPNT), the HIT entry of the next file.
Original Source Code Comment: SAVE THE HIT FOR THE FILE POINTER
527F
XOR A AF
Set Register A to 00H.
Original Source Code Comment: START AN LFN COUNTER
5280
LD (5B05H),ALD (LFNCNT),A 32 05 5B
Store 00H into 5B05H (LFNCNT), the number of the directory record that goes with the HIT entry in FILPNT.
5283
LD (5B01H),ALD (MOVFLG),A 32 01 5B
Store 00H into 5B01H (MOVFLG), the flag that the password was not typed.
Original Source Code Comment: INIT THE 'MOVE' FLAG
5286
LD A,40H 3E 40
LET Register A = 40H (64), the number of HIT entries to look at (8 directory sectors of 8 records).
Original Source Code Comment: MAX NUMBER OF FILES TO LOOK AT
5288
LD (5B04H),ALD (FILCNT),A 32 04 5B
Store 64 into 5B04H (FILCNT), the HIT entries left.
Original Source Code Comment: SET THE COUNTER
528B
GOSUB to 5780H (REDGAT) to read the GAT of the source diskette (track 17, sector 0) into 5F00H (BUFER2).
Original Source Code Comment: GO READ IN THE GAT
528E
If the NZ FLAG is set the GAT could not be read, so JUMP to 4409H (ERROR) with the error code in Register A.
Original Source Code Comment: EXIT IF ERROR
5291
LD A,(5FC0H)LD A,(BUFER2+0C0H) 3A C0 5F
Fetch the byte at offset C0H of the GAT (5FC0H), the version byte of the source diskette, into Register A.
Original Source Code Comment: SEE IF THIS IS MODEL 1, VERSION 2.4
5294
SUB 24H D6 24
SUBtract 24H, the version the source checks for: Register A is 00H for such a diskette.
Original Source Code Comment: IF IT IS, 'A' WILL BE ZERO
5296
Store the result into 5886H (VERSON), the operand of the LD A,0FFH at 5885H in SETDCB: 00H there makes SETDCB take the ending record number of each file as it is.
Original Source Code Comment: SAVE THE 'Z' OR 'NZ' IN VERSION FLAG

5299H - DOCON1 / DOCON2 - Main Loop: Convert Each File, then Conversion Complete

Every HIT entry is looked at in turn; each file found is converted.

5299DOCON1
DOCON1: GOSUB to 5495H (GETFIL) to find the next file to convert; it returns Register Pair HL at the file's directory record, or the CARRY FLAG set when no file is left.
Original Source Code Comment: GET THE NEXT FILE TO PROCESS
529C
If the CARRY FLAG is set every HIT entry has been looked at, so JUMP to 52A7H (DOCON2).
Original Source Code Comment: END OF FILES. DISPLAY FINALE
529E
GOSUB to 54E9H (PROCES) to convert the file whose directory record is at HL.
Original Source Code Comment: PROCESS THE FILE
52A1
XOR A AF
Set Register A to 00H.
52A2
LD (5B01H),ALD (MOVFLG),A 32 01 5B
Store 00H into 5B01H (MOVFLG) for the next file.
Original Source Code Comment: CLEAR THE 'MOVE' FLAG
52A5
LOOP BACK to 5299H (DOCON1) for the next file.
Original Source Code Comment: DO THE NEXT FILE
52A7DOCON2
DOCON2: LET Register Pair HL = 5A5AH (FINA), two line feeds and 'Conversion Complete'.
Original Source Code Comment: HL => 'CONVERSION COMPLETE' MSG
52AA
GOSUB to 021BH (the ROM's PRINT) to display it.
Original Source Code Comment: DISPLAY IT
52AD
JUMP to 402DH (SYS1IN, $JP2DOS) to return to TRSDOS READY.
Original Source Code Comment: RETURN TO DOS

52B0H - COMPRS - Make NAME/EXT from a Directory Record

52B0COMPRS
PUSH BCSAV3 C5
COMPRS: Save Register Pair BC to the top of the STACK ...
52B1
PUSH DE D5
... and Register Pair DE ...
52B2
PUSH HL E5
... and Register Pair HL (the directory record).
52B3
LD B,08H 06 08
LET Register B = 08H, the length of the name field.
Original Source Code Comment: SET FOR 8 CHARS
52B5
PUSH HL E5
Save the pointer to the directory record (Register Pair HL) to the top of the STACK again.
Original Source Code Comment: SAVE THE POINTER TO THE NAME
52B6
LD DE,0005HLD DE,DNAME 11 05 00
LET Register Pair DE = 0005H (DNAME), the offset of the name in a directory record.
Original Source Code Comment: OFFSET TO THE BEGIN OF FILENAME IN DIR
52B9
ADD HL,DE 19
ADD it to Register Pair HL, so HL points to the name.
Original Source Code Comment: HL => FRONT OF FILE NAME
52BA
LD DE,5B09HLD DE,FILNAM 11 09 5B
LET Register Pair DE = 5B09H (FILNAM), the place for the file spec.
Original Source Code Comment: PLACE TO STORE IT
52BDCOMPR1
LD A,(HL) 7E
COMPR1: Fetch a character of the name into Register A.
Original Source Code Comment: GET A CHAR
52BE
CP 20HCP ' ' FE 20
Compare Register A with 20H (space): the name is padded with spaces.
Original Source Code Comment: SPACE
52C0
If the Z FLAG is set the name has ended, so JUMP to 52C7H (COMPR2).
Original Source Code Comment: YES, GO FOR EXTENSION
52C2
LD (DE),A 12
Store the character into FILNAM at DE.
Original Source Code Comment: SAVE IT IN BUFFER
52C3
INC HL 23
INCrement Register Pair HL to the next character of the name ...
Original Source Code Comment: BUMP POINTERS
52C4
INC DE 13
... and Register Pair DE to the next place in FILNAM.
52C5
DECrement Register B and LOOP BACK to 52BDH (COMPR1) for up to 8 characters.
Original Source Code Comment: LOOP FOR COUNT
52C7COMPR2
POP HL E1
COMPR2: Restore the pointer to the directory record into Register Pair HL.
Original Source Code Comment: GET THE NAME POINTER BACK
52C8
PUSH DE D5
Save the FILNAM pointer (Register Pair DE) to the top of the STACK.
Original Source Code Comment: SAVE THE 'FILNAM' POINTER
52C9
LD DE,000DHLD DE,DEXT 11 0D 00
LET Register Pair DE = 000DH (DEXT), the offset of the extension in a directory record.
Original Source Code Comment: OFFSET TO THE EXTENSION
52CC
ADD HL,DE 19
ADD it to Register Pair HL, so HL points to the extension.
Original Source Code Comment: HL => EXTENSTION
52CD
POP DE D1
Restore the FILNAM pointer into Register Pair DE.
Original Source Code Comment: GET 'FILNAM' POINTER BACK
52CE
LD A,(HL) 7E
Fetch the first character of the extension into Register A.
Original Source Code Comment: SEE IF ANY EXTENSION
52CF
CP 20HCP ' ' FE 20
Compare Register A with 20H (space).
Original Source Code Comment: SPACE?
52D1
If the Z FLAG is set the file has no extension, so JUMP to 52E3H (COMPR4).
Original Source Code Comment: YES. NO EXT. EXIT
52D3
LD A,2FHLD A,'/' 3E 2F
LET Register A = 2FH ('/'), the extension specifier.
Original Source Code Comment: SET THE EXTENSTION SPECIFIER
52D5
LD (DE),A 12
Store it into FILNAM at DE.
Original Source Code Comment: INTO THE BUFFER
52D6
INC DE 13
INCrement Register Pair DE to the next place.
Original Source Code Comment: BUMP TO NEXT SLOT
52D7
LD B,03H 06 03
LET Register B = 03H, the length of the extension field.
Original Source Code Comment: SET FOR 3 CHARS
52D9COMPR3
LD A,(HL) 7E
COMPR3: Fetch a character of the extension into Register A.
Original Source Code Comment: GET A CHARACTER
52DA
CP 20HCP ' ' FE 20
Compare Register A with 20H (space).
Original Source Code Comment: END OF EXTENSTION?
52DC
If the Z FLAG is set the extension has ended, so JUMP to 52E3H (COMPR4).
Original Source Code Comment: YES, EXIT
52DE
LD (DE),A 12
Store the character into FILNAM at DE.
Original Source Code Comment: SET INTO THE BUFFER
52DF
INC HL 23
INCrement Register Pair HL ...
Original Source Code Comment: BUMP POINTERS
52E0
INC DE 13
... and Register Pair DE.
52E1
DECrement Register B and LOOP BACK to 52D9H (COMPR3) for up to 3 characters.
Original Source Code Comment: LOOP FOR COUNT
52E3COMPR4
LD A,03H 3E 03
COMPR4: LET Register A = 03H, the end of a text for PRINT.
Original Source Code Comment: TERMINATE THE NAME
52E5
LD (DE),A 12
Store 03H after the file spec in FILNAM: FILNAM now holds NAME/EXT and 03H.
52E6
POP HLEXI3 E1
Restore Register Pair HL ...
52E7
POP DE D1
... Register Pair DE ...
52E8
POP BC C1
... and Register Pair BC from the STACK.
52E9
RET C9
RETurn to the caller.

52EAH - MOVDCB - Copy the File Spec into the Read and Write DCBs

52EAMOVDCB
PUSH BCSAV3 C5
MOVDCB: Save Register Pair BC to the top of the STACK ...
52EB
PUSH DE D5
... and Register Pair DE ...
52EC
PUSH HL E5
... and Register Pair HL.
52ED
LD DE,5B63HLD DE,DCBW 11 63 5B
LET Register Pair DE = 5B63H (DCBW), the DCB of the file to write on the destination diskette; before the open it holds the file spec.
Original Source Code Comment: DE => WRITE DCB
52F0
LD BC,5B31HLD BC,DCBR 01 31 5B
LET Register Pair BC = 5B31H (DCBR), the DCB of the file to read on the source diskette.
Original Source Code Comment: BC => READ DCB
52F3
LD HL,5B09HLD HL,FILNAM 21 09 5B
LET Register Pair HL = 5B09H (FILNAM), the file spec made by COMPRS.
Original Source Code Comment: WHERE THE NAME IS
52F6MOVDC1
LD A,(HL) 7E
MOVDC1: Fetch a byte of the file spec into Register A.
Original Source Code Comment: GET A BYTE
52F7
LD (DE),A 12
Store it into the write DCB at DE ...
Original Source Code Comment: INTO THE WRITE DCB
52F8
LD (BC),A 02
... and into the read DCB at BC.
Original Source Code Comment: INTO THE READ DCB
52F9
CP 03H FE 03
Compare Register A with 03H, the end of the file spec.
Original Source Code Comment: END OF FILESPEC?
52FB
If the Z FLAG is set the whole spec (with its 03H) has been copied, so JUMP to 5302H (MOVDC2).
Original Source Code Comment: YES, EXIT
52FD
INC HL 23
INCrement Register Pair HL ...
Original Source Code Comment: NO, BUMP POINTERS
52FE
INC DE 13
... Register Pair DE ...
52FF
INC BC 03
... and Register Pair BC to the next byte.
5300
LOOP BACK to 52F6H (MOVDC1).
Original Source Code Comment: AND LOOP TILL DONE
5302MOVDC2
POP HLEXI3 E1
MOVDC2: Restore Register Pair HL ...
5303
POP DE D1
... Register Pair DE ...
5304
POP BC C1
... and Register Pair BC from the STACK.
5305
RET C9
RETurn to the caller.

5306H - SETPAS - Add the Password to Both File Specs

5306SETPAS
PUSH BCSAV3 C5
SETPAS: Save Register Pair BC to the top of the STACK ...
5307
PUSH DE D5
... and Register Pair DE ...
5308
PUSH HL E5
... and Register Pair HL.
5309
LD HL,5B31HLD HL,DCBR 21 31 5B
LET Register Pair HL = 5B31H (DCBR), the file spec in the read DCB.
Original Source Code Comment: HL => READ DCB
530C
LD C,00H 0E 00
LET Register C = 00H, a count of the characters before the 03H.
Original Source Code Comment: SET A COUNTER
530ESETPA1
LD A,(HL) 7E
SETPA1: Fetch a character of the spec into Register A.
Original Source Code Comment: GET A CHARACTER
530F
CP 03H FE 03
Compare Register A with 03H, the end of the spec.
Original Source Code Comment: END OF FILESPEC?
5311
If the Z FLAG is set the end is found, so JUMP to 5317H (SETPA2).
Original Source Code Comment: YES, SET THE PASSWORD
5313
INC HL 23
INCrement Register Pair HL to the next character ...
Original Source Code Comment: BUMP TO NEXT CHAR
5314
INC C 0C
... and the count in Register C.
Original Source Code Comment: INC THE COUNT
5315
LOOP BACK to 530EH (SETPA1).
Original Source Code Comment: LOOP TILL FOUND
5317SETPA2
EX DE,HL EB
SETPA2: EXchange Register Pairs DE and HL: DE points to the 03H in the read DCB.
Original Source Code Comment: SAVE THE POINTER IN DE
5318
LD HL,5B63HLD HL,DCBW 21 63 5B
LET Register Pair HL = 5B63H (DCBW), the file spec in the write DCB.
Original Source Code Comment: HL => WRITE DCB
531B
LD B,00H 06 00
LET Register B = 00H, so Register Pair BC holds the count.
Original Source Code Comment: CLEAR B
531D
ADD HL,BC 09
ADD the count to Register Pair HL, so HL points to the 03H in the write DCB.
Original Source Code Comment: HL => WHERE PW GOES IN WRITE DCB
531E
LD BC,5B27HLD BC,KEYBUF 01 27 5B
LET Register Pair BC = 5B27H (KEYBUF), where SETFLG put the password typed.
Original Source Code Comment: BC => WHERE USER SUPPLIED PW IS
5321
LD A,2EHLD A,'.' 3E 2E
LET Register A = 2EH ('.'), the password specifier.
Original Source Code Comment: SET PW SPECIFIER
5323
LD (HL),A 77
Store '.' over the 03H in the write DCB ...
Original Source Code Comment: INTO WRITE DCB
5324
LD (DE),A 12
... and over the 03H in the read DCB.
Original Source Code Comment: INTO READ DCB
5325
JUMP to 5335H (SETPA5) to step past the '.' and copy the password.
Original Source Code Comment: AND PICK UP THE PASSWORD
5327SETPA3
LD A,(BC) 0A
SETPA3: Fetch a character of the password from KEYBUF (BC) into Register A.
Original Source Code Comment: GET A CHAR
5328
CP 30HCP '0' FE 30
Compare Register A with 30H ('0'): the CARRY FLAG is set for a control character or punctuation.
Original Source Code Comment: LESS THEN LEGAL?
532A
If the NC FLAG is set the character is kept, so JUMP to 532EH (SETPA4).
Original Source Code Comment: NO, CONTINUE
532C
LD A,0DHLD A,0DH 3E 0D
LET Register A = 0DH, the end of a file spec, in place of the character below '0' (the 0DH KEYN left after the reply).
Original Source Code Comment: SET AS END OF LINE
532ESETPA4
LD (DE),A 12
SETPA4: Store Register A into the read DCB at DE ...
Original Source Code Comment: INTO THE READ DCB
532F
LD (HL),A 77
... and into the write DCB at HL.
Original Source Code Comment: INTO THE WRITE DCB
5330
CP 0DHCP 0DH FE 0D
Compare Register A with 0DH.
Original Source Code Comment: END OF LINE?
5332
If the Z FLAG is set the spec is complete (NAME/EXT.PASSWORD and 0DH), so JUMP to 5339H (SETPA6).
Original Source Code Comment: YES, EXIT
5334
INC BC 03
INCrement Register Pair BC to the next character of the password.
Original Source Code Comment: NO, BUMP POINTERS
5335SETPA5
INC DE 13
SETPA5: INCrement Register Pair DE (read DCB) ...
5336
INC HL 23
... and Register Pair HL (write DCB) to the next place.
5337
LOOP BACK to 5327H (SETPA3).
Original Source Code Comment: LOOP TILL END
5339SETPA6
POP HLEXI3 E1
SETPA6: Restore Register Pair HL ...
533A
POP DE D1
... Register Pair DE ...
533B
POP BC C1
... and Register Pair BC from the STACK.
533C
RET C9
RETurn to the caller.

533DH - SETDRV - Add the Drive Numbers to Both File Specs

533DSETDRV
PUSH BCSAV3 C5
SETDRV: Save Register Pair BC to the top of the STACK ...
533E
PUSH DE D5
... and Register Pair DE ...
533F
PUSH HL E5
... and Register Pair HL.
5340
LD HL,5B31HLD HL,DCBR 21 31 5B
LET Register Pair HL = 5B31H (DCBR), the file spec in the read DCB.
Original Source Code Comment: PICK UP THE READ DCB
5343
LD C,00H 0E 00
LET Register C = 00H, a count of the characters of the spec.
Original Source Code Comment: SET A COUNTER
5345SETDR1
LD A,(HL) 7E
SETDR1: Fetch a character of the spec into Register A.
Original Source Code Comment: GET A CHARACTER
5346
CP 20HCP ' ' FE 20
Compare Register A with 20H (space): the CARRY FLAG is set at the 03H or 0DH that ends the spec.
Original Source Code Comment: END OF FILE?
5348
If the CARRY FLAG is set the end is found, so JUMP to 534EH (SETDR2).
Original Source Code Comment: YES, SET THE DRIVE NUMBER
534A
INC HL 23
INCrement Register Pair HL to the next character ...
Original Source Code Comment: NO, BUMP TO NEXT CHAR
534B
INC C 0C
... and the count in Register C.
Original Source Code Comment: BUMP THE COUNT
534C
LOOP BACK to 5345H (SETDR1).
Original Source Code Comment: LOOP TILL FOUND
534ESETDR2
LD A,(5AFFH)LD A,(SDRIVE) 3A FF 5A
SETDR2: Fetch the source drive number from 5AFFH (SDRIVE) into Register A.
Original Source Code Comment: PICK UP THE SOURCE DRIVE NUMBER
5351
GOSUB to 5364H (DRVSET) to put ':', the drive digit and 0DH at HL, the end of the read DCB's spec.
Original Source Code Comment: SET IT
5354
LD HL,5B63HLD HL,DCBW 21 63 5B
LET Register Pair HL = 5B63H (DCBW), the file spec in the write DCB.
Original Source Code Comment: HL => WRITE DCB
5357
LD B,00H 06 00
LET Register B = 00H, so Register Pair BC holds the count.
Original Source Code Comment: CLEAR THE MSB OF THE COUNT
5359
ADD HL,BC 09
ADD the count to Register Pair HL: HL points to the end of the write DCB's spec, which is as long as the read DCB's.
Original Source Code Comment: HL => END OF THE FILESPEC
535A
LD A,(5B00H)LD A,(DDRIVE) 3A 00 5B
Fetch the destination drive number from 5B00H (DDRIVE) into Register A.
Original Source Code Comment: GET THE DESTINATION DRIVE NUMBER
535D
GOSUB to 5364H (DRVSET) to put ':', the drive digit and 0DH there.
Original Source Code Comment: SET IT
5360
POP HLEXI3 E1
Restore Register Pair HL ...
5361
POP DE D1
... Register Pair DE ...
5362
POP BC C1
... and Register Pair BC from the STACK.
5363
RET C9
RETurn to the caller.

5364H - DRVSET - Put a Drive Specifier and 0DH at HL

5364DRVSET
LD (HL),3AHLD (HL),':' 36 3A
DRVSET: Store 3AH (':'), the drive specifier, at HL.
Original Source Code Comment: SET A DRIVE SPECIFIER
5366
INC HL 23
INCrement Register Pair HL to the next place.
Original Source Code Comment: BUMP TO NEXT SLOT
5367
ADD A,30HADD A,'0' C6 30
ADD 30H to the binary drive number in Register A, making it the ASCII digit '0'-'3'.
Original Source Code Comment: MAKE THE DRIVE NUMBER ASCII
5369
LD (HL),A 77
Store the digit at HL.
536A
INC HL 23
INCrement Register Pair HL to the next place.
Original Source Code Comment: BUMP TO NEXT SLOT
536B
LD (HL),0DHLD (HL),0DH 36 0D
Store 0DH at HL, the end of the file spec.
Original Source Code Comment: SET TERMINATOR
536D
RET C9
RETurn to the caller.
Original Source Code Comment: EXIT. DONE

536EH - CKPROT - Check the Passwords of a Directory Record

536ECKPROT
PUSH BCSAV3 C5
CKPROT: Save Register Pair BC to the top of the STACK ...
536F
PUSH DE D5
... and Register Pair DE ...
5370
PUSH HL E5
... and Register Pair HL (the directory record).
5371
EX DE,HL EB
EXchange Register Pairs DE and HL: DE points to the directory record.
Original Source Code Comment: DE => DIR RECORD
5372
LD HL,0010HLD HL,DUPD 21 10 00
LET Register Pair HL = 0010H (DUPD), the offset of the hash code of the update password in a directory record.
Original Source Code Comment: OFFSET TO THE UPDATE HASH CODE
5375
ADD HL,DE 19
ADD Register Pair DE, so HL points to the update password code.
Original Source Code Comment: HL => UPD
5376
LD C,(HL) 4E
Fetch its low byte into Register C ...
Original Source Code Comment: PICK UP THE UPD
5377
INC HL 23
... INCrement Register Pair HL ...
5378
LD B,(HL) 46
... and fetch its high byte into Register B: Register Pair BC = the update password code.
5379
INC HL 23
INCrement Register Pair HL to offset 12H (DACC), the hash code of the access password.
Original Source Code Comment: BUMP TO THE ACC
537A
PUSH AF F5
Save Register Pair AF to the top of the STACK (the source's LD HL,(HL)) ...
Original Source Code Comment: PICK UP THE ACC
537B
LD A,(HL) 7E
... fetch the low byte of the access password code into Register A ...
537C
INC HL 23
... INCrement Register Pair HL ...
537D
LD H,(HL) 66
... fetch the high byte into Register H ...
537E
LD L,A 6F
... LET Register L = the low byte: Register Pair HL = the access password code ...
537F
POP AF F1
... and restore Register Pair AF.
5380
ADD HL,BC 09
ADD the update code (BC) to the access code (HL).
Original Source Code Comment: ADD THE TWO TOGETHER
5381
If the CARRY FLAG is set the sum went past FFFFH, so the codes are not both the code of a blank password: JUMP to 538BH (CKPRO0).
Original Source Code Comment: HAS EITHER ACC OR UPD ON IT

Both codes are the code of a blank password when their sum is 852CH.

5383
LD BC,852CHLD BC,.RES.(4296H*2) 01 2C 85
LET Register Pair BC = 852CH, twice 4296H, the hash code of a blank password on the source diskette (the source's .RES.(4296H*2)).
Original Source Code Comment: ARE BOTH PW'S BLANKS?
5386
OR A B7
Clear the CARRY FLAG for the SBC.
5387
SBC HL,BC ED 42
SUBtract BC from HL: the Z FLAG is set when both passwords are blank.
Original Source Code Comment: IF SO, HL = 0
5389
If the Z FLAG is set the file has no passwords, so JUMP to 53B9H (CKPRO2) to return with Z.
Original Source Code Comment: YES, BOTH BLANKS. EXIT 'Z'
538BCKPRO0
LD HL,0010HLD HL,DUPD 21 10 00
CKPRO0: LET Register Pair HL = 0010H (DUPD), the offset of the update password code.
Original Source Code Comment: OFFSET TO THE UPDATE HASH CODE
538E
ADD HL,DE 19
ADD Register Pair DE (the directory record): HL points to it.
Original Source Code Comment: HL => UPD TRAP
538F
PUSH AF F5
Save Register Pair AF (the source's LD HL,(HL)) ...
Original Source Code Comment: GET IT
5390
LD A,(HL) 7E
... fetch the low byte of the update password code into Register A ...
5391
INC HL 23
... INCrement Register Pair HL ...
5392
LD H,(HL) 66
... fetch the high byte into Register H ...
5393
LD L,A 6F
... LET Register L = the low byte: HL = the update password code ...
5394
POP AF F1
... and restore Register Pair AF.
5395
LD (5B07H),HLLD (PWSAVE),HL 22 07 5B
Store the update password code into 5B07H-5B08H (PWSAVE): CKPASS compares the password typed with it, and PROCE4 puts it into the new directory record.
Original Source Code Comment: SAVE IT FOR LATER
5398
LD HL,0012HLD HL,DACC 21 12 00
LET Register Pair HL = 0012H (DACC), the offset of the access password code.
Original Source Code Comment: OFFSET TO THE ACCESS HASH CODE
539B
ADD HL,DE 19
ADD Register Pair DE: HL points to it.
Original Source Code Comment: HL => ACC TRAP DOOR
539C
LD C,(HL) 4E
Fetch its low byte into Register C ...
Original Source Code Comment: PICK IT UP
539D
INC HL 23
... INCrement Register Pair HL ...
539E
LD B,(HL) 46
... and its high byte into Register B: BC = the access password code.
539F
LD HL,4296H 21 96 42
LET Register Pair HL = 4296H, the hash code of a blank password on the source diskette (a constant here, not an address).
Original Source Code Comment: TRAP FOR 'BLANKS'
53A2
PUSH HL E5
Save Register Pair HL (the source's CD BC, compare HL with BC) ...
Original Source Code Comment: ACC = BLANKS?
53A3
OR A B7
... clear the CARRY FLAG ...
53A4
SBC HL,BC ED 42
... SUBtract BC from HL: Z when the access password is blank ...
53A6
POP HL E1
... and restore Register Pair HL.
53A7
If the Z FLAG is set the access password is blank (only an update password), so JUMP to 53B7H (CKPRO1) to return NZ.
Original Source Code Comment: YES, EXIT AND SET 'NZ'
53A9
LD HL,(5B07H)LD HL,(PWSAVE) 2A 07 5B
Fetch the update password code from 5B07H (PWSAVE) into Register Pair HL.
Original Source Code Comment: GET THE UPDATE TRAP
53AC
PUSH HL E5
Save Register Pair HL (CD BC) ...
Original Source Code Comment: ACC = UPD?
53AD
OR A B7
... clear the CARRY FLAG ...
53AE
SBC HL,BC ED 42
... SUBtract BC: Z when the access password is the same as the update password ...
53B0
POP HL E1
... and restore Register Pair HL.
53B1
If the Z FLAG is set both passwords are the same, so JUMP to 53B7H (CKPRO1) to return NZ: the update password opens the file.
Original Source Code Comment: YES, EXIT
53B3
XOR A AF
The file has an access password of its own: set Register A to 00H and the Z FLAG ...
Original Source Code Comment: SET 'Z'
53B4
SCF 37
... and set the CARRY FLAG: the file is not converted.
Original Source Code Comment: SET THE CARRY FLAG
53B5
JUMP to 53B9H (CKPRO2) to return.
Original Source Code Comment: AND EXIT
53B7CKPRO1
OR 0FFH F6 FF
CKPRO1: OR Register A with FFH: the NZ FLAG is set and the CARRY FLAG cleared (an update password only).
Original Source Code Comment: CLEAR CARRY AND SET 'NZ'
53B9CKPRO2
POP HLEXI3 E1
CKPRO2: Restore Register Pair HL ...
53BA
POP DE D1
... Register Pair DE ...
53BB
POP BC C1
... and Register Pair BC from the STACK.
53BC
RET C9
RETurn: Z = no password, NZ = update password only, CARRY = access protected.

53BDH - DSPNAM - Display the File Name

53BDDSPNAM
PUSH BCSAV3 C5
DSPNAM: Save Register Pair BC to the top of the STACK ...
53BE
PUSH DE D5
... and Register Pair DE ...
53BF
PUSH HL E5
... and Register Pair HL.
53C0
LD HL,5B09HLD HL,FILNAM 21 09 5B
LET Register Pair HL = 5B09H (FILNAM), the file spec NAME/EXT made by COMPRS.
Original Source Code Comment: HL => COMPRESSED FILE NAME
53C3
GOSUB to 021BH (the ROM's PRINT) to display it.
Original Source Code Comment: DISPLAY IT
53C6
LET Register Pair HL = 5AFCH (SPCOFF): a space, 0FH (cursor off) and 03H.
Original Source Code Comment: OUTPUT A SPACE AND CURSOR OFF CHAR
53C9
GOSUB to 021BH (the ROM's PRINT) to display them.
53CC
POP HLEXI3 E1
Restore Register Pair HL ...
53CD
POP DE D1
... Register Pair DE ...
53CE
POP BC C1
... and Register Pair BC from the STACK.
53CF
RET C9
RETurn to the caller.

53D0H - INPUT - Display a Prompt and Get a One Character Reply

53D0INPUT
INPUT: Store the address of the prompt (Register Pair HL) into 53E9H (SAVTXT), the operand of the LD HL,0000H at 53E8H, so the prompt can be shown again.
Original Source Code Comment: SAVE POINTER IN CASE WE NEED IT AGAIN
53D3INPUT1
INPUT1: GOSUB to 021BH (the ROM's PRINT) to display the prompt at HL.
Original Source Code Comment: DISPLAY THE TEXT
53D6GETANS
LD HL,5B27HLD HL,KEYBUF 21 27 5B
GETANS: LET Register Pair HL = 5B27H (KEYBUF), the place for the reply.
Original Source Code Comment: SCRATCH PAD AREA
53D9
LD B,01H 06 01
LET Register B = 01H, the most characters KEYN takes.
Original Source Code Comment: SET FOR 1 CHAR
53DB
GOSUB to 0040H (the ROM's KEYN, line input): it returns Register B = the number of characters typed, HL = KEYBUF, or the CARRY FLAG set for BREAK.
Original Source Code Comment: KEYBOARD HANDLER
53DE
RET C D8
If the CARRY FLAG is set the BREAK key was pressed, so RETurn with it set.
Original Source Code Comment: RET IF BREAK KEY HIT
53DF
LD A,B 78
LET Register A = Register B, the number of characters typed.
Original Source Code Comment: GET THE COUNT
53E0
OR A B7
Set the FLAGS from Register A.
Original Source Code Comment: ANY ANSWER?
53E1
RET NZ C0
If the NZ FLAG is set a character was typed, so RETurn with HL = KEYBUF.
Original Source Code Comment: YES, EXIT
53E2
Nothing was typed: LET Register Pair HL = 5AA6H (INVALD), the text 'Invalid Reply'.
Original Source Code Comment: HL => 'INVALID REPLY' MSG
53E5
GOSUB to 021BH (the ROM's PRINT) to display it.
Original Source Code Comment: DISPLAY IT
53E8
LD HL,0000H 21 00 00
LET Register Pair HL = the prompt: the operand (53E9H-53EAH, SAVTXT) is 0000H in the file and was set at 53D0H.
Original Source Code Comment: PICK UP THE ORIGINAL MESSAGE
53EB
JUMP BACK to 53D3H (INPUT1) to show the prompt again.
Original Source Code Comment: AND DO IT AGAIN

53EDH - EXST - Existing File: Use It (Y/N/Q)?

53EDEXST
PUSH BCSAV3 C5
EXST: Save Register Pair BC to the top of the STACK ...
53EE
PUSH DE D5
... and Register Pair DE ...
53EF
PUSH HL E5
... and Register Pair HL.
53F0
LET Register Pair HL = 5A70H (EXSMSG), the text 'Existing File. Use it (Y/N/Q) ? '.
Original Source Code Comment: HL => EXISTING FILE MSG
53F3
GOSUB to 021BH (the ROM's PRINT) to display it after the file name.
Original Source Code Comment: DISPLAY IT
53F6
LD HL,5B27HLD HL,KEYBUF 21 27 5B
LET Register Pair HL = 5B27H (KEYBUF), the place for the reply.
Original Source Code Comment: PLACE TO STORE THE ANSWER
53F9
LD B,03H 06 03
LET Register B = 03H, the most characters KEYN takes.
Original Source Code Comment: SET FOR 3 CHARS
53FB
GOSUB to 0040H (the ROM's KEYN) to read the reply.
Original Source Code Comment: GET THE ANSWER
53FE
If the CARRY FLAG is set the BREAK key was pressed, so JUMP to 4030H (ABORT).
Original Source Code Comment: EXIT TO DOS IF BREAK KEY
5401
LD A,(HL) 7E
Fetch the first letter of the reply into Register A.
Original Source Code Comment: PICK UP THE 1ST LETTER
5402
CP 51HCP 'Q' FE 51
Compare Register A with 51H ('Q').
Original Source Code Comment: QUIT?
5404
If the Z FLAG is set the reply is Q (quit), so JUMP to 4030H (ABORT), back to TRSDOS READY.
Original Source Code Comment: EXIT TO DOS
5407
CP 4EHCP 'N' FE 4E
Compare Register A with 4EH ('N'): the Z FLAG is set for N; any other reply (Y, or only ENTER) leaves NZ, use the file.
Original Source Code Comment: NO?
5409
POP HLEXI3 E1
Restore Register Pair HL ...
540A
POP DE D1
... Register Pair DE ...
540B
POP BC C1
... and Register Pair BC (the POPs keep the flags).
540C
RET C9
RETurn: Z = N, skip the file; NZ = use the existing file.

540DH - SETFLG - Ask for the Password of a File

540DSETFLG
PUSH BC C5
SETFLG: Save Register Pair BC to the top of the STACK.
Original Source Code Comment: SAVE REGISTERS
540E
PUSH DE D5
Save Register Pair DE to the top of the STACK.
540F
XOR A AF
Set Register A to 00H.
Original Source Code Comment: CLEAR THE 'MOVE' FLAG
5410
LD (5B01H),ALD (MOVFLG),A 32 01 5B
Store 00H into 5B01H (MOVFLG): the password is to be typed.
5413
LET Register Pair HL = 5A92H (PASMSG), the text 'Enter Password for '.
Original Source Code Comment: HL => 'PASSWORD FOR' MSG
5416
GOSUB to 021BH (the ROM's PRINT) to display it.
5419
LD HL,5B09HLD HL,FILNAM 21 09 5B
LET Register Pair HL = 5B09H (FILNAM), the file spec NAME/EXT.
Original Source Code Comment: HL => FILENAME TO DISPLAY
541C
GOSUB to 021BH (the ROM's PRINT) to display it.
541F
LET Register Pair HL = 5AF7H (QUERY), the text ' ? '.
Original Source Code Comment: HL => '? ' MSG
5422
GOSUB to 021BH (the ROM's PRINT) to display it.
5425
LD HL,5B27HLD HL,KEYBUF 21 27 5B
LET Register Pair HL = 5B27H (KEYBUF), the place for the password.
Original Source Code Comment: SCRATCH PAD BUFFER
5428
LD B,08H 06 08
LET Register B = 08H, the length of a password.
Original Source Code Comment: SET FOR 8 CHARS
542A
GOSUB to 0040H (the ROM's KEYN) to read it: Register B = the characters typed.
Original Source Code Comment: GET THE ANSWER
542D
If the CARRY FLAG is set the BREAK key was pressed, so JUMP to 4030H (ABORT).
Original Source Code Comment: EXIT IF BREAK KEY
5430
LD A,B 78
LET Register A = Register B, the number of characters typed.
Original Source Code Comment: ANY ANSWER GIVEN?
5431
OR A B7
Set the FLAGS from Register A (this also clears the CARRY FLAG).
5432
If the Z FLAG is set only ENTER was pressed, so JUMP to 543AH (SETFL1).
Original Source Code Comment: NO, EXIT
5434
LD A,B 78
LET Register A = Register B, the number of characters ...
Original Source Code Comment: GET THE COUNT
5435
LD (5B06H),ALD (SVCNT),A 32 06 5B
... and store it into 5B06H (SVCNT), the length of the password typed.
Original Source Code Comment: SAVE THE CHAR COUNT
5438
JUMP to 543FH (SETFL2) to return with the CARRY FLAG clear.
Original Source Code Comment: AND EXIT
543ASETFL1
SUB 01H D6 01
SETFL1: SUBtract 01H from Register A (00H): Register A = FFH, the NZ and CARRY FLAGS set.
Original Source Code Comment: MAKE 'NZ' AND SET CARRY
543C
LD (5B01H),ALD (MOVFLG),A 32 01 5B
Store FFH into 5B01H (MOVFLG): the file is copied without a password and PROCE4 puts its update password code into the new directory record.
543FSETFL2
POP DE D1
SETFL2: Restore Register Pair DE from the STACK.
Original Source Code Comment: GET DE BACK
5440
POP BC C1
Restore Register Pair BC from the STACK.
5441
RET C9
RETurn: CARRY set = ENTER only, CARRY clear = a password is in KEYBUF.

5442H - CKPASS - Compare the Password Typed with the Update Password

5442CKPASS
PUSH BCSAV3 C5
CKPASS: Save Register Pair BC to the top of the STACK ...
5443
PUSH DE D5
... and Register Pair DE ...
5444
PUSH HL E5
... and Register Pair HL.
5445
LD HL,5B27HLD HL,KEYBUF 21 27 5B
LET Register Pair HL = 5B27H (KEYBUF), the password typed.
Original Source Code Comment: WHERE THE ANSWER IS STORED
5448
LD A,(5B06H)LD A,(SVCNT) 3A 06 5B
Fetch its length from 5B06H (SVCNT) into Register A ...
Original Source Code Comment: GET THE COUNT
544B
LD B,A 47
... and copy it into Register B.
Original Source Code Comment: INTO B
544C
GOSUB to 596EH (TRAP), which pads the password with spaces to 8 characters and returns its hash code (the source's trap door code) in Register Pair HL.
Original Source Code Comment: DO A TRAP DOOR ON IT
544F
LD DE,(5B07H)LD DE,(PWSAVE) ED 5B 07 5B
Fetch the update password code of the file from 5B07H (PWSAVE) into Register Pair DE.
Original Source Code Comment: GET THE SAVED ONE
5453
PUSH HL E5
Save Register Pair HL (the source's CD DE) ...
Original Source Code Comment: SEE IF MATCH
5454
OR A B7
... clear the CARRY FLAG ...
5455
SBC HL,DE ED 52
... SUBtract DE from HL: Z when the codes match ...
5457
POP HL E1
... and restore Register Pair HL.
5458
If the Z FLAG is set the password is right, so JUMP to 545DH (CKPAS1).
Original Source Code Comment: YES, WAS MATCH
545A
SCF 37
Set the CARRY FLAG: the password is wrong.
Original Source Code Comment: SET THE CARRY FLAG
545B
JUMP to 545EH (CKPAS2).
Original Source Code Comment: AND RETURN
545DCKPAS1
OR A B7
CKPAS1: OR Register A with itself to clear the CARRY FLAG.
Original Source Code Comment: CLEAR THE CARRY FLAG
545ECKPAS2
POP HLEXI3 E1
CKPAS2: Restore Register Pair HL ...
545F
POP DE D1
... Register Pair DE ...
5460
POP BC C1
... and Register Pair BC from the STACK.
5461
RET C9
RETurn: CARRY set = the password does not match.

5462H - CKDRIV - Check an ASCII Drive Number

5462CKDRIV
SUB 30HSUB '0' D6 30
CKDRIV: SUBtract 30H ('0') from the ASCII drive number in Register A.
Original Source Code Comment: MASK OFF ASCII
5464
If the CARRY FLAG is set the character was below '0', so JUMP to 5470H (CKDRV2).
Original Source Code Comment: ERROR, EXIT
5466
LD C,A 4F
Copy the binary drive number into Register C.
Original Source Code Comment: SAVE THE DRIVE NUMBER
5467
Fetch 4413H (MAXDRV, in SYS0), the highest drive number in the system, into Register A.
Original Source Code Comment: GET THE MAX DRIVE IN SYSTEM
546A
CP C B9
Compare MAXDRV with the drive number in Register C: the CARRY FLAG is set when the drive number is higher.
Original Source Code Comment: GREATER THAN WHAT YOU OWN?
546B
If the CARRY FLAG is set the drive is not in the system (a letter also lands here), so JUMP to 5474H (CKDRV3).
Original Source Code Comment: YES, EXIT
546D
XOR A AF
Set Register A to 00H and the Z FLAG.
Original Source Code Comment: SET 'Z'
546E
LD A,C 79
LET Register A = Register C, the binary drive number.
Original Source Code Comment: GET THE BINARY DRIVE BACK
546F
RET C9
RETurn with the Z FLAG set.
Original Source Code Comment: EXIT
5470CKDRV2
LD A,20HLD A,EBDRV 3E 20
CKDRV2: LET Register A = 20H, error 32 (EBDRV), invalid drive number.
Original Source Code Comment: BAD DRIVE NUMBER
5472
OR A B7
Set the NZ FLAG from Register A.
Original Source Code Comment: SET 'NZ'
5473
RET C9
RETurn with the NZ FLAG set.
Original Source Code Comment: EXIT
5474CKDRV3
LD A,02HLD A,EDNS 3E 02
CKDRV3: LET Register A = 02H, error 2 (EDNS), disk drive not in system.
Original Source Code Comment: DRIVE NOT IN SYSTEM
5476
OR A B7
Set the NZ FLAG from Register A.
Original Source Code Comment: SET 'NZ'
5477
RET C9
RETurn with the NZ FLAG set.

5478H - RWLOOP - Copy the File Byte by Byte

5478RWLOOP
LD DE,5B31HLD DE,DCBR 11 31 5B
RWLOOP: LET Register Pair DE = 5B31H (DCBR), the open file on the source diskette.
Original Source Code Comment: GET THE READ DCB
547B
GOSUB to 56E0H (READBT) to read its next byte into Register A: Z with the byte, or NZ with an error code.
Original Source Code Comment: READ A BYTE
547E
If the Z FLAG is set a byte was read, so JUMP to 548AH (RWLOO1) to write it.
Original Source Code Comment: GOOD READ
5480
LD B,A 47
Save the error code into Register B.
Original Source Code Comment: SAVE THE ERROR CODE
5481
AND 0FEHAND 0FEH E6 FE
MASK Register A with FEH, which makes error 29 (ENRF, record out of range) 28.
Original Source Code Comment: MASK A 29 TO A 28
5483
CP 1CHCP EEOF FE 1C
Compare Register A with 1CH, error 28 (EEOF), attempt to read past EOF.
Original Source Code Comment: END OF FILE?
5485
RET Z C8
If the Z FLAG is set the end of the file is reached, so RETurn with Z: the file is copied.
Original Source Code Comment: YES, EXIT
5486
LD A,B 78
LET Register A = Register B, the error code.
Original Source Code Comment: GET THE ERROR CODE BACK
5487
JUMP to 4409H (ERROR) to display it and return to TRSDOS READY.
Original Source Code Comment: AND EXIT
548ARWLOO1
LD DE,5B63HLD DE,DCBW 11 63 5B
RWLOO1: LET Register Pair DE = 5B63H (DCBW), the new file on the destination diskette.
Original Source Code Comment: GET THE WRITE DCB
548D
GOSUB to 001BH (the ROM's PUT) to write the byte in Register A to that file.
Original Source Code Comment: WRITE IT OUT
5490
If the Z FLAG is set the byte was written, so LOOP BACK to 5478H (RWLOOP) for the next byte.
Original Source Code Comment: LOOP IF GOOD WRITE
5492
JUMP to 4409H (ERROR) with the error code of the write in Register A.
Original Source Code Comment: ELSE EXIT

5495H - GETFIL - Find the Next File in the HIT of the Source Diskette

5495GETFIL
PUSH BC C5
GETFIL: Save Register Pair BC to the top of the STACK.
Original Source Code Comment: SAVE REGISTERS
5496
PUSH DE D5
Save Register Pair DE to the top of the STACK.
5497GETFI1
LD HL,(5B02H)LD HL,(FILPNT) 2A 02 5B
GETFI1: Fetch the address of the next HIT entry from 5B02H (FILPNT) into Register Pair HL.
Original Source Code Comment: GET THE FILE POINTER
549A
LD A,(HL) 7E
Fetch the HIT entry (the hash code of a file, or 00H) into Register A.
Original Source Code Comment: ANY HASH CODE HERE?
549B
OR A B7
Set the FLAGS from Register A.
549C
If the NZ FLAG is set a file has this HIT entry, so JUMP to 54ADH (GETFI2).
Original Source Code Comment: YES, PICK UP THE VALUES
549ENXTFIL
NXTFIL: GOSUB to 54C5H (BMPFIL) to move FILPNT and LFNCNT to the next HIT entry and count FILCNT down.
Original Source Code Comment: BUMP THE FILE POINTERS
54A1
LD A,(5B04H)LD A,(FILCNT) 3A 04 5B
Fetch the number of HIT entries left from 5B04H (FILCNT) into Register A.
Original Source Code Comment: GET THE FILE COUNT
54A4
OR A B7
Set the FLAGS from Register A.
Original Source Code Comment: WE DONE?
54A5
If the Z FLAG is set every entry has been looked at, so JUMP to 54AAH (NXTFI1).
Original Source Code Comment: YES, EXIT
54A7
If the P FLAG is set (FILCNT below 80H, always here) LOOP BACK to 5497H (GETFI1) for the next entry.
Original Source Code Comment: GET THE NEXT FILE
54AANXTFI1
SCF 37
NXTFI1: Set the CARRY FLAG: no file is left.
Original Source Code Comment: SET THE CARRY. END OF FILES
54AB
JUMP to 54C2H (GETFI3) to return.
Original Source Code Comment: AND EXIT
54ADGETFI2
LD A,(5B05H)LD A,(LFNCNT) 3A 05 5B
GETFI2: Fetch the record number that goes with this HIT entry from 5B05H (LFNCNT) into Register A ...
Original Source Code Comment: GET THE LFN COUNTER
54B0
LD B,A 47
... and copy it into Register B.
Original Source Code Comment: INTO B
54B1
LD A,(5AFFH)LD A,(SDRIVE) 3A FF 5A
Fetch the source drive number from 5AFFH (SDRIVE) into Register A ...
Original Source Code Comment: GET THE SOURCE DRIVE
54B4
LD C,A 4F
... and copy it into Register C.
Original Source Code Comment: INTO C
54B5
GOSUB to 576BH (DIRED) to read the directory sector of record B into 5F00H (BUFER2); Register Pair HL comes back at the record.
Original Source Code Comment: READ IN THE DIR RECORD FOR THIS GUY
54B8
If the NZ FLAG is set the sector could not be read, so JUMP to 4409H (ERROR).
Original Source Code Comment: EXIT IF ERROR
54BB
LD A,(HL) 7E
Fetch the attribute byte of the record (offset 0) into Register A.
Original Source Code Comment: GET THE ATTRIB BYTE
54BC
XOR 10H EE 10
Flip bit 4 with XOR 10H: bit 4 is set in a record that is in use, so after the XOR it is set only in a free record.
Original Source Code Comment: IF NO FILE, WILL SET THIS BIT
54BE
AND 0D8HAND 0D8H E6 D8
MASK with D8H (1101 1000): bit 7 (an extended record), bit 6 (a system file), bit 4 (free, after the XOR) and bit 3 (an invisible file).
Original Source Code Comment: FREE/EXTENDED/INVISIBLE/SYSTEM FILE?
54C0
If the NZ FLAG is set the record is one of those, so JUMP BACK to 549EH (NXTFIL) to skip it.
Original Source Code Comment: YES, SKIP IT
54C2GETFI3
POP DE D1
GETFI3: Restore Register Pair DE from the STACK.
Original Source Code Comment: RESTORE THE REGISTERS
54C3
POP BC C1
Restore Register Pair BC from the STACK.
54C4
RET C9
RETurn: Register Pair HL = the directory record of a file to convert and the CARRY FLAG clear, or the CARRY FLAG set when no file is left.

54C5H - BMPFIL - Move to the Next HIT Entry

54C5BMPFIL
LD HL,(5B02H)LD HL,(FILPNT) 2A 02 5B
BMPFIL: Fetch the address of the HIT entry from 5B02H (FILPNT) into Register Pair HL.
Original Source Code Comment: GET THE FILE POINTER
54C8
LD A,20H 3E 20
LET Register A = 20H (32): the HIT is walked a column at a time, 32 bytes apart (bits 0-4 of the offset are the column, which is the directory sector, bits 5-7 the record in it).
Original Source Code Comment: NUMBER OF BYTES TO BUMP
54CA
ADD A,L 85
ADD Register L to it.
Original Source Code Comment: BUMP THE POINTER
54CB
LD L,A 6F
LET Register L = the result.
Original Source Code Comment: BACK INTO L
54CC
If the NC FLAG is set the offset did not pass FFH, so JUMP to 54CFH (BMPFI1).
Original Source Code Comment: NO WRAP AROUND. COUNTINE
54CE
INC L 2C
The offset passed FFH and wrapped to the top of the column: INCrement Register L to the next column (the next directory sector).
Original Source Code Comment: BUMP TO NEXT RWO
54CFBMPFI1
LD (5B02H),HLLD (FILPNT),HL 22 02 5B
BMPFI1: Store the new HIT address into 5B02H (FILPNT).
Original Source Code Comment: SAVE IT
54D2
LD A,(5B05H)LD A,(LFNCNT) 3A 05 5B
Fetch the record number from 5B05H (LFNCNT) into Register A (bits 0-2 the directory sector, bits 3-5 the record in it).
Original Source Code Comment: GET THE LFN COUNTER
54D5
ADD A,08H C6 08
ADD 08H, the next record in the same sector.
Original Source Code Comment: BUMP TO NEXT LFN SLOT
54D7
AND 3FHAND 3FH E6 3F
MASK with 3FH, so it wraps after 64 records.
Original Source Code Comment: MASK FOR MAX VALUE
54D9
CP 08H FE 08
Compare Register A with 08H: below 8 it has wrapped to the top of the column.
Original Source Code Comment: DID WE WRAP AROUND?
54DB
If the NC FLAG is set it has not wrapped, so JUMP to 54DEH (BMPFI2).
Original Source Code Comment: NO, CONTINUE
54DD
INC A 3C
INCrement Register A to the next sector, as INC L did for FILPNT.
Original Source Code Comment: YES, BUMP THE COUNTER
54DEBMPFI2
LD (5B05H),ALD (LFNCNT),A 32 05 5B
BMPFI2: Store it into 5B05H (LFNCNT).
Original Source Code Comment: SAVE THE LFN COUNTER
54E1
LD A,(5B04H)LD A,(FILCNT) 3A 04 5B
Fetch the HIT entries left from 5B04H (FILCNT) into Register A.
Original Source Code Comment: GET THE FILE COUNTER
54E4
DEC A 3D
DECrement Register A for the entry just passed.
Original Source Code Comment: SUBTRACT THE ONE WE JUST DID
54E5
LD (5B04H),ALD (FILCNT),A 32 04 5B
Store it into 5B04H (FILCNT).
Original Source Code Comment: SAVE IT FOR NEXT TIME
54E8
RET C9
RETurn to the caller.
Original Source Code Comment: DONE

54E9H - PROCES - Convert One File

54E9PROCES
PROCES: GOSUB to 536EH (CKPROT) to check the passwords of the directory record at HL: Z none, NZ update only, CARRY access protected.
Original Source Code Comment: SEE IF 'ACC' PROTECTED
54EC
If the CARRY FLAG is set the file has an access password of its own, so JUMP to 5592H (PROCE6) to report it NOT Converted.
Original Source Code Comment: YES, EXIT AND DO NEXT FILE
54EF
Store the address of the directory record (Register Pair HL) into 5556H (SAVDIR), the operand of the LD HL,0000H at 5555H in PROCE4.
Original Source Code Comment: SAVE THE POINTER TO THE DIRECTORY ENTRY
54F2
PUSH AF F5
Save the flags of CKPROT (Register Pair AF) to the top of the STACK.
Original Source Code Comment: SAVE THE 'Z' 'NZ' FLAGS
54F3
GOSUB to 52B0H (COMPRS) to make NAME/EXT and 03H in 5B09H (FILNAM).
Original Source Code Comment: COMPRESS THE FILESPEC
54F6
GOSUB to 52EAH (MOVDCB) to copy the file spec into the read DCB (5B31H) and the write DCB (5B63H).
Original Source Code Comment: COPY THE NAMES TO THE READ/WRITE DCB'S
54F9
POP AF F1
Restore the flags of CKPROT.
Original Source Code Comment: GET THE FLAGS BACK
54FA
If the Z FLAG is set the file has no password, so JUMP to 550BH (PROCE1).
Original Source Code Comment: NO PASSWORD. CONTINUE

A file with an update password: the password is asked for, or ENTER copies the file without it.

54FCPROCE0
PROCE0: GOSUB to 540DH (SETFLG) to ask 'Enter Password for NAME/EXT ?' and read up to 8 characters into KEYBUF.
Original Source Code Comment: PROMPT FOR THE PASSWORD
54FF
If the CARRY FLAG is set only ENTER was pressed (MOVFLG = FFH), so JUMP to 550EH (PROCE2): the file is copied without its password and PROCE4 sets the password later.
Original Source Code Comment: USER HIT ENTER KEY. CONTINUE
5501
GOSUB to 5442H (CKPASS) to compare the hash code of the password typed with the update password code in PWSAVE.
Original Source Code Comment: SEE IF VALID PASSWORD
5504
If the CARRY FLAG is set the password is wrong, so LOOP BACK to 54FCH (PROCE0) to ask again.
Original Source Code Comment: NO, DO IT AGAIN
5506
GOSUB to 5306H (SETPAS) to add '.' and the password to the file spec in both DCBs.
Original Source Code Comment: SET THE PASSWORD
5509
JUMP to 550EH (PROCE2).
Original Source Code Comment: AND CONTINUE
550BPROCE1
PROCE1: GOSUB to 53BDH (DSPNAM) to display NAME/EXT, a space and turn the cursor off.
Original Source Code Comment: DISPLAY THE FILE NAME
550EPROCE2
PROCE2: GOSUB to 533DH (SETDRV) to add ':' and the drive number to the spec in both DCBs (the source drive to the read DCB, the destination drive to the write DCB).
Original Source Code Comment: SET THE DRIVE NUMBERS INTO DCB'S
5511
LD HL,5B95HLD HL,DBUFR1 21 95 5B
LET Register Pair HL = 5B95H (DBUFR1), the 256 byte buffer of the read DCB.
Original Source Code Comment: HL => READ DISK BUFFER
5514
LD DE,5B31HLD DE,DCBR 11 31 5B
LET Register Pair DE = 5B31H (DCBR), the read DCB with the file spec.
Original Source Code Comment: DE => READ DCB
5517
LD B,00H 06 00
LET Register B = 00H, the record length for ROPEN (0: the file is read a byte at a time).
Original Source Code Comment: SET FOR LRL OF 0
5519
GOSUB to 57AEH (ROPEN) to open the file on the source diskette: it searches the source HIT and directory and fills the DCB.
Original Source Code Comment: DO THE READ OPEN
551C
If the NZ FLAG is set the file could not be opened, so JUMP to 4409H (ERROR) with the error code in Register A.
Original Source Code Comment: EXIT IF ERROR
551F
LD A,(5B3AH)LD A,(DCBR+LRL) 3A 3A 5B
Fetch the logical record length of the source file from 5B3AH (DCBR+LRL, offset 09H, which SETDCB took from the directory record) into Register A.
Original Source Code Comment: GET THE SOURCE LRL
5522
Store it into 552CH (CHGLRL), the operand of the LD B,00H at 552BH, so the new file gets the same record length.
Original Source Code Comment: SET THE DESTINATION FOR SAME
5525
LD HL,5C95HLD HL,DBUFR2 21 95 5C
LET Register Pair HL = 5C95H (DBUFR2), the 256 byte buffer of the write DCB.
Original Source Code Comment: HL => WRITE DISK BUFFER
5528
LD DE,5B63HLD DE,DCBW 11 63 5B
LET Register Pair DE = 5B63H (DCBW), the write DCB with the file spec.
Original Source Code Comment: WRITE DCB
552B
LD B,00H 06 00
LET Register B = the record length of the source file: the operand (552CH, CHGLRL) is 00H in the file and was set at 5522H.
Original Source Code Comment: SET FOR LRL OF 256
552D
GOSUB to 4420H (INIT in SYS0) to open the file on the destination diskette, or create it when it is not there; the CARRY FLAG is set for a new file.
Original Source Code Comment: OPEN THE FILE ON MODEL 3
5530
If the NZ FLAG is set the file could not be opened or created, so JUMP to 4409H (ERROR).
Original Source Code Comment: EXIT IF ERROR
5533
If the CARRY FLAG is set the file is new, so JUMP to 553AH (PROCE3).
Original Source Code Comment: IS A NEW FILE. CONTINUE
5535
The file is already on the destination diskette: GOSUB to 53EDH (EXST) to ask 'Existing File. Use it (Y/N/Q) ?'.
Original Source Code Comment: IS EXISTING. PROMPT FOR IT
5538
If the Z FLAG is set the reply was N, so JUMP to 559EH (PROCE7) to go on to the next file.
Original Source Code Comment: NO, BUMP TO NEXT FILE
553APROCE3
PROCE3: GOSUB to 5478H (RWLOOP) to copy the file byte by byte until its end.
Original Source Code Comment: DO THE READ/WRITE
553D
LD A,0DHLD A,0DH 3E 0D
LET Register A = 0DH, a new line.
Original Source Code Comment: NEW LINE
553F
GOSUB to 0033H (the ROM's DSP) to display it.
Original Source Code Comment: OUT TO THE VIDEO
5542
GOSUB to 54C5H (BMPFIL) to move FILPNT to the next HIT entry.
Original Source Code Comment: BUMP THE POINTERS TO THE NEXT FILE
5545
LD A,(5B01H)LD A,(MOVFLG) 3A 01 5B
Fetch 5B01H (MOVFLG) into Register A: FFH when the password was not typed.
Original Source Code Comment: DO WE HAVE TO TRANSFER THE PASSWORD?
5548
OR A B7
Set the FLAGS from Register A.
5549
If the NZ FLAG is set the password must be moved by hand, so JUMP to 5555H (PROCE4).
Original Source Code Comment: YES, DO IT
554BDOCLOS
LD DE,5B63HLD DE,DCBW 11 63 5B
DOCLOS: LET Register Pair DE = 5B63H (DCBW), the new file.
Original Source Code Comment: NO, CLOSE THE FILE
554E
GOSUB to 4428H (CLOSE in SYS0) to close it.
5551
If the NZ FLAG is set the close failed, so JUMP to 4409H (ERROR).
Original Source Code Comment: EXIT IF ERROR
5554
RET C9
RETurn to the main loop: the file is converted.
Original Source Code Comment: ELSE RETURN

5555H - PROCE4 - Put the Update Password and the Attributes into the New Directory Record

Only ENTER was pressed for the password: the update password code and the attribute byte of the source record go into the new directory record.

5555PROCE4
LD HL,0000H 21 00 00
PROCE4: LET Register Pair HL = the directory record of the source file: the operand (5556H-5557H, SAVDIR) is 0000H in the file and was set at 54EFH.
Original Source Code Comment: POINTER TO DIR SAVED HERE
5558
LD A,(HL) 7E
Fetch the attribute byte of the source file's record into Register A. BUFER2 (5F00H) holds that record's sector unless ROPEN read an extended record (DOLINK) into it since.
Original Source Code Comment: GET THE ATTRIB BYTE
5559
PUSH AF F5
Save the attribute byte (Register Pair AF) to the top of the STACK.
Original Source Code Comment: SAVE IT ON THE STACK
555A
LD DE,(5B07H)LD DE,(PWSAVE) ED 5B 07 5B
Fetch the update password code of the source file from 5B07H (PWSAVE) into Register Pair DE.
Original Source Code Comment: GET THE SAVED UPDATE PW
555E
LD HL,4296H 21 96 42
LET Register Pair HL = 4296H, the hash code of a blank password on the source diskette (a constant here, not an address).
Original Source Code Comment: BLANKS?
5561
PUSH HL E5
Save Register Pair HL (the source's CD DE) ...
5562
OR A B7
... clear the CARRY FLAG ...
5563
SBC HL,DE ED 52
... SUBtract DE from HL: Z when the update password is blank ...
5565
POP HL E1
... and restore Register Pair HL.
5566
If the NZ FLAG is set the password is not blank, so JUMP to 556BH (PROCE5) to keep its code.
Original Source Code Comment: NO, CONTINUE
5568
LD DE,5CEFHLD DE,MASTPW 11 EF 5C
LET Register Pair DE = 5CEFH (MASTPW), the hash code TRSDOS 1.3 has for a blank password (a constant here, not an address).
Original Source Code Comment: YES, CHANGE TO 'NEW' BLANKS
556BPROCE5
PUSH DE D5
PROCE5: Save the password code (Register Pair DE) to the top of the STACK.
Original Source Code Comment: SAVE IT ON THE STACK
556C
LD A,(5B6AH)LD A,(DCBW+LFN) 3A 6A 5B
Fetch the logical file number of the new file from 5B6AH (DCBW+LFN, offset 07H) into Register A ...
Original Source Code Comment: GET THE MODEL 3 LFN
556F
LD B,A 47
... and copy it into Register B.
Original Source Code Comment: INTO B
5570
LD A,(5B69H)LD A,(DCBW+DRVNUM) 3A 69 5B
Fetch its drive number from 5B69H (DCBW+DRVNUM, offset 06H) into Register A ...
Original Source Code Comment: GET THE MODEL 3 DRIVE NUMBER
5573
LD C,A 4F
... and copy it into Register C.
Original Source Code Comment: INTO C
5574
Store Register Pair BC into 5587H-5588H (SAVLFN), the operand of the LD BC,0000H at 5586H, for the WRDIR call.
Original Source Code Comment: SAVE IT FOR A DIRECTORY WRITE
5578
GOSUB to 4AD8H (LFNDIR in SYS0): Register Pair HL returns at the new file's directory record in BUFF1 (4300H-43FFH), the buffer WRDIR writes.
Original Source Code Comment: GET HL POINTING TO THE DIR ENTRY
557B
EX DE,HL EB
EXchange Register Pairs DE and HL: DE points to the directory record.
Original Source Code Comment: DE => FILE
557C
LD HL,0010HLD HL,DUPD 21 10 00
LET Register Pair HL = 0010H (DUPD), the offset of the update password code.
Original Source Code Comment: OFFSET TO THE PASSWORD
557F
ADD HL,DE 19
ADD Register Pair DE: HL points to the update password code of the new record.
Original Source Code Comment: HL => PASSWORD
5580
POP BC C1
Restore the password code into Register Pair BC.
Original Source Code Comment: GET THE TRAP DOOR CODE BACK
5581
LD (HL),C 71
Store its low byte into the record (the source's LD (HL),BC) ...
Original Source Code Comment: SET IT
5582
INC HL 23
... INCrement Register Pair HL ...
5583
LD (HL),B 70
... and store its high byte.
5584
POP AF F1
Restore the attribute byte of the source file into Register A.
Original Source Code Comment: GET THE ATTRIB BYTE BACK
5585
LD (DE),A 12
Store it into offset 0 of the new record (DE), the attribute byte.
Original Source Code Comment: SET IT IN THE ATTRIB SLOT
5586
LD BC,0000H 01 00 00
LET Register Pair BC = the logical file number (B) and drive (C) of the new file: the operand (5587H-5588H, SAVLFN) is 0000H in the file and was set at 5574H.
Original Source Code Comment: LFN AND DRIVE NUMBER SAVED HERE
5589
GOSUB to 4A7BH (WRDIR in SYS0) to write the directory sector in BUFF1 back to the destination diskette.
Original Source Code Comment: WRITE OUT THE MODIFIED DIRECTORY
558C
If the NZ FLAG is set the write failed, so JUMP to 4409H (ERROR).
Original Source Code Comment: EXIT IF ERROR
558F
JUMP to 554BH (DOCLOS) to close the new file.
Original Source Code Comment: CLOSE THE WRITE FILE

5592H - PROCE6 / PROCE7 - NOT Converted (Protected File); the Next File

5592PROCE6
PROCE6: GOSUB to 52B0H (COMPRS) to make NAME/EXT in FILNAM.
Original Source Code Comment: COMPRESS THE NAME
5595
GOSUB to 53BDH (DSPNAM) to display it.
Original Source Code Comment: DISPLAY THE NAME
5598
LET Register Pair HL = 5AD8H (SKIP), the text 'NOT Converted (Protected File)'.
Original Source Code Comment: HL => 'SKIPPED' MSG
559B
GOSUB to 021BH (the ROM's PRINT) to display it.
559EPROCE7
PROCE7: GOSUB to 54C5H (BMPFIL) to move FILPNT to the next HIT entry.
Original Source Code Comment: BUMP TO NEXT FILE
55A1
RET C9
RETurn to the main loop.
Original Source Code Comment: AND EXIT

55A2H - DUMMY / DRIVE / TRK / SEC / DIRTK - Variables of the Source Diskette Routines (M1M3READ)

55A2-55AADUMMY
DEFS 9
DUMMY: 9 bytes, not in the file. SPEEK reads the ID field of a sector here (Read Address); its first byte is the track the head is on.
Original Source Code Comment: DUMMY BUFFER FOR READ TRACK ADDRESS
55ABDRIVE
DEFB 00H 00
DRIVE: the select byte of the drive in use (bit 7 clear, single density), stored by SPEEK and sent to port F4H by CSELCT.
Original Source Code Comment: CURRENT DRIVE IN USE
55ACTRK
DEFB 00H 00
TRK: the source names it the current track in use; nothing in CONVERT reads or writes it.
Original Source Code Comment: CURRENT TRACK IN USE
55ADSEC
DEFB 00H 00
SEC: the source names it the current sector in use; nothing in CONVERT reads or writes it.
Original Source Code Comment: CURRENT SECTOR IN USE
55AEDRIVE1
DEFB 11H 11
DRIVE1 (DIRTK): 11H (17), the directory track of drive 0. TRKGT adds the drive number to 55AEH.
Original Source Code Comment: DIRECTORY TRACK FOR DRIVE 1
55AFDRIVE2
DEFB 11H 11
DRIVE2: 11H, the directory track of drive 1.
Original Source Code Comment: " " " " 2
55B0DRIVE3
DEFB 11H 11
DRIVE3: 11H, the directory track of drive 2.
Original Source Code Comment: " " " " 3
55B1DRIVE4
DEFB 11H 11
DRIVE4: 11H, the directory track of drive 3.
Original Source Code Comment: " " " " 4

55B2H - CSEL / CSELCT - Select the Drive in Single Density

55B2CSEL
LD A,C 79
CSEL: LET Register A = Register C, the drive number.
Original Source Code Comment: GET THE DRIVE NUMBER
55B3
GOSUB to 45E9H (SITIT in SYS0) to turn it into its select bit (01H, 02H, 04H or 08H); bit 7 stays clear, single density.
Original Source Code Comment: MAKE IT A BIT PATTERN
55B6
JUMP to 55BDH (CSEL1).
Original Source Code Comment: AND DO THE SELECT
55B8CSELCT
CSELCT: Fetch the select byte of the drive from 55ABH (DRIVE) into Register A.
Original Source Code Comment: GET THE DRIVE BIT PATTERN
55BB
AND 7FHAND 7FH E6 7F
MASK it with 7FH: bit 7 of port F4H selects double density, so clearing it keeps the drive in single density.
Original Source Code Comment: INSURE SINGLE DENSITY
55BDCSEL1
CSEL1: OUTput Register A to port F4H, the drive select latch: it selects the drive and starts its motor (single density, no wait).
Original Source Code Comment: OUT TO THE SELECT LATCH
55BFDELEY
NOP 00
DELEY: No operation (a short delay).
55C0
RET C9
RETurn with the select byte in Register A.
Original Source Code Comment: EXIT

55C1H - SPEEK - Seek a Track of the Source Diskette

The FDC is told which track the head is on by reading an ID field first, then it seeks.

55C1SPEEK
DI F3
SPEEK: Disable the maskable interrupts.
55C2
LD A,C 79
LET Register A = Register C, the drive number.
Original Source Code Comment: GET THE DRIVE NUMBER
55C3
GOSUB to 45E9H (SITIT) to turn it into its select bit.
Original Source Code Comment: MAKE IT A BIT PATTERN
55C6
AND 7FHAND 7FH E6 7F
MASK it with 7FH: single density.
Original Source Code Comment: INSURE SINGLE DENSITY
55C8
Store the select byte into 55ABH (DRIVE) for CSELCT.
Original Source Code Comment: SAVE IT
55CB
LD A,D 7A
LET Register A = Register D, the track wanted.
Original Source Code Comment: GET THE TRACK NUMBER
55CC
Store it into 55FDH (SVTRK), the operand of the LD D,00H at 55FCH.
Original Source Code Comment: SAVE IT FOR LATER
55CF
INput the FDC status from port F0H into Register A.
Original Source Code Comment: GET THE FDC STATUS
55D1
AND 80H E6 80
MASK it with 80H, bit 7 (not ready): the Z FLAG is set when the drive is ready, its motor running.
Original Source Code Comment: MOTOR ON?
55D3
If the Z FLAG is set the motor is running, so JUMP to 55E2H (SPEEK5) to seek.
Original Source Code Comment: YES, DO THE SEEK
55D5
GOSUB to 55B8H (CSELCT) to select the drive and start its motor.
Original Source Code Comment: SELECT THE DRIVE
55D8
LD A,0D0HLD A,CTERM 3E D0
LET Register A = D0H, the FDC's Force Interrupt command (the source's CTERM).
Original Source Code Comment: INTERRUPT THE DISK
55DA
OUTput D0H to port F0H, the FDC command register, to end any command.
55DC
LD BC,0D000HLD BC,0D000H 01 00 D0
LET Register Pair BC = D000H, the count of the delay.
Original Source Code Comment: AND DELAY FOR MOTOR SPEED
55DF
GOSUB to 0060H (the ROM's PAUSE) to wait while the motor comes up to speed.
55E2SPEEK5
SPEEK5: GOSUB to 5607H (CKBSY) to wait until the FDC is not busy.
Original Source Code Comment: WILL FOR FDC
55E5
LD BC,00F3HLD BC,CDATA 01 F3 00
LET Register Pair BC = 00F3H: Register C = F3H, the FDC data port, for INI; Register B = 00H.
Original Source Code Comment: B=0, C=FDC DATA PORT
55E8
GOSUB to 55B8H (CSELCT) to select the drive again; Register A returns the select byte.
Original Source Code Comment: RESELECT THE DRIVE
55EB
LD D,A 57
Copy the select byte into Register D for the read loop at 5638H.
Original Source Code Comment: KEEP A COPY OF IT
55EC
XOR A AF
Set Register A to 00H (the source has the CALL BOTNMI and LD A,80H for the NMI starred out).
Original Source Code Comment: INSURE INTERRUPTS OFF
55ED
OUTput 00H to port E4H, the NMI mask latch: no disk NMIs, the reads are polled.
55EF
LD E,02H 1E 02
LET Register E = 02H, the data request mask (the read loop tests BIT 1 itself and does not use Register E).
Original Source Code Comment: DATA REQUEST MASK
55F1
LD HL,55A2HLD HL,DUMMY 21 A2 55
LET Register Pair HL = 55A2H (DUMMY), the 9 byte place for the ID field.
Original Source Code Comment: HL => DUMMY BUFFER AREA
55F4
LD A,0C4HLD A,RADDR 3E C4
LET Register A = C4H (the source's RADDR): the FDC's Read Address command (bits 7-4 1100) with the 15 ms delay (bit 2).
Original Source Code Comment: READ TRACK ADDRESS COMMAND
55F6
GOSUB to 5633H (OUTRED) to issue it and read the ID field of the next sector under the head into DUMMY.
Original Source Code Comment: DO THE READ
55F9
LD A,(55A2H)LD A,(DUMMY) 3A A2 55
Fetch the first byte of the ID field, the track the head is on, from 55A2H (DUMMY) into Register A.
Original Source Code Comment: GET THE TRACK ADDRESS
55FC
LD D,00H 16 00
LET Register D = the track wanted: the operand (55FDH, SVTRK) is 00H in the file and was set at 55CCH.
Original Source Code Comment: DESIRED TRACK SAVED HERE
55FE
OUTput the track the head is on to port F1H, the FDC track register.
Original Source Code Comment: TELL FDC WHERE WE ARE
5600
LD A,D 7A
LET Register A = Register D, the track wanted.
Original Source Code Comment: GET THE DESIRED TRACK
5601
OUTput it to port F3H, the FDC data register, where the Seek takes its destination.
Original Source Code Comment: OUTPUT TO THE FDC
5603
LD A,1CHLD A,CSEEK 3E 1C
LET Register A = 1CH (the source's CSEEK): the FDC's Seek command (0001) with head load (bit 3), verify (bit 2) and 6 ms steps (bits 1-0 00).
Original Source Code Comment: THE SEEK COMMAND
5605
OUTput 1CH to port F0H to start the seek, then fall into CKBSY to wait for its end.
Original Source Code Comment: ISSUE THE COMMAND

5607H - CKBSY - Wait until the FDC Is Not Busy

5607CKBSY
CKBSY: GOSUB to 5614H (DELLU) for a short delay before the status is valid.
Original Source Code Comment: 'SDELY'
560ACKBS0
CKBS0: INput the FDC status from port F0H into Register A.
Original Source Code Comment: GET FDC STATUS
560C
BIT 0,A CB 47
Test bit 0 (busy).
Original Source Code Comment: BUSY?
560E
RET Z C8
If the Z FLAG is set the FDC is not busy, so RETurn with the status in Register A.
Original Source Code Comment: NO, RETURN
560F
GOSUB to 55B8H (CSELCT) to select the drive again, which keeps its motor running.
Original Source Code Comment: KEEP THE DRIVE GOING
5612
LOOP BACK to 560AH (CKBS0).
Original Source Code Comment: AND CONTINUE LOOKING

5614H - DELLU / DELLZ / SDELY / SDELAZ - Delays

5614DELLU
DELLU: GOSUB to 5617H (DELLZ), then fall into it again: two passes.
5617DELLZ
PUSH AF F5
DELLZ: PUSH Register Pair AF to the top of the STACK (delay only).
5618
POP AF F1
POP Register Pair AF (no change).
5619
PUSH AF F5
PUSH Register Pair AF (delay only).
561A
POP AF F1
POP Register Pair AF (no change).
561BSDELY
PUSH AF F5
SDELY: PUSH Register Pair AF (delay only).
561C
POP AF F1
POP Register Pair AF (no change).
561DSDELAZ
PUSH AF F5
SDELAZ: PUSH Register Pair AF (delay only).
561E
POP AF F1
POP Register Pair AF (no change).
561F
NOP 00
No operation (delay).
5620
RET C9
RETurn to the caller.

5621H - READT / OUTRED - Read a Sector (or an ID Field) by Polling the FDC

5621READT
LD BC,00F3HLD BC,CDATA 01 F3 00
READT: LET Register Pair BC = 00F3H: Register C = F3H, the FDC data port; Register B = 00H, 256 bytes for INI.
Original Source Code Comment: B=0, C=FDC DATA PORT
5624
GOSUB to 55B8H (CSELCT) to select the drive; Register A returns the select byte.
Original Source Code Comment: SELECT THE DRIVE
5627
LD D,A 57
Copy the select byte into Register D for the read loop.
Original Source Code Comment: SAVE COPY OF IT
5628
DI F3
Disable the maskable interrupts.
5629
XOR A AF
Set Register A to 00H (the source has CALL BOTNMI and LD A,80H starred out).
Original Source Code Comment: INSURE INTERRUPTS OFF
562A
OUTput 00H to port E4H, the NMI mask latch: no disk NMIs.
562C
LD E,02H 1E 02
LET Register E = 02H, the data request mask (not used by the loop).
Original Source Code Comment: DATA REQUEST MASK
562E
LD HL,0000H 21 00 00
LET Register Pair HL = the buffer for the sector: the operand (562FH-5630H, RHLL) is 0000H in the file and was set by MREAD at 5653H.
Original Source Code Comment: SAVE BUFFER POINTER
5631
LD A,84HLD A,CREAD 3E 84
LET Register A = 84H (the source's CREAD): the FDC's Read Sector command (bits 7-5 100), one sector, with the 15 ms delay (bit 2).
Original Source Code Comment: READ COMMAND
5633OUTRED
OUTRED: OUTput the command in Register A to port F0H, the FDC command register.
Original Source Code Comment: TO THE FDC
5635
GOSUB to 5614H (DELLU) for a short delay before the status is valid.
Original Source Code Comment: 'SDELY'
5638FST
LD A,D 7A
FST: LET Register A = Register D, the select byte.
Original Source Code Comment: GET THE DRIVE NUMBER
5639
OUTput it to port F4H to keep the drive selected and its motor running.
Original Source Code Comment: KEEP SELECTING IT
563BFST1
FST1: INput the FDC status from port F0H into Register A.
Original Source Code Comment: GET THE FDC STATUS
563D
BIT 1,A CB 4F
Test bit 1, the data request: set when the FDC has a byte.
Original Source Code Comment: FDC DRQ?
563F
If the Z FLAG is set there is no byte, so JUMP to 564DH (FST2).
5642
INI ED A2
INI: read the byte from port F3H (Register C) into the memory at HL, INCrement HL and DECrement Register B.
Original Source Code Comment: READ THE BYTE
5644
If the NZ FLAG is set (Register B not 0) LOOP BACK to 563BH (FST1) for the next byte.
Original Source Code Comment: READ ALL BYTES

The sector buffer is full.

5647
LD HL,0000H 21 00 00
256 bytes have been read: LET Register Pair HL = 0000H, so any byte the FDC still has goes into the ROM, where the write changes nothing.
564A
JUMP BACK to 5638H (FST).
Original Source Code Comment: ABORT MISSION
564DFST2
BIT 0,A CB 47
FST2: Test bit 0 of the status (busy).
Original Source Code Comment: IS FDC BUSY
564F
If the NZ FLAG is set the command is still running, so LOOP BACK to 563BH (FST1).
Original Source Code Comment: RETRY AS LONG AS FDC BUSY
5652
RET C9
RETurn with the final FDC status in Register A.

5653H - MREAD - Read a Sector of the Source Diskette, 9 Tries

5653MREAD
MREAD: Store the buffer address (Register Pair HL) into 562FH (RHLL), the operand of the LD HL,0000H at 562EH in READT.
Original Source Code Comment: SAVE BUFFER POINTER
5656
DI F3
Disable the maskable interrupts.
5657
GOSUB to 55B2H (CSEL) to select the drive in Register C.
Original Source Code Comment: SELECT THE DRIVE
565A
LD A,0D0HLD A,CTERM 3E D0
LET Register A = D0H, Force Interrupt.
Original Source Code Comment: INTERRUPT THE FDC
565C
OUTput D0H to port F0H to end any command.
565E
GOSUB to 5614H (DELLU) for a short delay.
5661
LD A,0D0HLD A,CTERM 3E D0
LET Register A = D0H, Force Interrupt.
5663
OUTput D0H to port F0H a second time.
5665
GOSUB to 5614H (DELLU) for a short delay.
5668
GOSUB to 55B2H (CSEL) to select the drive again.
Original Source Code Comment: SELECT THE DRIVE
566B
LD B,09H 06 09
LET Register B = 09H, the number of tries.
Original Source Code Comment: SET FOR 9 RETRIES
566DRERED
PUSH BC C5
RERED: Save the tries left (Register Pair BC) to the top of the STACK.
Original Source Code Comment: SAVE RETRY COUNT
566E
PUSH DE D5
Save the track and sector (Register Pair DE) to the top of the STACK.
Original Source Code Comment: SAVE TRACK SECTOR
566F
PUSH HL E5
Save the buffer address (Register Pair HL) to the top of the STACK.
Original Source Code Comment: SAVE BUFFER POINTER
5670
GOSUB to 55C1H (SPEEK) to seek track D on drive C; it returns the FDC status in Register A.
5673
POP HL E1
Restore the buffer address into Register Pair HL.
Original Source Code Comment: GET BUFFER POINTER BACK
5674
POP DE D1
Restore the track and sector into Register Pair DE.
5675
POP BC C1
Restore the tries left into Register Pair BC.
5676
AND 18H E6 18
MASK the status with 18H: bit 4 (seek error) and bit 3 (CRC error).
Original Source Code Comment: SEEK OR CRC ERROR?
5678
If the NZ FLAG is set the seek failed, so JUMP to 569FH (NOREAD) to try again.
Original Source Code Comment: YES, DO A RETRY
567A
LD A,0D0HLD A,CTERM 3E D0
LET Register A = D0H, Force Interrupt.
567C
OUTput D0H to port F0H.
567E
GOSUB to 5614H (DELLU) for a short delay.
5681
LD A,0D0HLD A,CTERM 3E D0
LET Register A = D0H, Force Interrupt.
5683
OUTput D0H to port F0H a second time.
5685
GOSUB to 5614H (DELLU) for a short delay.
5688
GOSUB to 55B8H (CSELCT) to select the drive again.
568B
LD A,E 7B
LET Register A = Register E, the sector wanted (0-9).
Original Source Code Comment: GET THE SECTOR NUMBER
568C
OUTput it to port F2H, the FDC sector register.
Original Source Code Comment: OUTPUT TO THE SECTOR REGISTER
568E
GOSUB to 5614H (DELLU) for a short delay.
5691
PUSH BC C5
Save Register Pair BC (the tries left) to the top of the STACK ...
5692
PUSH DE D5
... and Register Pair DE (track and sector) ...
5693
PUSH HL E5
... and Register Pair HL (the buffer).
5694
GOSUB to 5621H (READT) to read the sector into the buffer in RHLL.
Original Source Code Comment: READ IT IN
5697
POP HL E1
Restore Register Pair HL ...
5698
POP DE D1
... Register Pair DE ...
5699
POP BC C1
... and Register Pair BC.
569A
INput the FDC status from port F0H into Register A.
Original Source Code Comment: ANY ERROR?
569C
AND 1FHAND 1FH E6 1F
MASK it with 1FH: bits 0-4 (busy, data request, lost data, CRC error, record not found).
569E
RET Z C8
If the Z FLAG is set the sector was read with no error, so RETurn with Z.
569FNOREAD
PUSH AF F5
NOREAD: Save the masked status (Register Pair AF) to the top of the STACK.
Original Source Code Comment: SAVE THE FLAGS
56A0
LD A,0D0HLD A,CTERM 3E D0
LET Register A = D0H, Force Interrupt.
Original Source Code Comment: TERMINATE THE OPERATION
56A2
OUTput D0H to port F0H to end the command.
56A4
POP AF F1
Restore the masked status into Register Pair AF.
Original Source Code Comment: GET THE FLAGS BACK
56A5
DECrement Register B (the tries left) and, if it is not 0, LOOP BACK to 566DH (RERED) to try again.
Original Source Code Comment: YES, DO A RETRY
56A7
LD B,01HLD B,ECRC 06 01
9 tries failed: LET Register B = 01H, error 1 (ECRC), CRC error during disk I/O.
Original Source Code Comment: CRC ERROR CODE
56A9
BIT 3,A CB 5F
Test bit 3 of the masked status, the CRC error.
Original Source Code Comment: CRC ERROR?
56AB
If the NZ FLAG is set it was a CRC error, so JUMP to 56AFH (TSTS1).
Original Source Code Comment: YES, EXIT
56AD
LD B,04HLD B,ESKER 06 04
LET Register B = 04H, error 4 (ESKER), seek error.
Original Source Code Comment: ASSUME SEEK ERROR
56AFTSTS1
LD A,B 78
TSTS1: LET Register A = Register B, the error code.
Original Source Code Comment: GET THE ERROR CODE
56B0
OR A B7
Set the NZ FLAG from Register A.
Original Source Code Comment: SET 'NZ'
56B1
RET C9
RETurn with the NZ FLAG set and the error code in Register A.

56B2H - READ0 - Read a Record

READ0 is not called by any instruction of CONVERT.

56B2READ0
READ0 (no instruction of CONVERT calls it): GOSUB to 4881H (SAVER in SYS0), which checks that the DCB at DE is open, saves the registers and points Register IX to the DCB.
Original Source Code Comment: SAVE THE USERS REGISTERS
56B5
BIT 7,(IX+1)BIT 7,(IX+PROT) DD CB 01 7E
Test bit 7 of IX+01H (PROT): set by READBT and SETDCB for byte access.
Original Source Code Comment: LRL OF 256?
56B9
If the Z FLAG is set (whole records of 256 bytes) JUMP to 56CBH (RDREC).
Original Source Code Comment: YES, GO READ
56BB
LD B,(IX+9)LD B,(IX+LRL) DD 46 09
Fetch the logical record length from IX+09H (LRL) into Register B, the count of bytes to read.
Original Source Code Comment: GET THE LRL
56BEREAD2
PUSH HL E5
READ2: Save the buffer pointer (Register Pair HL) to the top of the STACK.
Original Source Code Comment: SAVE BUFFER POINTER
56BF
PUSH BC C5
Save the count (Register Pair BC) to the top of the STACK.
Original Source Code Comment: SAVE LRL
56C0
GOSUB to 56E7H (RBYTE) to read the next byte of the file into Register A.
Original Source Code Comment: READ A BYTE FROM DISK
56C3
POP BC C1
Restore the count into Register Pair BC.
56C4
POP HL E1
Restore the buffer pointer into Register Pair HL.
56C5
RET NZ C0
If the NZ FLAG is set there was an error, so RETurn with it.
Original Source Code Comment: RET IF ERROR
56C6
LD (HL),A 77
Store the byte into the buffer at HL.
Original Source Code Comment: PUT IT INTO THE BUFFER
56C7
INC HL 23
INCrement Register Pair HL to the next place.
Original Source Code Comment: BUMP POINTER TO NEXT LOC
56C8
DECrement Register B and LOOP BACK to 56BEH (READ2) for the rest of the record.
Original Source Code Comment: CONTINUE FOR COUNT
56CA
RET C9
RETurn with the Z FLAG set.

56CBH - RDREC / RDSEC - Read the Next Sector of a File into its Buffer

56CBRDREC
RDREC: GOSUB to 4A2EH (GETPRN in SYS0), which compares the next record number (IX+0AH-0BH) with the ending record number (IX+0CH-0DH) and the EOF byte (IX+08H): NZ with an error when the record is past the end.
Original Source Code Comment: GET THE RECORD NUMBER
56CE
RET NZ C0
If the NZ FLAG is set the record is not in the file, so RETurn with the error.
Original Source Code Comment: EXIT IF NOT IN RANGE
56CFRDSEC
RDSEC: GOSUB to 5709H (GETPA) to find the track (Register D) and sector (Register E) of the record and the drive (Register C).
Original Source Code Comment: GET PHYSICAL DISK ADDRESS
56D2
RET NZ C0
If the NZ FLAG is set the record is outside the extents, so RETurn with the error.
Original Source Code Comment: EXIT IF ERROR
56D3
RES 5,(IX+1)RES 5,(IX+PROT) DD CB 01 AE
RESet bit 5 of IX+01H (PROT): the record in the buffer is the one wanted.
Original Source Code Comment: SHOW RECORD HAS BEEN READ
56D7
LD L,(IX+3)LD L,(IX+BUFL) DD 6E 03
Fetch the low byte of the buffer address from IX+03H (BUFL) into Register L ...
Original Source Code Comment: GET THE BUFFER ADDRESS IN HL
56DA
LD H,(IX+4)LD H,(IX+BUFH) DD 66 04
... and the high byte from IX+04H (BUFH) into Register H.
56DD
JUMP to 5653H (MREAD) to read the sector into the buffer; it returns to the caller of RDREC.
Original Source Code Comment: GO READ SECTOR INTO BUFFER

56E0H - READBT / RBYTE - Read the Next Byte of a File

56E0READBT
READBT: GOSUB to 4881H (SAVER in SYS0), which checks that the DCB at DE is open (error 38 if not), saves the registers and points Register IX to the DCB.
56E3
SET 7,(IX+1)SET 7,(IX+PROT) DD CB 01 FE
SET bit 7 of IX+01H (PROT): the file is read a byte at a time.
Original Source Code Comment: ASSUME LRL OF 256
56E7RBYTE
BIT 5,(IX+1)BIT 5,(IX+PROT) DD CB 01 6E
RBYTE: Test bit 5 of IX+01H (PROT), set when the next record must be read into the buffer.
Original Source Code Comment: DO WE NEED TO READ NEXT RECORD?
56EB
If the Z FLAG is set the buffer holds the record, so JUMP to 56F1H (RDTOB0).
Original Source Code Comment: NOPE, IT'S OKAY
56ED
GOSUB to 56CBH (RDREC) to read the next record into the buffer.
Original Source Code Comment: YES, READ NEXT RECORD TO BUFFER
56F0
RET NZ C0
If the NZ FLAG is set the read failed (or the file ended), so RETurn with the error.
Original Source Code Comment: EXIT IF ERROR
56F1RDTOB0
RDTOB0: GOSUB to 4A2EH (GETPRN) to check that the byte is before the end of the file: NZ with an error code when it is not (RWLOOP takes error 28 or 29 as the end of the file).
Original Source Code Comment: SEE IF RECORD IN IN RANGE
56F4
RET NZ C0
If the NZ FLAG is set the end of the file is reached, so RETurn with the error.
Original Source Code Comment: EXIT IF SO
56F5
GOSUB to 4872H (CALCBA in SYS0): Register Pair DE = the buffer address (IX+03H-04H) plus the byte offset (IX+05H).
Original Source Code Comment: CALCULATE BUFFER ADDRESS
56F8
XOR A AF
Set Register A to 00H and the Z FLAG, the good return.
Original Source Code Comment: SET Z FOR GOOD RETURN
56F9
LD A,(DE) 1A
Fetch the byte of the file at DE into Register A.
Original Source Code Comment: GET A CHARACTER
56FA
PUSH AF F5
Save the byte and the Z FLAG (Register Pair AF) to the top of the STACK.
Original Source Code Comment: SAVE CHAR AND FLAGS
56FB
INC (IX+5)INC (IX+OFFSET) DD 34 05
INCrement the byte offset at IX+05H.
Original Source Code Comment: INCREMENT BYTE POINTER
56FE
If the NZ FLAG is set the offset did not wrap, so JUMP to 5707H (RDTOB1).
Original Source Code Comment: EXIT IF NO WRAP AROUND
5700
SET 5,(IX+1)SET 5,(IX+PROT) DD CB 01 EE
The last byte of the buffer was taken: SET bit 5 of IX+01H (PROT) so the next call reads the next record.
Original Source Code Comment: SHOW NEXT REC NEEDS TO BE READ
5704
GOSUB to 4776H (INCREC in SYS0) to add 1 to the next record number (IX+0AH-0BH).
Original Source Code Comment: BUMP TO NEXT RECORD NUMBER
5707RDTOB1
POP AF F1
RDTOB1: Restore the byte and the Z FLAG into Register Pair AF.
Original Source Code Comment: GET THE CHAR AND FLAGS
5708
RET C9
RETurn with the byte in Register A and the Z FLAG set.

5709H - GETPA - Track and Sector of the Next Record from the Extents

5709GETPA
PUSH BC C5
GETPA: Save Register Pair BC to the top of the STACK.
570A
PUSH DE D5
Save Register Pair DE to the top of the STACK.
570B
PUSH HL E5
Save Register Pair HL to the top of the STACK.
Original Source Code Comment: SAVE CALLERS REGISTERS
570C
LD B,(IX+11)LD B,(IX+NRNH) DD 46 0B
Fetch the high byte of the next record number from IX+0BH (NRNH) into Register B ...
Original Source Code Comment: GET THE NEXT RECORD NUMBER
570F
LD C,(IX+10)LD C,(IX+NRNL) DD 4E 0A
... and the low byte from IX+0AH (NRNL) into Register C: Register Pair BC = the record (sector) wanted, from 0.
5712
PUSH IX DD E5
Copy the DCB address (Register IX) ...
Original Source Code Comment: MOVE DCB POINTER TO HL
5714
POP HL E1
... into Register Pair HL.
5715
LD DE,000EHLD DE,EXTBEG-2 11 0E 00
LET Register Pair DE = 000EH (the source's EXTBEG-2), the offset of the extents in this DCB.
Original Source Code Comment: HL => BEGIN OF EXTENTS
5718
ADD HL,DE 19
ADD it to Register Pair HL: HL points to the first extent (2 bytes: the track, then the granule byte).
5719CPA1
LD A,(HL) 7E
CPA1: Fetch the track of the extent into Register A.
Original Source Code Comment: GET THE TRACK NUMBER
571A
CP 0FFH FE FF
Compare Register A with FFH, the end of the extents.
Original Source Code Comment: END OF EXTENTS?
571C
If the Z FLAG is set there are no more extents, so JUMP to 5738H (CPAOOR): the record is out of range.
Original Source Code Comment: YES, OUT OF RANGE
571E
INC HL 23
INCrement Register Pair HL to the granule byte of the extent.
Original Source Code Comment: BUMP TO GRAN POINTER
571F
LD A,(HL) 7E
Fetch it into Register A: bits 7-5 the first granule on the track, bits 4-0 the number of granules less 1.
Original Source Code Comment: GET EXTENT POINTER
5720
AND 1FHAND 1FH E6 1F
MASK it with 1FH to keep the number of granules less 1.
Original Source Code Comment: MASK OFF STARTING GRAN
5722
INC A 3C
INCrement Register A: the number of granules in the extent.
Original Source Code Comment: CORRECT FOR 1'S OFFSET
5723
PUSH HL E5
Save the extent pointer (Register Pair HL) to the top of the STACK.
Original Source Code Comment: SAVE FOR NOW
5724
PUSH BC C5
Save the record wanted (Register Pair BC) to the top of the STACK.
5725
GOSUB to 5764H (MB5) to multiply Register A by 5, the sectors of a granule on the source diskette.
Original Source Code Comment: MULT A * 5
5728
LD E,A 5F
LET Register E = Register A, the number of sectors in the extent ...
Original Source Code Comment: E=#SECTORS IN EXTENT
5729
XOR A AF
... set Register A to 00H (this also clears the CARRY FLAG for the SBC) ...
572A
LD D,A 57
... and LET Register D = 00H: Register Pair DE = the sectors in the extent.
Original Source Code Comment: DE = # SECTORS IN EXTENT
572B
POP HL E1
Fetch the record wanted (pushed from BC) into Register Pair HL.
Original Source Code Comment: HL = DESIRED SECTOR OFFSET
572C
PUSH HL E5
Save it to the top of the STACK again.
572D
SBC HL,DE ED 52
SUBtract the sectors in the extent (DE) from it: the CARRY FLAG is set when the record is in this extent.
Original Source Code Comment: SUBTRACT DESIRED - # IN THIS EXTENT
572F
If the CARRY FLAG is set this is the extent, so JUMP to 573FH (CPA3).
Original Source Code Comment: THIS IS THE EXTENT
5731
POP BC C1
Throw away the saved record number (into Register Pair BC) ...
Original Source Code Comment: THROW AWAY PREV DESIRED SECTOR OFFSET
5732
PUSH HL E5
... and move the remainder (HL, the record counted from the next extent) ...
Original Source Code Comment: PUT IN NEW ONE
5733
POP BC C1
... into Register Pair BC.
Original Source Code Comment: GET IT BACK INTO BC
5734
POP HL E1
Restore the extent pointer (the granule byte) into Register Pair HL.
Original Source Code Comment: HL =>THIS EXTENTS 2ND BYTE
5735
INC HL 23
INCrement it to the track of the next extent.
Original Source Code Comment: HL =>NEXT EXTENTS 1ST BYTE
5736
LOOP BACK to 5719H (CPA1).
Original Source Code Comment: TRY NEXT EXTENT
5738CPAOOR
POP HL E1
CPAOOR: Restore Register Pair HL ...
Original Source Code Comment: RESTORE CALLERS REGISTERS
5739
POP DE D1
... Register Pair DE ...
573A
POP BC C1
... and Register Pair BC of the caller.
573B
LD A,1DHLD A,ENRF 3E 1D
LET Register A = 1DH, error 29 (ENRF), record out of range.
Original Source Code Comment: RECORD OUT OF RANGE
573D
OR A B7
Set the NZ FLAG from Register A.
Original Source Code Comment: SET 'NZ'
573E
RET C9
RETurn with the NZ FLAG set.
573FCPA3
POP DE D1
CPA3: Fetch the record counted from the start of this extent into Register Pair DE.
Original Source Code Comment: DE = TOTAL SECTOR OFFSET
5740
POP HL E1
Restore the extent pointer (the granule byte) into Register Pair HL.
Original Source Code Comment: HL => 2ND BYTE OF THIS EXTENT
5741
LD A,(HL) 7E
Fetch the granule byte into Register A.
Original Source Code Comment: GET STARING GRAN NUMBER
5742
AND 0E0HAND 0E0H E6 E0
MASK it with E0H to keep bits 7-5, the first granule on the track.
Original Source Code Comment: MASK OFF NUMBER OF GRANS
5744
RLCA 07
RLCA: rotate Register A left (bits 7-5 move toward bits 2-0) ...
5745
RLCA 07
... RLCA again ...
5746
RLCA 07
... and a third RLCA: Register A = the first granule (0 or 1 on a track of 2 granules).
Original Source Code Comment: GET IT TO BITS 0-2
5747
PUSH HL E5
Save the extent pointer (Register Pair HL) to the top of the STACK.
Original Source Code Comment: SAVE DCB EXTENT POINTER
5748
GOSUB to 5764H (MB5) to multiply the granule by 5: the first sector of the extent on its track.
Original Source Code Comment: MULT START GRAN# * 5 = STARTING SECTOR NUM
574B
LD L,A 6F
LET Register L = Register A ...
574C
LD H,00H 26 00
... and Register H = 00H: Register Pair HL = the first sector of the extent.
Original Source Code Comment: HL = STARTING SECTOR NUMBER
574E
ADD HL,DE 19
ADD the record counted in the extent (DE): HL = the sector counted from the first sector of the extent's track.
Original Source Code Comment: ADD TO GET TOTL SECR OFFSET
574F
LD A,0AH 3E 0A
LET Register A = 0AH (10), the sectors of a track on the source diskette.
Original Source Code Comment: NUMBER OF SECTORS IN A TRACK
5751
GOSUB to 4451H (DIV in SYS0) to divide Register Pair HL by Register A: HL returns the quotient (tracks on from the extent's track), Register A the remainder (the sector, 0-9).
5754
LD C,A 4F
Save the sector into Register C.
Original Source Code Comment: SAVE IT
5755
POP DE D1
Restore the extent pointer (the granule byte) into Register Pair DE.
5756
DEC DE 1B
DECrement Register Pair DE to the track byte of the extent.
Original Source Code Comment: DE => 1ST BYTE OF TRACK FOR THIS EXTENT
5757
LD A,(DE) 1A
Fetch the track of the extent into Register A.
Original Source Code Comment: GET THE TRACK NUMBER
5758
ADD A,L 85
ADD the quotient (Register L).
Original Source Code Comment: ADD IN THE OFFSET
5759
LD D,A 57
LET Register D = the track of the record.
Original Source Code Comment: PUT IT INTO D
575A
LD E,C 59
LET Register E = Register C, the sector of the record.
Original Source Code Comment: GET THE SECTOR NUMBER
575B
POP HL E1
Restore Register Pair HL of the caller.
575C
POP AF F1
Take the caller's DE off the STACK into Register Pair AF (the source: THIS IS THE DE VALUE): DE keeps the track and sector.
Original Source Code Comment: THIS IS THE DE VALUE
575D
POP BC C1
Restore Register Pair BC of the caller.
575E
LD A,(IX+6)LD A,(IX+DRVNUM) DD 7E 06
Fetch the drive number from IX+06H (DRVNUM) into Register A ...
Original Source Code Comment: GET THE DRIVE NUMBER
5761
LD C,A 4F
... and copy it into Register C.
Original Source Code Comment: INTO C
5762
XOR A AF
Set Register A to 00H and the Z FLAG, the good return.
Original Source Code Comment: GOOD RETURN
5763
RET C9
RETurn with Register D = track, Register E = sector, Register C = drive.

5764H - MB5 - Multiply A by 5

5764MB5
PUSH BC C5
MB5: Save Register Pair BC to the top of the STACK.
Original Source Code Comment: SAVE BC
5765
LD B,A 47
Copy the number in Register A into Register B.
Original Source Code Comment: SAVE A COPY OF NUMBER IN B
5766
RLCA 07
RLCA: Register A times 2 (the numbers here are small, so nothing rotates out of bit 7) ...
Original Source Code Comment: TIMES 2
5767
RLCA 07
... RLCA: times 4 ...
Original Source Code Comment: TIMES 4
5768
ADD A,B 80
... ADD Register B: times 5.
Original Source Code Comment: TIMES 5
5769
POP BC C1
Restore Register Pair BC.
Original Source Code Comment: GET BC BACK
576A
RET C9
RETurn with Register A times 5.

576BH - DIRED - Read the Directory Record of a File

576BDIRED
PUSH BC C5
DIRED: Save Register Pair BC (Register B = the record number, Register C = the drive) to the top of the STACK.
576C
PUSH DE D5
Save Register Pair DE to the top of the STACK.
576D
GOSUB to 5792H (LFDIR): Register D = 17 (the directory track), Register E = the directory sector of record B, Register Pair HL = the record's place in 5F00H (BUFER2).
5770
If the NZ FLAG is set JUMP to 577BH (DIRER0); LFDIR always returns Z.
5772
PUSH HL E5
Save the record's place (Register Pair HL) to the top of the STACK.
5773
LD L,00H 2E 00
LET Register L = 00H: HL = 5F00H, the start of the buffer.
5775
GOSUB to 5653H (MREAD) to read that directory sector of drive C into 5F00H.
5778
POP HL E1
Restore the record's place into Register Pair HL.
5779
If the Z FLAG is set the sector was read, so JUMP to 577DH (DIROUT).
577BDIRER0
LD A,11H 3E 11
DIRER0: LET Register A = 11H, error 17 (EDRE), directory read error.
577DDIROUT
POP DE D1
DIROUT: Restore Register Pair DE from the STACK.
577E
POP BC C1
Restore Register Pair BC from the STACK.
577F
RET C9
RETurn: Z with Register Pair HL at the directory record, or NZ with error 17.

5780H - REDGAT - Read the GAT of the Source Diskette

5780REDGAT
PUSH DE D5
REDGAT: Save Register Pair DE to the top of the STACK.
5781
PUSH BC C5
Save Register Pair BC (Register C = the drive) to the top of the STACK.
5782
LD D,11H 16 11
LET Register D = 11H (17), the directory track.
5784
LD E,00H 1E 00
LET Register E = 00H, the sector of the GAT on the source diskette.
5786
LD HL,5F00HLD HL,BUFER2 21 00 5F
LET Register Pair HL = 5F00H (BUFER2), the buffer.
5789
GOSUB to 5653H (MREAD) to read the GAT of drive C into 5F00H.
578C
POP BC C1
Restore Register Pair BC from the STACK.
578D
POP DE D1
Restore Register Pair DE from the STACK.
578E
RET Z C8
If the Z FLAG is set the GAT was read, so RETurn with Z.
578FGATER0
LD A,14HLD A,EADRE 3E 14
GATER0: LET Register A = 14H, error 20 (EADRE), GAT read error.
5791
RET C9
RETurn with the NZ FLAG set (from MREAD).

5792H - LFDIR - Track, Sector and Buffer Place of a Directory Record

5792LFDIR
LD D,11H 16 11
LFDIR: LET Register D = 11H (17), the directory track.
Original Source Code Comment: SET FOR DIRECTORY TRACK
5794
LD A,B 78
LET Register A = Register B, the record number (bits 0-2 the directory sector, bits 3-5 the record in it).
Original Source Code Comment: GET THE LFN
5795
AND 07H E6 07
MASK it with 07H to keep the sector bits.
Original Source Code Comment: MASK FOR SECTOR NUMBER
5797
ADD A,02H C6 02
ADD 02H: the directory records of the source diskette start in sector 2.
Original Source Code Comment: DIR STARTS ON SECTOR 2
5799
LD E,A 5F
LET Register E = the directory sector.
Original Source Code Comment: INTO E
579A
LD H,5FHLD H,BUFER2.HIGH. 26 5F
LET Register H = 5FH, the high byte of BUFER2 (5F00H).
Original Source Code Comment: MSB OF BUFFER
579C
LD A,(5B02H)LD A,(FILPNT) 3A 02 5B
Fetch the low byte of FILPNT (5B02H), the HIT offset of the file, into Register A: bits 5-7 are the record in the sector.
Original Source Code Comment: GET THE LSB OF THE FILE POINTER
579F
AND 0F0HAND 0F0H E6 F0
MASK it with F0H (bits 0-3 are the column, 0-7, so only bits 5-7 stay set): the record times 32.
Original Source Code Comment: MASK OFF SECTOR OFFSET
57A1
LD L,A 6F
LET Register L = Register A: HL = the record's place in BUFER2.
Original Source Code Comment: INTO HL
57A2
XOR A AF
Set Register A to 00H and the Z FLAG.
Original Source Code Comment: SET GOOD RETURN
57A3
RET C9
RETurn with Register D = track, Register E = sector, Register Pair HL = the record's place.

57A4H - TRKGT - The Directory Track of a Drive

57A4TRKGT
PUSH BC C5
TRKGT: Save Register Pair BC (Register C = the drive) to the top of the STACK.
Original Source Code Comment: SAVE B
57A5
LD B,00H 06 00
LET Register B = 00H, so Register Pair BC = the drive number.
57A7
LET Register Pair HL = 55AEH (DIRTK), the table of directory tracks, one byte per drive.
Original Source Code Comment: HL => DIRECTORY TRACK TABLE
57AA
ADD HL,BC 09
ADD the drive number: HL points to the directory track of the drive.
Original Source Code Comment: HL => THIS DRIVE'S DIR TRK
57AB
POP BC C1
Restore Register Pair BC.
Original Source Code Comment: GET B BACK
57AC
LD D,(HL) 56
Fetch the directory track (17 for every drive) into Register D.
Original Source Code Comment: GET THE DIRECTORY TRACK
57AD
RET C9
RETurn with Register D = the directory track.

57AEH - ROPEN - Open a File of the Source Diskette

57AEROPEN
ROPEN: GOSUB to 4885H (SAVERN in SYS0), which saves the registers and points Register IX to the DCB at DE without checking that it is open.
57B1OPENR
LD A,B 78
OPENR: LET Register A = Register B, the record length (0 here).
57B2
Store it into 5846H (RLRL), the operand of the LD A,00H at 5845H in SETDCB.
Original Source Code Comment: SAVE THE LRL
57B5
Store the buffer address (Register Pair HL) into 5857H-5858H (BLKBUF), the operand of the LD DE,0000H at 5856H in SETDCB.
Original Source Code Comment: SAVE THE BUFF ADDRESS
57B8
PUSH IX DD E5
Copy the DCB address (Register IX) ...
57BA
POP HL E1
... into Register Pair HL: the DCB holds the file spec.
Original Source Code Comment: HL=> FILE NAME
57BB
GOSUB to 58E6H (CRACK) to split the file spec into NAME (59F7H), EXT (59FFH), PWORD (59EFH) and DRV (59EEH).
Original Source Code Comment: CRACK OPEN FILE SPEC
57BE
RET NZ C0
If the NZ FLAG is set the file spec is not valid, so RETurn with the error.
Original Source Code Comment: ILLEGAL SPEC
57BF
LD HL,59F7HLD HL,NAME 21 F7 59
LET Register Pair HL = 59F7H (NAME), the 8 byte name and 3 byte extension.
57C2
GOSUB to 595EH (HASH) to make the hash code of NAME and EXT in Register A, the byte the HIT holds for the file.
Original Source Code Comment: GENERATE A HASH CODE
57C5
Store it into 57EAH (HCODE), the operand of the CP 00H at 57E9H.
Original Source Code Comment: AND SAVE IT
57C8
LD DE,59EFHLD DE,PWORD 11 EF 59
LET Register Pair DE = 59EFH (PWORD), the 8 byte password.
Original Source Code Comment: DE=> PASSWORD STRING
57CB
GOSUB to 597EH (SETTDC) to make its hash code in Register Pair HL.
Original Source Code Comment: CALCULATE TRAP DOOR CODE
57CE
LD (5A02H),HLLD (UPDTDC),HL 22 02 5A
Store it into 5A02H (UPDTDC) ...
Original Source Code Comment: SET THE UPDATE TDC
57D1
LD (5A04H),HLLD (ACCTDC),HL 22 04 5A
... and into 5A04H (ACCTDC); nothing in CONVERT reads them again.
Original Source Code Comment: SET THE ACCESS TDC
57D4
Fetch the drive of the file spec from 59EEH (DRV) into Register A: FFH when the spec gave none.
57D7
LD C,A 4F
LET Register C = Register A, the drive to search.
Original Source Code Comment: C = REQUESTED DRIVE NUM
57D8
INC A 3C
INCrement Register A: the Z FLAG is set for FFH.
57D9
If the NZ FLAG is set a drive was given, so JUMP to 57DCH (OPENL).
Original Source Code Comment: JUMP IF A DRIVE SUPPLIED
57DB
LD C,A 4F
LET Register C = 00H (Register A after the INC): search from drive 0.
Original Source Code Comment: GLOBAL, START WITH 0
57DCOPENL
OPENL: GOSUB to 59AAH (CKHDRV) to see whether drive C is there (it waits for an index pulse).
Original Source Code Comment: SEE IF THE DRIVE EXISTS
57DF
If the NZ FLAG is set the drive is not there, so JUMP to 57F0H (OPNODR).
57E1
GOSUB to 59D9H (RDHITT) to read the HIT of drive C into 5E00H; Register Pair HL comes back as 5E00H.
Original Source Code Comment: READ IN THE HASH TABLE
57E4
RET NZ C0
If the NZ FLAG is set the HIT could not be read, so RETurn with the error.
Original Source Code Comment: RETURN IF ERROR
57E5OPEN2
LD A,(HL) 7E
OPEN2: Fetch the next HIT entry into Register A.
Original Source Code Comment: PICK UP NEXT HIT CODE
57E6
OR A B7
Set the FLAGS from Register A.
57E7
If the Z FLAG is set the entry is free, so JUMP to 57EDH (OPEN3).
Original Source Code Comment: JUMP IF NO HIT CODE
57E9
CP 00H FE 00
Compare Register A with the hash code of the file wanted: the operand (57EAH, HCODE) is 00H in the file and was set at 57C5H.
57EB
If the Z FLAG is set the hash codes match, so JUMP to 5810H (OPEN4) to read the record and compare the name.
Original Source Code Comment: VALID HASH,CHECK NAME
57EDOPEN3
INC L 2C
OPEN3: INCrement Register L to the next HIT entry.
57EE
If the NZ FLAG is set the HIT is not finished (256 entries), so LOOP BACK to 57E5H (OPEN2).

57F0H - OPNODR / OPNONE / OPERR0 - Not Found on this Drive; the Errors

57F0OPNODR
OPNODR: Fetch DRV (59EEH) into Register A.
57F3
INC A 3C
INCrement it: Z for FFH (any drive).
57F4
If the NZ FLAG is set the file spec named a drive, so JUMP to 57FCH (OPNONE): the file is not found.
57F6
INC C 0C
INCrement Register C to the next drive.
57F7
LD A,04H 3E 04
LET Register A = 04H.
57F9
CP C B9
Compare it with Register C: the NC FLAG is set for drives 0 to 4.
57FA
If the NC FLAG is set LOOP BACK to 57DCH (OPENL) to search the next drive.
Original Source Code Comment: CHECK NEXT DIRVE
57FCOPNONE
LD A,18HLD A,EFNF 3E 18
OPNONE: LET Register A = 18H, error 24 (EFNF), file not found.
Original Source Code Comment: FILE NOT IN DIR
57FEOPERR0
PUSH AF F5
OPERR0: Save the error code (Register Pair AF) to the top of the STACK.
57FF
LD C,00H 0E 00
LET Register C = 00H, drive 0.
Original Source Code Comment: SET FOR DRIVE 0
5801
GOSUB to 55B2H (CSEL) to select drive 0 again.
Original Source Code Comment: PUT US BACK ON 0
5804
POP AF F1
Restore the error code into Register Pair AF.
5805
RET C9
RETurn with the NZ FLAG set and the error code in Register A.

OPERR1 is not reached by any instruction of CONVERT.

5806OPERR1
LD A,02HLD A,EDNS 3E 02
OPERR1 (no instruction of CONVERT jumps here): LET Register A = 02H, error 2 (EDNS), disk drive not in system.
Original Source Code Comment: DRIVE NOT IN SYSTEM
5808
JUMP to 57FEH (OPERR0).

580AH - OPEN6 - Not this Record: the Next HIT Entry

580AOPEN6
POP BC C1
OPEN6: Take the saved count off the STACK into Register Pair BC (pushed at 581CH).
Original Source Code Comment: B = LEN
580B
POP HL E1
Take the directory record pointer off the STACK into Register Pair HL (pushed at 581BH).
Original Source Code Comment: HL=> DIR
580C
POP BC C1
Restore Register Pair BC (Register C = the drive) pushed at 5811H.
Original Source Code Comment: C = DRIVE, B = HASH
580D
POP HL E1
Restore the HIT pointer into Register Pair HL (pushed at 5810H).
Original Source Code Comment: HL => DIT
580E
JUMP BACK to 57EDH (OPEN3) for the next HIT entry.

5810H - OPEN4 / OPEN4A - The Hash Code Matches: Compare the Name

5810OPEN4
PUSH HL E5
OPEN4: Save the HIT pointer (Register Pair HL) to the top of the STACK.
Original Source Code Comment: HL => HIT
5811
PUSH BC C5
Save Register Pair BC (Register C = the drive) to the top of the STACK.
Original Source Code Comment: C = DRIVE
5812
LD B,L 45
LET Register B = Register L, the HIT offset of the entry: bits 0-2 give DIRED the directory sector (LFDIR takes the record in the sector from FILPNT).
Original Source Code Comment: B = LFN
5813
GOSUB to 576BH (DIRED) to read the directory sector into 5F00H; Register Pair HL comes back at the record.
Original Source Code Comment: READ IN DIR RECORD
5816
If the Z FLAG is set the sector was read, so JUMP to 581BH (OPEN4A).
5818
POP BC C1
Restore Register Pair BC ...
5819
POP HL E1
... and Register Pair HL ...
581A
RET C9
... and RETurn with the error of DIRED.
581BOPEN4A
PUSH HL E5
OPEN4A: Save the directory record pointer (Register Pair HL) to the top of the STACK.
Original Source Code Comment: HL => DIR
581C
PUSH BC C5
Save Register Pair BC (Register B = the HIT offset) to the top of the STACK.
Original Source Code Comment: SAVE THE LFN
581D
BIT 7,(HL) CB 7E
Test bit 7 of the attribute byte of the record: set in an extended record.
581F
If the NZ FLAG is set the record is an extended record, so JUMP to 580AH (OPEN6).
Original Source Code Comment: JUMP IF LINKED ENTRY
5821
LD A,05H 3E 05
LET Register A = 05H, the offset of the name in the record.
5823
ADD A,L 85
ADD Register L.
5824
LD L,A 6F
LET Register L = Register A: HL points to the name of the record.
Original Source Code Comment: HL => DIR+5
5825
LD DE,59F7HLD DE,NAME 11 F7 59
LET Register Pair DE = 59F7H (NAME), the name and extension wanted.
Original Source Code Comment: DE => NAME AND EXT
5828
LD B,0BH 06 0B
LET Register B = 0BH (11), the bytes of the name and extension.
582AOPEN5
LD A,(DE) 1A
OPEN5: Fetch a byte of the name wanted into Register A.
582B
CP (HL) BE
Compare it with the byte of the record.
Original Source Code Comment: VERIFY FILE NAME & EXT
582C
If the NZ FLAG is set they differ, so JUMP to 580AH (OPEN6).
Original Source Code Comment: JP IF NOT SAME
582E
INC HL 23
INCrement Register Pair HL ...
582F
INC DE 13
... and Register Pair DE.
5830
DECrement Register B and LOOP BACK to 582AH (OPEN5) for all 11 bytes.
Original Source Code Comment: VERIFY ENTIRE NAM/EXT
5832
POP BC C1
The file is found: restore Register Pair BC (Register B = the HIT offset, Register C = the drive).
5833
LD A,C 79
LET Register A = Register C, the drive ...
5834
... and store it into 59EEH (DRV).
Original Source Code Comment: SAVE DRIVE NUMBER
5837
POP HL E1
Restore the directory record pointer into Register Pair HL.
Original Source Code Comment: HL => DIR
5838
POP AF F1
Take the saved drive off the STACK (into Register Pair AF, not used).
Original Source Code Comment: IGNORE THE SAVED DRV #
5839
POP AF F1
Take the saved HIT pointer off the STACK (into Register Pair AF, not used).
Original Source Code Comment: IGNORE HIT POINTER
583A
XOR A AF
Set Register A to 00H.
583B
Store 00H into 5849H (PRIV), the operand of the LD A,00H at 5848H: no access level bits.
Original Source Code Comment: SAVE PRIVILEDGE LEVEL

583EH - SETDCB - Fill the DCB from the Directory Record

583ESETDCB
EX DE,HL EB
SETDCB: EXchange Register Pairs DE and HL: DE points to the directory record.
Original Source Code Comment: DE = DIR
583F
PUSH IX DD E5
Copy the DCB address (Register IX) ...
5841
POP HL E1
... into Register Pair HL.
Original Source Code Comment: HL = DCB
5842
LD (HL),80H 36 80
Store 80H into the first byte of the DCB (TYPE): the file is open.
Original Source Code Comment: 'FILE'
5844
INC HL 23
INCrement Register Pair HL to DCB+01H.
5845
LD A,00H 3E 00
LET Register A = the record length ROPEN was given: the operand (5846H, RLRL) is 00H in the file and was set at 57B2H.
5847
OR A B7
Set the FLAGS from it.
5848
LD A,00H 3E 00
LET Register A = the access level: the operand (5849H, PRIV) is 00H in the file and was set at 583BH (the LD does not change the FLAGS).
584A
If the Z FLAG is set (record length 0) JUMP to 584EH (SETDC2).
Original Source Code Comment: JP IF NOT BLOCKED ACCESS
584C
OR 80H F6 80
OR Register A with 80H, bit 7: blocked records.
Original Source Code Comment: SET BLOCKED
584ESETDC2
OR 20H F6 20
SETDC2: OR Register A with 20H, bit 5: the first record must be read into the buffer.
Original Source Code Comment: SET POSN
5850
LD (HL),A 77
Store it into DCB+01H (PROT).
Original Source Code Comment: SAVE THE ACCESS MODE
5851
INC HL 23
INCrement Register Pair HL to DCB+02H.
5852
LD (HL),00H 36 00
Store 00H into DCB+02H (reserved).
Original Source Code Comment: RESERVED
5854
INC HL 23
INCrement Register Pair HL to DCB+03H.
5855
PUSH DE D5
Save the directory record pointer (Register Pair DE) to the top of the STACK.
5856
LD DE,0000H 11 00 00
LET Register Pair DE = the buffer address ROPEN was given: the operand (5857H-5858H, BLKBUF) is 0000H in the file and was set at 57B5H.
5859
LD (HL),E 73
Store its low byte into DCB+03H (BUFL) ...
Original Source Code Comment: BLOCK BUFF (LSB)
585A
INC HL 23
... INCrement Register Pair HL ...
585B
LD (HL),D 72
... and its high byte into DCB+04H (BUFH).
Original Source Code Comment: BLOCK BUFF (MSB)
585C
INC HL 23
INCrement Register Pair HL to DCB+05H.
585D
POP DE D1
Restore the directory record pointer into Register Pair DE.
585E
LD (HL),00H 36 00
Store 00H into DCB+05H (OFFSET), the byte offset in the buffer.
Original Source Code Comment: BYTE ADDRESS
5860
INC HL 23
INCrement Register Pair HL to DCB+06H.
5861
LD (HL),C 71
Store the drive (Register C) into DCB+06H (DRVNUM).
Original Source Code Comment: DRIVE
5862
LD A,C 79
LET Register A = Register C, the drive ...
Original Source Code Comment: GET THE DRIVE NUMBER
5863
... and store it into 58C0H (SAVDRV), the operand of the LD C,00H at 58BFH in DOLINK.
Original Source Code Comment: SAVE IT
5866
INC HL 23
INCrement Register Pair HL to DCB+07H.
5867
LD (HL),B 70
Store Register B (the HIT offset of the file) into DCB+07H (LFN).
Original Source Code Comment: LFN
5868
INC HL 23
INCrement Register Pair HL to DCB+08H.
5869
LD A,03H 3E 03
LET Register A = 03H, the offset of the EOF byte in the directory record.
586B
ADD A,E 83
ADD Register E.
586C
LD E,A 5F
LET Register E = Register A: DE points to the EOF byte of the record.
Original Source Code Comment: DE = DIR +3
586D
LD A,(DE) 1A
Fetch the EOF byte (the byte offset of the end in the last sector) into Register A.
586E
LD (HL),A 77
Store it into DCB+08H (EOF).
Original Source Code Comment: EOF BYTE
586F
Store it into 588FH (INCFLG), the operand of the LD A,00H at 588EH.
5872
INC HL 23
INCrement Register Pair HL to DCB+09H.
5873
INC DE 13
INCrement Register Pair DE to offset 04H of the record.
5874
LD A,(DE) 1A
Fetch the logical record length of the file from the record into Register A.
Original Source Code Comment: GET THE DIRECTORY LRL
5875
LD (HL),A 77
Store it into DCB+09H (LRL).
Original Source Code Comment: LRL
5876
INC HL 23
INCrement Register Pair HL to DCB+0AH.
5877
LD (HL),00H 36 00
Store 00H into DCB+0AH (NRN, low byte).
Original Source Code Comment: NRN (LSB)
5879
INC HL 23
INCrement Register Pair HL to DCB+0BH.
587A
LD (HL),00H 36 00
Store 00H into DCB+0BH (NRN, high byte): the next record is the first.
Original Source Code Comment: NRN (MSB)
587C
INC HL 23
INCrement Register Pair HL to DCB+0CH.
587D
LD A,10H 3E 10
LET Register A = 10H (16).
587F
ADD A,E 83
ADD Register E.
5880
LD E,A 5F
LET Register E = Register A: DE points to offset 14H of the record, the ending record number.
Original Source Code Comment: DE = DIR + 20
5881
EX DE,HL EB
EXchange Register Pairs DE and HL: HL points to the record, DE to DCB+0CH.
Original Source Code Comment: HL = DIR POINTER
5882
LD C,(HL) 4E
Fetch the low byte of the ending record number into Register C (the source's LD BC,(HL)) ...
Original Source Code Comment: GET THE ERN
5883
INC HL 23
... INCrement Register Pair HL ...
5884
LD B,(HL) 46
... and the high byte into Register B: Register Pair BC = the ending record number.

The ending record number is corrected unless the diskette has the version byte 24H.

5885
LD A,0FFH 3E FF
LET Register A = the version flag: the operand (5886H, VERSON) is FFH in the file and was set at 5296H to the GAT's version byte less 24H (00H for the version the source names).
Original Source Code Comment: WILL BE 'Z' IF VERSION 2.4
5887
OR A B7
Set the FLAGS from Register A.
Original Source Code Comment: IS IT 2.4?
5888
If the Z FLAG is set (VERSON 00H) the ending record number is used as it is, so JUMP to 5894H (NOINC).
Original Source Code Comment: YES. DON'T BUMP THE ERN
588A
LD A,B 78
LET Register A = Register B ...
Original Source Code Comment: NULL FILE?
588B
OR C B1
... OR Register C: the Z FLAG is set for an ending record number of 0 (an empty file).
588C
If the Z FLAG is set JUMP to 5894H (NOINC).
Original Source Code Comment: YES. EXIT
588E
LD A,00H 3E 00
LET Register A = the EOF byte: the operand (588FH, INCFLG) is 00H in the file and was set at 586FH.
Original Source Code Comment: GET THE EOF BYTE
5890
OR A B7
Set the FLAGS from Register A.
Original Source Code Comment: EOF OF ZERO?
5891
If the Z FLAG is set (the last sector is full) JUMP to 5894H (NOINC).
Original Source Code Comment: YES. DON'T DEC THE ERN
5893
DEC BC 0B
DECrement Register Pair BC, the ending record number: the correction the source makes when the version byte is not 24H, the file is not empty and its last sector is not full.
Original Source Code Comment: BUMP THE ERN TO CORRECT FOR 2.3 AND EARLIER
5894NOINC
EX DE,HL EB
NOINC: EXchange Register Pairs DE and HL: HL points to DCB+0CH, DE to the record.
Original Source Code Comment: HL = DCB POINTER
5895
LD (HL),C 71
Store the low byte of the ending record number into DCB+0CH (the source's LD (HL),BC) ...
Original Source Code Comment: STORE THE ERN IN THE DCB
5896
INC HL 23
... INCrement Register Pair HL ...
5897
LD (HL),B 70
... and the high byte into DCB+0DH.
5898
INC HL 23
INCrement Register Pair HL to DCB+0EH, the extents.
5899
INC DE 13
INCrement Register Pair DE to offset 16H of the record, the extents (DSEG).
Original Source Code Comment: DE = DIR + 22
589A
EX DE,HL EB
EXchange Register Pairs DE and HL: HL = the record's extents, DE = the DCB's.
589BREEXT
LD BC,000AH 01 0A 00
REEXT: LET Register Pair BC = 000AH (10), the bytes of 5 extents (the record's 4 and the link after them).
Original Source Code Comment: NUMBER OF BYTES IN EXTENTS
589E
LDIR ED B0
LDIR: copy them from the record (HL) to the DCB (DE).
Original Source Code Comment: MOVE THEM TO THE DCB
58A0
DEC HL 2B
DECrement Register Pair HL ...
Original Source Code Comment: BACK UP TO LAST EXTENT
58A1
DEC HL 2B
... twice, back to the last 2 bytes copied (the link).
58A2
LD A,(HL) 7E
Fetch its first byte into Register A.
Original Source Code Comment: GET THE TRACK NUMBER
58A3
CP 0FEH FE FE
Compare Register A with FEH: FEH means the file goes on in an extended record.
Original Source Code Comment: EXTENDED DIRECTORY?
58A5
If the Z FLAG is set JUMP to 58AFH (DOLINK) to copy the extents of the extended record.
Original Source Code Comment: YES, MOVE IN THE LINKED EXTENTS
58A7
XOR A AF
Set Register A to 00H and the Z FLAG, the good return.
Original Source Code Comment: NO, SET 'GOOD' RETURN
58A8
Store 00H into 5849H (PRIV) ...
Original Source Code Comment: CLEAR PRIVLEDGE
58AB
... and into 5846H (RLRL) for the next open.
Original Source Code Comment: AND LRL
58AE
RET C9
RETurn with the Z FLAG set: the file is open.

58AFH - DOLINK - The Extents of the Extended Directory Record

58AFDOLINK
DEC DE 1B
DOLINK: DECrement Register Pair DE ...
Original Source Code Comment: BACK UP OVER LAST POINTER
58B0
DEC DE 1B
... twice, back over the link copied into the DCB, so the next extents go in its place.
58B1
Store the DCB pointer (Register Pair DE) into 58E1H-58E2H (SAVEDE), the operand of the LD DE,0000H at 58E0H.
Original Source Code Comment: SAVE THE POINTER
58B5
INC HL 23
INCrement Register Pair HL to the second byte of the link, which names the extended record.
Original Source Code Comment: BUMP TO EXTEND EXT POINTER
58B6
LD A,(HL) 7E
Fetch it into Register A.
Original Source Code Comment: GET IT
58B7
Store it into 58CCH (SAVEA), the operand of the LD A,00H at 58CBH.
Original Source Code Comment: SAVE THE OFFSET VALUES
58BA
AND 0FHAND 0FH E6 0F
MASK it with 0FH to keep the sector bits.
Original Source Code Comment: MASK FOR JUST SECTOR NUMBER
58BC
ADD A,02H C6 02
ADD 02H: the directory records start in sector 2.
Original Source Code Comment: CORRECT WITH SECTOR OFFSET
58BE
LD E,A 5F
LET Register E = Register A, the sector of the extended record.
Original Source Code Comment: INTO E FOR SECTOR
58BF
LD C,00H 0E 00
LET Register C = the drive: the operand (58C0H, SAVDRV) is 00H in the file and was set at 5863H.
Original Source Code Comment: DRIVE SAVED HERE
58C1
GOSUB to 57A4H (TRKGT) to fetch the directory track of the drive into Register D.
Original Source Code Comment: GET THE DIR TRACK NUMBER
58C4
LD HL,5F00HLD HL,BUFER2 21 00 5F
LET Register Pair HL = 5F00H (BUFER2), the buffer.
Original Source Code Comment: HL => BUFFER
58C7
GOSUB to 5653H (MREAD) to read the directory sector of the extended record into 5F00H.
Original Source Code Comment: READ IN THE EXTED DIR REC
58CA
RET NZ C0
If the NZ FLAG is set the read failed, so RETurn with the error.
Original Source Code Comment: EXIT IF ERROR
58CB
LD A,00H 3E 00
LET Register A = the second byte of the link: the operand (58CCH, SAVEA) is 00H in the file and was set at 58B7H.
Original Source Code Comment: OFFSET SAVED HERE
58CD
RLCA 07
RLCA: rotate bits 7-5 toward bits 2-0 ...
Original Source Code Comment: SHIFT IT TO LSB
58CE
RLCA 07
... RLCA again ...
58CF
RLCA 07
... and a third RLCA.
58D0
AND 07H E6 07
MASK with 07H: Register A = the record in the sector (0-7).
Original Source Code Comment: GET JUST THE OFFSET
58D2NXTLOP
OR A B7
NXTLOP: Set the FLAGS from Register A.
Original Source Code Comment: WE DONE?
58D3
If the Z FLAG is set HL is at the record, so JUMP to 58DCH (FNDLOP).
Original Source Code Comment: YES, FOUND IT
58D5
LD DE,0020H 11 20 00
LET Register Pair DE = 0020H (32), the size of a directory record.
Original Source Code Comment: SIZE OF A DIRECTORY RECORD
58D8
ADD HL,DE 19
ADD it to Register Pair HL.
58D9
DEC A 3D
DECrement the count in Register A.
Original Source Code Comment: DEC THE COUNTER
58DA
LOOP BACK to 58D2H (NXTLOP).
Original Source Code Comment: LOOP TILL FOUND
58DCFNDLOP
LD DE,0016HLD DE,DSEG 11 16 00
FNDLOP: LET Register Pair DE = 0016H (DSEG), the offset of the extents in a record.
Original Source Code Comment: OFFSET TO BEG OF EXT POINTERS
58DF
ADD HL,DE 19
ADD it to Register Pair HL: HL points to the extents of the extended record.
Original Source Code Comment: HL => EXTENTS
58E0
LD DE,0000H 11 00 00
LET Register Pair DE = the place in the DCB for them: the operand (58E1H-58E2H, SAVEDE) is 0000H in the file and was set at 58B1H.
Original Source Code Comment: DCB POINTER SAVED HERE
58E3
JUMP to 589BH (REEXT) to copy them.
Original Source Code Comment: DO MORE EXTENTS

58E6H - CRACK - Split a File Spec into Name, Extension, Password and Drive

58E6CRACK
LD B,0BH 06 0B
CRACK: LET Register B = 0BH (11), the bytes of NAME and EXT.
58E8
LD DE,59F7HLD DE,NAME 11 F7 59
LET Register Pair DE = 59F7H (NAME).
58EB
LD A,20H 3E 20
LET Register A = 20H (space).
58EDCRACK1
LD (DE),A 12
CRACK1: Store a space at DE.
Original Source Code Comment: INITIALIZE NAME & EXT
58EE
INC DE 13
INCrement Register Pair DE.
58EF
DECrement Register B and LOOP BACK to 58EDH (CRACK1): NAME and EXT are all spaces.
58F1
LD B,08H 06 08
LET Register B = 08H, the bytes of the password.
58F3
LD DE,59EFHLD DE,PWORD 11 EF 59
LET Register Pair DE = 59EFH (PWORD).
58F6CRACKP
LD (DE),A 12
CRACKP: Store a space at DE.
Original Source Code Comment: INITIALIZE PASSWORD
58F7
INC DE 13
INCrement Register Pair DE.
58F8
DECrement Register B and LOOP BACK to 58F6H (CRACKP): PWORD is all spaces.
58FA
LD A,0FFHLD A,0FFH 3E FF
LET Register A = FFH.
58FC
Store FFH into 59EEH (DRV): search every drive unless the spec names one.
Original Source Code Comment: ASSUME GLOBAL DRV SEARCH
58FF
LD DE,59F7HLD DE,NAME 11 F7 59
LET Register Pair DE = 59F7H (NAME).
5902
LD B,08H 06 08
LET Register B = 08H, the most characters of a name.
5904
GOSUB to 5944H (GETFLD) to copy the name from the spec at HL: Register A returns the character after it, Register B the places left.
Original Source Code Comment: GET THE NAME FIELD
5907
LD C,A 4F
Save the character that ended the name into Register C.
Original Source Code Comment: SAVE TERMINATING CHAR
5908
LD A,B 78
LET Register A = Register B, the places left.
5909
CP 08H FE 08
Compare Register A with 08H: 8 left means no name was copied.
590B
If the NZ FLAG is set there is a name, so JUMP to 5911H (CRACK2).
Original Source Code Comment: JP IF NAME FIELD SUPPLIED
590D
LD A,13HLD A,EBFN 3E 13
LET Register A = 13H, error 19 (EBFN), invalid file name.
Original Source Code Comment: ILLEGAL FILE NAME
590F
OR A B7
Set the NZ FLAG from Register A.
5910
RET C9
RETurn with the NZ FLAG set.
5911CRACK2
LD A,C 79
CRACK2: LET Register A = Register C, the character that ended the name.
Original Source Code Comment: A = NAME FIELD TERMINATOR
5912
CP 2FHCP '/' FE 2F
Compare Register A with 2FH ('/').
5914
If the NZ FLAG is set there is no extension, so JUMP to 591EH (CRACK3).
Original Source Code Comment: JP IF NOT EXTENSION
5916
LD DE,59FFHLD DE,EXT 11 FF 59
LET Register Pair DE = 59FFH (EXT).
5919
LD B,03H 06 03
LET Register B = 03H, the most characters of an extension.
591B
GOSUB to 5944H (GETFLD) to copy the extension; Register A returns the character after it.
Original Source Code Comment: GET FILE'S EXTENSION
591ECRACK3
CP 2EHCP '.' FE 2E
CRACK3: Compare Register A with 2EH ('.').
5920
If the NZ FLAG is set there is no password, so JUMP to 592AH (CRACK4).
Original Source Code Comment: JP IF NOT PASSWORD
5922
LD DE,59EFHLD DE,PWORD 11 EF 59
LET Register Pair DE = 59EFH (PWORD).
5925
LD B,08H 06 08
LET Register B = 08H, the most characters of a password.
5927
GOSUB to 5944H (GETFLD) to copy the password; Register A returns the character after it.
Original Source Code Comment: GET FILE'S PASSWORD
592ACRACK4
CP 3AHCP ':' FE 3A
CRACK4: Compare Register A with 3AH (':').
592C
If the NZ FLAG is set there is no drive, so JUMP to 5942H (CRACK7).
Original Source Code Comment: JP IF NOT DRIVE SPEC
592E
LD A,(HL) 7E
Fetch the drive digit (ASCII) at HL into Register A.
Original Source Code Comment: GET THE DRIVE IN ASCII
592F
SUB 30HSUB '0' D6 30
SUBtract 30H ('0') to make it binary.
Original Source Code Comment: CONVERT TO HEX
5931
If the CARRY FLAG is set the character was below '0', so JUMP to 593AH (CRACK5).
Original Source Code Comment: ILLEGAL
5933
LD C,A 4F
Copy the drive number into Register C.
5934
LD A,04H 3E 04
LET Register A = 04H, the highest drive number CRACK takes.
5936
CP C B9
Compare it with Register C: the CARRY FLAG is set for a drive above 4.
Original Source Code Comment: GREATER THAN MAX
5937
LD A,C 79
LET Register A = Register C, the drive (the LD keeps the FLAGS).
Original Source Code Comment: RESTORE A
5938
If the NC FLAG is set the drive is 0 to 4, so JUMP to 593FH (CRACK6).
593ACRACK5
LD A,02HLD A,EDNS 3E 02
CRACK5: LET Register A = 02H, error 2 (EDNS), disk drive not in system.
Original Source Code Comment: DRIVE NOT IN SYSTEM
593C
JUMP to 57FEH (OPERR0) to select drive 0 and return with the error.
Original Source Code Comment: REPORT IT!
593FCRACK6
CRACK6: Store the drive number into 59EEH (DRV).
5942CRACK7
XOR A AF
CRACK7: Set Register A to 00H and the Z FLAG: the spec is valid.
5943
RET C9
RETurn with the Z FLAG set.

5944H - GETFLD - Copy One Field of a File Spec

5944GETFLD
LD A,(HL) 7E
GETFLD: Fetch the first character of the field from HL into Register A.
Original Source Code Comment: GET 1ST CHAR IN STRING
5945
INC HL 23
INCrement Register Pair HL.
5946
JUMP to 5951H (GETFL3): the first character must be a letter.
Original Source Code Comment: 1ST CHAR MUST BE ALPHA
5948GETFL2
LD A,(HL) 7E
GETFL2: Fetch the next character from HL into Register A.
Original Source Code Comment: GET NEXT CHAR
5949
INC HL 23
INCrement Register Pair HL.
594A
CP 30HCP '0' FE 30
Compare Register A with 30H ('0').
594C
RET C D8
If the CARRY FLAG is set it is a control character or punctuation, so RETurn with it in Register A (the field has ended).
Original Source Code Comment: RET IF CONTROL CHAR
594D
CP 3AHCP ':' FE 3A
Compare Register A with 3AH (':').
594F
If the CARRY FLAG is set it is a digit, so JUMP to 5957H (GETFL4) to keep it.
Original Source Code Comment: JP IF NUMERIC
5951GETFL3
CP 41HCP 'A' FE 41
GETFL3: Compare Register A with 41H ('A').
5953
RET C D8
If the CARRY FLAG is set it is not a letter, so RETurn with it (the field has ended).
Original Source Code Comment: RET IF SPECIAL CHAR
5954
CP 5BHCP 'Z'+1 FE 5B
Compare Register A with 5BH ('Z' + 1).
5956
RET NC D0
If the NC FLAG is set it is above 'Z', so RETurn with it (the field has ended).
Original Source Code Comment: RETURN IF NOT ALPHA
5957GETFL4
LD (DE),A 12
GETFL4: Store the character into the field at DE.
5958
INC DE 13
INCrement Register Pair DE.
5959
DECrement Register B (the places left) and LOOP BACK to 5948H (GETFL2).
Original Source Code Comment: MOVE FIELD
595B
LD A,(HL) 7E
The field is full: fetch the character after it into Register A ...
595C
INC HL 23
... INCrement Register Pair HL past it ...
595D
RET C9
... and RETurn with it in Register A and Register B = 00H.

595EH - HASH - The Hash Code of NAME and EXT

595EHASH
LD B,0BH 06 0B
HASH: LET Register B = 0BH (11), the bytes of NAME and EXT.
5960
LD C,00H 0E 00
LET Register C = 00H, the hash code so far.
5962HASH2
LD A,(HL) 7E
HASH2: Fetch the next byte at HL into Register A.
Original Source Code Comment: GET NEXT CHAR
5963
INC HL 23
INCrement Register Pair HL.
5964
XOR C A9
XOR the hash code so far (Register C) into Register A.
Original Source Code Comment: ACCUMULATE HASH CODE
5965
RLCA 07
RLCA: rotate Register A left one bit.
5966
LD C,A 4F
LET Register C = Register A, the new hash code.
5967
DECrement Register B and LOOP BACK to 5962H (HASH2) for all 11 bytes.
Original Source Code Comment: CONTINUE THROUGH NAME
5969
LD A,C 79
LET Register A = Register C, the hash code.
Original Source Code Comment: REFETCH HASH CODE
596A
OR A B7
Set the FLAGS from Register A.
596B
RET NZ C0
If the NZ FLAG is set RETurn with it: a HIT entry of 00H means a free entry, so the code may not be 00H.
596C
INC A 3C
INCrement Register A: a code of 00H becomes 01H.
Original Source Code Comment: FORCE NON-ZERO
596D
RET C9
RETurn with the hash code in Register A.

596EH - TRAP / SETTDC - The Hash Code of a Password

596ETRAP
EX DE,HL EB
TRAP: EXchange Register Pairs DE and HL: DE points to the password typed (KEYBUF).
Original Source Code Comment: DE => FILENAME
596F
LD H,D 62
LET Register H = Register D ...
5970
LD A,E 7B
... LET Register A = Register E ...
5971
ADD A,B 80
... ADD the length of the password (Register B) ...
5972
LD L,A 6F
... and LET Register L = Register A: HL points just past the password.
5973
LD A,08H 3E 08
LET Register A = 08H, the length of a password.
5975
SUB B 90
SUBtract the length typed (Register B): the places left.
5976
If the Z FLAG is set the password is 8 characters long, so JUMP to 597EH (SETTDC).
5978
LD B,A 47
LET Register B = the places left.
5979FILSPC
LD (HL),20HLD (HL),' ' 36 20
FILSPC: Store a space at HL.
597B
INC HL 23
INCrement Register Pair HL.
597C
DECrement Register B and LOOP BACK to 5979H (FILSPC): the password is padded with spaces to 8 characters.
597ESETTDC
LD HL,0FFFFH 21 FF FF
SETTDC: LET Register Pair HL = FFFFH, the start of the hash code (the source's trap door code).
5981
LD B,08H 06 08
LET Register B = 08H, the characters of the password.
5983
LD A,E 7B
LET Register A = Register E ...
5984
ADD A,07H C6 07
... ADD 07H ...
5986
LD E,A 5F
... and LET Register E = Register A: DE points to the last character of the password.
5987
If the NC FLAG is set the ADD did not carry, so JUMP to 598AH (SETTD2).
5989
INC D 14
INCrement Register D for the carry.
598ASETTD2
LD A,(DE) 1A
SETTD2: Fetch a character of the password (from the last to the first) into Register A.
598B
PUSH DE D5
Save the pointer (Register Pair DE) to the top of the STACK.
598C
LD D,A 57
LET Register D = the character.
598D
LD E,H 5C
LET Register E = Register H, the high byte of the code so far.
598E
LD A,L 7D
LET Register A = Register L, the low byte of the code so far.
598F
AND 07H E6 07
MASK it with 07H.
5991
RRCA 0F
RRCA: rotate Register A right ...
5992
RRCA 0F
... RRCA ...
5993
RRCA 0F
... RRCA: bits 2-0 of L are now bits 7-5.
5994
XOR L AD
XOR Register L into Register A.
5995
LD L,A 6F
LET Register L = Register A.
5996
LD H,00H 26 00
LET Register H = 00H.
5998
ADD HL,HL 29
ADD HL,HL: shift Register Pair HL left one bit ...
5999
ADD HL,HL 29
... again ...
599A
ADD HL,HL 29
... again ...
599B
ADD HL,HL 29
... and a fourth time.
599C
XOR H AC
XOR Register H into Register A.
599D
XOR D AA
XOR the character (Register D) into Register A.
599E
LD D,A 57
LET Register D = Register A, the new high byte.
599F
LD A,L 7D
LET Register A = Register L.
59A0
ADD HL,HL 29
ADD HL,HL: shift Register Pair HL left one more bit.
59A1
XOR H AC
XOR Register H into Register A.
59A2
XOR E AB
XOR the old high byte (Register E) into Register A.
59A3
LD E,A 5F
LET Register E = Register A, the new low byte.
59A4
EX DE,HL EB
EXchange Register Pairs DE and HL: HL = the new code.
59A5
POP DE D1
Restore the pointer into Register Pair DE.
59A6
DEC DE 1B
DECrement Register Pair DE to the character before.
59A7
DECrement Register B and LOOP BACK to 598AH (SETTD2) for all 8 characters.
59A9
RET C9
RETurn with the hash code of the password in Register Pair HL.

59AAH - CKHDRV - Is the Drive There? (Index Pulses)

59AACKHDRV
LD A,0D0HLD A,0D0H 3E D0
CKHDRV: LET Register A = D0H, Force Interrupt.
59AC
OUTput D0H to port F0H, so the status register shows the drive's status (index, write protect).
Original Source Code Comment: FORCE CLEAR FDC
59AE
GOSUB to 55B2H (CSEL) to select drive C and start its motor.
Original Source Code Comment: SELECT DRIVE
59B1
PUSH BC C5
Save Register Pair BC (Register C = the drive) to the top of the STACK.
59B2
LD BC,3155H 01 55 31
LET Register Pair BC = 3155H (12629), the time out count for CHKINX (the source: motor on, one turn and one sector).
59B5CHKDR1
CHKDR1: GOSUB to 59CAH (CHKINX) to read the index bit.
Original Source Code Comment: START WITH NO INDEX
59B8
If the NZ FLAG is set the index hole is under the sensor, so LOOP BACK to 59B5H (CHKDR1) until it has passed.
59BACHKDR2
CHKDR2: GOSUB to 59CAH (CHKINX) to read the index bit.
Original Source Code Comment: WAIT FOR INDEX
59BD
If the Z FLAG is set there is no index yet, so LOOP BACK to 59BAH (CHKDR2) until one comes.
59BFCHKDR3
CHKDR3: GOSUB to 59CAH (CHKINX) to read the index bit.
Original Source Code Comment: WAIT FOR INDEX TO PASS
59C2
If the NZ FLAG is set the index is still there, so LOOP BACK to 59BFH (CHKDR3) until it has passed.
59C4
POP BC C1
The disk turns: restore Register Pair BC.
59C5
RLCA 07
RLCA: rotate the status in Register A left, so bit 6 (write protect) goes to bit 7.
59C6
AND 80H E6 80
MASK with 80H to keep it.
59C8
ADD A,A 87
ADD Register A to itself: the CARRY FLAG gets the write protect bit and Register A becomes 00H, which sets the Z FLAG.
Original Source Code Comment: SET C FLAG IF WRITE PROT
59C9
RET C9
RETurn with Z (the drive is there) and the CARRY FLAG set when it is write protected.

59CAH - CHKINX - Read the Index Bit, with a Time Out

59CACHKINX
DEC BC 0B
CHKINX: DECrement the time out count in Register Pair BC.
59CB
LD A,B 78
LET Register A = Register B ...
59CC
OR C B1
... OR Register C: Z when the count has run out.
59CD
If the Z FLAG is set the time is up, so JUMP to 59D4H (CHKIN2): the drive is not there.
Original Source Code Comment: DRIVE DOESN'T EXIST
59CF
INput the FDC status from port F0H into Register A.
59D1
BIT 1,A CB 4F
Test bit 1, the index bit of the status after a Force Interrupt.
Original Source Code Comment: CHECK INDEX STATUS BIT
59D3
RET C9
RETurn: NZ while the index hole is under the sensor.
59D4CHKIN2
POP BC C1
CHKIN2: Take the return address of the CHKINX call off the STACK.
Original Source Code Comment: IGNORE CHKINX CALLER
59D5
POP BC C1
Restore Register Pair BC (pushed at 59B1H).
Original Source Code Comment: RESTORE BC
59D6
OR 01H F6 01
OR Register A with 01H to set the NZ FLAG.
Original Source Code Comment: CLEAR Z FLAG
59D8
RET C9
RETurn to the caller of CKHDRV with the NZ FLAG set: the drive is not there.

59D9H - RDHITT - Read the HIT of the Source Diskette

59D9RDHITT
PUSH BC C5
RDHITT: Save Register Pair BC (Register C = the drive) to the top of the STACK.
59DA
PUSH DE D5
Save Register Pair DE to the top of the STACK.
59DB
GOSUB to 57A4H (TRKGT) to fetch the directory track of drive C into Register D.
59DE
LD E,01H 1E 01
LET Register E = 01H, the sector of the HIT on the source diskette.
59E0
LD HL,5E00HLD HL,HITBUF 21 00 5E
LET Register Pair HL = 5E00H (HITBUF), the buffer for the HIT.
Original Source Code Comment: HIT TABLE BUFFER
59E3
PUSH HL E5
Save the buffer address to the top of the STACK.
Original Source Code Comment: SAVE THE POINTER
59E4
GOSUB to 5653H (MREAD) to read the HIT of drive C into 5E00H.
Original Source Code Comment: READ IN THE HIT
59E7
POP HL E1
Restore the buffer address into Register Pair HL.
Original Source Code Comment: GET THE BUFFER POINTER BACK
59E8
POP DE D1
Restore Register Pair DE from the STACK.
59E9
POP BC C1
Restore Register Pair BC from the STACK.
59EA
RET Z C8
If the Z FLAG is set the HIT was read, so RETurn with Z and Register Pair HL = 5E00H.
59EB
LD A,16HLD A,EFRE 3E 16
LET Register A = 16H, error 22 (EFRE), HIT read error.
Original Source Code Comment: ERROR CODE
59ED
RET C9
RETurn with the NZ FLAG set (from MREAD).

59EEH - DRV / PWORD / NAME / EXT / UPDTDC / ACCTDC - Variables of the File Spec

59EEDRV
DEFB 00H 00
DRV: the drive of the file spec, FFH when it names none (CRACK); ROPEN stores the drive the file was found on.
Original Source Code Comment: REQUESTED DRIVE NUM
59EF-59F6
DEFS 8
PWORD: 8 bytes, not in the file. The password of the file spec, padded with spaces (CRACK); SETTDC makes its hash code.
Original Source Code Comment: PASSWORD FIELD
59F7-59FE
DEFS 8
NAME: 8 bytes, not in the file. The name of the file spec, padded with spaces; NAME and EXT are compared with the 11 bytes at offset 05H of a directory record.
Original Source Code Comment: FILE NAME
59FF-5A01
DEFS 3
EXT: 3 bytes, not in the file. The extension of the file spec, padded with spaces.
Original Source Code Comment: FILE EXTENSION
5A02-5A03
DEFS 2
UPDTDC: 2 bytes, not in the file. The hash code of PWORD, stored by ROPEN and not read again.
Original Source Code Comment: UPDATE PASS TDC
5A04-5A05
DEFS 2
ACCTDC: 2 bytes, not in the file. The hash code of PWORD, stored by ROPEN and not read again.
Original Source Code Comment: ACCESS PASS TDC

5A06H - Messages

5A06-5A34TITLE
DEFM "Model 1 to Model 3 Conversion Utility. Ver 1.3" 4D 6F 64 65 6C 20 31 20 74 6F 20 4D 6F 64 65 6C 20 33 20 43 6F 6E 76 65 72 73 69 6F 6E 20 55 74 69 6C 69 74 79 2E 20 20 56 65 72 20 31 2E 33
TITLE: the sign on text 'Model 1 to Model 3 Conversion Utility. Ver 1.3'.
5A35-5A36
DEFW 0D0AH 0A 0D
The bytes 0AH (line feed) and 0DH, which ends TITLE for PRINT.
5A37-5A44DRIV1
DEFM "Source Drive? " 53 6F 75 72 63 65 20 44 72 69 76 65 3F 20
DRIV1: the prompt 'Source Drive? '.
5A45
DEFB 03H 03
03H ends DRIV1 for PRINT without a new line.
5A46-5A58DRV2
DEFM "Destination Drive? " 44 65 73 74 69 6E 61 74 69 6F 6E 20 44 72 69 76 65 3F 20
DRV2: the prompt 'Destination Drive? '.
5A59
DEFB 03H 03
03H ends DRV2 without a new line.
5A5A-5A5BFINA
DEFW 0A0AH 0A 0A
FINA: two line feeds (0AH 0AH) before the text that follows.
5A5C-5A6E
DEFM "Conversion Complete" 43 6F 6E 76 65 72 73 69 6F 6E 20 43 6F 6D 70 6C 65 74 65
'Conversion Complete', shown when every file has been looked at.
5A6F
DEFB 0DH 0D
0DH ends FINA with a new line (the source writes it as ~).
5A70-5A90EXSMSG
DEFM "Existing File. Use it (Y/N/Q) ? " 45 78 69 73 74 69 6E 67 20 46 69 6C 65 2E 20 20 55 73 65 20 69 74 20 28 59 2F 4E 2F 51 29 20 3F 20
EXSMSG: 'Existing File. Use it (Y/N/Q) ? ', shown after the file name when the file is already on the destination diskette.
5A91
DEFB 03H 03
03H ends EXSMSG without a new line.
5A92-5AA4PASMSG
DEFM "Enter Password for " 45 6E 74 65 72 20 50 61 73 73 77 6F 72 64 20 66 6F 72 20
PASMSG: 'Enter Password for ', shown before the file name.
5AA5
DEFB 03H 03
03H ends PASMSG without a new line.
5AA6-5AB2INVALD
DEFM "Invalid Reply" 49 6E 76 61 6C 69 64 20 52 65 70 6C 79
INVALD: 'Invalid Reply', shown when INPUT gets no character.
5AB3
DEFB 0DH 0D
0DH ends INVALD with a new line (~).
5AB4-5AD6CANT
DEFM "Single Drive Convert is NOT allowed" 53 69 6E 67 6C 65 20 44 72 69 76 65 20 43 6F 6E 76 65 72 74 20 69 73 20 4E 4F 54 20 61 6C 6C 6F 77 65 64
CANT: 'Single Drive Convert is NOT allowed', shown when the two drives are the same.
5AD7
DEFB 0DH 0D
0DH ends CANT with a new line (~).
5AD8-5AF5SKIP
DEFM "NOT Converted (Protected File)" 4E 4F 54 20 43 6F 6E 76 65 72 74 65 64 20 28 50 72 6F 74 65 63 74 65 64 20 46 69 6C 65 29
SKIP: 'NOT Converted (Protected File)', shown after the name of a file with an access password of its own.
5AF6
DEFB 0DH 0D
0DH ends SKIP with a new line (~).
5AF7-5AFAQUERY
DEFM " ? " 20 3F 20 20
QUERY: ' ? ', shown after the file name when the password is asked for.
5AFB
DEFB 03H 03
03H ends QUERY without a new line.
5AFC-5AFDSPCOFF
DEFW 0F20H 20 0F
SPCOFF: the bytes 20H (a space) and 0FH (cursor off), shown after the file name by DSPNAM.
5AFE
DEFB 03H 03
03H ends SPCOFF without a new line; the last byte of the file.

5AFFH - Variables and Buffers (not in the file)

5AFFSDRIVE
DEFS 1
SDRIVE: 1 byte, not in the file. The source drive (binary).
Original Source Code Comment: SOURCE DRIVE (BINARY)
5B00DDRIVE
DEFS 1
DDRIVE: 1 byte, not in the file. The destination drive (binary).
Original Source Code Comment: DESTINATION DRIVE (BINARY)
5B01MOVFLG
DEFS 1
MOVFLG: 1 byte, not in the file. FFH when only ENTER was pressed for the password: the file is copied without it and PROCE4 puts the update password code into the new directory record; 00H otherwise.
Original Source Code Comment: FLAG TO SHOW 'ENTER' FOR PASSWORD
5B02-5B03FILPNT
DEFS 2
FILPNT: 2 bytes, not in the file. The address of the next HIT entry in 5E00H-5EFFH; it walks a column at a time (32 bytes apart).
Original Source Code Comment: POINTER TO HIT TABLE
5B04FILCNT
DEFS 1
FILCNT: 1 byte, not in the file. The HIT entries left to look at, from 64.
Original Source Code Comment: NUMBER OF FILES LEFT TO LOOK AT
5B05LFNCNT
DEFS 1
LFNCNT: 1 byte, not in the file. The directory record of the HIT entry in FILPNT: bits 0-2 the directory sector less 2, bits 3-5 the record in it.
Original Source Code Comment: LFN COUNTER
5B06SVCNT
DEFS 1
SVCNT: 1 byte, not in the file. The length of the password typed.
Original Source Code Comment: CHAR COUNT OF PW ENTERED
5B07-5B08PWSAVE
DEFS 2
PWSAVE: 2 bytes, not in the file. The hash code of the update password of the file (directory record offset 10H), stored by CKPROT.
Original Source Code Comment: USER SUPPLIED PW (TRAP DOOR CODE) HERE
5B09-5B26FILNAM
DEFS 30
FILNAM: 30 bytes, not in the file. NAME/EXT and 03H, made by COMPRS from the directory record.
Original Source Code Comment: SCRATCH PAD FOR FILE NAME
5B27-5B30KEYBUF
DEFS 10
KEYBUF: 10 bytes, not in the file. The reply KEYN reads (a drive, Y/N/Q, a password).
Original Source Code Comment: SCRATCH PAD KEYBOARD BUFFER
5B31-5B62DCBR
DEFS 50
DCBR: 50 bytes, not in the file. The DCB of the file read from the source diskette; before ROPEN it holds the file spec.
Original Source Code Comment: READ DCB
5B63-5B94DCBW
DEFS 50
DCBW: 50 bytes, not in the file. The DCB of the file written on the destination diskette; before INIT it holds the file spec.
Original Source Code Comment: WRITE DCB
5B95-5C94DBUFR1
DEFS 256
DBUFR1: 256 bytes, not in the file. The sector buffer of DCBR.
Original Source Code Comment: READ DISK BUFFER
5C95-5D94DBUFR2
DEFS 256
DBUFR2: 256 bytes, not in the file. The sector buffer of DCBW.
Original Source Code Comment: WRITE DISK BUFFER
5E00-5EFFHITBUF
DEFS 256
HITBUF: 256 bytes, not in the file (ORG $,256 puts it on a 256 byte boundary). The HIT of the source diskette.
Original Source Code Comment: HASH CODE TABLE BUFFER
5F00-5FFFBUFER2
DEFS 256
BUFER2: 256 bytes, not in the file. The GAT of the source diskette, then each directory sector read.
Original Source Code Comment: MODEL 1 INTERNAL DISK BUFFER
 
END 5200H