[Glide64] Cleanup texture code
This commit is contained in:
parent
308010e16c
commit
989c7294cc
|
@ -37,7 +37,7 @@
|
|||
//
|
||||
//****************************************************************
|
||||
//
|
||||
// CRC32 calculation functions
|
||||
// CRC32 calculation functions
|
||||
//
|
||||
// Created by Gonetz, 2004
|
||||
//
|
||||
|
@ -45,21 +45,21 @@
|
|||
//*
|
||||
#define CRC32_POLYNOMIAL 0x04C11DB7
|
||||
|
||||
unsigned int CRCTable[ 256 ];
|
||||
unsigned int CRCTable[256];
|
||||
|
||||
unsigned int Reflect( unsigned int ref, char ch )
|
||||
unsigned int Reflect(unsigned int ref, char ch)
|
||||
{
|
||||
unsigned int value = 0;
|
||||
unsigned int value = 0;
|
||||
|
||||
// Swap bit 0 for bit 7
|
||||
// bit 1 for bit 6, etc.
|
||||
for (char i = 1; i < (ch + 1); i++)
|
||||
{
|
||||
if(ref & 1)
|
||||
value |= 1 << (ch - i);
|
||||
ref >>= 1;
|
||||
}
|
||||
return value;
|
||||
// Swap bit 0 for bit 7
|
||||
// bit 1 for bit 6, etc.
|
||||
for (char i = 1; i < (ch + 1); i++)
|
||||
{
|
||||
if (ref & 1)
|
||||
value |= 1 << (ch - i);
|
||||
ref >>= 1;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void CRC_BuildTable()
|
||||
|
@ -67,76 +67,76 @@ void CRC_BuildTable()
|
|||
unsigned int crc;
|
||||
|
||||
for (unsigned i = 0; i <= 255; i++)
|
||||
{
|
||||
crc = Reflect( i, 8 ) << 24;
|
||||
{
|
||||
crc = Reflect(i, 8) << 24;
|
||||
for (unsigned j = 0; j < 8; j++)
|
||||
crc = (crc << 1) ^ (crc & (1 << 31) ? CRC32_POLYNOMIAL : 0);
|
||||
|
||||
CRCTable[i] = Reflect( crc, 32 );
|
||||
crc = (crc << 1) ^ (crc & (1 << 31) ? CRC32_POLYNOMIAL : 0);
|
||||
|
||||
CRCTable[i] = Reflect(crc, 32);
|
||||
}
|
||||
}
|
||||
//*/
|
||||
//*
|
||||
unsigned int CRC32( unsigned int crc, void *buffer, unsigned int count )
|
||||
unsigned int CRC32(unsigned int crc, void *buffer, unsigned int count)
|
||||
{
|
||||
unsigned int orig = crc;
|
||||
unsigned char * p = reinterpret_cast<unsigned char*>(buffer);
|
||||
while (count--)
|
||||
crc = (crc >> 8) ^ CRCTable[(crc & 0xFF) ^ *p++];
|
||||
return crc ^ orig;
|
||||
unsigned int orig = crc;
|
||||
unsigned char * p = reinterpret_cast<unsigned char*>(buffer);
|
||||
while (count--)
|
||||
crc = (crc >> 8) ^ CRCTable[(crc & 0xFF) ^ *p++];
|
||||
return crc ^ orig;
|
||||
}
|
||||
//*/
|
||||
|
||||
/*
|
||||
uint32_t CRC_Calculate( uint32_t crc, void *buffer, uint32_t count )
|
||||
{
|
||||
uint32_t Crc32=crc;
|
||||
__asm {
|
||||
mov esi, buffer
|
||||
mov ecx, count
|
||||
mov edx, crc
|
||||
xor eax, eax
|
||||
uint32_t Crc32=crc;
|
||||
__asm {
|
||||
mov esi, buffer
|
||||
mov ecx, count
|
||||
mov edx, crc
|
||||
xor eax, eax
|
||||
|
||||
loop1:
|
||||
inc esi
|
||||
mov al, dl
|
||||
xor al, byte ptr [esi]
|
||||
shr edx, 8
|
||||
mov ebx, [CRCTable+eax*4]
|
||||
xor edx, ebx
|
||||
inc esi
|
||||
mov al, dl
|
||||
xor al, byte ptr [esi]
|
||||
shr edx, 8
|
||||
mov ebx, [CRCTable+eax*4]
|
||||
xor edx, ebx
|
||||
|
||||
loop loop1
|
||||
loop loop1
|
||||
|
||||
xor Crc32, edx
|
||||
}
|
||||
return Crc32;
|
||||
xor Crc32, edx
|
||||
}
|
||||
return Crc32;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
unsigned int CRC_Calculate( unsigned int crc, void *buffer, unsigned int count )
|
||||
{
|
||||
unsigned int Crc32=crc;
|
||||
__asm {
|
||||
mov esi, buffer
|
||||
mov edx, count
|
||||
add edx, esi
|
||||
mov ecx, crc
|
||||
unsigned int Crc32=crc;
|
||||
__asm {
|
||||
mov esi, buffer
|
||||
mov edx, count
|
||||
add edx, esi
|
||||
mov ecx, crc
|
||||
|
||||
loop1:
|
||||
mov bl, byte ptr [esi]
|
||||
movzx eax, cl
|
||||
inc esi
|
||||
xor al, bl
|
||||
shr ecx, 8
|
||||
mov ebx, [CRCTable+eax*4]
|
||||
xor ecx, ebx
|
||||
mov bl, byte ptr [esi]
|
||||
movzx eax, cl
|
||||
inc esi
|
||||
xor al, bl
|
||||
shr ecx, 8
|
||||
mov ebx, [CRCTable+eax*4]
|
||||
xor ecx, ebx
|
||||
|
||||
cmp edx, esi
|
||||
jne loop1
|
||||
cmp edx, esi
|
||||
jne loop1
|
||||
|
||||
xor Crc32, ecx
|
||||
}
|
||||
return Crc32;
|
||||
xor Crc32, ecx
|
||||
}
|
||||
//*/
|
||||
return Crc32;
|
||||
}
|
||||
//*/
|
|
@ -37,7 +37,7 @@
|
|||
//
|
||||
//****************************************************************
|
||||
//
|
||||
// CRC32 calculation functions
|
||||
// CRC32 calculation functions
|
||||
//
|
||||
// Created by Gonetz, 2004
|
||||
//
|
||||
|
@ -45,4 +45,4 @@
|
|||
|
||||
void CRC_BuildTable();
|
||||
|
||||
unsigned int CRC32( unsigned int crc, void *buffer, unsigned int count );
|
||||
unsigned int CRC32(unsigned int crc, void *buffer, unsigned int count);
|
||||
|
|
|
@ -42,211 +42,205 @@ typedef uint32_t uint32_t;
|
|||
|
||||
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;
|
||||
uint16_t *v8;
|
||||
int v9;
|
||||
int v10;
|
||||
|
||||
v8 = (uint16_t *)start;
|
||||
v9 = height;
|
||||
do
|
||||
{
|
||||
v10 = 0;
|
||||
v8 = (uint16_t *)start;
|
||||
v9 = height;
|
||||
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 );
|
||||
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;
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
int v9;
|
||||
|
||||
v7 = (uint32_t *)start;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v9 = 0;
|
||||
v7 = (uint32_t *)start;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
*v7 = *(uint32_t *)&tex[4 * (mask & v9)];
|
||||
++v7;
|
||||
++v9;
|
||||
}
|
||||
while ( v9 != count );
|
||||
v7 = (uint32_t *)((char *)v7 + line);
|
||||
tex += full;
|
||||
--v8;
|
||||
}
|
||||
while ( v8 );
|
||||
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;
|
||||
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;
|
||||
v6 = (uint16_t *)constant;
|
||||
v7 = (uint16_t *)tex;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
*v7 = v9;
|
||||
++v7;
|
||||
--v10;
|
||||
}
|
||||
while ( v10 );
|
||||
v6 = (uint16_t *)((char *)v6 + full);
|
||||
v7 = (uint16_t *)((char *)v7 + line);
|
||||
--v8;
|
||||
}
|
||||
while ( v8 );
|
||||
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 (unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
void Mirror16bS(unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width-1) << 1;
|
||||
if (mask_width >= max_width) return;
|
||||
int count = max_width - mask_width;
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width << 1;
|
||||
int line = line_full - (count << 1);
|
||||
if (line < 0) return;
|
||||
unsigned char *start = tex + (mask_width << 1);
|
||||
mirror16bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width - 1) << 1;
|
||||
if (mask_width >= max_width) return;
|
||||
int count = max_width - mask_width;
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width << 1;
|
||||
int line = line_full - (count << 1);
|
||||
if (line < 0) return;
|
||||
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 (unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
void Wrap16bS(unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width-1) >> 1;
|
||||
if (mask_width >= max_width) return;
|
||||
int count = (max_width - mask_width) >> 1;
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width << 1;
|
||||
int line = line_full - (count << 2);
|
||||
if (line < 0) return;
|
||||
unsigned char * start = tex + (mask_width << 1);
|
||||
wrap16bS (tex, start, height, mask_mask, line, line_full, count);
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width - 1) >> 1;
|
||||
if (mask_width >= max_width) return;
|
||||
int count = (max_width - mask_width) >> 1;
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width << 1;
|
||||
int line = line_full - (count << 2);
|
||||
if (line < 0) return;
|
||||
unsigned char * start = tex + (mask_width << 1);
|
||||
wrap16bS(tex, start, height, mask_mask, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 16-bit Horizontal Clamp
|
||||
|
||||
void Clamp16bS (unsigned char * tex, uint32_t width, uint32_t clamp_to, uint32_t real_width, uint32_t real_height)
|
||||
void Clamp16bS(unsigned char * tex, uint32_t width, uint32_t clamp_to, uint32_t real_width, uint32_t real_height)
|
||||
{
|
||||
if (real_width <= width) return;
|
||||
if (real_width <= width) return;
|
||||
|
||||
unsigned char * dest = tex + (width << 1);
|
||||
unsigned char * constant = dest-2;
|
||||
int count = clamp_to - width;
|
||||
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;
|
||||
int line_full = real_width << 1;
|
||||
int line = width << 1;
|
||||
|
||||
clamp16bS (dest, constant, real_height, line, line_full, count);
|
||||
clamp16bS(dest, constant, real_height, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 16-bit Vertical Mirror
|
||||
|
||||
void Mirror16bT (unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
void Mirror16bT(unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height-1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width << 1;
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height - 1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width << 1;
|
||||
|
||||
unsigned char * dst = tex + mask_height * line_full;
|
||||
unsigned char * dst = tex + mask_height * line_full;
|
||||
|
||||
for (uint32_t y=mask_height; y<max_height; y++)
|
||||
{
|
||||
if (y & mask_height)
|
||||
for (uint32_t y = mask_height; y < max_height; y++)
|
||||
{
|
||||
// mirrored
|
||||
memcpy ((void*)dst, (void*)(tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
|
||||
}
|
||||
else
|
||||
{
|
||||
// not mirrored
|
||||
memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
|
||||
}
|
||||
if (y & mask_height)
|
||||
{
|
||||
// mirrored
|
||||
memcpy((void*)dst, (void*)(tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
|
||||
}
|
||||
else
|
||||
{
|
||||
// not mirrored
|
||||
memcpy((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
|
||||
}
|
||||
|
||||
dst += line_full;
|
||||
}
|
||||
dst += line_full;
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 16-bit Vertical Wrap
|
||||
|
||||
void Wrap16bT (unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
void Wrap16bT(unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height-1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width << 1;
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height - 1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width << 1;
|
||||
|
||||
unsigned char * dst = tex + mask_height * line_full;
|
||||
unsigned char * dst = tex + mask_height * line_full;
|
||||
|
||||
for (uint32_t y=mask_height; y<max_height; y++)
|
||||
{
|
||||
// not mirrored
|
||||
memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
|
||||
for (uint32_t y = mask_height; y < max_height; y++)
|
||||
{
|
||||
// not mirrored
|
||||
memcpy((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
|
||||
|
||||
dst += line_full;
|
||||
}
|
||||
dst += line_full;
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 16-bit Vertical Clamp
|
||||
|
||||
void Clamp16bT (unsigned char * tex, uint32_t height, uint32_t real_width, uint32_t clamp_to)
|
||||
void Clamp16bT(unsigned char * tex, uint32_t height, uint32_t real_width, uint32_t clamp_to)
|
||||
{
|
||||
int line_full = real_width << 1;
|
||||
unsigned char * dst = tex + height * line_full;
|
||||
unsigned char * const_line = dst - line_full;
|
||||
int line_full = real_width << 1;
|
||||
unsigned char * dst = tex + height * line_full;
|
||||
unsigned char * const_line = dst - line_full;
|
||||
|
||||
for (uint32_t y=height; y<clamp_to; y++)
|
||||
{
|
||||
memcpy ((void*)dst, (void*)const_line, line_full);
|
||||
dst += line_full;
|
||||
}
|
||||
for (uint32_t y = height; y < clamp_to; y++)
|
||||
{
|
||||
memcpy((void*)dst, (void*)const_line, line_full);
|
||||
dst += line_full;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,212 +43,206 @@
|
|||
|
||||
static inline void mirror32bS(uint8_t *tex, uint8_t *start, int width, int height, int mask, int line, int full, int count)
|
||||
{
|
||||
uint32_t *v8;
|
||||
int v9;
|
||||
int v10;
|
||||
uint32_t *v8;
|
||||
int v9;
|
||||
int v10;
|
||||
|
||||
v8 = (uint32_t *)start;
|
||||
v9 = height;
|
||||
do
|
||||
{
|
||||
v10 = 0;
|
||||
v8 = (uint32_t *)start;
|
||||
v9 = height;
|
||||
do
|
||||
{
|
||||
if ( width & (v10 + width) )
|
||||
{
|
||||
*v8 = *(uint32_t *)(&tex[mask] - (mask & 4 * v10));
|
||||
++v8;
|
||||
}
|
||||
else
|
||||
{
|
||||
*v8 = *(uint32_t *)&tex[mask & 4 * v10];
|
||||
++v8;
|
||||
}
|
||||
++v10;
|
||||
}
|
||||
while ( v10 != count );
|
||||
v8 = (uint32_t *)((char *)v8 + line);
|
||||
tex += full;
|
||||
--v9;
|
||||
}
|
||||
while ( v9 );
|
||||
v10 = 0;
|
||||
do
|
||||
{
|
||||
if (width & (v10 + width))
|
||||
{
|
||||
*v8 = *(uint32_t *)(&tex[mask] - (mask & 4 * v10));
|
||||
++v8;
|
||||
}
|
||||
else
|
||||
{
|
||||
*v8 = *(uint32_t *)&tex[mask & 4 * v10];
|
||||
++v8;
|
||||
}
|
||||
++v10;
|
||||
} while (v10 != count);
|
||||
v8 = (uint32_t *)((char *)v8 + line);
|
||||
tex += full;
|
||||
--v9;
|
||||
} while (v9);
|
||||
}
|
||||
|
||||
static inline void wrap32bS(uint8_t *tex, uint8_t *start, int height, int mask, int line, int full, int count)
|
||||
{
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
int v9;
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
int v9;
|
||||
|
||||
v7 = (uint32_t *)start;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v9 = 0;
|
||||
v7 = (uint32_t *)start;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
*v7 = *(uint32_t *)&tex[4 * (mask & v9)];
|
||||
++v7;
|
||||
++v9;
|
||||
}
|
||||
while ( v9 != count );
|
||||
v7 = (uint32_t *)((char *)v7 + line);
|
||||
tex += full;
|
||||
--v8;
|
||||
}
|
||||
while ( v8 );
|
||||
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 clamp32bS(uint8_t *tex, uint8_t *constant, int height, int line, int full, int count)
|
||||
{
|
||||
uint32_t *v6;
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
uint32_t v9;
|
||||
int v10;
|
||||
uint32_t *v6;
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
uint32_t v9;
|
||||
int v10;
|
||||
|
||||
v6 = (uint32_t *)constant;
|
||||
v7 = (uint32_t *)tex;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v9 = *v6;
|
||||
v10 = count;
|
||||
v6 = (uint32_t *)constant;
|
||||
v7 = (uint32_t *)tex;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
*v7 = v9;
|
||||
++v7;
|
||||
--v10;
|
||||
}
|
||||
while ( v10 );
|
||||
v6 = (uint32_t *)((char *)v6 + full);
|
||||
v7 = (uint32_t *)((char *)v7 + line);
|
||||
--v8;
|
||||
}
|
||||
while ( v8 );
|
||||
v9 = *v6;
|
||||
v10 = count;
|
||||
do
|
||||
{
|
||||
*v7 = v9;
|
||||
++v7;
|
||||
--v10;
|
||||
} while (v10);
|
||||
v6 = (uint32_t *)((char *)v6 + full);
|
||||
v7 = (uint32_t *)((char *)v7 + line);
|
||||
--v8;
|
||||
} while (v8);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 32-bit Horizontal Mirror
|
||||
|
||||
void Mirror32bS (unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
void Mirror32bS(unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width-1) << 2;
|
||||
if (mask_width >= max_width) return;
|
||||
int count = max_width - mask_width;
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width << 2;
|
||||
int line = line_full - (count << 2);
|
||||
if (line < 0) return;
|
||||
unsigned char * start = tex + (mask_width << 2);
|
||||
mirror32bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width - 1) << 2;
|
||||
if (mask_width >= max_width) return;
|
||||
int count = max_width - mask_width;
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width << 2;
|
||||
int line = line_full - (count << 2);
|
||||
if (line < 0) return;
|
||||
unsigned char * start = tex + (mask_width << 2);
|
||||
mirror32bS(tex, start, mask_width, height, mask_mask, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 32-bit Horizontal Wrap
|
||||
// 32-bit Horizontal Wrap
|
||||
|
||||
void Wrap32bS (unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
void Wrap32bS(unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width-1);
|
||||
if (mask_width >= max_width) return;
|
||||
int count = (max_width - mask_width);
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width << 2;
|
||||
int line = line_full - (count << 2);
|
||||
if (line < 0) return;
|
||||
unsigned char * start = tex + (mask_width << 2);
|
||||
wrap32bS (tex, start, height, mask_mask, line, line_full, count);
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width - 1);
|
||||
if (mask_width >= max_width) return;
|
||||
int count = (max_width - mask_width);
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width << 2;
|
||||
int line = line_full - (count << 2);
|
||||
if (line < 0) return;
|
||||
unsigned char * start = tex + (mask_width << 2);
|
||||
wrap32bS(tex, start, height, mask_mask, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 32-bit Horizontal Clamp
|
||||
|
||||
void Clamp32bS (unsigned char * tex, uint32_t width, uint32_t clamp_to, uint32_t real_width, uint32_t real_height)
|
||||
void Clamp32bS(unsigned char * tex, uint32_t width, uint32_t clamp_to, uint32_t real_width, uint32_t real_height)
|
||||
{
|
||||
if (real_width <= width) return;
|
||||
if (real_width <= width) return;
|
||||
|
||||
unsigned char *dest = tex + (width << 2);
|
||||
unsigned char *constant = dest-4;
|
||||
|
||||
int count = clamp_to - width;
|
||||
|
||||
int line_full = real_width << 2;
|
||||
int line = width << 2;
|
||||
clamp32bS (dest, constant, real_height, line, line_full, count);
|
||||
unsigned char *dest = tex + (width << 2);
|
||||
unsigned char *constant = dest - 4;
|
||||
|
||||
int count = clamp_to - width;
|
||||
|
||||
int line_full = real_width << 2;
|
||||
int line = width << 2;
|
||||
clamp32bS(dest, constant, real_height, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 32-bit Vertical Mirror
|
||||
|
||||
void Mirror32bT (unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
void Mirror32bT(unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height-1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width << 2;
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height - 1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width << 2;
|
||||
|
||||
unsigned char *dst = tex + mask_height * line_full;
|
||||
unsigned char *dst = tex + mask_height * line_full;
|
||||
|
||||
for (uint32_t y=mask_height; y<max_height; y++)
|
||||
{
|
||||
if (y & mask_height)
|
||||
{
|
||||
// mirrored
|
||||
memcpy ((void*)dst, (void*)(tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
|
||||
}
|
||||
else
|
||||
{
|
||||
// not mirrored
|
||||
memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
|
||||
}
|
||||
for (uint32_t y = mask_height; y < max_height; y++)
|
||||
{
|
||||
if (y & mask_height)
|
||||
{
|
||||
// mirrored
|
||||
memcpy((void*)dst, (void*)(tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
|
||||
}
|
||||
else
|
||||
{
|
||||
// not mirrored
|
||||
memcpy((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
|
||||
}
|
||||
|
||||
dst += line_full;
|
||||
}
|
||||
dst += line_full;
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 32-bit Vertical Wrap
|
||||
|
||||
void Wrap32bT (unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
void Wrap32bT(unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height-1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width << 2;
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height - 1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width << 2;
|
||||
|
||||
unsigned char *dst = tex + mask_height * line_full;
|
||||
unsigned char *dst = tex + mask_height * line_full;
|
||||
|
||||
for (uint32_t y=mask_height; y<max_height; y++)
|
||||
{
|
||||
// not mirrored
|
||||
memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * (line_full>>2)), (line_full>>2));
|
||||
for (uint32_t y = mask_height; y < max_height; y++)
|
||||
{
|
||||
// not mirrored
|
||||
memcpy((void*)dst, (void*)(tex + (y & mask_mask) * (line_full >> 2)), (line_full >> 2));
|
||||
|
||||
dst += line_full;
|
||||
}
|
||||
dst += line_full;
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 32-bit Vertical Clamp
|
||||
|
||||
void Clamp32bT (unsigned char * tex, uint32_t height, uint32_t real_width, uint32_t clamp_to)
|
||||
void Clamp32bT(unsigned char * tex, uint32_t height, uint32_t real_width, uint32_t clamp_to)
|
||||
{
|
||||
int line_full = real_width << 2;
|
||||
unsigned char *dst = tex + height * line_full;
|
||||
unsigned char *const_line = dst - line_full;
|
||||
int line_full = real_width << 2;
|
||||
unsigned char *dst = tex + height * line_full;
|
||||
unsigned char *const_line = dst - line_full;
|
||||
|
||||
for (uint32_t y=height; y<clamp_to; y++)
|
||||
{
|
||||
memcpy ((void*)dst, (void*)const_line, line_full);
|
||||
dst += line_full;
|
||||
}
|
||||
for (uint32_t y = height; y < clamp_to; y++)
|
||||
{
|
||||
memcpy((void*)dst, (void*)const_line, line_full);
|
||||
dst += line_full;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,204 +42,195 @@
|
|||
|
||||
static inline void mirror8bS(uint8_t *tex, uint8_t *start, int width, int height, int mask, int line, int full, int count)
|
||||
{
|
||||
uint8_t *v8;
|
||||
int v9;
|
||||
int v10;
|
||||
uint8_t *v8;
|
||||
int v9;
|
||||
int v10;
|
||||
|
||||
v8 = start;
|
||||
v9 = height;
|
||||
do
|
||||
{
|
||||
v10 = 0;
|
||||
v8 = start;
|
||||
v9 = height;
|
||||
do
|
||||
{
|
||||
if ( width & (v10 + width) )
|
||||
*v8++ = *(&tex[mask] - (mask & v10));
|
||||
else
|
||||
*v8++ = tex[mask & v10];
|
||||
++v10;
|
||||
}
|
||||
while ( v10 != count );
|
||||
v8 += line;
|
||||
tex += full;
|
||||
--v9;
|
||||
}
|
||||
while ( v9 );
|
||||
v10 = 0;
|
||||
do
|
||||
{
|
||||
if (width & (v10 + width))
|
||||
*v8++ = *(&tex[mask] - (mask & v10));
|
||||
else
|
||||
*v8++ = tex[mask & v10];
|
||||
++v10;
|
||||
} while (v10 != count);
|
||||
v8 += line;
|
||||
tex += full;
|
||||
--v9;
|
||||
} while (v9);
|
||||
}
|
||||
|
||||
static inline void wrap8bS(uint8_t *tex, uint8_t *start, int height, int mask, int line, int full, int count)
|
||||
{
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
int v9;
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
int v9;
|
||||
|
||||
v7 = (uint32_t *)start;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v9 = 0;
|
||||
v7 = (uint32_t *)start;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
*v7 = *(uint32_t *)&tex[4 * (mask & v9)];
|
||||
++v7;
|
||||
++v9;
|
||||
}
|
||||
while ( v9 != count );
|
||||
v7 = (uint32_t *)((char *)v7 + line);
|
||||
tex += full;
|
||||
--v8;
|
||||
}
|
||||
while ( v8 );
|
||||
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 clamp8bS(uint8_t *tex, uint8_t *constant, int height, int line, int full, int count)
|
||||
{
|
||||
uint8_t *v6;
|
||||
uint8_t *v7;
|
||||
int v8;
|
||||
uint8_t v9;
|
||||
int v10;
|
||||
uint8_t *v6;
|
||||
uint8_t *v7;
|
||||
int v8;
|
||||
uint8_t v9;
|
||||
int v10;
|
||||
|
||||
v6 = constant;
|
||||
v7 = tex;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v9 = *v6;
|
||||
v10 = count;
|
||||
v6 = constant;
|
||||
v7 = tex;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
*v7++ = v9;
|
||||
--v10;
|
||||
}
|
||||
while ( v10 );
|
||||
v6 += full;
|
||||
v7 += line;
|
||||
--v8;
|
||||
}
|
||||
while ( v8 );
|
||||
v9 = *v6;
|
||||
v10 = count;
|
||||
do
|
||||
{
|
||||
*v7++ = v9;
|
||||
--v10;
|
||||
} while (v10);
|
||||
v6 += full;
|
||||
v7 += line;
|
||||
--v8;
|
||||
} while (v8);
|
||||
}
|
||||
|
||||
void Mirror8bS (unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
void Mirror8bS(unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width-1);
|
||||
if (mask_width >= max_width) return;
|
||||
int count = max_width - mask_width;
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width;
|
||||
int line = line_full - (count);
|
||||
if (line < 0) return;
|
||||
unsigned char * start = tex + (mask_width);
|
||||
mirror8bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width - 1);
|
||||
if (mask_width >= max_width) return;
|
||||
int count = max_width - mask_width;
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width;
|
||||
int line = line_full - (count);
|
||||
if (line < 0) return;
|
||||
unsigned char * start = tex + (mask_width);
|
||||
mirror8bS(tex, start, mask_width, height, mask_mask, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 8-bit Horizontal Wrap (like mirror) ** UNTESTED **
|
||||
|
||||
|
||||
void Wrap8bS (unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
void Wrap8bS(unsigned char * tex, uint32_t mask, uint32_t max_width, uint32_t real_width, uint32_t height)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width-1) >> 2;
|
||||
if (mask_width >= max_width) return;
|
||||
int count = (max_width - mask_width) >> 2;
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width;
|
||||
int line = line_full - (count << 2);
|
||||
if (line < 0) return;
|
||||
unsigned char * start = tex + (mask_width);
|
||||
wrap8bS (tex, start, height, mask_mask, line, line_full, count);
|
||||
uint32_t mask_width = (1 << mask);
|
||||
uint32_t mask_mask = (mask_width - 1) >> 2;
|
||||
if (mask_width >= max_width) return;
|
||||
int count = (max_width - mask_width) >> 2;
|
||||
if (count <= 0) return;
|
||||
int line_full = real_width;
|
||||
int line = line_full - (count << 2);
|
||||
if (line < 0) return;
|
||||
unsigned char * start = tex + (mask_width);
|
||||
wrap8bS(tex, start, height, mask_mask, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 8-bit Horizontal Clamp
|
||||
|
||||
|
||||
void Clamp8bS (unsigned char * tex, uint32_t width, uint32_t clamp_to, uint32_t real_width, uint32_t real_height)
|
||||
void Clamp8bS(unsigned char * tex, uint32_t width, uint32_t clamp_to, uint32_t real_width, uint32_t real_height)
|
||||
{
|
||||
if (real_width <= width) return;
|
||||
if (real_width <= width) return;
|
||||
|
||||
unsigned char * dest = tex + (width);
|
||||
unsigned char * constant = dest-1;
|
||||
int count = clamp_to - width;
|
||||
unsigned char * dest = tex + (width);
|
||||
unsigned char * constant = dest - 1;
|
||||
int count = clamp_to - width;
|
||||
|
||||
int line_full = real_width;
|
||||
int line = width;
|
||||
clamp8bS (dest, constant, real_height, line, line_full, count);
|
||||
int line_full = real_width;
|
||||
int line = width;
|
||||
clamp8bS(dest, constant, real_height, line, line_full, count);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 8-bit Vertical Mirror
|
||||
|
||||
void Mirror8bT (unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
void Mirror8bT(unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height-1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width;
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height - 1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width;
|
||||
|
||||
unsigned char * dst = tex + mask_height * line_full;
|
||||
unsigned char * dst = tex + mask_height * line_full;
|
||||
|
||||
for (uint32_t y=mask_height; y<max_height; y++)
|
||||
{
|
||||
if (y & mask_height)
|
||||
for (uint32_t y = mask_height; y < max_height; y++)
|
||||
{
|
||||
// mirrored
|
||||
memcpy ((void*)dst, (void*)(tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
|
||||
}
|
||||
else
|
||||
{
|
||||
// not mirrored
|
||||
memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
|
||||
}
|
||||
if (y & mask_height)
|
||||
{
|
||||
// mirrored
|
||||
memcpy((void*)dst, (void*)(tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
|
||||
}
|
||||
else
|
||||
{
|
||||
// not mirrored
|
||||
memcpy((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
|
||||
}
|
||||
|
||||
dst += line_full;
|
||||
}
|
||||
dst += line_full;
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 8-bit Vertical Wrap
|
||||
|
||||
void Wrap8bT (unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
void Wrap8bT(unsigned char * tex, uint32_t mask, uint32_t max_height, uint32_t real_width)
|
||||
{
|
||||
if (mask == 0) return;
|
||||
if (mask == 0) return;
|
||||
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height-1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width;
|
||||
uint32_t mask_height = (1 << mask);
|
||||
uint32_t mask_mask = mask_height - 1;
|
||||
if (max_height <= mask_height) return;
|
||||
int line_full = real_width;
|
||||
|
||||
unsigned char * dst = tex + mask_height * line_full;
|
||||
unsigned char * dst = tex + mask_height * line_full;
|
||||
|
||||
for (uint32_t y=mask_height; y<max_height; y++)
|
||||
{
|
||||
// not mirrored
|
||||
memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
|
||||
for (uint32_t y = mask_height; y < max_height; y++)
|
||||
{
|
||||
// not mirrored
|
||||
memcpy((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
|
||||
|
||||
dst += line_full;
|
||||
}
|
||||
dst += line_full;
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// 8-bit Vertical Clamp
|
||||
|
||||
void Clamp8bT (unsigned char * tex, uint32_t height, uint32_t real_width, uint32_t clamp_to)
|
||||
void Clamp8bT(unsigned char * tex, uint32_t height, uint32_t real_width, uint32_t clamp_to)
|
||||
{
|
||||
int line_full = real_width;
|
||||
unsigned char * dst = tex + height * line_full;
|
||||
unsigned char * const_line = dst - line_full;
|
||||
int line_full = real_width;
|
||||
unsigned char * dst = tex + height * line_full;
|
||||
unsigned char * const_line = dst - line_full;
|
||||
|
||||
for (uint32_t y=height; y<clamp_to; y++)
|
||||
{
|
||||
memcpy ((void*)dst, (void*)const_line, line_full);
|
||||
dst += line_full;
|
||||
}
|
||||
for (uint32_t y = height; y < clamp_to; y++)
|
||||
{
|
||||
memcpy((void*)dst, (void*)const_line, line_full);
|
||||
dst += line_full;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
#ifndef TEXCACHE_H
|
||||
#define TEXCACHE_H
|
||||
|
||||
void TexCacheInit ();
|
||||
void TexCache ();
|
||||
void ClearCache ();
|
||||
void TexCacheInit();
|
||||
void TexCache();
|
||||
void ClearCache();
|
||||
|
||||
extern uint8_t * texture_buffer;
|
||||
|
||||
|
|
|
@ -39,129 +39,124 @@
|
|||
|
||||
static inline void texConv_ARGB1555_ARGB4444(uint8_t *src, uint8_t *dst, int size)
|
||||
{
|
||||
uint32_t *v3;
|
||||
uint32_t *v4;
|
||||
int v5;
|
||||
uint32_t v6;
|
||||
uint32_t v7;
|
||||
uint32_t *v3;
|
||||
uint32_t *v4;
|
||||
int v5;
|
||||
uint32_t v6;
|
||||
uint32_t v7;
|
||||
|
||||
v3 = (uint32_t *)src;
|
||||
v4 = (uint32_t *)dst;
|
||||
v5 = size;
|
||||
do
|
||||
{
|
||||
v6 = *v3;
|
||||
++v3;
|
||||
v7 = v6;
|
||||
*v4 = ((v7 & 0x1E001E) >> 1) | ((v6 & 0x3C003C0) >> 2) | ((v6 & 0x78007800) >> 3) | ((v6 & 0x80008000) >> 3) | ((v6 & 0x80008000) >> 2) | ((v6 & 0x80008000) >> 1) | (v6 & 0x80008000);
|
||||
++v4;
|
||||
--v5;
|
||||
}
|
||||
while ( v5 );
|
||||
v3 = (uint32_t *)src;
|
||||
v4 = (uint32_t *)dst;
|
||||
v5 = size;
|
||||
do
|
||||
{
|
||||
v6 = *v3;
|
||||
++v3;
|
||||
v7 = v6;
|
||||
*v4 = ((v7 & 0x1E001E) >> 1) | ((v6 & 0x3C003C0) >> 2) | ((v6 & 0x78007800) >> 3) | ((v6 & 0x80008000) >> 3) | ((v6 & 0x80008000) >> 2) | ((v6 & 0x80008000) >> 1) | (v6 & 0x80008000);
|
||||
++v4;
|
||||
--v5;
|
||||
} while (v5);
|
||||
}
|
||||
|
||||
static inline void texConv_AI88_ARGB4444(uint8_t *src, uint8_t *dst, int size)
|
||||
{
|
||||
uint32_t *v3;
|
||||
uint32_t *v4;
|
||||
int v5;
|
||||
uint32_t v6;
|
||||
uint32_t v7;
|
||||
uint32_t *v3;
|
||||
uint32_t *v4;
|
||||
int v5;
|
||||
uint32_t v6;
|
||||
uint32_t v7;
|
||||
|
||||
v3 = (uint32_t *)src;
|
||||
v4 = (uint32_t *)dst;
|
||||
v5 = size;
|
||||
do
|
||||
{
|
||||
v6 = *v3;
|
||||
++v3;
|
||||
v7 = v6;
|
||||
*v4 = (16 * (v7 & 0xF000F0) >> 8) | (v7 & 0xF000F0) | (16 * (v7 & 0xF000F0)) | (v6 & 0xF000F000);
|
||||
++v4;
|
||||
--v5;
|
||||
}
|
||||
while ( v5 );
|
||||
v3 = (uint32_t *)src;
|
||||
v4 = (uint32_t *)dst;
|
||||
v5 = size;
|
||||
do
|
||||
{
|
||||
v6 = *v3;
|
||||
++v3;
|
||||
v7 = v6;
|
||||
*v4 = (16 * (v7 & 0xF000F0) >> 8) | (v7 & 0xF000F0) | (16 * (v7 & 0xF000F0)) | (v6 & 0xF000F000);
|
||||
++v4;
|
||||
--v5;
|
||||
} while (v5);
|
||||
}
|
||||
|
||||
static inline void texConv_AI44_ARGB4444(uint8_t *src, uint8_t *dst, int size)
|
||||
{
|
||||
uint32_t *v3;
|
||||
uint32_t *v4;
|
||||
int v5;
|
||||
uint32_t v6;
|
||||
uint32_t *v7;
|
||||
uint32_t *v3;
|
||||
uint32_t *v4;
|
||||
int v5;
|
||||
uint32_t v6;
|
||||
uint32_t *v7;
|
||||
|
||||
v3 = (uint32_t *)src;
|
||||
v4 = (uint32_t *)dst;
|
||||
v5 = size;
|
||||
do
|
||||
{
|
||||
v6 = *v3;
|
||||
++v3;
|
||||
*v4 = ((((uint16_t)v6 << 8) & 0xFF00 & 0xF00u) >> 8) | ((((uint16_t)v6 << 8) & 0xFF00 & 0xF00u) >> 4) | (uint16_t)(((uint16_t)v6 << 8) & 0xFF00) | (((v6 << 16) & 0xF000000) >> 8) | (((v6 << 16) & 0xF000000) >> 4) | ((v6 << 16) & 0xFF000000);
|
||||
v7 = v4 + 1;
|
||||
*v7 = (((v6 >> 8) & 0xF00) >> 8) | (((v6 >> 8) & 0xF00) >> 4) | ((v6 >> 8) & 0xFF00) | ((v6 & 0xF000000) >> 8) | ((v6 & 0xF000000) >> 4) | (v6 & 0xFF000000);
|
||||
v4 = v7 + 1;
|
||||
--v5;
|
||||
}
|
||||
while ( v5 );
|
||||
v3 = (uint32_t *)src;
|
||||
v4 = (uint32_t *)dst;
|
||||
v5 = size;
|
||||
do
|
||||
{
|
||||
v6 = *v3;
|
||||
++v3;
|
||||
*v4 = ((((uint16_t)v6 << 8) & 0xFF00 & 0xF00u) >> 8) | ((((uint16_t)v6 << 8) & 0xFF00 & 0xF00u) >> 4) | (uint16_t)(((uint16_t)v6 << 8) & 0xFF00) | (((v6 << 16) & 0xF000000) >> 8) | (((v6 << 16) & 0xF000000) >> 4) | ((v6 << 16) & 0xFF000000);
|
||||
v7 = v4 + 1;
|
||||
*v7 = (((v6 >> 8) & 0xF00) >> 8) | (((v6 >> 8) & 0xF00) >> 4) | ((v6 >> 8) & 0xFF00) | ((v6 & 0xF000000) >> 8) | ((v6 & 0xF000000) >> 4) | (v6 & 0xFF000000);
|
||||
v4 = v7 + 1;
|
||||
--v5;
|
||||
} while (v5);
|
||||
}
|
||||
|
||||
static inline void texConv_A8_ARGB4444(uint8_t *src, uint8_t *dst, int size)
|
||||
{
|
||||
uint32_t *v3;
|
||||
uint32_t *v4;
|
||||
int v5;
|
||||
uint32_t v6;
|
||||
uint32_t v7;
|
||||
uint32_t *v8;
|
||||
uint32_t *v3;
|
||||
uint32_t *v4;
|
||||
int v5;
|
||||
uint32_t v6;
|
||||
uint32_t v7;
|
||||
uint32_t *v8;
|
||||
|
||||
v3 = (uint32_t *)src;
|
||||
v4 = (uint32_t *)dst;
|
||||
v5 = size;
|
||||
do
|
||||
{
|
||||
v6 = *v3;
|
||||
++v3;
|
||||
v7 = v6;
|
||||
*v4 = ((v6 & 0xF0) << 8 >> 12) | (uint8_t)(v6 & 0xF0) | (16 * (uint8_t)(v6 & 0xF0) & 0xFFFFFFF) | ((uint8_t)(v6 & 0xF0) << 8) | (16 * (uint16_t)(v6 & 0xF000) & 0xFFFFF) | (((uint16_t)(v6 & 0xF000) << 8) & 0xFFFFFF) | (((uint16_t)(v6 & 0xF000) << 12) & 0xFFFFFFF) | ((uint16_t)(v6 & 0xF000) << 16);
|
||||
v8 = v4 + 1;
|
||||
*v8 = ((v7 & 0xF00000) >> 20) | ((v7 & 0xF00000) >> 16) | ((v7 & 0xF00000) >> 12) | ((v7 & 0xF00000) >> 8) | ((v6 & 0xF0000000) >> 12) | ((v6 & 0xF0000000) >> 8) | ((v6 & 0xF0000000) >> 4) | (v6 & 0xF0000000);
|
||||
v4 = v8 + 1;
|
||||
--v5;
|
||||
}
|
||||
while ( v5 );
|
||||
v3 = (uint32_t *)src;
|
||||
v4 = (uint32_t *)dst;
|
||||
v5 = size;
|
||||
do
|
||||
{
|
||||
v6 = *v3;
|
||||
++v3;
|
||||
v7 = v6;
|
||||
*v4 = ((v6 & 0xF0) << 8 >> 12) | (uint8_t)(v6 & 0xF0) | (16 * (uint8_t)(v6 & 0xF0) & 0xFFFFFFF) | ((uint8_t)(v6 & 0xF0) << 8) | (16 * (uint16_t)(v6 & 0xF000) & 0xFFFFF) | (((uint16_t)(v6 & 0xF000) << 8) & 0xFFFFFF) | (((uint16_t)(v6 & 0xF000) << 12) & 0xFFFFFFF) | ((uint16_t)(v6 & 0xF000) << 16);
|
||||
v8 = v4 + 1;
|
||||
*v8 = ((v7 & 0xF00000) >> 20) | ((v7 & 0xF00000) >> 16) | ((v7 & 0xF00000) >> 12) | ((v7 & 0xF00000) >> 8) | ((v6 & 0xF0000000) >> 12) | ((v6 & 0xF0000000) >> 8) | ((v6 & 0xF0000000) >> 4) | (v6 & 0xF0000000);
|
||||
v4 = v8 + 1;
|
||||
--v5;
|
||||
} while (v5);
|
||||
}
|
||||
|
||||
void TexConv_ARGB1555_ARGB4444 (unsigned char * src, unsigned char * dst, int width, int height)
|
||||
void TexConv_ARGB1555_ARGB4444(unsigned char * src, unsigned char * dst, int width, int height)
|
||||
{
|
||||
int size = (width * height) >> 1; // Hiroshi Morii <koolsmoky@users.sourceforge.net>
|
||||
// 2 pixels are converted in one loop
|
||||
// NOTE: width * height must be a multiple of 2
|
||||
texConv_ARGB1555_ARGB4444(src, dst, size);
|
||||
int size = (width * height) >> 1; // Hiroshi Morii <koolsmoky@users.sourceforge.net>
|
||||
// 2 pixels are converted in one loop
|
||||
// NOTE: width * height must be a multiple of 2
|
||||
texConv_ARGB1555_ARGB4444(src, dst, size);
|
||||
}
|
||||
|
||||
void TexConv_AI88_ARGB4444 (unsigned char * src, unsigned char * dst, int width, int height)
|
||||
void TexConv_AI88_ARGB4444(unsigned char * src, unsigned char * dst, int width, int height)
|
||||
{
|
||||
int size = (width * height) >> 1; // Hiroshi Morii <koolsmoky@users.sourceforge.net>
|
||||
// 2 pixels are converted in one loop
|
||||
// NOTE: width * height must be a multiple of 2
|
||||
texConv_AI88_ARGB4444(src, dst, size);
|
||||
int size = (width * height) >> 1; // Hiroshi Morii <koolsmoky@users.sourceforge.net>
|
||||
// 2 pixels are converted in one loop
|
||||
// NOTE: width * height must be a multiple of 2
|
||||
texConv_AI88_ARGB4444(src, dst, size);
|
||||
}
|
||||
|
||||
void TexConv_AI44_ARGB4444 (unsigned char * src, unsigned char * dst, int width, int height)
|
||||
void TexConv_AI44_ARGB4444(unsigned char * src, unsigned char * dst, int width, int height)
|
||||
{
|
||||
int size = (width * height) >> 2; // Hiroshi Morii <koolsmoky@users.sourceforge.net>
|
||||
// 4 pixels are converted in one loop
|
||||
// NOTE: width * height must be a multiple of 4
|
||||
texConv_AI44_ARGB4444(src, dst, size);
|
||||
int size = (width * height) >> 2; // Hiroshi Morii <koolsmoky@users.sourceforge.net>
|
||||
// 4 pixels are converted in one loop
|
||||
// NOTE: width * height must be a multiple of 4
|
||||
texConv_AI44_ARGB4444(src, dst, size);
|
||||
}
|
||||
|
||||
void TexConv_A8_ARGB4444 (unsigned char * src, unsigned char * dst, int width, int height)
|
||||
void TexConv_A8_ARGB4444(unsigned char * src, unsigned char * dst, int width, int height)
|
||||
{
|
||||
int size = (width * height) >> 2; // Hiroshi Morii <koolsmoky@users.sourceforge.net>
|
||||
// 4 pixels are converted in one loop
|
||||
// NOTE: width * height must be a multiple of 4
|
||||
texConv_A8_ARGB4444(src, dst, size);
|
||||
int size = (width * height) >> 2; // Hiroshi Morii <koolsmoky@users.sourceforge.net>
|
||||
// 4 pixels are converted in one loop
|
||||
// NOTE: width * height must be a multiple of 4
|
||||
texConv_A8_ARGB4444(src, dst, size);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,35 +42,35 @@
|
|||
#include "TexLoad16b.h"
|
||||
#include "TexLoad32b.h"
|
||||
|
||||
uint32_t LoadNone(uintptr_t /*dst*/,uintptr_t /*src*/,int /*wid_64*/,int /*height*/,int /*line*/,int /*real_width*/,int /*tile*/)
|
||||
uint32_t LoadNone(uintptr_t /*dst*/, uintptr_t /*src*/, int /*wid_64*/, int /*height*/, int /*line*/, int /*real_width*/, int /*tile*/)
|
||||
{
|
||||
memset (texture, 0, 4096*4);
|
||||
return (1 << 16) | GR_TEXFMT_ARGB_1555;
|
||||
memset(texture, 0, 4096 * 4);
|
||||
return (1 << 16) | GR_TEXFMT_ARGB_1555;
|
||||
}
|
||||
|
||||
typedef uint32_t (*texfunc)(uintptr_t, uintptr_t, int, int, int, int, int);
|
||||
texfunc load_table [4][5] = { // [size][format]
|
||||
{ Load4bSelect,
|
||||
LoadNone,
|
||||
Load4bCI,
|
||||
Load4bIA,
|
||||
Load4bI },
|
||||
typedef uint32_t(*texfunc)(uintptr_t, uintptr_t, int, int, int, int, int);
|
||||
texfunc load_table[4][5] = { // [size][format]
|
||||
{ Load4bSelect,
|
||||
LoadNone,
|
||||
Load4bCI,
|
||||
Load4bIA,
|
||||
Load4bI },
|
||||
|
||||
{ Load8bCI,
|
||||
LoadNone,
|
||||
Load8bCI,
|
||||
Load8bIA,
|
||||
Load8bI },
|
||||
{ Load8bCI,
|
||||
LoadNone,
|
||||
Load8bCI,
|
||||
Load8bIA,
|
||||
Load8bI },
|
||||
|
||||
{ Load16bRGBA,
|
||||
Load16bYUV,
|
||||
Load16bRGBA,
|
||||
Load16bIA,
|
||||
LoadNone },
|
||||
{ Load16bRGBA,
|
||||
Load16bYUV,
|
||||
Load16bRGBA,
|
||||
Load16bIA,
|
||||
LoadNone },
|
||||
|
||||
{ Load32bRGBA,
|
||||
LoadNone,
|
||||
LoadNone,
|
||||
LoadNone,
|
||||
LoadNone }
|
||||
{ Load32bRGBA,
|
||||
LoadNone,
|
||||
LoadNone,
|
||||
LoadNone,
|
||||
LoadNone }
|
||||
};
|
||||
|
|
|
@ -43,79 +43,79 @@
|
|||
// Load 32bit RGBA texture
|
||||
// Based on sources of angrylion's software plugin.
|
||||
//
|
||||
uint32_t Load32bRGBA (uintptr_t dst, uintptr_t src, int wid_64, int height, int line, int real_width, int tile)
|
||||
uint32_t Load32bRGBA(uintptr_t dst, uintptr_t src, int wid_64, int height, int line, int real_width, int tile)
|
||||
{
|
||||
if (height < 1) height = 1;
|
||||
const uint16_t *tmem16 = (uint16_t*)rdp.tmem;
|
||||
const uint32_t tbase = (src - (uintptr_t)rdp.tmem) >> 1;
|
||||
const uint32_t width = maxval(1, wid_64 << 1);
|
||||
const int ext = real_width - width;
|
||||
line = width + (line>>2);
|
||||
uint32_t s, t, c;
|
||||
uint32_t * tex = (uint32_t*)dst;
|
||||
uint16_t rg, ba;
|
||||
for (t = 0; t < (uint32_t)height; t++)
|
||||
{
|
||||
uint32_t tline = tbase + line * t;
|
||||
uint32_t xorval = (t & 1) ? 3 : 1;
|
||||
for (s = 0; s < width; s++)
|
||||
if (height < 1) height = 1;
|
||||
const uint16_t *tmem16 = (uint16_t*)rdp.tmem;
|
||||
const uint32_t tbase = (src - (uintptr_t)rdp.tmem) >> 1;
|
||||
const uint32_t width = maxval(1, wid_64 << 1);
|
||||
const int ext = real_width - width;
|
||||
line = width + (line >> 2);
|
||||
uint32_t s, t, c;
|
||||
uint32_t * tex = (uint32_t*)dst;
|
||||
uint16_t rg, ba;
|
||||
for (t = 0; t < (uint32_t)height; t++)
|
||||
{
|
||||
uint32_t taddr = ((tline + s) ^ xorval) & 0x3ff;
|
||||
rg = tmem16[taddr];
|
||||
ba = tmem16[taddr|0x400];
|
||||
c = ((ba&0xFF)<<24) | (rg << 8) | (ba>>8);
|
||||
*tex++ = c;
|
||||
uint32_t tline = tbase + line * t;
|
||||
uint32_t xorval = (t & 1) ? 3 : 1;
|
||||
for (s = 0; s < width; s++)
|
||||
{
|
||||
uint32_t taddr = ((tline + s) ^ xorval) & 0x3ff;
|
||||
rg = tmem16[taddr];
|
||||
ba = tmem16[taddr | 0x400];
|
||||
c = ((ba & 0xFF) << 24) | (rg << 8) | (ba >> 8);
|
||||
*tex++ = c;
|
||||
}
|
||||
tex += ext;
|
||||
}
|
||||
tex += ext;
|
||||
}
|
||||
int id = tile - rdp.cur_tile;
|
||||
uint32_t mod = (id == 0) ? cmb.mod_0 : cmb.mod_1;
|
||||
if (mod || !voodoo.sup_32bit_tex)
|
||||
{
|
||||
//convert to ARGB_4444
|
||||
const uint32_t tex_size = real_width * height;
|
||||
tex = (uint32_t *)dst;
|
||||
uint16_t *tex16 = (uint16_t*)dst;
|
||||
uint16_t a, r, g, b;
|
||||
for (uint32_t i = 0; i < tex_size; i++) {
|
||||
c = tex[i];
|
||||
a = (c >> 28) & 0xF;
|
||||
r = (c >> 20) & 0xF;
|
||||
g = (c >> 12) & 0xF;
|
||||
b = (c >> 4) & 0xF;
|
||||
tex16[i] = (a <<12) | (r << 8) | (g << 4) | b;
|
||||
int id = tile - rdp.cur_tile;
|
||||
uint32_t mod = (id == 0) ? cmb.mod_0 : cmb.mod_1;
|
||||
if (mod || !voodoo.sup_32bit_tex)
|
||||
{
|
||||
//convert to ARGB_4444
|
||||
const uint32_t tex_size = real_width * height;
|
||||
tex = (uint32_t *)dst;
|
||||
uint16_t *tex16 = (uint16_t*)dst;
|
||||
uint16_t a, r, g, b;
|
||||
for (uint32_t i = 0; i < tex_size; i++) {
|
||||
c = tex[i];
|
||||
a = (c >> 28) & 0xF;
|
||||
r = (c >> 20) & 0xF;
|
||||
g = (c >> 12) & 0xF;
|
||||
b = (c >> 4) & 0xF;
|
||||
tex16[i] = (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
return (1 << 16) | GR_TEXFMT_ARGB_4444;
|
||||
}
|
||||
return (1 << 16) | GR_TEXFMT_ARGB_4444;
|
||||
}
|
||||
return (2 << 16) | GR_TEXFMT_ARGB_8888;
|
||||
return (2 << 16) | GR_TEXFMT_ARGB_8888;
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// LoadTile for 32bit RGBA texture
|
||||
// Based on sources of angrylion's software plugin.
|
||||
//
|
||||
void LoadTile32b (uint32_t tile, uint32_t ul_s, uint32_t ul_t, uint32_t width, uint32_t height)
|
||||
void LoadTile32b(uint32_t tile, uint32_t ul_s, uint32_t ul_t, uint32_t width, uint32_t height)
|
||||
{
|
||||
const uint32_t line = rdp.tiles[tile].line << 2;
|
||||
const uint32_t tbase = rdp.tiles[tile].t_mem << 2;
|
||||
const uint32_t addr = rdp.timg.addr >> 2;
|
||||
const uint32_t* src = (const uint32_t*)gfx.RDRAM;
|
||||
uint16_t *tmem16 = (uint16_t*)rdp.tmem;
|
||||
uint32_t c, ptr, tline, s, xorval;
|
||||
const uint32_t line = rdp.tiles[tile].line << 2;
|
||||
const uint32_t tbase = rdp.tiles[tile].t_mem << 2;
|
||||
const uint32_t addr = rdp.timg.addr >> 2;
|
||||
const uint32_t* src = (const uint32_t*)gfx.RDRAM;
|
||||
uint16_t *tmem16 = (uint16_t*)rdp.tmem;
|
||||
uint32_t c, ptr, tline, s, xorval;
|
||||
|
||||
for (uint32_t j = 0; j < height; j++)
|
||||
{
|
||||
tline = tbase + line * j;
|
||||
s = ((j + ul_t) * rdp.timg.width) + ul_s;
|
||||
xorval = (j & 1) ? 3 : 1;
|
||||
for (uint32_t i = 0; i < width; i++)
|
||||
for (uint32_t j = 0; j < height; j++)
|
||||
{
|
||||
c = src[addr + s + i];
|
||||
ptr = ((tline + i) ^ xorval) & 0x3ff;
|
||||
tmem16[ptr] = c >> 16;
|
||||
tmem16[ptr|0x400] = c & 0xffff;
|
||||
tline = tbase + line * j;
|
||||
s = ((j + ul_t) * rdp.timg.width) + ul_s;
|
||||
xorval = (j & 1) ? 3 : 1;
|
||||
for (uint32_t i = 0; i < width; i++)
|
||||
{
|
||||
c = src[addr + s + i];
|
||||
ptr = ((tline + i) ^ xorval) & 0x3ff;
|
||||
tmem16[ptr] = c >> 16;
|
||||
tmem16[ptr | 0x400] = c & 0xffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
|
@ -124,54 +124,54 @@ void LoadTile32b (uint32_t tile, uint32_t ul_s, uint32_t ul_t, uint32_t width, u
|
|||
//
|
||||
void LoadBlock32b(uint32_t tile, uint32_t ul_s, uint32_t ul_t, uint32_t lr_s, uint32_t dxt)
|
||||
{
|
||||
const uint32_t * src = (const uint32_t*)gfx.RDRAM;
|
||||
const uint32_t tb = rdp.tiles[tile].t_mem << 2;
|
||||
const uint32_t tiwindwords = rdp.timg.width;
|
||||
const uint32_t slindwords = ul_s;
|
||||
const uint32_t line = rdp.tiles[tile].line << 2;
|
||||
const uint32_t * src = (const uint32_t*)gfx.RDRAM;
|
||||
const uint32_t tb = rdp.tiles[tile].t_mem << 2;
|
||||
const uint32_t tiwindwords = rdp.timg.width;
|
||||
const uint32_t slindwords = ul_s;
|
||||
const uint32_t line = rdp.tiles[tile].line << 2;
|
||||
|
||||
uint16_t *tmem16 = (uint16_t*)rdp.tmem;
|
||||
uint32_t addr = rdp.timg.addr >> 2;
|
||||
uint32_t width = (lr_s - ul_s + 1) << 2;
|
||||
if (width & 7)
|
||||
width = (width & (~7)) + 8;
|
||||
uint16_t *tmem16 = (uint16_t*)rdp.tmem;
|
||||
uint32_t addr = rdp.timg.addr >> 2;
|
||||
uint32_t width = (lr_s - ul_s + 1) << 2;
|
||||
if (width & 7)
|
||||
width = (width & (~7)) + 8;
|
||||
|
||||
if (dxt != 0)
|
||||
{
|
||||
uint32_t j= 0;
|
||||
uint32_t t = 0;
|
||||
uint32_t oldt = 0;
|
||||
uint32_t ptr;
|
||||
|
||||
addr += (ul_t * tiwindwords) + slindwords;
|
||||
uint32_t c = 0;
|
||||
for (uint32_t i = 0; i < width; i += 2)
|
||||
if (dxt != 0)
|
||||
{
|
||||
oldt = t;
|
||||
t = ((j >> 11) & 1) ? 3 : 1;
|
||||
if (t != oldt)
|
||||
i += line;
|
||||
ptr = ((tb + i) ^ t) & 0x3ff;
|
||||
c = src[addr + i];
|
||||
tmem16[ptr] = c >> 16;
|
||||
tmem16[ptr|0x400] = c & 0xffff;
|
||||
ptr = ((tb+ i + 1) ^ t) & 0x3ff;
|
||||
c = src[addr + i + 1];
|
||||
tmem16[ptr] = c >> 16;
|
||||
tmem16[ptr|0x400] = c & 0xffff;
|
||||
j += dxt;
|
||||
uint32_t j = 0;
|
||||
uint32_t t = 0;
|
||||
uint32_t oldt = 0;
|
||||
uint32_t ptr;
|
||||
|
||||
addr += (ul_t * tiwindwords) + slindwords;
|
||||
uint32_t c = 0;
|
||||
for (uint32_t i = 0; i < width; i += 2)
|
||||
{
|
||||
oldt = t;
|
||||
t = ((j >> 11) & 1) ? 3 : 1;
|
||||
if (t != oldt)
|
||||
i += line;
|
||||
ptr = ((tb + i) ^ t) & 0x3ff;
|
||||
c = src[addr + i];
|
||||
tmem16[ptr] = c >> 16;
|
||||
tmem16[ptr | 0x400] = c & 0xffff;
|
||||
ptr = ((tb + i + 1) ^ t) & 0x3ff;
|
||||
c = src[addr + i + 1];
|
||||
tmem16[ptr] = c >> 16;
|
||||
tmem16[ptr | 0x400] = c & 0xffff;
|
||||
j += dxt;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
addr += (ul_t * tiwindwords) + slindwords;
|
||||
uint32_t c, ptr;
|
||||
for (uint32_t i = 0; i < width; i ++)
|
||||
else
|
||||
{
|
||||
ptr = ((tb + i) ^ 1) & 0x3ff;
|
||||
c = src[addr + i];
|
||||
tmem16[ptr] = c >> 16;
|
||||
tmem16[ptr|0x400] = c & 0xffff;
|
||||
addr += (ul_t * tiwindwords) + slindwords;
|
||||
uint32_t c, ptr;
|
||||
for (uint32_t i = 0; i < width; i++)
|
||||
{
|
||||
ptr = ((tb + i) ^ 1) & 0x3ff;
|
||||
c = src[addr + i];
|
||||
tmem16[ptr] = c >> 16;
|
||||
tmem16[ptr | 0x400] = c & 0xffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -39,392 +39,380 @@
|
|||
|
||||
static inline void load8bCI(uint8_t *src, uint8_t *dst, int wid_64, int height, int line, int ext, uint16_t *pal)
|
||||
{
|
||||
uint8_t *v7;
|
||||
uint32_t *v8;
|
||||
int v9;
|
||||
int v10;
|
||||
int v11;
|
||||
uint32_t v12;
|
||||
uint32_t *v13;
|
||||
uint32_t v14;
|
||||
uint32_t *v15;
|
||||
uint32_t v16;
|
||||
uint32_t *v17;
|
||||
uint32_t *v18;
|
||||
int v19;
|
||||
int v20;
|
||||
uint32_t v21;
|
||||
uint32_t v22;
|
||||
uint32_t *v23;
|
||||
uint32_t v24;
|
||||
int v25;
|
||||
int v26;
|
||||
uint8_t *v7;
|
||||
uint32_t *v8;
|
||||
int v9;
|
||||
int v10;
|
||||
int v11;
|
||||
uint32_t v12;
|
||||
uint32_t *v13;
|
||||
uint32_t v14;
|
||||
uint32_t *v15;
|
||||
uint32_t v16;
|
||||
uint32_t *v17;
|
||||
uint32_t *v18;
|
||||
int v19;
|
||||
int v20;
|
||||
uint32_t v21;
|
||||
uint32_t v22;
|
||||
uint32_t *v23;
|
||||
uint32_t v24;
|
||||
int v25;
|
||||
int v26;
|
||||
|
||||
v7 = src;
|
||||
v8 = (uint32_t *)dst;
|
||||
v9 = height;
|
||||
do
|
||||
{
|
||||
v25 = v9;
|
||||
v10 = wid_64;
|
||||
v7 = src;
|
||||
v8 = (uint32_t *)dst;
|
||||
v9 = height;
|
||||
do
|
||||
{
|
||||
v11 = v10;
|
||||
v12 = bswap32(*(uint32_t *)v7);
|
||||
v13 = (uint32_t *)(v7 + 4);
|
||||
ALOWORD(v10) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 15) & 0x1FE)), 1);
|
||||
v14 = v10 << 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 23) & 0x1FE)), 1);
|
||||
*v8 = v14;
|
||||
v15 = v8 + 1;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v12 & 0x1FE)), 1);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 7) & 0x1FE)), 1);
|
||||
*v15 = v14;
|
||||
++v15;
|
||||
v16 = bswap32(*v13);
|
||||
v7 = (uint8_t *)(v13 + 1);
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 15) & 0x1FE)), 1);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 23) & 0x1FE)), 1);
|
||||
*v15 = v14;
|
||||
++v15;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v16 & 0x1FE)), 1);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 7) & 0x1FE)), 1);
|
||||
*v15 = v14;
|
||||
v8 = v15 + 1;
|
||||
v10 = v11 - 1;
|
||||
}
|
||||
while ( v11 != 1 );
|
||||
if ( v25 == 1 )
|
||||
break;
|
||||
v26 = v25 - 1;
|
||||
v17 = (uint32_t *)&src[(line + (uintptr_t)v7 - (uintptr_t)src) & 0x7FF];
|
||||
v18 = (uint32_t *)((char *)v8 + ext);
|
||||
v19 = wid_64;
|
||||
do
|
||||
{
|
||||
v20 = v19;
|
||||
v21 = bswap32(v17[1]);
|
||||
ALOWORD(v19) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 15) & 0x1FE)), 1);
|
||||
v22 = v19 << 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 23) & 0x1FE)), 1);
|
||||
*v18 = v22;
|
||||
v23 = v18 + 1;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v21 & 0x1FE)), 1);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 7) & 0x1FE)), 1);
|
||||
*v23 = v22;
|
||||
++v23;
|
||||
v24 = bswap32(*v17);
|
||||
v17 = (uint32_t *)&src[((uintptr_t)v17 + 8 - (uintptr_t)src) & 0x7FF];
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 15) & 0x1FE)), 1);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 23) & 0x1FE)), 1);
|
||||
*v23 = v22;
|
||||
++v23;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v24 & 0x1FE)), 1);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 7) & 0x1FE)), 1);
|
||||
*v23 = v22;
|
||||
v18 = v23 + 1;
|
||||
v19 = v20 - 1;
|
||||
}
|
||||
while ( v20 != 1 );
|
||||
v7 = &src[(line + (uintptr_t)v17 - (uintptr_t)src) & 0x7FF];
|
||||
v8 = (uint32_t *)((char *)v18 + ext);
|
||||
v9 = v26 - 1;
|
||||
}
|
||||
while ( v26 != 1 );
|
||||
v25 = v9;
|
||||
v10 = wid_64;
|
||||
do
|
||||
{
|
||||
v11 = v10;
|
||||
v12 = bswap32(*(uint32_t *)v7);
|
||||
v13 = (uint32_t *)(v7 + 4);
|
||||
ALOWORD(v10) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 15) & 0x1FE)), 1);
|
||||
v14 = v10 << 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 23) & 0x1FE)), 1);
|
||||
*v8 = v14;
|
||||
v15 = v8 + 1;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v12 & 0x1FE)), 1);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 7) & 0x1FE)), 1);
|
||||
*v15 = v14;
|
||||
++v15;
|
||||
v16 = bswap32(*v13);
|
||||
v7 = (uint8_t *)(v13 + 1);
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 15) & 0x1FE)), 1);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 23) & 0x1FE)), 1);
|
||||
*v15 = v14;
|
||||
++v15;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v16 & 0x1FE)), 1);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 7) & 0x1FE)), 1);
|
||||
*v15 = v14;
|
||||
v8 = v15 + 1;
|
||||
v10 = v11 - 1;
|
||||
} while (v11 != 1);
|
||||
if (v25 == 1)
|
||||
break;
|
||||
v26 = v25 - 1;
|
||||
v17 = (uint32_t *)&src[(line + (uintptr_t)v7 - (uintptr_t)src) & 0x7FF];
|
||||
v18 = (uint32_t *)((char *)v8 + ext);
|
||||
v19 = wid_64;
|
||||
do
|
||||
{
|
||||
v20 = v19;
|
||||
v21 = bswap32(v17[1]);
|
||||
ALOWORD(v19) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 15) & 0x1FE)), 1);
|
||||
v22 = v19 << 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 23) & 0x1FE)), 1);
|
||||
*v18 = v22;
|
||||
v23 = v18 + 1;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v21 & 0x1FE)), 1);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 7) & 0x1FE)), 1);
|
||||
*v23 = v22;
|
||||
++v23;
|
||||
v24 = bswap32(*v17);
|
||||
v17 = (uint32_t *)&src[((uintptr_t)v17 + 8 - (uintptr_t)src) & 0x7FF];
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 15) & 0x1FE)), 1);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 23) & 0x1FE)), 1);
|
||||
*v23 = v22;
|
||||
++v23;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v24 & 0x1FE)), 1);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 7) & 0x1FE)), 1);
|
||||
*v23 = v22;
|
||||
v18 = v23 + 1;
|
||||
v19 = v20 - 1;
|
||||
} while (v20 != 1);
|
||||
v7 = &src[(line + (uintptr_t)v17 - (uintptr_t)src) & 0x7FF];
|
||||
v8 = (uint32_t *)((char *)v18 + ext);
|
||||
v9 = v26 - 1;
|
||||
} while (v26 != 1);
|
||||
}
|
||||
|
||||
static inline void load8bIA8(uint8_t *src, uint8_t *dst, int wid_64, int height, int line, int ext, uint16_t *pal)
|
||||
{
|
||||
uint32_t *v7;
|
||||
uint32_t *v8;
|
||||
int v9;
|
||||
int v10;
|
||||
int v11;
|
||||
uint32_t v12;
|
||||
uint32_t *v13;
|
||||
uint32_t v14;
|
||||
uint32_t *v15;
|
||||
uint32_t v16;
|
||||
uint32_t *v17;
|
||||
uint32_t *v18;
|
||||
int v19;
|
||||
int v20;
|
||||
uint32_t v21;
|
||||
uint32_t v22;
|
||||
uint32_t *v23;
|
||||
uint32_t v24;
|
||||
int v25;
|
||||
int v26;
|
||||
uint32_t *v7;
|
||||
uint32_t *v8;
|
||||
int v9;
|
||||
int v10;
|
||||
int v11;
|
||||
uint32_t v12;
|
||||
uint32_t *v13;
|
||||
uint32_t v14;
|
||||
uint32_t *v15;
|
||||
uint32_t v16;
|
||||
uint32_t *v17;
|
||||
uint32_t *v18;
|
||||
int v19;
|
||||
int v20;
|
||||
uint32_t v21;
|
||||
uint32_t v22;
|
||||
uint32_t *v23;
|
||||
uint32_t v24;
|
||||
int v25;
|
||||
int v26;
|
||||
|
||||
v7 = (uint32_t *)src;
|
||||
v8 = (uint32_t *)dst;
|
||||
v9 = height;
|
||||
do
|
||||
{
|
||||
v25 = v9;
|
||||
v10 = wid_64;
|
||||
v7 = (uint32_t *)src;
|
||||
v8 = (uint32_t *)dst;
|
||||
v9 = height;
|
||||
do
|
||||
{
|
||||
v11 = v10;
|
||||
v12 = bswap32(*v7);
|
||||
v13 = v7 + 1;
|
||||
ALOWORD(v10) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 15) & 0x1FE)), 8);
|
||||
v14 = v10 << 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 23) & 0x1FE)), 8);
|
||||
*v8 = v14;
|
||||
v15 = v8 + 1;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v12 & 0x1FE)), 8);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 7) & 0x1FE)), 8);
|
||||
*v15 = v14;
|
||||
++v15;
|
||||
v16 = bswap32(*v13);
|
||||
v7 = v13 + 1;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 15) & 0x1FE)), 8);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 23) & 0x1FE)), 8);
|
||||
*v15 = v14;
|
||||
++v15;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v16 & 0x1FE)), 8);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 7) & 0x1FE)), 8);
|
||||
*v15 = v14;
|
||||
v8 = v15 + 1;
|
||||
v10 = v11 - 1;
|
||||
}
|
||||
while ( v11 != 1 );
|
||||
if ( v25 == 1 )
|
||||
break;
|
||||
v26 = v25 - 1;
|
||||
v17 = (uint32_t *)((char *)v7 + line);
|
||||
v18 = (uint32_t *)((char *)v8 + ext);
|
||||
v19 = wid_64;
|
||||
do
|
||||
{
|
||||
v20 = v19;
|
||||
v21 = bswap32(v17[1]);
|
||||
ALOWORD(v19) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 15) & 0x1FE)), 8);
|
||||
v22 = v19 << 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 23) & 0x1FE)), 8);
|
||||
*v18 = v22;
|
||||
v23 = v18 + 1;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v21 & 0x1FE)), 8);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 7) & 0x1FE)), 8);
|
||||
*v23 = v22;
|
||||
++v23;
|
||||
v24 = bswap32(*v17);
|
||||
v17 += 2;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 15) & 0x1FE)), 8);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 23) & 0x1FE)), 8);
|
||||
*v23 = v22;
|
||||
++v23;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v24 & 0x1FE)), 8);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 7) & 0x1FE)), 8);
|
||||
*v23 = v22;
|
||||
v18 = v23 + 1;
|
||||
v19 = v20 - 1;
|
||||
}
|
||||
while ( v20 != 1 );
|
||||
v7 = (uint32_t *)((char *)v17 + line);
|
||||
v8 = (uint32_t *)((char *)v18 + ext);
|
||||
v9 = v26 - 1;
|
||||
}
|
||||
while ( v26 != 1 );
|
||||
v25 = v9;
|
||||
v10 = wid_64;
|
||||
do
|
||||
{
|
||||
v11 = v10;
|
||||
v12 = bswap32(*v7);
|
||||
v13 = v7 + 1;
|
||||
ALOWORD(v10) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 15) & 0x1FE)), 8);
|
||||
v14 = v10 << 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 23) & 0x1FE)), 8);
|
||||
*v8 = v14;
|
||||
v15 = v8 + 1;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v12 & 0x1FE)), 8);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v12 >> 7) & 0x1FE)), 8);
|
||||
*v15 = v14;
|
||||
++v15;
|
||||
v16 = bswap32(*v13);
|
||||
v7 = v13 + 1;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 15) & 0x1FE)), 8);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 23) & 0x1FE)), 8);
|
||||
*v15 = v14;
|
||||
++v15;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v16 & 0x1FE)), 8);
|
||||
v14 <<= 16;
|
||||
ALOWORD(v14) = __ROR__(*(uint16_t *)((char *)pal + ((v16 >> 7) & 0x1FE)), 8);
|
||||
*v15 = v14;
|
||||
v8 = v15 + 1;
|
||||
v10 = v11 - 1;
|
||||
} while (v11 != 1);
|
||||
if (v25 == 1)
|
||||
break;
|
||||
v26 = v25 - 1;
|
||||
v17 = (uint32_t *)((char *)v7 + line);
|
||||
v18 = (uint32_t *)((char *)v8 + ext);
|
||||
v19 = wid_64;
|
||||
do
|
||||
{
|
||||
v20 = v19;
|
||||
v21 = bswap32(v17[1]);
|
||||
ALOWORD(v19) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 15) & 0x1FE)), 8);
|
||||
v22 = v19 << 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 23) & 0x1FE)), 8);
|
||||
*v18 = v22;
|
||||
v23 = v18 + 1;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v21 & 0x1FE)), 8);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v21 >> 7) & 0x1FE)), 8);
|
||||
*v23 = v22;
|
||||
++v23;
|
||||
v24 = bswap32(*v17);
|
||||
v17 += 2;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 15) & 0x1FE)), 8);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 23) & 0x1FE)), 8);
|
||||
*v23 = v22;
|
||||
++v23;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + (2 * (uint16_t)v24 & 0x1FE)), 8);
|
||||
v22 <<= 16;
|
||||
ALOWORD(v22) = __ROR__(*(uint16_t *)((char *)pal + ((v24 >> 7) & 0x1FE)), 8);
|
||||
*v23 = v22;
|
||||
v18 = v23 + 1;
|
||||
v19 = v20 - 1;
|
||||
} while (v20 != 1);
|
||||
v7 = (uint32_t *)((char *)v17 + line);
|
||||
v8 = (uint32_t *)((char *)v18 + ext);
|
||||
v9 = v26 - 1;
|
||||
} while (v26 != 1);
|
||||
}
|
||||
|
||||
static inline void load8bIA4(uint8_t *src, uint8_t *dst, int wid_64, int height, int line, int ext)
|
||||
{
|
||||
uint32_t *v6;
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
int v9;
|
||||
uint32_t v10;
|
||||
uint32_t v11;
|
||||
uint32_t *v12;
|
||||
uint32_t *v13;
|
||||
uint32_t v14;
|
||||
uint32_t v15;
|
||||
uint32_t *v16;
|
||||
uint32_t *v17;
|
||||
int v18;
|
||||
uint32_t *v19;
|
||||
uint32_t v20;
|
||||
int v21;
|
||||
int v22;
|
||||
uint32_t *v6;
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
int v9;
|
||||
uint32_t v10;
|
||||
uint32_t v11;
|
||||
uint32_t *v12;
|
||||
uint32_t *v13;
|
||||
uint32_t v14;
|
||||
uint32_t v15;
|
||||
uint32_t *v16;
|
||||
uint32_t *v17;
|
||||
int v18;
|
||||
uint32_t *v19;
|
||||
uint32_t v20;
|
||||
int v21;
|
||||
int v22;
|
||||
|
||||
v6 = (uint32_t *)src;
|
||||
v7 = (uint32_t *)dst;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v21 = v8;
|
||||
v9 = wid_64;
|
||||
v6 = (uint32_t *)src;
|
||||
v7 = (uint32_t *)dst;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v10 = *v6;
|
||||
v11 = (*v6 >> 4) & 0xF0F0F0F;
|
||||
v12 = v6 + 1;
|
||||
*v7 = (16 * v10 & 0xF0F0F0F0) | v11;
|
||||
v13 = v7 + 1;
|
||||
v14 = (*v12 >> 4) & 0xF0F0F0F;
|
||||
v15 = 16 * *v12 & 0xF0F0F0F0;
|
||||
v6 = v12 + 1;
|
||||
*v13 = v15 | v14;
|
||||
v7 = v13 + 1;
|
||||
--v9;
|
||||
}
|
||||
while ( v9 );
|
||||
if ( v21 == 1 )
|
||||
break;
|
||||
v22 = v21 - 1;
|
||||
v16 = (uint32_t *)((char *)v6 + line);
|
||||
v17 = (uint32_t *)((char *)v7 + ext);
|
||||
v18 = wid_64;
|
||||
do
|
||||
{
|
||||
*v17 = (16 * v16[1] & 0xF0F0F0F0) | ((v16[1] >> 4) & 0xF0F0F0F);
|
||||
v19 = v17 + 1;
|
||||
v20 = *v16;
|
||||
v16 += 2;
|
||||
*v19 = (16 * v20 & 0xF0F0F0F0) | ((v20 >> 4) & 0xF0F0F0F);
|
||||
v17 = v19 + 1;
|
||||
--v18;
|
||||
}
|
||||
while ( v18 );
|
||||
v6 = (uint32_t *)((char *)v16 + line);
|
||||
v7 = (uint32_t *)((char *)v17 + ext);
|
||||
v8 = v22 - 1;
|
||||
}
|
||||
while ( v22 != 1 );
|
||||
v21 = v8;
|
||||
v9 = wid_64;
|
||||
do
|
||||
{
|
||||
v10 = *v6;
|
||||
v11 = (*v6 >> 4) & 0xF0F0F0F;
|
||||
v12 = v6 + 1;
|
||||
*v7 = (16 * v10 & 0xF0F0F0F0) | v11;
|
||||
v13 = v7 + 1;
|
||||
v14 = (*v12 >> 4) & 0xF0F0F0F;
|
||||
v15 = 16 * *v12 & 0xF0F0F0F0;
|
||||
v6 = v12 + 1;
|
||||
*v13 = v15 | v14;
|
||||
v7 = v13 + 1;
|
||||
--v9;
|
||||
} while (v9);
|
||||
if (v21 == 1)
|
||||
break;
|
||||
v22 = v21 - 1;
|
||||
v16 = (uint32_t *)((char *)v6 + line);
|
||||
v17 = (uint32_t *)((char *)v7 + ext);
|
||||
v18 = wid_64;
|
||||
do
|
||||
{
|
||||
*v17 = (16 * v16[1] & 0xF0F0F0F0) | ((v16[1] >> 4) & 0xF0F0F0F);
|
||||
v19 = v17 + 1;
|
||||
v20 = *v16;
|
||||
v16 += 2;
|
||||
*v19 = (16 * v20 & 0xF0F0F0F0) | ((v20 >> 4) & 0xF0F0F0F);
|
||||
v17 = v19 + 1;
|
||||
--v18;
|
||||
} while (v18);
|
||||
v6 = (uint32_t *)((char *)v16 + line);
|
||||
v7 = (uint32_t *)((char *)v17 + ext);
|
||||
v8 = v22 - 1;
|
||||
} while (v22 != 1);
|
||||
}
|
||||
|
||||
static inline void load8bI(uint8_t *src, uint8_t *dst, int wid_64, int height, int line, int ext)
|
||||
{
|
||||
uint32_t *v6;
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
int v9;
|
||||
uint32_t v10;
|
||||
uint32_t *v11;
|
||||
uint32_t *v12;
|
||||
uint32_t v13;
|
||||
uint32_t *v14;
|
||||
uint32_t *v15;
|
||||
int v16;
|
||||
uint32_t *v17;
|
||||
uint32_t v18;
|
||||
int v19;
|
||||
int v20;
|
||||
uint32_t *v6;
|
||||
uint32_t *v7;
|
||||
int v8;
|
||||
int v9;
|
||||
uint32_t v10;
|
||||
uint32_t *v11;
|
||||
uint32_t *v12;
|
||||
uint32_t v13;
|
||||
uint32_t *v14;
|
||||
uint32_t *v15;
|
||||
int v16;
|
||||
uint32_t *v17;
|
||||
uint32_t v18;
|
||||
int v19;
|
||||
int v20;
|
||||
|
||||
v6 = (uint32_t *)src;
|
||||
v7 = (uint32_t *)dst;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v19 = v8;
|
||||
v9 = wid_64;
|
||||
v6 = (uint32_t *)src;
|
||||
v7 = (uint32_t *)dst;
|
||||
v8 = height;
|
||||
do
|
||||
{
|
||||
v10 = *v6;
|
||||
v11 = v6 + 1;
|
||||
*v7 = v10;
|
||||
v12 = v7 + 1;
|
||||
v13 = *v11;
|
||||
v6 = v11 + 1;
|
||||
*v12 = v13;
|
||||
v7 = v12 + 1;
|
||||
--v9;
|
||||
}
|
||||
while ( v9 );
|
||||
if ( v19 == 1 )
|
||||
break;
|
||||
v20 = v19 - 1;
|
||||
v14 = (uint32_t *)((char *)v6 + line);
|
||||
v15 = (uint32_t *)((char *)v7 + ext);
|
||||
v16 = wid_64;
|
||||
do
|
||||
{
|
||||
*v15 = v14[1];
|
||||
v17 = v15 + 1;
|
||||
v18 = *v14;
|
||||
v14 += 2;
|
||||
*v17 = v18;
|
||||
v15 = v17 + 1;
|
||||
--v16;
|
||||
}
|
||||
while ( v16 );
|
||||
v6 = (uint32_t *)((char *)v14 + line);
|
||||
v7 = (uint32_t *)((char *)v15 + ext);
|
||||
v8 = v20 - 1;
|
||||
}
|
||||
while ( v20 != 1 );
|
||||
v19 = v8;
|
||||
v9 = wid_64;
|
||||
do
|
||||
{
|
||||
v10 = *v6;
|
||||
v11 = v6 + 1;
|
||||
*v7 = v10;
|
||||
v12 = v7 + 1;
|
||||
v13 = *v11;
|
||||
v6 = v11 + 1;
|
||||
*v12 = v13;
|
||||
v7 = v12 + 1;
|
||||
--v9;
|
||||
} while (v9);
|
||||
if (v19 == 1)
|
||||
break;
|
||||
v20 = v19 - 1;
|
||||
v14 = (uint32_t *)((char *)v6 + line);
|
||||
v15 = (uint32_t *)((char *)v7 + ext);
|
||||
v16 = wid_64;
|
||||
do
|
||||
{
|
||||
*v15 = v14[1];
|
||||
v17 = v15 + 1;
|
||||
v18 = *v14;
|
||||
v14 += 2;
|
||||
*v17 = v18;
|
||||
v15 = v17 + 1;
|
||||
--v16;
|
||||
} while (v16);
|
||||
v6 = (uint32_t *)((char *)v14 + line);
|
||||
v7 = (uint32_t *)((char *)v15 + ext);
|
||||
v8 = v20 - 1;
|
||||
} while (v20 != 1);
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// Size: 1, Format: 2
|
||||
//
|
||||
|
||||
uint32_t Load8bCI (uintptr_t dst, uintptr_t src, int wid_64, int height, int line, int real_width, int /*tile*/)
|
||||
uint32_t Load8bCI(uintptr_t dst, uintptr_t src, int wid_64, int height, int line, int real_width, int /*tile*/)
|
||||
{
|
||||
if (wid_64 < 1) wid_64 = 1;
|
||||
if (height < 1) height = 1;
|
||||
int ext = (real_width - (wid_64 << 3));
|
||||
unsigned short * pal = rdp.pal_8;
|
||||
if (wid_64 < 1) wid_64 = 1;
|
||||
if (height < 1) height = 1;
|
||||
int ext = (real_width - (wid_64 << 3));
|
||||
unsigned short * pal = rdp.pal_8;
|
||||
|
||||
switch (rdp.tlut_mode) {
|
||||
switch (rdp.tlut_mode) {
|
||||
case 0: //palette is not used
|
||||
//in tlut DISABLE mode load CI texture as plain intensity texture instead of palette dereference.
|
||||
//Thanks to angrylion for the advice
|
||||
load8bI ((uint8_t *)src, (uint8_t *)dst, wid_64, height, line, ext);
|
||||
return /*(0 << 16) | */GR_TEXFMT_ALPHA_8;
|
||||
//in tlut DISABLE mode load CI texture as plain intensity texture instead of palette dereference.
|
||||
//Thanks to angrylion for the advice
|
||||
load8bI((uint8_t *)src, (uint8_t *)dst, wid_64, height, line, ext);
|
||||
return /*(0 << 16) | */GR_TEXFMT_ALPHA_8;
|
||||
case 2: //color palette
|
||||
ext <<= 1;
|
||||
load8bCI ((uint8_t *)src, (uint8_t *)dst, wid_64, height, line, ext, pal);
|
||||
return (1 << 16) | GR_TEXFMT_ARGB_1555;
|
||||
ext <<= 1;
|
||||
load8bCI((uint8_t *)src, (uint8_t *)dst, wid_64, height, line, ext, pal);
|
||||
return (1 << 16) | GR_TEXFMT_ARGB_1555;
|
||||
default: //IA palette
|
||||
ext <<= 1;
|
||||
load8bIA8 ((uint8_t *)src, (uint8_t *)dst, wid_64, height, line, ext, pal);
|
||||
return (1 << 16) | GR_TEXFMT_ALPHA_INTENSITY_88;
|
||||
}
|
||||
ext <<= 1;
|
||||
load8bIA8((uint8_t *)src, (uint8_t *)dst, wid_64, height, line, ext, pal);
|
||||
return (1 << 16) | GR_TEXFMT_ALPHA_INTENSITY_88;
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// Size: 1, Format: 3
|
||||
//
|
||||
|
||||
uint32_t Load8bIA (uintptr_t dst, uintptr_t src, int wid_64, int height, int line, int real_width, int tile)
|
||||
uint32_t Load8bIA(uintptr_t dst, uintptr_t src, int wid_64, int height, int line, int real_width, int tile)
|
||||
{
|
||||
if (rdp.tlut_mode != 0)
|
||||
return Load8bCI (dst, src, wid_64, height, line, real_width, tile);
|
||||
if (rdp.tlut_mode != 0)
|
||||
return Load8bCI(dst, src, wid_64, height, line, real_width, tile);
|
||||
|
||||
if (wid_64 < 1) wid_64 = 1;
|
||||
if (height < 1) height = 1;
|
||||
int ext = (real_width - (wid_64 << 3));
|
||||
load8bIA4 ((uint8_t *)src, (uint8_t *)dst, wid_64, height, line, ext);
|
||||
return /*(0 << 16) | */GR_TEXFMT_ALPHA_INTENSITY_44;
|
||||
}
|
||||
if (wid_64 < 1) wid_64 = 1;
|
||||
if (height < 1) height = 1;
|
||||
int ext = (real_width - (wid_64 << 3));
|
||||
load8bIA4((uint8_t *)src, (uint8_t *)dst, wid_64, height, line, ext);
|
||||
return /*(0 << 16) | */GR_TEXFMT_ALPHA_INTENSITY_44;
|
||||
}
|
||||
|
||||
//****************************************************************
|
||||
// Size: 1, Format: 4
|
||||
//
|
||||
|
||||
uint32_t Load8bI (uintptr_t dst, uintptr_t src, int wid_64, int height, int line, int real_width, int tile)
|
||||
uint32_t Load8bI(uintptr_t dst, uintptr_t src, int wid_64, int height, int line, int real_width, int tile)
|
||||
{
|
||||
if (rdp.tlut_mode != 0)
|
||||
return Load8bCI (dst, src, wid_64, height, line, real_width, tile);
|
||||
if (rdp.tlut_mode != 0)
|
||||
return Load8bCI(dst, src, wid_64, height, line, real_width, tile);
|
||||
|
||||
if (wid_64 < 1) wid_64 = 1;
|
||||
if (height < 1) height = 1;
|
||||
int ext = (real_width - (wid_64 << 3));
|
||||
load8bI ((uint8_t *)src, (uint8_t *)dst, wid_64, height, line, ext);
|
||||
return /*(0 << 16) | */GR_TEXFMT_ALPHA_8;
|
||||
if (wid_64 < 1) wid_64 = 1;
|
||||
if (height < 1) height = 1;
|
||||
int ext = (real_width - (wid_64 << 3));
|
||||
load8bI((uint8_t *)src, (uint8_t *)dst, wid_64, height, line, ext);
|
||||
return /*(0 << 16) | */GR_TEXFMT_ALPHA_8;
|
||||
}
|
||||
|
|
|
@ -37,541 +37,541 @@
|
|||
//
|
||||
//****************************************************************
|
||||
|
||||
static void mod_tex_inter_color_using_factor (uint16_t *dst, int size, uint32_t color, uint32_t factor)
|
||||
static void mod_tex_inter_color_using_factor(uint16_t *dst, int size, uint32_t color, uint32_t factor)
|
||||
{
|
||||
float percent = factor / 255.0f;
|
||||
float percent_i = 1 - percent;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col, a;
|
||||
uint8_t r, g, b;
|
||||
float percent = factor / 255.0f;
|
||||
float percent_i = 1 - percent;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col, a;
|
||||
uint8_t r, g, b;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
r = (uint8_t)(percent_i * ((col >> 8) & 0xF) + percent * cr);
|
||||
g = (uint8_t)(percent_i * ((col >> 4) & 0xF) + percent * cg);
|
||||
b = (uint8_t)(percent_i * (col & 0xF) + percent * cb);
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
r = (uint8_t)(percent_i * ((col >> 8) & 0xF) + percent * cr);
|
||||
g = (uint8_t)(percent_i * ((col >> 4) & 0xF) + percent * cg);
|
||||
b = (uint8_t)(percent_i * (col & 0xF) + percent * cb);
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_inter_col_using_col1 (uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
static void mod_tex_inter_col_using_col1(uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
{
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col, a;
|
||||
uint8_t r, g, b;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col, a;
|
||||
uint8_t r, g, b;
|
||||
|
||||
float percent_r = ((color1 >> 12) & 0xF) / 15.0f;
|
||||
float percent_g = ((color1 >> 8) & 0xF) / 15.0f;
|
||||
float percent_b = ((color1 >> 4) & 0xF) / 15.0f;
|
||||
float percent_r_i = 1.0f - percent_r;
|
||||
float percent_g_i = 1.0f - percent_g;
|
||||
float percent_b_i = 1.0f - percent_b;
|
||||
float percent_r = ((color1 >> 12) & 0xF) / 15.0f;
|
||||
float percent_g = ((color1 >> 8) & 0xF) / 15.0f;
|
||||
float percent_b = ((color1 >> 4) & 0xF) / 15.0f;
|
||||
float percent_r_i = 1.0f - percent_r;
|
||||
float percent_g_i = 1.0f - percent_g;
|
||||
float percent_b_i = 1.0f - percent_b;
|
||||
|
||||
cr = (color0 >> 12) & 0xF;
|
||||
cg = (color0 >> 8) & 0xF;
|
||||
cb = (color0 >> 4) & 0xF;
|
||||
cr = (color0 >> 12) & 0xF;
|
||||
cg = (color0 >> 8) & 0xF;
|
||||
cb = (color0 >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
r = (uint8_t)(percent_r_i * ((col >> 8) & 0xF) + percent_r * cr);
|
||||
g = (uint8_t)(percent_g_i * ((col >> 4) & 0xF) + percent_g * cg);
|
||||
b = (uint8_t)(percent_b_i * (col & 0xF) + percent_b * cb);
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
r = (uint8_t)(percent_r_i * ((col >> 8) & 0xF) + percent_r * cr);
|
||||
g = (uint8_t)(percent_g_i * ((col >> 4) & 0xF) + percent_g * cg);
|
||||
b = (uint8_t)(percent_b_i * (col & 0xF) + percent_b * cb);
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_full_color_sub_tex (uint16_t *dst, int size, uint32_t color)
|
||||
static void mod_full_color_sub_tex(uint16_t *dst, int size, uint32_t color)
|
||||
{
|
||||
uint32_t cr, cg, cb, ca;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
uint32_t cr, cg, cb, ca;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
ca = color & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
ca = color & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)(ca - ((col >> 12) & 0xF));
|
||||
r = (uint8_t)(cr - ((col >> 8) & 0xF));
|
||||
g = (uint8_t)(cg - ((col >> 4) & 0xF));
|
||||
b = (uint8_t)(cb - (col & 0xF));
|
||||
*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)(ca - ((col >> 12) & 0xF));
|
||||
r = (uint8_t)(cr - ((col >> 8) & 0xF));
|
||||
g = (uint8_t)(cg - ((col >> 4) & 0xF));
|
||||
b = (uint8_t)(cb - (col & 0xF));
|
||||
*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_col_inter_col1_using_tex (uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
static void mod_col_inter_col1_using_tex(uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
{
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent_r, percent_g, percent_b;
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent_r, percent_g, percent_b;
|
||||
|
||||
cr0 = (color0 >> 12) & 0xF;
|
||||
cg0 = (color0 >> 8) & 0xF;
|
||||
cb0 = (color0 >> 4) & 0xF;
|
||||
cr1 = (color1 >> 12) & 0xF;
|
||||
cg1 = (color1 >> 8) & 0xF;
|
||||
cb1 = (color1 >> 4) & 0xF;
|
||||
cr0 = (color0 >> 12) & 0xF;
|
||||
cg0 = (color0 >> 8) & 0xF;
|
||||
cb0 = (color0 >> 4) & 0xF;
|
||||
cr1 = (color1 >> 12) & 0xF;
|
||||
cg1 = (color1 >> 8) & 0xF;
|
||||
cb1 = (color1 >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent_r = ((col >> 8) & 0xF) / 15.0f;
|
||||
percent_g = ((col >> 4) & 0xF) / 15.0f;
|
||||
percent_b = (col & 0xF) / 15.0f;
|
||||
r = minval(15, (uint8_t)((1.0f-percent_r) * cr0 + percent_r * cr1 + 0.0001f));
|
||||
g = minval(15, (uint8_t)((1.0f-percent_g) * cg0 + percent_g * cg1 + 0.0001f));
|
||||
b = minval(15, (uint8_t)((1.0f-percent_b) * cb0 + percent_b * cb1 + 0.0001f));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent_r = ((col >> 8) & 0xF) / 15.0f;
|
||||
percent_g = ((col >> 4) & 0xF) / 15.0f;
|
||||
percent_b = (col & 0xF) / 15.0f;
|
||||
r = minval(15, (uint8_t)((1.0f - percent_r) * cr0 + percent_r * cr1 + 0.0001f));
|
||||
g = minval(15, (uint8_t)((1.0f - percent_g) * cg0 + percent_g * cg1 + 0.0001f));
|
||||
b = minval(15, (uint8_t)((1.0f - percent_b) * cb0 + percent_b * cb1 + 0.0001f));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_col_inter_col1_using_texa (uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
static void mod_col_inter_col1_using_texa(uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
{
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent, percent_i;
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent, percent_i;
|
||||
|
||||
cr0 = (color0 >> 12) & 0xF;
|
||||
cg0 = (color0 >> 8) & 0xF;
|
||||
cb0 = (color0 >> 4) & 0xF;
|
||||
cr1 = (color1 >> 12) & 0xF;
|
||||
cg1 = (color1 >> 8) & 0xF;
|
||||
cb1 = (color1 >> 4) & 0xF;
|
||||
cr0 = (color0 >> 12) & 0xF;
|
||||
cg0 = (color0 >> 8) & 0xF;
|
||||
cb0 = (color0 >> 4) & 0xF;
|
||||
cr1 = (color1 >> 12) & 0xF;
|
||||
cg1 = (color1 >> 8) & 0xF;
|
||||
cb1 = (color1 >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent = (a >> 12) / 15.0f;
|
||||
percent_i = 1.0f - percent;
|
||||
r = (uint8_t)(percent_i * cr0 + percent * cr1);
|
||||
g = (uint8_t)(percent_i * cg0 + percent * cg1);
|
||||
b = (uint8_t)(percent_i * cb0 + percent * cb1);
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent = (a >> 12) / 15.0f;
|
||||
percent_i = 1.0f - percent;
|
||||
r = (uint8_t)(percent_i * cr0 + percent * cr1);
|
||||
g = (uint8_t)(percent_i * cg0 + percent * cg1);
|
||||
b = (uint8_t)(percent_i * cb0 + percent * cb1);
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_col_inter_col1_using_texa__mul_tex (uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
static void mod_col_inter_col1_using_texa__mul_tex(uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
{
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent, percent_i;
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent, percent_i;
|
||||
|
||||
cr0 = (color0 >> 12) & 0xF;
|
||||
cg0 = (color0 >> 8) & 0xF;
|
||||
cb0 = (color0 >> 4) & 0xF;
|
||||
cr1 = (color1 >> 12) & 0xF;
|
||||
cg1 = (color1 >> 8) & 0xF;
|
||||
cb1 = (color1 >> 4) & 0xF;
|
||||
cr0 = (color0 >> 12) & 0xF;
|
||||
cg0 = (color0 >> 8) & 0xF;
|
||||
cb0 = (color0 >> 4) & 0xF;
|
||||
cr1 = (color1 >> 12) & 0xF;
|
||||
cg1 = (color1 >> 8) & 0xF;
|
||||
cb1 = (color1 >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent = (a >> 12) / 15.0f;
|
||||
percent_i = 1.0f - percent;
|
||||
r = (uint8_t)(((percent_i * cr0 + percent * cr1) / 15.0f) * (((col & 0x0F00) >> 8) / 15.0f) * 15.0f);
|
||||
g = (uint8_t)(((percent_i * cg0 + percent * cg1) / 15.0f) * (((col & 0x00F0) >> 4) / 15.0f) * 15.0f);
|
||||
b = (uint8_t)(((percent_i * cb0 + percent * cb1) / 15.0f) * ((col & 0x000F) / 15.0f) * 15.0f);
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent = (a >> 12) / 15.0f;
|
||||
percent_i = 1.0f - percent;
|
||||
r = (uint8_t)(((percent_i * cr0 + percent * cr1) / 15.0f) * (((col & 0x0F00) >> 8) / 15.0f) * 15.0f);
|
||||
g = (uint8_t)(((percent_i * cg0 + percent * cg1) / 15.0f) * (((col & 0x00F0) >> 4) / 15.0f) * 15.0f);
|
||||
b = (uint8_t)(((percent_i * cb0 + percent * cb1) / 15.0f) * ((col & 0x000F) / 15.0f) * 15.0f);
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_col_inter_tex_using_tex (uint16_t *dst, int size, uint32_t color)
|
||||
static void mod_col_inter_tex_using_tex(uint16_t *dst, int size, uint32_t color)
|
||||
{
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent_r, percent_g, percent_b;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent_r, percent_g, percent_b;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent_r = ((col >> 8) & 0xF) / 15.0f;
|
||||
percent_g = ((col >> 4) & 0xF) / 15.0f;
|
||||
percent_b = (col & 0xF) / 15.0f;
|
||||
r = (uint8_t)((1.0f-percent_r) * cr + percent_r * ((col & 0x0F00) >> 8));
|
||||
g = (uint8_t)((1.0f-percent_g) * cg + percent_g * ((col & 0x00F0) >> 4));
|
||||
b = (uint8_t)((1.0f-percent_b) * cb + percent_b * (col & 0x000F));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent_r = ((col >> 8) & 0xF) / 15.0f;
|
||||
percent_g = ((col >> 4) & 0xF) / 15.0f;
|
||||
percent_b = (col & 0xF) / 15.0f;
|
||||
r = (uint8_t)((1.0f - percent_r) * cr + percent_r * ((col & 0x0F00) >> 8));
|
||||
g = (uint8_t)((1.0f - percent_g) * cg + percent_g * ((col & 0x00F0) >> 4));
|
||||
b = (uint8_t)((1.0f - percent_b) * cb + percent_b * (col & 0x000F));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_col_inter_tex_using_texa (uint16_t *dst, int size, uint32_t color)
|
||||
static void mod_col_inter_tex_using_texa(uint16_t *dst, int size, uint32_t color)
|
||||
{
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent, percent_i;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent, percent_i;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent = (a >> 12) / 15.0f;
|
||||
percent_i = 1.0f - percent;
|
||||
r = (uint8_t)(percent_i * cr + percent * ((col & 0x0F00) >> 8));
|
||||
g = (uint8_t)(percent_i * cg + percent * ((col & 0x00F0) >> 4));
|
||||
b = (uint8_t)(percent_i * cb + percent * (col & 0x000F));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent = (a >> 12) / 15.0f;
|
||||
percent_i = 1.0f - percent;
|
||||
r = (uint8_t)(percent_i * cr + percent * ((col & 0x0F00) >> 8));
|
||||
g = (uint8_t)(percent_i * cg + percent * ((col & 0x00F0) >> 4));
|
||||
b = (uint8_t)(percent_i * cb + percent * (col & 0x000F));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_col2_inter__col_inter_col1_using_tex__using_texa (uint16_t *dst, int size,
|
||||
uint32_t color0, uint32_t color1,
|
||||
uint32_t color2)
|
||||
static void mod_col2_inter__col_inter_col1_using_tex__using_texa(uint16_t *dst, int size,
|
||||
uint32_t color0, uint32_t color1,
|
||||
uint32_t color2)
|
||||
{
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1, cr2, cg2, cb2;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent_r, percent_g, percent_b, percent_a;
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1, cr2, cg2, cb2;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent_r, percent_g, percent_b, percent_a;
|
||||
|
||||
cr0 = (color0 >> 12) & 0xF;
|
||||
cg0 = (color0 >> 8) & 0xF;
|
||||
cb0 = (color0 >> 4) & 0xF;
|
||||
cr1 = (color1 >> 12) & 0xF;
|
||||
cg1 = (color1 >> 8) & 0xF;
|
||||
cb1 = (color1 >> 4) & 0xF;
|
||||
cr2 = (color2 >> 12) & 0xF;
|
||||
cg2 = (color2 >> 8) & 0xF;
|
||||
cb2 = (color2 >> 4) & 0xF;
|
||||
cr0 = (color0 >> 12) & 0xF;
|
||||
cg0 = (color0 >> 8) & 0xF;
|
||||
cb0 = (color0 >> 4) & 0xF;
|
||||
cr1 = (color1 >> 12) & 0xF;
|
||||
cg1 = (color1 >> 8) & 0xF;
|
||||
cb1 = (color1 >> 4) & 0xF;
|
||||
cr2 = (color2 >> 12) & 0xF;
|
||||
cg2 = (color2 >> 8) & 0xF;
|
||||
cb2 = (color2 >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent_a = (a >> 12) / 15.0f;
|
||||
percent_r = ((col >> 8) & 0xF) / 15.0f;
|
||||
percent_g = ((col >> 4) & 0xF) / 15.0f;
|
||||
percent_b = (col & 0xF) / 15.0f;
|
||||
r = (uint8_t)(((1.0f-percent_r) * cr0 + percent_r * cr1) * percent_a + cr2 * (1.0f-percent_a));
|
||||
g = (uint8_t)(((1.0f-percent_g) * cg0 + percent_g * cg1) * percent_a + cg2 * (1.0f-percent_a));
|
||||
b = (uint8_t)(((1.0f-percent_b) * cb0 + percent_b * cb1) * percent_a + cb2 * (1.0f-percent_a));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent_a = (a >> 12) / 15.0f;
|
||||
percent_r = ((col >> 8) & 0xF) / 15.0f;
|
||||
percent_g = ((col >> 4) & 0xF) / 15.0f;
|
||||
percent_b = (col & 0xF) / 15.0f;
|
||||
r = (uint8_t)(((1.0f - percent_r) * cr0 + percent_r * cr1) * percent_a + cr2 * (1.0f - percent_a));
|
||||
g = (uint8_t)(((1.0f - percent_g) * cg0 + percent_g * cg1) * percent_a + cg2 * (1.0f - percent_a));
|
||||
b = (uint8_t)(((1.0f - percent_b) * cb0 + percent_b * cb1) * percent_a + cb2 * (1.0f - percent_a));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_scale_fac_add_fac (uint16_t *dst, int size, uint32_t factor)
|
||||
static void mod_tex_scale_fac_add_fac(uint16_t *dst, int size, uint32_t factor)
|
||||
{
|
||||
float percent = factor / 255.0f;
|
||||
uint16_t col;
|
||||
uint8_t a;
|
||||
float base_a = (1.0f - percent) * 15.0f;
|
||||
float percent = factor / 255.0f;
|
||||
uint16_t col;
|
||||
uint8_t a;
|
||||
float base_a = (1.0f - percent) * 15.0f;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)(base_a + percent * (col>>12));
|
||||
*(dst++) = (a<<12) | (col & 0x0FFF);
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)(base_a + percent * (col >> 12));
|
||||
*(dst++) = (a << 12) | (col & 0x0FFF);
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_sub_col_mul_fac_add_tex (uint16_t *dst, int size, uint32_t color, uint32_t factor)
|
||||
static void mod_tex_sub_col_mul_fac_add_tex(uint16_t *dst, int size, uint32_t color, uint32_t factor)
|
||||
{
|
||||
float percent = factor / 255.0f;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col, a;
|
||||
float r, g, b;
|
||||
float percent = factor / 255.0f;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col, a;
|
||||
float r, g, b;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
r = (float)((col >> 8) & 0xF);
|
||||
r = /*maxval(*/(r - cr) * percent/*, 0.0f)*/ + r;
|
||||
if (r > 15.0f) r = 15.0f;
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
g = (float)((col >> 4) & 0xF);
|
||||
g = /*maxval(*/(g - cg) * percent/*, 0.0f)*/ + g;
|
||||
if (g > 15.0f) g = 15.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
b = (float)(col & 0xF);
|
||||
b = /*maxval(*/(b - cb) * percent/*, 0.0f)*/ + b;
|
||||
if (b > 15.0f) b = 15.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
for (int i = 0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
r = (float)((col >> 8) & 0xF);
|
||||
r = /*maxval(*/(r - cr) * percent/*, 0.0f)*/ + r;
|
||||
if (r > 15.0f) r = 15.0f;
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
g = (float)((col >> 4) & 0xF);
|
||||
g = /*maxval(*/(g - cg) * percent/*, 0.0f)*/ + g;
|
||||
if (g > 15.0f) g = 15.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
b = (float)(col & 0xF);
|
||||
b = /*maxval(*/(b - cb) * percent/*, 0.0f)*/ + b;
|
||||
if (b > 15.0f) b = 15.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
|
||||
*(dst++) = a | ((uint16_t)r << 8) | ((uint16_t)g << 4) | (uint16_t)b;
|
||||
}
|
||||
*(dst++) = a | ((uint16_t)r << 8) | ((uint16_t)g << 4) | (uint16_t)b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_scale_col_add_col (uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
static void mod_tex_scale_col_add_col(uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
{
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent_r, percent_g, percent_b;
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent_r, percent_g, percent_b;
|
||||
|
||||
cr0 = (color0 >> 12) & 0xF;
|
||||
cg0 = (color0 >> 8) & 0xF;
|
||||
cb0 = (color0 >> 4) & 0xF;
|
||||
cr1 = (color1 >> 12) & 0xF;
|
||||
cg1 = (color1 >> 8) & 0xF;
|
||||
cb1 = (color1 >> 4) & 0xF;
|
||||
cr0 = (color0 >> 12) & 0xF;
|
||||
cg0 = (color0 >> 8) & 0xF;
|
||||
cb0 = (color0 >> 4) & 0xF;
|
||||
cr1 = (color1 >> 12) & 0xF;
|
||||
cg1 = (color1 >> 8) & 0xF;
|
||||
cb1 = (color1 >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent_r = ((col >> 8) & 0xF) / 15.0f;
|
||||
percent_g = ((col >> 4) & 0xF) / 15.0f;
|
||||
percent_b = (col & 0xF) / 15.0f;
|
||||
r = minval(15, (uint8_t)(percent_r * cr0 + cr1 + 0.0001f));
|
||||
g = minval(15, (uint8_t)(percent_g * cg0 + cg1 + 0.0001f));
|
||||
b = minval(15, (uint8_t)(percent_b * cb0 + cb1 + 0.0001f));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent_r = ((col >> 8) & 0xF) / 15.0f;
|
||||
percent_g = ((col >> 4) & 0xF) / 15.0f;
|
||||
percent_b = (col & 0xF) / 15.0f;
|
||||
r = minval(15, (uint8_t)(percent_r * cr0 + cr1 + 0.0001f));
|
||||
g = minval(15, (uint8_t)(percent_g * cg0 + cg1 + 0.0001f));
|
||||
b = minval(15, (uint8_t)(percent_b * cb0 + cb1 + 0.0001f));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_add_col (uint16_t *dst, int size, uint32_t color)
|
||||
static void mod_tex_add_col(uint16_t *dst, int size, uint32_t color)
|
||||
{
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)((col >> 12) & 0xF);
|
||||
// a = col & 0xF000;
|
||||
r = (uint8_t)(cr + ((col >> 8) & 0xF))&0xF;
|
||||
g = (uint8_t)(cg + ((col >> 4) & 0xF))&0xF;
|
||||
b = (uint8_t)(cb + (col & 0xF))&0xF;
|
||||
*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)((col >> 12) & 0xF);
|
||||
// a = col & 0xF000;
|
||||
r = (uint8_t)(cr + ((col >> 8) & 0xF)) & 0xF;
|
||||
g = (uint8_t)(cg + ((col >> 4) & 0xF)) & 0xF;
|
||||
b = (uint8_t)(cb + (col & 0xF)) & 0xF;
|
||||
*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_col_mul_texa_add_tex (uint16_t *dst, int size, uint32_t color)
|
||||
static void mod_col_mul_texa_add_tex(uint16_t *dst, int size, uint32_t color)
|
||||
{
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float factor;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float factor;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
factor = (a >> 12) / 15.0f;
|
||||
r = (uint8_t)(cr*factor + ((col >> 8) & 0xF))&0xF;
|
||||
g = (uint8_t)(cg*factor + ((col >> 4) & 0xF))&0xF;
|
||||
b = (uint8_t)(cb*factor + (col & 0xF))&0xF;
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
factor = (a >> 12) / 15.0f;
|
||||
r = (uint8_t)(cr*factor + ((col >> 8) & 0xF)) & 0xF;
|
||||
g = (uint8_t)(cg*factor + ((col >> 4) & 0xF)) & 0xF;
|
||||
b = (uint8_t)(cb*factor + (col & 0xF)) & 0xF;
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_sub_col (uint16_t *dst, int size, uint32_t color)
|
||||
static void mod_tex_sub_col(uint16_t *dst, int size, uint32_t color)
|
||||
{
|
||||
int cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
int cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)(col & 0xF000);
|
||||
r = (uint8_t)maxval((((col >> 8) & 0xF) - cr), 0);
|
||||
g = (uint8_t)maxval((((col >> 4) & 0xF) - cg), 0);
|
||||
b = (uint8_t)maxval(((col & 0xF) - cb), 0);
|
||||
*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)(col & 0xF000);
|
||||
r = (uint8_t)maxval((((col >> 8) & 0xF) - cr), 0);
|
||||
g = (uint8_t)maxval((((col >> 4) & 0xF) - cg), 0);
|
||||
b = (uint8_t)maxval(((col & 0xF) - cb), 0);
|
||||
*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_sub_col_mul_fac (uint16_t *dst, int size, uint32_t color, uint32_t factor)
|
||||
static void mod_tex_sub_col_mul_fac(uint16_t *dst, int size, uint32_t color, uint32_t factor)
|
||||
{
|
||||
float percent = factor / 255.0f;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col, a;
|
||||
float r, g, b;
|
||||
float percent = factor / 255.0f;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col, a;
|
||||
float r, g, b;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)((col >> 12) & 0xF);
|
||||
r = (float)((col >> 8) & 0xF);
|
||||
r = (r - cr) * percent;
|
||||
if (r > 15.0f) r = 15.0f;
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
g = (float)((col >> 4) & 0xF);
|
||||
g = (g - cg) * percent;
|
||||
if (g > 15.0f) g = 15.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
b = (float)(col & 0xF);
|
||||
b = (b - cb) * percent;
|
||||
if (b > 15.0f) b = 15.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
for (int i = 0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)((col >> 12) & 0xF);
|
||||
r = (float)((col >> 8) & 0xF);
|
||||
r = (r - cr) * percent;
|
||||
if (r > 15.0f) r = 15.0f;
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
g = (float)((col >> 4) & 0xF);
|
||||
g = (g - cg) * percent;
|
||||
if (g > 15.0f) g = 15.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
b = (float)(col & 0xF);
|
||||
b = (b - cb) * percent;
|
||||
if (b > 15.0f) b = 15.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
|
||||
*(dst++) = (a << 12) | ((uint16_t)r << 8) | ((uint16_t)g << 4) | (uint16_t)b;
|
||||
}
|
||||
*(dst++) = (a << 12) | ((uint16_t)r << 8) | ((uint16_t)g << 4) | (uint16_t)b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_col_inter_tex_using_col1 (uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
static void mod_col_inter_tex_using_col1(uint16_t *dst, int size, uint32_t color0, uint32_t color1)
|
||||
{
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col, a;
|
||||
uint8_t r, g, b;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col, a;
|
||||
uint8_t r, g, b;
|
||||
|
||||
float percent_r = ((color1 >> 12) & 0xF) / 15.0f;
|
||||
float percent_g = ((color1 >> 8) & 0xF) / 15.0f;
|
||||
float percent_b = ((color1 >> 4) & 0xF) / 15.0f;
|
||||
float percent_r_i = 1.0f - percent_r;
|
||||
float percent_g_i = 1.0f - percent_g;
|
||||
float percent_b_i = 1.0f - percent_b;
|
||||
float percent_r = ((color1 >> 12) & 0xF) / 15.0f;
|
||||
float percent_g = ((color1 >> 8) & 0xF) / 15.0f;
|
||||
float percent_b = ((color1 >> 4) & 0xF) / 15.0f;
|
||||
float percent_r_i = 1.0f - percent_r;
|
||||
float percent_g_i = 1.0f - percent_g;
|
||||
float percent_b_i = 1.0f - percent_b;
|
||||
|
||||
cr = (color0 >> 12) & 0xF;
|
||||
cg = (color0 >> 8) & 0xF;
|
||||
cb = (color0 >> 4) & 0xF;
|
||||
cr = (color0 >> 12) & 0xF;
|
||||
cg = (color0 >> 8) & 0xF;
|
||||
cb = (color0 >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)((col >> 12) & 0xF);
|
||||
r = (uint8_t)(percent_r * ((col >> 8) & 0xF) + percent_r_i * cr);
|
||||
g = (uint8_t)(percent_g * ((col >> 4) & 0xF) + percent_g_i * cg);
|
||||
b = (uint8_t)(percent_b * (col & 0xF) + percent_b_i * cb);
|
||||
*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = (uint8_t)((col >> 12) & 0xF);
|
||||
r = (uint8_t)(percent_r * ((col >> 8) & 0xF) + percent_r_i * cr);
|
||||
g = (uint8_t)(percent_g * ((col >> 4) & 0xF) + percent_g_i * cg);
|
||||
b = (uint8_t)(percent_b * (col & 0xF) + percent_b_i * cb);
|
||||
*(dst++) = (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_inter_noise_using_col (uint16_t *dst, int size, uint32_t color)
|
||||
static void mod_tex_inter_noise_using_col(uint16_t *dst, int size, uint32_t color)
|
||||
{
|
||||
uint16_t col, a;
|
||||
uint8_t r, g, b, noise;
|
||||
uint16_t col, a;
|
||||
uint8_t r, g, b, noise;
|
||||
|
||||
float percent_r = ((color >> 12) & 0xF) / 15.0f;
|
||||
float percent_g = ((color >> 8) & 0xF) / 15.0f;
|
||||
float percent_b = ((color >> 4) & 0xF) / 15.0f;
|
||||
float percent_r_i = 1.0f - percent_r;
|
||||
float percent_g_i = 1.0f - percent_g;
|
||||
float percent_b_i = 1.0f - percent_b;
|
||||
float percent_r = ((color >> 12) & 0xF) / 15.0f;
|
||||
float percent_g = ((color >> 8) & 0xF) / 15.0f;
|
||||
float percent_b = ((color >> 4) & 0xF) / 15.0f;
|
||||
float percent_r_i = 1.0f - percent_r;
|
||||
float percent_g_i = 1.0f - percent_g;
|
||||
float percent_b_i = 1.0f - percent_b;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
noise = rand()%16;
|
||||
r = (uint8_t)(percent_r_i * ((col >> 8) & 0xF) + percent_r * noise);
|
||||
g = (uint8_t)(percent_g_i * ((col >> 4) & 0xF) + percent_g * noise);
|
||||
b = (uint8_t)(percent_b_i * (col & 0xF) + percent_b * noise);
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
noise = rand() % 16;
|
||||
r = (uint8_t)(percent_r_i * ((col >> 8) & 0xF) + percent_r * noise);
|
||||
g = (uint8_t)(percent_g_i * ((col >> 4) & 0xF) + percent_g * noise);
|
||||
b = (uint8_t)(percent_b_i * (col & 0xF) + percent_b * noise);
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_inter_col_using_texa (uint16_t *dst, int size, uint32_t color)
|
||||
static void mod_tex_inter_col_using_texa(uint16_t *dst, int size, uint32_t color)
|
||||
{
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent, percent_i;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float percent, percent_i;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent = (a >> 12) / 15.0f;
|
||||
percent_i = 1.0f - percent;
|
||||
r = (uint8_t)(percent * cr + percent_i * ((col & 0x0F00) >> 8));
|
||||
g = (uint8_t)(percent * cg + percent_i * ((col & 0x00F0) >> 4));
|
||||
b = (uint8_t)(percent * cb + percent_i * (col & 0x000F));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
percent = (a >> 12) / 15.0f;
|
||||
percent_i = 1.0f - percent;
|
||||
r = (uint8_t)(percent * cr + percent_i * ((col & 0x0F00) >> 8));
|
||||
g = (uint8_t)(percent * cg + percent_i * ((col & 0x00F0) >> 4));
|
||||
b = (uint8_t)(percent * cb + percent_i * (col & 0x000F));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_mul_col (uint16_t *dst, int size, uint32_t color)
|
||||
static void mod_tex_mul_col(uint16_t *dst, int size, uint32_t color)
|
||||
{
|
||||
float cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
float cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t r, g, b;
|
||||
uint16_t a;
|
||||
|
||||
cr = (float)((color >> 12) & 0xF)/16.0f;
|
||||
cg = (float)((color >> 8) & 0xF)/16.0f;
|
||||
cb = (float)((color >> 4) & 0xF)/16.0f;
|
||||
cr = (float)((color >> 12) & 0xF) / 16.0f;
|
||||
cg = (float)((color >> 8) & 0xF) / 16.0f;
|
||||
cb = (float)((color >> 4) & 0xF) / 16.0f;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
r = (uint8_t)(cr * ((col & 0x0F00) >> 8));
|
||||
g = (uint8_t)(cg * ((col & 0x00F0) >> 4));
|
||||
b = (uint8_t)(cb * (col & 0x000F));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
a = col & 0xF000;
|
||||
r = (uint8_t)(cr * ((col & 0x0F00) >> 8));
|
||||
g = (uint8_t)(cg * ((col & 0x00F0) >> 4));
|
||||
b = (uint8_t)(cb * (col & 0x000F));
|
||||
*(dst++) = a | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_scale_fac_add_col (uint16_t *dst, int size, uint32_t color, uint32_t factor)
|
||||
static void mod_tex_scale_fac_add_col(uint16_t *dst, int size, uint32_t color, uint32_t factor)
|
||||
{
|
||||
float percent = factor / 255.0f;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
float r, g, b;
|
||||
float percent = factor / 255.0f;
|
||||
uint32_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
float r, g, b;
|
||||
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
cr = (color >> 12) & 0xF;
|
||||
cg = (color >> 8) & 0xF;
|
||||
cb = (color >> 4) & 0xF;
|
||||
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
r = cr + percent * (float)((col>>8)&0xF);
|
||||
g = cg + percent * (float)((col>>4)&0xF);
|
||||
b = cb + percent * (float)(col&0xF);
|
||||
*(dst++) = (col&0xF000) | ((uint8_t)r << 8) | ((uint8_t)g << 4) | (uint8_t)b;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
col = *dst;
|
||||
r = cr + percent * (float)((col >> 8) & 0xF);
|
||||
g = cg + percent * (float)((col >> 4) & 0xF);
|
||||
b = cb + percent * (float)(col & 0xF);
|
||||
*(dst++) = (col & 0xF000) | ((uint8_t)r << 8) | ((uint8_t)g << 4) | (uint8_t)b;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,401 +37,399 @@
|
|||
//
|
||||
//****************************************************************
|
||||
|
||||
static void mod_tex_inter_color_using_factor_CI (uint32_t color, uint32_t factor)
|
||||
static void mod_tex_inter_color_using_factor_CI(uint32_t color, uint32_t factor)
|
||||
{
|
||||
float percent = factor / 255.0f;
|
||||
float percent_i = 1 - percent;
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
float percent = factor / 255.0f;
|
||||
float percent_i = 1 - percent;
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);;
|
||||
r = (uint8_t)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = (uint8_t)(minval(255, percent_i * r + percent * cr));
|
||||
g = (uint8_t)(minval(255, percent_i * g + percent * cg));
|
||||
b = (uint8_t)(minval(255, percent_i * b + percent * cb));
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);;
|
||||
r = (uint8_t)((float)((col & 0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col & 0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col & 0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = (uint8_t)(minval(255, percent_i * r + percent * cr));
|
||||
g = (uint8_t)(minval(255, percent_i * g + percent * cg));
|
||||
b = (uint8_t)(minval(255, percent_i * b + percent * cb));
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)(r >> 3) << 11) |
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a ) << 0));
|
||||
}
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a) << 0));
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_inter_col_using_col1_CI (uint32_t color0, uint32_t color1)
|
||||
static void mod_tex_inter_col_using_col1_CI(uint32_t color0, uint32_t color1)
|
||||
{
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
float percent_r = ((color1 >> 24) & 0xFF) / 255.0f;
|
||||
float percent_g = ((color1 >> 16) & 0xFF) / 255.0f;
|
||||
float percent_b = ((color1 >> 8) & 0xFF) / 255.0f;
|
||||
float percent_r_i = 1.0f - percent_r;
|
||||
float percent_g_i = 1.0f - percent_g;
|
||||
float percent_b_i = 1.0f - percent_b;
|
||||
float percent_r = ((color1 >> 24) & 0xFF) / 255.0f;
|
||||
float percent_g = ((color1 >> 16) & 0xFF) / 255.0f;
|
||||
float percent_b = ((color1 >> 8) & 0xFF) / 255.0f;
|
||||
float percent_r_i = 1.0f - percent_r;
|
||||
float percent_g_i = 1.0f - percent_g;
|
||||
float percent_b_i = 1.0f - percent_b;
|
||||
|
||||
cr = (uint8_t)((color0 >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color0 >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color0 >> 8) & 0xFF);
|
||||
cr = (uint8_t)((color0 >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color0 >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color0 >> 8) & 0xFF);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);;
|
||||
r = (uint8_t)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = (uint8_t)(minval(255, percent_r_i * r + percent_r * cr));
|
||||
g = (uint8_t)(minval(255, percent_g_i * g + percent_g * cg));
|
||||
b = (uint8_t)(minval(255, percent_b_i * b + percent_b * cb));
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);;
|
||||
r = (uint8_t)((float)((col & 0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col & 0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col & 0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = (uint8_t)(minval(255, percent_r_i * r + percent_r * cr));
|
||||
g = (uint8_t)(minval(255, percent_g_i * g + percent_g * cg));
|
||||
b = (uint8_t)(minval(255, percent_b_i * b + percent_b * cb));
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)(r >> 3) << 11) |
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a ) << 0));
|
||||
}
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a) << 0));
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_full_color_sub_tex_CI (uint32_t color)
|
||||
static void mod_full_color_sub_tex_CI(uint32_t color)
|
||||
{
|
||||
uint8_t cr, cg, cb, ca;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
uint8_t cr, cg, cb, ca;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
ca = (uint8_t)(color & 0xFF);
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
ca = (uint8_t)(color & 0xFF);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);;
|
||||
r = (uint8_t)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
|
||||
a = maxval(0, ca - a);
|
||||
r = maxval(0, cr - r);
|
||||
g = maxval(0, cg - g);
|
||||
b = maxval(0, cb - b);
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);;
|
||||
r = (uint8_t)((float)((col & 0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col & 0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col & 0x003E) >> 1) / 31.0f * 255.0f);
|
||||
a = maxval(0, ca - a);
|
||||
r = maxval(0, cr - r);
|
||||
g = maxval(0, cg - g);
|
||||
b = maxval(0, cb - b);
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)(r >> 3) << 11) |
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a ) << 0));
|
||||
}
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a) << 0));
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_col_inter_col1_using_tex_CI (uint32_t color0, uint32_t color1)
|
||||
static void mod_col_inter_col1_using_tex_CI(uint32_t color0, uint32_t color1)
|
||||
{
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
float percent_r, percent_g, percent_b;
|
||||
uint32_t cr0, cg0, cb0, cr1, cg1, cb1;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
float percent_r, percent_g, percent_b;
|
||||
|
||||
cr0 = (uint8_t)((color0 >> 24) & 0xFF);
|
||||
cg0 = (uint8_t)((color0 >> 16) & 0xFF);
|
||||
cb0 = (uint8_t)((color0 >> 8) & 0xFF);
|
||||
cr1 = (uint8_t)((color1 >> 24) & 0xFF);
|
||||
cg1 = (uint8_t)((color1 >> 16) & 0xFF);
|
||||
cb1 = (uint8_t)((color1 >> 8) & 0xFF);
|
||||
cr0 = (uint8_t)((color0 >> 24) & 0xFF);
|
||||
cg0 = (uint8_t)((color0 >> 16) & 0xFF);
|
||||
cb0 = (uint8_t)((color0 >> 8) & 0xFF);
|
||||
cr1 = (uint8_t)((color1 >> 24) & 0xFF);
|
||||
cg1 = (uint8_t)((color1 >> 16) & 0xFF);
|
||||
cb1 = (uint8_t)((color1 >> 8) & 0xFF);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);;
|
||||
percent_r = ((col&0xF800) >> 11) / 31.0f;
|
||||
percent_g = ((col&0x07C0) >> 6) / 31.0f;
|
||||
percent_b = ((col&0x003E) >> 1) / 31.0f;
|
||||
r = (uint8_t)(minval((1.0f-percent_r) * cr0 + percent_r * cr1, 255));
|
||||
g = (uint8_t)(minval((1.0f-percent_g) * cg0 + percent_g * cg1, 255));
|
||||
b = (uint8_t)(minval((1.0f-percent_b) * cb0 + percent_b * cb1, 255));
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);;
|
||||
percent_r = ((col & 0xF800) >> 11) / 31.0f;
|
||||
percent_g = ((col & 0x07C0) >> 6) / 31.0f;
|
||||
percent_b = ((col & 0x003E) >> 1) / 31.0f;
|
||||
r = (uint8_t)(minval((1.0f - percent_r) * cr0 + percent_r * cr1, 255));
|
||||
g = (uint8_t)(minval((1.0f - percent_g) * cg0 + percent_g * cg1, 255));
|
||||
b = (uint8_t)(minval((1.0f - percent_b) * cb0 + percent_b * cb1, 255));
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)(r >> 3) << 11) |
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a ) << 0));
|
||||
}
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a) << 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void mod_tex_sub_col_mul_fac_add_tex_CI (uint32_t color, uint32_t factor)
|
||||
static void mod_tex_sub_col_mul_fac_add_tex_CI(uint32_t color, uint32_t factor)
|
||||
{
|
||||
float percent = factor / 255.0f;
|
||||
uint8_t cr, cg, cb, a;
|
||||
uint16_t col;
|
||||
float r, g, b;
|
||||
float percent = factor / 255.0f;
|
||||
uint8_t cr, cg, cb, a;
|
||||
uint16_t col;
|
||||
float r, g, b;
|
||||
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);;
|
||||
r = (uint8_t)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = (r - cr) * percent + r;
|
||||
if (r > 255.0f) r = 255.0f;
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
g = (g - cg) * percent + g;
|
||||
if (g > 255.0f) g = 255.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
b = (b - cb) * percent + b;
|
||||
if (b > 255.0f) g = 255.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
for (int i = 0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);;
|
||||
r = (uint8_t)((float)((col & 0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col & 0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col & 0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = (r - cr) * percent + r;
|
||||
if (r > 255.0f) r = 255.0f;
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
g = (g - cg) * percent + g;
|
||||
if (g > 255.0f) g = 255.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
b = (b - cb) * percent + b;
|
||||
if (b > 255.0f) g = 255.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)((uint8_t)(r) >> 3) << 11) |
|
||||
((uint16_t)((uint8_t)(g) >> 3) << 6) |
|
||||
((uint16_t)((uint8_t)(b) >> 3) << 1) |
|
||||
(uint16_t)(a) );
|
||||
}
|
||||
((uint16_t)((uint8_t)(g) >> 3) << 6) |
|
||||
((uint16_t)((uint8_t)(b) >> 3) << 1) |
|
||||
(uint16_t)(a));
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_scale_col_add_col_CI (uint32_t color0, uint32_t color1)
|
||||
static void mod_tex_scale_col_add_col_CI(uint32_t color0, uint32_t color1)
|
||||
{
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
float percent_r = ((color0 >> 24) & 0xFF) / 255.0f;
|
||||
float percent_g = ((color0 >> 16) & 0xFF) / 255.0f;
|
||||
float percent_b = ((color0 >> 8) & 0xFF) / 255.0f;
|
||||
cr = (uint8_t)((color1 >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color1 >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color1 >> 8) & 0xFF);
|
||||
float percent_r = ((color0 >> 24) & 0xFF) / 255.0f;
|
||||
float percent_g = ((color0 >> 16) & 0xFF) / 255.0f;
|
||||
float percent_b = ((color0 >> 8) & 0xFF) / 255.0f;
|
||||
cr = (uint8_t)((color1 >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color1 >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color1 >> 8) & 0xFF);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);;
|
||||
r = (uint8_t)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = (uint8_t)(minval(255, percent_r * r + cr));
|
||||
g = (uint8_t)(minval(255, percent_g * g + cg));
|
||||
b = (uint8_t)(minval(255, percent_b * b + cb));
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);;
|
||||
r = (uint8_t)((float)((col & 0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col & 0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col & 0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = (uint8_t)(minval(255, percent_r * r + cr));
|
||||
g = (uint8_t)(minval(255, percent_g * g + cg));
|
||||
b = (uint8_t)(minval(255, percent_b * b + cb));
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)(r >> 3) << 11) |
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a ) << 0));
|
||||
}
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a) << 0));
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_add_col_CI (uint32_t color)
|
||||
static void mod_tex_add_col_CI(uint32_t color)
|
||||
{
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);;
|
||||
r = (uint8_t)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = minval(cr + r, 255);
|
||||
g = minval(cg + g, 255);
|
||||
b = minval(cb + b, 255);
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);;
|
||||
r = (uint8_t)((float)((col & 0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col & 0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col & 0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = minval(cr + r, 255);
|
||||
g = minval(cg + g, 255);
|
||||
b = minval(cb + b, 255);
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)(r >> 3) << 11) |
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a ) << 0));
|
||||
}
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a) << 0));
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_sub_col_CI (uint32_t color)
|
||||
static void mod_tex_sub_col_CI(uint32_t color)
|
||||
{
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);;
|
||||
r = (uint8_t)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = maxval(r - cr, 0);
|
||||
g = maxval(g - cg, 0);
|
||||
b = maxval(b - cb, 0);
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);;
|
||||
r = (uint8_t)((float)((col & 0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col & 0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col & 0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = maxval(r - cr, 0);
|
||||
g = maxval(g - cg, 0);
|
||||
b = maxval(b - cb, 0);
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)(r >> 3) << 11) |
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a ) << 0));
|
||||
}
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a) << 0));
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_sub_col_mul_fac_CI (uint32_t color, uint32_t factor)
|
||||
static void mod_tex_sub_col_mul_fac_CI(uint32_t color, uint32_t factor)
|
||||
{
|
||||
float percent = factor / 255.0f;
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a;
|
||||
float r, g, b;
|
||||
float percent = factor / 255.0f;
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a;
|
||||
float r, g, b;
|
||||
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
cr = (uint8_t)((color >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color >> 8) & 0xFF);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);
|
||||
r = (float)((col&0xF800) >> 11) / 31.0f * 255.0f;
|
||||
g = (float)((col&0x07C0) >> 6) / 31.0f * 255.0f;
|
||||
b = (float)((col&0x003E) >> 1) / 31.0f * 255.0f;
|
||||
r = (r - cr) * percent;
|
||||
if (r > 255.0f) r = 255.0f;
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
g = (g - cg) * percent;
|
||||
if (g > 255.0f) g = 255.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
b = (b - cb) * percent;
|
||||
if (b > 255.0f) g = 255.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
for (int i = 0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);
|
||||
r = (float)((col & 0xF800) >> 11) / 31.0f * 255.0f;
|
||||
g = (float)((col & 0x07C0) >> 6) / 31.0f * 255.0f;
|
||||
b = (float)((col & 0x003E) >> 1) / 31.0f * 255.0f;
|
||||
r = (r - cr) * percent;
|
||||
if (r > 255.0f) r = 255.0f;
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
g = (g - cg) * percent;
|
||||
if (g > 255.0f) g = 255.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
b = (b - cb) * percent;
|
||||
if (b > 255.0f) g = 255.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)((uint8_t)(r) >> 3) << 11) |
|
||||
((uint16_t)((uint8_t)(g) >> 3) << 6) |
|
||||
((uint16_t)((uint8_t)(b) >> 3) << 1) |
|
||||
(uint16_t)(a) );
|
||||
}
|
||||
((uint16_t)((uint8_t)(g) >> 3) << 6) |
|
||||
((uint16_t)((uint8_t)(b) >> 3) << 1) |
|
||||
(uint16_t)(a));
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_col_inter_tex_using_col1_CI (uint32_t color0, uint32_t color1)
|
||||
static void mod_col_inter_tex_using_col1_CI(uint32_t color0, uint32_t color1)
|
||||
{
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
uint8_t cr, cg, cb;
|
||||
uint16_t col;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
float percent_r = ((color1 >> 24) & 0xFF) / 255.0f;
|
||||
float percent_g = ((color1 >> 16) & 0xFF) / 255.0f;
|
||||
float percent_b = ((color1 >> 8) & 0xFF) / 255.0f;
|
||||
float percent_r_i = 1.0f - percent_r;
|
||||
float percent_g_i = 1.0f - percent_g;
|
||||
float percent_b_i = 1.0f - percent_b;
|
||||
float percent_r = ((color1 >> 24) & 0xFF) / 255.0f;
|
||||
float percent_g = ((color1 >> 16) & 0xFF) / 255.0f;
|
||||
float percent_b = ((color1 >> 8) & 0xFF) / 255.0f;
|
||||
float percent_r_i = 1.0f - percent_r;
|
||||
float percent_g_i = 1.0f - percent_g;
|
||||
float percent_b_i = 1.0f - percent_b;
|
||||
|
||||
cr = (uint8_t)((color0 >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color0 >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color0 >> 8) & 0xFF);
|
||||
cr = (uint8_t)((color0 >> 24) & 0xFF);
|
||||
cg = (uint8_t)((color0 >> 16) & 0xFF);
|
||||
cb = (uint8_t)((color0 >> 8) & 0xFF);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);;
|
||||
r = (uint8_t)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = (uint8_t)(minval(255, percent_r * r + percent_r_i * cr));
|
||||
g = (uint8_t)(minval(255, percent_g * g + percent_g_i * cg));
|
||||
b = (uint8_t)(minval(255, percent_b * b + percent_b_i * cb));
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);;
|
||||
r = (uint8_t)((float)((col & 0xF800) >> 11) / 31.0f * 255.0f);
|
||||
g = (uint8_t)((float)((col & 0x07C0) >> 6) / 31.0f * 255.0f);
|
||||
b = (uint8_t)((float)((col & 0x003E) >> 1) / 31.0f * 255.0f);
|
||||
r = (uint8_t)(minval(255, percent_r * r + percent_r_i * cr));
|
||||
g = (uint8_t)(minval(255, percent_g * g + percent_g_i * cg));
|
||||
b = (uint8_t)(minval(255, percent_b * b + percent_b_i * cb));
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)(r >> 3) << 11) |
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a ) << 0));
|
||||
}
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a) << 0));
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_inter_col_using_texa_CI (uint32_t color)
|
||||
static void mod_tex_inter_col_using_texa_CI(uint32_t color)
|
||||
{
|
||||
uint8_t a, r, g, b;
|
||||
uint8_t a, r, g, b;
|
||||
|
||||
r = (uint8_t)((float)((color >> 24) & 0xFF) / 255.0f * 31.0f);
|
||||
r = (uint8_t)((float)((color >> 24) & 0xFF) / 255.0f * 31.0f);
|
||||
g = (uint8_t)((float)((color >> 16) & 0xFF) / 255.0f * 31.0f);
|
||||
b = (uint8_t)((float)((color >> 8) & 0xFF) / 255.0f * 31.0f);
|
||||
a = (color&0xFF) ? 1 : 0;
|
||||
uint16_t col16 = (uint16_t)((r<<11)|(g<<6)|(b<<1)|a);
|
||||
b = (uint8_t)((float)((color >> 8) & 0xFF) / 255.0f * 31.0f);
|
||||
a = (color & 0xFF) ? 1 : 0;
|
||||
uint16_t col16 = (uint16_t)((r << 11) | (g << 6) | (b << 1) | a);
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
if (rdp.pal_8[i]&1)
|
||||
rdp.pal_8[i] = col16;
|
||||
}
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
if (rdp.pal_8[i] & 1)
|
||||
rdp.pal_8[i] = col16;
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_tex_mul_col_CI (uint32_t color)
|
||||
static void mod_tex_mul_col_CI(uint32_t color)
|
||||
{
|
||||
uint8_t a, r, g, b;
|
||||
uint16_t col;
|
||||
float cr, cg, cb;
|
||||
uint8_t a, r, g, b;
|
||||
uint16_t col;
|
||||
float cr, cg, cb;
|
||||
|
||||
cr = (float)((color >> 24) & 0xFF) / 255.0f;
|
||||
cr = (float)((color >> 24) & 0xFF) / 255.0f;
|
||||
cg = (float)((color >> 16) & 0xFF) / 255.0f;
|
||||
cb = (float)((color >> 8) & 0xFF) / 255.0f;
|
||||
cb = (float)((color >> 8) & 0xFF) / 255.0f;
|
||||
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col&0x0001);;
|
||||
r = (uint8_t)((float)((col&0xF800) >> 11) * cr);
|
||||
g = (uint8_t)((float)((col&0x07C0) >> 6) * cg);
|
||||
b = (uint8_t)((float)((col&0x003E) >> 1) * cb);
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
col = rdp.pal_8[i];
|
||||
a = (uint8_t)(col & 0x0001);;
|
||||
r = (uint8_t)((float)((col & 0xF800) >> 11) * cr);
|
||||
g = (uint8_t)((float)((col & 0x07C0) >> 6) * cg);
|
||||
b = (uint8_t)((float)((col & 0x003E) >> 1) * cb);
|
||||
rdp.pal_8[i] = (uint16_t)(((uint16_t)(r >> 3) << 11) |
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a ) << 0));
|
||||
}
|
||||
((uint16_t)(g >> 3) << 6) |
|
||||
((uint16_t)(b >> 3) << 1) |
|
||||
((uint16_t)(a) << 0));
|
||||
}
|
||||
}
|
||||
|
||||
static void ModifyPalette(uint32_t mod, uint32_t modcolor, uint32_t modcolor1, uint32_t modfactor)
|
||||
{
|
||||
switch (mod)
|
||||
{
|
||||
case TMOD_TEX_INTER_COLOR_USING_FACTOR:
|
||||
mod_tex_inter_color_using_factor_CI (modcolor, modfactor);
|
||||
break;
|
||||
case TMOD_TEX_INTER_COL_USING_COL1:
|
||||
mod_tex_inter_col_using_col1_CI (modcolor, modcolor1);
|
||||
break;
|
||||
case TMOD_FULL_COLOR_SUB_TEX:
|
||||
mod_full_color_sub_tex_CI (modcolor);
|
||||
break;
|
||||
case TMOD_COL_INTER_COL1_USING_TEX:
|
||||
mod_col_inter_col1_using_tex_CI (modcolor, modcolor1);
|
||||
break;
|
||||
case TMOD_TEX_SUB_COL_MUL_FAC_ADD_TEX:
|
||||
mod_tex_sub_col_mul_fac_add_tex_CI (modcolor, modfactor);
|
||||
break;
|
||||
case TMOD_TEX_SCALE_COL_ADD_COL:
|
||||
mod_tex_scale_col_add_col_CI (modcolor, modcolor1);
|
||||
break;
|
||||
case TMOD_TEX_ADD_COL:
|
||||
mod_tex_add_col_CI (modcolor);
|
||||
break;
|
||||
case TMOD_TEX_SUB_COL:
|
||||
mod_tex_sub_col_CI (modcolor);
|
||||
break;
|
||||
case TMOD_TEX_SUB_COL_MUL_FAC:
|
||||
mod_tex_sub_col_mul_fac_CI (modcolor, modfactor);
|
||||
break;
|
||||
case TMOD_COL_INTER_TEX_USING_COL1:
|
||||
mod_col_inter_tex_using_col1_CI (modcolor, modcolor1);
|
||||
break;
|
||||
case TMOD_TEX_INTER_COL_USING_TEXA:
|
||||
mod_tex_inter_col_using_texa_CI (modcolor);
|
||||
break;
|
||||
case TMOD_TEX_MUL_COL:
|
||||
mod_tex_mul_col_CI (modcolor);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
switch (mod)
|
||||
{
|
||||
case TMOD_TEX_INTER_COLOR_USING_FACTOR:
|
||||
mod_tex_inter_color_using_factor_CI(modcolor, modfactor);
|
||||
break;
|
||||
case TMOD_TEX_INTER_COL_USING_COL1:
|
||||
mod_tex_inter_col_using_col1_CI(modcolor, modcolor1);
|
||||
break;
|
||||
case TMOD_FULL_COLOR_SUB_TEX:
|
||||
mod_full_color_sub_tex_CI(modcolor);
|
||||
break;
|
||||
case TMOD_COL_INTER_COL1_USING_TEX:
|
||||
mod_col_inter_col1_using_tex_CI(modcolor, modcolor1);
|
||||
break;
|
||||
case TMOD_TEX_SUB_COL_MUL_FAC_ADD_TEX:
|
||||
mod_tex_sub_col_mul_fac_add_tex_CI(modcolor, modfactor);
|
||||
break;
|
||||
case TMOD_TEX_SCALE_COL_ADD_COL:
|
||||
mod_tex_scale_col_add_col_CI(modcolor, modcolor1);
|
||||
break;
|
||||
case TMOD_TEX_ADD_COL:
|
||||
mod_tex_add_col_CI(modcolor);
|
||||
break;
|
||||
case TMOD_TEX_SUB_COL:
|
||||
mod_tex_sub_col_CI(modcolor);
|
||||
break;
|
||||
case TMOD_TEX_SUB_COL_MUL_FAC:
|
||||
mod_tex_sub_col_mul_fac_CI(modcolor, modfactor);
|
||||
break;
|
||||
case TMOD_COL_INTER_TEX_USING_COL1:
|
||||
mod_col_inter_tex_using_col1_CI(modcolor, modcolor1);
|
||||
break;
|
||||
case TMOD_TEX_INTER_COL_USING_TEXA:
|
||||
mod_tex_inter_col_using_texa_CI(modcolor);
|
||||
break;
|
||||
case TMOD_TEX_MUL_COL:
|
||||
mod_tex_mul_col_CI(modcolor);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue