From 9bfc9c08ffe88de4b54734d6fd03182c0a51e181 Mon Sep 17 00:00:00 2001 From: Jesse Talavera Date: Tue, 12 Dec 2023 05:07:22 -0500 Subject: Sprinkle `const` around where appropriate (#1909) * Sprinkle `const` around where appropriate - This will make it easier to use `NDS` objects in `const` contexts (e.g. `const` parameters or methods) * Remove the `const` qualifier on `DSi_DSP::DSPRead16` - MMIO reads can be non-pure, so this may not be `const` in the future --- src/SPI.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/SPI.h') diff --git a/src/SPI.h b/src/SPI.h index aee4165..7ed889a 100644 --- a/src/SPI.h +++ b/src/SPI.h @@ -51,7 +51,7 @@ public: virtual void Reset() = 0; virtual void DoSavestate(Savestate* file) = 0; - virtual u8 Read() { return Data; } + virtual u8 Read() const { return Data; } virtual void Write(u8 val) = 0; virtual void Release() { Hold = false; DataPos = 0; } @@ -76,7 +76,7 @@ public: Firmware& GetFirmware() noexcept { return FirmwareData; } [[nodiscard]] const Firmware& GetFirmware() const noexcept { return FirmwareData; } void SetFirmware(Firmware&& firmware) { FirmwareData = std::move(firmware); } - bool IsLoadedFirmwareBuiltIn(); + bool IsLoadedFirmwareBuiltIn() const; void Write(u8 val) override; void Release() override; @@ -89,7 +89,7 @@ private: u8 StatusReg; u32 Addr; - bool VerifyCRC16(u32 start, u32 offset, u32 len, u32 crcoffset); + bool VerifyCRC16(u32 start, u32 offset, u32 len, u32 crcoffset) const; }; class PowerMan : public SPIDevice @@ -100,7 +100,7 @@ public: void Reset() override; void DoSavestate(Savestate* file) override; - bool GetBatteryLevelOkay(); + bool GetBatteryLevelOkay() const; void SetBatteryLevelOkay(bool okay); void Write(u8 val) override; @@ -121,7 +121,7 @@ public: virtual void DoSavestate(Savestate* file) override; virtual void SetTouchCoords(u16 x, u16 y); - virtual void MicInputFrame(s16* data, int samples); + virtual void MicInputFrame(const s16* data, int samples); virtual void Write(u8 val) override; @@ -148,16 +148,18 @@ public: FirmwareMem* GetFirmwareMem() { return (FirmwareMem*)Devices[SPIDevice_FirmwareMem]; } const FirmwareMem* GetFirmwareMem() const { return (FirmwareMem*)Devices[SPIDevice_FirmwareMem]; } PowerMan* GetPowerMan() { return (PowerMan*)Devices[SPIDevice_PowerMan]; } + const PowerMan* GetPowerMan() const { return (PowerMan*)Devices[SPIDevice_PowerMan]; } TSC* GetTSC() { return (TSC*)Devices[SPIDevice_TSC]; } + const TSC* GetTSC() const { return (TSC*)Devices[SPIDevice_TSC]; } const Firmware& GetFirmware() const { return GetFirmwareMem()->GetFirmware(); } Firmware& GetFirmware() { return GetFirmwareMem()->GetFirmware(); } void SetFirmware(Firmware&& firmware) { GetFirmwareMem()->SetFirmware(std::move(firmware)); } - u16 ReadCnt() { return Cnt; } + u16 ReadCnt() const { return Cnt; } void WriteCnt(u16 val); - u8 ReadData(); + u8 ReadData() const; void WriteData(u8 val); void TransferDone(u32 param); -- cgit v1.2.3