From c319aeb8034fc29a2dee311748e5d93f3b1b9a0d Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Wed, 16 Apr 2025 23:15:08 -0700 Subject: [PATCH] Try to correct light sensor too --- src/gba/cart/gpio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gba/cart/gpio.c b/src/gba/cart/gpio.c index 6248fba23..2371fc87d 100644 --- a/src/gba/cart/gpio.c +++ b/src/gba/cart/gpio.c @@ -404,6 +404,7 @@ void _lightReadPins(struct GBACartridgeHardware* hw) { struct GBALuminanceSource* lux = hw->p->luminanceSource; mLOG(GBA_HW, DEBUG, "[SOLAR] Got reset"); hw->lightCounter = 0; + hw->lightEdge = true; // unverified (perhaps reset only happens on bit 1 rising edge?) if (lux) { if (lux->sample) { lux->sample(lux); @@ -419,7 +420,7 @@ void _lightReadPins(struct GBACartridgeHardware* hw) { hw->lightEdge = !(hw->pinState & 1); bool sendBit = hw->lightCounter >= hw->lightSample; - _outputPins(hw, sendBit << 3); + _outputPins(hw, (sendBit << 3) | (hw->pinState & 0x7)); mLOG(GBA_HW, DEBUG, "[SOLAR] Output %u with pins %u", hw->lightCounter, hw->pinState); }