254 Commits
Author SHA1 Message Date
Thomas MartinandClaude Opus 5.5 37abf45ccb libsd: an effect work area clear takes its SPU2 DMA time, also for ready-completion hosts
sceSdCleanEffectWorkArea reported its end after the transfer latency alone,
and a host that delivers audio completions at once (VP2S) ran it immediately.
VP2's reverb change (Csm export 8) clears core 0, then core 1, then releases
its lock; the EE asks (Csi RPC 0x1c) about two frames later whether the change
is still running and sends it again when it is not. With a clear that takes no
time it was never running: the castle-hall event of chapter 2 waited forever.

The clear's end now comes after the area's DMA time (16 IOP cycles per
halfword: mode 7 is 0x18040 bytes, about 21 ms per core) through a new
LibsdHost::interruptCallAfterWork, which ready-completion hosts honour (its
default forwards to interruptCall). Test: the end's delay and its route.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 14:29:51 +01:00
Thomas MartinandClaude Opus 5.5 57dd73bd34 Mixer: the SPU2's Gaussian interpolation, a port's choice
Shinobido's Hideout music recorded from PCSX2 (its own media capture of the
SPU2's samples) against the port's: the same to within 0.2 dB from 200 Hz to
4 kHz (coherence 1.000), but the port 1 dB brighter at 4-8 kHz, 2.6 dB at
8-12 kHz, 4 dB at 12-16 kHz and 6.4 dB above. The mixer resamples the voices
by 4-point Catmull-Rom (nearly flat to the top); the SPU2 by its 4-point
Gaussian table, as the PS1's SPU (psx-spx, "SPU ADPCM Pitch": 512 entries, the
index the pitch counter's bits 4-11, each of the four products shifted right
15), which rolls the highs off. With it the port's music is within 0.17 dB of
PCSX2's in every band from 200 Hz up.

Mixer::setGaussianInterpolation(bool), for every mixer, off by default (the
other ports' sound, and any recordings they compare against, unchanged);
Mixer::gaussian(y0, y1, y2, y3, t) the interpolation itself. The table's 512
values checked as the page says: each set of four weights sums to 0x7F7F-0x7F81.

Test (bozo-audio-tests): off by default; a constant 0x7000 at fraction 0 is
4206 + 20092 + 4262 - 1 = 28559; every index's weights sum within bounds; the
fraction's low 4 bits ignored (y1 alone at 0: 0x59B3); the switch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 11:50:29 +01:00
Thomas MartinandClaude Opus 5.5 0f0c281b7d Renderer: readImage, a game's read of an auxiliary image
Breath of Fire: Dragon Quarter's memory card picture is a sprite drawing the
frame so far into the GS memory, in the middle of a frame whose end is a
black fade tile: the presented picture (readPicture) is black. Natively the
port copies the frame so far into an auxiliary image there (fromFrame,
source 0) and reads that image back.

Renderer::readImage(image, width, height, rgba, timeoutMs) asks the first
present showing the frame published when it was called (or a later one) for
the auxiliary image as the frames drawn so far left it: all of it, one
ReadPixels, rows top-down as the screen's, RGBA (alpha 0x80), and its size.
Called on the game's thread after the frame drawing into the image was
published. False at once when nothing has presented in the last second
(headless), for an image no frame has drawn, and on a timeout.

GPU test (BOZO_APP, label gpu): a frame red over blue is copied into image 2
(8 x 6), then covered black; another thread reads the image back (red over
blue, top-down) while readPicture gives the black frame; an image never drawn
reads false.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 01:45:16 +01:00
Thomas MartinandClaude Opus 5.5 dd9e3bb4d8 Pad scripts: stick-only names (LUP LDOWN LLEFT LRIGHT, RUP RDOWN RLEFT RRIGHT)
The D-pad pushes the left stick too, but always with its button bit. Games
that read the D-pad apart (VP2's battle: left/right split the party) could
not be given a plain stick move from a script. The new names push one stick
to its end with no button bit or pressure, winning on their axis.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 01:10:51 +01:00
Thomas MartinandClaude Opus 5.5 784932f106 Renderer: the destination alpha test (TEST.DATE) and GS alpha writes for opaque draws
- Material::destinationAlpha (Off / Clear: pass where the target's alpha is below
  0x80 / Set: 0x80 and up): the target so far copied to unit 4 before the draw (3 being the shader blend's destination),
  its alpha tested per fragment (0x80 is the 1.0 the target keeps).
- Material::frameAlpha: an opaque draw writes its own alpha (As) instead of 1, as
  the GS does, so a later DATE or DST_ALPHA blend reads it.
Both default off: other ports draw as before.

Breath of Fire: Dragon Quarter's character outlines: an inflated dark mesh drawn
with DATE, DATM 1 where the frame's alpha is set, not over the characters (alpha 0).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 23:05:52 +01:00
boubou666 97efe9e745 Merge pull request #180 from TheBozos/vp2s/gs-arithmetic-passes
Renderer: GS arithmetic also truncates image passes on store
2026-11-30 16:14:52 +01:00
Thomas MartinandClaude Opus 5.5 aa74966b16 Renderer: GS arithmetic also truncates image passes on store
With setGsArithmetic on, image passes (frame copies, filters, levels, chains) store their result as truncated
bytes, as each GS pass does, where the 8-bit target would round to nearest. Scene draws are unchanged.

VP2S's world-map glow measured against a GS-rule render of PCSX2's dump: the full frame was +3.3..+4.0 per
channel over PCSX2, now +0.9..+1.8 (with a VP2S-side split of the glow level pass).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 16:06:21 +01:00
Thomas MartinandClaude Opus 5.5 bfac857af0 Renderer: readPicture, a game's read of its presented picture
Steambot Chronicles' menus are drawn over a half-size copy of the screen
(sceGsExecStoreImage of the frame buffer). Renderer::readPicture asks the
next present for a rectangle of the frame's screen, read back with one
ReadPixels after the picture is drawn and before the window draws over it,
box-averaged to the size asked for (RGBA, rows top-down, alpha 0x80). It
waits up to a timeout for that present and answers false at once when
nothing has presented in the last second (headless).

GPU test (BOZO_APP, label gpu): a hidden window presents red and blue
halves while another thread reads them back at 4 x 2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 16:01:28 +01:00
boubou666 a924c3ec5d Merge pull request #177 from TheBozos/vp2s/gs-arithmetic
Renderer: optional GS colour arithmetic (truncating bytes)
2026-11-30 14:59:08 +01:00
Thomas MartinandClaude Opus 5.5 71cea27656 Renderer: optional GS colour arithmetic (truncating bytes) for scene draws
Renderer::setGsArithmetic(true) makes textured scene draws compute as the GS does: the filtered texel and the
interpolated vertex colour as truncated bytes, modulate floor(T x C / 128), fog (F x C + (255 - F) x FOG) >> 8.
Off by default (exact float, rounded once on store). Image passes are unaffected.

VP2S measured a town frame against a GS-rule render of PCSX2's dump of the same frame: exact arithmetic is
+2.2 per channel over the GS (doubled by the game's 2x pass); with this, +0.4.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 14:48:55 +01:00
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 24691830b2 Native IRX: a work-free IOP clock (opt-in) and an import call log (BOZO_IRX_CALLS)
CompiledLibraries::useWorkFreeClock(): the IOP clock moves only with its own
events (deadlines, timers, the EE's time), not with the work compiled code
does, so a native rewrite of a compiled routine meets the same times and a
timer handler's work no longer delays its next period.

BOZO_IRX_CALLS=<file>: every import call (cycle, library, ordinal, a0-a3,
the caller, the result) written out, to compare two runs of the same
modules, compiled or rewritten. docs/native-irx.md also describes bindings
that sleep and resume at admitted return addresses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 19:16:40 +01:00
Thomas MartinandClaude Opus 5.5 76b56a3d5a libsif: native sceSifGetOtherData (IOP memory read back to the EE)
The SDK sends a SIF command and the IOP's sifcmd sends the bytes back by SIF DMA; with no IOP the guest code's
request is never answered and the EE buffer stays as it was. Natively the bytes come from the IOP host's memory
(SifState::receive, a port's provider) at once; the receive record is filled; 0.

Steambot Chronicles' file loader reads each archive into an IOP buffer (sceCdReadIOPm) and takes every file back
with sceSifGetOtherData: without it the map's models and textures were zeros (ImdGetObjFirst: Not IMD).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 14:44:38 +01:00
Thomas MartinandClaude Opus 5.5 fd67f9e899 libmpeg: callbacks on the caller's thread (MpegOptions::callbacksOnCaller)
Sony's libmpeg calls the stream callbacks inside sceMpegDemuxPss / sceMpegDemuxPssRing and Nodata inside
sceMpegGetPicture, on the caller's thread. The native library queued them for whichever thread ran next, which
deadlocks Steambot Chronicles' player (Sony's sample): its video callback waits on the IPU input ring's lock held by
the thread it was stacked on. With the option on (off by default), each callback is a handler bound to the calling
thread and the call is made again after it: the demux going on from where it was, GetPicture calling Nodata again
until a picture is there.

- Kernel::queue(handler, thread): a handler that runs only on that thread; handlerQueuedFor(thread) for the
  dispatcher's checks; the bindings saved in an optional section (older states load with none).
- Libraries::queueHandlerOn and restartCall: the free host stops the thread at the call's own address.
- MpegState::demuxResuming / demuxBytes, saved as an optional tail of the mpeg section.
- Tests: thread-bound handlers (handler_stacks), the demux and Nodata loop (mpeg_callbacks).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 13:39:05 +01:00
Thomas MartinandClaude Opus 5.5 4946fa820a EE kernel: ReferSemaStatus and iReferSemaStatus
The SemaParam words (current, max and initial counts, waiting threads, attr, option) and the id, or -408 for an
unknown id as the other semaphore calls answer. Steambot Chronicles' graphics interrupt handlers call the i-form
(syscall -0x48) to signal the frame semaphore only when nobody already did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 03:50:35 +01:00
Thomas MartinandClaude Opus 5.5 eb05b04ca0 SPU2 output IRQ: the mix stops at it, its handler 32 samples on
A sample-clocked timer on the output write-back (Harmonix's softFX refills
core 0's input area on it) was answered only after the whole mix of a
frame, so its refills landed anywhere in the half being played: stale
halves replayed, a crackle and a slowed-down sound. The native IRX host's
mix now stops where the output reaches an enabled IRQ address
(Mixer::nextOutputIrqCycle), and the SPU2 interrupt's handler runs 32
samples later (Libsd::kIrqResponse): the IOP's response and its driver's
work, which take no time here. Run at once, softFX's transfer landed 2
samples before the half it refills had played.

Amplitude's tutorial narration: 265 clicks in 65 s before, 7 after; the
song select's previews likewise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 19:16:51 +01:00
Thomas MartinandClaude Opus 5.5 30013e436a FreeHost: the real-time sound held to the host's time without clicks
holdToHostTime cut a frame's surplus samples whenever the frame made more
than the host's time allowed plus a quarter field. A window whose frames
run a hair off the sound card's clock (the game's steady 800 samples a
frame against a budget slightly short) lost 1 to 16 samples every few
frames, each cut a click: Amplitude's tutorial narration crackled (826
cuts in two and a half minutes).

- A small surplus (up to 5 % of the frame: drift and jitter) is now
  resampled into what is allowed, the frame's first and last samples
  kept, a pitch change too small to hear.
- A larger one (a leap: a disc wait the PC did not live) is cut as before,
  the newest samples kept, but the join is cross-faded over up to 64
  samples.

Measured on the tutorial's output (SDL's dummy audio driver, the window's
WAV): as many clicks as the game's own mix (446 against 444 in 80 s).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 13:31:31 +01:00
Thomas MartinandClaude Opus 5.5 e590551574 render: setBackdrop shows a part of its texture (the picture in a power-of-two one)
A movie picture decoded as a texture is rounded up to powers of two: a
640 x 448 picture in a 1024 x 512 texture. setBackdrop mapped the whole
texture to its rectangle, so a port had to draw it larger than the
picture and let the window cut the padding off. Where the window does not
(a 4:3 picture kept 4:3 in a widescreen frame, or a letterbox), the
padding showed: Amplitude's widescreen movies had a strip of stale
pictures at the right and below.

Two trailing parameters (u, v) give the part that is the picture; their
defaults (1, 1) keep every port's call as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 12:46:56 +01:00
boubou666 a12742f4ed Merge pull request #161 from TheBozos/amp/mpeg-entries-in-work
libmpeg (SDK layout): stream callback entries in the work area, nothing from the game's heap
2026-11-27 10:47:13 +01:00
Thomas MartinandClaude Opus 5.5 553cac12f5 libmpeg (SDK layout): stream callback entries in the work area, nothing from the game's heap
Off the reference's layout, each stream callback's 32-byte entry came from
the engine's heap, which by default starts after the game's .bss, where a
game's own allocator works. Both handed out the same memory: Amplitude's
task manager list header was overwritten from the movie's first frame.

The entries now come from the last 64 x 32 bytes of the work area the game
gave sceMpegCreate (libmpeg's own memory, never read by the game), freed
as each handler ends. The reference's layout keeps the heap as before. A
save state from before has no in-use mask: it loads as none waiting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 10:41:01 +01:00
Thomas MartinandClaude Opus 5.5 7678d91bad libs: sceGsSyncV waits for the next vblank (opt-in, syncVWaitsForVblank)
A game that paces itself on the EE's timers and then calls sceGsSyncV gets
the console's wait: the EE clock goes on to the next vblank's start, and
the result is that field's parity. Off (the default, the reference's), the
frame ends at once, held to the frame period, with the parity of the frames
ended.

Amplitude's movie player waits 500 hblanks on timer 0, then sceGsSyncV:
two fields a picture with the wait, three with a frame end held to a whole
period.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 10:16:38 +01:00
Thomas MartinandClaude Opus 5.5 7b3f7dff26 libs: sceIoctl's status poll, sceSifInitCmd, sceSifSetDChain, sceIpuInit; whole stream reads (opt-in)
What Amplitude_Recomp answered in its port, generic SDK behaviour:
- sceIoctl: request 1, the status a file opened with O_NOWAIT is polled with, is "done" (*arg = 0): the native
  sceOpen / sceRead have finished as they return. Any other request: -1.
- sceSifInitCmd, sceSifSetDChain, isceSifSetDChain: nothing to set up or arm (Onimusha_Recomp answered
  sceSifSetDChain the same way in its port).
- sceIpuInit: no IPU to reset.
- CdState::wholeStreamReads (off by default): a sceCdStRead that does not wait brings all its sectors or none,
  as a console's drive fills the stream ring a bank at a time. Amplitude's movie player resumes its demux at
  buffer + 0x4000 - bytes left and skipped a sector after a short read.
- texture.h: Texture::rgba carries the GS's alpha (0x80 opaque); the comment said 255.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 10:16:20 +01:00
Thomas MartinandClaude Opus 5.5 2cca000176 FreeHost: a port's VU0 programs found by pair, not by a search
VCALLMS went through a linear search of the port's VU0 programs on each call. Shinobido
calls about 10,000 a frame (19 entries); they are now in a table by pair (VCALLMS targets
under 16 KB, the first entry for an address kept, as the search did). Other addresses
still go through the search and its fault.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 01:09:45 +01:00
boubou666 64d228e508 Merge pull request #155 from TheBozos/mmi-sse2
MMI: SSE2 for the lane-wise helpers
2026-11-27 00:41:06 +01:00
Thomas MartinandClaude Opus 5.5 1348603da6 MMI: SSE2 for the lane-wise helpers
The helpers were lane loops over the Gpr128 union, which the compiler kept as scalar
loops through stack temporaries. The 42 that one SSE2 instruction (or a compare and a
blend: pmaxw, pminw) does lane by lane now use it: add/subtract (wrapping, signed and
unsigned saturating halfwords and bytes), compares, min/max, logic, shifts, the
interleaves and pcpyld/pcpyud. Word saturation, packs and the rest stay loops.
BOZO_MMI_SCALAR=1 at build keeps the loops alone.

Checked against the loops on 8.4M random cases (edge lanes: 0, min, max, equal): none
differ. In Shinobido a collision loop of pcgtw/pmaxw around VU0 calls was 10% of the
game thread in a busy fight; the stretch's CPU time is down about a fifth.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 00:34:01 +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
boubou666 edf3baeea2 Merge pull request #149 from TheBozos/claude/picture-crop
Window: setPictureCrop, the picture zoomed to another shape
2026-11-25 18:02:53 +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 f125fbfe3a mixer: an opt-in core input read from sound memory without a block transfer
The SPU2 mixes each core's sound data input from sound memory (core c's left samples at bytes 0x4000 + 0x800 c,
its right ones 0x400 further, 512 each) at the output position, whatever writes it: an AutoDMA block transfer,
or a driver's ordinary transfers. The mixer only played the input of a block transfer. Amplitude's softFX
writes its software mix there by voice transfers, double-buffered by halves on the output IRQ, and never starts
a block transfer: the song select's preview loops were silent.

Mixer::setMemoryInput(true) reads the input from sound memory at the output position while no block transfer
feeds it, through the core's input volume and mix routing. Off by default: nothing changes for other ports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 16:52:18 +01:00
boubou666 0a5c32e3e6 Merge pull request #101 from TheBozos/jc2/native-irx-host
Native IRX host: vblank waits 4 and 6, data guesses left out of discovery, stuck task named
2026-11-25 15:07:06 +01:00
boubou666 8470f7c29c Merge pull request #139 from TheBozos/jc2/state-older-sections
Save states: read pad, mpeg, sif and 989SND sections written before their newer fields
2026-11-25 15:06:28 +01:00
boubou666 cbdd7e3f49 Merge pull request #147 from TheBozos/amp/spu2-output-irq
mixer: the output write-back reaching an IRQ address raises the SPU2 IRQ
2026-11-25 15:03:30 +01:00
Thomas MartinandClaude Opus 5.5 d000472614 mixer: the output write-back reaching an IRQ address raises the SPU2 IRQ
The SPU2 writes each output sample back to sound memory at the same position (0-511) of 512-sample rings: the
voice 1 / 3 outputs and both cores' dry and wet mixes, halfwords 0x0400-0x1FFF. Harmonix's softFX (Amplitude's
SOFTFX_S) points a core's IRQ address into those areas as a sample-clocked timer and refills its stream buffers
on each IRQ; the mixer only raised the IRQ on voice reads and transfers, so the streams never refilled.

Mixer::reachOutputIrq steps the write-back position with each output frame and raises the IRQ of a core whose
enabled IRQ address sits there. The position is not saved in states (a load shifts the next IRQ by at most one
ring).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 14:57:48 +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 bca53d29a5 Stall sound held to the host's time, as a frame's is
In real time a stall's sound (the watcher's, while no frame ends: a
load) was the engine brought up to the EE clock, its disc waits counted
where the PC had none: The Third Age's first movie after the title gave
about 1.3 s of extra sound in a second (bursts up to 8613 samples), and
the output queue dropped 1.2 s of it. stallSound now goes through the
same budget as frameSound (holdToHostTime): 52K samples in that second,
the queue at most 82 ms, nothing dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 20:59:08 +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
Thomas MartinandClaude Opus 5.5 52ac66bb36 libs: Libraries::dmaStarted, a port told when the game starts a DMA channel
The I/O library completes a channel the game starts (CHCR with STR) at once: no DMA, no VIF, no GIF. A port that
needs to know what the game sent can now read the transfer there: dmaStarted(channel, its registers) is called as
the channel starts, before the library completes it; unset, nothing changes. JC2 uses it to follow the GS image
transfers in its VIF1 and GIF chains (which RAM went to which texture page), for the effects whose texture records
are their own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 16:33:52 +01:00
Thomas MartinandClaude Opus 5.5 2903dbe686 Renderer: draws assembled in place (appendVertices, drawRange, continueFrame)
A port that makes its draws' vertices itself (Shinobido's GS translator: 30,000
primitives a frame) built them in its own batches and draw() copied every one into the
frame being built at the flip. Now it can make them straight into that frame:
appendVertices gives room at its end, drawRange adds a batch over vertices already there
(two batches may share a range, as a two-pass draw's do), and continueFrame starts the
frame like beginFrame but keeps the vertices appended since the last one ended. draw() is
append + drawRange (a refused batch keeps none of its vertices).

tests/render/draw_in_place_tests.cpp: the same frame digest as draw()'s copies, shared
ranges, a range past the vertices refused, beginFrame dropping what was appended.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 13:38:17 +01:00
Thomas Martin 24dddf439c Merge branch 'jc2/state-older-sections' into jc2/native-irx-host 2026-11-24 12:10:21 +01:00
Thomas Martin 570bba3e48 Merge remote-tracking branch 'origin/master' into jc2/native-irx-host 2026-11-24 12:10:21 +01:00
Thomas MartinandClaude Opus 5.5 b1dc62d002 libs: IpuStream, a game's own .ipu streams decoded natively (FFmpeg's ipu parser and decoder)
For a game that drives the IPU itself to play Sony's ".ipu" files (header "ipum", size, width, height, frame count,
then intra-only IPU frames) as animated textures: no IPU, no DMA. open() copies the file and splits its frames with
FFmpeg's "ipu" parser; decodeMacroblocks(index, out) gives a frame as the IPU's colour conversion (CSC, RGB32) writes
it, 16 x 16 macroblocks in raster order (BT.601 video range), and decodeRaster the picture's rows. Built with
BOZO_HAVE_FFMPEG like libmpeg's decoder; without FFmpeg open() fails and the port keeps its own path.

