Add option to force A23 to high while flashing HiROM repros

A23-> low enables P0 and A23->high enables P1 flashrom.
This commit is contained in:
sanni 2021-05-12 17:42:49 +02:00
parent 91be66a89b
commit c343094966
2 changed files with 80 additions and 29 deletions

View File

@ -16,7 +16,7 @@ unsigned long time;
unsigned long blank; unsigned long blank;
unsigned long sectorSize; unsigned long sectorSize;
uint16_t bufferSize; uint16_t bufferSize;
boolean hiROM = 1; byte hiROM = 1;
/****************************************** /******************************************
Menu Menu
@ -746,16 +746,22 @@ void dataIn16() {
*****************************************/ *****************************************/
void writeByte_Flash(unsigned long myAddress, byte myData) { void writeByte_Flash(unsigned long myAddress, byte myData) {
PORTF = myAddress & 0xFF; PORTF = myAddress & 0xFF;
if (hiROM) { if (hiROM == 1) {
PORTK = (myAddress >> 8) & 0xFF; PORTK = (myAddress >> 8) & 0xFF;
PORTL = (myAddress >> 16) & 0xFF; PORTL = (myAddress >> 16) & 0xFF;
} }
else { else if (hiROM == 0) {
PORTK = (myAddress >> 8) & 0x7F; PORTK = (myAddress >> 8) & 0x7F;
// Set A15(PK7) HIGH to disable SRAM // Set A15(PK7) HIGH to disable SRAM
PORTK |= (1 << 7); PORTK |= (1 << 7);
PORTL = (myAddress >> 15) & 0xFF; PORTL = (myAddress >> 15) & 0xFF;
} }
if (hiROM == 4) {
PORTK = (myAddress >> 8) & 0xFF;
PORTL = (myAddress >> 16) & 0xFF;
// Set A23(PL7) HIGH to enable high part of ExHiROM
PORTL |= (1 << 7);
}
PORTC = myData; PORTC = myData;
// Arduino running at 16Mhz -> one nop = 62.5ns // Arduino running at 16Mhz -> one nop = 62.5ns
@ -777,16 +783,22 @@ void writeByte_Flash(unsigned long myAddress, byte myData) {
byte readByte_Flash(unsigned long myAddress) { byte readByte_Flash(unsigned long myAddress) {
PORTF = myAddress & 0xFF; PORTF = myAddress & 0xFF;
if (hiROM) { if (hiROM == 1) {
PORTK = (myAddress >> 8) & 0xFF; PORTK = (myAddress >> 8) & 0xFF;
PORTL = (myAddress >> 16) & 0xFF; PORTL = (myAddress >> 16) & 0xFF;
} }
else { else if (hiROM == 0) {
PORTK = (myAddress >> 8) & 0x7F; PORTK = (myAddress >> 8) & 0x7F;
// Set A15(PK7) HIGH to disable SRAM // Set A15(PK7) HIGH to disable SRAM
PORTK |= (1 << 7); PORTK |= (1 << 7);
PORTL = (myAddress >> 15) & 0xFF; PORTL = (myAddress >> 15) & 0xFF;
} }
else if (hiROM == 4) {
PORTK = (myAddress >> 8) & 0xFF;
PORTL = (myAddress >> 16) & 0xFF;
// Set A23(PL7) HIGH to enable high part of ExHiROM
PORTL |= (1 << 7);
}
// Arduino running at 16Mhz -> one nop = 62.5ns // Arduino running at 16Mhz -> one nop = 62.5ns
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t"); __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");

View File

@ -35,10 +35,9 @@ boolean altconf = 0;
static const char snsMenuItem1[] PROGMEM = "Super Nintendo"; static const char snsMenuItem1[] PROGMEM = "Super Nintendo";
static const char snsMenuItem2[] PROGMEM = "NPower SF Memory"; static const char snsMenuItem2[] PROGMEM = "NPower SF Memory";
static const char snsMenuItem3[] PROGMEM = "Satellaview BS-X"; static const char snsMenuItem3[] PROGMEM = "Satellaview BS-X";
static const char snsMenuItem4[] PROGMEM = "HiROM repro"; static const char snsMenuItem4[] PROGMEM = "Flash repro";
static const char snsMenuItem5[] PROGMEM = "LoROM repro"; static const char snsMenuItem5[] PROGMEM = "Reset";
static const char snsMenuItem6[] PROGMEM = "Reset"; static const char* const menuOptionsSNS[] PROGMEM = {snsMenuItem1, snsMenuItem2, snsMenuItem3, snsMenuItem4, snsMenuItem5};
static const char* const menuOptionsSNS[] PROGMEM = {snsMenuItem1, snsMenuItem2, snsMenuItem3, snsMenuItem4, snsMenuItem5, snsMenuItem6};
// SNES menu items // SNES menu items
static const char SnesMenuItem1[] PROGMEM = "Read Rom"; static const char SnesMenuItem1[] PROGMEM = "Read Rom";
@ -58,13 +57,69 @@ 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 menuOptionsConfManual[] PROGMEM = {confMenuItem1, confMenuItem2, confMenuItem3, confMenuItem4, confMenuItem5}; static const char* const menuOptionsConfManual[] PROGMEM = {confMenuItem1, confMenuItem2, confMenuItem3, confMenuItem4, confMenuItem5};
// Repro menu items
static const char reproMenuItem1[] PROGMEM = "LoROM repro";
static const char reproMenuItem2[] PROGMEM = "HiROM repro P0";
static const char reproMenuItem3[] PROGMEM = "HiROM repro P1";
static const char reproMenuItem4[] PROGMEM = "Reset";
static const char* const menuOptionsRepro[] PROGMEM = {reproMenuItem1, reproMenuItem2, reproMenuItem3, reproMenuItem4};
// SNES repro menu
void reproMenu() {
// create menu with title and 6 options to choose from
unsigned char snsRepro;
// Copy menuOptions out of progmem
convertPgm(menuOptionsRepro, 4);
snsRepro = question_box(F("Select Repro Type"), menuOptions, 4, 0);
// wait for user choice to come back from the question box menu
switch (snsRepro)
{
#ifdef enable_FLASH
case 0:
display_Clear();
display_Update();
hiROM = 0;
setup_Flash8();
id_Flash8();
wait();
mode = mode_FLASH8;
break;
case 1:
display_Clear();
display_Update();
hiROM = 1;
setup_Flash8();
id_Flash8();
wait();
mode = mode_FLASH8;
break;
case 2:
display_Clear();
display_Update();
hiROM = 4;
setup_Flash8();
id_Flash8();
wait();
mode = mode_FLASH8;
break;
#endif
case 3:
resetArduino();
break;
}
}
// SNES start menu // SNES start menu
void snsMenu() { void snsMenu() {
// create menu with title and 6 options to choose from // create menu with title and 6 options to choose from
unsigned char snsCart; unsigned char snsCart;
// Copy menuOptions out of progmem // Copy menuOptions out of progmem
convertPgm(menuOptionsSNS, 6); convertPgm(menuOptionsSNS, 5);
snsCart = question_box(F("Select Cart Type"), menuOptions, 6, 0); snsCart = question_box(F("Select Cart Type"), 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
switch (snsCart) switch (snsCart)
@ -94,27 +149,11 @@ void snsMenu() {
#ifdef enable_FLASH #ifdef enable_FLASH
case 3: case 3:
display_Clear(); reproMenu();
display_Update();
hiROM = 1;
setup_Flash8();
id_Flash8();
wait();
mode = mode_FLASH8;
break;
case 4:
display_Clear();
display_Update();
hiROM = 0;
setup_Flash8();
id_Flash8();
wait();
mode = mode_FLASH8;
break; break;
#endif #endif
case 5: case 4:
resetArduino(); resetArduino();
break; break;
} }