Skip to content

Commit

Permalink
Release CPS3 OSCR Adapter commit
Browse files Browse the repository at this point in the history
  • Loading branch information
herzmx committed Sep 12, 2024
1 parent 612d020 commit 62c4f5e
Show file tree
Hide file tree
Showing 6 changed files with 1,800 additions and 18 deletions.
24 changes: 19 additions & 5 deletions Cart_Reader/Cart_Reader.ino
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ boolean checkCartSelection(FsFile& database, void (*readData)(FsFile&, void*), v
}

#if ( \
defined(ENABLE_ODY2) || defined(ENABLE_ARC) || defined(ENABLE_FAIRCHILD) || defined(ENABLE_MSX) || defined(ENABLE_POKE) || defined(ENABLE_2600) || defined(ENABLE_5200) || defined(ENABLE_7800) || defined(ENABLE_C64) || defined(ENABLE_VECTREX) || defined(ENABLE_NES) || defined(ENABLE_GBX) || defined(ENABLE_BALLY) || defined(ENABLE_PV1000) || defined(ENABLE_PYUUTA) || defined(ENABLE_RCA) || defined(ENABLE_TRS80) || defined(ENABLE_VIC20) || defined(ENABLE_LEAP) || defined(ENABLE_LJ) || defined(ENABLE_VSMILE) || defined(ENABLE_TI99) || defined(ENABLE_ATARI8))
defined(ENABLE_ODY2) || defined(ENABLE_ARC) || defined(ENABLE_FAIRCHILD) || defined(ENABLE_MSX) || defined(ENABLE_POKE) || defined(ENABLE_2600) || defined(ENABLE_5200) || defined(ENABLE_7800) || defined(ENABLE_C64) || defined(ENABLE_VECTREX) || defined(ENABLE_NES) || defined(ENABLE_GBX) || defined(ENABLE_BALLY) || defined(ENABLE_PV1000) || defined(ENABLE_PYUUTA) || defined(ENABLE_RCA) || defined(ENABLE_TRS80) || defined(ENABLE_VIC20) || defined(ENABLE_LEAP) || defined(ENABLE_LJ) || defined(ENABLE_VSMILE) || defined(ENABLE_TI99) || defined(ENABLE_ATARI8) || defined(ENABLE_CPS3))
void printInstructions() {
println_Msg(FS(FSTRING_EMPTY));

Expand Down Expand Up @@ -1125,8 +1125,9 @@ constexpr char modeItem38[] PROGMEM = "Tomy Pyuuta";
constexpr char modeItem39[] PROGMEM = "TRS-80";
constexpr char modeItem40[] PROGMEM = "Vtech V.Smile (3V)";
constexpr char modeItem41[] PROGMEM = "Flashrom Programmer";
constexpr char modeItem42[] PROGMEM = "Self Test (3V)";
constexpr char modeItem43[] PROGMEM = "About";
constexpr char modeItem42[] PROGMEM = "CP System III";
constexpr char modeItem43[] PROGMEM = "Self Test (3V)";
constexpr char modeItem44[] PROGMEM = "About";

static const char* const modeOptions[] PROGMEM = {
#ifdef ENABLE_GBX
Expand Down Expand Up @@ -1252,10 +1253,13 @@ static const char* const modeOptions[] PROGMEM = {
#ifdef ENABLE_FLASH8
modeItem41,
#endif
#ifdef ENABLE_SELFTEST
#ifdef ENABLE_CPS3
modeItem42,
#endif
modeItem43, FSTRING_RESET
#ifdef ENABLE_SELFTEST
modeItem43,
#endif
modeItem44, FSTRING_RESET

};

Expand Down Expand Up @@ -1573,6 +1577,11 @@ void mainMenu() {
break;
#endif

#ifdef ENABLE_CPS3
case SYSTEM_MENU_CPS3:
return cpsMenu();
#endif

#ifdef ENABLE_SELFTEST
case SYSTEM_MENU_SELFTEST:
return selfTest();
Expand Down Expand Up @@ -3835,6 +3844,11 @@ void loop() {
#endif
#ifdef ENABLE_VSMILE
case CORE_VSMILE: return vsmileMenu();
#endif
#ifdef ENABLE_CPS3
case CORE_CPS3_CART: return flashromCPS_Cartridge();
case CORE_CPS3_128SIMM: return flashromCPS_SIMM2x8();
case CORE_CPS3_64SIMM: return flashromCPS_SIMM4x8();
#endif
case CORE_MAX: return resetArduino();
}
Expand Down
7 changes: 7 additions & 0 deletions Cart_Reader/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@

/****/

/* [ CP System III ------------------------------------------------ ]
*/

#define ENABLE_CPS3

/****/

/*==== FIRMWARE OPTIONS ===========================================*/

/* [ Config File -------------------------------------------------- ]
Expand Down
53 changes: 41 additions & 12 deletions Cart_Reader/FLASH.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ unsigned long blank;
unsigned long sectorSize;
uint16_t bufferSize;
byte mapping = 0;
boolean byteCtrl = 0;

/******************************************
Menu
Expand Down Expand Up @@ -238,7 +239,7 @@ void flashromMenu8() {
writeFlash29LV640();
else if (flashid == 0x017E)
writeFlash29GL(sectorSize, bufferSize);
else if ((flashid == 0x0458) || (flashid == 0x0158) || (flashid == 0x01AB))
else if ((flashid == 0x0458) || (flashid == 0x0158) || (flashid == 0x01AB) || (flashid == 0x0422) || (flashid == 0x0423))
writeFlash29F800();
else if (flashid == 0x0) // Manual flash config, pick most common type
writeFlash29LV640();
Expand Down Expand Up @@ -576,7 +577,7 @@ idtheflash:
flashSize = 2097152;
flashromType = 1;
} else if (flashid == 0x04AD) {
println_Msg(F("AM29F016D detected"));
println_Msg(F("MBM29F016A detected"));
flashSize = 2097152;
flashromType = 1;
} else if (flashid == 0x04D4) {
Expand All @@ -595,6 +596,14 @@ idtheflash:
println_Msg(F("AM29F400AB detected"));
flashSize = 131072 * 4;
flashromType = 2;
} else if (flashid == 0x0423) {
println_Msg(F("MBM29F400TC detected"));
flashSize = 131072 * 4;
flashromType = 2;
} else if (flashid == 0x0422) {
println_Msg(F("MBM29F400BC detected"));
flashSize = 131072 * 4;
flashromType = 2;
} else if (flashid == 0x0158) {
println_Msg(F("AM29F800BB detected"));
flashSize = 1048576;
Expand Down Expand Up @@ -1207,8 +1216,13 @@ byte readByte_Flash(unsigned long myAddress) {
"nop\n\t"
"nop\n\t");

// Setting OE(PH1) OE_SNS(PH3) LOW
PORTH &= ~((1 << 1) | (1 << 3));
if (byteCtrl) {
// Setting OE(PH1) LOW
PORTH &= ~(1 << 1);
} else {
// Setting OE(PH1) OE_SNS(PH3) LOW
PORTH &= ~((1 << 1) | (1 << 3));
}

__asm__("nop\n\t"
"nop\n\t"
Expand All @@ -1220,8 +1234,13 @@ byte readByte_Flash(unsigned long myAddress) {
// Read
byte tempByte = PINC;

// Setting OE(PH1) OE_SNS(PH3) HIGH
PORTH |= (1 << 1) | (1 << 3);
if (byteCtrl) {
// Setting OE(PH1) HIGH
PORTH |= (1 << 1);
} else {
// Setting OE(PH1) OE_SNS(PH3) HIGH
PORTH |= (1 << 1) | (1 << 3);
}
__asm__("nop\n\t"
"nop\n\t"
"nop\n\t"
Expand Down Expand Up @@ -1507,8 +1526,13 @@ int busyCheck29F032(uint32_t addr, byte c) {
// Set data pins to input
dataIn8();

// Setting OE(PH1) OE_SNS(PH3) CE(PH6)LOW
PORTH &= ~((1 << 1) | (1 << 3) | (1 << 6));
if (byteCtrl) {
// Setting OE(PH1) CE(PH6)LOW
PORTH &= ~((1 << 1) | (1 << 6));
} else {
// Setting OE(PH1) OE_SNS(PH3) CE(PH6)LOW
PORTH &= ~((1 << 1) | (1 << 3) | (1 << 6));
}
// Setting WE(PH4) WE_SNES(PH5) HIGH
PORTH |= (1 << 4) | (1 << 5);

Expand Down Expand Up @@ -1537,8 +1561,13 @@ int busyCheck29F032(uint32_t addr, byte c) {
// Set data pins to output
dataOut();

// Setting OE(PH1) OE_SNS(PH3) HIGH
PORTH |= (1 << 1) | (1 << 3);
if (byteCtrl) {
// Setting OE(PH1) HIGH
PORTH |= (1 << 1);
} else {
// Setting OE(PH1) OE_SNS(PH3) HIGH
PORTH |= (1 << 1) | (1 << 3);
}
return ret;
}
/******************************************
Expand Down Expand Up @@ -2425,11 +2454,11 @@ void printFlash16(int numBytes) {
byte right_byte = (currWord >> 8) & 0xFF;


sprintf(buf, "%.2x", left_byte);
sprintf(buf, "%.2X", left_byte);
// Now print the significant bits
print_Msg(buf);

sprintf(buf, "%.2x", right_byte);
sprintf(buf, "%.2X", right_byte);
// Now print the significant bits
print_Msg(buf);
}
Expand Down
Loading

0 comments on commit 62c4f5e

Please sign in to comment.