Why do DPCM samples have a ROM size limit?

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

CKY-2K/Clay Man
Posts: 215
Joined: Sun Apr 01, 2007 2:10 pm

Why do DPCM samples have a ROM size limit?

Post by CKY-2K/Clay Man » Sun Jun 02, 2013 10:08 am

Why do DPCMs have a storage size limit when full PCMs don't?
What is the exact limit size of DPCM data you can store?

I've notice Famitracker has an "expanded" size limit, but when I export to NSF, the songs freak out when it calls up a DPCM past the "limit".
Image
Here to at least get an idea of how the NES works. I mean I know alot of the basic things, but this place'll help me grasp more how NES functions.
Major respect to NES developers.

Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Re: Why do DPCM samples have a ROM size limit?

Post by Shiru » Sun Jun 02, 2013 10:14 am

DPCM is played by the hardware, so the size is limited by the hardware design. It is 16384 bytes (could be a bit more, not practically usable). If you want more, you'd have to bankswitch the top 16K, selecting needed bank for a sample, and solve all related problems (keeping vectors and other stuff in place). You can't automatically switch the bank during play, though.

PCM does not have limitations, as it is played purely by software.

CKY-2K/Clay Man
Posts: 215
Joined: Sun Apr 01, 2007 2:10 pm

Re: Why do DPCM samples have a ROM size limit?

Post by CKY-2K/Clay Man » Sun Jun 02, 2013 10:47 am

Shiru wrote:DPCM is played by the hardware, so the size is limited by the hardware design. It is 16384 bytes (could be a bit more, not practically usable). If you want more, you'd have to bankswitch the top 16K, selecting needed bank for a sample, and solve all related problems (keeping vectors and other stuff in place). You can't automatically switch the bank during play, though.

PCM does not have limitations, as it is played purely by software.
Does it include the entire ROM or just the DPCM data? I only used 9k bytes and it still freaked out. I narrowed it down to 1 song and it stopped freaking out.
Image
Here to at least get an idea of how the NES works. I mean I know alot of the basic things, but this place'll help me grasp more how NES functions.
Major respect to NES developers.

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Why do DPCM samples have a ROM size limit?

Post by thefox » Sun Jun 02, 2013 10:49 am

Shiru wrote:DPCM is played by the hardware, so the size is limited by the hardware design. It is 16384 bytes (could be a bit more, not practically usable). If you want more, you'd have to bankswitch the top 16K, selecting needed bank for a sample, and solve all related problems (keeping vectors and other stuff in place). You can't automatically switch the bank during play, though.
You must mean 4081 bytes, the limitation set by the APU DMC register $4013. Of course DMC samples can also be chained by starting the next part of the sample when the DMC IRQ hits. The IRQ handling can also employ bank switching, effectively removing all size limitations.

If FamiTracker has support for some kind of expanded size limit and it doesn't work, there's probably a bug in its NSF player code (or "not implemented", or whatever).
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Re: Why do DPCM samples have a ROM size limit?

Post by Shiru » Sun Jun 02, 2013 11:04 am

I meant total amount of DPCM data that could be used in a program without extra effort, like IRQ and bankswitching. One sample is smaller, yes, up to 4081 bytes.

CKY-2K/Clay Man
Posts: 215
Joined: Sun Apr 01, 2007 2:10 pm

Re: Why do DPCM samples have a ROM size limit?

Post by CKY-2K/Clay Man » Sun Jun 02, 2013 11:08 am

Shiru wrote:I meant total amount of DPCM data that could be used in a program without extra effort, like IRQ and bankswitching. One sample is smaller, yes, up to 4081 bytes.
This. I'm talking about all the data, not just a single sample.

Famitracker used to have an obvious limit, but I checked out a recent version and it's expanded to allow 256k of DPCM data. It works on Famitracker obviously, but when I exported it started to freak out during playback of the DPCM samples that are past the limit allowed.
Image
Here to at least get an idea of how the NES works. I mean I know alot of the basic things, but this place'll help me grasp more how NES functions.
Major respect to NES developers.

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Why do DPCM samples have a ROM size limit?

Post by thefox » Sun Jun 02, 2013 11:14 am

