+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  Mapper 7 (AOROM) & Writes to Sound Registers
Pages: [1]
Author Topic: Mapper 7 (AOROM) & Writes to Sound Registers  (Read 2 times)
Dr. Floppy
Guest
« on: January 18, 2009, 06:16:26 pm »

Does anyone know anything about NES Mapper #7 (AOROM), specifically whether or not it had any significant add-ons that would enable special sound routines (and, by extension, prevent them from working within non-AOROM games)?

If not, I'd love to port the kickdrum from the Battletoads pause theme (roughly 3:48) into classic games such as Mario and Zelda. Given the non-Atari nature of the sound (the bass beat from the second measure, NOT that belching thing), I'm guessing that it's probably a DMC sample, which would require additional handling in non-DMC games such as SMB1.


Disch
Guest
« Reply #1 on: January 18, 2009, 09:13:32 pm »

Quote from: Dr. Floppy on January 18, 2009, 06:16:26 pm
Does anyone know anything about NES Mapper #7 (AOROM)

Yes

Quote
specifically whether or not it had any significant add-ons that would enable special sound routines (and, by extension, prevent them from working within non-AOROM games)?

Nope.  No extra sound in AOROM at all.  AOROM is actually very, very, very simplistic and bare-bones.  Many of the games that use it are coded by insane madmen and do very crafty things to push maximum power out of the minimum a mapper can provide (you mention battletoads, which is an infamous example of this -- that game pulls off an insane amount of really cool tricks).

Quote
If not, I'd love to port the kickdrum from the Battletoads pause theme (roughly 3:48) into classic games such as Mario and Zelda.

Not going to happen.  All the kickdrum/punch/etc sound effects in Battletoads are streamed PCM (writes to $4011 at timed intervals).  In order to play this sound effect you need to dedicate a VERY large portion of in game CPU time into LDAing sample data and STAing it to $4011 every few cycles.  It's tricky and extremely time consuming -- in fact, you can't really do much else while you're doing it.

Ever notice how everything in game stops when it plays those sound effects in game?  And during the title sequence, you can notice the text drawing and things get choppier when the drums are playing -- and the drums in the title screen cut out completely for parts where there's too much on-screen action going on.

Quote
I'm guessing that it's probably a DMC sample, which would require additional handling in non-DMC games such as SMB1.

$4011 is part of the DMC, but it's not the "usual" DMC.  Most DMC sound effects are fetched and streamed automatically by the DMC unit, so all it takes is the sound effect stored in ROM somwhere, a few register writes, and then the hardware takes care of the rest.  $4011 streaming has to be done completely in software -- no hardware support.


- EDIT -

I suppose you could always convert the streamed PCM to the DMC format and play it the "normal" way.  Then you could probably get it to work in Mario/Zelda.  It would only be an approximation of the original sound, though.  Probably wouldn't sound as good.
« Last Edit: January 18, 2009, 09:19:52 pm by Disch »
Dr. Floppy
Guest
« Reply #2 on: January 18, 2009, 09:46:15 pm »

Quote from: Disch on January 18, 2009, 09:13:32 pm
I suppose you could always convert the streamed PCM to the DMC format and play it the "normal" way.  Then you could probably get it to work in Mario/Zelda.  It would only be an approximation of the original sound, though.  Probably wouldn't sound as good.

Then my first task will be setting a write breakpoint for $4011 in Battletoads and backtracking to find the code for the kickdrum in question. Is there any specific method of PCM --> DMC conversion, or is it pretty straightforward once one familiarizes themselves with the respective paradigms?

I erred earlier in limiting my application intent to Zelda and Mario. While such games would be worthy showcases of better kickdrum samples, my main goal is to incorporate a decent-sounding kickdrum into a ghetto-themed Dragon Warrior hack slated for release sometime in 2012. Of course, all the medieval flute stuff will be replaced with 8-bit renditions of "In Da Club" and the like. The original game didn't use the Noise channel to any appreciable extent, so I figured if I'm going to be doing Noise/DMC ASM coding, I might as well go for broke.

Like many of the classics, Dragon Warrior is MMC1; anything I need to be wary of with respect to that particular mapper?
Disch
Guest
« Reply #3 on: January 18, 2009, 10:06:48 pm »

