![]() |
Routines |
| Prev: 5CD0 | Up: Map | Next: 5D96 |
|
Used by the routine at Load_Stage_Two.
Custom edge sampler used by the bootstrap. It still calls the ROM edge routines LD-EDGE-1 / LD-EDGE-2, but with Micromega timing thresholds rather than the standard ROM pilot. On success it returns through Restore_Border; tape errors from Load_Stage_Two jump to Load_Tape_Block_PrintError, which prints "TAPE LOADING ERROR" via Restore_Border_PrintLoop.
|
||||||||||||||||
|
Preserve the flag byte and install the post-load return at Restore_Border.
|
||||||||||||||||
| Load_Tape_Block | 5CFC | INC D | Preserve the flag byte in AF'. | |||||||||||||
| 5CFD | EX AF,AF' | |||||||||||||||
| 5CFE | DEC D | |||||||||||||||
| 5CFF | DI | Disable interrupts. | ||||||||||||||
| 5D00 | LD A,$0F | Set the border to white via port FE. | ||||||||||||||
| 5D02 | OUT ($FE),A | |||||||||||||||
| 5D04 | LD HL,$5DAC | Point HL at Restore_Border and stash it as the return address. | ||||||||||||||
| 5D07 | PUSH HL | |||||||||||||||
|
Seed the EAR/border state in C from the current EAR bit.
|
||||||||||||||||
| 5D08 | IN A,($FE) | Read the EAR port. | ||||||||||||||
| 5D0A | RRA | Rotate the EAR bit into bit 0 of A. | ||||||||||||||
| 5D0B | AND %00100000 | Keep only the EAR bit. | ||||||||||||||
| 5D0D | OR %00000010 | Set the blue border bit. | ||||||||||||||
| 5D0F | LD C,A | Copy the EAR/border state into C and set the zero flag. | ||||||||||||||
| 5D10 | CP A | |||||||||||||||
|
Wait for the pilot tone.
|
||||||||||||||||
| Load_Tape_Block_WaitPilot | 5D11 | RET NZ | Return if the zero flag is reset (BREAK was pressed). | |||||||||||||
|
Listen for a pair of edges that look like the pilot.
|
||||||||||||||||
| Load_Tape_Block_PilotPair | 5D12 | CALL $05E7 | Jump back to Load_Tape_Block_WaitPilot if LD-EDGE-2 resets the carry flag. | |||||||||||||
| 5D15 | JR NC,Load_Tape_Block_WaitPilot | |||||||||||||||
| 5D17 | LD HL,$0415 | Set the leader timing budget in HL to 0415. | ||||||||||||||
|
Exhaust the leader timing budget while edges continue to arrive.
|
||||||||||||||||
| Load_Tape_Block_LeaderDelay | 5D1A | DJNZ Load_Tape_Block_LeaderDelay | Decrease B and loop until it is zero. | |||||||||||||
| 5D1C | DEC HL | Decrease HL. | ||||||||||||||
| 5D1D | LD A,H | Jump back to Load_Tape_Block_LeaderDelay if HL is non-zero. | ||||||||||||||
| 5D1E | OR L | |||||||||||||||
| 5D1F | JR NZ,Load_Tape_Block_LeaderDelay | |||||||||||||||
| 5D21 | CALL $05E3 | Jump back to Load_Tape_Block_WaitPilot if LD-EDGE-1 resets the carry flag. | ||||||||||||||
| 5D24 | JR NC,Load_Tape_Block_WaitPilot | |||||||||||||||
|
Confirm a long enough run of short pilot pulses.
|
||||||||||||||||
| Load_Tape_Block_PilotPulse | 5D26 | LD B,$9C | Set the pulse timing constant in B to 9C. | |||||||||||||
| 5D28 | CALL $05E3 | Jump back to Load_Tape_Block_WaitPilot if LD-EDGE-1 resets the carry flag. | ||||||||||||||
| 5D2B | JR NC,Load_Tape_Block_WaitPilot | |||||||||||||||
| 5D2D | LD A,$A6 | Jump back to Load_Tape_Block_PilotPair if B is at least A6. | ||||||||||||||
| 5D2F | CP B | |||||||||||||||
| 5D30 | JR NC,Load_Tape_Block_PilotPair | |||||||||||||||
| 5D32 | INC H | Increase H by one and jump back to Load_Tape_Block_PilotPulse until it wraps. | ||||||||||||||
| 5D33 | JR NZ,Load_Tape_Block_PilotPulse | |||||||||||||||
|
Wait for the sync pulse that ends the pilot.
|
||||||||||||||||
| Load_Tape_Block_Sync | 5D35 | LD B,$C9 | Set the sync timing constant in B to C9. | |||||||||||||
| 5D37 | CALL $05E7 | Jump back to Load_Tape_Block_WaitPilot if LD-EDGE-2 resets the carry flag. | ||||||||||||||
| 5D3A | JR NC,Load_Tape_Block_WaitPilot | |||||||||||||||
| 5D3C | LD A,B | Jump back to Load_Tape_Block_Sync if B is at least D4. | ||||||||||||||
| 5D3D | CP $D4 | |||||||||||||||
| 5D3F | JR NC,Load_Tape_Block_Sync | |||||||||||||||
| 5D41 | CALL $05E7 | Call LD-EDGE-2 and return if the carry flag is reset. | ||||||||||||||
| 5D44 | RET NC | |||||||||||||||
|
Flip the border colour and start the byte-load loop.
|
||||||||||||||||
| 5D45 | LD A,C | Fetch the EAR/border state from C. | ||||||||||||||
| 5D46 | XOR %00000011 | Toggle the border colour bits. | ||||||||||||||
| 5D48 | LD C,A | Store the updated EAR/border state in C. | ||||||||||||||
| 5D49 | LD H,$00 | Clear the parity byte in H. | ||||||||||||||
| 5D4B | LD B,$B0 | Set B to B0. | ||||||||||||||
| 5D4D | JR Load_Tape_Block_SampleByte | Jump to Load_Tape_Block_SampleByte. | ||||||||||||||
|
Handle each loaded byte under the preserved flag in AF'.
|
||||||||||||||||
| Load_Tape_Block_NextByte | 5D4F | EX AF,AF' | Switch to AF'. | |||||||||||||
| 5D50 | JR NZ,Load_Tape_Block_FlagByte | Jump to Load_Tape_Block_FlagByte if the flag byte is not zero. | ||||||||||||||
| 5D52 | JR NC,Load_Tape_Block_VerifyByte | Jump to Load_Tape_Block_VerifyByte if the carry flag is reset (verify mode). | ||||||||||||||
| 5D54 | LD (IX+$00),L | Store the assembled byte in *IX+00. | ||||||||||||||
| 5D57 | JR Load_Tape_Block_Advance | Jump to Load_Tape_Block_Advance. | ||||||||||||||
|
Compare the assembled byte against the expected flag byte.
|
||||||||||||||||
| Load_Tape_Block_FlagByte | 5D59 | RL C | Rotate the stored flag bits in C. | |||||||||||||
| 5D5B | XOR L | Return if the assembled byte does not match. | ||||||||||||||
| 5D5C | RET NZ | |||||||||||||||
| 5D5D | LD A,C | Restore C from the rotated value. | ||||||||||||||
| 5D5E | RRA | |||||||||||||||
| 5D5F | LD C,A | |||||||||||||||
| 5D60 | INC DE | Advance DE past the flag byte. | ||||||||||||||
| 5D61 | JR Load_Tape_Block_Continue | Jump to Load_Tape_Block_Continue. | ||||||||||||||
|
Verify the assembled byte against *IX.
|
||||||||||||||||
| Load_Tape_Block_VerifyByte | 5D63 | LD A,(IX+$00) | Return if *IX+00 does not match the assembled byte. | |||||||||||||
| 5D66 | XOR L | |||||||||||||||
| 5D67 | RET NZ | |||||||||||||||
|
Advance the destination and continue for the remaining length.
|
||||||||||||||||
| Load_Tape_Block_Advance | 5D68 | INC IX | Advance IX. | |||||||||||||
|
Prepare the timing constant for the next byte.
|
||||||||||||||||
| Load_Tape_Block_Continue | 5D6A | DEC DE | Decrease the remaining length. | |||||||||||||
| 5D6B | EX AF,AF' | Switch back to AF'. | ||||||||||||||
| 5D6C | LD B,$B2 | Set B to B2. | ||||||||||||||
|
Sample eight edges to assemble the next byte into L.
|
||||||||||||||||
| Load_Tape_Block_SampleByte | 5D6E | LD L,$01 | Seed the assembled byte in L with 01. | |||||||||||||
|
Sample one bit into L.
|
||||||||||||||||
| Load_Tape_Block_SampleBit | 5D70 | CALL $05E3 | Call LD-EDGE-1 and return if the carry flag is reset. | |||||||||||||
| 5D73 | RET NC | |||||||||||||||
| 5D74 | LD A,$CB | Compare B with the bit-threshold CB. | ||||||||||||||
| 5D76 | CP B | |||||||||||||||
| 5D77 | RL L | Rotate that comparison result into L. | ||||||||||||||
| 5D79 | LD B,$B0 | Set B to B0. | ||||||||||||||
| 5D7B | JP NC,Load_Tape_Block_SampleBit | Jump back to Load_Tape_Block_SampleBit until eight bits are in. | ||||||||||||||
| 5D7E | LD A,H | Mix the assembled byte into the running parity in H. | ||||||||||||||
| 5D7F | XOR L | |||||||||||||||
| 5D80 | LD H,A | |||||||||||||||
| 5D81 | LD A,D | Jump back to Load_Tape_Block_NextByte until the remaining length in DE is zero. | ||||||||||||||
| 5D82 | OR E | |||||||||||||||
| 5D83 | JR NZ,Load_Tape_Block_NextByte | |||||||||||||||
| 5D85 | LD A,H | Compare the parity byte with 01. | ||||||||||||||
| 5D86 | CP $01 | |||||||||||||||
| 5D88 | RET | Return. | ||||||||||||||
|
This entry point is used by the routine at Load_Stage_Two.
Print "TAPE LOADING ERROR" after a failed load from Load_Stage_Two.
|
||||||||||||||||
| Load_Tape_Block_PrintError | 5D89 | LD A,$01 | Open stream 01 via CHAN_OPEN. | |||||||||||||
| 5D8B | CALL $1601 | |||||||||||||||
| 5D8E | LD B,$19 | Point DE at Messaging_TapeLoadingError with length 19. | ||||||||||||||
| 5D90 | LD DE,$5DEA | |||||||||||||||
| 5D93 | JP Restore_Border_PrintLoop | Jump to Restore_Border_PrintLoop. | ||||||||||||||
| Prev: 5CD0 | Up: Map | Next: 5D96 |