From ebf714f7a50630d7d94d601a1ba7a4f22a9bcc1a Mon Sep 17 00:00:00 2001 From: DaMarkov Date: Mon, 14 Feb 2022 02:13:21 +0100 Subject: [PATCH 1/7] Added support for texture packs for OOT. Fixed an endian issue in `RiceCRC32`. Hardcoded in the hyrule day skybox. --- src/GLideNHQ/TxCache.cpp | 162 ++++++++++++++++++++++++++++++++++++++- src/GLideNHQ/TxCache.h | 6 ++ src/GLideNHQ/TxUtil.cpp | 39 ++++++++-- src/RSP.cpp | 2 +- src/native/Native.cpp | 2 + 5 files changed, 202 insertions(+), 9 deletions(-) diff --git a/src/GLideNHQ/TxCache.cpp b/src/GLideNHQ/TxCache.cpp index 892887c2..b2c2abf5 100644 --- a/src/GLideNHQ/TxCache.cpp +++ b/src/GLideNHQ/TxCache.cpp @@ -743,15 +743,175 @@ bool TxFileStorage::add(Checksum checksum, GHQTexInfo *info, int dataSize) return true; } -bool TxFileStorage::get(Checksum checksum, GHQTexInfo *info) +std::unordered_map ChecksumPatch = { + //side 1 + {949418576, 0x5FF7ECEC},//5 ! + {10882665135961641694, 0x2F4EDB9D},//IX ! + {5414539152399578714, 0xB80E023F},//8 !! + {10882665134782356329, 0x4AE635CE},//3 !! + {2515104943, 0x0CCCAA5B},//!! X + {11186014692243632140, 0x35B9F368},//!! 6 + + //side 2 + { 10882665136203779059, 0x9015ED9E },//P22 5 ! + { 5414539149093704324, 0xD6AB076A },//P21 8 ! + { 11186014690300810000, 0x1625825E },//P32 6 ! + { 5414539151466847353, 0x05D90B0B },//P31 2 ! + { 3404850891, 0x080B6D4B },//P41 3 ! + { 1833555532, 0x1A332B7C },//P42 1 ! + + //side 3 + { 943979577, 0x5E4DF38B },//P21 2 ! + { 3533519242, 0xD6ED2362 },//P22 6 ! + { 2234966330, 0xB07C6A7E },//P31 5 ! + { 1503921592, 0xE05C90EE },//P32 7 ! + { 2591730432, 0xF9776A92 },//P41 8 ! + { 2964873944, 0x2E24C44F },//P42 1 ! + + //side 4 + { 5414539151491076179, 0x390CED3F },//P21 5 ! + { 5414539151285576078, 0x7A7C2364 },//P31 3 ! + { 11186014689284962803, 0x1D829500 },//P32 1 ! + {3919890579, 0xBF8DACB3},//P41 7 ! + {10882665136854288861, 0xE48CE0F3},//P42 8 ! + { 1423883039, 0x3B14582D },//P22 2 ! + + //top + {5502028069262581124, 0xC933E141},//P23 12 ! + {5502028070078972781, 0xE1E006F3},//P24 14 ! + {14664577533604172876, 0xC996EF57},//P33 13 ! + {5502028069585931648, 0x26EBC37E},//P43 3 ! + {5502028067428979633, 0xF2B7A163},//PP34 16 ! + {5414539148579585546, 0x021684BB},//P44 7 ! + { 5502028070045778849, 0x8E0981EC },//P32 ! + { 5502028066273592584, 0xEA2D877D },//P22 ! + { 5502028069937715905, 0xA75435AE },//P21 ! + { 5502028070085518301, 0x01562A8F },//P31 ! + { 5502028066402158781, 0xA5659FDF },//P41 ! + { 5502028067270540643, 0x352F61EF },//P42 ! + + + {3414363026, 0},//P33 (maps to multiple?) + {3622161792, 0},//P43 (maps to multiple?) + + + { 10882665136854288861, 0 },//None + {5414539151285576078, 0},//None + {11186014689284962803, 0},//None + + { 5414539150103370152, 0 }, + {10882665138023449373, 0}, + {5414539149301971536, 0}, + {5414539150867657903, 0}, + + {1183159006, 0}, + {4047025754, 0}, + {3873641, 0}, + {3078320140, 0}, + {5414539149879856177, 0}, + {10882665136793763036, 0}, + + {5502028067605713056, 0}, + {5414539152272443539, 0}, + {5502028069311277329, 0}, + + + {5502028067464568065, 0}, + {11186014692698831242, 0}, + {10882665136282404280, 0}, + {10882665137743356632, 0}, + + + {10882665135986160333, 0}, + { 5414539149997265656, 0 }, + { 5414539149296532537, 0 }, + { 5414539150587519290, 0 }, + { 5414539150944283392, 0 }, + { 10882665137380901185, 0 }, + { 10882665136202365727, 0 }, + + { 5414539151193485679, 0},//N + { 10882665136612038220, 0 },// + { 5414539151757403851, 0 },// + { 5502028067833184045, 0 },// + + + { 1260670635, 0 },//N + { 1281040736, 0 },//N + + {1425296371, 0 }, + {227032586, 0 }, + {2533817928, 0 },//Maps to multiple + + {262575180, 0 }, + {1465209777, 0 }, + { 4115202925, 0 }, + { 2075806173, 0 }, + { 3298811268, 0 }, + { 2933023118, 0 }, + { 119650803, 0 }, + { 2604447000, 0 }, +}; + +int active = 1; + +std::vector unaccounted; + +#include + + +bool TxFileStorage::get(Checksum checksum, GHQTexInfo* info) { if (!checksum || _storage.empty()) return false; + //if (checksum != Checksum(214739547)) + //return get(Checksum(214739547), info); + /* find a match in storage */ auto itMap = _storage.find(checksum); if (itMap == _storage.end()) + { + if (active) + { + auto patch = ChecksumPatch.find(checksum); + + if (patch != ChecksumPatch.end()) + { + if (patch->second == 0) + return false; + + bool ret = get(patch->second, info); + if (!ret) + int t = 54; + return ret; + } + + + bool found = false; + for (auto& key : unaccounted) + { + if (key == checksum._checksum) + found = true; + } + if (!found) + { + unaccounted.push_back(checksum._checksum); + FILE* file; + file = fopen("unaccounted.txt", "w"); + + if (file) + { + for (auto& key : unaccounted) + fprintf(file, "%" PRIu64 "\n", key); + + fclose(file); + } + } + } + return false; + } if (_outfile.is_open() || !_infile.is_open()) if (!open(true)) diff --git a/src/GLideNHQ/TxCache.h b/src/GLideNHQ/TxCache.h index af06a954..34d40fd4 100644 --- a/src/GLideNHQ/TxCache.h +++ b/src/GLideNHQ/TxCache.h @@ -50,6 +50,12 @@ struct Checksum operator uint64() { return _checksum; } + bool operator ==(const Checksum& rhs) { + return _checksum == rhs._checksum; + } + bool operator !=(const Checksum& rhs) { + return _checksum != rhs._checksum; + } }; class TxCacheImpl; diff --git a/src/GLideNHQ/TxUtil.cpp b/src/GLideNHQ/TxUtil.cpp index fa6e4fce..bc238f5f 100644 --- a/src/GLideNHQ/TxUtil.cpp +++ b/src/GLideNHQ/TxUtil.cpp @@ -140,6 +140,22 @@ TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, u * (unsigned short)(rdp.tiles[tile].format << 8 | rdp.tiles[tile].size), * bpl); */ + +uint32_t my_byteswap32(uint32_t num) +{ + uint32_t b0, b1, b2, b3; + uint32_t res; + + b0 = (num & 0x000000ff) << 24u; + b1 = (num & 0x0000ff00) << 8u; + b2 = (num & 0x00ff0000) >> 8u; + b3 = (num & 0xff000000) >> 24u; + + res = b0 | b1 | b2 | b3; + return res; +} + + uint32 TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStride) { @@ -193,6 +209,11 @@ loop1: while (x >= 0) { esi = *(uint32*)(src + x); + +#ifdef NATIVE + esi = my_byteswap32(esi); +#endif + esi ^= x; crc32Ret = (crc32Ret << 4) + ((crc32Ret >> 28) & 15); @@ -215,17 +236,21 @@ loop1: static uint8 CalculateMaxCI8b(const uint8* src, uint32 width, uint32 height, uint32 rowStride) { - uint8 val = 0; + uint32_t depth = rowStride / width; + uint8 max = 0; + for (uint32 y = 0; y < height; ++y) { const uint8 * buf = src + rowStride * y; - for (uint32 x = 0; x val) - val = buf[x]; - if (val == 0xFF) + for (uint32 x = 0; x < width; ++x) { + uint8 val = buf[x]; + + if (buf[x] > max) + max = buf[x]; + if (max == 0xFF) return 0xFF; } } - return val; + return max; } static @@ -236,7 +261,7 @@ uint8 CalculateMaxCI4b(const uint8* src, uint32 width, uint32 height, uint32 row width >>= 1; for (uint32 y = 0; y < height; ++y) { const uint8 * buf = src + rowStride * y; - for (uint32 x = 0; x> 4; val2 = buf[x] & 0xF; if (val1 > val) val = val1; diff --git a/src/RSP.cpp b/src/RSP.cpp index c1f2bf34..980b0e18 100644 --- a/src/RSP.cpp +++ b/src/RSP.cpp @@ -54,7 +54,7 @@ void _ProcessDList() #else RSP.words = *(Gwords*)&RDRAM[RSP.PC[RSP.PCi]]; RSP.cmd = _SHIFTR(RSP.words.w0, 24, 8); -#endif +#endif #ifdef DEBUG_DUMP DebugMsg(DEBUG_LOW, "0x%08lX: CMD=0x%02lX W0=0x%08lX W1=0x%08lX\n", RSP.PC[RSP.PCi], _SHIFTR(RSP.words.w0, 24, 8), RSP.words.w0, RSP.words.w1); diff --git a/src/native/Native.cpp b/src/native/Native.cpp index 3ee314dd..fd219650 100644 --- a/src/native/Native.cpp +++ b/src/native/Native.cpp @@ -139,6 +139,8 @@ extern "C" { RDRAMSize = (word)-1; api().RomOpen(romName); + + config.textureFilter.txHiresEnable = 1; } void gfx_force_43(bool enable) { From 6d9ebf6ff34adb3d6f2479dbf6170458619d8cf1 Mon Sep 17 00:00:00 2001 From: DaMarkov Date: Mon, 14 Feb 2022 05:26:00 +0100 Subject: [PATCH 2/7] Some cleanup. Added RELATIVE_PATHS to tell gliden that paths are relative. Added functions to enabled/disable high res on the fly. --- src/GLideNHQ/TxCache.cpp | 6 +++++- src/GLideNHQ/TxUtil.cpp | 24 +++++++----------------- src/native/Native.cpp | 9 +++++++++ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/GLideNHQ/TxCache.cpp b/src/GLideNHQ/TxCache.cpp index b2c2abf5..0ff7953a 100644 --- a/src/GLideNHQ/TxCache.cpp +++ b/src/GLideNHQ/TxCache.cpp @@ -559,8 +559,12 @@ TxFileStorage::TxFileStorage(uint32 options, void TxFileStorage::buildFullPath() { - char cbuf[MAX_PATH * 2]; + char cbuf[MAX_PATH * 2]; +#ifdef RELATIVE_PATHS + tx_wstring filename = _filename; +#else tx_wstring filename = _cachePath + OSAL_DIR_SEPARATOR_STR + _filename; +#endif wcstombs(cbuf, filename.c_str(), MAX_PATH * 2); _fullPath = cbuf; } diff --git a/src/GLideNHQ/TxUtil.cpp b/src/GLideNHQ/TxUtil.cpp index bc238f5f..0f7c3a5c 100644 --- a/src/GLideNHQ/TxUtil.cpp +++ b/src/GLideNHQ/TxUtil.cpp @@ -38,6 +38,11 @@ #include #endif +#define SWAP32(data) \ +( (((data) >> 24) & 0x000000FF) | (((data) >> 8) & 0x0000FF00) | \ + (((data) << 8) & 0x00FF0000) | (((data) << 24) & 0xFF000000) ) + + /* * Utilities ******************************************************************************/ @@ -141,21 +146,6 @@ TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, u * bpl); */ -uint32_t my_byteswap32(uint32_t num) -{ - uint32_t b0, b1, b2, b3; - uint32_t res; - - b0 = (num & 0x000000ff) << 24u; - b1 = (num & 0x0000ff00) << 8u; - b2 = (num & 0x00ff0000) >> 8u; - b3 = (num & 0xff000000) >> 24u; - - res = b0 | b1 | b2 | b3; - return res; -} - - uint32 TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStride) { @@ -209,9 +199,9 @@ loop1: while (x >= 0) { esi = *(uint32*)(src + x); - + #ifdef NATIVE - esi = my_byteswap32(esi); + esi = SWAP32(esi); #endif esi ^= x; diff --git a/src/native/Native.cpp b/src/native/Native.cpp index fd219650..d939c3c9 100644 --- a/src/native/Native.cpp +++ b/src/native/Native.cpp @@ -141,6 +141,15 @@ extern "C" { api().RomOpen(romName); config.textureFilter.txHiresEnable = 1; + wsprintf(config.textureFilter.txCachePath, L"."); + } + + bool gfx_is_highres_enabled() { + return config.textureFilter.txHiresEnable; + } + + void gfx_highres_enable(bool enable) { + config.textureFilter.txHiresEnable = enable; } void gfx_force_43(bool enable) { From 3e9bafb1454080a8163f6057bbf85f101fd7577a Mon Sep 17 00:00:00 2001 From: DaMarkov Date: Mon, 14 Feb 2022 06:07:16 +0100 Subject: [PATCH 3/7] Tiny cleanup. --- src/GLideNHQ/TxCache.cpp | 93 +++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/src/GLideNHQ/TxCache.cpp b/src/GLideNHQ/TxCache.cpp index 0ff7953a..a62d6069 100644 --- a/src/GLideNHQ/TxCache.cpp +++ b/src/GLideNHQ/TxCache.cpp @@ -748,15 +748,18 @@ bool TxFileStorage::add(Checksum checksum, GHQTexInfo *info, int dataSize) } std::unordered_map ChecksumPatch = { - //side 1 + //---------- + //Hyrule Day + //---------- + //side1 {949418576, 0x5FF7ECEC},//5 ! - {10882665135961641694, 0x2F4EDB9D},//IX ! - {5414539152399578714, 0xB80E023F},//8 !! - {10882665134782356329, 0x4AE635CE},//3 !! - {2515104943, 0x0CCCAA5B},//!! X - {11186014692243632140, 0x35B9F368},//!! 6 + {10882665135961641694, 0x2F4EDB9D},//2 ! + {5414539152399578714, 0xB80E023F},//8 ! + {10882665134782356329, 0x4AE635CE},//3 ! + {2515104943, 0x0CCCAA5B},//1 ! + {11186014692243632140, 0x35B9F368},//6 ! - //side 2 + //side2 { 10882665136203779059, 0x9015ED9E },//P22 5 ! { 5414539149093704324, 0xD6AB076A },//P21 8 ! { 11186014690300810000, 0x1625825E },//P32 6 ! @@ -764,29 +767,29 @@ std::unordered_map ChecksumPatch = { { 3404850891, 0x080B6D4B },//P41 3 ! { 1833555532, 0x1A332B7C },//P42 1 ! - //side 3 - { 943979577, 0x5E4DF38B },//P21 2 ! + //side3 + { 943979577, 0x5E4DF38B },//P21 2 ! { 3533519242, 0xD6ED2362 },//P22 6 ! { 2234966330, 0xB07C6A7E },//P31 5 ! { 1503921592, 0xE05C90EE },//P32 7 ! { 2591730432, 0xF9776A92 },//P41 8 ! { 2964873944, 0x2E24C44F },//P42 1 ! - //side 4 - { 5414539151491076179, 0x390CED3F },//P21 5 ! - { 5414539151285576078, 0x7A7C2364 },//P31 3 ! + //side4 + { 5414539151491076179, 0x390CED3F },//P21 5 ! + { 5414539151285576078, 0x7A7C2364 },//P31 3 ! { 11186014689284962803, 0x1D829500 },//P32 1 ! {3919890579, 0xBF8DACB3},//P41 7 ! {10882665136854288861, 0xE48CE0F3},//P42 8 ! { 1423883039, 0x3B14582D },//P22 2 ! //top - {5502028069262581124, 0xC933E141},//P23 12 ! - {5502028070078972781, 0xE1E006F3},//P24 14 ! - {14664577533604172876, 0xC996EF57},//P33 13 ! - {5502028069585931648, 0x26EBC37E},//P43 3 ! - {5502028067428979633, 0xF2B7A163},//PP34 16 ! - {5414539148579585546, 0x021684BB},//P44 7 ! + { 5502028069262581124, 0xC933E141},//P23 12 ! + { 5502028070078972781, 0xE1E006F3},//P24 14 ! + { 14664577533604172876, 0xC996EF57},//P33 13 ! + { 5502028069585931648, 0x26EBC37E},//P43 3 ! + { 5502028067428979633, 0xF2B7A163},//PP34 16 ! + { 5414539148579585546, 0x021684BB},//P44 7 ! { 5502028070045778849, 0x8E0981EC },//P32 ! { 5502028066273592584, 0xEA2D877D },//P22 ! { 5502028069937715905, 0xA75435AE },//P21 ! @@ -795,38 +798,38 @@ std::unordered_map ChecksumPatch = { { 5502028067270540643, 0x352F61EF },//P42 ! - {3414363026, 0},//P33 (maps to multiple?) - {3622161792, 0},//P43 (maps to multiple?) + { 3414363026, 0},//P33 (maps to multiple?) + { 3622161792, 0},//P43 (maps to multiple?) { 10882665136854288861, 0 },//None - {5414539151285576078, 0},//None - {11186014689284962803, 0},//None + { 5414539151285576078, 0},//None + { 11186014689284962803, 0},//None { 5414539150103370152, 0 }, - {10882665138023449373, 0}, - {5414539149301971536, 0}, - {5414539150867657903, 0}, + { 10882665138023449373, 0}, + { 5414539149301971536, 0}, + { 5414539150867657903, 0}, - {1183159006, 0}, - {4047025754, 0}, - {3873641, 0}, - {3078320140, 0}, - {5414539149879856177, 0}, - {10882665136793763036, 0}, + { 1183159006, 0}, + { 4047025754, 0}, + { 3873641, 0}, + { 3078320140, 0}, + { 5414539149879856177, 0}, + { 10882665136793763036, 0}, - {5502028067605713056, 0}, - {5414539152272443539, 0}, - {5502028069311277329, 0}, + { 5502028067605713056, 0}, + { 5414539152272443539, 0}, + { 5502028069311277329, 0}, - {5502028067464568065, 0}, - {11186014692698831242, 0}, - {10882665136282404280, 0}, - {10882665137743356632, 0}, + { 5502028067464568065, 0}, + { 11186014692698831242, 0}, + { 10882665136282404280, 0}, + { 10882665137743356632, 0}, - {10882665135986160333, 0}, + { 10882665135986160333, 0}, { 5414539149997265656, 0 }, { 5414539149296532537, 0 }, { 5414539150587519290, 0 }, @@ -843,12 +846,12 @@ std::unordered_map ChecksumPatch = { { 1260670635, 0 },//N { 1281040736, 0 },//N - {1425296371, 0 }, - {227032586, 0 }, - {2533817928, 0 },//Maps to multiple + { 1425296371, 0 }, + { 227032586, 0 }, + { 2533817928, 0 },//Maps to multiple - {262575180, 0 }, - {1465209777, 0 }, + { 262575180, 0 }, + { 1465209777, 0 }, { 4115202925, 0 }, { 2075806173, 0 }, { 3298811268, 0 }, @@ -887,7 +890,7 @@ bool TxFileStorage::get(Checksum checksum, GHQTexInfo* info) bool ret = get(patch->second, info); if (!ret) - int t = 54; + int t = 54;//Breakpoint return ret; } From 7d6fa0bfe1dde959ab2ae78aa4f24db14d79bcff Mon Sep 17 00:00:00 2001 From: DaMarkov Date: Mon, 14 Feb 2022 12:34:41 +0100 Subject: [PATCH 4/7] Added a function to switch between .htc and .hts files. --- src/native/Native.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/native/Native.cpp b/src/native/Native.cpp index d939c3c9..e46c1ce6 100644 --- a/src/native/Native.cpp +++ b/src/native/Native.cpp @@ -18,6 +18,7 @@ static u64 g_originalWidth = START_WIDTH;//Size set by the end-user static u64 g_width = START_WIDTH;//Current size static u64 g_height = START_HEIGHT; +static bool highres_hts = true; extern "C" { u64 gfx_width() @@ -142,6 +143,12 @@ extern "C" { config.textureFilter.txHiresEnable = 1; wsprintf(config.textureFilter.txCachePath, L"."); + config.textureFilter.txHiresTextureFileStorage = highres_hts ? 1 : 0; + } + + void gfx_switch_to_htc(bool enable) { + highres_hts = !enable; + config.textureFilter.txHiresTextureFileStorage = enable ? 0 : 1; } bool gfx_is_highres_enabled() { From 9c187aa79f48835efc387dc5615fe8970db80d85 Mon Sep 17 00:00:00 2001 From: DaMarkov Date: Fri, 4 Mar 2022 14:23:15 +0100 Subject: [PATCH 5/7] Removed debugging code. --- src/GLideNHQ/TxCache.cpp | 163 --------------------------------------- 1 file changed, 163 deletions(-) diff --git a/src/GLideNHQ/TxCache.cpp b/src/GLideNHQ/TxCache.cpp index a62d6069..4709edd4 100644 --- a/src/GLideNHQ/TxCache.cpp +++ b/src/GLideNHQ/TxCache.cpp @@ -747,178 +747,15 @@ bool TxFileStorage::add(Checksum checksum, GHQTexInfo *info, int dataSize) return true; } -std::unordered_map ChecksumPatch = { - //---------- - //Hyrule Day - //---------- - //side1 - {949418576, 0x5FF7ECEC},//5 ! - {10882665135961641694, 0x2F4EDB9D},//2 ! - {5414539152399578714, 0xB80E023F},//8 ! - {10882665134782356329, 0x4AE635CE},//3 ! - {2515104943, 0x0CCCAA5B},//1 ! - {11186014692243632140, 0x35B9F368},//6 ! - - //side2 - { 10882665136203779059, 0x9015ED9E },//P22 5 ! - { 5414539149093704324, 0xD6AB076A },//P21 8 ! - { 11186014690300810000, 0x1625825E },//P32 6 ! - { 5414539151466847353, 0x05D90B0B },//P31 2 ! - { 3404850891, 0x080B6D4B },//P41 3 ! - { 1833555532, 0x1A332B7C },//P42 1 ! - - //side3 - { 943979577, 0x5E4DF38B },//P21 2 ! - { 3533519242, 0xD6ED2362 },//P22 6 ! - { 2234966330, 0xB07C6A7E },//P31 5 ! - { 1503921592, 0xE05C90EE },//P32 7 ! - { 2591730432, 0xF9776A92 },//P41 8 ! - { 2964873944, 0x2E24C44F },//P42 1 ! - - //side4 - { 5414539151491076179, 0x390CED3F },//P21 5 ! - { 5414539151285576078, 0x7A7C2364 },//P31 3 ! - { 11186014689284962803, 0x1D829500 },//P32 1 ! - {3919890579, 0xBF8DACB3},//P41 7 ! - {10882665136854288861, 0xE48CE0F3},//P42 8 ! - { 1423883039, 0x3B14582D },//P22 2 ! - - //top - { 5502028069262581124, 0xC933E141},//P23 12 ! - { 5502028070078972781, 0xE1E006F3},//P24 14 ! - { 14664577533604172876, 0xC996EF57},//P33 13 ! - { 5502028069585931648, 0x26EBC37E},//P43 3 ! - { 5502028067428979633, 0xF2B7A163},//PP34 16 ! - { 5414539148579585546, 0x021684BB},//P44 7 ! - { 5502028070045778849, 0x8E0981EC },//P32 ! - { 5502028066273592584, 0xEA2D877D },//P22 ! - { 5502028069937715905, 0xA75435AE },//P21 ! - { 5502028070085518301, 0x01562A8F },//P31 ! - { 5502028066402158781, 0xA5659FDF },//P41 ! - { 5502028067270540643, 0x352F61EF },//P42 ! - - - { 3414363026, 0},//P33 (maps to multiple?) - { 3622161792, 0},//P43 (maps to multiple?) - - - { 10882665136854288861, 0 },//None - { 5414539151285576078, 0},//None - { 11186014689284962803, 0},//None - - { 5414539150103370152, 0 }, - { 10882665138023449373, 0}, - { 5414539149301971536, 0}, - { 5414539150867657903, 0}, - - { 1183159006, 0}, - { 4047025754, 0}, - { 3873641, 0}, - { 3078320140, 0}, - { 5414539149879856177, 0}, - { 10882665136793763036, 0}, - - { 5502028067605713056, 0}, - { 5414539152272443539, 0}, - { 5502028069311277329, 0}, - - - { 5502028067464568065, 0}, - { 11186014692698831242, 0}, - { 10882665136282404280, 0}, - { 10882665137743356632, 0}, - - - { 10882665135986160333, 0}, - { 5414539149997265656, 0 }, - { 5414539149296532537, 0 }, - { 5414539150587519290, 0 }, - { 5414539150944283392, 0 }, - { 10882665137380901185, 0 }, - { 10882665136202365727, 0 }, - - { 5414539151193485679, 0},//N - { 10882665136612038220, 0 },// - { 5414539151757403851, 0 },// - { 5502028067833184045, 0 },// - - - { 1260670635, 0 },//N - { 1281040736, 0 },//N - - { 1425296371, 0 }, - { 227032586, 0 }, - { 2533817928, 0 },//Maps to multiple - - { 262575180, 0 }, - { 1465209777, 0 }, - { 4115202925, 0 }, - { 2075806173, 0 }, - { 3298811268, 0 }, - { 2933023118, 0 }, - { 119650803, 0 }, - { 2604447000, 0 }, -}; - -int active = 1; - -std::vector unaccounted; - -#include - - bool TxFileStorage::get(Checksum checksum, GHQTexInfo* info) { if (!checksum || _storage.empty()) return false; - //if (checksum != Checksum(214739547)) - //return get(Checksum(214739547), info); - /* find a match in storage */ auto itMap = _storage.find(checksum); if (itMap == _storage.end()) - { - if (active) - { - auto patch = ChecksumPatch.find(checksum); - - if (patch != ChecksumPatch.end()) - { - if (patch->second == 0) - return false; - - bool ret = get(patch->second, info); - if (!ret) - int t = 54;//Breakpoint - return ret; - } - - - bool found = false; - for (auto& key : unaccounted) - { - if (key == checksum._checksum) - found = true; - } - if (!found) - { - unaccounted.push_back(checksum._checksum); - FILE* file; - file = fopen("unaccounted.txt", "w"); - - if (file) - { - for (auto& key : unaccounted) - fprintf(file, "%" PRIu64 "\n", key); - - fclose(file); - } - } - } - return false; - } if (_outfile.is_open() || !_infile.is_open()) if (!open(true)) From 9c60bf101fee8eaa7b4e1162bd2df4498767f7af Mon Sep 17 00:00:00 2001 From: DaMarkov Date: Fri, 4 Mar 2022 14:31:04 +0100 Subject: [PATCH 6/7] Cleanup --- src/GLideNHQ/TxUtil.cpp | 3 --- src/RSP.cpp | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/GLideNHQ/TxUtil.cpp b/src/GLideNHQ/TxUtil.cpp index 0f7c3a5c..2ce1820a 100644 --- a/src/GLideNHQ/TxUtil.cpp +++ b/src/GLideNHQ/TxUtil.cpp @@ -226,14 +226,11 @@ loop1: static uint8 CalculateMaxCI8b(const uint8* src, uint32 width, uint32 height, uint32 rowStride) { - uint32_t depth = rowStride / width; uint8 max = 0; for (uint32 y = 0; y < height; ++y) { const uint8 * buf = src + rowStride * y; for (uint32 x = 0; x < width; ++x) { - uint8 val = buf[x]; - if (buf[x] > max) max = buf[x]; if (max == 0xFF) diff --git a/src/RSP.cpp b/src/RSP.cpp index 980b0e18..c1f2bf34 100644 --- a/src/RSP.cpp +++ b/src/RSP.cpp @@ -54,7 +54,7 @@ void _ProcessDList() #else RSP.words = *(Gwords*)&RDRAM[RSP.PC[RSP.PCi]]; RSP.cmd = _SHIFTR(RSP.words.w0, 24, 8); -#endif +#endif #ifdef DEBUG_DUMP DebugMsg(DEBUG_LOW, "0x%08lX: CMD=0x%02lX W0=0x%08lX W1=0x%08lX\n", RSP.PC[RSP.PCi], _SHIFTR(RSP.words.w0, 24, 8), RSP.words.w0, RSP.words.w1); From f8d114de20f7a07d427571ea8298aded4bdda0ac Mon Sep 17 00:00:00 2001 From: DaMarkov Date: Fri, 4 Mar 2022 14:32:42 +0100 Subject: [PATCH 7/7] Made HD texture mode not the default anymore. --- src/native/Native.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/native/Native.cpp b/src/native/Native.cpp index e46c1ce6..f3ddbeec 100644 --- a/src/native/Native.cpp +++ b/src/native/Native.cpp @@ -18,6 +18,7 @@ static u64 g_originalWidth = START_WIDTH;//Size set by the end-user static u64 g_width = START_WIDTH;//Current size static u64 g_height = START_HEIGHT; +static int highres_enabled = 0;//1 if HD texture mode is enabled static bool highres_hts = true; extern "C" { @@ -141,7 +142,7 @@ extern "C" { api().RomOpen(romName); - config.textureFilter.txHiresEnable = 1; + config.textureFilter.txHiresEnable = highres_enabled; wsprintf(config.textureFilter.txCachePath, L"."); config.textureFilter.txHiresTextureFileStorage = highres_hts ? 1 : 0; } @@ -152,6 +153,7 @@ extern "C" { } bool gfx_is_highres_enabled() { + highres_enabled = 1; return config.textureFilter.txHiresEnable; }