mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-15 01:15:06 +01:00
Initial work on PCE flash repro, erase working
This commit is contained in:
parent
9cbc8caad3
commit
88564c21da
@ -18,6 +18,7 @@
|
|||||||
#define HUCARD 0
|
#define HUCARD 0
|
||||||
#define TURBOCHIP 1
|
#define TURBOCHIP 1
|
||||||
#define HUCARD_NOSWAP 2
|
#define HUCARD_NOSWAP 2
|
||||||
|
#define PCE_FLASH 3
|
||||||
#define DETECTION_SIZE 64
|
#define DETECTION_SIZE 64
|
||||||
#define FORCED_SIZE 1024
|
#define FORCED_SIZE 1024
|
||||||
#define CHKSUM_SKIP 0
|
#define CHKSUM_SKIP 0
|
||||||
@ -53,7 +54,8 @@ uint8_t tennokoe_bank_index = 0;
|
|||||||
static const char pceMenuItem1[] PROGMEM = "HuCARD (swapped)";
|
static const char pceMenuItem1[] PROGMEM = "HuCARD (swapped)";
|
||||||
static const char pceMenuItem2[] PROGMEM = "HuCARD(not swapped)";
|
static const char pceMenuItem2[] PROGMEM = "HuCARD(not swapped)";
|
||||||
static const char pceMenuItem3[] PROGMEM = "Turbochip";
|
static const char pceMenuItem3[] PROGMEM = "Turbochip";
|
||||||
static const char *const menuOptionspce[] PROGMEM = { pceMenuItem1, pceMenuItem2, pceMenuItem3, FSTRING_RESET };
|
static const char pceMenuItem4[] PROGMEM = "Flash Repro (SST)";
|
||||||
|
static const char *const menuOptionspce[] PROGMEM = { pceMenuItem1, pceMenuItem2, pceMenuItem3, pceMenuItem4, FSTRING_RESET };
|
||||||
|
|
||||||
// PCE card menu items
|
// PCE card menu items
|
||||||
static const char menuOptionspceCart_1[] PROGMEM = "Read RAM Bank %d";
|
static const char menuOptionspceCart_1[] PROGMEM = "Read RAM Bank %d";
|
||||||
@ -66,15 +68,18 @@ static const char menuOptionspceCart_5_fmt[] PROGMEM = "ROM size now %dK";
|
|||||||
// Turbochip menu items
|
// Turbochip menu items
|
||||||
static const char *const menuOptionspceTC[] PROGMEM = { FSTRING_READ_ROM, FSTRING_RESET };
|
static const char *const menuOptionspceTC[] PROGMEM = { FSTRING_READ_ROM, FSTRING_RESET };
|
||||||
|
|
||||||
// PCE start menu
|
#ifdef ENABLE_FLASH
|
||||||
void pcsMenu(void) {
|
// Flash repro menu items
|
||||||
// create menu with title and 3 options to choose from
|
static const char menuOptionspceFlash1[] PROGMEM = "Erase";
|
||||||
unsigned char pceDev;
|
static const char *const menuOptionspceFlash[] PROGMEM = { menuOptionspceFlash1, FSTRING_RESET };
|
||||||
// Copy menuOptions out of progmem
|
#endif
|
||||||
convertPgm(menuOptionspce, 3);
|
|
||||||
pceDev = question_box(F("Select device"), menuOptions, 3, 0);
|
// PCE start menu, first a device type is selected and set in pce_internal_mode
|
||||||
|
void pcsMenu(void) {
|
||||||
|
unsigned char pceDev;
|
||||||
|
convertPgm(menuOptionspce, 4);
|
||||||
|
pceDev = question_box(F("Select device"), menuOptions, 4, 0);
|
||||||
|
|
||||||
// wait for user choice to come back from the question box menu
|
|
||||||
switch (pceDev) {
|
switch (pceDev) {
|
||||||
case 0:
|
case 0:
|
||||||
//Hucard
|
//Hucard
|
||||||
@ -103,9 +108,23 @@ void pcsMenu(void) {
|
|||||||
mode = CORE_PCE;
|
mode = CORE_PCE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef ENABLE_FLASH
|
||||||
case 3:
|
case 3:
|
||||||
|
//Flash Repro
|
||||||
|
display_Clear();
|
||||||
|
display_Update();
|
||||||
|
pce_internal_mode = PCE_FLASH;
|
||||||
|
setup_cart_PCE();
|
||||||
|
mode = CORE_PCE;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case 4:
|
||||||
resetArduino();
|
resetArduino();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
print_MissingModule(); // does not return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +292,7 @@ void write_byte_PCE(uint32_t address, uint8_t data) {
|
|||||||
"nop\n\t");
|
"nop\n\t");
|
||||||
|
|
||||||
//Swap bit order for PC Engine HuCARD
|
//Swap bit order for PC Engine HuCARD
|
||||||
if (pce_internal_mode == HUCARD) {
|
if (pce_internal_mode == HUCARD || pce_internal_mode == PCE_FLASH) {
|
||||||
data = ((data & 0x01) << 7) | ((data & 0x02) << 5) | ((data & 0x04) << 3) | ((data & 0x08) << 1) | ((data & 0x10) >> 1) | ((data & 0x20) >> 3) | ((data & 0x40) >> 5) | ((data & 0x80) >> 7);
|
data = ((data & 0x01) << 7) | ((data & 0x02) << 5) | ((data & 0x04) << 3) | ((data & 0x08) << 1) | ((data & 0x10) >> 1) | ((data & 0x20) >> 3) | ((data & 0x40) >> 5) | ((data & 0x80) >> 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,6 +827,28 @@ void read_rom_PCE(void) {
|
|||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void flash_erase_PCE() {
|
||||||
|
display_Clear();
|
||||||
|
pin_read_write_PCE();
|
||||||
|
data_output_PCE();
|
||||||
|
PORTH |= (1 << 3); // RD HIGH
|
||||||
|
write_byte_PCE(0x5555, 0xAA);
|
||||||
|
write_byte_PCE(0x2AAA, 0x55);
|
||||||
|
write_byte_PCE(0x5555, 0x80);
|
||||||
|
write_byte_PCE(0x5555, 0xAA);
|
||||||
|
write_byte_PCE(0x2AAA, 0x55);
|
||||||
|
write_byte_PCE(0x5555, 0x10);
|
||||||
|
// TSCE = 100ms
|
||||||
|
delay(100);
|
||||||
|
|
||||||
|
pin_init_PCE();
|
||||||
|
|
||||||
|
println_Msg(FS(FSTRING_OK));
|
||||||
|
print_STR(press_button_STR, 1);
|
||||||
|
display_Update();
|
||||||
|
wait();
|
||||||
|
}
|
||||||
|
|
||||||
// PC Engine Menu
|
// PC Engine Menu
|
||||||
void pceMenu() {
|
void pceMenu() {
|
||||||
// create menu with title and 7 options to choose from
|
// create menu with title and 7 options to choose from
|
||||||
@ -861,7 +902,8 @@ void pceMenu() {
|
|||||||
resetArduino();
|
resetArduino();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else if (pce_internal_mode == TURBOCHIP) {
|
||||||
// Copy menuOptions out of progmem
|
// Copy menuOptions out of progmem
|
||||||
convertPgm(menuOptionspceTC, 2);
|
convertPgm(menuOptionspceTC, 2);
|
||||||
mainMenu = question_box(F("TG TurboChip menu"), menuOptions, 2, 0);
|
mainMenu = question_box(F("TG TurboChip menu"), menuOptions, 2, 0);
|
||||||
@ -877,6 +919,27 @@ void pceMenu() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_FLASH
|
||||||
|
else if (pce_internal_mode == PCE_FLASH) {
|
||||||
|
const int max = 2;
|
||||||
|
convertPgm(menuOptionspceFlash, max);
|
||||||
|
mainMenu = question_box(F("Flash Repro menu"), menuOptions, max, 0);
|
||||||
|
|
||||||
|
switch (mainMenu) {
|
||||||
|
case 0:
|
||||||
|
// Format/erase
|
||||||
|
flash_erase_PCE();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
resetArduino();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
print_MissingModule(); // does not return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user