From 5c9d5d9ddf92ece61614d3c0c5e1b92c14b604bd Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 1 Mar 2015 21:54:22 -0800 Subject: [PATCH] GBA SIO: Add bits for JOY connections --- src/gba/bios.c | 4 ++-- src/gba/io.c | 17 +++++++++++++---- src/gba/io.h | 6 ++++-- src/gba/sio.c | 5 +++-- src/gba/sio.h | 2 +- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/gba/bios.c b/src/gba/bios.c index 42f7512e2..bcfb6b7ce 100644 --- a/src/gba/bios.c +++ b/src/gba/bios.c @@ -70,8 +70,8 @@ static void _RegisterRamReset(struct GBA* gba) { cpu->memory.store16(cpu, BASE_IO | REG_RCNT, RCNT_INITIAL, 0); cpu->memory.store16(cpu, BASE_IO | REG_SIOMLT_SEND, 0, 0); cpu->memory.store16(cpu, BASE_IO | REG_JOYCNT, 0, 0); - cpu->memory.store32(cpu, BASE_IO | REG_JOY_RECV, 0, 0); - cpu->memory.store32(cpu, BASE_IO | REG_JOY_TRANS, 0, 0); + cpu->memory.store32(cpu, BASE_IO | REG_JOY_RECV_LO, 0, 0); + cpu->memory.store32(cpu, BASE_IO | REG_JOY_TRANS_LO, 0, 0); } if (registers & 0x40) { cpu->memory.store16(cpu, BASE_IO | REG_SOUND1CNT_LO, 0, 0); diff --git a/src/gba/io.c b/src/gba/io.c index f5ce85466..ec340bf90 100644 --- a/src/gba/io.c +++ b/src/gba/io.c @@ -515,7 +515,13 @@ void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) { GBASIOWriteRCNT(&gba->sio, value); break; case REG_SIOMLT_SEND: - GBASIOWriteSIOMLT_SEND(&gba->sio, value); + case REG_JOYCNT: + case REG_JOYSTAT: + case REG_JOY_RECV_LO: + case REG_JOY_RECV_HI: + case REG_JOY_TRANS_LO: + case REG_JOY_TRANS_HI: + value = GBASIOWriteRegister(&gba->sio, address, value); break; // Interrupts and misc @@ -757,9 +763,6 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) { return GBALoadBad(gba->cpu); case REG_SOUNDBIAS: - case REG_JOYCNT: - case REG_JOY_RECV: - case REG_JOY_TRANS: case REG_KEYCNT: case REG_POSTFLG: mLOG(GBA_IO, STUB, "Stub I/O register read: %03x", address); @@ -814,6 +817,12 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) { case REG_SIOMULTI2: case REG_SIOMULTI3: case REG_SIOMLT_SEND: + case REG_JOYCNT: + case REG_JOY_RECV_LO: + case REG_JOY_RECV_HI: + case REG_JOY_TRANS_LO: + case REG_JOY_TRANS_HI: + case REG_JOYSTAT: case REG_IE: case REG_IF: case REG_WAITCNT: diff --git a/src/gba/io.h b/src/gba/io.h index eeb142b60..b66cc2a39 100644 --- a/src/gba/io.h +++ b/src/gba/io.h @@ -131,8 +131,10 @@ enum GBAIORegisters { REG_SIODATA8 = 0x12A, REG_RCNT = 0x134, REG_JOYCNT = 0x140, - REG_JOY_RECV = 0x150, - REG_JOY_TRANS = 0x154, + REG_JOY_RECV_LO = 0x150, + REG_JOY_RECV_HI = 0x152, + REG_JOY_TRANS_LO = 0x154, + REG_JOY_TRANS_HI = 0x156, REG_JOYSTAT = 0x158, // Keypad diff --git a/src/gba/sio.c b/src/gba/sio.c index e07380bae..bcf972c5c 100644 --- a/src/gba/sio.c +++ b/src/gba/sio.c @@ -167,10 +167,11 @@ void GBASIOWriteSIOCNT(struct GBASIO* sio, uint16_t value) { sio->siocnt = value; } -void GBASIOWriteSIOMLT_SEND(struct GBASIO* sio, uint16_t value) { +uint16_t GBASIOWriteRegister(struct GBASIO* sio, uint32_t address, uint16_t value) { if (sio->activeDriver && sio->activeDriver->writeRegister) { - sio->activeDriver->writeRegister(sio->activeDriver, REG_SIOMLT_SEND, value); + return sio->activeDriver->writeRegister(sio->activeDriver, address, value); } + return value; } int32_t GBASIOProcessEvents(struct GBASIO* sio, int32_t cycles) { diff --git a/src/gba/sio.h b/src/gba/sio.h index 57e8a820a..7110ff7bf 100644 --- a/src/gba/sio.h +++ b/src/gba/sio.h @@ -76,7 +76,7 @@ void GBASIOSetDriver(struct GBASIO* sio, struct GBASIODriver* driver, enum GBASI void GBASIOWriteRCNT(struct GBASIO* sio, uint16_t value); void GBASIOWriteSIOCNT(struct GBASIO* sio, uint16_t value); -void GBASIOWriteSIOMLT_SEND(struct GBASIO* sio, uint16_t value); +uint16_t GBASIOWriteRegister(struct GBASIO* sio, uint32_t address, uint16_t value); int32_t GBASIOProcessEvents(struct GBASIO* sio, int32_t cycles);