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

BS2Emu: Set HID0/1/2/4 and MSR with correct default values #10746

Merged
merged 2 commits into from Jun 26, 2022

Conversation

Pokechu22
Copy link
Contributor

@Pokechu22 Pokechu22 commented Jun 13, 2022

These values were obtained by setting a breakpoint at a game's entry point, and then observing the register values with Dolphin's register widget.

There are other registers that aren't handled by this PR, including CR, XER, SRR0, SRR1, and "Int Mask" (as well as most of the GPRs). They could be added in a later PR if it turns out that their values matter, but probably most of them don't.

This fixes Datel titles booting with the IPL skipped (see https://bugs.dolphin-emu.org/issues/8223), though when booted this way they are currently missing textures. Due to somewhat janky code, Datel overwrites the syscall interrupt handler and then immediately triggers it (with the sc instruction) before they restore the correct one. This works on real hardware due to icache, and also works in Dolphin when the IPL runs due to icache, but prior to this change HID0.ICE defaulted to 0 so icache was not enabled when the IPL was skipped.

@Pokechu22 Pokechu22 force-pushed the bs2-emu-registers branch 2 times, most recently from 0349324 to deeef80 Compare June 13, 2022 06:38
@Pokechu22
Copy link
Contributor Author

I've added a workaround for the missing textures. It's kinda jank, but it works.

@sepalani
Copy link
Contributor

The registers values LGTM and match what I have with the GC and Wii system menu.

@Pokechu22 Pokechu22 force-pushed the bs2-emu-registers branch 2 times, most recently from 5856751 to d4bde9d Compare June 25, 2022 02:49
// Datel titles don't initialize the postMatrices, but they have dual-texture coordinate
// transformation enabled. We initialize all of xfmem to 0, which results in everything using
// a texture coordinate of (0, 0), breaking textures. Normally the IPL will initialize the last
// entry to the identity matrix, but BS2 EMU skips that.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment confuses me, doesn't this new piece of code initialize the last entry to the identity matrix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BS2 EMU skips running the IPL, so the initialization that the IPL performs is skipped and thus needs to be performed in BS2 EMU. But that comment can also be read as "BS2 EMU skips performing this initialization", which is misleading - I'll change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the comment (I thought I did so earlier, but it seems like I didn't).

@Pokechu22
Copy link
Contributor Author

Hmm. I just tested, and it seems like with this PR (and #10761 which was merged yesterday), you can boot Datel titles with DSP HLE and the IPL enabled, or DSP LLE and the IPL disabled, but it still hangs if you have both DSP HLE and the IPL enabled. That's annoying...

@JMC47
Copy link
Contributor

JMC47 commented Jun 25, 2022

Possibly a timing issue? That is annoying, though.

@Pokechu22
Copy link
Contributor Author

I figured it out; see #10785.

These values were obtained by setting a breakpoint at a game's entry point, and then observing the register values with Dolphin's register widget.

There are other registers that aren't handled by this PR, including CR, XER, SRR0, SRR1, and "Int Mask" (as well as most of the GPRs). They could be added in a later PR if it turns out that their values matter, but probably most of them don't.

This fixes Datel titles booting with the IPL skipped (see https://bugs.dolphin-emu.org/issues/8223), though when booted this way they are currently missing textures. Due to somewhat janky code, Datel overwrites the syscall interrupt handler and then immediately triggers it (with the `sc` instruction) before they restore the correct one. This works on real hardware due to icache, and also works in Dolphin when the IPL runs due to icache, but prior to this change `HID0.ICE` defaulted to 0 so icache was not enabled when the IPL was skipped.
Copy link
Contributor

@JMC47 JMC47 left a comment

Choose a reason for hiding this comment

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

It seems all of the Datel Products work with this now.

This fixes Datel titles having missing textures (which was an issue with the previous commit).
@JMC47 JMC47 merged commit e18053d into dolphin-emu:master Jun 26, 2022
11 checks passed
dvessel pushed a commit to dvessel/dolphin that referenced this pull request Jun 28, 2022
BS2Emu: Set HID0/1/2/4 and MSR with correct default values
@Pokechu22
Copy link
Contributor Author

Here's a detailed writeup of how Datel's code was broken and why this fixes it: https://gist.github.com/Pokechu22/abed8faefa0afc6dd881a8958e2407fe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants