Routines |
Prev: D940 | Up: Map | Next: DA0A |
Evaluates objects in data sets at 7C00 and store state of any DOORS, CREATURES or OBJECTS.
|
||||
D94C | LD A,($EAB0) | Room number | ||
D94F | CP $00 | |||
D951 | JP Z,$C6B6 | If it's zero, it means that room's all set up, so jump to the main game cycle | ||
D954 | LD A,$00 | |||
Start preparing the room items that will need dealing with:
|
||||
D956 | LD ($EBB7),A | Set the creatures in the room to zero | ||
D959 | LD HL,($DAEE) | Pointer to start of the room data sets at 7C00 | ||
D95C | LD DE,$0010 | Skip pointer past first data set, which deals with the room/viewport setup | ||
D95F | ADD HL,DE | |||
Check each data set in the room item list at 7C00 in turn:
|
||||
D960 | LD A,(HL) | Get first byte of data set | ||
D961 | CP $FF | Check for end-of-data marker | ||
D963 | JP Z,$DA0A | If found, skip copying routine | ||
D966 | LD DE,$0010 | |||
D969 | CP $00 | If first data byte <> 0, there's some data to copy for this set | ||
D96B | JR NZ,$D970 | |||
D96D | ADD HL,DE | First data byte is zero, so skip to next data set and keep checking data sets | ||
D96E | JR $D960 | |||
D970 | LD BC,$0010 | 16 bytes to copy | ||
D973 | LD DE,$EB43 | Start of buffer (destination) | ||
D976 | LDIR | |||
D978 | LD ($EABE),HL | Store data pointer ready at the start of the next data bank | ||
Check what the item in the data set is:
|
||||
D97B | LD A,($EB43) | Get first byte of data set which indicates the item type | ||
D97E | CP $02 | Door | ||
D980 | JR Z,$D98C | |||
D982 | CP $04 | Interactable object | ||
D984 | JR Z,$D99A | |||
D986 | CP $03 | Creature | ||
D988 | JR Z,$D9D5 | |||
D98A | JR $D960 | If not one of these three items, no extra processing needed at this point, so jump back and continue copying data sets | ||
DOOR
|
||||
D98C | LD HL,($EB44) | Address pointer to door connector data set in the table at 6790 | ||
D98F | INC HL | Move to 3rd byte of data set | ||
D990 | INC HL | |||
D991 | LD A,($EB4E) | This is the door properties byte | ||
D994 | LD (HL),A | Store in the 3rd byte of the room connector data set | ||
D995 | LD HL,($EABE) | Retrieve address pointer to current data set at 7C00 | ||
D998 | JR $D960 | ...and continue to check data sets | ||
INTERACTABLE OBJECT
|
||||
D99A | LD HL,($EB44) | Address pointer to object data set in the table at 736F | ||
D99D | LD A,($EAB7) | Get room number... | ||
D9A0 | LD (HL),A | Store in object set as the room number for this item (first byte of set) | ||
D9A1 | INC HL | Move to the next item data byte... | ||
D9A2 | LD ($EB44),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 736F)
|
||||
D9A5 | LD HL,($EAF8) | Horizontal position of current screen viewport in 4-pixel/half-character steps - to be used as a calculation offset for the item's position | ||
D9A8 | EX DE,HL | Swap into DE | ||
D9A9 | LD HL,($EB47) | Item graphic's horizontal position in room - H register contains value in 4-pixel/half-character steps (L = pixel fraction/overflow) | ||
D9AC | SCF | Clear/reset the carry flag (set, then toggle) | ||
D9AD | CCF | |||
D9AE | SBC HL,DE | Subtract the offset to get the item's room position | ||
D9B0 | LD A,H | Get the high byte (contains the object's adjusted horizontal position in 4-pixel steps) | ||
D9B1 | LD HL,($EB44) | |||
D9B4 | LD (HL),A | Store as the 2nd byte of the object's data set at 736F | ||
D9B5 | INC HL | Move address pointer to next byte (which stores the item's vertical pixel position) | ||
D9B6 | LD ($EB44),HL | Store the address pointer | ||
D9B9 | LD HL,($EAF6) | Get vertical room pixel position | ||
D9BC | EX DE,HL | Swap into DE | ||
D9BD | LD HL,($EB49) | Item graphic's vertical position in room - H register contains value in pixels (L = pixel fraction/overflow) | ||
D9C0 | SCF | Clear/reset the carry flag (set, then toggle) | ||
D9C1 | CCF | |||
D9C2 | SBC HL,DE | Subtract the offset to get the item's room position in pixels | ||
D9C4 | LD A,H | Get the high byte (contains the adjusted vertical pixel position) | ||
D9C5 | LD HL,($EB44) | Retrieve the address pointer to the 3rd byte of the object's data set at 736F | ||
D9C8 | LD (HL),A | Store the item's vertical room position | ||
D9C9 | INC HL | Move along to the next byte of the object's data set | ||
Store item properties byte:
|
||||
D9CA | LD A,($EB4E) | Get item properties byte | ||
D9CD | AND $EF | 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 |
||
D9CF | LD (HL),A | Store in item data set | ||
D9D0 | LD HL,($EABE) | Restore pointer to data set at 7C00 | ||
D9D3 | JR $D960 | Continue to copy data sets | ||
CREATURE
|
||||
D9D5 | LD B,$00 | The B register will hold a value indicating the type and number of creatures in the room | ||
D9D7 | LD A,($EB4E) | Creature properties byte | ||
D9DA | AND $E0 | Check if any of the top 3 bits are set: Bit 6/7 = creature materializing Bit 5 = creature disintegrating |
||
D9DC | JR NZ,$D9FD | If any of these are set, the creature isn't considered present, so don't add this creature's value | ||
D9DE | LD A,($EB46) | Creature type | ||
D9E1 | CP $08 | Byte value < 8, it's a warlock (no action to take as they're not 'stored') | ||
D9E3 | JR C,$D9FD | |||
D9E5 | CP $08 | |||
D9E7 | JR NZ,$D9EB | |||
D9E9 | LD B,$40 | Byte value = 8, it's a guardian of chaos (set value = 64, these creatures are stored in bits 6 & 7) | ||
D9EB | CP $09 | |||
D9ED | JR NZ,$D9F1 | |||
D9EF | LD B,$10 | Byte value = 9, it's a goblin warrior (set value = 16, these creatures are stored in bits 4 & 5) | ||
D9F1 | CP $0A | |||
D9F3 | JR NZ,$D9F7 | |||
D9F5 | LD B,$04 | Byte value = 10 it's a goblin missile thrower (set value = 4, these creatures are stored in bits 2 & 3) | ||
D9F7 | CP $0B | |||
D9F9 | JR NZ,$D9FD | |||
D9FB | LD B,$01 | 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.
|
||||
D9FD | LD A,($EBB7) | Creature data byte for room | ||
DA00 | ADD A,B | Add the creature type value | ||
DA01 | LD ($EBB7),A | ...and re-store | ||
DA04 | LD HL,($EABE) | Retrieve address pointer to the next data set (at 7C00) | ||
DA07 | JP $D960 |
Prev: D940 | Up: Map | Next: DA0A |