Skip to content

Commit

Permalink
Allow CartGameSolarSensor::LightLevel to be set explicitly (#2179)
Browse files Browse the repository at this point in the history
* Allow `CartGameSolarSensor::LightLevel` to be set explicitly

* Add `CartGameSolarSensor::GetLightLevel`

* Update GBACart.cpp

---------

Co-authored-by: Kemal Afzal <[email protected]>
  • Loading branch information
JesseTG and RSDuck authored Oct 30, 2024
1 parent 7a4255b commit 3877a8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/GBACart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,11 @@ int CartGameSolarSensor::SetInput(int num, bool pressed)
return -1;
}

void CartGameSolarSensor::SetLightLevel(u8 level) noexcept
{
LightLevel = std::clamp<u8>(level, 0, 10);
}

void CartGameSolarSensor::ProcessGPIO()
{
if (GPIO.data & 4) return; // Boktai chip select
Expand Down
2 changes: 2 additions & 0 deletions src/GBACart.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ class CartGameSolarSensor : public CartGame
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;
Expand Down

0 comments on commit 3877a8e

Please sign in to comment.