Prev: F595 Up: Map Next: F7B0
F65C: Show the frame, then move the object and redraw it
The rest of the author's ANIM (KNIGHT_CONTROLS), and then the common end of every object's update: INPE sets the sprite, KON6 takes the direction, NOPROP adds gravity, NOG makes the direction into the three axes of the step, and the step is tried against every other record (FIND_OBSTACLE). If something is in the way, BUMPED deals with it: a door may take the knight to another room, anything else is met (OBJECTS_MEET) and the step tried again axis by axis (MEET_DECOY), which comes back to TRY_STEP here. When the step is clear the record gets the new state and place (ISO_MOVE), and the object is redrawn (REDRAW_OBJECT).
Gravity: unless the direction has bit 1 (rising), the up bit is cleared (by the constant $EF in IY+$0B) and down added (from the constant in IY+$05), so everything falls two units a pass until it is stopped. A fall sets bit 7 of the state, in the air, and while that is set CHE3D does not run the object's own case but keeps it going the way +18 says. A fall keeps only the down bit (and the low two), so everything falls straight down, the knight at the end of a jump too (measured). The air ends when the fall is stopped, or when the count in +15 runs out (it is 1 while falling, 3 for a bounce), and if it was in the air at the start of the pass and did not move at all, the object is updated again at once (CHE3D) as a thing on the ground. Bit 6 of IY+$7B, which MEET_DECOY sets when the step was stopped by an object of kind 2 or 3, makes it bounce: three passes going up.
The knight's screen position is worked out afresh on each pass: his record is first put back to one fixed point on the floor (50, 78, 50) and its place on the screen, and ISO_MOVE moves him from there. Everything else is moved from where it was.
On the first pass in a room (bit 2 of IY+$17, which the room's entry sets and MAIN_LOOP clears) nothing moves: the direction is cleared, but all three axis bits are set, so the test runs on a box one unit up x, two down and one down y from where the object is, and whatever that meets is dealt with as usual (BUMPED); then the record is only drawn. What the offset box is for is not worked out.
Input
HL The first frame of the run
DE The size of one frame
B The frame, plus one
A The next frame
C The object's +17
ANIMATE_AND_MOVE F65C ADD HL,DE HL = the frame to show
This entry point is used by the routine at KNIGHT_CONTROLS.
ANIMATE_AND_MOVE_0 F65D DJNZ ANIMATE_AND_MOVE }
F65F LD B,A The last frame of the run
F660 LD A,C
F661 RRA
F662 RRA
F663 RRA
F664 AND $07
F666 CP B Past it: go back, and next time show frame 1
F667 LD A,C
F668 JR NC,ANIMATE_AND_MOVE_1
F66A AND $F8
F66C OR $81
F66E JR ANIMATE_AND_MOVE_2
ANIMATE_AND_MOVE_1 F670 AND $F8 Otherwise the next frame
F672 OR B
ANIMATE_AND_MOVE_2 F673 LD (IX+OBJ_FRAME),A
F676 POP BC The way to go
This entry point is used by the routines at CHE3D, CREATURE_UPDATE and KNIGHT_CONTROLS.
SET_SPRITE_AND_MOVE F677 LD (IX+OBJ_SPRITE),L The author's INPE: the sprite is HL
F67A LD (IX+OBJ_SPRITE+$01),H
This entry point is used by the routines at CHE3D and CREATURE_UPDATE.
MOVE_IN_DIRECTION F67D LD A,C The author's KON6: the way to go is C
This entry point is used by the routine at CHE3D.
ADD_GRAVITY F67E BIT 1,A The author's NOPROP. Rising (bit 1): no gravity this pass
F680 JR NZ,SKIP_GRAVITY
F682 AND (IY+NO_RISE_MASK-V) Otherwise no up (IY+$0B holds $EF), and down (IY+$05 holds $23; its low two bits are not used)
F685 LD C,A
F686 LD A,(GRAVITY)
F689 AND $FC
F68B OR C
This entry point is used by the routine at CHE3D.
SKIP_GRAVITY F68C LD C,$00 The author's NOG. C will be the axes of the step
F68E BIT 2,(IY+GAME_FLAGS-V)
F692 JR Z,ANIMATE_AND_MOVE_3
F694 XOR A The first pass in a room: no way to go, but a test on all three axes
F695 LD C,$07
This entry point is used by the routine at CREATURE_UPDATE.
ANIMATE_AND_MOVE_3 F697 LD (WORK_DIRECTION),A The way to go this pass: IY+$71 (which MEET_DECOY may change) and IY+$7C (which it does not)
F69A LD (ASKED_DIRECTION),A
F69D LD B,A Down or up x: an x step (bit 0 of IY+$7B)
F69E AND $0C
F6A0 JR Z,ANIMATE_AND_MOVE_4
F6A2 SET 0,C
ANIMATE_AND_MOVE_4 F6A4 LD A,B Up or down: a step in height (bit 1)
F6A5 AND $30
F6A7 JR Z,ANIMATE_AND_MOVE_5
F6A9 SET 1,C
ANIMATE_AND_MOVE_5 F6AB LD A,B Up or down y: a y step (bit 2)
F6AC AND $C0
F6AE JR Z,ANIMATE_AND_MOVE_6
F6B0 SET 2,C
ANIMATE_AND_MOVE_6 F6B2 LD (IY+STEP_AXES-V),C IY+$7B = the axes of the step
This entry point is used by the routine at MEET_DECOY.
TRY_STEP F6B5 RES 7,(IY+STEP_AXES-V) MEET_DECOY comes back here: no door met yet (bit 7 of IY+$7B)
F6B9 LD C,(IY+STEP_AXES-V) B, D, H = where it would be after the step
F6BC CALL WORKING_POSITION
F6BF CALL STEP_ALL_AXES
F6C2 LD A,(STEP_AXES) Not moving: nothing to test
F6C5 AND $07
F6C7 JR Z,COMMIT_STEP
F6C9 CALL WORKING_SIZES With its sizes, does it meet anything? If so, see what (IX is what it met)
F6CC CALL FIND_OBSTACLE
F6CF JP C,BUMPED
This entry point is used by the routines at OBJECTS_MEET and MOVER_VANISHES.
COMMIT_STEP F6D2 LD IX,(WORK_RECORD) The step is clear. The record gets the state from the working copy
F6D6 LD A,(WORK_BEHAVIOUR)
F6D9 LD (IX+OBJ_STATE),A
F6DC BIT 2,(IY+GAME_FLAGS-V) The first pass in a room: just draw it
F6E0 JP NZ,REDRAW_THIS_OBJECT
F6E3 AND $0F The knight?
F6E5 CP $08
F6E7 JR NZ,ANIMATE_AND_MOVE_7
F6E9 LD (IX+OBJ_SCREEN_X),$74 Put his record back to the fixed point, so that his screen place comes out afresh
F6ED LD (IX+OBJ_SCREEN_Y),$22
F6F1 LD (IX+OBJ_X),$32
F6F5 LD (IX+OBJ_TOP),$4E
F6F9 LD (IX+OBJ_Z),$32
ANIMATE_AND_MOVE_7 F6FD CALL ISO_MOVE Move it: the new place, and the screen position from it
F700 LD E,(IX+OBJ_STATE) E = the state; D = the way it went (after any change by MEET_DECOY)
F703 LD D,(IY+WORK_DIRECTION-V)
F706 BIT 7,E On the ground, that becomes its way (+13)
F708 JR NZ,ANIMATE_AND_MOVE_8
F70A LD (IX+OBJ_DIRECTION),D
ANIMATE_AND_MOVE_8 F70D BIT 4,E Riding on something that moves (state bit 4): take its way (IY+RIDE_DIRECTION-V), keeping the low bits
F70F JR Z,ANIMATE_AND_MOVE_9
F711 LD A,D
F712 AND $03
F714 LD C,A
F715 LD A,(RIDE_DIRECTION)
F718 AND $FC
F71A OR C
F71B LD (IX+OBJ_DIRECTION),A
ANIMATE_AND_MOVE_9 F71E BIT 1,(IY+STEP_AXES-V) Moved in height, going down: falling
F722 JR Z,ANIMATE_AND_MOVE_10
F724 BIT 5,D
F726 JR Z,ANIMATE_AND_MOVE_10
F728 LD (IX+OBJ_COUNT),$01 In the air; keep going down (with the low bits)
F72C LD A,D
F72D AND $23
F72F SET 7,E
F731 LD B,A The knight counts the passes he falls for (IY+FALL_COUNT-V)
F732 LD A,(THIS_RECORD)
F735 CP $07
F737 LD A,B
F738 JR NZ,ANIMATE_AND_MOVE_12
F73A INC (IY+FALL_COUNT-V)
F73D JR ANIMATE_AND_MOVE_12
ANIMATE_AND_MOVE_10 F73F BIT 6,(IY+STEP_AXES-V) Stopped by an object of kind 2 or 3 (bit 6 of IY+$7B, from MEET_DECOY)
F743 JR Z,ANIMATE_AND_MOVE_11
F745 SET 7,E Bounce: in the air, going up for three passes
F747 LD (IX+OBJ_COUNT),$03
F74B LD B,$12
F74D JR ANIMATE_AND_MOVE_15
ANIMATE_AND_MOVE_11 F74F BIT 7,E On the ground: done
F751 JR Z,ANIMATE_AND_MOVE_16
F753 DEC (IX+OBJ_COUNT) In the air: count down, and at nought it is out of the air
F756 JR Z,ANIMATE_AND_MOVE_14
F758 LD A,D Keep going the way it went
ANIMATE_AND_MOVE_12 F759 LD B,A Mid-jump (state 5): the way asked for, before MEET_DECOY changed it
F75A LD A,E
F75B AND $0F
F75D CP $05
F75F JR NZ,ANIMATE_AND_MOVE_13
F761 LD B,(IY+ASKED_DIRECTION-V)
ANIMATE_AND_MOVE_13 F764 CP $08 The knight in the air with no step in height has landed
F766 JR NZ,ANIMATE_AND_MOVE_15
F768 BIT 1,(IY+STEP_AXES-V)
F76C JR NZ,ANIMATE_AND_MOVE_15
ANIMATE_AND_MOVE_14 F76E RES 7,E Out of the air; carry on the way +13 says
F770 LD (IX+OBJ_COUNT),$01
F774 LD B,(IX+OBJ_DIRECTION)
ANIMATE_AND_MOVE_15 F777 LD (IX+OBJ_COURSE),B Its way while in the air
F77A LD A,(STEP_AXES) It moved: keep the new state
F77D AND $07
F77F JR NZ,ANIMATE_AND_MOVE_16
F781 BIT 7,(IY+SECOND_POINT_ROW-V) It did not move, and was not in the air at the start of the pass: keep the state
F785 JR Z,ANIMATE_AND_MOVE_16
F787 RES 7,E It was in the air and could not move at all: out of the air, and update it again at once
F789 LD (IX+OBJ_STATE),E
F78C LD (IX+OBJ_COUNT),$01
F790 LD HL,(WORK_RECORD)
F793 JP CHE3D
ANIMATE_AND_MOVE_16 F796 LD A,E The new state
F797 LD (IX+OBJ_STATE),A
F79A AND $0F Anything but a thing lying (state 0) is redrawn
F79C JR NZ,REDRAW_THIS_OBJECT
F79E BIT 5,(IX+OBJ_WEIGHT) A thing that is carried too
F7A2 JR NZ,REDRAW_THIS_OBJECT
F7A4 LD A,(STEP_AXES) A thing lying still needs no redraw
F7A7 AND $07
F7A9 RET Z
This entry point is used by the routine at CREATURE_UPDATE.
REDRAW_THIS_OBJECT F7AA LD HL,(WORK_RECORD) Redraw the object, in its new place
F7AD JP REDRAW_OBJECT
Prev: F595 Up: Map Next: F7B0