Routines
| Prev: B77E | Up: Map | Next: B83C |
B77F: Fetch the next word for $B6FD's name match
|
Addresses named in the title: B6FD.
Fetch the next word of a message for B6FD's name match. B77E is $FF once the last word of the message has been given out.
How it works:
1. If B77E is $FF, the message is finished: take the most recent saved call position from the list headed at B6D6 (none left: return Z), unhook it, free its node (A1C7) and carry on reading just after the call.
2. Read the next byte. If bit 7 is set it starts a two-byte dictionary reference, which is put in DE. If its class ($70 bits) is $60, $30 or $20 it is the last word of the message, so B77E is set to $FF. Return NZ with the word in DE.
3. Below $20 is a control code. Code 2 is a jump: add the 16-bit offset to the position and carry on. Code $0B is a call: make a 2-byte node holding the position after the call, put it on the front of the list at B6D6 and go to the sub-message. Codes $1D to $1F end the text. Other codes are skipped.
4. $20 to $5F is a run of packed letters, (byte AND $1F) + 1 of them at five bits each (A990); they are stepped over, not returned.
5. $60 and above is one of the common words (A840): return NZ with A = 0.
|
||||||||||||||||
| B77F | LD A,($B77E) | Read "B6FD's flag" (B77E) into A - Finished the sub-message last time (B77E = $FF)? | ||||||||||||||
| B782 | CP $FF | Compare A with $FF | ||||||||||||||
| B784 | JR NZ,$B7AA | If A differs from $FF, skip ahead to B7AA | ||||||||||||||
| B786 | LD HL,($B6D6) | Read "B6FD's working pointers" (B6D6) into HL - Then go back to where the last one was called from (none left: Z) | ||||||||||||||
| B789 | LD A,L | Copy L into A | ||||||||||||||
| B78A | OR H | Set in A the bits that are set in H | ||||||||||||||
| B78B | RET Z | If the result is zero, return | ||||||||||||||
| B78C | XOR A | Clear A to zero (and the carry flag) - Unhook the saved position from the list at B6D6... | ||||||||||||||
| B78D | LD ($B77E),A | Store A in "B6FD's flag" (B77E) | ||||||||||||||
| B790 | PUSH HL | Save HL on the stack | ||||||||||||||
| B791 | POP IX | Restore IX from the stack | ||||||||||||||
| B793 | LD L,(IX-$02) | Read byte -2 of the record at IX into L | ||||||||||||||
| B796 | LD H,(IX-$01) | Read byte -1 of the record at IX into H | ||||||||||||||
| B799 | LD ($B6D6),HL | Store HL in "B6FD's working pointers" (B6D6) | ||||||||||||||
| B79C | LD L,(IX+$00) | Read the first byte of the record at IX into L - ...and free its node (A1C7) | ||||||||||||||
| B79F | LD H,(IX+$01) | Read byte +1 of the record at IX into H | ||||||||||||||
| B7A2 | CALL $A1C7 | Call the routine "Free node IX back to the heap" (A1C7) | ||||||||||||||
| B7A5 | INC HL | Step HL on to the next byte | ||||||||||||||
| B7A6 | INC HL | Step HL on to the next byte | ||||||||||||||
| B7A7 | PUSH HL | Save HL on the stack | ||||||||||||||
| B7A8 | POP IX | Restore IX from the stack | ||||||||||||||
| B7AA | LD A,(IX+$00) | Read the first byte of the record at IX into A - The next byte | ||||||||||||||
| B7AD | INC IX | Step IX on to the next byte | ||||||||||||||
| B7AF | BIT 7,A | Test bit 7 of A | ||||||||||||||
| B7B1 | JR Z,$B7CD | If bit 7 of A is clear, skip ahead to B7CD | ||||||||||||||
| B7B3 | LD D,A | Copy A into D - A dictionary reference: DE | ||||||||||||||
| B7B4 | LD E,(IX+$00) | Read the first byte of the record at IX into E | ||||||||||||||
| B7B7 | INC IX | Step IX on to the next byte | ||||||||||||||
| B7B9 | AND $70 | Keep only bits 4, 5, 6 of A (mask $70) - A word of class $60, $30 or $20 is the last of its message (the printer, A647, ends there): B77E = $FF | ||||||||||||||
| B7BB | CP $60 | Compare A with $60 | ||||||||||||||
| B7BD | JR Z,$B7C6 | If A equals $60, skip ahead to B7C6 | ||||||||||||||
| B7BF | CP $30 | Compare A with $30 | ||||||||||||||
| B7C1 | JR Z,$B7C6 | If A equals $30, skip ahead to B7C6 | ||||||||||||||
| B7C3 | CP $20 | Compare A with $20 - Return NZ with the word in DE | ||||||||||||||
| B7C5 | RET NZ | If A differs from $20, return | ||||||||||||||
| B7C6 | LD A,$FF | Load A with $FF | ||||||||||||||
| B7C8 | LD ($B77E),A | Store A in "B6FD's flag" (B77E) | ||||||||||||||
| B7CB | AND A | Clear the carry flag for the caller (A is unchanged) | ||||||||||||||
| B7CC | RET | Return to the caller | ||||||||||||||
| B7CD | CP $20 | Compare A with $20 - $00-$1F: a control code | ||||||||||||||
| B7CF | JR C,$B7F7 | If A is below $20, skip ahead to B7F7 | ||||||||||||||
| B7D1 | CP $60 | Compare A with $60 - $20-$5F: a run of packed letters to skip (the printer takes $20-$3F as single characters: see Bugs) | ||||||||||||||
| B7D3 | JR C,$B7DD | If A is below $60, skip ahead to B7DD | ||||||||||||||
| B7D5 | CALL $A840 | Call A840 (inside "Message bytes $60 and up: a common word") - $60 and up: one of the common words at 67B7 (A840); NZ, A = 0 | ||||||||||||||
| B7D8 | OR $01 | Set bit 0 of A | ||||||||||||||
| B7DA | LD A,$00 | Load A with $00 | ||||||||||||||
| B7DC | RET | Return to the caller | ||||||||||||||
| B7DD | AND $1F | Keep only bits 0, 1, 2, 3, 4 of A (mask $1F) - (A AND $1F) + 1 letters... | ||||||||||||||
| B7DF | INC A | Add one to A | ||||||||||||||
| B7E0 | LD B,A | Copy A into B | ||||||||||||||
| B7E1 | PUSH IX | Save IX on the stack | ||||||||||||||
| B7E3 | POP HL | Restore HL from the stack | ||||||||||||||
| B7E4 | INC HL | Step HL on to the next byte | ||||||||||||||
| B7E5 | LD C,$00 | Load C with $00 | ||||||||||||||
| B7E7 | CALL $A990 | Call the routine "Unpack the next five-bit letter (C = bit position)" (A990) - ...five bits each (A990, C counts the half bytes) | ||||||||||||||
| B7EA | DJNZ $B7E7 | Count B down and, while it is not zero, go back to B7E7 | ||||||||||||||
| B7EC | PUSH HL | Save HL on the stack | ||||||||||||||
| B7ED | POP IX | Restore IX from the stack | ||||||||||||||
| B7EF | LD A,C | Copy C into A | ||||||||||||||
| B7F0 | AND A | Test A for zero (this leaves A as it was and clears carry) | ||||||||||||||
| B7F1 | JR NZ,$B7AA | If A is not zero, go back to B7AA | ||||||||||||||
| B7F3 | DEC IX | Step IX back one byte | ||||||||||||||
| B7F5 | JR $B7AA | Go back to B7AA | ||||||||||||||
| B7F7 | CP $02 | Compare A with $02 - Code 2: a jump - follow it | ||||||||||||||
| B7F9 | JR NZ,$B807 | If A differs from $02, skip ahead to B807 | ||||||||||||||
| B7FB | LD E,(IX+$00) | Read the first byte of the record at IX into E | ||||||||||||||
| B7FE | LD D,(IX+$01) | Read byte +1 of the record at IX into D | ||||||||||||||
| B801 | ADD IX,DE | Add DE to IX | ||||||||||||||
| B803 | DEC IX | Step IX back one byte | ||||||||||||||
| B805 | JR $B7AA | Go back to B7AA | ||||||||||||||
| B807 | CP $0B | Compare A with $0B - Code $0B: a call - save the position after it on the list at B6D6... | ||||||||||||||
| B809 | JR NZ,$B834 | If A differs from $0B, jump on to B834 | ||||||||||||||
| B80B | LD E,(IX+$00) | Read the first byte of the record at IX into E - DE = the word pair at IX (its link) | ||||||||||||||
| B80E | LD D,(IX+$01) | Read byte +1 of the record at IX into D | ||||||||||||||
| B811 | PUSH IX | Save IX on the stack - Get a 2-byte heap node (A11C) | ||||||||||||||
| B813 | POP HL | Restore HL from the stack | ||||||||||||||
| B814 | LD A,$02 | Load A with $02 | ||||||||||||||
| B816 | CALL $A11C | Call the routine "Allocate A + 3 bytes from the free list, cleared" (A11C) | ||||||||||||||
| B819 | LD (IX+$00),L | Store L in the first byte of the record at IX - Put the old link in it | ||||||||||||||
| B81C | LD (IX+$01),H | Store H in byte +1 of the record at IX | ||||||||||||||
| B81F | PUSH HL | Save HL on the stack | ||||||||||||||
| B820 | LD HL,($B6D6) | Read "B6FD's working pointers" (B6D6) into HL - Push the node on the front of the list headed at B6D6 | ||||||||||||||
| B823 | LD ($B6D6),IX | Store IX in "B6FD's working pointers" (B6D6) | ||||||||||||||
| B827 | LD (IX-$02),L | Store L in byte -2 of the record at IX | ||||||||||||||
| B82A | LD (IX-$01),H | Store H in byte -1 of the record at IX | ||||||||||||||
| B82D | POP HL | Restore HL from the stack | ||||||||||||||
| B82E | ADD HL,DE | Add DE to HL - ...and go to the sub-message | ||||||||||||||
| B82F | PUSH HL | Save HL on the stack | ||||||||||||||
| B830 | POP IX | Restore IX from the stack | ||||||||||||||
| B832 | JR $B803 | Go back to B803 | ||||||||||||||
| B834 | CP $1D | Compare A with $1D - Other codes below $1D are passed over (their operands are not); $1D-$1F end the text | ||||||||||||||
| B836 | JP C,$B7AA | If A is below $1D, go back to B7AA | ||||||||||||||
| B839 | JP $B786 | Go back to B786 | ||||||||||||||
| Prev: B77E | Up: Map | Next: B83C |