V1.2: CX4 support by skaman

Thanks alot :)
This commit is contained in:
sanni 2018-06-21 11:38:42 +02:00 committed by GitHub
parent 38d872a7b6
commit 904e23cecd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 5 deletions

View File

@ -2,8 +2,8 @@
Cartridge Reader for Arduino Mega2560
Author: sanni
Date: 11-06-2018
Version: 1.1
Date: 21-06-2018
Version: 1.2
SD lib: https://github.com/greiman/SdFat
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
@ -35,7 +35,7 @@
infinest - help with GB Memory cart
**********************************************************************************/
char ver[5] = "1.1";
char ver[5] = "1.2";
/******************************************
Define Starting Point

View File

@ -17,10 +17,12 @@
// Define SNES Cart Reader Variables
int romSpeed = 0; // 0 = SlowROM, 3 = FastROM
int romChips = 0; // 0 = ROM only, 1 = ROM & RAM, 2 = ROM & Save RAM, 3 = ROM & DSP1, 4 = ROM & RAM & DSP1, 5 = ROM & Save RAM & DSP1, 19 = ROM & SFX
// 227 = ROM & RAM & GameBoy data, 246 = ROM & DSP2
// 227 = ROM & RAM & GameBoy data, 243 = CX4, 246 = ROM & DSP2
byte romSizeExp = 0; // ROM-Size Exponent
int cartCountry = 255;
boolean NP = false;
byte cx4Type = 0;
byte cx4Map = 0;
/******************************************
Menu
@ -484,6 +486,8 @@ void getCartInfo_SNES() {
}
else if (romChips == 227)
println_Msg(F("RAM GBoy"));
else if (romChips == 243)
println_Msg(F("CX4"));
else if (romChips == 246)
println_Msg(F("DSP2"));
else if (romChips == 245)
@ -607,6 +611,17 @@ boolean checkcart_SNES() {
numBanks = 96;
romType = HI;
}
else if (romChips == 243) {
cx4Type = readBank_SNES(0, 65481) & 0xF;
if (cx4Type == 3) { // X3
romSize = 16;
numBanks = 64;
}
else { // X2
romSize = 12;
numBanks = 48;
}
}
else if ((romChips == 245) && (romType == HI)) {
romSize = 24;
numBanks = 48;
@ -941,6 +956,23 @@ void readROM_SNES() {
//Dump Low-type ROM
else if (romType == LO) {
if (romChips == 243) { //0xF3
cx4Map = readBank_SNES(0, 32594); //0x7F52
if ((cx4Type == 2) && (cx4Map != 0)) { //X2
dataOut();
controlOut_SNES();
writeBank_SNES(0, 32594, 0); // Set 0x7F52 to 0
dataIn();
controlIn_SNES();
}
else if ((cx4Type == 3) && (cx4Map == 0)) { //X3
dataOut();
controlOut_SNES();
writeBank_SNES(0, 32594, 1); // Set 0x7F52 to 1
dataIn();
controlIn_SNES();
}
}
if (romSize > 24) {
// ROM > 96 banks (up to 128 banks)
readLoRomBanks( 0x80, numBanks + 0x80, &myFile );
@ -948,6 +980,14 @@ void readROM_SNES() {
// Read up to 96 banks starting at bank 0×00.
readLoRomBanks( 0, numBanks, &myFile );
}
if (romChips == 243) { //0xF3
// Restore CX4 Mapping Register
dataOut();
controlOut_SNES();
writeBank_SNES(0, 32594, cx4Map); // 0x7F52
dataIn();
controlIn_SNES();
}
}
// Dump SDD1 High-type ROM