Repository navigation
Conversation
Works around vWii autoboot hanging on a black screen when the GamePad is powered off (wiiu-env#67). The BOTH/DRC screen-state probing succeeds even with no GamePad connected, after which the vWii transition waits on the DRC forever. Claude-Session: https://claude.ai/code/session_01PE4DJqPCXQzkGorJSUDrGv (cherry picked from commit f8eacbf of patapovich/AutobootModule; the same change is in his pull request wiiu-env#69)
CMPTAcctSetScreenType alone does not prevent the hang: the Wii U Menu additionally calls CMPTAcctSetDrcCtrlEnabled (nn_cmpt.rpl export, undeclared in wut) before launching vWii titles. Without it the vWii transition waits on a GamePad connection (wiiu-env#67). Claude-Session: https://claude.ai/code/session_01PE4DJqPCXQzkGorJSUDrGv (cherry picked from commit 474b98e of patapovich/AutobootModule; the same change is in his pull request wiiu-env#69)
On autoboot the launch runs much earlier than a manual selection from the boot menu, and launching before the compat subsystem is ready gives a black screen. Wait for CMPTCheckScreenState, launching anyway after 5s. From patapovich's wiiu-env#69 (commit 653bf27), which adds this wait to the two earlier commits above: its author found the screen type and DRC changes alone did not fix the black screen with the GamePad off.
With the GamePad off, CMPTLaunchTitle and CMPTLaunchMenu return -512: avm's AVMSetDCWiiCompat, which switches the TV to Wii mode, also reprograms the GamePad's display pipe from avm's GamePad settings, and with no GamePad those say "off" (what GX2SetDRCBuffer with GX2_DRC_RENDER_MODE_DISABLE stores), which dc rejects. Set the GamePad display to 854x480 first, the call GX2SetDRCBuffer makes for GX2_DRC_RENDER_MODE_SINGLE: AVMSetDRCBufferAttr(2, 1, 896), found with OSDynLoad.
The fixes for issue wiiu-env#67 forced TV-only output and turned GamePad control off for every vWii launch, which would cost GamePad users the vWii on their GamePad. Ask VPADRead whether a GamePad is connected (for up to half a second, as one switched on with the console may still be connecting at autoboot): if one is, launch exactly as before, trying both screens, then the GamePad, then the TV; if none is, take the TV-only path with the compat wait and the GamePad pipe mode.
VPADRead can report a GamePad that isn't there: the DRC Read Result Spoofer plugin makes every read succeed, so a vWii launch with no GamePad took the GamePad path and went black. CCRCDCDevicePing answers 0 only when a GamePad replies (2 to 4 ms either way on a Wii U, with and without the spoofer).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #67. Builds on #69: @patapovich's three commits are included as they are, under his name, with the GamePad check and a fix for the GamePad pipe on top (as offered in #69).
Picking the vWii System Menu, the vWii Homebrew Channel or any vWii title from the boot menu (or as the autoboot title) gives a black screen when no GamePad is connected (its battery flat, out of range, or not there at all, as when the console travels without it). With a GamePad connected, the same launch works.
Cause
CMPTLaunchTitle/CMPTLaunchMenureturn -512 because nn_cmpt's switch of the TV to Wii mode fails. The chain that fails:CMPTLaunchTitle→ nn_cmpt AV setup →AVMSetDCWiiCompat→AVMSetRenderAttr/AVMSetTVBufferAttr→ avm's internal "apply render state" →DCGetBufferRequirement(1, …)= -2While flag
0x100of avm's per-process state is set, every render or buffer attribute change on the TV also reprograms dc pipe 1 (the GamePad) from avm's GamePad sub-state. With no GamePad connected, that sub-state's mode is 0, which is whatGX2SetDRCBufferwithGX2_DRC_RENDER_MODE_DISABLEstores throughAVMSetDRCBufferAttr, andDCGetBufferRequirementrejects mode 0 on pipe 1 with -2.AVMSetDCWiiCompatthen returns FALSE, and nn_cmpt gives up with -512 beforeMCP_LaunchCompat. With the GamePad on, the mode is 6 (854×480), so the same path succeeds.How I found it: a debug build logged nn_cmpt's launch step by step (each AV call made by hand with its result), plus the avm and dc state, comparing runs with a GamePad connected and with none, on the same console. The two runs differed only in the GamePad pipe and the sub-state's mode.
Change
Only when no GamePad is connected; with one connected, the launch is exactly as before (BOTH, then DRC, then TV), so the vWii keeps mirroring to the GamePad.
CCRCDCDevicePing(CCR_CDC_DESTINATION_DRC0), up to 10 times 50 ms apart (a GamePad that wakes with the console may still be connecting at autoboot). NotVPADRead: a plugin that replaces it (the DRC Read Result Spoofer) makes it report a GamePad that isn't there.CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_TV)andCMPTAcctSetDrcCtrlEnabled(0)before launching, and the wait forCMPTCheckScreenState(from Fix vWii autoboot hanging when no GamePad is connected #69, by patapovich). The Wii U Menu makes the same calls for a TV-only launch. The wait is kept as Fix vWii autoboot hanging when no GamePad is connected #69 has it: it checks the screen setup rather than the compat subsystem itself, but it costs nothing when the check passes at once, and it caps at 5 s.AVMSetDRCBufferAttr(2, 1, 896): the callGX2SetDRCBuffermakes forGX2_DRC_RENDER_MODE_SINGLE(854×480) with double buffering. The Wii-mode switch can then reprogram pipe 1 without a GamePad, andAVMSetDCWiiCompatsucceeds. No memory is patched.(An earlier version cleared avm's internal flag
0x100instead, found by decodingAVMSetDCWiiCompat. It works too, but needs a state address read out of avm's code, so the exported call is the cleaner fix.)The state is per-process (Health & Safety, where the boot menu runs) and the process ends with the launch, so the changed GamePad setting doesn't carry over to the Wii U side.
Tested
Wii U (US), Aroma, from the boot menu and as the autoboot title (31 Oct, checked again 16 Nov):
VPADReadcheck it went black)Not changed here: when a vWii title starts from the boot menu, the GamePad switches itself off (stock does the same); pressing HOME on the GamePad brings it back, mirroring.