mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-15 01:15:06 +01:00
Always disable SRAM when flashing any hirom repros
This commit is contained in:
parent
27b84d2f7e
commit
f798336aaa
@ -15,7 +15,7 @@ unsigned long time;
|
||||
unsigned long blank;
|
||||
unsigned long sectorSize;
|
||||
uint16_t bufferSize;
|
||||
byte mapping = 1;
|
||||
byte mapping = 0;
|
||||
|
||||
/******************************************
|
||||
Menu
|
||||
@ -57,6 +57,10 @@ static const char epromMenuItem4[] PROGMEM = "Verify";
|
||||
static const char* const menuOptionsEprom[] PROGMEM = { flashMenuItemBlankcheck, flashMenuItemRead, flashMenuItemWrite, epromMenuItem4, flashMenuItemPrint, FSTRING_RESET };
|
||||
|
||||
void flashMenu() {
|
||||
display_Clear();
|
||||
display_Update();
|
||||
mapping = 0;
|
||||
|
||||
// create menu with title and 5 options to choose from
|
||||
unsigned char flashSlot;
|
||||
// Copy menuOptions out of progmem
|
||||
@ -77,9 +81,6 @@ void flashMenu() {
|
||||
break;
|
||||
|
||||
case 1:
|
||||
display_Clear();
|
||||
display_Update();
|
||||
mapping = 1;
|
||||
setup_Flash8();
|
||||
id_Flash8();
|
||||
wait();
|
||||
@ -87,15 +88,11 @@ void flashMenu() {
|
||||
break;
|
||||
|
||||
case 2:
|
||||
display_Clear();
|
||||
display_Update();
|
||||
setup_Eprom();
|
||||
mode = CORE_EPROM;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
display_Clear();
|
||||
display_Update();
|
||||
setup_Flash16();
|
||||
id_Flash16();
|
||||
wait();
|
||||
@ -114,7 +111,7 @@ void flashMenu() {
|
||||
void flashMenu() {
|
||||
display_Clear();
|
||||
display_Update();
|
||||
mapping = 1;
|
||||
mapping = 0;
|
||||
|
||||
// create menu with title and 3 options to choose from
|
||||
unsigned char flashMode;
|
||||
@ -856,15 +853,15 @@ void writeByte_Flash(unsigned long myAddress, byte myData) {
|
||||
// A0-A7
|
||||
PORTF = myAddress & 0xFF;
|
||||
|
||||
// standard for flash adapter and SNES HiRom
|
||||
if (mapping == 1) {
|
||||
// flash adapter (without SRAM save chip)
|
||||
if (mapping == 0) {
|
||||
// A8-A15
|
||||
PORTK = (myAddress >> 8) & 0xFF;
|
||||
// A16-A23
|
||||
PORTL = (myAddress >> 16) & 0xFF;
|
||||
}
|
||||
// for SNES LoRom
|
||||
else if (mapping == 0) {
|
||||
// SNES LoRom
|
||||
else if (mapping == 1) {
|
||||
// A8-A14
|
||||
PORTK = (myAddress >> 8) & 0x7F;
|
||||
// Set SNES A15(PK7) HIGH to disable SRAM
|
||||
@ -872,8 +869,39 @@ void writeByte_Flash(unsigned long myAddress, byte myData) {
|
||||
// A15-A22
|
||||
PORTL = (myAddress >> 15) & 0xFF;
|
||||
}
|
||||
// for SNES ExLoRom repro with 2x 4MB
|
||||
// SNES HiRom
|
||||
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
|
||||
PORTK = (myAddress >> 8) & 0x7F;
|
||||
// Set SNES A15(PK7) HIGH to disable SRAM
|
||||
@ -884,7 +912,7 @@ void writeByte_Flash(unsigned long myAddress, byte myData) {
|
||||
PORTL ^= (1 << 7);
|
||||
}
|
||||
// for SNES ExHiRom repro
|
||||
else if (mapping == 3) {
|
||||
else if (mapping == 222) {
|
||||
// A8-A15
|
||||
PORTK = (myAddress >> 8) & 0xFF;
|
||||
// A16-A22
|
||||
@ -900,28 +928,6 @@ void writeByte_Flash(unsigned long myAddress, byte myData) {
|
||||
// Switch SNES BA6(PL6) to HIGH to disable SRAM
|
||||
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
|
||||
PORTC = myData;
|
||||
@ -962,15 +968,15 @@ byte readByte_Flash(unsigned long myAddress) {
|
||||
// A0-A7
|
||||
PORTF = myAddress & 0xFF;
|
||||
|
||||
// standard for flash adapter and SNES HiRom
|
||||
if (mapping == 1) {
|
||||
// flash adapter (without SRAM save chip)
|
||||
if (mapping == 0) {
|
||||
// A8-A15
|
||||
PORTK = (myAddress >> 8) & 0xFF;
|
||||
// A16-A23
|
||||
PORTL = (myAddress >> 16) & 0xFF;
|
||||
}
|
||||
// for SNES LoRom
|
||||
else if (mapping == 0) {
|
||||
// SNES LoRom
|
||||
else if (mapping == 1) {
|
||||
// A8-A14
|
||||
PORTK = (myAddress >> 8) & 0x7F;
|
||||
// Set SNES A15(PK7) HIGH to disable SRAM
|
||||
@ -978,8 +984,39 @@ byte readByte_Flash(unsigned long myAddress) {
|
||||
// A15-A22
|
||||
PORTL = (myAddress >> 15) & 0xFF;
|
||||
}
|
||||
// for SNES ExLoRom repro
|
||||
// SNES HiRom
|
||||
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
|
||||
PORTK = (myAddress >> 8) & 0x7F;
|
||||
// Set SNES A15(PK7) HIGH to disable SRAM
|
||||
@ -990,7 +1027,7 @@ byte readByte_Flash(unsigned long myAddress) {
|
||||
PORTL ^= (1 << 7);
|
||||
}
|
||||
// for SNES ExHiRom repro
|
||||
else if (mapping == 3) {
|
||||
else if (mapping == 222) {
|
||||
// A8-A15
|
||||
PORTK = (myAddress >> 8) & 0xFF;
|
||||
// A16-A22
|
||||
@ -1006,28 +1043,6 @@ byte readByte_Flash(unsigned long myAddress) {
|
||||
// Switch SNES BA6(PL6) to HIGH to disable SRAM
|
||||
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
|
||||
__asm__("nop\n\t"
|
||||
|
@ -112,11 +112,11 @@ void reproCFIMenu() {
|
||||
|
||||
// Switch to second ROM chip, see flash.ino low level functions line 811
|
||||
// LoROM
|
||||
if (mapping == 0)
|
||||
mapping = 4;
|
||||
if (mapping == 1)
|
||||
mapping = 11;
|
||||
// HiROM
|
||||
else if (mapping == 1)
|
||||
mapping = 5;
|
||||
else if (mapping == 2)
|
||||
mapping = 22;
|
||||
|
||||
// Write second rom chip
|
||||
display_Clear();
|
||||
@ -159,13 +159,13 @@ void reproMenu() {
|
||||
#ifdef ENABLE_FLASH
|
||||
case 0:
|
||||
// CFI LoROM
|
||||
mapping = 0;
|
||||
mapping = 1;
|
||||
reproCFIMenu();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// CFI HiROM
|
||||
mapping = 1;
|
||||
mapping = 2;
|
||||
reproCFIMenu();
|
||||
break;
|
||||
|
||||
@ -173,7 +173,7 @@ void reproMenu() {
|
||||
// LoRom
|
||||
display_Clear();
|
||||
display_Update();
|
||||
mapping = 0;
|
||||
mapping = 1;
|
||||
setup_Flash8();
|
||||
id_Flash8();
|
||||
wait();
|
||||
@ -184,7 +184,7 @@ void reproMenu() {
|
||||
// HiRom
|
||||
display_Clear();
|
||||
display_Update();
|
||||
mapping = 1;
|
||||
mapping = 2;
|
||||
setup_Flash8();
|
||||
id_Flash8();
|
||||
wait();
|
||||
@ -195,7 +195,7 @@ void reproMenu() {
|
||||
// ExLoRom
|
||||
display_Clear();
|
||||
display_Update();
|
||||
mapping = 2;
|
||||
mapping = 111;
|
||||
setup_Flash8();
|
||||
id_Flash8();
|
||||
wait();
|
||||
@ -206,7 +206,7 @@ void reproMenu() {
|
||||
// ExHiRom
|
||||
display_Clear();
|
||||
display_Update();
|
||||
mapping = 3;
|
||||
mapping = 222;
|
||||
setup_Flash8();
|
||||
id_Flash8();
|
||||
wait();
|
||||
|
Loading…
Reference in New Issue
Block a user