Prev: 8D6D Up: Map Next: 8DC4
8D77: Turn the controls into movement
Used by the routines at UPDATE_WIZARD, UPDATE_SERF and UPDATE_KNIGHT.
The other end of READ_CONTROLS. It takes the byte that routine returns and turns it into a signed step on each axis: bit 0 right, bit 1 left, bit 2 down, bit 3 up, each tested for being clear because a zero bit is a pressed one. B holds the distance, so left is B negated and right is B as it stands.
The character handler passes a step in B ($20), a decay in DE and a value in HL that is popped and never used. DECAY_HEADING takes the decay off the heading, STEER adds the step and clamps it to 32, and SCALE_SIGNED makes two pixels of 32. So all three characters reach full speed at once and differ in how they stop: the knight's decay of 3 slides him five pixels, the serf's 1 sixteen, the wizard's 32 not at all (measured in the simulator).
Input
IX The player
MOVE_PLAYER 8D77 LD A,($EA91) Keep the drop controller at $EE58 in the player's room, so MAIN_LOOP runs PUT_DOWN every pass.
8D7A LD ($EE59),A
8D7D PUSH BC
8D7E PUSH DE
8D7F PUSH HL
8D80 CALL TICK_LOW_NIBBLE
8D83 LD A,(IX+$02) Mark the record as being worked on.
8D86 OR $30
8D88 LD (IX+$02),A
8D8B CALL ACTOR_TO_WORKSPACE Position into the workspace, then read the controls.
8D8E CALL READ_CONTROLS
8D91 LD C,A
8D92 POP HL
8D93 LD DE,$0000
8D96 BIT 1,C Left: the step, negated.
8D98 JR NZ,MOVE_PLAYER_0
8D9A LD A,B
8D9B NEG
8D9D LD E,A
MOVE_PLAYER_0 8D9E BIT 0,C Right: the step as it is.
8DA0 JR NZ,MOVE_PLAYER_1
8DA2 LD E,B
MOVE_PLAYER_1 8DA3 BIT 2,C Down.
8DA5 JR NZ,MOVE_PLAYER_2
8DA7 LD D,B
MOVE_PLAYER_2 8DA8 BIT 3,C Up: negated again.
8DAA JR NZ,MOVE_PLAYER_3
8DAC LD A,B
8DAD NEG
8DAF LD D,A
MOVE_PLAYER_3 8DB0 POP HL
8DB1 CALL DECAY_HEADING Apply it...
8DB4 POP HL
8DB5 CALL STEER ...through STEER, so the change is gradual.
8DB8 CALL TEST_STEP_IN_ROOM
8DBB CALL CHECK_IN_DOORWAY
8DBE CALL TEST_STEP_BOXES
8DC1 JP APPLY_HEADING
Prev: 8D6D Up: Map Next: 8DC4