gs: initial merge complete up to linking errors

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2021-05-12 14:22:10 +02:00 committed by Kojin
parent 3a5d1ace91
commit 24b9c5698e
6 changed files with 37 additions and 55 deletions

View File

@ -30,6 +30,7 @@
#include "SPU2/spu2.h" #include "SPU2/spu2.h"
#include "DEV9/DEV9.h" #include "DEV9/DEV9.h"
#include "USB/USB.h" #include "USB/USB.h"
#include "gui/MemoryCardFile.h"
#ifdef _WIN32 #ifdef _WIN32
#include "PAD/Windows/PAD.h" #include "PAD/Windows/PAD.h"
#else #else
@ -102,9 +103,7 @@ void SysCoreThread::OnStart()
void SysCoreThread::Start() void SysCoreThread::Start()
{ {
if (!GetCorePlugins().AreLoaded()) GSinit();
return;
GetCorePlugins().Init();
SPU2init(); SPU2init();
PADinit(); PADinit();
DEV9init(); DEV9init();
@ -317,18 +316,19 @@ void SysCoreThread::ExecuteTaskInThread()
void SysCoreThread::OnSuspendInThread() void SysCoreThread::OnSuspendInThread()
{ {
GetCorePlugins().Close();
DEV9close(); DEV9close();
USBclose(); USBclose();
DoCDVDclose(); DoCDVDclose();
FWclose(); FWclose();
PADclose(); PADclose();
SPU2close(); SPU2close();
FileMcd_EmuClose();
GetMTGS().Suspend();
} }
void SysCoreThread::OnResumeInThread(bool isSuspended) void SysCoreThread::OnResumeInThread(bool isSuspended)
{ {
GetCorePlugins().Open(); GetMTGS().WaitForOpen();
if (isSuspended) if (isSuspended)
{ {
DEV9open((void*)pDsp); DEV9open((void*)pDsp);
@ -337,6 +337,7 @@ void SysCoreThread::OnResumeInThread(bool isSuspended)
FWopen(); FWopen();
SPU2open((void*)pDsp); SPU2open((void*)pDsp);
PADopen((void*)pDsp); PADopen((void*)pDsp);
FileMcd_EmuOpen();
} }
@ -357,12 +358,13 @@ void SysCoreThread::OnCleanupInThread()
DEV9close(); DEV9close();
DoCDVDclose(); DoCDVDclose();
FWclose(); FWclose();
GetCorePlugins().Close(); FileMcd_EmuClose();
GetCorePlugins().Shutdown(); GetMTGS().Suspend();
USBshutdown(); USBshutdown();
SPU2shutdown(); SPU2shutdown();
PADshutdown(); PADshutdown();
DEV9shutdown(); DEV9shutdown();
GetMTGS().Cancel();
_mm_setcsr(m_mxcsr_saved.bitmask); _mm_setcsr(m_mxcsr_saved.bitmask);
Threading::DisableHiresScheduler(); Threading::DisableHiresScheduler();

View File

@ -247,8 +247,6 @@ void SysThreadBase::Resume()
return; return;
if ((m_ExecMode != ExecMode_Closed) && (m_ExecMode != ExecMode_Paused)) if ((m_ExecMode != ExecMode_Closed) && (m_ExecMode != ExecMode_Paused))
return; return;
if (!GetCorePlugins().AreLoaded())
return;
break; break;
case ExecMode_Paused: case ExecMode_Paused:

View File

@ -870,13 +870,6 @@ ScopedCoreThreadPause::~ScopedCoreThreadPause()
ScopedCoreThreadPopup::ScopedCoreThreadPopup() ScopedCoreThreadPopup::ScopedCoreThreadPopup()
{ {
// The old style GUI (without GSopen2) must use a full close of the CoreThread, in order to
// ensure that the GS window isn't blocking the popup, and to avoid crashes if the GS window
// is maximized or fullscreen.
if (!GSopen2)
m_scoped_core = std::unique_ptr<BaseScopedCoreThread>(new ScopedCoreThreadClose());
else
m_scoped_core = std::unique_ptr<BaseScopedCoreThread>(new ScopedCoreThreadPause()); m_scoped_core = std::unique_ptr<BaseScopedCoreThread>(new ScopedCoreThreadPause());
}; };

View File

@ -21,10 +21,6 @@
#include <chrono> #include <chrono>
// IMPORTANT! If this gets a macro redefinition error it means PluginCallbacks.h is included
// in a global-scope header, and that's a BAD THING. Include it only into modules that need
// it, because some need to be able to alter its behavior using defines. Like this:
struct Component_FileMcd; struct Component_FileMcd;
#include "MemoryCardFile.h" #include "MemoryCardFile.h"
@ -583,12 +579,11 @@ u64 FileMemoryCard::GetCRC(uint slot)
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// MemoryCard Component API Bindings // MemoryCard Component API Bindings
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
namespace Mcd
struct Component_FileMcd
{ {
FileMemoryCard impl; // class-based implementations we refer to when API is invoked FileMemoryCard impl; // class-based implementations we refer to when API is invoked
FolderMemoryCardAggregator implFolder; FolderMemoryCardAggregator implFolder;
}; }; // namespace Mcd
uint FileMcd_ConvertToSlot(uint port, uint slot) uint FileMcd_ConvertToSlot(uint port, uint slot)
{ {
@ -622,15 +617,15 @@ void FileMcd_EmuOpen()
} }
} }
Component_FileMcd->impl.Open(); Mcd::impl.Open();
Component_FileMcd->implFolder.SetFiltering(g_Conf->EmuOptions.McdFolderAutoManage); Mcd::implFolder.SetFiltering(g_Conf->EmuOptions.McdFolderAutoManage);
Component_FileMcd->implFolder.Open(); Mcd::implFolder.Open();
} }
void FileMcd_EmuClose() void FileMcd_EmuClose()
{ {
Component_FileMcd->implFolder.Close(); Mcd::implFolder.Close();
Component_FileMcd->impl.Close(); Mcd::impl.Close();
} }
s32 FileMcd_IsPresent(uint port, uint slot) s32 FileMcd_IsPresent(uint port, uint slot)
@ -639,9 +634,9 @@ s32 FileMcd_IsPresent(uint port, uint slot)
switch (g_Conf->Mcd[combinedSlot].Type) switch (g_Conf->Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Component_FileMcd->impl.IsPresent(combinedSlot); return Mcd::impl.IsPresent(combinedSlot);
case MemoryCardType::MemoryCard_Folder: case MemoryCardType::MemoryCard_Folder:
return Component_FileMcd->implFolder.IsPresent(combinedSlot); return Mcd::implFolder.IsPresent(combinedSlot);
default: default:
return false; return false;
} }
@ -653,10 +648,10 @@ void FileMcd_GetSizeInfo(uint port, uint slot, McdSizeInfo* outways)
switch (g_Conf->Mcd[combinedSlot].Type) switch (g_Conf->Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
Component_FileMcd->impl.GetSizeInfo(combinedSlot, *outways); Mcd::impl.GetSizeInfo(combinedSlot, *outways);
break; break;
case MemoryCardType::MemoryCard_Folder: case MemoryCardType::MemoryCard_Folder:
Component_FileMcd->implFolder.GetSizeInfo(combinedSlot, *outways); Mcd::implFolder.GetSizeInfo(combinedSlot, *outways);
break; break;
default: default:
return; return;
@ -669,9 +664,9 @@ bool FileMcd_IsPSX(uint port, uint slot)
switch (g_Conf->Mcd[combinedSlot].Type) switch (g_Conf->Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Component_FileMcd->impl.IsPSX(combinedSlot); return Mcd::impl.IsPSX(combinedSlot);
case MemoryCardType::MemoryCard_Folder: case MemoryCardType::MemoryCard_Folder:
return Component_FileMcd->implFolder.IsPSX(combinedSlot); return Mcd::implFolder.IsPSX(combinedSlot);
default: default:
return false; return false;
} }
@ -683,9 +678,9 @@ s32 FileMcd_Read(uint port, uint slot, u8* dest, u32 adr, int size)
switch (g_Conf->Mcd[combinedSlot].Type) switch (g_Conf->Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Component_FileMcd->impl.Read(combinedSlot, dest, adr, size); return Mcd::impl.Read(combinedSlot, dest, adr, size);
case MemoryCardType::MemoryCard_Folder: case MemoryCardType::MemoryCard_Folder:
return Component_FileMcd->implFolder.Read(combinedSlot, dest, adr, size); return Mcd::implFolder.Read(combinedSlot, dest, adr, size);
default: default:
return 0; return 0;
} }
@ -697,9 +692,9 @@ s32 FileMcd_Save(uint port, uint slot, const u8* src, u32 adr, int size)
switch (g_Conf->Mcd[combinedSlot].Type) switch (g_Conf->Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Component_FileMcd->impl.Save(combinedSlot, src, adr, size); return Mcd::impl.Save(combinedSlot, src, adr, size);
case MemoryCardType::MemoryCard_Folder: case MemoryCardType::MemoryCard_Folder:
return Component_FileMcd->implFolder.Save(combinedSlot, src, adr, size); return Mcd::implFolder.Save(combinedSlot, src, adr, size);
default: default:
return 0; return 0;
} }
@ -711,9 +706,9 @@ s32 FileMcd_EraseBlock(uint port, uint slot, u32 adr)
switch (g_Conf->Mcd[combinedSlot].Type) switch (g_Conf->Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Component_FileMcd->impl.EraseBlock(combinedSlot, adr); return Mcd::impl.EraseBlock(combinedSlot, adr);
case MemoryCardType::MemoryCard_Folder: case MemoryCardType::MemoryCard_Folder:
return Component_FileMcd->implFolder.EraseBlock(combinedSlot, adr); return Mcd::implFolder.EraseBlock(combinedSlot, adr);
default: default:
return 0; return 0;
} }
@ -725,9 +720,9 @@ u64 FileMcd_GetCRC(uint port, uint slot)
switch (g_Conf->Mcd[combinedSlot].Type) switch (g_Conf->Mcd[combinedSlot].Type)
{ {
case MemoryCardType::MemoryCard_File: case MemoryCardType::MemoryCard_File:
return Component_FileMcd->impl.GetCRC(combinedSlot); return Mcd::impl.GetCRC(combinedSlot);
case MemoryCardType::MemoryCard_Folder: case MemoryCardType::MemoryCard_Folder:
return Component_FileMcd->implFolder.GetCRC(combinedSlot); return Mcd::implFolder.GetCRC(combinedSlot);
default: default:
return 0; return 0;
} }
@ -739,10 +734,10 @@ void FileMcd_NextFrame(uint port, uint slot)
switch (g_Conf->Mcd[combinedSlot].Type) switch (g_Conf->Mcd[combinedSlot].Type)
{ {
//case MemoryCardType::MemoryCard_File: //case MemoryCardType::MemoryCard_File:
// Component_FileMcd->impl.NextFrame( combinedSlot ); // Mcd::impl.NextFrame( combinedSlot );
// break; // break;
case MemoryCardType::MemoryCard_Folder: case MemoryCardType::MemoryCard_Folder:
Component_FileMcd->implFolder.NextFrame(combinedSlot); Mcd::implFolder.NextFrame(combinedSlot);
break; break;
default: default:
return; return;
@ -755,10 +750,10 @@ bool FileMcd_ReIndex(uint port, uint slot, const wxString& filter)
switch (g_Conf->Mcd[combinedSlot].Type) switch (g_Conf->Mcd[combinedSlot].Type)
{ {
//case MemoryCardType::MemoryCard_File: //case MemoryCardType::MemoryCard_File:
// return Component_FileMcd->impl.ReIndex( combinedSlot, filter ); // return Mcd::impl.ReIndex( combinedSlot, filter );
// break; // break;
case MemoryCardType::MemoryCard_Folder: case MemoryCardType::MemoryCard_Folder:
return Component_FileMcd->implFolder.ReIndex(combinedSlot, g_Conf->EmuOptions.McdFolderAutoManage, filter); return Mcd::implFolder.ReIndex(combinedSlot, g_Conf->EmuOptions.McdFolderAutoManage, filter);
break; break;
default: default:
return false; return false;

View File

@ -679,7 +679,7 @@ s32 FolderMemoryCard::IsPresent() const
return m_isEnabled; return m_isEnabled;
} }
void FolderMemoryCard::GetSizeInfo(PS2E_McdSizeInfo& outways) const void FolderMemoryCard::GetSizeInfo(McdSizeInfo& outways) const
{ {
outways.SectorSize = PageSize; outways.SectorSize = PageSize;
outways.EraseBlockSizeInSectors = BlockSize / PageSize; outways.EraseBlockSizeInSectors = BlockSize / PageSize;
@ -2148,7 +2148,7 @@ s32 FolderMemoryCardAggregator::IsPresent(uint slot)
return m_cards[slot].IsPresent(); return m_cards[slot].IsPresent();
} }
void FolderMemoryCardAggregator::GetSizeInfo(uint slot, PS2E_McdSizeInfo& outways) void FolderMemoryCardAggregator::GetSizeInfo(uint slot, McdSizeInfo& outways)
{ {
m_cards[slot].GetSizeInfo(outways); m_cards[slot].GetSizeInfo(outways);
} }

View File

@ -72,7 +72,6 @@ void States_FreezeCurrentSlot()
return; return;
} }
GSchangeSaveState(StatesC, SaveStateBase::GetFilename(StatesC).ToUTF8());
StateCopy_SaveToSlot(StatesC); StateCopy_SaveToSlot(StatesC);
#ifdef USE_NEW_SAVESLOTS_UI #ifdef USE_NEW_SAVESLOTS_UI
@ -98,7 +97,6 @@ void _States_DefrostCurrentSlot(bool isFromBackup)
return; return;
} }
GSchangeSaveState(StatesC, SaveStateBase::GetFilename(StatesC).ToUTF8());
StateCopy_LoadFromSlot(StatesC, isFromBackup); StateCopy_LoadFromSlot(StatesC, isFromBackup);
GetSysExecutorThread().PostIdleEvent(SysExecEvent_ClearSavingLoadingFlag()); GetSysExecutorThread().PostIdleEvent(SysExecEvent_ClearSavingLoadingFlag());
@ -127,10 +125,6 @@ void States_updateLoadBackupMenuItem()
static void OnSlotChanged() static void OnSlotChanged()
{ {
OSDlog(Color_StrongGreen, true, " > Selected savestate slot %d", StatesC); OSDlog(Color_StrongGreen, true, " > Selected savestate slot %d", StatesC);
if (GSchangeSaveState != NULL)
GSchangeSaveState(StatesC, SaveStateBase::GetFilename(StatesC).utf8_str());
States_updateLoadBackupMenuItem(); States_updateLoadBackupMenuItem();
} }