DPCM Samples in SMB1

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.
JackfeldSeinfeld
Posts: 3
Joined: Sun Sep 07, 2025 11:43 am
Location: Brazil, Land of Soccer

DPCM Samples in SMB1

Post by JackfeldSeinfeld »

Hi. I'm New Here
Tell Me, is there a way to add DPCM samples to SMB1?
kinda like adding the SMB3 drum samples or the sound that plays when Link gets hurt in Zelda 2 play when Mario Shrinks. :roll:
I'm using simplistic6502's SMB2J MMC5 conversion btw.
Thanks, ig.
User avatar
Ben Boldt
Posts: 1502
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: DPCM Samples in SMB1

Post by Ben Boldt »

SMB1 already does use DPCM samples, strangely enough. Due to the way that the sound channels are mixed together, It is used in order to give a subtle volume control to the triangle channel. So you will probably need to find that and disable it in order to use the channel for other purposes.
User avatar
TakuikaNinja
Posts: 426
Joined: Mon Jan 09, 2023 6:42 pm
Location: New Zealand

Re: DPCM Samples in SMB1

Post by TakuikaNinja »

It's raw $4011 PCM rather than DPCM, and the writes it does is better treated as a ramp to smoothly shift the DMC level for nonlinear mixing purposes.

Disabling that feature/sequence in the sound driver should be straightforward but the real problem is allocating enough PRG-ROM space within $C000-$FFF1 (assuming that interrupt vectors are not played as part of the sample) for DPCM samples. Even with the MMC5 port used here, said samples need to be placed into a bank that is mapped for the entire time they are used. Otherwise, a bankswitch during playback will result in garbage data being played as DPCM.
User avatar
Dwedit
Posts: 5257
Joined: Fri Nov 19, 2004 7:35 pm

Re: DPCM Samples in SMB1

Post by Dwedit »

Hard part is bankswitching. No room for samples in a non-expanded ROM. Need to add bankswitching to the game to expand the game, this involves rearranging the code and data to be next to other code that uses it.

Simple trick to get 8K more is to add 8K WRAM to the game, bankswitch to a bank reserved for holding the 8KB data, do a one-time copy from ROM into RAM, then bankswitch to the main 32KB.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
JackfeldSeinfeld
Posts: 3
Joined: Sun Sep 07, 2025 11:43 am
Location: Brazil, Land of Soccer

Re: DPCM Samples in SMB1

Post by JackfeldSeinfeld »

UPDATE: I got it to work. well, Kinda... Basically i wanted to play the "Link Hurt" Sample from Zelda 2 when Mario Dies, and ig it worked. somehow it just sounds like bees humming into my eardrums. :|
btw, i ripped the DMC file from a "Mike Tyson's Punch-Out!!" nsf file using famistudio. and i used code from this github repository and converted it to ca65
TakuikaNinja wrote: Tue Sep 16, 2025 5:54 pm Even with the MMC5 port used here, said samples need to be placed into a bank that is mapped for the entire time they are used. Otherwise, a bankswitch during playback will result in garbage data being played as DPCM.
i think that's what just happens at my end, even though i think the dpcm sample is in the SMBPRG bank or something idk. :(
WHATEVER I DO, IT JUST PLAYS GARBAGE DATA!
User avatar
Ben Boldt
Posts: 1502
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: DPCM Samples in SMB1

Post by Ben Boldt »

Here's a thought. When Mario dies, how about if you just lock everything up, turn off the PPU, everything, and manually play the sound with raw 8-bit PCM samples through the MMC5. Using NOPs to get your sample rate right, etc. Then resume everything when the sound is done. It will make it more dramatic for the screen to go blank during the sound like that. You could have a 44kHz 8-bit sound effect this way if you want.
JackfeldSeinfeld
Posts: 3
Joined: Sun Sep 07, 2025 11:43 am
Location: Brazil, Land of Soccer

Re: DPCM Samples in SMB1

Post by JackfeldSeinfeld »

Ben Boldt wrote: Wed Sep 17, 2025 5:10 pm Here's a thought. When Mario dies, how about if you just lock everything up, turn off the PPU, everything, and manually play the sound with raw 8-bit PCM samples through the MMC5. Using NOPs to get your sample rate right, etc. Then resume everything when the sound is done. It will make it more dramatic for the screen to go blank during the sound like that. You could have a 44kHz 8-bit sound effect this way if you want.
y'know what? you're a genius, too Bad mesen got fucked up when i loaded the rom into it (even though FCEUX runs it just fine). eh, i just give up. :(