diff options
| author | SND\dario86_cp <SND\dario86_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-03-12 18:54:28 +0000 |
|---|---|---|
| committer | SND\dario86_cp <SND\dario86_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-03-12 18:54:28 +0000 |
| commit | a58cfdac407bc1d8fedc11acd924b275ba28cc51 (patch) | |
| tree | b4c2e08c34ef1bfe0ba947ef8eed931c9a43fc0e /plugins/peopsxgl/texture.c | |
| parent | 9bdd06684bcc627c06ddcf4c406f6b48f0dfe389 (diff) | |
| download | pcsxr-a58cfdac407bc1d8fedc11acd924b275ba28cc51.tar.gz | |
Commited patch in issue #8171 (by darktjm).
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@64524 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins/peopsxgl/texture.c')
| -rw-r--r-- | plugins/peopsxgl/texture.c | 1366 |
1 files changed, 687 insertions, 679 deletions
diff --git a/plugins/peopsxgl/texture.c b/plugins/peopsxgl/texture.c index c287768f..f247175a 100644 --- a/plugins/peopsxgl/texture.c +++ b/plugins/peopsxgl/texture.c @@ -1,62 +1,62 @@ -/***************************************************************************
- texture.c - description
- -------------------
- begin : Sun Mar 08 2009
- copyright : (C) 1999-2009 by Pete Bernert
- web : www.pbernert.com
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
+/*************************************************************************** + texture.c - description + ------------------- + begin : Sun Mar 08 2009 + copyright : (C) 1999-2009 by Pete Bernert + web : www.pbernert.com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. See also the license.txt file for * + * additional informations. * + * * + ***************************************************************************/ + #include "stdafx.h" //////////////////////////////////////////////////////////////////////////////////// // Texture related functions are here ! -//
-// The texture handling is heart and soul of this gpu. The plugin was developed
-// 1999, by this time no shaders were available. Since the psx gpu is making
-// heavy use of CLUT (="color lookup tables", aka palettized textures), it was
-// an interesting task to get those emulated at good speed on NV TNT cards
-// (which was my major goal when I created the first "gpuPeteTNT"). Later cards
-// (Geforce256) supported texture palettes by an OGL extension, but at some point
-// this support was dropped again by gfx card vendors.
-// Well, at least there is a certain advatage, if no texture palettes extension can
-// be used: it is possible to modify the textures in any way, allowing "hi-res"
-// textures and other tweaks.
-//
-// My main texture caching is kinda complex: the plugin is allocating "n" 256x256 textures,
-// and it places small psx texture parts inside them. The plugin keeps track what
-// part (with what palette) it had placed in which texture, so it can re-use this
-// part again. The more ogl textures it can use, the better (of course the managing/
-// searching will be slower, but everything is faster than uploading textures again
-// and again to a gfx card). My first card (TNT1) had 16 MB Vram, and it worked
-// well with many games, but I recommend nowadays 64 MB Vram to get a good speed.
-//
-// Sadly, there is also a second kind of texture cache needed, for "psx texture windows".
-// Those are "repeated" textures, so a psx "texture window" needs to be put in
-// a whole texture to use the GL_TEXTURE_WRAP_ features. This cache can get full very
-// fast in games which are having an heavy "texture window" usage, like RRT4. As an
-// alternative, this plugin can use the OGL "palette" extension on texture windows,
-// if available. Nowadays also a fragment shader can easily be used to emulate
-// texture wrapping in a texture atlas, so the main cache could hold the texture
-// windows as well (that's what I am doing in the OGL2 plugin). But currently the
-// OGL1 plugin is a "shader-free" zone, so heavy "texture window" games will cause
-// much texture uploads.
-//
-// Some final advice: take care if you change things in here. I've removed my ASM
-// handlers (they didn't cause much speed gain anyway) for readability/portability,
-// but still the functions/data structures used here are easy to mess up. I guess it
-// can be a pain in the ass to port the plugin to another byte order :)
-//
-////////////////////////////////////////////////////////////////////////////////////
+// +// The texture handling is heart and soul of this gpu. The plugin was developed +// 1999, by this time no shaders were available. Since the psx gpu is making +// heavy use of CLUT (="color lookup tables", aka palettized textures), it was +// an interesting task to get those emulated at good speed on NV TNT cards +// (which was my major goal when I created the first "gpuPeteTNT"). Later cards +// (Geforce256) supported texture palettes by an OGL extension, but at some point +// this support was dropped again by gfx card vendors. +// Well, at least there is a certain advatage, if no texture palettes extension can +// be used: it is possible to modify the textures in any way, allowing "hi-res" +// textures and other tweaks. +// +// My main texture caching is kinda complex: the plugin is allocating "n" 256x256 textures, +// and it places small psx texture parts inside them. The plugin keeps track what +// part (with what palette) it had placed in which texture, so it can re-use this +// part again. The more ogl textures it can use, the better (of course the managing/ +// searching will be slower, but everything is faster than uploading textures again +// and again to a gfx card). My first card (TNT1) had 16 MB Vram, and it worked +// well with many games, but I recommend nowadays 64 MB Vram to get a good speed. +// +// Sadly, there is also a second kind of texture cache needed, for "psx texture windows". +// Those are "repeated" textures, so a psx "texture window" needs to be put in +// a whole texture to use the GL_TEXTURE_WRAP_ features. This cache can get full very +// fast in games which are having an heavy "texture window" usage, like RRT4. As an +// alternative, this plugin can use the OGL "palette" extension on texture windows, +// if available. Nowadays also a fragment shader can easily be used to emulate +// texture wrapping in a texture atlas, so the main cache could hold the texture +// windows as well (that's what I am doing in the OGL2 plugin). But currently the +// OGL1 plugin is a "shader-free" zone, so heavy "texture window" games will cause +// much texture uploads. +// +// Some final advice: take care if you change things in here. I've removed my ASM +// handlers (they didn't cause much speed gain anyway) for readability/portability, +// but still the functions/data structures used here are easy to mess up. I guess it +// can be a pain in the ass to port the plugin to another byte order :) +// +//////////////////////////////////////////////////////////////////////////////////// #define _IN_TEXTURE @@ -80,9 +80,9 @@ GLuint gTexFrameName=0; int iTexGarbageCollection=1; uint32_t dwTexPageComp=0; int iVRamSize=0; -int iClampType=GL_CLAMP;
+int iClampType=GL_CLAMP; -void (*LoadSubTexFn) (int,int,short,short);
+void (*LoadSubTexFn) (int,int,short,short); uint32_t (*PalTexturedColourFn) (uint32_t); //////////////////////////////////////////////////////////////////////// @@ -111,7 +111,7 @@ uint32_t (*PalTexturedColourFn) (uint32_t); #define SOFFD 3072 #define MAXWNDTEXCACHE 128 -
+ #define XCHECK(pos1,pos2) ((pos1.c[0]>=pos2.c[1])&&(pos1.c[1]<=pos2.c[0])&&(pos1.c[2]>=pos2.c[3])&&(pos1.c[3]<=pos2.c[2])) #define INCHECK(pos2,pos1) ((pos1.c[0]<=pos2.c[0]) && (pos1.c[1]>=pos2.c[1]) && (pos1.c[2]<=pos2.c[2]) && (pos1.c[3]>=pos2.c[3])) @@ -145,13 +145,13 @@ unsigned short (*PTCF[2]) (unsigned short); //////////////////////////////////////////////////////////////////////// // texture cache implementation -////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS
-#pragma pack(1)
-#endif
-
-// "texture window" cache entry
+#ifdef _WINDOWS +#pragma pack(1) +#endif + +// "texture window" cache entry typedef struct textureWndCacheEntryTag { @@ -163,8 +163,8 @@ typedef struct textureWndCacheEntryTag EXLong pos; GLuint texname; } textureWndCacheEntry; -
-// "standard texture" cache entry (12 byte per entry, as small as possible... we need lots of them)
+ +// "standard texture" cache entry (12 byte per entry, as small as possible... we need lots of them) typedef struct textureSubCacheEntryTagS { @@ -175,18 +175,18 @@ typedef struct textureSubCacheEntryTagS unsigned char cTexID; unsigned char Opaque; } textureSubCacheEntryS; -
-#ifdef _WINDOWS
-#pragma pack()
-#endif
- -//---------------------------------------------
-
-#define MAXTPAGES_MAX 64
-#define MAXSORTTEX_MAX 196
-
-//---------------------------------------------
-
+ +#ifdef _WINDOWS +#pragma pack() +#endif + +//--------------------------------------------- + +#define MAXTPAGES_MAX 64 +#define MAXSORTTEX_MAX 196 + +//--------------------------------------------- + textureWndCacheEntry wcWndtexStore[MAXWNDTEXCACHE]; textureSubCacheEntryS * pscSubtexStore[3][MAXTPAGES_MAX]; EXLong * pxSsubtexLeft [MAXSORTTEX_MAX]; @@ -202,14 +202,14 @@ GLubyte * texturepart = NULL; GLubyte * texturebuffer = NULL; uint32_t g_x1,g_y1,g_x2,g_y2; unsigned char ubOpaqueDraw = 0; -
-unsigned short MAXTPAGES = 32;
-unsigned short CLUTMASK = 0x7fff;
-unsigned short CLUTYMASK = 0x1ff;
-unsigned short MAXSORTTEX = 196;
-
+ +unsigned short MAXTPAGES = 32; +unsigned short CLUTMASK = 0x7fff; +unsigned short CLUTYMASK = 0x1ff; +unsigned short MAXSORTTEX = 196; + //////////////////////////////////////////////////////////////////////// -// Texture color conversions... all my ASM funcs are removed for easier
+// Texture color conversions... all my ASM funcs are removed for easier // porting... and honestly: nowadays the speed gain would be pointless //////////////////////////////////////////////////////////////////////// @@ -526,7 +526,7 @@ void CheckTextureMemory(void) glBindTexture(GL_TEXTURE_2D,0); free(p); -
+ bDetail=malloc(MAXSORTTEX*sizeof(GLboolean)); memset(bDetail,0,MAXSORTTEX*sizeof(GLboolean)); b=glAreTexturesResident(MAXSORTTEX,uiStexturePage,bDetail); @@ -537,9 +537,9 @@ void CheckTextureMemory(void) { if(bDetail[i]) iCnt++; uiStexturePage[i]=0; - }
-
- free(bDetail);
+ } + + free(bDetail); if(b) iSortTexCnt=MAXSORTTEX-min(1,iHiResTextures); else iSortTexCnt=iCnt-3+min(1,iHiResTextures); // place for menu&texwnd @@ -552,24 +552,24 @@ void CheckTextureMemory(void) //////////////////////////////////////////////////////////////////////// void InitializeTextureStore() -{
- int i,j;
-
- if(iGPUHeight==1024)
- {
- MAXTPAGES = 64;
- CLUTMASK = 0xffff;
- CLUTYMASK = 0x3ff;
- MAXSORTTEX = 128;
- iTexGarbageCollection=0;
- }
- else
- {
- MAXTPAGES = 32;
- CLUTMASK = 0x7fff;
- CLUTYMASK = 0x1ff;
- MAXSORTTEX = 196;
- }
+{ + int i,j; + + if(iGPUHeight==1024) + { + MAXTPAGES = 64; + CLUTMASK = 0xffff; + CLUTYMASK = 0x3ff; + MAXSORTTEX = 128; + iTexGarbageCollection=0; + } + else + { + MAXTPAGES = 32; + CLUTMASK = 0x7fff; + CLUTYMASK = 0x1ff; + MAXSORTTEX = 196; + } memset(vertex,0,4*sizeof(OGLVertex)); // init vertices @@ -707,7 +707,7 @@ void ResetTextureArea(BOOL bDelTex) // Invalidate tex windows //////////////////////////////////////////////////////////////////////// -void InvalidateWndTextureArea(int X, int Y, int W, int H) +static void InvalidateWndTextureArea(int X, int Y, int W, int H) { int i,px1,px2,py1,py2,iYM=1; textureWndCacheEntry * tsw=wcWndtexStore; @@ -715,15 +715,15 @@ void InvalidateWndTextureArea(int X, int Y, int W, int H) W+=X-1; H+=Y-1; if(X<0) X=0;if(X>1023) X=1023; - if(W<0) W=0;if(W>1023) W=1023;
- if(Y<0) Y=0;if(Y>iGPUHeightMask) Y=iGPUHeightMask;
- if(H<0) H=0;if(H>iGPUHeightMask) H=iGPUHeightMask;
+ if(W<0) W=0;if(W>1023) W=1023; + if(Y<0) Y=0;if(Y>iGPUHeightMask) Y=iGPUHeightMask; + if(H<0) H=0;if(H>iGPUHeightMask) H=iGPUHeightMask; W++;H++; -
- if(iGPUHeight==1024) iYM=3;
-
- py1=min(iYM,Y>>8);
- py2=min(iYM,H>>8); // y: 0 or 1
+ + if(iGPUHeight==1024) iYM=3; + + py1=min(iYM,Y>>8); + py2=min(iYM,H>>8); // y: 0 or 1 px1=max(0,(X>>6)); px2=min(15,(W>>6)); @@ -769,7 +769,7 @@ void InvalidateWndTextureArea(int X, int Y, int W, int H) // same for sort textures //////////////////////////////////////////////////////////////////////// -void MarkFree(textureSubCacheEntryS * tsx) +static void MarkFree(textureSubCacheEntryS * tsx) { EXLong * ul, * uls; int j,iMax;unsigned char x1,y1,dx,dy; @@ -798,7 +798,7 @@ void MarkFree(textureSubCacheEntryS * tsx) } } -void InvalidateSubSTextureArea(int X, int Y, int W, int H) +static void InvalidateSubSTextureArea(int X, int Y, int W, int H) { int i,j,k,iMax,px,py,px1,px2,py1,py2,iYM = 1; EXLong npos; @@ -808,16 +808,16 @@ void InvalidateSubSTextureArea(int X, int Y, int W, int H) W+=X-1; H+=Y-1; if(X<0) X=0;if(X>1023) X=1023; - if(W<0) W=0;if(W>1023) W=1023;
- if(Y<0) Y=0;if(Y>iGPUHeightMask) Y=iGPUHeightMask;
- if(H<0) H=0;if(H>iGPUHeightMask) H=iGPUHeightMask;
+ if(W<0) W=0;if(W>1023) W=1023; + if(Y<0) Y=0;if(Y>iGPUHeightMask) Y=iGPUHeightMask; + if(H<0) H=0;if(H>iGPUHeightMask) H=iGPUHeightMask; W++;H++; -
- if(iGPUHeight==1024) iYM=3;
- py1=min(iYM,Y>>8);
- py2=min(iYM,H>>8); // y: 0 or 1
- px1=max(0,(X>>6)-3);
+ if(iGPUHeight==1024) iYM=3; + + py1=min(iYM,Y>>8); + py2=min(iYM,H>>8); // y: 0 or 1 + px1=max(0,(X>>6)-3); px2=min(15,(W>>6)+3); // x: 0-15 for(py=py1;py<=py2;py++) @@ -847,10 +847,10 @@ void InvalidateSubSTextureArea(int X, int Y, int W, int H) if(X>x1) x1=X; if(W<x2) x2=W; if(x2<x1) {sw=x1;x1=x2;x2=sw;} -
- if (dwGPUVersion == 2)
- npos.l=0x00ff00ff;
- else
+ + if (dwGPUVersion == 2) + npos.l=0x00ff00ff; + else npos.l=((x1-xa)<<(26-k))|((x2-xa)<<(18-k))|y1|y2; { @@ -917,7 +917,7 @@ void InvalidateTextureArea(int X, int Y, int W, int H) // tex window: define //////////////////////////////////////////////////////////////////////// -void DefineTextureWnd(void) +static void DefineTextureWnd(void) { if (gTexName == 0) glGenTextures(1, &gTexName); @@ -948,7 +948,7 @@ void DefineTextureWnd(void) // tex window: load packed stretch //////////////////////////////////////////////////////////////////////// -void LoadStretchPackedWndTexturePage(int pageid, int mode, short cx, short cy) +static void LoadStretchPackedWndTexturePage(int pageid, int mode, short cx, short cy) { uint32_t start, row, column, j, sxh, sxm, ldx, ldy, ldxo; unsigned int palstart; @@ -975,41 +975,41 @@ void LoadStretchPackedWndTexturePage(int pageid, int mode, short cx, short cy) { //--------------------------------------------------// // 4bit texture load .. - case 0:
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
- for(row=0;row<16;row++)
- *px++=LPTCOL(*wSRCPtr++);
-
- column=g_y2-ldy;
- for(TXV=g_y1;TXV<=column;TXV++)
- {
- ldx=ldxo;
- for(TXU=g_x1;TXU<=g_x2-ldxo;TXU++)
- {
- n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
- n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf );
-
- s=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ));
- *ta++=s;
-
- if(ldx) {*ta++=s;ldx--;}
- }
-
- if(ldy)
- {ldy--;
- for(TXU=g_x1;TXU<=g_x2;TXU++)
- *ta++=*(ta-(g_x2-g_x1));
- }
- }
-
- DefineTextureWnd();
-
- break;
- }
+ case 0: + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + for(row=0;row<16;row++) + *px++=LPTCOL(*wSRCPtr++); + + column=g_y2-ldy; + for(TXV=g_y1;TXV<=column;TXV++) + { + ldx=ldxo; + for(TXU=g_x1;TXU<=g_x2-ldxo;TXU++) + { + n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c ); + n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf ); + + s=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f )); + *ta++=s; + + if(ldx) {*ta++=s;ldx--;} + } + + if(ldy) + {ldy--; + for(TXU=g_x1;TXU<=g_x2;TXU++,ta++) + *ta=*(ta-(g_x2-g_x1)); + } + } + + DefineTextureWnd(); + + break; + } start=((pageid-16*pmult)*128)+256*2048*pmult; @@ -1052,45 +1052,45 @@ void LoadStretchPackedWndTexturePage(int pageid, int mode, short cx, short cy) break; //--------------------------------------------------// // 8bit texture load .. - case 1:
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
- for(row=0;row<256;row++)
- *px++=LPTCOL(*wSRCPtr++);
-
- column=g_y2-ldy;
- for(TXV=g_y1;TXV<=column;TXV++)
- {
- ldx=ldxo;
- for(TXU=g_x1;TXU<=g_x2-ldxo;TXU++)
- {
- n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
- n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
-
- s=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff));
-
- *ta++=s;
- if(ldx) {*ta++=s;ldx--;}
- }
-
- if(ldy)
- {ldy--;
- for(TXU=g_x1;TXU<=g_x2;TXU++)
- *ta++=*(ta-(g_x2-g_x1));
- }
-
- }
-
- DefineTextureWnd();
-
- break;
- }
-
+ case 1: + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + for(row=0;row<256;row++) + *px++=LPTCOL(*wSRCPtr++); + + column=g_y2-ldy; + for(TXV=g_y1;TXV<=column;TXV++) + { + ldx=ldxo; + for(TXU=g_x1;TXU<=g_x2-ldxo;TXU++) + { + n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 ); + n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 ); + + s=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff)); + + *ta++=s; + if(ldx) {*ta++=s;ldx--;} + } + + if(ldy) + {ldy--; + for(TXU=g_x1;TXU<=g_x2;TXU++,ta++) + *ta=*(ta-(g_x2-g_x1)); + } + + } + + DefineTextureWnd(); + + break; + } + start=((pageid-16*pmult)*128)+256*2048*pmult; -
+ // not using a lookup table here... speeds up smaller texture areas cSRCPtr = psxVub + start + (2048*g_y1) + g_x1; LineOffset = 2048 - (g_x2-g_x1+1) +ldxo; @@ -1141,7 +1141,7 @@ void LoadStretchPackedWndTexturePage(int pageid, int mode, short cx, short cy) // tex window: load stretched //////////////////////////////////////////////////////////////////////// -void LoadStretchWndTexturePage(int pageid, int mode, short cx, short cy) +static void LoadStretchWndTexturePage(int pageid, int mode, short cx, short cy) { uint32_t start,row,column,j,sxh,sxm,ldx,ldy,ldxo,s; unsigned int palstart; @@ -1167,53 +1167,53 @@ void LoadStretchWndTexturePage(int pageid, int mode, short cx, short cy) { //--------------------------------------------------// // 4bit texture load .. - case 0:
- //------------------- ZN STUFF
-
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
-
- row=4;do
- {
- *px =LTCOL(*wSRCPtr);
- *(px+1)=LTCOL(*(wSRCPtr+1));
- *(px+2)=LTCOL(*(wSRCPtr+2));
- *(px+3)=LTCOL(*(wSRCPtr+3));
- row--;px+=4;wSRCPtr+=4;
- }
- while (row);
-
- column=g_y2-ldy;
- for(TXV=g_y1;TXV<=column;TXV++)
- {
- ldx=ldxo;
- for(TXU=g_x1;TXU<=g_x2-ldxo;TXU++)
- {
- n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
- n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf );
-
- s=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ));
- *ta++=s;
-
- if(ldx) {*ta++=s;ldx--;}
- }
-
- if(ldy)
- {ldy--;
- for(TXU=g_x1;TXU<=g_x2;TXU++)
- *ta++=*(ta-(g_x2-g_x1));
- }
- }
-
- DefineTextureWnd();
-
- break;
- }
-
- //-------------------
+ case 0: + //------------------- ZN STUFF + + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + + row=4;do + { + *px =LTCOL(*wSRCPtr); + *(px+1)=LTCOL(*(wSRCPtr+1)); + *(px+2)=LTCOL(*(wSRCPtr+2)); + *(px+3)=LTCOL(*(wSRCPtr+3)); + row--;px+=4;wSRCPtr+=4; + } + while (row); + + column=g_y2-ldy; + for(TXV=g_y1;TXV<=column;TXV++) + { + ldx=ldxo; + for(TXU=g_x1;TXU<=g_x2-ldxo;TXU++) + { + n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c ); + n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf ); + + s=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f )); + *ta++=s; + + if(ldx) {*ta++=s;ldx--;} + } + + if(ldy) + {ldy--; + for(TXU=g_x1;TXU<=g_x2;TXU++,ta++) + *ta=*(ta-(g_x2-g_x1)); + } + } + + DefineTextureWnd(); + + break; + } + + //------------------- start=((pageid-16*pmult)*128)+256*2048*pmult; // convert CLUT to 32bits .. and then use THAT as a lookup table @@ -1253,51 +1253,51 @@ void LoadStretchWndTexturePage(int pageid, int mode, short cx, short cy) break; //--------------------------------------------------// // 8bit texture load .. - case 1:
- //------------ ZN STUFF
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
-
- row=64;do
- {
- *px =LTCOL(*wSRCPtr);
- *(px+1)=LTCOL(*(wSRCPtr+1));
- *(px+2)=LTCOL(*(wSRCPtr+2));
- *(px+3)=LTCOL(*(wSRCPtr+3));
- row--;px+=4;wSRCPtr+=4;
- }
- while (row);
-
- column=g_y2-ldy;
- for(TXV=g_y1;TXV<=column;TXV++)
- {
- ldx=ldxo;
- for(TXU=g_x1;TXU<=g_x2-ldxo;TXU++)
- {
- n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
- n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
-
- s=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff));
- *ta++=s;
- if(ldx) {*ta++=s;ldx--;}
- }
-
- if(ldy)
- {ldy--;
- for(TXU=g_x1;TXU<=g_x2;TXU++)
- *ta++=*(ta-(g_x2-g_x1));
- }
-
- }
-
- DefineTextureWnd();
-
- break;
- }
- //------------
+ case 1: + //------------ ZN STUFF + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + + row=64;do + { + *px =LTCOL(*wSRCPtr); + *(px+1)=LTCOL(*(wSRCPtr+1)); + *(px+2)=LTCOL(*(wSRCPtr+2)); + *(px+3)=LTCOL(*(wSRCPtr+3)); + row--;px+=4;wSRCPtr+=4; + } + while (row); + + column=g_y2-ldy; + for(TXV=g_y1;TXV<=column;TXV++) + { + ldx=ldxo; + for(TXU=g_x1;TXU<=g_x2-ldxo;TXU++) + { + n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 ); + n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 ); + + s=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff)); + *ta++=s; + if(ldx) {*ta++=s;ldx--;} + } + + if(ldy) + {ldy--; + for(TXU=g_x1;TXU<=g_x2;TXU++,ta++) + *ta=*(ta-(g_x2-g_x1)); + } + + } + + DefineTextureWnd(); + + break; + } + //------------ start=((pageid-16*pmult)*128)+256*2048*pmult; @@ -1352,7 +1352,7 @@ void LoadStretchWndTexturePage(int pageid, int mode, short cx, short cy) // tex window: load packed simple //////////////////////////////////////////////////////////////////////// -void LoadPackedWndTexturePage(int pageid, int mode, short cx, short cy) +static void LoadPackedWndTexturePage(int pageid, int mode, short cx, short cy) { uint32_t start,row,column,j,sxh,sxm; unsigned int palstart; @@ -1375,30 +1375,30 @@ void LoadPackedWndTexturePage(int pageid, int mode, short cx, short cy) { //--------------------------------------------------// // 4bit texture load .. - case 0:
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
- for(row=0;row<16;row++)
- *px++=LPTCOL(*wSRCPtr++);
-
- for(TXV=g_y1;TXV<=g_y2;TXV++)
- {
- for(TXU=g_x1;TXU<=g_x2;TXU++)
- {
- n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
- n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf );
-
- *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ));
- }
- }
-
- DefineTextureWnd();
-
- break;
- }
+ case 0: + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + for(row=0;row<16;row++) + *px++=LPTCOL(*wSRCPtr++); + + for(TXV=g_y1;TXV<=g_y2;TXV++) + { + for(TXU=g_x1;TXU<=g_x2;TXU++) + { + n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c ); + n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf ); + + *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f )); + } + } + + DefineTextureWnd(); + + break; + } start=((pageid-16*pmult)*128)+256*2048*pmult; @@ -1429,30 +1429,30 @@ void LoadPackedWndTexturePage(int pageid, int mode, short cx, short cy) break; //--------------------------------------------------// // 8bit texture load .. - case 1:
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
- for(row=0;row<256;row++)
- *px++=LPTCOL(*wSRCPtr++);
-
- for(TXV=g_y1;TXV<=g_y2;TXV++)
- {
- for(TXU=g_x1;TXU<=g_x2;TXU++)
- {
- n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
- n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
-
- *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff));
- }
- }
-
- DefineTextureWnd();
-
- break;
- }
+ case 1: + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + for(row=0;row<256;row++) + *px++=LPTCOL(*wSRCPtr++); + + for(TXV=g_y1;TXV<=g_y2;TXV++) + { + for(TXU=g_x1;TXU<=g_x2;TXU++) + { + n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 ); + n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 ); + + *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff)); + } + } + + DefineTextureWnd(); + + break; + } start=((pageid-16*pmult)*128)+256*2048*pmult; @@ -1494,7 +1494,7 @@ void LoadPackedWndTexturePage(int pageid, int mode, short cx, short cy) // tex window: load simple //////////////////////////////////////////////////////////////////////// -void LoadWndTexturePage(int pageid, int mode, short cx, short cy) +static void LoadWndTexturePage(int pageid, int mode, short cx, short cy) { uint32_t start,row,column,j,sxh,sxm; unsigned int palstart; @@ -1517,39 +1517,39 @@ void LoadWndTexturePage(int pageid, int mode, short cx, short cy) { //--------------------------------------------------// // 4bit texture load .. - case 0:
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
-
- row=4;do
- {
- *px =LTCOL(*wSRCPtr);
- *(px+1)=LTCOL(*(wSRCPtr+1));
- *(px+2)=LTCOL(*(wSRCPtr+2));
- *(px+3)=LTCOL(*(wSRCPtr+3));
- row--;px+=4;wSRCPtr+=4;
- }
- while (row);
-
- for(TXV=g_y1;TXV<=g_y2;TXV++)
- {
- for(TXU=g_x1;TXU<=g_x2;TXU++)
- {
- n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
- n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf );
-
- *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ));
- }
- }
-
- DefineTextureWnd();
-
- break;
- }
-
+ case 0: + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + + row=4;do + { + *px =LTCOL(*wSRCPtr); + *(px+1)=LTCOL(*(wSRCPtr+1)); + *(px+2)=LTCOL(*(wSRCPtr+2)); + *(px+3)=LTCOL(*(wSRCPtr+3)); + row--;px+=4;wSRCPtr+=4; + } + while (row); + + for(TXV=g_y1;TXV<=g_y2;TXV++) + { + for(TXU=g_x1;TXU<=g_x2;TXU++) + { + n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c ); + n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf ); + + *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f )); + } + } + + DefineTextureWnd(); + + break; + } + start=((pageid-16*pmult)*128)+256*2048*pmult; // convert CLUT to 32bits .. and then use THAT as a lookup table @@ -1579,39 +1579,39 @@ void LoadWndTexturePage(int pageid, int mode, short cx, short cy) break; //--------------------------------------------------// // 8bit texture load .. - case 1:
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
-
- row=64;do
- {
- *px =LTCOL(*wSRCPtr);
- *(px+1)=LTCOL(*(wSRCPtr+1));
- *(px+2)=LTCOL(*(wSRCPtr+2));
- *(px+3)=LTCOL(*(wSRCPtr+3));
- row--;px+=4;wSRCPtr+=4;
- }
- while (row);
-
- for(TXV=g_y1;TXV<=g_y2;TXV++)
- {
- for(TXU=g_x1;TXU<=g_x2;TXU++)
- {
- n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
- n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
-
- *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff));
- }
- }
-
- DefineTextureWnd();
-
- break;
- }
-
+ case 1: + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + + row=64;do + { + *px =LTCOL(*wSRCPtr); + *(px+1)=LTCOL(*(wSRCPtr+1)); + *(px+2)=LTCOL(*(wSRCPtr+2)); + *(px+3)=LTCOL(*(wSRCPtr+3)); + row--;px+=4;wSRCPtr+=4; + } + while (row); + + for(TXV=g_y1;TXV<=g_y2;TXV++) + { + for(TXU=g_x1;TXU<=g_x2;TXU++) + { + n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 ); + n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 ); + + *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff)); + } + } + + DefineTextureWnd(); + + break; + } + start=((pageid-16*pmult)*128)+256*2048*pmult; // not using a lookup table here... speeds up smaller texture areas @@ -1654,7 +1654,7 @@ void LoadWndTexturePage(int pageid, int mode, short cx, short cy) //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -void UploadTexWndPal(int mode,short cx,short cy) +static void UploadTexWndPal(int mode,short cx,short cy) { unsigned int i,iSize; unsigned short *wSrcPtr; @@ -1681,7 +1681,7 @@ void UploadTexWndPal(int mode,short cx,short cy) //////////////////////////////////////////////////////////////////////// -void DefinePalTextureWnd(void) +static void DefinePalTextureWnd(void) { if(gTexName==0) glGenTextures(1, &gTexName); @@ -1710,12 +1710,12 @@ void DefinePalTextureWnd(void) /////////////////////////////////////////////////////// -void LoadPalWndTexturePage(int pageid, int mode, short cx, short cy) +static void LoadPalWndTexturePage(int pageid, int mode, short cx, short cy) { uint32_t start,row,column,j,sxh,sxm; unsigned char *ta; unsigned char *cSRCPtr; - uint32_t LineOffset;
+ uint32_t LineOffset; int pmult = pageid / 16; ta = (unsigned char *)texturepart; @@ -1724,8 +1724,8 @@ void LoadPalWndTexturePage(int pageid, int mode, short cx, short cy) { //--------------------------------------------------// // 4bit texture load .. - case 0:
- start=((pageid-16*pmult)*128)+256*2048*pmult;
+ case 0: + start=((pageid-16*pmult)*128)+256*2048*pmult; sxm=g_x1&1;sxh=g_x1>>1; if(sxm) j=g_x1+1; else j=g_x1; @@ -1748,7 +1748,7 @@ void LoadPalWndTexturePage(int pageid, int mode, short cx, short cy) break; //--------------------------------------------------// // 8bit texture load .. - case 1:
+ case 1: start=((pageid-16*pmult)*128)+256*2048*pmult; // not using a lookup table here... speeds up smaller texture areas @@ -1770,13 +1770,13 @@ void LoadPalWndTexturePage(int pageid, int mode, short cx, short cy) //////////////////////////////////////////////////////////////////////// -void LoadStretchPalWndTexturePage(int pageid, int mode, short cx, short cy) +static void LoadStretchPalWndTexturePage(int pageid, int mode, short cx, short cy) { uint32_t start,row,column,j,sxh,sxm,ldx,ldy,ldxo; unsigned char *ta,s; unsigned char *cSRCPtr,*cOSRCPtr; uint32_t LineOffset; - int pmult = pageid / 16;
+ int pmult = pageid / 16; ldxo = TWin.Position.x1-TWin.OPosition.x1; ldy = TWin.Position.y1-TWin.OPosition.y1; @@ -1788,7 +1788,7 @@ void LoadStretchPalWndTexturePage(int pageid, int mode, short cx, short cy) //--------------------------------------------------// // 4bit texture load .. case 0: - start=((pageid-16*pmult)*128)+256*2048*pmult;
+ start=((pageid-16*pmult)*128)+256*2048*pmult; sxm=g_x1&1;sxh=g_x1>>1; if(sxm) j=g_x1+1; else j=g_x1; @@ -1821,8 +1821,8 @@ void LoadStretchPalWndTexturePage(int pageid, int mode, short cx, short cy) break; //--------------------------------------------------// // 8bit texture load .. - case 1:
- start=((pageid-16*pmult)*128)+256*2048*pmult;
+ case 1: + start=((pageid-16*pmult)*128)+256*2048*pmult; cSRCPtr = psxVub + start + (2048*g_y1) + g_x1; LineOffset = 2048 - (g_x2-g_x1+1) +ldxo; @@ -1871,7 +1871,7 @@ GLuint LoadTextureWnd(int pageid, int TextureMode, uint32_t GivenClutId) cx = ((GivenClutId << 4) & 0x3F0); cy = ((GivenClutId >> 6) & CLUTYMASK); GivenClutId = (GivenClutId & CLUTMASK) | (DrawSemiTrans << 30); -
+ // palette check sum { uint32_t l = 0,row; @@ -1974,7 +1974,7 @@ GLuint LoadTextureWnd(int pageid, int TextureMode, uint32_t GivenClutId) // movie texture: define //////////////////////////////////////////////////////////////////////// -void DefinePackedTextureMovie(void) +static void DefinePackedTextureMovie(void) { if(gTexMovieName==0) { @@ -2015,7 +2015,7 @@ void DefinePackedTextureMovie(void) //////////////////////////////////////////////////////////////////////// -void DefineTextureMovie(void) +static void DefineTextureMovie(void) { if(gTexMovieName==0) { @@ -2110,7 +2110,7 @@ unsigned char * LoadDirectMovieFast(void) //////////////////////////////////////////////////////////////////////// -GLuint LoadTextureMovieFast(void) +static GLuint LoadTextureMovieFast(void) { int row,column; unsigned int start,startxy; @@ -2130,7 +2130,7 @@ GLuint LoadTextureMovieFast(void) { pD=(unsigned char *)&psxVuw[startxy]; startxy+=1024; -
+ for(row=xrMovieArea.x0;row<sx0;row+=2) { lu1=*((uint32_t *)pD);pD+=3; @@ -2145,7 +2145,7 @@ GLuint LoadTextureMovieFast(void) { lu1=*((uint32_t *)pD); *ta++=XMBLUE(lu1)|XMGREEN(lu1)|XMRED(lu1)|1; - }
+ } } } else @@ -2247,14 +2247,16 @@ GLuint LoadTextureMovie(void) lu=*((uint32_t *)pD);pD+=3; *ta++=XMBLUE(lu)|XMGREEN(lu)|XMRED(lu)|1; } - *ta++=*(ta-1); + *ta=*(ta-1); + ta++; } if(b_Y) { dx=xrMovieArea.x1-xrMovieArea.x0+1; - for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++) - *ta++=*(ta-dx); - *ta++=*(ta-1); + for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++,ta++) + *ta=*(ta-dx); + *ta=*(ta-1); + ta++; } } else @@ -2272,8 +2274,8 @@ GLuint LoadTextureMovie(void) if(b_Y) { dx=xrMovieArea.x1-xrMovieArea.x0; - for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++) - *ta++=*(ta-dx); + for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++,ta++) + *ta=*(ta-dx); } } } @@ -2296,14 +2298,16 @@ GLuint LoadTextureMovie(void) *ta++=((c&0x1f)<<11)|((c&0x3e0)<<1)|((c&0x7c00)>>9)|1; } - *ta++=*(ta-1); + *ta=*(ta-1); + ta++; } if(b_Y) { dx=xrMovieArea.x1-xrMovieArea.x0+1; - for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++) - *ta++=*(ta-dx); - *ta++=*(ta-1); + for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++,ta++) + *ta=*(ta-dx); + *ta=*(ta-1); + ta++; } } else @@ -2320,8 +2324,8 @@ GLuint LoadTextureMovie(void) if(b_Y) { dx=xrMovieArea.x1-xrMovieArea.x0; - for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++) - *ta++=*(ta-dx); + for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++,ta++) + *ta=*(ta-dx); } } } @@ -2347,14 +2351,16 @@ GLuint LoadTextureMovie(void) *ta++=*((uint32_t *)pD)|0xff000000; pD+=3; } - *ta++=*(ta-1); + *ta=*(ta-1); + ta++; } if(b_Y) { dx=xrMovieArea.x1-xrMovieArea.x0+1; - for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++) - *ta++=*(ta-dx); - *ta++=*(ta-1); + for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++,ta++) + *ta=*(ta-dx); + *ta=*(ta-1); + ta++; } } else @@ -2372,8 +2378,8 @@ GLuint LoadTextureMovie(void) if(b_Y) { dx=xrMovieArea.x1-xrMovieArea.x0; - for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++) - *ta++=*(ta-dx); + for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++,ta++) + *ta=*(ta-dx); } } } @@ -2392,17 +2398,19 @@ GLuint LoadTextureMovie(void) for(column=xrMovieArea.y0;column<xrMovieArea.y1;column++) { startxy=((1024)*column)+xrMovieArea.x0; - for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++) - *ta++=LTCOL(psxVuw[startxy++]|0x8000); - *ta++=*(ta-1); + for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++,ta++) + *ta=LTCOL(psxVuw[startxy++]|0x8000); + *ta=*(ta-1); + ta++; } if(b_Y) { dx=xrMovieArea.x1-xrMovieArea.x0+1; - for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++) - *ta++=*(ta-dx); - *ta++=*(ta-1); + for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++,ta++) + *ta=*(ta-dx); + *ta=*(ta-1); + ta++; } } else @@ -2417,8 +2425,8 @@ GLuint LoadTextureMovie(void) if(b_Y) { dx=xrMovieArea.x1-xrMovieArea.x0; - for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++) - *ta++=*(ta-dx); + for(row=xrMovieArea.x0;row<xrMovieArea.x1;row++,ta++) + *ta=*(ta-dx); } } } @@ -2434,7 +2442,7 @@ GLuint LoadTextureMovie(void) ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -GLuint BlackFake15BitTexture(void) +static GLuint BlackFake15BitTexture(void) { int pmult;short x1,x2,y1,y2; @@ -2511,7 +2519,7 @@ BOOL bIgnoreNextTile =FALSE; int iFTex=512; -GLuint Fake15BitTexture(void) +static GLuint Fake15BitTexture(void) { int pmult;short x1,x2,y1,y2;int iYAdjust; float ScaleX,ScaleY;RECT rSrc; @@ -2539,7 +2547,7 @@ GLuint Fake15BitTexture(void) if(bFakeFrontBuffer) bIgnoreNextTile=TRUE; CheckVRamReadEx(x1,y1,x1+x2,y1+y2); return 0; - }
+ } ///////////////////////// @@ -2731,36 +2739,36 @@ void LoadSubTexturePageSort(int pageid, int mode, short cx, short cy) { //--------------------------------------------------// // 4bit texture load .. - case 0:
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
-
- row=4;do
- {
- *px =LTCOL(*wSRCPtr);
- *(px+1)=LTCOL(*(wSRCPtr+1));
- *(px+2)=LTCOL(*(wSRCPtr+2));
- *(px+3)=LTCOL(*(wSRCPtr+3));
- row--;px+=4;wSRCPtr+=4;
- }
- while (row);
-
- for(TXV=y1;TXV<=y2;TXV++)
- {
- for(TXU=x1;TXU<=x2;TXU++)
- {
- n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
- n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf );
-
- *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ));
- }
- ta+=xalign;
- }
- break;
- }
+ case 0: + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + + row=4;do + { + *px =LTCOL(*wSRCPtr); + *(px+1)=LTCOL(*(wSRCPtr+1)); + *(px+2)=LTCOL(*(wSRCPtr+2)); + *(px+3)=LTCOL(*(wSRCPtr+3)); + row--;px+=4;wSRCPtr+=4; + } + while (row); + + for(TXV=y1;TXV<=y2;TXV++) + { + for(TXU=x1;TXU<=x2;TXU++) + { + n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c ); + n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf ); + + *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f )); + } + ta+=xalign; + } + break; + } start=((pageid-16*pmult)<<7)+524288*pmult; // convert CLUT to 32bits .. and then use THAT as a lookup table @@ -2805,37 +2813,37 @@ void LoadSubTexturePageSort(int pageid, int mode, short cx, short cy) break; //--------------------------------------------------// // 8bit texture load .. - case 1:
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
-
- row=64;do
- {
- *px =LTCOL(*wSRCPtr);
- *(px+1)=LTCOL(*(wSRCPtr+1));
- *(px+2)=LTCOL(*(wSRCPtr+2));
- *(px+3)=LTCOL(*(wSRCPtr+3));
- row--;px+=4;wSRCPtr+=4;
- }
- while (row);
-
- for(TXV=y1;TXV<=y2;TXV++)
- {
- for(TXU=x1;TXU<=x2;TXU++)
- {
- n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
- n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
-
- *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff));
- }
- ta+=xalign;
- }
-
- break;
- }
+ case 1: + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + + row=64;do + { + *px =LTCOL(*wSRCPtr); + *(px+1)=LTCOL(*(wSRCPtr+1)); + *(px+2)=LTCOL(*(wSRCPtr+2)); + *(px+3)=LTCOL(*(wSRCPtr+3)); + row--;px+=4;wSRCPtr+=4; + } + while (row); + + for(TXV=y1;TXV<=y2;TXV++) + { + for(TXU=x1;TXU<=x2;TXU++) + { + n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 ); + n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 ); + + *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff)); + } + ta+=xalign; + } + + break; + } start=((pageid-16*pmult)<<7)+524288*pmult; @@ -3057,9 +3065,9 @@ void LoadSubTexturePageSort(int pageid, int mode, short cx, short cy) ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -//
-// load texture part (packed)
-//
+// +// load texture part (packed) +// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// @@ -3099,35 +3107,35 @@ void LoadPackedSubTexturePageSort(int pageid, int mode, short cx, short cy) { //--------------------------------------------------// // 4bit texture load .. - case 0:
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
- row=4;do
- {
- *px =LPTCOL(*wSRCPtr);
- *(px+1)=LPTCOL(*(wSRCPtr+1));
- *(px+2)=LPTCOL(*(wSRCPtr+2));
- *(px+3)=LPTCOL(*(wSRCPtr+3));
- row--;px+=4;wSRCPtr+=4;
- }
- while (row);
-
- for(TXV=y1;TXV<=y2;TXV++)
- {
- for(TXU=x1;TXU<=x2;TXU++)
- {
- n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
- n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf );
-
- *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ));
- }
- ta+=xalign;
- }
- break;
- }
+ case 0: + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + row=4;do + { + *px =LPTCOL(*wSRCPtr); + *(px+1)=LPTCOL(*(wSRCPtr+1)); + *(px+2)=LPTCOL(*(wSRCPtr+2)); + *(px+3)=LPTCOL(*(wSRCPtr+3)); + row--;px+=4;wSRCPtr+=4; + } + while (row); + + for(TXV=y1;TXV<=y2;TXV++) + { + for(TXU=x1;TXU<=x2;TXU++) + { + n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c ); + n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf ); + + *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f )); + } + ta+=xalign; + } + break; + } start=((pageid-16*pmult)<<7)+524288*pmult; @@ -3170,37 +3178,37 @@ void LoadPackedSubTexturePageSort(int pageid, int mode, short cx, short cy) break; //--------------------------------------------------// // 8bit texture load .. - case 1:
- if(GlobalTextIL)
- {
- unsigned int TXV,TXU,n_xi,n_yi;
-
- wSRCPtr=psxVuw+palstart;
-
- row=64;do
- {
- *px =LPTCOL(*wSRCPtr);
- *(px+1)=LPTCOL(*(wSRCPtr+1));
- *(px+2)=LPTCOL(*(wSRCPtr+2));
- *(px+3)=LPTCOL(*(wSRCPtr+3));
- row--;px+=4;wSRCPtr+=4;
- }
- while (row);
-
- for(TXV=y1;TXV<=y2;TXV++)
- {
- for(TXU=x1;TXU<=x2;TXU++)
- {
- n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
- n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
-
- *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff));
- }
- ta+=xalign;
- }
-
- break;
- }
+ case 1: + if(GlobalTextIL) + { + unsigned int TXV,TXU,n_xi,n_yi; + + wSRCPtr=psxVuw+palstart; + + row=64;do + { + *px =LPTCOL(*wSRCPtr); + *(px+1)=LPTCOL(*(wSRCPtr+1)); + *(px+2)=LPTCOL(*(wSRCPtr+2)); + *(px+3)=LPTCOL(*(wSRCPtr+3)); + row--;px+=4;wSRCPtr+=4; + } + while (row); + + for(TXV=y1;TXV<=y2;TXV++) + { + for(TXU=x1;TXU<=x2;TXU++) + { + n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 ); + n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 ); + + *ta++=*(pa+((*( psxVuw + ((GlobalTextAddrY + n_yi)*1024) + GlobalTextAddrX + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff)); + } + ta+=xalign; + } + + break; + } start=((pageid-16*pmult)<<7)+524288*pmult; @@ -3433,17 +3441,17 @@ void LoadPackedSubTexturePageSort(int pageid, int mode, short cx, short cy) } ///////////////////////////////////////////////////////////////////////////// -
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-//
-// hires texture funcs
-//
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
+ +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +// +// hires texture funcs +// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// + #define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D)) @@ -3463,7 +3471,7 @@ void LoadPackedSubTexturePageSort(int pageid, int mode, short cx, short cy) #define Q_INTERPOLATE8(A, B, C, D) (((((A & qcolorMask8) >> 2) + ((B & qcolorMask8) >> 2) + ((C & qcolorMask8) >> 2) + ((D & qcolorMask8) >> 2) + ((((A & qlowpixelMask8) + (B & qlowpixelMask8) + (C & qlowpixelMask8) + (D & qlowpixelMask8)) >> 2) & qlowpixelMask8))|((((A&0xFF000000)==0x50000000)?0x50000000:(((B&0xFF000000)==0x50000000)?0x50000000:(((C&0xFF000000)==0x50000000)?0x50000000:(((D&0xFF000000)==0x50000000)?0x50000000:(((A&0xFF000000)==0x00000000)?0x00000000:(((B&0xFF000000)==0x00000000)?0x00000000:(((C&0xFF000000)==0x00000000)?0x00000000:(((D&0xFF000000)==0x00000000)?0x00000000:0xFF000000))))))))))) -void Super2xSaI_ex8_Ex(unsigned char *srcPtr, DWORD srcPitch, +static void Super2xSaI_ex8_Ex(unsigned char *srcPtr, DWORD srcPitch, unsigned char *dstBitmap, int width, int height) { DWORD dstPitch = srcPitch * 2; @@ -3608,7 +3616,7 @@ void Super2xSaI_ex8_Ex(unsigned char *srcPtr, DWORD srcPitch, } -void Super2xSaI_ex8(unsigned char *srcPtr, DWORD srcPitch, +static void Super2xSaI_ex8(unsigned char *srcPtr, DWORD srcPitch, unsigned char *dstBitmap, int width, int height) { DWORD dstPitch = srcPitch * 2; @@ -3762,7 +3770,7 @@ void Super2xSaI_ex8(unsigned char *srcPtr, DWORD srcPitch, #define Q_INTERPOLATE4(A, B, C, D) ((((A & qcolorMask4) >> 2) + ((B & qcolorMask4) >> 2) + ((C & qcolorMask4) >> 2) + ((D & qcolorMask4) >> 2) + ((((A & qlowpixelMask4) + (B & qlowpixelMask4) + (C & qlowpixelMask4) + (D & qlowpixelMask4)) >> 2) & qlowpixelMask4))| ((((A&0x0000000F)==0x00000006)?0x00000006:(((B&0x0000000F)==0x00000006)?0x00000006:(((C&0x0000000F)==0x00000006)?0x00000006:(((D&0x0000000F)==0x00000006)?0x00000006:(((A&0x0000000F)==0x00000000)?0x00000000:(((B&0x0000000F)==0x00000000)?0x00000000:(((C&0x0000000F)==0x00000000)?0x00000000:(((D&0x0000000F)==0x00000000)?0x00000000:0x0000000F)))))))))) -void Super2xSaI_ex4(unsigned char *srcPtr, DWORD srcPitch, +static void Super2xSaI_ex4(unsigned char *srcPtr, DWORD srcPitch, unsigned char *dstBitmap, int width, int height) { DWORD dstPitch = srcPitch * 2; @@ -3917,7 +3925,7 @@ void Super2xSaI_ex4(unsigned char *srcPtr, DWORD srcPitch, #define Q_INTERPOLATE5(A, B, C, D) ((((A & qcolorMask5) >> 2) + ((B & qcolorMask5) >> 2) + ((C & qcolorMask5) >> 2) + ((D & qcolorMask5) >> 2) + ((((A & qlowpixelMask5) + (B & qlowpixelMask5) + (C & qlowpixelMask5) + (D & qlowpixelMask5)) >> 2) & qlowpixelMask5))| ((((A&0x00000001)==0x00000000)?0x00000000:(((B&0x00000001)==0x00000000)?0x00000000:(((C&0x00000001)==0x00000000)?0x00000000:(((D&0x00000001)==0x00000000)?0x00000000:0x00000001)))))) -void Super2xSaI_ex5(unsigned char *srcPtr, DWORD srcPitch, +static void Super2xSaI_ex5(unsigned char *srcPtr, DWORD srcPitch, unsigned char *dstBitmap, int width, int height) { DWORD dstPitch = srcPitch * 2; @@ -4064,14 +4072,14 @@ void Super2xSaI_ex5(unsigned char *srcPtr, DWORD srcPitch, ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -//
-// ogl texture defines
-//
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
- -void DefineSubTextureSortHiRes(void) +// +// ogl texture defines +// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// + +static void DefineSubTextureSortHiRes(void) { int x,y,dx2; @@ -4201,18 +4209,18 @@ void DefineSubTextureSort(void) } ///////////////////////////////////////////////////////////////////////////// -
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-//
-// texture cache garbage collection
-//
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
- -void DoTexGarbageCollection(void) + +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +// +// texture cache garbage collection +// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// + +static void DoTexGarbageCollection(void) { static unsigned short LRUCleaned=0; unsigned short iC,iC1,iC2; @@ -4248,15 +4256,15 @@ void DoTexGarbageCollection(void) usLRUTexPage=LRUCleaned; } -/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-//
-// search cache for existing (already used) parts
-//
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +// +// search cache for existing (already used) parts +// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// unsigned char * CheckTextureInSubSCache(int TextureMode, uint32_t GivenClutId, unsigned short * pCache) { @@ -4480,7 +4488,7 @@ ENDLOOP: if(ul) { ////////////////////////////////////////////////////// -
+ { dwTexPageComp=0; @@ -4556,17 +4564,17 @@ ENDLOOP: return &tsx->Opaque; } -/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-//
-// search cache for free place (on compress)
-//
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
- -BOOL GetCompressTexturePlace(textureSubCacheEntryS * tsx) +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +// +// search cache for free place (on compress) +// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// + +static BOOL GetCompressTexturePlace(textureSubCacheEntryS * tsx) { int i,j,k,iMax,iC;uint32_t rx,ry,mx,my; EXLong * ul=0, * uls, rfree; @@ -4627,7 +4635,7 @@ BOOL GetCompressTexturePlace(textureSubCacheEntryS * tsx) rfree=*ul; mx=ul->c[2]-2; my=ul->c[0]-2; -
+ if(rx<mx && ry<my) { ul->c[3]+=rx; @@ -4691,17 +4699,17 @@ TENDLOOP: return TRUE; } -/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-//
-// compress texture cache (to make place for new texture part, if needed)
-//
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
- -void CompressTextureSpace(void) +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +// +// compress texture cache (to make place for new texture part, if needed) +// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// + +static void CompressTextureSpace(void) { textureSubCacheEntryS * tsx, * tsg, * tsb; int i,j,k,m,n,iMax;EXLong * ul, r,opos; @@ -4754,14 +4762,14 @@ void CompressTextureSpace(void) tsb->ClutID=0; } } -
+ // if(r.l!=tsx->pos.l) { cx=((tsx->ClutID << 4) & 0x3F0); cy=((tsx->ClutID >> 6) & CLUTYMASK); if(j!=2) - {
+ { // palette check sum l=0;lSRCPtr=(uint32_t *)(psxVuw+cx+(cy*1024)); if(j==1) for(row=1;row<129;row++) l+=((*lSRCPtr++)-1)*row; @@ -4774,9 +4782,9 @@ void CompressTextureSpace(void) } tsx->pos.l=r.l; - if(!GetCompressTexturePlace(tsx)) // no place?
+ if(!GetCompressTexturePlace(tsx)) // no place? { - for(i=0;i<3;i++) // -> clean up everything
+ for(i=0;i<3;i++) // -> clean up everything for(j=0;j<MAXTPAGES;j++) { tsb=pscSubtexStore[i][j]; @@ -4826,21 +4834,21 @@ void CompressTextureSpace(void) DrawSemiTrans=sOldDST; } -/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-//
-// main entry for searching/creating textures, called from prim.c
-//
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +// +// main entry for searching/creating textures, called from prim.c +// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// GLuint SelectSubTextureS(int TextureMode, uint32_t GivenClutId) { unsigned char * OPtr;unsigned short iCache;short cx,cy; -
- // sort sow/tow infos for fast access
+ + // sort sow/tow infos for fast access unsigned char ma1,ma2,mi1,mi2; if(gl_ux[0]>gl_ux[1]) {mi1=gl_ux[1];ma1=gl_ux[0];} @@ -4860,10 +4868,10 @@ GLuint SelectSubTextureS(int TextureMode, uint32_t GivenClutId) else gl_ux[5]=mi1; if(ma1>ma2) gl_ux[4]=ma1; else gl_ux[4]=ma2; -
- // get clut infos in one 32 bit val
- if(TextureMode==2) // no clut here
+ // get clut infos in one 32 bit val + + if(TextureMode==2) // no clut here { GivenClutId=CLUTUSED|(DrawSemiTrans<<30);cx=cy=0; @@ -4875,7 +4883,7 @@ GLuint SelectSubTextureS(int TextureMode, uint32_t GivenClutId) cx=((GivenClutId << 4) & 0x3F0); // but here cy=((GivenClutId >> 6) & CLUTYMASK); GivenClutId=(GivenClutId&CLUTMASK)|(DrawSemiTrans<<30)|CLUTUSED; -
+ // palette check sum.. removed MMX asm, this easy func works as well { uint32_t l=0,row; @@ -4888,22 +4896,22 @@ GLuint SelectSubTextureS(int TextureMode, uint32_t GivenClutId) } } -
+ // search cache iCache=0; - OPtr=CheckTextureInSubSCache(TextureMode,GivenClutId,&iCache);
-
+ OPtr=CheckTextureInSubSCache(TextureMode,GivenClutId,&iCache); + // cache full? compress and try again if(iCache==0xffff) { CompressTextureSpace(); OPtr=CheckTextureInSubSCache(TextureMode,GivenClutId,&iCache); - }
-
+ } + // found? fine usLRUTexPage=iCache; - if(!OPtr) return uiStexturePage[iCache];
-
+ if(!OPtr) return uiStexturePage[iCache]; + // not found? upload texture and store infos in cache gTexName=uiStexturePage[iCache]; LoadSubTexFn(GlobalTexturePage,TextureMode,cx,cy); |
