MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / Initialize

Method Initialize

pcsx2/VMManager.cpp:1341–1648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1339}
1340
1341VMBootResult VMManager::Initialize(const VMBootParameters& boot_params, Error* error)
1342{
1343 const Common::Timer init_timer;
1344 if (s_state.load(std::memory_order_acquire) != VMState::Shutdown)
1345 {
1346 Error::SetString(error, TRANSLATE_STR("VMManager", "The virtual machine is already running."));
1347 return VMBootResult::StartupFailure;
1348 }
1349
1350 // cancel any game list scanning, we need to use CDVD!
1351 // TODO: we can get rid of this once, we make CDVD not use globals...
1352 // (or make it thread-local, but that seems silly.)
1353 Host::CancelGameListRefresh();
1354
1355 s_state.store(VMState::Initializing, std::memory_order_release);
1356 s_vm_thread_handle = Threading::ThreadHandle::GetForCallingThread();
1357 Host::OnVMStarting();
1358 VMManager::Internal::ResetVMHotkeyState();
1359
1360 ScopedGuard close_state = [] {
1361 if (GSDumpReplayer::IsReplayingDump())
1362 GSDumpReplayer::Shutdown();
1363
1364 s_elf_override = {};
1365 ClearELFInfo();
1366 ClearDiscDetails();
1367
1368 Achievements::GameChanged(0, 0);
1369 FullscreenUI::GameChanged(s_title, std::string(), s_disc_serial, 0, 0);
1370 UpdateDiscordPresence(true);
1371 Host::OnGameChanged(s_title, std::string(), std::string(), s_disc_serial, 0, 0);
1372
1373 UpdateGameSettingsLayer();
1374 s_state.store(VMState::Shutdown, std::memory_order_release);
1375 Host::OnVMDestroyed();
1376 ApplySettings();
1377 };
1378
1379 std::string state_to_load;
1380
1381 s_elf_override = boot_params.elf_override;
1382 if (!boot_params.save_state.empty())
1383 state_to_load = boot_params.save_state;
1384
1385 // if we're loading an indexed save state, we need to get the serial/crc from the disc.
1386 if (boot_params.state_index.has_value())
1387 {
1388 if (boot_params.filename.empty())
1389 {
1390 Error::SetString(error,
1391 TRANSLATE_STR("VMManager", "Cannot load an indexed save state without a boot filename."));
1392 return VMBootResult::StartupFailure;
1393 }
1394
1395 state_to_load = GetSaveStateFileName(boot_params.filename.c_str(), boot_params.state_index.value());
1396 if (state_to_load.empty())
1397 {
1398 Error::SetString(error,

Callers

nothing calls this directly

Calls 15

cdvdLockFunction · 0.85
CDVDsys_SetFileFunction · 0.85
CDVDsys_ChangeSourceFunction · 0.85
LoadBIOSFunction · 0.85
cdvdLoadNVRAMFunction · 0.85
DoCDVDopenFunction · 0.85
CDVDsys_GetSourceTypeFunction · 0.85
Hle_SetHostRootFunction · 0.85
Hle_ClearHostRootFunction · 0.85
mmap_ResetBlockTrackingFunction · 0.85
memSetExtraMemModeFunction · 0.85

Tested by

no test coverage detected