Prev: 9CED Up: Map Next: 9D37
9D00: Add up the sizes or the weights of what object A holds
Used by the routine at WEIGHT_HELD.
With B set, the sizes of what it holds directly (SIZE_HELD, SIZE_HELD); with B clear, the weights of everything in it at any depth (WEIGHT_HELD, WEIGHT_HELD). The sum is kept in C, and goes to $FF on overflow.
Input
A The holder
B 1 for sizes, 0 for weights
Output
C The sum
ADD_UP_HELD 9D00 PUSH IX
9D02 LD IX,OBJECT_INDEX
ADD_UP_HELD_0 9D06 CALL NEXT_OBJECT_KEEP_A
9D09 JR Z,ADD_UP_HELD_3
9D0B CP (IY+$01)
9D0E JR NZ,ADD_UP_HELD_0
9D10 PUSH AF
9D11 SUB A
9D12 CP B
9D13 LD A,C
9D14 JR Z,ADD_UP_HELD_1
9D16 ADD A,(IY+$02)
9D19 JP PE,ADD_UP_HELD_4
9D1C LD C,A
9D1D JR ADD_UP_HELD_2
ADD_UP_HELD_1 9D1F ADD A,(IY+$03)
9D22 JP PE,ADD_UP_HELD_4
9D25 LD C,A
9D26 LD A,(IX+$00)
9D29 CALL ADD_UP_HELD
ADD_UP_HELD_2 9D2C POP AF
9D2D JR ADD_UP_HELD_0
ADD_UP_HELD_3 9D2F POP IX
9D31 RET
ADD_UP_HELD_4 9D32 POP AF
9D33 LD C,$FF
9D35 JR ADD_UP_HELD_3
Prev: 9CED Up: Map Next: 9D37