diff --git a/include/mgba/gba/interface.h b/include/mgba/gba/interface.h index 3a5412645..90f5e0697 100644 --- a/include/mgba/gba/interface.h +++ b/include/mgba/gba/interface.h @@ -28,6 +28,10 @@ struct GBAVideoRenderer; extern const int GBA_LUX_LEVELS[10]; +enum { + mPERIPH_GBA_LUMINANCE = 0x1000 +}; + struct GBALuminanceSource { void (*sample)(struct GBALuminanceSource*); diff --git a/src/feature/gui/gui-runner.c b/src/feature/gui/gui-runner.c index c26cbe662..ad59ae893 100644 --- a/src/feature/gui/gui-runner.c +++ b/src/feature/gui/gui-runner.c @@ -298,7 +298,7 @@ void mGUIRun(struct mGUIRunner* runner, const char* path) { return; } if (runner->core->platform(runner->core) == PLATFORM_GBA) { - ((struct GBA*) runner->core->board)->luminanceSource = &runner->luminanceSource.d; + runner->core->setPeripheral(runner->core, mPERIPH_GBA_LUMINANCE, &runner->luminanceSource.d); } mLOG(GUI_RUNNER, DEBUG, "Loading config..."); mCoreLoadForeignConfig(runner->core, &runner->config); diff --git a/src/gba/core.c b/src/gba/core.c index 2d653deca..4f7963cea 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -414,6 +414,9 @@ static void _GBACoreSetPeripheral(struct mCore* core, int type, void* periph) { case mPERIPH_RUMBLE: gba->rumble = periph; break; + case mPERIPH_GBA_LUMINANCE: + gba->luminanceSource = periph; + break; default: return; } diff --git a/src/platform/libretro/libretro.c b/src/platform/libretro/libretro.c index e640a91f0..d19c5006f 100644 --- a/src/platform/libretro/libretro.c +++ b/src/platform/libretro/libretro.c @@ -409,8 +409,7 @@ bool retro_load_game(const struct retro_game_info* game) { #ifdef M_CORE_GBA if (core->platform(core) == PLATFORM_GBA) { - struct GBA* gba = core->board; - gba->luminanceSource = &lux; + core->setPeripheral(core, mPERIPH_GBA_LUMINANCE, &lux); const char* sysDir = 0; if (core->opts.useBios && environCallback(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &sysDir)) { diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 7d8484b84..486c22d6e 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -99,7 +99,7 @@ GameController::GameController(QObject* parent) switch (context->core->platform(context->core)) { #ifdef M_CORE_GBA case PLATFORM_GBA: - gba->luminanceSource = &controller->m_lux; + context->core->setPeripheral(context->core, mPERIPH_GBA_LUMINANCE, &controller->m_lux); gba->audio.psg.forceDisableCh[0] = !controller->m_audioChannels[0]; gba->audio.psg.forceDisableCh[1] = !controller->m_audioChannels[1]; gba->audio.psg.forceDisableCh[2] = !controller->m_audioChannels[2];