From 7ab8a6d8f658b1aa32ef419bd60464152cad0019 Mon Sep 17 00:00:00 2001 From: Ryan Holtz Date: Sun, 20 Dec 2009 20:12:04 +0000 Subject: [PATCH] More RDP optimization through branch flattening. [Harmony] --- .gitattributes | 2 + src/mame/video/n64.c | 1228 +++++++++------- src/mame/video/rdpacomp.c | 10 +- src/mame/video/rdpacomp.h | 10 +- src/mame/video/rdpacvg.c | 48 +- src/mame/video/rdpacvg.h | 10 +- src/mame/video/rdpfb.c | 240 ++-- src/mame/video/rdpfb.h | 64 +- src/mame/video/rdpfetch.c | 43 - src/mame/video/rdpfetch.h | 81 ++ src/mame/video/rdpspn16.c | 978 ++++++++++--- src/mame/video/rdpspn16.h | 203 ++- src/mame/video/rdptpipe.c | 36 +- src/mame/video/rdptrect.c | 1278 ++++------------- src/mame/video/rdptrect.h | 102 +- src/mame/video/rdptri.c | 2775 +++++++++++++++++++++++++++++++++++++ src/mame/video/rdptri.h | 8 + 17 files changed, 5107 insertions(+), 2009 deletions(-) create mode 100644 src/mame/video/rdptri.c create mode 100644 src/mame/video/rdptri.h diff --git a/.gitattributes b/.gitattributes index 84524afb1df..ccac5c04e80 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3558,6 +3558,8 @@ src/mame/video/rdptpipe.c svneol=native#text/plain src/mame/video/rdptpipe.h svneol=native#text/plain src/mame/video/rdptrect.c svneol=native#text/plain src/mame/video/rdptrect.h svneol=native#text/plain +src/mame/video/rdptri.c svneol=native#text/plain +src/mame/video/rdptri.h svneol=native#text/plain src/mame/video/realbrk.c svneol=native#text/plain src/mame/video/redalert.c svneol=native#text/plain src/mame/video/redclash.c svneol=native#text/plain diff --git a/src/mame/video/n64.c b/src/mame/video/n64.c index 1a2497a8ae2..7ad3ce6c100 100644 --- a/src/mame/video/n64.c +++ b/src/mame/video/n64.c @@ -306,12 +306,12 @@ static INT32 gamma_dither_table[0x4000]; static UINT16 z_com_table[0x40000]; // Pre-calculated table of compressed z values static UINT32 max_level = 0; static UINT32 min_level = 0; -static COLOR ViBuffer[640][480]; // Used by divot filter +//static COLOR ViBuffer[640][480]; // Used by divot filter static INT32 maskbits_table[16]; // Pre-calculated static INT32 clamp_t_diff[8]; static INT32 clamp_s_diff[8]; -INLINE UINT8 COMBINER_EQUATION(UINT8 A, UINT8 B, UINT8 C, UINT8 D); +INLINE void COMBINER_EQUATION(UINT8* out, UINT8 *A, UINT8 *B, UINT8 *C, UINT8 *D); INLINE UINT32 addrightcvg(UINT32 x, UINT32 k); INLINE UINT32 addleftcvg(UINT32 x, UINT32 k); INLINE UINT32 z_decompress(UINT16* zb); @@ -321,12 +321,11 @@ INLINE void z_store(UINT16* zb, UINT8* zhb, UINT32 z, UINT32 deltaz); INLINE UINT32 z_compare(void* fb, UINT8* hb, UINT16* zb, UINT8* zhb, UINT32 sz, UINT16 dzpix); INLINE INT32 normalize_dzpix(INT32 sum); INLINE INT32 CLIP(INT32 value,INT32 min,INT32 max); -INLINE COLOR video_filter16(UINT16* vbuff, UINT8* hbuff, UINT32 hres); +INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UINT8* hbuff, UINT32 hres); INLINE void divot_filter16(INT32* r, INT32* g, INT32* 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); INLINE void set_shade_for_rects(void); -INLINE void set_shade_for_tris(UINT32 shade); INLINE void copy_colors(COLOR* dst, COLOR* src); INLINE void BILERP_AND_WRITE(UINT32* src0, UINT32* src1, UINT32* dest); INLINE void tcdiv(INT32 ss, INT32 st, INT32 sw, INT32* sss, INT32* sst); @@ -338,10 +337,13 @@ INLINE UINT32 ge_two(UINT32 enb); INLINE void calculate_clamp_diffs(UINT32 prim_tile); INLINE void rgb_dither(INT32* r, INT32* g, INT32* b, int dith); -INLINE void BLENDER_EQUATION_FORCE(INT32* r, INT32* g, INT32* b, int cycle, int bsel_special); -INLINE void BLENDER_EQUATION_NFORCE(INT32* r, INT32* g, INT32* b, int cycle, int bsel_special); +INLINE void BLENDER_EQUATION0_FORCE(INT32* r, INT32* g, INT32* b, int bsel_special); +INLINE void BLENDER_EQUATION0_NFORCE(INT32* r, INT32* g, INT32* b, int bsel_special); +INLINE void BLENDER_EQUATION1_FORCE(INT32* r, INT32* g, INT32* b, int bsel_special); +INLINE void BLENDER_EQUATION1_NFORCE(INT32* r, INT32* g, INT32* b, int bsel_special); -static void (*BLENDER_EQUATION)(INT32* r, INT32* g, INT32* b, int cycle, int bsel_special); +static void (*BLENDER_EQUATION0)(INT32* r, INT32* g, INT32* b, int bsel_special); +static void (*BLENDER_EQUATION1)(INT32* r, INT32* g, INT32* b, int bsel_special); #include "video/rdpfb.h" @@ -350,24 +352,66 @@ static UINT32 (*FBWRITE_32)(UINT32*, UINT32, UINT32, UINT32); #include "video/rdpacvg.h" -static UINT8 (*alpha_cvg_get)(UINT8 comb_alpha); +static void (*alpha_cvg_get)(UINT8 *comb_alpha); #include "video/rdpacomp.h" -static int (*alpha_compare)(running_machine *machine, UINT8 comb_alpha); +static int (*alpha_compare)(UINT8 comb_alpha); #include "video/rdptrect.h" -static void (*texture_rectangle_16bit)(running_machine *machine, TEX_RECTANGLE *rect); +static void (*texture_rectangle_16bit)(TEX_RECTANGLE *rect); #include "video/rdpspn16.h" -static void (*render_spans_16)(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip); +static void (*render_spans_16_ns_nt_nz_nf)( int start, int end, TILE* tex_tile); +static void (*render_spans_16_ns_nt_z_nf)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_ns_t_nz_nf)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_ns_t_z_nf)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_s_nt_nz_nf)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_s_nt_z_nf)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_s_t_nz_nf)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_s_t_z_nf)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_ns_nt_nz_f)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_ns_nt_z_f)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_ns_t_nz_f)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_ns_t_z_f)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_s_nt_nz_f)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_s_nt_z_f)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_s_t_nz_f)(int start, int end, TILE* tex_tile); +static void (*render_spans_16_s_t_z_f)(int start, int end, TILE* tex_tile); #include "video/rdptpipe.h" static void (*TEXTURE_PIPELINE)(COLOR* TEX, INT32 SSS, INT32 SST, TILE* tex_tile); +#include "video/rdpblend.h" + +static int (*BLENDER1_16)(UINT16 *fb, UINT8* hb, COLOR c, int dith); +static int (*BLENDER2_16)(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith); + +#include "video/rdptri.h" + +INLINE void CLAMP_C(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile); +INLINE void CLAMP_NC(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile); + +static void (*CLAMP)(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile); + +INLINE void CLAMP_LIGHT_C(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile); +INLINE void CLAMP_LIGHT_NC(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile); + +static void (*CLAMP_LIGHT)(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile); + +static UINT8 rdp_rand_val = 0; + +#include "video/rdpfetch.h" + +// Hack, but more efficient than mame_rand +static UINT8 rdp_rand(void) +{ + return (rdp_rand_val += 19); +} + INLINE void MASK(INT32* S, INT32* T, TILE* tex_tile) { INT32 swrap, twrap; @@ -433,21 +477,18 @@ INLINE void texshift(INT32* S, INT32* T, INT32* maxs, INT32* maxt, TILE* tex_til *maxt = ((*T >> 3) >= tex_tile->th); } -INLINE void CLAMP(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile) +INLINE void CLAMP_NC(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile) { - int notcopy = (other_modes.cycle_type != CYCLE_TYPE_COPY); int dosfrac = (tex_tile->cs || !tex_tile->mask_s); - int dos = dosfrac && notcopy; int dotfrac = (tex_tile->ct || !tex_tile->mask_t); - int dot = dotfrac && notcopy; int overunders = 0; int overundert = 0; - if (*S & 0x10000 && dos) + if (*S & 0x10000 && dosfrac) { *S = 0; overunders = 1; } - else if (maxs && dos) + else if (maxs && dosfrac) { *S = clamp_s_diff[tex_tile->num]; overunders = 1; @@ -457,17 +498,18 @@ INLINE void CLAMP(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, IN { *S = (SIGN17(*S) >> 5) & 0x1fff; } + if (overunders && dosfrac) { *SFRAC = 0; } - if (*T & 0x10000 && dot) + if (*T & 0x10000 && dotfrac) { *T = 0; overundert = 1; } - else if (maxt && dot) + else if (maxt && dotfrac) { *T = clamp_t_diff[tex_tile->num]; overundert = 1; @@ -476,17 +518,45 @@ INLINE void CLAMP(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, IN { *T = (SIGN17(*T) >> 5) & 0x1fff; } + if (overundert && dotfrac) { *TFRAC = 0; } } -INLINE void CLAMP_LIGHT(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile) +INLINE void CLAMP_C(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile) { - int notcopy = (other_modes.cycle_type != CYCLE_TYPE_COPY); - int dos = (tex_tile->cs || !tex_tile->mask_s) && notcopy; - int dot = (tex_tile->ct || !tex_tile->mask_t) && notcopy; + int dosfrac = (tex_tile->cs || !tex_tile->mask_s); + int dotfrac = (tex_tile->ct || !tex_tile->mask_t); + int overunders = 0; + int overundert = 0; + + *S = (SIGN17(*S) >> 5) & 0x1fff; + + if (overunders && dosfrac) + { + *SFRAC = 0; + } + + *T = (SIGN17(*T) >> 5) & 0x1fff; + + if (overundert && dotfrac) + { + *TFRAC = 0; + } +} + +INLINE void CLAMP_LIGHT_C(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile) +{ + *S = (SIGN17(*S) >> 5) & 0x1fff; + *T = (SIGN17(*T) >> 5) & 0x1fff; +} + +INLINE void CLAMP_LIGHT_NC(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile) +{ + int dos = (tex_tile->cs || !tex_tile->mask_s); + int dot = (tex_tile->ct || !tex_tile->mask_t); if (*S & 0x10000 && dos) { @@ -598,27 +668,29 @@ VIDEO_START(n64) } } -VIDEO_UPDATE(n64) +#define FSAA + #define DIVOT + #include "rdpupd16.c" + #undef DIVOT + #include "rdpupd16.c" +#undef FSAA + #define DIVOT + #include "rdpupd16.c" + #undef DIVOT + #include "rdpupd16.c" + +static void video_update_n64_32(bitmap_t *bitmap) { int i, j; - UINT32 final = 0; - UINT32 prev_cvg = 0, next_cvg = 0; - int height = fb_height; - int dither_filter = (n64_vi_control >> 16) & 1; - int fsaa = (((n64_vi_control >> 8) & 3) < 2); - int divot = (n64_vi_control >> 4) & 1; int gamma = (n64_vi_control >> 3) & 1; int gamma_dither = (n64_vi_control >> 2) & 1; - int vibuffering = ((n64_vi_control & 2) && fsaa && divot); + //int vibuffering = ((n64_vi_control & 2) && fsaa && divot); UINT32 *frame_buffer32; UINT16 *frame_buffer; UINT32 hb; UINT8* hidden_buffer; - COLOR newc; - UINT32 pixels = 0; - UINT16 pix = 0; int r, g, b; int dith = 0; @@ -633,22 +705,84 @@ VIDEO_UPDATE(n64) if (vdiff <= 0 || hdiff <= 0) { - return 0; + + return; } frame_buffer = (UINT16*)&rdram[(n64_vi_origin & 0xffffff) >> 2]; hb = ((n64_vi_origin & 0xffffff) >> 2) >> 1; hidden_buffer = &hidden_bits[hb]; - vibuffering = 0; // Disabled for now - - 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++) + { + UINT32 *d = BITMAP_ADDR32(bitmap, j, 0); + for (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; + if (gamma_dither) + { + dith = rdp_rand() & 0x3f; + } + if (gamma) + { + if (gamma_dither) + { + r = gamma_dither_table[(r << 6)| dith]; + g = gamma_dither_table[(g << 6)| dith]; + b = gamma_dither_table[(b << 6)| dith]; + } + else + { + r = gamma_table[r]; + g = gamma_table[g]; + b = gamma_table[b]; + } + } + else if (gamma_dither) + { + if (r < 255) + r += (dith & 1); + if (g < 255) + g += (dith & 1); + if (b < 255) + b += (dith & 1); + } + pix = (r << 24) | (g << 16) | (b << 8); + } + + + d[i] = (pix >> 8); + } + frame_buffer32 += invisiblewidth; + } + } +} + +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; + //int vibuffering = ((n64_vi_control & 2) && fsaa && divot); + + //vibuffering = 0; // Disabled for now + + /* if (vibuffering && ((n64_vi_control & 3) == 2)) { if (frame_buffer) @@ -678,6 +812,7 @@ VIDEO_UPDATE(n64) } } } + */ if (n64_vi_blank) { @@ -701,152 +836,28 @@ VIDEO_UPDATE(n64) case 2: // RGBA5551 { - pixels = 0; - - if (frame_buffer) + if(divot && fsaa) { - for (j=0; j < vres; j++) - { - UINT32 *d = BITMAP_ADDR32(bitmap, j, 0); - - for (i=0; i < hres; i++) - { - int r, g, b; - - pix = frame_buffer[pixels ^ WORD_ADDR_XOR]; - curpixel_cvg = ((pix & 1) << 2) | (hidden_buffer[pixels ^ BYTE_ADDR_XOR] & 3); - - if (i > 0 && i < (hres - 1) && divot) - { - prev_cvg = ((frame_buffer[(pixels - 1)^WORD_ADDR_XOR] & 1) << 2) | (hidden_buffer[(pixels - 1)^BYTE_ADDR_XOR] & 3); - next_cvg = ((frame_buffer[(pixels + 1)^WORD_ADDR_XOR] & 1) << 2) | (hidden_buffer[(pixels + 1)^BYTE_ADDR_XOR] & 3); - } - r = ((pix >> 8) & 0xf8) | (pix >> 13); - g = ((pix >> 3) & 0xf8) | ((pix >> 8) & 0x07); - b = ((pix << 2) & 0xf8) | ((pix >> 3) & 0x07); - - if (!vibuffering && 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); - r = newc.i.r; g = newc.i.g; b = newc.i.b; - } - else if (dither_filter && curpixel_cvg == 7 && i > 0 && j > 0 && i < (hres - 1) && j < (vres - 1)) - { - if (vibuffering) - { - restore_filter16_buffer(&r, &g, &b, &ViBuffer[i][j], n64_vi_width); - } - else - { - //restore_filter16(&r, &g, &b, &frame_buffer[pixels ^ WORD_ADDR_XOR], pixels ^ WORD_ADDR_XOR, n64_vi_width); - } - } - if (i > 0 && i < (hres - 1) && divot && (curpixel_cvg != 7 || prev_cvg != 7 || next_cvg != 7)) - { - if (vibuffering) - { - divot_filter16_buffer(&r, &g, &b, &ViBuffer[i][j]); - } - else - { - divot_filter16(&r, &g, &b, &frame_buffer[pixels ^ WORD_ADDR_XOR], pixels ^ WORD_ADDR_XOR); - } - } - - /* - if (gamma_dither) - { - dith = mame_rand(screen->machine) & 0x3f; - } - if (gamma) - { - if (gamma_dither) - { - r = gamma_dither_table[(r << 6)|dith]; - g = gamma_dither_table[(g << 6)|dith]; - b = gamma_dither_table[(b << 6)|dith]; - } - else - { - r = gamma_table[r]; - g = gamma_table[g]; - b = gamma_table[b]; - } - } - else if (gamma_dither) - { - if (r < 255) - r += (dith & 1); - if (g < 255) - g += (dith & 1); - if (b < 255) - b += (dith & 1); - } - */ - pixels++; - - final = (r << 16) | (g << 8) | b; - d[i] = final; // Fix me for endianness - } - pixels +=invisiblewidth; - } + video_update_n64_16_fsaa_divot(bitmap); + } + else if(divot) + { + video_update_n64_16_nofsaa_divot(bitmap); + } + else if(fsaa) + { + video_update_n64_16_fsaa_nodivot(bitmap); + } + else + { + video_update_n64_16_nofsaa_nodivot(bitmap); } break; } case 3: // RGBA8888 { - frame_buffer32 = (UINT32*)&rdram[(n64_vi_origin & 0xffffff) >> 2]; - if (frame_buffer32) - { - for (j=0; j < vres; j++) - { - UINT32 *d = BITMAP_ADDR32(bitmap, j, 0); - for (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; - if (gamma_dither) - { - dith = mame_rand(screen->machine) & 0x3f; - } - if (gamma) - { - if (gamma_dither) - { - r = gamma_dither_table[(r << 6)| dith]; - g = gamma_dither_table[(g << 6)| dith]; - b = gamma_dither_table[(b << 6)| dith]; - } - else - { - r = gamma_table[r]; - g = gamma_table[g]; - b = gamma_table[b]; - } - } - else if (gamma_dither) - { - if (r < 255) - r += (dith & 1); - if (g < 255) - g += (dith & 1); - if (b < 255) - b += (dith & 1); - } - pix = (r << 24) | (g << 16) | (b << 8); - } - - - d[i] = (pix >> 8); - } - frame_buffer32 += invisiblewidth; - } - } + video_update_n64_32(bitmap); break; } @@ -970,72 +981,60 @@ INLINE void SET_MUL_ALPHA_INPUT(UINT8 **input, int code) -INLINE COLOR COLOR_COMBINER1(running_machine *machine) +INLINE void COLOR_COMBINER1(COLOR *c) { - COLOR c; - if (combiner_rgbsub_a_r[1] == &noise_color.i.r) { - noise_color.i.r = mame_rand(machine) & 0xff; - noise_color.i.g = mame_rand(machine) & 0xff; - noise_color.i.b = mame_rand(machine) & 0xff; + noise_color.i.r = rdp_rand() & 0xff; + noise_color.i.g = rdp_rand() & 0xff; + noise_color.i.b = rdp_rand() & 0xff; } - c.i.r = COMBINER_EQUATION(*combiner_rgbsub_a_r[1],*combiner_rgbsub_b_r[1],*combiner_rgbmul_r[1],*combiner_rgbadd_r[1]); - c.i.g = COMBINER_EQUATION(*combiner_rgbsub_a_g[1],*combiner_rgbsub_b_g[1],*combiner_rgbmul_g[1],*combiner_rgbadd_g[1]); - c.i.b = COMBINER_EQUATION(*combiner_rgbsub_a_b[1],*combiner_rgbsub_b_b[1],*combiner_rgbmul_b[1],*combiner_rgbadd_b[1]); - c.i.a = COMBINER_EQUATION(*combiner_alphasub_a[1],*combiner_alphasub_b[1],*combiner_alphamul[1],*combiner_alphaadd[1]); + COMBINER_EQUATION(&c->i.r, combiner_rgbsub_a_r[1],combiner_rgbsub_b_r[1],combiner_rgbmul_r[1],combiner_rgbadd_r[1]); + COMBINER_EQUATION(&c->i.g, combiner_rgbsub_a_g[1],combiner_rgbsub_b_g[1],combiner_rgbmul_g[1],combiner_rgbadd_g[1]); + COMBINER_EQUATION(&c->i.b, combiner_rgbsub_a_b[1],combiner_rgbsub_b_b[1],combiner_rgbmul_b[1],combiner_rgbadd_b[1]); + COMBINER_EQUATION(&c->i.a, combiner_alphasub_a[1],combiner_alphasub_b[1],combiner_alphamul[1],combiner_alphaadd[1]); //Alpha coverage combiner - c.i.a = alpha_cvg_get(c.i.a); - - return c; + alpha_cvg_get(&c->i.a); } -INLINE COLOR COLOR_COMBINER2_C0(running_machine *machine) +INLINE void COLOR_COMBINER2_C0(COLOR *c) { - COLOR c; - if (combiner_rgbsub_a_r[0] == &noise_color.i.r) { - noise_color.i.r = mame_rand(machine) & 0xff; - noise_color.i.g = mame_rand(machine) & 0xff; - noise_color.i.b = mame_rand(machine) & 0xff; + noise_color.i.r = rdp_rand() & 0xff; + noise_color.i.g = rdp_rand() & 0xff; + noise_color.i.b = rdp_rand() & 0xff; } - c.i.r = COMBINER_EQUATION(*combiner_rgbsub_a_r[0],*combiner_rgbsub_b_r[0],*combiner_rgbmul_r[0],*combiner_rgbadd_r[0]); - c.i.g = COMBINER_EQUATION(*combiner_rgbsub_a_g[0],*combiner_rgbsub_b_g[0],*combiner_rgbmul_g[0],*combiner_rgbadd_g[0]); - c.i.b = COMBINER_EQUATION(*combiner_rgbsub_a_b[0],*combiner_rgbsub_b_b[0],*combiner_rgbmul_b[0],*combiner_rgbadd_b[0]); - c.i.a = COMBINER_EQUATION(*combiner_alphasub_a[0],*combiner_alphasub_b[0],*combiner_alphamul[0],*combiner_alphaadd[0]); + COMBINER_EQUATION(&c->i.r, combiner_rgbsub_a_r[0],combiner_rgbsub_b_r[0],combiner_rgbmul_r[0],combiner_rgbadd_r[0]); + COMBINER_EQUATION(&c->i.g, combiner_rgbsub_a_g[0],combiner_rgbsub_b_g[0],combiner_rgbmul_g[0],combiner_rgbadd_g[0]); + COMBINER_EQUATION(&c->i.b, combiner_rgbsub_a_b[0],combiner_rgbsub_b_b[0],combiner_rgbmul_b[0],combiner_rgbadd_b[0]); + COMBINER_EQUATION(&c->i.a, combiner_alphasub_a[0],combiner_alphasub_b[0],combiner_alphamul[0],combiner_alphaadd[0]); - combined_color.c = c.c; - - return c; + combined_color.c = c->c; } -INLINE COLOR COLOR_COMBINER2_C1(running_machine *machine) +INLINE void COLOR_COMBINER2_C1(COLOR *c) { - COLOR c; - - c.c = texel0_color.c; + c->c = texel0_color.c; texel0_color.c = texel1_color.c; - texel1_color.c = c.c; + texel1_color.c = c->c; if (combiner_rgbsub_a_r[1] == &noise_color.i.r) { - noise_color.i.r = mame_rand(machine) & 0xff; - noise_color.i.g = mame_rand(machine) & 0xff; - noise_color.i.b = mame_rand(machine) & 0xff; + noise_color.i.r = rdp_rand() & 0xff; + noise_color.i.g = rdp_rand() & 0xff; + noise_color.i.b = rdp_rand() & 0xff; } - c.i.r = COMBINER_EQUATION(*combiner_rgbsub_a_r[1],*combiner_rgbsub_b_r[1],*combiner_rgbmul_r[1],*combiner_rgbadd_r[1]); - c.i.g = COMBINER_EQUATION(*combiner_rgbsub_a_g[1],*combiner_rgbsub_b_g[1],*combiner_rgbmul_g[1],*combiner_rgbadd_g[1]); - c.i.b = COMBINER_EQUATION(*combiner_rgbsub_a_b[1],*combiner_rgbsub_b_b[1],*combiner_rgbmul_b[1],*combiner_rgbadd_b[1]); - c.i.a = COMBINER_EQUATION(*combiner_alphasub_a[1],*combiner_alphasub_b[1],*combiner_alphamul[1],*combiner_alphaadd[1]); + COMBINER_EQUATION(&c->i.r, combiner_rgbsub_a_r[1],combiner_rgbsub_b_r[1],combiner_rgbmul_r[1],combiner_rgbadd_r[1]); + COMBINER_EQUATION(&c->i.g, combiner_rgbsub_a_g[1],combiner_rgbsub_b_g[1],combiner_rgbmul_g[1],combiner_rgbadd_g[1]); + COMBINER_EQUATION(&c->i.b, combiner_rgbsub_a_b[1],combiner_rgbsub_b_b[1],combiner_rgbmul_b[1],combiner_rgbadd_b[1]); + COMBINER_EQUATION(&c->i.a, combiner_alphasub_a[1],combiner_alphasub_b[1],combiner_alphamul[1],combiner_alphaadd[1]); - c.i.a = alpha_cvg_get(c.i.a); - - return c; + alpha_cvg_get(&c->i.a); } INLINE void SET_BLENDER_INPUT(int cycle, int which, UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, UINT8 **input_a, int a, int b) @@ -1118,169 +1117,9 @@ static const UINT8 magic_matrix[16] = 7, 1, 6, 0 }; -INLINE int BLENDER1_16(running_machine *machine, UINT16 *fb, UINT8* hb, COLOR c, int dith) -{ - int r, g, b; - int special_bsel = 0; - UINT16 mem = *fb; - UINT32 memory_cvg = ((mem & 1) << 2) + (*hb & 3); - - // Alpha compare - if (!alpha_compare(machine, c.i.a)) - { - return 0; - } - if (!curpixel_cvg) // New coverage is zero, so abort - { - return 0; - } - - if (blender2b_a[0] == &memory_color.i.a) - { - special_bsel = 1; - } - - pixel_color.c = c.c; - //copy_colors(&pixel_color,&c); - - if (!other_modes.z_compare_en) - { - curpixel_overlap = 0; - } - - memory_color.i.r = ((mem >> 8) & 0xf8) | (mem >> 13); - memory_color.i.g = ((mem >> 3) & 0xf8) | ((mem >> 8) & 0x07); - memory_color.i.b = ((mem << 2) & 0xf8) | ((mem >> 3) & 0x07); - - if (other_modes.image_read_en) - { - memory_color.i.a = (memory_cvg << 5) & 0xe0; - } - else - { - memory_color.i.a = 0xe0; - } - - if (!curpixel_overlap && !other_modes.force_blend) - { - r = *blender1a_r[0]; - g = *blender1a_g[0]; - b = *blender1a_b[0]; - } - else - { - inv_pixel_color.i.a = 0xff - *blender1b_a[0]; - - BLENDER_EQUATION(&r, &g, &b, 0, special_bsel); - } - - if (other_modes.rgb_dither_sel < 2) - { - // Hack to prevent "double-dithering" artifacts - int dithhack = ((r & 0xf8)==(memory_color.i.r&0xf8) && (g & 0xf8) == (memory_color.i.g & 0xf8) &&(b&0xf8)==(memory_color.i.b&0xf8)); - if (!dithhack) - { - rgb_dither(&r, &g, &b, dith); - } - } - - return (FBWRITE_16(fb, hb, r, g, b)); -} - -INLINE int BLENDER2_16(running_machine *machine, UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith) -{ - int r, g, b; - int special_bsel = 0; - UINT16 mem = *fb; - UINT32 memory_cvg = ((mem & 1) << 2) + (*hb & 3); - - // Alpha compare - if (!alpha_compare(machine, c2.i.a)) - { - return 0; - } - if (!curpixel_cvg) - { - return 0; - } - - if (blender2b_a[0] == &memory_color.i.a) - { - special_bsel = 1; - } - - pixel_color.c = c2.c; - //copy_colors(&pixel_color, &c2); - if (!other_modes.z_compare_en) - { - curpixel_overlap = 0; - } - - memory_color.i.r = ((mem >> 8) & 0xf8) | (mem >> 13); - memory_color.i.g = ((mem >> 3) & 0xf8) | ((mem >> 8) & 0x07); - memory_color.i.b = ((mem << 2) & 0xf8) | ((mem >> 3) & 0x07); - - if (other_modes.image_read_en) - { - memory_color.i.a = (memory_cvg << 5) & 0xe0; - } - else - { - memory_color.i.a = 0xe0; - } - - inv_pixel_color.i.a = 0xff - *blender1b_a[0]; - - BLENDER_EQUATION(&r, &g, &b, 0, special_bsel); - - blended_pixel_color.i.r = r; - blended_pixel_color.i.g = g; - blended_pixel_color.i.b = b; - blended_pixel_color.i.a = pixel_color.i.a; - - pixel_color.i.r = r; - pixel_color.i.g = g; - pixel_color.i.b = b; - - inv_pixel_color.i.a = 0xff - *blender1b_a[1]; - - if (!curpixel_overlap && !other_modes.force_blend) - { - r = *blender1a_r[1]; - g = *blender1a_g[1]; - b = *blender1a_b[1]; - } - else - { - if (blender2b_a[1] == &memory_color.i.a) - { - special_bsel = 1; - } - else - { - special_bsel = 0; - } - - BLENDER_EQUATION(&r, &g, &b, 1, special_bsel); - } - - if (other_modes.rgb_dither_sel < 2) - { - // Hack to prevent "double-dithering" artifacts - int dithhack = ((r & 0xf8)==(memory_color.i.r&0xf8) && (g & 0xf8) == (memory_color.i.g & 0xf8) &&(b&0xf8)==(memory_color.i.b&0xf8)); - if (!dithhack) - { - rgb_dither(&r, &g, &b, dith); - } - } - - return (FBWRITE_16(fb, hb, r, g, b)); -} - /*****************************************************************************/ - -static void fill_rectangle_16bit(running_machine *machine, RECTANGLE *rect) +static void fill_rectangle_16bit(RECTANGLE *rect) { UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)]; UINT8* hb = &hidden_bits[fb_address >> 1]; @@ -1360,9 +1199,9 @@ static void fill_rectangle_16bit(running_machine *machine, RECTANGLE *rect) for (i = x1; i <= x2; i++) { curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2; - c = COLOR_COMBINER1(machine); + COLOR_COMBINER1(&c); dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - BLENDER1_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith); + BLENDER1_16(&fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith); } } } @@ -1376,9 +1215,9 @@ static void fill_rectangle_16bit(running_machine *machine, RECTANGLE *rect) for (i = x1; i <= x2; i++) { curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2; - c = COLOR_COMBINER1(machine); + COLOR_COMBINER1(&c); dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - BLENDER1_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith); + BLENDER1_16(&fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith); } } } @@ -1392,8 +1231,8 @@ static void fill_rectangle_16bit(running_machine *machine, RECTANGLE *rect) for (i = x1; i <= x2; i++) { curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2; - c = COLOR_COMBINER1(machine); - BLENDER1_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith); + COLOR_COMBINER1(&c); + BLENDER1_16(&fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith); } } } @@ -1410,10 +1249,10 @@ static void fill_rectangle_16bit(running_machine *machine, RECTANGLE *rect) for (i=x1; i <= x2; i++) { curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2; - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); + COLOR_COMBINER2_C0(&c1); + COLOR_COMBINER2_C1(&c2); dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - BLENDER2_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith); + BLENDER2_16(&fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith); } } } @@ -1427,10 +1266,10 @@ static void fill_rectangle_16bit(running_machine *machine, RECTANGLE *rect) for (i=x1; i <= x2; i++) { curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2; - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); + COLOR_COMBINER2_C0(&c1); + COLOR_COMBINER2_C1(&c2); dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - BLENDER2_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith); + BLENDER2_16(&fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith); } } } @@ -1444,9 +1283,9 @@ static void fill_rectangle_16bit(running_machine *machine, RECTANGLE *rect) for (i=x1; i <= x2; i++) { curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2; - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); - BLENDER2_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith); + COLOR_COMBINER2_C0(&c1); + COLOR_COMBINER2_C1(&c2); + BLENDER2_16(&fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith); } } } @@ -1474,8 +1313,6 @@ static INT32 tbase; static INT32 twidth; static INT32 tpal; -#include "video/rdpfetch.c" - INLINE void FETCH_TEXEL(COLOR *color, int s, int t, TILE* tex_tile) { twidth = tex_tile->line; @@ -1488,8 +1325,6 @@ INLINE void FETCH_TEXEL(COLOR *color, int s, int t, TILE* tex_tile) rdp_fetch_texel_func[tex_tile->fetch_index](color, s, t); } -#include "video/rdptpipe.c" - INLINE UINT32 z_decompress(UINT16 *zb) { UINT32 exponent = (*zb >> 13) & 7; @@ -1695,9 +1530,9 @@ INLINE INT32 CLIP(INT32 value,INT32 min,INT32 max) } } -INLINE COLOR video_filter16(UINT16* vbuff, UINT8* hbuff, UINT32 hres) +INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UINT8* hbuff, UINT32 hres) { - COLOR filtered, penumax, penumin, max, min; + COLOR penumax, penumin, max, min; UINT16 pix = *vbuff; UINT32 centercvg = (*hbuff & 3) + ((pix & 1) << 2) + 1; UINT32 numoffull = 1; @@ -1715,8 +1550,7 @@ INLINE COLOR video_filter16(UINT16* vbuff, UINT8* hbuff, UINT32 hres) UINT32 enb; int i = 0; - filtered.c = 0; - //filtered.i.r = filtered.i.g = filtered.i.b = filtered.i.a = 0; + *out_r = *out_g = *out_b = 0; backr[0] = r; backg[0] = g; @@ -1727,8 +1561,10 @@ INLINE COLOR video_filter16(UINT16* vbuff, UINT8* hbuff, UINT32 hres) if (centercvg == 8) { - filtered.i.r = r; filtered.i.g = g; filtered.i.b = b; - return filtered; + *out_r = r; + *out_g = g; + *out_b = b; + return; } for(i = 0; i < 5; i++) @@ -1898,14 +1734,11 @@ INLINE COLOR video_filter16(UINT16* vbuff, UINT8* hbuff, UINT32 hres) colr = (((colr * coeff) + 4) >> 3) + r; colg = (((colg * coeff) + 4) >> 3) + g; colb = (((colb * coeff) + 4) >> 3) + b; - colr &= 0xff; - colg &= 0xff; - colb &= 0xff; - filtered.i.r = colr; - filtered.i.g = colg; - filtered.i.b = colb; - return filtered; + *out_r = colr & 0xff; + *out_g = colg & 0xff; + *out_b = colb & 0xff; + return; } // This needs to be fixed for endianness. @@ -2288,18 +2121,6 @@ INLINE void set_shade_for_rects(void) //shade_color.i.a = 0; } -INLINE void set_shade_for_tris(UINT32 shade) -{ - if (!shade) // Hack, needed for Top Gear Rally 2 sky - { - shade_color.c = prim_color.c; - //shade_color.i.r = prim_color.i.r; - //shade_color.i.g = prim_color.i.g; - //shade_color.i.b = prim_color.i.b;; - //shade_color.i.a = prim_color.i.a; - } -} - INLINE UINT32 getlog2(UINT32 lod_clamp) { int i; @@ -2399,17 +2220,15 @@ void col_decode16(UINT16* addr, COLOR* col) } #endif -#include "rdptrect.c" - /*****************************************************************************/ -INLINE int BLENDER1_32(running_machine *machine, UINT32 *fb, COLOR c) +INLINE int BLENDER1_32(UINT32 *fb, COLOR c) { UINT32 mem = *fb; int r, g, b; // Alpha compare - if (!alpha_compare(machine, c.i.a)) + if (!alpha_compare(c.i.a)) { return 0; } @@ -2455,20 +2274,20 @@ INLINE int BLENDER1_32(running_machine *machine, UINT32 *fb, COLOR c) inv_pixel_color.i.a = 0xff - *blender1b_a[0]; - BLENDER_EQUATION(&r, &g, &b, 0, special_bsel); + BLENDER_EQUATION0(&r, &g, &b, special_bsel); } return (FBWRITE_32(fb,r,g,b)); } -INLINE int BLENDER2_32(running_machine *machine, UINT32 *fb, COLOR c1, COLOR c2) +INLINE int BLENDER2_32(UINT32 *fb, COLOR c1, COLOR c2) { UINT32 mem = *fb; int r, g, b; int special_bsel = 0; // Alpha compare - if (!alpha_compare(machine, c2.i.a)) + if (!alpha_compare(c2.i.a)) { return 0; } @@ -2505,7 +2324,7 @@ INLINE int BLENDER2_32(running_machine *machine, UINT32 *fb, COLOR c1, COLOR c2) inv_pixel_color.i.a = 0xff - *blender1b_a[0]; - BLENDER_EQUATION(&r, &g, &b, 0, special_bsel); + BLENDER_EQUATION0(&r, &g, &b, special_bsel); blended_pixel_color.i.r = r; blended_pixel_color.i.g = g; @@ -2534,13 +2353,13 @@ INLINE int BLENDER2_32(running_machine *machine, UINT32 *fb, COLOR c1, COLOR c2) inv_pixel_color.i.a = 0xff - *blender1b_a[1]; - BLENDER_EQUATION(&r, &g, &b, 1, special_bsel); + BLENDER_EQUATION1(&r, &g, &b, special_bsel); } return (FBWRITE_32(fb,r,g,b)); } -static void fill_rectangle_32bit(running_machine *machine, RECTANGLE *rect) +static void fill_rectangle_32bit(RECTANGLE *rect) { UINT32 *fb = (UINT32*)&rdram[(fb_address / 4)]; int index, i, j; @@ -2605,8 +2424,8 @@ static void fill_rectangle_32bit(running_machine *machine, RECTANGLE *rect) for (i=x1; i <= x2; i++) { curpixel_cvg = fill_cvg; - c = COLOR_COMBINER1(machine); - BLENDER1_32(machine, &fb[(index + i)], c); + COLOR_COMBINER1(&c); + BLENDER1_32(&fb[(index + i)], c); } } } @@ -2619,9 +2438,9 @@ static void fill_rectangle_32bit(running_machine *machine, RECTANGLE *rect) for (i=x1; i <= x2; i++) { curpixel_cvg = fill_cvg; - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); - BLENDER2_32(machine, &fb[(index + i)], c1, c2); + COLOR_COMBINER2_C0(&c1); + COLOR_COMBINER2_C1(&c2); + BLENDER2_32(&fb[(index + i)], c1, c2); } } } @@ -2631,7 +2450,7 @@ static void fill_rectangle_32bit(running_machine *machine, RECTANGLE *rect) } } -INLINE void texture_rectangle_32bit(running_machine *machine, TEX_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; @@ -2711,9 +2530,9 @@ INLINE void texture_rectangle_32bit(running_machine *machine, TEX_RECTANGLE *rec TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); } - c = COLOR_COMBINER1(machine); + COLOR_COMBINER1(&c); - BLENDER1_32(machine, &fb[(fb_index + i)], c); + BLENDER1_32(&fb[(fb_index + i)], c); s += rect->dsdx; } @@ -2746,10 +2565,10 @@ INLINE void texture_rectangle_32bit(running_machine *machine, TEX_RECTANGLE *rec TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2); } - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); + COLOR_COMBINER2_C0(&c1); + COLOR_COMBINER2_C1(&c2); - BLENDER2_32(machine, &fb[(fb_index + i)], c1, c2); + BLENDER2_32(&fb[(fb_index + i)], c1, c2); s += rect->dsdx; } @@ -2793,7 +2612,7 @@ INLINE void texture_rectangle_32bit(running_machine *machine, TEX_RECTANGLE *rec } -static void render_spans_32(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip) +static void render_spans_32(int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip) { UINT32 *fb = (UINT32*)&rdram[fb_address / 4]; UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; @@ -2871,7 +2690,10 @@ static void render_spans_32(running_machine *machine, int start, int end, TILE* dtinc = flip ? (dt.w) : -dt.w; dwinc = flip ? (dw.w) : -dw.w; - set_shade_for_tris(shade); + if(!shade) + { + shade_color.c = prim_color.c; + } for (i = start; i <= end; i++) { @@ -2973,12 +2795,12 @@ static void render_spans_32(running_machine *machine, int start, int end, TILE* if (other_modes.cycle_type == CYCLE_TYPE_1) { - c1 = COLOR_COMBINER1(machine); + COLOR_COMBINER1(&c1); } else if (other_modes.cycle_type == CYCLE_TYPE_2) { - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); + COLOR_COMBINER2_C0(&c1); + COLOR_COMBINER2_C1(&c2); } if ((zbuffer || other_modes.z_source_sel) && other_modes.z_compare_en) @@ -2992,11 +2814,11 @@ static void render_spans_32(running_machine *machine, int start, int end, TILE* if (other_modes.cycle_type == CYCLE_TYPE_1) { - rendered = BLENDER1_32(machine, fbcur, c1); + rendered = BLENDER1_32(fbcur, c1); } else { - rendered = BLENDER2_32(machine, fbcur, c1, c2); + rendered = BLENDER2_32(fbcur, c1, c2); } if (other_modes.z_update_en && rendered) @@ -3023,9 +2845,8 @@ static void render_spans_32(running_machine *machine, int start, int end, TILE* /*****************************************************************************/ -#include "rdpspn16.c" - -static void triangle(running_machine *machine, UINT32 w1, UINT32 w2, int shade, int texture, int zbuffer) +/* +static void triangle(UINT32 w1, UINT32 w2, int shade, int texture, int zbuffer) { int j; int xleft, xright, xleft_inc, xright_inc; @@ -3471,11 +3292,12 @@ static void triangle(running_machine *machine, UINT32 w1, UINT32 w2, int shade, switch (fb_size) // 8bpp needs to be implemented { - case PIXEL_SIZE_16BIT: render_spans_16(machine, yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break; - case PIXEL_SIZE_32BIT: render_spans_32(machine, yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break; + case PIXEL_SIZE_16BIT: render_spans_16(yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break; + case PIXEL_SIZE_32BIT: render_spans_32(yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break; default: break; // V-Rally2 does this, fb_size=0 } } +*/ /*****************************************************************************/ @@ -3890,42 +3712,42 @@ static RDP_COMMAND( rdp_noop ) static RDP_COMMAND( rdp_tri_noshade ) { - triangle(machine, w1, w2, 0, 0, 0); + triangle_ns_nt_nz(w1, w2); } static RDP_COMMAND( rdp_tri_noshade_z ) { - triangle(machine, w1, w2, 0, 0, 1); + triangle_ns_nt_z(w1, w2); } static RDP_COMMAND( rdp_tri_tex ) { - triangle(machine, w1, w2, 0, 1, 0); + triangle_ns_t_nz(w1, w2); } static RDP_COMMAND( rdp_tri_tex_z ) { - triangle(machine, w1, w2, 0, 1, 1); + triangle_ns_t_z(w1, w2); } static RDP_COMMAND( rdp_tri_shade ) { - triangle(machine, w1, w2, 1, 0, 0); + triangle_s_nt_nz(w1, w2); } static RDP_COMMAND( rdp_tri_shade_z ) { - triangle(machine, w1, w2, 1, 0, 1); + triangle_s_nt_z(w1, w2); } static RDP_COMMAND( rdp_tri_texshade ) { - triangle(machine, w1, w2, 1, 1, 0); + triangle_s_t_nz(w1, w2); } static RDP_COMMAND( rdp_tri_texshade_z ) { - triangle(machine, w1, w2, 1, 1, 1); + triangle_s_t_z(w1, w2); } static RDP_COMMAND( rdp_tex_rect ) @@ -3949,8 +3771,8 @@ static RDP_COMMAND( rdp_tex_rect ) switch (fb_size) { - case PIXEL_SIZE_16BIT: texture_rectangle_16bit(machine, &rect); break; - case PIXEL_SIZE_32BIT: texture_rectangle_32bit(machine, &rect); break; + case PIXEL_SIZE_16BIT: texture_rectangle_16bit(&rect); break; + case PIXEL_SIZE_32BIT: texture_rectangle_32bit(&rect); break; } } @@ -3975,8 +3797,8 @@ static RDP_COMMAND( rdp_tex_rect_flip ) switch (fb_size) { - case PIXEL_SIZE_16BIT: texture_rectangle_16bit(machine, &rect); break; - case PIXEL_SIZE_32BIT: texture_rectangle_32bit(machine, &rect); break; + case PIXEL_SIZE_16BIT: texture_rectangle_16bit(&rect); break; + case PIXEL_SIZE_32BIT: texture_rectangle_32bit(&rect); break; } } @@ -4090,19 +3912,41 @@ static RDP_COMMAND( rdp_set_other_modes ) alpha_compare = rdp_alpha_compare_func[(other_modes.alpha_compare_en << 1) | other_modes.dither_alpha_en]; - render_spans_16 = rdp_render_spans_16_func[(other_modes.cycle_type)]; + render_spans_16_ns_nt_nz_nf = rdp_render_spans_16_func[0 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_ns_nt_z_nf = rdp_render_spans_16_func[2 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_ns_t_nz_nf = rdp_render_spans_16_func[4 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_ns_t_z_nf = rdp_render_spans_16_func[6 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_s_nt_nz_nf = rdp_render_spans_16_func[8 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_s_nt_z_nf = rdp_render_spans_16_func[10 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_s_t_nz_nf = rdp_render_spans_16_func[12 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_s_t_z_nf = rdp_render_spans_16_func[14 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_ns_nt_nz_f = rdp_render_spans_16_func[16 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_ns_nt_z_f = rdp_render_spans_16_func[18 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_ns_t_nz_f = rdp_render_spans_16_func[20 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_ns_t_z_f = rdp_render_spans_16_func[22 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_s_nt_nz_f = rdp_render_spans_16_func[24 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_s_nt_z_f = rdp_render_spans_16_func[26 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_s_t_nz_f = rdp_render_spans_16_func[28 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; + render_spans_16_s_t_z_f = rdp_render_spans_16_func[30 + ((other_modes.cycle_type) | (other_modes.z_compare_en << 5) | (other_modes.z_update_en << 6))]; TEXTURE_PIPELINE = rdp_texture_pipeline_func[(other_modes.mid_texel << 1) | other_modes.sample_type]; + CLAMP = (other_modes.cycle_type == CYCLE_TYPE_COPY) ? CLAMP_C : CLAMP_NC; + CLAMP_LIGHT = (other_modes.cycle_type == CYCLE_TYPE_COPY) ? CLAMP_LIGHT_C : CLAMP_LIGHT_NC; + for(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; } - FBWRITE_16 = rdp_fbwrite_16_func[(other_modes.image_read_en << 2) | other_modes.cvg_dest]; - FBWRITE_32 = rdp_fbwrite_32_func[(other_modes.image_read_en << 2) | other_modes.cvg_dest]; + FBWRITE_16 = rdp_fbwrite_16_func[(other_modes.color_on_cvg << 3) | (other_modes.image_read_en << 2) | other_modes.cvg_dest]; + FBWRITE_32 = rdp_fbwrite_32_func[(other_modes.color_on_cvg << 3) | (other_modes.image_read_en << 2) | other_modes.cvg_dest]; - BLENDER_EQUATION = other_modes.force_blend ? BLENDER_EQUATION_FORCE : BLENDER_EQUATION_NFORCE; + BLENDER_EQUATION0 = other_modes.force_blend ? BLENDER_EQUATION0_FORCE : BLENDER_EQUATION0_NFORCE; + BLENDER_EQUATION1 = other_modes.force_blend ? BLENDER_EQUATION1_FORCE : BLENDER_EQUATION1_NFORCE; + + BLENDER1_16 = rdp_blender1_16_func[(other_modes.image_read_en << 2) | (other_modes.z_compare_en << 1) | (other_modes.rgb_dither_sel >> 1)]; + BLENDER2_16 = rdp_blender2_16_func[(other_modes.image_read_en << 2) | (other_modes.z_compare_en << 1) | (other_modes.rgb_dither_sel >> 1)]; SET_BLENDER_INPUT(0, 0, &blender1a_r[0], &blender1a_g[0], &blender1a_b[0], &blender1b_a[0], other_modes.blend_m1a_0, other_modes.blend_m1b_0); @@ -4466,8 +4310,8 @@ static RDP_COMMAND( rdp_fill_rect ) switch (fb_size) { - case PIXEL_SIZE_16BIT: fill_rectangle_16bit(machine, &rect); break; - case PIXEL_SIZE_32BIT: fill_rectangle_32bit(machine, &rect); break; + case PIXEL_SIZE_16BIT: fill_rectangle_16bit(&rect); break; + case PIXEL_SIZE_32BIT: fill_rectangle_32bit(&rect); break; } } @@ -4677,30 +4521,31 @@ void rdp_process_list(running_machine *machine) dp_start = dp_current = dp_end; } -#include "rdpacomp.c" -#include "rdpacvg.c" - -INLINE UINT8 COMBINER_EQUATION(UINT8 A, UINT8 B, UINT8 C, UINT8 D) +INLINE void COMBINER_EQUATION(UINT8 *out, UINT8 *A, UINT8 *B, UINT8 *C, UINT8 *D) { - INT32 color = (((A-B)* C) + (D << 8) + 0x80); + INT32 color = (((*A-*B)* *C) + (*D << 8) + 0x80); color >>= 8; if (color > 255) { - return 255; + *out = 255; } - if (color < 0) + else if (color < 0) { - return 0; + *out = 0; + } + else + { + *out = (UINT8)color; } - return (UINT8)color; } -INLINE void BLENDER_EQUATION_FORCE(INT32* r, INT32* g, INT32* b, int cycle, int bsel_special) +INLINE void BLENDER_EQUATION0_FORCE(INT32* r, INT32* g, INT32* b, int bsel_special) { UINT8 blend1a, blend2a; UINT32 sum = 0; - blend1a = *blender1b_a[cycle]; - blend2a = *blender2b_a[cycle]; + INT32 tr, tg, tb; + blend1a = *blender1b_a[0]; + blend2a = *blender2b_a[0]; if (bsel_special) { blend1a &= 0xe0; @@ -4708,34 +4553,34 @@ INLINE void BLENDER_EQUATION_FORCE(INT32* r, INT32* g, INT32* b, int cycle, int sum = (((blend1a >> 5) + (blend2a >> 5) + 1) & 0xf) << 5; - *r = (((int)(*blender1a_r[cycle]) * (int)(blend1a))) + - (((int)(*blender2a_r[cycle]) * (int)(blend2a))); - *r += (bsel_special) ? (((int)(*blender2a_r[cycle])) << 5) : (((int)(*blender2a_r[cycle])) << 3); + tr = (((int)(*blender1a_r[0]) * (int)(blend1a))) + + (((int)(*blender2a_r[0]) * (int)(blend2a))); + tr += (bsel_special) ? (((int)(*blender2a_r[0])) << 5) : (((int)(*blender2a_r[0])) << 3); - *g = (((int)(*blender1a_g[cycle]) * (int)(blend1a))) + - (((int)(*blender2a_g[cycle]) * (int)(blend2a))); - *g += (bsel_special) ? ((int)((*blender2a_g[cycle])) << 5) : (((int)(*blender2a_g[cycle])) << 3); + tg = (((int)(*blender1a_g[0]) * (int)(blend1a))) + + (((int)(*blender2a_g[0]) * (int)(blend2a))); + tg += (bsel_special) ? ((int)((*blender2a_g[0])) << 5) : (((int)(*blender2a_g[0])) << 3); - *b = (((int)(*blender1a_b[cycle]) * (int)(blend1a))) + - (((int)(*blender2a_b[cycle]) * (int)(blend2a))); - *b += (bsel_special) ? (((int)(*blender2a_b[cycle])) << 5) : (((int)(*blender2a_b[cycle])) << 3); + tb = (((int)(*blender1a_b[0]) * (int)(blend1a))) + + (((int)(*blender2a_b[0]) * (int)(blend2a))); + tb += (bsel_special) ? (((int)(*blender2a_b[0])) << 5) : (((int)(*blender2a_b[0])) << 3); - *r >>= 8; - *g >>= 8; - *b >>= 8; + tr >>= 8; + tg >>= 8; + tb >>= 8; - - if (*r > 255) *r = 255; - if (*g > 255) *g = 255; - if (*b > 255) *b = 255; + if (tr > 255) *r = 255; else *r = tr; + if (tg > 255) *g = 255; else *g = tg; + if (tb > 255) *b = 255; else *b = tb; } -INLINE void BLENDER_EQUATION_NFORCE(INT32* r, INT32* g, INT32* b, int cycle, int bsel_special) +INLINE void BLENDER_EQUATION0_NFORCE(INT32* r, INT32* g, INT32* b, int bsel_special) { UINT8 blend1a, blend2a; UINT32 sum = 0; - blend1a = *blender1b_a[cycle]; - blend2a = *blender2b_a[cycle]; + INT32 tr, tg, tb; + blend1a = *blender1b_a[0]; + blend2a = *blender2b_a[0]; if (bsel_special) { blend1a &= 0xe0; @@ -4743,33 +4588,112 @@ INLINE void BLENDER_EQUATION_NFORCE(INT32* r, INT32* g, INT32* b, int cycle, int sum = (((blend1a >> 5) + (blend2a >> 5) + 1) & 0xf) << 5; - *r = (((int)(*blender1a_r[cycle]) * (int)(blend1a))) + - (((int)(*blender2a_r[cycle]) * (int)(blend2a))); - *r += (bsel_special) ? (((int)(*blender2a_r[cycle])) << 5) : (((int)(*blender2a_r[cycle])) << 3); + tr = (((int)(*blender1a_r[0]) * (int)(blend1a))) + + (((int)(*blender2a_r[0]) * (int)(blend2a))); + tr += (bsel_special) ? (((int)(*blender2a_r[0])) << 5) : (((int)(*blender2a_r[0])) << 3); - *g = (((int)(*blender1a_g[cycle]) * (int)(blend1a))) + - (((int)(*blender2a_g[cycle]) * (int)(blend2a))); - *g += (bsel_special) ? ((int)((*blender2a_g[cycle])) << 5) : (((int)(*blender2a_g[cycle])) << 3); + tg = (((int)(*blender1a_g[0]) * (int)(blend1a))) + + (((int)(*blender2a_g[0]) * (int)(blend2a))); + tg += (bsel_special) ? ((int)((*blender2a_g[0])) << 5) : (((int)(*blender2a_g[0])) << 3); - *b = (((int)(*blender1a_b[cycle]) * (int)(blend1a))) + - (((int)(*blender2a_b[cycle]) * (int)(blend2a))); - *b += (bsel_special) ? (((int)(*blender2a_b[cycle])) << 5) : (((int)(*blender2a_b[cycle])) << 3); + tb = (((int)(*blender1a_b[0]) * (int)(blend1a))) + + (((int)(*blender2a_b[0]) * (int)(blend2a))); + tb += (bsel_special) ? (((int)(*blender2a_b[0])) << 5) : (((int)(*blender2a_b[0])) << 3); if (sum) { - *r /= sum; - *g /= sum; - *b /= sum; + tr /= sum; + tg /= sum; + tb /= sum; } else { *r = *g = *b = 0xff; + return; } - if (*r > 255) *r = 255; - if (*g > 255) *g = 255; - if (*b > 255) *b = 255; + if (tr > 255) *r = 255; else *r = tr; + if (tg > 255) *g = 255; else *g = tg; + if (tb > 255) *b = 255; else *b = tb; +} + +INLINE void BLENDER_EQUATION1_FORCE(INT32* r, INT32* g, INT32* b, int bsel_special) +{ + UINT8 blend1a, blend2a; + UINT32 sum = 0; + INT32 tr, tg, tb; + blend1a = *blender1b_a[1]; + blend2a = *blender2b_a[1]; + if (bsel_special) + { + blend1a &= 0xe0; + } + + sum = (((blend1a >> 5) + (blend2a >> 5) + 1) & 0xf) << 5; + + tr = (((int)(*blender1a_r[1]) * (int)(blend1a))) + + (((int)(*blender2a_r[1]) * (int)(blend2a))); + tr += (bsel_special) ? (((int)(*blender2a_r[1])) << 5) : (((int)(*blender2a_r[1])) << 3); + + tg = (((int)(*blender1a_g[1]) * (int)(blend1a))) + + (((int)(*blender2a_g[1]) * (int)(blend2a))); + tg += (bsel_special) ? ((int)((*blender2a_g[1])) << 5) : (((int)(*blender2a_g[1])) << 3); + + tb = (((int)(*blender1a_b[1]) * (int)(blend1a))) + + (((int)(*blender2a_b[1]) * (int)(blend2a))); + tb += (bsel_special) ? (((int)(*blender2a_b[1])) << 5) : (((int)(*blender2a_b[1])) << 3); + + tr >>= 8; + tg >>= 8; + tb >>= 8; + + if (tr > 255) *r = 255; else *r = tr; + if (tg > 255) *g = 255; else *g = tg; + if (tb > 255) *b = 255; else *b = tb; +} + +INLINE void BLENDER_EQUATION1_NFORCE(INT32* r, INT32* g, INT32* b, int bsel_special) +{ + UINT8 blend1a, blend2a; + UINT32 sum = 0; + INT32 tr, tg, tb; + blend1a = *blender1b_a[1]; + blend2a = *blender2b_a[1]; + if (bsel_special) + { + blend1a &= 0xe0; + } + + sum = (((blend1a >> 5) + (blend2a >> 5) + 1) & 0xf) << 5; + + tr = (((int)(*blender1a_r[1]) * (int)(blend1a))) + + (((int)(*blender2a_r[1]) * (int)(blend2a))); + tr += (bsel_special) ? (((int)(*blender2a_r[1])) << 5) : (((int)(*blender2a_r[1])) << 3); + + tg = (((int)(*blender1a_g[1]) * (int)(blend1a))) + + (((int)(*blender2a_g[1]) * (int)(blend2a))); + tg += (bsel_special) ? ((int)((*blender2a_g[1])) << 5) : (((int)(*blender2a_g[1])) << 3); + + tb = (((int)(*blender1a_b[1]) * (int)(blend1a))) + + (((int)(*blender2a_b[1]) * (int)(blend2a))); + tb += (bsel_special) ? (((int)(*blender2a_b[1])) << 5) : (((int)(*blender2a_b[1])) << 3); + + if (sum) + { + tr /= sum; + tg /= sum; + tb /= sum; + } + else + { + *r = *g = *b = 0xff; + return; + } + + if (tr > 255) *r = 255; else *r = tr; + if (tg > 255) *g = 255; else *g = tg; + if (tb > 255) *b = 255; else *b = tb; } INLINE UINT32 addrightcvg(UINT32 x, UINT32 k) @@ -4858,4 +4782,266 @@ INLINE UINT32 addleftcvg(UINT32 x, UINT32 k) } } -#include "video/rdpfb.c" +#include "video/rdpacomp.c" + +#include "video/rdpacvg.c" + +#define COLOR_ON_CVG + #include "video/rdpfb.c" +#undef COLOR_ON_CVG + #include "video/rdpfb.c" + +#define IMGREAD + #define ZCOMPARE + #define RGBDITHER1 + #include "video/rdpblend.c" + #undef RGBDITHER1 + #include "video/rdpblend.c" + #undef ZCOMPARE + #define RGBDITHER1 + #include "video/rdpblend.c" + #undef RGBDITHER1 + #include "video/rdpblend.c" +#undef IMGREAD + #define ZCOMPARE + #define RGBDITHER1 + #include "video/rdpblend.c" + #undef RGBDITHER1 + #include "video/rdpblend.c" + #undef ZCOMPARE + #define RGBDITHER1 + #include "video/rdpblend.c" + #undef RGBDITHER1 + #include "video/rdpblend.c" + +#include "video/rdpfetch.c" + +#include "video/rdptpipe.c" + +#define ZCOMPARE + #define ZUPDATE + #define MAGICDITHER + #include "video/rdptrect.c" + #undef MAGICDITHER + #define BAYERDITHER + #include "video/rdptrect.c" + #undef BAYERDITHER + #include "video/rdptrect.c" + #undef ZUPDATE + #define MAGICDITHER + #include "video/rdptrect.c" + #undef MAGICDITHER + #define BAYERDITHER + #include "video/rdptrect.c" + #undef BAYERDITHER + #include "video/rdptrect.c" +#undef ZCOMPARE + #define ZUPDATE + #define MAGICDITHER + #include "video/rdptrect.c" + #undef MAGICDITHER + #define BAYERDITHER + #include "video/rdptrect.c" + #undef BAYERDITHER + #include "video/rdptrect.c" + #undef ZUPDATE + #define MAGICDITHER + #include "video/rdptrect.c" + #undef MAGICDITHER + #define BAYERDITHER + #include "video/rdptrect.c" + #undef BAYERDITHER + #include "video/rdptrect.c" + +#define SHADE + #define TEXTURE + #define ZBUF + #define FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZBUF + #define FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef TEXTURE + #define ZBUF + #define FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZBUF + #define FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" +#undef SHADE + #define TEXTURE + #define ZBUF + #define FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZBUF + #define FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef TEXTURE + #define ZBUF + #define FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZBUF + #define FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef FLIP + #define ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" + #undef ZUPDATE + #define ZCOMPARE + #include "video/rdpspn16.c" + #undef ZCOMPARE + #include "video/rdpspn16.c" +#include "video/rdptri.c" + diff --git a/src/mame/video/rdpacomp.c b/src/mame/video/rdpacomp.c index 30cc362f401..ce796080a17 100644 --- a/src/mame/video/rdpacomp.c +++ b/src/mame/video/rdpacomp.c @@ -1,14 +1,14 @@ -INLINE int alpha_compare_nac_nda(running_machine *machine, UINT8 comb_alpha) +INLINE int alpha_compare_nac_nda(UINT8 comb_alpha) { return 1; } -INLINE int alpha_compare_nac_da(running_machine *machine, UINT8 comb_alpha) +INLINE int alpha_compare_nac_da(UINT8 comb_alpha) { return 1; } -INLINE int alpha_compare_ac_nda(running_machine *machine, UINT8 comb_alpha) +INLINE int alpha_compare_ac_nda(UINT8 comb_alpha) { if (comb_alpha < blend_color.i.a) { @@ -17,9 +17,9 @@ INLINE int alpha_compare_ac_nda(running_machine *machine, UINT8 comb_alpha) return 1; } -INLINE int alpha_compare_ac_da(running_machine *machine, UINT8 comb_alpha) +INLINE int alpha_compare_ac_da(UINT8 comb_alpha) { - if (comb_alpha < (mame_rand(machine) & 0xff)) + if (comb_alpha < (rdp_rand() & 0xff)) { return 0; } diff --git a/src/mame/video/rdpacomp.h b/src/mame/video/rdpacomp.h index 780c92b07a0..400758a7fd2 100644 --- a/src/mame/video/rdpacomp.h +++ b/src/mame/video/rdpacomp.h @@ -1,9 +1,9 @@ -INLINE int alpha_compare_nac_nda(running_machine *machine, UINT8 comb_alpha); -INLINE int alpha_compare_nac_da(running_machine *machine, UINT8 comb_alpha); -INLINE int alpha_compare_ac_nda(running_machine *machine, UINT8 comb_alpha); -INLINE int alpha_compare_ac_da(running_machine *machine, UINT8 comb_alpha); +INLINE int alpha_compare_nac_nda(UINT8 comb_alpha); +INLINE int alpha_compare_nac_da(UINT8 comb_alpha); +INLINE int alpha_compare_ac_nda(UINT8 comb_alpha); +INLINE int alpha_compare_ac_da(UINT8 comb_alpha); -static int (*rdp_alpha_compare_func[4])(running_machine *, UINT8) = +static int (*rdp_alpha_compare_func[4])(UINT8) = { alpha_compare_nac_nda, alpha_compare_nac_da, alpha_compare_ac_nda, alpha_compare_ac_da }; diff --git a/src/mame/video/rdpacvg.c b/src/mame/video/rdpacvg.c index e41f7636079..81a4120bcfb 100644 --- a/src/mame/video/rdpacvg.c +++ b/src/mame/video/rdpacvg.c @@ -1,6 +1,6 @@ -INLINE UINT8 alpha_cvg_get_cta_ca(UINT8 comb_alpha) +INLINE void alpha_cvg_get_cta_ca(UINT8 *comb_alpha) { - UINT32 temp = comb_alpha; + UINT32 temp = *comb_alpha; UINT32 temp2 = curpixel_cvg; UINT32 temp3 = 0; @@ -11,30 +11,34 @@ INLINE UINT8 alpha_cvg_get_cta_ca(UINT8 comb_alpha) if (temp > 0xff) { - temp = 0xff; + *comb_alpha = 0xff; + } + else + { + *comb_alpha = (UINT8)temp; } - - return (UINT8)temp; } -INLINE UINT8 alpha_cvg_get_ncta_ca(UINT8 comb_alpha) +INLINE void alpha_cvg_get_ncta_ca(UINT8 *comb_alpha) { - UINT32 temp = comb_alpha; + UINT32 temp = *comb_alpha; UINT32 temp2 = curpixel_cvg; temp = temp2 << 5; if (temp > 0xff) { - temp = 0xff; + *comb_alpha = 0xff; + } + else + { + *comb_alpha = (UINT8)temp; } - - return (UINT8)temp; } -INLINE UINT8 alpha_cvg_get_cta_nca(UINT8 comb_alpha) +INLINE void alpha_cvg_get_cta_nca(UINT8 *comb_alpha) { - UINT32 temp = comb_alpha; + UINT32 temp = *comb_alpha; UINT32 temp2 = curpixel_cvg; UINT32 temp3 = 0; @@ -43,20 +47,24 @@ INLINE UINT8 alpha_cvg_get_cta_nca(UINT8 comb_alpha) if (temp > 0xff) { - temp = 0xff; + *comb_alpha = 0xff; + } + else + { + *comb_alpha = (UINT8)temp; } - - return (UINT8)temp; } -INLINE UINT8 alpha_cvg_get_ncta_nca(UINT8 comb_alpha) +INLINE void alpha_cvg_get_ncta_nca(UINT8 *comb_alpha) { - UINT32 temp = comb_alpha; + UINT32 temp = *comb_alpha; if (temp > 0xff) { - temp = 0xff; + *comb_alpha = 0xff; + } + else + { + *comb_alpha = (UINT8)temp; } - - return (UINT8)temp; } diff --git a/src/mame/video/rdpacvg.h b/src/mame/video/rdpacvg.h index 74168aeb404..ac82f417d55 100644 --- a/src/mame/video/rdpacvg.h +++ b/src/mame/video/rdpacvg.h @@ -1,9 +1,9 @@ -INLINE UINT8 alpha_cvg_get_cta_ca(UINT8 comb_alpha); -INLINE UINT8 alpha_cvg_get_ncta_ca(UINT8 comb_alpha); -INLINE UINT8 alpha_cvg_get_cta_nca(UINT8 comb_alpha); -INLINE UINT8 alpha_cvg_get_ncta_nca(UINT8 comb_alpha); +INLINE void alpha_cvg_get_cta_ca(UINT8 *comb_alpha); +INLINE void alpha_cvg_get_ncta_ca(UINT8 *comb_alpha); +INLINE void alpha_cvg_get_cta_nca(UINT8 *comb_alpha); +INLINE void alpha_cvg_get_ncta_nca(UINT8 *comb_alpha); -static UINT8 (*rdp_alpha_cvg_func[4])(UINT8) = +static void (*rdp_alpha_cvg_func[4])(UINT8*) = { alpha_cvg_get_ncta_nca, alpha_cvg_get_ncta_ca, alpha_cvg_get_cta_nca, alpha_cvg_get_cta_ca, }; diff --git a/src/mame/video/rdpfb.c b/src/mame/video/rdpfb.c index ca0ad050947..f54fcdb6101 100644 --- a/src/mame/video/rdpfb.c +++ b/src/mame/video/rdpfb.c @@ -1,4 +1,8 @@ -INLINE UINT32 FBWRITE_16_RDEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_16_RDEN_CVGD0_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_16_RDEN_CVGD0_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#endif { #undef CVG_DRAW UINT16 finalcolor; @@ -24,11 +28,6 @@ INLINE UINT32 FBWRITE_16_RDEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, U curpixel_overlap = 0; } - if (curpixel_cvg > 8) - { - fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg); - } - newcvg = curpixel_cvg + memory_cvg; wrapflag = (newcvg > 8) ? 1 : 0; @@ -37,23 +36,20 @@ INLINE UINT32 FBWRITE_16_RDEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, U clampcvg = (newcvg > 8) ? 8 : newcvg; newcvg = (wrapflag)? (newcvg - 8) : newcvg; - if (!curpixel_cvg) - { - fatalerror("cvg underflow"); - } - curpixel_cvg--; newcvg--; memory_cvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xfffe; *fb |= ((newcvg >> 2) & 1); *hb = (newcvg & 3); return 0; } +#endif if (!other_modes.force_blend && !curpixel_overlap) { @@ -68,7 +64,11 @@ INLINE UINT32 FBWRITE_16_RDEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, U return 1; } -INLINE UINT32 FBWRITE_16_RDEN_CVGD1(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_16_RDEN_CVGD1_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_16_RDEN_CVGD1_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#endif { #undef CVG_DRAW UINT16 finalcolor; @@ -94,11 +94,6 @@ INLINE UINT32 FBWRITE_16_RDEN_CVGD1(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, U curpixel_overlap = 0; } - if (curpixel_cvg > 8) - { - fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg); - } - newcvg = curpixel_cvg + memory_cvg; wrapflag = (newcvg > 8) ? 1 : 0; @@ -107,30 +102,31 @@ INLINE UINT32 FBWRITE_16_RDEN_CVGD1(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, U clampcvg = (newcvg > 8) ? 8 : newcvg; newcvg = (wrapflag)? (newcvg - 8) : newcvg; - if (!curpixel_cvg) - { - fatalerror("cvg underflow"); - } - curpixel_cvg--; newcvg--; memory_cvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xfffe; *fb |= ((newcvg >> 2) & 1); *hb = (newcvg & 3); return 0; } +#endif *fb = finalcolor|((newcvg >> 2) & 1); *hb = (newcvg & 3); return 1; } -INLINE UINT32 FBWRITE_16_RDEN_CVGD2(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_16_RDEN_CVGD2_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_16_RDEN_CVGD2_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#endif { #undef CVG_DRAW UINT16 finalcolor; @@ -156,11 +152,6 @@ INLINE UINT32 FBWRITE_16_RDEN_CVGD2(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, U curpixel_overlap = 0; } - if (curpixel_cvg > 8) - { - fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg); - } - newcvg = curpixel_cvg + memory_cvg; wrapflag = (newcvg > 8) ? 1 : 0; @@ -169,30 +160,31 @@ INLINE UINT32 FBWRITE_16_RDEN_CVGD2(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, U clampcvg = (newcvg > 8) ? 8 : newcvg; newcvg = (wrapflag)? (newcvg - 8) : newcvg; - if (!curpixel_cvg) - { - fatalerror("cvg underflow"); - } - curpixel_cvg--; newcvg--; memory_cvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xfffe; *fb |= ((newcvg >> 2) & 1); *hb = (newcvg & 3); return 0; } +#endif *fb = finalcolor|1; *hb = 3; return 1; } -INLINE UINT32 FBWRITE_16_RDEN_CVGD3(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_16_RDEN_CVGD3_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_16_RDEN_CVGD3_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#endif { #undef CVG_DRAW UINT16 finalcolor; @@ -218,11 +210,6 @@ INLINE UINT32 FBWRITE_16_RDEN_CVGD3(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, U curpixel_overlap = 0; } - if (curpixel_cvg > 8) - { - fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg); - } - newcvg = curpixel_cvg + memory_cvg; wrapflag = (newcvg > 8) ? 1 : 0; @@ -231,30 +218,31 @@ INLINE UINT32 FBWRITE_16_RDEN_CVGD3(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, U clampcvg = (newcvg > 8) ? 8 : newcvg; newcvg = (wrapflag)? (newcvg - 8) : newcvg; - if (!curpixel_cvg) - { - fatalerror("cvg underflow"); - } - curpixel_cvg--; newcvg--; memory_cvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xfffe; *fb |= ((newcvg >> 2) & 1); *hb = (newcvg & 3); return 0; } +#endif *fb = finalcolor|((memory_cvg >> 2) & 1); *hb = (memory_cvg & 3); return 1; } -INLINE UINT32 FBWRITE_16_RDNEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_16_RDNEN_CVGD0_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_16_RDNEN_CVGD0_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#endif { #undef CVG_DRAW UINT16 finalcolor; @@ -279,11 +267,6 @@ INLINE UINT32 FBWRITE_16_RDNEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, curpixel_overlap = 0; } - if (curpixel_cvg > 8) - { - fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg); - } - newcvg = curpixel_cvg + 8; wrapflag = (newcvg > 8) ? 1 : 0; @@ -292,22 +275,19 @@ INLINE UINT32 FBWRITE_16_RDNEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, clampcvg = (newcvg > 8) ? 8 : newcvg; newcvg = (wrapflag)? (newcvg - 8) : newcvg; - if (!curpixel_cvg) - { - fatalerror("cvg underflow"); - } - curpixel_cvg--; newcvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xfffe; *fb |= ((newcvg >> 2) & 1); *hb = (newcvg & 3); return 0; } +#endif if (!other_modes.force_blend && !curpixel_overlap) { @@ -322,7 +302,11 @@ INLINE UINT32 FBWRITE_16_RDNEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, return 1; } -INLINE UINT32 FBWRITE_16_RDNEN_CVGD1(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_16_RDNEN_CVGD1_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_16_RDNEN_CVGD1_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#endif { #undef CVG_DRAW UINT16 finalcolor; @@ -347,11 +331,6 @@ INLINE UINT32 FBWRITE_16_RDNEN_CVGD1(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, curpixel_overlap = 0; } - if (curpixel_cvg > 8) - { - fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg); - } - newcvg = curpixel_cvg + 8; wrapflag = (newcvg > 8) ? 1 : 0; @@ -360,29 +339,30 @@ INLINE UINT32 FBWRITE_16_RDNEN_CVGD1(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, clampcvg = (newcvg > 8) ? 8 : newcvg; newcvg = (wrapflag)? (newcvg - 8) : newcvg; - if (!curpixel_cvg) - { - fatalerror("cvg underflow"); - } - curpixel_cvg--; newcvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xfffe; *fb |= ((newcvg >> 2) & 1); *hb = (newcvg & 3); return 0; } +#endif *fb = finalcolor|1; *hb = 3; return 1; } -INLINE UINT32 FBWRITE_16_RDNEN_CVGD2(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_16_RDNEN_CVGD2_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_16_RDNEN_CVGD2_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#endif { #undef CVG_DRAW UINT16 finalcolor; @@ -407,11 +387,6 @@ INLINE UINT32 FBWRITE_16_RDNEN_CVGD2(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, curpixel_overlap = 0; } - if (curpixel_cvg > 8) - { - fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg); - } - newcvg = curpixel_cvg + 8; wrapflag = (newcvg > 8) ? 1 : 0; @@ -420,29 +395,30 @@ INLINE UINT32 FBWRITE_16_RDNEN_CVGD2(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, clampcvg = (newcvg > 8) ? 8 : newcvg; newcvg = (wrapflag)? (newcvg - 8) : newcvg; - if (!curpixel_cvg) - { - fatalerror("cvg underflow"); - } - curpixel_cvg--; newcvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xfffe; *fb |= ((newcvg >> 2) & 1); *hb = (newcvg & 3); return 0; } +#endif *fb = finalcolor|1; *hb = 3; return 1; } -INLINE UINT32 FBWRITE_16_RDNEN_CVGD3(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_16_RDNEN_CVGD3_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_16_RDNEN_CVGD3_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b) +#endif { #undef CVG_DRAW UINT16 finalcolor; @@ -467,11 +443,6 @@ INLINE UINT32 FBWRITE_16_RDNEN_CVGD3(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, curpixel_overlap = 0; } - if (curpixel_cvg > 8) - { - fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg); - } - newcvg = curpixel_cvg + 8; wrapflag = (newcvg > 8) ? 1 : 0; @@ -480,29 +451,30 @@ INLINE UINT32 FBWRITE_16_RDNEN_CVGD3(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, clampcvg = (newcvg > 8) ? 8 : newcvg; newcvg = (wrapflag)? (newcvg - 8) : newcvg; - if (!curpixel_cvg) - { - fatalerror("cvg underflow"); - } - curpixel_cvg--; newcvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xfffe; *fb |= ((newcvg >> 2) & 1); *hb = (newcvg & 3); return 0; } +#endif *fb = finalcolor|1; *hb = 4; return 1; } -INLINE UINT32 FBWRITE_32_RDEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_32_RDEN_CVGD0_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_32_RDEN_CVGD0_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#endif { UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8); UINT32 memory_cvg = ((*fb >>5) & 7) + 1; @@ -520,12 +492,14 @@ INLINE UINT32 FBWRITE_32_RDEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) memory_cvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xffffff00; *fb |= ((newcvg << 5) & 0xff); return 0; } +#endif if (!other_modes.force_blend && !curpixel_overlap) { @@ -538,7 +512,11 @@ INLINE UINT32 FBWRITE_32_RDEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) return 1; } -INLINE UINT32 FBWRITE_32_RDEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_32_RDEN_CVGD1_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_32_RDEN_CVGD1_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#endif { UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8); UINT32 memory_cvg = ((*fb >>5) & 7) + 1; @@ -556,18 +534,24 @@ INLINE UINT32 FBWRITE_32_RDEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) memory_cvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xffffff00; *fb |= ((newcvg << 5) & 0xff); return 0; } +#endif *fb = finalcolor | (newcvg << 5); return 1; } -INLINE UINT32 FBWRITE_32_RDEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_32_RDEN_CVGD2_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_32_RDEN_CVGD2_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#endif { UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8); UINT32 memory_cvg = ((*fb >>5) & 7) + 1; @@ -585,18 +569,24 @@ INLINE UINT32 FBWRITE_32_RDEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) memory_cvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xffffff00; *fb |= ((newcvg << 5) & 0xff); return 0; } +#endif *fb = finalcolor | 0xE0; return 1; } -INLINE UINT32 FBWRITE_32_RDEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_32_RDEN_CVGD3_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_32_RDEN_CVGD3_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#endif { UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8); UINT32 memory_alphachannel = *fb & 0xff; @@ -615,18 +605,24 @@ INLINE UINT32 FBWRITE_32_RDEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) memory_cvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xffffff00; *fb |= ((newcvg << 5) & 0xff); return 0; } +#endif *fb = finalcolor | memory_alphachannel; return 1; } -INLINE UINT32 FBWRITE_32_RDNEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_32_RDNEN_CVGD0_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_32_RDNEN_CVGD0_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#endif { UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8); UINT32 newcvg; @@ -642,12 +638,14 @@ INLINE UINT32 FBWRITE_32_RDNEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) newcvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xffffff00; *fb |= ((newcvg << 5) & 0xff); return 0; } +#endif if (!other_modes.force_blend && !curpixel_overlap) { @@ -660,7 +658,11 @@ INLINE UINT32 FBWRITE_32_RDNEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) return 1; } -INLINE UINT32 FBWRITE_32_RDNEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_32_RDNEN_CVGD1_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_32_RDNEN_CVGD1_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#endif { UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8); UINT32 newcvg; @@ -676,18 +678,24 @@ INLINE UINT32 FBWRITE_32_RDNEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) newcvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xffffff00; *fb |= ((newcvg << 5) & 0xff); return 0; } +#endif *fb = finalcolor | (newcvg << 5); return 1; } -INLINE UINT32 FBWRITE_32_RDNEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_32_RDNEN_CVGD2_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_32_RDNEN_CVGD2_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#endif { UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8); UINT32 newcvg; @@ -703,18 +711,24 @@ INLINE UINT32 FBWRITE_32_RDNEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) newcvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xffffff00; *fb |= ((newcvg << 5) & 0xff); return 0; } +#endif *fb = finalcolor | 0xE0; return 1; } -INLINE UINT32 FBWRITE_32_RDNEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#if defined(COLOR_ON_CVG) + INLINE UINT32 FBWRITE_32_RDNEN_CVGD3_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#else + INLINE UINT32 FBWRITE_32_RDNEN_CVGD3_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) +#endif { UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8); UINT32 memory_alphachannel = *fb & 0xff; @@ -731,12 +745,14 @@ INLINE UINT32 FBWRITE_32_RDNEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b) newcvg--; clampcvg--; - if (other_modes.color_on_cvg && !wrapflag) +#if defined(COLOR_ON_CVG) + if (!wrapflag) { *fb &= 0xffffff00; *fb |= ((newcvg << 5) & 0xff); return 0; } +#endif *fb = finalcolor | memory_alphachannel; return 1; diff --git a/src/mame/video/rdpfb.h b/src/mame/video/rdpfb.h index fef4e4149f0..e134160e045 100644 --- a/src/mame/video/rdpfb.h +++ b/src/mame/video/rdpfb.h @@ -1,29 +1,49 @@ -INLINE UINT32 FBWRITE_16_RDEN_CVGD0(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_16_RDEN_CVGD1(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_16_RDEN_CVGD2(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_16_RDEN_CVGD3(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_16_RDNEN_CVGD0(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_16_RDNEN_CVGD1(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_16_RDNEN_CVGD2(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_16_RDNEN_CVGD3(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDEN_CVGD0_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDEN_CVGD0_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDEN_CVGD1_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDEN_CVGD1_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDEN_CVGD2_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDEN_CVGD2_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDEN_CVGD3_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDEN_CVGD3_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDNEN_CVGD0_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDNEN_CVGD0_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDNEN_CVGD1_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDNEN_CVGD1_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDNEN_CVGD2_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDNEN_CVGD2_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDNEN_CVGD3_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_16_RDNEN_CVGD3_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_32_RDEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_32_RDEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_32_RDEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_32_RDEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_32_RDNEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_32_RDNEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_32_RDNEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); -INLINE UINT32 FBWRITE_32_RDNEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDEN_CVGD0_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDEN_CVGD0_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDEN_CVGD1_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDEN_CVGD1_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDEN_CVGD2_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDEN_CVGD2_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDEN_CVGD3_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDEN_CVGD3_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDNEN_CVGD0_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDNEN_CVGD0_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDNEN_CVGD1_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDNEN_CVGD1_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDNEN_CVGD2_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDNEN_CVGD2_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDNEN_CVGD3_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); +INLINE UINT32 FBWRITE_32_RDNEN_CVGD3_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b); -static UINT32 (*rdp_fbwrite_16_func[8])(UINT16*, UINT8*, UINT32, UINT32, UINT32) = +static UINT32 (*rdp_fbwrite_16_func[16])(UINT16*, UINT8*, UINT32, UINT32, UINT32) = { - FBWRITE_16_RDNEN_CVGD0, FBWRITE_16_RDNEN_CVGD1, FBWRITE_16_RDNEN_CVGD2, FBWRITE_16_RDNEN_CVGD3, - FBWRITE_16_RDEN_CVGD0, FBWRITE_16_RDEN_CVGD1, FBWRITE_16_RDEN_CVGD2, FBWRITE_16_RDEN_CVGD3, + FBWRITE_16_RDNEN_CVGD0_NCOC, FBWRITE_16_RDNEN_CVGD1_NCOC, FBWRITE_16_RDNEN_CVGD2_NCOC, FBWRITE_16_RDNEN_CVGD3_NCOC, + FBWRITE_16_RDEN_CVGD0_NCOC, FBWRITE_16_RDEN_CVGD1_NCOC, FBWRITE_16_RDEN_CVGD2_NCOC, FBWRITE_16_RDEN_CVGD3_NCOC, + FBWRITE_16_RDNEN_CVGD0_COC, FBWRITE_16_RDNEN_CVGD1_COC, FBWRITE_16_RDNEN_CVGD2_COC, FBWRITE_16_RDNEN_CVGD3_COC, + FBWRITE_16_RDEN_CVGD0_COC, FBWRITE_16_RDEN_CVGD1_COC, FBWRITE_16_RDEN_CVGD2_COC, FBWRITE_16_RDEN_CVGD3_COC, }; -static UINT32 (*rdp_fbwrite_32_func[8])(UINT32*, UINT32, UINT32, UINT32) = +static UINT32 (*rdp_fbwrite_32_func[16])(UINT32*, UINT32, UINT32, UINT32) = { - FBWRITE_32_RDNEN_CVGD0, FBWRITE_32_RDNEN_CVGD1, FBWRITE_32_RDNEN_CVGD2, FBWRITE_32_RDNEN_CVGD3, - FBWRITE_32_RDEN_CVGD0, FBWRITE_32_RDEN_CVGD1, FBWRITE_32_RDEN_CVGD2, FBWRITE_32_RDEN_CVGD3, + FBWRITE_32_RDNEN_CVGD0_NCOC, FBWRITE_32_RDNEN_CVGD1_NCOC, FBWRITE_32_RDNEN_CVGD2_NCOC, FBWRITE_32_RDNEN_CVGD3_NCOC, + FBWRITE_32_RDEN_CVGD0_NCOC, FBWRITE_32_RDEN_CVGD1_NCOC, FBWRITE_32_RDEN_CVGD2_NCOC, FBWRITE_32_RDEN_CVGD3_NCOC, + FBWRITE_32_RDNEN_CVGD0_COC, FBWRITE_32_RDNEN_CVGD1_COC, FBWRITE_32_RDNEN_CVGD2_COC, FBWRITE_32_RDNEN_CVGD3_COC, + FBWRITE_32_RDEN_CVGD0_COC, FBWRITE_32_RDEN_CVGD1_COC, FBWRITE_32_RDEN_CVGD2_COC, FBWRITE_32_RDEN_CVGD3_COC, }; diff --git a/src/mame/video/rdpfetch.c b/src/mame/video/rdpfetch.c index e912f077364..de22d99740e 100644 --- a/src/mame/video/rdpfetch.c +++ b/src/mame/video/rdpfetch.c @@ -439,46 +439,3 @@ INLINE void FETCH_TEXEL_INVALID(COLOR *color, int s, int t) } //typedef void (*rdp_fetch_texel_func)(COLOR *color, int s, int t); - -static void (*rdp_fetch_texel_func[128])(COLOR*, int, int) = -{ - // 4-bit accessors - FETCH_TEXEL_RGBA4_TLUT_NEN, FETCH_TEXEL_RGBA4_TLUT_NEN, FETCH_TEXEL_RGBA4_TLUT_EN0, FETCH_TEXEL_RGBA4_TLUT_EN1, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_CI4_TLUT_NEN, FETCH_TEXEL_CI4_TLUT_NEN, FETCH_TEXEL_CI4_TLUT_EN0, FETCH_TEXEL_CI4_TLUT_EN1, - FETCH_TEXEL_IA4_TLUT_NEN, FETCH_TEXEL_IA4_TLUT_NEN, FETCH_TEXEL_IA4_TLUT_EN0, FETCH_TEXEL_IA4_TLUT_EN1, - FETCH_TEXEL_I4_TLUT_NEN, FETCH_TEXEL_I4_TLUT_NEN, FETCH_TEXEL_I4_TLUT_EN0, FETCH_TEXEL_I4_TLUT_EN1, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - - // 8-bit accessors - FETCH_TEXEL_RGBA8_TLUT_NEN, FETCH_TEXEL_RGBA8_TLUT_NEN, FETCH_TEXEL_RGBA8_TLUT_EN0, FETCH_TEXEL_RGBA8_TLUT_EN1, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_CI8_TLUT_NEN, FETCH_TEXEL_CI8_TLUT_NEN, FETCH_TEXEL_CI8_TLUT_EN0, FETCH_TEXEL_CI8_TLUT_EN1, - FETCH_TEXEL_IA8_TLUT_NEN, FETCH_TEXEL_IA8_TLUT_NEN, FETCH_TEXEL_IA8_TLUT_EN0, FETCH_TEXEL_IA8_TLUT_EN1, - FETCH_TEXEL_I8_TLUT_NEN, FETCH_TEXEL_I8_TLUT_NEN, FETCH_TEXEL_I8_TLUT_EN0, FETCH_TEXEL_I8_TLUT_EN1, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - - // 16-bit accessors - FETCH_TEXEL_RGBA16_TLUT_NEN,FETCH_TEXEL_RGBA16_TLUT_NEN,FETCH_TEXEL_RGBA16_TLUT_EN0,FETCH_TEXEL_RGBA16_TLUT_EN1, - FETCH_TEXEL_YUV16, FETCH_TEXEL_YUV16, FETCH_TEXEL_YUV16, FETCH_TEXEL_YUV16, - FETCH_TEXEL_CI16_TLUT_NEN, FETCH_TEXEL_CI16_TLUT_NEN, FETCH_TEXEL_CI16_TLUT_EN0, FETCH_TEXEL_CI16_TLUT_EN1, - FETCH_TEXEL_IA16_TLUT_NEN, FETCH_TEXEL_IA16_TLUT_NEN, FETCH_TEXEL_IA16_TLUT_EN0, FETCH_TEXEL_IA16_TLUT_EN1, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - - // 32-bit accessors - FETCH_TEXEL_RGBA32_TLUT_NEN,FETCH_TEXEL_RGBA32_TLUT_NEN,FETCH_TEXEL_RGBA32_TLUT_EN0,FETCH_TEXEL_RGBA32_TLUT_EN1, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, - FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, -}; diff --git a/src/mame/video/rdpfetch.h b/src/mame/video/rdpfetch.h index e69de29bb2d..cf5a00336f4 100644 --- a/src/mame/video/rdpfetch.h +++ b/src/mame/video/rdpfetch.h @@ -0,0 +1,81 @@ +INLINE void FETCH_TEXEL_RGBA4_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA4_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA4_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA8_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA8_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA8_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA16_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA16_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA16_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA32_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA32_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_RGBA32_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_YUV16(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_CI4_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_CI4_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_CI4_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_CI8_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_CI8_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_CI8_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_CI16_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_CI16_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_CI16_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_IA4_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_IA4_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_IA4_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_IA8_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_IA8_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_IA8_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_IA16_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_IA16_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_IA16_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_I4_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_I4_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_I4_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_I8_TLUT_EN0(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_I8_TLUT_EN1(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_I8_TLUT_NEN(COLOR *color, int s, int t); +INLINE void FETCH_TEXEL_INVALID(COLOR *color, int s, int t); + +static void (*rdp_fetch_texel_func[128])(COLOR*, int, int) = +{ + // 4-bit accessors + FETCH_TEXEL_RGBA4_TLUT_NEN, FETCH_TEXEL_RGBA4_TLUT_NEN, FETCH_TEXEL_RGBA4_TLUT_EN0, FETCH_TEXEL_RGBA4_TLUT_EN1, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_CI4_TLUT_NEN, FETCH_TEXEL_CI4_TLUT_NEN, FETCH_TEXEL_CI4_TLUT_EN0, FETCH_TEXEL_CI4_TLUT_EN1, + FETCH_TEXEL_IA4_TLUT_NEN, FETCH_TEXEL_IA4_TLUT_NEN, FETCH_TEXEL_IA4_TLUT_EN0, FETCH_TEXEL_IA4_TLUT_EN1, + FETCH_TEXEL_I4_TLUT_NEN, FETCH_TEXEL_I4_TLUT_NEN, FETCH_TEXEL_I4_TLUT_EN0, FETCH_TEXEL_I4_TLUT_EN1, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + + // 8-bit accessors + FETCH_TEXEL_RGBA8_TLUT_NEN, FETCH_TEXEL_RGBA8_TLUT_NEN, FETCH_TEXEL_RGBA8_TLUT_EN0, FETCH_TEXEL_RGBA8_TLUT_EN1, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_CI8_TLUT_NEN, FETCH_TEXEL_CI8_TLUT_NEN, FETCH_TEXEL_CI8_TLUT_EN0, FETCH_TEXEL_CI8_TLUT_EN1, + FETCH_TEXEL_IA8_TLUT_NEN, FETCH_TEXEL_IA8_TLUT_NEN, FETCH_TEXEL_IA8_TLUT_EN0, FETCH_TEXEL_IA8_TLUT_EN1, + FETCH_TEXEL_I8_TLUT_NEN, FETCH_TEXEL_I8_TLUT_NEN, FETCH_TEXEL_I8_TLUT_EN0, FETCH_TEXEL_I8_TLUT_EN1, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + + // 16-bit accessors + FETCH_TEXEL_RGBA16_TLUT_NEN,FETCH_TEXEL_RGBA16_TLUT_NEN,FETCH_TEXEL_RGBA16_TLUT_EN0,FETCH_TEXEL_RGBA16_TLUT_EN1, + FETCH_TEXEL_YUV16, FETCH_TEXEL_YUV16, FETCH_TEXEL_YUV16, FETCH_TEXEL_YUV16, + FETCH_TEXEL_CI16_TLUT_NEN, FETCH_TEXEL_CI16_TLUT_NEN, FETCH_TEXEL_CI16_TLUT_EN0, FETCH_TEXEL_CI16_TLUT_EN1, + FETCH_TEXEL_IA16_TLUT_NEN, FETCH_TEXEL_IA16_TLUT_NEN, FETCH_TEXEL_IA16_TLUT_EN0, FETCH_TEXEL_IA16_TLUT_EN1, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + + // 32-bit accessors + FETCH_TEXEL_RGBA32_TLUT_NEN,FETCH_TEXEL_RGBA32_TLUT_NEN,FETCH_TEXEL_RGBA32_TLUT_EN0,FETCH_TEXEL_RGBA32_TLUT_EN1, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, + FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, +}; diff --git a/src/mame/video/rdpspn16.c b/src/mame/video/rdpspn16.c index cb76e58e3db..f2b7a7aaa43 100644 --- a/src/mame/video/rdpspn16.c +++ b/src/mame/video/rdpspn16.c @@ -1,56 +1,339 @@ -static void render_spans_16_c1(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip) +#if defined(SHADE) + #if defined(TEXTURE) + #if defined(ZBUF) + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_t_z_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_t_z_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_t_z_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_t_z_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_t_z_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_t_z_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_t_z_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #else + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_t_nz_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_t_nz_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_t_nz_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_t_nz_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_t_nz_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #endif + #else + #if defined(ZBUF) + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_nt_z_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_nt_z_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_nt_z_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_nt_z_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_nt_z_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #else + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_nt_nz_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_nt_nz_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_s_nt_nz_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_s_nt_nz_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #endif + #endif +#else + #if defined(TEXTURE) + #if defined(ZBUF) + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_t_z_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_t_z_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_t_z_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_t_z_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_t_z_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_t_z_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_t_z_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #else + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_t_nz_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_t_nz_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_t_nz_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_t_nz_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_t_nz_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #endif + #else + #if defined(ZBUF) + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_nt_z_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_nt_z_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_nt_z_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_nt_z_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_nt_z_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #else + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_nt_nz_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_nt_nz_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c1_ns_nt_nz_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c1_ns_nt_nz_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #endif + #endif +#endif { UINT16 *fb = (UINT16*)&rdram[fb_address / 4]; - UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; UINT8 *hb = &hidden_bits[fb_address >> 1]; +#if defined(ZUPDATE) || defined(ZCOMPARE) + UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; UINT8 *zhb = &hidden_bits[zb_address >> 1]; +#endif int i, j; int clipx1, clipx2, clipy1, clipy2; - UINT32 prim_tile = tex_tile->num; - UINT32 disable_lod = 0; - int tilenum; - +#if defined(SHADE) SPAN_PARAM dr = span[0].dr; SPAN_PARAM dg = span[0].dg; SPAN_PARAM db = span[0].db; SPAN_PARAM da = span[0].da; - SPAN_PARAM dz = span[0].dz; +#if defined(FLIP) + int drinc = dr.w; + int dginc = dg.w; + int dbinc = db.w; + int dainc = da.w; +#else + int drinc = -dr.w; + int dginc = -dg.w; + int dbinc = -db.w; + int dainc = -da.w; +#endif +#endif + +#if defined(TEXTURE) + UINT32 prim_tile = tex_tile->num; + UINT32 disable_lod = 0; + int tilenum; + SPAN_PARAM ds = span[0].ds; 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; +#if defined(FLIP) + int dsinc = ds.w; + int dtinc = dt.w; + int dwinc = dw.w; +#else + int dsinc = -ds.w; + int dtinc = -dt.w; + int dwinc = -dw.w; +#endif +#endif - calculate_clamp_diffs(tex_tile->num); +#if defined(ZBUF) + SPAN_PARAM dz = span[0].dz; + int dzpix = span[0].dzpix; +#if defined(FLIP) + int dzinc = dz.w; +#else + int dzinc = -dz.w; +#endif +#else + int sz = 0, dzpix = 0; + + if (other_modes.z_source_sel) + { + sz = (((UINT32)primitive_z) << 3) & 0x3ffff; + dzpix = primitive_delta_z; + } +#endif clipx1 = clip.xh / 4; clipx2 = clip.xl / 4; clipy1 = clip.yh / 4; clipy2 = clip.yl / 4; - if (texture && !other_modes.tex_lod_en) +#if defined(TEXTURE) + if (!other_modes.tex_lod_en) { tilenum = prim_tile; tex_tile = &tile[tilenum]; } - - if (other_modes.tex_lod_en) // Used by World Driver Championship + else { - disable_lod = 1; + disable_lod = 1; // Used by World Driver Championship } - - 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; +#endif if (start < clipy1) { @@ -69,82 +352,91 @@ static void render_spans_16_c1(running_machine *machine, int start, int end, TIL end = clipy2 - 1; } - set_shade_for_tris(shade); // Needed by backgrounds in Top Gear Rally 1 +#if !defined(SHADE) + shade_color.c = prim_color.c; +#endif for (i = start; i <= end; i++) { int xstart = span[i].lx; int xend = span[i].rx; - SPAN_PARAM r; - SPAN_PARAM g; - SPAN_PARAM b; - SPAN_PARAM a; - SPAN_PARAM z = span[i].z; - SPAN_PARAM s = span[i].s; - SPAN_PARAM t = span[i].t; - SPAN_PARAM w = span[i].w; int x; int fb_index = fb_width * i; int length; - if (shade) - { - r = span[i].r; - g = span[i].g; - b = span[i].b; - a = span[i].a; - } +#if defined(SHADE) + SPAN_PARAM r = span[i].r; + SPAN_PARAM g = span[i].g; + SPAN_PARAM b = span[i].b; + SPAN_PARAM a = span[i].a; +#endif +#if defined(TEXTURE) + SPAN_PARAM s = span[i].s; + SPAN_PARAM t = span[i].t; + SPAN_PARAM w = span[i].w; +#endif +#if defined(ZBUF) + SPAN_PARAM z = span[i].z; +#endif x = xend; - length = flip ? (xstart - xend) : (xend - xstart); //Moogly +#if defined(FLIP) + length = (xstart - xend); +#else + length = (xend - xstart); +#endif for (j = 0; j <= length; j++) { - int sr = 0, sg = 0, sb = 0, sa = 0; +#if defined(SHADE) + int sr = r.h.h; + int sg = g.h.h; + int sb = b.h.h; + int sa = a.h.h; +#endif +#if defined(TEXTURE) int ss = s.h.h; int st = t.h.h; int sw = w.h.h; - int sz = z.w >> 13; int sss = 0, sst = 0; +#endif +#if defined(ZBUF) + int sz = z.w >> 13; +#endif COLOR c1, c2; - if (shade) - { - sr = r.h.h; - sg = g.h.h; - sb = b.h.h; - sa = a.h.h; - } c1.c = 0; c2.c = 0; + +#if defined(ZBUF) if (other_modes.z_source_sel) { sz = (((UINT32)primitive_z) << 3) & 0x3ffff; dzpix = primitive_delta_z; } - +#endif if (x >= clipx1 && x < clipx2) { +#if defined(ZCOMPARE) int z_compare_result = 1; +#endif curpixel_cvg=span[i].cvg[x]; - if (curpixel_cvg > 8) - { - stricterror("render_spans_16: cvg of current pixel is %d", curpixel_cvg); - } - if (curpixel_cvg) { int curpixel = fb_index + x; UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR]; - UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR]; +#if defined(ZUPDATE) || defined(ZCOMPARE) + UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR]; +#endif +#if defined(TEXTURE) if (other_modes.persp_tex_en) { tcdiv(ss, st, sw, &sss, &sst); @@ -154,36 +446,39 @@ static void render_spans_16_c1(running_machine *machine, int start, int end, TIL sss = ss; sst = st; } +#endif - if (shade) - { - if (sr > 0xff) sr = 0xff; - if (sg > 0xff) sg = 0xff; - if (sb > 0xff) sb = 0xff; - if (sa > 0xff) sa = 0xff; - if (sr < 0) sr = 0; - if (sg < 0) sg = 0; - if (sb < 0) sb = 0; - if (sa < 0) sa = 0; - shade_color.i.r = sr; - shade_color.i.g = sg; - shade_color.i.b = sb; - shade_color.i.a = sa; - } +#if defined(SHADE) + if (sr > 0xff) sr = 0xff; + if (sg > 0xff) sg = 0xff; + if (sb > 0xff) sb = 0xff; + if (sa > 0xff) sa = 0xff; + if (sr < 0) sr = 0; + if (sg < 0) sg = 0; + if (sb < 0) sb = 0; + if (sa < 0) sa = 0; + shade_color.i.r = sr; + shade_color.i.g = sg; + shade_color.i.b = sb; + shade_color.i.a = sa; +#endif - if (texture) - { - TEXTURE_PIPELINE(&texel0_color, sss, sst, tex_tile); - } +#if defined(TEXTURE) + TEXTURE_PIPELINE(&texel0_color, sss, sst, tex_tile); +#endif - c1 = COLOR_COMBINER1(machine); + COLOR_COMBINER1(&c1); - if ((zbuffer || other_modes.z_source_sel) && other_modes.z_compare_en) +#if defined(ZCOMPARE) +#if !defined(ZBUF) + if (other_modes.z_source_sel) +#endif { z_compare_result = z_compare(fbcur, hbcur, zbcur, zhbcur, sz, dzpix); } if(z_compare_result) +#endif { int rendered = 0; int dith = 0; @@ -196,44 +491,326 @@ static void render_spans_16_c1(running_machine *machine, int start, int end, TIL dith = bayer_matrix[(((i) & 3) << 2) + ((x ^ WORD_ADDR_XOR) & 3)]; } - rendered = BLENDER1_16(machine, fbcur, hbcur, c1, dith); + rendered = BLENDER1_16(fbcur, hbcur, c1, dith); - if (other_modes.z_update_en && rendered) +#if defined(ZUPDATE) + if (rendered) { z_store(zbcur, zhbcur, sz, dzpix); } +#endif } } } - if (shade) - { - r.w += drinc; - g.w += dginc; - b.w += dbinc; - a.w += dainc; - } - z.w += dzinc; +#if defined(SHADE) + r.w += drinc; + g.w += dginc; + b.w += dbinc; + a.w += dainc; +#endif +#if defined(TEXTURE) s.w += dsinc; t.w += dtinc; w.w += dwinc; +#endif +#if defined(ZBUF) + z.w += dzinc; +#endif - x += xinc; +#if defined(FLIP) + x++; +#else + x--; +#endif } } } -static void render_spans_16_c2(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip) +#if defined(SHADE) + #if defined(TEXTURE) + #if defined(ZBUF) + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_t_z_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_t_z_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_t_z_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_t_z_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_t_z_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_t_z_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_t_z_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #else + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_t_nz_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_t_nz_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_t_nz_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_t_nz_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_t_nz_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #endif + #else + #if defined(ZBUF) + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_nt_z_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_nt_z_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_nt_z_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_nt_z_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_nt_z_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #else + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_nt_nz_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_nt_nz_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_s_nt_nz_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_s_nt_nz_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #endif + #endif +#else + #if defined(TEXTURE) + #if defined(ZBUF) + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_t_z_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_t_z_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_t_z_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_t_z_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_t_z_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_t_z_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_t_z_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #else + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_t_nz_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_t_nz_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_t_nz_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_t_nz_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_t_nz_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #endif + #else + #if defined(ZBUF) + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_nt_z_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_nt_z_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_nt_z_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_nt_z_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_nt_z_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #else + #if defined(FLIP) + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_nt_nz_f_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_nt_nz_f_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #else + #if defined(ZUPDATE) + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile) + #endif + #else + #if defined(ZCOMPARE) + static void render_spans_16_c2_ns_nt_nz_nf_zc(int start, int end, TILE* tex_tile) + #else + static void render_spans_16_c2_ns_nt_nz_nf_nzc(int start, int end, TILE* tex_tile) + #endif + #endif + #endif + #endif + #endif +#endif { UINT16 *fb = (UINT16*)&rdram[fb_address / 4]; - UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; UINT8 *hb = &hidden_bits[fb_address >> 1]; +#if defined(ZUPDATE) || defined(ZCOMPARE) + UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; 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; + SPAN_PARAM db = span[0].db; + SPAN_PARAM da = span[0].da; +#if defined(FLIP) + int drinc = dr.w; + int dginc = dg.w; + int dbinc = db.w; + int dainc = da.w; +#else + int drinc = -dr.w; + int dginc = -dg.w; + int dbinc = -db.w; + int dainc = -da.w; +#endif +#endif + +#if defined(TEXTURE) UINT32 prim_tile = tex_tile->num; UINT32 tilenum2 = 0; TILE *tex_tile2 = NULL; @@ -245,44 +822,57 @@ static void render_spans_16_c2(running_machine *machine, int start, int end, TIL UINT32 magnify = 0; UINT32 distant = 0; - SPAN_PARAM dr = span[0].dr; - SPAN_PARAM dg = span[0].dg; - SPAN_PARAM db = span[0].db; - SPAN_PARAM da = span[0].da; - SPAN_PARAM dz = span[0].dz; - SPAN_PARAM ds = span[0].ds; - 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; - int nexts, nextt, nextsw; int lodclamp = 0; + SPAN_PARAM ds = span[0].ds; + SPAN_PARAM dt = span[0].dt; + SPAN_PARAM dw = span[0].dw; +#if defined(FLIP) + int dsinc = ds.w; + int dtinc = dt.w; + int dwinc = dw.w; +#else + int dsinc = -ds.w; + int dtinc = -dt.w; + int dwinc = -dw.w; +#endif +#endif + +#if defined(ZBUF) + SPAN_PARAM dz = span[0].dz; + int dzpix = span[0].dzpix; +#if defined(FLIP) + int dzinc = dz.w; +#else + int dzinc = -dz.w; +#endif +#else + int sz = 0, dzpix = 0; + + if (other_modes.z_source_sel) + { + sz = (((UINT32)primitive_z) << 3) & 0x3ffff; + dzpix = primitive_delta_z; + } +#endif + +#if defined(TEXTURE) calculate_clamp_diffs(tex_tile->num); - clipx1 = clip.xh / 4; - clipx2 = clip.xl / 4; - clipy1 = clip.yh / 4; - clipy2 = clip.yl / 4; - - if (texture && !other_modes.tex_lod_en) + if (!other_modes.tex_lod_en) { tilenum = prim_tile; tex_tile = &tile[tilenum]; tilenum2 = (prim_tile + 1) & 7; tex_tile2 = &tile[tilenum2]; } +#endif - 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; + clipx1 = clip.xh / 4; + clipx2 = clip.xl / 4; + clipy1 = clip.yh / 4; + clipy2 = clip.yl / 4; if (start < clipy1) { @@ -301,82 +891,105 @@ static void render_spans_16_c2(running_machine *machine, int start, int end, TIL end = clipy2 - 1; } - set_shade_for_tris(shade); // Needed by backgrounds in Top Gear Rally 1 +#if !defined(SHADE) + shade_color.c = prim_color.c; +#endif for (i = start; i <= end; i++) { int xstart = span[i].lx; int xend = span[i].rx; - SPAN_PARAM r; - SPAN_PARAM g; - SPAN_PARAM b; - SPAN_PARAM a; - SPAN_PARAM z = span[i].z; +#if defined(SHADE) + SPAN_PARAM r = span[i].r; + SPAN_PARAM g = span[i].g; + SPAN_PARAM b = span[i].b; + SPAN_PARAM a = span[i].a; +#endif +#if defined(TEXTURE) SPAN_PARAM s = span[i].s; SPAN_PARAM t = span[i].t; SPAN_PARAM w = span[i].w; +#endif +#if defined(ZBUF) + SPAN_PARAM z = span[i].z; +#endif int x; int fb_index = fb_width * i; int length; - if (shade) - { - r = span[i].r; - g = span[i].g; - b = span[i].b; - a = span[i].a; - } - x = xend; - length = flip ? (xstart - xend) : (xend - xstart); //Moogly +#if defined(FLIP) + length = (xstart - xend); +#else + length = (xend - xstart); +#endif for (j = 0; j <= length; j++) { - int sr = 0, sg = 0, sb = 0, sa = 0; +#if defined(SHADE) + int sr = r.h.h; + int sg = g.h.h; + int sb = b.h.h; + int sa = a.h.h; +#endif +#if defined(TEXTURE) int ss = s.h.h; int st = t.h.h; int sw = w.h.h; - int sz = z.w >> 13; int sss = 0, sst = 0; +#endif +#if defined(ZBUF) + int sz = z.w >> 13; +#endif COLOR c1, c2; - if (shade) - { - sr = r.h.h; - sg = g.h.h; - sb = b.h.h; - sa = a.h.h; - } - c1.c = 0; - c2.c = 0; + //c1.c = 0; + //c2.c = 0; + +#if defined(ZBUF) if (other_modes.z_source_sel) { sz = (((UINT32)primitive_z) << 3) & 0x3ffff; dzpix = primitive_delta_z; } - +#endif if (x >= clipx1 && x < clipx2) { +#if defined(ZCOMPARE) int z_compare_result = 1; +#endif curpixel_cvg=span[i].cvg[x]; - if (curpixel_cvg > 8) - { - stricterror("render_spans_16: cvg of current pixel is %d", curpixel_cvg); - } - if (curpixel_cvg) { int curpixel = fb_index + x; UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR]; - UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR]; +#if defined(ZUPDATE) || defined(ZCOMPARE) + UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR]; +#endif +#if defined(SHADE) + if (sr > 0xff) sr = 0xff; + if (sg > 0xff) sg = 0xff; + if (sb > 0xff) sb = 0xff; + if (sa > 0xff) sa = 0xff; + if (sr < 0) sr = 0; + if (sg < 0) sg = 0; + if (sb < 0) sb = 0; + if (sa < 0) sa = 0; + shade_color.i.r = sr; + shade_color.i.g = sg; + shade_color.i.b = sb; + shade_color.i.a = sa; +#endif + +#if defined(TEXTURE) if (other_modes.persp_tex_en) { tcdiv(ss, st, sw, &sss, &sst); @@ -493,37 +1106,23 @@ static void render_spans_16_c2(running_machine *machine, int start, int end, TIL } } - if (shade) - { - if (sr > 0xff) sr = 0xff; - if (sg > 0xff) sg = 0xff; - if (sb > 0xff) sb = 0xff; - if (sa > 0xff) sa = 0xff; - if (sr < 0) sr = 0; - if (sg < 0) sg = 0; - if (sb < 0) sb = 0; - if (sa < 0) sa = 0; - shade_color.i.r = sr; - shade_color.i.g = sg; - shade_color.i.b = sb; - shade_color.i.a = sa; - } + TEXTURE_PIPELINE(&texel0_color, sss, sst, tex_tile); + TEXTURE_PIPELINE(&texel1_color, sss, sst, tex_tile2); +#endif - if (texture) - { - TEXTURE_PIPELINE(&texel0_color, sss, sst, tex_tile); - TEXTURE_PIPELINE(&texel1_color, sss, sst, tex_tile2); - } + COLOR_COMBINER2_C0(&c1); + COLOR_COMBINER2_C1(&c2); - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); - - if ((zbuffer || other_modes.z_source_sel) && other_modes.z_compare_en) +#if defined(ZCOMPARE) +#if !defined(ZBUF) + if (other_modes.z_source_sel) +#endif { z_compare_result = z_compare(fbcur, hbcur, zbcur, zhbcur, sz, dzpix); } if(z_compare_result) +#endif { int rendered = 0; int dith = 0; @@ -536,29 +1135,38 @@ static void render_spans_16_c2(running_machine *machine, int start, int end, TIL dith = bayer_matrix[(((i) & 3) << 2) + ((x ^ WORD_ADDR_XOR) & 3)]; } - rendered = BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith); + rendered = BLENDER2_16(fbcur, hbcur, c1, c2, dith); - if (other_modes.z_update_en && rendered) +#if defined(ZUPDATE) + if (rendered) { z_store(zbcur, zhbcur, sz, dzpix); } +#endif } } } - if (shade) - { - r.w += drinc; - g.w += dginc; - b.w += dbinc; - a.w += dainc; - } - z.w += dzinc; +#if defined(SHADE) + r.w += drinc; + g.w += dginc; + b.w += dbinc; + a.w += dainc; +#endif +#if defined(TEXTURE) s.w += dsinc; t.w += dtinc; w.w += dwinc; +#endif +#if defined(ZBUF) + z.w += dzinc; +#endif - x += xinc; +#if defined(FLIP) + x++; +#else + x--; +#endif } } } diff --git a/src/mame/video/rdpspn16.h b/src/mame/video/rdpspn16.h index f8c5fce3958..4d12aab53e3 100644 --- a/src/mame/video/rdpspn16.h +++ b/src/mame/video/rdpspn16.h @@ -1,7 +1,202 @@ -static void render_spans_16_c1(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip); -static void render_spans_16_c2(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip); +INLINE void render_spans_16_c1_ns_nt_nz_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_nz_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_z_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_z_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_nz_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_nz_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_z_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_z_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_nz_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_nz_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_z_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_z_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_nz_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_nz_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_z_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_z_nf_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_nz_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_nz_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_z_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_z_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_nz_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_nz_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_z_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_z_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_nz_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_nz_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_z_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_z_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_nz_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_nz_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_z_f_nzc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_z_f_nzc(int start, int end, TILE* tex_tile); -static void (*rdp_render_spans_16_func[4])(running_machine*, int, int, TILE*, int, int, int, int) = +INLINE void render_spans_16_c1_ns_nt_nz_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_nz_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_z_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_z_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_nz_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_nz_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_z_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_z_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_nz_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_nz_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_z_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_z_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_nz_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_nz_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_z_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_z_nf_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_nz_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_nz_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_z_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_z_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_nz_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_nz_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_z_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_z_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_nz_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_nz_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_z_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_z_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_nz_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_nz_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_z_f_zc(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_z_f_zc(int start, int end, TILE* tex_tile); + +INLINE void render_spans_16_c1_ns_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_z_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_z_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_z_f_nzc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_z_f_nzc_zu(int start, int end, TILE* tex_tile); + +INLINE void render_spans_16_c1_ns_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_z_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_z_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_z_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_z_nf_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_nt_z_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_nt_z_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_nz_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_nz_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_ns_t_z_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_ns_t_z_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_nt_z_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_nt_z_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_nz_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_nz_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c1_s_t_z_f_zc_zu(int start, int end, TILE* tex_tile); +INLINE void render_spans_16_c2_s_t_z_f_zc_zu(int start, int end, TILE* tex_tile); + +static void (*rdp_render_spans_16_func[128])(int, int, TILE*) = { - render_spans_16_c1, render_spans_16_c2, render_spans_16_c1, render_spans_16_c1 + render_spans_16_c1_ns_nt_nz_nf_nzc, render_spans_16_c2_ns_nt_nz_nf_nzc, + render_spans_16_c1_ns_nt_z_nf_nzc, render_spans_16_c2_ns_nt_z_nf_nzc, + render_spans_16_c1_ns_t_nz_nf_nzc, render_spans_16_c2_ns_t_nz_nf_nzc, + render_spans_16_c1_ns_t_z_nf_nzc, render_spans_16_c2_ns_t_z_nf_nzc, + render_spans_16_c1_s_nt_nz_nf_nzc, render_spans_16_c2_s_nt_nz_nf_nzc, + render_spans_16_c1_s_nt_z_nf_nzc, render_spans_16_c2_s_nt_z_nf_nzc, + render_spans_16_c1_s_t_nz_nf_nzc, render_spans_16_c2_s_t_nz_nf_nzc, + render_spans_16_c1_s_t_z_nf_nzc, render_spans_16_c2_s_t_z_nf_nzc, + render_spans_16_c1_ns_nt_nz_f_nzc, render_spans_16_c2_ns_nt_nz_f_nzc, + render_spans_16_c1_ns_nt_z_f_nzc, render_spans_16_c2_ns_nt_z_f_nzc, + render_spans_16_c1_ns_t_nz_f_nzc, render_spans_16_c2_ns_t_nz_f_nzc, + render_spans_16_c1_ns_t_z_f_nzc, render_spans_16_c2_ns_t_z_f_nzc, + render_spans_16_c1_s_nt_nz_f_nzc, render_spans_16_c2_s_nt_nz_f_nzc, + render_spans_16_c1_s_nt_z_f_nzc, render_spans_16_c2_s_nt_z_f_nzc, + render_spans_16_c1_s_t_nz_f_nzc, render_spans_16_c2_s_t_nz_f_nzc, + render_spans_16_c1_s_t_z_f_nzc, render_spans_16_c2_s_t_z_f_nzc, + + render_spans_16_c1_ns_nt_nz_nf_zc, render_spans_16_c2_ns_nt_nz_nf_zc, + render_spans_16_c1_ns_nt_z_nf_zc, render_spans_16_c2_ns_nt_z_nf_zc, + render_spans_16_c1_ns_t_nz_nf_zc, render_spans_16_c2_ns_t_nz_nf_zc, + render_spans_16_c1_ns_t_z_nf_zc, render_spans_16_c2_ns_t_z_nf_zc, + render_spans_16_c1_s_nt_nz_nf_zc, render_spans_16_c2_s_nt_nz_nf_zc, + render_spans_16_c1_s_nt_z_nf_zc, render_spans_16_c2_s_nt_z_nf_zc, + render_spans_16_c1_s_t_nz_nf_zc, render_spans_16_c2_s_t_nz_nf_zc, + render_spans_16_c1_s_t_z_nf_zc, render_spans_16_c2_s_t_z_nf_zc, + render_spans_16_c1_ns_nt_nz_f_zc, render_spans_16_c2_ns_nt_nz_f_zc, + render_spans_16_c1_ns_nt_z_f_zc, render_spans_16_c2_ns_nt_z_f_zc, + render_spans_16_c1_ns_t_nz_f_zc, render_spans_16_c2_ns_t_nz_f_zc, + render_spans_16_c1_ns_t_z_f_zc, render_spans_16_c2_ns_t_z_f_zc, + render_spans_16_c1_s_nt_nz_f_zc, render_spans_16_c2_s_nt_nz_f_zc, + render_spans_16_c1_s_nt_z_f_zc, render_spans_16_c2_s_nt_z_f_zc, + render_spans_16_c1_s_t_nz_f_zc, render_spans_16_c2_s_t_nz_f_zc, + render_spans_16_c1_s_t_z_f_zc, render_spans_16_c2_s_t_z_f_zc, + + render_spans_16_c1_ns_nt_nz_nf_nzc_zu, render_spans_16_c2_ns_nt_nz_nf_nzc_zu, + render_spans_16_c1_ns_nt_z_nf_nzc_zu, render_spans_16_c2_ns_nt_z_nf_nzc_zu, + render_spans_16_c1_ns_t_nz_nf_nzc_zu, render_spans_16_c2_ns_t_nz_nf_nzc_zu, + render_spans_16_c1_ns_t_z_nf_nzc_zu, render_spans_16_c2_ns_t_z_nf_nzc_zu, + render_spans_16_c1_s_nt_nz_nf_nzc_zu, render_spans_16_c2_s_nt_nz_nf_nzc_zu, + render_spans_16_c1_s_nt_z_nf_nzc_zu, render_spans_16_c2_s_nt_z_nf_nzc_zu, + render_spans_16_c1_s_t_nz_nf_nzc_zu, render_spans_16_c2_s_t_nz_nf_nzc_zu, + render_spans_16_c1_s_t_z_nf_nzc_zu, render_spans_16_c2_s_t_z_nf_nzc_zu, + render_spans_16_c1_ns_nt_nz_f_nzc_zu, render_spans_16_c2_ns_nt_nz_f_nzc_zu, + render_spans_16_c1_ns_nt_z_f_nzc_zu, render_spans_16_c2_ns_nt_z_f_nzc_zu, + render_spans_16_c1_ns_t_nz_f_nzc_zu, render_spans_16_c2_ns_t_nz_f_nzc_zu, + render_spans_16_c1_ns_t_z_f_nzc_zu, render_spans_16_c2_ns_t_z_f_nzc_zu, + render_spans_16_c1_s_nt_nz_f_nzc_zu, render_spans_16_c2_s_nt_nz_f_nzc_zu, + render_spans_16_c1_s_nt_z_f_nzc_zu, render_spans_16_c2_s_nt_z_f_nzc_zu, + render_spans_16_c1_s_t_nz_f_nzc_zu, render_spans_16_c2_s_t_nz_f_nzc_zu, + render_spans_16_c1_s_t_z_f_nzc_zu, render_spans_16_c2_s_t_z_f_nzc_zu, + + render_spans_16_c1_ns_nt_nz_nf_zc_zu, render_spans_16_c2_ns_nt_nz_nf_zc_zu, + render_spans_16_c1_ns_nt_z_nf_zc_zu, render_spans_16_c2_ns_nt_z_nf_zc_zu, + render_spans_16_c1_ns_t_nz_nf_zc_zu, render_spans_16_c2_ns_t_nz_nf_zc_zu, + render_spans_16_c1_ns_t_z_nf_zc_zu, render_spans_16_c2_ns_t_z_nf_zc_zu, + render_spans_16_c1_s_nt_nz_nf_zc_zu, render_spans_16_c2_s_nt_nz_nf_zc_zu, + render_spans_16_c1_s_nt_z_nf_zc_zu, render_spans_16_c2_s_nt_z_nf_zc_zu, + render_spans_16_c1_s_t_nz_nf_zc_zu, render_spans_16_c2_s_t_nz_nf_zc_zu, + render_spans_16_c1_s_t_z_nf_zc_zu, render_spans_16_c2_s_t_z_nf_zc_zu, + render_spans_16_c1_ns_nt_nz_f_zc_zu, render_spans_16_c2_ns_nt_nz_f_zc_zu, + render_spans_16_c1_ns_nt_z_f_zc_zu, render_spans_16_c2_ns_nt_z_f_zc_zu, + render_spans_16_c1_ns_t_nz_f_zc_zu, render_spans_16_c2_ns_t_nz_f_zc_zu, + render_spans_16_c1_ns_t_z_f_zc_zu, render_spans_16_c2_ns_t_z_f_zc_zu, + render_spans_16_c1_s_nt_nz_f_zc_zu, render_spans_16_c2_s_nt_nz_f_zc_zu, + render_spans_16_c1_s_nt_z_f_zc_zu, render_spans_16_c2_s_nt_z_f_zc_zu, + render_spans_16_c1_s_t_nz_f_zc_zu, render_spans_16_c2_s_t_nz_f_zc_zu, + render_spans_16_c1_s_t_z_f_zc_zu, render_spans_16_c2_s_t_z_f_zc_zu, }; diff --git a/src/mame/video/rdptpipe.c b/src/mame/video/rdptpipe.c index 964283fe733..8d9145dbe28 100644 --- a/src/mame/video/rdptpipe.c +++ b/src/mame/video/rdptpipe.c @@ -45,30 +45,12 @@ INLINE void TEXTURE_PIPELINE_BILINEAR_NMID(COLOR* TEX, INT32 SSS, INT32 SST, TIL INVTF = 0x20 - TFRAC; } + FETCH_TEXEL(&t1, sss2, sst1, tex_tile); + FETCH_TEXEL(&t2, sss1, sst2, tex_tile); + if (!upper) { FETCH_TEXEL(&t0, sss1, sst1, tex_tile); - } - FETCH_TEXEL(&t1, sss2, sst1, tex_tile); - FETCH_TEXEL(&t2, sss1, sst2, tex_tile); - if (upper) - { - FETCH_TEXEL(&t3, sss2, sst2, tex_tile); - } - - if (upper) - { - R32 = t3.i.r + ((INVSF*(t2.i.r - t3.i.r))>>5) + ((INVTF*(t1.i.r - t3.i.r))>>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); 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); @@ -78,6 +60,18 @@ INLINE void TEXTURE_PIPELINE_BILINEAR_NMID(COLOR* TEX, INT32 SSS, INT32 SST, TIL 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 + { + FETCH_TEXEL(&t3, sss2, sst2, tex_tile); + R32 = t3.i.r + ((INVSF*(t2.i.r - t3.i.r))>>5) + ((INVTF*(t1.i.r - t3.i.r))>>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; + } } INLINE void TEXTURE_PIPELINE_BILINEAR_MID(COLOR* TEX, INT32 SSS, INT32 SST, TILE* tex_tile) diff --git a/src/mame/video/rdptrect.c b/src/mame/video/rdptrect.c index 093c409d166..5b07e9c8975 100644 --- a/src/mame/video/rdptrect.c +++ b/src/mame/video/rdptrect.c @@ -1,14 +1,51 @@ -static void texture_rectangle_16bit_c1_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect) +#if defined(ZCOMPARE) + #if defined(ZUPDATE) + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_c1_zc_zu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_c1_zc_zu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_c1_zc_zu_dn(TEX_RECTANGLE *rect) + #endif + #else + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_c1_zc_nzu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_c1_zc_nzu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_c1_zc_nzu_dn(TEX_RECTANGLE *rect) + #endif + #endif +#else + #if defined(ZUPDATE) + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_c1_nzc_zu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_c1_nzc_zu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_c1_nzc_zu_dn(TEX_RECTANGLE *rect) + #endif + #else + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_c1_nzc_nzu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_c1_nzc_nzu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_c1_nzc_nzu_dn(TEX_RECTANGLE *rect) + #endif + #endif +#endif { UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)]; - UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; UINT8 *hb = &hidden_bits[fb_address >> 1]; +#if (defined(ZCOMPARE) || defined(ZUPDATE)) + UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; UINT8 *zhb = &hidden_bits[zb_address >> 1]; +#endif int i, j; int x1, x2, y1, y2; int s, t; - int ss, st; int clipx1, clipx2, clipy1, clipy2; @@ -47,13 +84,26 @@ static void texture_rectangle_16bit_c1_nzc_nzu(running_machine *machine, TEX_REC set_shade_for_rects(); // Needed by Pilotwings 64 + if(rect->flip) + { + int temp = rect->t; + rect->t = rect->s; + rect->s = temp; + temp = rect->dtdy; + rect->dtdy = rect->dsdx; + rect->dsdx= temp; + } + t = ((int)(rect->t)) << 5; for (j = y1; j < y2; j++) { - int fb_index = j * fb_width; 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)) << 5; for (i = x1; i < x2; i++) @@ -61,371 +111,51 @@ static void texture_rectangle_16bit_c1_nzc_nzu(running_machine *machine, TEX_REC if (i >= clipx1 && i < clipx2) { COLOR c; +#if defined(ZUPDATE) int rendered = 0; +#endif int dith = 0; int curpixel = fb_index + i; UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR]; - UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR]; - UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR]; - - curpixel_cvg = 8; - - ss = s >> 5; - st = t >> 5; - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - } - - c = COLOR_COMBINER1(machine); - - if (!other_modes.rgb_dither_sel) - { - dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - else if (other_modes.rgb_dither_sel == 1) - { - dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - - - rendered = BLENDER1_16(machine, fbcur, hbcur, c, dith); - - if (other_modes.z_update_en && other_modes.z_source_sel && rendered) - { - z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z); - } - } - - s += (int)(rect->dsdx); - } - } - t += (int)(rect->dtdy); - } -} - -static void texture_rectangle_16bit_c2_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect) -{ - UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)]; - UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; - UINT8 *hb = &hidden_bits[fb_address >> 1]; - UINT8 *zhb = &hidden_bits[zb_address >> 1]; - - 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); - - if (x2<=x1) - { - x2 = x1 + 1; - } - if (y1==y2) - { - y2 = y1 + 1; // Needed by Goldeneye - } - - if ((rect->xl & 3) == 3) // Needed by Mega Man 64 - { - x2++; - } - if ((rect->yl & 3) == 3) - { - 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) - { - tilenum2 = (tilenum + 1) & 7; - tex_tile2 = &tile[tilenum2]; - } - else - { - tilenum2 = (tilenum + 1) & 7; - tex_tile2 = &tile[tilenum2]; - } - - - set_shade_for_rects(); // Needed by Pilotwings 64 - - t = ((int)(rect->t)) << 5; - - for (j = y1; j < y2; j++) - { - int fb_index = j * fb_width; - - if (j >= clipy1 && j < clipy2) - { - s = (int)(rect->s) << 5; - - for (i = x1; i < x2; i++) - { - if (i >= clipx1 && i < clipx2) - { - COLOR c1, c2; - int rendered=0; - int curpixel = fb_index + i; - UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR]; +#if (defined(ZCOMPARE) || defined(ZUPDATE)) UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; - UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR]; UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR]; - int dith = 0; +#endif curpixel_cvg = 8; - ss = s >> 5; - st = t >> 5; + TEXTURE_PIPELINE(&texel0_color, s >> 5, t >> 5, tex_tile); - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - TEXTURE_PIPELINE(&texel1_color, st, ss, tex_tile2); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2); - } - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); + COLOR_COMBINER1(&c); - if (!other_modes.rgb_dither_sel) - { - dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - else if (other_modes.rgb_dither_sel == 1) - { - dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - - rendered = BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith); - - if (other_modes.z_update_en && other_modes.z_source_sel && rendered) - { - z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z); - } - } - - s += (rect->dsdx); - } - } - t += (rect->dtdy); - } -} - -static void texture_rectangle_16bit_cc_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect) -{ - UINT16 *fb = (UINT16*)&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; - TILE *tex_tile = &tile[rect->tilenum]; - - x1 = (rect->xh / 4); - x2 = (rect->xl / 4); - y1 = (rect->yh / 4); - y2 = (rect->yl / 4); - - if (x2<=x1) - { - x2 = x1 + 1; - } - if (y1==y2) - { - y2 = y1 + 1; // Needed by Goldeneye - } - - rect->dsdx /= 4; - x2 += 1; - y2 += 1; - - clipx1 = clip.xh / 4; - clipx2 = clip.xl / 4; - clipy1 = clip.yh / 4; - clipy2 = clip.yl / 4; - - calculate_clamp_diffs(tilenum); - - set_shade_for_rects(); // Needed by Pilotwings 64 - - t = ((int)(rect->t)) << 5; - - for (j = y1; j < y2; j++) - { - int fb_index = j * fb_width; - if (j >= clipy1 && j < clipy2) - { - s = (int)(rect->s) << 5; - - for (i = x1; i < x2; i++) - { - if (i >= clipx1 && i < clipx2) - { - ss = s >> 5; - st = t >> 5; - - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - } - - 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; - } - } - s += rect->dsdx; - } - } - t += rect->dtdy; - } -} - -static void texture_rectangle_16bit_cf_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect) -{ - fatalerror("texture_rectangle with FILL cycle type is not supported\n"); -} - -static void texture_rectangle_16bit_c1_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect) -{ - UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)]; - UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; - UINT8 *hb = &hidden_bits[fb_address >> 1]; - UINT8 *zhb = &hidden_bits[zb_address >> 1]; - - int i, j; - int x1, x2, y1, y2; - int s, t; - int ss, st; - - 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); - - if (x2<=x1) - { - x2 = x1 + 1; - } - if (y1==y2) - { - y2 = y1 + 1; // Needed by Goldeneye - } - - if ((rect->xl & 3) == 3) // Needed by Mega Man 64 - { - x2++; - } - if ((rect->yl & 3) == 3) - { - y2++; - } - - clipx1 = clip.xh / 4; - clipx2 = clip.xl / 4; - clipy1 = clip.yh / 4; - clipy2 = clip.yl / 4; - - calculate_clamp_diffs(tilenum); - - set_shade_for_rects(); // Needed by Pilotwings 64 - - t = ((int)(rect->t)) << 5; - - for (j = y1; j < y2; j++) - { - int fb_index = j * fb_width; - if (j >= clipy1 && j < clipy2) - { - s = ((int)(rect->s)) << 5; - - for (i = x1; i < x2; i++) - { - if (i >= clipx1 && i < clipx2) - { - COLOR c; - int rendered = 0; - int dith = 0; - int curpixel = fb_index + i; - UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR]; - UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; - UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR]; - UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR]; - - curpixel_cvg = 8; - - ss = s >> 5; - st = t >> 5; - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - } - - c = COLOR_COMBINER1(machine); - - if (!other_modes.rgb_dither_sel) - { - dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - else if (other_modes.rgb_dither_sel == 1) - { - dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } +#if defined(MAGICDITHER) + dith = magic_matrix[mline + ((i ^ WORD_ADDR_XOR) & 3)]; +#elif defined(BAYERDITHER) + dith = bayer_matrix[mline + ((i ^ WORD_ADDR_XOR) & 3)]; +#endif +#if defined(ZCOMPARE) if (z_compare(fbcur, hbcur, zbcur, zhbcur, ((UINT32)primitive_z)<<3,primitive_delta_z)) { - rendered = BLENDER1_16(machine, fbcur, hbcur, c, dith); +#if defined(ZUPDATE) + rendered = BLENDER1_16(fbcur, hbcur, c, dith); +#else + BLENDER1_16(fbcur, hbcur, c, dith); +#endif } +#elif defined(ZUPDATE) + rendered = BLENDER1_16(fbcur, hbcur, c, dith); +#else + BLENDER1_16(fbcur, hbcur, c, dith); +#endif - if (other_modes.z_update_en && other_modes.z_source_sel && rendered) +#if defined(ZUPDATE) + if(rendered) { z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z); } +#endif } s += (int)(rect->dsdx); @@ -435,12 +165,50 @@ static void texture_rectangle_16bit_c1_zc_nzu(running_machine *machine, TEX_RECT } } -static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect) +#if defined(ZCOMPARE) + #if defined(ZUPDATE) + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_c2_zc_zu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_c2_zc_zu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_c2_zc_zu_dn(TEX_RECTANGLE *rect) + #endif + #else + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_c2_zc_nzu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_c2_zc_nzu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_c2_zc_nzu_dn(TEX_RECTANGLE *rect) + #endif + #endif +#else + #if defined(ZUPDATE) + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_c2_nzc_zu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_c2_nzc_zu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_c2_nzc_zu_dn(TEX_RECTANGLE *rect) + #endif + #else + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_c2_nzc_nzu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_c2_nzc_nzu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_c2_nzc_nzu_dn(TEX_RECTANGLE *rect) + #endif + #endif +#endif { UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)]; - UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; UINT8 *hb = &hidden_bits[fb_address >> 1]; +#if (defined(ZCOMPARE) || defined(ZUPDATE)) + UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; UINT8 *zhb = &hidden_bits[zb_address >> 1]; +#endif int i, j; int x1, x2, y1, y2; @@ -498,14 +266,27 @@ static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECT set_shade_for_rects(); // Needed by Pilotwings 64 + if(rect->flip) + { + int temp = rect->t; + rect->t = rect->s; + rect->s = temp; + temp = rect->dtdy; + rect->dtdy = rect->dsdx; + rect->dsdx= temp; + } + t = ((int)(rect->t)) << 5; for (j = y1; j < y2; j++) { - int fb_index = j * fb_width; 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) << 5; for (i = x1; i < x2; i++) @@ -513,12 +294,16 @@ static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECT if (i >= clipx1 && i < clipx2) { COLOR c1, c2; +#if defined(ZUPDATE) int rendered=0; +#endif int curpixel = fb_index + i; UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR]; - UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR]; +#if (defined(ZCOMPARE) || defined(ZUPDATE)) + UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR]; +#endif int dith = 0; curpixel_cvg = 8; @@ -526,679 +311,41 @@ static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECT ss = s >> 5; st = t >> 5; - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - TEXTURE_PIPELINE(&texel1_color, st, ss, tex_tile2); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2); - } - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); + TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); + TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2); - if (!other_modes.rgb_dither_sel) - { - dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - else if (other_modes.rgb_dither_sel == 1) - { - dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } + COLOR_COMBINER2_C0(&c1); + COLOR_COMBINER2_C1(&c2); - if (z_compare(fbcur, hbcur, zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z)) - { - rendered = BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith); - } - - if (other_modes.z_update_en && other_modes.z_source_sel && rendered) - { - z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z); - } - } - - s += (rect->dsdx); - } - } - t += (rect->dtdy); - } -} - -static void texture_rectangle_16bit_cc_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect) -{ - UINT16 *fb = (UINT16*)&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; - TILE *tex_tile = &tile[rect->tilenum]; - - x1 = (rect->xh / 4); - x2 = (rect->xl / 4); - y1 = (rect->yh / 4); - y2 = (rect->yl / 4); - - if (x2<=x1) - { - x2 = x1 + 1; - } - if (y1==y2) - { - y2 = y1 + 1; // Needed by Goldeneye - } - - rect->dsdx /= 4; - x2 += 1; - y2 += 1; - - clipx1 = clip.xh / 4; - clipx2 = clip.xl / 4; - clipy1 = clip.yh / 4; - clipy2 = clip.yl / 4; - - calculate_clamp_diffs(tilenum); - - set_shade_for_rects(); // Needed by Pilotwings 64 - - t = ((int)(rect->t)) << 5; - - for (j = y1; j < y2; j++) - { - int fb_index = j * fb_width; - if (j >= clipy1 && j < clipy2) - { - s = (int)(rect->s) << 5; - - for (i = x1; i < x2; i++) - { - if (i >= clipx1 && i < clipx2) - { - ss = s >> 5; - st = t >> 5; - - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - } - - 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; - } - } - s += rect->dsdx; - } - } - t += rect->dtdy; - } -} - -static void texture_rectangle_16bit_cf_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect) -{ - fatalerror("texture_rectangle with FILL cycle type is not supported\n"); -} - -static void texture_rectangle_16bit_c1_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect) -{ - UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)]; - UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; - UINT8 *hb = &hidden_bits[fb_address >> 1]; - UINT8 *zhb = &hidden_bits[zb_address >> 1]; - - int i, j; - int x1, x2, y1, y2; - int s, t; - int ss, st; - - 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); - - if (x2<=x1) - { - x2 = x1 + 1; - } - if (y1==y2) - { - y2 = y1 + 1; // Needed by Goldeneye - } - - if ((rect->xl & 3) == 3) // Needed by Mega Man 64 - { - x2++; - } - if ((rect->yl & 3) == 3) - { - y2++; - } - - clipx1 = clip.xh / 4; - clipx2 = clip.xl / 4; - clipy1 = clip.yh / 4; - clipy2 = clip.yl / 4; - - calculate_clamp_diffs(tilenum); - - set_shade_for_rects(); // Needed by Pilotwings 64 - - t = ((int)(rect->t)) << 5; - - for (j = y1; j < y2; j++) - { - int fb_index = j * fb_width; - if (j >= clipy1 && j < clipy2) - { - s = ((int)(rect->s)) << 5; - - for (i = x1; i < x2; i++) - { - if (i >= clipx1 && i < clipx2) - { - COLOR c; - int dith = 0; - int curpixel = fb_index + i; - UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR]; - UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; - UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR]; - UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR]; - - curpixel_cvg = 8; - - ss = s >> 5; - st = t >> 5; - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - } - - c = COLOR_COMBINER1(machine); - - if (!other_modes.rgb_dither_sel) - { - dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - else if (other_modes.rgb_dither_sel == 1) - { - dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - - if (BLENDER1_16(machine, fbcur, hbcur, c, dith)) - { - z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z); - } - } - - s += (int)(rect->dsdx); - } - } - t += (int)(rect->dtdy); - } -} - -static void texture_rectangle_16bit_c2_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect) -{ - UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)]; - UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; - UINT8 *hb = &hidden_bits[fb_address >> 1]; - UINT8 *zhb = &hidden_bits[zb_address >> 1]; - - 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); - - if (x2<=x1) - { - x2 = x1 + 1; - } - if (y1==y2) - { - y2 = y1 + 1; // Needed by Goldeneye - } - - if ((rect->xl & 3) == 3) // Needed by Mega Man 64 - { - x2++; - } - if ((rect->yl & 3) == 3) - { - 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) - { - tilenum2 = (tilenum + 1) & 7; - tex_tile2 = &tile[tilenum2]; - } - else - { - tilenum2 = (tilenum + 1) & 7; - tex_tile2 = &tile[tilenum2]; - } - - - set_shade_for_rects(); // Needed by Pilotwings 64 - - t = ((int)(rect->t)) << 5; - - for (j = y1; j < y2; j++) - { - int fb_index = j * fb_width; - - if (j >= clipy1 && j < clipy2) - { - s = (int)(rect->s) << 5; - - for (i = x1; i < x2; i++) - { - if (i >= clipx1 && i < clipx2) - { - COLOR c1, c2; - int curpixel = fb_index + i; - UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR]; - UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; - UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR]; - UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR]; - int dith = 0; - - curpixel_cvg = 8; - - ss = s >> 5; - st = t >> 5; - - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - TEXTURE_PIPELINE(&texel1_color, st, ss, tex_tile2); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2); - } - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); - - if (!other_modes.rgb_dither_sel) - { - dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - else if (other_modes.rgb_dither_sel == 1) - { - dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - - if (BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith)) - { - z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z); - } - } - - s += (rect->dsdx); - } - } - t += (rect->dtdy); - } -} - -static void texture_rectangle_16bit_cc_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect) -{ - UINT16 *fb = (UINT16*)&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; - TILE *tex_tile = &tile[rect->tilenum]; - - x1 = (rect->xh / 4); - x2 = (rect->xl / 4); - y1 = (rect->yh / 4); - y2 = (rect->yl / 4); - - if (x2<=x1) - { - x2 = x1 + 1; - } - if (y1==y2) - { - y2 = y1 + 1; // Needed by Goldeneye - } - - rect->dsdx /= 4; - x2 += 1; - y2 += 1; - - clipx1 = clip.xh / 4; - clipx2 = clip.xl / 4; - clipy1 = clip.yh / 4; - clipy2 = clip.yl / 4; - - calculate_clamp_diffs(tilenum); - - set_shade_for_rects(); // Needed by Pilotwings 64 - - t = ((int)(rect->t)) << 5; - - for (j = y1; j < y2; j++) - { - int fb_index = j * fb_width; - if (j >= clipy1 && j < clipy2) - { - s = (int)(rect->s) << 5; - - for (i = x1; i < x2; i++) - { - if (i >= clipx1 && i < clipx2) - { - ss = s >> 5; - st = t >> 5; - - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - } - - 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; - } - } - s += rect->dsdx; - } - } - t += rect->dtdy; - } -} - -static void texture_rectangle_16bit_cf_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect) -{ - fatalerror("texture_rectangle with FILL cycle type is not supported\n"); -} - -static void texture_rectangle_16bit_c1_zc_zu(running_machine *machine, TEX_RECTANGLE *rect) -{ - UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)]; - UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; - UINT8 *hb = &hidden_bits[fb_address >> 1]; - UINT8 *zhb = &hidden_bits[zb_address >> 1]; - - int i, j; - int x1, x2, y1, y2; - int s, t; - int ss, st; - - 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); - - if (x2<=x1) - { - x2 = x1 + 1; - } - if (y1==y2) - { - y2 = y1 + 1; // Needed by Goldeneye - } - - if ((rect->xl & 3) == 3) // Needed by Mega Man 64 - { - x2++; - } - if ((rect->yl & 3) == 3) - { - y2++; - } - - clipx1 = clip.xh / 4; - clipx2 = clip.xl / 4; - clipy1 = clip.yh / 4; - clipy2 = clip.yl / 4; - - calculate_clamp_diffs(tilenum); - - set_shade_for_rects(); // Needed by Pilotwings 64 - - t = ((int)(rect->t)) << 5; - - for (j = y1; j < y2; j++) - { - int fb_index = j * fb_width; - if (j >= clipy1 && j < clipy2) - { - s = ((int)(rect->s)) << 5; - - for (i = x1; i < x2; i++) - { - if (i >= clipx1 && i < clipx2) - { - COLOR c; - int dith = 0; - int curpixel = fb_index + i; - UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR]; - UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; - UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR]; - UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR]; - - curpixel_cvg = 8; - - ss = s >> 5; - st = t >> 5; - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - } - - c = COLOR_COMBINER1(machine); - - if (!other_modes.rgb_dither_sel) - { - dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - else if (other_modes.rgb_dither_sel == 1) - { - dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } +#if defined(MAGICDITHER) + dith = magic_matrix[mline + ((i ^ WORD_ADDR_XOR) & 3)]; +#elif defined(BAYERDITHER) + dith = bayer_matrix[mline + ((i ^ WORD_ADDR_XOR) & 3)]; +#endif +#if defined(ZCOMPARE) if (z_compare(fbcur, hbcur, zbcur, zhbcur, ((UINT32)primitive_z)<<3,primitive_delta_z)) { - if(BLENDER1_16(machine, fbcur, hbcur, c, dith)) - { - z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z); - } +#if defined(ZUPDATE) + rendered = BLENDER2_16(fbcur, hbcur, c1, c2, dith); +#else + BLENDER2_16(fbcur, hbcur, c1, c2, dith); +#endif } +#else +#if defined(ZUPDATE) + rendered = BLENDER2_16(fbcur, hbcur, c1, c2, dith); +#else + BLENDER2_16(fbcur, hbcur, c1, c2, dith); +#endif +#endif - } - - s += (int)(rect->dsdx); - } - } - t += (int)(rect->dtdy); - } -} - -static void texture_rectangle_16bit_c2_zc_zu(running_machine *machine, TEX_RECTANGLE *rect) -{ - UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)]; - UINT16 *zb = (UINT16*)&rdram[zb_address / 4]; - UINT8 *hb = &hidden_bits[fb_address >> 1]; - UINT8 *zhb = &hidden_bits[zb_address >> 1]; - - 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); - - if (x2<=x1) - { - x2 = x1 + 1; - } - if (y1==y2) - { - y2 = y1 + 1; // Needed by Goldeneye - } - - if ((rect->xl & 3) == 3) // Needed by Mega Man 64 - { - x2++; - } - if ((rect->yl & 3) == 3) - { - 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) - { - tilenum2 = (tilenum + 1) & 7; - tex_tile2 = &tile[tilenum2]; - } - else - { - tilenum2 = (tilenum + 1) & 7; - tex_tile2 = &tile[tilenum2]; - } - - - set_shade_for_rects(); // Needed by Pilotwings 64 - - t = ((int)(rect->t)) << 5; - - for (j = y1; j < y2; j++) - { - int fb_index = j * fb_width; - - if (j >= clipy1 && j < clipy2) - { - s = (int)(rect->s) << 5; - - for (i = x1; i < x2; i++) - { - if (i >= clipx1 && i < clipx2) - { - COLOR c1, c2; - int curpixel = fb_index + i; - UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR]; - UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR]; - UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR]; - UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR]; - int dith = 0; - - curpixel_cvg = 8; - - ss = s >> 5; - st = t >> 5; - - if (rect->flip) +#if defined(ZUPDATE) + if(rendered) { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - TEXTURE_PIPELINE(&texel1_color, st, ss, tex_tile2); + z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z); } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2); - } - c1 = COLOR_COMBINER2_C0(machine); - c2 = COLOR_COMBINER2_C1(machine); - - if (!other_modes.rgb_dither_sel) - { - dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - else if (other_modes.rgb_dither_sel == 1) - { - dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)]; - } - - if (z_compare(fbcur, hbcur, zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z)) - { - if (BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith)) - { - z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z); - } - } - +#endif } s += (rect->dsdx); @@ -1208,7 +355,43 @@ static void texture_rectangle_16bit_c2_zc_zu(running_machine *machine, TEX_RECTA } } -static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTANGLE *rect) +#if defined(ZCOMPARE) + #if defined(ZUPDATE) + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_cc_zc_zu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_cc_zc_zu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_cc_zc_zu_dn(TEX_RECTANGLE *rect) + #endif + #else + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_cc_zc_nzu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_cc_zc_nzu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_cc_zc_nzu_dn(TEX_RECTANGLE *rect) + #endif + #endif +#else + #if defined(ZUPDATE) + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_cc_nzc_zu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_cc_nzc_zu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_cc_nzc_zu_dn(TEX_RECTANGLE *rect) + #endif + #else + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_cc_nzc_nzu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_cc_nzc_nzu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_cc_nzc_nzu_dn(TEX_RECTANGLE *rect) + #endif + #endif +#endif { UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)]; @@ -1249,8 +432,17 @@ static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTA set_shade_for_rects(); // Needed by Pilotwings 64 - t = ((int)(rect->t)) << 5; + if(rect->flip) + { + int temp = rect->t; + rect->t = rect->s; + rect->s = temp; + temp = rect->dtdy; + rect->dtdy = rect->dsdx; + rect->dsdx= temp; + } + t = ((int)(rect->t)) << 5; for (j = y1; j < y2; j++) { @@ -1266,14 +458,7 @@ static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTA ss = s >> 5; st = t >> 5; - if (rect->flip) - { - TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile); - } - else - { - TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); - } + TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile); curpixel_cvg = 8; @@ -1289,8 +474,43 @@ static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTA } } -static void texture_rectangle_16bit_cf_zc_zu(running_machine *machine, TEX_RECTANGLE *rect) +#if defined(ZCOMPARE) + #if defined(ZUPDATE) + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_cf_zc_zu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_cf_zc_zu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_cf_zc_zu_dn(TEX_RECTANGLE *rect) + #endif + #else + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_cf_zc_nzu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_cf_zc_nzu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_cf_zc_nzu_dn(TEX_RECTANGLE *rect) + #endif + #endif +#else + #if defined(ZUPDATE) + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_cf_nzc_zu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_cf_nzc_zu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_cf_nzc_zu_dn(TEX_RECTANGLE *rect) + #endif + #else + #if defined(MAGICDITHER) + static void texture_rectangle_16bit_cf_nzc_nzu_dm(TEX_RECTANGLE *rect) + #elif defined(BAYERDITHER) + static void texture_rectangle_16bit_cf_nzc_nzu_db(TEX_RECTANGLE *rect) + #else + static void texture_rectangle_16bit_cf_nzc_nzu_dn(TEX_RECTANGLE *rect) + #endif + #endif +#endif { fatalerror("texture_rectangle with FILL cycle type is not supported\n"); } - diff --git a/src/mame/video/rdptrect.h b/src/mame/video/rdptrect.h index 1922167fa53..107aba805e7 100644 --- a/src/mame/video/rdptrect.h +++ b/src/mame/video/rdptrect.h @@ -1,41 +1,69 @@ -static void texture_rectangle_16bit_c1_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c2_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cc_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cf_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c1_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cc_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cf_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c1_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c2_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cc_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cf_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c1_zc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c2_zc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cf_zc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c1_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c2_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cc_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cf_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c1_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cc_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cf_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c1_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c2_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cc_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cf_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c1_zc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_c2_zc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTANGLE *rect); -static void texture_rectangle_16bit_cf_zc_zu(running_machine *machine, TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_nzc_nzu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_nzc_nzu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_nzc_nzu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_nzc_nzu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_nzc_nzu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_nzc_nzu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_nzc_nzu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_nzc_nzu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_nzc_nzu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_nzc_nzu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_nzc_nzu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_nzc_nzu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_zc_nzu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_zc_nzu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_zc_nzu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_zc_nzu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_zc_nzu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_zc_nzu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_zc_nzu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_zc_nzu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_zc_nzu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_zc_nzu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_zc_nzu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_zc_nzu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_nzc_zu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_nzc_zu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_nzc_zu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_nzc_zu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_nzc_zu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_nzc_zu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_nzc_zu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_nzc_zu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_nzc_zu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_nzc_zu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_nzc_zu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_nzc_zu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_zc_zu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_zc_zu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c1_zc_zu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_zc_zu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_zc_zu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_c2_zc_zu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_zc_zu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_zc_zu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cc_zc_zu_dn(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_zc_zu_dm(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_zc_zu_db(TEX_RECTANGLE *rect); +static void texture_rectangle_16bit_cf_zc_zu_dn(TEX_RECTANGLE *rect); -static void (*rdp_texture_rectangle_16bit_func[16])(running_machine *, TEX_RECTANGLE *) = +static void (*rdp_texture_rectangle_16bit_func[48])(TEX_RECTANGLE *) = { - texture_rectangle_16bit_c1_nzc_nzu, texture_rectangle_16bit_c2_nzc_nzu, texture_rectangle_16bit_cc_nzc_nzu, texture_rectangle_16bit_cf_nzc_nzu, - texture_rectangle_16bit_c1_zc_nzu, texture_rectangle_16bit_c2_zc_nzu, texture_rectangle_16bit_cc_zc_nzu, texture_rectangle_16bit_cf_zc_nzu, - texture_rectangle_16bit_c1_nzc_zu, texture_rectangle_16bit_c2_nzc_zu, texture_rectangle_16bit_cc_nzc_zu, texture_rectangle_16bit_cf_nzc_zu, - texture_rectangle_16bit_c1_zc_zu, texture_rectangle_16bit_c2_zc_zu, texture_rectangle_16bit_cc_zc_zu, texture_rectangle_16bit_cf_zc_zu, + texture_rectangle_16bit_c1_nzc_nzu_dm, texture_rectangle_16bit_c1_nzc_nzu_db, texture_rectangle_16bit_c1_nzc_nzu_dn, + texture_rectangle_16bit_c2_nzc_nzu_dm, texture_rectangle_16bit_c2_nzc_nzu_db, texture_rectangle_16bit_c2_nzc_nzu_dn, + texture_rectangle_16bit_cc_nzc_nzu_dm, texture_rectangle_16bit_cc_nzc_nzu_db, texture_rectangle_16bit_cc_nzc_nzu_dn, + texture_rectangle_16bit_cf_nzc_nzu_dm, texture_rectangle_16bit_cf_nzc_nzu_db, texture_rectangle_16bit_cf_nzc_nzu_dn, + texture_rectangle_16bit_c1_zc_nzu_dm, texture_rectangle_16bit_c1_zc_nzu_db, texture_rectangle_16bit_c1_zc_nzu_dn, + texture_rectangle_16bit_c2_zc_nzu_dm, texture_rectangle_16bit_c2_zc_nzu_db, texture_rectangle_16bit_c2_zc_nzu_dn, + texture_rectangle_16bit_cc_zc_nzu_dm, texture_rectangle_16bit_cc_zc_nzu_db, texture_rectangle_16bit_cc_zc_nzu_dn, + texture_rectangle_16bit_cf_zc_nzu_dm, texture_rectangle_16bit_cf_zc_nzu_db, texture_rectangle_16bit_cf_zc_nzu_dn, + texture_rectangle_16bit_c1_nzc_zu_dm, texture_rectangle_16bit_c1_nzc_zu_db, texture_rectangle_16bit_c1_nzc_zu_dn, + texture_rectangle_16bit_c2_nzc_zu_dm, texture_rectangle_16bit_c2_nzc_zu_db, texture_rectangle_16bit_c2_nzc_zu_dn, + texture_rectangle_16bit_cc_nzc_zu_dm, texture_rectangle_16bit_cc_nzc_zu_db, texture_rectangle_16bit_cc_nzc_zu_dn, + texture_rectangle_16bit_cf_nzc_zu_dm, texture_rectangle_16bit_cf_nzc_zu_db, texture_rectangle_16bit_cf_nzc_zu_dn, + texture_rectangle_16bit_c1_zc_zu_dm, texture_rectangle_16bit_c1_zc_zu_db, texture_rectangle_16bit_c1_zc_zu_dn, + texture_rectangle_16bit_c2_zc_zu_dm, texture_rectangle_16bit_c2_zc_zu_db, texture_rectangle_16bit_c2_zc_zu_dn, + texture_rectangle_16bit_cc_zc_zu_dm, texture_rectangle_16bit_cc_zc_zu_db, texture_rectangle_16bit_cc_zc_zu_dn, + texture_rectangle_16bit_cf_zc_zu_dm, texture_rectangle_16bit_cf_zc_zu_db, texture_rectangle_16bit_cf_zc_zu_dn, }; diff --git a/src/mame/video/rdptri.c b/src/mame/video/rdptri.c new file mode 100644 index 00000000000..a002c45cda7 --- /dev/null +++ b/src/mame/video/rdptri.c @@ -0,0 +1,2775 @@ +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; + + int sign_dxldy = 0; + int sign_dxmdy = 0; + int samesign = 0; + + int sign_dxhdy = 0; + + 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); + // Inverse slopes in 16.16 format + dxldy = (INT32)(w4); + dxhdy = (INT32)(w6); + dxmdy = (INT32)(w8); + + max_level = ((w1 >> 19) & 7); + + if (yl & 0x2000) yl |= 0xffffc000; + if (ym & 0x2000) ym |= 0xffffc000; + if (yh & 0x2000) yh |= 0xffffc000; + + if (xl & 0x20000000) xl |= 0xc0000000; + if (xm & 0x20000000) xm |= 0xc0000000; + if (xh & 0x20000000) xh |= 0xc0000000; + + span[0].dymax = 0; + + xleft_inc = dxmdy >> 2; + xright_inc = dxhdy >> 2; + + xright = xh; + xleft = xm; + + 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++) + { + 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; + + 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; + + for (k = ycur; k <= ylfar; k++) + { + if (k == ym) + { + xleft = xl; + xleft_inc = dxldy >> 2; + } + + xstart = xleft >> 16; + xend = xright >> 16; + j = k >> 2; + spix = k & 3; + + if (k >= 0 && k < 0x1000) + { + 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) + { + 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; + } + } + + if (spix == max) + { + if (flip) + { + span[j].lx = maxxmx; + span[j].rx = minxhx; + } + else + { + span[j].lx = minxmx; + span[j].rx = maxxhx; + } + } + + length = flip ? (xstart - xend) : (xend - xstart); + + if (spix == ldflag) + { + xfrac = ((xright >> 8) & 0xff); + } + + m = flip ? (xend+1) : (xend-1); + + if (k >= yh && length >= 0 && k <= yl) + { + if (xstart>=0 && xstart <1024) + { + if (!flip) + { + span[j].cvg[xstart] += addleft(xleft); + } + else + { + span[j].cvg[xstart] += addright(xleft); + } + } + if (xend>=0 && xend<1024) + { + if (xstart != xend) + { + if (!flip) + { + span[j].cvg[xend] += addright(xright); + } + else + { + span[j].cvg[xend] += addleft(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; + } + } + } + for (n = 0; n < (length - 1); n++) + { + if (m>=0 && m < 640) + { + span[j].cvg[m] += 2; + } + + m += m_inc; + } + } + } + + xleft += xleft_inc; + xright += xright_inc; + } + + switch (fb_size) // 8bpp needs to be implemented + { + case PIXEL_SIZE_16BIT: + if(flip) + { + render_spans_16_ns_nt_nz_f(yh>>2, yl>>2, &tile[0]); break; + } + else + { + render_spans_16_ns_nt_nz_nf(yh>>2, yl>>2, &tile[0]); break; + } + case PIXEL_SIZE_32BIT: render_spans_32(yh>>2, yl>>2, &tile[0], 0, 0, 0, flip); break; + default: break; // V-Rally2 does this, fb_size=0 + } +} + +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 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); + // Inverse slopes in 16.16 format + dxldy = (INT32)(w4); + dxhdy = (INT32)(w6); + dxmdy = (INT32)(w8); + + max_level = ((w1 >> 19) & 7); + tilenum = (w1 >> 16) & 0x7; + + if (yl & 0x2000) yl |= 0xffffc000; + if (ym & 0x2000) ym |= 0xffffc000; + if (yh & 0x2000) yh |= 0xffffc000; + + if (xl & 0x20000000) xl |= 0xc0000000; + 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]; + + 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; + + xright = xh; + xleft = xm; + + 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++) + { + 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; + + do_offset = !(sign_dxhdy ^ (flip)); + + if (do_offset) + { + dzdeh = dzde >> 9; dzdyh = dzdy >> 9; + + dzdiff = (dzdeh*3 - dzdyh*3) << 7; + } + else + { + dzdiff = 0; + } + + if (do_offset) + { + dzeoff = (dzdeh*3) << 7; + } + else + { + 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); \ +} + +#define addvalues() { \ + z += dzde; \ +} + + 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; + + for (k = ycur; k <= ylfar; k++) + { + if (k == ym) + { + xleft = xl; + xleft_inc = dxldy >> 2; + } + + xstart = xleft >> 16; + xend = xright >> 16; + j = k >> 2; + spix = k & 3; + + if (k >= 0 && k < 0x1000) + { + 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) + { + 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; + } + } + + if (spix == max) + { + if (flip) + { + span[j].lx = maxxmx; + span[j].rx = minxhx; + } + else + { + span[j].lx = minxmx; + span[j].rx = maxxhx; + } + } + + length = flip ? (xstart - xend) : (xend - xstart); + + if (spix == ldflag) + { + xfrac = ((xright >> 8) & 0xff); + adjust_attr(); + } + + m = flip ? (xend+1) : (xend-1); + + if (k >= yh && length >= 0 && k <= yl) + { + if (xstart>=0 && xstart <1024) + { + if (!flip) + { + span[j].cvg[xstart] += addleft(xleft); + } + else + { + span[j].cvg[xstart] += addright(xleft); + } + } + if (xend>=0 && xend<1024) + { + if (xstart != xend) + { + if (!flip) + { + span[j].cvg[xend] += addright(xright); + } + else + { + span[j].cvg[xend] += addleft(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; + } + } + } + for (n = 0; n < (length - 1); n++) + { + if (m>=0 && m < 640) + { + span[j].cvg[m] += 2; + } + + m += m_inc; + } + } + } + + if (spix == 3) + { + addvalues(); + } + xleft += xleft_inc; + xright += xright_inc; + } + + switch (fb_size) // 8bpp needs to be implemented + { + case PIXEL_SIZE_16BIT: + if(flip) + { + render_spans_16_ns_nt_z_f(yh>>2, yl>>2, &tile[0]); break; + } + else + { + render_spans_16_ns_nt_z_nf(yh>>2, yl>>2, &tile[0]); break; + } + case PIXEL_SIZE_32BIT: render_spans_32(yh>>2, yl>>2, &tile[tilenum], 0, 0, 1, flip); break; + default: break; // V-Rally2 does this, fb_size=0 + } +} +#undef addvalues +#undef adjust_attr +#undef addleft +#undef addright +#undef setvalues + +static void triangle_ns_t_nz(UINT32 w1, UINT32 w2) +{ + int j; + int xleft, xright, xleft_inc, xright_inc; + int xstart, xend; + int s = 0, t = 0, w = 0; + int dsdx = 0, dtdx = 0, dwdx = 0; + int dsdy = 0, dtdy = 0, dwdy = 0; + int dsde = 0, dtde = 0, dwde = 0; + int tilenum; + 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; + + int sign_dxldy = 0; + int sign_dxmdy = 0; + int samesign = 0; + + int dsdiff = 0, dtdiff = 0, dwdiff = 0; + int sign_dxhdy = 0; + + int dsdeh = 0, dtdeh = 0, dwdeh = 0, dsdyh = 0, dtdyh = 0, dwdyh = 0; + int do_offset = 0; + + int xfrac = 0; + int dseoff = 0, dteoff = 0, dweoff = 0; + + int dsdxh = 0, dtdxh = 0, dwdxh = 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 texture_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); + // Inverse slopes in 16.16 format + dxldy = (INT32)(w4); + dxhdy = (INT32)(w6); + dxmdy = (INT32)(w8); + + max_level = ((w1 >> 19) & 7); + tilenum = (w1 >> 16) & 0x7; + + if (yl & 0x2000) yl |= 0xffffc000; + if (ym & 0x2000) ym |= 0xffffc000; + if (yh & 0x2000) yh |= 0xffffc000; + + if (xl & 0x20000000) xl |= 0xc0000000; + if (xm & 0x20000000) xm |= 0xc0000000; + if (xh & 0x20000000) xh |= 0xc0000000; + + s = 0; t = 0; w = 0; + + s = (rdp_cmd_data[texture_base+0 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+4 ] >> 16) & 0x0000ffff); + t = ((rdp_cmd_data[texture_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+4 ] & 0x0000ffff); + w = (rdp_cmd_data[texture_base+1 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+5 ] >> 16) & 0x0000ffff); + dsdx = (rdp_cmd_data[texture_base+2 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+6 ] >> 16) & 0x0000ffff); + dtdx = ((rdp_cmd_data[texture_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+6 ] & 0x0000ffff); + dwdx = (rdp_cmd_data[texture_base+3 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+7 ] >> 16) & 0x0000ffff); + dsde = (rdp_cmd_data[texture_base+8 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+12] >> 16) & 0x0000ffff); + dtde = ((rdp_cmd_data[texture_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+12] & 0x0000ffff); + dwde = (rdp_cmd_data[texture_base+9 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+13] >> 16) & 0x0000ffff); + dsdy = (rdp_cmd_data[texture_base+10] & 0xffff0000) | ((rdp_cmd_data[texture_base+14] >> 16) & 0x0000ffff); + dtdy = ((rdp_cmd_data[texture_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+14] & 0x0000ffff); + dwdy = (rdp_cmd_data[texture_base+11] & 0xffff0000) | ((rdp_cmd_data[texture_base+15] >> 16) & 0x0000ffff); + + span[0].ds.w = dsdx; + span[0].dt.w = dtdx; + span[0].dw.w = dwdx; + + xleft_inc = dxmdy >> 2; + xright_inc = dxhdy >> 2; + + xright = xh; + xleft = xm; + + 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++) + { + 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; + + do_offset = !(sign_dxhdy ^ (flip)); + + if (do_offset) + { + dsdeh = dsde >> 9; dsdyh = dsdy >> 9; + dtdeh = dtde >> 9; dtdyh = dtdy >> 9; + dwdeh = dwde >> 9; dwdyh = dwdy >> 9; + + dsdiff = (dsdeh*3 - dsdyh*3) << 7; + dtdiff = (dtdeh*3 - dtdyh*3) << 7; + dwdiff = (dwdeh*3 - dwdyh*3) << 7; + } + else + { + dsdiff = dtdiff = dwdiff = 0; + } + + if (do_offset) + { + dseoff = (dsdeh*3) << 7; + dteoff = (dtdeh*3) << 7; + dweoff = (dwdeh*3) << 7; + } + else + { + 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; + +#define adjust_attr() \ +{ \ + span[j].s.w = (s + dsdiff - (xfrac * dsdxh)) & ~0x1f; \ + span[j].t.w = (t + dtdiff - (xfrac * dtdxh)) & ~0x1f; \ + span[j].w.w = (w + dwdiff - (xfrac * dwdxh)) & ~0x1f; \ +} + +#define addvalues() { \ + s += dsde; \ + t += dtde; \ + w += dwde; \ +} + + 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; + + for (k = ycur; k <= ylfar; k++) + { + if (k == ym) + { + xleft = xl; + xleft_inc = dxldy >> 2; + } + + xstart = xleft >> 16; + xend = xright >> 16; + j = k >> 2; + spix = k & 3; + + if (k >= 0 && k < 0x1000) + { + 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) + { + 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; + } + } + + if (spix == max) + { + if (flip) + { + span[j].lx = maxxmx; + span[j].rx = minxhx; + } + else + { + span[j].lx = minxmx; + span[j].rx = maxxhx; + } + } + + length = flip ? (xstart - xend) : (xend - xstart); + + if (spix == ldflag) + { + xfrac = ((xright >> 8) & 0xff); + adjust_attr(); + } + + m = flip ? (xend+1) : (xend-1); + + if (k >= yh && length >= 0 && k <= yl) + { + if (xstart>=0 && xstart <1024) + { + if (!flip) + { + span[j].cvg[xstart] += addleft(xleft); + } + else + { + span[j].cvg[xstart] += addright(xleft); + } + } + if (xend>=0 && xend<1024) + { + if (xstart != xend) + { + if (!flip) + { + span[j].cvg[xend] += addright(xright); + } + else + { + span[j].cvg[xend] += addleft(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; + } + } + } + for (n = 0; n < (length - 1); n++) + { + if (m>=0 && m < 640) + { + span[j].cvg[m] += 2; + } + + m += m_inc; + } + } + } + + if (spix == 3) + { + addvalues(); + } + xleft += xleft_inc; + xright += xright_inc; + } + + switch (fb_size) // 8bpp needs to be implemented + { + case PIXEL_SIZE_16BIT: + if(flip) + { + render_spans_16_ns_t_nz_f(yh>>2, yl>>2, &tile[0]); break; + } + else + { + render_spans_16_ns_t_nz_nf(yh>>2, yl>>2, &tile[0]); break; + } + case PIXEL_SIZE_32BIT: render_spans_32(yh>>2, yl>>2, &tile[tilenum], 0, 1, 0, flip); break; + default: break; // V-Rally2 does this, fb_size=0 + } +} +#undef addvalues +#undef adjust_attr +#undef addleft +#undef addright +#undef setvalues + +static void triangle_ns_t_z(UINT32 w1, UINT32 w2) +{ + int j; + int xleft, xright, xleft_inc, xright_inc; + int xstart, xend; + int z = 0, s = 0, t = 0, w = 0; + int dzdx = 0, dsdx = 0, dtdx = 0, dwdx = 0; + int dzdy = 0, dsdy = 0, dtdy = 0, dwdy = 0; + int dzde = 0, dsde = 0, dtde = 0, dwde = 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; + int dsdylod, dtdylod; + 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 dsdiff = 0, dtdiff = 0, dwdiff = 0, dzdiff = 0; + int sign_dxhdy = 0; + + int dsdeh = 0, dtdeh = 0, dwdeh = 0, dzdeh = 0, dsdyh = 0, dtdyh = 0, dwdyh = 0, dzdyh = 0; + int do_offset = 0; + + int xfrac = 0; + int dseoff = 0, dteoff = 0, dweoff = 0, dzeoff = 0; + + 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; + + int spix = 0; // Current subpixel + int ycur; + int ylfar; + int ldflag; + int yhpix; + int ympix; + int ylpix; + + int texture_base = rdp_cmd_cur + 8; + int zbuffer_base = rdp_cmd_cur + 8; + + zbuffer_base += 16; + + 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); + // Inverse slopes in 16.16 format + dxldy = (INT32)(w4); + dxhdy = (INT32)(w6); + dxmdy = (INT32)(w8); + + max_level = ((w1 >> 19) & 7); + tilenum = (w1 >> 16) & 0x7; + + if (yl & 0x2000) yl |= 0xffffc000; + if (ym & 0x2000) ym |= 0xffffc000; + if (yh & 0x2000) yh |= 0xffffc000; + + if (xl & 0x20000000) xl |= 0xc0000000; + if (xm & 0x20000000) xm |= 0xc0000000; + if (xh & 0x20000000) xh |= 0xc0000000; + + z = 0; + s = 0; t = 0; w = 0; + + s = (rdp_cmd_data[texture_base+0 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+4 ] >> 16) & 0x0000ffff); + t = ((rdp_cmd_data[texture_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+4 ] & 0x0000ffff); + w = (rdp_cmd_data[texture_base+1 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+5 ] >> 16) & 0x0000ffff); + dsdx = (rdp_cmd_data[texture_base+2 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+6 ] >> 16) & 0x0000ffff); + dtdx = ((rdp_cmd_data[texture_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+6 ] & 0x0000ffff); + dwdx = (rdp_cmd_data[texture_base+3 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+7 ] >> 16) & 0x0000ffff); + dsde = (rdp_cmd_data[texture_base+8 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+12] >> 16) & 0x0000ffff); + dtde = ((rdp_cmd_data[texture_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+12] & 0x0000ffff); + dwde = (rdp_cmd_data[texture_base+9 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+13] >> 16) & 0x0000ffff); + dsdy = (rdp_cmd_data[texture_base+10] & 0xffff0000) | ((rdp_cmd_data[texture_base+14] >> 16) & 0x0000ffff); + dtdy = ((rdp_cmd_data[texture_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+14] & 0x0000ffff); + dwdy = (rdp_cmd_data[texture_base+11] & 0xffff0000) | ((rdp_cmd_data[texture_base+15] >> 16) & 0x0000ffff); + 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]; + + span[0].ds.w = dsdx; + span[0].dt.w = dtdx; + span[0].dw.w = dwdx; + 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); + dsdylod = dsdy >> 16; + dtdylod = dtdy >> 16; + if (dsdylod & 0x20000) + { + dsdylod = ~dsdylod & 0x1ffff; + } + if (dtdylod & 0x20000) + { + dtdylod = ~dtdylod & 0x1ffff; + } + span[0].dymax = (dsdylod > dtdylod)? dsdylod : dtdylod; + + xleft_inc = dxmdy >> 2; + xright_inc = dxhdy >> 2; + + xright = xh; + xleft = xm; + + 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++) + { + 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; + + do_offset = !(sign_dxhdy ^ (flip)); + + if (do_offset) + { + dsdeh = dsde >> 9; dsdyh = dsdy >> 9; + dtdeh = dtde >> 9; dtdyh = dtdy >> 9; + dwdeh = dwde >> 9; dwdyh = dwdy >> 9; + dzdeh = dzde >> 9; dzdyh = dzdy >> 9; + + dsdiff = (dsdeh*3 - dsdyh*3) << 7; + dtdiff = (dtdeh*3 - dtdyh*3) << 7; + dwdiff = (dwdeh*3 - dwdyh*3) << 7; + dzdiff = (dzdeh*3 - dzdyh*3) << 7; + } + else + { + dsdiff = dtdiff = dwdiff = dzdiff = 0; + } + + if (do_offset) + { + dseoff = (dsdeh*3) << 7; + dteoff = (dtdeh*3) << 7; + dweoff = (dwdeh*3) << 7; + dzeoff = (dzdeh*3) << 7; + } + else + { + 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; + dzdxh = dzdx >> 8; + +#define adjust_attr() \ +{ \ + span[j].s.w = (s + dsdiff - (xfrac * dsdxh)) & ~0x1f; \ + span[j].t.w = (t + dtdiff - (xfrac * dtdxh)) & ~0x1f; \ + span[j].w.w = (w + dwdiff - (xfrac * dwdxh)) & ~0x1f; \ + span[j].z.w = z + dzdiff - (xfrac * dzdxh); \ +} + +#define addvalues() { \ + s += dsde; \ + t += dtde; \ + w += dwde; \ + z += dzde; \ +} + + 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; + + for (k = ycur; k <= ylfar; k++) + { + if (k == ym) + { + xleft = xl; + xleft_inc = dxldy >> 2; + } + + xstart = xleft >> 16; + xend = xright >> 16; + j = k >> 2; + spix = k & 3; + + if (k >= 0 && k < 0x1000) + { + 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) + { + 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; + } + } + + if (spix == max) + { + if (flip) + { + span[j].lx = maxxmx; + span[j].rx = minxhx; + } + else + { + span[j].lx = minxmx; + span[j].rx = maxxhx; + } + } + + length = flip ? (xstart - xend) : (xend - xstart); + + if (spix == ldflag) + { + xfrac = ((xright >> 8) & 0xff); + adjust_attr(); + } + + m = flip ? (xend+1) : (xend-1); + + if (k >= yh && length >= 0 && k <= yl) + { + if (xstart>=0 && xstart <1024) + { + if (!flip) + { + span[j].cvg[xstart] += addleft(xleft); + } + else + { + span[j].cvg[xstart] += addright(xleft); + } + } + if (xend>=0 && xend<1024) + { + if (xstart != xend) + { + if (!flip) + { + span[j].cvg[xend] += addright(xright); + } + else + { + span[j].cvg[xend] += addleft(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; + } + } + } + for (n = 0; n < (length - 1); n++) + { + if (m>=0 && m < 640) + { + span[j].cvg[m] += 2; + } + + m += m_inc; + } + } + } + + if (spix == 3) + { + addvalues(); + } + xleft += xleft_inc; + xright += xright_inc; + } + + switch (fb_size) // 8bpp needs to be implemented + { + case PIXEL_SIZE_16BIT: + if(flip) + { + render_spans_16_ns_t_z_f(yh>>2, yl>>2, &tile[0]); break; + } + else + { + render_spans_16_ns_t_z_nf(yh>>2, yl>>2, &tile[0]); break; + } + case PIXEL_SIZE_32BIT: render_spans_32(yh>>2, yl>>2, &tile[tilenum], 0, 1, 1, flip); break; + default: break; // V-Rally2 does this, fb_size=0 + } +} +#undef addvalues +#undef adjust_attr +#undef addleft +#undef addright +#undef setvalues + +static void triangle_s_nt_nz(UINT32 w1, UINT32 w2) +{ + int j; + int xleft, xright, xleft_inc, xright_inc; + int xstart, xend; + int r = 0, g = 0, b = 0, a = 0; + int dr, dg, db, da; + int drdx = 0, dgdx = 0, dbdx = 0, dadx = 0; + int drdy = 0, dgdy = 0, dbdy = 0, dady = 0; + int drde = 0, dgde = 0, dbde = 0, dade = 0; + int tilenum; + 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; + + int sign_dxldy = 0; + int sign_dxmdy = 0; + int samesign = 0; + + int drdiff = 0, dgdiff = 0, dbdiff = 0, dadiff = 0; + int sign_dxhdy = 0; + + int drdeh = 0, dgdeh = 0, dbdeh = 0, dadeh = 0, drdyh = 0, dgdyh = 0, dbdyh = 0, dadyh = 0; + int do_offset = 0; + + int xfrac = 0; + int dreoff = 0, dgeoff = 0, dbeoff = 0, daeoff = 0; + + 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; + + int spix = 0; // Current subpixel + int ycur; + int ylfar; + int ldflag; + int yhpix; + int ympix; + int ylpix; + + int shade_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); + // Inverse slopes in 16.16 format + dxldy = (INT32)(w4); + dxhdy = (INT32)(w6); + dxmdy = (INT32)(w8); + + max_level = ((w1 >> 19) & 7); + tilenum = (w1 >> 16) & 0x7; + + if (yl & 0x2000) yl |= 0xffffc000; + if (ym & 0x2000) ym |= 0xffffc000; + if (yh & 0x2000) yh |= 0xffffc000; + + if (xl & 0x20000000) xl |= 0xc0000000; + if (xm & 0x20000000) xm |= 0xc0000000; + if (xh & 0x20000000) xh |= 0xc0000000; + + dr = 0; dg = 0; db = 0; da = 0; + + r = (rdp_cmd_data[shade_base+0 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+4 ] >> 16) & 0x0000ffff); + g = ((rdp_cmd_data[shade_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+4 ] & 0x0000ffff); + b = (rdp_cmd_data[shade_base+1 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+5 ] >> 16) & 0x0000ffff); + a = ((rdp_cmd_data[shade_base+1 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+5 ] & 0x0000ffff); + drdx = (rdp_cmd_data[shade_base+2 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+6 ] >> 16) & 0x0000ffff); + dgdx = ((rdp_cmd_data[shade_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+6 ] & 0x0000ffff); + dbdx = (rdp_cmd_data[shade_base+3 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+7 ] >> 16) & 0x0000ffff); + dadx = ((rdp_cmd_data[shade_base+3 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+7 ] & 0x0000ffff); + drde = (rdp_cmd_data[shade_base+8 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+12] >> 16) & 0x0000ffff); + dgde = ((rdp_cmd_data[shade_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+12] & 0x0000ffff); + dbde = (rdp_cmd_data[shade_base+9 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+13] >> 16) & 0x0000ffff); + dade = ((rdp_cmd_data[shade_base+9 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+13] & 0x0000ffff); + drdy = (rdp_cmd_data[shade_base+10] & 0xffff0000) | ((rdp_cmd_data[shade_base+14] >> 16) & 0x0000ffff); + dgdy = ((rdp_cmd_data[shade_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+14] & 0x0000ffff); + dbdy = (rdp_cmd_data[shade_base+11] & 0xffff0000) | ((rdp_cmd_data[shade_base+15] >> 16) & 0x0000ffff); + dady = ((rdp_cmd_data[shade_base+11] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+15] & 0x0000ffff); + + span[0].dr.w = drdx & ~0x1f; + span[0].dg.w = dgdx & ~0x1f; + span[0].db.w = dbdx & ~0x1f; + span[0].da.w = dadx & ~0x1f; + + xleft_inc = dxmdy >> 2; + xright_inc = dxhdy >> 2; + + xright = xh; + xleft = xm; + + 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++) + { + 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; + + do_offset = !(sign_dxhdy ^ (flip)); + + if (do_offset) + { + drdeh = drde >> 9; drdyh = drdy >> 9; + dgdeh = dgde >> 9; dgdyh = dgdy >> 9; + dbdeh = dbde >> 9; dbdyh = dbdy >> 9; + dadeh = dade >> 9; dadyh = dady >> 9; + + drdiff = (drdeh*3 - drdyh*3) << 7; + dgdiff = (dgdeh*3 - dgdyh*3) << 7; + dbdiff = (dbdeh*3 - dbdyh*3) << 7; + dadiff = (dadeh*3 - dadyh*3) << 7; + } + else + { + drdiff = dgdiff = dbdiff = dadiff; + } + + if (do_offset) + { + dreoff = (drdeh*3) << 7; + dgeoff = (dgdeh*3) << 7; + dbeoff = (dbdeh*3) << 7; + daeoff = (dadeh*3) << 7; + } + else + { + 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; + dadxh = dadx >> 8; + +#define adjust_attr() \ +{ \ + span[j].r.w = r + drdiff - (xfrac * drdxh); \ + span[j].g.w = g + dgdiff - (xfrac * dgdxh); \ + span[j].b.w = b + dbdiff - (xfrac * dbdxh); \ + span[j].a.w = a + dadiff - (xfrac * dadxh); \ +} + +#define addvalues() { \ + r += drde; \ + g += dgde; \ + b += dbde; \ + a += dade; \ +} + + 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; + + for (k = ycur; k <= ylfar; k++) + { + if (k == ym) + { + xleft = xl; + xleft_inc = dxldy >> 2; + } + + xstart = xleft >> 16; + xend = xright >> 16; + j = k >> 2; + spix = k & 3; + + if (k >= 0 && k < 0x1000) + { + 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) + { + 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; + } + } + + if (spix == max) + { + if (flip) + { + span[j].lx = maxxmx; + span[j].rx = minxhx; + } + else + { + span[j].lx = minxmx; + span[j].rx = maxxhx; + } + } + + length = flip ? (xstart - xend) : (xend - xstart); + + if (spix == ldflag) + { + xfrac = ((xright >> 8) & 0xff); + adjust_attr(); + } + + m = flip ? (xend+1) : (xend-1); + + if (k >= yh && length >= 0 && k <= yl) + { + if (xstart>=0 && xstart <1024) + { + if (!flip) + { + span[j].cvg[xstart] += addleft(xleft); + } + else + { + span[j].cvg[xstart] += addright(xleft); + } + } + if (xend>=0 && xend<1024) + { + if (xstart != xend) + { + if (!flip) + { + span[j].cvg[xend] += addright(xright); + } + else + { + span[j].cvg[xend] += addleft(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; + } + } + } + for (n = 0; n < (length - 1); n++) + { + if (m>=0 && m < 640) + { + span[j].cvg[m] += 2; + } + + m += m_inc; + } + } + } + + if (spix == 3) + { + addvalues(); + } + xleft += xleft_inc; + xright += xright_inc; + } + + switch (fb_size) // 8bpp needs to be implemented + { + case PIXEL_SIZE_16BIT: + if(flip) + { + render_spans_16_s_nt_nz_f(yh>>2, yl>>2, &tile[0]); break; + } + else + { + render_spans_16_s_nt_nz_nf(yh>>2, yl>>2, &tile[0]); break; + } + case PIXEL_SIZE_32BIT: render_spans_32(yh>>2, yl>>2, &tile[tilenum], 1, 0, 0, flip); break; + default: break; // V-Rally2 does this, fb_size=0 + } +} +#undef addvalues +#undef adjust_attr +#undef addleft +#undef addright +#undef setvalues + +static void triangle_s_nt_z(UINT32 w1, UINT32 w2) +{ + int j; + int xleft, xright, xleft_inc, xright_inc; + int xstart, xend; + int r = 0, g = 0, b = 0, a = 0, z = 0; + int dr, dg, db, da; + int drdx = 0, dgdx = 0, dbdx = 0, dadx = 0, dzdx = 0; + int drdy = 0, dgdy = 0, dbdy = 0, dady = 0, dzdy = 0; + int drde = 0, dgde = 0, dbde = 0, dade = 0, 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 drdiff = 0, dgdiff = 0, dbdiff = 0, dadiff = 0, dzdiff = 0; + int sign_dxhdy = 0; + + int drdeh = 0, dgdeh = 0, dbdeh = 0, dadeh = 0, dzdeh = 0, drdyh = 0, dgdyh = 0, dbdyh = 0, dadyh = 0, dzdyh = 0; + int do_offset = 0; + + int xfrac = 0; + int dreoff = 0, dgeoff = 0, dbeoff = 0, daeoff = 0, dzeoff = 0; + + 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; + + int spix = 0; // Current subpixel + int ycur; + int ylfar; + int ldflag; + int yhpix; + int ympix; + int ylpix; + + int shade_base = rdp_cmd_cur + 8; + int zbuffer_base = rdp_cmd_cur + 8; + + zbuffer_base += 16; + + 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); + // Inverse slopes in 16.16 format + dxldy = (INT32)(w4); + dxhdy = (INT32)(w6); + dxmdy = (INT32)(w8); + + max_level = ((w1 >> 19) & 7); + tilenum = (w1 >> 16) & 0x7; + + if (yl & 0x2000) yl |= 0xffffc000; + if (ym & 0x2000) ym |= 0xffffc000; + if (yh & 0x2000) yh |= 0xffffc000; + + if (xl & 0x20000000) xl |= 0xc0000000; + if (xm & 0x20000000) xm |= 0xc0000000; + if (xh & 0x20000000) xh |= 0xc0000000; + + z = 0; + dr = 0; dg = 0; db = 0; da = 0; + + r = (rdp_cmd_data[shade_base+0 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+4 ] >> 16) & 0x0000ffff); + g = ((rdp_cmd_data[shade_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+4 ] & 0x0000ffff); + b = (rdp_cmd_data[shade_base+1 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+5 ] >> 16) & 0x0000ffff); + a = ((rdp_cmd_data[shade_base+1 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+5 ] & 0x0000ffff); + drdx = (rdp_cmd_data[shade_base+2 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+6 ] >> 16) & 0x0000ffff); + dgdx = ((rdp_cmd_data[shade_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+6 ] & 0x0000ffff); + dbdx = (rdp_cmd_data[shade_base+3 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+7 ] >> 16) & 0x0000ffff); + dadx = ((rdp_cmd_data[shade_base+3 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+7 ] & 0x0000ffff); + drde = (rdp_cmd_data[shade_base+8 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+12] >> 16) & 0x0000ffff); + dgde = ((rdp_cmd_data[shade_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+12] & 0x0000ffff); + dbde = (rdp_cmd_data[shade_base+9 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+13] >> 16) & 0x0000ffff); + dade = ((rdp_cmd_data[shade_base+9 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+13] & 0x0000ffff); + drdy = (rdp_cmd_data[shade_base+10] & 0xffff0000) | ((rdp_cmd_data[shade_base+14] >> 16) & 0x0000ffff); + dgdy = ((rdp_cmd_data[shade_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+14] & 0x0000ffff); + dbdy = (rdp_cmd_data[shade_base+11] & 0xffff0000) | ((rdp_cmd_data[shade_base+15] >> 16) & 0x0000ffff); + dady = ((rdp_cmd_data[shade_base+11] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+15] & 0x0000ffff); + 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]; + + span[0].dr.w = drdx & ~0x1f; + span[0].dg.w = dgdx & ~0x1f; + span[0].db.w = dbdx & ~0x1f; + span[0].da.w = dadx & ~0x1f; + 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; + + xright = xh; + xleft = xm; + + 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++) + { + 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; + + do_offset = !(sign_dxhdy ^ (flip)); + + if (do_offset) + { + drdeh = drde >> 9; drdyh = drdy >> 9; + dgdeh = dgde >> 9; dgdyh = dgdy >> 9; + dbdeh = dbde >> 9; dbdyh = dbdy >> 9; + dadeh = dade >> 9; dadyh = dady >> 9; + dzdeh = dzde >> 9; dzdyh = dzdy >> 9; + + drdiff = (drdeh*3 - drdyh*3) << 7; + dgdiff = (dgdeh*3 - dgdyh*3) << 7; + dbdiff = (dbdeh*3 - dbdyh*3) << 7; + dadiff = (dadeh*3 - dadyh*3) << 7; + dzdiff = (dzdeh*3 - dzdyh*3) << 7; + } + else + { + drdiff = dgdiff = dbdiff = dadiff = dzdiff = 0; + } + + if (do_offset) + { + dreoff = (drdeh*3) << 7; + dgeoff = (dgdeh*3) << 7; + dbeoff = (dbdeh*3) << 7; + daeoff = (dadeh*3) << 7; + dzeoff = (dzdeh*3) << 7; + } + else + { + 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; + dadxh = dadx >> 8; + dzdxh = dzdx >> 8; + +#define adjust_attr() \ +{ \ + span[j].r.w = r + drdiff - (xfrac * drdxh); \ + span[j].g.w = g + dgdiff - (xfrac * dgdxh); \ + span[j].b.w = b + dbdiff - (xfrac * dbdxh); \ + span[j].a.w = a + dadiff - (xfrac * dadxh); \ + span[j].z.w = z + dzdiff - (xfrac * dzdxh); \ +} + +#define addvalues() { \ + r += drde; \ + g += dgde; \ + b += dbde; \ + a += dade; \ + z += dzde; \ +} + + 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; + + for (k = ycur; k <= ylfar; k++) + { + if (k == ym) + { + xleft = xl; + xleft_inc = dxldy >> 2; + } + + xstart = xleft >> 16; + xend = xright >> 16; + j = k >> 2; + spix = k & 3; + + if (k >= 0 && k < 0x1000) + { + 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) + { + 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; + } + } + + if (spix == max) + { + if (flip) + { + span[j].lx = maxxmx; + span[j].rx = minxhx; + } + else + { + span[j].lx = minxmx; + span[j].rx = maxxhx; + } + } + + length = flip ? (xstart - xend) : (xend - xstart); + + if (spix == ldflag) + { + xfrac = ((xright >> 8) & 0xff); + adjust_attr(); + } + + m = flip ? (xend+1) : (xend-1); + + if (k >= yh && length >= 0 && k <= yl) + { + if (xstart>=0 && xstart <1024) + { + if (!flip) + { + span[j].cvg[xstart] += addleft(xleft); + } + else + { + span[j].cvg[xstart] += addright(xleft); + } + } + if (xend>=0 && xend<1024) + { + if (xstart != xend) + { + if (!flip) + { + span[j].cvg[xend] += addright(xright); + } + else + { + span[j].cvg[xend] += addleft(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; + } + } + } + for (n = 0; n < (length - 1); n++) + { + if (m>=0 && m < 640) + { + span[j].cvg[m] += 2; + } + + m += m_inc; + } + } + } + + if (spix == 3) + { + addvalues(); + } + xleft += xleft_inc; + xright += xright_inc; + } + + switch (fb_size) // 8bpp needs to be implemented + { + case PIXEL_SIZE_16BIT: + if(flip) + { + render_spans_16_s_nt_z_f(yh>>2, yl>>2, &tile[0]); break; + } + else + { + render_spans_16_s_nt_z_nf(yh>>2, yl>>2, &tile[0]); break; + } + case PIXEL_SIZE_32BIT: render_spans_32(yh>>2, yl>>2, &tile[tilenum], 1, 0, 1, flip); break; + default: break; // V-Rally2 does this, fb_size=0 + } +} +#undef addvalues +#undef adjust_attr +#undef addleft +#undef addright +#undef setvalues + +static void triangle_s_t_nz(UINT32 w1, UINT32 w2) +{ + int j; + int xleft, xright, xleft_inc, xright_inc; + int xstart, xend; + int r = 0, g = 0, b = 0, a = 0, s = 0, t = 0, w = 0; + int dr, dg, db, da; + int drdx = 0, dgdx = 0, dbdx = 0, dadx = 0, dsdx = 0, dtdx = 0, dwdx = 0; + int drdy = 0, dgdy = 0, dbdy = 0, dady = 0, dsdy = 0, dtdy = 0, dwdy = 0; + int drde = 0, dgde = 0, dbde = 0, dade = 0, dsde = 0, dtde = 0, dwde = 0; + int tilenum; + int flip = (w1 & 0x800000) ? 1 : 0; + + INT32 yl, ym, yh; + INT32 xl, xm, xh; + INT32 dxldy, dxhdy, dxmdy; + int dsdylod, dtdylod; + 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 dsdiff = 0, dtdiff = 0, dwdiff = 0, drdiff = 0, dgdiff = 0, dbdiff = 0, dadiff = 0; + int sign_dxhdy = 0; + + int dsdeh = 0, dtdeh = 0, dwdeh = 0, drdeh = 0, dgdeh = 0, dbdeh = 0, dadeh = 0, dsdyh = 0, dtdyh = 0, dwdyh = 0, drdyh = 0, dgdyh = 0, dbdyh = 0, dadyh = 0; + int do_offset = 0; + + int xfrac = 0; + int dseoff = 0, dteoff = 0, dweoff = 0, dreoff = 0, dgeoff = 0, dbeoff = 0, daeoff = 0; + + 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; + + int spix = 0; // Current subpixel + int ycur; + int ylfar; + int ldflag; + int yhpix; + int ympix; + int ylpix; + + int shade_base = rdp_cmd_cur + 8; + int texture_base = rdp_cmd_cur + 8; + + texture_base += 16; + + 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); + // Inverse slopes in 16.16 format + dxldy = (INT32)(w4); + dxhdy = (INT32)(w6); + dxmdy = (INT32)(w8); + + max_level = ((w1 >> 19) & 7); + tilenum = (w1 >> 16) & 0x7; + + if (yl & 0x2000) yl |= 0xffffc000; + if (ym & 0x2000) ym |= 0xffffc000; + if (yh & 0x2000) yh |= 0xffffc000; + + if (xl & 0x20000000) xl |= 0xc0000000; + if (xm & 0x20000000) xm |= 0xc0000000; + if (xh & 0x20000000) xh |= 0xc0000000; + + s = 0; t = 0; w = 0; + dr = 0; dg = 0; db = 0; da = 0; + + r = (rdp_cmd_data[shade_base+0 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+4 ] >> 16) & 0x0000ffff); + g = ((rdp_cmd_data[shade_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+4 ] & 0x0000ffff); + b = (rdp_cmd_data[shade_base+1 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+5 ] >> 16) & 0x0000ffff); + a = ((rdp_cmd_data[shade_base+1 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+5 ] & 0x0000ffff); + drdx = (rdp_cmd_data[shade_base+2 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+6 ] >> 16) & 0x0000ffff); + dgdx = ((rdp_cmd_data[shade_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+6 ] & 0x0000ffff); + dbdx = (rdp_cmd_data[shade_base+3 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+7 ] >> 16) & 0x0000ffff); + dadx = ((rdp_cmd_data[shade_base+3 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+7 ] & 0x0000ffff); + drde = (rdp_cmd_data[shade_base+8 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+12] >> 16) & 0x0000ffff); + dgde = ((rdp_cmd_data[shade_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+12] & 0x0000ffff); + dbde = (rdp_cmd_data[shade_base+9 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+13] >> 16) & 0x0000ffff); + dade = ((rdp_cmd_data[shade_base+9 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+13] & 0x0000ffff); + drdy = (rdp_cmd_data[shade_base+10] & 0xffff0000) | ((rdp_cmd_data[shade_base+14] >> 16) & 0x0000ffff); + dgdy = ((rdp_cmd_data[shade_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+14] & 0x0000ffff); + dbdy = (rdp_cmd_data[shade_base+11] & 0xffff0000) | ((rdp_cmd_data[shade_base+15] >> 16) & 0x0000ffff); + dady = ((rdp_cmd_data[shade_base+11] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+15] & 0x0000ffff); + s = (rdp_cmd_data[texture_base+0 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+4 ] >> 16) & 0x0000ffff); + t = ((rdp_cmd_data[texture_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+4 ] & 0x0000ffff); + w = (rdp_cmd_data[texture_base+1 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+5 ] >> 16) & 0x0000ffff); + dsdx = (rdp_cmd_data[texture_base+2 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+6 ] >> 16) & 0x0000ffff); + dtdx = ((rdp_cmd_data[texture_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+6 ] & 0x0000ffff); + dwdx = (rdp_cmd_data[texture_base+3 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+7 ] >> 16) & 0x0000ffff); + dsde = (rdp_cmd_data[texture_base+8 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+12] >> 16) & 0x0000ffff); + dtde = ((rdp_cmd_data[texture_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+12] & 0x0000ffff); + dwde = (rdp_cmd_data[texture_base+9 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+13] >> 16) & 0x0000ffff); + dsdy = (rdp_cmd_data[texture_base+10] & 0xffff0000) | ((rdp_cmd_data[texture_base+14] >> 16) & 0x0000ffff); + dtdy = ((rdp_cmd_data[texture_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+14] & 0x0000ffff); + dwdy = (rdp_cmd_data[texture_base+11] & 0xffff0000) | ((rdp_cmd_data[texture_base+15] >> 16) & 0x0000ffff); + + span[0].ds.w = dsdx; + span[0].dt.w = dtdx; + span[0].dw.w = dwdx; + span[0].dr.w = drdx & ~0x1f; + span[0].dg.w = dgdx & ~0x1f; + span[0].db.w = dbdx & ~0x1f; + span[0].da.w = dadx & ~0x1f; + dsdylod = dsdy >> 16; + dtdylod = dtdy >> 16; + if (dsdylod & 0x20000) + { + dsdylod = ~dsdylod & 0x1ffff; + } + if (dtdylod & 0x20000) + { + dtdylod = ~dtdylod & 0x1ffff; + } + span[0].dymax = (dsdylod > dtdylod)? dsdylod : dtdylod; + + xleft_inc = dxmdy >> 2; + xright_inc = dxhdy >> 2; + + xright = xh; + xleft = xm; + + 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++) + { + 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; + + do_offset = !(sign_dxhdy ^ (flip)); + + if (do_offset) + { + dsdeh = dsde >> 9; dsdyh = dsdy >> 9; + dtdeh = dtde >> 9; dtdyh = dtdy >> 9; + dwdeh = dwde >> 9; dwdyh = dwdy >> 9; + drdeh = drde >> 9; drdyh = drdy >> 9; + dgdeh = dgde >> 9; dgdyh = dgdy >> 9; + dbdeh = dbde >> 9; dbdyh = dbdy >> 9; + dadeh = dade >> 9; dadyh = dady >> 9; + + dsdiff = (dsdeh*3 - dsdyh*3) << 7; + dtdiff = (dtdeh*3 - dtdyh*3) << 7; + dwdiff = (dwdeh*3 - dwdyh*3) << 7; + drdiff = (drdeh*3 - drdyh*3) << 7; + dgdiff = (dgdeh*3 - dgdyh*3) << 7; + dbdiff = (dbdeh*3 - dbdyh*3) << 7; + dadiff = (dadeh*3 - dadyh*3) << 7; + } + else + { + dsdiff = dtdiff = dwdiff = drdiff = dgdiff = dbdiff = dadiff = 0; + } + + if (do_offset) + { + dseoff = (dsdeh*3) << 7; + dteoff = (dtdeh*3) << 7; + dweoff = (dwdeh*3) << 7; + dreoff = (drdeh*3) << 7; + dgeoff = (dgdeh*3) << 7; + dbeoff = (dbdeh*3) << 7; + daeoff = (dadeh*3) << 7; + } + else + { + 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; + drdxh = drdx >> 8; + dgdxh = dgdx >> 8; + dbdxh = dbdx >> 8; + dadxh = dadx >> 8; + +#define adjust_attr() \ +{ \ + span[j].s.w = (s + dsdiff - (xfrac * dsdxh)) & ~0x1f; \ + span[j].t.w = (t + dtdiff - (xfrac * dtdxh)) & ~0x1f; \ + span[j].w.w = (w + dwdiff - (xfrac * dwdxh)) & ~0x1f; \ + span[j].r.w = r + drdiff - (xfrac * drdxh); \ + span[j].g.w = g + dgdiff - (xfrac * dgdxh); \ + span[j].b.w = b + dbdiff - (xfrac * dbdxh); \ + span[j].a.w = a + dadiff - (xfrac * dadxh); \ +} + +#define addvalues() { \ + s += dsde; \ + t += dtde; \ + w += dwde; \ + r += drde; \ + g += dgde; \ + b += dbde; \ + a += dade; \ +} + + 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; + + for (k = ycur; k <= ylfar; k++) + { + if (k == ym) + { + xleft = xl; + xleft_inc = dxldy >> 2; + } + + xstart = xleft >> 16; + xend = xright >> 16; + j = k >> 2; + spix = k & 3; + + if (k >= 0 && k < 0x1000) + { + 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) + { + 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; + } + } + + if (spix == max) + { + if (flip) + { + span[j].lx = maxxmx; + span[j].rx = minxhx; + } + else + { + span[j].lx = minxmx; + span[j].rx = maxxhx; + } + } + + length = flip ? (xstart - xend) : (xend - xstart); + + if (spix == ldflag) + { + xfrac = ((xright >> 8) & 0xff); + adjust_attr(); + } + + m = flip ? (xend+1) : (xend-1); + + if (k >= yh && length >= 0 && k <= yl) + { + if (xstart>=0 && xstart <1024) + { + if (!flip) + { + span[j].cvg[xstart] += addleft(xleft); + } + else + { + span[j].cvg[xstart] += addright(xleft); + } + } + if (xend>=0 && xend<1024) + { + if (xstart != xend) + { + if (!flip) + { + span[j].cvg[xend] += addright(xright); + } + else + { + span[j].cvg[xend] += addleft(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; + } + } + } + for (n = 0; n < (length - 1); n++) + { + if (m>=0 && m < 640) + { + span[j].cvg[m] += 2; + } + + m += m_inc; + } + } + } + + if (spix == 3) + { + addvalues(); + } + xleft += xleft_inc; + xright += xright_inc; + } + + switch (fb_size) // 8bpp needs to be implemented + { + case PIXEL_SIZE_16BIT: + if(flip) + { + render_spans_16_s_t_nz_f(yh>>2, yl>>2, &tile[0]); break; + } + else + { + render_spans_16_s_t_nz_nf(yh>>2, yl>>2, &tile[0]); break; + } + case PIXEL_SIZE_32BIT: render_spans_32(yh>>2, yl>>2, &tile[tilenum], 1, 1, 0, flip); break; + default: break; // V-Rally2 does this, fb_size=0 + } +} +#undef addvalues +#undef adjust_attr +#undef addleft +#undef addright +#undef setvalues + +static void triangle_s_t_z(UINT32 w1, UINT32 w2) +{ + int j; + int xleft, xright, xleft_inc, xright_inc; + int xstart, xend; + int r = 0, g = 0, b = 0, a = 0, z = 0, s = 0, t = 0, w = 0; + int dr, dg, db, da; + int drdx = 0, dgdx = 0, dbdx = 0, dadx = 0, dzdx = 0, dsdx = 0, dtdx = 0, dwdx = 0; + int drdy = 0, dgdy = 0, dbdy = 0, dady = 0, dzdy = 0, dsdy = 0, dtdy = 0, dwdy = 0; + 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; + + INT32 yl, ym, yh; + INT32 xl, xm, xh; + INT32 dxldy, dxhdy, dxmdy; + int dzdy_dz, dzdx_dz; + int dsdylod, dtdylod; + 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 dsdiff = 0, dtdiff = 0, dwdiff = 0, drdiff = 0, dgdiff = 0, dbdiff = 0, dadiff = 0, dzdiff = 0; + int sign_dxhdy = 0; + + int dsdeh = 0, dtdeh = 0, dwdeh = 0, drdeh = 0, dgdeh = 0, dbdeh = 0, dadeh = 0, dzdeh = 0, dsdyh = 0, dtdyh = 0, dwdyh = 0, drdyh = 0, dgdyh = 0, dbdyh = 0, dadyh = 0, dzdyh = 0; + int do_offset = 0; + + int xfrac = 0; + int dseoff = 0, dteoff = 0, dweoff = 0, dreoff = 0, dgeoff = 0, dbeoff = 0, daeoff = 0, dzeoff = 0; + + 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; + + int spix = 0; // Current subpixel + int ycur; + int ylfar; + int ldflag; + int yhpix; + int ympix; + int ylpix; + + int shade_base = rdp_cmd_cur + 8; + int texture_base = rdp_cmd_cur + 24; + int zbuffer_base = rdp_cmd_cur + 40; + + 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); + // Inverse slopes in 16.16 format + dxldy = (INT32)(w4); + dxhdy = (INT32)(w6); + dxmdy = (INT32)(w8); + + max_level = ((w1 >> 19) & 7); + tilenum = (w1 >> 16) & 0x7; + + if (yl & 0x2000) yl |= 0xffffc000; + if (ym & 0x2000) ym |= 0xffffc000; + if (yh & 0x2000) yh |= 0xffffc000; + + if (xl & 0x20000000) xl |= 0xc0000000; + if (xm & 0x20000000) xm |= 0xc0000000; + if (xh & 0x20000000) xh |= 0xc0000000; + + z = 0; + s = 0; t = 0; w = 0; + dr = 0; dg = 0; db = 0; da = 0; + + r = (rdp_cmd_data[shade_base+0 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+4 ] >> 16) & 0x0000ffff); + g = ((rdp_cmd_data[shade_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+4 ] & 0x0000ffff); + b = (rdp_cmd_data[shade_base+1 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+5 ] >> 16) & 0x0000ffff); + a = ((rdp_cmd_data[shade_base+1 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+5 ] & 0x0000ffff); + drdx = (rdp_cmd_data[shade_base+2 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+6 ] >> 16) & 0x0000ffff); + dgdx = ((rdp_cmd_data[shade_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+6 ] & 0x0000ffff); + dbdx = (rdp_cmd_data[shade_base+3 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+7 ] >> 16) & 0x0000ffff); + dadx = ((rdp_cmd_data[shade_base+3 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+7 ] & 0x0000ffff); + drde = (rdp_cmd_data[shade_base+8 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+12] >> 16) & 0x0000ffff); + dgde = ((rdp_cmd_data[shade_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+12] & 0x0000ffff); + dbde = (rdp_cmd_data[shade_base+9 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+13] >> 16) & 0x0000ffff); + dade = ((rdp_cmd_data[shade_base+9 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+13] & 0x0000ffff); + drdy = (rdp_cmd_data[shade_base+10] & 0xffff0000) | ((rdp_cmd_data[shade_base+14] >> 16) & 0x0000ffff); + dgdy = ((rdp_cmd_data[shade_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+14] & 0x0000ffff); + dbdy = (rdp_cmd_data[shade_base+11] & 0xffff0000) | ((rdp_cmd_data[shade_base+15] >> 16) & 0x0000ffff); + dady = ((rdp_cmd_data[shade_base+11] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+15] & 0x0000ffff); + s = (rdp_cmd_data[texture_base+0 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+4 ] >> 16) & 0x0000ffff); + t = ((rdp_cmd_data[texture_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+4 ] & 0x0000ffff); + w = (rdp_cmd_data[texture_base+1 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+5 ] >> 16) & 0x0000ffff); + dsdx = (rdp_cmd_data[texture_base+2 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+6 ] >> 16) & 0x0000ffff); + dtdx = ((rdp_cmd_data[texture_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+6 ] & 0x0000ffff); + dwdx = (rdp_cmd_data[texture_base+3 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+7 ] >> 16) & 0x0000ffff); + dsde = (rdp_cmd_data[texture_base+8 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+12] >> 16) & 0x0000ffff); + dtde = ((rdp_cmd_data[texture_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+12] & 0x0000ffff); + dwde = (rdp_cmd_data[texture_base+9 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+13] >> 16) & 0x0000ffff); + dsdy = (rdp_cmd_data[texture_base+10] & 0xffff0000) | ((rdp_cmd_data[texture_base+14] >> 16) & 0x0000ffff); + dtdy = ((rdp_cmd_data[texture_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+14] & 0x0000ffff); + dwdy = (rdp_cmd_data[texture_base+11] & 0xffff0000) | ((rdp_cmd_data[texture_base+15] >> 16) & 0x0000ffff); + 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]; + + span[0].ds.w = dsdx; + span[0].dt.w = dtdx; + span[0].dw.w = dwdx; + span[0].dr.w = drdx & ~0x1f; + span[0].dg.w = dgdx & ~0x1f; + span[0].db.w = dbdx & ~0x1f; + span[0].da.w = dadx & ~0x1f; + 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); + dsdylod = dsdy >> 16; + dtdylod = dtdy >> 16; + if (dsdylod & 0x20000) + { + dsdylod = ~dsdylod & 0x1ffff; + } + if (dtdylod & 0x20000) + { + dtdylod = ~dtdylod & 0x1ffff; + } + span[0].dymax = (dsdylod > dtdylod)? dsdylod : dtdylod; + + xleft_inc = dxmdy >> 2; + xright_inc = dxhdy >> 2; + + xright = xh; + xleft = xm; + + 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++) + { + 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; + + do_offset = !(sign_dxhdy ^ (flip)); + + if (do_offset) + { + dsdeh = dsde >> 9; dsdyh = dsdy >> 9; + dtdeh = dtde >> 9; dtdyh = dtdy >> 9; + dwdeh = dwde >> 9; dwdyh = dwdy >> 9; + drdeh = drde >> 9; drdyh = drdy >> 9; + dgdeh = dgde >> 9; dgdyh = dgdy >> 9; + dbdeh = dbde >> 9; dbdyh = dbdy >> 9; + dadeh = dade >> 9; dadyh = dady >> 9; + dzdeh = dzde >> 9; dzdyh = dzdy >> 9; + + dsdiff = (dsdeh*3 - dsdyh*3) << 7; + dtdiff = (dtdeh*3 - dtdyh*3) << 7; + dwdiff = (dwdeh*3 - dwdyh*3) << 7; + drdiff = (drdeh*3 - drdyh*3) << 7; + dgdiff = (dgdeh*3 - dgdyh*3) << 7; + dbdiff = (dbdeh*3 - dbdyh*3) << 7; + dadiff = (dadeh*3 - dadyh*3) << 7; + dzdiff = (dzdeh*3 - dzdyh*3) << 7; + } + else + { + dsdiff = dtdiff = dwdiff = drdiff = dgdiff = dbdiff = dadiff = dzdiff = 0; + } + + if (do_offset) + { + dseoff = (dsdeh*3) << 7; + dteoff = (dtdeh*3) << 7; + dweoff = (dwdeh*3) << 7; + dreoff = (drdeh*3) << 7; + dgeoff = (dgdeh*3) << 7; + dbeoff = (dbdeh*3) << 7; + daeoff = (dadeh*3) << 7; + dzeoff = (dzdeh*3) << 7; + } + else + { + 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; + drdxh = drdx >> 8; + dgdxh = dgdx >> 8; + dbdxh = dbdx >> 8; + dadxh = dadx >> 8; + dzdxh = dzdx >> 8; + +#define adjust_attr() \ +{ \ + span[j].s.w = (s + dsdiff - (xfrac * dsdxh)) & ~0x1f; \ + span[j].t.w = (t + dtdiff - (xfrac * dtdxh)) & ~0x1f; \ + span[j].w.w = (w + dwdiff - (xfrac * dwdxh)) & ~0x1f; \ + span[j].r.w = r + drdiff - (xfrac * drdxh); \ + span[j].g.w = g + dgdiff - (xfrac * dgdxh); \ + span[j].b.w = b + dbdiff - (xfrac * dbdxh); \ + span[j].a.w = a + dadiff - (xfrac * dadxh); \ + span[j].z.w = z + dzdiff - (xfrac * dzdxh); \ +} + +#define addvalues() { \ + s += dsde; \ + t += dtde; \ + w += dwde; \ + r += drde; \ + g += dgde; \ + b += dbde; \ + a += dade; \ + z += dzde; \ +} + + 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; + + for (k = ycur; k <= ylfar; k++) + { + if (k == ym) + { + xleft = xl; + xleft_inc = dxldy >> 2; + } + + xstart = xleft >> 16; + xend = xright >> 16; + j = k >> 2; + spix = k & 3; + + if (k >= 0 && k < 0x1000) + { + 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) + { + 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; + } + } + + if (spix == max) + { + if (flip) + { + span[j].lx = maxxmx; + span[j].rx = minxhx; + } + else + { + span[j].lx = minxmx; + span[j].rx = maxxhx; + } + } + + length = flip ? (xstart - xend) : (xend - xstart); + + if (spix == ldflag) + { + xfrac = ((xright >> 8) & 0xff); + adjust_attr(); + } + + m = flip ? (xend+1) : (xend-1); + + if (k >= yh && length >= 0 && k <= yl) + { + if (xstart>=0 && xstart <1024) + { + if (!flip) + { + span[j].cvg[xstart] += addleft(xleft); + } + else + { + span[j].cvg[xstart] += addright(xleft); + } + } + if (xend>=0 && xend<1024) + { + if (xstart != xend) + { + if (!flip) + { + span[j].cvg[xend] += addright(xright); + } + else + { + span[j].cvg[xend] += addleft(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; + } + } + } + for (n = 0; n < (length - 1); n++) + { + if (m>=0 && m < 640) + { + span[j].cvg[m] += 2; + } + + m += m_inc; + } + } + } + + if (spix == 3) + { + addvalues(); + } + xleft += xleft_inc; + xright += xright_inc; + } + + switch (fb_size) // 8bpp needs to be implemented + { + case PIXEL_SIZE_16BIT: + if(flip) + { + render_spans_16_s_t_z_f(yh>>2, yl>>2, &tile[0]); break; + } + else + { + render_spans_16_s_t_z_nf(yh>>2, yl>>2, &tile[0]); break; + } + case PIXEL_SIZE_32BIT: render_spans_32(yh>>2, yl>>2, &tile[tilenum], 1, 1, 1, flip); break; + default: break; // V-Rally2 does this, fb_size=0 + } +} +#undef addvalues +#undef adjust_attr +#undef addleft +#undef addright +#undef setvalues diff --git a/src/mame/video/rdptri.h b/src/mame/video/rdptri.h new file mode 100644 index 00000000000..8d2a05cde5e --- /dev/null +++ b/src/mame/video/rdptri.h @@ -0,0 +1,8 @@ +static void triangle_ns_nt_nz(UINT32 w1, UINT32 w2); +static void triangle_ns_nt_z(UINT32 w1, UINT32 w2); +static void triangle_ns_t_nz(UINT32 w1, UINT32 w2); +static void triangle_ns_t_z(UINT32 w1, UINT32 w2); +static void triangle_s_nt_nz(UINT32 w1, UINT32 w2); +static void triangle_s_nt_z(UINT32 w1, UINT32 w2); +static void triangle_s_t_nz(UINT32 w1, UINT32 w2); +static void triangle_s_t_z(UINT32 w1, UINT32 w2);