From 423f8dfb196781f9f4ff5ddc47a0a494c941a945 Mon Sep 17 00:00:00 2001 From: splash5 <2173030+splash5@users.noreply.github.com> Date: Mon, 14 Oct 2019 01:26:50 +0800 Subject: [PATCH] Add some description about cartridge pinout --- Cart_Reader/WS.ino | 143 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 108 insertions(+), 35 deletions(-) diff --git a/Cart_Reader/WS.ino b/Cart_Reader/WS.ino index c9e1b45..6bf5697 100644 --- a/Cart_Reader/WS.ino +++ b/Cart_Reader/WS.ino @@ -2,14 +2,41 @@ // WonderSwan MODULE //****************************************** // WonderSwan cartridge pinout -// C40: /RST : PH0 -// C45: /CART? : PH3 (L when accessing cartridge (ROM/SRAM/PORT)) -// C42: /MMC : PH4 (access port on cartridge with both /CART and /MMC = L) -// C44: /WE : PH5 -// C43: /OE : PH6 -// C47: CLK : PE3 (384KHz on real device) -// C41: /IO? : PE4 (only use when unlocking MMC) -// C46: INT : PG5 (for RTC alarm interrupt) +// 48P 1.25mm pitch connector +// C1, C48 : GND +// C24, C25 : VDD (+3.3v) +// C16-C23 : D7-D0 +// C34-C39 : D8-D13 +// C14-C15 : D15-D14 +// C26-C29 : A(-1)-A2 +// C10-C13 : A6-A3 +// C30-C33 : A18-A15 +// C2,C3,C4,C5 : A14,A9,A10,A8 +// C6,C7,C8,C9 : A7,A12,A13,A11 +// C40 : /RST +// C41 : /IO? (only use when unlocking MMC) +// C42 : /MMC (access port on cartridge with both /CART and /MMC = L) +// C43 : /OE +// C44 : /WE +// C45 : /CART? (L when accessing cartridge (ROM/SRAM/PORT)) +// C46 : INT (for RTC alarm interrupt) +// C47 : CLK (384KHz on wonderswan) +// ------------------------------------------ +// how to connect to CartReader +// ------------------------------------------ +// /RST : PH0 +// /CART? : PH3 +// /MMC : PH4 +// /WE : PH5 +// /OE : PH6 +// CLK : PE3 +// /IO? : PE4 +// INT : PG5 +// A(-1)-A6: PF0-PF7 +// A7-A14: PK0-PK7 +// A15-A18: PL0-PL3 +// D0-D7 : PC0-PC7 +// D8-D15 : PA0-PA7 /****************************************** Menu @@ -17,8 +44,8 @@ static const char wsMenuItem1[] PROGMEM = "Read Rom"; static const char wsMenuItem2[] PROGMEM = "Read Save"; static const char wsMenuItem3[] PROGMEM = "Write Save"; -static const char wsMenuItem4[] PROGMEM = "Reset"; -static const char* const menuOptionsWS[] PROGMEM = {wsMenuItem1, wsMenuItem2, wsMenuItem3, wsMenuItem4}; +static const char wsMenuItemReset[] PROGMEM = "Reset"; +static const char* const menuOptionsWS[] PROGMEM = {wsMenuItem1, wsMenuItem2, wsMenuItem3, wsMenuItemReset}; /****************************************** * Developer Name @@ -31,6 +58,8 @@ static const char wsDevName1D[] PROGMEM = "BEC"; static const char wsDevName24[] PROGMEM = "0MN"; static const char wsDevName28[] PROGMEM = "SQR"; static const char wsDevName31[] PROGMEM = "VGD"; +static const char wsDevName7A[] PROGMEM = "7AC"; +static const char wsDevNameFF[] PROGMEM = "WWGP"; static uint8_t wsGameOrientation = 0; static uint8_t wsGameHasRTC = 0; @@ -79,8 +108,8 @@ void wsMenu() { uint8_t mainMenu; - convertPgm(menuOptionsWS, 4); - mainMenu = question_box(F("WonderSwan Menu"), menuOptions, 4, 0); + convertPgm(menuOptionsWS, 6); + mainMenu = question_box(F("WonderSwan Menu"), menuOptions, 6, 0); switch (mainMenu) { @@ -139,7 +168,7 @@ void wsMenu() } println_Msg(F("")); - println_Msg(F("Press Button...")); + println_Msg(F("Press Button...")); display_Update(); wait(); @@ -183,21 +212,20 @@ uint8_t getCartInfo_WS() // developerId/cartId/checksum are all filled with 0x00 in wonderwitch based games if (readWord_WS(0xf0000) == 0x4c45 && readWord_WS(0xf0002) == 0x5349 && readWord_WS(0xf0004) == 0x0041) { - // looking for "> 8) & 0xff; + PORTL = (addr >> 16) & 0x0f; + + PORTC = data; + + // switch CART(PH3) and WE(PH5) to LOW + PORTH &= ~((1 << 3) | (1 << 5)); + NOP; + + // switch CART(PH3) and WE(PH5) to HIGH + PORTH |= (1 << 3) | (1 << 5); + NOP; NOP; +} + +uint8_t readByte_WS(uint32_t addr) +{ + PORTF = addr & 0xff; + PORTK = (addr >> 8) & 0xff; + PORTL = (addr >> 16) & 0x0f; + + // switch CART(PH3) and OE(PH6) to LOW + PORTH &= ~((1 << 3) | (1 << 6)); + NOP; NOP; NOP; + + uint8_t ret = PINC; + + // switch CART(PH3) and OE(PH6) to HIGH + PORTH |= (1 << 3) | (1 << 6); + + return ret; +} + void unprotectEEPROM() { generateEepromInstruction_WS(wsEepromShiftReg, 0x0, 0x3);