Prev: 8895 Up: Map Next: 88EC
88A7: Address the orders to a character
After SAY TO someone "...", the commands inside the quotation are waiting in the orders buffer (B628), each in a slot marked $FF. This routine gives the first A of them to the character being spoken to, by writing the character's object number ($B5D9) into the slots' first bytes. Any further waiting orders (more than the character will accept) are thrown away by setting their first byte to 0.
88A7 PUSH BC
88A8 PUSH IX
88AA PUSH DE
88AB LD B,A B = the number of orders the character will take
88AC LD A,($B627) C = the number of orders waiting
88AF LD C,A
88B0 CP B More wanted than there are?
88B1 JR NC,$88B4
88B3 LD B,A Then take them all
88B4 LD A,C C = the number left over
88B5 SUB B
88B6 LD C,A
88B7 LD IX,$B60F IX = one slot before the orders buffer
88BB LD DE,$0019 25 bytes per slot
88BE XOR A Any to hand over?
88BF CP B
88C0 JR Z,$88D3 No
88C2 ADD IX,DE Find the next waiting order (marked $FF)
88C4 LD A,(IX+$00)
88C7 CP $FF
88C9 JR NZ,$88C2
88CB LD A,($B5D9) Address it to the character
88CE LD (IX+$00),A
88D1 DJNZ $88C2 Next
88D3 LD B,C Now the left-over orders:
88D4 XOR A
88D5 CP B
88D6 JR Z,$88E7 None
88D8 ADD IX,DE find each one...
88DA LD A,(IX+$00)
88DD CP $FF
88DF JR NZ,$88D8
88E1 LD (IX+$00),$00 ...and throw it away
88E5 DJNZ $88D8
88E7 POP DE
88E8 POP IX
88EA POP BC
88EB RET
Prev: 8895 Up: Map Next: 88EC