Skip to content

Nintendo support#349

Merged
superg merged 3 commits intosuperg:mainfrom
Deterous:nintendo
Feb 18, 2026
Merged

Nintendo support#349
superg merged 3 commits intosuperg:mainfrom
Deterous:nintendo

Conversation

@Deterous
Copy link
Contributor

@Deterous Deterous commented Feb 17, 2026

Summary by CodeRabbit

  • New Features

    • Added GameCube and Wii disc support for reading and displaying disc info.
    • Enhanced Nintendo-specific processing to enable raw dumping for Nintendo discs and improved descrambling when applicable.
  • Bug Fixes / Improvements

    • More reliable detection of Nintendo discs via physical-data checks.
    • Processing now stops cleanly at leadout zones to avoid extra non-data frames.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 17, 2026

📝 Walkthrough

Walkthrough

Adds GameCube and Wii system modules, updates build to include them, and modifies DVD dump/split logic to detect Nintendo discs, derive a Nintendo key from CPR_MAI data, and change raw/descrambling and ISO extraction behavior for Nintendo media.

Changes

Cohort / File(s) Summary
Build Configuration
CMakeLists.txt
Adds systems/gc.ixx and systems/wii.ixx to the redumper public file set.
DVD Dumping & Split
dvd/dvd_dump.ixx, dvd/dvd_split.ixx
Detects Nintendo discs via physical-structure header bytes; enables raw dumping for Nintendo when omnidrive firmware present; derives a Nintendo key from cpr_mai (LBA 0) and applies it during descrambling; switches main data offsets to cpr_mai for Nintendo mode; stops processing at LEADOUT_ZONE; adds #include <numeric>.
System Modules & Registry
systems/gc.ixx, systems/wii.ixx, systems/systems.ixx
Adds exported SystemGC and SystemWII modules implementing metadata parsing (magic, version, serial, title, disc number) and registers them in Systems::get().

Sequence Diagram(s)

sequenceDiagram
    participant CLI as Options/CLI
    participant Dump as dvd_dump
    participant Split as dvd_split
    participant FS as Filesystem/DataReader

    CLI->>Dump: start dump (options, omnidrive_firmware)
    Dump->>FS: read physical structure / CMD_ParameterListHeader
    FS-->>Dump: header bytes
    alt header first byte == 0xFF
        Dump->>Dump: set nintendo = true
    end
    Dump->>Split: hand off frames (nintendo flag, omnidrive_firmware)
    Split->>FS: read LBA 0 cpr_mai
    FS-->>Split: cpr_mai bytes
    Split->>Split: derive nintendo_key from cpr_mai
    loop per ECC frame
        Split->>Split: descramble using nintendo_key (if nintendo)
        Split->>FS: write ISO payload (main_data_offset or cpr_mai offset)
    end
    Split->>Dump: finish (LEADOUT_ZONE or end)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • superg

Poem

🐰 I hopped through headers, magic found with glee,

From CPR_MAI the secret key for me,
GameCube and Wii now join the run,
ISOs bloom beneath the sun,
Hooray — redumping’s hoppin’ with glee!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Nintendo support' directly and concisely describes the main change: adding GameCube and Wii disc support to the redumper tool.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@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

🧹 Nitpick comments (4)
systems/gc.ixx (1)

1-6: Unused #include <sstream>.

<sstream> is included but no std::stringstream or related type is used in this file. The output goes directly to the std::ostream &os parameter.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@systems/gc.ixx` around lines 1 - 6, Remove the unused include for <sstream>
from the module header — the file currently includes <sstream> but only uses
std::ostream &os (and no stringstream or related types), so delete the "#include
<sstream>" line to avoid an unnecessary dependency; verify compilation and that
no other symbols from <sstream> are referenced in this translation unit (look
for the include near the top with module; and alongside <format>, <string>,
<vector>, "system.hh").
systems/wii.ixx (2)

1-6: Unused #include <sstream> (same as gc.ixx).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@systems/wii.ixx` around lines 1 - 6, The file systems/wii.ixx includes
<sstream> but that header is unused (duplicate of gc.ixx); remove the stray
`#include` <sstream> line from systems/wii.ixx so only needed headers remain
(<format>, <string>, <vector>, "system.hh"), then rebuild to confirm no symbols
from std::stringstream are referenced anywhere in functions or classes in this
module.

19-72: Consider extracting shared logic between SystemGC and SystemWII.

The two classes are nearly identical in structure: same serial extraction, same title parsing, same disc_number logic, same Header layout (differing only in unknown size and magic fields). A shared base or template could reduce duplication, but this is optional given the files are small and self-contained.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@systems/wii.ixx` around lines 19 - 72, SystemWII duplicates much of
SystemGC's parsing/printing logic; refactor to extract the shared header parsing
and info printing into a common helper or base (e.g., a shared function
parse_and_print_wii_gc_header or a BaseDiscSystem class) that both SystemWII and
SystemGC call from their printInfo implementations; move common symbols/logic
(serial extraction using normalize_string, title parsing using
erase_all/std::string handling, disc_number check, and the shared parts of
struct Header layout) into that helper while keeping per-system differences
(getName(), getType(), magic constants and any differing Header field sizes) in
each subclass, and update SystemWII::printInfo and SystemGC::printInfo to
delegate to the new shared routine.
dvd/dvd_split.ixx (1)

169-169: Consider initializing nintendo_key.

nintendo_key is declared without initialization. Although it's guaranteed to be assigned at lba == 0 before use at lba == ECC_FRAMES - 1, leaving it uninitialized may trigger compiler warnings and hurts readability.

Suggested fix
-    std::uint8_t nintendo_key;
+    std::uint8_t nintendo_key = 0;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dvd/dvd_split.ixx` at line 169, nintendo_key is declared without an initial
value which can trigger warnings; initialize it where declared (e.g., set to 0
or a sentinel) to make intent clear and avoid uninitialized-use warnings—update
the declaration of std::uint8_t nintendo_key in dvd_split.ixx to include an
initializer (e.g., = 0) or switch to an optional-like type if you need an
explicit "unset" state.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@dvd/dvd_dump.ixx`:
- Line 826: The assignment to raw incorrectly treats ctx.nintendo as truthy when
the optional merely exists; update the boolean expression in the raw
initialization (the line assigning to raw) to require the optional to be true by
using ctx.nintendo && *ctx.nintendo (i.e., replace the plain ctx.nintendo check
with ctx.nintendo && *ctx.nintendo) so that presence + true value are both
required alongside options.dvd_raw and omnidrive_firmware.

---

Nitpick comments:
In `@dvd/dvd_split.ixx`:
- Line 169: nintendo_key is declared without an initial value which can trigger
warnings; initialize it where declared (e.g., set to 0 or a sentinel) to make
intent clear and avoid uninitialized-use warnings—update the declaration of
std::uint8_t nintendo_key in dvd_split.ixx to include an initializer (e.g., = 0)
or switch to an optional-like type if you need an explicit "unset" state.

In `@systems/gc.ixx`:
- Around line 1-6: Remove the unused include for <sstream> from the module
header — the file currently includes <sstream> but only uses std::ostream &os
(and no stringstream or related types), so delete the "#include <sstream>" line
to avoid an unnecessary dependency; verify compilation and that no other symbols
from <sstream> are referenced in this translation unit (look for the include
near the top with module; and alongside <format>, <string>, <vector>,
"system.hh").

In `@systems/wii.ixx`:
- Around line 1-6: The file systems/wii.ixx includes <sstream> but that header
is unused (duplicate of gc.ixx); remove the stray `#include` <sstream> line from
systems/wii.ixx so only needed headers remain (<format>, <string>, <vector>,
"system.hh"), then rebuild to confirm no symbols from std::stringstream are
referenced anywhere in functions or classes in this module.
- Around line 19-72: SystemWII duplicates much of SystemGC's parsing/printing
logic; refactor to extract the shared header parsing and info printing into a
common helper or base (e.g., a shared function parse_and_print_wii_gc_header or
a BaseDiscSystem class) that both SystemWII and SystemGC call from their
printInfo implementations; move common symbols/logic (serial extraction using
normalize_string, title parsing using erase_all/std::string handling,
disc_number check, and the shared parts of struct Header layout) into that
helper while keeping per-system differences (getName(), getType(), magic
constants and any differing Header field sizes) in each subclass, and update
SystemWII::printInfo and SystemGC::printInfo to delegate to the new shared
routine.

Copy link
Owner

@superg superg left a comment

Choose a reason for hiding this comment

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

Looks good, just couple small things.

Copy link
Contributor

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@dvd/dvd_dump.ixx`:
- Around line 827-829: The current logic sets bool raw = (options.dvd_raw ||
nintendo) && omnidrive_firmware but only logs when options.dvd_raw is requested
without omnidrive_firmware; add a warning path for when nintendo is detected but
omnidrive_firmware is absent so the user knows raw dumping was skipped for
Nintendo discs. Update the block that computes raw (referencing
variables/options: options.dvd_raw, nintendo, omnidrive_firmware, and the raw
variable) to emit a LOG warning when nintendo && !omnidrive_firmware explaining
that a Nintendo disc was detected and raw dumping is unavailable without
Omnidrive firmware; keep the existing warning for options.dvd_raw &&
!omnidrive_firmware as well.

@Deterous
Copy link
Contributor Author

Because of a bug with OmniDrive reading lead-out of dual-layer DVDs, I have temporarily disabled overreading of lead-out to prevent dual-layer Wii discs from being overdumped with redumper.

A later fix can be made to better split the lead-out once the firmware bug is fixed.

Copy link
Contributor

@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.

🧹 Nitpick comments (1)
dvd/dvd_split.ixx (1)

168-175: nintendo_key is declared without initialization.

If nintendo is true, nintendo_key is always set at lba == 0 before use at lba == ECC_FRAMES - 1, so this is safe in practice. Still, initializing it avoids warnings from static analyzers and makes the intent clearer.

Proposed fix
     bool nintendo = false;
-    uint8_t nintendo_key;
+    uint8_t nintendo_key = 0;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dvd/dvd_split.ixx` around lines 168 - 175, The variable nintendo_key is
declared without initialization which triggers static analyzer warnings;
initialize it when declared (e.g., set uint8_t nintendo_key = 0) in the
dvd_split.ixx snippet alongside the existing bool nintendo declaration so that
nintendo_key has a defined value before any conditional assignment/use
(references: nintendo_key, nintendo, and the related lba/ECC_FRAMES usage in the
same file).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@dvd/dvd_split.ixx`:
- Around line 168-175: The variable nintendo_key is declared without
initialization which triggers static analyzer warnings; initialize it when
declared (e.g., set uint8_t nintendo_key = 0) in the dvd_split.ixx snippet
alongside the existing bool nintendo declaration so that nintendo_key has a
defined value before any conditional assignment/use (references: nintendo_key,
nintendo, and the related lba/ECC_FRAMES usage in the same file).

@superg superg merged commit 3330258 into superg:main Feb 18, 2026
11 checks passed
@Deterous Deterous deleted the nintendo branch February 18, 2026 01:18
@coderabbitai coderabbitai bot mentioned this pull request Feb 24, 2026
@coderabbitai coderabbitai bot mentioned this pull request Mar 11, 2026
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.

2 participants