From db1bc859d79e091b246e1a31ee8dc5c7f66f10f2 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Fri, 2 Aug 2024 12:36:16 +1000 Subject: [PATCH 01/31] DrawText doesn't need to be loaded here. --- Source/SysPSP/main.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/SysPSP/main.cpp b/Source/SysPSP/main.cpp index 9c9b54bc..6226fdf7 100644 --- a/Source/SysPSP/main.cpp +++ b/Source/SysPSP/main.cpp @@ -197,9 +197,7 @@ void HandleEndOfFrame() CGraphicsContext::Get()->SwitchToLcdDisplay(); CGraphicsContext::Get()->ClearAllSurfaces(); - CDrawText::Initialise(); - - CUIContext * p_context( CUIContext::Create() ); + auto p_context = CUIContext::Create(); if(p_context != NULL) { @@ -208,7 +206,6 @@ void HandleEndOfFrame() delete p_context; } - CDrawText::Destroy(); // Commit the preferences database before starting to run // CPreferences::Get()->Commit(); From f4dc409305a92d37787ff3bf80457d26b3c97104 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Fri, 2 Aug 2024 13:59:00 +1000 Subject: [PATCH 02/31] Use std::byteswap instead of builtins. --- Source/System/Endian.h | 46 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/Source/System/Endian.h b/Source/System/Endian.h index 1636cc57..56d800bc 100644 --- a/Source/System/Endian.h +++ b/Source/System/Endian.h @@ -17,49 +17,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#pragma once - -#include "Base/Types.h" #ifndef UTILITY_ENDIAN_H_ #define UTILITY_ENDIAN_H_ +#include "Base/Types.h" +#include +#include -#ifdef DAEDALUS_ENDIAN_BIG - - #define U8_TWIDDLE 0x0 - #define U16_TWIDDLE 0x0 - #define U16H_TWIDDLE 0x0 - #define BSWAP32(x) x - #define BSWAP16(x) x - -#elif DAEDALUS_ENDIAN_LITTLE - #define U8_TWIDDLE 0x3 - #define U16_TWIDDLE 0x2 - #define U16H_TWIDDLE 0x1 - - #if defined( __GNUC__ ) && !defined(__clang__) - #ifdef DAEDALUS_PSP - #define BSWAP32(x) __builtin_allegrex_wsbw(x) - #define BSWAP16(x) __builtin_allegrex_wsbh(x) - #define WSWAP32(x) __builtin_allegrex_rotr(x, 16) - - #else - #define BSWAP32(x) __builtin_bswap32(x) - #define BSWAP16(x) __builtin_bswap16(x) - #endif - #elif defined( _MSC_VER ) - - #define BSWAP32(x) _byteswap_ulong(x) - #define BSWAP16(x) _byteswap_ushort(x) +constexpr bool is_big_endian = std::endian::native == std::endian::big; - #else - //TODO: Clang? - #define BSWAP32(x) ((x >> 24) | ((x >> 8) & 0xFF00) | ((x & 0xFF00) << 8) | (x << 24)) - #define BSWAP16(x) ((x>>8)|(x<<8)) - #endif +constexpr auto U8_TWIDDLE = is_big_endian ? 0x0 : 0x3; +constexpr auto U16_TWIDDLE = is_big_endian ? 0x0 : 0x2; +constexpr auto U16H_TWIDDLE = is_big_endian ? 0x0 : 0x1; -#else - #error No DAEDALUS_ENDIAN_MODE specified -#endif +#define BSWAP32(x) std::byteswap(x) #endif // UTILITY_ENDIAN_H_ From 057d301b11f91fd125495fb3a4e819670c36f26b Mon Sep 17 00:00:00 2001 From: wally4000 Date: Fri, 2 Aug 2024 15:15:58 +1000 Subject: [PATCH 03/31] Remove BaseDir extern and replace with setBasePath function --- Source/Config/ConfigOptions.h | 2 +- Source/Core/CPU.cpp | 2 +- Source/Core/CPU.h | 2 +- Source/Core/Cheats.cpp | 2 +- Source/Core/Dynamo.cpp | 6 +- Source/Core/PIF.cpp | 4 +- Source/Core/ROM.cpp | 2 +- Source/Core/ROM.h | 2 +- Source/Core/ROMBuffer.cpp | 2 +- Source/Core/RSP_HLE.cpp | 5 +- Source/Core/RomSettings.cpp | 12 +- Source/Core/Save.cpp | 90 +-- Source/Debug/DebugLog.cpp | 5 +- Source/Debug/Dump.cpp | 28 +- Source/Debug/Synchroniser.cpp | 2 +- Source/DynaRec/FragmentCache.cpp | 5 +- Source/DynaRec/TraceRecorder.cpp | 4 +- Source/HLEGraphics/CachedTexture.cpp | 2 +- Source/HLEGraphics/DLDebug.cpp | 2 +- Source/HLEGraphics/DLParser.cpp | 2 +- Source/Interface/Preferences.cpp | 8 +- Source/Interface/RomDB.cpp | 7 +- Source/Interface/SaveState.h | 2 +- Source/OSHLE/patch.cpp | 19 +- Source/RomFile/ROMBuffer.cpp | 515 +++++++++++++++++ Source/RomFile/RomFile.cpp | 2 +- Source/RomFile/RomFile.h | 3 +- Source/RomFile/RomFileCompressed.cpp | 2 +- Source/RomFile/RomSettings.cpp | 516 ++++++++++++++++++ Source/SysCTR/Graphics/GraphicsContextCTR.cpp | 2 +- Source/SysCTR/HLEGraphics/RendererCTR.cpp | 2 +- Source/SysCTR/Input/InputManagerCTR.cpp | 2 +- Source/SysCTR/UI/InGameMenu.cpp | 2 +- Source/SysCTR/UI/RomSelector.cpp | 4 +- Source/SysCTR/main.cpp | 8 +- Source/SysGL/HLEGraphics/RendererGL.cpp | 9 +- Source/SysPSP/Graphics/GraphicsContextPSP.cpp | 2 +- .../HLEGraphics/DisplayListDebugger.cpp | 2 +- Source/SysPSP/HLEGraphics/RendererPSP.cpp | 2 +- Source/SysPSP/Input/InputManagerPSP.cpp | 2 +- Source/SysPSP/Utility/CMakeLists.txt | 2 +- Source/SysPSP/main.cpp | 2 +- Source/SysPosix/Debug/WebDebug.cpp | 2 +- Source/SysPosix/Utility/CMakeLists.txt | 2 +- Source/SysPosix/main.cpp | 2 +- Source/System/CompressedStream.h | 2 +- Source/System/DataSink.h | 2 +- Source/System/IO.h | 1 - Source/Test/BatchTest.cpp | 2 +- Source/UI/CheatOptionsScreen.cpp | 2 +- Source/UI/GlobalSettingsComponent.cpp | 2 +- Source/UI/PauseOptionsComponent.cpp | 2 +- Source/UI/RomSelectorComponent.cpp | 2 +- Source/UI/SavestateSelectorComponent.cpp | 6 +- Source/Utility/CMakeLists.txt | 1 + Source/Utility/IniFile.h | 2 +- .../Utility/IOPosix.cpp => Utility/Paths.cpp} | 19 +- Source/Utility/Paths.h | 11 + Source/Utility/Translate.cpp | 9 +- 59 files changed, 1203 insertions(+), 162 deletions(-) create mode 100644 Source/RomFile/ROMBuffer.cpp create mode 100644 Source/RomFile/RomSettings.cpp rename Source/{SysPosix/Utility/IOPosix.cpp => Utility/Paths.cpp} (66%) create mode 100644 Source/Utility/Paths.h diff --git a/Source/Config/ConfigOptions.h b/Source/Config/ConfigOptions.h index 440bbe06..779a8b0d 100644 --- a/Source/Config/ConfigOptions.h +++ b/Source/Config/ConfigOptions.h @@ -23,7 +23,7 @@ #ifndef CONFIG_CONFIGOPTIONS_H_ #define CONFIG_CONFIGOPTIONS_H_ -#include "System/IO.h" + #include diff --git a/Source/Core/CPU.cpp b/Source/Core/CPU.cpp index a5767797..4349a9c3 100644 --- a/Source/Core/CPU.cpp +++ b/Source/Core/CPU.cpp @@ -678,7 +678,7 @@ void CPU_HANDLE_COUNT_INTERRUPT() // interrupt the dynamo tracer for instance) // TODO(strmnnrmn): should register this with CPU_RegisterVblCallback. if ((gVerticalInterrupts & 0x3F) == 0) { // once every 60 VBLs - // Save_Flush(); + Save_Flush(); for (size_t i = 0; i < gVblCallbacks.size(); ++i) { VblCallback & callback = gVblCallbacks[i]; diff --git a/Source/Core/CPU.h b/Source/Core/CPU.h index db0b6bc0..382a7efc 100644 --- a/Source/Core/CPU.h +++ b/Source/Core/CPU.h @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/R4300OpCode.h" #include "Core/TLB.h" #include "System/SpinLock.h" -#include "System/IO.h" +#include "Utility/Paths.h" //***************************************************************************** // //***************************************************************************** diff --git a/Source/Core/Cheats.cpp b/Source/Core/Cheats.cpp index 49fc2b37..fcdfbc97 100644 --- a/Source/Core/Cheats.cpp +++ b/Source/Core/Cheats.cpp @@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Config/ConfigOptions.h" #include "Ultra/ultra_R4300.h" -#include "System/IO.h" + #include "Utility/StringUtil.h" #include "Utility/VolatileMem.h" #include diff --git a/Source/Core/Dynamo.cpp b/Source/Core/Dynamo.cpp index a4355a2e..1fa2ffba 100644 --- a/Source/Core/Dynamo.cpp +++ b/Source/Core/Dynamo.cpp @@ -41,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "DynaRec/TraceRecorder.h" #include "OSHLE/patch.h" // GetCorrectOp #include "Ultra/ultra_R4300.h" -#include "System/IO.h" + #include "Base/Macros.h" #include "Utility/Profiler.h" #include "Debug/Synchroniser.h" @@ -305,8 +305,8 @@ bool SortByHitCount( const SAddressHitCount & a, const SAddressHitCount & b ) //***************************************************************************** void CPU_DumpFragmentCache() { - std::filesystem::path& dynarecDump = baseDir; - dynarecDump /= "DynarecDump"; + + std::filesystem::path dynarecDump = setBasePath("DynarecDump"); std::filesystem::create_directory(dynarecDump); dynarecDump /= "hot_trace_map.html"; diff --git a/Source/Core/PIF.cpp b/Source/Core/PIF.cpp index 072a6d36..11727269 100644 --- a/Source/Core/PIF.cpp +++ b/Source/Core/PIF.cpp @@ -268,8 +268,8 @@ IController::IController() : mpEepromData( nullptr ) { #ifdef DAEDALUS_DEBUG_PIF - std::filesystem::path controller_path = baseDir; - controller_path /= "controller.txt"; + + std::filesystem::path controller_path = setBasePath("controller.txt"); mDebugFile.open(controller_path, std::ios::out); #endif diff --git a/Source/Core/ROM.cpp b/Source/Core/ROM.cpp index bd8ceb43..a35ac61c 100644 --- a/Source/Core/ROM.cpp +++ b/Source/Core/ROM.cpp @@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "HLEGraphics/GraphicsPlugin.h" #include "Utility/CRC.h" #include "Core/FramerateLimiter.h" -#include "System/IO.h" + #include "Base/Macros.h" #include "Interface/Preferences.h" #include "RomFile/RomFile.h" diff --git a/Source/Core/ROM.h b/Source/Core/ROM.h index 79f407a3..67415e86 100644 --- a/Source/Core/ROM.h +++ b/Source/Core/ROM.h @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CORE_ROM_H_ #include "Core/ROMImage.h" -#include "System/IO.h" + #include #include class RomID diff --git a/Source/Core/ROMBuffer.cpp b/Source/Core/ROMBuffer.cpp index d6381d31..b9e78b28 100644 --- a/Source/Core/ROMBuffer.cpp +++ b/Source/Core/ROMBuffer.cpp @@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "RomFile/RomFileCache.h" #include "RomFile/RomFileMemory.h" #include "Utility/Stream.h" -#include "System/IO.h" + #include diff --git a/Source/Core/RSP_HLE.cpp b/Source/Core/RSP_HLE.cpp index 36691751..5df66276 100644 --- a/Source/Core/RSP_HLE.cpp +++ b/Source/Core/RSP_HLE.cpp @@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "HLEAudio/AudioPlugin.h" #include "HLEGraphics/GraphicsPlugin.h" #include "Test/BatchTest.h" -#include "System/IO.h" + #include "Core/PrintOpCode.h" #include "Utility/Profiler.h" @@ -63,8 +63,7 @@ static void RDP_DumpRSPCode(char * name, u32 crc, u32 * mem_base, u32 pc_base, u std::string filename = std::format("task_dump_{}_crc_0x{}.txt", name, crc); // snprintf(filename, sizeof(filename), "task_dump_%s_crc_0x%08x.txt", name, crc); - std::filesystem::path filepath = baseDir; - filepath /= "rsp_dumps"; + std::filesystem::path filepath = setBasePath("rsp_dumps"); std::filesystem::create_directory(filepath); filepath /= filename; diff --git a/Source/Core/RomSettings.cpp b/Source/Core/RomSettings.cpp index b2488dfd..a5e902ae 100644 --- a/Source/Core/RomSettings.cpp +++ b/Source/Core/RomSettings.cpp @@ -35,7 +35,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Debug/DBGConsole.h" #include "Interface/RomDB.h" #include "Utility/IniFile.h" -#include "System/IO.h" +#include "Utility/Paths.h" namespace { @@ -152,11 +152,7 @@ template<> bool CSingleton< CRomSettingsDB >::Create() DAEDALUS_ASSERT_Q(mpInstance == nullptr); #endif mpInstance = std::make_shared(); - std::filesystem::path p = baseDir; - p /= "roms.ini"; - - mpInstance->OpenSettingsFile( p ); - + mpInstance->OpenSettingsFile( setBasePath("roms.ini") ); return true; } @@ -221,9 +217,9 @@ static RomID RomIDFromString( const char * str ) bool IRomSettingsDB::OpenSettingsFile( const std::filesystem::path &filename ) { - std::filesystem::path mFilename = baseDir; - mFilename /= filename; + std::filesystem::path mFilename = setBasePath(filename); + auto p_ini_file = CIniFile::Create(filename); if( p_ini_file == nullptr ) { diff --git a/Source/Core/Save.cpp b/Source/Core/Save.cpp index 470209f2..23b9365e 100644 --- a/Source/Core/Save.cpp +++ b/Source/Core/Save.cpp @@ -19,23 +19,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "Base/Path.h" + #include "Core/ROM.h" #include "Core/Memory.h" #include "Core/Save.h" #include "Config/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "Debug/Dump.h" -#include "System/IO.h" +#include "Utility/Paths.h" #include #include #include #include - +#include static void InitMempackContent(); -std::filesystem::path gSaveFileName; +static std::filesystem::path gSaveFileName; static bool gSaveDirty; static u32 gSaveSize; static std::filesystem::path gMempackFileName; @@ -73,27 +73,28 @@ bool Save_Reset() gSaveDirty = false; if (gSaveSize > 0) { - gSaveFileName = Save_As(g_ROM.mFileName, ext, "SaveGames/"); - std::fstream file(gSaveFileName, std::ios::in | std::ios::out | std::ios::binary); + std::filesystem::path saveDir = setBasePath("SaveGames"); + std::filesystem::path romName = g_ROM.mFileName; + gSaveFileName = saveDir / (romName.filename().string()); + gSaveFileName.replace_extension(ext); + std::ifstream file(gSaveFileName, std::ios::in | std::ios::binary); if (file.is_open()) - - // if (fp != nullptr) { DBGConsole_Msg(0, "Loading save from [C%s]", gSaveFileName.string().c_str()); - std::vector buffer(2048); + u8 buffer[2048]; u8 * dst = (u8*)g_pMemoryBuffers[MEM_SAVE]; - for (u32 d = 0; d < gSaveSize; d += buffer.size()) + for (u32 d = 0; d < gSaveSize; d += sizeof(buffer)) { - file.read(reinterpret_cast(buffer.data()), buffer.size()); + file.read(reinterpret_cast(buffer), sizeof(buffer)); for (u32 i = 0; i < sizeof(buffer); i++) { dst[d+i] = buffer[i^U8_TWIDDLE]; } } - // fclose(fp); + } else { @@ -103,27 +104,33 @@ bool Save_Reset() // init mempack, we always assume the presence of the mempack for simplicity { - gSaveFileName = Save_As(g_ROM.mFileName, ".mpk", "SaveGames/"); - std::fstream file(gSaveFileName, std::ios::in |std::ios::out |std::ios::binary); - if (file.is_open()) + std::filesystem::path saveDir = setBasePath("SaveGames"); + std::filesystem::path romName = g_ROM.mFileName; + gMempackFileName = saveDir / (romName.filename().string()); + gMempackFileName.replace_extension(".mpk"); + bool fileExists = std::filesystem::exists(gMempackFileName); + std::fstream file(gMempackFileName, std::ios::in | std::ios::out | std::ios::binary); + if (!file) { - DBGConsole_Msg(0, "Loading MemPack from [C%s]", gSaveFileName.string().c_str()); - file.read(reinterpret_cast(g_pMemoryBuffers[MEM_MEMPACK]), MemoryRegionSizes[MEM_MEMPACK]); - gMempackDirty = false; + DBGConsole_Msg(0, "MemPack File [C%s] cannot be found.", gMempackFileName.string().c_str()); + InitMempackContent(); + gMempackDirty = true; + } else - { - DBGConsole_Msg(0, "MemPack File [C%s] cannot be found.", gSaveFileName.string().c_str()); - InitMempackContent(); - gMempackDirty = true; + { + DBGConsole_Msg(0, "Loading MemPack from [C%s]", gMempackFileName.string().c_str()); + file.read(static_cast(g_pMemoryBuffers[MEM_MEMPACK]), MemoryRegionSizes[MEM_MEMPACK]); + gMempackDirty = false; + } } - } return true; } void Save_Fini() { + std::cout << "Save Fini called" << std::endl; gSaveDirty = true; gMempackDirty = true; @@ -132,6 +139,7 @@ void Save_Fini() void Save_MarkSaveDirty() { + std::cout << "Save Mark Dirty called" << std::endl; gSaveDirty = true; } @@ -144,12 +152,12 @@ void Save_Flush() { if (gSaveDirty && g_ROM.settings.SaveType != SAVE_TYPE_UNKNOWN) { - DBGConsole_Msg(0, "Saving to [C%s]", gSaveFileName.string().c_str()); - std::fstream fp(gSaveFileName, std::ios::in | std::ios::out | std::ios::binary); + DBGConsole_Msg(0, "Saving to [C%s]", gSaveFileName.string().c_str()); + std::ofstream fp(gSaveFileName, std::ios::binary); if (fp.is_open()) { - std::vector buffer(2048); + u8 buffer[2048]; u8 * src = (u8*)g_pMemoryBuffers[MEM_SAVE]; for (u32 d = 0; d < gSaveSize; d += sizeof(buffer)) @@ -158,20 +166,22 @@ void Save_Flush() { buffer[i^U8_TWIDDLE] = src[d+i]; } - fp.write(reinterpret_cast(buffer.data()), buffer.size()); - // fwrite(buffer, 1, sizeof(buffer), fp); + fp.write(reinterpret_cast(buffer), sizeof(buffer)); } - // fclose(fp); } gSaveDirty = false; } if (gMempackDirty) { + // XXX We could have file generate on write and initiaise if not already done. + DBGConsole_Msg(0, "Saving MemPack to [C%s]", gMempackFileName.string().c_str()); - std::ofstream fp(gMempackFileName, std::ios::in | std::ios::out | std::ios::binary); + std::ofstream fp(gMempackFileName, std::ios::out ); if (fp.is_open()) { + std::cout << "File opened successfully." << std::endl; + std::cout << "Writing " << MemoryRegionSizes[MEM_MEMPACK] << " bytes to the file." << std::endl; fp.write(reinterpret_cast(g_pMemoryBuffers[MEM_MEMPACK]), MemoryRegionSizes[MEM_MEMPACK]); } gMempackDirty = false; @@ -185,7 +195,7 @@ void Save_Flush() // static const u8 gMempackInitialize[] = { - 0x81,0x01,0x02,0x03, 0x04,0x05,0x06,0x07, 0x08,0x09,0x0a,0x0b, 0x0C,0x0D,0x0E,0x0F, + 0x81,0x01,0x02,0x03, 0x04,0x05,0x06,0x07, 0x08,0x09,0x0a,0x0b, 0x0C,0x0D,0x0E,0x0F, 0x10,0x11,0x12,0x13, 0x14,0x15,0x16,0x17, 0x18,0x19,0x1A,0x1B, 0x1C,0x1D,0x1E,0x1F, 0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD, @@ -201,24 +211,24 @@ static const u8 gMempackInitialize[] = 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, - 0x00,0x71,0x00,0x03, 0x00,0x03,0x00,0x03, 0x00,0x03,0x00,0x03, 0x00,0x03,0x00,0x03 + 0x00,0x71,0x00,0x03, 0x00,0x03,0x00,0x03, 0x00,0x03,0x00,0x03, 0x00,0x03,0x00,0x03, }; static void InitMempackContent() { for (size_t dst_off = 0; dst_off < MemoryRegionSizes[MEM_MEMPACK]; dst_off += 32 * 1024) { - u8 * mempack = (u8*)g_pMemoryBuffers[MEM_MEMPACK] + dst_off; - - memcpy(mempack, gMempackInitialize, 272); - - for (u32 i = 272; i < 0x8000; i += 2) + u8 * mempack = static_cast(g_pMemoryBuffers[MEM_MEMPACK]) + dst_off; + for (u32 i = 0; i < 0x8000; i += 2) { - mempack[i] = 0x00; - mempack[i+1] = 0x03; + mempack[i + 0] = 0x00; + mempack[i + 1] = 0x03; } + std::cout << "size of gMempak Initalise: " << sizeof(gMempackInitialize) << std::endl; + memcpy(mempack, gMempackInitialize, sizeof(gMempackInitialize)); + DAEDALUS_ASSERT(dst_off + 0x8000 <= MemoryRegionSizes[MEM_MEMPACK], "Buffer overflow"); DAEDALUS_ASSERT(dst_off + sizeof(gMempackInitialize) <= MemoryRegionSizes[MEM_MEMPACK], "Buffer overflow"); } -} +} \ No newline at end of file diff --git a/Source/Debug/DebugLog.cpp b/Source/Debug/DebugLog.cpp index 9904d7cc..eb9b031a 100644 --- a/Source/Debug/DebugLog.cpp +++ b/Source/Debug/DebugLog.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Debug/Dump.h" #include "Debug/DBGConsole.h" -#include "System/IO.h" + #include #include #include @@ -38,9 +38,8 @@ std::ofstream g_hOutputLog;; bool Debug_InitLogging() { - std::filesystem::path path = baseDir; const std::filesystem::path log_filename = "daedalus.txt"; - path /= log_filename; + std::filesystem::path path = setBasePath(log_filename); std::cout << "Creating Dump File: " << path << std::endl; g_hOutputLog.open( log_filename); // Is always going to return true diff --git a/Source/Debug/Dump.cpp b/Source/Debug/Dump.cpp index af03e722..b4e3fafe 100644 --- a/Source/Debug/Dump.cpp +++ b/Source/Debug/Dump.cpp @@ -38,9 +38,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Debug/DBGConsole.h" #include "OSHLE/patch.h" // For GetCorrectOp #include "Ultra/ultra_R4300.h" -#include "System/IO.h" + #include "Core/PrintOpCode.h" -#include "Base/Path.h" + const std::filesystem::path gDumpDir = "Dumps"; @@ -60,21 +60,6 @@ void Dump_GetDumpDirectory(std::filesystem::path& rootdir, const std::filesystem } -// Fetch the filename, extension, create the output file. -std::filesystem::path Save_As(const std::filesystem::path filename, const std::filesystem::path extension, std::filesystem::path dest) -{ - std::filesystem::create_directories(baseDir/"SaveGames/Cache/"); // Create the Save Directories if not already done - - std::filesystem::path path = baseDir; - - std::filesystem::path file = filename.filename(); - file.replace_extension(extension); - path /= dest; - std::filesystem::path gSaveFileName = path /= file; - return gSaveFileName; - -} - #ifndef DAEDALUS_SILENT //***************************************************************************** // @@ -113,8 +98,9 @@ void Dump_DisassembleMIPSRange(std::ofstream& fh, u32 address_offset, const OpCo void Dump_Disassemble(u32 start, u32 end, const std::filesystem::path& p_file_name) { - std::filesystem::path file_path = baseDir; - file_path /= p_file_name; + + std::filesystem::path file_path = setBasePath(p_file_name); + // Cute hack - if the end of the range is less than the start, // assume it is a length to disassemble if (end < start) @@ -197,9 +183,7 @@ void Dump_RSPDisassemble(const std::filesystem::path& p_file_name) return; } - std::filesystem::path file_path = baseDir; - - file_path /= p_file_name; + std::filesystem::path file_path = setBasePath(p_file_name); DBGConsole_Msg(0, "Disassembling from 0x%08x to 0x%08x ([C%s])", start, end, file_path.string().c_str()); diff --git a/Source/Debug/Synchroniser.cpp b/Source/Debug/Synchroniser.cpp index b171ab6c..dbba1761 100644 --- a/Source/Debug/Synchroniser.cpp +++ b/Source/Debug/Synchroniser.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Debug/DBGConsole.h" #include "Debug/Dump.h" #include "Utility/MathUtil.h" -#include "System/IO.h" + #include "System/CompressedStream.h" diff --git a/Source/DynaRec/FragmentCache.cpp b/Source/DynaRec/FragmentCache.cpp index e2fbc0cd..636b7cd0 100644 --- a/Source/DynaRec/FragmentCache.cpp +++ b/Source/DynaRec/FragmentCache.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "DynaRec/FragmentCache.h" #include "Debug/DBGConsole.h" #include "Utility/Profiler.h" -#include "System/IO.h" + //Define to show hash table statistics cache hit/miss //#define HASH_TABLE_STATS @@ -393,8 +393,9 @@ void CFragmentCache::DumpStats( const std::filesystem::path outputdir ) const std::sort( all_fragments.begin(), all_fragments.end(), SDescendingCyclesSort() ); + std::filesystem::path filename = "fragments.html"; - std::filesystem::path fragments_dir = baseDir /= "fragments"; + std::filesystem::path fragments_dir = setbasePath("fragments"); fragments_dir /= filename; diff --git a/Source/DynaRec/TraceRecorder.cpp b/Source/DynaRec/TraceRecorder.cpp index 3fb5db84..4449e2a6 100644 --- a/Source/DynaRec/TraceRecorder.cpp +++ b/Source/DynaRec/TraceRecorder.cpp @@ -331,8 +331,8 @@ void CTraceRecorder::AbortTrace() if( mTracing ) { #ifdef LOG_ABORTED_TRACES - std::filesystem::path path = baseDir; - path /= "aborted_traces.txt"; + + std::filesystem::path path = setBasePath("aborted_traces.txt"):; std::fstream fh(path); if (fh.is_open()) { diff --git a/Source/HLEGraphics/CachedTexture.cpp b/Source/HLEGraphics/CachedTexture.cpp index af2be861..ff2ffba6 100644 --- a/Source/HLEGraphics/CachedTexture.cpp +++ b/Source/HLEGraphics/CachedTexture.cpp @@ -41,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Utility/MathUtil.h" #include "Ultra/ultra_gbi.h" -#include "System/IO.h" + #include "Utility/Profiler.h" #include diff --git a/Source/HLEGraphics/DLDebug.cpp b/Source/HLEGraphics/DLDebug.cpp index 7b73daf6..34a54523 100644 --- a/Source/HLEGraphics/DLDebug.cpp +++ b/Source/HLEGraphics/DLDebug.cpp @@ -11,7 +11,7 @@ #include "Debug/Dump.h" #include "HLEGraphics/RDP.h" #include "Ultra/ultra_gbi.h" -#include "System/IO.h" + #include "Base/Macros.h" diff --git a/Source/HLEGraphics/DLParser.cpp b/Source/HLEGraphics/DLParser.cpp index 38c9b08e..54cfb7c4 100644 --- a/Source/HLEGraphics/DLParser.cpp +++ b/Source/HLEGraphics/DLParser.cpp @@ -46,7 +46,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Test/BatchTest.h" #include "uCodes/UcodeDefs.h" #include "uCodes/Ucode.h" -#include "System/IO.h" + #include "Utility/Profiler.h" diff --git a/Source/Interface/Preferences.cpp b/Source/Interface/Preferences.cpp index 5112a4cd..91040c18 100644 --- a/Source/Interface/Preferences.cpp +++ b/Source/Interface/Preferences.cpp @@ -36,8 +36,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/ROM.h" #include "Input/InputManager.h" #include "Interface/RomDB.h" -#include "System/IO.h" -#include "Base/Path.h" +#include "Utility/Paths.h" + #include "Utility/Translate.h" @@ -103,9 +103,7 @@ CPreferences::~CPreferences() IPreferences::IPreferences() : mDirty( false ) { - std::filesystem::path ini_filename = baseDir; - ini_filename /= "preferences.ini"; - OpenPreferencesFile( ini_filename ); + OpenPreferencesFile( setBasePath("Preferences.ini")); } IPreferences::~IPreferences() diff --git a/Source/Interface/RomDB.cpp b/Source/Interface/RomDB.cpp index 831d4ca8..3c9251f1 100644 --- a/Source/Interface/RomDB.cpp +++ b/Source/Interface/RomDB.cpp @@ -33,6 +33,7 @@ #include "Utility/MathUtil.h" #include "RomFile/RomFile.h" #include "Utility/Stream.h" +#include "Utility/Paths.h" #include static const u64 ROMDB_MAGIC_NO = 0x42444D5244454144LL; //DAEDRMDB // 44 41 45 44 52 4D 44 42 @@ -166,11 +167,7 @@ template<> bool CSingleton< CRomDB >::Create() { DAEDALUS_ASSERT_Q(mpInstance == nullptr); mpInstance = std::make_shared(); - std::filesystem::path p = baseDir; - p /= "rom.db"; - - /*ret = */mpInstance->OpenDB( p ); - + mpInstance->OpenDB(setBasePath("rom.db")); return true; } diff --git a/Source/Interface/SaveState.h b/Source/Interface/SaveState.h index 7e65c100..ac146497 100644 --- a/Source/Interface/SaveState.h +++ b/Source/Interface/SaveState.h @@ -23,7 +23,7 @@ #ifndef CORE_SAVESTATE_H_ #define CORE_SAVESTATE_H_ -#include "System/IO.h" +#include "Utility/Paths.h" class RomID; diff --git a/Source/OSHLE/patch.cpp b/Source/OSHLE/patch.cpp index 895c36eb..6cb60939 100644 --- a/Source/OSHLE/patch.cpp +++ b/Source/OSHLE/patch.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" - +#include #ifdef DAEDALUS_ENABLE_OS_HOOKS @@ -53,6 +53,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "System/Endian.h" #include "Utility/FastMemcpy.h" #include "Utility/Profiler.h" +#include "Utility/Paths.h" #ifdef DAEDALUS_PSP #include "Graphics/GraphicsContext.h" @@ -63,7 +64,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifdef DUMPOSFUNCTIONS #include "Debug/Dump.h" -#include "System/IO.h" + static const char * const gEventStrings[23] = { @@ -961,9 +962,11 @@ bool Patch_VerifyLocation_CheckSignature(PatchSymbol * ps, static void Patch_FlushCache() { - - std::filesystem::path name = Save_As(g_ROM.mFileName, ".hle", "SaveGames/Cache"); - std::ofstream fp(name, std::ios::binary); + std::filesystem::path path = setBasePath("SaveGames/Cache"); + std::filesystem::path name = g_ROM.mFileName.filename(); + name.replace_extension("hle"); + path /= name; + std::ofstream fp(path, std::ios::binary); if (fp.is_open()) { @@ -1011,8 +1014,12 @@ static void Patch_FlushCache() static bool Patch_GetCache() { + std::filesystem::path name = setBasePath("SaveGames/Cache"); + std::filesystem::path romName = g_ROM.mFileName; + romName.replace_extension(".hle"); + name /= romName; + std::cout << name << std::endl; - std::filesystem::path name = Save_As(g_ROM.mFileName, ".hle", "SaveGames/Cache"); std::fstream fp(name, std::ios::in |std::ios::binary); if(fp.is_open()) diff --git a/Source/RomFile/ROMBuffer.cpp b/Source/RomFile/ROMBuffer.cpp new file mode 100644 index 00000000..9df9a614 --- /dev/null +++ b/Source/RomFile/ROMBuffer.cpp @@ -0,0 +1,515 @@ +/* +Copyright (C) 2006 StrmnNrmn + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + + +#include "Base/Types.h" + +#include "RomFile/ROMBuffer.h" +#include "Core/ROM.h" +#include "Core/DMA.h" +#include "Debug/DBGConsole.h" +#include "Utility/MathUtil.h" +#include "Interface/Preferences.h" +#include "RomFile/RomFile.h" +#include "RomFile/RomFileCache.h" +#include "RomFile/RomFileMemory.h" +#include "Utility/Stream.h" + + +#include + +#ifdef DAEDALUS_PSP +#include "Graphics/GraphicsContext.h" +#ifdef INTRAFONT + #include "intraFont.h" +#endif + +extern bool PSP_IS_SLIM; +#endif + +#ifdef DAEDALUS_CTR +extern bool isN3DS; +#endif + +namespace +{ + bool sRomLoaded = false; + u8 * spRomData = nullptr; + u32 sRomSize [[maybe_unused]] = 0; + bool sRomFixed = false; + bool sRomWritten = false; + u32 sRomValue = 0; + std::shared_ptr spRomFileCache = nullptr; + +#ifdef DAEDALUS_COMPRESSED_ROM_SUPPORT + static bool DECOMPRESS_ROMS = true; +#endif + // Maximum read length is 8 bytes (i.e. double, u64) + const u32 SCRATCH_BUFFER_LENGTH = 16; + u8 sScratchBuffer[ SCRATCH_BUFFER_LENGTH ]; + + bool ShouldLoadAsFixed( u32 rom_size [[maybe_unused]] ) + { +#if defined(DAEDALUS_PSP) + if (PSP_IS_SLIM && !gGlobalPreferences.LargeROMBuffer) + return rom_size <= 32 * 1024 * 1024; + else + return rom_size <= 2 * 1024 * 1024; +#elif defined(DAEDALUS_CTR) + if(isN3DS) + return rom_size < 32 * 1024 * 1024; + else + return rom_size < 8 * 1024 * 1024; +#else + return true; +#endif + } + +#ifdef DAEDALUS_COMPRESSED_ROM_SUPPORT + std::shared_ptr DecompressRom( std::shared_ptr p_rom_file, const std::filesystem::path &temp_filename, COutputStream & messages ) + { + + FILE * fh( fopen( temp_filename.c_str(), "wb" ) ); + auto p_new_file = ROMFile::Create( temp_filename ); + if( fh == nullptr ) + { + messages << "Unable to create temporary rom '" << temp_filename.c_str() << "' for decompression\n"; + } + else + { + bool failed = false; + const u32 TEMP_BUFFER_SIZE = 32 * 1024; + u8 * p_temp_buffer( new u8[ TEMP_BUFFER_SIZE ] ); + +#ifdef DAEDALUS_DEBUG_CONSOLE + CDebugConsole::Get()->MsgOverwriteStart(); +#endif + + u32 offset( 0 ); + u32 total_length( p_rom_file->GetRomSize() ); + u32 length_remaining( total_length ); + + while( length_remaining > 0 ) + { +#ifdef DAEDALUS_DEBUG_CONSOLE + if ((offset % 0x8000) == 0) + { + CDebugConsole::Get()->MsgOverwrite(0, "Converted [M%d / %d] KB", offset /1024, total_length / 1024 ); + } +#endif + u32 length_to_process( std::min( length_remaining, TEMP_BUFFER_SIZE ) ); + + if( !p_rom_file->ReadChunk( offset, p_temp_buffer, length_to_process ) ) + { + failed = true; + break; + } + + if( fwrite( p_temp_buffer, 1, length_to_process, fh ) != length_to_process ) + { + failed = true; + break; + } + + offset += length_to_process; + length_remaining -= length_to_process; + } +#ifdef DAEDALUS_DEBUG_CONSOLE + CDebugConsole::Get()->MsgOverwrite(0, "Converted [M%d / %d] KB", offset /1024, total_length / 1024 ); + CDebugConsole::Get()->MsgOverwriteEnd(); +#endif + + fclose( fh ); + delete [] p_temp_buffer; + + if( failed ) + { + messages << "Failed to decompress rom to '" << temp_filename.c_str() << "' - out of disk space?\n"; + } + else + { + // + // Open the newly created file + // + + if( p_new_file == nullptr ) + { + messages << "Failed to open temporary rom '" << temp_filename.c_str() << "' we just created\n"; + } + else + { + if( !p_new_file->Open( messages ) ) + { + messages << "Failed to open temporary rom '" << temp_filename.c_str() << "' we just created\n"; + p_new_file = nullptr; + } + } + } + } + + return p_new_file; + } +#endif +} + + +bool RomBuffer::Create() +{ + // Create memory heap used for either ROM Cache or ROM buffer + // We do this to avoid memory fragmentation + CROMFileMemory::Create(); + return true; +} + + +void RomBuffer::Destroy() +{ + +} + + +bool RomBuffer::Open() +{ + CNullOutputStream messages; + const std::filesystem::path &filename = g_ROM.mFileName; + auto p_rom_file = ROMFile::Create( filename.c_str() ); + if(p_rom_file == nullptr) + { + DBGConsole_Msg(0, "Failed to create [C%s]\n", filename.string().c_str()); + return false; + } + + if( !p_rom_file->Open( messages ) ) + { + + DBGConsole_Msg(0, "Failed to open [C%s]\n", filename.string().c_str()); + return false; + } + + sRomSize = p_rom_file->GetRomSize(); + + if( ShouldLoadAsFixed( sRomSize ) ) + { + // Now, allocate memory for rom - round up to a 4 byte boundry + u32 size_aligned = AlignPow2( sRomSize, 4 ); + u8 * p_bytes = (u8*)CROMFileMemory::Get()->Alloc( size_aligned ); + +#ifndef DAEDALUS_PSP + if( !p_rom_file->LoadData( sRomSize, p_bytes, messages ) ) + { + #ifdef DAEDALUS_DEBUG_CONSOLE + DBGConsole_Msg(0, "Failed to load [C%s]\n", filename.c_str()); + #endif + CROMFileMemory::Get()->Free( p_bytes ); + return false; + } +#else + u32 offset = 0; + u32 length_remaining( sRomSize ); + const u32 TEMP_BUFFER_SIZE = 128 * 1024; + #ifdef INTRAFONT + intraFont* ltn8 = intraFontLoad( "flash0:/font/ltn8.pgf", INTRAFONT_CACHE_ASCII); + intraFontSetStyle( ltn8, 1.5f, 0xFFFFFFFF, 0, 0.f, INTRAFONT_ALIGN_CENTER ); + #endif + while( offset < sRomSize ) + { + u32 length_to_process( std::min( length_remaining, TEMP_BUFFER_SIZE ) ); + + if( !p_rom_file->ReadChunk( offset, p_bytes + offset, length_to_process ) ) + { + break; + } + + offset += length_to_process; + length_remaining -= length_to_process; + + CGraphicsContext::Get()->BeginFrame(); + CGraphicsContext::Get()->ClearToBlack(); + #ifdef INTRAFONT + intraFontPrintf( ltn8, 480/2, (272>>1), "Buffering ROM %d%%...", offset * 100 / sRomSize ); + #endif + CGraphicsContext::Get()->EndFrame(); + CGraphicsContext::Get()->UpdateFrame( false ); + } + #ifdef INTRAFONT + intraFontUnload( ltn8 ); + #endif +#endif + spRomData = p_bytes; + sRomFixed = true; + + } + else + { +#ifdef DAEDALUS_COMPRESSED_ROM_SUPPORT + if(DECOMPRESS_ROMS) + { + bool compressed( p_rom_file->IsCompressed() ); + bool byteswapped( p_rom_file->RequiresSwapping() ); + if(compressed)// || byteswapped) + { + const char * temp_filename( "daedrom.tmp" ); + + #ifdef DAEDALUS_DEBUG_CONSOLE + if(compressed && byteswapped) + { + DBGConsole_Msg( 0, "Rom is [Mcompressed] and [Mbyteswapped]" ); + } + else if(compressed) + { + DBGConsole_Msg( 0, "Rom is [Mcompressed]" ); + } + else + { + DBGConsole_Msg( 0, "Rom is [Mbyteswapped]" ); + } + DBGConsole_Msg( 0, "Decompressing rom to [C%s] (this may take some time)", temp_filename ); + #endif + CNullOutputStream local_messages; + + auto p_new_file = DecompressRom( p_rom_file, temp_filename, local_messages ); + #ifdef DAEDALUS_DEBUG_CONSOLE + DBGConsole_Msg( 0, "messages:\n%s", local_messages.c_str() ); + #endif + messages << local_messages; + + if(p_new_file != nullptr) + { + #ifdef DAEDALUS_DEBUG_CONSOLE + DBGConsole_Msg( 0, "Decompression [gsuccessful]. Booting using decompressed rom" ); + #endif + p_rom_file = p_new_file; + } + #ifdef DAEDALUS_DEBUG_CONSOLE + else + { + DBGConsole_Msg( 0, "Decompression [rfailed]. Booting using original rom" ); + } + #endif + } + } +#endif + spRomFileCache = std::make_unique(); + spRomFileCache->Open(std::move(p_rom_file )); + sRomFixed = false; + } + + DBGConsole_Msg(0, "Opened [C%s]\n", filename.string().c_str()); + sRomLoaded = true; + return true; +} + + +void RomBuffer::Close() +{ + if (spRomData) + { + CROMFileMemory::Get()->Free( spRomData ); + spRomData = nullptr; + } + + if (spRomFileCache) + { + spRomFileCache->Close(); + } + + sRomSize = 0; + sRomLoaded = false; + sRomFixed = false; + sRomWritten = false; + sRomValue = 0; +} + +bool RomBuffer::IsRomLoaded() { return sRomLoaded; } +u32 RomBuffer::GetRomSize() { return sRomSize; } + +namespace +{ + void CopyBytesRaw( std::shared_ptr p_cache, u8 * p_dst, u32 rom_offset, u32 length ) + { + // Read the cached bytes into our scratch buffer, and return that + u32 dst_offset( 0 ); + u32 src_offset( rom_offset ); + + // Similar algorithm to below - we don't care about byte swapping though + while(length > 0) + { + u8 * p_chunk_base = 0; + u32 chunk_offset = 0; + u32 chunk_size = 0; + + if( !p_cache->GetChunk( src_offset, &p_chunk_base, &chunk_offset, &chunk_size ) ) + { + // Out of range + break; + } + + // Calculate how many bytes we can transfer this pass + u32 offset_into_chunk( src_offset - chunk_offset ); + u32 bytes_remaining_in_chunk( chunk_size - offset_into_chunk ); + u32 bytes_this_pass( std::min( length, bytes_remaining_in_chunk ) ); + + DAEDALUS_ASSERT( s32( bytes_this_pass ) > 0, "How come we're trying to copy <= 0 bytes across?" ); + + // Copy this chunk across + memcpy( p_dst + dst_offset, p_chunk_base + offset_into_chunk, bytes_this_pass ); + + // Update the src/dst pointers and reduce length by the number of copied bytes + dst_offset += bytes_this_pass; + src_offset += bytes_this_pass; + length -= bytes_this_pass; + } + } +} + + +void RomBuffer::GetRomBytesRaw( void * p_dst, u32 rom_start, u32 length ) +{ + if( sRomFixed ) + { + memcpy(p_dst, (const u8*)spRomData + rom_start, length ); + } + else + { + DAEDALUS_ASSERT( spRomFileCache != nullptr, "How come we have no file cache?" ); + + CopyBytesRaw( spRomFileCache, reinterpret_cast< u8 * >( p_dst ), rom_start, length ); + } +} + + +void RomBuffer::SaveRomValue( u32 value ) +{ + sRomWritten = true; + sRomValue = value; +} + + +void RomBuffer::PutRomBytesRaw( u32 rom_start, const void * p_src, u32 length ) +{ + DAEDALUS_ASSERT( sRomFixed, "Cannot put rom bytes when the data isn't fixed" ); + memcpy( (u8*)spRomData + rom_start, p_src, length ); +} + + +void * RomBuffer::GetAddressRaw( u32 rom_start ) +{ + if (sRomWritten) + { + sRomWritten = false; + + return (u8 *)&sRomValue; + } + + if( rom_start < sRomSize ) + { + if( sRomFixed ) + { + return (u8 *)spRomData + rom_start; + } + else + { + // Read the cached bytes into our scratch buffer, and return that + DAEDALUS_ASSERT( spRomFileCache != nullptr, "How come we have no file cache?" ); + CopyBytesRaw( spRomFileCache, sScratchBuffer, rom_start, SCRATCH_BUFFER_LENGTH ); + + return sScratchBuffer; + } + } + + return nullptr; +} + + +bool RomBuffer::CopyToRam( u8 * p_dst, u32 dst_offset, u32 dst_size, u32 src_offset, u32 length ) +{ + if( sRomFixed ) + { + const u8* p_src = (const u8 *)spRomData ; + u32 src_size = sRomSize; + + return DMA_HandleTransfer( p_dst, dst_offset, dst_size, p_src, src_offset, src_size, length ); + } + else + { + while(length > 0) + { + u8 * p_chunk_base = 0; + u32 chunk_offset = 0; + u32 chunk_size = 0; + + if( !spRomFileCache->GetChunk( src_offset, &p_chunk_base, &chunk_offset, &chunk_size ) ) + { + // Out of range + break; + } + + // Calculate how many bytes we can transfer this pass + u32 offset_into_chunk( src_offset - chunk_offset ); + u32 bytes_remaining_in_chunk( chunk_size - offset_into_chunk ); + u32 bytes_this_pass( std::min( length, bytes_remaining_in_chunk ) ); + + DAEDALUS_ASSERT( s32( bytes_this_pass ) > 0, "How come we're trying to copy <= 0 bytes across?" ); + + // Copy this chunk across + if( !DMA_HandleTransfer( p_dst, dst_offset, dst_size, p_chunk_base, offset_into_chunk, chunk_size, bytes_this_pass ) ) + { + break; + } + + // Update the src/dst pointers and reduce length by the number of copied bytes + dst_offset += bytes_this_pass; + src_offset += bytes_this_pass; + length -= bytes_this_pass; + } + return length == 0; + } +} + + +bool RomBuffer::CopyFromRam( u32 dst_offset, const u8 * p_src, u32 src_offset, u32 src_size, u32 length ) +{ + if( sRomFixed ) + { + u8 * p_dst = (u8 *)spRomData; + u32 dst_size = sRomSize; + + return DMA_HandleTransfer( p_dst, dst_offset, dst_size, p_src, src_offset, src_size, length ); + } + else + { + DAEDALUS_ERROR( "Cannot put rom bytes when the data isn't fixed" ); + return false; + } +} + + +bool RomBuffer::IsRomAddressFixed() +{ + return sRomFixed; +} + + +const void * RomBuffer::GetFixedRomBaseAddress() +{ + DAEDALUS_ASSERT( sRomLoaded, "The rom isn't loaded" ); + DAEDALUS_ASSERT( sRomFixed, "Trying to access the rom base address when it's not fixed" ); + + return spRomData; +} diff --git a/Source/RomFile/RomFile.cpp b/Source/RomFile/RomFile.cpp index 1b48b9b0..02aaf6fc 100644 --- a/Source/RomFile/RomFile.cpp +++ b/Source/RomFile/RomFile.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "RomFile/RomFileCompressed.h" #include "RomFile/RomFileUncompressed.h" #include "Utility/Stream.h" -#include "System/IO.h" + #include #include diff --git a/Source/RomFile/RomFile.h b/Source/RomFile/RomFile.h index 9b82157f..bb620647 100644 --- a/Source/RomFile/RomFile.h +++ b/Source/RomFile/RomFile.h @@ -22,8 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef UTILITY_ROMFILE_H_ #define UTILITY_ROMFILE_H_ -#include "System/IO.h" + #include +#include "Utility/Paths.h" class COutputStream; diff --git a/Source/RomFile/RomFileCompressed.cpp b/Source/RomFile/RomFileCompressed.cpp index 1544c7bb..f2f290fc 100644 --- a/Source/RomFile/RomFileCompressed.cpp +++ b/Source/RomFile/RomFileCompressed.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Debug/DBGConsole.h" -#include "System/IO.h" + #include "Base/Macros.h" #include "Utility/Stream.h" //***************************************************************************** diff --git a/Source/RomFile/RomSettings.cpp b/Source/RomFile/RomSettings.cpp new file mode 100644 index 00000000..323ef5aa --- /dev/null +++ b/Source/RomFile/RomSettings.cpp @@ -0,0 +1,516 @@ +/* +Copyright (C) 2001 CyRUS64 (http://www.boob.co.uk) +Copyright (C) 2006,2007 StrmnNrmn + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + + +#include "Base/Types.h" + + +#include + +#include +#include +#include +#include +#include + +#include "Core/ROM.h" +#include "RomFile/RomSettings.h" +#include "Debug/DBGConsole.h" +#include "Interface/RomDB.h" +#include "Utility/IniFile.h" + + +namespace +{ +// + +EExpansionPakUsage ExpansionPakUsageFromString( const char * str ) +{ + for( u32 i = 0; i < NUM_EXPANSIONPAK_USAGE_TYPES; ++i ) + { + EExpansionPakUsage pak_usage = EExpansionPakUsage( i ); + + if( strcasecmp( str, ROM_GetExpansionPakUsageName( pak_usage ) ) == 0 ) + { + return pak_usage; + } + } + + return PAK_STATUS_UNKNOWN; +} + +ESaveType SaveTypeFromString( const char * str ) +{ + for( u32 i = 0; i < NUM_SAVE_TYPES; ++i ) + { + ESaveType save_type = ESaveType( i ); + + if( strcasecmp( str, ROM_GetSaveTypeName( save_type ) ) == 0 ) + { + return save_type; + } + } + + return SAVE_TYPE_UNKNOWN; +} + +} + + +// + +const char * ROM_GetExpansionPakUsageName( EExpansionPakUsage pak_usage ) +{ + switch( pak_usage ) + { + case PAK_STATUS_UNKNOWN: return "Unknown"; + case PAK_UNUSED: return "Unused"; + case PAK_USED: return "Used"; + case PAK_REQUIRED: return "Required"; + } + +#ifdef DAEDALUS_DEBUG_CONSOLE + DAEDALUS_ERROR( "Unknown expansion pak type" ); + #endif + return "?"; +} + + +// Get the name of a save type from an ESaveType enum + +const char * ROM_GetSaveTypeName( ESaveType save_type ) +{ + switch ( save_type ) + { + case SAVE_TYPE_UNKNOWN: return "Unknown"; + case SAVE_TYPE_EEP4K: return "Eeprom4k"; + case SAVE_TYPE_EEP16K: return "Eeprom16k"; + case SAVE_TYPE_SRAM: return "SRAM"; + case SAVE_TYPE_FLASH: return "FlashRam"; + } +#ifdef DAEDALUS_DEBUG_CONSOLE + DAEDALUS_ERROR( "Unknown save type" ); + #endif + return "?"; +} + + +// + +class IRomSettingsDB : public CRomSettingsDB +{ + public: + IRomSettingsDB(); + virtual ~IRomSettingsDB(); + + // + // CRomSettingsDB implementation + // + bool OpenSettingsFile( const std::filesystem::path &filename ); + void Commit(); // (STRMNNRMN - Write ini back out to disk?) + + bool GetSettings( const RomID & id, RomSettings * p_settings ) const; + void SetSettings( const RomID & id, const RomSettings & settings ); + + private: + + void OutputSectionDetails( const RomID & id, const RomSettings & settings, std::ostream &fh ); + + private: + using SettingsMap = std::map; + SettingsMap mSettings; + + bool mDirty; // (STRMNNRMN - Changed since read from disk?) + const std::filesystem::path mFilename; +}; + + + + +// Singleton creator + +template<> bool CSingleton< CRomSettingsDB >::Create() +{ + #ifdef DAEDALUS_ENABLE_ASSERTS + DAEDALUS_ASSERT_Q(mpInstance == nullptr); + #endif + mpInstance = std::make_shared(); + + mpInstance->OpenSettingsFile( setBasePath("roms.ini") ); + + return true; +} + + +IRomSettingsDB::IRomSettingsDB() : mDirty( false ) {} + + +IRomSettingsDB::~IRomSettingsDB() +{ + // if ( mDirty ) + // { + // Commit(); + // } +} + + +// Remove the specified characters from p_string +static bool trim( char * p_string, const char * p_trim_chars ) +{ + u32 num_trims = (u32)strlen( p_trim_chars ); + char * pin = p_string; + char * pout = p_string; + bool found = false; + while ( *pin ) + { + char c = *pin; + + found = false; + for ( u32 i = 0; i < num_trims; i++ ) + { + if ( p_trim_chars[ i ] == c ) + { + // Skip + found = true; + break; + } + } + + if ( found ) + { + pin++; + } + else + { + // Copy + *pout++ = *pin++; + } + } + *pout = '\0'; + return true; +} + + +// + +static RomID RomIDFromString( const char * str ) +{ + u32 crc1, crc2, country; + sscanf( str, "%08x%08x-%02x", &crc1, &crc2, &country ); + return RomID( crc1, crc2, (u8)country ); +} + +bool IRomSettingsDB::OpenSettingsFile( const std::filesystem::path &filename ) +{ + + std::filesystem::path mFilename = setBasePath(filename); + + auto p_ini_file = CIniFile::Create(filename); + if( p_ini_file == nullptr ) + { + DBGConsole_Msg( 0, "Failed to open roms.ini from %s\n", filename.c_str() ); + return false; + } + + for( u32 section_idx = 0; section_idx < p_ini_file->GetNumSections(); ++section_idx ) + { + const CIniFileSection * p_section( p_ini_file->GetSection( section_idx ) ); + + RomID id( RomIDFromString( p_section->GetName() ) ); + RomSettings settings; + + const CIniFileProperty * p_property; + if( p_section->FindProperty( "Comment", &p_property ) ) + { + settings.Comment = p_property->GetValue(); + } + if( p_section->FindProperty( "Info", &p_property ) ) + { + settings.Info = p_property->GetValue(); + } + if( p_section->FindProperty( "Name", &p_property ) ) + { + settings.GameName = p_property->GetValue(); + } + if( p_section->FindProperty( "Preview", &p_property ) ) + { + settings.Preview = p_property->GetValue(); + } + if( p_section->FindProperty( "ExpansionPakUsage", &p_property ) ) + { + settings.ExpansionPakUsage = ExpansionPakUsageFromString( p_property->GetValue() ); + } + if( p_section->FindProperty( "SaveType", &p_property ) ) + { + settings.SaveType = SaveTypeFromString( p_property->GetValue() ); + } + if( p_section->FindProperty( "PatchesEnabled", &p_property ) ) + { + settings.PatchesEnabled = p_property->GetBooleanValue( true ); + } + if( p_section->FindProperty( "SpeedSyncEnabled", &p_property ) ) + { + settings.SpeedSyncEnabled = atoi( p_property->GetValue() ); + } + if( p_section->FindProperty( "DynarecSupported", &p_property ) ) + { + settings.DynarecSupported = p_property->GetBooleanValue( true ); + } + if( p_section->FindProperty( "DynarecLoopOptimisation", &p_property ) ) + { + settings.DynarecLoopOptimisation = p_property->GetBooleanValue( false ); + } + if( p_section->FindProperty( "DynarecDoublesOptimisation", &p_property ) ) + { + settings.DynarecDoublesOptimisation = p_property->GetBooleanValue( false ); + } + if( p_section->FindProperty( "DoubleDisplayEnabled", &p_property ) ) + { + settings.DoubleDisplayEnabled = p_property->GetBooleanValue( true ); + } + if( p_section->FindProperty( "CleanSceneEnabled", &p_property ) ) + { + settings.CleanSceneEnabled = p_property->GetBooleanValue( false ); + } + if( p_section->FindProperty( "ClearDepthFrameBuffer", &p_property ) ) + { + settings.ClearDepthFrameBuffer = p_property->GetBooleanValue( false ); + } + if( p_section->FindProperty( "AudioRateMatch", &p_property ) ) + { + settings.AudioRateMatch = p_property->GetBooleanValue( false ); + } + if( p_section->FindProperty( "VideoRateMatch", &p_property ) ) + { + settings.VideoRateMatch = p_property->GetBooleanValue( false ); + } + if( p_section->FindProperty( "FogEnabled", &p_property ) ) + { + settings.FogEnabled = p_property->GetBooleanValue( false ); + } + if( p_section->FindProperty( "MemoryAccessOptimisation", &p_property ) ) + { + settings.MemoryAccessOptimisation = p_property->GetBooleanValue( false ); + } + if( p_section->FindProperty( "CheatsEnabled", &p_property ) ) + { + settings.CheatsEnabled = p_property->GetBooleanValue( false ); + } + SetSettings( id, settings ); + } + + mDirty = false; + + return true; +} + +// // Write out the .ini file, keeping the original comments intact +void IRomSettingsDB::Commit(){} +// mFilename = "roms.ini"; + + +// std::filesystem::path filename_tmp = "roms.ini.tmp"; + +// std::fstream fh_src(mFilename, std::ios::in); +// if (!fh_src) +// { +// std::cerr << mFilename << " : Does not exist"; +// return; +// } +// std::fstream fh_dst(filename_tmp, std::ios::out); + + +// // Keep track of visited sections in a set +// std::set visited; + +// std::string line; +// while (std::getline(fh_src, line)) +// { +// if (line[0] == '{') +// { +// const char * const trim_chars = "{}\n\r"; //remove first and last character +// char buffer[1024 + 1]; +// std::strncpy(buffer, line.c_str(), sizeof(buffer) -1); +// buffer[sizeof(buffer) - 1 ] = '\0'; + +// // Start of section +// trim( buffer, trim_chars ); + +// RomID id( RomIDFromString( buffer ) ); + +// // Avoid duplicated entries for this id +// if ( visited.find( id ) != visited.end() ) +// continue; + +// visited.insert( id ); + +// SettingsMap::const_iterator it( mSettings.find( id ) ); +// if( it != mSettings.end() ) +// { +// // Output this CRC +// OutputSectionDetails( id, it->second, fh_dst ); +// } +// else +// { +// // Do what? This should never happen, unless the user +// // replaces the inifile while Daedalus is running! +// } +// } +// else if (line[0] == '/') +// { +// // Skip Comment +// fh_dst << line << '\n'; +// continue; +// } +// } +// for (const auto& [id, settings] : mSettings) +// { +// // Skip any that have not been done. +// if ( visited.find( id) == visited.end() ) +// { +// OutputSectionDetails( id, settings, fh_dst ); +// } +// } + + +// // Create the new file +// std::filesystem::remove(mFilename); +// std::filesystem::rename(filename_tmp, mFilename); + +// mDirty = false; + +// } + + +void IRomSettingsDB::OutputSectionDetails( const RomID & id, const RomSettings & settings, std::ostream &out ) +{ + // Generate the CRC-ID for this rom + out << "{" << std::hex << std::uppercase << id.CRC[0] << std::hex << std::uppercase << id.CRC[1] << "-" + << std::dec << std::setfill('0') << std::setw(2) << id.CountryID << "}\n"; + + out << "Name=" << settings.GameName << "\n"; + + if (!settings.Comment.empty()) out << "Comment=" << settings.Comment << "\n"; + if (!settings.Info.empty()) out << "Info=" << settings.Info << "\n"; + if (!settings.Preview.empty()) out << "Preview=" << settings.Preview << "\n"; + if (!settings.PatchesEnabled) out << "PatchesEnabled=no\n"; + if (!settings.SpeedSyncEnabled) out << "SpeedSyncEnabled=" << settings.SpeedSyncEnabled << "\n"; + if (!settings.DynarecSupported) out << "DynarecSupported=no\n"; + if (settings.DynarecLoopOptimisation) out << "DynarecLoopOptimisation=yes\n"; + if (settings.DynarecDoublesOptimisation) out << "DynarecDoublesOptimisation=yes\n"; + if (!settings.DoubleDisplayEnabled) out << "DoubleDisplayEnabled=no\n"; + if (settings.CleanSceneEnabled) out << "CleanSceneEnabled=yes\n"; + if (settings.ClearDepthFrameBuffer) out << "ClearDepthFrameBuffer=yes\n"; + if (settings.AudioRateMatch) out << "AudioRateMatch=yes\n"; + if (settings.VideoRateMatch) out << "VideoRateMatch=yes\n"; + if (settings.FogEnabled) out << "FogEnabled=yes\n"; + if (settings.MemoryAccessOptimisation) out << "MemoryAccessOptimisation=yes\n"; + if (settings.CheatsEnabled) out << "CheatsEnabled=yes\n"; + + if (settings.ExpansionPakUsage != PAK_STATUS_UNKNOWN) + out << "ExpansionPakUsage=" << ROM_GetExpansionPakUsageName(settings.ExpansionPakUsage) << "\n"; + if (settings.SaveType != SAVE_TYPE_UNKNOWN) + out << "SaveType=" << ROM_GetSaveTypeName(settings.SaveType) << "\n"; + + out << "\n"; // Spacer +} + + +// Retreive the settings for the specified rom. Returns false if the rom is +// not in the database +bool IRomSettingsDB::GetSettings( const RomID & id, RomSettings * p_settings ) const +{ + for ( SettingsMap::const_iterator it = mSettings.begin(); it != mSettings.end(); ++it ) + { + if ( it->first == id ) + { + *p_settings = it->second; + return true; + } + } + + return false; +} + + +// Update the settings for the specified rom - creates a new entry if necessary +void IRomSettingsDB::SetSettings( const RomID & id, const RomSettings & settings ) +{ + for ( SettingsMap::iterator it = mSettings.begin(); it != mSettings.end(); ++it ) + { + if ( it->first == id ) + { + it->second = settings; + return; + } + } + + mSettings[id] = settings; + mDirty = true; +} + + +// + +RomSettings::RomSettings() +: ExpansionPakUsage( PAK_STATUS_UNKNOWN ) +, SaveType( SAVE_TYPE_UNKNOWN ) +, PatchesEnabled( true ) +, SpeedSyncEnabled( 1 ) +, DynarecSupported( true ) +, DynarecLoopOptimisation( false ) +, DynarecDoublesOptimisation( false ) +, DoubleDisplayEnabled( true ) +, CleanSceneEnabled( false ) +, ClearDepthFrameBuffer( false ) +, AudioRateMatch( false ) +, VideoRateMatch( false ) +, FogEnabled( false ) +, MemoryAccessOptimisation( false ) +, CheatsEnabled( false ) +{ +} + + +// + +RomSettings::~RomSettings() {} + +void RomSettings::Reset() +{ + GameName = ""; + Comment = ""; + Info = ""; + ExpansionPakUsage = PAK_STATUS_UNKNOWN; + SaveType = SAVE_TYPE_UNKNOWN; + PatchesEnabled = true; + SpeedSyncEnabled = 0; + DynarecSupported = true; + DynarecLoopOptimisation = false; + DynarecDoublesOptimisation = false; + DoubleDisplayEnabled = true; + CleanSceneEnabled = false; + ClearDepthFrameBuffer = false; + AudioRateMatch = false; + VideoRateMatch = false; + FogEnabled = false; + CheatsEnabled = false; + MemoryAccessOptimisation = false; +} diff --git a/Source/SysCTR/Graphics/GraphicsContextCTR.cpp b/Source/SysCTR/Graphics/GraphicsContextCTR.cpp index f868cc89..88d84bb4 100644 --- a/Source/SysCTR/Graphics/GraphicsContextCTR.cpp +++ b/Source/SysCTR/Graphics/GraphicsContextCTR.cpp @@ -10,7 +10,7 @@ #include "Debug/Dump.h" #include "Graphics/ColourValue.h" #include "Graphics/PngUtil.h" -#include "System/IO.h" + #include "Interface/Preferences.h" #include "Utility/Profiler.h" diff --git a/Source/SysCTR/HLEGraphics/RendererCTR.cpp b/Source/SysCTR/HLEGraphics/RendererCTR.cpp index 6739b30d..f8d5e884 100644 --- a/Source/SysCTR/HLEGraphics/RendererCTR.cpp +++ b/Source/SysCTR/HLEGraphics/RendererCTR.cpp @@ -16,7 +16,7 @@ #include "HLEGraphics/TextureCache.h" #include "Utility/MathUtil.h" #include "Ultra/ultra_gbi.h" -#include "System/IO.h" + #include "Utility/Profiler.h" BaseRenderer *gRenderer = nullptr; diff --git a/Source/SysCTR/Input/InputManagerCTR.cpp b/Source/SysCTR/Input/InputManagerCTR.cpp index eac1c4d8..7f319b03 100644 --- a/Source/SysCTR/Input/InputManagerCTR.cpp +++ b/Source/SysCTR/Input/InputManagerCTR.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Math/Math.h" #include "Utility/MathUtil.h" #include "Utility/IniFile.h" -#include "System/IO.h" + #include "Base/Macros.h" #include "Interface/Preferences.h" #include "Utility/Stream.h" diff --git a/Source/SysCTR/UI/InGameMenu.cpp b/Source/SysCTR/UI/InGameMenu.cpp index fe42f664..d0aefc41 100644 --- a/Source/SysCTR/UI/InGameMenu.cpp +++ b/Source/SysCTR/UI/InGameMenu.cpp @@ -22,7 +22,7 @@ #include "Interface/RomDB.h" #include "System/SystemInit.h" #include "Test/BatchTest.h" -#include "System/IO.h" + #include "Interface/Preferences.h" #include "Utility/Profiler.h" #include "System/Thread.h" diff --git a/Source/SysCTR/UI/RomSelector.cpp b/Source/SysCTR/UI/RomSelector.cpp index 3463ca5d..d4e50b31 100644 --- a/Source/SysCTR/UI/RomSelector.cpp +++ b/Source/SysCTR/UI/RomSelector.cpp @@ -17,8 +17,8 @@ #include "Core/Save.h" #include "Interface/RomDB.h" #include "System/SystemInit.h" -#include "Base/Path.h" -#include "System/IO.h" + + #include "Interface/Preferences.h" #include "RomFile/RomFile.h" diff --git a/Source/SysCTR/main.cpp b/Source/SysCTR/main.cpp index 17b31d14..40177b32 100644 --- a/Source/SysCTR/main.cpp +++ b/Source/SysCTR/main.cpp @@ -28,11 +28,11 @@ #include "UI/UserInterface.h" #include "UI/RomSelector.h" -#include "System/IO.h" + #include "Interface/Preferences.h" #include "Utility/Profiler.h" #include "System/Thread.h" -#include "Base/Path.h" + #include "Utility/Timer.h" #include "RomFile/RomFile.h" @@ -136,8 +136,8 @@ int main(int argc, char* argv[]) // Set the default path std::string rom = UI::DrawRomSelector(); - std::filesystem::path RomPath = baseDir / "Roms" / std::string(rom); - + std::filesystem::path RomPath = setBasePath("Roms"); + RomPath /= rom; System_Open(RomPath.string().c_str()); CPU_Run(); System_Close(); diff --git a/Source/SysGL/HLEGraphics/RendererGL.cpp b/Source/SysGL/HLEGraphics/RendererGL.cpp index 7a4db310..8b4d6d92 100644 --- a/Source/SysGL/HLEGraphics/RendererGL.cpp +++ b/Source/SysGL/HLEGraphics/RendererGL.cpp @@ -18,8 +18,9 @@ #include "SysGL/GL.h" #include "SysGL/HLEGraphics/RendererGL.h" -#include "System/IO.h" + #include "Base/Macros.h" +#include "Utility/Paths.h" #include "Utility/Profiler.h" BaseRenderer * gRenderer = NULL; @@ -114,14 +115,10 @@ bool loadShader(const std::filesystem::path& shader_path) bool initgl() { - std::filesystem::path p = baseDir; - std::filesystem::path shader_path = "n64.psh"; - p /= shader_path; - + std::filesystem::path p = setBasePath("n64.psh"); loadShader(p); - std::cout << "Loading Shader File: " << p << std::endl; // Only do software emulation of mirror_s/mirror_t if we're not doing accurate UV handling gRDPStateManager.SetEmulateMirror(!gAccurateUVPipe); diff --git a/Source/SysPSP/Graphics/GraphicsContextPSP.cpp b/Source/SysPSP/Graphics/GraphicsContextPSP.cpp index 8a833c8a..9ff05fd9 100644 --- a/Source/SysPSP/Graphics/GraphicsContextPSP.cpp +++ b/Source/SysPSP/Graphics/GraphicsContextPSP.cpp @@ -34,7 +34,7 @@ #include "Graphics/GraphicsContext.h" #include "Graphics/PngUtil.h" #include "SysPSP/Graphics/VideoMemoryManager.h" -#include "System/IO.h" + #include "UI/DrawText.h" #include "Interface/Preferences.h" #include "Utility/Profiler.h" diff --git a/Source/SysPSP/HLEGraphics/DisplayListDebugger.cpp b/Source/SysPSP/HLEGraphics/DisplayListDebugger.cpp index 33d8ed1c..252397fc 100644 --- a/Source/SysPSP/HLEGraphics/DisplayListDebugger.cpp +++ b/Source/SysPSP/HLEGraphics/DisplayListDebugger.cpp @@ -40,7 +40,7 @@ #include "Core/ROM.h" #include "Debug/Dump.h" -#include "System/IO.h" + #include "Interface/Preferences.h" #include "Utility/Timer.h" #include "System/Timing.h" diff --git a/Source/SysPSP/HLEGraphics/RendererPSP.cpp b/Source/SysPSP/HLEGraphics/RendererPSP.cpp index 858852a8..758b8422 100644 --- a/Source/SysPSP/HLEGraphics/RendererPSP.cpp +++ b/Source/SysPSP/HLEGraphics/RendererPSP.cpp @@ -17,7 +17,7 @@ #include "Utility/MathUtil.h" #include "SysPSP/HLEGraphics/RendererPSP.h" #include "Ultra/ultra_gbi.h" -#include "System/IO.h" + #include "Utility/Profiler.h" diff --git a/Source/SysPSP/Input/InputManagerPSP.cpp b/Source/SysPSP/Input/InputManagerPSP.cpp index 7b581765..558c8b9c 100644 --- a/Source/SysPSP/Input/InputManagerPSP.cpp +++ b/Source/SysPSP/Input/InputManagerPSP.cpp @@ -16,7 +16,7 @@ #include "Utility/MathUtil.h" #include "Utility/IniFile.h" -#include "System/IO.h" + #include "Base/Macros.h" #include "Interface/Preferences.h" #include "Utility/Stream.h" diff --git a/Source/SysPSP/Utility/CMakeLists.txt b/Source/SysPSP/Utility/CMakeLists.txt index 23fb8b2a..cc12c539 100644 --- a/Source/SysPSP/Utility/CMakeLists.txt +++ b/Source/SysPSP/Utility/CMakeLists.txt @@ -9,7 +9,7 @@ add_library(Utility_PSP OBJECT VolatileMemPSP.cpp ${PROJECT_SOURCE_DIR}/Source/SysPosix/Utility/TimingPosix.cpp ${PROJECT_SOURCE_DIR}/Source/SysPosix/Utility/ThreadPosix.cpp - ${PROJECT_SOURCE_DIR}/Source/SysPosix/Utility/IOPosix.cpp + # ${PROJECT_SOURCE_DIR}/Source/SysPosix/Utility/IOPosix.cpp ) diff --git a/Source/SysPSP/main.cpp b/Source/SysPSP/main.cpp index 6226fdf7..e76e9b91 100644 --- a/Source/SysPSP/main.cpp +++ b/Source/SysPSP/main.cpp @@ -61,7 +61,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "System/SystemInit.h" #include "Test/BatchTest.h" -#include "System/IO.h" + #include "Utility/ModulePSP.h" #include "Interface/Preferences.h" #include "Utility/Profiler.h" diff --git a/Source/SysPosix/Debug/WebDebug.cpp b/Source/SysPosix/Debug/WebDebug.cpp index f4055ddc..9afb481d 100644 --- a/Source/SysPosix/Debug/WebDebug.cpp +++ b/Source/SysPosix/Debug/WebDebug.cpp @@ -22,7 +22,7 @@ #include "Debug/DBGConsole.h" #include "Utility/MathUtil.h" -#include "System/IO.h" + #include "Base/Macros.h" #include "Utility/StringUtil.h" #include "System/Thread.h" diff --git a/Source/SysPosix/Utility/CMakeLists.txt b/Source/SysPosix/Utility/CMakeLists.txt index 5570d1c5..7c76e026 100644 --- a/Source/SysPosix/Utility/CMakeLists.txt +++ b/Source/SysPosix/Utility/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(Utility_POSIX OBJECT CondPosix.cpp - IOPosix.cpp + # IOPosix.cpp ThreadPosix.cpp TimingPosix.cpp ) diff --git a/Source/SysPosix/main.cpp b/Source/SysPosix/main.cpp index 810dc15b..88f3fcfd 100644 --- a/Source/SysPosix/main.cpp +++ b/Source/SysPosix/main.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Interface/RomDB.h" #include "System/SystemInit.h" #include "Test/BatchTest.h" -#include "System/IO.h" + #include "Config/ConfigOptions.h" #include "Interface/Preferences.h" #include "Utility/Translate.h" diff --git a/Source/System/CompressedStream.h b/Source/System/CompressedStream.h index 3462a634..3fadf77b 100644 --- a/Source/System/CompressedStream.h +++ b/Source/System/CompressedStream.h @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef UTILITY_ZLIBWRAPPER_H_ #define UTILITY_ZLIBWRAPPER_H_ -#include "System/IO.h" +#include "Utility/Paths.h" // // A buffered output stream diff --git a/Source/System/DataSink.h b/Source/System/DataSink.h index a2c120b0..b10b52c5 100644 --- a/Source/System/DataSink.h +++ b/Source/System/DataSink.h @@ -2,7 +2,7 @@ #define UTILITY_DATASINK_H_ #include -#include "System/IO.h" +#include "Utility/Paths.h" class DataSink { public: diff --git a/Source/System/IO.h b/Source/System/IO.h index 201c33b0..f5138e9c 100644 --- a/Source/System/IO.h +++ b/Source/System/IO.h @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -extern const std::filesystem::path baseDir; namespace IO { namespace Path diff --git a/Source/Test/BatchTest.cpp b/Source/Test/BatchTest.cpp index da0b2cf6..099cb06a 100644 --- a/Source/Test/BatchTest.cpp +++ b/Source/Test/BatchTest.cpp @@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "System/SystemInit.h" #include "Test/BatchTest.h" #include "Utility/Hash.h" -#include "System/IO.h" + #include "RomFile/RomFile.h" #include "Utility/Timer.h" #include "System/Timing.h" diff --git a/Source/UI/CheatOptionsScreen.cpp b/Source/UI/CheatOptionsScreen.cpp index 5ba94a9a..eb9c2436 100644 --- a/Source/UI/CheatOptionsScreen.cpp +++ b/Source/UI/CheatOptionsScreen.cpp @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Graphics/ColourValue.h" #include "Input/InputManager.h" #include "DrawTextUtilities.h" -#include "System/IO.h" + #include "Interface/Preferences.h" #include "Utility/Stream.h" diff --git a/Source/UI/GlobalSettingsComponent.cpp b/Source/UI/GlobalSettingsComponent.cpp index 9b49a0c3..4b2b6f5b 100644 --- a/Source/UI/GlobalSettingsComponent.cpp +++ b/Source/UI/GlobalSettingsComponent.cpp @@ -38,7 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "System/Thread.h" #include "Core/FramerateLimiter.h" #include "Interface/Preferences.h" -#include "System/IO.h" + #include "Utility/Translate.h" #include "Input/InputManager.h" diff --git a/Source/UI/PauseOptionsComponent.cpp b/Source/UI/PauseOptionsComponent.cpp index cdf39274..841ddd92 100644 --- a/Source/UI/PauseOptionsComponent.cpp +++ b/Source/UI/PauseOptionsComponent.cpp @@ -41,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "UISetting.h" #include "UICommand.h" #include "UISpacer.h" -#include "System/IO.h" + #include diff --git a/Source/UI/RomSelectorComponent.cpp b/Source/UI/RomSelectorComponent.cpp index 9f1e723a..9e0ce5b6 100644 --- a/Source/UI/RomSelectorComponent.cpp +++ b/Source/UI/RomSelectorComponent.cpp @@ -42,7 +42,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "UIScreen.h" -#include "System/IO.h" + #include "Interface/Preferences.h" #include "RomFile/RomFile.h" diff --git a/Source/UI/SavestateSelectorComponent.cpp b/Source/UI/SavestateSelectorComponent.cpp index ede0f04f..6c7f2d12 100644 --- a/Source/UI/SavestateSelectorComponent.cpp +++ b/Source/UI/SavestateSelectorComponent.cpp @@ -38,7 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "UIScreen.h" #include "Menu.h" #include "SavestateSelectorComponent.h" -#include "System/IO.h" +#include "Utility/Paths.h" #include "Utility/Stream.h" #include "Utility/Translate.h" @@ -103,9 +103,9 @@ namespace void MakeSaveSlotPath(std::filesystem::path& path, std::filesystem::path& png_path, u32 slot_idx, const std::filesystem::path& slot_path) { //XXXX Todo Add support for alternative directories - std::filesystem::create_directory("SaveStates"); - std::filesystem::path save_directory = "SaveStates"; + std::filesystem::path save_directory = setBasePath("SaveStates"); std::filesystem::path full_directory = save_directory / slot_path; + std::filesystem::create_directory(full_directory); std::string filename_png = std::format("saveslot{}.ss.png", slot_idx); std::string filename_ss = std::format("saveslot{}.ss", slot_idx); diff --git a/Source/Utility/CMakeLists.txt b/Source/Utility/CMakeLists.txt index 54a12166..8ee3fa9b 100644 --- a/Source/Utility/CMakeLists.txt +++ b/Source/Utility/CMakeLists.txt @@ -4,6 +4,7 @@ add_library(Utility OBJECT Hash.cpp IniFile.cpp MemoryHeap.cpp + Paths.cpp Profiler.cpp Stream.cpp StringUtil.cpp diff --git a/Source/Utility/IniFile.h b/Source/Utility/IniFile.h index c607c6c7..038a1067 100644 --- a/Source/Utility/IniFile.h +++ b/Source/Utility/IniFile.h @@ -24,7 +24,7 @@ #define UTILITY_INIFILE_H_ #include "Base/Types.h" -#include "System/IO.h" +#include "Utility/Paths.h" //***************************************************************************** // diff --git a/Source/SysPosix/Utility/IOPosix.cpp b/Source/Utility/Paths.cpp similarity index 66% rename from Source/SysPosix/Utility/IOPosix.cpp rename to Source/Utility/Paths.cpp index 894c7aa7..69716ca1 100644 --- a/Source/SysPosix/Utility/IOPosix.cpp +++ b/Source/Utility/Paths.cpp @@ -1,5 +1,5 @@ /* -Copyright (C) 2006 StrmnNrmn +Copyright (C) 2024 DaedalusX64 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -19,9 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "System/IO.h" -#include +#include "Utility/Paths.h" +#include +/* + Declare the base DaedalusX64 directory for your device. + If it doesn't require a custom path then all files will appear in the current directory. +*/ #ifdef DAEDALUS_CTR const std::filesystem::path baseDir = std::filesystem::current_path() / "3ds" / "DaedalusX64"; @@ -30,3 +34,12 @@ const std::filesystem::path baseDir = "ux0:/data"; #else const std::filesystem::path baseDir = std::filesystem::current_path(); #endif + +// TODO Create directory structure here + +std::filesystem::path setBasePath(const std::filesystem::path& path) +{ + auto combinedPath = baseDir / path; + std::cout << "Path set for:" << path << "to:" << combinedPath << std::endl; + return combinedPath; +} \ No newline at end of file diff --git a/Source/Utility/Paths.h b/Source/Utility/Paths.h new file mode 100644 index 00000000..3caf305f --- /dev/null +++ b/Source/Utility/Paths.h @@ -0,0 +1,11 @@ + +#ifndef UTILITY_PATHS_H +#define UTILITY_PATHS_H + + +#include + +extern const std::filesystem::path baseDir; + +std::filesystem::path setBasePath(const std::filesystem::path& path); +#endif //UTILITY_PATHS_H \ No newline at end of file diff --git a/Source/Utility/Translate.cpp b/Source/Utility/Translate.cpp index 52d76dbd..4e54b0d3 100644 --- a/Source/Utility/Translate.cpp +++ b/Source/Utility/Translate.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "System/IO.h" +#include "Utility/Paths.h" #include "Utility/StringUtil.h" #include "Utility/Translate.h" #include "Utility/VolatileMem.h" @@ -253,11 +253,8 @@ bool Translate_Read(u32 idx, const std::filesystem::path& dir) // Build path where we'll load the translation file(s) - std::filesystem::path path = baseDir / dir; - std::filesystem::path language = gLanguage[ idx ].c_str(); - std::filesystem::path ext = ".lng"; - path /= language; - path += ext; + const std::string languageFile = "Language/" + gLanguage[idx] + ".lng"; + const std::filesystem::path& path = setBasePath(languageFile); std::cout << "Language Path: " << path << std::endl; From 2a5888ae7c1a8af2f44f01ed979e1b3339589393 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Fri, 2 Aug 2024 15:21:08 +1000 Subject: [PATCH 04/31] Use correct definition for saveslot --- Source/UI/PauseOptionsComponent.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/UI/PauseOptionsComponent.cpp b/Source/UI/PauseOptionsComponent.cpp index 841ddd92..3b3e0593 100644 --- a/Source/UI/PauseOptionsComponent.cpp +++ b/Source/UI/PauseOptionsComponent.cpp @@ -234,7 +234,7 @@ void IPauseOptionsComponent::CheatOptions() void IPauseOptionsComponent::SaveState() { -auto onSaveStateSlotSelected = [this](const char* slot) { this->OnSaveStateSlotSelected(slot); +auto onSaveStateSlotSelected = [this](const std::filesystem::path slot) { this->OnSaveStateSlotSelected(slot); }; auto component = CSavestateSelectorComponent::Create(mpContext, CSavestateSelectorComponent::AT_SAVING, onSaveStateSlotSelected, g_ROM.settings.GameName.c_str()); @@ -247,7 +247,7 @@ auto component = CSavestateSelectorComponent::Create(mpContext, CSavestateSelect void IPauseOptionsComponent::LoadState() { -auto onLoadStateSlotSelected = [this](const char* slot) { +auto onLoadStateSlotSelected = [this](const std::filesystem::path slot) { this->OnLoadStateSlotSelected(slot); }; From 4543f773ff8fb58e7f052a61f4a3007170efeda3 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Sat, 3 Aug 2024 09:44:12 +1000 Subject: [PATCH 05/31] Not sure why rumble was in this function twice. --- Source/HLEGraphics/BaseRenderer.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Source/HLEGraphics/BaseRenderer.cpp b/Source/HLEGraphics/BaseRenderer.cpp index 70d10a9b..7a022785 100644 --- a/Source/HLEGraphics/BaseRenderer.cpp +++ b/Source/HLEGraphics/BaseRenderer.cpp @@ -326,12 +326,6 @@ void BaseRenderer::InitViewport() mN64ToScreenTranslate.x = (f32)display_x - roundf(0.55f * (gZoomX - 1.0f) * fViWidth); mN64ToScreenTranslate.y = (f32)display_y - roundf(0.55f * (gZoomX - 1.0f) * fViHeight); - if( gRumblePakActive ) - { - mN64ToScreenTranslate.x += (FastRand() & 3); - mN64ToScreenTranslate.y += (FastRand() & 3); - } - #ifndef DAEDALUS_CTR if (gRumblePakActive) { @@ -341,6 +335,7 @@ void BaseRenderer::InitViewport() #endif + #if defined(DAEDALUS_GL) || defined(DAEDALUS_CTR) f32 w = mScreenWidth; f32 h = mScreenHeight; From 1b613bb9b86489d4d0ae23a09b6157f68eeba1df Mon Sep 17 00:00:00 2001 From: wally4000 Date: Sat, 3 Aug 2024 09:47:38 +1000 Subject: [PATCH 06/31] Posix timing is just STL now, move to base. --- Source/SysCTR/Utility/CMakeLists.txt | 3 +-- Source/SysPSP/Utility/CMakeLists.txt | 2 -- Source/SysPosix/Utility/CMakeLists.txt | 2 -- Source/Utility/CMakeLists.txt | 4 +++- .../{SysPosix/Utility/TimingPosix.cpp => Utility/Timing.cpp} | 0 5 files changed, 4 insertions(+), 7 deletions(-) rename Source/{SysPosix/Utility/TimingPosix.cpp => Utility/Timing.cpp} (100%) diff --git a/Source/SysCTR/Utility/CMakeLists.txt b/Source/SysCTR/Utility/CMakeLists.txt index 08af614b..524e55bc 100644 --- a/Source/SysCTR/Utility/CMakeLists.txt +++ b/Source/SysCTR/Utility/CMakeLists.txt @@ -1,9 +1,8 @@ add_library(Utility_CTR OBJECT CacheCTR.S - ${PROJECT_SOURCE_DIR}/Source/SysPosix/Utility/IOPosix.cpp MemoryCTR.c ThreadCTR.cpp - TimingCTR.cpp + # TimingCTR.cpp // We use the Timing based on the STL now. (Remove when tested okay) ) diff --git a/Source/SysPSP/Utility/CMakeLists.txt b/Source/SysPSP/Utility/CMakeLists.txt index cc12c539..e958724b 100644 --- a/Source/SysPSP/Utility/CMakeLists.txt +++ b/Source/SysPSP/Utility/CMakeLists.txt @@ -7,9 +7,7 @@ add_library(Utility_PSP OBJECT FastMemcpyPSP.cpp ModulePSP.cpp VolatileMemPSP.cpp - ${PROJECT_SOURCE_DIR}/Source/SysPosix/Utility/TimingPosix.cpp ${PROJECT_SOURCE_DIR}/Source/SysPosix/Utility/ThreadPosix.cpp - # ${PROJECT_SOURCE_DIR}/Source/SysPosix/Utility/IOPosix.cpp ) diff --git a/Source/SysPosix/Utility/CMakeLists.txt b/Source/SysPosix/Utility/CMakeLists.txt index 7c76e026..b29cc936 100644 --- a/Source/SysPosix/Utility/CMakeLists.txt +++ b/Source/SysPosix/Utility/CMakeLists.txt @@ -1,8 +1,6 @@ add_library(Utility_POSIX OBJECT CondPosix.cpp - # IOPosix.cpp ThreadPosix.cpp - TimingPosix.cpp ) list(APPEND daed_libs Utility_POSIX) diff --git a/Source/Utility/CMakeLists.txt b/Source/Utility/CMakeLists.txt index 8ee3fa9b..52047607 100644 --- a/Source/Utility/CMakeLists.txt +++ b/Source/Utility/CMakeLists.txt @@ -8,8 +8,10 @@ add_library(Utility OBJECT Profiler.cpp Stream.cpp StringUtil.cpp - Translate.cpp Timer.cpp + Timing.cpp + Translate.cpp + ) diff --git a/Source/SysPosix/Utility/TimingPosix.cpp b/Source/Utility/Timing.cpp similarity index 100% rename from Source/SysPosix/Utility/TimingPosix.cpp rename to Source/Utility/Timing.cpp From d0f9fd7c8e58bcc5517d6932ed6fe0d80a554dd0 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Sat, 3 Aug 2024 09:57:12 +1000 Subject: [PATCH 07/31] Move all Plugins to HLEAudio/Plugin --- Source/HLEAudio/CMakeLists.txt | 2 + .../Plugin}/AudioPluginNone.cpp | 0 Source/HLEAudio/Plugin/CMakeLists.txt | 14 ++ .../Plugin/CTR}/AudioOutput.cpp | 0 .../Plugin/CTR}/AudioOutput.h | 0 .../Plugin/CTR}/AudioPluginCTR.cpp | 0 .../Plugin/CTR}/AudioPluginCTR.h | 0 .../Plugin/PSP}/AudioPluginPSP.cpp | 0 .../Plugin/PSP}/AudioPluginPSP_SDL.cpp | 0 .../Plugin/PSP}/CMakeLists.txt | 0 .../Plugin/PSP/macOS}/AudioPluginOSX.cpp | 0 .../Plugin/PSP}/old/AudioOutput.cpp | 0 .../Plugin/PSP}/old/AudioOutput.h.old | 0 .../Plugin/PSP}/old/AudioPluginPSP.cpp | 0 .../Plugin/PSP}/old/AudioPluginPSP.h | 0 .../Plugin/SDL}/AudioPluginSDL.cpp | 0 .../Plugin/Windows}/AudioPluginW32.cpp | 0 Source/SysCTR/CMakeLists.txt | 1 - Source/SysCTR/HLEAudio/CMakeLists.txt | 9 - Source/SysPSP/CMakeLists.txt | 1 - Source/SysPosix/CMakeLists.txt | 1 - Source/SysPosix/HLEAudio/AudioPluginLinux.cpp | 11 - .../SysPosix/HLEAudio/AudioPluginSDL copy.cpp | 194 ------------------ Source/SysPosix/HLEAudio/CMakeLists.txt | 12 -- Source/SysW32/CMakeLists.txt | 2 - Source/SysW32/HLEAudio/CMakeLists.txt | 7 - 26 files changed, 16 insertions(+), 238 deletions(-) rename Source/{SysPosix/HLEAudio => HLEAudio/Plugin}/AudioPluginNone.cpp (100%) create mode 100644 Source/HLEAudio/Plugin/CMakeLists.txt rename Source/{SysCTR/HLEAudio => HLEAudio/Plugin/CTR}/AudioOutput.cpp (100%) rename Source/{SysCTR/HLEAudio => HLEAudio/Plugin/CTR}/AudioOutput.h (100%) rename Source/{SysCTR/HLEAudio => HLEAudio/Plugin/CTR}/AudioPluginCTR.cpp (100%) rename Source/{SysCTR/HLEAudio => HLEAudio/Plugin/CTR}/AudioPluginCTR.h (100%) rename Source/{SysPSP/HLEAudio => HLEAudio/Plugin/PSP}/AudioPluginPSP.cpp (100%) rename Source/{SysPSP/HLEAudio => HLEAudio/Plugin/PSP}/AudioPluginPSP_SDL.cpp (100%) rename Source/{SysPSP/HLEAudio => HLEAudio/Plugin/PSP}/CMakeLists.txt (100%) rename Source/{SysPosix/HLEAudio => HLEAudio/Plugin/PSP/macOS}/AudioPluginOSX.cpp (100%) rename Source/{SysPSP/HLEAudio => HLEAudio/Plugin/PSP}/old/AudioOutput.cpp (100%) rename Source/{SysPSP/HLEAudio => HLEAudio/Plugin/PSP}/old/AudioOutput.h.old (100%) rename Source/{SysPSP/HLEAudio => HLEAudio/Plugin/PSP}/old/AudioPluginPSP.cpp (100%) rename Source/{SysPSP/HLEAudio => HLEAudio/Plugin/PSP}/old/AudioPluginPSP.h (100%) rename Source/{SysPosix/HLEAudio => HLEAudio/Plugin/SDL}/AudioPluginSDL.cpp (100%) rename Source/{SysW32/HLEAudio => HLEAudio/Plugin/Windows}/AudioPluginW32.cpp (100%) delete mode 100644 Source/SysCTR/HLEAudio/CMakeLists.txt delete mode 100644 Source/SysPosix/HLEAudio/AudioPluginLinux.cpp delete mode 100644 Source/SysPosix/HLEAudio/AudioPluginSDL copy.cpp delete mode 100644 Source/SysPosix/HLEAudio/CMakeLists.txt delete mode 100644 Source/SysW32/HLEAudio/CMakeLists.txt diff --git a/Source/HLEAudio/CMakeLists.txt b/Source/HLEAudio/CMakeLists.txt index 6be75219..ff0f3b86 100644 --- a/Source/HLEAudio/CMakeLists.txt +++ b/Source/HLEAudio/CMakeLists.txt @@ -1,3 +1,5 @@ +add_subdirectory(Plugin) # Plugin based Audio added here + add_library(HLEAudio OBJECT ABI1.cpp ABI2.cpp diff --git a/Source/SysPosix/HLEAudio/AudioPluginNone.cpp b/Source/HLEAudio/Plugin/AudioPluginNone.cpp similarity index 100% rename from Source/SysPosix/HLEAudio/AudioPluginNone.cpp rename to Source/HLEAudio/Plugin/AudioPluginNone.cpp diff --git a/Source/HLEAudio/Plugin/CMakeLists.txt b/Source/HLEAudio/Plugin/CMakeLists.txt new file mode 100644 index 00000000..80c907c6 --- /dev/null +++ b/Source/HLEAudio/Plugin/CMakeLists.txt @@ -0,0 +1,14 @@ +if(PSP) +add_library(Audio_Plugin OBJECT PSP/AudioPluginPSP.cpp ) +elseif(DAEDLAUS_CTR) +add_library(Audio_Plugin OBJECT CTR/AudioOutput.cpp CTR/AudioPluginCTR.cpp) +elseif(WIN32) +add_library(Audio_Plugin OBJECT Windows/AudioPluginW32.cpp) +elseif(APPLE AND NOT UNIX) +add_library(Audio_Plugin OBJECT macOS/AudioPluginOSX.cpp ) +else() +add_library(Audio_Plugin OBJECT SDL/AudioPluginSDL.cpp) +endif() + +list(APPEND daed_libs "Audio_Plugin") +set(daed_libs ${daed_libs} PARENT_SCOPE) \ No newline at end of file diff --git a/Source/SysCTR/HLEAudio/AudioOutput.cpp b/Source/HLEAudio/Plugin/CTR/AudioOutput.cpp similarity index 100% rename from Source/SysCTR/HLEAudio/AudioOutput.cpp rename to Source/HLEAudio/Plugin/CTR/AudioOutput.cpp diff --git a/Source/SysCTR/HLEAudio/AudioOutput.h b/Source/HLEAudio/Plugin/CTR/AudioOutput.h similarity index 100% rename from Source/SysCTR/HLEAudio/AudioOutput.h rename to Source/HLEAudio/Plugin/CTR/AudioOutput.h diff --git a/Source/SysCTR/HLEAudio/AudioPluginCTR.cpp b/Source/HLEAudio/Plugin/CTR/AudioPluginCTR.cpp similarity index 100% rename from Source/SysCTR/HLEAudio/AudioPluginCTR.cpp rename to Source/HLEAudio/Plugin/CTR/AudioPluginCTR.cpp diff --git a/Source/SysCTR/HLEAudio/AudioPluginCTR.h b/Source/HLEAudio/Plugin/CTR/AudioPluginCTR.h similarity index 100% rename from Source/SysCTR/HLEAudio/AudioPluginCTR.h rename to Source/HLEAudio/Plugin/CTR/AudioPluginCTR.h diff --git a/Source/SysPSP/HLEAudio/AudioPluginPSP.cpp b/Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp similarity index 100% rename from Source/SysPSP/HLEAudio/AudioPluginPSP.cpp rename to Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp diff --git a/Source/SysPSP/HLEAudio/AudioPluginPSP_SDL.cpp b/Source/HLEAudio/Plugin/PSP/AudioPluginPSP_SDL.cpp similarity index 100% rename from Source/SysPSP/HLEAudio/AudioPluginPSP_SDL.cpp rename to Source/HLEAudio/Plugin/PSP/AudioPluginPSP_SDL.cpp diff --git a/Source/SysPSP/HLEAudio/CMakeLists.txt b/Source/HLEAudio/Plugin/PSP/CMakeLists.txt similarity index 100% rename from Source/SysPSP/HLEAudio/CMakeLists.txt rename to Source/HLEAudio/Plugin/PSP/CMakeLists.txt diff --git a/Source/SysPosix/HLEAudio/AudioPluginOSX.cpp b/Source/HLEAudio/Plugin/PSP/macOS/AudioPluginOSX.cpp similarity index 100% rename from Source/SysPosix/HLEAudio/AudioPluginOSX.cpp rename to Source/HLEAudio/Plugin/PSP/macOS/AudioPluginOSX.cpp diff --git a/Source/SysPSP/HLEAudio/old/AudioOutput.cpp b/Source/HLEAudio/Plugin/PSP/old/AudioOutput.cpp similarity index 100% rename from Source/SysPSP/HLEAudio/old/AudioOutput.cpp rename to Source/HLEAudio/Plugin/PSP/old/AudioOutput.cpp diff --git a/Source/SysPSP/HLEAudio/old/AudioOutput.h.old b/Source/HLEAudio/Plugin/PSP/old/AudioOutput.h.old similarity index 100% rename from Source/SysPSP/HLEAudio/old/AudioOutput.h.old rename to Source/HLEAudio/Plugin/PSP/old/AudioOutput.h.old diff --git a/Source/SysPSP/HLEAudio/old/AudioPluginPSP.cpp b/Source/HLEAudio/Plugin/PSP/old/AudioPluginPSP.cpp similarity index 100% rename from Source/SysPSP/HLEAudio/old/AudioPluginPSP.cpp rename to Source/HLEAudio/Plugin/PSP/old/AudioPluginPSP.cpp diff --git a/Source/SysPSP/HLEAudio/old/AudioPluginPSP.h b/Source/HLEAudio/Plugin/PSP/old/AudioPluginPSP.h similarity index 100% rename from Source/SysPSP/HLEAudio/old/AudioPluginPSP.h rename to Source/HLEAudio/Plugin/PSP/old/AudioPluginPSP.h diff --git a/Source/SysPosix/HLEAudio/AudioPluginSDL.cpp b/Source/HLEAudio/Plugin/SDL/AudioPluginSDL.cpp similarity index 100% rename from Source/SysPosix/HLEAudio/AudioPluginSDL.cpp rename to Source/HLEAudio/Plugin/SDL/AudioPluginSDL.cpp diff --git a/Source/SysW32/HLEAudio/AudioPluginW32.cpp b/Source/HLEAudio/Plugin/Windows/AudioPluginW32.cpp similarity index 100% rename from Source/SysW32/HLEAudio/AudioPluginW32.cpp rename to Source/HLEAudio/Plugin/Windows/AudioPluginW32.cpp diff --git a/Source/SysCTR/CMakeLists.txt b/Source/SysCTR/CMakeLists.txt index 7c8df9b7..0d81bc24 100644 --- a/Source/SysCTR/CMakeLists.txt +++ b/Source/SysCTR/CMakeLists.txt @@ -1,6 +1,5 @@ add_subdirectory(Debug) add_subdirectory(Graphics) -add_subdirectory(HLEAudio) add_subdirectory(HLEGraphics) add_subdirectory(Input) add_subdirectory(UI) diff --git a/Source/SysCTR/HLEAudio/CMakeLists.txt b/Source/SysCTR/HLEAudio/CMakeLists.txt deleted file mode 100644 index 5f8a5513..00000000 --- a/Source/SysCTR/HLEAudio/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -add_library(HLEAudio_CTR OBJECT - AudioOutput.cpp - AudioPluginCTR.cpp - - ) - - -list(APPEND daed_libs "HLEAudio_CTR") -set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/SysPSP/CMakeLists.txt b/Source/SysPSP/CMakeLists.txt index f0bd5213..508ad664 100644 --- a/Source/SysPSP/CMakeLists.txt +++ b/Source/SysPSP/CMakeLists.txt @@ -1,6 +1,5 @@ add_subdirectory(Debug) add_subdirectory(Graphics) -add_subdirectory(HLEAudio) add_subdirectory(HLEGraphics) add_subdirectory(Input) add_subdirectory(PRX) diff --git a/Source/SysPosix/CMakeLists.txt b/Source/SysPosix/CMakeLists.txt index 86993e71..a8ed79d2 100644 --- a/Source/SysPosix/CMakeLists.txt +++ b/Source/SysPosix/CMakeLists.txt @@ -1,5 +1,4 @@ add_subdirectory(Debug) -add_subdirectory(HLEAudio) add_subdirectory(HLEGraphics) add_subdirectory(Utility) diff --git a/Source/SysPosix/HLEAudio/AudioPluginLinux.cpp b/Source/SysPosix/HLEAudio/AudioPluginLinux.cpp deleted file mode 100644 index 74abd452..00000000 --- a/Source/SysPosix/HLEAudio/AudioPluginLinux.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -#include "Base/Types.h" -#include "HLEAudio/AudioPlugin.h" -#include "Config/ConfigOptions.h" - -EAudioPluginMode gAudioPluginEnabled = APM_DISABLED; - -std::unique_ptr CreateAudioPlugin() -{ - return NULL; -} diff --git a/Source/SysPosix/HLEAudio/AudioPluginSDL copy.cpp b/Source/SysPosix/HLEAudio/AudioPluginSDL copy.cpp deleted file mode 100644 index c39b941a..00000000 --- a/Source/SysPosix/HLEAudio/AudioPluginSDL copy.cpp +++ /dev/null @@ -1,194 +0,0 @@ -#include - - - -#include "Base/Types.h" -#include "Config/ConfigOptions.h" -#include "Core/FramerateLimiter.h" -#include "Core/Memory.h" -#include "Debug/DBGConsole.h" -#include "HLEAudio/AudioPlugin.h" -#include "HLEAudio/HLEAudioInternal.h" -#include "System/Timing.h" -#include -#include - -EAudioPluginMode gAudioPluginEnabled = APM_ENABLED_ASYNC; - -pthread_t Asyncthread; -int Asyncthreadreturn; - -void* Audio_UcodeEntry(void* arg) { - Audio_Ucode(); - return nullptr; -} - -SDL_AudioDeviceID audio_device; - -struct Sample { - s16 L; - s16 R; -}; - -class AudioPluginSDL : public CAudioPlugin -{ -public: - AudioPluginSDL(); - virtual ~AudioPluginSDL(); - - virtual bool StartEmulation(); - virtual void StopEmulation(); - - virtual void DacrateChanged(int system_type); - virtual void LenChanged(); - virtual u32 ReadLength() { return 0; } - virtual EProcessResult ProcessAList(); - - void AddBuffer(void * ptr, u32 length); // Uploads a new buffer and returns status - void StopAudio(); // Stops the Audio PlayBack (as if paused) - void StartAudio(); // Starts the Audio PlayBack (as if unpaused) - - static void AudioSyncFunction(void * arg); - static int AudioThread(void * arg); - -private: - u32 mFrequency; - SDL_Thread* mAudioThread; -}; - -AudioPluginSDL::AudioPluginSDL() -: mFrequency( 44100 ) -{} - -AudioPluginSDL::~AudioPluginSDL() -{ - StopAudio(); -} - -bool AudioPluginSDL::StartEmulation() -{ - return true; -} - -void AudioPluginSDL::StopEmulation() -{ - Audio_Reset(); - StopAudio(); -} - -void AudioPluginSDL::DacrateChanged(int system_type) -{ - u32 clock = (system_type == ST_NTSC) ? VI_NTSC_CLOCK : VI_PAL_CLOCK; - u32 dacrate = Memory_AI_GetRegister(AI_DACRATE_REG); - u32 frequency = clock / (dacrate + 1); - - mFrequency = frequency; -} - -void AudioPluginSDL::LenChanged() -{ - if (gAudioPluginEnabled > APM_DISABLED) - { - u32 address = Memory_AI_GetRegister(AI_DRAM_ADDR_REG) & 0xFFFFFF; - u32 length = Memory_AI_GetRegister(AI_LEN_REG); - - AddBuffer( g_pu8RamBase + address, length ); - } -} - -EProcessResult AudioPluginSDL::ProcessAList() -{ - Memory_SP_SetRegisterBits(SP_STATUS_REG, SP_STATUS_HALT); - - EProcessResult result = PR_NOT_STARTED; - - switch (gAudioPluginEnabled) - { - case APM_DISABLED: - result = PR_COMPLETED; - break; - case APM_ENABLED_ASYNC: - Asyncthreadreturn = pthread_create(&Asyncthread, NULL, &Audio_UcodeEntry, (void*)nullptr); - result = PR_COMPLETED; - break; - case APM_ENABLED_SYNC: - Audio_Ucode(); - result = PR_COMPLETED; - break; - } - - return result; -} - -void AudioPluginSDL::AddBuffer(void * ptr, u32 length) -{ - if (length == 0) - return; - - if (mAudioThread == nullptr) - StartAudio(); - - u32 num_samples = length / sizeof(Sample); - - // Queue the samples into SDL's audio buffer - if(SDL_QueueAudio(audio_device, ptr, num_samples * sizeof(Sample)) != 0) { - DBGConsole_Msg(0, "SDL_QueueAudio error: %s", SDL_GetError()); - return; - } -} - -int AudioPluginSDL::AudioThread(void * arg) -{ - AudioPluginSDL * plugin = static_cast< AudioPluginSDL *>(arg); - - SDL_AudioSpec audio_spec; - audio_spec.freq = plugin->mFrequency; - audio_spec.format = AUDIO_S16SYS; - audio_spec.channels = 2; - audio_spec.samples = 4096; - audio_spec.callback = NULL; - audio_spec.userdata = plugin; - - audio_device = SDL_OpenAudioDevice( - NULL, 0, &audio_spec, NULL, 0); - - SDL_QueueAudio(0, &audio_spec, 4096); - - SDL_PauseAudioDevice(audio_device, 0); - - return 0; -} - -void AudioPluginSDL::StartAudio() -{ - - mAudioThread = SDL_CreateThread(&AudioThread, "Audio", this); - - if (mAudioThread == nullptr) - { - DBGConsole_Msg(0, "Failed to start the audio thread!"); - FramerateLimiter_SetAuxillarySyncFunction(nullptr, nullptr); - } -} - -void AudioPluginSDL::StopAudio() -{ - if (mAudioThread == nullptr) - return; - - if (mAudioThread != nullptr) - { - int threadReturnValue; - SDL_WaitThread(mAudioThread, &threadReturnValue); - mAudioThread = nullptr; - } - - // Clear the remaining audio data in SDL's audio buffer - SDL_ClearQueuedAudio(audio_device); - SDL_CloseAudioDevice(audio_device); -} - -std::unique_ptr CreateAudioPlugin() -{ - return std::make_unique(); -} \ No newline at end of file diff --git a/Source/SysPosix/HLEAudio/CMakeLists.txt b/Source/SysPosix/HLEAudio/CMakeLists.txt deleted file mode 100644 index e9653b20..00000000 --- a/Source/SysPosix/HLEAudio/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -if(UNIX AND NOT APPLE) -add_library(Audio_POSIX OBJECT AudioPluginSDL.cpp) -elseif( APPLE) -add_library(Audio_POSIX OBJECT AudioPluginOSX.cpp) -else() ## No Audio available -add_library(Audio_POSIX OBJECT AudioPluginNone.cpp) -endif() - - -list(APPEND daed_libs Audio_POSIX) -set(daed_libs ${daed_libs} PARENT_SCOPE) - diff --git a/Source/SysW32/CMakeLists.txt b/Source/SysW32/CMakeLists.txt index ccc18eb6..ab0966d1 100644 --- a/Source/SysW32/CMakeLists.txt +++ b/Source/SysW32/CMakeLists.txt @@ -1,8 +1,6 @@ add_subdirectory(Debug) -add_subdirectory(HLEAudio) add_subdirectory(Utility) - install(FILES ${PROJECT_BINARY_DIR}/../Data/roms.ini DESTINATION DaedalusX64) install(FILES ${PROJECT_BINARY_DIR}/../Data/readme.txt DESTINATION DaedalusX64) install(FILES ${PROJECT_BINARY_DIR}/../Data/copying.txt DESTINATION DaedalusX64) diff --git a/Source/SysW32/HLEAudio/CMakeLists.txt b/Source/SysW32/HLEAudio/CMakeLists.txt deleted file mode 100644 index 59d8da51..00000000 --- a/Source/SysW32/HLEAudio/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_library(HLEAudio_Win OBJECT - AudioPluginW32.cpp - ) - -list(APPEND daed_libs HLEAudio_Win) -set(daed_libs ${daed_libs} PARENT_SCOPE) - From 4e6d4f6c51b5358d86d3a494863cde1b0c5f37dc Mon Sep 17 00:00:00 2001 From: wally4000 Date: Mon, 5 Aug 2024 06:54:56 +1000 Subject: [PATCH 08/31] Move all Input to the Input Folder --- Source/CMakeLists.txt | 1 + Source/Input/CMakeLists.txt | 11 +++++++++++ .../{SysCTR/Input => Input/CTR}/InputManagerCTR.cpp | 0 .../{SysPSP/Input => Input/PSP}/InputManagerPSP.cpp | 0 .../SDL/InputManagerSDL.cpp} | 0 Source/SysCTR/CMakeLists.txt | 1 - Source/SysCTR/Input/CMakeLists.txt | 8 -------- Source/SysCTR/UI/RomSelector.cpp | 6 +++--- Source/SysGL/CMakeLists.txt | 2 +- Source/SysPSP/CMakeLists.txt | 1 - Source/SysPSP/Input/CMakeLists.txt | 7 ------- 11 files changed, 16 insertions(+), 21 deletions(-) create mode 100644 Source/Input/CMakeLists.txt rename Source/{SysCTR/Input => Input/CTR}/InputManagerCTR.cpp (100%) rename Source/{SysPSP/Input => Input/PSP}/InputManagerPSP.cpp (100%) rename Source/{SysGL/Input/InputManagerGL.cpp => Input/SDL/InputManagerSDL.cpp} (100%) delete mode 100644 Source/SysCTR/Input/CMakeLists.txt delete mode 100644 Source/SysPSP/Input/CMakeLists.txt diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index e324a4bc..fd11015e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -211,6 +211,7 @@ link_libraries(ZLIB::ZLIB) add_subdirectory(HLEAudio) add_subdirectory(HLEGraphics) add_subdirectory(Interface) + add_subdirectory(Input) add_subdirectory(Math) add_subdirectory(OSHLE) add_subdirectory(RomFile) diff --git a/Source/Input/CMakeLists.txt b/Source/Input/CMakeLists.txt new file mode 100644 index 00000000..1b1701f3 --- /dev/null +++ b/Source/Input/CMakeLists.txt @@ -0,0 +1,11 @@ +if(DAEDALUS_PSP) +add_library(Input OBJECT PSP/InputManagerPSP.cpp) +elif(DAEDALUS_CTR) +add_library(Input OBJECT CTR/InputManagerCTR.cpp) +else() +add_library(Input OBJECT SDL/InputManagerSDL.cpp) +endif() + +list(APPEND daed_libs "Input") +set(daed_libs ${daed_libs} PARENT_SCOPE) + \ No newline at end of file diff --git a/Source/SysCTR/Input/InputManagerCTR.cpp b/Source/Input/CTR/InputManagerCTR.cpp similarity index 100% rename from Source/SysCTR/Input/InputManagerCTR.cpp rename to Source/Input/CTR/InputManagerCTR.cpp diff --git a/Source/SysPSP/Input/InputManagerPSP.cpp b/Source/Input/PSP/InputManagerPSP.cpp similarity index 100% rename from Source/SysPSP/Input/InputManagerPSP.cpp rename to Source/Input/PSP/InputManagerPSP.cpp diff --git a/Source/SysGL/Input/InputManagerGL.cpp b/Source/Input/SDL/InputManagerSDL.cpp similarity index 100% rename from Source/SysGL/Input/InputManagerGL.cpp rename to Source/Input/SDL/InputManagerSDL.cpp diff --git a/Source/SysCTR/CMakeLists.txt b/Source/SysCTR/CMakeLists.txt index 0d81bc24..14226c37 100644 --- a/Source/SysCTR/CMakeLists.txt +++ b/Source/SysCTR/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory(Debug) add_subdirectory(Graphics) add_subdirectory(HLEGraphics) -add_subdirectory(Input) add_subdirectory(UI) add_subdirectory(Utility) diff --git a/Source/SysCTR/Input/CMakeLists.txt b/Source/SysCTR/Input/CMakeLists.txt deleted file mode 100644 index 284ea8f4..00000000 --- a/Source/SysCTR/Input/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ - -add_library(Input_CTR OBJECT - InputManagerCTR.cpp - ) - - -list(APPEND daed_libs "Input_CTR") -set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/SysCTR/UI/RomSelector.cpp b/Source/SysCTR/UI/RomSelector.cpp index d4e50b31..884cdb21 100644 --- a/Source/SysCTR/UI/RomSelector.cpp +++ b/Source/SysCTR/UI/RomSelector.cpp @@ -47,14 +47,14 @@ static std::vector PopulateRomList() std::vector roms = {}; std::string full_path; - IO::FindHandleT find_handle; - IO::FindDataT find_data; + // IO::FindHandleT find_handle; + // IO::FindDataT find_data; // if(IO::FindFileOpen( DAEDALUS_CTR_PATH("Roms/"), &find_handle, find_data )) // { // do // { - const std::filesystem::path rom_filename( find_data.Name ); + const std::filesystem::path rom_filename; if(std::find(valid_extensions.begin(), valid_extensions.end(), rom_filename.extension()) != valid_extensions.end()) { SRomInfo info; diff --git a/Source/SysGL/CMakeLists.txt b/Source/SysGL/CMakeLists.txt index 8d9a28ba..dc2ca50b 100644 --- a/Source/SysGL/CMakeLists.txt +++ b/Source/SysGL/CMakeLists.txt @@ -1,4 +1,4 @@ -file(GLOB SRC_FILES Graphics/*.cpp HLEGraphics/*.cpp Input/*.cpp) +file(GLOB SRC_FILES Graphics/*.cpp HLEGraphics/*.cpp) add_library(SysGL OBJECT ${SRC_FILES}) diff --git a/Source/SysPSP/CMakeLists.txt b/Source/SysPSP/CMakeLists.txt index 508ad664..fb6e6e9d 100644 --- a/Source/SysPSP/CMakeLists.txt +++ b/Source/SysPSP/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory(Debug) add_subdirectory(Graphics) add_subdirectory(HLEGraphics) -add_subdirectory(Input) add_subdirectory(PRX) add_subdirectory(Utility) diff --git a/Source/SysPSP/Input/CMakeLists.txt b/Source/SysPSP/Input/CMakeLists.txt deleted file mode 100644 index 3c1b54a9..00000000 --- a/Source/SysPSP/Input/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_library(Input_PSP OBJECT - InputManagerPSP.cpp - ) - - -list(APPEND daed_libs "Input_PSP") -set(daed_libs ${daed_libs} PARENT_SCOPE) From e3326478a4f612bea1f50ebb5d77b7dece28fd6d Mon Sep 17 00:00:00 2001 From: wally4000 Date: Mon, 5 Aug 2024 13:32:54 +1000 Subject: [PATCH 09/31] Fix SaveStates --- Source/UI/SavestateSelectorComponent.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/UI/SavestateSelectorComponent.cpp b/Source/UI/SavestateSelectorComponent.cpp index 6c7f2d12..68296e86 100644 --- a/Source/UI/SavestateSelectorComponent.cpp +++ b/Source/UI/SavestateSelectorComponent.cpp @@ -78,6 +78,7 @@ class ISavestateSelectorComponent : public CSavestateSelectorComponent std::vector mElementTitle; bool mSlotEmpty[ NUM_SAVESTATE_SLOTS ]; std::filesystem::path mPVFilename[ NUM_SAVESTATE_SLOTS ]; + std::filesystem::path mPVScreenShot [ NUM_SAVESTATE_SLOTS ]; s8 mPVExists[ NUM_SAVESTATE_SLOTS ]; //0=skip, 1=file exists, -1=show no preview std::shared_ptr mPreviewTexture; u32 mLastPreviewLoad; @@ -177,8 +178,8 @@ void ISavestateSelectorComponent::LoadSlots() { for (u32 i = 0; i < NUM_SAVESTATE_SLOTS; ++i) { std::string str = std::string("Slot ") + std::to_string(i + 1) + ": "; - std::filesystem::path filename_ss; - MakeSaveSlotPath(filename_ss, mPVFilename[i], i, current_slot_path); + // std::filesystem::path filename_ss; + MakeSaveSlotPath(mPVFilename [i], mPVScreenShot[i], i, current_slot_path); // Is outputting filenames correctly mPVExists[i] = std::filesystem::exists(mPVFilename[i]) ? 1 : -1; From fd22ce09e053c78d2f00f6f622f805a82db632f3 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Mon, 5 Aug 2024 21:15:57 +1000 Subject: [PATCH 10/31] Shuffle some files around --- Source/CMakeLists.txt | 2 - Source/Config/CMakeLists.txt | 4 - Source/Core/CMakeLists.txt | 13 +- Source/Core/CPU.cpp | 14 +- Source/Core/DMA.cpp | 2 +- Source/Core/Interpret.cpp | 6 +- Source/Core/Memory.cpp | 4 +- Source/Core/R4300.cpp | 4 +- Source/Core/ROM.cpp | 10 +- Source/Core/ROM.h | 2 +- Source/Core/ROMBuffer.cpp | 515 ------------------ Source/Core/RSP_HLE.cpp | 4 +- Source/Core/RomSettings.cpp | 514 ----------------- Source/Core/Save.cpp | 2 +- Source/Debug/CMakeLists.txt | 2 + Source/Debug/DebugLog.cpp | 18 +- Source/Debug/Dump.cpp | 6 +- Source/{Core => Debug}/PrintOpCode.cpp | 2 +- Source/{Core => Debug}/PrintOpCode.h | 0 Source/{Core => Debug}/Registers.cpp | 0 Source/{Core => Debug}/Registers.h | 0 Source/DynaRec/ARM/CodeGeneratorARM.cpp | 4 +- Source/DynaRec/CMakeLists.txt | 1 + Source/{Core => DynaRec}/Dynamo.cpp | 6 +- Source/{Core => DynaRec}/Dynamo.h | 0 Source/DynaRec/Fragment.cpp | 4 +- Source/DynaRec/TraceRecorder.cpp | 4 +- Source/DynaRec/mips/AssemblyWriterPSP.cpp | 2 +- Source/DynaRec/mips/CodeGeneratorPSP.cpp | 6 +- Source/DynaRec/x64/CodeGeneratorX64.cpp | 4 +- Source/DynaRec/x86/CodeGeneratorX86.cpp | 4 +- Source/Graphics/CMakeLists.txt | 2 + Source/{Core => Graphics}/HvqmTask.cpp | 0 Source/{Core => Graphics}/JpegTask.cpp | 0 Source/HLEAudio/AudioBuffer.cpp | 2 +- Source/HLEAudio/Plugin/AudioPluginNone.cpp | 2 +- Source/HLEAudio/Plugin/CMakeLists.txt | 2 +- Source/HLEAudio/Plugin/CTR/AudioOutput.cpp | 4 +- Source/HLEAudio/Plugin/CTR/AudioPluginCTR.cpp | 2 +- Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp | 4 +- .../Plugin/PSP/AudioPluginPSP_SDL.cpp | 6 +- .../Plugin/PSP/macOS/AudioPluginOSX.cpp | 4 +- .../HLEAudio/Plugin/PSP/old/AudioOutput.cpp | 4 +- .../Plugin/PSP/old/AudioPluginPSP.cpp | 2 +- Source/HLEAudio/Plugin/SDL/AudioPluginSDL.cpp | 4 +- .../Plugin/Windows/AudioPluginW32.cpp | 2 +- Source/HLEGraphics/CachedTexture.cpp | 2 +- Source/HLEGraphics/DLParser.cpp | 4 +- Source/HLEGraphics/TextureInfo.cpp | 2 +- Source/Input/CMakeLists.txt | 2 +- Source/Input/CTR/InputManagerCTR.cpp | 2 +- Source/Input/PSP/InputManagerPSP.cpp | 2 +- Source/Interface/CMakeLists.txt | 2 + Source/{Core => Interface}/Cheats.cpp | 4 +- Source/{Core => Interface}/Cheats.h | 0 .../{Config => Interface}/ConfigOptions.cpp | 2 +- Source/{Config => Interface}/ConfigOptions.h | 0 Source/Interface/Preferences.cpp | 4 +- Source/Interface/RomPreferences.h | 2 +- Source/OSHLE/patch.cpp | 4 +- Source/OSHLE/patch.h | 2 +- Source/RomFile/CMakeLists.txt | 2 + Source/{Core => RomFile}/ROMBuffer.h | 0 Source/RomFile/RomSettings.cpp | 8 +- Source/{Core => RomFile}/RomSettings.h | 0 Source/SysCTR/Debug/DBGConsoleCTR.cpp | 2 +- Source/SysCTR/Graphics/GraphicsContextCTR.cpp | 2 +- .../SysCTR/HLEGraphics/GraphicsPluginCTR.cpp | 2 +- Source/SysCTR/UI/InGameMenu.cpp | 8 +- Source/SysCTR/UI/InGameMenu.h | 2 +- Source/SysCTR/main.cpp | 9 +- Source/SysPSP/Debug/DBGConsolePSP.cpp | 2 +- Source/SysPSP/Graphics/GraphicsContextPSP.cpp | 2 +- .../SysPSP/HLEGraphics/GraphicsPluginPSP.cpp | 2 +- Source/SysPSP/Utility/exception.cpp | 6 +- Source/SysPSP/main.cpp | 8 +- Source/SysPosix/main.cpp | 4 +- Source/System/SystemInit.cpp | 6 +- Source/Test/CMakeLists.txt | 1 - Source/UI/AdvancedOptionsScreen.cpp | 4 +- Source/UI/CheatOptionsScreen.cpp | 6 +- Source/UI/GlobalSettingsComponent.cpp | 2 +- Source/UI/MainMenuScreen.cpp | 2 +- Source/UI/PauseOptionsComponent.cpp | 2 +- Source/UI/PauseScreen.cpp | 2 +- Source/UI/RomPreferencesScreen.cpp | 4 +- Source/UI/RomSelectorComponent.cpp | 19 +- Source/{Test => Utility}/BatchTest.cpp | 4 +- Source/{Test => Utility}/BatchTest.h | 0 Source/Utility/CMakeLists.txt | 2 + Source/{Core => Utility}/FramerateLimiter.cpp | 0 Source/{Core => Utility}/FramerateLimiter.h | 0 92 files changed, 148 insertions(+), 1198 deletions(-) delete mode 100644 Source/Config/CMakeLists.txt delete mode 100644 Source/Core/ROMBuffer.cpp delete mode 100644 Source/Core/RomSettings.cpp rename Source/{Core => Debug}/PrintOpCode.cpp (99%) rename Source/{Core => Debug}/PrintOpCode.h (100%) rename Source/{Core => Debug}/Registers.cpp (100%) rename Source/{Core => Debug}/Registers.h (100%) rename Source/{Core => DynaRec}/Dynamo.cpp (96%) rename Source/{Core => DynaRec}/Dynamo.h (100%) rename Source/{Core => Graphics}/HvqmTask.cpp (100%) rename Source/{Core => Graphics}/JpegTask.cpp (100%) rename Source/{Core => Interface}/Cheats.cpp (99%) rename Source/{Core => Interface}/Cheats.h (100%) rename Source/{Config => Interface}/ConfigOptions.cpp (98%) rename Source/{Config => Interface}/ConfigOptions.h (100%) rename Source/{Core => RomFile}/ROMBuffer.h (100%) rename Source/{Core => RomFile}/RomSettings.h (100%) delete mode 100644 Source/Test/CMakeLists.txt rename Source/{Test => Utility}/BatchTest.cpp (95%) rename Source/{Test => Utility}/BatchTest.h (100%) rename Source/{Core => Utility}/FramerateLimiter.cpp (100%) rename Source/{Core => Utility}/FramerateLimiter.h (100%) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index fd11015e..d2c59b95 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -203,7 +203,6 @@ find_package(ZLIB REQUIRED) link_libraries(ZLIB::ZLIB) ## Daedalus Core Build - add_subdirectory(Config) add_subdirectory(Core) add_subdirectory(Debug) add_subdirectory(DynaRec) @@ -216,7 +215,6 @@ link_libraries(ZLIB::ZLIB) add_subdirectory(OSHLE) add_subdirectory(RomFile) add_subdirectory(System) - add_subdirectory(Test) add_subdirectory(Utility) add_subdirectory(UI) diff --git a/Source/Config/CMakeLists.txt b/Source/Config/CMakeLists.txt deleted file mode 100644 index 034a2a5b..00000000 --- a/Source/Config/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_library(Config OBJECT ConfigOptions.cpp) - -list(APPEND daed_libs "Config") -set(daed_libs ${daed_libs} PARENT_SCOPE) diff --git a/Source/Core/CMakeLists.txt b/Source/Core/CMakeLists.txt index fd4e24d5..16b22f22 100644 --- a/Source/Core/CMakeLists.txt +++ b/Source/Core/CMakeLists.txt @@ -1,24 +1,17 @@ add_library(Core OBJECT - HvqmTask.cpp - RDRam.cpp - Cheats.cpp + + CPU.cpp DMA.cpp - Dynamo.cpp FlashMem.cpp - FramerateLimiter.cpp Interpret.cpp Interrupt.cpp - JpegTask.cpp Memory.cpp PIF.cpp - PrintOpCode.cpp R4300.cpp - Registers.cpp + RDRam.cpp ROM.cpp - ROMBuffer.cpp ROMImage.cpp - RomSettings.cpp RSP_HLE.cpp Save.cpp TLB.cpp diff --git a/Source/Core/CPU.cpp b/Source/Core/CPU.cpp index 4349a9c3..979eeeaa 100644 --- a/Source/Core/CPU.cpp +++ b/Source/Core/CPU.cpp @@ -29,16 +29,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "System/Mutex.h" #include -#include "Config/ConfigOptions.h" -#include "Core/Cheats.h" -#include "Core/Dynamo.h" +#include "Interface/ConfigOptions.h" +#include "Interface/Cheats.h" +#include "DynaRec/Dynamo.h" #include "Core/Interpret.h" #include "Core/Interrupt.h" #include "Core/Memory.h" #include "Core/R4300.h" -#include "Core/Registers.h" // For REG_?? defines +#include "Debug/Registers.h" // For REG_?? defines #include "Core/ROM.h" -#include "Core/ROMBuffer.h" +#include "RomFile/ROMBuffer.h" #include "Core/RSP_HLE.h" #include "Core/Save.h" #include "Interface/SaveState.h" @@ -47,10 +47,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Ultra/ultra_R4300.h" #include "System/SystemInit.h" #include "System/AtomicPrimitives.h" -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" #include "Utility/Hash.h" #include "Base/Macros.h" -#include "Core/PrintOpCode.h" +#include "Debug/PrintOpCode.h" #include "Debug/Synchroniser.h" #include "System/Thread.h" diff --git a/Source/Core/DMA.cpp b/Source/Core/DMA.cpp index 96f4032b..751d3b36 100644 --- a/Source/Core/DMA.cpp +++ b/Source/Core/DMA.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/RSP_HLE.h" #include "Core/CPU.h" #include "Core/ROM.h" -#include "Core/ROMBuffer.h" +#include "RomFile/ROMBuffer.h" #include "Core/PIF.h" #include "Core/Interrupt.h" #include "Core/Save.h" diff --git a/Source/Core/Interpret.cpp b/Source/Core/Interpret.cpp index 78ee9abd..356942f0 100644 --- a/Source/Core/Interpret.cpp +++ b/Source/Core/Interpret.cpp @@ -22,13 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" #include "Core/CPU.h" -#include "Core/Registers.h" // For REG_?? defines +#include "Debug/Registers.h" // For REG_?? defines #include "Core/Memory.h" #include "Core/Interpret.h" #include "Core/Interrupt.h" -#include "Core/ROMBuffer.h" +#include "RomFile/ROMBuffer.h" #include "Core/R4300.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" #include "OSHLE/patch.h" // GetCorrectOp diff --git a/Source/Core/Memory.cpp b/Source/Core/Memory.cpp index 84f77821..20b21b74 100644 --- a/Source/Core/Memory.cpp +++ b/Source/Core/Memory.cpp @@ -31,8 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/Interrupt.h" #include "Core/Memory.h" #include "Core/ROM.h" -#include "Core/ROMBuffer.h" -#include "Config/ConfigOptions.h" +#include "RomFile/ROMBuffer.h" +#include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" #include "Debug/DebugLog.h" diff --git a/Source/Core/R4300.cpp b/Source/Core/R4300.cpp index 0095211a..912d5821 100644 --- a/Source/Core/R4300.cpp +++ b/Source/Core/R4300.cpp @@ -28,8 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/Interrupt.h" #include "Core/R4300.h" #include "Core/ROM.h" -#include "Config/ConfigOptions.h" -#include "Core/Registers.h" // For REG_?? defines +#include "Interface/ConfigOptions.h" +#include "Debug/Registers.h" // For REG_?? defines #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" #include "DynaRec/TraceRecorder.h" diff --git a/Source/Core/ROM.cpp b/Source/Core/ROM.cpp index a35ac61c..5594cc81 100644 --- a/Source/Core/ROM.cpp +++ b/Source/Core/ROM.cpp @@ -24,14 +24,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Core/Cheats.h" +#include "Interface/Cheats.h" #include "Core/CPU.h" #include "Core/PIF.h" // CController #include "Core/R4300.h" -#include "Core/ROMBuffer.h" +#include "RomFile/ROMBuffer.h" #include "Core/ROMImage.h" -#include "Core/RomSettings.h" -#include "Config/ConfigOptions.h" +#include "RomFile/RomSettings.h" +#include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" #include "Interface/RomDB.h" @@ -42,7 +42,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "HLEAudio/AudioPlugin.h" #include "HLEGraphics/GraphicsPlugin.h" #include "Utility/CRC.h" -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" #include "Base/Macros.h" #include "Interface/Preferences.h" diff --git a/Source/Core/ROM.h b/Source/Core/ROM.h index 67415e86..2e852db2 100644 --- a/Source/Core/ROM.h +++ b/Source/Core/ROM.h @@ -82,7 +82,7 @@ class RomID u8 CountryID; }; -#include "RomSettings.h" +#include "RomFile/RomSettings.h" struct SRomPreferences; diff --git a/Source/Core/ROMBuffer.cpp b/Source/Core/ROMBuffer.cpp deleted file mode 100644 index b9e78b28..00000000 --- a/Source/Core/ROMBuffer.cpp +++ /dev/null @@ -1,515 +0,0 @@ -/* -Copyright (C) 2006 StrmnNrmn - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - - -#include "Base/Types.h" - -#include "Core/ROMBuffer.h" -#include "Core/ROM.h" -#include "Core/DMA.h" -#include "Debug/DBGConsole.h" -#include "Utility/MathUtil.h" -#include "Interface/Preferences.h" -#include "RomFile/RomFile.h" -#include "RomFile/RomFileCache.h" -#include "RomFile/RomFileMemory.h" -#include "Utility/Stream.h" - - -#include - -#ifdef DAEDALUS_PSP -#include "Graphics/GraphicsContext.h" -#ifdef INTRAFONT - #include "intraFont.h" -#endif - -extern bool PSP_IS_SLIM; -#endif - -#ifdef DAEDALUS_CTR -extern bool isN3DS; -#endif - -namespace -{ - bool sRomLoaded = false; - u8 * spRomData = nullptr; - u32 sRomSize [[maybe_unused]] = 0; - bool sRomFixed = false; - bool sRomWritten = false; - u32 sRomValue = 0; - std::shared_ptr spRomFileCache = nullptr; - -#ifdef DAEDALUS_COMPRESSED_ROM_SUPPORT - static bool DECOMPRESS_ROMS = true; -#endif - // Maximum read length is 8 bytes (i.e. double, u64) - const u32 SCRATCH_BUFFER_LENGTH = 16; - u8 sScratchBuffer[ SCRATCH_BUFFER_LENGTH ]; - - bool ShouldLoadAsFixed( u32 rom_size [[maybe_unused]] ) - { -#if defined(DAEDALUS_PSP) - if (PSP_IS_SLIM && !gGlobalPreferences.LargeROMBuffer) - return rom_size <= 32 * 1024 * 1024; - else - return rom_size <= 2 * 1024 * 1024; -#elif defined(DAEDALUS_CTR) - if(isN3DS) - return rom_size < 32 * 1024 * 1024; - else - return rom_size < 8 * 1024 * 1024; -#else - return true; -#endif - } - -#ifdef DAEDALUS_COMPRESSED_ROM_SUPPORT - std::shared_ptr DecompressRom( std::shared_ptr p_rom_file, const std::filesystem::path &temp_filename, COutputStream & messages ) - { - - FILE * fh( fopen( temp_filename.c_str(), "wb" ) ); - auto p_new_file = ROMFile::Create( temp_filename ); - if( fh == nullptr ) - { - messages << "Unable to create temporary rom '" << temp_filename.c_str() << "' for decompression\n"; - } - else - { - bool failed = false; - const u32 TEMP_BUFFER_SIZE = 32 * 1024; - u8 * p_temp_buffer( new u8[ TEMP_BUFFER_SIZE ] ); - -#ifdef DAEDALUS_DEBUG_CONSOLE - CDebugConsole::Get()->MsgOverwriteStart(); -#endif - - u32 offset( 0 ); - u32 total_length( p_rom_file->GetRomSize() ); - u32 length_remaining( total_length ); - - while( length_remaining > 0 ) - { -#ifdef DAEDALUS_DEBUG_CONSOLE - if ((offset % 0x8000) == 0) - { - CDebugConsole::Get()->MsgOverwrite(0, "Converted [M%d / %d] KB", offset /1024, total_length / 1024 ); - } -#endif - u32 length_to_process( std::min( length_remaining, TEMP_BUFFER_SIZE ) ); - - if( !p_rom_file->ReadChunk( offset, p_temp_buffer, length_to_process ) ) - { - failed = true; - break; - } - - if( fwrite( p_temp_buffer, 1, length_to_process, fh ) != length_to_process ) - { - failed = true; - break; - } - - offset += length_to_process; - length_remaining -= length_to_process; - } -#ifdef DAEDALUS_DEBUG_CONSOLE - CDebugConsole::Get()->MsgOverwrite(0, "Converted [M%d / %d] KB", offset /1024, total_length / 1024 ); - CDebugConsole::Get()->MsgOverwriteEnd(); -#endif - - fclose( fh ); - delete [] p_temp_buffer; - - if( failed ) - { - messages << "Failed to decompress rom to '" << temp_filename.c_str() << "' - out of disk space?\n"; - } - else - { - // - // Open the newly created file - // - - if( p_new_file == nullptr ) - { - messages << "Failed to open temporary rom '" << temp_filename.c_str() << "' we just created\n"; - } - else - { - if( !p_new_file->Open( messages ) ) - { - messages << "Failed to open temporary rom '" << temp_filename.c_str() << "' we just created\n"; - p_new_file = nullptr; - } - } - } - } - - return p_new_file; - } -#endif -} - - -bool RomBuffer::Create() -{ - // Create memory heap used for either ROM Cache or ROM buffer - // We do this to avoid memory fragmentation - CROMFileMemory::Create(); - return true; -} - - -void RomBuffer::Destroy() -{ - -} - - -bool RomBuffer::Open() -{ - CNullOutputStream messages; - const std::filesystem::path &filename = g_ROM.mFileName; - auto p_rom_file = ROMFile::Create( filename.c_str() ); - if(p_rom_file == nullptr) - { - DBGConsole_Msg(0, "Failed to create [C%s]\n", filename.string().c_str()); - return false; - } - - if( !p_rom_file->Open( messages ) ) - { - - DBGConsole_Msg(0, "Failed to open [C%s]\n", filename.string().c_str()); - return false; - } - - sRomSize = p_rom_file->GetRomSize(); - - if( ShouldLoadAsFixed( sRomSize ) ) - { - // Now, allocate memory for rom - round up to a 4 byte boundry - u32 size_aligned = AlignPow2( sRomSize, 4 ); - u8 * p_bytes = (u8*)CROMFileMemory::Get()->Alloc( size_aligned ); - -#ifndef DAEDALUS_PSP - if( !p_rom_file->LoadData( sRomSize, p_bytes, messages ) ) - { - #ifdef DAEDALUS_DEBUG_CONSOLE - DBGConsole_Msg(0, "Failed to load [C%s]\n", filename.c_str()); - #endif - CROMFileMemory::Get()->Free( p_bytes ); - return false; - } -#else - u32 offset = 0; - u32 length_remaining( sRomSize ); - const u32 TEMP_BUFFER_SIZE = 128 * 1024; - #ifdef INTRAFONT - intraFont* ltn8 = intraFontLoad( "flash0:/font/ltn8.pgf", INTRAFONT_CACHE_ASCII); - intraFontSetStyle( ltn8, 1.5f, 0xFFFFFFFF, 0, 0.f, INTRAFONT_ALIGN_CENTER ); - #endif - while( offset < sRomSize ) - { - u32 length_to_process( std::min( length_remaining, TEMP_BUFFER_SIZE ) ); - - if( !p_rom_file->ReadChunk( offset, p_bytes + offset, length_to_process ) ) - { - break; - } - - offset += length_to_process; - length_remaining -= length_to_process; - - CGraphicsContext::Get()->BeginFrame(); - CGraphicsContext::Get()->ClearToBlack(); - #ifdef INTRAFONT - intraFontPrintf( ltn8, 480/2, (272>>1), "Buffering ROM %d%%...", offset * 100 / sRomSize ); - #endif - CGraphicsContext::Get()->EndFrame(); - CGraphicsContext::Get()->UpdateFrame( false ); - } - #ifdef INTRAFONT - intraFontUnload( ltn8 ); - #endif -#endif - spRomData = p_bytes; - sRomFixed = true; - - } - else - { -#ifdef DAEDALUS_COMPRESSED_ROM_SUPPORT - if(DECOMPRESS_ROMS) - { - bool compressed( p_rom_file->IsCompressed() ); - bool byteswapped( p_rom_file->RequiresSwapping() ); - if(compressed)// || byteswapped) - { - const char * temp_filename( "daedrom.tmp" ); - - #ifdef DAEDALUS_DEBUG_CONSOLE - if(compressed && byteswapped) - { - DBGConsole_Msg( 0, "Rom is [Mcompressed] and [Mbyteswapped]" ); - } - else if(compressed) - { - DBGConsole_Msg( 0, "Rom is [Mcompressed]" ); - } - else - { - DBGConsole_Msg( 0, "Rom is [Mbyteswapped]" ); - } - DBGConsole_Msg( 0, "Decompressing rom to [C%s] (this may take some time)", temp_filename ); - #endif - CNullOutputStream local_messages; - - auto p_new_file = DecompressRom( p_rom_file, temp_filename, local_messages ); - #ifdef DAEDALUS_DEBUG_CONSOLE - DBGConsole_Msg( 0, "messages:\n%s", local_messages.c_str() ); - #endif - messages << local_messages; - - if(p_new_file != nullptr) - { - #ifdef DAEDALUS_DEBUG_CONSOLE - DBGConsole_Msg( 0, "Decompression [gsuccessful]. Booting using decompressed rom" ); - #endif - p_rom_file = p_new_file; - } - #ifdef DAEDALUS_DEBUG_CONSOLE - else - { - DBGConsole_Msg( 0, "Decompression [rfailed]. Booting using original rom" ); - } - #endif - } - } -#endif - spRomFileCache = std::make_unique(); - spRomFileCache->Open(std::move(p_rom_file )); - sRomFixed = false; - } - - DBGConsole_Msg(0, "Opened [C%s]\n", filename.string().c_str()); - sRomLoaded = true; - return true; -} - - -void RomBuffer::Close() -{ - if (spRomData) - { - CROMFileMemory::Get()->Free( spRomData ); - spRomData = nullptr; - } - - if (spRomFileCache) - { - spRomFileCache->Close(); - } - - sRomSize = 0; - sRomLoaded = false; - sRomFixed = false; - sRomWritten = false; - sRomValue = 0; -} - -bool RomBuffer::IsRomLoaded() { return sRomLoaded; } -u32 RomBuffer::GetRomSize() { return sRomSize; } - -namespace -{ - void CopyBytesRaw( std::shared_ptr p_cache, u8 * p_dst, u32 rom_offset, u32 length ) - { - // Read the cached bytes into our scratch buffer, and return that - u32 dst_offset( 0 ); - u32 src_offset( rom_offset ); - - // Similar algorithm to below - we don't care about byte swapping though - while(length > 0) - { - u8 * p_chunk_base = 0; - u32 chunk_offset = 0; - u32 chunk_size = 0; - - if( !p_cache->GetChunk( src_offset, &p_chunk_base, &chunk_offset, &chunk_size ) ) - { - // Out of range - break; - } - - // Calculate how many bytes we can transfer this pass - u32 offset_into_chunk( src_offset - chunk_offset ); - u32 bytes_remaining_in_chunk( chunk_size - offset_into_chunk ); - u32 bytes_this_pass( std::min( length, bytes_remaining_in_chunk ) ); - - DAEDALUS_ASSERT( s32( bytes_this_pass ) > 0, "How come we're trying to copy <= 0 bytes across?" ); - - // Copy this chunk across - memcpy( p_dst + dst_offset, p_chunk_base + offset_into_chunk, bytes_this_pass ); - - // Update the src/dst pointers and reduce length by the number of copied bytes - dst_offset += bytes_this_pass; - src_offset += bytes_this_pass; - length -= bytes_this_pass; - } - } -} - - -void RomBuffer::GetRomBytesRaw( void * p_dst, u32 rom_start, u32 length ) -{ - if( sRomFixed ) - { - memcpy(p_dst, (const u8*)spRomData + rom_start, length ); - } - else - { - DAEDALUS_ASSERT( spRomFileCache != nullptr, "How come we have no file cache?" ); - - CopyBytesRaw( spRomFileCache, reinterpret_cast< u8 * >( p_dst ), rom_start, length ); - } -} - - -void RomBuffer::SaveRomValue( u32 value ) -{ - sRomWritten = true; - sRomValue = value; -} - - -void RomBuffer::PutRomBytesRaw( u32 rom_start, const void * p_src, u32 length ) -{ - DAEDALUS_ASSERT( sRomFixed, "Cannot put rom bytes when the data isn't fixed" ); - memcpy( (u8*)spRomData + rom_start, p_src, length ); -} - - -void * RomBuffer::GetAddressRaw( u32 rom_start ) -{ - if (sRomWritten) - { - sRomWritten = false; - - return (u8 *)&sRomValue; - } - - if( rom_start < sRomSize ) - { - if( sRomFixed ) - { - return (u8 *)spRomData + rom_start; - } - else - { - // Read the cached bytes into our scratch buffer, and return that - DAEDALUS_ASSERT( spRomFileCache != nullptr, "How come we have no file cache?" ); - CopyBytesRaw( spRomFileCache, sScratchBuffer, rom_start, SCRATCH_BUFFER_LENGTH ); - - return sScratchBuffer; - } - } - - return nullptr; -} - - -bool RomBuffer::CopyToRam( u8 * p_dst, u32 dst_offset, u32 dst_size, u32 src_offset, u32 length ) -{ - if( sRomFixed ) - { - const u8* p_src = (const u8 *)spRomData ; - u32 src_size = sRomSize; - - return DMA_HandleTransfer( p_dst, dst_offset, dst_size, p_src, src_offset, src_size, length ); - } - else - { - while(length > 0) - { - u8 * p_chunk_base = 0; - u32 chunk_offset = 0; - u32 chunk_size = 0; - - if( !spRomFileCache->GetChunk( src_offset, &p_chunk_base, &chunk_offset, &chunk_size ) ) - { - // Out of range - break; - } - - // Calculate how many bytes we can transfer this pass - u32 offset_into_chunk( src_offset - chunk_offset ); - u32 bytes_remaining_in_chunk( chunk_size - offset_into_chunk ); - u32 bytes_this_pass( std::min( length, bytes_remaining_in_chunk ) ); - - DAEDALUS_ASSERT( s32( bytes_this_pass ) > 0, "How come we're trying to copy <= 0 bytes across?" ); - - // Copy this chunk across - if( !DMA_HandleTransfer( p_dst, dst_offset, dst_size, p_chunk_base, offset_into_chunk, chunk_size, bytes_this_pass ) ) - { - break; - } - - // Update the src/dst pointers and reduce length by the number of copied bytes - dst_offset += bytes_this_pass; - src_offset += bytes_this_pass; - length -= bytes_this_pass; - } - return length == 0; - } -} - - -bool RomBuffer::CopyFromRam( u32 dst_offset, const u8 * p_src, u32 src_offset, u32 src_size, u32 length ) -{ - if( sRomFixed ) - { - u8 * p_dst = (u8 *)spRomData; - u32 dst_size = sRomSize; - - return DMA_HandleTransfer( p_dst, dst_offset, dst_size, p_src, src_offset, src_size, length ); - } - else - { - DAEDALUS_ERROR( "Cannot put rom bytes when the data isn't fixed" ); - return false; - } -} - - -bool RomBuffer::IsRomAddressFixed() -{ - return sRomFixed; -} - - -const void * RomBuffer::GetFixedRomBaseAddress() -{ - DAEDALUS_ASSERT( sRomLoaded, "The rom isn't loaded" ); - DAEDALUS_ASSERT( sRomFixed, "Trying to access the rom base address when it's not fixed" ); - - return spRomData; -} diff --git a/Source/Core/RSP_HLE.cpp b/Source/Core/RSP_HLE.cpp index 5df66276..a2eb54c6 100644 --- a/Source/Core/RSP_HLE.cpp +++ b/Source/Core/RSP_HLE.cpp @@ -35,9 +35,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Ultra/ultra_sptask.h" #include "HLEAudio/AudioPlugin.h" #include "HLEGraphics/GraphicsPlugin.h" -#include "Test/BatchTest.h" +#include "Utility/BatchTest.h" -#include "Core/PrintOpCode.h" +#include "Debug/PrintOpCode.h" #include "Utility/Profiler.h" static const bool gGraphicsEnabled = true; diff --git a/Source/Core/RomSettings.cpp b/Source/Core/RomSettings.cpp deleted file mode 100644 index a5e902ae..00000000 --- a/Source/Core/RomSettings.cpp +++ /dev/null @@ -1,514 +0,0 @@ -/* -Copyright (C) 2001 CyRUS64 (http://www.boob.co.uk) -Copyright (C) 2006,2007 StrmnNrmn - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - - -#include "Base/Types.h" - - -#include - -#include -#include -#include -#include -#include - -#include "Core/ROM.h" -#include "Core/RomSettings.h" -#include "Debug/DBGConsole.h" -#include "Interface/RomDB.h" -#include "Utility/IniFile.h" -#include "Utility/Paths.h" - -namespace -{ -// - -EExpansionPakUsage ExpansionPakUsageFromString( const char * str ) -{ - for( u32 i = 0; i < NUM_EXPANSIONPAK_USAGE_TYPES; ++i ) - { - EExpansionPakUsage pak_usage = EExpansionPakUsage( i ); - - if( strcasecmp( str, ROM_GetExpansionPakUsageName( pak_usage ) ) == 0 ) - { - return pak_usage; - } - } - - return PAK_STATUS_UNKNOWN; -} - -ESaveType SaveTypeFromString( const char * str ) -{ - for( u32 i = 0; i < NUM_SAVE_TYPES; ++i ) - { - ESaveType save_type = ESaveType( i ); - - if( strcasecmp( str, ROM_GetSaveTypeName( save_type ) ) == 0 ) - { - return save_type; - } - } - - return SAVE_TYPE_UNKNOWN; -} - -} - - -// - -const char * ROM_GetExpansionPakUsageName( EExpansionPakUsage pak_usage ) -{ - switch( pak_usage ) - { - case PAK_STATUS_UNKNOWN: return "Unknown"; - case PAK_UNUSED: return "Unused"; - case PAK_USED: return "Used"; - case PAK_REQUIRED: return "Required"; - } - -#ifdef DAEDALUS_DEBUG_CONSOLE - DAEDALUS_ERROR( "Unknown expansion pak type" ); - #endif - return "?"; -} - - -// Get the name of a save type from an ESaveType enum - -const char * ROM_GetSaveTypeName( ESaveType save_type ) -{ - switch ( save_type ) - { - case SAVE_TYPE_UNKNOWN: return "Unknown"; - case SAVE_TYPE_EEP4K: return "Eeprom4k"; - case SAVE_TYPE_EEP16K: return "Eeprom16k"; - case SAVE_TYPE_SRAM: return "SRAM"; - case SAVE_TYPE_FLASH: return "FlashRam"; - } -#ifdef DAEDALUS_DEBUG_CONSOLE - DAEDALUS_ERROR( "Unknown save type" ); - #endif - return "?"; -} - - -// - -class IRomSettingsDB : public CRomSettingsDB -{ - public: - IRomSettingsDB(); - virtual ~IRomSettingsDB(); - - // - // CRomSettingsDB implementation - // - bool OpenSettingsFile( const std::filesystem::path &filename ); - void Commit(); // (STRMNNRMN - Write ini back out to disk?) - - bool GetSettings( const RomID & id, RomSettings * p_settings ) const; - void SetSettings( const RomID & id, const RomSettings & settings ); - - private: - - void OutputSectionDetails( const RomID & id, const RomSettings & settings, std::ostream &fh ); - - private: - using SettingsMap = std::map; - SettingsMap mSettings; - - bool mDirty; // (STRMNNRMN - Changed since read from disk?) - const std::filesystem::path mFilename; -}; - - - - -// Singleton creator - -template<> bool CSingleton< CRomSettingsDB >::Create() -{ - #ifdef DAEDALUS_ENABLE_ASSERTS - DAEDALUS_ASSERT_Q(mpInstance == nullptr); - #endif - mpInstance = std::make_shared(); - mpInstance->OpenSettingsFile( setBasePath("roms.ini") ); - return true; -} - - -IRomSettingsDB::IRomSettingsDB() : mDirty( false ) {} - - -IRomSettingsDB::~IRomSettingsDB() -{ - // if ( mDirty ) - // { - // Commit(); - // } -} - - -// Remove the specified characters from p_string -static bool trim( char * p_string, const char * p_trim_chars ) -{ - u32 num_trims = (u32)strlen( p_trim_chars ); - char * pin = p_string; - char * pout = p_string; - bool found = false; - while ( *pin ) - { - char c = *pin; - - found = false; - for ( u32 i = 0; i < num_trims; i++ ) - { - if ( p_trim_chars[ i ] == c ) - { - // Skip - found = true; - break; - } - } - - if ( found ) - { - pin++; - } - else - { - // Copy - *pout++ = *pin++; - } - } - *pout = '\0'; - return true; -} - - -// - -static RomID RomIDFromString( const char * str ) -{ - u32 crc1, crc2, country; - sscanf( str, "%08x%08x-%02x", &crc1, &crc2, &country ); - return RomID( crc1, crc2, (u8)country ); -} - -bool IRomSettingsDB::OpenSettingsFile( const std::filesystem::path &filename ) -{ - - std::filesystem::path mFilename = setBasePath(filename); - - auto p_ini_file = CIniFile::Create(filename); - if( p_ini_file == nullptr ) - { - DBGConsole_Msg( 0, "Failed to open roms.ini from %s\n", filename.c_str() ); - return false; - } - - for( u32 section_idx = 0; section_idx < p_ini_file->GetNumSections(); ++section_idx ) - { - const CIniFileSection * p_section( p_ini_file->GetSection( section_idx ) ); - - RomID id( RomIDFromString( p_section->GetName() ) ); - RomSettings settings; - - const CIniFileProperty * p_property; - if( p_section->FindProperty( "Comment", &p_property ) ) - { - settings.Comment = p_property->GetValue(); - } - if( p_section->FindProperty( "Info", &p_property ) ) - { - settings.Info = p_property->GetValue(); - } - if( p_section->FindProperty( "Name", &p_property ) ) - { - settings.GameName = p_property->GetValue(); - } - if( p_section->FindProperty( "Preview", &p_property ) ) - { - settings.Preview = p_property->GetValue(); - } - if( p_section->FindProperty( "ExpansionPakUsage", &p_property ) ) - { - settings.ExpansionPakUsage = ExpansionPakUsageFromString( p_property->GetValue() ); - } - if( p_section->FindProperty( "SaveType", &p_property ) ) - { - settings.SaveType = SaveTypeFromString( p_property->GetValue() ); - } - if( p_section->FindProperty( "PatchesEnabled", &p_property ) ) - { - settings.PatchesEnabled = p_property->GetBooleanValue( true ); - } - if( p_section->FindProperty( "SpeedSyncEnabled", &p_property ) ) - { - settings.SpeedSyncEnabled = atoi( p_property->GetValue() ); - } - if( p_section->FindProperty( "DynarecSupported", &p_property ) ) - { - settings.DynarecSupported = p_property->GetBooleanValue( true ); - } - if( p_section->FindProperty( "DynarecLoopOptimisation", &p_property ) ) - { - settings.DynarecLoopOptimisation = p_property->GetBooleanValue( false ); - } - if( p_section->FindProperty( "DynarecDoublesOptimisation", &p_property ) ) - { - settings.DynarecDoublesOptimisation = p_property->GetBooleanValue( false ); - } - if( p_section->FindProperty( "DoubleDisplayEnabled", &p_property ) ) - { - settings.DoubleDisplayEnabled = p_property->GetBooleanValue( true ); - } - if( p_section->FindProperty( "CleanSceneEnabled", &p_property ) ) - { - settings.CleanSceneEnabled = p_property->GetBooleanValue( false ); - } - if( p_section->FindProperty( "ClearDepthFrameBuffer", &p_property ) ) - { - settings.ClearDepthFrameBuffer = p_property->GetBooleanValue( false ); - } - if( p_section->FindProperty( "AudioRateMatch", &p_property ) ) - { - settings.AudioRateMatch = p_property->GetBooleanValue( false ); - } - if( p_section->FindProperty( "VideoRateMatch", &p_property ) ) - { - settings.VideoRateMatch = p_property->GetBooleanValue( false ); - } - if( p_section->FindProperty( "FogEnabled", &p_property ) ) - { - settings.FogEnabled = p_property->GetBooleanValue( false ); - } - if( p_section->FindProperty( "MemoryAccessOptimisation", &p_property ) ) - { - settings.MemoryAccessOptimisation = p_property->GetBooleanValue( false ); - } - if( p_section->FindProperty( "CheatsEnabled", &p_property ) ) - { - settings.CheatsEnabled = p_property->GetBooleanValue( false ); - } - SetSettings( id, settings ); - } - - mDirty = false; - - return true; -} - -// // Write out the .ini file, keeping the original comments intact -void IRomSettingsDB::Commit(){} -// mFilename = "roms.ini"; - - -// std::filesystem::path filename_tmp = "roms.ini.tmp"; - -// std::fstream fh_src(mFilename, std::ios::in); -// if (!fh_src) -// { -// std::cerr << mFilename << " : Does not exist"; -// return; -// } -// std::fstream fh_dst(filename_tmp, std::ios::out); - - -// // Keep track of visited sections in a set -// std::set visited; - -// std::string line; -// while (std::getline(fh_src, line)) -// { -// if (line[0] == '{') -// { -// const char * const trim_chars = "{}\n\r"; //remove first and last character -// char buffer[1024 + 1]; -// std::strncpy(buffer, line.c_str(), sizeof(buffer) -1); -// buffer[sizeof(buffer) - 1 ] = '\0'; - -// // Start of section -// trim( buffer, trim_chars ); - -// RomID id( RomIDFromString( buffer ) ); - -// // Avoid duplicated entries for this id -// if ( visited.find( id ) != visited.end() ) -// continue; - -// visited.insert( id ); - -// SettingsMap::const_iterator it( mSettings.find( id ) ); -// if( it != mSettings.end() ) -// { -// // Output this CRC -// OutputSectionDetails( id, it->second, fh_dst ); -// } -// else -// { -// // Do what? This should never happen, unless the user -// // replaces the inifile while Daedalus is running! -// } -// } -// else if (line[0] == '/') -// { -// // Skip Comment -// fh_dst << line << '\n'; -// continue; -// } -// } -// for (const auto& [id, settings] : mSettings) -// { -// // Skip any that have not been done. -// if ( visited.find( id) == visited.end() ) -// { -// OutputSectionDetails( id, settings, fh_dst ); -// } -// } - - -// // Create the new file -// std::filesystem::remove(mFilename); -// std::filesystem::rename(filename_tmp, mFilename); - -// mDirty = false; - -// } - - -void IRomSettingsDB::OutputSectionDetails( const RomID & id, const RomSettings & settings, std::ostream &out ) -{ - // Generate the CRC-ID for this rom - out << "{" << std::hex << std::uppercase << id.CRC[0] << std::hex << std::uppercase << id.CRC[1] << "-" - << std::dec << std::setfill('0') << std::setw(2) << id.CountryID << "}\n"; - - out << "Name=" << settings.GameName << "\n"; - - if (!settings.Comment.empty()) out << "Comment=" << settings.Comment << "\n"; - if (!settings.Info.empty()) out << "Info=" << settings.Info << "\n"; - if (!settings.Preview.empty()) out << "Preview=" << settings.Preview << "\n"; - if (!settings.PatchesEnabled) out << "PatchesEnabled=no\n"; - if (!settings.SpeedSyncEnabled) out << "SpeedSyncEnabled=" << settings.SpeedSyncEnabled << "\n"; - if (!settings.DynarecSupported) out << "DynarecSupported=no\n"; - if (settings.DynarecLoopOptimisation) out << "DynarecLoopOptimisation=yes\n"; - if (settings.DynarecDoublesOptimisation) out << "DynarecDoublesOptimisation=yes\n"; - if (!settings.DoubleDisplayEnabled) out << "DoubleDisplayEnabled=no\n"; - if (settings.CleanSceneEnabled) out << "CleanSceneEnabled=yes\n"; - if (settings.ClearDepthFrameBuffer) out << "ClearDepthFrameBuffer=yes\n"; - if (settings.AudioRateMatch) out << "AudioRateMatch=yes\n"; - if (settings.VideoRateMatch) out << "VideoRateMatch=yes\n"; - if (settings.FogEnabled) out << "FogEnabled=yes\n"; - if (settings.MemoryAccessOptimisation) out << "MemoryAccessOptimisation=yes\n"; - if (settings.CheatsEnabled) out << "CheatsEnabled=yes\n"; - - if (settings.ExpansionPakUsage != PAK_STATUS_UNKNOWN) - out << "ExpansionPakUsage=" << ROM_GetExpansionPakUsageName(settings.ExpansionPakUsage) << "\n"; - if (settings.SaveType != SAVE_TYPE_UNKNOWN) - out << "SaveType=" << ROM_GetSaveTypeName(settings.SaveType) << "\n"; - - out << "\n"; // Spacer -} - - -// Retreive the settings for the specified rom. Returns false if the rom is -// not in the database -bool IRomSettingsDB::GetSettings( const RomID & id, RomSettings * p_settings ) const -{ - for ( SettingsMap::const_iterator it = mSettings.begin(); it != mSettings.end(); ++it ) - { - if ( it->first == id ) - { - *p_settings = it->second; - return true; - } - } - - return false; -} - - -// Update the settings for the specified rom - creates a new entry if necessary -void IRomSettingsDB::SetSettings( const RomID & id, const RomSettings & settings ) -{ - for ( SettingsMap::iterator it = mSettings.begin(); it != mSettings.end(); ++it ) - { - if ( it->first == id ) - { - it->second = settings; - return; - } - } - - mSettings[id] = settings; - mDirty = true; -} - - -// - -RomSettings::RomSettings() -: ExpansionPakUsage( PAK_STATUS_UNKNOWN ) -, SaveType( SAVE_TYPE_UNKNOWN ) -, PatchesEnabled( true ) -, SpeedSyncEnabled( 1 ) -, DynarecSupported( true ) -, DynarecLoopOptimisation( false ) -, DynarecDoublesOptimisation( false ) -, DoubleDisplayEnabled( true ) -, CleanSceneEnabled( false ) -, ClearDepthFrameBuffer( false ) -, AudioRateMatch( false ) -, VideoRateMatch( false ) -, FogEnabled( false ) -, MemoryAccessOptimisation( false ) -, CheatsEnabled( false ) -{ -} - - -// - -RomSettings::~RomSettings() {} - -void RomSettings::Reset() -{ - GameName = ""; - Comment = ""; - Info = ""; - ExpansionPakUsage = PAK_STATUS_UNKNOWN; - SaveType = SAVE_TYPE_UNKNOWN; - PatchesEnabled = true; - SpeedSyncEnabled = 0; - DynarecSupported = true; - DynarecLoopOptimisation = false; - DynarecDoublesOptimisation = false; - DoubleDisplayEnabled = true; - CleanSceneEnabled = false; - ClearDepthFrameBuffer = false; - AudioRateMatch = false; - VideoRateMatch = false; - FogEnabled = false; - CheatsEnabled = false; - MemoryAccessOptimisation = false; -} diff --git a/Source/Core/Save.cpp b/Source/Core/Save.cpp index 23b9365e..b9b76ff0 100644 --- a/Source/Core/Save.cpp +++ b/Source/Core/Save.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/ROM.h" #include "Core/Memory.h" #include "Core/Save.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "Debug/Dump.h" #include "Utility/Paths.h" diff --git a/Source/Debug/CMakeLists.txt b/Source/Debug/CMakeLists.txt index c4446bb1..a3994840 100644 --- a/Source/Debug/CMakeLists.txt +++ b/Source/Debug/CMakeLists.txt @@ -2,6 +2,8 @@ add_library(Debug OBJECT DebugConsoleImpl.cpp DebugLog.cpp Dump.cpp + PrintOpCode.cpp + Registers.cpp Synchroniser.cpp ) diff --git a/Source/Debug/DebugLog.cpp b/Source/Debug/DebugLog.cpp index eb9b031a..72207bdf 100644 --- a/Source/Debug/DebugLog.cpp +++ b/Source/Debug/DebugLog.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include - +#include "Utility/Paths.h" #ifdef DAEDALUS_LOG @@ -50,15 +50,15 @@ bool Debug_InitLogging() void Debug_FinishLogging() {} -void Debug_Print(const char* format, ...) -{ - va_list args; - va_start(args, format); - std::string formattedString = std::vformat(format, std::make_format_args(args)); - va_end(args); +// void Debug_Print(const char* format, ...) +// { +// va_list args; +// va_start(args, format); +// std::string formattedString = std::vformat(format, std::make_format_args(args)); +// va_end(args); - g_hOutputLog << formattedString << '\n'; -} +// g_hOutputLog << formattedString << '\n'; +// } diff --git a/Source/Debug/Dump.cpp b/Source/Debug/Dump.cpp index b4e3fafe..2e9eff9e 100644 --- a/Source/Debug/Dump.cpp +++ b/Source/Debug/Dump.cpp @@ -28,18 +28,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/Interrupt.h" #include "Core/Memory.h" -#include "Core/ROMBuffer.h" +#include "RomFile/ROMBuffer.h" #include "Debug/Dump.h" #include "Debug/DebugLog.h" #include "Debug/DBGConsole.h" #include "OSHLE/patch.h" // For GetCorrectOp #include "Ultra/ultra_R4300.h" -#include "Core/PrintOpCode.h" +#include "Debug/PrintOpCode.h" const std::filesystem::path gDumpDir = "Dumps"; diff --git a/Source/Core/PrintOpCode.cpp b/Source/Debug/PrintOpCode.cpp similarity index 99% rename from Source/Core/PrintOpCode.cpp rename to Source/Debug/PrintOpCode.cpp index 1f65bf17..e0e922ff 100644 --- a/Source/Core/PrintOpCode.cpp +++ b/Source/Debug/PrintOpCode.cpp @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Code to format opcodes and display them nicely #include "Base/Types.h" -#include "Core/PrintOpCode.h" +#include "Debug/PrintOpCode.h" // // Exclude this from public release builds to save a little on the elf size diff --git a/Source/Core/PrintOpCode.h b/Source/Debug/PrintOpCode.h similarity index 100% rename from Source/Core/PrintOpCode.h rename to Source/Debug/PrintOpCode.h diff --git a/Source/Core/Registers.cpp b/Source/Debug/Registers.cpp similarity index 100% rename from Source/Core/Registers.cpp rename to Source/Debug/Registers.cpp diff --git a/Source/Core/Registers.h b/Source/Debug/Registers.h similarity index 100% rename from Source/Core/Registers.h rename to Source/Debug/Registers.h diff --git a/Source/DynaRec/ARM/CodeGeneratorARM.cpp b/Source/DynaRec/ARM/CodeGeneratorARM.cpp index cb8a3697..1763ff8c 100644 --- a/Source/DynaRec/ARM/CodeGeneratorARM.cpp +++ b/Source/DynaRec/ARM/CodeGeneratorARM.cpp @@ -23,10 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/R4300.h" -#include "Core/Registers.h" +#include "Debug/Registers.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" #include "DynaRec/AssemblyUtils.h" diff --git a/Source/DynaRec/CMakeLists.txt b/Source/DynaRec/CMakeLists.txt index 5c087ebf..017bcc8c 100644 --- a/Source/DynaRec/CMakeLists.txt +++ b/Source/DynaRec/CMakeLists.txt @@ -15,6 +15,7 @@ endif() add_library(DynaRec OBJECT ${SRC_FILES} BranchType.cpp + Dynamo.cpp DynaRecProfile.cpp Fragment.cpp FragmentCache.cpp diff --git a/Source/Core/Dynamo.cpp b/Source/DynaRec/Dynamo.cpp similarity index 96% rename from Source/Core/Dynamo.cpp rename to Source/DynaRec/Dynamo.cpp index 1fa2ffba..2475f94b 100644 --- a/Source/Core/Dynamo.cpp +++ b/Source/DynaRec/Dynamo.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "Base/Types.h" -#include "Core/Dynamo.h" +#include "DynaRec/Dynamo.h" @@ -31,8 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/Memory.h" #include "Core/Interrupt.h" #include "Core/R4300.h" -#include "Core/Registers.h" -#include "Config/ConfigOptions.h" +#include "Debug/Registers.h" +#include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" #include "DynaRec/DynaRecProfile.h" diff --git a/Source/Core/Dynamo.h b/Source/DynaRec/Dynamo.h similarity index 100% rename from Source/Core/Dynamo.h rename to Source/DynaRec/Dynamo.h diff --git a/Source/DynaRec/Fragment.cpp b/Source/DynaRec/Fragment.cpp index 698b4c59..5913bb1a 100644 --- a/Source/DynaRec/Fragment.cpp +++ b/Source/DynaRec/Fragment.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include "Core/Registers.h" +#include "Debug/Registers.h" #include "Core/CPU.h" // Try to remove this cyclic dependency #include "Core/R4300.h" #include "Core/Interrupt.h" @@ -38,7 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "DynaRec/IndirectExitMap.h" #include "DynaRec/StaticAnalysis.h" #include "Base/Macros.h" -#include "Core/PrintOpCode.h" +#include "Debug/PrintOpCode.h" #include "Utility/Profiler.h" #include "Debug/Synchroniser.h" diff --git a/Source/DynaRec/TraceRecorder.cpp b/Source/DynaRec/TraceRecorder.cpp index 4449e2a6..6881359e 100644 --- a/Source/DynaRec/TraceRecorder.cpp +++ b/Source/DynaRec/TraceRecorder.cpp @@ -22,13 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/CPU.h" // For dubious use of PC/NewPC -#include "Core/Registers.h" +#include "Debug/Registers.h" #include "Debug/DBGConsole.h" #include "DynaRec/BranchType.h" #include "DynaRec/Fragment.h" #include "DynaRec/TraceRecorder.h" #include "Utility/Profiler.h" -#include "Core/PrintOpCode.h" +#include "Debug/PrintOpCode.h" #include namespace diff --git a/Source/DynaRec/mips/AssemblyWriterPSP.cpp b/Source/DynaRec/mips/AssemblyWriterPSP.cpp index c195dd1a..01c240ab 100644 --- a/Source/DynaRec/mips/AssemblyWriterPSP.cpp +++ b/Source/DynaRec/mips/AssemblyWriterPSP.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" #include "AssemblyWriterPSP.h" -#include "Core/Registers.h" +#include "Debug/Registers.h" #include "Ultra/ultra_R4300.h" diff --git a/Source/DynaRec/mips/CodeGeneratorPSP.cpp b/Source/DynaRec/mips/CodeGeneratorPSP.cpp index 575574e2..c7f4dad0 100644 --- a/Source/DynaRec/mips/CodeGeneratorPSP.cpp +++ b/Source/DynaRec/mips/CodeGeneratorPSP.cpp @@ -23,11 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/Memory.h" #include "Core/R4300.h" -#include "Core/Registers.h" +#include "Debug/Registers.h" #include "Core/ROM.h" #include "Debug/DBGConsole.h" #include "DynaRec/AssemblyUtils.h" @@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Ultra/ultra_R4300.h" #include "CodeGeneratorPSP.h" #include "Base/Macros.h" -#include "Core/PrintOpCode.h" +#include "Debug/PrintOpCode.h" #include "Utility/Profiler.h" using namespace AssemblyUtils; diff --git a/Source/DynaRec/x64/CodeGeneratorX64.cpp b/Source/DynaRec/x64/CodeGeneratorX64.cpp index 408ca091..bc25d282 100644 --- a/Source/DynaRec/x64/CodeGeneratorX64.cpp +++ b/Source/DynaRec/x64/CodeGeneratorX64.cpp @@ -22,10 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/R4300.h" -#include "Core/Registers.h" +#include "Debug/Registers.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" #include "DynaRec/AssemblyUtils.h" diff --git a/Source/DynaRec/x86/CodeGeneratorX86.cpp b/Source/DynaRec/x86/CodeGeneratorX86.cpp index 6da85327..8b5ed1a8 100644 --- a/Source/DynaRec/x86/CodeGeneratorX86.cpp +++ b/Source/DynaRec/x86/CodeGeneratorX86.cpp @@ -22,10 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/R4300.h" -#include "Core/Registers.h" +#include "Debug/Registers.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" #include "DynaRec/AssemblyUtils.h" diff --git a/Source/Graphics/CMakeLists.txt b/Source/Graphics/CMakeLists.txt index 5a8e42df..310e99cd 100644 --- a/Source/Graphics/CMakeLists.txt +++ b/Source/Graphics/CMakeLists.txt @@ -1,5 +1,7 @@ add_library(Graphics OBJECT ColourValue.cpp + HvqmTask.cpp + JpegTask.cpp PngUtil.cpp TextureTransform.cpp ) diff --git a/Source/Core/HvqmTask.cpp b/Source/Graphics/HvqmTask.cpp similarity index 100% rename from Source/Core/HvqmTask.cpp rename to Source/Graphics/HvqmTask.cpp diff --git a/Source/Core/JpegTask.cpp b/Source/Graphics/JpegTask.cpp similarity index 100% rename from Source/Core/JpegTask.cpp rename to Source/Graphics/JpegTask.cpp diff --git a/Source/HLEAudio/AudioBuffer.cpp b/Source/HLEAudio/AudioBuffer.cpp index 5630ef54..3c019d28 100644 --- a/Source/HLEAudio/AudioBuffer.cpp +++ b/Source/HLEAudio/AudioBuffer.cpp @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "HLEAudio/AudioBuffer.h" #include "System/Thread.h" diff --git a/Source/HLEAudio/Plugin/AudioPluginNone.cpp b/Source/HLEAudio/Plugin/AudioPluginNone.cpp index 74abd452..4b1f07f4 100644 --- a/Source/HLEAudio/Plugin/AudioPluginNone.cpp +++ b/Source/HLEAudio/Plugin/AudioPluginNone.cpp @@ -1,7 +1,7 @@ #include "Base/Types.h" #include "HLEAudio/AudioPlugin.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" EAudioPluginMode gAudioPluginEnabled = APM_DISABLED; diff --git a/Source/HLEAudio/Plugin/CMakeLists.txt b/Source/HLEAudio/Plugin/CMakeLists.txt index 80c907c6..57c7172e 100644 --- a/Source/HLEAudio/Plugin/CMakeLists.txt +++ b/Source/HLEAudio/Plugin/CMakeLists.txt @@ -1,6 +1,6 @@ if(PSP) add_library(Audio_Plugin OBJECT PSP/AudioPluginPSP.cpp ) -elseif(DAEDLAUS_CTR) +elseif(DAEDALUS_CTR) add_library(Audio_Plugin OBJECT CTR/AudioOutput.cpp CTR/AudioPluginCTR.cpp) elseif(WIN32) add_library(Audio_Plugin OBJECT Windows/AudioPluginW32.cpp) diff --git a/Source/HLEAudio/Plugin/CTR/AudioOutput.cpp b/Source/HLEAudio/Plugin/CTR/AudioOutput.cpp index 28bff5f0..0e89778b 100644 --- a/Source/HLEAudio/Plugin/CTR/AudioOutput.cpp +++ b/Source/HLEAudio/Plugin/CTR/AudioOutput.cpp @@ -27,8 +27,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <3ds.h> #include -#include "Core/FramerateLimiter.h" -#include "Config/ConfigOptions.h" +#include "Utility/FramerateLimiter.h" +#include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "HLEAudio/AudioBuffer.h" diff --git a/Source/HLEAudio/Plugin/CTR/AudioPluginCTR.cpp b/Source/HLEAudio/Plugin/CTR/AudioPluginCTR.cpp index bc742443..141871fc 100644 --- a/Source/HLEAudio/Plugin/CTR/AudioPluginCTR.cpp +++ b/Source/HLEAudio/Plugin/CTR/AudioPluginCTR.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "HLEAudio/AudioPlugin.h" #include "HLEAudio/HLEAudioInternal.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/Interrupt.h" #include "Core/Memory.h" diff --git a/Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp b/Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp index 1fcbcd46..6f04d5b1 100644 --- a/Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp +++ b/Source/HLEAudio/Plugin/PSP/AudioPluginPSP.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/Interrupt.h" #include "Core/Memory.h" @@ -46,7 +46,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // #include "SysPSP/Utility/JobManager.h" #include "SysPSP/Utility/CacheUtil.h" // #include "SysPSP/Utility/JobManager.h" -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" #include "System/Thread.h" #ifdef DAEDALUS_PSP_USE_ME diff --git a/Source/HLEAudio/Plugin/PSP/AudioPluginPSP_SDL.cpp b/Source/HLEAudio/Plugin/PSP/AudioPluginPSP_SDL.cpp index ddcfb248..0afc35a8 100644 --- a/Source/HLEAudio/Plugin/PSP/AudioPluginPSP_SDL.cpp +++ b/Source/HLEAudio/Plugin/PSP/AudioPluginPSP_SDL.cpp @@ -1,15 +1,15 @@ #include "Base/Types.h" #include "HLEAudio/AudioPlugin.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/Memory.h" #include "Debug/DBGConsole.h" #include "HLEAudio/AudioBuffer.h" #include "HLEAudio/HLEAudioInternal.h" -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" #include "System/Thread.h" #include "System/Timing.h" diff --git a/Source/HLEAudio/Plugin/PSP/macOS/AudioPluginOSX.cpp b/Source/HLEAudio/Plugin/PSP/macOS/AudioPluginOSX.cpp index b37b4cb7..bdf77bbc 100644 --- a/Source/HLEAudio/Plugin/PSP/macOS/AudioPluginOSX.cpp +++ b/Source/HLEAudio/Plugin/PSP/macOS/AudioPluginOSX.cpp @@ -34,12 +34,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/Memory.h" #include "Debug/DBGConsole.h" #include "HLEAudio/AudioBuffer.h" #include "HLEAudio/HLEAudioInternal.h" -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" #include "System/Thread.h" #include "System/Timing.h" diff --git a/Source/HLEAudio/Plugin/PSP/old/AudioOutput.cpp b/Source/HLEAudio/Plugin/PSP/old/AudioOutput.cpp index 23717870..ff82d831 100644 --- a/Source/HLEAudio/Plugin/PSP/old/AudioOutput.cpp +++ b/Source/HLEAudio/Plugin/PSP/old/AudioOutput.cpp @@ -34,12 +34,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "HLEAudio/AudioBuffer.h" #include "SysPSP/Utility/CacheUtil.h" #include "SysPSP/Utility/JobManager.h" -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" #include "System/Thread.h" extern u32 gSoundSync; diff --git a/Source/HLEAudio/Plugin/PSP/old/AudioPluginPSP.cpp b/Source/HLEAudio/Plugin/PSP/old/AudioPluginPSP.cpp index 8641eda7..5be42d4b 100644 --- a/Source/HLEAudio/Plugin/PSP/old/AudioPluginPSP.cpp +++ b/Source/HLEAudio/Plugin/PSP/old/AudioPluginPSP.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "AudioOutput.h" #include "HLEAudio/HLEAudioInternal.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/Interrupt.h" #include "Core/Memory.h" diff --git a/Source/HLEAudio/Plugin/SDL/AudioPluginSDL.cpp b/Source/HLEAudio/Plugin/SDL/AudioPluginSDL.cpp index 024d057a..46a9e20a 100644 --- a/Source/HLEAudio/Plugin/SDL/AudioPluginSDL.cpp +++ b/Source/HLEAudio/Plugin/SDL/AudioPluginSDL.cpp @@ -3,8 +3,8 @@ #include "Base/Types.h" -#include "Config/ConfigOptions.h" -#include "Core/FramerateLimiter.h" +#include "Interface/ConfigOptions.h" +#include "Utility/FramerateLimiter.h" #include "Core/Memory.h" #include "Debug/DBGConsole.h" #include "HLEAudio/AudioPlugin.h" diff --git a/Source/HLEAudio/Plugin/Windows/AudioPluginW32.cpp b/Source/HLEAudio/Plugin/Windows/AudioPluginW32.cpp index 7ede169e..355aee3b 100644 --- a/Source/HLEAudio/Plugin/Windows/AudioPluginW32.cpp +++ b/Source/HLEAudio/Plugin/Windows/AudioPluginW32.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" #include "HLEAudio/AudioPlugin.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/Interrupt.h" #include "Core/Memory.h" diff --git a/Source/HLEGraphics/CachedTexture.cpp b/Source/HLEGraphics/CachedTexture.cpp index ff2ffba6..89492f13 100644 --- a/Source/HLEGraphics/CachedTexture.cpp +++ b/Source/HLEGraphics/CachedTexture.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/ROM.h" #include "Debug/DBGConsole.h" #include "Debug/Dump.h" diff --git a/Source/HLEGraphics/DLParser.cpp b/Source/HLEGraphics/DLParser.cpp index 54cfb7c4..5b5b2d29 100644 --- a/Source/HLEGraphics/DLParser.cpp +++ b/Source/HLEGraphics/DLParser.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/Memory.h" #include "Core/ROM.h" @@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Ultra/ultra_rcp.h" #include "Ultra/ultra_sptask.h" #include "HLEGraphics/GraphicsPlugin.h" -#include "Test/BatchTest.h" +#include "Utility/BatchTest.h" #include "uCodes/UcodeDefs.h" #include "uCodes/Ucode.h" diff --git a/Source/HLEGraphics/TextureInfo.cpp b/Source/HLEGraphics/TextureInfo.cpp index 441b163c..95e97101 100644 --- a/Source/HLEGraphics/TextureInfo.cpp +++ b/Source/HLEGraphics/TextureInfo.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/Memory.h" #include "Core/ROM.h" #include "HLEGraphics/TextureInfo.h" diff --git a/Source/Input/CMakeLists.txt b/Source/Input/CMakeLists.txt index 1b1701f3..be59f1b8 100644 --- a/Source/Input/CMakeLists.txt +++ b/Source/Input/CMakeLists.txt @@ -1,6 +1,6 @@ if(DAEDALUS_PSP) add_library(Input OBJECT PSP/InputManagerPSP.cpp) -elif(DAEDALUS_CTR) +elseif(DAEDALUS_CTR) add_library(Input OBJECT CTR/InputManagerCTR.cpp) else() add_library(Input OBJECT SDL/InputManagerSDL.cpp) diff --git a/Source/Input/CTR/InputManagerCTR.cpp b/Source/Input/CTR/InputManagerCTR.cpp index 7f319b03..2dbfd8e2 100644 --- a/Source/Input/CTR/InputManagerCTR.cpp +++ b/Source/Input/CTR/InputManagerCTR.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <3ds.h> #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "Math/Math.h" #include "Utility/MathUtil.h" diff --git a/Source/Input/PSP/InputManagerPSP.cpp b/Source/Input/PSP/InputManagerPSP.cpp index 558c8b9c..9008717b 100644 --- a/Source/Input/PSP/InputManagerPSP.cpp +++ b/Source/Input/PSP/InputManagerPSP.cpp @@ -9,7 +9,7 @@ #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Debug/DBGConsole.h" #include "Input/InputManager.h" #include "Math/Math.h" // VFPU Math diff --git a/Source/Interface/CMakeLists.txt b/Source/Interface/CMakeLists.txt index 86a38dd7..da47454b 100644 --- a/Source/Interface/CMakeLists.txt +++ b/Source/Interface/CMakeLists.txt @@ -1,4 +1,6 @@ add_library(Interface OBJECT + ConfigOptions.cpp + Cheats.cpp Preferences.cpp RomDB.cpp SaveState.cpp diff --git a/Source/Core/Cheats.cpp b/Source/Interface/Cheats.cpp similarity index 99% rename from Source/Core/Cheats.cpp rename to Source/Interface/Cheats.cpp index fcdfbc97..86957bc7 100644 --- a/Source/Core/Cheats.cpp +++ b/Source/Interface/Cheats.cpp @@ -23,13 +23,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "Core/Cheats.h" +#include "Interface/Cheats.h" #include "Core/Memory.h" #include "Core/ROM.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Ultra/ultra_R4300.h" diff --git a/Source/Core/Cheats.h b/Source/Interface/Cheats.h similarity index 100% rename from Source/Core/Cheats.h rename to Source/Interface/Cheats.h diff --git a/Source/Config/ConfigOptions.cpp b/Source/Interface/ConfigOptions.cpp similarity index 98% rename from Source/Config/ConfigOptions.cpp rename to Source/Interface/ConfigOptions.cpp index 923f2c6a..aa39b00c 100644 --- a/Source/Config/ConfigOptions.cpp +++ b/Source/Interface/ConfigOptions.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" u32 gSpeedSyncEnabled = 0; // Enable to limit frame rate. bool gDynarecEnabled = true; // Use dynamic recompilation diff --git a/Source/Config/ConfigOptions.h b/Source/Interface/ConfigOptions.h similarity index 100% rename from Source/Config/ConfigOptions.h rename to Source/Interface/ConfigOptions.h diff --git a/Source/Interface/Preferences.cpp b/Source/Interface/Preferences.cpp index 91040c18..559f6cd1 100644 --- a/Source/Interface/Preferences.cpp +++ b/Source/Interface/Preferences.cpp @@ -30,9 +30,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "Utility/IniFile.h" -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/ROM.h" #include "Input/InputManager.h" #include "Interface/RomDB.h" diff --git a/Source/Interface/RomPreferences.h b/Source/Interface/RomPreferences.h index 9b72ede1..9904257c 100644 --- a/Source/Interface/RomPreferences.h +++ b/Source/Interface/RomPreferences.h @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef UTILITY_ROM_PREFERENCES_H_ #define UTILITY_ROM_PREFERENCES_H_ -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" enum ETextureHashFrequency diff --git a/Source/OSHLE/patch.cpp b/Source/OSHLE/patch.cpp index 6cb60939..90d8be4e 100644 --- a/Source/OSHLE/patch.cpp +++ b/Source/OSHLE/patch.cpp @@ -27,12 +27,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/DMA.h" #include "Core/Memory.h" #include "Core/R4300.h" -#include "Core/Registers.h" +#include "Debug/Registers.h" #include "Core/ROM.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" diff --git a/Source/OSHLE/patch.h b/Source/OSHLE/patch.h index 5944e0cd..02987989 100644 --- a/Source/OSHLE/patch.h +++ b/Source/OSHLE/patch.h @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef OSHLE_PATCH_H_ #define OSHLE_PATCH_H_ -#include "Core/Registers.h" // For SRHACK_???? etc +#include "Debug/Registers.h" // For SRHACK_???? etc #include "Core/CPU.h" // Breakpoint stuff #include "Ultra/ultra_R4300.h" diff --git a/Source/RomFile/CMakeLists.txt b/Source/RomFile/CMakeLists.txt index ec2a8460..b0d5bce2 100644 --- a/Source/RomFile/CMakeLists.txt +++ b/Source/RomFile/CMakeLists.txt @@ -6,6 +6,8 @@ add_library(RomFile OBJECT RomFileCompressed.cpp RomFileMemory.cpp RomFileUncompressed.cpp + RomBuffer.cpp + RomSettings.cpp ) diff --git a/Source/Core/ROMBuffer.h b/Source/RomFile/ROMBuffer.h similarity index 100% rename from Source/Core/ROMBuffer.h rename to Source/RomFile/ROMBuffer.h diff --git a/Source/RomFile/RomSettings.cpp b/Source/RomFile/RomSettings.cpp index 323ef5aa..d7b27159 100644 --- a/Source/RomFile/RomSettings.cpp +++ b/Source/RomFile/RomSettings.cpp @@ -35,7 +35,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Debug/DBGConsole.h" #include "Interface/RomDB.h" #include "Utility/IniFile.h" - +#include "Utility/Paths.h" namespace { @@ -152,9 +152,7 @@ template<> bool CSingleton< CRomSettingsDB >::Create() DAEDALUS_ASSERT_Q(mpInstance == nullptr); #endif mpInstance = std::make_shared(); - mpInstance->OpenSettingsFile( setBasePath("roms.ini") ); - return true; } @@ -219,9 +217,9 @@ static RomID RomIDFromString( const char * str ) bool IRomSettingsDB::OpenSettingsFile( const std::filesystem::path &filename ) { - - std::filesystem::path mFilename = setBasePath(filename); + std::filesystem::path mFilename = setBasePath(filename); + auto p_ini_file = CIniFile::Create(filename); if( p_ini_file == nullptr ) { diff --git a/Source/Core/RomSettings.h b/Source/RomFile/RomSettings.h similarity index 100% rename from Source/Core/RomSettings.h rename to Source/RomFile/RomSettings.h diff --git a/Source/SysCTR/Debug/DBGConsoleCTR.cpp b/Source/SysCTR/Debug/DBGConsoleCTR.cpp index ef435578..4f5f68d3 100644 --- a/Source/SysCTR/Debug/DBGConsoleCTR.cpp +++ b/Source/SysCTR/Debug/DBGConsoleCTR.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "Debug/DebugConsoleImpl.h" -#include "Test/BatchTest.h" +#include "Utility/BatchTest.h" static const char * const kTerminalSaveCursor = "\033[s"; static const char * const kTerminalRestoreCursor = "\033[u"; diff --git a/Source/SysCTR/Graphics/GraphicsContextCTR.cpp b/Source/SysCTR/Graphics/GraphicsContextCTR.cpp index 88d84bb4..82671300 100644 --- a/Source/SysCTR/Graphics/GraphicsContextCTR.cpp +++ b/Source/SysCTR/Graphics/GraphicsContextCTR.cpp @@ -4,7 +4,7 @@ #include <3ds.h> #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/ROM.h" #include "Debug/DBGConsole.h" #include "Debug/Dump.h" diff --git a/Source/SysCTR/HLEGraphics/GraphicsPluginCTR.cpp b/Source/SysCTR/HLEGraphics/GraphicsPluginCTR.cpp index d3433c94..f440e2c1 100644 --- a/Source/SysCTR/HLEGraphics/GraphicsPluginCTR.cpp +++ b/Source/SysCTR/HLEGraphics/GraphicsPluginCTR.cpp @@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "HLEGraphics/GraphicsPlugin.h" #include "Utility/Profiler.h" -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" #include "Interface/Preferences.h" #include "System/Timing.h" diff --git a/Source/SysCTR/UI/InGameMenu.cpp b/Source/SysCTR/UI/InGameMenu.cpp index d0aefc41..04c88ac2 100644 --- a/Source/SysCTR/UI/InGameMenu.cpp +++ b/Source/SysCTR/UI/InGameMenu.cpp @@ -7,12 +7,12 @@ #include "InGameMenu.h" -#include "Config/ConfigOptions.h" -#include "Core/Cheats.h" +#include "Interface/ConfigOptions.h" +#include "Interface/Cheats.h" #include "Core/CPU.h" #include "Core/Memory.h" #include "Core/PIF.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Core/Save.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" @@ -21,7 +21,7 @@ #include "Input/InputManager.h" #include "Interface/RomDB.h" #include "System/SystemInit.h" -#include "Test/BatchTest.h" +#include "Utility/BatchTest.h" #include "Interface/Preferences.h" #include "Utility/Profiler.h" diff --git a/Source/SysCTR/UI/InGameMenu.h b/Source/SysCTR/UI/InGameMenu.h index e657c46a..36e9d53b 100644 --- a/Source/SysCTR/UI/InGameMenu.h +++ b/Source/SysCTR/UI/InGameMenu.h @@ -1,6 +1,6 @@ #pragma once -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" namespace UI { diff --git a/Source/SysCTR/main.cpp b/Source/SysCTR/main.cpp index 40177b32..bee5c2f6 100644 --- a/Source/SysCTR/main.cpp +++ b/Source/SysCTR/main.cpp @@ -8,13 +8,13 @@ #include -#include "Config/ConfigOptions.h" -#include "Core/Cheats.h" +#include "Interface/ConfigOptions.h" +#include "Interface/Cheats.h" #include "Core/CPU.h" #include "Core/CPU.h" #include "Core/Memory.h" #include "Core/PIF.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Core/Save.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" @@ -23,7 +23,7 @@ #include "Input/InputManager.h" #include "Interface/RomDB.h" #include "System/SystemInit.h" -#include "Test/BatchTest.h" +#include "Utility/BatchTest.h" #include "UI/UserInterface.h" #include "UI/RomSelector.h" @@ -136,6 +136,7 @@ int main(int argc, char* argv[]) // Set the default path std::string rom = UI::DrawRomSelector(); + std::filesystem::path rom; std::filesystem::path RomPath = setBasePath("Roms"); RomPath /= rom; System_Open(RomPath.string().c_str()); diff --git a/Source/SysPSP/Debug/DBGConsolePSP.cpp b/Source/SysPSP/Debug/DBGConsolePSP.cpp index e72dd5aa..879267f7 100644 --- a/Source/SysPSP/Debug/DBGConsolePSP.cpp +++ b/Source/SysPSP/Debug/DBGConsolePSP.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "Debug/DebugConsoleImpl.h" -#include "Test/BatchTest.h" +#include "Utility/BatchTest.h" static const char * const kTerminalSaveCursor = "\033[s"; static const char * const kTerminalRestoreCursor = "\033[u"; diff --git a/Source/SysPSP/Graphics/GraphicsContextPSP.cpp b/Source/SysPSP/Graphics/GraphicsContextPSP.cpp index 9ff05fd9..45a048bf 100644 --- a/Source/SysPSP/Graphics/GraphicsContextPSP.cpp +++ b/Source/SysPSP/Graphics/GraphicsContextPSP.cpp @@ -26,7 +26,7 @@ #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/ROM.h" #include "Debug/DBGConsole.h" #include "Debug/Dump.h" diff --git a/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp b/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp index b420278c..e0b408ba 100644 --- a/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp +++ b/Source/SysPSP/HLEGraphics/GraphicsPluginPSP.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "HLEGraphics/GraphicsPlugin.h" #include "Utility/Profiler.h" -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" #include "Interface/Preferences.h" #include "System/Timing.h" diff --git a/Source/SysPSP/Utility/exception.cpp b/Source/SysPSP/Utility/exception.cpp index 79a870a2..49bbdec5 100644 --- a/Source/SysPSP/Utility/exception.cpp +++ b/Source/SysPSP/Utility/exception.cpp @@ -11,12 +11,12 @@ #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/ROM.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Debug/Dump.h" -#include "Core/PrintOpCode.h" +#include "Debug/PrintOpCode.h" PspDebugRegBlock *exception_regs; diff --git a/Source/SysPSP/main.cpp b/Source/SysPSP/main.cpp index e76e9b91..27be72f2 100644 --- a/Source/SysPSP/main.cpp +++ b/Source/SysPSP/main.cpp @@ -36,13 +36,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Config/ConfigOptions.h" -#include "Core/Cheats.h" +#include "Interface/ConfigOptions.h" +#include "Interface/Cheats.h" #include "Core/CPU.h" #include "Core/CPU.h" #include "Core/Memory.h" #include "Core/PIF.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Core/Save.h" #include "Debug/DBGConsole.h" #include "Debug/DebugLog.h" @@ -60,7 +60,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "System/SystemInit.h" -#include "Test/BatchTest.h" +#include "Utility/BatchTest.h" #include "Utility/ModulePSP.h" #include "Interface/Preferences.h" diff --git a/Source/SysPosix/main.cpp b/Source/SysPosix/main.cpp index 88f3fcfd..7bf61f24 100644 --- a/Source/SysPosix/main.cpp +++ b/Source/SysPosix/main.cpp @@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Debug/DBGConsole.h" #include "Interface/RomDB.h" #include "System/SystemInit.h" -#include "Test/BatchTest.h" +#include "Utility/BatchTest.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Interface/Preferences.h" #include "Utility/Translate.h" #include "UI/MainMenuScreen.h" diff --git a/Source/System/SystemInit.cpp b/Source/System/SystemInit.cpp index 9b455e81..5d473cd4 100644 --- a/Source/System/SystemInit.cpp +++ b/Source/System/SystemInit.cpp @@ -25,8 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/CPU.h" #include "Core/Save.h" #include "Core/PIF.h" -#include "Core/ROMBuffer.h" -#include "Core/RomSettings.h" +#include "RomFile/ROMBuffer.h" +#include "RomFile/RomSettings.h" #include "Interface/RomDB.h" #include "System/SystemInit.h" @@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" #include "Debug/Synchroniser.h" #include "Base/Macros.h" #include "Utility/Profiler.h" diff --git a/Source/Test/CMakeLists.txt b/Source/Test/CMakeLists.txt deleted file mode 100644 index e87d9ca0..00000000 --- a/Source/Test/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_library(BatchTest OBJECT BatchTest.cpp) \ No newline at end of file diff --git a/Source/UI/AdvancedOptionsScreen.cpp b/Source/UI/AdvancedOptionsScreen.cpp index aff695d1..3da461fc 100644 --- a/Source/UI/AdvancedOptionsScreen.cpp +++ b/Source/UI/AdvancedOptionsScreen.cpp @@ -28,9 +28,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "UISpacer.h" #include "UICommand.h" -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/ROM.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Graphics/ColourValue.h" #include "Input/InputManager.h" #include "DrawTextUtilities.h" diff --git a/Source/UI/CheatOptionsScreen.cpp b/Source/UI/CheatOptionsScreen.cpp index eb9c2436..45a7284f 100644 --- a/Source/UI/CheatOptionsScreen.cpp +++ b/Source/UI/CheatOptionsScreen.cpp @@ -27,10 +27,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "UISpacer.h" #include "UICommand.h" -#include "Config/ConfigOptions.h" -#include "Core/Cheats.h" +#include "Interface/ConfigOptions.h" +#include "Interface/Cheats.h" #include "Core/ROM.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Graphics/ColourValue.h" #include "Input/InputManager.h" #include "DrawTextUtilities.h" diff --git a/Source/UI/GlobalSettingsComponent.cpp b/Source/UI/GlobalSettingsComponent.cpp index 4b2b6f5b..e081529d 100644 --- a/Source/UI/GlobalSettingsComponent.cpp +++ b/Source/UI/GlobalSettingsComponent.cpp @@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "System/Thread.h" -#include "Core/FramerateLimiter.h" +#include "Utility/FramerateLimiter.h" #include "Interface/Preferences.h" #include "Utility/Translate.h" diff --git a/Source/UI/MainMenuScreen.cpp b/Source/UI/MainMenuScreen.cpp index c0fbe932..5f3afa98 100644 --- a/Source/UI/MainMenuScreen.cpp +++ b/Source/UI/MainMenuScreen.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/CPU.h" #include "Core/ROM.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Interface/SaveState.h" #include "Graphics/ColourValue.h" #include "Graphics/GraphicsContext.h" diff --git a/Source/UI/PauseOptionsComponent.cpp b/Source/UI/PauseOptionsComponent.cpp index 3b3e0593..4422c66d 100644 --- a/Source/UI/PauseOptionsComponent.cpp +++ b/Source/UI/PauseOptionsComponent.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/CPU.h" -#include "Core/Dynamo.h" +#include "DynaRec/Dynamo.h" #include "Core/ROM.h" #include "Interface/SaveState.h" #include "HLEGraphics/DisplayListDebugger.h" diff --git a/Source/UI/PauseScreen.cpp b/Source/UI/PauseScreen.cpp index 8a447685..68285010 100644 --- a/Source/UI/PauseScreen.cpp +++ b/Source/UI/PauseScreen.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/CPU.h" #include "Core/ROM.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Graphics/ColourValue.h" #include "Graphics/GraphicsContext.h" #include "Utility/MathUtil.h" diff --git a/Source/UI/RomPreferencesScreen.cpp b/Source/UI/RomPreferencesScreen.cpp index 460765d6..a20e139e 100644 --- a/Source/UI/RomPreferencesScreen.cpp +++ b/Source/UI/RomPreferencesScreen.cpp @@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/ROM.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Graphics/ColourValue.h" #include "Input/InputManager.h" #include "DrawTextUtilities.h" diff --git a/Source/UI/RomSelectorComponent.cpp b/Source/UI/RomSelectorComponent.cpp index 9e0ce5b6..322598ac 100644 --- a/Source/UI/RomSelectorComponent.cpp +++ b/Source/UI/RomSelectorComponent.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" #include "UI/Menu.h" #include "Core/ROM.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Graphics/ColourValue.h" #include "Graphics/NativeTexture.h" #include "Input/InputManager.h" @@ -263,23 +263,6 @@ void IRomSelectorComponent::UpdateROMList() } } -void IRomSelectorComponent::AddRomDirectory(const std::filesystem::path &p_roms_dir, std::vector & roms) -{ - - for (const auto& entry : std::filesystem::directory_iterator(p_roms_dir)) - { - if (entry.is_regular_file()) - { - const std::filesystem::path& rom_filename = entry.path().filename(); - if(std::find(valid_extensions.begin(), valid_extensions.end(), rom_filename.extension()) != valid_extensions.end()) - { - auto p_rom_info = new SRomInfo(entry); - roms.emplace_back( p_rom_info); - } - } - } -} - ECategory IRomSelectorComponent::GetCurrentCategory() const { if( !mRomsList.empty() ) diff --git a/Source/Test/BatchTest.cpp b/Source/Utility/BatchTest.cpp similarity index 95% rename from Source/Test/BatchTest.cpp rename to Source/Utility/BatchTest.cpp index 099cb06a..db4c7b36 100644 --- a/Source/Test/BatchTest.cpp +++ b/Source/Utility/BatchTest.cpp @@ -29,13 +29,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "Config/ConfigOptions.h" +#include "Interface/ConfigOptions.h" #include "Core/CPU.h" #include "Core/ROM.h" #include "Debug/Dump.h" #include "HLEGraphics/DLParser.h" #include "System/SystemInit.h" -#include "Test/BatchTest.h" +#include "Utility/BatchTest.h" #include "Utility/Hash.h" #include "RomFile/RomFile.h" diff --git a/Source/Test/BatchTest.h b/Source/Utility/BatchTest.h similarity index 100% rename from Source/Test/BatchTest.h rename to Source/Utility/BatchTest.h diff --git a/Source/Utility/CMakeLists.txt b/Source/Utility/CMakeLists.txt index 52047607..c9801e17 100644 --- a/Source/Utility/CMakeLists.txt +++ b/Source/Utility/CMakeLists.txt @@ -1,6 +1,8 @@ add_library(Utility OBJECT + BatchTest.cpp CRC.cpp FastMemcpy.cpp + FramerateLimiter.cpp Hash.cpp IniFile.cpp MemoryHeap.cpp diff --git a/Source/Core/FramerateLimiter.cpp b/Source/Utility/FramerateLimiter.cpp similarity index 100% rename from Source/Core/FramerateLimiter.cpp rename to Source/Utility/FramerateLimiter.cpp diff --git a/Source/Core/FramerateLimiter.h b/Source/Utility/FramerateLimiter.h similarity index 100% rename from Source/Core/FramerateLimiter.h rename to Source/Utility/FramerateLimiter.h From 1c9f9a53e02c5ec66e2e1d1f60ae8fe6e2d7e94e Mon Sep 17 00:00:00 2001 From: wally4000 Date: Tue, 6 Aug 2024 10:46:04 +1000 Subject: [PATCH 11/31] Redirect all debug messages to cout. --- Source/SysCTR/Debug/DBGConsoleCTR.cpp | 30 +++++++------ Source/SysCTR/main.cpp | 61 +++++++++++++++++++-------- 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/Source/SysCTR/Debug/DBGConsoleCTR.cpp b/Source/SysCTR/Debug/DBGConsoleCTR.cpp index 4f5f68d3..8e4f5f1c 100644 --- a/Source/SysCTR/Debug/DBGConsoleCTR.cpp +++ b/Source/SysCTR/Debug/DBGConsoleCTR.cpp @@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #include "Debug/DebugConsoleImpl.h" #include "Utility/BatchTest.h" @@ -58,20 +59,23 @@ template<> bool CSingleton< CDebugConsole >::Create() CDebugConsole::~CDebugConsole() { } - -void IDebugConsole::Msg(u32 type, const char * format, ...) +void IDebugConsole::Msg(u32 type, const char* format, ...) { - #ifdef DAEDALUS_DEBUG_CONSOLE - char * temp = NULL; - va_list marker; - va_start( marker, format ); - vprintf( format, marker ); - va_end( marker ); - printf("\n"); - - if (temp) - free(temp); - #endif + // Buffer to hold formatted string + char buffer[1024]; + + // Initialize variable argument list + va_list args; + va_start(args, format); + + // Format the string + vsnprintf(buffer, sizeof(buffer), format, args); + + // Clean up variable argument list + va_end(args); + + // Output the formatted string to std::cout + std::cout << buffer << std::endl; } void IDebugConsole::MsgOverwriteStart() diff --git a/Source/SysCTR/main.cpp b/Source/SysCTR/main.cpp index bee5c2f6..a7b8f78b 100644 --- a/Source/SysCTR/main.cpp +++ b/Source/SysCTR/main.cpp @@ -40,24 +40,42 @@ bool isN3DS = false; bool shouldQuit = false; - + std::streambuf* coutBuf = nullptr; + std::streambuf* cerrBuf = nullptr; EAudioPluginMode enable_audio = APM_ENABLED_ASYNC; #ifdef DAEDALUS_LOG -void log2file(const char *format, ...) { - __gnuc_va_list arg; - int done; - va_start(arg, format); - char msg[512]; - done = vsprintf(msg, format, arg); - va_end(arg); - snprintf(msg, sizeof(msg), "%s\n", msg); - std::ofstream log("sdmc:/DaedalusX64.log", std::ios::out); - if (log.is_open) { - log.write(reinterpret_cast(msg), strlen(msg)); - log.close(); - } +// void log2file(const char *format, ...) { +// __gnuc_va_list arg; +// int done; +// va_start(arg, format); +// char msg[512]; +// done = vsprintf(msg, format, arg); +// va_end(arg); +// snprintf(msg, sizeof(msg), "%s\n", msg); +// std::ofstream log("sdmc:/DaedalusX64.log", std::ios::out); +// if (log.is_open()) { +// log.write(reinterpret_cast(msg), strlen(msg)); +// log.close(); +// } +// } +void redirectOutputToLogFile(std::ofstream& logFile, std::streambuf*& coutBuf, std::streambuf*& cerrBuf) { + // Open the log file + logFile.open("sdmc:/3ds/DaedalusX64/daedalus.log"); + + // Check if the file opened successfully + if (!logFile.is_open()) { + std::cerr << "Failed to open log file." << std::endl; + return; + } + + // Redirect stdout and stderr to the log file + coutBuf = std::cout.rdbuf(); + cerrBuf = std::cerr.rdbuf(); + std::cout.rdbuf(logFile.rdbuf()); + std::cerr.rdbuf(logFile.rdbuf()); } + #endif static void CheckDSPFirmware() @@ -90,6 +108,11 @@ static void CheckDSPFirmware() static void Initialize() { + // Variables to store the original stream buffers + + + + CheckDSPFirmware(); _InitializeSvcHack(); @@ -126,18 +149,22 @@ extern u32 __ctru_heap_size; int main(int argc, char* argv[]) { + // File stream for logging + std::ofstream logFile; + + // Redirect output to log file + redirectOutputToLogFile(logFile, coutBuf, cerrBuf); char fullpath[512]; Initialize(); - + std::cout << "Hello this is being logged" << std::endl; while(shouldQuit == false) { - // Set the default path std::string rom = UI::DrawRomSelector(); - std::filesystem::path rom; std::filesystem::path RomPath = setBasePath("Roms"); + // std::filesystem::path rom = "Super Mario 64 (USA).z64"; RomPath /= rom; System_Open(RomPath.string().c_str()); CPU_Run(); From 69ef00bff2d4baea43a2352e52ed4f9776e953d2 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Tue, 6 Aug 2024 12:38:08 +1000 Subject: [PATCH 12/31] Whoops --- Source/UI/RomSelectorComponent.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/UI/RomSelectorComponent.cpp b/Source/UI/RomSelectorComponent.cpp index 322598ac..03062813 100644 --- a/Source/UI/RomSelectorComponent.cpp +++ b/Source/UI/RomSelectorComponent.cpp @@ -235,7 +235,22 @@ IRomSelectorComponent::~IRomSelectorComponent() mRomsList.clear(); } - +void IRomSelectorComponent::AddRomDirectory(const std::filesystem::path &p_roms_dir, std::vector & roms) +{ + + for (const auto& entry : std::filesystem::directory_iterator(p_roms_dir)) + { + if (entry.is_regular_file()) + { + const std::filesystem::path& rom_filename = entry.path().filename(); + if(std::find(valid_extensions.begin(), valid_extensions.end(), rom_filename.extension()) != valid_extensions.end()) + { + auto p_rom_info = new SRomInfo(entry); + roms.emplace_back( p_rom_info); + } + } + } +} //Refresh ROM list void IRomSelectorComponent::UpdateROMList() From a367c6a4dbf624a473531a0f56d83ad66706d5bb Mon Sep 17 00:00:00 2001 From: wally4000 Date: Tue, 6 Aug 2024 14:29:39 +1000 Subject: [PATCH 13/31] Path issues breaking out of tree builds. --- Source/Debug/DebugLog.cpp | 2 +- Source/Input/CTR/InputManagerCTR.cpp | 3 ++- Source/Interface/Preferences.cpp | 37 ++++++++++++++++++++++------ Source/Interface/RomDB.cpp | 7 +++--- Source/OSHLE/patch.cpp | 3 ++- Source/RomFile/RomSettings.cpp | 2 +- Source/Utility/Paths.cpp | 2 +- 7 files changed, 40 insertions(+), 16 deletions(-) diff --git a/Source/Debug/DebugLog.cpp b/Source/Debug/DebugLog.cpp index 72207bdf..f18d5b5e 100644 --- a/Source/Debug/DebugLog.cpp +++ b/Source/Debug/DebugLog.cpp @@ -41,7 +41,7 @@ bool Debug_InitLogging() const std::filesystem::path log_filename = "daedalus.txt"; std::filesystem::path path = setBasePath(log_filename); std::cout << "Creating Dump File: " << path << std::endl; - g_hOutputLog.open( log_filename); + g_hOutputLog.open( path); // Is always going to return true return true; } diff --git a/Source/Input/CTR/InputManagerCTR.cpp b/Source/Input/CTR/InputManagerCTR.cpp index 2dbfd8e2..826864c4 100644 --- a/Source/Input/CTR/InputManagerCTR.cpp +++ b/Source/Input/CTR/InputManagerCTR.cpp @@ -316,7 +316,8 @@ bool IInputManager::Initialise() } // char ControllerConfigs[128]; - std::filesystem::path ControllerConfigs = "ControllerConfigs"; + + std::filesystem::path ControllerConfigs = setBasePath("ControllerConfigs"); LoadControllerConfigs(ControllerConfigs); SetConfiguration(0); diff --git a/Source/Interface/Preferences.cpp b/Source/Interface/Preferences.cpp index 559f6cd1..642775fa 100644 --- a/Source/Interface/Preferences.cpp +++ b/Source/Interface/Preferences.cpp @@ -23,12 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Interface/Preferences.h" #include - #include #include -#include #include - +#include #include "Utility/IniFile.h" #include "Utility/FramerateLimiter.h" @@ -40,6 +38,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Utility/Translate.h" +template +void OutputValue(std::ofstream& fh, const std::string& name, const T& value) { + fh << name << "=" << value << "\n"; +} + +template <> +void OutputValue(std::ofstream& fh, const std::string& name, const bool& value) { + fh << name << "=" << (value ? "yes" : "no") << "\n"; +} + +template <> +void OutputValue(std::ofstream& fh, const std::string& name, const float& value) { + fh << name << "=" << std::fixed << std::setprecision(6) << value << "\n"; +} + +template <> +void OutputValue(std::ofstream& fh, const std::string& name, const int& value) { + fh << name << "=" << value << "\n"; +} + +void OutputLanguage(std::ofstream& fh, const std::string& name, int index) { + fh << name << "=" << Translate_NameFromIndex(index) << "\n"; +} // Audio is disabled on the PSP by default, but enabled on other platforms. #ifdef DAEDALUS_PSP @@ -99,7 +120,7 @@ template<> bool CSingleton< CPreferences >::Create() CPreferences::~CPreferences() { } -#include + IPreferences::IPreferences() : mDirty( false ) { @@ -325,10 +346,10 @@ void IPreferences::Commit() { const SGlobalPreferences defaults; -#define OUTPUT_BOOL(b, nm, def) fh << std::format("{}={}\n", #nm, b.nm ? "yes" : "no") -#define OUTPUT_FLOAT(b, nm, def) fh << std::format("{}={:.6f}\n", #nm, b.nm) -#define OUTPUT_INT(b, nm, def) fh << #nm << "=" << static_cast(b.nm) << "\n" -#define OUTPUT_LANGUAGE(b, nm, def) fh << std::format("{}={}\n", #nm, Translate_NameFromIndex(b.nm)) +#define OUTPUT_BOOL(b, nm, def) OutputValue(fh, #nm, b.nm) +#define OUTPUT_FLOAT(b, nm, def) OutputValue(fh, #nm, b.nm) +#define OUTPUT_INT(b, nm, def) OutputValue(fh, #nm, b.nm) +#define OUTPUT_LANGUAGE(b, nm, def) OutputLanguage(fh, #nm, b.nm) OUTPUT_BOOL( gGlobalPreferences, DisplayFramerate, defaults ); OUTPUT_BOOL( gGlobalPreferences, ForceLinearFilter, defaults ); diff --git a/Source/Interface/RomDB.cpp b/Source/Interface/RomDB.cpp index 3c9251f1..82c6e221 100644 --- a/Source/Interface/RomDB.cpp +++ b/Source/Interface/RomDB.cpp @@ -285,16 +285,17 @@ void IRomDB::AddRomEntry( const std::filesystem::path& filename, const RomID & i void IRomDB::AddRomDirectory(const std::filesystem::path& directory) { - DBGConsole_Msg(0, "Adding roms directory [C%s]", directory.c_str()); + std::filesystem::path romdir = setBasePath(directory); + DBGConsole_Msg(0, "Adding roms directory [C%s]", romdir.c_str()); - for (const auto& entry : std::filesystem::directory_iterator(directory)) + for (const auto& entry : std::filesystem::directory_iterator(romdir)) { if (entry.is_regular_file()) { const std::filesystem::path rom_filename = entry.path().filename(); if (std::find(valid_extensions.begin(), valid_extensions.end(), rom_filename.extension()) != valid_extensions.end()) { - std::filesystem::path rompath = directory / rom_filename; + std::filesystem::path rompath = romdir / rom_filename; AddRomFile(rompath); } } diff --git a/Source/OSHLE/patch.cpp b/Source/OSHLE/patch.cpp index 90d8be4e..6a376287 100644 --- a/Source/OSHLE/patch.cpp +++ b/Source/OSHLE/patch.cpp @@ -963,6 +963,7 @@ bool Patch_VerifyLocation_CheckSignature(PatchSymbol * ps, static void Patch_FlushCache() { std::filesystem::path path = setBasePath("SaveGames/Cache"); + std::filesystem::create_directories(path); std::filesystem::path name = g_ROM.mFileName.filename(); name.replace_extension("hle"); path /= name; @@ -1015,7 +1016,7 @@ static void Patch_FlushCache() static bool Patch_GetCache() { std::filesystem::path name = setBasePath("SaveGames/Cache"); - std::filesystem::path romName = g_ROM.mFileName; + std::filesystem::path romName = g_ROM.mFileName.filename(); romName.replace_extension(".hle"); name /= romName; std::cout << name << std::endl; diff --git a/Source/RomFile/RomSettings.cpp b/Source/RomFile/RomSettings.cpp index d7b27159..d9d81c72 100644 --- a/Source/RomFile/RomSettings.cpp +++ b/Source/RomFile/RomSettings.cpp @@ -218,7 +218,7 @@ static RomID RomIDFromString( const char * str ) bool IRomSettingsDB::OpenSettingsFile( const std::filesystem::path &filename ) { - std::filesystem::path mFilename = setBasePath(filename); + std::filesystem::path mFilename = filename; auto p_ini_file = CIniFile::Create(filename); if( p_ini_file == nullptr ) diff --git a/Source/Utility/Paths.cpp b/Source/Utility/Paths.cpp index 69716ca1..98e04742 100644 --- a/Source/Utility/Paths.cpp +++ b/Source/Utility/Paths.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef DAEDALUS_CTR -const std::filesystem::path baseDir = std::filesystem::current_path() / "3ds" / "DaedalusX64"; +const std::filesystem::path baseDir = "sdmc:/3ds/DaedalusX64"; #elif defined(DAEDALUS_VITA) const std::filesystem::path baseDir = "ux0:/data"; #else From 934c195043876bd5121e30f178e85978905a8b51 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Tue, 6 Aug 2024 14:30:52 +1000 Subject: [PATCH 14/31] Remove redundant IO file again. --- Source/System/IO.h | 56 ---------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 Source/System/IO.h diff --git a/Source/System/IO.h b/Source/System/IO.h deleted file mode 100644 index f5138e9c..00000000 --- a/Source/System/IO.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (C) 2006 StrmnNrmn - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#ifndef UTILITY_IO_H_ -#define UTILITY_IO_H_ - -#include "Base/Types.h" - -#include - -namespace IO -{ - namespace Path - { - const u32 kMaxPathLen = 260; - - #ifdef DAEDALUS_BATCH_TEST - const char * FindExtension( const char * p_path ); - const char * FindFileName( const char * p_path ); - #endif - } - - typedef char Filename[IO::Path::kMaxPathLen+1]; - - #ifdef DAEDALUS_CTR - struct FindDataT - { - Filename Name; - }; - -// This is also pretty redundant, as the IO file is pretty much deprecated - using FindHandleT = void *; - - bool FindFileOpen( const char * path, FindHandleT * handle, FindDataT & data ); - bool FindFileNext( FindHandleT handle, FindDataT & data ); - bool FindFileClose( FindHandleT handle ); - #endif -} - -#endif // UTILITY_IO_H_ From 4d09013b1db6c489973938f1cb45acb43284010e Mon Sep 17 00:00:00 2001 From: wally4000 Date: Tue, 6 Aug 2024 14:33:57 +1000 Subject: [PATCH 15/31] Clean up old CTR Stuff --- Source/SysCTR/UI/RomSelector.cpp | 99 +++++++++++++++----------------- Source/SysCTR/main.cpp | 24 +------- 2 files changed, 50 insertions(+), 73 deletions(-) diff --git a/Source/SysCTR/UI/RomSelector.cpp b/Source/SysCTR/UI/RomSelector.cpp index 884cdb21..d5aeb5bc 100644 --- a/Source/SysCTR/UI/RomSelector.cpp +++ b/Source/SysCTR/UI/RomSelector.cpp @@ -8,20 +8,18 @@ #include #include - -#include "Config/ConfigOptions.h" -#include "Core/Cheats.h" +#include "Interface/ConfigOptions.h" +#include "Interface/Cheats.h" #include "Core/CPU.h" #include "Core/PIF.h" -#include "Core/RomSettings.h" +#include "RomFile/RomSettings.h" #include "Core/Save.h" #include "Interface/RomDB.h" #include "System/SystemInit.h" - +#include "Utility/Paths.h" #include "Interface/Preferences.h" #include "RomFile/RomFile.h" - #include "Graphics/NativeTexture.h" #define DAEDALUS_CTR_PATH(p) "sdmc:/3ds/DaedalusX64/" p @@ -46,52 +44,49 @@ static std::vector PopulateRomList() { std::vector roms = {}; - std::string full_path; - // IO::FindHandleT find_handle; - // IO::FindDataT find_data; - - // if(IO::FindFileOpen( DAEDALUS_CTR_PATH("Roms/"), &find_handle, find_data )) - // { - // do - // { - const std::filesystem::path rom_filename; - if(std::find(valid_extensions.begin(), valid_extensions.end(), rom_filename.extension()) != valid_extensions.end()) - { - SRomInfo info; - - full_path = DAEDALUS_CTR_PATH("Roms/"); - full_path += rom_filename; - - info.mFilename = rom_filename; - - if (ROM_GetRomDetailsByFilename(full_path.c_str(), &info.mRomID, &info.mRomSize, &info.mCicType)) - { - if (!CRomSettingsDB::Get()->GetSettings(info.mRomID, &info.mSettings )) - { - std::string game_name; - - info.mSettings.Reset(); - info.mSettings.Comment = "Unknown"; - - if (!ROM_GetRomName(full_path.c_str(), game_name )) game_name = full_path; - - game_name = game_name.substr(0, 63); - info.mSettings.GameName = game_name.c_str(); - CRomSettingsDB::Get()->SetSettings(info.mRomID, info.mSettings); - } - } - else - { - info.mSettings.GameName = "Unknown"; - } - - roms.push_back(info); - } - - // } while(IO::FindFileNext( find_handle, find_data )); - - // IO::FindFileClose( find_handle ); - // } + std::filesystem::path roms_path = setBasePath("Roms"); + + if (std::filesystem::exists(roms_path) && std::filesystem::is_directory(roms_path)) + { + for (const auto& entry : std::filesystem::directory_iterator(roms_path)) + { + if (entry.is_regular_file()) + { + const std::filesystem::path& rom_filename = entry.path(); + + if (std::find(valid_extensions.begin(), valid_extensions.end(), rom_filename.extension()) != valid_extensions.end()) + { + SRomInfo info; + std::string full_path = rom_filename.string(); + + info.mFilename = rom_filename.filename().string(); + + if (ROM_GetRomDetailsByFilename(full_path.c_str(), &info.mRomID, &info.mRomSize, &info.mCicType)) + { + if (!CRomSettingsDB::Get()->GetSettings(info.mRomID, &info.mSettings)) + { + std::string game_name; + + info.mSettings.Reset(); + info.mSettings.Comment = "Unknown"; + + if (!ROM_GetRomName(full_path.c_str(), game_name)) game_name = full_path; + + game_name = game_name.substr(0, 63); + info.mSettings.GameName = game_name.c_str(); + CRomSettingsDB::Get()->SetSettings(info.mRomID, info.mSettings); + } + } + else + { + info.mSettings.GameName = "Unknown"; + } + + roms.push_back(info); + } + } + } + } std::stable_sort(roms.begin(), roms.end()); diff --git a/Source/SysCTR/main.cpp b/Source/SysCTR/main.cpp index a7b8f78b..afffc514 100644 --- a/Source/SysCTR/main.cpp +++ b/Source/SysCTR/main.cpp @@ -44,21 +44,7 @@ bool shouldQuit = false; std::streambuf* cerrBuf = nullptr; EAudioPluginMode enable_audio = APM_ENABLED_ASYNC; -#ifdef DAEDALUS_LOG -// void log2file(const char *format, ...) { -// __gnuc_va_list arg; -// int done; -// va_start(arg, format); -// char msg[512]; -// done = vsprintf(msg, format, arg); -// va_end(arg); -// snprintf(msg, sizeof(msg), "%s\n", msg); -// std::ofstream log("sdmc:/DaedalusX64.log", std::ios::out); -// if (log.is_open()) { -// log.write(reinterpret_cast(msg), strlen(msg)); -// log.close(); -// } -// } + void redirectOutputToLogFile(std::ofstream& logFile, std::streambuf*& coutBuf, std::streambuf*& cerrBuf) { // Open the log file logFile.open("sdmc:/3ds/DaedalusX64/daedalus.log"); @@ -76,8 +62,6 @@ void redirectOutputToLogFile(std::ofstream& logFile, std::streambuf*& coutBuf, s std::cerr.rdbuf(logFile.rdbuf()); } -#endif - static void CheckDSPFirmware() { std::filesystem::path firmwarePath = "sdmc:/3ds/dspfirm.cdc"; @@ -157,14 +141,12 @@ int main(int argc, char* argv[]) char fullpath[512]; Initialize(); - std::cout << "Hello this is being logged" << std::endl; while(shouldQuit == false) { // Set the default path - - std::string rom = UI::DrawRomSelector(); std::filesystem::path RomPath = setBasePath("Roms"); - // std::filesystem::path rom = "Super Mario 64 (USA).z64"; + std::string rom = UI::DrawRomSelector(); + RomPath /= rom; System_Open(RomPath.string().c_str()); CPU_Run(); From 5e145861c362309bc13acf18c06be58f08d04ddb Mon Sep 17 00:00:00 2001 From: wally4000 Date: Tue, 6 Aug 2024 14:35:57 +1000 Subject: [PATCH 16/31] Fix ROMBuffer Filename --- Source/RomFile/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/RomFile/CMakeLists.txt b/Source/RomFile/CMakeLists.txt index b0d5bce2..d7762ac1 100644 --- a/Source/RomFile/CMakeLists.txt +++ b/Source/RomFile/CMakeLists.txt @@ -6,7 +6,7 @@ add_library(RomFile OBJECT RomFileCompressed.cpp RomFileMemory.cpp RomFileUncompressed.cpp - RomBuffer.cpp + ROMBuffer.cpp RomSettings.cpp ) From 65e5106b0534410c1641962db4e2596d47fffb22 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Tue, 6 Aug 2024 16:14:57 +1000 Subject: [PATCH 17/31] Create the Controller Config Directory as a failsafe. --- Source/Input/CTR/InputManagerCTR.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Input/CTR/InputManagerCTR.cpp b/Source/Input/CTR/InputManagerCTR.cpp index 826864c4..3dc556a7 100644 --- a/Source/Input/CTR/InputManagerCTR.cpp +++ b/Source/Input/CTR/InputManagerCTR.cpp @@ -318,6 +318,7 @@ bool IInputManager::Initialise() // char ControllerConfigs[128]; std::filesystem::path ControllerConfigs = setBasePath("ControllerConfigs"); + std::filesystem::create_directory(ControllerConfigs); // Failsafe, to prevent emu from crashing LoadControllerConfigs(ControllerConfigs); SetConfiguration(0); From 3dfc08188780d6885b0f13aad2b123d5b6d1fbeb Mon Sep 17 00:00:00 2001 From: wally4000 Date: Tue, 6 Aug 2024 16:53:45 +1000 Subject: [PATCH 18/31] Remove Redundant Path file --- Source/Base/Path.h | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 Source/Base/Path.h diff --git a/Source/Base/Path.h b/Source/Base/Path.h deleted file mode 100644 index 2bb2af5a..00000000 --- a/Source/Base/Path.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - - Copyright (C) 2023 Wally4000 - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -#ifndef PATH_PATHBASE_H_ -#define PATH_PATHBASE_H_ - -#include - -// This file is just for setting the BaseDir as extern. -// extern const std::filesystem::path baseDir; - -#endif // PATH_PATHBASE_H_ \ No newline at end of file From ee97a0d3582179aad09ff193073a8301e5775881 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Wed, 7 Aug 2024 12:56:19 +1000 Subject: [PATCH 19/31] Only set DAEDALUS_SDL if using PSP via CMake --- Options.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Options.cmake b/Options.cmake index 5eaac62d..edcd7051 100644 --- a/Options.cmake +++ b/Options.cmake @@ -184,6 +184,8 @@ if(INTRAFONT) message("Using Intrafont") add_compile_definitions(INTRAFONT) else() - message("using SDL2_TTF") + if(DAEDALUS_PSP) + message("Not using intrafont") add_compile_definitions(DAEDALUS_SDL) + endif() endif() \ No newline at end of file From af02433cc43af7d56c41c62c6e28bd5adbbfd572 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Wed, 7 Aug 2024 12:56:49 +1000 Subject: [PATCH 20/31] Fix Typo --- Source/SysCTR/UI/InGameMenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SysCTR/UI/InGameMenu.cpp b/Source/SysCTR/UI/InGameMenu.cpp index 04c88ac2..b7eefe6b 100644 --- a/Source/SysCTR/UI/InGameMenu.cpp +++ b/Source/SysCTR/UI/InGameMenu.cpp @@ -247,7 +247,7 @@ bool UI::DrawOptionsPage(RomID mRomID) ImGui::Spacing(); - const char* viewporOptions[] = { "4:3", "Widescreen (Streteched)", "Widescreen (Hack)" }; + const char* viewporOptions[] = { "4:3", "Widescreen (Stretched)", "Widescreen (Hack)" }; ImGui::Text("Aspect Ratio"); currentSelection = (int)gGlobalPreferences.ViewportType; ImGui::Combo("##viewport_combo", ¤tSelection, viewporOptions, 3); From fbfaaf5f66d96f58d08ae868b51a776a59f77cfc Mon Sep 17 00:00:00 2001 From: wally4000 Date: Wed, 7 Aug 2024 12:57:13 +1000 Subject: [PATCH 21/31] Only use Timing if not CTR (Might need to change this for all embedded platforms) --- Source/System/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/System/CMakeLists.txt b/Source/System/CMakeLists.txt index 114ba70e..8ad2ed22 100644 --- a/Source/System/CMakeLists.txt +++ b/Source/System/CMakeLists.txt @@ -1,4 +1,13 @@ -add_library(System OBJECT CompressedStream.cpp SystemInit.cpp) +if(NOT DAEDALUS_CTR) +set(Timing Timing.cpp) +endif() + +add_library(System OBJECT + + CompressedStream.cpp + SystemInit.cpp + ${Timing} + ) target_include_directories(System PUBLIC ${ZLIB_INCLUDE_DIRS}) From 3ef43eaa48760fa6360a0ebb3c4e0801f702b21d Mon Sep 17 00:00:00 2001 From: wally4000 Date: Wed, 7 Aug 2024 12:57:53 +1000 Subject: [PATCH 22/31] Move Timing.cpp to System --- Source/{Utility => System}/Timing.cpp | 0 Source/Utility/CMakeLists.txt | 1 - 2 files changed, 1 deletion(-) rename Source/{Utility => System}/Timing.cpp (100%) diff --git a/Source/Utility/Timing.cpp b/Source/System/Timing.cpp similarity index 100% rename from Source/Utility/Timing.cpp rename to Source/System/Timing.cpp diff --git a/Source/Utility/CMakeLists.txt b/Source/Utility/CMakeLists.txt index c9801e17..176e070d 100644 --- a/Source/Utility/CMakeLists.txt +++ b/Source/Utility/CMakeLists.txt @@ -11,7 +11,6 @@ add_library(Utility OBJECT Stream.cpp StringUtil.cpp Timer.cpp - Timing.cpp Translate.cpp ) From 9cea81d9e37b893cf648aa6738897723b6dfe83a Mon Sep 17 00:00:00 2001 From: wally4000 Date: Wed, 7 Aug 2024 12:58:47 +1000 Subject: [PATCH 23/31] Re-enable CTR timing --- Source/SysCTR/Utility/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SysCTR/Utility/CMakeLists.txt b/Source/SysCTR/Utility/CMakeLists.txt index 524e55bc..15525e28 100644 --- a/Source/SysCTR/Utility/CMakeLists.txt +++ b/Source/SysCTR/Utility/CMakeLists.txt @@ -2,7 +2,7 @@ add_library(Utility_CTR OBJECT CacheCTR.S MemoryCTR.c ThreadCTR.cpp - # TimingCTR.cpp // We use the Timing based on the STL now. (Remove when tested okay) + TimingCTR.cpp ) From 53bb512f16f58cf6eb52ace3a72aae37bbb2eeac Mon Sep 17 00:00:00 2001 From: wally4000 Date: Wed, 7 Aug 2024 12:58:59 +1000 Subject: [PATCH 24/31] Disable Language section for CTR (Crashes) --- Source/System/SystemInit.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/System/SystemInit.cpp b/Source/System/SystemInit.cpp index 5d473cd4..32b57ac2 100644 --- a/Source/System/SystemInit.cpp +++ b/Source/System/SystemInit.cpp @@ -155,7 +155,9 @@ static const std::array gSysInitTable = {"ROM Database", CRomDB::Create, CRomDB::Destroy}, {"ROM Settings", CRomSettingsDB::Create, CRomSettingsDB::Destroy}, {"InputManager", CInputManager::Create, CInputManager::Destroy}, + #ifndef DAEDALUS_CTR {"Language", Translate_Init, NULL}, + #endif #ifdef DAEDALUS_PSP {"VideoMemory", CVideoMemoryManager::Create, NULL}, From 292d2218f6031f7ffea655493ec238d0a2fe0f6a Mon Sep 17 00:00:00 2001 From: wally4000 Date: Wed, 7 Aug 2024 20:16:05 +1000 Subject: [PATCH 25/31] Fix Savestates - CTR --- Source/SysCTR/UI/InGameMenu.cpp | 49 +++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/Source/SysCTR/UI/InGameMenu.cpp b/Source/SysCTR/UI/InGameMenu.cpp index b7eefe6b..0ce68f96 100644 --- a/Source/SysCTR/UI/InGameMenu.cpp +++ b/Source/SysCTR/UI/InGameMenu.cpp @@ -5,6 +5,7 @@ #include "UserInterface.h" #include "InGameMenu.h" +#include #include "Interface/ConfigOptions.h" @@ -28,45 +29,63 @@ #include "System/Thread.h" #include "RomFile/RomFile.h" #include "Utility/Timer.h" +#include "Utility/Paths.h" extern float gCurrentFramerate; extern EFrameskipValue gFrameskipValue; extern RomInfo g_ROM; static uint8_t currentPage = 0; -#define DAEDALUS_CTR_PATH(p) "sdmc:/3ds/DaedalusX64/" p + static void ExecSaveState(int slot) { - std::filesystem::path full_path; - std::string path = std::format("{}{}.ss{}", "SaveStates", g_ROM.settings.GameName.c_str(), slot); - - full_path = path; - // snprintf(full_path, sizeof(full_path), "%s%s.ss%d", "SaveStates/", g_ROM.settings.GameName.c_str(), slot); + std::filesystem::path savePath = setBasePath("SaveStates"); + std::string name = g_ROM.settings.GameName; + savePath /= name; + std::filesystem::create_directories(savePath); - CPU_RequestSaveState(full_path); + std::string filename = std::format("saveslot{}.ss", slot); + savePath /= filename; + + std::cout << "Save Save Slot Path" << savePath << std::endl; + CPU_RequestSaveState(savePath); } static void LoadSaveState(int slot) { - std::filesystem::path full_path; - std::string path = std::format("{}{}.ss{}", "SaveStates", g_ROM.settings.GameName.c_str(), slot); - full_path = path; + std::filesystem::path savePath = setBasePath("SaveStates"); + std::string name = g_ROM.settings.GameName; + savePath /= name; + std::filesystem::create_directories(savePath); + + std::string filename = std::format("saveslot{}.ss", slot); + savePath /= filename; + + std::cout << "Load Save Slot Path" << savePath << std::endl; // snprintf(full_path),sizeof(full_path), "%s%s.ss%d", "SaveStates/", g_ROM.settings.GameName.c_str(), slot); - CPU_RequestLoadState(full_path); + CPU_RequestLoadState(savePath); } static bool SaveStateExists(int slot) { - std::filesystem::path full_path; - std::string path = std::format("{}{}.ss{}", "SaveStates", g_ROM.settings.GameName.c_str(), slot); - full_path = path; + std::filesystem::path savePath = setBasePath("SaveStates"); + std::string name = g_ROM.settings.GameName; + savePath /= name; + std::filesystem::create_directories(savePath); + + std::string filename = std::format("saveslot{}.ss", slot); + savePath /= filename; + + // std::string path = std::format("{}/{}{}.ss", "SaveStates", g_ROM.settings.GameName.c_str(), slot); + // full_path = path; + std::cout << "Slot Exists Path" << savePath << std::endl; // snprintf(full_path, sizeof(full_path), "%s%s.ss%d", DAEDALUS_CTR_PATH("SaveStates/"), g_ROM.settings.GameName.c_str(), slot); // snprintf(full_path, sizeof(full_path), "%s%s.ss%d", "SaveStates/", g_ROM.settings.GameName.c_str(), slot); - return std::filesystem::exists(full_path); + return std::filesystem::exists(savePath); } static void DrawSaveStatePage() From 32d2b7f057af4ded71eed0209c3f686f4cf0ef74 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Wed, 7 Aug 2024 20:16:22 +1000 Subject: [PATCH 26/31] Enable O3 for CTR Build --- Source/CMakeLists.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d2c59b95..1febca9e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -30,8 +30,13 @@ else() message("Release Build") set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) add_compile_definitions(DAEDALUS_CONFIG_VERSION="Release") ## Show the build type in the UI - option(DAEDALUS_SILENT "Shhh, no debug console message, on by default" OFF) -endif() + option(DAEDALUS_SILENT "Shhh, no debug console message, on by default" ON) + option(DAEDALUS_DEBUG_CONSOLE "Enable Debug Console" OFF) + message (${CMAKE_CXX_FLAGS_RELEASE}) + if(DAEDALUS_CTR) + set( CMAKE_CXX_FLAGS_RELEASE "-g -O3 -DNDEBUG") + endif() + endif() #Determine Dynarec compatibility and link in appropriate Dynarec #Todo: Move all relevant Dynarec to the Dynarec/arch folder and enable here when correct platform is detected if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64" ) @@ -75,7 +80,7 @@ endif() # General options option(DAEDALUS_BATCH_TEST_ENABLED "Enable batch testing for compatibility" OFF) - option(DAEDALUS_ENABLE_OS_HOOKS "Enable High Level Emulation Hooks" ON) ## Per platform? + option(DAEDALUS_COMPRESSED_ROM_SUPPORT "Enable Compressed ROM Support" OFF) ## Probably should be a default option. option(DAEDALUS_LOG "Log stuff " OFF) ## NEeds to be off on the PSP unless debugging @@ -112,10 +117,10 @@ endif() option(DAEDALUS_SIM_DOUBLES "Simulate Doubles" ON) option(INTRAFONT "Use Native Fonts" ON) #If this is off, SDL will be enabled option(DAEDALUS_SDL "Enable SDL" OFF) + option(DAEDALUS_ENABLE_OS_HOOKS "Enable High Level Emulation Hooks" ON) elseif(UNIX) option(DAEDALUS_SDL "SDL Build" ON) - option(DAEDALUS_ENABLE_DYNAREC "Enable Dynamic Recompilation, Disable if system not supported" OFF) option(DAEDALUS_POSIX "Posix specific options" ON) option(DAEDALUS_ACCURATE_TMEM "Accurate TMEM" ON) option(DAEDALUS_128BIT_MULT "128 Bit Multiplication, not supported on PSP" ON) @@ -126,15 +131,13 @@ endif() option(DAED_USE_VIRTUAL_ALLOC "Use Windows Memory specifiers" ON) # We probably need to remove and simplfy this using modern C++ option(DAEDALUS_ACCURATE_CVT "Convert using the rounding mode specified in the Floating Control/Status register (FCSR)" ON) option(DAEDALUS_W32 "Windows specific Options" ON) - option(DAEDALUS_ENABLE_DYNAREC "Enable Dynamic Recompilation, Disable if system not supported" ON) option(DAEDALUS_ACCURATE_TMEM "Accurate TMEM" ON) option(DAEDALUS_BREAKPOINTS_ENABLED "Enable Breakpoints" OFF) option(DAEDALUS_GL "OpenGL Renderer" ON) enable_language(CXX ASM_MASM) elseif(CTR) + option(DAEDALUS_ENABLE_OS_HOOKS "Enable High Level Emulation Hooks" OFF) ## Causes some weird black screen issues option(DAEDALUS_CTR "3DS Specific Options" ON) - option(DAEDALUS_ENABLE_DYNAREC "Enable Dynamic Recompilation" ON) - option(DAEDALUS_ENABLE_OS_HOOKS " High Level Emulation Hooks" ON) endif() # Needed below the options to post process @@ -216,8 +219,9 @@ link_libraries(ZLIB::ZLIB) add_subdirectory(RomFile) add_subdirectory(System) add_subdirectory(Utility) + if(NOT CTR) add_subdirectory(UI) - + endif() if(UNIX) add_subdirectory(SysPosix) add_subdirectory(SysGL) From 6106446a60c97409fff790e0ada2ac231e2de46b Mon Sep 17 00:00:00 2001 From: wally4000 Date: Fri, 9 Aug 2024 19:14:31 +1000 Subject: [PATCH 27/31] Move Dynamo back to core. Performance goes all weird --- Source/Core/CMakeLists.txt | 1 + Source/Core/CPU.cpp | 2 +- Source/{DynaRec => Core}/Dynamo.cpp | 2 +- Source/{DynaRec => Core}/Dynamo.h | 0 Source/DynaRec/CMakeLists.txt | 1 - 5 files changed, 3 insertions(+), 3 deletions(-) rename Source/{DynaRec => Core}/Dynamo.cpp (96%) rename Source/{DynaRec => Core}/Dynamo.h (100%) diff --git a/Source/Core/CMakeLists.txt b/Source/Core/CMakeLists.txt index 16b22f22..d07fa162 100644 --- a/Source/Core/CMakeLists.txt +++ b/Source/Core/CMakeLists.txt @@ -3,6 +3,7 @@ add_library(Core OBJECT CPU.cpp DMA.cpp + Dynamo.cpp FlashMem.cpp Interpret.cpp Interrupt.cpp diff --git a/Source/Core/CPU.cpp b/Source/Core/CPU.cpp index 979eeeaa..27eb900a 100644 --- a/Source/Core/CPU.cpp +++ b/Source/Core/CPU.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Interface/ConfigOptions.h" #include "Interface/Cheats.h" -#include "DynaRec/Dynamo.h" +#include "Core/Dynamo.h" #include "Core/Interpret.h" #include "Core/Interrupt.h" #include "Core/Memory.h" diff --git a/Source/DynaRec/Dynamo.cpp b/Source/Core/Dynamo.cpp similarity index 96% rename from Source/DynaRec/Dynamo.cpp rename to Source/Core/Dynamo.cpp index 2475f94b..d63ec574 100644 --- a/Source/DynaRec/Dynamo.cpp +++ b/Source/Core/Dynamo.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "Base/Types.h" -#include "DynaRec/Dynamo.h" +#include "Core/Dynamo.h" diff --git a/Source/DynaRec/Dynamo.h b/Source/Core/Dynamo.h similarity index 100% rename from Source/DynaRec/Dynamo.h rename to Source/Core/Dynamo.h diff --git a/Source/DynaRec/CMakeLists.txt b/Source/DynaRec/CMakeLists.txt index 017bcc8c..5c087ebf 100644 --- a/Source/DynaRec/CMakeLists.txt +++ b/Source/DynaRec/CMakeLists.txt @@ -15,7 +15,6 @@ endif() add_library(DynaRec OBJECT ${SRC_FILES} BranchType.cpp - Dynamo.cpp DynaRecProfile.cpp Fragment.cpp FragmentCache.cpp From 25786904f3736dfb2ab71af01cb47442ece85330 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Fri, 9 Aug 2024 19:14:46 +1000 Subject: [PATCH 28/31] Don't use extern basedir anymore, create directories if needed --- Source/Utility/Paths.cpp | 4 ++++ Source/Utility/Paths.h | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Utility/Paths.cpp b/Source/Utility/Paths.cpp index 98e04742..60c2e93c 100644 --- a/Source/Utility/Paths.cpp +++ b/Source/Utility/Paths.cpp @@ -40,6 +40,10 @@ const std::filesystem::path baseDir = std::filesystem::current_path(); std::filesystem::path setBasePath(const std::filesystem::path& path) { auto combinedPath = baseDir / path; + if (std::filesystem::is_directory(combinedPath)) + { + std::filesystem::create_directories(combinedPath); + } std::cout << "Path set for:" << path << "to:" << combinedPath << std::endl; return combinedPath; } \ No newline at end of file diff --git a/Source/Utility/Paths.h b/Source/Utility/Paths.h index 3caf305f..67f572f5 100644 --- a/Source/Utility/Paths.h +++ b/Source/Utility/Paths.h @@ -5,7 +5,6 @@ #include -extern const std::filesystem::path baseDir; std::filesystem::path setBasePath(const std::filesystem::path& path); #endif //UTILITY_PATHS_H \ No newline at end of file From 2e9ed6cce26cbf838a24a4342e9a46e95a861b22 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Fri, 9 Aug 2024 19:16:08 +1000 Subject: [PATCH 29/31] Remove Dynamo reference from PauseOptions --- Source/UI/PauseOptionsComponent.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/UI/PauseOptionsComponent.cpp b/Source/UI/PauseOptionsComponent.cpp index 4422c66d..ad8193ec 100644 --- a/Source/UI/PauseOptionsComponent.cpp +++ b/Source/UI/PauseOptionsComponent.cpp @@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core/CPU.h" -#include "DynaRec/Dynamo.h" #include "Core/ROM.h" #include "Interface/SaveState.h" #include "HLEGraphics/DisplayListDebugger.h" From 052d6b17b16181e2d9bdc6bae88fbdc79c1d8864 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Fri, 9 Aug 2024 19:16:28 +1000 Subject: [PATCH 30/31] Add function to get CRC --- Source/Core/ROMImage.cpp | 11 ++++++++++- Source/Core/ROMImage.h | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/Core/ROMImage.cpp b/Source/Core/ROMImage.cpp index 98fb7670..6c05a050 100644 --- a/Source/Core/ROMImage.cpp +++ b/Source/Core/ROMImage.cpp @@ -20,7 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Base/Types.h" #include "Core/ROMImage.h" - +#include +#include // Find out the CIC type ECicType ROM_GenerateCICType( const u8 * p_rom_base ) { @@ -58,3 +59,11 @@ const char * ROM_GetCicName( ECicType cic_type ) default: return "?"; } } + +std::string ROM_GetCRC(const ROMHeader& header) +{ + // Convert CRC values to strings and concatenate them + std::stringstream crcStream; + crcStream << "{" << std::hex << std::uppercase << header.CRC1 << header.CRC2 << "}"; + return crcStream.str(); +} \ No newline at end of file diff --git a/Source/Core/ROMImage.h b/Source/Core/ROMImage.h index e5adc252..794c9c1c 100644 --- a/Source/Core/ROMImage.h +++ b/Source/Core/ROMImage.h @@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CORE_ROMIMAGE_H_ #include "Base/Types.h" +#include +#include //const u32 RAMROM_FONTDATA_SIZE = 1152; //const u32 RAMROM_CLOCKRATE_MASK = 0xfffffff0; @@ -72,4 +74,6 @@ ECicType ROM_GenerateCICType( const u8 * rom_base ); const char * ROM_GetCicName( ECicType cic_type ); +std::string ROM_GetCRC(const ROMHeader& header); + #endif // CORE_ROMIMAGE_H_ From 7000be3afbfa4d27a70aacf2868aa8bdea7b27c1 Mon Sep 17 00:00:00 2001 From: wally4000 Date: Fri, 9 Aug 2024 19:17:00 +1000 Subject: [PATCH 31/31] Remove -g flag from CMAKE_FXX_FLAGS_RELEASE --- Source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1febca9e..2e566efc 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -34,7 +34,7 @@ else() option(DAEDALUS_DEBUG_CONSOLE "Enable Debug Console" OFF) message (${CMAKE_CXX_FLAGS_RELEASE}) if(DAEDALUS_CTR) - set( CMAKE_CXX_FLAGS_RELEASE "-g -O3 -DNDEBUG") + set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") endif() endif() #Determine Dynarec compatibility and link in appropriate Dynarec