Always disable SRAM when flashing any hirom repros

This commit is contained in:
sanni 2024-06-30 11:04:40 +02:00
parent 27b84d2f7e
commit f798336aaa
3 changed files with 107 additions and 92 deletions

View File

@ -442,46 +442,46 @@
*/ */
#if defined(ENABLE_CONFIG) #if defined(ENABLE_CONFIG)
# define CONFIG_FILE "config.txt" #define CONFIG_FILE "config.txt"
// Define the max length of the key=value pairs // Define the max length of the key=value pairs
// Do your best not to have to increase these. // Do your best not to have to increase these.
# define CONFIG_KEY_MAX 32 #define CONFIG_KEY_MAX 32
# define CONFIG_VALUE_MAX 32 #define CONFIG_VALUE_MAX 32
#endif #endif
#if (defined(HW4) || defined(HW5)) #if (defined(HW4) || defined(HW5))
# define ENABLE_LCD #define ENABLE_LCD
# define ENABLE_NEOPIXEL #define ENABLE_NEOPIXEL
# define ENABLE_ROTARY #define ENABLE_ROTARY
//# define rotate_counter_clockwise //# define rotate_counter_clockwise
# define ENABLE_CLOCKGEN #define ENABLE_CLOCKGEN
# define OPTION_N64_FASTCRC #define OPTION_N64_FASTCRC
# define OPTION_WS_ADAPTER_V2 #define OPTION_WS_ADAPTER_V2
#endif #endif
#if (defined(HW2) || defined(HW3)) #if (defined(HW2) || defined(HW3))
# define ENABLE_OLED #define ENABLE_OLED
# define ENABLE_BUTTON2 #define ENABLE_BUTTON2
# define ENABLE_CLOCKGEN #define ENABLE_CLOCKGEN
# define ENABLE_CA_LED #define ENABLE_CA_LED
# define OPTION_N64_FASTCRC #define OPTION_N64_FASTCRC
#endif #endif
#if defined(HW1) #if defined(HW1)
# define ENABLE_OLED #define ENABLE_OLED
//#define ENABLE_CLOCKGEN //#define ENABLE_CLOCKGEN
//#define OPTION_N64_FASTCRC //#define OPTION_N64_FASTCRC
#endif #endif
#if defined(SERIAL_MONITOR) #if defined(SERIAL_MONITOR)
# define ENABLE_SERIAL #define ENABLE_SERIAL
//#define ENABLE_CLOCKGEN //#define ENABLE_CLOCKGEN
//#define OPTION_N64_FASTCRC //#define OPTION_N64_FASTCRC
#endif #endif
/* Firmware updater only works with HW3 and HW5 */ /* Firmware updater only works with HW3 and HW5 */
#if !(defined(HW5) || defined(HW3)) #if !(defined(HW5) || defined(HW3))
# undef ENABLE_UPDATER #undef ENABLE_UPDATER
#endif #endif
/* End of settings */ /* End of settings */

View File

