![]() |
Routines |
| Prev: 59950 | Up: Map | Next: 60236 |
|
Used by the routine at Control_Loading.
Custom turbo sampler. Before sampling it compares the loader's additive checksum in *Running_Checksum_Total against the expected value in *Expected_Checksum.
|
||||||||||||||||
|
Refuse to load if the self-check total is wrong.
|
||||||||||||||||
| Sample_Tape | 60078 | PUSH DE | Stash DE and AF on the stack. | |||||||||||||
| 60079 | PUSH AF | |||||||||||||||
| 60080 | LD HL,(59879) | Jump to START if *Expected_Checksum does not equal *Running_Checksum_Total. | ||||||||||||||
| 60083 | LD DE,(59877) | |||||||||||||||
| 60087 | SCF | |||||||||||||||
| 60088 | CCF | |||||||||||||||
| 60089 | SBC HL,DE | |||||||||||||||
| 60091 | JP NZ,0 | |||||||||||||||
| 60094 | POP AF | Restore AF and DE from the stack. | ||||||||||||||
| 60095 | POP DE | |||||||||||||||
|
Preserve the flag byte and blank the border.
|
||||||||||||||||
| 60096 | INC D | Preserve the flag byte in AF'. | ||||||||||||||
| 60097 | EX AF,AF' | |||||||||||||||
| 60098 | DEC D | |||||||||||||||
| 60099 | DI | Disable interrupts. | ||||||||||||||
| 60100 | LD A,0 | Set the border to black via port 254. | ||||||||||||||
| 60102 | OUT (254),A | |||||||||||||||
| 60104 | LD HL,1343 | Set the initial timing budget in HL to 1343. | ||||||||||||||
|
Seed the EAR/border state in C from the current EAR bit.
|
||||||||||||||||
| 60107 | IN A,(254) | Read the EAR port. | ||||||||||||||
| 60109 | RRA | Rotate the EAR bit into bit 0 of A. | ||||||||||||||
| 60110 | AND %00100000 | Keep only the EAR bit. | ||||||||||||||
| 60112 | OR %00000010 | Set the blue border bit. | ||||||||||||||
| 60114 | LD C,A | Copy the EAR/border state into C and set the zero flag. | ||||||||||||||
| 60115 | CP A | |||||||||||||||
|
Wait for the pilot tone.
|
||||||||||||||||
| Sample_Tape_WaitPilot | 60116 | RET NZ | Return if the zero flag is reset (BREAK was pressed). | |||||||||||||
|
Listen for a pair of edges that look like the pilot.
|
||||||||||||||||
| Sample_Tape_PilotPair | 60117 | CALL Sample_Edge_Wait | Jump back to Sample_Tape_WaitPilot if Sample_Edge_Wait resets the carry flag. | |||||||||||||
| 60120 | JR NC,Sample_Tape_WaitPilot | |||||||||||||||
| 60122 | LD HL,1045 | Set the leader timing budget in HL to 1045. | ||||||||||||||
|
Exhaust the leader timing budget while edges continue to arrive.
|
||||||||||||||||
| Sample_Tape_LeaderDelay | 60125 | DJNZ Sample_Tape_LeaderDelay | Decrease B and loop until it is zero. | |||||||||||||
| 60127 | DEC HL | Decrease HL. | ||||||||||||||
| 60128 | LD A,H | Jump back to Sample_Tape_LeaderDelay if HL is non-zero. | ||||||||||||||
| 60129 | OR L | |||||||||||||||
| 60130 | JR NZ,Sample_Tape_LeaderDelay | |||||||||||||||
| 60132 | CALL Sample_Edge | Jump back to Sample_Tape_WaitPilot if Sample_Edge resets the carry flag. | ||||||||||||||
| 60135 | JR NC,Sample_Tape_WaitPilot | |||||||||||||||
|
Confirm a long enough run of short pilot pulses.
|
||||||||||||||||
| Sample_Tape_PilotPulse | 60137 | LD B,156 | Set the pulse timing constant in B to 156. | |||||||||||||
| 60139 | CALL Sample_Edge | Jump back to Sample_Tape_WaitPilot if Sample_Edge resets the carry flag. | ||||||||||||||
| 60142 | JR NC,Sample_Tape_WaitPilot | |||||||||||||||
| 60144 | LD A,166 | Jump back to Sample_Tape_PilotPair if B is at least 166. | ||||||||||||||
| 60146 | CP B | |||||||||||||||
| 60147 | JR NC,Sample_Tape_PilotPair | |||||||||||||||
| 60149 | INC H | Increase H by one and jump back to Sample_Tape_PilotPulse until it wraps. | ||||||||||||||
| 60150 | JR NZ,Sample_Tape_PilotPulse | |||||||||||||||
|
Wait for the sync pulse that ends the pilot.
|
||||||||||||||||
| Sample_Tape_Sync | 60152 | LD B,201 | Set the sync timing constant in B to 201. | |||||||||||||
| 60154 | CALL Sample_Edge_Wait | Jump back to Sample_Tape_WaitPilot if Sample_Edge_Wait resets the carry flag. | ||||||||||||||
| 60157 | JR NC,Sample_Tape_WaitPilot | |||||||||||||||
| 60159 | LD A,B | Jump back to Sample_Tape_Sync if B is at least 212. | ||||||||||||||
| 60160 | CP 212 | |||||||||||||||
| 60162 | JR NC,Sample_Tape_Sync | |||||||||||||||
| 60164 | CALL Sample_Edge_Wait | Call Sample_Edge_Wait and return if the carry flag is reset. | ||||||||||||||
| 60167 | RET NC | |||||||||||||||
|
Flip the border colour and start the byte-load loop.
|
||||||||||||||||
| 60168 | LD A,C | Fetch the EAR/border state from C. | ||||||||||||||
| 60169 | XOR %00000011 | Toggle the border colour bits. | ||||||||||||||
| 60171 | LD C,A | Store the updated EAR/border state in C. | ||||||||||||||
| 60172 | LD H,0 | Clear the parity byte in H. | ||||||||||||||
|
First-byte B timing, patched by Patch_Timing.
|
||||||||||||||||
| Sample_Tape_First_Byte_Timing | 60174 | LD B,176 | Set B to the patched first-byte timing constant. | |||||||||||||
| 60176 | JR Sample_Tape_SampleByte | Jump to Sample_Tape_SampleByte. | ||||||||||||||
|
Handle each loaded byte under the preserved flag in AF'.
|
||||||||||||||||
| Sample_Tape_NextByte | 60178 | EX AF,AF' | Switch to AF'. | |||||||||||||
| 60179 | JR NZ,Sample_Tape_FlagByte | Jump to Sample_Tape_FlagByte if the flag byte is not zero. | ||||||||||||||
| 60181 | JR NC,Sample_Tape_VerifyByte | Jump to Sample_Tape_VerifyByte if the carry flag is reset (verify mode). | ||||||||||||||
| 60183 | LD (IX+0),L | Store the assembled byte in *IX+0. | ||||||||||||||
| 60186 | JR Sample_Tape_Advance | Jump to Sample_Tape_Advance. | ||||||||||||||
|
Compare the assembled byte against the expected flag byte.
|
||||||||||||||||
| Sample_Tape_FlagByte | 60188 | RL C | Rotate the stored flag bits in C. | |||||||||||||
| 60190 | XOR L | Return if the assembled byte does not match. | ||||||||||||||
| 60191 | RET NZ | |||||||||||||||
| 60192 | LD A,C | Restore C from the rotated value. | ||||||||||||||
| 60193 | RRA | |||||||||||||||
| 60194 | LD C,A | |||||||||||||||
| 60195 | INC DE | Advance DE past the flag byte. | ||||||||||||||
| 60196 | JR Sample_Tape_Continue | Jump to Sample_Tape_Continue. | ||||||||||||||
|
Verify the assembled byte against *IX.
|
||||||||||||||||
| Sample_Tape_VerifyByte | 60198 | LD A,(IX+0) | Return if *IX+0 does not match the assembled byte. | |||||||||||||
| 60201 | XOR L | |||||||||||||||
| 60202 | RET NZ | |||||||||||||||
|
Advance the destination and continue for the remaining length.
|
||||||||||||||||
| Sample_Tape_Advance | 60203 | INC IX | Advance IX. | |||||||||||||
|
Prepare the timing constant for the next byte.
|
||||||||||||||||
| Sample_Tape_Continue | 60205 | DEC DE | Decrease the remaining length. | |||||||||||||
| 60206 | EX AF,AF' | Switch back to AF'. | ||||||||||||||
|
Next-byte B timing, patched by Patch_Timing.
|
||||||||||||||||
| Sample_Tape_Next_Byte_Timing | 60207 | LD B,178 | Set B to the patched next-byte timing constant. | |||||||||||||
|
Sample eight edges to assemble the next byte into L.
|
||||||||||||||||
| Sample_Tape_SampleByte | 60209 | LD L,1 | Seed the assembled byte in L with 1. | |||||||||||||
|
Sample one bit into L.
|
||||||||||||||||
| Sample_Tape_SampleBit | 60211 | CALL Sample_Edge | Call Sample_Edge and return if the carry flag is reset. | |||||||||||||
| 60214 | RET NC | |||||||||||||||
|
Bit-threshold comparison, patched by Patch_Timing.
|
||||||||||||||||
| Sample_Tape_Bit_Threshold | 60215 | LD A,203 | Compare B with the patched bit-threshold. | |||||||||||||
| 60217 | CP B | |||||||||||||||
| 60218 | RL L | Rotate that comparison result into L. | ||||||||||||||
|
Bit-loop B timing, patched by Patch_Timing.
|
||||||||||||||||
| Sample_Tape_Bit_Loop | 60220 | LD B,176 | Set B to the patched bit-loop timing constant. | |||||||||||||
| 60222 | JP NC,Sample_Tape_SampleBit | Jump back to Sample_Tape_SampleBit until eight bits are in. | ||||||||||||||
| 60225 | LD A,H | Mix the assembled byte into the running parity in H. | ||||||||||||||
| 60226 | XOR L | |||||||||||||||
| 60227 | LD H,A | |||||||||||||||
| 60228 | LD A,D | Jump back to Sample_Tape_NextByte until the remaining length in DE is zero. | ||||||||||||||
| 60229 | OR E | |||||||||||||||
| 60230 | JR NZ,Sample_Tape_NextByte | |||||||||||||||
| 60232 | LD A,H | Compare the parity byte with 1. | ||||||||||||||
| 60233 | CP 1 | |||||||||||||||
| 60235 | RET | Return. | ||||||||||||||
| Prev: 59950 | Up: Map | Next: 60236 |