Load code

32768: Collect one bit from tape


Used by load routine at 32815

32768 33 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 33 INC SP
32770 E3 EX (SP),HL
32771 2600 LD H,0
32773 6C LD L,H
32774 E3 EX (SP),HL
32775 3B DEC SP
32776 3B DEC SP
32777 3E06 LD A,6
32779 CD1180 CALL 32785 Listen for one edge
32782 D0 RET NC Return if not found within time limit
32783 3E0B LD A,11
32785 3D DEC A Wait a bit
32786 20FD JR NZ,32785
32788 A7 AND A Reset the carry flag
32789 04 INC B
32790 C8 RET Z Return with carry reset if no edge found and time is up
32791 3E7F LD A,127 Collect EAR port reading into bit 6 of A
32793 DBFE IN A,(254)
32795 1F RRA Move it to bit 5 of A
32796 A7 AND A Clear the carry flag
32797 A9 XOR C Compare EAR port reading with previous one
32798 E620 AND 32
32800 28F3 JR Z,32789 Jump back if they are the same (i.e. no edge found yet)
32802 79 LD A,C Alternate border colour
32803 2F CPL
32804 4F LD C,A
32805 E607 AND 7
32807 F608 OR 8
32809 D3FE OUT (254),A
32811 37 SCF Signal: edge found within time limit
32812 C9 RET Return with B indicating time taken to find edge