Prev: $BCDE Up: Map Next: $BE08
$BD00: Manage sound effects
Called from the main loop at $0800.
$BD00 LDA $2C Pick up the sound effect identifier from $2C.
$BD02 CMP #$01 Is the shield-hitting sound effect currently playing?
$BD04 BNE $BD09 Branch if not.
$BD06 JMP $BD1A Otherwise jump forward.
$BD09 CMP #$02 Is the jumping sound effect currently playing?
$BD0B BNE $BD10 Branch if not.
$BD0D JMP $BD66 Otherwise jump forward.
$BD10 CMP #$03 Is the bell ringing?
$BD12 BNE $BD17 Branch if not.
$BD14 JMP $BDB2 Otherwise jump forward.
$BD17 JMP $BE07 Return.
The value at $2C is 1: shield-hitting sound effect.
$BD1A DEC $2D Decrement the sound effect timer at $2D.
$BD1C LDA $2D Is the sound effect timer equal to $10 now?
$BD1E CMP #$10
$BD20 BNE $BD3E Branch if not.
$BD22 LDA #$40 Set voice #2 frequency to $4000.
$BD24 STA $D408
$BD27 LDA #$00
$BD29 STA $D407
$BD2C LDA #$00 Set voice #2 attack length to 2ms and decay length to 6ms.
$BD2E STA $D40C
$BD31 LDA #$F0 Set voice #2 sustain volume to maximum and release length to 6ms.
$BD33 STA $D40D
$BD36 LDA #$11 Set voice #2 control register: voice on, attack-decay-sustain cycle; triangle waveform enabled.
$BD38 STA $D40B
$BD3B JMP $BE07 Return.
$BD3E CMP #$00 Is the sound effect timer equal to 0?
$BD40 BNE $BD55 Branch if not.
$BD42 LDA #$FB Set voice #2 sustain volume to maximum and release length to 2.4s.
$BD44 STA $D40D
$BD47 LDA #$10 Set voice #2 control register: voice off, release cycle; triangle waveform enabled.
$BD49 STA $D40B
$BD4C LDA #$00 Reset the sound effect identifier at $2C and the sound effect timer at $2D to 0.
$BD4E STA $2C
$BD50 STA $2D
$BD52 JMP $BE07 Return.
$BD55 LDA #$10 Set A to 192-8*($2D).
$BD57 SEC
$BD58 SBC $2D
$BD5A ASL A
$BD5B ASL A
$BD5C ASL A
$BD5D CLC
$BD5E ADC #$40
$BD60 STA $D408 Make this the MSB of voice #2's frequency.
$BD63 JMP $BE07 Return.
The value at $2C is 2: jumping sound effect.
$BD66 DEC $2D Decrement the sound effect timer at $2D.
$BD68 LDA $2D Is the sound effect timer equal to $20 now?
$BD6A CMP #$20
$BD6C BNE $BD8A Branch if not.
$BD6E LDA #$A0 Set voice #2 frequency to $A000.
$BD70 STA $D408
$BD73 LDA #$00
$BD75 STA $D407
$BD78 LDA #$00 Set voice #2 attack length to 2ms and decay length to 6ms.
$BD7A STA $D40C
$BD7D LDA #$F0 Set voice #2 sustain volume to maximum and release length to 6ms.
$BD7F STA $D40D
$BD82 LDA #$21 Set voice #2 control register: voice on, attack-sustain-decay cycle; saw waveform enabled.
$BD84 STA $D40B
$BD87 JMP $BE07 Return.
$BD8A CMP #$00 Is the sound effect timer equal to 0?
$BD8C BNE $BDA1 Branch if not.
$BD8E LDA #$F7 Set voice #2 sustain volume to maximum and release length to 240ms.
$BD90 STA $D40D
$BD93 LDA #$20 Set voice #2 control register: voice off, release cycle; saw waveform enabled.
$BD95 STA $D40B
$BD98 LDA #$00 Reset the sound effect identifier at $2C and the sound effect timer at $2D to 0.
$BD9A STA $2C
$BD9C STA $2D
$BD9E JMP $BE07 Return.
$BDA1 STA $57 Set A to 224-2*($2D).
$BDA3 LDA #$20
$BDA5 SEC
$BDA6 SBC $57
$BDA8 ASL A
$BDA9 CLC
$BDAA ADC #$A0
$BDAC STA $D408 Make this the MSB of voice #2's frequency.
$BDAF JMP $BE07 Return.
The value at $2C is 3: lesson bell sound effect.
$BDB2 DEC $2D Decrement the sound effect timer at $2D($2D).
$BDB4 LDA $2D Is the sound effect timer equal to $20?
$BDB6 CMP #$20
$BDB8 BNE $BDE0 Branch if not.
$BDBA LDA #$38 Set voice #2 frequency to $3800.
$BDBC STA $D408
$BDBF LDA #$00
$BDC1 STA $D407
$BDC4 LDA #$00 Set voice #2 attack length to 2ms and decay length to 6ms.
$BDC6 STA $D40C
$BDC9 LDA #$F0 Set voice #2 sustain volume to maximum and release length to 6ms.
$BDCB STA $D40D
$BDCE LDA #$43 Set voice #2 pulse width to $4350.
$BDD0 STA $D40A
$BDD3 LDA #$50
$BDD5 STA $D409
$BDD8 LDA #$41 Set voice #2 control register: voice on, attack-decay-sustain cycle; rectangle waveform enabled.
$BDDA STA $D40B
$BDDD JMP $BE07 Return.
$BDE0 CMP #$00 Is the sound effect timer equal to 0?
$BDE2 BNE $BDF7 Branch if not.
$BDE4 LDA #$F4 Set voice #2 sustain volume to maximum and release length to 114ms.
$BDE6 STA $D40D
$BDE9 LDA #$40 Set voice #2 control register: voice off, release cycle; rectangle waveform enabled.
$BDEB STA $D40B
$BDEE LDA #$00 Reset the sound effect identifier at $2C and the sound effect timer at $2D to 0.
$BDF0 STA $2C
$BDF2 STA $2D
$BDF4 JMP $BE07 Return.
$BDF7 LSR A Is the sound effect timer value even?
$BDF8 BCC $BDFF Branch if so.
$BDFA LDA #$39 This will be the MSB of voice 2's frequency.
$BDFC JMP $BE01 Jump forward.
$BDFF LDA #$37 This will be the MSB of voice 2's frequency.
$BE01 STA $D408 Set the MSB of voice #2's frequency to $37 or $39.
$BE04 JMP $BE07 Return.
$BE07 RTS
Prev: $BCDE Up: Map Next: $BE08