![]() |
Routines |
| Prev: 23760 | Up: Map | Next: 23958 |
|
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 | 23804 | INC D | Preserve the flag byte in AF'. | |||||||||||||
| 23805 | EX AF,AF' | |||||||||||||||
| 23806 | DEC D | |||||||||||||||
| 23807 | DI | Disable interrupts. | ||||||||||||||
| 23808 | LD A,15 | Set the border to white via port 254. | ||||||||||||||
| 23810 | OUT (254),A | |||||||||||||||
| 23812 | LD HL,23980 | Point HL at Restore_Border and stash it as the return address. | ||||||||||||||
| 23815 | PUSH HL | |||||||||||||||
|
Seed the EAR/border state in C from the current EAR bit.
|
||||||||||||||||
| 23816 | IN A,(254) | Read the EAR port. | ||||||||||||||
| 23818 | RRA | Rotate the EAR bit into bit 0 of A. | ||||||||||||||
| 23819 | AND %00100000 | Keep only the EAR bit. | ||||||||||||||
| 23821 | OR %00000010 | Set the blue border bit. | ||||||||||||||
| 23823 | LD C,A | Copy the EAR/border state into C and set the zero flag. | ||||||||||||||
| 23824 | CP A | |||||||||||||||
|
Wait for the pilot tone.
|
||||||||||||||||
| Load_Tape_Block_WaitPilot | 23825 | 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 | 23826 | CALL 1511 | Jump back to Load_Tape_Block_WaitPilot if LD-EDGE-2 resets the carry flag. | |||||||||||||
| 23829 | JR NC,Load_Tape_Block_WaitPilot | |||||||||||||||
| 23831 | LD HL,1045 | Set the leader timing budget in HL to 1045. | ||||||||||||||
|
Exhaust the leader timing budget while edges continue to arrive.
|
||||||||||||||||
| Load_Tape_Block_LeaderDelay | 23834 | DJNZ Load_Tape_Block_LeaderDelay | Decrease B and loop until it is zero. | |||||||||||||
| 23836 | DEC HL | Decrease HL. | ||||||||||||||
| 23837 | LD A,H | Jump back to Load_Tape_Block_LeaderDelay if HL is non-zero. | ||||||||||||||
| 23838 | OR L | |||||||||||||||
| 23839 | JR NZ,Load_Tape_Block_LeaderDelay | |||||||||||||||
| 23841 | CALL 1507 | Jump back to Load_Tape_Block_WaitPilot if LD-EDGE-1 resets the carry flag. | ||||||||||||||
| 23844 | JR NC,Load_Tape_Block_WaitPilot | |||||||||||||||
|
Confirm a long enough run of short pilot pulses.
|
||||||||||||||||
| Load_Tape_Block_PilotPulse | 23846 | LD B,156 | Set the pulse timing constant in B to 156. | |||||||||||||
| 23848 | CALL 1507 | Jump back to Load_Tape_Block_WaitPilot if LD-EDGE-1 resets the carry flag. | ||||||||||||||
| 23851 | JR NC,Load_Tape_Block_WaitPilot | |||||||||||||||
| 23853 | LD A,166 | Jump back to Load_Tape_Block_PilotPair if B is at least 166. | ||||||||||||||
| 23855 | CP B | |||||||||||||||
| 23856 | JR NC,Load_Tape_Block_PilotPair | |||||||||||||||
| 23858 | INC H | Increase H by one and jump back to Load_Tape_Block_PilotPulse until it wraps. | ||||||||||||||
| 23859 | JR NZ,Load_Tape_Block_PilotPulse | |||||||||||||||
|
Wait for the sync pulse that ends the pilot.
|
||||||||||||||||
| Load_Tape_Block_Sync | 23861 | LD B,201 | Set the sync timing constant in B to 201. | |||||||||||||
| 23863 | CALL 1511 | Jump back to Load_Tape_Block_WaitPilot if LD-EDGE-2 resets the carry flag. | ||||||||||||||
| 23866 | JR NC,Load_Tape_Block_WaitPilot | |||||||||||||||
| 23868 | LD A,B | Jump back to Load_Tape_Block_Sync if B is at least 212. | ||||||||||||||
| 23869 | CP 212 | |||||||||||||||
| 23871 | JR NC,Load_Tape_Block_Sync | |||||||||||||||
| 23873 | CALL 1511 | Call LD-EDGE-2 and return if the carry flag is reset. | ||||||||||||||
| 23876 | RET NC | |||||||||||||||
|
Flip the border colour and start the byte-load loop.
|
||||||||||||||||
| 23877 | LD A,C | Fetch the EAR/border state from C. | ||||||||||||||
| 23878 | XOR %00000011 | Toggle the border colour bits. | ||||||||||||||
| 23880 | LD C,A | Store the updated EAR/border state in C. | ||||||||||||||
| 23881 | LD H,0 | Clear the parity byte in H. | ||||||||||||||
| 23883 | LD B,176 | Set B to 176. | ||||||||||||||
| 23885 | 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 | 23887 | EX AF,AF' | Switch to AF'. | |||||||||||||
| 23888 | JR NZ,Load_Tape_Block_FlagByte | Jump to Load_Tape_Block_FlagByte if the flag byte is not zero. | ||||||||||||||
| 23890 | JR NC,Load_Tape_Block_VerifyByte | Jump to Load_Tape_Block_VerifyByte if the carry flag is reset (verify mode). | ||||||||||||||
| 23892 | LD (IX+0),L | Store the assembled byte in *IX+0. | ||||||||||||||
| 23895 | JR Load_Tape_Block_Advance | Jump to Load_Tape_Block_Advance. | ||||||||||||||
|
Compare the assembled byte against the expected flag byte.
|
||||||||||||||||
| Load_Tape_Block_FlagByte | 23897 | RL C | Rotate the stored flag bits in C. | |||||||||||||
| 23899 | XOR L | Return if the assembled byte does not match. | ||||||||||||||
| 23900 | RET NZ | |||||||||||||||
| 23901 | LD A,C | Restore C from the rotated value. | ||||||||||||||
| 23902 | RRA | |||||||||||||||
| 23903 | LD C,A | |||||||||||||||
| 23904 | INC DE | Advance DE past the flag byte. | ||||||||||||||
| 23905 | JR Load_Tape_Block_Continue | Jump to Load_Tape_Block_Continue. | ||||||||||||||
|
Verify the assembled byte against *IX.
|
||||||||||||||||
| Load_Tape_Block_VerifyByte | 23907 | LD A,(IX+0) | Return if *IX+0 does not match the assembled byte. | |||||||||||||
| 23910 | XOR L | |||||||||||||||
| 23911 | RET NZ | |||||||||||||||
|
Advance the destination and continue for the remaining length.
|
||||||||||||||||
| Load_Tape_Block_Advance | 23912 | INC IX | Advance IX. | |||||||||||||
|
Prepare the timing constant for the next byte.
|
||||||||||||||||
| Load_Tape_Block_Continue | 23914 | DEC DE | Decrease the remaining length. | |||||||||||||
| 23915 | EX AF,AF' | Switch back to AF'. | ||||||||||||||
| 23916 | LD B,178 | Set B to 178. | ||||||||||||||
|
Sample eight edges to assemble the next byte into L.
|
||||||||||||||||
| Load_Tape_Block_SampleByte | 23918 | LD L,1 | Seed the assembled byte in L with 1. | |||||||||||||
|
Sample one bit into L.
|
||||||||||||||||
| Load_Tape_Block_SampleBit | 23920 | CALL 1507 | Call LD-EDGE-1 and return if the carry flag is reset. | |||||||||||||
| 23923 | RET NC | |||||||||||||||
| 23924 | LD A,203 | Compare B with the bit-threshold 203. | ||||||||||||||
| 23926 | CP B | |||||||||||||||
| 23927 | RL L | Rotate that comparison result into L. | ||||||||||||||
| 23929 | LD B,176 | Set B to 176. | ||||||||||||||
| 23931 | JP NC,Load_Tape_Block_SampleBit | Jump back to Load_Tape_Block_SampleBit until eight bits are in. | ||||||||||||||
| 23934 | LD A,H | Mix the assembled byte into the running parity in H. | ||||||||||||||
| 23935 | XOR L | |||||||||||||||
| 23936 | LD H,A | |||||||||||||||
| 23937 | LD A,D | Jump back to Load_Tape_Block_NextByte until the remaining length in DE is zero. | ||||||||||||||
| 23938 | OR E | |||||||||||||||
| 23939 | JR NZ,Load_Tape_Block_NextByte | |||||||||||||||
| 23941 | LD A,H | Compare the parity byte with 1. | ||||||||||||||
| 23942 | CP 1 | |||||||||||||||
| 23944 | 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 | 23945 | LD A,1 | Open stream 1 via CHAN_OPEN. | |||||||||||||
| 23947 | CALL 5633 | |||||||||||||||
| 23950 | LD B,25 | Point DE at Messaging_TapeLoadingError with length 25. | ||||||||||||||
| 23952 | LD DE,24042 | |||||||||||||||
| 23955 | JP Restore_Border_PrintLoop | Jump to Restore_Border_PrintLoop. | ||||||||||||||
| Prev: 23760 | Up: Map | Next: 23958 |