Prev: DDA1 Up: Map Next: DE7F
DE4C: Identify objects for current room
Used by the routines at C42A, CEB1 and D019.
Input
B Room number (from EAB7)
HL Address pointer to start of room item data at 736F
C Object number in table at 736F (starts at #1)
This routine uses the room object table at 736F and has a dual function:
  • Upon room entry, the routine checks for any objects in the room (first byte of set = room number)
  • The routine can also identify an object's data set from its object number
Depending on which check is needed, the B or C register is set before this routine is called, with the other set to zero.
In either case, once the item data is found, its details & current 'state' are copied into the object data set buffer at EB85.
DE4C LD A,($EB84) Counter. Starts at 0.
DE4F INC A Room/object numbers start from 1 so we need to immediately increment the counter for the first data set...
DE50 LD ($EB84),A ...and re-store
DE53 LD A,(HL) First byte of data set
DE54 CP $FF
DE56 JR NZ,$DE5D
DE58 LD ($EB84),A We've reached the end of the list - set counter byte to 255...
DE5B JR $DEB6 ...and jump straight to RET
There are data sets still to check:
DE5D LD A,C Are we doing the check against an object number or a room number?
DE5E CP $00
DE60 JR NZ,$DE68 Run one of the next two checks depending on whether the B or the C register contains the value to check
ROOM NUMBER CHECK
DE62 LD A,(HL) C register is 0 so it's a room number check. Get the first byte of the room object set (this is the room number of the object)
DE63 CP B Current room number - is the object in this room?
DE64 JR Z,$DE7F If so, we've found an object in the room so jump to next routine to deal with it
DE66 JR $DE6E
OBJECT NUMBER CHECK
DE68 LD A,($EB84) As we know the object number (data set number), we just need to perform the check against the incremental counter to find its data
DE6B CP C Check object number set against counter
DE6C JR Z,$DE7F If we've found it, jump to the next routine to handle its data
Object not found in this set after one of the above checks. Skip forward to next data set.
Data sets vary in size, so this routine identifies the number of bytes that need skipping to get to the next set.
DE6E LD DE,$0007 Jump forward to 8th byte in original data set
DE71 ADD HL,DE
DE72 LD A,(HL) Byte indicates number of additional 4 byte data sets this item has
DE73 INC HL
DE74 LD DE,$0004 4 bytes for each set to skip
DE77 CP $00 Have we skipped all the additional 4-byte sets for this item?
DE79 JR Z,$DE4C If so, go and check for the next object in the list
DE7B ADD HL,DE Skip this 4-byte data set
DE7C DEC A Decrement the data set counter
DE7D JR $DE77 ...Until they're all skipped.
Prev: DDA1 Up: Map Next: DE7F