X Tutup
Skip to content

[Agent] feat(mednafen): enable PSX multi-tap support for known serials#2811

Merged
github-actions[bot] merged 2 commits intodevelopfrom
agent/issue-2133-mednafen-psx-multitap
Mar 10, 2026
Merged

[Agent] feat(mednafen): enable PSX multi-tap support for known serials#2811
github-actions[bot] merged 2 commits intodevelopfrom
agent/issue-2133-mednafen-psx-multitap

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 9, 2026

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

  • Uncomments and rewrites the PSX multi-tap detection in loadGame
  • Uses MednafenGameCoreOptions.multiTapPSXGames (extensive serial dictionary) to detect multi-tap games at load time
  • Calls psx.input.pport1.multitap / psx.input.pport2.multitap Mednafen settings appropriately
  • For 5-player-port-2 games (e.g. Bomberman), enables port 2 multitap per multiTap5PlayerPort2 list
  • For 6–8 player games, enables both port taps
  • Re-initialises all inputBuffer slots and calls game->SetInput() for the full player count
  • Expands pollControllers to support up to 8 players using controllerForPlayer: instead of hardcoded controller1-4 ivar checks

Testing

Load a known multi-tap PSX title (e.g. Crash Bash SCES-02834, Bomberman SLUS-01189, or FIFA World Cup 98 for 8-player) — the multi-tap should be enabled automatically.

Test plan

  • Load a 4-player multi-tap PSX game and verify 3-4 controllers are accepted
  • Load a 5-player port-2 game (Bomberman SLUS-01189) and verify port 2 multitap activates
  • Load a 2-player PSX game and verify multi-tap is NOT enabled (single-player still works)
  • Verify maxNumberPlayers correctly reflects the detected count

Part of #2133

🤖 Generated with Claude Code

@github-actions github-actions bot requested a review from JoeMatt as a code owner March 9, 2026 21:13
@github-actions github-actions bot enabled auto-merge (squash) March 9, 2026 21:13
@github-actions github-actions bot added agent-work PR or issue being worked on by the AI agent ai-reviewing AI code review in progress labels Mar 9, 2026
@JoeMatt JoeMatt mentioned this pull request Mar 9, 2026
@github-actions github-actions bot force-pushed the agent/issue-2133-mednafen-psx-multitap branch 4 times, most recently from b68c4d8 to 3f6beb6 Compare March 10, 2026 00:02
@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 10, 2026

Ready for Human Review - AI approved, auto-merge enabled, @JoeMatt assigned. Completed: 2026-03-10 03:19 UTC

Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions
Copy link
Contributor Author

No description provided.

@github-actions github-actions bot added ready-for-review AI approved; awaiting human review and removed ai-reviewing AI code review in progress labels Mar 10, 2026
@github-actions github-actions bot added the ai-reviewing AI code review in progress label Mar 10, 2026
@github-actions github-actions bot force-pushed the agent/issue-2133-mednafen-psx-multitap branch 2 times, most recently from 924bbab to 11bc838 Compare March 10, 2026 00:28
Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions
Copy link
Contributor Author

No description provided.

@github-actions github-actions bot force-pushed the agent/issue-2133-mednafen-psx-multitap branch from 11bc838 to f3afaed Compare March 10, 2026 00:40
@github-actions github-actions bot added ai-reviewing AI code review in progress and removed ai-reviewing AI code review in progress labels Mar 10, 2026
@github-actions github-actions bot force-pushed the agent/issue-2133-mednafen-psx-multitap branch 2 times, most recently from 5f56cdf to 46fe7d8 Compare March 10, 2026 02:02
Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with unrecognized selector sent to instance. The method controller(forPlayer:) is defined on the Swift EmulatorCoreControllerDataSource protocol and implemented in PVEmulatorCore+Controller.swift, but MednafenGameCoreBridge inherits from PVCoreObjCBridge which does not implement this method. The same crash occurs at ~1192 in executeFrameSkippingFrame:. Fix: Either revert to using self.controller1/self.controller2/etc. properties (which ARE declared on PVCoreObjCBridge) with a helper switch, or implement controllerForPlayer: directly on MednafenGameCoreBridge. For 8-player support, a simple switch on playerIndex accessing self.controller1 through self.controller8 would work.

