Prev: C8DC Up: Map Next: C99B
C95F: Check which creatures are entering the room
Used by the routine at C8DC.
Input
C Creature data byte from room creature list at 6B8C
Checks at the previous routine have determined that a creature in an adjacent room will enter Maroc's room. Creatures appear one by one.
This routine determines what type of creature (from those in the adjacent room) will enter out of:
  • Guardian of chaos
  • Goblin warrior
  • Goblin missile thrower
  • Wraith
Creature type checks are made in the order below. So if there's a mix of creatures, this determines the priority of entry into the room.
C95F LD A,C Get room creature byte from table at 6B8C
Check for any GUARDIANS OF CHAOS
C960 AND %11000000 Bits 6 & 7 - creature data for guardians of chaos
C962 JR Z,$C96C If there aren't any in this room, skip to the next check
C964 LD A,C Retrieve room creature byte
C965 SUB $40 Guardian of chaos is entering the room, so reduce the number of guardians of chaos in the adjacent room by 1
C967 LD (HL),A ...and re-store the reduced room creature byte value
C968 LD A,$08 Creature type number for guardian of chaos = 8
C96A JR $C98C
Check for any GOBLIN WARRIORS
C96C LD A,C Retrieve room creature byte
C96D AND %00110000 Bits 4 & 5 - creature data for goblin warriors
C96F JR Z,$C979 If there aren't any in this room, skip to the next check
C971 LD A,C Retrieve room creature byte
C972 SUB $10 Goblin warrior is entering the room, so reduce the number of goblin warriors in the adjacent room by 1
C974 LD (HL),A ...and re-store the reduced room creature byte value
C975 LD A,$09 Creature type number for goblin warrior = 9
C977 JR $C98C
Check for any GOBLIN MISSILE THROWERS
C979 LD A,C Retrieve room creature byte
C97A AND %00001100 Bits 2 & 3 - creature data for goblin missile throwers
C97C JR Z,$C986 If there aren't any in this room, skip to the next check
C97E LD A,C Retrieve room creature byte
C97F SUB $04 Goblin missile thrower is entering the room, so reduce the number of goblin missile throwers in the adjacent room by 1
C981 LD (HL),A ...and re-store the reduced room creature byte value
C982 LD A,$0A Creature type number for goblin missile thrower = 10
C984 JR $C98C
If the creature entering the room isn't one of the above, it must be a WRAITH (bits 0 & 1)
C986 LD A,C Retrieve the creature byte
C987 SUB $01 Wraith is entering the room, so reduce the number of wraiths in the adjacent room by 1
C989 LD (HL),A ...and re-store the reduced room creature byte value
C98A LD A,$0B Creature type number for wraith = 11
Creature type entering the room has been identified
C98C LD ($EBB7),A Store creature type
C98F LD A,($EB48) Get the door graphic horizontal position within current room, in half character (4-pixel) steps
C992 LD ($EBB8),A Copy this to the entering creature's horizontal room position, as this will be its entry point
C995 LD A,($EB4A) Similarly, get the door vertical pixel position
C998 LD ($EBB9),A Copy to the entering creature's vertical room position
Prev: C8DC Up: Map Next: C99B