From f48c67a49ec443f064cdce44f82de14701ea837c Mon Sep 17 00:00:00 2001 From: Schindler Date: Wed, 18 Nov 2026 14:04:13 -0500 Subject: [PATCH 1/5] Docs: related projects survey (VCKing101/Dissidia012-pc, RocherBrockas/DissidiaDecompProject, RecompLauncher) Notes, with credit and licence terms, on what the other Dissidia 012 projects have that we lack: the 8-way walk input at ovl_battle 0x08B38A0C, the game's online exchange at 0x0890D664 and their rollback numbers, Japanese story scene scripts, BGM picker and music mods, event names missing from charmod_objx.py. Sources: https://github.com/VCKing101/Dissidia012-pc (MIT, VCKing101), https://github.com/RocherBrockas/DissidiaDecompProject (MIT, Pierre Brossy). Co-Authored-By: Claude Opus 5.5 --- psprecomp/games/dissidia/docs/README.md | 1 + .../games/dissidia/docs/related-projects.md | 133 ++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 psprecomp/games/dissidia/docs/related-projects.md diff --git a/psprecomp/games/dissidia/docs/README.md b/psprecomp/games/dissidia/docs/README.md index 5c900a0..728c916 100644 --- a/psprecomp/games/dissidia/docs/README.md +++ b/psprecomp/games/dissidia/docs/README.md @@ -32,6 +32,7 @@ Short guides next to the tools, and the full reference here: - [spawned-objects.md](spawned-objects.md): the `wpnp` table and the objects `hold_prop` / `summon_object` spawn (Gilgamesh's swords, Yuna's aeons). - [effects.md](effects.md): how the game draws effects (placement, timing, colour and blending, every component), and corrections to the FEP notes. - [audio.md](audio.md): extra BGM tracks, voice banks. +- [related-projects.md](related-projects.md): other Dissidia 012 projects (VCKing101's port, DissidiaDecompProject, RecompLauncher), credited, and what is worth taking from them. - [recomp-status.md](recomp-status.md): how the native build came together (October 2026), and soak-test findings. Historical. - [character-lighting.md](character-lighting.md): live key and rim lighting on character bodies in the native build (`body.lighting`). - [spring-bones.md](spring-bones.md): how the game swings capes, hair, skirts and weapon chains, and giving a mod character a physics cape. diff --git a/psprecomp/games/dissidia/docs/related-projects.md b/psprecomp/games/dissidia/docs/related-projects.md new file mode 100644 index 0000000..a4bce96 --- /dev/null +++ b/psprecomp/games/dissidia/docs/related-projects.md @@ -0,0 +1,133 @@ +# Related projects: what we can learn from them + +Surveyed 18 November 2026. Three other Dissidia 012 projects, what they have that this project does not, and what is +worth taking. Addresses in their notes are for the USA release (ULUS10566), but the main executable and the overlays +load at the same addresses as ours, so they can be used directly (checked: their `0x08872138` is our +`FUN_08872138`, the pad dead-zone routine; their `0x0889F234` is our BGM playback `FUN_0889F234`). + +## Credits and licences + +- **[VCKing101/Dissidia012-pc](https://github.com/VCKing101/Dissidia012-pc)**, by VCKing101. A native port built + on [PortableKit](https://github.com/TeamGDB/PortableKit), plus a matching decompilation. MIT licence (copyright + 2026 VCKing101) for its port code, tools and docs. Its `NOTICE.md` says the MIT licence does **not** cover the + decompiled C in `src/`, `include/` and `port/decomp/`. So: research facts and designs from its docs can be + used with credit. Code from `port/host/` or `tools/` may be copied only with the MIT notice kept. Do not copy the + decompiled C. Write our own from their notes. +- **[RocherBrockas/DissidiaDecompProject](https://github.com/RocherBrockas/DissidiaDecompProject)**, by Pierre + Brossy. An early decompilation setup (splat, Ghidra scripts, a `PACKAGE.BIN` extractor, per-format notes). MIT. + Some format notes in it are credited to Sky Noxt. +- **[RecompLauncher](https://recomplauncher.com/game/dissidia012-pc)**: a launcher that lists recomps from their + GitHub repos, installs them, and runs their setup from the player's disc image. VCKing101's port is listed there. + +Anything added to this project from these sources must name the source in the commit message and in the doc or code +comment it lands in. Use a link to the repo and the file it came from. + +## Worth taking, most useful first + +### 1. Analogue walking: the direction is still 8-way (bug in ours) + +Source: [docs/port/analog-movement.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/analog-movement.md). + +Our `input.cpp` replaces the stick vector that `FUN_08872138` writes. Their notes show that **nothing in the walk +reads that vector**. The walker's input is `ovl_battle 0x08B38A0C`, called once a frame from `0x08B36D2C` with +`(out, walker, pad, camera)`. It builds a camera-space step from the four "walk" bits only (+-1 on x and z), so every +walk direction is one of eight. Lowering the per-axis dead zone (`PSPRECOMP_ANALOG_DPAD_ZONE`) changes when a bit +appears, not the angle. This applies on the world map, and in battle too: the fighter under the player's pad calls the +same function. + +Their fix: override `0x08B38A0C` and, when the walk bits come from the stick (the "move with analog stick" option, pad +table B at `0x08B7F380`), use the real stick direction in camera space. Set the walker's direction flags at +`walker+0x5B0` as the 8-way bits would be (each axis within 67.5 degrees). Leave the rest as the game does it. The walk +speed stays the same, because the output is a unit direction. + +Two cautions from them: +- **Replays.** A battle replay records only the 8-way bits (`0x08889628` -> `0x088CA680`, 15 bits a frame). Analogue + steering in battle makes a saved replay play back differently. They keep battle 8-way by default. Netplay is safe + if both machines are fed the same bytes. +- **World map camera follow.** The free camera's follow (`ovl_battle 0x08B3F7F4`, the end at `0x08B3FAA4..0x08B3FC08`) + turns toward the walker's facing by up to 0.05 rad per frame, with no dead zone. With true angles, a push slightly + off straight up makes the camera turn and the walker veer. They added a 22.5 degree dead zone to the follow. + +### 2. Online battles: replacing the game's per-frame exchange + +Source: [docs/port/communication-mode.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/communication-mode.md) +(sections 4 and 11 onward) and [online-next.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/online-next.md) section 5. + +Our multiplayer runs the game's own lock-step over our ad-hoc emulation. Their notes on that lock-step: +- All of it is one function, the role-0 handler `0x0890D664` (frame pump `0x088EC010 -> 0x0890E794 -> 0x08907F14 -> + 0x0890C5BC`). Spectators use `0x0890DF58`. +- It sends a 16-bit word a frame: 12 buttons plus 4 stick-direction bits. So online fighters get only the 8-way stick + and no right stick. Input delay is 0 to 2 frames, it grows and never shrinks, and the battle freezes on every + late frame past about 100 ms round trip. After 900 waiting frames the session ends. +- Packet: 0x24 bytes, the last 8 pad words, a desync hash every 10 frames (`0x0890CD90`; the hash callback is battle + `0x08B136D4`). +- Both machines simulate both fighters and both cameras from the two pads, so full analogue input can go in the raw + pads' injected samples (`+0x40..+0x4F`) as long as both machines inject the same bytes. + +They replaced `0x0890D664` during battles with their own UDP lock-step: full analogue, both right sticks (bytes 10 and +11 of the sample), a set input delay, redundancy, and the game's own check value compared every 10 frames. They then +added **rollback**. Their measurements: dirty-page snapshots are about 2 MiB a frame, and 2 to 3 frames of rollback on +top of 1 frame of delay covers about 100 to 130 ms without a stall. This is the main gap in our +[multiplayer.md](multiplayer.md) ("input delay or rollback for high latency" is listed there as missing). + +### 3. Japanese voices: story scene scripts + +Source: [docs/port/japanese-voices.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/japanese-voices.md), "Story scenes". + +Our `jp_audio.py` swaps audio files only. They found that **302 voiced story scenes** (`talkevent/*.evex`, ARC +archives) have different scripts on the English and Japanese discs. 55 have other voice lists and 247 have other +waits, because each line waits a fixed time tuned to its own recording. With English scripts and Japanese audio, lines +get cut off or the wrong line plays (their example: Vaan and Terra, 012 Chapter 2, `up02_103`). Their fix is to read +each of those scenes as the Japanese disc has it, keeping the English text. The English game knows every script +command of the Japanese scripts except `0x157` and `0x162`. They also keep the English movie picture with the +Japanese sound, where we swap the whole PMF. + +Their trick for pairing files without names: the `PACKAGE_INFO.BIN` hash is CRC-32/BZIP2, which is linear. Two names +of the same length that differ only in `jp`/`en` differ by a constant that depends only on how many characters follow, +so `hash XOR delta(n)` finds the English twin of every Japanese file (6,222 of 6,354 sound files pair one to one). + +### 4. Features we do not have + +| Feature | Their doc | Notes for us | +| --- | --- | --- | +| BGM picker on the loading screen (series left/right, track wheel up/down) and music mods in MP3/Ogg/Opus/FLAC/WAV/BRSTM with loop points, no disc change | [bgm-playlist-design.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/bgm-playlist-design.md), [mod-folder.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/mod-folder.md) | Ours needs AT3 encoding and a `main.bin` rewrite ([audio.md](audio.md)). Their facts: the table object `*0x089D6C30` has room for 256 rows; DLC rows are added at run time by `0x0889F040`; the selector is battle `0x08AF8CA4`, struct at loading screen `+0x6AC`. | +| Local split-screen versus (1v1 and party), each player with a controller and camera | [local-versus.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/local-versus.md) | Large job (one game drawn twice). Their notes on player 2's input path also serve netplay. | +| Cheats page: built-in cheats plus PPSSPP CWCheat files (`PSP/Cheats/ULUS10566.ini`) | [cheats.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/cheats.md) | Their CWCheat engine is in PortableKit (MIT). | +| Button prompts drawn as Xbox / PlayStation / Nintendo / keyboard, following the controller in use | [button-prompts.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/button-prompts.md) | Also changes the prompts inside hint text. | +| L/R on the triggers option; per-player controller choice; one key each for dodge, dash, EX Mode, summon and assists | [keyboard-controls.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/keyboard-controls.md), [controller-picker.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/controller-picker.md) | Small. | +| Save, message and keyboard dialogs drawn in the game's own menu style with its sounds | [native-dialogs.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/native-dialogs.md) | Cosmetic. | +| Listing on RecompLauncher | [recomplauncher.json](https://github.com/VCKing101/Dissidia012-pc/blob/main/recomplauncher.json) | Needs a portable zip and a no-window `--prepare --game {game}` step; the manifest describes the ISO check, an ini settings file, and the save, mod and log folders. | + +### 5. Event names + +Source: [docs/research/moveset-format.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/research/moveset-format.md), section 6. + +They list all 125 ranged and 56 keyed event handlers. Compared with the names in `tools/charmod_objx.py`, these codes +have names there and not here (uses / fighters in brackets): +- Ranged: `0x3C brave_regen` (Gabranth), `0x51 armor` (Kain, Chaos), `0x17 swing_reset` (Sephiroth, Bartz, Firion), + `0x6B sound_ramp`, `0x1A actionable_ex` (Feral Chaos). +- Unused by any retail move, but working handlers that new moves could use: `0x0D freeze_state`, `0x0E hold_target`, + `0x41 break_lock_ons`, `0x44 tint`, `0x4E shape_off`, plus camera paths `0x5C`/`0x6F` (partly understood). +- Keyed: `0x17 cart_effect` (Laguna, Squall). + +Check each in the game code before adding it to the table: their codes are the event type, ours are +`(arg count << 8) | type`. + +### 6. Smaller facts + +- `PACKAGE_INFO.BIN` is read into a fixed buffer of `0x20F8C` bytes (`0x08871938`), room for only 210 more records + ([japanese-voices.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/japanese-voices.md)). +- The pad manager object map (`0x08C15B90`), its three pad arrays, the remap tables and the injected / replay / + network input paths: [research/pad-module.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/research/pad-module.md). +- `DES4` files are stage geometry: collision meshes, transforms of breakable objects, EX core positions and fighter + start and end positions (Sky Noxt, in DissidiaDecompProject `Extract/des4/README.md`). + +## Already covered here + +- The text cipher (DissidiaDecompProject `Tools/MiscTools`): our `tools/mess_text.py` already reads and writes it, + including the OFF4 layout. +- The `PACKAGE.BIN` extractor and builder: `tools/package_extract.py` and the loose-file layer do more. +- Right-stick camera, analogue dead zone, 60+ fps, HD textures, Discord status, Japanese voices, internet play, + cloud saves: all here already. Our frame rates (up to 240) and character modding go further than theirs. +- Their quit crash (a descriptor pool destroyed before sets were freed from it) does not apply. Our Vulkan code + never frees single descriptor sets. From 73a376750eb261a172effe114f44a6ed2bda738d Mon Sep 17 00:00:00 2001 From: Schindler Date: Wed, 18 Nov 2026 14:27:53 -0500 Subject: [PATCH 2/5] Analogue walking direction on the world map The walker's input (ovl_battle FUN_08B38A0C) builds each step from the four walk bits, so walks went one of eight ways even with the radial stick vector. While it runs for raw[0]'s LogicalPad with the stick pushed, the step on its stack is replaced by the stick's own direction just before the camera is applied (first of FUN_0885EA88 / FUN_089A3BC8 from its frame). World map by default; PSPRECOMP_ANALOG_WALK=0 off, PSPRECOMP_ANALOG_WALK_BATTLE=1 also in battle (experimental: battle heading moves only a few degrees), PSPRECOMP_ANALOG_WALK_LOG=. Measured on the prologue field: 15, -15 and 30 degree pushes turned the walk by 14.8, 15.0 and 30.2 degrees. Cause and addresses from VCKing101's notes: https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/analog-movement.md (MIT) Co-Authored-By: Claude Opus 5.5 --- psprecomp/games/dissidia/docs/native-build.md | 13 +++ .../games/dissidia/docs/related-projects.md | 3 + psprecomp/games/dissidia/docs/steamdeck.md | 8 +- psprecomp/games/dissidia/runtime/input.cpp | 89 +++++++++++++++++++ psprecomp/runtime/src/psp_env_options.inc | 3 + 5 files changed, 113 insertions(+), 3 deletions(-) diff --git a/psprecomp/games/dissidia/docs/native-build.md b/psprecomp/games/dissidia/docs/native-build.md index ede824c..b327201 100644 --- a/psprecomp/games/dissidia/docs/native-build.md +++ b/psprecomp/games/dissidia/docs/native-build.md @@ -132,3 +132,16 @@ axes, so in battle the original runs on a square-gate version of the stick with (`PSPRECOMP_ANALOG_DPAD_ZONE`, default 0.35 of travel; `PSPRECOMP_ANALOG_8WAY=0` turns it off). `PSPRECOMP_ANALOG_FULL=0` restores the original 8-way behaviour, `PSPRECOMP_ANALOG_DEADZONE` (default 0.20 of travel) sets the radial dead zone, `PSPRECOMP_ANALOG_LOG=` logs raw / game / replacement vectors. + +Walking direction: the stick vector above is not what steers a walk. The walker's input (`ovl_battle FUN_08B38A0C`, on the world map +and for the player's fighter in battle) builds its step from the four walk bits only, so even with the changes above every walk went one +of eight ways (found by VCKing101, [related-projects.md](related-projects.md)). `input.cpp` turns that step to the stick's own direction +just before the game applies the camera to it, for a human pad with the stick past the dead zone; when the walk starts, the walk speed +and everything after it stay the game's. World map only by default: a battle replay stores just the 8-way bits, so a stick-steered +fighter would play back elsewhere. `PSPRECOMP_ANALOG_WALK=0` turns it off, `PSPRECOMP_ANALOG_WALK_BATTLE=1` also steers in battle (never +while the pads are fed by the game's online exchange), `PSPRECOMP_ANALOG_WALK_LOG=` logs n replaced steps. +Measured 18 November 2026 (Story Mode prologue field, debug socket `A` pushes of 0.4 s, walker position at `+0x110`): relative to a +straight push, 15, -15 and 30 degrees of stick turned the walk by 14.8, 15.0 and 30.2 degrees; with `PSPRECOMP_ANALOG_WALK=0` the +headings jump by 20 to 45 degrees. In battle the step is replaced too, but the fighter's heading moved only 2 to 6 degrees for a +15 degree push and drifted back to the line to the opponent (battle_test, Squall, stage 12): battle movement has more steering after +this step, so `PSPRECOMP_ANALOG_WALK_BATTLE` is experimental. diff --git a/psprecomp/games/dissidia/docs/related-projects.md b/psprecomp/games/dissidia/docs/related-projects.md index a4bce96..4e33fa6 100644 --- a/psprecomp/games/dissidia/docs/related-projects.md +++ b/psprecomp/games/dissidia/docs/related-projects.md @@ -26,6 +26,9 @@ comment it lands in. Use a link to the repo and the file it came from. ### 1. Analogue walking: the direction is still 8-way (bug in ours) +**Done for the world map** (18 November 2026, `runtime/input.cpp`, [native-build.md](native-build.md)); battle is opt-in and only +partly steered. The camera follow dead zone below is not done. + Source: [docs/port/analog-movement.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/analog-movement.md). Our `input.cpp` replaces the stick vector that `FUN_08872138` writes. Their notes show that **nothing in the walk diff --git a/psprecomp/games/dissidia/docs/steamdeck.md b/psprecomp/games/dissidia/docs/steamdeck.md index b0d9b75..b3c4dbe 100644 --- a/psprecomp/games/dissidia/docs/steamdeck.md +++ b/psprecomp/games/dissidia/docs/steamdeck.md @@ -296,9 +296,11 @@ Input to any of the buttons above if you want them. stick then does nothing in menus), `PSPRECOMP_RSTICK_DEADZONE=0.3` widens the dead zone. Environment variables set in Steam's Launch Options as `PSPRECOMP_CAM_SENS=1.5 %command%` do not work here (the entry is a script, `%command%` is the script); export them in `play.sh` above the `exec` line instead. -* Movement is fully analogue: the game itself only has 8 stick directions (a 78% per-axis dead zone); the port - replaces that with a radial dead zone (`PSPRECOMP_ANALOG_DEADZONE`, default 0.20) so any angle works. - `PSPRECOMP_ANALOG_FULL=0` brings back the original 8-way movement. The Deck's sticks have a hardware dead zone +* Movement: the game itself only has 8 stick directions (a 78% per-axis dead zone). The port uses a radial dead zone + (`PSPRECOMP_ANALOG_DEADZONE`, default 0.20). On the world map the walk follows the stick's own angle; in battle it + stays 8-way in eight even sectors, because battle replays store only those 8 ways (`PSPRECOMP_ANALOG_WALK_BATTLE=1` + steers fighters by the real angle too, `PSPRECOMP_ANALOG_WALK=0` brings back the 8 ways on the world map, + `PSPRECOMP_ANALOG_FULL=0` the original stick code everywhere). The Deck's sticks have a hardware dead zone of their own plus Steam Input's; if drift is a problem raise the radial one. * `PSPRECOMP_GAMECONTROLLERDB=/path/gamecontrollerdb.txt` (or `run.sh --gamecontrollerdb FILE`, or just drop the file in the work directory as `gamecontrollerdb.txt`) loads extra SDL mappings for pads SDL diff --git a/psprecomp/games/dissidia/runtime/input.cpp b/psprecomp/games/dissidia/runtime/input.cpp index 27fa127..bc36b9f 100644 --- a/psprecomp/games/dissidia/runtime/input.cpp +++ b/psprecomp/games/dissidia/runtime/input.cpp @@ -22,6 +22,21 @@ // // PSPRECOMP_ANALOG_FULL=0 restores the original 8-way behaviour. PSPRECOMP_ANALOG_LOG= logs n stick // updates (raw, game vector, replacement). +// +// Walking direction. The vector above is not what steers a walk: the walker's input, ovl_battle FUN_08B38A0C +// (a0 = out, a1 = walker, a2 = its pad, a3 = camera; called each frame from FUN_08B36D2C on the world map and for the +// player's fighter in battle), asks the pad for the four logical walk bits and builds a camera-space step from them +// (sp+0x40: x = +-1, z = +-1, or y with walker+0x5B1 bit 0x20), then turns it by the inverted camera matrix +// (FUN_0885EA88 .. FUN_089A3F40) or copies it (FUN_089A3BC8, walker+0x5B1 bit 0x40) and normalises it. So every walk goes +// one of eight ways whatever the stick says. Found by VCKing101 (https://github.com/VCKing101/Dissidia012-pc, +// docs/port/analog-movement.md, MIT); this is our own code from those notes. +// Fix: while FUN_08B38A0C runs for the LogicalPad of raw[0] (the hardware pad) with the stick pushed, the first of FUN_0885EA88 / FUN_089A3BC8 +// called from its frame rewrites the step at sp+0x40 to the stick's own direction (the pad's +0x20 vector, the radial +// one written above). Everything after it (camera, normalisation, walker+0x5B0 flags from the 8-way bits) is the game's. +// The walk still starts when the game sees a walk bit. World map only by default: a battle replay records just the +// 8-way bits, so a stick-steered fighter would replay elsewhere. PSPRECOMP_ANALOG_WALK=0 turns it off, +// PSPRECOMP_ANALOG_WALK_BATTLE=1 also steers in battle (never while the pads are fed by the online exchange), +// PSPRECOMP_ANALOG_WALK_LOG= logs n replaced steps. #include "psp_game_module.h" #include "recomp.h" @@ -112,8 +127,70 @@ void dissidia_stick_process(uint8_t* rdram, recomp_context* ctx) { wrf(out, ox); wrf(out + 4, oy); wrf(out + 8, 0.f); wrf(out + 12, w); } +// ---- walking direction (see the top of the file) ---- +constexpr uint32_t WALK_INPUT = 0x08B38A0Cu; // ovl_battle +constexpr uint32_t CAM_MATRIX = 0x0885EA88u; // first call after the step is built (camera path) +constexpr uint32_t VEC_COPY = 0x089A3BC8u; // first call after the step is built (no-camera path) +constexpr uint32_t WALK_FRAME = 336u; // FUN_08B38A0C's stack frame; the step is at sp+0x40 +constexpr uint32_t LOGICAL_PAD_VT = 0x089C96E8u, PAD_MGR = 0x08C15B90u, BATTLE_OBJ = 0x089D6A10u; +FuncPtr g_orig_walk = nullptr, g_orig_cam_matrix = nullptr, g_orig_vec_copy = nullptr; +bool g_walk_battle = false; +int g_walk_log = 0; +uint32_t g_walk_sp = 0, g_walk_walker = 0; // set only while an eligible FUN_08B38A0C runs +float g_walk_dx = 0.f, g_walk_dy = 0.f; + +uint32_t rdw(uint32_t a) { uint32_t v; std::memcpy(&v, g_ram + (a & 0x07FFFFFFu), 4); return v; } + +bool walk_eligible(uint32_t pad) { + if (!pad || rdw(pad + 0x34u) != LOGICAL_PAD_VT) return false; // a CPU brain's or the null pad: the game's way + if ((rdw(pad + 0x44u) & 1u) || !rdw(pad + 0x4Cu)) return false; // disabled, or no action map + if (rdw(PAD_MGR + 0x264u) & 3u) return false; // replay playback / muted + const uint32_t src = rdw(pad + 0x40u); + if (src != PAD_MGR) return false; // only the pad read from the hardware (raw[0]): not a CPU's + if (rdw(src + 0x50u) == 1u) return false; // raw[0] fed by the online exchange or a replay + const uint32_t bo = rdw(BATTLE_OBJ); + const bool battle = bo && (rdw(bo + 0x38u) || rdw(bo + 0x3Cu)); // the world map's battle object has no fighters + if (battle && !g_walk_battle) return false; + return rdf(pad + 0x2Cu) > 0.f; // stick past the radial dead zone +} + +void walk_input_hook(uint8_t* rdram, recomp_context* ctx) { + const uint32_t pad = static_cast(ctx->r[6]); + if (!walk_eligible(pad)) { g_orig_walk(rdram, ctx); return; } + const uint32_t prev_sp = g_walk_sp, prev_walker = g_walk_walker; + const float pdx = g_walk_dx, pdy = g_walk_dy; + g_walk_sp = static_cast(ctx->r[29]) - WALK_FRAME; + g_walk_walker = static_cast(ctx->r[5]); + g_walk_dx = rdf(pad + 0x20u); g_walk_dy = rdf(pad + 0x24u); + g_orig_walk(rdram, ctx); + g_walk_sp = prev_sp; g_walk_walker = prev_walker; g_walk_dx = pdx; g_walk_dy = pdy; +} + +// Called at the first of FUN_0885EA88 / FUN_089A3BC8 from the walk's own frame: the step is complete at sp+0x40. +void walk_replace_step(const recomp_context* ctx) { + if (!g_walk_sp || static_cast(ctx->r[29]) != g_walk_sp) return; + const uint32_t v = g_walk_sp + 0x40u; + const float x = rdf(v), y = rdf(v + 4), z = rdf(v + 8); + if (x == 0.f && y == 0.f && z == 0.f) return; // not walking this frame + const bool vertical = (g_ram[(g_walk_walker + 0x5B1u) & 0x07FFFFFFu] & 0x20u) != 0; + const float nx = g_walk_dx, nf = g_walk_dy; // stick: x right, y down = towards the camera + if (g_walk_log > 0) { + g_walk_log--; + std::fprintf(stderr, "[WALK] walker=%08X step (%.0f,%.0f,%.0f) -> (%.3f,%.3f,%.3f) stick angle %.1f\n", g_walk_walker, x, y, z, + nx, vertical ? -nf : 0.f, vertical ? 0.f : nf, std::atan2(nx, -nf) * 57.29578f); + } + wrf(v, nx); + if (vertical) { wrf(v + 4, -nf); wrf(v + 8, 0.f); } else { wrf(v + 4, 0.f); wrf(v + 8, nf); } + g_walk_sp = 0; // once per walk call +} + +void cam_matrix_hook(uint8_t* rdram, recomp_context* ctx) { walk_replace_step(ctx); g_orig_cam_matrix(rdram, ctx); } +void vec_copy_hook(uint8_t* rdram, recomp_context* ctx) { walk_replace_step(ctx); g_orig_vec_copy(rdram, ctx); } + } // namespace +extern FuncPtr ovl_battle_lookup(uint32_t vaddr); + void dissidia_input_install(uint8_t* rdram) { const char* e = std::getenv("PSPRECOMP_ANALOG_FULL"); if (e && e[0] == '0') { std::fprintf(stderr, "[INPUT] analogue stick: original 8-way processing (PSPRECOMP_ANALOG_FULL=0)\n"); return; } @@ -129,4 +206,16 @@ void dissidia_input_install(uint8_t* rdram) { if (!g_orig) { std::fprintf(stderr, "[INPUT] stick hook NOT installed\n"); return; } psp_dispatch_register(STICK_PROCESS, dissidia_stick_process); std::fprintf(stderr, "[INPUT] continuous analogue stick direction (dead zone %.2f)\n", g_dz); + + if ((e = std::getenv("PSPRECOMP_ANALOG_WALK")) && e[0] == '0') { std::fprintf(stderr, "[INPUT] walking: original 8 ways\n"); return; } + if ((e = std::getenv("PSPRECOMP_ANALOG_WALK_BATTLE"))) g_walk_battle = e[0] == '1'; + if ((e = std::getenv("PSPRECOMP_ANALOG_WALK_LOG"))) g_walk_log = std::atoi(e); + g_orig_walk = ovl_battle_lookup(WALK_INPUT); + g_orig_cam_matrix = psp_dispatch_probe_lookup(CAM_MATRIX); + g_orig_vec_copy = psp_dispatch_probe_lookup(VEC_COPY); + if (!g_orig_walk || !g_orig_cam_matrix || !g_orig_vec_copy) { std::fprintf(stderr, "[INPUT] walk hook NOT installed\n"); return; } + psp_dispatch_register(WALK_INPUT, walk_input_hook); + psp_dispatch_register(CAM_MATRIX, cam_matrix_hook); + psp_dispatch_register(VEC_COPY, vec_copy_hook); + std::fprintf(stderr, "[INPUT] analogue walking direction (world map%s)\n", g_walk_battle ? " and battle" : ""); } diff --git a/psprecomp/runtime/src/psp_env_options.inc b/psprecomp/runtime/src/psp_env_options.inc index e195704..c6666a9 100644 --- a/psprecomp/runtime/src/psp_env_options.inc +++ b/psprecomp/runtime/src/psp_env_options.inc @@ -61,6 +61,8 @@ const EnvOpt k_env_opts[] = { {"ANALOG_8WAY", EC_INPUT, 'k', "", "In battle, run the game's original stick code on a square-gate stick for eight even sectors."}, {"ANALOG_DEADZONE", EC_INPUT, 'c', "0.1|0.15|0.3", "Left stick dead zone, as a fraction of full travel (default 0.20)."}, {"ANALOG_DPAD_ZONE", EC_INPUT, 'c', "0.25|0.45|0.55", "Stick travel at which a direction counts as a D-pad press in battle (default 0.35)."}, + {"ANALOG_WALK", EC_INPUT, 'k', "", "Walk in the stick's own direction on the world map. Off: one of eight ways, as on the PSP."}, + {"ANALOG_WALK_BATTLE", EC_INPUT, 'e', "", "Also steer fighters in the stick's own direction in battle (saved replays then play back differently)."}, {"RSTICK_DPAD", EC_INPUT, 'k', "", "Right stick presses the D-pad (menus, selecting). Off: it does nothing."}, {"RSTICK_DEADZONE", EC_INPUT, 'c', "0.1|0.3|0.4", "Right stick dead zone, as a fraction of full travel (default 0.20)."}, {"ARROWS_DPAD_ONLY", EC_INPUT, 'e', "", "Keyboard arrow keys press only the D-pad, not the left stick as well."}, @@ -224,6 +226,7 @@ const EnvOpt k_env_opts[] = { {"STAGE_LOG", EC_LOG_GAME, 'e', "", "Log the stage id as stages load."}, {"FEP_LOG_SKIN", EC_LOG_GAME, 'e', "", "With the effect-draw log: also log skinned draws."}, {"ANALOG_LOG", EC_LOG_GAME, 'c', "50|500", "Log this many stick samples."}, + {"ANALOG_WALK_LOG", EC_LOG_GAME, 'c', "20|200", "Log this many walk steps turned to the stick's direction."}, {"PAD_LOG", EC_LOG_GAME, 'e', "", "Log pad connects and button mapping."}, {"CTRL_LOG", EC_LOG_GAME, 'e', "", "Log which game code polls the pad."}, {"TOUCH_LOG", EC_LOG_GAME, 'e', "", "Log touch input."}, From 6224024fb37737cacc6706467e72e4b8de942635 Mon Sep 17 00:00:00 2001 From: Schindler Date: Wed, 18 Nov 2026 15:09:18 -0500 Subject: [PATCH 3/5] World map camera follow dead zone for the analogue walk The world map's free camera (ovl_battle FUN_08B3F7F4) turns toward the walker's facing with no dead zone, so with the walk at the stick's own angle a push a few degrees off straight up spins the camera. While the follow runs for the walker whose last step was the analogue one, its atan2 result (FUN_089A457C on the walker's facing) is moved: no turn within PSPRECOMP_ANALOG_FOLLOW_ZONE degrees (default 22.5, 0 = game), a ramp to the cap over half the zone, the game's follow beyond. Measured with PSPRECOMP_CAM_UNLOCK_HOLD=0, 15 degree push: 186 degrees of turn in 1.75 s without the zone, a straight walk with it. With camera.cpp's hold camera (the default) the spin was already hidden; the zone covers the rest. Design from VCKing101's notes (docs/port/analog-movement.md section 7, MIT): https://github.com/VCKing101/Dissidia012-pc Co-Authored-By: Claude Opus 5.5 --- psprecomp/games/dissidia/docs/native-build.md | 10 +++ .../games/dissidia/docs/related-projects.md | 2 +- psprecomp/games/dissidia/runtime/input.cpp | 73 +++++++++++++++++++ psprecomp/runtime/src/psp_env_options.inc | 2 + 4 files changed, 86 insertions(+), 1 deletion(-) diff --git a/psprecomp/games/dissidia/docs/native-build.md b/psprecomp/games/dissidia/docs/native-build.md index b327201..4289407 100644 --- a/psprecomp/games/dissidia/docs/native-build.md +++ b/psprecomp/games/dissidia/docs/native-build.md @@ -145,3 +145,13 @@ straight push, 15, -15 and 30 degrees of stick turned the walk by 14.8, 15.0 and headings jump by 20 to 45 degrees. In battle the step is replaced too, but the fighter's heading moved only 2 to 6 degrees for a 15 degree push and drifted back to the line to the opponent (battle_test, Squall, stage 12): battle movement has more steering after this step, so `PSPRECOMP_ANALOG_WALK_BATTLE` is experimental. + +Camera follow dead zone: the world map's free camera (`ovl_battle FUN_08B3F7F4`) turns toward the walker's facing by up to 0.05 rad a +frame with no dead zone. With the walk at the stick's own angle, a push a few degrees off straight up then turns the camera, the +camera-relative walk turns with it, and the camera spins (VCKing101's measurement; here with `PSPRECOMP_CAM_UNLOCK_HOLD=0` and no +zone, a 15 degree push turned the walk 186 degrees in 1.75 s). `input.cpp` moves the follow's atan2 result (`FUN_089A457C`, only the +call on the walker's facing) so the follow does not turn within `PSPRECOMP_ANALOG_FOLLOW_ZONE` degrees (default 22.5, 0 = the game's +follow), ramps up to the cap over half the zone, and is the game's beyond that; only while the walker's last step was the analogue +one. With it the same push walked straight. Normally `camera.cpp`'s hold camera is active on the world map too (no lock-on target): +it keeps the view and turns the stick by the game camera's turn, which already hides the spin; the zone covers the cases without it +(`PSPRECOMP_CAM_UNLOCK_HOLD=0`, `PSPRECOMP_CAM_FREE=0`). `PSPRECOMP_ANALOG_FOLLOW_LOG=` logs reduced follow turns. diff --git a/psprecomp/games/dissidia/docs/related-projects.md b/psprecomp/games/dissidia/docs/related-projects.md index 4e33fa6..c4e0542 100644 --- a/psprecomp/games/dissidia/docs/related-projects.md +++ b/psprecomp/games/dissidia/docs/related-projects.md @@ -27,7 +27,7 @@ comment it lands in. Use a link to the repo and the file it came from. ### 1. Analogue walking: the direction is still 8-way (bug in ours) **Done for the world map** (18 November 2026, `runtime/input.cpp`, [native-build.md](native-build.md)); battle is opt-in and only -partly steered. The camera follow dead zone below is not done. +partly steered. The camera follow dead zone below is done too (same file). Source: [docs/port/analog-movement.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/analog-movement.md). diff --git a/psprecomp/games/dissidia/runtime/input.cpp b/psprecomp/games/dissidia/runtime/input.cpp index bc36b9f..48350d5 100644 --- a/psprecomp/games/dissidia/runtime/input.cpp +++ b/psprecomp/games/dissidia/runtime/input.cpp @@ -37,10 +37,20 @@ // 8-way bits, so a stick-steered fighter would replay elsewhere. PSPRECOMP_ANALOG_WALK=0 turns it off, // PSPRECOMP_ANALOG_WALK_BATTLE=1 also steers in battle (never while the pads are fed by the online exchange), // PSPRECOMP_ANALOG_WALK_LOG= logs n replaced steps. +// +// Camera follow. The world map's free camera (ovl_battle FUN_08B3F7F4: a0 = yaw block, yaw at +8; a1 = camera, owner at +248) +// turns its yaw toward the walker's facing (owner+0x90, through the atan2 FUN_089A457C) by up to the row's cap (0.05 rad) a frame, +// with no dead zone. With the 8-way walk a push near straight up walked straight up; with the stick's own angle the facing is a few +// degrees off, the camera turns, the camera-relative walk turns with it and the camera spins (VCKing101 measured 172 deg/s for a +// 15 degree push, docs/port/analog-movement.md section 7). Fix, as theirs: while the follow runs for the walker whose last walk step +// was ours, its atan2 result is moved so that the angle it turns toward is 0 within PSPRECOMP_ANALOG_FOLLOW_ZONE degrees of straight +// ahead (default 22.5, 0 = the game's follow), rises to the cap over a ramp of half the zone, and is the game's beyond that. Straight +// back, the sides and diagonals turn as in the game. #include "psp_game_module.h" #include "recomp.h" #include "hle/psp_hle.h" +#include #include #include #include @@ -138,6 +148,8 @@ bool g_walk_battle = false; int g_walk_log = 0; uint32_t g_walk_sp = 0, g_walk_walker = 0; // set only while an eligible FUN_08B38A0C runs float g_walk_dx = 0.f, g_walk_dy = 0.f; +uint32_t g_last_walker = 0; // walker of the last FUN_08B38A0C call, and whether its step was ours +bool g_last_walk_analog = false; uint32_t rdw(uint32_t a) { uint32_t v; std::memcpy(&v, g_ram + (a & 0x07FFFFFFu), 4); return v; } @@ -156,6 +168,8 @@ bool walk_eligible(uint32_t pad) { void walk_input_hook(uint8_t* rdram, recomp_context* ctx) { const uint32_t pad = static_cast(ctx->r[6]); + g_last_walker = static_cast(ctx->r[5]); + g_last_walk_analog = false; if (!walk_eligible(pad)) { g_orig_walk(rdram, ctx); return; } const uint32_t prev_sp = g_walk_sp, prev_walker = g_walk_walker; const float pdx = g_walk_dx, pdy = g_walk_dy; @@ -182,6 +196,54 @@ void walk_replace_step(const recomp_context* ctx) { wrf(v, nx); if (vertical) { wrf(v + 4, -nf); wrf(v + 8, 0.f); } else { wrf(v + 4, 0.f); wrf(v + 8, nf); } g_walk_sp = 0; // once per walk call + g_last_walk_analog = true; +} + +// ---- camera follow dead zone ---- +constexpr uint32_t FREE_CAM_INPUT = 0x08B3F7F4u; // ovl_battle +constexpr uint32_t ATAN2 = 0x089A457Cu; // f0 = atan2(f12, f13) +FuncPtr g_orig_free_input = nullptr, g_orig_atan2 = nullptr; +float g_follow_zone = 22.5f * 0.017453293f; +uint32_t g_follow_owner = 0, g_follow_yaw = 0; // set while FUN_08B3F7F4 runs for that walker +int g_follow_log = 0; + +void free_input_hook(uint8_t* rdram, recomp_context* ctx) { + const uint32_t yaw_blk = static_cast(ctx->r[4]), cam = static_cast(ctx->r[5]); + const uint32_t owner = cam ? rdw(cam + 248u) : 0; + if (!owner || owner != g_last_walker || !g_last_walk_analog) { g_orig_free_input(rdram, ctx); return; } + g_follow_owner = owner; g_follow_yaw = yaw_blk; + g_orig_free_input(rdram, ctx); + g_follow_owner = 0; g_follow_yaw = 0; +} + +float wrap_pi(float a) { + const float two_pi = 6.2831853f; + while (a > 3.14159265f) a -= two_pi; + while (a <= -3.14159265f) a += two_pi; + return a; +} + +void atan2_hook(uint8_t* rdram, recomp_context* ctx) { + if (!g_follow_owner) { g_orig_atan2(rdram, ctx); return; } + // Only the follow's own call: atan2(-facing.x, -facing.z) of the owner. + const float a = ctx->f[12], b = ctx->f[13]; + const bool follow = a == -rdf(g_follow_owner + 0x90u) && b == -rdf(g_follow_owner + 0x98u); + g_orig_atan2(rdram, ctx); + if (!follow) return; + const float yaw = rdf(g_follow_yaw + 8u), target = ctx->f[0]; + const float diff = wrap_pi(target - yaw), ad = std::fabs(diff); + float cap = rdf(static_cast(ctx->r[18]) + 32u); // the follow's per-frame cap (read the same way right after this call) + if (!(cap > 0.f && cap < 1.f)) cap = 0.05f; + const float ramp = std::max(g_follow_zone * 0.5f, cap); + float fed = diff; + if (ad <= g_follow_zone) fed = 0.f; + else if (ad < g_follow_zone + ramp) fed = std::copysign(cap * (ad - g_follow_zone) / ramp, diff); + if (g_follow_log > 0 && fed != diff) { + g_follow_log--; + std::fprintf(stderr, "[FOLLOW] yaw %.1f target %.1f diff %.2f -> %.2f deg (cap %.2f)\n", yaw * 57.29578f, target * 57.29578f, + diff * 57.29578f, fed * 57.29578f, cap * 57.29578f); + } + ctx->f[0] = yaw + fed; } void cam_matrix_hook(uint8_t* rdram, recomp_context* ctx) { walk_replace_step(ctx); g_orig_cam_matrix(rdram, ctx); } @@ -218,4 +280,15 @@ void dissidia_input_install(uint8_t* rdram) { psp_dispatch_register(CAM_MATRIX, cam_matrix_hook); psp_dispatch_register(VEC_COPY, vec_copy_hook); std::fprintf(stderr, "[INPUT] analogue walking direction (world map%s)\n", g_walk_battle ? " and battle" : ""); + + if ((e = std::getenv("PSPRECOMP_ANALOG_FOLLOW_ZONE"))) g_follow_zone = static_cast(std::atof(e)) * 0.017453293f; + if (g_follow_zone > 60.f * 0.017453293f) g_follow_zone = 60.f * 0.017453293f; + if ((e = std::getenv("PSPRECOMP_ANALOG_FOLLOW_LOG"))) g_follow_log = std::atoi(e); + if (g_follow_zone <= 0.f) return; + g_orig_free_input = ovl_battle_lookup(FREE_CAM_INPUT); + g_orig_atan2 = psp_dispatch_probe_lookup(ATAN2); + if (!g_orig_free_input || !g_orig_atan2) { std::fprintf(stderr, "[INPUT] camera follow zone NOT installed\n"); return; } + psp_dispatch_register(FREE_CAM_INPUT, free_input_hook); + psp_dispatch_register(ATAN2, atan2_hook); + std::fprintf(stderr, "[INPUT] camera follow dead zone %.1f deg for the analogue walk\n", g_follow_zone * 57.29578f); } diff --git a/psprecomp/runtime/src/psp_env_options.inc b/psprecomp/runtime/src/psp_env_options.inc index c6666a9..dfb6da5 100644 --- a/psprecomp/runtime/src/psp_env_options.inc +++ b/psprecomp/runtime/src/psp_env_options.inc @@ -63,6 +63,7 @@ const EnvOpt k_env_opts[] = { {"ANALOG_DPAD_ZONE", EC_INPUT, 'c', "0.25|0.45|0.55", "Stick travel at which a direction counts as a D-pad press in battle (default 0.35)."}, {"ANALOG_WALK", EC_INPUT, 'k', "", "Walk in the stick's own direction on the world map. Off: one of eight ways, as on the PSP."}, {"ANALOG_WALK_BATTLE", EC_INPUT, 'e', "", "Also steer fighters in the stick's own direction in battle (saved replays then play back differently)."}, + {"ANALOG_FOLLOW_ZONE", EC_INPUT, 'c', "0|10|35", "World map camera: degrees either side of straight ahead in which it does not turn after the walker (default 22.5; 0 = the game's follow)."}, {"RSTICK_DPAD", EC_INPUT, 'k', "", "Right stick presses the D-pad (menus, selecting). Off: it does nothing."}, {"RSTICK_DEADZONE", EC_INPUT, 'c', "0.1|0.3|0.4", "Right stick dead zone, as a fraction of full travel (default 0.20)."}, {"ARROWS_DPAD_ONLY", EC_INPUT, 'e', "", "Keyboard arrow keys press only the D-pad, not the left stick as well."}, @@ -227,6 +228,7 @@ const EnvOpt k_env_opts[] = { {"FEP_LOG_SKIN", EC_LOG_GAME, 'e', "", "With the effect-draw log: also log skinned draws."}, {"ANALOG_LOG", EC_LOG_GAME, 'c', "50|500", "Log this many stick samples."}, {"ANALOG_WALK_LOG", EC_LOG_GAME, 'c', "20|200", "Log this many walk steps turned to the stick's direction."}, + {"ANALOG_FOLLOW_LOG", EC_LOG_GAME, 'c', "20|200", "Log this many world map camera follow turns reduced by the dead zone."}, {"PAD_LOG", EC_LOG_GAME, 'e', "", "Log pad connects and button mapping."}, {"CTRL_LOG", EC_LOG_GAME, 'e', "", "Log which game code polls the pad."}, {"TOUCH_LOG", EC_LOG_GAME, 'e', "", "Log touch input."}, From a5f3c086db2ddd2ad5a0de9977af9dc7d21859f5 Mon Sep 17 00:00:00 2001 From: Schindler Date: Thu, 19 Nov 2026 00:04:59 -0500 Subject: [PATCH 4/5] Analogue walking in battle too, on by default A per-frame log of the walk's world output (PSPRECOMP_ANALOG_WALK_OUTLOG) shows battle is fully steered: stick 0 -> 15 degrees turned the walk direction 15.6 degrees and the fighter moved along it to within 1-3 degrees a frame; the 8-way walk stayed on one direction for 0, 15 and -15. The earlier 2-6 degree figure came from comparing separate runs, which the lock-on camera's orbit and the dummy's varying spot make meaningless. On by default; PSPRECOMP_ANALOG_WALK_BATTLE=0 keeps battle 8-way (saved battle replays record only the 8-way bits). Pads fed by the online exchange or a replay are never steered. Co-Authored-By: Claude Opus 5.5 --- psprecomp/games/dissidia/docs/native-build.md | 20 +++++++------ .../games/dissidia/docs/related-projects.md | 4 +-- psprecomp/games/dissidia/docs/steamdeck.md | 7 ++--- psprecomp/games/dissidia/runtime/input.cpp | 28 ++++++++++++++----- psprecomp/runtime/src/psp_env_options.inc | 4 +-- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/psprecomp/games/dissidia/docs/native-build.md b/psprecomp/games/dissidia/docs/native-build.md index 4289407..536f7ef 100644 --- a/psprecomp/games/dissidia/docs/native-build.md +++ b/psprecomp/games/dissidia/docs/native-build.md @@ -136,15 +136,17 @@ original 8-way behaviour, `PSPRECOMP_ANALOG_DEADZONE` (default 0.20 of travel) s Walking direction: the stick vector above is not what steers a walk. The walker's input (`ovl_battle FUN_08B38A0C`, on the world map and for the player's fighter in battle) builds its step from the four walk bits only, so even with the changes above every walk went one of eight ways (found by VCKing101, [related-projects.md](related-projects.md)). `input.cpp` turns that step to the stick's own direction -just before the game applies the camera to it, for a human pad with the stick past the dead zone; when the walk starts, the walk speed -and everything after it stay the game's. World map only by default: a battle replay stores just the 8-way bits, so a stick-steered -fighter would play back elsewhere. `PSPRECOMP_ANALOG_WALK=0` turns it off, `PSPRECOMP_ANALOG_WALK_BATTLE=1` also steers in battle (never -while the pads are fed by the game's online exchange), `PSPRECOMP_ANALOG_WALK_LOG=` logs n replaced steps. -Measured 18 November 2026 (Story Mode prologue field, debug socket `A` pushes of 0.4 s, walker position at `+0x110`): relative to a -straight push, 15, -15 and 30 degrees of stick turned the walk by 14.8, 15.0 and 30.2 degrees; with `PSPRECOMP_ANALOG_WALK=0` the -headings jump by 20 to 45 degrees. In battle the step is replaced too, but the fighter's heading moved only 2 to 6 degrees for a -15 degree push and drifted back to the line to the opponent (battle_test, Squall, stage 12): battle movement has more steering after -this step, so `PSPRECOMP_ANALOG_WALK_BATTLE` is experimental. +just before the game applies the camera to it, for the hardware pad's walker with the stick past the dead zone; when the walk starts, the +walk speed and everything after it stay the game's. On the world map and in battle; never while the pads are fed by the game's online +exchange or a replay. A saved battle replay stores just the 8-way bits, so a fight steered by the stick can play back a little +differently; `PSPRECOMP_ANALOG_WALK_BATTLE=0` keeps battle 8-way (and replays exact). `PSPRECOMP_ANALOG_WALK=0` turns it all off, +`PSPRECOMP_ANALOG_WALK_LOG=` logs n replaced steps, `PSPRECOMP_ANALOG_WALK_OUTLOG=` the walk's world-space output. +Measured 18-19 November 2026: on the prologue field (debug socket `A` pushes of 0.4 s, walker position at `+0x110`) 15, -15 and 30 +degrees of stick turned the walk by 14.8, 15.0 and 30.2 degrees against a straight push, where the 8-way walk jumps by 20 to 45. In +battle (battle_test, Squall, stage 12, stick 0 then 15 degrees) the walk's world direction turned 15.6 degrees and the fighter moved +along it to within 1 to 3 degrees a frame (more while the body turns); with the 8-way walk it stayed on one direction for 0, 15 and -15. +Comparing world headings between separate battle runs does not work: the lock-on camera orbits the opponent, and the dummy stands +somewhere else each run. Camera follow dead zone: the world map's free camera (`ovl_battle FUN_08B3F7F4`) turns toward the walker's facing by up to 0.05 rad a frame with no dead zone. With the walk at the stick's own angle, a push a few degrees off straight up then turns the camera, the diff --git a/psprecomp/games/dissidia/docs/related-projects.md b/psprecomp/games/dissidia/docs/related-projects.md index c4e0542..e219af1 100644 --- a/psprecomp/games/dissidia/docs/related-projects.md +++ b/psprecomp/games/dissidia/docs/related-projects.md @@ -26,8 +26,8 @@ comment it lands in. Use a link to the repo and the file it came from. ### 1. Analogue walking: the direction is still 8-way (bug in ours) -**Done for the world map** (18 November 2026, `runtime/input.cpp`, [native-build.md](native-build.md)); battle is opt-in and only -partly steered. The camera follow dead zone below is done too (same file). +**Done** for the world map and battle (18-19 November 2026, `runtime/input.cpp`, [native-build.md](native-build.md)); battle replays +may play back a little differently. The camera follow dead zone below is done too (same file). Source: [docs/port/analog-movement.md](https://github.com/VCKing101/Dissidia012-pc/blob/main/docs/port/analog-movement.md). diff --git a/psprecomp/games/dissidia/docs/steamdeck.md b/psprecomp/games/dissidia/docs/steamdeck.md index b3c4dbe..c718e41 100644 --- a/psprecomp/games/dissidia/docs/steamdeck.md +++ b/psprecomp/games/dissidia/docs/steamdeck.md @@ -297,10 +297,9 @@ Input to any of the buttons above if you want them. Environment variables set in Steam's Launch Options as `PSPRECOMP_CAM_SENS=1.5 %command%` do not work here (the entry is a script, `%command%` is the script); export them in `play.sh` above the `exec` line instead. * Movement: the game itself only has 8 stick directions (a 78% per-axis dead zone). The port uses a radial dead zone - (`PSPRECOMP_ANALOG_DEADZONE`, default 0.20). On the world map the walk follows the stick's own angle; in battle it - stays 8-way in eight even sectors, because battle replays store only those 8 ways (`PSPRECOMP_ANALOG_WALK_BATTLE=1` - steers fighters by the real angle too, `PSPRECOMP_ANALOG_WALK=0` brings back the 8 ways on the world map, - `PSPRECOMP_ANALOG_FULL=0` the original stick code everywhere). The Deck's sticks have a hardware dead zone + (`PSPRECOMP_ANALOG_DEADZONE`, default 0.20) and walks and fights in the stick's own direction + (`PSPRECOMP_ANALOG_WALK_BATTLE=0` keeps battle 8-way, which saved battle replays need to play back exactly; + `PSPRECOMP_ANALOG_WALK=0` the 8 ways everywhere, `PSPRECOMP_ANALOG_FULL=0` the original stick code). The Deck's sticks have a hardware dead zone of their own plus Steam Input's; if drift is a problem raise the radial one. * `PSPRECOMP_GAMECONTROLLERDB=/path/gamecontrollerdb.txt` (or `run.sh --gamecontrollerdb FILE`, or just drop the file in the work directory as `gamecontrollerdb.txt`) loads extra SDL mappings for pads SDL diff --git a/psprecomp/games/dissidia/runtime/input.cpp b/psprecomp/games/dissidia/runtime/input.cpp index 48350d5..8a7e222 100644 --- a/psprecomp/games/dissidia/runtime/input.cpp +++ b/psprecomp/games/dissidia/runtime/input.cpp @@ -33,10 +33,10 @@ // Fix: while FUN_08B38A0C runs for the LogicalPad of raw[0] (the hardware pad) with the stick pushed, the first of FUN_0885EA88 / FUN_089A3BC8 // called from its frame rewrites the step at sp+0x40 to the stick's own direction (the pad's +0x20 vector, the radial // one written above). Everything after it (camera, normalisation, walker+0x5B0 flags from the 8-way bits) is the game's. -// The walk still starts when the game sees a walk bit. World map only by default: a battle replay records just the -// 8-way bits, so a stick-steered fighter would replay elsewhere. PSPRECOMP_ANALOG_WALK=0 turns it off, -// PSPRECOMP_ANALOG_WALK_BATTLE=1 also steers in battle (never while the pads are fed by the online exchange), -// PSPRECOMP_ANALOG_WALK_LOG= logs n replaced steps. +// The walk still starts when the game sees a walk bit. On the world map and in battle (never while the pads are fed by +// the online exchange or a replay). A saved battle replay records just the 8-way bits, so a fight steered by the stick +// can play back a little differently. PSPRECOMP_ANALOG_WALK=0 turns it off, PSPRECOMP_ANALOG_WALK_BATTLE=0 keeps battle +// 8-way, PSPRECOMP_ANALOG_WALK_LOG= logs n replaced steps, PSPRECOMP_ANALOG_WALK_OUTLOG= the walk's world output. // // Camera follow. The world map's free camera (ovl_battle FUN_08B3F7F4: a0 = yaw block, yaw at +8; a1 = camera, owner at +248) // turns its yaw toward the walker's facing (owner+0x90, through the atan2 FUN_089A457C) by up to the row's cap (0.05 rad) a frame, @@ -144,7 +144,7 @@ constexpr uint32_t VEC_COPY = 0x089A3BC8u; // first call after the step is constexpr uint32_t WALK_FRAME = 336u; // FUN_08B38A0C's stack frame; the step is at sp+0x40 constexpr uint32_t LOGICAL_PAD_VT = 0x089C96E8u, PAD_MGR = 0x08C15B90u, BATTLE_OBJ = 0x089D6A10u; FuncPtr g_orig_walk = nullptr, g_orig_cam_matrix = nullptr, g_orig_vec_copy = nullptr; -bool g_walk_battle = false; +bool g_walk_battle = true; int g_walk_log = 0; uint32_t g_walk_sp = 0, g_walk_walker = 0; // set only while an eligible FUN_08B38A0C runs float g_walk_dx = 0.f, g_walk_dy = 0.f; @@ -166,11 +166,23 @@ bool walk_eligible(uint32_t pad) { return rdf(pad + 0x2Cu) > 0.f; // stick past the radial dead zone } +// PSPRECOMP_ANALOG_WALK_OUTLOG=: the walk's world-space output for the hardware pad's walker, hook on or off (diagnostics). +int g_out_log = 0; +void walk_log_out(uint32_t pad, uint32_t out) { + if (g_out_log <= 0 || !pad || rdw(pad + 0x40u) != PAD_MGR) return; + const float x = rdf(out), z = rdf(out + 8); + if (x == 0.f && z == 0.f) return; + g_out_log--; + std::fprintf(stderr, "[WALKOUT] walker=%08X out=(%.3f,%.3f) heading %.1f analog=%d\n", g_last_walker, x, z, + std::atan2(x, z) * 57.29578f, (int)g_last_walk_analog); +} + void walk_input_hook(uint8_t* rdram, recomp_context* ctx) { const uint32_t pad = static_cast(ctx->r[6]); + const uint32_t out_vec = static_cast(ctx->r[4]); g_last_walker = static_cast(ctx->r[5]); g_last_walk_analog = false; - if (!walk_eligible(pad)) { g_orig_walk(rdram, ctx); return; } + if (!walk_eligible(pad)) { g_orig_walk(rdram, ctx); walk_log_out(pad, out_vec); return; } const uint32_t prev_sp = g_walk_sp, prev_walker = g_walk_walker; const float pdx = g_walk_dx, pdy = g_walk_dy; g_walk_sp = static_cast(ctx->r[29]) - WALK_FRAME; @@ -178,6 +190,7 @@ void walk_input_hook(uint8_t* rdram, recomp_context* ctx) { g_walk_dx = rdf(pad + 0x20u); g_walk_dy = rdf(pad + 0x24u); g_orig_walk(rdram, ctx); g_walk_sp = prev_sp; g_walk_walker = prev_walker; g_walk_dx = pdx; g_walk_dy = pdy; + walk_log_out(pad, out_vec); } // Called at the first of FUN_0885EA88 / FUN_089A3BC8 from the walk's own frame: the step is complete at sp+0x40. @@ -270,8 +283,9 @@ void dissidia_input_install(uint8_t* rdram) { std::fprintf(stderr, "[INPUT] continuous analogue stick direction (dead zone %.2f)\n", g_dz); if ((e = std::getenv("PSPRECOMP_ANALOG_WALK")) && e[0] == '0') { std::fprintf(stderr, "[INPUT] walking: original 8 ways\n"); return; } - if ((e = std::getenv("PSPRECOMP_ANALOG_WALK_BATTLE"))) g_walk_battle = e[0] == '1'; + if ((e = std::getenv("PSPRECOMP_ANALOG_WALK_BATTLE"))) g_walk_battle = e[0] != '0'; if ((e = std::getenv("PSPRECOMP_ANALOG_WALK_LOG"))) g_walk_log = std::atoi(e); + if ((e = std::getenv("PSPRECOMP_ANALOG_WALK_OUTLOG"))) g_out_log = std::atoi(e); g_orig_walk = ovl_battle_lookup(WALK_INPUT); g_orig_cam_matrix = psp_dispatch_probe_lookup(CAM_MATRIX); g_orig_vec_copy = psp_dispatch_probe_lookup(VEC_COPY); diff --git a/psprecomp/runtime/src/psp_env_options.inc b/psprecomp/runtime/src/psp_env_options.inc index dfb6da5..d6fc984 100644 --- a/psprecomp/runtime/src/psp_env_options.inc +++ b/psprecomp/runtime/src/psp_env_options.inc @@ -61,8 +61,8 @@ const EnvOpt k_env_opts[] = { {"ANALOG_8WAY", EC_INPUT, 'k', "", "In battle, run the game's original stick code on a square-gate stick for eight even sectors."}, {"ANALOG_DEADZONE", EC_INPUT, 'c', "0.1|0.15|0.3", "Left stick dead zone, as a fraction of full travel (default 0.20)."}, {"ANALOG_DPAD_ZONE", EC_INPUT, 'c', "0.25|0.45|0.55", "Stick travel at which a direction counts as a D-pad press in battle (default 0.35)."}, - {"ANALOG_WALK", EC_INPUT, 'k', "", "Walk in the stick's own direction on the world map. Off: one of eight ways, as on the PSP."}, - {"ANALOG_WALK_BATTLE", EC_INPUT, 'e', "", "Also steer fighters in the stick's own direction in battle (saved replays then play back differently)."}, + {"ANALOG_WALK", EC_INPUT, 'k', "", "Move in the stick's own direction on the world map and in battle. Off: one of eight ways, as on the PSP."}, + {"ANALOG_WALK_BATTLE", EC_INPUT, 'k', "", "In battle too. Off: fighters move one of eight ways (saved battle replays then play back exactly)."}, {"ANALOG_FOLLOW_ZONE", EC_INPUT, 'c', "0|10|35", "World map camera: degrees either side of straight ahead in which it does not turn after the walker (default 22.5; 0 = the game's follow)."}, {"RSTICK_DPAD", EC_INPUT, 'k', "", "Right stick presses the D-pad (menus, selecting). Off: it does nothing."}, {"RSTICK_DEADZONE", EC_INPUT, 'c', "0.1|0.3|0.4", "Right stick dead zone, as a fraction of full travel (default 0.20)."}, From 3b5387ff94ad66d147d57b9a18bd2b9ae7f81a7b Mon Sep 17 00:00:00 2001 From: Schindler Date: Thu, 19 Nov 2026 00:44:51 -0500 Subject: [PATCH 5/5] World map camera: no follow for walks with the stick (right stick turns it) Asked for: the left stick swung the world map camera left and right as the game's follow turned it after the walker. PSPRECOMP_ANALOG_FOLLOW_ZONE now defaults to 180 degrees (never turns after a stick walk); 22.5 is the earlier zone, 0 the game's follow. D-pad walks keep the game's follow. Checked with PSPRECOMP_CAM_UNLOCK_HOLD=0, stick held at 90 degrees: game's follow 227 degrees of turn in 1.5 s, now a straight walk. Co-Authored-By: Claude Opus 5.5 --- psprecomp/games/dissidia/docs/native-build.md | 7 ++++--- psprecomp/games/dissidia/runtime/input.cpp | 12 +++++++----- psprecomp/runtime/src/psp_env_options.inc | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/psprecomp/games/dissidia/docs/native-build.md b/psprecomp/games/dissidia/docs/native-build.md index 536f7ef..09ee5ec 100644 --- a/psprecomp/games/dissidia/docs/native-build.md +++ b/psprecomp/games/dissidia/docs/native-build.md @@ -152,8 +152,9 @@ Camera follow dead zone: the world map's free camera (`ovl_battle FUN_08B3F7F4`) frame with no dead zone. With the walk at the stick's own angle, a push a few degrees off straight up then turns the camera, the camera-relative walk turns with it, and the camera spins (VCKing101's measurement; here with `PSPRECOMP_CAM_UNLOCK_HOLD=0` and no zone, a 15 degree push turned the walk 186 degrees in 1.75 s). `input.cpp` moves the follow's atan2 result (`FUN_089A457C`, only the -call on the walker's facing) so the follow does not turn within `PSPRECOMP_ANALOG_FOLLOW_ZONE` degrees (default 22.5, 0 = the game's -follow), ramps up to the cap over half the zone, and is the game's beyond that; only while the walker's last step was the analogue -one. With it the same push walked straight. Normally `camera.cpp`'s hold camera is active on the world map too (no lock-on target): +call on the walker's facing) so the follow does not turn within `PSPRECOMP_ANALOG_FOLLOW_ZONE` degrees, ramps up to the cap over half the zone, and is +the game's beyond that; only while the walker's last step was the analogue one. Default 180: the camera does not follow a walk with +the stick at all, since the right stick turns it (asked for 19 November 2026: the left stick also swung the camera left and right); +22.5 is VCKing101's zone, 0 the game's follow. Walking with the D-pad keeps the game's follow. With it the same push walked straight. Normally `camera.cpp`'s hold camera is active on the world map too (no lock-on target): it keeps the view and turns the stick by the game camera's turn, which already hides the spin; the zone covers the cases without it (`PSPRECOMP_CAM_UNLOCK_HOLD=0`, `PSPRECOMP_CAM_FREE=0`). `PSPRECOMP_ANALOG_FOLLOW_LOG=` logs reduced follow turns. diff --git a/psprecomp/games/dissidia/runtime/input.cpp b/psprecomp/games/dissidia/runtime/input.cpp index 8a7e222..51b1002 100644 --- a/psprecomp/games/dissidia/runtime/input.cpp +++ b/psprecomp/games/dissidia/runtime/input.cpp @@ -44,8 +44,9 @@ // degrees off, the camera turns, the camera-relative walk turns with it and the camera spins (VCKing101 measured 172 deg/s for a // 15 degree push, docs/port/analog-movement.md section 7). Fix, as theirs: while the follow runs for the walker whose last walk step // was ours, its atan2 result is moved so that the angle it turns toward is 0 within PSPRECOMP_ANALOG_FOLLOW_ZONE degrees of straight -// ahead (default 22.5, 0 = the game's follow), rises to the cap over a ramp of half the zone, and is the game's beyond that. Straight -// back, the sides and diagonals turn as in the game. +// ahead, rises to the cap over a ramp of half the zone, and is the game's beyond that. Default 180: the camera does not follow the +// analogue walk at all (the right stick turns it; walking with the D-pad keeps the game's follow). 22.5 is VCKing101's zone (straight +// back, the sides and diagonals turn as in the game), 0 the game's follow. #include "psp_game_module.h" #include "recomp.h" @@ -216,7 +217,7 @@ void walk_replace_step(const recomp_context* ctx) { constexpr uint32_t FREE_CAM_INPUT = 0x08B3F7F4u; // ovl_battle constexpr uint32_t ATAN2 = 0x089A457Cu; // f0 = atan2(f12, f13) FuncPtr g_orig_free_input = nullptr, g_orig_atan2 = nullptr; -float g_follow_zone = 22.5f * 0.017453293f; +float g_follow_zone = 180.f * 0.017453293f; // default: no follow at all (the right stick turns the camera) uint32_t g_follow_owner = 0, g_follow_yaw = 0; // set while FUN_08B3F7F4 runs for that walker int g_follow_log = 0; @@ -296,7 +297,7 @@ void dissidia_input_install(uint8_t* rdram) { std::fprintf(stderr, "[INPUT] analogue walking direction (world map%s)\n", g_walk_battle ? " and battle" : ""); if ((e = std::getenv("PSPRECOMP_ANALOG_FOLLOW_ZONE"))) g_follow_zone = static_cast(std::atof(e)) * 0.017453293f; - if (g_follow_zone > 60.f * 0.017453293f) g_follow_zone = 60.f * 0.017453293f; + if (g_follow_zone > 180.f * 0.017453293f) g_follow_zone = 180.f * 0.017453293f; if ((e = std::getenv("PSPRECOMP_ANALOG_FOLLOW_LOG"))) g_follow_log = std::atoi(e); if (g_follow_zone <= 0.f) return; g_orig_free_input = ovl_battle_lookup(FREE_CAM_INPUT); @@ -304,5 +305,6 @@ void dissidia_input_install(uint8_t* rdram) { if (!g_orig_free_input || !g_orig_atan2) { std::fprintf(stderr, "[INPUT] camera follow zone NOT installed\n"); return; } psp_dispatch_register(FREE_CAM_INPUT, free_input_hook); psp_dispatch_register(ATAN2, atan2_hook); - std::fprintf(stderr, "[INPUT] camera follow dead zone %.1f deg for the analogue walk\n", g_follow_zone * 57.29578f); + if (g_follow_zone >= 3.14159f) std::fprintf(stderr, "[INPUT] world map camera does not follow the analogue walk (right stick turns it)\n"); + else std::fprintf(stderr, "[INPUT] camera follow dead zone %.1f deg for the analogue walk\n", g_follow_zone * 57.29578f); } diff --git a/psprecomp/runtime/src/psp_env_options.inc b/psprecomp/runtime/src/psp_env_options.inc index d6fc984..a46cdfa 100644 --- a/psprecomp/runtime/src/psp_env_options.inc +++ b/psprecomp/runtime/src/psp_env_options.inc @@ -63,7 +63,7 @@ const EnvOpt k_env_opts[] = { {"ANALOG_DPAD_ZONE", EC_INPUT, 'c', "0.25|0.45|0.55", "Stick travel at which a direction counts as a D-pad press in battle (default 0.35)."}, {"ANALOG_WALK", EC_INPUT, 'k', "", "Move in the stick's own direction on the world map and in battle. Off: one of eight ways, as on the PSP."}, {"ANALOG_WALK_BATTLE", EC_INPUT, 'k', "", "In battle too. Off: fighters move one of eight ways (saved battle replays then play back exactly)."}, - {"ANALOG_FOLLOW_ZONE", EC_INPUT, 'c', "0|10|35", "World map camera: degrees either side of straight ahead in which it does not turn after the walker (default 22.5; 0 = the game's follow)."}, + {"ANALOG_FOLLOW_ZONE", EC_INPUT, 'c', "0|22.5|60", "World map camera: degrees either side of straight ahead in which it does not turn after a walk with the stick (default 180 = never, the right stick turns it; 0 = the game's follow)."}, {"RSTICK_DPAD", EC_INPUT, 'k', "", "Right stick presses the D-pad (menus, selecting). Off: it does nothing."}, {"RSTICK_DEADZONE", EC_INPUT, 'c', "0.1|0.3|0.4", "Right stick dead zone, as a fraction of full travel (default 0.20)."}, {"ARROWS_DPAD_ONLY", EC_INPUT, 'e', "", "Keyboard arrow keys press only the D-pad, not the left stick as well."},