Prev: 26304 Up: Map Next: 26378
26318: Get the next character of a message being spoken or written
Used by the routines at 26513, 27144 and 27419. Returns with the next character in A.
Input
H Number of the character speaking or writing (183-209)
26318 LD L,16 Bytes 15 and 16 hold the address of the next character in the sub-submessage being written/spoken (if any)
26320 LD A,(HL)
26321 AND A Are we working on a sub-submessage?
26322 JR NZ,26332 Jump if so
26324 LD L,14 Bytes 13 and 14 hold the address of the next character in the submessage being written/spoken (if any)
26326 LD A,(HL)
26327 AND A Are we working on a submessage?
26328 JR NZ,26332 Jump if so
26330 LD L,12 We're working on a top-level message
26332 LD D,(HL) DE=address of the next character in the (sub)(sub)message
26333 DEC L
26334 LD E,(HL)
26335 LD A,(DE) Pick up the character code in A
26336 INC DE Move the pointer to the next character and store the address for future reference
26337 LD (HL),E
26338 INC L
26339 LD (HL),D
26340 AND A Has the end of the (sub)(sub)message been reached?
26341 JR NZ,26352 Jump if not
We've reached the end of the (sub)(sub)message.
26343 LD (HL),0 Signal: end of (sub)(sub)message
26345 DEC L L=11 (top-level message), 13 (submessage) or 15 (sub-submessage)
26346 BIT 2,L Has the end of the top-level message been reached (L=11)?
26348 RET Z Return if so
26349 DEC L Otherwise go up to the submessage or the top-level message and jump back to deal with it
26350 JR 26332
We haven't reached the end of the (sub)(sub)message yet. Determine whether the next code is a regular character code or a pointer to another message.
26352 SUB 32
26354 CP 96
26356 JR NC,26361 Jump with character codes 1-31 or 128 onwards
26358 ADD A,32
26360 RET Return with the standard ASCII code in A
26361 ADD A,32
26363 CP 3
26365 RET C Return with character codes 1 and 2 (end of line)
The next character in the message is actually a pointer to another message. Find the address of that message, and store it for future reference.
26366 LD E,A DE points to the LSB of the start address of the (sub)submessage
26367 LD D,254
26369 INC L L=13 (submessage) or 15 (sub-submessage)
26370 LD A,(DE) A=LSB of the start address of the (sub)submessage
26371 LD (HL),A Store it in byte 13 or 15 of the character's buffer
26372 INC L L=14 (submessage) or 16 (sub-submessage)
26373 INC D A=MSB of the address of the (sub)submessage
26374 LD A,(DE)
26375 LD (HL),A Store it in byte 14 or 16 of the character's buffer
26376 JR 26332 Jump back to collect a character from this (sub)submessage
Prev: 26304 Up: Map Next: 26378