I can't seem to get it to repeat just one sound, it seems like I've tried everything :/ On the NESDev wiki it says $400d isn't used so could that be what I am missing? Just setting another bit or two?
Code:
LDA #%00001000
STA $4015
LDA #%00100010
STA $400C
LDA #%00000111
STA $400E
LDA #%00000000
STA $400F
Maybe you should write $08 (%00001000) instead of 0 into $400f to disable the lenght counter ?
Hmm nope, does same thing :/ Just hits the note, and just keeps repeating, it's not constant T.T
Oh I'm not sure what you want to do. If you want the sound to decay one, but don't repeat you shouldn't set bit 5 of $400c. If you want the sound to be at constant volume level then you should set both bit 4 and bit 5 of $400c.
Yeah I just want a constant sound.....Setting those bits seemed not to work, either....Leme try alot harder to find the page where it showed every sound registers stuff, as I lost it, maybe the page changed....
Bregalad hit the problem right on the money. You need to set bit 4 to disable decay.
Code:
LDA #%00100010
STA $400C
If this doesn't solve your problem, then the problem must be somewhere else in the code (ie: maybe you're writing to $400C again somewhere else)
Ahhh yes it did work, I set the bits of the wrong address. It works now for the single tone
Next is, well.....How do I make it decrease without it repeating? 0_o I can't get it.....Grr.....There's not really anything that really details this as good as the lost document did T.T
To get a non-looping envelope, you need to turn off bits 5 and 4 of $400C and load a valid length counter value into bits 7-3 of $400F. But at that point, a more versatile way involves software envelopes: turn on bits 5 and 4 for constant-volume mode, and write decreasing values to bits 3-0 over the course of several frames.
Okay so for that channel you must do it manually?
I generally use this as a reference:
http://slack.net/~ant/nes-emu/apu_ref.txt
Quote:
Next is, well.....How do I make it decrease without it repeating?
- disable looping (bit 5 clear)
- enable decay (bit 4 clear)
The side effect of this is that the length counter will be enabled, so you'll have to specify a longer length or else the note will cut out early.
Code:
LDA #%0000xxxx ; where xxxx is the decay speed
; higher values = slower decay
STA $400C
LDA #%00000111
STA $400E
lda #%00001000 ; use the longest length to prevent the note from cutting out
STA $400F
Or... you can just use a constant note like you were before and just change the volume every couple of frames.
EDIT: doh too slow
Ahhh thanks alot! ^_^ I got the bit assignments all kinds of screwed up :/ I got it working now with a basic understanding, thanks so much guys! Lets hope I can make some decent sound effects with this one channel XD
65024U wrote:
Lets hope I can make some decent sound effects with this one channel XD
Good luck with that
. Lots of sound effects are made by canceling out music played on the square waves temporarily and playing the sound effect. Like Mario's jump, for example, is made with the square wave. The only sound effect I can think of made with the noise channel is the block breaking or the Bowser Bridge falling. I make most of my sound effects with square waves. Maybe you should consider allowing your code to make sound effects this way as it allows for more/better sound effects. Just a suggestion!
Some games like Rygar use the two square channels for music, and the noise and triangle for sound effects. Cheap, but at least you can say that a commercial game has done it as well!
Celius wrote:
I make most of my sound effects with square waves. Maybe you should consider allowing your code to make sound effects this way as it allows for more/better sound effects.
I agree, but I can also think of several noisy sound effects in commercial games:
- Gunfire (Duck Hunt and several others)
- Climbing steps (Kung Fu)
- Bomb explosion (Wario Blast and Tetris Blast for Game Boy)
- Balloon breaking (Balloon Fight)
- Falling into water (Balloon Fight; possibly other games)
- Piece landing and locking (Tetris for Game Boy)
- Castle front door opening (Super Mario Land 2 for Game Boy)
- Mario or shell hits a brick (Super Mario World for Super NES)
Yeah what I am using this for is a bomb fuse sound and it does a pretty good job! ^_^