diff --git a/include/mgba/gba/interface.h b/include/mgba/gba/interface.h index 9b8f6e001..cbbb4d23a 100644 --- a/include/mgba/gba/interface.h +++ b/include/mgba/gba/interface.h @@ -81,7 +81,7 @@ extern MGBA_EXPORT const int GBA_LUX_LEVELS[10]; enum { mPERIPH_GBA_LUMINANCE = 0x1000, - mPERIPH_GBA_BATTLECHIP_GATE, + mPERIPH_GBA_LINK_PORT, }; struct GBACartridgeOverride { diff --git a/src/gba/core.c b/src/gba/core.c index 898745e9e..67550bd7a 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -962,7 +962,7 @@ static void _GBACoreSetPeripheral(struct mCore* core, int type, void* periph) { case mPERIPH_GBA_LUMINANCE: gba->luminanceSource = periph; break; - case mPERIPH_GBA_BATTLECHIP_GATE: + case mPERIPH_GBA_LINK_PORT: GBASIOSetDriver(&gba->sio, periph); break; default: diff --git a/src/platform/qt/CoreController.cpp b/src/platform/qt/CoreController.cpp index 032bdbc4f..807a86685 100644 --- a/src/platform/qt/CoreController.cpp +++ b/src/platform/qt/CoreController.cpp @@ -423,8 +423,8 @@ bool CoreController::attachDolphin(const Address& address) { return false; } if (GBASIODolphinConnect(&m_dolphin, &address, 0, 0)) { - GBA* gba = static_cast(m_threadContext.core->board); - GBASIOSetDriver(&gba->sio, &m_dolphin.d); + clearMultiplayerController(); + m_threadContext.core->setPeripheral(m_threadContext.core, mPERIPH_GBA_LINK_PORT, &m_dolphin.d); return true; } return false; @@ -432,9 +432,8 @@ bool CoreController::attachDolphin(const Address& address) { void CoreController::detachDolphin() { if (platform() == mPLATFORM_GBA) { - GBA* gba = static_cast(m_threadContext.core->board); // TODO: Reattach to multiplayer controller - GBASIOSetDriver(&gba->sio, nullptr); + m_threadContext.core->setPeripheral(m_threadContext.core, mPERIPH_GBA_LINK_PORT, NULL); } GBASIODolphinDestroy(&m_dolphin); } @@ -1095,7 +1094,7 @@ void CoreController::attachBattleChipGate() { Interrupter interrupter(this); clearMultiplayerController(); GBASIOBattlechipGateCreate(&m_battlechip); - m_threadContext.core->setPeripheral(m_threadContext.core, mPERIPH_GBA_BATTLECHIP_GATE, &m_battlechip); + m_threadContext.core->setPeripheral(m_threadContext.core, mPERIPH_GBA_LINK_PORT, &m_battlechip); } void CoreController::detachBattleChipGate() { @@ -1103,7 +1102,7 @@ void CoreController::detachBattleChipGate() { return; } Interrupter interrupter(this); - m_threadContext.core->setPeripheral(m_threadContext.core, mPERIPH_GBA_BATTLECHIP_GATE, nullptr); + m_threadContext.core->setPeripheral(m_threadContext.core, mPERIPH_GBA_LINK_PORT, nullptr); } void CoreController::setBattleChipId(uint16_t id) { diff --git a/src/platform/qt/MultiplayerController.cpp b/src/platform/qt/MultiplayerController.cpp index 0d12359bb..5839b0f84 100644 --- a/src/platform/qt/MultiplayerController.cpp +++ b/src/platform/qt/MultiplayerController.cpp @@ -327,9 +327,9 @@ bool MultiplayerController::attachGame(CoreController* controller) { if (player.attached) { continue; } - GBA* gba = static_cast(player.controller->thread()->core->board); + struct mCore* core = player.controller->thread()->core; GBASIOLockstepCoordinatorAttach(&m_gbaCoordinator, player.node.gba); - GBASIOSetDriver(&gba->sio, &player.node.gba->d); + core->setPeripheral(core, mPERIPH_GBA_LINK_PORT, &player.node.gba->d); player.attached = true; } } @@ -371,7 +371,7 @@ void MultiplayerController::detachGame(CoreController* controller) { Player& p = m_pids.find(pid).value(); GBASIODriver* node = gba->sio.driver; if (node == &p.node.gba->d) { - GBASIOSetDriver(&gba->sio, nullptr); + thread->core->setPeripheral(thread->core, mPERIPH_GBA_LINK_PORT, NULL); } if (p.attached) { GBASIOLockstepCoordinatorDetach(&m_gbaCoordinator, p.node.gba);