mirror of
https://github.com/NovaSquirrel/Mesen-X.git
synced 2024-06-11 08:47:50 -04:00
Refactor starting phase
This commit is contained in:
parent
b9268282ae
commit
1a21018d5e
|
@ -52,17 +52,11 @@ bool BaseVideoFilter::IsOddFrame()
|
|||
return _isOddFrame;
|
||||
}
|
||||
|
||||
uint8_t BaseVideoFilter::GetFieldPhase()
|
||||
{
|
||||
return _fieldPhase;
|
||||
}
|
||||
|
||||
void BaseVideoFilter::SendFrame(uint16_t *ppuOutputBuffer, uint32_t frameNumber)
|
||||
{
|
||||
_frameLock.Acquire();
|
||||
_overscan = _console->GetSettings()->GetOverscanDimensions();
|
||||
_isOddFrame = frameNumber & 0x01;
|
||||
_fieldPhase = frameNumber % 3;
|
||||
UpdateBufferSize();
|
||||
OnBeforeApplyFilter();
|
||||
ApplyFilter(ppuOutputBuffer);
|
||||
|
|
|
@ -15,8 +15,6 @@ private:
|
|||
SimpleLock _frameLock;
|
||||
OverscanDimensions _overscan;
|
||||
bool _isOddFrame;
|
||||
// https://forums.nesdev.org/viewtopic.php?p=30625#p30625
|
||||
uint8_t _fieldPhase;
|
||||
|
||||
void UpdateBufferSize();
|
||||
|
||||
|
@ -25,7 +23,6 @@ protected:
|
|||
|
||||
virtual void ApplyFilter(uint16_t *ppuOutputBuffer) = 0;
|
||||
virtual void OnBeforeApplyFilter();
|
||||
uint8_t GetFieldPhase();
|
||||
|
||||
public:
|
||||
BaseVideoFilter(shared_ptr<Console> console);
|
||||
|
|
|
@ -50,7 +50,7 @@ BisqwitNtscFilter::BisqwitNtscFilter(shared_ptr<Console> console, int resDivider
|
|||
} else {
|
||||
outputBuffer += GetOverscan().GetScreenWidth() * 64 / _resDivider / _resDivider * (120 - GetOverscan().Top);
|
||||
}
|
||||
DecodeFrame(120, 239 - GetOverscan().Bottom, _ppuOutputBuffer, outputBuffer, (_console->IsDotBypassed() ? (GetFieldPhase() * 4) : (IsOddFrame() ? 0 : 8)) + 327360);
|
||||
DecodeFrame(120, 239 - GetOverscan().Bottom, _ppuOutputBuffer, outputBuffer, (_console->GetStartingPhase() * 4) + 327360);
|
||||
|
||||
_workDone = true;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ void BisqwitNtscFilter::ApplyFilter(uint16_t *ppuOutputBuffer)
|
|||
|
||||
_workDone = false;
|
||||
_waitWork.Signal();
|
||||
DecodeFrame(GetOverscan().Top, 120, ppuOutputBuffer, GetOutputBuffer(), (_console->IsDotBypassed() ? (GetFieldPhase() * 4) : (IsOddFrame() ? 0 : 8)) + GetOverscan().Top * 341 * 8);
|
||||
DecodeFrame(GetOverscan().Top, 120, ppuOutputBuffer, GetOutputBuffer(), (_console->GetStartingPhase() * 4) + GetOverscan().Top * 341 * 8);
|
||||
while(!_workDone) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -568,9 +568,9 @@ uint32_t Console::GetFrameCount()
|
|||
return _ppu ? _ppu->GetFrameCount() : 0;
|
||||
}
|
||||
|
||||
bool Console::IsDotBypassed()
|
||||
uint8_t Console::GetStartingPhase()
|
||||
{
|
||||
return _ppu ? _ppu->IsDotBypassed() : false;
|
||||
return _ppu ? _ppu->GetStartingPhase() : 0;
|
||||
}
|
||||
|
||||
NesModel Console::GetModel()
|
||||
|
|
|
@ -205,7 +205,7 @@ public:
|
|||
RomInfo GetRomInfo();
|
||||
uint32_t GetFrameCount();
|
||||
// https://forums.nesdev.org/viewtopic.php?p=30625#p30625
|
||||
bool IsDotBypassed();
|
||||
uint8_t GetStartingPhase();
|
||||
NesModel GetModel();
|
||||
|
||||
uint32_t GetLagCounter();
|
||||
|
|
|
@ -132,7 +132,7 @@ void NtscFilter::OnBeforeApplyFilter()
|
|||
|
||||
void NtscFilter::ApplyFilter(uint16_t *ppuOutputBuffer)
|
||||
{
|
||||
nes_ntsc_blit(&_ntscData, ppuOutputBuffer, _ntsc_border, PPU::ScreenWidth, (_console->IsDotBypassed() ? GetFieldPhase() : (IsOddFrame() ? 0 : 2)), PPU::ScreenWidth, 240, _ntscBuffer, NES_NTSC_OUT_WIDTH(PPU::ScreenWidth)*4);
|
||||
nes_ntsc_blit(&_ntscData, ppuOutputBuffer, _ntsc_border, PPU::ScreenWidth, _console->GetStartingPhase(), PPU::ScreenWidth, 240, _ntscBuffer, NES_NTSC_OUT_WIDTH(PPU::ScreenWidth)*4);
|
||||
GenerateArgbFrame(_ntscBuffer);
|
||||
}
|
||||
|
||||
|
|
22
Core/PPU.cpp
22
Core/PPU.cpp
|
@ -105,7 +105,7 @@ void PPU::Reset()
|
|||
memset(_oamDecayCycles, 0, sizeof(_oamDecayCycles));
|
||||
_enableOamDecay = _settings->CheckFlag(EmulationFlags::EnableOamDecay);
|
||||
|
||||
_isDotBypassed = false;
|
||||
_startingPhase = 0;
|
||||
|
||||
UpdateMinimumDrawCycles();
|
||||
}
|
||||
|
@ -999,21 +999,13 @@ void PPU::ProcessScanline()
|
|||
LoadTileInfo();
|
||||
}
|
||||
} else if(_cycle == 337 || _cycle == 339) {
|
||||
if(_scanline == -1 && _cycle == 339 && (_frameCount & 0x01) && _nesModel == NesModel::NTSC && _settings->GetPpuModel() == PpuModel::Ppu2C02) {
|
||||
if (IsRenderingEnabled()) {
|
||||
//This behavior is NTSC-specific - PAL frames are always the same number of cycles
|
||||
//"With rendering enabled, each odd PPU frame is one PPU clock shorter than normal" (skip from 339 to 0, going over 340)
|
||||
_cycle = 340;
|
||||
_isDotBypassed = false;
|
||||
}
|
||||
else {
|
||||
// "By keeping rendering disabled until after the time when the clock is skipped on odd frames,
|
||||
// you can get a different color dot crawl pattern than normal."
|
||||
_isDotBypassed = true;
|
||||
}
|
||||
}
|
||||
if (IsRenderingEnabled()) {
|
||||
ReadVram(GetNameTableAddr());
|
||||
if (_scanline == -1 && _cycle == 339 && (_frameCount & 0x01) && _nesModel == NesModel::NTSC && _settings->GetPpuModel() == PpuModel::Ppu2C02) {
|
||||
//This behavior is NTSC-specific - PAL frames are always the same number of cycles
|
||||
//"With rendering enabled, each odd PPU frame is one PPU clock shorter than normal" (skip from 339 to 0, going over 340)
|
||||
_cycle = 340;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1351,6 +1343,8 @@ void PPU::Exec()
|
|||
}
|
||||
}
|
||||
|
||||
_startingPhase = _cycle % 3;
|
||||
|
||||
if(_needStateUpdate) {
|
||||
UpdateState();
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class PPU : public IMemoryHandler, public Snapshotable
|
|||
bool _corruptOamRow[32];
|
||||
|
||||
// https://forums.nesdev.org/viewtopic.php?p=30625#p30625
|
||||
bool _isDotBypassed;
|
||||
uint8_t _startingPhase;
|
||||
|
||||
void UpdateStatusFlag();
|
||||
|
||||
|
@ -220,9 +220,9 @@ class PPU : public IMemoryHandler, public Snapshotable
|
|||
return _frameCount;
|
||||
}
|
||||
|
||||
bool IsDotBypassed()
|
||||
uint8_t GetStartingPhase()
|
||||
{
|
||||
return _isDotBypassed;
|
||||
return _startingPhase;
|
||||
}
|
||||
|
||||
uint32_t GetFrameCycle()
|
||||
|
|
Loading…
Reference in a new issue