![]() |
Routines |
| Prev: D4A7 | Up: Map | Next: D4EF |
|
Used by the routines at DescribeCurrentRoom, PrintObjectList, PrintFormattedObjectList and MeasureGapBetweenTwoPointers_Next.
Counts how many objects are inside the current room.
|
||||||||||||
| CountObjectsInLocation | D4CC | PUSH IX | Save the character record, the schedule entry, the pointer and the count. | |||||||||
| D4CE | PUSH IY | |||||||||||
| D4D0 | PUSH HL | |||||||||||
| D4D1 | PUSH BC | |||||||||||
| D4D2 | CALL AdjustObjectTableForSum | Call AdjustObjectTableForSum to set up the object table pointer. | ||||||||||
| D4D5 | LD B,$00 | Initialise the object counter in B to zero. | ||||||||||
| D4D7 | LD C,A | Store the location ID in C for later use. | ||||||||||
| CountObjectsInLocation_Loop | D4D8 | CALL FetchNextObject | Go to CountObjectsInLocation_End if the next object id is FF. | |||||||||
| D4DB | JR Z,CountObjectsInLocation_End | |||||||||||
| D4DD | LD A,C | Take the count. | ||||||||||
| D4DE | CALL CheckObjectMatchCriteria | Call CheckObjectMatchCriteria to check if this object matches the location and visibility criteria. | ||||||||||
|
Skip this object if it does not match the location and visibility criteria.
|
||||||||||||
| D4E1 | JR NC,CountObjectsInLocation_Loop | Jump back to CountObjectsInLocation_Loop to continue checking objects if this one doesn't match. | ||||||||||
|
This object matches the criteria, so count it.
|
||||||||||||
| D4E3 | INC B | Increment the object counter in B by one. | ||||||||||
| D4E4 | JR CountObjectsInLocation_Loop | Jump back to CountObjectsInLocation_Loop to check the next object. | ||||||||||
|
Read the count.
|
||||||||||||
| CountObjectsInLocation_End | D4E6 | LD A,B | Transfer the object count from B to A. | |||||||||
| D4E7 | AND A | Set the zero flag when the count is zero. | ||||||||||
| D4E8 | POP BC | Restore the saved count, the saved pointer, the saved schedule entry and the saved character record from the stack. | ||||||||||
| D4E9 | POP HL | |||||||||||
| D4EA | POP IY | |||||||||||
| D4EC | POP IX | |||||||||||
| D4EE | RET | Return. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: D4A7 | Up: Map | Next: D4EF |