mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-10 23:15:08 +01:00
V6.4: Add ExLoRom and ExHiRom flash options
- LoRom (P0) will write up to 8MB starting from file 0x0 to flashrom 0x0. - HiRom (P0) will write up to 4MB starting from file 0x0 to flashrom 0x0. - ExLoRom (P1) will write the first 4MB starting from file 0x0 to flashrom 0x400000. And then a second block up to 4MB from file 0x400000 to flashrom 0x0. - ExHiRom (P1) will write the first 4MB starting from file 0x0 to flashrom 0x400000. And then a second block up to 4MB from file 0x400000 to flashrom 0x0.
This commit is contained in:
parent
78b5f7cb10
commit
527f3562ed
@ -1,5 +1,6 @@
|
||||
//******************************************
|
||||
// FLASHROM MODULE
|
||||
// (also includes SNES repro functions)
|
||||
//******************************************
|
||||
|
||||
#include "options.h"
|
||||
@ -16,7 +17,7 @@ unsigned long time;
|
||||
unsigned long blank;
|
||||
unsigned long sectorSize;
|
||||
uint16_t bufferSize;
|
||||
byte hiROM = 1;
|
||||
byte mapping = 1;
|
||||
|
||||
/******************************************
|
||||
Menu
|
||||
@ -70,7 +71,7 @@ void flashMenu() {
|
||||
case 0:
|
||||
display_Clear();
|
||||
display_Update();
|
||||
hiROM = 1;
|
||||
mapping = 1;
|
||||
setup_Flash8();
|
||||
id_Flash8();
|
||||
wait();
|
||||
@ -745,23 +746,56 @@ void dataIn16() {
|
||||
Low level functions
|
||||
*****************************************/
|
||||
void writeByte_Flash(unsigned long myAddress, byte myData) {
|
||||
// A0-A7
|
||||
PORTF = myAddress & 0xFF;
|
||||
if (hiROM == 1) {
|
||||
|
||||
// standard for flash adapter and SNES HiRom
|
||||
if (mapping == 1) {
|
||||
// A8-A15
|
||||
PORTK = (myAddress >> 8) & 0xFF;
|
||||
// A16-A23
|
||||
PORTL = (myAddress >> 16) & 0xFF;
|
||||
}
|
||||
else if (hiROM == 0) {
|
||||
// for SNES LoRom
|
||||
else if (mapping == 0) {
|
||||
// A8-A14
|
||||
PORTK = (myAddress >> 8) & 0x7F;
|
||||
// Set A15(PK7) HIGH to disable SRAM
|
||||
// Set SNES A15(PK7) HIGH to disable SRAM
|
||||
PORTK |= (1 << 7);
|
||||
// A15-A22
|
||||
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);
|
||||
// for SNES ExLoRom repro
|
||||
else if (mapping == 2) {
|
||||
// A8-A14
|
||||
PORTK = (myAddress >> 8) & 0x7F;
|
||||
// Set SNES A15(PK7) HIGH to disable SRAM
|
||||
PORTK |= (1 << 7);
|
||||
// A15-A22
|
||||
PORTL = (myAddress >> 15) & 0xFF;
|
||||
// Flip A22(PL7) to reverse P0 and P1 roms
|
||||
PORTL ^= (1 << PL7);
|
||||
}
|
||||
// for SNES ExHiRom repro
|
||||
else if (mapping == 3) {
|
||||
// A8-A15
|
||||
PORTK = (myAddress >> 8) & 0xFF;
|
||||
// A16-A22
|
||||
PORTL = (myAddress >> 16) & 0xFF;
|
||||
// Set PL7 to inverse of PL6 to reverse P0 and P1 roms
|
||||
if (!(((myAddress >> 16) & 0xFF) & 0x40)) {
|
||||
// if PL6 is 0 set PL7 to 1
|
||||
PORTL |= (1 << 7);
|
||||
}
|
||||
else if (((myAddress >> 16) & 0xFF) & 0x40) {
|
||||
// if PL6 is 1 set PL7 to 0
|
||||
PORTL &= ~ (1 << 7);
|
||||
}
|
||||
// Switch SNES BA6(PL6) to HIGH to disable SRAM
|
||||
PORTL |= (1 << 6);
|
||||
}
|
||||
|
||||
// Data
|
||||
PORTC = myData;
|
||||
|
||||
// Arduino running at 16Mhz -> one nop = 62.5ns
|
||||
@ -782,22 +816,53 @@ void writeByte_Flash(unsigned long myAddress, byte myData) {
|
||||
}
|
||||
|
||||
byte readByte_Flash(unsigned long myAddress) {
|
||||
// A0-A7
|
||||
PORTF = myAddress & 0xFF;
|
||||
if (hiROM == 1) {
|
||||
|
||||
// standard for flash adapter and SNES HiRom
|
||||
if (mapping == 1) {
|
||||
// A8-A15
|
||||
PORTK = (myAddress >> 8) & 0xFF;
|
||||
// A16-A23
|
||||
PORTL = (myAddress >> 16) & 0xFF;
|
||||
}
|
||||
else if (hiROM == 0) {
|
||||
// for SNES LoRom
|
||||
else if (mapping == 0) {
|
||||
// A8-A14
|
||||
PORTK = (myAddress >> 8) & 0x7F;
|
||||
// Set A15(PK7) HIGH to disable SRAM
|
||||
// Set SNES A15(PK7) HIGH to disable SRAM
|
||||
PORTK |= (1 << 7);
|
||||
// A15-A22
|
||||
PORTL = (myAddress >> 15) & 0xFF;
|
||||
}
|
||||
else if (hiROM == 4) {
|
||||
// for SNES ExLoRom repro
|
||||
else if (mapping == 2) {
|
||||
// A8-A14
|
||||
PORTK = (myAddress >> 8) & 0x7F;
|
||||
// Set SNES A15(PK7) HIGH to disable SRAM
|
||||
PORTK |= (1 << 7);
|
||||
// A15-A22
|
||||
PORTL = (myAddress >> 15) & 0xFF;
|
||||
// Flip A22(PL7) to reverse P0 and P1 roms
|
||||
PORTL ^= (1 << PL7);
|
||||
}
|
||||
// for SNES ExHiRom repro
|
||||
else if (mapping == 3) {
|
||||
// A8-A15
|
||||
PORTK = (myAddress >> 8) & 0xFF;
|
||||
// A16-A22
|
||||
PORTL = (myAddress >> 16) & 0xFF;
|
||||
// Set A23(PL7) HIGH to enable high part of ExHiROM
|
||||
PORTL |= (1 << 7);
|
||||
// Set PL7 to inverse of PL6 to reverse P0 and P1 roms
|
||||
if (!(((myAddress >> 16) & 0xFF) & 0x40)) {
|
||||
// if PL6 is 0 set PL7 to 1
|
||||
PORTL |= (1 << 7);
|
||||
}
|
||||
else if (((myAddress >> 16) & 0xFF) & 0x40) {
|
||||
// if PL6 is 1 set PL7 to 0
|
||||
PORTL &= ~ (1 << 7);
|
||||
}
|
||||
// Switch SNES BA6(PL6) to HIGH to disable SRAM
|
||||
PORTL |= (1 << 6);
|
||||
}
|
||||
|
||||
// Arduino running at 16Mhz -> one nop = 62.5ns
|
||||
|
@ -1,6 +1,6 @@
|
||||
/******************************************
|
||||
GB MEMORY MODULE
|
||||
******************************************/
|
||||
//******************************************
|
||||
// GB MEMORY MODULE
|
||||
//******************************************
|
||||
|
||||
#include "options.h"
|
||||
#ifdef enable_GBX
|
||||
|
@ -58,28 +58,30 @@ static const char confMenuItem5[] PROGMEM = "Reset";
|
||||
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};
|
||||
static const char reproMenuItem1[] PROGMEM = "LoRom (P0)";
|
||||
static const char reproMenuItem2[] PROGMEM = "HiRom (P0)";
|
||||
static const char reproMenuItem3[] PROGMEM = "ExLoRom (P1)";
|
||||
static const char reproMenuItem4[] PROGMEM = "ExHiRom (P1)";
|
||||
static const char reproMenuItem5[] PROGMEM = "Reset";
|
||||
static const char* const menuOptionsRepro[] PROGMEM = {reproMenuItem1, reproMenuItem2, reproMenuItem3, reproMenuItem4, reproMenuItem5};
|
||||
|
||||
// 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);
|
||||
convertPgm(menuOptionsRepro, 5);
|
||||
snsRepro = question_box(F("Select Repro Type"), menuOptions, 5, 0);
|
||||
|
||||
// wait for user choice to come back from the question box menu
|
||||
switch (snsRepro)
|
||||
{
|
||||
#ifdef enable_FLASH
|
||||
case 0:
|
||||
// LoRom
|
||||
display_Clear();
|
||||
display_Update();
|
||||
hiROM = 0;
|
||||
mapping = 0;
|
||||
setup_Flash8();
|
||||
id_Flash8();
|
||||
wait();
|
||||
@ -87,9 +89,10 @@ void reproMenu() {
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// HiRom
|
||||
display_Clear();
|
||||
display_Update();
|
||||
hiROM = 1;
|
||||
mapping = 1;
|
||||
setup_Flash8();
|
||||
id_Flash8();
|
||||
wait();
|
||||
@ -97,9 +100,21 @@ void reproMenu() {
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// ExLoRom
|
||||
display_Clear();
|
||||
display_Update();
|
||||
hiROM = 4;
|
||||
mapping = 2;
|
||||
setup_Flash8();
|
||||
id_Flash8();
|
||||
wait();
|
||||
mode = mode_FLASH8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// ExHiRom
|
||||
display_Clear();
|
||||
display_Update();
|
||||
mapping = 3;
|
||||
setup_Flash8();
|
||||
id_Flash8();
|
||||
wait();
|
||||
@ -107,7 +122,7 @@ void reproMenu() {
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 3:
|
||||
case 4:
|
||||
resetArduino();
|
||||
break;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/******************************************
|
||||
Options
|
||||
******************************************/
|
||||
//******************************************
|
||||
// OPTIONS
|
||||
//******************************************
|
||||
// Change mainMenu to snsMenu, mdMenu, n64Menu, gbxMenu, pcsMenu,
|
||||
// flashMenu, nesMenu or smsMenu for single slot Cart Readers
|
||||
#define startMenu mainMenu
|
||||
|
Loading…
Reference in New Issue
Block a user