Prev: 8014 Up: Map Next: 81DD
80B9: Tape loading
Used by the routine at load_stage.
Output
F Carry set on success (see 8146).
tape_load_stage 80B9 LD IX,$5C00 Setup to load a block at $5C00 of length $1AF0
80BD LD DE,$1AF0
This entry point is used by the routine at start. IX = address DE = bytes
tape_load_at_ix 80C0 INC D D++ only to clear the Zero flag, since D is never $FF; the flags are banked with A below
80C1 LD A,$98 A = 152
80C3 SCF Set carry flag
80C4 EX AF,AF' bank
80C5 DEC D D-- to undo the INC at tape_load_at_ix
80C6 DI Disable interrupts
80C7 LD A,$08 Set MIC bit (deactivates MIC)
80C9 OUT ($FE),A output
80CB IN A,($FE) input
80CD RRA Shift bit 6 (EAR) down to bit 5
80CE AND $20 Check EAR input bit 6
80D0 OR $02 Set border colour bit (visible load flicker)
80D2 LD C,A
80D3 CP A Always sets Z (A compared to itself)
tl_break 80D4 RET NZ
tl_start 80D5 CALL tl_edge_1 Call tl_edge_1
80D8 JR NC,tl_break
80DA LD HL,$0415 Delay time
tl_delay 80DD DJNZ tl_delay Delay for B iterations; B is whatever the edge test left, so the delay is only approximate
80DF DEC HL HL--
80E0 LD A,H Loop while HL > 0
80E1 OR L
80E2 JR NZ,tl_delay
80E4 CALL tl_edge_2 Call tl_edge_2
80E7 JR NC,tl_break
tl_leader 80E9 LD B,$9C B = 156
80EB CALL tl_edge_2 Call tl_edge_2
tl_leader_edge 80EE JR NC,tl_break
80F0 LD A,$C6 A = 198
80F2 CP B
80F3 JR NC,tl_start
80F5 INC H
80F6 JR NZ,tl_leader
tl_sync 80F8 LD B,$C9 B = 201
80FA CALL tl_edge_1 Call tl_edge_1
80FD JR NC,tl_break
80FF LD A,B
8100 CP $D4 212
8102 JR NC,tl_sync
8104 CALL tl_edge_1 Call tl_edge_1
8107 RET NC
8108 LD A,C A = C ^= 3
8109 XOR $03
810B LD C,A
810C LD H,$00
810E LD B,$B0 B = 176
8110 JR tl_marker
tl_loop 8112 EX AF,AF'
8113 JR NZ,tl_flag Odd/Bug: Doubled JR NZ
8115 JR NZ,tl_store Odd/Bug: Jump to next instr
tl_store 8117 LD (IX+$00),L
811A JR tl_next
tl_flag 811C RL C Keep the carry (the load/verify flag) in bit 0 of C
811E XOR L A ^= L
811F RET NZ
8120 LD A,C Restore C, putting the flag back in carry
8121 RRA
8122 LD C,A
8123 INC DE DE++
8124 JR tl_dec
tl_next 8126 INC IX
tl_dec 8128 DEC DE
8129 EX AF,AF'
812A LD B,$B2 B = 178
tl_marker 812C LD L,$01
tl_8_bits 812E CALL tl_edge_2 Call tl_edge_2
8131 RET NC
8132 LD A,$C8 A = 200
8134 CP B
8135 RL L
8137 LD B,$B0 B = 176
8139 JP NC,tl_8_bits
813C LD A,H A = H ^ L
813D XOR L
813E LD H,A Save A
813F LD A,D Loop while DE > 0
8140 OR E
8141 JR NZ,tl_loop
8143 LD A,H Restore A
8144 CP $01 Carry set if the checksum in H is zero
8146 RET Return, carry set for success
tl_edge_2 8147 CALL tl_edge_1 Call tl_edge_1
814A RET NC
tl_edge_1 814B LD A,$16 Delay loop of 22 iterations
tl_delay_loop 814D DEC A
814E JR NZ,tl_delay_loop
8150 AND A Clear carry flag
tl_sample 8151 INC B Count the edge timing in B; wrapping to zero is a timeout
8152 RET Z Return if zero (failure)
8153 LD A,$7F %01111111
8155 IN A,($FE) Read from port
8157 RRA
8158 RET Z
8159 XOR C A ^= C
815A AND $20 check EAR input bit 6
815C JR Z,tl_sample loop if zero
815E LD A,C A = C = ~C
815F CPL
8160 LD C,A
8161 AND $02
8163 OR $08 Set MIC bit (deactivate MIC)
8165 OUT ($FE),A Output
8167 SCF Set carry
8168 RET Return (success)
rewind_tape 8169 DEFB $70 Attribute byte
816A DEFW $F001 Screen position (8,64)
816C DEFW $5901 Screen attribute position (1,8)
816E DEFM "REWIND TAPE TO START OF SIDE ",$B2 "REWIND TAPE TO START OF SIDE 2"
start_tape 818C DEFB $68 Attribute byte
818D DEFW $F04B Screen position (88,96)
818F DEFW $598B Screen attribute position (11,12)
8191 DEFM "START TAP",$C5 "START TAPE"
819B DEFB $68 Attribute byte
819C DEFW $F089 Screen position (72,128)
819E DEFW $5A09 Screen attribute position (9,16)
searching_for_n 81A0 DEFM "SEARCHING FOR ",$B1 "SEARCHING FOR 1"
81AF DEFB $68 Attribute byte
81B0 DEFW $F0CD Screen position (104,160)
81B2 DEFW $5A8D Screen attribute position (13,20)
found_n 81B4 DEFM "FOUND ",$B1 "FOUND 1"
stop_the_tape_press_gear 81BB DEFB $70 Attribute byte
81BC DEFW $F04A Screen position (80,96)
81BE DEFW $598A Screen attribute position (10,12)
81C0 DEFM "STOP THE TAP",$C5 "STOP THE TAPE"
81CD DEFB $60 Attribute byte
81CE DEFW $F08B Screen position (88,128)
81D0 DEFW $5A0B Screen attribute position (11,16)
81D2 DEFM "PRESS GEA",$D2 "PRESS GEAR"
Prev: 8014 Up: Map Next: 81DD