From a196f0af476180ec2283bc7b7d07fdb79550c435 Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Sat, 22 Jul 2006 23:35:48 +0000 Subject: [PATCH] Clean up the texture loader, and removing software renderer code paths. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@496 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/data.c | 74 +----------------- src/texture.c | 202 ++++++++------------------------------------------ 2 files changed, 33 insertions(+), 243 deletions(-) diff --git a/src/data.c b/src/data.c index cd6be7174..e15a26c51 100644 --- a/src/data.c +++ b/src/data.c @@ -802,78 +802,6 @@ void dataIMGPAGERelease(void *pData) dataISpriteRelease(psSprite); } -// Tertiles loader. This version for software renderer. -BOOL dataTERTILESLoad(UBYTE *pBuffer, UDWORD size, void **ppData) -{ - if(pie_Hardware()) { - *ppData = NULL; - return TRUE; - } - - // tile loader. - if (bTilesPCXLoaded) - { - debug( LOG_TEXTURE, "Reloading terrain tiles\n" ); - if(!pie_PNGLoadMem((SBYTE *)pBuffer,&tilesPCX,NULL)) - { - debug( LOG_ERROR, "TERTILES reload failed" ); - return FALSE; - } - } - else - { - debug( LOG_TEXTURE, "Loading terrain tiles\n" ); - if(!pie_PNGLoadMem((SBYTE *)pBuffer,&tilesPCX,NULL)) - { - debug( LOG_ERROR, "TERTILES load failed" ); - return FALSE; - } - } - - /* Squirt the tiles into a nice long thin bitmap */ - if (bTilesPCXLoaded) - { - if(!remakeTileTextures()) - { - debug( LOG_ERROR, "Problem converting the terrain graphics file" ); - return(FALSE); - } - } - else - { - if(!makeTileTextures()) - { - debug( LOG_ERROR, "Problem converting the terrain graphics file" ); - return(FALSE); - } - } - - if (bTilesPCXLoaded) - { - *ppData = NULL; - } - else - { - bTilesPCXLoaded = TRUE; - *ppData = &tilesPCX; - } - debug( LOG_TEXTURE, "Tiles loaded\n" ); - return TRUE; -} - -void dataTERTILESRelease(void *pData) -{ - iSprite *psSprite = (iSprite*) pData; - - freeTileTextures(); - if( psSprite->bmp ) - { - free(psSprite->bmp); - psSprite->bmp = NULL; - } - bTilesPCXLoaded = FALSE; -} - // Tertiles loader. This version for hardware renderer. BOOL dataHWTERTILESLoad(UBYTE *pBuffer, UDWORD size, void **ppData) { @@ -1406,7 +1334,7 @@ static RES_TYPE_MIN ResourceTypes[]= {"SCRIPTVAL", dataScriptLoadVals, NULL}, {"STR_RES", dataStrResLoad, dataStrResRelease}, {"IMGPAGE", dataIMGPAGELoad, dataIMGPAGERelease}, - {"TERTILES", dataTERTILESLoad, dataTERTILESRelease}, // freed by 3d shutdow},// Tertiles Files. This version used when running with software renderer. + {"TERTILES", NULL, NULL}, // This version was used when running with the software renderer. {"HWTERTILES", dataHWTERTILESLoad, dataHWTERTILESRelease}, // freed by 3d shutdow},// Tertiles Files. This version used when running with hardware renderer. {"AUDIOCFG", dataAudioCfgLoad, NULL}, {"WAV", dataAudioLoad, dataAudioRelease}, diff --git a/src/texture.c b/src/texture.c index 254e74b3f..3a1b7aca8 100644 --- a/src/texture.c +++ b/src/texture.c @@ -1,18 +1,14 @@ - -/* Texture stuff. Calls 3dfxText functions in the 3dfx cases */ -/* Alex McLean, Pumpkin Studios, EIDOS Interactive, 1997 */ +/* Texture stuff. Alex McLean, Pumpkin Studios, EIDOS Interactive, 1997 */ #include "lib/framework/frame.h" #include "lib/ivis_common/pietypes.h" #include "lib/ivis_common/piestate.h" -// FIXME Direct iVis implementation include! -#include "lib/ivis_opengl/pietexture.h" +#include "lib/ivis_common/tex.h" #include "lib/ivis_common/piepalette.h" +#include "lib/ivis_opengl/pietexture.h" #include "display3ddef.h" #include "texture.h" #include "radar.h" -#include "lib/ivis_common/tex.h" - /* Can fit at most 32 texture pages into a 2meg texture memory */ #define MAX_TEXTURE_PAGES 32 @@ -31,9 +27,8 @@ iSprite tilesPCX; /* Stores the raw PCX data for the terrain tiles at load file time */ iBitmap **tilesRAW; /* How many tiles have we loaded */ -//UDWORD numTiles; UDWORD numPCXTiles; -/* How many pages have we loaded (hardware)*/ +/* How many pages have we loaded */ SDWORD firstTexturePage; SDWORD numTexturePages; int pageId[MAX_TERRAIN_PAGES]; @@ -41,139 +36,19 @@ int pageId[MAX_TERRAIN_PAGES]; /* Presently all texture pages are 256*256 big */ typedef struct _texturePage { -UDWORD pageNumber; -UDWORD cardAddress; + UDWORD pageNumber; + UDWORD cardAddress; } TEXTURE_PAGE_3DFX; TILE_TEX_INFO tileTexInfo[MAX_TILES]; -static void getRectFromPage(UDWORD width, UDWORD height, unsigned char *src, UDWORD bufWidth, unsigned char *dest); -static void putRectIntoPage(UDWORD width, UDWORD height, unsigned char *dest, UDWORD bufWidth, unsigned char *src); static UDWORD getTileXIndex(UDWORD tileNumber); static UDWORD getTileYIndex(UDWORD tileNumber); static void getRectFromPage(UDWORD width, UDWORD height, unsigned char *src, UDWORD bufWidth, unsigned char *dest); static void putRectIntoPage(UDWORD width, UDWORD height, unsigned char *dest, UDWORD bufWidth, unsigned char *src); static void buildTileIndexes(void); -/* Extracts the tile texture in pcx format of abc.. - def.. - ghi.. (say) - and puts them into raw format of - a - b - c - d - e - f - . - . - - currently only used for software renderer -*/ -int makeTileTextures(void) -{ - UDWORD x, y, i, j, w, h, t; - iBitmap *b, *s, *saved; - - - w = tilesPCX.width / TILE_WIDTH; - h = tilesPCX.height / TILE_HEIGHT; - numPCXTiles = w * h; - - debug(LOG_TEXTURE, "makeTileTextures: tile(%d,%d) num=%d", w, h, numPCXTiles); - - tilesRAW = (iBitmap **) MALLOC(sizeof(iBitmap *) * numPCXTiles); - - for (i=0; i= w * h,"remakeTileTextures: New Tertiles larger than existing version")); - - debug(LOG_TEXTURE, "remakeTileTextures: tile(%d,%d) num=%d", w, h, numPCXTiles); - - //tilesRAW is already set up - t = 0; - if (tilesRAW) - { - for (i=0; i