I wrote an update for my Mega Drive modchip. I was a little annoyed by the different colors to show what region was set. The reason of a switchless mod is to stay as close to the original as possible, so the LED should be red!
I changed it so it will only show the setting (LED color) when you cycle through the different regions and when you power on the Mega Drive. If you want to you can now solder two wires and two resistors and make it work with a multi BIOS on your SegaCD / Mega-CD. There are already other solutions available on the internet but I wanted to make my own because it needs to work with an unmodified MegaDrive console. For my version of the multi-bios, I used the original bios and the three region-free BIOSes. This way I can use the Mega-CD as originally intended but when connected to my modified switchless Mega Drive it will match the region of choice.
To save you a google search, the command to create your multi-bios is:
copy /b org_swapped.bin + eur_swapped.bin + usa_swapped.bin + jap_swapped.bin 4xbios.bin
I then programmed a 27c4002 EPROM with the 4xbios.bin and insert it into my Mega-CD. Lucky enough I have one of those early Mega-CD units with an EPROM socket. Do not insert pins 38 and 39, these are used to switch between the different BIOSes. Connect pin 38 to the 6th pin and pin 39 to the 4th pin on the connector, connect a 10k resistor from pin 6 to GND, do the same for pin 4. These two pull-down resistors will make sure pin 38 and 39 are tied to ground when a non-modded Mega Drive is connected to the Mega-CD. In the modded Mega Drive connect the 4th pin to Arduino pin 0 and the 6th pin Arduino pin 1.
Now you only need to reprogram your Arduino (with USBasp) and you will have a matching BIOS with your Mega Drive region setting. Anyway, 🍻 and happy gaming!
#include <OneButton.h> //https://github.com/mathertel/OneButton
#include <Arduino.h>
#include <EEPROM.h>
// CONFIG // CONFIG // CONFIG // CONFIG //
const int address = 39; // EEPROM address we will write
const int HzPin = 9; // Pin connected to JP3 on the MegaDrive
const int LanguagePin = 8; // Pin connected to JP2 on the MegaDrive
const int HaltPin = 10; // Pin connected to pin 17 of 68K CPU (*not used yet)
const int Red_LED = 7;
const int Green_LED = 6;
const int Blue_LED = 5;
const int ButtonPin = 2;
const int ResetPin = 3;
const int CDpin38 = 0;
const int CDpin39 = 1;
unsigned long previousMillis = 0; // will store last time LED was updated
const long interval = 10000; // interval at which to return to red LED
// END CONFIG // END CONFIG // END CONFIG //
OneButton button(ButtonPin, // Pin connected to RESET switch
true, // Button is active LOW
true); // Enable internal pull-up resistor
int stateHZ;
int stateLANG;
int lastState;
void setup() {
noInterrupts();
lastState = EEPROM.read(address); // Read the last state
pinMode(LanguagePin, OUTPUT); // Set the digital pins as output
pinMode(CDpin39, OUTPUT);
pinMode(CDpin38, OUTPUT);
pinMode(HzPin, OUTPUT);
setState(lastState);
interrupts();
pinMode(ResetPin, OUTPUT);
pinMode(Red_LED, OUTPUT);
pinMode(Green_LED, OUTPUT);
pinMode(Blue_LED, OUTPUT);
button.attachDoubleClick(doublePress); // Link the function to be called on event.
button.attachLongPressStart(longPress); // Link the function to be called on event.
button.attachClick(shortPress); // Link the function to be called on event.
button.setPressTicks(3000); // Lenght of longPress in ms
}
void loop() {
button.tick(); // Check the status of the button
delay(10); // A short wait between checking the button
unsigned long currentMillis = millis(); //Let's check how long ago the LED color changed
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
RGB_Color("RED");
}//end if
} // loop
void shortPress() { // Reset the console
digitalWrite(ResetPin, HIGH);
delay(10);
digitalWrite(ResetPin, LOW);
}
void doublePress() { // Get current state and switch to next
State("next");
}
void longPress() { // Save settings to eeprom
State("save");
}
void State(char *var) {
stateHZ = digitalRead(HzPin); // Check Current Hz state
stateLANG = digitalRead(LanguagePin); // Check Current Language state
if (stateHZ == LOW && stateLANG == HIGH) { // PAL
if (var == "next") {
setState(2); //We change to 2 = USA
}
else {
EEPROM.update(address, 1); // Save state to EEPROM
CONFIRM(); // Blink LED to Confirm
RGB_Color("RED"); // Red Color Color
} // End Next or Save
} // End PAL
else if (stateHZ == HIGH && stateLANG == HIGH) { // USA
if (var == "next") {
setState(3); //We change to 3 = JAP
}
else {
EEPROM.update(address, 2); // Save state to EEPROM
CONFIRM(); // Blink LED to Confirm
RGB_Color("GREEN"); // Red Color Color
} // End Next or Save
} // End USA
else if (stateHZ == HIGH && stateLANG == LOW) { // JAP
if (var == "next") {
setState(1); //We change to 1 = PAL
}
else {
EEPROM.update(address, 3); // Save state to EEPROM
CONFIRM(); // Blink LED to Confirm
RGB_Color("BLUE"); // Red Color Color
} // End Next or Save
} // End JAP
}
void setState(int s) {
switch (s) {
case 1: //PAL
//HALT
digitalWrite(HzPin, LOW);
digitalWrite(LanguagePin, HIGH);
RGB_Color("RED"); // Red Color Color
//Serial.println("PAL region set");
digitalWrite(CDpin39, LOW);
digitalWrite(CDpin38, HIGH);
break;
case 2: //USA
digitalWrite(HzPin, HIGH);
digitalWrite(LanguagePin, HIGH);
RGB_Color("GREEN"); // Green Color
//Serial.println("USA region set");
digitalWrite(CDpin39, HIGH);
digitalWrite(CDpin38, LOW);
break;
case 3: //JAP
digitalWrite(HzPin, HIGH);
digitalWrite(LanguagePin, LOW);
RGB_Color("BLUE"); // Blue Color
//Serial.println("JAP region set");
digitalWrite(CDpin39, HIGH);
digitalWrite(CDpin38, HIGH);
break;
default: // Default is PAL
digitalWrite(HzPin, LOW);
digitalWrite(LanguagePin, HIGH);
RGB_Color("RED"); // Red Color Color
//Serial.println("PAL region set");
digitalWrite(CDpin39, LOW);
digitalWrite(CDpin38, HIGH);
break;
}
}
void CONFIRM() {
for (int i = 0; i <= 2; i++) {
RGB_Color("OFF"); // All OFF
delay(500);
RGB_Color("WHITE"); // White Color
delay(500);
}
}
void RGB_Color(char *color){
int red; int green; int blue;
if(color=="RED") { red=130; green=0; blue=0; }
else if(color=="GREEN") { red=0; green=30; blue=0; }
else if(color=="BLUE") { red=0; green=0; blue=30; }
else if(color=="WHITE") { red=150; green=30; blue=30; }
else if(color=="OFF") { red=0; green=0; blue=0; }
analogWrite(Red_LED, red);
analogWrite(Green_LED, green);
analogWrite(Blue_LED, blue);
}


