Friday, August 23, 2013

The NES and the Powerpak - An Oldie but Goodie

Once upon a time, if you wanted to play a game on the Nintendo Entertainment System, you needed the cartridge of that game.  The idea of a flash, programmable or rewritable cartridge, either with a single game or a multi-cart, was something strictly in the domain of hackers and pirates.  Unlike other cartridge systems, where the internal hardware inside the cartridge rarely varied, there were enormous numbers of different cartridge hardware for the NES.  While the basic NES cartridge could support either 16KB or 32KB of game code (Program ROM) and 8KB of graphics tiles (Character ROM), anything beyond that required hardware to implement a bank switching scheme to allow the game to overcome those limits.

When a NES or Famicom cartridge uses extra hardware, that hardware is called a mapper.  With the Japanese Family Computer (Famicom), Nintendo created several methods, some using simple glue logic, others using custom application-specific integrated circuits (ASICs) which it termed Multi-Memory Controllers (MMCs).  It allowed its initial partners, Namco, Konami, Sunsoft, Irem, Bandai, Jaleco and Taito to make cartridges and whatever hardware they could put on them.  Later partners had to use Nintendo's boards almost without exception.  Some Famicom mappers supported additional sound channels.  Many games used battery backed static RAM (S-RAM) in the cartridge to save games, and a few used EEPROM to save.

When the Famicom came to the USA and became the NES, Nintendo implemented stricter controls over cartridge manufacture.  Almost without exception, it manufactured all cartridges and its partners had to use the hardware Nintendo offered or their game would not be released.  The number and variety of different mapping schemes was greatly reduced compared with the Japanese cartridges.  This situation carried over into Europe.  However, all versions of the NES added a lockout chip, one region for the US and Canada, a region for the U.K., Italy and Australia (PAL-A), a region for the rest of Europe (PAL-B), and even a region for short lived Hong Kong version of the NES.

Still, when unlicensed third parties entered the scene, they quickly devised their own mapping schemes, although sometimes their schemes function identically with a Nintendo mapper.  Unlicensed manufacturers were Tengen (began as a licensed third party), Camerica/Codemasters, Color Dreams/Wisdom Tree/AGCI/Bunch Games, SEI/American Video Entertainment, Racermate, Inc., Panesian, Caltron/Myriad and Active Enterprises.  These cartridges contain various methods to defeat the lockout chip in the NES.

In Japan the Famicom had an add-on peripheral called the Famicom Disk System.  This allowed the users to load games off special, 3" floppy disks into a special adapter cartridge containing 32KB and 8KB of RAM and an ASIC containing the logic and code necessary to control the disk drive and provide an extra sound channel.  Disks were much, much easier to manufacture than ROM cartridges and far cheaper to make. Nintendo considered releasing it in the west, but the disks did not have a great profit margin, were easy to pirate, not very reliable and the peripheral was not a smash success in Japan.  Because of all those issues it was never released overseas.  Still, several of Nintendo's classics like The Legend of Zelda, Zelda II: The Adventure of Link, Metroid, Kid Icarus, Super Mario Bros. 2 and Doki Doki Panic and Konami classics like the first two Castlevania games were released first for the Disk System.

The NES hardware found its way into the arcades.  The Playchoice-10 was an arcade machine that allowed people to play NES games for as long as they had quarters to buy time in the machine.  The games themselves were on PCBs that inserted into special slots on the arcade PCB, but the code was little changed from the consumer cartridge and can easily be run with the appropriate NES cartridge.  This was the only exposure The Goonies had in the West.  The Vs. System was an arcade machine dedicated to playing an adapted NES or Famicom game like Duck Hunt or Super Mario Bros.  The game would usually be more challenging for the arcades and often have some additional graphics.  The NES hardware would still be the basis for the game, however the games started via coin slots and multiple, incompatible PPU chips were used with the games.

Most licensed NES games use only a few mappers.  0, 1, 2, 3, 4 & 7 are the most popular.  5, 9, 13, 34 & 66, 69, 105, 118, 119 & 206 are also used by NES games, although often only one to five games may use a mapper.  Unlicensed NES games use several more mappers, including 11, 34, 41, 64, 68, 71, 79, 113, 144, 158, 168, 228 & 232

As anyone might observe, this dizzying array of hardware would have made anyone wary of trying to make a cartridge that could play multiple games as a multi-cart.  Early copiers are very obscure nowadays and never covered a complete variety of hardware.  Emulators began to be able to play a large number of games and the ability to dump games was focused on in the mid-to-late 90s.  Not until 2007 was a cartridge released that allowed people to play a wide variety of games on a real NES or Famicom.  That cartridge is called the NES PowerPak, and it revolutionized the way multi-carts were made for retro-systems.  It was released by RetroZone, which had previously offered USB converter kits and adapters for NES, SNES and Genesis controllers.

There had been multi-carts before, but they used odd methods to transmit games (the Atari 2600 Cuttle Cart required the game to be converted into an audio signal) or only had a fixed and relatively small amount of memory (Tototek) to hold games.  The PowerPak's chief innovation was to allow removable storage in the form of easily available Compact Flash cards to hold games.  Thus the number of games that the cartridge could access at any one time was only limited by the size of the card and the file system.  The result was that the whole NES library could easily be fit within a 1GB Compact Flash card.

The PowerPak required a second innovation to work particularly with the NES.  Since the NES contained so many mappers, few of which could co-exist with each other, each had to be emulated by the cartridge. Bunnyboy, the inventor of the cartridge, used a large Field Programmable Grid Array (FPGA) chip that would be programmed to emulate each game's mapper as they game loaded.  The FPGA is RAM based, so it can be reprogrammed long after you and I are dead, in theory.  Other programmable logic chips may be flash memory based and have a finite number of rewrite cycles.

I was a very early adopter of the NES PowerPak, and there were some growing pains with the device. Early cartridges required a resistor pack soldered to the data pins of the video bus to avoid graphical tile corruption. I had to send my cartridge back for the modification.  The mod instructions are here for anyone who has not had their early device modded : http://www.nespowerpak.com/powerpakmod.html  In the beginning some NES games did not read the joystick properly loaded from the PowerPak, and a BIOS update, which had to be done with a Flash Programmer, was needed to fix these games.

For Famicom users, the PowerPak will require a 72-to-60 pin connector, and they are hard to find.  You will also need to make sure that the converter does not tie pins 48 and 49 on the Famicom connector.  Many, many games do tie these pins together, but some games do not and the PowerPak needs them separated to work properly.  Also, you need to consider a housing for the converter to add stability to the setup.  The PowerPak must face the rear of the Famicom when inserted into the adapter.

The PowerPak can support the expansion audio of games that use VRC6, N163, Sunsoft-5B chips and the Famicom Disk System.  If using the cartridge on the Famicom with an adapter, a 10K resistor will need to be run from pin 54 on the NES side of the connector to pin 45 of the Famicom connector, and another 10K resistor needs to be run from pins 45 to 46 on the Famicom connector.  The resistor values may need to be changed for a Famicom AV, because those resistors make the system audio virtually inaudible on the AV unit.

To obtain expansion sound on a Front Loader NES, you will need to solder a 47K resistor from pin 3 to pin 9 of the expansion connector.  To obtain expansion sound on a Top Loader, you will need to solder a wire connecting pins 51 and 54 in the PowerPak.  Next you will need to solder a 1.2K resistor between pin 51 and the audio out pin on the NES PCB.  See here for details : http://forums.nesdev.com/viewtopic.php?f=9&t=7880&hilit=top+loader+expansion+audio

The PowerPak can have a bit of trouble with some Compact Flash cards.  I would use genuine Sandisk CF cards and they should not be especially fast.  There are fakes floating around, see here for more details : http://www.ebay.com/gds/FAKE-SanDisk-Extreme-Compact-Flash-Cards-Exposed-/10000000001456539/g.html

The card requires a set of files to be put in a PowerPak directory to instruct the cartridge how to program the FPGA for each mapper or feature.  Mapper support was a bit weak at first, but it eventually improved. Also, programmers other than Bunnyboy began making their own mappers to add features beyond the intended scope of the NES PowerPak like Famicom Disk System support.  This is how the PowerPak supports mapper 5 games, which use the most complex Nintendo MMC, MMC5 at all.

In my experience, the PowerPak requires mapper files from a few sources to ensure that almost every non-Famicom game will play correctly on it.  Here is my mapper mix :

Start with the lastrelease of the official PowerPak mappers, found here : http://www.retrousb.com/downloads/POWERPAK135b2.zip.  Place those mappers into a directory labeled POWERPAK in the root of your CF card.

Next download loopy's latest PowerPak mappers, found here : http://3dscapture.com/NES/powerpak_loopy.zip.  You will also need to download his mapper 5 file separately.  They will overwrite the older mapper files (also from loopy) from the official set.

The most frequent issue with games is that they have wrong or missing headers.  All NES ROMs require a 16-byte header (iNES) for emulators to make them work.  The actual ROM in a GoodSet or No-Intro set may be perfectly dumped, but information in the header may be wrong.  Pay close attention to the mapper number, the mirroring and the battery backed flag.  I used to see a warped racetrack for Mach Rider for years in emulators and I erroneously believed it to be due to poor emulation when it was due to the wrong mirroring being set in the header.  Super Cars has a similar issue.  The NES Cart Database will give the proper mapper, mirroring and battery backed memory settings for every US/European game.  Alien Syndrome and all the Mapper 206 games should be set to Mapper 4 for the PowerPak.

At this point, you may be able to enjoy fully glitch free NES games and many Famicom and Famicom Disk System games.  Some games, like Gimmick! and Akumajou Densetsu, (the original version of Castlevania III) use expansion sound that their NES ports cannot.  Famicom Disk System games need the 16-byte header before the disk code, the crucial byte informs the PowerPak how many sides the disk is supposed to have.  FDS image = 65,500 bytes, one sided disk; FDS image = 131,000 bytes, two sided disk.  (The mapper could have determined this easily enough by the file size alone).  The PowerPak does not support two disk games.

More information about the mappers the PowerPak supports can be found here : http://wiki.nesdev.com/w/index.php/PowerPak

Fixable Issues with Games

I had some issues with certain NES games after the PowerPak folder had been setup in this way.  Here are my solutions :

Mapper 4 Games (used by many, many games, best candidates are ) :

Crystalis
Mega Man 3
Kirby's Adventure
Startropics 1-2
Super Mario Bros. 3
Mickey's Adventures in Numberland

Issue : Portion of Screen Shakes uncontrollably

Solution : These games use the MMC3's IRQ Scanline Counter to change tilesets.  On real hardware you may notice one scanline flicker a bit before a status bar, this is normal.  However, the portion of the screen after the line should not shake (with the exception of some games like Zombie Nation).  On the robot master screen of Mega Man 3, the scanline counter should cause the top line of Shadow Man's box to flicker back and forth.  I found that the save state mappers from thefox, available here : http://kkfos.aspekt.fi/projects/nes/powerpak/save-state-mappers/  make the scanline counter behave in every game.  Thefox has save state mappers for Mappers 0, 1, 2, 3, 4, 7 and 69 (except for Japanese Gimmick!), which encompass 95% of all Licensed NES games.  Use v1.6 and turn off the save state support.  His later NES PowerMappers are not as accurate with the MMC3 scanline counter.

Four-Screen Mirroring Games :

Gauntlet
Rad Racer II

Issue : Tile Corruption or Wrong Tiles

Solution : The use of the save state mapper breaks these games.  Use MAP04.MAP from loopy's latest PowerPak mappers and rename the file to MAP06.MAP.  Set the mapper from 4 to 6 for both games in the ROM header.  I would recommend the Nintendulator emulator to change the mapper number in the ROM header, which can be found here : http://www.qmtpro.com/~nes/nintendulator/, ROMs must have four screen mirroring set in the header for these games to work correctly.

Nintendo World Championships :

Issue : While the PowerPak supports this game, the official mapper does not support the dipswitches to change the time allowed for the game, and acts like no dipswitches are set, giving the player just over five minutes.  The official competition time was six minutes and twenty-one seconds.

Solution : Join Nintendoage.com, download the file MAP695.MAP attached to this thread http://nintendoage.com/forum/messageview.cfm?catid=8&threadid=97798, rename it to MAP69.MAP and overwrite the official MAP69.MAP.  This mapper file will give you the official competition competition time of six minutes and twenty-one seconds.

