CoreTiming: Catch the ME up when the main CPU reads the boot page

The ME runs a slice behind the main CPU, so a main CPU polling a mailbox
in the boot page saw the ME's progress up to a slice late. Reading the
boot page now runs the ME up to where the main CPU is in its slice first,
and the end of the slice runs only the rest. me/audiofifo, which times
the ME's playing from the main CPU, read 43900Hz for 44100.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-21 12:50:46 +02:00
1 parent c1e04f0516
commit e906b9f700
3 files changed
+22 -1

No files matched your search

+15 -1
View File
@@ -58,6 +58,8 @@ static Event *eventPool = 0;
// Downcount has been moved to currentMIPS, to save a couple of clocks in every ARM JIT block
// as we can already reach that structure through a register.
int slicelength;
// How much of the current slice the other CPUs have already run (CatchUpOtherCPUs).
static int otherCPUsRan = 0;
alignas(16) static s64 globalTimer;
static s64 idledCycles;
@@ -218,6 +220,7 @@ void UnregisterAllEvents() {
void Init(MIPSState *mips) {
mips->downcount = INITIAL_SLICE_LENGTH;
slicelength = INITIAL_SLICE_LENGTH;
otherCPUsRan = 0;
globalTimer = 0;
idledCycles = 0;
lastGlobalTimeTicks = 0;
@@ -417,7 +420,16 @@ void ProcessEvents() {
// The Media Engine catches up with the main CPU.
static void RunOtherCPUs(int cycles) {
if (MeCore::g_meState) {
MeCore::RunFor(cycles);
MeCore::RunFor(cycles - otherCPUsRan);
}
otherCPUsRan = 0;
}
void CatchUpOtherCPUs(MIPSState *mips) {
const int ran = slicelength - mips->downcount;
if (MeCore::g_meState && ran > otherCPUsRan) {
MeCore::RunFor(ran - otherCPUsRan);
otherCPUsRan = ran;
}
}
@@ -553,6 +565,8 @@ void DoState(PointerWrap &p) {
auto s = p.Section("CoreTiming", 1, 3);
if (!s)
return;
// States are saved between slices.
otherCPUsRan = 0;
int n = (int)event_types.size();
int current = n;