Prev: 72CE Up: Map Next: 7340
72D3: Print a message
Used by the routines at MATCH_PATTERN, ASK_WHICH and TARGET_TROUBLE.
Nearly everything the game says goes through here, as a compact bytecode rather than text. A byte with bit 7 set starts a two-byte word reference, high byte first: twelve bits of offset into the dictionary and a flag nibble, of which 2, 3 and 6 end the message. A byte from $60 to $7F is one of the COMMON_WORDS; from $20 to $5F, a literal character; below $20, a control code, dispatched through CONTROL_CODES -- below $14 as a subroutine that returns to the message, from $14 up as the end of it.
Checked against the screen, not only read: location 4's description decodes to exactly the words the game printed on arriving there, and so does Bag End's. The v1.0 disassembly credited in build_hobbit.py describes the same bytecode, and pointed at where to look.
The messages are stored end to end from MSG_BUT_FALL_AND_HIT, straight after COMMON_WORDS, and a few are entered part-way through another: five at an element boundary, sharing its tail -- the last is the two banks of the black river, one description entered at two places -- and one on the second byte of the word that ends the message before, which it reads as a control code.
Input
HL The message
RUN_MESSAGE 72D3 LD A,(IS_ORDER) Inside a quotation, clear DOING_IT first
72D6 AND A
72D7 JR Z,RUN_MESSAGE_HL
72D9 XOR A
72DA LD (DOING_IT),A
RUN_MESSAGE_HL 72DD LD (MESSAGE_DE),DE Keep DE, IX and A to put back at the end
72E1 LD (MESSAGE_IX),IX
72E5 LD (MESSAGE_A),A
72E8 LD A,(DOING_IT) Clear SUCCEEDED unless DOING_IT is set
72EB AND A
72EC JR NZ,RUN_SUBMESSAGE
72EE LD (SUCCEEDED),A
This entry point is used by the routine at MC_SUBMESSAGE.
RUN_SUBMESSAGE 72F1 PUSH HL IX walks the message
72F2 POP IX
RUN_MESSAGE_0 72F4 LD A,(IX+$00) Bit 7 set: a word reference
72F7 BIT 7,A
72F9 JR Z,RUN_MESSAGE_2
72FB AND $7F DE = the reference: flags and offset from the first byte, low byte from the second
72FD LD D,A
72FE LD E,(IX+$01)
7301 INC IX
7303 AND $F0 Ending flags 3, 2 or 6: print it and end the message
7305 CP $30
7307 JR Z,WORD_AND_END
7309 CP $20
730B JR Z,WORD_AND_END
730D CP $60
730F JR Z,WORD_AND_END
This entry point is used by the routine at COMMON_WORD.
MESSAGE_WORD 7311 CALL PRINT_WORD_DE Print it, and on to the next byte
RUN_MESSAGE_1 7314 INC IX
7316 JR RUN_MESSAGE_0
RUN_MESSAGE_2 7318 CP $20 $60 and up: one of the COMMON_WORDS
731A JR C,RUN_MESSAGE_3
731C CP $60
731E JP NC,COMMON_WORD
7321 CALL PRINT_LITERAL $20-$5F: print it as it is
7324 JR RUN_MESSAGE_1
RUN_MESSAGE_3 7326 PUSH DE Below $20: HL = its handler from CONTROL_CODES
7327 LD E,A
7328 LD D,$00
732A LD HL,CONTROL_CODES
732D ADD HL,DE
732E ADD HL,DE
732F LD E,(HL)
7330 INC HL
7331 LD D,(HL)
7332 EX DE,HL
7333 POP DE
7334 CP $14 $14 and up ends the message: jump to it
7336 JR NC,RUN_MESSAGE_4
7338 CALL RUN_MESSAGE_4 Below $14: call it; Z to carry on, NZ to print the word it left in DE
733B JR Z,RUN_MESSAGE_1
733D JR MESSAGE_WORD
RUN_MESSAGE_4 733F JP (HL)
Prev: 72CE Up: Map Next: 7340