mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
GLideNHQ: add wildcard support
This commit is contained in:
parent
88e606de95
commit
31b38a7a2b
|
@ -506,7 +506,8 @@ TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *i
|
||||||
|
|
||||||
return 1; /* yep, got it */
|
return 1; /* yep, got it */
|
||||||
}
|
}
|
||||||
if (_txHiResCache->get((r_crc64 & 0xffffffff), info)) {
|
if (_txHiResCache->get((r_crc64 >> 32), info) ||
|
||||||
|
_txHiResCache->get((r_crc64 & 0xffffffff), info)) {
|
||||||
DBG_INFO(80, wst("hires hit: %d x %d gfmt:%x\n"), info->width, info->height, info->format);
|
DBG_INFO(80, wst("hires hit: %d x %d gfmt:%x\n"), info->width, info->height, info->format);
|
||||||
|
|
||||||
/* for true CI textures, we use the passed in palette to convert to
|
/* for true CI textures, we use the passed in palette to convert to
|
||||||
|
|
|
@ -237,6 +237,7 @@ TxHiResCache::LoadResult TxHiResCache::loadHiResTextures(const wchar_t * dir_pat
|
||||||
/* Rice hi-res textures: begin
|
/* Rice hi-res textures: begin
|
||||||
*/
|
*/
|
||||||
uint32 chksum = 0, fmt = 0, siz = 0, palchksum = 0;
|
uint32 chksum = 0, fmt = 0, siz = 0, palchksum = 0;
|
||||||
|
bool hasWildcard = false;
|
||||||
char *pfname = nullptr, fname[MAX_PATH];
|
char *pfname = nullptr, fname[MAX_PATH];
|
||||||
std::string ident;
|
std::string ident;
|
||||||
FILE *fp = nullptr;
|
FILE *fp = nullptr;
|
||||||
|
@ -255,6 +256,7 @@ TxHiResCache::LoadResult TxHiResCache::loadHiResTextures(const wchar_t * dir_pat
|
||||||
|
|
||||||
/* read in Rice's file naming convention */
|
/* read in Rice's file naming convention */
|
||||||
#define CRCFMTSIZ_LEN 13
|
#define CRCFMTSIZ_LEN 13
|
||||||
|
#define CRCWILDCARD_LEN 15
|
||||||
#define PALCRC_LEN 9
|
#define PALCRC_LEN 9
|
||||||
wcstombs(fname, foundfilename, MAX_PATH);
|
wcstombs(fname, foundfilename, MAX_PATH);
|
||||||
/* XXX case sensitivity fiasco!
|
/* XXX case sensitivity fiasco!
|
||||||
|
@ -281,13 +283,33 @@ TxHiResCache::LoadResult TxHiResCache::loadHiResTextures(const wchar_t * dir_pat
|
||||||
pfname = strstr(fname, ident.c_str());
|
pfname = strstr(fname, ident.c_str());
|
||||||
if (pfname != fname) pfname = 0;
|
if (pfname != fname) pfname = 0;
|
||||||
if (pfname) {
|
if (pfname) {
|
||||||
if (sscanf(pfname + ident.size(), "#%08X#%01X#%01X#%08X", &chksum, &fmt, &siz, &palchksum) == 4)
|
uint32_t length = 0;
|
||||||
pfname += (ident.size() + CRCFMTSIZ_LEN + PALCRC_LEN);
|
const char* strName = pfname + ident.size();
|
||||||
else if (sscanf(pfname + ident.size(), "#%08X#%01X#%01X", &chksum, &fmt, &siz) == 3)
|
|
||||||
pfname += (ident.size() + CRCFMTSIZ_LEN);
|
/* wildcard support */
|
||||||
else
|
if (strchr(strName, '$')) {
|
||||||
|
if (sscanf(strName, "#%08X#%01X#%01X#$", &chksum, &fmt, &siz) == 3) {
|
||||||
|
length = CRCWILDCARD_LEN;
|
||||||
|
} else if (sscanf(strName, "#$#%01X#%01X#%08X", &fmt, &siz, &palchksum) == 3) {
|
||||||
|
length = CRCWILDCARD_LEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
hasWildcard = (length != 0);
|
||||||
|
} else {
|
||||||
|
if (sscanf(strName, "#%08X#%01X#%01X#%08X", &chksum, &fmt, &siz, &palchksum) == 4) {
|
||||||
|
length = CRCFMTSIZ_LEN + PALCRC_LEN;
|
||||||
|
} else if (sscanf(strName, "#%08X#%01X#%01X", &chksum, &fmt, &siz) == 3) {
|
||||||
|
length = CRCFMTSIZ_LEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length) {
|
||||||
|
pfname += (ident.size() + length);
|
||||||
|
} else {
|
||||||
pfname = 0;
|
pfname = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pfname) {
|
if (!pfname) {
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
INFO(80, wst("-----\n"));
|
INFO(80, wst("-----\n"));
|
||||||
|
@ -297,7 +319,7 @@ TxHiResCache::LoadResult TxHiResCache::loadHiResTextures(const wchar_t * dir_pat
|
||||||
INFO(80, wst("Error: not Rice texture naming convention!\n"));
|
INFO(80, wst("Error: not Rice texture naming convention!\n"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!chksum) {
|
if (!chksum && !hasWildcard) {
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
INFO(80, wst("-----\n"));
|
INFO(80, wst("-----\n"));
|
||||||
INFO(80, wst("path: %ls\n"), dir_path.string().c_str());
|
INFO(80, wst("path: %ls\n"), dir_path.string().c_str());
|
||||||
|
@ -310,8 +332,10 @@ TxHiResCache::LoadResult TxHiResCache::loadHiResTextures(const wchar_t * dir_pat
|
||||||
/* check if we already have it in hires texture cache */
|
/* check if we already have it in hires texture cache */
|
||||||
if (!replace) {
|
if (!replace) {
|
||||||
uint64 chksum64 = (uint64)palchksum;
|
uint64 chksum64 = (uint64)palchksum;
|
||||||
chksum64 <<= 32;
|
if (chksum) {
|
||||||
chksum64 |= (uint64)chksum;
|
chksum64 <<= 32;
|
||||||
|
chksum64 |= (uint64)chksum;
|
||||||
|
}
|
||||||
if (isCached(chksum64)) {
|
if (isCached(chksum64)) {
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
INFO(80, wst("-----\n"));
|
INFO(80, wst("-----\n"));
|
||||||
|
@ -714,7 +738,7 @@ TxHiResCache::LoadResult TxHiResCache::loadHiResTextures(const wchar_t * dir_pat
|
||||||
|
|
||||||
|
|
||||||
/* last minute validations */
|
/* last minute validations */
|
||||||
if (!tex || !chksum || !width || !height || format == graphics::internalcolorFormat::NOCOLOR || width > _maxwidth || height > _maxheight) {
|
if (!tex || (!chksum && !hasWildcard) || !width || !height || format == graphics::internalcolorFormat::NOCOLOR || width > _maxwidth || height > _maxheight) {
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
INFO(80, wst("-----\n"));
|
INFO(80, wst("-----\n"));
|
||||||
INFO(80, wst("path: %ls\n"), dir_path.string().c_str());
|
INFO(80, wst("path: %ls\n"), dir_path.string().c_str());
|
||||||
|
@ -734,8 +758,10 @@ TxHiResCache::LoadResult TxHiResCache::loadHiResTextures(const wchar_t * dir_pat
|
||||||
/* load it into hires texture cache. */
|
/* load it into hires texture cache. */
|
||||||
{
|
{
|
||||||
uint64 chksum64 = (uint64)palchksum;
|
uint64 chksum64 = (uint64)palchksum;
|
||||||
chksum64 <<= 32;
|
if (chksum) {
|
||||||
chksum64 |= (uint64)chksum;
|
chksum64 <<= 32;
|
||||||
|
chksum64 |= (uint64)chksum;
|
||||||
|
}
|
||||||
|
|
||||||
GHQTexInfo tmpInfo;
|
GHQTexInfo tmpInfo;
|
||||||
tmpInfo.data = tex;
|
tmpInfo.data = tex;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user