CKY-2K/Clay Man wrote:
Shiru wrote:I meant total amount of DPCM data that could be used in a program without extra effort, like IRQ and bankswitching. One sample is smaller, yes, up to 4081 bytes.
This. I'm talking about all the data, not just a single sample.
Well, in that case it depends on the mapper that is used. With simple mappers the limitation is 16KB or less like Shiru said, with more complex mappers the limitation is the maximum size of data that said mapper can handle. For the "complex" mappers (ones that can map into $C000-$FFFF region of memory) the PCM size limitation is not any bigger than the DPCM limitation!

For the NSF mapper, the upper limit for any data (including DPCM and PCM samples), is 1 megabyte.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

User avatar
rainwarrior
Posts: 7812
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Why do DPCM samples have a ROM size limit?

Post by rainwarrior » Sun Jun 02, 2013 11:49 am

If a Famitracker export fails, please report the bug on its forum.

Some games, like Gimmick! use an 8k region at C000-DFFF dedicated to samples. It has two 8k banks, I believe, and whenever a sample is played the correct bank for that sample gets swapped in.

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

Re: Why do DPCM samples have a ROM size limit?

Post by tepples » Sun Jun 02, 2013 12:59 pm

NSF itself is theoretically limited to 1 MiB, but the NSF player on the PowerPak can use only 256 KiB. The limit of total sample size in an NES ROM using MMC3, FME-7, etc. is limited by the number of PRG ROM address output pins on the mapper.

CKY-2K/Clay Man
Posts: 215
Joined: Sun Apr 01, 2007 2:10 pm

Re: Why do DPCM samples have a ROM size limit?

Post by CKY-2K/Clay Man » Sun Jun 02, 2013 1:35 pm

rainwarrior wrote:If a Famitracker export fails, please report the bug on its forum.
I believe it's related to this bug
http://famitracker.com/forum/posts.php?id=4396
Image
Here to at least get an idea of how the NES works. I mean I know alot of the basic things, but this place'll help me grasp more how NES functions.
Major respect to NES developers.

User avatar
Dwedit
Posts: 4306
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Why do DPCM samples have a ROM size limit?

Post by Dwedit » Tue Jun 04, 2013 1:33 pm

MMC3 can bankswitch the second-last 8k, so you can have unlimited samples (limited only by total ROM size).
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

CKY-2K/Clay Man
Posts: 215
Joined: Sun Apr 01, 2007 2:10 pm

Re: Why do DPCM samples have a ROM size limit?

Post by CKY-2K/Clay Man » Fri Jun 07, 2013 2:07 pm

Dwedit wrote:MMC3 can bankswitch the second-last 8k, so you can have unlimited samples (limited only by total ROM size).
Is that why some of the samples are missing on PocketNES on SMB3 (ex: samples in world 2 theme)? I thought it was because it might have been using raw PCM but it was a Delta PCM.
Image
Here to at least get an idea of how the NES works. I mean I know alot of the basic things, but this place'll help me grasp more how NES functions.
Major respect to NES developers.

User avatar
Dwedit
Posts: 4306
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Why do DPCM samples have a ROM size limit?

Post by Dwedit » Sat Jun 08, 2013 1:19 pm

That would be a bug in Pocketnes, thanks for the report.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

CKY-2K/Clay Man
Posts: 215
Joined: Sun Apr 01, 2007 2:10 pm

Re: Why do DPCM samples have a ROM size limit?

Post by CKY-2K/Clay Man » Sat Jun 08, 2013 5:40 pm

Dwedit wrote:That would be a bug in Pocketnes, thanks for the report.
lol
It's been there for the longest time, really. It does it with the last samples of world 1 too, but I think it's the same samples used in the desert theme anyways.
Image
Here to at least get an idea of how the NES works. I mean I know alot of the basic things, but this place'll help me grasp more how NES functions.
Major respect to NES developers.

User avatar
Dwedit
Posts: 4306
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Why do DPCM samples have a ROM size limit?

Post by Dwedit » Sun Jun 09, 2013 8:13 am

11 lines of code changed and the bug is fixed now. It was calculating the sample's address too early, now it doesn't look up the address until it actually starts fetching samples.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

Post Reply