parent
bdc85ddbb7
commit
8bc33bc4d9
|
@ -41,6 +41,7 @@
|
|||
#include "Gfx_1.3.h"
|
||||
#include "TexCache.h"
|
||||
#include "Combine.h"
|
||||
#include "Util.h"
|
||||
|
||||
void LoadTex (int id, int tmu);
|
||||
|
||||
|
@ -1417,9 +1418,9 @@ void LoadTex (int id, int tmu)
|
|||
if (size == 1)
|
||||
Clamp16bT ((texture)+start_dst, texinfo[id].height, real_x, cache->splitheight);
|
||||
else if (size != 2)
|
||||
Clamp8bT (wxPtrToUInt(texture)+start_dst, texinfo[id].height, real_x, cache->splitheight);
|
||||
Clamp8bT ((texture)+start_dst, texinfo[id].height, real_x, cache->splitheight);
|
||||
else
|
||||
Clamp32bT (wxPtrToUInt(texture)+start_dst, texinfo[id].height, real_x, cache->splitheight);
|
||||
Clamp32bT ((texture)+start_dst, texinfo[id].height, real_x, cache->splitheight);
|
||||
}
|
||||
}
|
||||
// ** end texture splitting **
|
||||
|
@ -1447,9 +1448,9 @@ void LoadTex (int id, int tmu)
|
|||
if (size == 1)
|
||||
Clamp16bS ((texture), texinfo[id].width, min_x, real_x, texinfo[id].height);
|
||||
else if (size != 2)
|
||||
Clamp8bS (wxPtrToUInt(texture), texinfo[id].width, min_x, real_x, texinfo[id].height);
|
||||
Clamp8bS ((texture), texinfo[id].width, min_x, real_x, texinfo[id].height);
|
||||
else
|
||||
Clamp32bS (wxPtrToUInt(texture), texinfo[id].width, min_x, real_x, texinfo[id].height);
|
||||
Clamp32bS ((texture), texinfo[id].width, min_x, real_x, texinfo[id].height);
|
||||
}
|
||||
|
||||
if (texinfo[id].width < (int)real_x)
|
||||
|
@ -1460,10 +1461,10 @@ void LoadTex (int id, int tmu)
|
|||
Mirror16bS ((texture), rdp.tiles[td].mask_s,
|
||||
real_x, real_x, texinfo[id].height);
|
||||
else if (size != 2)
|
||||
Mirror8bS (wxPtrToUInt(texture), rdp.tiles[td].mask_s,
|
||||
Mirror8bS ((texture), rdp.tiles[td].mask_s,
|
||||
real_x, real_x, texinfo[id].height);
|
||||
else
|
||||
Mirror32bS (wxPtrToUInt(texture), rdp.tiles[td].mask_s,
|
||||
Mirror32bS ((texture), rdp.tiles[td].mask_s,
|
||||
real_x, real_x, texinfo[id].height);
|
||||
}
|
||||
else
|
||||
|
@ -1472,10 +1473,10 @@ void LoadTex (int id, int tmu)
|
|||
Wrap16bS ((texture), rdp.tiles[td].mask_s,
|
||||
real_x, real_x, texinfo[id].height);
|
||||
else if (size != 2)
|
||||
Wrap8bS (wxPtrToUInt(texture), rdp.tiles[td].mask_s,
|
||||
Wrap8bS ((texture), rdp.tiles[td].mask_s,
|
||||
real_x, real_x, texinfo[id].height);
|
||||
else
|
||||
Wrap32bS (wxPtrToUInt(texture), rdp.tiles[td].mask_s,
|
||||
Wrap32bS ((texture), rdp.tiles[td].mask_s,
|
||||
real_x, real_x, texinfo[id].height);
|
||||
}
|
||||
}
|
||||
|
@ -1485,9 +1486,9 @@ void LoadTex (int id, int tmu)
|
|||
if (size == 1)
|
||||
Clamp16bT ((texture), texinfo[id].height, real_x, min_y);
|
||||
else if (size != 2)
|
||||
Clamp8bT (wxPtrToUInt(texture), texinfo[id].height, real_x, min_y);
|
||||
Clamp8bT ((texture), texinfo[id].height, real_x, min_y);
|
||||
else
|
||||
Clamp32bT (wxPtrToUInt(texture), texinfo[id].height, real_x, min_y);
|
||||
Clamp32bT ((texture), texinfo[id].height, real_x, min_y);
|
||||
}
|
||||
|
||||
if (texinfo[id].height < (int)real_y)
|
||||
|
@ -1498,10 +1499,10 @@ void LoadTex (int id, int tmu)
|
|||
Mirror16bT ((texture), rdp.tiles[td].mask_t,
|
||||
real_y, real_x);
|
||||
else if (size != 2)
|
||||
Mirror8bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
||||
Mirror8bT ((texture), rdp.tiles[td].mask_t,
|
||||
real_y, real_x);
|
||||
else
|
||||
Mirror32bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
||||
Mirror32bT ((texture), rdp.tiles[td].mask_t,
|
||||
real_y, real_x);
|
||||
}
|
||||
else
|
||||
|
@ -1510,10 +1511,10 @@ void LoadTex (int id, int tmu)
|
|||
Wrap16bT ((texture), rdp.tiles[td].mask_t,
|
||||
real_y, real_x);
|
||||
else if (size != 2)
|
||||
Wrap8bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
||||
Wrap8bT ((texture), rdp.tiles[td].mask_t,
|
||||
real_y, real_x);
|
||||
else
|
||||
Wrap32bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
||||
Wrap32bT ((texture), rdp.tiles[td].mask_t,
|
||||
real_y, real_x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,4 +90,42 @@ float ScaleZ(float z);
|
|||
lx = lc; \
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
|
||||
#include <stdlib.h>
|
||||
#define bswap32(x) _byteswap_ulong(x)
|
||||
#else
|
||||
static inline uint32_t bswap32(uint32_t val)
|
||||
{
|
||||
return (((val & 0xff000000) >> 24) |
|
||||
((val & 0x00ff0000) >> 8) |
|
||||
((val & 0x0000ff00) << 8) |
|
||||
((val & 0x000000ff) << 24));
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ALOWORD(x) (*((uint16_t*)&(x))) // low word
|
||||
|
||||
template<class T> static inline T __ROR__(T value, unsigned int count)
|
||||
{
|
||||
const unsigned int nbits = sizeof(T) * 8;
|
||||
count %= nbits;
|
||||
|
||||
T low = value << (nbits - count);
|
||||
value >>= count;
|
||||
value |= low;
|
||||
return value;
|
||||
}
|
||||
|
||||
// rotate left
|
||||
template<class T> static T __ROL__(T value, unsigned int count)
|
||||
{
|
||||
const unsigned int nbits = sizeof(T) * 8;
|
||||
count %= nbits;
|
||||
|
||||
T high = value >> (nbits - count);
|
||||
value <<= count;
|
||||
value |= high;
|
||||
return value;
|
||||
}
|
||||
|
||||
#endif // ifndef Util_H
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include "TxDbg.h"
|
||||
#include <zlib/zlib.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
#include <common/stdtypes.h>
|
||||
|
||||
|
||||
/*
|
||||
* External libraries
|
||||
|
@ -847,30 +850,18 @@ DebugBreak();
|
|||
int
|
||||
TxUtil::log2(int num)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
#if 1
|
||||
if (!num) return 0;
|
||||
#ifdef _M_IX86
|
||||
#ifdef WIN32
|
||||
#if defined(__GNUC__)
|
||||
return __builtin_ctz(num);
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
uint32_t i;
|
||||
_BitScanForward((DWORD *)&i, num);
|
||||
return i;
|
||||
#elif defined(__MSC__)
|
||||
__asm {
|
||||
mov eax, dword ptr [num];
|
||||
bsr eax, eax;
|
||||
mov dword ptr [i], eax;
|
||||
}
|
||||
#else
|
||||
asm volatile(
|
||||
"movl %0, %%eax \n"
|
||||
"bsrl %%eax, %%eax \n"
|
||||
"movl %%eax, %1 \n"
|
||||
:
|
||||
: "m"(num), "m"(i)
|
||||
: "memory", "cc"
|
||||
);
|
||||
#endif
|
||||
#else
|
||||
DebugBreak();
|
||||
#endif
|
||||
#else
|
||||
switch (num) {
|
||||
case 1: return 0;
|
||||
|
@ -887,8 +878,6 @@ TxUtil::log2(int num)
|
|||
case 2048: return 11;
|
||||
}
|
||||
#endif
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in New Issue