diff --git a/src/gba/sio.c b/src/gba/sio.c index 363c431cc..84f4962ed 100644 --- a/src/gba/sio.c +++ b/src/gba/sio.c @@ -31,6 +31,23 @@ static struct GBASIODriver* _lookupDriver(struct GBASIO* sio, enum GBASIOMode mo } } +static const char* _modeName(enum GBASIOMode mode) { + switch (mode) { + case SIO_NORMAL_8: + return "NORMAL8"; + case SIO_NORMAL_32: + return "NORMAL32"; + case SIO_MULTI: + return "MULTI"; + case SIO_JOYBUS: + return "JOYBUS"; + case SIO_GPIO: + return "GPIO"; + default: + return "(unknown)"; + } +} + static void _switchMode(struct GBASIO* sio) { unsigned mode = ((sio->rcnt & 0xC000) | (sio->siocnt & 0x3000)) >> 12; enum GBASIOMode newMode; @@ -43,6 +60,7 @@ static void _switchMode(struct GBASIO* sio) { if (sio->activeDriver && sio->activeDriver->unload) { sio->activeDriver->unload(sio->activeDriver); } + mLOG(GBA_SIO, DEBUG, "Switching mode from %s to %s", _modeName(sio->mode), _modeName(newMode)); sio->mode = newMode; sio->activeDriver = _lookupDriver(sio, sio->mode); if (sio->activeDriver && sio->activeDriver->load) { diff --git a/src/gba/sio/joybus.c b/src/gba/sio/joybus.c index c5a339883..7b4f9e207 100644 --- a/src/gba/sio/joybus.c +++ b/src/gba/sio/joybus.c @@ -21,9 +21,22 @@ void GBASIOJOYCreate(struct GBASIODriver* sio) { uint16_t GBASIOJOYWriteRegister(struct GBASIODriver* sio, uint32_t address, uint16_t value) { switch (address) { case REG_JOYCNT: + mLOG(GBA_SIO, DEBUG, "JOY write: CNT <- %04X", value); return (value & 0x0040) | (sio->p->p->memory.io[REG_JOYCNT >> 1] & ~(value & 0x7) & ~0x0040); case REG_JOYSTAT: + mLOG(GBA_SIO, DEBUG, "JOY write: STAT <- %04X", value); return (value & 0x0030) | (sio->p->p->memory.io[REG_JOYSTAT >> 1] & ~0x30); + case REG_JOY_TRANS_LO: + mLOG(GBA_SIO, DEBUG, "JOY write: TRANS_LO <- %04X", value); + break; + case REG_JOY_TRANS_HI: + mLOG(GBA_SIO, DEBUG, "JOY write: TRANS_HI <- %04X", value); + break; + default: + mLOG(GBA_SIO, DEBUG, "JOY write: Unknown reg %03X <- %04X", address, value); + // Fall through + case REG_RCNT: + break; } return value; }