diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 46d56014..c997c976 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -1,4 +1,4 @@ - + @@ -593,6 +593,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index fa3520e2..7037ac23 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -1511,6 +1511,9 @@ Nes\Mappers\EPSG + + Nes\Mappers + diff --git a/Core/EPSGAudio.h b/Core/EPSGAudio.h index 763ccea5..38b80239 100644 --- a/Core/EPSGAudio.h +++ b/Core/EPSGAudio.h @@ -56,7 +56,7 @@ private: if (_inputBuffer[cycle].wrote) { - std::cout << "DOUBLE WRITE" << std::endl; + std::cout << "EPSG CHIP DOUBLE WRITE" << std::endl; } _inputBuffer[cycle] = { @@ -121,13 +121,18 @@ protected: for (uint8_t x = 0; x < 2; x++) { - _currentOutputs[x] *= 11; + _currentOutputs[x] /= 6; } UpdateOutputLevel(); } } + virtual uint32_t GetSSGClockFrequency() + { + return EPSGSSGAudio::GetSSGClockFrequency() * (3579545.0 / _console->GetSettings()->GetEPSGClockFrequency()); + } + public: EPSGAudio(shared_ptr console) : EPSGSSGAudio(console) { @@ -138,8 +143,7 @@ public: _clock = 0; OPN2_Reset(&_chip); - OPN2_SetChipType(ym3438_mode_ym2612 | ym3438_mode_readmode); - //OPN2_SetChipType(0); + OPN2_SetChipType(0); } void WriteRegister(uint16_t addr, uint8_t value) diff --git a/Core/SSGAudio.h b/Core/SSGAudio.h index c20e12f5..b7fc3d87 100644 --- a/Core/SSGAudio.h +++ b/Core/SSGAudio.h @@ -16,6 +16,7 @@ private: int16_t _lastOutput; int16_t _timer[3]; uint8_t _toneStep[3]; + double _clock; bool _processTick; uint16_t GetPeriod(int channel) @@ -71,7 +72,7 @@ private: } } - const auto delta = (summedOutput - _lastOutput) * 15; + const auto delta = (summedOutput - _lastOutput); (_console->GetApu()->AddExpansionAudioDelta(channels, summedOutput - _lastOutput), ...); _lastOutput = summedOutput; } @@ -84,18 +85,27 @@ protected: ArrayInfo timer{ _timer, 3 }; ArrayInfo registers{ _registers, 0x10 }; ArrayInfo toneStep{ _toneStep, 3 }; - Stream(timer, registers, toneStep, _currentRegister, _lastOutput, _processTick); + Stream(timer, registers, toneStep, _currentRegister, _lastOutput, _clock); } void ClockAudio() override { - if(_processTick) { - for(int i = 0; i < 3; i++) { + _clock += GetSSGClockFrequency() / (double)_console->GetCpu()->GetClockRate(_console->GetModel()); + + while (_clock >= 1) + { + for (int i = 0; i < 3; i++) { UpdateChannel(i); } + + _clock--; UpdateOutputLevel(); } - _processTick = !_processTick; + } + + virtual uint32_t GetSSGClockFrequency() + { + return _console->GetCpu()->GetClockRate(_console->GetModel()) / 2; } public: @@ -106,7 +116,7 @@ public: memset(_toneStep, 0, sizeof(_toneStep)); _currentRegister = 0; _lastOutput = 0; - _processTick = false; + _clock = 0; double output = 1.0; _volumeLut[0] = 0; diff --git a/Core/SoundMixer.cpp b/Core/SoundMixer.cpp index 466362b9..7846fde0 100644 --- a/Core/SoundMixer.cpp +++ b/Core/SoundMixer.cpp @@ -264,11 +264,11 @@ int16_t SoundMixer::GetOutputVolume(bool forRightChannel) GetChannelOutput(AudioChannel::FDS, forRightChannel) * 20 + GetChannelOutput(AudioChannel::MMC5, forRightChannel) * 43 + GetChannelOutput(AudioChannel::Namco163, forRightChannel) * 20 + - GetChannelOutput(AudioChannel::Sunsoft5B, forRightChannel) + + GetChannelOutput(AudioChannel::Sunsoft5B, forRightChannel) * 15 + GetChannelOutput(AudioChannel::VRC6, forRightChannel) * 75 + GetChannelOutput(AudioChannel::VRC7, forRightChannel) + - GetChannelOutput(AudioChannel::EPSG_L, forRightChannel) + - GetChannelOutput(AudioChannel::EPSG_R, forRightChannel) + GetChannelOutput(AudioChannel::EPSG_L, forRightChannel) * 15 + + GetChannelOutput(AudioChannel::EPSG_R, forRightChannel) * 15 ); } diff --git a/Core/SunsoftFme7.h b/Core/SunsoftFme7.h index d3c2e0b5..41aabb61 100644 --- a/Core/SunsoftFme7.h +++ b/Core/SunsoftFme7.h @@ -10,15 +10,15 @@ #endif #ifdef SUNSOFT_USE_EPSG -using AudioClass = EPSGAudio; +using SunsoftFme7AudioClass = EPSGAudio; #else -using AudioClass = Sunsoft5bAudio; +using SunsoftFme7AudioClass = Sunsoft5bAudio; #endif class SunsoftFme7 : public BaseMapper { private: - unique_ptr _audio; + unique_ptr _audio; uint8_t _command; uint8_t _workRamValue; bool _irqEnabled;