Prev: 01366 Up: Map Next: 01541
Used by the routine at LD_BYTES.
These two subroutines form the most important part of the LOAD/VERIFY operation.
The subroutines are entered with a timing constant in the B register, and the previous border colour and 'edge-type' in the C register.
The subroutines return with the carry flag set if the required number of 'edges' have been found in the time allowed, and the change to the value in the B register shows just how long it took to find the 'edge(s)'.
The carry flag will be reset if there is an error. The zero flag then signals 'BREAK pressed' by being reset, or 'time-up' by being set.
The entry point LD_EDGE_2 is used when the length of a complete pulse is required and LD_EDGE_1 is used to find the time before the next 'edge'.
B Timing constant
C Border colour (bits 0-2) and previous edge-type (bit 5)
LD_EDGE_2 01507 CALL LD_EDGE_1 In effect call LD_EDGE_1 twice, returning in between if there is an error.
01510 RET NC
This entry point is used by the routine at LD_BYTES.
LD_EDGE_1 01511 LD A,22 Wait 358 T states before entering the sampling loop.
01516 AND A
The sampling loop is now entered. The value in the B register is incremented for each pass; 'time-up' is given when B reaches zero.
LD_SAMPLE 01517 INC B Count each pass.
01518 RET Z Return carry reset and zero set if 'time-up'.
01519 LD A,127 Read from port 32766, i.e. BREAK and EAR.
01521 IN A,(254)
01523 RRA Shift the byte.
01524 RET NC Return carry reset and zero reset if BREAK was pressed.
01525 XOR C Now test the byte against the 'last edge-type'; jump back unless it has changed.
01526 AND 32
A new 'edge' has been found within the time period allowed for the search. So change the border colour and set the carry flag.
01530 LD A,C Change the 'last edge-type' and border colour.
01531 CPL
01532 LD C,A
01533 AND 7 Keep only the border colour.
01535 OR 8 Signal 'MIC off'.
01537 OUT (254),A Change the border colour (red/cyan or blue/yellow).
01539 SCF Signal the successful search before returning.
01540 RET
Note: the LD_EDGE_1 subroutine takes 465 T states, plus an additional 58 T states for each unsuccessful pass around the sampling loop.
For example, therefore, when awaiting the sync pulse (see LD_SYNC) allowance is made for ten additional passes through the sampling loop. The search is thereby for the next edge to be found within, roughly, 1100 T states (465+10*58+overhead). This will prove successful for the sync 'off' pulse that comes after the long 'leader pulses'.
Prev: 01366 Up: Map Next: 01541