Prev: 8D99 Up: Map Next: 8E85
8D9D: Move a character one step
Used by the routine at DO_RUN.
Called for every character that moves, the player included, with the direction in ACTION. Watched directly: a single turn in which the player only typed INVENTORY ran this 21 times for nine other characters, each wandering on its own -- which is The Hobbit's independent cast, seen from the inside.
For the player -- told apart by ACTING being zero -- the codes observed are 1 north, 2 south, 3 east, 9 up and 10 down. West was not observed because it was blocked where the test stood. The rest follow the order of DIRECTION_WORDS, which DIRECTION_WORD indexes by the same code: 4 west, 5 northeast, 6 northwest, 7 southeast, 8 southwest.
MOVE 8D9D CALL TOO_DARK In the dark, the direction asked for is thrown away for a random one from 1 to 10
8DA0 JR NC,MOVE_ACTOR
8DA2 LD A,$09
8DA4 CALL RANDOM_POSITIVE
8DA7 INC A
8DA8 LD (ACTION),A
This entry point is used by the routines at GO_THROUGH and SWIM_RIVER.
MOVE_ACTOR 8DAB LD IY,(ACTOR) Is the actor held by anything?
8DAF LD A,(IY+$01)
8DB2 CP $FF
8DB4 JR Z,MOVE_0
8DB6 CALL GET_OBJECT Held by a thing, not a character: cannot move
8DB9 BIT 6,(IX+$07)
8DBD JR Z,MOVE_1
8DBF LD (IY+$01),$FF Held by a character: let go
MOVE_0 8DC3 LD A,(ACTING) The actor's size with everything it carries, for fitting through the way out
8DC6 CALL SIZE_HELD
8DC9 ADD A,(IY+$02)
8DCC LD (ACTOR_SIZE),A
8DCF LD A,(ACTION) Is there an exit in that direction?
8DD2 CALL FIND_EXIT
8DD5 CP $FF
8DD7 JR NZ,MOVE_2
MOVE_1 8DD9 CALL TOO_DARK No way through. In the light, the ordinary refusal
8DDC JP NC,REFUSE
8DDF CALL FOR_REAL In the dark the player falls: halve byte 5 of the player's record...
8DE2 LD IX,PLAYER
8DE6 AND A
8DE7 LD HL,MSG_BUT_FALL_AND_HIT
8DEA RR (IX+$05)
8DEE JP NZ,RUN_MESSAGE_HL ...and while anything is left, "but fall and hit your HEAD." -- six falls are survived
8DF1 LD HL,MSG_BUT_FALL_AND_SMASH The seventh empties it: "but fall and smash your skull.", and PLAYER_DIES
8DF4 CALL RUN_MESSAGE_HL
8DF7 JP PLAYER_DIES
MOVE_2 8DFA LD A,(IX+$02) The exit leads to location 0: nowhere yet
8DFD AND A
8DFE JR Z,MOVE_1
8E00 LD (DESTINATION),A Keep the destination; A = the object the way goes through
8E03 LD A,(IX+$01)
8E06 CALL CAN_PASS Can it be used (CAN_PASS)? 1 no, 2 too small, 3 no room there
8E09 DEC A
8E0A JR Z,MOVE_1
8E0C DEC A
8E0D JR Z,MOVE_5
8E0F DEC A
8E10 JR Z,MOVE_6
This entry point is used by the routine at MOVE_CONTENTS.
MOVE_THERE 8E12 CALL FOR_REAL Move: the actor's location becomes the destination
8E15 LD (IY+$10),B
8E18 LD A,(ACTING) And everything it holds goes too
8E1B CALL MOVE_CONTENTS
8E1E LD A,(ACTING) The rest is for the player only
8E21 CP $00
8E23 RET NZ
8E24 LD IX,ARRIVAL_HOOKS Run the place's arrival hook, if it has one (ARRIVAL_HOOKS)
8E28 LD A,(DESTINATION)
8E2B CALL FIND_RECORD
8E2E JR Z,ARRIVE
8E30 LD L,(IX+$01)
8E33 LD H,(IX+$02)
8E36 CALL RUN_ROUTINE
This entry point is used by the routine at AT_FOREST_RIVER.
ARRIVE 8E39 CALL TOO_DARK In the dark, that is all
8E3C RET C
8E3D LD A,(ACTING) A = the destination
8E40 AND A
8E41 LD A,(DESTINATION)
8E44 JR NZ,MOVE_4
8E46 LD HL,(DESTINATION_ROOM) Been here before? On at DESCRIBE_BRIEFLY. If not, mark the room visited (bit 6)
8E49 BIT 6,(HL)
8E4B JP NZ,DESCRIBE_BRIEFLY
8E4E SET 6,(HL)
8E50 PUSH AF
8E51 LD IX,VISIT_SCORES And score it (VISIT_SCORES)
8E55 CALL FIND_RECORD
8E58 JR Z,MOVE_3
8E5A PUSH DE
8E5B LD E,(IX+$01)
8E5E LD D,(IX+$02)
8E61 LD HL,(SCORE)
8E64 ADD HL,DE
8E65 LD (SCORE),HL
8E68 POP DE
MOVE_3 8E69 POP AF Then DESCRIBE_ROOM
MOVE_4 8E6A JP DESCRIBE_ROOM
MOVE_5 8E6D LD HL,MSG_IS_TOO_SMALL_FOR
8E70 JR MOVE_7
MOVE_6 8E72 LD IX,(DESTINATION_ROOM)
8E76 LD HL,MSG_IS_TOO_FULL_FOR
MOVE_7 8E79 PUSH HL
8E7A LD L,(IX+$02)
8E7D LD H,(IX+$03)
8E80 EX (SP),HL
8E81 CALL RUN_MESSAGE_HL
8E84 RET
Prev: 8D99 Up: Map Next: 8E85