This commit is contained in:
splash5 2019-10-11 21:15:59 +08:00
parent 1771104fe5
commit 5c1d28a0d6
2 changed files with 21 additions and 6 deletions

View File

@ -154,6 +154,7 @@ typedef enum COLOR_T {
#define mode_GB_GBSmart 18 #define mode_GB_GBSmart 18
#define mode_GB_GBSmart_Flash 19 #define mode_GB_GBSmart_Flash 19
#define mode_GB_GBSmart_Game 20 #define mode_GB_GBSmart_Game 20
#define mode_WS 21
// optimization-safe nop delay // optimization-safe nop delay
#define NOP __asm__ __volatile__ ("nop\n\t") #define NOP __asm__ __volatile__ ("nop\n\t")
@ -381,8 +382,9 @@ static const char addonsItem1[] PROGMEM = "NES/Famicom";
static const char addonsItem2[] PROGMEM = "Flashrom Programmer"; static const char addonsItem2[] PROGMEM = "Flashrom Programmer";
static const char addonsItem3[] PROGMEM = "PC Engine/TG16"; static const char addonsItem3[] PROGMEM = "PC Engine/TG16";
static const char addonsItem4[] PROGMEM = "Sega Master System"; static const char addonsItem4[] PROGMEM = "Sega Master System";
static const char addonsItem6[] PROGMEM = "WonderSwan";
static const char addonsItem5[] PROGMEM = "Reset"; static const char addonsItem5[] PROGMEM = "Reset";
static const char* const addonsOptions[] PROGMEM = {addonsItem1, addonsItem2, addonsItem3, addonsItem4, addonsItem5}; static const char* const addonsOptions[] PROGMEM = {addonsItem1, addonsItem2, addonsItem3, addonsItem4, addonsItem6, addonsItem5};
// Info Screen // Info Screen
void aboutScreen() { void aboutScreen() {
@ -480,8 +482,8 @@ void addonsMenu() {
// create menu with title and 5 options to choose from // create menu with title and 5 options to choose from
unsigned char addonsMenu; unsigned char addonsMenu;
// Copy menuOptions out of progmem // Copy menuOptions out of progmem
convertPgm(addonsOptions, 5); convertPgm(addonsOptions, 6);
addonsMenu = question_box(F("Choose Adapter"), menuOptions, 5, 0); addonsMenu = question_box(F("Choose Adapter"), menuOptions, 6, 0);
// wait for user choice to come back from the question box menu // wait for user choice to come back from the question box menu
switch (addonsMenu) switch (addonsMenu)
@ -503,6 +505,10 @@ void addonsMenu() {
break; break;
case 4: case 4:
setup_WS();
break;
default:
resetArduino(); resetArduino();
break; break;
} }
@ -1500,6 +1506,9 @@ void loop() {
else if (mode == mode_GB_GBSmart_Game) { else if (mode == mode_GB_GBSmart_Game) {
gbSmartGameOptions(); gbSmartGameOptions();
} }
else if (mode == mode_WS) {
wsMenu();
}
else { else {
display_Clear(); display_Clear();
println_Msg(F("Menu Error")); println_Msg(F("Menu Error"));

View File

@ -4,10 +4,10 @@
// WonderSwan cartridge pinout // WonderSwan cartridge pinout
// C40: /RST : PH0 // C40: /RST : PH0
// C45: /CART? : PH3 (L when accessing cartridge (ROM/SRAM/PORT)) // C45: /CART? : PH3 (L when accessing cartridge (ROM/SRAM/PORT))
// C42: /MMC : PH4 (access port on cartridge when both /CART and /MMC = L) // C42: /MMC : PH4 (access port on cartridge with both /CART and /MMC = L)
// C44: /WE : PH5 // C44: /WE : PH5
// C43: /OE : PH6 // C43: /OE : PH6
// C47: CLK : PE3 (384KHz in real device) // C47: CLK : PE3 (384KHz on real device)
// C41: /IO? : PE4 // C41: /IO? : PE4
// C46: INT : PG5 (for RTC alarm interrupt) // C46: INT : PG5 (for RTC alarm interrupt)
@ -267,6 +267,7 @@ void readROM_WS(char *outPathBuf, size_t bufferSize)
dataIn_WS(); dataIn_WS();
for (uint32_t addr = 0; addr < 0x10000; addr += 512) for (uint32_t addr = 0; addr < 0x10000; addr += 512)
{ {
// blink LED
if ((addr & ((1 << 14) - 1)) == 0) if ((addr & ((1 << 14) - 1)) == 0)
PORTB ^= (1 << 4); PORTB ^= (1 << 4);
@ -319,6 +320,7 @@ void readSRAM_WS()
dataIn_WS(); dataIn_WS();
for (uint32_t addr = 0; addr < bank_size; addr += 512) for (uint32_t addr = 0; addr < bank_size; addr += 512)
{ {
// blink LED
if ((addr & ((1 << 14) - 1)) == 0) if ((addr & ((1 << 14) - 1)) == 0)
PORTB ^= (1 << 4); PORTB ^= (1 << 4);
@ -419,6 +421,7 @@ void writeSRAM_WS()
for (uint32_t addr = 0; addr < bank_size && myFile.available(); addr += 512) for (uint32_t addr = 0; addr < bank_size && myFile.available(); addr += 512)
{ {
// blink LED
if ((addr & ((1 << 14) - 1)) == 0) if ((addr & ((1 << 14) - 1)) == 0)
PORTB ^= (1 << 4); PORTB ^= (1 << 4);
@ -471,6 +474,7 @@ void readEEPROM_WS()
{ {
for (uint32_t j = 0; j < bufSize; j += 2) for (uint32_t j = 0; j < bufSize; j += 2)
{ {
// blink LED
if ((j & 0x1f) == 0x00) if ((j & 0x1f) == 0x00)
PORTB ^= (1 << 4); PORTB ^= (1 << 4);
@ -514,6 +518,7 @@ void verifyEEPROM_WS()
for (uint32_t j = 0; j < bufSize; j += 2) for (uint32_t j = 0; j < bufSize; j += 2)
{ {
// blink LED
if ((j & 0x1f) == 0x00) if ((j & 0x1f) == 0x00)
PORTB ^= (1 << 4); PORTB ^= (1 << 4);
@ -582,6 +587,7 @@ void writeEEPROM_WS()
for (uint32_t j = 0; j < bufSize; j += 2) for (uint32_t j = 0; j < bufSize; j += 2)
{ {
// blink LED
if ((j & 0x1f) == 0x00) if ((j & 0x1f) == 0x00)
PORTB ^= (1 << 4); PORTB ^= (1 << 4);
@ -764,7 +770,7 @@ void unprotectEEPROM()
} }
// generate data for port 0xc4 to 0xc8 // generate data for port 0xc4 to 0xc8
// return value is number of CLKs need to pulse // number of CLK pulses needed for each instruction is 1 + (16/32) + 2
void generateEepromInstruction_WS(uint8_t *instruction, uint8_t opcode, uint16_t addr, uint8_t l_data, uint8_t h_data) void generateEepromInstruction_WS(uint8_t *instruction, uint8_t opcode, uint16_t addr, uint8_t l_data, uint8_t h_data)
{ {
uint32_t *ptr = (uint32_t*)instruction; uint32_t *ptr = (uint32_t*)instruction;