diff options
Diffstat (limited to 'Cart_Reader')
-rw-r--r-- | Cart_Reader/Config.h | 34 | ||||
-rw-r--r-- | Cart_Reader/FLASH.ino | 141 | ||||
-rw-r--r-- | Cart_Reader/SNES.ino | 20 |
3 files changed, 105 insertions, 90 deletions
diff --git a/Cart_Reader/Config.h b/Cart_Reader/Config.h index 474c10b..f086edd 100644 --- a/Cart_Reader/Config.h +++ b/Cart_Reader/Config.h @@ -442,46 +442,46 @@ */
#if defined(ENABLE_CONFIG)
-# define CONFIG_FILE "config.txt"
+#define CONFIG_FILE "config.txt"
// Define the max length of the key=value pairs
// Do your best not to have to increase these.
-# define CONFIG_KEY_MAX 32
-# define CONFIG_VALUE_MAX 32
+#define CONFIG_KEY_MAX 32
+#define CONFIG_VALUE_MAX 32
#endif
#if (defined(HW4) || defined(HW5))
-# define ENABLE_LCD
-# define ENABLE_NEOPIXEL
-# define ENABLE_ROTARY
+#define ENABLE_LCD
+#define ENABLE_NEOPIXEL
+#define ENABLE_ROTARY
//# define rotate_counter_clockwise
-# define ENABLE_CLOCKGEN
-# define OPTION_N64_FASTCRC
-# define OPTION_WS_ADAPTER_V2
+#define ENABLE_CLOCKGEN
+#define OPTION_N64_FASTCRC
+#define OPTION_WS_ADAPTER_V2
#endif
#if (defined(HW2) || defined(HW3))
-# define ENABLE_OLED
-# define ENABLE_BUTTON2
-# define ENABLE_CLOCKGEN
-# define ENABLE_CA_LED
-# define OPTION_N64_FASTCRC
+#define ENABLE_OLED
+#define ENABLE_BUTTON2
+#define ENABLE_CLOCKGEN
+#define ENABLE_CA_LED
+#define OPTION_N64_FASTCRC
#endif
#if defined(HW1)
-# define ENABLE_OLED
+#define ENABLE_OLED
//#define ENABLE_CLOCKGEN
//#define OPTION_N64_FASTCRC
#endif
#if defined(SERIAL_MONITOR)
-# define ENABLE_SERIAL
+#define ENABLE_SERIAL
//#define ENABLE_CLOCKGEN
//#define OPTION_N64_FASTCRC
#endif
/* Firmware updater only works with HW3 and HW5 */
#if !(defined(HW5) || defined(HW3))
-# undef ENABLE_UPDATER
+#undef ENABLE_UPDATER
#endif
/* End of settings */
diff --git a/Cart_Reader/FLASH.ino b/Cart_Reader/FLASH.ino index 36313a1..a983469 100644 --- a/Cart_Reader/FLASH.ino +++ b/Cart_Reader/FLASH.ino @@ -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,36 +869,17 @@ 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-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 << 7);
- }
- // for SNES ExHiRom repro
- else if (mapping == 3) {
// A8-A15
PORTK = (myAddress >> 8) & 0xFF;
- // A16-A22
+ // A16-A23
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);
}
// for SNES LoRom repro with 2x 2MB
- else if (mapping == 4) {
+ else if (mapping == 11) {
// A8-A14
PORTK = (myAddress >> 8) & 0x7F;
// Set SNES A15(PK7) HIGH to disable SRAM
@@ -912,7 +890,7 @@ void writeByte_Flash(unsigned long myAddress, byte myData) { PORTL ^= (1 << 6);
}
// for SNES HiRom repro with 2x 2MB
- else if (mapping == 5) {
+ else if (mapping == 22) {
// A8-A15
PORTK = (myAddress >> 8) & 0xFF;
// A16-A23
@@ -922,6 +900,34 @@ void writeByte_Flash(unsigned long myAddress, byte myData) { // 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
+ PORTK |= (1 << 7);
+ // A15-A22
+ PORTL = (myAddress >> 15) & 0xFF;
+ // Flip A22(PL7) to reverse P0 and P1 roms
+ PORTL ^= (1 << 7);
+ }
+ // for SNES ExHiRom repro
+ else if (mapping == 222) {
+ // 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;
@@ -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,36 +984,17 @@ byte readByte_Flash(unsigned long myAddress) { // A15-A22
PORTL = (myAddress >> 15) & 0xFF;
}
- // for SNES ExLoRom repro
+ // SNES HiRom
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 << 7);
- }
- // for SNES ExHiRom repro
- else if (mapping == 3) {
// A8-A15
PORTK = (myAddress >> 8) & 0xFF;
- // A16-A22
+ // A16-A23
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);
}
// for SNES LoRom repro with 2x 2MB
- else if (mapping == 4) {
+ else if (mapping == 11) {
// A8-A14
PORTK = (myAddress >> 8) & 0x7F;
// Set SNES A15(PK7) HIGH to disable SRAM
@@ -1018,7 +1005,7 @@ byte readByte_Flash(unsigned long myAddress) { PORTL ^= (1 << 6);
}
// for SNES HiRom repro with 2x 2MB
- else if (mapping == 5) {
+ else if (mapping == 22) {
// A8-A15
PORTK = (myAddress >> 8) & 0xFF;
// A16-A23
@@ -1028,6 +1015,34 @@ byte readByte_Flash(unsigned long myAddress) { // 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
+ PORTK |= (1 << 7);
+ // A15-A22
+ PORTL = (myAddress >> 15) & 0xFF;
+ // Flip A22(PL7) to reverse P0 and P1 roms
+ PORTL ^= (1 << 7);
+ }
+ // for SNES ExHiRom repro
+ else if (mapping == 222) {
+ // 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);
+ }
// Arduino running at 16Mhz -> one nop = 62.5ns
__asm__("nop\n\t"
diff --git a/Cart_Reader/SNES.ino b/Cart_Reader/SNES.ino index d8e83c5..9782039 100644 --- a/Cart_Reader/SNES.ino +++ b/Cart_Reader/SNES.ino @@ -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();
|