Prev: 8D15 Up: Map Next: 8E34
8D19: Move an actor (GO north, EAST, etc.)
Moves the current actor one step in the direction given by the action number (1-10: north, south, east, west, northeast, northwest, southeast, southwest, up, down). Used for the player's movement commands and for every character that moves.
IN THE DARK, Bilbo does not know which way he is going: the direction is replaced by a random one (8D1E). And if there is no exit that way, instead of 'you cannot go that way' he stumbles: his strength is halved, and he reads 'but fall and hit your head.', or, once his strength has dropped to nothing, 'but fall and smash your skull.' and dies.
A character being carried by another character (for example Bilbo carried by someone) is set down first. The size of the actor plus everything it carries is worked out (8D18). The exit must exist; if it has a door, the door must be open (or broken); Bilbo cannot use a door with bit 7 of its attributes set; and the actor must be no bigger than the door ('the window is too small for you to enter'). If the destination room has a capacity, there must be room ('the boat is too full for you to enter').
Then the actor's location becomes the destination and everything it carries moves with it (9B38). If the actor is Bilbo, the room-entry handler for the destination is run (C67D), and the room is described. The first time Bilbo enters a room, bit 6 of the room's flags is set, the room is described in full (958E), and if the room is in the scoring table at 8CEA its points are added to the score. On later visits the short description is used (9606).
8D19 CALL $954D Is Bilbo in the dark?
8D1C JR NC,$8D27 No: go on with the direction he chose
8D1E LD A,$09 In the dark: pick a random direction from 1 to 10 instead...
8D20 CALL $9BF4 A = a random number from 0 to A
8D23 INC A Increment A
8D24 LD ($B5D8),A ...and make it the action
This entry point is used by the routines at 8EA0 and A1FD.
8D27 LD IY,($B5FC) IY = the actor's record
8D2B LD A,(IY+$01) Is the actor being held by something?
8D2E CP $FF Is it nobody ($FF)?
8D30 JR Z,$8D3F No: skip
8D32 CALL $9B25 IX = the holder's record
8D35 BIT 6,(IX+$07) Is the holder a living character (bit 6)?
8D39 JR Z,$8D55 No (a box or barrel): the actor cannot just walk off
8D3B LD (IY+$01),$FF Yes: the actor gets down from the character carrying it
8D3F LD A,($B5DB) Work out the size of the actor plus everything it carries...
8D42 CALL $9C3D Call: Total size of an object's contents (9C3D)
8D45 ADD A,(IY+$02) ...plus its own size
8D48 LD ($8D18),A ...and keep it for the door and room checks
8D4B LD A,($B5D8) A = the direction
8D4E CALL $9E51 IX = the exit that way, if there is one
8D51 CP $FF Is there one?
8D53 JR NZ,$8D76 Yes: go and check it
8D55 CALL $954D No exit (or it cannot be used): is Bilbo in the dark?
8D58 JP NC,$9EBF No: just report the failure ("you cannot go that way")
8D5B CALL $9C99 Dry run? Then stop here
8D5E LD IX,$C00B IX = Bilbo's record
8D62 AND A Clear the carry flag
8D63 LD HL,$AC71 "but fall and hit your head."
8D66 RR (IX+$05) Halve Bilbo's strength
8D6A JP NZ,$72D4 If he has any left, print the message and return
8D6D LD HL,$AC7E Otherwise: "but fall and smash your skull."
8D70 CALL $72D4 Print it
8D73 JP $903C Bilbo is dead
8D76 LD A,(IX+$02) A = the exit's destination room
8D79 AND A Is there one?
8D7A JR Z,$8D55 No: the exit cannot be used
8D7C LD ($8D17),A Save the destination room number
8D7F LD A,(IX+$01) A = the exit's door, if any
8D82 AND A Is there a door?
8D83 JR Z,$8DA4 No door: go on to the destination room
8D85 CALL $9B25 IX = the door's record
8D88 LD A,(IX+$07) A = the door's flags
8D8B AND $28 Is it open (bit 5) or broken (bit 3)?
8D8D JR Z,$8D55 No: the door is in the way
8D8F LD A,($B5DB) Is the actor Bilbo?
8D92 AND A Is A zero?
8D93 JR NZ,$8D9B No: skip the next check
8D95 BIT 7,(IX+$04) Bit 7 of the door's attributes: a way Bilbo cannot use
8D99 JR NZ,$8D55 Set: he cannot go this way
8D9B LD A,($8D18) A = the size of the actor and its load
8D9E LD B,(IX+$02) B = the size of the door
8DA1 SUB B Compare them
8DA2 JR NC,$8E1C Too big: "the X is too small for you to enter"
8DA4 LD A,($8D17) A = the destination room
8DA7 LD B,A Keep it in B
8DA8 CALL $9B0C IX = its room record
8DAB LD ($8D15),IX Keep that for later
8DAF LD A,$FF Does the room have a capacity ($FF = unlimited)?
8DB1 CP (IX+$01) Compare with the byte at (IX+$01)
8DB4 JR Z,$8DC1 Unlimited: go ahead
8DB6 LD A,B A = the destination room
8DB7 CALL $9B96 A = the space left in it
8DBA LD C,A Keep it in C
8DBB LD A,($8D18) A = the size of the actor and its load
8DBE SUB C Compare them
8DBF JR NC,$8E21 Too big: "the X is too full for you to enter"
This entry point is used by the routine at 9B38.
8DC1 CALL $9C99 Dry run? Then stop here: the move would work
8DC4 LD (IY+$10),B Move the actor: its location becomes the destination
8DC7 LD A,($B5DB) Move everything the actor holds with it
8DCA CALL $9B38
8DCD LD A,($B5DB) Is the actor Bilbo?
8DD0 CP $00
8DD2 RET NZ No: a character has moved, and that is all
8DD3 LD IX,$C67D Look up the destination in the room-entry handlers
8DD7 LD A,($8D17)
8DDA CALL $9D12
8DDD JR Z,$8DE8 None: skip
8DDF LD L,(IX+$01) HL = the handler...
8DE2 LD H,(IX+$02)
8DE5 CALL $9AC7 ...and run it
This entry point is used by the routine at C6D9.
8DE8 CALL $954D Is Bilbo now in the dark?
8DEB RET C Yes: he sees nothing, so describe nothing
8DEC LD A,($B5DB) Is the actor Bilbo?
8DEF AND A
8DF0 LD A,($8D17) A = the room
8DF3 JR NZ,$8E19 No: describe it anyway (entry for other callers)
8DF5 LD HL,($8D15) HL = the room record
8DF8 BIT 6,(HL) Has Bilbo been here before (bit 6 of the room's flags)?
8DFA JP NZ,$9606 Yes: give the short description
8DFD SET 6,(HL) No: mark the room as visited
8DFF PUSH AF Save the room number
8E00 LD IX,$8CEA Look the room up in the scoring table
8E04 CALL $9D12
8E07 JR Z,$8E18 Not there: no points
8E09 PUSH DE
8E0A LD E,(IX+$01) DE = the points for this room
8E0D LD D,(IX+$02)
8E10 LD HL,($B5E8) Add them to the score
8E13 ADD HL,DE
8E14 LD ($B5E8),HL
8E17 POP DE
8E18 POP AF Restore the room number
8E19 JP $958E Describe the room in full
8E1C LD HL,$AD16 "<the door> is too small for you to enter"
8E1F JR $8E28
8E21 LD IX,($8D15) IX = the destination room record
8E25 LD HL,$AD21 "<the room> is too full for you to enter"
8E28 PUSH HL
8E29 LD L,(IX+$02) Push the room's (or door's) words as the message parameter
8E2C LD H,(IX+$03) H = (IX+3)
8E2F EX (SP),HL
8E30 CALL $72D4 Print the message
8E33 RET Done
Prev: 8D15 Up: Map Next: 8E34