parent
bdc85ddbb7
commit
8bc33bc4d9
|
@ -41,6 +41,7 @@
|
||||||
#include "Gfx_1.3.h"
|
#include "Gfx_1.3.h"
|
||||||
#include "TexCache.h"
|
#include "TexCache.h"
|
||||||
#include "Combine.h"
|
#include "Combine.h"
|
||||||
|
#include "Util.h"
|
||||||
|
|
||||||
void LoadTex (int id, int tmu);
|
void LoadTex (int id, int tmu);
|
||||||
|
|
||||||
|
@ -1417,9 +1418,9 @@ void LoadTex (int id, int tmu)
|
||||||
if (size == 1)
|
if (size == 1)
|
||||||
Clamp16bT ((texture)+start_dst, texinfo[id].height, real_x, cache->splitheight);
|
Clamp16bT ((texture)+start_dst, texinfo[id].height, real_x, cache->splitheight);
|
||||||
else if (size != 2)
|
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
|
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 **
|
// ** end texture splitting **
|
||||||
|
@ -1447,9 +1448,9 @@ void LoadTex (int id, int tmu)
|
||||||
if (size == 1)
|
if (size == 1)
|
||||||
Clamp16bS ((texture), texinfo[id].width, min_x, real_x, texinfo[id].height);
|
Clamp16bS ((texture), texinfo[id].width, min_x, real_x, texinfo[id].height);
|
||||||
else if (size != 2)
|
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
|
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)
|
if (texinfo[id].width < (int)real_x)
|
||||||
|
@ -1460,10 +1461,10 @@ void LoadTex (int id, int tmu)
|
||||||
Mirror16bS ((texture), rdp.tiles[td].mask_s,
|
Mirror16bS ((texture), rdp.tiles[td].mask_s,
|
||||||
real_x, real_x, texinfo[id].height);
|
real_x, real_x, texinfo[id].height);
|
||||||
else if (size != 2)
|
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);
|
real_x, real_x, texinfo[id].height);
|
||||||
else
|
else
|
||||||
Mirror32bS (wxPtrToUInt(texture), rdp.tiles[td].mask_s,
|
Mirror32bS ((texture), rdp.tiles[td].mask_s,
|
||||||
real_x, real_x, texinfo[id].height);
|
real_x, real_x, texinfo[id].height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1472,10 +1473,10 @@ void LoadTex (int id, int tmu)
|
||||||
Wrap16bS ((texture), rdp.tiles[td].mask_s,
|
Wrap16bS ((texture), rdp.tiles[td].mask_s,
|
||||||
real_x, real_x, texinfo[id].height);
|
real_x, real_x, texinfo[id].height);
|
||||||
else if (size != 2)
|
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);
|
real_x, real_x, texinfo[id].height);
|
||||||
else
|
else
|
||||||
Wrap32bS (wxPtrToUInt(texture), rdp.tiles[td].mask_s,
|
Wrap32bS ((texture), rdp.tiles[td].mask_s,
|
||||||
real_x, real_x, texinfo[id].height);
|
real_x, real_x, texinfo[id].height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1485,9 +1486,9 @@ void LoadTex (int id, int tmu)
|
||||||
if (size == 1)
|
if (size == 1)
|
||||||
Clamp16bT ((texture), texinfo[id].height, real_x, min_y);
|
Clamp16bT ((texture), texinfo[id].height, real_x, min_y);
|
||||||
else if (size != 2)
|
else if (size != 2)
|
||||||
Clamp8bT (wxPtrToUInt(texture), texinfo[id].height, real_x, min_y);
|
Clamp8bT ((texture), texinfo[id].height, real_x, min_y);
|
||||||
else
|
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)
|
if (texinfo[id].height < (int)real_y)
|
||||||
|
@ -1498,10 +1499,10 @@ void LoadTex (int id, int tmu)
|
||||||
Mirror16bT ((texture), rdp.tiles[td].mask_t,
|
Mirror16bT ((texture), rdp.tiles[td].mask_t,
|
||||||
real_y, real_x);
|
real_y, real_x);
|
||||||
else if (size != 2)
|
else if (size != 2)
|
||||||
Mirror8bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
Mirror8bT ((texture), rdp.tiles[td].mask_t,
|
||||||
real_y, real_x);
|
real_y, real_x);
|
||||||
else
|
else
|
||||||
Mirror32bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
Mirror32bT ((texture), rdp.tiles[td].mask_t,
|
||||||
real_y, real_x);
|
real_y, real_x);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1510,10 +1511,10 @@ void LoadTex (int id, int tmu)
|
||||||
Wrap16bT ((texture), rdp.tiles[td].mask_t,
|
Wrap16bT ((texture), rdp.tiles[td].mask_t,
|
||||||
real_y, real_x);
|
real_y, real_x);
|
||||||
else if (size != 2)
|
else if (size != 2)
|
||||||
Wrap8bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
Wrap8bT ((texture), rdp.tiles[td].mask_t,
|
||||||
real_y, real_x);
|
real_y, real_x);
|
||||||
else
|
else
|
||||||
Wrap32bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
Wrap32bT ((texture), rdp.tiles[td].mask_t,
|
||||||
real_y, real_x);
|
real_y, real_x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,4 +90,42 @@ float ScaleZ(float z);
|
||||||
lx = lc; \
|
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
|
#endif // ifndef Util_H
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
#include "TxDbg.h"
|
#include "TxDbg.h"
|
||||||
#include <zlib/zlib.h>
|
#include <zlib/zlib.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <common/stdtypes.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* External libraries
|
* External libraries
|
||||||
|
@ -847,30 +850,18 @@ DebugBreak();
|
||||||
int
|
int
|
||||||
TxUtil::log2(int num)
|
TxUtil::log2(int num)
|
||||||
{
|
{
|
||||||
int i = 0;
|
#if defined(__GNUC__)
|
||||||
|
return __builtin_ctz(num);
|
||||||
#if 1
|
#elif defined(_MSC_VER) && _MSC_VER >= 1400
|
||||||
if (!num) return 0;
|
uint32_t i;
|
||||||
#ifdef _M_IX86
|
_BitScanForward((DWORD *)&i, num);
|
||||||
#ifdef WIN32
|
return i;
|
||||||
|
#elif defined(__MSC__)
|
||||||
__asm {
|
__asm {
|
||||||
mov eax, dword ptr [num];
|
mov eax, dword ptr [num];
|
||||||
bsr eax, eax;
|
bsr eax, eax;
|
||||||
mov dword ptr [i], 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
|
#else
|
||||||
switch (num) {
|
switch (num) {
|
||||||
case 1: return 0;
|
case 1: return 0;
|
||||||
|
@ -887,8 +878,6 @@ TxUtil::log2(int num)
|
||||||
case 2048: return 11;
|
case 2048: return 11;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue