https://bugs.dolphin-emu.org/https://bugs.dolphin-emu.org/favicon.ico?12015-02-13T19:37:18ZDolphin bug trackerEmulator - Emulator Issues #8223: Datel AGP requires default exception handlershttps://bugs.dolphin-emu.org/issues/8223?journal_id=7179342015-02-13T19:37:18Zmimimi
<ul></ul><p>Do the exception handlers from normal games work for this? Are they always the same, or are there differences? Could you dump those exception handlers when running any gamecube game, and use them for the Datel-AGP stuff?</p>
Emulator - Emulator Issues #8223: Datel AGP requires default exception handlershttps://bugs.dolphin-emu.org/issues/8223?journal_id=7179352015-02-13T19:40:02ZSonicadvance1Sonicadvance1@gmail.com
<ul></ul><p>The ones that regular games install with the SDK are the same as the ones that the IPL installs.<br>
Just ripping the ones from the games/IPL don't seem to work, but they do cause a change in behaviour. Also we wouldn't be able to package them in Dolphin.</p>
<p>Creating a default exception handler that saves the required information to the exception frame is fairly easy to do.</p>
Emulator - Emulator Issues #8223: Datel AGP requires default exception handlershttps://bugs.dolphin-emu.org/issues/8223?journal_id=7179362015-02-13T19:44:39Zmimimi
<ul></ul><p>So, the exception handlers are only half of the issue?</p>
<p>And i wasn't thinking about packing the exception handlers in Dolphin, more like dumping them when running a gamecube game. And then add like a 3rd bios/ipl option that copies those exception handlers to memory.</p>
<p>Well, it seems like somebody needs to debug this to find out what exactly is going on</p>
Emulator - Emulator Issues #8223: Datel AGP requires default exception handlershttps://bugs.dolphin-emu.org/issues/8223?journal_id=7442372022-06-06T21:32:04Zpokechu22
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-6 priority-2 priority-default closed" href="/issues/8179">Emulator Issues #8179</a>: Datel Discs need INI changes, Bios forced on, LLE audio forced on.</i> added</li></ul> Emulator - Emulator Issues #8223: Datel AGP requires default exception handlershttps://bugs.dolphin-emu.org/issues/8223?journal_id=7443272022-06-13T00:45:47Zpokechu22
<ul></ul><p>I investigated this further, and it does seem like they do install exception handlers; they just do it in a somewhat broken way.</p>
<p>The function that copies the exception handlers (or more precisely the function that does <code>dcbst</code> after they've been copied) contains a <code>sc</code> instruction instruction, which jumps to the interrupt handler at <code>00000c00</code>, which is odd because they also are writing the exception handler <u>at</u> <code>00000c00</code> (they copy a single exception handler to each of the exception handlers). The <code>sc</code> instruction corresponds to <code>ppcsync()</code> in libogc, which ends up calling <a href="https://github.com/devkitPro/libogc/blob/ed2f0bb0b488e1a9c7afeee2b822e44aeed3ad0a/libogc/exception_handler.S#L227-L238" class="external">this</a> for them. (Libogc's version doesn't exactly match; the official one doesn't save <code>r9</code> and <code>r10</code>)</p>
<p>After they've set all of the exception handlers once, they overwrite <code>00000c00</code> with a separate one that syncs the instruction cache. Using pure interpreter with a Datel title, you can see some icache-related warnings about that address when booting normally, so I think it only works due to icache.</p>
<p>The IPL also does the same thing where it copies a default exception handler over all of the exception handlers (I think; I haven't checked too closely) and then special-cases <code>00000c00</code> afterwards. However, they don't use the <code>sc</code> instruction to jump to <code>00000c00</code>; instead, they use <code>sync</code> and <code>isync</code> directly.</p>
<p>The same applies to retail titles (for both GameCube and Wii); <code>OSInit</code> calls <code>OSExceptionInit</code>. For each address in <code>__OSExceptionLocations</code>, that <code>memcpy</code>s <code>OSExceptionVector</code> to the address, then calls <code>DCFlushRangeNoSync</code>, <code>_sync()</code> [i.e. the <code>sync</code> instruction], and <code>ICInvalidateRange</code>. Then <code>OSInit</code> calls <code>__OSInitSystemCall</code>, which special-cases <code>00000c00</code> with <code>SystemCallVector</code>. Datel's equivalent to <code>OSExceptionInit</code> instead calls <code>DCFlushRange</code> and doesn't call <code>ICInvalidateRange</code>.</p>
<p>I think that if we provide a default interrupt handler at <code>00000c00</code> that does the expected stuff, everything should work fine. And, it would be only 7 instructions, so I don't think it's as big of a deal as needing to provide all of the default exception handlers. I haven't gotten it to work yet though.</p>
Emulator - Emulator Issues #8223: Datel AGP requires default exception handlershttps://bugs.dolphin-emu.org/issues/8223?journal_id=7443292022-06-13T04:00:27Zpokechu22
<ul></ul><p>After investigating it further, I noticed that the icache message also appears on the jit... but for both the jit and the pure interpreter, it didn't appear when booting via emulated BS2. As it turns out, icache starts disabled when booting booting via emulated BS2, but it's normally enabled when booting from the IPL. Most titles enable icache on startup, but Datel doesn't.</p>
<p>Adding <code>HID0.ICE = true</code> into <code>CBoot::EmulatedBS2_GC</code> is enough to get Datel titles to start! Unfortunately they still don't work quite right; textures are completely missing: <a href="https://i.imgur.com/BK0Daad.png" class="external">https://i.imgur.com/BK0Daad.png</a> (except for titles such as "Ultimate Cheats for use with Enter the Matrix" that do all of their rendering in software, which render fine). So, we don't need to provide a default system call interrupt after all (other than the existing <code>rfi</code> that makes it immediately return)... which I guess makes sense because we ignore the <a href="https://github.com/dolphin-emu/dolphin/blob/99f98b2481dd735472467cf31af2a9430892f921/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp#L1040-L1043" class="external"><code>sync</code></a> and <a href="https://github.com/dolphin-emu/dolphin/blob/99f98b2481dd735472467cf31af2a9430892f921/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp#L549-L552" class="external"><code>isync</code></a> instructions and the <code>HID0</code> <code>ABE</code> (address broadcast enable) bit.</p>
Emulator - Emulator Issues #8223: Datel AGP requires default exception handlershttps://bugs.dolphin-emu.org/issues/8223?journal_id=7443302022-06-13T04:18:02ZJMC4789JMC4789@gmail.com
<ul></ul><p>That's weird that they're missing textures now. This is seriously confusing.</p>
Emulator - Emulator Issues #8223: Datel AGP requires default exception handlershttps://bugs.dolphin-emu.org/issues/8223?journal_id=7443322022-06-13T06:46:06Zpokechu22
<ul><li><strong>Status</strong> changed from <i>Accepted</i> to <i>Fix pending</i></li></ul><p><a href="https://github.com/dolphin-emu/dolphin/pull/10746" class="external">https://github.com/dolphin-emu/dolphin/pull/10746</a></p>
Emulator - Emulator Issues #8223: Datel AGP requires default exception handlershttps://bugs.dolphin-emu.org/issues/8223?journal_id=7443792022-06-26T04:55:31Zpokechu22
<ul><li><strong>Status</strong> changed from <i>Fix pending</i> to <i>Fixed</i></li><li><strong>Fixed in</strong> set to <i>5.0-16737</i></li></ul><p><a href="https://dolphin-emu.org/download/dev/e18053d3075dd010a3a9db80d1b29b99cf7b69da/" class="external">https://dolphin-emu.org/download/dev/e18053d3075dd010a3a9db80d1b29b99cf7b69da/</a></p>
Emulator - Emulator Issues #8223: Datel AGP requires default exception handlershttps://bugs.dolphin-emu.org/issues/8223?journal_id=7444172022-07-07T22:30:43Zpokechu22
<ul></ul><p>Here's a detailed writeup of how Datel's code was broken and the above change fixes it: <a href="https://gist.github.com/Pokechu22/abed8faefa0afc6dd881a8958e2407fe" class="external">https://gist.github.com/Pokechu22/abed8faefa0afc6dd881a8958e2407fe</a></p>