Broken, Buggy, Incomplete or Non-working Games :

Incomplete MMC5 Emulation : 

Bandit Kings of Ancient China - Severe Graphical Glitches due to incomplete MMC5 emulation
Uncharted Waters - Severe Graphical Glitches due to incomplete MMC5 emulation

No Mapper Support :

Racermate Challenge II
Super Mario Bros./Tetris/World Class Track Meet (PAL only)

Game Size :

Action 52 - PowerPak not big enough to fit a 1.5 Megabyte PRG-ROM, so most games will not work

CHR-ROM/CHR-RAM Conflicts:

All games are still playable :

Noah's Ark (Konami PAL only) - Background tiles corrupted
Addams Family, The - Pugsley's Scavenger Hunt - Extraneous lines on text and menu screens
Baseball Stars II - Extraneous lines and moderate graphical glitches on menu screens, game is playable
Bigfoot - Extraneous lines on title screen
Krusty's Fun House - Extraneous lines on text screens
Fisher Price - Perfect Fit - Garbled Graphics at times

Acclaim MMC3 Clone :

Mickey's Safari in Letterland (shaking status bar)

MMC3B/C Behavior :

Star Trek 25th Anniversary (glitches when character text boxes appear on screen)
Kid Klown in Night Mayor World/Mickey Mouse III: Yume Fuusen (glitches in warping effect when beginning first level)

PowerPak Menu and ROM Naming :

The PowerPak does not sort files alphabetically, it displays them as they were copied to the card.  A program called DriveSort, available here : http://www.anerty.net/software/file/DriveSort.php can be used to sort the files in a directory or subdirectory.  It does not sort files in subdirectories automatically, you have to enter each subdirectory and click on Sort.  The resulting sort may not be ideal for games that start with the same word like Super.  Due to the way long file names in FAT works, each title will be truncated to an 8.3 filename, and after the tenth game with the same first seven characters, the names start to get weird.  The result is that the sort will not work properly unless you rename the 8.3 names into something sortable.

The PowerPak menu uses an 8x8 pixel fixed width font within a 256x240 resolution.  30 lines of characters can be seen on the screen, but the TV bezel may totally or partially obscure the first and last line.  For cosmetic purposes, I place a dummy directory named ! so it gets obscured.  The menu will display 26 characters in a file name.  For a clean looking menu, I recommend shortening names whenever possible.  You can use abbreviations like Adv for Adventure and eliminate unnecessary portions of titles.  For sports games I usually shorten the title to the name of the athlete or organization and the type of game (basketball, baseball, etc.).  Arabic numerals should replace roman numerals.

The PowerPak does support battery backed S-RAM games which use the RAM for saving games.  There has to be a file with the exact same name as the ROM, with the extension .sav instead of .nes, in the SAVES subfolder of the POWERPAK folder.  The PowerPak has the capability to save to the appropriate file automatically.  However, the user cannot simply turn off the NES, he must hold the reset button down until the PowerPak menu reappears.  Later multicartridges from Krikzz will automatically create save files and keep the save if the user turns the console off.  All NES games use an 8KB S-RAM except for Romance of the Three Kingdoms II, which requires 32KB.  If using the save state mappers, the .sav file must be 32KB to save the game's state.

Competitors :

While the PowerPak is currently available for sale, there is a similar device for the NES and the Famicom made by Krikzz called the Everdrive N8.  It comes in a 60-pin version for the Famicom and a 72-pin version for the NES.  Its support for Famicom games is may be better than the PowerPak's,  It uses SD cards, which are more common nowadays than CF cards.  It has a save battery socket on the PCB, so you don't have to press reset to save a game.  Firmware updates do not require a reprogrammer, and more mappers have support for save states.  It even has enough MMC5 support to play Castlevania III, but not enough for other MMC5 games like the Koei games, Just Breed or Laser Invasion.  Among the few other NES ROMs it does not support is Nintendo World Championships, Action 52 and Cheetamen II and Maxi-15.  However, it is somewhat cheaper than the PowerPak.

No comments: