mod nes apu to disable sound channels

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

Moderator: Moderators

Post Reply
pikasurf
Posts: 5
Joined: Fri Jun 19, 2015 2:48 pm

mod nes apu to disable sound channels

Post by pikasurf » Sun Sep 10, 2017 3:42 pm

hello all,

i wasn't sure whether to put this in the music section or here, but sided with here because it involves real hardware.

i was wondering if the nes apu/cpu could be modded to disable/enable specific sound channels (p1, p2, t, n, and dmc). i realize that emulators can already do this, but i'd love to be able to do it on a real nes. im not talking about the hi-def mod feature either, because that is only possible for the emulated audio sent through hdmi. anybody know if this is possible through a hardware modification?

edit: whoops, i accidentally posted it in the music section!

lidnariq
Posts: 8902
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: mod nes apu to disable sound channels

Post by lidnariq » Sun Sep 10, 2017 4:00 pm

pulse channels 1 and 2 are one channel.
Triangle, noise, and DPCM are the other.

https://forums.nesdev.com/viewtopic.php?p=72984#p72984

User avatar
Fisher
Posts: 993
Joined: Sat Jul 04, 2015 9:58 am
Location: -29.794229 -55.795374

Re: mod nes apu to disable sound channels

Post by Fisher » Sun Sep 10, 2017 5:11 pm

Interesting...
Can 2 NES CPU's be tied together and make one play only p1 and triangle while the other plays p2, noise and DMC?

lidnariq
Posts: 8902
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: mod nes apu to disable sound channels

Post by lidnariq » Sun Sep 10, 2017 5:13 pm

No, there's no way to selectively disable channels on one CPU other than by changing the code that is executed.

I'm not certain if any of the rest of that's possible either, but the above is an obvious very-difficult-to-bypass thing.

User avatar
Memblers
Site Admin
Posts: 3777
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: mod nes apu to disable sound channels

Post by Memblers » Sun Sep 10, 2017 5:31 pm

I seem to remember when ripping NSFs, that many games often wrote $0F to $4015 during the init and never touch it again (unless they are using DPCM). In that case it should be possible to use a Game Genie code to disable channels. Change the $0F byte to mask out whatever channels you want. Won't work for everything.

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

Re: mod nes apu to disable sound channels

Post by rainwarrior » Sun Sep 10, 2017 5:47 pm

Memblers wrote:I seem to remember when ripping NSFs, that many games often wrote $0F to $4015 during the init and never touch it again (unless they are using DPCM). In that case it should be possible to use a Game Genie code to disable channels. Change the $0F byte to mask out whatever channels you want. Won't work for everything.
Shouldn't it work for everything? Reset silences all channels, and $4015 is the only way to re-enable them. Masking writes to $4015 should be enough... I think?

The only thing I think you're missing is the nonlinear mix from shared channels, but that's a pretty subtle thing, acceptable to ignore in most cases.

User avatar
Memblers
Site Admin
Posts: 3777
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: mod nes apu to disable sound channels

Post by Memblers » Sun Sep 10, 2017 6:04 pm

rainwarrior wrote:
Memblers wrote:I seem to remember when ripping NSFs, that many games often wrote $0F to $4015 during the init and never touch it again (unless they are using DPCM). In that case it should be possible to use a Game Genie code to disable channels. Change the $0F byte to mask out whatever channels you want. Won't work for everything.
Shouldn't it work for everything? Reset silences all channels, and $4015 is the only way to re-enable them. Masking writes to $4015 should be enough... I think?
Yeah, what I was thinking is that some games might do wacky stuff and write to $4015 all over the place even if they didn't need to, then you'd just run out of GG codes. So probably better to say it should work for almost everything. Actually this would probably work with DPCM games as well, you might look for them writing $0F as well as $1F to $4015 and possibly need 2 codes (assuming again that they only have one bit of code that handles this write).

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

Re: mod nes apu to disable sound channels

Post by rainwarrior » Sun Sep 10, 2017 6:51 pm

Oh, I didn't realize you meant actually doing it with a game genie. I just presumed were were talking about theoretically building a board with two NES CPUs on it, and just masking $4015 writes for them both.

User avatar
Fisher
Posts: 993
Joined: Sat Jul 04, 2015 9:58 am
Location: -29.794229 -55.795374

Re: mod nes apu to disable sound channels

Post by Fisher » Mon Sep 11, 2017 3:25 pm

This is great!
Altough very complicated to do!!

pikasurf
Posts: 5
Joined: Fri Jun 19, 2015 2:48 pm

