Prev: 88FD Up: Map Next: 894D
8907: Obey an order
Called with A non-zero by 976C when a character has been given an order by the player. The order's slot is found (88EC) and freed, and the 24-byte frame stored in it is matched to an action and objects exactly as if the player had typed it (83A7), but with the quotation flag set so that nothing is printed while this happens. If the action would work (84DE), the character will carry it out on its turn; if not, all the character's orders are cancelled (894D).
With A=0 it only frees the slot.
Input
A 0 to discard the order
8907 PUSH IX
8909 PUSH IY
890B PUSH BC
890C PUSH DE
890D PUSH HL
890E LD C,A C = 0 to discard the order, 1 to obey it
890F CALL $88EC HL = the actor's order slot
8912 LD (HL),$00 Free the slot
8914 INC HL HL = the command frame stored in it
8915 XOR A Discarding?
8916 CP C
8917 JR NZ,$8924 No: obey it
8919 OR $01 Return with Z reset
891B EX (SP),HL Return HL (the frame) to the caller
891C POP HL
891D POP DE
891E POP BC
891F POP IY
8921 POP IX
8923 RET
8924 PUSH HL IY = the frame
8925 POP IY
8927 LD A,$01 Pretend to be inside a quotation so nothing is printed
8929 LD ($B60B),A
892C LD A,($B60C)
892F PUSH AF
8930 CALL $83A7 Find the action and objects for the order, as if the player had typed it
8933 EX AF,AF'
8934 XOR A Back to normal
8935 LD ($B60B),A
8938 POP AF
8939 LD ($B60C),A
893C EX AF,AF'
893D JR Z,$8944 It made no sense: give up
893F CALL $84DE Would it work?
8942 JR NZ,$891C Yes: return with Z reset; the character will do it
8944 LD A,($B5DB) No: the character forgets all its orders
8947 CALL $894D
894A XOR A Return with Z set
894B JR $891C
Prev: 88FD Up: Map Next: 894D