Skip to content
Giorgioggì edited this page Mar 2, 2024 · 22 revisions

MegaDrive++ can run on several microcontrollers. It can probably be ported to many others with little effort, thanks to the flexibility of Arduino.

The recommended platform (and the only supported one) is the Arduino Nano, since:

  • It is small
  • It is cheap (Unofficial clones are 2-3 EUR straight from China, shipping included!)
  • It has plenty of pins
  • On clones, pin headers usually come unsoldered, which simplifies installation
  • It has an embedded USB port and serial converter, allowing for easy upgrades (and debugging, in case)

Note that clones can sometimes be found with an ATmega168 instead of the standard ATmega328. Both versions are supported.

You can also use an Arduino Uno if you have it handy, as it is essentially equivalent to the Nano, but it is larger and cumbersome.

If you have already modded your console with the D4s/Seb mod and you don't feel like rewiring too much stuff, you might want to have a look at the legacy branch: you can use that version with an ATtiny44(A) or ATtiny84(A) and just add a few wires, but you will be on your own as it is no longer supported.

Wiring

                                 +-----+
                    +------------| USB |------------+
                    |            +-----+            |
     (Built-in LED) | [ ]D13/SCK        MISO/D12[ ] |
                    | [ ]3.3V           MOSI/D11[X]~| [LED Blue]
                    | [ ]V.ref     ___    SS/D10[X]~| [LED Green]
          Reset Out | [X]A0       / N \       D9[X]~| [LED Red]
           Reset In | [X]A1      /  A  \      D8[X] | [Single Pin Led]
 JP3/4 (Video Mode) | [X]A2      \  N  /      D7[X] | Pad Port Pin 1
   JP1/2 (Language) | [X]A3       \_0_/       D6[X]~| Pad Port Pin 2
          [LCD SDA] | [X]A4/SDA               D5[X]~| Pad Port Pin 3
          [LCD SCL] | [X]A5/SCL               D4[X] | Pad Port Pin 4
                    | [ ]A6              INT1/D3[X]~| Pad Port Pin 6
                    | [ ]A7              INT0/D2[X] | Pad Port Pin 7
                +5V | [X]5V                  GND[X] | GND
                    | [ ]RST                 RST[ ] |
                    | [ ]GND   5V MOSI GND   RX0[X] | Pad Port Pin 9
                    | [ ]Vin   [ ] [ ] [ ]   TX1[ ] |
                    |          [ ] [ ] [ ]          |
                    |          MISO SCK RST         |
                    | NANO-V3                       |
                    +-------------------------------+

(Arduino ASCII-Art courtesy of BusyDuckMan)

Connections of pins in square brackets are optional. All the others are mandatory.

I recommend putting a (Schottky) diode on the 5V line (1N5817/8/9 will be fine, cathode towards Arduino), so that the console does not get power while Arduino is connected to the PC. That way you will be able to do firmware updates without removing the board from the console, and to keep it connected to the PC and read debug messages on the serial console, if you ever need that.

Bootloader

When Arduino Uno switched to the then-new Optiboot bootloader, the Nano was left behind. Only recently official boards have begun shipping with the newer bootloader. Clones are probably still using the older one.

The newer bootloader has a lot of improvements, one of which is particularly interesting for our purposes: it boots user code muuuuch sooner. This means that MegaDrive++ can set the the desired language and region sooner, hopefully sooner than games with region protections check them. I took some measurements which show that the region and language lines are set in ~74 milliseconds since power-up when using Optiboot, vs. ~1.46 seconds when using the old Nano bootloader.

I still don't know if this is quick enough to bypass region checks in all games (Feedback needed!), but I would still recommend to make sure your Nano is using Optiboot. You need an ISP programmer (or a second Arduino) to flash the bootloader. The procedure for doing so is relatively easy, I recommend googling around for instructions or videos. This guide looks reasonable, but I haven't checked it thoroughly. Just make sure you treat your Nano as an Uno, when choosing the board type from the menus.

Options

MegaDrive++ can optionally show some useful information on an LCD display (the common 16x4 type) while it is running. It looks ugly actually if you somehow embed it into the console. It is meant mainly as a debug tool, to see what mode the console is set in, what buttons you press, etc... Probably it's only useful for me, so don't worry too much about it :).

If you really want to enable it, look for the following line in the MegaDrivePlusPlus.ino file and uncomment it:

//#define ENABLE_LCD

There are many other aspects of MegaDrive++ that are customizabile to a certain degree. These are not documented yet, so you will have to skim through thr source code, read the comments and experiment :).

Flashing

MegaDrive++ comes as a normal Arduino sketch in source format, thus you will need to compile it and flash the obtained firmware on your board. While this might sound scary, it is very simple to do with Arduino, it takes more time to read through it than to do it!

  1. Download the Arduino IDE (latest stable version from https://www.arduino.cc/en/Main/Software) and install it.
  2. Download MegaDrive++ and save it in a directory with the same name in your Arduino sketch folder. If you have no such folder, run the Arduino IDE once and it will be created. IMPORTANT: You will need to put both the MegaDrivePlusPlus.ino and readpad.S files into the sketch folder. The former alone is NOT enough! If you don't include the latter, MD++ will compile and flash fine but it will not be able to read your controller input.
  3. Select Open from the File menu and navigate to where you saved MegaDrive++.
  4. Make sure that the type of board in the Tools menu is set to Arduino Nano.
  5. Connect your board through USB.
  6. Select Upload from the Sketch menu.

If no errors show up, your board is ready!