Sherlock: annotated disassembly

Routines

Prev: C03B Up: Map Next: C0A5
C040: Save the game to tape, then verify it
Prints a prompt taken from the ROM's tape messages (C1C0 with HL = $09A2: the ROM's 'Start tape, then press any key.', then a key is waited for), writes a 17-byte header (C0FE: a code file named 'SHD V2.0') and the block with SA-BYTES ($04C2), then asks for the tape to be rewound ('REWIND TAPE', C0A5) and verifies both with LD-BYTES ($0556) - 'TAPE ERROR' (C0B1) if they do not match.
Input
IX The start of the block
DE Its length
Output
The block saved to tape and verified
C040 LD HL,$09A2 Load HL with $09A2 - 'Start tape, then press any key.' (from the ROM), and wait for a key
C043 CALL $C1C0 Call the routine "Print a prompt at HL, wait for a key, newline" (C1C0)
C046 LD ($C109),DE Store DE in C109 in "The saved game's tape header: a CODE file..." - Keep the block's length and start
C04A LD ($C10B),IX Store IX in C10B in "The saved game's tape header: a CODE file..."
C04E LD IX,$C0FE Point IX at "The saved game's tape header: a CODE file 'SHD..." (C0FE) - Save the 17-byte header at C0FE (a code file, 'SHD V2.0') with the ROM's SA-BYTES
C052 LD DE,$0011 Load DE with $0011
C055 XOR A Clear A to zero (and the carry flag)
C056 CALL $04C2 Call the ROM tape-save routine ($04C2)
C059 LD B,$32 Load B with $32 - A pause of fifty frames
C05B HALT Wait for the next interrupt
C05C DJNZ $C05B Count B down and, while it is not zero, go back to C05B
C05E DI Disable interrupts
C05F LD DE,($C109) Read C109 in "The saved game's tape header: a CODE file..." into DE - Then the block itself
C063 LD IX,($C10B) Read C10B in "The saved game's tape header: a CODE file..." into IX
C067 LD A,$FF Load A with $FF
C069 CALL $04C2 Call the ROM tape-save routine ($04C2)
C06C DI Disable interrupts
C06D LD HL,$C0A5 Point HL at "Tape message: 'REWIND TAPE.'" (C0A5)
C070 CALL $C1CB Call the routine "Print a message: plain ASCII, last byte has bit 7 set" (C1CB)
C073 LD HL,$09AC Load HL with $09AC - ', then press any key.' (the end of the ROM's message), and wait
C076 CALL $C1C0 Call the routine "Print a prompt at HL, wait for a key, newline" (C1C0)
C079 LD IX,$C0FE Point IX at "The saved game's tape header: a CODE file 'SHD..." (C0FE) - Read the header back in VERIFY mode (LD-BYTES with carry clear)
C07D LD DE,$0011 Load DE with $0011
C080 LD A,$00 Load A with $00
C082 AND A Test A for zero (this leaves A as it was and clears carry)
C083 CALL $0556 Call the ROM tape-load routine ($0556)
C086 JR NC,$C098 If the carry flag is clear, skip ahead to C098 - (no match: TAPE ERROR)
C088 AND A Test A for zero (this leaves A as it was and clears carry)
This entry point is used by the routine at C0DF.
C089 LD DE,($C109) Read C109 in "The saved game's tape header: a CODE file..." into DE - Then verify the block
C08D LD IX,($C10B) Read C10B in "The saved game's tape header: a CODE file..." into IX
C091 LD A,$FF Load A with $FF
C093 CALL $0556 Call the ROM tape-load routine ($0556)
C096 DI Disable interrupts
C097 RET C Matched: return with carry set
C098 DI Disable interrupts - 'TAPE ERROR.' and ' press any key.'
C099 LD HL,$C0B1 Point HL at "Tape message: 'TAPE ERROR.'" (C0B1)
C09C CALL $C1CB Call the routine "Print a message: plain ASCII, last byte has bit 7 set" (C1CB)
C09F LD HL,$09B2 Load HL with $09B2
C0A2 JP $C1C0 Jump on to the routine "Print a prompt at HL, wait for a key, newline" (C1C0)
Prev: C03B Up: Map Next: C0A5