Prev: $2241 Up: Map Next: $246B
$2387: Make a character speak
This corresponds to $7986 in the ZX Spectrum version.
The address of this interruptible subcommand routine is placed into a character's buffer by the routines at $09E9, $0A58, $0B3B, $1F4D, $1FA0, $2241, $2757, $277D and $28BC.
$2387 LDA #$00 Remove any submessage address from the character's buffer.
$2389 STA $AE
$238B STA $AF
$238D LDA $FC Pick up the character's x-coordinate.
$238F STA $57 Store it at $57 and increment it.
$2391 INC $57
$2393 LDA $58 Pick up the x-coordinate of the leftmost column of the skool on screen.
$2395 CMP $57 Is the character off-screen to the left?
$2397 BCC $239C Branch if not.
$2399 JMP $1D28 Otherwise terminate this interruptible subcommand.
$239C LDA $59 Pick up the x-coordinate of the leftmost column of the skool that is off screen.
$239E INC $57 Is the character off-screen to the right?
$23A0 CMP $57
$23A2 BCS $23A7 Branch if not.
$23A4 JMP $1D28 Otherwise terminate this interruptible subcommand.
$23A7 LDA $D015 Are any sprites enabled at the moment?
$23AA BEQ $23AF Branch if not.
$23AC JMP $246A Otherwise return (someone else is speaking).
The character is on-screen and no one else is speaking at the moment.
$23AF LDA #$58 Replace the address of this interruptible subcommand routine in the character's buffer with that of $2458 (below).
$23B1 STA $AA
$23B3 LDA #$24
$23B5 STA $AB
$23B7 LDA #$CA Store $CA40 (the address of the sprite for the first middle section of the speech bubble) at $4E.
$23B9 STA $4F
$23BB LDA #$40
$23BD STA $4E
$23BF LDA #$00 Remove any existing text from this sprite.
$23C1 LDY #$24
$23C3 STA ($4E),Y
$23C5 DEY
$23C6 CPY #$0B
$23C8 BNE $23C3
$23CA LDA #$80 Store $CA80 (the address of the sprite for the second middle section of the speech bubble) at $4E.
$23CC STA $4E
$23CE LDA #$00 Remove any existing text from this sprite.
$23D0 LDY #$24
$23D2 STA ($4E),Y
$23D4 DEY
$23D5 CPY #$0B
$23D7 BNE $23D2
$23D9 LDA $60 Pick up the current character number from $60.
$23DB CMP #$0B Is it $00-$0A (one of the little boys)?
$23DD BCS $23E2 Branch if not.
$23DF JMP $23EE Jump forward.
$23E2 CMP #$0F Is the current character a teacher ($0B-$0E)?
$23E4 BCS $23EE Branch if not.
$23E6 LDA $FB Pick up the teacher's y-coordinate from $FB.
$23E8 SEC Subtract 3 from the teacher's y-coordinate. This will be the y-coordinate of the speech bubble.
$23E9 SBC #$03
$23EB JMP $23F3 Jump forward.
$23EE LDA $FB Pick up the boy's y-coordinate.
$23F0 SEC Subtract 2 from the boy's y-coordinate. This will be the y-coordinate of the speech bubble.
$23F1 SBC #$02
$23F3 ASL A Multiply this y-coordinate by 8 to get the screen pixel y-coordinate.
$23F4 ASL A
$23F5 ASL A
$23F6 CLC Add 52 to this pixel y-coordinate and store the result at $D1.
$23F7 ADC #$34
$23F9 STA $D1
$23FB LDA #$00 Reset bit 8 of the x-coordinates of all sprites.
$23FD STA $D010
$2400 LDA $FC Pick up the character's x-coordinate.
$2402 CLC Add 4 to the character's x-coordinate.
$2403 ADC #$04
$2405 SEC Subtract the x-coordinate of the leftmost column of the skool on screen.
$2406 SBC $58
$2408 ASL A Multiply by 8 to get the screen pixel x-coordinate of the lip section of the speech bubble.
$2409 ASL A
$240A ASL A
$240B BCC $2415 Branch unless the multiplication overflowed.
$240D LDX #$28 Set bit 8 of the x-coordinates of sprites #3 and #5.
$240F STX $D010
$2412 JMP $241B Jump forward.
$2415 JSR $379F Prepare sprites #0-#6 for the speech bubble with the lip on the left.
$2418 JMP $241E Jump forward.
$241B JSR $3805 Prepare sprites #0-#6 for the speech bubble with the lip on the right.
$241E LDA #$40 Stretch sprite #6 (the filled in middle section of the speech bubble) to double width.
$2420 STA $D01D
$2423 LDA #$00 Set the colour of sprites #0-#3 (the outline sections of the speech bubble) to black.
$2425 STA $D027
$2428 STA $D028
$242B STA $D029
$242E STA $D02A
$2431 LDA #$01 Set the colour of sprites #4-#6 (the filled in sections of the speech bubble) to white.
$2433 STA $D02B
$2436 STA $D02C
$2439 STA $D02D
$243C LDA $D1 Set the y-coordinates of sprites #0-#6.
$243E STA $D001
$2441 STA $D003
$2444 STA $D005
$2447 STA $D007
$244A STA $D009
$244D STA $D00B
$2450 STA $D00D
$2453 LDA #$7F Enable sprites #0-#6 and draw them.
$2455 STA $D015
This entry point is used while the character is speaking.
$2458 JSR $246B Slide a message character into the speech bubble text window.
$245B BCC $2465 Branch unless the message has finished.
$245D LDA #$00 Disable all sprites, effectively removing the speech bubble.
$245F STA $D015
$2462 JMP $1D28 Terminate this interruptible subcommand.
$2465 JSR $246B Slide another message character into the speech bubble text window.
$2468 BCS $245D Branch if the message has finished.
$246A RTS
Prev: $2241 Up: Map Next: $246B