Quote from: Dr. Floppy on January 18, 2009, 09:46:15 pm
Is there any specific method of PCM --> DMC conversion, or is it pretty straightforward once one familiarizes themselves with the respective paradigms?

I'm pretty sure there are wav->dmc conversion utilities.  If you can get a wav recording of sound effect (without other sound channels playing -- which is probably relatively easy to do during the pause screen in Battletoads), save it as an 8-bit mono .wav file and run it through a conversion util.  I don't think there are any on this site, but you can check 2a03.org or nesdev.parodius.com for one (2a03.org would be my first target).

Keep in mind, though, with this method there will be significant quality loss.  You may be better off taking a kickdrum sound from another game.  Konami had some pretty good ones used in the CV series and TMNT1.  If you go this route you won't have to mess with conversions, and the samples themselves quite possibly have already been ripped from the game (again, I'd check 2a03.org for them -- maybe even post on the forums there about it).

Quote
Like many of the classics, Dragon Warrior is MMC1; anything I need to be wary of with respect to that particular mapper?

Nothing particularly special about it.  Only thing to mention is it doesn't allow swapping at $C000-FFFF with the standard setup (which I'm sure DW uses) -- and that DMC samples must lie within that range.  Which means you'll have to clear out or move a significant portion of code/data from that bank to make room for the sample data.


EDIT:

Also should mention this.

It's been semi-recently discovered that the DMC can interfere with serial register reads -- notably $4016 (joypad) and $2007 (PPU reading).  The DMC can insert 'dummy' reads from these addresses if the DMA occurs while the game is reading from them.  This can mess up your joypad data or mess up the data you're reading from the PPU.

If you add the DMC to a game which does not use it, be sure to do the following:

1)  Redo the joypad reading routine so that it strobes and reads data multiple times (at least twice).  Generally I think games keep reading data until they get 2 sets of buttons that match.

2)  Make sure the DMC isn't playing during $2007 reads.  I doubt Dragon Warrior reads from $2007, so you probably don't have to worry about this -- but you never know.

Emulators will not catch this, but things like the PowerPak will exhibit very strange quirks if you fail to do this (like the player seemingly randomly walking on his own due to false button presses caused by disrupted joypad reads)


EDIT2 -

Relevent information:

http://nesdev.parodius.com/bbs/viewtopic.php?t=4116
« Last Edit: January 18, 2009, 10:33:55 pm by Disch »
Dr. Floppy
Guest
« Reply #4 on: January 19, 2009, 12:59:14 am »

Quote from: Disch on January 18, 2009, 10:06:48 pm
You may be better off taking a kickdrum sound from another game.  Konami had some pretty good ones used in the CV series and TMNT1.  If you go this route you won't have to mess with conversions, and the samples themselves quite possibly have already been ripped from the game (again, I'd check 2a03.org for them -- maybe even post on the forums there about it).


Excellent! I can fire up the NSF Player and peruse said games at my leisure upon my triumphant return home from work on Tuesday. Would some of these samples be stored as regular Noise Channel sounds? I found the part of SMB1 that creates each percussion "instrument" sound effect:

Code:
$78A1: A9 1C A2 03 A0 18 D0 12 A9 1C A2 0C A0 18 D0 0A A9 1C A2 03 A0 58 D0 02

The (segmented) 1C--03--18 sequence creates the "hihat" sound, 1C--0C--18 the "kickdrum" and 1C--03--58 the "snare". Is this essentially how all games do it, or are there additional factors that can be put into play in order to affect the final product(s)? Three slots at 256 possible values per slot equals almost 17 million potential combinations. (And I'm guessing they all sound like Atari SFX.)


Quote from: Disch on January 18, 2009, 10:06:48 pm
Only thing to mention is it doesn't allow swapping at $C000-FFFF with the standard setup (which I'm sure DW uses) -- and that DMC samples must lie within that range.  Which means you'll have to clear out or move a significant portion of code/data from that bank to make room for the sample data.

That explains why Zelda 1 always has the data at $[1C000-1FFFF] loaded in that particular slot...

Quote from: Disch on January 18, 2009, 10:06:48 pm
If you add the DMC to a game which does not use it, be sure to do the following:

1)  Redo the joypad reading routine so that it strobes and reads data multiple times (at least twice).  Generally I think games keep reading data until they get 2 sets of buttons that match.

