It is currently Wed Nov 22, 2017 7:06 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Need help with MMC5 PCM
PostPosted: Fri Mar 01, 2013 5:13 am 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 251
I have some questions regarding the PCM when it deals with the MMC5.

Ive been working on a major overhaul of The Legend of Zelda. I converted the rom from MMC1 to MMC5.

Zelda uses $4010 & $4011 for the PCM sfx located at $C000-$FFFF.

The sfx are Link's flying sword, dungeon doors, boss sfx.

Ive had to use the beginning of $C000, for alot of asm to take place within the hard wired bank. In doing this, Link's flying sword sfx has been overwritten, about 40% of it.

I tried reading up on the PCM within the MMC5. Id like to know the following.

1. Can I just use $5010-$5011 as the only way to play the PCM sfx?
2. It says MMC5's PCM read the raw data from $8000-$BFFF, so, does that mean it reads it within the same bank as the sound engine? Do I/can I, define any bank for where I want the PCM to be read from?
3. The original APU PCM pointers, that load where the specific sfx starts, and how far to read, are those included in MMC5, or do those original APU registers need to stay there?

I appreciate any assistance. Ive never messed with the actual asm to a sound engine, ive rewritten music though.

Thanks for reading.

-infidelity


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 5:17 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3951
MMC5 sound won't work on the US NES, but will still work on emulators which support it. MMC5 PCM is not a DMC channel like the NES has, instead it outputs raw 8-bit samples that are written there.
In MMC5 read mode, any read from 8000-BFFF will change the sound wave, this includes CPU instruction fetches. So executing code at 8000-BFFF will change the sound wave too. The MMC5 won't automatically generate 8000-BFFF fetches at a regular interval, so it won't automatically play the sound for you.

So you're best off finding a different place to store your code, or hacking the game to use a switchable bank at C000-FFFF so it can switch between multiple sets of samples.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 7:26 am 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 251
So you are saying the hard wired bank $C000-$FFFF can be swapped?


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 8:02 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1392
infidelity wrote:
So you are saying the hard wired bank $C000-$FFFF can be swapped?

By definition, a "hard-wired" bank cannot be swapped - what he's suggesting is that you use a mapper where $C000-$FFFF (or at least $C000-$DFFF) is not hard-wired so that you can swap new banks into it. Incidentally, the MMC3 works quite nicely for this (assuming you don't mind having $8000-$9FFF hardwired instead), and it's a lot easier to get an MMC3 to put in a physical cartridge (or find a donor cartridge) than an MMC5.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 8:15 am 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 251
I originaly did use mmc3, but needed my prg to be set to 64x16kb, and the only way I could get my prg that maxed was to upgrade to mmc5. If there was a way for me to have stayed in mmc3, with the extra prg space I needed, I wouldve.

My 4000 byte banks go all the way to $100000


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 8:28 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1392
If you're using the MMC5, though, then none of the banks are actually hardwired...

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 8:43 am 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 251
I dont understand. Ive always been under the impression, that $C000-$FFF was the hw bank, regardless of whatever mapper. I apologize for not knowing otherwise.

But I believe ive found my answer, im pretty much screwed, because I need my code that I have in $C000 to stay there.

Thanks for all the info and insight everyone. :-)


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 11:04 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3951
So duplicate the code in the new bank.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 11:25 am 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 251
Duplicate it to where?

Certain functions will only work for me within $C000-$FFFF, particularly custom bankswap routines. Like if im in bank 04 and need to get into bank 30, I wiuld have to first load 30 jsr to the hw bank, perform my bankswap routine to bank 30, then when im done in there, I rts back to the hw bank, and rhen I have to bankswap back to bank 04 with a jmp to the address right after the lda 30. I tried doing bankswaps from within 04 to 30, but it never wirked, caused crasges, etc.

I cant put the cide in exram, cause $5C00-$5FFF is being used specificly for Link's movements fir hookshot, pegasus shoed.

And I cant swap my sram cause the game heavily uses sram to run the game, si when I try to swap out all the sram, it xrashes.

So im screwed. I may just remove some of the pcm sfx that I can live without, and relocate Links flying sword pcm sfx to that area.


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 11:34 am 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2257
Make a jump table and put code in RAM. If you can't do something, you have to start programming different/better. If it's a hack I'd understand, but if you're coding something, there's no reason it can't be done otherwise.


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 3:31 pm 
Offline

Joined: Fri May 13, 2011 7:36 pm
Posts: 143
3gengames wrote:
If it's a hack I'd understand


This is a hack of the Legend of Zelda, not his own source code, so it's not trivial. That said, if you look at the wiki documentation on MMC5, there is no fixed bank. You can duplicate the "fixed" bank (we'll call it "primary") to another bank (which we can call "secondary"). In the "secondary" bank replace whatever data you can with your PCM data. Then you can swap between them seamlessly, loading up whichever bank has the data you need.


Top
 Profile  
 
PostPosted: Fri Mar 01, 2013 4:19 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5827
Location: Canada
infidelity wrote:
So im screwed. I may just remove some of the pcm sfx that I can live without, and relocate Links flying sword pcm sfx to that area.


If your sounds are actually PCM you can put them anywhere, but I think you mean DPCM don't you? The MMC5 PCM channel doesn't actually do DPCM like the APU. Also, if you are doing PCM (and not DPCM) the APU is as pretty much equally capable of doing PCM as the MMC5 so it's not really worth using the MMC5's version. (It's not well supported in emulators anyway.)


Top
 Profile  
 
PostPosted: Sat Mar 02, 2013 6:26 am 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 251
Yes I think im misphrasing. The sounds are DPCM, cause they cant be played anywhere else in the rom, only $C000-$FFF.

@snarfblam, I will definitly check out that wiki document. I purposely set aside 5, 4000 byte prg banks, for when the time comes for new asm.


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 1:05 pm 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 932
Dwedit wrote:
MMC5 sound won't work on the US NES, but will still work on emulators which support it. MMC5 PCM is not a DMC channel like the NES has, instead it outputs raw 8-bit samples that are written there.
In MMC5 read mode, any read from 8000-BFFF will change the sound wave, this includes CPU instruction fetches. So executing code at 8000-BFFF will change the sound wave too. The MMC5 won't automatically generate 8000-BFFF fetches at a regular interval, so it won't automatically play the sound for you.
What exactly is the point of this? I suppose that, together with IRQ, it might be used to play back samples at a higher sample rate if it is not doing anything else, but if it is longer than 256 then you will need the code to increment the 16-bit address. Or you might use hacks to make the CPU instructions to make music, or just use that feature only for the IRQ when reading zero from that area, which would even more hack.

_________________
.


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 1:46 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1392
From what the patent describes, it was meant to be used along with an interrupt timer (probably external from the MMC5 itself) so your interrupt routine could be 4 cycles shorter (i.e. just read the value from RAM and skip the write to $5011), but said interrupt routine would also have to read $5010 to see if it had read the last byte (which makes it rather useless, since doing "BIT $5010 ; BMI done" takes just as long as "STA $5011 ; BEQ done" and also requires an additional "CLI" at the top of the IRQ routine to make it re-entrant, so overall it's slower than doing it manually).

MMC5 PCM's "read mode" would really only be useful in a system that has proper support for DMA, and that system is not the NES.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: ReverendSA, samwise970 and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group