JC2 answers its IPU player with it (scene D001's water: 64 x 64, 298 frames decoded into the game's ring).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 12:10:21 +01:00
Thomas MartinandClaude Opus 5.5 de65040fec Save states: read the pad, mpeg, sif and 989SND sections written before their newer fields
States saved before these sections grew fail to load ("section pad ends before its fields"; then mpeg, sif) and the
game starts from the boot. JC2's states from before 2026-11-24 hit all four:
- pad: libpad2's sockets (pad2Sockets, pad2Next) came after multitapAttached; an older section ends there, and no
  socket is open.
- mpeg: inputEnded (MpegOptions::sdkNodata) came before the sound; an older section has exactly the sound left, and
  the input goes on.
- sif: the IOP side's software registers came before the heap; the older layout is tried first and kept only when it
  reads the section exactly (Archive::end checks it), with the registers cleared; otherwise the reader rewinds.
- snd: a state from before the 989SND driver was saved has "timers" next; the driver stays as it is.

Archive::sectionLeft(): the bytes the open section has left when reading. What is written does not change.

bozo-state-tests (sectionLeft) passes, with the whole engine suite on jc2/native-irx-host (symbol_maps aside: the
build's temp directory has "game" in its path). JC2: s24300_arena.state, saved on the engine before these fields,
loads again and the run goes on in the scene it was saved in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 12:09:55 +01:00
Marc-Etienne Barrut 0a2459a35c Merge pull request #138 from TheBozos/perf/fight-frames
[perf/fight-frames] VU0 FMAC inlined; the frame pacer on a waitable timer on Windows
2026-11-24 17:41:10 +07:00
Thomas Martin 9a8a3a41d3 Merge remote-tracking branch 'origin/master' into jc2/native-irx-host 2026-11-24 11:37:11 +01:00
Thomas MartinandClaude Opus 5.5 b8f8f37b71 Wording: rewrap the two lines to the files' width
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 11:20:55 +01:00
Thomas MartinandClaude Opus 5.5 1ee6e6e531 Wording: match1p's readbacks are on the "No lives left" screen, not an attract demo
Frames 13736 on are the game-over screen after the 1P match (tmb-check's hidden
captures at 13740 and 15900). Comment and spec text only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 11:20:37 +01:00
boubou666 d04e9d863c Merge pull request #135 from TheBozos/dc/msaa-decal-offset
Material depth offset: decals land under anti-aliasing
2026-11-24 11:17:42 +01:00
Thomas MartinandClaude Opus 5.5 8ee365b4a2 Material depth offset: decals land under anti-aliasing
Material::depthOffsetSlope / depthOffsetUnits (glPolygonOffset, toward the camera): with anti-aliasing a
target sharing the frame's depth gets the depth resolved from one sample point off each pixel's centre,
which on a steep surface can lie nearer than a decal's centre depth, so marks laid at the surface's own
depth all failed (Dark Cloud's character shadows vanished at 4x). 0, 0 (the default) draws as before.

native_render_targets: a decal on a steep slope through a shared-depth target lands with no
anti-aliasing (with and without the offset) and, with the offset, at 4x and 8x. Without the offset at
4x every mark failed (checked, not kept as a case: which sample the resolve takes is the driver's).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 10:50:23 +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