| Routines

70D2: Get the next character of a message being spoken or written

Used by the routines at 7142 and 740A. Returns with the next character in A.
Input
H | Number of the character speaking or writing (0x98-0xA9)
70D2 | LD L,$6E | Bytes 0x6D and 0x6E of the character's buffer hold the address of the next character in the submessage
70D4 | LD A,(HL)
70D5 | AND A | Are we in a submessage at the moment?
70D6 | JR Z,$70E8 | Jump if not
70D8 | LD D,A | DE=address of the next character in the submessage
70D9 | DEC L
70DA | LD E,(HL)
70DB | LD A,(DE) | Pick up this character in A
70DC | AND A | Has the submessage finished?
70DD | JR Z,$70E5 | Jump if so
70DF | NOP |
70E0 | INC DE | Move to the next character in the submessage, and store its address in bytes 0x6D and 0x6E of the character's buffer
70E1 | LD (HL),E
70E2 | INC L
70E3 | LD (HL),D
70E4 | RET |
The submessage has finished.
70E5 | LD (HL),A | Zero out bytes 0x6D and 0x6E of the character's buffer to indicate that the submessage is finished
70E6 | INC L
70E7 | LD (HL),A
We are dealing with the main message.
70E8 | LD L,$6C | DE=address of the next character in the main message (collected from bytes 0x6B and 0x6C of the character's buffer)
70EA | LD D,(HL)
70EB | DEC L
70EC | LD E,(HL)
70ED | LD A,(DE) | Pick up the next character of the message
70EE | INC DE | Move to the next character in the main message, and store its address in bytes 0x6B and 0x6C of the character's buffer
70EF | LD (HL),E
70F0 | INC L
70F1 | LD (HL),D
70F2 | INC L | L=0x6D
70F3 | BIT 7,A | Is the ASCII code of the next character < 0x80?
70F5 | JR Z,$710A | Jump if so
The ASCII code of the next character is >= 0x80, which refers to an entry in one of the symbol/element, capital city/country and date/battle question-and-answer pairs.
70F7 | AND $7F | Set DE to DF00+0x0C*(A-0x80)
70F9 | LD E,A
70FA | EX DE,HL
70FB | ADD A,A
70FC | ADD A,L
70FD | LD L,A
70FE | LD H,$38
7100 | JR NC,$7103
7102 | INC H
7103 | ADD HL,HL
7104 | ADD HL,HL
7105 | DEC H
7106 | EX DE,HL
7107 | LD A,(DE) | Pick up the first character of this submessage in A and store the next address in bytes 0x6D and 0x6E of the character's buffer
7108 | JR $70E0
The ASCII code of the next character in the message is < 0x80.
710A | CP $20 | Return if the next character is a normal, printable character (ASCII code >= 0x20)
710C | RET NC
710D | CP $10 | Return if the ASCII code of the next character in the message is < 0x10
710F | RET C
The ASCII code of the next character in the message is 0x10-0x18. We have a submessage to deal with, which will be one of the following:
Code | Address | Submessage
--- | --- | ---
0x10 | D980 | 'ERIC'
0x11 | D98E | 'BOY WANDER'
0x12 | D99C | 'ANGELFACE'
0x13 | D9AA | 'EINSTEIN'
0x14 | D9B8 | 'MR WACKER'
0x15 | D9C6 | 'MR ROCKITT'
0x16 | D9D4 | 'MR WITHIT'
0x17 | D9E2 | 'MR CREAK'
0x18 | D9F0 | 'Please Sir - I cannot tell a lie . . '
7110 | SUB $10 | Point DE at the appropriate submessage from the table above
7112 | LD E,A
7113 | ADD A,A
7114 | ADD A,A
7115 | ADD A,A
7116 | SUB E
7117 | ADD A,A
7118 | ADD A,$80
711A | LD E,A
711B | LD D,$D9
711D | LD A,(DE) | Pick up the first character of the submessage in A
711E | JR $70E0 | Store the address of the next character in the submessage