Prev: 8341 Up: Map Next: 83C3
8375: Save bytes from tape
Used by the routine at 8341.
Input
IX Pointer to current byte to store
DE Remaining length to read
L The byte loaded from tape ready to store to memory
8375 LD (IX+$00),L Got a byte, so store it
8378 INC IX Next address
837A DEC DE Decrease length
837B LD B,$B2 Timing constant
This entry point is used by the routine at 8000. The timing constant is B1
837D LD L,$01 Initialize L to build up a byte from tape
837F CALL $8341 Get a bit from tape
8382 JP NC,$0000 Reset on error
8385 LD A,$CB Timing constant
8387 CP B If an edge change was found quickly enough, reset the carry flag to denote "0" read. If not, set it to denote "1" read
8388 RLA Put the read bit in bit 0 of A
8389 EXX Save registers
838A LD B,A Remember the saved bit
838B AND $01 Store the next value to update in the animation buffers to 1 or 2 depending on what bit was read
838D INC A
838E LD C,A
838F LD DE,$806B Point to animation queue
8392 LD A,(DE) Is some animation required?
8393 AND A
8394 CALL NZ,$8277 Do some if so
8397 RR B Put the bit found in the carry flag
8399 EXX Restore registers
839A RL L Shift byte being read along ready for next bit
839C LD B,$B1 Timing constant
839E JR NC,$837F Loop back if there are still bits left
83A0 LD A,H Get the parity byte and save it
83A1 XOR L
83A2 LD H,A
83A3 LD A,D Reached the end of the block?
83A4 OR E
83A5 JR NZ,$8375 No, more work to do
At this point, the game has been read into memory. There are still some bits on the tape, so retrieve those to check everything is still in sync properly.
83A7 LD A,H Test the parity byte
83A8 AND A
83A9 JP NZ,$0000 Reset if it doesn't match
83AC LD DE,$EC2F
83AF LD B,$EB Timing constant
83B1 CALL $8341 Read a bit from tape
83B4 CP (HL)
83B5 NOP
83B6 INC D
83B7 LD A,$EA Did we find an edge quickly enough?
83B9 CP B
83BA JP NC,$0000 If so, something's gone wrong, so reset
83BD LD B,D
83BE DEC D
83BF DEC E
83C0 JP NZ,$83B1 Loop back if there are more bytes to be read
Prev: 8341 Up: Map Next: 83C3