@ -15,7 +15,7 @@ unsigned long time;
unsigned long blank; unsigned long blank;
unsigned long sectorSize; unsigned long sectorSize;
uint16_t bufferSize; uint16_t bufferSize;
byte mapping = 1; byte mapping = 0;
/****************************************** /******************************************
Menu Menu
@ -57,6 +57,10 @@ static const char epromMenuItem4[] PROGMEM = "Verify";
static const char* const menuOptionsEprom[] PROGMEM = { flashMenuItemBlankcheck, flashMenuItemRead, flashMenuItemWrite, epromMenuItem4, flashMenuItemPrint, FSTRING_RESET }; static const char* const menuOptionsEprom[] PROGMEM = { flashMenuItemBlankcheck, flashMenuItemRead, flashMenuItemWrite, epromMenuItem4, flashMenuItemPrint, FSTRING_RESET };
void flashMenu() { void flashMenu() {
display_Clear();
display_Update();
mapping = 0;
// create menu with title and 5 options to choose from // create menu with title and 5 options to choose from
unsigned char flashSlot; unsigned char flashSlot;
// Copy menuOptions out of progmem // Copy menuOptions out of progmem
@ -77,9 +81,6 @@ void flashMenu() {
break; break;
case 1: case 1:
display_Clear();
display_Update();
mapping = 1;
setup_Flash8(); setup_Flash8();
id_Flash8(); id_Flash8();
wait(); wait();
@ -87,15 +88,11 @@ void flashMenu() {
break; break;
case 2: case 2:
display_Clear();
display_Update();
setup_Eprom(); setup_Eprom();
mode = CORE_EPROM; mode = CORE_EPROM;
break; break;
case 3: case 3:
display_Clear();
display_Update();
setup_Flash16(); setup_Flash16();
id_Flash16(); id_Flash16();
wait(); wait();
@ -114,7 +111,7 @@ void flashMenu() {
void flashMenu() { void flashMenu() {
display_Clear(); display_Clear();
display_Update(); display_Update();
mapping = 1; mapping = 0;
// create menu with title and 3 options to choose from // create menu with title and 3 options to choose from
unsigned char flashMode; unsigned char flashMode;
@ -856,15 +853,15 @@ void writeByte_Flash(unsigned long myAddress, byte myData) {
// A0-A7 // A0-A7
PORTF = myAddress & 0xFF; PORTF = myAddress & 0xFF;
// standard for flash adapter and SNES HiRom // flash adapter (without SRAM save chip)
if (mapping == 1) { if (mapping == 0) {
// A8-A15 // A8-A15
PORTK = (myAddress >> 8) & 0xFF; PORTK = (myAddress >> 8) & 0xFF;
// A16-A23 // A16-A23
PORTL = (myAddress >> 16) & 0xFF; PORTL = (myAddress >> 16) & 0xFF;
} }
// for SNES LoRom // SNES LoRom
else if (mapping == 0) { else if (mapping == 1) {
// A8-A14 // A8-A14
PORTK = (myAddress >> 8) & 0x7F; PORTK = (myAddress >> 8) & 0x7F;
// Set SNES A15(PK7) HIGH to disable SRAM // Set SNES A15(PK7) HIGH to disable SRAM
@ -872,8 +869,39 @@ void writeByte_Flash(unsigned long myAddress, byte myData) {
// A15-A22 // A15-A22
PORTL = (myAddress >> 15) & 0xFF; PORTL = (myAddress >> 15) & 0xFF;
} }
// for SNES ExLoRom repro with 2x 4MB // SNES HiRom
else if (mapping == 2) { else if (mapping == 2) {
// A8-A15
PORTK = (myAddress >> 8) & 0xFF;
// A16-A23
PORTL = (myAddress >> 16) & 0xFF;
// Switch SNES BA6(PL6) to HIGH to disable SRAM
PORTL |= (1 << 6);
}
// for SNES LoRom repro with 2x 2MB
else if (mapping == 11) {
// A8-A14
PORTK = (myAddress >> 8) & 0x7F;
// Set SNES A15(PK7) HIGH to disable SRAM
PORTK |= (1 << 7);
// A15-A22
PORTL = (myAddress >> 15) & 0xFF;
// Flip BA6(PL6) to address second rom chip
PORTL ^= (1 << 6);
}
// for SNES HiRom repro with 2x 2MB
else if (mapping == 22) {
// A8-A15
PORTK = (myAddress >> 8) & 0xFF;
// A16-A23
PORTL = (myAddress >> 16) & 0xFF;
// Flip BA5(PL5) to address second rom chip
PORTL ^= (1 << 5);
// Switch SNES BA6(PL6) to HIGH to disable SRAM
PORTL |= (1 << 6);
}
// for SNES ExLoRom repro with 2x 4MB
else if (mapping == 111) {
// A8-A14 // A8-A14
PORTK = (myAddress >> 8) & 0x7F; PORTK = (myAddress >> 8) & 0x7F;
// Set SNES A15(PK7) HIGH to disable SRAM // Set SNES A15(PK7) HIGH to disable SRAM
@ -884,7 +912,7 @@ void writeByte_Flash(unsigned long myAddress, byte myData) {
PORTL ^= (1 << 7); PORTL ^= (1 << 7);
} }
// for SNES ExHiRom repro // for SNES ExHiRom repro
else if (mapping == 3) { else if (mapping == 222) {
// A8-A15 // A8-A15
PORTK = (myAddress >> 8) & 0xFF; PORTK = (myAddress >> 8) & 0xFF;
// A16-A22 // A16-A22
@ -900,28 +928,6 @@ void writeByte_Flash(unsigned long myAddress, byte myData) {
// Switch SNES BA6(PL6) to HIGH to disable SRAM // Switch SNES BA6(PL6) to HIGH to disable SRAM
PORTL |= (1 << 6); PORTL |= (1 << 6);
} }
// for SNES LoRom repro with 2x 2MB
else if (mapping == 4) {
// A8-A14
PORTK = (myAddress >> 8) & 0x7F;
// Set SNES A15(PK7) HIGH to disable SRAM
PORTK |= (1 << 7);
// A15-A22
PORTL = (myAddress >> 15) & 0xFF;
// Flip BA6(PL6) to address second rom chip
PORTL ^= (1 << 6);
}
// for SNES HiRom repro with 2x 2MB
else if (mapping == 5) {
// A8-A15
PORTK = (myAddress >> 8) & 0xFF;
// A16-A23
PORTL = (myAddress >> 16) & 0xFF;
// Flip BA5(PL5) to address second rom chip
PORTL ^= (1 << 5);
// Switch SNES BA6(PL6) to HIGH to disable SRAM
PORTL |= (1 << 6);
}
// Data // Data
PORTC = myData; PORTC = myData;
@ -962,15 +968,15 @@ byte readByte_Flash(unsigned long myAddress) {
// A0-A7 // A0-A7
PORTF = myAddress & 0xFF; PORTF = myAddress & 0xFF;
// standard for flash adapter and SNES HiRom // flash adapter (without SRAM save chip)
if (mapping == 1) { if (mapping == 0) {
// A8-A15 // A8-A15
PORTK = (myAddress >> 8) & 0xFF; PORTK = (myAddress >> 8) & 0xFF;
// A16-A23 // A16-A23
PORTL = (myAddress >> 16) & 0xFF; PORTL = (myAddress >> 16) & 0xFF;
} }
// for SNES LoRom // SNES LoRom
else if (mapping == 0) { else if (mapping == 1) {
// A8-A14 // A8-A14
PORTK = (myAddress >> 8) & 0x7F; PORTK = (myAddress >> 8) & 0x7F;
// Set SNES A15(PK7) HIGH to disable SRAM // Set SNES A15(PK7) HIGH to disable SRAM
@ -978,8 +984,39 @@ byte readByte_Flash(unsigned long myAddress) {
// A15-A22 // A15-A22
PORTL = (myAddress >> 15) & 0xFF; PORTL = (myAddress >> 15) & 0xFF;
} }
// for SNES ExLoRom repro // SNES HiRom
else if (mapping == 2) { else if (mapping == 2) {
// A8-A15
PORTK = (myAddress >> 8) & 0xFF;
// A16-A23
PORTL = (myAddress >> 16) & 0xFF;
// Switch SNES BA6(PL6) to HIGH to disable SRAM
PORTL |= (1 << 6);
}
// for SNES LoRom repro with 2x 2MB
else if (mapping == 11) {
// A8-A14
PORTK = (myAddress >> 8) & 0x7F;
// Set SNES A15(PK7) HIGH to disable SRAM
PORTK |= (1 << 7);
// A15-A22
PORTL = (myAddress >> 15) & 0xFF;
// Flip BA6(PL6) to address second rom chip
PORTL ^= (1 << 6);
}
// for SNES HiRom repro with 2x 2MB
else if (mapping == 22) {
// A8-A15
PORTK = (myAddress >> 8) & 0xFF;
// A16-A23
PORTL = (myAddress >> 16) & 0xFF;
// Flip BA5(PL5) to address second rom chip
PORTL ^= (1 << 5);
// Switch SNES BA6(PL6) to HIGH to disable SRAM
PORTL |= (1 << 6);
}
// for SNES ExLoRom repro
else if (mapping == 111) {
// A8-A14 // A8-A14
PORTK = (myAddress >> 8) & 0x7F; PORTK = (myAddress >> 8) & 0x7F;
// Set SNES A15(PK7) HIGH to disable SRAM // Set SNES A15(PK7) HIGH to disable SRAM
@ -990,7 +1027,7 @@ byte readByte_Flash(unsigned long myAddress) {
PORTL ^= (1 << 7); PORTL ^= (1 << 7);
} }
// for SNES ExHiRom repro // for SNES ExHiRom repro
else if (mapping == 3) { else if (mapping == 222) {
// A8-A15 // A8-A15
PORTK = (myAddress >> 8) & 0xFF; PORTK = (myAddress >> 8) & 0xFF;
// A16-A22 // A16-A22
@ -1006,28 +1043,6 @@ byte readByte_Flash(unsigned long myAddress) {
// Switch SNES BA6(PL6) to HIGH to disable SRAM // Switch SNES BA6(PL6) to HIGH to disable SRAM
PORTL |= (1 << 6); PORTL |= (1 << 6);
} }
// for SNES LoRom repro with 2x 2MB
else if (mapping == 4) {
// A8-A14
PORTK = (myAddress >> 8) & 0x7F;
// Set SNES A15(PK7) HIGH to disable SRAM
PORTK |= (1 << 7);
// A15-A22
PORTL = (myAddress >> 15) & 0xFF;
// Flip BA6(PL6) to address second rom chip
PORTL ^= (1 << 6);
}
// for SNES HiRom repro with 2x 2MB
else if (mapping == 5) {
// A8-A15
PORTK = (myAddress >> 8) & 0xFF;
// A16-A23
PORTL = (myAddress >> 16) & 0xFF;
// Flip BA5(PL5) to address second rom chip
PORTL ^= (1 << 5);
// Switch SNES BA6(PL6) to HIGH to disable SRAM
PORTL |= (1 << 6);
}
// Arduino running at 16Mhz -> one nop = 62.5ns // Arduino running at 16Mhz -> one nop = 62.5ns
__asm__("nop\n\t" __asm__("nop\n\t"

View File

@ -112,11 +112,11 @@ void reproCFIMenu() {
// Switch to second ROM chip, see flash.ino low level functions line 811 // Switch to second ROM chip, see flash.ino low level functions line 811
// LoROM // LoROM
if (mapping == 0) if (mapping == 1)
mapping = 4; mapping = 11;
// HiROM // HiROM
else if (mapping == 1) else if (mapping == 2)
mapping = 5; mapping = 22;
// Write second rom chip // Write second rom chip
display_Clear(); display_Clear();
@ -159,13 +159,13 @@ void reproMenu() {
#ifdef ENABLE_FLASH #ifdef ENABLE_FLASH
case 0: case 0:
// CFI LoROM // CFI LoROM
mapping = 0; mapping = 1;
reproCFIMenu(); reproCFIMenu();
break; break;
case 1: case 1:
// CFI HiROM // CFI HiROM
mapping = 1; mapping = 2;
reproCFIMenu(); reproCFIMenu();
break; break;
@ -173,7 +173,7 @@ void reproMenu() {
// LoRom // LoRom
display_Clear(); display_Clear();
display_Update(); display_Update();
mapping = 0; mapping = 1;
setup_Flash8(); setup_Flash8();
id_Flash8(); id_Flash8();
wait(); wait();
@ -184,7 +184,7 @@ void reproMenu() {
// HiRom // HiRom
display_Clear(); display_Clear();
display_Update(); display_Update();
mapping = 1; mapping = 2;
setup_Flash8(); setup_Flash8();
id_Flash8(); id_Flash8();
wait(); wait();
@ -195,7 +195,7 @@ void reproMenu() {
// ExLoRom // ExLoRom
display_Clear(); display_Clear();
display_Update(); display_Update();
mapping = 2; mapping = 111;
setup_Flash8(); setup_Flash8();
id_Flash8(); id_Flash8();
wait(); wait();
@ -206,7 +206,7 @@ void reproMenu() {
// ExHiRom // ExHiRom
display_Clear(); display_Clear();
display_Update(); display_Update();
mapping = 3; mapping = 222;
setup_Flash8(); setup_Flash8();
id_Flash8(); id_Flash8();
wait(); wait();