mirror of https://github.com/mgba-emu/mgba.git
GBA SIO: Allow seamless mode switching if driver supports it
This commit is contained in:
parent
ab655db3f8
commit
914d879811
|
@ -60,16 +60,24 @@ static void _switchMode(struct GBASIO* sio) {
|
||||||
newMode = (enum GBASIOMode) (mode & 0xC);
|
newMode = (enum GBASIOMode) (mode & 0xC);
|
||||||
}
|
}
|
||||||
if (newMode != sio->mode) {
|
if (newMode != sio->mode) {
|
||||||
if (sio->activeDriver && sio->activeDriver->unload) {
|
struct GBASIODriver* driver = _lookupDriver(sio, newMode);
|
||||||
sio->activeDriver->unload(sio->activeDriver);
|
|
||||||
}
|
|
||||||
if (sio->mode != (enum GBASIOMode) -1) {
|
if (sio->mode != (enum GBASIOMode) -1) {
|
||||||
mLOG(GBA_SIO, DEBUG, "Switching mode from %s to %s", _modeName(sio->mode), _modeName(newMode));
|
mLOG(GBA_SIO, DEBUG, "Switching mode from %s to %s", _modeName(sio->mode), _modeName(newMode));
|
||||||
}
|
}
|
||||||
sio->mode = newMode;
|
if (driver != sio->activeDriver || (driver && !driver->setMode)) {
|
||||||
sio->activeDriver = _lookupDriver(sio, sio->mode);
|
if (sio->activeDriver && sio->activeDriver->unload) {
|
||||||
if (sio->activeDriver && sio->activeDriver->load) {
|
sio->activeDriver->unload(sio->activeDriver);
|
||||||
sio->activeDriver->load(sio->activeDriver);
|
}
|
||||||
|
sio->mode = newMode;
|
||||||
|
sio->activeDriver = driver;
|
||||||
|
if (sio->activeDriver && sio->activeDriver->load) {
|
||||||
|
sio->activeDriver->load(sio->activeDriver);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sio->mode = newMode;
|
||||||
|
if (sio->activeDriver && sio->activeDriver->setMode) {
|
||||||
|
sio->activeDriver->setMode(sio->activeDriver, newMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
|
@ -15,7 +15,6 @@ static bool GBASIOLockstepNodeInit(struct GBASIODriver* driver);
|
||||||
static void GBASIOLockstepNodeDeinit(struct GBASIODriver* driver);
|
static void GBASIOLockstepNodeDeinit(struct GBASIODriver* driver);
|
||||||
static bool GBASIOLockstepNodeLoad(struct GBASIODriver* driver);
|
static bool GBASIOLockstepNodeLoad(struct GBASIODriver* driver);
|
||||||
static bool GBASIOLockstepNodeUnload(struct GBASIODriver* driver);
|
static bool GBASIOLockstepNodeUnload(struct GBASIODriver* driver);
|
||||||
static void GBASIOLockstepNodeSetMode(struct GBASIODriver* driver, enum GBASIOMode mode);
|
|
||||||
static bool GBASIOLockstepNodeHandlesMode(struct GBASIODriver* driver, enum GBASIOMode mode);
|
static bool GBASIOLockstepNodeHandlesMode(struct GBASIODriver* driver, enum GBASIOMode mode);
|
||||||
static int GBASIOLockstepNodeConnectedDevices(struct GBASIODriver* driver);
|
static int GBASIOLockstepNodeConnectedDevices(struct GBASIODriver* driver);
|
||||||
static int GBASIOLockstepNodeDeviceId(struct GBASIODriver* driver);
|
static int GBASIOLockstepNodeDeviceId(struct GBASIODriver* driver);
|
||||||
|
@ -42,7 +41,7 @@ void GBASIOLockstepNodeCreate(struct GBASIOLockstepNode* node) {
|
||||||
node->d.deinit = GBASIOLockstepNodeDeinit;
|
node->d.deinit = GBASIOLockstepNodeDeinit;
|
||||||
node->d.load = GBASIOLockstepNodeLoad;
|
node->d.load = GBASIOLockstepNodeLoad;
|
||||||
node->d.unload = GBASIOLockstepNodeUnload;
|
node->d.unload = GBASIOLockstepNodeUnload;
|
||||||
node->d.setMode = GBASIOLockstepNodeSetMode;
|
node->d.setMode = NULL;
|
||||||
node->d.handlesMode = GBASIOLockstepNodeHandlesMode;
|
node->d.handlesMode = GBASIOLockstepNodeHandlesMode;
|
||||||
node->d.connectedDevices = GBASIOLockstepNodeConnectedDevices;
|
node->d.connectedDevices = GBASIOLockstepNodeConnectedDevices;
|
||||||
node->d.deviceId = GBASIOLockstepNodeDeviceId;
|
node->d.deviceId = GBASIOLockstepNodeDeviceId;
|
||||||
|
@ -190,13 +189,6 @@ bool GBASIOLockstepNodeUnload(struct GBASIODriver* driver) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GBASIOLockstepNodeSetMode(struct GBASIODriver* driver, enum GBASIOMode mode) {
|
|
||||||
struct GBASIOLockstepNode* node = (struct GBASIOLockstepNode*) driver;
|
|
||||||
mLockstepLock(&node->p->d);
|
|
||||||
node->mode = mode;
|
|
||||||
mLockstepUnlock(&node->p->d);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool GBASIOLockstepNodeHandlesMode(struct GBASIODriver* driver, enum GBASIOMode mode) {
|
static bool GBASIOLockstepNodeHandlesMode(struct GBASIODriver* driver, enum GBASIOMode mode) {
|
||||||
UNUSED(driver);
|
UNUSED(driver);
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|
Loading…
Reference in New Issue