mirror of
https://github.com/libretro/Mesen.git
synced 2025-02-03 15:42:35 +00:00
Overclocking: Improved compatibility with games that write to $4011 + fixed PAL issues with OC
This commit is contained in:
parent
a4d0b00fe7
commit
547fbab29f
@ -33,6 +33,8 @@ void DeltaModulationChannel::Reset(bool softReset)
|
||||
_silenceFlag = true;
|
||||
_needToRun = false;
|
||||
|
||||
_lastValue4011 = 0;
|
||||
|
||||
//Not sure if this is accurate, but it seems to make things better rather than worse (for dpcmletterbox)
|
||||
//"On the real thing, I think the power-on value is 428 (or the equivalent at least - it uses a linear feedback shift register), though only the even/oddness should matter for this test."
|
||||
_period = (GetNesModel() == NesModel::NTSC ? _dmcPeriodLookupTableNtsc : _dmcPeriodLookupTablePal)[0] - 1;
|
||||
@ -153,8 +155,9 @@ void DeltaModulationChannel::WriteRAM(uint16_t addr, uint8_t value)
|
||||
break;
|
||||
|
||||
case 1: { //4011
|
||||
uint8_t newValue = value & 0x7F;
|
||||
uint8_t previousLevel = _outputLevel;
|
||||
_outputLevel = value & 0x7F;
|
||||
_outputLevel = newValue;
|
||||
|
||||
if(EmulationSettings::CheckFlag(EmulationFlags::ReduceDmcPopping) && abs(_outputLevel - previousLevel) > 50) {
|
||||
//Reduce popping sounds for 4011 writes
|
||||
@ -164,9 +167,11 @@ void DeltaModulationChannel::WriteRAM(uint16_t addr, uint8_t value)
|
||||
//4011 applies new output right away, not on the timer's reload. This fixes bad DMC sound when playing through 4011.
|
||||
AddOutput(_outputLevel);
|
||||
|
||||
if((value & 0x7F) > 0 && EmulationSettings::GetOverclockAdjustApu()) {
|
||||
if(_lastValue4011 != value && newValue > 0) {
|
||||
Console::SetNextFrameOverclockStatus(true);
|
||||
}
|
||||
|
||||
_lastValue4011 = newValue;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,8 @@ private:
|
||||
bool _silenceFlag = true;
|
||||
bool _needToRun = false;
|
||||
|
||||
uint8_t _lastValue4011 = 0;
|
||||
|
||||
void InitSample();
|
||||
void FillReadBuffer();
|
||||
|
||||
|
@ -42,7 +42,6 @@ bool EmulationSettings::_hasOverclock = false;
|
||||
uint32_t EmulationSettings::_overclockRate = 100;
|
||||
uint32_t EmulationSettings::_extraScanlinesBeforeNmi = 0;
|
||||
uint32_t EmulationSettings::_extraScanlinesAfterNmi = 0;
|
||||
uint32_t EmulationSettings::_ppuScanlineCount = 262;
|
||||
double EmulationSettings::_effectiveOverclockRate = 100;
|
||||
bool EmulationSettings::_overclockAdjustApu = true;
|
||||
bool EmulationSettings::_disableOverclocking = false;
|
||||
|
@ -397,7 +397,6 @@ private:
|
||||
static bool _disableOverclocking;
|
||||
static uint32_t _extraScanlinesBeforeNmi;
|
||||
static uint32_t _extraScanlinesAfterNmi;
|
||||
static uint32_t _ppuScanlineCount;
|
||||
static double _effectiveOverclockRate;
|
||||
static double _effectiveOverclockRateSound;
|
||||
|
||||
@ -727,12 +726,6 @@ public:
|
||||
_audioSettingsChanged = true;
|
||||
}
|
||||
|
||||
static void SetPpuScanlineCount(uint32_t scanlineCount)
|
||||
{
|
||||
_ppuScanlineCount = scanlineCount;
|
||||
UpdateEffectiveOverclockRate();
|
||||
}
|
||||
|
||||
static void DisableOverclocking(bool disabled)
|
||||
{
|
||||
_disableOverclocking = disabled;
|
||||
|
@ -112,25 +112,23 @@ void PPU::SetNesModel(NesModel model)
|
||||
_vblankEnd = 260;
|
||||
_standardNmiScanline = 241;
|
||||
_standardVblankEnd = 260;
|
||||
EmulationSettings::SetPpuScanlineCount(262);
|
||||
break;
|
||||
case NesModel::PAL:
|
||||
_nmiScanline = 241;
|
||||
_vblankEnd = 310;
|
||||
_standardNmiScanline = 241;
|
||||
_standardVblankEnd = 310;
|
||||
EmulationSettings::SetPpuScanlineCount(312);
|
||||
break;
|
||||
case NesModel::Dendy:
|
||||
_nmiScanline = 291;
|
||||
_vblankEnd = 310;
|
||||
_standardNmiScanline = 291;
|
||||
_standardVblankEnd = 310;
|
||||
EmulationSettings::SetPpuScanlineCount(312);
|
||||
break;
|
||||
}
|
||||
|
||||
_nmiScanline += EmulationSettings::GetPpuExtraScanlinesBeforeNmi();
|
||||
_palSpriteEvalScanline = _nmiScanline + 24;
|
||||
_standardVblankEnd += EmulationSettings::GetPpuExtraScanlinesBeforeNmi();
|
||||
_vblankEnd += EmulationSettings::GetPpuExtraScanlinesAfterNmi() + EmulationSettings::GetPpuExtraScanlinesBeforeNmi();
|
||||
}
|
||||
|
@ -28,8 +28,7 @@ class PPU : public IMemoryHandler, public Snapshotable
|
||||
{
|
||||
protected:
|
||||
static PPU* Instance;
|
||||
static constexpr uint16_t _palSpriteEvalScanline = 265;
|
||||
|
||||
|
||||
BaseMapper *_mapper;
|
||||
|
||||
PPUState _state;
|
||||
@ -52,7 +51,8 @@ class PPU : public IMemoryHandler, public Snapshotable
|
||||
uint16_t _standardNmiScanline;
|
||||
uint16_t _vblankEnd;
|
||||
uint16_t _nmiScanline;
|
||||
|
||||
uint16_t _palSpriteEvalScanline;
|
||||
|
||||
PPUControlFlags _flags;
|
||||
PPUStatusFlags _statusFlags;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user