54D3TSRC
LD HL,5392HLD HL,TAPE
Let Register Pair HL equal 5392H, which points to the message "TAPE TO DISK".
Original Source Code Comment: HL => TAPE
54D6
GOSUB to 021BH.
NOTE: 021BH is the Model III ROM routine to display the character at (HL) until a 03H is found.
Original Source Code Comment: DISPLAY IT
54D9
Prompt the user to insert a cassette and wait for a key via a GOSUB to 5348H.
Original Source Code Comment: TELL USER TO READY CASSETTE
54DC
GOSUB to 0243H which is the Model III ROM Routine to start the tape and read the header.
Original Source Code Comment: READ IN THE SYNC
54DF
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: READ IN THE 'SYSTEM' BYTE
54E2
CP 55H
Compare the byte which was just read from cassette (held in Register A) against 55H, which is the SYSTEM TAPE identifier. Results: If Register A equals 55H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: IS IT CORRECT
54E4
If the byte read was not a SYSTEM TAPE identifier, then we have a problem; JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: NO, NOT A SYSTEM TAPE
54E7
LD HL,(4020H)LD HL,(CURSOR)
Fetch the value held in memory location 4020H and store it into Register Pair HL.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: GET PRESENT CURSOR POSITION
54EA
LD IY,5BA2HLD IY,SDCB1
Let Special Index Register IY equal 5BA2H which is the SOURCE FCB Buffer.
Original Source Code Comment: PLACE TO STORE THE FILENAME
54EE
LD B,06HLD B,6
Since a maching language file's filename is 6 characters, set Register B equal 06H.
Original Source Code Comment: SET A COUNTER
54F0TSRC1
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: READ A FILE CHAR
54F3
LD (HL),A
Store byte which was just read from cassette (held in Register A) into the screen location pointed to by Register Pair HL.
Original Source Code Comment: PUT IT ON THE SCREEN
54F4
INC HL
INCrement the screen location (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
54F5
CP 21HCP 'SPACE'+1
Compare the value held in Register A against 21H (ASCII: SPACE + 1). If Register A < SPACE + 1, the CARRY FLAG will be set.
Original Source Code Comment: SPACE OR CONTROL CHAR?
54F7
If the byte is a SPACE or lower, then we are at the end of the filename and the C FLAG (Carry) will have been set, JUMP to 54FEH.
Original Source Code Comment: YES, BYPASS IT
54F9
LD (IY+00H),ALD (IY),A
Store the byte read from tape (which is part of the filename) into the filename buffer pointed to by Special Index Register IY+00H.
Original Source Code Comment: PUT IT IN THE DCB
54FC
INC IY
INCrement Special Index Register IY by 1 to point to the next available spot in the filename buffer.
54FETSRC11
LOOP back to 54F0H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: LOOP FOR COUNT
5500
LD (4020H),HLLD (CURSOR),HL
Store the value held in Register Pair HL into memory location 4020H.
NOTE: 4020H is the storage location for the CURSOR POSITION ON SCREEN.
Original Source Code Comment: MAKE IT THE CURRENT CURSOR POSITION
5503
PUSH IY
POP DEPUSH IY
Let Register Pair DE = Special Register Index IY. At this point DE will the 1 byte beyond the filename.
Original Source Code Comment: MOVE DCB POINTER TO DE
5506
LD HL,53B7HLD HL,CMEXT
Let Register Pair HL equal 53B7H to point to the message "/CMD + 03H".
Original Source Code Comment: HL => '/CMD' EXTENSION
5509
LD BC,0005HLD BC,5
We have 5 bytes to move so set Register Pair BC equal 0005H.
Original Source Code Comment: 5 CHARACTERS
550C
LDIR
Add the "/CMD + 03H" to the end of the filename by transfers a byte of data from the memory location pointed to by HL to the memory location pointed to by DE. Then HL and DE are incremented and BC is decremented. If BC is not zero, this operation is repeated. Interrupts can trigger while this instruction is processing.
Original Source Code Comment: COMPLETE THE FILESPEC
550E
LD HL,5E00HLD HL,BUFER2
Let Register Pair HL equal 5E00H for a FILE BUFFER / DATA STORAGE BUFFER.
Original Source Code Comment: PLACE TO STORE DATA
Top of a loop (ending at 5544H) to read the entire file from tape.
5511TSRC2
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET THE 'START' or 'STOP' BYTE
5514
CP 78H
Check to see if the byte is an EXECUTION ADDRESS IDENTIFIER by comparing the value held in Register A against 78H. Results: If Register A equals 78H, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: STOP?
5516
If we are at an EXECUTION ADDRESS IDENTIFIER BYTE, the Z FLAG (Zero) will have been set, so JUMP to 5546H.
Original Source Code Comment: YES, GET TRANSFER ADDRESS
5518
CP 3CH
Check to see if the byte is a CODE BLOCK IDENTIFIER by comparing the value held in Register A against 3CH. Results: If Register A equals 3CH, the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: START BYTE?
551A
If the byte read was NOT a CODE BLOCK IDENTIFIER then loop back to 5511H and keep reading.
Original Source Code Comment: NO, KEEP LOOKING
If we are here, then the byte read from the cassette was a CODE BLOCK identifier.
551C
LD (HL),01HLD (HL),1
Store a CODE BLOCK MARKER (01H) into the FILE BUFFER (pointed to by Register Pair HL).
Original Source Code Comment: SET A LOAD FILE FORMAT
551E
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
Next, process the BLOCK LENGTH.
551F
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET THE BYTE COUNT
5522
LD B,A
Register A should be holding the BLOCK LENGTH BYTE. Copy that into Register B.
Original Source Code Comment: SAVE IT AS A COUNTER
5523
ADD A,02HADD A,2
Adjust the BLOCK LENGTH by 2 to deal with diskette, by setting Register A = Register A + 02H.
Original Source Code Comment: ADD IN THE ADDRESS
5525
LD (HL),A
Store the adjusted BLOCK LENGTH into the FILE BUFFER (pointed to by Register Pair HL).
Original Source Code Comment: STORE IT IN MEMORY
5526
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
Next, process the LSB of the CODE ADDRESS.
5527
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET THE LSB OF THE ADDRESS
552A
LD C,A
Prepare to calculate the file's checksum by copying the contents of Register A (i.e., the LSB of the CODE ADDRESS) into Register C.
Original Source Code Comment: START A CHECKSUM
552B
LD (HL),A
Store the value held in Register A (which is the LSB of the CODE ADDRESS) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: INTO MEMORY
552C
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Next, process the MSB of the CODE ADDRESS.
552D
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET THE MSB OF THE ADDRESS
5530
LD (HL),A
Store the value held in Register A (which is the MSB of the CODE ADDRESS) into the memory location pointed to by Register Pair HL.
Original Source Code Comment: INTO MEMORY
5531
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
5532
ADD A,C
LET Register A = Register A + Register C.
Original Source Code Comment: ADD TO THE CHECKSUM
5533
LD C,A
Copy the contents of Register A (i.e., the checksum which now includes the MSB of the CODE ADDRESS) into Register C.
Original Source Code Comment: SAVE IT
Next, loop to read the block
5534TSRC3
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: READ A DATA BYTE
5537
LD (HL),A
Store the value held in Register A (i.e., a data byte) into the FILE BUFFER at the location pointed to by Register Pair HL.
Original Source Code Comment: INTO MEMORY
5538
INC HL
INCrement the FILE BUFFER POINTER (stored in Register Pair HL) by 1.
Original Source Code Comment: BUMP TO NEXT SLOT
5539
ADD A,C
LET Register A = Register A + Register C.
Original Source Code Comment: ADD TO CHECKSUM
553A
LD C,A
Copy the contents of Register A (i.e., the checksum which now includes the most recently read data byte) into Register C.
Original Source Code Comment: SAVE IT
553B
LOOP back to 5534H, reducing Register B each time, and continue to LOOP until Register B has been reduced to ZERO, in which case, continue with the next instruction.
Original Source Code Comment: LOOP FOR COUNT
The block is now read into the buffer at HL, and Register C now holds the checksum. So next, verify the checksum.
553D
GOSUB to 0235H which is the Model III ROM Routine to read one byte from the cassette drive specified in register A, and returns the byte in register A.
Original Source Code Comment: GET THE CHECKSUM BYTE
5540
CP C
Compare the the checksum as read from the tape (held in Register A) against the checksum as just calculated (held in Register C). Results: If the checksums match, the the Z FLAG is set; otherwise the NZ FLAG is set.
Original Source Code Comment: MATCH OURS?
5541
If the NZ FLAG (Not Zero) has been set, JUMP to 5219H to display an ILLEGAL PARAMETER error and exit via a JUMP to 5223H.
Original Source Code Comment: NO, BAD PARAMETER
5544
JUMP to 5511H.
Original Source Code Comment: GO GET MORE DATA