Prev: 80B5 Up: Map Next: 8149
80CD: Quotation mark
A quotation mark (class $90, word 0) arrives here from 8009. If no quotation is open, it is an opening quote (80B5). Otherwise it closes the quotation: $B60B is decreased, and the frames that were parsed inside it are moved to the orders buffer at B628 so that the character spoken to can act on them later.
The orders buffer has eight slots of 25 bytes. Each command is put in the first free slot: the slot's first byte is set to $FF (in use) and the 24-byte frame is copied after it. An ALL EXCEPT exception frame (bit 6) is stored as an empty order. $B627 is set to the number of orders stored. The parser state saved at the opening quote is then restored.
80CD LD A,($B60B) Are we already inside a quotation?
80D0 AND A
80D1 JR Z,$80B5 No: this is an OPENING quote (80B5)
80D3 DEC A Yes: this closes it - one level shallower
80D4 LD ($B60B),A
80D7 LD A,($8008) A = the frame count as it was when the quotation opened
80DA LD B,A
80DB LD A,($B5F7) Subtract that from the frame count now, giving how many frames were built INSIDE the quotation
80DE SUB B
80DF AND A
80E0 LD C,$00 C will count how many orders are actually stored
80E2 JR Z,$8130 None at all (an empty quotation): tidy up and finish, below
80E4 POP IY Restore IY to the frame just before the quotation opened...
80E6 PUSH IY
80E8 LD DE,$FFE8 ...then move up to the FIRST frame built inside it
80EB ADD IY,DE
80ED LD B,A B = how many frames to process
80EE LD IX,$B628 IX = the start of the orders buffer
80F2 PUSH DE Find the first free slot (marked with a 0 in its first byte)...
80F3 PUSH BC
80F4 LD DE,$0019
80F7 LD B,$08
80F9 LD A,(IX+$00)
80FC AND A
80FD JR Z,$8103
80FF ADD IX,DE
8101 DJNZ $80F9
8103 LD (IX+$00),$FF ...mark it in use (properly addressed later, in 88A7)
8107 INC IX Move past the slot's own marker byte, to where the frame goes
8109 POP BC Restore the frame counter
810A POP DE
810B JR NZ,$8130 No free slot was found: the rest of the orders are simply lost
810D BIT 6,(IY+$01) Is this frame only an ALL EXCEPT exception, with no command of its own?
8111 JR Z,$8119 No: copy it properly, below
8113 LD (IX-$01),$00 Yes: store it as an empty order instead
8117 JR $812B
8119 PUSH BC Copy the whole 24-byte frame into the order slot...
811A LD B,$18
811C LD A,(IY+$00)
811F LD (IX+$00),A
8122 INC IY
8124 INC IX
8126 DJNZ $811C
8128 POP BC
8129 ADD IY,DE Move IY on to the next frame that was inside the quotation
812B ADD IY,DE (the exception-frame path joins here too, at the same offset)
812D INC C One more order stored
812E DJNZ $80EE Repeat for every frame that was built inside the quotation
8130 XOR A No ALL or ALL EXCEPT is in force any more
8131 LD ($B609),A
8134 LD A,C Remember how many orders were actually stored
8135 LD ($B627),A
8138 POP IY Restore the frame pointer from before the quotation opened
813A LD A,($8008) Restore the frame count too
813D LD ($B5F7),A
8140 POP BC Restore BC and DE, saved when the quotation opened
8141 POP DE
8142 LD A,($8007) Restore the word class the parser had reached
8145 LD D,A
8146 JP $7C7E Go back to reading the next word, as if the whole quotation had been a single word
Prev: 80B5 Up: Map Next: 8149