V2.6 Auto backup current Gameshark ROM

This commit is contained in:
sanni 2019-01-18 14:37:22 +01:00
parent b3453a1c58
commit a6e2613379
2 changed files with 54 additions and 6 deletions

View File

@ -2,8 +2,8 @@
Cartridge Reader for Arduino Mega2560
Author: sanni
Date: 16-01-2018
Version: 2.5
Date: 18-01-2019
Version: 2.6
SD lib: https://github.com/greiman/SdFat
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
@ -37,7 +37,7 @@
vogelfreiheit - N64 flashram fix
**********************************************************************************/
char ver[5] = "2.5";
char ver[5] = "2.6";
/******************************************
Define Starting Point

View File

@ -46,8 +46,8 @@ boolean MN63F81MPN = false;
Menu
*****************************************/
// N64 start menu
static const char n64MenuItem1[] PROGMEM = "Cart Slot";
static const char n64MenuItem2[] PROGMEM = "Controller";
static const char n64MenuItem1[] PROGMEM = "Game Cartridge";
static const char n64MenuItem2[] PROGMEM = "Controller Pak";
static const char n64MenuItem3[] PROGMEM = "Flash Repro";
static const char n64MenuItem4[] PROGMEM = "Flash Gameshark";
static const char* const menuOptionsN64[] PROGMEM = {n64MenuItem1, n64MenuItem2, n64MenuItem3, n64MenuItem4};
@ -3042,7 +3042,7 @@ void flashGameshark_N64() {
// Check for SST 29LE010
if (strcmp(flashid, "0808") == 0) {
backupGameshark_N64();
println_Msg("");
println_Msg(F("This will erase your"));
println_Msg(F("Gameshark cartridge"));
@ -3153,6 +3153,54 @@ void resetGameshark_N64() {
delay(100);
}
// Read rom and save to the SD card
void backupGameshark_N64() {
// create a new folder
EEPROM_readAnything(10, foldern);
sprintf(fileName, "GS%d", foldern);
strcat(fileName, ".z64");
sd.mkdir("N64/ROM/Gameshark", true);
sd.chdir("N64/ROM/Gameshark");
display_Clear();
print_Msg(F("Saving "));
print_Msg(fileName);
println_Msg(F("..."));
display_Update();
// write new folder number back to eeprom
foldern = foldern + 1;
EEPROM_writeAnything(10, foldern);
// Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(F("SD Error"), true);
}
for (unsigned long currByte = romBase + 0xC00000; currByte < (romBase + 0xC00000 + 262144); currByte += 512) {
// Blink led
if (currByte % 16384 == 0)
PORTB ^= (1 << 4);
// Set the address for the next 512 bytes
setAddress_N64(currByte);
for (int c = 0; c < 512; c += 2) {
// split word
word myWord = readWord_N64();
byte loByte = myWord & 0xFF;
byte hiByte = myWord >> 8;
// write to buffer
sdBuffer[c] = hiByte;
sdBuffer[c + 1] = loByte;
}
myFile.write(sdBuffer, 512);
}
// Close the file:
myFile.close();
}
// Send chip erase to the two SST29LE010 inside the Gameshark
void eraseGameshark_N64() {
println_Msg(F("Erasing..."));