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]>
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]>
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]>
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]>
- 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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
- 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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>