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

IOS: Improve timing accuracy for title launches (both ARM and PPC) #9545

Merged
merged 9 commits into from
Mar 27, 2021

Conversation

leoetlino
Copy link
Member

(alternative title: make ES_Launch slower and potentially break it)

This is a series of commits to make ES launch timings closer to console:

  • In BootstrapPPC, we no longer neglect the amount of time it takes to read the DOL/ELF into memory.
  • IOS and ES's slow boot time (>400ms) is now taken into account.
  • IOS reloads are no longer instant. This fixes reloadtest (from this HackMii post) as it makes the reasonable assumption that ES launches for IOS titles do not complete instantly.
  • We now simulate what IOS does with /sys/launch.sys when launching a PPC title because FS operations that modify the NAND are particularly slow.

(those commits can be reviewed one at a time)

This PR also simplifies IPC reinitialisation after an IOS relaunch and makes it more accurate. Contrary to what the current code suggests, there is no complicated ack queue or anything. The extra IPC ack is actually triggered by a syscall that is invoked in ES's main function; the syscall literally just sets Y2, IX1 and IX2 in HW_IPC_ARMCTRL.

Needs careful testing because ES_Launch is cursed

Source/Core/Core/State.cpp Outdated Show resolved Hide resolved
Source/Core/Core/IOS/IOS.cpp Outdated Show resolved Hide resolved
Source/Core/Core/State.cpp Outdated Show resolved Hide resolved
@leoetlino leoetlino removed the WIP / do not merge Work in progress (do not merge) label Mar 2, 2021
@BhaaLseN
Copy link
Member

BhaaLseN commented Mar 3, 2021

Changes seem good, but this time I'll wait with approving until testing is done.

Copy link
Contributor

@iwubcode iwubcode left a comment

Choose a reason for hiding this comment

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

Wasn't 100% sure what to test so tested a handful of things: wiiware titles, wii games, system menu and various channels, and a VC game. Code wise, LGTM

@BhaaLseN
Copy link
Member

BhaaLseN commented Mar 4, 2021

You still have fixup! commits in there btw.

Low MEM1 is cleared by IOS before all the other constants are written.

This will overwrite the Gecko code handler but it should be fine
because HLE::Reload (which will set up the code handler hook again)
will be called after a title change is detected.
Reading the boot content from the NAND takes a non-negligible amount of
time and the PPC should be held in reset while the DOL is being read.
The extra IPC ack is triggered by a syscall that is invoked in ES's
main function; the syscall literally just sets Y2, IX1 and IX2 in
HW_IPC_ARMCTRL -- there is no complicated ack queue or anything.
We should only try to load a symbol map for the new title *after* it
has been loaded into memory, not before. Likewise for applying HLE
patches and loading new custom textures.

In practice, loading/repatching too early was only a problem for
titles that are launched via ES_Launch. This commit fixes that.
The PPC is supposed to be held in reset when another version of IOS is
in the process of being launched for a PPC title launch.

Probably doesn't matter in practice, though the inaccuracy was
definitely observable from the PPC.
@leoetlino
Copy link
Member Author

Squashed and rebased

Copy link
Member

@BhaaLseN BhaaLseN left a comment

Choose a reason for hiding this comment

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

Code LGTM, untested

@leoetlino leoetlino added QA done The PR has been checked to work properly. and removed needs testing labels Mar 27, 2021
@leoetlino leoetlino merged commit 8d2b0ff into dolphin-emu:master Mar 27, 2021
@JMC47
Copy link
Contributor

JMC47 commented Mar 27, 2021

I forgot to post I tested this with Ocarina of Time, Super Smash Bros. Brawl, and Metroid Prime Trilogy among other titles.

leoetlino added a commit to leoetlino/dolphin that referenced this pull request Apr 22, 2021
Oversight from dolphin-emu#9545, which moved the "new game has been loaded" logic
to a separate OnNewTitleLoad function that has to be called explicitly
*after* a title has loaded.
leoetlino added a commit to leoetlino/dolphin that referenced this pull request Apr 22, 2021
Oversight from dolphin-emu#9545, which moved the "new game has been loaded" logic
to a separate OnNewTitleLoad function that has to be called explicitly
*after* a title has loaded.

Coupled with the commit that makes Dolphin not clobber 0x1800-0x3000
when using MIOS, this fixes Wind Waker and other MIOS-patched games
when they are launched from the System Menu.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QA done The PR has been checked to work properly.
Development

Successfully merging this pull request may close these issues.

5 participants