Commit Graph
382 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 9422cb4899 sceMpegbase: save its state
The output pixel mode decides both the colour packing and the bytes per pixel of
the conversion, and a game sets it once per movie rather than per frame - so a
state resumed mid-movie converted at the default until the next
sceMpegBaseCscInit, which may never come. The gathered PES payloads go in too,
since a state can land between the copy and the decode that consumes it.

The section is optional (minimum version 0), so states written before it still
load.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 12:53:13 -06:00
Henrik RydgårdandClaude Opus 5 184c2cb4ea Implement sceVideocodec, the ME's H.264 decoding interface
The last piece mpeg.prx needs from us. It decodes through AvcDecoder and writes
the result where sceMpegbase expects to read it: for type 0, the eight-buffer
tiled layout, produced here as the exact inverse of the reader added with the
colour conversion. Type 1 hands back plain planar YUV instead.

The descriptor mpeg.prx passes in is empty - on hardware the Media Engine owns
the frame buffers and reports back where it put them - so they are allocated
here and their addresses filled in, and sceMpegbase can recover the full set
from that allocation afterwards. The list is only read as addresses once it
holds addresses: a caller that leaves small integers there used to take us
straight into a memory exception.

Both those buffers and the block sceVideocodecGetEDRAM hands out live in a
model of the ME's own 2MB of embedded DRAM rather than in either PSP partition,
with a BlockAllocator carving it up. The CPU can't reach ME memory on hardware:
mpeg.prx keeps the EDRAM value and hands it back without ever dereferencing it,
and it has no way to say where the frame buffers should go - sceVideocodecSetMemory
is given a frame size and a buffer count, 480, 272 and 2 for a full-screen movie.
Taking either from the game would push its own allocations around or spend memory
a real PSP never spends, so sceMpegbase reads the frame through a host pointer
into that block instead of through Memory::.

A game can hold several contexts at once - Silent Hill Origins runs two, one
that owns the EDRAM and one that does every decode - so the decoder, the frame
buffers and the EDRAM address are per context, keyed by context address the way
sceAudiocodec keys its decoders. The EDRAM itself the firmware tracks in the
caller's context struct and nowhere else, including refusing a second request
rather than replacing the first, as videocodec_260.prx shows, so we do the same.

Registered at the end of RegisterAllModules, since a savestate stores the
syscall opcode encoding that order.

GetSEI, ScanHeader, GetFrameCrop and the two unnamed NIDs return 0 and log -
mpeg.prx calls them but nothing yet shows what they need to return, and
guessing seemed worse than being loud about it.

Untested: nothing calls this until mpeg.prx is loaded, which is the next step.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 12:53:13 -06:00
Henrik Rydgård 11b4509158 Apply proper names to some more HLE functions 2026-08-24 17:37:39 +02:00
Henrik Rydgård 9205eb642a UWP buildfix, tweaks and de-clauding 2026-08-24 12:15:31 +02:00
Henrik RydgårdandClaude Opus 5 f449fa6ab2 Implement a batch of the VSH's unresolved imports (and document three we must not)
Mostly small stubs:

- sceImpose: GetParam/SetParam/Changes/SetStatus, plus the 6.60 alias of
  sceImposeGetBatteryIconStatus. Also fixes that function's first output - it
  is a plain "is it charging" boolean, not a BATTICON_ value. We wrote
  PSP_IMPOSE_BATTICON_NONE (0x80000000) there, which games ignore but which the
  VSH reads as "no battery" and draws the empty-battery indicator for. These
  are the bulk of the traffic: the VSH calls sceImposeChanges once a frame, so
  this alone removes ~10000 trapped calls from a boot.
- SysMemForKernel: sceKernelSetRebootKernel, sceKernelSetUmdCacheOn.
- scePower_driver: scePowerSetWakeupCondition.
- sceHprm_driver, sceUsb: one NID-named call each, as in JPCSP.

Three groups are deliberately left unresolved, with comments explaining why,
because resolving them lets real flash0 drivers walk into hardware we do not
emulate and the boot dies where it used to reach the shell:

- ThreadManForKernel mutex/fpl NIDs: the NAND and ID storage drivers use these
  to init, then poll the NAND controller at 0xbd101300 forever.
- InterruptManagerForKernel intr registration: 31 calls, then a stall in GE
  list execution with no plugin module ever started.

