Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds BCA read/write in the DVD redump path and BCA file hexdump display for GC/Wii printInfo; introduces a rawhexdump utility used to format BCA output. Changes
Sequence Diagram(s)sequenceDiagram
participant Dumper as Dumper
participant PhysParser as PhysParser
participant SCSI as SCSI
participant FS as Filesystem
participant PrintInfo as PrintInfo
participant HexUtil as HexUtil
Dumper->>PhysParser: parse disc physical / per-layer structure
PhysParser-->>Dumper: has_bca flag
alt has_bca == true
Dumper->>SCSI: READ_DISC_STRUCTURE (Format: BCA)
SCSI-->>Dumper: BCA bytes or error
alt success
Dumper->>FS: write "<image_prefix>.bca"
end
end
Note over PrintInfo,FS: Later, printInfo may read the .bca file
PrintInfo->>FS: open "<track_basename>.bca"
FS-->>PrintInfo: BCA bytes
PrintInfo->>HexUtil: rawhexdump(BCA[0x80..0xBF])
HexUtil-->>PrintInfo: formatted hexdump
PrintInfo-->>User: display BCA header + hexdump
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
For redump submission, BCA should be formatted in raw hexdump style, not ISO buster style. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
systems/gc.ixx (1)
53-69: Consider extracting shared Nintendo BCA formatting into a common helper.The GC/WII implementations are nearly identical; centralizing this avoids drift in offsets/size handling and output behavior.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@systems/gc.ixx` around lines 53 - 69, The GC-specific BCA handling (bca_path creation, existence check, read_vector, size compare against _GC_BCA_STRUCTURE_SIZE, and hexdump output using _GC_REPORTED_BCA_OFFSET/_GC_REPORTED_BCA_SIZE) should be extracted into a shared helper (e.g., format_nintendo_bca or print_nintendo_bca) used by both GC and WII modules; implement a single function that accepts the track path and an output stream, encapsulates the path construction (track_extract_basename + ".bca"), existence check, read_vector call, size validation, and hexdump formatting using the shared constants (or move constants to a shared header), then replace the duplicated block in the GC implementation with a call to that helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@systems/gc.ixx`:
- Around line 53-59: The code currently returns silently when the .bca sidecar
vector size is invalid; update the block around bca_path/read_vector so that
when bca.size() != _GC_BCA_STRUCTURE_SIZE you emit a clear INFO-level message
(including bca_path and the actual bca.size()) before returning, rather than
silently returning; locate the check using the symbols bca_path, read_vector,
and _GC_BCA_STRUCTURE_SIZE and add a logging call (e.g., logger.info(...) or
std::cerr if no logger exists) that distinguishes "missing" (prior exists()
check) from "malformed .bca" and then return.
In `@systems/wii.ixx`:
- Around line 54-60: Replace the silent early return when a .bca sidecar has the
wrong size with an informational log that includes the bca_path, the actual
bca.size(), and the expected _WII_BCA_STRUCTURE_SIZE before returning; locate
the check around bca_path, read_vector(bca_path) and the if (bca.size() !=
_WII_BCA_STRUCTURE_SIZE) and add a single log/warn/info call describing the
malformed sidecar and its sizes, then keep the existing return behavior.
---
Nitpick comments:
In `@systems/gc.ixx`:
- Around line 53-69: The GC-specific BCA handling (bca_path creation, existence
check, read_vector, size compare against _GC_BCA_STRUCTURE_SIZE, and hexdump
output using _GC_REPORTED_BCA_OFFSET/_GC_REPORTED_BCA_SIZE) should be extracted
into a shared helper (e.g., format_nintendo_bca or print_nintendo_bca) used by
both GC and WII modules; implement a single function that accepts the track path
and an output stream, encapsulates the path construction (track_extract_basename
+ ".bca"), existence check, read_vector call, size validation, and hexdump
formatting using the shared constants (or move constants to a shared header),
then replace the duplicated block in the GC implementation with a call to that
helper.
|
Before I review this PR, do you plan to finish it and address all open threads? |
|
Yes, I hope to get back to it this weekend. |
93a5065 to
2d08456
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
systems/gc.ixx (1)
57-59:⚠️ Potential issue | 🟡 MinorLog malformed
.bcabefore returning.At Line 59, size mismatch exits silently, so malformed sidecars are indistinguishable from “no BCA output.” Please emit a clear INFO line (path + actual size) before returning.
Suggested patch
auto bca = read_vector(bca_path); - if(bca.size() != _GC_BCA_STRUCTURE_SIZE) - return; + if(bca.size() != _GC_BCA_STRUCTURE_SIZE) + { + os << std::format(" BCA: unavailable (unexpected size: {} bytes in {}, expected: {})", + bca.size(), bca_path.string(), _GC_BCA_STRUCTURE_SIZE) + << std::endl; + return; + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@systems/gc.ixx` around lines 57 - 59, The size-check on the BCA vector silently returns when bca.size() != _GC_BCA_STRUCTURE_SIZE; before returning, emit a clear INFO-level log containing the bca_path and the actual bca.size() so malformed .bca files are distinguishable from missing output. Locate the check around the read_vector(bca_path) call and replace the silent return with: log an INFO message (using the project’s logging facility) that includes the bca_path and bca.size(), then return; keep the same early-return control flow and reference _GC_BCA_STRUCTURE_SIZE in the message for clarity.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@systems/gc.ixx`:
- Around line 57-59: The size-check on the BCA vector silently returns when
bca.size() != _GC_BCA_STRUCTURE_SIZE; before returning, emit a clear INFO-level
log containing the bca_path and the actual bca.size() so malformed .bca files
are distinguishable from missing output. Locate the check around the
read_vector(bca_path) call and replace the silent return with: log an INFO
message (using the project’s logging facility) that includes the bca_path and
bca.size(), then return; keep the same early-return control flow and reference
_GC_BCA_STRUCTURE_SIZE in the message for clarity.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
dvd/dvd_dump.ixxsystems/gc.ixxsystems/wii.ixxutils/hex_bin.ixx
🚧 Files skipped from review as they are similar to previous changes (2)
- systems/wii.ixx
- dvd/dvd_dump.ixx
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
dvd/dvd_dump.ixx (1)
687-688: For multi-layer DVDs,has_bcareflects only the last layer's BCA flag.The
has_bcaassignment inside the loop means it gets overwritten for each layer, and only the last layer's value is retained. While BCA presence is typically consistent across layers, consider assigning from the first layer (layer 0) which is authoritative, or using a logical OR to capture if any layer reports BCA.♻️ Proposed fix to use first layer's BCA flag
// nintendo discs have first byte 0xFF if(structure[sizeof(CMD_ParameterListHeader)] == 0xFF) nintendo_key = 0; - has_bca = layer_descriptor.bca; + if(i == 0) + has_bca = layer_descriptor.bca; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dvd/dvd_dump.ixx` around lines 687 - 688, The current loop overwrites has_bca with layer_descriptor.bca for each layer so only the last layer's value is kept; change the assignment so has_bca reflects the authoritative BCA state by either setting has_bca once from the first layer (e.g., when layer index == 0) or by computing has_bca |= layer_descriptor.bca inside the loop to capture any layer reporting BCA; update the code around the loop where has_bca and layer_descriptor are used to follow one of these two approaches.systems/wii.ixx (1)
68-70: Consider sharing BCA constants between GC and WII.The BCA constants (
_WII_BCA_STRUCTURE_SIZE,_WII_REPORTED_BCA_OFFSET,_WII_REPORTED_BCA_SIZE) are identical to those ingc.ixx. Since both GameCube and Wii discs share the same BCA structure format, consider extracting these to a shared location (e.g., a common Nintendo disc header or constants module) to reduce duplication and ensure consistency.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@systems/wii.ixx` around lines 68 - 70, The three BCA constants (_WII_BCA_STRUCTURE_SIZE, _WII_REPORTED_BCA_OFFSET, _WII_REPORTED_BCA_SIZE) are duplicated in systems/wii.ixx and gc.ixx; extract them into a shared constants header/module (e.g., nintendo_disc_constants or disc_bca) and replace the local definitions in systems/wii.ixx and gc.ixx with references to the shared symbols (import/include the new module and use its symbol names), update any namespaces as needed so callers (e.g., code that used _WII_BCA_STRUCTURE_SIZE) now reference the single shared constant to remove duplication and ensure consistency.utils/hex_bin.ixx (1)
109-131: Consider adding a trailing newline for consistent output formatting.The function does not append a trailing newline after the last line of output. When used in gc.ixx and wii.ixx (e.g.,
os << std::format("{}", rawhexdump(...))), this means the BCA hex dump won't end with a newline, which may cause the next output to appear on the same line or result in inconsistent formatting.♻️ Proposed fix to add trailing newline
ss << std::setw(2) << (uint32_t)data[i]; } + if(size > 0) + ss << std::endl; + return ss.str(); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@utils/hex_bin.ixx` around lines 109 - 131, The rawhexdump function currently builds hex lines into std::stringstream ss but does not append a trailing newline, causing subsequent output to appear on the same line; update rawhexdump (the function signature rawhexdump(const uint8_t *data, uint32_t size, uint32_t group_size = 2, uint32_t groups_per_line = 8)) to ensure a trailing newline is added to ss before return (e.g., append '\n' or use ss << std::endl) so output always ends with a newline when using ss.str().
🤖 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 829-834: The BCA data returned by cmd_read_disc_structure includes
a CMD_ParameterListHeader and must be stripped before further processing; call
strip_response_header(bca) immediately after the cmd_read_disc_structure call
(before any size checks or the write_vector call) so the vector contains the raw
192-byte BCA expected by systems/gc.ixx and systems/wii.ixx; keep the existing
branches around status and use the same image_prefix/WRITE logic (i.e., replace
direct use of bca with the header-stripped bca before writing or validating
against _GC_BCA_STRUCTURE_SIZE).
---
Nitpick comments:
In `@dvd/dvd_dump.ixx`:
- Around line 687-688: The current loop overwrites has_bca with
layer_descriptor.bca for each layer so only the last layer's value is kept;
change the assignment so has_bca reflects the authoritative BCA state by either
setting has_bca once from the first layer (e.g., when layer index == 0) or by
computing has_bca |= layer_descriptor.bca inside the loop to capture any layer
reporting BCA; update the code around the loop where has_bca and
layer_descriptor are used to follow one of these two approaches.
In `@systems/wii.ixx`:
- Around line 68-70: The three BCA constants (_WII_BCA_STRUCTURE_SIZE,
_WII_REPORTED_BCA_OFFSET, _WII_REPORTED_BCA_SIZE) are duplicated in
systems/wii.ixx and gc.ixx; extract them into a shared constants header/module
(e.g., nintendo_disc_constants or disc_bca) and replace the local definitions in
systems/wii.ixx and gc.ixx with references to the shared symbols (import/include
the new module and use its symbol names), update any namespaces as needed so
callers (e.g., code that used _WII_BCA_STRUCTURE_SIZE) now reference the single
shared constant to remove duplication and ensure consistency.
In `@utils/hex_bin.ixx`:
- Around line 109-131: The rawhexdump function currently builds hex lines into
std::stringstream ss but does not append a trailing newline, causing subsequent
output to appear on the same line; update rawhexdump (the function signature
rawhexdump(const uint8_t *data, uint32_t size, uint32_t group_size = 2, uint32_t
groups_per_line = 8)) to ensure a trailing newline is added to ss before return
(e.g., append '\n' or use ss << std::endl) so output always ends with a newline
when using ss.str().
|
@Deterous |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
dvd/dvd_dump.ixx (1)
820-835: Consider using consistentstd::setlookup pattern.The BCA handling logic is correct. However, line 824 uses
readable_formats.contains()while the rest of the file consistently uses thefind(...) != end()pattern (e.g., lines 646, 736, 853). Consider aligning with the existing style for consistency.♻️ Optional: Align with existing lookup pattern
- if(!readable_formats.contains(READ_DISC_STRUCTURE_Format::BCA)) + if(readable_formats.find(READ_DISC_STRUCTURE_Format::BCA) == readable_formats.end())Alternatively, modernizing all lookups to use
contains()would also be valid.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dvd/dvd_dump.ixx` around lines 820 - 835, The BCA branch uses readable_formats.contains(...) which is inconsistent with the rest of the file; change the lookup to the existing pattern using readable_formats.find(READ_DISC_STRUCTURE_Format::BCA) != readable_formats.end() (refer to has_bca, readable_formats, and READ_DISC_STRUCTURE_Format::BCA used in this block) so the set lookup style matches other checks in this 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_dump.ixx`:
- Around line 820-835: The BCA branch uses readable_formats.contains(...) which
is inconsistent with the rest of the file; change the lookup to the existing
pattern using readable_formats.find(READ_DISC_STRUCTURE_Format::BCA) !=
readable_formats.end() (refer to has_bca, readable_formats, and
READ_DISC_STRUCTURE_Format::BCA used in this block) so the set lookup style
matches other checks in this file.
|
It's ready for review now. |
superg
left a comment
There was a problem hiding this comment.
Fundamentally OK, left some comments.
This PR adds bca dumping on supported discs and logs the relevant part of it for GC and Wii platforms.
Example of produced log:
I haven't tested it much yet though, that's why it's WIP.
Summary by CodeRabbit