MDEC: Adjust 16bpp timing

Fixes jittery movement in Parasite Eve II opening.
This commit is contained in:
Connor McLaughlin 2020-12-09 20:29:31 +10:00
parent 59c338f461
commit 50bcdc0abb
2 changed files with 13 additions and 6 deletions

View file

@ -18,8 +18,8 @@ MDEC::~MDEC() = default;
void MDEC::Initialize() void MDEC::Initialize()
{ {
m_block_copy_out_event = TimingEvents::CreateTimingEvent("MDEC Block Copy Out", TICKS_PER_BLOCK, TICKS_PER_BLOCK, m_block_copy_out_event =
std::bind(&MDEC::CopyOutBlock, this), false); TimingEvents::CreateTimingEvent("MDEC Block Copy Out", 1, 1, std::bind(&MDEC::CopyOutBlock, this), false);
m_total_blocks_decoded = 0; m_total_blocks_decoded = 0;
Reset(); Reset();
} }
@ -353,6 +353,14 @@ bool MDEC::HandleDecodeMacroblockCommand()
return DecodeColoredMacroblock(); return DecodeColoredMacroblock();
} }
// Parasite Eve needs slightly higher timing in 16bpp mode, Disney's Treasure Planet needs lower timing in 24bpp mode.
static constexpr std::array<TickCount, 4> s_ticks_per_block = {{
448, // 4bpp
448, // 8bpp
448, // 24bpp
550, // 16bpp
}};
bool MDEC::DecodeMonoMacroblock() bool MDEC::DecodeMonoMacroblock()
{ {
// TODO: This should guard the output not the input // TODO: This should guard the output not the input
@ -370,7 +378,7 @@ bool MDEC::DecodeMonoMacroblock()
y_to_mono(m_blocks[0]); y_to_mono(m_blocks[0]);
ScheduleBlockCopyOut(TICKS_PER_BLOCK); ScheduleBlockCopyOut(s_ticks_per_block[static_cast<u8>(m_status.data_output_depth)] * 6);
m_total_blocks_decoded++; m_total_blocks_decoded++;
return true; return true;
@ -400,7 +408,7 @@ bool MDEC::DecodeColoredMacroblock()
yuv_to_rgb(8, 8, m_blocks[0], m_blocks[1], m_blocks[5]); yuv_to_rgb(8, 8, m_blocks[0], m_blocks[1], m_blocks[5]);
m_total_blocks_decoded += 4; m_total_blocks_decoded += 4;
ScheduleBlockCopyOut(TICKS_PER_BLOCK * 6); ScheduleBlockCopyOut(s_ticks_per_block[static_cast<u8>(m_status.data_output_depth)] * 6);
return true; return true;
} }
@ -409,7 +417,7 @@ void MDEC::ScheduleBlockCopyOut(TickCount ticks)
DebugAssert(!HasPendingBlockCopyOut()); DebugAssert(!HasPendingBlockCopyOut());
Log_DebugPrintf("Scheduling block copy out in %d ticks", ticks); Log_DebugPrintf("Scheduling block copy out in %d ticks", ticks);
m_block_copy_out_event->Schedule(ticks); m_block_copy_out_event->SetIntervalAndSchedule(ticks);
} }
void MDEC::CopyOutBlock() void MDEC::CopyOutBlock()

View file

@ -33,7 +33,6 @@ private:
static constexpr u32 DATA_IN_FIFO_SIZE = 1024; static constexpr u32 DATA_IN_FIFO_SIZE = 1024;
static constexpr u32 DATA_OUT_FIFO_SIZE = 768; static constexpr u32 DATA_OUT_FIFO_SIZE = 768;
static constexpr u32 NUM_BLOCKS = 6; static constexpr u32 NUM_BLOCKS = 6;
static constexpr TickCount TICKS_PER_BLOCK = 448;
enum DataOutputDepth : u8 enum DataOutputDepth : u8
{ {