From 48af07578cefcf2059f20ca64624a115e5c8a91e Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Wed, 4 Nov 2020 14:38:44 +0100 Subject: [PATCH] fix --- Source/RMG/M64P/Wrapper/Core.cpp | 30 +++++++++++++++++++++++++++--- Source/RMG/M64P/Wrapper/Core.hpp | 1 + 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Source/RMG/M64P/Wrapper/Core.cpp b/Source/RMG/M64P/Wrapper/Core.cpp index 6e5bcf65..22bff513 100644 --- a/Source/RMG/M64P/Wrapper/Core.cpp +++ b/Source/RMG/M64P/Wrapper/Core.cpp @@ -236,12 +236,36 @@ bool Core::SetPlugin(Plugin_t plugin) return true; } +bool Core::GetRomInfo(RomInfo_t *info) +{ + m64p_error ret; + + ret = M64P::Core.DoCommand(M64CMD_ROM_GET_HEADER, sizeof(m64p_rom_header), &info->Header); + if (ret != M64ERR_SUCCESS) + { + this->rom_Close(); + this->error_Message = "Core::GetRomInfo: M64P::Core.DoCommand(M64CMD_ROM_GET_HEADER) Failed: "; + this->error_Message += M64P::Core.ErrorMessage(ret); + return false; + } + + ret = M64P::Core.DoCommand(M64CMD_ROM_GET_SETTINGS, sizeof(m64p_rom_settings), &info->Settings); + if (ret != M64ERR_SUCCESS) + { + this->rom_Close(); + this->error_Message = "Core::GetRomInfo: M64P::Core.DoCommand(M64CMD_ROM_GET_SETTINGS) Failed: "; + this->error_Message += M64P::Core.ErrorMessage(ret); + return false; + } + + return true; +} + bool Core::GetRomInfo(QString file, RomInfo_t *info) { m64p_error ret; - bool inEmulation = this->emulation_IsRunning() || this->emulation_IsPaused(); - if (!inEmulation && !this->rom_Open(file)) + if (!this->rom_Open(file)) return false; ret = M64P::Core.DoCommand(M64CMD_ROM_GET_HEADER, sizeof(m64p_rom_header), &info->Header); @@ -264,7 +288,7 @@ bool Core::GetRomInfo(QString file, RomInfo_t *info) info->FileName = file; - if (!inEmulation && !this->rom_Close()) + if (!this->rom_Close()) return false; return true; diff --git a/Source/RMG/M64P/Wrapper/Core.hpp b/Source/RMG/M64P/Wrapper/Core.hpp index 8bace652..c639bd9b 100644 --- a/Source/RMG/M64P/Wrapper/Core.hpp +++ b/Source/RMG/M64P/Wrapper/Core.hpp @@ -35,6 +35,7 @@ namespace M64P bool SetPlugin(Plugin_t); bool GetRomInfo(QString, RomInfo_t*); + bool GetRomInfo(RomInfo_t*); bool LaunchEmulation(QString); bool StopEmulation(void);