🟠 MAJOR (should fix)

  • Cores/Mednafen/Sources/MednafenGameCoreBridge/MednafenGameCoreBridge.mm:~1192 — In executeFrameSkippingFrame:, the change only checks controllers 1–4 but pollControllers now supports up to 8 players. If players 5–8 have controllers connected but 1–4 don't, pollControllers won't be called. Should check up to 8, or better yet, always call pollControllers when multi-tap is active.
  • Cores/Mednafen/Sources/MednafenGameCoreBridge/MednafenGameCoreBridge.mm:~929 — Multi-tap settings (psx.input.pport1.multitap, psx.input.pport2.multitap) are set to true when a multi-tap game is loaded, but never explicitly reset to false for 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 explicit MDFNI_SetSettingB("psx.input.pport1.multitap", false) / pport2 in an else branch.

🟡 MINOR (optional)

  • none

⚪ NIT

  • none

Verdict: REQUEST_CHANGES 🔧


🤖 Claude Code fixer has been dispatched to address CRITICAL and MAJOR issues automatically.

@github-actions
Copy link
Contributor Author

No description provided.

@github-actions github-actions bot removed the ready-for-review AI approved; awaiting human review label Mar 10, 2026
@github-actions
Copy link
Contributor Author

Fixes pushed — addressed all CRITICAL and MAJOR issues from AI review cycle 1:

  • CRITICAL fixed: Replaced [self controllerForPlayer:N] (unavailable on PVCoreObjCBridge) with a switch on playerIndex accessing self.controller1...self.controller8 directly in pollControllers — eliminates the unrecognized selector crash
  • MAJOR fixed: Extended executeFrameSkippingFrame: to check all 8 controller slots (was only checking 1-4), so 5-8 player multi-tap games correctly trigger pollControllers
  • MAJOR fixed: Added explicit MDFNI_SetSettingB("psx.input.pport1.multitap", false) / pport2 in an else branch for non-multi-tap PSX games, preventing setting bleed across game loads

@github-actions github-actions bot force-pushed the agent/issue-2133-mednafen-psx-multitap branch from 93fbe01 to 0a6ed17 Compare March 10, 2026 02:16
Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Max review cycles (3) reached. Escalating to human review. See previous reviews for outstanding issues.

@github-actions github-actions bot added ready-for-review AI approved; awaiting human review and removed ai-reviewing AI code review in progress labels Mar 10, 2026
@github-actions github-actions bot force-pushed the agent/issue-2133-mednafen-psx-multitap branch from 0a6ed17 to 943fcab Compare March 10, 2026 02:32
@github-actions github-actions bot added the ai-reviewing AI code review in progress label Mar 10, 2026
Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions
Copy link
Contributor Author

No description provided.

@github-actions github-actions bot removed the ai-reviewing AI code review in progress label Mar 10, 2026
@github-actions github-actions bot force-pushed the agent/issue-2133-mednafen-psx-multitap branch from 943fcab to 50420d0 Compare March 10, 2026 02:51
@github-actions github-actions bot added the ai-reviewing AI code review in progress label Mar 10, 2026
Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Code Review Cycle 1/3 - Reviewer: claude-opus-4-6 - APPROVE. Clean re-enablement of PSX multi-tap support. No CRITICAL or MAJOR issues. One NIT: duplicated analog-center + SetInput loop could be extracted into helper.

@github-actions
Copy link
Contributor Author

No description provided.

@github-actions github-actions bot removed the ai-reviewing AI code review in progress label Mar 10, 2026
github-actions bot and others added 2 commits March 10, 2026 03:06
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>
@github-actions github-actions bot force-pushed the agent/issue-2133-mednafen-psx-multitap branch from 50420d0 to 7ae36b2 Compare March 10, 2026 03:06
@github-actions github-actions bot added the ai-reviewing AI code review in progress label Mar 10, 2026
Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Code Review Cycle 1/3 - Reviewer: claude-opus-4-6 - Verdict: APPROVE - No CRITICAL or MAJOR issues found. See status comment for full details.

@github-actions
Copy link
Contributor Author

No description provided.

@github-actions github-actions bot removed the ai-reviewing AI code review in progress label Mar 10, 2026
@github-actions github-actions bot merged commit f149edf into develop Mar 10, 2026
10 of 11 checks passed
@github-actions github-actions bot deleted the agent/issue-2133-mednafen-psx-multitap branch March 10, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-work PR or issue being worked on by the AI agent ready-for-review AI approved; awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

X Tutup