From d46448cdf8a2923d98fc537f5b3de199834dc0c9 Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sat, 28 Oct 2023 01:06:38 -0400 Subject: [PATCH 1/9] MM --- CMakeLists.txt | 4 ++-- extern/ZAPDUtils/Utils/DiskFile.h | 12 ++++++++++++ include/libultraship/libultra/abi.h | 20 ++++++++++++++------ src/debug/CrashHandler.cpp | 8 ++++++++ src/graphic/Fast3D/gfx_pc.cpp | 6 +++--- src/public/bridge/resourcebridge.cpp | 3 +++ src/resource/ResourceManager.cpp | 13 ++++++++++++- src/resource/ResourceType.h | 3 +++ 8 files changed, 57 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0b689413..6a3844f17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,8 @@ include(cmake/Utils.cmake) if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND USE_AUTO_VCPKG) include(cmake/automate-vcpkg.cmake) - set(VCPKG_TRIPLET x64-windows-static) - set(VCPKG_TARGET_TRIPLET x64-windows-static) + set(VCPKG_TRIPLET x86-windows-static) + set(VCPKG_TARGET_TRIPLET x86-windows-static) vcpkg_bootstrap() vcpkg_install_packages(zlib bzip2 sdl2 glew) diff --git a/extern/ZAPDUtils/Utils/DiskFile.h b/extern/ZAPDUtils/Utils/DiskFile.h index 74962a02a..51aefb44a 100644 --- a/extern/ZAPDUtils/Utils/DiskFile.h +++ b/extern/ZAPDUtils/Utils/DiskFile.h @@ -81,7 +81,19 @@ class DiskFile static void WriteAllText(const fs::path& filePath, const std::string& text) { + try { + std::filesystem::create_directories(filePath.parent_path().string()); + } catch (std::filesystem::filesystem_error const& ex) { + std::cout << "what(): " << ex.what() << '\n' + << "path1(): " << ex.path1() << '\n' + << "path2(): " << ex.path2() << '\n' + << "code().value(): " << ex.code().value() << '\n' + << "code().message(): " << ex.code().message() << '\n' + << "code().category(): " << ex.code().category().name() << '\n'; + } std::ofstream file(filePath, std::ios::out); + + file.write(text.c_str(), text.size()); } }; diff --git a/include/libultraship/libultra/abi.h b/include/libultraship/libultra/abi.h index 99d8ddf35..3b0912f72 100644 --- a/include/libultraship/libultra/abi.h +++ b/include/libultraship/libultra/abi.h @@ -37,6 +37,7 @@ typedef unsigned int u32; #define A_INIT 0x01 #define A_CONTINUE 0x00 #define A_LOOP 0x02 +#define A_ADPCM_SHORT 0x04 #define A_OUT 0x02 #define A_LEFT 0x02 #define A_RIGHT 0x00 @@ -446,13 +447,20 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (u32)(addr); \ } -#define aDuplicate(pkt, count, dmemi, dmemo, a4) \ - { \ - Acmd* _a = (Acmd*)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | _SHIFTL(count, 16, 8) | _SHIFTL(dmemi, 0, 16)); \ - _a->words.w1 = _SHIFTL(dmemo, 16, 16) | _SHIFTL(a4, 0, 16); \ +#define aDuplicate(pkt, numCopies, dmemSrc, dmemDest) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | _SHIFTL(numCopies, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmemDest, 16, 16) | _SHIFTL(0x80, 0, 16); \ } +//#define aDuplicate(pkt, count, dmemi, dmemo, a4) \ +// { \ +// Acmd* _a = (Acmd*)pkt; \ +// \ +// _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | _SHIFTL(count, 16, 8) | _SHIFTL(dmemi, 0, 16)); \ +// _a->words.w1 = _SHIFTL(dmemo, 16, 16) | _SHIFTL(a4, 0, 16); \ +// } #define aAddMixer(pkt, count, dmemi, dmemo, a4) \ { \ diff --git a/src/debug/CrashHandler.cpp b/src/debug/CrashHandler.cpp index 47855e53b..287a00630 100644 --- a/src/debug/CrashHandler.cpp +++ b/src/debug/CrashHandler.cpp @@ -74,6 +74,7 @@ void CrashHandler::PrintCommon() { #if (__linux__) void CrashHandler::PrintRegisters(ucontext_t* ctx) { + #if 0 char regbuffer[30]; AppendLine("Registers:"); #if defined(__x86_64__) @@ -135,6 +136,7 @@ void CrashHandler::PrintRegisters(ucontext_t* ctx) { snprintf(regbuffer, std::size(regbuffer), "EFL: 0x%08lX", ctx->uc_mcontext.gregs[REG_EFL]); AppendLine(regbuffer); #endif + #endif } static void ErrorHandler(int sig, siginfo_t* sigInfo, void* data) { @@ -215,6 +217,7 @@ static void ShutdownHandler(int sig, siginfo_t* sigInfo, void* data) { void CrashHandler::PrintRegisters(CONTEXT* ctx) { AppendLine("Registers: "); char regBuff[25]; + #if 0 #if defined(_M_AMD64) sprintf_s(regBuff, std::size(regBuff), "RAX: 0x%016llX", ctx->Rax); AppendLine(regBuff); @@ -294,9 +297,11 @@ void CrashHandler::PrintRegisters(CONTEXT* ctx) { sprintf_s(regBuff, std::size(regBuff), "EIP: 0x%08lX", ctx->Eip); AppendLine(regBuff); #endif + #endif } void CrashHandler::PrintStack(CONTEXT* ctx) { + #if 0 BOOL result; HANDLE process; HANDLE thread; @@ -387,6 +392,7 @@ void CrashHandler::PrintStack(CONTEXT* ctx) { PrintCommon(); LUS::Context::GetInstance()->GetLogger()->flush(); spdlog::shutdown(); + #endif } extern "C" LONG seh_filter(struct _EXCEPTION_POINTERS* ex) { @@ -409,6 +415,7 @@ extern "C" LONG seh_filter(struct _EXCEPTION_POINTERS* ex) { #endif CrashHandler::CrashHandler() { + #if 0 mOutBuffer = new char[gMaxBufferSize]; #if defined(__linux__) struct sigaction action; @@ -431,6 +438,7 @@ CrashHandler::CrashHandler() { #elif _WIN32 SetUnhandledExceptionFilter(seh_filter); #endif + #endif } CrashHandler::CrashHandler(CrashHandlerCallback callback) { diff --git a/src/graphic/Fast3D/gfx_pc.cpp b/src/graphic/Fast3D/gfx_pc.cpp index 537f5923d..0658e9b0e 100644 --- a/src/graphic/Fast3D/gfx_pc.cpp +++ b/src/graphic/Fast3D/gfx_pc.cpp @@ -1961,9 +1961,9 @@ static void gfx_dp_set_tile_size(uint8_t tile, uint16_t uls, uint16_t ult, uint1 static void gfx_dp_load_tlut(uint8_t tile, uint32_t high_index) { SUPPORT_CHECK(tile == G_TX_LOADTILE); SUPPORT_CHECK(rdp.texture_to_load.siz == G_IM_SIZ_16b); - - SUPPORT_CHECK((rdp.texture_tile[tile].tmem == 256 && (high_index <= 127 || high_index == 255)) || - (rdp.texture_tile[tile].tmem == 384 && high_index == 127)); + // BENTODO + //SUPPORT_CHECK((rdp.texture_tile[tile].tmem == 256 && (high_index <= 127 || high_index == 255)) || + // (rdp.texture_tile[tile].tmem == 384 && high_index == 127)); if (rdp.texture_tile[tile].tmem == 256) { rdp.palettes[0] = rdp.texture_to_load.addr; diff --git a/src/public/bridge/resourcebridge.cpp b/src/public/bridge/resourcebridge.cpp index 83d41485c..3e18e7098 100644 --- a/src/public/bridge/resourcebridge.cpp +++ b/src/public/bridge/resourcebridge.cpp @@ -59,6 +59,9 @@ uint8_t ResourceGetIsCustomByCrc(uint64_t crc) { } void* ResourceGetDataByName(const char* name) { + if(strcmp(name, "__OTR__misc/link_animation/gPlayerAnim_link_normal_wait_free_Data") == 0) { + int bp = 5; + } auto resource = ResourceLoad(name); if (resource == nullptr) { diff --git a/src/resource/ResourceManager.cpp b/src/resource/ResourceManager.cpp index 8c705f1cf..de1446d68 100644 --- a/src/resource/ResourceManager.cpp +++ b/src/resource/ResourceManager.cpp @@ -59,7 +59,11 @@ bool ResourceManager::DidLoadSuccessfully() { } std::shared_ptr ResourceManager::LoadFileProcess(const std::string& filePath) { + if (filePath == "objects/gameplay_keep/gPlayerAnim_link_normal_wait_free") { + int bp = 5; + } auto file = mArchive->LoadFile(filePath, true); + if (file != nullptr) { SPDLOG_TRACE("Loaded File {} on ResourceManager", file->Path); } else { @@ -70,6 +74,10 @@ std::shared_ptr ResourceManager::LoadFileProcess(const std::string& filePa std::shared_ptr ResourceManager::LoadResourceProcess(const std::string& filePath, bool loadExact) { // Check for and remove the OTR signature + SPDLOG_TRACE("LOAD RESOURCE PROCESS {}", filePath); + if (filePath == "misc/link_animation/gPlayerAnim_link_normal_wait_free_Data") { + int bp = 5; + } if (OtrSignatureCheck(filePath.c_str())) { const auto newFilePath = filePath.substr(7); return LoadResourceProcess(newFilePath); @@ -163,6 +171,9 @@ std::shared_ptr ResourceManager::LoadFile(const std::string& filePath) { std::shared_future> ResourceManager::LoadResourceAsync(const std::string& filePath, bool loadExact, bool priority) { + if (filePath == "misc/link_animation/gPlayerAnim_link_normal_wait_free_Data") { + int bp = 5; + } // Check for and remove the OTR signature if (OtrSignatureCheck(filePath.c_str())) { auto newFilePath = filePath.substr(7); @@ -187,7 +198,7 @@ std::shared_future> ResourceManager::LoadResourceAsyn } std::shared_ptr ResourceManager::LoadResource(const std::string& filePath, bool loadExact) { - auto resource = LoadResourceAsync(filePath, loadExact, true).get(); + auto resource = LoadResourceProcess(filePath, true); // LoadResourceAsync(filePath, loadExact, true).get(); if (resource == nullptr) { SPDLOG_ERROR("Failed to load resource file at path {}", filePath); } diff --git a/src/resource/ResourceType.h b/src/resource/ResourceType.h index cc0512a86..7b13ba1b0 100644 --- a/src/resource/ResourceType.h +++ b/src/resource/ResourceType.h @@ -31,5 +31,8 @@ enum class ResourceType { SOH_AudioSequence = 0x4F534551, // OSEQ SOH_Background = 0x4F424749, // OBGI SOH_SceneCommand = 0x4F52434D, // ORCM + + //LUS of Two + TSH_TexAnim = 0x4F54414E, //OTAN }; } // namespace LUS From 0063a454bbaae3f02b6be8975264eca2e91fd214 Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sat, 4 Nov 2023 14:49:42 -0400 Subject: [PATCH 2/9] Work for MM --- include/libultraship/libultra/gbi.h | 14 ++++++++++++++ src/public/bridge/resourcebridge.cpp | 3 --- src/resource/ResourceManager.cpp | 1 - 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/libultraship/libultra/gbi.h b/include/libultraship/libultra/gbi.h index f72898d72..9923bd19a 100644 --- a/include/libultraship/libultra/gbi.h +++ b/include/libultraship/libultra/gbi.h @@ -343,6 +343,7 @@ #define G_TEXTURE_GEN 0x00040000 #define G_TEXTURE_GEN_LINEAR 0x00080000 #define G_LOD 0x00100000 /* NOT IMPLEMENTED */ +#define G_LIGHTING_POSITIONAL 0x00400000 #if (defined(F3DEX_GBI) || defined(F3DLP_GBI)) #define G_CLIPPING 0x00800000 #else @@ -1270,6 +1271,15 @@ typedef struct { char pad3; } Light_t; +typedef struct { + unsigned char col[3]; + unsigned char unk3; + unsigned char colc[3]; + unsigned char unk7; + short pos[3]; + unsigned char unkE; +} PointLight_t; + typedef struct { unsigned char col[3]; /* ambient light value (rgba) */ char pad1; @@ -1283,6 +1293,7 @@ typedef struct { typedef union { Light_t l; + PointLight_t p; long long int force_structure_alignment[2]; } Light; @@ -2785,6 +2796,9 @@ typedef union { #define gsDPSetAlphaDither(mode) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) #endif +#define gDPSetDither(pkt, mode) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 4, mode) + + /* 'blendmask' is not supported anymore. * The bits are reserved for future use. * Fri May 26 13:45:55 PDT 1995 diff --git a/src/public/bridge/resourcebridge.cpp b/src/public/bridge/resourcebridge.cpp index 3e18e7098..83d41485c 100644 --- a/src/public/bridge/resourcebridge.cpp +++ b/src/public/bridge/resourcebridge.cpp @@ -59,9 +59,6 @@ uint8_t ResourceGetIsCustomByCrc(uint64_t crc) { } void* ResourceGetDataByName(const char* name) { - if(strcmp(name, "__OTR__misc/link_animation/gPlayerAnim_link_normal_wait_free_Data") == 0) { - int bp = 5; - } auto resource = ResourceLoad(name); if (resource == nullptr) { diff --git a/src/resource/ResourceManager.cpp b/src/resource/ResourceManager.cpp index de1446d68..4aca2900f 100644 --- a/src/resource/ResourceManager.cpp +++ b/src/resource/ResourceManager.cpp @@ -74,7 +74,6 @@ std::shared_ptr ResourceManager::LoadFileProcess(const std::string& filePa std::shared_ptr ResourceManager::LoadResourceProcess(const std::string& filePath, bool loadExact) { // Check for and remove the OTR signature - SPDLOG_TRACE("LOAD RESOURCE PROCESS {}", filePath); if (filePath == "misc/link_animation/gPlayerAnim_link_normal_wait_free_Data") { int bp = 5; } From 5fd278e71ae303e73d178657e1863d7892ff6d77 Mon Sep 17 00:00:00 2001 From: Nicholas Estelami Date: Sat, 4 Nov 2023 21:23:48 -0400 Subject: [PATCH 3/9] Fixed palette issues in MM (#1) * Fixed palette issues with MM * Test --- src/graphic/Fast3D/gfx_pc.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/graphic/Fast3D/gfx_pc.cpp b/src/graphic/Fast3D/gfx_pc.cpp index 0658e9b0e..c3dee0457 100644 --- a/src/graphic/Fast3D/gfx_pc.cpp +++ b/src/graphic/Fast3D/gfx_pc.cpp @@ -817,7 +817,15 @@ static void import_texture_ci4(int tile, bool importReplacement) { rdp.loaded_texture[rdp.texture_tile[tile].tmem_index].full_image_line_size_bytes; uint32_t line_size_bytes = rdp.loaded_texture[rdp.texture_tile[tile].tmem_index].line_size_bytes; uint32_t pal_idx = rdp.texture_tile[tile].palette; // 0-15 - const uint8_t* palette = rdp.palettes[pal_idx / 8] + (pal_idx % 8) * 16 * 2; // 16 pixel entries, 16 bits each + + uint8_t* palette = nullptr; + //const uint8_t* palette = rdp.palettes[pal_idx / 8] + (pal_idx % 8) * 16 * 2; // 16 pixel entries, 16 bits each + + if (pal_idx > 7) + palette = (uint8_t*)rdp.palettes[pal_idx / 8]; // 16 pixel entries, 16 bits each + else + palette = (uint8_t*)(rdp.palettes[pal_idx / 8] + (pal_idx % 8) * 16 * 2); + SUPPORT_CHECK(full_image_line_size_bytes == line_size_bytes); for (uint32_t i = 0; i < size_bytes * 2; i++) { @@ -1907,7 +1915,8 @@ static void gfx_dp_set_scissor(uint32_t mode, uint32_t ulx, uint32_t uly, uint32 } static void gfx_dp_set_texture_image(uint32_t format, uint32_t size, uint32_t width, const char* texPath, - uint32_t texFlags, RawTexMetadata rawTexMetdata, const void* addr) { + uint32_t texFlags, RawTexMetadata rawTexMetdata, const void* addr) +{ rdp.texture_to_load.addr = (const uint8_t*)addr; rdp.texture_to_load.siz = size; rdp.texture_to_load.width = width; @@ -1919,7 +1928,7 @@ static void gfx_dp_set_tile(uint8_t fmt, uint32_t siz, uint32_t line, uint32_t t uint32_t cmt, uint32_t maskt, uint32_t shiftt, uint32_t cms, uint32_t masks, uint32_t shifts) { // OTRTODO: - // SUPPORT_CHECK(tmem == 0 || tmem == 256); + //SUPPORT_CHECK(tmem == 0 || tmem == 256); if (cms == G_TX_WRAP && masks == G_TX_NOMASK) { cms = G_TX_CLAMP; @@ -1937,14 +1946,11 @@ static void gfx_dp_set_tile(uint8_t fmt, uint32_t siz, uint32_t line, uint32_t t rdp.texture_tile[tile].shiftt = shiftt; rdp.texture_tile[tile].line_size_bytes = line * 8; - if (rdp.texture_tile[tile].line_size_bytes > 15000) { - int bp = 0; - } - rdp.texture_tile[tile].tmem = tmem; // rdp.texture_tile[tile].tmem_index = tmem / 256; // tmem is the 64-bit word offset, so 256 words means 2 kB - rdp.texture_tile[tile].tmem_index = - tmem != 0; // assume one texture is loaded at address 0 and another texture at any other address + + rdp.texture_tile[tile].tmem_index = tmem != 0; // assume one texture is loaded at address 0 and another texture at any other address + rdp.textures_changed[0] = true; rdp.textures_changed[1] = true; } @@ -1965,6 +1971,7 @@ static void gfx_dp_load_tlut(uint8_t tile, uint32_t high_index) { //SUPPORT_CHECK((rdp.texture_tile[tile].tmem == 256 && (high_index <= 127 || high_index == 255)) || // (rdp.texture_tile[tile].tmem == 384 && high_index == 127)); + if (rdp.texture_tile[tile].tmem == 256) { rdp.palettes[0] = rdp.texture_to_load.addr; if (high_index == 255) { From 7d054576804a84021d10f1b898d4c3c8b2482ae6 Mon Sep 17 00:00:00 2001 From: Nicholas Estelami Date: Sat, 11 Nov 2023 22:45:47 -0500 Subject: [PATCH 4/9] Added MM Text Resource Type --- src/resource/ResourceType.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/resource/ResourceType.h b/src/resource/ResourceType.h index 7b13ba1b0..d10ebc140 100644 --- a/src/resource/ResourceType.h +++ b/src/resource/ResourceType.h @@ -25,6 +25,7 @@ enum class ResourceType { SOH_Path = 0x4F505448, // OPTH SOH_Cutscene = 0x4F435654, // OCUT SOH_Text = 0x4F545854, // OTXT + SOH_TextMM = 0x4F54584D, // OTXM SOH_Audio = 0x4F415544, // OAUD SOH_AudioSample = 0x4F534D50, // OSMP SOH_AudioSoundFont = 0x4F534654, // OSFT From 413428d2510da7e83390e3c930ea9b07abc33109 Mon Sep 17 00:00:00 2001 From: Louis <35883445+louist103@users.noreply.github.com> Date: Tue, 14 Nov 2023 22:44:48 -0500 Subject: [PATCH 5/9] opcode for open/close disps --- src/graphic/Fast3D/gfx_pc.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/graphic/Fast3D/gfx_pc.cpp b/src/graphic/Fast3D/gfx_pc.cpp index c3dee0457..aa687cba3 100644 --- a/src/graphic/Fast3D/gfx_pc.cpp +++ b/src/graphic/Fast3D/gfx_pc.cpp @@ -2465,7 +2465,7 @@ static inline void* seg_addr(uintptr_t w1) { #define C1(pos, width) ((cmd->words.w1 >> (pos)) & ((1U << width) - 1)) uintptr_t clearMtx; - +extern "C" char* ResourceMgr_GetNameByCRC(uint64_t crc, char* alloc); static void gfx_run_dl(Gfx* cmd) { // puts("dl"); int dummy = 0; @@ -2494,9 +2494,10 @@ static void gfx_run_dl(Gfx* cmd) { ourHash = ((uint64_t)cmd->words.w0 << 32) + cmd->words.w1; #if _DEBUG - // uint64_t hash = ((uint64_t)cmd->words.w0 << 32) + cmd->words.w1; - // ResourceMgr_GetNameByCRC(hash, dlName); - // lusprintf(__FILE__, __LINE__, 6, "G_MARKER: %s\n", dlName); + //uint64_t hash = ((uint64_t)cmd->words.w0 << 32) + cmd->words.w1; + //const char* str = ResourceGetNameByCrc(hash); + //memcpy(dlName, str, strlen(str)); + //lusprintf(__FILE__, __LINE__, 6, "G_MARKER: %s\n", dlName); #endif markerOn = true; @@ -2510,7 +2511,17 @@ static void gfx_run_dl(Gfx* cmd) { gfx_texture_cache_delete((const uint8_t*)texAddr); } } break; - case G_NOOP: + case G_NOOP: { + break; + char* file = (char*)cmd->words.w1; + int line = cmd->words.w0 & 0xFFFF; + int magic = (cmd->words.w0 >> 16) & 0xFF; + if (magic == 7) { + lusprintf(__FILE__, __LINE__, 6, "OPEN DISPS: %s : %d\n", file, line); + } else if (magic == 8) { + lusprintf(__FILE__, __LINE__, 6, "CLOSE DISPS: %s : %d\n", file, line); + } + } break; case G_MTX: { uintptr_t mtxAddr = cmd->words.w1; @@ -2723,7 +2734,7 @@ static void gfx_run_dl(Gfx* cmd) { case (uint8_t)G_ENDDL: // if (markerOn) - // printf("END DL ON MARKER\n"); + //lusprintf("END DL ON MARKER\n"); markerOn = false; return; From 0ca42bff5f32681e8e516657b98dee6dff62db1d Mon Sep 17 00:00:00 2001 From: Random <28494085+Random06457@users.noreply.github.com> Date: Tue, 21 Nov 2023 03:12:18 +0100 Subject: [PATCH 6/9] Gfx Debugger (#2) * BitConverter: fix type correcteness in loop * gbi: get rid of LoadUcode macros * Gui: add ability to make a GuiImage out of a LUS::Texture * Add GfxDebugger * GfxDebugger: add C Bridge * gfx_pc: expose internal state + intergrate debugger * Add GfxDebuggerWindow * Context: integrate GfxDebuggerWindow * update CMakeLists.txt * GfxDebugger: move inline code from header to cpp file --- extern/ZAPDUtils/Utils/BitConverter.h | 4 +- include/libultraship/bridge.h | 1 + include/libultraship/libultra/gbi.h | 4 +- src/CMakeLists.txt | 36 +- src/Context.cpp | 14 + src/Context.h | 4 + src/debug/GfxDebugger.cpp | 54 + src/debug/GfxDebugger.h | 34 + src/graphic/Fast3D/gfx_pc.cpp | 2091 ++++++++++++----------- src/graphic/Fast3D/gfx_pc.h | 134 ++ src/public/bridge/gfxdebuggerbridge.cpp | 16 + src/public/bridge/gfxdebuggerbridge.h | 22 + src/window/gui/GfxDebuggerWindow.cpp | 479 ++++++ src/window/gui/GfxDebuggerWindow.h | 27 + src/window/gui/Gui.cpp | 131 +- src/window/gui/Gui.h | 3 + 16 files changed, 2000 insertions(+), 1054 deletions(-) create mode 100644 src/debug/GfxDebugger.cpp create mode 100644 src/debug/GfxDebugger.h create mode 100644 src/public/bridge/gfxdebuggerbridge.cpp create mode 100644 src/public/bridge/gfxdebuggerbridge.h create mode 100644 src/window/gui/GfxDebuggerWindow.cpp create mode 100644 src/window/gui/GfxDebuggerWindow.h diff --git a/extern/ZAPDUtils/Utils/BitConverter.h b/extern/ZAPDUtils/Utils/BitConverter.h index 46845fe36..c90b3dfbd 100644 --- a/extern/ZAPDUtils/Utils/BitConverter.h +++ b/extern/ZAPDUtils/Utils/BitConverter.h @@ -193,12 +193,12 @@ class BitConverter switch (firstByte) { case 0x37: // v64 - for (int32_t pos = 0; pos < (romSize / 2); pos++) { + for (size_t pos = 0; pos < (romSize / 2); pos++) { ((uint16_t*)rom)[pos] = ToUInt16BE(rom, pos * 2); } break; case 0x40: // n64 - for (int32_t pos = 0; pos < (romSize / 4); pos++) { + for (size_t pos = 0; pos < (romSize / 4); pos++) { ((uint32_t*)rom)[pos] = ToUInt32BE(rom, pos * 4); } break; diff --git a/include/libultraship/bridge.h b/include/libultraship/bridge.h index 9d4f6dca7..668e6b63e 100644 --- a/include/libultraship/bridge.h +++ b/include/libultraship/bridge.h @@ -7,5 +7,6 @@ #include "public/bridge/windowbridge.h" #include "public/bridge/consolevariablebridge.h" #include "public/bridge/crashhandlerbridge.h" +#include "public/bridge/gfxdebuggerbridge.h" #endif diff --git a/include/libultraship/libultra/gbi.h b/include/libultraship/libultra/gbi.h index 9923bd19a..45e124b8b 100644 --- a/include/libultraship/libultra/gbi.h +++ b/include/libultraship/libultra/gbi.h @@ -2282,9 +2282,9 @@ typedef union { #define gsSPLoadUcode(uc_start, uc_dstart) gsSPLoadUcodeEx((uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) #define gSPLoadUcodeL(pkt, ucode) \ - gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&##ucode##TextStart), OS_K0_TO_PHYSICAL(&##ucode##DataStart)) +// gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&##ucode##TextStart), OS_K0_TO_PHYSICAL(&##ucode##DataStart)) #define gsSPLoadUcodeL(ucode) \ - gsSPLoadUcode(OS_K0_TO_PHYSICAL(&##ucode##TextStart), OS_K0_TO_PHYSICAL(&##ucode##DataStart)) +// gsSPLoadUcode(OS_K0_TO_PHYSICAL(&##ucode##TextStart), OS_K0_TO_PHYSICAL(&##ucode##DataStart)) #endif #ifdef F3DEX_GBI_2 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de362932b..ff1b78f04 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,7 +87,7 @@ set(Source_Files__Public__Libultra ${CMAKE_CURRENT_SOURCE_DIR}/public/libultra/os.h ${CMAKE_CURRENT_SOURCE_DIR}/public/libultra/os.cpp ) - + source_group("public/libultra" FILES ${Source_Files__Public__Libultra}) set(Source_Files__Public__Bridge @@ -97,6 +97,8 @@ set(Source_Files__Public__Bridge ${CMAKE_CURRENT_SOURCE_DIR}/public/bridge/windowbridge.cpp ${CMAKE_CURRENT_SOURCE_DIR}/public/bridge/audiobridge.h ${CMAKE_CURRENT_SOURCE_DIR}/public/bridge/audiobridge.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/public/bridge/gfxdebuggerbridge.h + ${CMAKE_CURRENT_SOURCE_DIR}/public/bridge/gfxdebuggerbridge.cpp ${CMAKE_CURRENT_SOURCE_DIR}/public/bridge/controllerbridge.h ${CMAKE_CURRENT_SOURCE_DIR}/public/bridge/controllerbridge.cpp ${CMAKE_CURRENT_SOURCE_DIR}/public/bridge/consolevariablebridge.h @@ -104,7 +106,7 @@ set(Source_Files__Public__Bridge ${CMAKE_CURRENT_SOURCE_DIR}/public/bridge/crashhandlerbridge.h ${CMAKE_CURRENT_SOURCE_DIR}/public/bridge/crashhandlerbridge.cpp ) - + source_group("public/bridge" FILES ${Source_Files__Public__Bridge}) target_sources(libultraship PRIVATE ${Source_Files__Public__Libultra} ${Source_Files__Public__Bridge}) @@ -115,6 +117,8 @@ set(Source_Files__Debug ${CMAKE_CURRENT_SOURCE_DIR}/debug/CrashHandler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/debug/Console.h ${CMAKE_CURRENT_SOURCE_DIR}/debug/Console.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/debug/GfxDebugger.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/debug/GfxDebugger.h ) source_group("debug" FILES ${Source_Files__Debug}) @@ -163,11 +167,35 @@ set(Source_Files__Window__Gui ${CMAKE_CURRENT_SOURCE_DIR}/window/gui/GuiElement.cpp ${CMAKE_CURRENT_SOURCE_DIR}/window/gui/GuiMenuBar.h ${CMAKE_CURRENT_SOURCE_DIR}/window/gui/GuiMenuBar.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/window/gui/GfxDebuggerWindow.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/window/gui/GfxDebuggerWindow.h ) source_group("window/gui" FILES ${Source_Files__Window__Gui}) target_sources(libultraship PRIVATE ${Source_Files__Window__Gui}) + +set(Header_Files__Libraries__libgfxd + "../../ZAPDTR/lib/libgfxd/gbi.h" + "../../ZAPDTR/lib/libgfxd/gfxd.h" + "../../ZAPDTR/lib/libgfxd/priv.h" +) +source_group("Header Files\\Libraries\\libgfxd" FILES ${Header_Files__Libraries__libgfxd}) + +set(Source_Files__Libraries__libgfxd + "../../ZAPDTR/lib/libgfxd/gfxd.c" + "../../ZAPDTR/lib/libgfxd/uc.c" + "../../ZAPDTR/lib/libgfxd/uc_f3d.c" + "../../ZAPDTR/lib/libgfxd/uc_f3db.c" + "../../ZAPDTR/lib/libgfxd/uc_f3dex.c" + "../../ZAPDTR/lib/libgfxd/uc_f3dex2.c" + "../../ZAPDTR/lib/libgfxd/uc_f3dexb.c" +) +source_group("Source Files\\Libraries\\libgfxd" FILES ${Source_Files__Libraries__libgfxd}) + + +target_sources(libultraship PRIVATE ${Header_Files__Libraries__libgfxd} ${Source_Files__Libraries__libgfxd}) + #=================== Utils =================== set(Source_Files__Utils @@ -349,7 +377,7 @@ endif() #=================== Packages & Includes =================== target_include_directories(libultraship - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../extern ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../extern ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../../ZAPDTR/lib/libgfxd PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../extern/spdlog/include ${CMAKE_CURRENT_SOURCE_DIR}/../extern/stb ) @@ -398,7 +426,7 @@ endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set_target_properties(${PROJECT_NAME} PROPERTIES - XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES + XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES ) endif() diff --git a/src/Context.cpp b/src/Context.cpp index 6140e0458..cb08eb027 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -5,6 +5,7 @@ #include #include #include "install_config.h" +#include "debug/GfxDebugger.h" #ifdef __APPLE__ #include "utils/OSXFolderManager.h" @@ -82,6 +83,7 @@ void Context::Init(const std::vector& otrFiles, const std::unordere InitConsole(); InitWindow(); InitAudio(); + InitGfxDebugger(); } void Context::InitLogging() { @@ -237,6 +239,14 @@ void Context::InitAudio() { GetAudio()->Init(); } +void Context::InitGfxDebugger() { + if (GetGfxDebugger() != nullptr) { + return; + } + + mGfxDebugger = std::make_shared(); +} + void Context::InitConsole() { if (GetConsole() != nullptr) { return; @@ -291,6 +301,10 @@ std::shared_ptr