Prev: 79B6 Up: Map Next: 7A73
7A14: Try the objects that fit the sentence's names until the action works
Used by the routines at PARSE_ACTION and WOULD_WORK.
For a pattern with objects, the target and the instrument are each only names until something fits them. This goes through the objects that fit the target's name (NEXT_TARGET) and, for each, those that fit the instrument's (NEXT_INSTRUMENT), trying the action on each pair, and stops at the first that works. How many fitted is counted at TARGETS_FOUND to INSTRUMENTS_FAILED, and the first of each is kept at FIRST_TARGET_FAILED to FIRST_INSTRUMENT_FAILED, so that when only one thing fitted it is that one the refusal is about. The exact order of the fall-backs is not worked out in full.
MATCH_AND_TRY 7A14 CALL NEXT_TARGET The next target that fits
7A17 JR NZ,MATCH_AND_TRY_0
7A19 LD A,(TARGETS_FAILED) None left: if only one ever fitted, it is the one; try it with the instruments
7A1C CP $01
7A1E RET NZ
7A1F LD A,(FIRST_TARGET_FAILED)
7A22 LD (TARGET),A
7A25 CALL START_INSTRUMENTS
7A28 CALL WANTS_INSTRUMENT
7A2B JR NZ,MATCH_AND_TRY_3
7A2D RET
MATCH_AND_TRY_0 7A2E LD HL,TARGETS_FOUND Count it
7A31 INC (HL)
7A32 CALL WANTS_INSTRUMENT Wants an instrument? Try each with it
7A35 JR Z,MATCH_AND_TRY_2
7A37 CALL START_INSTRUMENTS
7A3A CALL NEXT_INSTRUMENT
MATCH_AND_TRY_1 7A3D JR Z,MATCH_AND_TRY Did not work: keep the first, count, and go on
7A3F LD A,(WITH_ALL)
7A42 DEC A
7A43 RET Z
7A44 LD A,(TARGET)
7A47 LD (FIRST_TARGET_FAILED),A
7A4A LD HL,TARGETS_FAILED
7A4D INC (HL)
7A4E JR MATCH_AND_TRY
MATCH_AND_TRY_2 7A50 CALL TRY_IT No instrument wanted: just try it
7A53 JR MATCH_AND_TRY_1
MATCH_AND_TRY_3 7A55 CALL NEXT_INSTRUMENT The instruments in turn, keeping the first
7A58 JR NZ,MATCH_AND_TRY_4
7A5A LD A,(INSTRUMENTS_FAILED)
7A5D CP $01
7A5F RET NZ
7A60 LD A,(FIRST_INSTRUMENT_FAILED)
7A63 LD (INSTRUMENT),A
7A66 RET
MATCH_AND_TRY_4 7A67 LD A,(INSTRUMENT)
7A6A LD (FIRST_INSTRUMENT_FAILED),A
7A6D LD HL,INSTRUMENTS_FAILED
7A70 INC (HL)
7A71 JR MATCH_AND_TRY_3
Prev: 79B6 Up: Map Next: 7A73