mirror of
https://github.com/holub/mame
synced 2025-10-05 00:38:58 +03:00
Convert rgbint and rgbaint globals to a class (nw)
This commit is contained in:
parent
9fe201b57c
commit
fd6db5d503
@ -311,6 +311,7 @@ files {
|
||||
MAME_DIR .. "src/emu/video/rgbutil.c",
|
||||
MAME_DIR .. "src/emu/video/rgbutil.h",
|
||||
MAME_DIR .. "src/emu/video/rgbgen.h",
|
||||
MAME_DIR .. "src/emu/video/rgbsse.c",
|
||||
MAME_DIR .. "src/emu/video/rgbsse.h",
|
||||
MAME_DIR .. "src/emu/video/rgbvmx.h",
|
||||
MAME_DIR .. "src/emu/video/vector.c",
|
||||
|
@ -149,7 +149,7 @@ private:
|
||||
UINT32 pix01 = palbase[texbase[u1]];
|
||||
UINT32 pix10 = palbase[texbase[v1]];
|
||||
UINT32 pix11 = palbase[texbase[u1 + v1]];
|
||||
return rgb_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
|
||||
return rgbint_t::bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -181,11 +181,7 @@ private:
|
||||
const UINT16 *texbase = reinterpret_cast<const UINT16 *>(texture.base);
|
||||
texbase += v0 * texture.rowpixels + u0;
|
||||
|
||||
UINT32 pix00 = palbase[texbase[0]];
|
||||
UINT32 pix01 = palbase[texbase[u1]];
|
||||
UINT32 pix10 = palbase[texbase[v1]];
|
||||
UINT32 pix11 = palbase[texbase[u1 + v1]];
|
||||
return rgba_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
|
||||
return rgbint_t::bilinear_filter(palbase[texbase[0]], palbase[texbase[u1]], palbase[texbase[v1]], palbase[texbase[u1 + v1]], curu >> 8, curv >> 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -247,7 +243,7 @@ private:
|
||||
else
|
||||
pix11 = pix10;
|
||||
}
|
||||
return rgb_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
|
||||
return rgbint_t::bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -278,11 +274,7 @@ private:
|
||||
const UINT32 *texbase = reinterpret_cast<const UINT32 *>(texture.base);
|
||||
texbase += v0 * texture.rowpixels + u0;
|
||||
|
||||
UINT32 pix00 = texbase[0];
|
||||
UINT32 pix01 = texbase[u1];
|
||||
UINT32 pix10 = texbase[v1];
|
||||
UINT32 pix11 = texbase[u1 + v1];
|
||||
return rgb_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
|
||||
return rgbint_t::bilinear_filter(texbase[0], texbase[u1], texbase[v1], texbase[u1 + v1], curu >> 8, curv >> 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -313,11 +305,7 @@ private:
|
||||
const UINT32 *texbase = reinterpret_cast<const UINT32 *>(texture.base);
|
||||
texbase += v0 * texture.rowpixels + u0;
|
||||
|
||||
UINT32 pix00 = texbase[0];
|
||||
UINT32 pix01 = texbase[u1];
|
||||
UINT32 pix10 = texbase[v1];
|
||||
UINT32 pix11 = texbase[u1 + v1];
|
||||
return rgba_bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8);
|
||||
return rgbint_t::bilinear_filter(texbase[0], texbase[u1], texbase[v1], texbase[u1 + v1], curu >> 8, curv >> 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
276
src/emu/video/rgbsse.c
Normal file
276
src/emu/video/rgbsse.c
Normal file
@ -0,0 +1,276 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Vas Crabb,Ryan Holtz
|
||||
/***************************************************************************
|
||||
|
||||
rgbsse.c
|
||||
|
||||
SSE optimized RGB utilities.
|
||||
|
||||
WARNING: This code assumes SSE2 or greater capability.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include <emmintrin.h>
|
||||
#include "rgbutil.h"
|
||||
|
||||
rgbint_t::rgbint_t()
|
||||
{
|
||||
m_value = _mm_setzero_si128();
|
||||
}
|
||||
|
||||
rgbint_t::rgbint_t(UINT32 rgb)
|
||||
{
|
||||
set_rgb(rgb);
|
||||
}
|
||||
|
||||
rgbint_t::rgbint_t(INT16 r, INT16 g, INT16 b)
|
||||
{
|
||||
set_rgb(r, g, b);
|
||||
}
|
||||
|
||||
rgbint_t::rgbint_t(rgb_t& rgb)
|
||||
{
|
||||
m_value = _mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128());
|
||||
}
|
||||
|
||||
rgbaint_t::rgbaint_t()
|
||||
{
|
||||
set_rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
rgbaint_t::rgbaint_t(UINT32 argb)
|
||||
{
|
||||
m_value = _mm_set_epi16(0, 0, 0, 0, (argb >> 24) & 0xff, (argb >> 16) & 0xff, (argb >> 8) & 0xff, argb & 0xff);
|
||||
}
|
||||
|
||||
rgbaint_t::rgbaint_t(INT16 a, INT16 r, INT16 g, INT16 b)
|
||||
{
|
||||
set_rgba(a, r, g, b);
|
||||
}
|
||||
|
||||
rgbaint_t::rgbaint_t(rgb_t& rgba)
|
||||
{
|
||||
m_value = _mm_unpacklo_epi8(_mm_cvtsi32_si128(rgba), _mm_setzero_si128());
|
||||
}
|
||||
|
||||
void rgbint_t::set(__m128i value)
|
||||
{
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
void rgbint_t::set_rgb(UINT32 rgb)
|
||||
{
|
||||
m_value = _mm_set_epi16(0, 0, 0, 0, 0, (rgb >> 16) & 0xff, (rgb >> 8) & 0xff, rgb & 0xff);
|
||||
}
|
||||
|
||||
void rgbint_t::set_rgb(rgb_t& rgb)
|
||||
{
|
||||
m_value = _mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128());
|
||||
}
|
||||
|
||||
void rgbint_t::set_rgb(INT16 r, INT16 g, INT16 b)
|
||||
{
|
||||
m_value = _mm_set_epi16(0, 0, 0, 0, 0, r, g, b);
|
||||
}
|
||||
|
||||
void rgbaint_t::set_rgba(INT16 a, INT16 r, INT16 g, INT16 b)
|
||||
{
|
||||
m_value = _mm_set_epi16(0, 0, 0, 0, a, r, g, b);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
BASIC CONVERSIONS
|
||||
***************************************************************************/
|
||||
|
||||
rgb_t rgbint_t::to_rgb()
|
||||
{
|
||||
return _mm_cvtsi128_si32(_mm_packus_epi16(m_value, m_value));
|
||||
}
|
||||
|
||||
rgb_t rgbint_t::to_rgb_clamp()
|
||||
{
|
||||
return _mm_cvtsi128_si32(_mm_packus_epi16(m_value, m_value));
|
||||
}
|
||||
|
||||
rgb_t rgbint_t::to_rgba()
|
||||
{
|
||||
return to_rgb();
|
||||
}
|
||||
|
||||
rgb_t rgbint_t::to_rgba_clamp()
|
||||
{
|
||||
return to_rgb_clamp();
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
CORE MATH
|
||||
***************************************************************************/
|
||||
|
||||
void rgbint_t::add(const rgbint_t& color2)
|
||||
{
|
||||
m_value = _mm_add_epi16(m_value, color2.m_value);
|
||||
}
|
||||
|
||||
void rgbint_t::add_imm(const INT16 imm)
|
||||
{
|
||||
__m128i temp = _mm_set_epi16(0, 0, 0, 0, imm, imm, imm, imm);
|
||||
m_value = _mm_add_epi16(m_value, temp);
|
||||
}
|
||||
|
||||
void rgbint_t::add_imm_rgb(const INT16 r, const INT16 g, const INT16 b)
|
||||
{
|
||||
__m128i temp = _mm_set_epi16(0, 0, 0, 0, 0, r, g, b);
|
||||
m_value = _mm_add_epi16(m_value, temp);
|
||||
}
|
||||
|
||||
void rgbaint_t::add_imm_rgba(const INT16 a, const INT16 r, const INT16 g, const INT16 b)
|
||||
{
|
||||
__m128i temp = _mm_set_epi16(0, 0, 0, 0, a, r, g, b);
|
||||
m_value = _mm_add_epi16(m_value, temp);
|
||||
}
|
||||
|
||||
void rgbint_t::sub(const rgbint_t& color2)
|
||||
{
|
||||
m_value = _mm_sub_epi16(m_value, color2.m_value);
|
||||
}
|
||||
|
||||
void rgbint_t::sub_imm(const INT16 imm)
|
||||
{
|
||||
__m128i temp = _mm_set_epi16(0, 0, 0, 0, imm, imm, imm, imm);
|
||||
m_value = _mm_sub_epi16(m_value, temp);
|
||||
}
|
||||
|
||||
void rgbint_t::sub_imm_rgb(const INT16 r, const INT16 g, const INT16 b)
|
||||
{
|
||||
__m128i temp = _mm_set_epi16(0, 0, 0, 0, 0, r, g, b);
|
||||
m_value = _mm_sub_epi16(m_value, temp);
|
||||
}
|
||||
|
||||
void rgbaint_t::sub_imm_rgba(const INT16 a, const INT16 r, const INT16 g, const INT16 b)
|
||||
{
|
||||
__m128i temp = _mm_set_epi16(0, 0, 0, 0, a, r, g, b);
|
||||
m_value = _mm_sub_epi16(m_value, temp);
|
||||
}
|
||||
|
||||
void rgbint_t::subr(rgbint_t& color2)
|
||||
{
|
||||
color2.m_value = _mm_sub_epi16(color2.m_value, m_value);
|
||||
}
|
||||
|
||||
void rgbint_t::subr_imm(const INT16 imm)
|
||||
{
|
||||
__m128i temp = _mm_set_epi16(0, 0, 0, 0, imm, imm, imm, imm);
|
||||
m_value = _mm_sub_epi16(temp, m_value);
|
||||
}
|
||||
|
||||
void rgbint_t::subr_imm_rgb(const INT16 r, const INT16 g, const INT16 b)
|
||||
{
|
||||
__m128i temp = _mm_set_epi16(0, 0, 0, 0, 0, r, g, b);
|
||||
m_value = _mm_sub_epi16(temp, m_value);
|
||||
}
|
||||
|
||||
void rgbaint_t::subr_imm_rgba(const INT16 a, const INT16 r, const INT16 g, const INT16 b)
|
||||
{
|
||||
__m128i temp = _mm_set_epi16(0, 0, 0, 0, a, r, g, b);
|
||||
m_value = _mm_sub_epi16(temp, m_value);
|
||||
}
|
||||
|
||||
void rgbint_t::shl(UINT8 shift)
|
||||
{
|
||||
m_value = _mm_slli_epi16(m_value, shift);
|
||||
}
|
||||
|
||||
void rgbint_t::shr(UINT8 shift)
|
||||
{
|
||||
m_value = _mm_srli_epi16(m_value, shift);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
HIGHER LEVEL OPERATIONS
|
||||
***************************************************************************/
|
||||
|
||||
void rgbint_t::blend(const rgbint_t& other, UINT8 factor)
|
||||
{
|
||||
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_srli_epi32(m_value, 8);
|
||||
m_value = _mm_packs_epi32(m_value, m_value);
|
||||
}
|
||||
|
||||
void rgbint_t::scale_and_clamp(const rgbint_t& scale)
|
||||
{
|
||||
__m128i mscale = _mm_unpacklo_epi16(scale.m_value, _mm_setzero_si128());
|
||||
m_value = _mm_unpacklo_epi16(m_value, _mm_setzero_si128());
|
||||
m_value = _mm_madd_epi16(m_value, mscale);
|
||||
m_value = _mm_srli_epi32(m_value, 8);
|
||||
m_value = _mm_packs_epi32(m_value, m_value);
|
||||
m_value = _mm_min_epi16(m_value, *(__m128i *)&rgbsse_statics.maxbyte);
|
||||
}
|
||||
|
||||
void rgbint_t::scale_imm_and_clamp(const INT16 scale)
|
||||
{
|
||||
__m128i mscale = _mm_set1_epi16(scale);
|
||||
m_value = _mm_unpacklo_epi16(m_value, _mm_setzero_si128());
|
||||
m_value = _mm_madd_epi16(m_value, mscale);
|
||||
m_value = _mm_srli_epi32(m_value, 8);
|
||||
m_value = _mm_packs_epi32(m_value, m_value);
|
||||
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)
|
||||
{
|
||||
__m128i mscale = _mm_unpacklo_epi16(scale.m_value, scale2.m_value);
|
||||
m_value = _mm_unpacklo_epi16(m_value, other.m_value);
|
||||
m_value = _mm_madd_epi16(m_value, mscale);
|
||||
m_value = _mm_srli_epi32(m_value, 8);
|
||||
m_value = _mm_packs_epi32(m_value, m_value);
|
||||
m_value = _mm_min_epi16(m_value, *(__m128i *)&rgbsse_statics.maxbyte);
|
||||
}
|
||||
|
||||
void rgbint_t::scale_imm_add_and_clamp(const INT16 scale, const rgbint_t& other)
|
||||
{
|
||||
// color2 will get mutiplied by 2^8 (256) and then divided by 2^8 by the shift by 8
|
||||
__m128i mscale = _mm_unpacklo_epi16(_mm_set1_epi16(scale), _mm_set_epi16(0, 0, 0, 0, 256, 256, 256, 256));
|
||||
m_value = _mm_unpacklo_epi16(m_value, other.m_value);
|
||||
m_value = _mm_madd_epi16(m_value, mscale);
|
||||
m_value = _mm_srli_epi32(m_value, 8);
|
||||
m_value = _mm_packs_epi32(m_value, m_value);
|
||||
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)
|
||||
{
|
||||
// color2 will get mutiplied by 2^8 (256) and then divided by 2^8 by the shift by 8
|
||||
__m128i mscale = _mm_unpacklo_epi16(scale.m_value, _mm_set_epi16(0, 0, 0, 0, 256, 256, 256, 256));
|
||||
m_value = _mm_unpacklo_epi16(m_value, other.m_value);
|
||||
m_value = _mm_madd_epi16(m_value, mscale);
|
||||
m_value = _mm_srli_epi32(m_value, 8);
|
||||
m_value = _mm_packs_epi32(m_value, m_value);
|
||||
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)
|
||||
{
|
||||
__m128i color00 = _mm_cvtsi32_si128(rgb00);
|
||||
__m128i color01 = _mm_cvtsi32_si128(rgb01);
|
||||
__m128i color10 = _mm_cvtsi32_si128(rgb10);
|
||||
__m128i color11 = _mm_cvtsi32_si128(rgb11);
|
||||
|
||||
/* interleave color01 and color00 at the byte level */
|
||||
color01 = _mm_unpacklo_epi8(color01, color00);
|
||||
color11 = _mm_unpacklo_epi8(color11, color10);
|
||||
color01 = _mm_unpacklo_epi8(color01, _mm_setzero_si128());
|
||||
color11 = _mm_unpacklo_epi8(color11, _mm_setzero_si128());
|
||||
color01 = _mm_madd_epi16(color01, *(__m128i *)&rgbsse_statics.scale_table[u][0]);
|
||||
color11 = _mm_madd_epi16(color11, *(__m128i *)&rgbsse_statics.scale_table[u][0]);
|
||||
color01 = _mm_slli_epi32(color01, 15);
|
||||
color11 = _mm_srli_epi32(color11, 1);
|
||||
color01 = _mm_max_epi16(color01, color11);
|
||||
color01 = _mm_madd_epi16(color01, *(__m128i *)&rgbsse_statics.scale_table[v][0]);
|
||||
color01 = _mm_srli_epi32(color01, 15);
|
||||
color01 = _mm_packs_epi32(color01, color01);
|
||||
color01 = _mm_packus_epi16(color01, color01);
|
||||
return _mm_cvtsi128_si32(color01);
|
||||
}
|
@ -15,237 +15,74 @@
|
||||
|
||||
#include <emmintrin.h>
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
|
||||
/* intermediate RGB values are stored in an __m128i */
|
||||
typedef __m128i rgbint;
|
||||
|
||||
/* intermediate RGB values are stored in an __m128i */
|
||||
typedef __m128i rgbaint;
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
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)
|
||||
class rgbint_t : public rgbint_base_t
|
||||
{
|
||||
*rgb = _mm_set_epi16(0, 0, 0, 0, 0, r, g, b);
|
||||
}
|
||||
public:
|
||||
rgbint_t();
|
||||
rgbint_t(UINT32 rgb);
|
||||
rgbint_t(INT16 r, INT16 g, INT16 b);
|
||||
rgbint_t(rgb_t& rgb);
|
||||
|
||||
virtual void* get_ptr() { return &m_value; }
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgba_comp_to_rgbint - converts a quad of RGB
|
||||
components to an rgbint type
|
||||
-------------------------------------------------*/
|
||||
virtual void set(__m128i value);
|
||||
virtual void set_rgb(UINT32 rgb);
|
||||
virtual void set_rgb(INT16 r, INT16 g, INT16 b);
|
||||
virtual void set_rgb(rgb_t& rgb);
|
||||
|
||||
INLINE void rgba_comp_to_rgbaint(rgbaint *rgb, INT16 a, INT16 r, INT16 g, INT16 b)
|
||||
virtual rgb_t to_rgb();
|
||||
virtual rgb_t to_rgb_clamp();
|
||||
|
||||
virtual rgb_t to_rgba();
|
||||
virtual rgb_t to_rgba_clamp();
|
||||
|
||||
void add(const rgbint_t& color2);
|
||||
virtual void add_imm(const INT16 imm);
|
||||
virtual void add_imm_rgb(const INT16 imm_r, const INT16 imm_g, const INT16 imm_b);
|
||||
|
||||
virtual void sub(const rgbint_t& color2);
|
||||
virtual void sub_imm(const INT16 imm);
|
||||
virtual void sub_imm_rgb(const INT16 imm_r, const INT16 imm_g, const INT16 imm_b);
|
||||
|
||||
void subr(rgbint_t& color);
|
||||
virtual void subr_imm(const INT16 imm);
|
||||
virtual void subr_imm_rgb(const INT16 imm_r, const INT16 imm_g, const INT16 imm_b);
|
||||
|
||||
void shl(const UINT8 shift);
|
||||
void shr(const UINT8 shift);
|
||||
|
||||
virtual void blend(const rgbint_t& other, UINT8 factor);
|
||||
|
||||
virtual void scale_and_clamp(const rgbint_t& scale);
|
||||
virtual void scale_imm_and_clamp(const INT16 scale);
|
||||
virtual void scale_add_and_clamp(const rgbint_t& scale, const rgbint_t& other, const rgbint_t& scale2);
|
||||
virtual void scale_add_and_clamp(const rgbint_t& scale, const rgbint_t& other);
|
||||
virtual void scale_imm_add_and_clamp(const INT16 scale, const rgbint_t& other);
|
||||
|
||||
static UINT32 bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v);
|
||||
|
||||
protected:
|
||||
__m128i m_value;
|
||||
};
|
||||
|
||||
class rgbaint_t : public rgbint_t
|
||||
{
|
||||
*rgb = _mm_set_epi16(0, 0, 0, 0, a, r, g, b);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgb_to_rgbint - converts a packed trio of RGB
|
||||
components to an rgbint type
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgb_to_rgbint(rgbint *rgb, rgb_t color)
|
||||
{
|
||||
*rgb = _mm_unpacklo_epi8(_mm_cvtsi32_si128(color), _mm_setzero_si128());
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgba_to_rgbaint - converts a packed quad of RGB
|
||||
components to an rgbint type
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgba_to_rgbaint(rgbaint *rgb, rgb_t color)
|
||||
{
|
||||
*rgb = _mm_unpacklo_epi8(_mm_cvtsi32_si128(color), _mm_setzero_si128());
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbint_to_rgb - converts an rgbint back to
|
||||
a packed trio of RGB values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE rgb_t rgbint_to_rgb(const rgbint *color)
|
||||
{
|
||||
return _mm_cvtsi128_si32(_mm_packus_epi16(*color, *color));
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbaint_to_rgba - converts an rgbint back to
|
||||
a packed quad of RGB values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE rgb_t rgbaint_to_rgba(const rgbaint *color)
|
||||
{
|
||||
return _mm_cvtsi128_si32(_mm_packus_epi16(*color, *color));
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbint_to_rgb_clamp - converts an rgbint back
|
||||
to a packed trio of RGB values, clamping them
|
||||
to bytes first
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE rgb_t rgbint_to_rgb_clamp(const rgbint *color)
|
||||
{
|
||||
return _mm_cvtsi128_si32(_mm_packus_epi16(*color, *color));
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbaint_to_rgba_clamp - converts an rgbint back
|
||||
to a packed quad of RGB values, clamping them
|
||||
to bytes first
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE rgb_t rgbaint_to_rgba_clamp(const rgbaint *color)
|
||||
{
|
||||
return _mm_cvtsi128_si32(_mm_packus_epi16(*color, *color));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
CORE MATH
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbint_add - add two rgbint values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbint_add(rgbint *color1, const rgbint *color2)
|
||||
{
|
||||
*color1 = _mm_add_epi16(*color1, *color2);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbaint_add - add two rgbaint values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbaint_add(rgbaint *color1, const rgbaint *color2)
|
||||
{
|
||||
*color1 = _mm_add_epi16(*color1, *color2);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbaint_add_imm - add immediate INT16 to rgbaint value
|
||||
-------------------------------------------------*/
|
||||
INLINE void rgbaint_add_imm(rgbaint *color1, const INT16 imm)
|
||||
{
|
||||
__m128i temp = _mm_set_epi16(0, 0, 0, 0, imm, imm, imm, imm);
|
||||
*color1 = _mm_add_epi16(*color1, temp);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbint_sub - subtract two rgbint values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbint_sub(rgbint *color1, const rgbint *color2)
|
||||
{
|
||||
*color1 = _mm_sub_epi16(*color1, *color2);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbaint_sub - subtract two rgbaint values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbaint_sub(rgbaint *color1, const rgbaint *color2)
|
||||
{
|
||||
*color1 = _mm_sub_epi16(*color1, *color2);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbint_subr - reverse subtract two rgbint
|
||||
values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbint_subr(rgbint *color1, const rgbint *color2)
|
||||
{
|
||||
__m128i temp = *color1;
|
||||
*color1 = *color2;
|
||||
*color1 = _mm_sub_epi16(*color1, temp);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbaint_subr - reverse subtract two rgbaint
|
||||
values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbaint_subr(rgbaint *color1, const rgbaint *color2)
|
||||
{
|
||||
__m128i temp = *color1;
|
||||
*color1 = *color2;
|
||||
*color1 = _mm_sub_epi16(*color1, temp);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbint_shl - shift each component of an
|
||||
rgbint struct by the given number of bits
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbint_shl(rgbint *color, UINT8 shift)
|
||||
{
|
||||
*color = _mm_slli_epi16(*color, shift);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbaint_shl - shift each component of an
|
||||
rgbaint struct by the given number of bits
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbaint_shl(rgbaint *color, UINT8 shift)
|
||||
{
|
||||
*color = _mm_slli_epi16(*color, shift);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbint_shr - shift each component of an
|
||||
rgbint struct by the given number of bits
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbint_shr(rgbint *color, UINT8 shift)
|
||||
{
|
||||
*color = _mm_srli_epi16(*color, shift);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbaint_shr - shift each component of an
|
||||
rgbaint struct by the given number of bits
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbaint_shr(rgbaint *color, UINT8 shift)
|
||||
{
|
||||
*color = _mm_srli_epi16(*color, shift);
|
||||
}
|
||||
public:
|
||||
rgbaint_t();
|
||||
rgbaint_t(UINT32 rgba);
|
||||
rgbaint_t(INT16 a, INT16 r, INT16 g, INT16 b);
|
||||
rgbaint_t(rgb_t& rgb);
|
||||
|
||||
virtual void set_rgba(INT16 a, INT16 r, INT16 g, INT16 b);
|
||||
|
||||
virtual void add_imm_rgba(const INT16 imm_a, const INT16 imm_r, const INT16 imm_g, const INT16 imm_b);
|
||||
virtual void sub_imm_rgba(const INT16 imm_a, const INT16 imm_r, const INT16 imm_g, const INT16 imm_b);
|
||||
virtual void subr_imm_rgba(const INT16 imm_a, const INT16 imm_r, const INT16 imm_g, const INT16 imm_b);
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
TABLES
|
||||
@ -258,191 +95,4 @@ extern const struct _rgbsse_statics
|
||||
INT16 scale_table[256][8];
|
||||
} rgbsse_statics;
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
HIGHER LEVEL OPERATIONS
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbint_blend - blend two colors by the given
|
||||
scale factor
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbint_blend(rgbint *color1, const rgbint *color2, UINT8 color1scale)
|
||||
{
|
||||
*color1 = _mm_unpacklo_epi16(*color1, *color2);
|
||||
*color1 = _mm_madd_epi16(*color1, *(__m128i *)&rgbsse_statics.scale_table[color1scale][0]);
|
||||
*color1 = _mm_srli_epi32(*color1, 8);
|
||||
*color1 = _mm_packs_epi32(*color1, *color1);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbaint_blend - blend two colors by the given
|
||||
scale factor
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbaint_blend(rgbaint *color1, const rgbaint *color2, UINT8 color1scale)
|
||||
{
|
||||
rgbint_blend(color1, color2, color1scale);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbint_scale_and_clamp - scale the given
|
||||
color by an 8.8 scale factor, immediate or
|
||||
per channel, and clamp to byte values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbint_scale_immediate_and_clamp(rgbint *color, INT16 colorscale)
|
||||
{
|
||||
__m128i mscale = _mm_set1_epi16(colorscale);
|
||||
*color = _mm_unpacklo_epi16(*color, _mm_setzero_si128());
|
||||
*color = _mm_madd_epi16(*color, mscale);
|
||||
*color = _mm_srli_epi32(*color, 8);
|
||||
*color = _mm_packs_epi32(*color, *color);
|
||||
*color = _mm_min_epi16(*color, *(__m128i *)&rgbsse_statics.maxbyte);
|
||||
}
|
||||
|
||||
INLINE void rgbint_scale_channel_and_clamp(rgbint *color, const rgbint *colorscale)
|
||||
{
|
||||
__m128i mscale = _mm_unpacklo_epi16(*colorscale, _mm_setzero_si128());
|
||||
*color = _mm_unpacklo_epi16(*color, _mm_setzero_si128());
|
||||
*color = _mm_madd_epi16(*color, mscale);
|
||||
*color = _mm_srli_epi32(*color, 8);
|
||||
*color = _mm_packs_epi32(*color, *color);
|
||||
*color = _mm_min_epi16(*color, *(__m128i *)&rgbsse_statics.maxbyte);
|
||||
}
|
||||
|
||||
INLINE void rgbaint_scale_immediate_add_and_clamp(rgbaint *color1, INT16 colorscale, const rgbaint *color2)
|
||||
{
|
||||
// color2 will get mutiplied by 2^8 (256) and then divided by 2^8 by the shift by 8
|
||||
__m128i mscale = _mm_unpacklo_epi16(_mm_set1_epi16(colorscale), _mm_set_epi16(0, 0, 0, 0, 256, 256, 256, 256));
|
||||
*color1 = _mm_unpacklo_epi16(*color1, *color2);
|
||||
*color1 = _mm_madd_epi16(*color1, mscale);
|
||||
*color1 = _mm_srli_epi32(*color1, 8);
|
||||
*color1 = _mm_packs_epi32(*color1, *color1);
|
||||
*color1 = _mm_min_epi16(*color1, *(__m128i *)&rgbsse_statics.maxbyte);
|
||||
}
|
||||
|
||||
INLINE void rgbaint_scale_channel_add_and_clamp(rgbaint *color1, const rgbaint *colorscale, const rgbaint *color2)
|
||||
{
|
||||
// color2 will get mutiplied by 2^8 (256) and then divided by 2^8 by the shift by 8
|
||||
__m128i mscale = _mm_unpacklo_epi16(*colorscale, _mm_set_epi16(0, 0, 0, 0, 256, 256, 256, 256));
|
||||
*color1 = _mm_unpacklo_epi16(*color1, *color2);
|
||||
*color1 = _mm_madd_epi16(*color1, mscale);
|
||||
*color1 = _mm_srli_epi32(*color1, 8);
|
||||
*color1 = _mm_packs_epi32(*color1, *color1);
|
||||
*color1 = _mm_min_epi16(*color1, *(__m128i *)&rgbsse_statics.maxbyte);
|
||||
}
|
||||
|
||||
INLINE void rgbaint_scale_channel_add_and_clamp(rgbaint *color1, const rgbaint *colorscale1, const rgbaint *color2, const rgbaint *colorscale2)
|
||||
|
||||
{
|
||||
__m128i mscale = _mm_unpacklo_epi16(*colorscale1, *colorscale2);
|
||||
*color1 = _mm_unpacklo_epi16(*color1, *color2);
|
||||
*color1 = _mm_madd_epi16(*color1, mscale);
|
||||
*color1 = _mm_srli_epi32(*color1, 8);
|
||||
*color1 = _mm_packs_epi32(*color1, *color1);
|
||||
*color1 = _mm_min_epi16(*color1, *(__m128i *)&rgbsse_statics.maxbyte);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
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 rgbaint_scale_immediate_and_clamp(rgbaint *color, INT16 colorscale)
|
||||
{
|
||||
rgbint_scale_immediate_and_clamp(color, colorscale);
|
||||
}
|
||||
|
||||
INLINE void rgbaint_scale_channel_and_clamp(rgbaint *color, const rgbint *colorscale)
|
||||
{
|
||||
rgbint_scale_channel_and_clamp(color, color);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgb_bilinear_filter - bilinear filter between
|
||||
four pixel values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE UINT32 rgb_bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
|
||||
{
|
||||
__m128i color00 = _mm_cvtsi32_si128(rgb00);
|
||||
__m128i color01 = _mm_cvtsi32_si128(rgb01);
|
||||
__m128i color10 = _mm_cvtsi32_si128(rgb10);
|
||||
__m128i color11 = _mm_cvtsi32_si128(rgb11);
|
||||
|
||||
/* interleave color01 and color00 at the byte level */
|
||||
color01 = _mm_unpacklo_epi8(color01, color00);
|
||||
color11 = _mm_unpacklo_epi8(color11, color10);
|
||||
color01 = _mm_unpacklo_epi8(color01, _mm_setzero_si128());
|
||||
color11 = _mm_unpacklo_epi8(color11, _mm_setzero_si128());
|
||||
color01 = _mm_madd_epi16(color01, *(__m128i *)&rgbsse_statics.scale_table[u][0]);
|
||||
color11 = _mm_madd_epi16(color11, *(__m128i *)&rgbsse_statics.scale_table[u][0]);
|
||||
color01 = _mm_slli_epi32(color01, 15);
|
||||
color11 = _mm_srli_epi32(color11, 1);
|
||||
color01 = _mm_max_epi16(color01, color11);
|
||||
color01 = _mm_madd_epi16(color01, *(__m128i *)&rgbsse_statics.scale_table[v][0]);
|
||||
color01 = _mm_srli_epi32(color01, 15);
|
||||
color01 = _mm_packs_epi32(color01, color01);
|
||||
color01 = _mm_packus_epi16(color01, color01);
|
||||
return _mm_cvtsi128_si32(color01);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgba_bilinear_filter - bilinear filter between
|
||||
four pixel values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE UINT32 rgba_bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
|
||||
{
|
||||
return rgb_bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbint_bilinear_filter - bilinear filter between
|
||||
four pixel values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbint_bilinear_filter(rgbint *color, UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
|
||||
{
|
||||
__m128i color00 = _mm_cvtsi32_si128(rgb00);
|
||||
__m128i color01 = _mm_cvtsi32_si128(rgb01);
|
||||
__m128i color10 = _mm_cvtsi32_si128(rgb10);
|
||||
__m128i color11 = _mm_cvtsi32_si128(rgb11);
|
||||
|
||||
/* interleave color01 and color00 at the byte level */
|
||||
color01 = _mm_unpacklo_epi8(color01, color00);
|
||||
color11 = _mm_unpacklo_epi8(color11, color10);
|
||||
color01 = _mm_unpacklo_epi8(color01, _mm_setzero_si128());
|
||||
color11 = _mm_unpacklo_epi8(color11, _mm_setzero_si128());
|
||||
color01 = _mm_madd_epi16(color01, *(__m128i *)&rgbsse_statics.scale_table[u][0]);
|
||||
color11 = _mm_madd_epi16(color11, *(__m128i *)&rgbsse_statics.scale_table[u][0]);
|
||||
color01 = _mm_slli_epi32(color01, 15);
|
||||
color11 = _mm_srli_epi32(color11, 1);
|
||||
color01 = _mm_max_epi16(color01, color11);
|
||||
color01 = _mm_madd_epi16(color01, *(__m128i *)&rgbsse_statics.scale_table[v][0]);
|
||||
color01 = _mm_srli_epi32(color01, 15);
|
||||
*color = _mm_packs_epi32(color01, color01);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
rgbaint_bilinear_filter - bilinear filter between
|
||||
four pixel values
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void rgbaint_bilinear_filter(rgbaint *color, UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v)
|
||||
{
|
||||
rgbint_bilinear_filter(color, rgb00, rgb01, rgb10, rgb11, u, v);
|
||||
}
|
||||
|
||||
|
||||
#endif /* __RGBSSE__ */
|
||||
|
@ -12,6 +12,37 @@
|
||||
#ifndef __RGBUTIL__
|
||||
#define __RGBUTIL__
|
||||
|
||||
class rgbint_base_t
|
||||
{
|
||||
public:
|
||||
rgbint_base_t() { }
|
||||
rgbint_base_t(UINT32 rgb) { }
|
||||
rgbint_base_t(INT16 r, INT16 g, INT16 b) { }
|
||||
rgbint_base_t(rgb_t& rgb) { }
|
||||
|
||||
virtual void set_rgb(UINT32 rgb) = 0;
|
||||
virtual void set_rgb(INT16 r, INT16 g, INT16 b) = 0;
|
||||
virtual void set_rgb(rgb_t& rgb) = 0;
|
||||
|
||||
virtual rgb_t to_rgb() = 0;
|
||||
virtual rgb_t to_rgb_clamp() = 0;
|
||||
|
||||
virtual rgb_t to_rgba() = 0;
|
||||
virtual rgb_t to_rgba_clamp() = 0;
|
||||
|
||||
virtual void add_imm(const INT16 imm) = 0;
|
||||
virtual void add_imm_rgb(const INT16 imm_r, const INT16 imm_g, const INT16 imm_b) = 0;
|
||||
|
||||
virtual void sub_imm(const INT16 imm) = 0;
|
||||
virtual void sub_imm_rgb(const INT16 imm_r, const INT16 imm_g, const INT16 imm_b) = 0;
|
||||
|
||||
virtual void subr_imm(const INT16 imm) = 0;
|
||||
virtual void subr_imm_rgb(const INT16 imm_r, const INT16 imm_g, const INT16 imm_b) = 0;
|
||||
|
||||
virtual void shl(const UINT8 shift) = 0;
|
||||
virtual void shr(const UINT8 shift) = 0;
|
||||
};
|
||||
|
||||
/* use SSE on 64-bit implementations, where it can be assumed */
|
||||
#if (!defined(MAME_DEBUG) || defined(__OPTIMIZE__)) && (defined(__SSE2__) || defined(_MSC_VER)) && defined(PTR64)
|
||||
#include "rgbsse.h"
|
||||
|
@ -2202,29 +2202,28 @@ while (0)
|
||||
INLINE UINT32 clampARGB(INT32 iterr, INT32 iterg, INT32 iterb, INT32 itera, UINT32 FBZCP)
|
||||
{
|
||||
rgb_t result;
|
||||
rgbaint colorint;
|
||||
rgba_comp_to_rgbaint(&colorint, (INT16) (itera>>12), (INT16) (iterr>>12), (INT16) (iterg>>12), (INT16) (iterb>>12));
|
||||
rgbaint_t colorint((INT16) (itera>>12), (INT16) (iterr>>12), (INT16) (iterg>>12), (INT16) (iterb>>12));
|
||||
|
||||
if (FBZCP_RGBZW_CLAMP(FBZCP) == 0)
|
||||
{
|
||||
//r &= 0xfff;
|
||||
__m128i temp = _mm_set1_epi16(0xfff);
|
||||
colorint = _mm_and_si128(*(__m128i *)&colorint, *(__m128i *)&temp);
|
||||
colorint.set(_mm_and_si128(*(__m128i *)colorint.get_ptr(), *(__m128i *)&temp));
|
||||
//if (r == 0xfff)
|
||||
temp = _mm_cmpeq_epi16(*(__m128i *)&colorint, *(__m128i *)&temp);
|
||||
temp = _mm_cmpeq_epi16(*(__m128i *)colorint.get_ptr(), *(__m128i *)&temp);
|
||||
// result.rgb.r = 0;
|
||||
colorint = _mm_andnot_si128(*(__m128i *)&temp, *(__m128i *)&colorint);
|
||||
colorint.set(_mm_andnot_si128(*(__m128i *)&temp, *(__m128i *)colorint.get_ptr()));
|
||||
//else if (r == 0x100)
|
||||
temp = _mm_set1_epi16(0x100);
|
||||
temp = _mm_cmpeq_epi16(*(__m128i *)&colorint, *(__m128i *)&temp);
|
||||
temp = _mm_cmpeq_epi16(*(__m128i *)colorint.get_ptr(), *(__m128i *)&temp);
|
||||
// result.rgb.r = 0xff;
|
||||
colorint = _mm_or_si128(*(__m128i *)&colorint, *(__m128i *)&temp);
|
||||
colorint.set(_mm_or_si128(*(__m128i *)colorint.get_ptr(), *(__m128i *)&temp));
|
||||
|
||||
result = rgbaint_to_rgba(&colorint);
|
||||
result = colorint.to_rgba();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = rgbaint_to_rgba_clamp(&colorint);
|
||||
result = colorint.to_rgba_clamp();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -2817,7 +2816,7 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
|
||||
int sa = color.rgb.a;
|
||||
int ta;
|
||||
int srcAlphaScale, destAlphaScale;
|
||||
rgbaint srcScale, destScale;
|
||||
rgbaint_t srcScale, destScale;
|
||||
|
||||
/* apply dither subtraction */
|
||||
if (FBZMODE_ALPHA_DITHER_SUBTRACT(FBZMODE))
|
||||
@ -2842,20 +2841,20 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
|
||||
{
|
||||
default: /* reserved */
|
||||
case 0: /* AZERO */
|
||||
rgba_comp_to_rgbaint(&srcScale, srcAlphaScale, 0, 0, 0);
|
||||
srcScale.set_rgba(srcAlphaScale, 0, 0, 0);
|
||||
//(RR) = (GG) = (BB) = 0;
|
||||
break;
|
||||
|
||||
case 1: /* ASRC_ALPHA */
|
||||
rgba_comp_to_rgbaint(&srcScale, srcAlphaScale, sa, sa, sa);
|
||||
srcScale.set_rgba(srcAlphaScale, sa, sa, sa);
|
||||
//(RR) = (sr * (sa + 1)) >> 8;
|
||||
//(GG) = (sg * (sa + 1)) >> 8;
|
||||
//(BB) = (sb * (sa + 1)) >> 8;
|
||||
break;
|
||||
|
||||
case 2: /* A_COLOR */
|
||||
rgba_comp_to_rgbaint(&srcScale, srcAlphaScale-1, dr, dg, db);
|
||||
rgbaint_add_imm(&srcScale, 1);
|
||||
srcScale.set_rgba(srcAlphaScale-1, dr, dg, db);
|
||||
srcScale.add_imm(1);
|
||||
//(RR) = (sr * (dr + 1)) >> 8;
|
||||
//(GG) = (sg * (dg + 1)) >> 8;
|
||||
//(BB) = (sb * (db + 1)) >> 8;
|
||||
@ -2863,26 +2862,26 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
|
||||
|
||||
case 3: /* ADST_ALPHA */
|
||||
ta = da + 1;
|
||||
rgba_comp_to_rgbaint(&srcScale, srcAlphaScale, ta, ta, ta);
|
||||
srcScale.set_rgba(srcAlphaScale, ta, ta, ta);
|
||||
//(RR) = (sr * (da + 1)) >> 8;
|
||||
//(GG) = (sg * (da + 1)) >> 8;
|
||||
//(BB) = (sb * (da + 1)) >> 8;
|
||||
break;
|
||||
|
||||
case 4: /* AONE */
|
||||
rgba_comp_to_rgbaint(&srcScale, srcAlphaScale, 256, 256, 256);
|
||||
srcScale.set_rgba(srcAlphaScale, 256, 256, 256);
|
||||
break;
|
||||
|
||||
case 5: /* AOMSRC_ALPHA */
|
||||
ta = (0x100 - sa);
|
||||
rgba_comp_to_rgbaint(&srcScale, srcAlphaScale, ta, ta, ta);
|
||||
srcScale.set_rgba(srcAlphaScale, ta, ta, ta);
|
||||
//(RR) = (sr * (0x100 - sa)) >> 8;
|
||||
//(GG) = (sg * (0x100 - sa)) >> 8;
|
||||
//(BB) = (sb * (0x100 - sa)) >> 8;
|
||||
break;
|
||||
|
||||
case 6: /* AOM_COLOR */
|
||||
rgba_comp_to_rgbaint(&srcScale, srcAlphaScale, (0x100 - dr), (0x100 - dg), (0x100 - db));
|
||||
srcScale.set_rgba(srcAlphaScale, (0x100 - dr), (0x100 - dg), (0x100 - db));
|
||||
//(RR) = (sr * (0x100 - dr)) >> 8;
|
||||
//(GG) = (sg * (0x100 - dg)) >> 8;
|
||||
//(BB) = (sb * (0x100 - db)) >> 8;
|
||||
@ -2890,7 +2889,7 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
|
||||
|
||||
case 7: /* AOMDST_ALPHA */
|
||||
ta = (0x100 - da);
|
||||
rgba_comp_to_rgbaint(&srcScale, srcAlphaScale, ta, ta, ta);
|
||||
srcScale.set_rgba(srcAlphaScale, ta, ta, ta);
|
||||
//(RR) = (sr * (0x100 - da)) >> 8;
|
||||
//(GG) = (sg * (0x100 - da)) >> 8;
|
||||
//(BB) = (sb * (0x100 - da)) >> 8;
|
||||
@ -2898,7 +2897,7 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
|
||||
|
||||
case 15: /* ASATURATE */
|
||||
ta = (sa < (0x100 - da)) ? sa : (0x100 - da);
|
||||
rgba_comp_to_rgbaint(&srcScale, srcAlphaScale, ta, ta, ta);
|
||||
srcScale.set_rgba(srcAlphaScale, ta, ta, ta);
|
||||
//(RR) = (sr * (ta + 1)) >> 8;
|
||||
//(GG) = (sg * (ta + 1)) >> 8;
|
||||
//(BB) = (sb * (ta + 1)) >> 8;
|
||||
@ -2916,20 +2915,20 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
|
||||
{
|
||||
default: /* reserved */
|
||||
case 0: /* AZERO */
|
||||
rgba_comp_to_rgbaint(&destScale, destAlphaScale, 0, 0, 0);
|
||||
destScale.set_rgba(destAlphaScale, 0, 0, 0);
|
||||
break;
|
||||
|
||||
case 1: /* ASRC_ALPHA */
|
||||
rgba_comp_to_rgbaint(&destScale, destAlphaScale, sa, sa, sa);
|
||||
rgbaint_add_imm(&destScale, 1);
|
||||
destScale.set_rgba(destAlphaScale, sa, sa, sa);
|
||||
destScale.add_imm(1);
|
||||
//(RR) += (dr * (sa + 1)) >> 8;
|
||||
//(GG) += (dg * (sa + 1)) >> 8;
|
||||
//(BB) += (db * (sa + 1)) >> 8;
|
||||
break;
|
||||
|
||||
case 2: /* A_COLOR */
|
||||
rgba_to_rgbaint(&destScale, (rgb_t) (((destAlphaScale-1)<<24) | (color.u & 0x00ffffff)));
|
||||
rgbaint_add_imm(&destScale, 1);
|
||||
destScale.set_rgb((rgb_t) (((destAlphaScale-1)<<24) | (color.u & 0x00ffffff)));
|
||||
destScale.add_imm(1);
|
||||
//(RR) += (dr * (sr + 1)) >> 8;
|
||||
//(GG) += (dg * (sg + 1)) >> 8;
|
||||
//(BB) += (db * (sb + 1)) >> 8;
|
||||
@ -2937,14 +2936,14 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
|
||||
|
||||
case 3: /* ADST_ALPHA */
|
||||
ta = da + 1;
|
||||
rgba_comp_to_rgbaint(&destScale, destAlphaScale, ta, ta, ta);
|
||||
destScale.set_rgba(destAlphaScale, ta, ta, ta);
|
||||
//(RR) += (dr * (da + 1)) >> 8;
|
||||
//(GG) += (dg * (da + 1)) >> 8;
|
||||
//(BB) += (db * (da + 1)) >> 8;
|
||||
break;
|
||||
|
||||
case 4: /* AONE */
|
||||
rgba_comp_to_rgbaint(&destScale, destAlphaScale, 256, 256, 256);
|
||||
destScale.set_rgba(destAlphaScale, 256, 256, 256);
|
||||
//(RR) += dr;
|
||||
//(GG) += dg;
|
||||
//(BB) += db;
|
||||
@ -2952,14 +2951,14 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
|
||||
|
||||
case 5: /* AOMSRC_ALPHA */
|
||||
ta = (0x100 - sa);
|
||||
rgba_comp_to_rgbaint(&destScale, destAlphaScale, ta, ta, ta);
|
||||
destScale.set_rgba(destAlphaScale, ta, ta, ta);
|
||||
//(RR) += (dr * (0x100 - sa)) >> 8;
|
||||
//(GG) += (dg * (0x100 - sa)) >> 8;
|
||||
//(BB) += (db * (0x100 - sa)) >> 8;
|
||||
break;
|
||||
|
||||
case 6: /* AOM_COLOR */
|
||||
rgba_comp_to_rgbaint(&destScale, destAlphaScale, (0x100 - color.rgb.r), (0x100 - color.rgb.g), (0x100 - color.rgb.b));
|
||||
destScale.set_rgba(destAlphaScale, (0x100 - color.rgb.r), (0x100 - color.rgb.g), (0x100 - color.rgb.b));
|
||||
//(RR) += (dr * (0x100 - sr)) >> 8;
|
||||
//(GG) += (dg * (0x100 - sg)) >> 8;
|
||||
//(BB) += (db * (0x100 - sb)) >> 8;
|
||||
@ -2967,28 +2966,26 @@ INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *d
|
||||
|
||||
case 7: /* AOMDST_ALPHA */
|
||||
ta = (0x100 - da);
|
||||
rgba_comp_to_rgbaint(&destScale, destAlphaScale, ta, ta, ta);
|
||||
destScale.set_rgba(destAlphaScale, ta, ta, ta);
|
||||
//(RR) += (dr * (0x100 - da)) >> 8;
|
||||
//(GG) += (dg * (0x100 - da)) >> 8;
|
||||
//(BB) += (db * (0x100 - da)) >> 8;
|
||||
break;
|
||||
|
||||
case 15: /* A_COLORBEFOREFOG */
|
||||
rgba_to_rgbaint(&destScale, (rgb_t) (((destAlphaScale-1)<<24) | (preFog.u & 0x00ffffff)));
|
||||
rgbaint_add_imm(&destScale, 1);
|
||||
destScale.set_rgb((rgb_t) (((destAlphaScale-1)<<24) | (preFog.u & 0x00ffffff)));
|
||||
destScale.add_imm(1);
|
||||
//(RR) += (dr * (prefogr + 1)) >> 8;
|
||||
//(GG) += (dg * (prefogg + 1)) >> 8;
|
||||
//(BB) += (db * (prefogb + 1)) >> 8;
|
||||
break;
|
||||
}
|
||||
// Main blend
|
||||
rgbaint srcColor;
|
||||
rgbaint destColor;
|
||||
rgbaint_t srcColor((rgb_t) color.u);
|
||||
rgbaint_t destColor(da, dr, dg, db);
|
||||
|
||||
rgba_to_rgbaint(&srcColor, (rgb_t) color.u);
|
||||
rgba_comp_to_rgbaint(&destColor, da, dr, dg, db);
|
||||
rgbaint_scale_channel_add_and_clamp(&srcColor, &srcScale, &destColor, &destScale);
|
||||
color.u = rgbaint_to_rgba(&srcColor);
|
||||
srcColor.scale_add_and_clamp(srcScale, destColor, destScale);
|
||||
color.u = srcColor.to_rgba();
|
||||
/* clamp */
|
||||
//CLAMP((RR), 0x00, 0xff);
|
||||
//CLAMP((GG), 0x00, 0xff);
|
||||
@ -3120,20 +3117,18 @@ INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, I
|
||||
if (FOGMODE_ENABLE_FOG(fogModeReg))
|
||||
{
|
||||
UINT32 color_alpha = color.u & 0xff000000;
|
||||
rgbaint tmpA, tmpB;
|
||||
|
||||
//INT32 fr, fg, fb;
|
||||
rgbaint_t tmpA;
|
||||
|
||||
/* constant fog bypasses everything else */
|
||||
rgb_union fogColorLocal = v->reg[fogColor];
|
||||
rgba_to_rgbaint(&tmpB, (rgb_t) color.u);
|
||||
rgbaint_t tmpB((rgb_t) color.u);
|
||||
if (FOGMODE_FOG_CONSTANT(fogModeReg))
|
||||
{
|
||||
rgba_to_rgbaint(&tmpA, (rgb_t) fogColorLocal.u);
|
||||
tmpA.set_rgb((rgb_t) fogColorLocal.u);
|
||||
/* if fog_mult is 0, we add this to the original color */
|
||||
if (FOGMODE_FOG_MULT(fogModeReg) == 0)
|
||||
{
|
||||
rgbaint_add(&tmpA, &tmpB);
|
||||
tmpA.add(tmpB);
|
||||
//color += fog;
|
||||
}
|
||||
|
||||
@ -3142,7 +3137,7 @@ INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, I
|
||||
//{
|
||||
//color = fog;
|
||||
//}
|
||||
color.u = rgbaint_to_rgba_clamp(&tmpA);
|
||||
color.u = tmpA.to_rgba_clamp();
|
||||
}
|
||||
/* non-constant fog comes from several sources */
|
||||
else
|
||||
@ -3154,12 +3149,12 @@ INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, I
|
||||
fogColorLocal.u = 0;
|
||||
//fr = fg = fb = 0;
|
||||
|
||||
rgba_to_rgbaint(&tmpA, (rgb_t) fogColorLocal.u);
|
||||
tmpA.set_rgb((rgb_t) fogColorLocal.u);
|
||||
|
||||
/* if fog_mult is zero, we subtract the incoming color */
|
||||
if (!FOGMODE_FOG_MULT(fogModeReg))
|
||||
{
|
||||
rgbaint_sub(&tmpA, &tmpB);
|
||||
tmpA.sub(tmpB);
|
||||
//fog.rgb -= color.rgb;
|
||||
//fr -= (RR);
|
||||
//fg -= (GG);
|
||||
@ -3216,7 +3211,7 @@ INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, I
|
||||
/* if fog_mult is 0, we add this to the original color */
|
||||
if (FOGMODE_FOG_MULT(fogModeReg) == 0)
|
||||
{
|
||||
rgbaint_scale_immediate_add_and_clamp(&tmpA, (INT16) fogblend, &tmpB);
|
||||
tmpA.scale_imm_add_and_clamp((INT16) fogblend, tmpB);
|
||||
//color += fog;
|
||||
//(RR) += fr;
|
||||
//(GG) += fg;
|
||||
@ -3226,13 +3221,13 @@ INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, I
|
||||
/* otherwise this just becomes the new color */
|
||||
else
|
||||
{
|
||||
rgbaint_scale_immediate_and_clamp(&tmpA, fogblend);
|
||||
tmpA.scale_imm_and_clamp(fogblend);
|
||||
//color = fog;
|
||||
//(RR) = fr;
|
||||
//(GG) = fg;
|
||||
//(BB) = fb;
|
||||
}
|
||||
color.u = rgbaint_to_rgba(&tmpA);
|
||||
color.u = tmpA.to_rgba();
|
||||
}
|
||||
|
||||
|
||||
@ -3422,7 +3417,7 @@ do
|
||||
} \
|
||||
\
|
||||
/* weigh in each texel */ \
|
||||
c_local.u = rgba_bilinear_filter(texel0, texel1, texel2, texel3, sfrac, tfrac);\
|
||||
c_local.u = rgbaint_t::bilinear_filter(texel0, texel1, texel2, texel3, sfrac, tfrac); \
|
||||
} \
|
||||
\
|
||||
/* select zero/other for RGB */ \
|
||||
@ -4289,7 +4284,7 @@ INLINE bool combineColor(voodoo_state *VV, stats_block *STATS, UINT32 FBZCOLORPA
|
||||
UINT8 a_local = c_local.rgb.a;
|
||||
UINT8 tmp;
|
||||
rgb_union add_val = c_local;
|
||||
rgbaint tmpA, tmpB, tmpC;
|
||||
rgbaint_t tmpA, tmpB, tmpC;
|
||||
|
||||
|
||||
/* select zero or c_other */
|
||||
@ -4301,7 +4296,7 @@ INLINE bool combineColor(voodoo_state *VV, stats_block *STATS, UINT32 FBZCOLORPA
|
||||
if (FBZCP_CCA_ZERO_OTHER(FBZCOLORPATH))
|
||||
c_other.u &= 0x00ffffff;
|
||||
|
||||
rgba_to_rgbaint(&tmpA, (rgb_t) c_other.u);
|
||||
tmpA.set_rgb((rgb_t) c_other.u);
|
||||
|
||||
/* subtract a/c_local */
|
||||
if (FBZCP_CC_SUB_CLOCAL(FBZCOLORPATH) || (FBZCP_CCA_SUB_CLOCAL(FBZCOLORPATH)))
|
||||
@ -4314,8 +4309,8 @@ INLINE bool combineColor(voodoo_state *VV, stats_block *STATS, UINT32 FBZCOLORPA
|
||||
if (!FBZCP_CCA_SUB_CLOCAL(FBZCOLORPATH))
|
||||
sub_val.u &= 0x00ffffff;
|
||||
|
||||
rgba_to_rgbaint(&tmpB, (rgb_t) sub_val.u);
|
||||
rgbaint_sub(&tmpA, &tmpB);
|
||||
tmpB.set_rgb((rgb_t) sub_val.u);
|
||||
tmpA.sub(tmpB);
|
||||
}
|
||||
|
||||
/* blend RGB */
|
||||
@ -4409,11 +4404,11 @@ INLINE bool combineColor(voodoo_state *VV, stats_block *STATS, UINT32 FBZCOLORPA
|
||||
//CLAMP(color.rgb.r, 0x00, 0xff);
|
||||
//CLAMP(color.rgb.g, 0x00, 0xff);
|
||||
//CLAMP(color.rgb.b, 0x00, 0xff);
|
||||
rgba_to_rgbaint(&tmpB, (rgb_t) c_local.u);
|
||||
rgbaint_add_imm(&tmpB, 1);
|
||||
rgba_to_rgbaint(&tmpC, (rgb_t) add_val.u);
|
||||
rgbaint_scale_channel_add_and_clamp(&tmpA, &tmpB, &tmpC);
|
||||
color.u = rgbaint_to_rgba(&tmpA);
|
||||
tmpB.set_rgb((rgb_t) c_local.u);
|
||||
tmpB.add_imm(1);
|
||||
tmpC.set_rgb((rgb_t) add_val.u);
|
||||
tmpA.scale_add_and_clamp(tmpB, tmpC);
|
||||
color.u = tmpA.to_rgba();
|
||||
|
||||
/* invert */
|
||||
if (FBZCP_CCA_INVERT_OUTPUT(FBZCOLORPATH))
|
||||
@ -4628,16 +4623,14 @@ static void raster_##name(void *destbase, INT32 y, const poly_extent *extent, co
|
||||
INLINE UINT32 genTexture(tmu_state *TT, INT32 x, const UINT8 *dither4, const UINT32 TEXMODE, rgb_t *LOOKUP, INT32 LODBASE, INT64 ITERS, INT64 ITERT, INT64 ITERW, INT32 &lod)
|
||||
{
|
||||
UINT32 result;
|
||||
INT32 oow, s, t, ilod;
|
||||
INT32 smax, tmax;
|
||||
UINT32 texbase;
|
||||
INT32 s, t, ilod;
|
||||
|
||||
/* determine the S/T/LOD values for this texture */
|
||||
lod = (LODBASE);
|
||||
if (TEXMODE_ENABLE_PERSPECTIVE(TEXMODE))
|
||||
{
|
||||
INT32 wLog;
|
||||
oow = fast_reciplog((ITERW), &wLog);
|
||||
const INT32 oow = fast_reciplog((ITERW), &wLog);
|
||||
lod += wLog;
|
||||
s = ((INT64)oow * (ITERS)) >> 29;
|
||||
t = ((INT64)oow * (ITERT)) >> 29;
|
||||
@ -4669,11 +4662,11 @@ INLINE UINT32 genTexture(tmu_state *TT, INT32 x, const UINT8 *dither4, const UIN
|
||||
ilod++;
|
||||
|
||||
/* fetch the texture base */
|
||||
texbase = (TT)->lodoffset[ilod];
|
||||
UINT32 texbase = (TT)->lodoffset[ilod];
|
||||
|
||||
/* compute the maximum s and t values at this LOD */
|
||||
smax = (TT)->wmask >> ilod;
|
||||
tmax = (TT)->hmask >> ilod;
|
||||
INT32 smax = (TT)->wmask >> ilod;
|
||||
INT32 tmax = (TT)->hmask >> ilod;
|
||||
|
||||
/* determine whether we are point-sampled or bilinear */
|
||||
if ((lod == (TT)->lodmin && !TEXMODE_MAGNIFICATION_FILTER(TEXMODE)) ||
|
||||
@ -4808,7 +4801,8 @@ INLINE UINT32 genTexture(tmu_state *TT, INT32 x, const UINT8 *dither4, const UIN
|
||||
}
|
||||
|
||||
/* weigh in each texel */
|
||||
result = rgba_bilinear_filter(texel0, texel1, texel2, texel3, sfrac, tfrac);
|
||||
|
||||
result = rgbaint_t::bilinear_filter(texel0, texel1, texel2, texel3, sfrac, tfrac);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -4822,7 +4816,7 @@ INLINE UINT32 combineTexture(tmu_state *TT, const UINT32 TEXMODE, rgb_union c_lo
|
||||
UINT8 a_local = c_local.rgb.a;
|
||||
rgb_union add_val = c_local;
|
||||
UINT8 tmp;
|
||||
rgbaint tmpA, tmpB, tmpC;
|
||||
rgbaint_t tmpA, tmpB, tmpC;
|
||||
|
||||
/* select zero/other for RGB */
|
||||
if (TEXMODE_TC_ZERO_OTHER(TEXMODE))
|
||||
@ -4832,7 +4826,7 @@ INLINE UINT32 combineTexture(tmu_state *TT, const UINT32 TEXMODE, rgb_union c_lo
|
||||
if (TEXMODE_TCA_ZERO_OTHER(TEXMODE))
|
||||
c_other.u &= 0x00ffffff;
|
||||
|
||||
rgba_to_rgbaint(&tmpA, (rgb_t) c_other.u);
|
||||
tmpA.set_rgb((rgb_t) c_other.u);
|
||||
|
||||
if (TEXMODE_TC_SUB_CLOCAL(TEXMODE) || TEXMODE_TCA_SUB_CLOCAL(TEXMODE))
|
||||
{
|
||||
@ -4845,8 +4839,8 @@ INLINE UINT32 combineTexture(tmu_state *TT, const UINT32 TEXMODE, rgb_union c_lo
|
||||
if (!TEXMODE_TCA_SUB_CLOCAL(TEXMODE))
|
||||
sub_val.u &= 0x00ffffff;
|
||||
|
||||
rgba_to_rgbaint(&tmpB, (rgb_t) sub_val.u);
|
||||
rgbaint_sub(&tmpA, &tmpB);
|
||||
tmpB.set_rgb((rgb_t) sub_val.u);
|
||||
tmpA.sub(tmpB);
|
||||
}
|
||||
|
||||
/* blend RGB */
|
||||
@ -4966,11 +4960,11 @@ 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.b = (tb < 0) ? 0 : (tb > 0xff) ? 0xff : tb;
|
||||
//result.rgb.a = (ta < 0) ? 0 : (ta > 0xff) ? 0xff : ta;
|
||||
rgba_to_rgbaint(&tmpB, (rgb_t) c_local.u);
|
||||
rgbaint_add_imm(&tmpB, 1);
|
||||
rgba_to_rgbaint(&tmpC, (rgb_t) add_val.u);
|
||||
rgbaint_scale_channel_add_and_clamp(&tmpA, &tmpB, &tmpC);
|
||||
result = rgbaint_to_rgba(&tmpA);
|
||||
tmpB.set_rgb((rgb_t) c_local.u);
|
||||
tmpB.add_imm(1);
|
||||
tmpC.set_rgb((rgb_t) add_val.u);
|
||||
tmpA.scale_add_and_clamp(tmpB, tmpC);
|
||||
result = tmpA.to_rgba();
|
||||
|
||||
/* invert */
|
||||
if (TEXMODE_TC_INVERT_OUTPUT(TEXMODE))
|
||||
|
@ -323,7 +323,7 @@
|
||||
#include "machine/timekpr.h"
|
||||
#include "video/k001604.h"
|
||||
#include "video/poly.h"
|
||||
#include "video/rgbgen.h"
|
||||
#include "video/rgbutil.h"
|
||||
#include "sound/rf5c400.h"
|
||||
#include "sound/dmadac.h"
|
||||
|
||||
@ -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 texel11 = texture_fetch(&m_texture_ram[tex_address], iu+1, iv+1, texture_width, tex_format);
|
||||
|
||||
rgb_t texel = rgba_bilinear_filter(texel00, texel01, texel10, texel11, (int)(lerp_u * 255), (int)(lerp_v * 255));
|
||||
rgb_t texel = rgbint_t::bilinear_filter(texel00, texel01, texel10, texel11, (int)(lerp_u * 255), (int)(lerp_v * 255));
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -93,9 +93,9 @@ struct namcos22_scenenode
|
||||
struct namcos22_object_data
|
||||
{
|
||||
/* poly / sprites */
|
||||
rgbint fogcolor;
|
||||
rgbint fadecolor;
|
||||
rgbint polycolor;
|
||||
rgbint_t fogcolor;
|
||||
rgbint_t fadecolor;
|
||||
rgbint_t polycolor;
|
||||
const pen_t *pens;
|
||||
bitmap_rgb32 *destbase;
|
||||
bitmap_ind8 *primap;
|
||||
|
@ -224,11 +224,11 @@ void gaelco3d_renderer::render_noz_noperspective(INT32 scanline, const extent_t
|
||||
int pixeloffs = (tex + (v >> 8) * 4096 + (u >> 8)) & endmask;
|
||||
if (pixeloffs >= m_texmask_size || !m_texmask[pixeloffs])
|
||||
{
|
||||
rgb_t rgb00 = palsource[m_texture[pixeloffs]];
|
||||
rgb_t rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]];
|
||||
rgb_t rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]];
|
||||
rgb_t rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]];
|
||||
UINT32 filtered = rgb_bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v);
|
||||
UINT32 rgb00 = palsource[m_texture[pixeloffs]];
|
||||
UINT32 rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]];
|
||||
UINT32 rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]];
|
||||
UINT32 rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]];
|
||||
const UINT32 filtered = rgbint_t::bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v);
|
||||
dest[x] = (filtered & 0x1f) | ((filtered & 0x1ff800) >> 6);
|
||||
zbuf[x] = zbufval;
|
||||
}
|
||||
@ -271,11 +271,11 @@ void gaelco3d_renderer::render_normal(INT32 scanline, const extent_t &extent, co
|
||||
int pixeloffs = (tex + (v >> 8) * 4096 + (u >> 8)) & endmask;
|
||||
if (pixeloffs >= m_texmask_size || !m_texmask[pixeloffs])
|
||||
{
|
||||
rgb_t rgb00 = palsource[m_texture[pixeloffs]];
|
||||
rgb_t rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]];
|
||||
rgb_t rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]];
|
||||
rgb_t rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]];
|
||||
UINT32 filtered = rgb_bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v);
|
||||
UINT32 rgb00 = palsource[m_texture[pixeloffs]];
|
||||
UINT32 rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]];
|
||||
UINT32 rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]];
|
||||
UINT32 rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]];
|
||||
const UINT32 filtered = rgbint_t::bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v);
|
||||
dest[x] = (filtered & 0x1f) | ((filtered & 0x1ff800) >> 6);
|
||||
zbuf[x] = (zbufval < 0) ? -zbufval : zbufval;
|
||||
}
|
||||
@ -321,11 +321,11 @@ void gaelco3d_renderer::render_alphablend(INT32 scanline, const extent_t &extent
|
||||
int pixeloffs = (tex + (v >> 8) * 4096 + (u >> 8)) & endmask;
|
||||
if (pixeloffs >= m_texmask_size || !m_texmask[pixeloffs])
|
||||
{
|
||||
rgb_t rgb00 = palsource[m_texture[pixeloffs]];
|
||||
rgb_t rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]];
|
||||
rgb_t rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]];
|
||||
rgb_t rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]];
|
||||
UINT32 filtered = rgb_bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v) >> 1;
|
||||
UINT32 rgb00 = palsource[m_texture[pixeloffs]];
|
||||
UINT32 rgb01 = palsource[m_texture[(pixeloffs + 1) & endmask]];
|
||||
UINT32 rgb10 = palsource[m_texture[(pixeloffs + 4096) & endmask]];
|
||||
UINT32 rgb11 = palsource[m_texture[(pixeloffs + 4097) & endmask]];
|
||||
const UINT32 filtered = rgbint_t::bilinear_filter(rgb00, rgb01, rgb10, rgb11, u, v) >> 1;
|
||||
dest[x] = ((filtered & 0x0f) | ((filtered & 0x0f7800) >> 6)) + ((dest[x] >> 1) & 0x3def);
|
||||
zbuf[x] = (zbufval < 0) ? -zbufval : zbufval;
|
||||
}
|
||||
|
@ -1305,12 +1305,11 @@ static void render_poly_texture(void *dest, INT32 scanline, const poly_extent *e
|
||||
rgb_t color1 = WAVERAM_READ16(palbase, texel1);
|
||||
rgb_t color2 = WAVERAM_READ16(palbase, texel2);
|
||||
rgb_t color3 = WAVERAM_READ16(palbase, texel3);
|
||||
rgb_t filtered;
|
||||
color0 = ((color0 & 0x7fe0) << 6) | (color0 & 0x1f);
|
||||
color1 = ((color1 & 0x7fe0) << 6) | (color1 & 0x1f);
|
||||
color2 = ((color2 & 0x7fe0) << 6) | (color2 & 0x1f);
|
||||
color3 = ((color3 & 0x7fe0) << 6) | (color3 & 0x1f);
|
||||
filtered = rgb_bilinear_filter(color0, color1, color2, color3, curu, curv);
|
||||
rgb_t filtered = rgbint_t::bilinear_filter(color0, color1, color2, color3, curu, curv);
|
||||
WAVERAM_WRITEPIX(zeus_renderbase, scanline, x, ((filtered >> 6) & 0x7fe0) | (filtered & 0x1f));
|
||||
*depthptr = depth;
|
||||
}
|
||||
|
@ -1289,16 +1289,15 @@ static void render_poly_8bit(void *dest, INT32 scanline, const poly_extent *exte
|
||||
UINT8 texel3 = get_texel_8bit(texbase, v1, u1, texwidth);
|
||||
if (texel0 != transcolor)
|
||||
{
|
||||
rgb_t color0 = WAVERAM_READ16(palbase, texel0);
|
||||
rgb_t color1 = WAVERAM_READ16(palbase, texel1);
|
||||
rgb_t color2 = WAVERAM_READ16(palbase, texel2);
|
||||
rgb_t color3 = WAVERAM_READ16(palbase, texel3);
|
||||
rgb_t filtered;
|
||||
UINT32 color0 = WAVERAM_READ16(palbase, texel0);
|
||||
UINT32 color1 = WAVERAM_READ16(palbase, texel1);
|
||||
UINT32 color2 = WAVERAM_READ16(palbase, texel2);
|
||||
UINT32 color3 = WAVERAM_READ16(palbase, texel3);
|
||||
color0 = ((color0 & 0x7c00) << 9) | ((color0 & 0x3e0) << 6) | ((color0 & 0x1f) << 3);
|
||||
color1 = ((color1 & 0x7c00) << 9) | ((color1 & 0x3e0) << 6) | ((color1 & 0x1f) << 3);
|
||||
color2 = ((color2 & 0x7c00) << 9) | ((color2 & 0x3e0) << 6) | ((color2 & 0x1f) << 3);
|
||||
color3 = ((color3 & 0x7c00) << 9) | ((color3 & 0x3e0) << 6) | ((color3 & 0x1f) << 3);
|
||||
filtered = rgb_bilinear_filter(color0, color1, color2, color3, curu, curv);
|
||||
rgb_t filtered = rgbint_t::bilinear_filter(color0, color1, color2, color3, curu, curv);
|
||||
WAVERAM_WRITEPIX(zeus_renderbase, scanline, x, filtered);
|
||||
*depthptr = depth;
|
||||
}
|
||||
|
@ -2352,7 +2352,7 @@ do {
|
||||
UINT32 pix01 = texture->data[(v1 << width) + u2]; \
|
||||
UINT32 pix10 = texture->data[(v2 << width) + u1]; \
|
||||
UINT32 pix11 = texture->data[(v2 << width) + u2]; \
|
||||
texel = rgba_bilinear_filter(pix00, pix01, pix10, pix11, u, v); \
|
||||
texel = rgbaint_t::bilinear_filter(pix00, pix01, pix10, pix11, u, v); \
|
||||
} while(0);
|
||||
|
||||
#if ENABLE_BILINEAR
|
||||
|
@ -83,9 +83,9 @@ void namcos22_renderer::renderscanline_uvi_full(INT32 scanline, const extent_t &
|
||||
int fogfactor = 0xff - extra.fogfactor;
|
||||
int fadefactor = 0xff - extra.fadefactor;
|
||||
int alphafactor = 0xff - m_state.m_poly_translucency;
|
||||
rgbint fogcolor = extra.fogcolor;
|
||||
rgbint fadecolor = extra.fadecolor;
|
||||
rgbint polycolor = extra.polycolor;
|
||||
rgbint_t fogcolor = extra.fogcolor;
|
||||
rgbint_t fadecolor = extra.fadecolor;
|
||||
rgbint_t polycolor = extra.polycolor;
|
||||
int polyfade_enabled = extra.pfade_enabled;
|
||||
int penmask = 0xff;
|
||||
int penshift = 0;
|
||||
@ -118,18 +118,17 @@ void namcos22_renderer::renderscanline_uvi_full(INT32 scanline, const extent_t &
|
||||
for (int x = extent.startx; x < extent.stopx; x++)
|
||||
{
|
||||
float ooz = 1.0f / z;
|
||||
int tx = (int)(u * ooz);
|
||||
int ty = (int)(v * ooz) + bn;
|
||||
int to = ((ty & 0xfff0) << 4) | ((tx & 0xff0) >> 4);
|
||||
int pen = ttdata[(ttmap[to] << 8) | tt_ayx_to_pixel[ttattr[to] << 8 | (ty << 4 & 0xf0) | (tx & 0xf)]];
|
||||
INT32 tx = (int)(u * ooz);
|
||||
INT32 ty = (int)(v * ooz) + bn;
|
||||
INT32 to = ((ty & 0xfff0) << 4) | ((tx & 0xff0) >> 4);
|
||||
INT32 pen = ttdata[(ttmap[to] << 8) | tt_ayx_to_pixel[ttattr[to] << 8 | (ty << 4 & 0xf0) | (tx & 0xf)]];
|
||||
// pen = 0x55; // debug: disable textures
|
||||
|
||||
rgbint rgb;
|
||||
rgb_to_rgbint(&rgb, pens[pen >> penshift & penmask]);
|
||||
rgbint_t rgb(pens[pen >> penshift & penmask]);
|
||||
|
||||
// apply shading before fog
|
||||
int shade = i*ooz;
|
||||
rgbint_scale_immediate_and_clamp(&rgb, shade << 2);
|
||||
INT32 shade = i*ooz;
|
||||
rgb.scale_imm_and_clamp(shade << 2);
|
||||
|
||||
// per-z distance fogging
|
||||
if (zfog_enabled)
|
||||
@ -142,26 +141,30 @@ void namcos22_renderer::renderscanline_uvi_full(INT32 scanline, const extent_t &
|
||||
if (fogfactor > 0)
|
||||
{
|
||||
if (fogfactor > 0xff) fogfactor = 0xff;
|
||||
rgbint_blend(&rgb, &fogcolor, 0xff - fogfactor);
|
||||
rgb.blend(fogcolor, 0xff - fogfactor);
|
||||
}
|
||||
}
|
||||
else if (fogfactor != 0xff) // direct
|
||||
rgbint_blend(&rgb, &fogcolor, fogfactor);
|
||||
{
|
||||
rgb.blend(fogcolor, fogfactor);
|
||||
}
|
||||
|
||||
if (polyfade_enabled)
|
||||
rgbint_scale_channel_and_clamp(&rgb, &polycolor);
|
||||
{
|
||||
rgb.scale_and_clamp(polycolor);
|
||||
}
|
||||
|
||||
if (fadefactor != 0xff)
|
||||
rgbint_blend(&rgb, &fadecolor, fadefactor);
|
||||
{
|
||||
rgb.blend(fadecolor, fadefactor);
|
||||
}
|
||||
|
||||
if (alphafactor != 0xff)
|
||||
{
|
||||
rgbint mix;
|
||||
rgb_to_rgbint(&mix, dest[x]);
|
||||
rgbint_blend(&rgb, &mix, alphafactor);
|
||||
rgb.blend(rgbint_t(dest[x]), alphafactor);
|
||||
}
|
||||
|
||||
dest[x] = rgbint_to_rgb(&rgb);
|
||||
dest[x] = rgb.to_rgb();
|
||||
primap[x] |= prioverchar;
|
||||
|
||||
u += du;
|
||||
@ -181,8 +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)]];
|
||||
// pen = 0x55; // debug: disable textures
|
||||
|
||||
rgbint rgb;
|
||||
rgb_to_rgbint(&rgb, pens[pen >> penshift & penmask]);
|
||||
rgbint_t rgb(pens[pen >> penshift & penmask]);
|
||||
|
||||
// per-z distance fogging
|
||||
if (zfog_enabled)
|
||||
@ -193,19 +195,25 @@ void namcos22_renderer::renderscanline_uvi_full(INT32 scanline, const extent_t &
|
||||
else cz = (cz < 0) ? 0 : 0x1fff;
|
||||
fogfactor = czram[NATIVE_ENDIAN_VALUE_LE_BE(3, 0) ^ cz];
|
||||
if (fogfactor != 0)
|
||||
rgbint_blend(&rgb, &fogcolor, 0xff - fogfactor);
|
||||
{
|
||||
rgb.blend(fogcolor, 0xff - fogfactor);
|
||||
}
|
||||
}
|
||||
else if (fogfactor != 0xff) // direct
|
||||
rgbint_blend(&rgb, &fogcolor, fogfactor);
|
||||
{
|
||||
rgb.blend(fogcolor, fogfactor);
|
||||
}
|
||||
|
||||
// apply shading after fog
|
||||
int shade = i*ooz;
|
||||
rgbint_scale_immediate_and_clamp(&rgb, shade << 2);
|
||||
rgb.scale_imm_and_clamp(shade << 2);
|
||||
|
||||
if (polyfade_enabled)
|
||||
rgbint_scale_channel_and_clamp(&rgb, &polycolor);
|
||||
{
|
||||
rgb.scale_and_clamp(polycolor);
|
||||
}
|
||||
|
||||
dest[x] = rgbint_to_rgb(&rgb);
|
||||
dest[x] = rgb.to_rgb();
|
||||
primap[x] |= prioverchar;
|
||||
|
||||
u += du;
|
||||
@ -227,8 +235,8 @@ void namcos22_renderer::renderscanline_sprite(INT32 scanline, const extent_t &ex
|
||||
int alphafactor = extra.alpha;
|
||||
int fogfactor = 0xff - extra.fogfactor;
|
||||
int fadefactor = 0xff - extra.fadefactor;
|
||||
rgbint fogcolor = extra.fogcolor;
|
||||
rgbint fadecolor = extra.fadecolor;
|
||||
rgbint_t fogcolor(extra.fogcolor);
|
||||
rgbint_t fadecolor(extra.fadecolor);
|
||||
UINT8 *source = (UINT8 *)extra.source + y_index * extra.line_modulo;
|
||||
UINT32 *dest = &extra.destbase->pix32(scanline);
|
||||
UINT8 *primap = &extra.primap->pix8(scanline);
|
||||
@ -238,23 +246,24 @@ void namcos22_renderer::renderscanline_sprite(INT32 scanline, const extent_t &ex
|
||||
int pen = source[(int)x_index];
|
||||
if (pen != 0xff)
|
||||
{
|
||||
rgbint rgb;
|
||||
rgb_to_rgbint(&rgb, pal[pen]);
|
||||
rgbint_t rgb(pal[pen]);
|
||||
|
||||
if (fogfactor != 0xff)
|
||||
rgbint_blend(&rgb, &fogcolor, fogfactor);
|
||||
{
|
||||
rgb.blend(fogcolor, fogfactor);
|
||||
}
|
||||
|
||||
if (fadefactor != 0xff)
|
||||
rgbint_blend(&rgb, &fadecolor, fadefactor);
|
||||
{
|
||||
rgb.blend(fadecolor, fadefactor);
|
||||
}
|
||||
|
||||
if (alphafactor != 0xff)
|
||||
{
|
||||
rgbint mix;
|
||||
rgb_to_rgbint(&mix, dest[x]);
|
||||
rgbint_blend(&rgb, &mix, alphafactor);
|
||||
rgb.blend(rgbint_t(dest[x]), alphafactor);
|
||||
}
|
||||
|
||||
dest[x] = rgbint_to_rgb(&rgb);
|
||||
dest[x] = rgb.to_rgb();
|
||||
primap[x] |= prioverchar;
|
||||
}
|
||||
x_index += dx;
|
||||
@ -356,12 +365,12 @@ void namcos22_renderer::poly3d_drawquad(screen_device &screen, bitmap_rgb32 &bit
|
||||
if (m_state.m_mixer_flags & 1)
|
||||
{
|
||||
extra.fadefactor = m_state.m_screen_fade_factor;
|
||||
rgb_comp_to_rgbint(&extra.fadecolor, m_state.m_screen_fade_r, m_state.m_screen_fade_g, m_state.m_screen_fade_b);
|
||||
extra.fadecolor.set_rgb(m_state.m_screen_fade_r, m_state.m_screen_fade_g, m_state.m_screen_fade_b);
|
||||
}
|
||||
|
||||
// poly fade
|
||||
extra.pfade_enabled = m_state.m_poly_fade_enabled;
|
||||
rgb_comp_to_rgbint(&extra.polycolor, m_state.m_poly_fade_r, m_state.m_poly_fade_g, m_state.m_poly_fade_b);
|
||||
extra.polycolor.set_rgb(m_state.m_poly_fade_r, m_state.m_poly_fade_g, m_state.m_poly_fade_b);
|
||||
|
||||
/* poly fog (not completely accurate yet)
|
||||
|
||||
@ -432,7 +441,7 @@ void namcos22_renderer::poly3d_drawquad(screen_device &screen, bitmap_rgb32 &bit
|
||||
if (nthword(m_state.m_czattr, 4) & (4 << (cztype * 4)))
|
||||
{
|
||||
int delta = (INT16)nthword(m_state.m_czattr, cztype);
|
||||
rgb_comp_to_rgbint(&extra.fogcolor, m_state.m_fog_r, m_state.m_fog_g, m_state.m_fog_b);
|
||||
extra.fogcolor.set_rgb(m_state.m_fog_r, m_state.m_fog_g, m_state.m_fog_b);
|
||||
if (direct)
|
||||
{
|
||||
int cz = ((flags & 0x1fff00) + cz_adjust) >> 8;
|
||||
@ -462,7 +471,7 @@ void namcos22_renderer::poly3d_drawquad(screen_device &screen, bitmap_rgb32 &bit
|
||||
if (m_state.m_mixer_flags & 1)
|
||||
{
|
||||
extra.pfade_enabled = m_state.m_poly_fade_enabled;
|
||||
rgb_comp_to_rgbint(&extra.polycolor, m_state.m_poly_fade_r, m_state.m_poly_fade_g, m_state.m_poly_fade_b);
|
||||
extra.polycolor.set_rgb(m_state.m_poly_fade_r, m_state.m_poly_fade_g, m_state.m_poly_fade_b);
|
||||
}
|
||||
|
||||
// poly fog
|
||||
@ -470,7 +479,7 @@ void namcos22_renderer::poly3d_drawquad(screen_device &screen, bitmap_rgb32 &bit
|
||||
{
|
||||
int cztype = flags & 3;
|
||||
int czcolor = cztype & nthbyte(&m_state.m_fog_colormask, cztype);
|
||||
rgb_comp_to_rgbint(&extra.fogcolor, 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_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]);
|
||||
|
||||
if (direct)
|
||||
{
|
||||
@ -555,7 +564,7 @@ void namcos22_renderer::poly3d_drawsprite(
|
||||
if (m_state.m_mixer_flags & 2)
|
||||
{
|
||||
extra.fadefactor = m_state.m_screen_fade_factor;
|
||||
rgb_comp_to_rgbint(&extra.fadecolor, m_state.m_screen_fade_r, m_state.m_screen_fade_g, m_state.m_screen_fade_b);
|
||||
extra.fadecolor.set_rgb(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
|
||||
@ -563,7 +572,7 @@ void namcos22_renderer::poly3d_drawsprite(
|
||||
{
|
||||
// or does it fetch from poly-cz ram? that will break timecris though
|
||||
extra.fogfactor = cz_factor;
|
||||
rgb_comp_to_rgbint(&extra.fogcolor, m_state.m_fog_r, m_state.m_fog_g, m_state.m_fog_b);
|
||||
extra.fogcolor.set_rgb(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);
|
||||
@ -1883,8 +1892,7 @@ void namcos22_state::namcos22s_mix_text_layer(screen_device &screen, bitmap_rgb3
|
||||
// prepare fader
|
||||
bool fade_enabled = (m_mixer_flags & 2) && m_screen_fade_factor;
|
||||
int fade_factor = 0xff - m_screen_fade_factor;
|
||||
rgbint fade_color;
|
||||
rgb_comp_to_rgbint(&fade_color, m_screen_fade_r, m_screen_fade_g, m_screen_fade_b);
|
||||
rgbint_t fade_color(m_screen_fade_r, m_screen_fade_g, m_screen_fade_b);
|
||||
|
||||
// mix textlayer with poly/sprites
|
||||
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
|
||||
@ -1897,8 +1905,7 @@ void namcos22_state::namcos22s_mix_text_layer(screen_device &screen, bitmap_rgb3
|
||||
// skip if transparent or under poly/sprite
|
||||
if (pri[x] == prival)
|
||||
{
|
||||
rgbint rgb;
|
||||
rgb_to_rgbint(&rgb, pens[src[x]]);
|
||||
rgbint_t rgb(pens[src[x]]);
|
||||
|
||||
// apply alpha
|
||||
if (alpha_factor)
|
||||
@ -1906,9 +1913,7 @@ void namcos22_state::namcos22s_mix_text_layer(screen_device &screen, bitmap_rgb3
|
||||
UINT8 pen = src[x] & 0xff;
|
||||
if ((pen & 0xf) == alpha_mask || pen == alpha_check12 || pen == alpha_check13)
|
||||
{
|
||||
rgbint mix;
|
||||
rgb_to_rgbint(&mix, dest[x]);
|
||||
rgbint_blend(&rgb, &mix, 0xff - alpha_factor);
|
||||
rgb.blend(rgbint_t(dest[x]), 0xff - alpha_factor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1916,29 +1921,27 @@ void namcos22_state::namcos22s_mix_text_layer(screen_device &screen, bitmap_rgb3
|
||||
if (spot_enabled)
|
||||
{
|
||||
UINT8 pen = src[x] & 0xff;
|
||||
rgbint mix;
|
||||
rgb_to_rgbint(&mix, dest[x]);
|
||||
rgbint_t mix(dest[x]);
|
||||
if (spot_flags & 8)
|
||||
{
|
||||
// mix with per-channel brightness
|
||||
rgbint shade;
|
||||
rgb_comp_to_rgbint(&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
|
||||
);
|
||||
rgbint_scale_channel_and_clamp(&mix, &shade);
|
||||
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);
|
||||
mix.scale_and_clamp(shade);
|
||||
}
|
||||
|
||||
int spot_factor = 0xff - (m_spotram[pen << 2] & 0xff);
|
||||
if (spot_factor < spot_limit)
|
||||
rgbint_blend(&rgb, &mix, spot_factor);
|
||||
{
|
||||
rgb.blend(mix, spot_factor);
|
||||
}
|
||||
}
|
||||
|
||||
if (fade_enabled)
|
||||
rgbint_blend(&rgb, &fade_color, fade_factor);
|
||||
{
|
||||
rgb.blend(fade_color, fade_factor);
|
||||
}
|
||||
|
||||
dest[x] = rgbint_to_rgb(&rgb);
|
||||
dest[x] = rgb.to_rgb();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1954,12 +1957,13 @@ void namcos22_state::namcos22_mix_text_layer(screen_device &screen, bitmap_rgb32
|
||||
// prepare fader and shadow factor
|
||||
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)
|
||||
rgbint fade_color, rgb_mix[3];
|
||||
|
||||
rgb_comp_to_rgbint(&fade_color, m_poly_fade_r, m_poly_fade_g, m_poly_fade_b);
|
||||
rgb_comp_to_rgbint(&rgb_mix[0], nthbyte(m_mixer, 0x08), nthbyte(m_mixer, 0x09), nthbyte(m_mixer, 0x0a)); // pen c
|
||||
rgb_comp_to_rgbint(&rgb_mix[1], nthbyte(m_mixer, 0x0b), nthbyte(m_mixer, 0x0c), nthbyte(m_mixer, 0x0d)); // pen d
|
||||
rgb_comp_to_rgbint(&rgb_mix[2], nthbyte(m_mixer, 0x0e), nthbyte(m_mixer, 0x0f), nthbyte(m_mixer, 0x10)); // pen e
|
||||
rgbint_t fade_color(m_poly_fade_r, m_poly_fade_g, m_poly_fade_b);
|
||||
rgbint_t rgb_mix[3] = {
|
||||
rgbint_t(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
|
||||
rgbint_t(nthbyte(m_mixer, 0x0e), nthbyte(m_mixer, 0x0f), nthbyte(m_mixer, 0x10)) // pen e
|
||||
};
|
||||
|
||||
// mix textlayer with poly/sprites
|
||||
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
|
||||
@ -1973,7 +1977,7 @@ void namcos22_state::namcos22_mix_text_layer(screen_device &screen, bitmap_rgb32
|
||||
if (pri[x] == 2)
|
||||
{
|
||||
// apply shadow
|
||||
rgbint rgb;
|
||||
rgbint_t rgb;
|
||||
switch (src[x] & 0xff)
|
||||
{
|
||||
case 0xfc:
|
||||
@ -1981,24 +1985,26 @@ void namcos22_state::namcos22_mix_text_layer(screen_device &screen, bitmap_rgb32
|
||||
case 0xfe:
|
||||
if (shadow_enabled)
|
||||
{
|
||||
rgb_to_rgbint(&rgb, dest[x]);
|
||||
rgbint_scale_channel_and_clamp(&rgb, &rgb_mix[(src[x] & 0xf) - 0xc]);
|
||||
rgb.set_rgb(dest[x]);
|
||||
rgb.scale_and_clamp(rgb_mix[(src[x] & 0xf) - 0xc]);
|
||||
break;
|
||||
}
|
||||
// (fall through)
|
||||
default:
|
||||
rgb_to_rgbint(&rgb, pens[src[x]]);
|
||||
rgb.set_rgb(pens[src[x]]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (fade_enabled)
|
||||
rgbint_scale_channel_and_clamp(&rgb, &fade_color);
|
||||
{
|
||||
rgb.scale_and_clamp(fade_color);
|
||||
}
|
||||
|
||||
// BTANB note: fading to white does not affect color channels set to 00,
|
||||
// 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
|
||||
|
||||
dest[x] = rgbint_to_rgb(&rgb);
|
||||
dest[x] = rgb.to_rgb();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2279,15 +2285,13 @@ UINT32 namcos22_state::screen_update_namcos22s(screen_device &screen, bitmap_rgb
|
||||
screen.priority().fill(0, cliprect);
|
||||
|
||||
// background color
|
||||
rgbint bg_color;
|
||||
rgb_comp_to_rgbint(&bg_color, nthbyte(m_mixer, 0x08), nthbyte(m_mixer, 0x09), nthbyte(m_mixer, 0x0a));
|
||||
rgbint_t bg_color(nthbyte(m_mixer, 0x08), nthbyte(m_mixer, 0x09), nthbyte(m_mixer, 0x0a));
|
||||
if (m_mixer_flags & 1 && m_screen_fade_factor)
|
||||
{
|
||||
rgbint fade_color;
|
||||
rgb_comp_to_rgbint(&fade_color, m_screen_fade_r, m_screen_fade_g, m_screen_fade_b);
|
||||
rgbint_blend(&bg_color, &fade_color, 0xff - m_screen_fade_factor);
|
||||
rgbint_t fade_color(m_screen_fade_r, m_screen_fade_g, m_screen_fade_b);
|
||||
bg_color.blend(fade_color, 0xff - m_screen_fade_factor);
|
||||
}
|
||||
bitmap.fill(rgbint_to_rgb(&bg_color), cliprect);
|
||||
bitmap.fill(bg_color.to_rgb(), cliprect);
|
||||
|
||||
// layers
|
||||
UINT8 layer = nthbyte(m_mixer, 0x1f);
|
||||
|
@ -119,9 +119,9 @@ inline INT32 powervr2_device::clamp(INT32 in, INT32 min, INT32 max)
|
||||
// Perform a standard bilinear filter across four pixels
|
||||
inline UINT32 powervr2_device::bilinear_filter(UINT32 c0, UINT32 c1, UINT32 c2, UINT32 c3, float u, float v)
|
||||
{
|
||||
UINT32 ui = (u * 256.0f);
|
||||
UINT32 vi = (v * 256.0f);
|
||||
return rgba_bilinear_filter(c0, c1, c3, c2, ui, vi);
|
||||
const UINT32 ui = (u * 256.0f);
|
||||
const UINT32 vi = (v * 256.0f);
|
||||
return rgbaint_t::bilinear_filter(c0, c1, c3, c2, ui, vi);
|
||||
}
|
||||
|
||||
// Multiply with alpha value in bits 31-24
|
||||
|
Loading…
Reference in New Issue
Block a user