parent
42f633c482
commit
32c64b3d54
|
@ -36,15 +36,100 @@
|
|||
// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
|
||||
//
|
||||
//****************************************************************
|
||||
#include <common/stdtypes.h>
|
||||
#include <string.h>
|
||||
typedef uint32_t wxUint32;
|
||||
|
||||
extern "C" void asmMirror16bS (int tex, int start, int width, int height, int mask, int line, int full, int count);
|
||||
extern "C" void asmWrap16bS (int tex, int start, int height, int mask, int line, int full, int count);
|
||||
extern "C" void asmClamp16bS (int tex, int constant, int height,int line, int full, int count);
|
||||
static inline void mirror16bS(uint8_t *tex, uint8_t *start, int width, int height, int mask, int line, int full, int count)
|
||||
{
|
||||
uint16_t *v8;
|
||||
int v9;
|
||||
int v10;
|
||||
|
||||
v8 = (uint16_t *)start;
|
||||
v9 = height;
|
||||
do
|
||||
{
|
||||
v10 = 0;
|
||||
do
|
||||
{
|
||||
if ( width & (v10 + width) )
|
||||
{
|
||||
*v8 = *(uint16_t *)(&tex[mask] - (mask & 2 * v10));
|
||||
++v8;
|
||||
}
|
||||
else
|
||||
{
|
||||
*v8 = *(uint16_t *)&tex[mask & 2 * v10];
|
||||
++v8;
|
||||
}
|
||||
++v10;
|
||||
}
|
||||
while ( v10 != count );
|
||||
v8 = (uint16_t *)((char *)v8 + line);
|
||||
tex += full;
|
||||
--v9;
|
||||
}
|
||||
while ( v9 );
|
||||
}
|
||||
|
||||
static inline void wrap16bS(uint8_t *tex, uint8_t *start, int height, int mask, int line, int full, int count)
|
||||
{
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
int v9;
|
||||
|
||||
v7 = (uint32_t *)start;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v9 = 0;
|
||||
do
|
||||
{
|
||||
*v7 = *(uint32_t *)&tex[4 * (mask & v9)];
|
||||
++v7;
|
||||
++v9;
|
||||
}
|
||||
while ( v9 != count );
|
||||
v7 = (uint32_t *)((char *)v7 + line);
|
||||
tex += full;
|
||||
--v8;
|
||||
}
|
||||
while ( v8 );
|
||||
}
|
||||
|
||||
static inline void clamp16bS(uint8_t *tex, uint8_t *constant, int height, int line, int full, int count)
|
||||
{
|
||||
uint16_t *v6;
|
||||
uint16_t *v7;
|
||||
int v8;
|
||||
uint16_t v9;
|
||||
int v10;
|
||||
|
||||
v6 = (uint16_t *)constant;
|
||||
v7 = (uint16_t *)tex;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v9 = *v6;
|
||||
v10 = count;
|
||||
do
|
||||
{
|
||||
*v7 = v9;
|
||||
++v7;
|
||||
--v10;
|
||||
}
|
||||
while ( v10 );
|
||||
v6 = (uint16_t *)((char *)v6 + full);
|
||||
v7 = (uint16_t *)((char *)v7 + line);
|
||||
--v8;
|
||||
}
|
||||
while ( v8 );
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 16-bit Horizontal Mirror
|
||||
|
||||
void Mirror16bS (wxUint32 tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
|
||||
void Mirror16bS (unsigned char * tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
|
||||
|
@ -56,14 +141,14 @@ void Mirror16bS (wxUint32 tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_
|
|||
int line_full = real_width << 1;
|
||||
int line = line_full - (count << 1);
|
||||
if (line < 0) return;
|
||||
wxUint32 start = tex + (mask_width << 1);
|
||||
asmMirror16bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
|
||||
unsigned char *start = tex + (mask_width << 1);
|
||||
mirror16bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 16-bit Horizontal Wrap (like mirror)
|
||||
|
||||
void Wrap16bS (wxUint32 tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
|
||||
void Wrap16bS (unsigned char * tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
|
||||
|
@ -75,31 +160,31 @@ void Wrap16bS (wxUint32 tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_wi
|
|||
int line_full = real_width << 1;
|
||||
int line = line_full - (count << 2);
|
||||
if (line < 0) return;
|
||||
wxUint32 start = tex + (mask_width << 1);
|
||||
asmWrap16bS (tex, start, height, mask_mask, line, line_full, count);
|
||||
unsigned char * start = tex + (mask_width << 1);
|
||||
wrap16bS (tex, start, height, mask_mask, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 16-bit Horizontal Clamp
|
||||
|
||||
void Clamp16bS (wxUint32 tex, wxUint32 width, wxUint32 clamp_to, wxUint32 real_width, wxUint32 real_height)
|
||||
void Clamp16bS (unsigned char * tex, wxUint32 width, wxUint32 clamp_to, wxUint32 real_width, wxUint32 real_height)
|
||||
{
|
||||
if (real_width <= width) return;
|
||||
|
||||
wxUint32 dest = tex + (width << 1);
|
||||
wxUint32 constant = dest-2;
|
||||
unsigned char * dest = tex + (width << 1);
|
||||
unsigned char * constant = dest-2;
|
||||
int count = clamp_to - width;
|
||||
|
||||
int line_full = real_width << 1;
|
||||
int line = width << 1;
|
||||
|
||||
asmClamp16bS (dest, constant, real_height, line, line_full, count);
|
||||
clamp16bS (dest, constant, real_height, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 16-bit Vertical Mirror
|
||||
|
||||
void Mirror16bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
|
||||
void Mirror16bT (unsigned char * tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
|
||||
|
@ -108,7 +193,7 @@ void Mirror16bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real
|
|||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width << 1;
|
||||
|
||||
wxUint32 dst = tex + mask_height * line_full;
|
||||
unsigned char * dst = tex + mask_height * line_full;
|
||||
|
||||
for (wxUint32 y=mask_height; y<max_height; y++)
|
||||
{
|
||||
|
@ -130,7 +215,7 @@ void Mirror16bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real
|
|||
//****************************************************************
|
||||
// 16-bit Vertical Wrap
|
||||
|
||||
void Wrap16bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
|
||||
void Wrap16bT (unsigned char * tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
|
||||
|
@ -139,7 +224,7 @@ void Wrap16bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_w
|
|||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width << 1;
|
||||
|
||||
wxUint32 dst = tex + mask_height * line_full;
|
||||
unsigned char * dst = tex + mask_height * line_full;
|
||||
|
||||
for (wxUint32 y=mask_height; y<max_height; y++)
|
||||
{
|
||||
|
@ -153,11 +238,11 @@ void Wrap16bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_w
|
|||
//****************************************************************
|
||||
// 16-bit Vertical Clamp
|
||||
|
||||
void Clamp16bT (wxUint32 tex, wxUint32 height, wxUint32 real_width, wxUint32 clamp_to)
|
||||
void Clamp16bT (unsigned char * tex, wxUint32 height, wxUint32 real_width, wxUint32 clamp_to)
|
||||
{
|
||||
int line_full = real_width << 1;
|
||||
wxUint32 dst = tex + height * line_full;
|
||||
wxUint32 const_line = dst - line_full;
|
||||
unsigned char * dst = tex + height * line_full;
|
||||
unsigned char * const_line = dst - line_full;
|
||||
|
||||
for (wxUint32 y=height; y<clamp_to; y++)
|
||||
{
|
||||
|
|
|
@ -1366,7 +1366,7 @@ void LoadTex (int id, int tmu)
|
|||
wxUint32 size = HIWORD(result);
|
||||
// clamp so that it looks somewhat ok when wrapping
|
||||
if (size == 1)
|
||||
Clamp16bT (wxPtrToUInt(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)
|
||||
Clamp8bT (wxPtrToUInt(texture)+start_dst, texinfo[id].height, real_x, cache->splitheight);
|
||||
else
|
||||
|
@ -1396,7 +1396,7 @@ void LoadTex (int id, int tmu)
|
|||
if (min_x > texinfo[id].width)
|
||||
{
|
||||
if (size == 1)
|
||||
Clamp16bS (wxPtrToUInt(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)
|
||||
Clamp8bS (wxPtrToUInt(texture), texinfo[id].width, min_x, real_x, texinfo[id].height);
|
||||
else
|
||||
|
@ -1408,7 +1408,7 @@ void LoadTex (int id, int tmu)
|
|||
if (rdp.tiles[td].mirror_s)
|
||||
{
|
||||
if (size == 1)
|
||||
Mirror16bS (wxPtrToUInt(texture), rdp.tiles[td].mask_s,
|
||||
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,
|
||||
|
@ -1420,7 +1420,7 @@ void LoadTex (int id, int tmu)
|
|||
else
|
||||
{
|
||||
if (size == 1)
|
||||
Wrap16bS (wxPtrToUInt(texture), rdp.tiles[td].mask_s,
|
||||
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,
|
||||
|
@ -1434,7 +1434,7 @@ void LoadTex (int id, int tmu)
|
|||
if (min_y > texinfo[id].height)
|
||||
{
|
||||
if (size == 1)
|
||||
Clamp16bT (wxPtrToUInt(texture), texinfo[id].height, real_x, min_y);
|
||||
Clamp16bT ((texture), texinfo[id].height, real_x, min_y);
|
||||
else if (size != 2)
|
||||
Clamp8bT (wxPtrToUInt(texture), texinfo[id].height, real_x, min_y);
|
||||
else
|
||||
|
@ -1446,7 +1446,7 @@ void LoadTex (int id, int tmu)
|
|||
if (rdp.tiles[td].mirror_t)
|
||||
{
|
||||
if (size == 1)
|
||||
Mirror16bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
||||
Mirror16bT ((texture), rdp.tiles[td].mask_t,
|
||||
real_y, real_x);
|
||||
else if (size != 2)
|
||||
Mirror8bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
||||
|
@ -1458,7 +1458,7 @@ void LoadTex (int id, int tmu)
|
|||
else
|
||||
{
|
||||
if (size == 1)
|
||||
Wrap16bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
||||
Wrap16bT ((texture), rdp.tiles[td].mask_t,
|
||||
real_y, real_x);
|
||||
else if (size != 2)
|
||||
Wrap8bT (wxPtrToUInt(texture), rdp.tiles[td].mask_t,
|
||||
|
|
Loading…
Reference in New Issue