Wednesday, January 24, 2018

sd2snes and MSU-1

The MSU-1 was a software memory controller (mapper) created by byuu for the bsnes/higan emulator to allow for vastly increased storage for SNES software.  The MSU-1 allows for ROMS up to 4GB in size whereas ROMs for the SNES were limited usually to 4MB without extra hardware.  FMV playback became possible due to the DVD-like storage capacity provided by the MSU-1.  In addition to the size increase, the MSU-1 allows for streaming audio in the same format provided by a CD, namely 16-bit uncompressed stereo audio at a 44.1KHz sample rate.  The ill-fated SNES CD-ROM system that Nintendo and Sony collaborated on was not nearly as powerful and would have suffered from noticeable load times.  In this blog post, let's talk about the hardware behind the MSU-1 and some of the more interesting hacks available for it.

On the real SNES the MSU-1 has been implemented in hardware by the sd2snes flash cart.  The MSU-1 implementation takes care of all the bankswitching required via an FPGA to allow the SNES to address up to 4GB of memory.  It generates stereo analog audio on the board and sends that audio to the SNES through the the cartridge connector's audio input pins.  This audio will be mixed with the audio inside the SNES and output via the Multi-Out connector.  The only other common cartridge-slot devices which generate audio and interact with the SNES for more than just reading gamepads are the Super Game Boys.

The sd2snes is an open source project, anyone with the skills, tools and hardware can make one.  The creator of the sd2snes, ikari, has partnered with krikzz to make "official creator-approved" boards.  The publicly available boards have had an interesting revision history which should be documented here :

Rev E1 - Initial version made by Krikzz
Rev E2 - Older then E2, changes made because ikari was unable to find a source for the voltage regulator used in E1.  Only version not sold by Krizz (open source)
Rev F - Eliminates RF-interference pattern seen in 1-Chip SNES systems, based on E1.
Rev G -  The DAC runs at 5V to improve on the MSU1 volume issue, but added noise
Rev H - Reverts Rev. G change and instead adds a unity-gain operational amplifier to the PCB to normalize volume levels with higan

The mod to bring any sd2snes board up to revision H can be found here :

This evolution may appear to be all well and good, but the revision H boards have an issue, namely a lack of filtering.  The DAC does not have the RC low-pass filter stage called for in the DAC's specifications given in its datasheet.  The output of the DAC goes almost straight into the Op-Amp.  Even though it is better to add the filter before the audio enters the Op-Amp, the Op-Amp outputs do not have a filter to perform nearly the same function.  This means that high pitched noise can be heard from the MSU-1 audio on a rev-H board.  Ironically, the pre-H units did have the RC filter stage, but the mod requires the removal of the resistors and capacitors that make up the filter stage.  Essentially the filter was removed to make room for the Op-Amp on the rev. H board.

Now you may ask, why just not add the filter back?  Unfortunately that solution is easier said than done.  If the filter were present, a negative voltage supply would have to be generated for the Op-Amp, and negative voltages are not available from the SNES's cartridge slot.  The Op-Amp on the rev. H boards was designed not to require a negative voltage, instead it uses a negative feedback resistor not unlike the inverter amp on the NES.

It seems that every day a new MSU-1 audio hack is being released for a SNES cartridge game.  Of course, the MSU-1 has been around since 2011, so the number of finished and available hacks is more modest that it may seem.  Here is a list of audio hacks available to date :

BS F-Zero Grand Prix 2
BS Zelda - Ancient Stone Tablets
BS Zelda Map 1, Map 2, Third Quest & Fourth Quest
Castlevania Dracula X
Chrono Trigger
Contra III The Alien Wars
Darius Twin
Death and Return of Superman
Donkey Kong Country
Donkey Kong Country 2
Donkey Kong Country 3
Final Fantasy 3
Final Fight*
Gradius III
Home Alone
Joe and Mac*
Legend of Zelda - A Link To The Past
Mega Man 7
Mega Man X
Mega Man X2
Mega Man X3
Power Moves
Rock n' Roll Racing
Rockman & Forte
Rival Turf (Rushing Beat)
Secret of Evermore
Secret of Mana
Street Fighter 2 The New Challengers*
Street Fighter 2 Turbo*
Super Adventure Island
Super Castlevania IV
Super Ghouls n Ghosts
Super Mario Allstars
Super Mario Kart
Super Mario World
Super Metroid
Super R-Type
Super Turrican
TMNT IV: Turtles in Time
Top Gear 1
Top Gear 2
Top Gear 3000
Toy Story
UN Squadron*

The following have hacks to insert FMV video into the game :

The Legend of Zelda - A Link To The Past (with fanmade FMV)
Final Fantasy IV (WIP using PlayStation re-release FMV, no audio enhancement)
Chrono Trigger (WIP using PlayStation re-release FMV) is the go-to site for most ROM hacks, but MSU-1 files get huge compared to your average ROM hack.  The sd2snes supports SD cards up to 32GB in size, but an MSU-1 hack can easily take 1GB of space.  You won't find the files there.  Instead you can get links to download all of the above here :

Unfortunately, at the present time there is no legitimate use for the MSU-1 of which I am aware.  Game hacking is just as illegal as game piracy.  No original SNES homebrew has been released to take advantage of the capabilities of the MSU-1.  An MSU-1 homebrew cartridge would cost a lot of money to manufacture given that it requires an FPGA for functionality and level translator buffers and a large amount of storage for the game.  Given that the SD2SNES typically runs just shy of $200, at what price point does an MSU-1 cart make sense?  How much money will you save on making essentially a cut-down version of the SD2SNES?

When I did my review of the sd2snes, I mentioned the MSU-1 and made the obligatory "Wow, they ported a Laserdisc game to the SNES with Full Motion Video intact" with Super Road Blaster, but that was about it.  I was ambivalent at best to all the audio hacks floating around.  I have never cared much for some random individual's subjective ideas about how a game's graphics or sound could be improved.  The music on virtually all of these games listed above is really, really good as it comes from the cartridge.  The SPC700 uses sample-based synthesis not unlike the Gravis Ultrasound.  Its interpolation does a good job smoothing out many of the rougher edges of the low bit-depth samples.  There are so many great SNES games I need to experience for the first time as they were released that I have little interest in or time for your average MSU-1 "CD Audio-quality" hack. While I understand that some of these hacks may use recordings from OST releases as re-recorded by people playing live instruments, most of the time the new music comes from MIDI devices.

Some of these hacks are interesting from a historical perspective.  The audio hacks in the list above marked with an * asterisk have had their arcade sound tracks added.  Additionally, Final Fight has an optional track which uses the audio tracks from the Sega CD version of the game.

The current version of the sd2snes firmware, v1.7e, has an MSU-1 audio boost feature.  You should use it if you do not have a rev. H board or the mod to rev. H.  If you still find the sampled audio too low in comparison to the internal audio, you can raise the volume level of the .pcm files in audacity.  You must Import the files as Raw Data, using 16-bit, 44100Hz stereo choices.  Then you can amplify or normalize the files, but you may need to listen to the audio a few times in a console to get the right balance.

One of the most interesting, yet obscure, elements of the sd2SNES is its support for BS-X games.  The Broadcast Satellaview was a Japanese add-on that allowed downloads of games and data to your Super Famicom.  The Satellaview was produced by Nintendo in 1995 and used the St. GIGA network to broadcast data via satellite.  It also required a satellite dish, a BS tuner (both sold separately), an AV selector, a second AC adapter, an L-shaped power transfer bracket, an BS-X application cartridge and a 8 Megabyte Memory Pack.  The system was a little complex to setup and not cheap to run.

When you started up the system, the ROM built into the application cartridge, BS-X : The Story of The Town Whose Name Was Stolen would allow your avatar to go around a town and use the various buildings to access features of the system.  You could download games, read digital magazines and receive news about contest winners and the latest games.  You could also download data meant for special Super Famicom cartridge games like Derby Stallion '96 and SameGame which had a slot in them for the Memory Pack.

Several types of games were broadcast, some were simply just regular cartridge games, with or without some minor updates.  Others were competition games held each month.  But the most interesting of the bunch were the BS original games.  An original game was broadcast weekly over the service in multiple parts, usually four.  The game would be downloaded onto the Memory Pack and then immediately run.  You would play the game for one hour (less 10 minutes with download time and opening/closing credits) and you had to complete certain goals to win that portion of the game.  Your progress would be saved for the next week's broadcast.  Many of the original games had support for the SoundLink service, where voice acting and narration would be be broadcast while the game played.

The wikipedia page on the Satellaview does a very good job of giving an overview of the system and its features.  It is well-worth a read and undoubtedly superior to my little summary.  But text and static pictures can only illustrate so much.  I would seriously suggest watching at least the first 15 minutes of this video to see how this experience really happened back in the day for Japanese gamers :

BS-X support in the sd2snes is rather hit and miss.  Some games work, some will not.  Three games that will work are BS Zelda no Densetsu: Map 1, BS Zelda no Densetsu: Map 2 and BS Zelda - Ancient Stone Tablets.  BS Zelda is a remake of the original Legend of Zelda.  Map 1 is its own game, as is Map 2, and they have differences in their overworlds and dungeons.  BS Zelda - Ancient Stone Tablets is a game using the engine found in A Link to the Past.

I understand that some ROMs may require waiting seven minutes, the download time for the games, before the games would start  The satellite link downloaded data at 2.5K/sec, which was adequate for 1995 but rather meager by 2000.  Interestingly, the way that these BS-X games were preserved is by finding a BS-X Memory Pack cartridge with game code contained on it.  Even though the game code was slightly different each week for the multi-week games, there were enough common features to recreate the whole four-week experience, at least for those games with full video recordings available.

Here is where the MSU-1 comes in.  BS Zelda broadcast digital audio and voice acting over the satellite link as you were playing the game.  The audio and voice was timed not to events in the game but to discrete points in time within the hour.  The MSU-1 can recreate that digital stream and there is a patch to add English voice acting to the game.  You are required to use the BS Zelda Restoration Map 1 ROM, which translates all the text into English.  The best place to find more information about the BS Zelda games is here :


Kawa said...

I'm glad to have been involved in the MSU-1 project.

qwertymodo said...

"The DAC does not have the RC low-pass filter stage called for in the DAC's specifications given in its datasheet. The output of the DAC goes almost straight into the Op-Amp. . . . This means that high pitched noise can be heard from the MSU-1 audio on a rev-H board."

Do you have any side-by-side recordings to compare the noise level? The datasheet specifically states that the filter is only necessary when the DAC is directly driving the output, which is not the case with the SD2SNES Rev. H, where the output is driven by the op-amp.

Great Hierophant said...

I honestly do not, but I would be happy to record some samples from my Rev F.

qwertymodo said...

I have a modded RevF->H of my own I can record and compare, I was just curious where you were coming up with the assertion that the output filter was required, when the datasheet doesn't actually seem to imply that it is unless you're directly driving an output with it, which isn't the case with the RevH output circuit. In any case, you've gotten me curious now, so I've modified borti's RevH upgrade PCB to add the filter back in between the DAC and the op-amp. It should work just fine with the single-supply amp, you just have to remove the series DC-blocking capacitor. I'll try it out with the original RevF components (with and without MSU-1 boost enabled), with borti's RevH upgrade, and with my RevH upgrade + filter. I'll be interested to see the results.

ikari_01 said...

I doubt that the omission of the filter would cause a significant amount of extra noise. Possible exception: Aliasing effects occurring in digital capture devices that do not have a low-pass filter on their own inputs. The SNES itself only has an internal low-pass filter with a cut-off frequency of ~500kHz. (1kOhm + 330pF) so that won't help with aliasing on ADCs.
I can take some measurements later, right behind the DAC and right behind the opamp.

The cut-off frequency chosen for the recommended low-pass filter in the datasheet is designed so that it's well above the Nyquist frequency for the chosen sampling rate:

Datasheet recommendation for Fs=44100Hz: Cl=~12.8nF; Fcutoff=26455Hz
sd2snes Rev. E-G: Fs=44100Hz; Cl=10nF; Fcutoff=33862Hz
The evaluation board by Cirrus uses a Fcutoff around 100000Hz IIRC.

All of these frequencies are well above the limit of human hearing so whatever high-pitch noise occurs, being in the audible range it would have been untouched by the filter anyway.

I wonder whether this was a theoretical observation or anybody actually experienced high pitch noise with the Rev.H sd2snes. The DAC is always on btw, so the noise should be audible with regular games as well.

With Rev.E-G, the DACs AGND was connected via a ferrite bead to minimize digital noise coming from load fluctuations of the SNES input - the DAC was painfully overloaded with the 200 Ohm resistors inside the SNES, it only survives because of the high-pass filter on its outputs (3.3uF + 10kOhm) but as a result the output is way too quiet and has no bass.

With Rev.H said ferrite bead should be replaced with a jumper/0-ohm resistor to give the opamp a solid GND (which it needs since it's actually able to drive the SNES's load). There is more audible digital noise, sounding like the CPU "working", when AGND is still connected via a ferrite bead instead of a direct connection.
I fear that some Rev.Hs actually shipped with ferrite beads which might in turn have led to noise.

That said, neither revision of the sd2snes should be considered to be anywhere near audiophile standards, you can hear interference with any revision. It is more pronounced with 1CHIP consoles. I think the SNR is somewhere around 60-80dB.