2009 - A fireworks demo

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
Matrixz
Posts: 19
Joined: Sat Oct 23, 2004 4:25 pm
Location: Norway
Contact:

2009 - A fireworks demo

Post by Matrixz » Wed Dec 31, 2008 3:36 pm

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.

User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg » Wed Dec 31, 2008 4:28 pm

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

User avatar
Petruza
Posts: 311
Joined: Mon Dec 22, 2008 10:45 pm
Location: Argentina

Post by Petruza » Tue Jan 06, 2009 10:02 pm

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: Select all

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

tepples
Posts: 22332
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Wed Jan 07, 2009 7:28 am

Petruza wrote:Matrixz and/or Blargg: could you explain the code for the sound effects?
[...]

Code: Select all

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.

Code: Select all

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.

Code: Select all

	; 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.

User avatar
Petruza
Posts: 311
Joined: Mon Dec 22, 2008 10:45 pm
Location: Argentina

Post by Petruza » Wed Jan 07, 2009 9:41 am

Thanks!
So, it's reading the sample info from some binary data right?
How were that samples generated?

tepples
Posts: 22332
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Wed Jan 07, 2009 10:30 am

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.

User avatar
Zepper
Formerly Fx3
Posts: 3239
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Wed Jan 07, 2009 4:07 pm

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

CartCollector
Posts: 122
Joined: Mon Oct 30, 2006 8:32 pm

Post by CartCollector » Sun Jan 25, 2009 10:40 am

This effect would would look nice when you get a high score. Someone should add it to one of their games.

tepples
Posts: 22332
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Sun Jan 25, 2009 12:12 pm

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?

CartCollector
Posts: 122
Joined: Mon Oct 30, 2006 8:32 pm

Post by CartCollector » Wed Jan 28, 2009 3:48 pm

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.

Post Reply