nw, update rgbgen

This commit is contained in:
therealmogminer@gmail.com 2015-06-21 04:51:05 +02:00
parent 15279b7178
commit c487569042
17 changed files with 950 additions and 923 deletions

View File

@ -149,7 +149,7 @@ private:
UINT32 pix01 = palbase[texbase[u1]]; UINT32 pix01 = palbase[texbase[u1]];
UINT32 pix10 = palbase[texbase[v1]]; UINT32 pix10 = palbase[texbase[v1]];
UINT32 pix11 = palbase[texbase[u1 + v1]]; UINT32 pix11 = palbase[texbase[u1 + v1]];
return rgbint_t::bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8); return rgbaint_t::bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
} }
else else
{ {
@ -181,7 +181,7 @@ private:
const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base); const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base);
texbase += v0 * texture.rowpixels + u0; texbase += v0 * texture.rowpixels + u0;
return rgbint_t::bilinear_filter(palbase[texbase[0]], palbase[texbase[u1]], palbase[texbase[v1]], palbase[texbase[u1 + v1]], curu >> 8, curv >> 8); return rgbaint_t::bilinear_filter(palbase[texbase[0]], palbase[texbase[u1]], palbase[texbase[v1]], palbase[texbase[u1 + v1]], curu >> 8, curv >> 8);
} }
else else
{ {
@ -243,7 +243,7 @@ private:
else else
pix11 = pix10; pix11 = pix10;
} }
return rgbint_t::bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8); return rgbaint_t::bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
} }
else else
{ {
@ -274,7 +274,7 @@ private:
const UINT32 *texbase = reinterpret_cast<const UINT32 *>(texture.base); const UINT32 *texbase = reinterpret_cast<const UINT32 *>(texture.base);
texbase += v0 * texture.rowpixels + u0; texbase += v0 * texture.rowpixels + u0;
return rgbint_t::bilinear_filter(texbase[0], texbase[u1], texbase[v1], texbase[u1 + v1], curu >> 8, curv >> 8); return rgbaint_t::bilinear_filter(texbase[0], texbase[u1], texbase[v1], texbase[u1 + v1], curu >> 8, curv >> 8);
} }
else else
{ {
@ -305,7 +305,7 @@ private:
const UINT32 *texbase = reinterpret_cast<const UINT32 *>(texture.base); const UINT32 *texbase = reinterpret_cast<const UINT32 *>(texture.base);
texbase += v0 * texture.rowpixels + u0; texbase += v0 * texture.rowpixels + u0;
return rgbint_t::bilinear_filter(texbase[0], texbase[u1], texbase[v1], texbase[u1 + v1], curu >> 8, curv >> 8); return rgbaint_t::bilinear_filter(texbase[0], texbase[u1], texbase[v1], texbase[u1 + v1], curu >> 8, curv >> 8);
} }
else else
{ {

130
src/emu/video/rgbgen.c Normal file
View File

@ -0,0 +1,130 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb, Ryan Holtz
/***************************************************************************
rgbgen.c
General RGB utilities.
***************************************************************************/
#include "emu.h"
#include "rgbgen.h"
/***************************************************************************
HIGHER LEVEL OPERATIONS
***************************************************************************/
/*-------------------------------------------------
rgbaint_blend - blend two colors by the given
scale factor
-------------------------------------------------*/
void rgbaint_t::blend(const rgbaint_t& color2, UINT8 color1scale)
{
INT32 scale1 = (INT32)color1scale;
INT32 scale2 = 256 - scale1;
m_a = (m_a * scale1 + color2.m_a * scale2) >> 8;
m_r = (m_r * scale1 + color2.m_r * scale2) >> 8;
m_g = (m_g * scale1 + color2.m_g * scale2) >> 8;
m_b = (m_b * scale1 + color2.m_b * scale2) >> 8;
}
/*-------------------------------------------------
rgbaint_scale_and_clamp - scale the given
color by an 8.8 scale factor, immediate or
per channel, and clamp to byte values
-------------------------------------------------*/
void rgbaint_t::scale_imm_and_clamp(INT32 scale)
{
m_a = (m_a * scale) >> 8;
if (m_a > 255) { m_a = (m_a < 0) ? 0 : 255; }
m_r = (m_r * scale) >> 8;
if (m_r > 255) { m_r = (m_r < 0) ? 0 : 255; }
m_g = (m_g * scale) >> 8;
if (m_g > 255) { m_g = (m_g < 0) ? 0 : 255; }
m_b = (m_b * scale) >> 8;
if (m_b > 255) { m_b = (m_b < 0) ? 0 : 255; }
}
void rgbaint_t::scale_and_clamp(const rgbaint_t& scale)
{
m_a = (m_a * scale.m_a) >> 8;
if (m_a > 255) { m_a = (m_a < 0) ? 0 : 255; }
m_r = (m_r * scale.m_r) >> 8;
if (m_r > 255) { m_r = (m_r < 0) ? 0 : 255; }
m_g = (m_g * scale.m_g) >> 8;
if (m_g > 255) { m_g = (m_g < 0) ? 0 : 255; }
m_b = (m_b * scale.m_b) >> 8;
if (m_b > 255) { m_b = (m_b < 0) ? 0 : 255; }
}
void rgbaint_t::scale_imm_add_and_clamp(INT32 scale, const rgbaint_t& other)
{
m_a = (m_a * scale) >> 8;
m_a += other.m_a;
if (m_a > 255) { m_a = (m_a < 0) ? 0 : 255; }
m_r = (m_r * scale) >> 8;
m_r += other.m_r;
if (m_r > 255) { m_r = (m_r < 0) ? 0 : 255; }
m_g = (m_g * scale) >> 8;
m_g += other.m_g;
if (m_g > 255) { m_g = (m_g < 0) ? 0 : 255; }
m_b = (m_b * scale) >> 8;
m_b += other.m_b;
if (m_b > 255) { m_b = (m_b < 0) ? 0 : 255; }
}
void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other)
{
m_a = (m_a * scale.m_a) >> 8;
m_a += other.m_a;
if (m_a > 255) { m_a = (m_a < 0) ? 0 : 255; }
m_r = (m_r * scale.m_r) >> 8;
m_r += other.m_r;
if (m_r > 255) { m_r = (m_r < 0) ? 0 : 255; }
m_g = (m_g * scale.m_g) >> 8;
m_g += other.m_g;
if (m_g > 255) { m_g = (m_g < 0) ? 0 : 255; }
m_b = (m_b * scale.m_b) >> 8;
m_b += other.m_b;
if (m_b > 255) { m_b = (m_b < 0) ? 0 : 255; }
}
void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2)
{
m_a = (m_a * scale.m_a + other.m_a * scale2.m_a) >> 8;
if ((UINT16)m_a > 255) { m_a = (m_a < 0) ? 0 : 255; }
m_r = (m_r * scale.m_r + other.m_r * scale2.m_r) >> 8;
if ((UINT16)m_r > 255) { m_r = (m_r < 0) ? 0 : 255; }
m_g = (m_g * scale.m_g + other.m_g * scale2.m_g) >> 8;
if ((UINT16)m_g > 255) { m_g = (m_g < 0) ? 0 : 255; }
m_b = (m_b * scale.m_b + other.m_b * scale2.m_b) >> 8;
if ((UINT16)m_b > 255) { m_b = (m_b < 0) ? 0 : 255; }
}
/*-------------------------------------------------
bilinear_filter - bilinear filter between
four pixel values; this code is derived from
code provided by Michael Herf
-------------------------------------------------*/
UINT32 rgbaint_t::bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
{
UINT32 ag0, ag1, rb0, rb1;
rb0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8);
rb1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8);
ag0 = (rgb00 & 0xff00ff00) + ((((rgb01 & 0xff00ff00) - (rgb00 & 0xff00ff00)) * u) >> 8);
ag1 = (rgb10 & 0xff00ff00) + ((((rgb11 & 0xff00ff00) - (rgb10 & 0xff00ff00)) * u) >> 8);
rb0 = (rb0 & 0x00ff00ff) + ((((rb1 & 0x00ff00ff) - (rb0 & 0x00ff00ff)) * v) >> 8);
ag0 = (ag0 & 0xff00ff00) + ((((ag1 & 0xff00ff00) - (ag0 & 0xff00ff00)) * v) >> 8);
return (ag0 & 0xff00ff00) | (rb0 & 0x00ff00ff);
}

View File

@ -1,5 +1,5 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Vas Crabb // copyright-holders:Vas Crabb, Ryan Holtz
/*************************************************************************** /***************************************************************************
rgbgen.h rgbgen.h
@ -16,511 +16,451 @@
TYPE DEFINITIONS TYPE DEFINITIONS
***************************************************************************/ ***************************************************************************/
/* intermediate RGB values are stored in a struct */ class rgbaint_t
struct rgbint { INT16 dummy, r, g, b; };
/* intermediate RGB values are stored in a struct */
struct rgbaint { INT16 a, r, g, b; };
/***************************************************************************
BASIC CONVERSIONS
***************************************************************************/
/*-------------------------------------------------
rgb_comp_to_rgbint - converts a trio of RGB
components to an rgbint type
-------------------------------------------------*/
INLINE void rgb_comp_to_rgbint(rgbint *rgb, INT16 r, INT16 g, INT16 b)
{ {
rgb->r = r; public:
rgb->g = g; inline rgbaint_t() { }
rgb->b = b; inline rgbaint_t(UINT32 a, UINT32 r, UINT32 g, UINT32 b) { set(a, r, g, b); }
} inline rgbaint_t(rgb_t& rgba) { set(rgba); }
inline void set(rgbaint_t& other) { set(other.m_a, other.m_r, other.m_g, other.m_b); }
/*------------------------------------------------- inline void set(UINT32 rgba) { set((rgba >> 24) & 0xff, (rgba >> 16) & 0xff, (rgba >> 8) & 0xff, rgba & 0xff); }
rgba_comp_to_rgbint - converts a quad of RGB inline void set(UINT32 a, UINT32 r, UINT32 g, UINT32 b)
components to an rgbint type {
-------------------------------------------------*/ m_a = a;
m_r = r;
INLINE void rgba_comp_to_rgbaint(rgbaint *rgb, INT16 a, INT16 r, INT16 g, INT16 b) m_g = g;
{ m_b = b;
rgb->a = a; }
rgb->r = r; inline void set(rgb_t& rgba) { set(rgba.a(), rgba.r(), rgba.g(), rgba.b()); }
rgb->g = g;
rgb->b = b; inline rgb_t to_rgba()
} {
return rgb_t(m_a, m_r, m_g, m_b);
}
/*-------------------------------------------------
rgb_to_rgbint - converts a packed trio of RGB inline rgb_t to_rgba_clamp()
components to an rgbint type {
-------------------------------------------------*/ UINT8 a = (m_a < 0) ? 0 : (m_a > 255) ? 255 : m_a;
UINT8 r = (m_r < 0) ? 0 : (m_r > 255) ? 255 : m_r;
INLINE void rgb_to_rgbint(rgbint *rgb, rgb_t color) UINT8 g = (m_g < 0) ? 0 : (m_g > 255) ? 255 : m_g;
{ UINT8 b = (m_b < 0) ? 0 : (m_b > 255) ? 255 : m_b;
rgb->r = color.r(); return rgb_t(a, r, g, b);
rgb->g = color.g(); }
rgb->b = color.b();
} inline void add(const rgbaint_t& color)
{
add_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
/*------------------------------------------------- }
rgba_to_rgbaint - converts a packed quad of RGB
components to an rgbint type inline void add_imm(const UINT32 imm)
-------------------------------------------------*/ {
add_imm_rgba(imm, imm, imm, imm);
INLINE void rgba_to_rgbaint(rgbaint *rgb, rgb_t color) }
{
rgb->a = color.a(); inline void add_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
rgb->r = color.r(); {
rgb->g = color.g(); m_a += a;
rgb->b = color.b(); m_r += r;
} m_g += g;
m_b += b;
}
/*-------------------------------------------------
rgbint_to_rgb - converts an rgbint back to inline void sub(const rgbaint_t& color)
a packed trio of RGB values {
-------------------------------------------------*/ sub_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
}
INLINE rgb_t rgbint_to_rgb(const rgbint *color)
{ inline void sub_imm(const UINT32 imm)
return rgb_t(color->r, color->g, color->b); {
} sub_imm_rgba(imm, imm, imm, imm);
}
/*------------------------------------------------- inline void sub_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
rgbaint_to_rgba - converts an rgbint back to {
a packed quad of RGB values m_a -= a;
-------------------------------------------------*/ m_r -= r;
m_g -= g;
INLINE rgb_t rgbaint_to_rgba(const rgbaint *color) m_b -= b;
{ }
return rgb_t(color->a, color->r, color->g, color->b);
} inline void subr(rgbaint_t& color)
{
subr_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
/*------------------------------------------------- }
rgbint_to_rgb_clamp - converts an rgbint back
to a packed trio of RGB values, clamping them inline void subr_imm(const UINT32 imm)
to bytes first {
-------------------------------------------------*/ subr_imm_rgba(imm, imm, imm, imm);
}
INLINE rgb_t rgbint_to_rgb_clamp(const rgbint *color)
{ inline void subr_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
UINT8 r = (color->r < 0) ? 0 : (color->r > 255) ? 255 : color->r; {
UINT8 g = (color->g < 0) ? 0 : (color->g > 255) ? 255 : color->g; m_a = a - m_a;
UINT8 b = (color->b < 0) ? 0 : (color->b > 255) ? 255 : color->b; m_r = r - m_r;
return rgb_t(r, g, b); m_g = g - m_g;
} m_b = b - m_b;
}
/*------------------------------------------------- inline void set_a(const UINT32 value)
rgbaint_to_rgba_clamp - converts an rgbint back {
to a packed quad of RGB values, clamping them m_r = value;
to bytes first }
-------------------------------------------------*/
inline void set_r(const UINT32 value)
INLINE rgb_t rgbaint_to_rgba_clamp(const rgbaint *color) {
{ m_r = value;
UINT8 a = (color->a < 0) ? 0 : (color->a > 255) ? 255 : color->a; }
UINT8 r = (color->r < 0) ? 0 : (color->r > 255) ? 255 : color->r;
UINT8 g = (color->g < 0) ? 0 : (color->g > 255) ? 255 : color->g; inline void set_g(const UINT32 value)
UINT8 b = (color->b < 0) ? 0 : (color->b > 255) ? 255 : color->b; {
return rgb_t(a, r, g, b); m_g = value;
} }
inline void set_b(const UINT32 value)
{
/*************************************************************************** m_b = value;
CORE MATH }
***************************************************************************/
inline UINT8 get_a()
/*------------------------------------------------- {
rgbint_add - add two rgbint values return m_r;
-------------------------------------------------*/ }
INLINE void rgbint_add(rgbint *color1, const rgbint *color2) inline UINT8 get_r()
{ {
color1->r += color2->r; return m_r;
color1->g += color2->g; }
color1->b += color2->b;
} inline UINT8 get_g()
{
return m_g;
/*------------------------------------------------- }
rgbaint_add - add two rgbaint values
-------------------------------------------------*/ inline UINT8 get_b()
{
INLINE void rgbaint_add(rgbaint *color1, const rgbaint *color2) return m_b;
{ }
color1->a += color2->a;
color1->r += color2->r; inline UINT32 get_a32()
color1->g += color2->g; {
color1->b += color2->b; return m_a;
} }
/*------------------------------------------------- inline UINT32 get_r32()
rgbaint_add_imm - add immediate INT16 to rgbaint value {
-------------------------------------------------*/ return m_r;
}
INLINE void rgbaint_add_imm(rgbaint *color1, const INT16 imm)
{ inline UINT32 get_g32()
color1->a += imm; {
color1->r += imm; return m_g;
color1->g += imm; }
color1->b += imm;
} inline UINT32 get_b32()
{
return m_b;
/*------------------------------------------------- }
rgbint_sub - subtract two rgbint values
-------------------------------------------------*/ inline void mul(rgbaint_t& color)
{
INLINE void rgbint_sub(rgbint *color1, const rgbint *color2) mul_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
{ }
color1->r -= color2->r;
color1->g -= color2->g; inline void mul_imm(const UINT32 imm)
color1->b -= color2->b; {
} mul_imm_rgba(imm, imm, imm, imm);
}
/*------------------------------------------------- inline void mul_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
rgbaint_sub - subtract two rgbaint values {
-------------------------------------------------*/ m_a *= a;
m_r *= r;
INLINE void rgbaint_sub(rgbaint *color1, const rgbaint *color2) m_g *= g;
{ m_b *= b;
color1->a -= color2->a; }
color1->r -= color2->r;
color1->g -= color2->g; inline void shl(const rgbaint_t& shift)
color1->b -= color2->b; {
} m_a <<= shift.m_a;
m_r <<= shift.m_r;
m_g <<= shift.m_g;
/*------------------------------------------------- m_b <<= shift.m_b;
rgbint_subr - reverse subtract two rgbint }
values
-------------------------------------------------*/ inline void shl_imm(const UINT8 shift)
{
INLINE void rgbint_subr(rgbint *color1, const rgbint *color2) if (shift == 0)
{ return;
color1->r = color2->r - color1->r;
color1->g = color2->g - color1->g; m_a <<= shift;
color1->b = color2->b - color1->b; m_r <<= shift;
} m_g <<= shift;
m_b <<= shift;
}
/*-------------------------------------------------
rgbaint_subr - reverse subtract two rgbaint inline void shl_imm_all(const UINT8 shift)
values {
-------------------------------------------------*/ if (shift == 0)
return;
INLINE void rgbaint_subr(rgbaint *color1, const rgbaint *color2)
{ m_a <<= shift;
color1->a = color2->a - color1->a; m_a |= m_r >> (32 - shift);
color1->r = color2->r - color1->r; m_r <<= shift;
color1->g = color2->g - color1->g; m_r |= m_g >> (32 - shift);
color1->b = color2->b - color1->b; m_g <<= shift;
} m_g |= m_b >> (32 - shift);
m_b <<= shift;
}
/*-------------------------------------------------
rgbint_shl - shift each component of an inline void shr(const rgbaint_t& shift)
rgbint struct by the given number of bits {
-------------------------------------------------*/ m_a >>= shift.m_a;
m_r >>= shift.m_r;
INLINE void rgbint_shl(rgbint *color, UINT8 shift) m_g >>= shift.m_g;
{ m_b >>= shift.m_b;
color->r <<= shift; }
color->g <<= shift;
color->b <<= shift; inline void shr_imm(const UINT8 shift)
} {
if (shift == 0)
return;
/*-------------------------------------------------
rgbaint_shl - shift each component of an m_a >>= shift;
rgbaint struct by the given number of bits m_r >>= shift;
-------------------------------------------------*/ m_g >>= shift;
m_b >>= shift;
INLINE void rgbaint_shl(rgbaint *color, UINT8 shift) }
{
color->r <<= shift; inline void shr_imm_all(const UINT8 shift)
color->g <<= shift; {
color->b <<= shift; if (shift == 0)
color->a <<= shift; return;
}
m_b >>= shift;
m_b |= m_g << (32 - shift);
/*------------------------------------------------- m_g >>= shift;
rgbint_shr - shift each component of an m_g |= m_r << (32 - shift);
rgbint struct by the given number of bits m_r >>= shift;
-------------------------------------------------*/ m_r |= m_a << (32 - shift);
m_a >>= shift;
INLINE void rgbint_shr(rgbint *color, UINT8 shift) }
{
color->r >>= shift; inline void sra(const rgbaint_t& shift)
color->g >>= shift; {
color->b >>= shift; m_a >>= shift.m_a;
} if (m_a & (1 << (31 - shift.m_a)))
m_a |= ~0 << (32 - shift.m_a);
/*------------------------------------------------- m_r >>= shift.m_r;
rgbaint_shr - shift each component of an if (m_r & (1 << (31 - shift.m_r)))
rgbaint struct by the given number of bits m_r |= ~0 << (32 - shift.m_r);
-------------------------------------------------*/
m_g >>= shift.m_g;
INLINE void rgbaint_shr(rgbaint *color, UINT8 shift) if (m_g & (1 << (31 - shift.m_g)))
{ m_g |= ~0 << (32 - shift.m_g);
color->r >>= shift;
color->g >>= shift; m_b >>= shift.m_b;
color->b >>= shift; if (m_b & (1 << (31 - shift.m_b)))
color->a >>= shift; m_b |= ~0 << (32 - shift.m_b);
} }
inline void sra_imm(const UINT8 shift)
{
/*************************************************************************** const UINT32 high_bit = 1 << (31 - shift);
HIGHER LEVEL OPERATIONS const UINT32 high_mask = ~0 << (32 - shift);
***************************************************************************/
m_a >>= shift;
/*------------------------------------------------- if (m_a & high_bit)
rgbint_blend - blend two colors by the given m_a |= high_mask;
scale factor
-------------------------------------------------*/ m_r >>= shift;
if (m_r & high_bit)
INLINE void rgbint_blend(rgbint *color1, const rgbint *color2, UINT8 color1scale) m_r |= high_mask;
{
int scale1 = (int)color1scale; m_g >>= shift;
int scale2 = 256 - scale1; if (m_g & high_bit)
m_g |= high_mask;
color1->r = (color1->r * scale1 + color2->r * scale2) >> 8;
color1->g = (color1->g * scale1 + color2->g * scale2) >> 8; m_b >>= shift;
color1->b = (color1->b * scale1 + color2->b * scale2) >> 8; if (m_b & high_bit)
} m_b |= high_mask;
}
/*------------------------------------------------- inline void or_reg(const rgbaint_t& color)
rgbaint_blend - blend two colors by the given {
scale factor or_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
-------------------------------------------------*/ }
INLINE void rgbaint_blend(rgbaint *color1, const rgbaint *color2, UINT8 color1scale) inline void or_imm(const UINT32 imm)
{ {
int scale1 = (int)color1scale; or_imm_rgba(imm, imm, imm, imm);
int scale2 = 256 - scale1; }
color1->a = (color1->a * scale1 + color2->a * scale2) >> 8; inline void or_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
color1->r = (color1->r * scale1 + color2->r * scale2) >> 8; {
color1->g = (color1->g * scale1 + color2->g * scale2) >> 8; m_a |= a;
color1->b = (color1->b * scale1 + color2->b * scale2) >> 8; m_r |= r;
} m_g |= g;
m_b |= b;
/*------------------------------------------------- }
rgbint_scale_and_clamp - scale the given
color by an 8.8 scale factor, immediate or inline void and_reg(const rgbaint_t& color)
per channel, and clamp to byte values {
-------------------------------------------------*/ and_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
}
INLINE void rgbint_scale_immediate_and_clamp(rgbint *color, INT16 colorscale)
{ inline void and_imm(const UINT32 imm)
color->r = (color->r * colorscale) >> 8; {
if ((UINT16)color->r > 255) { color->r = (color->r < 0) ? 0 : 255; } and_imm_rgba(imm, imm, imm, imm);
color->g = (color->g * colorscale) >> 8; }
if ((UINT16)color->g > 255) { color->g = (color->g < 0) ? 0 : 255; }
color->b = (color->b * colorscale) >> 8; inline void and_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
if ((UINT16)color->b > 255) { color->b = (color->b < 0) ? 0 : 255; } {
} m_a &= a;
m_r &= r;
INLINE void rgbint_scale_channel_and_clamp(rgbint *color, const rgbint *colorscale) m_g &= g;
{ m_b &= b;
color->r = (color->r * colorscale->r) >> 8; }
if ((UINT16)color->r > 255) { color->r = (color->r < 0) ? 0 : 255; }
color->g = (color->g * colorscale->g) >> 8; inline void xor_reg(const rgbaint_t& color)
if ((UINT16)color->g > 255) { color->g = (color->g < 0) ? 0 : 255; } {
color->b = (color->b * colorscale->b) >> 8; xor_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b);
if ((UINT16)color->b > 255) { color->b = (color->b < 0) ? 0 : 255; } }
}
inline void xor_imm(const UINT32 imm)
{
/*------------------------------------------------- xor_imm_rgba(imm, imm, imm, imm);
rgbaint_scale_and_clamp - scale the given }
color by an 8.8 scale factor, immediate or
per channel, and clamp to byte values inline void xor_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
-------------------------------------------------*/ {
m_a ^= a;
INLINE void rgbaint_scale_immediate_and_clamp(rgbaint *color, INT16 colorscale) m_r ^= r;
{ m_g ^= g;
color->a = (color->a * colorscale) >> 8; m_b ^= b;
if ((UINT16)color->a > 255) { color->a = (color->a < 0) ? 0 : 255; } }
color->r = (color->r * colorscale) >> 8;
if ((UINT16)color->r > 255) { color->r = (color->r < 0) ? 0 : 255; } inline void clamp_and_clear(const UINT32 sign)
color->g = (color->g * colorscale) >> 8; {
if ((UINT16)color->g > 255) { color->g = (color->g < 0) ? 0 : 255; } if (m_a & sign)
color->b = (color->b * colorscale) >> 8; m_a = 0;
if ((UINT16)color->b > 255) { color->b = (color->b < 0) ? 0 : 255; }
} if (m_r & sign)
m_r = 0;
INLINE void rgbaint_scale_channel_and_clamp(rgbaint *color, const rgbaint *colorscale)
{ if (m_g & sign)
color->a = (color->a * colorscale->a) >> 8; m_g = 0;
if ((UINT16)color->a > 255) { color->a = (color->a < 0) ? 0 : 255; }
color->r = (color->r * colorscale->r) >> 8; if (m_b & sign)
if ((UINT16)color->r > 255) { color->r = (color->r < 0) ? 0 : 255; } m_b = 0;
color->g = (color->g * colorscale->g) >> 8;
if ((UINT16)color->g > 255) { color->g = (color->g < 0) ? 0 : 255; } m_a = (m_a < 0) ? 0 : (m_a > 255) ? 255 : m_a;
color->b = (color->b * colorscale->b) >> 8; m_r = (m_r < 0) ? 0 : (m_r > 255) ? 255 : m_r;
if ((UINT16)color->b > 255) { color->b = (color->b < 0) ? 0 : 255; } m_g = (m_g < 0) ? 0 : (m_g > 255) ? 255 : m_g;
} m_b = (m_b < 0) ? 0 : (m_b > 255) ? 255 : m_b;
}
INLINE void rgbaint_scale_immediate_add_and_clamp(rgbaint *color1, INT16 colorscale, const rgbaint *color2)
{ inline void sign_extend(const UINT32 compare, const UINT32 sign)
color1->a = (color1->a * colorscale) >> 8; {
color1->a += color2->a; if ((m_a & compare) == compare)
if ((UINT16)color1->a > 255) { color1->a = (color1->a < 0) ? 0 : 255; } m_a |= sign;
color1->r = (color1->r * colorscale) >> 8;
color1->r += color2->r; if ((m_r & compare) == compare)
if ((UINT16)color1->r > 255) { color1->r = (color1->r < 0) ? 0 : 255; } m_r |= sign;
color1->g = (color1->g * colorscale) >> 8;
color1->g += color2->g; if ((m_g & compare) == compare)
if ((UINT16)color1->g > 255) { color1->g = (color1->g < 0) ? 0 : 255; } m_g |= sign;
color1->b = (color1->b * colorscale) >> 8;
color1->b += color2->b; if ((m_b & compare) == compare)
if ((UINT16)color1->b > 255) { color1->b = (color1->b < 0) ? 0 : 255; } m_b |= sign;
} }
INLINE void rgbaint_scale_channel_add_and_clamp(rgbaint *color1, const rgbaint *colorscale, const rgbaint *color2) inline void min(const UINT32 value)
{ {
color1->a = (color1->a * colorscale->a) >> 8; m_a = (m_a > value) ? value : m_a;
color1->a += color2->a; m_r = (m_r > value) ? value : m_r;
if ((UINT16)color1->a > 255) { color1->a = (color1->a < 0) ? 0 : 255; } m_g = (m_g > value) ? value : m_g;
color1->r = (color1->r * colorscale->r) >> 8; m_b = (m_b > value) ? value : m_b;
color1->r += color2->r; }
if ((UINT16)color1->r > 255) { color1->r = (color1->r < 0) ? 0 : 255; }
color1->g = (color1->g * colorscale->g) >> 8; void blend(const rgbaint_t& other, UINT8 factor);
color1->g += color2->g;
if ((UINT16)color1->g > 255) { color1->g = (color1->g < 0) ? 0 : 255; } void scale_and_clamp(const rgbaint_t& scale);
color1->b = (color1->b * colorscale->b) >> 8; void scale_imm_and_clamp(const INT32 scale);
color1->b += color2->b; void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2);
if ((UINT16)color1->b > 255) { color1->b = (color1->b < 0) ? 0 : 255; } void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other);
} void scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other);
INLINE void rgbaint_scale_channel_add_and_clamp(rgbaint *color1, const rgbaint *colorscale1, const rgbaint *color2, const rgbaint *colorscale2) inline void cmpeq(const rgbaint_t& value)
{ {
color1->a = (color1->a * colorscale1->a + color2->a * colorscale2->a) >> 8; m_a = (m_a == value.m_a) ? 0xffffffff : 0;
if ((UINT16)color1->a > 255) { color1->a = (color1->a < 0) ? 0 : 255; } m_r = (m_r == value.m_r) ? 0xffffffff : 0;
color1->r = (color1->r * colorscale1->r + color2->r * colorscale2->r) >> 8; m_g = (m_g == value.m_g) ? 0xffffffff : 0;
if ((UINT16)color1->r > 255) { color1->r = (color1->r < 0) ? 0 : 255; } m_b = (m_b == value.m_b) ? 0xffffffff : 0;
color1->g = (color1->g * colorscale1->g + color2->g * colorscale2->g) >> 8; }
if ((UINT16)color1->g > 255) { color1->g = (color1->g < 0) ? 0 : 255; }
color1->b = (color1->b * colorscale1->b + color2->b * colorscale2->b) >> 8; inline void cmpeq_imm(const UINT32 value)
if ((UINT16)color1->b > 255) { color1->b = (color1->b < 0) ? 0 : 255; } {
} m_a = (m_a == value) ? 0xffffffff : 0;
m_r = (m_r == value) ? 0xffffffff : 0;
m_g = (m_g == value) ? 0xffffffff : 0;
/*------------------------------------------------- m_b = (m_b == value) ? 0xffffffff : 0;
rgb_bilinear_filter - bilinear filter between }
four pixel values; this code is derived from
code provided by Michael Herf inline void cmpgt(const rgbaint_t& value)
-------------------------------------------------*/ {
m_a = (m_a > value.m_a) ? 0xffffffff : 0;
INLINE UINT32 rgb_bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v) m_r = (m_r > value.m_r) ? 0xffffffff : 0;
{ m_g = (m_g > value.m_g) ? 0xffffffff : 0;
UINT32 ag0, ag1, rb0, rb1; m_b = (m_b > value.m_b) ? 0xffffffff : 0;
}
rb0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8);
rb1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8); inline void cmpgt_imm(const UINT32 value)
ag0 = (rgb00 & 0x0000ff00) + ((((rgb01 & 0x0000ff00) - (rgb00 & 0x0000ff00)) * u) >> 8); {
ag1 = (rgb10 & 0x0000ff00) + ((((rgb11 & 0x0000ff00) - (rgb10 & 0x0000ff00)) * u) >> 8); m_a = (m_a > value) ? 0xffffffff : 0;
m_r = (m_r > value) ? 0xffffffff : 0;
rb0 = (rb0 & 0x00ff00ff) + ((((rb1 & 0x00ff00ff) - (rb0 & 0x00ff00ff)) * v) >> 8); m_g = (m_g > value) ? 0xffffffff : 0;
ag0 = (ag0 & 0x0000ff00) + ((((ag1 & 0x0000ff00) - (ag0 & 0x0000ff00)) * v) >> 8); m_b = (m_b > value) ? 0xffffffff : 0;
}
return (ag0 & 0x0000ff00) | (rb0 & 0x00ff00ff);
} inline void cmplt(const rgbaint_t& value)
{
m_a = (m_a < value.m_a) ? 0xffffffff : 0;
/*------------------------------------------------- m_r = (m_r < value.m_r) ? 0xffffffff : 0;
rgba_bilinear_filter - bilinear filter between m_g = (m_g < value.m_g) ? 0xffffffff : 0;
four pixel values; this code is derived from m_b = (m_b < value.m_b) ? 0xffffffff : 0;
code provided by Michael Herf }
-------------------------------------------------*/
inline void cmplt_imm(const UINT32 value)
INLINE UINT32 rgba_bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v) {
{ m_a = (m_a < value) ? 0xffffffff : 0;
UINT32 ag0, ag1, rb0, rb1; m_r = (m_r < value) ? 0xffffffff : 0;
m_g = (m_g < value) ? 0xffffffff : 0;
rb0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); m_b = (m_b < value) ? 0xffffffff : 0;
rb1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8); }
rgb00 = rgb00 >> 8;
rgb01 = rgb01 >> 8; inline void merge_alpha(rgbaint_t& alpha)
rgb10 = rgb10 >> 8; {
rgb11 = rgb11 >> 8; m_a = alpha.m_a;
ag0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); }
ag1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8);
inline rgbaint_t operator=(const rgbaint_t& other)
rb0 = (rb0 & 0x00ff00ff) + ((((rb1 & 0x00ff00ff) - (rb0 & 0x00ff00ff)) * v) >> 8); {
ag0 = (ag0 & 0x00ff00ff) + ((((ag1 & 0x00ff00ff) - (ag0 & 0x00ff00ff)) * v) >> 8); m_a = other.m_a;
m_r = other.m_r;
return ((ag0 << 8) & 0xff00ff00) | (rb0 & 0x00ff00ff); m_g = other.m_g;
} m_b = other.m_b;
return *this;
}
/*-------------------------------------------------
rgbint_bilinear_filter - bilinear filter between static UINT32 bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v);
four pixel values; this code is derived from
code provided by Michael Herf protected:
-------------------------------------------------*/ UINT32 m_a;
UINT32 m_r;
INLINE void rgbint_bilinear_filter(rgbint *color, UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v) UINT32 m_g;
{ UINT32 m_b;
UINT32 ag0, ag1, rb0, rb1; };
rb0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); #endif /* __RGBGEN__ */
rb1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8);
ag0 = (rgb00 & 0x0000ff00) + ((((rgb01 & 0x0000ff00) - (rgb00 & 0x0000ff00)) * u) >> 8);
ag1 = (rgb10 & 0x0000ff00) + ((((rgb11 & 0x0000ff00) - (rgb10 & 0x0000ff00)) * u) >> 8);
rb0 = (rb0 & 0x00ff00ff) + ((((rb1 & 0x00ff00ff) - (rb0 & 0x00ff00ff)) * v) >> 8);
ag0 = (ag0 & 0x0000ff00) + ((((ag1 & 0x0000ff00) - (ag0 & 0x0000ff00)) * v) >> 8);
color->r = rb0 >> 16;
color->g = ag0 >> 8;
color->b = rb0;
}
/*-------------------------------------------------
rgbaint_bilinear_filter - bilinear filter between
four pixel values; this code is derived from
code provided by Michael Herf
-------------------------------------------------*/
INLINE void rgbaint_bilinear_filter(rgbaint *color, UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
{
UINT32 ag0, ag1, rb0, rb1;
rb0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8);
rb1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8);
rgb00 = rgb00 >> 8;
rgb01 = rgb01 >> 8;
rgb10 = rgb10 >> 8;
rgb11 = rgb11 >> 8;
ag0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8);
ag1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8);
rb0 = (rb0 & 0x00ff00ff) + ((((rb1 & 0x00ff00ff) - (rb0 & 0x00ff00ff)) * v) >> 8);
ag0 = (ag0 & 0x00ff00ff) + ((((ag1 & 0x00ff00ff) - (ag0 & 0x00ff00ff)) * v) >> 8);
color->a = ag0 >> 16;
color->r = rb0 >> 16;
color->g = ag0;
color->b = rb0;
}
#endif /* __RGBUTIL__ */

View File

@ -1,5 +1,5 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Vas Crabb,Ryan Holtz // copyright-holders:Vas Crabb, Ryan Holtz
/*************************************************************************** /***************************************************************************
rgbsse.c rgbsse.c
@ -14,77 +14,60 @@
#include <emmintrin.h> #include <emmintrin.h>
#include "rgbutil.h" #include "rgbutil.h"
void rgbint_t::print()
{
printf("%04x ", _mm_extract_epi16(m_value, 7));
printf("%04x ", _mm_extract_epi16(m_value, 6));
printf("%04x ", _mm_extract_epi16(m_value, 5));
printf("%04x ", _mm_extract_epi16(m_value, 4));
printf("%04x ", _mm_extract_epi16(m_value, 3));
printf("%04x ", _mm_extract_epi16(m_value, 2));
printf("%04x ", _mm_extract_epi16(m_value, 1));
printf("%04x\n", _mm_extract_epi16(m_value, 0));
}
/*************************************************************************** /***************************************************************************
HIGHER LEVEL OPERATIONS HIGHER LEVEL OPERATIONS
***************************************************************************/ ***************************************************************************/
void rgbint_t::blend(const rgbint_t& other, UINT8 factor) void rgbaint_t::blend(const rgbaint_t& other, UINT8 factor)
{ {
m_value = _mm_unpacklo_epi16(m_value, other.m_value); m_value = _mm_unpacklo_epi16(m_value, other.m_value);
m_value = _mm_madd_epi16(m_value, *(__m128i *)&rgbsse_statics.scale_table[factor][0]); m_value = _mm_madd_epi16(m_value, *(__m128i *)&rgbsse_statics.scale_table[factor][0]);
m_value = _mm_srli_epi32(m_value, 8); m_value = _mm_srli_epi32(m_value, 8);
} }
void rgbint_t::scale_and_clamp(const rgbint_t& scale) void rgbaint_t::scale_and_clamp(const rgbaint_t& scale)
{ {
__m128i mscale = _mm_unpacklo_epi16(scale.m_value, _mm_setzero_si128()); mul(scale);
m_value = _mm_unpacklo_epi16(m_value, _mm_setzero_si128()); shr(8);
m_value = _mm_madd_epi16(m_value, mscale); min(255);
m_value = _mm_srli_epi32(m_value, 8);
m_value = _mm_min_epi16(m_value, *(__m128i *)&rgbsse_statics.maxbyte);
} }
void rgbint_t::scale_imm_and_clamp(const INT16 scale) void rgbaint_t::scale_imm_and_clamp(const INT32 scale)
{ {
__m128i mscale = _mm_set1_epi16(scale); mul_imm(scale);
m_value = _mm_unpacklo_epi16(m_value, _mm_setzero_si128()); shr(8);
m_value = _mm_madd_epi16(m_value, mscale); min(255);
m_value = _mm_srli_epi32(m_value, 8);
m_value = _mm_min_epi16(m_value, *(__m128i *)&rgbsse_statics.maxbyte);
} }
void rgbint_t::scale_add_and_clamp(const rgbint_t& scale, const rgbint_t& other, const rgbint_t& scale2) void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2)
{ {
__m128i mscale = _mm_unpacklo_epi16(scale.m_value, scale2.m_value); mul(scale);
m_value = _mm_unpacklo_epi16(m_value, other.m_value); rgbaint_t color2(other);
m_value = _mm_madd_epi16(m_value, mscale); color2.mul(scale2);
m_value = _mm_srli_epi32(m_value, 8);
m_value = _mm_min_epi16(m_value, *(__m128i *)&rgbsse_statics.maxbyte); mul(scale);
add(color2);
shr(8);
min(255);
} }
void rgbint_t::scale_imm_add_and_clamp(const INT16 scale, const rgbint_t& other) void rgbaint_t::scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other)
{ {
// color2 will get mutiplied by 2^8 (256) and then divided by 2^8 by the shift by 8 mul_imm(scale);
__m128i mscale = _mm_unpacklo_epi16(_mm_set1_epi16(scale), _mm_set_epi16(0, 0, 0, 0, 256, 256, 256, 256)); add(other);
m_value = _mm_unpacklo_epi16(m_value, other.m_value); shr(8);
m_value = _mm_madd_epi16(m_value, mscale); min(255);
m_value = _mm_srli_epi32(m_value, 8);
m_value = _mm_min_epi16(m_value, *(__m128i *)&rgbsse_statics.maxbyte);
} }
void rgbint_t::scale_add_and_clamp(const rgbint_t& scale, const rgbint_t& other) void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other)
{ {
// color2 will get mutiplied by 2^8 (256) and then divided by 2^8 by the shift by 8 mul(scale);
__m128i mscale = _mm_unpacklo_epi16(scale.m_value, _mm_set_epi16(0, 0, 0, 0, 256, 256, 256, 256)); add(other);
m_value = _mm_unpacklo_epi16(m_value, other.m_value); shr(8);
m_value = _mm_madd_epi16(m_value, mscale); min(255);
m_value = _mm_srli_epi32(m_value, 8);
m_value = _mm_min_epi16(m_value, *(__m128i *)&rgbsse_statics.maxbyte);
} }
UINT32 rgbint_t::bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v) UINT32 rgbaint_t::bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
{ {
__m128i color00 = _mm_cvtsi32_si128(rgb00); __m128i color00 = _mm_cvtsi32_si128(rgb00);
__m128i color01 = _mm_cvtsi32_si128(rgb01); __m128i color01 = _mm_cvtsi32_si128(rgb01);

View File

@ -1,5 +1,5 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Vas Crabb // copyright-holders:Vas Crabb, Ryan Holtz
/*************************************************************************** /***************************************************************************
rgbsse.h rgbsse.h
@ -34,144 +34,143 @@ extern const struct _rgbsse_statics
TYPE DEFINITIONS TYPE DEFINITIONS
***************************************************************************/ ***************************************************************************/
class rgbint_t class rgbaint_t
{ {
public: public:
inline rgbint_t() { } inline rgbaint_t() { }
inline rgbint_t(UINT32 rgb) { set_rgb(rgb); } inline rgbaint_t(UINT32 rgba) { set(rgba); }
inline rgbint_t(UINT32 r, UINT32 g, UINT32 b) { set_rgb(r, g, b); } inline rgbaint_t(UINT32 a, UINT32 r, UINT32 g, UINT32 b) { set(a, r, g, b); }
inline rgbint_t(rgb_t& rgb) { m_value = _mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128()); } inline rgbaint_t(rgb_t& rgba) { set(rgba); }
inline void set(void* value) { m_value = *(__m128i*)value; } inline void set(rgbaint_t& other) { m_value = other.m_value; }
inline __m128i get() { return m_value; } inline void set(UINT32 rgba) { m_value = _mm_and_si128(_mm_set1_epi32(0xff), _mm_set_epi32(rgba >> 24, rgba >> 16, rgba >> 8, rgba)); }
inline void set(__m128i value) { m_value = value; } inline void set(UINT32 a, UINT32 r, UINT32 g, UINT32 b) { m_value = _mm_set_epi32(a, r, g, b); }
inline void set(rgbint_t& other) { m_value = other.m_value; } inline void set(rgb_t& rgb) { m_value = _mm_unpacklo_epi16(_mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128()), _mm_setzero_si128()); }
inline void set_rgb(UINT32 rgb) { m_value = _mm_and_si128(_mm_set1_epi32(0xff), _mm_set_epi32(0, rgb, rgb >> 8, rgb >> 16)); }
inline void set_rgb(INT32 r, INT32 g, INT32 b) { m_value = _mm_set_epi32(0, r, g, b); }
inline void set_rgb(rgb_t& rgb) { m_value = _mm_unpacklo_epi16(_mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128()), _mm_setzero_si128()); }
inline rgb_t to_rgb() inline rgb_t to_rgba()
{ {
__m128i anded = _mm_and_si128(m_value, _mm_set1_epi32(0x000000ff)); __m128i anded = _mm_and_si128(m_value, _mm_set1_epi32(0x000000ff));
return _mm_cvtsi128_si32(_mm_packus_epi16(_mm_packs_epi32(anded, anded), _mm_setzero_si128())); return _mm_cvtsi128_si32(_mm_packus_epi16(_mm_packs_epi32(anded, anded), _mm_setzero_si128()));
} }
inline rgb_t to_rgb_clamp() inline rgb_t to_rgba_clamp()
{ {
return _mm_cvtsi128_si32(_mm_packus_epi16(_mm_packs_epi32(m_value, m_value), _mm_setzero_si128())); return _mm_cvtsi128_si32(_mm_packus_epi16(_mm_packs_epi32(m_value, m_value), _mm_setzero_si128()));
} }
inline rgb_t to_rgba() inline void add(const rgbaint_t& color2)
{
return to_rgb();
}
inline rgb_t to_rgba_clamp()
{
return to_rgb_clamp();
}
inline void add(const rgbint_t& color2)
{ {
m_value = _mm_add_epi32(m_value, color2.m_value); m_value = _mm_add_epi32(m_value, color2.m_value);
} }
inline void add_imm(const INT32 imm) inline void add_imm(const UINT32 imm)
{ {
__m128i temp = _mm_set1_epi32(imm); m_value = _mm_add_epi32(m_value, _mm_set1_epi32(imm));
m_value = _mm_add_epi32(m_value, temp);
} }
inline void add_imm_rgb(const INT32 r, const INT32 g, const INT32 b) inline void add_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
{ {
__m128i temp = _mm_set_epi32(0, r, g, b); m_value = _mm_add_epi32(m_value, _mm_set_epi32(a, r, g, b));
m_value = _mm_add_epi32(m_value, temp);
} }
inline void sub(const rgbint_t& color2) inline void sub(const rgbaint_t& color2)
{ {
m_value = _mm_sub_epi32(m_value, color2.m_value); m_value = _mm_sub_epi32(m_value, color2.m_value);
} }
inline void sub_imm(const INT32 imm) inline void sub_imm(const UINT32 imm)
{ {
m_value = _mm_sub_epi32(m_value, _mm_set1_epi32(imm)); m_value = _mm_sub_epi32(m_value, _mm_set1_epi32(imm));
} }
inline void sub_imm_rgb(const INT32 r, const INT32 g, const INT32 b) inline void sub_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
{ {
m_value = _mm_sub_epi32(m_value, _mm_set_epi32(0, r, g, b)); m_value = _mm_sub_epi32(m_value, _mm_set_epi32(a, r, g, b));
} }
inline void subr(rgbint_t& color2) inline void subr(rgbaint_t& color2)
{ {
m_value = _mm_sub_epi32(color2.m_value, m_value); m_value = _mm_sub_epi32(color2.m_value, m_value);
} }
inline void subr_imm(const INT32 imm) inline void subr_imm(const UINT32 imm)
{ {
m_value = _mm_sub_epi32(_mm_set1_epi32(imm), m_value); m_value = _mm_sub_epi32(_mm_set1_epi32(imm), m_value);
} }
inline void subr_imm_rgb(const INT32 r, const INT32 g, const INT32 b) inline void subr_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
{ {
__m128i temp = _mm_set_epi32(0, r, g, b); m_value = _mm_sub_epi32(_mm_set_epi32(a, r, g, b), m_value);
m_value = _mm_sub_epi32(temp, m_value);
} }
inline void set_r(const INT32 value) inline void set_a(const UINT32 value)
{
m_value = _mm_or_si128(_mm_and_si128(m_value, *(__m128i *)&rgbsse_statics.alpha_mask), _mm_set_epi32(value, 0, 0, 0));
}
inline void set_r(const UINT32 value)
{ {
m_value = _mm_or_si128(_mm_and_si128(m_value, *(__m128i *)&rgbsse_statics.red_mask), _mm_set_epi32(0, value, 0, 0)); m_value = _mm_or_si128(_mm_and_si128(m_value, *(__m128i *)&rgbsse_statics.red_mask), _mm_set_epi32(0, value, 0, 0));
} }
inline void set_g(const INT32 value) inline void set_g(const UINT32 value)
{ {
m_value = _mm_or_si128(_mm_and_si128(m_value, *(__m128i *)&rgbsse_statics.green_mask), _mm_set_epi32(0, 0, value, 0)); m_value = _mm_or_si128(_mm_and_si128(m_value, *(__m128i *)&rgbsse_statics.green_mask), _mm_set_epi32(0, 0, value, 0));
} }
inline void set_b(const INT32 value) inline void set_b(const UINT32 value)
{ {
m_value = _mm_or_si128(_mm_and_si128(m_value, *(__m128i *)&rgbsse_statics.blue_mask), _mm_set_epi32(0, 0, 0, value)); m_value = _mm_or_si128(_mm_and_si128(m_value, *(__m128i *)&rgbsse_statics.blue_mask), _mm_set_epi32(0, 0, 0, value));
} }
inline UINT8 get_a()
{
return _mm_extract_epi16(m_value, 6);
}
inline UINT8 get_r() inline UINT8 get_r()
{
return _mm_extract_epi16(m_value, 4) & 0xff;
}
inline UINT8 get_g()
{
return _mm_extract_epi16(m_value, 2) & 0xff;
}
inline UINT8 get_b()
{
return _mm_extract_epi16(m_value, 0) & 0xff;
}
inline UINT16 get_r32()
{ {
return _mm_extract_epi16(m_value, 4); return _mm_extract_epi16(m_value, 4);
} }
inline UINT16 get_g32() inline UINT8 get_g()
{ {
return _mm_extract_epi16(m_value, 2); return _mm_extract_epi16(m_value, 2);
} }
inline UINT16 get_b32() inline UINT8 get_b()
{ {
return _mm_extract_epi16(m_value, 0); return _mm_extract_epi16(m_value, 0);
} }
inline void mul(rgbint_t& color) inline UINT16 get_a32()
{
return (_mm_extract_epi16(m_value, 7) << 16) | _mm_extract_epi16(m_value, 6);
}
inline UINT16 get_r32()
{
return (_mm_extract_epi16(m_value, 5) << 16) | _mm_extract_epi16(m_value, 4);
}
inline UINT16 get_g32()
{
return (_mm_extract_epi16(m_value, 3) << 16) | _mm_extract_epi16(m_value, 2);
}
inline UINT16 get_b32()
{
return (_mm_extract_epi16(m_value, 1) << 16) | _mm_extract_epi16(m_value, 0);
}
inline void mul(const rgbaint_t& color)
{ {
__m128i tmp1 = _mm_mul_epu32(m_value, color.m_value); __m128i tmp1 = _mm_mul_epu32(m_value, color.m_value);
__m128i tmp2 = _mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(color.m_value, 4)); __m128i tmp2 = _mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(color.m_value, 4));
m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(tmp2, _MM_SHUFFLE(0, 0, 2, 0))); m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(tmp2, _MM_SHUFFLE(0, 0, 2, 0)));
} }
inline void mul_imm(const INT32 imm) inline void mul_imm(const UINT32 imm)
{ {
__m128i immv = _mm_set1_epi32(imm); __m128i immv = _mm_set1_epi32(imm);
__m128i tmp1 = _mm_mul_epu32(m_value, immv); __m128i tmp1 = _mm_mul_epu32(m_value, immv);
@ -179,15 +178,15 @@ public:
m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(tmp2, _MM_SHUFFLE(0, 0, 2, 0))); m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(tmp2, _MM_SHUFFLE(0, 0, 2, 0)));
} }
inline void mul_imm_rgb(const INT32 r, const INT32 g, const INT32 b) inline void mul_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
{ {
__m128i immv = _mm_set_epi32(0, r, g, b); __m128i immv = _mm_set_epi32(a, r, g, b);
__m128i tmp1 = _mm_mul_epu32(m_value, immv); __m128i tmp1 = _mm_mul_epu32(m_value, immv);
__m128i tmp2 = _mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(immv, 4)); __m128i tmp2 = _mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(immv, 4));
m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(tmp2, _MM_SHUFFLE(0, 0, 2, 0))); m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(tmp2, _MM_SHUFFLE(0, 0, 2, 0)));
} }
inline void shl(const rgbint_t& shift) inline void shl(const rgbaint_t& shift)
{ {
m_value = _mm_sll_epi32(m_value, shift.m_value); m_value = _mm_sll_epi32(m_value, shift.m_value);
} }
@ -202,7 +201,7 @@ public:
m_value = _mm_slli_si128(m_value, shift >> 3); m_value = _mm_slli_si128(m_value, shift >> 3);
} }
inline void shr(const rgbint_t& shift) inline void shr(const rgbaint_t& shift)
{ {
m_value = _mm_srl_epi32(m_value, shift.m_value); m_value = _mm_srl_epi32(m_value, shift.m_value);
} }
@ -217,7 +216,7 @@ public:
m_value = _mm_srli_si128(m_value, shift >> 3); m_value = _mm_srli_si128(m_value, shift >> 3);
} }
inline void sra(const rgbint_t& shift) inline void sra(const rgbaint_t& shift)
{ {
m_value = _mm_sra_epi32(m_value, shift.m_value); m_value = _mm_sra_epi32(m_value, shift.m_value);
} }
@ -227,32 +226,37 @@ public:
m_value = _mm_srai_epi32(m_value, shift); m_value = _mm_srai_epi32(m_value, shift);
} }
inline void or_reg(const rgbint_t& color2) inline void or_reg(const rgbaint_t& color2)
{ {
m_value = _mm_or_si128(m_value, color2.m_value); m_value = _mm_or_si128(m_value, color2.m_value);
} }
inline void or_imm(const INT32 value) inline void or_imm(const UINT32 value)
{ {
m_value = _mm_or_si128(m_value, _mm_set1_epi32(value)); m_value = _mm_or_si128(m_value, _mm_set1_epi32(value));
} }
inline void and_reg(const rgbint_t& color) inline void or_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
{
m_value = _mm_or_si128(m_value, _mm_set_epi32(a, r, g, b));
}
inline void and_reg(const rgbaint_t& color)
{ {
m_value = _mm_and_si128(m_value, color.m_value); m_value = _mm_and_si128(m_value, color.m_value);
} }
inline void and_imm(const INT32 value) inline void and_imm(const UINT32 value)
{ {
m_value = _mm_and_si128(m_value, _mm_set1_epi32(value)); m_value = _mm_and_si128(m_value, _mm_set1_epi32(value));
} }
inline void and_imm_rgb(const INT32 r, const INT32 g, const INT32 b) inline void and_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
{ {
m_value = _mm_and_si128(m_value, _mm_set_epi32(0xffffffff, r, g, b)); m_value = _mm_and_si128(m_value, _mm_set_epi32(a, r, g, b));
} }
inline void xor_reg(const rgbint_t& color2) inline void xor_reg(const rgbaint_t& color2)
{ {
m_value = _mm_xor_si128(m_value, color2.m_value); m_value = _mm_xor_si128(m_value, color2.m_value);
} }
@ -262,34 +266,22 @@ public:
m_value = _mm_xor_si128(m_value, _mm_set1_epi32(value)); m_value = _mm_xor_si128(m_value, _mm_set1_epi32(value));
} }
inline void clamp_and_clear(const rgbint_t& color, const INT32 sign) inline void xor_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
{
m_value = _mm_xor_si128(m_value, _mm_set_epi32(a, r, g, b));
}
inline void clamp_and_clear(const UINT32 sign)
{ {
__m128i vsign = _mm_set1_epi32(sign); __m128i vsign = _mm_set1_epi32(sign);
m_value = _mm_and_si128(color.m_value, _mm_cmpeq_epi32(_mm_and_si128(color.m_value, vsign), _mm_setzero_si128())); m_value = _mm_and_si128(m_value, _mm_cmpeq_epi32(_mm_and_si128(m_value, vsign), _mm_setzero_si128()));
vsign = _mm_srai_epi32(vsign, 1); vsign = _mm_srai_epi32(vsign, 1);
vsign = _mm_xor_si128(vsign, _mm_set1_epi32(0xffffffff)); vsign = _mm_xor_si128(vsign, _mm_set1_epi32(0xffffffff));
__m128i mask = _mm_cmpgt_epi32(m_value, vsign); // m_value > vsign ? 0xffffffff : 0 __m128i mask = _mm_cmpgt_epi32(m_value, vsign);
m_value = _mm_or_si128(_mm_and_si128(vsign, mask), _mm_and_si128(m_value, _mm_xor_si128(mask, _mm_set1_epi32(0xffffffff)))); m_value = _mm_or_si128(_mm_and_si128(vsign, mask), _mm_and_si128(m_value, _mm_xor_si128(mask, _mm_set1_epi32(0xffffffff))));
} }
inline void min(const INT32 value) inline void sign_extend(const UINT32 compare, const UINT32 sign)
{
__m128i val = _mm_set1_epi32(value);
__m128i mask = _mm_cmpgt_epi32(m_value, val); // m_value > value ? 0xffffffff : 0
m_value = _mm_or_si128(_mm_and_si128(val, mask), _mm_and_si128(m_value, _mm_xor_si128(mask, _mm_set1_epi32(0xffffffff))));
}
void blend(const rgbint_t& other, UINT8 factor);
void scale_and_clamp(const rgbint_t& scale);
void scale_imm_and_clamp(const INT16 scale);
void scale_add_and_clamp(const rgbint_t& scale, const rgbint_t& other, const rgbint_t& scale2);
void scale_add_and_clamp(const rgbint_t& scale, const rgbint_t& other);
void scale_imm_add_and_clamp(const INT16 scale, const rgbint_t& other);
void max(const rgbint_t& max);
inline void sign_extend(const INT32 compare, const INT32 sign)
{ {
__m128i compare_vec = _mm_set1_epi32(compare); __m128i compare_vec = _mm_set1_epi32(compare);
__m128i compare_mask = _mm_cmpeq_epi32(_mm_and_si128(m_value, compare_vec), compare_vec); __m128i compare_mask = _mm_cmpeq_epi32(_mm_and_si128(m_value, compare_vec), compare_vec);
@ -297,9 +289,22 @@ public:
m_value = _mm_or_si128(m_value, compared); m_value = _mm_or_si128(m_value, compared);
} }
void print(); inline void min(const UINT32 value)
{
__m128i val = _mm_set1_epi32(value);
__m128i mask = _mm_cmpgt_epi32(m_value, val);
m_value = _mm_or_si128(_mm_and_si128(val, mask), _mm_and_si128(m_value, _mm_xor_si128(mask, _mm_set1_epi32(0xffffffff))));
}
inline void cmpeq(const rgbint_t& value) void blend(const rgbaint_t& other, UINT8 factor);
void scale_and_clamp(const rgbaint_t& scale);
void scale_imm_and_clamp(const INT32 scale);
void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2);
void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other);
void scale_imm_add_and_clamp(const INT32 scale, const rgbaint_t& other);
inline void cmpeq(const rgbaint_t& value)
{ {
m_value = _mm_cmpeq_epi32(m_value, value.m_value); m_value = _mm_cmpeq_epi32(m_value, value.m_value);
} }
@ -309,134 +314,94 @@ public:
m_value = _mm_cmpeq_epi32(m_value, _mm_set1_epi32(value)); m_value = _mm_cmpeq_epi32(m_value, _mm_set1_epi32(value));
} }
inline void cmpgt(const rgbint_t& value) inline void cmpeq_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
{
m_value = _mm_cmpeq_epi32(m_value, _mm_set_epi32(a, r, g, b));
}
inline void cmpgt(const rgbaint_t& value)
{ {
m_value = _mm_cmpgt_epi32(m_value, value.m_value); m_value = _mm_cmpgt_epi32(m_value, value.m_value);
} }
inline void cmplt(const rgbint_t& value) inline void cmpgt_imm(const UINT32 value)
{
m_value = _mm_cmpgt_epi32(m_value, _mm_set1_epi32(value));
}
inline void cmpgt_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
{
m_value = _mm_cmpgt_epi32(m_value, _mm_set_epi32(a, r, g, b));
}
inline void cmplt(const rgbaint_t& value)
{ {
m_value = _mm_cmplt_epi32(m_value, value.m_value); m_value = _mm_cmplt_epi32(m_value, value.m_value);
} }
inline rgbint_t operator=(const rgbint_t& other) inline void cmplt_imm(const UINT32 value)
{
m_value = _mm_cmplt_epi32(m_value, _mm_set1_epi32(value));
}
inline void cmplt_imm_rgba(const UINT32 a, const UINT32 r, const UINT32 g, const UINT32 b)
{
m_value = _mm_cmplt_epi32(m_value, _mm_set_epi32(a, r, g, b));
}
inline rgbaint_t operator=(const rgbaint_t& other)
{ {
m_value = other.m_value; m_value = other.m_value;
return *this; return *this;
} }
inline rgbint_t& operator+=(const rgbint_t& other) inline rgbaint_t& operator+=(const rgbaint_t& other)
{ {
m_value = _mm_add_epi32(m_value, other.m_value); m_value = _mm_add_epi32(m_value, other.m_value);
return *this; return *this;
} }
inline rgbint_t& operator+=(const INT32 other) inline rgbaint_t& operator+=(const INT32 other)
{ {
m_value = _mm_add_epi32(m_value, _mm_set1_epi32(other)); m_value = _mm_add_epi32(m_value, _mm_set1_epi32(other));
return *this; return *this;
} }
inline rgbint_t& operator-=(const rgbint_t& other) inline rgbaint_t& operator-=(const rgbaint_t& other)
{ {
m_value = _mm_sub_epi32(m_value, other.m_value); m_value = _mm_sub_epi32(m_value, other.m_value);
return *this; return *this;
} }
inline rgbint_t& operator*=(const rgbint_t& other) inline rgbaint_t& operator*=(const rgbaint_t& other)
{ {
m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(_mm_mul_epu32(m_value, other.m_value), _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(other.m_value, 4)), _MM_SHUFFLE(0, 0, 2, 0))); m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(_mm_mul_epu32(m_value, other.m_value), _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(other.m_value, 4)), _MM_SHUFFLE(0, 0, 2, 0)));
return *this; return *this;
} }
inline rgbint_t& operator*=(const INT32 other) inline rgbaint_t& operator*=(const INT32 other)
{ {
const __m128i immv = _mm_set1_epi32(other); const __m128i immv = _mm_set1_epi32(other);
m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(_mm_mul_epu32(m_value, immv), _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(immv, 4)), _MM_SHUFFLE(0, 0, 2, 0))); m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(_mm_mul_epu32(m_value, immv), _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(immv, 4)), _MM_SHUFFLE(0, 0, 2, 0)));
return *this; return *this;
} }
inline rgbint_t& operator>>=(const INT32 shift) inline rgbaint_t& operator>>=(const INT32 shift)
{ {
m_value = _mm_srai_epi32(m_value, shift); m_value = _mm_srai_epi32(m_value, shift);
return *this; return *this;
} }
static UINT32 bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v);
protected:
__m128i m_value;
private:
rgbint_t(__m128i value);
};
class rgbaint_t : public rgbint_t
{
public:
inline rgbaint_t() { }
inline rgbaint_t(UINT32 rgba) { m_value = _mm_and_si128(_mm_set1_epi32(0xff), _mm_set_epi32(rgba >> 24, rgba >> 16, rgba >> 8, rgba)); }
inline rgbaint_t(UINT32 a, UINT32 r, UINT32 g, UINT32 b) { set_rgba(a, r, g, b); }
inline rgbaint_t(rgb_t& rgba) { m_value = _mm_unpacklo_epi8(_mm_cvtsi32_si128(rgba), _mm_setzero_si128()); }
inline void set(rgbaint_t& other) { m_value = other.m_value; }
inline void set(__m128i value) { m_value = value; }
inline void set_rgba(INT32 a, INT32 r, INT32 g, INT32 b)
{
m_value = _mm_set_epi32(a, r, g, b);
}
inline void set_a(const INT32 value)
{
m_value = _mm_or_si128(_mm_and_si128(m_value, *(__m128i *)&rgbsse_statics.alpha_mask), _mm_set_epi32(value, 0, 0, 0));
}
inline UINT8 get_a()
{
return _mm_extract_epi16(m_value, 6) & 0xff;
}
inline UINT16 get_a32()
{
return _mm_extract_epi16(m_value, 6);
}
inline void and_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
m_value = _mm_and_si128(m_value, _mm_set_epi32(a, r, g, b));
}
inline void add_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
__m128i temp = _mm_set_epi32(a, r, g, b);
m_value = _mm_add_epi32(m_value, temp);
}
inline void sub_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
__m128i temp = _mm_set_epi32(a, r, g, b);
m_value = _mm_sub_epi32(m_value, temp);
}
inline void subr_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
__m128i temp = _mm_set_epi32(a, r, g, b);
m_value = _mm_sub_epi32(temp, m_value);
}
inline void mul_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b)
{
__m128i immv = _mm_set_epi32(a, r, g, b);
__m128i tmp1 = _mm_mul_epu32(m_value, immv);
__m128i tmp2 = _mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(immv, 4));
m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(tmp2, _MM_SHUFFLE(0, 0, 2, 0)));
}
inline void merge_alpha(rgbaint_t& alpha) inline void merge_alpha(rgbaint_t& alpha)
{ {
m_value = _mm_insert_epi16(m_value, _mm_extract_epi16(alpha.m_value, 7), 7); m_value = _mm_insert_epi16(m_value, _mm_extract_epi16(alpha.m_value, 7), 7);
m_value = _mm_insert_epi16(m_value, _mm_extract_epi16(alpha.m_value, 6), 6); m_value = _mm_insert_epi16(m_value, _mm_extract_epi16(alpha.m_value, 6), 6);
} }
static UINT32 bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v);
protected:
__m128i m_value;
}; };
#endif /* __RGBSSE__ */ #endif /* __RGBSSE__ */

View File

@ -2199,33 +2199,33 @@ while (0)
/* use SSE on 64-bit implementations, where it can be assumed */ /* use SSE on 64-bit implementations, where it can be assumed */
#if (!defined(MAME_DEBUG) || defined(__OPTIMIZE__)) && (defined(__SSE2__) || defined(_MSC_VER)) && defined(PTR64) #if (!defined(MAME_DEBUG) || defined(__OPTIMIZE__)) && (defined(__SSE2__) || defined(_MSC_VER)) && defined(PTR64)
// NB: This code should no longer be SSE2-specific now that it uses rgbaint_t, consider removing the #define and the #else case.
INLINE UINT32 clampARGB(INT32 iterr, INT32 iterg, INT32 iterb, INT32 itera, UINT32 FBZCP) INLINE UINT32 clampARGB(INT32 iterr, INT32 iterg, INT32 iterb, INT32 itera, UINT32 FBZCP)
{ {
rgb_t result; rgb_t result;
rgbaint_t colorint((INT16) (itera>>12), (INT16) (iterr>>12), (INT16) (iterg>>12), (INT16) (iterb>>12)); rgbaint_t colorint((INT32) (itera>>12), (INT32) (iterr>>12), (INT32) (iterg>>12), (INT32) (iterb>>12));
if (FBZCP_RGBZW_CLAMP(FBZCP) == 0) if (FBZCP_RGBZW_CLAMP(FBZCP) == 0)
{ {
//r &= 0xfff; //r &= 0xfff;
__m128i temp = _mm_set1_epi16(0xfff); colorint.and_imm(0xfff);
colorint.set(_mm_and_si128(colorint.get(), temp));
//if (r == 0xfff) //if (r == 0xfff)
temp = _mm_cmpeq_epi16(colorint.get(), temp); rgbaint_t temp(colorint);
temp.cmpeq_imm(0xfff);
// result.rgb.r = 0; // result.rgb.r = 0;
colorint.set(_mm_andnot_si128(temp, colorint.get())); temp.xor_imm(0xffffffff);
colorint.and_reg(temp);
//else if (r == 0x100) //else if (r == 0x100)
temp = _mm_set1_epi16(0x100); temp.set(colorint);
temp = _mm_cmpeq_epi16(colorint.get(), temp); temp.cmpeq_imm(0x100);
// result.rgb.r = 0xff; // result.rgb.r = 0xff;
colorint.set(_mm_or_si128(colorint.get(), temp));
result = colorint.to_rgba(); return colorint.to_rgba();
} }
else else
{ {
result = colorint.to_rgba_clamp(); return colorint.to_rgba_clamp();
} }
return result;
} }
#else #else
@ -2841,19 +2841,19 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
{ {
default: /* reserved */ default: /* reserved */
case 0: /* AZERO */ case 0: /* AZERO */
srcScale.set_rgba(srcAlphaScale, 0, 0, 0); srcScale.set(srcAlphaScale, 0, 0, 0);
//(RR) = (GG) = (BB) = 0; //(RR) = (GG) = (BB) = 0;
break; break;
case 1: /* ASRC_ALPHA */ case 1: /* ASRC_ALPHA */
srcScale.set_rgba(srcAlphaScale, sa, sa, sa); srcScale.set(srcAlphaScale, sa, sa, sa);
//(RR) = (sr * (sa + 1)) >> 8; //(RR) = (sr * (sa + 1)) >> 8;
//(GG) = (sg * (sa + 1)) >> 8; //(GG) = (sg * (sa + 1)) >> 8;
//(BB) = (sb * (sa + 1)) >> 8; //(BB) = (sb * (sa + 1)) >> 8;
break; break;
case 2: /* A_COLOR */ case 2: /* A_COLOR */
srcScale.set_rgba(srcAlphaScale-1, dr, dg, db); srcScale.set(srcAlphaScale-1, dr, dg, db);
srcScale.add_imm(1); srcScale.add_imm(1);
//(RR) = (sr * (dr + 1)) >> 8; //(RR) = (sr * (dr + 1)) >> 8;
//(GG) = (sg * (dg + 1)) >> 8; //(GG) = (sg * (dg + 1)) >> 8;
@ -2862,26 +2862,26 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
case 3: /* ADST_ALPHA */ case 3: /* ADST_ALPHA */
ta = da + 1; ta = da + 1;
srcScale.set_rgba(srcAlphaScale, ta, ta, ta); srcScale.set(srcAlphaScale, ta, ta, ta);
//(RR) = (sr * (da + 1)) >> 8; //(RR) = (sr * (da + 1)) >> 8;
//(GG) = (sg * (da + 1)) >> 8; //(GG) = (sg * (da + 1)) >> 8;
//(BB) = (sb * (da + 1)) >> 8; //(BB) = (sb * (da + 1)) >> 8;
break; break;
case 4: /* AONE */ case 4: /* AONE */
srcScale.set_rgba(srcAlphaScale, 256, 256, 256); srcScale.set(srcAlphaScale, 256, 256, 256);
break; break;
case 5: /* AOMSRC_ALPHA */ case 5: /* AOMSRC_ALPHA */
ta = (0x100 - sa); ta = (0x100 - sa);
srcScale.set_rgba(srcAlphaScale, ta, ta, ta); srcScale.set(srcAlphaScale, ta, ta, ta);
//(RR) = (sr * (0x100 - sa)) >> 8; //(RR) = (sr * (0x100 - sa)) >> 8;
//(GG) = (sg * (0x100 - sa)) >> 8; //(GG) = (sg * (0x100 - sa)) >> 8;
//(BB) = (sb * (0x100 - sa)) >> 8; //(BB) = (sb * (0x100 - sa)) >> 8;
break; break;
case 6: /* AOM_COLOR */ case 6: /* AOM_COLOR */
srcScale.set_rgba(srcAlphaScale, (0x100 - dr), (0x100 - dg), (0x100 - db)); srcScale.set(srcAlphaScale, (0x100 - dr), (0x100 - dg), (0x100 - db));
//(RR) = (sr * (0x100 - dr)) >> 8; //(RR) = (sr * (0x100 - dr)) >> 8;
//(GG) = (sg * (0x100 - dg)) >> 8; //(GG) = (sg * (0x100 - dg)) >> 8;
//(BB) = (sb * (0x100 - db)) >> 8; //(BB) = (sb * (0x100 - db)) >> 8;
@ -2889,7 +2889,7 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
case 7: /* AOMDST_ALPHA */ case 7: /* AOMDST_ALPHA */
ta = (0x100 - da); ta = (0x100 - da);
srcScale.set_rgba(srcAlphaScale, ta, ta, ta); srcScale.set(srcAlphaScale, ta, ta, ta);
//(RR) = (sr * (0x100 - da)) >> 8; //(RR) = (sr * (0x100 - da)) >> 8;
//(GG) = (sg * (0x100 - da)) >> 8; //(GG) = (sg * (0x100 - da)) >> 8;
//(BB) = (sb * (0x100 - da)) >> 8; //(BB) = (sb * (0x100 - da)) >> 8;
@ -2897,7 +2897,7 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
case 15: /* ASATURATE */ case 15: /* ASATURATE */
ta = (sa < (0x100 - da)) ? sa : (0x100 - da); ta = (sa < (0x100 - da)) ? sa : (0x100 - da);
srcScale.set_rgba(srcAlphaScale, ta, ta, ta); srcScale.set(srcAlphaScale, ta, ta, ta);
//(RR) = (sr * (ta + 1)) >> 8; //(RR) = (sr * (ta + 1)) >> 8;
//(GG) = (sg * (ta + 1)) >> 8; //(GG) = (sg * (ta + 1)) >> 8;
//(BB) = (sb * (ta + 1)) >> 8; //(BB) = (sb * (ta + 1)) >> 8;
@ -2915,11 +2915,11 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
{ {
default: /* reserved */ default: /* reserved */
case 0: /* AZERO */ case 0: /* AZERO */
destScale.set_rgba(destAlphaScale, 0, 0, 0); destScale.set(destAlphaScale, 0, 0, 0);
break; break;
case 1: /* ASRC_ALPHA */ case 1: /* ASRC_ALPHA */
destScale.set_rgba(destAlphaScale, sa, sa, sa); destScale.set(destAlphaScale, sa, sa, sa);
destScale.add_imm(1); destScale.add_imm(1);
//(RR) += (dr * (sa + 1)) >> 8; //(RR) += (dr * (sa + 1)) >> 8;
//(GG) += (dg * (sa + 1)) >> 8; //(GG) += (dg * (sa + 1)) >> 8;
@ -2927,7 +2927,7 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
break; break;
case 2: /* A_COLOR */ case 2: /* A_COLOR */
destScale.set_rgb((rgb_t) (((destAlphaScale-1)<<24) | (color.u & 0x00ffffff))); destScale.set((rgb_t) (((destAlphaScale-1)<<24) | (color.u & 0x00ffffff)));
destScale.add_imm(1); destScale.add_imm(1);
//(RR) += (dr * (sr + 1)) >> 8; //(RR) += (dr * (sr + 1)) >> 8;
//(GG) += (dg * (sg + 1)) >> 8; //(GG) += (dg * (sg + 1)) >> 8;
@ -2936,14 +2936,14 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
case 3: /* ADST_ALPHA */ case 3: /* ADST_ALPHA */
ta = da + 1; ta = da + 1;
destScale.set_rgba(destAlphaScale, ta, ta, ta); destScale.set(destAlphaScale, ta, ta, ta);
//(RR) += (dr * (da + 1)) >> 8; //(RR) += (dr * (da + 1)) >> 8;
//(GG) += (dg * (da + 1)) >> 8; //(GG) += (dg * (da + 1)) >> 8;
//(BB) += (db * (da + 1)) >> 8; //(BB) += (db * (da + 1)) >> 8;
break; break;
case 4: /* AONE */ case 4: /* AONE */
destScale.set_rgba(destAlphaScale, 256, 256, 256); destScale.set(destAlphaScale, 256, 256, 256);
//(RR) += dr; //(RR) += dr;
//(GG) += dg; //(GG) += dg;
//(BB) += db; //(BB) += db;
@ -2951,14 +2951,14 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
case 5: /* AOMSRC_ALPHA */ case 5: /* AOMSRC_ALPHA */
ta = (0x100 - sa); ta = (0x100 - sa);
destScale.set_rgba(destAlphaScale, ta, ta, ta); destScale.set(destAlphaScale, ta, ta, ta);
//(RR) += (dr * (0x100 - sa)) >> 8; //(RR) += (dr * (0x100 - sa)) >> 8;
//(GG) += (dg * (0x100 - sa)) >> 8; //(GG) += (dg * (0x100 - sa)) >> 8;
//(BB) += (db * (0x100 - sa)) >> 8; //(BB) += (db * (0x100 - sa)) >> 8;
break; break;
case 6: /* AOM_COLOR */ case 6: /* AOM_COLOR */
destScale.set_rgba(destAlphaScale, (0x100 - color.rgb.r), (0x100 - color.rgb.g), (0x100 - color.rgb.b)); destScale.set(destAlphaScale, (0x100 - color.rgb.r), (0x100 - color.rgb.g), (0x100 - color.rgb.b));
//(RR) += (dr * (0x100 - sr)) >> 8; //(RR) += (dr * (0x100 - sr)) >> 8;
//(GG) += (dg * (0x100 - sg)) >> 8; //(GG) += (dg * (0x100 - sg)) >> 8;
//(BB) += (db * (0x100 - sb)) >> 8; //(BB) += (db * (0x100 - sb)) >> 8;
@ -2966,14 +2966,14 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
case 7: /* AOMDST_ALPHA */ case 7: /* AOMDST_ALPHA */
ta = (0x100 - da); ta = (0x100 - da);
destScale.set_rgba(destAlphaScale, ta, ta, ta); destScale.set(destAlphaScale, ta, ta, ta);
//(RR) += (dr * (0x100 - da)) >> 8; //(RR) += (dr * (0x100 - da)) >> 8;
//(GG) += (dg * (0x100 - da)) >> 8; //(GG) += (dg * (0x100 - da)) >> 8;
//(BB) += (db * (0x100 - da)) >> 8; //(BB) += (db * (0x100 - da)) >> 8;
break; break;
case 15: /* A_COLORBEFOREFOG */ case 15: /* A_COLORBEFOREFOG */
destScale.set_rgb((rgb_t) (((destAlphaScale-1)<<24) | (preFog.u & 0x00ffffff))); destScale.set((rgb_t) (((destAlphaScale-1)<<24) | (preFog.u & 0x00ffffff)));
destScale.add_imm(1); destScale.add_imm(1);
//(RR) += (dr * (prefogr + 1)) >> 8; //(RR) += (dr * (prefogr + 1)) >> 8;
//(GG) += (dg * (prefogg + 1)) >> 8; //(GG) += (dg * (prefogg + 1)) >> 8;
@ -3124,7 +3124,7 @@ INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, I
rgbaint_t tmpB((rgb_t) color.u); rgbaint_t tmpB((rgb_t) color.u);
if (FOGMODE_FOG_CONSTANT(fogModeReg)) if (FOGMODE_FOG_CONSTANT(fogModeReg))
{ {
tmpA.set_rgb((rgb_t) fogColorLocal.u); tmpA.set((rgb_t) fogColorLocal.u);
/* if fog_mult is 0, we add this to the original color */ /* if fog_mult is 0, we add this to the original color */
if (FOGMODE_FOG_MULT(fogModeReg) == 0) if (FOGMODE_FOG_MULT(fogModeReg) == 0)
{ {
@ -3149,7 +3149,7 @@ INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, I
fogColorLocal.u = 0; fogColorLocal.u = 0;
//fr = fg = fb = 0; //fr = fg = fb = 0;
tmpA.set_rgb((rgb_t) fogColorLocal.u); tmpA.set((rgb_t) fogColorLocal.u);
/* if fog_mult is zero, we subtract the incoming color */ /* if fog_mult is zero, we subtract the incoming color */
if (!FOGMODE_FOG_MULT(fogModeReg)) if (!FOGMODE_FOG_MULT(fogModeReg))
@ -4296,7 +4296,7 @@ INLINE bool combineColor(voodoo_state *VV, stats_block *STATS, UINT32 FBZCOLORPA
if (FBZCP_CCA_ZERO_OTHER(FBZCOLORPATH)) if (FBZCP_CCA_ZERO_OTHER(FBZCOLORPATH))
c_other.u &= 0x00ffffff; c_other.u &= 0x00ffffff;
tmpA.set_rgb((rgb_t) c_other.u); tmpA.set((rgb_t) c_other.u);
/* subtract a/c_local */ /* subtract a/c_local */
if (FBZCP_CC_SUB_CLOCAL(FBZCOLORPATH) || (FBZCP_CCA_SUB_CLOCAL(FBZCOLORPATH))) if (FBZCP_CC_SUB_CLOCAL(FBZCOLORPATH) || (FBZCP_CCA_SUB_CLOCAL(FBZCOLORPATH)))
@ -4309,7 +4309,7 @@ INLINE bool combineColor(voodoo_state *VV, stats_block *STATS, UINT32 FBZCOLORPA
if (!FBZCP_CCA_SUB_CLOCAL(FBZCOLORPATH)) if (!FBZCP_CCA_SUB_CLOCAL(FBZCOLORPATH))
sub_val.u &= 0x00ffffff; sub_val.u &= 0x00ffffff;
tmpB.set_rgb((rgb_t) sub_val.u); tmpB.set((rgb_t) sub_val.u);
tmpA.sub(tmpB); tmpA.sub(tmpB);
} }
@ -4404,9 +4404,9 @@ INLINE bool combineColor(voodoo_state *VV, stats_block *STATS, UINT32 FBZCOLORPA
//CLAMP(color.rgb.r, 0x00, 0xff); //CLAMP(color.rgb.r, 0x00, 0xff);
//CLAMP(color.rgb.g, 0x00, 0xff); //CLAMP(color.rgb.g, 0x00, 0xff);
//CLAMP(color.rgb.b, 0x00, 0xff); //CLAMP(color.rgb.b, 0x00, 0xff);
tmpB.set_rgb((rgb_t) c_local.u); tmpB.set((rgb_t) c_local.u);
tmpB.add_imm(1); tmpB.add_imm(1);
tmpC.set_rgb((rgb_t) add_val.u); tmpC.set((rgb_t) add_val.u);
tmpA.scale_add_and_clamp(tmpB, tmpC); tmpA.scale_add_and_clamp(tmpB, tmpC);
color.u = tmpA.to_rgba(); color.u = tmpA.to_rgba();
@ -4826,7 +4826,7 @@ INLINE UINT32 combineTexture(tmu_state *TT, const UINT32 TEXMODE, rgb_union c_lo
if (TEXMODE_TCA_ZERO_OTHER(TEXMODE)) if (TEXMODE_TCA_ZERO_OTHER(TEXMODE))
c_other.u &= 0x00ffffff; c_other.u &= 0x00ffffff;
tmpA.set_rgb((rgb_t) c_other.u); tmpA.set((rgb_t) c_other.u);
if (TEXMODE_TC_SUB_CLOCAL(TEXMODE) || TEXMODE_TCA_SUB_CLOCAL(TEXMODE)) if (TEXMODE_TC_SUB_CLOCAL(TEXMODE) || TEXMODE_TCA_SUB_CLOCAL(TEXMODE))
{ {
@ -4839,7 +4839,7 @@ INLINE UINT32 combineTexture(tmu_state *TT, const UINT32 TEXMODE, rgb_union c_lo
if (!TEXMODE_TCA_SUB_CLOCAL(TEXMODE)) if (!TEXMODE_TCA_SUB_CLOCAL(TEXMODE))
sub_val.u &= 0x00ffffff; sub_val.u &= 0x00ffffff;
tmpB.set_rgb((rgb_t) sub_val.u); tmpB.set((rgb_t) sub_val.u);
tmpA.sub(tmpB); tmpA.sub(tmpB);
} }
@ -4960,9 +4960,9 @@ INLINE UINT32 combineTexture(tmu_state *TT, const UINT32 TEXMODE, rgb_union c_lo
//result.rgb.g = (tg < 0) ? 0 : (tg > 0xff) ? 0xff : tg; //result.rgb.g = (tg < 0) ? 0 : (tg > 0xff) ? 0xff : tg;
//result.rgb.b = (tb < 0) ? 0 : (tb > 0xff) ? 0xff : tb; //result.rgb.b = (tb < 0) ? 0 : (tb > 0xff) ? 0xff : tb;
//result.rgb.a = (ta < 0) ? 0 : (ta > 0xff) ? 0xff : ta; //result.rgb.a = (ta < 0) ? 0 : (ta > 0xff) ? 0xff : ta;
tmpB.set_rgb((rgb_t) c_local.u); tmpB.set((rgb_t) c_local.u);
tmpB.add_imm(1); tmpB.add_imm(1);
tmpC.set_rgb((rgb_t) add_val.u); tmpC.set((rgb_t) add_val.u);
tmpA.scale_add_and_clamp(tmpB, tmpC); tmpA.scale_add_and_clamp(tmpB, tmpC);
result = tmpA.to_rgba(); result = tmpA.to_rgba();

View File

@ -895,7 +895,7 @@ void cobra_renderer::render_texture_scan(INT32 scanline, const extent_t &extent,
rgb_t texel10 = texture_fetch(&m_texture_ram[tex_address], iu, iv+1, texture_width, tex_format); rgb_t texel10 = texture_fetch(&m_texture_ram[tex_address], iu, iv+1, texture_width, tex_format);
rgb_t texel11 = texture_fetch(&m_texture_ram[tex_address], iu+1, iv+1, texture_width, tex_format); rgb_t texel11 = texture_fetch(&m_texture_ram[tex_address], iu+1, iv+1, texture_width, tex_format);
rgb_t texel = rgbint_t::bilinear_filter(texel00, texel01, texel10, texel11, (int)(lerp_u * 255), (int)(lerp_v * 255)); rgb_t texel = rgbaint_t::bilinear_filter(texel00, texel01, texel10, texel11, (int)(lerp_u * 255), (int)(lerp_v * 255));
#endif #endif

View File

@ -93,9 +93,9 @@ struct namcos22_scenenode
struct namcos22_object_data struct namcos22_object_data
{ {
/* poly / sprites */ /* poly / sprites */
rgbint_t fogcolor; rgbaint_t fogcolor;
rgbint_t fadecolor; rgbaint_t fadecolor;
rgbint_t polycolor; rgbaint_t polycolor;
const pen_t *pens; const pen_t *pens;
bitmap_rgb32 *destbase; bitmap_rgb32 *destbase;
bitmap_ind8 *primap; bitmap_ind8 *primap;

View File

@ -228,7 +228,7 @@ void gaelco3d_renderer::render_noz_noperspective(INT32 scanline, const extent_t
UINT32 rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]]; UINT32 rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]];
UINT32 rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]]; UINT32 rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]];
UINT32 rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]]; UINT32 rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]];
const UINT32 filtered = rgbint_t::bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v); const UINT32 filtered = rgbaint_t::bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v);
dest[x] = (filtered & 0x1f) | ((filtered & 0x1ff800) >> 6); dest[x] = (filtered & 0x1f) | ((filtered & 0x1ff800) >> 6);
zbuf[x] = zbufval; zbuf[x] = zbufval;
} }
@ -275,7 +275,7 @@ void gaelco3d_renderer::render_normal(INT32 scanline, const extent_t &extent, co
UINT32 rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]]; UINT32 rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]];
UINT32 rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]]; UINT32 rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]];
UINT32 rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]]; UINT32 rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]];
const UINT32 filtered = rgbint_t::bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v); const UINT32 filtered = rgbaint_t::bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v);
dest[x] = (filtered & 0x1f) | ((filtered & 0x1ff800) >> 6); dest[x] = (filtered & 0x1f) | ((filtered & 0x1ff800) >> 6);
zbuf[x] = (zbufval < 0) ? -zbufval : zbufval; zbuf[x] = (zbufval < 0) ? -zbufval : zbufval;
} }
@ -325,7 +325,7 @@ void gaelco3d_renderer::render_alphablend(INT32 scanline, const extent_t &extent
UINT32 rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]]; UINT32 rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]];
UINT32 rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]]; UINT32 rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]];
UINT32 rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]]; UINT32 rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]];
const UINT32 filtered = rgbint_t::bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v) >> 1; const UINT32 filtered = rgbaint_t::bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v) >> 1;
dest[x] = ((filtered & 0x0f) | ((filtered & 0x0f7800) >> 6)) + ((dest[x] >> 1) & 0x3def); dest[x] = ((filtered & 0x0f) | ((filtered & 0x0f7800) >> 6)) + ((dest[x] >> 1) & 0x3def);
zbuf[x] = (zbufval < 0) ? -zbufval : zbufval; zbuf[x] = (zbufval < 0) ? -zbufval : zbufval;
} }

