[Glide64] Clean up GlideHQ/TxHiResCache.cpp
This commit is contained in:
parent
d8a35cbfba
commit
d6722faee6
|
@ -135,7 +135,6 @@ boolean
|
|||
TxHiResCache::load(boolean replace) /* 0 : reload, 1 : replace partial */
|
||||
{
|
||||
if (!_path.empty() && !_ident.empty()) {
|
||||
|
||||
if (!replace) TxCache::clear();
|
||||
|
||||
CPath dir_path(stdstr().FromUTF16(_path.c_str()).c_str(), "");
|
||||
|
@ -388,9 +387,11 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
#endif
|
||||
if (!tex) {
|
||||
INFO(80, L"Error: missing _rgb.*!\n");
|
||||
} else if (width != tmpwidth || height != tmpheight) {
|
||||
}
|
||||
else if (width != tmpwidth || height != tmpheight) {
|
||||
INFO(80, L"Error: _rgb.* and _a.* have mismatched width or height!\n");
|
||||
} else if (format != GR_TEXFMT_ARGB_8888 || tmpformat != GR_TEXFMT_ARGB_8888) {
|
||||
}
|
||||
else if (format != GR_TEXFMT_ARGB_8888 || tmpformat != GR_TEXFMT_ARGB_8888) {
|
||||
INFO(80, L"Error: _rgb.* or _a.* not in 32bit color!\n");
|
||||
}
|
||||
if (tex) free(tex);
|
||||
|
@ -431,7 +432,8 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
}
|
||||
free(tmptex);
|
||||
tmptex = NULL;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* clobber A comp. never a question of alpha. only RGB used. */
|
||||
#if !DEBUG
|
||||
INFO(80, L"-----\n");
|
||||
|
@ -445,7 +447,8 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
|
||||
/*
|
||||
* read in _all.png, _all.dds, _allciByRGBA.png, _allciByRGBA.dds
|
||||
|
@ -593,7 +596,8 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
((uint32*)tex)[i * width + j] = ((r / numtexel) << 16) |
|
||||
((g / numtexel) << 8) |
|
||||
((b / numtexel));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
((uint32*)tex)[i * width + j] = texel & 0x00ffffff;
|
||||
}
|
||||
}
|
||||
|
@ -610,14 +614,16 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
if ((texel & 0xff000000) < 0x00000003) {
|
||||
alphabits = 1;
|
||||
fullalpha++;
|
||||
} else if ((texel & 0xff000000) < 0xfe000000) {
|
||||
}
|
||||
else if ((texel & 0xff000000) < 0xfe000000) {
|
||||
alphabits = 8;
|
||||
}
|
||||
#else
|
||||
if ((texel & 0xff000000) == 0x00000000) {
|
||||
alphabits = 1;
|
||||
fullalpha++;
|
||||
} else if ((texel & 0xff000000) != 0xff000000) {
|
||||
}
|
||||
else if ((texel & 0xff000000) != 0xff000000) {
|
||||
alphabits = 8;
|
||||
}
|
||||
#endif
|
||||
|
@ -644,7 +650,8 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
else if (alphabits == 1) destformat = GR_TEXFMT_ARGB_1555;
|
||||
else destformat = GR_TEXFMT_ARGB_8888;
|
||||
#if !REDUCE_TEXTURE_FOOTPRINT
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
destformat = GR_TEXFMT_ARGB_8888;
|
||||
}
|
||||
#endif
|
||||
|
@ -663,7 +670,8 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
if (alphabits == 0) {
|
||||
if (fmt == 4) destformat = GR_TEXFMT_ALPHA_8;
|
||||
else destformat = GR_TEXFMT_INTENSITY_8;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
destformat = GR_TEXFMT_ALPHA_INTENSITY_88;
|
||||
}
|
||||
}
|
||||
|
@ -673,10 +681,8 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
/*
|
||||
* Rice hi-res textures: end */
|
||||
|
||||
|
||||
/* XXX: only ARGB8888 for now. comeback to this later... */
|
||||
if (format == GR_TEXFMT_ARGB_8888) {
|
||||
|
||||
#if TEXTURE_TILING
|
||||
|
||||
/* Glide64 style texture tiling */
|
||||
|
@ -708,7 +714,8 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
DBG_INFO(80, L"width > 256, minification ratio:%d %d x %d -> %d x %d\n",
|
||||
ratio, width, height, width / ratio, height / ratio);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* normal minification to fit max texture size */
|
||||
if (width > _maxwidth || height > _maxheight) {
|
||||
DBG_INFO(80, L"determine minification ratio to fit max texture size\n");
|
||||
|
@ -745,7 +752,6 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
|
||||
/* to tile or not to tile, that is the question */
|
||||
if (width > 256 && height <= 128 && (((width - 1) >> 8) + 1) * height <= 256) {
|
||||
|
||||
if (width > _maxwidth) usetile = 1;
|
||||
else {
|
||||
/* tile if the tiled texture memory footprint is smaller */
|
||||
|
@ -772,13 +778,13 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
/* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */
|
||||
if (tmpwidth > tmpheight) {
|
||||
if (tmpwidth > (tmpheight << 3)) tmpheight = tmpwidth >> 3;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (tmpheight > (tmpwidth << 3)) tmpwidth = tmpheight >> 3;
|
||||
}
|
||||
|
||||
usetile = (tilewidth * tileheight < tmpwidth * tmpheight);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* tile it! do the actual tiling into 256x256 size */
|
||||
|
@ -794,7 +800,8 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
for (y = 0; y < height; y++) {
|
||||
if (x < ratio - 1) {
|
||||
memcpy(&tmptex[offset << 2], &tex[(x * 256 + y * width) << 2], 256 << 2);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (z = 0; z < width - 256 * (ratio - 1); z++) {
|
||||
((uint32*)tmptex)[offset + z] = ((uint32*)tex)[x * 256 + y * width + z];
|
||||
}
|
||||
|
@ -928,14 +935,14 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
width = tmpwidth;
|
||||
height = tmpheight;
|
||||
format = destformat = tmpformat;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
free(tmptex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
else {
|
||||
#if POW2_TEXTURES
|
||||
#if (POW2_TEXTURES == 2)
|
||||
/* 3dfx Glide3x aspect ratio (8:1 - 1:8) */
|
||||
|
@ -997,10 +1004,8 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* last minute validations */
|
||||
if (!tex || !chksum || !width || !height || !format || width > _maxwidth || height > _maxheight) {
|
||||
#if !DEBUG
|
||||
|
@ -1012,7 +1017,8 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
free(tex);
|
||||
tex = NULL;
|
||||
INFO(80, L"Error: bad format or size! %d x %d gfmt:%x\n", width, height, format);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
INFO(80, L"Error: load failed!!\n");
|
||||
}
|
||||
continue;
|
||||
|
@ -1063,7 +1069,6 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
|
|||
}
|
||||
free(tex);
|
||||
}
|
||||
|
||||
} while (TextureDir.FindNext());
|
||||
}
|
||||
return 1;
|
||||
|
|
Loading…
Reference in New Issue