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

VMManager: Refactor and improve boot process #8975

Merged
merged 1 commit into from
Jun 17, 2023
Merged

Conversation

stenzek
Copy link
Member

@stenzek stenzek commented Jun 13, 2023

Description of Changes

  • Serial/title is now linked to disc, instead of running ELF.
  • Save states can be created during BIOS boot.
  • Patches now apply based on the executing CRC, and only after the entry point starts executing (fixes multi-game discs).
  • Add "Fast Forward Boot" option.
  • Split achievements download and activation, downloads occur on initialization, but are not activated until after the ELF loads.
  • Prevent HostFS access while in PS1 mode.
  • Remove multiple sources of truth for ELF/CRC/etc.
  • Move ELF state from global scope to VMManager.
  • Prevent game fixes and hw fixes being active while booting game.
  • Simplify game update.
  • Flush recompilers after ELF loads. No point keeping boot code around which gets overwritten.

Rationale behind Changes

More wx cleanup. Less jank.

Stops games like Burnout 3's NFSU2 demo from crashing if you have widescreen patches enabled.

Gets rid of confusing "Booting PS2 BIOS" which is a holdout from the wx days, instead we load game settings at boot time.

Suggested Testing Steps

  • Test cheats and ws patches.
  • Test demo discs (e.g. Burnout above).
  • Test achievements, make sure they still work.
  • Make sure per-game settings still work, including per-game renderer.
  • Hammer save states a bit. Try save stating while booting.
  • Make sure the interpreter still works. I haven't tested that.
  • Make sure disc swapping still works.

@JordanTheToaster
Copy link
Contributor

Discord rich presence no longer notes what game you are playing or if you are in the BIOS simply saying "No Game Running".

@refractionpcsx2
Copy link
Member

Can we make it so the BIOS shows the region like PS2 BIOS (Europe) or something, please :)

@bigol83
Copy link

bigol83 commented Jun 13, 2023

I wasn't using a widescreen patch for Burnout 3, but bios set to 16:9, that's how Burnout widescreen works on PS2 too. Interesting that a widescreen patch for Burnout makes the demo crash, probably the emulator recognizes it's another game and doesn't like a Burnout 3 widescreen patch applied to NFSU2 demo.

@refractionpcsx2
Copy link
Member

I wasn't using a widescreen patch for Burnout 3, but bios set to 16:9, that's how Burnout widescreen works on PS2 too. Interesting that a widescreen patch for Burnout makes the demo crash, probably the emulator recognizes it's another game and doesn't like a Burnout 3 widescreen patch applied to NFSU2 demo.

It's not really unusual, it unloads burnout and loads NFS, so a widescreen patch (in master) would be overwriting random NFS demo code.

@stenzek stenzek force-pushed the crc branch 2 times, most recently from 33c70df to 4208634 Compare June 14, 2023 14:45
@bigol83
Copy link

bigol83 commented Jun 14, 2023

I tested it and now Burnout 3 boots in French instead of Italian. I need to use complete boot to have Italian language ingame.
I don't know how it works in nightly, i think it checks the language set in bios (i have Italian) without the need to boot the bios. now with this PR that doesn't work anymore. As i said, i need a full boot to have Italian.

My Burnout 3 PAL version SLES-52585 has 3 languages: French, German and Italian.

@refractionpcsx2
Copy link
Member

it's possible the HLE regionparams isn't triggering with the new fast boot changes.

@bigol83
Copy link

bigol83 commented Jun 14, 2023

Just a question, what does fast forward boot option do?

@refractionpcsx2
Copy link
Member

fastforwards the bios part of the boot (which happens even in fast boot mode), until it starts loading the ELF file of the game.

@stenzek stenzek force-pushed the crc branch 2 times, most recently from 14793a2 to 8521e7c Compare June 15, 2023 11:37
@stenzek
Copy link
Member Author

stenzek commented Jun 15, 2023

Language selection should be sorted.

@bigol83
Copy link

bigol83 commented Jun 15, 2023

Language selection in Burnout 3 is now fixed. Also i noticed a couple of really cool improvements.

First, when i enter the NFSU2 demo OSD says that there are no widescreen or patches whatsoever, so it recognizes as its own game.

Then another one i really like because i am using a 60 fps menu cheat. In nightly when i exited the NFSU2 demo and Burnout 3 rebooted it went back to 30 fps menu, like the cheats were disabled, now with this PR it goes back to 60 fps menus and it correctly applies all the cheats i have enabled.

Really great PR. 👍

@refractionpcsx2
Copy link
Member

