Prev: $2005 Up: Map Next: $20F5
$2043: Print a lines message or safe combination letter above a teacher's head
Used by the routines at $1DB7, $1F3A and $298B.
Input
($86,$87) Address of the first line of the message
($88,$89) Address of the second line of the message
($84) Colour information
We start by comparing the teacher's x-coordinate (T) with the x-coordinates of the leftmost columns of the skool that are on screen (S) and off (S'=S+40).
$2043 LDA $FC Pick up the teacher's x-coordinate from $FC.
$2045 CMP $59 Is S'>T (meaning the teacher is not fully off screen to the right)?
$2047 BCC $204C Branch if so.
$2049 JMP $20F4 Otherwise return (the teacher is fully off screen to the right).
$204C CMP $58 Is S>T (meaning the teacher is partially or fully off screen to the left)?
$204E BCS $2053 Branch if not.
$2050 JMP $20F4 Otherwise return (the teacher is partially or fully off screen to the left).
$2053 LDA $FC Pick up the teacher's x-coordinate from $FC.
$2055 SEC Is S>T-4 (meaning the teacher is close to the left edge of the screen)?
$2056 SBC #$04
$2058 CMP $58
$205A BCC $2070 Branch if so.
$205C LDA $FC Pick up the teacher's x-coordinate from $FC.
$205E CLC Is S'>T+5 (meaning the teacher is a good distance from the right edge of the screen)?
$205F ADC #$05
$2061 CMP $59
$2063 BCS $2075 Branch if not.
$2065 LDA $FC Pick up the teacher's x-coordinate from $FC.
$2067 SEC Subtract 3 and then S (the x-coordinate of the leftmost column of the skool on screen) to get the cell x-coordinate of the left edge of the message box. This actually shifts the centre of the message box well to the left of the teacher's head, which is probably a bug.
$2068 SBC #$03
$206A SEC
$206B SBC $58
$206D JMP $2077 Jump forward.
$2070 LDA #$04 When the teacher is close to the left edge of the screen, this sets the x-coordinate of sprite #1 (and therefore the left edge of the message box) to 32.
$2072 JMP $2077 Jump forward.
$2075 LDA #$20 When the teacher is close to the right edge of the screen, this sets the x-coordinate of sprite #1 (and therefore the left edge of the message box) to 256.
$2077 STA $9A Save this cell x-coordinate at $9A, where it will never be used.
$2079 ASL A Multiply by 8 to get the corresponding pixel x-coordinate.
$207A ASL A
$207B ASL A
$207C BCC $2086 Branch unless the pixel x-coordinate is greater than 256.
$207E LDX #$FF Set bit 8 of the x-coordinates of sprites #0-#7.
$2080 STX $D010
$2083 JMP $208B Jump forward.
$2086 LDX #$00 Reset bit 8 of the x-coordinates of sprites #0-#7.
$2088 STX $D010
$208B STA $9B Store bits 0-7 of the pixel x-coordinate at $9B.
$208D LDA $FB Pick up the teacher's y-coordinate from $FB.
$208F SEC Subtract 3 to get the y-coordinate of the top edge of the message box.
$2090 SBC #$03
$2092 ASL A Multiply by 8 to get the corresponding pixel y-coordinate.
$2093 ASL A
$2094 ASL A
$2095 STA $9C Store this pixel y-coordinate at $9C.
$2097 LDA $84 Set the colour of sprites #4 and #5 using the colour information at $84.
$2099 STA $D02B
$209C STA $D02C
$209F LDA #$00 Set the background and foreground colours of sprites #1, #2 and #3 to black.
$20A1 STA $D028
$20A4 STA $D029
$20A7 STA $D02A
$20AA LDA #$08 The message box will be 8 character cells wide.
$20AC STA $9D Store this width at $9D.
$20AE LDA $86 Copy the address of the first line of the message from $86 to $D6.
$20B0 STA $D6
$20B2 LDA $87
$20B4 STA $D7
$20B6 JSR $2005 Write the first line of the lines or safe combination letter message into the text graphic buffer.
$20B9 JSR $213B Centre the text in the text graphic buffer.
$20BC LDA #$06 Indicate to the routine at $0DD4 that this is the first line of the message.
$20BE STA $57
$20C0 JSR $0DD4 Prepare sprite graphic data from the text graphic buffer for the first line of the message.
$20C3 LDA $88 Copy the address of the second line of the message from $88 to $D6.
$20C5 STA $D6
$20C7 LDA $89
$20C9 STA $D7
$20CB JSR $2005 Write the second line of the lines or safe combination letter message into the text graphic buffer.
$20CE JSR $213B Centre the text in the text graphic buffer.
$20D1 LDA #$21 Indicate to the routine at $0DD4 that this is the second line of the message.
$20D3 STA $57
$20D5 JSR $0DD4 Prepare sprite graphic data from the text graphic buffer for the second line of the message.
$20D8 JSR $3724 Set up sprites #1-#5.
$20DB LDA #$3E Enable and draw sprites #1-#5.
$20DD STA $D015
$20E0 JSR $31DF Pause.
$20E3 JSR $31DF
$20E6 JSR $31DF
$20E9 JSR $31DF
$20EC JSR $31DF
$20EF LDA #$00 Disable all sprites.
$20F1 STA $D015
$20F4 RTS
Prev: $2005 Up: Map Next: $20F5