summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.gitattributes4
-rw-r--r--src/mame/video/rdpblend.c206
-rw-r--r--src/mame/video/rdpblend.h33
-rw-r--r--src/mame/video/rdpupd16.c149
-rw-r--r--src/mame/video/rdpupd16.h0
5 files changed, 392 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
index ccac5c04e80..e5d0741c3f6 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -3548,6 +3548,8 @@ src/mame/video/rdpacomp.c svneol=native#text/plain
src/mame/video/rdpacomp.h svneol=native#text/plain
src/mame/video/rdpacvg.c svneol=native#text/plain
src/mame/video/rdpacvg.h svneol=native#text/plain
+src/mame/video/rdpblend.c svneol=native#text/plain
+src/mame/video/rdpblend.h svneol=native#text/plain
src/mame/video/rdpfb.c svneol=native#text/plain
src/mame/video/rdpfb.h svneol=native#text/plain
src/mame/video/rdpfetch.c svneol=native#text/plain
@@ -3560,6 +3562,8 @@ 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/rdpupd16.c svneol=native#text/plain
+src/mame/video/rdpupd16.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/rdpblend.c b/src/mame/video/rdpblend.c
new file mode 100644
index 00000000000..15ab5cc01b1
--- /dev/null
+++ b/src/mame/video/rdpblend.c
@@ -0,0 +1,206 @@
+#if defined(RGBDITHER1)
+ #if defined(ZCOMPARE)
+ #if defined(IMGREAD)
+ INLINE int BLENDER1_16_IMR_ZC_DITH(UINT16 *fb, UINT8* hb, COLOR c, int dith)
+ #else
+ INLINE int BLENDER1_16_NIMR_ZC_DITH(UINT16 *fb, UINT8* hb, COLOR c, int dith)
+ #endif
+ #else
+ #if defined(IMGREAD)
+ INLINE int BLENDER1_16_IMR_NZC_DITH(UINT16 *fb, UINT8* hb, COLOR c, int dith)
+ #else
+ INLINE int BLENDER1_16_NIMR_NZC_DITH(UINT16 *fb, UINT8* hb, COLOR c, int dith)
+ #endif
+ #endif
+#else
+ #if defined(ZCOMPARE)
+ #if defined(IMGREAD)
+ INLINE int BLENDER1_16_IMR_ZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c, int dith)
+ #else
+ INLINE int BLENDER1_16_NIMR_ZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c, int dith)
+ #endif
+ #else
+ #if defined(IMGREAD)
+ INLINE int BLENDER1_16_IMR_NZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c, int dith)
+ #else
+ INLINE int BLENDER1_16_NIMR_NZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c, int dith)
+ #endif
+ #endif
+#endif
+{
+ int r, g, b;
+ int special_bsel = 0;
+ UINT16 mem = *fb;
+#if defined(IMGREAD)
+ UINT32 memory_cvg = ((mem & 1) << 2) + (*hb & 3);
+#endif
+
+ // Alpha compare
+ if (!alpha_compare(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;
+
+#if !defined(ZCOMPARE)
+ curpixel_overlap = 0;
+#endif
+
+ 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 defined(IMGREAD)
+ memory_color.i.a = (memory_cvg << 5) & 0xe0;
+#else
+ memory_color.i.a = 0xe0;
+#endif
+
+ 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_EQUATION0(&r, &g, &b, special_bsel);
+ }
+
+#if !defined(RGBDITHER1)
+ // Hack to prevent "double-dithering" artifacts
+ if (!(((r & 0xf8)==(memory_color.i.r&0xf8) && (g & 0xf8) == (memory_color.i.g & 0xf8) &&(b&0xf8)==(memory_color.i.b&0xf8))))
+ {
+ rgb_dither(&r, &g, &b, dith);
+ }
+#endif
+
+ return (FBWRITE_16(fb, hb, r, g, b));
+}
+
+#if defined(RGBDITHER1)
+ #if defined(ZCOMPARE)
+ #if defined(IMGREAD)
+ INLINE int BLENDER2_16_IMR_ZC_DITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith)
+ #else
+ INLINE int BLENDER2_16_NIMR_ZC_DITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith)
+ #endif
+ #else
+ #if defined(IMGREAD)
+ INLINE int BLENDER2_16_IMR_NZC_DITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith)
+ #else
+ INLINE int BLENDER2_16_NIMR_NZC_DITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith)
+ #endif
+ #endif
+#else
+ #if defined(ZCOMPARE)
+ #if defined(IMGREAD)
+ INLINE int BLENDER2_16_IMR_ZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith)
+ #else
+ INLINE int BLENDER2_16_NIMR_ZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith)
+ #endif
+ #else
+ #if defined(IMGREAD)
+ INLINE int BLENDER2_16_IMR_NZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith)
+ #else
+ INLINE int BLENDER2_16_NIMR_NZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith)
+ #endif
+ #endif
+#endif
+{
+ int r, g, b;
+ int special_bsel = 0;
+ UINT16 mem = *fb;
+#if defined(IMGREAD)
+ UINT32 memory_cvg = ((mem & 1) << 2) + (*hb & 3);
+#endif
+
+ // Alpha compare
+ if (!alpha_compare(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;
+
+#if !defined(ZCOMPARE)
+ curpixel_overlap = 0;
+#endif
+
+ 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 defined(IMGREAD)
+ memory_color.i.a = (memory_cvg << 5) & 0xe0;
+#else
+ memory_color.i.a = 0xe0;
+#endif
+
+ inv_pixel_color.i.a = 0xff - *blender1b_a[0];
+
+ BLENDER_EQUATION0(&r, &g, &b, 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_EQUATION1(&r, &g, &b, special_bsel);
+ }
+
+#if !defined(RGBDITH1)
+ // Hack to prevent "double-dithering" artifacts
+ if (!(((r & 0xf8)==(memory_color.i.r&0xf8) && (g & 0xf8) == (memory_color.i.g & 0xf8) &&(b&0xf8)==(memory_color.i.b&0xf8))))
+ {
+ rgb_dither(&r, &g, &b, dith);
+ }
+#endif
+
+ return (FBWRITE_16(fb, hb, r, g, b));
+}
diff --git a/src/mame/video/rdpblend.h b/src/mame/video/rdpblend.h
new file mode 100644
index 00000000000..13af9b4685e
--- /dev/null
+++ b/src/mame/video/rdpblend.h
@@ -0,0 +1,33 @@
+INLINE int BLENDER1_16_IMR_ZC_DITH(UINT16 *fb, UINT8* hb, COLOR c, int dith);
+INLINE int BLENDER1_16_IMR_ZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c, int dith);
+INLINE int BLENDER1_16_IMR_NZC_DITH(UINT16 *fb, UINT8* hb, COLOR c, int dith);
+INLINE int BLENDER1_16_IMR_NZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c, int dith);
+INLINE int BLENDER1_16_NIMR_ZC_DITH(UINT16 *fb, UINT8* hb, COLOR c, int dith);
+INLINE int BLENDER1_16_NIMR_ZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c, int dith);
+INLINE int BLENDER1_16_NIMR_NZC_DITH(UINT16 *fb, UINT8* hb, COLOR c, int dith);
+INLINE int BLENDER1_16_NIMR_NZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c, int dith);
+
+INLINE int BLENDER2_16_IMR_ZC_DITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith);
+INLINE int BLENDER2_16_IMR_ZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith);
+INLINE int BLENDER2_16_IMR_NZC_DITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith);
+INLINE int BLENDER2_16_IMR_NZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith);
+INLINE int BLENDER2_16_NIMR_ZC_DITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith);
+INLINE int BLENDER2_16_NIMR_ZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith);
+INLINE int BLENDER2_16_NIMR_NZC_DITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith);
+INLINE int BLENDER2_16_NIMR_NZC_NDITH(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith);
+
+static int (*rdp_blender1_16_func[8])(UINT16 *, UINT8 *, COLOR, int) =
+{
+ BLENDER1_16_NIMR_NZC_NDITH, BLENDER1_16_NIMR_ZC_NDITH,
+ BLENDER1_16_NIMR_ZC_NDITH, BLENDER1_16_NIMR_ZC_DITH,
+ BLENDER1_16_IMR_NZC_NDITH, BLENDER1_16_IMR_NZC_DITH,
+ BLENDER1_16_IMR_ZC_NDITH, BLENDER1_16_IMR_ZC_DITH,
+};
+
+static int (*rdp_blender2_16_func[8])(UINT16 *, UINT8 *, COLOR, COLOR, int) =
+{
+ BLENDER2_16_NIMR_NZC_NDITH, BLENDER2_16_NIMR_NZC_DITH,
+ BLENDER2_16_NIMR_ZC_NDITH, BLENDER2_16_NIMR_ZC_DITH,
+ BLENDER2_16_IMR_NZC_NDITH, BLENDER2_16_IMR_NZC_DITH,
+ BLENDER2_16_IMR_ZC_NDITH, BLENDER2_16_IMR_ZC_DITH,
+};
diff --git a/src/mame/video/rdpupd16.c b/src/mame/video/rdpupd16.c
new file mode 100644
index 00000000000..7ce3a4dc91b
--- /dev/null
+++ b/src/mame/video/rdpupd16.c
@@ -0,0 +1,149 @@
+#if defined(FSAA)
+ #if defined(DIVOT)
+ static void video_update_n64_16_fsaa_divot(bitmap_t *bitmap)
+ #else
+ static void video_update_n64_16_fsaa_nodivot(bitmap_t *bitmap)
+ #endif
+#else
+ #if defined(DIVOT)
+ static void video_update_n64_16_nofsaa_divot(bitmap_t *bitmap)
+ #else
+ static void video_update_n64_16_nofsaa_nodivot(bitmap_t *bitmap)
+ #endif
+#endif
+{
+ int i, j;
+ UINT32 final = 0;
+#if defined(DIVOT)
+ UINT32 prev_cvg = 0, next_cvg = 0;
+#endif
+ //int dither_filter = (n64_vi_control >> 16) & 1;
+ //int vibuffering = ((n64_vi_control & 2) && fsaa && divot);
+
+ UINT16 *frame_buffer;
+ UINT32 hb;
+ UINT8* hidden_buffer;
+
+ UINT32 pixels = 0;
+ UINT16 pix = 0;
+
+ INT32 hdiff = (n64_vi_hstart & 0x3ff) - ((n64_vi_hstart >> 16) & 0x3ff);
+ float hcoeff = ((float)(n64_vi_xscale & 0xfff) / (1 << 10));
+ UINT32 hres = ((float)hdiff * hcoeff);
+ INT32 invisiblewidth = n64_vi_width - hres;
+
+ INT32 vdiff = ((n64_vi_vstart & 0x3ff) - ((n64_vi_vstart >> 16) & 0x3ff)) >> 1;
+ float vcoeff = ((float)(n64_vi_yscale & 0xfff) / (1 << 10));
+ UINT32 vres = ((float)vdiff * vcoeff);
+
+ if (vdiff <= 0 || hdiff <= 0)
+ {
+ return;
+ }
+
+ frame_buffer = (UINT16*)&rdram[(n64_vi_origin & 0xffffff) >> 2];
+ hb = ((n64_vi_origin & 0xffffff) >> 2) >> 1;
+ hidden_buffer = &hidden_bits[hb];
+
+ if (hres > 640) // Needed by Top Gear Overdrive (E)
+ {
+ invisiblewidth += (hres - 640);
+ hres = 640;
+ }
+
+ pixels = 0;
+
+ if (frame_buffer)
+ {
+ 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 defined(DIVOT)
+ if (i > 0 && i < (hres - 1))
+ {
+ 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);
+ }
+#endif
+ r = ((pix >> 8) & 0xf8) | (pix >> 13);
+ g = ((pix >> 3) & 0xf8) | ((pix >> 8) & 0x07);
+ b = ((pix << 2) & 0xf8) | ((pix >> 3) & 0x07);
+
+#if defined(FSAA)
+ if (/*!vibuffering &&*/ curpixel_cvg < 7 && i > 1 && j > 1 && i < (hres - 2) && j < (vres - 2))
+ {
+ video_filter16(&r, &g, &b, &frame_buffer[pixels ^ WORD_ADDR_XOR],&hidden_buffer[pixels ^ BYTE_ADDR_XOR], n64_vi_width);
+ }
+#endif
+ //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 defined(DIVOT)
+ if (i > 0 && i < (hres - 1) && (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);
+ //}
+ }
+#endif
+
+ /*
+ 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;
+ }
+ }
+}
diff --git a/src/mame/video/rdpupd16.h b/src/mame/video/rdpupd16.h
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/src/mame/video/rdpupd16.h