5200H - Main Entry Point and Initialization
This is the main entry point for the CONVERT utility. It saves the command line pointer, sets a system flag, clears the screen, displays the title message, and then parses the command line for optional source:destination drive specifications. If no drives are specified on the command line, it prompts the user for each.
5200
PUSH HL E5
Save Register Pair HL to the stack. HL points to the command line parameters passed to the program.
5201
LD A,55H 3E 55
Load Register A with 55H. This is a flag value indicating the program has been initialized.
5203
LD (42B4H),A 32 B4 42
Store the value 55H into memory location 42B4H, setting the initialization flag.
5206
GOSUB to ROM routine at 01C9H to clear the screen.
5209
Point Register Pair HL to 5A06H, which contains the title message: "Model 1 to Model 3 Conversion Utility. Ver 1.3"
520C
GOSUB to ROM routine at 021BH to display the string at (HL) until a 03H byte is encountered.
520F
POP HL E1
Restore Register Pair HL from the stack (command line pointer).
5210
LD A,(HL) 7E
Fetch the first character from the command line into Register A.
5211
CP 20H FE 20
Compare Register A against 20H (ASCII space). If A < 20H (control character), the CARRY FLAG is set.
5213
If the CARRY FLAG is set (character is a control code like CR), JUMP to 523CH to prompt for source drive.
5215
CP 3AH FE 3A
Compare Register A against 3AH (ASCII colon :). If equal, Z FLAG is set.
5217
If the NZ FLAG is set (not a colon), JUMP to 523CH to prompt for source drive. We expect ":n" format.
If we reach here, the user specified a source drive as ":n" on the command line.
5219
INC HL 23
INCrement HL to point to the character after the colon (the drive number).
521A
LD A,(HL) 7E
Fetch the drive number character into Register A.
521B
GOSUB to 5462H to validate and convert the ASCII drive number to binary (0-3).
521E
If the NZ FLAG is set (invalid drive number), JUMP to DOS error handler at 4409H.
5221
LD (5AFFH),A 32 FF 5A
Store the validated source drive number into 5AFFH.
5224
INC HL 23
INCrement HL past the drive number.
5225
INC HL 23
INCrement HL again (skip potential space).
5226
LD A,(HL) 7E
Fetch the next character (expecting another colon for destination drive).
5227
CP 20H FE 20
Compare Register A against 20H (space). If A < 20H, CARRY is set.
5229
If CARRY is set (end of parameters), JUMP to 524EH to prompt for destination drive only.
522B
CP 3AH FE 3A
Compare against 3AH (colon) to check for destination drive specification.
522D
If NZ FLAG is set (not a colon), JUMP to 524EH to prompt for destination drive.
522F
INC HL 23
INCrement HL to point to destination drive number.
5230
LD A,(HL) 7E
Fetch the destination drive number character.
5231
GOSUB to 5462H to validate the destination drive number.
5234
If invalid, JUMP to DOS error handler.
5237
LD (5B00H),A 32 00 5B
Store the destination drive number into 5B00H.
523A
JUMP to 5260H to begin conversion (both drives specified).
523CH - Prompt for Source Drive
This routine prompts the user to enter the source drive number (the Model I diskette). It displays "Source Drive?" and waits for input. If the user presses BREAK or enters an invalid drive, it returns to DOS or re-prompts.
523C
Point HL to 5A37H, which contains the message: "Source Drive? "
523F
GOSUB to 53D0H to display the prompt and get user input (single character).
5242
If CARRY is set (user pressed BREAK), JUMP to 4030H to return to DOS READY.
5245
LD A,(HL) 7E
Fetch the character entered by the user from the input buffer.
5246
GOSUB to 5462H to validate the drive number (convert ASCII to binary).
5249
If NZ FLAG is set (invalid entry), [LOOP] back to 523CH to re-prompt.
524B
LD (5AFFH),A 32 FF 5A
Store the validated source drive number into 5AFFH.
524EH - Prompt for Destination Drive
This routine prompts the user to enter the destination drive number (the Model III diskette). It displays "Destination Drive?" and validates the input.
524E
Point HL to 5A46H, which contains the message: "Destination Drive? "
5251
GOSUB to 53D0H to display the prompt and get user input.
5254
If CARRY is set (BREAK pressed), JUMP to DOS READY at 4030H.
5257
LD A,(HL) 7E
Fetch the user's input character.
5258
GOSUB to 5462H to validate the destination drive number.
525B
If NZ FLAG is set (invalid), [LOOP] back to 524EH to re-prompt.
525D
LD (5B00H),A 32 00 5B
Store the destination drive number into 5B00H.
5260H - Validate Drives and Initialize Conversion
This section verifies that source and destination drives are different, then initializes the conversion process by reading the source disk's GAT and setting up counters for directory traversal.
5260
LD A,(5AFFH) 3A FF 5A
Fetch the source drive number from 5AFFH.
5263
LD B,A 47
Copy the source drive number to Register B for comparison.
5264
LD A,(5B00H) 3A 00 5B
Fetch the destination drive number from 5B00H.
5267
SUB B 90
SUBtract source from destination. If they are the same, result is zero.
5268
If NZ FLAG is set (drives are different), JUMP to 5272H to continue.
Source and destination drives are the same - display error and re-prompt.
526A
Point HL to 5AB4H containing: "Single Drive Convert is NOT allowed"
526D
GOSUB to ROM to display the error message.
5270
[LOOP] back to 523CH to re-prompt for source drive.
Drives are valid and different - proceed with initialization.
5272
LD A,(5AFFH) 3A FF 5A
Fetch source drive number again.
5275
LD C,A 4F
Copy to Register C for the directory read routine.
5276
GOSUB to 59D9H to read the source disk's directory sector into buffer at 5E00H.
5279
If NZ FLAG is set (read error), JUMP to DOS error handler.
527C
LD (5B02H),HL 22 02 5B
Store HL (directory buffer pointer) into 5B02H for tracking current position.
527F
XOR A AF
Set Register A to ZERO.
5280
LD (5B05H),A 32 05 5B
Clear 5B05H (current sector/granule position counter).
5283
LD (5B01H),A 32 01 5B
Clear 5B01H (skip file flag).
5286
LD A,40H 3E 40
Load Register A with 40H (64 decimal) - maximum directory entries.
5288
LD (5B04H),A 32 04 5B
Store 64 into 5B04H as the directory entry counter.
528B
GOSUB to 5780H to read the GAT (Granule Allocation Table) from the source disk.
528E
If NZ FLAG is set (read error), JUMP to DOS error handler.
5291
LD A,(5FC0H) 3A C0 5F
Fetch the "tracks per disk" value from offset C0H in the GAT buffer.
5294
SUB 24H D6 24
SUBtract 24H (36 decimal). This adjusts for the directory track offset.
5296
LD (5886H),A 32 86 58
Store the adjusted track count at 5886H (self-modifying code location).
5299H - Main Directory Processing Loop
This is the main loop that processes each directory entry on the source disk. It scans through all 64 possible entries, converting files one at a time until complete.
5299
GOSUB to 5495H to check and process the current directory entry.
529C
If CARRY is set (no more entries or done), JUMP to 52A7H to finish.
529E
GOSUB to 54E9H to perform the actual file conversion.
52A1
XOR A AF
Set Register A to ZERO.
52A2
LD (5B01H),A 32 01 5B
Clear the skip file flag at 5B01H.
52A5
[LOOP] back to 5299H to process the next directory entry.
All entries processed - display completion message and return to DOS.
52A7
Point HL to 5A5AH containing: "Conversion Complete"
52AA
GOSUB to ROM to display the completion message.
52AD
JUMP to 402DH ($JP2DOS) to return to TRSDOS READY.
52B0H - Extract Filename from Directory Entry
This routine extracts the filename and extension from a Model I directory entry pointed to by HL. It copies up to 8 characters of the filename and 3 characters of the extension (separated by a slash) into the buffer at 5B09H, terminated with 03H.
52B0
PUSH BC C5
Save Register Pair BC to the stack.
52B1
PUSH DE D5
Save Register Pair DE to the stack.
52B2
PUSH HL E5
Save Register Pair HL to the stack (directory entry pointer).
52B3
LD B,08H 06 08
Load Register B with 08H - maximum filename length.
52B5
PUSH HL E5
Save HL again for later restoration.
52B6
LD DE,0005H 11 05 00
Load DE with offset 5 - the filename starts at offset 5 in a Model I directory entry.
52B9
ADD HL,DE 19
ADD offset to HL to point to the filename within the directory entry.
52BA
LD DE,5B09H 11 09 5B
Point DE to the filename output buffer at 5B09H.
52BD
LD A,(HL) 7E
[LOOP START] Fetch a character from the filename.
52BE
CP 20H FE 20
Compare against 20H (space). Filenames are padded with spaces.
52C0
If Z FLAG is set (found a space), JUMP to 52C7H to end filename copy.
52C2
LD (DE),A 12
Store the filename character into the output buffer.
52C3
INC HL 23
INCrement HL to next source character.
52C4
INC DE 13
INCrement DE to next destination position.
52C5
DECrement B and Jump if Not Zero - [LOOP] for up to 8 characters.
52C7
POP HL E1
Restore HL to point to start of directory entry.
52C8
PUSH DE D5
Save current output position.
52C9
LD DE,000DH 11 0D 00
Load DE with offset 0DH (13) - extension starts at offset 13 in directory entry.
52CC
ADD HL,DE 19
ADD offset to HL to point to the extension.
52CD
POP DE D1
Restore output buffer pointer.
52CE
LD A,(HL) 7E
Fetch first extension character.
52CF
CP 20H FE 20
Compare against space - check if extension exists.
52D1
If Z FLAG is set (no extension), JUMP to 52E3H to finish.
52D3
LD A,2FH 3E 2F
Load Register A with 2FH (ASCII slash /) as separator.
52D5
LD (DE),A 12
Store the slash separator in the output buffer.
52D6
INC DE 13
INCrement output pointer.
52D7
LD B,03H 06 03
Load Register B with 03H - maximum extension length.
52D9
LD A,(HL) 7E
[LOOP START] Fetch extension character.
52DA
CP 20H FE 20
Compare against space.
52DC
If space found, JUMP to 52E3H to finish.
52DE
LD (DE),A 12
Store extension character.
52DF
INC HL 23
INCrement source pointer.
52E0
INC DE 13
INCrement destination pointer.
52E1
DECrement B and loop for up to 3 characters.
52E3
LD A,03H 3E 03
Load Register A with 03H (ETX - end of text marker).
52E5
LD (DE),A 12
Store the terminator in the output buffer.
52E6
POP HL E1
Restore original HL.
52E7
POP DE D1
Restore original DE.
52E8
POP BC C1
Restore original BC.
52E9
RET C9
RETurn to caller.
52EAH - Copy Filename to Source and Destination Buffers
This routine copies the extracted filename from the buffer at 5B09H to both the source filespec buffer (5B63H) and destination filespec buffer (5B31H), creating complete filespecs for both drives.
52EA
PUSH BC C5
Save Register Pair BC to the stack.
52EB
PUSH DE D5
Save Register Pair DE to the stack.
52EC
PUSH HL E5
Save Register Pair HL to the stack.
52ED
LD DE,5B63H 11 63 5B
Point DE to the destination filespec buffer at 5B63H.
52F0
LD BC,5B31H 01 31 5B
Point BC to the source filespec buffer at 5B31H.
52F3
LD HL,5B09H 21 09 5B
Point HL to the filename buffer at 5B09H.
52F6
LD A,(HL) 7E
[LOOP START] Fetch a character from the filename buffer.
52F7
LD (DE),A 12
Store the character to the destination buffer.
52F8
LD (BC),A 02
Store the character to the source buffer.
52F9
CP 03H FE 03
Compare against 03H (end of text marker).
52FB
If Z FLAG is set (end of filename), JUMP to 5302H to finish.
52FD
INC HL 23
INCrement source pointer.
52FE
INC DE 13
INCrement destination buffer pointer.
52FF
INC BC 03
INCrement source buffer pointer.
5300
[LOOP] back to copy next character.
5302
POP HL E1
Restore HL from the stack.
5303
POP DE D1
Restore DE from the stack.
5304
POP BC C1
Restore BC from the stack.
5305
RET C9
RETurn to caller.
5306H - Append Extension Separator and Build Full Filespec
This routine appends a period separator and processes the filespec, building properly formatted source and destination file specifications with drive numbers appended.
5306
PUSH BC C5
Save Register Pair BC to the stack.
5307
PUSH DE D5
Save Register Pair DE to the stack.
5308
PUSH HL E5
Save Register Pair HL to the stack.
5309
LD HL,5B31H 21 31 5B
Point HL to the source filespec buffer at 5B31H.
530C
LD C,00H 0E 00
Clear Register C (character counter).
530E
LD A,(HL) 7E
[LOOP START] Fetch a character from the source buffer.
530F
CP 03H FE 03
Compare against 03H (end marker).
5311
If Z FLAG is set (found end), JUMP to 5317H.
5313
INC HL 23
INCrement buffer pointer.
5314
INC C 0C
INCrement character count.
5315
[LOOP] back to count next character.
5317
EX DE,HL EB
Exchange DE and HL. DE now points to end of source buffer.
5318
LD HL,5B63H 21 63 5B
Point HL to the destination filespec buffer.
531B
LD B,00H 06 00
Clear Register B (high byte of offset).
531D
ADD HL,BC 09
ADD character count to HL to point to end of destination filename.
531E
LD BC,5B27H 01 27 5B
Point BC to the input buffer at 5B27H.
5321
LD A,2EH 3E 2E
Load Register A with 2EH (ASCII period .).
5323
LD (HL),A 77
Store the period at the end of destination filename.
5324
LD (DE),A 12
Store the period at the end of source filename.
5325
JUMP to 5335H to continue building filespec.
5327
LD A,(BC) 0A
[LOOP START] Fetch character from input buffer.
5328
CP 30H FE 30
Compare against 30H (ASCII 0).
532A
If NC FLAG (character >= '0'), JUMP to 532EH.
532C
LD A,0DH 3E 0D
Load Register A with 0DH (carriage return) as terminator.
532E
LD (DE),A 12
Store character to source buffer.
532F
LD (HL),A 77
Store character to destination buffer.
5330
CP 0DH FE 0D
Compare against 0DH (carriage return).
5332
If Z FLAG is set (found CR), JUMP to 5339H to finish.
5334
INC BC 03
INCrement input buffer pointer.
5335
INC DE 13
INCrement source buffer pointer.
5336
INC HL 23
INCrement destination buffer pointer.
5337
[LOOP] back to process next character.
5339
POP HL E1
Restore HL from the stack.
533A
POP DE D1
Restore DE from the stack.
533B
POP BC C1
Restore BC from the stack.
533C
RET C9
RETurn to caller.
533DH - Append Drive Numbers to Filespecs
This routine appends the appropriate drive number specifiers (":n") to the source and destination filespec buffers, completing the full file specifications.
533D
PUSH BC C5
Save Register Pair BC to the stack.
533E
PUSH DE D5
Save Register Pair DE to the stack.
533F
PUSH HL E5
Save Register Pair HL to the stack.
5340
LD HL,5B31H 21 31 5B
Point HL to the source filespec buffer.
5343
LD C,00H 0E 00
Clear Register C (character counter).
5345
LD A,(HL) 7E
[LOOP START] Fetch character from buffer.
5346
CP 20H FE 20
Compare against 20H (space). Looking for end of filespec.
5348
If CARRY (control character), JUMP to 534EH - found end.
534A
INC HL 23
INCrement buffer pointer.
534B
INC C 0C
INCrement character count.
534C
[LOOP] back to count next character.
534E
LD A,(5AFFH) 3A FF 5A
Fetch the source drive number.
5351
GOSUB to 5364H to append ":n" to the current buffer position.
5354
LD HL,5B63H 21 63 5B
Point HL to the destination filespec buffer.
5357
LD B,00H 06 00
Clear Register B.
5359
ADD HL,BC 09
ADD character count to HL to point to end of filename.
535A
LD A,(5B00H) 3A 00 5B
Fetch the destination drive number.
535D
GOSUB to 5364H to append ":n" to the destination buffer.
5360
POP HL E1
Restore HL from the stack.
5361
POP DE D1
Restore DE from the stack.
5362
POP BC C1
Restore BC from the stack.
5363
RET C9
RETurn to caller.
5364H - Append Drive Specifier to Buffer
This helper routine appends a colon, ASCII drive number, and carriage return to the buffer pointed to by HL. Entry: A = drive number (0-3), HL = buffer position.
5364
LD (HL),3AH 36 3A
Store 3AH (ASCII colon :) at (HL).
5366
INC HL 23
INCrement buffer pointer.
5367
ADD 30H C6 30
ADD 30H to Register A to convert binary drive number to ASCII ('0'-'3').
5369
LD (HL),A 77
Store the ASCII drive number at (HL).
536A
INC HL 23
INCrement buffer pointer.
536B
LD (HL),0DH 36 0D
Store 0DH (carriage return) as terminator.
536D
RET C9
RETurn to caller.
536EH - Check File Transfer/Load Address
This routine examines the directory entry to determine if the file is a loadable program with a transfer address. It checks if the file loads to 4296H (DOS READY) indicating it's a program file, or if the load address matches the file start, indicating it's not a program.
536E
PUSH BC C5
Save Register Pair BC to the stack.
536F
PUSH DE D5
Save Register Pair DE to the stack.
5370
PUSH HL E5
Save Register Pair HL to the stack.
5371
EX DE,HL EB
Exchange DE and HL. DE now points to directory entry.
5372
LD HL,0010H 21 10 00
Load HL with offset 10H (16) - location of load address in directory entry.
5375
ADD HL,DE 19
ADD offset to directory entry pointer.
5376
LD C,(HL) 4E
Fetch low byte of load address into Register C.
5377
INC HL 23
INCrement to high byte.
5378
LD B,(HL) 46
Fetch high byte of load address into Register B. BC = load address.
5379
INC HL 23
INCrement to transfer address low byte.
537A
PUSH AF F5
Save AF to the stack.
537B
LD A,(HL) 7E
Fetch low byte of transfer address.
537C
INC HL 23
INCrement to high byte.
537D
LD H,(HL) 66
Fetch high byte of transfer address into H.
537E
LD L,A 6F
Put low byte into L. HL = transfer address.
537F
POP AF F1
Restore AF from the stack.
5380
ADD HL,BC 09
ADD load address to transfer address.
5381
If CARRY (overflow), JUMP to 538BH.
5383
LD BC,852CH 01 2C 85
Load BC with 852CH - a comparison value.
5386
OR A B7
Clear CARRY flag for subtraction.
5387
SBC HL,BC ED 42
SUBtract BC from HL with borrow.
5389
If Z FLAG is set (matched), JUMP to 53B9H.
538B
LD HL,0010H 21 10 00
Load HL with offset 10H again.
538E
ADD HL,DE 19
ADD to directory entry pointer.
5390
LD A,(HL) 7E
Fetch load address low byte.
5391
INC HL 23
INCrement pointer.
5392
LD H,(HL) 66
Fetch load address high byte.
5393
LD L,A 6F
Complete HL = load address.
5395
LD (5B07H),HL 22 07 5B
Store load address at 5B07H.
5398
LD HL,0012H 21 12 00
Load HL with offset 12H (transfer address location).
539B
ADD HL,DE 19
ADD to directory entry pointer.
539C
LD C,(HL) 4E
Fetch transfer address low byte.
539D
INC HL 23
INCrement pointer.
539E
LD B,(HL) 46
Fetch transfer address high byte. BC = transfer address.
539F
LD HL,4296H 21 96 42
Load HL with 4296H (DOS READY entry point).
53A2
PUSH HL E5
Save 4296H for later comparison.
53A3
OR A B7
Clear CARRY flag.
53A4
SBC HL,BC ED 42
Compare transfer address against 4296H.
53A7
If Z FLAG (transfer = 4296H), JUMP to 53B7H - it's a program file.
53A9
LD HL,(5B07H) 2A 07 5B
Fetch load address from storage.
53AC
PUSH HL E5
Save load address.
53AD
OR A B7
Clear CARRY flag.
53AE
SBC HL,BC ED 42
Compare load address against transfer address.
53B1
If Z FLAG (load = transfer), JUMP to 53B7H.
53B3
XOR A AF
Set Register A to ZERO.
53B4
SCF 37
Set the CARRY flag to indicate special case.
53B5
JUMP to 53B9H to return.
53B7
OR FFHOR 11111111 F6 FF
Set A to FFH and clear Z flag to indicate normal file.
53B9
POP HL E1
Restore HL from the stack.
53BA
POP DE D1
Restore DE from the stack.
53BB
POP BC C1
Restore BC from the stack.
53BC
RET C9
RETurn to caller with flags indicating file type.
53BDH - Display Filename with Message
This routine displays the current filename followed by additional status text. It outputs the filename from 5B09H and then a message from 5AFCH.
53BD
PUSH BC C5
Save Register Pair BC to the stack.
53BE
PUSH DE D5
Save Register Pair DE to the stack.
53BF
PUSH HL E5
Save Register Pair HL to the stack.
53C0
LD HL,5B09H 21 09 5B
Point HL to the filename buffer at 5B09H.
53C3
GOSUB to ROM to display the filename string.
53C6
Point HL to 5AFCH containing: " ? "
53C9
GOSUB to ROM to display the status message.
53CC
POP HL E1
Restore HL from the stack.
53CD
POP DE D1
Restore DE from the stack.
53CE
POP BC C1
Restore BC from the stack.
53CF
RET C9
RETurn to caller.
53D0H - Display Prompt and Get Single Character Input
This routine displays a prompt message at (HL), then waits for the user to enter a single character. If the user enters nothing and just presses ENTER, it displays "Invalid Reply" and loops. Returns with HL pointing to the input buffer and CARRY set if BREAK was pressed.
53D0
LD (53E9H),HL 22 E9 53
Store the prompt address at 53E9H (self-modifying code).
53D3
GOSUB to ROM to display the prompt string.
53D6
LD HL,5B27H 21 27 5B
Point HL to the input buffer at 5B27H.
53D9
LD B,01H 06 01
Load Register B with 01H - maximum input length of 1 character.
53DB
GOSUB to ROM at 0040H to get line input. Returns CARRY if BREAK pressed.
53DE
RET C D8
If CARRY is set (BREAK pressed), RETurn immediately.
53DF
LD A,B 78
Copy B (number of characters entered) to Register A.
53E0
OR A B7
Set FLAGS based on A (check if any characters entered).
53E1
RET NZ C0
If NZ FLAG is set (user entered something), RETurn.
User pressed ENTER without entering anything - display error and re-prompt.
53E2
Point HL to 5AA6H containing: "Invalid Reply"
53E5
GOSUB to ROM to display the error message.
53E8
LD HL,0000H 21 00 00
Load HL with 0000H (placeholder - will be modified by 53D0H).
53EB
[LOOP] back to 53D3H to re-display prompt and get input.
53EDH - Prompt for File Conversion (Y/N/Q)
This routine displays a prompt asking if the user wants to convert the current file. It shows "Existing File. Use it (Y/N/Q)?" and waits for the user's response. Returns Z flag set if user pressed Q to quit.
53ED
PUSH BC C5
Save Register Pair BC to the stack.
53EE
PUSH DE D5
Save Register Pair DE to the stack.
53EF
PUSH HL E5
Save Register Pair HL to the stack.
53F0
Point HL to 5A70H containing: "Existing File. Use it (Y/N/Q)? "
53F3
GOSUB to ROM to display the prompt.
53F6
LD HL,5B27H 21 27 5B
Point HL to the input buffer at 5B27H.
53F9
LD B,03H 06 03
Load Register B with 03H - maximum 3 characters input.
53FB
GOSUB to ROM to get line input.
53FE
If CARRY is set (BREAK pressed), JUMP to DOS READY.
5401
LD A,(HL) 7E
Fetch the first character of user input.
5402
CP 51H FE 51
Compare against 51H (ASCII Q for Quit).
5404
If Z FLAG is set (user typed Q), JUMP to DOS READY to quit.
5407
CP 4EH FE 4E
Compare against 4EH (ASCII N for No).
5409
POP HL E1
Restore HL from the stack.
540A
POP DE D1
Restore DE from the stack.
540B
POP BC C1
Restore BC from the stack.
540C
RET C9
RETurn. Z flag indicates if user typed N (skip file).
540DH - Prompt for Password
This routine prompts the user for a password when converting a password-protected file. It displays "Enter Password for " followed by the filename, then accepts up to 8 characters of input. If the user presses ENTER without typing anything, the skip flag is set at 5B01H.
540D
PUSH BC C5
Save Register Pair BC to the stack.
540E
PUSH DE D5
Save Register Pair DE to the stack.
540F
XOR A AF
Set Register A to ZERO.
5410
LD (5B01H),A 32 01 5B
Clear the skip flag at 5B01H.
5413
Point HL to 5A92H containing: "Enter Password for "
5416
GOSUB to ROM to display the prompt prefix.
5419
LD HL,5B09H 21 09 5B
Point HL to filename buffer at 5B09H.
541C
GOSUB to ROM to display the filename.
541F
Point HL to 5AF7H containing: " ? "
5422
GOSUB to ROM to display the prompt suffix.
5425
LD HL,5B27H 21 27 5B
Point HL to input buffer at 5B27H.
5428
LD B,08H 06 08
Load Register B with 08H - maximum 8 characters for password.
542A
GOSUB to ROM at 0040H to get line input.
542D
If CARRY is set (BREAK pressed), JUMP to DOS READY.
5430
LD A,B 78
Copy B (number of characters entered) to Register A.
5431
OR A B7
Set FLAGS based on A (check if any characters entered).
5432
If Z FLAG is set (no characters entered), JUMP to 543AH to set skip flag.
5434
LD A,B 78
Copy character count to A again.
5435
LD (5B06H),A 32 06 5B
Store password length at 5B06H.
5438
JUMP to 543FH to return normally.
User pressed ENTER without entering a password - set skip flag.
543A
SUB 01H D6 01
SUBtract 1 from A (0 - 1 = FFH with CARRY).
543C
LD (5B01H),A 32 01 5B
Store FFH at 5B01H as skip flag (non-zero = skip file).
543F
POP DE D1
Restore DE from the stack.
5440
POP BC C1
Restore BC from the stack.
5441
RET C9
RETurn to caller.
5442H - Verify Password
This routine verifies the entered password against the file's stored password hash. It computes a hash of the entered password and compares it against the hash stored in the file's directory entry. Returns CARRY set if password is incorrect.
5442
PUSH BC C5
Save Register Pair BC to the stack.
5443
PUSH DE D5
Save Register Pair DE to the stack.
5444
PUSH HL E5
Save Register Pair HL to the stack.
5445
LD HL,5B27H 21 27 5B
Point HL to the password input buffer at 5B27H.
5448
LD A,(5B06H) 3A 06 5B
Fetch the password length from 5B06H.
544B
LD B,A 47
Copy password length to Register B.
544C
GOSUB to 596EH to compute password hash. Returns hash in HL.
544F
LD DE,(5B07H) ED 5B 07 5B
Fetch the stored password hash from 5B07H.
5453
PUSH HL E5
Save computed hash.
5454
OR A B7
Clear CARRY flag for subtraction.
5455
SBC HL,DE ED 52
Compare computed hash against stored hash (HL - DE).
5457
POP HL E1
Restore computed hash to HL.
5458
If Z FLAG is set (hashes match), JUMP to 545DH - password correct.
545A
SCF 37
Set CARRY flag to indicate password mismatch.
545B
JUMP to 545EH to return with CARRY set.
545D
OR A B7
Clear CARRY flag - password is correct.
545E
POP HL E1
Restore HL from the stack.
545F
POP DE D1
Restore DE from the stack.
5460
POP BC C1
Restore BC from the stack.
5461
RET C9
RETurn. CARRY set = wrong password, CARRY clear = correct.
5462H - Validate Drive Number
This routine validates a drive number character. It converts the ASCII digit to binary and checks it against the maximum allowed drive number stored at 4413H. Returns Z flag set if valid, NZ if invalid.
5462
SUB 30H D6 30
SUBtract 30H from Register A to convert ASCII '0'-'9' to binary 0-9.
5464
If CARRY is set (character was below '0'), JUMP to 5470H - invalid.
5466
LD C,A 4F
Copy the binary drive number to Register C.
5467
LD A,(4413H) 3A 13 44
Fetch the maximum drive number from DOS variable at 4413H.
546A
CP C B9
Compare maximum against the entered drive number.
546B
If CARRY is set (entered > max), JUMP to 5474H - invalid.
546D
XOR A AF
Set Register A to ZERO (clears flags, sets Z).
546E
LD A,C 79
Copy the valid drive number back to Register A.
546F
RET C9
RETurn with Z flag set (valid drive).
5470
LD A,20H 3E 20
Load A with 20H (error code for invalid input).
5472
OR A B7
Set FLAGS - NZ indicates error.
5473
RET C9
RETurn with NZ flag (invalid - below '0').
5474
LD A,02H 3E 02
Load A with 02H (error code for drive out of range).
5476
OR A B7
Set FLAGS - NZ indicates error.
5477
RET C9
RETurn with NZ flag (invalid - exceeds max drive).
5478H - Open Source and Destination Files
This routine opens both the source file (for reading from Model I disk) and destination file (for writing to Model III disk). It handles the case where the destination file already exists (error 1CH = file exists).
5478
LD DE,5B31H 11 31 5B
Point DE to source filespec buffer at 5B31H.
547B
GOSUB to 56E0H to open the source file for reading.
547E
If Z FLAG is set (file opened successfully), JUMP to 548AH to open destination.
5480
LD B,A 47
Save error code in Register B.
5481
AND FEHAND 11111110 E6 FE
Mask off bit 0 to group similar errors.
5483
CP 1CH FE 1C
Compare against 1CH (file already exists error).
5485
RET Z C8
If Z FLAG is set (file exists), RETurn - will prompt user.
5486
LD A,B 78
Restore original error code to Register A.
5487
JUMP to DOS error handler at 4409H.
548A
LD DE,5B63H 11 63 5B
Point DE to destination filespec buffer at 5B63H.
548D
GOSUB to ROM at 001BH to create/open destination file.
5490
If Z FLAG is set (success), [LOOP] back to verify source file again.
5492
JUMP to DOS error handler with destination file error.
5495H - Process Current Directory Entry
This routine checks the current directory entry. If the entry is empty (first byte = 00H), it advances to the next entry. If the entry is valid, it checks file attributes and prepares for conversion. Returns CARRY set when all entries processed.
5495
PUSH BC C5
Save Register Pair BC to the stack.
5496
PUSH DE D5
Save Register Pair DE to the stack.
5497
LD HL,(5B02H) 2A 02 5B
[LOOP START] Fetch current directory pointer from 5B02H.
549A
LD A,(HL) 7E
Fetch first byte of directory entry (file status byte).
549B
OR A B7
Test if entry is empty (00H = unused entry).
549C
If NZ FLAG (entry in use), JUMP to 54ADH to process it.
549E
GOSUB to 54C5H to advance to next directory entry.
54A1
LD A,(5B04H) 3A 04 5B
Fetch remaining entry count from 5B04H.
54A4
OR A B7
Test if any entries remain.
54A5
If Z FLAG (no more entries), JUMP to 54AAH to set done flag.
54A7
If P FLAG (count positive), [LOOP] to check next entry.
54AA
SCF 37
Set CARRY flag to indicate all entries processed.
54AB
JUMP to 54C2H to return.
Entry is in use - check if it's a valid file we can convert.
54AD
LD A,(5B05H) 3A 05 5B
Fetch current sector/granule position from 5B05H.
54B0
LD B,A 47
Copy to Register B.
54B1
LD A,(5AFFH) 3A FF 5A
Fetch source drive number from 5AFFH.
54B4
LD C,A 4F
Copy to Register C.
54B5
GOSUB to 576BH to read the file's first data sector.
54B8
If NZ FLAG (read error), JUMP to DOS error handler.
54BB
LD A,(HL) 7E
Fetch file attribute byte.
54BC
XOR 10H EE 10
Toggle bit 4 (system file flag).
54BE
AND D8HAND 11011000 E6 D8
Mask to check protected/invisible/system bits.
54C0
If NZ FLAG (file has protection), skip to next entry.
54C2
POP DE D1
Restore DE from the stack.
54C3
POP BC C1
Restore BC from the stack.
54C4
RET C9
RETurn to caller.
54C5H - Advance to Next Directory Entry
This routine advances the directory pointer by 32 bytes (20H) to point to the next entry, updates the sector position counter, and decrements the entry counter. Model I directory entries are 32 bytes each, 8 entries per sector.
54C5
LD HL,(5B02H) 2A 02 5B
Fetch current directory pointer.
54C8
LD A,20H 3E 20
Load A with 20H (32 decimal) - size of one directory entry.
54CA
ADD A,L 85
ADD 32 to low byte of pointer.
54CB
LD L,A 6F
Store result back in L.
54CC
If no carry (no page boundary crossed), JUMP to 54CFH.
54CE
INC L 2C
Handle carry into high byte (INC L is unusual - may be INC H bug).
54CF
LD (5B02H),HL 22 02 5B
Store updated directory pointer.
54D2
LD A,(5B05H) 3A 05 5B
Fetch current sector position.
54D5
ADD 08H C6 08
ADD 8 (entries per sector offset increment).
54D7
AND 3FHAND 00111111 E6 3F
Mask to 6 bits (wrap at 64 entries).
54D9
CP 08H FE 08
Compare against 8.
54DB
If NC FLAG (A >= 8), JUMP to 54DEH.
54DD
INC A 3C
INCrement A to advance to next sector.
54DE
LD (5B05H),A 32 05 5B
Store updated sector position.
54E1
LD A,(5B04H) 3A 04 5B
Fetch entry counter.
54E4
DEC A 3D
DECrement entry counter.
54E5
LD (5B04H),A 32 04 5B
Store updated counter.
54E8
RET C9
RETurn to caller.
54E9H - Convert Single File
This is the main file conversion routine. It checks file type, extracts the filename, prompts the user if needed, opens source and destination files, and performs the actual data transfer.
54E9
GOSUB to 536EH to check file transfer address.
54EC
If CARRY (protected file), JUMP to 5592H to display "NOT Converted".
54EF
LD (5556H),HL 22 56 55
Store directory entry pointer at 5556H (self-modifying).
54F2
PUSH AF F5
Save AF (file type flags).
54F3
GOSUB to 52B0H to extract filename from directory entry.
54F6
GOSUB to 52EAH to copy filename to source and dest buffers.
54FA
If Z FLAG (normal file), JUMP to 550BH to display and continue.
54FC
[LOOP START] GOSUB to 540DH to prompt for password.
54FF
If CARRY (password accepted or skipped), JUMP to 550EH.
5501
GOSUB to 5442H to verify password.
5504
If CARRY (password wrong), [LOOP] back to re-prompt.
5506
GOSUB to 5306H to build full filespec with extension.
5509
JUMP to 550EH to continue.
550B
GOSUB to 53BDH to display filename with prompt.
550E
GOSUB to 533DH to append drive numbers to filespecs.
5511
LD HL,5B95H 21 95 5B
Point HL to source DCB buffer at 5B95H.
5514
LD DE,5B31H 11 31 5B
Point DE to source filespec at 5B31H.
5517
LD B,00H 06 00
Load B with 00H (open mode = read).
5519
GOSUB to 57AEH to open source file.
551C
If NZ FLAG (open error), JUMP to DOS error handler.
551F
LD A,(5B3AH) 3A 3A 5B
Fetch file attribute from DCB.
5522
LD (552CH),A 32 2C 55
Store attribute at 552CH (self-modifying code).
5525
LD HL,5C95H 21 95 5C
Point HL to destination DCB buffer at 5C95H.
5528
LD DE,5B63H 11 63 5B
Point DE to destination filespec at 5B63H.
552B
LD B,00H 06 00
Load B with 00H (placeholder - modified by 5522).
552D
GOSUB to DOS $INIT at 4420H to create destination file.
5530
If NZ FLAG (create error), JUMP to DOS error handler.
5533
If CARRY (new file created), JUMP to 553AH to proceed.
5535
GOSUB to 53EDH to ask "Existing File. Use it (Y/N/Q)?".
5538
If Z FLAG (user said N), JUMP to 559EH to skip file.
553A
GOSUB to 5478H to open both files.
553D
LD A,0DH 3E 0D
Load A with 0DH (carriage return).
553F
GOSUB to ROM to output carriage return.
5542
GOSUB to 54C5H to advance directory pointer.
5545
LD A,(5B01H) 3A 01 5B
Fetch skip flag from 5B01H.
5548
OR A B7
Test if skip flag is set.
5549
If NZ FLAG (skip requested), JUMP to 5555H.
554B
LD DE,5B63H 11 63 5B
Point DE to destination filespec.
554E
GOSUB to DOS $CLOSE at 4428H to close destination file.
5551
If NZ FLAG (close error), JUMP to DOS error handler.
5554
RET C9
RETurn - file converted successfully.
5555H - Handle File with Transfer Address
This routine handles program files that have a transfer (entry) address. It updates the destination file's directory entry with the correct load and transfer addresses for Model III format.
5555
LD HL,0000H 21 00 00
Load HL with 0000H (placeholder - modified at runtime).
5558
LD A,(HL) 7E
Fetch byte from directory entry.
5559
PUSH AF F5
Save the byte.
555A
LD DE,(5B07H) ED 5B 07 5B
Fetch file size/load address from 5B07H.
555E
LD HL,4296H 21 96 42
Load HL with 4296H (DOS READY address).
5561
PUSH HL E5
Save 4296H.
5562
OR A B7
Clear CARRY for subtraction.
5563
SBC HL,DE ED 52
Compare 4296H against load address.
5566
If NZ FLAG (not DOS READY), JUMP to 556BH.
5568
LD DE,5CEFH 11 EF 5C
Point DE to destination DCB transfer address field.
556C
LD A,(5B6AH) 3A 6A 5B
Fetch high byte of record count.
556F
LD B,A 47
Copy to Register B.
5570
LD A,(5B69H) 3A 69 5B
Fetch low byte of record count.
5573
LD C,A 4F
Copy to Register C. BC = record count.
5574
LD (5587H),BC ED 43 87 55
Store record count at 5587H (self-modifying).
5578
GOSUB to DOS routine at 4AD8H.
557B
EX DE,HL EB
Exchange DE and HL.
557C
LD HL,0010H 21 10 00
Load HL with offset 10H (load address offset).
557F
ADD HL,DE 19
ADD to DCB base to point to load address field.
5580
POP BC C1
Restore BC (was DE - transfer address).
5581
LD (HL),C 71
Store low byte of transfer address.
5582
INC HL 23
INCrement to high byte.
5583
LD (HL),B 70
Store high byte of transfer address.
5584
POP AF F1
Restore original byte.
5585
LD (DE),A 12
Store it back.
5586
LD BC,0000H 01 00 00
Load BC with 0000H (placeholder - modified by 5574).
5589
GOSUB to DOS routine at 4A7BH to write directory.
558C
If NZ FLAG (write error), JUMP to DOS error handler.
558F
JUMP to 554BH to close file.
5592H - Display "NOT Converted" Message
This routine displays the filename followed by "NOT Converted (Protected File)" for files that cannot be converted due to protection attributes.
5592
GOSUB to 52B0H to extract filename.
5595
GOSUB to 53BDH to display filename.
5598
Point HL to message: "NOT Converted (Protected File)"
559B
GOSUB to ROM to display the message.
559E
GOSUB to 54C5H to advance to next directory entry.
55A1
RET C9
RETurn to caller.
55ABH - Drive Select Storage and Track Table
This area contains drive select value storage and a track number lookup table used for disk I/O operations.
55AB
NOP 00
Drive select value storage (modified at runtime).
55AE
DEFB 11H,11H,11H 11 11 11
Track number table for drives 0-2 (track 17 = directory track).
55B8H - Output Drive Select
This routine outputs the current drive select value to the FDC drive select port (F4H). It masks off the motor-on bit to get the drive select pattern.
55B8
LD A,(55ABH) 3A AB 55
Fetch drive select value from storage.
55BB
AND 7FHAND 01111111 E6 7F
Mask off bit 7 (motor on bit).
55BD
OUT (F4H),A D3 F4
Output to FDC drive select port F4H.
55C0
RET C9
RETurn to caller.
55C1H - Seek Track and Read Sector
This routine seeks to the specified track and reads a sector. Entry: C = drive number, D = track number. It handles the FDC command sequencing for Model I format disk access on a Model III.
55C1
DI F3
Disable interrupts for disk operation.
55C2
LD A,C 79
Copy drive number to Register A.
55C3
GOSUB to DOS at 45E9H to get drive select pattern.
55C6
AND 7FHAND 01111111 E6 7F
Mask off motor bit.
55C8
LD (55ABH),A 32 AB 55
Store drive select pattern.
55CB
LD A,D 7A
Copy track number to Register A.
55CC
LD (55FDH),A 32 FD 55
Store track number at 55FDH (self-modifying).
55CF
IN A,(F0H) DB F0
Read FDC status register. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
55D1
AND 80HAND 10000000 E6 80
Mask to check busy bit.
55D3
If Z FLAG (not busy), JUMP to 55E2H.
55D5
GOSUB to output drive select.
55D8
LD A,D0HLD A,11010000 3E D0
Load A with D0H (Force Interrupt command).
55DA
OUT (F0H),A D3 F0
When D0H is sent to the Floppy Disk Controller, it resets the Floppy Disk Controller and puts Floppy Disk Controller in mode 1 (INTRQ; 000 terminate command without interrupt).
55DC
LD BC,D000H 01 00 D0
Load BC with delay count.
55DF
GOSUB to ROM delay routine.
55E2
GOSUB to 5607H to wait for FDC ready.
55E5
LD BC,00F3H 01 F3 00
Load BC with F3H in C (data port), 00H in B.
55E8
GOSUB to output drive select.
55EB
LD D,A 57
Save drive select value in D.
55EC
XOR A AF
Set A to ZERO.
55ED
OUT (E4H),A D3 E4
Output to NMI mask register (disable NMI).
55EF
LD E,02H 1E 02
Load E with 02H (sector 2 for ID read).
55F1
LD HL,55A2H 21 A2 55
Point HL to buffer for ID field.
55F4
LD A,C4H 3E C4
Load A with C4H (Read Address command).
55F6
GOSUB to 5633H to execute FDC command.
55F9
LD A,(55A2H) 3A A2 55
Fetch track number from ID field.
55FC
LD D,00H 16 00
Load D with 00H (placeholder - modified at 55CC).
55FE
OUT (F1H),A D3 F1
Output current track to FDC track register.
5600
LD A,D 7A
Get target track number.
5601
OUT (F3H),A D3 F3
Output target track to FDC data register.
5603
LD A,1CHLD A,00011100 3E 1C
Load A with 1CH (Seek command with verify). When sent to the FLOPPY DISK COMMAND register, 0001 is Seek, 1=Head Load at Beginning, 1=Verify On Destination Track, 00 = 6 ms stepping.
5605
OUT (F0H),A D3 F0
Output Seek command to FDC.
5607H - Wait for FDC Not Busy
This routine waits for the FDC to become not busy by polling the status register bit 0.
5607
GOSUB to 5614H for timing delay.
560A
IN A,(F0H) DB F0
Read FDC status register. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
560C
BIT 0,A CB 47
Test bit 0 (busy flag).
560E
RET Z C8
If Z FLAG (not busy), RETurn.
560F
GOSUB to output drive select (keep motor on).
5612
[LOOP] back to check status again.
5614H - FDC Timing Delay
This routine provides a short timing delay required between FDC operations. It uses PUSH/POP pairs which consume CPU cycles without affecting registers.
5614
GOSUB to 5617H (adds CALL/RET overhead for longer delay).
5617
PUSH AF F5
Push AF (timing delay).
561F
NOP 00
Additional delay.
5620
RET C9
RETurn to caller.
5621H - Read Sector Data
This routine reads a sector of data from the disk using the FDC. It issues the Read Sector command and uses the INI instruction to transfer data from the FDC data port to memory.
5621
LD BC,00F3H 01 F3 00
Load BC: B=00 (256 bytes), C=F3H (FDC data port).
5624
GOSUB to output drive select.
5627
LD D,A 57
Save drive select in D.
5628
DI F3
Disable interrupts for data transfer.
5629
XOR A AF
Set A to ZERO.
562A
OUT (E4H),A D3 E4
Disable NMI.
562C
LD E,02H 1E 02
Load E with sector number 2.
562E
LD HL,0000H 21 00 00
Load HL with buffer address (modified at runtime).
5631
LD A,84HLD A,10000100 3E 84
Load A with 84H (Read Sector command, single density).
5633
OUT (F0H),A D3 F0
Output Read Sector command to FDC.
5635
GOSUB for timing delay.
5638
LD A,D 7A
[LOOP START] Get drive select value.
5639
OUT (F4H),A D3 F4
Output to drive select port.
563B
IN A,(F0H) DB F0
Read FDC status register. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
563D
BIT 1,A CB 4F
Test bit 1 (DRQ - data request).
563F
If Z FLAG (no DRQ), JUMP to 564DH to check if done.
5642
INI ED A2
Input byte from (C) to (HL), increment HL, decrement B.
5644
If NZ FLAG (more bytes), [LOOP] to get next byte.
5647
LD HL,0000H 21 00 00
Reset buffer pointer for next sector.
564A
JUMP to continue reading.
564D
BIT 0,A CB 47
Test bit 0 (busy flag).
564F
If NZ FLAG (still busy), [LOOP] to wait for more data.
5652
RET C9
RETurn - sector read complete.
5653H - Read Sector with Retry
This is the main sector read routine with retry logic. It attempts to read a sector up to 9 times before returning an error. Entry: D = track, E = sector, HL = buffer address. Returns Z flag set on success.
5653
LD (562FH),HL 22 2F 56
Store buffer address at 562FH (self-modifying).
5656
DI F3
Disable interrupts.
5657
GOSUB to 55B2H to select drive.
565A
LD A,D0HLD A,11010000 3E D0
Load A with D0H (Force Interrupt).
565C
OUT (F0H),A D3 F0
Output Force Interrupt to abort any pending command.
565E
GOSUB for timing delay.
5661
LD A,D0HLD A,11010000 3E D0
Load Force Interrupt again.
5663
OUT (F0H),A D3 F0
Output to ensure FDC is reset.
5665
GOSUB for timing delay.
5668
GOSUB to select drive again.
566B
LD B,09H 06 09
Load B with 09H (9 retry attempts).
566D
PUSH BC C5
[RETRY LOOP] Save retry counter.
566E
PUSH DE D5
Save track/sector.
566F
PUSH HL E5
Save buffer address.
5670
GOSUB to 55C1H to seek and read sector.
5673
POP HL E1
Restore buffer address.
5674
POP DE D1
Restore track/sector.
5675
POP BC C1
Restore retry counter.
5676
AND 18HAND 00011000 E6 18
Mask FDC status for error bits (CRC error, record not found).
5678
If NZ FLAG (error), JUMP to 569FH to retry.
567A
LD A,D0HLD A,11010000 3E D0
Load Force Interrupt command.
567C
OUT (F0H),A D3 F0
Output to FDC.
5681
LD A,D0HLD A,11010000 3E D0
Force Interrupt again.
5683
OUT (F0H),A D3 F0
Output to FDC.
5688
GOSUB to output drive select.
568B
LD A,E 7B
Get sector number.
568C
OUT (F2H),A D3 F2
Output to FDC sector register.
5691
PUSH BC C5
Save registers.
5692
PUSH DE D5
Save registers.
5693
PUSH HL E5
Save registers.
5694
GOSUB to 5621H to read sector data.
569A
IN A,(F0H) DB F0
Read FDC status register. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
569C
AND 1FHAND 00011111 E6 1F
Mask to error bits.
569E
RET Z C8
If Z FLAG (no errors), RETurn success.
569F
PUSH AF F5
Save error status.
56A0
LD A,D0HLD A,11010000 3E D0
Load Force Interrupt.
56A2
OUT (F0H),A D3 F0
Reset FDC.
56A4
POP AF F1
Restore error status.
56A5
DECrement retry count; if not zero, [LOOP] to retry.
56A7
LD B,01H 06 01
Load B with error code 01H (default).
56A9
BIT 3,A CB 5F
Test bit 3 (CRC error).
56AB
If NZ FLAG (CRC error), JUMP to return error.
56AD
LD B,04H 06 04
Load B with error code 04H (record not found).
56AF
LD A,B 78
Copy error code to A.
56B0
OR A B7
Set flags (NZ = error).
56B1
RET C9
RETurn with error.
56B2H - Select Drive and Prepare DCB
This routine selects the appropriate drive and prepares for file operations. It checks the DCB flags and either reads data byte-by-byte for Model I format or uses DOS routines for Model III format.
56B2
GOSUB to DOS at 4881H to get DCB pointer in IX.
56B5
BIT 7,(IX+01H) DD CB 01 7E
Test bit 7 of DCB+01H (Model I format flag).
56B9
If Z FLAG (Model III format), JUMP to 56CBH to use DOS.
56BB
LD B,(IX+09H) DD 46 09
Fetch byte count from DCB+09H.
56BE
PUSH HL E5
[LOOP START] Save buffer pointer.
56BF
PUSH BC C5
Save byte counter.
56C0
GOSUB to 56E7H to read one byte from Model I disk.
56C3
POP BC C1
Restore byte counter.
56C4
POP HL E1
Restore buffer pointer.
56C5
RET NZ C0
If NZ FLAG (read error), RETurn with error.
56C6
LD (HL),A 77
Store byte in buffer.
56C7
INC HL 23
INCrement buffer pointer.
56C8
DECrement B; if not zero, [LOOP] to read next byte.
56CA
RET C9
RETurn - all bytes read successfully.
56CBH - Read Using DOS Routines
This routine reads data using standard DOS routines for Model III format disks. It calls DOS to get track/sector information and then reads the sector.
56CB
GOSUB to DOS at 4A2EH to locate file data.
56CE
RET NZ C0
If NZ FLAG (error), RETurn.
56CF
GOSUB to 5709H to compute track/sector from granule.
56D2
RET NZ C0
If NZ FLAG (error), RETurn.
56D3
RES 5,(IX+01H) DD CB 01 AE
Reset bit 5 of DCB+01H (clear sector-loaded flag).
56D7
LD L,(IX+03H) DD 6E 03
Fetch low byte of buffer address from DCB+03H.
56DA
LD H,(IX+04H) DD 66 04
Fetch high byte of buffer address from DCB+04H.
56DD
JUMP to 5653H to read the sector.
56E0H - Open File for Reading (Model I Format)
This routine opens a file for reading from a Model I format disk. It sets the Model I format flag in the DCB and calls the byte-read routine.
56E0
GOSUB to DOS at 4881H to get DCB pointer in IX.
56E3
SET 7,(IX+01H) DD CB 01 FE
Set bit 7 of DCB+01H (Model I format flag).
56E7
BIT 5,(IX+01H) DD CB 01 6E
Test bit 5 of DCB+01H (sector-loaded flag).
56EB
If Z FLAG (sector not loaded), JUMP to 56F1H.
56ED
GOSUB to 56CBH to read using DOS routines.
56F0
RET NZ C0
If NZ FLAG (error), RETurn.
56F1
GOSUB to DOS at 4A2EH to locate data.
56F4
RET NZ C0
If NZ FLAG (error), RETurn.
56F5
GOSUB to DOS at 4872H to get byte pointer.
56F8
XOR A AF
Set A to ZERO (clear error).
56F9
LD A,(DE) 1A
Fetch byte from sector buffer.
56FA
PUSH AF F5
Save the byte.
56FB
INC (IX+05H) DD 34 05
INCrement byte position in DCB+05H.
56FE
If NZ FLAG (not at sector boundary), JUMP to 5707H.
5700
SET 5,(IX+01H) DD CB 01 EE
Set bit 5 of DCB+01H (need new sector flag).
5704
GOSUB to DOS at 4776H to advance to next sector.
5707
POP AF F1
Restore the byte to A.
5708
RET C9
RETurn with byte in A.
5709H - Compute Track/Sector from Granule
This routine converts a granule number to track and sector values for Model I disk format. Model I uses 3 granules per track with 5 sectors per granule.
5709
PUSH BC C5
Save Register Pair BC to the stack.
570A
PUSH DE D5
Save Register Pair DE to the stack.
570B
PUSH HL E5
Save Register Pair HL to the stack.
570C
LD B,(IX+0BH) DD 46 0B
Fetch high byte of logical record from DCB+0BH.
570F
LD C,(IX+0AH) DD 4E 0A
Fetch low byte of logical record from DCB+0AH. BC = record number.
5712
PUSH IX DD E5
Push IX.
5714
POP HL E1
Pop to HL (HL = DCB base address).
5715
LD DE,000EH 11 0E 00
Load DE with 0EH (offset to extent table).
5718
ADD HL,DE 19
Point HL to extent table in DCB.
5719
LD A,(HL) 7E
[LOOP START] Fetch extent granule number.
571A
CP FFH FE FF
Compare against FFH (end of extent table).
571C
If Z FLAG (end of extents), JUMP to 5738H - record not found.
571E
INC HL 23
Point to extent sector count.
571F
LD A,(HL) 7E
Fetch extent sector count.
5720
AND 1FHAND 00011111 E6 1F
Mask to 5 bits (sector count within granule).
5722
INC A 3C
INCrement (sectors are 0-based).
5723
PUSH HL E5
Save extent pointer.
5724
PUSH BC C5
Save record number.
5725
GOSUB to 5764H to multiply A by 5 (sectors per granule).
5728
LD E,A 5F
Copy result to E.
5729
XOR A AF
Set A to ZERO.
572A
LD D,A 57
Clear D. DE = sectors in this extent.
572B
POP HL E1
Restore record number to HL (was BC).
572C
PUSH HL E5
Save record number again.
572D
SBC HL,DE ED 52
Subtract extent size from record number.
572F
If CARRY (record is in this extent), JUMP to 573FH.
5731
POP BC C1
Restore record number to BC.
5732
PUSH HL E5
Push remaining record count.
5733
POP BC C1
Pop to BC (BC = remaining records).
5734
POP HL E1
Restore extent pointer.
5735
INC HL 23
Advance to next extent entry.
5736
[LOOP] back to check next extent.
5738
POP HL E1
Clean up stack.
5739
POP DE D1
Clean up stack.
573A
POP BC C1
Clean up stack.
573B
LD A,1DH 3E 1D
Load A with 1DH (error code: record not found).
573D
OR A B7
Set flags (NZ = error).
573E
RET C9
RETurn with error.
Record found in current extent - compute track/sector.
573F
POP DE D1
Discard saved record count.
5740
POP HL E1
Restore extent pointer.
5741
LD A,(HL) 7E
Fetch extent info byte.
5742
AND E0HAND 11100000 E6 E0
Mask to upper 3 bits (granule within track).
5746
RLCA 07
Rotate left (now 0-7 in lower bits).
5747
PUSH HL E5
Save extent pointer.
5748
GOSUB to 5764H to multiply by 5.
574C
LD H,00H 26 00
Clear H.
574E
ADD HL,DE 19
ADD sector offset within extent. HL = absolute sector.
574F
LD A,0AH 3E 0A
Load A with 0AH (10 = sectors per track on Model I).
5751
GOSUB to DOS at 4451H to divide HL by A. Result: sector in A.
5754
LD C,A 4F
Copy sector to C.
5755
POP DE D1
Restore extent pointer to DE.
5756
DEC DE 1B
Back up to granule byte.
5757
LD A,(DE) 1A
Fetch granule number.
5758
ADD A,L 85
ADD track offset.
5759
LD D,A 57
Store track in D.
575A
LD E,C 59
Store sector in E.
575E
LD A,(IX+06H) DD 7E 06
Fetch drive number from DCB+06H.
5761
LD C,A 4F
Copy drive to C.
5762
XOR A AF
Set A to ZERO (no error).
5763
RET C9
RETurn with D=track, E=sector, C=drive.
5764H - Multiply A by 5
This routine multiplies Register A by 5. Used to convert granule numbers to sector counts (5 sectors per granule on Model I).
5764
PUSH BC C5
Save Register Pair BC.
5765
LD B,A 47
Copy A to B (save original value).
5768
ADD A,B 80
A = A * 4 + original = A * 5.
576A
RET C9
RETurn with A = original * 5.
576BH - Read File Data Sector
This routine reads a data sector from the file. Entry: B = sector position, C = drive number. It computes the track/sector from the directory information and reads the sector.
576B
PUSH BC C5
Save BC (sector position and drive).
576D
GOSUB to 5792H to compute track/sector.
5770
If NZ FLAG (error), JUMP to 577BH.
5773
LD L,00H 2E 00
Set L to 00H (sector 0 of computed track).
5775
GOSUB to 5653H to read the sector.
5779
If Z FLAG (success), JUMP to 577DH.
577B
LD A,11H 3E 11
Load A with 11H (error code: read error).
5780H - Read GAT (Granule Allocation Table)
This routine reads the Granule Allocation Table from track 17, sector 0 (the first directory sector on Model I disks) into the buffer at 5F00H.
5780
PUSH DE D5
Save Register Pair DE.
5781
PUSH BC C5
Save Register Pair BC.
5782
LD D,11H 16 11
Load D with 11H (track 17 - directory track).
5784
LD E,00H 1E 00
Load E with 00H (sector 0 - GAT sector).
5786
LD HL,5F00H 21 00 5F
Point HL to GAT buffer at 5F00H.
5789
GOSUB to 5653H to read the sector.
578E
RET Z C8
If Z FLAG (success), RETurn.
578F
LD A,14H 3E 14
Load A with 14H (error code: GAT read error).
5791
RET C9
RETurn with error.
5792H - Compute Track/Sector from Position
This routine computes the track and sector numbers from the current position. It uses the directory pointer to determine which sector to read.
5792
LD D,11H 16 11
Load D with 11H (track 17 - directory track).
5794
LD A,B 78
Copy sector position to A.
5795
AND 07HAND 00000111 E6 07
Mask to 3 bits (sector within group).
5797
ADD 02H C6 02
ADD 2 (directory starts at sector 2).
5799
LD E,A 5F
Store sector number in E.
579A
LD H,5FH 26 5F
Set H to 5FH (high byte of buffer address).
579C
LD A,(5B02H) 3A 02 5B
Fetch directory pointer low byte.
579F
AND F0HAND 11110000 E6 F0
Mask to high nibble (entry within sector).
57A1
LD L,A 6F
Store as low byte of buffer offset.
57A2
XOR A AF
Set A to ZERO (no error).
57A3
RET C9
RETurn with D=track, E=sector, HL=buffer.
57A4H - Get Track from Table
This routine looks up the track number from the track table at 55AEH. Entry: C = drive number. Returns: D = track number.
57A4
PUSH BC C5
Save Register Pair BC.
57A5
LD B,00H 06 00
Clear B for 16-bit addition.
57A7
LD HL,55AEH 21 AE 55
Point HL to track table at 55AEH.
57AA
ADD HL,BC 09
ADD drive number as offset.
57AC
LD D,(HL) 56
Fetch track number from table.
57AD
RET C9
RETurn with D = track number.
57AEH - Open File (Model I Directory Search)
This is the main file open routine for reading Model I format files. It searches the directory, parses the filename, and sets up the DCB for reading. Entry: HL = DCB address, DE = filespec, B = open mode.
57AE
GOSUB to DOS at 4885H to initialize DCB.
57B1
LD A,B 78
Copy open mode to A.
57B2
LD (5846H),A 32 46 58
Store open mode at 5846H.
57B5
LD (5857H),HL 22 57 58
Store DCB address at 5857H.
57B8
PUSH IX DD E5
Push IX.
57BA
POP HL E1
Pop to HL (HL = DCB base).
57BB
GOSUB to 58E6H to parse filename into work buffers.
57BE
RET NZ C0
If NZ FLAG (parse error), RETurn.
57BF
LD HL,59F7H 21 F7 59
Point HL to filename buffer at 59F7H.
57C2
GOSUB to 595EH to compute filename hash.
57C5
LD (57EAH),A 32 EA 57
Store hash at 57EAH (self-modifying).
57C8
LD DE,59EFH 11 EF 59
Point DE to extension buffer at 59EFH.
57CB
GOSUB to 597EH to compute password hash.
57CE
LD (5A02H),HL 22 02 5A
Store hash at 5A02H.
57D1
LD (5A04H),HL 22 04 5A
Store hash at 5A04H (duplicate for comparison).
57D4
LD A,(59EEH) 3A EE 59
Fetch drive number from 59EEH.
57D8
INC A 3C
INCrement to check for FFH (no drive specified).
57D9
If NZ (drive specified), JUMP to 57DCH.
57DB
LD C,A 4F
Use drive 0 as default.
57DC
[SEARCH LOOP] GOSUB to 59AAH to check disk format.
57DF
If NZ (wrong format), JUMP to try next drive.
57E1
GOSUB to 59D9H to read directory sector.
57E4
RET NZ C0
If NZ (read error), RETurn.
57E5
LD A,(HL) 7E
[ENTRY LOOP] Fetch first byte of directory entry.
57E6
OR A B7
Test if entry is empty.
57E7
If Z (empty entry), JUMP to try next.
57E9
CP 00H FE 00
Compare against 00H (deleted entry marker).
57EB
If Z (valid entry), JUMP to 5810H to check filename.
57ED
INC L 2C
Advance to next entry (32 bytes apart).
57EE
If NZ (more entries in sector), [LOOP].
57F0
LD A,(59EEH) 3A EE 59
Fetch drive number.
57F4
If NZ (specific drive), JUMP to return error.
57F6
INC C 0C
Try next drive.
57F7
LD A,04H 3E 04
Load A with 04H (max drive number).
57F9
CP C B9
Compare against current drive.
57FA
If NC (more drives), [LOOP] to search next drive.
57FC
LD A,18H 3E 18
Load A with 18H (error code: file not found).
57FE
PUSH AF F5
Save error code.
57FF
LD C,00H 0E 00
Load C with 00H.
5801
GOSUB to 55B2H to deselect drive.
5804
POP AF F1
Restore error code.
5805
RET C9
RETurn with error.
5810H - Check Directory Entry Match
This routine checks if the current directory entry matches the filename being searched for. It compares the 11-byte filename/extension field.
5810
PUSH HL E5
Save directory entry pointer.
5812
LD B,L 45
Copy entry position to B.
5813
GOSUB to 576BH to read the file's data sector.
5816
If Z (read OK), JUMP to 581BH to compare.
581A
RET C9
RETurn with error.
581B
PUSH HL E5
Save buffer pointer.
581D
BIT 7,(HL) CB 7E
Test bit 7 of first byte (deleted flag).
581F
If NZ (deleted), JUMP to 580AH to skip.
5821
LD A,05H 3E 05
Load A with 05H (offset to filename in entry).
5823
ADD A,L 85
ADD to entry base.
5824
LD L,A 6F
Point to filename field.
5825
LD DE,59F7H 11 F7 59
Point DE to search filename at 59F7H.
5828
LD B,0BH 06 0B
Load B with 0BH (11 bytes to compare).
582A
LD A,(DE) 1A
[COMPARE LOOP] Fetch byte from search name.
582B
CP (HL) BE
Compare against directory entry.
582C
If NZ (no match), JUMP to 580AH to try next.
582E
INC HL 23
INCrement entry pointer.
582F
INC DE 13
INCrement search pointer.
5830
DECrement B; if not zero, [LOOP].
Filename matches - set up DCB for file access.
5833
LD A,C 79
Copy drive number to A.
5834
LD (59EEH),A 32 EE 59
Store drive number.
5837
POP HL E1
Restore buffer pointer.
5838
POP AF F1
Clean up stack.
5839
POP AF F1
Clean up stack.
583A
XOR A AF
Set A to ZERO (success).
583B
LD (5849H),A 32 49 58
Clear flag at 5849H.
583E
EX DE,HL EB
Exchange DE and HL.
583F
PUSH IX DD E5
Push IX (DCB pointer).
5842
LD (HL),80H 36 80
Set DCB+00H to 80H (file open flag).
5844
INC HL 23
Point to DCB+01H.
5845
LD A,00H 3E 00
Load A with 00H (placeholder).
5848
LD A,00H 3E 00
Load A with 00H (placeholder).
584C
OR 80HOR 10000000 F6 80
Set bit 7 (Model I format flag).
584E
OR 20H F6 20
Set bit 5 (read mode).
5850
LD (HL),A 77
Store flags in DCB+01H.
5851
INC HL 23
Point to DCB+02H.
5852
LD (HL),00H 36 00
Clear DCB+02H.
5854
INC HL 23
Point to DCB+03H (buffer address).
5855
PUSH DE D5
Save directory entry pointer.
5856
LD DE,0000H 11 00 00
Load DE with 0000H.
5859
LD (HL),E 73
Store low byte of buffer address.
585A
INC HL 23
Point to DCB+04H.
585B
LD (HL),D 72
Store high byte of buffer address.
585C
INC HL 23
Point to DCB+05H.
585D
POP DE D1
Restore directory entry pointer.
585E
LD (HL),00H 36 00
Clear DCB+05H (byte position).
5860
INC HL 23
Point to DCB+06H (drive number).
5861
LD (HL),C 71
Store drive number.
5862
LD A,C 79
Copy drive to A.
5863
LD (58C0H),A 32 C0 58
Store at 58C0H.
5866
INC HL 23
Point to DCB+07H.
5868
INC HL 23
Point to DCB+08H.
5869
LD A,03H 3E 03
Load A with 03H (offset to first granule).
586B
ADD A,E 83
ADD to directory entry base.
586C
LD E,A 5F
Point DE to first granule in entry.
586D
LD A,(DE) 1A
Fetch first granule number.
586E
LD (HL),A 77
Store in DCB+08H.
586F
LD (588FH),A 32 8F 58
Store at 588FH (self-modifying).
5872
INC HL 23
Point to DCB+09H.
5873
INC DE 13
Point to second granule byte.
5874
LD A,(DE) 1A
Fetch second granule byte.
5875
LD (HL),A 77
Store in DCB+09H.
5876
INC HL 23
Point to DCB+0AH.
5877
LD (HL),00H 36 00
Clear DCB+0AH.
5879
INC HL 23
Point to DCB+0BH.
587A
LD (HL),00H 36 00
Clear DCB+0BH.
587C
INC HL 23
Point to DCB+0CH.
Note: The DCB setup continues through 58E5H, followed by filename parsing (58E6H-5943H), character validation (5944H-595DH), hash computation (595EH-596DH), password hash (596EH-59A9H), disk format detection (59AAH-59D8H), directory reading (59D9H-59EDH), and message strings (5A06H-5AFFH).
595EH - Compute Filename Hash
This routine computes a simple hash value from the 11-byte filename. The hash is used for quick comparison during directory searches.
595E
LD B,0BH 06 0B
Load B with 0BH (11 bytes to process).
5960
LD C,00H 0E 00
Clear C (hash accumulator).
5962
LD A,(HL) 7E
[LOOP START] Fetch byte from filename.
5963
INC HL 23
INCrement pointer.
5964
XOR C A9
XOR with accumulator.
5966
LD C,A 4F
Store in accumulator.
5967
DECrement B; if not zero, [LOOP].
5969
LD A,C 79
Copy hash to A.
596A
OR A B7
Test if hash is zero.
596B
RET NZ C0
If NZ, RETurn with hash in A.
596C
INC A 3C
If hash is zero, make it 1.
596D
RET C9
RETurn with hash in A (never zero).
596EH - Compute Password Hash
This routine computes a 16-bit hash from a password string. The hash uses a complex mixing algorithm with rotates and XORs. Entry: DE = password buffer, B = password length. Returns: HL = hash value.
596E
EX DE,HL EB
Exchange DE and HL (HL = password buffer).
596F
LD H,D 62
Copy D to H.
5970
LD A,E 7B
Copy E to A.
5971
ADD A,B 80
ADD password length.
5973
LD A,08H 3E 08
Load A with 08H (max password length).
5975
SUB B 90
SUBtract actual length.
5976
If Z (full length), JUMP to hash routine.
5978
LD B,A 47
Use remaining as pad count.
5979
LD (HL),20H 36 20
[PAD LOOP] Store space character.
597B
INC HL 23
INCrement pointer.
597C
DECrement B; if not zero, [LOOP] to pad.
597E
LD HL,FFFFH 21 FF FF
Initialize hash to FFFFH.
5981
LD B,08H 06 08
Load B with 08H (8 bytes to process).
5983
LD A,E 7B
Copy E to A.
5984
ADD 07H C6 07
ADD 7 to get end of password.
5989
INC D 14
Handle carry into D.
598A
LD A,(DE) 1A
[HASH LOOP] Fetch password byte.
598B
PUSH DE D5
Save pointer.
598C
LD D,A 57
Copy byte to D.
598D
LD E,H 5C
Copy hash high to E.
598E
LD A,L 7D
Copy hash low to A.
598F
AND 07HAND 00000111 E6 07
Mask to 3 bits.
5994
XOR L AD
XOR with hash low.
5996
LD H,00H 26 00
Clear H.
5998
ADD HL,HL 29
Shift left.
5999
ADD HL,HL 29
Shift left.
599A
ADD HL,HL 29
Shift left.
599B
ADD HL,HL 29
Shift left.
599C
XOR H AC
XOR with shifted high.
599D
XOR D AA
XOR with password byte.
599F
LD A,L 7D
Get shifted low.
59A0
ADD HL,HL 29
Shift left again.
59A1
XOR H AC
XOR with result.
59A2
XOR E AB
XOR with saved hash high.
59A4
EX DE,HL EB
Exchange - HL = new hash.
59A5
POP DE D1
Restore pointer.
59A6
DEC DE 1B
Point to previous byte.
59A7
DECrement B; if not zero, [LOOP].
59A9
RET C9
RETurn with hash in HL.
59AAH - Detect Disk Format (Model I Single Density)
This routine detects if the disk is in Model I single-density format by checking for the index pulse pattern. It waits for specific timing patterns that indicate the disk rotation speed and format. Returns Z flag set if Model I format detected.
59AA
LD A,D0HLD A,11010000 3E D0
Load A with D0H (Force Interrupt command).
59AC
OUT (F0H),A D3 F0
Output Force Interrupt to FDC command register.
59AE
GOSUB to 55B2H to select the drive.
59B1
PUSH BC C5
Save Register Pair BC to the stack.
59B2
LD BC,3155H 01 55 31
Load BC with 3155H (timeout counter for index pulse detection).
59B5
[WAIT LOOP 1] GOSUB to 59CAH to check index pulse status.
59B8
If NZ FLAG (index pulse high), [LOOP] to wait for low.
59BA
[WAIT LOOP 2] GOSUB to check index pulse again.
59BD
If Z FLAG (index pulse low), [LOOP] to wait for high.
59BF
[WAIT LOOP 3] GOSUB to check index pulse.
59C2
If NZ FLAG (index high), [LOOP] to wait for low.
59C4
POP BC C1
Restore BC from the stack.
59C5
RLCA 07
Rotate A left through carry.
59C6
AND 80HAND 10000000 E6 80
Mask to keep only bit 7.
59C8
ADD A,A 87
Double A (shifts bit 7 into carry, sets Z if A was 00H or 80H).
59C9
RET C9
RETurn. Z flag set = Model I format detected.
59CAH - Check Index Pulse with Timeout
This routine checks the FDC status register for the index pulse (DRQ bit). It decrements the timeout counter and returns with the pulse status. Returns Z flag reflecting bit 1 of status.
59CA
DEC BC 0B
DECrement timeout counter BC.
59CB
LD A,B 78
Copy B to A.
59CC
OR C B1
OR with C to check if BC is zero.
59CD
If Z FLAG (timeout), JUMP to 59D4H to handle timeout.
59CF
IN A,(F0H) DB F0
Read FDC status register. Input Results:
- Bit 0: Busy
- Bit 1: Index/DRQ
- Bit 2: Track 0/Data Lost
- Bit 3: CRC error
- Bit 4: Seek error/Record not found
- Bit 5: If Reading, Record Type, if Writing, Write Fault/Head loaded
- Bit 6: Write Protect
- Bit 7: Not ready
59D1
BIT 1,A CB 4F
Test bit 1 (DRQ/index pulse status).
59D3
RET C9
RETurn with Z flag reflecting bit 1 status.
59D4
POP BC C1
Discard return address (timeout exit).
59D5
POP BC C1
Restore original BC from caller's stack.
59D6
OR 01HOR 00000001 F6 01
Set bit 0 to force NZ flag (timeout error).
59D8
RET C9
RETurn with NZ flag set (timeout occurred).
59D9H - Read Directory Sector
This routine reads a directory sector from the Model I disk into the buffer at 5E00H. It uses the track table to determine which track to read from. Returns Z flag set on success, with HL pointing to the buffer.
59D9
PUSH BC C5
Save Register Pair BC to the stack.
59DA
PUSH DE D5
Save Register Pair DE to the stack.
59DB
GOSUB to 57A4H to get track number from table into D.
59DE
LD E,01H 1E 01
Load E with 01H (sector 1 - first directory sector after GAT).
59E0
LD HL,5E00H 21 00 5E
Point HL to directory sector buffer at 5E00H.
59E3
PUSH HL E5
Save buffer address for return.
59E4
GOSUB to 5653H to read the sector with retry.
59E7
POP HL E1
Restore buffer address to HL.
59E8
POP DE D1
Restore DE from the stack.
59E9
POP BC C1
Restore BC from the stack.
59EA
RET Z C8
If Z FLAG (read successful), RETurn with HL = buffer.
59EB
LD A,16H 3E 16
Load A with 16H (error code: directory read error).
59ED
RET C9
RETurn with error code in A, NZ flag set.
59EEH - Drive Number Storage
Single byte storage for the current drive number being accessed.
59EE
DEFB 00H 00
Current drive number (0-3, or FFH for unspecified).
5A06H - Message Strings Data Area
This area contains all the text messages displayed by the CONVERT utility. Each string is terminated with 0DH (CR) or 03H (ETX - End of Text). The disassembler incorrectly shows these as instructions, but they are ASCII text data.
5A06
DEFM "Model 1 to Model 3 Conversion Utility. Ver 1.3"
Program title and version string (47 bytes).
5A35
DEFB 0AH,0DH 0A 0D
Line feed and carriage return.
5A37
DEFM "Source Drive? "
Prompt for the Model I source drive (14 bytes).
5A45
DEFB 03H 03
ETX terminator.
5A46
DEFM "Destination Drive? "
Prompt for the Model III destination drive (19 bytes).
5A59
DEFB 03H 03
ETX terminator.
5A5A
DEFB 0AH,0AH 0A 0A
Two line feeds for spacing.
5A5C
DEFM "Conversion Complete"
Success message when all files processed (19 bytes).
5A6F
DEFB 0DH 0D
Carriage return terminator.
5A70
DEFM "Existing File. Use it (Y/N/Q)? "
Prompt when destination file already exists (31 bytes).
5A91
DEFB 03H 03
ETX terminator.
5A92
DEFM "Enter Password for "
Password prompt prefix (19 bytes).
5AA5
DEFB 03H 03
ETX terminator.
5AA6
DEFM "Invalid Reply"
Error message for invalid user input (13 bytes).
5AB3
DEFB 0DH 0D
Carriage return terminator.
5AB4
DEFM "Single Drive Convert is NOT allowed"
Error when source and destination drives are the same (35 bytes).
5AD7
DEFB 0DH 0D
Carriage return terminator.
5AD8
DEFM "NOT Converted (Protected File)"
Message for files that cannot be converted due to protection (30 bytes).
5AF6
DEFB 0DH 0D
Carriage return terminator.
5AF7
DEFM " ? "
Prompt suffix for password entry (4 bytes).
5AFB
DEFB 03H 03
ETX terminator.
5AFC
DEFM " "
Single space (1 byte).
5AFD
DEFB 0FH 0F
Control character.
5AFE
DEFB 03H 03
ETX terminator.