Prev: DE4C Up: Map Next: DEB7
DE7F: Identify state of object in current room
Used by the routines at CB00, DADC and DE4C.
Input
HL Address pointer to room/object data at 736F
The fifth byte of an object's data set (held in the object buffer at EB89) holds its state, which can change. For example a chest can be closed (state = 1) and be moved to state 2 (open).
This routine identifies the state of the object and copies the 4 bytes for this state into the additional buffer at EB8D.
DE7F LD ($EB82),HL Store address pointer (data at 736F)
DE82 LD DE,$EB85 Copy the first 8 bytes of this object's data into buffer at EB85
DE85 LD BC,$0008
DE88 LDIR
DE8A LD A,($EB89) State number of this object. All standard object 'sets' start at 1
DE8D LD C,A
DE8E CP $00
DE90 JR Z,$DEA9
DE92 DEC A Decrement state number
DE93 CP $00 Is this the object's current state?
DE95 JR Z,$DE9E
DE97 LD DE,$0004 If so, skip 4 bytes for each state the object has advanced to
DE9A LD B,A
DE9B ADD HL,DE
DE9C DJNZ $DE9B
Current object state found:
DE9E LD B,$04 Copy the 4 data bytes for this object state into the additional buffer at EB8D
DEA0 LD DE,$EB8D
DEA3 LD A,(HL)
DEA4 LD (DE),A
DEA5 INC HL
DEA6 INC DE
DEA7 DJNZ $DEA3
Skip over any additional data sets for this object
DEA9 LD A,($EB8C) Get the count of additional 4 byte data sets for this object
DEAC SUB C Subtract the current state number, whose data has already been copied over to the buffer
DEAD JR Z,$DEB6 If zero, there's no more data for this set - jump straight to RET
DEAF LD DE,$0004 ...Otherwise, skip over the remaining object states
DEB2 LD B,A
DEB3 ADD HL,DE
DEB4 DJNZ $DEB3
This entry point is used by the routine at DE4C.
DEB6 RET Object set now dealt with
Prev: DE4C Up: Map Next: DEB7