| Load routines

8000: Collect one bit from tape

Used by the routine at 802F.
8000 | INC SP | Place the address 0000 on the stack above the current return address, so the Spectrum will reset if there's a loading error
8001 | INC SP
8002 | EX (SP),HL
8003 | LD H,$00
8005 | LD L,H
8006 | EX (SP),HL
8007 | DEC SP
8008 | DEC SP
8009 | LD A,$06 | After the fast code block has loaded, this instruction is changed to 'LD A,$11' for the standard speed code block
800B | CALL $8011 | Listen for one edge
800E | RET NC | Return if no edge was found within the time limit
This entry point is also used by the routine at 802F.
800F | LD A,$0B | Wait a bit; after the fast code block has loaded, this instruction is changed to 'LD A,$16' for the standard speed code block
8011 | DEC A
8012 | JR NZ,$8011
8014 | AND A | Reset the carry flag
8015 | INC B | Have we run out of time to find an edge?
8016 | RET Z | Return with the carry flag reset if so
8017 | LD A,$7F | Collect an EAR port reading in bit 6 of A
8019 | IN A,($FE)
801B | RRA | Move it to bit 5 of A
801C | AND A | In the analogous ROM routine, the instruction here is 'RET NC', causing a return if BREAK was pressed; that behaviour is disabled when loading the fast code block (pressing BREAK does nothing), but after the fast code block has loaded, this instruction is changed to 'RET NC' for the standard speed code block
801D | XOR C | Compare this EAR port reading with the previous one
801E | AND $20
8020 | JR Z,$8015 | Jump back if they are the same (i.e. no edge was found)
8022 | LD A,C | Alternate the border colour
8023 | CPL
8024 | LD C,A
8025 | AND $07
8027 | OR $08
8029 | OUT ($FE),A
802B | SCF | Signal: an edge was found within the time limit
802C | RET | Return with B indicating the time taken to find the edge