Skip to content

Dispatch syscalls 0x79/0x7A to the existing SIF register handlers - #274

Open
llesieur99 wants to merge 1 commit into
ran-j:mainfrom
llesieur99:fix/sif-register-syscalls
Open

llesieur99 wants to merge 1 commit into
ran-j:mainfrom
llesieur99:fix/sif-register-syscalls

Conversation

@llesieur99

Copy link
Copy Markdown

What this fixes

Dispatcher.cpp has no branch for syscalls 0x79 and 0x7A, so sceSifInitCmd fell through to "Unimplemented PS2 syscall" and the game never reached the SIF path.

Measured on Ratchet & Clank (SCUS-97199), 140-second run with the ISO:

before after
[Syscall TODO] lines, all v1=0x7a 31 254 (7.8 MB of error stream) 0
SIF register path never reached sceSifGetReg, sceSifSetReg, sceSifSetDma lines appear

Why 0x79 and 0x7A are SifSetReg and SifGetReg

Read off the game's own disassembly, not guessed:

0x118B60: `li v1,0x79; syscall`  called with (0x80000000, value) then
                                 (0x80000001, address)  -> two arguments
0x118B70: `li v1,0x7A; syscall`  called with (0x80000000), (4), (2)
                                 -> one argument

Two arguments is the setter, one is the getter. The SDK numbering agrees — 118 SifDmaStat, 119 SifSetDma, 120 SifSetDChain, 121 SifSetReg, 122 SifGetReg — and the three lower neighbours are already dispatched a few lines above in the same switch. Bit 31 of the register number is the PS2 convention (0x80000000 | SIF register).

What changed

Both handlers already exist in Stubs/SIF.cpp and read a0/a1, which is the syscall convention, so only the two dispatch branches were missing. The change is 19 lines in one file, no other behaviour touched.

Verification

  • Built locally against c5a9d02 (MSVC Release, exit 0) and run with the game ISO, 140 s.
  • The run above is the A/B: same binary except this commit (rac1-port-1 → rac1-port-2).
  • Scope limit, stated plainly: this fix does not make the game run. Our port still stops later, in SIF RPC initialisation; no frame is rendered. The claim here is only that the two syscalls are dispatched and the SIF path becomes reachable.

The syscall numbers were also cross-checked against the published PS2 SDK numbering, but the measurement above is what I would look at first.

The dispatcher had no branch for 0x79/0x7A, so sceSifInitCmd fell through to
"Unimplemented PS2 syscall" and never reached the SIF path. Measured on
Ratchet & Clank (SCUS-97199): 31 254 "[Syscall TODO]" lines, all of them
v1=0x7a, 7.8 MB of error stream in a 140-second run, zero frames and zero CD
reads. After the change the same run logs 0 "[Syscall TODO]" and the SIF
register path becomes reachable (sceSifGetReg / sceSifSetReg / sceSifSetDma).

The mapping was read off the disassembly rather than guessed:

  0x118B60: `li v1,0x79; syscall` called with (0x80000000, value) then
            (0x80000001, address)  -> two arguments -> sceSifSetReg(reg,val)
  0x118B70: `li v1,0x7A; syscall` called with (0x80000000), (4), (2)
                                   -> one argument  -> sceSifGetReg(reg)

The SDK agrees: 118 SifDmaStat, 119 SifSetDma, 120 SifSetDChain, 121
SifSetReg, 122 SifGetReg. The three lower neighbours (0x76/0x77/0x78) are
already dispatched a few lines above; only these two branches were missing.

Both handlers already exist in Stubs/SIF.cpp and read a0/a1, which is the
syscall convention, so only the dispatch branch was added. Bit 31 of the
register number is the PS2 convention (0x80000000 | SIF register).

Built and run locally against c5a9d02 (MSVC Release, exit 0).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant