From 080cfe2249f715c90e47883e4ec8d30248892650 Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Wed, 27 Oct 2021 18:41:51 +0200 Subject: [PATCH] RMG: remove some misc functions from M64P::Wrapper::Core --- Source/RMG/M64P/Wrapper/Core.cpp | 305 +------------------------------ Source/RMG/M64P/Wrapper/Core.hpp | 30 --- 2 files changed, 8 insertions(+), 327 deletions(-) diff --git a/Source/RMG/M64P/Wrapper/Core.cpp b/Source/RMG/M64P/Wrapper/Core.cpp index 7d8b8144..1b60c559 100644 --- a/Source/RMG/M64P/Wrapper/Core.cpp +++ b/Source/RMG/M64P/Wrapper/Core.cpp @@ -13,7 +13,8 @@ #include "../Api.hpp" #include "../api/version.h" #include "Config.hpp" -#include "Plugin.hpp" + +#include #include #include @@ -27,20 +28,6 @@ Core::Core(void) Core::~Core(void) { - for (Plugin p : - { - this->plugin_Gfx, - this->plugin_Rsp, - this->plugin_Audio, - this->plugin_Input - }) - { - if (p.HasInit()) - { - p.Shutdown(); - } - - } } bool Core::Init(m64p_dynlib_handle handle) @@ -78,28 +65,6 @@ bool Core::Init(m64p_dynlib_handle handle) return true; } -bool Core::HasPluginConfig(PluginType type) -{ - return this->plugin_Get(type)->HasConfig(); -} - -bool Core::OpenPluginConfig(PluginType type) -{ - bool ret, paused; - - paused = this->emulation_IsPaused(); - - if (!paused) - this->PauseEmulation(); - - ret = this->plugin_Get(type)->OpenConfig(); - - if (!paused) - this->ResumeEmulation(); - - return ret; -} - bool Core::TakeScreenshot(void) { m64p_error ret; @@ -146,69 +111,6 @@ bool Core::SetSpeedLimiter(bool enabled) return ret == M64ERR_SUCCESS; } -QList Core::GetPlugins(PluginType type) -{ - QList plugins; - QString dir; - - switch (type) - { - default: - case PluginType::Gfx: - dir = MUPEN_DIR_GFX; - break; - case PluginType::Rsp: - dir = MUPEN_DIR_RSP; - break; - case PluginType::Audio: - dir = MUPEN_DIR_AUDIO; - break; - case PluginType::Input: - dir = MUPEN_DIR_INPUT; - break; - } - - QDir qDir(dir); - QStringList filter; - - filter << "*." SO_EXT; - - QFileInfoList fileList = qDir.entryInfoList(filter); - - Plugin p; - Plugin_t pInfo; - - for (const QFileInfo &info : fileList) - { - if (p.Init(info.filePath(), this->handle)) - { - pInfo = p.GetPlugin_t(); - - if (pInfo.Type == type) - plugins.append(pInfo); - } - } - - return plugins; -} - -M64P::Wrapper::Plugin *Core::plugin_Get(PluginType type) -{ - switch (type) - { - case PluginType::Gfx: - return &this->plugin_Gfx; - case PluginType::Rsp: - return &this->plugin_Rsp; - case PluginType::Audio: - return &this->plugin_Audio; - case PluginType::Input: - return &this->plugin_Input; - default: - return nullptr; - } -} - char *Core::media_loader_get_gb_cart_rom(void *_this, int) { return NULL; @@ -239,107 +141,6 @@ char *Core::media_loader_get_dd_disk(void *_this) return strdup(file.toStdString().c_str()); } -bool Core::plugin_Attach(Plugin *p) -{ - m64p_error ret; - - ret = M64P::Core.AttachPlugin(p->GetType(), p->GetHandle()); - - if (ret != M64ERR_SUCCESS) - { - this->error_Message = "Core::plugin_Attach ( " + p->GetPlugin_t().Name + " ) Failed: "; - this->error_Message += M64P::Core.ErrorMessage(ret); - } - - return ret == M64ERR_SUCCESS; -} - -bool Core::plugins_Attach(void) -{ - return this->plugin_Attach(&this->plugin_Gfx) && this->plugin_Attach(&this->plugin_Audio) && - this->plugin_Attach(&this->plugin_Input) && this->plugin_Attach(&this->plugin_Rsp); -} - -bool Core::plugins_Detach(void) -{ - M64P::Core.DetachPlugin(M64PLUGIN_GFX); - M64P::Core.DetachPlugin(M64PLUGIN_AUDIO); - M64P::Core.DetachPlugin(M64PLUGIN_INPUT); - M64P::Core.DetachPlugin(M64PLUGIN_RSP); - return true; -} - -bool Core::plugin_LoadTodo(void) -{ - if (!this->plugin_Todo.isEmpty()) - { - for (const Plugin_t &p : this->plugin_Todo) - { - if (!this->SetPlugin(p)) - return false; - } - - this->plugin_Todo.clear(); - } - - return true; -} - -bool Core::SetPlugin(Plugin_t plugin) -{ - bool ret; - - // don't apply plugins when emulation is running - if (this->IsEmulationRunning() || this->isEmulationPaused()) - { - plugin_Todo.append(plugin); - return true; - } - - Plugin *p = this->plugin_Get(plugin.Type); - - if (p->HasInit()) - { - ret = p->Shutdown(); - if (!ret) - { - this->error_Message = "Core::SetPlugin p->Shutdown() Failed: "; - this->error_Message += p->GetLastError(); - return false; - } - } - - ret = p->Init(plugin.FileName, this->handle); - if (!ret) - { - this->error_Message = "Core::SetPlugin p->Init() Failed: "; - this->error_Message += p->GetLastError(); - return false; - } - - ret = p->Startup(); - if (!ret) - { - this->error_Message = "Core::SetPlugin p->Startup() Failed: "; - this->error_Message += p->GetLastError(); - return false; - } - - return true; -} - -bool Core::GetCurrentPlugin(PluginType type, Plugin_t *plugin_t) -{ - Plugin *p = this->plugin_Get(type); - - if (!p->HasInit()) - return false; - - *plugin_t = p->GetPlugin_t(); - - return true; -} - bool Core::GetRomInfo(RomInfo_t *info) { m64p_error ret; @@ -412,9 +213,6 @@ bool Core::LaunchEmulation(QString file) { m64p_error ret; - if (!this->plugin_LoadTodo()) - return false; - if (!this->GetRomInfo(file, &this->rom_Info, false)) return false; @@ -427,12 +225,12 @@ bool Core::LaunchEmulation(QString file) if (!this->core_ApplyOverlay()) return false; - if (!this->plugins_Attach()) + if (!CoreAttachPlugins()) return false; ret = M64P::Core.DoCommand(M64CMD_EXECUTE, 0, NULL); - this->plugins_Detach(); + CoreDetachPlugins(); if (ret != M64ERR_SUCCESS) { @@ -445,9 +243,6 @@ bool Core::LaunchEmulation(QString file) if (!this->rom_Close()) return false; - if (!this->plugin_LoadTodo()) - return false; - return true; } @@ -545,91 +340,6 @@ bool Core::PressGameSharkButton(void) return true; } -int Core::GetSaveSlot(void) -{ - m64p_error ret; - int slot = 0; - - ret = M64P::Core.DoCommand(M64CMD_CORE_STATE_QUERY, M64CORE_SAVESTATE_SLOT, &slot); - if (ret != M64ERR_SUCCESS) - { - this->error_Message = "Core::GetSaveSlot M64P::Core.DoCommand(M64CMD_CORE_STATE_QUERY, M64CORE_SAVESTATE_SLOT) Failed: "; - this->error_Message += M64P::Core.ErrorMessage(ret); - } - - return slot; -} - -bool Core::SetSaveSlot(int slot) -{ - m64p_error ret; - - ret = M64P::Core.DoCommand(M64CMD_CORE_STATE_SET, M64CORE_SAVESTATE_SLOT, &slot); - if (ret != M64ERR_SUCCESS) - { - this->error_Message = "Core::SetSaveSlot M64P::Core.DoCommand(M64CMD_CORE_STATE_SET, M64CORE_SAVESTATE_SLOT) Failed: "; - this->error_Message += M64P::Core.ErrorMessage(ret); - } - - return ret == M64ERR_SUCCESS; -} - -bool Core::SaveStateAsFile(QString file) -{ - m64p_error ret; - - ret = M64P::Core.DoCommand(M64CMD_STATE_SAVE, 1, (void *)file.toStdString().c_str()); - if (ret != M64ERR_SUCCESS) - { - this->error_Message = "Core::SaveStateAsFile: M64P::Core.DoCommand(M64CMD_STATE_SAVE) Failed: "; - this->error_Message += M64P::Core.ErrorMessage(ret); - } - - return ret == M64ERR_SUCCESS; -} - -bool Core::LoadStateFromFile(QString file) -{ - m64p_error ret; - - ret = M64P::Core.DoCommand(M64CMD_STATE_LOAD, 0, (void *)file.toStdString().c_str()); - if (ret != M64ERR_SUCCESS) - { - this->error_Message = "Core::SaveStateAsFile: M64P::Core.DoCommand(M64CMD_STATE_LOAD) Failed: "; - this->error_Message += M64P::Core.ErrorMessage(ret); - } - - return ret == M64ERR_SUCCESS; -} - -bool Core::SaveState(void) -{ - m64p_error ret; - - ret = M64P::Core.DoCommand(M64CMD_STATE_SAVE, 0, NULL); - if (ret != M64ERR_SUCCESS) - { - this->error_Message = "Core::SaveState: M64P::Core.DoCommand(M64CMD_STATE_SAVE) Failed: "; - this->error_Message += M64P::Core.ErrorMessage(ret); - } - - return ret == M64ERR_SUCCESS; -} - -bool Core::LoadState(void) -{ - m64p_error ret; - - ret = M64P::Core.DoCommand(M64CMD_STATE_LOAD, 0, NULL); - if (ret != M64ERR_SUCCESS) - { - this->error_Message = "Core::LoadState: M64P::Core.DoCommand(M64CMD_STATE_LOAD) Failed: "; - this->error_Message += M64P::Core.ErrorMessage(ret); - } - - return ret == M64ERR_SUCCESS; -} - bool Core::SetKeyDown(int key, int mod) { m64p_error ret; @@ -952,18 +662,19 @@ bool Core::rom_ApplyPluginOverlay(void) SettingsID settingIdArray[] = {SettingsID::Game_GFX_Plugin, SettingsID::Game_AUDIO_Plugin, SettingsID::Game_INPUT_Plugin, SettingsID::Game_RSP_Plugin}; +/* for (int i = 0; i < 4; i++) this->plugin_Todo.append(g_Plugins.GetCurrentPlugin((PluginType)i)); - +*/ for (int i = 0; i < 4; i++) { value = QString::fromStdString(CoreSettingsGetStringValue(settingIdArray[i], section.toStdString())); - if (!value.isEmpty()) + /*if (!value.isEmpty()) { Plugin_t plugin = {.FileName = value}; if (!this->SetPlugin(plugin)) return false; - } + }*/ } return true; diff --git a/Source/RMG/M64P/Wrapper/Core.hpp b/Source/RMG/M64P/Wrapper/Core.hpp index e426b086..db18cdbe 100644 --- a/Source/RMG/M64P/Wrapper/Core.hpp +++ b/Source/RMG/M64P/Wrapper/Core.hpp @@ -10,7 +10,6 @@ #ifndef M64P_WRAPPER_CORE_HPP #define M64P_WRAPPER_CORE_HPP -#include "Plugin.hpp" #include "Types.hpp" #include @@ -30,13 +29,6 @@ class Core : public QObject bool Init(m64p_dynlib_handle); - bool HasPluginConfig(PluginType); - bool OpenPluginConfig(PluginType); - - QList GetPlugins(PluginType); - bool SetPlugin(Plugin_t); - bool GetCurrentPlugin(PluginType, Plugin_t *); - bool GetRomInfo(QString, RomInfo_t *, bool); bool GetRomInfo(RomInfo_t *); bool GetDefaultRomInfo(RomInfo_t *); @@ -58,15 +50,6 @@ class Core : public QObject bool PressGameSharkButton(void); - int GetSaveSlot(void); - bool SetSaveSlot(int); - - bool SaveStateAsFile(QString); - bool LoadStateFromFile(QString); - - bool SaveState(void); - bool LoadState(void); - bool SetKeyDown(int, int); bool SetKeyUp(int, int); @@ -90,19 +73,6 @@ class Core : public QObject m64p_dynlib_handle handle; - QList plugin_Todo; - M64P::Wrapper::Plugin plugin_Rsp; - M64P::Wrapper::Plugin plugin_Gfx; - M64P::Wrapper::Plugin plugin_Audio; - M64P::Wrapper::Plugin plugin_Input; - - M64P::Wrapper::Plugin *plugin_Get(PluginType); - bool plugin_Attach(Plugin *); - bool plugins_Attach(void); - bool plugins_Detach(void); - bool plugin_LoadTodo(void); - - RomInfo_t rom_Info; bool rom_Open(QString, bool);