Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release CPS3 OSCR Adapter #1024

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions Cart_Reader/Cart_Reader.ino
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ uint32_t calculateCRC(char* fileName, char* folder, unsigned long offset) {
/******************************************
CRC Functions for Atari, Fairchild, Ody2, Arc, etc. modules
*****************************************/
#if (defined(ENABLE_ODY2) || defined(ENABLE_ARC) || defined(ENABLE_FAIRCHILD) || defined(ENABLE_MSX) || defined(ENABLE_POKE) || defined(ENABLE_2600) || defined(ENABLE_7800) || defined(ENABLE_C64) || defined(ENABLE_VECTREX) || defined(ENABLE_NES) || defined(ENABLE_LYNX) || defined(ENABLE_ATARI8) || defined(ENABLE_BALLY) || defined(ENABLE_LEAP) || defined(ENABLE_LJ) || defined(ENABLE_LJPRO) || defined(ENABLE_PV1000) || defined(ENABLE_PYUUTA) || defined(ENABLE_RCA) || defined(ENABLE_TI99) || defined(ENABLE_TRS80) || defined(ENABLE_VIC20) || defined(ENABLE_VSMILE))
#if (defined(ENABLE_ODY2) || defined(ENABLE_ARC) || defined(ENABLE_FAIRCHILD) || defined(ENABLE_MSX) || defined(ENABLE_POKE) || defined(ENABLE_2600) || defined(ENABLE_7800) || defined(ENABLE_C64) || defined(ENABLE_VECTREX) || defined(ENABLE_NES) || defined(ENABLE_LYNX) || defined(ENABLE_ATARI8) || defined(ENABLE_BALLY) || defined(ENABLE_LEAP) || defined(ENABLE_LJ) || defined(ENABLE_LJPRO) || defined(ENABLE_PV1000) || defined(ENABLE_PYUUTA) || defined(ENABLE_RCA) || defined(ENABLE_TI99) || defined(ENABLE_TRS80) || defined(ENABLE_VIC20) || defined(ENABLE_VSMILE) || defined(ENABLE_CPS3))

void printCRC(char* checkFile, uint32_t* crcCopy, unsigned long offset) {
uint32_t crc = calculateCRC(checkFile, folder, offset);
Expand Down Expand Up @@ -1122,8 +1122,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 @@ -1249,10 +1250,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 @@ -1570,6 +1574,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 @@ -3832,6 +3841,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 @@ -390,6 +390,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
Loading