Routines
| Prev: A85C | Up: Map | Next: A92F |
A880: Print the dictionary word that HL refers to
|
HL points at a 2-byte word reference (low 12 bits: offset into the dictionary; high nibble: flags). Prints nothing when output is switched off ($5C3C = 0: the text belongs to something the player cannot see) or the reference is 0. Otherwise prints a space, finds the word through the per-letter index at 5D80, prints it (A95B) and its suffix. Called by the object-name printers at $A39F-$A3F8 and by $D5E5.
How it works:
1. Take the 12-bit offset and the flag nibble from the two bytes at HL; print nothing if output is off ($5C3C) or the offset is 0.
2. Print a space, then find the letter whose records contain the offset by searching the per-letter index at 5D80.
3. From that letter's first record, spell each record (A95B) until the offset is reached; the spelling is built at $5C42 from its kept letters, new packed letters and suffix.
4. Print the spelling a letter at a time through the word-wrap printer, applying capitals and the flag nibble's rules.
|
||||||||||||||
| A880 | LD E,(HL) | Read the byte HL points at into E - DE = the 2-byte word reference at HL: low 12 bits the dictionary offset... | ||||||||||||
| A881 | INC HL | Step HL on to the next byte | ||||||||||||
| A882 | LD A,(HL) | Read the byte HL points at into A | ||||||||||||
| A883 | INC HL | Step HL on to the next byte | ||||||||||||
| A884 | AND $0F | Keep only bits 0, 1, 2, 3 of A (mask $0F) - ...high nibble the flags; HL moves on past it | ||||||||||||
| A886 | LD D,A | Copy A into D | ||||||||||||
|
This entry point is used by the routines at A2E4, A37D, A5CD, A63F, A7EB, A80E, A82F, BF1C, CB7B, D113, D526, D5D3, D60B and D68C.
|
||||||||||||||
| A887 | LD A,($5C3C) | Read the output-switch byte (TV_FLAG) ($5C3C) into A - Output switched off ($5C3C = 0)? | ||||||||||||
| A88A | AND A | Clear the carry flag for the caller (A is unchanged) | ||||||||||||
| A88B | RET Z | Yes: print nothing | ||||||||||||
| A88C | LD ($A022),DE | Remember the reference in A022 | ||||||||||||
| A890 | LD A,D | Copy D into A - Offset zero: no word, print nothing | ||||||||||||
| A891 | AND $0F | Keep only bits 0, 1, 2, 3 of A (mask $0F) | ||||||||||||
| A893 | OR E | Set in A the bits that are set in E | ||||||||||||
| A894 | RET Z | If the result is zero, return | ||||||||||||
| A895 | PUSH IX | Save IX on the stack - Save the registers the dictionary search will use | ||||||||||||
| A897 | PUSH HL | Save HL on the stack | ||||||||||||
| A898 | PUSH BC | Save BC on the stack | ||||||||||||
| A899 | PUSH DE | Save DE on the stack | ||||||||||||
| A89A | LD A,$20 | Load A with $20 - Print a space first (A9B7) | ||||||||||||
| A89C | CALL $A9B7 | Call the routine "Print character A, a word at a time (word wrap)" (A9B7) | ||||||||||||
| A89F | LD A,D | Copy D into A - Flag nibble into C | ||||||||||||
| A8A0 | AND $F0 | Keep only bits 4, 5, 6, 7 of A (mask $F0) | ||||||||||||
| A8A2 | LD C,A | Copy A into C | ||||||||||||
| A8A3 | CP $70 | Flag $70? | ||||||||||||
| A8A5 | LD A,$01 | Load A with $01 - Then set $A026 to 1 | ||||||||||||
| A8A7 | JR NZ,$A8AC | If A differs from $70, skip ahead to A8AC | ||||||||||||
| A8A9 | LD ($A026),A | Store A in $A026 in "Game variables" | ||||||||||||
| A8AC | LD A,D | Copy D into A - Offset alone into HL | ||||||||||||
| A8AD | AND $0F | Keep only bits 0, 1, 2, 3 of A (mask $0F) | ||||||||||||
| A8AF | LD D,A | Copy A into D | ||||||||||||
| A8B0 | EX DE,HL | Swap DE and HL | ||||||||||||
| A8B1 | PUSH HL | Save HL on the stack | ||||||||||||
| A8B2 | LD A,H | Copy H into A | ||||||||||||
| A8B3 | OR C | Set in A the bits that are set in C | ||||||||||||
| A8B4 | LD H,A | Copy A into H | ||||||||||||
| A8B5 | LD ($A022),HL | Store HL in A022 in "Game variables" - A022 = offset with the flag nibble | ||||||||||||
| A8B8 | POP HL | Restore HL from the stack | ||||||||||||
| A8B9 | PUSH BC | Save BC on the stack | ||||||||||||
| A8BA | LD IX,$5D80 | IX = the per-letter index at 5D80 (2 bytes a letter) | ||||||||||||
| A8BE | LD B,$5F | Load B with $5F - B counts letters from 'a' (the code before 'a' is $60) | ||||||||||||
| A8C0 | INC B | Add one to B | ||||||||||||
| A8C1 | LD A,(IX+$01) | Read byte +1 of the record at IX into A - Find the last letter whose first record starts at or before the offset (high byte, then low) | ||||||||||||
| A8C4 | CP H | Compare A with H | ||||||||||||
| A8C5 | JR C,$A8CF | If A is below H, skip ahead to A8CF | ||||||||||||
| A8C7 | JR NZ,$A8D9 | If A differs from H, skip ahead to A8D9 | ||||||||||||
| A8C9 | LD A,(IX+$00) | Read the first byte of the record at IX into A | ||||||||||||
| A8CC | CP L | Compare A with L | ||||||||||||
| A8CD | JR NC,$A8D9 | If A is L or more, skip ahead to A8D9 | ||||||||||||
| A8CF | INC IX | Step IX on to the next byte | ||||||||||||
| A8D1 | INC IX | Step IX on to the next byte | ||||||||||||
| A8D3 | LD A,B | Copy B into A | ||||||||||||
| A8D4 | CP $7B | |||||||||||||
| A8D6 | JR NZ,$A8C0 | If A differs from $7B, go back to A8C0 | ||||||||||||
| A8D8 | INC B | Add one to B | ||||||||||||
| A8D9 | JR Z,$A8E0 | If B has become zero, skip ahead to A8E0 | ||||||||||||
| A8DB | DEC IX | Step IX back one byte - Step back to the previous letter | ||||||||||||
| A8DD | DEC IX | Step IX back one byte | ||||||||||||
| A8DF | DEC B | Subtract one from B | ||||||||||||
| A8E0 | LD E,(IX+$00) | Read the first byte of the record at IX into E - DE = where that letter's records start | ||||||||||||
| A8E3 | LD D,(IX+$01) | Read byte +1 of the record at IX into D | ||||||||||||
| A8E6 | LD A,D | Copy D into A - Zero means no word begins with that letter: step back again | ||||||||||||
| A8E7 | OR E | Set in A the bits that are set in E | ||||||||||||
| A8E8 | JR Z,$A8DB | If the result is zero, go back to A8DB | ||||||||||||
| A8EA | LD A,B | Copy B into A - Print the first letter itself (A9B7) | ||||||||||||
| A8EB | CALL $A9B7 | Call the routine "Print character A, a word at a time (word wrap)" (A9B7) | ||||||||||||
| A8EE | LD BC,$5DBF | Load BC with $5DBF, the amount that is added next - Dictionary base $5DBF turns offsets into addresses | ||||||||||||
| A8F1 | ADD HL,BC | Add BC to HL | ||||||||||||
| A8F2 | PUSH HL | Save HL on the stack | ||||||||||||
| A8F3 | EX DE,HL | Swap DE and HL | ||||||||||||
| A8F4 | ADD HL,BC | Add BC to HL | ||||||||||||
| A8F5 | PUSH HL | Save HL on the stack - Unpack records one at a time (A95B, front-coded) from the letter's first record up to the wanted word, leaving its spelling in $5C42 | ||||||||||||
| A8F6 | AND A | Clear the carry flag, so that the subtraction that follows is a plain one (a compare) | ||||||||||||
| A8F7 | SBC HL,DE | Subtract DE from HL (a compare: carry = HL was smaller, zero = equal) | ||||||||||||
| A8F9 | POP HL | Restore HL from the stack - (compare with the wanted word's address) | ||||||||||||
| A8FA | PUSH AF | Save AF on the stack | ||||||||||||
| A8FB | CALL $A95B | Call the routine "Unpack a dictionary record's letters (front-coded)" (A95B) | ||||||||||||
| A8FE | POP AF | Restore AF from the stack | ||||||||||||
| A8FF | JR NZ,$A8F5 | Not there yet: next record | ||||||||||||
| A901 | POP HL | Restore HL from the stack - Restore HL, BC | ||||||||||||
| A902 | POP BC | Restore BC from the stack | ||||||||||||
| A903 | LD A,C | The flag nibble decides whether the suffix is added (A92F): | ||||||||||||
| A904 | CP $50 | Compare A with $50 - $50: never | ||||||||||||
| A906 | JR Z,$A91C | If A equals $50, skip ahead to A91C | ||||||||||||
| A908 | CP $40 | Compare A with $40 - $40: always | ||||||||||||
| A90A | JR Z,$A919 | If A equals $40, skip ahead to A919 | ||||||||||||
| A90C | CP $10 | Compare A with $10 - $10: if the direct object $A034 is non-zero; any other: if the actor $A036 is | ||||||||||||
| A90E | LD A,($A034) | Read $A034 in "Game variables" into A | ||||||||||||
| A911 | JR Z,$A916 | If A equals $10, skip ahead to A916 | ||||||||||||
| A913 | LD A,($A036) | Read $A036 in "Game variables" into A | ||||||||||||
| A916 | AND A | Test A for zero (this leaves A as it was and clears carry) | ||||||||||||
| A917 | JR Z,$A91C | Zero: no suffix | ||||||||||||
| A919 | CALL $A92F | Add the dictionary suffix (A92F) | ||||||||||||
| A91C | LD HL,$5C42 | Point HL at the BASIC workspace ($5C42) - Print the unpacked spelling at $5C42 up to its 0 terminator, a character at a time | ||||||||||||
| A91F | LD A,(HL) | Read the byte HL points at into A | ||||||||||||
| A920 | AND A | Test A for zero (this leaves A as it was and clears carry) | ||||||||||||
| A921 | JR Z,$A929 | If A is zero, skip ahead to A929 | ||||||||||||
| A923 | CALL $A9B7 | Call the routine "Print character A, a word at a time (word wrap)" (A9B7) | ||||||||||||
| A926 | INC HL | Step HL on to the next byte | ||||||||||||
| A927 | JR $A91F | Go back to A91F | ||||||||||||
| A929 | POP DE | Restore DE from the stack - Restore the registers and return | ||||||||||||
| A92A | POP BC | Restore BC from the stack | ||||||||||||
| A92B | POP HL | Restore HL from the stack | ||||||||||||
| A92C | POP IX | Restore IX from the stack | ||||||||||||
| A92E | RET | Return to the caller | ||||||||||||
| Prev: A85C | Up: Map | Next: A92F |