mirror of
https://github.com/sanni/cartreader.git
synced 2024-12-02 17:24:18 +01:00
V24: Changed folder structure on SD card
All modules now write their roms/saves to a separate subfolder.
This commit is contained in:
parent
ed5dc3f573
commit
dddf21fc3e
@ -2,8 +2,8 @@
|
|||||||
Cartridge Reader for Arduino Mega2560
|
Cartridge Reader for Arduino Mega2560
|
||||||
|
|
||||||
Author: sanni
|
Author: sanni
|
||||||
Date: 2017-05-03
|
Date: 2017-05-08
|
||||||
Version: V23A
|
Version: V24
|
||||||
|
|
||||||
SD lib: https://github.com/greiman/SdFat
|
SD lib: https://github.com/greiman/SdFat
|
||||||
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
|
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
|
||||||
@ -34,7 +34,7 @@
|
|||||||
YamaArashi - GBA flashrom bank switch command
|
YamaArashi - GBA flashrom bank switch command
|
||||||
|
|
||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
char ver[5] = "V23A";
|
char ver[5] = "V24";
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
Define Output
|
Define Output
|
||||||
@ -117,13 +117,14 @@ SdFile myFile;
|
|||||||
#define mode_N64_Cart 0
|
#define mode_N64_Cart 0
|
||||||
#define mode_N64_Controller 1
|
#define mode_N64_Controller 1
|
||||||
#define mode_SNES 2
|
#define mode_SNES 2
|
||||||
#define mode_NP 3
|
#define mode_SFM 3
|
||||||
#define mode_NPFlash 4
|
#define mode_SFM_Flash 4
|
||||||
#define mode_NPGame 5
|
#define mode_SFM_Game 5
|
||||||
#define mode_GB 6
|
#define mode_GB 6
|
||||||
#define mode_FLASH8 7
|
#define mode_FLASH8 7
|
||||||
#define mode_FLASH16 8
|
#define mode_FLASH16 8
|
||||||
#define mode_GBA 9
|
#define mode_GBA 9
|
||||||
|
#define mode_GBM 10
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
Variables
|
Variables
|
||||||
@ -178,7 +179,7 @@ boolean filebrowse = 0;
|
|||||||
char fileOptions[30][20];
|
char fileOptions[30][20];
|
||||||
|
|
||||||
// Common
|
// Common
|
||||||
char romName[10];
|
char romName[17];
|
||||||
int sramSize = 0;
|
int sramSize = 0;
|
||||||
int romType = 0;
|
int romType = 0;
|
||||||
byte saveType;
|
byte saveType;
|
||||||
@ -199,7 +200,7 @@ byte mode;
|
|||||||
|
|
||||||
//remember folder number to create a new folder for every save
|
//remember folder number to create a new folder for every save
|
||||||
int foldern;
|
int foldern;
|
||||||
char folder[24];
|
char folder[36];
|
||||||
|
|
||||||
// Array that holds the data
|
// Array that holds the data
|
||||||
byte sdBuffer[512];
|
byte sdBuffer[512];
|
||||||
@ -333,6 +334,11 @@ static const char n64MenuItem2[] PROGMEM = "Controller";
|
|||||||
static const char n64MenuItem3[] PROGMEM = "Flash Repro";
|
static const char n64MenuItem3[] PROGMEM = "Flash Repro";
|
||||||
static const char* const menuOptionsN64[] PROGMEM = {n64MenuItem1, n64MenuItem2, n64MenuItem3};
|
static const char* const menuOptionsN64[] PROGMEM = {n64MenuItem1, n64MenuItem2, n64MenuItem3};
|
||||||
|
|
||||||
|
// Nintendo Power Submenu
|
||||||
|
static const char npMenuItem1[] PROGMEM = "SF Memory";
|
||||||
|
static const char npMenuItem2[] PROGMEM = "GB Memory";
|
||||||
|
static const char* const menuOptionsNP[] PROGMEM = {npMenuItem1, npMenuItem2};
|
||||||
|
|
||||||
// Flash Submenu
|
// Flash Submenu
|
||||||
static const char flashMenuItem1[] PROGMEM = "8bit slot";
|
static const char flashMenuItem1[] PROGMEM = "8bit slot";
|
||||||
static const char flashMenuItem2[] PROGMEM = "16bit slot";
|
static const char flashMenuItem2[] PROGMEM = "16bit slot";
|
||||||
@ -354,7 +360,7 @@ void mainMenu() {
|
|||||||
switch (modeMenu)
|
switch (modeMenu)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
// create menu with title and 2 options to choose from
|
// create menu with title and 3 options to choose from
|
||||||
unsigned char n64Dev;
|
unsigned char n64Dev;
|
||||||
// Copy menuOptions out of progmem
|
// Copy menuOptions out of progmem
|
||||||
convertPgm(menuOptionsN64, 3);
|
convertPgm(menuOptionsN64, 3);
|
||||||
@ -398,10 +404,29 @@ void mainMenu() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
// create menu with title and 2 options to choose from
|
||||||
|
unsigned char npCart;
|
||||||
|
// Copy menuOptions out of progmem
|
||||||
|
convertPgm(menuOptionsNP, 1);
|
||||||
|
npCart = question_box("Select NP Cart", menuOptions, 1, 0);
|
||||||
|
|
||||||
|
// wait for user choice to come back from the question box menu
|
||||||
|
switch (npCart)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
display_Clear();
|
display_Clear();
|
||||||
display_Update();
|
display_Update();
|
||||||
setup_NP();
|
setup_SFM();
|
||||||
mode = mode_NP;
|
mode = mode_SFM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
display_Clear();
|
||||||
|
display_Update();
|
||||||
|
setup_GBM();
|
||||||
|
mode = mode_GBM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
@ -493,7 +518,7 @@ void mainMenu() {
|
|||||||
display_Update();
|
display_Update();
|
||||||
delay(2000);
|
delay(2000);
|
||||||
foldern = 0;
|
foldern = 0;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
asm volatile (" jmp 0");
|
asm volatile (" jmp 0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -522,7 +547,7 @@ void setup() {
|
|||||||
rgb.setColor(0, 0, 0);
|
rgb.setColor(0, 0, 0);
|
||||||
|
|
||||||
// Read current folder number out of eeprom
|
// Read current folder number out of eeprom
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
|
|
||||||
if (enable_OLED) {
|
if (enable_OLED) {
|
||||||
// GLCD
|
// GLCD
|
||||||
@ -1269,8 +1294,8 @@ void loop() {
|
|||||||
else if (mode == mode_FLASH16) {
|
else if (mode == mode_FLASH16) {
|
||||||
flashromMenu16();
|
flashromMenu16();
|
||||||
}
|
}
|
||||||
else if (mode == mode_NP) {
|
else if (mode == mode_SFM) {
|
||||||
npMenu();
|
sfmMenu();
|
||||||
}
|
}
|
||||||
else if (mode == mode_GB) {
|
else if (mode == mode_GB) {
|
||||||
gbMenu();
|
gbMenu();
|
||||||
@ -1278,11 +1303,14 @@ void loop() {
|
|||||||
else if (mode == mode_GBA) {
|
else if (mode == mode_GBA) {
|
||||||
gbaMenu();
|
gbaMenu();
|
||||||
}
|
}
|
||||||
else if (mode == mode_NPFlash) {
|
else if (mode == mode_SFM_Flash) {
|
||||||
NPFlashMenu();
|
sfmFlashMenu();
|
||||||
}
|
}
|
||||||
else if (mode == mode_NPGame) {
|
else if (mode == mode_SFM_Game) {
|
||||||
NPGameOptions();
|
sfmGameOptions();
|
||||||
|
}
|
||||||
|
else if (mode == mode_GBM) {
|
||||||
|
gbmMenu();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
display_Clear();
|
display_Clear();
|
||||||
|
@ -824,14 +824,14 @@ void readFlash() {
|
|||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
|
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sd.mkdir("FLASH", true);
|
sd.mkdir("FLASH", true);
|
||||||
sd.chdir("FLASH");
|
sd.chdir("FLASH");
|
||||||
sprintf(fileName, "FL%d", foldern);
|
sprintf(fileName, "FL%d", foldern);
|
||||||
strcat(fileName, ".bin");
|
strcat(fileName, ".bin");
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
display_Clear();
|
display_Clear();
|
||||||
print_Msg(F("Saving as "));
|
print_Msg(F("Saving as "));
|
||||||
@ -1060,14 +1060,14 @@ void readFlash16() {
|
|||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
|
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sd.mkdir("FLASH", true);
|
sd.mkdir("FLASH", true);
|
||||||
sd.chdir("FLASH");
|
sd.chdir("FLASH");
|
||||||
sprintf(fileName, "FL%d", foldern);
|
sprintf(fileName, "FL%d", foldern);
|
||||||
strcat(fileName, ".bin");
|
strcat(fileName, ".bin");
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
display_Clear();
|
display_Clear();
|
||||||
print_Msg(F("Saving as "));
|
print_Msg(F("Saving as "));
|
||||||
|
@ -128,7 +128,7 @@ void setup_GB() {
|
|||||||
display_Clear();
|
display_Clear();
|
||||||
if (strcmp(checksumStr, "00") != 0) {
|
if (strcmp(checksumStr, "00") != 0) {
|
||||||
println_Msg(F("GB Cart Info"));
|
println_Msg(F("GB Cart Info"));
|
||||||
print_Msg(F("Rom Name: "));
|
print_Msg(F("Name: "));
|
||||||
println_Msg(romName);
|
println_Msg(romName);
|
||||||
print_Msg(F("Rom Type: "));
|
print_Msg(F("Rom Type: "));
|
||||||
switch (romType) {
|
switch (romType) {
|
||||||
@ -329,13 +329,13 @@ void getCartInfo_GB() {
|
|||||||
// Get Checksum as string
|
// Get Checksum as string
|
||||||
sprintf(checksumStr, "%02X%02X", readByte_GB(0x014E), readByte_GB(0x014F));
|
sprintf(checksumStr, "%02X%02X", readByte_GB(0x014E), readByte_GB(0x014F));
|
||||||
|
|
||||||
// Dump name into 8.3 compatible format
|
// Get name
|
||||||
byte myByte = 0;
|
byte myByte = 0;
|
||||||
byte myLength = 0;
|
byte myLength = 0;
|
||||||
|
|
||||||
for (int addr = 0x0134; addr <= 0x13C; addr++) {
|
for (int addr = 0x0134; addr <= 0x13C; addr++) {
|
||||||
myByte = readByte_GB(addr);
|
myByte = readByte_GB(addr);
|
||||||
if (((char(myByte) >= 48 && char(myByte) <= 57) || (char(myByte) >= 65 && char(myByte) <= 122)) && myLength < 8) {
|
if (((char(myByte) >= 48 && char(myByte) <= 57) || (char(myByte) >= 65 && char(myByte) <= 122)) && myLength < 16) {
|
||||||
romName[myLength] = char(myByte);
|
romName[myLength] = char(myByte);
|
||||||
myLength++;
|
myLength++;
|
||||||
}
|
}
|
||||||
@ -345,25 +345,24 @@ void getCartInfo_GB() {
|
|||||||
// Dump ROM
|
// Dump ROM
|
||||||
void readROM_GB() {
|
void readROM_GB() {
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
char fileName[26];
|
|
||||||
strcpy(fileName, romName);
|
strcpy(fileName, romName);
|
||||||
strcat(fileName, ".GB");
|
strcat(fileName, ".GB");
|
||||||
|
|
||||||
// create a new folder for the rom file
|
// create a new folder for the rom file
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "ROM/%s/%d", romName, foldern);
|
sprintf(folder, "GB/ROM/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
//clear the screen
|
|
||||||
display_Clear();
|
display_Clear();
|
||||||
println_Msg(F("Creating folder: "));
|
print_Msg(F("Saving to "));
|
||||||
println_Msg(folder);
|
print_Msg(folder);
|
||||||
|
println_Msg(F("/..."));
|
||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
//open file on sd card
|
//open file on sd card
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
@ -406,10 +405,6 @@ void readROM_GB() {
|
|||||||
|
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
|
|
||||||
// Signal end of process
|
|
||||||
print_Msg(F("Saved as "));
|
|
||||||
println_Msg(fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int calc_checksum_GB (char* fileName, char* folder) {
|
unsigned int calc_checksum_GB (char* fileName, char* folder) {
|
||||||
@ -451,13 +446,12 @@ boolean compare_checksum_GB() {
|
|||||||
println_Msg(F("Calculating Checksum"));
|
println_Msg(F("Calculating Checksum"));
|
||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
char fileName[26];
|
|
||||||
strcpy(fileName, romName);
|
strcpy(fileName, romName);
|
||||||
strcat(fileName, ".GB");
|
strcat(fileName, ".GB");
|
||||||
|
|
||||||
// last used rom folder
|
// last used rom folder
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "ROM/%s/%d", romName, foldern - 1);
|
sprintf(folder, "GB/ROM/%s/%d", romName, foldern - 1);
|
||||||
|
|
||||||
char calcsumStr[5];
|
char calcsumStr[5];
|
||||||
sprintf(calcsumStr, "%04X", calc_checksum_GB(fileName, folder));
|
sprintf(calcsumStr, "%04X", calc_checksum_GB(fileName, folder));
|
||||||
@ -483,19 +477,18 @@ void readSRAM_GB() {
|
|||||||
if (sramEndAddress > 0) {
|
if (sramEndAddress > 0) {
|
||||||
|
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
char fileName[26];
|
|
||||||
strcpy(fileName, romName);
|
strcpy(fileName, romName);
|
||||||
strcat(fileName, ".sav");
|
strcat(fileName, ".sav");
|
||||||
|
|
||||||
// create a new folder for the save file
|
// create a new folder for the save file
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "SAVE/%s/%d", romName, foldern);
|
sprintf(folder, "GB/SAVE/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
//open file on sd card
|
//open file on sd card
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
@ -540,12 +533,9 @@ void readSRAM_GB() {
|
|||||||
myFile.close();
|
myFile.close();
|
||||||
|
|
||||||
// Signal end of process
|
// Signal end of process
|
||||||
print_Msg(F("Saved to SAVE/"));
|
print_Msg(F("Saved to "));
|
||||||
print_Msg(romName);
|
print_Msg(folder);
|
||||||
print_Msg(F("/"));
|
println_Msg(F("/"));
|
||||||
print_Msg(foldern - 1);
|
|
||||||
print_Msg(F("/"));
|
|
||||||
println_Msg(fileName);
|
|
||||||
display_Update();
|
display_Update();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -453,8 +453,7 @@ void setup_GBA() {
|
|||||||
getCartInfo_GBA();
|
getCartInfo_GBA();
|
||||||
display_Clear();
|
display_Clear();
|
||||||
|
|
||||||
println_Msg(F("GBA Cart Info"));
|
print_Msg(F("Name: "));
|
||||||
print_Msg(F("Rom Name: "));
|
|
||||||
println_Msg(romName);
|
println_Msg(romName);
|
||||||
print_Msg(F("Cart ID: "));
|
print_Msg(F("Cart ID: "));
|
||||||
println_Msg(cartID);
|
println_Msg(cartID);
|
||||||
@ -733,12 +732,12 @@ void getCartInfo_GBA() {
|
|||||||
print_Error(F("GBA.txt missing"), true);
|
print_Error(F("GBA.txt missing"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump name into 8.3 compatible format
|
// Get name
|
||||||
byte myByte = 0;
|
byte myByte = 0;
|
||||||
byte myLength = 0;
|
byte myLength = 0;
|
||||||
for (int addr = 0xA0; addr <= 0xAB; addr++) {
|
for (int addr = 0xA0; addr <= 0xAB; addr++) {
|
||||||
myByte = sdBuffer[addr];
|
myByte = sdBuffer[addr];
|
||||||
if (((char(myByte) >= 48 && char(myByte) <= 57) || (char(myByte) >= 65 && char(myByte) <= 122)) && myLength < 8) {
|
if (((char(myByte) >= 48 && char(myByte) <= 57) || (char(myByte) >= 65 && char(myByte) <= 122)) && myLength < 16) {
|
||||||
romName[myLength] = char(myByte);
|
romName[myLength] = char(myByte);
|
||||||
myLength++;
|
myLength++;
|
||||||
}
|
}
|
||||||
@ -775,25 +774,25 @@ void getCartInfo_GBA() {
|
|||||||
// Dump ROM
|
// Dump ROM
|
||||||
void readROM_GBA() {
|
void readROM_GBA() {
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
char fileName[26];
|
|
||||||
strcpy(fileName, romName);
|
strcpy(fileName, romName);
|
||||||
strcat(fileName, ".gba");
|
strcat(fileName, ".gba");
|
||||||
|
|
||||||
// create a new folder for the rom file
|
// create a new folder for the rom file
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "ROM/%s/%d", romName, foldern);
|
sprintf(folder, "GBA/ROM/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
//clear the screen
|
//clear the screen
|
||||||
display_Clear();
|
display_Clear();
|
||||||
println_Msg(F("Reading to: "));
|
print_Msg(F("Saving to "));
|
||||||
println_Msg(folder);
|
print_Msg(folder);
|
||||||
|
println_Msg(F("/..."));
|
||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
//open file on sd card
|
//open file on sd card
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
@ -821,10 +820,6 @@ void readROM_GBA() {
|
|||||||
|
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
|
|
||||||
// Signal end of process
|
|
||||||
print_Msg(F("Saved as "));
|
|
||||||
println_Msg(fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the checksum of the dumped rom
|
// Calculate the checksum of the dumped rom
|
||||||
@ -832,13 +827,12 @@ boolean compare_checksum_GBA () {
|
|||||||
println_Msg(F("Calculating Checksum"));
|
println_Msg(F("Calculating Checksum"));
|
||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
char fileName[26];
|
|
||||||
strcpy(fileName, romName);
|
strcpy(fileName, romName);
|
||||||
strcat(fileName, ".gba");
|
strcat(fileName, ".gba");
|
||||||
|
|
||||||
// last used rom folder
|
// last used rom folder
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "ROM/%s/%d", romName, foldern - 1);
|
sprintf(folder, "GBA/ROM/%s/%d", romName, foldern - 1);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
// If file exists
|
// If file exists
|
||||||
@ -901,24 +895,19 @@ void readFRAM_GBA (unsigned long framSize) {
|
|||||||
strcat(fileName, ".srm");
|
strcat(fileName, ".srm");
|
||||||
|
|
||||||
// create a new folder for the save file
|
// create a new folder for the save file
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "SAVE/%s/%d", romName, foldern);
|
sprintf(folder, "GBA/SAVE/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
// Signal end of process
|
// Save location
|
||||||
print_Msg(F("Reading to SAVE/"));
|
print_Msg(F("Saving to "));
|
||||||
print_Msg(romName);
|
print_Msg(folder);
|
||||||
print_Msg(F("/"));
|
println_Msg(F("/..."));
|
||||||
print_Msg(foldern);
|
|
||||||
print_Msg(F("/"));
|
|
||||||
print_Msg(fileName);
|
|
||||||
print_Msg(F("..."));
|
|
||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
//open file on sd card
|
//open file on sd card
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
@ -1315,25 +1304,21 @@ void readFLASH_GBA (boolean browseFile, unsigned long flashSize, uint32_t pos) {
|
|||||||
strcat(fileName, ".fla");
|
strcat(fileName, ".fla");
|
||||||
|
|
||||||
// create a new folder for the save file
|
// create a new folder for the save file
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
|
|
||||||
sprintf(folder, "SAVE/%s/%d", romName, foldern);
|
sprintf(folder, "GBA/SAVE/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
// Signal end of process
|
// Save location
|
||||||
print_Msg(F("Reading to SAVE/"));
|
print_Msg(F("Saving to "));
|
||||||
print_Msg(romName);
|
print_Msg(folder);
|
||||||
print_Msg(F("/"));
|
println_Msg(F("/..."));
|
||||||
print_Msg(foldern);
|
|
||||||
print_Msg(F("/"));
|
|
||||||
print_Msg(fileName);
|
|
||||||
print_Msg(F("..."));
|
|
||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
}
|
}
|
||||||
|
|
||||||
//open file on sd card
|
//open file on sd card
|
||||||
@ -1548,25 +1533,21 @@ void readEeprom_GBA(word eepSize) {
|
|||||||
strcat(fileName, ".eep");
|
strcat(fileName, ".eep");
|
||||||
|
|
||||||
// create a new folder for the save file
|
// create a new folder for the save file
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
|
|
||||||
sprintf(folder, "SAVE/%s/%d", romName, foldern);
|
sprintf(folder, "GBA/SAVE/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
// Signal end of process
|
// Save location
|
||||||
print_Msg(F("Reading to SAVE/"));
|
print_Msg(F("Saving to "));
|
||||||
print_Msg(romName);
|
print_Msg(folder);
|
||||||
print_Msg(F("/"));
|
println_Msg(F("/..."));
|
||||||
print_Msg(foldern);
|
|
||||||
print_Msg(F("/"));
|
|
||||||
print_Msg(fileName);
|
|
||||||
print_Msg(F("..."));
|
|
||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
//open file on sd card
|
//open file on sd card
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
|
@ -132,10 +132,6 @@ void n64CartMenu() {
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
display_Clear();
|
|
||||||
|
|
||||||
println_Msg(F("Reading Rom..."));
|
|
||||||
display_Update();
|
|
||||||
readRom_N64();
|
readRom_N64();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -805,17 +801,19 @@ void readBlock(word myAddress) {
|
|||||||
void readMPK() {
|
void readMPK() {
|
||||||
// Change to root
|
// Change to root
|
||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
|
// Make MPK directory
|
||||||
|
sd.mkdir("N64/MPK", true);
|
||||||
// Change to MPK directory
|
// Change to MPK directory
|
||||||
sd.chdir("MPK");
|
sd.chdir("N64/MPK");
|
||||||
|
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(fileName, "%d", foldern);
|
sprintf(fileName, "%d", foldern);
|
||||||
strcat(fileName, ".mpk");
|
strcat(fileName, ".mpk");
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
//open file on sd card
|
//open file on sd card
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
@ -836,7 +834,7 @@ void readMPK() {
|
|||||||
}
|
}
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
print_Msg(F("Saved as /MPK/"));
|
print_Msg(F("Saved as N64/MPK/"));
|
||||||
println_Msg(fileName);
|
println_Msg(fileName);
|
||||||
display_Update();
|
display_Update();
|
||||||
}
|
}
|
||||||
@ -1202,10 +1200,10 @@ void idCart() {
|
|||||||
// Get rom version
|
// Get rom version
|
||||||
romVersion = sdBuffer[0x3F];
|
romVersion = sdBuffer[0x3F];
|
||||||
|
|
||||||
// Get name in 8.3 compatible format
|
// Get name
|
||||||
byte myLength = 0;
|
byte myLength = 0;
|
||||||
for (unsigned int i = 0; i < 20; i++) {
|
for (unsigned int i = 0; i < 20; i++) {
|
||||||
if (((char(sdBuffer[0x20 + i]) >= 48 && char(sdBuffer[0x20 + i]) <= 57) || (char(sdBuffer[0x20 + i]) >= 65 && char(sdBuffer[0x20 + i]) <= 122)) && myLength < 8) {
|
if (((char(sdBuffer[0x20 + i]) >= 48 && char(sdBuffer[0x20 + i]) <= 57) || (char(sdBuffer[0x20 + i]) >= 65 && char(sdBuffer[0x20 + i]) <= 122)) && myLength < 16) {
|
||||||
romName[myLength] = char(sdBuffer[0x20 + i]);
|
romName[myLength] = char(sdBuffer[0x20 + i]);
|
||||||
myLength++;
|
myLength++;
|
||||||
}
|
}
|
||||||
@ -1341,14 +1339,14 @@ void readEeprom() {
|
|||||||
strcat(fileName, ".eep");
|
strcat(fileName, ".eep");
|
||||||
|
|
||||||
// create a new folder for the save file
|
// create a new folder for the save file
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "SAVE/%s/%d", romName, foldern);
|
sprintf(folder, "N64/SAVE/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
// Open file on sd card
|
// Open file on sd card
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
@ -1386,12 +1384,11 @@ void readEeprom() {
|
|||||||
}
|
}
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
print_Msg(F("Saved to SAVE/"));
|
//clear the screen
|
||||||
print_Msg(romName);
|
display_Clear();
|
||||||
print_Msg(F("/"));
|
print_Msg(F("Saved to "));
|
||||||
print_Msg(foldern - 1);
|
print_Msg(folder);
|
||||||
print_Msg(F("/"));
|
println_Msg(F("/"));
|
||||||
println_Msg(fileName);
|
|
||||||
display_Update();
|
display_Update();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1531,14 +1528,14 @@ void readSram(unsigned long sramSize, byte flashramType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create a new folder for the save file
|
// create a new folder for the save file
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "SAVE/%s/%d", romName, foldern);
|
sprintf(folder, "N64/SAVE/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
// Open file on sd card
|
// Open file on sd card
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
@ -1563,12 +1560,9 @@ void readSram(unsigned long sramSize, byte flashramType) {
|
|||||||
}
|
}
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
print_Msg(F("Saved to SAVE/"));
|
print_Msg(F("Saved to "));
|
||||||
print_Msg(romName);
|
print_Msg(folder);
|
||||||
print_Msg(F("/"));
|
println_Msg(F("/"));
|
||||||
print_Msg(foldern - 1);
|
|
||||||
print_Msg(F("/"));
|
|
||||||
println_Msg(fileName);
|
|
||||||
display_Update();
|
display_Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1932,14 +1926,20 @@ void readRom_N64() {
|
|||||||
strcat(fileName, ".Z64");
|
strcat(fileName, ".Z64");
|
||||||
|
|
||||||
// create a new folder
|
// create a new folder
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "ROM/%s/%d", romName, foldern);
|
sprintf(folder, "N64/ROM/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
|
display_Clear();
|
||||||
|
print_Msg(F("Saving to "));
|
||||||
|
print_Msg(folder);
|
||||||
|
println_Msg(F("/..."));
|
||||||
|
display_Update();
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
readn64rom:
|
readn64rom:
|
||||||
// Open file on sd card
|
// Open file on sd card
|
||||||
@ -1969,13 +1969,6 @@ readn64rom:
|
|||||||
}
|
}
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
print_Msg(F("Saved to ROM/"));
|
|
||||||
print_Msg(romName);
|
|
||||||
print_Msg(F("/"));
|
|
||||||
print_Msg(foldern - 1);
|
|
||||||
print_Msg(F("/"));
|
|
||||||
println_Msg(fileName);
|
|
||||||
display_Update();
|
|
||||||
|
|
||||||
calcn64crc:
|
calcn64crc:
|
||||||
// Calculate Checksum and convert to string
|
// Calculate Checksum and convert to string
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -375,7 +375,7 @@ void getCartInfo_SNES() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
display_Clear();
|
display_Clear();
|
||||||
print_Msg(F("Rom Name: "));
|
print_Msg(F("Name: "));
|
||||||
println_Msg(romName);
|
println_Msg(romName);
|
||||||
|
|
||||||
print_Msg(F("Type: "));
|
print_Msg(F("Type: "));
|
||||||
@ -560,12 +560,12 @@ boolean checkcart_SNES() {
|
|||||||
//Check SD card for alt config
|
//Check SD card for alt config
|
||||||
checkAltConf();
|
checkAltConf();
|
||||||
|
|
||||||
// Dump name into 8.3 compatible format
|
// Get name
|
||||||
byte myByte = 0;
|
byte myByte = 0;
|
||||||
byte myLength = 0;
|
byte myLength = 0;
|
||||||
for (unsigned int i = 65472; i < 65492; i++) {
|
for (unsigned int i = 65472; i < 65492; i++) {
|
||||||
myByte = readBank_SNES(0, i);
|
myByte = readBank_SNES(0, i);
|
||||||
if (((char(myByte) >= 48 && char(myByte) <= 57) || (char(myByte) >= 65 && char(myByte) <= 122)) && myLength < 8) {
|
if (((char(myByte) >= 48 && char(myByte) <= 57) || (char(myByte) >= 65 && char(myByte) <= 122)) && myLength < 16) {
|
||||||
romName[myLength] = char(myByte);
|
romName[myLength] = char(myByte);
|
||||||
myLength++;
|
myLength++;
|
||||||
}
|
}
|
||||||
@ -777,8 +777,8 @@ boolean compare_checksum() {
|
|||||||
strcat(fileName, ".sfc");
|
strcat(fileName, ".sfc");
|
||||||
|
|
||||||
// last used rom folder
|
// last used rom folder
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "ROM/%s/%d", romName, foldern - 1);
|
sprintf(folder, "SNES/ROM/%s/%d", romName, foldern - 1);
|
||||||
|
|
||||||
char calcsumStr[5];
|
char calcsumStr[5];
|
||||||
sprintf(calcsumStr, "%04X", calc_checksum(fileName, folder));
|
sprintf(calcsumStr, "%04X", calc_checksum(fileName, folder));
|
||||||
@ -810,20 +810,21 @@ void readROM_SNES() {
|
|||||||
strcat(fileName, ".sfc");
|
strcat(fileName, ".sfc");
|
||||||
|
|
||||||
// create a new folder for the save file
|
// create a new folder for the save file
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "ROM/%s/%d", romName, foldern);
|
sprintf(folder, "SNES/ROM/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
//clear the screen
|
//clear the screen
|
||||||
display_Clear();
|
display_Clear();
|
||||||
println_Msg(F("Creating folder: "));
|
print_Msg(F("Saving to "));
|
||||||
println_Msg(folder);
|
print_Msg(folder);
|
||||||
|
println_Msg(F("/..."));
|
||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
//open file on sd card
|
//open file on sd card
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
@ -832,9 +833,6 @@ void readROM_SNES() {
|
|||||||
|
|
||||||
// Check if LoROM or HiROM...
|
// Check if LoROM or HiROM...
|
||||||
if (romType == LO) {
|
if (romType == LO) {
|
||||||
println_Msg(F("Dumping LoRom..."));
|
|
||||||
display_Update();
|
|
||||||
|
|
||||||
// Read up to 96 banks starting at bank 0×00.
|
// Read up to 96 banks starting at bank 0×00.
|
||||||
for (int currBank = 0; currBank < numBanks; currBank++) {
|
for (int currBank = 0; currBank < numBanks; currBank++) {
|
||||||
// Dump the bytes to SD 512B at a time
|
// Dump the bytes to SD 512B at a time
|
||||||
@ -848,9 +846,6 @@ void readROM_SNES() {
|
|||||||
}
|
}
|
||||||
// Dump High-type ROM
|
// Dump High-type ROM
|
||||||
else if (((romType == HI) || (romType == SA) || (romType == EX)) && (romChips != 69)) {
|
else if (((romType == HI) || (romType == SA) || (romType == EX)) && (romChips != 69)) {
|
||||||
println_Msg(F("Dumping HiRom..."));
|
|
||||||
display_Update();
|
|
||||||
|
|
||||||
for (int currBank = 192; currBank < (numBanks + 192); currBank++) {
|
for (int currBank = 192; currBank < (numBanks + 192); currBank++) {
|
||||||
for (long currByte = 0; currByte < 65536; currByte += 512) {
|
for (long currByte = 0; currByte < 65536; currByte += 512) {
|
||||||
for (int c = 0; c < 512; c++) {
|
for (int c = 0; c < 512; c++) {
|
||||||
@ -862,9 +857,6 @@ void readROM_SNES() {
|
|||||||
}
|
}
|
||||||
// Dump SDD1 High-type ROM
|
// Dump SDD1 High-type ROM
|
||||||
else if ((romType == HI) && (romChips == 69)) {
|
else if ((romType == HI) && (romChips == 69)) {
|
||||||
println_Msg(F("Dumping SDD1 HiRom..."));
|
|
||||||
display_Update();
|
|
||||||
|
|
||||||
controlIn_SNES();
|
controlIn_SNES();
|
||||||
byte initialSOMap = readBank_SNES(0, 18439);
|
byte initialSOMap = readBank_SNES(0, 18439);
|
||||||
|
|
||||||
@ -898,10 +890,6 @@ void readROM_SNES() {
|
|||||||
}
|
}
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
|
|
||||||
// Signal end of process
|
|
||||||
print_Msg(F("Saved as "));
|
|
||||||
println_Msg(fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
@ -1044,24 +1032,14 @@ void readSRAM () {
|
|||||||
strcat(fileName, ".srm");
|
strcat(fileName, ".srm");
|
||||||
|
|
||||||
// create a new folder for the save file
|
// create a new folder for the save file
|
||||||
EEPROM_readAnything(0, foldern);
|
EEPROM_readAnything(10, foldern);
|
||||||
sprintf(folder, "SAVE/%s/%d", romName, foldern);
|
sprintf(folder, "SNES/SAVE/%s/%d", romName, foldern);
|
||||||
sd.mkdir(folder, true);
|
sd.mkdir(folder, true);
|
||||||
sd.chdir(folder);
|
sd.chdir(folder);
|
||||||
|
|
||||||
// Signal end of process
|
|
||||||
print_Msg(F("Reading to SAVE/"));
|
|
||||||
print_Msg(romName);
|
|
||||||
print_Msg(F("/"));
|
|
||||||
print_Msg(foldern);
|
|
||||||
print_Msg(F("/"));
|
|
||||||
print_Msg(fileName);
|
|
||||||
print_Msg(F("..."));
|
|
||||||
display_Update();
|
|
||||||
|
|
||||||
// write new folder number back to eeprom
|
// write new folder number back to eeprom
|
||||||
foldern = foldern + 1;
|
foldern = foldern + 1;
|
||||||
EEPROM_writeAnything(0, foldern);
|
EEPROM_writeAnything(10, foldern);
|
||||||
|
|
||||||
//open file on sd card
|
//open file on sd card
|
||||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
@ -1106,7 +1084,10 @@ void readSRAM () {
|
|||||||
myFile.close();
|
myFile.close();
|
||||||
|
|
||||||
// Signal end of process
|
// Signal end of process
|
||||||
println_Msg(F("Done"));
|
display_Clear();
|
||||||
|
print_Msg(F("Saved to "));
|
||||||
|
print_Msg(folder);
|
||||||
|
println_Msg(F("/..."));
|
||||||
display_Update();
|
display_Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user