2)  Make sure the DMC isn't playing during $2007 reads.  I doubt Dragon Warrior reads from $2007, so you probably don't have to worry about this -- but you never know.

I'll keep a close eye on that portion of the hex editor whilst wandering around aimlessly / slamming into invisible creatures. (Something tells me I'll be doing a lot of that anyway during playtesting.)

Quote from: Disch on January 18, 2009, 10:06:48 pm


Good stuff! I've got that bookmarked for future reference. Mr. Disch, it's been quite a pleasure.  Smiley :cookie:
Disch
Guest
« Reply #5 on: January 19, 2009, 01:31:49 am »

Quote from: Dr. Floppy on January 19, 2009, 12:59:14 am
Would some of these samples be stored as regular Noise Channel sounds?

Yes.  I think Konami uses the noise for its snare drums in many games (CV2 comes to mind).

Quote
The (segmented) 1C--03--18 sequence creates the "hihat" sound, 1C--0C--18 the "kickdrum" and 1C--03--58 the "snare". Is this essentially how all games do it, or are there additional factors that can be put into play in order to affect the final product(s)?

It all depends on the music driver.  Since you'll be adding this stuff to a game which doesn't already support it, you'll have to write your own driver, which means you can design the format any way you want.  It might be easier to have a single byte represent a specific sound effect.. like maybe:

Code:
00 = whole note
01 = half note
02 = quarter note
03 = eighth note

80 = snare
81 = kickdrum

example score:

00 00 81 02 80 81 02 81 02 80 81 02

Which would wait 2 measures, then play a kickdrum every beat and a snare every odd beat (see it?).

The length of whole/half/quarter notes will need to be translated into a number of frames -- which you'll have to examine the game's existing music driver to figure out how it figures that out so that you can match its tempo.

As for actually playing these...

DMC is pretty easy, just set up the regs at $4010-4013 to have it point to your sample data and stuff... then start it up with $4015.

Noise is bit trickier.  Noise sound effects will often require attention for several frames.  Like you'll have to set the regs to something one frame, then set them to something else a few frames down the line, then to something else, etc.  This isn't terribly difficult to do.

Noise comes down to three basic parts:
- mode:   short (bzzz) or long (shhhh)
- freq:   the pitch, low or high (16 possible pitches for noise)
- volume: 16 possible output volumes:  0 (silence) - $F (full)

Creating a good sound effect will require pitch and volume changes at a somewhat rapid rate.  This is just an example, but say you want to do the following for a sound effect:

- Freq 5, vol 7  for 5 frames
- Freq 7, vol 6  for 2 frames
- Freq 8, vol 3  for 9 frames
- Freq 8, vol 0 (sound effect done)

You could store this like so:

Code:
57 05 76 02 83 09 80 00

You'd just need to keep a counter which counts down every frame to know when to perform the next part of the sound effect.  And you'd need to keep a pointer of sorts to know where in the sound effect you currently are, so that when the down counter expires you know which byte to apply next.  Applying the volume and freq changes are as simple as [properly] copying those numbers to the noise regs.

There's also a decay unit on the noise if you want rapid (faster than 1 frame) volume changes.  But that'll probably be unnecessary and would require a more complicated sound effect format.

Music driver stuff is fun, but a lot of work.  Getting it to work alongside an existing music driver is an even bigger challenge.  You might want to consider gutting the game's original music/sound effect system and writing your own.  In the long run it might be simpler -- or not.  It's hard to say.

Quote
I'll keep a close eye on that portion of the hex editor whilst wandering around aimlessly / slamming into invisible creatures.

Tongue

Fortunately most games have a specific routine for polling the joypad reg.  So you just have to find that one routine and change it and you should be good to go.

Quote
Mr. Disch, it's been quite a pleasure.  Smiley :cookie:

Likewise.  I love music driver stuff.  If you need further theories/explanations/whathaveyou, don't be shy. ^^
KingMike
Guest
« Reply #6 on: January 19, 2009, 09:31:15 am »

Since you're talking about Battletoads' mapper...
I vaguely recall Xodnizel (?, FCEU author) years ago asking for ROMs for two different mapper varients of Battletoads. (supposedly labeled on the cart as NES-8T-USA-1?)
Any confirmation a revision ("-1" in the ID) exists?
(a seach of the GoodNES reveals only AOROM (mapper 7).)

And this amusing pirate Cheesy
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC