Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Download the latest **Dissidia Recomp** from the [Releases page](https://github.
- **Frame rates** above the PSP's 30: any multiple of 30 up to 240, with game logic, UI and EX Burst timing scaled to match ([docs/frame-rate.md](psprecomp/games/dissidia/docs/frame-rate.md)).
- **HD textures** from community packs (on by default when present) and **undub audio** (Japanese voices and movies extracted from an undub disc) ([texture packs](psprecomp/games/dissidia/docs/texture-packs.md), [audio](psprecomp/games/dissidia/docs/audio.md)).
- **Cloud save sync** between devices through a folder, WebDAV or Google Drive ([docs/cloud-sync.md](psprecomp/games/dissidia/docs/cloud-sync.md)).
- **Discord Rich Presence**: your Discord profile shows the mode, the fighters and the stage ([docs/discord.md](psprecomp/games/dissidia/docs/discord.md)).
- **Cross-region saves** and **internet multiplayer** (below).
- A headless battle test harness for checking moves at different frame rates ([docs/testing.md](psprecomp/games/dissidia/docs/testing.md)).

Expand Down
1 change: 1 addition & 0 deletions psprecomp/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ All under `runtime/` (headers in `runtime/include/`, sources in `runtime/src/`):
| Settings menu | `psp_settings.{h,cpp}`, `src/hle/psp_settings_render.inc` (via `psp_savedata_dialog.cpp`), `include/psp_touch.h` | In-game menu (Esc / F1, Guide, L3+R3, the touch menu button, or `psp_settings_request_open()` from a game module's own menu entry). A category sidebar (Display, Graphics, Image, Effects, Controls (only with a touch screen), Network, Cloud, System, Drivers (only where `psp_gpu::supported`), Debug), a scrolling list of captioned rows (toggles, choices, sliders, actions, text fields, sub-menus: Image > HDR, Effects > Ray Tracing) and a description panel whose text scrolls by itself when long. `psp_settings.cpp` owns the state, applies and persists choices (`settings.ini`, exported as `PSPRECOMP_*` at the top of `main()`), and turns the page's `Row`s into a `psp_sddialog::SetScene`; `SettingsView` (`psp_settings_render.inc`, same painter, fonts and `SdTheme` as the save dialog) draws it at ~60 fps with animation (iris open / close, staggered panel slide, gliding selection and sliders, value pulses, drifting crystal motes) into the second overlay slot that `overlay_fetch` prefers, and remembers the geometry it drew (`SetGeom`) so pad, keyboard, mouse (hover, click, wheel, scroll-bar and slider drags, right click = Back) and touch (tap, drag-scroll with fling, sliders) hit-test the exact same rectangles; pointer positions are mapped through the picture rectangle (`ge_draw_overlay_rect`). While the menu is open the on-screen touch controls are hidden and let go (`psp_touch.cpp`), so fingers drive the menu directly. The frosted panels are drawn once per canvas scale into cached premultiplied layers and composited per frame, and the canvas scale drops automatically when a frame takes over 20 ms. Text entry (server, room, peers, sync folder, WebDAV) is an on-screen keyboard modal (pad, mouse, touch, or the host keyboard typing directly). While open the game is paused (guest threads wait in the vblank HLE, `psp_settings_guest_wait`), sees no input (and none until released after closing; the close animation keeps the game paused until it ends), and the main thread presents the last frame plus the menu (`ge_draw_present_overlay_now`). Render-scale changes resize every pool target in place, keeping its picture (`ge_draw_set_render_scale`), once a guest thread has parked, so no display list is mid-way. Frame rate is a game capability: a module registers `PspFrameRateHook` (Dissidia: `games/dissidia/runtime/framerate.cpp`); without one the row is hidden. Host test: `runtime/tests/run_settings_ui.sh` (`DUMP_SETTINGS=<dir>` writes PPM frames). Game modules open it from the game's own menus (Dissidia: `games/dissidia/runtime/menu_settings.cpp`, which adds rows to the title, start and pause menus); elements they add to the game's screens are drawn on the game layer (`ge_draw_set_game_layer`, `psp_ge_draw.h`), a translucent image over the PSP picture under dialogs and touch controls that expires 0.15 s after the module stops sending it, with optional copies of parts of the game's own picture under it (`ge_draw_set_game_layer_copies`); `psp_texpack_watch` hands a module the HD image (either pack kind) the game got for a texture so added elements match the active texture pack |
| VFPU | `psp_vfpu_ops.cpp`, `psp_vfpu_core.cpp`, `vfpu_ppsspp/` | VFPU entry points called by recompiled code. `psp_vfpu_ops.cpp` builds the PSP opcode word from the emitter's decoded fields and runs PPSSPP's `InterpreterVFPU` (vendored in `vfpu_ppsspp/`, see its README) on a pointer view of `recomp_context`, so prefix lifetime, last-lane quirks, hardware min/max/sin/rcp/dot and conversions match the PSP. Replaced hand-written per-op files whose untested paths had diverged. `tests/run_vfpu_semantics.sh` diffs every entry point bit for bit against an unmodified PPSSPP checkout |
| Cloud sync | `src/hle/psp_cloudsync.{h,cpp}`, `psp_cloud_providers.{h,cpp}`, `psp_http.{h,cpp}`, `psp_cloud_service.{h,cpp}`, `psp_cloud_glue.{h,cpp}`, `assets/ca/`, `cmake/psp_mbedtls.cmake` | Keeps save folders in step between installs through a pluggable `Provider` (flat store of small named objects: a folder, WebDAV, Google Drive (a folder created in My Drive, `drive.file` scope)). Per slot, keyed by the region-neutral suffix, the cloud holds `<slot>.save` (container of the files that travel) and `<slot>.meta` (content hash of the data files, container checksum, mtime, device, disc ID; written last). `sync_all` is three-way against the hash recorded at the last sync: one side changed -> copy it, both changed or no history -> a conflict that is never resolved silently (`resolve_conflict`), nothing is ever deleted; pulls retarget and re-sign `PARAM.SFO` through `psp_savemgr::copy_save` and move the replaced save to `SAVEDATA_BACKUP`. `psp_http` is a blocking HTTP/1.1 client (HTTPS via mbedTLS 3.6 with the embedded Mozilla CA bundle, full certificate and host name verification; mbedTLS is optional at build time, without it https reports an error); `psp_cloud_service` owns `cloud.ini` (mode 0600, secrets), a worker thread and the status, and runs a full sync at start-up, one a few seconds after each save (debounced), and one on request. The savedata HLE waits for the start-up sync before the first save dialog (`psp_cloud_glue`) and the Manage saves screen and Settings > Cloud page are thin clients of the service. Decisions: secrets stay out of `settings.ini`; the CA bundle is embedded so Windows, Linux and Android verify identically; a conflict needs the user because a silent newest-wins loses progress. Usage and setup: [games/dissidia/docs/cloud-sync.md](games/dissidia/docs/cloud-sync.md) |
| Discord Rich Presence | `include/psp_discord.h`, `src/psp_discord.cpp` | Speaks the Discord desktop app's local IPC directly (Unix socket `discord-ipc-N` / Windows named pipe; length-prefixed JSON frames: handshake, `SET_ACTIVITY`, ping / pong), no SDK. One background thread owns the connection, polls the game module's `psp_discord::Provider` once a second and sends only changes, at most one per 4 s (Discord's rate limit), reconnecting with back-off when Discord is absent or restarts; the activity is cleared on quit (`main()`) and when switched off (Settings > Network, `discord=`). The provider runs on that thread, so it may only read guest RAM words and atomics. The game decides the content and the Discord application id (Dissidia: `games/dissidia/runtime/discord_presence.cpp`). No-op on Android (no Discord IPC there). Decision: a raw IPC client instead of the Discord SDK keeps the build free of a closed binary and works the same on Linux, Windows and macOS. Details: [games/dissidia/docs/discord.md](games/dissidia/docs/discord.md) |
| Ad-hoc networking | `include/hle/psp_hle_adhoc.h`, `src/hle/psp_hle_adhoc.cpp` | Emulates the PSP ad-hoc stack over UDP: `sceNetAdhocctl*` (groups, peers, handlers), `sceNetAdhocMatching*` (the lobby state machine), `sceNetAdhoc` PDP datagrams and PTP streams, plus the Wlan/net MAC helpers. Registered after the utility module so it overrides that module's no-op `sceNet*` stubs (`PSPRECOMP_ADHOC=0` leaves the stubs). One UDP socket and one network thread; state shared with guest threads is behind a single mutex. Two modes: **LAN** (beacons to local ports, the broadcast address, `PSPRECOMP_ADHOC_PEERS` and gossiped addresses) and **Internet** (the default: every packet goes to a relay server, `tools/adhoc_relay`, which registers the client into a room with a cookie handshake and forwards beacons to the room and other packets by destination MAC; only the server's address is accepted as a source). A peer expires after 4 s. `psp_adhoc_configure()` / `psp_adhoc_status()` let the settings menu switch mode, server and room at run time. The virtual MAC is random per launch. PTP is a small TCP-like stream: every packet carries a connection id, SYN with no listener is refused, sends are partial like `send()`. Recompiled-code callbacks (adhocctl handlers, the matching callback) must run on a guest thread, so the network thread only queues them and `psp_adhoc_pump()` runs them from `sceKernelCheckCallback` and the vblank wait, saving and restoring the caller's argument registers. Exposes `psp_adhoc_group_fps_cap()` / `psp_adhoc_set_local_fps()` so a game module can run a session at the lowest frame rate any player wants (used by `games/dissidia/runtime/framerate.cpp`). The module is generic; the title only decides frame rate. Usage, options and protocol: [games/dissidia/docs/multiplayer.md](games/dissidia/docs/multiplayer.md) |
| Debug socket | `psp_debug_socket.cpp` | TCP server on port 9999, multiple concurrent clients, OK/ERR-framed line protocol: memory read/write, runtime-info JSON, button injection, screenshots (serviced by the render thread), fast-forward. Protocol reference: DEBUGGING.md §6 |
| Game clock | `hle/psp_hle_display.cpp` | The 60 Hz vblank timeline the game is paced by (`sceDisplayWaitVblankStart` sleeps to the next boundary) and the vcount / system time it reads (`psp_hle_kernel_thread.cpp`). Both are the host clock plus a skew that only grows: fast-forward (`FF`) advances the skew to the next boundary instead of sleeping, so the game runs as fast as frames render and time never goes back when it stops (`FF <ms> x` gives each frame at least 1/x of the game time it covers on the host clock: at most x times real time, for screens with idle timers). A movie keeps its own pace: its picture follows its sound, which plays in real time. `PSPRECOMP_VCLOCK=1` replaces the clock with one that advances a vblank per wait |
Expand Down
1 change: 1 addition & 0 deletions psprecomp/games/dissidia/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Everything about the game itself, the native build and the modding tools, in one
- [multiplayer.md](multiplayer.md): Communications mode over UDP (LAN, one machine, internet), options, how the ad-hoc stack is emulated.
- [savedata.md](savedata.md): saves between regions: `savemgr` list / import / export.
- [cloud-sync.md](cloud-sync.md): saves between devices through a folder, WebDAV or Google Drive.
- [discord.md](discord.md): Discord Rich Presence (mode, fighters, stage, the other players on your Discord profile).
- [testing.md](testing.md): the battle test harness, frame-rate parity tests, testing on a phone or a Deck.

## Making characters
Expand Down
71 changes: 71 additions & 0 deletions psprecomp/games/dissidia/docs/discord.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Discord Rich Presence

With the Discord desktop app running on the same computer, your Discord profile shows what you are doing in the game:

```
Playing Dissidia 012 Duodecim
Quick Battle (1-on-1) · Order's Sanctuary
Squall vs. Kefka (2 of 2)
03:12 elapsed
[ Dissidia Recomp on GitHub ]
```

| Where you are | First line | Second line | Timer |
|---|---|---|---|
| Title screen | Title Screen | | since the game started |
| Start menu (and its Battle Mode / Communications lists) | Main Menu | | since the game started |
| After choosing a mode | the mode: Story Mode, Quick Battle (1-on-1), Quick Battle (Party), Arcade Mode, Labyrinth, Communications Mode, PP Catalog, Collection, Data Config, Options | | since the game started |
| In a fight | the mode · the stage | your fighter vs. the opponent (manikins by their own names: Transient Lion, ...) | since the fight started |
| In a Communications Mode group (lobby, room) | Communications Mode | With Zack (or "With Zack, Cloud and 2 others") plus "(n of n)" | as above |
| One-on-one against another player | Communications Mode · the stage | Ender (Lightning) vs. Zack (Laguna) | since the fight started |

The large picture is the game's icon; hovering it shows the Dissidia Recomp version, or in a group every player's name ("Players: Ender
and Zack"). Players are named by the player name of their save (Data Config > Player Name): each copy of the game sends it to the
others as its ad-hoc nickname (it was "Player" before), so the game's own lists of nearby players show it too. Everyone in one room gets
the same Discord party, so Discord shows them together. Your Discord name is never sent to other players. Characters added with `roster.txt` show their
`nm=` name (else their code). Stages without a confirmed name (labyrinth floors, a few story-only arenas) are left out.

## Turning it off

Settings > Network > **Discord Status** (On / Off, saved as `discord=` in `settings.ini`). The **Discord** row under it says whether the
app was found ("Connected as ...", "Discord is not running", ...). Turning it off clears what Discord shows at once. Nothing is sent
anywhere but to the Discord app on this computer, and Discord only shows it while the game runs.

| Option | Effect |
|---|---|
| `PSPRECOMP_DISCORD=0` | off (the saved setting wins) |
| `PSPRECOMP_DISCORD_APP_ID=<id>` | another Discord application (its name is the "Playing ..." line) |
| `PSPRECOMP_DISCORD_LOG=1` | log every message to and from Discord |
| `PSPRECOMP_DISCORD_IPC=<path>` | use this socket / pipe instead of searching (tests) |

Not on Android: the Discord phone app has no local connection for games. On a Steam Deck it works in Desktop Mode with Discord running;
in Game Mode only if Discord runs in the background.

## How it works

`runtime/src/psp_discord.cpp` (generic, no Discord SDK) talks to the desktop app over its local IPC: a Unix socket `discord-ipc-0..9`
in `$XDG_RUNTIME_DIR`, `$TMPDIR` or `/tmp` (also the Flatpak, Snap and Vesktop sub-folders), or the named pipe
`\\.\pipe\discord-ipc-0..9` on Windows. Frames are `{u32 opcode, u32 length, JSON}`: a handshake with the application id, then
`SET_ACTIVITY` commands; pings are answered. One background thread owns the connection. Once a second it asks the game module what to
show and sends it when it changed, at most once every 4 s (Discord drops more than 5 updates in 20 s; the newest state always goes out).
If Discord is not running, quits or restarts, the thread looks again after 5 s, doubling up to 60 s; the game never waits for it. On quit
and when turned off the activity is cleared.

`games/dissidia/runtime/discord_presence.cpp` decides what to show:

- **Menus.** `menu_settings.cpp` reports every frame the title screen, the start menu (`ovl_menu` FUN_089E45E8; cursor at state +0xA28
+4) or its sub-list (FUN_089E4A60; group at state +0xA88, cursor at +0xA58 +4) updates. The rows they were on when the start menu was
left are the chosen mode, kept until the start menu shows again.
- **Fights.** `framerate.cpp` keeps the fighters on stage; each fighter's object record (actor +0x2F8) gives its charId (+6) and model
type (+8, 5 = manikin), and the brain (actor +0x5C4, +0x54 != 0) tells which one a person drives. charIds follow the EBOOT code
table at 0x089D6CA8 (one100 .. sev120). The stage is `psp_stage_id()` (the battle setup word, hooks_main.cpp), named from the game's
own text (`text/en/mess_pk_loading_0.bin` entry 3).
- **Online.** The save's player name is UTF-16 at 0x08BCEB40 (EBOOT BSS; found by changing it in RAM and watching Data Config follow,
the copy at 0x08BDC4BC is a stale duplicate). The start menu hands it to `psp_adhoc_set_nickname` (every Communications session starts
there; `PSPRECOMP_ADHOC_NICK` still wins). `psp_adhoc_group_size()` / `psp_adhoc_group_nicks()` give the other players, and
`psp_adhoc_group_key()` (room + the game's group name) a party id everyone in the room shares. Which fighter is yours: actor +0x5B0
bit 0x04 (…35 against …31; found by diffing two copies in one Group Battle, the same in single player). The brain's human mode is set
for the other players' fighters too, so it is only the fallback.

Test: `runtime/tests/test_discord.cpp` (ctest `discord`) checks the JSON and runs a whole session against a fake Discord app on a Unix
socket: handshake, first activity, rate limit, ping, off / on, Discord restarting, clearing on quit.
2 changes: 1 addition & 1 deletion psprecomp/games/dissidia/docs/multiplayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ both run at 30. It returns to the player's own setting when the group ends. A me
| `PSPRECOMP_ADHOC_PORT=<n>` | LAN mode: first UDP port (default 27312) |
| `PSPRECOMP_ADHOC_SPAN=<n>` | how many consecutive ports are tried and probed (default 16, up to 64) |
| `PSPRECOMP_ADHOC_PEERS=a,b` | LAN mode: extra peers to contact directly: `host` or `host:port` (a bare host probes the whole port span) |
| `PSPRECOMP_ADHOC_NICK=<name>` | nickname other adhocctl clients see (the in-game player name comes from the save) |
| `PSPRECOMP_ADHOC_NICK=<name>` | nickname other adhocctl clients see (default: the save's player name once a save is loaded, else "Player"; Discord status names players by it) |
| `PSPRECOMP_ADHOC_MAC=aa:bb:cc:dd:ee:ff` | virtual MAC; default is random per launch (a host-name hash collides: every Steam Deck is called `steamdeck`) |
| `PSPRECOMP_ADHOC_LOG=1` | log every call and event with arguments, results and the first bytes of each message |
| `PSPRECOMP_PAD_BACKGROUND=1` | let controllers act while the window is unfocused |
Expand Down
3 changes: 3 additions & 0 deletions psprecomp/games/dissidia/docs/settings-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Changes marked **Next start** ask "Restart now / Later" when the menu is closed.
The **Mods** category lists mod folders with a `mod.json` (the repo's `mods/`, `PSPRECOMP_MODS_SRC`, and the game's mods folder) and extra
characters from the mods folder's `roster.txt`. A switch writes `"enabled"` into `mod.json`, or puts `#off# ` in front of the roster line.

The **Network** category also has a **Discord** section (not on Android): **Discord Status** On / Off (applies at once, saved) and a
connection line; see [discord.md](discord.md).

The screen is drawn by up to 8 threads in horizontal bands (`PSPRECOMP_SETTINGS_THREADS=N` to change, 1 = one thread);
`PSPRECOMP_SETTINGS_PROFILE=1` logs the drawing time per part.

Expand Down
Loading
Loading