Routines |
Prev: 51420 | Up: Map | Next: 51611 |
Used by the routine at 51420.
|
||||||||
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:
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.
|
||||||||
51551 | LD A,C | Get room creature byte from table at 27532 | ||||||
Check for any GUARDIANS OF CHAOS
|
||||||||
51552 | AND %11000000 | Bits 6 & 7 - creature data for guardians of chaos | ||||||
51554 | JR Z,51564 | If there aren't any in this room, skip to the next check | ||||||
51556 | LD A,C | Retrieve room creature byte | ||||||
51557 | SUB 64 | Guardian of chaos is entering the room, so reduce the number of guardians of chaos in the adjacent room by 1 | ||||||
51559 | LD (HL),A | ...and re-store the reduced room creature byte value | ||||||
51560 | LD A,8 | Creature type number for guardian of chaos = 8 | ||||||
51562 | JR 51596 | |||||||
Check for any GOBLIN WARRIORS
|
||||||||
51564 | LD A,C | Retrieve room creature byte | ||||||
51565 | AND %00110000 | Bits 4 & 5 - creature data for goblin warriors | ||||||
51567 | JR Z,51577 | If there aren't any in this room, skip to the next check | ||||||
51569 | LD A,C | Retrieve room creature byte | ||||||
51570 | SUB 16 | Goblin warrior is entering the room, so reduce the number of goblin warriors in the adjacent room by 1 | ||||||
51572 | LD (HL),A | ...and re-store the reduced room creature byte value | ||||||
51573 | LD A,9 | Creature type number for goblin warrior = 9 | ||||||
51575 | JR 51596 | |||||||
Check for any GOBLIN MISSILE THROWERS
|
||||||||
51577 | LD A,C | Retrieve room creature byte | ||||||
51578 | AND %00001100 | Bits 2 & 3 - creature data for goblin missile throwers | ||||||
51580 | JR Z,51590 | If there aren't any in this room, skip to the next check | ||||||
51582 | LD A,C | Retrieve room creature byte | ||||||
51583 | SUB 4 | Goblin missile thrower is entering the room, so reduce the number of goblin missile throwers in the adjacent room by 1 | ||||||
51585 | LD (HL),A | ...and re-store the reduced room creature byte value | ||||||
51586 | LD A,10 | Creature type number for goblin missile thrower = 10 | ||||||
51588 | JR 51596 | |||||||
If the creature entering the room isn't one of the above, it must be a WRAITH (bits 0 & 1)
|
||||||||
51590 | LD A,C | Retrieve the creature byte | ||||||
51591 | SUB 1 | Wraith is entering the room, so reduce the number of wraiths in the adjacent room by 1 | ||||||
51593 | LD (HL),A | ...and re-store the reduced room creature byte value | ||||||
51594 | LD A,11 | Creature type number for wraith = 11 | ||||||
Creature type entering the room has been identified
|
||||||||
51596 | LD (60343),A | Store creature type | ||||||
51599 | LD A,(60232) | Get the door graphic horizontal position within current room, in half character (4-pixel) steps | ||||||
51602 | LD (60344),A | Copy this to the entering creature's horizontal room position, as this will be its entry point | ||||||
51605 | LD A,(60234) | Similarly, get the door vertical pixel position | ||||||
51608 | LD (60345),A | Copy to the entering creature's vertical room position |
Prev: 51420 | Up: Map | Next: 51611 |