GBA SIO: Improve logging
Vicki Pfau vi@endrift.com
Fri, 12 Mar 2021 04:37:48 -0800
2 files changed,
31 insertions(+),
0 deletions(-)
M
src/gba/sio.c
→
src/gba/sio.c
@@ -31,6 +31,23 @@ return 0;
} } +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 @@ if (newMode != sio->mode) {
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) {
M
src/gba/sio/joybus.c
→
src/gba/sio/joybus.c
@@ -21,9 +21,22 @@
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; }