It looks like patches and gamefixes are applying immediately on disc swap, tried monster rancher 4 and the very second I double click on the disc to swap to (before it's even "inserted") it's loaded patches and settings, and the screen flashes as the GS config updates. However I'm mostly concerned about the patches.

[ 254.6437] OSD [ChangeDisc]: Disc changed to 'Ghost in the Shell - Stand Alone Complex [SLUS-21006] (U).chd'.
[ 254.6441] (IsoFS) Block 0x10: Primary partition info.
[ 254.6442] (IsoFS) Filesystem is ISO9660
[ 254.6451] (SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLUS_210.06;1
[ 254.6454] (SYSTEM.CNF) Software version = 1.01
[ 254.6457] (SYSTEM.CNF) Disc region type = NTSC
[ 254.6462] (IsoFS) Block 0x10: Primary partition info.
[ 254.6463] (IsoFS) Filesystem is ISO9660
[ 254.6914] Initializing Elf: 3684156 bytes
[ 254.6921] Add 111 seconds play time to SLUS-20702 -> now 188
[ 254.6924] Disc changed to Ghost in the Shell - Stand Alone Complex [SLUS-21006] (U).chd.
[ 254.6927] Name: Ghost in the Shell - Stand Alone Complex
[ 254.6930] Serial: SLUS-21006
[ 254.6934] Version: 1.01
[ 254.6937] CRC: 95CC86EF
[ 254.6941] Found 1 game patches in GameDB.
[ 254.6947] Enabled patch:
[ 254.6950] 0,EE,word,0010bc88,48468800
[ 254.6951] 0,EE,word,0010bc8c,4bec682c
[ 254.6954] 0,EE,word,0010bc90,4b8d617d
[ 254.6957] 0,EE,word,0010bc98,4a6d617c
[ 254.6959] 0,EE,word,0012b200,48468800
[ 254.6962] 0,EE,word,0012b204,4bec682c
[ 254.6965] 0,EE,word,0012b208,4b8d617d
[ 254.6968] 0,EE,word,0012b210,4a6d617c
[ 254.6970] 0,EE,word,0012b528,48468800
[ 254.6973] 0,EE,word,0012b52c,4bec682c
[ 254.6976] 0,EE,word,0012b530,4b8d617d
[ 254.6979] 0,EE,word,0012b538,4a6d617c
[ 254.6981] 0,EE,word,00165bb0,48468800
[ 254.6984] 0,EE,word,00165bb4,4bec682c
[ 254.6987] 0,EE,word,00165bb8,4b8d617d
[ 254.6990] 0,EE,word,00165bc0,4a6d617c
[ 254.6993] 0,EE,word,001b0a40,4bec682c
[ 254.6996] 0,EE,word,001b0a4c,4b8d617d
[ 254.6998] 0,EE,word,001bf4c0,48588800
[ 254.7011] 0,EE,word,001bf4d0,4a0002ff
[ 254.7014] 0,EE,word,001bfa7c,48588800
[ 254.7017] 0,EE,word,001bfa8c,4a0002ff
[ 254.7021] 0,EE,word,001bf6dc,48588800
[ 254.7023] 0,EE,word,001bf6ec,4a0002ff
[ 254.7026] 0,EE,word,001c0040,48588800
[ 254.7029] 0,EE,word,001c0050,4a0002ff
[ 254.7032] No game settings found (tried 'G:\ps2\gitrepo\Builds\PCSX2-windows-Qt-x64-cmake-pr[8975]-sha[8521e7c]-title[VMManager Refactor and improve boot process]\gamesettings\95CC86EF.ini')
[ 254.7037] Applying settings...
[ 254.7042] [GameDB] Enabled GS Hardware Fix: halfPixelOffset to [mode=1]
[ 254.7042] [GameDB] Enabled GS Hardware Fix: mergeSprite to [mode=1]
[ 254.7045] [GameDB] Enabled GS Hardware Fix: getSkipCount to [mode=19]
[ 254.7048] Updating GS configuration...
[ 254.7052] Vsync is OFF
[ 254.7054] (UpdateVSyncRate) Mode Changed to NTSC.
[ 254.7059] (UpdateVSyncRate) Mode Changed to NTSC.
[ 254.8898] Simulating ejected media
[ 257.8928] Close virtual disk tray
[ 257.8930] Detecting media
[ 260.8958] Seeking new disc
[ 262.8977] Media ready to use

Here's a memcard for the SLUS-20702 version of Monster Rancher 4. You need to load the save, go to the Association, choose to retire the only monster, then get a new monster "from saucer" that will let you swap disc, choose one which has compatibility patches.
monsterrancher4.zip

[SAVEVERSION+] VM struct changes.

 - Serial/title is now linked to disc, instead of running ELF.
 - Save states can be created during BIOS boot.
 - Patches now apply based on the executing CRC, and only after the
   entry point starts executing (fixes multi-game discs).
 - Add "Fast Forward Boot" option.
 - Split achievements download and activation, downloads occur on
   initialization, but are not activated until after the ELF loads.
 - Prevent HostFS access while in PS1 mode.
 - Remove multiple sources of truth for ELF/CRC/etc.
 - Move ELF state from global scope to VMManager.
 - Prevent game fixes and hw fixes being active while booting game.
 - Simplify game update.
 - Flush recompilers after ELF loads. No point keeping boot code around
   which gets overwritten.
@stenzek
Copy link
Member Author

stenzek commented Jun 16, 2023

It looks like patches and gamefixes are applying immediately on disc swap, tried monster rancher 4 and the very second I double click on the disc to swap to (before it's even "inserted") it's loaded patches and settings, and the screen flashes as the GS config updates. However I'm mostly concerned about the patches.

This is actually working as expected. GiTS has a "default" patch in the gamedb (i.e. "apply to all serials"), hence why it gets applied immediately on disc swap. The serial is tied to the mounted disc, so it reloads patches, and matches, because the GameDB is "default".

IMO, gamedb should be fixed, rather than making things gross and hacky. Like I said the other day, having "default" patches doesn't really make sense, when the patch is dependent on the ELF, which is what the CRC is derived from...

(I did refactor ReloadPatches() slightly and simplify it a bit, getting rid of the double serial storage, though.)

@refractionpcsx2
Copy link
Member

refractionpcsx2 commented Jun 16, 2023

The reason default exists is because there can be multiple versions of the game under the same serial with the same offsets for the patch, so to save having to write exactly the same patch multiple times, we use the default tag. The other solution would be to allow multiple CRC's to be specified at the top of the patch entry, but I don't think it does that right now.

@stenzek
Copy link
Member Author

stenzek commented Jun 16, 2023

For the record, we discussed the patch conflict issue - probably the best solution would be to have a whitelist of CRCs that the "default" patch should apply to, but that's a separate issue.

@stenzek stenzek merged commit 36c2718 into PCSX2:master Jun 17, 2023
12 checks passed
@stenzek stenzek deleted the crc branch June 17, 2023 07:38
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

4 participants