summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Ryan Holtz <rholtz@batcountryentertainment.com>2010-03-11 06:49:53 +0000
committer Ryan Holtz <rholtz@batcountryentertainment.com>2010-03-11 06:49:53 +0000
commit5d5ec72024c2e5907a14cce33d9043c357fda797 (patch)
treec271d3c5a5d0217b7b45571fb06132c7ba6521f5
parent4c0a6f40e752ddfbd7b4c04e545446803afefe8f (diff)
Slightly fixed interrupt handling and added SBIC and MUL opcodes to the Atmel AVR8 core. [Harmony]
Added FJMP/JMPF opcode to the SunPlus u'nSP core. [Segher, Harmony] Performed an initial code cleanup pass on the N64 rendering code to make use of booleans and inline variable instantiation, and removed a number of unused variables that were exposed as a result of the latter. [Harmony]
-rw-r--r--src/emu/cpu/avr8/avr8.c47
-rw-r--r--src/emu/cpu/unsp/unsp.c10
-rw-r--r--src/emu/cpu/unsp/unspdasm.c8
-rw-r--r--src/mame/video/n64.c671
-rw-r--r--src/mame/video/rdpacvg.c10
-rw-r--r--src/mame/video/rdpblend.c16
-rw-r--r--src/mame/video/rdpfb.c168
-rw-r--r--src/mame/video/rdpfetch.c101
-rw-r--r--src/mame/video/rdpfrect.c90
-rw-r--r--src/mame/video/rdpmask.c11
-rw-r--r--src/mame/video/rdpspn16.c116
-rw-r--r--src/mame/video/rdptpipe.c100
-rw-r--r--src/mame/video/rdptrect.c191
-rw-r--r--src/mame/video/rdptri.c621
14 files changed, 943 insertions, 1217 deletions
diff --git a/src/emu/cpu/avr8/avr8.c b/src/emu/cpu/avr8/avr8.c
index 8819bf9cce2..a57130b036b 100644
--- a/src/emu/cpu/avr8/avr8.c
+++ b/src/emu/cpu/avr8/avr8.c
@@ -93,6 +93,28 @@ static void unimplemented_opcode(avr8_state *cpustate, UINT32 op)
/*****************************************************************************/
+INLINE bool avr8_is_long_opcode(UINT16 op)
+{
+ if((op & 0xf000) == 0x9000)
+ {
+ if((op & 0x0f00) < 0x0400)
+ {
+ if((op & 0x000f) == 0x0000)
+ {
+ return true;
+ }
+ }
+ else if((op & 0x0f00) < 0x0600)
+ {
+ if((op & 0x000f) >= 0x000c)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
INLINE UINT8 READ_PRG_8(avr8_state *cpustate, UINT32 address)
{
return memory_read_byte_16le(cpustate->program, address);
@@ -149,10 +171,13 @@ static void avr8_set_irq_line(avr8_state *cpustate, UINT16 vector, int state)
// Horrible hack, not accurate
if(state)
{
- SREG_W(AVR8_SREG_I, 0);
- PUSH(cpustate, (cpustate->pc >> 8) & 0x00ff);
- PUSH(cpustate, cpustate->pc & 0x00ff);
- cpustate->pc = vector;
+ if(SREG_R(AVR8_SREG_I))
+ {
+ SREG_W(AVR8_SREG_I, 0);
+ PUSH(cpustate, (cpustate->pc >> 8) & 0x00ff);
+ PUSH(cpustate, cpustate->pc & 0x00ff);
+ cpustate->pc = vector;
+ }
}
}
@@ -828,8 +853,11 @@ static CPU_EXECUTE( avr8 )
opcycles = 2;
break;
case 0x0900: // SBIC A,b
- //output += sprintf( output, "SBIC 0x%02x, %d", ACONST5(op), RR3(op) );
- unimplemented_opcode(cpustate, op);
+ if(!(READ_IO_8(cpustate, ACONST5(op)) & (1 << RR3(op))))
+ {
+ opcycles += avr8_is_long_opcode(op) ? 2 : 1;
+ cpustate->pc += avr8_is_long_opcode(op) ? 2 : 1;
+ }
break;
case 0x0a00: // SBI A,b
//output += sprintf( output, "SBI 0x%02x, %d", ACONST5(op), RR3(op) );
@@ -844,8 +872,13 @@ static CPU_EXECUTE( avr8 )
case 0x0d00:
case 0x0e00:
case 0x0f00: // MUL Rd,Rr
+ sd = (UINT8)READ_IO_8(cpustate, RD5(op)) * (UINT8)READ_IO_8(cpustate, RR5(op));
+ WRITE_IO_8(cpustate, 1, (sd >> 8) & 0x00ff);
+ WRITE_IO_8(cpustate, 0, sd & 0x00ff);
+ SREG_W(AVR8_SREG_C, (sd & 0x8000) ? 1 : 0);
+ SREG_W(AVR8_SREG_Z, (sd == 0) ? 1 : 0);
+ opcycles = 2;
//output += sprintf( output, "MUL R%d, R%d", RD5(op), RR5(op) );
- unimplemented_opcode(cpustate, op);
break;
}
break;
diff --git a/src/emu/cpu/unsp/unsp.c b/src/emu/cpu/unsp/unsp.c
index 1bacb925c28..ba629b19bde 100644
--- a/src/emu/cpu/unsp/unsp.c
+++ b/src/emu/cpu/unsp/unsp.c
@@ -648,6 +648,16 @@ static CPU_EXECUTE( unsp )
}
break;
+ // Far Jump
+ case 0x2f: case 0x3f: case 0x6f: case 0x7f:
+ if (OPA == 7 && OP1 == 2)
+ {
+ UNSP_REG(PC) = READ16(unsp, UNSP_LPC);
+ UNSP_REG(SR) &= 0xffc0;
+ UNSP_REG(SR) |= OPIMM;
+ }
+ break;
+
// Multiply, Unsigned * Signed
case 0x0f:
if(OPN == 1 && OPA != 7)
diff --git a/src/emu/cpu/unsp/unspdasm.c b/src/emu/cpu/unsp/unspdasm.c
index da23ae83da8..aa591533ea5 100644
--- a/src/emu/cpu/unsp/unspdasm.c
+++ b/src/emu/cpu/unsp/unspdasm.c
@@ -205,6 +205,14 @@ CPU_DISASSEMBLE( unsp )
}
return UNSP_DASM_OK;
+ // Far Jump
+ case 0x2f: case 0x3f: case 0x6f: case 0x7f:
+ if (OPA == 7 && OPA == 2)
+ {
+ print("goto %06x", ((OPIMM << 16) | imm16) << 1);
+ }
+ return UNSP_DASM_OK;
+
// Multiply, Unsigned * Signed
case 0x0f:
if(OPN == 1 && OPA != 7)
diff --git a/src/mame/video/n64.c b/src/mame/video/n64.c
index 13c73c491e4..1d88ccf14e3 100644
--- a/src/mame/video/n64.c
+++ b/src/mame/video/n64.c
@@ -134,18 +134,18 @@ typedef struct
typedef struct
{
int cycle_type;
- int persp_tex_en;
- int detail_tex_en;
- int sharpen_tex_en;
- int tex_lod_en;
- int en_tlut;
- int tlut_type;
- int sample_type;
- int mid_texel;
- int bi_lerp0;
- int bi_lerp1;
- int convert_one;
- int key_en;
+ bool persp_tex_en;
+ bool detail_tex_en;
+ bool sharpen_tex_en;
+ bool tex_lod_en;
+ bool en_tlut;
+ bool tlut_type;
+ bool sample_type;
+ bool mid_texel;
+ bool bi_lerp0;
+ bool bi_lerp1;
+ bool convert_one;
+ bool key_en;
int rgb_dither_sel;
int alpha_dither_sel;
int blend_m1a_0;
@@ -157,19 +157,19 @@ typedef struct
int blend_m2b_0;
int blend_m2b_1;
int tex_edge;
- int force_blend;
- int alpha_cvg_select;
- int cvg_times_alpha;
+ bool force_blend;
+ bool alpha_cvg_select;
+ bool cvg_times_alpha;
int z_mode;
int cvg_dest;
- int color_on_cvg;
- int image_read_en;
- int z_update_en;
- int z_compare_en;
- int antialias_en;
- int z_source_sel;
- int dither_alpha_en;
- int alpha_compare_en;
+ bool color_on_cvg;
+ bool image_read_en;
+ bool z_update_en;
+ bool z_compare_en;
+ bool antialias_en;
+ bool z_source_sel;
+ bool dither_alpha_en;
+ bool alpha_compare_en;
} OTHER_MODES;
/*****************************************************************************/
@@ -318,7 +318,7 @@ INLINE void z_build_com_table(void);
INLINE void z_store(UINT16* zb, UINT8* zhb, UINT32 z, UINT32 deltaz);
INLINE INT32 normalize_dzpix(INT32 sum);
INLINE INT32 CLIP(INT32 value,INT32 min,INT32 max);
-INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UINT8* hbuff, UINT32 hres);
+INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UINT8* hbuff, const UINT32 hres);
INLINE void divot_filter16(UINT8* r, UINT8* g, UINT8* b, UINT16* fbuff, UINT32 fbuff_index);
INLINE void restore_filter16(INT32* r, INT32* g, INT32* b, UINT16* fbuff, UINT32 fbuff_index, UINT32 hres);
INLINE UINT32 getlog2(UINT32 lod_clamp);
@@ -430,12 +430,13 @@ static int special_bsel0, special_bsel1;
VIDEO_START(n64)
{
- int i = 0, j = 0;
UINT8 *normpoint = memory_region(machine, "normpoint");
UINT8 *normslope = memory_region(machine, "normslope");
if (LOG_RDP_EXECUTION)
+ {
rdp_exec = fopen("rdp_execute.txt", "wt");
+ }
TMEM = auto_alloc_array(machine, UINT8, 0x1004); // 4 guard bytes
memset(TMEM, 0, 0x1000);
@@ -446,7 +447,7 @@ VIDEO_START(n64)
one_color.c = 0xffffffff;
zero_color.c = 0;
- for(i = 0; i < (1 << 21); i++)
+ for(int i = 0; i < (1 << 21); i++)
{
INT32 frac = i >> 16;
INT32 left = (i >> 8) & 0x000000ff;
@@ -454,7 +455,7 @@ VIDEO_START(n64)
tex_lerp_lut[i] = (frac*(left - right))>>5;
}
- for(i = 0; i < (1 << 24); i++)
+ for(int i = 0; i < (1 << 24); i++)
{
UINT8 A = (i >> 16) & 0x000000ff;
UINT8 B = (i >> 8) & 0x000000ff;
@@ -462,9 +463,9 @@ VIDEO_START(n64)
cc_lut1[i] = (INT16)((((((INT32)A - (INT32)B) * (INT32)C) + 0x80) >> 8) & 0x0000ffff);
}
- for(i = 0; i < (1 << 16); i++)
+ for(int i = 0; i < (1 << 16); i++)
{
- for(j = 0; j < (1 << 8); j++)
+ for(int j = 0; j < (1 << 8); j++)
{
INT32 temp = (INT32)((INT16)i) + j;
if(temp > 255)
@@ -482,7 +483,7 @@ VIDEO_START(n64)
}
}
- for(i = 0; i < (1 << 16); i++)
+ for(int i = 0; i < (1 << 16); i++)
{
UINT8 r = ((i >> 8) & 0xf8) | (i >> 13);
UINT8 g = ((i >> 3) & 0xf8) | ((i >> 8) & 0x07);
@@ -524,18 +525,18 @@ VIDEO_START(n64)
memset(hidden_bits, 3, 4194304); // Hack / fix for letters in Rayman 2
- for (i = 0; i < 8; i++)
+ for (int i = 0; i < 8; i++)
{
tile[i].num = i;
}
- for (i = 0; i < 256; i++)
+ for (int i = 0; i < 256; i++)
{
gamma_table[i] = sqrt((float)(i << 6));
gamma_table[i] <<= 1;
}
- for (i = 0; i < 0x4000; i++)
+ for (int i = 0; i < 0x4000; i++)
{
gamma_dither_table[i] = sqrt((float)i);
gamma_dither_table[i] <<= 1;
@@ -544,12 +545,12 @@ VIDEO_START(n64)
z_build_com_table();
maskbits_table[0] = 0x3ff;
- for(i = 1; i < 16; i++)
+ for(int i = 1; i < 16; i++)
{
maskbits_table[i] = ((UINT16)(0xffff) >> (16 - i)) & 0x3ff;
}
- for(i = 0; i < 64; i++)
+ for(int i = 0; i < 64; i++)
{
NormPointRom[i] = (normpoint[(i << 1) + 1] << 8) | normpoint[i << 1];
NormSlopeRom[i] = (normslope[(i << 1) + 1] << 8) | normslope[i << 1];
@@ -569,58 +570,46 @@ VIDEO_START(n64)
static void video_update_n64_32(bitmap_t *bitmap)
{
- int i, j;
int gamma = (n64_vi_control >> 3) & 1;
int gamma_dither = (n64_vi_control >> 2) & 1;
//int vibuffering = ((n64_vi_control & 2) && fsaa && divot);
- UINT32 *frame_buffer32;
- UINT16 *frame_buffer;
- UINT32 hb;
- UINT8* hidden_buffer;
-
- int r, g, b;
- int dith = 0;
+ UINT32 *frame_buffer32 = (UINT32*)&rdram[(n64_vi_origin & 0xffffff) >> 2];
- INT32 hdiff = (n64_vi_hstart & 0x3ff) - ((n64_vi_hstart >> 16) & 0x3ff);
- float hcoeff = ((float)(n64_vi_xscale & 0xfff) / (1 << 10));
+ const INT32 hdiff = (n64_vi_hstart & 0x3ff) - ((n64_vi_hstart >> 16) & 0x3ff);
+ const float hcoeff = ((float)(n64_vi_xscale & 0xfff) / (1 << 10));
UINT32 hres = ((float)hdiff * hcoeff);
INT32 invisiblewidth = n64_vi_width - hres;
- INT32 vdiff = ((n64_vi_vstart & 0x3ff) - ((n64_vi_vstart >> 16) & 0x3ff)) >> 1;
- float vcoeff = ((float)(n64_vi_yscale & 0xfff) / (1 << 10));
- UINT32 vres = ((float)vdiff * vcoeff);
+ const INT32 vdiff = ((n64_vi_vstart & 0x3ff) - ((n64_vi_vstart >> 16) & 0x3ff)) >> 1;
+ const float vcoeff = ((float)(n64_vi_yscale & 0xfff) / (1 << 10));
+ const UINT32 vres = ((float)vdiff * vcoeff);
if (vdiff <= 0 || hdiff <= 0)
{
-
return;
}
- frame_buffer = (UINT16*)&rdram[(n64_vi_origin & 0xffffff) >> 2];
- hb = ((n64_vi_origin & 0xffffff) >> 2) >> 1;
- hidden_buffer = &hidden_bits[hb];
-
if (hres > 640) // Needed by Top Gear Overdrive (E)
{
invisiblewidth += (hres - 640);
hres = 640;
}
- frame_buffer32 = (UINT32*)&rdram[(n64_vi_origin & 0xffffff) >> 2];
if (frame_buffer32)
{
- for (j=0; j < vres; j++)
+ for (int j = 0; j < vres; j++)
{
UINT32 *d = BITMAP_ADDR32(bitmap, j, 0);
- for (i=0; i < hres; i++)
+ for (int i = 0; i < hres; i++)
{
UINT32 pix = *frame_buffer32++;
if (gamma || gamma_dither)
{
- r = (pix >> 24) & 0xff;
- g = (pix >> 16) & 0xff;
- b = (pix >> 8) & 0xff;
+ int r = (pix >> 24) & 0xff;
+ int g = (pix >> 16) & 0xff;
+ int b = (pix >> 8) & 0xff;
+ int dith = 0;
if (gamma_dither)
{
dith = rdp_rand() & 0x3f;
@@ -662,10 +651,11 @@ static void video_update_n64_32(bitmap_t *bitmap)
VIDEO_UPDATE(n64)
{
- int i, j;
int fsaa = (((n64_vi_control >> 8) & 3) < 2);
int divot = (n64_vi_control >> 4) & 1;
int height = fb_height;
+ //UINT16 *frame_buffer = (UINT16*)&rdram[(n64_vi_origin & 0xffffff) >> 2];
+ //UINT8 *cvg_buffer = &hidden_bits[((n64_vi_origin & 0xffffff) >> 2) >> 1];
//int vibuffering = ((n64_vi_control & 2) && fsaa && divot);
//vibuffering = 0; // Disabled for now
@@ -681,10 +671,10 @@ VIDEO_UPDATE(n64)
{
UINT16 pix;
pix = frame_buffer[pixels ^ WORD_ADDR_XOR];
- curpixel_cvg = ((pix & 1) << 2) | (hidden_buffer[pixels ^ BYTE_ADDR_XOR] & 3); // Reuse of this variable
+ curpixel_cvg = ((pix & 1) << 2) | (cvg_buffer[pixels ^ BYTE_ADDR_XOR] & 3); // Reuse of this variable
if (curpixel_cvg < 7 && i > 1 && j > 1 && i < (hres - 2) && j < (vres - 2) && fsaa)
{
- newc = video_filter16(&frame_buffer[pixels ^ WORD_ADDR_XOR], &hidden_buffer[pixels ^ BYTE_ADDR_XOR], n64_vi_width);
+ newc = video_filter16(&frame_buffer[pixels ^ WORD_ADDR_XOR], &cvg_buffer[pixels ^ BYTE_ADDR_XOR], n64_vi_width);
ViBuffer[i][j] = newc;
}
else
@@ -704,10 +694,10 @@ VIDEO_UPDATE(n64)
if (n64_vi_blank)
{
- for (j=0; j <height; j++)
+ for (int j = 0; j <height; j++)
{
UINT32 *d = BITMAP_ADDR32(bitmap, j, 0);
- for (i=0; i < fb_width; i++)
+ for (int i = 0; i < fb_width; i++)
{
d[BYTE_XOR_BE(i)] = 0;
}
@@ -949,6 +939,10 @@ static const UINT8 magic_matrix[16] =
/*****************************************************************************/
+#define XOR_SWAP_BYTE_SHIFT 2
+#define XOR_SWAP_WORD_SHIFT 1
+#define XOR_SWAP_DWORD_SHIFT 0
+
#define XOR_SWAP_BYTE 4
#define XOR_SWAP_WORD 2
#define XOR_SWAP_DWORD 1
@@ -980,8 +974,7 @@ INLINE UINT32 z_decompress(UINT16 *zb)
INLINE void z_build_com_table(void) // Thanks to angrylion, Gonetz and Orkin
{
- int j = 0;
- for(j = 0; j < 0x40000; j++)
+ for(int j = 0; j < 0x40000; j++)
{
UINT32 exponent = 0;
UINT32 testbit = 0x20000;
@@ -1000,10 +993,9 @@ INLINE void z_build_com_table(void) // Thanks to angrylion, Gonetz and Orkin
INLINE void z_store(UINT16* zb, UINT8* zhb, UINT32 z, UINT32 deltaz)
{
UINT8 deltazmem = 15;
- int j = 0;
z &= 0x3ffff;
deltaz &= 0xffff;
- for(j = 15; j >= 0; j--)
+ for(int j = 15; j >= 0; j--)
{
if( (deltaz >> j) == 1 )
{
@@ -1083,7 +1075,6 @@ static UINT32 (*z_compare)(void* fb, UINT8* hb, UINT16* zb, UINT8* zhb, UINT32 s
INLINE INT32 normalize_dzpix(INT32 sum)
{
- int count = 0;
if (sum & 0xc000)
{
return 0x8000;
@@ -1092,7 +1083,7 @@ INLINE INT32 normalize_dzpix(INT32 sum)
{
return 1;
}
- for(count = 0x2000; count > 0; count >>= 1)
+ for(int count = 0x2000; count > 0; count >>= 1)
{
if (sum & count)
{
@@ -1118,16 +1109,14 @@ INLINE INT32 CLIP(INT32 value,INT32 min,INT32 max)
}
}
-INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UINT8* hbuff, UINT32 hres)
+INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UINT8* hbuff, const UINT32 hres)
{
+
COLOR penumax, penumin, max, min;
UINT16 pix = *vbuff;
- UINT32 centercvg = (*hbuff & 3) + ((pix & 1) << 2) + 1;
+ const UINT8 centercvg = (*hbuff & 3) + ((pix & 1) << 2) + 1;
UINT32 numoffull = 1;
UINT32 cvg;
- UINT32 r = ((pix >> 8) & 0xf8) | (pix >> 13);
- UINT32 g = ((pix >> 3) & 0xf8) | ((pix >> 8) & 0x07);
- UINT32 b = ((pix << 2) & 0xf8) | ((pix >> 3) & 0x07);
UINT32 backr[7], backg[7], backb[7];
UINT32 invr[7], invg[7], invb[7];
INT32 coeff;
@@ -1136,7 +1125,9 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
INT32 toleft = -2;
UINT32 colr, colg, colb;
UINT32 enb;
- int i = 0;
+ UINT32 r = ((pix >> 8) & 0xf8) | (pix >> 13);
+ UINT32 g = ((pix >> 3) & 0xf8) | ((pix >> 8) & 0x07);
+ UINT32 b = ((pix << 2) & 0xf8) | ((pix >> 3) & 0x07);
*out_r = *out_g = *out_b = 0;
@@ -1155,7 +1146,7 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
return;
}
- for(i = 0; i < 5; i++)
+ for(int i = 0; i < 5; i++)
{
pix = vbuff[leftup ^ WORD_ADDR_XOR];
cvg = hbuff[leftup ^ BYTE_ADDR_XOR] & 3;
@@ -1181,7 +1172,7 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
leftup++;
}
- for(i = 0; i < 5; i++)
+ for(int i = 0; i < 5; i++)
{
pix = vbuff[leftdown ^ WORD_ADDR_XOR];
cvg = hbuff[leftdown ^ BYTE_ADDR_XOR] & 3;
@@ -1207,7 +1198,7 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
leftdown++;
}
- for(i = 0; i < 5; i++)
+ for(int i = 0; i < 5; i++)
{
pix = vbuff[toleft ^ WORD_ADDR_XOR];
cvg = hbuff[toleft ^ BYTE_ADDR_XOR] & 3;
@@ -1234,7 +1225,7 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
}
video_max(&backr[0], &max.i.r, &enb);
- for(i = 1; i < 7; i++)
+ for(int i = 1; i < 7; i++)
{
if (!((enb >> i) & 1))
{
@@ -1242,7 +1233,7 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
}
}
video_max(&backg[0], &max.i.g, &enb);
- for (i = 1; i < 7; i++)
+ for (int i = 1; i < 7; i++)
{
if (!((enb >> i) & 1))
{
@@ -1250,7 +1241,7 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
}
}
video_max(&backb[0], &max.i.b, &enb);
- for (i = 1; i < 7; i++)
+ for (int i = 1; i < 7; i++)
{
if (!((enb >> i) & 1))
{
@@ -1258,7 +1249,7 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
}
}
video_max(&invr[0], &min.i.r, &enb);
- for (i = 1; i < 7; i++)
+ for (int i = 1; i < 7; i++)
{
if (!((enb >> i) & 1))
{
@@ -1266,7 +1257,7 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
}
}
video_max(&invg[0], &min.i.g, &enb);
- for (i = 1; i < 7; i++)
+ for (int i = 1; i < 7; i++)
{
if (!((enb >> i) & 1))
{
@@ -1274,7 +1265,7 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
}
}
video_max(&invb[0], &min.i.b, &enb);
- for (i = 1; i < 7; i++)
+ for (int i = 1; i < 7; i++)
{
if (!((enb >> i) & 1))
{
@@ -1283,28 +1274,22 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
}
video_max(&backr[0], &penumax.i.r, &enb);
- i = ge_two(enb);
- penumax.i.r = i ? max.i.r : penumax.i.r;
+ penumax.i.r = ge_two(enb) ? max.i.r : penumax.i.r;
video_max(&backg[0], &penumax.i.g, &enb);
- i = ge_two(enb);
- penumax.i.g = i ? max.i.g : penumax.i.g;
+ penumax.i.g = ge_two(enb) ? max.i.g : penumax.i.g;
video_max(&backb[0], &penumax.i.b, &enb);
- i = ge_two(enb);
- penumax.i.b = i ? max.i.b : penumax.i.b;
+ penumax.i.b = ge_two(enb) ? max.i.b : penumax.i.b;
video_max(&invr[0], &penumin.i.r, &enb);
- i = ge_two(enb);
- penumin.i.r = i ? min.i.r : penumin.i.r;
+ penumin.i.r = ge_two(enb) ? min.i.r : penumin.i.r;
video_max(&invg[0], &penumin.i.g, &enb);
- i = ge_two(enb);
- penumin.i.g = i ? min.i.g : penumin.i.g;
+ penumin.i.g = ge_two(enb) ? min.i.g : penumin.i.g;
video_max(&invb[0], &penumin.i.b, &enb);
- i = ge_two(enb);
- penumin.i.b = i ? min.i.b : penumin.i.b;
+ penumin.i.b = ge_two(enb) ? min.i.b : penumin.i.b;
penumin.i.r = ~penumin.i.r;
penumin.i.g = ~penumin.i.g;
@@ -1313,7 +1298,7 @@ INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UI
colr = (UINT32)penumin.i.r + (UINT32)penumax.i.r - (r << 1);
colg = (UINT32)penumin.i.g + (UINT32)penumax.i.g - (g << 1);
colb = (UINT32)penumin.i.b + (UINT32)penumax.i.b - (b << 1);
- coeff = 8 - (INT32)centercvg;
+ coeff = 8 - centercvg;
colr = (((colr * coeff) + 4) >> 3) + r;
colg = (((colg * coeff) + 4) >> 3) + g;
colb = (((colb * coeff) + 4) >> 3) + b;
@@ -1373,21 +1358,20 @@ INLINE void divot_filter16(UINT8* r, UINT8* g, UINT8* b, UINT16* fbuff, UINT32 f
INLINE void divot_filter16_buffer(int* r, int* g, int* b, COLOR* vibuffer)
{
- UINT32 leftr, leftg, leftb, rightr, rightg, rightb;
- COLOR leftpix, rightpix, filtered;
- leftpix = vibuffer[-1];
- rightpix = vibuffer[1];
- filtered = *vibuffer;
+ COLOR leftpix = vibuffer[-1];
+ COLOR rightpix = vibuffer[1];
+ COLOR filtered = *vibuffer;
*r = filtered.i.r;
*g = filtered.i.g;
*b = filtered.i.b;
- leftr = leftpix.i.r;
- leftg = leftpix.i.g;
- leftb = leftpix.i.b;
- rightr = rightpix.i.r;
- rightg = rightpix.i.g;
- rightb = rightpix.i.b;
+ UINT32 leftr = leftpix.i.r;
+ UINT32 leftg = leftpix.i.g;
+ UINT32 leftb = leftpix.i.b;
+ UINT32 rightr = rightpix.i.r;
+ UINT32 rightg = rightpix.i.g;
+ UINT32 rightb = rightpix.i.b;
+
if ((leftr >= *r && rightr >= leftr) || (leftr >= rightr && *r >= leftr))
{
*r = leftr; //left = median value
@@ -1624,7 +1608,9 @@ INLINE void video_max(UINT32* Pixels, UINT8* max, UINT32* enb)
temp |= 1;
}
else if (Pixels[0] < Pixels[pos])
+ {
temp |= 1;
+ }
if (Pixels[1] > Pixels[pos])
{
@@ -1632,9 +1618,13 @@ INLINE void video_max(UINT32* Pixels, UINT8* max, UINT32* enb)
pos = 1;
}
else if (Pixels[1] < Pixels[pos])
+ {
temp |= 2;
+ }
else
+ {
pos = 1;
+ }
if (Pixels[2] > Pixels[pos])
{
@@ -1642,9 +1632,13 @@ INLINE void video_max(UINT32* Pixels, UINT8* max, UINT32* enb)
pos = 2;
}
else if (Pixels[2] < Pixels[pos])
+ {
temp |= 4;
+ }
else
+ {
pos = 2;
+ }
if (Pixels[3] > Pixels[pos])
{
@@ -1652,9 +1646,13 @@ INLINE void video_max(UINT32* Pixels, UINT8* max, UINT32* enb)
pos = 3;
}
else if (Pixels[3] < Pixels[pos])
+ {
temp |= 8;
+ }
else
+ {
pos = 3;
+ }
if (Pixels[4] > Pixels[pos])
{
@@ -1662,9 +1660,13 @@ INLINE void video_max(UINT32* Pixels, UINT8* max, UINT32* enb)
pos = 4;
}
else if (Pixels[4] < Pixels[pos])
+ {
temp |= 16;
+ }
else
+ {
pos = 4;
+ }
if (Pixels[5] > Pixels[pos])
{
@@ -1672,9 +1674,13 @@ INLINE void video_max(UINT32* Pixels, UINT8* max, UINT32* enb)
pos = 5;
}
else if (Pixels[5] < Pixels[pos])
+ {
temp |= 32;
+ }
else
+ {
pos = 5;
+ }
if (Pixels[6] > Pixels[pos])
{
@@ -1682,9 +1688,13 @@ INLINE void video_max(UINT32* Pixels, UINT8* max, UINT32* enb)
pos = 6;
}
else if (Pixels[6] < Pixels[pos])
+ {
temp |= 64;
+ }
else
+ {
pos = 6;
+ }
if (Pixels[7] > Pixels[pos])
{
@@ -1692,13 +1702,18 @@ INLINE void video_max(UINT32* Pixels, UINT8* max, UINT32* enb)
pos = 7;
}
else if (Pixels[7] < Pixels[pos])
+ {
temp |= 128;
+ }
else
+ {
pos = 7;
+ }
*enb = temp;
*max = Pixels[pos];
}
+
/*
INLINE void video_max(UINT32* Pixels, UINT8* max, UINT32* enb)
{
@@ -1858,14 +1873,13 @@ INLINE void rgb_dither(INT32* r, INT32* g, INT32* b, int dith)
INLINE UINT32 getlog2(UINT32 lod_clamp)
{
- int i;
if (lod_clamp < 2)
{
return 0;
}
else
{
- for (i = 7; i > 0; i--)
+ for (int i = 7; i > 0; i--)
{
if ((lod_clamp >> i) & 1)
{
@@ -1883,12 +1897,11 @@ INLINE void copy_colors(COLOR* dst, COLOR* src)
INLINE void BILERP_AND_WRITE(UINT32* src0, UINT32* src1, UINT32* dest)
{
- UINT32 r1, g1, b1, col0, col1;
- col0 = *src0;
- col1 = *src1;
- r1 = (((col0 >> 16)&0xff) + ((col1 >> 16)&0xff))>>1;
- g1 = (((col0 >> 8)&0xff) + ((col1 >> 8)&0xff))>>1;
- b1 = (((col0 >> 0)&0xff) + ((col1 >> 0)&0xff))>>1;
+ UINT32 col0 = *src0;
+ UINT32 col1 = *src1;
+ UINT32 r1 = (((col0 >> 16) & 0xff) + ((col1 >> 16) & 0xff))>>1;
+ UINT32 g1 = (((col0 >> 8) & 0xff) + ((col1 >> 8) & 0xff))>>1;
+ UINT32 b1 = (((col0 >> 0) & 0xff) + ((col1 >> 0) & 0xff))>>1;
*dest = (r1 << 16) | (g1 << 8) | b1;
}
@@ -1896,10 +1909,6 @@ INLINE void tcdiv(INT32 ss, INT32 st, INT32 sw, INT32* sss, INT32* sst)
{
int w_carry;
int shift;
- int normout;
- int wnorm;
- int tlu_rcp;
- int shift_value;
if (!(sw & 0x7fff))
{
@@ -1914,10 +1923,10 @@ INLINE void tcdiv(INT32 ss, INT32 st, INT32 sw, INT32* sss, INT32* sst)
for(shift = 1; shift <= 14 && !((sw << shift) & 0x8000); shift++);
shift -= 1;
- normout = ((sw << shift) & 0x3fff) >> 8;
- wnorm = ((sw << shift) & 0xff) << 2;
+ int normout = ((sw << shift) & 0x3fff) >> 8;
+ int wnorm = ((sw << shift) & 0xff) << 2;
- tlu_rcp = ((-(NormSlopeRom[normout] * wnorm)) >> 10) + NormPointRom[normout];
+ int tlu_rcp = ((-(NormSlopeRom[normout] * wnorm)) >> 10) + NormPointRom[normout];
if(shift == 14)
{
@@ -1926,7 +1935,7 @@ INLINE void tcdiv(INT32 ss, INT32 st, INT32 sw, INT32* sss, INT32* sst)
}
else
{
- shift_value = 13 - shift;
+ int shift_value = 13 - shift;
*sss = (SIGN16(ss) * tlu_rcp) >> shift_value;
*sst = (SIGN16(st) * tlu_rcp) >> shift_value;
}
@@ -2084,36 +2093,28 @@ INLINE int BLENDER2_32(UINT32 *fb, COLOR c1, COLOR c2)
static void fill_rectangle_32bit(RECTANGLE *rect)
{
UINT32 *fb = (UINT32*)&rdram[(fb_address / 4)];
- int index, i, j;
- int x1 = rect->xh / 4;
- int x2 = rect->xl / 4;
- int y1 = rect->yh / 4;
- int y2 = rect->yl / 4;
- int clipx1, clipx2, clipy1, clipy2;
+ int x1 = rect->xh;
+ int x2 = rect->xl;
+ int y1 = rect->yh;
+ int y2 = rect->yl;
int fill_cvg = 0;
- // TODO: clip
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
-
// clip
- if (x1 < clipx1)
+ if (x1 < clip.xh)
{
- x1 = clipx1;
+ x1 = clip.xh;
}
- if (y1 < clipy1)
+ if (y1 < clip.yh)
{
- y1 = clipy1;
+ y1 = clip.yh;
}
- if (x2 >= clipx2)
+ if (x2 >= clip.xl)
{
- x2 = clipx2-1;
+ x2 = clip.xl - 1;
}
- if (y2 >= clipy2)
+ if (y2 >= clip.yl)
{
- y2 = clipy2-1;
+ y2 = clip.yl - 1;
}
shade_color.c = 0;
@@ -2122,11 +2123,11 @@ static void fill_rectangle_32bit(RECTANGLE *rect)
if (other_modes.cycle_type == CYCLE_TYPE_FILL)
{
- for (j=y1; j <= y2; j++)
+ for (int j = y1; j <= y2; j++)
{
- index = j * fb_width;
+ int index = j * fb_width;
- for (i=x1; i <= x2; i++)
+ for (int i = x1; i <= x2; i++)
{
fb[(index + i)^1] = fill_color;
}
@@ -2134,11 +2135,11 @@ static void fill_rectangle_32bit(RECTANGLE *rect)
}
else if (other_modes.cycle_type == CYCLE_TYPE_1)
{
- for (j=y1; j <= y2; j++)
+ for (int j = y1; j <= y2; j++)
{
COLOR c;
- index = j * fb_width;
- for (i=x1; i <= x2; i++)
+ int index = j * fb_width;
+ for (int i = x1; i <= x2; i++)
{
curpixel_cvg = fill_cvg;
COLOR_COMBINER1(c);
@@ -2148,11 +2149,11 @@ static void fill_rectangle_32bit(RECTANGLE *rect)
}
else if (other_modes.cycle_type == CYCLE_TYPE_2)
{
- for (j=y1; j <= y2; j++)
+ for (int j = y1; j <= y2; j++)
{
COLOR c1, c2;
- index = j * fb_width;
- for (i=x1; i <= x2; i++)
+ int index = j * fb_width;
+ for (int i = x1; i <= x2; i++)
{
curpixel_cvg = fill_cvg;
COLOR_COMBINER2_C0(c1);
@@ -2170,22 +2171,16 @@ static void fill_rectangle_32bit(RECTANGLE *rect)
INLINE void texture_rectangle_32bit(TEX_RECTANGLE *rect)
{ // TODO: Z-compare and Z-update
UINT32 *fb = (UINT32*)&rdram[(fb_address / 4)];
- int i, j;
- int x1, x2, y1, y2;
- int s, t;
- int ss, st;
-
- int clipx1, clipx2, clipy1, clipy2;
UINT32 tilenum = rect->tilenum;
UINT32 tilenum2 = 0;
TILE *tex_tile = &tile[rect->tilenum];
TILE *tex_tile2 = NULL;
- x1 = (rect->xh / 4);
- x2 = (rect->xl / 4);
- y1 = (rect->yh / 4);
- y2 = (rect->yl / 4);
+ int x1 = rect->xh;
+ int x2 = rect->xl;
+ int y1 = rect->yh;
+ int y2 = rect->yl;
if (other_modes.cycle_type == CYCLE_TYPE_FILL || other_modes.cycle_type == CYCLE_TYPE_COPY)
{
@@ -2194,10 +2189,23 @@ INLINE void texture_rectangle_32bit(TEX_RECTANGLE *rect)
y2 += 1;
}
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
+ // clip
+ if (x1 < clip.xh)
+ {
+ x1 = clip.xh;
+ }
+ if (y1 < clip.yh)
+ {
+ y1 = clip.yh;
+ }
+ if (x2 >= clip.xl)
+ {
+ x2 = clip.xl - 1;
+ }
+ if (y2 >= clip.yl)
+ {
+ y2 = clip.yl - 1;
+ }
calculate_clamp_diffs(tex_tile->num);
@@ -2217,24 +2225,26 @@ INLINE void texture_rectangle_32bit(TEX_RECTANGLE *rect)
shade_color.c = 0; // Needed by Pilotwings 64
- t = (int)(rect->t) << 5;
+ int t = (int)(rect->t) << 5;
if (other_modes.cycle_type == CYCLE_TYPE_1)
{
CACHE_TEXTURE_PARAMS(tex_tile);
- for (j = y1; j < y2; j++)
+ for (int j = y1; j < y2; j++)
{
int fb_index = j * fb_width;
- s = (int)(rect->s) << 5;
+ int s = (int)(rect->s) << 5;
- for (i = x1; i < x2; i++)
+ for (int i = x1; i < x2; i++)
{
COLOR c;
- curpixel_cvg=8;
- ss = s >> 5;
- st = t >> 5;
+ int ss = s >> 5;
+ int st = t >> 5;
+
+ curpixel_cvg = 8;
+
if (rect->flip)
{
texel0_color.c = TEXTURE_PIPELINE(st, ss, tex_tile);
@@ -2256,18 +2266,20 @@ INLINE void texture_rectangle_32bit(TEX_RECTANGLE *rect)
}
else if (other_modes.cycle_type == CYCLE_TYPE_2)
{
- for (j = y1; j < y2; j++)
+ for (int j = y1; j < y2; j++)
{
int fb_index = j * fb_width;
- s = (int)(rect->s) << 5;
+ int s = (int)(rect->s) << 5;
- for (i = x1; i < x2; i++)
+ for (int i = x1; i < x2; i++)
{
COLOR c1, c2;
+ int ss = s >> 5;
+ int st = t >> 5;
+
curpixel_cvg=8;
- ss = s >> 5;
- st = t >> 5;
+
if (rect->flip)
{
CACHE_TEXTURE_PARAMS(tex_tile);
@@ -2300,16 +2312,16 @@ INLINE void texture_rectangle_32bit(TEX_RECTANGLE *rect)
{
CACHE_TEXTURE_PARAMS(tex_tile);
- for (j = y1; j < y2; j++)
+ for (int j = y1; j < y2; j++)
{
int fb_index = j * fb_width;
- s = (int)(rect->s) << 5;
+ int s = (int)(rect->s) << 5;
- for (i = x1; i < x2; i++)
+ for (int i = x1; i < x2; i++)
{
- ss = s >> 5;
- st = t >> 5;
+ int ss = s >> 5;
+ int st = t >> 5;
if (rect->flip)
{
texel0_color.c = TEXTURE_PIPELINE(st, ss, tex_tile);
@@ -2339,11 +2351,8 @@ static void render_spans_32(int start, int end, TILE* tex_tile, int shade, int t
UINT32 *fb = (UINT32*)&rdram[fb_address / 4];
UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
UINT8 *zhb = &hidden_bits[zb_address >> 1];
- int i, j;
int tilenum = tex_tile->num;
- int clipx1, clipx2, clipy1, clipy2;
-
UINT32 tilenum2 = 0;
TILE *tex_tile2 = NULL;
@@ -2356,16 +2365,10 @@ static void render_spans_32(int start, int end, TILE* tex_tile, int shade, int t
SPAN_PARAM dt = span[0].dt;
SPAN_PARAM dw = span[0].dw;
int dzpix = span[0].dzpix;
- int drinc, dginc, dbinc, dainc, dzinc, dsinc, dtinc, dwinc;
int xinc = flip ? 1 : -1;
calculate_clamp_diffs(tilenum);
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
-
if (other_modes.cycle_type == CYCLE_TYPE_2 && texture)
{
if (!other_modes.tex_lod_en)
@@ -2380,31 +2383,31 @@ static void render_spans_32(int start, int end, TILE* tex_tile, int shade, int t
}
}
- if (start < clipy1)
+ if (start < clip.yh)
{
- start = clipy1;
+ start = clip.yh;
}
- if (start >= clipy2)
+ if (start >= clip.yl)
{
- start = clipy2-1;
+ start = clip.yl - 1;
}
- if (end < clipy1)
+ if (end < clip.yh)
{
- end = clipy1;
+ end = clip.yh;
}
- if (end >= clipy2)
+ if (end >= clip.yl)
{
- end = clipy2-1;
+ end = clip.yl - 1;
}
- drinc = flip ? (dr.w) : -dr.w;
- dginc = flip ? (dg.w) : -dg.w;
- dbinc = flip ? (db.w) : -db.w;
- dainc = flip ? (da.w) : -da.w;
- dzinc = flip ? (dz.w) : -dz.w;
- dsinc = flip ? (ds.w) : -ds.w;
- dtinc = flip ? (dt.w) : -dt.w;
- dwinc = flip ? (dw.w) : -dw.w;
+ int drinc = flip ? (dr.w) : -dr.w;
+ int dginc = flip ? (dg.w) : -dg.w;
+ int dbinc = flip ? (db.w) : -db.w;
+ int dainc = flip ? (da.w) : -da.w;
+ int dzinc = flip ? (dz.w) : -dz.w;
+ int dsinc = flip ? (ds.w) : -ds.w;
+ int dtinc = flip ? (dt.w) : -dt.w;
+ int dwinc = flip ? (dw.w) : -dw.w;
if(!shade)
{
@@ -2413,7 +2416,7 @@ static void render_spans_32(int start, int end, TILE* tex_tile, int shade, int t
CACHE_TEXTURE_PARAMS(tex_tile);
- for (i = start; i <= end; i++)
+ for (int i = start; i <= end; i++)
{
int xstart = span[i].lx;
int xend = span[i].rx;
@@ -2426,32 +2429,20 @@ static void render_spans_32(int start, int end, TILE* tex_tile, int shade, int t
SPAN_PARAM t = span[i].t;
SPAN_PARAM w = span[i].w;
- int x;
+ int x = xend;
int fb_index = fb_width * i;
- int length;
-
- x = xend;
-
- length = flip ? (xstart - xend) : (xend - xstart);
+ int length = flip ? (xstart - xend) : (xend - xstart);
- for (j=0; j <= length; j++)
+ for (int j = 0; j <= length; j++)
{
- int sr = r.h.h;
- int sg = g.h.h;
- int sb = b.h.h;
- int sa = a.h.h;
- int ss = s.h.h;
- int st = t.h.h;
- int sw = w.h.h;
UINT32 sz = z.w >> 13;
- int sss = 0, sst = 0;
if (other_modes.z_source_sel)
{
sz = (((UINT32)primitive_z) << 3) & 0x3ffff;
dzpix = primitive_delta_z;
}
- if (x >= clipx1 && x < clipx2)
+ if (x >= clip.xh && x < clip.xl)
{
curpixel_cvg = span[i].cvg[x];
if (curpixel_cvg)
@@ -2467,18 +2458,13 @@ static void render_spans_32(int start, int end, TILE* tex_tile, int shade, int t
c1.i.r = c1.i.g = c1.i.b = c1.i.a = 0;
c2.i.r = c2.i.g = c2.i.b = c2.i.a = 0;
- if (other_modes.persp_tex_en)
- {
- tcdiv(ss, st, sw, &sss, &sst);
- }
- else
- {
- sss = ss;
- sst = st;
- }
-
if (shade)
{
+ int sr = r.h.h;
+ int sg = g.h.h;
+ int sb = b.h.h;
+ int sa = a.h.h;
+
// Needed by Superman
if (sr > 0xff) sr = 0xff;
if (sg > 0xff) sg = 0xff;
@@ -2496,6 +2482,22 @@ static void render_spans_32(int start, int end, TILE* tex_tile, int shade, int t
if (texture)
{
+ int ss = s.h.h;
+ int st = t.h.h;
+ int sw = w.h.h;
+ int sss = 0;
+ int sst = 0;
+
+ if (other_modes.persp_tex_en)
+ {
+ tcdiv(ss, st, sw, &sss, &sst);
+ }
+ else
+ {
+ sss = ss;
+ sst = st;
+ }
+
if (other_modes.cycle_type == CYCLE_TYPE_1)
{
texel0_color.c = TEXTURE_PIPELINE(sss, sst, tex_tile);
@@ -3469,17 +3471,15 @@ static RDP_COMMAND( rdp_tri_texshade_z )
static RDP_COMMAND( rdp_tex_rect )
{
- UINT32 w3, w4;
TEX_RECTANGLE rect;
-
- w3 = rdp_cmd_data[rdp_cmd_cur+2];
- w4 = rdp_cmd_data[rdp_cmd_cur+3];
+ UINT32 w3 = rdp_cmd_data[rdp_cmd_cur+2];
+ UINT32 w4 = rdp_cmd_data[rdp_cmd_cur+3];
rect.tilenum = (w2 >> 24) & 0x7;
- rect.xl = (w1 >> 12) & 0xfff;
- rect.yl = (w1 >> 0) & 0xfff;
- rect.xh = (w2 >> 12) & 0xfff;
- rect.yh = (w2 >> 0) & 0xfff;
+ rect.xl = ((w1 >> 12) & 0xfff) >> 2;
+ rect.yl = ((w1 >> 0) & 0xfff) >> 2;
+ rect.xh = ((w2 >> 12) & 0xfff) >> 2;
+ rect.yh = ((w2 >> 0) & 0xfff) >> 2;
rect.s = (w3 >> 16) & 0xffff;
rect.t = (w3 >> 0) & 0xffff;
rect.dsdx = (w4 >> 16) & 0xffff;
@@ -3495,17 +3495,15 @@ static RDP_COMMAND( rdp_tex_rect )
static RDP_COMMAND( rdp_tex_rect_flip )
{
- UINT32 w3, w4;
TEX_RECTANGLE rect;
-
- w3 = rdp_cmd_data[rdp_cmd_cur+2];
- w4 = rdp_cmd_data[rdp_cmd_cur+3];
+ UINT32 w3 = rdp_cmd_data[rdp_cmd_cur+2];
+ UINT32 w4 = rdp_cmd_data[rdp_cmd_cur+3];
rect.tilenum = (w2 >> 24) & 0x7;
- rect.xl = (w1 >> 12) & 0xfff;
- rect.yl = (w1 >> 0) & 0xfff;
- rect.xh = (w2 >> 12) & 0xfff;
- rect.yh = (w2 >> 0) & 0xfff;
+ rect.xl = ((w1 >> 12) & 0xfff) >> 2;
+ rect.yl = ((w1 >> 0) & 0xfff) >> 2;
+ rect.xh = ((w2 >> 12) & 0xfff) >> 2;
+ rect.yh = (( w2 >> 0) & 0xfff) >> 2;
rect.t = (w3 >> 16) & 0xffff;
rect.s = (w3 >> 0) & 0xffff;
rect.dtdy = (w4 >> 16) & 0xffff;
@@ -3573,6 +3571,11 @@ static RDP_COMMAND( rdp_set_scissor )
clip.xl = (w2 >> 12) & 0xfff;
clip.yl = (w2 >> 0) & 0xfff;
+ clip.xh >>= 2;
+ clip.yh >>= 2;
+ clip.xl >>= 2;
+ clip.yl >>= 2;
+
// TODO: handle f & o?
}
@@ -3584,21 +3587,19 @@ static RDP_COMMAND( rdp_set_prim_depth )
static RDP_COMMAND( rdp_set_other_modes )
{
- int index;
-
other_modes.cycle_type = (w1 >> 20) & 0x3;
- other_modes.persp_tex_en = (w1 & 0x80000) ? 1 : 0;
- other_modes.detail_tex_en = (w1 & 0x40000) ? 1 : 0;
- other_modes.sharpen_tex_en = (w1 & 0x20000) ? 1 : 0;
- other_modes.tex_lod_en = (w1 & 0x10000) ? 1 : 0;
- other_modes.en_tlut = (w1 & 0x08000) ? 1 : 0;
- other_modes.tlut_type = (w1 & 0x04000) ? 1 : 0;
- other_modes.sample_type = (w1 & 0x02000) ? 1 : 0;
- other_modes.mid_texel = (w1 & 0x01000) ? 1 : 0;
- other_modes.bi_lerp0 = (w1 & 0x00800) ? 1 : 0;
- other_modes.bi_lerp1 = (w1 & 0x00400) ? 1 : 0;
- other_modes.convert_one = (w1 & 0x00200) ? 1 : 0;
- other_modes.key_en = (w1 & 0x00100) ? 1 : 0;
+ other_modes.persp_tex_en = (w1 & 0x80000) ? true : false;
+ other_modes.detail_tex_en = (w1 & 0x40000) ? true : false;
+ other_modes.sharpen_tex_en = (w1 & 0x20000) ? true : false;
+ other_modes.tex_lod_en = (w1 & 0x10000) ? true : false;
+ other_modes.en_tlut = (w1 & 0x08000) ? true : false;
+ other_modes.tlut_type = (w1 & 0x04000) ? true : false;
+ other_modes.sample_type = (w1 & 0x02000) ? true : false;
+ other_modes.mid_texel = (w1 & 0x01000) ? true : false;
+ other_modes.bi_lerp0 = (w1 & 0x00800) ? true : false;
+ other_modes.bi_lerp1 = (w1 & 0x00400) ? true : false;
+ other_modes.convert_one = (w1 & 0x00200) ? true : false;
+ other_modes.key_en = (w1 & 0x00100) ? true : false;
other_modes.rgb_dither_sel = (w1 >> 6) & 0x3;
other_modes.alpha_dither_sel = (w1 >> 4) & 0x3;
other_modes.blend_m1a_0 = (w2 >> 30) & 0x3;
@@ -3609,19 +3610,19 @@ static RDP_COMMAND( rdp_set_other_modes )
other_modes.blend_m2a_1 = (w2 >> 20) & 0x3;
other_modes.blend_m2b_0 = (w2 >> 18) & 0x3;
other_modes.blend_m2b_1 = (w2 >> 16) & 0x3;
- other_modes.force_blend = (w2 & 0x4000) ? 1 : 0;
- other_modes.alpha_cvg_select = (w2 & 0x2000) ? 1 : 0;
- other_modes.cvg_times_alpha = (w2 & 0x1000) ? 1 : 0;
+ other_modes.force_blend = (w2 & 0x4000) ? true : false;
+ other_modes.alpha_cvg_select = (w2 & 0x2000) ? true : false;
+ other_modes.cvg_times_alpha = (w2 & 0x1000) ? true : false;
other_modes.z_mode = (w2 >> 10) & 0x3;
other_modes.cvg_dest = (w2 >> 8) & 0x3;
- other_modes.color_on_cvg = (w2 & 0x80) ? 1 : 0;
- other_modes.image_read_en = (w2 & 0x40) ? 1 : 0;
- other_modes.z_update_en = (w2 & 0x20) ? 1 : 0;
- other_modes.z_compare_en = (w2 & 0x10) ? 1 : 0;
- other_modes.antialias_en = (w2 & 0x08) ? 1 : 0;
- other_modes.z_source_sel = (w2 & 0x04) ? 1 : 0;
- other_modes.dither_alpha_en = (w2 & 0x02) ? 1 : 0;
- other_modes.alpha_compare_en = (w2 & 0x01) ? 1 : 0;
+ other_modes.color_on_cvg = (w2 & 0x80) ? true : false;
+ other_modes.image_read_en = (w2 & 0x40) ? true : false;
+ other_modes.z_update_en = (w2 & 0x20) ? true : false;
+ other_modes.z_compare_en = (w2 & 0x10) ? true : false;
+ other_modes.antialias_en = (w2 & 0x08) ? true : false;
+ other_modes.z_source_sel = (w2 & 0x04) ? true : false;
+ other_modes.dither_alpha_en = (w2 & 0x02) ? true : false;
+ other_modes.alpha_compare_en = (w2 & 0x01) ? true : false;
texture_rectangle_16bit = rdp_texture_rectangle_16bit_func[((((other_modes.z_update_en | other_modes.z_source_sel) << 3) | ((other_modes.z_compare_en | other_modes.z_source_sel) << 2) | other_modes.cycle_type) << 2) | other_modes.rgb_dither_sel];
fill_rectangle_16bit = rdp_fill_rectangle_16bit_func[(other_modes.cycle_type << 2) | other_modes.rgb_dither_sel];
@@ -3649,7 +3650,7 @@ static RDP_COMMAND( rdp_set_other_modes )
render_spans_16_s_t_nz_f = rdp_render_spans_16_func[28 + ((other_modes.cycle_type & 1) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6) | (other_modes.rgb_dither_sel << 7))];
render_spans_16_s_t_z_f = rdp_render_spans_16_func[30 + ((other_modes.cycle_type & 1) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6) | (other_modes.rgb_dither_sel << 7))];
- for(index = 0; index < 8; index++)
+ for(int index = 0; index < 8; index++)
{
tile[index].fetch_index = (tile[index].size << 5) | (tile[index].format << 2) | (other_modes.en_tlut << 1) | other_modes.tlut_type;
}
@@ -3677,15 +3678,12 @@ static RDP_COMMAND( rdp_set_other_modes )
static RDP_COMMAND( rdp_load_tlut )
{
- int i;
- int tl, th, sl, sh;
- int tilenum = (w2 >> 24) & 7;
+ const int tilenum = (w2 >> 24) & 7;
TILE* tex_tile = &tile[tilenum];
- sl = tex_tile->sl = ((w1 >> 12) & 0xfff);
- tl = tex_tile->tl = w1 & 0xfff;
- sh = tex_tile->sh = ((w2 >> 12) & 0xfff);
- th = tex_tile->th = w2 & 0xfff;
+ int sl = tex_tile->sl = ((w1 >> 12) & 0xfff);
+ int tl = tex_tile->tl = w1 & 0xfff;
+ int sh = tex_tile->sh = ((w2 >> 12) & 0xfff);
switch (ti_size)
{
@@ -3697,7 +3695,7 @@ static RDP_COMMAND( rdp_load_tlut )
UINT16 *dst = (UINT16*)&TMEM[tex_tile->tmem];
int count = ((sh >> 2) - (sl >> 2)) + 1;
- for (i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
if((i*4) < 0x400)
{
@@ -3737,65 +3735,46 @@ static RDP_COMMAND( rdp_set_tile_size )
static RDP_COMMAND( rdp_load_block )
{
- int i, width;
- UINT16 sl, sh, tl, dxt;
- int tilenum = (w2 >> 24) & 0x7;
- UINT32 *src, *tc;
- UINT32 tb;
+ const int tilenum = (w2 >> 24) & 0x7;
+ const UINT32 ti_address2 = ti_address - ((ti_address & 3) ? 4 : 0);
UINT16 *ram16 = (UINT16*)rdram;
- UINT32 ti_address2 = ti_address - ((ti_address & 3) ? 4 : 0);
int ti_width2 = ti_width;
int slindwords = 0;
- tile[tilenum].sl = sl = ((w1 >> 12) & 0xfff);
- tile[tilenum].tl = tl = ((w1 >> 0) & 0xfff);
- tile[tilenum].sh = sh = ((w2 >> 12) & 0xfff);
- dxt = ((w2 >> 0) & 0xfff);
+ UINT32 sl = tile[tilenum].sl = ((w1 >> 12) & 0xfff);
+ UINT32 tl = tile[tilenum].tl = ((w1 >> 0) & 0xfff);
+ UINT32 sh = tile[tilenum].sh = ((w2 >> 12) & 0xfff);
+ UINT32 dxt = ((w2 >> 0) & 0xfff);
- width = (sh - sl) + 1;
+ int width = (sh - sl) + 1;
if (width > 2048) // Hack for Magical Tetris Challenge
{
width = 2048;
}
- switch (ti_size)
- {
- case PIXEL_SIZE_4BIT: width >>= 1; break;
- case PIXEL_SIZE_8BIT: break;
- case PIXEL_SIZE_16BIT: width <<= 1; break;
- case PIXEL_SIZE_32BIT: width <<= 2; break;
- }
-
if ((ti_address & 3) && (ti_address & 0xffffff00) != 0xf8a00)
{
fatalerror( "load block: unaligned ti_address 0x%x",ti_address ); // Rat Attack, Frogger 2 prototype
}
- src = (UINT32*)&ram16[ti_address2 >> 1];
- tc = (UINT32*)TMEM;
- tb = tile[tilenum].tmem >> 2;
+ UINT32* src = (UINT32*)&ram16[ti_address2 >> 1];
+ UINT32* tc = (UINT32*)TMEM;
+ UINT32 tb = tile[tilenum].tmem >> 2;
- if ((tb + (width >> 2)) > 0x400)
- {
- width = 0x1000 - tb*4; // Hack for Magical Tetris Challenge
- }
+ slindwords = sl;
- switch (ti_size)
+ switch (ti_size) // slindwords Neededby Vigilante 8
{
- case PIXEL_SIZE_4BIT: ti_width2 >>= 1; break;
- case PIXEL_SIZE_8BIT: break;
- case PIXEL_SIZE_16BIT: ti_width2 <<= 1; break;
- case PIXEL_SIZE_32BIT: ti_width2 <<= 2; break;
+ case PIXEL_SIZE_4BIT: ti_width2 >>= 1; slindwords >>= 3; width >>= 1; break;
+ case PIXEL_SIZE_8BIT: slindwords >>= 2; break;
+ case PIXEL_SIZE_16BIT: ti_width2 <<= 1; slindwords >>= 1; width <<= 1; break;
+ case PIXEL_SIZE_32BIT: ti_width2 <<= 2; width <<= 2; break;
}
- slindwords = sl;
- switch (ti_size) // Needed by Vigilante 8
+ if ((tb + (width >> 2)) > 0x400)
{
- case PIXEL_SIZE_4BIT: slindwords >>= 3; break;
- case PIXEL_SIZE_8BIT: slindwords >>= 2;break;
- case PIXEL_SIZE_16BIT: slindwords >>= 1; break;
- case PIXEL_SIZE_32BIT: break;
+ width = 0x1000 - tb*4; // Hack for Magical Tetris Challenge
}
if (width & 7) // Sigh... another Rat Attack-specific thing.
@@ -3805,14 +3784,14 @@ static RDP_COMMAND( rdp_load_block )
if (dxt != 0)
{
- int j= 0;
+ int j = 0;
int t = 0;
int oldt = 0;
int ptr;
int xorval = (fb_size == PIXEL_SIZE_16BIT && ti_size == PIXEL_SIZE_32BIT ) ? 2 : 1; // Wave Race-specific
UINT32 srcstart = ((tl * ti_width2) >> 2) + slindwords;
src = &src[srcstart];
- for (i = 0; i < (width >> 2); i += 2)
+ for (int i = 0; i < (width >> 2); i += 2)
{
oldt = t;
t = ((j >> 11) & 1) ? xorval : 0;
@@ -3837,13 +3816,10 @@ static RDP_COMMAND( rdp_load_block )
static RDP_COMMAND( rdp_load_tile )
{
- int i, j;
- UINT16 sl, sh, tl, th;
- int width, height;
- int tilenum = (w2 >> 24) & 0x7;
+ const int tilenum = (w2 >> 24) & 0x7;
TILE *tex_tile = &tile[tilenum];
int line = tex_tile->line; // Per Ziggy
- int toppad;
+ int toppad = 0;
if (!line)
{
@@ -3854,13 +3830,14 @@ static RDP_COMMAND( rdp_load_tile )
tex_tile->tl = ((w1 >> 0) & 0xfff);
tex_tile->sh = ((w2 >> 12) & 0xfff);
tex_tile->th = ((w2 >> 0) & 0xfff);
- sl = tex_tile->sl / 4;
- tl = tex_tile->tl / 4;
- sh = tex_tile->sh / 4;
- th = tex_tile->th / 4;
- width = (sh - sl) + 1;
- height = (th - tl) + 1;
+ UINT16 sl = tex_tile->sl / 4;
+ UINT16 tl = tex_tile->tl / 4;
+ UINT16 sh = tex_tile->sh / 4;
+ UINT16 th = tex_tile->th / 4;
+
+ int width = (sh - sl) + 1;
+ int height = (th - tl) + 1;
if (ti_size < 3)
{
@@ -3885,14 +3862,14 @@ static RDP_COMMAND( rdp_load_tile )
height = (4096 - tb) / line; // Per Ziggy
}
- for (j=0; j < height; j++)
+ for (int j = 0; j < height; j++)
{
int tline = tb + (tex_tile->line * j);
int s = ((j + tl) * ti_width) + sl;
#define BYTE_XOR_DWORD_SWAP 7
int xorval8 = ((j & 1) ? BYTE_XOR_DWORD_SWAP : BYTE_ADDR_XOR); // Per Ziggy
- for (i=0; i < width; i++)
+ for (int i = 0; i < width; i++)
{
tc[(tline + i) ^ xorval8] = src[(ti_address + s + i) ^ BYTE_ADDR_XOR];
}
@@ -3912,7 +3889,7 @@ static RDP_COMMAND( rdp_load_tile )
height = (2048 - tb) / (line / 2); // Per Ziggy
}
- for (j = 0; j < height; j++)
+ for (int j = 0; j < height; j++)
{
int tline = tb + ((tex_tile->line / 2) * j);
int s = 0;
@@ -3925,7 +3902,7 @@ static RDP_COMMAND( rdp_load_tile )
#define WORD_XOR_DWORD_SWAP 3
xorval16 = (j & 1) ? WORD_XOR_DWORD_SWAP : WORD_ADDR_XOR;
- for (i = 0; i < width; i++)
+ for (int i = 0; i < width; i++)
{
taddr = (tline+i) ^ xorval16;
if (taddr < 2048) // Needed by World Driver Championship
@@ -3952,12 +3929,12 @@ static RDP_COMMAND( rdp_load_tile )
height = (1024 - tb) / (line/4); // Per Ziggy
}
- for (j=0; j < height; j++)
+ for (int j = 0; j < height; j++)
{
int tline = tb + ((tex_tile->line / 2) * j);
int s = ((j + tl) * ti_width) + sl;
int xorval32cur = (j & 1) ? xorval32 : 0;
- for (i=0; i < width; i++)
+ for (int i = 0; i < width; i++)
{
tc[(tline + i) ^ xorval32cur] = src[s + i];
}
@@ -3997,10 +3974,10 @@ static RDP_COMMAND( rdp_set_tile )
static RDP_COMMAND( rdp_fill_rect )
{
RECTANGLE rect;
- rect.xl = (w1 >> 12) & 0xfff;
- rect.yl = (w1 >> 0) & 0xfff;
- rect.xh = (w2 >> 12) & 0xfff;
- rect.yh = (w2 >> 0) & 0xfff;
+ rect.xl = (w1 >> 14) & 0x3ff;
+ rect.yl = (w1 >> 2) & 0x3ff;
+ rect.xh = (w2 >> 14) & 0x3ff;
+ rect.yh = (w2 >> 2) & 0x3ff;
switch (fb_size)
{
diff --git a/src/mame/video/rdpacvg.c b/src/mame/video/rdpacvg.c
index 77f4a7b8ab5..4d18da913c3 100644
--- a/src/mame/video/rdpacvg.c
+++ b/src/mame/video/rdpacvg.c
@@ -2,9 +2,8 @@ INLINE void alpha_cvg_get_cta_ca(UINT8 *comb_alpha)
{
UINT32 temp = *comb_alpha;
UINT32 temp2 = curpixel_cvg;
- UINT32 temp3 = 0;
- temp3 = (temp * temp2) + 4;
+ UINT32 temp3 = (temp * temp2) + 4;
curpixel_cvg = temp3 >> 8;
temp = (temp3 >> 3);
@@ -21,10 +20,8 @@ INLINE void alpha_cvg_get_cta_ca(UINT8 *comb_alpha)
INLINE void alpha_cvg_get_ncta_ca(UINT8 *comb_alpha)
{
- UINT32 temp = *comb_alpha;
UINT32 temp2 = curpixel_cvg;
-
- temp = temp2 << 5;
+ UINT32 temp = temp2 << 5;
if (temp > 0xff)
{
@@ -40,9 +37,8 @@ INLINE void alpha_cvg_get_cta_nca(UINT8 *comb_alpha)
{
UINT32 temp = *comb_alpha;
UINT32 temp2 = curpixel_cvg;
- UINT32 temp3 = 0;
+ UINT32 temp3 = (temp * temp2) + 4;
- temp3 = (temp * temp2) + 4;
curpixel_cvg = temp3 >> 8;
if (temp > 0xff)
diff --git a/src/mame/video/rdpblend.c b/src/mame/video/rdpblend.c
index 785d4ca591e..95ffda92e7a 100644
--- a/src/mame/video/rdpblend.c
+++ b/src/mame/video/rdpblend.c
@@ -124,8 +124,6 @@
#endif
#endif
{
- int r, g, b;
- int special_bsel = 0;
UINT16 mem = *fb;
#if defined(IMGREAD)
UINT32 memory_cvg = ((mem & 1) << 2) + (*hb & 3);
@@ -144,6 +142,7 @@
return 0;
}
+ int special_bsel = 0;
if (blender2b_a[0] == &memory_color.i.a)
{
special_bsel = 1;
@@ -163,6 +162,7 @@
memory_color.i.a = 0xe0;
#endif
+ int r, g, b;
#if defined(ZCOMPARE)
#if defined(FORCEBLEND)
inv_pixel_color.i.a = 0xff - *blender1b_a[0];
@@ -331,8 +331,6 @@
#endif
#endif
{
- int r, g, b;
- int special_bsel = 0;
UINT16 mem = *fb;
#if defined(IMGREAD)
UINT32 memory_cvg = ((mem & 1) << 2) + (*hb & 3);
@@ -351,6 +349,7 @@
return 0;
}
+ int special_bsel = 0;
if (blender2b_a[0] == &memory_color.i.a)
{
special_bsel = 1;
@@ -372,6 +371,7 @@
inv_pixel_color.i.a = 0xff - *blender1b_a[0];
+ int r, g, b;
#if defined(FORCEBLEND)
BLENDER_EQUATION0_FORCE(&r, &g, &b, special_bsel);
#else
@@ -496,8 +496,6 @@
#endif
#endif
{
- int r, g, b;
- int special_bsel = 0;
UINT16 mem = *fb;
#if defined(IMGREAD)
UINT32 memory_cvg = ((mem & 1) << 2) + (*hb & 3);
@@ -516,6 +514,7 @@
return 0;
}
+ int special_bsel = 0;
if (blender2b_a[0] == &memory_color.i.a)
{
special_bsel = 1;
@@ -535,6 +534,7 @@
memory_color.i.a = 0xe0;
#endif
+ int r, g, b;
#if defined(ZCOMPARE)
#if defined(FORCEBLEND)
inv_pixel_color.i.a = 0xff - *blender1b_a[0];
@@ -631,8 +631,6 @@
#endif
#endif
{
- int r, g, b;
- int special_bsel = 0;
UINT16 mem = *fb;
#if defined(IMGREAD)
UINT32 memory_cvg = ((mem & 1) << 2) + (*hb & 3);
@@ -651,6 +649,7 @@
return 0;
}
+ int special_bsel = 0;
if (blender2b_a[0] == &memory_color.i.a)
{
special_bsel = 1;
@@ -672,6 +671,7 @@
inv_pixel_color.i.a = 0xff - *blender1b_a[0];
+ int r, g, b;
#if defined(FORCEBLEND)
BLENDER_EQUATION0_FORCE(&r, &g, &b, special_bsel);
#else
diff --git a/src/mame/video/rdpfb.c b/src/mame/video/rdpfb.c
index f54fcdb6101..c606d8e348f 100644
--- a/src/mame/video/rdpfb.c
+++ b/src/mame/video/rdpfb.c
@@ -5,11 +5,7 @@
#endif
{
#undef CVG_DRAW
- UINT16 finalcolor;
UINT32 memory_cvg = ((*fb & 1) << 2) + (*hb & 3) + 1;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
#ifdef CVG_DRAW
int covdraw;
if (curpixel_cvg == 8)
@@ -28,12 +24,12 @@
curpixel_overlap = 0;
}
- newcvg = curpixel_cvg + memory_cvg;
- wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 newcvg = curpixel_cvg + memory_cvg;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
- finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
+ UINT16 finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -71,11 +67,7 @@
#endif
{
#undef CVG_DRAW
- UINT16 finalcolor;
UINT32 memory_cvg = ((*fb & 1) << 2) + (*hb & 3) + 1;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
#ifdef CVG_DRAW
int covdraw;
if (curpixel_cvg == 8)
@@ -94,12 +86,12 @@
curpixel_overlap = 0;
}
- newcvg = curpixel_cvg + memory_cvg;
- wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 newcvg = curpixel_cvg + memory_cvg;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
- finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
+ UINT16 finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -129,11 +121,7 @@
#endif
{
#undef CVG_DRAW
- UINT16 finalcolor;
UINT32 memory_cvg = ((*fb & 1) << 2) + (*hb & 3) + 1;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
#ifdef CVG_DRAW
int covdraw;
if (curpixel_cvg == 8)
@@ -152,12 +140,12 @@
curpixel_overlap = 0;
}
- newcvg = curpixel_cvg + memory_cvg;
- wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 newcvg = curpixel_cvg + memory_cvg;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
- finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
+ UINT16 finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -187,11 +175,7 @@
#endif
{
#undef CVG_DRAW
- UINT16 finalcolor;
UINT32 memory_cvg = ((*fb & 1) << 2) + (*hb & 3) + 1;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
#ifdef CVG_DRAW
int covdraw;
if (curpixel_cvg == 8)
@@ -210,12 +194,12 @@
curpixel_overlap = 0;
}
- newcvg = curpixel_cvg + memory_cvg;
- wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 newcvg = curpixel_cvg + memory_cvg;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
- finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
+ UINT16 finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -245,10 +229,6 @@
#endif
{
#undef CVG_DRAW
- UINT16 finalcolor;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
#ifdef CVG_DRAW
int covdraw;
if (curpixel_cvg == 8)
@@ -267,12 +247,12 @@
curpixel_overlap = 0;
}
- newcvg = curpixel_cvg + 8;
- wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 newcvg = curpixel_cvg + 8;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
- finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
+ UINT16 finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -309,10 +289,6 @@
#endif
{
#undef CVG_DRAW
- UINT16 finalcolor;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
#ifdef CVG_DRAW
int covdraw;
if (curpixel_cvg == 8)
@@ -331,12 +307,12 @@
curpixel_overlap = 0;
}
- newcvg = curpixel_cvg + 8;
- wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 newcvg = curpixel_cvg + 8;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
- finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
+ UINT16 finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -365,10 +341,6 @@
#endif
{
#undef CVG_DRAW
- UINT16 finalcolor;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
#ifdef CVG_DRAW
int covdraw;
if (curpixel_cvg == 8)
@@ -387,12 +359,12 @@
curpixel_overlap = 0;
}
- newcvg = curpixel_cvg + 8;
- wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 newcvg = curpixel_cvg + 8;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
- finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
+ UINT16 finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -421,10 +393,6 @@
#endif
{
#undef CVG_DRAW
- UINT16 finalcolor;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
#ifdef CVG_DRAW
int covdraw;
if (curpixel_cvg == 8)
@@ -443,12 +411,12 @@
curpixel_overlap = 0;
}
- newcvg = curpixel_cvg + 8;
- wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 newcvg = curpixel_cvg + 8;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
- finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
+ UINT16 finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -478,13 +446,10 @@
{
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
- newcvg = curpixel_cvg + memory_cvg;
- wrapflag = (newcvg > 8) ? 1 : 0;
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 newcvg = curpixel_cvg + memory_cvg;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -520,13 +485,10 @@
{
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
- newcvg = curpixel_cvg + memory_cvg;
- wrapflag = (newcvg > 8) ? 1 : 0;
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 newcvg = curpixel_cvg + memory_cvg;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -555,13 +517,10 @@
{
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
- newcvg = curpixel_cvg + memory_cvg;
- wrapflag = (newcvg > 8) ? 1 : 0;
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 newcvg = curpixel_cvg + memory_cvg;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -591,13 +550,10 @@
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
UINT32 memory_alphachannel = *fb & 0xff;
UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
- newcvg = curpixel_cvg + memory_cvg;
- wrapflag = (newcvg > 8) ? 1 : 0;
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 newcvg = curpixel_cvg + memory_cvg;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -625,13 +581,10 @@
#endif
{
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
- newcvg = curpixel_cvg + 8;
- wrapflag = (newcvg > 8) ? 1 : 0;
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 newcvg = curpixel_cvg + 8;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -665,13 +618,10 @@
#endif
{
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
- newcvg = curpixel_cvg + 8;
- wrapflag = (newcvg > 8) ? 1 : 0;
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 newcvg = curpixel_cvg + 8;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -698,13 +648,10 @@
#endif
{
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
- newcvg = curpixel_cvg + 8;
- wrapflag = (newcvg > 8) ? 1 : 0;
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 newcvg = curpixel_cvg + 8;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
@@ -732,13 +679,10 @@
{
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
UINT32 memory_alphachannel = *fb & 0xff;
- UINT32 newcvg;
- UINT32 wrapflag;
- UINT32 clampcvg;
- newcvg = curpixel_cvg + 8;
- wrapflag = (newcvg > 8) ? 1 : 0;
- clampcvg = (newcvg > 8) ? 8 : newcvg;
+ UINT32 newcvg = curpixel_cvg + 8;
+ UINT32 wrapflag = (newcvg > 8) ? 1 : 0;
+ UINT32 clampcvg = (newcvg > 8) ? 8 : newcvg;
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
curpixel_cvg--;
diff --git a/src/mame/video/rdpfetch.c b/src/mame/video/rdpfetch.c
index 00b0c32dd09..5cfc8fc018c 100644
--- a/src/mame/video/rdpfetch.c
+++ b/src/mame/video/rdpfetch.c
@@ -1,65 +1,65 @@
INLINE UINT32 FETCH_TEXEL_RGBA4_TLUT_EN0(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
- UINT32 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + (s / 2)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff;
+ UINT32 p = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
return rgb16_to_32_lut[tlut[((cached_tpal | p) ^ WORD_ADDR_XOR) << 2]];
}
INLINE UINT32 FETCH_TEXEL_RGBA4_TLUT_EN1(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
- UINT32 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + (s / 2)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff;
+ UINT32 p = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
return ia8_to_32_lut[tlut[((cached_tpal | p) ^ WORD_ADDR_XOR) << 2]];
}
INLINE UINT32 FETCH_TEXEL_RGBA4_TLUT_NEN(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
- UINT32 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + (s / 2)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff;
+ UINT32 p = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
return (cached_tpal | p) * 0x01010101;
}
INLINE UINT32 FETCH_TEXEL_RGBA8_TLUT_EN0(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff;
return rgb16_to_32_lut[tlut[(TMEM[taddr ^ BYTE_ADDR_XOR] ^ WORD_ADDR_XOR) << 2]];
}
INLINE UINT32 FETCH_TEXEL_RGBA8_TLUT_EN1(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff;
return ia8_to_32_lut[tlut[(TMEM[taddr ^ BYTE_ADDR_XOR] ^ WORD_ADDR_XOR) << 2]];
}
INLINE UINT32 FETCH_TEXEL_RGBA8_TLUT_NEN(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff;
return TMEM[taddr ^ BYTE_ADDR_XOR] * 0x01010101;
}
INLINE UINT32 FETCH_TEXEL_RGBA16_TLUT_EN0(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
+ UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + s) ^ ((t & 1) << XOR_SWAP_WORD_SHIFT);
return rgb16_to_32_lut[tlut[(TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR] >> 8) << 2]];
}
INLINE UINT32 FETCH_TEXEL_RGBA16_TLUT_EN1(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
+ UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + s) ^ ((t & 1) << XOR_SWAP_WORD_SHIFT);
return ia8_to_32_lut[tlut[(TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR] >> 8) << 2]];
}
INLINE UINT32 FETCH_TEXEL_RGBA16_TLUT_NEN(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
+ UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + s) ^ ((t & 1) << XOR_SWAP_WORD_SHIFT);
return rgb16_to_32_lut[TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR]];
}
INLINE UINT32 FETCH_TEXEL_RGBA32_TLUT_EN0(UINT32 s, UINT32 t)
{
int xorval = (fb_size == PIXEL_SIZE_16BIT) ? XOR_SWAP_WORD : XOR_SWAP_DWORD; // Conker's Bad Fur Day, Jet Force Gemini, Super Smash Bros., Mickey's Speedway USA, Ogre Battle, Wave Race, Gex 3, South Park Rally
- UINT32 taddr = (((cached_tbase >> 2) + ((t) * (cached_twidth >> 1)) + (s)) ^ ((t & 1) ? xorval : 0)) & 0x3ff;
+ UINT32 taddr = (((cached_tbase >> 2) + ((t) * (cached_twidth >> 1)) + s) ^ ((t & 1) ? xorval : 0)) & 0x3ff;
return rgb16_to_32_lut[tlut[(TMEM32[taddr] >> 24) << 2]];
}
@@ -67,7 +67,7 @@ INLINE UINT32 FETCH_TEXEL_RGBA32_TLUT_EN0(UINT32 s, UINT32 t)
INLINE UINT32 FETCH_TEXEL_RGBA32_TLUT_EN1(UINT32 s, UINT32 t)
{
int xorval = (fb_size == PIXEL_SIZE_16BIT) ? XOR_SWAP_WORD : XOR_SWAP_DWORD; // Conker's Bad Fur Day, Jet Force Gemini, Super Smash Bros., Mickey's Speedway USA, Ogre Battle, Wave Race, Gex 3, South Park Rally
- UINT32 taddr = (((cached_tbase >> 2) + ((t) * (cached_twidth >> 1)) + (s)) ^ ((t & 1) ? xorval : 0)) & 0x3ff;
+ UINT32 taddr = (((cached_tbase >> 2) + ((t) * (cached_twidth >> 1)) + s) ^ ((t & 1) ? xorval : 0)) & 0x3ff;
return ia8_to_32_lut[tlut[(TMEM32[taddr] >> 24) << 2]];
}
@@ -75,7 +75,7 @@ INLINE UINT32 FETCH_TEXEL_RGBA32_TLUT_EN1(UINT32 s, UINT32 t)
INLINE UINT32 FETCH_TEXEL_RGBA32_TLUT_NEN(UINT32 s, UINT32 t)
{
int xorval = (fb_size == PIXEL_SIZE_16BIT) ? XOR_SWAP_WORD : XOR_SWAP_DWORD; // Conker's Bad Fur Day, Jet Force Gemini, Super Smash Bros., Mickey's Speedway USA, Ogre Battle, Wave Race, Gex 3, South Park Rally
- UINT32 taddr = (((cached_tbase >> 2) + ((t) * (cached_twidth >> 1)) + (s)) ^ ((t & 1) ? xorval : 0)) & 0x3ff;
+ UINT32 taddr = (((cached_tbase >> 2) + ((t) * (cached_twidth >> 1)) + s) ^ ((t & 1) ? xorval : 0)) & 0x3ff;
return TMEM32[taddr];
}
@@ -85,7 +85,7 @@ INLINE UINT32 FETCH_TEXEL_YUV16(UINT32 s, UINT32 t)
INT32 newr = 0;
INT32 newg = 0;
INT32 newb = 0;
- UINT32 taddr = ((cached_tbase >> 1) + ((t) * (cached_twidth)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
+ UINT32 taddr = ((cached_tbase >> 1) + ((t) * (cached_twidth)) + s) ^ ((t & 1) << XOR_SWAP_WORD_SHIFT);
UINT32 c1, c2;
INT32 y;
INT32 u, v;
@@ -113,6 +113,7 @@ INLINE UINT32 FETCH_TEXEL_YUV16(UINT32 s, UINT32 t)
newg = y + ((k1 * u) >> 8) + ((k2 * v) >> 8);
newb = y + ((k3 * u) >> 8);
}
+
return (((newr < 0) ? 0 : ((newr > 0xff) ? 0xff : newr)) << 24) |
(((newg < 0) ? 0 : ((newg > 0xff) ? 0xff : newg)) << 16) |
(((newb < 0) ? 0 : ((newb > 0xff) ? 0xff : newb)) << 8) |
@@ -121,98 +122,98 @@ INLINE UINT32 FETCH_TEXEL_YUV16(UINT32 s, UINT32 t)
INLINE UINT32 FETCH_TEXEL_CI4_TLUT_EN0(UINT32 s, UINT32 t)
{
- UINT32 b = TMEM[(((cached_tbase + ((t) * cached_twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff) ^ BYTE_ADDR_XOR];
- return rgb16_to_32_lut[tlut[(cached_tpal | (((s) & 1) ? (b & 0xf) : (b >> 4))) << 2]];
+ UINT32 b = TMEM[(((cached_tbase + ((t) * cached_twidth) + (s / 2)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff) ^ BYTE_ADDR_XOR];
+ return rgb16_to_32_lut[tlut[(cached_tpal | ((b >> ((s & 1) << 2)) & 0xf)) << 2]];
}
INLINE UINT32 FETCH_TEXEL_CI4_TLUT_EN1(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
- UINT32 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + (s / 2)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff;
+ UINT32 p = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
return ia8_to_32_lut[tlut[(cached_tpal | p) << 2]];
}
INLINE UINT32 FETCH_TEXEL_CI4_TLUT_NEN(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
- UINT32 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + (s / 2)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff;
+ UINT32 p = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
return (cached_tpal | p) * 0x01010101;
}
INLINE UINT32 FETCH_TEXEL_CI8_TLUT_EN0(UINT32 s, UINT32 t)
{
- return rgb16_to_32_lut[tlut[TMEM[(((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff) ^ BYTE_ADDR_XOR] << 2]];
+ return rgb16_to_32_lut[tlut[TMEM[(((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff) ^ BYTE_ADDR_XOR] << 2]];
}
INLINE UINT32 FETCH_TEXEL_CI8_TLUT_EN1(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff;
return ia8_to_32_lut[tlut[TMEM[taddr ^ BYTE_ADDR_XOR] << 2]];
}
INLINE UINT32 FETCH_TEXEL_CI8_TLUT_NEN(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0x7ff;
return TMEM[taddr ^ BYTE_ADDR_XOR] * 0x01010101;
}
INLINE UINT32 FETCH_TEXEL_CI16_TLUT_EN0(UINT32 s, UINT32 t)
{ // 16-bit CI is a "valid" mode; some games use it, it behaves the same as 16-bit RGBA
- UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
+ UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + s) ^ ((t & 1) << XOR_SWAP_WORD_SHIFT);
return rgb16_to_32_lut[tlut[(TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR] >> 8) << 2]];
}
INLINE UINT32 FETCH_TEXEL_CI16_TLUT_EN1(UINT32 s, UINT32 t)
{ // 16-bit CI is a "valid" mode; some games use it, it behaves the same as 16-bit RGBA
- UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
+ UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + s) ^ ((t & 1) << XOR_SWAP_WORD_SHIFT);
return ia8_to_32_lut[tlut[(TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR] >> 8) << 2]]; // Beetle Adventure Racing, Mount Mayhem
}
INLINE UINT32 FETCH_TEXEL_CI16_TLUT_NEN(UINT32 s, UINT32 t)
{ // 16-bit CI is a "valid" mode; some games use it, it behaves the same as 16-bit RGBA
- UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
+ UINT32 taddr = ((cached_tbase_s1) + ((t) * (cached_twidth_s1)) + s) ^ ((t & 1) << XOR_SWAP_WORD_SHIFT);
return rgb16_to_32_lut[TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR]]; // PGA European Tour (U)
}
INLINE UINT32 FETCH_TEXEL_IA4_TLUT_EN0(UINT32 s, UINT32 t)
{
- UINT32 taddr = (cached_tbase + ((t) * cached_twidth) + (s >> 1)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0);
- UINT32 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = (cached_tbase + ((t) * cached_twidth) + (s >> 1)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT);
+ UINT32 p = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
return rgb16_to_32_lut[tlut[(cached_tpal | p) << 2]];
}
INLINE UINT32 FETCH_TEXEL_IA4_TLUT_EN1(UINT32 s, UINT32 t)
{
- UINT32 taddr = (cached_tbase + ((t) * cached_twidth) + (s >> 1)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0);
- UINT32 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = (cached_tbase + ((t) * cached_twidth) + (s >> 1)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT);
+ UINT32 p = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
return ia8_to_32_lut[tlut[(cached_tpal | p) << 2]];
}
INLINE UINT32 FETCH_TEXEL_IA4_TLUT_NEN(UINT32 s, UINT32 t)
{
- UINT32 taddr = (cached_tbase + ((t) * cached_twidth) + (s >> 1)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0);
- UINT32 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = (cached_tbase + ((t) * cached_twidth) + (s >> 1)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT);
+ UINT32 p = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
UINT32 i = ((p & 0xe) << 4) | ((p & 0xe) << 1) | (p & 0xe >> 2);
- return (i * 0x01010100) | ((p & 0x1) ? 0xff : 0);
+ return (i * 0x01010100) | ((p & 0x1) & 0xff);
}
INLINE UINT32 FETCH_TEXEL_IA8_TLUT_EN0(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0xfff;
return rgb16_to_32_lut[tlut[TMEM[taddr ^ BYTE_ADDR_XOR] << 2]];
}
INLINE UINT32 FETCH_TEXEL_IA8_TLUT_EN1(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0xfff;
return ia8_to_32_lut[tlut[TMEM[taddr ^ BYTE_ADDR_XOR] << 2]];
}
INLINE UINT32 FETCH_TEXEL_IA8_TLUT_NEN(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0xfff;
UINT32 p = TMEM[taddr ^ BYTE_ADDR_XOR];
UINT32 i = (p >> 4) | (p & 0xf0);
@@ -221,19 +222,19 @@ INLINE UINT32 FETCH_TEXEL_IA8_TLUT_NEN(UINT32 s, UINT32 t)
INLINE UINT32 FETCH_TEXEL_IA16_TLUT_EN0(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase >> 1) + ((t) * (cached_twidth >> 1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
+ UINT32 taddr = ((cached_tbase >> 1) + ((t) * (cached_twidth >> 1)) + s) ^ ((t & 1) << XOR_SWAP_WORD_SHIFT);
return rgb16_to_32_lut[tlut[(TMEM16[taddr ^ WORD_ADDR_XOR] >> 8) << 2]];
}
INLINE UINT32 FETCH_TEXEL_IA16_TLUT_EN1(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase >> 1) + ((t) * (cached_twidth >> 1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
+ UINT32 taddr = ((cached_tbase >> 1) + ((t) * (cached_twidth >> 1)) + s) ^ ((t & 1) << XOR_SWAP_WORD_SHIFT);
return ia8_to_32_lut[tlut[(TMEM16[taddr ^ WORD_ADDR_XOR] >> 8) << 2]];
}
INLINE UINT32 FETCH_TEXEL_IA16_TLUT_NEN(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase >> 1) + ((t) * (cached_twidth >> 1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
+ UINT32 taddr = ((cached_tbase >> 1) + ((t) * (cached_twidth >> 1)) + s) ^ ((t & 1) << XOR_SWAP_WORD_SHIFT);
UINT32 c = TMEM16[taddr ^ WORD_ADDR_XOR];
return ((c >> 8) * 0x01010100) | (c & 0xff);
@@ -241,8 +242,8 @@ INLINE UINT32 FETCH_TEXEL_IA16_TLUT_NEN(UINT32 s, UINT32 t)
INLINE UINT32 FETCH_TEXEL_I4_TLUT_EN0(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
- UINT32 c = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + (s / 2)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0xfff;
+ UINT32 c = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
c |= (c << 4);
return rgb16_to_32_lut[tlut[(cached_tpal | c) << 2]];
@@ -250,8 +251,8 @@ INLINE UINT32 FETCH_TEXEL_I4_TLUT_EN0(UINT32 s, UINT32 t)
INLINE UINT32 FETCH_TEXEL_I4_TLUT_EN1(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
- UINT32 c = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + (s / 2)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0xfff;
+ UINT32 c = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
c |= (c << 4);
return ia8_to_32_lut[tlut[(cached_tpal | c) << 2]];
@@ -259,8 +260,8 @@ INLINE UINT32 FETCH_TEXEL_I4_TLUT_EN1(UINT32 s, UINT32 t)
INLINE UINT32 FETCH_TEXEL_I4_TLUT_NEN(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
- UINT32 c = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + (s / 2)) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0xfff;
+ UINT32 c = (TMEM[taddr ^ BYTE_ADDR_XOR] >> ((s & 1) << 2)) & 0xf;
c |= (c << 4);
return (c * 0x01010101);
@@ -268,19 +269,19 @@ INLINE UINT32 FETCH_TEXEL_I4_TLUT_NEN(UINT32 s, UINT32 t)
INLINE UINT32 FETCH_TEXEL_I8_TLUT_EN0(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0xfff;
return rgb16_to_32_lut[tlut[TMEM[taddr ^ BYTE_ADDR_XOR] << 2]];
}
INLINE UINT32 FETCH_TEXEL_I8_TLUT_EN1(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0xfff;
return ia8_to_32_lut[tlut[TMEM[taddr ^ BYTE_ADDR_XOR] << 2]];
}
INLINE UINT32 FETCH_TEXEL_I8_TLUT_NEN(UINT32 s, UINT32 t)
{
- UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
+ UINT32 taddr = ((cached_tbase + ((t) * cached_twidth) + s) ^ ((t & 1) << XOR_SWAP_BYTE_SHIFT)) & 0xfff;
return TMEM[taddr ^ BYTE_ADDR_XOR] * 0x01010101;
}
diff --git a/src/mame/video/rdpfrect.c b/src/mame/video/rdpfrect.c
index 46933586397..2d08d044285 100644
--- a/src/mame/video/rdpfrect.c
+++ b/src/mame/video/rdpfrect.c
@@ -10,11 +10,10 @@
UINT8* hb = &hidden_bits[fb_address >> 1];
int index, i, j;
- int x1 = rect->xh / 4;
- int x2 = rect->xl / 4;
- int y1 = rect->yh / 4;
- int y2 = rect->yl / 4;
- int clipx1, clipx2, clipy1, clipy2;
+ int x1 = rect->xh;
+ int x2 = rect->xl;
+ int y1 = rect->yh;
+ int y2 = rect->yl;
UINT16 fill_color1, fill_color2;
int fill_cvg1;
int fill_cvg2;
@@ -34,27 +33,22 @@
fill_cvg1 = (fill_color1 & 1) ? 8 : 1;
fill_cvg2 = (fill_color2 & 1) ? 8 : 1;
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
-
// clip
- if (x1 < clipx1)
+ if (x1 < clip.xh)
{
- x1 = clipx1;
+ x1 = clip.xh;
}
- if (y1 < clipy1)
+ if (y1 < clip.yh)
{
- y1 = clipy1;
+ y1 = clip.yh;
}
- if (x2 >= clipx2)
+ if (x2 >= clip.xl)
{
- x2 = clipx2-1;
+ x2 = clip.xl - 1;
}
- if (y2 >= clipy2)
+ if (y2 >= clip.yl)
{
- y2 = clipy2-1;
+ y2 = clip.yl - 1;
}
shade_color.c = 0; // Needed by Command & Conquer menus
@@ -114,11 +108,10 @@
UINT8* hb = &hidden_bits[fb_address >> 1];
int index, i, j;
- int x1 = rect->xh / 4;
- int x2 = rect->xl / 4;
- int y1 = rect->yh / 4;
- int y2 = rect->yl / 4;
- int clipx1, clipx2, clipy1, clipy2;
+ int x1 = rect->xh;
+ int x2 = rect->xl;
+ int y1 = rect->yh;
+ int y2 = rect->yl;
UINT16 fill_color1, fill_color2;
int fill_cvg1;
int fill_cvg2;
@@ -138,27 +131,22 @@
fill_cvg1 = (fill_color1 & 1) ? 8 : 1;
fill_cvg2 = (fill_color2 & 1) ? 8 : 1;
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
-
// clip
- if (x1 < clipx1)
+ if (x1 < clip.xh)
{
- x1 = clipx1;
+ x1 = clip.xh;
}
- if (y1 < clipy1)
+ if (y1 < clip.yh)
{
- y1 = clipy1;
+ y1 = clip.yh;
}
- if (x2 >= clipx2)
+ if (x2 >= clip.xl)
{
- x2 = clipx2-1;
+ x2 = clip.xl - 1;
}
- if (y2 >= clipy2)
+ if (y2 >= clip.yl)
{
- y2 = clipy2-1;
+ y2 = clip.yl - 1;
}
shade_color.c = 0; // Needed by Command & Conquer menus
@@ -223,11 +211,10 @@ static void fill_rectangle_16bit_cf(RECTANGLE *rect)
UINT8* hb = &hidden_bits[fb_address >> 1];
int index, i, j;
- int x1 = rect->xh / 4;
- int x2 = rect->xl / 4;
- int y1 = rect->yh / 4;
- int y2 = rect->yl / 4;
- int clipx1, clipx2, clipy1, clipy2;
+ int x1 = rect->xh;
+ int x2 = rect->xl;
+ int y1 = rect->yh;
+ int y2 = rect->yl;
UINT16 fill_color1, fill_color2;
int fill_cvg1;
int fill_cvg2;
@@ -247,27 +234,22 @@ static void fill_rectangle_16bit_cf(RECTANGLE *rect)
fill_cvg1 = (fill_color1 & 1) ? 8 : 1;
fill_cvg2 = (fill_color2 & 1) ? 8 : 1;
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
-
// clip
- if (x1 < clipx1)
+ if (x1 < clip.xh)
{
- x1 = clipx1;
+ x1 = clip.xh;
}
- if (y1 < clipy1)
+ if (y1 < clip.yh)
{
- y1 = clipy1;
+ y1 = clip.yh;
}
- if (x2 >= clipx2)
+ if (x2 >= clip.xl)
{
- x2 = clipx2-1;
+ x2 = clip.xl - 1;
}
- if (y2 >= clipy2)
+ if (y2 >= clip.yl)
{
- y2 = clipy2-1;
+ y2 = clip.yl - 1;
}
shade_color.c = 0; // Needed by Command & Conquer menus
diff --git a/src/mame/video/rdpmask.c b/src/mame/video/rdpmask.c
index 4794a36e56f..9951624b3d0 100644
--- a/src/mame/video/rdpmask.c
+++ b/src/mame/video/rdpmask.c
@@ -13,14 +13,7 @@
#endif
{
#if defined(MASK_S)
- INT32 swrap;
-#endif
-#if defined(MASK_T)
- INT32 twrap;
-#endif
-
-#if defined(MASK_S)
- swrap = *S >> tex_tile->mask_s;
+ INT32 swrap = *S >> tex_tile->mask_s;
swrap &= 1;
if (tex_tile->ms && swrap)
{
@@ -33,7 +26,7 @@
#endif
#if defined(MASK_T)
- twrap = *T >> tex_tile->mask_t;
+ INT32 twrap = *T >> tex_tile->mask_t;
twrap &= 1;
if (tex_tile->mt && twrap)
{
diff --git a/src/mame/video/rdpspn16.c b/src/mame/video/rdpspn16.c
index 082cf9c5ba3..5ef67ccd2cb 100644
--- a/src/mame/video/rdpspn16.c
+++ b/src/mame/video/rdpspn16.c
@@ -769,10 +769,6 @@
UINT8 *zhb = &hidden_bits[zb_address >> 1];
#endif
- int i, j;
-
- int clipx1, clipx2, clipy1, clipy2;
-
#if defined(SHADE)
SPAN_PARAM dr = span[0].dr;
SPAN_PARAM dg = span[0].dg;
@@ -828,11 +824,6 @@
}
#endif
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
-
#if defined(TEXTURE)
calculate_clamp_diffs(tex_tile->num);
@@ -847,21 +838,21 @@
}
#endif
- if (start < clipy1)
+ if (start < clip.yh)
{
- start = clipy1;
+ start = clip.yh;
}
- if (start >= clipy2)
+ if (start >= clip.yl)
{
- start = clipy2 - 1;
+ start = clip.yl - 1;
}
- if (end < clipy1)
+ if (end < clip.yh)
{
- end = clipy1;
+ end = clip.yh;
}
- if (end >= clipy2) // Needed by 40 Winks
+ if (end >= clip.yl) // Needed by 40 Winks
{
- end = clipy2 - 1;
+ end = clip.yl - 1;
}
#if !defined(SHADE)
@@ -870,15 +861,11 @@
CACHE_TEXTURE_PARAMS(tex_tile);
- for (i = start; i <= end; i++)
+ for (int i = start; i <= end; i++)
{
- int xstart = span[i].lx;
- int xend = span[i].rx;
-
- int x;
+ int x = span[i].rx;
int fb_index = fb_width * i;
- int length;
#if defined(SHADE)
SPAN_PARAM r = span[i].r;
@@ -895,15 +882,13 @@
SPAN_PARAM z = span[i].z;
#endif
- x = xend;
-
#if defined(FLIP)
- length = (xstart - xend);
+ int length = (span[i].lx - span[i].rx);
#else
- length = (xend - xstart);
+ int length = (span[i].rx - span[i].lx);
#endif
- for (j = 0; j <= length; j++)
+ for (int j = 0; j <= length; j++)
{
#if defined(SHADE)
int sr = r.h.h;
@@ -931,7 +916,7 @@
}
#endif
- if (x >= clipx1 && x < clipx2)
+ if (x >= clip.xh && x < clip.xl)
{
#if defined(ZCOMPARE)
int z_compare_result = 1;
@@ -994,7 +979,6 @@
#endif
{
#if defined(ZUPDATE)
- int rendered = 0;
#endif
#if defined(MAGICDITHER)
int dith = magic_matrix[(((i) & 3) << 2) + ((x ^ WORD_ADDR_XOR) & 3)];
@@ -1004,9 +988,9 @@
#if defined(ZUPDATE)
#if defined(MAGICDITHER) || defined(BAYERDITHER)
- rendered = BLENDER1_16_DITH(fbcur, hbcur, c1, dith);
+ int rendered = BLENDER1_16_DITH(fbcur, hbcur, c1, dith);
#else
- rendered = BLENDER1_16_NDITH(fbcur, hbcur, c1);
+ int rendered = BLENDER1_16_NDITH(fbcur, hbcur, c1);
#endif
if (rendered)
@@ -1819,10 +1803,6 @@
UINT8 *zhb = &hidden_bits[zb_address >> 1];
#endif
- int i, j;
-
- int clipx1, clipx2, clipy1, clipy2;
-
#if defined(SHADE)
SPAN_PARAM dr = span[0].dr;
SPAN_PARAM dg = span[0].dg;
@@ -1847,14 +1827,9 @@
TILE *tex_tile2 = NULL;
int tilenum;
- int LOD = 0;
- INT32 horstep, vertstep;
- INT32 l_tile;
- UINT32 magnify = 0;
- UINT32 distant = 0;
-
- int nexts, nextt, nextsw;
- int lodclamp = 0;
+ int nexts;// = 0;
+ int nextt;// = 0;
+ int nextsw;// = 0;
SPAN_PARAM ds = span[0].ds;
SPAN_PARAM dt = span[0].dt;
@@ -1900,36 +1875,29 @@
}
#endif
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
-
- if (start < clipy1)
+ if (start < clip.yh)
{
- start = clipy1;
+ start = clip.yh;
}
- if (start >= clipy2)
+ if (start >= clip.yl)
{
- start = clipy2 - 1;
+ start = clip.yl - 1;
}
- if (end < clipy1)
+ if (end < clip.yh)
{
- end = clipy1;
+ end = clip.yh;
}
- if (end >= clipy2) // Needed by 40 Winks
+ if (end >= clip.yl) // Needed by 40 Winks
{
- end = clipy2 - 1;
+ end = clip.yl - 1;
}
#if !defined(SHADE)
shade_color.c = prim_color.c;
#endif
- for (i = start; i <= end; i++)
+ for (int i = start; i <= end; i++)
{
- int xstart = span[i].lx;
- int xend = span[i].rx;
#if defined(SHADE)
SPAN_PARAM r = span[i].r;
SPAN_PARAM g = span[i].g;
@@ -1945,20 +1913,16 @@
SPAN_PARAM z = span[i].z;
#endif
- int x;
-
int fb_index = fb_width * i;
- int length;
-
- x = xend;
+ int x = span[i].rx;
#if defined(FLIP)
- length = (xstart - xend);
+ int length = (span[i].lx - span[i].rx);
#else
- length = (xend - xstart);
+ int length = (span[i].rx - span[i].lx);
#endif
- for (j = 0; j <= length; j++)
+ for (int j = 0; j <= length; j++)
{
#if defined(SHADE)
int sr = r.h.h;
@@ -1987,7 +1951,7 @@
}
#endif
- if (x >= clipx1 && x < clipx2)
+ if (x >= clip.xh && x < clip.xl)
{
#if defined(ZCOMPARE)
int z_compare_result = 1;
@@ -2046,10 +2010,10 @@
nextt = (t.w + dtinc)>>16;
}
- lodclamp = 0;
+ int lodclamp = 0;
- horstep = SIGN17(nexts & 0x1ffff) - SIGN17(sss & 0x1ffff);
- vertstep = SIGN17(nextt & 0x1ffff) - SIGN17(sst & 0x1ffff);
+ INT32 horstep = SIGN17(nexts & 0x1ffff) - SIGN17(sss & 0x1ffff);
+ INT32 vertstep = SIGN17(nextt & 0x1ffff) - SIGN17(sst & 0x1ffff);
if (horstep & 0x20000)
{
horstep = ~horstep & 0x1ffff;
@@ -2058,7 +2022,7 @@
{
vertstep = ~vertstep & 0x1ffff;
}
- LOD = ((horstep >= vertstep) ? horstep : vertstep);
+ int LOD = ((horstep >= vertstep) ? horstep : vertstep);
LOD = (LOD >= span[0].dymax) ? LOD : span[0].dymax;
if ((LOD & 0x1c000) || lodclamp)
@@ -2070,9 +2034,9 @@
LOD = min_level;
}
- magnify = (LOD < 32) ? 1: 0;
- l_tile = getlog2((LOD >> 5) & 0xff);
- distant = ((LOD & 0x6000) || (l_tile >= max_level)) ? 1 : 0;
+ bool magnify = (LOD < 32);
+ INT32 l_tile = getlog2((LOD >> 5) & 0xff);
+ bool distant = ((LOD & 0x6000) || (l_tile >= max_level));
lod_frac = ((LOD << 3) >> l_tile) & 0xff;
diff --git a/src/mame/video/rdptpipe.c b/src/mame/video/rdptpipe.c
index 24b23b919c2..0824446f140 100644
--- a/src/mame/video/rdptpipe.c
+++ b/src/mame/video/rdptpipe.c
@@ -81,12 +81,12 @@
#endif
#if defined(COPY)
- #define CLAMP_LIGHT(SSS, SST, maxs, maxt) \
+ #define CLAMP_LIGHT(SSS, SST) \
SSS = (SIGN17(SSS) >> 5) & 0x1fff; \
SST = (SIGN17(SST) >> 5) & 0x1fff;
#else
#if defined(DOS) && defined(DOT)
- #define CLAMP_LIGHT(SSS, SST, maxs, maxt) \
+ #define CLAMP_LIGHT(SSS, SST) \
if (SSS & 0x10000) \
{ \
SSS = 0; \
@@ -113,7 +113,7 @@
SST = (SIGN17(SST) >> 5) & 0x1fff; \
}
#elif defined(DOS) && !defined(DOT)
- #define CLAMP_LIGHT(SSS, SST, maxs, maxt) \
+ #define CLAMP_LIGHT(SSS, SST) \
if (SSS & 0x10000) \
{ \
SSS = 0; \
@@ -129,7 +129,7 @@
\
SST = (SIGN17(SST) >> 5) & 0x1fff;
#elif !defined(DOS) && defined(DOT)
- #define CLAMP_LIGHT(SSS, SST, maxs, maxt) \
+ #define CLAMP_LIGHT(SSS, SST) \
SSS = (SIGN17(SSS) >> 5) & 0x1fff; \
\
if (SST & 0x10000) \
@@ -145,7 +145,7 @@
SST = (SIGN17(SST) >> 5) & 0x1fff; \
}
#else
- #define CLAMP_LIGHT(SSS, SST, maxs, maxt) \
+ #define CLAMP_LIGHT(SSS, SST) \
SSS = (SIGN17(SSS) >> 5) & 0x1fff; \
SST = (SIGN17(SST) >> 5) & 0x1fff;
#endif
@@ -336,60 +336,53 @@
#endif
{
INT32 maxs, maxt;
- COLOR t0, t1, t2, t3, TEX;
- int sss2, sst2;
-
- INT32 SFRAC = 0, TFRAC = 0, INVSF = 0, INVTF = 0;
- INT32 R32, G32, B32, A32;
- INT32 maxs2, maxt2;
+ int sss2 = SSS + 32;
+ int sst2 = SST + 32;
TEXSHIFT(SSS, SST, maxs, maxt)
- sss2 = SSS + 32; sst2 = SST + 32;
- maxs2 = ((sss2 >> 3) >= tex_tile->sh);
- maxt2 = ((sst2 >> 3) >= tex_tile->th);
-
SSS = RELATIVE(SSS, tex_tile->sl);
SST = RELATIVE(SST, tex_tile->tl);
sss2 = RELATIVE(sss2, tex_tile->sl);
sst2 = RELATIVE(sst2, tex_tile->tl);
- SFRAC = SSS & 0x1f;
- TFRAC = SST & 0x1f;
+ INT32 SFRAC = SSS & 0x1f;
+ INT32 TFRAC = SST & 0x1f;
CLAMP(SSS, SST, maxs, maxt)
- CLAMP_LIGHT(sss2, sst2, maxs2, maxt2)
+ CLAMP_LIGHT(sss2, sst2)
MASK(&SSS, &SST, tex_tile);
MASK(&sss2, &sst2, tex_tile);
- t1.c = FETCH_TEXEL(sss2, SST);
- t2.c = FETCH_TEXEL(SSS, sst2);
+ COLOR t1 = { { FETCH_TEXEL(sss2, SST) } };
+ COLOR t2 = { { FETCH_TEXEL(SSS, sst2) } };
+ COLOR TEX;
if ((SFRAC + TFRAC) < 0x20)
{
- t0.c = FETCH_TEXEL(SSS, SST);
- R32 = t0.i.r + ((SFRAC*(t1.i.r - t0.i.r))>>5) + ((TFRAC*(t2.i.r - t0.i.r))>>5);
+ COLOR t0 = { { FETCH_TEXEL(SSS, SST) } };
+ INT32 R32 = t0.i.r + ((SFRAC*(t1.i.r - t0.i.r))>>5) + ((TFRAC*(t2.i.r - t0.i.r))>>5);
+ INT32 G32 = t0.i.g + ((SFRAC*(t1.i.g - t0.i.g))>>5) + ((TFRAC*(t2.i.g - t0.i.g))>>5);
+ INT32 B32 = t0.i.b + ((SFRAC*(t1.i.b - t0.i.b))>>5) + ((TFRAC*(t2.i.b - t0.i.b))>>5);
+ INT32 A32 = t0.i.a + ((SFRAC*(t1.i.a - t0.i.a))>>5) + ((TFRAC*(t2.i.a - t0.i.a))>>5);
TEX.i.r = (R32 < 0) ? 0 : R32;
- G32 = t0.i.g + ((SFRAC*(t1.i.g - t0.i.g))>>5) + ((TFRAC*(t2.i.g - t0.i.g))>>5);
TEX.i.g = (G32 < 0) ? 0 : G32;
- B32 = t0.i.b + ((SFRAC*(t1.i.b - t0.i.b))>>5) + ((TFRAC*(t2.i.b - t0.i.b))>>5);
TEX.i.b = (B32 < 0) ? 0 : B32;
- A32 = t0.i.a + ((SFRAC*(t1.i.a - t0.i.a))>>5) + ((TFRAC*(t2.i.a - t0.i.a))>>5);
TEX.i.a = (A32 < 0) ? 0 : A32;
}
else
{
- INVSF = 0x20 - SFRAC;
- INVTF = 0x20 - TFRAC;
- t3.c = FETCH_TEXEL(sss2, sst2);
- R32 = t3.i.r + ((INVSF*(t2.i.r - t3.i.r))>>5) + ((INVTF*(t1.i.r - t3.i.r))>>5);
+ INT32 INVSF = 0x20 - SFRAC;
+ INT32 INVTF = 0x20 - TFRAC;
+ COLOR t3 = { { FETCH_TEXEL(sss2, sst2) } };
+ INT32 R32 = t3.i.r + ((INVSF*(t2.i.r - t3.i.r))>>5) + ((INVTF*(t1.i.r - t3.i.r))>>5);
+ INT32 G32 = t3.i.g + ((INVSF*(t2.i.g - t3.i.g))>>5) + ((INVTF*(t1.i.g - t3.i.g))>>5);
+ INT32 B32 = t3.i.b + ((INVSF*(t2.i.b - t3.i.b))>>5) + ((INVTF*(t1.i.b - t3.i.b))>>5);
+ INT32 A32 = t3.i.a + ((INVSF*(t2.i.a - t3.i.a))>>5) + ((INVTF*(t1.i.a - t3.i.a))>>5);
TEX.i.r = (R32 < 0) ? 0 : R32;
- G32 = t3.i.g + ((INVSF*(t2.i.g - t3.i.g))>>5) + ((INVTF*(t1.i.g - t3.i.g))>>5);
TEX.i.g = (G32 < 0) ? 0 : G32;
- B32 = t3.i.b + ((INVSF*(t2.i.b - t3.i.b))>>5) + ((INVTF*(t1.i.b - t3.i.b))>>5);
TEX.i.b = (B32 < 0) ? 0 : B32;
- A32 = t3.i.a + ((INVSF*(t2.i.a - t3.i.a))>>5) + ((INVTF*(t1.i.a - t3.i.a))>>5);
TEX.i.a = (A32 < 0) ? 0 : A32;
}
@@ -523,63 +516,56 @@
#endif
{
INT32 maxs, maxt;
- COLOR t0, t1, t2, t3, TEX;
int sss2, sst2;
- INT32 SFRAC = 0, TFRAC = 0, INVSF = 0, INVTF = 0;
- INT32 R32, G32, B32, A32;
- INT32 maxs2, maxt2;
-
TEXSHIFT(SSS, SST, maxs, maxt)
sss2 = SSS + 32; sst2 = SST + 32;
- maxs2 = ((sss2 >> 3) >= tex_tile->sh);
- maxt2 = ((sst2 >> 3) >= tex_tile->th);
SSS = RELATIVE(SSS, tex_tile->sl);
SST = RELATIVE(SST, tex_tile->tl);
sss2 = RELATIVE(sss2, tex_tile->sl);
sst2 = RELATIVE(sst2, tex_tile->tl);
- SFRAC = SSS & 0x1f;
- TFRAC = SST & 0x1f;
+ INT32 SFRAC = SSS & 0x1f;
+ INT32 TFRAC = SST & 0x1f;
CLAMP(SSS, SST, maxs, maxt)
- CLAMP_LIGHT(sss2, sst2, maxs2, maxt2)
+ CLAMP_LIGHT(sss2, sst2)
MASK(&SSS, &SST, tex_tile);
MASK(&sss2, &sst2, tex_tile);
+ COLOR t0 = { { FETCH_TEXEL(SSS, SST) } };
+ COLOR t1 = { { FETCH_TEXEL(sss2, SST) } };
+ COLOR t2 = { { FETCH_TEXEL(SSS, sst2) } };
+ COLOR t3 = { { FETCH_TEXEL(sss2, sst2) } };
- t0.c = FETCH_TEXEL(SSS, SST);
- t1.c = FETCH_TEXEL(sss2, SST);
- t2.c = FETCH_TEXEL(SSS, sst2);
- t3.c = FETCH_TEXEL(sss2, sst2);
-
+ COLOR TEX;
if (SFRAC!= 0x10 || TFRAC != 0x10)
{
if ((SFRAC + TFRAC) >= 0x20)
{
- INVSF = 0x20 - SFRAC;
- INVTF = 0x20 - TFRAC;
- R32 = t3.i.r + ((INVSF*(t2.i.r - t3.i.r))>>5) + ((INVTF*(t1.i.r - t3.i.r))>>5);
+ INT32 INVSF = 0x20 - SFRAC;
+ INT32 INVTF = 0x20 - TFRAC;
+ INT32 R32 = t3.i.r + ((INVSF*(t2.i.r - t3.i.r))>>5) + ((INVTF*(t1.i.r - t3.i.r))>>5);
+ INT32 G32 = t3.i.g + ((INVSF*(t2.i.g - t3.i.g))>>5) + ((INVTF*(t1.i.g - t3.i.g))>>5);
+ INT32 B32 = t3.i.b + ((INVSF*(t2.i.b - t3.i.b))>>5) + ((INVTF*(t1.i.b - t3.i.b))>>5);
+ INT32 A32 = t3.i.a + ((INVSF*(t2.i.a - t3.i.a))>>5) + ((INVTF*(t1.i.a - t3.i.a))>>5);
TEX.i.r = (R32 < 0) ? 0 : R32;
- G32 = t3.i.g + ((INVSF*(t2.i.g - t3.i.g))>>5) + ((INVTF*(t1.i.g - t3.i.g))>>5);
TEX.i.g = (G32 < 0) ? 0 : G32;
- B32 = t3.i.b + ((INVSF*(t2.i.b - t3.i.b))>>5) + ((INVTF*(t1.i.b - t3.i.b))>>5);
TEX.i.b = (B32 < 0) ? 0 : B32;
- A32 = t3.i.a + ((INVSF*(t2.i.a - t3.i.a))>>5) + ((INVTF*(t1.i.a - t3.i.a))>>5);
TEX.i.a = (A32 < 0) ? 0 : A32;
}
else
{
- R32 = t0.i.r + ((SFRAC*(t1.i.r - t0.i.r))>>5) + ((TFRAC*(t2.i.r - t0.i.r))>>5);
+ INT32 R32 = t0.i.r + ((SFRAC*(t1.i.r - t0.i.r))>>5) + ((TFRAC*(t2.i.r - t0.i.r))>>5);
+ INT32 G32 = t0.i.g + ((SFRAC*(t1.i.g - t0.i.g))>>5) + ((TFRAC*(t2.i.g - t0.i.g))>>5);
+ INT32 B32 = t0.i.b + ((SFRAC*(t1.i.b - t0.i.b))>>5) + ((TFRAC*(t2.i.b - t0.i.b))>>5);
+ INT32 A32 = t0.i.a + ((SFRAC*(t1.i.a - t0.i.a))>>5) + ((TFRAC*(t2.i.a - t0.i.a))>>5);
TEX.i.r = (R32 < 0) ? 0 : R32;
- G32 = t0.i.g + ((SFRAC*(t1.i.g - t0.i.g))>>5) + ((TFRAC*(t2.i.g - t0.i.g))>>5);
TEX.i.g = (G32 < 0) ? 0 : G32;
- B32 = t0.i.b + ((SFRAC*(t1.i.b - t0.i.b))>>5) + ((TFRAC*(t2.i.b - t0.i.b))>>5);
TEX.i.b = (B32 < 0) ? 0 : B32;
- A32 = t0.i.a + ((SFRAC*(t1.i.a - t0.i.a))>>5) + ((TFRAC*(t2.i.a - t0.i.a))>>5);
TEX.i.a = (A32 < 0) ? 0 : A32;
}
}
diff --git a/src/mame/video/rdptrect.c b/src/mame/video/rdptrect.c
index 00368ab00ed..ac1dd8e2cab 100644
--- a/src/mame/video/rdptrect.c
+++ b/src/mame/video/rdptrect.c
@@ -43,25 +43,19 @@
UINT8 *zhb = &hidden_bits[zb_address >> 1];
#endif
- int i, j;
- int x1, x2, y1, y2;
- int s, t;
-
- int clipx1, clipx2, clipy1, clipy2;
-
UINT32 tilenum = rect->tilenum;
TILE *tex_tile = &tile[rect->tilenum];
- x1 = (rect->xh / 4);
- x2 = (rect->xl / 4);
- y1 = (rect->yh / 4);
- y2 = (rect->yl / 4);
+ int x1 = rect->xh;
+ int x2 = rect->xl;
+ int y1 = rect->yh;
+ int y2 = rect->yl;
- if (x2<=x1)
+ if (x2 <= x1)
{
x2 = x1 + 1;
}
- if (y1==y2)
+ if (y1 == y2)
{
y2 = y1 + 1; // Needed by Goldeneye
}
@@ -75,51 +69,46 @@
y2++;
}
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
-
calculate_clamp_diffs(tilenum);
shade_color.c = 0; // Needed by Pilotwings 64
CACHE_TEXTURE_PARAMS(tex_tile);
- if(y1 < clipy1)
+ if(y1 < clip.yh)
{
- rect->t += rect->dtdy * (clipy1 - y1);
- y1 = clipy1;
+ rect->t += rect->dtdy * (clip.yh - y1);
+ y1 = clip.yh;
}
- if(y2 > clipy2)
+ if(y2 > clip.yl)
{
- y2 = clipy2;
+ y2 = clip.yl;
}
- if(x1 < clipx1)
+ if(x1 < clip.xh)
{
- rect->s += rect->dsdx * (clipx1 - x1);
- x1 = clipx1;
+ rect->s += rect->dsdx * (clip.xh - x1);
+ x1 = clip.xh;
}
- if(x2 > clipx2)
+ if(x2 > clip.xl)
{
- x2 = clipx2;
+ x2 = clip.xl;
}
rect->dsdx >>= 5;
rect->dtdy >>= 5;
- t = ((int)(rect->t));
+ int t = ((int)(rect->t));
if(rect->flip)
{
- for (j = y1; j < y2; j++)
+ for (int j = y1; j < y2; j++)
{
int fb_index = j * fb_width;
#if defined(MAGICDITHER) || defined(BAYERDITHER)
int mline = (j & 3) << 2;
#endif
- s = ((int)(rect->s));
+ int s = ((int)(rect->s));
- for (i = x1; i < x2; i++)
+ for (int i = x1; i < x2; i++)
{
COLOR c;
#if defined(ZUPDATE)
@@ -184,16 +173,16 @@
}
else
{
- for (j = y1; j < y2; j++)
+ for (int j = y1; j < y2; j++)
{
int fb_index = j * fb_width;
#if defined(MAGICDITHER) || defined(BAYERDITHER)
int mline = (j & 3) << 2;
#endif
- s = ((int)(rect->s));
+ int s = ((int)(rect->s));
- for (i = x1; i < x2; i++)
+ for (int i = x1; i < x2; i++)
{
COLOR c;
#if defined(ZUPDATE)
@@ -308,27 +297,21 @@
UINT8 *zhb = &hidden_bits[zb_address >> 1];
#endif
- int i, j;
- int x1, x2, y1, y2;
- int s, t;
-
- int clipx1, clipx2, clipy1, clipy2;
-
UINT32 tilenum = rect->tilenum;
UINT32 tilenum2 = 0;
TILE *tex_tile = &tile[rect->tilenum];
TILE *tex_tile2 = NULL;
- x1 = (rect->xh / 4);
- x2 = (rect->xl / 4);
- y1 = (rect->yh / 4);
- y2 = (rect->yl / 4);
+ int x1 = rect->xh;
+ int x2 = rect->xl;
+ int y1 = rect->yh;
+ int y2 = rect->yl;
- if (x2<=x1)
+ if (x2 <= x1)
{
x2 = x1 + 1;
}
- if (y1==y2)
+ if (y1 == y2)
{
y2 = y1 + 1; // Needed by Goldeneye
}
@@ -342,11 +325,6 @@
y2++;
}
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
-
calculate_clamp_diffs(tilenum);
if (!other_modes.tex_lod_en)
@@ -362,44 +340,42 @@
shade_color.c = 0; // Needed by Pilotwings 64
- if(y1 < clipy1)
+ if(y1 < clip.yh)
{
- rect->t += rect->dtdy * (clipy1 - y1);
- y1 = clipy1;
+ rect->t += rect->dtdy * (clip.yh - y1);
+ y1 = clip.yh;
}
- if(y2 > clipy2)
+ if(y2 > clip.yl)
{
- y2 = clipy2;
+ y2 = clip.yl;
}
- if(x1 < clipx1)
+ if(x1 < clip.xh)
{
- rect->s += rect->dsdx * (clipx1 - x1);
- x1 = clipx1;
+ rect->s += rect->dsdx * (clip.xh - x1);
+ x1 = clip.xh;
}
- if(x2 > clipx2)
+ if(x2 > clip.xl)
{
- x2 = clipx2;
+ x2 = clip.xl;
}
rect->dsdx >>= 5;
rect->dtdy >>= 5;
- t = ((int)(rect->t));
+ int t = ((int)(rect->t));
if(rect->flip)
{
- for (j = y1; j < y2; j++)
+ for (int j = y1; j < y2; j++)
{
- //if (j >= clipy1 && j < clipy2)
{
int fb_index = j * fb_width;
#if defined(MAGICDITHER) || defined(BAYERDITHER)
int mline = (j & 3) << 2;
#endif
- s = (int)(rect->s);
+ int s = (int)(rect->s);
- for (i = x1; i < x2; i++)
+ for (int i = x1; i < x2; i++)
{
- //if (i >= clipx1 && i < clipx2)
{
COLOR c1, c2;
#if defined(ZUPDATE)
@@ -470,19 +446,17 @@
}
else
{
- for (j = y1; j < y2; j++)
+ for (int j = y1; j < y2; j++)
{
- //if (j >= clipy1 && j < clipy2)
{
int fb_index = j * fb_width;
#if defined(MAGICDITHER) || defined(BAYERDITHER)
int mline = (j & 3) << 2;
#endif
- s = (int)(rect->s);
+ int s = (int)(rect->s);
- for (i = x1; i < x2; i++)
+ for (int i = x1; i < x2; i++)
{
- //if (i >= clipx1 && i < clipx2)
{
COLOR c1, c2;
#if defined(ZUPDATE)
@@ -593,25 +567,19 @@
{
UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
- int i, j;
- int x1, x2, y1, y2;
- int s, t;
-
- int clipx1, clipx2, clipy1, clipy2;
-
UINT32 tilenum = rect->tilenum;
TILE *tex_tile = &tile[rect->tilenum];
- x1 = (rect->xh / 4);
- x2 = (rect->xl / 4);
- y1 = (rect->yh / 4);
- y2 = (rect->yl / 4);
+ int x1 = rect->xh;
+ int x2 = rect->xl;
+ int y1 = rect->yh;
+ int y2 = rect->yl;
- if (x2<=x1)
+ if (x2 <= x1)
{
x2 = x1 + 1;
}
- if (y1==y2)
+ if (y1 == y2)
{
y2 = y1 + 1; // Needed by Goldeneye
}
@@ -620,52 +588,45 @@
x2 += 1;
y2 += 1;
- clipx1 = clip.xh / 4;
- clipx2 = clip.xl / 4;
- clipy1 = clip.yh / 4;
- clipy2 = clip.yl / 4;
-
calculate_clamp_diffs(tilenum);
shade_color.c = 0; // Needed by Pilotwings 64
CACHE_TEXTURE_PARAMS(tex_tile);
- if(y1 < clipy1)
+ if(y1 < clip.yh)
{
- rect->t += rect->dtdy * (clipy1 - y1);
- y1 = clipy1;
+ rect->t += rect->dtdy * (clip.yh - y1);
+ y1 = clip.yh;
}
- if(y2 > clipy2)
+ if(y2 > clip.yl)
{
- y2 = clipy2;
+ y2 = clip.yl;
}
- if(x1 < clipx1)
+ if(x1 < clip.xh)
{
- rect->s += rect->dsdx * (clipx1 - x1);
- x1 = clipx1;
+ rect->s += rect->dsdx * (clip.xh - x1);
+ x1 = clip.xh;
}
- if(x2 > clipx2)
+ if(x2 > clip.xl)
{
- x2 = clipx2;
+ x2 = clip.xl;
}
rect->dsdx >>= 5;
rect->dtdy >>= 5;
- t = ((int)(rect->t));
+ int t = ((int)(rect->t));
if(rect->flip)
{
- for (j = y1; j < y2; j++)
+ for (int j = y1; j < y2; j++)
{
int fb_index = j * fb_width;
- //if (j >= clipy1 && j < clipy2)
{
- s = (int)(rect->s);
+ int s = (int)(rect->s);
- for (i = x1; i < x2; i++)
+ for (int i = x1; i < x2; i++)
{
- //if (i >= clipx1 && i < clipx2)
{
texel0_color.c = TEXTURE_PIPELINE(t, s, tex_tile);
@@ -684,25 +645,21 @@
}
else
{
- for (j = y1; j < y2; j++)
+ for (int j = y1; j < y2; j++)
{
int fb_index = j * fb_width;
- //if (j >= clipy1 && j < clipy2)
{
- s = (int)(rect->s);
+ int s = (int)(rect->s);
- for (i = x1; i < x2; i++)
+ for (int i = x1; i < x2; i++)
{
- //if (i >= clipx1 && i < clipx2)
- {
- texel0_color.c = TEXTURE_PIPELINE(s, t, tex_tile);
+ texel0_color.c = TEXTURE_PIPELINE(s, t, tex_tile);
- curpixel_cvg = 8;
+ curpixel_cvg = 8;
- if ((texel0_color.i.a != 0)||(!other_modes.alpha_compare_en))
- {
- fb[(fb_index + i) ^ WORD_ADDR_XOR] = ((texel0_color.i.r >> 3) << 11) | ((texel0_color.i.g >> 3) << 6) | ((texel0_color.i.b >> 3) << 1)|1;
- }
+ if ((texel0_color.i.a != 0)||(!other_modes.alpha_compare_en))
+ {
+ fb[(fb_index + i) ^ WORD_ADDR_XOR] = ((texel0_color.i.r >> 3) << 11) | ((texel0_color.i.g >> 3) << 6) | ((texel0_color.i.b >> 3) << 1)|1;
}
s += rect->dsdx;
}
diff --git a/src/mame/video/rdptri.c b/src/mame/video/rdptri.c
index 73a8f6959a3..5ce513c20d5 100644
--- a/src/mame/video/rdptri.c
+++ b/src/mame/video/rdptri.c
@@ -1,60 +1,42 @@
-static void triangle_ns_nt_nz(UINT32 w1, UINT32 w2)
-{
- int j;
- int xleft, xright, xleft_inc, xright_inc;
- int xstart, xend;
- int flip = (w1 & 0x800000) ? 1 : 0;
-
- INT32 yl, ym, yh;
- INT32 xl, xm, xh;
- INT32 dxldy, dxhdy, dxmdy;
- UINT32 w3, w4, w5, w6, w7, w8;
-
- int k = 0;
-
- INT32 limcvg = 0;
- INT32 startcvg = 0;
+#define addleft(x) addleftcvg(x,k)
+#define addright(x) addrightcvg(x,k)
- int sign_dxldy = 0;
- int sign_dxmdy = 0;
- int samesign = 0;
+#define setvalues() \
+{ \
+ addvalues(); \
+ adjust_attr(); \
+}
- int sign_dxhdy = 0;
+static void triangle_ns_nt_nz(UINT32 w1, UINT32 w2)
+{
+ int flip = (w1 & 0x800000) ? 1 : 0;
+ int sign = (w1 & 0x800000) ? -1 : 1;
+ int inv_sign = (w1 & 0x800000) ? 1 : -1;
int xfrac = 0;
- int m_inc;
- UINT32 min=0, max=3;
- INT32 maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;
-
- int spix = 0; // Current subpixel
- int ycur;
- int ylfar;
- int ldflag;
- int yhpix;
- int ympix;
- int ylpix;
-
-#define addleft(x) addleftcvg(x,k)
-#define addright(x) addrightcvg(x,k)
-
- w3 = rdp_cmd_data[rdp_cmd_cur+2];
- w4 = rdp_cmd_data[rdp_cmd_cur+3];
- w5 = rdp_cmd_data[rdp_cmd_cur+4];
- w6 = rdp_cmd_data[rdp_cmd_cur+5];
- w7 = rdp_cmd_data[rdp_cmd_cur+6];
- w8 = rdp_cmd_data[rdp_cmd_cur+7];
-
- yl = (w1 & 0x3fff);
- ym = ((w2 >> 16) & 0x3fff);
- yh = ((w2 >> 0) & 0x3fff);
- xl = (INT32)(w3 & 0x3fffffff);
- xh = (INT32)(w5 & 0x3fffffff);
- xm = (INT32)(w7 & 0x3fffffff);
+ INT32 maxxmx = 0;
+ INT32 minxmx = 0;
+ INT32 maxxhx = 0;
+ INT32 minxhx = 0;
+
+ UINT32 w3 = rdp_cmd_data[rdp_cmd_cur+2];
+ UINT32 w4 = rdp_cmd_data[rdp_cmd_cur+3];
+ UINT32 w5 = rdp_cmd_data[rdp_cmd_cur+4];
+ UINT32 w6 = rdp_cmd_data[rdp_cmd_cur+5];
+ UINT32 w7 = rdp_cmd_data[rdp_cmd_cur+6];
+ UINT32 w8 = rdp_cmd_data[rdp_cmd_cur+7];
+
+ INT32 yl = (w1 & 0x3fff);
+ INT32 ym = ((w2 >> 16) & 0x3fff);
+ INT32 yh = ((w2 >> 0) & 0x3fff);
+ INT32 xl = (INT32)(w3 & 0x3fffffff);
+ INT32 xh = (INT32)(w5 & 0x3fffffff);
+ INT32 xm = (INT32)(w7 & 0x3fffffff);
// Inverse slopes in 16.16 format
- dxldy = (INT32)(w4);
- dxhdy = (INT32)(w6);
- dxmdy = (INT32)(w8);
+ INT32 dxldy = (INT32)(w4);
+ INT32 dxhdy = (INT32)(w6);
+ INT32 dxmdy = (INT32)(w8);
max_level = ((w1 >> 19) & 7);
@@ -68,40 +50,38 @@ static void triangle_ns_nt_nz(UINT32 w1, UINT32 w2)
span[0].dymax = 0;
- xleft_inc = dxmdy >> 2;
- xright_inc = dxhdy >> 2;
+ int xleft_inc = dxmdy >> 2;
+ int xright_inc = dxhdy >> 2;
- xright = xh;
- xleft = xm;
+ int xright = xh;
+ int xleft = xm;
- limcvg = ((yl>>2) <= 1023) ? (yl>>2) : 1023; // Needed by 40 Winks
+ INT32 limcvg = ((yl>>2) <= 1023) ? (yl>>2) : 1023; // Needed by 40 Winks
if (limcvg < 0)
{
limcvg = 0;
}
- startcvg = ((yh>>2)>=0) ? (yh>>2) : 0;
- for (k = startcvg; k <= limcvg; k++)
+ INT32 startcvg = ((yh>>2)>=0) ? (yh>>2) : 0;
+ for (int k = startcvg; k <= limcvg; k++)
{
memset((void*)&span[k].cvg[0],0,640);
}
- sign_dxldy = (dxldy & 0x80000000) ? 1 : 0;
- sign_dxmdy = (dxmdy & 0x80000000) ? 1 : 0;
- samesign = !(sign_dxldy ^ sign_dxmdy);
+ int sign_dxhdy = (dxhdy & 0x80000000) ? 1 : 0;
- sign_dxhdy = (dxhdy & 0x80000000) ? 1 : 0;
+ int ycur = yh & ~3;
+ int ylfar = yl | 3;
+ int ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
+ int yhpix = yh >> 2;
+ int ylpix = yl >> 2;
- m_inc = flip ? 1 : -1;
-
- ycur = yh & ~3;
- ylfar = yl | 3;
- ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
- yhpix = yh >> 2;
- ympix = ym >> 2;
- ylpix = yl >> 2;
+ if(ylfar >= 0x1000)
+ {
+ ylfar = 0x0fff;
+ }
- for (k = ycur; k <= ylfar; k++)
+ for (int k = ycur; k <= ylfar; k++)
{
if (k == ym)
{
@@ -109,116 +89,111 @@ static void triangle_ns_nt_nz(UINT32 w1, UINT32 w2)
xleft_inc = dxldy >> 2;
}
- xstart = xleft >> 16;
- xend = xright >> 16;
- j = k >> 2;
- spix = k & 3;
+ int xstart = xleft >> 16;
+ int xend = xright >> 16;
+ int j = k >> 2;
+ int spix = k & 3;
- if (k >= 0 && k < 0x1000)
+ UINT32 min = 0;
+ UINT32 max = 3;
+ if (j == yhpix)
{
- int m = 0;
- int n = 0;
- int length = 0;
- min = 0; max = 3;
- if (j == yhpix)
+ min = yh & 3;
+ }
+ if (j == ylpix)
+ {
+ max = yl & 3;
+ }
+ if (spix >= min && spix <= max)
+ {
+ if (spix == min)
{
- min = yh & 3;
+ minxmx = maxxmx = xstart;
+ minxhx = maxxhx = xend;
}
- if (j == ylpix)
+ else
{
- max = yl & 3;
+ minxmx = (xstart < minxmx) ? xstart : minxmx;
+ maxxmx = (xstart > maxxmx) ? xstart : maxxmx;
+ minxhx = (xend < minxhx) ? xend : minxhx;
+ maxxhx = (xend > maxxhx) ? xend : maxxhx;
}
- if (spix >= min && spix <= max)
+ }
+
+ if (spix == max)
+ {
+ if (flip)
{
- if (spix == min)
- {
- minxmx = maxxmx = xstart;
- minxhx = maxxhx = xend;
- }
- else
- {
- minxmx = (xstart < minxmx) ? xstart : minxmx;
- maxxmx = (xstart > maxxmx) ? xstart : maxxmx;
- minxhx = (xend < minxhx) ? xend : minxhx;
- maxxhx = (xend > maxxhx) ? xend : maxxhx;
- }
+ span[j].lx = maxxmx;
+ span[j].rx = minxhx;
}
+ else
+ {
+ span[j].lx = minxmx;
+ span[j].rx = maxxhx;
+ }
+ }
- if (spix == max)
+ int length = (xend - xstart) * sign;
+
+ if (spix == ldflag)
+ {
+ xfrac = ((xright >> 8) & 0xff);
+ }
+
+ int m = flip ? (xend+1) : (xend-1);
+
+ if (k >= yh && length >= 0 && k <= yl)
+ {
+ if (xstart>=0 && xstart <1024)
{
- if (flip)
+ if (!flip)
{
- span[j].lx = maxxmx;
- span[j].rx = minxhx;
+ span[j].cvg[xstart] += addleft(xleft);
}
else
{
- span[j].lx = minxmx;
- span[j].rx = maxxhx;
+ span[j].cvg[xstart] += addright(xleft);
}
}
-
- length = flip ? (xstart - xend) : (xend - xstart);
-
- if (spix == ldflag)
+ if (xend>=0 && xend<1024)
{
- xfrac = ((xright >> 8) & 0xff);
- }
-
- m = flip ? (xend+1) : (xend-1);
-
- if (k >= yh && length >= 0 && k <= yl)
- {
- if (xstart>=0 && xstart <1024)
+ if (xstart != xend)
{
if (!flip)
{
- span[j].cvg[xstart] += addleft(xleft);
+ span[j].cvg[xend] += addright(xright);
}
else
{
- span[j].cvg[xstart] += addright(xleft);
+ span[j].cvg[xend] += addleft(xright);
}
}
- if (xend>=0 && xend<1024)
+ else
{
- if (xstart != xend)
+ if (!flip)
{
- if (!flip)
- {
- span[j].cvg[xend] += addright(xright);
- }
- else
- {
- span[j].cvg[xend] += addleft(xright);
- }
+ span[j].cvg[xend] -= (2 - addright(xright));
}
else
{
- if (!flip)
- {
- span[j].cvg[xend] -= (2 - addright(xright));
- }
- else
- {
- span[j].cvg[xend] -= (2 - addleft(xright));
- }
- if (span[j].cvg[xend] > 200)
- {
- span[j].cvg[xend] = 0;
- }
+ span[j].cvg[xend] -= (2 - addleft(xright));
}
- }
- for (n = 0; n < (length - 1); n++)
- {
- if (m>=0 && m < 640)
+ if (span[j].cvg[xend] > 200)
{
- span[j].cvg[m] += 2;
+ span[j].cvg[xend] = 0;
}
-
- m += m_inc;
}
}
+ for (int n = 0; n < (length - 1); n++)
+ {
+ if (m >= 0 && m < 640)
+ {
+ span[j].cvg[m] += 2;
+ }
+
+ m += inv_sign;
+ }
}
xleft += xleft_inc;
@@ -243,76 +218,36 @@ static void triangle_ns_nt_nz(UINT32 w1, UINT32 w2)
static void triangle_ns_nt_z(UINT32 w1, UINT32 w2)
{
- int j;
- int xleft, xright, xleft_inc, xright_inc;
- int xstart, xend;
- int z = 0;
- int dzdx = 0;
- int dzdy = 0;
- int dzde = 0;
- int tilenum;
- int flip = (w1 & 0x800000) ? 1 : 0;
-
- INT32 yl, ym, yh;
- INT32 xl, xm, xh;
- INT32 dxldy, dxhdy, dxmdy;
- int dzdy_dz, dzdx_dz;
- UINT32 w3, w4, w5, w6, w7, w8;
-
- int k = 0;
-
- INT32 limcvg = 0;
- INT32 startcvg = 0;
-
- int sign_dxldy = 0;
- int sign_dxmdy = 0;
- int samesign = 0;
-
- int dzdiff = 0;
- int sign_dxhdy = 0;
-
- int dzdeh = 0, dzdyh = 0;
- int do_offset = 0;
+ int flip = (w1 & 0x800000) ? 1 : 0;
+ int sign = (w1 & 0x800000) ? -1 : 1;
+ int inv_sign = (w1 & 0x800000) ? 1 : -1;
int xfrac = 0;
- int dzeoff = 0;
- int dzdxh = 0;
-
- int m_inc;
- UINT32 min=0, max=3;
INT32 maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;
- int spix = 0; // Current subpixel
- int ycur;
- int ylfar;
- int ldflag;
- int yhpix;
- int ympix;
- int ylpix;
-
int zbuffer_base = rdp_cmd_cur + 8;
- w3 = rdp_cmd_data[rdp_cmd_cur+2];
- w4 = rdp_cmd_data[rdp_cmd_cur+3];
- w5 = rdp_cmd_data[rdp_cmd_cur+4];
- w6 = rdp_cmd_data[rdp_cmd_cur+5];
- w7 = rdp_cmd_data[rdp_cmd_cur+6];
- w8 = rdp_cmd_data[rdp_cmd_cur+7];
-
- yl = (w1 & 0x3fff);
- ym = ((w2 >> 16) & 0x3fff);
- yh = ((w2 >> 0) & 0x3fff);
- xl = (INT32)(w3 & 0x3fffffff);
- xh = (INT32)(w5 & 0x3fffffff);
- xm = (INT32)(w7 & 0x3fffffff);
+ UINT32 w3 = rdp_cmd_data[rdp_cmd_cur+2];
+ UINT32 w4 = rdp_cmd_data[rdp_cmd_cur+3];
+ UINT32 w5 = rdp_cmd_data[rdp_cmd_cur+4];
+ UINT32 w6 = rdp_cmd_data[rdp_cmd_cur+5];
+ UINT32 w7 = rdp_cmd_data[rdp_cmd_cur+6];
+ UINT32 w8 = rdp_cmd_data[rdp_cmd_cur+7];
+
+ INT32 yl = (w1 & 0x3fff);
+ INT32 ym = ((w2 >> 16) & 0x3fff);
+ INT32 yh = ((w2 >> 0) & 0x3fff);
+ INT32 xl = (INT32)(w3 & 0x3fffffff);
+ INT32 xh = (INT32)(w5 & 0x3fffffff);
+ INT32 xm = (INT32)(w7 & 0x3fffffff);
// Inverse slopes in 16.16 format
- dxldy = (INT32)(w4);
- dxhdy = (INT32)(w6);
- dxmdy = (INT32)(w8);
+ INT32 dxldy = (INT32)(w4);
+ INT32 dxhdy = (INT32)(w6);
+ INT32 dxmdy = (INT32)(w8);
max_level = ((w1 >> 19) & 7);
- tilenum = (w1 >> 16) & 0x7;
+ int tilenum = (w1 >> 16) & 0x7;
if (yl & 0x2000) yl |= 0xffffc000;
if (ym & 0x2000) ym |= 0xffffc000;
@@ -322,72 +257,56 @@ static void triangle_ns_nt_z(UINT32 w1, UINT32 w2)
if (xm & 0x20000000) xm |= 0xc0000000;
if (xh & 0x20000000) xh |= 0xc0000000;
- z = rdp_cmd_data[zbuffer_base+0];
- dzdx = rdp_cmd_data[zbuffer_base+1];
- dzde = rdp_cmd_data[zbuffer_base+2];
- dzdy = rdp_cmd_data[zbuffer_base+3];
+ int z = rdp_cmd_data[zbuffer_base+0];
+ int dzdx = rdp_cmd_data[zbuffer_base+1];
+ int dzde = rdp_cmd_data[zbuffer_base+2];
+ int dzdy = rdp_cmd_data[zbuffer_base+3];
+ int dzdiff = 0;
+ int dzeoff = 0;
+ int dzdeh = 0;
+ int dzdyh = 0;
+ int dzdxh = dzdx >> 8;
+
+ int dzdy_dz = (dzdy >> 16) & 0xffff;
+ int dzdx_dz = (dzdx >> 16) & 0xffff;
span[0].dz.w = dzdx;
- dzdy_dz = (dzdy >> 16) & 0xffff;
- dzdx_dz = (dzdx >> 16) & 0xffff;
span[0].dzpix = ((dzdy_dz & 0x8000) ? ((~dzdy_dz) & 0x7fff) : dzdy_dz) + ((dzdx_dz & 0x8000) ? ((~dzdx_dz) & 0x7fff) : dzdx_dz);
span[0].dzpix = normalize_dzpix(span[0].dzpix);
- xleft_inc = dxmdy >> 2;
- xright_inc = dxhdy >> 2;
+ int xleft_inc = dxmdy >> 2;
+ int xright_inc = dxhdy >> 2;
- xright = xh;
- xleft = xm;
+ int xright = xh;
+ int xleft = xm;
- limcvg = ((yl>>2) <= 1023) ? (yl>>2) : 1023; // Needed by 40 Winks
+ INT32 limcvg = ((yl>>2) <= 1023) ? (yl>>2) : 1023; // Needed by 40 Winks
if (limcvg < 0)
{
limcvg = 0;
}
- startcvg = ((yh>>2)>=0) ? (yh>>2) : 0;
- for (k = startcvg; k <= limcvg; k++)
+ INT32 startcvg = ((yh>>2)>=0) ? (yh>>2) : 0;
+ for (int k = startcvg; k <= limcvg; k++)
{
memset((void*)&span[k].cvg[0],0,640);
}
- sign_dxldy = (dxldy & 0x80000000) ? 1 : 0;
- sign_dxmdy = (dxmdy & 0x80000000) ? 1 : 0;
- samesign = !(sign_dxldy ^ sign_dxmdy);
-
- sign_dxhdy = (dxhdy & 0x80000000) ? 1 : 0;
+ int sign_dxhdy = (dxhdy & 0x80000000) ? 1 : 0;
- do_offset = !(sign_dxhdy ^ (flip));
-
- if (do_offset)
+ if (!(sign_dxhdy ^ (flip)))
{
- dzdeh = dzde >> 9; dzdyh = dzdy >> 9;
-
+ dzdeh = dzde >> 9;
+ dzdyh = dzdy >> 9;
dzdiff = (dzdeh*3 - dzdyh*3) << 7;
- }
- else
- {
- dzdiff = 0;
- }
-
- if (do_offset)
- {
dzeoff = (dzdeh*3) << 7;
}
else
{
+ dzdiff = 0;
dzeoff = 0;
}
-#define addleft(x) addleftcvg(x,k)
-#define addright(x) addrightcvg(x,k)
-#define setvalues() { \
- addvalues(); \
- adjust_attr(); \
-}
-
- dzdxh = dzdx >> 8;
-
#define adjust_attr() \
{ \
span[j].z.w = z + dzdiff - (xfrac * dzdxh); \
@@ -397,16 +316,18 @@ static void triangle_ns_nt_z(UINT32 w1, UINT32 w2)
z += dzde; \
}
- m_inc = flip ? 1 : -1;
+ int ycur = yh & ~3;
+ int ylfar = yl | 3;
+ int ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
+ int yhpix = yh >> 2;
+ int ylpix = yl >> 2;
- ycur = yh & ~3;
- ylfar = yl | 3;
- ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
- yhpix = yh >> 2;
- ympix = ym >> 2;
- ylpix = yl >> 2;
+ if(ylfar >= 0x1000)
+ {
+ ylfar = 0x0fff;
+ }
- for (k = ycur; k <= ylfar; k++)
+ for (int k = ycur; k <= ylfar; k++)
{
if (k == ym)
{
@@ -414,17 +335,16 @@ static void triangle_ns_nt_z(UINT32 w1, UINT32 w2)
xleft_inc = dxldy >> 2;
}
- xstart = xleft >> 16;
- xend = xright >> 16;
- j = k >> 2;
- spix = k & 3;
+ int xstart = xleft >> 16;
+ int xend = xright >> 16;
+ int j = k >> 2;
+ int spix = k & 3;
- if (k >= 0 && k < 0x1000)
+ //if (k >= 0 && k < 0x1000)
{
- int m = 0;
int n = 0;
- int length = 0;
- min = 0; max = 3;
+ UINT32 min = 0;
+ UINT32 max = 3;
if (j == yhpix)
{
min = yh & 3;
@@ -463,7 +383,7 @@ static void triangle_ns_nt_z(UINT32 w1, UINT32 w2)
}
}
- length = flip ? (xstart - xend) : (xend - xstart);
+ int length = (xend - xstart) * sign;
if (spix == ldflag)
{
@@ -471,7 +391,7 @@ static void triangle_ns_nt_z(UINT32 w1, UINT32 w2)
adjust_attr();
}
- m = flip ? (xend+1) : (xend-1);
+ int m = flip ? (xend+1) : (xend-1);
if (k >= yh && length >= 0 && k <= yl)
{
@@ -522,7 +442,7 @@ static void triangle_ns_nt_z(UINT32 w1, UINT32 w2)
span[j].cvg[m] += 2;
}
- m += m_inc;
+ m += inv_sign;
}
}
}
@@ -552,9 +472,6 @@ static void triangle_ns_nt_z(UINT32 w1, UINT32 w2)
}
#undef addvalues
#undef adjust_attr
-#undef addleft
-#undef addright
-#undef setvalues
static void triangle_ns_t_nz(UINT32 w1, UINT32 w2)
{
@@ -567,6 +484,8 @@ static void triangle_ns_t_nz(UINT32 w1, UINT32 w2)
int dsde = 0, dtde = 0, dwde = 0;
int tilenum;
int flip = (w1 & 0x800000) ? 1 : 0;
+ int sign = (w1 & 0x800000) ? -1 : 1;
+ int inv_sign = (w1 & 0x800000) ? 1 : -1;
INT32 yl, ym, yh;
INT32 xl, xm, xh;
@@ -593,7 +512,6 @@ static void triangle_ns_t_nz(UINT32 w1, UINT32 w2)
int dsdxh = 0, dtdxh = 0, dwdxh = 0;
- int m_inc;
UINT32 min=0, max=3;
INT32 maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;
@@ -707,13 +625,6 @@ static void triangle_ns_t_nz(UINT32 w1, UINT32 w2)
dseoff = dteoff = dweoff;
}
-#define addleft(x) addleftcvg(x,k)
-#define addright(x) addrightcvg(x,k)
-#define setvalues() { \
- addvalues(); \
- adjust_attr(); \
-}
-
dsdxh = dsdx >> 8;
dtdxh = dtdx >> 8;
dwdxh = dwdx >> 8;
@@ -731,8 +642,6 @@ static void triangle_ns_t_nz(UINT32 w1, UINT32 w2)
w += dwde; \
}
- m_inc = flip ? 1 : -1;
-
ycur = yh & ~3;
ylfar = yl | 3;
ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
@@ -740,6 +649,11 @@ static void triangle_ns_t_nz(UINT32 w1, UINT32 w2)
ympix = ym >> 2;
ylpix = yl >> 2;
+ if(ylfar >= 0x1000)
+ {
+ ylfar = 0x0fff;
+ }
+
for (k = ycur; k <= ylfar; k++)
{
if (k == ym)
@@ -753,11 +667,10 @@ static void triangle_ns_t_nz(UINT32 w1, UINT32 w2)
j = k >> 2;
spix = k & 3;
- if (k >= 0 && k < 0x1000)
+ //if (k >= 0 && k < 0x1000)
{
int m = 0;
int n = 0;
- int length = 0;
min = 0; max = 3;
if (j == yhpix)
{
@@ -797,7 +710,7 @@ static void triangle_ns_t_nz(UINT32 w1, UINT32 w2)
}
}
- length = flip ? (xstart - xend) : (xend - xstart);
+ int length = (xend - xstart) * sign;
if (spix == ldflag)
{
@@ -856,7 +769,7 @@ static void triangle_ns_t_nz(UINT32 w1, UINT32 w2)
span[j].cvg[m] += 2;
}
- m += m_inc;
+ m += inv_sign;
}
}
}
@@ -886,9 +799,6 @@ static void triangle_ns_t_nz(UINT32 w1, UINT32 w2)
}
#undef addvalues
#undef adjust_attr
-#undef addleft
-#undef addright
-#undef setvalues
static void triangle_ns_t_z(UINT32 w1, UINT32 w2)
{
@@ -901,6 +811,8 @@ static void triangle_ns_t_z(UINT32 w1, UINT32 w2)
int dzde = 0, dsde = 0, dtde = 0, dwde = 0;
int tilenum;
int flip = (w1 & 0x800000) ? 1 : 0;
+ int sign = (w1 & 0x800000) ? -1 : 1;
+ int inv_sign = (w1 & 0x800000) ? 1 : -1;
INT32 yl, ym, yh;
INT32 xl, xm, xh;
@@ -929,7 +841,6 @@ static void triangle_ns_t_z(UINT32 w1, UINT32 w2)
int dsdxh = 0, dtdxh = 0, dwdxh = 0, dzdxh = 0;
- int m_inc;
UINT32 min=0, max=3;
INT32 maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;
@@ -1070,13 +981,6 @@ static void triangle_ns_t_z(UINT32 w1, UINT32 w2)
dseoff = dteoff = dweoff = dzeoff = 0;
}
-#define addleft(x) addleftcvg(x,k)
-#define addright(x) addrightcvg(x,k)
-#define setvalues() { \
- addvalues(); \
- adjust_attr(); \
-}
-
dsdxh = dsdx >> 8;
dtdxh = dtdx >> 8;
dwdxh = dwdx >> 8;
@@ -1097,8 +1001,6 @@ static void triangle_ns_t_z(UINT32 w1, UINT32 w2)
z += dzde; \
}
- m_inc = flip ? 1 : -1;
-
ycur = yh & ~3;
ylfar = yl | 3;
ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
@@ -1106,6 +1008,11 @@ static void triangle_ns_t_z(UINT32 w1, UINT32 w2)
ympix = ym >> 2;
ylpix = yl >> 2;
+ if(ylfar >= 0x1000)
+ {
+ ylfar = 0x0fff;
+ }
+
for (k = ycur; k <= ylfar; k++)
{
if (k == ym)
@@ -1119,11 +1026,10 @@ static void triangle_ns_t_z(UINT32 w1, UINT32 w2)
j = k >> 2;
spix = k & 3;
- if (k >= 0 && k < 0x1000)
+ //if (k >= 0 && k < 0x1000)
{
int m = 0;
int n = 0;
- int length = 0;
min = 0; max = 3;
if (j == yhpix)
{
@@ -1163,7 +1069,7 @@ static void triangle_ns_t_z(UINT32 w1, UINT32 w2)
}
}
- length = flip ? (xstart - xend) : (xend - xstart);
+ int length = (xend - xstart) * sign;
if (spix == ldflag)
{
@@ -1222,7 +1128,7 @@ static void triangle_ns_t_z(UINT32 w1, UINT32 w2)
span[j].cvg[m] += 2;
}
- m += m_inc;
+ m += inv_sign;
}
}
}
@@ -1252,9 +1158,6 @@ static void triangle_ns_t_z(UINT32 w1, UINT32 w2)
}
#undef addvalues
#undef adjust_attr
-#undef addleft
-#undef addright
-#undef setvalues
static void triangle_s_nt_nz(UINT32 w1, UINT32 w2)
{
@@ -1268,6 +1171,8 @@ static void triangle_s_nt_nz(UINT32 w1, UINT32 w2)
int drde = 0, dgde = 0, dbde = 0, dade = 0;
int tilenum;
int flip = (w1 & 0x800000) ? 1 : 0;
+ int sign = (w1 & 0x800000) ? -1 : 1;
+ int inv_sign = (w1 & 0x800000) ? 1 : -1;
INT32 yl, ym, yh;
INT32 xl, xm, xh;
@@ -1294,7 +1199,6 @@ static void triangle_s_nt_nz(UINT32 w1, UINT32 w2)
int drdxh = 0, dgdxh = 0, dbdxh = 0, dadxh = 0;
- int m_inc;
UINT32 min=0, max=3;
INT32 maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;
@@ -1416,13 +1320,6 @@ static void triangle_s_nt_nz(UINT32 w1, UINT32 w2)
dreoff = dgeoff = dbeoff = daeoff;
}
-#define addleft(x) addleftcvg(x,k)
-#define addright(x) addrightcvg(x,k)
-#define setvalues() { \
- addvalues(); \
- adjust_attr(); \
-}
-
drdxh = drdx >> 8;
dgdxh = dgdx >> 8;
dbdxh = dbdx >> 8;
@@ -1443,8 +1340,6 @@ static void triangle_s_nt_nz(UINT32 w1, UINT32 w2)
a += dade; \
}
- m_inc = flip ? 1 : -1;
-
ycur = yh & ~3;
ylfar = yl | 3;
ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
@@ -1452,6 +1347,11 @@ static void triangle_s_nt_nz(UINT32 w1, UINT32 w2)
ympix = ym >> 2;
ylpix = yl >> 2;
+ if(ylfar >= 0x1000)
+ {
+ ylfar = 0x0fff;
+ }
+
for (k = ycur; k <= ylfar; k++)
{
if (k == ym)
@@ -1465,11 +1365,10 @@ static void triangle_s_nt_nz(UINT32 w1, UINT32 w2)
j = k >> 2;
spix = k & 3;
- if (k >= 0 && k < 0x1000)
+ //if (k >= 0 && k < 0x1000)
{
int m = 0;
int n = 0;
- int length = 0;
min = 0; max = 3;
if (j == yhpix)
{
@@ -1509,7 +1408,7 @@ static void triangle_s_nt_nz(UINT32 w1, UINT32 w2)
}
}
- length = flip ? (xstart - xend) : (xend - xstart);
+ int length = (xend - xstart) * sign;
if (spix == ldflag)
{
@@ -1568,7 +1467,7 @@ static void triangle_s_nt_nz(UINT32 w1, UINT32 w2)
span[j].cvg[m] += 2;
}
- m += m_inc;
+ m += inv_sign;
}
}
}
@@ -1598,9 +1497,6 @@ static void triangle_s_nt_nz(UINT32 w1, UINT32 w2)
}
#undef addvalues
#undef adjust_attr
-#undef addleft
-#undef addright
-#undef setvalues
static void triangle_s_nt_z(UINT32 w1, UINT32 w2)
{
@@ -1614,6 +1510,8 @@ static void triangle_s_nt_z(UINT32 w1, UINT32 w2)
int drde = 0, dgde = 0, dbde = 0, dade = 0, dzde = 0;
int tilenum;
int flip = (w1 & 0x800000) ? 1 : 0;
+ int sign = (w1 & 0x800000) ? -1 : 1;
+ int inv_sign = (w1 & 0x800000) ? 1 : -1;
INT32 yl, ym, yh;
INT32 xl, xm, xh;
@@ -1641,7 +1539,6 @@ static void triangle_s_nt_z(UINT32 w1, UINT32 w2)
int drdxh = 0, dgdxh = 0, dbdxh = 0, dadxh = 0, dzdxh = 0;
- int m_inc;
UINT32 min=0, max=3;
INT32 maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;
@@ -1779,13 +1676,6 @@ static void triangle_s_nt_z(UINT32 w1, UINT32 w2)
dreoff = dgeoff = dbeoff = daeoff = dzeoff = 0;
}
-#define addleft(x) addleftcvg(x,k)
-#define addright(x) addrightcvg(x,k)
-#define setvalues() { \
- addvalues(); \
- adjust_attr(); \
-}
-
drdxh = drdx >> 8;
dgdxh = dgdx >> 8;
dbdxh = dbdx >> 8;
@@ -1809,8 +1699,6 @@ static void triangle_s_nt_z(UINT32 w1, UINT32 w2)
z += dzde; \
}
- m_inc = flip ? 1 : -1;
-
ycur = yh & ~3;
ylfar = yl | 3;
ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
@@ -1818,6 +1706,11 @@ static void triangle_s_nt_z(UINT32 w1, UINT32 w2)
ympix = ym >> 2;
ylpix = yl >> 2;
+ if(ylfar >= 0x1000)
+ {
+ ylfar = 0x0fff;
+ }
+
for (k = ycur; k <= ylfar; k++)
{
if (k == ym)
@@ -1831,11 +1724,10 @@ static void triangle_s_nt_z(UINT32 w1, UINT32 w2)
j = k >> 2;
spix = k & 3;
- if (k >= 0 && k < 0x1000)
+ //if (k >= 0 && k < 0x1000)
{
int m = 0;
int n = 0;
- int length = 0;
min = 0; max = 3;
if (j == yhpix)
{
@@ -1875,7 +1767,7 @@ static void triangle_s_nt_z(UINT32 w1, UINT32 w2)
}
}
- length = flip ? (xstart - xend) : (xend - xstart);
+ int length = (xend - xstart) * sign;
if (spix == ldflag)
{
@@ -1934,7 +1826,7 @@ static void triangle_s_nt_z(UINT32 w1, UINT32 w2)
span[j].cvg[m] += 2;
}
- m += m_inc;
+ m += inv_sign;
}
}
}
@@ -1964,9 +1856,6 @@ static void triangle_s_nt_z(UINT32 w1, UINT32 w2)
}
#undef addvalues
#undef adjust_attr
-#undef addleft
-#undef addright
-#undef setvalues
static void triangle_s_t_nz(UINT32 w1, UINT32 w2)
{
@@ -1980,6 +1869,8 @@ static void triangle_s_t_nz(UINT32 w1, UINT32 w2)
int drde = 0, dgde = 0, dbde = 0, dade = 0, dsde = 0, dtde = 0, dwde = 0;
int tilenum;
int flip = (w1 & 0x800000) ? 1 : 0;
+ int sign = (w1 & 0x800000) ? -1 : 1;
+ int inv_sign = (w1 & 0x800000) ? 1 : -1;
INT32 yl, ym, yh;
INT32 xl, xm, xh;
@@ -2007,7 +1898,6 @@ static void triangle_s_t_nz(UINT32 w1, UINT32 w2)
int dsdxh = 0, dtdxh = 0, dwdxh = 0, drdxh = 0, dgdxh = 0, dbdxh = 0, dadxh = 0;
- int m_inc;
UINT32 min=0, max=3;
INT32 maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;
@@ -2168,13 +2058,6 @@ static void triangle_s_t_nz(UINT32 w1, UINT32 w2)
dseoff = dteoff = dweoff = dreoff = dgeoff = dbeoff = daeoff = 0;
}
-#define addleft(x) addleftcvg(x,k)
-#define addright(x) addrightcvg(x,k)
-#define setvalues() { \
- addvalues(); \
- adjust_attr(); \
-}
-
dsdxh = dsdx >> 8;
dtdxh = dtdx >> 8;
dwdxh = dwdx >> 8;
@@ -2204,8 +2087,6 @@ static void triangle_s_t_nz(UINT32 w1, UINT32 w2)
a += dade; \
}
- m_inc = flip ? 1 : -1;
-
ycur = yh & ~3;
ylfar = yl | 3;
ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
@@ -2213,6 +2094,11 @@ static void triangle_s_t_nz(UINT32 w1, UINT32 w2)
ympix = ym >> 2;
ylpix = yl >> 2;
+ if(ylfar >= 0x1000)
+ {
+ ylfar = 0x0fff;
+ }
+
for (k = ycur; k <= ylfar; k++)
{
if (k == ym)
@@ -2226,11 +2112,10 @@ static void triangle_s_t_nz(UINT32 w1, UINT32 w2)
j = k >> 2;
spix = k & 3;
- if (k >= 0 && k < 0x1000)
+ //if (k >= 0 && k < 0x1000)
{
int m = 0;
int n = 0;
- int length = 0;
min = 0; max = 3;
if (j == yhpix)
{
@@ -2270,7 +2155,7 @@ static void triangle_s_t_nz(UINT32 w1, UINT32 w2)
}
}
- length = flip ? (xstart - xend) : (xend - xstart);
+ int length = (xend - xstart) * sign;
if (spix == ldflag)
{
@@ -2329,7 +2214,7 @@ static void triangle_s_t_nz(UINT32 w1, UINT32 w2)
span[j].cvg[m] += 2;
}
- m += m_inc;
+ m += inv_sign;
}
}
}
@@ -2359,9 +2244,6 @@ static void triangle_s_t_nz(UINT32 w1, UINT32 w2)
}
#undef addvalues
#undef adjust_attr
-#undef addleft
-#undef addright
-#undef setvalues
static void triangle_s_t_z(UINT32 w1, UINT32 w2)
{
@@ -2375,6 +2257,8 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
int drde = 0, dgde = 0, dbde = 0, dade = 0, dzde = 0, dsde = 0, dtde = 0, dwde = 0;
int tilenum;
int flip = (w1 & 0x800000) ? 1 : 0;
+ int sign = (w1 & 0x800000) ? -1 : 1;
+ int inv_sign = (w1 & 0x800000) ? 1 : -1;
INT32 yl, ym, yh;
INT32 xl, xm, xh;
@@ -2403,7 +2287,6 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
int dsdxh = 0, dtdxh = 0, dwdxh = 0, drdxh = 0, dgdxh = 0, dbdxh = 0, dadxh = 0, dzdxh = 0;
- int m_inc;
UINT32 min=0, max=3;
INT32 maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;
@@ -2576,13 +2459,6 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
dseoff = dteoff = dweoff = dreoff = dgeoff = dbeoff = daeoff = dzeoff = 0;
}
-#define addleft(x) addleftcvg(x,k)
-#define addright(x) addrightcvg(x,k)
-#define setvalues() { \
- addvalues(); \
- adjust_attr(); \
-}
-
dsdxh = dsdx >> 8;
dtdxh = dtdx >> 8;
dwdxh = dwdx >> 8;
@@ -2615,8 +2491,6 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
z += dzde; \
}
- m_inc = flip ? 1 : -1;
-
ycur = yh & ~3;
ylfar = yl | 3;
ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
@@ -2624,6 +2498,11 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
ympix = ym >> 2;
ylpix = yl >> 2;
+ if(ylfar >= 0x1000)
+ {
+ ylfar = 0x0fff;
+ }
+
if(flip)
{
for (k = ycur; k <= ylfar; k++)
@@ -2639,11 +2518,10 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
j = k >> 2;
spix = k & 3;
- if (k >= 0 && k < 0x1000)
+ //if (k >= 0 && k < 0x1000)
{
int m = 0;
int n = 0;
- int length = 0;
min = 0; max = 3;
if (j == yhpix)
{
@@ -2675,7 +2553,7 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
span[j].rx = minxhx;
}
- length = xstart - xend;
+ int length = (xend - xstart) * sign;
if (spix == ldflag)
{
@@ -2713,7 +2591,7 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
span[j].cvg[m] += 2;
}
- m += m_inc;
+ m += inv_sign;
}
}
}
@@ -2745,7 +2623,6 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
{
int m = 0;
int n = 0;
- int length = 0;
min = 0; max = 3;
if (j == yhpix)
{
@@ -2777,7 +2654,7 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
span[j].rx = maxxhx;
}
- length = xend - xstart;
+ int length = (xend - xstart) * sign;
if (spix == ldflag)
{
@@ -2815,7 +2692,7 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
span[j].cvg[m] += 2;
}
- m += m_inc;
+ m += inv_sign;
}
}
}
@@ -2844,8 +2721,6 @@ static void triangle_s_t_z(UINT32 w1, UINT32 w2)
default: break; // V-Rally2 does this, fb_size=0
}
}
+
#undef addvalues
#undef adjust_attr
-#undef addleft
-#undef addright
-#undef setvalues