Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
005587a
Frame-rate parity tests: any character via the recorded walk, [PAR] s…
schindlershadow Nov 15, 2026
4782d72
docs/testing.md: frame-rate parity tests (how they work, findings so …
schindlershadow Nov 15, 2026
0c47233
Parity tests: reset HP / bravery at every trial, live HP damage clear…
schindlershadow Nov 15, 2026
c40a752
fps_parity: HP damage may differ by 3% (bravery varies a little betwe…
schindlershadow Nov 15, 2026
6d1f054
Parity tests: samples every update, paths aligned by whole updates wi…
schindlershadow Nov 15, 2026
f10c2c5
docs/testing.md: parity judging (phase, alignment, tolerances), findi…
schindlershadow Nov 15, 2026
26d42a5
Parity tests: 3 s settle before the first trial, motion time in [PAR]…
schindlershadow Nov 15, 2026
40e9a92
Parity tests: restore both status blocks at every trial, analogue cam…
schindlershadow Nov 15, 2026
7cce3bb
docs/testing.md: parity run repeatability notes
schindlershadow Nov 15, 2026
1f33750
Jecht combo test as an optional part of the parity tests: direct boot…
schindlershadow Nov 15, 2026
0c39e96
combo_timing: adaptive sweep (1/30 s grid, 1/120 s only between probe…
schindlershadow Nov 15, 2026
eea5cf3
docs/testing.md: Jecht combo test checked in the game (PASS at 30 / 1…
schindlershadow Nov 15, 2026
03a7ac3
Jecht combo test: every rate (30..240) by default, --jobs limit
schindlershadow Nov 15, 2026
9bd02aa
Jecht combo test: dummy's live HP damage cleared in AI-off runs (the …
schindlershadow Nov 15, 2026
ec72c32
combo_timing verdict: a sweep where over a quarter of the trials coul…
schindlershadow Nov 15, 2026
23bb65e
docs/testing.md: Jecht combo test at all eight rates (Rush chain wind…
schindlershadow Nov 16, 2026
bb05149
fps_parity: CPU brain keeps running with its presses blocked (a CPU c…
schindlershadow Nov 16, 2026
f038223
Parity tests: CPU brain stopped again with its pad cleared every upda…
schindlershadow Nov 16, 2026
b5ebd59
Character swap: match the player model entry by name (Prishe's P_GST1…
schindlershadow Nov 16, 2026
0a29df6
docs/testing.md: dummy pad / stuck runs, Prishe's model entry
schindlershadow Nov 16, 2026
01001b9
docs/testing.md: whole-roster parity results (full4)
schindlershadow Nov 16, 2026
64a311c
Exact steps above 60 fps: each update's step is the next of a fixed c…
schindlershadow Nov 16, 2026
1714a37
WIP 30 Hz logic experiment (PSPRECOMP_LOGIC30=1): drawn-only frames r…
schindlershadow Nov 16, 2026
efbb7b1
30 Hz logic: timer step and global step agree every frame (global_ste…
schindlershadow Nov 16, 2026
97f5ad7
30 Hz logic: frame interpolation of the drawn-only frames, FX60 off u…
schindlershadow Nov 16, 2026
ce4aa5f
docs: 30 Hz logic (task filter, clocks, input, interpolation) and its…
schindlershadow Nov 16, 2026
d31b111
parity harness: every trial starts with the initial bravery (the firs…
schindlershadow Nov 16, 2026
a75048c
docs: 30 Hz logic whole-roster results, failure breakdown (bravery ha…
schindlershadow Nov 16, 2026
71913ab
framerate: TASK_TRACE backtraces only where execinfo/dladdr exist (An…
schindlershadow Nov 16, 2026
c6cb446
30 Hz logic paced by real time in play: a gameplay frame every 33.3 m…
schindlershadow Nov 16, 2026
6b47423
WIP 30 Hz logic smoothing: pacing from frame end (steady phases), neg…
schindlershadow Nov 16, 2026
3a7f4ac
30 Hz logic: tag each display list with the frame it was built in (fi…
schindlershadow Nov 16, 2026
eae8b50
30 Hz logic: the lock-on ring / target pointer move with the blended …
schindlershadow Nov 16, 2026
9ac1dc2
30 Hz logic: the UI update (FUN_088CF550) runs on gameplay frames onl…
schindlershadow Nov 16, 2026
8b4eb1e
Merge remote-tracking branch 'origin/main' into fps-parity-tests
schindlershadow Nov 16, 2026
66ca3d6
30 Hz logic on by default (PSPRECOMP_LOGIC30=0 / the Developer option…
schindlershadow Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions psprecomp/games/dissidia/docs/frame-rate.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,40 @@ update run one update in `rate / 30` with dt 2. **Not yet tested in play**: expe
fades that truncate at a small dt. There is no vsync, so a rate above the monitor's refresh tears or drops frames.
In multiplayer the lowest rate any player asked for wins, whatever the values.

## 30 Hz logic (on by default; `PSPRECOMP_LOGIC30=0` or Debug > Developer options > Timing turns it off)

Above 30 fps the battle can run its gameplay at the PSP's 30 updates a second instead of `rate` updates with a smaller step: every
`rate / 30`-th frame is a gameplay frame (timer step 2); the frames between are drawn-only (step 0). Native high-rate play can never
match 30 fps exactly, because a keyed event at 30 fps acts for a whole 33 ms frame; with 30 Hz logic every move plays as at 30 fps
(docs/testing.md "30 Hz logic" for the parity results).

- **Pacing** (`l30_decide_next`): in play a gameplay frame is due every 33.3 ms of real time (the frame shown nearest to it runs the
gameplay), and each frame is blended by the time actually passed since the last gameplay frame. Counting frames instead (every
rate / 30-th frame, phases k/n) looked jittery on the RP6 at 120 fps while moving: it drops ~7 % of frames, and a late frame then
showed the picture a quarter step on although more time had passed. Tests stay on frame counting (repeatable): parity runs, a test
script, `PSPRECOMP_VCLOCK`, or `PSPRECOMP_L30_PACE=frames`; `=clock` forces real time. `PSPRECOMP_L30_PACE_LOG=<n>` logs decisions,
`PSPRECOMP_L30_TIMING=1` frame times by position after the gameplay frame.
- **Task tree** (framerate.cpp `task_run_hook` on the runner FUN_0888245C): on drawn-only frames the battle scene list runs with the
pause filter (flags mask/value 4/4 instead of 1/1), so the scene is still built and drawn, minus 11 tasks that change gameplay when
run that way (the skip list in framerate.cpp; `PSPRECOMP_L30_KEEP` keeps them, for checks).
- **Clocks**: the timer's dt (`*(0x089D69E0)+0x18`, read directly by ~85 battle sites) is the current frame's step; the global step
(0x089D5EAC, copied a frame late by FUN_08864DD8) is made to show the step of the frame it will be used in (`global_step_hook`), and
the slow-motion clock only advances before gameplay frames.
- **Input**: the pad changes only on gameplay frames; a press that comes and goes between two of them is latched and shown once.
- **Camera**: the camera manager update (FUN_08B3CA24) is in the gameplay part of the battle list: it runs on gameplay frames only
(counted), and the renderer blends the view between them.
- **Random sequences** (0x09AF84D0, 0x09AFB89C) are put back after drawn-only frames (measured: not drawn from there; a guard).
- **Compensations for native high rates** (press latch, Jecht grid, EX Burst gating, gauges, UI step, steered moves, action start step,
exact steps, FX60) all stand down: they test for a step below 2 or for 30 Hz logic. A new one must too (FX60 did not at first:
it lengthened hitboxes, extra hits at 60 / 120 fps).
- **Drawing the frames between** (runtime/src/psp_ge_draw.cpp, `PSPRECOMP_INTERP`): the game module tags each display list with
(gameplay generation, phase) via `ge_interp_set_frame`; the render queue hands the tag to the renderer per list. On gameplay frames the
world / view / projection / bone matrices, texture-gen matrix and texture scale / offset of every 3D draw are recorded, keyed by the
draw's identity and occurrence (with a looser key without the vertex / index addresses for double-buffered vertices such as weapons).
Drawn-only frames draw with those values blended between the last two gameplay frames by phase (1, default: smooth, up to one 30 Hz
frame behind) or extrapolated from them (2); 0 draws the last gameplay frame as is. 2D (through-mode) draws, moves over 3 m and camera
cuts (the eye jumps over 3 m) are not blended. Effects whose vertices the CPU writes each update still move at 30 Hz.

## What 60 fps means here

It is **native**: the battle simulation runs 60 updates a second. Nothing is interpolated, and there's no extra
Expand Down
181 changes: 181 additions & 0 deletions psprecomp/games/dissidia/docs/testing.md

Large diffs are not rendered by default.

102 changes: 100 additions & 2 deletions psprecomp/games/dissidia/runtime/direct_battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,28 @@
// PSPRECOMP_TEST_PAD_RECORD=1 log the pad of a normal (harness) walk: "[PADREC] <poll> <mask hex>", and a
// "[PADREC] loaded <poll>" line when the save finishes loading
// PSPRECOMP_TEST_DIRECT_BATTLE=<f> replay the recording <f> (tools/battle_test.py --direct, tests/replays/quick_battle_walk.txt)
// Both are off by default; with neither set the filter returns the pad state unchanged.
// PSPRECOMP_TEST_CHAR_SWAP=<from>=<to>[,<from>=<to>] fight with other characters than the recording picked (tools/fps_parity.py),
// so the Squall vs Lightning walk loads any match-up. The menu fills the battle block at 0x09AFB8A0
// (FUN_088FB1A4 copies it for the battle): per side a 0x1060-byte fighter record that starts with a copy of
// the character's 0x778-byte save record (byte 0 = charId, then level, abilities ...; the CPU side gets a
// generated one), and behind them a team struct per side (+0x272F, stride 0x38: a count byte, five bytes,
// the charIds, 0xFF filled). On every poll a side whose record holds <from> gets <to>'s own save record
// (save records: *(0x089D712C) + 0xF58 + 0x778 x the charId's index in the 31-entry id list at 0x089CBC98)
// and its team charId; the CPU side's generated record only gets the charId. What the loading
// screen (FUN_0888C4C8) loads is the record's +0xF3A halfword: the object table id of the fighter's
// model entry (P_<code>_1P: byte 6 charId, byte 7 costume 1, byte 8 type 0 (Prishe: 16); table *(0x089D4968));
// it is set to <to>'s entry on every poll. The assist (+0xF3E) stays as the menu picked it.
// All are off by default; with none set the filter returns the pad state unchanged.
#include "psp_game_module.h"
#include "hle/psp_hle.h"
#include "psp_platform.h"
#include "psp_runtime.h"
#include "recomp.h"
#include <atomic>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>

extern std::atomic<uint32_t> g_savedata_list_opened, g_savedata_completed; // runtime/src/hle/psp_hle_utility.cpp
Expand All @@ -42,8 +55,73 @@ uint32_t g_cur = 0;

} // namespace

namespace {
uint8_t* g_rdram = nullptr;
std::vector<std::pair<int, int>> g_swap; // PSPRECOMP_TEST_CHAR_SWAP
uint8_t* g_at(uint32_t a) { return g_rdram + (a & 0x07FFFFFFu); }
uint32_t g_w32(uint32_t a) { uint32_t v; std::memcpy(&v, g_at(a), 4); return v; }
uint32_t save_record(int charId) { // the save record of a charId (0 = none)
for (uint32_t i = 0; i < 31; i++) {
if (*g_at(0x089CBC98u + i) != charId) continue;
const uint32_t base = g_w32(0x089D712Cu);
return base >= 0x08800000u && base < 0x0A000000u ? base + 0xF58u + 0x778u * i : 0u;
}
return 0;
}
int model_id(int charId) { // object table id of a character's first-costume player model entry (P_<code>_1P), -1 = none
const uint32_t t = g_w32(0x089D4968u);
if (t < 0x08800000u || t >= 0x0A000000u) return -1;
const uint32_t h = g_w32(t);
if (h < 0x08800000u || h >= 0x0A000000u) return -1;
const uint32_t n = g_w32(h + 4u);
for (uint32_t i = 0; i < n && i < 4000u; i++) {
const uint8_t* r = g_at(h + 8u + 0x44u * i);
if (r[6] != charId || r[7] != 1 || r[8] == 5 || r[8] == 8 || r[8] == 13) continue; // costume 1, not an assist (8 / 13) or manikin (5): Prishe's is type 16
const char* name = reinterpret_cast<const char*>(r + 36);
const size_t len = strnlen(name, 16);
if (len < 4 || std::strncmp(name, "P_", 2) != 0 || std::strncmp(name + len - 3, "_1P", 3) != 0) continue;
uint16_t id; std::memcpy(&id, r, 2);
return id;
}
return -1;
}
void team_swap() {
constexpr uint32_t kBlock = 0x09AFB8A0u, kSide = 0x1060u, kTeam = 0x2735u, kTeamStride = 0x38u;
static int done[2] = {-1, -1}; // the pair applied to each side (one per side: "15=31,31=15" must not flip a side back)
static int want[2] = {-2, -2}, from_id[2] = {-2, -2};
for (uint32_t side = 0; side < 2; side++) {
uint8_t* rec = g_at(kBlock + kSide * side);
uint8_t* ids = g_at(kBlock + kTeam + kTeamStride * side);
if (done[side] >= 0 && rec[0] != g_swap[done[side]].second) done[side] = -1; // the menu wrote the record again
if (done[side] < 0) {
for (size_t k = 0; k < g_swap.size(); k++) {
const auto& s = g_swap[k];
if (rec[0] != s.first || rec[1] < 1 || rec[1] > 100) continue; // a fighter record (charId, level 1..100)
const uint32_t src = side == 0 ? save_record(s.second) : 0u;
if (src) std::memcpy(rec, g_at(src), 0x778);
rec[0] = static_cast<uint8_t>(s.second);
done[side] = static_cast<int>(k);
want[side] = model_id(s.second); from_id[side] = model_id(s.first);
std::fprintf(stderr, "[DIRECT] side %u fighter record: charId %d -> %d (%s)\n", side, s.first, s.second, src ? "its own save record" : "charId only");
break;
}
}
if (done[side] < 0) continue;
const auto& s = g_swap[done[side]];
if (ids[-6] == 1 && ids[0] == s.first && ids[1] == 0xFF) ids[0] = static_cast<uint8_t>(s.second); // a 1-on-1 team struct
uint16_t m; std::memcpy(&m, rec + 0xF3A, 2); // the model the loading screen loads: <to>'s (the menu sets it from its own pick)
if (want[side] >= 0 && m != want[side] && (m == from_id[side] || from_id[side] < 0)) {
const uint16_t w = static_cast<uint16_t>(want[side]);
std::memcpy(rec + 0xF3A, &w, 2);
std::fprintf(stderr, "[DIRECT] side %u model id %u -> %u (charId %d)\n", side, m, w, s.second);
}
}
}
} // namespace

// Called by the pad filter of framerate.cpp for every poll; returns the buttons to hand the game.
uint32_t dissidia_walk_filter(uint32_t buttons) {
if (!g_swap.empty()) team_swap();
if (!g_replay && !g_record) return buttons;
const uint64_t n = ++g_poll;
if (g_record) {
Expand Down Expand Up @@ -81,8 +159,28 @@ uint32_t dissidia_walk_filter(uint32_t buttons) {
}
}

// FUN_08846E18(table, charId, costume): the object table entry (byte 6 charId, byte 7 costume) of a character's model files.
FuncPtr g_orig_objfind = nullptr;
void objfind_hook(uint8_t* rdram, recomp_context* ctx) {
const int id = static_cast<int>(ctx->r[5]);
static int logged = 0;
if (logged++ < 40) std::fprintf(stderr, "[DIRECT] objfind charId %d costume %d ra=%08X\n", id, static_cast<int>(ctx->r[6]), static_cast<uint32_t>(ctx->r[31]));
g_orig_objfind(rdram, ctx);
}

void dissidia_direct_battle_install(uint8_t* rdram) {
(void)rdram;
g_rdram = rdram;
if (std::getenv("PSPRECOMP_TEST_OBJFIND_LOG") && (g_orig_objfind = psp_dispatch_probe_lookup(0x08846E18u))) psp_dispatch_register(0x08846E18u, objfind_hook);
if (const char* sw = std::getenv("PSPRECOMP_TEST_CHAR_SWAP"); sw && sw[0]) {
for (const char* q = sw; *q;) {
int a = 0, b = 0, used = 0;
if (std::sscanf(q, "%d=%d%n", &a, &b, &used) != 2) break;
if (a > 0 && a < 255 && b > 0 && b < 255) g_swap.push_back({a, b});
q += used;
if (*q == ',') q++;
}
std::fprintf(stderr, "[DIRECT] character swap: %zu pair(s) from %s\n", g_swap.size(), sw);
}
if (const char* r = std::getenv("PSPRECOMP_TEST_PAD_RECORD"); r && r[0] && r[0] != '0') {
g_record = true;
std::fprintf(stderr, "[DIRECT] recording the pad (PADREC lines)\n");
Expand Down
Loading
Loading