Prev: B77E Up: Map Next: B83C
B77F: Process Text Token Stream
Used by the routine at ProcessLocationDisplay.
Walks the text tokens while the display flag is not the end marker.
Output
F Zero flag set if end of stream reached
ProcessTextTokenStream B77F LD A,($B77E) Jump to ProcessTextTokenStream_BitRecordFlag if the display is not FF.
B782 CP $FF
B784 JR NZ,ProcessTextTokenStream_BitRecordFlag
ProcessTextTokenStream_Loop B786 LD HL,($B6D6) Return if the pointer at B6D6 is zero.
B789 LD A,L
B78A OR H
B78B RET Z
B78C XOR A Clear the display.
B78D LD ($B77E),A
B790 PUSH HL
B791 POP IX
B793 LD L,(IX-$02) Read the low byte saved ahead of this record.
B796 LD H,(IX-$01) Record the display pointers.
B799 LD ($B6D6),HL
B79C LD L,(IX+$00) Read the record's flag byte.
B79F LD H,(IX+$01) Call ProcessMemoryEntry to run memory entry.
B7A2 CALL ProcessMemoryEntry
B7A5 INC HL Step on two bytes and point IX at that address.
B7A6 INC HL
B7A7 PUSH HL
B7A8 POP IX
ProcessTextTokenStream_BitRecordFlag B7AA LD A,(IX+$00) Jump ahead to ProcessTextTokenStream_TestCharacterClass if bit 7 of the record's flag byte is clear, and step through the text token.
B7AD INC IX
B7AF BIT 7,A
B7B1 JR Z,ProcessTextTokenStream_TestCharacterClass
B7B3 LD D,A Keep this token and read the next byte as its parameter.
B7B4 LD E,(IX+$00)
B7B7 INC IX
B7B9 AND %01110000 Keep the token type (bits 4-6) for the checks below.
B7BB CP $60 Jump ahead to ProcessTextTokenStream_Next if the record flag is 60.
B7BD JR Z,ProcessTextTokenStream_Next
B7BF CP $30 Jump ahead to ProcessTextTokenStream_Next if the record flag is 30.
B7C1 JR Z,ProcessTextTokenStream_Next
B7C3 CP $20 Return if the record flag is not 20.
B7C5 RET NZ
ProcessTextTokenStream_Next B7C6 LD A,$FF Write FF to the display.
B7C8 LD ($B77E),A
B7CB AND A Clear the carry so a blank character ends this token.
B7CC RET Return.
Treats a blank as a break and a vocabulary code as a common word.
ProcessTextTokenStream_TestCharacterClass B7CD CP $20 Jump ahead to ProcessTextTokenStream_CommandTwo if the character code is below 20.
B7CF JR C,ProcessTextTokenStream_CommandTwo
B7D1 CP $60 Jump ahead to ProcessTextTokenStream_TestKeepBitsCount if the character code is below 60.
B7D3 JR C,ProcessTextTokenStream_TestKeepBitsCount
Get common word.
B7D5 CALL GetCommonWord Call GetCommonWord to look up this common word.
B7D8 OR $01 Set the found marker.
B7DA LD A,$00 Leave A clear. The flags still show that the word was found.
B7DC RET Return.
Keep the token's low five bits and add one for the letter count.
ProcessTextTokenStream_TestKeepBitsCount B7DD AND %00011111 Take the letter count of this packed word from bits 0-4.
B7DF INC A Set B to the token length plus one, point HL at the byte after IX, and clear C.
B7E0 LD B,A
B7E1 PUSH IX
B7E3 POP HL
B7E4 INC HL
B7E5 LD C,$00
Rotate and extract character code.
ProcessTextTokenStream_0 B7E7 CALL RotateAndExtractCharacterCode Call RotateAndExtractCharacterCode to unpack the next letter.
B7EA DJNZ ProcessTextTokenStream_0 Count the next character of the message and repeat from ProcessTextTokenStream_0.
B7EC PUSH HL Jump back to ProcessTextTokenStream_BitRecordFlag while the count is not zero.
B7ED POP IX
B7EF LD A,C
B7F0 AND A
B7F1 JR NZ,ProcessTextTokenStream_BitRecordFlag
B7F3 DEC IX Step back one byte and continue at ProcessTextTokenStream_BitRecordFlag.
B7F5 JR ProcessTextTokenStream_BitRecordFlag
Command 2 adds the following offset to the text pointer.
ProcessTextTokenStream_CommandTwo B7F7 CP $02 Jump ahead to ProcessTextTokenStream_CommandEleven if the command is not 02.
B7F9 JR NZ,ProcessTextTokenStream_CommandEleven
B7FB LD E,(IX+$00) Read the flag word and add it to the record pointer.
B7FE LD D,(IX+$01)
B801 ADD IX,DE
ProcessTextTokenStream_TestRecordFlagStep B803 DEC IX Step back one byte and read the next token from ProcessTextTokenStream_BitRecordFlag.
B805 JR ProcessTextTokenStream_BitRecordFlag
Command 11 saves the text pointer and adds the following offset.
ProcessTextTokenStream_CommandEleven B807 CP $0B Go to ProcessTextTokenStream_TestControlBelowGoes when the text command is not 0B.
B809 JR NZ,ProcessTextTokenStream_TestControlBelowGoes
B80B LD E,(IX+$00) Read the record's flag byte and read the moved marker.
B80E LD D,(IX+$01)
B811 PUSH IX
B813 POP HL Call AllocateMemory to allocate 02 bytes.
B814 LD A,$02
B816 CALL AllocateMemory
B819 LD (IX+$00),L Store the link word at the start of the record and keep it.
B81C LD (IX+$01),H
B81F PUSH HL
B820 LD HL,($B6D6) Read the display pointers.
B823 LD ($B6D6),IX Remember this record at B6D6 and store the previous pointer's low byte just ahead of it.
B827 LD (IX-$02),L
B82A LD (IX-$01),H Store the high byte of the previous pointer just ahead of this record.
B82D POP HL Restore the pointer from the stack.
B82E ADD HL,DE Add the offset, copy it into the record, and go to ProcessTextTokenStream_TestRecordFlagStep.
B82F PUSH HL
B830 POP IX
B832 JR ProcessTextTokenStream_TestRecordFlagStep
A control below 29 goes back to the main text walk.
ProcessTextTokenStream_TestControlBelowGoes B834 CP $1D Jump back to ProcessTextTokenStream_BitRecordFlag if the character is below 1D.
B836 JP C,ProcessTextTokenStream_BitRecordFlag
B839 JP ProcessTextTokenStream_Loop Jump back to ProcessTextTokenStream_Loop to read the display pointers and take the low byte of the display pointers.
Prev: B77E Up: Map Next: B83C