Merge pull request #42 from ramapcsx2/various

SNES, MD: avoid dumping/writing 0 Byte files to SD card
This commit is contained in:
sanni 2019-09-11 20:54:54 +02:00 committed by GitHub
commit 6d47a68f29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 22 deletions

View File

@ -195,10 +195,18 @@ void mdCartMenu() {
{ {
case 0: case 0:
display_Clear(); display_Clear();
// Change working dir to root
sd.chdir("/"); // common ROM read fail state: no cart inserted - tends to report impossibly large cartSize
readROM_MD(); // largest known game so far is supposedly "Paprium" at 10MB, so cap sanity check at 16MB
//compare_checksum_MD(); if (cartSize != 0 && cartSize <= 16777216) {
// Change working dir to root
sd.chdir("/");
readROM_MD();
//compare_checksum_MD();
}
else {
print_Error(F("Cart has no ROM"), false);
}
break; break;
case 1: case 1:

View File

@ -298,6 +298,7 @@ void n64CartMenu() {
} }
} }
else { else {
display_Clear();
print_Error(F("Savetype Error"), false); print_Error(F("Savetype Error"), false);
} }
println_Msg(F("Press Button...")); println_Msg(F("Press Button..."));

View File

@ -49,7 +49,7 @@ static const char confMenuItem2[] PROGMEM = "4MB LoRom 256K Sram";
static const char confMenuItem3[] PROGMEM = "4MB HiRom 64K Sram"; static const char confMenuItem3[] PROGMEM = "4MB HiRom 64K Sram";
static const char confMenuItem4[] PROGMEM = "6MB ExRom 256K Sram"; static const char confMenuItem4[] PROGMEM = "6MB ExRom 256K Sram";
static const char confMenuItem5[] PROGMEM = "Reset"; static const char confMenuItem5[] PROGMEM = "Reset";
static const char* const menuOptionsConf[] PROGMEM = {confMenuItem1, confMenuItem2, confMenuItem3, confMenuItem4, confMenuItem5}; static const char* const menuOptionsConfManual[] PROGMEM = {confMenuItem1, confMenuItem2, confMenuItem3, confMenuItem4, confMenuItem5};
// SNES start menu // SNES start menu
void snsMenu() { void snsMenu() {
@ -118,19 +118,25 @@ void snesMenu() {
{ {
case 0: case 0:
{ {
display_Clear(); if (numBanks > 0) {
// Change working dir to root display_Clear();
sd.chdir("/"); // Change working dir to root
// get current time sd.chdir("/");
unsigned long startTime = millis(); // get current time
// start reading from cart unsigned long startTime = millis();
readROM_SNES(); // start reading from cart
compare_checksum(); readROM_SNES();
// print elapsed time compare_checksum();
print_Msg(F("Time elapsed: ")); // print elapsed time
print_Msg((millis() - startTime) / 1000); print_Msg(F("Time elapsed: "));
println_Msg(F("s")); print_Msg((millis() - startTime) / 1000);
display_Update(); println_Msg(F("s"));
display_Update();
}
else {
display_Clear();
print_Error(F("Does not have ROM"), false);
}
} }
break; break;
@ -239,11 +245,11 @@ void snesMenu() {
} }
// Menu for manual configuration // Menu for manual configuration
void confMenu() { void confMenuManual() {
// create menu with title and 5 options to choose from // create menu with title and 5 options to choose from
unsigned char subMenu; unsigned char subMenu;
// Copy menuOptions out of progmem // Copy menuOptions out of progmem
convertPgm(menuOptionsConf, 5); convertPgm(menuOptionsConfManual, 5);
subMenu = question_box(F("Choose mapping"), menuOptions, 5, 0); subMenu = question_box(F("Choose mapping"), menuOptions, 5, 0);
// wait for user choice to come back from the question box menu // wait for user choice to come back from the question box menu
@ -658,7 +664,7 @@ void getCartInfo_SNES() {
// Start manual config // Start manual config
if (manualConfig == 1) { if (manualConfig == 1) {
confMenu(); confMenuManual();
} }
} }
@ -834,7 +840,8 @@ boolean checkcart_SNES() {
} }
// Calculate sramSize // Calculate sramSize
if (sramSizeExp != 0) { // Fail states usually have sramSizeExp at 255 (no cart inserted, SA-1 failure, etc)
if (sramSizeExp != 0 && sramSizeExp != 255) {
sramSizeExp = sramSizeExp + 3; sramSizeExp = sramSizeExp + 3;
sramSize = 1; sramSize = 1;
while (sramSizeExp--) while (sramSizeExp--)