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 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"
|
||||||
|
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user