Routines |
Prev: 55616 | Up: Map | Next: 55818 |
Evaluates objects in data sets at 31744 and store state of any DOORS, CREATURES or OBJECTS.
|
||||
55628 | LD A,(60080) | Room number | ||
55631 | CP 0 | |||
55633 | JP Z,50870 | If it's zero, it means that room's all set up, so jump to the main game cycle | ||
55636 | LD A,0 | |||
Start preparing the room items that will need dealing with:
|
||||
55638 | LD (60343),A | Set the creatures in the room to zero | ||
55641 | LD HL,(56046) | Pointer to start of the room data sets at 31744 | ||
55644 | LD DE,16 | Skip pointer past first data set, which deals with the room/viewport setup | ||
55647 | ADD HL,DE | |||
Check each data set in the room item list at 31744 in turn:
|
||||
55648 | LD A,(HL) | Get first byte of data set | ||
55649 | CP 255 | Check for end-of-data marker | ||
55651 | JP Z,55818 | If found, skip copying routine | ||
55654 | LD DE,16 | |||
55657 | CP 0 | If first data byte <> 0, there's some data to copy for this set | ||
55659 | JR NZ,55664 | |||
55661 | ADD HL,DE | First data byte is zero, so skip to next data set and keep checking data sets | ||
55662 | JR 55648 | |||
55664 | LD BC,16 | 16 bytes to copy | ||
55667 | LD DE,60227 | Start of buffer (destination) | ||
55670 | LDIR | |||
55672 | LD (60094),HL | Store data pointer ready at the start of the next data bank | ||
Check what the item in the data set is:
|
||||
55675 | LD A,(60227) | Get first byte of data set which indicates the item type | ||
55678 | CP 2 | Door | ||
55680 | JR Z,55692 | |||
55682 | CP 4 | Interactable object | ||
55684 | JR Z,55706 | |||
55686 | CP 3 | Creature | ||
55688 | JR Z,55765 | |||
55690 | JR 55648 | If not one of these three items, no extra processing needed at this point, so jump back and continue copying data sets | ||
DOOR
|
||||
55692 | LD HL,(60228) | Address pointer to door connector data set in the table at 26512 | ||
55695 | INC HL | Move to 3rd byte of data set | ||
55696 | INC HL | |||
55697 | LD A,(60238) | This is the door properties byte | ||
55700 | LD (HL),A | Store in the 3rd byte of the room connector data set | ||
55701 | LD HL,(60094) | Retrieve address pointer to current data set at 31744 | ||
55704 | JR 55648 | ...and continue to check data sets | ||
INTERACTABLE OBJECT
|
||||
55706 | LD HL,(60228) | Address pointer to object data set in the table at 29551 | ||
55709 | LD A,(60087) | Get room number... | ||
55712 | LD (HL),A | Store in object set as the room number for this item (first byte of set) | ||
55713 | INC HL | Move to the next item data byte... | ||
55714 | LD (60228),HL | ...And store the address pointer to this object's set | ||
Calculate item's vertical & horizontal co-ordinates (in relation to the room viewport's position) and store in the object's data set (in the table at 29551)
|
||||
55717 | LD HL,(60152) | Horizontal position of current screen viewport in 4-pixel/half-character steps - to be used as a calculation offset for the item's position | ||
55720 | EX DE,HL | Swap into DE | ||
55721 | LD HL,(60231) | Item graphic's horizontal position in room - H register contains value in 4-pixel/half-character steps (L = pixel fraction/overflow) | ||
55724 | SCF | Clear/reset the carry flag (set, then toggle) | ||
55725 | CCF | |||
55726 | SBC HL,DE | Subtract the offset to get the item's room position | ||
55728 | LD A,H | Get the high byte (contains the object's adjusted horizontal position in 4-pixel steps) | ||
55729 | LD HL,(60228) | |||
55732 | LD (HL),A | Store as the 2nd byte of the object's data set at 29551 | ||
55733 | INC HL | Move address pointer to next byte (which stores the item's vertical pixel position) | ||
55734 | LD (60228),HL | Store the address pointer | ||
55737 | LD HL,(60150) | Get vertical room pixel position | ||
55740 | EX DE,HL | Swap into DE | ||
55741 | LD HL,(60233) | Item graphic's vertical position in room - H register contains value in pixels (L = pixel fraction/overflow) | ||
55744 | SCF | Clear/reset the carry flag (set, then toggle) | ||
55745 | CCF | |||
55746 | SBC HL,DE | Subtract the offset to get the item's room position in pixels | ||
55748 | LD A,H | Get the high byte (contains the adjusted vertical pixel position) | ||
55749 | LD HL,(60228) | Retrieve the address pointer to the 3rd byte of the object's data set at 29551 | ||
55752 | LD (HL),A | Store the item's vertical room position | ||
55753 | INC HL | Move along to the next byte of the object's data set | ||
Store item properties byte:
|
||||
55754 | LD A,(60238) | Get item properties byte | ||
55757 | AND 239 | Reset bit 4 (if set, indicates item carried by servant). In most cases it's unlikely for Maroc to be able to switch room while the servant spell is active however |
||
55759 | LD (HL),A | Store in item data set | ||
55760 | LD HL,(60094) | Restore pointer to data set at 31744 | ||
55763 | JR 55648 | Continue to copy data sets | ||
CREATURE
|
||||
55765 | LD B,0 | The B register will hold a value indicating the type and number of creatures in the room | ||
55767 | LD A,(60238) | Creature properties byte | ||
55770 | AND 224 | Check if any of the top 3 bits are set: Bit 6/7 = creature materializing Bit 5 = creature disintegrating |
||
55772 | JR NZ,55805 | If any of these are set, the creature isn't considered present, so don't add this creature's value | ||
55774 | LD A,(60230) | Creature type | ||
55777 | CP 8 | Byte value < 8, it's a warlock (no action to take as they're not 'stored') | ||
55779 | JR C,55805 | |||
55781 | CP 8 | |||
55783 | JR NZ,55787 | |||
55785 | LD B,64 | Byte value = 8, it's a guardian of chaos (set value = 64, these creatures are stored in bits 6 & 7) | ||
55787 | CP 9 | |||
55789 | JR NZ,55793 | |||
55791 | LD B,16 | Byte value = 9, it's a goblin warrior (set value = 16, these creatures are stored in bits 4 & 5) | ||
55793 | CP 10 | |||
55795 | JR NZ,55799 | |||
55797 | LD B,4 | Byte value = 10 it's a goblin missile thrower (set value = 4, these creatures are stored in bits 2 & 3) | ||
55799 | CP 11 | |||
55801 | JR NZ,55805 | |||
55803 | LD B,1 | Byte value = 11, it's a wraith (set value = 1, these creatures are stored in bits 0 & 1) | ||
Add this creature's value (in B register) to the creature data byte for this room.
|
||||
55805 | LD A,(60343) | Creature data byte for room | ||
55808 | ADD A,B | Add the creature type value | ||
55809 | LD (60343),A | ...and re-store | ||
55812 | LD HL,(60094) | Retrieve address pointer to the next data set (at 31744) | ||
55815 | JP 55648 |
Prev: 55616 | Up: Map | Next: 55818 |