Add option to force ROM size for MD carts

This commit is contained in:
sanni 2024-06-13 19:40:57 +02:00 committed by GitHub
parent 27a213a3c1
commit 0203e4bf93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,6 +31,8 @@ byte eepType;
// chksum is located in ROM at 0x18E (0xC7) // chksum is located in ROM at 0x18E (0xC7)
// eepType and eepSize are combined to conserve memory // eepType and eepSize are combined to conserve memory
//********************************************************* //*********************************************************
const byte MDSize[] PROGMEM = { 1, 2, 4, 8, 12, 16, 20, 24, 32, 40 };
static const word PROGMEM eepid[] = { static const word PROGMEM eepid[] = {
// ACCLAIM TYPE 1 // ACCLAIM TYPE 1
0x5B9F, 0x101, // NBA Jam (J) 0x5B9F, 0x101, // NBA Jam (J)
@ -93,9 +95,9 @@ int segaSram16bit = 0;
#else /* !ENABLED_CONFIG */ #else /* !ENABLED_CONFIG */
# ifndef OPTION_MD_DEFAULT_SAVE_TYPE #ifndef OPTION_MD_DEFAULT_SAVE_TYPE
# define OPTION_MD_DEFAULT_SAVE_TYPE 0 #define OPTION_MD_DEFAULT_SAVE_TYPE 0
# endif /* !OPTION_MD_DEFAULT_SAVE_TYPE */ #endif /* !OPTION_MD_DEFAULT_SAVE_TYPE */
int segaSram16bit = OPTION_MD_DEFAULT_SAVE_TYPE; int segaSram16bit = OPTION_MD_DEFAULT_SAVE_TYPE;
@ -212,9 +214,8 @@ static const char MDMenuItem3[] PROGMEM = "Flash Repro";
static const char* const menuOptionsMD[] PROGMEM = { MDMenuItem1, MDMenuItem2, MDMenuItem3, FSTRING_RESET }; static const char* const menuOptionsMD[] PROGMEM = { MDMenuItem1, MDMenuItem2, MDMenuItem3, FSTRING_RESET };
// Cart menu items // Cart menu items
static const char MDCartMenuItem4[] PROGMEM = "Read EEPROM"; static const char MDCartMenuItem4[] PROGMEM = "Force ROM size";
static const char MDCartMenuItem5[] PROGMEM = "Write EEPROM"; static const char* const menuOptionsMDCart[] PROGMEM = { FSTRING_READ_ROM, FSTRING_READ_SAVE, FSTRING_WRITE_SAVE, MDCartMenuItem4, FSTRING_REFRESH_CART, FSTRING_RESET };
static const char* const menuOptionsMDCart[] PROGMEM = { FSTRING_READ_ROM, FSTRING_READ_SAVE, FSTRING_WRITE_SAVE, MDCartMenuItem4, MDCartMenuItem5, FSTRING_REFRESH_CART, FSTRING_RESET };
// Sega CD Ram Backup Cartridge menu items // Sega CD Ram Backup Cartridge menu items
static const char SCDMenuItem1[] PROGMEM = "Read Backup RAM"; static const char SCDMenuItem1[] PROGMEM = "Read Backup RAM";
@ -302,8 +303,8 @@ void mdCartMenu() {
// create menu with title and 6 options to choose from // create menu with title and 6 options to choose from
unsigned char mainMenu; unsigned char mainMenu;
// Copy menuOptions out of progmem // Copy menuOptions out of progmem
convertPgm(menuOptionsMDCart, 7); convertPgm(menuOptionsMDCart, 6);
mainMenu = question_box(F("MEGA DRIVE Reader"), menuOptions, 7, 0); mainMenu = question_box(F("MEGA DRIVE Reader"), menuOptions, 6, 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
switch (mainMenu) { switch (mainMenu) {
@ -345,8 +346,10 @@ void mdCartMenu() {
enableSram_MD(1); enableSram_MD(1);
readSram_MD(); readSram_MD();
enableSram_MD(0); enableSram_MD(0);
} else if (saveType == 4) {
readEEP_MD();
} else { } else {
print_Error(F("Cart has no Sram")); print_Error(F("Cart has no Save"));
} }
break; break;
@ -372,33 +375,22 @@ void mdCartMenu() {
print_STR(_bytes_STR, 1); print_STR(_bytes_STR, 1);
print_Error(did_not_verify_STR); print_Error(did_not_verify_STR);
} }
} else { } else if (saveType == 4) {
print_Error(F("Cart has no Sram"));
}
break;
case 3:
display_Clear();
if (saveType == 4)
readEEP_MD();
else {
print_Error(F("Cart has no EEPROM"));
}
break;
case 4:
display_Clear();
if (saveType == 4) {
// Launch file browser // Launch file browser
fileBrowser(F("Select eep file")); fileBrowser(F("Select eep file"));
display_Clear(); display_Clear();
writeEEP_MD(); writeEEP_MD();
} else { } else {
print_Error(F("Cart has no EEPROM")); print_Error(F("Cart has no Save"));
} }
break; break;
case 5: case 3:
display_Clear();
force_cartSize_MD();
break;
case 4:
// For multi-game carts // For multi-game carts
// Set reset pin to output (PH0) // Set reset pin to output (PH0)
DDRH |= (1 << 0); DDRH |= (1 << 0);
@ -412,7 +404,7 @@ void mdCartMenu() {
resetArduino(); resetArduino();
break; break;
case 6: case 5:
// Reset // Reset
resetArduino(); resetArduino();
break; break;
@ -1161,7 +1153,7 @@ void getCartInfo_MD() {
} else if (sramBase == 0x3FFC00) { } else if (sramBase == 0x3FFC00) {
// Used for some aftermarket carts without sram // Used for some aftermarket carts without sram
saveType = 0; saveType = 0;
}else { } else {
print_Msg(("sramType: ")); print_Msg(("sramType: "));
print_Msg_PaddedHex16(sramType); print_Msg_PaddedHex16(sramType);
println_Msg(FS(FSTRING_EMPTY)); println_Msg(FS(FSTRING_EMPTY));
@ -2894,6 +2886,24 @@ void readRealtec_MD() {
myFile.close(); myFile.close();
} }
void printRomSize_MD(int index) {
display_Clear();
print_Msg(F("ROM Size: "));
print_Msg(pgm_read_byte(&(MDSize[index])));
println_Msg(F(" Mbit"));
}
void force_cartSize_MD() {
cartSize = navigateMenu(0, 9, &printRomSize_MD);
cartSize = pgm_read_byte(&(MDSize[cartSize])) * 131072;
display.setCursor(0, 56); // Display selection at bottom
print_Msg(FS(FSTRING_ROM_SIZE));
print_Msg(cartSize / 131072);
println_Msg(F(" Mbit"));
display_Update();
delay(1000);
}
#endif #endif
//****************************************** //******************************************