| Routines

6A08: Make a character speak

The address of this interruptible subcommand routine is placed into bytes 0x09 and 0x0A of the character's buffer by the routine at F05D, F073, F100, F250 or F55F.
Input
E | Message number
H | Character number (0xC8-0xCC, 0xD0)
6A08 | LD L,$0B | Store the message number in byte 0x0B of the character's buffer
6A0A | LD (HL),E
The address of this entry point is placed into bytes 0x09 and 0x0A of EINSTEIN's buffer by the routine at F000.
6A0B | LD L,$10 | Clear bytes 0x0C-0x10 of the character's buffer, thus removing the addresses of any old (sub)(sub)messages
6A0D | LD B,$05
6A0F | LD (HL),$00
6A11 | DEC L
6A12 | DJNZ $6A0F
6A14 | LD E,(HL) | E=message number
6A15 | LD D,$FE | Pick up the address of the message and place it into bytes 0x0B and 0x0C of the character's buffer
6A17 | LD A,(DE)
6A18 | LD (HL),A
6A19 | INC D
6A1A | LD A,(DE)
6A1B | INC L
6A1C | LD (HL),A
If somebody else is already speaking, this entry point is used while this character waits his turn to speak.
6A1D | LD A,($7FF8) | 7FF8 holds the LSB of the SRB address corresponding to the lip of the speech bubble (or 0 if there is no bubble on-screen)
6A20 | LD L,$09 | Place the address of the entry point at 6A1D into bytes 0x09 and 0x0A of the character's buffer
6A22 | LD (HL),$1D
6A24 | AND A | Is anyone else speaking at the moment?
6A25 | RET NZ | Return if so
6A26 | LD (HL),$2E | Place the address of the entry point at 6A2E into bytes 0x09 and 0x0A of the character's buffer
6A28 | CALL $694E | Print the speech bubble if the character's head is on-screen
6A2B | RET NC | Return if the character's head is on-screen
6A2C | JR $6A45 | Otherwise make this routine relinquish control of the character
This entry point is used while the character is speaking.
6A2E | PUSH HL |
6A2F | CALL $68E1 | Update the SRB so that the speech bubble is not corrupted
6A32 | POP HL |
6A33 | JR NC,$6A42 | Jump if the speech bubble is no longer on-screen
6A35 | EXX | Point HL' at the end of the buffer (at 5B00) which will contain the speech text graphic data
6A36 | LD HL,$5B3F
6A39 | EXX
6A3A | LD B,$02 | We scroll the message two letters at a time
6A3C | CALL $66CE | Collect in A the next character code from the message
6A3F | AND A | Has the message finished?
6A40 | JR NZ,$6A48 | Jump if not
The message has finished, or the speech bubble has been scrolled off the screen. Either way, the character has finished speaking.
6A42 | CALL $691E | Update the SRB to get rid of the speech bubble
6A45 | JP $6390 | Terminate this interruptible subcommand
The character has not finished speaking.
6A48 | PUSH BC |
6A49 | CALL $69E6 | Roll the font character bitmap into the message buffer
6A4C | POP BC |
6A4D | DJNZ $6A3C | Jump back until two more letters have been rolled into the buffer
6A4F | LD L,$1D | Reset the walk/run bit in byte 0x1D of the character's buffer to make sure he speaks slowly
6A51 | RES 7,(HL)
6A53 | LD A,($7FF8) | Now A=LSB of the address of the SRB byte corresponding to the top line of the speech bubble
6A56 | SUB $08
6A58 | LD L,A | Set HL to the display file address of the start of the top pixel line of text
6A59 | RRCA
6A5A | RRCA
6A5B | AND $18
6A5D | ADD A,$44
6A5F | LD H,A
6A60 | LD A,L
6A61 | ADD A,A
6A62 | ADD A,A
6A63 | ADD A,A
6A64 | LD L,A
6A65 | NOP
6A66 | INC L
6A67 | LD DE,$5B02 | The speech text graphic data is stored in the 64-byte buffer at 5B00
6A6A | EX DE,HL |
6A6B | CALL $6A77 | Print the top 4 pixel rows of the text inside the speech bubble
6A6E | ADD A,$20 | Set DE to the display file address of the start of the 5th pixel row of text
6A70 | LD E,A
6A71 | JR C,$6A78
6A73 | LD A,D
6A74 | SUB $08
6A76 | LD D,A
6A77 | LD A,E | Save the LSB of the base display file address
6A78 | LD B,$04 | 4 pixel lines at a time
6A7A | PUSH BC |
6A7B | LD BC,$0006 | There are 6 character squares inside the speech bubble
6A7E | LDIR | Copy a row of 6 bytes to the screen
6A80 | INC L | Move HL to the start of the next row of pixel data in the message buffer
6A81 | INC L
6A82 | LD E,A | Restore the LSB of the base display file address
6A83 | INC D | Next pixel row down
6A84 | POP BC |
6A85 | DJNZ $6A7A | Jump back until all 4 pixel rows in this half have been copied to the screen
6A87 | RET |