Prev: 9D44 Up: Map Next: 9DBD
9D97: Routine at 9D97
Used by the routines at Action_Inventory, 910E, Action_Examine, A050 and ActionTie.
Output
A The number of objects
ObjectCount 9D97 PUSH IX Stash IX, IY and BC on the stack.
9D99 PUSH IY
9D9B PUSH BC
9D9C LD B,$00 Initialise the count of the number of objects.
9D9E LD IX,$C060 Set IX to $C060 which is 3 bytes less than the start of the object table due to the following line adding $0003 and moving us on to the first record.
ObjectCount_Loop 9DA2 CALL Step3ByteTable_Next Call Step3ByteTable_Next to fetch the next record in IY.
9DA5 JR Z,ObjectCount_End Jump to ObjectCount_End if we've reached the end of the table data.
9DA7 CP (IY+$01) Don't count this record if it's a "Mother Object", if it is then loop back to ObjectCount_Loop to continue.
9DAA JR NZ,ObjectCount_Loop
9DAC BIT 7,(IY+$07) Don't count this record if it's not "visible", if not then loop back to ObjectCount_Loop to continue.
9DB0 JR Z,ObjectCount_Loop
9DB2 INC B Increase B, the object counter, by one.
9DB3 JP ObjectCount_Loop Jump to ObjectCount_Loop.
ObjectCount_End 9DB6 LD A,B Store the object count in A.
9DB7 POP BC Restore BC, IY and IX from the stack.
9DB8 POP IY
9DBA POP IX
9DBC RET Return.
Prev: 9D44 Up: Map Next: 9DBD