![]() |
Routines |
| Prev: B75A | Up: Map | Next: B837 |
|
This resets all visible characters, the game clock, day_or_night flag, general flags, collapsed tunnel objects, locks the gates, resets all beds, clears the mess halls and resets characters.
Used by the routines at reset_game and solitary.
|
||||
| reset_map_and_characters | B79B | LD B,$07 | Set B for seven iterations | |
| B79D | LD HL,$8020 | Point HL at the second vischar | ||
|
Start loop (iterate over non-player characters)
|
||||
| reset_map_and_characters_0 | B7A0 | PUSH BC | Preserve the counter | |
| B7A1 | PUSH HL | Preserve the vischar pointer | ||
| B7A2 | CALL reset_visible_character | Reset the visible character | ||
| B7A5 | POP HL | Restore the vischar pointer | ||
| B7A6 | LD A,L | Advance HL to the next vischar (note shortcut) | ||
| B7A7 | ADD A,$20 | |||
| B7A9 | LD L,A | |||
| B7AA | POP BC | Restore the counter | ||
| B7AB | DJNZ reset_map_and_characters_0 | ...loop | ||
| B7AD | LD A,$07 | Set the game clock to seven [unsure why seven in particular] | ||
| B7AF | LD ($A13D),A | |||
| B7B2 | XOR A | Clear the night-time flag | ||
| B7B3 | LD ($A146),A | |||
| B7B6 | LD ($8001),A | Clear the hero's vischar flags | ||
| B7B9 | LD A,$14 | Set the roomdef_50_blocked_tunnel_collapsed_tunnel object to interiorobject_COLLAPSED_TUNNEL_SW_NE | ||
| B7BB | LD ($708C),A | |||
| B7BE | LD A,$34 | Set the blocked tunnel boundary | ||
| B7C0 | LD ($7077),A | |||
|
Lock the gates and doors.
|
||||
| B7C3 | LD HL,$F05D | Point HL at locked_doors[0] | ||
| B7C6 | LD B,$09 | Set B for nine iterations (nine locked doors) | ||
|
Start loop
|
||||
| reset_map_and_characters_1 | B7C8 | SET 7,(HL) | Set the door_LOCKED flag Advance HL to the next locked door | |
| B7CA | INC HL | |||
| B7CB | DJNZ reset_map_and_characters_1 | ...loop | ||
|
Reset all beds.
|
||||
| B7CD | LD B,$06 | Set B for six iterations (six beds) | ||
| B7CF | LD A,$17 | Preload A with interiorobject_OCCUPIED_BED | ||
| B7D1 | LD HL,$6B79 | Point HL at beds[0] | ||
|
Start loop
|
||||
| reset_map_and_characters_2 | B7D4 | LD E,(HL) | Load the address of the bed object | |
| B7D5 | INC HL | |||
| B7D6 | LD D,(HL) | |||
| B7D7 | INC HL | |||
| B7D8 | LD (DE),A | Set the bed object to interiorobject_OCCUPIED_BED | ||
| B7D9 | DJNZ reset_map_and_characters_2 | ...loop | ||
|
Clear the mess halls.
|
||||
| B7DB | LD A,$0D | Preload A with interiorobject_EMPTY_BENCH | ||
| B7DD | LD ($6F17),A | Set to empty roomdef_23_breakfast_bench_A | ||
| B7E0 | LD ($6F1A),A | Set to empty roomdef_23_breakfast_bench_B | ||
| B7E3 | LD ($6F1D),A | Set to empty roomdef_23_breakfast_bench_C | ||
| B7E6 | LD ($6F4F),A | Set to empty roomdef_25_breakfast_bench_D | ||
| B7E9 | LD ($6F52),A | Set to empty roomdef_25_breakfast_bench_E | ||
| B7EC | LD ($6F55),A | Set to empty roomdef_25_breakfast_bench_F | ||
| B7EF | LD ($6F58),A | Set to empty roomdef_25_breakfast_bench_G | ||
|
Reset characters 12..15 (guards) and 20..25 (prisoners).
|
||||
| B7F2 | LD DE,$7667 | Point DE at character_structs[12].room | ||
| B7F5 | LD C,$0A | Set C for ten iterations | ||
| B7F7 | LD HL,$B819 | Point HL at character_reset_data[0] | ||
|
Start loop
|
||||
| reset_map_and_characters_3 | B7FA | LD B,$03 | Set B for three iterations | |
| reset_map_and_characters_4 | B7FC | LD A,(HL) | Copy a byte and advance | |
| B7FD | LD (DE),A | |||
| B7FE | INC DE | |||
| B7FF | INC HL | |||
| B800 | DJNZ reset_map_and_characters_4 | ...loop | ||
|
DE now points to the height
|
||||
| B802 | EX DE,HL | Swap | ||
|
Bug: This is reset to 18 here but the initial value is 24.
|
||||
| B803 | LD (HL),$12 | Set height to 18 and advance | ||
| B805 | INC HL | |||
| B806 | LD (HL),$00 | Set route index to zero (halt) | ||
| B808 | INC HL | |||
| B809 | INC HL | Advance to the next character struct | ||
| B80A | INC HL | |||
| B80B | EX DE,HL | Swap | ||
| B80C | LD A,C | Get our loop counter | ||
| B80D | CP $07 | Do seven iterations remain? | ||
| B80F | JR NZ,reset_map_and_characters_5 | Jump if not | ||
| B811 | LD DE,$769F | Otherwise point DE at character_structs[20].room | ||
| reset_map_and_characters_5 | B814 | DEC C | ...loop | |
| B815 | JP NZ,reset_map_and_characters_3 | |||
| B818 | RET | Return | ||
|
Reset data for character_structs.
struct { byte room; byte x; byte y; }; // partial of character_struct
|
||||
| character_reset_data | B819 | DEFB $03,$28,$3C | (room_3_HUT2RIGHT, 40,60) for character 12 | |
| B81C | DEFB $03,$24,$30 | (room_3_HUT2RIGHT, 36,48) for character 13 | ||
| B81F | DEFB $05,$28,$3C | (room_5_HUT3RIGHT, 40,60) for character 14 | ||
| B822 | DEFB $05,$24,$22 | (room_5_HUT3RIGHT, 36,34) for character 15 | ||
| B825 | DEFB $FF,$34,$3C | (room_NONE, 52,60) for character 20 | ||
| B828 | DEFB $FF,$34,$2C | (room_NONE, 52,44) for character 21 | ||
| B82B | DEFB $FF,$34,$1C | (room_NONE, 52,28) for character 22 | ||
| B82E | DEFB $FF,$34,$3C | (room_NONE, 52,60) for character 23 | ||
| B831 | DEFB $FF,$34,$2C | (room_NONE, 52,44) for character 24 | ||
| B834 | DEFB $FF,$34,$1C | (room_NONE, 52,28) for character 25 | ||
| Prev: B75A | Up: Map | Next: B837 |