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]>
CreateThread took each task's stack from a bump arena (0x1fe000 down to 0x190000) and DeleteThread never gave it
back, so a game that creates and deletes IOP threads at every map load ran the arena out: Steambot Chronicles stopped
with "native library task stacks exhausted" (thbase 4) after about 20 map loads.
- DeleteThread puts the task's stack on a free list; CreateThread takes the smallest free stack that fits (its whole
size becomes the task's) before the arena's next.
- The free list is saved in the IOP section's new "taskstacks" part; a state saved before it loads with none free.
- Test: 257 CreateThread / DeleteThread pairs with 4 KiB stacks, each thread on the first one's stack.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Capcom's SNDDRV.IRX 2.27W (Breath of Fire: Dragon Quarter) parses its arguments
with strstr and moves and clears its stream buffers with wmemcopy / wmemset
(bytes / 4 words). Test: tests/native/library_sysclib_words_tests.cpp.
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]>
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]>
- MpegOptions::picturesAhead (was kPicturesAhead, 8): how far the demux reads ahead of the game. Shinobido's first
audio packet comes 14 pictures into the stream and its player waits for 0x6000 bytes of it.
- MpegOptions::sdkDemux: sceMpegDemuxPssRing as the SDK runs it. Each packet's callback runs before the demux goes
on (the calling thread waits for it), and a 0 from the sound callback ends the call before that packet, which the
next call gives again; only whole packets are taken. Shinobido's PCM callback refuses a packet when its ring is
full: with the queued callbacks a refused packet was lost, and the sound after an odd-sized one (4073 bytes) was
read a byte off (noise from 28 s into its intro). A video callback's 0 is not waited for: the decoder takes the
video from the demux and the game's own IPU input is never drained. Off by default (TMB unchanged).
- Libraries::palConsole: sceGsResetGraph's video mode 0 (the console's own standard) at 50 Hz on a PAL console.
- CompiledLibraries::useBlockTransStatusAhead: sceSdBlockTransStatus one 1 KB block ahead of the sample playing, as
the SPU2's input DMA reports it (a driver keeping its ring full by it). Off by default (TMB's logged answers kept).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Mixer: a core's IRQ address and enable (setIrqAddress / setIrqEnabled).
A voice reading the 16-byte block that holds the address (a block
decoded, a key on) or a transfer writing over it calls the IRQ
callback once. The core then stays disabled until it is enabled again,
as the SPU2's IRQ flag is cleared. Both are saved with the mixer's
state.
- libsd: SD_A_IRQA (0x1F00) and SD_CORE_IRQ_ENABLE (0x4) drive the mixer.
sceSdSetSpu2IntrHandler (27) keeps its handler, which the interrupt
calls as handler(1 << core, argument) through the host's interrupt
calls, like the transfer handlers. It was a no-op before.
- IRX host: sifcmd 18 (sceSifCheckStatRpc) answers 0, since IOP calls to
EE services complete within sceSifCallRpc. sifman 6 (sceSifSetDChain)
does nothing, as no chain mode needs arming.
Capcom's SNDDRVCD (Onimusha: Warlords) plays its voice streams (ADS)
through the SPU2 interrupt and reports a stream busy until it ends. Its
room events wait for that, so the first room's opening never started.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- compiled_libraries: sysclib 13 (memmove) shares memcpy's overlap-safe copy;
sysclib 32 (strrchr) returns the last occurrence or 0. Capcom's SNDDRVCD
(Onimusha: Warlords) imports both.
- libsd: VOLXL / VOLXR report the voice's current volume (its volume scaled
by ENVX, a sweeping volume counting as full), as the SPU2 does, instead of
the volume as set. SNDDRVCD releases a voice and polls VOLX until it
reaches 0; with the set volume it never did.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: libmpeg's Nodata end becomes a Resume record that keeps TTA's SDK callback (a[2] flags:
1 work area, 2 SDK callback; 0 is the reference's behaviour); cdvdman keeps JC2's drive commands and
TTA's sceCdSearchFile. TTA's state the archive did not have: libpad2's sockets, the IOP software
registers and libmpeg's inputEnded.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
runReady and advance() could be reached while a task was running (its
call into the EE, the EE handler calling back into the IOP), and then ran
the ready tasks nested, the calling task itself too, on its live state.
They now leave the ready tasks to the loop running that task.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- vblank 7 (WaitNonVblank) returns at once: there is no display, so never a
vblank to wait out (Jade Cocoon 2's M2SOUND).
- FunctionTable::moduleAt scanned every module on every lookup (JC2
registers 1,383 overlay modules, 559 of them sharing 0x940000, so each call
into a slot compared up to 559 headers). It now rejects addresses outside
the span all modules cover at once, and asks the module found last first,
identity checked; the full scan with its ambiguity check is unchanged when
that misses.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Jade Cocoon 2's i-mode and sound drivers (Genki's M2IMODE/M2SOUND over Sony's
IMODEMAN, LIBSD, MODMIDI, MODHSYN) on the compiled-library host:
- vblank 4 (WaitVblankStart) and 6 (WaitVblank) wait for the next native frame
tick, as 5 (WaitVblankEnd) does: no display, the start and end of a vblank
are one tick. IMODEMAN polls on 4.
- recompile.py: a pointer_seeds guess that cannot be recompiled and that no
recompiled function calls is data, not a function. It is left out instead of
failing the module (IMODEMAN.IRX 0x84c10 at base 0x6a100: a data word that
holds the address after a JR $ra). The entry, exports and --entry addresses
are never dropped. DC's LIBSD, SDRDRV, MODMIDI, MODHSYN and EZMIDI discover
the same functions as before.
- "native library tasks made no blocking progress" names each task still
running and its pc/ra (M2IOPSYS's bind retry loop, for instance).
- BOZO_NATIVE_IRX_TRACE also logs sifcmd 15 (an IOP bind of an EE service).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
QueryMaxFreeMemSize (7) and QueryTotalFreeMemSize (8) answer from the native
heap. sceSifGetOtherData (23) copies from EE RAM when called.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
init, standby, seek, disk type, disk ready, tray request, stop, clock, status, pause, break and media mode, for
compiled disc callers that set the drive up before reading (a game's own file server). They complete at once; seek,
standby, stop and pause notify the callback with their SCECdFunc code as a read does. The clock is the EE library's
(deterministic unless the host clock is chosen).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fighting for One Piece's STRADPCM waits on IOP event flags and asks
QueryIntrContext which form of a call to make; its SK sound modules
clear with bzero and SKSADPCM reads a semaphore's status. thevent 4-11,
13, 14 are native host objects on the task scheduler, as semaphores
are; waits take AND and OR, the clearing mode fails explicitly.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
For EA's sound driver in The Third Age (AUDIOPF.IRX), which talks to the EE only
through SIF commands and software registers:
- SifState::iopSreg, the IOP side's 32 software registers: sifcmd
sceSifGetSreg (6) and sceSifSetSreg (7) read and write them; a module's
set-sreg system command (sceSifSendCmd 0x80000001, index at +0x10, value at
+0x14) writes the EE's (sif.sreg). sceSifInitCmd (4) / sceSifExitCmd (5) do
nothing.
- cdvdman with native disc files: sceCdInit (4) and sceCdMmode (75) answer 1,
sceCdDiskReady (13) 2, sceCdSearchFile (10) fills sceCdlFILE from the ISO
directory as the EE library's sceCdSearchFile does.
- useReadyAudioCompletionsAfterImports(): ready audio completions also
delivered when an import call returns, for a routine that starts a libsd
transfer then polls its flag in a loop with no call. Opt-in: other ports
keep their schedule.
- setRootCallBudget(n): the work a root call may do (default 1,000,000
unchanged); AUDIOPF's start clears its buffers byte by byte.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A task's instructions move the cycle while the mixer stays behind. nextInputHalfCycle then named a cycle already past and the stop was dropped, so the step ran the mix over every half up to its target, with no handler and no refill in between. In SC3 this recurs where a vblank task lands just before a half (39 vblanks against 61 halves): 280-285 stale samples every 31232.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
sysclib 11, 19, 20, 22, 23, 30, thbase 5, 8, 10, 27, 28, timrman 10, loadcore 7, vblank 5 (a 60 Hz job on
the library clock, no display behind it). printf and Kprintf format their arguments.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A 4 KiB sceSdBlockTrans ring: a long clock step no longer plays a half before its handler
refilled it, and a status read after the input moved on still names the half to refill.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
An EE call to a server registered by a compiled module runs the handler
above the server task's parked RpcLoop frame, so it may wait (HELLO.IRX
delays inside its RPC). The host clock goes on to the next deadline until
the handler returns; a failing handler leaves the task parked.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
thbase SetAlarm, iSetAlarm, CancelAlarm, iCancelAlarm and USec2SysClock
(35-39) for HELLO.IRX: the linked handler runs on the host's timer
scheduler, its return value is the next interval, zero ends it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>