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

WiiU Fixes #3234

Merged
merged 20 commits into from
Sep 2, 2024
Merged

WiiU Fixes #3234

merged 20 commits into from
Sep 2, 2024

Conversation

Ghabry
Copy link
Member

@Ghabry Ghabry commented Jun 2, 2024

Still lacks polish like e.g. a nice banner but at least audio does not assert anymore and saving of the config works.


About this weird teardown in player.cpp (can we do better?)

SDL2 has a ProcUI handle which refers to the current application and for a proper shutdown of the app, SDL2 listens to PROCUI_STATUS_EXITING and then does some further cleanup.

When using the Exit menu item this will not trigger the cleanup automatically because SDL will not receive the shutdown event (but it receives it when using "WiiU Menu" in the home menu).

To make it receive the event I call SYSLaunchMenu(), then pump events once more (via that recursive call, SDL gets the quit event now) and then everything works...

https://github.com/devkitPro/SDL/blob/7b058bd042a7c624c277aaddbca6fb2f6ae5233d/src/video/wiiu/SDL_wiiuvideo.c#L326-L338

@Ghabry Ghabry added the WiiU label Jun 2, 2024
@Ghabry Ghabry added this to the 0.8.1 milestone Jun 2, 2024
@Ghabry Ghabry requested a review from carstene1ns June 2, 2024 22:34
@carstene1ns

This comment was marked as outdated.

@Ghabry
Copy link
Member Author

Ghabry commented Jun 3, 2024

woah that UDP logger is awesome. Makes my life much easier xD

@Ghabry
Copy link
Member Author

Ghabry commented Jun 3, 2024

Your code terminates fine when using the exit option but exiting from the WiiU menu crashes in most cases :/

Haven't found a working solution yet.


My ugly recursive call on exit is working in both cases

The ProcUI API is very unstable and querying it crashes when a shutdown was requested.

For more control use it directly.
Consider "/vol" a valid path
@Ghabry
Copy link
Member Author

Ghabry commented Jun 3, 2024

Shutting down works now properly in all three cases:

  • Home Menu
  • Player picks Exit
  • Output::Error

The only remaining problem is extremly slow opening of ZIP archives, likely some IO buffering issue. But is not a blocker for me.


Had to replace these WHB wrapper functions with calls to ProcUI which is the low level API.

SDL2 will not handle it when it is initialized before launching SDL2. (see code in wiiu_video.c)

Problem is that you cannot query the ProcUI status after it was shutdown (calling the function will crash) so I needed more low level access to differentiate between "Home Menu used" and "Exit option selected (or Output::Error)".

(This also makes WHBProcIsRunning crash when the shut down was requested, making this function pretty useless for checking whether it is running xD)


btw it seems USB Keyboards are not initialized by SDL2/WUT, so cannot use it :( (used it to input the Wifi password before so should work in theory...)

@Ghabry
Copy link
Member Author

Ghabry commented Jun 3, 2024

IMG_20240603_143132

IMG_20240603_143145

IMG_20240603_143147

IMG_20240603_201808

@Ghabry
Copy link
Member Author

Ghabry commented Jun 3, 2024

The ICU issue is a simple fix 🎊 🎊 🎊

The patch must be moved before cp -rup icu icu-native as the tool that requires patching is from the native icu.

https://github.com/EasyRPG/buildscripts/blob/master/wiiu/2_build_toolchain.sh#L45

@jetrotal
Copy link
Contributor

jetrotal commented Jun 4, 2024

icon
image

TV
image

PAD
image


The idea is to promote our charsets on the joypad screen, by letting a user search for their favorite character by looking while waiting... But I don't have a wii u to test how does it look like 🤔

Here's a psd containing editable assets:
EasyRP_wiiu_PSDs.zip

I recomend opening my psd files over the browser editor https://www.photopea.com/
instead of GIMP.

@Ghabry
Copy link
Member Author

Ghabry commented Jun 4, 2024

Thanks!

The downscale made imo Y look weird because on one side it is one pixel shorter.

Quickly edited it:

grafik

…a single read

Was the only agressive use of "end" in our code.
Implemented for the WiiU because IO through std::filebuf appears to be unbuffered.

But can maybe help on other platforms.

Can be toggled by setting USE_CUSTOM_FILE_READBUF to the prefered buffer size.
@Ghabry
Copy link
Member Author

Ghabry commented Jun 4, 2024

Somehow the buffering doesn't work and "pubsetbuf" does nothing (which is allowed by the standard xD) so I wrote my own buffering file IO.

Verifying whether the filebuf implementation is correct is a bit tricky. I wrote a test code that does hundreds of random seeks using beg/cur/end mode and reads and compared the result with the normal fstream.

Then executed it multiple times until I got no asserts anymore because of mismatches...

With the upcoming audiocfg branch it will create "Soundfont" and "Font" folders on startup.
Looks ugly when in the game directory as they are shown.
@Ghabry
Copy link
Member Author

Ghabry commented Jun 5, 2024

I will enable this custom IO for the other homebrew targets.

Only did an additional test on the Wii and this gives a huge loading time speedup. So likely also helps on Vita, 3DS and Switch.

@Ghabry
Copy link
Member Author

Ghabry commented Jun 6, 2024

Is imo enough xD. Can start to bitrot now ;). At least some improvements (ZIP and buffer) will help other homebrew platforms, too.

The pixel format was wrong (we know this issue ^^). Fixing this made the rendering significantly faster. Went in Yume Nikki from 22 FPS to 58 FPS in one map. Unterwegs in Düsterburg got +5-10 FPS.

Also did some measuring and SDL2 render step takes around ~3-5ms.

Decided to not implement ErrEula for now. This requires integration in the render loop so is not a simple fire-and-forget as the typical message box.

Copy link
Member

@carstene1ns carstene1ns left a comment

Choose a reason for hiding this comment

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

Apart from a few nits, works really great now!

src/platform/wiiu/main.cpp Show resolved Hide resolved
src/platform/wiiu/main.cpp Outdated Show resolved Hide resolved
src/platform/wiiu/main.cpp Outdated Show resolved Hide resolved
src/platform/wiiu/main.cpp Outdated Show resolved Hide resolved
src/player.cpp Outdated Show resolved Hide resolved
@fdelapena fdelapena added the Awaiting Rebase Pull requests with conflicting files due to former merge label Jul 2, 2024
@Ghabry Ghabry removed the Awaiting Rebase Pull requests with conflicting files due to former merge label Aug 27, 2024
@Ghabry
Copy link
Member Author

Ghabry commented Aug 27, 2024

Addressed the review comments and fixed a few more minor bugs. Is ready now 👍

- ProdUi renamed
- Fixed save path for bundled games
- Moved ProcessProcUi call to the Ui
Calling Player::Exit in the Ui can crash because the Ui is deleted by it.
Also the normal teardown codepath is too slow on WiiU and crashes the console when the home button is used.
@fdelapena fdelapena merged commit b4fd5d5 into EasyRPG:master Sep 2, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

4 participants