This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

2009 - A fireworks demo

2009 - A fireworks demo
by on (#41162)
Here's a little fireworks demo, which i always wanted to do.
This could have been improved in many ways.. maybe next year ;)

Source is included.

GeoCities Download:
http://www.geocities.com/matrixz15/2009.zip

Enjoy.. and be welcome to do whatever good can be done with the source code.

by on (#41163)
Some changes (source + NES rom, as before): 2009-blargg.zip

- Delayed explosion sound
- Added noise burst to beginning of explosion sound
- Sound of firework shooting from ground
- Eliminated thump at end of explosion sound

by on (#41444)
Matrixz and/or Blargg: could you explain the code for the sound effects? it would help me a lot to understand how to make this kind of sounds. ( I just experimented with rectangular wave channels )
Thanks!

( great demo, by the way, matrixz )

Code:
shoot_sound:
   lda #$01
   sta $400C
   lda <random+3
   and #$03
   sta $400E
   lda #$08
   sta $400F
   rts
   
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
   
   ; Noise burst
   lda #$00
   sta $400C
   lda <random+3
   lsr a
   and #1
   adc #$0B
   sta $400E
   lda #$08
   sta $400F
   rts

by on (#41452)
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.

by on (#41455)
Thanks!
So, it's reading the sample info from some binary data right?
How were that samples generated?

by on (#41459)
Petruza wrote:
So, it's reading the sample info from some binary data right?
How were that samples generated?

By converting a .wav file, I'm guessing. See wiki article and conversion tool.

by on (#41477)
Great demo! :) I liked it a lot.
It's me or the fireworks explosion rate increases with the time?

by on (#42312)
This effect would would look nice when you get a high score. Someone should add it to one of their games.

by on (#42314)
CartCollector wrote:
This effect would would look nice when you get a high score. Someone should add it to one of their games.

You mean like on the right side of this video? Or this one?

by on (#42432)
I'm actually thinking more like Tempest, where there's fireworks right before the "enter your initials" screen. (scroll to 5:45) I don't think it would be feasible to use fireworks during the main game, though, unless the main game doesn't use that meny sprites. However, Tempest's fireworks are pretty lame compared to Matrixz/Blargg's program. And there's no reason why you couldn't have the fireworks after every level, say, or during the "enter your initials" screen, as long as there aren't too many sprites being used at the time.