GBA SIO: Add writeRCNT callback, mostly for GPIO mode

This commit is contained in:
Vicki Pfau 2024-05-22 22:42:58 -07:00
parent 5da4b1fc4d
commit aad552ff47
6 changed files with 9 additions and 8 deletions

View File

@ -118,6 +118,7 @@ struct GBASIODriver {
int (*connectedDevices)(struct GBASIODriver* driver);
int (*deviceId)(struct GBASIODriver* driver);
uint16_t (*writeSIOCNT)(struct GBASIODriver* driver, uint16_t value);
uint16_t (*writeRCNT)(struct GBASIODriver* driver, uint16_t value);
};
enum GBASIOBattleChipGateFlavor {

View File

@ -51,6 +51,7 @@ void GBASIOBattlechipGateCreate(struct GBASIOBattlechipGate* gate) {
gate->d.handlesMode = GBASIOBattlechipGateHandlesMode;
gate->d.connectedDevices = GBASIOBattlechipGateConnectedDevices;
gate->d.deviceId = NULL;
gate->d.writeRCNT = NULL;
gate->event.context = gate;
gate->event.callback = _battlechipTransferEvent;

View File

@ -193,6 +193,10 @@ void GBASIOWriteRCNT(struct GBASIO* sio, uint16_t value) {
sio->rcnt &= 0xF;
sio->rcnt |= value & ~0xF;
_switchMode(sio);
if (sio->activeDriver && sio->activeDriver->writeRCNT) {
sio->rcnt &= 0xC000;
sio->rcnt |= sio->activeDriver->writeRCNT(sio->activeDriver, value) & 0x01FF;
}
}
void GBASIOWriteSIOCNT(struct GBASIO* sio, uint16_t value) {
@ -278,8 +282,6 @@ uint16_t GBASIOWriteRegister(struct GBASIO* sio, uint32_t address, uint16_t valu
default:
mLOG(GBA_SIO, DEBUG, "JOY write: Unknown reg %03X <- %04X", address, value);
break;
case GBA_REG_RCNT:
break;
}
break;
case GBA_SIO_NORMAL_8:
@ -290,8 +292,6 @@ uint16_t GBASIOWriteRegister(struct GBASIO* sio, uint32_t address, uint16_t valu
default:
mLOG(GBA_SIO, DEBUG, "NORMAL8 %i write: Unknown reg %03X <- %04X", id, address, value);
break;
case GBA_REG_RCNT:
break;
}
break;
case GBA_SIO_NORMAL_32:
@ -305,8 +305,6 @@ uint16_t GBASIOWriteRegister(struct GBASIO* sio, uint32_t address, uint16_t valu
default:
mLOG(GBA_SIO, DEBUG, "NORMAL32 %i write: Unknown reg %03X <- %04X", id, address, value);
break;
case GBA_REG_RCNT:
break;
}
break;
case GBA_SIO_MULTI:
@ -317,8 +315,6 @@ uint16_t GBASIOWriteRegister(struct GBASIO* sio, uint32_t address, uint16_t valu
default:
mLOG(GBA_SIO, DEBUG, "MULTI %i write: Unknown reg %03X <- %04X", id, address, value);
break;
case GBA_REG_RCNT:
break;
}
break;
default:

View File

@ -41,6 +41,7 @@ void GBASIODolphinCreate(struct GBASIODolphin* dol) {
dol->d.handlesMode = GBASIODolphinHandlesMode;
dol->d.connectedDevices = GBASIODolphinConnectedDevices;
dol->d.deviceId = NULL;
dol->d.writeSIOCNT = NULL;
dol->event.context = dol;
dol->event.name = "GB SIO Lockstep";
dol->event.callback = GBASIODolphinProcessEvents;

View File

@ -54,6 +54,7 @@ void GBASIOPlayerInit(struct GBASIOPlayer* gbp) {
gbp->d.handlesMode = _gbpSioHandlesMode;
gbp->d.connectedDevices = _gbpSioConnectedDevices;
gbp->d.deviceId = NULL;
gbp->d.writeRCNT = NULL;
gbp->event.context = gbp;
gbp->event.name = "GBA SIO Game Boy Player";
gbp->event.callback = _gbpSioProcessEvents;

View File

@ -47,6 +47,7 @@ void GBASIOLockstepNodeCreate(struct GBASIOLockstepNode* node) {
node->d.connectedDevices = GBASIOLockstepNodeConnectedDevices;
node->d.deviceId = GBASIOLockstepNodeDeviceId;
node->d.writeSIOCNT = NULL;
node->d.writeRCNT = NULL;
}
bool GBASIOLockstepAttachNode(struct GBASIOLockstep* lockstep, struct GBASIOLockstepNode* node) {