https://bugs.dolphin-emu.org/https://bugs.dolphin-emu.org/favicon.ico?12021-04-29T00:36:51ZDolphin bug trackerEmulator - Emulator Issues #12498: Syobon Action Wii (Homebrew) Doesn't Workhttps://bugs.dolphin-emu.org/issues/12498?journal_id=7417062021-04-29T00:36:51ZJMC4789JMC4789@gmail.com
<ul></ul><p>Is this a free homebrew? If so can you link to where we can get it?</p>
Emulator - Emulator Issues #12498: Syobon Action Wii (Homebrew) Doesn't Workhttps://bugs.dolphin-emu.org/issues/12498?journal_id=7417082021-04-29T00:46:02ZClector
<ul></ul><p>Yes, it is.<br>
There's the link: <a href="https://wii.brewology.com/downloads/download.php?id=10491&mcid=3" class="external">https://wii.brewology.com/downloads/download.php?id=10491&mcid=3</a></p>
Emulator - Emulator Issues #12498: Syobon Action Wii (Homebrew) Doesn't Workhttps://bugs.dolphin-emu.org/issues/12498?journal_id=7417092021-04-29T10:41:31Zsepalanisepalani@hotmail.fr
<ul></ul><p>Here is the official website with the source code</p>
<ul>
<li><a href="https://web.archive.org/web/20160305112938/http://scognito.drunkencoders.com/projects/syobon-action.php" class="external">https://web.archive.org/web/20160305112938/http://scognito.drunkencoders.com/projects/syobon-action.php</a></li>
<li>Source: <a href="https://web.archive.org/web/20160314171536/http://scognito.drunkencoders.com/projects/downloads/syobon-action-src.rar" class="external">https://web.archive.org/web/20160314171536/http://scognito.drunkencoders.com/projects/downloads/syobon-action-src.rar</a></li>
</ul>
Emulator - Emulator Issues #12498: Syobon Action Wii (Homebrew) Doesn't Workhttps://bugs.dolphin-emu.org/issues/12498?journal_id=7417462021-05-16T07:00:33Zsepalanisepalani@hotmail.fr
<ul><li><strong>File</strong> <a href="/attachments/8331">syobon-action-wii.7z</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/8331/syobon-action-wii.7z">syobon-action-wii.7z</a> added</li></ul><p>The homebrew can run using <code>Emulated CPU Clock Override</code> at <code>10%</code>. It needs DSP LLE to play audio, otherwise, it runs properly.</p>
<p>It sounds like a DMA issue to me, maybe like <a href="https://dolp.in/i9509" class="external">https://dolp.in/i9509</a></p>
<p>The game keeps spamming in the log: <code>Audio DMA configured: 128 blocks from 0x0039aca0</code></p>
<pre><code>25:27:480 Core\HW\DSP.cpp:391 I[AI]: Audio DMA configured: 128 blocks from 0x00398ca0
25:27:480 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00af (0x0000)
25:27:482 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00ee (0x0000)
25:27:486 Core\HW\DSP.cpp:391 I[AI]: Audio DMA configured: 128 blocks from 0x0039aca0
25:27:486 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00af (0x0000)
25:27:489 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00ee (0x0000)
25:27:510 Core\HW\DSP.cpp:391 I[AI]: Audio DMA configured: 128 blocks from 0x00398ca0
25:27:510 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00af (0x0000)
25:27:514 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00ee (0x0000)
25:27:531 Core\HW\DSP.cpp:391 I[AI]: Audio DMA configured: 128 blocks from 0x0039aca0
</code></pre>
<p>The game doesn't crash per se but is interrupted (during a setjmp call, IIRC) in a function which loads PNG and doesn't come back to it.</p>
<p>It doesn't occur with the version I compiled from source which is working without DMA issues:</p>
<pre><code>33:36:922 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00af (0x0000)
33:36:925 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00ee (0x0000)
33:36:943 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00af (0x0000)
33:36:946 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00ee (0x0000)
33:36:965 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00af (0x0000)
33:36:965 Core\DSP\DSPHWInterface.cpp:101 W[DSPLLE]: Unknown Interrupt Request pc=0x00ee (0x0000)
</code></pre> Emulator - Emulator Issues #12498: Syobon Action Wii (Homebrew) Doesn't Workhttps://bugs.dolphin-emu.org/issues/12498?journal_id=7422232021-07-12T18:04:09Zsepalanisepalani@hotmail.fr
<ul></ul><p>After digging more into the issue, I managed to find why the game doesn't resume. Basically, the audio interrupt is happening too quickly:</p>
<ul>
<li><a href="https://github.com/devkitPro/libogc/blob/36f6bef9e1e8cb021a03d041ce0b47b568154d27/libasnd/asndlib.c#L268" class="external">https://github.com/devkitPro/libogc/blob/36f6bef9e1e8cb021a03d041ce0b47b568154d27/libasnd/asndlib.c#L268</a></li>
</ul>
<p>This audio interrupt is also preventing Wii/Hollywood IRQs to be processed by libogc:</p>
<ul>
<li>IRQ priority: <a href="https://github.com/devkitPro/libogc/blob/master/libogc/irq.c#L74" class="external">https://github.com/devkitPro/libogc/blob/master/libogc/irq.c#L74</a></li>
<li><a href="https://github.com/devkitPro/libogc/blob/master/libogc/irq.c#L254" class="external">https://github.com/devkitPro/libogc/blob/master/libogc/irq.c#L254</a></li>
</ul>
<p>The WPAD's <code>IOS_IoctvAsync</code> can't be processed due to that. It was initiated by <code>WPAD_Init</code>:</p>
<pre><code class="c syntaxhl" data-language="c"><span class="c1">// Functions called from WPAD_Init</span>
<span class="n">WPAD_Init</span>
<span class="n">BTE_Init</span>
<span class="n">physbusif_init</span>
<span class="n">__usb_open</span>
<span class="n">__issue_bulkread</span>
<span class="n">__readbulkdataCB</span>
<span class="c1">// Infinite async WPAD loop handled by __readbulkdataCB</span>
<span class="n">__issue_bulkread</span>
<span class="n">USB_ReadBlkMsgAsync</span><span class="p">(</span><span class="n">__readbulkdataCB</span><span class="p">)</span>
<span class="n">__usb_interrupt_bulk_message</span>
<span class="n">IOS_IoctlvAsync</span><span class="p">(</span><span class="n">__usbv0_messageCB</span><span class="p">)</span>
</code></pre>
<p>Now, I need to find precisely what makes Dolphin too fast:</p>
<ul>
<li>It can be specific instruction timing (for instance, mtspr/mfspr used in epilog/prolog from the exception handler)</li>
<li>The interrupt timing</li>
<li>Something else?</li>
</ul>
<p>I hardware tested the interrupt timing and Dolphin's timing is really close to what the hardware does. Unless there are special cases where its timing can be delayed/canceled (still have to hwtest that), I doubt that's the root cause.</p>
<p>I'll investigate more to see if I can find anything interesting.</p>
Emulator - Emulator Issues #12498: Syobon Action Wii (Homebrew) Doesn't Workhttps://bugs.dolphin-emu.org/issues/12498?journal_id=7422552021-07-17T19:46:32Zsepalanisepalani@hotmail.fr
<ul></ul><p>I think I have all pieces of the puzzle, now.</p>
<a name="Dolphin-point-of-view"></a>
<h1 >Dolphin point of view<a href="#Dolphin-point-of-view" class="wiki-anchor">¶</a></h1>
<ol>
<li><p>Syobon Action boots up and its <code>main</code> function calls some functions that will produce interrupts later on:</p>
<blockquote>
<ul>
<li><code>WPAD_Init</code></li>
<li><code>ASND_Init</code>'s <a href="https://github.com/devkitPro/libogc/blob/36f6bef9e1e8cb021a03d041ce0b47b568154d27/libasnd/asndlib.c#L392" class="external">AUDIO_StartDMA</a></li>
</ul>
</blockquote></li>
<li><p>The game is stuck on a floating-point instruction with FPU disabled <em>(lazy FP context switch)</em> at</p>
<blockquote>
<p><code>80052644 stfdu f14, 0x0008 (r3)</code></p>
</blockquote></li>
<li><p>It raises an <code>FPU unavailable</code> exception and its <a href="https://github.com/devkitPro/libogc/blob/36f6bef9e1e8cb021a03d041ce0b47b568154d27/libogc/exception_handler.S#L218" class="external">handler</a> re-enable FP.</p></li>
<li><p>However, while resuming at <code>80052644</code> the FP instruction isn't processed as the AI interrupt occurs </p>
<blockquote>
<p>The one generated by <code>AUDIO_StartDMA</code></p>
</blockquote></li>
<li><p>It goes through the <a href="https://github.com/devkitPro/libogc/blob/36f6bef9e1e8cb021a03d041ce0b47b568154d27/libogc/irq_handler.S#L92" class="external">IRQ handler</a></p>
<blockquote>
<ul>
<li>Then, the <a href="https://github.com/devkitPro/libogc/blob/36f6bef9e1e8cb021a03d041ce0b47b568154d27/libogc/irq.c#L130" class="external">IRQ dispatcher</a></li>
<li>Said dispatcher that calls the audio's <a href="https://github.com/devkitPro/libogc/blob/36f6bef9e1e8cb021a03d041ce0b47b568154d27/libasnd/asndlib.c#L259" class="external">DMA callback</a></li>
</ul>
</blockquote></li>
<li><p>The Audio DMA callback</p>
<blockquote>
<ul>
<li>calls <a href="https://github.com/devkitPro/libogc/blob/36f6bef9e1e8cb021a03d041ce0b47b568154d27/libasnd/asndlib.c#L268" class="external">AUDIO_StartDMA</a></li>
<li><a href="https://github.com/devkitPro/libogc/blob/36f6bef9e1e8cb021a03d041ce0b47b568154d27/libasnd/asndlib.c#L270" class="external">exits early</a> as <code>static vs32 global_pause = 1</code></li>
<li>Indeed, the game's <code>ogg_player_thread</code>'s <code>ASND_Pause(0)</code> hasn't been called yet</li>
</ul>
</blockquote></li>
<li><p>Upon exiting the IRQ handler, <a href="https://github.com/devkitPro/libogc/blob/master/libogc/irq_handler.S#L160" class="external">FP is disabled again</a></p></li>
<li><p>Execution resumes at <code>80052644</code></p>
<blockquote>
<p><code>80052644 stfdu f14, 0x0008 (r3)</code><br>
and raises (see 3.) <code>FPU unavailable</code> exception</p>
</blockquote></li>
<li><p>Rinse and repeat from <code>3.</code></p></li>
</ol>
<a name="Summary"></a>
<h1 >Summary<a href="#Summary" class="wiki-anchor">¶</a></h1>
<p>Unless I did something wrong, here is why the game can't start properly:</p>
<ul>
<li>The execution is stuck on a floating point instruction.</li>
<li>The AI interrupt is the only one processed.</li>
<li>The FP exception handler takes enough time for the next AI interrupt to be generated.</li>
<li>It seems more like an <strong>execution timing issue</strong> than an <strong>audio timing issue</strong>.</li>
</ul>
<a name="What-I-tried"></a>
<h1 >What I tried<a href="#What-I-tried" class="wiki-anchor">¶</a></h1>
<p>I created a bunch of hardware tests to check various cases such as audio/interrupt timing and FP exception.<br>
Based on them, I think:</p>
<ul>
<li>Dolphin's DMA timing should be good enough</li>
<li>It seems to happen on real hardware but with another timing (I can't check where it's stuck, though)
<ul>
<li>I used <code>AUDIO_StartDMA</code>'s AI interrupt,</li>
<li>I forced FP exception in a loop with something like this:</li>
</ul></li>
</ul>
<pre><code class="c syntaxhl" data-language="c"><span class="kt">float</span> <span class="k">volatile</span> <span class="n">dummy</span> <span class="o">=</span> <span class="mi">1</span><span class="p">.</span><span class="mi">0</span><span class="n">f</span><span class="p">;</span>
<span class="k">for</span> <span class="p">(</span><span class="n">u32</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><</span> <span class="mi">5</span><span class="p">;</span> <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span><span class="p">)</span>
<span class="p">{</span>
<span class="c1">// Trigger FPU unavailable exception</span>
<span class="n">_CPU_FPR_Disable</span><span class="p">();</span>
<span class="n">dummy</span> <span class="o">*=</span> <span class="mi">2</span><span class="p">.</span><span class="mi">0</span><span class="n">f</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
<p>I exhausted most of the things I could think of. I might, at a later point, try to improve MMIO timings to be closer to real hardware. Delaying the audio interrupts (or using CPU clock overriding) allows the FP instructions to be executed properly.</p>
Emulator - Emulator Issues #12498: Syobon Action Wii (Homebrew) Doesn't Workhttps://bugs.dolphin-emu.org/issues/12498?journal_id=7425892021-07-25T10:45:38Zflacs
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Accepted</i></li></ul> Emulator - Emulator Issues #12498: Syobon Action Wii (Homebrew) Doesn't Workhttps://bugs.dolphin-emu.org/issues/12498?journal_id=7444012022-07-04T17:49:30Zpokechu22
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-7 priority-2 priority-default" href="/issues/12799">Emulator Issues #12799</a>: Rick Dangerous Wii - Doesn't Boot</i> added</li></ul> Emulator - Emulator Issues #12498: Syobon Action Wii (Homebrew) Doesn't Workhttps://bugs.dolphin-emu.org/issues/12498?journal_id=7450672022-10-24T18:28:44Zpokechu22
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-3 priority-2 priority-default closed" href="/issues/9410">Emulator Issues #9410</a>: Audio Crackling in Homebrew Demo, not present on 4.0.2</i> added</li></ul>