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

some fixes: avoid black banners / minimize one usb related dsi exceptions / get custom banners / install shared content #2

Open
wants to merge 12 commits into
base: enhanced
Choose a base branch
from

Conversation

w3irDv
Copy link

@w3irDv w3irDv commented Jul 24, 2024

This PR contains some solutions to problems I've encountered using USBLGX.

Emunand related:

  • No more black animation banners due to emunand path+name being too large.
  • Emunand WAD manager now installs wad's shared content. Without this fix, if you install a wad with USBLGX and the shared content is not previously installed in the Emunand , weird behaviour will result during loading (black screen, corrupted memory errors, ...) or when exiting (errors opening the Operations Manual, freeze when exiting, ...) . A more detailed description can be found here ,

Other:

  • Minimize the likelihood of a DSI exception if you move to any screen (game settings, configuration) before the free USB space is displayed on the main screen. This is probably more of a bypass than a definitive solution to the race condition between the asynchronous thread that calculates free HD space and the menu manager when it deletes the current screen to move to a new one.
  • Initial USBLGX configuration file will use non-SSL URL to get custom banners. This (trivial) change is already advised in the Wii Hacks Guide. No change if the config file is already generated.

This fixes are already included in this PR at wiidev/usbloadergx repo.

@w3irDv w3irDv changed the title Fix/someissues some fixes: avoid black banners / minimize one usb related dsi exceptions / get custom banners / install shared content Jul 24, 2024
@Jacoby6000
Copy link
Owner

Thanks for the contribution! I'll look over this and get it tested/merged over the next couple of days.

Comment on lines +462 to +471
// Content does not exists
return 0;
}

int Wad::UpdateContentMap(const char *installpath, tmd_content *content, char *filepath)
{
int result = CheckContentMap(installpath,content,filepath);
if ( result != 0 )
return result; // content already exists or error

Copy link
Owner

@Jacoby6000 Jacoby6000 Jul 25, 2024

Choose a reason for hiding this comment

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

Since this is breaking up the Wad::CheckContentMap function in to two separate functions (which is probably a good thing), I think you will need to update all existing invocations of CheckContentMap to use UpdateContentMap, since those old calls expect CheckContentMap to do both pieces.

Not 💯 on this yet, but I'm pretty sure. Still learning my way around here.

Copy link
Author

Choose a reason for hiding this comment

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

Hi Jacoby6000!

No, in fact the original problem was that despite its name, checkContenMap checked and always updated the content.map file without installing the shared content. The updateContentMap process should only be called once, after the shared content has been succesfully installed. The other invocations of checkContentMap only need the check stuff. The flow is explained here with a little more of detail.

Copy link
Owner

Choose a reason for hiding this comment

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

Ahhh I see. I didn't fully understand what was going on. This makes sense! I'll test it this week and get it merged

Copy link
Owner

Choose a reason for hiding this comment

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

Do you have any examples of wads with shared content so that I can validate this?

Copy link
Author

Choose a reason for hiding this comment

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

I think any title will do.

If you want to see the bug in action, you can prepare the following lab.

Take a working emunand and delete all but one shared content:

cd ${NAND_ROOT}
mv shared1 _shared1
mkdir shared1
cp _shared1/00000000.app shared1
dd if=_shared1/content.map of=shared1/content.map bs=28 count=1
-rw-r--r-- 1  wii  wii      28 Aug  1 11:18 content.map

Install any title with the old build. Check the shared1 folder. You will find no new file. But notice that the content.map file has increased in size::

-rw-r--r-- 1  wii  wii     112 Aug  1  2024 content.map

USBGLX have added the hash of the shared contents included in the wad to the content.map file. The title won't load for sure. And from now on, this emunand is doomed. Any tool that checks content.map will assume that the shared content is already installed and will skip its installation.

Recreate the minimal content.map again:

dd if=_shared1/content.map of=shared1/content.map bs=28 count=1

and install the same content with the new build. content.map will have the same size (and content) than with the old build, but now shared1 folder will contain some 0000000x.app files. If you try, the installed title will (probably) load (if not, well ... we have deleted ~ 70 files or so, some unexpected behavior can happens...).

If you have access to a (physical) Wii , the real case scenario is to create a minimal emunand using modMii and then install any title with USBGLX. You will will succeed only with the new build (with the old build, installation apparently works, but the title won't load).
Or in a wii/vWii, only if you have never installed any title in the real NAND: if you export it to create and emunand, title installation will only succeed with the new build.

It's a subtle bug, which is why it has gone unnoticed for years. And I think mainly affects to new modders.

By the way, when testing this with the previous version, the DSI exception error hit me twice :D

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.

2 participants