From 5b58c011be68d239ed69daaa29e5a1d01a3bcc1c Mon Sep 17 00:00:00 2001 From: Persune <54422576+Gumball2415@users.noreply.github.com> Date: Sun, 15 Aug 2021 00:22:20 +0800 Subject: [PATCH] Refactor code --- Core/Console.cpp | 3 +-- Core/ControlManager.cpp | 5 +++-- Core/ControlManager.h | 4 ++-- Core/PPU.cpp | 2 +- Core/SoundMixer.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Core/Console.cpp b/Core/Console.cpp index 68b54b7d..ee61be78 100644 --- a/Core/Console.cpp +++ b/Core/Console.cpp @@ -476,8 +476,7 @@ void Console::ProcessInterferenceAudio() _InvA13 = _ppu->_A13pinLowSum; _ppu->_A13pinLowSum = 0; - _controlManager->GetInvOE1(_controlManager->_address); - _InvOE1 = (_controlManager->_OE1pinLow == 1) ? 0 : 1; // invert relative to 2A03 + _InvOE1 = !_controlManager->GetInvOE1(_controlManager->_address); // invert relative to 2A03 if (_controlManager->_strobed == true) _controlManager->_strobed = false; diff --git a/Core/ControlManager.cpp b/Core/ControlManager.cpp index 9e80e937..bc5045ef 100644 --- a/Core/ControlManager.cpp +++ b/Core/ControlManager.cpp @@ -351,11 +351,12 @@ void ControlManager::WriteRAM(uint16_t addr, uint8_t value) } } -void ControlManager::GetInvOE1(uint16_t addr) +bool ControlManager::GetInvOE1(uint16_t addr) { // pull low for only one clock if (addr == 0x4016) - _OE1pinLow = (_strobed) ? 0 : 1; + _OE1pinLow = !_strobed; + return _OE1pinLow; } void ControlManager::Reset(bool softReset) diff --git a/Core/ControlManager.h b/Core/ControlManager.h index 976ecb9e..1b590734 100644 --- a/Core/ControlManager.h +++ b/Core/ControlManager.h @@ -43,7 +43,7 @@ protected: virtual uint8_t GetOpenBusMask(uint8_t port); public: - uint8_t _OE1pinLow; + bool _OE1pinLow; uint16_t _address; bool _strobed; @@ -85,5 +85,5 @@ public: virtual uint8_t ReadRAM(uint16_t addr) override; virtual void WriteRAM(uint16_t addr, uint8_t value) override; - void GetInvOE1(uint16_t addr); + bool GetInvOE1(uint16_t addr); }; diff --git a/Core/PPU.cpp b/Core/PPU.cpp index 5edbdd9c..1ee1d1bb 100644 --- a/Core/PPU.cpp +++ b/Core/PPU.cpp @@ -466,7 +466,7 @@ void PPU::WriteRAM(uint16_t addr, uint8_t value) void PPU::GetInvA13() { // pull level high when PPU/VRAM addr bit 13 is low - _A13pinLowSum += (_ppuBusAddress & 0x2000) ? 1 : 0; // invert relative to 2A03 + _A13pinLowSum += (bool)(_ppuBusAddress & 0x2000); // invert relative to 2A03 } uint8_t PPU::ReadPaletteRAM(uint16_t addr) diff --git a/Core/SoundMixer.cpp b/Core/SoundMixer.cpp index 186e62da..854e2cda 100644 --- a/Core/SoundMixer.cpp +++ b/Core/SoundMixer.cpp @@ -278,7 +278,7 @@ int16_t SoundMixer::GetOutputVolume(bool forRightChannel) GetChannelOutput(AudioChannel::EPSM_L, forRightChannel) * 4 + GetChannelOutput(AudioChannel::EPSM_R, forRightChannel) * 4 + (GetChannelOutput(AudioChannel::InvA13, forRightChannel) * 20) / 3.0 + // 3 PPU samples per CPU clock - GetChannelOutput(AudioChannel::InvOE1, forRightChannel) * 1000 + GetChannelOutput(AudioChannel::InvOE1, forRightChannel) * 100 ); }