![]() |
Routines |
| Prev: F7C4 | Up: Map | Next: F959 |
|
Run whenever the knight leaves a room: through a door (BUMPED), carried off by the thing of kind 9 (MAIN_LOOP), and at the end of a game, before GAME OVER (TITLE_SCREEN). The records after the knight's (from RECORDS) are the things he carries and then the object table's things for this room, in the table's order. For each, the three bytes of where it is -- +6 x, +7 y (its top: y is the height) and +8 z -- are copied into bytes 3 to 5 of its entry in the object table (OBJECTS), found from the number at +$13. That is how a thing left somewhere, or pushed, is still there when the knight comes back.
The walk stops at the first door. The table lists a room's things that can move before its doors, and nothing after them is kept: not the doors, not the table's last six-byte entries (the author's source text heads them STATIC OBJ), and not what the room's drawing placed. The walk would also stop after the last record in use, but that never happened in the build's sessions: every room has a door.
Two creatures are drawn facing the other way by turning their shared frames round in place: the wraith (SPRITE5E88, behaviour 11) and the troll (SPRITE8BB8, behaviour 7) -- the author's MIWRAI and MITRO name the routines. One whose frames are turned (bit 5 of +14) has them turned back here, by asking for the direction +x (C=8), so that the next room's wraiths and trolls, which start with bit 5 clear, find them the way round they expect. The record keeps its bit 5, but it is about to be overwritten.
|
||||
| SAVE_OBJECT_POSITIONS | F906 | LD A,(OBJECT_COUNT) | Nothing to do if the knight's is the last record in use (the seventh) | |
| F909 | SUB $07 | |||
| F90B | RET Z | |||
| F90C | LD IX,RECORDS | IX = the first record after his; B = how many there are | ||
| F910 | LD B,A | |||
| SAVE_OBJECT_POSITIONS_0 | F911 | LD A,(IX+OBJ_KIND) | Stop at the first door (kind 1 in +12) | |
| F914 | AND $0F | |||
| F916 | CP $01 | |||
| F918 | RET Z | |||
| F919 | PUSH BC | HL = the thing's entry plus 3: six bytes a number, counted on from just below the table; kept on the stack | ||
| F91A | LD B,(IX+OBJ_NUMBER) | |||
| F91D | LD DE,$0006 | |||
| F920 | LD HL,$A921 | |||
| SAVE_OBJECT_POSITIONS_1 | F923 | ADD HL,DE | ||
| F924 | DJNZ SAVE_OBJECT_POSITIONS_1 | |||
| F926 | PUSH HL | |||
| F927 | LD A,(IX+OBJ_STATE) | B = its behaviour byte (+14); C = 8, facing +x, for the mirror routines | ||
| F92A | LD B,A | |||
| F92B | LD C,$08 | |||
| F92D | AND $0F | |||
| F92F | CP $0B | Behaviour 11, the wraith: frames turned round (bit 5)? Turn them back (MIWRAI) | ||
| F931 | JR NZ,SAVE_OBJECT_POSITIONS_2 | |||
| F933 | BIT 5,B | |||
| F935 | CALL NZ,MIWRAI | |||
| F938 | JR SAVE_OBJECT_POSITIONS_3 | |||
| SAVE_OBJECT_POSITIONS_2 | F93A | CP $07 | Behaviour 7, the troll: the same (MITRO) | |
| F93C | JR NZ,SAVE_OBJECT_POSITIONS_3 | |||
| F93E | BIT 5,B | |||
| F940 | CALL NZ,MITRO | |||
| SAVE_OBJECT_POSITIONS_3 | F943 | PUSH IX | Copy x, y and z (+6 to +8) into the entry | |
| F945 | POP HL | |||
| F946 | LD DE,$0006 | |||
| F949 | ADD HL,DE | |||
| F94A | POP DE | |||
| F94B | LD BC,$0003 | |||
| F94E | LDIR | |||
| F950 | POP BC | On to the next record | ||
| F951 | LD DE,$0014 | |||
| F954 | ADD IX,DE | |||
| F956 | DJNZ SAVE_OBJECT_POSITIONS_0 | |||
| F958 | RET | After the last record (never reached in the build's sessions) | ||
|
Measured in the simulator: a thing's +6 and +8 changed in room 20, then LIFE set to 0; after this routine the thing's entry held the new values.
|
||||
| Prev: F7C4 | Up: Map | Next: F959 |