Prev: 0556 Up: Map Next: 0605
05E3: THE 'LD-EDGE-2' AND 'LD-EDGE-1' SUBROUTINES
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'.
Input
B Timing constant
C Border colour (bits 0-2) and previous edge-type (bit 5)
LD_EDGE_2 05E3 CALL LD_EDGE_1 In effect call LD_EDGE_1 twice, returning in between if there is an error.
05E6 RET NC
This entry point is used by the routine at LD_BYTES.
LD_EDGE_1 05E7 LD A,$16 Wait 358 T states before entering the sampling loop.
LD_DELAY 05E9 DEC A
05EA JR NZ,LD_DELAY
05EC 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 05ED INC B Count each pass.
05EE RET Z Return carry reset and zero set if 'time-up'.
05EF LD A,$7F Read from port +7FFE, i.e. BREAK and EAR.
05F1 IN A,($FE)
05F3 RRA Shift the byte.
05F4 RET NC Return carry reset and zero reset if BREAK was pressed.
05F5 XOR C Now test the byte against the 'last edge-type'; jump back unless it has changed.
05F6 AND $20
05F8 JR Z,LD_SAMPLE
A new 'edge' has been found within the time period allowed for the search. So change the border colour and set the carry flag.
05FA LD A,C Change the 'last edge-type' and border colour.
05FB CPL
05FC LD C,A
05FD AND $07 Keep only the border colour.
05FF OR $08 Signal 'MIC off'.
0601 OUT ($FE),A Change the border colour (red/cyan or blue/yellow).
0603 SCF Signal the successful search before returning.
0604 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: 0556 Up: Map Next: 0605