Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[develop] Add basic support for ED64 X series #137

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from

Conversation

networkfusion
Copy link
Collaborator

@networkfusion networkfusion commented Aug 24, 2024

Description

Add basic support for ED64 X series
Only loads ROM's (no save support)

Motivation and Context

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that adds a new feature)
  • Bug fix (fixes an issue)
  • Breaking change (breaking change)
  • Documentation Improvement
  • Config and build (change in the configuration and build system, has no impact on code or features)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Signed-off-by: GITHUB_USER <GITHUB_USER_EMAIL>

Summary by CodeRabbit

  • New Features

    • Added support for the ED64 Xseries flashcart, including initialization and file management capabilities.
  • Bug Fixes

    • Improved clarity in flashcart initialization logic, ensuring accurate handling of different flashcart types.
  • Documentation

    • Enhanced documentation comments across the codebase for better clarity on functionalities and features.

Copy link

coderabbitai bot commented Aug 24, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce a new source file for the ED64 flashcart implementation and modify existing files to incorporate support for a new feature, FLASHCART_FEATURE_AUTO_CIC. The modifications expand functionality in both new and existing components of the flashcart system, ensuring better management of various flashcart features and device types.

Changes

Files Change Summary
Makefile Added flashcart/ed64x/ed64x.c to the SRCS variable.
src/flashcart/64drive/64drive.c Added case for FLASHCART_FEATURE_AUTO_CIC in d64_has_feature function.
src/flashcart/ed64x/ed64x.c, ed64x.h, ed64x_ll.h Introduced new functionality for ED64 flashcart, including various operations and a header for low-level access.
src/flashcart/flashcart.c Updated initialization logic for CART_EDX to call ed64x_get_flashcart(), enhanced comments.
src/flashcart/flashcart.h Added FLASHCART_FEATURE_AUTO_CIC to flashcart_features_t enumeration.
src/flashcart/sc64/sc64.c Added case for FLASHCART_FEATURE_AUTO_CIC in sc64_has_feature function.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Flashcart
    participant ED64X

    User->>Flashcart: Initialize ED64X
    Flashcart->>ED64X: Call ed64x_get_flashcart()
    ED64X-->>Flashcart: Return ED64X instance
    Flashcart-->>User: ED64X Initialized
Loading

🐰 In a world of code and light,
The flashcarts burst into flight,
New features hop, a joyful dance,
With every change, we take a chance!
So here’s to leaps in tech’s embrace,
A rabbit’s cheer in cyberspace! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 resolve resolve all the CodeRabbit review comments.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@networkfusion
Copy link
Collaborator Author

@coderabbitai review

Copy link

coderabbitai bot commented Aug 24, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (5)
src/flashcart/ed64x/ed64x.c (4)

26-29: Initialization function is a placeholder.

The ed64x_init function currently does nothing and returns FLASHCART_OK. Ensure to implement any necessary initialization logic in the future.


31-34: De-initialization function is a placeholder.

The ed64x_deinit function currently does nothing and returns FLASHCART_OK. Ensure to implement any necessary de-initialization logic in the future.


132-136: Save loading function is a placeholder.

The ed64x_load_save function currently does nothing and returns FLASHCART_OK. Ensure to implement the save loading logic in the future.


138-142: Set save type function is a placeholder.

The ed64x_set_save_type function currently does nothing and returns FLASHCART_OK. Ensure to implement the logic for setting save types in the future.

src/flashcart/flashcart.c (1)

116-116: Clarify comment for CART_ED.

The updated comment for CART_ED as "Series V EverDrive-64 or clone" provides better context and clarity.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4e4c109 and 323e238.

