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 <RSDuck@users.noreply.github.com>
This commit is contained in:
Jesse Talavera 2024-10-29 20:10:32 -04:00 committed by GitHub
parent 7a4255b732
commit 3877a8e46b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -582,6 +582,11 @@ int CartGameSolarSensor::SetInput(int num, bool pressed)
return -1; return -1;
} }
void CartGameSolarSensor::SetLightLevel(u8 level) noexcept
{
LightLevel = std::clamp<u8>(level, 0, 10);
}
void CartGameSolarSensor::ProcessGPIO() void CartGameSolarSensor::ProcessGPIO()
{ {
if (GPIO.data & 4) return; // Boktai chip select if (GPIO.data & 4) return; // Boktai chip select

View File

@ -158,6 +158,8 @@ public:
void DoSavestate(Savestate* file) override; void DoSavestate(Savestate* file) override;
int SetInput(int num, bool pressed) override; int SetInput(int num, bool pressed) override;
void SetLightLevel(u8 level) noexcept;
[[nodiscard]] u8 GetLightLevel() const noexcept { return LightLevel; }
protected: protected:
void ProcessGPIO() override; void ProcessGPIO() override;