Skip to content
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 support for WUHB file format #1190

Merged
merged 39 commits into from
May 5, 2024
Merged

Conversation

goeiecool9999
Copy link
Collaborator

@goeiecool9999 goeiecool9999 commented Apr 30, 2024

Closes: #962
This work is heavily inspired by the existing code to support WUA.
Some parts are copied and modified from WUT's wuhbtool (structures and hash calculation function)

Questions left to be answered:

  • is std::filesystem::path safe to use across platforms in this way?
    while (it != path.end())
  • Should fil/dir table entries be cached? A: It's probably fine.
  • How to assign a title ID to homebrew apps? Some kind of hash function? A: CRC32(author+longName+shortName)

@Crementif
Copy link
Member

Oh, this is awesome to have. Nice work!

@Maschell
Copy link
Contributor

Maschell commented May 3, 2024

How to assign a title ID to homebrew apps? Some kind of hash function?

On console for the "homebrew_on_menu" plugin I'm using a hash of the relative path to the .wuhb (e.g. "wiiu/apps/test.wuhb") with this hash function to get the lower title id and 0005000F for the first 4bytes : https://github.com/wiiu-env/homebrew_on_menu_plugin/blob/d0581407d69575d5205ba40ee188867e6c0dcdc1/src/utils/utils.cpp#L7

e.g. 0005000F-[HASH]

I think CEMU could/should come up with it's own implementation for the "lower tid", but they should also start with0005000F for consistency?

@Maschell
Copy link
Contributor

Maschell commented May 3, 2024

Not sure to whiche extend Cemu is even handling the cos.xml, but .wuhb under Aroma are running with these cos.xml values:

https://github.com/wiiu-env/MochaPayload/blob/6f47f2f9bb29b4bf649bf52f60ceb83876c8a45f/source/ios_mcp/source/mcp_loadfile.c#L476-L498

@goeiecool9999 goeiecool9999 changed the title WIP: add support for WUHB file format add support for WUHB file format May 3, 2024
@goeiecool9999 goeiecool9999 marked this pull request as ready for review May 3, 2024 22:01

do
{
decompressed.resize(decompressed.size() + 1024);
Copy link
Member

Choose a reason for hiding this comment

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

Increasing by a fixed 1024 bytes at a time seems rather inefficient? For a 1MB file thats a thousand vector resize operations.
I recommend starting out with a smallish size like 32KB (maybe even as a size hint parameter?) and then just doubling the size each loop iteration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See latest commit. I know defining a variable and assigning the argument is redundant but I think it helps readability and it should be trivial for a compiler to optimize. I set the hint in the game list for the icons to 70KiB since one extracted game icon TGA I looked at is slightly more than 64KiB.

@Exzap
Copy link
Member

Exzap commented May 5, 2024

Looks good. Thanks!

@Exzap Exzap merged commit dc480ac into cemu-project:main May 5, 2024
5 checks passed
@goeiecool9999 goeiecool9999 deleted the WUHB branch May 22, 2024 19:26
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.

Homebrew Format Support
4 participants