73 unresolved import hits over 37 distinct module/NID pairs remain in a VSH
boot, mostly sceSysEventForKernel, sceSuspendForKernel and the various
*_driver modules that need real hardware behind them.

The sceImpose savestate section goes to v2 for the two new state variables.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-24 10:58:35 +02:00
Henrik Rydgård 1d991557e8 Extend LoadExecForKernel with real VSH loadexec/exit syscalls
Adds SceKernelLoadExecVSHParam and fills in the rest of LoadExecForKernel's
NIDs: real implementations for sceKernelExitVSHVSH/Kernel
(mirrors sceKernelExitGame) and sceKernelLoadExecBufferVSHUsbWlan (loads
an exec from an in-RAM buffer instead of a file, plus UNIMPL stubs.

sceKernelLoadExecBufferVSHUsbWlan needed __KernelLoadExec split into a
file-reading front end and a shared __KernelLoadExecFromPtr back end
that both it and the new buffer-based path call into.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PSNaZnHCjmryS3ziVN9gZU
(cherry picked from commit 4adbedec9e2e3221113c9e5ad00b248bba1153e1)
2026-08-24 10:58:34 +02:00
Henrik Rydgård a0ecf545a6 Implement or stub assorted functions the VSH is calling 2026-08-21 10:56:06 +02:00
Henrik RydgårdandClaude Sonnet 5 43dccd5903 HLE: implement assorted stubs and minor functionality
This is stuff encountered in the VSH boot research.

sceRtc_driver, scePower_driver, sceImpose_driver, ThreadManForKernel funcs,
sceRtcGetAlarmTick, sceHprm_driver/sceHprmReadLatch

sceVshBridge_Driver imports sceKernelResumeDispatchThread, SuspendDispatchThread,
and NotifyCallback from ThreadManForKernel, but they were only registered under
ThreadManForUser. Added sceKernelGetUserLevel and sceKernelIsUserModeThread (new).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-19 18:38:03 +02:00
Henrik Rydgård 9f90512ef6 Make instruction cache invalidation (for us, jit cache invalidation) clearer 2026-08-16 16:59:52 +02:00
Henrik RydgårdandClaude Sonnet 5 d718bda178 Rename MIPSInt/MIPSIntVFPU to Interpreter/InterpreterVFPU
Just a file rename (plus updating all build configs and includes) to
give the interpreter source files clearer names. No functional change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019SKhm9wKEQzRUsx9mTrrtQ
2026-08-12 10:04:40 +02:00
Henrik Rydgård a957086eeb Try to fix test failure (vary strange) 2026-08-08 00:45:11 +02:00
Henrik Rydgård bb3862b37e Revert "Extend LoadExecForKernel with real VSH loadexec/exit syscalls"
This reverts commit 510cfb421c.
2026-08-07 16:01:27 +02:00
Henrik RydgårdandClaude Sonnet 5 510cfb421c Extend LoadExecForKernel with real VSH loadexec/exit syscalls
Adds SceKernelLoadExecVSHParam (matching JPCSP's reference layout - its
first four fields line up with the existing SceKernelLoadExecParam,
which is why the plain sceKernelLoadExec already worked for
sceKernelLoadExecVSHMs2) and fills in the rest of LoadExecForKernel's
NIDs from JPCSP: real implementations for sceKernelExitVSHVSH/Kernel
(mirrors sceKernelExitGame) and sceKernelLoadExecBufferVSHUsbWlan (loads
an exec from an in-RAM buffer instead of a file - the VSH's "push a game
over USB/WLAN" path), plus UNIMPL stubs for everything JPCSP itself only
knows by NID.

sceKernelLoadExecBufferVSHUsbWlan needed __KernelLoadExec split into a
file-reading front end and a shared __KernelLoadExecFromPtr back end
that both it and the new buffer-based path call into - a pure
extract-method refactor of the single most heavily used boot path in the
emulator. Verified no regression: same 11 passed / 9 pre-existing-failed
split on pspautotests/tests/cpu/*, and loader/bss still passes, before
and after this change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PSNaZnHCjmryS3ziVN9gZU
2026-08-07 08:49:25 +02:00
Henrik Rydgård 55eee26c52 Assorted warning fixes 2026-08-03 18:55:35 +02:00
Henrik Rydgård 634b9dba9b Add some new NIDs, update some comments 2026-06-15 08:16:40 +02:00
Nemoumbra 54d0e427c7 Forgot to update a comment 2026-04-12 02:26:10 +03:00
Henrik Rydgård a591fbff38 Move two more error codes to the enum 2026-01-08 22:02:08 +01:00
Henrik Rydgård cfba17b6e6 Correct error codes from sceUtilityLoadAvModule / UnloadAvModule.
Fixes #20775
2025-09-04 15:18:15 +02:00
Henrik Rydgård a08b6c1340 More error code cleanup 2025-08-06 17:44:54 +02:00
Henrik Rydgård 3e2dce1e54 Move AdHoc error codes to the big enum, fix the naming convention to be consistent 2025-08-06 17:44:54 +02:00
Henrik Rydgård 4d7b51d8cb Reimplement AA3 header parsing 2025-07-22 17:48:20 +02:00
Henrik Rydgård c61595596e Rename mp3Map to g_mp3Map 2025-07-20 19:32:05 +02:00
Henrik Rydgård 4e0b6ac3ec More misc cleanup 2025-05-14 15:14:03 +02:00
Henrik Rydgård bebcec8314 EmuScreen: Clarify some logic, add some checks 2025-04-29 16:46:14 +02:00
Henrik Rydgård b34f34ebde Move some more error codes to the big enum 2025-04-07 22:25:36 +02:00
Henrik Rydgård 89c0b5f20b sceNetResolver: Move error codes to enum, modernize logging 2025-04-07 22:16:32 +02:00
Henrik Rydgård 291e5ef1c6 Move sceMp3 error codes to the big enum 2025-04-03 21:15:09 +02:00
Henrik Rydgård 3b86539632 Fixed the dumper, so now it's complete. More games work. 2025-04-03 15:31:30 +02:00
Henrik Rydgård a555fe8924 Partially implement sceReg 2025-04-03 14:13:50 +02:00
Henrik Rydgård 77e1c9dd69 Work on audiocodec 2025-04-02 13:30:34 +02:00
Henrik Rydgård 4e25f44eef Rename some module-related functions to include HLE where appropriate 2025-03-31 11:17:50 +02:00
Henrik Rydgård 088a02bfdb Cleanup a lot of the bootup state management. 2025-03-30 14:02:29 +02:00
Henrik Rydgård 4b123a2e09 Move the sceSas error codes into the big enum 2025-03-25 12:04:33 +01:00
Henrik Rydgård 63c4b2e9b3 Move SSL error codes to the big enumt 2025-03-21 20:45:23 +01:00
Henrik Rydgård 0f840e6240 Move JPEG error codes to the big enum, some include cleanup 2025-03-21 20:44:46 +01:00
Henrik Rydgård 999bf59ae1 Move mutex error codes into the big enum 2025-03-21 20:44:46 +01:00
Henrik Rydgård 82728652d8 Move Font and Psmf error codes to the big enum 2025-03-21 20:44:46 +01:00
Henrik Rydgård ea198dd593 Add mpeg error codes to the big enum 2025-03-21 20:44:46 +01:00
Henrik Rydgård b99348383c Some new findings, loop work 2025-03-18 09:36:33 +01:00
Henrik Rydgård adbceabd93 Show fake-loaded HLE modules in the debugger. Notify Atrac of its address when one is loaded
Will be useful later.
2025-03-15 15:56:11 +01:00
Henrik Rydgård 0f9c97c2a0 Another big batch of logging cleanup 2025-03-05 17:02:46 +01:00
Henrik Rydgård 47ef0e9b6e More logging refactoring 2025-03-05 17:02:46 +01:00
Henrik Rydgård 6ddfcca0e7 Logspam fix 2025-03-05 14:02:17 +01:00
Henrik Rydgård 5ac7b8b9ee Rename the Atrac errors to match the pattern 2025-02-24 12:49:44 -06:00
Henrik Rydgård 59a4eb0ea5 Add Atrac error codes to the big enum 2025-02-24 12:07:21 -06:00
Henrik Rydgård c3708f741b Convert sceMp4 to new style hle logging 2025-02-14 09:50:55 -06:00
Henrik Rydgård d1e5b45b4b Consolidate the last spread-out error codes. 2025-02-04 12:34:49 -06:00
Henrik Rydgård d2c1c7b54f Consolidate even more error codes 2025-02-04 12:32:11 -06:00
Henrik Rydgård a18eb97be3 Consolidate more error codes into the big enum 2025-02-04 12:11:22 -06:00
Henrik Rydgård b2b0ff1753 Consolidate error codes in ErrorCodes.h 2025-02-04 11:53:00 -06:00