I made the sound effects in Famitracker, each one as a song, all in one file. (just like last time).
Apparently, there are no restrictions on Fx and such when making Sound Effects for Famitone2 (except the length needs to be fairly short). You need to cut the sound off every channel at the end, and add the effect…C00, which ends the pattern early. Then export the songs into 1 NSF file.
Now, put it in Famitone2/tools. and run the nsf2data from the command line…
nsf2data SoundFx.nsf -ca65
…and it will produce a SoundFx.s file that we can include into our reset.s file…
And, enable Sound Fx for the Famitone2 engine…
.define FT_SFX_ENABLE 1
And, I edited the Famitone2.s file again, adding some underscored labels…
(I have only 1 Sound Fx Stream enabled right now, THAT is why I’m loading X with zero, to force the stream to be #0. You may wish to enable more streams, in which case, delete the ‘ldx #0’ line, and make sure X has the appropriate value before calling FamiToneSfxPlay).
And I can call the sound effect by passing the sound effect # (corresponds to the song # in the NSF file, first song = 0) to the Play_Fx() function.
void __fastcall__ Play_Fx(unsigned char effect);
In my example, I have 3 sound effects set up. The first is set to trigger anytime you jump. The second and third are tied to the Up/Down buttons.
if (((joypad1old & UP) == 0)&&((joypad1 & UP) != 0))
Start button still switches between the 2 songs. Here’s the source code…
On a side note, I’m sorry I didn’t use any DPCM samples in any of my examples. I personally think DPCM samples are great for sound effects – even if they use a lot of ROM space. You can use any .wav sound sample, and convert it to a DMC file with Famitracker (inside the instrument options), and you can use Famitone2 to trigger the sample. I really should revisit this subject in the future.