Prev: F906 Up: Map Next: FA74
F959: Settle what happens when a moving object runs into one that is not a door
Used by the routine at BUMPED.
Jumped to from BUMPED when the move tried for the object being updated -- the mover: its record at WORK_RECORD, its number in THIS_RECORD and a working copy of it from IY+$64 -- would overlap a record that is not a door: the other, at IX, its number in FOUND_RECORD. The kind bytes (+12) of the two decide, in this order.
A mover with bit 4 of its kind byte hurts what it touches: the troll and the bouncing balls (SPRITE7E88). If the other is the knight he loses 10 LIFE, except on a room's first pass (bit 2 of GAME_FLAGS). If the other is not a still thing (+16), it is knocked -- bit 4 of its +14 and the direction $12 make its next update a hop upward -- and the mover vanishes where it is (bit 5 of its +16). Against a still thing the tests go on.
When the knight walks into something whose kind byte has bit 4, he loses 10 LIFE, the other vanishes, and his move carries on as if it had not been there.
Bit 7 of the kind byte marks a fighter: the knight and nearly every creature. A fighter other than the knight that walks into him takes 1 LIFE; the knight walking into a fighter loses 1 LIFE himself, unless his sword is out (bit 1 of GAME_FLAGS, the striking half of the fight animation, KNIGHT_CONTROLS). Then a fighter that can be killed (bit 6: the guards, the ghosts and the troll) has one of its strikes taken: the counter FIND_OBSTACLE gave it, one of the six STRIKES_LEFT, each 4 when the room was entered. At none left, a guard (behaviour 6, 9 or 10) is left lying as its helmet (SPRITEA4B8), a thing that can be picked up; anything else vanishes. That never happened in the build's sessions. Staged in the simulator -- the counters set to 1, the guard of room 29 put in front of the knight, and B and Y held -- the guard became the helmet.
After the fighters: a creature of behaviour 13 (the ghost, SPRITE5B30) takes any thing that can be picked up that it runs into: the thing vanishes, and its entry in the object table is moved to room $FE, out of the game (SET_THING_ROOM). A wraith (behaviour 11) that a thing of kind 6 or 10 runs into vanishes with it, both taken out of the game; that too never ran in the sessions, and was staged in room 28 by dropping the kind-6 thing onto the wraith. Anything that runs into a kind-7 object -- the floor of the pits in rooms 9 and 12 -- vanishes, and if it is the knight, LIFE goes to 0. Everything else goes on to MEET_DECOY.
OBJECTS_MEET F959 BIT 4,(IY+WORK_KIND-V) Does the mover hurt what it touches (bit 4 of its kind)?
F95D JR Z,OBJECTS_MEET_1
F95F BIT 2,(IY+GAME_FLAGS-V) Not on the room's first pass
F963 JR NZ,OBJECTS_MEET_0
F965 LD A,(FOUND_RECORD) The knight touched: 10 LIFE (the author's DECLI1)
F968 CP $07
F96A JR NZ,OBJECTS_MEET_1
F96C CALL DECLI1
OBJECTS_MEET_0 F96F LD A,(IX+OBJ_WEIGHT) A still thing: on to the next test
F972 AND $1F
F974 JR Z,OBJECTS_MEET_1
F976 SET 4,(IX+OBJ_STATE) Knock it: next time it moves by the direction $12, up
F97A LD (IX+OBJ_DIRECTION),$12
F97E LD IX,(WORK_RECORD) The mover vanishes
F982 SET 5,(IX+OBJ_WEIGHT)
F986 CALL WORKING_POSITION where it was, and is erased (ANIMATE_AND_MOVE)
F989 JP COMMIT_STEP
OBJECTS_MEET_1 F98C BIT 4,(IX+OBJ_KIND) Does the other hurt, and is the mover the knight?
F990 JR Z,OBJECTS_MEET_2
F992 LD A,(THIS_RECORD)
F995 CP $07
F997 JR NZ,OBJECTS_MEET_2
F999 CALL DECLI1 10 LIFE, and the other vanishes
F99C JR OTHER_VANISHES
OBJECTS_MEET_2 F99E BIT 7,(IY+WORK_KIND-V) Is the mover a fighter (bit 7)?
F9A2 JR Z,OBJECTS_MEET_8
F9A4 LD A,(THIS_RECORD) The knight: below
F9A7 CP $07
F9A9 JR Z,OBJECTS_MEET_4
F9AB LD A,(FOUND_RECORD) Another fighter: has it walked into the knight?
F9AE CP $07
F9B0 JR NZ,OBJECTS_MEET_8
OBJECTS_MEET_3 F9B2 LD A,$01 Take 1 LIFE (at DECLIF, DECLI1)
F9B4 CALL DECLIF
F9B7 JR OBJECTS_MEET_8
OBJECTS_MEET_4 F9B9 BIT 1,(IY+GAME_FLAGS-V) The knight: is his sword out?
F9BD JR NZ,OBJECTS_MEET_5
F9BF BIT 7,(IX+OBJ_KIND) No: a fighter touched costs him 1 LIFE
F9C3 JR NZ,OBJECTS_MEET_3
F9C5 JR OBJECTS_MEET_8
OBJECTS_MEET_5 F9C7 BIT 6,(IX+OBJ_KIND) Yes: can the other be killed (bit 6)?
F9CB JR Z,OBJECTS_MEET_8
F9CD LD L,(IY+STRIKES_AT-V) Take a strike off its counter (the address's low byte in IY+2)
F9D0 LD H,$FF
F9D2 DEC (HL)
F9D3 JR NZ,OBJECTS_MEET_8
F9D5 LD A,(IX+OBJ_STATE) None left: is it a guard (behaviour 6, 9 or 10)?
F9D8 AND $0F
F9DA CP $06
F9DC JR Z,OBJECTS_MEET_6
F9DE CP $09
F9E0 JR Z,OBJECTS_MEET_6
F9E2 CP $0A
F9E4 JR Z,OBJECTS_MEET_6
This entry point is used by the routine at MEET_DECOY.
OTHER_VANISHES F9E6 SET 5,(IX+OBJ_WEIGHT) OTHER_VANISHES: bit 5 of its +16
F9EA JR OBJECTS_MEET_7
OBJECTS_MEET_6 F9EC LD (IX+OBJ_SPRITE),$B8 The guard's helmet: its sprite, behaviour 0 with a hop, a fighter that can be picked up, direction $12
F9F0 LD (IX+OBJ_SPRITE+$01),$A4
F9F4 LD (IX+OBJ_STATE),$10
F9F8 LD (IX+OBJ_KIND),$A0
F9FC LD (IX+OBJ_DIRECTION),$12
OBJECTS_MEET_7 FA00 LD A,(THIS_RECORD) Finish the mover's move (BLOCKED_MOVE, MEET_DECOY)
FA03 PUSH AF
FA04 PUSH IX
FA06 CALL BLOCKED_MOVE
FA09 POP HL Redraw the other as the record being drawn (the number is stale: see below)
FA0A PUSH HL
FA0B POP IX
FA0D LD A,(FOUND_RECORD)
FA10 LD (THIS_RECORD),A
FA13 CALL REDRAW_OBJECT
FA16 POP AF THIS_RECORD back; the mover's update is done
FA17 LD (THIS_RECORD),A
FA1A RET
OBJECTS_MEET_8 FA1B LD A,(WORK_BEHAVIOUR) A behaviour-13 creature, the ghost, and a thing that can be picked up?
FA1E AND $0F
FA20 CP $0D
FA22 JR NZ,OBJECTS_MEET_9
FA24 BIT 5,(IX+OBJ_KIND)
FA28 JR NZ,OBJECTS_MEET_11
OBJECTS_MEET_9 FA2A LD A,(IX+OBJ_STATE) A wraith (behaviour 11) met by a thing of kind 6 or 10?
FA2D AND $0F
FA2F CP $0B
FA31 JR NZ,OBJECTS_MEET_12
FA33 LD A,(WORK_KIND)
FA36 AND $0F
FA38 CP $06
FA3A JR Z,OBJECTS_MEET_10
FA3C CP $0A
FA3E JR NZ,OBJECTS_MEET_12
OBJECTS_MEET_10 FA40 PUSH IX The thing leaves the game (room $FE) and vanishes...
FA42 LD IX,(WORK_RECORD)
FA46 LD C,$FE
FA48 CALL SET_THING_ROOM
FA4B SET 5,(IX+OBJ_WEIGHT)
FA4F POP IX
OBJECTS_MEET_11 FA51 LD C,$FE ...and so does the other
FA53 CALL SET_THING_ROOM
FA56 JR OTHER_VANISHES
OBJECTS_MEET_12 FA58 LD A,(IX+OBJ_KIND) Kind 7, the pit floor?
FA5B AND $0F
FA5D CP $07
FA5F JR NZ,MEET_DECOY
FA61 LD IX,(WORK_RECORD) IX = the mover
FA65 LD A,(THIS_RECORD) The knight: LIFE 0
FA68 CP $07
FA6A JR NZ,MOVER_VANISHES
FA6C LD HL,$0000
FA6F LD (LIFE_TENS),HL
FA72 JR MOVER_VANISHES Over the five bytes at SKIPPED_REMOVAL
When something has vanished, or a guard become a helmet, the mover's move is finished at MEET_DECOY's BLOCKED_MOVE and the other is redrawn -- erased, in fact, as it is now hidden -- with THIS_RECORD set to the other's number for REDRAW_OBJECT. The number is read from FOUND_RECORD after the mover's own redraw has used that byte for its sprite's width in bytes (DRAW_SPRITE), so it is wrong: 3, not 19, when the knight met the troll in room 2 in the simulator. It only changes which record REDRAW_OBJECT leaves out of the redraw. A vanished thing is hidden anyway; a helmet is not, and is drawn once as if in front of itself -- measured with a guard killed by fighting in room 77: one pixel differs from a corrected run, for one pass.
Prev: F906 Up: Map Next: FA74