diff --git a/src/emu/video/rgbsse.c b/src/emu/video/rgbsse.c index b58d76c8fcd..c7566a18f38 100644 --- a/src/emu/video/rgbsse.c +++ b/src/emu/video/rgbsse.c @@ -14,205 +14,6 @@ #include #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(INT32 r, INT32 g, INT32 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_epi32((argb >> 24) & 0xff, (argb >> 16) & 0xff, (argb >> 8) & 0xff, argb & 0xff); -} - -rgbaint_t::rgbaint_t(INT32 a, INT32 r, INT32 g, INT32 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(void* value) -{ - m_value = *(__m128i*)value; -} - -void rgbint_t::set(__m128i value) -{ - m_value = value; -} - -__m128i rgbint_t::get() -{ - return m_value; -} - -void rgbint_t::set_rgb(UINT32 rgb) -{ - m_value = _mm_set_epi32(0, rgb & 0xff, (rgb >> 8) & 0xff, (rgb >> 16) & 0xff); -} - -void rgbint_t::set_rgb(rgb_t& rgb) -{ - m_value = _mm_unpacklo_epi16(_mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128()), _mm_setzero_si128()); -} - -void rgbint_t::set_rgb(INT32 r, INT32 g, INT32 b) -{ - m_value = _mm_set_epi32(0, r, g, b); -} - -/*************************************************************************** - OPERATORS -***************************************************************************/ - -rgbint_t rgbint_t::operator=(const rgbint_t& other) -{ - m_value = other.m_value; - return *this; -} - -rgbint_t& rgbint_t::operator+=(const rgbint_t& other) -{ - m_value = _mm_add_epi32(m_value, other.m_value); - return *this; -} - -rgbint_t& rgbint_t::operator+=(const INT32 other) -{ - m_value = _mm_add_epi32(m_value, _mm_set1_epi32(other)); - return *this; -} - -rgbint_t& rgbint_t::operator-=(const rgbint_t& other) -{ - m_value = _mm_sub_epi32(m_value, other.m_value); - return *this; -} - -rgbint_t& rgbint_t::operator*=(const rgbint_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))); - return *this; -} - -rgbint_t& rgbint_t::operator*=(const INT32 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))); - return *this; -} - -rgbint_t& rgbint_t::operator>>=(const INT32 shift) -{ - m_value = _mm_srai_epi32(m_value, shift); - return *this; -} - -/*************************************************************************** - BASIC CONVERSIONS -***************************************************************************/ - -rgb_t rgbint_t::to_rgb() -{ - __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())); -} - -rgb_t rgbint_t::to_rgb_clamp() -{ - return _mm_cvtsi128_si32(_mm_packus_epi16(_mm_packs_epi32(m_value, m_value), _mm_setzero_si128())); -} - -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_imm_rgb(const INT32 r, const INT32 g, const INT32 b) -{ - __m128i temp = _mm_set_epi32(0, r, g, b); - m_value = _mm_add_epi32(m_value, temp); -} - -void rgbaint_t::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); -} - -void rgbint_t::sub_imm(const INT32 imm) -{ - __m128i temp = _mm_set_epi32(imm, imm, imm, imm); - m_value = _mm_sub_epi32(m_value, temp); -} - -void rgbint_t::sub_imm_rgb(const INT32 r, const INT32 g, const INT32 b) -{ - __m128i temp = _mm_set_epi32(0, r, g, b); - m_value = _mm_sub_epi32(m_value, temp); -} - -void rgbaint_t::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); -} - -void rgbint_t::subr(rgbint_t& color2) -{ - color2.m_value = _mm_sub_epi32(color2.m_value, m_value); -} - -void rgbint_t::subr_imm(const INT32 imm) -{ - __m128i temp = _mm_set_epi32(imm, imm, imm, imm); - m_value = _mm_sub_epi32(temp, m_value); -} - -void rgbint_t::subr_imm_rgb(const INT32 r, const INT32 g, const INT32 b) -{ - __m128i temp = _mm_set_epi32(0, r, g, b); - m_value = _mm_sub_epi32(temp, m_value); -} - -void rgbaint_t::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); -} - void rgbint_t::print() { printf("%04x ", _mm_extract_epi16(m_value, 7)); @@ -225,22 +26,6 @@ void rgbint_t::print() printf("%04x\n", _mm_extract_epi16(m_value, 0)); } -void rgbint_t::mul_imm_rgb(const INT32 r, const INT32 g, const INT32 b) -{ - __m128i immv = _mm_set_epi32(0, 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))); -} - -void rgbaint_t::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))); -} - /*************************************************************************** HIGHER LEVEL OPERATIONS ***************************************************************************/ diff --git a/src/emu/video/rgbsse.h b/src/emu/video/rgbsse.h index 7fe27d03eef..b6c78059bfc 100644 --- a/src/emu/video/rgbsse.h +++ b/src/emu/video/rgbsse.h @@ -37,28 +37,39 @@ extern const struct _rgbsse_statics class rgbint_t { public: - rgbint_t(); - rgbint_t(UINT32 rgb); - rgbint_t(INT32 r, INT32 g, INT32 b); - rgbint_t(rgb_t& rgb); + inline rgbint_t() { } + inline rgbint_t(UINT32 rgb) { set_rgb(rgb); } + inline rgbint_t(UINT32 r, UINT32 g, UINT32 b) { set_rgb(r, g, b); } + inline rgbint_t(rgb_t& rgb) { m_value = _mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128()); } - void set(void* value); - __m128i get(); - void set(__m128i value); - void set_rgb(UINT32 rgb); - void set_rgb(INT32 r, INT32 g, INT32 b); - void set_rgb(rgb_t& rgb); + inline void set(void* value) { m_value = *(__m128i*)value; } + inline __m128i get() { return m_value; } + inline void set(__m128i value) { m_value = value; } + inline void set(rgbint_t& other) { m_value = other.m_value; } + 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 void set(rgbint_t& other) + inline rgb_t to_rgb() { - m_value = other.m_value; + __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())); } - rgb_t to_rgb(); - rgb_t to_rgb_clamp(); + inline rgb_t to_rgb_clamp() + { + return _mm_cvtsi128_si32(_mm_packus_epi16(_mm_packs_epi32(m_value, m_value), _mm_setzero_si128())); + } - rgb_t to_rgba(); - rgb_t to_rgba_clamp(); + inline rgb_t to_rgba() + { + return to_rgb(); + } + + inline rgb_t to_rgba_clamp() + { + return to_rgb_clamp(); + } inline void add(const rgbint_t& color2) { @@ -67,21 +78,46 @@ public: inline void add_imm(const INT32 imm) { - __m128i temp = _mm_set_epi32(imm, imm, imm, imm); + __m128i temp = _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) + { + __m128i temp = _mm_set_epi32(0, r, g, b); m_value = _mm_add_epi32(m_value, temp); } - void add_imm_rgb(const INT32 r, const INT32 g, const INT32 b); inline void sub(const rgbint_t& color2) { m_value = _mm_sub_epi32(m_value, color2.m_value); } - void sub_imm(const INT32 imm); - void sub_imm_rgb(const INT32 r, const INT32 g, const INT32 b); - void subr(rgbint_t& color); - void subr_imm(const INT32 imm); - void subr_imm_rgb(const INT32 r, const INT32 g, const INT32 b); + inline void sub_imm(const INT32 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) + { + m_value = _mm_sub_epi32(m_value, _mm_set_epi32(0, r, g, b)); + } + + inline void subr(rgbint_t& color2) + { + m_value = _mm_sub_epi32(color2.m_value, m_value); + } + + inline void subr_imm(const INT32 imm) + { + 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) + { + __m128i temp = _mm_set_epi32(0, r, g, b); + m_value = _mm_sub_epi32(temp, m_value); + } inline void set_r(const INT32 value) { @@ -143,19 +179,50 @@ 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))); } - void mul_imm_rgb(const INT32 r, const INT32 g, const INT32 b); + inline void mul_imm_rgb(const INT32 r, const INT32 g, const INT32 b) + { + __m128i immv = _mm_set_epi32(0, 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 shl(const UINT8 shift) + inline void shl(const rgbint_t& shift) + { + m_value = _mm_sll_epi32(m_value, shift.m_value); + } + + inline void shl_imm(const UINT8 shift) { m_value = _mm_slli_epi32(m_value, shift); } - inline void shr(const UINT8 shift) + inline void shl_imm_all(const UINT8 shift) + { + m_value = _mm_slli_si128(m_value, shift >> 3); + } + + inline void shr(const rgbint_t& shift) + { + m_value = _mm_srl_epi32(m_value, shift.m_value); + } + + inline void shr_imm(const UINT8 shift) { m_value = _mm_srli_epi32(m_value, shift); } - inline void sra(const UINT8 shift) + inline void shr_imm_all(const UINT8 shift) + { + m_value = _mm_srli_si128(m_value, shift >> 3); + } + + inline void sra(const rgbint_t& shift) + { + m_value = _mm_sra_epi32(m_value, shift.m_value); + } + + inline void sra_imm(const UINT8 shift) { m_value = _mm_srai_epi32(m_value, shift); } @@ -185,6 +252,16 @@ public: m_value = _mm_and_si128(m_value, _mm_set_epi32(0xffffffff, r, g, b)); } + inline void xor_reg(const rgbint_t& color2) + { + m_value = _mm_xor_si128(m_value, color2.m_value); + } + + inline void xor_imm(const INT32 value) + { + m_value = _mm_xor_si128(m_value, _mm_set1_epi32(value)); + } + inline void clamp_and_clear(const rgbint_t& color, const INT32 sign) { __m128i vsign = _mm_set1_epi32(sign); @@ -216,18 +293,74 @@ public: { __m128i compare_vec = _mm_set1_epi32(compare); __m128i compare_mask = _mm_cmpeq_epi32(_mm_and_si128(m_value, compare_vec), compare_vec); - m_value = _mm_or_si128(m_value, _mm_and_si128(_mm_set1_epi32(sign), compare_mask)); + __m128i compared = _mm_and_si128(_mm_set1_epi32(sign), compare_mask); + m_value = _mm_or_si128(m_value, compared); } void print(); - rgbint_t operator=(const rgbint_t& other); - rgbint_t& operator+=(const rgbint_t& other); - rgbint_t& operator+=(const INT32 other); - rgbint_t& operator-=(const rgbint_t& other); - rgbint_t& operator*=(const rgbint_t& other); - rgbint_t& operator*=(const INT32 other); - rgbint_t& operator>>=(const INT32 shift); + inline void cmpeq(const rgbint_t& value) + { + m_value = _mm_cmpeq_epi32(m_value, value.m_value); + } + + inline void cmpeq_imm(const UINT32 value) + { + m_value = _mm_cmpeq_epi32(m_value, _mm_set1_epi32(value)); + } + + inline void cmpgt(const rgbint_t& value) + { + m_value = _mm_cmpgt_epi32(m_value, value.m_value); + } + + inline void cmplt(const rgbint_t& value) + { + m_value = _mm_cmplt_epi32(m_value, value.m_value); + } + + inline rgbint_t operator=(const rgbint_t& other) + { + m_value = other.m_value; + return *this; + } + + inline rgbint_t& operator+=(const rgbint_t& other) + { + m_value = _mm_add_epi32(m_value, other.m_value); + return *this; + } + + inline rgbint_t& operator+=(const INT32 other) + { + m_value = _mm_add_epi32(m_value, _mm_set1_epi32(other)); + return *this; + } + + inline rgbint_t& operator-=(const rgbint_t& other) + { + m_value = _mm_sub_epi32(m_value, other.m_value); + return *this; + } + + inline rgbint_t& operator*=(const rgbint_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))); + return *this; + } + + inline rgbint_t& operator*=(const INT32 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))); + return *this; + } + + inline rgbint_t& operator>>=(const INT32 shift) + { + m_value = _mm_srai_epi32(m_value, shift); + return *this; + } static UINT32 bilinear_filter(UINT32 rgb00, UINT32 rgb01, UINT32 rgb10, UINT32 rgb11, UINT8 u, UINT8 v); @@ -241,11 +374,13 @@ private: class rgbaint_t : public rgbint_t { public: - rgbaint_t(); - rgbaint_t(UINT32 rgba); - rgbaint_t(INT32 a, INT32 r, INT32 g, INT32 b); - rgbaint_t(rgb_t& rgb); + 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); @@ -261,15 +396,47 @@ public: 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)); } - void add_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b); - void sub_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b); - void subr_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 b); - void mul_imm_rgba(const INT32 a, const INT32 r, const INT32 g, const INT32 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) + { + 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); + } }; #endif /* __RGBSSE__ */ diff --git a/src/mame/video/n64.c b/src/mame/video/n64.c index 603ce4e0a47..c5a81ed0d36 100644 --- a/src/mame/video/n64.c +++ b/src/mame/video/n64.c @@ -429,12 +429,12 @@ void n64_rdp::set_add_input_rgb(color_t** input, INT32 code, rdp_span_aux* userd { switch (code & 0x7) { - case 0: *input = &userdata->m_combined_alpha; break; - case 1: *input = &userdata->m_texel0_alpha; break; - case 2: *input = &userdata->m_texel1_alpha; break; - case 3: *input = &userdata->m_prim_alpha; break; - case 4: *input = &userdata->m_shade_alpha; break; - case 5: *input = &userdata->m_env_alpha; break; + case 0: *input = &userdata->m_combined_color; break; + case 1: *input = &userdata->m_texel0_color; break; + case 2: *input = &userdata->m_texel1_color; break; + case 3: *input = &userdata->m_prim_color; break; + case 4: *input = &userdata->m_shade_color; break; + case 5: *input = &userdata->m_env_color; break; case 6: *input = &m_one; break; case 7: *input = &m_zero; break; } @@ -496,8 +496,8 @@ void n64_rdp::set_blender_input(INT32 cycle, INT32 which, color_t** input_rgb, c switch (b & 0x3) { case 0: *input_a = &userdata->m_pixel_color; break; - case 1: *input_a = &userdata->m_fog_alpha; break; - case 2: *input_a = &userdata->m_shade_alpha; break; + case 1: *input_a = &userdata->m_fog_color; break; + case 2: *input_a = &userdata->m_shade_color; break; case 3: *input_a = &m_zero; break; } } @@ -2041,10 +2041,8 @@ void n64_rdp::draw_triangle(bool shade, bool texture, bool zbuffer, bool rect) userdata->m_prim_color = m_prim_color; userdata->m_env_color = m_env_color; userdata->m_fog_color = m_fog_color; - userdata->m_blend_alpha = m_blend_alpha; userdata->m_prim_alpha = m_prim_alpha; userdata->m_env_alpha = m_env_alpha; - userdata->m_fog_alpha = m_fog_alpha; userdata->m_key_scale = m_key_scale; userdata->m_lod_fraction = m_lod_fraction; userdata->m_prim_lod_fraction = m_prim_lod_fraction; @@ -2112,7 +2110,7 @@ void n64_rdp::draw_triangle(bool shade, bool texture, bool zbuffer, bool rect) xright += xright_inc; } - if(!new_object && valid && !ignored) + if(!new_object && valid) { render_spans(yh >> 2, yl >> 2, tilenum, flip ? true : false, spans, rect, object); } @@ -2327,22 +2325,19 @@ void n64_rdp::cmd_set_fill_color32(UINT32 w1, UINT32 w2) void n64_rdp::cmd_set_convert(UINT32 w1, UINT32 w2) { if(!m_pipe_clean) { m_pipe_clean = true; wait("SetConvert"); } - INT32 k0 = (w1 >> 13) & 0xff; - INT32 k1 = (w1 >> 4) & 0xff; - INT32 k2 = ((w1 & 7) << 5) | ((w2 >> 27) & 0x1f); - INT32 k3 = (w2 >> 18) & 0xff; - INT32 k4 = (w2 >> 9) & 0xff; - INT32 k5 = w2 & 0xff; - k0 = ((w1 >> 21) & 1) ? (-(0x100 - k0)) : k0; - k1 = ((w1 >> 12) & 1) ? (-(0x100 - k1)) : k1; - k2 = (w1 & 0xf) ? (-(0x100 - k2)) : k2; - k3 = ((w2 >> 26) & 1) ? (-(0x100 - k3)) : k3; - k4 = ((w2 >> 17) & 1) ? (-(0x100 - k4)) : k4; - k5 = ((w2 >> 8) & 1) ? (-(0x100 - k5)) : k5; + INT32 k0 = (w1 >> 13) & 0x1ff; + INT32 k1 = (w1 >> 4) & 0x1ff; + INT32 k2 = ((w1 & 0xf) << 5) | ((w2 >> 27) & 0x1f); + INT32 k3 = (w2 >> 18) & 0x1ff; + INT32 k4 = (w2 >> 9) & 0x1ff; + INT32 k5 = w2 & 0x1ff; - const UINT32 k4val = k4 & 0xff; - const UINT32 k5val = k5 & 0xff; - set_yuv_factors(k0, k1, k2, k3, rgbaint_t(k4val, k4val, k4val, k4val), rgbaint_t(k5val, k5val, k5val, k5val)); + k0 = (SIGN9(k0) << 1) + 1; + k1 = (SIGN9(k1) << 1) + 1; + k2 = (SIGN9(k2) << 1) + 1; + k3 = (SIGN9(k3) << 1) + 1; + + set_yuv_factors(rgbaint_t(0, k0, k2, k3), rgbaint_t(0, 0, k1, 0), rgbaint_t(k4, k4, k4, k4), rgbaint_t(k5, k5, k5, k5)); } void n64_rdp::cmd_set_scissor(UINT32 w1, UINT32 w2) @@ -2450,6 +2445,9 @@ void n64_rdp::cmd_load_tlut(UINT32 w1, UINT32 w2) } default: fatalerror("RDP: load_tlut: size = %d\n", m_misc_state.m_ti_size); } + + m_tiles[tilenum].sth = rgbaint_t(0, m_tiles[tilenum].sh, 0, m_tiles[tilenum].th); + m_tiles[tilenum].stl = rgbaint_t(0, m_tiles[tilenum].sl, 0, m_tiles[tilenum].tl); } void n64_rdp::cmd_set_tile_size(UINT32 w1, UINT32 w2) @@ -2462,13 +2460,14 @@ void n64_rdp::cmd_set_tile_size(UINT32 w1, UINT32 w2) m_tiles[tilenum].tl = (w1 >> 0) & 0xfff; m_tiles[tilenum].sh = (w2 >> 12) & 0xfff; m_tiles[tilenum].th = (w2 >> 0) & 0xfff; + + m_tiles[tilenum].sth = rgbaint_t(0, m_tiles[tilenum].sh, 0, m_tiles[tilenum].th); + m_tiles[tilenum].stl = rgbaint_t(0, m_tiles[tilenum].sl, 0, m_tiles[tilenum].tl); } void n64_rdp::cmd_load_block(UINT32 w1, UINT32 w2) { //wait("LoadBlock"); - ignored = false; - if (w1 != 0xf3000000 || w2 != 0x070ff200) ignored = true; n64_tile_t* tile = m_tiles; const INT32 tilenum = (w2 >> 24) & 0x7; @@ -2626,6 +2625,9 @@ void n64_rdp::cmd_load_block(UINT32 w1, UINT32 w2) } tile[tilenum].th = tl; } + + m_tiles[tilenum].sth = rgbaint_t(0, m_tiles[tilenum].sh, 0, m_tiles[tilenum].th); + m_tiles[tilenum].stl = rgbaint_t(0, m_tiles[tilenum].sl, 0, m_tiles[tilenum].tl); } void n64_rdp::cmd_load_tile(UINT32 w1, UINT32 w2) @@ -2745,6 +2747,9 @@ void n64_rdp::cmd_load_tile(UINT32 w1, UINT32 w2) default: fatalerror("RDP: load_tile: size = %d\n", m_misc_state.m_ti_size); } + + m_tiles[tilenum].sth = rgbaint_t(0, m_tiles[tilenum].sh, 0, m_tiles[tilenum].th); + m_tiles[tilenum].stl = rgbaint_t(0, m_tiles[tilenum].sl, 0, m_tiles[tilenum].tl); } void n64_rdp::cmd_set_tile(UINT32 w1, UINT32 w2) @@ -2774,8 +2779,15 @@ void n64_rdp::cmd_set_tile(UINT32 w1, UINT32 w2) tex_tile->rshift_t = (tex_tile->shift_t < 11) ? tex_tile->shift_t : 0; tex_tile->wrapped_mask_s = (tex_tile->mask_s > 10 ? 10 : tex_tile->mask_s); tex_tile->wrapped_mask_t = (tex_tile->mask_t > 10 ? 10 : tex_tile->mask_t); + tex_tile->wrapped_mask = rgbaint_t(tex_tile->wrapped_mask_s, tex_tile->wrapped_mask_s, tex_tile->wrapped_mask_t, tex_tile->wrapped_mask_t); tex_tile->clamp_s = tex_tile->cs || !tex_tile->mask_s; tex_tile->clamp_t = tex_tile->ct || !tex_tile->mask_t; + tex_tile->mm = rgbaint_t(tex_tile->ms ? ~0 : 0, tex_tile->ms ? ~0 : 0, tex_tile->mt ? ~0 : 0, tex_tile->mt ? ~0 : 0); + tex_tile->invmm = rgbaint_t(tex_tile->ms ? 0 : ~0, tex_tile->ms ? 0 : ~0, tex_tile->mt ? 0 : ~0, tex_tile->mt ? 0 : ~0); + tex_tile->mask = rgbaint_t(tex_tile->mask_s, tex_tile->mask_s, tex_tile->mask_t, tex_tile->mask_t); + tex_tile->lshift = rgbaint_t(0, tex_tile->lshift_s, 0, tex_tile->lshift_t); + tex_tile->rshift = rgbaint_t(0, tex_tile->rshift_s, 0, tex_tile->rshift_t); + tex_tile->clamp_st = rgbaint_t(0, tex_tile->clamp_s ? ~0 : 0, 0, tex_tile->clamp_t ? ~0 : 0); if (tex_tile->format == FORMAT_I && tex_tile->size > PIXEL_SIZE_8BIT) { @@ -2828,13 +2840,11 @@ void n64_rdp::cmd_fill_rect(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_alpha.set(m_fog_color); } 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_alpha.set(m_blend_color); } void n64_rdp::cmd_set_prim_color(UINT32 w1, UINT32 w2) @@ -2844,13 +2854,13 @@ void n64_rdp::cmd_set_prim_color(UINT32 w1, UINT32 w2) m_prim_lod_fraction.set_rgba(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_alpha.set(m_prim_color); + m_prim_alpha.set_rgba(w2 & 0xff, w2 & 0xff, w2 & 0xff, w2 & 0xff); } 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_alpha.set(m_env_color); + m_env_alpha.set_rgba(w2 & 0xff, w2 & 0xff, w2 & 0xff, w2 & 0xff); } void n64_rdp::cmd_set_combine(UINT32 w1, UINT32 w2) @@ -3031,7 +3041,6 @@ void n64_rdp::process_command_list() n64_rdp::n64_rdp(n64_state &state) : poly_manager(state.machine()) { - ignored = true; m_aux_buf_ptr = 0; m_aux_buf = NULL; m_pipe_clean = true; diff --git a/src/mame/video/n64.h b/src/mame/video/n64.h index c7b1537265c..9d132f22146 100644 --- a/src/mame/video/n64.h +++ b/src/mame/video/n64.h @@ -192,11 +192,9 @@ public: UINT8 get_random() { return m_misc_state.m_random_seed += 0x13; } // YUV Factors - void set_yuv_factors(INT32 k0, INT32 k1, INT32 k2, INT32 k3, color_t k4, color_t k5) { m_k0 = k0; m_k1 = k1; m_k2 = k2; m_k3 = k3; m_k4 = k4; m_k5 = k5; } - INT32 get_k0() const { return m_k0; } - INT32 get_k1() const { return m_k1; } - INT32 get_k2() const { return m_k2; } - INT32 get_k3() const { return m_k3; } + void set_yuv_factors(color_t k023, color_t k1, color_t k4, color_t k5) { m_k023 = k023; m_k1 = k1; m_k4 = k4; m_k5 = k5; } + color_t& get_k023() { return m_k023; } + color_t& get_k1() { return m_k1; } // Blender-related (move into RDP::Blender) void set_blender_input(INT32 cycle, INT32 which, color_t** input_rgb, color_t** input_a, INT32 a, INT32 b, rdp_span_aux* userdata); @@ -277,13 +275,11 @@ public: // Color constants color_t m_blend_color; /* constant blend color */ - color_t m_blend_alpha; /* constant blend alpha */ color_t m_prim_color; /* flat primitive color */ color_t m_prim_alpha; /* flat primitive alpha */ color_t m_env_color; /* generic color constant ('environment') */ color_t m_env_alpha; /* generic alpha constant ('environment') */ color_t m_fog_color; /* generic color constant ('fog') */ - color_t m_fog_alpha; /* generic alpha constant ('fog') */ color_t m_key_scale; /* color-keying constant */ color_t m_lod_fraction; /* Z-based LOD fraction for this poly */ color_t m_prim_lod_fraction; /* fixed LOD fraction for this poly */ @@ -364,10 +360,8 @@ private: UINT8* m_tmem; // YUV factors - INT32 m_k0; - INT32 m_k1; - INT32 m_k2; - INT32 m_k3; + color_t m_k023; + color_t m_k1; color_t m_k4; color_t m_k5; @@ -378,7 +372,6 @@ private: INT32 m_gamma_table[256]; INT32 m_gamma_dither_table[0x4000]; - bool ignored; static UINT32 s_special_9bit_clamptable[512]; static const z_decompress_entry_t m_z_dec_table[8]; diff --git a/src/mame/video/n64types.h b/src/mame/video/n64types.h index d37d867be42..98b7ff0e766 100644 --- a/src/mame/video/n64types.h +++ b/src/mame/video/n64types.h @@ -120,6 +120,8 @@ struct n64_tile_t INT32 lshift_s, rshift_s, lshift_t, rshift_t; INT32 wrapped_mask_s, wrapped_mask_t; bool clamp_s, clamp_t; + rgbaint_t mm, invmm; + rgbaint_t wrapped_mask, mask, lshift, rshift, sth, stl, clamp_st; UINT16 sl, tl, sh, th; // 10.2 fixed-point, starting and ending texel row / column INT32 num; }; @@ -272,15 +274,13 @@ struct rdp_span_aux color_t m_next_texel_color; color_t m_next_texel_alpha; color_t m_blend_color; /* constant blend color */ - color_t m_blend_alpha; /* constant blend alpha */ color_t m_prim_color; /* flat primitive color */ color_t m_prim_alpha; /* flat primitive alpha */ color_t m_env_color; /* generic color constant ('environment') */ - color_t m_env_alpha; /* generic color constant ('environment') */ + color_t m_env_alpha; /* generic alpha constant ('environment') */ color_t m_fog_color; /* generic color constant ('fog') */ - color_t m_fog_alpha; /* generic color constant ('fog') */ color_t m_shade_color; /* gouraud-shaded color */ - color_t m_shade_alpha; /* gouraud-shaded color */ + color_t m_shade_alpha; /* gouraud-shaded alpha */ color_t m_key_scale; /* color-keying constant */ color_t m_noise_color; /* noise */ color_t m_lod_fraction; /* Z-based LOD fraction for this poly */ @@ -300,8 +300,7 @@ struct rdp_span_aux INT32 m_dzpix_enc; UINT8* m_tmem; /* pointer to texture cache for this polygon */ bool m_start_span; - INT32 m_clamp_s_diff[8]; - INT32 m_clamp_t_diff[8]; + rgbaint_t m_clamp_diff[8]; }; struct z_decompress_entry_t diff --git a/src/mame/video/rdpblend.c b/src/mame/video/rdpblend.c index 08d99b299c5..a431a985b74 100644 --- a/src/mame/video/rdpblend.c +++ b/src/mame/video/rdpblend.c @@ -101,7 +101,7 @@ bool n64_blender_t::alpha_reject(rdp_span_aux* userdata, const rdp_poly_state& o bool n64_blender_t::cycle1_noblend_noacvg_nodither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, rdp_span_aux* userdata, const rdp_poly_state& object) { userdata->m_pixel_color.set_a(m_alpha_dither[((UINT8)userdata->m_pixel_color.get_a() << 3) | adseed]); - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { return false; @@ -114,14 +114,14 @@ bool n64_blender_t::cycle1_noblend_noacvg_nodither(color_t& blended_pixel, int d bool n64_blender_t::cycle1_noblend_noacvg_dither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, rdp_span_aux* userdata, const rdp_poly_state& object) { userdata->m_pixel_color.set_a(m_alpha_dither[((UINT8)userdata->m_pixel_color.get_a() << 3) | adseed]); - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { return false; } rgbaint_t index(*userdata->m_color_inputs.blender1a_rgb[0]); - index.shl(3); + index.shl_imm(3); index.or_imm(dith); 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()]); @@ -131,7 +131,7 @@ bool n64_blender_t::cycle1_noblend_noacvg_dither(color_t& blended_pixel, int dit bool n64_blender_t::cycle1_noblend_acvg_nodither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, rdp_span_aux* userdata, const rdp_poly_state& object) { - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { @@ -144,7 +144,7 @@ bool n64_blender_t::cycle1_noblend_acvg_nodither(color_t& blended_pixel, int dit bool n64_blender_t::cycle1_noblend_acvg_dither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, rdp_span_aux* userdata, const rdp_poly_state& object) { - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { @@ -152,7 +152,7 @@ bool n64_blender_t::cycle1_noblend_acvg_dither(color_t& blended_pixel, int dith, } rgbaint_t index(*userdata->m_color_inputs.blender1a_rgb[0]); - index.shl(3); + index.shl_imm(3); index.or_imm(dith); 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()]); @@ -163,7 +163,7 @@ bool n64_blender_t::cycle1_noblend_acvg_dither(color_t& blended_pixel, int dith, bool n64_blender_t::cycle1_blend_noacvg_nodither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, rdp_span_aux* userdata, const rdp_poly_state& object) { userdata->m_pixel_color.set_a(m_alpha_dither[((UINT8)userdata->m_pixel_color.get_a() << 3) | adseed]); - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { @@ -178,7 +178,7 @@ bool n64_blender_t::cycle1_blend_noacvg_nodither(color_t& blended_pixel, int dit bool n64_blender_t::cycle1_blend_noacvg_dither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, rdp_span_aux* userdata, const rdp_poly_state& object) { userdata->m_pixel_color.set_a(m_alpha_dither[((UINT8)userdata->m_pixel_color.get_a() << 3) | adseed]); - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { @@ -188,7 +188,7 @@ bool n64_blender_t::cycle1_blend_noacvg_dither(color_t& blended_pixel, int dith, color_t rgb; blend_with_partial_reject(rgb, 0, partialreject, sel0, userdata, object); - rgb.shl(3); + rgb.shl_imm(3); rgb.or_imm(dith); 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()]); @@ -198,7 +198,7 @@ bool n64_blender_t::cycle1_blend_noacvg_dither(color_t& blended_pixel, int dith, bool n64_blender_t::cycle1_blend_acvg_nodither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, rdp_span_aux* userdata, const rdp_poly_state& object) { - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { @@ -212,7 +212,7 @@ bool n64_blender_t::cycle1_blend_acvg_nodither(color_t& blended_pixel, int dith, bool n64_blender_t::cycle1_blend_acvg_dither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, rdp_span_aux* userdata, const rdp_poly_state& object) { - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { @@ -222,7 +222,7 @@ bool n64_blender_t::cycle1_blend_acvg_dither(color_t& blended_pixel, int dith, i color_t rgb; blend_with_partial_reject(rgb, 0, partialreject, sel0, userdata, object); - rgb.shl(3); + rgb.shl_imm(3); rgb.or_imm(dith); 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()]); @@ -233,17 +233,17 @@ bool n64_blender_t::cycle1_blend_acvg_dither(color_t& blended_pixel, int dith, i bool n64_blender_t::cycle2_noblend_noacvg_nodither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, int sel1, rdp_span_aux* userdata, const rdp_poly_state& object) { userdata->m_pixel_color.set_a(m_alpha_dither[((UINT8)userdata->m_pixel_color.get_a() << 3) | adseed]); - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { return false; } - userdata->m_inv_pixel_color.set_a(0xff - (UINT8)userdata->m_color_inputs.blender1b_a[0]->get_a()); + userdata->m_inv_pixel_color.set_a(0xff - userdata->m_color_inputs.blender1b_a[0]->get_a()); blend_pipe(0, sel0, userdata->m_blended_pixel_color, userdata, object); - userdata->m_blended_pixel_color.set_a(userdata->m_pixel_color.get_a()); + blended_pixel.set(*userdata->m_color_inputs.blender1a_rgb[1]); return true; @@ -252,7 +252,7 @@ bool n64_blender_t::cycle2_noblend_noacvg_nodither(color_t& blended_pixel, int d bool n64_blender_t::cycle2_noblend_noacvg_dither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, int sel1, rdp_span_aux* userdata, const rdp_poly_state& object) { userdata->m_pixel_color.set_a(m_alpha_dither[((UINT8)userdata->m_pixel_color.get_a() << 3) | adseed]); - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { @@ -261,10 +261,10 @@ bool n64_blender_t::cycle2_noblend_noacvg_dither(color_t& blended_pixel, int dit userdata->m_inv_pixel_color.set_a(0xff - (UINT8)userdata->m_color_inputs.blender1b_a[0]->get_a()); blend_pipe(0, sel0, userdata->m_blended_pixel_color, userdata, object); - userdata->m_blended_pixel_color.set_a((UINT8)userdata->m_pixel_color.get_a()); + userdata->m_blended_pixel_color.set_a(userdata->m_pixel_color.get_a()); rgbaint_t index(*userdata->m_color_inputs.blender1a_rgb[1]); - index.shl(3); + index.shl_imm(3); index.or_imm(dith); 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()]); @@ -274,16 +274,16 @@ bool n64_blender_t::cycle2_noblend_noacvg_dither(color_t& blended_pixel, int dit bool n64_blender_t::cycle2_noblend_acvg_nodither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, int sel1, rdp_span_aux* userdata, const rdp_poly_state& object) { - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { return false; } - userdata->m_inv_pixel_color.set_a(0xff - (UINT8)userdata->m_color_inputs.blender1b_a[0]->get_a()); + userdata->m_inv_pixel_color.set_a(0xff - userdata->m_color_inputs.blender1b_a[0]->get_a()); blend_pipe(0, sel0, userdata->m_blended_pixel_color, userdata, object); - userdata->m_blended_pixel_color.set_a((UINT8)userdata->m_pixel_color.get_a()); + userdata->m_blended_pixel_color.set_a(userdata->m_pixel_color.get_a()); blended_pixel.set(*userdata->m_color_inputs.blender1a_rgb[1]); @@ -292,30 +292,22 @@ bool n64_blender_t::cycle2_noblend_acvg_nodither(color_t& blended_pixel, int dit bool n64_blender_t::cycle2_noblend_acvg_dither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, int sel1, rdp_span_aux* userdata, const rdp_poly_state& object) { - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { return false; } - userdata->m_inv_pixel_color.set_a(0xff - (UINT8)userdata->m_color_inputs.blender1b_a[0]->get_a()); + userdata->m_inv_pixel_color.set_a(0xff - userdata->m_color_inputs.blender1b_a[0]->get_a()); blend_pipe(0, sel0, userdata->m_blended_pixel_color, userdata, object); - userdata->m_blended_pixel_color.set_a((UINT8)userdata->m_pixel_color.get_a()); + userdata->m_blended_pixel_color.set_a(userdata->m_pixel_color.get_a()); rgbaint_t index(*userdata->m_color_inputs.blender1a_rgb[1]); - index.shl(3); + index.shl_imm(3); index.or_imm(dith); 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()]); - if (blended_pixel.get_r() == 0 && blended_pixel.get_g() == 0 && blended_pixel.get_b() == 0) - { - rgbaint_t other_index(*userdata->m_color_inputs.blender1a_rgb[1]); - //other_index.shl(3); - //other_index.or_imm(dith); - //other_index.and_imm(0x7ff); - printf("%08x%08x%08x\n", userdata->m_blended_pixel_color.get_r32(), userdata->m_blended_pixel_color.get_g32(), userdata->m_blended_pixel_color.get_b32()); - } return true; } @@ -323,16 +315,16 @@ bool n64_blender_t::cycle2_noblend_acvg_dither(color_t& blended_pixel, int dith, bool n64_blender_t::cycle2_blend_noacvg_nodither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, int sel1, rdp_span_aux* userdata, const rdp_poly_state& object) { userdata->m_pixel_color.set_a(m_alpha_dither[((UINT8)userdata->m_pixel_color.get_a() << 3) | adseed]); - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { return false; } - userdata->m_inv_pixel_color.set_a(0xff - (UINT8)userdata->m_color_inputs.blender1b_a[0]->get_a()); + userdata->m_inv_pixel_color.set_a(0xff - userdata->m_color_inputs.blender1b_a[0]->get_a()); blend_pipe(0, sel0, userdata->m_blended_pixel_color, userdata, object); - userdata->m_blended_pixel_color.set_a((UINT8)userdata->m_pixel_color.get_a()); + userdata->m_blended_pixel_color.set_a(userdata->m_pixel_color.get_a()); blend_with_partial_reject(blended_pixel, 1, partialreject, sel1, userdata, object); @@ -341,22 +333,22 @@ bool n64_blender_t::cycle2_blend_noacvg_nodither(color_t& blended_pixel, int dit bool n64_blender_t::cycle2_blend_noacvg_dither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, int sel1, rdp_span_aux* userdata, const rdp_poly_state& object) { - userdata->m_pixel_color.set_a(m_alpha_dither[((UINT8)userdata->m_pixel_color.get_a() << 3) | adseed]); - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_pixel_color.set_a(m_alpha_dither[(userdata->m_pixel_color.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[(userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { return false; } - userdata->m_inv_pixel_color.set_a(0xff - (UINT8)userdata->m_color_inputs.blender1b_a[0]->get_a()); + userdata->m_inv_pixel_color.set_a(0xff - userdata->m_color_inputs.blender1b_a[0]->get_a()); blend_pipe(0, sel0, userdata->m_blended_pixel_color, userdata, object); userdata->m_blended_pixel_color.set_a(userdata->m_pixel_color.get_a()); color_t rgb; blend_with_partial_reject(rgb, 1, partialreject, sel1, userdata, object); - rgb.shl(3); + rgb.shl_imm(3); rgb.or_imm(dith); 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()]); @@ -366,16 +358,16 @@ bool n64_blender_t::cycle2_blend_noacvg_dither(color_t& blended_pixel, int dith, bool n64_blender_t::cycle2_blend_acvg_nodither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, int sel1, rdp_span_aux* userdata, const rdp_poly_state& object) { - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[(userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { return false; } - userdata->m_inv_pixel_color.set_a(0xff - (UINT8)userdata->m_color_inputs.blender1b_a[0]->get_a()); + userdata->m_inv_pixel_color.set_a(0xff - userdata->m_color_inputs.blender1b_a[0]->get_a()); blend_pipe(0, sel0, userdata->m_blended_pixel_color, userdata, object); - userdata->m_blended_pixel_color.set_a((UINT8)userdata->m_pixel_color.get_a()); + userdata->m_blended_pixel_color.set_a(userdata->m_pixel_color.get_a()); blend_with_partial_reject(blended_pixel, 1, partialreject, sel1, userdata, object); @@ -384,21 +376,21 @@ bool n64_blender_t::cycle2_blend_acvg_nodither(color_t& blended_pixel, int dith, bool n64_blender_t::cycle2_blend_acvg_dither(color_t& blended_pixel, int dith, int adseed, int partialreject, int sel0, int sel1, rdp_span_aux* userdata, const rdp_poly_state& object) { - userdata->m_shade_color.set_a(m_alpha_dither[((UINT8)userdata->m_shade_alpha.get_a() << 3) | adseed]); + userdata->m_shade_color.set_a(m_alpha_dither[(userdata->m_shade_color.get_a() << 3) | adseed]); if (test_for_reject(userdata, object)) { return false; } - userdata->m_inv_pixel_color.set_a(0xff - (UINT8)userdata->m_color_inputs.blender1b_a[0]->get_a()); + userdata->m_inv_pixel_color.set_a(0xff - userdata->m_color_inputs.blender1b_a[0]->get_a()); blend_pipe(0, sel0, userdata->m_blended_pixel_color, userdata, object); - userdata->m_blended_pixel_color.set_a((UINT8)userdata->m_pixel_color.get_a()); + userdata->m_blended_pixel_color.set_a(userdata->m_pixel_color.get_a()); color_t rgb; blend_with_partial_reject(rgb, 1, partialreject, sel1, userdata, object); - rgb.shl(3); + rgb.shl_imm(3); rgb.or_imm(dith); 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()]); @@ -408,13 +400,13 @@ bool n64_blender_t::cycle2_blend_acvg_dither(color_t& blended_pixel, int dith, i void n64_blender_t::blend_with_partial_reject(color_t& out, INT32 cycle, INT32 partialreject, INT32 select, rdp_span_aux* userdata, const rdp_poly_state& object) { - if (partialreject && (UINT8)userdata->m_pixel_color.get_a() >= 0xff) + if (partialreject && userdata->m_pixel_color.get_a() >= 0xff) { out.set(*userdata->m_color_inputs.blender1a_rgb[cycle]); } else { - userdata->m_inv_pixel_color.set_a(0xff - (UINT8)userdata->m_color_inputs.blender1b_a[cycle]->get_a()); + userdata->m_inv_pixel_color.set_a(0xff - userdata->m_color_inputs.blender1b_a[cycle]->get_a()); blend_pipe(cycle, select, out, userdata, object); } } @@ -436,18 +428,19 @@ void n64_blender_t::blend_pipe(const int cycle, const int special, color_t& out, other.mul_imm(blend2a); temp.add(other); - secondary.shl(special_shift); + secondary.shl_imm(special_shift); temp.add(secondary); - temp.shr(object.m_other_modes.blend_shift); + temp.shr_imm(object.m_other_modes.blend_shift); + INT32 factor_sum = 0; if (!object.m_other_modes.force_blend) { - INT32 factor_sum = ((blend1a >> 2) + (blend2a >> 2) + 1) & 0xf; + factor_sum = ((blend1a >> 2) + (blend2a >> 2) + 1) & 0xf; if (factor_sum) { - temp.set_r(temp.get_r() / factor_sum); - temp.set_g(temp.get_g() / factor_sum); - temp.set_b(temp.get_b() / factor_sum); + temp.set_r(temp.get_r32() / factor_sum); + temp.set_g(temp.get_g32() / factor_sum); + temp.set_b(temp.get_b32() / factor_sum); } else { diff --git a/src/mame/video/rdpspn16.c b/src/mame/video/rdpspn16.c index ea7bdaf63e8..6498da54164 100644 --- a/src/mame/video/rdpspn16.c +++ b/src/mame/video/rdpspn16.c @@ -82,8 +82,9 @@ 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) { - userdata->m_shade_color.clamp_and_clear(rgbaint_t((UINT8)sa, (UINT8)sr, (UINT8)sg, (UINT8)sb), 0xfffffe00); - userdata->m_shade_alpha = userdata->m_shade_color; + userdata->m_shade_color.clamp_and_clear(rgbaint_t(sa, sr, sg, sb), 0xfffffe00); + UINT32 a = userdata->m_shade_color.get_a(); + userdata->m_shade_alpha.set_rgba(a, a, a, a); INT32 zanded = (*sz) & 0x60000; @@ -142,7 +143,7 @@ inline void n64_rdp::write_pixel(UINT32 curpixel, color_t& color, rdp_span_aux* } else { - color.shr(3); + color.shr_imm(3); finalcolor = (color.get_r() << 11) | (color.get_g() << 6) | (color.get_b() << 1); } @@ -428,48 +429,32 @@ void n64_rdp::span_draw_1cycle(INT32 scanline, const extent_t &extent, const rdp rgbaz_clip(sr, sg, sb, sa, &sz, userdata); ((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.Cycle(&userdata->m_texel0_color, &userdata->m_texel0_color, sss, sst, tilenum, 0, userdata, object); - - userdata->m_texel0_alpha.set(userdata->m_texel0_color); + UINT32 t0a = userdata->m_texel0_color.get_a(); + userdata->m_texel0_alpha.set_rgba(t0a, t0a, t0a, t0a); const UINT8 noise = rand() << 3; // Not accurate userdata->m_noise_color.set_rgba(0, noise, noise, noise); - 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 rgbmul(*userdata->m_color_inputs.combiner_rgbmul[0]); - rgbaint_t rgbadd(*userdata->m_color_inputs.combiner_rgbadd[0]); + 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 rgbmul(*userdata->m_color_inputs.combiner_rgbmul[1]); + rgbaint_t rgbadd(*userdata->m_color_inputs.combiner_rgbadd[1]); - rgbaint_t alphasub_a(*userdata->m_color_inputs.combiner_alphasub_a[0]); - rgbaint_t alphasub_b(*userdata->m_color_inputs.combiner_alphasub_b[0]); - rgbaint_t alphamul(*userdata->m_color_inputs.combiner_alphamul[0]); - rgbaint_t alphaadd(*userdata->m_color_inputs.combiner_alphaadd[0]); - - rgbsub_a.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - rgbsub_b.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - rgbmul.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - rgbadd.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - - alphasub_a.and_imm_rgba(0xffffffff, 0, 0, 0); - alphasub_b.and_imm_rgba(0xffffffff, 0, 0, 0); - alphamul.and_imm_rgba(0xffffffff, 0, 0, 0); - alphaadd.and_imm_rgba(0xffffffff, 0, 0, 0); - - rgbsub_a.or_reg(alphasub_a); - rgbsub_b.or_reg(alphasub_b); - rgbmul.or_reg(alphamul); - rgbadd.or_reg(alphaadd); + rgbsub_a.merge_alpha(*userdata->m_color_inputs.combiner_alphasub_a[1]); + rgbsub_b.merge_alpha(*userdata->m_color_inputs.combiner_alphasub_b[1]); + rgbmul.merge_alpha(*userdata->m_color_inputs.combiner_alphamul[1]); + rgbadd.merge_alpha(*userdata->m_color_inputs.combiner_alphaadd[1]); rgbsub_a.sign_extend(0x180, 0xfffffe00); rgbsub_b.sign_extend(0x180, 0xfffffe00); rgbadd.sign_extend(0x180, 0xfffffe00); - rgbadd.shl(8); + rgbadd.shl_imm(8); rgbsub_a.sub(rgbsub_b); rgbsub_a.mul(rgbmul); rgbsub_a.add(rgbadd); rgbsub_a.add_imm(0x0080); - rgbsub_a.sra(8); + rgbsub_a.sra_imm(8); rgbsub_a.clamp_and_clear(rgbsub_a, 0xfffffe00); userdata->m_pixel_color = rgbsub_a; @@ -491,10 +476,6 @@ void n64_rdp::span_draw_1cycle(INT32 scanline, const extent_t &extent, const rdp color_t blended_pixel; bool rendered = ((&m_blender)->*(m_blender.blend1[(userdata->m_blend_enable << 2) | blend_index]))(blended_pixel, cdith, adith, partialreject, sel0, userdata, object); - if (machine().input().code_pressed(KEYCODE_S) && blended_pixel.get_r() == 0 && blended_pixel.get_g() == 0 && blended_pixel.get_b() == 0) - { - printf("1:%d ", (userdata->m_blend_enable << 2) | blend_index); - } if (rendered) { @@ -673,9 +654,12 @@ void n64_rdp::span_draw_2cycle(INT32 scanline, const extent_t &extent, const rdp ((m_tex_pipe).*(m_tex_pipe.m_cycle[cycle1]))(&userdata->m_texel1_color, &userdata->m_texel0_color, sss, sst, tile2, 1, userdata, object); ((m_tex_pipe).*(m_tex_pipe.m_cycle[cycle1]))(&userdata->m_next_texel_color, &userdata->m_next_texel_color, sss, sst, tile2, 1, userdata, object); - userdata->m_texel0_alpha.set(userdata->m_texel0_color); - userdata->m_texel1_alpha.set(userdata->m_texel1_color); - userdata->m_next_texel_alpha.set(userdata->m_next_texel_color); + UINT32 t0a = userdata->m_texel0_color.get_a(); + UINT32 t1a = userdata->m_texel1_color.get_a(); + UINT32 tna = userdata->m_next_texel_color.get_a(); + userdata->m_texel0_alpha.set_rgba(t0a, t0a, t0a, t0a); + userdata->m_texel1_alpha.set_rgba(t1a, t1a, t1a, t1a); + userdata->m_next_texel_alpha.set_rgba(tna, tna, tna, tna); const UINT8 noise = rand() << 3; // Not accurate userdata->m_noise_color.set_rgba(0, noise, noise, noise); @@ -685,84 +669,56 @@ void n64_rdp::span_draw_2cycle(INT32 scanline, const extent_t &extent, const rdp rgbaint_t rgbmul(*userdata->m_color_inputs.combiner_rgbmul[0]); rgbaint_t rgbadd(*userdata->m_color_inputs.combiner_rgbadd[0]); - rgbaint_t alphasub_a(*userdata->m_color_inputs.combiner_alphasub_a[0]); - rgbaint_t alphasub_b(*userdata->m_color_inputs.combiner_alphasub_b[0]); - rgbaint_t alphamul(*userdata->m_color_inputs.combiner_alphamul[0]); - rgbaint_t alphaadd(*userdata->m_color_inputs.combiner_alphaadd[0]); - - rgbsub_a.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - rgbsub_b.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - rgbmul.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - rgbadd.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - - alphasub_a.and_imm_rgba(0xffffffff, 0, 0, 0); - alphasub_b.and_imm_rgba(0xffffffff, 0, 0, 0); - alphamul.and_imm_rgba(0xffffffff, 0, 0, 0); - alphaadd.and_imm_rgba(0xffffffff, 0, 0, 0); - - rgbsub_a.or_reg(alphasub_a); - rgbsub_b.or_reg(alphasub_b); - rgbmul.or_reg(alphamul); - rgbadd.or_reg(alphaadd); + rgbsub_a.merge_alpha(*userdata->m_color_inputs.combiner_alphasub_a[0]); + rgbsub_b.merge_alpha(*userdata->m_color_inputs.combiner_alphasub_b[0]); + rgbmul.merge_alpha(*userdata->m_color_inputs.combiner_alphamul[0]); + rgbadd.merge_alpha(*userdata->m_color_inputs.combiner_alphaadd[0]); rgbsub_a.sign_extend(0x180, 0xfffffe00); rgbsub_b.sign_extend(0x180, 0xfffffe00); rgbadd.sign_extend(0x180, 0xfffffe00); - rgbadd.shl(8); + rgbadd.shl_imm(8); rgbsub_a.sub(rgbsub_b); rgbsub_a.mul(rgbmul); rgbsub_a.add(rgbadd); rgbsub_a.add_imm(0x0080); - rgbsub_a.sra(8); + rgbsub_a.sra_imm(8); rgbsub_a.clamp_and_clear(rgbsub_a, 0xfffffe00); userdata->m_combined_color.set(rgbsub_a); - userdata->m_combined_alpha.set(rgbsub_a); userdata->m_texel0_color.set(userdata->m_texel1_color); - userdata->m_texel0_alpha.set(userdata->m_texel1_alpha); userdata->m_texel1_color.set(userdata->m_next_texel_color); + + UINT32 ca = userdata->m_combined_color.get_a(); + userdata->m_combined_alpha.set_rgba(ca, ca, ca, ca); + userdata->m_texel0_alpha.set(userdata->m_texel1_alpha); userdata->m_texel1_alpha.set(userdata->m_next_texel_alpha); - rgbsub_a = *userdata->m_color_inputs.combiner_rgbsub_a[1]; - rgbsub_b = *userdata->m_color_inputs.combiner_rgbsub_b[1]; - rgbmul = *userdata->m_color_inputs.combiner_rgbmul[1]; - rgbadd = *userdata->m_color_inputs.combiner_rgbadd[1]; + rgbsub_a.set(*userdata->m_color_inputs.combiner_rgbsub_a[1]); + rgbsub_b.set(*userdata->m_color_inputs.combiner_rgbsub_b[1]); + rgbmul.set(*userdata->m_color_inputs.combiner_rgbmul[1]); + rgbadd.set(*userdata->m_color_inputs.combiner_rgbadd[1]); - alphasub_a = *userdata->m_color_inputs.combiner_alphasub_a[1]; - alphasub_b = *userdata->m_color_inputs.combiner_alphasub_b[1]; - alphamul = *userdata->m_color_inputs.combiner_alphamul[1]; - alphaadd = *userdata->m_color_inputs.combiner_alphaadd[1]; - - rgbsub_a.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - rgbsub_b.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - rgbmul.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - rgbadd.and_imm_rgba(0, 0xffffffff, 0xffffffff, 0xffffffff); - - alphasub_a.and_imm_rgba(0xffffffff, 0, 0, 0); - alphasub_b.and_imm_rgba(0xffffffff, 0, 0, 0); - alphamul.and_imm_rgba(0xffffffff, 0, 0, 0); - alphaadd.and_imm_rgba(0xffffffff, 0, 0, 0); - - rgbsub_a.or_reg(alphasub_a); - rgbsub_b.or_reg(alphasub_b); - rgbmul.or_reg(alphamul); - rgbadd.or_reg(alphaadd); + rgbsub_a.merge_alpha(*userdata->m_color_inputs.combiner_alphasub_a[1]); + rgbsub_b.merge_alpha(*userdata->m_color_inputs.combiner_alphasub_b[1]); + rgbmul.merge_alpha(*userdata->m_color_inputs.combiner_alphamul[1]); + rgbadd.merge_alpha(*userdata->m_color_inputs.combiner_alphaadd[1]); rgbsub_a.sign_extend(0x180, 0xfffffe00); rgbsub_b.sign_extend(0x180, 0xfffffe00); rgbadd.sign_extend(0x180, 0xfffffe00); - rgbadd.shl(8); + rgbadd.shl_imm(8); rgbsub_a.sub(rgbsub_b); rgbsub_a.mul(rgbmul); rgbsub_a.add(rgbadd); rgbsub_a.add_imm(0x0080); - rgbsub_a.sra(8); + rgbsub_a.sra_imm(8); rgbsub_a.clamp_and_clear(rgbsub_a, 0xfffffe00); - userdata->m_pixel_color = rgbsub_a; + userdata->m_pixel_color.set(rgbsub_a); //Alpha coverage combiner userdata->m_pixel_color.set_a(get_alpha_cvg(userdata->m_pixel_color.get_a(), userdata, object)); @@ -779,10 +735,6 @@ void n64_rdp::span_draw_2cycle(INT32 scanline, const extent_t &extent, const rdp color_t blended_pixel; bool rendered = ((&m_blender)->*(m_blender.blend2[(userdata->m_blend_enable << 2) | blend_index]))(blended_pixel, cdith, adith, partialreject, sel0, sel1, userdata, object); - if (machine().input().code_pressed(KEYCODE_S) && blended_pixel.get_r() == 0 && blended_pixel.get_g() == 0 && blended_pixel.get_b() == 0) - { - printf("2:%d ", (userdata->m_blend_enable << 2) | blend_index); - } if (rendered) { diff --git a/src/mame/video/rdptpipe.c b/src/mame/video/rdptpipe.c index b1ada230132..d10f237bb2b 100644 --- a/src/mame/video/rdptpipe.c +++ b/src/mame/video/rdptpipe.c @@ -60,429 +60,320 @@ void n64_texture_pipe_t::set_machine(running_machine &machine) } } } + + m_st2_add.set_rgba(0, 1, 0, 1); + m_v1.set_rgba(1, 1, 1, 1); } -void n64_texture_pipe_t::mask(INT32* S, INT32* T, const n64_tile_t& tile) +void n64_texture_pipe_t::mask(rgbaint_t& st, const n64_tile_t& tile) { - if (tile.mask_s) - { - INT32 wrap = *S >> tile.wrapped_mask_s; - wrap &= 1; - if (tile.ms && wrap) - { - *S = (~(*S)); - } - *S &= m_maskbits_table[tile.mask_s]; - } - - if (tile.mask_t) - { - INT32 wrap = *T >> tile.wrapped_mask_t; - wrap &= 1; - if (tile.mt && wrap) - { - *T = (~(*T)); - } - *T &= m_maskbits_table[tile.mask_t]; - } + rgbaint_t wrap(st); + wrap.shr(tile.wrapped_mask); + wrap.and_reg(m_v1); + wrap.cmpeq(m_v1); + wrap.and_reg(tile.mm); + st.xor_reg(wrap); + st.and_reg(rgbaint_t(0, m_maskbits_table[tile.mask_s], 0, m_maskbits_table[tile.mask_t])); } -void n64_texture_pipe_t::mask_coupled(INT32* S, INT32* S1, INT32* T, INT32* T1, const n64_tile_t& tile) +void n64_texture_pipe_t::mask_coupled(rgbaint_t& sstt, const n64_tile_t& tile) { - if (tile.mask_s) - { - const INT32 maskbits_s = m_maskbits_table[tile.mask_s]; - if (tile.ms) - { - const INT32 swrapthreshold = tile.mask_s > 10 ? 10 : tile.mask_s; - const INT32 wrap = (*S >> swrapthreshold) & 1; - const INT32 wrap1 = (*S1 >> swrapthreshold) & 1; - if (wrap) - { - *S = (~(*S)); - } - if (wrap1) - { - *S1 = (~(*S1)); - } - } - *S &= maskbits_s; - *S1 &= maskbits_s; - } + UINT32 s_mask_bits = m_maskbits_table[tile.mask_s]; + UINT32 t_mask_bits = m_maskbits_table[tile.mask_t]; + rgbaint_t maskbits(s_mask_bits, s_mask_bits, t_mask_bits, t_mask_bits); - if (tile.mask_t) - { - const INT32 maskbits_t = m_maskbits_table[tile.mask_t]; - if (tile.mt) - { - const INT32 twrapthreshold = tile.mask_t > 10 ? 10 : tile.mask_t; - const INT32 wrap = (*T >> twrapthreshold) & 1; - const INT32 wrap1 = (*T1 >> twrapthreshold) & 1; - if (wrap) - { - *T = (~(*T)); - } - if (wrap1) - { - *T1 = (~(*T1)); - } - } - *T &= maskbits_t; - *T1 &= maskbits_t; - } + rgbaint_t wrap(sstt); + wrap.shr(tile.wrapped_mask); + wrap.and_reg(m_v1); + wrap.cmpeq(m_v1); + wrap.and_reg(tile.mm); + sstt.xor_reg(wrap); + sstt.and_reg(maskbits); } -void n64_texture_pipe_t::shift_cycle(INT32* S, INT32* T, bool* maxs, bool* maxt, const n64_tile_t& tile) +rgbaint_t n64_texture_pipe_t::shift_cycle(rgbaint_t& st, const n64_tile_t& tile) { - INT32 sss = (INT32)(INT16)*S; - sss >>= tile.rshift_s; - sss <<= tile.lshift_s; - sss = (INT32)(INT16)sss; - *maxs = ((sss >> 3) >= tile.sh); - *S = (((sss >> 3) - tile.sl) << 3) | (sss & 7); + st.sign_extend(0x00008000, 0xffff8000); + st.sra(tile.rshift); + st.shl(tile.lshift); - INT32 sst = (INT32)(INT16)*T; - sst >>= tile.rshift_t; - sst <<= tile.lshift_t; - *T = (INT32)(INT16)sst; - *maxt = ((*T >> 3) >= tile.th); - *T = (((sst >> 3) - tile.tl) << 3) | (sst & 7); + rgbaint_t maxst(st); + maxst.sra_imm(3); + rgbaint_t maxst_eq(maxst); + maxst.cmpgt(tile.sth); + maxst_eq.cmpeq(tile.sth); + maxst.or_reg(maxst_eq); + + rgbaint_t stlsb(st); + stlsb.and_imm(7); + + st.sra_imm(3); + st.sub(tile.stl); + st.shl_imm(3); + st.or_reg(stlsb); + + return maxst; } -void n64_texture_pipe_t::shift_copy(INT32* S, INT32* T, const n64_tile_t& tile) +inline void n64_texture_pipe_t::shift_copy(rgbaint_t& st, const n64_tile_t& tile) { - INT32 sss = (INT32)(INT16)*S; - sss >>= tile.rshift_s; - sss <<= tile.lshift_s; - *S = (INT32)(INT16)sss; - - INT32 sst = (INT32)(INT16)*T; - sst >>= tile.rshift_t; - sst <<= tile.lshift_t; - *T = (INT32)(INT16)sst; + st.shr(tile.rshift); + st.shl(tile.lshift); } -void n64_texture_pipe_t::clamp_cycle(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, const bool maxs, const bool maxt, const INT32 tilenum, const n64_tile_t& tile, rdp_span_aux* userdata) +void n64_texture_pipe_t::clamp_cycle(rgbaint_t& st, rgbaint_t& stfrac, rgbaint_t& maxst, const INT32 tilenum, const n64_tile_t& tile, rdp_span_aux* userdata) { - if (tile.clamp_s) - { - if (*S & 0x10000) - { - *S = 0; - *SFRAC = 0; - } - else if (maxs) - { - *S = userdata->m_clamp_s_diff[tilenum]; - *SFRAC = 0; - } - else - { - *S = (SIGN17(*S) >> 5) & 0x1fff; - } - } - else - { - *S = (SIGN17(*S) >> 5) & 0x1fff; - } + rgbaint_t not_clamp(tile.clamp_st); + not_clamp.xor_imm(0xffffffff); - if (tile.clamp_t) - { - if (*T & 0x10000) - { - *T = 0; - *TFRAC = 0; - } - else if (maxt) - { - *T = userdata->m_clamp_t_diff[tilenum]; - *TFRAC = 0; - } - else - { - *T = (SIGN17(*T) >> 5) & 0x1fff; - } - } - else - { - *T = (SIGN17(*T) >> 5) & 0x1fff; - } + rgbaint_t highbit_mask(0x10000, 0x10000, 0x10000, 0x10000); + rgbaint_t highbit(st); + highbit.and_reg(highbit_mask); + highbit.cmpeq(highbit_mask); + + rgbaint_t not_highbit(highbit); + not_highbit.xor_imm(0xffffffff); + + rgbaint_t not_maxst(maxst); + not_maxst.xor_imm(0xffffffff); + not_maxst.and_reg(not_highbit); + not_maxst.or_reg(not_clamp); + + rgbaint_t shifted_st(st); + shifted_st.sign_extend(0x00010000, 0xffff0000); + shifted_st.shr_imm(5); + shifted_st.and_imm(0x1fff); + shifted_st.and_reg(not_maxst); + stfrac.and_reg(not_maxst); + + rgbaint_t clamp_diff(userdata->m_clamp_diff[tilenum]); + clamp_diff.and_reg(tile.clamp_st); + clamp_diff.and_reg(maxst); + + st.set(shifted_st); + st.or_reg(clamp_diff); } -void n64_texture_pipe_t::clamp_cycle_light(INT32* S, INT32* T, const bool maxs, const bool maxt, const INT32 tilenum, const n64_tile_t& tile, rdp_span_aux* userdata) +void n64_texture_pipe_t::clamp_cycle_light(rgbaint_t& st, rgbaint_t& maxst, const INT32 tilenum, const n64_tile_t& tile, rdp_span_aux* userdata) { - if (tile.clamp_s) - { - if (*S & 0x10000) - { - *S = 0; - } - else if (maxs) - { - *S = userdata->m_clamp_s_diff[tilenum]; - } - else - { - *S = (SIGN17(*S) >> 5) & 0x1fff; - } - } - else - { - *S = (SIGN17(*S) >> 5) & 0x1fff; - } + rgbaint_t not_clamp(tile.clamp_st); + not_clamp.xor_imm(0xffffffff); - if (tile.clamp_t) - { - if (*T & 0x10000) - { - *T = 0; - } - else if (maxt) - { - *T = userdata->m_clamp_t_diff[tilenum]; - } - else - { - *T = (SIGN17(*T) >> 5) & 0x1fff; - } - } - else - { - *T = (SIGN17(*T) >> 5) & 0x1fff; - } + rgbaint_t highbit_mask(0x10000, 0x10000, 0x10000, 0x10000); + rgbaint_t highbit(st); + highbit.and_reg(highbit_mask); + highbit.cmpeq(highbit_mask); + + rgbaint_t not_highbit(highbit); + not_highbit.xor_imm(0xffffffff); + + rgbaint_t not_maxst(maxst); + not_maxst.xor_imm(0xffffffff); + not_maxst.and_reg(not_highbit); + not_maxst.or_reg(not_clamp); + + rgbaint_t shifted_st(st); + shifted_st.sign_extend(0x00010000, 0xffff0000); + shifted_st.shr_imm(5); + shifted_st.and_imm(0x1fff); + shifted_st.and_reg(not_maxst); + + rgbaint_t clamp_diff(userdata->m_clamp_diff[tilenum]); + clamp_diff.and_reg(tile.clamp_st); + clamp_diff.and_reg(maxst); + + st.set(shifted_st); + st.or_reg(clamp_diff); } void n64_texture_pipe_t::cycle_nearest(color_t* TEX, color_t* prev, INT32 SSS, INT32 SST, UINT32 tilenum, UINT32 cycle, rdp_span_aux* userdata, const rdp_poly_state& object) { - // const n64_tile_t* tiles = object.m_tiles; const n64_tile_t& tile = object.m_tiles[tilenum]; - const UINT32 tformat = tile.format; - const UINT32 tsize = tile.size; - const UINT32 tpal = tile.palette; - const UINT32 index = (tformat << 4) | (tsize << 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; - INT32 sss1 = SSS, sst1 = SST; - bool maxs, maxt; - shift_cycle(&sss1, &sst1, &maxs, &maxt, tile); - clamp_cycle_light(&sss1, &sst1, maxs, maxt, tilenum, tile, userdata); - mask(&sss1, &sst1, tile); + rgbaint_t st(0, SSS, 0, SST); + rgbaint_t maxst = shift_cycle(st, tile); + clamp_cycle_light(st, maxst, tilenum, tile, userdata); + mask(st, tile); - UINT32 tbase = tile.tmem + ((tile.line * sst1) & 0x1ff); + UINT32 tbase = tile.tmem + ((tile.line * st.get_b()) & 0x1ff); - color_t t0 = ((this)->*(m_texel_fetch[index]))(sss1, sst1, tbase, tpal, userdata); - - const INT32 newk0 = SIGN9(m_rdp->get_k0()); - const INT32 newk1 = SIGN9(m_rdp->get_k1()); - const INT32 newk2 = SIGN9(m_rdp->get_k2()); - const INT32 newk3 = SIGN9(m_rdp->get_k3()); - const INT32 invk0 = ~newk0; - const INT32 invk1 = ~newk1; - const INT32 invk2 = ~newk2; - const INT32 invk3 = ~newk3; + rgbaint_t t0; + ((this)->*(m_texel_fetch[index]))(t0, st.get_r(), st.get_b(), tbase, tile.palette, userdata); if (object.m_other_modes.convert_one && cycle) { - t0 = *prev; + t0.set(*prev); } t0.sign_extend(0x00000100, 0xffffff00); - const UINT32 r = t0.get_r(); - const UINT32 g = t0.get_g(); - TEX->set_rgba(0, (newk0 - invk0) * g + 0x80, (newk1 - invk1) * r + (newk2 - invk2) * g + 0x80, (newk3 - invk3) * g + 0x80); - TEX->shr(8); + rgbaint_t k1r(m_rdp->get_k1()); + k1r.mul_imm(t0.get_r()); + + TEX->set(m_rdp->get_k023()); + TEX->mul_imm(t0.get_g()); + TEX->add(k1r); + TEX->add_imm(0x80); + TEX->shr_imm(8); TEX->add_imm(t0.get_b()); TEX->and_imm(0x1ff); } void n64_texture_pipe_t::cycle_nearest_lerp(color_t* TEX, color_t* prev, INT32 SSS, INT32 SST, UINT32 tilenum, UINT32 cycle, rdp_span_aux* userdata, const rdp_poly_state& object) { - const n64_tile_t* tiles = object.m_tiles; - const n64_tile_t& tile = tiles[tilenum]; - const UINT32 tformat = tile.format; - const UINT32 tsize = tile.size; - const UINT32 tpal = tile.palette; - const UINT32 index = (tformat << 4) | (tsize << 2) | ((UINT32) object.m_other_modes.en_tlut << 1) | (UINT32) object.m_other_modes.tlut_type; + const n64_tile_t& tile = object.m_tiles[tilenum]; + const UINT32 index = (tile.format << 4) | (tile.size << 2) | ((UINT32) object.m_other_modes.en_tlut << 1) | (UINT32) object.m_other_modes.tlut_type; - color_t t0; + rgbaint_t st(0, SSS, 0, SST); + rgbaint_t maxst = shift_cycle(st, tile); + clamp_cycle_light(st, maxst, tilenum, tile, userdata); + mask(st, tile); - INT32 sss1 = SSS, sst1 = SST; - bool maxs, maxt; - shift_cycle(&sss1, &sst1, &maxs, &maxt, tile); - clamp_cycle_light(&sss1, &sst1, maxs, maxt, tilenum, tile, userdata); - mask(&sss1, &sst1, tile); + UINT32 tbase = tile.tmem + ((tile.line * st.get_b()) & 0x1ff); - UINT32 tbase = tile.tmem + ((tile.line * sst1) & 0x1ff); - - *TEX = ((this)->*(m_texel_fetch[index]))(sss1, sst1, tbase, tpal, userdata); + ((this)->*(m_texel_fetch[index]))(*TEX, st.get_r(), st.get_b(), 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) { - const n64_tile_t* tiles = object.m_tiles; - const n64_tile_t& tile = tiles[tilenum]; - - const UINT32 tpal = tile.palette; + const n64_tile_t& tile = object.m_tiles[tilenum]; const UINT32 index = (tile.format << 4) | (tile.size << 2) | ((UINT32) object.m_other_modes.en_tlut << 1) | (UINT32) object.m_other_modes.tlut_type; - INT32 sss1 = SSS, sst1 = SST; - bool maxs, maxt; - shift_cycle(&sss1, &sst1, &maxs, &maxt, tile); + rgbaint_t st1(0, SSS, 0, SST); + rgbaint_t maxst = shift_cycle(st1, tile); + rgbaint_t stfrac(st1); + stfrac.and_imm(0x1f); - INT32 sfrac = sss1 & 0x1f; - INT32 tfrac = sst1 & 0x1f; + clamp_cycle(st1, stfrac, maxst, tilenum, tile, userdata); - clamp_cycle(&sss1, &sst1, &sfrac, &tfrac, maxs, maxt, tilenum, tile, userdata); + rgbaint_t sstt(st1); + sstt.add(m_st2_add); + sstt.shl_imm_all(32); + sstt.or_reg(st1); - INT32 sss2 = sss1 + 1; - INT32 sst2 = sst1 + 1; + mask_coupled(sstt, tile); - mask_coupled(&sss1, &sss2, &sst1, &sst2, tile); + const UINT32 tbase = tile.tmem + ((tile.line * st1.get_b()) & 0x1ff); - const UINT32 tbase = tile.tmem + ((tile.line * sst1) & 0x1ff); + bool upper = ((stfrac.get_r() + stfrac.get_b()) >= 0x20); - bool upper = ((sfrac + tfrac) >= 0x20); - - INT32 invsf = 0; - INT32 invtf = 0; + rgbaint_t invstf(0); if (upper) { - invsf = 0x20 - sfrac; - invsf <<= 3; - - invtf = 0x20 - tfrac; - invtf <<= 3; + invstf.set(stfrac); + invstf.subr_imm(0x20); + invstf.shl_imm(3); } - sfrac <<= 3; - tfrac <<= 3; + stfrac.shl_imm(3); - color_t t0 = ((this)->*(m_texel_fetch[index]))(sss1, sst1, tbase, tpal, userdata); - const INT32 newk0 = SIGN9(m_rdp->get_k0()); - const INT32 newk1 = SIGN9(m_rdp->get_k1()); - const INT32 newk2 = SIGN9(m_rdp->get_k2()); - const INT32 newk3 = SIGN9(m_rdp->get_k3()); - const INT32 invk0 = ~newk0; - const INT32 invk1 = ~newk1; - const INT32 invk2 = ~newk2; - const INT32 invk3 = ~newk3; + rgbaint_t t0; + ((this)->*(m_texel_fetch[index]))(t0, st1.get_r(), st1.get_b(), tbase, tile.palette, userdata); if (object.m_other_modes.convert_one && cycle) { - t0 = *prev; + t0.set(*prev); } t0.sign_extend(0x00000100, 0xffffff00); - const UINT32 r = t0.get_r(); - const UINT32 g = t0.get_g(); - TEX->set_rgba(0, (newk0 - invk0) * g + 0x80, (newk1 - invk1) * r + (newk2 - invk2) * g + 0x80, (newk3 - invk3) * g + 0x80); - TEX->shr(8); + rgbaint_t k1r(m_rdp->get_k1()); + k1r.mul_imm(t0.get_r()); + + TEX->set(m_rdp->get_k023()); + TEX->mul_imm(t0.get_g()); + TEX->add(k1r); + TEX->add_imm(0x80); + TEX->shr_imm(8); TEX->add_imm(t0.get_b()); TEX->and_imm(0x1ff); } void n64_texture_pipe_t::cycle_linear_lerp(color_t* TEX, color_t* prev, INT32 SSS, INT32 SST, UINT32 tilenum, UINT32 cycle, rdp_span_aux* userdata, const rdp_poly_state& object) { - const n64_tile_t* tiles = object.m_tiles; - const n64_tile_t& tile = tiles[tilenum]; + const n64_tile_t& tile = object.m_tiles[tilenum]; UINT32 tpal = tile.palette; UINT32 index = (tile.format << 4) | (tile.size << 2) | ((UINT32) object.m_other_modes.en_tlut << 1) | (UINT32) object.m_other_modes.tlut_type; - INT32 sss1 = SSS, sst1 = SST; - printf("%08x %08x ", sss1, sst1); - bool maxs, maxt; - shift_cycle(&sss1, &sst1, &maxs, &maxt, tile); - printf("%08x %08x %d %d ", sss1, sst1, maxs ? 255 : 0, maxt ? 255 : 0); + rgbaint_t st1(0, SSS, 0, SST); + rgbaint_t maxst = shift_cycle(st1, tile); + rgbaint_t stfrac = st1; + stfrac.and_imm(0x1f); - INT32 sfrac = sss1 & 0x1f; - INT32 tfrac = sst1 & 0x1f; + clamp_cycle(st1, stfrac, maxst, tilenum, tile, userdata); - printf("%d %d ", sfrac, tfrac); + rgbaint_t sstt(st1); + sstt.add(m_st2_add); + sstt.shl_imm_all(32); + sstt.or_reg(st1); - clamp_cycle(&sss1, &sst1, &sfrac, &tfrac, maxs, maxt, tilenum, tile, userdata); + mask_coupled(sstt, tile); - printf("%08x %08x %d %d ", sss1, sst1, sfrac, tfrac); + const UINT32 tbase1 = tile.tmem + ((tile.line * sstt.get_b32()) & 0x1ff); + const UINT32 tbase2 = tile.tmem + ((tile.line * sstt.get_g32()) & 0x1ff); - INT32 sss2 = sss1 + 1; - INT32 sst2 = sst1 + 1; + bool upper = ((stfrac.get_r32() + stfrac.get_b32()) >= 0x20); - mask_coupled(&sss1, &sss2, &sst1, &sst2, tile); - printf("%08x %08x %08x %08x ", sss1, sst1, sss2, sst2); - - const UINT32 tbase1 = tile.tmem + ((tile.line * sst1) & 0x1ff); - const UINT32 tbase2 = tile.tmem + ((tile.line * sst2) & 0x1ff); - - bool upper = ((sfrac + tfrac) >= 0x20); - - INT32 invsf = 0; - INT32 invtf = 0; + rgbaint_t invstf(0); if (upper) { - invsf = 0x20 - sfrac; - invsf <<= 3; - - invtf = 0x20 - tfrac; - invtf <<= 3; + invstf.set(stfrac); + invstf.subr_imm(0x20); + invstf.shl_imm(3); } - INT32 center = (sfrac == 0x10) && (tfrac == 0x10) && object.m_other_modes.mid_texel; + stfrac.shl_imm(3); - sfrac <<= 3; - tfrac <<= 3; + bool center = (stfrac.get_r() == 0x10) && (stfrac.get_b() == 0x10) && object.m_other_modes.mid_texel; - printf("%d %d %d %d\n", sfrac, tfrac, invsf, invtf); + rgbaint_t t2; + ((this)->*(m_texel_fetch[index]))(*TEX, sstt.get_a(), sstt.get_b(), tbase1, tpal, userdata); + ((this)->*(m_texel_fetch[index]))(t2, sstt.get_r(), sstt.get_g(), tbase2, tpal, userdata); if (!center) { if (upper) { - rgbaint_t v1_vec = ((this)->*(m_texel_fetch[index]))(sss2, sst1, tbase1, tpal, userdata); - rgbaint_t v2_vec = ((this)->*(m_texel_fetch[index]))(sss1, sst2, tbase2, tpal, userdata); - rgbaint_t v3_vec = ((this)->*(m_texel_fetch[index]))(sss2, sst2, tbase2, tpal, userdata); + rgbaint_t t3; + ((this)->*(m_texel_fetch[index]))(t3, sstt.get_a(), sstt.get_g(), tbase2, tpal, userdata); - v1_vec.sub(v3_vec); - v2_vec.sub(v3_vec); + TEX->sub(t3); + t2.sub(t3); - v1_vec.mul_imm(invtf); - v2_vec.mul_imm(invsf); + TEX->mul_imm(invstf.get_b()); + t2.mul_imm(invstf.get_r()); - v1_vec.add(v2_vec); - v1_vec.add_imm(0x0080); - v1_vec.sra(8); - v1_vec.add(v3_vec); - - *TEX = v1_vec; + TEX->add(t2); + TEX->add_imm(0x0080); + TEX->sra_imm(8); + TEX->add(t3); } else { - rgbaint_t v0_vec = ((this)->*(m_texel_fetch[index]))(sss1, sst1, tbase1, tpal, userdata); - rgbaint_t v1_vec = ((this)->*(m_texel_fetch[index]))(sss2, sst1, tbase1, tpal, userdata); - rgbaint_t v2_vec = ((this)->*(m_texel_fetch[index]))(sss1, sst2, tbase2, tpal, userdata); + rgbaint_t t0; + ((this)->*(m_texel_fetch[index]))(t0, sstt.get_r(), sstt.get_b(), tbase1, tpal, userdata); - v1_vec.sub(v0_vec); - v2_vec.sub(v0_vec); + TEX->sub(t0); + t2.sub(t0); - v1_vec.mul_imm(sfrac); - v2_vec.mul_imm(tfrac); + TEX->mul_imm(stfrac.get_r()); + t2.mul_imm(stfrac.get_b()); - v1_vec.add(v2_vec); - v1_vec.add_imm(0x0080); - v1_vec.sra(8); - v1_vec.add(v0_vec); - - *TEX = v1_vec; + TEX->add(t2); + TEX->add_imm(0x80); + TEX->sra_imm(8); + TEX->add(t0); } } else { - rgbaint_t t0_vec((rgbaint_t)((this)->*(m_texel_fetch[index]))(sss1, sst1, tbase1, tpal, userdata)); - - t0_vec.add(((this)->*(m_texel_fetch[index]))(sss2, sst1, tbase1, tpal, userdata)); - t0_vec.add(((this)->*(m_texel_fetch[index]))(sss2, sst2, tbase2, tpal, userdata)); - t0_vec.add(((this)->*(m_texel_fetch[index]))(sss1, sst2, tbase2, tpal, userdata)); - t0_vec.sra(2); - - *TEX = t0_vec; + rgbaint_t t0, t3; + ((this)->*(m_texel_fetch[index]))(t0, sstt.get_r(), sstt.get_b(), tbase1, tpal, userdata); + ((this)->*(m_texel_fetch[index]))(t3, sstt.get_a(), sstt.get_g(), tbase2, tpal, userdata); + TEX->add(t0); + TEX->add(t2); + TEX->add(t3); + TEX->sra(2); } } @@ -491,19 +382,22 @@ void n64_texture_pipe_t::copy(color_t* TEX, INT32 SSS, INT32 SST, UINT32 tilenum const n64_tile_t* tiles = object.m_tiles; const n64_tile_t& tile = tiles[tilenum]; - INT32 sss1 = SSS; - INT32 sst1 = SST; - shift_copy(&sss1, &sst1, tile); - sss1 = (((sss1 >> 3) - tile.sl) << 3) | (sss1 & 7); - sss1 = (SIGN17(sss1) >> 5) & 0x1fff; - - sst1 = (((sst1 >> 3) - tile.tl) << 3) | (sst1 & 7); - sst1 = (SIGN17(sst1) >> 5) & 0x1fff; - mask(&sss1, &sst1, tile); + rgbaint_t st(0, SSS, 0, SST); + shift_copy(st, tile); + rgbaint_t stlsb(st); + stlsb.and_imm(7); + st.shr_imm(3); + st.sub(rgbaint_t(0, tile.sl, 0, tile.tl)); + st.shl_imm(3); + st.add(stlsb); + st.sign_extend(0x00010000, 0xffff0000); + st.shr_imm(5); + st.and_imm(0x1fff); + 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 tbase = tile.tmem + ((tile.line * sst1) & 0x1ff); - *TEX = ((this)->*(m_texel_fetch[index]))(sss1, sst1, tbase, tile.palette, userdata); + const UINT32 tbase = tile.tmem + ((tile.line * st.get_b()) & 0x1ff); + ((this)->*(m_texel_fetch[index]))(*TEX, st.get_r(), st.get_b(), 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) @@ -772,24 +666,20 @@ void n64_texture_pipe_t::calculate_clamp_diffs(UINT32 prim_tile, rdp_span_aux* u { for (INT32 start = 0; start <= 7; start++) { - userdata->m_clamp_s_diff[start] = (tiles[start].sh >> 2) - (tiles[start].sl >> 2); - userdata->m_clamp_t_diff[start] = (tiles[start].th >> 2) - (tiles[start].tl >> 2); + 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)); } } else { const INT32 start = prim_tile; const INT32 end = (prim_tile + 1) & 7; - userdata->m_clamp_s_diff[start] = (tiles[start].sh >> 2) - (tiles[start].sl >> 2); - userdata->m_clamp_t_diff[start] = (tiles[start].th >> 2) - (tiles[start].tl >> 2); - userdata->m_clamp_s_diff[end] = (tiles[end].sh >> 2) - (tiles[end].sl >> 2); - userdata->m_clamp_t_diff[end] = (tiles[end].th >> 2) - (tiles[end].tl >> 2); + 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[end].set_rgba(0, (tiles[end].sh >> 2) - (tiles[end].sl >> 2), 0, (tiles[end].th >> 2) - (tiles[end].tl >> 2)); } } else//1-cycle or copy { - userdata->m_clamp_s_diff[prim_tile] = (tiles[prim_tile].sh >> 2) - (tiles[prim_tile].sl >> 2); - userdata->m_clamp_t_diff[prim_tile] = (tiles[prim_tile].th >> 2) - (tiles[prim_tile].tl >> 2); + 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)); } } @@ -798,7 +688,7 @@ void n64_texture_pipe_t::calculate_clamp_diffs(UINT32 prim_tile, rdp_span_aux* u static INT32 sTexAddrSwap16[2] = { WORD_ADDR_XOR, WORD_XOR_DWORD_SWAP }; static INT32 sTexAddrSwap8[2] = { BYTE_ADDR_XOR, BYTE_XOR_DWORD_SWAP }; -color_t n64_texture_pipe_t::fetch_rgba16_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_rgba16_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { INT32 taddr = (((tbase << 2) + s) ^ sTexAddrSwap16[t & 1]) & 0x7ff; @@ -806,13 +696,13 @@ color_t n64_texture_pipe_t::fetch_rgba16_tlut0(INT32 s, INT32 t, INT32 tbase, IN c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 8) << 2]; #if USE_64K_LUT - return m_expand_16to32_table[c]; + out.set(m_expand_16to32_table[c]); #else - return color_t((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); + out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); #endif } -color_t n64_texture_pipe_t::fetch_rgba16_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_rgba16_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const INT32 taddr = (((tbase << 2) + s) ^ sTexAddrSwap16[t & 1]) & 0x7ff; @@ -820,22 +710,23 @@ color_t n64_texture_pipe_t::fetch_rgba16_tlut1(INT32 s, INT32 t, INT32 tbase, IN c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 8) << 2]; const UINT8 k = (c >> 8) & 0xff; - return color_t(c & 0xff, k, k, k); + out.set_rgba(c & 0xff, k, k, k); } -color_t n64_texture_pipe_t::fetch_rgba16_raw(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) { const INT32 taddr = (((tbase << 2) + s) ^ sTexAddrSwap16[t & 1]) & 0x7ff; -#if USE_64K_LUT - return m_expand_16to32_table[((UINT16*)userdata->m_tmem)[taddr]]; -#else const UINT16 c = ((UINT16*)userdata->m_tmem)[taddr]; - return color_t((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); + +#if USE_64K_LUT + out.set(m_expand_16to32_table[c]); +#else + out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); #endif } -color_t n64_texture_pipe_t::fetch_rgba32_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_rgba32_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const UINT32 *tc = ((UINT32*)userdata->m_tmem); const INT32 taddr = (((tbase << 2) + s) ^ sTexAddrSwap16[t & 1]) & 0x3ff; @@ -844,13 +735,13 @@ color_t n64_texture_pipe_t::fetch_rgba32_tlut0(INT32 s, INT32 t, INT32 tbase, IN c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 24) << 2]; #if USE_64K_LUT - return m_expand_16to32_table[c]; + out.set(m_expand_16to32_table[c]); #else - return color_t((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); + out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); #endif } -color_t n64_texture_pipe_t::fetch_rgba32_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_rgba32_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const UINT32 *tc = ((UINT32*)userdata->m_tmem); const INT32 taddr = (((tbase << 2) + s) ^ sTexAddrSwap16[t & 1]) & 0x3ff; @@ -859,23 +750,22 @@ color_t n64_texture_pipe_t::fetch_rgba32_tlut1(INT32 s, INT32 t, INT32 tbase, IN c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 24) << 2]; const UINT8 k = (c >> 8) & 0xff; - return color_t(c & 0xff, k, k, k); + out.set_rgba(c & 0xff, k, k, k); } -color_t n64_texture_pipe_t::fetch_rgba32_raw(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) { const INT32 taddr = (((tbase << 2) + s) ^ sTexAddrSwap16[t & 1]) & 0x3ff; const UINT16 cl = ((UINT16*)userdata->m_tmem)[taddr]; const UINT16 ch = ((UINT16*)userdata->m_tmem)[taddr | 0x400]; - color_t val = color_t(ch & 0xff, cl >> 8, cl & 0xff, ch >> 8); - return val; + out.set_rgba(ch & 0xff, cl >> 8, cl & 0xff, ch >> 8); } -color_t n64_texture_pipe_t::fetch_nop(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { return 0; } +void n64_texture_pipe_t::fetch_nop(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { } -color_t n64_texture_pipe_t::fetch_yuv(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_yuv(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const UINT16 *tc = ((UINT16*)userdata->m_tmem); @@ -892,10 +782,10 @@ color_t n64_texture_pipe_t::fetch_yuv(INT32 s, INT32 t, INT32 tbase, INT32 tpal, u |= ((u & 0x80) << 1); v |= ((v & 0x80) << 1); - return color_t(y, y, u, v); + out.set_rgba(y, y, u, v); } -color_t n64_texture_pipe_t::fetch_ci4_tlut0(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = ((((tbase << 4) + s) >> 1) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -904,13 +794,13 @@ color_t n64_texture_pipe_t::fetch_ci4_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | p) << 2]; #if USE_64K_LUT - return m_expand_16to32_table[c]; + out.set(m_expand_16to32_table[c]); #else - return color_t((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); + out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); #endif } -color_t n64_texture_pipe_t::fetch_ci4_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_ci4_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const UINT8 *tc = userdata->m_tmem; INT32 taddr = ((((tbase << 4) + s) >> 1) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -919,10 +809,10 @@ color_t n64_texture_pipe_t::fetch_ci4_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | p) << 2]; const UINT8 k = (c >> 8) & 0xff; - return color_t(c & 0xff, k, k, k); + out.set_rgba(c & 0xff, k, k, k); } -color_t n64_texture_pipe_t::fetch_ci4_raw(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = ((((tbase << 4) + s) >> 1) ^ sTexAddrSwap8[t & 1]) & 0xfff; @@ -930,10 +820,10 @@ color_t n64_texture_pipe_t::fetch_ci4_raw(INT32 s, INT32 t, INT32 tbase, INT32 t UINT8 p = (s & 1) ? (tc[taddr] & 0xf) : (tc[taddr] >> 4); p = (tpal << 4) | p; - return color_t(p, p, p, p); + out.set_rgba(p, p, p, p); } -color_t n64_texture_pipe_t::fetch_ci8_tlut0(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -942,13 +832,13 @@ color_t n64_texture_pipe_t::fetch_ci8_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[p << 2]; #if USE_64K_LUT - return m_expand_16to32_table[c]; + out.set(m_expand_16to32_table[c]); #else - return color_t((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); + out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); #endif } -color_t n64_texture_pipe_t::fetch_ci8_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_ci8_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -957,19 +847,19 @@ color_t n64_texture_pipe_t::fetch_ci8_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[p << 2]; const UINT8 k = (c >> 8) & 0xff; - return color_t(c & 0xff, k, k, k); + out.set_rgba(c & 0xff, k, k, k); } -color_t n64_texture_pipe_t::fetch_ci8_raw(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0xfff; const UINT8 p = tc[taddr]; - return color_t(p, p, p, p); + out.set_rgba(p, p, p, p); } -color_t n64_texture_pipe_t::fetch_ia4_tlut0(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = ((((tbase << 4) + s) >> 1) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -978,13 +868,13 @@ color_t n64_texture_pipe_t::fetch_ia4_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | p) << 2]; #if USE_64K_LUT - return m_expand_16to32_table[c]; + out.set(m_expand_16to32_table[c]); #else - return color_t((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); + out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); #endif } -color_t n64_texture_pipe_t::fetch_ia4_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_ia4_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = ((((tbase << 4) + s) >> 1) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -993,10 +883,10 @@ color_t n64_texture_pipe_t::fetch_ia4_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | p) << 2]; const UINT8 k = (c >> 8) & 0xff; - return color_t(c & 0xff, k, k, k); + out.set_rgba(c & 0xff, k, k, k); } -color_t n64_texture_pipe_t::fetch_ia4_raw(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = ((((tbase << 4) + s) >> 1) ^ sTexAddrSwap8[t & 1]) & 0xfff; @@ -1005,10 +895,10 @@ color_t n64_texture_pipe_t::fetch_ia4_raw(INT32 s, INT32 t, INT32 tbase, INT32 t UINT8 i = p & 0xe; i = (i << 4) | (i << 1) | (i >> 2); - return color_t((p & 1) * 0xff, i, i, i); + out.set_rgba((p & 1) * 0xff, i, i, i); } -color_t n64_texture_pipe_t::fetch_ia8_tlut0(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -1017,13 +907,13 @@ color_t n64_texture_pipe_t::fetch_ia8_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[p << 2]; #if USE_64K_LUT - return m_expand_16to32_table[c]; + out.set(m_expand_16to32_table[c]); #else - return color_t((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); + out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); #endif } -color_t n64_texture_pipe_t::fetch_ia8_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_ia8_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -1032,10 +922,10 @@ color_t n64_texture_pipe_t::fetch_ia8_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 c = ((UINT16*)(userdata->m_tmem + 0x800))[p << 2]; const UINT8 k = (c >> 8) & 0xff; - return color_t(c & 0xff, k, k, k); + out.set_rgba(c & 0xff, k, k, k); } -color_t n64_texture_pipe_t::fetch_ia8_raw(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0xfff; @@ -1044,10 +934,10 @@ color_t n64_texture_pipe_t::fetch_ia8_raw(INT32 s, INT32 t, INT32 tbase, INT32 t UINT8 i = p & 0xf0; i |= (i >> 4); - return color_t((p << 4) | (p & 0xf), i, i, i); + out.set_rgba((p << 4) | (p & 0xf), i, i, i); } -color_t n64_texture_pipe_t::fetch_ia16_tlut0(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) { const UINT16 *tc = ((UINT16*)userdata->m_tmem); const INT32 taddr = (((tbase << 2) + s) ^ sTexAddrSwap16[t & 1]) & 0x3ff; @@ -1056,13 +946,13 @@ color_t n64_texture_pipe_t::fetch_ia16_tlut0(INT32 s, INT32 t, INT32 tbase, INT3 c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 8) << 2]; #if USE_64K_LUT - return m_expand_16to32_table[c]; + out.set(m_expand_16to32_table[c]); #else - return color_t((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); + out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); #endif } -color_t n64_texture_pipe_t::fetch_ia16_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_ia16_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const UINT16 *tc = ((UINT16*)userdata->m_tmem); const INT32 taddr = (((tbase << 2) + s) ^ sTexAddrSwap16[t & 1]) & 0x3ff; @@ -1071,20 +961,20 @@ color_t n64_texture_pipe_t::fetch_ia16_tlut1(INT32 s, INT32 t, INT32 tbase, INT3 c = ((UINT16*)(userdata->m_tmem + 0x800))[(c >> 8) << 2]; const UINT8 k = (c >> 8) & 0xff; - return color_t(c & 0xff, k, k, k); + out.set_rgba(c & 0xff, k, k, k); } -color_t n64_texture_pipe_t::fetch_ia16_raw(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) { const UINT16 *tc = ((UINT16*)userdata->m_tmem); const INT32 taddr = (((tbase << 2) + s) ^ sTexAddrSwap16[t & 1]) & 0x7ff; const UINT16 c = tc[taddr]; const UINT8 i = (c >> 8); - return color_t(c & 0xff, i, i, i); + out.set_rgba(c & 0xff, i, i, i); } -color_t n64_texture_pipe_t::fetch_i4_tlut0(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = ((((tbase << 4) + s) >> 1) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -1094,13 +984,13 @@ color_t n64_texture_pipe_t::fetch_i4_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 k = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | c) << 2]; #if USE_64K_LUT - return m_expand_16to32_table[k]; + out.set(m_expand_16to32_table[k]); #else - return color_t((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); + out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); #endif } -color_t n64_texture_pipe_t::fetch_i4_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_i4_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = ((((tbase << 4) + s) >> 1) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -1110,10 +1000,10 @@ color_t n64_texture_pipe_t::fetch_i4_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 k = ((UINT16*)(userdata->m_tmem + 0x800))[((tpal << 4) | c) << 2]; const UINT8 i = (k >> 8) & 0xff; - return color_t(k & 0xff, i, i, i); + out.set_rgba(k & 0xff, i, i, i); } -color_t n64_texture_pipe_t::fetch_i4_raw(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = ((((tbase << 4) + s) >> 1) ^ sTexAddrSwap8[t & 1]) & 0xfff; @@ -1122,10 +1012,10 @@ color_t n64_texture_pipe_t::fetch_i4_raw(INT32 s, INT32 t, INT32 tbase, INT32 tp UINT8 c = ((s & 1)) ? (byteval & 0xf) : ((byteval >> 4) & 0xf); c |= (c << 4); - return color_t(c, c, c, c); + out.set_rgba(c, c, c, c); } -color_t n64_texture_pipe_t::fetch_i8_tlut0(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -1134,13 +1024,13 @@ color_t n64_texture_pipe_t::fetch_i8_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 k = ((UINT16*)(userdata->m_tmem + 0x800))[c << 2]; #if USE_64K_LUT - return m_expand_16to32_table[k]; + out.set(m_expand_16to32_table[k]); #else - return color_t((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); + out.set_rgba((c & 1) * 0xff, GET_HI_RGBA16_TMEM(c), GET_MED_RGBA16_TMEM(c), GET_LOW_RGBA16_TMEM(c)); #endif } -color_t n64_texture_pipe_t::fetch_i8_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) +void n64_texture_pipe_t::fetch_i8_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0x7ff; @@ -1149,15 +1039,15 @@ color_t n64_texture_pipe_t::fetch_i8_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 const UINT16 k = ((UINT16*)(userdata->m_tmem + 0x800))[c << 2]; const UINT8 i = (k >> 8) & 0xff; - return color_t(k & 0xff, i, i, i); + out.set_rgba(k & 0xff, i, i, i); } -color_t n64_texture_pipe_t::fetch_i8_raw(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) { const UINT8 *tc = userdata->m_tmem; const INT32 taddr = (((tbase << 3) + s) ^ sTexAddrSwap8[t & 1]) & 0xfff; const UINT8 c = tc[taddr]; - return color_t(c, c, c, c); + out.set_rgba(c, c, c, c); } diff --git a/src/mame/video/rdptpipe.h b/src/mame/video/rdptpipe.h index ded943037d5..4493eb39aa1 100644 --- a/src/mame/video/rdptpipe.h +++ b/src/mame/video/rdptpipe.h @@ -22,12 +22,12 @@ class n64_texture_pipe_t { public: - typedef color_t (n64_texture_pipe_t::*texel_fetcher_t) (INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + typedef void (n64_texture_pipe_t::*texel_fetcher_t) (rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); typedef void (n64_texture_pipe_t::*texel_cycler_t) (color_t* TEX, color_t* prev, INT32 SSS, INT32 SST, UINT32 tilenum, UINT32 cycle, rdp_span_aux* userdata, const rdp_poly_state& object); n64_texture_pipe_t() { - m_maskbits_table[0] = 0x3ff; + m_maskbits_table[0] = ~0; for(int i = 1; i < 16; i++) { m_maskbits_table[i] = ((UINT16)(0xffff) >> (16 - i)) & 0x3ff; @@ -108,49 +108,49 @@ class n64_texture_pipe_t bool m_start_span; private: - void mask(INT32* S, INT32* T, const n64_tile_t& tile); - void mask_coupled(INT32* S, INT32* S1, INT32* T, INT32* T1, const n64_tile_t& tile); + void mask(rgbaint_t& st, const n64_tile_t& tile); + void mask_coupled(rgbaint_t& sstt, const n64_tile_t& tile); - void shift_cycle(INT32* S, INT32* T, bool* maxs, bool* maxt, const n64_tile_t& tile); - void shift_copy(INT32* S, INT32* T, const n64_tile_t& tile); + rgbaint_t shift_cycle(rgbaint_t& st, const n64_tile_t& tile); + void shift_copy(rgbaint_t& st, const n64_tile_t& tile); - void clamp_cycle(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, const bool maxs, const bool maxt, const INT32 tilenum, const n64_tile_t& tile, rdp_span_aux* userdata); - void clamp_cycle_light(INT32* S, INT32* T, const bool maxs, const bool maxt, const INT32 tilenum, const n64_tile_t& tile, rdp_span_aux* userdata); + void clamp_cycle(rgbaint_t& st, rgbaint_t& stfrac, rgbaint_t& maxst, const INT32 tilenum, const n64_tile_t& tile, rdp_span_aux* userdata); + void clamp_cycle_light(rgbaint_t& st, rgbaint_t& maxst, const INT32 tilenum, const n64_tile_t& tile, rdp_span_aux* userdata); - color_t fetch_nop(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_nop(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_rgba16_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_rgba16_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_rgba16_raw(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_rgba32_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_rgba32_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_rgba32_raw(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_rgba16_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_rgba16_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_rgba16_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_rgba32_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_rgba32_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_rgba32_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_yuv(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_yuv(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ci4_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ci4_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ci4_raw(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ci8_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ci8_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ci8_raw(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ci4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ci4_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ci4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ci8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ci8_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ci8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ia4_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ia4_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ia4_raw(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ia8_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ia8_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ia8_raw(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ia16_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ia16_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_ia16_raw(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ia4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ia4_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ia4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ia8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ia8_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ia8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ia16_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ia16_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_ia16_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_i4_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_i4_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_i4_raw(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_i8_tlut0(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_i8_tlut1(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); - color_t fetch_i8_raw(INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_i4_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_i4_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_i4_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_i8_tlut0(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_i8_tlut1(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); + void fetch_i8_raw(rgbaint_t& out, INT32 s, INT32 t, INT32 tbase, INT32 tpal, rdp_span_aux* userdata); texel_fetcher_t m_texel_fetch[16*5]; @@ -159,6 +159,9 @@ class n64_texture_pipe_t INT32 m_maskbits_table[16]; color_t m_expand_16to32_table[0x10000]; UINT16 m_lod_lookup[0x80000]; + + rgbaint_t m_st2_add; + rgbaint_t m_v1; }; #endif // _VIDEO_RDPTEXPIPE_H_