all repos — mgba @ a6e747add45fc8fd3b959d647634bee1f8dee0b1

mGBA Game Boy Advance Emulator

GBA SIO: Improve logging
Vicki Pfau vi@endrift.com
Fri, 12 Mar 2021 04:37:48 -0800
commit

a6e747add45fc8fd3b959d647634bee1f8dee0b1

parent

3a95b30d631fcbce31207d3e7d47924d0a0c1031

2 files changed, 31 insertions(+), 0 deletions(-)

jump to
M src/gba/sio.csrc/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.csrc/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; }