Open badgertapes opened 1 week ago
You're right, there isn't a how-to for it, even though it's a one liner and it's described in API docs. Still, I may add this how-to in the future.
Short answer:
move.b #<<YOUR SAMPLE ID>>, d0
jsr MegaPCM_PlaySample
Long answer:
Just like you call PlaySound
to play SFX using SMPS (Sonic 1's main driver), you can call MegaPCM_PlaySample
to play SFX samples using Mega PCM.
So instead of this:
move.w #sfx_Bumper,d0
jsr (PlaySound_Special).l ; play bumper sound
You'll do this:
move.b #<<YOUR SAMPLE ID>>, d0
jsr MegaPCM_PlaySample
Where <<YOUR SAMPLE ID>>
is a sample number in Mega PCM's sample table. You usually count these manually starting from $81 (but comments help in tracking those numbers).
It's also recommended that your sample will have FLAGS_SFX
set (it will still work without it, but it may get interrupted by BGM drums, which would have the same priority otherwise), for example:
SampleTable:
; type pointer Hz
dcSample TYPE_DPCM, Kick, 8000 ; $81
dcSample TYPE_PCM, Snare, 24000 ; $82
dcSample TYPE_DPCM, Timpani, 7250 ; $83
dcSample TYPE_PCM, MyBumper, 0, FLAGS_SFX ; $84 NOTE: sample rate is auto-detected from WAV file
; <...>
MyBumper:
incdac MyBumper, "sound/dac/my-bumper.wav"
Thank you. Works like a charm.
Is there any case I can get this sound to play on every hit of the bumper? Only plays once in rapid succession. I'm OK with if it's not possible
Oh, you technically can, if you remove FLAGS_SFX
. Unfortunately, this also means it can be interrupted by BGM drums now, but if it's a rapid succession, it should be fine for you.
Samples with FLAGS_SFX
have the highest priority and they can't be interrupted by anything, even by another sample with the same flag. It's a limitation of this flag since version 1.x. I'll consider adding more flexibility in the future.
I'm interested in playing back a PCM sample in Sonic 1 (AS disasm) in lieu of a sound effect. Let's say, in place of SndB4 - Bumper. How can I go about doing this? I'm not sure if I see this written down in documentation, so I apologize if I missed it.