| Routines

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

Used by the routines at 28994 and 29706. Returns with the next character in A.
Input
H | Number of the character speaking or writing (152-169)
28882 | LD L,110 | Bytes 109 and 110 of the character's buffer hold the address of the next character in the submessage
28884 | LD A,(HL)
28885 | AND A | Are we in a submessage at the moment?
28886 | JR Z,28904 | Jump if not
28888 | LD D,A | DE=address of the next character in the submessage
28889 | DEC L
28890 | LD E,(HL)
28891 | LD A,(DE) | Pick up this character in A
28892 | AND A | Has the submessage finished?
28893 | JR Z,28901 | Jump if so
28895 | NOP |
28896 | INC DE | Move to the next character in the submessage, and store its address in bytes 109 and 110 of the character's buffer
28897 | LD (HL),E
28898 | INC L
28899 | LD (HL),D
28900 | RET |
The submessage has finished.
28901 | LD (HL),A | Zero out bytes 109 and 110 of the character's buffer to indicate that the submessage is finished
28902 | INC L
28903 | LD (HL),A
We are dealing with the main message.
28904 | LD L,108 | DE=address of the next character in the main message (collected from bytes 107 and 108 of the character's buffer)
28906 | LD D,(HL)
28907 | DEC L
28908 | LD E,(HL)
28909 | LD A,(DE) | Pick up the next character of the message
28910 | INC DE | Move to the next character in the main message, and store its address in bytes 107 and 108 of the character's buffer
28911 | LD (HL),E
28912 | INC L
28913 | LD (HL),D
28914 | INC L | L=109
28915 | BIT 7,A | Is the ASCII code of the next character < 128?
28917 | JR Z,28938 | Jump if so
The ASCII code of the next character is >= 128, which refers to an entry in one of the symbol/element, capital city/country and date/battle question-and-answer pairs.
28919 | AND 127 | Set DE to 57088+12*(A-128)
28921 | LD E,A
28922 | EX DE,HL
28923 | ADD A,A
28924 | ADD A,L
28925 | LD L,A
28926 | LD H,56
28928 | JR NC,28931
28930 | INC H
28931 | ADD HL,HL
28932 | ADD HL,HL
28933 | DEC H
28934 | EX DE,HL
28935 | LD A,(DE) | Pick up the first character of this submessage in A and store the next address in bytes 109 and 110 of the character's buffer
28936 | JR 28896
The ASCII code of the next character in the message is < 128.
28938 | CP 32 | Return if the next character is a normal, printable character (ASCII code >= 32)
28940 | RET NC
28941 | CP 16 | Return if the ASCII code of the next character in the message is < 16
28943 | RET C
The ASCII code of the next character in the message is 16-24. We have a submessage to deal with, which will be one of the following:
Code | Address | Submessage
--- | --- | ---
16 | 55680 | 'ERIC'
17 | 55694 | 'BOY WANDER'
18 | 55708 | 'ANGELFACE'
19 | 55722 | 'EINSTEIN'
20 | 55736 | 'MR WACKER'
21 | 55750 | 'MR ROCKITT'
22 | 55764 | 'MR WITHIT'
23 | 55778 | 'MR CREAK'
24 | 55792 | 'Please Sir - I cannot tell a lie . . '
28944 | SUB 16 | Point DE at the appropriate submessage from the table above
28946 | LD E,A
28947 | ADD A,A
28948 | ADD A,A
28949 | ADD A,A
28950 | SUB E
28951 | ADD A,A
28952 | ADD A,128
28954 | LD E,A
28955 | LD D,217
28957 | LD A,(DE) | Pick up the first character of the submessage in A
28958 | JR 28896 | Store the address of the next character in the submessage