Routines |
Prev: C42A | Up: Map | Next: C501 |
Used by the routine at C42A.
|
||||
Run after previous routine setting up interactable objects for the room has finished.
Identifies creatures (by creature type) in the current room using the table at 6B8C. Number and types of creature in each room is stored in a single byte. Sets up creature data and copies it into the room data sets at 7C00.
|
||||
C460 | LD A,$00 | Set number of creatures in current room to 0 | ||
C462 | LD ($EBB6),A | |||
C465 | LD HL,($DAF0) | Address pointer for room creature data table at 6B8C | ||
C468 | LD A,($EAB7) | Get room number | ||
C46B | DEC A | Offset starts from 0 not 1, so reduce by 1 | ||
C46C | LD E,A | Create offset for data sets | ||
C46D | LD D,$00 | |||
C46F | ADD HL,DE | Add to base address at 6B8C so that pointer is at current room's creatures | ||
Check for any GUARDIANS OF CHAOS in the current room
|
||||
C470 | LD A,(HL) | Get the creature byte for this room | ||
C471 | LD ($EBB7),A | ...and store | ||
C474 | AND %11000000 | Top two bits (6 & 7) contain the count of any guardians of chaos in the room | ||
C476 | JR Z,$C48E | If there aren't any, skip to the next check | ||
Set up GUARDIANS OF CHAOS in the current room
|
||||
C478 | RLA | Shift top two bits into bits 0 & 1 to get the guardian of chaos room count (1-3) | ||
C479 | RLA | |||
C47A | RLA | |||
C47B | AND $03 | |||
C47D | LD ($EAF1),A | Store the current room's creature count for this creature | ||
C480 | LD A,$08 | Creature type = 8 (guardian of chaos) | ||
C482 | CALL $E16A | Set up this creature's data (room position & graphics) | ||
C485 | CALL $E0B0 | Copy the creature's data into one of the room item data sets at 7C00 | ||
C488 | LD A,($EAF1) | Retrieve the count of these creatures for the current room | ||
C48B | DEC A | ...and reduce by 1 | ||
C48C | JR NZ,$C47D | If count of this creature in the room is still > 0, repeat for others | ||
Check for any GOBLIN WARRIORS in the current room
|
||||
C48E | LD A,($EBB7) | Retrieve the room data byte containing the creature information | ||
C491 | AND %00110000 | Bits 4 & 5 contain the count of any goblin warriors in this room | ||
C493 | JR Z,$C4AC | If there aren't any, skip to the next check | ||
Set up GOBLIN WARRIORS in the current room
|
||||
C495 | RRA | Shift bits into bits 0 & 1 to get the goblin warrior count (1-3) | ||
C496 | RRA | |||
C497 | RRA | |||
C498 | RRA | |||
C499 | AND $03 | |||
C49B | LD ($EAF1),A | Store the current room's creature count for this creature | ||
C49E | LD A,$09 | Creature type = 9 (goblin warrior) | ||
C4A0 | CALL $E16A | Set up this creature's data (room position & graphics) | ||
C4A3 | CALL $E0B0 | Copy the creature's data into one of the room item data sets at 7C00 | ||
C4A6 | LD A,($EAF1) | Retrieve the count of these creatures for the current room | ||
C4A9 | DEC A | ...and reduce by 1 | ||
C4AA | JR NZ,$C49B | If count of this creature in the room is still > 0, repeat for others | ||
Check for any GOBLIN MISSILE THROWERS in the current room
|
||||
C4AC | LD A,($EBB7) | Retrieve the room data byte containing the creature information | ||
C4AF | AND %00001100 | Bits 2 & 3 contain the count of any goblin missile throwers in this room | ||
C4B1 | JR Z,$C4C8 | If there aren't any, skip to the next check | ||
Set up GOBLIN MISSILE THROWERS in the current room
|
||||
C4B3 | RRA | Shift bits into bits 0 & 1 to get the goblin missile throwers count (1-3) | ||
C4B4 | RRA | |||
C4B5 | AND $03 | |||
C4B7 | LD ($EAF1),A | Store the current room's creature count for this creature | ||
C4BA | LD A,$0A | Creature type = 10 (goblin missile thrower) | ||
C4BC | CALL $E16A | Set up this creature's data (room position & graphics) | ||
C4BF | CALL $E0B0 | Copy the creature's data into one of the room item data sets at 7C00 | ||
C4C2 | LD A,($EAF1) | Retrieve the count of these creatures for the current room | ||
C4C5 | DEC A | ...and reduce by 1 | ||
C4C6 | JR NZ,$C4B7 | If count of this creature in the room is still > 0, repeat for others | ||
Check for any WRAITHS in the current room
|
||||
C4C8 | LD A,($EBB7) | Retrieve the room data byte containing the creature information | ||
C4CB | AND %00000011 | Bits 0 & 1 contain the count of any wraiths in this room, so filter out the other bits | ||
C4CD | JR Z,$C4E0 | If there aren't any, skip these setup instructions | ||
Set up WRAITHS in the current room
|
||||
C4CF | LD ($EAF1),A | Store the current room's creature count for this creature | ||
C4D2 | LD A,$0B | Creature type = 11 (wraith) | ||
C4D4 | CALL $E16A | Set up this creature's data (room position & graphics) | ||
C4D7 | CALL $E0B0 | Copy the creature's data into one of the room item data sets at 7C00 | ||
C4DA | LD A,($EAF1) | Retrieve the count of these creatures for the current room | ||
C4DD | DEC A | ...and reduce by 1 | ||
C4DE | JR NZ,$C4CF | If count of this creature in the room is still > 0, repeat for others | ||
When Maroc moves room, two 'creature appearance' timers are topped up slightly to avoid an immediate appearance in the new room:
In both cases, the carry check (JR C) ensures that the timer's bits don't wrap around to zero
|
||||
C4E0 | LD A,($EBB4) | |||
C4E3 | ADD A,$40 | Add 64 to the warlock appearance timer | ||
C4E5 | JR C,$C4EA | |||
C4E7 | LD ($EBB4),A | |||
C4EA | LD A,($EBB5) | |||
C4ED | ADD A,$80 | Add 128 to the wandering creature timer | ||
C4EF | JR C,$C4F4 | |||
C4F1 | LD ($EBB5),A | |||
Finish the creature data set:
|
||||
C4F4 | LD HL,($EABE) | Address pointer to room item (creature) data set at 7C00 | ||
C4F7 | LD (HL),$FF | Mark the start of the next set with an end-of-data byte | ||
C4F9 | LD ($EB72),HL | ...and store the address pointer to the next set, ready for more data | ||
C4FC | LD A,$00 | |||
C4FE | LD ($EBB7),A | Reset the number-of-creatures-in-room counter to zero |
Prev: C42A | Up: Map | Next: C501 |