Commit Graph
117 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 b4b8e2e733 AvcDecoder: Check the pixel format
AvcDecoder handed out frame_->data[0..2] without looking at the pixel format,
and everything downstream indexes them as 8-bit 4:2:0. Check it, and drop the
frame instead of converting whatever else turned up.

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årdandClaude Opus 5 7c6f9d18b8 sceMpegbase: implement the colour conversion functions
Five of the six functions in this module were registered as nullptr, so any
caller reaching them got nothing. mpeg.prx needs all of them, and this is the
first of the pieces required before the real module can run in place of our
sceMpeg HLE.

The module gets its own file at the same time. It was a tail of sceMpeg.cpp,
which is long enough already, and everything below is new code for it.

sceMpegBaseCscAvc and sceMpegBaseCscAvcRange convert the ME's decoded output to
RGB. The 48-byte descriptor holds the frame size in macroblocks at 0x10 and
0x14 - it appears at 0x00/0x04 too, but scaled differently depending on which
path built it, so the second pair is the one every caller agrees on - and the
four luma buffers at 0x20. What they point at is not planar: luma arrives as
16-pixel-wide vertical strips alternating between buffers on every other line,
and chroma as Cb/Cr pairs interleaved across four more. All eight are untangled
into planes once per frame before converting, which keeps the pixel loop
readable.

