Saturday, September 21, 2013

SNES flash cartridge SFC-32

A year ago I have acquired a pure SNES console without any additional peripherals (joypad, power supply, video cable etc.). The console was untested. Some months later I've also found some cartridges for it (Super Mario World), thus the story continued: connected the console to TV, inserted a cart and turned it on: IT WORKED! Perfect! ;)

Thousands games are available for this great console; most of them have superb 2D classic pixel graphics and perfect stereo digital audio. The graphical and sound capabilites are much better than Amiga 500; 256 colors on the sreen at once, multi hardware layers, extra large sprites, 8 channel audio D/A, mode 7 etc. 

After testing some games in emulator the results were fantastic. Chaos Engine looked similar to the A1200 version (it has 2 frame scroll, why?!), but Street Fighter, Final Fight and Mortal Kombat 2 were exactly the same as the original arcade versions! 

The next step was straightforward: purchase or develop a flash cartridge for the SNES. A brand new Super UFO costs 70-80 USD, others also have similar price.

Below You can watch the preview video of my own developed SNES SFC-32 flash cartridge.


Another usual problem with me: if I order the Super UFO, the delivery time will be 30-40 days. Once it arrives, I'll test it, play 1-2 hours and the whole stuff will not be interesting anymore. I know myself. So what to do? The available options were:

1. Build a flash cart based on someone else's design or
2. Develop a completely own cartridge

Of course, option 2 has been selected. The development procedure is much more interesting than playing games with a factory made cartridge. Not mentioning the required 2-3 months of hard work. ;)

There are many cart hacking schemes available freely on the Internet. 90% of them replace the mask programmed ROM with a flash ROM. The flash programming requires EPROM programmer. Some of them has it's own programmer hardware (USB etc.). The most perfect ones use SD card for data storage and games are selectable on the TV screen using the SNES gamepad.

I needed an optimal solution for my design: not the most complicated one, but either not a primitive realization. The requirements became clear quickly:

  • SD card with FAT 16 filesystem support, max. 512 files in root directory
  • Self programmable system with microcontroller 
  • Cheap display hardware (3x7 segment LED display instead of a 2x16 LCD) 
  • 5V 4 MB flash chip (the max. game ROM size is 4 MB)
  • LOROM, HIROM support with or without header

The first step was to obtain a few 256 kByte 8 bit parallel flash EPROMs  and wire one of them to a PIC 16F873 microcontroller for initial tests. These chips are available from various old PC motherboards (Pentium 1 category).

256k x 8 parallel flash EPROM

After learning the flash chip datasheet I have managed to write low level routines in C (with MPLAB) to read, write and erase the flash content.

Once this worked, connecting the SD card was the next step. I have made an adapter cable to quickly connect the SD card slot to the breadboard.


Open source SD libraries are available for larger microcontrollers, but not for a 4k PIC 16F873. As usual there are tons of documents available on the Internet how to initialize the SD card, how to read / write data etc. The most useful document was the Sandisk SD user manual.

Once the SD read operations worked, I have copied (with dd) a SNES game ROM dump to the card from sector 0 and invoked the flash writer routine. The system copied the ROM file to the flash memory successfully. The SNES booted up with it (the first tested stuff was Top Gear, it is a 512 kB ROM).

It was time to order a 4 MB (32 Mbit) 8 bit flash EPROM for the final design (M39F032D).

32M x 8 parallel flash EPROM

As the design became more complex, the microcontroller has been replaced with a larger one: PIC 16F887 with 8 kiloword program memory. Buttons and LED display have been added to the breadboard design.

At this point I needed a FAT 16 filesystem. There is no such library available for a small device like a 8 k PIC, so I decided to write my own FAT 16 implementation (read only).  Once it worked properly, the breadboard design achieved 95% of completion.


Breadboard version running Street Fighter II
During the test cca. 90% of games were running without any problem. Games not working were which require FX chip, check SRAM (copy protection) etc.

The next step was to design a 2 layer prototype PCB.

 
 

Current status

The system is working perfectly, without any issue. The original goal has been achieved, I can play almost every SNES game I would like.

You can find the v 1.1 schematic diagram and some additional images below.
 
SFC-32 v 1.1 schematic diagram



Future plans, ideas:
  • Redesign the PCB and fix the routing errors
  • Use CPLD to reduce the number of components and the size of PCB
  • Add SRAM for save game feature
  • Redesign the complete system to use SNES program for selecting games on the TV screen
  • Use DRAM instead of the slow flash (SRAM is still expensive, even in 2013!)

All materials presented on this page are Copyright © 2013. Viktor K. All rights reserved.

12 comments:

  1. Want to make your flash more snes I have not seen the menu software for downloading to your blog if I get to do

    ReplyDelete
  2. Can You please clarify your question?

    ReplyDelete
  3. Great work! I am interested in your project. Perhaps I can help you improve the design / continue your work ?

    ReplyDelete
  4. No further improvements are planned to this PIC microcontroller based flash cart. It works properly and it is bug free.

    The next, complete new hardware / software should be a SNES CPU controlled flash cart, which uses the TV screen for selecting the ROM images.

    ReplyDelete
  5. So...I guess you wouldn't agree to share the Pic firmware... :-"

    ReplyDelete
  6. great work! can you please tell me what i need know to make things like that, what's your career? thank you in advance!

    ReplyDelete
  7. -Learn C programming
    -Learn Assembly
    -Learn the electronic design
    -Learn the PCB design

    And much more. :)

    ReplyDelete
  8. So with that board you powered up the system more?

    ReplyDelete
  9. Hi, You can give a schema? My email: jacielferreira@gmail.com

    ReplyDelete
  10. Dear Jaciel,

    the complete schematic is available on this page. Please find it above.

    ReplyDelete
  11. Hi, I would try to build it. Can you share pic firmware and schema to print a pcb?
    My e-mail: miky6682@gmail.com

    Thank you!

    ReplyDelete