Prev: 40173 Up: Map Next: 40247
40192: Condition: Add Up The Objects Inside
Used by the routine at Condition_TotalTheMassInside.
Adds the volume or the mass of each object inside the id in A. Volume covers those objects only; mass also adds what they hold. An overflow returns 255.
Condition_AddUpTheObjectsInside 40192 PUSH IX Point IX at the object table.
40194 LD IX,49251
Condition_AddUpTheObjectsInside_Loop 40198 CALL Table_FindTheRecord Call Table_FindTheRecord to find the record.
40201 JR Z,Condition_AddUpTheObjectsInside_RestoreAndReturn Jump to Condition_AddUpTheObjectsInside_RestoreAndReturn at the end of the object index.
40203 CP (IY+1) Jump back to Condition_AddUpTheObjectsInside_Loop if where this object is is not the id in A.
40206 JR NZ,Condition_AddUpTheObjectsInside_Loop
40208 PUSH AF Jump to Condition_AddUpTheObjectsInside_AddTheMass if B is zero (add masses instead of volumes).
40209 SUB A
40210 CP B
40211 LD A,C
40212 JR Z,Condition_AddUpTheObjectsInside_AddTheMass
40214 ADD A,(IY+2) Add the object's volume onto the total.
40217 JP PE,Condition_AddUpTheObjectsInside_MarkTheTotalAsFull Jump to Condition_AddUpTheObjectsInside_MarkTheTotalAsFull if the total overflowed.
40220 LD C,A Copy the result into C.
40221 JR Condition_AddUpTheObjectsInside_FindTheRecord Jump to Condition_AddUpTheObjectsInside_FindTheRecord to find the next record.
Condition_AddUpTheObjectsInside_AddTheMass 40223 ADD A,(IY+3) Add the object's mass onto the total.
40226 JP PE,Condition_AddUpTheObjectsInside_MarkTheTotalAsFull Jump to Condition_AddUpTheObjectsInside_MarkTheTotalAsFull if the total overflowed.
40229 LD C,A Copy the result into C.
40230 LD A,(IX+0) Read the id from the index entry.
40233 CALL Condition_AddUpTheObjectsInside Call Condition_AddUpTheObjectsInside to add the mass of what this object holds.
Condition_AddUpTheObjectsInside_FindTheRecord 40236 POP AF Jump back to Condition_AddUpTheObjectsInside_Loop to find the record.
40237 JR Condition_AddUpTheObjectsInside_Loop
Condition_AddUpTheObjectsInside_RestoreAndReturn 40239 POP IX Restore IX from the stack.
40241 RET Return.
Condition_AddUpTheObjectsInside_MarkTheTotalAsFull 40242 POP AF Pop the saved id and mark the total as full (255).
40243 LD C,255
40245 JR Condition_AddUpTheObjectsInside_RestoreAndReturn Jump back to Condition_AddUpTheObjectsInside_RestoreAndReturn to return.
View the equivalent code in;
Prev: 40173 Up: Map Next: 40247