Prev: 9B80 Up: Map Next: 9B93
9B81: Find an object's own handler for an action
Used by the routines at DO_STRIKE, HANDLED and DO_ACTION.
Skips the record's 16-byte head and the list whose length is byte 0 of it, and searches what follows with FIND_RECORD. That is the object record's grammar stated by the game itself: parsed this way, all 61 records end exactly where the next begins, and the last exactly where ACTION_TABLE starts.
So an object can carry handlers of its own for particular actions, and this is how the game asks whether it does before falling back on the ordinary ones. A handler of $0000 in a record is not an address.
Input
A The action code
IX The object's record
Output
IX The matching handler record, or the $FF that ended the list
F NZ if the object has its own handler for this action
FIND_OBJECT_HANDLER 9B81 PUSH DE
9B82 LD D,A Keep the action code
9B83 LD A,(IX+$00) Skip the 16-byte head and the list of locations, whose length is byte 0
9B86 ADD A,$10
9B88 LD E,A
9B89 LD A,D IX = the start of the object's own handlers
9B8A LD D,$00
9B8C ADD IX,DE
9B8E CALL FIND_RECORD Look for this action among them
9B91 POP DE
9B92 RET
Prev: 9B80 Up: Map Next: 9B93