![]() |
Routines |
| Prev: 94D6 | Up: Map | Next: 95DF |
|
The one place every action is done, the player's and every other character's alike. The action is refused outright if it makes no sense (SENSIBLE), and in the dark it can only be done to what the actor is carrying. Then the objects get the first say: an object can carry a handler of its own for an action (see FIND_OBJECT_HANDLER), and only if neither has one does ACTION_TABLE's ordinary handler run. For most actions the first object is asked; for the five in SECOND_FIRST -- DROP IN, PUT IN, PUT ON, TAKE OUT OF and THROW THROUGH -- the second object is asked first, since it is the container or the gap that decides.
A handler is followed by any records after it keyed 0, which run too: the wine's record has the ordinary handler for DRINK followed by WINE_DRUNK under key 0, so drinking it does both. Last, each object that is a character reacts to what was done to it (REACT_TO_ACTION).
|
||||
| DO_ACTION | 950F | PUSH HL | ||
| 9510 | PUSH IX | |||
| 9512 | PUSH BC | |||
| 9513 | CALL SENSIBLE | Makes no sense? "i cannot do that." | ||
| 9516 | JP Z,DO_ACTION_9 | |||
| 9519 | CALL TOO_DARK | Can the actor see? | ||
| 951C | JR NC,DO_ACTION_1 | |||
| 951E | LD A,(NEEDS_LIGHT) | In the dark, only what the actor carries -- and nothing at all while NEEDS_LIGHT is set | ||
| 9521 | AND A | |||
| 9522 | JR NZ,DO_ACTION_0 | |||
| 9524 | CALL ACTOR_HAS_FIRST | |||
| 9527 | JR NC,DO_ACTION_0 | |||
| 9529 | LD A,(INSTRUMENT) | |||
| 952C | CALL ACTOR_HAS_A | |||
| 952F | JR C,DO_ACTION_1 | |||
| DO_ACTION_0 | 9531 | LD HL,MSG_I_SEE_NOTHING_HERE | "i see nothing here." | |
| 9534 | CALL RUN_MESSAGE_HL | |||
| 9537 | JR DO_ACTION_5 | |||
| DO_ACTION_1 | 9539 | LD A,(TARGET_IS_PLACE) | TARGET_IS_PLACE set, or no object: the ordinary handler | |
| 953C | CP $01 | |||
| 953E | JP Z,DO_ACTION_8 | |||
| 9541 | LD A,(TARGET) | |||
| 9544 | CP $FF | |||
| 9546 | JP Z,DO_ACTION_8 | |||
| 9549 | CALL GET_OBJECT | The first object, in TARGET_RECORD: not being carried by somebody else | ||
| 954C | LD (TARGET_RECORD),IX | |||
| 9550 | LD A,(TARGET) | |||
| 9553 | CALL CARRIED_BY_ANOTHER | |||
| 9556 | JR NZ,DO_ACTION_5 | |||
| 9558 | LD A,(INSTRUMENT) | No second object: ask the first | ||
| 955B | CP $FF | |||
| 955D | JR Z,DO_ACTION_2 | |||
| 955F | LD A,(INSTRUMENT_IS_PLACE) | INSTRUMENT_IS_PLACE set: the ordinary handler | ||
| 9562 | CP $01 | |||
| 9564 | JR Z,DO_ACTION_8 | |||
| 9566 | LD A,(INSTRUMENT) | The second object, in INSTRUMENT_RECORD: not being carried by somebody else | ||
| 9569 | CALL GET_OBJECT | |||
| 956C | LD (INSTRUMENT_RECORD),IX | |||
| 9570 | CALL CARRIED_BY_ANOTHER | |||
| 9573 | JR NZ,DO_ACTION_5 | |||
| 9575 | CALL IS_SECOND_FIRST | One of SECOND_FIRST? Ask the second object | ||
| 9578 | JR Z,DO_ACTION_3 | |||
| DO_ACTION_2 | 957A | LD IX,(TARGET_RECORD) | Otherwise the first | |
| DO_ACTION_3 | 957E | LD A,(ACTION) | Does it have a handler of its own for this? If not, the ordinary one | |
| 9581 | CALL FIND_OBJECT_HANDLER | |||
| 9584 | JR NC,DO_ACTION_8 | |||
| DO_ACTION_4 | 9586 | LD L,(IX+$01) | Run the handler, and every record after it keyed 0 | |
| 9589 | LD H,(IX+$02) | |||
| 958C | CALL RUN_ROUTINE | |||
| 958F | INC IX | |||
| 9591 | INC IX | |||
| 9593 | INC IX | |||
| 9595 | SUB A | |||
| 9596 | CP (IX+$00) | |||
| 9599 | JR Z,DO_ACTION_4 | |||
| DO_ACTION_5 | 959B | LD A,(DOING_IT) | Done quietly, as a test? Then that is all | |
| 959E | CP $01 | |||
| 95A0 | JR NZ,DO_ACTION_7 | |||
| 95A2 | LD A,(ACTING) | For the player in the dark: "it is dark.", the message TOO_DARK leaves in HL | ||
| 95A5 | CP $00 | |||
| 95A7 | JR NZ,DO_ACTION_6 | |||
| 95A9 | CALL TOO_DARK | |||
| 95AC | CALL C,RUN_MESSAGE_HL | |||
| DO_ACTION_6 | 95AF | LD A,(ACTION) | Each object that is a character reacts | |
| 95B2 | LD B,A | |||
| 95B3 | LD A,(TARGET) | |||
| 95B6 | LD IX,(TARGET_RECORD) | |||
| 95BA | CALL REACT_TO_ACTION | |||
| 95BD | LD A,(INSTRUMENT) | |||
| 95C0 | LD IX,(INSTRUMENT_RECORD) | |||
| 95C4 | CALL REACT_TO_ACTION | |||
| DO_ACTION_7 | 95C7 | POP BC | ||
| 95C8 | POP IX | |||
| 95CA | POP HL | |||
| 95CB | RET | |||
| DO_ACTION_8 | 95CC | LD A,(ACTION) | The ordinary handler, from ACTION_TABLE | |
| 95CF | LD IX,ACTION_TABLE | |||
| 95D3 | CALL FIND_RECORD | |||
| 95D6 | CP $FF | |||
| 95D8 | JR NZ,DO_ACTION_4 | |||
| DO_ACTION_9 | 95DA | CALL CANNOT_DO | "i cannot do that." | |
| 95DD | JR DO_ACTION_7 | |||
| Prev: 94D6 | Up: Map | Next: 95DF |