Prev: 84B9 Up: Map Next: 8576
84CC: Save Game
SaveGame 84CC PUSH IX Stash IX and DE on the stack.
84CE PUSH DE
84CF LD DE,$B6EB Call ThreeByteCopy with DE=B6EB and HL=$C9E2.
84D2 LD HL,$C9E2
84D5 CALL ThreeByteCopy
84D8 LD A,$01 Write $01 to WaitCoutdown.
84DA LD ($B701),A
84DD LD HL,$B342 HL="start tape then press any key"
84E0 CALL PrintMsg Call PrintMsg.
84E3 CALL DebounceAnyKey Call DebounceAnyKey.
Save "flags".
84E6 LD A,$FF Set the save as a "data block".
84E8 LD IX,$B6EB Set the start address to; B6EB.
84EC LD DE,$001D Set the block length to; $001D bytes.
84EF CALL $04C2 Call SA_BYTES.
Save "objects".
84F2 LD A,$FF Set the save as a "data block".
84F4 LD IX,$C11B Set the start address to; Objects.
84F8 LD DE,$0615 Set the block length to; $0615 bytes.
84FB CALL $04C2 Call SA_BYTES.
Save ...
84FE LD A,$FF Set the save as a "data block".
8500 LD IX,$CA84 Set the start address to; $CA84.
8504 LD DE,$00BF Set the block length to; $00BF bytes.
8507 CALL $04C2 Call SA_BYTES.
Save "locations".
850A LD A,$FF Set the save as a "data block".
850C LD IX,$BA8A Set the start address to; Locations.
8510 LD DE,$05D9 Set the block length to; $05D9 bytes.
8513 CALL $04C2 Call SA_BYTES.
Begin verification.
8516 LD HL,$B3A4 HL="rewind and prepare tape for verification -- then hit any key"
8519 CALL PrintMsg Call PrintMsg.
851C CALL DebounceAnyKey Call DebounceAnyKey.
Verify "flags".
851F LD A,$FF Set the load as a "data block".
8521 AND A Reset the carry flag.
8522 LD IX,$B6EB Set the start address to; B6EB.
8526 LD DE,$001D Set the block length to; $001D bytes.
8529 CALL VerifyBlock Call VerifyBlock.
Verify "objects".
852C LD A,$FF Set the load as a "data block".
852E AND A Reset the carry flag.
852F LD IX,$C11B Set the start address to; Objects.
8533 LD DE,$0615 Set the block length to; $0615 bytes.
8536 CALL VerifyBlock Call VerifyBlock.
Verify ...
8539 LD A,$FF Set the load as a "data block".
853B AND A Reset the carry flag.
853C LD IX,$CA84 Set the start address to; $CA84.
8540 LD DE,$00BF Set the block length to; $00BF bytes.
8543 CALL VerifyBlock Call VerifyBlock.
Verify "locations".
8546 LD A,$FF Set the load as a "data block".
8548 AND A Reset the carry flag.
8549 LD IX,$BA8A Set the start address to; Locations.
854D LD DE,$05D9 Set the block length to; $05D9 bytes.
8550 CALL VerifyBlock Call VerifyBlock.
Success!
SaveGame_Done 8553 DI Disable interrupts.
8554 POP DE Restore DE and IX from the stack.
8555 POP IX
8557 JP $82B3 Jump to 82B3.
Verify block.
VerifyBlock 855A CALL $0556 Call LD_BYTES.
855D RET C Return if the carry flag is set.
855E LD A,$01 Write $01 to WaitCoutdown.
8560 LD ($B701),A
8563 LD HL,$B381 HL="tape error - hit any key to continue[0x15]"
8566 CALL PrintMsg Call PrintMsg.
This is almost a carbon copy of WaitForKey.
VerifyBlock_WaitForKey 8569 XOR A Read from the keyboard port.
856A IN A,($FE)
856C AND %00011111 A pressed key from any line will set its respective bit; bit 0 (outer key) to bit 4 (inner key). Hence keep only bits 0-4 for the check.
856E CP $1F Loop back to VerifyBlock_WaitForKey until any key has been pressed.
8570 JR Z,VerifyBlock_WaitForKey
8572 POP DE Restore DE from the stack.
8573 JP SaveGame_Done Jump to SaveGame_Done.
Prev: 84B9 Up: Map Next: 8576