sceMpegBaseCscInit carries the default buffer width for callers that pass zero.
sceMpegBaseCscSetPixelMode (0x0530BE4E - the official name isn't known) carries
the output format, in mpegbase's own numbering rather than the GE's: mpeg.prx
gets it by indexing a table of {1, 2, 3, 0} with the pixel mode the game gave
sceMpegAvcDecodeMode, making 0 ABGR8888 and 2 ABGR5551. Read as a GE mode it
turned Thrillville's black into blue.

sceMpegBaseYCrCbCopy copies the descriptor but not the buffers it points at,
and says so in its log - nothing seen so far needs more, and inventing the
buffer copy without something to test it against seemed worse than a note.

Behaviour is cross-checked against JPCSP, which implements all of these.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 11:52:09 -06:00
Henrik Rydgård 9205eb642a UWP buildfix, tweaks and de-clauding 2026-08-24 12:15:31 +02:00
Henrik RydgårdandClaude Opus 5 e7e8d362f0 Add sceResmgr, which is what the VSH uses to decrypt the XMB index
Found the cause of the red error screen the VSH ends on. Every resource load in
the boot succeeds - fonts, all the plugin RCOs, topmenu_icon.rco - and then:

  sceIoOpen(flash0:/vsh/etc/index_02g.dat) -> fd 8
  sceIoRead(8, 092a2d40, 496)
  sceIoClose(8)
  unresolved import sceResmgr/9dc14891, called from 'vsh_module'
  sceKernelExitDeleteThread(1)

index_02g.dat is the index of what the XMB displays, and it is encrypted (it
starts "PSPsysGP"). sceResmgr_9DC14891 decrypts it. There was no sceResmgr module
at all, so the call trapped, the index stayed encrypted, and the ScePafJob thread
building the top menu exited - a shell with everything loaded and nothing to show.

This adds the module and the three tags it needs (0x0B2B90F0/91F0/92F0, keys and
code 0x5C) to PrxDecrypter.

It is not the whole fix yet: pspDecryptPRX() tries decryption types 0, 1, 2, 5
and 6, and this needs type 9, which JPCSP passes explicitly. So the call is now
reached and fails cleanly with a logged error instead of trapping, but does not
yet decrypt. Type 9 is a variant of type 2 and is the next job; the notes in
docs/VSHBootInvestigation.md say where it is in JPCSP and how to check a port
(159 bytes out, starting "release:").

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-24 11:12:59 +02:00
Henrik Rydgård ed5c05fb28 VSH boot: load real kd/ kernel driver modules
Extends LoadAndStartVshKernelModules() to load the 11 real kd/*.prx
kernel drivers for --vsh (dmacman, systimer, memlmd_01g,
loadexec_01g, lowio, idstorage, syscon, rtc, wlan, wlanfirm_01g, utility),
ahead of the existing 4 VSH-specific modules.
Only active when g_runningVSH, no effect on normal game boot.

Improve implementations of sceKernelSm1ReferOperations and sceKernelIsIntrContext.

Add some more MMIO stubs (GPIO, SYSCON).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
(cherry picked from commit 7f3168b7df85e47438900016c9ee7d7ef01a0a28)
2026-08-24 10:58:35 +02:00
Henrik RydgårdandClaude Sonnet 5 04a8948ded Add a VSH-only allowlist for real-loading flash0 modules, sceVshCommonUtil stub and sceVshBridge
Load and start VSH's kernel modules before booting vshmain.prx

A few flash0 modules (vshbridge.prx, paf.prx, common_gui.prx,
common_util.prx) should run for real once we know we're
actually booting the VSH rather than a game, since our fakes are unlikely
to be good substitutes for the genuine thing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PSNaZnHCjmryS3ziVN9gZU
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ård 31decccb9a Style and comment settings. Surface a setting in the ImDebugger. 2026-08-20 01:05:19 +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 a555fe8924 Partially implement sceReg 2025-04-03 14:13:50 +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 fdb606c8cb Break out sceAac from sceMp4.cpp/h 2025-02-14 09:50:55 -06:00
Nemoumbra 4e8b1f24d6 Added dummy funcs + registered the module 2025-02-12 16:49:43 +03:00
Nemoumbra ef11d80b84 UPnP logs, wrong NpMatching2 syscall name, more names 2025-01-10 23:34:11 +03:00
Henrik Rydgård 56dd10f283 Fix savestates 2025-01-05 00:00:06 +01:00
White Blood CellandAdamN ee0b0fce6c sceNetInet and sceNetResolver support.
Co-authored-by: AdamN <anr2000@gmail.com>
2025-01-04 17:28:36 +01:00
Nemoumbra 60e502c259 Restored the order of HLE module registration 2025-01-03 23:33:09 +03:00
Nemoumbra 96f9749e2e Split out the matching code from sceNetAdhoc.cpp 2025-01-03 04:59:26 +03:00
Henrik Rydgård ccd5bcaa45 Add facility for __KernelGPUReplay to request to be called again 2024-12-10 01:27:25 +01:00
Florin9doi cad232e60e sceSircs/Infrared support on Android 2024-01-12 20:29:53 +02:00
Unknown W. Brackets c122ee0a11 HLE: Add some assorted detected func names.
These come from here:
https://github.com/SiSTR0/sce_symbols/blob/main/psp_names.txt
2023-06-06 23:50:49 -07:00
sum2012 63606634bb Add InterruptManagerForKernel
Find in #16297
2022-10-31 20:17:12 +08:00
sum2012 4764c54803 Fix save states 2022-10-16 15:23:33 +08:00
Henrik Rydgård 52c6169a59 Merge pull request #13241 from ANR2ME/openpsid
Added some missing OpenPSID nids and some stub functions
2020-12-20 14:18:13 +01:00
sum 37737ceaa1 Add draft sceKernelFindModuleByUID (#13380)
* Add draft sceKernelFindModuleByUID

#13205

* Add KERNEL_SYSCALL flag

* oop

* oop2

* Not sure why make this change before

* Last night I might be too tried
2020-09-05 07:29:56 +02:00
ANR2ME 051bbb6e14 Added 1 new NID of OpenPSID Service, also added Init & Shutdown function 2020-08-22 19:47:33 +07:00
sum a897be92c7 Imp sceUtilsBufferCopyWithRange and sceUtilsBufferCopyByPollingWithRange (#13206)
* Imp sceUtilsBufferCopyWithRange

Used in Shin Sangoku Musou 6 Special chinese patach #13205

* Fix sceUtilsBufferCopyByPollingWithRange

* Add logging and reporting

* Fix logging and remove report by @hrydgard
2020-08-01 14:15:12 +02:00
sum2012 a6b1f9d1f8 oop 2020-06-21 11:03:04 +08:00
sum2012 2fcb55a772 Add a sceOpenPSID_driver nid
Used in  "Shin Sangoku Musou 6 special" chinese patched game
2020-06-21 11:01:21 +08:00
Henrik Rydgård e3aa2f5e4c Assorted fixes (build and crash) 2020-04-26 11:19:31 +02:00
Unknown W. Brackets 9cb74691b6 Core: Add argmask for threadhacks to prevent crash.
Every HLEFunction should have an argmask.  Some asserts for shutdown
crashes someone was seeing when calling HLE funcs from a shutdown
function.
2020-03-22 23:33:05 -07:00
Unknown W. Brackets 54e1afda1e HLE: Make calling mips funcs simpler.
This makes their return value handling, scheduling, etc. more
straight-forward.
2020-03-22 06:59:43 -07:00
Florin9doi 99c4a00dae sceUsbMic 2019-08-03 21:09:33 +03:00
LunaMoo f038b6489a Add sceUsbAcc stubs, improves EyePet(fixes endless loop on boot) 2018-08-15 18:35:07 +02:00
Florin9doi 892bc8617d Integrate sceUsbGps and sceUsbCam with Android 2017-08-27 17:19:11 +03:00
Unknown W. Brackets 36069d1446 GE Debugger: Simple framework to load dumps.
This tries to execute them within the context of the emulator as much as
possible, so we don't have weird bugs.  Going with a file type so we can
easily load the dump by opening the file directly.
2017-06-03 15:29:11 -07:00
Henrik Rydgard d3305b88b9 Partially implement KUBridge, trying to help #8925. However, it doesn't even call the function.... Odd. 2016-10-09 12:40:40 +02:00
Unknown W. Brackets e78a389ecc Move sceIo kernel tables to sceIo. 2016-08-04 09:46:29 -07:00
Unknown W. Brackets 4b4770bbc5 Log kernel syscalls with a K.
This way they can be properly differentiated.
2016-08-04 09:46:26 -07:00
Unknown W. Brackets 9b706975ad Module: Reimport stubs on load state. 2016-05-29 08:27:19 -07:00
sum2012 29f24a600e Add sceNetIfhandle staff
Used in Yu-Gi-Oh 5Ds Tag Force 4
2016-02-13 20:27:07 +08:00
Unknown W. Brackets fcf0518223 Update all the HLE tables with arg and ret info. 2015-03-22 20:51:55 -07:00
sum2012 c2435c1e9b Add sceNetUpnp module 2015-03-08 20:07:03 +08:00
sum2012 18e7e73646 Type missing in HLETable.cpp 2015-03-08 16:53:49 +08:00
sum2012 8b2712975a Forget update HLETables.cpp 2015-03-08 16:27:12 +08:00
sum2012 0157f88035 Fix sceUsbCam 2015-03-08 12:37:56 +08:00
sum2012 7b262949aa Add sceAudioRouting
First step to fix "Invizimals" 's game
2015-03-08 10:58:12 +08:00
daniel229 21b0c2992b Implement sceSfmt19937 module. 2015-02-15 13:22:20 +08:00
daniel229 851070a6f8 Implement sceAdler32 2015-02-08 09:35:00 +08:00