Routines |
Prev: 50218 | Up: Map | Next: 50433 |
Used by the routine at 50218.
|
||||
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 27532. 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 31744.
|
||||
50272 | LD A,0 | Set number of creatures in current room to 0 | ||
50274 | LD (60342),A | |||
50277 | LD HL,(56048) | Address pointer for room creature data table at 27532 | ||
50280 | LD A,(60087) | Get room number | ||
50283 | DEC A | Offset starts from 0 not 1, so reduce by 1 | ||
50284 | LD E,A | Create offset for data sets | ||
50285 | LD D,0 | |||
50287 | ADD HL,DE | Add to base address at 27532 so that pointer is at current room's creatures | ||
Check for any GUARDIANS OF CHAOS in the current room
|
||||
50288 | LD A,(HL) | Get the creature byte for this room | ||
50289 | LD (60343),A | ...and store | ||
50292 | AND %11000000 | Top two bits (6 & 7) contain the count of any guardians of chaos in the room | ||
50294 | JR Z,50318 | If there aren't any, skip to the next check | ||
Set up GUARDIANS OF CHAOS in the current room
|
||||
50296 | RLA | Shift top two bits into bits 0 & 1 to get the guardian of chaos room count (1-3) | ||
50297 | RLA | |||
50298 | RLA | |||
50299 | AND 3 | |||
50301 | LD (60145),A | Store the current room's creature count for this creature | ||
50304 | LD A,8 | Creature type = 8 (guardian of chaos) | ||
50306 | CALL 57706 | Set up this creature's data (room position & graphics) | ||
50309 | CALL 57520 | Copy the creature's data into one of the room item data sets at 31744 | ||
50312 | LD A,(60145) | Retrieve the count of these creatures for the current room | ||
50315 | DEC A | ...and reduce by 1 | ||
50316 | JR NZ,50301 | If count of this creature in the room is still > 0, repeat for others | ||
Check for any GOBLIN WARRIORS in the current room
|
||||
50318 | LD A,(60343) | Retrieve the room data byte containing the creature information | ||
50321 | AND %00110000 | Bits 4 & 5 contain the count of any goblin warriors in this room | ||
50323 | JR Z,50348 | If there aren't any, skip to the next check | ||
Set up GOBLIN WARRIORS in the current room
|
||||
50325 | RRA | Shift bits into bits 0 & 1 to get the goblin warrior count (1-3) | ||
50326 | RRA | |||
50327 | RRA | |||
50328 | RRA | |||
50329 | AND 3 | |||
50331 | LD (60145),A | Store the current room's creature count for this creature | ||
50334 | LD A,9 | Creature type = 9 (goblin warrior) | ||
50336 | CALL 57706 | Set up this creature's data (room position & graphics) | ||
50339 | CALL 57520 | Copy the creature's data into one of the room item data sets at 31744 | ||
50342 | LD A,(60145) | Retrieve the count of these creatures for the current room | ||
50345 | DEC A | ...and reduce by 1 | ||
50346 | JR NZ,50331 | If count of this creature in the room is still > 0, repeat for others | ||
Check for any GOBLIN MISSILE THROWERS in the current room
|
||||
50348 | LD A,(60343) | Retrieve the room data byte containing the creature information | ||
50351 | AND %00001100 | Bits 2 & 3 contain the count of any goblin missile throwers in this room | ||
50353 | JR Z,50376 | If there aren't any, skip to the next check | ||
Set up GOBLIN MISSILE THROWERS in the current room
|
||||
50355 | RRA | Shift bits into bits 0 & 1 to get the goblin missile throwers count (1-3) | ||
50356 | RRA | |||
50357 | AND 3 | |||
50359 | LD (60145),A | Store the current room's creature count for this creature | ||
50362 | LD A,10 | Creature type = 10 (goblin missile thrower) | ||
50364 | CALL 57706 | Set up this creature's data (room position & graphics) | ||
50367 | CALL 57520 | Copy the creature's data into one of the room item data sets at 31744 | ||
50370 | LD A,(60145) | Retrieve the count of these creatures for the current room | ||
50373 | DEC A | ...and reduce by 1 | ||
50374 | JR NZ,50359 | If count of this creature in the room is still > 0, repeat for others | ||
Check for any WRAITHS in the current room
|
||||
50376 | LD A,(60343) | Retrieve the room data byte containing the creature information | ||
50379 | AND %00000011 | Bits 0 & 1 contain the count of any wraiths in this room, so filter out the other bits | ||
50381 | JR Z,50400 | If there aren't any, skip these setup instructions | ||
Set up WRAITHS in the current room
|
||||
50383 | LD (60145),A | Store the current room's creature count for this creature | ||
50386 | LD A,11 | Creature type = 11 (wraith) | ||
50388 | CALL 57706 | Set up this creature's data (room position & graphics) | ||
50391 | CALL 57520 | Copy the creature's data into one of the room item data sets at 31744 | ||
50394 | LD A,(60145) | Retrieve the count of these creatures for the current room | ||
50397 | DEC A | ...and reduce by 1 | ||
50398 | JR NZ,50383 | 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
|
||||
50400 | LD A,(60340) | |||
50403 | ADD A,64 | Add 64 to the warlock appearance timer | ||
50405 | JR C,50410 | |||
50407 | LD (60340),A | |||
50410 | LD A,(60341) | |||
50413 | ADD A,128 | Add 128 to the wandering creature timer | ||
50415 | JR C,50420 | |||
50417 | LD (60341),A | |||
Finish the creature data set:
|
||||
50420 | LD HL,(60094) | Address pointer to room item (creature) data set at 31744 | ||
50423 | LD (HL),255 | Mark the start of the next set with an end-of-data byte | ||
50425 | LD (60274),HL | ...and store the address pointer to the next set, ready for more data | ||
50428 | LD A,0 | |||
50430 | LD (60343),A | Reset the number-of-creatures-in-room counter to zero |
Prev: 50218 | Up: Map | Next: 50433 |