Prev: D5D4 Up: Map Next: D63A
D5FE: 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.
D5FE LD A,($EBB7) Creature type (see EB46)
D601 CP $00
D603 JR Z,$D63A If no creature, skip to the next routine
D605 CALL $E16A This routine sets up data for creatures/warlocks appearing in Maroc's room (the A register normally contains creature type/number from EB46)
D608 LD A,($EBB8) Creature's horizontal position (in 4 pixel steps) in room, after entering through a door
D60B LD ($EB48),A Copy to graphic data buffer
D60E LD C,A
D60F LD A,($EBB9) Creature's vertical pixel position in room, after entering through a door
D612 SUB $0E 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
D614 LD ($EB4A),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:
D617 LD DE,$0004 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
D61A LD A,C (Superfluous instruction, as this value is immediately overwritten in next one)
D61B LD A,($EAFB) Left room corner section - floor/wall connector - graphic's horizontal position, in half character squares (4 pixel steps)
D61E CP C Compare with creature's horizontal position (also in 4 pixel steps)
D61F JR C,$D626
D621 LD DE,$0400 Creature is to the left of the room's left connector, so entering through a LEFT WALL DOOR
D624 JR $D62F
D626 LD A,($EAFC) Right wall corner section - floor/wall connector - graphic's horizontal position, in half character squares (4 pixel steps)
D629 CP C Compare with creature's horizontal position (also in 4 pixel steps) in room
D62A JR NC,$D62F
D62C LD DE,$FC00 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 (EB4C) and vertical (EB4D) 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)
D62F LD A,D
D630 LD ($EB4C),A Horizontal speed/direction
D633 LD A,E
D634 LD ($EB4D),A Vertical speed/direction
D637 JP $D6C7
Prev: D5D4 Up: Map Next: D63A