Prev: D064 Up: Map Next: D0D0
D078: Check Object Visibility
Sets the carry when the current character is visible and a matching object is found. Returns with the carry clear when the character is not visible.
Output
F Carry flag set if object is visible
CheckObjectVisibility D078 PUSH IX Save the character record, the schedule entry and the count.
D07A PUSH IY
D07C PUSH BC
D07D LD IX,($A017) Read the current character record.
D081 LD A,(IX+$04) Read the attribute type.
D084 AND %10000000 Keep only bit 7.
D086 JR Z,CheckObjectVisibility_TestObjectVisibility Skip the object when bit 7 is clear, so it is not visible.
D088 CALL CheckObjectMother Go to CheckObjectVisibility_Next unless CheckObjectMother returned FF.
D08B INC A
D08C JR NZ,CheckObjectVisibility_Next
Fetch current character location.
D08E CALL FetchCurrentCharacterLocation Call FetchCurrentCharacterLocation to read where the current character is.
D091 BIT 7,(IX+$00) Jump to CheckObjectVisibility_TestObjectVisibility if a marker on the record's flag byte is set.
D095 JR NZ,CheckObjectVisibility_TestObjectVisibility
D097 CALL GetTimePeriod Go to CheckObjectVisibility_TestObjectVisibility if it is not 01.
D09A CP $01
D09C JR NZ,CheckObjectVisibility_TestObjectVisibility
It's late night/ evening (8 PM - 5 AM).
CheckObjectVisibility_Next D09E LD IX,$8B6F Use the objects at Table_Objects.
CheckObjectVisibility_Loop D0A2 CALL FetchNextObject Go to CheckObjectVisibility_ConditionHoldsCaller if the next object id is FF.
D0A5 JR Z,CheckObjectVisibility_ConditionHoldsCaller
D0A7 LD A,(IY+$00) Jump to CheckObjectVisibility_Loop if the character id is not 01.
D0AA CP $01
D0AC JR NZ,CheckObjectVisibility_Loop
D0AE LD A,(IY+$05) Read the schedule entry.
D0B1 XOR %10110111 Jump back to CheckObjectVisibility_Loop unless bits 2 and 4 of the schedule entry are set and bits 3 and 6 are clear.
D0B3 AND %01011100
D0B5 JR NZ,CheckObjectVisibility_Loop
D0B7 LD A,(IY+$04) Read the schedule entry.
D0BA AND %10000000 Keep only bit 7.
D0BC JR Z,CheckObjectVisibility_Loop Go back and test the next object when bit 7 is clear.
D0BE LD A,(IX+$00) Jump back to CheckObjectVisibility_Loop while the object is not in this location.
D0C1 CALL CheckObjectLocationMatch
D0C4 JR Z,CheckObjectVisibility_Loop
CheckObjectVisibility_TestObjectVisibility D0C6 AND A Clear the carry and jump ahead to CheckObjectVisibility_BringSavedCount.
D0C7 JR CheckObjectVisibility_BringSavedCount
The condition holds, so the caller continues.
CheckObjectVisibility_ConditionHoldsCaller D0C9 SCF Set the carry.
CheckObjectVisibility_BringSavedCount D0CA POP BC Restore the saved count, the saved schedule entry and the saved character record from the stack.
D0CB POP IY
D0CD POP IX
D0CF RET Return.
Prev: D064 Up: Map Next: D0D0