Files selected for processing (8)
  • Makefile (1 hunks)
  • src/flashcart/64drive/64drive.c (1 hunks)
  • src/flashcart/ed64x/ed64x.c (1 hunks)
  • src/flashcart/ed64x/ed64x.h (1 hunks)
  • src/flashcart/ed64x/ed64x_ll.h (1 hunks)
  • src/flashcart/flashcart.c (2 hunks)
  • src/flashcart/flashcart.h (1 hunks)
  • src/flashcart/sc64/sc64.c (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/flashcart/ed64x/ed64x_ll.h
Additional comments not posted (21)
src/flashcart/ed64x/ed64x.h (1)

1-24: Header file looks good.

The header file is well-structured with appropriate header guards and a clear function declaration for ed64x_get_flashcart.

src/flashcart/flashcart.h (1)

32-32: Feature addition looks good.

The addition of FLASHCART_FEATURE_AUTO_CIC to the flashcart_features_t enumeration is consistent with the existing features.

src/flashcart/ed64x/ed64x.c (3)

41-50: Feature checking relies on incomplete function.

The ed64x_has_feature function logic appears correct but depends on the incomplete get_cart_model function. Ensure that get_cart_model is implemented correctly for accurate feature checking.


52-92: ROM loading function looks good.

The ed64x_load_rom function is well-implemented, with appropriate error handling and progress reporting.


94-130: File loading function looks good.

The ed64x_load_file function is well-implemented, with appropriate error handling.

Makefile (1)

33-33: LGTM! Addition of ed64x.c is appropriate.

The inclusion of flashcart/ed64x/ed64x.c in the SRCS variable is correct and aligns with the PR objective of adding support for the ED64 X series.

src/flashcart/flashcart.c (2)

14-14: Include ed64x.h for ED64 X series support.

The inclusion of ed64x.h is necessary for the integration of the ED64 X series functionality.


112-113: Update for CART_EDX initialization is appropriate.

The change to use ed64x_get_flashcart() for CART_EDX aligns with the new support for the Official EverDrive 64 Series X.

src/flashcart/64drive/64drive.c (1)

78-78: Support for FLASHCART_FEATURE_AUTO_CIC added.

The addition of the FLASHCART_FEATURE_AUTO_CIC case in d64_has_feature expands the function's capability to recognize this feature.

src/flashcart/sc64/sc64.c (12)

256-258: Addition of FLASHCART_FEATURE_AUTO_CIC looks good!

The new feature case has been correctly added to the sc64_has_feature function.


Line range hint 72-94: Function load_to_flash is well-implemented.

The function handles loading data to flash memory with appropriate error handling and progress updates.


Line range hint 97-103: Function disk_zone_track_is_bad is correctly implemented.

The logic for checking bad tracks is straightforward and correct.


Line range hint 105-111: Function disk_system_lba_is_bad is correctly implemented.

The logic for checking bad LBAs is straightforward and correct.


Line range hint 113-118: Function disk_set_thb_mapping is correctly implemented.

The logic for setting THB mapping is correct and follows the expected pattern.


Line range hint 120-154: Function disk_load_thb_table is correctly implemented.

The logic for loading the THB table is sound and follows the expected pattern.


Line range hint 156-164: Function disk_load_sector_table is correctly implemented.

The logic for loading the sector table is sound and follows the expected pattern.


Line range hint 167-205: Function sc64_init is correctly implemented.

The logic for initializing the SC64 flashcart is sound and follows the expected pattern.


Line range hint 207-212: Function sc64_deinit is correctly implemented.

The logic for deinitializing the SC64 flashcart is sound and follows the expected pattern.


Line range hint 260-317: Function sc64_load_rom is correctly implemented.

The logic for loading a ROM file is sound and follows the expected pattern.


Line range hint 319-342: Function sc64_load_file is correctly implemented.

The logic for loading a file into memory is sound and follows the expected pattern.


Line range hint 344-381: Function sc64_load_save is correctly implemented.

The logic for loading a save file is sound and follows the expected pattern.

Comment on lines 36 to 39
static ed64x_device_variant_t get_cart_model() {
// Currently either X5 or X7
return true; // FIXME: check cart model.
}
Copy link

Choose a reason for hiding this comment

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

Incomplete function implementation.

The get_cart_model function is incomplete and contains a FIXME comment. It currently returns true, which is likely incorrect. Implement the logic to determine the actual cart model.

@networkfusion networkfusion force-pushed the ed64-xseries branch 4 times, most recently from 31d0758 to 866387a Compare August 30, 2024 20:54
Improve variant enumeration
@networkfusion
Copy link
Collaborator Author

This change is dependent on libcart changes for detection to work properly:

#include <string.h>
int edx_init(void)
{
    __cart_acs_get();
    io_write(EDX_KEY_REG, EDX_KEY);
    io_write(EDX_SYS_CFG_REG, EDX_CFG_SDRAM_OFF);
    /* Check Bootloader ROM label */
    __cart_dma_rd(__cart_buf, 0x10000020, 20);
    if (
        memcmp(__cart_buf, "EverDrive bootloader", 20) &&
        memcmp(__cart_buf, "ED64 SD boot", 12)
    ) CART_ABORT();
    io_write(EDX_SYS_CFG_REG, EDX_CFG_SDRAM_ON);
    __cart_dom1 = 0x80370C04;
    cart_size = 0x4000000; /* 64 MiB */
    __cart_acs_rel();
    return 0;
}

We await the change to be merged to libdragon.

@networkfusion networkfusion changed the title Add basic support for ED64 X series [develop] Add basic support for ED64 X series Dec 24, 2024
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