Try to correct light sensor too

This commit is contained in:
CasualPokePlayer 2025-04-16 23:15:08 -07:00
parent f5586ca079
commit c319aeb803
1 changed files with 2 additions and 1 deletions

View File

@ -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);
}