Previous 15994 Revisions Next

r6715 Sunday 20th December, 2009 at 20:14:22 UTC by Harmony
[N64] More RDP optimization through branch flattening. RSP is once again the bottleneck on 3D games. [Harmony]
[src/mame/video]n64.c rdpacomp.c rdpacomp.h rdpacvg.c rdpacvg.h rdpfb.c rdpfb.h rdpfetch.c rdpfetch.h rdpspn16.c rdpspn16.h rdptpipe.c rdptrect.c rdptrect.h

src/mame/video/rdpfetch.c
r6714r6715
439439}
440440
441441//typedef void (*rdp_fetch_texel_func)(COLOR *color, int s, int t);
442
443static void (*rdp_fetch_texel_func[128])(COLOR*, int, int) =
444{
445   // 4-bit accessors
446   FETCH_TEXEL_RGBA4_TLUT_NEN, FETCH_TEXEL_RGBA4_TLUT_NEN, FETCH_TEXEL_RGBA4_TLUT_EN0, FETCH_TEXEL_RGBA4_TLUT_EN1,
447   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
448   FETCH_TEXEL_CI4_TLUT_NEN,    FETCH_TEXEL_CI4_TLUT_NEN,    FETCH_TEXEL_CI4_TLUT_EN0,    FETCH_TEXEL_CI4_TLUT_EN1,
449   FETCH_TEXEL_IA4_TLUT_NEN,   FETCH_TEXEL_IA4_TLUT_NEN,   FETCH_TEXEL_IA4_TLUT_EN0,   FETCH_TEXEL_IA4_TLUT_EN1,
450   FETCH_TEXEL_I4_TLUT_NEN,   FETCH_TEXEL_I4_TLUT_NEN,   FETCH_TEXEL_I4_TLUT_EN0,   FETCH_TEXEL_I4_TLUT_EN1,
451   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
452   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
453   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
454
455   // 8-bit accessors
456   FETCH_TEXEL_RGBA8_TLUT_NEN, FETCH_TEXEL_RGBA8_TLUT_NEN, FETCH_TEXEL_RGBA8_TLUT_EN0, FETCH_TEXEL_RGBA8_TLUT_EN1,
457   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
458   FETCH_TEXEL_CI8_TLUT_NEN,    FETCH_TEXEL_CI8_TLUT_NEN,    FETCH_TEXEL_CI8_TLUT_EN0,    FETCH_TEXEL_CI8_TLUT_EN1,
459   FETCH_TEXEL_IA8_TLUT_NEN,   FETCH_TEXEL_IA8_TLUT_NEN,   FETCH_TEXEL_IA8_TLUT_EN0,   FETCH_TEXEL_IA8_TLUT_EN1,
460   FETCH_TEXEL_I8_TLUT_NEN,   FETCH_TEXEL_I8_TLUT_NEN,   FETCH_TEXEL_I8_TLUT_EN0,   FETCH_TEXEL_I8_TLUT_EN1,
461   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
462   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
463   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
464
465   // 16-bit accessors
466   FETCH_TEXEL_RGBA16_TLUT_NEN,FETCH_TEXEL_RGBA16_TLUT_NEN,FETCH_TEXEL_RGBA16_TLUT_EN0,FETCH_TEXEL_RGBA16_TLUT_EN1,
467   FETCH_TEXEL_YUV16,          FETCH_TEXEL_YUV16,          FETCH_TEXEL_YUV16,          FETCH_TEXEL_YUV16,
468   FETCH_TEXEL_CI16_TLUT_NEN,    FETCH_TEXEL_CI16_TLUT_NEN,    FETCH_TEXEL_CI16_TLUT_EN0,    FETCH_TEXEL_CI16_TLUT_EN1,
469   FETCH_TEXEL_IA16_TLUT_NEN,   FETCH_TEXEL_IA16_TLUT_NEN,   FETCH_TEXEL_IA16_TLUT_EN0,   FETCH_TEXEL_IA16_TLUT_EN1,
470   FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,
471   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
472   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
473   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
474
475   // 32-bit accessors
476   FETCH_TEXEL_RGBA32_TLUT_NEN,FETCH_TEXEL_RGBA32_TLUT_NEN,FETCH_TEXEL_RGBA32_TLUT_EN0,FETCH_TEXEL_RGBA32_TLUT_EN1,
477   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
478   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
479   FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,
480   FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,
481   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
482   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
483   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
484};
src/mame/video/rdpfetch.h
r6714r6715
1INLINE void FETCH_TEXEL_RGBA4_TLUT_EN0(COLOR *color, int s, int t);
2INLINE void FETCH_TEXEL_RGBA4_TLUT_EN1(COLOR *color, int s, int t);
3INLINE void FETCH_TEXEL_RGBA4_TLUT_NEN(COLOR *color, int s, int t);
4INLINE void FETCH_TEXEL_RGBA8_TLUT_EN0(COLOR *color, int s, int t);
5INLINE void FETCH_TEXEL_RGBA8_TLUT_EN1(COLOR *color, int s, int t);
6INLINE void FETCH_TEXEL_RGBA8_TLUT_NEN(COLOR *color, int s, int t);
7INLINE void FETCH_TEXEL_RGBA16_TLUT_EN0(COLOR *color, int s, int t);
8INLINE void FETCH_TEXEL_RGBA16_TLUT_EN1(COLOR *color, int s, int t);
9INLINE void FETCH_TEXEL_RGBA16_TLUT_NEN(COLOR *color, int s, int t);
10INLINE void FETCH_TEXEL_RGBA32_TLUT_EN0(COLOR *color, int s, int t);
11INLINE void FETCH_TEXEL_RGBA32_TLUT_EN1(COLOR *color, int s, int t);
12INLINE void FETCH_TEXEL_RGBA32_TLUT_NEN(COLOR *color, int s, int t);
13INLINE void FETCH_TEXEL_YUV16(COLOR *color, int s, int t);
14INLINE void FETCH_TEXEL_CI4_TLUT_EN0(COLOR *color, int s, int t);
15INLINE void FETCH_TEXEL_CI4_TLUT_EN1(COLOR *color, int s, int t);
16INLINE void FETCH_TEXEL_CI4_TLUT_NEN(COLOR *color, int s, int t);
17INLINE void FETCH_TEXEL_CI8_TLUT_EN0(COLOR *color, int s, int t);
18INLINE void FETCH_TEXEL_CI8_TLUT_EN1(COLOR *color, int s, int t);
19INLINE void FETCH_TEXEL_CI8_TLUT_NEN(COLOR *color, int s, int t);
20INLINE void FETCH_TEXEL_CI16_TLUT_EN0(COLOR *color, int s, int t);
21INLINE void FETCH_TEXEL_CI16_TLUT_EN1(COLOR *color, int s, int t);
22INLINE void FETCH_TEXEL_CI16_TLUT_NEN(COLOR *color, int s, int t);
23INLINE void FETCH_TEXEL_IA4_TLUT_EN0(COLOR *color, int s, int t);
24INLINE void FETCH_TEXEL_IA4_TLUT_EN1(COLOR *color, int s, int t);
25INLINE void FETCH_TEXEL_IA4_TLUT_NEN(COLOR *color, int s, int t);
26INLINE void FETCH_TEXEL_IA8_TLUT_EN0(COLOR *color, int s, int t);
27INLINE void FETCH_TEXEL_IA8_TLUT_EN1(COLOR *color, int s, int t);
28INLINE void FETCH_TEXEL_IA8_TLUT_NEN(COLOR *color, int s, int t);
29INLINE void FETCH_TEXEL_IA16_TLUT_EN0(COLOR *color, int s, int t);
30INLINE void FETCH_TEXEL_IA16_TLUT_EN1(COLOR *color, int s, int t);
31INLINE void FETCH_TEXEL_IA16_TLUT_NEN(COLOR *color, int s, int t);
32INLINE void FETCH_TEXEL_I4_TLUT_EN0(COLOR *color, int s, int t);
33INLINE void FETCH_TEXEL_I4_TLUT_EN1(COLOR *color, int s, int t);
34INLINE void FETCH_TEXEL_I4_TLUT_NEN(COLOR *color, int s, int t);
35INLINE void FETCH_TEXEL_I8_TLUT_EN0(COLOR *color, int s, int t);
36INLINE void FETCH_TEXEL_I8_TLUT_EN1(COLOR *color, int s, int t);
37INLINE void FETCH_TEXEL_I8_TLUT_NEN(COLOR *color, int s, int t);
38INLINE void FETCH_TEXEL_INVALID(COLOR *color, int s, int t);
39
40static void (*rdp_fetch_texel_func[128])(COLOR*, int, int) =
41{
42   // 4-bit accessors
43   FETCH_TEXEL_RGBA4_TLUT_NEN, FETCH_TEXEL_RGBA4_TLUT_NEN, FETCH_TEXEL_RGBA4_TLUT_EN0, FETCH_TEXEL_RGBA4_TLUT_EN1,
44   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
45   FETCH_TEXEL_CI4_TLUT_NEN,    FETCH_TEXEL_CI4_TLUT_NEN,    FETCH_TEXEL_CI4_TLUT_EN0,    FETCH_TEXEL_CI4_TLUT_EN1,
46   FETCH_TEXEL_IA4_TLUT_NEN,   FETCH_TEXEL_IA4_TLUT_NEN,   FETCH_TEXEL_IA4_TLUT_EN0,   FETCH_TEXEL_IA4_TLUT_EN1,
47   FETCH_TEXEL_I4_TLUT_NEN,   FETCH_TEXEL_I4_TLUT_NEN,   FETCH_TEXEL_I4_TLUT_EN0,   FETCH_TEXEL_I4_TLUT_EN1,
48   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
49   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
50   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
51
52   // 8-bit accessors
53   FETCH_TEXEL_RGBA8_TLUT_NEN, FETCH_TEXEL_RGBA8_TLUT_NEN, FETCH_TEXEL_RGBA8_TLUT_EN0, FETCH_TEXEL_RGBA8_TLUT_EN1,
54   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
55   FETCH_TEXEL_CI8_TLUT_NEN,    FETCH_TEXEL_CI8_TLUT_NEN,    FETCH_TEXEL_CI8_TLUT_EN0,    FETCH_TEXEL_CI8_TLUT_EN1,
56   FETCH_TEXEL_IA8_TLUT_NEN,   FETCH_TEXEL_IA8_TLUT_NEN,   FETCH_TEXEL_IA8_TLUT_EN0,   FETCH_TEXEL_IA8_TLUT_EN1,
57   FETCH_TEXEL_I8_TLUT_NEN,   FETCH_TEXEL_I8_TLUT_NEN,   FETCH_TEXEL_I8_TLUT_EN0,   FETCH_TEXEL_I8_TLUT_EN1,
58   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
59   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
60   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
61
62   // 16-bit accessors
63   FETCH_TEXEL_RGBA16_TLUT_NEN,FETCH_TEXEL_RGBA16_TLUT_NEN,FETCH_TEXEL_RGBA16_TLUT_EN0,FETCH_TEXEL_RGBA16_TLUT_EN1,
64   FETCH_TEXEL_YUV16,          FETCH_TEXEL_YUV16,          FETCH_TEXEL_YUV16,          FETCH_TEXEL_YUV16,
65   FETCH_TEXEL_CI16_TLUT_NEN,    FETCH_TEXEL_CI16_TLUT_NEN,    FETCH_TEXEL_CI16_TLUT_EN0,    FETCH_TEXEL_CI16_TLUT_EN1,
66   FETCH_TEXEL_IA16_TLUT_NEN,   FETCH_TEXEL_IA16_TLUT_NEN,   FETCH_TEXEL_IA16_TLUT_EN0,   FETCH_TEXEL_IA16_TLUT_EN1,
67   FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,
68   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
69   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
70   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
71
72   // 32-bit accessors
73   FETCH_TEXEL_RGBA32_TLUT_NEN,FETCH_TEXEL_RGBA32_TLUT_NEN,FETCH_TEXEL_RGBA32_TLUT_EN0,FETCH_TEXEL_RGBA32_TLUT_EN1,
74   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
75   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
76   FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,
77   FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,      FETCH_TEXEL_INVALID,
78   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
79   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
80   FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,       FETCH_TEXEL_INVALID,
81};
src/mame/video/rdptpipe.c
r6714r6715
4545      INVTF = 0x20 - TFRAC;
4646   }
4747
48   if (!upper)
49   {
50      FETCH_TEXEL(&t0, sss1, sst1, tex_tile);
51   }
5248   FETCH_TEXEL(&t1, sss2, sst1, tex_tile);
5349   FETCH_TEXEL(&t2, sss1, sst2, tex_tile);
54   if (upper)
55   {
56      FETCH_TEXEL(&t3, sss2, sst2, tex_tile);
57   }
5850
59   if (upper)
51   if (!upper)
6052   {
61      R32 = t3.i.r + ((INVSF*(t2.i.r - t3.i.r))>>5) + ((INVTF*(t1.i.r - t3.i.r))>>5);
53      FETCH_TEXEL(&t0, sss1, sst1, tex_tile);
54      R32 = t0.i.r + ((SFRAC*(t1.i.r - t0.i.r))>>5) + ((TFRAC*(t2.i.r - t0.i.r))>>5);
6255      TEX->i.r = (R32 < 0) ? 0 : R32;
63      G32 = t3.i.g + ((INVSF*(t2.i.g - t3.i.g))>>5) + ((INVTF*(t1.i.g - t3.i.g))>>5);
56      G32 = t0.i.g + ((SFRAC*(t1.i.g - t0.i.g))>>5) + ((TFRAC*(t2.i.g - t0.i.g))>>5);
6457      TEX->i.g = (G32 < 0) ? 0 : G32;
65      B32 = t3.i.b + ((INVSF*(t2.i.b - t3.i.b))>>5) + ((INVTF*(t1.i.b - t3.i.b))>>5);
58      B32 = t0.i.b + ((SFRAC*(t1.i.b - t0.i.b))>>5) + ((TFRAC*(t2.i.b - t0.i.b))>>5);
6659      TEX->i.b = (B32 < 0) ? 0 : B32;
67      A32 = t3.i.a + ((INVSF*(t2.i.a - t3.i.a))>>5) + ((INVTF*(t1.i.a - t3.i.a))>>5);
60      A32 = t0.i.a + ((SFRAC*(t1.i.a - t0.i.a))>>5) + ((TFRAC*(t2.i.a - t0.i.a))>>5);
6861      TEX->i.a = (A32 < 0) ? 0 : A32;
6962   }
7063   else
7164   {
72      R32 = t0.i.r + ((SFRAC*(t1.i.r - t0.i.r))>>5) + ((TFRAC*(t2.i.r - t0.i.r))>>5);
65      FETCH_TEXEL(&t3, sss2, sst2, tex_tile);
66      R32 = t3.i.r + ((INVSF*(t2.i.r - t3.i.r))>>5) + ((INVTF*(t1.i.r - t3.i.r))>>5);
7367      TEX->i.r = (R32 < 0) ? 0 : R32;
74      G32 = t0.i.g + ((SFRAC*(t1.i.g - t0.i.g))>>5) + ((TFRAC*(t2.i.g - t0.i.g))>>5);
68      G32 = t3.i.g + ((INVSF*(t2.i.g - t3.i.g))>>5) + ((INVTF*(t1.i.g - t3.i.g))>>5);
7569      TEX->i.g = (G32 < 0) ? 0 : G32;
76      B32 = t0.i.b + ((SFRAC*(t1.i.b - t0.i.b))>>5) + ((TFRAC*(t2.i.b - t0.i.b))>>5);
70      B32 = t3.i.b + ((INVSF*(t2.i.b - t3.i.b))>>5) + ((INVTF*(t1.i.b - t3.i.b))>>5);
7771      TEX->i.b = (B32 < 0) ? 0 : B32;
78      A32 = t0.i.a + ((SFRAC*(t1.i.a - t0.i.a))>>5) + ((TFRAC*(t2.i.a - t0.i.a))>>5);
72      A32 = t3.i.a + ((INVSF*(t2.i.a - t3.i.a))>>5) + ((INVTF*(t1.i.a - t3.i.a))>>5);
7973      TEX->i.a = (A32 < 0) ? 0 : A32;
8074   }
8175}
src/mame/video/rdpspn16.c
r6714r6715
1static void render_spans_16_c1(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip)
1#if defined(SHADE)
2   #if defined(TEXTURE)
3      #if defined(ZBUF)
4         #if defined(FLIP)
5            #if defined(ZUPDATE)
6               #if defined(ZCOMPARE)
7                  static void render_spans_16_c1_s_t_z_f_zc_zu(int start, int end, TILE* tex_tile)
8               #else
9                  static void render_spans_16_c1_s_t_z_f_nzc_zu(int start, int end, TILE* tex_tile)
10               #endif
11            #else
12               #if defined(ZCOMPARE)
13                  static void render_spans_16_c1_s_t_z_f_zc(int start, int end, TILE* tex_tile)
14               #else
15                  static void render_spans_16_c1_s_t_z_f_nzc(int start, int end, TILE* tex_tile)
16               #endif
17            #endif
18         #else
19            #if defined(ZUPDATE)
20               #if defined(ZCOMPARE)
21                  static void render_spans_16_c1_s_t_z_nf_zc_zu(int start, int end, TILE* tex_tile)
22               #else
23                  static void render_spans_16_c1_s_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile)
24               #endif
25            #else
26               #if defined(ZCOMPARE)
27                  static void render_spans_16_c1_s_t_z_nf_zc(int start, int end, TILE* tex_tile)
28               #else
29                  static void render_spans_16_c1_s_t_z_nf_nzc(int start, int end, TILE* tex_tile)
30               #endif
31            #endif
32         #endif
33      #else
34         #if defined(FLIP)
35            #if defined(ZUPDATE)
36               #if defined(ZCOMPARE)
37                  static void render_spans_16_c1_s_t_nz_f_zc_zu(int start, int end, TILE* tex_tile)
38               #else
39                  static void render_spans_16_c1_s_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile)
40               #endif
41            #else
42               #if defined(ZCOMPARE)
43                  static void render_spans_16_c1_s_t_nz_f_zc(int start, int end, TILE* tex_tile)
44               #else
45                  static void render_spans_16_c1_s_t_nz_f_nzc(int start, int end, TILE* tex_tile)
46               #endif
47            #endif
48         #else
49            #if defined(ZUPDATE)
50               #if defined(ZCOMPARE)
51                  static void render_spans_16_c1_s_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile)
52               #else
53                  static void render_spans_16_c1_s_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile)
54               #endif
55            #else
56               #if defined(ZCOMPARE)
57                  static void render_spans_16_c1_s_t_nz_nf_zc(int start, int end, TILE* tex_tile)
58               #else
59                  static void render_spans_16_c1_s_t_nz_nf_nzc(int start, int end, TILE* tex_tile)
60               #endif
61            #endif
62         #endif
63      #endif
64   #else
65      #if defined(ZBUF)
66         #if defined(FLIP)
67            #if defined(ZUPDATE)
68               #if defined(ZCOMPARE)
69                  static void render_spans_16_c1_s_nt_z_f_zc_zu(int start, int end, TILE* tex_tile)
70               #else
71                  static void render_spans_16_c1_s_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile)
72               #endif
73            #else
74               #if defined(ZCOMPARE)
75                  static void render_spans_16_c1_s_nt_z_f_zc(int start, int end, TILE* tex_tile)
76               #else
77                  static void render_spans_16_c1_s_nt_z_f_nzc(int start, int end, TILE* tex_tile)
78               #endif
79            #endif
80         #else
81            #if defined(ZUPDATE)
82               #if defined(ZCOMPARE)
83                  static void render_spans_16_c1_s_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile)
84               #else
85                  static void render_spans_16_c1_s_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile)
86               #endif
87            #else
88               #if defined(ZCOMPARE)
89                  static void render_spans_16_c1_s_nt_z_nf_zc(int start, int end, TILE* tex_tile)
90               #else
91                  static void render_spans_16_c1_s_nt_z_nf_nzc(int start, int end, TILE* tex_tile)
92               #endif
93            #endif
94         #endif
95      #else
96         #if defined(FLIP)
97            #if defined(ZUPDATE)
98               #if defined(ZCOMPARE)
99                  static void render_spans_16_c1_s_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile)
100               #else
101                  static void render_spans_16_c1_s_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile)
102               #endif
103            #else
104               #if defined(ZCOMPARE)
105                  static void render_spans_16_c1_s_nt_nz_f_zc(int start, int end, TILE* tex_tile)
106               #else
107                  static void render_spans_16_c1_s_nt_nz_f_nzc(int start, int end, TILE* tex_tile)
108               #endif
109            #endif
110         #else
111            #if defined(ZUPDATE)
112               #if defined(ZCOMPARE)
113                  static void render_spans_16_c1_s_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile)
114               #else
115                  static void render_spans_16_c1_s_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile)
116               #endif
117            #else
118               #if defined(ZCOMPARE)
119                  static void render_spans_16_c1_s_nt_nz_nf_zc(int start, int end, TILE* tex_tile)
120               #else
121                  static void render_spans_16_c1_s_nt_nz_nf_nzc(int start, int end, TILE* tex_tile)
122               #endif
123            #endif
124         #endif
125      #endif
126   #endif
127#else
128   #if defined(TEXTURE)
129      #if defined(ZBUF)
130         #if defined(FLIP)
131            #if defined(ZUPDATE)
132               #if defined(ZCOMPARE)
133                  static void render_spans_16_c1_ns_t_z_f_zc_zu(int start, int end, TILE* tex_tile)
134               #else
135                  static void render_spans_16_c1_ns_t_z_f_nzc_zu(int start, int end, TILE* tex_tile)
136               #endif
137            #else
138               #if defined(ZCOMPARE)
139                  static void render_spans_16_c1_ns_t_z_f_zc(int start, int end, TILE* tex_tile)
140               #else
141                  static void render_spans_16_c1_ns_t_z_f_nzc(int start, int end, TILE* tex_tile)
142               #endif
143            #endif
144         #else
145            #if defined(ZUPDATE)
146               #if defined(ZCOMPARE)
147                  static void render_spans_16_c1_ns_t_z_nf_zc_zu(int start, int end, TILE* tex_tile)
148               #else
149                  static void render_spans_16_c1_ns_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile)
150               #endif
151            #else
152               #if defined(ZCOMPARE)
153                  static void render_spans_16_c1_ns_t_z_nf_zc(int start, int end, TILE* tex_tile)
154               #else
155                  static void render_spans_16_c1_ns_t_z_nf_nzc(int start, int end, TILE* tex_tile)
156               #endif
157            #endif
158         #endif
159      #else
160         #if defined(FLIP)
161            #if defined(ZUPDATE)
162               #if defined(ZCOMPARE)
163                  static void render_spans_16_c1_ns_t_nz_f_zc_zu(int start, int end, TILE* tex_tile)
164               #else
165                  static void render_spans_16_c1_ns_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile)
166               #endif
167            #else
168               #if defined(ZCOMPARE)
169                  static void render_spans_16_c1_ns_t_nz_f_zc(int start, int end, TILE* tex_tile)
170               #else
171                  static void render_spans_16_c1_ns_t_nz_f_nzc(int start, int end, TILE* tex_tile)
172               #endif
173            #endif
174         #else
175            #if defined(ZUPDATE)
176               #if defined(ZCOMPARE)
177                  static void render_spans_16_c1_ns_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile)
178               #else
179                  static void render_spans_16_c1_ns_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile)
180               #endif
181            #else
182               #if defined(ZCOMPARE)
183                  static void render_spans_16_c1_ns_t_nz_nf_zc(int start, int end, TILE* tex_tile)
184               #else
185                  static void render_spans_16_c1_ns_t_nz_nf_nzc(int start, int end, TILE* tex_tile)
186               #endif
187            #endif
188         #endif
189      #endif
190   #else
191      #if defined(ZBUF)
192         #if defined(FLIP)
193            #if defined(ZUPDATE)
194               #if defined(ZCOMPARE)
195                  static void render_spans_16_c1_ns_nt_z_f_zc_zu(int start, int end, TILE* tex_tile)
196               #else
197                  static void render_spans_16_c1_ns_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile)
198               #endif
199            #else
200               #if defined(ZCOMPARE)
201                  static void render_spans_16_c1_ns_nt_z_f_zc(int start, int end, TILE* tex_tile)
202               #else
203                  static void render_spans_16_c1_ns_nt_z_f_nzc(int start, int end, TILE* tex_tile)
204               #endif
205            #endif
206         #else
207            #if defined(ZUPDATE)
208               #if defined(ZCOMPARE)
209                  static void render_spans_16_c1_ns_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile)
210               #else
211                  static void render_spans_16_c1_ns_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile)
212               #endif
213            #else
214               #if defined(ZCOMPARE)
215                  static void render_spans_16_c1_ns_nt_z_nf_zc(int start, int end, TILE* tex_tile)
216               #else
217                  static void render_spans_16_c1_ns_nt_z_nf_nzc(int start, int end, TILE* tex_tile)
218               #endif
219            #endif
220         #endif
221      #else
222         #if defined(FLIP)
223            #if defined(ZUPDATE)
224               #if defined(ZCOMPARE)
225                  static void render_spans_16_c1_ns_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile)
226               #else
227                  static void render_spans_16_c1_ns_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile)
228               #endif
229            #else
230               #if defined(ZCOMPARE)
231                  static void render_spans_16_c1_ns_nt_nz_f_zc(int start, int end, TILE* tex_tile)
232               #else
233                  static void render_spans_16_c1_ns_nt_nz_f_nzc(int start, int end, TILE* tex_tile)
234               #endif
235            #endif
236         #else
237            #if defined(ZUPDATE)
238               #if defined(ZCOMPARE)
239                  static void render_spans_16_c1_ns_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile)
240               #else
241                  static void render_spans_16_c1_ns_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile)
242               #endif
243            #else
244               #if defined(ZCOMPARE)
245                  static void render_spans_16_c1_ns_nt_nz_nf_zc(int start, int end, TILE* tex_tile)
246               #else
247                  static void render_spans_16_c1_ns_nt_nz_nf_nzc(int start, int end, TILE* tex_tile)
248               #endif
249            #endif
250         #endif
251      #endif
252   #endif
253#endif
2254{
3255   UINT16 *fb = (UINT16*)&rdram[fb_address / 4];
256   UINT8 *hb = &hidden_bits[fb_address >> 1];
257#if defined(ZUPDATE) || defined(ZCOMPARE)
4258   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
5   UINT8 *hb = &hidden_bits[fb_address >> 1];
6259   UINT8 *zhb = &hidden_bits[zb_address >> 1];
260#endif
7261
8262   int i, j;
9263
10264   int clipx1, clipx2, clipy1, clipy2;
11265
266#if defined(SHADE)
267   SPAN_PARAM dr = span[0].dr;
268   SPAN_PARAM dg = span[0].dg;
269   SPAN_PARAM db = span[0].db;
270   SPAN_PARAM da = span[0].da;
271#if defined(FLIP)
272   int drinc = dr.w;
273   int dginc = dg.w;
274   int dbinc = db.w;
275   int dainc = da.w;
276#else
277   int drinc = -dr.w;
278   int dginc = -dg.w;
279   int dbinc = -db.w;
280   int dainc = -da.w;
281#endif
282#endif
283
284#if defined(TEXTURE)
12285   UINT32 prim_tile = tex_tile->num;
13286   UINT32 disable_lod = 0;
14287   int tilenum;
15288
16   SPAN_PARAM dr = span[0].dr;
17   SPAN_PARAM dg = span[0].dg;
18   SPAN_PARAM db = span[0].db;
19   SPAN_PARAM da = span[0].da;
20   SPAN_PARAM dz = span[0].dz;
21289   SPAN_PARAM ds = span[0].ds;
22290   SPAN_PARAM dt = span[0].dt;
23291   SPAN_PARAM dw = span[0].dw;
292#if defined(FLIP)
293   int dsinc = ds.w;
294   int dtinc = dt.w;
295   int dwinc = dw.w;
296#else
297   int dsinc = -ds.w;
298   int dtinc = -dt.w;
299   int dwinc = -dw.w;
300#endif
301#endif
302
303#if defined(ZBUF)
304   SPAN_PARAM dz = span[0].dz;
24305   int dzpix = span[0].dzpix;
25   int drinc, dginc, dbinc, dainc, dzinc, dsinc, dtinc, dwinc;
26   int xinc = flip ? 1 : -1;
306#if defined(FLIP)
307   int dzinc = dz.w;
308#else
309   int dzinc = -dz.w;
310#endif
311#else
312   int sz = 0, dzpix = 0;
27313
28   calculate_clamp_diffs(tex_tile->num);
314   if (other_modes.z_source_sel)
315   {
316      sz = (((UINT32)primitive_z) << 3) & 0x3ffff;
317      dzpix = primitive_delta_z;
318   }
319#endif
29320
30321   clipx1 = clip.xh / 4;
31322   clipx2 = clip.xl / 4;
32323   clipy1 = clip.yh / 4;
33324   clipy2 = clip.yl / 4;
34325
35   if (texture && !other_modes.tex_lod_en)
326#if defined(TEXTURE)
327   if (!other_modes.tex_lod_en)
36328   {
37329      tilenum = prim_tile;
38330      tex_tile = &tile[tilenum];
39331   }
40
41   if (other_modes.tex_lod_en) // Used by World Driver Championship
332   else
42333   {
43      disable_lod = 1;
334      disable_lod = 1; // Used by World Driver Championship
44335   }
336#endif
45337
46   drinc = flip ? (dr.w) : -dr.w;
47   dginc = flip ? (dg.w) : -dg.w;
48   dbinc = flip ? (db.w) : -db.w;
49   dainc = flip ? (da.w) : -da.w;
50   dzinc = flip ? (dz.w) : -dz.w;
51   dsinc = flip ? (ds.w) : -ds.w;
52   dtinc = flip ? (dt.w) : -dt.w;
53   dwinc = flip ? (dw.w) : -dw.w;
54
55338   if (start < clipy1)
56339   {
57340      start = clipy1;
r6714r6715
69352      end = clipy2 - 1;
70353   }
71354
72   set_shade_for_tris(shade); // Needed by backgrounds in Top Gear Rally 1
355#if !defined(SHADE)
356   shade_color.c = prim_color.c;
357#endif
73358
74359   for (i = start; i <= end; i++)
75360   {
76361      int xstart = span[i].lx;
77362      int xend = span[i].rx;
78      SPAN_PARAM r;
79      SPAN_PARAM g;
80      SPAN_PARAM b;
81      SPAN_PARAM a;
82      SPAN_PARAM z = span[i].z;
83      SPAN_PARAM s = span[i].s;
84      SPAN_PARAM t = span[i].t;
85      SPAN_PARAM w = span[i].w;
86363
87364      int x;
88365
89366      int fb_index = fb_width * i;
90367      int length;
91368
92      if (shade)
93      {
94         r = span[i].r;
95         g = span[i].g;
96         b = span[i].b;
97         a = span[i].a;
98      }
369#if defined(SHADE)
370      SPAN_PARAM r = span[i].r;
371      SPAN_PARAM g = span[i].g;
372      SPAN_PARAM b = span[i].b;
373      SPAN_PARAM a = span[i].a;
374#endif
375#if defined(TEXTURE)
376      SPAN_PARAM s = span[i].s;
377      SPAN_PARAM t = span[i].t;
378      SPAN_PARAM w = span[i].w;
379#endif
380#if defined(ZBUF)
381      SPAN_PARAM z = span[i].z;
382#endif
99383
100384      x = xend;
101385
102      length = flip ? (xstart - xend) : (xend - xstart); //Moogly
386#if defined(FLIP)
387      length = (xstart - xend);
388#else
389      length = (xend - xstart);
390#endif
103391
104392      for (j = 0; j <= length; j++)
105393      {
106         int sr = 0, sg = 0, sb = 0, sa = 0;
394#if defined(SHADE)
395         int sr = r.h.h;
396         int sg = g.h.h;
397         int sb = b.h.h;
398         int sa = a.h.h;
399#endif
400#if defined(TEXTURE)
107401         int ss = s.h.h;
108402         int st = t.h.h;
109403         int sw = w.h.h;
404         int sss = 0, sst = 0;
405#endif
406#if defined(ZBUF)
110407         int sz = z.w >> 13;
111         int sss = 0, sst = 0;
408#endif
112409         COLOR c1, c2;
113         if (shade)
114         {
115            sr = r.h.h;
116            sg = g.h.h;
117            sb = b.h.h;
118            sa = a.h.h;
119         }
120410         c1.c = 0;
121411         c2.c = 0;
412
413#if defined(ZBUF)
122414         if (other_modes.z_source_sel)
123415         {
124416            sz = (((UINT32)primitive_z) << 3) & 0x3ffff;
125417            dzpix = primitive_delta_z;
126418         }
419#endif
127420
128
129421         if (x >= clipx1 && x < clipx2)
130422         {
423#if defined(ZCOMPARE)
131424            int z_compare_result = 1;
425#endif
132426
133427            curpixel_cvg=span[i].cvg[x];
134428
135            if (curpixel_cvg > 8)
136            {
137               stricterror("render_spans_16: cvg of current pixel is %d", curpixel_cvg);
138            }
139
140429            if (curpixel_cvg)
141430            {
142431               int curpixel = fb_index + x;
143432               UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
433               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
434#if defined(ZUPDATE) || defined(ZCOMPARE)
144435               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
145               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
146436               UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
437#endif
147438
439#if defined(TEXTURE)
148440               if (other_modes.persp_tex_en)
149441               {
150442                  tcdiv(ss, st, sw, &sss, &sst);
r6714r6715
154446                  sss = ss;
155447                  sst = st;
156448               }
449#endif
157450
158               if (shade)
159               {
160                  if (sr > 0xff) sr = 0xff;
161                  if (sg > 0xff) sg = 0xff;
162                  if (sb > 0xff) sb = 0xff;
163                  if (sa > 0xff) sa = 0xff;
164                  if (sr < 0) sr = 0;
165                  if (sg < 0) sg = 0;
166                  if (sb < 0) sb = 0;
167                  if (sa < 0) sa = 0;
168                  shade_color.i.r = sr;
169                  shade_color.i.g = sg;
170                  shade_color.i.b = sb;
171                  shade_color.i.a = sa;
172               }
451#if defined(SHADE)
452               if (sr > 0xff) sr = 0xff;
453               if (sg > 0xff) sg = 0xff;
454               if (sb > 0xff) sb = 0xff;
455               if (sa > 0xff) sa = 0xff;
456               if (sr < 0) sr = 0;
457               if (sg < 0) sg = 0;
458               if (sb < 0) sb = 0;
459               if (sa < 0) sa = 0;
460               shade_color.i.r = sr;
461               shade_color.i.g = sg;
462               shade_color.i.b = sb;
463               shade_color.i.a = sa;
464#endif
173465
174               if (texture)
175               {
176                  TEXTURE_PIPELINE(&texel0_color, sss, sst, tex_tile);
177               }
466#if defined(TEXTURE)
467               TEXTURE_PIPELINE(&texel0_color, sss, sst, tex_tile);
468#endif
178469
179               c1 = COLOR_COMBINER1(machine);
470               COLOR_COMBINER1(&c1);
180471
181               if ((zbuffer || other_modes.z_source_sel) && other_modes.z_compare_en)
472#if defined(ZCOMPARE)
473#if !defined(ZBUF)
474               if (other_modes.z_source_sel)
475#endif
182476               {
183477                  z_compare_result = z_compare(fbcur, hbcur, zbcur, zhbcur, sz, dzpix);
184478               }
185479
186480               if(z_compare_result)
481#endif
187482               {
188483                  int rendered = 0;
189484                  int dith = 0;
r6714r6715
196491                     dith = bayer_matrix[(((i) & 3) << 2) + ((x ^ WORD_ADDR_XOR) & 3)];
197492                  }
198493
199                  rendered = BLENDER1_16(machine, fbcur, hbcur, c1, dith);
494                  rendered = BLENDER1_16(fbcur, hbcur, c1, dith);
200495
201                  if (other_modes.z_update_en && rendered)
496#if defined(ZUPDATE)
497                  if (rendered)
202498                  {
203499                     z_store(zbcur, zhbcur, sz, dzpix);
204500                  }
501#endif
205502               }
206503            }
207504         }
208505
209         if (shade)
210         {
211            r.w += drinc;
212            g.w += dginc;
213            b.w += dbinc;
214            a.w += dainc;
215         }
216         z.w += dzinc;
506#if defined(SHADE)
507         r.w += drinc;
508         g.w += dginc;
509         b.w += dbinc;
510         a.w += dainc;
511#endif
512#if defined(TEXTURE)
217513         s.w += dsinc;
218514         t.w += dtinc;
219515         w.w += dwinc;
516#endif
517#if defined(ZBUF)
518         z.w += dzinc;
519#endif
220520
221         x += xinc;
521#if defined(FLIP)
522         x++;
523#else
524         x--;
525#endif
222526      }
223527   }
224528}
225529
226static void render_spans_16_c2(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip)
530#if defined(SHADE)
531   #if defined(TEXTURE)
532      #if defined(ZBUF)
533         #if defined(FLIP)
534            #if defined(ZUPDATE)
535               #if defined(ZCOMPARE)
536               static void render_spans_16_c2_s_t_z_f_zc_zu(int start, int end, TILE* tex_tile)
537               #else
538               static void render_spans_16_c2_s_t_z_f_nzc_zu(int start, int end, TILE* tex_tile)
539               #endif
540            #else
541               #if defined(ZCOMPARE)
542               static void render_spans_16_c2_s_t_z_f_zc(int start, int end, TILE* tex_tile)
543               #else
544               static void render_spans_16_c2_s_t_z_f_nzc(int start, int end, TILE* tex_tile)
545               #endif
546            #endif
547         #else
548            #if defined(ZUPDATE)
549               #if defined(ZCOMPARE)
550               static void render_spans_16_c2_s_t_z_nf_zc_zu(int start, int end, TILE* tex_tile)
551               #else
552               static void render_spans_16_c2_s_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile)
553               #endif
554            #else
555               #if defined(ZCOMPARE)
556               static void render_spans_16_c2_s_t_z_nf_zc(int start, int end, TILE* tex_tile)
557               #else
558               static void render_spans_16_c2_s_t_z_nf_nzc(int start, int end, TILE* tex_tile)
559               #endif
560            #endif
561         #endif
562      #else
563         #if defined(FLIP)
564            #if defined(ZUPDATE)
565               #if defined(ZCOMPARE)
566               static void render_spans_16_c2_s_t_nz_f_zc_zu(int start, int end, TILE* tex_tile)
567               #else
568               static void render_spans_16_c2_s_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile)
569               #endif
570            #else
571               #if defined(ZCOMPARE)
572               static void render_spans_16_c2_s_t_nz_f_zc(int start, int end, TILE* tex_tile)
573               #else
574               static void render_spans_16_c2_s_t_nz_f_nzc(int start, int end, TILE* tex_tile)
575               #endif
576            #endif
577         #else
578            #if defined(ZUPDATE)
579               #if defined(ZCOMPARE)
580               static void render_spans_16_c2_s_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile)
581               #else
582               static void render_spans_16_c2_s_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile)
583               #endif
584            #else
585               #if defined(ZCOMPARE)
586               static void render_spans_16_c2_s_t_nz_nf_zc(int start, int end, TILE* tex_tile)
587               #else
588               static void render_spans_16_c2_s_t_nz_nf_nzc(int start, int end, TILE* tex_tile)
589               #endif
590            #endif
591         #endif
592      #endif
593   #else
594      #if defined(ZBUF)
595         #if defined(FLIP)
596            #if defined(ZUPDATE)
597               #if defined(ZCOMPARE)
598               static void render_spans_16_c2_s_nt_z_f_zc_zu(int start, int end, TILE* tex_tile)
599               #else
600               static void render_spans_16_c2_s_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile)
601               #endif
602            #else
603               #if defined(ZCOMPARE)
604               static void render_spans_16_c2_s_nt_z_f_zc(int start, int end, TILE* tex_tile)
605               #else
606               static void render_spans_16_c2_s_nt_z_f_nzc(int start, int end, TILE* tex_tile)
607               #endif
608            #endif
609         #else
610            #if defined(ZUPDATE)
611               #if defined(ZCOMPARE)
612               static void render_spans_16_c2_s_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile)
613               #else
614               static void render_spans_16_c2_s_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile)
615               #endif
616            #else
617               #if defined(ZCOMPARE)
618               static void render_spans_16_c2_s_nt_z_nf_zc(int start, int end, TILE* tex_tile)
619               #else
620               static void render_spans_16_c2_s_nt_z_nf_nzc(int start, int end, TILE* tex_tile)
621               #endif
622            #endif
623         #endif
624      #else
625         #if defined(FLIP)
626            #if defined(ZUPDATE)
627               #if defined(ZCOMPARE)
628               static void render_spans_16_c2_s_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile)
629               #else
630               static void render_spans_16_c2_s_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile)
631               #endif
632            #else
633               #if defined(ZCOMPARE)
634               static void render_spans_16_c2_s_nt_nz_f_zc(int start, int end, TILE* tex_tile)
635               #else
636               static void render_spans_16_c2_s_nt_nz_f_nzc(int start, int end, TILE* tex_tile)
637               #endif
638            #endif
639         #else
640            #if defined(ZUPDATE)
641               #if defined(ZCOMPARE)
642               static void render_spans_16_c2_s_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile)
643               #else
644               static void render_spans_16_c2_s_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile)
645               #endif
646            #else
647               #if defined(ZCOMPARE)
648               static void render_spans_16_c2_s_nt_nz_nf_zc(int start, int end, TILE* tex_tile)
649               #else
650               static void render_spans_16_c2_s_nt_nz_nf_nzc(int start, int end, TILE* tex_tile)
651               #endif
652            #endif
653         #endif
654      #endif
655   #endif
656#else
657   #if defined(TEXTURE)
658      #if defined(ZBUF)
659         #if defined(FLIP)
660            #if defined(ZUPDATE)
661               #if defined(ZCOMPARE)
662               static void render_spans_16_c2_ns_t_z_f_zc_zu(int start, int end, TILE* tex_tile)
663               #else
664               static void render_spans_16_c2_ns_t_z_f_nzc_zu(int start, int end, TILE* tex_tile)
665               #endif
666            #else
667               #if defined(ZCOMPARE)
668               static void render_spans_16_c2_ns_t_z_f_zc(int start, int end, TILE* tex_tile)
669               #else
670               static void render_spans_16_c2_ns_t_z_f_nzc(int start, int end, TILE* tex_tile)
671               #endif
672            #endif
673         #else
674            #if defined(ZUPDATE)
675               #if defined(ZCOMPARE)
676               static void render_spans_16_c2_ns_t_z_nf_zc_zu(int start, int end, TILE* tex_tile)
677               #else
678               static void render_spans_16_c2_ns_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile)
679               #endif
680            #else
681               #if defined(ZCOMPARE)
682               static void render_spans_16_c2_ns_t_z_nf_zc(int start, int end, TILE* tex_tile)
683               #else
684               static void render_spans_16_c2_ns_t_z_nf_nzc(int start, int end, TILE* tex_tile)
685               #endif
686            #endif
687         #endif
688      #else
689         #if defined(FLIP)
690            #if defined(ZUPDATE)
691               #if defined(ZCOMPARE)
692               static void render_spans_16_c2_ns_t_nz_f_zc_zu(int start, int end, TILE* tex_tile)
693               #else
694               static void render_spans_16_c2_ns_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile)
695               #endif
696            #else
697               #if defined(ZCOMPARE)
698               static void render_spans_16_c2_ns_t_nz_f_zc(int start, int end, TILE* tex_tile)
699               #else
700               static void render_spans_16_c2_ns_t_nz_f_nzc(int start, int end, TILE* tex_tile)
701               #endif
702            #endif
703         #else
704            #if defined(ZUPDATE)
705               #if defined(ZCOMPARE)
706               static void render_spans_16_c2_ns_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile)
707               #else
708               static void render_spans_16_c2_ns_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile)
709               #endif
710            #else
711               #if defined(ZCOMPARE)
712               static void render_spans_16_c2_ns_t_nz_nf_zc(int start, int end, TILE* tex_tile)
713               #else
714               static void render_spans_16_c2_ns_t_nz_nf_nzc(int start, int end, TILE* tex_tile)
715               #endif
716            #endif
717         #endif
718      #endif
719   #else
720      #if defined(ZBUF)
721         #if defined(FLIP)
722            #if defined(ZUPDATE)
723               #if defined(ZCOMPARE)
724               static void render_spans_16_c2_ns_nt_z_f_zc_zu(int start, int end, TILE* tex_tile)
725               #else
726               static void render_spans_16_c2_ns_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile)
727               #endif
728            #else
729               #if defined(ZCOMPARE)
730               static void render_spans_16_c2_ns_nt_z_f_zc(int start, int end, TILE* tex_tile)
731               #else
732               static void render_spans_16_c2_ns_nt_z_f_nzc(int start, int end, TILE* tex_tile)
733               #endif
734            #endif
735         #else
736            #if defined(ZUPDATE)
737               #if defined(ZCOMPARE)
738               static void render_spans_16_c2_ns_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile)
739               #else
740               static void render_spans_16_c2_ns_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile)
741               #endif
742            #else
743               #if defined(ZCOMPARE)
744               static void render_spans_16_c2_ns_nt_z_nf_zc(int start, int end, TILE* tex_tile)
745               #else
746               static void render_spans_16_c2_ns_nt_z_nf_nzc(int start, int end, TILE* tex_tile)
747               #endif
748            #endif
749         #endif
750      #else
751         #if defined(FLIP)
752            #if defined(ZUPDATE)
753               #if defined(ZCOMPARE)
754               static void render_spans_16_c2_ns_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile)
755               #else
756               static void render_spans_16_c2_ns_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile)
757               #endif
758            #else
759               #if defined(ZCOMPARE)
760               static void render_spans_16_c2_ns_nt_nz_f_zc(int start, int end, TILE* tex_tile)
761               #else
762               static void render_spans_16_c2_ns_nt_nz_f_nzc(int start, int end, TILE* tex_tile)
763               #endif
764            #endif
765         #else
766            #if defined(ZUPDATE)
767               #if defined(ZCOMPARE)
768               static void render_spans_16_c2_ns_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile)
769               #else
770               static void render_spans_16_c2_ns_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile)
771               #endif
772            #else
773               #if defined(ZCOMPARE)
774               static void render_spans_16_c2_ns_nt_nz_nf_zc(int start, int end, TILE* tex_tile)
775               #else
776               static void render_spans_16_c2_ns_nt_nz_nf_nzc(int start, int end, TILE* tex_tile)
777               #endif
778            #endif
779         #endif
780      #endif
781   #endif
782#endif
227783{
228784   UINT16 *fb = (UINT16*)&rdram[fb_address / 4];
785   UINT8 *hb = &hidden_bits[fb_address >> 1];
786#if defined(ZUPDATE) || defined(ZCOMPARE)
229787   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
230   UINT8 *hb = &hidden_bits[fb_address >> 1];
231788   UINT8 *zhb = &hidden_bits[zb_address >> 1];
789#endif
232790
233791   int i, j;
234792
235793   int clipx1, clipx2, clipy1, clipy2;
236794
795#if defined(SHADE)
796   SPAN_PARAM dr = span[0].dr;
797   SPAN_PARAM dg = span[0].dg;
798   SPAN_PARAM db = span[0].db;
799   SPAN_PARAM da = span[0].da;
800#if defined(FLIP)
801   int drinc = dr.w;
802   int dginc = dg.w;
803   int dbinc = db.w;
804   int dainc = da.w;
805#else
806   int drinc = -dr.w;
807   int dginc = -dg.w;
808   int dbinc = -db.w;
809   int dainc = -da.w;
810#endif
811#endif
812
813#if defined(TEXTURE)
237814   UINT32 prim_tile = tex_tile->num;
238815   UINT32 tilenum2 = 0;
239816   TILE *tex_tile2 = NULL;
r6714r6715
245822   UINT32 magnify = 0;
246823   UINT32 distant = 0;
247824
248   SPAN_PARAM dr = span[0].dr;
249   SPAN_PARAM dg = span[0].dg;
250   SPAN_PARAM db = span[0].db;
251   SPAN_PARAM da = span[0].da;
252   SPAN_PARAM dz = span[0].dz;
825   int nexts, nextt, nextsw;
826   int lodclamp = 0;
827
253828   SPAN_PARAM ds = span[0].ds;
254829   SPAN_PARAM dt = span[0].dt;
255830   SPAN_PARAM dw = span[0].dw;
831#if defined(FLIP)
832   int dsinc = ds.w;
833   int dtinc = dt.w;
834   int dwinc = dw.w;
835#else
836   int dsinc = -ds.w;
837   int dtinc = -dt.w;
838   int dwinc = -dw.w;
839#endif
840#endif
841
842#if defined(ZBUF)
843   SPAN_PARAM dz = span[0].dz;
256844   int dzpix = span[0].dzpix;
257   int drinc, dginc, dbinc, dainc, dzinc, dsinc, dtinc, dwinc;
258   int xinc = flip ? 1 : -1;
845#if defined(FLIP)
846   int dzinc = dz.w;
847#else
848   int dzinc = -dz.w;
849#endif
850#else
851   int sz = 0, dzpix = 0;
259852
260   int nexts, nextt, nextsw;
261   int lodclamp = 0;
853   if (other_modes.z_source_sel)
854   {
855      sz = (((UINT32)primitive_z) << 3) & 0x3ffff;
856      dzpix = primitive_delta_z;
857   }
858#endif
262859
860#if defined(TEXTURE)
263861   calculate_clamp_diffs(tex_tile->num);
264862
265   clipx1 = clip.xh / 4;
266   clipx2 = clip.xl / 4;
267   clipy1 = clip.yh / 4;
268   clipy2 = clip.yl / 4;
269
270   if (texture && !other_modes.tex_lod_en)
863   if (!other_modes.tex_lod_en)
271864   {
272865      tilenum = prim_tile;
273866      tex_tile = &tile[tilenum];
274867      tilenum2 = (prim_tile + 1) & 7;
275868      tex_tile2 = &tile[tilenum2];
276869   }
870#endif
277871
278   drinc = flip ? (dr.w) : -dr.w;
279   dginc = flip ? (dg.w) : -dg.w;
280   dbinc = flip ? (db.w) : -db.w;
281   dainc = flip ? (da.w) : -da.w;
282   dzinc = flip ? (dz.w) : -dz.w;
283   dsinc = flip ? (ds.w) : -ds.w;
284   dtinc = flip ? (dt.w) : -dt.w;
285   dwinc = flip ? (dw.w) : -dw.w;
872   clipx1 = clip.xh / 4;
873   clipx2 = clip.xl / 4;
874   clipy1 = clip.yh / 4;
875   clipy2 = clip.yl / 4;
286876
287877   if (start < clipy1)
288878   {
r6714r6715
301891      end = clipy2 - 1;
302892   }
303893
304   set_shade_for_tris(shade); // Needed by backgrounds in Top Gear Rally 1
894#if !defined(SHADE)
895   shade_color.c = prim_color.c;
896#endif
305897
306898   for (i = start; i <= end; i++)
307899   {
308900      int xstart = span[i].lx;
309901      int xend = span[i].rx;
310      SPAN_PARAM r;
311      SPAN_PARAM g;
312      SPAN_PARAM b;
313      SPAN_PARAM a;
314      SPAN_PARAM z = span[i].z;
902#if defined(SHADE)
903      SPAN_PARAM r = span[i].r;
904      SPAN_PARAM g = span[i].g;
905      SPAN_PARAM b = span[i].b;
906      SPAN_PARAM a = span[i].a;
907#endif
908#if defined(TEXTURE)
315909      SPAN_PARAM s = span[i].s;
316910      SPAN_PARAM t = span[i].t;
317911      SPAN_PARAM w = span[i].w;
912#endif
913#if defined(ZBUF)
914      SPAN_PARAM z = span[i].z;
915#endif
318916
319917      int x;
320918
321919      int fb_index = fb_width * i;
322920      int length;
323921
324      if (shade)
325      {
326         r = span[i].r;
327         g = span[i].g;
328         b = span[i].b;
329         a = span[i].a;
330      }
331
332922      x = xend;
333923
334      length = flip ? (xstart - xend) : (xend - xstart); //Moogly
924#if defined(FLIP)
925      length = (xstart - xend);
926#else
927      length = (xend - xstart);
928#endif
335929
336930      for (j = 0; j <= length; j++)
337931      {
338         int sr = 0, sg = 0, sb = 0, sa = 0;
932#if defined(SHADE)
933         int sr = r.h.h;
934         int sg = g.h.h;
935         int sb = b.h.h;
936         int sa = a.h.h;
937#endif
938#if defined(TEXTURE)
339939         int ss = s.h.h;
340940         int st = t.h.h;
341941         int sw = w.h.h;
942         int sss = 0, sst = 0;
943#endif
944#if defined(ZBUF)
342945         int sz = z.w >> 13;
343         int sss = 0, sst = 0;
946#endif
344947         COLOR c1, c2;
345         if (shade)
346         {
347            sr = r.h.h;
348            sg = g.h.h;
349            sb = b.h.h;
350            sa = a.h.h;
351         }
352         c1.c = 0;
353         c2.c = 0;
948         //c1.c = 0;
949         //c2.c = 0;
950
951#if defined(ZBUF)
354952         if (other_modes.z_source_sel)
355953         {
356954            sz = (((UINT32)primitive_z) << 3) & 0x3ffff;
357955            dzpix = primitive_delta_z;
358956         }
957#endif
359958
360
361959         if (x >= clipx1 && x < clipx2)
362960         {
961#if defined(ZCOMPARE)
363962            int z_compare_result = 1;
963#endif
364964
365965            curpixel_cvg=span[i].cvg[x];
366966
367            if (curpixel_cvg > 8)
368            {
369               stricterror("render_spans_16: cvg of current pixel is %d", curpixel_cvg);
370            }
371
372967            if (curpixel_cvg)
373968            {
374969               int curpixel = fb_index + x;
375970               UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
971               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
972#if defined(ZUPDATE) || defined(ZCOMPARE)
376973               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
377               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
378974               UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
975#endif
379976
977#if defined(SHADE)
978               if (sr > 0xff) sr = 0xff;
979               if (sg > 0xff) sg = 0xff;
980               if (sb > 0xff) sb = 0xff;
981               if (sa > 0xff) sa = 0xff;
982               if (sr < 0) sr = 0;
983               if (sg < 0) sg = 0;
984               if (sb < 0) sb = 0;
985               if (sa < 0) sa = 0;
986               shade_color.i.r = sr;
987               shade_color.i.g = sg;
988               shade_color.i.b = sb;
989               shade_color.i.a = sa;
990#endif
991
992#if defined(TEXTURE)
380993               if (other_modes.persp_tex_en)
381994               {
382995                  tcdiv(ss, st, sw, &sss, &sst);
r6714r6715
4931106                  }
4941107               }
4951108
496               if (shade)
497               {
498                  if (sr > 0xff) sr = 0xff;
499                  if (sg > 0xff) sg = 0xff;
500                  if (sb > 0xff) sb = 0xff;
501                  if (sa > 0xff) sa = 0xff;
502                  if (sr < 0) sr = 0;
503                  if (sg < 0) sg = 0;
504                  if (sb < 0) sb = 0;
505                  if (sa < 0) sa = 0;
506                  shade_color.i.r = sr;
507                  shade_color.i.g = sg;
508                  shade_color.i.b = sb;
509                  shade_color.i.a = sa;
510               }
1109               TEXTURE_PIPELINE(&texel0_color, sss, sst, tex_tile);
1110               TEXTURE_PIPELINE(&texel1_color, sss, sst, tex_tile2);
1111#endif
5111112
512               if (texture)
513               {
514                  TEXTURE_PIPELINE(&texel0_color, sss, sst, tex_tile);
515                  TEXTURE_PIPELINE(&texel1_color, sss, sst, tex_tile2);
516               }
1113               COLOR_COMBINER2_C0(&c1);
1114               COLOR_COMBINER2_C1(&c2);
5171115
518               c1 = COLOR_COMBINER2_C0(machine);
519               c2 = COLOR_COMBINER2_C1(machine);
520
521               if ((zbuffer || other_modes.z_source_sel) && other_modes.z_compare_en)
1116#if defined(ZCOMPARE)
1117#if !defined(ZBUF)
1118               if (other_modes.z_source_sel)
1119#endif
5221120               {
5231121                  z_compare_result = z_compare(fbcur, hbcur, zbcur, zhbcur, sz, dzpix);
5241122               }
5251123
5261124               if(z_compare_result)
1125#endif
5271126               {
5281127                  int rendered = 0;
5291128                  int dith = 0;
r6714r6715
5361135                     dith = bayer_matrix[(((i) & 3) << 2) + ((x ^ WORD_ADDR_XOR) & 3)];
5371136                  }
5381137
539                  rendered = BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith);
1138                  rendered = BLENDER2_16(fbcur, hbcur, c1, c2, dith);
5401139
541                  if (other_modes.z_update_en && rendered)
1140#if defined(ZUPDATE)
1141                  if (rendered)
5421142                  {
5431143                     z_store(zbcur, zhbcur, sz, dzpix);
5441144                  }
1145#endif
5451146               }
5461147            }
5471148         }
5481149
549         if (shade)
550         {
551            r.w += drinc;
552            g.w += dginc;
553            b.w += dbinc;
554            a.w += dainc;
555         }
556         z.w += dzinc;
1150#if defined(SHADE)
1151         r.w += drinc;
1152         g.w += dginc;
1153         b.w += dbinc;
1154         a.w += dainc;
1155#endif
1156#if defined(TEXTURE)
5571157         s.w += dsinc;
5581158         t.w += dtinc;
5591159         w.w += dwinc;
1160#endif
1161#if defined(ZBUF)
1162         z.w += dzinc;
1163#endif
5601164
561         x += xinc;
1165#if defined(FLIP)
1166         x++;
1167#else
1168         x--;
1169#endif
5621170      }
5631171   }
5641172}
src/mame/video/rdpspn16.h
r6714r6715
1static void render_spans_16_c1(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip);
2static void render_spans_16_c2(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip);
1INLINE void render_spans_16_c1_ns_nt_nz_nf_nzc(int start, int end, TILE* tex_tile);
2INLINE void render_spans_16_c2_ns_nt_nz_nf_nzc(int start, int end, TILE* tex_tile);
3INLINE void render_spans_16_c1_ns_nt_z_nf_nzc(int start, int end, TILE* tex_tile);
4INLINE void render_spans_16_c2_ns_nt_z_nf_nzc(int start, int end, TILE* tex_tile);
5INLINE void render_spans_16_c1_ns_t_nz_nf_nzc(int start, int end, TILE* tex_tile);
6INLINE void render_spans_16_c2_ns_t_nz_nf_nzc(int start, int end, TILE* tex_tile);
7INLINE void render_spans_16_c1_ns_t_z_nf_nzc(int start, int end, TILE* tex_tile);
8INLINE void render_spans_16_c2_ns_t_z_nf_nzc(int start, int end, TILE* tex_tile);
9INLINE void render_spans_16_c1_s_nt_nz_nf_nzc(int start, int end, TILE* tex_tile);
10INLINE void render_spans_16_c2_s_nt_nz_nf_nzc(int start, int end, TILE* tex_tile);
11INLINE void render_spans_16_c1_s_nt_z_nf_nzc(int start, int end, TILE* tex_tile);
12INLINE void render_spans_16_c2_s_nt_z_nf_nzc(int start, int end, TILE* tex_tile);
13INLINE void render_spans_16_c1_s_t_nz_nf_nzc(int start, int end, TILE* tex_tile);
14INLINE void render_spans_16_c2_s_t_nz_nf_nzc(int start, int end, TILE* tex_tile);
15INLINE void render_spans_16_c1_s_t_z_nf_nzc(int start, int end, TILE* tex_tile);
16INLINE void render_spans_16_c2_s_t_z_nf_nzc(int start, int end, TILE* tex_tile);
17INLINE void render_spans_16_c1_ns_nt_nz_f_nzc(int start, int end, TILE* tex_tile);
18INLINE void render_spans_16_c2_ns_nt_nz_f_nzc(int start, int end, TILE* tex_tile);
19INLINE void render_spans_16_c1_ns_nt_z_f_nzc(int start, int end, TILE* tex_tile);
20INLINE void render_spans_16_c2_ns_nt_z_f_nzc(int start, int end, TILE* tex_tile);
21INLINE void render_spans_16_c1_ns_t_nz_f_nzc(int start, int end, TILE* tex_tile);
22INLINE void render_spans_16_c2_ns_t_nz_f_nzc(int start, int end, TILE* tex_tile);
23INLINE void render_spans_16_c1_ns_t_z_f_nzc(int start, int end, TILE* tex_tile);
24INLINE void render_spans_16_c2_ns_t_z_f_nzc(int start, int end, TILE* tex_tile);
25INLINE void render_spans_16_c1_s_nt_nz_f_nzc(int start, int end, TILE* tex_tile);
26INLINE void render_spans_16_c2_s_nt_nz_f_nzc(int start, int end, TILE* tex_tile);
27INLINE void render_spans_16_c1_s_nt_z_f_nzc(int start, int end, TILE* tex_tile);
28INLINE void render_spans_16_c2_s_nt_z_f_nzc(int start, int end, TILE* tex_tile);
29INLINE void render_spans_16_c1_s_t_nz_f_nzc(int start, int end, TILE* tex_tile);
30INLINE void render_spans_16_c2_s_t_nz_f_nzc(int start, int end, TILE* tex_tile);
31INLINE void render_spans_16_c1_s_t_z_f_nzc(int start, int end, TILE* tex_tile);
32INLINE void render_spans_16_c2_s_t_z_f_nzc(int start, int end, TILE* tex_tile);
333
4static void (*rdp_render_spans_16_func[4])(running_machine*, int, int, TILE*, int, int, int, int) =
34INLINE void render_spans_16_c1_ns_nt_nz_nf_zc(int start, int end, TILE* tex_tile);
35INLINE void render_spans_16_c2_ns_nt_nz_nf_zc(int start, int end, TILE* tex_tile);
36INLINE void render_spans_16_c1_ns_nt_z_nf_zc(int start, int end, TILE* tex_tile);
37INLINE void render_spans_16_c2_ns_nt_z_nf_zc(int start, int end, TILE* tex_tile);
38INLINE void render_spans_16_c1_ns_t_nz_nf_zc(int start, int end, TILE* tex_tile);
39INLINE void render_spans_16_c2_ns_t_nz_nf_zc(int start, int end, TILE* tex_tile);
40INLINE void render_spans_16_c1_ns_t_z_nf_zc(int start, int end, TILE* tex_tile);
41INLINE void render_spans_16_c2_ns_t_z_nf_zc(int start, int end, TILE* tex_tile);
42INLINE void render_spans_16_c1_s_nt_nz_nf_zc(int start, int end, TILE* tex_tile);
43INLINE void render_spans_16_c2_s_nt_nz_nf_zc(int start, int end, TILE* tex_tile);
44INLINE void render_spans_16_c1_s_nt_z_nf_zc(int start, int end, TILE* tex_tile);
45INLINE void render_spans_16_c2_s_nt_z_nf_zc(int start, int end, TILE* tex_tile);
46INLINE void render_spans_16_c1_s_t_nz_nf_zc(int start, int end, TILE* tex_tile);
47INLINE void render_spans_16_c2_s_t_nz_nf_zc(int start, int end, TILE* tex_tile);
48INLINE void render_spans_16_c1_s_t_z_nf_zc(int start, int end, TILE* tex_tile);
49INLINE void render_spans_16_c2_s_t_z_nf_zc(int start, int end, TILE* tex_tile);
50INLINE void render_spans_16_c1_ns_nt_nz_f_zc(int start, int end, TILE* tex_tile);
51INLINE void render_spans_16_c2_ns_nt_nz_f_zc(int start, int end, TILE* tex_tile);
52INLINE void render_spans_16_c1_ns_nt_z_f_zc(int start, int end, TILE* tex_tile);
53INLINE void render_spans_16_c2_ns_nt_z_f_zc(int start, int end, TILE* tex_tile);
54INLINE void render_spans_16_c1_ns_t_nz_f_zc(int start, int end, TILE* tex_tile);
55INLINE void render_spans_16_c2_ns_t_nz_f_zc(int start, int end, TILE* tex_tile);
56INLINE void render_spans_16_c1_ns_t_z_f_zc(int start, int end, TILE* tex_tile);
57INLINE void render_spans_16_c2_ns_t_z_f_zc(int start, int end, TILE* tex_tile);
58INLINE void render_spans_16_c1_s_nt_nz_f_zc(int start, int end, TILE* tex_tile);
59INLINE void render_spans_16_c2_s_nt_nz_f_zc(int start, int end, TILE* tex_tile);
60INLINE void render_spans_16_c1_s_nt_z_f_zc(int start, int end, TILE* tex_tile);
61INLINE void render_spans_16_c2_s_nt_z_f_zc(int start, int end, TILE* tex_tile);
62INLINE void render_spans_16_c1_s_t_nz_f_zc(int start, int end, TILE* tex_tile);
63INLINE void render_spans_16_c2_s_t_nz_f_zc(int start, int end, TILE* tex_tile);
64INLINE void render_spans_16_c1_s_t_z_f_zc(int start, int end, TILE* tex_tile);
65INLINE void render_spans_16_c2_s_t_z_f_zc(int start, int end, TILE* tex_tile);
66
67INLINE void render_spans_16_c1_ns_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile);
68INLINE void render_spans_16_c2_ns_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile);
69INLINE void render_spans_16_c1_ns_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile);
70INLINE void render_spans_16_c2_ns_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile);
71INLINE void render_spans_16_c1_ns_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile);
72INLINE void render_spans_16_c2_ns_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile);
73INLINE void render_spans_16_c1_ns_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile);
74INLINE void render_spans_16_c2_ns_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile);
75INLINE void render_spans_16_c1_s_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile);
76INLINE void render_spans_16_c2_s_nt_nz_nf_nzc_zu(int start, int end, TILE* tex_tile);
77INLINE void render_spans_16_c1_s_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile);
78INLINE void render_spans_16_c2_s_nt_z_nf_nzc_zu(int start, int end, TILE* tex_tile);
79INLINE void render_spans_16_c1_s_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile);
80INLINE void render_spans_16_c2_s_t_nz_nf_nzc_zu(int start, int end, TILE* tex_tile);
81INLINE void render_spans_16_c1_s_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile);
82INLINE void render_spans_16_c2_s_t_z_nf_nzc_zu(int start, int end, TILE* tex_tile);
83INLINE void render_spans_16_c1_ns_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile);
84INLINE void render_spans_16_c2_ns_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile);
85INLINE void render_spans_16_c1_ns_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile);
86INLINE void render_spans_16_c2_ns_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile);
87INLINE void render_spans_16_c1_ns_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile);
88INLINE void render_spans_16_c2_ns_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile);
89INLINE void render_spans_16_c1_ns_t_z_f_nzc_zu(int start, int end, TILE* tex_tile);
90INLINE void render_spans_16_c2_ns_t_z_f_nzc_zu(int start, int end, TILE* tex_tile);
91INLINE void render_spans_16_c1_s_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile);
92INLINE void render_spans_16_c2_s_nt_nz_f_nzc_zu(int start, int end, TILE* tex_tile);
93INLINE void render_spans_16_c1_s_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile);
94INLINE void render_spans_16_c2_s_nt_z_f_nzc_zu(int start, int end, TILE* tex_tile);
95INLINE void render_spans_16_c1_s_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile);
96INLINE void render_spans_16_c2_s_t_nz_f_nzc_zu(int start, int end, TILE* tex_tile);
97INLINE void render_spans_16_c1_s_t_z_f_nzc_zu(int start, int end, TILE* tex_tile);
98INLINE void render_spans_16_c2_s_t_z_f_nzc_zu(int start, int end, TILE* tex_tile);
99
100INLINE void render_spans_16_c1_ns_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile);
101INLINE void render_spans_16_c2_ns_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile);
102INLINE void render_spans_16_c1_ns_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile);
103INLINE void render_spans_16_c2_ns_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile);
104INLINE void render_spans_16_c1_ns_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile);
105INLINE void render_spans_16_c2_ns_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile);
106INLINE void render_spans_16_c1_ns_t_z_nf_zc_zu(int start, int end, TILE* tex_tile);
107INLINE void render_spans_16_c2_ns_t_z_nf_zc_zu(int start, int end, TILE* tex_tile);
108INLINE void render_spans_16_c1_s_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile);
109INLINE void render_spans_16_c2_s_nt_nz_nf_zc_zu(int start, int end, TILE* tex_tile);
110INLINE void render_spans_16_c1_s_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile);
111INLINE void render_spans_16_c2_s_nt_z_nf_zc_zu(int start, int end, TILE* tex_tile);
112INLINE void render_spans_16_c1_s_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile);
113INLINE void render_spans_16_c2_s_t_nz_nf_zc_zu(int start, int end, TILE* tex_tile);
114INLINE void render_spans_16_c1_s_t_z_nf_zc_zu(int start, int end, TILE* tex_tile);
115INLINE void render_spans_16_c2_s_t_z_nf_zc_zu(int start, int end, TILE* tex_tile);
116INLINE void render_spans_16_c1_ns_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile);
117INLINE void render_spans_16_c2_ns_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile);
118INLINE void render_spans_16_c1_ns_nt_z_f_zc_zu(int start, int end, TILE* tex_tile);
119INLINE void render_spans_16_c2_ns_nt_z_f_zc_zu(int start, int end, TILE* tex_tile);
120INLINE void render_spans_16_c1_ns_t_nz_f_zc_zu(int start, int end, TILE* tex_tile);
121INLINE void render_spans_16_c2_ns_t_nz_f_zc_zu(int start, int end, TILE* tex_tile);
122INLINE void render_spans_16_c1_ns_t_z_f_zc_zu(int start, int end, TILE* tex_tile);
123INLINE void render_spans_16_c2_ns_t_z_f_zc_zu(int start, int end, TILE* tex_tile);
124INLINE void render_spans_16_c1_s_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile);
125INLINE void render_spans_16_c2_s_nt_nz_f_zc_zu(int start, int end, TILE* tex_tile);
126INLINE void render_spans_16_c1_s_nt_z_f_zc_zu(int start, int end, TILE* tex_tile);
127INLINE void render_spans_16_c2_s_nt_z_f_zc_zu(int start, int end, TILE* tex_tile);
128INLINE void render_spans_16_c1_s_t_nz_f_zc_zu(int start, int end, TILE* tex_tile);
129INLINE void render_spans_16_c2_s_t_nz_f_zc_zu(int start, int end, TILE* tex_tile);
130INLINE void render_spans_16_c1_s_t_z_f_zc_zu(int start, int end, TILE* tex_tile);
131INLINE void render_spans_16_c2_s_t_z_f_zc_zu(int start, int end, TILE* tex_tile);
132
133static void (*rdp_render_spans_16_func[128])(int, int, TILE*) =
5134{
6   render_spans_16_c1, render_spans_16_c2, render_spans_16_c1, render_spans_16_c1
135   render_spans_16_c1_ns_nt_nz_nf_nzc, render_spans_16_c2_ns_nt_nz_nf_nzc,
136   render_spans_16_c1_ns_nt_z_nf_nzc,    render_spans_16_c2_ns_nt_z_nf_nzc,
137   render_spans_16_c1_ns_t_nz_nf_nzc,    render_spans_16_c2_ns_t_nz_nf_nzc,
138   render_spans_16_c1_ns_t_z_nf_nzc,    render_spans_16_c2_ns_t_z_nf_nzc,
139   render_spans_16_c1_s_nt_nz_nf_nzc,    render_spans_16_c2_s_nt_nz_nf_nzc,
140   render_spans_16_c1_s_nt_z_nf_nzc,    render_spans_16_c2_s_nt_z_nf_nzc,
141   render_spans_16_c1_s_t_nz_nf_nzc,    render_spans_16_c2_s_t_nz_nf_nzc,
142   render_spans_16_c1_s_t_z_nf_nzc,    render_spans_16_c2_s_t_z_nf_nzc,
143   render_spans_16_c1_ns_nt_nz_f_nzc,    render_spans_16_c2_ns_nt_nz_f_nzc,
144   render_spans_16_c1_ns_nt_z_f_nzc,    render_spans_16_c2_ns_nt_z_f_nzc,
145   render_spans_16_c1_ns_t_nz_f_nzc,    render_spans_16_c2_ns_t_nz_f_nzc,
146   render_spans_16_c1_ns_t_z_f_nzc,    render_spans_16_c2_ns_t_z_f_nzc,
147   render_spans_16_c1_s_nt_nz_f_nzc,    render_spans_16_c2_s_nt_nz_f_nzc,
148   render_spans_16_c1_s_nt_z_f_nzc,    render_spans_16_c2_s_nt_z_f_nzc,
149   render_spans_16_c1_s_t_nz_f_nzc,    render_spans_16_c2_s_t_nz_f_nzc,
150   render_spans_16_c1_s_t_z_f_nzc,    render_spans_16_c2_s_t_z_f_nzc,
151
152   render_spans_16_c1_ns_nt_nz_nf_zc,   render_spans_16_c2_ns_nt_nz_nf_zc,
153   render_spans_16_c1_ns_nt_z_nf_zc,    render_spans_16_c2_ns_nt_z_nf_zc,
154   render_spans_16_c1_ns_t_nz_nf_zc,    render_spans_16_c2_ns_t_nz_nf_zc,
155   render_spans_16_c1_ns_t_z_nf_zc,    render_spans_16_c2_ns_t_z_nf_zc,
156   render_spans_16_c1_s_nt_nz_nf_zc,    render_spans_16_c2_s_nt_nz_nf_zc,
157   render_spans_16_c1_s_nt_z_nf_zc,    render_spans_16_c2_s_nt_z_nf_zc,
158   render_spans_16_c1_s_t_nz_nf_zc,    render_spans_16_c2_s_t_nz_nf_zc,
159   render_spans_16_c1_s_t_z_nf_zc,    render_spans_16_c2_s_t_z_nf_zc,
160   render_spans_16_c1_ns_nt_nz_f_zc,    render_spans_16_c2_ns_nt_nz_f_zc,
161   render_spans_16_c1_ns_nt_z_f_zc,    render_spans_16_c2_ns_nt_z_f_zc,
162   render_spans_16_c1_ns_t_nz_f_zc,    render_spans_16_c2_ns_t_nz_f_zc,
163   render_spans_16_c1_ns_t_z_f_zc,    render_spans_16_c2_ns_t_z_f_zc,
164   render_spans_16_c1_s_nt_nz_f_zc,    render_spans_16_c2_s_nt_nz_f_zc,
165   render_spans_16_c1_s_nt_z_f_zc,    render_spans_16_c2_s_nt_z_f_zc,
166   render_spans_16_c1_s_t_nz_f_zc,    render_spans_16_c2_s_t_nz_f_zc,
167   render_spans_16_c1_s_t_z_f_zc,       render_spans_16_c2_s_t_z_f_zc,
168
169   render_spans_16_c1_ns_nt_nz_nf_nzc_zu,    render_spans_16_c2_ns_nt_nz_nf_nzc_zu,
170   render_spans_16_c1_ns_nt_z_nf_nzc_zu,    render_spans_16_c2_ns_nt_z_nf_nzc_zu,
171   render_spans_16_c1_ns_t_nz_nf_nzc_zu,    render_spans_16_c2_ns_t_nz_nf_nzc_zu,
172   render_spans_16_c1_ns_t_z_nf_nzc_zu,    render_spans_16_c2_ns_t_z_nf_nzc_zu,
173   render_spans_16_c1_s_nt_nz_nf_nzc_zu,    render_spans_16_c2_s_nt_nz_nf_nzc_zu,
174   render_spans_16_c1_s_nt_z_nf_nzc_zu,    render_spans_16_c2_s_nt_z_nf_nzc_zu,
175   render_spans_16_c1_s_t_nz_nf_nzc_zu,    render_spans_16_c2_s_t_nz_nf_nzc_zu,
176   render_spans_16_c1_s_t_z_nf_nzc_zu,    render_spans_16_c2_s_t_z_nf_nzc_zu,
177   render_spans_16_c1_ns_nt_nz_f_nzc_zu,    render_spans_16_c2_ns_nt_nz_f_nzc_zu,
178   render_spans_16_c1_ns_nt_z_f_nzc_zu,    render_spans_16_c2_ns_nt_z_f_nzc_zu,
179   render_spans_16_c1_ns_t_nz_f_nzc_zu,    render_spans_16_c2_ns_t_nz_f_nzc_zu,
180   render_spans_16_c1_ns_t_z_f_nzc_zu,    render_spans_16_c2_ns_t_z_f_nzc_zu,
181   render_spans_16_c1_s_nt_nz_f_nzc_zu,    render_spans_16_c2_s_nt_nz_f_nzc_zu,
182   render_spans_16_c1_s_nt_z_f_nzc_zu,    render_spans_16_c2_s_nt_z_f_nzc_zu,
183   render_spans_16_c1_s_t_nz_f_nzc_zu,    render_spans_16_c2_s_t_nz_f_nzc_zu,
184   render_spans_16_c1_s_t_z_f_nzc_zu,       render_spans_16_c2_s_t_z_f_nzc_zu,
185
186   render_spans_16_c1_ns_nt_nz_nf_zc_zu,   render_spans_16_c2_ns_nt_nz_nf_zc_zu,
187   render_spans_16_c1_ns_nt_z_nf_zc_zu,    render_spans_16_c2_ns_nt_z_nf_zc_zu,
188   render_spans_16_c1_ns_t_nz_nf_zc_zu,    render_spans_16_c2_ns_t_nz_nf_zc_zu,
189   render_spans_16_c1_ns_t_z_nf_zc_zu,    render_spans_16_c2_ns_t_z_nf_zc_zu,
190   render_spans_16_c1_s_nt_nz_nf_zc_zu,    render_spans_16_c2_s_nt_nz_nf_zc_zu,
191   render_spans_16_c1_s_nt_z_nf_zc_zu,    render_spans_16_c2_s_nt_z_nf_zc_zu,
192   render_spans_16_c1_s_t_nz_nf_zc_zu,    render_spans_16_c2_s_t_nz_nf_zc_zu,
193   render_spans_16_c1_s_t_z_nf_zc_zu,       render_spans_16_c2_s_t_z_nf_zc_zu,
194   render_spans_16_c1_ns_nt_nz_f_zc_zu,    render_spans_16_c2_ns_nt_nz_f_zc_zu,
195   render_spans_16_c1_ns_nt_z_f_zc_zu,    render_spans_16_c2_ns_nt_z_f_zc_zu,
196   render_spans_16_c1_ns_t_nz_f_zc_zu,    render_spans_16_c2_ns_t_nz_f_zc_zu,
197   render_spans_16_c1_ns_t_z_f_zc_zu,       render_spans_16_c2_ns_t_z_f_zc_zu,
198   render_spans_16_c1_s_nt_nz_f_zc_zu,    render_spans_16_c2_s_nt_nz_f_zc_zu,
199   render_spans_16_c1_s_nt_z_f_zc_zu,       render_spans_16_c2_s_nt_z_f_zc_zu,
200   render_spans_16_c1_s_t_nz_f_zc_zu,       render_spans_16_c2_s_t_nz_f_zc_zu,
201   render_spans_16_c1_s_t_z_f_zc_zu,       render_spans_16_c2_s_t_z_f_zc_zu,
7202};
src/mame/video/rdpacvg.c
r6714r6715
1INLINE UINT8 alpha_cvg_get_cta_ca(UINT8 comb_alpha)
1INLINE void alpha_cvg_get_cta_ca(UINT8 *comb_alpha)
22{
3   UINT32 temp = comb_alpha;
3   UINT32 temp = *comb_alpha;
44   UINT32 temp2 = curpixel_cvg;
55   UINT32 temp3 = 0;
66
r6714r6715
1111
1212   if (temp > 0xff)
1313   {
14      temp = 0xff;
14      *comb_alpha = 0xff;
1515   }
16
17   return (UINT8)temp;
16   else
17   {
18      *comb_alpha = (UINT8)temp;
19   }
1820}
1921
20INLINE UINT8 alpha_cvg_get_ncta_ca(UINT8 comb_alpha)
22INLINE void alpha_cvg_get_ncta_ca(UINT8 *comb_alpha)
2123{
22   UINT32 temp = comb_alpha;
24   UINT32 temp = *comb_alpha;
2325   UINT32 temp2 = curpixel_cvg;
2426
2527   temp = temp2 << 5;
2628
2729   if (temp > 0xff)
2830   {
29      temp = 0xff;
31      *comb_alpha = 0xff;
3032   }
31
32   return (UINT8)temp;
33   else
34   {
35      *comb_alpha = (UINT8)temp;
36   }
3337}
3438
35INLINE UINT8 alpha_cvg_get_cta_nca(UINT8 comb_alpha)
39INLINE void alpha_cvg_get_cta_nca(UINT8 *comb_alpha)
3640{
37   UINT32 temp = comb_alpha;
41   UINT32 temp = *comb_alpha;
3842   UINT32 temp2 = curpixel_cvg;
3943   UINT32 temp3 = 0;
4044
r6714r6715
4347
4448   if (temp > 0xff)
4549   {
46      temp = 0xff;
50      *comb_alpha = 0xff;
4751   }
48
49   return (UINT8)temp;
52   else
53   {
54      *comb_alpha = (UINT8)temp;
55   }
5056}
5157
52INLINE UINT8 alpha_cvg_get_ncta_nca(UINT8 comb_alpha)
58INLINE void alpha_cvg_get_ncta_nca(UINT8 *comb_alpha)
5359{
54   UINT32 temp = comb_alpha;
60   UINT32 temp = *comb_alpha;
5561
5662   if (temp > 0xff)
5763   {
58      temp = 0xff;
64      *comb_alpha = 0xff;
5965   }
60
61   return (UINT8)temp;
66   else
67   {
68      *comb_alpha = (UINT8)temp;
69   }
6270}
src/mame/video/rdptrect.c
r6714r6715
1static void texture_rectangle_16bit_c1_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect)
1#if defined(ZCOMPARE)
2   #if defined(ZUPDATE)
3      #if defined(MAGICDITHER)
4         static void texture_rectangle_16bit_c1_zc_zu_dm(TEX_RECTANGLE *rect)
5      #elif defined(BAYERDITHER)
6         static void texture_rectangle_16bit_c1_zc_zu_db(TEX_RECTANGLE *rect)
7      #else
8         static void texture_rectangle_16bit_c1_zc_zu_dn(TEX_RECTANGLE *rect)
9      #endif
10   #else
11      #if defined(MAGICDITHER)
12         static void texture_rectangle_16bit_c1_zc_nzu_dm(TEX_RECTANGLE *rect)
13      #elif defined(BAYERDITHER)
14         static void texture_rectangle_16bit_c1_zc_nzu_db(TEX_RECTANGLE *rect)
15      #else
16         static void texture_rectangle_16bit_c1_zc_nzu_dn(TEX_RECTANGLE *rect)
17      #endif
18   #endif
19#else
20   #if defined(ZUPDATE)
21      #if defined(MAGICDITHER)
22         static void texture_rectangle_16bit_c1_nzc_zu_dm(TEX_RECTANGLE *rect)
23      #elif defined(BAYERDITHER)
24         static void texture_rectangle_16bit_c1_nzc_zu_db(TEX_RECTANGLE *rect)
25      #else
26         static void texture_rectangle_16bit_c1_nzc_zu_dn(TEX_RECTANGLE *rect)
27      #endif
28   #else
29      #if defined(MAGICDITHER)
30         static void texture_rectangle_16bit_c1_nzc_nzu_dm(TEX_RECTANGLE *rect)
31      #elif defined(BAYERDITHER)
32         static void texture_rectangle_16bit_c1_nzc_nzu_db(TEX_RECTANGLE *rect)
33      #else
34         static void texture_rectangle_16bit_c1_nzc_nzu_dn(TEX_RECTANGLE *rect)
35      #endif
36   #endif
37#endif
238{
339   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
4   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
540   UINT8 *hb = &hidden_bits[fb_address >> 1];
6   UINT8 *zhb = &hidden_bits[zb_address >> 1];
7
8   int i, j;
9   int x1, x2, y1, y2;
10   int s, t;
11   int ss, st;
12
13   int clipx1, clipx2, clipy1, clipy2;
14
15   UINT32 tilenum = rect->tilenum;
16   TILE *tex_tile = &tile[rect->tilenum];
17
18   x1 = (rect->xh / 4);
19   x2 = (rect->xl / 4);
20   y1 = (rect->yh / 4);
21   y2 = (rect->yl / 4);
22
23   if (x2<=x1)
24   {
25      x2 = x1 + 1;
26   }
27   if (y1==y2)
28   {
29      y2 = y1 + 1; // Needed by Goldeneye
30   }
31
32   if ((rect->xl & 3) == 3) // Needed by Mega Man 64
33   {
34      x2++;
35   }
36   if ((rect->yl & 3) == 3)
37   {
38      y2++;
39   }
40
41   clipx1 = clip.xh / 4;
42   clipx2 = clip.xl / 4;
43   clipy1 = clip.yh / 4;
44   clipy2 = clip.yl / 4;
45
46   calculate_clamp_diffs(tilenum);
47
48   set_shade_for_rects(); // Needed by Pilotwings 64
49
50   t = ((int)(rect->t)) << 5;
51
52   for (j = y1; j < y2; j++)
53   {
54      int fb_index = j * fb_width;
55      if (j >= clipy1 && j < clipy2)
56      {
57         s = ((int)(rect->s)) << 5;
58
59         for (i = x1; i < x2; i++)
60         {
61            if (i >= clipx1 && i < clipx2)
62            {
63               COLOR c;
64               int rendered = 0;
65               int dith = 0;
66               int curpixel = fb_index + i;
67               UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
68               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
69               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
70               UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
71
72               curpixel_cvg = 8;
73
74               ss = s >> 5;
75               st = t >> 5;
76               if (rect->flip)
77               {
78                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
79               }
80               else
81               {
82                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
83               }
84
85               c = COLOR_COMBINER1(machine);
86
87               if (!other_modes.rgb_dither_sel)
88               {
89                  dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
90               }
91               else if (other_modes.rgb_dither_sel == 1)
92               {
93                  dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
94               }
95
96
97               rendered = BLENDER1_16(machine, fbcur, hbcur, c, dith);
98
99               if (other_modes.z_update_en && other_modes.z_source_sel && rendered)
100               {
101                  z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z);
102               }
103            }
104
105            s += (int)(rect->dsdx);
106         }
107      }
108      t += (int)(rect->dtdy);
109   }
110}
111
112static void texture_rectangle_16bit_c2_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect)
113{
114   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
41#if (defined(ZCOMPARE) || defined(ZUPDATE))
11542   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
116   UINT8 *hb = &hidden_bits[fb_address >> 1];
11743   UINT8 *zhb = &hidden_bits[zb_address >> 1];
44#endif
11845
11946   int i, j;
12047   int x1, x2, y1, y2;
12148   int s, t;
122   int ss, st;
12349
12450   int clipx1, clipx2, clipy1, clipy2;
12551
12652   UINT32 tilenum = rect->tilenum;
127   UINT32 tilenum2 = 0;
12853   TILE *tex_tile = &tile[rect->tilenum];
129   TILE *tex_tile2 = NULL;
13054
13155   x1 = (rect->xh / 4);
13256   x2 = (rect->xl / 4);
r6714r6715
15882
15983   calculate_clamp_diffs(tilenum);
16084
161   if (!other_modes.tex_lod_en)
162   {
163      tilenum2 = (tilenum + 1) & 7;
164      tex_tile2 = &tile[tilenum2];
165   }
166   else
167   {
168      tilenum2 = (tilenum + 1) & 7;
169      tex_tile2 = &tile[tilenum2];
170   }
171
172
17385   set_shade_for_rects(); // Needed by Pilotwings 64
17486
175   t = ((int)(rect->t)) << 5;
176
177   for (j = y1; j < y2; j++)
87   if(rect->flip)
17888   {
179      int fb_index = j * fb_width;
180
181      if (j >= clipy1 && j < clipy2)
182      {
183         s = (int)(rect->s) << 5;
184
185         for (i = x1; i < x2; i++)
186         {
187            if (i >= clipx1 && i < clipx2)
188            {
189               COLOR c1, c2;
190               int rendered=0;
191               int curpixel = fb_index + i;
192               UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
193               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
194               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
195               UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
196               int dith = 0;
197
198               curpixel_cvg = 8;
199
200               ss = s >> 5;
201               st = t >> 5;
202
203               if (rect->flip)
204               {
205                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
206                  TEXTURE_PIPELINE(&texel1_color, st, ss, tex_tile2);
207               }
208               else
209               {
210                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
211                  TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2);
212               }
213               c1 = COLOR_COMBINER2_C0(machine);
214               c2 = COLOR_COMBINER2_C1(machine);
215
216               if (!other_modes.rgb_dither_sel)
217               {
218                  dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
219               }
220               else if (other_modes.rgb_dither_sel == 1)
221               {
222                  dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
223               }
224
225               rendered = BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith);
226
227               if (other_modes.z_update_en && other_modes.z_source_sel && rendered)
228               {
229                  z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z);
230               }
231            }
232
233            s += (rect->dsdx);
234         }
235      }
236      t += (rect->dtdy);
89      int temp = rect->t;
90      rect->t = rect->s;
91      rect->s = temp;
92      temp = rect->dtdy;
93      rect->dtdy = rect->dsdx;
94      rect->dsdx= temp;
23795   }
238}
23996
240static void texture_rectangle_16bit_cc_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect)
241{
242   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
243
244   int i, j;
245   int x1, x2, y1, y2;
246   int s, t;
247   int ss, st;
248
249   int clipx1, clipx2, clipy1, clipy2;
250
251   UINT32 tilenum = rect->tilenum;
252   TILE *tex_tile = &tile[rect->tilenum];
253
254   x1 = (rect->xh / 4);
255   x2 = (rect->xl / 4);
256   y1 = (rect->yh / 4);
257   y2 = (rect->yl / 4);
258
259   if (x2<=x1)
260   {
261      x2 = x1 + 1;
262   }
263   if (y1==y2)
264   {
265      y2 = y1 + 1; // Needed by Goldeneye
266   }
267
268   rect->dsdx /= 4;
269   x2 += 1;
270   y2 += 1;
271
272   clipx1 = clip.xh / 4;
273   clipx2 = clip.xl / 4;
274   clipy1 = clip.yh / 4;
275   clipy2 = clip.yl / 4;
276
277   calculate_clamp_diffs(tilenum);
278
279   set_shade_for_rects(); // Needed by Pilotwings 64
280
28197   t = ((int)(rect->t)) << 5;
28298
28399   for (j = y1; j < y2; j++)
284100   {
285      int fb_index = j * fb_width;
286101      if (j >= clipy1 && j < clipy2)
287102      {
288         s = (int)(rect->s) << 5;
289
290         for (i = x1; i < x2; i++)
291         {
292            if (i >= clipx1 && i < clipx2)
293            {
294               ss = s >> 5;
295               st = t >> 5;
296
297               if (rect->flip)
298               {
299                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
300               }
301               else
302               {
303                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
304               }
305
306               curpixel_cvg = 8;
307
308               if ((texel0_color.i.a != 0)||(!other_modes.alpha_compare_en))
309               {
310                  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;
311               }
312            }
313            s += rect->dsdx;
314         }
315      }
316      t += rect->dtdy;
317   }
318}
319
320static void texture_rectangle_16bit_cf_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect)
321{
322   fatalerror("texture_rectangle with FILL cycle type is not supported\n");
323}
324
325static void texture_rectangle_16bit_c1_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect)
326{
327   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
328   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
329   UINT8 *hb = &hidden_bits[fb_address >> 1];
330   UINT8 *zhb = &hidden_bits[zb_address >> 1];
331
332   int i, j;
333   int x1, x2, y1, y2;
334   int s, t;
335   int ss, st;
336
337   int clipx1, clipx2, clipy1, clipy2;
338
339   UINT32 tilenum = rect->tilenum;
340   TILE *tex_tile = &tile[rect->tilenum];
341
342   x1 = (rect->xh / 4);
343   x2 = (rect->xl / 4);
344   y1 = (rect->yh / 4);
345   y2 = (rect->yl / 4);
346
347   if (x2<=x1)
348   {
349      x2 = x1 + 1;
350   }
351   if (y1==y2)
352   {
353      y2 = y1 + 1; // Needed by Goldeneye
354   }
355
356   if ((rect->xl & 3) == 3) // Needed by Mega Man 64
357   {
358      x2++;
359   }
360   if ((rect->yl & 3) == 3)
361   {
362      y2++;
363   }
364
365   clipx1 = clip.xh / 4;
366   clipx2 = clip.xl / 4;
367   clipy1 = clip.yh / 4;
368   clipy2 = clip.yl / 4;
369
370   calculate_clamp_diffs(tilenum);
371
372   set_shade_for_rects(); // Needed by Pilotwings 64
373
374   t = ((int)(rect->t)) << 5;
375
376   for (j = y1; j < y2; j++)
377   {
378      int fb_index = j * fb_width;
379      if (j >= clipy1 && j < clipy2)
380      {
103         int fb_index = j * fb_width;
104#if defined(MAGICDITHER) || defined(BAYERDITHER)
105         int mline = (j & 3) << 2;
106#endif
381107         s = ((int)(rect->s)) << 5;
382108
383109         for (i = x1; i < x2; i++)
r6714r6715
385111            if (i >= clipx1 && i < clipx2)
386112            {
387113               COLOR c;
114#if defined(ZUPDATE)
388115               int rendered = 0;
116#endif
389117               int dith = 0;
390118               int curpixel = fb_index + i;
391119               UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
392               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
393120               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
121#if (defined(ZCOMPARE) || defined(ZUPDATE))
122               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
394123               UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
124#endif
395125
396126               curpixel_cvg = 8;
397127
398               ss = s >> 5;
399               st = t >> 5;
400               if (rect->flip)
401               {
402                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
403               }
404               else
405               {
406                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
407               }
128               TEXTURE_PIPELINE(&texel0_color, s >> 5, t >> 5, tex_tile);
408129
409               c = COLOR_COMBINER1(machine);
130               COLOR_COMBINER1(&c);
410131
411               if (!other_modes.rgb_dither_sel)
412               {
413                  dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
414               }
415               else if (other_modes.rgb_dither_sel == 1)
416               {
417                  dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
418               }
132#if defined(MAGICDITHER)
133               dith = magic_matrix[mline + ((i ^ WORD_ADDR_XOR) & 3)];
134#elif defined(BAYERDITHER)
135               dith = bayer_matrix[mline + ((i ^ WORD_ADDR_XOR) & 3)];
136#endif
419137
138#if defined(ZCOMPARE)
420139               if (z_compare(fbcur, hbcur, zbcur, zhbcur, ((UINT32)primitive_z)<<3,primitive_delta_z))
421140               {
422                  rendered = BLENDER1_16(machine, fbcur, hbcur, c, dith);
141#if defined(ZUPDATE)
142                  rendered = BLENDER1_16(fbcur, hbcur, c, dith);
143#else
144                  BLENDER1_16(fbcur, hbcur, c, dith);
145#endif
423146               }
147#elif defined(ZUPDATE)
148               rendered = BLENDER1_16(fbcur, hbcur, c, dith);
149#else
150               BLENDER1_16(fbcur, hbcur, c, dith);
151#endif
424152
425               if (other_modes.z_update_en && other_modes.z_source_sel && rendered)
153#if defined(ZUPDATE)
154               if(rendered)
426155               {
427156                  z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z);
428157               }
158#endif
429159            }
430160
431161            s += (int)(rect->dsdx);
r6714r6715
435165   }
436166}
437167
438static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect)
168#if defined(ZCOMPARE)
169   #if defined(ZUPDATE)
170      #if defined(MAGICDITHER)
171         static void texture_rectangle_16bit_c2_zc_zu_dm(TEX_RECTANGLE *rect)
172      #elif defined(BAYERDITHER)
173         static void texture_rectangle_16bit_c2_zc_zu_db(TEX_RECTANGLE *rect)
174      #else
175         static void texture_rectangle_16bit_c2_zc_zu_dn(TEX_RECTANGLE *rect)
176      #endif
177   #else
178      #if defined(MAGICDITHER)
179         static void texture_rectangle_16bit_c2_zc_nzu_dm(TEX_RECTANGLE *rect)
180      #elif defined(BAYERDITHER)
181         static void texture_rectangle_16bit_c2_zc_nzu_db(TEX_RECTANGLE *rect)
182      #else
183         static void texture_rectangle_16bit_c2_zc_nzu_dn(TEX_RECTANGLE *rect)
184      #endif
185   #endif
186#else
187   #if defined(ZUPDATE)
188      #if defined(MAGICDITHER)
189         static void texture_rectangle_16bit_c2_nzc_zu_dm(TEX_RECTANGLE *rect)
190      #elif defined(BAYERDITHER)
191         static void texture_rectangle_16bit_c2_nzc_zu_db(TEX_RECTANGLE *rect)
192      #else
193         static void texture_rectangle_16bit_c2_nzc_zu_dn(TEX_RECTANGLE *rect)
194      #endif
195   #else
196      #if defined(MAGICDITHER)
197         static void texture_rectangle_16bit_c2_nzc_nzu_dm(TEX_RECTANGLE *rect)
198      #elif defined(BAYERDITHER)
199         static void texture_rectangle_16bit_c2_nzc_nzu_db(TEX_RECTANGLE *rect)
200      #else
201         static void texture_rectangle_16bit_c2_nzc_nzu_dn(TEX_RECTANGLE *rect)
202      #endif
203   #endif
204#endif
439205{
440206   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
441   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
442207   UINT8 *hb = &hidden_bits[fb_address >> 1];
208#if (defined(ZCOMPARE) || defined(ZUPDATE))
209   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
443210   UINT8 *zhb = &hidden_bits[zb_address >> 1];
211#endif
444212
445213   int i, j;
446214   int x1, x2, y1, y2;
r6714r6715
498266
499267   set_shade_for_rects(); // Needed by Pilotwings 64
500268
269   if(rect->flip)
270   {
271      int temp = rect->t;
272      rect->t = rect->s;
273      rect->s = temp;
274      temp = rect->dtdy;
275      rect->dtdy = rect->dsdx;
276      rect->dsdx= temp;
277   }
278
501279   t = ((int)(rect->t)) << 5;
502280
503281   for (j = y1; j < y2; j++)
504282   {
505      int fb_index = j * fb_width;
506283
507284      if (j >= clipy1 && j < clipy2)
508285      {
286         int fb_index = j * fb_width;
287#if defined(MAGICDITHER) || defined(BAYERDITHER)
288         int mline = (j & 3) << 2;
289#endif
509290         s = (int)(rect->s) << 5;
510291
511292         for (i = x1; i < x2; i++)
r6714r6715
513294            if (i >= clipx1 && i < clipx2)
514295            {
515296               COLOR c1, c2;
297#if defined(ZUPDATE)
516298               int rendered=0;
299#endif
517300               int curpixel = fb_index + i;
518301               UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
519               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
520302               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
303#if (defined(ZCOMPARE) || defined(ZUPDATE))
304               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
521305               UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
306#endif
522307               int dith = 0;
523308
524309               curpixel_cvg = 8;
r6714r6715
526311               ss = s >> 5;
527312               st = t >> 5;
528313
529               if (rect->flip)
530               {
531                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
532                  TEXTURE_PIPELINE(&texel1_color, st, ss, tex_tile2);
533               }
534               else
535               {
536                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
537                  TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2);
538               }
539               c1 = COLOR_COMBINER2_C0(machine);
540               c2 = COLOR_COMBINER2_C1(machine);
314               TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
315               TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2);
541316
542               if (!other_modes.rgb_dither_sel)
543               {
544                  dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
545               }
546               else if (other_modes.rgb_dither_sel == 1)
547               {
548                  dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
549               }
317               COLOR_COMBINER2_C0(&c1);
318               COLOR_COMBINER2_C1(&c2);
550319
551               if (z_compare(fbcur, hbcur, zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z))
552               {
553                  rendered = BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith);
554               }
320#if defined(MAGICDITHER)
321               dith = magic_matrix[mline + ((i ^ WORD_ADDR_XOR) & 3)];
322#elif defined(BAYERDITHER)
323               dith = bayer_matrix[mline + ((i ^ WORD_ADDR_XOR) & 3)];
324#endif
555325
556               if (other_modes.z_update_en && other_modes.z_source_sel && rendered)
326#if defined(ZCOMPARE)
327               if (z_compare(fbcur, hbcur, zbcur, zhbcur, ((UINT32)primitive_z)<<3,primitive_delta_z))
557328               {
558                  z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z);
329#if defined(ZUPDATE)
330                  rendered = BLENDER2_16(fbcur, hbcur, c1, c2, dith);
331#else
332                  BLENDER2_16(fbcur, hbcur, c1, c2, dith);
333#endif
559334               }
560            }
335#else
336#if defined(ZUPDATE)
337               rendered = BLENDER2_16(fbcur, hbcur, c1, c2, dith);
338#else
339               BLENDER2_16(fbcur, hbcur, c1, c2, dith);
340#endif
341#endif
561342
562            s += (rect->dsdx);
563         }
564      }
565      t += (rect->dtdy);
566   }
567}
568
569static void texture_rectangle_16bit_cc_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect)
570{
571   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
572
573   int i, j;
574   int x1, x2, y1, y2;
575   int s, t;
576   int ss, st;
577
578   int clipx1, clipx2, clipy1, clipy2;
579
580   UINT32 tilenum = rect->tilenum;
581   TILE *tex_tile = &tile[rect->tilenum];
582
583   x1 = (rect->xh / 4);
584   x2 = (rect->xl / 4);
585   y1 = (rect->yh / 4);
586   y2 = (rect->yl / 4);
587
588   if (x2<=x1)
589   {
590      x2 = x1 + 1;
591   }
592   if (y1==y2)
593   {
594      y2 = y1 + 1; // Needed by Goldeneye
595   }
596
597   rect->dsdx /= 4;
598   x2 += 1;
599   y2 += 1;
600
601   clipx1 = clip.xh / 4;
602   clipx2 = clip.xl / 4;
603   clipy1 = clip.yh / 4;
604   clipy2 = clip.yl / 4;
605
606   calculate_clamp_diffs(tilenum);
607
608   set_shade_for_rects(); // Needed by Pilotwings 64
609
610   t = ((int)(rect->t)) << 5;
611
612   for (j = y1; j < y2; j++)
613   {
614      int fb_index = j * fb_width;
615      if (j >= clipy1 && j < clipy2)
616      {
617         s = (int)(rect->s) << 5;
618
619         for (i = x1; i < x2; i++)
620         {
621            if (i >= clipx1 && i < clipx2)
622            {
623               ss = s >> 5;
624               st = t >> 5;
625
626               if (rect->flip)
343#if defined(ZUPDATE)
344               if(rendered)
627345               {
628                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
629               }
630               else
631               {
632                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
633               }
634
635               curpixel_cvg = 8;
636
637               if ((texel0_color.i.a != 0)||(!other_modes.alpha_compare_en))
638               {
639                  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;
640               }
641            }
642            s += rect->dsdx;
643         }
644      }
645      t += rect->dtdy;
646   }
647}
648
649static void texture_rectangle_16bit_cf_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect)
650{
651   fatalerror("texture_rectangle with FILL cycle type is not supported\n");
652}
653
654static void texture_rectangle_16bit_c1_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect)
655{
656   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
657   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
658   UINT8 *hb = &hidden_bits[fb_address >> 1];
659   UINT8 *zhb = &hidden_bits[zb_address >> 1];
660
661   int i, j;
662   int x1, x2, y1, y2;
663   int s, t;
664   int ss, st;
665
666   int clipx1, clipx2, clipy1, clipy2;
667
668   UINT32 tilenum = rect->tilenum;
669   TILE *tex_tile = &tile[rect->tilenum];
670
671   x1 = (rect->xh / 4);
672   x2 = (rect->xl / 4);
673   y1 = (rect->yh / 4);
674   y2 = (rect->yl / 4);
675
676   if (x2<=x1)
677   {
678      x2 = x1 + 1;
679   }
680   if (y1==y2)
681   {
682      y2 = y1 + 1; // Needed by Goldeneye
683   }
684
685   if ((rect->xl & 3) == 3) // Needed by Mega Man 64
686   {
687      x2++;
688   }
689   if ((rect->yl & 3) == 3)
690   {
691      y2++;
692   }
693
694   clipx1 = clip.xh / 4;
695   clipx2 = clip.xl / 4;
696   clipy1 = clip.yh / 4;
697   clipy2 = clip.yl / 4;
698
699   calculate_clamp_diffs(tilenum);
700
701   set_shade_for_rects(); // Needed by Pilotwings 64
702
703   t = ((int)(rect->t)) << 5;
704
705   for (j = y1; j < y2; j++)
706   {
707      int fb_index = j * fb_width;
708      if (j >= clipy1 && j < clipy2)
709      {
710         s = ((int)(rect->s)) << 5;
711
712         for (i = x1; i < x2; i++)
713         {
714            if (i >= clipx1 && i < clipx2)
715            {
716               COLOR c;
717               int dith = 0;
718               int curpixel = fb_index + i;
719               UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
720               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
721               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
722               UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
723
724               curpixel_cvg = 8;
725
726               ss = s >> 5;
727               st = t >> 5;
728               if (rect->flip)
729               {
730                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
731               }
732               else
733               {
734                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
735               }
736
737               c = COLOR_COMBINER1(machine);
738
739               if (!other_modes.rgb_dither_sel)
740               {
741                  dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
742               }
743               else if (other_modes.rgb_dither_sel == 1)
744               {
745                  dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
746               }
747
748               if (BLENDER1_16(machine, fbcur, hbcur, c, dith))
749               {
750346                  z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z);
751347               }
348#endif
752349            }
753350
754            s += (int)(rect->dsdx);
755         }
756      }
757      t += (int)(rect->dtdy);
758   }
759}
760
761static void texture_rectangle_16bit_c2_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect)
762{
763   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
764   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
765   UINT8 *hb = &hidden_bits[fb_address >> 1];
766   UINT8 *zhb = &hidden_bits[zb_address >> 1];
767
768   int i, j;
769   int x1, x2, y1, y2;
770   int s, t;
771   int ss, st;
772
773   int clipx1, clipx2, clipy1, clipy2;
774
775   UINT32 tilenum = rect->tilenum;
776   UINT32 tilenum2 = 0;
777   TILE *tex_tile = &tile[rect->tilenum];
778   TILE *tex_tile2 = NULL;
779
780   x1 = (rect->xh / 4);
781   x2 = (rect->xl / 4);
782   y1 = (rect->yh / 4);
783   y2 = (rect->yl / 4);
784
785   if (x2<=x1)
786   {
787      x2 = x1 + 1;
788   }
789   if (y1==y2)
790   {
791      y2 = y1 + 1; // Needed by Goldeneye
792   }
793
794   if ((rect->xl & 3) == 3) // Needed by Mega Man 64
795   {
796      x2++;
797   }
798   if ((rect->yl & 3) == 3)
799   {
800      y2++;
801   }
802
803   clipx1 = clip.xh / 4;
804   clipx2 = clip.xl / 4;
805   clipy1 = clip.yh / 4;
806   clipy2 = clip.yl / 4;
807
808   calculate_clamp_diffs(tilenum);
809
810   if (!other_modes.tex_lod_en)
811   {
812      tilenum2 = (tilenum + 1) & 7;
813      tex_tile2 = &tile[tilenum2];
814   }
815   else
816   {
817      tilenum2 = (tilenum + 1) & 7;
818      tex_tile2 = &tile[tilenum2];
819   }
820
821
822   set_shade_for_rects(); // Needed by Pilotwings 64
823
824   t = ((int)(rect->t)) << 5;
825
826   for (j = y1; j < y2; j++)
827   {
828      int fb_index = j * fb_width;
829
830      if (j >= clipy1 && j < clipy2)
831      {
832         s = (int)(rect->s) << 5;
833
834         for (i = x1; i < x2; i++)
835         {
836            if (i >= clipx1 && i < clipx2)
837            {
838               COLOR c1, c2;
839               int curpixel = fb_index + i;
840               UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
841               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
842               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
843               UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
844               int dith = 0;
845
846               curpixel_cvg = 8;
847
848               ss = s >> 5;
849               st = t >> 5;
850
851               if (rect->flip)
852               {
853                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
854                  TEXTURE_PIPELINE(&texel1_color, st, ss, tex_tile2);
855               }
856               else
857               {
858                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
859                  TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2);
860               }
861               c1 = COLOR_COMBINER2_C0(machine);
862               c2 = COLOR_COMBINER2_C1(machine);
863
864               if (!other_modes.rgb_dither_sel)
865               {
866                  dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
867               }
868               else if (other_modes.rgb_dither_sel == 1)
869               {
870                  dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
871               }
872
873               if (BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith))
874               {
875                  z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z);
876               }
877            }
878
879351            s += (rect->dsdx);
880352         }
881353      }
r6714r6715
883355   }
884356}
885357
886static void texture_rectangle_16bit_cc_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect)
358#if defined(ZCOMPARE)
359   #if defined(ZUPDATE)
360      #if defined(MAGICDITHER)
361         static void texture_rectangle_16bit_cc_zc_zu_dm(TEX_RECTANGLE *rect)
362      #elif defined(BAYERDITHER)
363         static void texture_rectangle_16bit_cc_zc_zu_db(TEX_RECTANGLE *rect)
364      #else
365         static void texture_rectangle_16bit_cc_zc_zu_dn(TEX_RECTANGLE *rect)
366      #endif
367   #else
368      #if defined(MAGICDITHER)
369         static void texture_rectangle_16bit_cc_zc_nzu_dm(TEX_RECTANGLE *rect)
370      #elif defined(BAYERDITHER)
371         static void texture_rectangle_16bit_cc_zc_nzu_db(TEX_RECTANGLE *rect)
372      #else
373         static void texture_rectangle_16bit_cc_zc_nzu_dn(TEX_RECTANGLE *rect)
374      #endif
375   #endif
376#else
377   #if defined(ZUPDATE)
378      #if defined(MAGICDITHER)
379         static void texture_rectangle_16bit_cc_nzc_zu_dm(TEX_RECTANGLE *rect)
380      #elif defined(BAYERDITHER)
381         static void texture_rectangle_16bit_cc_nzc_zu_db(TEX_RECTANGLE *rect)
382      #else
383         static void texture_rectangle_16bit_cc_nzc_zu_dn(TEX_RECTANGLE *rect)
384      #endif
385   #else
386      #if defined(MAGICDITHER)
387         static void texture_rectangle_16bit_cc_nzc_nzu_dm(TEX_RECTANGLE *rect)
388      #elif defined(BAYERDITHER)
389         static void texture_rectangle_16bit_cc_nzc_nzu_db(TEX_RECTANGLE *rect)
390      #else
391         static void texture_rectangle_16bit_cc_nzc_nzu_dn(TEX_RECTANGLE *rect)
392      #endif
393   #endif
394#endif
887395{
888396   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
889397
r6714r6715
924432
925433   set_shade_for_rects(); // Needed by Pilotwings 64
926434
927   t = ((int)(rect->t)) << 5;
928
929   for (j = y1; j < y2; j++)
435   if(rect->flip)
930436   {
931      int fb_index = j * fb_width;
932      if (j >= clipy1 && j < clipy2)
933      {
934         s = (int)(rect->s) << 5;
935
936         for (i = x1; i < x2; i++)
937         {
938            if (i >= clipx1 && i < clipx2)
939            {
940               ss = s >> 5;
941               st = t >> 5;
942
943               if (rect->flip)
944               {
945                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
946               }
947               else
948               {
949                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
950               }
951
952               curpixel_cvg = 8;
953
954               if ((texel0_color.i.a != 0)||(!other_modes.alpha_compare_en))
955               {
956                  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;
957               }
958            }
959            s += rect->dsdx;
960         }
961      }
962      t += rect->dtdy;
437      int temp = rect->t;
438      rect->t = rect->s;
439      rect->s = temp;
440      temp = rect->dtdy;
441      rect->dtdy = rect->dsdx;
442      rect->dsdx= temp;
963443   }
964}
965444
966static void texture_rectangle_16bit_cf_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect)
967{
968   fatalerror("texture_rectangle with FILL cycle type is not supported\n");
969}
970
971static void texture_rectangle_16bit_c1_zc_zu(running_machine *machine, TEX_RECTANGLE *rect)
972{
973   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
974   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
975   UINT8 *hb = &hidden_bits[fb_address >> 1];
976   UINT8 *zhb = &hidden_bits[zb_address >> 1];
977
978   int i, j;
979   int x1, x2, y1, y2;
980   int s, t;
981   int ss, st;
982
983   int clipx1, clipx2, clipy1, clipy2;
984
985   UINT32 tilenum = rect->tilenum;
986   TILE *tex_tile = &tile[rect->tilenum];
987
988   x1 = (rect->xh / 4);
989   x2 = (rect->xl / 4);
990   y1 = (rect->yh / 4);
991   y2 = (rect->yl / 4);
992
993   if (x2<=x1)
994   {
995      x2 = x1 + 1;
996   }
997   if (y1==y2)
998   {
999      y2 = y1 + 1; // Needed by Goldeneye
1000   }
1001
1002   if ((rect->xl & 3) == 3) // Needed by Mega Man 64
1003   {
1004      x2++;
1005   }
1006   if ((rect->yl & 3) == 3)
1007   {
1008      y2++;
1009   }
1010
1011   clipx1 = clip.xh / 4;
1012   clipx2 = clip.xl / 4;
1013   clipy1 = clip.yh / 4;
1014   clipy2 = clip.yl / 4;
1015
1016   calculate_clamp_diffs(tilenum);
1017
1018   set_shade_for_rects(); // Needed by Pilotwings 64
1019
1020445   t = ((int)(rect->t)) << 5;
1021446
1022447   for (j = y1; j < y2; j++)
r6714r6715
1024449      int fb_index = j * fb_width;
1025450      if (j >= clipy1 && j < clipy2)
1026451      {
1027         s = ((int)(rect->s)) << 5;
1028
1029         for (i = x1; i < x2; i++)
1030         {
1031            if (i >= clipx1 && i < clipx2)
1032            {
1033               COLOR c;
1034               int dith = 0;
1035               int curpixel = fb_index + i;
1036               UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
1037               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
1038               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
1039               UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
1040
1041               curpixel_cvg = 8;
1042
1043               ss = s >> 5;
1044               st = t >> 5;
1045               if (rect->flip)
1046               {
1047                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
1048               }
1049               else
1050               {
1051                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
1052               }
1053
1054               c = COLOR_COMBINER1(machine);
1055
1056               if (!other_modes.rgb_dither_sel)
1057               {
1058                  dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
1059               }
1060               else if (other_modes.rgb_dither_sel == 1)
1061               {
1062                  dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
1063               }
1064
1065               if (z_compare(fbcur, hbcur, zbcur, zhbcur, ((UINT32)primitive_z)<<3,primitive_delta_z))
1066               {
1067                  if(BLENDER1_16(machine, fbcur, hbcur, c, dith))
1068                  {
1069                     z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z);
1070                  }
1071               }
1072
1073            }
1074
1075            s += (int)(rect->dsdx);
1076         }
1077      }
1078      t += (int)(rect->dtdy);
1079   }
1080}
1081
1082static void texture_rectangle_16bit_c2_zc_zu(running_machine *machine, TEX_RECTANGLE *rect)
1083{
1084   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
1085   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
1086   UINT8 *hb = &hidden_bits[fb_address >> 1];
1087   UINT8 *zhb = &hidden_bits[zb_address >> 1];
1088
1089   int i, j;
1090   int x1, x2, y1, y2;
1091   int s, t;
1092   int ss, st;
1093
1094   int clipx1, clipx2, clipy1, clipy2;
1095
1096   UINT32 tilenum = rect->tilenum;
1097   UINT32 tilenum2 = 0;
1098   TILE *tex_tile = &tile[rect->tilenum];
1099   TILE *tex_tile2 = NULL;
1100
1101   x1 = (rect->xh / 4);
1102   x2 = (rect->xl / 4);
1103   y1 = (rect->yh / 4);
1104   y2 = (rect->yl / 4);
1105
1106   if (x2<=x1)
1107   {
1108      x2 = x1 + 1;
1109   }
1110   if (y1==y2)
1111   {
1112      y2 = y1 + 1; // Needed by Goldeneye
1113   }
1114
1115   if ((rect->xl & 3) == 3) // Needed by Mega Man 64
1116   {
1117      x2++;
1118   }
1119   if ((rect->yl & 3) == 3)
1120   {
1121      y2++;
1122   }
1123
1124   clipx1 = clip.xh / 4;
1125   clipx2 = clip.xl / 4;
1126   clipy1 = clip.yh / 4;
1127   clipy2 = clip.yl / 4;
1128
1129   calculate_clamp_diffs(tilenum);
1130
1131   if (!other_modes.tex_lod_en)
1132   {
1133      tilenum2 = (tilenum + 1) & 7;
1134      tex_tile2 = &tile[tilenum2];
1135   }
1136   else
1137   {
1138      tilenum2 = (tilenum + 1) & 7;
1139      tex_tile2 = &tile[tilenum2];
1140   }
1141
1142
1143   set_shade_for_rects(); // Needed by Pilotwings 64
1144
1145   t = ((int)(rect->t)) << 5;
1146
1147   for (j = y1; j < y2; j++)
1148   {
1149      int fb_index = j * fb_width;
1150
1151      if (j >= clipy1 && j < clipy2)
1152      {
1153452         s = (int)(rect->s) << 5;
1154453
1155454         for (i = x1; i < x2; i++)
1156455         {
1157456            if (i >= clipx1 && i < clipx2)
1158457            {
1159               COLOR c1, c2;
1160               int curpixel = fb_index + i;
1161               UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
1162               UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
1163               UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
1164               UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
1165               int dith = 0;
1166
1167               curpixel_cvg = 8;
1168
1169458               ss = s >> 5;
1170459               st = t >> 5;
1171460
1172               if (rect->flip)
1173               {
1174                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
1175                  TEXTURE_PIPELINE(&texel1_color, st, ss, tex_tile2);
1176               }
1177               else
1178               {
1179                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
1180                  TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2);
1181               }
1182               c1 = COLOR_COMBINER2_C0(machine);
1183               c2 = COLOR_COMBINER2_C1(machine);
461               TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
1184462
1185               if (!other_modes.rgb_dither_sel)
1186               {
1187                  dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
1188               }
1189               else if (other_modes.rgb_dither_sel == 1)
1190               {
1191                  dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
1192               }
1193
1194               if (z_compare(fbcur, hbcur, zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z))
1195               {
1196                  if (BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith))
1197                  {
1198                     z_store(zbcur, zhbcur, ((UINT32)primitive_z) << 3,primitive_delta_z);
1199                  }
1200               }
1201
1202            }
1203
1204            s += (rect->dsdx);
1205         }
1206      }
1207      t += (rect->dtdy);
1208   }
1209}
1210
1211static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTANGLE *rect)
1212{
1213   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
1214
1215   int i, j;
1216   int x1, x2, y1, y2;
1217   int s, t;
1218   int ss, st;
1219
1220   int clipx1, clipx2, clipy1, clipy2;
1221
1222   UINT32 tilenum = rect->tilenum;
1223   TILE *tex_tile = &tile[rect->tilenum];
1224
1225   x1 = (rect->xh / 4);
1226   x2 = (rect->xl / 4);
1227   y1 = (rect->yh / 4);
1228   y2 = (rect->yl / 4);
1229
1230   if (x2<=x1)
1231   {
1232      x2 = x1 + 1;
1233   }
1234   if (y1==y2)
1235   {
1236      y2 = y1 + 1; // Needed by Goldeneye
1237   }
1238
1239   rect->dsdx /= 4;
1240   x2 += 1;
1241   y2 += 1;
1242
1243   clipx1 = clip.xh / 4;
1244   clipx2 = clip.xl / 4;
1245   clipy1 = clip.yh / 4;
1246   clipy2 = clip.yl / 4;
1247
1248   calculate_clamp_diffs(tilenum);
1249
1250   set_shade_for_rects(); // Needed by Pilotwings 64
1251
1252   t = ((int)(rect->t)) << 5;
1253
1254
1255   for (j = y1; j < y2; j++)
1256   {
1257      int fb_index = j * fb_width;
1258      if (j >= clipy1 && j < clipy2)
1259      {
1260         s = (int)(rect->s) << 5;
1261
1262         for (i = x1; i < x2; i++)
1263         {
1264            if (i >= clipx1 && i < clipx2)
1265            {
1266               ss = s >> 5;
1267               st = t >> 5;
1268
1269               if (rect->flip)
1270               {
1271                  TEXTURE_PIPELINE(&texel0_color, st, ss, tex_tile);
1272               }
1273               else
1274               {
1275                  TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
1276               }
1277
1278463               curpixel_cvg = 8;
1279464
1280465               if ((texel0_color.i.a != 0)||(!other_modes.alpha_compare_en))
r6714r6715
1289474   }
1290475}
1291476
1292static void texture_rectangle_16bit_cf_zc_zu(running_machine *machine, TEX_RECTANGLE *rect)
477#if defined(ZCOMPARE)
478   #if defined(ZUPDATE)
479      #if defined(MAGICDITHER)
480         static void texture_rectangle_16bit_cf_zc_zu_dm(TEX_RECTANGLE *rect)
481      #elif defined(BAYERDITHER)
482         static void texture_rectangle_16bit_cf_zc_zu_db(TEX_RECTANGLE *rect)
483      #else
484         static void texture_rectangle_16bit_cf_zc_zu_dn(TEX_RECTANGLE *rect)
485      #endif
486   #else
487      #if defined(MAGICDITHER)
488         static void texture_rectangle_16bit_cf_zc_nzu_dm(TEX_RECTANGLE *rect)
489      #elif defined(BAYERDITHER)
490         static void texture_rectangle_16bit_cf_zc_nzu_db(TEX_RECTANGLE *rect)
491      #else
492         static void texture_rectangle_16bit_cf_zc_nzu_dn(TEX_RECTANGLE *rect)
493      #endif
494   #endif
495#else
496   #if defined(ZUPDATE)
497      #if defined(MAGICDITHER)
498         static void texture_rectangle_16bit_cf_nzc_zu_dm(TEX_RECTANGLE *rect)
499      #elif defined(BAYERDITHER)
500         static void texture_rectangle_16bit_cf_nzc_zu_db(TEX_RECTANGLE *rect)
501      #else
502         static void texture_rectangle_16bit_cf_nzc_zu_dn(TEX_RECTANGLE *rect)
503      #endif
504   #else
505      #if defined(MAGICDITHER)
506         static void texture_rectangle_16bit_cf_nzc_nzu_dm(TEX_RECTANGLE *rect)
507      #elif defined(BAYERDITHER)
508         static void texture_rectangle_16bit_cf_nzc_nzu_db(TEX_RECTANGLE *rect)
509      #else
510         static void texture_rectangle_16bit_cf_nzc_nzu_dn(TEX_RECTANGLE *rect)
511      #endif
512   #endif
513#endif
1293514{
1294515   fatalerror("texture_rectangle with FILL cycle type is not supported\n");
1295516}
1296
src/mame/video/rdpacvg.h
r6714r6715
1INLINE UINT8 alpha_cvg_get_cta_ca(UINT8 comb_alpha);
2INLINE UINT8 alpha_cvg_get_ncta_ca(UINT8 comb_alpha);
3INLINE UINT8 alpha_cvg_get_cta_nca(UINT8 comb_alpha);
4INLINE UINT8 alpha_cvg_get_ncta_nca(UINT8 comb_alpha);
1INLINE void alpha_cvg_get_cta_ca(UINT8 *comb_alpha);
2INLINE void alpha_cvg_get_ncta_ca(UINT8 *comb_alpha);
3INLINE void alpha_cvg_get_cta_nca(UINT8 *comb_alpha);
4INLINE void alpha_cvg_get_ncta_nca(UINT8 *comb_alpha);
55
6static UINT8 (*rdp_alpha_cvg_func[4])(UINT8) =
6static void (*rdp_alpha_cvg_func[4])(UINT8*) =
77{
88   alpha_cvg_get_ncta_nca, alpha_cvg_get_ncta_ca, alpha_cvg_get_cta_nca, alpha_cvg_get_cta_ca,
99};
src/mame/video/rdptrect.h
r6714r6715
1static void texture_rectangle_16bit_c1_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
2static void texture_rectangle_16bit_c2_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
3static void texture_rectangle_16bit_cc_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
4static void texture_rectangle_16bit_cf_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
5static void texture_rectangle_16bit_c1_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
6static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
7static void texture_rectangle_16bit_cc_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
8static void texture_rectangle_16bit_cf_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
9static void texture_rectangle_16bit_c1_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
10static void texture_rectangle_16bit_c2_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
11static void texture_rectangle_16bit_cc_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
12static void texture_rectangle_16bit_cf_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
13static void texture_rectangle_16bit_c1_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
14static void texture_rectangle_16bit_c2_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
15static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
16static void texture_rectangle_16bit_cf_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
17static void texture_rectangle_16bit_c1_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
18static void texture_rectangle_16bit_c2_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
19static void texture_rectangle_16bit_cc_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
20static void texture_rectangle_16bit_cf_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
21static void texture_rectangle_16bit_c1_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
22static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
23static void texture_rectangle_16bit_cc_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
24static void texture_rectangle_16bit_cf_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
25static void texture_rectangle_16bit_c1_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
26static void texture_rectangle_16bit_c2_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
27static void texture_rectangle_16bit_cc_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
28static void texture_rectangle_16bit_cf_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
29static void texture_rectangle_16bit_c1_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
30static void texture_rectangle_16bit_c2_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
31static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
32static void texture_rectangle_16bit_cf_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
1static void texture_rectangle_16bit_c1_nzc_nzu_dm(TEX_RECTANGLE *rect);
2static void texture_rectangle_16bit_c1_nzc_nzu_db(TEX_RECTANGLE *rect);
3static void texture_rectangle_16bit_c1_nzc_nzu_dn(TEX_RECTANGLE *rect);
4static void texture_rectangle_16bit_c2_nzc_nzu_dm(TEX_RECTANGLE *rect);
5static void texture_rectangle_16bit_c2_nzc_nzu_db(TEX_RECTANGLE *rect);
6static void texture_rectangle_16bit_c2_nzc_nzu_dn(TEX_RECTANGLE *rect);
7static void texture_rectangle_16bit_cc_nzc_nzu_dm(TEX_RECTANGLE *rect);
8static void texture_rectangle_16bit_cc_nzc_nzu_db(TEX_RECTANGLE *rect);
9static void texture_rectangle_16bit_cc_nzc_nzu_dn(TEX_RECTANGLE *rect);
10static void texture_rectangle_16bit_cf_nzc_nzu_dm(TEX_RECTANGLE *rect);
11static void texture_rectangle_16bit_cf_nzc_nzu_db(TEX_RECTANGLE *rect);
12static void texture_rectangle_16bit_cf_nzc_nzu_dn(TEX_RECTANGLE *rect);
13static void texture_rectangle_16bit_c1_zc_nzu_dm(TEX_RECTANGLE *rect);
14static void texture_rectangle_16bit_c1_zc_nzu_db(TEX_RECTANGLE *rect);
15static void texture_rectangle_16bit_c1_zc_nzu_dn(TEX_RECTANGLE *rect);
16static void texture_rectangle_16bit_c2_zc_nzu_dm(TEX_RECTANGLE *rect);
17static void texture_rectangle_16bit_c2_zc_nzu_db(TEX_RECTANGLE *rect);
18static void texture_rectangle_16bit_c2_zc_nzu_dn(TEX_RECTANGLE *rect);
19static void texture_rectangle_16bit_cc_zc_nzu_dm(TEX_RECTANGLE *rect);
20static void texture_rectangle_16bit_cc_zc_nzu_db(TEX_RECTANGLE *rect);
21static void texture_rectangle_16bit_cc_zc_nzu_dn(TEX_RECTANGLE *rect);
22static void texture_rectangle_16bit_cf_zc_nzu_dm(TEX_RECTANGLE *rect);
23static void texture_rectangle_16bit_cf_zc_nzu_db(TEX_RECTANGLE *rect);
24static void texture_rectangle_16bit_cf_zc_nzu_dn(TEX_RECTANGLE *rect);
25static void texture_rectangle_16bit_c1_nzc_zu_dm(TEX_RECTANGLE *rect);
26static void texture_rectangle_16bit_c1_nzc_zu_db(TEX_RECTANGLE *rect);
27static void texture_rectangle_16bit_c1_nzc_zu_dn(TEX_RECTANGLE *rect);
28static void texture_rectangle_16bit_c2_nzc_zu_dm(TEX_RECTANGLE *rect);
29static void texture_rectangle_16bit_c2_nzc_zu_db(TEX_RECTANGLE *rect);
30static void texture_rectangle_16bit_c2_nzc_zu_dn(TEX_RECTANGLE *rect);
31static void texture_rectangle_16bit_cc_nzc_zu_dm(TEX_RECTANGLE *rect);
32static void texture_rectangle_16bit_cc_nzc_zu_db(TEX_RECTANGLE *rect);
33static void texture_rectangle_16bit_cc_nzc_zu_dn(TEX_RECTANGLE *rect);
34static void texture_rectangle_16bit_cf_nzc_zu_dm(TEX_RECTANGLE *rect);
35static void texture_rectangle_16bit_cf_nzc_zu_db(TEX_RECTANGLE *rect);
36static void texture_rectangle_16bit_cf_nzc_zu_dn(TEX_RECTANGLE *rect);
37static void texture_rectangle_16bit_c1_zc_zu_dm(TEX_RECTANGLE *rect);
38static void texture_rectangle_16bit_c1_zc_zu_db(TEX_RECTANGLE *rect);
39static void texture_rectangle_16bit_c1_zc_zu_dn(TEX_RECTANGLE *rect);
40static void texture_rectangle_16bit_c2_zc_zu_dm(TEX_RECTANGLE *rect);
41static void texture_rectangle_16bit_c2_zc_zu_db(TEX_RECTANGLE *rect);
42static void texture_rectangle_16bit_c2_zc_zu_dn(TEX_RECTANGLE *rect);
43static void texture_rectangle_16bit_cc_zc_zu_dm(TEX_RECTANGLE *rect);
44static void texture_rectangle_16bit_cc_zc_zu_db(TEX_RECTANGLE *rect);
45static void texture_rectangle_16bit_cc_zc_zu_dn(TEX_RECTANGLE *rect);
46static void texture_rectangle_16bit_cf_zc_zu_dm(TEX_RECTANGLE *rect);
47static void texture_rectangle_16bit_cf_zc_zu_db(TEX_RECTANGLE *rect);
48static void texture_rectangle_16bit_cf_zc_zu_dn(TEX_RECTANGLE *rect);
3349
34static void (*rdp_texture_rectangle_16bit_func[16])(running_machine *, TEX_RECTANGLE *) =
50static void (*rdp_texture_rectangle_16bit_func[48])(TEX_RECTANGLE *) =
3551{
36   texture_rectangle_16bit_c1_nzc_nzu,   texture_rectangle_16bit_c2_nzc_nzu,   texture_rectangle_16bit_cc_nzc_nzu,   texture_rectangle_16bit_cf_nzc_nzu,
37   texture_rectangle_16bit_c1_zc_nzu,   texture_rectangle_16bit_c2_zc_nzu,   texture_rectangle_16bit_cc_zc_nzu,   texture_rectangle_16bit_cf_zc_nzu,
38   texture_rectangle_16bit_c1_nzc_zu,   texture_rectangle_16bit_c2_nzc_zu,   texture_rectangle_16bit_cc_nzc_zu,   texture_rectangle_16bit_cf_nzc_zu,
39   texture_rectangle_16bit_c1_zc_zu,   texture_rectangle_16bit_c2_zc_zu,   texture_rectangle_16bit_cc_zc_zu,   texture_rectangle_16bit_cf_zc_zu,
52   texture_rectangle_16bit_c1_nzc_nzu_dm, texture_rectangle_16bit_c1_nzc_nzu_db, texture_rectangle_16bit_c1_nzc_nzu_dn,
53   texture_rectangle_16bit_c2_nzc_nzu_dm, texture_rectangle_16bit_c2_nzc_nzu_db, texture_rectangle_16bit_c2_nzc_nzu_dn,
54   texture_rectangle_16bit_cc_nzc_nzu_dm, texture_rectangle_16bit_cc_nzc_nzu_db, texture_rectangle_16bit_cc_nzc_nzu_dn,
55   texture_rectangle_16bit_cf_nzc_nzu_dm, texture_rectangle_16bit_cf_nzc_nzu_db, texture_rectangle_16bit_cf_nzc_nzu_dn,
56   texture_rectangle_16bit_c1_zc_nzu_dm, texture_rectangle_16bit_c1_zc_nzu_db, texture_rectangle_16bit_c1_zc_nzu_dn,
57   texture_rectangle_16bit_c2_zc_nzu_dm, texture_rectangle_16bit_c2_zc_nzu_db, texture_rectangle_16bit_c2_zc_nzu_dn,
58   texture_rectangle_16bit_cc_zc_nzu_dm, texture_rectangle_16bit_cc_zc_nzu_db, texture_rectangle_16bit_cc_zc_nzu_dn,
59   texture_rectangle_16bit_cf_zc_nzu_dm, texture_rectangle_16bit_cf_zc_nzu_db, texture_rectangle_16bit_cf_zc_nzu_dn,
60   texture_rectangle_16bit_c1_nzc_zu_dm, texture_rectangle_16bit_c1_nzc_zu_db, texture_rectangle_16bit_c1_nzc_zu_dn,
61   texture_rectangle_16bit_c2_nzc_zu_dm, texture_rectangle_16bit_c2_nzc_zu_db, texture_rectangle_16bit_c2_nzc_zu_dn,
62   texture_rectangle_16bit_cc_nzc_zu_dm, texture_rectangle_16bit_cc_nzc_zu_db, texture_rectangle_16bit_cc_nzc_zu_dn,
63   texture_rectangle_16bit_cf_nzc_zu_dm, texture_rectangle_16bit_cf_nzc_zu_db, texture_rectangle_16bit_cf_nzc_zu_dn,
64   texture_rectangle_16bit_c1_zc_zu_dm, texture_rectangle_16bit_c1_zc_zu_db, texture_rectangle_16bit_c1_zc_zu_dn,
65   texture_rectangle_16bit_c2_zc_zu_dm, texture_rectangle_16bit_c2_zc_zu_db, texture_rectangle_16bit_c2_zc_zu_dn,
66   texture_rectangle_16bit_cc_zc_zu_dm, texture_rectangle_16bit_cc_zc_zu_db, texture_rectangle_16bit_cc_zc_zu_dn,
67   texture_rectangle_16bit_cf_zc_zu_dm, texture_rectangle_16bit_cf_zc_zu_db, texture_rectangle_16bit_cf_zc_zu_dn,
4068};
4169
src/mame/video/rdpacomp.c
r6714r6715
1INLINE int alpha_compare_nac_nda(running_machine *machine, UINT8 comb_alpha)
1INLINE int alpha_compare_nac_nda(UINT8 comb_alpha)
22{
33   return 1;
44}
55
6INLINE int alpha_compare_nac_da(running_machine *machine, UINT8 comb_alpha)
6INLINE int alpha_compare_nac_da(UINT8 comb_alpha)
77{
88   return 1;
99}
1010
11INLINE int alpha_compare_ac_nda(running_machine *machine, UINT8 comb_alpha)
11INLINE int alpha_compare_ac_nda(UINT8 comb_alpha)
1212{
1313   if (comb_alpha < blend_color.i.a)
1414   {
r6714r6715
1717   return 1;
1818}
1919
20INLINE int alpha_compare_ac_da(running_machine *machine, UINT8 comb_alpha)
20INLINE int alpha_compare_ac_da(UINT8 comb_alpha)
2121{
22   if (comb_alpha < (mame_rand(machine) & 0xff))
22   if (comb_alpha < (rdp_rand() & 0xff))
2323   {
2424      return 0;
2525   }
src/mame/video/rdpacomp.h
r6714r6715
1INLINE int alpha_compare_nac_nda(running_machine *machine, UINT8 comb_alpha);
2INLINE int alpha_compare_nac_da(running_machine *machine, UINT8 comb_alpha);
3INLINE int alpha_compare_ac_nda(running_machine *machine, UINT8 comb_alpha);
4INLINE int alpha_compare_ac_da(running_machine *machine, UINT8 comb_alpha);
1INLINE int alpha_compare_nac_nda(UINT8 comb_alpha);
2INLINE int alpha_compare_nac_da(UINT8 comb_alpha);
3INLINE int alpha_compare_ac_nda(UINT8 comb_alpha);
4INLINE int alpha_compare_ac_da(UINT8 comb_alpha);
55
6static int (*rdp_alpha_compare_func[4])(running_machine *, UINT8) =
6static int (*rdp_alpha_compare_func[4])(UINT8) =
77{
88   alpha_compare_nac_nda, alpha_compare_nac_da, alpha_compare_ac_nda, alpha_compare_ac_da
99};
src/mame/video/rdpfb.c
r6714r6715
1INLINE UINT32 FBWRITE_16_RDEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
1#if defined(COLOR_ON_CVG)
2   INLINE UINT32 FBWRITE_16_RDEN_CVGD0_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
3#else
4   INLINE UINT32 FBWRITE_16_RDEN_CVGD0_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
5#endif
26{
37#undef CVG_DRAW
48   UINT16 finalcolor;
r6714r6715
2428      curpixel_overlap = 0;
2529   }
2630
27   if (curpixel_cvg > 8)
28   {
29      fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
30   }
31
3231   newcvg = curpixel_cvg + memory_cvg;
3332   wrapflag = (newcvg > 8) ? 1 : 0;
3433
r6714r6715
3736   clampcvg = (newcvg > 8) ? 8 : newcvg;
3837   newcvg = (wrapflag)? (newcvg - 8) : newcvg;
3938
40   if (!curpixel_cvg)
41   {
42      fatalerror("cvg underflow");
43   }
44
4539   curpixel_cvg--;
4640   newcvg--;
4741   memory_cvg--;
4842   clampcvg--;
4943
50   if (other_modes.color_on_cvg && !wrapflag)
44#if defined(COLOR_ON_CVG)
45   if (!wrapflag)
5146   {
5247      *fb &= 0xfffe;
5348      *fb |= ((newcvg >> 2) & 1);
5449      *hb = (newcvg & 3);
5550      return 0;
5651   }
52#endif
5753
5854   if (!other_modes.force_blend && !curpixel_overlap)
5955   {
r6714r6715
6864   return 1;
6965}
7066
71INLINE UINT32 FBWRITE_16_RDEN_CVGD1(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
67#if defined(COLOR_ON_CVG)
68   INLINE UINT32 FBWRITE_16_RDEN_CVGD1_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
69#else
70   INLINE UINT32 FBWRITE_16_RDEN_CVGD1_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
71#endif
7272{
7373#undef CVG_DRAW
7474   UINT16 finalcolor;
r6714r6715
9494      curpixel_overlap = 0;
9595   }
9696
97   if (curpixel_cvg > 8)
98   {
99      fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
100   }
101
10297   newcvg = curpixel_cvg + memory_cvg;
10398   wrapflag = (newcvg > 8) ? 1 : 0;
10499
r6714r6715
107102   clampcvg = (newcvg > 8) ? 8 : newcvg;
108103   newcvg = (wrapflag)? (newcvg - 8) : newcvg;
109104
110   if (!curpixel_cvg)
111   {
112      fatalerror("cvg underflow");
113   }
114
115105   curpixel_cvg--;
116106   newcvg--;
117107   memory_cvg--;
118108   clampcvg--;
119109
120   if (other_modes.color_on_cvg && !wrapflag)
110#if defined(COLOR_ON_CVG)
111   if (!wrapflag)
121112   {
122113      *fb &= 0xfffe;
123114      *fb |= ((newcvg >> 2) & 1);
124115      *hb = (newcvg & 3);
125116      return 0;
126117   }
118#endif
127119
128120   *fb = finalcolor|((newcvg >> 2) & 1);
129121   *hb = (newcvg & 3);
130122   return 1;
131123}
132124
133INLINE UINT32 FBWRITE_16_RDEN_CVGD2(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
125#if defined(COLOR_ON_CVG)
126   INLINE UINT32 FBWRITE_16_RDEN_CVGD2_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
127#else
128   INLINE UINT32 FBWRITE_16_RDEN_CVGD2_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
129#endif
134130{
135131#undef CVG_DRAW
136132   UINT16 finalcolor;
r6714r6715
156152      curpixel_overlap = 0;
157153   }
158154
159   if (curpixel_cvg > 8)
160   {
161      fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
162   }
163
164155   newcvg = curpixel_cvg + memory_cvg;
165156   wrapflag = (newcvg > 8) ? 1 : 0;
166157
r6714r6715
169160   clampcvg = (newcvg > 8) ? 8 : newcvg;
170161   newcvg = (wrapflag)? (newcvg - 8) : newcvg;
171162
172   if (!curpixel_cvg)
173   {
174      fatalerror("cvg underflow");
175   }
176
177163   curpixel_cvg--;
178164   newcvg--;
179165   memory_cvg--;
180166   clampcvg--;
181167
182   if (other_modes.color_on_cvg && !wrapflag)
168#if defined(COLOR_ON_CVG)
169   if (!wrapflag)
183170   {
184171      *fb &= 0xfffe;
185172      *fb |= ((newcvg >> 2) & 1);
186173      *hb = (newcvg & 3);
187174      return 0;
188175   }
176#endif
189177
190178   *fb = finalcolor|1;
191179   *hb = 3;
192180   return 1;
193181}
194182
195INLINE UINT32 FBWRITE_16_RDEN_CVGD3(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
183#if defined(COLOR_ON_CVG)
184   INLINE UINT32 FBWRITE_16_RDEN_CVGD3_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
185#else
186   INLINE UINT32 FBWRITE_16_RDEN_CVGD3_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
187#endif
196188{
197189#undef CVG_DRAW
198190   UINT16 finalcolor;
r6714r6715
218210      curpixel_overlap = 0;
219211   }
220212
221   if (curpixel_cvg > 8)
222   {
223      fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
224   }
225
226213   newcvg = curpixel_cvg + memory_cvg;
227214   wrapflag = (newcvg > 8) ? 1 : 0;
228215
r6714r6715
231218   clampcvg = (newcvg > 8) ? 8 : newcvg;
232219   newcvg = (wrapflag)? (newcvg - 8) : newcvg;
233220
234   if (!curpixel_cvg)
235   {
236      fatalerror("cvg underflow");
237   }
238
239221   curpixel_cvg--;
240222   newcvg--;
241223   memory_cvg--;
242224   clampcvg--;
243225
244   if (other_modes.color_on_cvg && !wrapflag)
226#if defined(COLOR_ON_CVG)
227   if (!wrapflag)
245228   {
246229      *fb &= 0xfffe;
247230      *fb |= ((newcvg >> 2) & 1);
248231      *hb = (newcvg & 3);
249232      return 0;
250233   }
234#endif
251235
252236   *fb = finalcolor|((memory_cvg >> 2) & 1);
253237   *hb = (memory_cvg & 3);
254238   return 1;
255239}
256240
257INLINE UINT32 FBWRITE_16_RDNEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
241#if defined(COLOR_ON_CVG)
242   INLINE UINT32 FBWRITE_16_RDNEN_CVGD0_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
243#else
244   INLINE UINT32 FBWRITE_16_RDNEN_CVGD0_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
245#endif
258246{
259247#undef CVG_DRAW
260248   UINT16 finalcolor;
r6714r6715
279267      curpixel_overlap = 0;
280268   }
281269
282   if (curpixel_cvg > 8)
283   {
284      fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
285   }
286
287270   newcvg = curpixel_cvg + 8;
288271   wrapflag = (newcvg > 8) ? 1 : 0;
289272
r6714r6715
292275   clampcvg = (newcvg > 8) ? 8 : newcvg;
293276   newcvg = (wrapflag)? (newcvg - 8) : newcvg;
294277
295   if (!curpixel_cvg)
296   {
297      fatalerror("cvg underflow");
298   }
299
300278   curpixel_cvg--;
301279   newcvg--;
302280   clampcvg--;
303281
304   if (other_modes.color_on_cvg && !wrapflag)
282#if defined(COLOR_ON_CVG)
283   if (!wrapflag)
305284   {
306285      *fb &= 0xfffe;
307286      *fb |= ((newcvg >> 2) & 1);
308287      *hb = (newcvg & 3);
309288      return 0;
310289   }
290#endif
311291
312292   if (!other_modes.force_blend && !curpixel_overlap)
313293   {
r6714r6715
322302   return 1;
323303}
324304
325INLINE UINT32 FBWRITE_16_RDNEN_CVGD1(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
305#if defined(COLOR_ON_CVG)
306   INLINE UINT32 FBWRITE_16_RDNEN_CVGD1_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
307#else
308   INLINE UINT32 FBWRITE_16_RDNEN_CVGD1_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
309#endif
326310{
327311#undef CVG_DRAW
328312   UINT16 finalcolor;
r6714r6715
347331      curpixel_overlap = 0;
348332   }
349333
350   if (curpixel_cvg > 8)
351   {
352      fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
353   }
354
355334   newcvg = curpixel_cvg + 8;
356335   wrapflag = (newcvg > 8) ? 1 : 0;
357336
r6714r6715
360339   clampcvg = (newcvg > 8) ? 8 : newcvg;
361340   newcvg = (wrapflag)? (newcvg - 8) : newcvg;
362341
363   if (!curpixel_cvg)
364   {
365      fatalerror("cvg underflow");
366   }
367
368342   curpixel_cvg--;
369343   newcvg--;
370344   clampcvg--;
371345
372   if (other_modes.color_on_cvg && !wrapflag)
346#if defined(COLOR_ON_CVG)
347   if (!wrapflag)
373348   {
374349      *fb &= 0xfffe;
375350      *fb |= ((newcvg >> 2) & 1);
376351      *hb = (newcvg & 3);
377352      return 0;
378353   }
354#endif
379355
380356   *fb = finalcolor|1;
381357   *hb = 3;
382358   return 1;
383359}
384360
385INLINE UINT32 FBWRITE_16_RDNEN_CVGD2(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
361#if defined(COLOR_ON_CVG)
362   INLINE UINT32 FBWRITE_16_RDNEN_CVGD2_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
363#else
364   INLINE UINT32 FBWRITE_16_RDNEN_CVGD2_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
365#endif
386366{
387367#undef CVG_DRAW
388368   UINT16 finalcolor;
r6714r6715
407387      curpixel_overlap = 0;
408388   }
409389
410   if (curpixel_cvg > 8)
411   {
412      fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
413   }
414
415390   newcvg = curpixel_cvg + 8;
416391   wrapflag = (newcvg > 8) ? 1 : 0;
417392
r6714r6715
420395   clampcvg = (newcvg > 8) ? 8 : newcvg;
421396   newcvg = (wrapflag)? (newcvg - 8) : newcvg;
422397
423   if (!curpixel_cvg)
424   {
425      fatalerror("cvg underflow");
426   }
427
428398   curpixel_cvg--;
429399   newcvg--;
430400   clampcvg--;
431401
432   if (other_modes.color_on_cvg && !wrapflag)
402#if defined(COLOR_ON_CVG)
403   if (!wrapflag)
433404   {
434405      *fb &= 0xfffe;
435406      *fb |= ((newcvg >> 2) & 1);
436407      *hb = (newcvg & 3);
437408      return 0;
438409   }
410#endif
439411
440412   *fb = finalcolor|1;
441413   *hb = 3;
442414   return 1;
443415}
444416
445INLINE UINT32 FBWRITE_16_RDNEN_CVGD3(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
417#if defined(COLOR_ON_CVG)
418   INLINE UINT32 FBWRITE_16_RDNEN_CVGD3_COC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
419#else
420   INLINE UINT32 FBWRITE_16_RDNEN_CVGD3_NCOC(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
421#endif
446422{
447423#undef CVG_DRAW
448424   UINT16 finalcolor;
r6714r6715
467443      curpixel_overlap = 0;
468444   }
469445
470   if (curpixel_cvg > 8)
471   {
472      fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
473   }
474
475446   newcvg = curpixel_cvg + 8;
476447   wrapflag = (newcvg > 8) ? 1 : 0;
477448
r6714r6715
480451   clampcvg = (newcvg > 8) ? 8 : newcvg;
481452   newcvg = (wrapflag)? (newcvg - 8) : newcvg;
482453
483   if (!curpixel_cvg)
484   {
485      fatalerror("cvg underflow");
486   }
487
488454   curpixel_cvg--;
489455   newcvg--;
490456   clampcvg--;
491457
492   if (other_modes.color_on_cvg && !wrapflag)
458#if defined(COLOR_ON_CVG)
459   if (!wrapflag)
493460   {
494461      *fb &= 0xfffe;
495462      *fb |= ((newcvg >> 2) & 1);
496463      *hb = (newcvg & 3);
497464      return 0;
498465   }
466#endif
499467
500468   *fb = finalcolor|1;
501469   *hb = 4;
502470   return 1;
503471}
504472
505INLINE UINT32 FBWRITE_32_RDEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
473#if defined(COLOR_ON_CVG)
474   INLINE UINT32 FBWRITE_32_RDEN_CVGD0_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
475#else
476   INLINE UINT32 FBWRITE_32_RDEN_CVGD0_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
477#endif
506478{
507479   UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
508480   UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
r6714r6715
520492   memory_cvg--;
521493   clampcvg--;
522494
523   if (other_modes.color_on_cvg && !wrapflag)
495#if defined(COLOR_ON_CVG)
496   if (!wrapflag)
524497   {
525498      *fb &= 0xffffff00;
526499      *fb |= ((newcvg << 5) & 0xff);
527500      return 0;
528501   }
502#endif
529503
530504   if (!other_modes.force_blend && !curpixel_overlap)
531505   {
r6714r6715
538512   return 1;
539513}
540514
541INLINE UINT32 FBWRITE_32_RDEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
515#if defined(COLOR_ON_CVG)
516   INLINE UINT32 FBWRITE_32_RDEN_CVGD1_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
517#else
518   INLINE UINT32 FBWRITE_32_RDEN_CVGD1_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
519#endif
542520{
543521   UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
544522   UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
r6714r6715
556534   memory_cvg--;
557535   clampcvg--;
558536
559   if (other_modes.color_on_cvg && !wrapflag)
537#if defined(COLOR_ON_CVG)
538   if (!wrapflag)
560539   {
561540      *fb &= 0xffffff00;
562541      *fb |= ((newcvg << 5) & 0xff);
563542      return 0;
564543   }
544#endif
565545
566546   *fb = finalcolor | (newcvg << 5);
567547   return 1;
568548}
569549
570INLINE UINT32 FBWRITE_32_RDEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
550#if defined(COLOR_ON_CVG)
551   INLINE UINT32 FBWRITE_32_RDEN_CVGD2_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
552#else
553   INLINE UINT32 FBWRITE_32_RDEN_CVGD2_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
554#endif
571555{
572556   UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
573557   UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
r6714r6715
585569   memory_cvg--;
586570   clampcvg--;
587571
588   if (other_modes.color_on_cvg && !wrapflag)
572#if defined(COLOR_ON_CVG)
573   if (!wrapflag)
589574   {
590575      *fb &= 0xffffff00;
591576      *fb |= ((newcvg << 5) & 0xff);
592577      return 0;
593578   }
579#endif
594580
595581   *fb = finalcolor | 0xE0;
596582   return 1;
597583}
598584
599INLINE UINT32 FBWRITE_32_RDEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
585#if defined(COLOR_ON_CVG)
586   INLINE UINT32 FBWRITE_32_RDEN_CVGD3_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
587#else
588   INLINE UINT32 FBWRITE_32_RDEN_CVGD3_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
589#endif
600590{
601591   UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
602592   UINT32 memory_alphachannel = *fb & 0xff;
r6714r6715
615605   memory_cvg--;
616606   clampcvg--;
617607
618   if (other_modes.color_on_cvg && !wrapflag)
608#if defined(COLOR_ON_CVG)
609   if (!wrapflag)
619610   {
620611      *fb &= 0xffffff00;
621612      *fb |= ((newcvg << 5) & 0xff);
622613      return 0;
623614   }
615#endif
624616
625617   *fb = finalcolor | memory_alphachannel;
626618   return 1;
627619}
628620
629INLINE UINT32 FBWRITE_32_RDNEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
621#if defined(COLOR_ON_CVG)
622   INLINE UINT32 FBWRITE_32_RDNEN_CVGD0_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
623#else
624   INLINE UINT32 FBWRITE_32_RDNEN_CVGD0_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
625#endif
630626{
631627   UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
632628   UINT32 newcvg;
r6714r6715
642638   newcvg--;
643639   clampcvg--;
644640
645   if (other_modes.color_on_cvg && !wrapflag)
641#if defined(COLOR_ON_CVG)
642   if (!wrapflag)
646643   {
647644      *fb &= 0xffffff00;
648645      *fb |= ((newcvg << 5) & 0xff);
649646      return 0;
650647   }
648#endif
651649
652650   if (!other_modes.force_blend && !curpixel_overlap)
653651   {
r6714r6715
660658   return 1;
661659}
662660
663INLINE UINT32 FBWRITE_32_RDNEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
661#if defined(COLOR_ON_CVG)
662   INLINE UINT32 FBWRITE_32_RDNEN_CVGD1_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
663#else
664   INLINE UINT32 FBWRITE_32_RDNEN_CVGD1_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
665#endif
664666{
665667   UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
666668   UINT32 newcvg;
r6714r6715
676678   newcvg--;
677679   clampcvg--;
678680
679   if (other_modes.color_on_cvg && !wrapflag)
681#if defined(COLOR_ON_CVG)
682   if (!wrapflag)
680683   {
681684      *fb &= 0xffffff00;
682685      *fb |= ((newcvg << 5) & 0xff);
683686      return 0;
684687   }
688#endif
685689
686690   *fb = finalcolor | (newcvg << 5);
687691   return 1;
688692}
689693
690INLINE UINT32 FBWRITE_32_RDNEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
694#if defined(COLOR_ON_CVG)
695   INLINE UINT32 FBWRITE_32_RDNEN_CVGD2_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
696#else
697   INLINE UINT32 FBWRITE_32_RDNEN_CVGD2_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
698#endif
691699{
692700   UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
693701   UINT32 newcvg;
r6714r6715
703711   newcvg--;
704712   clampcvg--;
705713
706   if (other_modes.color_on_cvg && !wrapflag)
714#if defined(COLOR_ON_CVG)
715   if (!wrapflag)
707716   {
708717      *fb &= 0xffffff00;
709718      *fb |= ((newcvg << 5) & 0xff);
710719      return 0;
711720   }
721#endif
712722
713723   *fb = finalcolor | 0xE0;
714724   return 1;
715725}
716726
717INLINE UINT32 FBWRITE_32_RDNEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
727#if defined(COLOR_ON_CVG)
728   INLINE UINT32 FBWRITE_32_RDNEN_CVGD3_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
729#else
730   INLINE UINT32 FBWRITE_32_RDNEN_CVGD3_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
731#endif
718732{
719733   UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
720734   UINT32 memory_alphachannel = *fb & 0xff;
r6714r6715
731745   newcvg--;
732746   clampcvg--;
733747
734   if (other_modes.color_on_cvg && !wrapflag)
748#if defined(COLOR_ON_CVG)
749   if (!wrapflag)
735750   {
736751      *fb &= 0xffffff00;
737752      *fb |= ((newcvg << 5) & 0xff);
738753      return 0;
739754   }
755#endif
740756
741757   *fb = finalcolor | memory_alphachannel;
742758   return 1;
src/mame/video/rdpfb.h
r6714r6715
1INLINE UINT32 FBWRITE_16_RDEN_CVGD0(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
2INLINE UINT32 FBWRITE_16_RDEN_CVGD1(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
3INLINE UINT32 FBWRITE_16_RDEN_CVGD2(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
4INLINE UINT32 FBWRITE_16_RDEN_CVGD3(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
5INLINE UINT32 FBWRITE_16_RDNEN_CVGD0(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
6INLINE UINT32 FBWRITE_16_RDNEN_CVGD1(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
7INLINE UINT32 FBWRITE_16_RDNEN_CVGD2(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
8INLINE UINT32 FBWRITE_16_RDNEN_CVGD3(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
1INLINE UINT32 FBWRITE_16_RDEN_CVGD0_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
2INLINE UINT32 FBWRITE_16_RDEN_CVGD0_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
3INLINE UINT32 FBWRITE_16_RDEN_CVGD1_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
4INLINE UINT32 FBWRITE_16_RDEN_CVGD1_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
5INLINE UINT32 FBWRITE_16_RDEN_CVGD2_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
6INLINE UINT32 FBWRITE_16_RDEN_CVGD2_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
7INLINE UINT32 FBWRITE_16_RDEN_CVGD3_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
8INLINE UINT32 FBWRITE_16_RDEN_CVGD3_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
9INLINE UINT32 FBWRITE_16_RDNEN_CVGD0_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
10INLINE UINT32 FBWRITE_16_RDNEN_CVGD0_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
11INLINE UINT32 FBWRITE_16_RDNEN_CVGD1_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
12INLINE UINT32 FBWRITE_16_RDNEN_CVGD1_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
13INLINE UINT32 FBWRITE_16_RDNEN_CVGD2_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
14INLINE UINT32 FBWRITE_16_RDNEN_CVGD2_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
15INLINE UINT32 FBWRITE_16_RDNEN_CVGD3_NCOC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
16INLINE UINT32 FBWRITE_16_RDNEN_CVGD3_COC(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
917
10INLINE UINT32 FBWRITE_32_RDEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
11INLINE UINT32 FBWRITE_32_RDEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
12INLINE UINT32 FBWRITE_32_RDEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
13INLINE UINT32 FBWRITE_32_RDEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
14INLINE UINT32 FBWRITE_32_RDNEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
15INLINE UINT32 FBWRITE_32_RDNEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
16INLINE UINT32 FBWRITE_32_RDNEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
17INLINE UINT32 FBWRITE_32_RDNEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
18INLINE UINT32 FBWRITE_32_RDEN_CVGD0_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
19INLINE UINT32 FBWRITE_32_RDEN_CVGD0_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
20INLINE UINT32 FBWRITE_32_RDEN_CVGD1_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
21INLINE UINT32 FBWRITE_32_RDEN_CVGD1_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
22INLINE UINT32 FBWRITE_32_RDEN_CVGD2_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
23INLINE UINT32 FBWRITE_32_RDEN_CVGD2_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
24INLINE UINT32 FBWRITE_32_RDEN_CVGD3_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
25INLINE UINT32 FBWRITE_32_RDEN_CVGD3_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
26INLINE UINT32 FBWRITE_32_RDNEN_CVGD0_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
27INLINE UINT32 FBWRITE_32_RDNEN_CVGD0_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
28INLINE UINT32 FBWRITE_32_RDNEN_CVGD1_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
29INLINE UINT32 FBWRITE_32_RDNEN_CVGD1_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
30INLINE UINT32 FBWRITE_32_RDNEN_CVGD2_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
31INLINE UINT32 FBWRITE_32_RDNEN_CVGD2_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
32INLINE UINT32 FBWRITE_32_RDNEN_CVGD3_NCOC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
33INLINE UINT32 FBWRITE_32_RDNEN_CVGD3_COC(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
1834
19static UINT32 (*rdp_fbwrite_16_func[8])(UINT16*, UINT8*, UINT32, UINT32, UINT32) =
35static UINT32 (*rdp_fbwrite_16_func[16])(UINT16*, UINT8*, UINT32, UINT32, UINT32) =
2036{
21   FBWRITE_16_RDNEN_CVGD0,   FBWRITE_16_RDNEN_CVGD1,   FBWRITE_16_RDNEN_CVGD2,   FBWRITE_16_RDNEN_CVGD3,
22   FBWRITE_16_RDEN_CVGD0,   FBWRITE_16_RDEN_CVGD1,   FBWRITE_16_RDEN_CVGD2,   FBWRITE_16_RDEN_CVGD3,
37   FBWRITE_16_RDNEN_CVGD0_NCOC,   FBWRITE_16_RDNEN_CVGD1_NCOC,   FBWRITE_16_RDNEN_CVGD2_NCOC,   FBWRITE_16_RDNEN_CVGD3_NCOC,
38   FBWRITE_16_RDEN_CVGD0_NCOC,      FBWRITE_16_RDEN_CVGD1_NCOC,      FBWRITE_16_RDEN_CVGD2_NCOC,      FBWRITE_16_RDEN_CVGD3_NCOC,
39   FBWRITE_16_RDNEN_CVGD0_COC,      FBWRITE_16_RDNEN_CVGD1_COC,      FBWRITE_16_RDNEN_CVGD2_COC,      FBWRITE_16_RDNEN_CVGD3_COC,
40   FBWRITE_16_RDEN_CVGD0_COC,      FBWRITE_16_RDEN_CVGD1_COC,      FBWRITE_16_RDEN_CVGD2_COC,      FBWRITE_16_RDEN_CVGD3_COC,
2341};
2442
25static UINT32 (*rdp_fbwrite_32_func[8])(UINT32*, UINT32, UINT32, UINT32) =
43static UINT32 (*rdp_fbwrite_32_func[16])(UINT32*, UINT32, UINT32, UINT32) =
2644{
27   FBWRITE_32_RDNEN_CVGD0,   FBWRITE_32_RDNEN_CVGD1,   FBWRITE_32_RDNEN_CVGD2,   FBWRITE_32_RDNEN_CVGD3,
28   FBWRITE_32_RDEN_CVGD0,   FBWRITE_32_RDEN_CVGD1,   FBWRITE_32_RDEN_CVGD2,   FBWRITE_32_RDEN_CVGD3,
45   FBWRITE_32_RDNEN_CVGD0_NCOC,   FBWRITE_32_RDNEN_CVGD1_NCOC,   FBWRITE_32_RDNEN_CVGD2_NCOC,   FBWRITE_32_RDNEN_CVGD3_NCOC,
46   FBWRITE_32_RDEN_CVGD0_NCOC,      FBWRITE_32_RDEN_CVGD1_NCOC,      FBWRITE_32_RDEN_CVGD2_NCOC,      FBWRITE_32_RDEN_CVGD3_NCOC,
47   FBWRITE_32_RDNEN_CVGD0_COC,      FBWRITE_32_RDNEN_CVGD1_COC,      FBWRITE_32_RDNEN_CVGD2_COC,      FBWRITE_32_RDNEN_CVGD3_COC,
48   FBWRITE_32_RDEN_CVGD0_COC,      FBWRITE_32_RDEN_CVGD1_COC,      FBWRITE_32_RDEN_CVGD2_COC,      FBWRITE_32_RDEN_CVGD3_COC,
2949};
src/mame/video/n64.c
r6714r6715
306306static UINT16 z_com_table[0x40000]; // Pre-calculated table of compressed z values
307307static UINT32 max_level = 0;
308308static UINT32 min_level = 0;
309static COLOR ViBuffer[640][480]; // Used by divot filter
309//static COLOR ViBuffer[640][480]; // Used by divot filter
310310static INT32 maskbits_table[16]; // Pre-calculated
311311static INT32 clamp_t_diff[8];
312312static INT32 clamp_s_diff[8];
313313
314INLINE UINT8 COMBINER_EQUATION(UINT8 A, UINT8 B, UINT8 C, UINT8 D);
314INLINE void COMBINER_EQUATION(UINT8* out, UINT8 *A, UINT8 *B, UINT8 *C, UINT8 *D);
315315INLINE UINT32 addrightcvg(UINT32 x, UINT32 k);
316316INLINE UINT32 addleftcvg(UINT32 x, UINT32 k);
317317INLINE UINT32 z_decompress(UINT16* zb);
r6714r6715
321321INLINE UINT32 z_compare(void* fb, UINT8* hb, UINT16* zb, UINT8* zhb, UINT32 sz, UINT16 dzpix);
322322INLINE INT32 normalize_dzpix(INT32 sum);
323323INLINE INT32 CLIP(INT32 value,INT32 min,INT32 max);
324INLINE COLOR video_filter16(UINT16* vbuff, UINT8* hbuff, UINT32 hres);
324INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UINT8* hbuff, UINT32 hres);
325325INLINE void divot_filter16(INT32* r, INT32* g, INT32* b, UINT16* fbuff, UINT32 fbuff_index);
326326INLINE void restore_filter16(INT32* r, INT32* g, INT32* b, UINT16* fbuff, UINT32 fbuff_index, UINT32 hres);
327327INLINE UINT32 getlog2(UINT32 lod_clamp);
328328INLINE void set_shade_for_rects(void);
329INLINE void set_shade_for_tris(UINT32 shade);
330329INLINE void copy_colors(COLOR* dst, COLOR* src);
331330INLINE void BILERP_AND_WRITE(UINT32* src0, UINT32* src1, UINT32* dest);
332331INLINE void tcdiv(INT32 ss, INT32 st, INT32 sw, INT32* sss, INT32* sst);
r6714r6715
338337INLINE void calculate_clamp_diffs(UINT32 prim_tile);
339338INLINE void rgb_dither(INT32* r, INT32* g, INT32* b, int dith);
340339
341INLINE void BLENDER_EQUATION_FORCE(INT32* r, INT32* g, INT32* b, int cycle, int bsel_special);
342INLINE void BLENDER_EQUATION_NFORCE(INT32* r, INT32* g, INT32* b, int cycle, int bsel_special);
340INLINE void BLENDER_EQUATION0_FORCE(INT32* r, INT32* g, INT32* b, int bsel_special);
341INLINE void BLENDER_EQUATION0_NFORCE(INT32* r, INT32* g, INT32* b, int bsel_special);
342INLINE void BLENDER_EQUATION1_FORCE(INT32* r, INT32* g, INT32* b, int bsel_special);
343INLINE void BLENDER_EQUATION1_NFORCE(INT32* r, INT32* g, INT32* b, int bsel_special);
343344
344static void (*BLENDER_EQUATION)(INT32* r, INT32* g, INT32* b, int cycle, int bsel_special);
345static void (*BLENDER_EQUATION0)(INT32* r, INT32* g, INT32* b, int bsel_special);
346static void (*BLENDER_EQUATION1)(INT32* r, INT32* g, INT32* b, int bsel_special);
345347
346348#include "video/rdpfb.h"
347349
r6714r6715
350352
351353#include "video/rdpacvg.h"
352354
353static UINT8 (*alpha_cvg_get)(UINT8 comb_alpha);
355static void (*alpha_cvg_get)(UINT8 *comb_alpha);
354356
355357#include "video/rdpacomp.h"
356358
357static int (*alpha_compare)(running_machine *machine, UINT8 comb_alpha);
359static int (*alpha_compare)(UINT8 comb_alpha);
358360
359361#include "video/rdptrect.h"
360362
361static void (*texture_rectangle_16bit)(running_machine *machine, TEX_RECTANGLE *rect);
363static void (*texture_rectangle_16bit)(TEX_RECTANGLE *rect);
362364
363365#include "video/rdpspn16.h"
364366
365static void (*render_spans_16)(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip);
367static void (*render_spans_16_ns_nt_nz_nf)( int start, int end, TILE* tex_tile);
368static void (*render_spans_16_ns_nt_z_nf)(int start, int end, TILE* tex_tile);
369static void (*render_spans_16_ns_t_nz_nf)(int start, int end, TILE* tex_tile);
370static void (*render_spans_16_ns_t_z_nf)(int start, int end, TILE* tex_tile);
371static void (*render_spans_16_s_nt_nz_nf)(int start, int end, TILE* tex_tile);
372static void (*render_spans_16_s_nt_z_nf)(int start, int end, TILE* tex_tile);
373static void (*render_spans_16_s_t_nz_nf)(int start, int end, TILE* tex_tile);
374static void (*render_spans_16_s_t_z_nf)(int start, int end, TILE* tex_tile);
375static void (*render_spans_16_ns_nt_nz_f)(int start, int end, TILE* tex_tile);
376static void (*render_spans_16_ns_nt_z_f)(int start, int end, TILE* tex_tile);
377static void (*render_spans_16_ns_t_nz_f)(int start, int end, TILE* tex_tile);
378static void (*render_spans_16_ns_t_z_f)(int start, int end, TILE* tex_tile);
379static void (*render_spans_16_s_nt_nz_f)(int start, int end, TILE* tex_tile);
380static void (*render_spans_16_s_nt_z_f)(int start, int end, TILE* tex_tile);
381static void (*render_spans_16_s_t_nz_f)(int start, int end, TILE* tex_tile);
382static void (*render_spans_16_s_t_z_f)(int start, int end, TILE* tex_tile);
366383
367384#include "video/rdptpipe.h"
368385
369386static void (*TEXTURE_PIPELINE)(COLOR* TEX, INT32 SSS, INT32 SST, TILE* tex_tile);
370387
388#include "video/rdpblend.h"
389
390static int (*BLENDER1_16)(UINT16 *fb, UINT8* hb, COLOR c, int dith);
391static int (*BLENDER2_16)(UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith);
392
393#include "video/rdptri.h"
394
395INLINE void CLAMP_C(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile);
396INLINE void CLAMP_NC(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile);
397
398static void (*CLAMP)(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile);
399
400INLINE void CLAMP_LIGHT_C(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile);
401INLINE void CLAMP_LIGHT_NC(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile);
402
403static void (*CLAMP_LIGHT)(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile);
404
405static UINT8 rdp_rand_val = 0;
406
407#include "video/rdpfetch.h"
408
409// Hack, but more efficient than mame_rand
410static UINT8 rdp_rand(void)
411{
412   return (rdp_rand_val += 19);
413}
414
371415INLINE void MASK(INT32* S, INT32* T, TILE* tex_tile)
372416{
373417   INT32 swrap, twrap;
r6714r6715
433477   *maxt = ((*T >> 3) >= tex_tile->th);
434478}
435479
436INLINE void CLAMP(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile)
480INLINE void CLAMP_NC(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile)
437481{
438   int notcopy = (other_modes.cycle_type != CYCLE_TYPE_COPY);
439482   int dosfrac = (tex_tile->cs || !tex_tile->mask_s);
440   int dos = dosfrac && notcopy;
441483   int dotfrac = (tex_tile->ct || !tex_tile->mask_t);
442   int dot = dotfrac && notcopy;
443484   int overunders = 0;
444485   int overundert = 0;
445   if (*S & 0x10000 && dos)
486   if (*S & 0x10000 && dosfrac)
446487   {
447488      *S = 0;
448489      overunders = 1;
449490   }
450   else if (maxs && dos)
491   else if (maxs && dosfrac)
451492   {
452493      *S = clamp_s_diff[tex_tile->num];
453494      overunders = 1;
r6714r6715
457498   {
458499      *S = (SIGN17(*S) >> 5) & 0x1fff;
459500   }
501
460502   if (overunders && dosfrac)
461503   {
462504      *SFRAC = 0;
463505   }
464506
465   if (*T & 0x10000 && dot)
507   if (*T & 0x10000 && dotfrac)
466508   {
467509      *T = 0;
468510      overundert = 1;
469511   }
470   else if (maxt && dot)
512   else if (maxt && dotfrac)
471513   {
472514      *T = clamp_t_diff[tex_tile->num];
473515      overundert = 1;
r6714r6715
476518   {
477519      *T = (SIGN17(*T) >> 5) & 0x1fff;
478520   }
521
479522   if (overundert && dotfrac)
480523   {
481524      *TFRAC = 0;
482525   }
483526}
484527
485INLINE void CLAMP_LIGHT(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile)
528INLINE void CLAMP_C(INT32* S, INT32* T, INT32* SFRAC, INT32* TFRAC, INT32 maxs, INT32 maxt, TILE* tex_tile)
486529{
487   int notcopy = (other_modes.cycle_type != CYCLE_TYPE_COPY);
488   int dos = (tex_tile->cs || !tex_tile->mask_s) && notcopy;
489   int dot = (tex_tile->ct || !tex_tile->mask_t) && notcopy;
530   int dosfrac = (tex_tile->cs || !tex_tile->mask_s);
531   int dotfrac = (tex_tile->ct || !tex_tile->mask_t);
532   int overunders = 0;
533   int overundert = 0;
490534
535   *S = (SIGN17(*S) >> 5) & 0x1fff;
536
537   if (overunders && dosfrac)
538   {
539      *SFRAC = 0;
540   }
541
542   *T = (SIGN17(*T) >> 5) & 0x1fff;
543
544   if (overundert && dotfrac)
545   {
546      *TFRAC = 0;
547   }
548}
549
550INLINE void CLAMP_LIGHT_C(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile)
551{
552   *S = (SIGN17(*S) >> 5) & 0x1fff;
553   *T = (SIGN17(*T) >> 5) & 0x1fff;
554}
555
556INLINE void CLAMP_LIGHT_NC(INT32* S, INT32* T, INT32 maxs, INT32 maxt, TILE* tex_tile)
557{
558   int dos = (tex_tile->cs || !tex_tile->mask_s);
559   int dot = (tex_tile->ct || !tex_tile->mask_t);
560
491561   if (*S & 0x10000 && dos)
492562   {
493563      *S = 0;
r6714r6715
598668   }
599669}
600670
601VIDEO_UPDATE(n64)
671#define FSAA
672   #define DIVOT
673      #include "rdpupd16.c"
674   #undef DIVOT
675      #include "rdpupd16.c"
676#undef FSAA
677   #define DIVOT
678      #include "rdpupd16.c"
679   #undef DIVOT
680      #include "rdpupd16.c"
681
682static void video_update_n64_32(bitmap_t *bitmap)
602683{
603684   int i, j;
604   UINT32 final = 0;
605   UINT32 prev_cvg = 0, next_cvg = 0;
606    int height = fb_height;
607    int dither_filter = (n64_vi_control >> 16) & 1;
608    int fsaa = (((n64_vi_control >> 8) & 3) < 2);
609    int divot = (n64_vi_control >> 4) & 1;
610685    int gamma = (n64_vi_control >> 3) & 1;
611686    int gamma_dither = (n64_vi_control >> 2) & 1;
612    int vibuffering = ((n64_vi_control & 2) && fsaa && divot);
687    //int vibuffering = ((n64_vi_control & 2) && fsaa && divot);
613688
614689    UINT32 *frame_buffer32;
615690   UINT16 *frame_buffer;
616691   UINT32 hb;
617692   UINT8* hidden_buffer;
618   COLOR newc;
619693
620   UINT32 pixels = 0;
621   UINT16 pix = 0;
622694   int r, g, b;
623695   int dith = 0;
624696
r6714r6715
633705
634706   if (vdiff <= 0 || hdiff <= 0)
635707   {
636      return 0;
708
709      return;
637710   }
638711
639712   frame_buffer = (UINT16*)&rdram[(n64_vi_origin & 0xffffff) >> 2];
640713   hb = ((n64_vi_origin & 0xffffff) >> 2) >> 1;
641714   hidden_buffer = &hidden_bits[hb];
642715
643   vibuffering = 0; // Disabled for now
644
645
646716   if (hres > 640) // Needed by Top Gear Overdrive (E)
647717   {
648718      invisiblewidth += (hres - 640);
649719      hres = 640;
650720   }
651721
722   frame_buffer32 = (UINT32*)&rdram[(n64_vi_origin & 0xffffff) >> 2];
723   if (frame_buffer32)
724   {
725      for (j=0; j < vres; j++)
726      {
727         UINT32 *d = BITMAP_ADDR32(bitmap, j, 0);
728         for (i=0; i < hres; i++)
729         {
730            UINT32 pix = *frame_buffer32++;
731            if (gamma || gamma_dither)
732            {
733               r = (pix >> 24) & 0xff;
734               g = (pix >> 16) & 0xff;
735               b = (pix >> 8) & 0xff;
736               if (gamma_dither)
737               {
738                  dith = rdp_rand() & 0x3f;
739               }
740               if (gamma)
741               {
742                  if (gamma_dither)
743                  {
744                     r = gamma_dither_table[(r << 6)| dith];
745                     g = gamma_dither_table[(g << 6)| dith];
746                     b = gamma_dither_table[(b << 6)| dith];
747                  }
748                  else
749                  {
750                     r = gamma_table[r];
751                     g = gamma_table[g];
752                     b = gamma_table[b];
753                  }
754               }
755               else if (gamma_dither)
756               {
757                  if (r < 255)
758                     r += (dith & 1);
759                  if (g < 255)
760                     g += (dith & 1);
761                  if (b < 255)
762                     b += (dith & 1);
763               }
764               pix = (r << 24) | (g << 16) | (b << 8);
765            }
766
767
768            d[i] = (pix >> 8);
769         }
770         frame_buffer32 += invisiblewidth;
771      }
772   }
773}
774
775VIDEO_UPDATE(n64)
776{
777   int i, j;
778    int fsaa = (((n64_vi_control >> 8) & 3) < 2);
779    int divot = (n64_vi_control >> 4) & 1;
780    int height = fb_height;
781    //int vibuffering = ((n64_vi_control & 2) && fsaa && divot);
782
783   //vibuffering = 0; // Disabled for now
784
785   /*
652786   if (vibuffering && ((n64_vi_control & 3) == 2))
653787   {
654788      if (frame_buffer)
r6714r6715
678812         }
679813      }
680814   }
815   */
681816
682817    if (n64_vi_blank)
683818    {
r6714r6715
701836
702837      case 2:      // RGBA5551
703838      {
704         pixels = 0;
705
706         if (frame_buffer)
839         if(divot && fsaa)
707840         {
708            for (j=0; j < vres; j++)
709            {
710               UINT32 *d = BITMAP_ADDR32(bitmap, j, 0);
711
712               for (i=0; i < hres; i++)
713               {
714                  int r, g, b;
715
716                  pix = frame_buffer[pixels ^ WORD_ADDR_XOR];
717                  curpixel_cvg = ((pix & 1) << 2) | (hidden_buffer[pixels ^ BYTE_ADDR_XOR] & 3);
718
719                  if (i > 0 && i < (hres - 1) && divot)
720                  {
721                     prev_cvg = ((frame_buffer[(pixels - 1)^WORD_ADDR_XOR] & 1) << 2) | (hidden_buffer[(pixels - 1)^BYTE_ADDR_XOR] & 3);
722                     next_cvg = ((frame_buffer[(pixels + 1)^WORD_ADDR_XOR] & 1) << 2) | (hidden_buffer[(pixels + 1)^BYTE_ADDR_XOR] & 3);
723                  }
724                  r = ((pix >> 8) & 0xf8) | (pix >> 13);
725                  g = ((pix >> 3) & 0xf8) | ((pix >>  8) & 0x07);
726                  b = ((pix << 2) & 0xf8) | ((pix >>  3) & 0x07);
727
728                  if (!vibuffering && curpixel_cvg < 7 && i > 1 && j > 1 && i < (hres - 2) && j < (vres - 2) && fsaa)
729                  {
730                     newc = video_filter16(&frame_buffer[pixels ^ WORD_ADDR_XOR],&hidden_buffer[pixels ^ BYTE_ADDR_XOR], n64_vi_width);
731                     r = newc.i.r; g = newc.i.g; b = newc.i.b;
732                  }
733                  else if (dither_filter && curpixel_cvg == 7 && i > 0 && j > 0 && i < (hres - 1) && j < (vres - 1))
734                  {
735                     if (vibuffering)
736                     {
737                        restore_filter16_buffer(&r, &g, &b, &ViBuffer[i][j], n64_vi_width);
738                     }
739                     else
740                     {
741                        //restore_filter16(&r, &g, &b, &frame_buffer[pixels ^ WORD_ADDR_XOR], pixels ^ WORD_ADDR_XOR, n64_vi_width);
742                     }
743                  }
744                  if (i > 0 && i < (hres - 1) && divot && (curpixel_cvg != 7 || prev_cvg != 7 || next_cvg != 7))
745                  {
746                     if (vibuffering)
747                     {
748                        divot_filter16_buffer(&r, &g, &b, &ViBuffer[i][j]);
749                     }
750                     else
751                     {
752                        divot_filter16(&r, &g, &b, &frame_buffer[pixels ^ WORD_ADDR_XOR], pixels ^ WORD_ADDR_XOR);
753                     }
754                  }
755
756                  /*
757                  if (gamma_dither)
758                  {
759                     dith = mame_rand(screen->machine) & 0x3f;
760                  }
761                  if (gamma)
762                  {
763                     if (gamma_dither)
764                     {
765                        r = gamma_dither_table[(r << 6)|dith];
766                        g = gamma_dither_table[(g << 6)|dith];
767                        b = gamma_dither_table[(b << 6)|dith];
768                     }
769                     else
770                     {
771                        r = gamma_table[r];
772                        g = gamma_table[g];
773                        b = gamma_table[b];
774                     }
775                  }
776                  else if (gamma_dither)
777                  {
778                     if (r < 255)
779                        r += (dith & 1);
780                     if (g < 255)
781                        g += (dith & 1);
782                     if (b < 255)
783                        b += (dith & 1);
784                  }
785                  */
786                  pixels++;
787
788                  final = (r << 16) | (g << 8) | b;
789                  d[i] = final; // Fix me for endianness
790               }
791               pixels +=invisiblewidth;
792            }
841            video_update_n64_16_fsaa_divot(bitmap);
793842         }
843         else if(divot)
844         {
845            video_update_n64_16_nofsaa_divot(bitmap);
846         }
847         else if(fsaa)
848         {
849            video_update_n64_16_fsaa_nodivot(bitmap);
850         }
851         else
852         {
853            video_update_n64_16_nofsaa_nodivot(bitmap);
854         }
794855         break;
795856      }
796857
797858      case 3:      // RGBA8888
798859      {
799            frame_buffer32 = (UINT32*)&rdram[(n64_vi_origin & 0xffffff) >> 2];
800         if (frame_buffer32)
801         {
802            for (j=0; j < vres; j++)
803            {
804               UINT32 *d = BITMAP_ADDR32(bitmap, j, 0);
805               for (i=0; i < hres; i++)
806               {
807                  UINT32 pix = *frame_buffer32++;
808                  if (gamma || gamma_dither)
809                  {
810                     r = (pix >> 24) & 0xff;
811                     g = (pix >> 16) & 0xff;
812                     b = (pix >> 8) & 0xff;
813                     if (gamma_dither)
814                     {
815                        dith = mame_rand(screen->machine) & 0x3f;
816                     }
817                     if (gamma)
818                     {
819                        if (gamma_dither)
820                        {
821                           r = gamma_dither_table[(r << 6)| dith];
822                           g = gamma_dither_table[(g << 6)| dith];
823                           b = gamma_dither_table[(b << 6)| dith];
824                        }
825                        else
826                        {
827                           r = gamma_table[r];
828                           g = gamma_table[g];
829                           b = gamma_table[b];
830                        }
831                     }
832                     else if (gamma_dither)
833                     {
834                        if (r < 255)
835                           r += (dith & 1);
836                        if (g < 255)
837                           g += (dith & 1);
838                        if (b < 255)
839                           b += (dith & 1);
840                     }
841                     pix = (r << 24) | (g << 16) | (b << 8);
842                  }
843
844
845                  d[i] = (pix >> 8);
846               }
847               frame_buffer32 += invisiblewidth;
848            }
849         }
860         video_update_n64_32(bitmap);
850861         break;
851862      }
852863
r6714r6715
970981
971982
972983
973INLINE COLOR COLOR_COMBINER1(running_machine *machine)
984INLINE void COLOR_COMBINER1(COLOR *c)
974985{
975   COLOR c;
976
977986   if (combiner_rgbsub_a_r[1] == &noise_color.i.r)
978987   {
979      noise_color.i.r = mame_rand(machine) & 0xff;
980      noise_color.i.g = mame_rand(machine) & 0xff;
981      noise_color.i.b = mame_rand(machine) & 0xff;
988      noise_color.i.r = rdp_rand() & 0xff;
989      noise_color.i.g = rdp_rand() & 0xff;
990      noise_color.i.b = rdp_rand() & 0xff;
982991   }
983992
984   c.i.r = COMBINER_EQUATION(*combiner_rgbsub_a_r[1],*combiner_rgbsub_b_r[1],*combiner_rgbmul_r[1],*combiner_rgbadd_r[1]);
985   c.i.g = COMBINER_EQUATION(*combiner_rgbsub_a_g[1],*combiner_rgbsub_b_g[1],*combiner_rgbmul_g[1],*combiner_rgbadd_g[1]);
986   c.i.b = COMBINER_EQUATION(*combiner_rgbsub_a_b[1],*combiner_rgbsub_b_b[1],*combiner_rgbmul_b[1],*combiner_rgbadd_b[1]);
987   c.i.a = COMBINER_EQUATION(*combiner_alphasub_a[1],*combiner_alphasub_b[1],*combiner_alphamul[1],*combiner_alphaadd[1]);
993   COMBINER_EQUATION(&c->i.r, combiner_rgbsub_a_r[1],combiner_rgbsub_b_r[1],combiner_rgbmul_r[1],combiner_rgbadd_r[1]);
994   COMBINER_EQUATION(&c->i.g, combiner_rgbsub_a_g[1],combiner_rgbsub_b_g[1],combiner_rgbmul_g[1],combiner_rgbadd_g[1]);
995   COMBINER_EQUATION(&c->i.b, combiner_rgbsub_a_b[1],combiner_rgbsub_b_b[1],combiner_rgbmul_b[1],combiner_rgbadd_b[1]);
996   COMBINER_EQUATION(&c->i.a, combiner_alphasub_a[1],combiner_alphasub_b[1],combiner_alphamul[1],combiner_alphaadd[1]);
988997
989998   //Alpha coverage combiner
990   c.i.a = alpha_cvg_get(c.i.a);
991
992   return c;
999   alpha_cvg_get(&c->i.a);
9931000}
9941001
995INLINE COLOR COLOR_COMBINER2_C0(running_machine *machine)
1002INLINE void COLOR_COMBINER2_C0(COLOR *c)
9961003{
997   COLOR c;
998
9991004   if (combiner_rgbsub_a_r[0] == &noise_color.i.r)
10001005   {
1001      noise_color.i.r = mame_rand(machine) & 0xff;
1002      noise_color.i.g = mame_rand(machine) & 0xff;
1003      noise_color.i.b = mame_rand(machine) & 0xff;
1006      noise_color.i.r = rdp_rand() & 0xff;
1007      noise_color.i.g = rdp_rand() & 0xff;
1008      noise_color.i.b = rdp_rand() & 0xff;
10041009   }
10051010
1006   c.i.r = COMBINER_EQUATION(*combiner_rgbsub_a_r[0],*combiner_rgbsub_b_r[0],*combiner_rgbmul_r[0],*combiner_rgbadd_r[0]);
1007   c.i.g = COMBINER_EQUATION(*combiner_rgbsub_a_g[0],*combiner_rgbsub_b_g[0],*combiner_rgbmul_g[0],*combiner_rgbadd_g[0]);
1008   c.i.b = COMBINER_EQUATION(*combiner_rgbsub_a_b[0],*combiner_rgbsub_b_b[0],*combiner_rgbmul_b[0],*combiner_rgbadd_b[0]);
1009   c.i.a = COMBINER_EQUATION(*combiner_alphasub_a[0],*combiner_alphasub_b[0],*combiner_alphamul[0],*combiner_alphaadd[0]);
1011   COMBINER_EQUATION(&c->i.r, combiner_rgbsub_a_r[0],combiner_rgbsub_b_r[0],combiner_rgbmul_r[0],combiner_rgbadd_r[0]);
1012   COMBINER_EQUATION(&c->i.g, combiner_rgbsub_a_g[0],combiner_rgbsub_b_g[0],combiner_rgbmul_g[0],combiner_rgbadd_g[0]);
1013   COMBINER_EQUATION(&c->i.b, combiner_rgbsub_a_b[0],combiner_rgbsub_b_b[0],combiner_rgbmul_b[0],combiner_rgbadd_b[0]);
1014   COMBINER_EQUATION(&c->i.a, combiner_alphasub_a[0],combiner_alphasub_b[0],combiner_alphamul[0],combiner_alphaadd[0]);
10101015
1011   combined_color.c = c.c;
1012
1013   return c;
1016   combined_color.c = c->c;
10141017}
10151018
1016INLINE COLOR COLOR_COMBINER2_C1(running_machine *machine)
1019INLINE void COLOR_COMBINER2_C1(COLOR *c)
10171020{
1018   COLOR c;
1019
1020   c.c = texel0_color.c;
1021   c->c = texel0_color.c;
10211022   texel0_color.c = texel1_color.c;
1022   texel1_color.c = c.c;
1023   texel1_color.c = c->c;
10231024
10241025   if (combiner_rgbsub_a_r[1] == &noise_color.i.r)
10251026   {
1026      noise_color.i.r = mame_rand(machine) & 0xff;
1027      noise_color.i.g = mame_rand(machine) & 0xff;
1028      noise_color.i.b = mame_rand(machine) & 0xff;
1027      noise_color.i.r = rdp_rand() & 0xff;
1028      noise_color.i.g = rdp_rand() & 0xff;
1029      noise_color.i.b = rdp_rand() & 0xff;
10291030   }
10301031
1031   c.i.r = COMBINER_EQUATION(*combiner_rgbsub_a_r[1],*combiner_rgbsub_b_r[1],*combiner_rgbmul_r[1],*combiner_rgbadd_r[1]);
1032   c.i.g = COMBINER_EQUATION(*combiner_rgbsub_a_g[1],*combiner_rgbsub_b_g[1],*combiner_rgbmul_g[1],*combiner_rgbadd_g[1]);
1033   c.i.b = COMBINER_EQUATION(*combiner_rgbsub_a_b[1],*combiner_rgbsub_b_b[1],*combiner_rgbmul_b[1],*combiner_rgbadd_b[1]);
1034   c.i.a = COMBINER_EQUATION(*combiner_alphasub_a[1],*combiner_alphasub_b[1],*combiner_alphamul[1],*combiner_alphaadd[1]);
1032   COMBINER_EQUATION(&c->i.r, combiner_rgbsub_a_r[1],combiner_rgbsub_b_r[1],combiner_rgbmul_r[1],combiner_rgbadd_r[1]);
1033   COMBINER_EQUATION(&c->i.g, combiner_rgbsub_a_g[1],combiner_rgbsub_b_g[1],combiner_rgbmul_g[1],combiner_rgbadd_g[1]);
1034   COMBINER_EQUATION(&c->i.b, combiner_rgbsub_a_b[1],combiner_rgbsub_b_b[1],combiner_rgbmul_b[1],combiner_rgbadd_b[1]);
1035   COMBINER_EQUATION(&c->i.a, combiner_alphasub_a[1],combiner_alphasub_b[1],combiner_alphamul[1],combiner_alphaadd[1]);
10351036
1036   c.i.a = alpha_cvg_get(c.i.a);
1037
1038   return c;
1037   alpha_cvg_get(&c->i.a);
10391038}
10401039
10411040INLINE void SET_BLENDER_INPUT(int cycle, int which, UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, UINT8 **input_a, int a, int b)
r6714r6715
11181117    7,  1,  6, 0
11191118};
11201119
1121INLINE int BLENDER1_16(running_machine *machine, UINT16 *fb, UINT8* hb, COLOR c, int dith)
1122{
1123   int r, g, b;
1124   int special_bsel = 0;
1125   UINT16 mem = *fb;
1126   UINT32 memory_cvg = ((mem & 1) << 2) + (*hb & 3);
1127
1128   // Alpha compare
1129   if (!alpha_compare(machine, c.i.a))
1130   {
1131      return 0;
1132   }
1133   if (!curpixel_cvg) // New coverage is zero, so abort
1134   {
1135      return 0;
1136   }
1137
1138   if (blender2b_a[0] == &memory_color.i.a)
1139   {
1140      special_bsel = 1;
1141   }
1142
1143   pixel_color.c = c.c;
1144   //copy_colors(&pixel_color,&c);
1145
1146   if (!other_modes.z_compare_en)
1147   {
1148      curpixel_overlap = 0;
1149   }
1150
1151   memory_color.i.r = ((mem >> 8) & 0xf8) | (mem >> 13);
1152   memory_color.i.g = ((mem >> 3) & 0xf8) | ((mem >>  8) & 0x07);
1153   memory_color.i.b = ((mem << 2) & 0xf8) | ((mem >>  3) & 0x07);
1154
1155   if (other_modes.image_read_en)
1156   {
1157      memory_color.i.a = (memory_cvg << 5) & 0xe0;
1158   }
1159   else
1160   {
1161      memory_color.i.a = 0xe0;
1162   }
1163
1164   if (!curpixel_overlap && !other_modes.force_blend)
1165   {
1166      r = *blender1a_r[0];
1167      g = *blender1a_g[0];
1168      b = *blender1a_b[0];
1169   }
1170   else
1171   {
1172      inv_pixel_color.i.a = 0xff - *blender1b_a[0];
1173
1174      BLENDER_EQUATION(&r, &g, &b, 0, special_bsel);
1175   }
1176
1177   if (other_modes.rgb_dither_sel < 2)
1178   {
1179      // Hack to prevent "double-dithering" artifacts
1180      int dithhack = ((r & 0xf8)==(memory_color.i.r&0xf8) && (g & 0xf8) == (memory_color.i.g & 0xf8) &&(b&0xf8)==(memory_color.i.b&0xf8));
1181      if (!dithhack)
1182      {
1183         rgb_dither(&r, &g, &b, dith);
1184      }
1185   }
1186
1187    return (FBWRITE_16(fb, hb, r, g, b));
1188}
1189
1190INLINE int BLENDER2_16(running_machine *machine, UINT16 *fb, UINT8* hb, COLOR c1, COLOR c2, int dith)
1191{
1192   int r, g, b;
1193   int special_bsel = 0;
1194   UINT16 mem = *fb;
1195   UINT32 memory_cvg = ((mem & 1) << 2) + (*hb & 3);
1196
1197   // Alpha compare
1198   if (!alpha_compare(machine, c2.i.a))
1199   {
1200      return 0;
1201   }
1202   if (!curpixel_cvg)
1203   {
1204      return 0;
1205   }
1206
1207   if (blender2b_a[0] == &memory_color.i.a)
1208   {
1209      special_bsel = 1;
1210   }
1211
1212   pixel_color.c = c2.c;
1213   //copy_colors(&pixel_color, &c2);
1214   if (!other_modes.z_compare_en)
1215   {
1216      curpixel_overlap = 0;
1217   }
1218
1219   memory_color.i.r = ((mem >> 8) & 0xf8) | (mem >> 13);
1220   memory_color.i.g = ((mem >> 3) & 0xf8) | ((mem >>  8) & 0x07);
1221   memory_color.i.b = ((mem << 2) & 0xf8) | ((mem >>  3) & 0x07);
1222
1223   if (other_modes.image_read_en)
1224   {
1225      memory_color.i.a = (memory_cvg << 5) & 0xe0;
1226   }
1227   else
1228   {
1229      memory_color.i.a = 0xe0;
1230   }
1231
1232   inv_pixel_color.i.a = 0xff - *blender1b_a[0];
1233
1234   BLENDER_EQUATION(&r, &g, &b, 0, special_bsel);
1235
1236   blended_pixel_color.i.r = r;
1237   blended_pixel_color.i.g = g;
1238   blended_pixel_color.i.b = b;
1239   blended_pixel_color.i.a = pixel_color.i.a;
1240
1241   pixel_color.i.r = r;
1242   pixel_color.i.g = g;
1243   pixel_color.i.b = b;
1244
1245   inv_pixel_color.i.a = 0xff - *blender1b_a[1];
1246
1247   if (!curpixel_overlap && !other_modes.force_blend)
1248   {
1249      r = *blender1a_r[1];
1250      g = *blender1a_g[1];
1251      b = *blender1a_b[1];
1252   }
1253   else
1254   {
1255      if (blender2b_a[1] == &memory_color.i.a)
1256      {
1257         special_bsel = 1;
1258      }
1259      else
1260      {
1261         special_bsel = 0;
1262      }
1263
1264      BLENDER_EQUATION(&r, &g, &b, 1, special_bsel);
1265   }
1266
1267   if (other_modes.rgb_dither_sel < 2)
1268   {
1269      // Hack to prevent "double-dithering" artifacts
1270      int dithhack = ((r & 0xf8)==(memory_color.i.r&0xf8) && (g & 0xf8) == (memory_color.i.g & 0xf8) &&(b&0xf8)==(memory_color.i.b&0xf8));
1271      if (!dithhack)
1272      {
1273         rgb_dither(&r, &g, &b, dith);
1274      }
1275   }
1276
1277   return (FBWRITE_16(fb, hb, r, g, b));
1278}
1279
12801120/*****************************************************************************/
12811121
1282
1283static void fill_rectangle_16bit(running_machine *machine, RECTANGLE *rect)
1122static void fill_rectangle_16bit(RECTANGLE *rect)
12841123{
12851124   UINT16 *fb = (UINT16*)&rdram[(fb_address / 4)];
12861125   UINT8* hb = &hidden_bits[fb_address >> 1];
r6714r6715
13601199            for (i = x1; i <= x2; i++)
13611200            {
13621201               curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2;
1363               c = COLOR_COMBINER1(machine);
1202               COLOR_COMBINER1(&c);
13641203               dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
1365               BLENDER1_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith);
1204               BLENDER1_16(&fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith);
13661205            }
13671206         }
13681207      }
r6714r6715
13761215            for (i = x1; i <= x2; i++)
13771216            {
13781217               curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2;
1379               c = COLOR_COMBINER1(machine);
1218               COLOR_COMBINER1(&c);
13801219               dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
1381               BLENDER1_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith);
1220               BLENDER1_16(&fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith);
13821221            }
13831222         }
13841223      }
r6714r6715
13921231            for (i = x1; i <= x2; i++)
13931232            {
13941233               curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2;
1395               c = COLOR_COMBINER1(machine);
1396               BLENDER1_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith);
1234               COLOR_COMBINER1(&c);
1235               BLENDER1_16(&fb[(index + i) ^ WORD_ADDR_XOR], &hb[(index + i) ^ BYTE_ADDR_XOR], c, dith);
13971236            }
13981237         }
13991238      }
r6714r6715
14101249            for (i=x1; i <= x2; i++)
14111250            {
14121251               curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2;
1413               c1 = COLOR_COMBINER2_C0(machine);
1414               c2 = COLOR_COMBINER2_C1(machine);
1252               COLOR_COMBINER2_C0(&c1);
1253               COLOR_COMBINER2_C1(&c2);
14151254               dith = magic_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
1416               BLENDER2_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR],  &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith);
1255               BLENDER2_16(&fb[(index + i) ^ WORD_ADDR_XOR],  &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith);
14171256            }
14181257         }
14191258      }
r6714r6715
14271266            for (i=x1; i <= x2; i++)
14281267            {
14291268               curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2;
1430               c1 = COLOR_COMBINER2_C0(machine);
1431               c2 = COLOR_COMBINER2_C1(machine);
1269               COLOR_COMBINER2_C0(&c1);
1270               COLOR_COMBINER2_C1(&c2);
14321271               dith = bayer_matrix[(((j) & 3) << 2) + ((i ^ WORD_ADDR_XOR) & 3)];
1433               BLENDER2_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR],  &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith);
1272               BLENDER2_16(&fb[(index + i) ^ WORD_ADDR_XOR],  &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith);
14341273            }
14351274         }
14361275      }
r6714r6715
14441283            for (i=x1; i <= x2; i++)
14451284            {
14461285               curpixel_cvg = (i & 1) ? fill_cvg1 : fill_cvg2;
1447               c1 = COLOR_COMBINER2_C0(machine);
1448               c2 = COLOR_COMBINER2_C1(machine);
1449               BLENDER2_16(machine, &fb[(index + i) ^ WORD_ADDR_XOR],  &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith);
1286               COLOR_COMBINER2_C0(&c1);
1287               COLOR_COMBINER2_C1(&c2);
1288               BLENDER2_16(&fb[(index + i) ^ WORD_ADDR_XOR],  &hb[(index + i) ^ BYTE_ADDR_XOR], c1, c2, dith);
14501289            }
14511290         }
14521291      }
r6714r6715
14741313static INT32 twidth;
14751314static INT32 tpal;
14761315
1477#include "video/rdpfetch.c"
1478
14791316INLINE void FETCH_TEXEL(COLOR *color, int s, int t, TILE* tex_tile)
14801317{
14811318   twidth  = tex_tile->line;
r6714r6715
14881325   rdp_fetch_texel_func[tex_tile->fetch_index](color, s, t);
14891326}
14901327
1491#include "video/rdptpipe.c"
1492
14931328INLINE UINT32 z_decompress(UINT16 *zb)
14941329{
14951330   UINT32 exponent = (*zb >> 13) & 7;
r6714r6715
16951530   }
16961531}
16971532
1698INLINE COLOR video_filter16(UINT16* vbuff, UINT8* hbuff, UINT32 hres)
1533INLINE void video_filter16(int *out_r, int *out_g, int *out_b, UINT16* vbuff, UINT8* hbuff, UINT32 hres)
16991534{
1700   COLOR filtered, penumax, penumin, max, min;
1535   COLOR penumax, penumin, max, min;
17011536   UINT16 pix = *vbuff;
17021537   UINT32 centercvg = (*hbuff & 3) + ((pix & 1) << 2) + 1;
17031538   UINT32 numoffull = 1;
r6714r6715
17151550   UINT32 enb;
17161551   int i = 0;
17171552
1718   filtered.c = 0;
1719   //filtered.i.r = filtered.i.g = filtered.i.b = filtered.i.a = 0;
1553   *out_r = *out_g = *out_b = 0;
17201554
17211555   backr[0] = r;
17221556   backg[0] = g;
r6714r6715
17271561
17281562   if (centercvg == 8)
17291563   {
1730      filtered.i.r = r; filtered.i.g = g; filtered.i.b = b;
1731      return filtered;
1564      *out_r = r;
1565      *out_g = g;
1566      *out_b = b;
1567      return;
17321568   }
17331569
17341570   for(i = 0; i < 5; i++)
r6714r6715
18981734   colr = (((colr * coeff) + 4) >> 3) + r;
18991735   colg = (((colg * coeff) + 4) >> 3) + g;
19001736   colb = (((colb * coeff) + 4) >> 3) + b;
1901   colr &= 0xff;
1902   colg &= 0xff;
1903   colb &= 0xff;
19041737
1905   filtered.i.r = colr;
1906   filtered.i.g = colg;
1907   filtered.i.b = colb;
1908   return filtered;
1738   *out_r = colr & 0xff;
1739   *out_g = colg & 0xff;
1740   *out_b = colb & 0xff;
1741   return;
19091742}
19101743
19111744// This needs to be fixed for endianness.
r6714r6715
22882121   //shade_color.i.a = 0;
22892122}
22902123
2291INLINE void set_shade_for_tris(UINT32 shade)
2292{
2293   if (!shade) // Hack, needed for Top Gear Rally 2 sky
2294   {
2295      shade_color.c = prim_color.c;
2296      //shade_color.i.r = prim_color.i.r;
2297      //shade_color.i.g = prim_color.i.g;
2298      //shade_color.i.b = prim_color.i.b;;
2299      //shade_color.i.a = prim_color.i.a;
2300   }
2301}
2302
23032124INLINE UINT32 getlog2(UINT32 lod_clamp)
23042125{
23052126   int i;
r6714r6715
23992220}
24002221#endif
24012222
2402#include "rdptrect.c"
2403
24042223/*****************************************************************************/
24052224
2406INLINE int BLENDER1_32(running_machine *machine, UINT32 *fb, COLOR c)
2225INLINE int BLENDER1_32(UINT32 *fb, COLOR c)
24072226{
24082227   UINT32 mem = *fb;
24092228   int r, g, b;
24102229
24112230   // Alpha compare
2412   if (!alpha_compare(machine, c.i.a))
2231   if (!alpha_compare(c.i.a))
24132232   {
24142233      return 0;
24152234   }
r6714r6715
24552274
24562275      inv_pixel_color.i.a = 0xff - *blender1b_a[0];
24572276
2458      BLENDER_EQUATION(&r, &g, &b, 0, special_bsel);
2277      BLENDER_EQUATION0(&r, &g, &b, special_bsel);
24592278   }
24602279
24612280   return  (FBWRITE_32(fb,r,g,b));
24622281}
24632282
2464INLINE int BLENDER2_32(running_machine *machine, UINT32 *fb, COLOR c1, COLOR c2)
2283INLINE int BLENDER2_32(UINT32 *fb, COLOR c1, COLOR c2)
24652284{
24662285   UINT32 mem = *fb;
24672286   int r, g, b;
24682287   int special_bsel = 0;
24692288
24702289   // Alpha compare
2471   if (!alpha_compare(machine, c2.i.a))
2290   if (!alpha_compare(c2.i.a))
24722291   {
24732292      return 0;
24742293   }
r6714r6715
25052324
25062325   inv_pixel_color.i.a = 0xff - *blender1b_a[0];
25072326
2508   BLENDER_EQUATION(&r, &g, &b, 0, special_bsel);
2327   BLENDER_EQUATION0(&r, &g, &b, special_bsel);
25092328
25102329   blended_pixel_color.i.r = r;
25112330   blended_pixel_color.i.g = g;
r6714r6715
25342353
25352354      inv_pixel_color.i.a = 0xff - *blender1b_a[1];
25362355
2537      BLENDER_EQUATION(&r, &g, &b, 1, special_bsel);
2356      BLENDER_EQUATION1(&r, &g, &b, special_bsel);
25382357   }
25392358
25402359   return  (FBWRITE_32(fb,r,g,b));
25412360}
25422361
2543static void fill_rectangle_32bit(running_machine *machine, RECTANGLE *rect)
2362static void fill_rectangle_32bit(RECTANGLE *rect)
25442363{
25452364   UINT32 *fb = (UINT32*)&rdram[(fb_address / 4)];
25462365   int index, i, j;
r6714r6715
26052424         for (i=x1; i <= x2; i++)
26062425         {
26072426            curpixel_cvg = fill_cvg;
2608            c = COLOR_COMBINER1(machine);
2609            BLENDER1_32(machine, &fb[(index + i)], c);
2427            COLOR_COMBINER1(&c);
2428            BLENDER1_32(&fb[(index + i)], c);
26102429         }
26112430      }
26122431   }
r6714r6715
26192438         for (i=x1; i <= x2; i++)
26202439         {
26212440            curpixel_cvg = fill_cvg;
2622            c1 = COLOR_COMBINER2_C0(machine);
2623            c2 = COLOR_COMBINER2_C1(machine);
2624            BLENDER2_32(machine, &fb[(index + i)], c1, c2);
2441            COLOR_COMBINER2_C0(&c1);
2442            COLOR_COMBINER2_C1(&c2);
2443            BLENDER2_32(&fb[(index + i)], c1, c2);
26252444         }
26262445      }
26272446   }
r6714r6715
26312450   }
26322451}
26332452
2634INLINE void texture_rectangle_32bit(running_machine *machine, TEX_RECTANGLE *rect)
2453INLINE void texture_rectangle_32bit(TEX_RECTANGLE *rect)
26352454{   // TODO: Z-compare and Z-update
26362455   UINT32 *fb = (UINT32*)&rdram[(fb_address / 4)];
26372456   int i, j;
r6714r6715
27112530               TEXTURE_PIPELINE(&texel0_color, ss, st, tex_tile);
27122531            }
27132532
2714            c = COLOR_COMBINER1(machine);
2533            COLOR_COMBINER1(&c);
27152534
2716            BLENDER1_32(machine, &fb[(fb_index + i)], c);
2535            BLENDER1_32(&fb[(fb_index + i)], c);
27172536
27182537            s += rect->dsdx;
27192538         }
r6714r6715
27462565               TEXTURE_PIPELINE(&texel1_color, ss, st, tex_tile2);
27472566            }
27482567
2749            c1 = COLOR_COMBINER2_C0(machine);
2750            c2 = COLOR_COMBINER2_C1(machine);
2568            COLOR_COMBINER2_C0(&c1);
2569            COLOR_COMBINER2_C1(&c2);
27512570
2752            BLENDER2_32(machine, &fb[(fb_index + i)], c1, c2);
2571            BLENDER2_32(&fb[(fb_index + i)], c1, c2);
27532572
27542573            s += rect->dsdx;
27552574         }
r6714r6715
27932612}
27942613
27952614
2796static void render_spans_32(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip)
2615static void render_spans_32(int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip)
27972616{
27982617   UINT32 *fb = (UINT32*)&rdram[fb_address / 4];
27992618   UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
r6714r6715
28712690   dtinc = flip ? (dt.w) : -dt.w;
28722691   dwinc = flip ? (dw.w) : -dw.w;
28732692
2874   set_shade_for_tris(shade);
2693   if(!shade)
2694   {
2695      shade_color.c = prim_color.c;
2696   }
28752697
28762698   for (i = start; i <= end; i++)
28772699   {
r6714r6715
29732795
29742796               if (other_modes.cycle_type == CYCLE_TYPE_1)
29752797               {
2976                  c1 = COLOR_COMBINER1(machine);
2798                  COLOR_COMBINER1(&c1);
29772799               }
29782800               else if (other_modes.cycle_type == CYCLE_TYPE_2)
29792801               {
2980                  c1 = COLOR_COMBINER2_C0(machine);
2981                  c2 = COLOR_COMBINER2_C1(machine);
2802                  COLOR_COMBINER2_C0(&c1);
2803                  COLOR_COMBINER2_C1(&c2);
29822804                 }
29832805
29842806               if ((zbuffer || other_modes.z_source_sel) && other_modes.z_compare_en)
r6714r6715
29922814
29932815                  if (other_modes.cycle_type == CYCLE_TYPE_1)
29942816                  {
2995                     rendered = BLENDER1_32(machine, fbcur, c1);
2817                     rendered = BLENDER1_32(fbcur, c1);
29962818                  }
29972819                      else
29982820                      {
2999                     rendered = BLENDER2_32(machine, fbcur, c1, c2);
2821                     rendered = BLENDER2_32(fbcur, c1, c2);
30002822                  }
30012823
30022824                  if (other_modes.z_update_en && rendered)
r6714r6715
30232845
30242846/*****************************************************************************/
30252847
3026#include "rdpspn16.c"
3027
3028//#include "rdptri.c"
3029
3030static void triangle(running_machine *machine, UINT32 w1, UINT32 w2, int shade, int texture, int zbuffer)
2848/*
2849static void triangle(UINT32 w1, UINT32 w2, int shade, int texture, int zbuffer)
30312850{
30322851   int j;
30332852   int xleft, xright, xleft_inc, xright_inc;
r6714r6715
34733292
34743293   switch (fb_size) // 8bpp needs to be implemented
34753294   {
3476      case PIXEL_SIZE_16BIT:   render_spans_16(machine, yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break;
3477      case PIXEL_SIZE_32BIT:   render_spans_32(machine, yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break;
3295      case PIXEL_SIZE_16BIT:   render_spans_16(yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break;
3296      case PIXEL_SIZE_32BIT:   render_spans_32(yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break;
34783297      default: break; // V-Rally2 does this, fb_size=0
34793298   }
34803299}
3300*/
34813301
34823302/*****************************************************************************/
34833303
r6714r6715
38923712
38933713static RDP_COMMAND( rdp_tri_noshade )
38943714{
3895   triangle(machine, w1, w2, 0, 0, 0);
3715   triangle_ns_nt_nz(w1, w2);
38963716}
38973717
38983718static RDP_COMMAND( rdp_tri_noshade_z )
38993719{
3900   triangle(machine, w1, w2, 0, 0, 1);
3720   triangle_ns_nt_z(w1, w2);
39013721}
39023722
39033723static RDP_COMMAND( rdp_tri_tex )
39043724{
3905   triangle(machine, w1, w2, 0, 1, 0);
3725   triangle_ns_t_nz(w1, w2);
39063726}
39073727
39083728static RDP_COMMAND( rdp_tri_tex_z )
39093729{
3910   triangle(machine, w1, w2, 0, 1, 1);
3730   triangle_ns_t_z(w1, w2);
39113731}
39123732
39133733static RDP_COMMAND( rdp_tri_shade )
39143734{
3915   triangle(machine, w1, w2, 1, 0, 0);
3735   triangle_s_nt_nz(w1, w2);
39163736}
39173737
39183738static RDP_COMMAND( rdp_tri_shade_z )
39193739{
3920   triangle(machine, w1, w2, 1, 0, 1);
3740   triangle_s_nt_z(w1, w2);
39213741}
39223742
39233743static RDP_COMMAND( rdp_tri_texshade )
39243744{
3925   triangle(machine, w1, w2, 1, 1, 0);
3745   triangle_s_t_nz(w1, w2);
39263746}
39273747
39283748static RDP_COMMAND( rdp_tri_texshade_z )
39293749{
3930   triangle(machine, w1, w2, 1, 1, 1);
3750   triangle_s_t_z(w1, w2);
39313751}
39323752
39333753static RDP_COMMAND( rdp_tex_rect )
r6714r6715
39513771
39523772   switch (fb_size)
39533773   {
3954      case PIXEL_SIZE_16BIT:      texture_rectangle_16bit(machine, &rect); break;
3955      case PIXEL_SIZE_32BIT:      texture_rectangle_32bit(machine, &rect); break;
3774      case PIXEL_SIZE_16BIT:      texture_rectangle_16bit(&rect); break;
3775      case PIXEL_SIZE_32BIT:      texture_rectangle_32bit(&rect); break;
39563776   }
39573777}
39583778
r6714r6715
39773797
39783798   switch (fb_size)
39793799   {
3980      case PIXEL_SIZE_16BIT:      texture_rectangle_16bit(machine, &rect); break;
3981      case PIXEL_SIZE_32BIT:      texture_rectangle_32bit(machine, &rect); break;
3800      case PIXEL_SIZE_16BIT:      texture_rectangle_16bit(&rect); break;
3801      case PIXEL_SIZE_32BIT:      texture_rectangle_32bit(&rect); break;
39823802   }
39833803}
39843804
r6714r6715
40923912
40933913   alpha_compare = rdp_alpha_compare_func[(other_modes.alpha_compare_en << 1) | other_modes.dither_alpha_en];
40943914
4095   render_spans_16 = rdp_render_spans_16_func[(other_modes.cycle_type)];
3915   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))];
3916   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))];
3917   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))];
3918   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))];
3919   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))];
3920   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))];
3921   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))];
3922   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))];
3923   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))];
3924   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))];
3925   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))];
3926   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))];
3927   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))];
3928   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))];
3929   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))];
3930   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))];
40963931
40973932   TEXTURE_PIPELINE = rdp_texture_pipeline_func[(other_modes.mid_texel << 1) | other_modes.sample_type];
40983933
3934   CLAMP = (other_modes.cycle_type == CYCLE_TYPE_COPY) ? CLAMP_C : CLAMP_NC;
3935   CLAMP_LIGHT = (other_modes.cycle_type == CYCLE_TYPE_COPY) ? CLAMP_LIGHT_C : CLAMP_LIGHT_NC;
3936
40993937   for(index = 0; index < 8; index++)
41003938   {
41013939      tile[index].fetch_index = (tile[index].size << 5) | (tile[index].format << 2) | (other_modes.en_tlut << 1) | other_modes.tlut_type;
41023940   }
41033941
4104   FBWRITE_16 = rdp_fbwrite_16_func[(other_modes.image_read_en << 2) | other_modes.cvg_dest];
4105   FBWRITE_32 = rdp_fbwrite_32_func[(other_modes.image_read_en << 2) | other_modes.cvg_dest];
3942   FBWRITE_16 = rdp_fbwrite_16_func[(other_modes.color_on_cvg << 3) | (other_modes.image_read_en << 2) | other_modes.cvg_dest];
3943   FBWRITE_32 = rdp_fbwrite_32_func[(other_modes.color_on_cvg << 3) | (other_modes.image_read_en << 2) | other_modes.cvg_dest];
41063944
4107   BLENDER_EQUATION = other_modes.force_blend ? BLENDER_EQUATION_FORCE : BLENDER_EQUATION_NFORCE;
3945   BLENDER_EQUATION0 = other_modes.force_blend ? BLENDER_EQUATION0_FORCE : BLENDER_EQUATION0_NFORCE;
3946   BLENDER_EQUATION1 = other_modes.force_blend ? BLENDER_EQUATION1_FORCE : BLENDER_EQUATION1_NFORCE;
41083947
3948   BLENDER1_16 = rdp_blender1_16_func[(other_modes.image_read_en << 2) | (other_modes.z_compare_en << 1) | (other_modes.rgb_dither_sel >> 1)];
3949   BLENDER2_16 = rdp_blender2_16_func[(other_modes.image_read_en << 2) | (other_modes.z_compare_en << 1) | (other_modes.rgb_dither_sel >> 1)];
3950
41093951   SET_BLENDER_INPUT(0, 0, &blender1a_r[0], &blender1a_g[0], &blender1a_b[0], &blender1b_a[0],
41103952                 other_modes.blend_m1a_0, other_modes.blend_m1b_0);
41113953   SET_BLENDER_INPUT(0, 1, &blender2a_r[0], &blender2a_g[0], &blender2a_b[0], &blender2b_a[0],
r6714r6715
44684310
44694311   switch (fb_size)
44704312   {
4471      case PIXEL_SIZE_16BIT:      fill_rectangle_16bit(machine, &rect); break;
4472      case PIXEL_SIZE_32BIT:      fill_rectangle_32bit(machine, &rect); break;
4313      case PIXEL_SIZE_16BIT:      fill_rectangle_16bit(&rect); break;
4314      case PIXEL_SIZE_32BIT:      fill_rectangle_32bit(&rect); break;
44734315   }
44744316}
44754317
r6714r6715
46794521   dp_start = dp_current = dp_end;
46804522}
46814523
4682#include "rdpacomp.c"
4683#include "rdpacvg.c"
4684
4685INLINE UINT8 COMBINER_EQUATION(UINT8 A, UINT8 B, UINT8 C, UINT8 D)
4524INLINE void COMBINER_EQUATION(UINT8 *out, UINT8 *A, UINT8 *B, UINT8 *C, UINT8 *D)
46864525{
4687   INT32 color = (((A-B)* C) + (D << 8) + 0x80);
4526   INT32 color = (((*A-*B)* *C) + (*D << 8) + 0x80);
46884527   color >>= 8;
46894528   if (color > 255)
46904529   {
4691      return 255;
4530      *out = 255;
46924531   }
4693   if (color < 0)
4532   else if (color < 0)
46944533   {
4695      return 0;
4534      *out = 0;
46964535   }
4697   return (UINT8)color;
4536   else
4537   {
4538      *out = (UINT8)color;
4539   }
46984540}
46994541
4700INLINE void BLENDER_EQUATION_FORCE(INT32* r, INT32* g, INT32* b, int cycle, int bsel_special)
4542INLINE void BLENDER_EQUATION0_FORCE(INT32* r, INT32* g, INT32* b, int bsel_special)
47014543{
47024544   UINT8 blend1a, blend2a;
47034545   UINT32 sum = 0;
4704   blend1a = *blender1b_a[cycle];
4705   blend2a = *blender2b_a[cycle];
4546   INT32 tr, tg, tb;
4547   blend1a = *blender1b_a[0];
4548   blend2a = *blender2b_a[0];
47064549   if (bsel_special)
47074550   {
47084551      blend1a &= 0xe0;
r6714r6715
47104553
47114554   sum = (((blend1a >> 5) + (blend2a >> 5) + 1) & 0xf) << 5;
47124555
4713   *r = (((int)(*blender1a_r[cycle]) * (int)(blend1a))) +
4714      (((int)(*blender2a_r[cycle]) * (int)(blend2a)));
4715   *r += (bsel_special) ? (((int)(*blender2a_r[cycle])) << 5) : (((int)(*blender2a_r[cycle])) << 3);
4556   tr = (((int)(*blender1a_r[0]) * (int)(blend1a))) +
4557      (((int)(*blender2a_r[0]) * (int)(blend2a)));
4558   tr += (bsel_special) ? (((int)(*blender2a_r[0])) << 5) : (((int)(*blender2a_r[0])) << 3);
47164559
4717   *g = (((int)(*blender1a_g[cycle]) * (int)(blend1a))) +
4718      (((int)(*blender2a_g[cycle]) * (int)(blend2a)));
4719   *g += (bsel_special) ? ((int)((*blender2a_g[cycle])) << 5) : (((int)(*blender2a_g[cycle])) << 3);
4560   tg = (((int)(*blender1a_g[0]) * (int)(blend1a))) +
4561      (((int)(*blender2a_g[0]) * (int)(blend2a)));
4562   tg += (bsel_special) ? ((int)((*blender2a_g[0])) << 5) : (((int)(*blender2a_g[0])) << 3);
47204563
4721   *b = (((int)(*blender1a_b[cycle]) * (int)(blend1a))) +
4722      (((int)(*blender2a_b[cycle]) * (int)(blend2a)));
4723   *b += (bsel_special) ? (((int)(*blender2a_b[cycle])) << 5) : (((int)(*blender2a_b[cycle])) << 3);
4564   tb = (((int)(*blender1a_b[0]) * (int)(blend1a))) +
4565      (((int)(*blender2a_b[0]) * (int)(blend2a)));
4566   tb += (bsel_special) ? (((int)(*blender2a_b[0])) << 5) : (((int)(*blender2a_b[0])) << 3);
47244567
4725   *r >>= 8;
4726   *g >>= 8;
4727   *b >>= 8;
4568   tr >>= 8;
4569   tg >>= 8;
4570   tb >>= 8;
47284571
4729
4730   if (*r > 255) *r = 255;
4731   if (*g > 255) *g = 255;
4732   if (*b > 255) *b = 255;
4572   if (tr > 255) *r = 255; else *r = tr;
4573   if (tg > 255) *g = 255; else *g = tg;
4574   if (tb > 255) *b = 255; else *b = tb;
47334575}
47344576
4735INLINE void BLENDER_EQUATION_NFORCE(INT32* r, INT32* g, INT32* b, int cycle, int bsel_special)
4577INLINE void BLENDER_EQUATION0_NFORCE(INT32* r, INT32* g, INT32* b, int bsel_special)
47364578{
47374579   UINT8 blend1a, blend2a;
47384580   UINT32 sum = 0;
4739   blend1a = *blender1b_a[cycle];
4740   blend2a = *blender2b_a[cycle];
4581   INT32 tr, tg, tb;
4582   blend1a = *blender1b_a[0];
4583   blend2a = *blender2b_a[0];
47414584   if (bsel_special)
47424585   {
47434586      blend1a &= 0xe0;
r6714r6715
47454588
47464589   sum = (((blend1a >> 5) + (blend2a >> 5) + 1) & 0xf) << 5;
47474590
4748   *r = (((int)(*blender1a_r[cycle]) * (int)(blend1a))) +
4749      (((int)(*blender2a_r[cycle]) * (int)(blend2a)));
4750   *r += (bsel_special) ? (((int)(*blender2a_r[cycle])) << 5) : (((int)(*blender2a_r[cycle])) << 3);
4591   tr = (((int)(*blender1a_r[0]) * (int)(blend1a))) +
4592      (((int)(*blender2a_r[0]) * (int)(blend2a)));
4593   tr += (bsel_special) ? (((int)(*blender2a_r[0])) << 5) : (((int)(*blender2a_r[0])) << 3);
47514594
4752   *g = (((int)(*blender1a_g[cycle]) * (int)(blend1a))) +
4753      (((int)(*blender2a_g[cycle]) * (int)(blend2a)));
4754   *g += (bsel_special) ? ((int)((*blender2a_g[cycle])) << 5) : (((int)(*blender2a_g[cycle])) << 3);
4595   tg = (((int)(*blender1a_g[0]) * (int)(blend1a))) +
4596      (((int)(*blender2a_g[0]) * (int)(blend2a)));
4597   tg += (bsel_special) ? ((int)((*blender2a_g[0])) << 5) : (((int)(*blender2a_g[0])) << 3);
47554598
4756   *b = (((int)(*blender1a_b[cycle]) * (int)(blend1a))) +
4757      (((int)(*blender2a_b[cycle]) * (int)(blend2a)));
4758   *b += (bsel_special) ? (((int)(*blender2a_b[cycle])) << 5) : (((int)(*blender2a_b[cycle])) << 3);
4599   tb = (((int)(*blender1a_b[0]) * (int)(blend1a))) +
4600      (((int)(*blender2a_b[0]) * (int)(blend2a)));
4601   tb += (bsel_special) ? (((int)(*blender2a_b[0])) << 5) : (((int)(*blender2a_b[0])) << 3);
47594602
47604603   if (sum)
47614604   {
4762      *r /= sum;
4763      *g /= sum;
4764      *b /= sum;
4605      tr /= sum;
4606      tg /= sum;
4607      tb /= sum;
47654608   }
47664609   else
47674610   {
47684611      *r = *g = *b = 0xff;
4612      return;
47694613   }
47704614
47714615
4772   if (*r > 255) *r = 255;
4773   if (*g > 255) *g = 255;
4774   if (*b > 255) *b = 255;
4616   if (tr > 255) *r = 255; else *r = tr;
4617   if (tg > 255) *g = 255; else *g = tg;
4618   if (tb > 255) *b = 255; else *b = tb;
47754619}
47764620
4621INLINE void BLENDER_EQUATION1_FORCE(INT32* r, INT32* g, INT32* b, int bsel_special)
4622{
4623   UINT8 blend1a, blend2a;
4624   UINT32 sum = 0;
4625   INT32 tr, tg, tb;
4626   blend1a = *blender1b_a[1];
4627   blend2a = *blender2b_a[1];
4628   if (bsel_special)
4629   {
4630      blend1a &= 0xe0;
4631   }
4632
4633   sum = (((blend1a >> 5) + (blend2a >> 5) + 1) & 0xf) << 5;
4634
4635   tr = (((int)(*blender1a_r[1]) * (int)(blend1a))) +
4636      (((int)(*blender2a_r[1]) * (int)(blend2a)));
4637   tr += (bsel_special) ? (((int)(*blender2a_r[1])) << 5) : (((int)(*blender2a_r[1])) << 3);
4638
4639   tg = (((int)(*blender1a_g[1]) * (int)(blend1a))) +
4640      (((int)(*blender2a_g[1]) * (int)(blend2a)));
4641   tg += (bsel_special) ? ((int)((*blender2a_g[1])) << 5) : (((int)(*blender2a_g[1])) << 3);
4642
4643   tb = (((int)(*blender1a_b[1]) * (int)(blend1a))) +
4644      (((int)(*blender2a_b[1]) * (int)(blend2a)));
4645   tb += (bsel_special) ? (((int)(*blender2a_b[1])) << 5) : (((int)(*blender2a_b[1])) << 3);
4646
4647   tr >>= 8;
4648   tg >>= 8;
4649   tb >>= 8;
4650
4651   if (tr > 255) *r = 255; else *r = tr;
4652   if (tg > 255) *g = 255; else *g = tg;
4653   if (tb > 255) *b = 255; else *b = tb;
4654}
4655
4656INLINE void BLENDER_EQUATION1_NFORCE(INT32* r, INT32* g, INT32* b, int bsel_special)
4657{
4658   UINT8 blend1a, blend2a;
4659   UINT32 sum = 0;
4660   INT32 tr, tg, tb;
4661   blend1a = *blender1b_a[1];
4662   blend2a = *blender2b_a[1];
4663   if (bsel_special)
4664   {
4665      blend1a &= 0xe0;
4666   }
4667
4668   sum = (((blend1a >> 5) + (blend2a >> 5) + 1) & 0xf) << 5;
4669
4670   tr = (((int)(*blender1a_r[1]) * (int)(blend1a))) +
4671      (((int)(*blender2a_r[1]) * (int)(blend2a)));
4672   tr += (bsel_special) ? (((int)(*blender2a_r[1])) << 5) : (((int)(*blender2a_r[1])) << 3);
4673
4674   tg = (((int)(*blender1a_g[1]) * (int)(blend1a))) +
4675      (((int)(*blender2a_g[1]) * (int)(blend2a)));
4676   tg += (bsel_special) ? ((int)((*blender2a_g[1])) << 5) : (((int)(*blender2a_g[1])) << 3);
4677
4678   tb = (((int)(*blender1a_b[1]) * (int)(blend1a))) +
4679      (((int)(*blender2a_b[1]) * (int)(blend2a)));
4680   tb += (bsel_special) ? (((int)(*blender2a_b[1])) << 5) : (((int)(*blender2a_b[1])) << 3);
4681
4682   if (sum)
4683   {
4684      tr /= sum;
4685      tg /= sum;
4686      tb /= sum;
4687   }
4688   else
4689   {
4690      *r = *g = *b = 0xff;
4691      return;
4692   }
4693
4694   if (tr > 255) *r = 255; else *r = tr;
4695   if (tg > 255) *g = 255; else *g = tg;
4696   if (tb > 255) *b = 255; else *b = tb;
4697}
4698
47774699INLINE UINT32 addrightcvg(UINT32 x, UINT32 k)
47784700{
47794701//#undef FULL_SUBPIXELS
r6714r6715
48604782   }
48614783}
48624784
4863#include "video/rdpfb.c"
4785#include "video/rdpacomp.c"
4786
4787#include "video/rdpacvg.c"
4788
4789#define COLOR_ON_CVG
4790   #include "video/rdpfb.c"
4791#undef COLOR_ON_CVG
4792   #include "video/rdpfb.c"
4793
4794#define IMGREAD
4795   #define ZCOMPARE
4796      #define RGBDITHER1
4797         #include "video/rdpblend.c"
4798      #undef RGBDITHER1
4799         #include "video/rdpblend.c"
4800   #undef ZCOMPARE
4801      #define RGBDITHER1
4802         #include "video/rdpblend.c"
4803      #undef RGBDITHER1
4804         #include "video/rdpblend.c"
4805#undef IMGREAD
4806   #define ZCOMPARE
4807      #define RGBDITHER1
4808         #include "video/rdpblend.c"
4809      #undef RGBDITHER1
4810         #include "video/rdpblend.c"
4811   #undef ZCOMPARE
4812      #define RGBDITHER1
4813         #include "video/rdpblend.c"
4814      #undef RGBDITHER1
4815         #include "video/rdpblend.c"
4816
4817#include "video/rdpfetch.c"
4818
4819#include "video/rdptpipe.c"
4820
4821#define ZCOMPARE
4822   #define ZUPDATE
4823      #define MAGICDITHER
4824         #include "video/rdptrect.c"
4825      #undef MAGICDITHER
4826      #define BAYERDITHER
4827         #include "video/rdptrect.c"
4828      #undef BAYERDITHER
4829         #include "video/rdptrect.c"
4830   #undef ZUPDATE
4831      #define MAGICDITHER
4832         #include "video/rdptrect.c"
4833      #undef MAGICDITHER
4834      #define BAYERDITHER
4835         #include "video/rdptrect.c"
4836      #undef BAYERDITHER
4837         #include "video/rdptrect.c"
4838#undef ZCOMPARE
4839   #define ZUPDATE
4840      #define MAGICDITHER
4841         #include "video/rdptrect.c"
4842      #undef MAGICDITHER
4843      #define BAYERDITHER
4844         #include "video/rdptrect.c"
4845      #undef BAYERDITHER
4846         #include "video/rdptrect.c"
4847   #undef ZUPDATE
4848      #define MAGICDITHER
4849         #include "video/rdptrect.c"
4850      #undef MAGICDITHER
4851      #define BAYERDITHER
4852         #include "video/rdptrect.c"
4853      #undef BAYERDITHER
4854         #include "video/rdptrect.c"
4855
4856#define SHADE
4857   #define TEXTURE
4858      #define ZBUF
4859         #define FLIP
4860            #define ZUPDATE
4861               #define ZCOMPARE
4862                  #include "video/rdpspn16.c"
4863               #undef ZCOMPARE
4864                  #include "video/rdpspn16.c"
4865            #undef ZUPDATE
4866               #define ZCOMPARE
4867                  #include "video/rdpspn16.c"
4868               #undef ZCOMPARE
4869                  #include "video/rdpspn16.c"
4870         #undef FLIP
4871            #define ZUPDATE
4872               #define ZCOMPARE
4873                  #include "video/rdpspn16.c"
4874               #undef ZCOMPARE
4875                  #include "video/rdpspn16.c"
4876            #undef ZUPDATE
4877               #define ZCOMPARE
4878                  #include "video/rdpspn16.c"
4879               #undef ZCOMPARE
4880                  #include "video/rdpspn16.c"
4881      #undef ZBUF
4882         #define FLIP
4883            #define ZUPDATE
4884               #define ZCOMPARE
4885                  #include "video/rdpspn16.c"
4886               #undef ZCOMPARE
4887                  #include "video/rdpspn16.c"
4888            #undef ZUPDATE
4889               #define ZCOMPARE
4890                  #include "video/rdpspn16.c"
4891               #undef ZCOMPARE
4892                  #include "video/rdpspn16.c"
4893         #undef FLIP
4894            #define ZUPDATE
4895               #define ZCOMPARE
4896                  #include "video/rdpspn16.c"
4897               #undef ZCOMPARE
4898                  #include "video/rdpspn16.c"
4899            #undef ZUPDATE
4900               #define ZCOMPARE
4901                  #include "video/rdpspn16.c"
4902               #undef ZCOMPARE
4903                  #include "video/rdpspn16.c"
4904   #undef TEXTURE
4905      #define ZBUF
4906         #define FLIP
4907            #define ZUPDATE
4908               #define ZCOMPARE
4909                  #include "video/rdpspn16.c"
4910               #undef ZCOMPARE
4911                  #include "video/rdpspn16.c"
4912            #undef ZUPDATE
4913               #define ZCOMPARE
4914                  #include "video/rdpspn16.c"
4915               #undef ZCOMPARE
4916                  #include "video/rdpspn16.c"
4917         #undef FLIP
4918            #define ZUPDATE
4919               #define ZCOMPARE
4920                  #include "video/rdpspn16.c"
4921               #undef ZCOMPARE
4922                  #include "video/rdpspn16.c"
4923            #undef ZUPDATE
4924               #define ZCOMPARE
4925                  #include "video/rdpspn16.c"
4926               #undef ZCOMPARE
4927                  #include "video/rdpspn16.c"
4928      #undef ZBUF
4929         #define FLIP
4930            #define ZUPDATE
4931               #define ZCOMPARE
4932                  #include "video/rdpspn16.c"
4933               #undef ZCOMPARE
4934                  #include "video/rdpspn16.c"
4935            #undef ZUPDATE
4936               #define ZCOMPARE
4937                  #include "video/rdpspn16.c"
4938               #undef ZCOMPARE
4939                  #include "video/rdpspn16.c"
4940         #undef FLIP
4941            #define ZUPDATE
4942               #define ZCOMPARE
4943                  #include "video/rdpspn16.c"
4944               #undef ZCOMPARE
4945                  #include "video/rdpspn16.c"
4946            #undef ZUPDATE
4947               #define ZCOMPARE
4948                  #include "video/rdpspn16.c"
4949               #undef ZCOMPARE
4950                  #include "video/rdpspn16.c"
4951#undef SHADE
4952   #define TEXTURE
4953      #define ZBUF
4954         #define FLIP
4955            #define ZUPDATE
4956               #define ZCOMPARE
4957                  #include "video/rdpspn16.c"
4958               #undef ZCOMPARE
4959                  #include "video/rdpspn16.c"
4960            #undef ZUPDATE
4961               #define ZCOMPARE
4962                  #include "video/rdpspn16.c"
4963               #undef ZCOMPARE
4964                  #include "video/rdpspn16.c"
4965         #undef FLIP
4966            #define ZUPDATE
4967               #define ZCOMPARE
4968                  #include "video/rdpspn16.c"
4969               #undef ZCOMPARE
4970                  #include "video/rdpspn16.c"
4971            #undef ZUPDATE
4972               #define ZCOMPARE
4973                  #include "video/rdpspn16.c"
4974               #undef ZCOMPARE
4975                  #include "video/rdpspn16.c"
4976      #undef ZBUF
4977         #define FLIP
4978            #define ZUPDATE
4979               #define ZCOMPARE
4980                  #include "video/rdpspn16.c"
4981               #undef ZCOMPARE
4982                  #include "video/rdpspn16.c"
4983            #undef ZUPDATE
4984               #define ZCOMPARE
4985                  #include "video/rdpspn16.c"
4986               #undef ZCOMPARE
4987                  #include "video/rdpspn16.c"
4988         #undef FLIP
4989            #define ZUPDATE
4990               #define ZCOMPARE
4991                  #include "video/rdpspn16.c"
4992               #undef ZCOMPARE
4993                  #include "video/rdpspn16.c"
4994            #undef ZUPDATE
4995               #define ZCOMPARE
4996                  #include "video/rdpspn16.c"
4997               #undef ZCOMPARE
4998                  #include "video/rdpspn16.c"
4999   #undef TEXTURE
5000      #define ZBUF
5001         #define FLIP
5002            #define ZUPDATE
5003               #define ZCOMPARE
5004                  #include "video/rdpspn16.c"
5005               #undef ZCOMPARE
5006                  #include "video/rdpspn16.c"
5007            #undef ZUPDATE
5008               #define ZCOMPARE
5009                  #include "video/rdpspn16.c"
5010               #undef ZCOMPARE
5011                  #include "video/rdpspn16.c"
5012         #undef FLIP
5013            #define ZUPDATE
5014               #define ZCOMPARE
5015                  #include "video/rdpspn16.c"
5016               #undef ZCOMPARE
5017                  #include "video/rdpspn16.c"
5018            #undef ZUPDATE
5019               #define ZCOMPARE
5020                  #include "video/rdpspn16.c"
5021               #undef ZCOMPARE
5022                  #include "video/rdpspn16.c"
5023      #undef ZBUF
5024         #define FLIP
5025            #define ZUPDATE
5026               #define ZCOMPARE
5027                  #include "video/rdpspn16.c"
5028               #undef ZCOMPARE
5029                  #include "video/rdpspn16.c"
5030            #undef ZUPDATE
5031               #define ZCOMPARE
5032                  #include "video/rdpspn16.c"
5033               #undef ZCOMPARE
5034                  #include "video/rdpspn16.c"
5035         #undef FLIP
5036            #define ZUPDATE
5037               #define ZCOMPARE
5038                  #include "video/rdpspn16.c"
5039               #undef ZCOMPARE
5040                  #include "video/rdpspn16.c"
5041            #undef ZUPDATE
5042               #define ZCOMPARE
5043                  #include "video/rdpspn16.c"
5044               #undef ZCOMPARE
5045                  #include "video/rdpspn16.c"
5046#include "video/rdptri.c"
5047

Previous 15994 Revisions Next


© 1998-2018 The MESS Team