-
Notifications
You must be signed in to change notification settings - Fork 39
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
Support array-of-bytes binary display #126
Conversation
I've given it a go, and it works well. I've added a few comments, but I wouldn't be against to get it merged in its current state. (The macOS error appears to be unrelated; might need to retry.) |
@cristian64 I don't see your comments. Do you have a pending review that you forgot to click "Submit review" for? |
Source/Common/MemoryCommon.cpp
Outdated
u8 unsignedByte = 0; | ||
std::memcpy(&unsignedByte, memory + i, sizeof(u8)); | ||
ss << std::bitset<sizeof(u8) * 8>(unsignedByte).to_string() << " "; |
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.
I think this could be just:
ss << std::bitset<sizeof(u8) * 8>(Common::bit_cast<u8, char>(memory[i])).to_string() << " ";
(Given that it's a single byte, not even the bit_cast
would be necessary; a regular static_cast
would work too.
Source/Common/MemoryCommon.cpp
Outdated
u8 aByte = 0; | ||
std::memcpy(&aByte, memory + i, sizeof(u8)); | ||
ss << std::setfill('0') << std::setw(2) << static_cast<int>(aByte) << " "; |
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.
Similarly, this could be:
ss << std::setfill('0') << std::setw(2)
<< static_cast<int>(Common::bit_cast<u8, char>(memory[i])) << " ";
And, again, the bit_cast
could just be a static_cast
.
Those changes seem to work fine on my end, so I'm all for cleaning it up! |
Viewing an
array of bytes
entry as binary can be especially useful when observing bitfields. For example, Mario Kart Wii uses bitfields to track whether we are accelerating, braking, drifting, tricking, etc. Being able to view each bit in the field makes viewing the current state of each scenario a bit easier!I didn't add octal or decimal support, because I can't imagine any scenarios where such a display could be useful.