Re: mod nes apu to disable sound channels

Post by pikasurf » Mon Sep 11, 2017 4:26 pm

wow, thanks for the input everyone!
lidnariq wrote:pulse channels 1 and 2 are one channel.
Triangle, noise, and DPCM are the other.

https://forums.nesdev.com/viewtopic.php?p=72984#p72984
i didnt know that they were bunched in 2 channels. can a mod be installed just to enable/disable those groupings, then?
Memblers wrote:I seem to remember when ripping NSFs, that many games often wrote $0F to $4015 during the init and never touch it again (unless they are using DPCM). In that case it should be possible to use a Game Genie code to disable channels. Change the $0F byte to mask out whatever channels you want. Won't work for everything.
i dont really have any experience with game genie codes, but this sounds cool. i have an everdrive for nes. what is the $0F byte and how do i change it? does this involve looking at game code?

lidnariq
Posts: 8902
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: mod nes apu to disable sound channels

Post by lidnariq » Mon Sep 11, 2017 4:44 pm

pikasurf wrote:i didnt know that they were bunched in 2 channels. can a mod be installed just to enable/disable those groupings, then?
Sure? If I understand you correctly?

Just search the internet for "nes stereo mod". It's a bit of a misnomer, because the voices were never intended to be separated L and R, but whatever.

User avatar
Memblers
Site Admin
Posts: 3777
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: mod nes apu to disable sound channels

Post by Memblers » Mon Sep 11, 2017 5:09 pm

pikasurf wrote:
Memblers wrote:I seem to remember when ripping NSFs, that many games often wrote $0F to $4015 during the init and never touch it again (unless they are using DPCM). In that case it should be possible to use a Game Genie code to disable channels. Change the $0F byte to mask out whatever channels you want. Won't work for everything.
i dont really have any experience with game genie codes, but this sounds cool. i have an everdrive for nes. what is the $0F byte and how do i change it? does this involve looking at game code?
Yeah, you'll have to look at the game code, but using a debug tool such as the breakpoint feature in FCEUX will take you straight to the part you want. You can set a breakpoint on writes to $4015, then the emulation will stop (very likely on a STA $4015 instruction). Then you can look at the code, and the instruction right before that will probably be LDA #$0F. When a game starts up it will usually write zero to $4015 (to disable audio when the player hits the reset button), in that case just press "run" to skip over that one. You'll be able to see the address of that LDA #$0F instruction in memory (in hexadecimal). Add 1 to it (to skip over the LDA), now you've got the address for that $0F byte. FCEUX has a Game Genie encoder/decoder built in (under the debug stuff). Enter that address, put in 0F as the compare byte, and the value you want as the value byte. And it will give you the GG code.

The value you replace 0F with, the lower 4 bits will enable each channel if set, disable if cleared. If you're not familiar with binary and hex notation, you can simply use 1, 2, 4, or 8 and that will enable 1 channel at at time (square 1, square 2, triangle, noise, respectively). Add those numbers together to enable multiple channels (e.g. 3 would be both square channels enabled).

Since you're using an Everdrive it might be easier just to modify the ROM in a hex editor. I'd recommend HxD - https://mh-nexus.de/en/hxd/
1- open ROM, choose Search, then Replace
2- in "search for" field, enter "a9 0f 8d 15 40"
3- in "replace with" field, enter "a9 01 8d 15 40" (the 01 will enable square #1 only)
3- change datatype to "hex-values"
4- hit replace all, if it doesn't find any matches, then the game is doing something differently and it might not be so easy. I took a peek at Alien 3 first and it won't work in that one, I'd guess it's going to work in 80% of games though.

pikasurf
Posts: 5
Joined: Fri Jun 19, 2015 2:48 pm

Re: mod nes apu to disable sound channels

Post by pikasurf » Mon Sep 11, 2017 6:48 pm

lidnariq wrote:
pikasurf wrote:i didnt know that they were bunched in 2 channels. can a mod be installed just to enable/disable those groupings, then?
Sure? If I understand you correctly?

Just search the internet for "nes stereo mod". It's a bit of a misnomer, because the voices were never intended to be separated L and R, but whatever.
twas unclear. i meant enable/disable each of the two channels you described. the stereo mod looks like it would do the trick, as it separates them

Memblers, thank you for that awesome walkthrough^^. im going to attempt this!

i don't have a real purpose for this, but i got the idea from the pause screen for SMB2 (USA). i like enabling/disabling the pulse channels in the background music for some reason

Post Reply