mirror of https://github.com/mgba-emu/mgba.git
GBA SIO: Improve logging
This commit is contained in:
parent
3a95b30d63
commit
a6e747add4
|
@ -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) {
|
static void _switchMode(struct GBASIO* sio) {
|
||||||
unsigned mode = ((sio->rcnt & 0xC000) | (sio->siocnt & 0x3000)) >> 12;
|
unsigned mode = ((sio->rcnt & 0xC000) | (sio->siocnt & 0x3000)) >> 12;
|
||||||
enum GBASIOMode newMode;
|
enum GBASIOMode newMode;
|
||||||
|
@ -43,6 +60,7 @@ static void _switchMode(struct GBASIO* sio) {
|
||||||
if (sio->activeDriver && sio->activeDriver->unload) {
|
if (sio->activeDriver && sio->activeDriver->unload) {
|
||||||
sio->activeDriver->unload(sio->activeDriver);
|
sio->activeDriver->unload(sio->activeDriver);
|
||||||
}
|
}
|
||||||
|
mLOG(GBA_SIO, DEBUG, "Switching mode from %s to %s", _modeName(sio->mode), _modeName(newMode));
|
||||||
sio->mode = newMode;
|
sio->mode = newMode;
|
||||||
sio->activeDriver = _lookupDriver(sio, sio->mode);
|
sio->activeDriver = _lookupDriver(sio, sio->mode);
|
||||||
if (sio->activeDriver && sio->activeDriver->load) {
|
if (sio->activeDriver && sio->activeDriver->load) {
|
||||||
|
|
|
@ -21,9 +21,22 @@ void GBASIOJOYCreate(struct GBASIODriver* sio) {
|
||||||
uint16_t GBASIOJOYWriteRegister(struct GBASIODriver* sio, uint32_t address, uint16_t value) {
|
uint16_t GBASIOJOYWriteRegister(struct GBASIODriver* sio, uint32_t address, uint16_t value) {
|
||||||
switch (address) {
|
switch (address) {
|
||||||
case REG_JOYCNT:
|
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);
|
return (value & 0x0040) | (sio->p->p->memory.io[REG_JOYCNT >> 1] & ~(value & 0x7) & ~0x0040);
|
||||||
case REG_JOYSTAT:
|
case REG_JOYSTAT:
|
||||||
|
mLOG(GBA_SIO, DEBUG, "JOY write: STAT <- %04X", value);
|
||||||
return (value & 0x0030) | (sio->p->p->memory.io[REG_JOYSTAT >> 1] & ~0x30);
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue