Prev: 54740 Up: Map Next: 54842
54782: Prepare data for any creatures that are entering Maroc's room
goblins following Maroc into a new room
For a creature entering the room - sets up graphics and determines its speed/direction of movement.
54782 LD A,(60343) Creature type (see 60230)
54785 CP 0
54787 JR Z,54842 If no creature, skip to the next routine
54789 CALL 57706 This routine sets up data for creatures/warlocks appearing in Maroc's room (the A register normally contains creature type/number from 60230)
54792 LD A,(60344) Creature's horizontal position (in 4 pixel steps) in room, after entering through a door
54795 LD (60232),A Copy to graphic data buffer
54798 LD C,A
54799 LD A,(60345) Creature's vertical pixel position in room, after entering through a door
54802 SUB 14 Adjust slightly by moving vertical position up 14 pixels. This puts the creatures in the doorway itself when they appear, rather than looking as if they've appeared a couple of feet into the room
54804 LD (60234),A Copy to graphic data buffer
Calculate which area of the room (left, right or back wall door) the creature is entering from, and set their speed/direction accordingly:
54807 LD DE,4 If the forthcoming checks don't hit a match, the creature is between the room floor/wall connectors, so entering through a BACK WALL DOOR
54810 LD A,C (Superfluous instruction, as this value is immediately overwritten in next one)
54811 LD A,(60155) Left room corner section - floor/wall connector - graphic's horizontal position, in half character squares (4 pixel steps)
54814 CP C Compare with creature's horizontal position (also in 4 pixel steps)
54815 JR C,54822
54817 LD DE,1024 Creature is to the left of the room's left connector, so entering through a LEFT WALL DOOR
54820 JR 54831
54822 LD A,(60156) Right wall corner section - floor/wall connector - graphic's horizontal position, in half character squares (4 pixel steps)
54825 CP C Compare with creature's horizontal position (also in 4 pixel steps) in room
54826 JR NC,54831
54828 LD DE,64512 Creature is to the right or the room's right (wall/floor) connector graphics - so entering through a RIGHT WALL DOOR
The result in the DE registers is used to set the creature's horizontal (60236) and vertical (60237) speed/direction
  • Back wall door: E (vertical) = +4, D (horizontal) = 0
  • Left wall door: E (vertical) = 0, D (horizontal) = +4
  • Right wall door: E (vertical) = 0, D (horizontal) = -4 (252)
54831 LD A,D
54832 LD (60236),A Horizontal speed/direction
54835 LD A,E
54836 LD (60237),A Vertical speed/direction
54839 JP 54983
Prev: 54740 Up: Map Next: 54842