View File

@ -1309,7 +1309,7 @@ static void render_poly_texture(void *dest, INT32 scanline, const poly_extent *e
color1 = ((color1 & 0x7fe0) << 6) | (color1 & 0x1f); color1 = ((color1 & 0x7fe0) << 6) | (color1 & 0x1f);
color2 = ((color2 & 0x7fe0) << 6) | (color2 & 0x1f); color2 = ((color2 & 0x7fe0) << 6) | (color2 & 0x1f);
color3 = ((color3 & 0x7fe0) << 6) | (color3 & 0x1f); color3 = ((color3 & 0x7fe0) << 6) | (color3 & 0x1f);
rgb_t filtered = rgbint_t::bilinear_filter(color0, color1, color2, color3, curu, curv); rgb_t filtered = rgbaint_t::bilinear_filter(color0, color1, color2, color3, curu, curv);
WAVERAM_WRITEPIX(zeus_renderbase, scanline, x, ((filtered >> 6) & 0x7fe0) | (filtered & 0x1f)); WAVERAM_WRITEPIX(zeus_renderbase, scanline, x, ((filtered >> 6) & 0x7fe0) | (filtered & 0x1f));
*depthptr = depth; *depthptr = depth;
} }

View File

@ -1297,7 +1297,7 @@ static void render_poly_8bit(void *dest, INT32 scanline, const poly_extent *exte
color1 = ((color1 & 0x7c00) << 9) | ((color1 & 0x3e0) << 6) | ((color1 & 0x1f) << 3); color1 = ((color1 & 0x7c00) << 9) | ((color1 & 0x3e0) << 6) | ((color1 & 0x1f) << 3);
color2 = ((color2 & 0x7c00) << 9) | ((color2 & 0x3e0) << 6) | ((color2 & 0x1f) << 3); color2 = ((color2 & 0x7c00) << 9) | ((color2 & 0x3e0) << 6) | ((color2 & 0x1f) << 3);
color3 = ((color3 & 0x7c00) << 9) | ((color3 & 0x3e0) << 6) | ((color3 & 0x1f) << 3); color3 = ((color3 & 0x7c00) << 9) | ((color3 & 0x3e0) << 6) | ((color3 & 0x1f) << 3);
rgb_t filtered = rgbint_t::bilinear_filter(color0, color1, color2, color3, curu, curv); rgb_t filtered = rgbaint_t::bilinear_filter(color0, color1, color2, color3, curu, curv);
WAVERAM_WRITEPIX(zeus_renderbase, scanline, x, filtered); WAVERAM_WRITEPIX(zeus_renderbase, scanline, x, filtered);
*depthptr = depth; *depthptr = depth;
} }

View File

