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

pcsx2: DI execution is delayed by one instruction #3172

Merged
merged 2 commits into from
Dec 22, 2019
Merged

Conversation

lightningterror
Copy link
Contributor

@lightningterror lightningterror commented Dec 18, 2019

Core: Fixes booting issues in the following games:
Jak X, Namco 50th anniversary, Spongebob the Movie, Spongebob Battle for Bikini Bottom,
The Incredibles, The Incredibles rize of the underminer, Soukou kihei armodyne, Garfield Saving Arlene, Tales of Fandom Vol. 2.
The games will no longer require a patch to boot.

Gamedb: remove gamefix patches for DI execution fixes. Jak X, Spongebob Squarepants( The movie and Battle for Bikini Bottom), namCollection - Namco 50th Anniversary, Soukou kihei armodyne, garfield saving arlene.

Credits go to Refraction, fix was backported from Dobiestation, original contributors Refraction and PSI

@ramapcsx2
Copy link
Member

Nice!
Any info where this is from / how it was discovered?

@refractionpcsx2
Copy link
Member

refractionpcsx2 commented Dec 18, 2019

Nice!
Any info where this is from / how it was discovered?

by PSI and Dobiestation, through testing :P and I think the information was looked up from old sony newsgroups

@ghost
Copy link

ghost commented Dec 19, 2019

This is a awsome fix! You forgot to mention the Incredibles games but it's not that important as it is the same engine as those 2 spongebob games.

@lightningterror
Copy link
Contributor Author

This is a awsome fix! You forgot to mention the Incredibles games but it's not that important as it is the same engine as those 2 spongebob games.

They do have a boot patch too, if it fixes those games too I can remove it as well.

@ramapcsx2
Copy link
Member

Well, code that uses DI is timing critical. This fix could be pretty big ;p

@MrCK1
Copy link
Member

MrCK1 commented Dec 19, 2019

As I've already told Ref, none of my other games have shown regressions. Everything is working fine so far :). He did mention on Discord that it shouldn't affect anything that didn't already have a big patch :P

@ramapcsx2
Copy link
Member

I suppose a good follow up would be to check IOP as well :)

@ghost ghost added the R5900 label Dec 20, 2019
@ghost
Copy link

ghost commented Dec 21, 2019

This PR solve a game hanging at start on the title "Soukou kihei armodyne"

image

@ghost ghost added this to the Release 1.6 milestone Dec 21, 2019
@ghost
Copy link

ghost commented Dec 21, 2019

And a another game fixed by this PR "garfield saving arlene", goes from intro to playable.

image

@PSI-Rockin
Copy link
Contributor

I'll give an in-depth explanation on what's going on.

These games rely on a bug in the EE kernel. Just before it starts executing a game, the kernel tries to disable interrupts with the following code:

di
mfc0 k0, Status
ori k0, 0x13
mtc0 k0, Status
sync

However, DI is not atomic. That means it does not complete after the instruction has executed, which means that the MFC0 will be executed before DI completes. That is to say... MFC0 will read the old value of the master interrupt enable, which is set to 1. The DI completes before MTC0 is executed, but MTC0 will overwrite the master interrupt enable as a result. The tl;dr here is that the DI has no effect because the kernel doesn't properly wait for interrupts to be disabled.

All these games check if interrupts are enabled when they start booting by reading the master interrupt enable bit. If interrupts are disabled, they will crash or hang in various ways - Jak X calls the Exit syscall, Namco 50 hangs on a black screen, Heavy Iron games hang on loading screens. There is no reason for them to do this other than to mess with emulators. Clearly it worked, given how long PCSX2 has needed patches to deal with the more popular games, and how the less popular games were simply doomed to never work.

@ghost
Copy link

ghost commented Dec 22, 2019

Seriously, please merge the PR now, it fixes hanging problem in "Tales of Fandom Vol. 2"

image

refractionpcsx2 and others added 2 commits December 22, 2019 18:03
Fixes booting issues in the following games:
Jak X, Namco 50th anniversary, Spongebob the Movie, Spongebob Battle for Bikini Bottom,
The Incredibles, The Incredibles rize of the underminer, Soukou kihei armodyne, Garfield Saving Arlene, Tales of Fandom Vol. 2.

The games will no longer require a patch to boot.
Jak X, Spongebob Squarepants( The movie  and Battle for Bikini Bottom),
namCollection - Namco 50th Anniversary, Disney-Pixar's The Incredibles,
Incredibles, The - Rise of the Underminer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants