[Agent] feat(mednafen): enable PSX multi-tap support for known serials#2811
Conversation
b68c4d8 to
3f6beb6
Compare
| Ready for Human Review - AI approved, auto-merge enabled, @JoeMatt assigned. Completed: 2026-03-10 03:19 UTC |
There was a problem hiding this comment.
AI Code Review Cycle 1/3 - Reviewer: claude-opus-4-6 - APPROVE. This PR cleanly re-enables PSX multi-tap support. The implementation correctly uses MednafenGameCoreOptions for serial lookup, MDFNI_SetSettingB for settings, and modernizes pollControllers to support up to 8 players. No CRITICAL or MAJOR issues. MINOR: PVCoreBridge EmulatorCoreControllerDataSource.swift:58 has a pre-existing bug where case 8 returns controller7 instead of controller8, now reachable with 8-player support enabled by this PR.
|
No description provided. |
924bbab to
11bc838
Compare
There was a problem hiding this comment.
AI Code Review - Cycle 1/3. Reviewer: claude-opus-4-6. Summary: Clean, well-scoped change that re-enables PSX multi-tap support. The implementation correctly looks up game serials, configures Mednafen multitap settings, re-initializes input buffers, and generalizes pollControllers to support up to 8 players. No thread safety, Realm, or upstream submodule concerns. CRITICAL - none. MAJOR - none. MINOR: (1) EmulatorCoreControllerDataSource.swift:58 - Pre-existing bug exposed: case 8 returns controller7 instead of controller8. Player 8 gets wrong controller. Follow-up fix recommended. (2) executeFrameSkippingFrame only checks controllers 1-4 to decide whether to poll but game may support 5-8. NIT: controllerForPlayer called 4x per frame vs direct property access - negligible overhead. Verdict: APPROVE
|
No description provided. |
11bc838 to
f3afaed
Compare
5f56cdf to
46fe7d8
Compare
There was a problem hiding this comment.
AI Code Review — Cycle 1/3
Reviewer: claude-opus-4-6
Summary
This PR re-enables PSX multi-tap support in the Mednafen core bridge by uncommenting and modernizing the multitap detection logic. The multitap configuration logic itself (serial lookup, port settings, input buffer re-initialization) looks correct and well-structured. However, the controller polling refactor introduces a critical crash: controllerForPlayer: is called on self (a MednafenGameCoreBridge which inherits from PVCoreObjCBridge), but that method is only implemented on PVEmulatorCore (the Swift wrapper), not on the ObjC bridge class itself. This will cause an unrecognized selector crash at runtime in both pollControllers and executeFrameSkippingFrame:.
Issues
🔴 CRITICAL (must fix)
Cores/Mednafen/Sources/MednafenGameCoreBridge/MednafenGameCoreBridge.mm:~1161—[self controllerForPlayer:(NSUInteger)(playerIndex + 1)]will crash withunrecognized selector sent to instance. The methodcontroller(forPlayer:)is defined on the SwiftEmulatorCoreControllerDataSourceprotocol and implemented inPVEmulatorCore+Controller.swift, butMednafenGameCoreBridgeinherits fromPVCoreObjCBridgewhich does not implement this method. The same crash occurs at~1192inexecuteFrameSkippingFrame:. Fix: Either revert to usingself.controller1/self.controller2/etc. properties (which ARE declared onPVCoreObjCBridge) with a helper switch, or implementcontrollerForPlayer:directly onMednafenGameCoreBridge. For 8-player support, a simple switch on playerIndex accessingself.controller1throughself.controller8would work.
🟠 MAJOR (should fix)
Cores/Mednafen/Sources/MednafenGameCoreBridge/MednafenGameCoreBridge.mm:~1192— InexecuteFrameSkippingFrame:, the change only checks controllers 1–4 butpollControllersnow supports up to 8 players. If players 5–8 have controllers connected but 1–4 don't,pollControllerswon't be called. Should check up to 8, or better yet, always callpollControllerswhen multi-tap is active.Cores/Mednafen/Sources/MednafenGameCoreBridge/MednafenGameCoreBridge.mm:~929— Multi-tap settings (psx.input.pport1.multitap,psx.input.pport2.multitap) are set totruewhen a multi-tap game is loaded, but never explicitly reset tofalsefor non-multi-tap games. If Mednafen settings persist across game loads (e.g., if the emulator is reused without full reinitialization), a subsequent 2-player game could incorrectly have multi-tap enabled. Consider adding explicitMDFNI_SetSettingB("psx.input.pport1.multitap", false)/pport2in anelsebranch.
🟡 MINOR (optional)
- none
⚪ NIT
- none
Verdict: REQUEST_CHANGES 🔧
🤖 Claude Code fixer has been dispatched to address CRITICAL and MAJOR issues automatically.
|
No description provided. |
|
Fixes pushed — addressed all CRITICAL and MAJOR issues from AI review cycle 1:
|
93fbe01 to
0a6ed17
Compare
0a6ed17 to
943fcab
Compare
There was a problem hiding this comment.
AI Code Review - Cycle 1/3
Reviewer: claude-opus-4-6
Summary: Clean re-enablement of previously disabled PSX multi-tap support in the Mednafen core bridge. The code correctly looks up game serials against a known multi-tap dictionary, configures port multitap settings via MDFNI_SetSettingB, re-initializes input buffers for up to 8 players, and expands pollControllers/executeFrameSkippingFrame to support players 5-8. The else branch that explicitly disables multitap for non-multitap games is a good defensive practice to prevent setting bleed across game loads. Buffer access is safe (inputBuffer[13] accommodates indices 0-7).
CRITICAL - none | MAJOR - none
MINOR - EmulatorCoreControllerDataSource.swift:58 - Pre-existing bug: case 8 returns controller7 instead of controller8. This PR does not use controller(for:) in its new code paths (it accesses self.controller8 directly), so no issues here, but the helper is broken for 8-player scenarios elsewhere. Consider fixing in a follow-up.
NIT - MednafenGameCoreBridge.mm - The initial SetInput loop (lines 903-911, unchanged) runs with multiTapPlayerCount=2 before the new multitap detection code updates it and re-calls SetInput. Works correctly but could be slightly cleaner if reordered. Not a bug.
Verdict: APPROVE
|
No description provided. |
943fcab to
50420d0
Compare
|
No description provided. |
Re-enable PSX multi-tap support in MednafenGameCoreBridge by uncommenting and updating the serial-based detection logic. When a game serial is found in MednafenGameCoreOptions.multiTapPSXGames the bridge now: - sets multiTapPlayerCount to the correct player count - enables psx.input.pport1.multitap (and pport2 for 6-8 player games) - re-initialises input slots for the full player count Also expand pollControllers to support up to 8 players using the controller(forPlayer:) protocol accessor instead of hardcoded controller1-4 checks. Part of #2133 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…irect properties - CRITICAL: Replace [self controllerForPlayer:N] with self.controllerN switch in pollControllers to avoid unrecognized selector crash on PVCoreObjCBridge - MAJOR: Extend executeFrameSkippingFrame check to all 8 controllers - MAJOR: Explicitly reset psx.input.pport1/2.multitap to false for non-multi-tap games to prevent setting bleed across game loads Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
50420d0 to
7ae36b2
Compare
|
No description provided. |
Summary
Re-enables PSX multi-tap support in the Mednafen core bridge that was previously disabled with a "FIXME: forget about multitap for now" comment.
Changes
loadGameMednafenGameCoreOptions.multiTapPSXGames(extensive serial dictionary) to detect multi-tap games at load timepsx.input.pport1.multitap/psx.input.pport2.multitapMednafen settings appropriatelymultiTap5PlayerPort2listinputBufferslots and callsgame->SetInput()for the full player countpollControllersto support up to 8 players usingcontrollerForPlayer:instead of hardcodedcontroller1-4ivar checksTesting
Load a known multi-tap PSX title (e.g. Crash Bash
SCES-02834, BombermanSLUS-01189, or FIFA World Cup 98 for 8-player) — the multi-tap should be enabled automatically.Test plan
SLUS-01189) and verify port 2 multitap activatesmaxNumberPlayerscorrectly reflects the detected countPart of #2133
🤖 Generated with Claude Code