22 Commits
Author SHA1 Message Date
Thomas MartinandClaude Opus 5.5 39268640ea ReShade's effects under the 2D
When a player installs ReShade (its opengl32.dll beside the executable), the
program registers as one of its add-ons and has it render its effects inside
present(), after the 3D picture and before the HUD and menus, so a colour
grade, depth of field or ambient occlusion no longer goes over the 2D. The
F2 / F3 panels stay clear too. Without ReShade nothing changes;
BOZO_RESHADE_AT_PRESENT=1 keeps ReShade's own pass over everything.

- Renderer::setBeforeOverlay: a hook present() calls when it draws to the
  window, between the 3D and the 2D, with the window's size; present()
  binds its own state again afterwards.
- app/reshade_bridge: registration after the window is made (ReShade's DLL
  loads with it) and before the GL context; the effects run on a texture
  of the window's size, copied upside down from and back to the window, as
  ReShade's own OpenGL pass does (its effects expect the top row first).
- ReShade 6.8.0's API headers (BSD-3-Clause) in app/reshade/.
- MinGW and ReShade's MSVC return structs from methods differently, so no
  API method returning a struct is called; views are built as ReShade's
  OpenGL backend makes them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 12:28:43 +01:00
Thomas MartinandClaude Opus 5.5 d111e97cdc Video: widescreen setting and a live picture aspect
- video::Settings::widescreen (video.ini `widescreen`, PS2X_WIDESCREEN):
  the port shows a 16:9 picture where its game can show more at the sides.
  Off by default. The Video tab offers it once the port calls
  video::offerWidescreen(true); a port without it ignores it.
- setPictureAspect(aspect) (window.h, any thread, live): the picture's
  shape the window letterboxes, over WindowOptions::aspect (0 back to it).
  A port drawing its wider picture sets 16:9 while it does.

TMB widens its match views with them (TheBozos/TMB_Recomp PR to follow).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 00:23:54 +01:00
Thomas MartinandClaude Opus 5.5 a02b93a3ea app: captureStatePicture(slot) for saves made from a game's own menu
A port whose in-game menu saves a state calls its own save rather than
Game::saveState through F5, so the slot kept its old picture in the
Save states tab. captureStatePicture(slot) takes the window's next frame
as the slot's picture, the same path F5 uses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 20:36:02 +01:00
Thomas MartinandClaude Opus 5.5 483d5b8916 Window: setPictureCrop, the picture zoomed to another shape
For a game whose views are fixed pictures (pre-rendered rooms) and cannot
show more at the sides: setPictureCrop(16/9) shows a 16:9 shape fitted in
the window, the 4:3 picture filling its width and cut at the top and
bottom (or its height for a narrower shape); outside the shape the window
stays black (scissored clears after the present). Live, any thread; 0
(the default) is the letterboxed 4:3 as before. The port keeps its HUD
inside the shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 17:58:37 +01:00
Thomas MartinandClaude Opus 5.5 cb7d0a5db6 Sampling profiler: the settings window's Profiler tab and PS2X_PROFILE
bozo/app/profiler.h (bozo_profiler, no SDL3): while it runs, a thread of its
own reads each registered thread's instruction pointer about every
millisecond (Windows: suspended for the read, nothing allocated meanwhile;
Linux: SIGPROF answered from the thread's handler) and a profile counts the
samples by function, named from the executable's own symbols (PE/COFF or
ELF .symtab, demangled; recompiled functions keep their PS2 address) and a
library's export ("ntdll.dll!ZwWaitForSingleObject": a thread waiting).

The window registers its game thread ("game") and its own ("window"); a
port registers its workers. F2 has a Profiler tab (start, stop, each
thread's functions, a report saved to the user folder's profiles/), and
PS2X_PROFILE=<from>:<to>[:<file>] profiles game frames in scripted runs.
Tested by tests/app/profiler_tests.cpp (a spinning thread's function first).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 12:10:40 +01:00
Thomas MartinandClaude Opus 5.5 1c5b3c15cb Window: frames on the monitor's refreshes, no frames queued ahead
A game paced at 60 on its own clock, presented with vsync on a 60 Hz
monitor: the two clocks drift, and every so often a picture stayed two
refreshes and the next was never shown. 60 frames a second that did not
feel smooth (TTA's players). The driver also queued up to three frames
ahead of the display, each a refresh of input delay.

On vsync at the game's rate (no frames between, not lockstep, a shown
window) the window now waits each present out (glFinish after the swap)
and counts it; once their period is steady and within 1 % of the cap's,
FramePacer ends each frame on the display's next refresh instead of its
own clock (bounded to 0.9..2 periods). Fast forward, a hidden window or
an unsteady display keep the clock. PS2X_NO_VSYNC_PACE=1 and
PS2X_NO_SWAP_FINISH=1 for the old ways; the window's stats line shows
the locked period.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 20:38:20 +01:00
ArzarothandClaude Opus 5.5 eca63e515f [perf/fight-frames] fix(app): sleep through a waitable timer on Windows
FramePacer::frameEnd and the window's own present schedule slept with
std::this_thread::sleep_until, which MinGW turns into nanosleep. Under
Proton Experimental with fsync that oversleeps by up to 13 ms, so a game
with 1 ms of work a frame ran its menus at 55 frames a second while the
presents held 60. bozo::app::sleepUntil waits on a high-resolution
waitable timer instead (a plain one where that kind is missing, then
sleep_until); other systems keep sleep_until.

PAL sc3.exe under Proton Experimental with fsync, menus: 58.6 -> 59.95
game frames a second (a standalone pacer loop: 55 -> 60.00).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 10:43:36 +01:00
Thomas MartinandClaude Opus 5.5 b30d316898 Anti-aliasing: MSAA 2x / 4x / 8x in the Video tab
The frame's 3D is drawn into a multisampled colour and depth-stencil of the
target's size and resolved into the single-sampled target wherever the frame
is read: the copies a material samples, the depth an image pass reads, an
auxiliary target sharing the frame's depth, the depth tiles and the present.
Off by default; video.ini anti_aliasing, PS2X_ANTI_ALIASING (also read by
scripted runs). A size or sample count the GPU refuses falls back to none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 10:45:36 +01:00
Thomas MartinandClaude Opus 5.5 f4fee1f4a1 The settings window, save and load from a gamepad
Window actions bound like the pad's buttons (input.ini, the Controls tab): fast forward,
the settings window (the gamepad's middle button by default), save and load a state
(unbound). input::windowActions evaluates them; DevicePad::windowActions gathers the
players'; the window acts on their presses. ImGui's gamepad navigation steers the settings
window (every gamepad), which takes the focus when opened and holds the gamepads from the
game while it is open. PS2X_VIRTUAL_PAD=<s>:<button>,... presses an SDL virtual gamepad's
buttons for scripted checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 01:03:28 +01:00
Thomas MartinandClaude Opus 5.5 aa891d64d7 Fast forward as a binding: the Controls tab, a gamepad's touchpad click
input::FastForward joins the actions (input.ini fast_forward): player 1's ` key and every
player's touchpad click by default (DualShock 4 / DualSense; no PS2 button has it), rebound
in the Controls tab like a PS2 button. padState reports it; DevicePad::fastForwardHeld
gathers the players' and the window sets the speed from it (focus and the panel's keyboard
hold as for the game's input).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 23:44:19 +01:00
Thomas MartinandClaude Opus 5.5 48657b9f2e Fast forward: hold ` to run the game faster (2x to 10x or unlimited)
FramePacer::speedPercent: a paced game's frames held to the cap times the speed, each
counted as one period of the cap; the sound stays on the host's clock. The window sets it
while ` is held with the focus (not while the panel takes the keyboard); the Video tab's
"Fast forward" picks the speed (video.ini fast_forward, PS2X_FAST_FORWARD, 3x by default);
">> 3x" shows at the top left meanwhile. PS2X_FAST_FORWARD_AT=<from>-<to> holds it from a
script.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 22:42:15 +01:00
Thomas MartinandClaude Opus 5.5 6554e1b234 Save states: a picture per slot, shown in the Save states tab
A save (F5 or the tab's Save) takes the game's picture at the next present as slotN.png beside the state (320 wide,
SDL_SavePNG on the capture thread). The tab shows it beside the slot (96 x 72, full size under the pointer), loaded
into a texture again when the file changes; empty slots stay one line. PS2X_STATE_SAVE_AT=<s>[,<s>...] presses F5
from a script.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 20:16:03 +01:00
Thomas MartinandClaude Opus 5.5 3bbf34748f F12: a screenshot of the game's picture (compressed PNG in the user folder's screenshots)
The game's picture without the panel, at the next present, written by the capture thread through SDL_SavePNG (alpha
made opaque) as screenshots/screenshot_<date>_<time>.png in the user folder (PS2X_SCREENSHOT_DIR another folder; a
number added within the same second), with a notice naming it. PS2X_SCREENSHOT_AT=<s>[,<s>...] presses it from a
script.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 20:06:10 +01:00
Thomas MartinandClaude Opus 5.5 f14a7ce587 The cursor hides over the game after two seconds without moving
Shown again by any motion, button or wheel, while the settings window is
open, and when the pointer leaves the window. Hidden (scripted) windows
are left alone; PS2X_KEEP_CURSOR=1 keeps it shown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 18:16:53 +01:00
Thomas MartinandClaude Opus 5.5 f6acc4fc49 Pause in the background: an opt-in video setting that holds the game while the window has no focus
FramePacer::backgroundHold(), set by the window's loop when the player's
video settings ask for it (video.ini pause_in_background, PS2X_PAUSE_IN_BACKGROUND,
the Video tab's checkbox) and the window is unfocused or minimised. A paced
game holds at its frame end; the frame after counts one period. Cleared
before the game is stopped. Off by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 17:04:57 +01:00
Thomas MartinandClaude Opus 5.5 7ff2241d5c Window: lockstep option for reproducible runs
WindowOptions::lockstep presents each published frame exactly once, in order, after the frame has ended, and
reports it through onPresented. A host that holds its game after each publish until then gets pictures that do not
depend on the window's timing, including what they keep from present to present (kPreviousFrame, the render
targets). TTA's Nazgul Scream ghosting varied by up to 0.9 levels between runs without it; with it, every capture
of TTA's regression check is pixel-identical run to run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-21 17:24:50 +01:00
Thomas MartinandClaude Opus 5.5 ead0535d31 Window: hidden test runs and offscreen captures; z-fail stencil counting
- WindowOptions::hidden (never shown) and captureScene (also PS2X_CAPTURE_SCENE=1): the window presents
  into an offscreen picture, captures read it, then it is copied to the window. A hidden or covered
  window's back buffer read back black, so captures depended on what was on top of the desktop.
- Renderer::present returns to the framebuffer it was called with instead of 0.
- gl: BlitFramebuffer.
- Material::stencilDepthFail: stencilOp counts where the depth test fails (z-fail), for closed volumes
  the near plane cuts or the camera is in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 22:56:22 +01:00
Thomas MartinandClaude Opus 5.5 b73692ed37 Save states: the whole runtime saved and loaded at the dispatcher's safe point
A state is taken at the top of Dispatcher::run's loop, where no guest code is on
the host stack: memory, the dispatcher, the kernel (threads, frames, queues,
deadlines), every library's state, the native IOP host (memory, tasks, kernel
objects, RPC servers, mixer, libsd) and sections ports add (state::Sections).

Parked library lambdas become data: Resume records and native deadline kinds,
rebuilt from tables on load; ports can add their own kinds. FreeHost serves
requestSave / requestLoad from any thread, rolls back a failed load, and takes
FreeOptions (gameTag, loadState[Frame], saveState[Frame]). Windows get ten slots:
F5 save, F7 load, F6 / Shift+F6 select, and a Save states tab in F2.

989SND's engine and a playing movie are not covered: a save waits, saying why.
docs/save-states.md tells a port how to use and check it; tests/runtime/state_tests.cpp
covers the archive, files and a dispatcher round trip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 18:22:15 +01:00
Thomas MartinandClaude Opus 5.5 05551895f4 Phase 4 M5: the picture as the fork's (the window's letterbox at its fractional place and size: in 640x448 the 4:3 picture covers columns 21-618 as the fork's, not 22-618; Material::sampleTarget, the heat haze, off unless BOZO_HEAT_HAZE=1, as the fork's renderer never sampled the target); run::setFrameHook and WindowOptions::onCaptured (a port's pinned run shown in the window, held at its capture frames); draws checked in pinned port runs on every frame but the log's last
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 17:27:47 +01:00
Thomas MartinandClaude Opus 5.5 2ed83b7ff0 Phase 4 M4b: frames between the game's (the fork renderer's interpolation moved: the smoothed clock and history at publishing, pickInterpolated, matchFrames, keyed matrices and tracked triangles between two frames) wired to video.ini's frame_rate, the Video tab and the window's loop (vsync at the monitor's rate, or n a second); FramePacer's step on its own schedule (a wake-up's overshoot was counted twice: the EE clock ran 1 % fast and the sound was dropped every few seconds)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 16:23:01 +01:00
Thomas MartinandClaude Opus 5.5 78a375f43a Phase 4 M4: the settings window (F2: Controls, Video, the port's tabs) and the frame rate counter (F3) on Dear ImGui's SDL3 and OpenGL 3 backends (ImGui pinned to b1bcb12a, v1.92.7-docking; bozo_ui without SDL3 for a port's tabs); video.ini moved from the team's ps2_video_settings on SDL3 (windowed / exclusive / borderless, render scale, F11; gs_scale and frame_rate kept for the file); the tab list moved from ps2_debug_ui; F8 capture sequences, F9 bursts, interval captures on a writer thread; DevicePad::setHeld
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:51:00 +01:00
Thomas MartinandClaude Opus 5.5 fa08bec901 Phase 4 M1: the renderer's present side on OpenGL 3.3 core (render/present_gl.cpp: the fork's GPU half moved off raylib's rlgl, its 330 shaders kept; gl.h, our own table of the 70 GL functions loaded at run time), the depth tiles read one present late, sampleTarget's target copy; bozo_app (BOZO_APP, SDL3 3.4.20 static): the window and present loop, the keyboard and gamepad as port 1, PNG captures; the free host in real time (realTime, requestStop); FramePacer keeps the cap's schedule (60.0 frames a second, not 59.4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 12:52:40 +01:00