trunk/src/mame/video/n64.c
r25462 | r25463 | |
4 | 4 | SGI/Nintendo Reality Display Processor |
5 | 5 | ------------------- |
6 | 6 | |
7 | | Initial revision by Ville Linde |
8 | | Many improvements by Harmony, angrylion, Ziggy, Gonetz and Orkin |
| 7 | by MooglyGuy |
| 8 | based on initial C code by Ville Linde |
| 9 | contains additional improvements from angrylion, Ziggy, Gonetz and Orkin |
9 | 10 | |
10 | | Class re-write by Harmony |
11 | 11 | |
12 | | |
13 | 12 | ******************************************************************************* |
14 | 13 | |
15 | 14 | STATUS: |
16 | 15 | |
17 | | Much behavior needs verification against real hardware. Many literal edge |
18 | | cases must be verified on real hardware as well. |
| 16 | Much behavior needs verification against real hardware. Many edge cases must |
| 17 | be verified on real hardware as well. |
19 | 18 | |
20 | 19 | TODO: |
21 | 20 | |
r25462 | r25463 | |
36 | 35 | if(MiscState.FBSize == 0) return false; |
37 | 36 | |
38 | 37 | int fbcount = ((MiscState.FBWidth * Scissor.m_yl) << (MiscState.FBSize - 1)) * 3; |
39 | | int zbcount = MiscState.FBWidth * Scissor.m_yl * 2; |
40 | 38 | int fbaddr = MiscState.FBAddress & 0x007fffff; |
41 | | int zbaddr = MiscState.ZBAddress & 0x007fffff; |
42 | 39 | if ((addr >= fbaddr) && (addr < (fbaddr + fbcount))) |
43 | 40 | { |
44 | 41 | return false; |
45 | 42 | } |
| 43 | |
| 44 | int zbcount = MiscState.FBWidth * Scissor.m_yl * 2; |
| 45 | int zbaddr = MiscState.ZBAddress & 0x007fffff; |
46 | 46 | if ((addr >= zbaddr) && (addr < (zbaddr + zbcount))) |
47 | 47 | { |
48 | 48 | return false; |
r25462 | r25463 | |
899 | 899 | *offy = cvarray[index].yoff; |
900 | 900 | } |
901 | 901 | |
902 | | void n64_rdp::ZStore(UINT32 zcurpixel, UINT32 dzcurpixel, UINT32 z, UINT32 enc) |
| 902 | void n64_rdp::ZStore(const rdp_poly_state &object, UINT32 zcurpixel, UINT32 dzcurpixel, UINT32 z, UINT32 enc) |
903 | 903 | { |
904 | 904 | UINT16 zval = z_com_table[z & 0x3ffff]|(enc >> 2); |
905 | 905 | if(zcurpixel <= MEM16_LIMIT) |
r25462 | r25463 | |
2032 | 2032 | int dzdy_dz = (dzdy >> 16) & 0xffff; |
2033 | 2033 | int dzdx_dz = (dzdx >> 16) & 0xffff; |
2034 | 2034 | |
2035 | | extent_t Spans[1024]; |
| 2035 | extent_t Spans[2048]; |
2036 | 2036 | |
2037 | 2037 | SpanBase.m_span_drdy = drdy; |
2038 | 2038 | SpanBase.m_span_dgdy = dgdy; |
r25462 | r25463 | |
2121 | 2121 | |
2122 | 2122 | bool new_object = true; |
2123 | 2123 | rdp_poly_state *object = NULL; |
| 2124 | bool valid = false; |
2124 | 2125 | |
2125 | 2126 | if(flip) |
2126 | 2127 | { |
r25462 | r25463 | |
2135 | 2136 | int xstart = xleft >> 16; // 319 |
2136 | 2137 | int xend = xright >> 16; // 0 |
2137 | 2138 | int j = k >> 2; |
| 2139 | int spanidx = (k - ycur) >> 2; |
2138 | 2140 | int spix = k & 3; |
2139 | 2141 | valid_y = !(k < yh || k >= yl); |
2140 | 2142 | |
2141 | | if (k >= 0 && k < 0x1000) |
| 2143 | if (spanidx >= 0 && spanidx < 2048) |
2142 | 2144 | { |
2143 | 2145 | majorxint[spix] = xend; // 0 |
2144 | 2146 | minorxint[spix] = xstart; // 319 |
r25462 | r25463 | |
2166 | 2168 | new_object = false; |
2167 | 2169 | } |
2168 | 2170 | |
2169 | | Spans[j - (ycur >> 2)].userdata = (void*)((UINT8*)AuxBuf + AuxBufPtr); |
| 2171 | Spans[spanidx].userdata = (void*)((UINT8*)AuxBuf + AuxBufPtr); |
2170 | 2172 | AuxBufPtr += sizeof(rdp_span_aux); |
2171 | 2173 | |
2172 | 2174 | if(AuxBufPtr >= EXTENT_AUX_COUNT) |
r25462 | r25463 | |
2174 | 2176 | fatalerror("n64_rdp::DrawTriangle: span aux buffer overflow\n"); |
2175 | 2177 | } |
2176 | 2178 | |
2177 | | rdp_span_aux *userdata = (rdp_span_aux*)Spans[j - (ycur >> 2)].userdata; |
| 2179 | rdp_span_aux *userdata = (rdp_span_aux*)Spans[spanidx].userdata; |
| 2180 | valid = true; |
2178 | 2181 | |
2179 | 2182 | userdata->m_tmem = object->m_tmem; |
2180 | 2183 | |
r25462 | r25463 | |
2252 | 2255 | |
2253 | 2256 | if (spix == 3) |
2254 | 2257 | { |
2255 | | Spans[j - (ycur >> 2)].startx = maxxmx; |
2256 | | Spans[j - (ycur >> 2)].stopx = minxhx; |
| 2258 | Spans[spanidx].startx = maxxmx; |
| 2259 | Spans[spanidx].stopx = minxhx; |
2257 | 2260 | compute_cvg_flip(Spans, majorx, minorx, majorxint, minorxint, j, yh, yl, ycur >> 2); |
2258 | 2261 | } |
2259 | 2262 | |
2260 | 2263 | if (spix == ldflag) |
2261 | 2264 | { |
2262 | | ((rdp_span_aux*)Spans[j - (ycur >> 2)].userdata)->m_unscissored_rx = xend; |
| 2265 | ((rdp_span_aux*)Spans[spanidx].userdata)->m_unscissored_rx = xend; |
2263 | 2266 | xfrac = ((xright >> 8) & 0xff); |
2264 | | Spans[j - (ycur >> 2)].param[SPAN_R].start = ((r >> 9) << 9) + drdiff - (xfrac * drdxh); |
2265 | | Spans[j - (ycur >> 2)].param[SPAN_G].start = ((g >> 9) << 9) + dgdiff - (xfrac * dgdxh); |
2266 | | Spans[j - (ycur >> 2)].param[SPAN_B].start = ((b >> 9) << 9) + dbdiff - (xfrac * dbdxh); |
2267 | | Spans[j - (ycur >> 2)].param[SPAN_A].start = ((a >> 9) << 9) + dadiff - (xfrac * dadxh); |
2268 | | Spans[j - (ycur >> 2)].param[SPAN_S].start = (((s >> 9) << 9) + dsdiff - (xfrac * dsdxh)) & ~0x1f; |
2269 | | Spans[j - (ycur >> 2)].param[SPAN_T].start = (((t >> 9) << 9) + dtdiff - (xfrac * dtdxh)) & ~0x1f; |
2270 | | Spans[j - (ycur >> 2)].param[SPAN_W].start = (((w >> 9) << 9) + dwdiff - (xfrac * dwdxh)) & ~0x1f; |
2271 | | Spans[j - (ycur >> 2)].param[SPAN_Z].start = ((z >> 9) << 9) + dzdiff - (xfrac * dzdxh); |
| 2267 | Spans[spanidx].param[SPAN_R].start = ((r >> 9) << 9) + drdiff - (xfrac * drdxh); |
| 2268 | Spans[spanidx].param[SPAN_G].start = ((g >> 9) << 9) + dgdiff - (xfrac * dgdxh); |
| 2269 | Spans[spanidx].param[SPAN_B].start = ((b >> 9) << 9) + dbdiff - (xfrac * dbdxh); |
| 2270 | Spans[spanidx].param[SPAN_A].start = ((a >> 9) << 9) + dadiff - (xfrac * dadxh); |
| 2271 | Spans[spanidx].param[SPAN_S].start = (((s >> 9) << 9) + dsdiff - (xfrac * dsdxh)) & ~0x1f; |
| 2272 | Spans[spanidx].param[SPAN_T].start = (((t >> 9) << 9) + dtdiff - (xfrac * dtdxh)) & ~0x1f; |
| 2273 | Spans[spanidx].param[SPAN_W].start = (((w >> 9) << 9) + dwdiff - (xfrac * dwdxh)) & ~0x1f; |
| 2274 | Spans[spanidx].param[SPAN_Z].start = ((z >> 9) << 9) + dzdiff - (xfrac * dzdxh); |
2272 | 2275 | } |
2273 | 2276 | } |
2274 | 2277 | |
r25462 | r25463 | |
2301 | 2304 | int xstart = xleft >> 16; |
2302 | 2305 | int xend = xright >> 16; |
2303 | 2306 | int j = k >> 2; |
| 2307 | int spanidx = j - (ycur >> 2); |
2304 | 2308 | int spix = k & 3; |
2305 | 2309 | valid_y = !(k < yh || k >= yl); |
2306 | 2310 | |
r25462 | r25463 | |
2332 | 2336 | new_object = false; |
2333 | 2337 | } |
2334 | 2338 | |
2335 | | Spans[j - (ycur >> 2)].userdata = (void*)((UINT8*)AuxBuf + AuxBufPtr); |
| 2339 | Spans[spanidx].userdata = (void*)((UINT8*)AuxBuf + AuxBufPtr); |
| 2340 | valid = true; |
2336 | 2341 | AuxBufPtr += sizeof(rdp_span_aux); |
2337 | 2342 | |
2338 | 2343 | if(AuxBufPtr >= EXTENT_AUX_COUNT) |
r25462 | r25463 | |
2340 | 2345 | fatalerror("n64_rdp::DrawTriangle: span aux buffer overflow\n"); |
2341 | 2346 | } |
2342 | 2347 | |
2343 | | rdp_span_aux *userdata = (rdp_span_aux*)Spans[j - (ycur >> 2)].userdata; |
| 2348 | rdp_span_aux *userdata = (rdp_span_aux*)Spans[spanidx].userdata; |
2344 | 2349 | userdata->m_tmem = object->m_tmem; |
2345 | 2350 | |
2346 | 2351 | userdata->BlendColor = BlendColor; |
r25462 | r25463 | |
2417 | 2422 | |
2418 | 2423 | if (spix == 3) |
2419 | 2424 | { |
2420 | | Spans[j - (ycur >> 2)].startx = minxmx; |
2421 | | Spans[j - (ycur >> 2)].stopx = maxxhx; |
| 2425 | Spans[spanidx].startx = minxmx; |
| 2426 | Spans[spanidx].stopx = maxxhx; |
2422 | 2427 | compute_cvg_noflip(Spans, majorx, minorx, majorxint, minorxint, j, yh, yl, ycur >> 2); |
2423 | 2428 | } |
2424 | 2429 | |
2425 | 2430 | if (spix == ldflag) |
2426 | 2431 | { |
2427 | | ((rdp_span_aux*)Spans[j - (ycur >> 2)].userdata)->m_unscissored_rx = xend; |
| 2432 | ((rdp_span_aux*)Spans[spanidx].userdata)->m_unscissored_rx = xend; |
2428 | 2433 | xfrac = ((xright >> 8) & 0xff); |
2429 | | Spans[j - (ycur >> 2)].param[SPAN_R].start = ((r >> 9) << 9) + drdiff - (xfrac * drdxh); |
2430 | | Spans[j - (ycur >> 2)].param[SPAN_G].start = ((g >> 9) << 9) + dgdiff - (xfrac * dgdxh); |
2431 | | Spans[j - (ycur >> 2)].param[SPAN_B].start = ((b >> 9) << 9) + dbdiff - (xfrac * dbdxh); |
2432 | | Spans[j - (ycur >> 2)].param[SPAN_A].start = ((a >> 9) << 9) + dadiff - (xfrac * dadxh); |
2433 | | Spans[j - (ycur >> 2)].param[SPAN_S].start = (((s >> 9) << 9) + dsdiff - (xfrac * dsdxh)) & ~0x1f; |
2434 | | Spans[j - (ycur >> 2)].param[SPAN_T].start = (((t >> 9) << 9) + dtdiff - (xfrac * dtdxh)) & ~0x1f; |
2435 | | Spans[j - (ycur >> 2)].param[SPAN_W].start = (((w >> 9) << 9) + dwdiff - (xfrac * dwdxh)) & ~0x1f; |
2436 | | Spans[j - (ycur >> 2)].param[SPAN_Z].start = ((z >> 9) << 9) + dzdiff - (xfrac * dzdxh); |
| 2434 | Spans[spanidx].param[SPAN_R].start = ((r >> 9) << 9) + drdiff - (xfrac * drdxh); |
| 2435 | Spans[spanidx].param[SPAN_G].start = ((g >> 9) << 9) + dgdiff - (xfrac * dgdxh); |
| 2436 | Spans[spanidx].param[SPAN_B].start = ((b >> 9) << 9) + dbdiff - (xfrac * dbdxh); |
| 2437 | Spans[spanidx].param[SPAN_A].start = ((a >> 9) << 9) + dadiff - (xfrac * dadxh); |
| 2438 | Spans[spanidx].param[SPAN_S].start = (((s >> 9) << 9) + dsdiff - (xfrac * dsdxh)) & ~0x1f; |
| 2439 | Spans[spanidx].param[SPAN_T].start = (((t >> 9) << 9) + dtdiff - (xfrac * dtdxh)) & ~0x1f; |
| 2440 | Spans[spanidx].param[SPAN_W].start = (((w >> 9) << 9) + dwdiff - (xfrac * dwdxh)) & ~0x1f; |
| 2441 | Spans[spanidx].param[SPAN_Z].start = ((z >> 9) << 9) + dzdiff - (xfrac * dzdxh); |
2437 | 2442 | } |
2438 | 2443 | } |
2439 | 2444 | |
r25462 | r25463 | |
2453 | 2458 | } |
2454 | 2459 | } |
2455 | 2460 | |
2456 | | if(!new_object) |
| 2461 | if(!new_object && valid) |
2457 | 2462 | { |
2458 | 2463 | RenderSpans(yh >> 2, yl >> 2, tilenum, flip ? true : false, Spans, rect, object); |
2459 | 2464 | } |
trunk/src/mame/video/rdpblend.c
r25462 | r25463 | |
| 1 | /****************************************************************************** |
| 2 | |
| 3 | |
| 4 | SGI/Nintendo Reality Display Processor Blend Unit (BL) |
| 5 | ------------------- |
| 6 | |
| 7 | by MooglyGuy |
| 8 | based on initial C code by Ville Linde |
| 9 | contains additional improvements from angrylion, Ziggy, Gonetz and Orkin |
| 10 | |
| 11 | |
| 12 | ******************************************************************************/ |
| 13 | |
1 | 14 | #include "emu.h" |
2 | 15 | #include "includes/n64.h" |
3 | 16 | #include "video/n64.h" |
| 17 | #include "video/rdpbhelp.h" |
4 | 18 | |
5 | 19 | N64BlenderT::N64BlenderT() |
6 | 20 | { |
r25462 | r25463 | |
31 | 45 | cycle1[1] = &N64BlenderT::BlendEquationCycle1NoForceSpecial; |
32 | 46 | cycle1[2] = &N64BlenderT::BlendEquationCycle1ForceNoSpecial; |
33 | 47 | cycle1[3] = &N64BlenderT::BlendEquationCycle1ForceSpecial; |
| 48 | |
| 49 | compare[0] = &N64BlenderT::AlphaCompareNone; |
| 50 | compare[1] = &N64BlenderT::AlphaCompareNone; |
| 51 | compare[2] = &N64BlenderT::AlphaCompareNoDither; |
| 52 | compare[3] = &N64BlenderT::AlphaCompareDither; |
34 | 53 | } |
35 | 54 | |
36 | | #define ALPHA_COMPARE() \ |
37 | | if (!AlphaCompare(userdata->PixelColor.i.a, userdata, object)) \ |
38 | | { \ |
39 | | return false; \ |
40 | | } |
41 | | |
42 | | #define CVG_COMPARE() \ |
43 | | if (object.OtherModes.antialias_en ? (!userdata->CurrentPixCvg) : (!userdata->CurrentCvgBit)) \ |
44 | | { \ |
45 | | return false; \ |
46 | | } |
47 | | |
48 | | #define TEST_REJECT() \ |
49 | | ALPHA_COMPARE() \ |
50 | | CVG_COMPARE() |
51 | | |
52 | | #define WRITE_OUT_NB_ND(cycle) \ |
53 | | *fr = *userdata->ColorInputs.blender1a_r[cycle]; \ |
54 | | *fg = *userdata->ColorInputs.blender1a_g[cycle]; \ |
55 | | *fb = *userdata->ColorInputs.blender1a_b[cycle]; |
56 | | |
57 | | #define WRITE_OUT() \ |
58 | | *fr = r; \ |
59 | | *fg = g; \ |
60 | | *fb = b; |
61 | | |
62 | | #define WRITE_BLENDED_COLOR() \ |
63 | | userdata->BlendedPixelColor.i.r = r; \ |
64 | | userdata->BlendedPixelColor.i.g = g; \ |
65 | | userdata->BlendedPixelColor.i.b = b; \ |
66 | | userdata->BlendedPixelColor.i.a = userdata->PixelColor.i.a; |
67 | | |
68 | | #define BLEND_CYCLE(cyc) \ |
69 | | if (partialreject && userdata->PixelColor.i.a >= 0xff) \ |
70 | | { \ |
71 | | ASSIGN_OUT(cyc); \ |
72 | | } \ |
73 | | else \ |
74 | | { \ |
75 | | userdata->InvPixelColor.i.a = 0xff - *userdata->ColorInputs.blender1b_a[cyc]; \ |
76 | | ((this)->*(cycle##cyc[((object.OtherModes.force_blend & 1) << 1) | (special_bsel##cyc & 1)]))(&r, &g, &b, userdata, object); \ |
77 | | } |
78 | | |
79 | | #define BLEND_FACTORS(cycle) \ |
80 | | UINT8 blend1a = *userdata->ColorInputs.blender1b_a[cycle] >> 3; \ |
81 | | UINT8 blend2a = *userdata->ColorInputs.blender2b_a[cycle] >> 3; |
82 | | |
83 | | #define BLEND_FACTORS_SUM(cycle) \ |
84 | | UINT8 blend1a = *userdata->ColorInputs.blender1b_a[cycle] >> 3; \ |
85 | | UINT8 blend2a = *userdata->ColorInputs.blender2b_a[cycle] >> 3; \ |
86 | | UINT32 sum = ((blend1a >> 2) + (blend2a >> 2) + 1) & 0xf; |
87 | | |
88 | | #define BLEND_FACTORS_SPECIAL(cycle) \ |
89 | | UINT8 blend1a = (*userdata->ColorInputs.blender1b_a[cycle] >> (3 + userdata->ShiftA)) & 0x1c; \ |
90 | | UINT8 blend2a = (*userdata->ColorInputs.blender2b_a[cycle] >> (3 + userdata->ShiftB)) & 0x1c; |
91 | | |
92 | | #define BLEND_FACTORS_SPECIAL_SUM(cycle) \ |
93 | | UINT8 blend1a = (*userdata->ColorInputs.blender1b_a[cycle] >> (3 + userdata->ShiftA)) & 0x1c; \ |
94 | | UINT8 blend2a = (*userdata->ColorInputs.blender2b_a[cycle] >> (3 + userdata->ShiftB)) & 0x1c; \ |
95 | | UINT32 sum = ((blend1a >> 2) + (blend2a >> 2) + 1) & 0xf; |
96 | | |
97 | | #define BLEND_MUL(cycle) \ |
98 | | *r = (((int)(*userdata->ColorInputs.blender1a_r[cycle]) * (int)(blend1a))) + \ |
99 | | (((int)(*userdata->ColorInputs.blender2a_r[cycle]) * (int)(blend2a))); \ |
100 | | *g = (((int)(*userdata->ColorInputs.blender1a_g[cycle]) * (int)(blend1a))) + \ |
101 | | (((int)(*userdata->ColorInputs.blender2a_g[cycle]) * (int)(blend2a))); \ |
102 | | *b = (((int)(*userdata->ColorInputs.blender1a_b[cycle]) * (int)(blend1a))) + \ |
103 | | (((int)(*userdata->ColorInputs.blender2a_b[cycle]) * (int)(blend2a))); |
104 | | |
105 | | #define BLEND_ADD_SPECIAL(cycle) \ |
106 | | *r += (((int)*userdata->ColorInputs.blender2a_r[cycle]) << 2); \ |
107 | | *g += (((int)*userdata->ColorInputs.blender2a_g[cycle]) << 2); \ |
108 | | *b += (((int)*userdata->ColorInputs.blender2a_b[cycle]) << 2); |
109 | | |
110 | | #define BLEND_ADD(cycle) \ |
111 | | *r += (int)*userdata->ColorInputs.blender2a_r[cycle]; \ |
112 | | *g += (int)*userdata->ColorInputs.blender2a_g[cycle]; \ |
113 | | *b += (int)*userdata->ColorInputs.blender2a_b[cycle]; |
114 | | |
115 | | #define BLEND_SHIFT(shift) \ |
116 | | *r >>= shift; \ |
117 | | *g >>= shift; \ |
118 | | *b >>= shift; |
119 | | |
120 | | #define BLEND_CLAMP() \ |
121 | | if (*r > 255) *r = 255; \ |
122 | | if (*g > 255) *g = 255; \ |
123 | | if (*b > 255) *b = 255; |
124 | | |
125 | | #define BLEND_SCALE() \ |
126 | | if (sum) \ |
127 | | { \ |
128 | | *r /= sum; \ |
129 | | *g /= sum; \ |
130 | | *b /= sum; \ |
131 | | } \ |
132 | | else \ |
133 | | { \ |
134 | | *r = *g = *b = 0xff; \ |
135 | | } |
136 | | |
137 | | |
138 | | #define ASSIGN_OUT(cycle) \ |
139 | | r = *userdata->ColorInputs.blender1a_r[cycle]; \ |
140 | | g = *userdata->ColorInputs.blender1a_g[cycle]; \ |
141 | | b = *userdata->ColorInputs.blender1a_b[cycle]; |
142 | | |
143 | | bool N64BlenderT::Blend1CycleNoBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 55 | bool N64BlenderT::Blend1CycleNoBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
144 | 56 | { |
145 | | DitherA(&userdata->PixelColor.i.a, adseed); |
146 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
147 | | |
| 57 | DITHER_A(userdata->PixelColor.i.a, adseed); |
| 58 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
148 | 59 | TEST_REJECT(); |
149 | 60 | WRITE_OUT_NB_ND(0); |
150 | 61 | |
151 | 62 | return true; |
152 | 63 | } |
153 | 64 | |
154 | | bool N64BlenderT::Blend1CycleNoBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 65 | bool N64BlenderT::Blend1CycleNoBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
155 | 66 | { |
156 | 67 | INT32 r, g, b; |
157 | 68 | |
158 | | DitherA(&userdata->PixelColor.i.a, adseed); |
159 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
160 | | |
| 69 | DITHER_A(userdata->PixelColor.i.a, adseed); |
| 70 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
161 | 71 | TEST_REJECT(); |
162 | 72 | ASSIGN_OUT(0); |
163 | | DitherRGB(&r, &g, &b, dith); |
| 73 | DITHER_RGB(dith); |
164 | 74 | WRITE_OUT(); |
165 | 75 | |
166 | 76 | return true; |
167 | 77 | } |
168 | 78 | |
169 | | bool N64BlenderT::Blend1CycleNoBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 79 | bool N64BlenderT::Blend1CycleNoBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
170 | 80 | { |
171 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 81 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
172 | 82 | |
173 | 83 | TEST_REJECT(); |
174 | 84 | WRITE_OUT_NB_ND(0); |
r25462 | r25463 | |
176 | 86 | return true; |
177 | 87 | } |
178 | 88 | |
179 | | bool N64BlenderT::Blend1CycleNoBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 89 | bool N64BlenderT::Blend1CycleNoBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
180 | 90 | { |
181 | 91 | INT32 r, g, b; |
182 | 92 | |
183 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 93 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
184 | 94 | |
185 | 95 | TEST_REJECT(); |
186 | 96 | ASSIGN_OUT(0); |
187 | | DitherRGB(&r, &g, &b, dith); |
| 97 | DITHER_RGB(dith); |
188 | 98 | WRITE_OUT(); |
189 | 99 | |
190 | 100 | return true; |
191 | 101 | } |
192 | 102 | |
193 | | bool N64BlenderT::Blend1CycleBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 103 | bool N64BlenderT::Blend1CycleBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
194 | 104 | { |
195 | 105 | INT32 r, g, b; |
196 | 106 | |
197 | | DitherA(&userdata->PixelColor.i.a, adseed); |
198 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 107 | DITHER_A(userdata->PixelColor.i.a, adseed); |
| 108 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
199 | 109 | |
200 | 110 | TEST_REJECT(); |
201 | | BLEND_CYCLE(0); |
| 111 | BLEND_CYCLE(0, 1); |
202 | 112 | WRITE_OUT(); |
203 | 113 | |
204 | 114 | return true; |
205 | 115 | } |
206 | 116 | |
207 | | bool N64BlenderT::Blend1CycleBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 117 | bool N64BlenderT::Blend1CycleBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
208 | 118 | { |
209 | 119 | INT32 r, g, b; |
210 | 120 | |
211 | | DitherA(&userdata->PixelColor.i.a, adseed); |
212 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 121 | DITHER_A(userdata->PixelColor.i.a, adseed); |
| 122 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
213 | 123 | |
214 | 124 | TEST_REJECT(); |
215 | | BLEND_CYCLE(0); |
216 | | DitherRGB(&r, &g, &b, dith); |
| 125 | BLEND_CYCLE(0, 1); |
| 126 | DITHER_RGB(dith); |
217 | 127 | WRITE_OUT(); |
218 | 128 | |
219 | 129 | return true; |
220 | 130 | } |
221 | 131 | |
222 | | bool N64BlenderT::Blend1CycleBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 132 | bool N64BlenderT::Blend1CycleBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
223 | 133 | { |
224 | 134 | INT32 r, g, b; |
225 | 135 | |
226 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 136 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
227 | 137 | |
228 | 138 | TEST_REJECT(); |
229 | | BLEND_CYCLE(0); |
| 139 | BLEND_CYCLE(0, 1); |
230 | 140 | WRITE_OUT(); |
231 | 141 | |
232 | 142 | return true; |
233 | 143 | } |
234 | 144 | |
235 | | bool N64BlenderT::Blend1CycleBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 145 | bool N64BlenderT::Blend1CycleBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
236 | 146 | { |
237 | 147 | INT32 r, g, b; |
238 | 148 | |
239 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 149 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
240 | 150 | |
241 | 151 | TEST_REJECT(); |
242 | | BLEND_CYCLE(0); |
243 | | DitherRGB(&r, &g, &b, dith); |
| 152 | BLEND_CYCLE(0, 1); |
| 153 | DITHER_RGB(dith); |
244 | 154 | WRITE_OUT(); |
245 | 155 | |
246 | 156 | return true; |
247 | 157 | } |
248 | 158 | |
249 | | bool N64BlenderT::Blend2CycleNoBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, int special_bsel1, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 159 | bool N64BlenderT::Blend2CycleNoBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
250 | 160 | { |
251 | 161 | INT32 r, g, b; |
252 | 162 | |
253 | | DitherA(&userdata->PixelColor.i.a, adseed); |
254 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 163 | DITHER_A(userdata->PixelColor.i.a, adseed); |
| 164 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
255 | 165 | |
256 | 166 | TEST_REJECT(); |
257 | | userdata->InvPixelColor.i.a = 0xff - *userdata->ColorInputs.blender1b_a[0]; |
258 | | ((this)->*(cycle0[((object.OtherModes.force_blend & 1) << 1) | (special_bsel0 & 1)]))(&r, &g, &b, userdata, object); |
| 167 | BLEND_CYCLE(0, 0); |
259 | 168 | WRITE_BLENDED_COLOR(); |
260 | 169 | WRITE_OUT_NB_ND(1); |
261 | 170 | |
262 | 171 | return true; |
263 | 172 | } |
264 | 173 | |
265 | | bool N64BlenderT::Blend2CycleNoBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, int special_bsel1, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 174 | bool N64BlenderT::Blend2CycleNoBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
266 | 175 | { |
267 | 176 | INT32 r, g, b; |
268 | 177 | |
269 | | DitherA(&userdata->PixelColor.i.a, adseed); |
270 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 178 | DITHER_A(userdata->PixelColor.i.a, adseed); |
| 179 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
271 | 180 | |
272 | 181 | TEST_REJECT(); |
273 | | userdata->InvPixelColor.i.a = 0xff - *userdata->ColorInputs.blender1b_a[0]; |
274 | | ((this)->*(cycle0[((object.OtherModes.force_blend & 1) << 1) | (special_bsel0 & 1)]))(&r, &g, &b, userdata, object); |
| 182 | BLEND_CYCLE(0, 0); |
275 | 183 | WRITE_BLENDED_COLOR(); |
276 | 184 | ASSIGN_OUT(1); |
277 | | DitherRGB(&r, &g, &b, dith); |
| 185 | DITHER_RGB(dith); |
278 | 186 | WRITE_OUT(); |
279 | 187 | |
280 | 188 | return true; |
281 | 189 | } |
282 | 190 | |
283 | | bool N64BlenderT::Blend2CycleNoBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, int special_bsel1, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 191 | bool N64BlenderT::Blend2CycleNoBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
284 | 192 | { |
285 | 193 | INT32 r, g, b; |
286 | 194 | |
287 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 195 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
288 | 196 | |
289 | 197 | TEST_REJECT(); |
290 | | userdata->InvPixelColor.i.a = 0xff - *userdata->ColorInputs.blender1b_a[0]; |
291 | | ((this)->*(cycle0[((object.OtherModes.force_blend & 1) << 1) | (special_bsel0 & 1)]))(&r, &g, &b, userdata, object); |
| 198 | BLEND_CYCLE(0, 0); |
292 | 199 | WRITE_BLENDED_COLOR(); |
293 | 200 | WRITE_OUT_NB_ND(1); |
294 | 201 | |
295 | 202 | return true; |
296 | 203 | } |
297 | 204 | |
298 | | bool N64BlenderT::Blend2CycleNoBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, int special_bsel1, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 205 | bool N64BlenderT::Blend2CycleNoBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
299 | 206 | { |
300 | 207 | INT32 r, g, b; |
301 | 208 | |
302 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 209 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
303 | 210 | |
304 | 211 | TEST_REJECT(); |
305 | | userdata->InvPixelColor.i.a = 0xff - *userdata->ColorInputs.blender1b_a[0]; |
306 | | ((this)->*(cycle0[((object.OtherModes.force_blend & 1) << 1) | (special_bsel0 & 1)]))(&r, &g, &b, userdata, object); |
| 212 | BLEND_CYCLE(0, 0); |
307 | 213 | WRITE_BLENDED_COLOR(); |
308 | 214 | ASSIGN_OUT(1); |
309 | | DitherRGB(&r, &g, &b, dith); |
| 215 | DITHER_RGB(dith); |
310 | 216 | WRITE_OUT(); |
311 | 217 | |
312 | 218 | return true; |
313 | 219 | } |
314 | 220 | |
315 | | bool N64BlenderT::Blend2CycleBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, int special_bsel1, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 221 | bool N64BlenderT::Blend2CycleBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
316 | 222 | { |
317 | 223 | INT32 r, g, b; |
318 | 224 | |
319 | | DitherA(&userdata->PixelColor.i.a, adseed); |
320 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 225 | DITHER_A(userdata->PixelColor.i.a, adseed); |
| 226 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
321 | 227 | |
322 | 228 | TEST_REJECT(); |
323 | | userdata->InvPixelColor.i.a = 0xff - *userdata->ColorInputs.blender1b_a[0]; |
324 | | ((this)->*(cycle0[((object.OtherModes.force_blend & 1) << 1) | (special_bsel0 & 1)]))(&r, &g, &b, userdata, object); |
| 229 | BLEND_CYCLE(0, 0); |
325 | 230 | WRITE_BLENDED_COLOR(); |
326 | | BLEND_CYCLE(1); |
| 231 | BLEND_CYCLE(1, 1); |
327 | 232 | WRITE_OUT(); |
328 | 233 | |
329 | 234 | return true; |
330 | 235 | } |
331 | 236 | |
332 | | bool N64BlenderT::Blend2CycleBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, int special_bsel1, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 237 | bool N64BlenderT::Blend2CycleBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
333 | 238 | { |
334 | 239 | INT32 r, g, b; |
335 | 240 | |
336 | | DitherA(&userdata->PixelColor.i.a, adseed); |
337 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 241 | DITHER_A(userdata->PixelColor.i.a, adseed); |
| 242 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
338 | 243 | |
339 | 244 | TEST_REJECT(); |
340 | | userdata->InvPixelColor.i.a = 0xff - *userdata->ColorInputs.blender1b_a[0]; |
341 | | ((this)->*(cycle0[((object.OtherModes.force_blend & 1) << 1) | (special_bsel0 & 1)]))(&r, &g, &b, userdata, object); |
| 245 | BLEND_CYCLE(0, 0); |
342 | 246 | WRITE_BLENDED_COLOR(); |
343 | | BLEND_CYCLE(1); |
344 | | DitherRGB(&r, &g, &b, dith); |
| 247 | BLEND_CYCLE(1, 1); |
| 248 | DITHER_RGB(dith); |
345 | 249 | WRITE_OUT(); |
346 | 250 | |
347 | 251 | return true; |
348 | 252 | } |
349 | 253 | |
350 | | bool N64BlenderT::Blend2CycleBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, int special_bsel1, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 254 | bool N64BlenderT::Blend2CycleBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
351 | 255 | { |
352 | 256 | INT32 r, g, b; |
353 | 257 | |
354 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 258 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
355 | 259 | |
356 | 260 | TEST_REJECT(); |
357 | | userdata->InvPixelColor.i.a = 0xff - *userdata->ColorInputs.blender1b_a[0]; |
358 | | ((this)->*(cycle0[((object.OtherModes.force_blend & 1) << 1) | (special_bsel0 & 1)]))(&r, &g, &b, userdata, object); |
| 261 | BLEND_CYCLE(0, 0); |
359 | 262 | WRITE_BLENDED_COLOR(); |
360 | | BLEND_CYCLE(1); |
| 263 | BLEND_CYCLE(1, 1); |
361 | 264 | WRITE_OUT(); |
362 | 265 | |
363 | 266 | return true; |
364 | 267 | } |
365 | 268 | |
366 | | bool N64BlenderT::Blend2CycleBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel0, int special_bsel1, rdp_span_aux *userdata, const rdp_poly_state& object) |
| 269 | bool N64BlenderT::Blend2CycleBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object) |
367 | 270 | { |
368 | 271 | INT32 r, g, b; |
369 | 272 | |
370 | | DitherA(&userdata->ShadeColor.i.a, adseed); |
| 273 | DITHER_A(userdata->ShadeColor.i.a, adseed); |
371 | 274 | |
372 | 275 | TEST_REJECT(); |
373 | | userdata->InvPixelColor.i.a = 0xff - *userdata->ColorInputs.blender1b_a[0]; |
374 | | ((this)->*(cycle0[((object.OtherModes.force_blend & 1) << 1) | (special_bsel0 & 1)]))(&r, &g, &b, userdata, object); |
| 276 | BLEND_CYCLE(0, 0); |
375 | 277 | WRITE_BLENDED_COLOR(); |
376 | | BLEND_CYCLE(1); |
377 | | DitherRGB(&r, &g, &b, dith); |
| 278 | BLEND_CYCLE(1, 1); |
| 279 | DITHER_RGB(dith); |
378 | 280 | WRITE_OUT(); |
379 | 281 | |
380 | 282 | return true; |
381 | 283 | } |
382 | 284 | |
| 285 | #define BLEND_PIPE(cycle, special, sum, shift) \ |
| 286 | BLEND_FACTORS(cycle, special, sum); \ |
| 287 | BLEND_MUL(cycle); \ |
| 288 | BLEND_ADD(cycle, special); \ |
| 289 | BLEND_SHIFT(shift); \ |
| 290 | BLEND_SCALE_CLAMP(sum); |
| 291 | |
383 | 292 | void N64BlenderT::BlendEquationCycle0NoForceNoSpecial(int* r, int* g, int* b, rdp_span_aux *userdata, const rdp_poly_state& object) |
384 | 293 | { |
385 | | BLEND_FACTORS_SUM(0); |
386 | | BLEND_MUL(0); |
387 | | BLEND_ADD(0); |
388 | | BLEND_SHIFT(2); |
389 | | BLEND_SCALE(); |
390 | | BLEND_CLAMP(); |
| 294 | BLEND_PIPE(0, 0, 1, 2); |
391 | 295 | } |
392 | 296 | |
393 | 297 | void N64BlenderT::BlendEquationCycle0NoForceSpecial(int* r, int* g, int* b, rdp_span_aux *userdata, const rdp_poly_state& object) |
394 | 298 | { |
395 | | BLEND_FACTORS_SPECIAL_SUM(0); |
396 | | BLEND_MUL(0); |
397 | | BLEND_ADD_SPECIAL(0); |
398 | | BLEND_SHIFT(2); |
399 | | BLEND_SCALE(); |
400 | | BLEND_CLAMP(); |
| 299 | BLEND_PIPE(0, 1, 1, 2); |
401 | 300 | } |
402 | 301 | |
403 | 302 | void N64BlenderT::BlendEquationCycle0ForceNoSpecial(int* r, int* g, int* b, rdp_span_aux *userdata, const rdp_poly_state& object) |
404 | 303 | { |
405 | | BLEND_FACTORS(0); |
406 | | BLEND_MUL(0); |
407 | | BLEND_ADD(0); |
408 | | BLEND_SHIFT(5); |
409 | | BLEND_CLAMP(); |
| 304 | BLEND_PIPE(0, 0, 0, 5); |
410 | 305 | } |
411 | 306 | |
412 | 307 | void N64BlenderT::BlendEquationCycle0ForceSpecial(int* r, int* g, int* b, rdp_span_aux *userdata, const rdp_poly_state& object) |
413 | 308 | { |
414 | | BLEND_FACTORS_SPECIAL(0); |
415 | | BLEND_MUL(0); |
416 | | BLEND_ADD_SPECIAL(0); |
417 | | BLEND_SHIFT(5); |
418 | | BLEND_CLAMP(); |
| 309 | BLEND_PIPE(0, 1, 0, 5); |
419 | 310 | } |
420 | 311 | |
421 | 312 | void N64BlenderT::BlendEquationCycle1NoForceNoSpecial(INT32* r, INT32* g, INT32* b, rdp_span_aux *userdata, const rdp_poly_state& object) |
422 | 313 | { |
423 | | BLEND_FACTORS_SUM(1); |
424 | | BLEND_MUL(1); |
425 | | BLEND_ADD(1); |
426 | | BLEND_SHIFT(2); |
427 | | BLEND_SCALE(); |
428 | | BLEND_CLAMP(); |
| 314 | BLEND_PIPE(1, 0, 1, 2); |
429 | 315 | } |
430 | 316 | |
431 | 317 | void N64BlenderT::BlendEquationCycle1NoForceSpecial(INT32* r, INT32* g, INT32* b, rdp_span_aux *userdata, const rdp_poly_state& object) |
432 | 318 | { |
433 | | BLEND_FACTORS_SPECIAL_SUM(1); |
434 | | BLEND_MUL(1); |
435 | | BLEND_ADD_SPECIAL(1); |
436 | | BLEND_SHIFT(2); |
437 | | BLEND_SCALE(); |
438 | | BLEND_CLAMP(); |
| 319 | BLEND_PIPE(1, 1, 1, 2); |
439 | 320 | } |
440 | 321 | |
441 | 322 | void N64BlenderT::BlendEquationCycle1ForceNoSpecial(INT32* r, INT32* g, INT32* b, rdp_span_aux *userdata, const rdp_poly_state& object) |
442 | 323 | { |
443 | | BLEND_FACTORS(1); |
444 | | BLEND_MUL(1); |
445 | | BLEND_ADD(1); |
446 | | BLEND_SHIFT(5); |
447 | | BLEND_CLAMP(); |
| 324 | BLEND_PIPE(1, 0, 0, 5); |
448 | 325 | } |
449 | 326 | |
450 | 327 | void N64BlenderT::BlendEquationCycle1ForceSpecial(INT32* r, INT32* g, INT32* b, rdp_span_aux *userdata, const rdp_poly_state& object) |
451 | 328 | { |
452 | | BLEND_FACTORS_SPECIAL(1); |
453 | | BLEND_MUL(1); |
454 | | BLEND_ADD_SPECIAL(1); |
455 | | BLEND_SHIFT(5); |
456 | | BLEND_CLAMP(); |
| 329 | BLEND_PIPE(1, 1, 0, 5); |
457 | 330 | } |
458 | 331 | |
459 | | bool N64BlenderT::AlphaCompare(UINT8 alpha, const rdp_span_aux *userdata, const rdp_poly_state& object) |
| 332 | bool N64BlenderT::AlphaCompareNone(UINT8 alpha, const rdp_span_aux *userdata, const rdp_poly_state& object) |
460 | 333 | { |
461 | | INT32 threshold; |
462 | | if (object.OtherModes.alpha_compare_en) |
463 | | { |
464 | | threshold = (object.OtherModes.dither_alpha_en) ? m_rdp->GetRandom() : userdata->BlendColor.i.a; |
465 | | if (alpha < threshold) |
466 | | { |
467 | | return false; |
468 | | } |
469 | | return true; |
470 | | } |
471 | | return true; |
| 334 | return false; |
472 | 335 | } |
473 | 336 | |
474 | | void N64BlenderT::DitherA(UINT8 *a, int dith) |
| 337 | bool N64BlenderT::AlphaCompareNoDither(UINT8 alpha, const rdp_span_aux *userdata, const rdp_poly_state& object) |
475 | 338 | { |
476 | | INT32 new_a = *a + dith; |
477 | | if(new_a & 0x100) |
478 | | { |
479 | | new_a = 0xff; |
480 | | } |
481 | | *a = (UINT8)new_a; |
| 339 | return alpha < userdata->BlendColor.i.a; |
482 | 340 | } |
483 | 341 | |
484 | | void N64BlenderT::DitherRGB(INT32 *r, INT32 *g, INT32 *b, int dith) |
| 342 | bool N64BlenderT::AlphaCompareDither(UINT8 alpha, const rdp_span_aux *userdata, const rdp_poly_state& object) |
485 | 343 | { |
486 | | if ((*r & 7) > dith) |
487 | | { |
488 | | *r = (*r & 0xf8) + 8; |
489 | | if (*r > 247) |
490 | | { |
491 | | *r = 255; |
492 | | } |
493 | | } |
494 | | if ((*g & 7) > dith) |
495 | | { |
496 | | *g = (*g & 0xf8) + 8; |
497 | | if (*g > 247) |
498 | | { |
499 | | *g = 255; |
500 | | } |
501 | | } |
502 | | if ((*b & 7) > dith) |
503 | | { |
504 | | *b = (*b & 0xf8) + 8; |
505 | | if (*b > 247) |
506 | | { |
507 | | *b = 255; |
508 | | } |
509 | | } |
| 344 | return alpha < (rand() & 0xff); |
510 | 345 | } |
trunk/src/mame/video/rdpblend.h
r25462 | r25463 | |
| 1 | /****************************************************************************** |
| 2 | |
| 3 | |
| 4 | SGI/Nintendo Reality Display Processor Blend Unit (BL) |
| 5 | ------------------- |
| 6 | |
| 7 | by MooglyGuy |
| 8 | based on initial C code by Ville Linde |
| 9 | contains additional improvements from angrylion, Ziggy, Gonetz and Orkin |
| 10 | |
| 11 | |
| 12 | ******************************************************************************/ |
| 13 | |
1 | 14 | #ifndef _VIDEO_RDPBLEND_H_ |
2 | 15 | #define _VIDEO_RDPBLEND_H_ |
3 | 16 | |
r25462 | r25463 | |
13 | 26 | class N64BlenderT |
14 | 27 | { |
15 | 28 | public: |
16 | | typedef bool (N64BlenderT::*Blender1)(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel, rdp_span_aux *userdata, const rdp_poly_state& object); |
17 | | typedef bool (N64BlenderT::*Blender2)(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 29 | typedef bool (N64BlenderT::*Blender1)(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 30 | typedef bool (N64BlenderT::*Blender2)(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
18 | 31 | typedef void (N64BlenderT::*BlendEquation)(INT32* r, INT32* g, INT32* b, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 32 | typedef bool (N64BlenderT::*AlphaCompare)(UINT8 alpha, const rdp_span_aux *userdata, const rdp_poly_state& object); |
| 33 | |
19 | 34 | N64BlenderT(); |
20 | 35 | |
21 | 36 | Blender1 blend1[8]; |
r25462 | r25463 | |
30 | 45 | running_machine* m_machine; |
31 | 46 | n64_rdp* m_rdp; |
32 | 47 | |
33 | | bool Blend1CycleNoBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel, rdp_span_aux *userdata, const rdp_poly_state& object); |
34 | | bool Blend1CycleNoBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel, rdp_span_aux *userdata, const rdp_poly_state& object); |
35 | | bool Blend1CycleNoBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel, rdp_span_aux *userdata, const rdp_poly_state& object); |
36 | | bool Blend1CycleNoBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel, rdp_span_aux *userdata, const rdp_poly_state& object); |
37 | | bool Blend1CycleBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel, rdp_span_aux *userdata, const rdp_poly_state& object); |
38 | | bool Blend1CycleBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel, rdp_span_aux *userdata, const rdp_poly_state& object); |
39 | | bool Blend1CycleBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel, rdp_span_aux *userdata, const rdp_poly_state& object); |
40 | | bool Blend1CycleBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int special_bsel, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 48 | bool Blend1CycleNoBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 49 | bool Blend1CycleNoBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 50 | bool Blend1CycleNoBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 51 | bool Blend1CycleNoBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 52 | bool Blend1CycleBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 53 | bool Blend1CycleBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 54 | bool Blend1CycleBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 55 | bool Blend1CycleBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
41 | 56 | |
42 | | bool Blend2CycleNoBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1, rdp_span_aux *userdata, const rdp_poly_state& object); |
43 | | bool Blend2CycleNoBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1, rdp_span_aux *userdata, const rdp_poly_state& object); |
44 | | bool Blend2CycleNoBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1, rdp_span_aux *userdata, const rdp_poly_state& object); |
45 | | bool Blend2CycleNoBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1, rdp_span_aux *userdata, const rdp_poly_state& object); |
46 | | bool Blend2CycleBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1, rdp_span_aux *userdata, const rdp_poly_state& object); |
47 | | bool Blend2CycleBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1, rdp_span_aux *userdata, const rdp_poly_state& object); |
48 | | bool Blend2CycleBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1, rdp_span_aux *userdata, const rdp_poly_state& object); |
49 | | bool Blend2CycleBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int bsel0, int bsel1, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 57 | bool Blend2CycleNoBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 58 | bool Blend2CycleNoBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 59 | bool Blend2CycleNoBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 60 | bool Blend2CycleNoBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 61 | bool Blend2CycleBlendNoACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 62 | bool Blend2CycleBlendNoACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 63 | bool Blend2CycleBlendACVGNoDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
| 64 | bool Blend2CycleBlendACVGDither(UINT32* fr, UINT32* fg, UINT32* fb, int dith, int adseed, int partialreject, int sel0, int sel1, int acmode, rdp_span_aux *userdata, const rdp_poly_state& object); |
50 | 65 | |
51 | 66 | void BlendEquationCycle0NoForceNoSpecial(INT32* r, INT32* g, INT32* b, rdp_span_aux *userdata, const rdp_poly_state& object); |
52 | 67 | void BlendEquationCycle0NoForceSpecial(INT32* r, INT32* g, INT32* b, rdp_span_aux *userdata, const rdp_poly_state& object); |
r25462 | r25463 | |
60 | 75 | |
61 | 76 | BlendEquation cycle0[4]; |
62 | 77 | BlendEquation cycle1[4]; |
| 78 | AlphaCompare compare[4]; |
63 | 79 | |
64 | | bool AlphaCompare(UINT8 alpha, const rdp_span_aux *userdata, const rdp_poly_state& object); |
| 80 | bool AlphaCompareNone(UINT8 alpha, const rdp_span_aux *userdata, const rdp_poly_state& object); |
| 81 | bool AlphaCompareNoDither(UINT8 alpha, const rdp_span_aux *userdata, const rdp_poly_state& object); |
| 82 | bool AlphaCompareDither(UINT8 alpha, const rdp_span_aux *userdata, const rdp_poly_state& object); |
65 | 83 | |
66 | 84 | void DitherRGB(INT32* r, INT32* g, INT32* b, int dith); |
67 | 85 | void DitherA(UINT8* a, int dith); |
trunk/src/mame/video/rdpspn16.c
r25462 | r25463 | |
| 1 | /****************************************************************************** |
| 2 | |
| 3 | |
| 4 | SGI/Nintendo Reality Display Processor span-drawing functions |
| 5 | ------------------- |
| 6 | |
| 7 | by MooglyGuy |
| 8 | based on initial C code by Ville Linde |
| 9 | contains additional improvements from angrylion, Ziggy, Gonetz and Orkin |
| 10 | |
| 11 | |
| 12 | ******************************************************************************/ |
| 13 | |
1 | 14 | #include "emu.h" |
2 | 15 | #include "includes/n64.h" |
3 | 16 | #include "video/n64.h" |
r25462 | r25463 | |
135 | 148 | SpanParam w; w.w = extent.param[SPAN_W].start; |
136 | 149 | |
137 | 150 | UINT32 zb = object.MiscState.ZBAddress >> 1; |
138 | | UINT32 zhb = zb; |
| 151 | UINT32 zhb = object.MiscState.ZBAddress; |
139 | 152 | UINT8 offx = 0, offy = 0; |
140 | 153 | |
141 | 154 | INT32 tile1 = tilenum; |
r25462 | r25463 | |
147 | 160 | m_rdp->TexPipe.CalculateClampDiffs(tile1, userdata, object, m_clamp_s_diff, m_clamp_t_diff); |
148 | 161 | |
149 | 162 | bool partialreject = (userdata->ColorInputs.blender2b_a[0] == &userdata->InvPixelColor.i.a && userdata->ColorInputs.blender1b_a[0] == &userdata->PixelColor.i.a); |
150 | | bool bsel0 = (userdata->ColorInputs.blender2b_a[0] == &userdata->MemoryColor.i.a); |
| 163 | int sel0 = (OtherModes.force_blend ? 2 : 0) | ((userdata->ColorInputs.blender2b_a[0] == &userdata->MemoryColor.i.a) ? 1 : 0); |
151 | 164 | |
152 | 165 | int drinc = object.SpanBase.m_span_dr; |
153 | 166 | int dginc = object.SpanBase.m_span_dg; |
r25462 | r25463 | |
196 | 209 | int blend_index = (object.OtherModes.alpha_cvg_select ? 2 : 0) | ((object.OtherModes.rgb_dither_sel < 3) ? 1 : 0); |
197 | 210 | int read_index = ((object.MiscState.FBSize - 2) << 1) | object.OtherModes.image_read_en; |
198 | 211 | int write_index = ((object.MiscState.FBSize - 2) << 3) | (object.OtherModes.cvg_dest << 1); |
| 212 | int acmode = (object.OtherModes.alpha_compare_en ? 2 : 0) | (object.OtherModes.dither_alpha_en ? 1 : 0); |
| 213 | |
199 | 214 | userdata->m_start_span = true; |
200 | 215 | for (int j = 0; j <= length; j++) |
201 | 216 | { |
r25462 | r25463 | |
255 | 270 | { |
256 | 271 | m_rdp->GetDitherValues(scanline, j, &cdith, &adith, object); |
257 | 272 | |
258 | | bool rendered = ((&m_rdp->Blender)->*(m_rdp->Blender.blend1[(userdata->BlendEnable << 2) | blend_index]))(&fir, &fig, &fib, cdith, adith, partialreject, bsel0, userdata, object); |
| 273 | bool rendered = ((&m_rdp->Blender)->*(m_rdp->Blender.blend1[(userdata->BlendEnable << 2) | blend_index]))(&fir, &fig, &fib, cdith, adith, partialreject, sel0, acmode, userdata, object); |
259 | 274 | |
260 | 275 | if (rendered) |
261 | 276 | { |
r25462 | r25463 | |
263 | 278 | |
264 | 279 | if (object.OtherModes.z_update_en) |
265 | 280 | { |
266 | | m_rdp->ZStore(zbcur, zhbcur, sz, userdata->m_dzpix_enc); |
| 281 | m_rdp->ZStore(object, zbcur, zhbcur, sz, userdata->m_dzpix_enc); |
267 | 282 | } |
268 | 283 | } |
269 | 284 | } |
r25462 | r25463 | |
300 | 315 | SpanParam w; w.w = extent.param[SPAN_W].start; |
301 | 316 | |
302 | 317 | UINT32 zb = object.MiscState.ZBAddress >> 1; |
303 | | UINT32 zhb = zb; |
| 318 | UINT32 zhb = object.MiscState.ZBAddress; |
304 | 319 | UINT8 offx = 0, offy = 0; |
305 | 320 | |
306 | 321 | INT32 tile2 = (tilenum + 1) & 7; |
r25462 | r25463 | |
318 | 333 | m_rdp->TexPipe.CalculateClampDiffs(tile1, userdata, object, m_clamp_s_diff, m_clamp_t_diff); |
319 | 334 | |
320 | 335 | bool partialreject = (userdata->ColorInputs.blender2b_a[1] == &userdata->InvPixelColor.i.a && userdata->ColorInputs.blender1b_a[1] == &userdata->PixelColor.i.a); |
321 | | bool bsel0 = (userdata->ColorInputs.blender2b_a[0] == &userdata->MemoryColor.i.a); |
322 | | bool bsel1 = (userdata->ColorInputs.blender2b_a[1] == &userdata->MemoryColor.i.a); |
| 336 | int sel0 = (OtherModes.force_blend ? 2 : 0) | ((userdata->ColorInputs.blender2b_a[0] == &userdata->MemoryColor.i.a) ? 1 : 0); |
| 337 | int sel1 = (OtherModes.force_blend ? 2 : 0) | ((userdata->ColorInputs.blender2b_a[1] == &userdata->MemoryColor.i.a) ? 1 : 0); |
323 | 338 | |
324 | 339 | int dzpix = object.SpanBase.m_span_dzpix; |
325 | 340 | int drinc = flip ? (object.SpanBase.m_span_dr) : -object.SpanBase.m_span_dr; |
r25462 | r25463 | |
356 | 371 | int blend_index = (object.OtherModes.alpha_cvg_select ? 2 : 0) | ((object.OtherModes.rgb_dither_sel < 3) ? 1 : 0); |
357 | 372 | int read_index = ((object.MiscState.FBSize - 2) << 1) | object.OtherModes.image_read_en; |
358 | 373 | int write_index = ((object.MiscState.FBSize - 2) << 3) | (object.OtherModes.cvg_dest << 1); |
| 374 | int acmode = (object.OtherModes.alpha_compare_en ? 2 : 0) | (object.OtherModes.dither_alpha_en ? 1 : 0); |
| 375 | |
359 | 376 | userdata->m_start_span = true; |
360 | 377 | for (int j = 0; j <= length; j++) |
361 | 378 | { |
r25462 | r25463 | |
424 | 441 | { |
425 | 442 | m_rdp->GetDitherValues(scanline, j, &cdith, &adith, object); |
426 | 443 | |
427 | | bool rendered = ((&m_rdp->Blender)->*(m_rdp->Blender.blend2[(userdata->BlendEnable << 2) | blend_index]))(&fir, &fig, &fib, cdith, adith, partialreject, bsel0, bsel1, userdata, object); |
| 444 | bool rendered = ((&m_rdp->Blender)->*(m_rdp->Blender.blend2[(userdata->BlendEnable << 2) | blend_index]))(&fir, &fig, &fib, cdith, adith, partialreject, sel0, sel1, acmode, userdata, object); |
428 | 445 | |
429 | 446 | if (rendered) |
430 | 447 | { |
431 | 448 | ((this)->*(_Write[write_index | userdata->BlendEnable]))(curpixel, fir, fig, fib, userdata, object); |
432 | 449 | if (object.OtherModes.z_update_en) |
433 | 450 | { |
434 | | m_rdp->ZStore(zbcur, zhbcur, sz, userdata->m_dzpix_enc); |
| 451 | m_rdp->ZStore(object, zbcur, zhbcur, sz, userdata->m_dzpix_enc); |
435 | 452 | } |
436 | 453 | } |
437 | 454 | } |