pcsx-redux icon indicating copy to clipboard operation
pcsx-redux copied to clipboard

SIO0 overhaul

Open johnbaumann opened this issue 1 year ago • 7 comments

~~Draft~~ PR, trying to shore up various changes I had worked up in preparation of adding multitap support. My initial branch became sorely outdated and conflicted, this branch attempts to cherry pick some of these changes and bring the branch back in line with head. Needs some additional cleanup; get rid of vectors, mentions of multitap, test various things, etc.

  • Moved all/most card + pad specific code out of SIO class
  • Began abstracting generic card & pad functions such as file IO to a parent class

johnbaumann avatar Jun 23 '24 16:06 johnbaumann

This one is ready for review. Moved a lot of things around to split the card and pad code away from the sio class.

johnbaumann avatar Aug 05 '24 02:08 johnbaumann

You're making Linux sad :)

nicolasnoble avatar Aug 09 '24 02:08 nicolasnoble

Looks like there's still an asan error, with a mismatched new/delete type.

nicolasnoble avatar Aug 09 '24 22:08 nicolasnoble

Codecov Report

Attention: Patch coverage is 8.85781% with 391 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@15520a9). Learn more about missing BASE report.

Files Patch % Lines
src/core/memorycard.cc 5.98% 220 Missing :warning:
src/core/sio.cc 15.68% 43 Missing :warning:
src/gui/widgets/memcard_manager.cc 0.00% 42 Missing :warning:
src/core/memorycard.h 11.90% 37 Missing :warning:
src/core/pad.cc 21.05% 30 Missing :warning:
src/core/sstate.cc 0.00% 16 Missing :warning:
src/gui/widgets/memcard_manager.h 0.00% 3 Missing :warning:
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1673   +/-   ##
=======================================
  Coverage        ?    9.87%           
=======================================
  Files           ?      448           
  Lines           ?   133030           
  Branches        ?        0           
=======================================
  Hits            ?    13143           
  Misses          ?   119887           
  Partials        ?        0           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 18 '24 04:08 codecov[bot]

@coderabbitai full review

johnbaumann avatar Jan 05 '25 01:01 johnbaumann

:white_check_mark: Actions performed

Full review triggered.

coderabbitai[bot] avatar Jan 05 '25 01:01 coderabbitai[bot]

Summary by CodeRabbit

Based on the comprehensive changes across multiple files, here are the release notes:

Release Notes

  • Memory Card Management

    • Introduced a new MemoryCards class to centralize memory card operations
    • Enhanced memory card block information retrieval and management
    • Improved error handling for memory card interactions
  • Pad and SIO Interactions

    • Refined communication protocols for game controllers
    • Streamlined device selection and data transmission methods
    • Added more robust acknowledgment handling
  • Emulator State Management

    • Updated save state structure for more efficient memory card tracking
    • Simplified memory card initialization and configuration
    • Improved type safety with enumerated memory card references
  • User Interface

    • Updated memory card manager to support new memory card management system
    • Enhanced icon and file export capabilities for memory card blocks

These changes represent a significant refactoring of the memory card and device interaction systems, focusing on improved reliability and maintainability.

Walkthrough

The pull request introduces a comprehensive refactoring of memory card and serial input/output (SIO) management in the PCSX emulator. The changes centralize memory card operations into a new MemoryCards class, removing memory card-related functionality from the SIO class. This restructuring enhances code organization, introduces more robust error handling, and provides a clearer interface for memory card interactions. The modifications span multiple files, updating method signatures, adding new methods, and reorganizing how memory card data is accessed and managed throughout the emulator.

Changes

File Change Summary
src/core/memorycard.cc/h Added MemoryCards class with methods for loading, saving, erasing, and managing memory card blocks. Introduced new methods like loadMcds, getMcdBlockInfo, eraseMcdFile, and getFreeSpace.
src/core/pad.cc/h Refined pad interaction methods, adding transceive and deselect methods to improve communication handling.
src/core/psxemulator.cc/h Added m_memoryCards member to Emulator class, introducing a new management point for memory card operations.
src/core/sio.cc/h Removed memory card-specific methods and simplified SIO class functionality.
src/core/sstate.cc/h Updated save state structure to reference memory card data through new m_memoryCards.
src/gui/widgets/memcard_manager.cc/h Updated method signatures and memory card handling to use new MemoryCards class.
src/main/main.cc Simplified memory card initialization logic by consolidating loading into a single function call using m_memoryCards->loadMcds(args).

Sequence Diagram

sequenceDiagram
    participant Emulator
    participant MemoryCards
    participant MemoryCard
    participant SIO

    Emulator->>MemoryCards: loadMcds(args)
    MemoryCards->>MemoryCard: createMcd(path)
    MemoryCards->>SIO: writePad/writeCard
    MemoryCard-->>MemoryCards: return block info
    MemoryCards-->>Emulator: memory card loaded

Suggested reviewers

  • nicolasnoble

Poem

🐰 Hop, hop, memory cards anew,
Refactored code, a cleaner view!
SIO's burden, now set free,
Emulator's dance of clarity
Memory managed with rabbit's might! 🎮

[!TIP]

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Jan 05 '25 01:01 coderabbitai[bot]