Prev: 8569 Up: Map Next: 8614
858F: Find the action for a command
Collects the verb of the current frame and up to two prepositions from its noun phrases into $8349-834E, and then searches the action table (AA47) for an entry with the same verb and prepositions (71EA). If one is found, 8614 sorts out which noun phrase is the target and which the instrument, and the routine returns with Z reset.
If none is found there are two cases. If the verb was right but the other words were wrong ($B5D0 set), 'I do not know the verb ...' is printed (8895). If the verb has no actions at all (WAIT, JUMP, SING, SMILE and many others), the game prints 'you wait. time passes...' with the verb substituted (AC97), and a turn goes by. This is how all the verbs that do nothing get their reply.
858F PUSH IY Save the caller's IY, the current frame
8591 LD L,(IY+$00) HL = the frame's own verb...
8594 LD H,(IY+$01)
8597 LD A,H Is the ALL bit (bit 7) set on it?
8598 AND $80
859A LD ($8343),A Remember whether this whole command is an ALL
859D RES 7,H Strip that bit back out of the verb itself
859F LD ($8349),HL Keep the plain verb
85A2 LD HL,$834B Clear the four preposition slots that follow it
85A5 PUSH HL
85A6 LD B,$04
85A8 CALL $70D9
85AB POP HL
85AC LD B,$02 Up to two prepositions to pick out from the two noun phrases
85AE LD E,$04 First noun phrase's first preposition slot...
85B0 CALL $869D ...pick it up, if there is one
85B3 LD E,$0E Second noun phrase's first preposition slot...
85B5 CALL $869D ...pick it up too
85B8 LD E,$06 First noun phrase's second preposition slot...
85BA CALL $869D
85BD LD E,$10 Second noun phrase's second preposition slot...
85BF CALL $869D
85C2 XOR A The verb has not yet been shown to match anything
85C3 LD ($B5D0),A
85C6 LD HL,$8349 HL = the verb and prepositions just collected
85C9 LD DE,$0008 DE = 8, the size of one action table entry
85CC LD IX,$AA47 IX = the start of the action table
85D0 PUSH IX IY = the entry being compared
85D2 POP IY
85D4 CALL $71EA Does this entry match the verb and words collected above?
85D7 JR Z,$860C Yes: settle which words are the target and which the instrument, below
85D9 ADD IX,DE No: move on to the next entry
85DB LD A,(IX+$01) Have we reached the end of the table (an entry of all zeros)?
85DE OR (IX+$00)
85E1 JR NZ,$85D0 Not yet: try this next entry
85E3 POP IY End of the table, with no match: restore IY
85E5 LD A,($B5D0) Did the verb itself match anything, just with the wrong words?
85E8 AND A
85E9 JP NZ,$8895 Yes: "I do not know the verb ..."
85EC LD HL,($8349) No: this verb has no actions at all - push it as the message parameter...
85EF PUSH HL
85F0 LD HL,$AC97 ..."you <verb>. time passes..."
85F3 XOR A Print it in the lower window, as if the command had succeeded
85F4 LD ($B5F2),A
85F7 LD ($B60C),A No ALL is in progress
85FA LD A,$01 This is really happening, not just a trial
85FC LD ($B5EB),A
85FF CALL $72CA Print the message
8602 LD A,($B60B) Are we inside a quotation (an order to a character)?
8605 DEC A
8606 RET Z If so, that is all - let the caller move on to the next frame as usual
8607 POP HL Otherwise throw away our own two return addresses...
8608 POP HL
8609 JP $837C ...and jump straight to ending the turn, as if a real action had just happened
860C POP IY A match was found: restore IY, the current frame
860E CALL $8614 Work out which of its noun phrases is the target and which the instrument
8611 OR $01 Make A non-zero...
8613 RET ...telling the caller a matching action was found
Prev: 8569 Up: Map Next: 8614