-
-
Notifications
You must be signed in to change notification settings - Fork 132
Improvements to CPU register view: #1983
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
base: main
Are you sure you want to change the base?
Conversation
rocketz
commented
Dec 11, 2025
- Colorized registers for easier overview
- Easier in-line editing of values
- Now also shows register as signed decimal
- Colorized registers for easier overview - Easier in-line editiing of values - Now also shows register as signed decimal
WalkthroughReworked the Registers widget UI: removed the old inline edit flow, added Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ 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 |
There was a problem hiding this 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 (1)
src/gui/widgets/registers.cc (1)
106-123: Minor: Inconsistent brace style.The
elseblock uses a different brace style than the rest of the codebase (brace on new line vs same line). The logic itself is correct for handling both hex and signed decimal input.if (radix == 16) { newReg = strtoul(val.c_str(), &endPtr, 16); - } - else { + } else { newReg = strtoll(val.c_str(), &endPtr, 10); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/gui/widgets/registers.cc(6 hunks)src/gui/widgets/registers.h(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/gui/widgets/registers.h (1)
src/gui/widgets/registers.cc (4)
contextMenu(34-54)contextMenu(34-34)updateRegisterValue(106-123)updateRegisterValue(106-107)
🪛 Cppcheck (2.18.0)
src/gui/widgets/registers.cc
[error] 48-48: syntax error
(syntaxError)
[error] 186-186: failed to expand 'TYPESTRING', Invalid ## usage when expanding 'TYPESTRING64'
(preprocessorErrorDirective)
🪛 GitHub Check: CodeScene Code Health Review (main)
src/gui/widgets/registers.cc
[warning] 34-53: ❌ New issue: Bumpy Road Ahead
PCSX::Widgets::Registers::contextMenu has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is 2 blocks per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
[warning] 34-53: ❌ New issue: Bumpy Road Ahead
PCSX::Widgets::Registers::contextMenu has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is 2 blocks per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
[warning] 139-422: ❌ Getting worse: Complex Method
PCSX::Widgets::Registers::draw increases in cyclomatic complexity from 60 to 66, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
[warning] 139-422: ❌ Getting worse: Bumpy Road Ahead
PCSX::Widgets::Registers::draw increases from 10 to 12 logical blocks with deeply nested code, threshold is 2 blocks per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
[warning] 139-422: ❌ Getting worse: Complex Method
PCSX::Widgets::Registers::draw increases in cyclomatic complexity from 60 to 66, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
[warning] 139-422: ❌ Getting worse: Bumpy Road Ahead
PCSX::Widgets::Registers::draw increases from 10 to 12 logical blocks with deeply nested code, threshold is 2 blocks per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: macos-arm-build-and-test
- GitHub Check: pcsx-redux (aarch64-linux)
- GitHub Check: pcsx-redux (x86_64-linux)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: asan
- GitHub Check: coverage
- GitHub Check: aur-build
- GitHub Check: cross-arm64
- GitHub Check: build
- GitHub Check: macos-build-and-test-toolchain
- GitHub Check: toolchain
🔇 Additional comments (5)
src/gui/widgets/registers.h (1)
40-41: LGTM!The new method declarations are clean and appropriately scoped as private members. The signatures align well with their implementations in the source file.
src/gui/widgets/registers.cc (4)
34-53: LGTM!The context menu implementation is clean and the radix-aware clipboard copy is a good UX improvement. The static analysis "Bumpy Road" warning is expected for UI menu handling code and acceptable here.
140-147: LGTM!The color indices and color arrays are properly sized and provide a clean way to visually distinguish register categories. The static const declaration is appropriate for this use case.
168-197: LGTM!The GPR rendering logic is well-structured with proper handling for the read-only zero register, dual hex/decimal editing for other registers, and appropriate context menus. The colorization improves readability.
410-421: LGTM!The Misc tab PC editing correctly uses
ImGuiInputTextFlags_CharsHexadecimalwith hex formatting and radix 16. This is the correct pattern that should also be used in the GPR tab.
- Fixed issues robots picked up - Removed old support code for the modal edit-dialog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/gui/widgets/registers.cc (1)
199-206: LGTM - Previous hex input filter bug has been fixed.The PC input field now correctly uses
ImGuiInputTextFlags_CharsHexadecimalto allow hex digitsa-f.
🧹 Nitpick comments (1)
src/gui/widgets/registers.cc (1)
106-122: Consider using a named constant for the PC register index.The magic number
34is used to distinguish PC from GPR registers (lines 116, 203, 414). A named constant would improve readability and reduce the risk of inconsistencies.+// Register indices: 0-31 = GPR, 32 = lo, 33 = hi, 34 = PC +static constexpr int kPCRegisterIndex = 34; + void PCSX::Widgets::Registers::updateRegisterValue(PCSX::psxRegisters* registers, const std::string& val, int reg, int radix) { uint32_t newReg; char* endPtr; if (radix == 16) { newReg = strtoul(val.c_str(), &endPtr, 16); } else { newReg = strtoll(val.c_str(), &endPtr, 10); } if (!*endPtr) { - if (reg == 34) { + if (reg == kPCRegisterIndex) { registers->pc = newReg; } else { registers->GPR.r[reg] = newReg; } } }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/gui/widgets/registers.cc(6 hunks)src/gui/widgets/registers.h(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/gui/widgets/registers.h
🧰 Additional context used
🪛 Cppcheck (2.18.0)
src/gui/widgets/registers.cc
[error] 48-48: syntax error
(syntaxError)
[error] 186-186: failed to expand 'TYPESTRING', Invalid ## usage when expanding 'TYPESTRING64'
(preprocessorErrorDirective)
🪛 GitHub Check: CodeScene Code Health Review (main)
src/gui/widgets/registers.cc
[warning] 34-53: ❌ New issue: Bumpy Road Ahead
PCSX::Widgets::Registers::contextMenu has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is 2 blocks per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
[warning] 34-53: ❌ New issue: Bumpy Road Ahead
PCSX::Widgets::Registers::contextMenu has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is 2 blocks per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
[notice] 138-501: ✅ Getting better: Complex Method
PCSX::Widgets::Registers::draw decreases in cyclomatic complexity from 60 to 54, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: macos-arm-build-and-test
- GitHub Check: pcsx-redux (x86_64-linux)
- GitHub Check: pcsx-redux (aarch64-linux)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: aur-build
- GitHub Check: build
- GitHub Check: asan
- GitHub Check: cross-arm64
- GitHub Check: coverage
- GitHub Check: macos-build-and-test-toolchain
- GitHub Check: toolchain
🔇 Additional comments (3)
src/gui/widgets/registers.cc (3)
34-54: LGTM - Context menu implementation is correct.The radix-aware clipboard copy logic handles both hex and signed decimal formats appropriately. The buffer size of 20 is sufficient for all cases. The Cppcheck syntax error at line 48 appears to be a false positive.
139-146: LGTM - Color scheme implementation is clean.The color arrays are correctly sized for 34 registers, and the indexing in the loop is bounds-safe. The visual distinction between register categories (gray for special, cyan and white for others) improves readability.
408-418: LGTM - Misc tab PC editing is consistent with GPR tab.The implementation correctly uses hex input flags and the shared
updateRegisterValuefunction, ensuring consistent behavior across tabs.