Fixed SSG overflow and fixed relative clock for SSG/EPSG

This commit is contained in:
lapinozz 2021-01-04 22:47:07 -05:00 committed by Perkka2
parent 5d00c055e6
commit d7213a76d5
6 changed files with 36 additions and 18 deletions

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -593,6 +593,7 @@
<ClInclude Include="Sachen9602.h" />
<ClInclude Include="ServerInformationMessage.h" />
<ClInclude Include="FamicomBox.h" />
<ClInclude Include="SSGAudio.h" />
<ClInclude Include="StereoCombFilter.h" />
<ClInclude Include="StudyBoxLoader.h" />
<ClInclude Include="SystemActionManager.h" />

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Debugger">
@ -1511,6 +1511,9 @@
<ClInclude Include="EPSGAudio.h">
<Filter>Nes\Mappers\EPSG</Filter>
</ClInclude>
<ClInclude Include="SSGAudio.h">
<Filter>Nes\Mappers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">

View file

@ -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> 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)

View file

@ -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<int16_t> timer{ _timer, 3 };
ArrayInfo<uint8_t> registers{ _registers, 0x10 };
ArrayInfo<uint8_t> 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;

View file

@ -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
);
}

View file

@ -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<AudioClass> _audio;
unique_ptr<SunsoftFme7AudioClass> _audio;
uint8_t _command;
uint8_t _workRamValue;
bool _irqEnabled;