Prev: 94D6 Up: Map Next: 95DF
950F: Turn: Run The Handler If Present
Runs the handler when one is present. In the dark, with nothing named, the player sees "i see nothing here".
Turn_RunTheHandlerIfPresent 950F PUSH HL Save HL, IX and BC, and call Turn_AcceptTheNamedObject to accept the named object.
9510 PUSH IX
9512 PUSH BC
9513 CALL Turn_AcceptTheNamedObject
9516 JP Z,Turn_RunTheHandlerIfPresent_Examine_CannotDoThat Jump to Turn_RunTheHandlerIfPresent_Examine_CannotDoThat when Turn_AcceptTheNamedObject returns with the zero flag set.
Test whether the location is lit.
9519 CALL LocationLit Call LocationLit to test whether the location is lit.
951C JR NC,Turn_RunTheHandlerIfPresent_Examine_TestNounFlag Jump to Turn_RunTheHandlerIfPresent_Examine_TestNounFlag if the location is lit.
Test this flag.
951E LD A,($B711) Jump to Turn_RunTheHandlerIfPresent_Examine_PrintNothing if *B711 is not zero.
9521 AND A
9522 JR NZ,Turn_RunTheHandlerIfPresent_Examine_PrintNothing
Test whether the object is being carried.
9524 CALL ConditionIsTheObjectCarried Call ConditionIsTheObjectCarried to test whether the object is carried.
9527 JR NC,Turn_RunTheHandlerIfPresent_Examine_PrintNothing Jump to Turn_RunTheHandlerIfPresent_Examine_PrintNothing if the object is not being carried.
9529 LD A,($B6E9) Read *B6E9.
952C CALL ConditionIsTheObjectCarried_0 Call ConditionIsTheObjectCarried_0 to test whether the character whose turn it is is carrying it.
952F JR C,Turn_RunTheHandlerIfPresent_Examine_TestNounFlag Jump to Turn_RunTheHandlerIfPresent_Examine_TestNounFlag if the character whose turn it is is carrying the object.
Turn_RunTheHandlerIfPresent_Examine_PrintNothing 9531 LD HL,$AFC4 Point at the message "i see nothing here" (AFC4).
9534 CALL PrintMessage Call PrintMessage to print message.
9537 JR Check_Lit Jump to Check_Lit to test the message gate.
Test the noun-print flag.
Turn_RunTheHandlerIfPresent_Examine_TestNounFlag 9539 LD A,($B6FE) Jump to Check_ValidAction if *B6FE is 01.
953C CP $01
953E JP Z,Check_ValidAction
Test the current object.
9541 LD A,($B6E8) Jump to Check_ValidAction if *CurrentObject is FF.
9544 CP $FF
9546 JP Z,Check_ValidAction
Find the object's record.
9549 CALL LocateObject Call LocateObject to locate object.
954C LD ($B708),IX Update *B708.
9550 LD A,($B6E8) Read *CurrentObject.
9553 CALL Turn_ReportWhoIsCarryingAnObject Call Turn_ReportWhoIsCarryingAnObject to report who is carrying the object.
9556 JR NZ,Check_Lit Jump to Check_Lit unless Turn_ReportWhoIsCarryingAnObject returned zero.
Test the second object.
9558 LD A,($B6E9) Jump to Turn_RunTheHandlerIfPresent_Examine_ReadTheObject if *B6E9 is FF.
955B CP $FF
955D JR Z,Turn_RunTheHandlerIfPresent_Examine_ReadTheObject
Test the second-noun flag.
955F LD A,($B6FF) Jump to Check_ValidAction if *B6FF is 01.
9562 CP $01
9564 JR Z,Check_ValidAction
9566 LD A,($B6E9) Read *B6E9.
Find the object's record.
9569 CALL LocateObject Call LocateObject to locate object.
956C LD ($B70A),IX Update *B70A.
9570 CALL Turn_ReportWhoIsCarryingAnObject Call Turn_ReportWhoIsCarryingAnObject to report who is carrying the object.
9573 JR NZ,Check_Lit Jump to Check_Lit if Turn_ReportWhoIsCarryingAnObject reported that another character is carrying the object.
9575 CALL Action_MatchAVerbInTheTable Call Action_MatchAVerbInTheTable to match the action against the five verb bytes.
9578 JR Z,Turn_RunTheHandlerIfPresent_Examine_ReadTheAction Jump to Turn_RunTheHandlerIfPresent_Examine_ReadTheAction if Action_MatchAVerbInTheTable found the action in the verb list.
Turn_RunTheHandlerIfPresent_Examine_ReadTheObject 957A LD IX,($B708) Read *B708.
Turn_RunTheHandlerIfPresent_Examine_ReadTheAction 957E LD A,($B6E7) Read *CurrentAction.
9581 CALL TableFindAnActionRecord Call TableFindAnActionRecord to find an action record.
9584 JR NC,Check_ValidAction Jump to Check_ValidAction if TableFindAnActionRecord did not find the action record.
Turn_RunTheHandlerIfPresent_Examine_CallHandler 9586 LD L,(IX+$01) Read the handler address from this action-list entry.
9589 LD H,(IX+$02)
958C CALL TriggerAction Call TriggerAction to call the handler stored for this action.
958F INC IX Jump back to Turn_RunTheHandlerIfPresent_Examine_CallHandler if the next action-list byte is zero.
9591 INC IX
9593 INC IX
9595 SUB A
9596 CP (IX+$00)
9599 JR Z,Turn_RunTheHandlerIfPresent_Examine_CallHandler
Check_Lit 959B LD A,($B6FA) If B6FA is not 01 then jump to Check_Return.
959E CP $01
95A0 JR NZ,Check_Return
This check is a little unnecessary as the first thing the routine at LocationLit does, is to check exactly this...
95A2 LD A,($B6EA) If CurrentCharacter is not 00 (i.e. "You") then skip the "is location lit" check, instead jump to Check_Action.
95A5 CP $00
95A7 JR NZ,Check_Action
LocationLit uses the carry flag to indicate if it is light or dark.
95A9 CALL LocationLit If the location is dark then call PrintMessage to tell the user "it is dark".
95AC CALL C,PrintMessage
Check_Action 95AF LD A,($B6E7) Read the current action.
95B2 LD B,A Keep the current action in B.
95B3 LD A,($B6E8) Call Turn_WakeAnAnimal with IX=B708 and A=CurrentObject.
95B6 LD IX,($B708)
95BA CALL Turn_WakeAnAnimal
95BD LD A,($B6E9) Call Turn_WakeAnAnimal with IX=B70A and A=B6E9.
95C0 LD IX,($B70A)
95C4 CALL Turn_WakeAnAnimal
Performs housekeeping and returns.
Check_Return 95C7 POP BC Restore BC, IX and HL from the stack.
95C8 POP IX
95CA POP HL
95CB RET Return.
Checks if the action given is valid.
Check_ValidAction 95CC LD A,($B6E7) Call IndexIdTable with ActionTable, to match the key value of CurrentAction.
95CF LD IX,$C730
95D3 CALL IndexIdTable
95D6 CP $FF Jump to Turn_RunTheHandlerIfPresent_Examine_CallHandler if IndexIdTable found the action, rather than the FF terminator.
95D8 JR NZ,Turn_RunTheHandlerIfPresent_Examine_CallHandler
Turn_RunTheHandlerIfPresent_Examine_CannotDoThat 95DA CALL Response_ICannotDoThat Else, call Response_ICannotDoThat and jump to Check_Return.
95DD JR Check_Return
Prev: 94D6 Up: Map Next: 95DF