-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add PS5 system to info #154
Conversation
systems/ps5.ixx
Outdated
auto it = param_json.find("masterVersion"); | ||
if(it != param_json.end()) |
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.
nit: please move it declaration into if(), like here:
https://github.com/superg/redumper/blob/main/systems/ps3.ixx#L48
systems/ps5.ixx
Outdated
it = param_json.find("masterDataId"); | ||
if(it != param_json.end()) |
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.
Same as previous comment
systems/ps5.ixx
Outdated
std::map<std::string, std::string> json; | ||
|
||
auto json_entry = root_directory->subEntry(json_file); | ||
if(json_entry) |
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.
nit: you can get rid of an extra indent by:
if(!json_entry)
return json;
systems/ps5.ixx
Outdated
if(data.size() <= 0x800) | ||
return json; | ||
|
||
data.erase(data.begin(), data.begin() + 0x800); |
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.
Erasing from std::vector has to shift all data left. In this case it's not a performance issue but consider using std::span<uint8_t>.
That will basically give you vector interface without modifying data, examples:
https://github.com/superg/redumper/blob/main/systems/ps4.ixx#L52
https://github.com/superg/redumper/blob/main/systems/ps3.ixx#L156
systems/ps5.ixx
Outdated
size_t cur = 0; | ||
while(cur < data.size()) |
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.
nit: As you don't need cur outside of the loop, for() loop is preferable over while(), could do:
for(size_t cur = 0; cur < data.size(); )
systems/ps5.ixx
Outdated
std::string key(data.begin() + keyStart, data.begin() + keyEnd); | ||
std::string value(data.begin() + valueStart, data.begin() + valueEnd); | ||
erase_all_inplace(key, '\0'); | ||
erase_all_inplace(key, '\r'); | ||
erase_all_inplace(key, '\n'); | ||
erase_all_inplace(value, '\0'); | ||
erase_all_inplace(value, '\r'); | ||
erase_all_inplace(value, '\n'); | ||
trim_inplace(key); | ||
trim_inplace(value); |
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.
Removing \0 \r \n
seem an overkill to me (unless serial and version that we use have those characters).
There is also an easy way to get rid of trailing \0 while being safe if string doesn't end with \0, example:
https://github.com/superg/redumper/blob/main/systems/ps3.ixx#L183
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.
Removing new lines is needed in order to properly trim the values due to the naive way I am parsing JSON. As values are not always enclosed in quotations, sometimes it is needed to keep looking until the end } which occurs after a newline. Removing nulls is just for safety.
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.
Ah, got it, so key/value can be surrounded by the new lines that get skipped by parser. Keep it then.
systems/ps5.ixx
Outdated
if(value.size() >= 2 && value.front() == '"' && value.back() == '"') | ||
value = value.substr(1, value.size() - 2); |
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.
Also, not really a performance thing here, but instead of substr() you can define std::string_view() and emplace it instead (same behavior as std::span but for std::string)
Ah, forgot to mention, please add dash to the serial if it isn't there. |
Adds PS5 as a supported system by
redumper info
Prints version and serial of the disc:
More info: https://www.psdevwiki.com/ps5/Param.json
I have implemented a very naive JSON parser, only what is required.
Tested by dumping the only PS5 disc I own.