@ -2839,28 +2839,28 @@ void n64_rdp::cmd_fill_rect(UINT32 w1, UINT32 w2)
void n64_rdp::cmd_set_fog_color(UINT32 w1, UINT32 w2) void n64_rdp::cmd_set_fog_color(UINT32 w1, UINT32 w2)
{ {
m_fog_color.set_rgba(w2 & 0xff, (w2 >> 24) & 0xff, (w2 >> 16) & 0xff, (w2 >> 8) & 0xff); m_fog_color.set(w2 & 0xff, (w2 >> 24) & 0xff, (w2 >> 16) & 0xff, (w2 >> 8) & 0xff);
} }
void n64_rdp::cmd_set_blend_color(UINT32 w1, UINT32 w2) void n64_rdp::cmd_set_blend_color(UINT32 w1, UINT32 w2)
{ {
m_blend_color.set_rgba(w2 & 0xff, (w2 >> 24) & 0xff, (w2 >> 16) & 0xff, (w2 >> 8) & 0xff); m_blend_color.set(w2 & 0xff, (w2 >> 24) & 0xff, (w2 >> 16) & 0xff, (w2 >> 8) & 0xff);
} }
void n64_rdp::cmd_set_prim_color(UINT32 w1, UINT32 w2) void n64_rdp::cmd_set_prim_color(UINT32 w1, UINT32 w2)
{ {
m_misc_state.m_min_level = (w1 >> 8) & 0x1f; m_misc_state.m_min_level = (w1 >> 8) & 0x1f;
const UINT8 prim_lod_fraction = w1 & 0xff; const UINT8 prim_lod_fraction = w1 & 0xff;
m_prim_lod_fraction.set_rgba(prim_lod_fraction, prim_lod_fraction, prim_lod_fraction, prim_lod_fraction); m_prim_lod_fraction.set(prim_lod_fraction, prim_lod_fraction, prim_lod_fraction, prim_lod_fraction);
m_prim_color.set_rgba(w2 & 0xff, (w2 >> 24) & 0xff, (w2 >> 16) & 0xff, (w2 >> 8) & 0xff); m_prim_color.set(w2 & 0xff, (w2 >> 24) & 0xff, (w2 >> 16) & 0xff, (w2 >> 8) & 0xff);
m_prim_alpha.set_rgba(w2 & 0xff, w2 & 0xff, w2 & 0xff, w2 & 0xff); m_prim_alpha.set(w2 & 0xff, w2 & 0xff, w2 & 0xff, w2 & 0xff);
} }
void n64_rdp::cmd_set_env_color(UINT32 w1, UINT32 w2) void n64_rdp::cmd_set_env_color(UINT32 w1, UINT32 w2)
{ {
m_env_color.set_rgba(w2 & 0xff, (w2 >> 24) & 0xff, (w2 >> 16) & 0xff, (w2 >> 8) & 0xff); m_env_color.set(w2 & 0xff, (w2 >> 24) & 0xff, (w2 >> 16) & 0xff, (w2 >> 8) & 0xff);
m_env_alpha.set_rgba(w2 & 0xff, w2 & 0xff, w2 & 0xff, w2 & 0xff); m_env_alpha.set(w2 & 0xff, w2 & 0xff, w2 & 0xff, w2 & 0xff);
} }
void n64_rdp::cmd_set_combine(UINT32 w1, UINT32 w2) void n64_rdp::cmd_set_combine(UINT32 w1, UINT32 w2)
@ -3060,8 +3060,8 @@ n64_rdp::n64_rdp(n64_state &state) : poly_manager<UINT32, rdp_poly_state, 8, 320
m_tiles[i].num = i; m_tiles[i].num = i;
} }
m_one.set_rgba(0xff, 0xff, 0xff, 0xff); m_one.set(0xff, 0xff, 0xff, 0xff);
m_zero.set_rgba(0, 0, 0, 0); m_zero.set(0, 0, 0, 0);
m_tmem = NULL; m_tmem = NULL;
@ -3069,7 +3069,7 @@ n64_rdp::n64_rdp(n64_state &state) : poly_manager<UINT32, rdp_poly_state, 8, 320
//memset(m_hidden_bits, 3, 8388608); //memset(m_hidden_bits, 3, 8388608);
m_prim_lod_fraction.set_rgba(0, 0, 0, 0); m_prim_lod_fraction.set(0, 0, 0, 0);
for (INT32 i = 0; i < 256; i++) for (INT32 i = 0; i < 256; i++)
{ {

View File

@ -83,9 +83,9 @@ void namcos22_renderer::renderscanline_uvi_full(INT32 scanline, const extent_t &
int fogfactor = 0xff - extra.fogfactor; int fogfactor = 0xff - extra.fogfactor;
int fadefactor = 0xff - extra.fadefactor; int fadefactor = 0xff - extra.fadefactor;
int alphafactor = 0xff - m_state.m_poly_translucency; int alphafactor = 0xff - m_state.m_poly_translucency;
rgbint_t fogcolor = extra.fogcolor; rgbaint_t fogcolor = extra.fogcolor;
rgbint_t fadecolor = extra.fadecolor; rgbaint_t fadecolor = extra.fadecolor;
rgbint_t polycolor = extra.polycolor; rgbaint_t polycolor = extra.polycolor;
int polyfade_enabled = extra.pfade_enabled; int polyfade_enabled = extra.pfade_enabled;
int penmask = 0xff; int penmask = 0xff;
int penshift = 0; int penshift = 0;
@ -124,7 +124,7 @@ void namcos22_renderer::renderscanline_uvi_full(INT32 scanline, const extent_t &
INT32 pen = ttdata[(ttmap[to] << 8) | tt_ayx_to_pixel[ttattr[to] << 8 | (ty << 4 & 0xf0) | (tx & 0xf)]]; INT32 pen = ttdata[(ttmap[to] << 8) | tt_ayx_to_pixel[ttattr[to] << 8 | (ty << 4 & 0xf0) | (tx & 0xf)]];
// pen = 0x55; // debug: disable textures // pen = 0x55; // debug: disable textures
rgbint_t rgb(pens[pen >> penshift & penmask]); rgbaint_t rgb(pens[pen >> penshift & penmask]);
// apply shading before fog // apply shading before fog
INT32 shade = i*ooz; INT32 shade = i*ooz;
@ -161,10 +161,10 @@ void namcos22_renderer::renderscanline_uvi_full(INT32 scanline, const extent_t &
if (alphafactor != 0xff) if (alphafactor != 0xff)
{ {
rgb.blend(rgbint_t(dest[x]), alphafactor); rgb.blend(rgbaint_t(dest[x]), alphafactor);
} }
dest[x] = rgb.to_rgb(); dest[x] = rgb.to_rgba();
primap[x] |= prioverchar; primap[x] |= prioverchar;
u += du; u += du;
@ -184,7 +184,7 @@ void namcos22_renderer::renderscanline_uvi_full(INT32 scanline, const extent_t &
int pen = ttdata[(ttmap[to] << 8) | tt_ayx_to_pixel[ttattr[to] << 8 | (ty << 4 & 0xf0) | (tx & 0xf)]]; int pen = ttdata[(ttmap[to] << 8) | tt_ayx_to_pixel[ttattr[to] << 8 | (ty << 4 & 0xf0) | (tx & 0xf)]];
// pen = 0x55; // debug: disable textures // pen = 0x55; // debug: disable textures
rgbint_t rgb(pens[pen >> penshift & penmask]); rgbaint_t rgb(pens[pen >> penshift & penmask]);
// per-z distance fogging // per-z distance fogging
if (zfog_enabled) if (zfog_enabled)
@ -213,7 +213,7 @@ void namcos22_renderer::renderscanline_uvi_full(INT32 scanline, const extent_t &
rgb.scale_and_clamp(polycolor); rgb.scale_and_clamp(polycolor);
} }
dest[x] = rgb.to_rgb(); dest[x] = rgb.to_rgba();
primap[x] |= prioverchar; primap[x] |= prioverchar;
u += du; u += du;
@ -235,8 +235,8 @@ void namcos22_renderer::renderscanline_sprite(INT32 scanline, const extent_t &ex
int alphafactor = extra.alpha; int alphafactor = extra.alpha;
int fogfactor = 0xff - extra.fogfactor; int fogfactor = 0xff - extra.fogfactor;
int fadefactor = 0xff - extra.fadefactor; int fadefactor = 0xff - extra.fadefactor;
rgbint_t fogcolor(extra.fogcolor); rgbaint_t fogcolor(extra.fogcolor);
rgbint_t fadecolor(extra.fadecolor); rgbaint_t fadecolor(extra.fadecolor);
UINT8 *source = (UINT8 *)extra.source + y_index * extra.line_modulo; UINT8 *source = (UINT8 *)extra.source + y_index * extra.line_modulo;
UINT32 *dest = &extra.destbase->pix32(scanline); UINT32 *dest = &extra.destbase->pix32(scanline);
UINT8 *primap = &extra.primap->pix8(scanline); UINT8 *primap = &extra.primap->pix8(scanline);
@ -246,7 +246,7 @@ void namcos22_renderer::renderscanline_sprite(INT32 scanline, const extent_t &ex
int pen = source[(int)x_index]; int pen = source[(int)x_index];
if (pen != 0xff) if (pen != 0xff)
{ {
rgbint_t rgb(pal[pen]); rgbaint_t rgb(pal[pen]);
if (fogfactor != 0xff) if (fogfactor != 0xff)
{ {
@ -260,10 +260,10 @@ void namcos22_renderer::renderscanline_sprite(INT32 scanline, const extent_t &ex
if (alphafactor != 0xff) if (alphafactor != 0xff)
{ {
rgb.blend(rgbint_t(dest[x]), alphafactor); rgb.blend(rgbaint_t(dest[x]), alphafactor);
} }
dest[x] = rgb.to_rgb(); dest[x] = rgb.to_rgba();
primap[x] |= prioverchar; primap[x] |= prioverchar;
} }
x_index += dx; x_index += dx;
@ -365,12 +365,12 @@ void namcos22_renderer::poly3d_drawquad(screen_device &screen, bitmap_rgb32 &bit
if (m_state.m_mixer_flags & 1) if (m_state.m_mixer_flags & 1)
{ {
extra.fadefactor = m_state.m_screen_fade_factor; extra.fadefactor = m_state.m_screen_fade_factor;
extra.fadecolor.set_rgb(m_state.m_screen_fade_r, m_state.m_screen_fade_g, m_state.m_screen_fade_b); extra.fadecolor.set(0, m_state.m_screen_fade_r, m_state.m_screen_fade_g, m_state.m_screen_fade_b);
} }
// poly fade // poly fade
extra.pfade_enabled = m_state.m_poly_fade_enabled; extra.pfade_enabled = m_state.m_poly_fade_enabled;
extra.polycolor.set_rgb(m_state.m_poly_fade_r, m_state.m_poly_fade_g, m_state.m_poly_fade_b); extra.polycolor.set(0, m_state.m_poly_fade_r, m_state.m_poly_fade_g, m_state.m_poly_fade_b);
/* poly fog (not completely accurate yet) /* poly fog (not completely accurate yet)
@ -441,7 +441,7 @@ void namcos22_renderer::poly3d_drawquad(screen_device &screen, bitmap_rgb32 &bit
if (nthword(m_state.m_czattr, 4) & (4 << (cztype * 4))) if (nthword(m_state.m_czattr, 4) & (4 << (cztype * 4)))
{ {
int delta = (INT16)nthword(m_state.m_czattr, cztype); int delta = (INT16)nthword(m_state.m_czattr, cztype);
extra.fogcolor.set_rgb(m_state.m_fog_r, m_state.m_fog_g, m_state.m_fog_b); extra.fogcolor.set(0, m_state.m_fog_r, m_state.m_fog_g, m_state.m_fog_b);
if (direct) if (direct)
{ {
int cz = ((flags & 0x1fff00) + cz_adjust) >> 8; int cz = ((flags & 0x1fff00) + cz_adjust) >> 8;
@ -471,7 +471,7 @@ void namcos22_renderer::poly3d_drawquad(screen_device &screen, bitmap_rgb32 &bit
if (m_state.m_mixer_flags & 1) if (m_state.m_mixer_flags & 1)
{ {
extra.pfade_enabled = m_state.m_poly_fade_enabled; extra.pfade_enabled = m_state.m_poly_fade_enabled;
extra.polycolor.set_rgb(m_state.m_poly_fade_r, m_state.m_poly_fade_g, m_state.m_poly_fade_b); extra.polycolor.set(0, m_state.m_poly_fade_r, m_state.m_poly_fade_g, m_state.m_poly_fade_b);
} }
// poly fog // poly fog
@ -479,7 +479,7 @@ void namcos22_renderer::poly3d_drawquad(screen_device &screen, bitmap_rgb32 &bit
{ {
int cztype = flags & 3; int cztype = flags & 3;
int czcolor = cztype & nthbyte(&m_state.m_fog_colormask, cztype); int czcolor = cztype & nthbyte(&m_state.m_fog_colormask, cztype);
extra.fogcolor.set_rgb(m_state.m_fog_r_per_cztype[czcolor], m_state.m_fog_g_per_cztype[czcolor], m_state.m_fog_b_per_cztype[czcolor]); extra.fogcolor.set(0, m_state.m_fog_r_per_cztype[czcolor], m_state.m_fog_g_per_cztype[czcolor], m_state.m_fog_b_per_cztype[czcolor]);
if (direct) if (direct)
{ {
@ -564,7 +564,7 @@ void namcos22_renderer::poly3d_drawsprite(
if (m_state.m_mixer_flags & 2) if (m_state.m_mixer_flags & 2)
{ {
extra.fadefactor = m_state.m_screen_fade_factor; extra.fadefactor = m_state.m_screen_fade_factor;
extra.fadecolor.set_rgb(m_state.m_screen_fade_r, m_state.m_screen_fade_g, m_state.m_screen_fade_b); extra.fadecolor.set(0, m_state.m_screen_fade_r, m_state.m_screen_fade_g, m_state.m_screen_fade_b);
} }
// fog, 0xfe is a special case for sprite priority over textlayer // fog, 0xfe is a special case for sprite priority over textlayer
@ -572,7 +572,7 @@ void namcos22_renderer::poly3d_drawsprite(
{ {
// or does it fetch from poly-cz ram? that will break timecris though // or does it fetch from poly-cz ram? that will break timecris though
extra.fogfactor = cz_factor; extra.fogfactor = cz_factor;
extra.fogcolor.set_rgb(m_state.m_fog_r, m_state.m_fog_g, m_state.m_fog_b); extra.fogcolor.set(0, m_state.m_fog_r, m_state.m_fog_g, m_state.m_fog_b);
} }
render_triangle_fan(m_cliprect, render_delegate(FUNC(namcos22_renderer::renderscanline_sprite), this), 2, 4, vert); render_triangle_fan(m_cliprect, render_delegate(FUNC(namcos22_renderer::renderscanline_sprite), this), 2, 4, vert);
@ -1892,7 +1892,7 @@ void namcos22_state::namcos22s_mix_text_layer(screen_device &screen, bitmap_rgb3
// prepare fader // prepare fader
bool fade_enabled = (m_mixer_flags & 2) && m_screen_fade_factor; bool fade_enabled = (m_mixer_flags & 2) && m_screen_fade_factor;
int fade_factor = 0xff - m_screen_fade_factor; int fade_factor = 0xff - m_screen_fade_factor;
rgbint_t fade_color(m_screen_fade_r, m_screen_fade_g, m_screen_fade_b); rgbaint_t fade_color(0, m_screen_fade_r, m_screen_fade_g, m_screen_fade_b);
// mix textlayer with poly/sprites // mix textlayer with poly/sprites
for (int y = cliprect.min_y; y <= cliprect.max_y; y++) for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
@ -1905,7 +1905,7 @@ void namcos22_state::namcos22s_mix_text_layer(screen_device &screen, bitmap_rgb3
// skip if transparent or under poly/sprite // skip if transparent or under poly/sprite
if (pri[x] == prival) if (pri[x] == prival)
{ {
rgbint_t rgb(pens[src[x]]); rgbaint_t rgb(pens[src[x]]);
// apply alpha // apply alpha
if (alpha_factor) if (alpha_factor)
@ -1913,7 +1913,7 @@ void namcos22_state::namcos22s_mix_text_layer(screen_device &screen, bitmap_rgb3
UINT8 pen = src[x] & 0xff; UINT8 pen = src[x] & 0xff;
if ((pen & 0xf) == alpha_mask || pen == alpha_check12 || pen == alpha_check13) if ((pen & 0xf) == alpha_mask || pen == alpha_check12 || pen == alpha_check13)
{ {
rgb.blend(rgbint_t(dest[x]), 0xff - alpha_factor); rgb.blend(rgbaint_t(dest[x]), 0xff - alpha_factor);
} }
} }
@ -1921,11 +1921,11 @@ void namcos22_state::namcos22s_mix_text_layer(screen_device &screen, bitmap_rgb3
if (spot_enabled) if (spot_enabled)
{ {
UINT8 pen = src[x] & 0xff; UINT8 pen = src[x] & 0xff;
rgbint_t mix(dest[x]); rgbaint_t mix(dest[x]);
if (spot_flags & 8) if (spot_flags & 8)
{ {
// mix with per-channel brightness // mix with per-channel brightness
rgbint_t shade((0xff - (m_spotram[pen << 2 | 1] & 0xff)) << 2, (0xff - (m_spotram[pen << 2 | 2] & 0xff)) << 2, (0xff - (m_spotram[pen << 2 | 3] & 0xff)) << 2); rgbaint_t shade(0, (0xff - (m_spotram[pen << 2 | 1] & 0xff)) << 2, (0xff - (m_spotram[pen << 2 | 2] & 0xff)) << 2, (0xff - (m_spotram[pen << 2 | 3] & 0xff)) << 2);
mix.scale_and_clamp(shade); mix.scale_and_clamp(shade);
} }
@ -1941,7 +1941,7 @@ void namcos22_state::namcos22s_mix_text_layer(screen_device &screen, bitmap_rgb3
rgb.blend(fade_color, fade_factor); rgb.blend(fade_color, fade_factor);
} }
dest[x] = rgb.to_rgb(); dest[x] = rgb.to_rgba();
} }
} }
} }
@ -1958,11 +1958,11 @@ void namcos22_state::namcos22_mix_text_layer(screen_device &screen, bitmap_rgb32
bool fade_enabled = m_mixer_flags & 2 && m_poly_fade_enabled; bool fade_enabled = m_mixer_flags & 2 && m_poly_fade_enabled;
bool shadow_enabled = (m_mixer_flags & 0x100) != 0; // ? (ridgerac is the only game not using shadow) bool shadow_enabled = (m_mixer_flags & 0x100) != 0; // ? (ridgerac is the only game not using shadow)
rgbint_t fade_color(m_poly_fade_r, m_poly_fade_g, m_poly_fade_b); rgbaint_t fade_color(0, m_poly_fade_r, m_poly_fade_g, m_poly_fade_b);
rgbint_t rgb_mix[3] = { rgbaint_t rgb_mix[3] = {
rgbint_t(nthbyte(m_mixer, 0x08), nthbyte(m_mixer, 0x09), nthbyte(m_mixer, 0x0a)), // pen c rgbaint_t(0, nthbyte(m_mixer, 0x08), nthbyte(m_mixer, 0x09), nthbyte(m_mixer, 0x0a)), // pen c
rgbint_t(nthbyte(m_mixer, 0x0b), nthbyte(m_mixer, 0x0c), nthbyte(m_mixer, 0x0d)), // pen d rgbaint_t(0, nthbyte(m_mixer, 0x0b), nthbyte(m_mixer, 0x0c), nthbyte(m_mixer, 0x0d)), // pen d
rgbint_t(nthbyte(m_mixer, 0x0e), nthbyte(m_mixer, 0x0f), nthbyte(m_mixer, 0x10)) // pen e rgbaint_t(0, nthbyte(m_mixer, 0x0e), nthbyte(m_mixer, 0x0f), nthbyte(m_mixer, 0x10)) // pen e
}; };
// mix textlayer with poly/sprites // mix textlayer with poly/sprites
@ -1977,7 +1977,7 @@ void namcos22_state::namcos22_mix_text_layer(screen_device &screen, bitmap_rgb32
if (pri[x] == 2) if (pri[x] == 2)
{ {
// apply shadow // apply shadow
rgbint_t rgb; rgbaint_t rgb;
switch (src[x] & 0xff) switch (src[x] & 0xff)
{ {
case 0xfc: case 0xfc:
@ -1985,13 +1985,13 @@ void namcos22_state::namcos22_mix_text_layer(screen_device &screen, bitmap_rgb32
case 0xfe: case 0xfe:
if (shadow_enabled) if (shadow_enabled)
{ {
rgb.set_rgb(dest[x]); rgb.set(dest[x]);
rgb.scale_and_clamp(rgb_mix[(src[x] & 0xf) - 0xc]); rgb.scale_and_clamp(rgb_mix[(src[x] & 0xf) - 0xc]);
break; break;
} }
// (fall through) // (fall through)
default: default:
rgb.set_rgb(pens[src[x]]); rgb.set(pens[src[x]]);
break; break;
} }
@ -2004,7 +2004,7 @@ void namcos22_state::namcos22_mix_text_layer(screen_device &screen, bitmap_rgb32
// eg. a rr-gg-bb of 3f-7f-00 will fade to ff-ff-00 and not ff-ff-ff // eg. a rr-gg-bb of 3f-7f-00 will fade to ff-ff-00 and not ff-ff-ff
// seen in victlapw attract mode // seen in victlapw attract mode
dest[x] = rgb.to_rgb(); dest[x] = rgb.to_rgba();
} }
} }
} }
@ -2285,13 +2285,13 @@ UINT32 namcos22_state::screen_update_namcos22s(screen_device &screen, bitmap_rgb
screen.priority().fill(0, cliprect); screen.priority().fill(0, cliprect);
// background color // background color
rgbint_t bg_color(nthbyte(m_mixer, 0x08), nthbyte(m_mixer, 0x09), nthbyte(m_mixer, 0x0a)); rgbaint_t bg_color(0, nthbyte(m_mixer, 0x08), nthbyte(m_mixer, 0x09), nthbyte(m_mixer, 0x0a));
if (m_mixer_flags & 1 && m_screen_fade_factor) if (m_mixer_flags & 1 && m_screen_fade_factor)
{ {
rgbint_t fade_color(m_screen_fade_r, m_screen_fade_g, m_screen_fade_b); rgbaint_t fade_color(0, m_screen_fade_r, m_screen_fade_g, m_screen_fade_b);
bg_color.blend(fade_color, 0xff - m_screen_fade_factor); bg_color.blend(fade_color, 0xff - m_screen_fade_factor);
} }
bitmap.fill(bg_color.to_rgb(), cliprect); bitmap.fill(bg_color.to_rgba(), cliprect);
// layers // layers
UINT8 layer = nthbyte(m_mixer, 0x1f); UINT8 layer = nthbyte(m_mixer, 0x1f);

View File

@ -124,7 +124,7 @@ bool n64_blender_t::cycle1_noblend_noacvg_dither(color_t& blended_pixel, int dit
index.shl_imm(3); index.shl_imm(3);
index.or_imm(dith); index.or_imm(dith);
index.and_imm(0x7ff); index.and_imm(0x7ff);
blended_pixel.set_rgba(0, m_color_dither[index.get_r32()], m_color_dither[index.get_g32()], m_color_dither[index.get_b32()]); blended_pixel.set(0, m_color_dither[index.get_r32()], m_color_dither[index.get_g32()], m_color_dither[index.get_b32()]);
return true; return true;
} }
@ -155,7 +155,7 @@ bool n64_blender_t::cycle1_noblend_acvg_dither(color_t& blended_pixel, int dith,
index.shl_imm(3); index.shl_imm(3);
index.or_imm(dith); index.or_imm(dith);
index.and_imm(0x7ff); index.and_imm(0x7ff);
blended_pixel.set_rgba(0, m_color_dither[index.get_r32()], m_color_dither[index.get_g32()], m_color_dither[index.get_b32()]); blended_pixel.set(0, m_color_dither[index.get_r32()], m_color_dither[index.get_g32()], m_color_dither[index.get_b32()]);
return true; return true;
} }
@ -191,7 +191,7 @@ bool n64_blender_t::cycle1_blend_noacvg_dither(color_t& blended_pixel, int dith,
rgb.shl_imm(3); rgb.shl_imm(3);
rgb.or_imm(dith); rgb.or_imm(dith);
rgb.and_imm(0x7ff); rgb.and_imm(0x7ff);
blended_pixel.set_rgba(0, m_color_dither[rgb.get_r32()], m_color_dither[rgb.get_g32()], m_color_dither[rgb.get_b32()]); blended_pixel.set(0, m_color_dither[rgb.get_r32()], m_color_dither[rgb.get_g32()], m_color_dither[rgb.get_b32()]);
return true; return true;
} }
@ -225,7 +225,7 @@ bool n64_blender_t::cycle1_blend_acvg_dither(color_t& blended_pixel, int dith, i
rgb.shl_imm(3); rgb.shl_imm(3);
rgb.or_imm(dith); rgb.or_imm(dith);
rgb.and_imm(0x7ff); rgb.and_imm(0x7ff);
blended_pixel.set_rgba(0, m_color_dither[rgb.get_r32()], m_color_dither[rgb.get_g32()], m_color_dither[rgb.get_b32()]); blended_pixel.set(0, m_color_dither[rgb.get_r32()], m_color_dither[rgb.get_g32()], m_color_dither[rgb.get_b32()]);
return true; return true;
} }
@ -267,7 +267,7 @@ bool n64_blender_t::cycle2_noblend_noacvg_dither(color_t& blended_pixel, int dit
index.shl_imm(3); index.shl_imm(3);
index.or_imm(dith); index.or_imm(dith);
index.and_imm(0x7ff); index.and_imm(0x7ff);
blended_pixel.set_rgba(0, m_color_dither[index.get_r32()], m_color_dither[index.get_g32()], m_color_dither[index.get_b32()]); blended_pixel.set(0, m_color_dither[index.get_r32()], m_color_dither[index.get_g32()], m_color_dither[index.get_b32()]);
return true; return true;
} }
@ -307,7 +307,7 @@ bool n64_blender_t::cycle2_noblend_acvg_dither(color_t& blended_pixel, int dith,
index.shl_imm(3); index.shl_imm(3);
index.or_imm(dith); index.or_imm(dith);
index.and_imm(0x7ff); index.and_imm(0x7ff);
blended_pixel.set_rgba(0, m_color_dither[index.get_r32()], m_color_dither[index.get_g32()], m_color_dither[index.get_b32()]); blended_pixel.set(0, m_color_dither[index.get_r32()], m_color_dither[index.get_g32()], m_color_dither[index.get_b32()]);
return true; return true;
} }
@ -351,7 +351,7 @@ bool n64_blender_t::cycle2_blend_noacvg_dither(color_t& blended_pixel, int dith,
rgb.shl_imm(3); rgb.shl_imm(3);
rgb.or_imm(dith); rgb.or_imm(dith);
rgb.and_imm(0x7ff); rgb.and_imm(0x7ff);
blended_pixel.set_rgba(0, m_color_dither[rgb.get_r32()], m_color_dither[rgb.get_g32()], m_color_dither[rgb.get_b32()]); blended_pixel.set(0, m_color_dither[rgb.get_r32()], m_color_dither[rgb.get_g32()], m_color_dither[rgb.get_b32()]);
return true; return true;
} }
@ -393,7 +393,7 @@ bool n64_blender_t::cycle2_blend_acvg_dither(color_t& blended_pixel, int dith, i
rgb.shl_imm(3); rgb.shl_imm(3);
rgb.or_imm(dith); rgb.or_imm(dith);
rgb.and_imm(0x7ff); rgb.and_imm(0x7ff);
blended_pixel.set_rgba(0, m_color_dither[rgb.get_r32()], m_color_dither[rgb.get_g32()], m_color_dither[rgb.get_b32()]); blended_pixel.set(0, m_color_dither[rgb.get_r32()], m_color_dither[rgb.get_g32()], m_color_dither[rgb.get_b32()]);
return true; return true;
} }
@ -444,7 +444,7 @@ void n64_blender_t::blend_pipe(const int cycle, const int special, color_t& out,
} }
else else
{ {
temp.set_rgba(0, 0xff, 0xff, 0xff); temp.set(0, 0xff, 0xff, 0xff);
} }
} }

View File

@ -82,9 +82,10 @@ void n64_rdp::render_spans(INT32 start, INT32 end, INT32 tilenum, bool flip, ext
void n64_rdp::rgbaz_clip(INT32 sr, INT32 sg, INT32 sb, INT32 sa, INT32* sz, rdp_span_aux* userdata) void n64_rdp::rgbaz_clip(INT32 sr, INT32 sg, INT32 sb, INT32 sa, INT32* sz, rdp_span_aux* userdata)
{ {
userdata->m_shade_color.clamp_and_clear(rgbaint_t(sa, sr, sg, sb), 0xfffffe00); userdata->m_shade_color.set(sa, sr, sg, sb);
userdata->m_shade_color.clamp_and_clear(0xfffffe00);
UINT32 a = userdata->m_shade_color.get_a(); UINT32 a = userdata->m_shade_color.get_a();
userdata->m_shade_alpha.set_rgba(a, a, a, a); userdata->m_shade_alpha.set(a, a, a, a);
INT32 zanded = (*sz) & 0x60000; INT32 zanded = (*sz) & 0x60000;
@ -235,7 +236,7 @@ inline void n64_rdp::read_pixel(UINT32 curpixel, rdp_span_aux* userdata, const r
{ {
const UINT16 fword = RREADIDX16((object.m_misc_state.m_fb_address >> 1) + curpixel); const UINT16 fword = RREADIDX16((object.m_misc_state.m_fb_address >> 1) + curpixel);
userdata->m_memory_color.set_rgba(0, GETHICOL(fword), GETMEDCOL(fword), GETLOWCOL(fword)); userdata->m_memory_color.set(0, GETHICOL(fword), GETMEDCOL(fword), GETLOWCOL(fword));
if (object.m_other_modes.image_read_en) if (object.m_other_modes.image_read_en)
{ {
UINT8 hbyte = HREADADDR8((object.m_misc_state.m_fb_address >> 1) + curpixel); UINT8 hbyte = HREADADDR8((object.m_misc_state.m_fb_address >> 1) + curpixel);
@ -251,7 +252,7 @@ inline void n64_rdp::read_pixel(UINT32 curpixel, rdp_span_aux* userdata, const r
else // 32-bit framebuffer else // 32-bit framebuffer
{ {
const UINT32 mem = RREADIDX32((object.m_misc_state.m_fb_address >> 2) + curpixel); const UINT32 mem = RREADIDX32((object.m_misc_state.m_fb_address >> 2) + curpixel);
userdata->m_memory_color.set_rgba(0, (mem >> 24) & 0xff, (mem >> 16) & 0xff, (mem >> 8) & 0xff); userdata->m_memory_color.set(0, (mem >> 24) & 0xff, (mem >> 16) & 0xff, (mem >> 8) & 0xff);
if (object.m_other_modes.image_read_en) if (object.m_other_modes.image_read_en)
{ {
userdata->m_memory_color.set_a(mem & 0xff); userdata->m_memory_color.set_a(mem & 0xff);
@ -430,10 +431,10 @@ void n64_rdp::span_draw_1cycle(INT32 scanline, const extent_t &extent, const rdp
((m_tex_pipe).*(m_tex_pipe.m_cycle[cycle0]))(&userdata->m_texel0_color, &userdata->m_texel0_color, sss, sst, tilenum, 0, userdata, object); ((m_tex_pipe).*(m_tex_pipe.m_cycle[cycle0]))(&userdata->m_texel0_color, &userdata->m_texel0_color, sss, sst, tilenum, 0, userdata, object);
UINT32 t0a = userdata->m_texel0_color.get_a(); UINT32 t0a = userdata->m_texel0_color.get_a();
userdata->m_texel0_alpha.set_rgba(t0a, t0a, t0a, t0a); userdata->m_texel0_alpha.set(t0a, t0a, t0a, t0a);
const UINT8 noise = rand() << 3; // Not accurate const UINT8 noise = rand() << 3; // Not accurate
userdata->m_noise_color.set_rgba(0, noise, noise, noise); userdata->m_noise_color.set(0, noise, noise, noise);
rgbaint_t rgbsub_a(*userdata->m_color_inputs.combiner_rgbsub_a[1]); rgbaint_t rgbsub_a(*userdata->m_color_inputs.combiner_rgbsub_a[1]);
rgbaint_t rgbsub_b(*userdata->m_color_inputs.combiner_rgbsub_b[1]); rgbaint_t rgbsub_b(*userdata->m_color_inputs.combiner_rgbsub_b[1]);
@ -455,7 +456,7 @@ void n64_rdp::span_draw_1cycle(INT32 scanline, const extent_t &extent, const rdp
rgbsub_a.add(rgbadd); rgbsub_a.add(rgbadd);
rgbsub_a.add_imm(0x0080); rgbsub_a.add_imm(0x0080);
rgbsub_a.sra_imm(8); rgbsub_a.sra_imm(8);
rgbsub_a.clamp_and_clear(rgbsub_a, 0xfffffe00); rgbsub_a.clamp_and_clear(0xfffffe00);
userdata->m_pixel_color = rgbsub_a; userdata->m_pixel_color = rgbsub_a;
@ -657,12 +658,12 @@ void n64_rdp::span_draw_2cycle(INT32 scanline, const extent_t &extent, const rdp
UINT32 t0a = userdata->m_texel0_color.get_a(); UINT32 t0a = userdata->m_texel0_color.get_a();
UINT32 t1a = userdata->m_texel1_color.get_a(); UINT32 t1a = userdata->m_texel1_color.get_a();
UINT32 tna = userdata->m_next_texel_color.get_a(); UINT32 tna = userdata->m_next_texel_color.get_a();
userdata->m_texel0_alpha.set_rgba(t0a, t0a, t0a, t0a); userdata->m_texel0_alpha.set(t0a, t0a, t0a, t0a);
userdata->m_texel1_alpha.set_rgba(t1a, t1a, t1a, t1a); userdata->m_texel1_alpha.set(t1a, t1a, t1a, t1a);
userdata->m_next_texel_alpha.set_rgba(tna, tna, tna, tna); userdata->m_next_texel_alpha.set(tna, tna, tna, tna);
const UINT8 noise = rand() << 3; // Not accurate const UINT8 noise = rand() << 3; // Not accurate
userdata->m_noise_color.set_rgba(0, noise, noise, noise); userdata->m_noise_color.set(0, noise, noise, noise);
rgbaint_t rgbsub_a(*userdata->m_color_inputs.combiner_rgbsub_a[0]); rgbaint_t rgbsub_a(*userdata->m_color_inputs.combiner_rgbsub_a[0]);
rgbaint_t rgbsub_b(*userdata->m_color_inputs.combiner_rgbsub_b[0]); rgbaint_t rgbsub_b(*userdata->m_color_inputs.combiner_rgbsub_b[0]);
@ -685,14 +686,14 @@ void n64_rdp::span_draw_2cycle(INT32 scanline, const extent_t &extent, const rdp
rgbsub_a.add(rgbadd); rgbsub_a.add(rgbadd);
rgbsub_a.add_imm(0x0080); rgbsub_a.add_imm(0x0080);
rgbsub_a.sra_imm(8); rgbsub_a.sra_imm(8);
rgbsub_a.clamp_and_clear(rgbsub_a, 0xfffffe00); rgbsub_a.clamp_and_clear(0xfffffe00);
userdata->m_combined_color.set(rgbsub_a); userdata->m_combined_color.set(rgbsub_a);
userdata->m_texel0_color.set(userdata->m_texel1_color); userdata->m_texel0_color.set(userdata->m_texel1_color);
userdata->m_texel1_color.set(userdata->m_next_texel_color); userdata->m_texel1_color.set(userdata->m_next_texel_color);
UINT32 ca = userdata->m_combined_color.get_a(); UINT32 ca = userdata->m_combined_color.get_a();
userdata->m_combined_alpha.set_rgba(ca, ca, ca, ca); userdata->m_combined_alpha.set(ca, ca, ca, ca);
userdata->m_texel0_alpha.set(userdata->m_texel1_alpha); userdata->m_texel0_alpha.set(userdata->m_texel1_alpha);
userdata->m_texel1_alpha.set(userdata->m_next_texel_alpha); userdata->m_texel1_alpha.set(userdata->m_next_texel_alpha);
@ -716,7 +717,7 @@ void n64_rdp::span_draw_2cycle(INT32 scanline, const extent_t &extent, const rdp
rgbsub_a.add(rgbadd); rgbsub_a.add(rgbadd);
rgbsub_a.add_imm(0x0080); rgbsub_a.add_imm(0x0080);
rgbsub_a.sra_imm(8); rgbsub_a.sra_imm(8);
rgbsub_a.clamp_and_clear(rgbsub_a, 0xfffffe00); rgbsub_a.clamp_and_clear(0xfffffe00);
userdata->m_pixel_color.set(rgbsub_a); userdata->m_pixel_color.set(rgbsub_a);

View File

@ -61,14 +61,14 @@ void n64_texture_pipe_t::set_machine(running_machine &machine)
} }
} }
m_st2_add.set_rgba(0, 1, 0, 1); m_st2_add.set(0, 1, 0, 1);
m_v1.set_rgba(1, 1, 1, 1); m_v1.set(1, 1, 1, 1);
} }
void n64_texture_pipe_t::mask(rgbaint_t& st, const n64_tile_t& tile) void n64_texture_pipe_t::mask(rgbaint_t& st, const n64_tile_t& tile)
{ {
rgbaint_t wrap(st); rgbaint_t wrap(st);
wrap.shr(tile.wrapped_mask); wrap.sra(tile.wrapped_mask);
wrap.and_reg(m_v1); wrap.and_reg(m_v1);
wrap.cmpeq(m_v1); wrap.cmpeq(m_v1);
wrap.and_reg(tile.mm); wrap.and_reg(tile.mm);
@ -83,7 +83,7 @@ void n64_texture_pipe_t::mask_coupled(rgbaint_t& sstt, const n64_tile_t& tile)
rgbaint_t maskbits(s_mask_bits, s_mask_bits, t_mask_bits, t_mask_bits); rgbaint_t maskbits(s_mask_bits, s_mask_bits, t_mask_bits, t_mask_bits);
rgbaint_t wrap(sstt); rgbaint_t wrap(sstt);
wrap.shr(tile.wrapped_mask); wrap.sra(tile.wrapped_mask);
wrap.and_reg(m_v1); wrap.and_reg(m_v1);
wrap.cmpeq(m_v1); wrap.cmpeq(m_v1);
wrap.and_reg(tile.mm); wrap.and_reg(tile.mm);
@ -196,10 +196,10 @@ void n64_texture_pipe_t::cycle_nearest(color_t* TEX, color_t* prev, INT32 SSS, I
clamp_cycle_light(st, maxst, tilenum, tile, userdata); clamp_cycle_light(st, maxst, tilenum, tile, userdata);
mask(st, tile); mask(st, tile);
UINT32 tbase = tile.tmem + ((tile.line * st.get_b()) & 0x1ff); UINT32 tbase = tile.tmem + ((tile.line * st.get_b32()) & 0x1ff);
rgbaint_t t0; rgbaint_t t0;
((this)->*(m_texel_fetch[index]))(t0, st.get_r(), st.get_b(), tbase, tile.palette, userdata); ((this)->*(m_texel_fetch[index]))(t0, st.get_r32(), st.get_b32(), tbase, tile.palette, userdata);
if (object.m_other_modes.convert_one && cycle) if (object.m_other_modes.convert_one && cycle)
{ {
t0.set(*prev); t0.set(*prev);
@ -208,14 +208,14 @@ void n64_texture_pipe_t::cycle_nearest(color_t* TEX, color_t* prev, INT32 SSS, I
t0.sign_extend(0x00000100, 0xffffff00); t0.sign_extend(0x00000100, 0xffffff00);
rgbaint_t k1r(m_rdp->get_k1()); rgbaint_t k1r(m_rdp->get_k1());
k1r.mul_imm(t0.get_r()); k1r.mul_imm(t0.get_r32());
TEX->set(m_rdp->get_k023()); TEX->set(m_rdp->get_k023());
TEX->mul_imm(t0.get_g()); TEX->mul_imm(t0.get_g32());
TEX->add(k1r); TEX->add(k1r);
TEX->add_imm(0x80); TEX->add_imm(0x80);
TEX->shr_imm(8); TEX->shr_imm(8);
TEX->add_imm(t0.get_b()); TEX->add_imm(t0.get_b32());
TEX->and_imm(0x1ff); TEX->and_imm(0x1ff);
} }
@ -229,9 +229,9 @@ void n64_texture_pipe_t::cycle_nearest_lerp(color_t* TEX, color_t* prev, INT32 S
clamp_cycle_light(st, maxst, tilenum, tile, userdata); clamp_cycle_light(st, maxst, tilenum, tile, userdata);
mask(st, tile); mask(st, tile);
UINT32 tbase = tile.tmem + ((tile.line * st.get_b()) & 0x1ff); UINT32 tbase = tile.tmem + ((tile.line * st.get_b32()) & 0x1ff);
((this)->*(m_texel_fetch[index]))(*TEX, st.get_r(), st.get_b(), tbase, tile.palette, userdata); ((this)->*(m_texel_fetch[index]))(*TEX, st.get_r32(), st.get_b32(), tbase, tile.palette, userdata);
} }
void n64_texture_pipe_t::cycle_linear(color_t* TEX, color_t* prev, INT32 SSS, INT32 SST, UINT32 tilenum, UINT32 cycle, rdp_span_aux* userdata, const rdp_poly_state& object) void n64_texture_pipe_t::cycle_linear(color_t* TEX, color_t* prev, INT32 SSS, INT32 SST, UINT32 tilenum, UINT32 cycle, rdp_span_aux* userdata, const rdp_poly_state& object)
@ -253,22 +253,26 @@ void n64_texture_pipe_t::cycle_linear(color_t* TEX, color_t* prev, INT32 SSS, IN
mask_coupled(sstt, tile); mask_coupled(sstt, tile);
const UINT32 tbase = tile.tmem + ((tile.line * st1.get_b()) & 0x1ff); const UINT32 tbase = tile.tmem + ((tile.line * st1.get_b32()) & 0x1ff);
bool upper = ((stfrac.get_r() + stfrac.get_b()) >= 0x20); bool upper = ((stfrac.get_r32() + stfrac.get_b32()) >= 0x20);
rgbaint_t invstf(0); rgbaint_t invstf;
if (upper) if (upper)
{ {
invstf.set(stfrac); invstf.set(stfrac);
invstf.subr_imm(0x20); invstf.subr_imm(0x20);
invstf.shl_imm(3); invstf.shl_imm(3);
} }
else
{
invstf.set(0, 0, 0, 0);
}
stfrac.shl_imm(3); stfrac.shl_imm(3);
rgbaint_t t0; rgbaint_t t0;
((this)->*(m_texel_fetch[index]))(t0, st1.get_r(), st1.get_b(), tbase, tile.palette, userdata); ((this)->*(m_texel_fetch[index]))(t0, st1.get_r32(), st1.get_b32(), tbase, tile.palette, userdata);
if (object.m_other_modes.convert_one && cycle) if (object.m_other_modes.convert_one && cycle)
{ {
t0.set(*prev); t0.set(*prev);
@ -277,14 +281,14 @@ void n64_texture_pipe_t::cycle_linear(color_t* TEX, color_t* prev, INT32 SSS, IN
t0.sign_extend(0x00000100, 0xffffff00); t0.sign_extend(0x00000100, 0xffffff00);
rgbaint_t k1r(m_rdp->get_k1()); rgbaint_t k1r(m_rdp->get_k1());
k1r.mul_imm(t0.get_r()); k1r.mul_imm(t0.get_r32());
TEX->set(m_rdp->get_k023()); TEX->set(m_rdp->get_k023());
TEX->mul_imm(t0.get_g()); TEX->mul_imm(t0.get_g32());
TEX->add(k1r); TEX->add(k1r);
TEX->add_imm(0x80); TEX->add_imm(0x80);
TEX->shr_imm(8); TEX->shr_imm(8);
TEX->add_imm(t0.get_b()); TEX->add_imm(t0.get_b32());
TEX->and_imm(0x1ff); TEX->and_imm(0x1ff);
} }
@ -314,34 +318,38 @@ void n64_texture_pipe_t::cycle_linear_lerp(color_t* TEX, color_t* prev, INT32 SS
bool upper = ((stfrac.get_r32() + stfrac.get_b32()) >= 0x20); bool upper = ((stfrac.get_r32() + stfrac.get_b32()) >= 0x20);
rgbaint_t invstf(0); rgbaint_t invstf;
if (upper) if (upper)
{ {
invstf.set(stfrac); invstf.set(stfrac);
invstf.subr_imm(0x20); invstf.subr_imm(0x20);
invstf.shl_imm(3); invstf.shl_imm(3);
} }
else
{
invstf.set(0, 0, 0, 0);
}
stfrac.shl_imm(3); stfrac.shl_imm(3);
bool center = (stfrac.get_r() == 0x10) && (stfrac.get_b() == 0x10) && object.m_other_modes.mid_texel; bool center = (stfrac.get_r32() == 0x10) && (stfrac.get_b32() == 0x10) && object.m_other_modes.mid_texel;
rgbaint_t t2; rgbaint_t t2;
((this)->*(m_texel_fetch[index]))(*TEX, sstt.get_a(), sstt.get_b(), tbase1, tpal, userdata); ((this)->*(m_texel_fetch[index]))(*TEX, sstt.get_a32(), sstt.get_b32(), tbase1, tpal, userdata);
((this)->*(m_texel_fetch[index]))(t2, sstt.get_r(), sstt.get_g(), tbase2, tpal, userdata); ((this)->*(m_texel_fetch[index]))(t2, sstt.get_r32(), sstt.get_g32(), tbase2, tpal, userdata);
if (!center) if (!center)
{ {
if (upper) if (upper)
{ {
rgbaint_t t3; rgbaint_t t3;
((this)->*(m_texel_fetch[index]))(t3, sstt.get_a(), sstt.get_g(), tbase2, tpal, userdata); ((this)->*(m_texel_fetch[index]))(t3, sstt.get_a32(), sstt.get_g32(), tbase2, tpal, userdata);
TEX->sub(t3); TEX->sub(t3);
t2.sub(t3); t2.sub(t3);
TEX->mul_imm(invstf.get_b()); TEX->mul_imm(invstf.get_b32());
t2.mul_imm(invstf.get_r()); t2.mul_imm(invstf.get_r32());
TEX->add(t2); TEX->add(t2);
TEX->add_imm(0x0080); TEX->add_imm(0x0080);
@ -351,13 +359,13 @@ void n64_texture_pipe_t::cycle_linear_lerp(color_t* TEX, color_t* prev, INT32 SS
else else
{ {
rgbaint_t t0; rgbaint_t t0;
((this)->*(m_texel_fetch[index]))(t0, sstt.get_r(), sstt.get_b(), tbase1, tpal, userdata); ((this)->*(m_texel_fetch[index]))(t0, sstt.get_r32(), sstt.get_b32(), tbase1, tpal, userdata);
TEX->sub(t0); TEX->sub(t0);
t2.sub(t0); t2.sub(t0);
TEX->mul_imm(stfrac.get_r()); TEX->mul_imm(stfrac.get_r32());
t2.mul_imm(stfrac.get_b()); t2.mul_imm(stfrac.get_b32());
TEX->add(t2); TEX->add(t2);
TEX->add_imm(0x80); TEX->add_imm(0x80);
@ -368,8 +376,8 @@ void n64_texture_pipe_t::cycle_linear_lerp(color_t* TEX, color_t* prev, INT32 SS
else else
{ {
rgbaint_t t0, t3; rgbaint_t t0, t3;
((this)->*(m_texel_fetch[index]))(t0, sstt.get_r(), sstt.get_b(), tbase1, tpal, userdata); ((this)->*(m_texel_fetch[index]))(t0, sstt.get_r32(), sstt.get_b32(), tbase1, tpal, userdata);
((this)->*(m_texel_fetch[index]))(t3, sstt.get_a(), sstt.get_g(), tbase2, tpal, userdata); ((this)->*(m_texel_fetch[index]))(t3, sstt.get_a32(), sstt.get_g32(), tbase2, tpal, userdata);
TEX->add(t0); TEX->add(t0);
TEX->add(t2); TEX->add(t2);
TEX->add(t3); TEX->add(t3);
@ -396,8 +404,8 @@ void n64_texture_pipe_t::copy(color_t* TEX, INT32 SSS, INT32 SST, UINT32 tilenum
mask(st, tile); mask(st, tile);
const UINT32 index = (tile.format << 4) | (tile.size << 2) | ((UINT32) object.m_other_modes.en_tlut << 1) | (UINT32) object.m_other_modes.tlut_type; const UINT32 index = (tile.format << 4) | (tile.size << 2) | ((UINT32) object.m_other_modes.en_tlut << 1) | (UINT32) object.m_other_modes.tlut_type;
const UINT32 tbase = tile.tmem + ((tile.line * st.get_b()) & 0x1ff); const UINT32 tbase = tile.tmem + ((tile.line * st.get_b32()) & 0x1ff);
((this)->*(m_texel_fetch[index]))(*TEX, st.get_r(), st.get_b(), tbase, tile.palette, userdata); ((this)->*(m_texel_fetch[index]))(*TEX, st.get_r32(), st.get_b32(), tbase, tile.palette, userdata);
} }
void n64_texture_pipe_t::lod_1cycle(INT32* sss, INT32* sst, const INT32 s, const INT32 t, const INT32 w, const INT32 dsinc, const INT32 dtinc, const INT32 dwinc, rdp_span_aux* userdata, const rdp_poly_state& object) void n64_texture_pipe_t::lod_1cycle(INT32* sss, INT32* sst, const INT32 s, const INT32 t, const INT32 w, const INT32 dsinc, const INT32 dtinc, const INT32 dwinc, rdp_span_aux* userdata, const rdp_poly_state& object)
@ -464,7 +472,7 @@ void n64_texture_pipe_t::lod_1cycle(INT32* sss, INT32* sst, const INT32 s, const
} }
} }
userdata->m_lod_fraction.set_rgba(lod_fraction, lod_fraction, lod_fraction, lod_fraction); userdata->m_lod_fraction.set(lod_fraction, lod_fraction, lod_fraction, lod_fraction);
/* FIXME: ??? /* FIXME: ???
if(object.m_other_modes.sharpen_tex_en && magnify) if(object.m_other_modes.sharpen_tex_en && magnify)
{ {
@ -537,7 +545,7 @@ void n64_texture_pipe_t::lod_2cycle(INT32* sss, INT32* sst, const INT32 s, const
} }
} }
userdata->m_lod_fraction.set_rgba(lod_fraction, lod_fraction, lod_fraction, lod_fraction); userdata->m_lod_fraction.set(lod_fraction, lod_fraction, lod_fraction, lod_fraction);
/* FIXME: ??? /* FIXME: ???
if(object.m_other_modes.sharpen_tex_en && magnify) if(object.m_other_modes.sharpen_tex_en && magnify)
@ -666,20 +674,20 @@ void n64_texture_pipe_t::calculate_clamp_diffs(UINT32 prim_tile, rdp_span_aux* u
{ {
for (INT32 start = 0; start <= 7; start++) for (INT32 start = 0; start <= 7; start++)
{ {
userdata->m_clamp_diff[start].set_rgba(0, (tiles[start].sh >> 2) - (tiles[start].sl >> 2), 0, (tiles[start].th >> 2) - (tiles[start].tl >> 2)); userdata->m_clamp_diff[start].set(0, (tiles[start].sh >> 2) - (tiles[start].sl >> 2), 0, (tiles[start].th >> 2) - (tiles[start].tl >> 2));
} }
} }
else else
{ {
const INT32 start = prim_tile; const INT32 start = prim_tile;
const INT32 end = (prim_tile + 1) & 7; const INT32 end = (prim_tile + 1) & 7;
userdata->m_clamp_diff[start].set_rgba(0, (tiles[start].sh >> 2) - (tiles[start].sl >> 2), 0, (tiles[start].th >> 2) - (tiles[start].tl >> 2)); userdata->m_clamp_diff[start].set(0, (tiles[start].sh >> 2) - (tiles[start].sl >> 2), 0, (tiles[start].th >> 2) - (tiles[start].tl >> 2));
userdata->m_clamp_diff[end].set_rgba(0, (tiles[end].sh >> 2) - (tiles[end].sl >> 2), 0, (tiles[end].th >> 2) - (tiles[end].tl >> 2)); userdata->m_clamp_diff[end].set(0, (tiles[end].sh >> 2) - (tiles[end].sl >> 2), 0, (tiles[end].th >> 2) - (tiles[end].tl >> 2));
} }
} }
else//1-cycle or copy else//1-cycle or copy
{ {
userdata->m_clamp_diff[prim_tile].set_rgba(0, (tiles[prim_tile].sh >> 2) - (tiles[prim_tile].sl >> 2), 0, (tiles[prim_tile].th >> 2) - (tiles[prim_tile].tl >> 2)); userdata->m_clamp_diff[prim_tile].set(0, (tiles[prim_tile].sh >> 2) - (tiles[prim_tile].sl >> 2), 0, (tiles[prim_tile].th >> 2) - (tiles[prim_tile].tl >> 2));
} }
} }
@ -698,7 +706,7 @@ void n64_texture_pipe_t::fetch_rgba16_tlut0(rgbaint_t& out, INT32 s, INT32 t, IN
#if USE_64K_LUT #if USE_64K_LUT
out.set(m_expand_16to32_table[c]); out.set(m_expand_16to32_table[c]);
#else #else
out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); out.set((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c));
#endif #endif
} }
@ -710,7 +718,7 @@ void n64_texture_pipe_t::fetch_rgba16_tlut1(rgbaint_t& out, INT32 s, INT32 t, IN
c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 8) << 2]; c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 8) << 2];
const UINT8 k = (c >> 8) & 0xff; const UINT8 k = (c >> 8) & 0xff;
out.set_rgba(c & 0xff, k, k, k); out.set(c & 0xff, k, k, k);
} }
void n64_texture_pipe_t::fetch_rgba16_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_rgba16_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -722,7 +730,7 @@ void n64_texture_pipe_t::fetch_rgba16_raw(rgbaint_t& out, INT32 s, INT32 t, INT3
#if USE_64K_LUT #if USE_64K_LUT
out.set(m_expand_16to32_table[c]); out.set(m_expand_16to32_table[c]);
#else #else
out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); out.set((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c));
#endif #endif
} }
@ -737,7 +745,7 @@ void n64_texture_pipe_t::fetch_rgba32_tlut0(rgbaint_t& out, INT32 s, INT32 t, IN
#if USE_64K_LUT #if USE_64K_LUT
out.set(m_expand_16to32_table[c]); out.set(m_expand_16to32_table[c]);
#else #else
out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); out.set((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c));
#endif #endif
} }
@ -750,7 +758,7 @@ void n64_texture_pipe_t::fetch_rgba32_tlut1(rgbaint_t& out, INT32 s, INT32 t, IN
c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 24) << 2]; c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 24) << 2];
const UINT8 k = (c >> 8) & 0xff; const UINT8 k = (c >> 8) & 0xff;
out.set_rgba(c & 0xff, k, k, k); out.set(c & 0xff, k, k, k);
} }
void n64_texture_pipe_t::fetch_rgba32_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_rgba32_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -760,7 +768,7 @@ void n64_texture_pipe_t::fetch_rgba32_raw(rgbaint_t& out, INT32 s, INT32 t, INT3
const UINT16 cl = ((UINT16*)userdata->m_tmem)[taddr]; const UINT16 cl = ((UINT16*)userdata->m_tmem)[taddr];
const UINT16 ch = ((UINT16*)userdata->m_tmem)[taddr | 0x400]; const UINT16 ch = ((UINT16*)userdata->m_tmem)[taddr | 0x400];
out.set_rgba(ch & 0xff, cl >> 8, cl & 0xff, ch >> 8); out.set(ch & 0xff, cl >> 8, cl & 0xff, ch >> 8);
} }
void n64_texture_pipe_t::fetch_nop(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { } void n64_texture_pipe_t::fetch_nop(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { }
@ -782,7 +790,7 @@ void n64_texture_pipe_t::fetch_yuv(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase
u |= ((u & 0x80) << 1); u |= ((u & 0x80) << 1);
v |= ((v & 0x80) << 1); v |= ((v & 0x80) << 1);
out.set_rgba(y, y, u, v); out.set(y, y, u, v);
} }
void n64_texture_pipe_t::fetch_ci4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_ci4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -796,7 +804,7 @@ void n64_texture_pipe_t::fetch_ci4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32
#if USE_64K_LUT #if USE_64K_LUT
out.set(m_expand_16to32_table[c]); out.set(m_expand_16to32_table[c]);
#else #else
out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); out.set((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c));
#endif #endif
} }
@ -809,7 +817,7 @@ void n64_texture_pipe_t::fetch_ci4_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32
const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | p) << 2]; const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | p) << 2];
const UINT8 k = (c >> 8) & 0xff; const UINT8 k = (c >> 8) & 0xff;
out.set_rgba(c & 0xff, k, k, k); out.set(c & 0xff, k, k, k);
} }
void n64_texture_pipe_t::fetch_ci4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_ci4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -820,7 +828,7 @@ void n64_texture_pipe_t::fetch_ci4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 t
UINT8 p = (s & 1) ? (tc[taddr] & 0xf) : (tc[taddr] >> 4); UINT8 p = (s & 1) ? (tc[taddr] & 0xf) : (tc[taddr] >> 4);
p = (tpal << 4) | p; p = (tpal << 4) | p;
out.set_rgba(p, p, p, p); out.set(p, p, p, p);
} }
void n64_texture_pipe_t::fetch_ci8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_ci8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -834,7 +842,7 @@ void n64_texture_pipe_t::fetch_ci8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32
#if USE_64K_LUT #if USE_64K_LUT
out.set(m_expand_16to32_table[c]); out.set(m_expand_16to32_table[c]);
#else #else
out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); out.set((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c));
#endif #endif
} }
@ -847,7 +855,7 @@ void n64_texture_pipe_t::fetch_ci8_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32
const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[p << 2]; const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[p << 2];
const UINT8 k = (c >> 8) & 0xff; const UINT8 k = (c >> 8) & 0xff;
out.set_rgba(c & 0xff, k, k, k); out.set(c & 0xff, k, k, k);
} }
void n64_texture_pipe_t::fetch_ci8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_ci8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -856,7 +864,7 @@ void n64_texture_pipe_t::fetch_ci8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 t
const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0xfff; const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0xfff;
const UINT8 p = tc[taddr]; const UINT8 p = tc[taddr];
out.set_rgba(p, p, p, p); out.set(p, p, p, p);
} }
void n64_texture_pipe_t::fetch_ia4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_ia4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -870,7 +878,7 @@ void n64_texture_pipe_t::fetch_ia4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32
#if USE_64K_LUT #if USE_64K_LUT
out.set(m_expand_16to32_table[c]); out.set(m_expand_16to32_table[c]);
#else #else
out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); out.set((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c));
#endif #endif
} }
@ -883,7 +891,7 @@ void n64_texture_pipe_t::fetch_ia4_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32
const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | p) << 2]; const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | p) << 2];
const UINT8 k = (c >> 8) & 0xff; const UINT8 k = (c >> 8) & 0xff;
out.set_rgba(c & 0xff, k, k, k); out.set(c & 0xff, k, k, k);
} }
void n64_texture_pipe_t::fetch_ia4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_ia4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -895,7 +903,7 @@ void n64_texture_pipe_t::fetch_ia4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 t
UINT8 i = p & 0xe; UINT8 i = p & 0xe;
i = (i << 4) | (i << 1) | (i >> 2); i = (i << 4) | (i << 1) | (i >> 2);
out.set_rgba((p & 1) * 0xff, i, i, i); out.set((p & 1) * 0xff, i, i, i);
} }
void n64_texture_pipe_t::fetch_ia8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_ia8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -909,7 +917,7 @@ void n64_texture_pipe_t::fetch_ia8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32
#if USE_64K_LUT #if USE_64K_LUT
out.set(m_expand_16to32_table[c]); out.set(m_expand_16to32_table[c]);
#else #else
out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); out.set((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c));
#endif #endif
} }
@ -922,7 +930,7 @@ void n64_texture_pipe_t::fetch_ia8_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32
const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[p << 2]; const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[p << 2];
const UINT8 k = (c >> 8) & 0xff; const UINT8 k = (c >> 8) & 0xff;
out.set_rgba(c & 0xff, k, k, k); out.set(c & 0xff, k, k, k);
} }
void n64_texture_pipe_t::fetch_ia8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_ia8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -934,7 +942,7 @@ void n64_texture_pipe_t::fetch_ia8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 t
UINT8 i = p & 0xf0; UINT8 i = p & 0xf0;
i |= (i >> 4); i |= (i >> 4);
out.set_rgba((p << 4) | (p & 0xf), i, i, i); out.set((p << 4) | (p & 0xf), i, i, i);
} }
void n64_texture_pipe_t::fetch_ia16_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_ia16_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -948,7 +956,7 @@ void n64_texture_pipe_t::fetch_ia16_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT3
#if USE_64K_LUT #if USE_64K_LUT
out.set(m_expand_16to32_table[c]); out.set(m_expand_16to32_table[c]);
#else #else
out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); out.set((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c));
#endif #endif
} }
@ -961,7 +969,7 @@ void n64_texture_pipe_t::fetch_ia16_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT3
c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 8) << 2]; c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 8) << 2];
const UINT8 k = (c >> 8) & 0xff; const UINT8 k = (c >> 8) & 0xff;
out.set_rgba(c & 0xff, k, k, k); out.set(c & 0xff, k, k, k);
} }
void n64_texture_pipe_t::fetch_ia16_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_ia16_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -971,7 +979,7 @@ void n64_texture_pipe_t::fetch_ia16_raw(rgbaint_t& out, INT32 s, INT32 t, INT32
const UINT16 c = tc[taddr]; const UINT16 c = tc[taddr];
const UINT8 i = (c >> 8); const UINT8 i = (c >> 8);
out.set_rgba(c & 0xff, i, i, i); out.set(c & 0xff, i, i, i);
} }
void n64_texture_pipe_t::fetch_i4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_i4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -986,7 +994,7 @@ void n64_texture_pipe_t::fetch_i4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32
#if USE_64K_LUT #if USE_64K_LUT
out.set(m_expand_16to32_table[k]); out.set(m_expand_16to32_table[k]);
#else #else
out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); out.set((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c));
#endif #endif
} }
@ -1000,7 +1008,7 @@ void n64_texture_pipe_t::fetch_i4_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32
const UINT16 k = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | c) << 2]; const UINT16 k = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | c) << 2];
const UINT8 i = (k >> 8) & 0xff; const UINT8 i = (k >> 8) & 0xff;
out.set_rgba(k & 0xff, i, i, i); out.set(k & 0xff, i, i, i);
} }
void n64_texture_pipe_t::fetch_i4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_i4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -1012,7 +1020,7 @@ void n64_texture_pipe_t::fetch_i4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tb
UINT8 c = ((s & 1)) ? (byteval & 0xf) : ((byteval >> 4) & 0xf); UINT8 c = ((s & 1)) ? (byteval & 0xf) : ((byteval >> 4) & 0xf);
c |= (c << 4); c |= (c << 4);
out.set_rgba(c, c, c, c); out.set(c, c, c, c);
} }
void n64_texture_pipe_t::fetch_i8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_i8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -1026,7 +1034,7 @@ void n64_texture_pipe_t::fetch_i8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32
#if USE_64K_LUT #if USE_64K_LUT
out.set(m_expand_16to32_table[k]); out.set(m_expand_16to32_table[k]);
#else #else
out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); out.set((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c));
#endif #endif
} }
@ -1039,7 +1047,7 @@ void n64_texture_pipe_t::fetch_i8_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32
const UINT16 k = ((UINT16*)(userdata->m_tmem + 0x800))[c << 2]; const UINT16 k = ((UINT16*)(userdata->m_tmem + 0x800))[c << 2];
const UINT8 i = (k >> 8) & 0xff; const UINT8 i = (k >> 8) & 0xff;
out.set_rgba(k & 0xff, i, i, i); out.set(k & 0xff, i, i, i);
} }
void n64_texture_pipe_t::fetch_i8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) void n64_texture_pipe_t::fetch_i8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata)
@ -1049,5 +1057,5 @@ void n64_texture_pipe_t::fetch_i8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tb
const UINT8 c = tc[taddr]; const UINT8 c = tc[taddr];
out.set_rgba(c, c, c, c); out.set(c, c, c, c);
} }

View File

@ -27,7 +27,7 @@ class n64_texture_pipe_t
n64_texture_pipe_t() n64_texture_pipe_t()
{ {
m_maskbits_table[0] = ~0; m_maskbits_table[0] = 0x3ff;
for(int i = 1; i < 16; i++) for(int i = 1; i < 16; i++)
{ {
m_maskbits_table[i] = ((UINT16)(0xffff) >> (16 - i)) & 0x3ff; m_maskbits_table[i] = ((UINT16)(0xffff) >> (16 - i)) & 0x3ff;