Prev: $1DB6 Up: Map Next: $1EC2
$1DB7: Make a teacher give lines
This corresponds to $7700 in the ZX Spectrum version.
Used by the routines at $0B3B, $0ECF, $149F, $191B and $2552. Note that this routine does not first check whether the teacher is currently on screen before adding lines to ERIC's total or starting the lines-giving sound effect, which is a bug.
Input
($72) Character number of the lines recipient ($0F, $10, $11 or $14)
($D8) Lines reprimand identifier ($00-$0F)
$1DB7 LDA $D015 Pick up the current value of the sprite enable register and store a copy at $F6.
$1DBA STA $F6
$1DBC BEQ $1DC1 Branch if no sprites are enabled at the moment.
$1DBE JSR $38AC Back up existing sprite information.
$1DC1 LDA #$46 Store the address of the first line of the lines message ($46C0) at $86.
$1DC3 STA $87
$1DC5 LDA #$C0
$1DC7 STA $86
$1DC9 LDA #$46 Store the address $46D0 (where the message number of the lines recipient's name will be placed) at $88.
$1DCB STA $89
$1DCD LDA #$D0
$1DCF STA $88
$1DD1 LDA $72 Pick up the character number of the lines recipient from $72.
$1DD3 CMP #$14 Is ERIC the lines recipient?
$1DD5 BNE $1DDC Branch if not.
$1DD7 LDA #$03 The background colour of the lines message box for ERIC is cyan.
$1DD9 JMP $1DE7 Jump forward.
$1DDC CMP #$10 Is BOY WONDER the lines recipient?
$1DDE BNE $1DE5 Branch if not.
$1DE0 LDA #$05 The background colour of the lines message box for BOY WONDER is green.
$1DE2 JMP $1DE7 Jump forward.
$1DE5 LDA #$07 The background colour of the lines message box for ANGELFACE and EINSTEIN is yellow.
$1DE7 STA $84 Store the lines message box colour information at $84.
$1DE9 LDA $D41B Generate a random value between 0 and 15.
$1DEC AND #$0F
$1DEE CLC Add 3 to get 3-18 and store the result at $57.
$1DEF ADC #$03
$1DF1 STA $57
$1DF3 ASL A Now multiply by 5 and store the result at $85. This will be the number of lines to give (divided by 10): 15, 20, 25...80, 85 or 90.
$1DF4 ASL A
$1DF5 CLC
$1DF6 ADC $57
$1DF8 STA $85
$1DFA LDA $72 Pick up the character number of the lines recipient from $72.
$1DFC CMP #$14 Is ERIC the lines recipient?
$1DFE BNE $1E05 Branch if not.
$1E00 LDA #$10 Message number $10: ERIC.
$1E02 JMP $1E19 Jump forward.
$1E05 CMP #$11 Is EINSTEIN the lines recipient?
$1E07 BNE $1E0E Branch if not.
$1E09 LDA #$13 Message number $13: EINSTEIN.
$1E0B JMP $1E19 Jump forward.
$1E0E CMP #$10 Is BOY WONDER the lines recipient?
$1E10 BNE $1E17 Branch if not.
$1E12 LDA #$11 Message number $11: BOY WONDER.
$1E14 JMP $1E19 Jump forward.
$1E17 LDA #$12 Message number $12: ANGELFACE.
$1E19 STA $D0 Store the message number of the lines recipient's name at $D0, where it will never be used.
$1E1B LDY #$00 Place the message number of the lines recipient's name at $46D0.
$1E1D STA ($88),Y
$1E1F LDA $85 Copy the number of lines to give (divided by 10) from $85 to $A3.
$1E21 STA $A3
$1E23 JSR $221C Generate the character codes of the first two digits of the lines amount.
$1E26 LDY #$00 Copy the character codes of the first two digits of the lines amount to $46C0.
$1E28 LDA $8D
$1E2A STA ($86),Y
$1E2C INY
$1E2D LDA $8E
$1E2F STA ($86),Y
$1E31 LDA $72 Pick up the character number of the lines recipient from $72.
$1E33 CMP #$10 Is BOY WONDER the lines recipient?
$1E35 BEQ $1E48 Branch if so.
$1E37 CMP #$14 Is ERIC the lines recipient?
$1E39 BEQ $1E43 Branch if so.
$1E3B LDA $85 Pick up the number of lines to give from $85.
$1E3D JSR $1D37 Add this value to the score and print it.
$1E40 JMP $1E48 Jump forward.
$1E43 LDA $85 Pick up the number of lines to give from $85.
$1E45 JSR $1D4A Add them to ERIC's lines total.
$1E48 LDA #$00 Set voice #1 attack length to 2ms and and decay length to 6ms.
$1E4A STA $D405
$1E4D STA $D400 Set the LSB of voice #1's frequency to 0.
$1E50 LDA #$F8 Set voice #1 sustain volume to $0F and release length to 300ms.
$1E52 STA $D406
$1E55 LDA #$31 Set voice #1 frequency to $3100.
$1E57 STA $D401
$1E5A LDA #$21 Set voice #1 control register: voice on, attack-decay-sustain cycle; saw waveform enabled.
$1E5C STA $D404
$1E5F JSR $2043 Print the lines message above the teacher's head.
$1E62 LDA #$49 Change the address at $86 to $4980 (the address of the first line of the first lines reprimand message) and the address at $88 to $4990 (the address of the second line of the first lines reprimand message.
$1E64 STA $87
$1E66 STA $89
$1E68 LDA #$80
$1E6A STA $86
$1E6C LDA #$90
$1E6E STA $88
$1E70 LDA $D8 Pick up the lines reprimand identifier from $D8.
$1E72 AND #$0C Add 0, 1, 2 or 3 to the MSBs of the lines reprimand message addresses at $86 and $88 depending on whether bits 3 and 2 of A are 00, 01, 10 or 11.
$1E74 ASL A
$1E75 ASL A
$1E76 ASL A
$1E77 ASL A
$1E78 ASL A
$1E79 BCC $1E83
$1E7B INC $87
$1E7D INC $87
$1E7F INC $89
$1E81 INC $89
$1E83 ASL A
$1E84 BCC $1E8A
$1E86 INC $87
$1E88 INC $89
$1E8A LDA $D8 Pick up the lines reprimand identifier from $D8.
$1E8C LSR A Add $00, $20, $40 or $60 to the LSBs of the lines reprimand message addresses at $86 and $88 depending on whether bits 1 and 0 of A are 00, 01, 10 or 11.
$1E8D LSR A
$1E8E BCC $1E9C
$1E90 LDA #$40
$1E92 CLC
$1E93 ADC $86
$1E95 STA $86
$1E97 CLC
$1E98 ADC #$10
$1E9A STA $88
$1E9C LDA $D8
$1E9E LSR A
$1E9F BCC $1EAD
$1EA1 LDA #$20
$1EA3 CLC
$1EA4 ADC $86
$1EA6 STA $86
$1EA8 CLC
$1EA9 ADC #$10
$1EAB STA $88
$1EAD LDA #$29 Set voice #1 frequency to $2900.
$1EAF STA $D401
$1EB2 JSR $2043 Print the lines reprimand message above the teacher's head.
$1EB5 LDA #$20 Set voice #1 control register: voice off, release cycle; saw waveform enabled.
$1EB7 STA $D404
$1EBA LDA $F6 Were any sprites enabled before this routine was called?
$1EBC BEQ $1EC1 Return if not.
$1EBE JSR $38EF Otherwise restore the previous sprite information.
$1EC1 RTS
Prev: $1DB6 Up: Map Next: $1EC2