Petruza wrote:
Matrixz and/or Blargg: could you explain the code for the sound effects?
[...]
Code:
shoot_sound:
lda #$01
sta $400C
lda <random+3
and #$03
sta $400E
lda #$08
sta $400F
rts
$400C=$01 sets the envelope decay rate (lower is faster) and turns on the hardware length counter.
$400E=$00 through $03 sets the pitch of the sound.
$400F=$08 sets the length of the sound.
Quote:
Code:
explode_sound:
lda #0
sta $4015
lda #$F
sta $4010
lda #0
sta $4011
lda #0
sta $4012
lda #$C0-3 ; -3 to get rid of thump at end of sample
sta $4013
lda #$18
sta $4015
$4015=$00 turns off all length counters and the sample playback hardware.
$4010=$0F sets the waveform playback rate to 33 kHz.
$4011=$00 sets the starting sample value to 0 (out of 127).
$4012=$00 sets the start address to $C000 (using the formula $C000+value*40).
$4013=$BD sets the length to 3025 bytes (using the formula 1+value*16), or 3025*8=24200 samples.
$4015=$18 turns the noise length counter back on and starts the sample.
Quote:
Code:
; Noise burst
lda #$00
sta $400C
lda <random+3
lsr a
and #1
adc #$0B
sta $400E
lda #$08
sta $400F
rts
Virtually identical to the first snippet, except at a lower pitch.
$400C=$00 sets the envelope decay rate and turns on the hardware length counter.
$400E=$0B through $0C sets the pitch of the sound.
$400F=$08 sets the length of the sound.