From 3877a8e46bf92a9c24eea21c245856c09e87ec7b Mon Sep 17 00:00:00 2001 From: Jesse Talavera Date: Tue, 29 Oct 2024 20:10:32 -0400 Subject: [PATCH] Allow `CartGameSolarSensor::LightLevel` to be set explicitly (#2179) * Allow `CartGameSolarSensor::LightLevel` to be set explicitly * Add `CartGameSolarSensor::GetLightLevel` * Update GBACart.cpp --------- Co-authored-by: Kemal Afzal --- src/GBACart.cpp | 5 +++++ src/GBACart.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/GBACart.cpp b/src/GBACart.cpp index 4fd42894..a62aca6b 100644 --- a/src/GBACart.cpp +++ b/src/GBACart.cpp @@ -582,6 +582,11 @@ int CartGameSolarSensor::SetInput(int num, bool pressed) return -1; } +void CartGameSolarSensor::SetLightLevel(u8 level) noexcept +{ + LightLevel = std::clamp(level, 0, 10); +} + void CartGameSolarSensor::ProcessGPIO() { if (GPIO.data & 4) return; // Boktai chip select diff --git a/src/GBACart.h b/src/GBACart.h index f6fb95dd..726a234d 100644 --- a/src/GBACart.h +++ b/src/GBACart.h @@ -158,6 +158,8 @@ public: void DoSavestate(Savestate* file) override; int SetInput(int num, bool pressed) override; + void SetLightLevel(u8 level) noexcept; + [[nodiscard]] u8 GetLightLevel() const noexcept { return LightLevel; } protected: void ProcessGPIO() override;