![]() |
Routines |
32768 | INC SP | Place the address 0 on the stack above the current return address, so the Spectrum will reset if there's a loading error |
32769 | INC SP | |
32770 | EX (SP),HL | |
32771 | LD H,0 | |
32773 | LD L,H | |
32774 | EX (SP),HL | |
32775 | DEC SP | |
32776 | DEC SP | |
32777 | LD A,6 | |
32779 | CALL 32785 | Listen for one edge |
32782 | RET NC | Return if no edge was found within the time limit |
32783 | LD A,11 | Wait a bit |
32785 | DEC A | |
32786 | JR NZ,32785 | |
32788 | AND A | Reset the carry flag |
32789 | INC B | Have we run out of time to find an edge? |
32790 | RET Z | Return with the carry flag reset if so |
32791 | LD A,127 | Collect an EAR port reading in bit 6 of A |
32793 | IN A,(254) | |
32795 | RRA | Move it to bit 5 of A |
32796 | AND A | Clear the carry flag |
32797 | XOR C | Compare this EAR port reading with the previous one |
32798 | AND 32 | |
32800 | JR Z,32789 | Jump back if they are the same (i.e. no edge was found) |
32802 | LD A,C | Alternate the border colour |
32803 | CPL | |
32804 | LD C,A | |
32805 | AND 7 | |
32807 | OR 8 | |
32809 | OUT (254),A | |
32811 | SCF | Signal: an edge was found within the time limit |
32812 | RET | Return with B indicating the time taken to find the edge |