mirror of
https://github.com/holub/mame
synced 2025-05-22 21:58:57 +03:00
Optimized N64 RDP renderer by using function pointers to function variants that eliminate costly branches. [Harmony]
This commit is contained in:
parent
c58957452c
commit
d47b36dae1
14
.gitattributes
vendored
14
.gitattributes
vendored
@ -3544,6 +3544,20 @@ src/mame/video/raiden.c svneol=native#text/plain
|
||||
src/mame/video/rallyx.c svneol=native#text/plain
|
||||
src/mame/video/rampart.c svneol=native#text/plain
|
||||
src/mame/video/rastan.c svneol=native#text/plain
|
||||
src/mame/video/rdpacomp.c svneol=native#text/plain
|
||||
src/mame/video/rdpacomp.h svneol=native#text/plain
|
||||
src/mame/video/rdpacvg.c svneol=native#text/plain
|
||||
src/mame/video/rdpacvg.h svneol=native#text/plain
|
||||
src/mame/video/rdpfb.c svneol=native#text/plain
|
||||
src/mame/video/rdpfb.h svneol=native#text/plain
|
||||
src/mame/video/rdpfetch.c svneol=native#text/plain
|
||||
src/mame/video/rdpfetch.h svneol=native#text/plain
|
||||
src/mame/video/rdpspn16.c svneol=native#text/plain
|
||||
src/mame/video/rdpspn16.h svneol=native#text/plain
|
||||
src/mame/video/rdptpipe.c svneol=native#text/plain
|
||||
src/mame/video/rdptpipe.h svneol=native#text/plain
|
||||
src/mame/video/rdptrect.c svneol=native#text/plain
|
||||
src/mame/video/rdptrect.h svneol=native#text/plain
|
||||
src/mame/video/realbrk.c svneol=native#text/plain
|
||||
src/mame/video/redalert.c svneol=native#text/plain
|
||||
src/mame/video/redclash.c svneol=native#text/plain
|
||||
|
2729
src/mame/video/n64.c
2729
src/mame/video/n64.c
File diff suppressed because it is too large
Load Diff
28
src/mame/video/rdpacomp.c
Normal file
28
src/mame/video/rdpacomp.c
Normal file
@ -0,0 +1,28 @@
|
||||
INLINE int alpha_compare_nac_nda(running_machine *machine, UINT8 comb_alpha)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE int alpha_compare_nac_da(running_machine *machine, UINT8 comb_alpha)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE int alpha_compare_ac_nda(running_machine *machine, UINT8 comb_alpha)
|
||||
{
|
||||
if (comb_alpha < blend_color.i.a)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE int alpha_compare_ac_da(running_machine *machine, UINT8 comb_alpha)
|
||||
{
|
||||
if (comb_alpha < (mame_rand(machine) & 0xff))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
9
src/mame/video/rdpacomp.h
Normal file
9
src/mame/video/rdpacomp.h
Normal file
@ -0,0 +1,9 @@
|
||||
INLINE int alpha_compare_nac_nda(running_machine *machine, UINT8 comb_alpha);
|
||||
INLINE int alpha_compare_nac_da(running_machine *machine, UINT8 comb_alpha);
|
||||
INLINE int alpha_compare_ac_nda(running_machine *machine, UINT8 comb_alpha);
|
||||
INLINE int alpha_compare_ac_da(running_machine *machine, UINT8 comb_alpha);
|
||||
|
||||
static int (*rdp_alpha_compare_func[4])(running_machine *, UINT8) =
|
||||
{
|
||||
alpha_compare_nac_nda, alpha_compare_nac_da, alpha_compare_ac_nda, alpha_compare_ac_da
|
||||
};
|
62
src/mame/video/rdpacvg.c
Normal file
62
src/mame/video/rdpacvg.c
Normal file
@ -0,0 +1,62 @@
|
||||
INLINE UINT8 alpha_cvg_get_cta_ca(UINT8 comb_alpha)
|
||||
{
|
||||
UINT32 temp = comb_alpha;
|
||||
UINT32 temp2 = curpixel_cvg;
|
||||
UINT32 temp3 = 0;
|
||||
|
||||
temp3 = (temp * temp2) + 4;
|
||||
curpixel_cvg = temp3 >> 8;
|
||||
|
||||
temp = (temp3 >> 3);
|
||||
|
||||
if (temp > 0xff)
|
||||
{
|
||||
temp = 0xff;
|
||||
}
|
||||
|
||||
return (UINT8)temp;
|
||||
}
|
||||
|
||||
INLINE UINT8 alpha_cvg_get_ncta_ca(UINT8 comb_alpha)
|
||||
{
|
||||
UINT32 temp = comb_alpha;
|
||||
UINT32 temp2 = curpixel_cvg;
|
||||
|
||||
temp = temp2 << 5;
|
||||
|
||||
if (temp > 0xff)
|
||||
{
|
||||
temp = 0xff;
|
||||
}
|
||||
|
||||
return (UINT8)temp;
|
||||
}
|
||||
|
||||
INLINE UINT8 alpha_cvg_get_cta_nca(UINT8 comb_alpha)
|
||||
{
|
||||
UINT32 temp = comb_alpha;
|
||||
UINT32 temp2 = curpixel_cvg;
|
||||
UINT32 temp3 = 0;
|
||||
|
||||
temp3 = (temp * temp2) + 4;
|
||||
curpixel_cvg = temp3 >> 8;
|
||||
|
||||
if (temp > 0xff)
|
||||
{
|
||||
temp = 0xff;
|
||||
}
|
||||
|
||||
return (UINT8)temp;
|
||||
}
|
||||
|
||||
INLINE UINT8 alpha_cvg_get_ncta_nca(UINT8 comb_alpha)
|
||||
{
|
||||
UINT32 temp = comb_alpha;
|
||||
|
||||
if (temp > 0xff)
|
||||
{
|
||||
temp = 0xff;
|
||||
}
|
||||
|
||||
return (UINT8)temp;
|
||||
}
|
9
src/mame/video/rdpacvg.h
Normal file
9
src/mame/video/rdpacvg.h
Normal file
@ -0,0 +1,9 @@
|
||||
INLINE UINT8 alpha_cvg_get_cta_ca(UINT8 comb_alpha);
|
||||
INLINE UINT8 alpha_cvg_get_ncta_ca(UINT8 comb_alpha);
|
||||
INLINE UINT8 alpha_cvg_get_cta_nca(UINT8 comb_alpha);
|
||||
INLINE UINT8 alpha_cvg_get_ncta_nca(UINT8 comb_alpha);
|
||||
|
||||
static UINT8 (*rdp_alpha_cvg_func[4])(UINT8) =
|
||||
{
|
||||
alpha_cvg_get_ncta_nca, alpha_cvg_get_ncta_ca, alpha_cvg_get_cta_nca, alpha_cvg_get_cta_ca,
|
||||
};
|
743
src/mame/video/rdpfb.c
Normal file
743
src/mame/video/rdpfb.c
Normal file
@ -0,0 +1,743 @@
|
||||
INLINE UINT32 FBWRITE_16_RDEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
#undef CVG_DRAW
|
||||
UINT16 finalcolor;
|
||||
UINT32 memory_cvg = ((*fb & 1) << 2) + (*hb & 3) + 1;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
#ifdef CVG_DRAW
|
||||
int covdraw;
|
||||
if (curpixel_cvg == 8)
|
||||
{
|
||||
covdraw=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
covdraw = curpixel_cvg << 5;
|
||||
}
|
||||
r=covdraw; g=covdraw; b=covdraw;
|
||||
#endif
|
||||
|
||||
if (!other_modes.z_compare_en)
|
||||
{
|
||||
curpixel_overlap = 0;
|
||||
}
|
||||
|
||||
if (curpixel_cvg > 8)
|
||||
{
|
||||
fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
|
||||
}
|
||||
|
||||
newcvg = curpixel_cvg + memory_cvg;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
|
||||
finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
|
||||
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
if (!curpixel_cvg)
|
||||
{
|
||||
fatalerror("cvg underflow");
|
||||
}
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
memory_cvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xfffe;
|
||||
*fb |= ((newcvg >> 2) & 1);
|
||||
*hb = (newcvg & 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!other_modes.force_blend && !curpixel_overlap)
|
||||
{
|
||||
*fb = finalcolor|((curpixel_cvg >>2)&1);
|
||||
*hb = (curpixel_cvg & 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
*fb = finalcolor|((clampcvg>>2)&1);
|
||||
*hb = (clampcvg&3);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_16_RDEN_CVGD1(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
#undef CVG_DRAW
|
||||
UINT16 finalcolor;
|
||||
UINT32 memory_cvg = ((*fb & 1) << 2) + (*hb & 3) + 1;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
#ifdef CVG_DRAW
|
||||
int covdraw;
|
||||
if (curpixel_cvg == 8)
|
||||
{
|
||||
covdraw=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
covdraw = curpixel_cvg << 5;
|
||||
}
|
||||
r=covdraw; g=covdraw; b=covdraw;
|
||||
#endif
|
||||
|
||||
if (!other_modes.z_compare_en)
|
||||
{
|
||||
curpixel_overlap = 0;
|
||||
}
|
||||
|
||||
if (curpixel_cvg > 8)
|
||||
{
|
||||
fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
|
||||
}
|
||||
|
||||
newcvg = curpixel_cvg + memory_cvg;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
|
||||
finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
|
||||
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
if (!curpixel_cvg)
|
||||
{
|
||||
fatalerror("cvg underflow");
|
||||
}
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
memory_cvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xfffe;
|
||||
*fb |= ((newcvg >> 2) & 1);
|
||||
*hb = (newcvg & 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor|((newcvg >> 2) & 1);
|
||||
*hb = (newcvg & 3);
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_16_RDEN_CVGD2(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
#undef CVG_DRAW
|
||||
UINT16 finalcolor;
|
||||
UINT32 memory_cvg = ((*fb & 1) << 2) + (*hb & 3) + 1;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
#ifdef CVG_DRAW
|
||||
int covdraw;
|
||||
if (curpixel_cvg == 8)
|
||||
{
|
||||
covdraw=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
covdraw = curpixel_cvg << 5;
|
||||
}
|
||||
r=covdraw; g=covdraw; b=covdraw;
|
||||
#endif
|
||||
|
||||
if (!other_modes.z_compare_en)
|
||||
{
|
||||
curpixel_overlap = 0;
|
||||
}
|
||||
|
||||
if (curpixel_cvg > 8)
|
||||
{
|
||||
fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
|
||||
}
|
||||
|
||||
newcvg = curpixel_cvg + memory_cvg;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
|
||||
finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
|
||||
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
if (!curpixel_cvg)
|
||||
{
|
||||
fatalerror("cvg underflow");
|
||||
}
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
memory_cvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xfffe;
|
||||
*fb |= ((newcvg >> 2) & 1);
|
||||
*hb = (newcvg & 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor|1;
|
||||
*hb = 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_16_RDEN_CVGD3(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
#undef CVG_DRAW
|
||||
UINT16 finalcolor;
|
||||
UINT32 memory_cvg = ((*fb & 1) << 2) + (*hb & 3) + 1;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
#ifdef CVG_DRAW
|
||||
int covdraw;
|
||||
if (curpixel_cvg == 8)
|
||||
{
|
||||
covdraw=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
covdraw = curpixel_cvg << 5;
|
||||
}
|
||||
r=covdraw; g=covdraw; b=covdraw;
|
||||
#endif
|
||||
|
||||
if (!other_modes.z_compare_en)
|
||||
{
|
||||
curpixel_overlap = 0;
|
||||
}
|
||||
|
||||
if (curpixel_cvg > 8)
|
||||
{
|
||||
fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
|
||||
}
|
||||
|
||||
newcvg = curpixel_cvg + memory_cvg;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
|
||||
finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
|
||||
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
if (!curpixel_cvg)
|
||||
{
|
||||
fatalerror("cvg underflow");
|
||||
}
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
memory_cvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xfffe;
|
||||
*fb |= ((newcvg >> 2) & 1);
|
||||
*hb = (newcvg & 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor|((memory_cvg >> 2) & 1);
|
||||
*hb = (memory_cvg & 3);
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_16_RDNEN_CVGD0(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
#undef CVG_DRAW
|
||||
UINT16 finalcolor;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
#ifdef CVG_DRAW
|
||||
int covdraw;
|
||||
if (curpixel_cvg == 8)
|
||||
{
|
||||
covdraw=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
covdraw = curpixel_cvg << 5;
|
||||
}
|
||||
r=covdraw; g=covdraw; b=covdraw;
|
||||
#endif
|
||||
|
||||
if (!other_modes.z_compare_en)
|
||||
{
|
||||
curpixel_overlap = 0;
|
||||
}
|
||||
|
||||
if (curpixel_cvg > 8)
|
||||
{
|
||||
fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
|
||||
}
|
||||
|
||||
newcvg = curpixel_cvg + 8;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
|
||||
finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
|
||||
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
if (!curpixel_cvg)
|
||||
{
|
||||
fatalerror("cvg underflow");
|
||||
}
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xfffe;
|
||||
*fb |= ((newcvg >> 2) & 1);
|
||||
*hb = (newcvg & 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!other_modes.force_blend && !curpixel_overlap)
|
||||
{
|
||||
*fb = finalcolor|((curpixel_cvg >>2)&1);
|
||||
*hb = (curpixel_cvg & 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
*fb = finalcolor|((clampcvg>>2)&1);
|
||||
*hb = (clampcvg&3);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_16_RDNEN_CVGD1(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
#undef CVG_DRAW
|
||||
UINT16 finalcolor;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
#ifdef CVG_DRAW
|
||||
int covdraw;
|
||||
if (curpixel_cvg == 8)
|
||||
{
|
||||
covdraw=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
covdraw = curpixel_cvg << 5;
|
||||
}
|
||||
r=covdraw; g=covdraw; b=covdraw;
|
||||
#endif
|
||||
|
||||
if (!other_modes.z_compare_en)
|
||||
{
|
||||
curpixel_overlap = 0;
|
||||
}
|
||||
|
||||
if (curpixel_cvg > 8)
|
||||
{
|
||||
fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
|
||||
}
|
||||
|
||||
newcvg = curpixel_cvg + 8;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
|
||||
finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
|
||||
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
if (!curpixel_cvg)
|
||||
{
|
||||
fatalerror("cvg underflow");
|
||||
}
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xfffe;
|
||||
*fb |= ((newcvg >> 2) & 1);
|
||||
*hb = (newcvg & 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor|1;
|
||||
*hb = 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_16_RDNEN_CVGD2(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
#undef CVG_DRAW
|
||||
UINT16 finalcolor;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
#ifdef CVG_DRAW
|
||||
int covdraw;
|
||||
if (curpixel_cvg == 8)
|
||||
{
|
||||
covdraw=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
covdraw = curpixel_cvg << 5;
|
||||
}
|
||||
r=covdraw; g=covdraw; b=covdraw;
|
||||
#endif
|
||||
|
||||
if (!other_modes.z_compare_en)
|
||||
{
|
||||
curpixel_overlap = 0;
|
||||
}
|
||||
|
||||
if (curpixel_cvg > 8)
|
||||
{
|
||||
fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
|
||||
}
|
||||
|
||||
newcvg = curpixel_cvg + 8;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
|
||||
finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
|
||||
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
if (!curpixel_cvg)
|
||||
{
|
||||
fatalerror("cvg underflow");
|
||||
}
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xfffe;
|
||||
*fb |= ((newcvg >> 2) & 1);
|
||||
*hb = (newcvg & 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor|1;
|
||||
*hb = 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_16_RDNEN_CVGD3(UINT16 *fb, UINT8* hb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
#undef CVG_DRAW
|
||||
UINT16 finalcolor;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
#ifdef CVG_DRAW
|
||||
int covdraw;
|
||||
if (curpixel_cvg == 8)
|
||||
{
|
||||
covdraw=255;
|
||||
}
|
||||
else
|
||||
{
|
||||
covdraw = curpixel_cvg << 5;
|
||||
}
|
||||
r=covdraw; g=covdraw; b=covdraw;
|
||||
#endif
|
||||
|
||||
if (!other_modes.z_compare_en)
|
||||
{
|
||||
curpixel_overlap = 0;
|
||||
}
|
||||
|
||||
if (curpixel_cvg > 8)
|
||||
{
|
||||
fatalerror("FBWRITE_16: curpixel_cvg %d", curpixel_cvg);
|
||||
}
|
||||
|
||||
newcvg = curpixel_cvg + 8;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
|
||||
finalcolor = ((r >> 3) << 11) | ((g >> 3) << 6) | ((b >> 3) << 1);
|
||||
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
if (!curpixel_cvg)
|
||||
{
|
||||
fatalerror("cvg underflow");
|
||||
}
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xfffe;
|
||||
*fb |= ((newcvg >> 2) & 1);
|
||||
*hb = (newcvg & 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor|1;
|
||||
*hb = 4;
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_32_RDEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
|
||||
UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
|
||||
newcvg = curpixel_cvg + memory_cvg;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
memory_cvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xffffff00;
|
||||
*fb |= ((newcvg << 5) & 0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!other_modes.force_blend && !curpixel_overlap)
|
||||
{
|
||||
*fb = finalcolor|(curpixel_cvg << 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
*fb = finalcolor|(clampcvg << 5);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_32_RDEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
|
||||
UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
|
||||
newcvg = curpixel_cvg + memory_cvg;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
memory_cvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xffffff00;
|
||||
*fb |= ((newcvg << 5) & 0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor | (newcvg << 5);
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_32_RDEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
|
||||
UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
|
||||
newcvg = curpixel_cvg + memory_cvg;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
memory_cvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xffffff00;
|
||||
*fb |= ((newcvg << 5) & 0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor | 0xE0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_32_RDEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
|
||||
UINT32 memory_alphachannel = *fb & 0xff;
|
||||
UINT32 memory_cvg = ((*fb >>5) & 7) + 1;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
|
||||
newcvg = curpixel_cvg + memory_cvg;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
memory_cvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xffffff00;
|
||||
*fb |= ((newcvg << 5) & 0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor | memory_alphachannel;
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_32_RDNEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
|
||||
newcvg = curpixel_cvg + 8;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xffffff00;
|
||||
*fb |= ((newcvg << 5) & 0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!other_modes.force_blend && !curpixel_overlap)
|
||||
{
|
||||
*fb = finalcolor|(curpixel_cvg << 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
*fb = finalcolor|(clampcvg << 5);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_32_RDNEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
|
||||
newcvg = curpixel_cvg + 8;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xffffff00;
|
||||
*fb |= ((newcvg << 5) & 0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor | (newcvg << 5);
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_32_RDNEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
|
||||
newcvg = curpixel_cvg + 8;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xffffff00;
|
||||
*fb |= ((newcvg << 5) & 0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor | 0xE0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
INLINE UINT32 FBWRITE_32_RDNEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b)
|
||||
{
|
||||
UINT32 finalcolor=(r << 24) | (g << 16) | (b << 8);
|
||||
UINT32 memory_alphachannel = *fb & 0xff;
|
||||
UINT32 newcvg;
|
||||
UINT32 wrapflag;
|
||||
UINT32 clampcvg;
|
||||
|
||||
newcvg = curpixel_cvg + 8;
|
||||
wrapflag = (newcvg > 8) ? 1 : 0;
|
||||
clampcvg = (newcvg > 8) ? 8 : newcvg;
|
||||
newcvg = (wrapflag)? (newcvg - 8) : newcvg;
|
||||
|
||||
curpixel_cvg--;
|
||||
newcvg--;
|
||||
clampcvg--;
|
||||
|
||||
if (other_modes.color_on_cvg && !wrapflag)
|
||||
{
|
||||
*fb &= 0xffffff00;
|
||||
*fb |= ((newcvg << 5) & 0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*fb = finalcolor | memory_alphachannel;
|
||||
return 1;
|
||||
}
|
29
src/mame/video/rdpfb.h
Normal file
29
src/mame/video/rdpfb.h
Normal file
@ -0,0 +1,29 @@
|
||||
INLINE UINT32 FBWRITE_16_RDEN_CVGD0(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_16_RDEN_CVGD1(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_16_RDEN_CVGD2(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_16_RDEN_CVGD3(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_16_RDNEN_CVGD0(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_16_RDNEN_CVGD1(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_16_RDNEN_CVGD2(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_16_RDNEN_CVGD3(UINT16 *fb, UINT8 *hb, UINT32 r, UINT32 g, UINT32 b);
|
||||
|
||||
INLINE UINT32 FBWRITE_32_RDEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_32_RDEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_32_RDEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_32_RDEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_32_RDNEN_CVGD0(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_32_RDNEN_CVGD1(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_32_RDNEN_CVGD2(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
|
||||
INLINE UINT32 FBWRITE_32_RDNEN_CVGD3(UINT32 *fb, UINT32 r, UINT32 g, UINT32 b);
|
||||
|
||||
static UINT32 (*rdp_fbwrite_16_func[8])(UINT16*, UINT8*, UINT32, UINT32, UINT32) =
|
||||
{
|
||||
FBWRITE_16_RDNEN_CVGD0, FBWRITE_16_RDNEN_CVGD1, FBWRITE_16_RDNEN_CVGD2, FBWRITE_16_RDNEN_CVGD3,
|
||||
FBWRITE_16_RDEN_CVGD0, FBWRITE_16_RDEN_CVGD1, FBWRITE_16_RDEN_CVGD2, FBWRITE_16_RDEN_CVGD3,
|
||||
};
|
||||
|
||||
static UINT32 (*rdp_fbwrite_32_func[8])(UINT32*, UINT32, UINT32, UINT32) =
|
||||
{
|
||||
FBWRITE_32_RDNEN_CVGD0, FBWRITE_32_RDNEN_CVGD1, FBWRITE_32_RDNEN_CVGD2, FBWRITE_32_RDNEN_CVGD3,
|
||||
FBWRITE_32_RDEN_CVGD0, FBWRITE_32_RDEN_CVGD1, FBWRITE_32_RDEN_CVGD2, FBWRITE_32_RDEN_CVGD3,
|
||||
};
|
484
src/mame/video/rdpfetch.c
Normal file
484
src/mame/video/rdpfetch.c
Normal file
@ -0,0 +1,484 @@
|
||||
INLINE void FETCH_TEXEL_RGBA4_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
UINT16 c = tlut[(((tpal << 4) | p) ^ WORD_ADDR_XOR) << 2];
|
||||
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA4_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
UINT16 c = tlut[(((tpal << 4) | p) ^ WORD_ADDR_XOR) << 2];
|
||||
|
||||
color->i.r = color->i.g = color->i.b = (c >> 8) & 0xff;
|
||||
color->i.a = c & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA4_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
|
||||
color->i.r = color->i.g = color->i.b = color->i.a = (tpal << 4) | p;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA8_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
UINT16 c = tlut[(p ^ WORD_ADDR_XOR) << 2];
|
||||
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA8_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
UINT16 c = tlut[(p ^ WORD_ADDR_XOR) << 2];
|
||||
|
||||
color->i.r = color->i.g = color->i.b = (c >> 8) & 0xff;
|
||||
color->i.a = c & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA8_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
|
||||
color->i.r = color->i.g = color->i.b = color->i.a = p;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA16_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase>>1) + ((t) * (twidth>>1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
|
||||
UINT16 c = TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR]; // PGA European Tour (U)
|
||||
|
||||
c = tlut[(c >> 8) << 2];
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA16_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase>>1) + ((t) * (twidth>>1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
|
||||
UINT16 c = TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR]; // PGA European Tour (U)
|
||||
|
||||
c = tlut[(c >> 8) << 2];
|
||||
color->i.r = color->i.g = color->i.b = (c >> 8) & 0xff;
|
||||
color->i.a = c & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA16_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase>>1) + ((t) * (twidth>>1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
|
||||
UINT16 c = TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR]; // PGA European Tour (U)
|
||||
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA32_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int xorval = (fb_size == PIXEL_SIZE_16BIT) ? XOR_SWAP_WORD : XOR_SWAP_DWORD; // Conker's Bad Fur Day, Jet Force Gemini, Super Smash Bros., Mickey's Speedway USA, Ogre Battle, Wave Race, Gex 3, South Park Rally
|
||||
int taddr = (((tbase >> 2) + ((t) * (twidth >> 1)) + (s)) ^ ((t & 1) ? xorval : 0)) & 0x3ff;
|
||||
UINT32 c = TMEM32[taddr];
|
||||
|
||||
c = tlut[(c >> 24) << 2];
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA32_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int xorval = (fb_size == PIXEL_SIZE_16BIT) ? XOR_SWAP_WORD : XOR_SWAP_DWORD; // Conker's Bad Fur Day, Jet Force Gemini, Super Smash Bros., Mickey's Speedway USA, Ogre Battle, Wave Race, Gex 3, South Park Rally
|
||||
int taddr = (((tbase >> 2) + ((t) * (twidth >> 1)) + (s)) ^ ((t & 1) ? xorval : 0)) & 0x3ff;
|
||||
UINT32 c = TMEM32[taddr];
|
||||
|
||||
c = tlut[(c >> 24) << 2];
|
||||
color->i.r = color->i.g = color->i.b = (c >> 8) & 0xff;
|
||||
color->i.a = c & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_RGBA32_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int xorval = (fb_size == PIXEL_SIZE_16BIT) ? XOR_SWAP_WORD : XOR_SWAP_DWORD; // Conker's Bad Fur Day, Jet Force Gemini, Super Smash Bros., Mickey's Speedway USA, Ogre Battle, Wave Race, Gex 3, South Park Rally
|
||||
int taddr = (((tbase >> 2) + ((t) * (twidth >> 1)) + (s)) ^ ((t & 1) ? xorval : 0)) & 0x3ff;
|
||||
UINT32 c = TMEM32[taddr];
|
||||
|
||||
color->c = c;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_YUV16(COLOR *color, int s, int t)
|
||||
{ // YUV: Bottom of the 9th, Pokemon Stadium, Ogre Battle 64
|
||||
INT32 newr = 0;
|
||||
INT32 newg = 0;
|
||||
INT32 newb = 0;
|
||||
int taddr = ((tbase >> 1) + ((t) * (twidth)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
|
||||
UINT16 c1, c2;
|
||||
INT32 y;
|
||||
INT32 u, v;
|
||||
c1 = TMEM16[taddr ^ WORD_ADDR_XOR];
|
||||
c2 = TMEM16[taddr]; // other word
|
||||
|
||||
if (!(taddr & 1))
|
||||
{
|
||||
v = c2 >> 8;
|
||||
u = c1 >> 8;
|
||||
y = c1 & 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
v = c1 >> 8;
|
||||
u = c2 >> 8;
|
||||
y = c1 & 0xff;
|
||||
}
|
||||
v -= 128;
|
||||
u -= 128;
|
||||
|
||||
if (!other_modes.bi_lerp0)
|
||||
{
|
||||
newr = y + ((k0 * v) >> 8);
|
||||
newg = y + ((k1 * u) >> 8) + ((k2 * v) >> 8);
|
||||
newb = y + ((k3 * u) >> 8);
|
||||
}
|
||||
color->i.r = (newr < 0) ? 0 : ((newr > 0xff) ? 0xff : newr);
|
||||
color->i.g = (newg < 0) ? 0 : ((newg > 0xff) ? 0xff : newg);
|
||||
color->i.b = (newb < 0) ? 0 : ((newb > 0xff) ? 0xff : newb);
|
||||
color->i.a = 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_CI4_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
UINT16 c = tlut[((tpal << 4) | p) << 2];
|
||||
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_CI4_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
UINT16 c = tlut[((tpal << 4) | p) << 2];
|
||||
|
||||
color->i.r = color->i.g = color->i.b = (c >> 8) & 0xff;
|
||||
color->i.a = c & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_CI4_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
|
||||
color->i.r = color->i.g = color->i.b = color->i.a = (tpal << 4) | p;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_CI8_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
UINT16 c = tlut[p << 2];
|
||||
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_CI8_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
UINT16 c = tlut[p << 2];
|
||||
|
||||
color->i.r = color->i.g = color->i.b = (c >> 8) & 0xff;
|
||||
color->i.a = c & 0xff;
|
||||
color->c = 0xffffffff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_CI8_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
|
||||
UINT8 p = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
|
||||
color->i.r = color->i.g = color->i.b = color->i.a = p;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_CI16_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{ // 16-bit CI is a "valid" mode; some games use it, it behaves the same as 16-bit RGBA
|
||||
int taddr = ((tbase>>1) + ((t) * (twidth>>1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
|
||||
UINT16 c = TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR]; // PGA European Tour (U)
|
||||
|
||||
c = tlut[(c >> 8) << 2];
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_CI16_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{ // 16-bit CI is a "valid" mode; some games use it, it behaves the same as 16-bit RGBA
|
||||
int taddr = ((tbase>>1) + ((t) * (twidth>>1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
|
||||
UINT16 c = TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR]; // PGA European Tour (U)
|
||||
|
||||
// Beetle Adventure Racing, Mount Mayhem
|
||||
c = tlut[(c >> 8) << 2];
|
||||
color->i.r = color->i.g = color->i.b = (c >> 8) & 0xff;
|
||||
color->i.a = c & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_CI16_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{ // 16-bit CI is a "valid" mode; some games use it, it behaves the same as 16-bit RGBA
|
||||
int taddr = ((tbase>>1) + ((t) * (twidth>>1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
|
||||
UINT16 c = TMEM16[(taddr & 0x7ff) ^ WORD_ADDR_XOR]; // PGA European Tour (U)
|
||||
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_IA4_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = (tbase + ((t) * twidth) + (s >> 1)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0);
|
||||
UINT8 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
UINT16 c = tlut[((tpal << 4) | p) << 2];
|
||||
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_IA4_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = (tbase + ((t) * twidth) + (s >> 1)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0);
|
||||
UINT8 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
UINT16 c = tlut[((tpal << 4) | p) << 2];
|
||||
|
||||
color->i.r = color->i.g = color->i.b = (c >> 8) & 0xff;
|
||||
color->i.a = c & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_IA4_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = (tbase + ((t) * twidth) + (s >> 1)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0);
|
||||
UINT8 p = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
UINT8 i = ((p & 0xe) << 4) | ((p & 0xe) << 1) | (p & 0xe >> 2);
|
||||
|
||||
color->i.r = i;
|
||||
color->i.g = i;
|
||||
color->i.b = i;
|
||||
color->i.a = (p & 0x1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_IA8_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
|
||||
UINT8 p = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
UINT16 c = tlut[p << 2];
|
||||
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_IA8_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
|
||||
UINT8 p = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
UINT16 c = tlut[p << 2];
|
||||
|
||||
color->i.r = color->i.g = color->i.b = (c >> 8) & 0xff;
|
||||
color->i.a = c & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_IA8_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
|
||||
UINT8 p = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
UINT8 i = (p >> 4) | (p & 0xf0);
|
||||
|
||||
color->i.r = i;
|
||||
color->i.g = i;
|
||||
color->i.b = i;
|
||||
color->i.a = (p & 0xf) | ((p << 4) & 0xf0);
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_IA16_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase >> 1) + ((t) * (twidth >> 1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
|
||||
UINT16 c = TMEM16[taddr ^ WORD_ADDR_XOR];
|
||||
|
||||
c = tlut[(c >> 8) << 2];
|
||||
color->i.r = ((c >> 8) & 0xf8) | (c >> 13);
|
||||
color->i.g = ((c >> 3) & 0xf8) | ((c >> 8) & 0x07);
|
||||
color->i.b = ((c << 2) & 0xf8) | ((c >> 3) & 0x07);
|
||||
color->i.a = (c & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_IA16_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase >> 1) + ((t) * (twidth >> 1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
|
||||
UINT16 c = TMEM16[taddr ^ WORD_ADDR_XOR];
|
||||
|
||||
c = tlut[(c >> 8) << 2];
|
||||
color->i.r = c >> 8;
|
||||
color->i.g = c >> 8;
|
||||
color->i.b = c >> 8;
|
||||
color->i.a = c & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_IA16_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase >> 1) + ((t) * (twidth >> 1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
|
||||
UINT16 c = TMEM16[taddr ^ WORD_ADDR_XOR];
|
||||
UINT8 i = (c >> 8);
|
||||
|
||||
color->i.r = i;
|
||||
color->i.g = i;
|
||||
color->i.b = i;
|
||||
color->i.a = c & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_I4_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
|
||||
UINT8 c = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
UINT16 k;
|
||||
c |= (c << 4);
|
||||
k = tlut[((tpal << 4) | c) << 2];
|
||||
|
||||
color->i.r = ((k >> 8) & 0xf8) | (k >> 13);
|
||||
color->i.g = ((k >> 3) & 0xf8) | ((k >> 8) & 0x07);
|
||||
color->i.b = ((k << 2) & 0xf8) | ((k >> 3) & 0x07);
|
||||
color->i.a = (k & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_I4_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
|
||||
UINT8 c = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
UINT16 k;
|
||||
|
||||
c |= (c << 4);
|
||||
k = tlut[((tpal << 4) | c) << 2];
|
||||
color->i.r = color->i.g = color->i.b = (k >> 8) & 0xff;
|
||||
color->i.a = k & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_I4_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
|
||||
UINT8 c = ((s) & 1) ? (TMEM[taddr ^ BYTE_ADDR_XOR] & 0xf) : (TMEM[taddr ^ BYTE_ADDR_XOR] >> 4);
|
||||
c |= (c << 4);
|
||||
|
||||
color->i.r = c;
|
||||
color->i.g = c;
|
||||
color->i.b = c;
|
||||
color->i.a = c;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_I8_TLUT_EN0(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
|
||||
UINT8 c = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
UINT16 k = tlut[ c << 2];
|
||||
|
||||
color->i.r = ((k >> 8) & 0xf8) | (k >> 13);
|
||||
color->i.g = ((k >> 3) & 0xf8) | ((k >> 8) & 0x07);
|
||||
color->i.b = ((k << 2) & 0xf8) | ((k >> 3) & 0x07);
|
||||
color->i.a = (k & 1) ? 0xff : 0;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_I8_TLUT_EN1(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
|
||||
UINT8 c = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
UINT16 k = tlut[ c << 2];
|
||||
|
||||
color->i.r = color->i.g = color->i.b = (k >> 8) & 0xff;
|
||||
color->i.a = k & 0xff;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_I8_TLUT_NEN(COLOR *color, int s, int t)
|
||||
{
|
||||
int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
|
||||
UINT8 c = TMEM[taddr ^ BYTE_ADDR_XOR];
|
||||
|
||||
color->i.r = c;
|
||||
color->i.g = c;
|
||||
color->i.b = c;
|
||||
color->i.a = c;
|
||||
}
|
||||
|
||||
INLINE void FETCH_TEXEL_INVALID(COLOR *color, int s, int t)
|
||||
{
|
||||
//printf("Invalid texel mode\n");
|
||||
}
|
||||
|
||||
//typedef void (*rdp_fetch_texel_func)(COLOR *color, int s, int t);
|
||||
|
||||
static void (*rdp_fetch_texel_func[128])(COLOR*, int, int) =
|
||||
{
|
||||
// 4-bit accessors
|
||||
FETCH_TEXEL_RGBA4_TLUT_NEN, FETCH_TEXEL_RGBA4_TLUT_NEN, FETCH_TEXEL_RGBA4_TLUT_EN0, FETCH_TEXEL_RGBA4_TLUT_EN1,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_CI4_TLUT_NEN, FETCH_TEXEL_CI4_TLUT_NEN, FETCH_TEXEL_CI4_TLUT_EN0, FETCH_TEXEL_CI4_TLUT_EN1,
|
||||
FETCH_TEXEL_IA4_TLUT_NEN, FETCH_TEXEL_IA4_TLUT_NEN, FETCH_TEXEL_IA4_TLUT_EN0, FETCH_TEXEL_IA4_TLUT_EN1,
|
||||
FETCH_TEXEL_I4_TLUT_NEN, FETCH_TEXEL_I4_TLUT_NEN, FETCH_TEXEL_I4_TLUT_EN0, FETCH_TEXEL_I4_TLUT_EN1,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
|
||||
// 8-bit accessors
|
||||
FETCH_TEXEL_RGBA8_TLUT_NEN, FETCH_TEXEL_RGBA8_TLUT_NEN, FETCH_TEXEL_RGBA8_TLUT_EN0, FETCH_TEXEL_RGBA8_TLUT_EN1,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_CI8_TLUT_NEN, FETCH_TEXEL_CI8_TLUT_NEN, FETCH_TEXEL_CI8_TLUT_EN0, FETCH_TEXEL_CI8_TLUT_EN1,
|
||||
FETCH_TEXEL_IA8_TLUT_NEN, FETCH_TEXEL_IA8_TLUT_NEN, FETCH_TEXEL_IA8_TLUT_EN0, FETCH_TEXEL_IA8_TLUT_EN1,
|
||||
FETCH_TEXEL_I8_TLUT_NEN, FETCH_TEXEL_I8_TLUT_NEN, FETCH_TEXEL_I8_TLUT_EN0, FETCH_TEXEL_I8_TLUT_EN1,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
|
||||
// 16-bit accessors
|
||||
FETCH_TEXEL_RGBA16_TLUT_NEN,FETCH_TEXEL_RGBA16_TLUT_NEN,FETCH_TEXEL_RGBA16_TLUT_EN0,FETCH_TEXEL_RGBA16_TLUT_EN1,
|
||||
FETCH_TEXEL_YUV16, FETCH_TEXEL_YUV16, FETCH_TEXEL_YUV16, FETCH_TEXEL_YUV16,
|
||||
FETCH_TEXEL_CI16_TLUT_NEN, FETCH_TEXEL_CI16_TLUT_NEN, FETCH_TEXEL_CI16_TLUT_EN0, FETCH_TEXEL_CI16_TLUT_EN1,
|
||||
FETCH_TEXEL_IA16_TLUT_NEN, FETCH_TEXEL_IA16_TLUT_NEN, FETCH_TEXEL_IA16_TLUT_EN0, FETCH_TEXEL_IA16_TLUT_EN1,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
|
||||
// 32-bit accessors
|
||||
FETCH_TEXEL_RGBA32_TLUT_NEN,FETCH_TEXEL_RGBA32_TLUT_NEN,FETCH_TEXEL_RGBA32_TLUT_EN0,FETCH_TEXEL_RGBA32_TLUT_EN1,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID, FETCH_TEXEL_INVALID,
|
||||
};
|
0
src/mame/video/rdpfetch.h
Normal file
0
src/mame/video/rdpfetch.h
Normal file
564
src/mame/video/rdpspn16.c
Normal file
564
src/mame/video/rdpspn16.c
Normal file
@ -0,0 +1,564 @@
|
||||
static void render_spans_16_c1(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip)
|
||||
{
|
||||
UINT16 *fb = (UINT16*)&rdram[fb_address / 4];
|
||||
UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
|
||||
UINT8 *hb = &hidden_bits[fb_address >> 1];
|
||||
UINT8 *zhb = &hidden_bits[zb_address >> 1];
|
||||
|
||||
int i, j;
|
||||
|
||||
int clipx1, clipx2, clipy1, clipy2;
|
||||
|
||||
UINT32 prim_tile = tex_tile->num;
|
||||
UINT32 disable_lod = 0;
|
||||
int tilenum;
|
||||
|
||||
SPAN_PARAM dr = span[0].dr;
|
||||
SPAN_PARAM dg = span[0].dg;
|
||||
SPAN_PARAM db = span[0].db;
|
||||
SPAN_PARAM da = span[0].da;
|
||||
SPAN_PARAM dz = span[0].dz;
|
||||
SPAN_PARAM ds = span[0].ds;
|
||||
SPAN_PARAM dt = span[0].dt;
|
||||
SPAN_PARAM dw = span[0].dw;
|
||||
int dzpix = span[0].dzpix;
|
||||
int drinc, dginc, dbinc, dainc, dzinc, dsinc, dtinc, dwinc;
|
||||
int xinc = flip ? 1 : -1;
|
||||
|
||||
calculate_clamp_diffs(tex_tile->num);
|
||||
|
||||
clipx1 = clip.xh / 4;
|
||||
clipx2 = clip.xl / 4;
|
||||
clipy1 = clip.yh / 4;
|
||||
clipy2 = clip.yl / 4;
|
||||
|
||||
if (texture && !other_modes.tex_lod_en)
|
||||
{
|
||||
tilenum = prim_tile;
|
||||
tex_tile = &tile[tilenum];
|
||||
}
|
||||
|
||||
if (other_modes.tex_lod_en) // Used by World Driver Championship
|
||||
{
|
||||
disable_lod = 1;
|
||||
}
|
||||
|
||||
drinc = flip ? (dr.w) : -dr.w;
|
||||
dginc = flip ? (dg.w) : -dg.w;
|
||||
dbinc = flip ? (db.w) : -db.w;
|
||||
dainc = flip ? (da.w) : -da.w;
|
||||
dzinc = flip ? (dz.w) : -dz.w;
|
||||
dsinc = flip ? (ds.w) : -ds.w;
|
||||
dtinc = flip ? (dt.w) : -dt.w;
|
||||
dwinc = flip ? (dw.w) : -dw.w;
|
||||
|
||||
if (start < clipy1)
|
||||
{
|
||||
start = clipy1;
|
||||
}
|
||||
if (start >= clipy2)
|
||||
{
|
||||
start = clipy2 - 1;
|
||||
}
|
||||
if (end < clipy1)
|
||||
{
|
||||
end = clipy1;
|
||||
}
|
||||
if (end >= clipy2) // Needed by 40 Winks
|
||||
{
|
||||
end = clipy2 - 1;
|
||||
}
|
||||
|
||||
set_shade_for_tris(shade); // Needed by backgrounds in Top Gear Rally 1
|
||||
|
||||
for (i = start; i <= end; i++)
|
||||
{
|
||||
int xstart = span[i].lx;
|
||||
int xend = span[i].rx;
|
||||
SPAN_PARAM r;
|
||||
SPAN_PARAM g;
|
||||
SPAN_PARAM b;
|
||||
SPAN_PARAM a;
|
||||
SPAN_PARAM z = span[i].z;
|
||||
SPAN_PARAM s = span[i].s;
|
||||
SPAN_PARAM t = span[i].t;
|
||||
SPAN_PARAM w = span[i].w;
|
||||
|
||||
int x;
|
||||
|
||||
int fb_index = fb_width * i;
|
||||
int length;
|
||||
|
||||
if (shade)
|
||||
{
|
||||
r = span[i].r;
|
||||
g = span[i].g;
|
||||
b = span[i].b;
|
||||
a = span[i].a;
|
||||
}
|
||||
|
||||
x = xend;
|
||||
|
||||
length = flip ? (xstart - xend) : (xend - xstart); //Moogly
|
||||
|
||||
for (j = 0; j <= length; j++)
|
||||
{
|
||||
int sr = 0, sg = 0, sb = 0, sa = 0;
|
||||
int ss = s.h.h;
|
||||
int st = t.h.h;
|
||||
int sw = w.h.h;
|
||||
int sz = z.w >> 13;
|
||||
int sss = 0, sst = 0;
|
||||
COLOR c1, c2;
|
||||
if (shade)
|
||||
{
|
||||
sr = r.h.h;
|
||||
sg = g.h.h;
|
||||
sb = b.h.h;
|
||||
sa = a.h.h;
|
||||
}
|
||||
c1.c = 0;
|
||||
c2.c = 0;
|
||||
if (other_modes.z_source_sel)
|
||||
{
|
||||
sz = (((UINT32)primitive_z) << 3) & 0x3ffff;
|
||||
dzpix = primitive_delta_z;
|
||||
}
|
||||
|
||||
|
||||
if (x >= clipx1 && x < clipx2)
|
||||
{
|
||||
int z_compare_result = 1;
|
||||
|
||||
curpixel_cvg=span[i].cvg[x];
|
||||
|
||||
if (curpixel_cvg > 8)
|
||||
{
|
||||
stricterror("render_spans_16: cvg of current pixel is %d", curpixel_cvg);
|
||||
}
|
||||
|
||||
if (curpixel_cvg)
|
||||
{
|
||||
int curpixel = fb_index + x;
|
||||
UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
|
||||
UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
|
||||
UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
|
||||
UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
|
||||
|
||||
if (other_modes.persp_tex_en)
|
||||
{
|
||||
tcdiv(ss, st, sw, &sss, &sst);
|
||||
}
|
||||
else // Hack for Bust-a-Move 2
|
||||
{
|
||||
sss = ss;
|
||||
sst = st;
|
||||
}
|
||||
|
||||
if (shade)
|
||||
{
|
||||
if (sr > 0xff) sr = 0xff;
|
||||
if (sg > 0xff) sg = 0xff;
|
||||
if (sb > 0xff) sb = 0xff;
|
||||
if (sa > 0xff) sa = 0xff;
|
||||
if (sr < 0) sr = 0;
|
||||
if (sg < 0) sg = 0;
|
||||
if (sb < 0) sb = 0;
|
||||
if (sa < 0) sa = 0;
|
||||
shade_color.i.r = sr;
|
||||
shade_color.i.g = sg;
|
||||
shade_color.i.b = sb;
|
||||
shade_color.i.a = sa;
|
||||
}
|
||||
|
||||
if (texture)
|
||||
{
|
||||
TEXTURE_PIPELINE(&texel0_color, sss, sst, tex_tile);
|
||||
}
|
||||
|
||||
c1 = COLOR_COMBINER1(machine);
|
||||
|
||||
if ((zbuffer || other_modes.z_source_sel) && other_modes.z_compare_en)
|
||||
{
|
||||
z_compare_result = z_compare(fbcur, hbcur, zbcur, zhbcur, sz, dzpix);
|
||||
}
|
||||
|
||||
if(z_compare_result)
|
||||
{
|
||||
int rendered = 0;
|
||||
int dith = 0;
|
||||
if (!other_modes.rgb_dither_sel)
|
||||
{
|
||||
dith = magic_matrix[(((i) & 3) << 2) + ((x ^ WORD_ADDR_XOR) & 3)];
|
||||
}
|
||||
else if (other_modes.rgb_dither_sel == 1)
|
||||
{
|
||||
dith = bayer_matrix[(((i) & 3) << 2) + ((x ^ WORD_ADDR_XOR) & 3)];
|
||||
}
|
||||
|
||||
rendered = BLENDER1_16(machine, fbcur, hbcur, c1, dith);
|
||||
|
||||
if (other_modes.z_update_en && rendered)
|
||||
{
|
||||
z_store(zbcur, zhbcur, sz, dzpix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shade)
|
||||
{
|
||||
r.w += drinc;
|
||||
g.w += dginc;
|
||||
b.w += dbinc;
|
||||
a.w += dainc;
|
||||
}
|
||||
z.w += dzinc;
|
||||
s.w += dsinc;
|
||||
t.w += dtinc;
|
||||
w.w += dwinc;
|
||||
|
||||
x += xinc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void render_spans_16_c2(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip)
|
||||
{
|
||||
UINT16 *fb = (UINT16*)&rdram[fb_address / 4];
|
||||
UINT16 *zb = (UINT16*)&rdram[zb_address / 4];
|
||||
UINT8 *hb = &hidden_bits[fb_address >> 1];
|
||||
UINT8 *zhb = &hidden_bits[zb_address >> 1];
|
||||
|
||||
int i, j;
|
||||
|
||||
int clipx1, clipx2, clipy1, clipy2;
|
||||
|
||||
UINT32 prim_tile = tex_tile->num;
|
||||
UINT32 tilenum2 = 0;
|
||||
TILE *tex_tile2 = NULL;
|
||||
int tilenum;
|
||||
|
||||
int LOD = 0;
|
||||
INT32 horstep, vertstep;
|
||||
INT32 l_tile;
|
||||
UINT32 magnify = 0;
|
||||
UINT32 distant = 0;
|
||||
|
||||
SPAN_PARAM dr = span[0].dr;
|
||||
SPAN_PARAM dg = span[0].dg;
|
||||
SPAN_PARAM db = span[0].db;
|
||||
SPAN_PARAM da = span[0].da;
|
||||
SPAN_PARAM dz = span[0].dz;
|
||||
SPAN_PARAM ds = span[0].ds;
|
||||
SPAN_PARAM dt = span[0].dt;
|
||||
SPAN_PARAM dw = span[0].dw;
|
||||
int dzpix = span[0].dzpix;
|
||||
int drinc, dginc, dbinc, dainc, dzinc, dsinc, dtinc, dwinc;
|
||||
int xinc = flip ? 1 : -1;
|
||||
|
||||
int nexts, nextt, nextsw;
|
||||
int lodclamp = 0;
|
||||
|
||||
calculate_clamp_diffs(tex_tile->num);
|
||||
|
||||
clipx1 = clip.xh / 4;
|
||||
clipx2 = clip.xl / 4;
|
||||
clipy1 = clip.yh / 4;
|
||||
clipy2 = clip.yl / 4;
|
||||
|
||||
if (texture && !other_modes.tex_lod_en)
|
||||
{
|
||||
tilenum = prim_tile;
|
||||
tex_tile = &tile[tilenum];
|
||||
tilenum2 = (prim_tile + 1) & 7;
|
||||
tex_tile2 = &tile[tilenum2];
|
||||
}
|
||||
|
||||
drinc = flip ? (dr.w) : -dr.w;
|
||||
dginc = flip ? (dg.w) : -dg.w;
|
||||
dbinc = flip ? (db.w) : -db.w;
|
||||
dainc = flip ? (da.w) : -da.w;
|
||||
dzinc = flip ? (dz.w) : -dz.w;
|
||||
dsinc = flip ? (ds.w) : -ds.w;
|
||||
dtinc = flip ? (dt.w) : -dt.w;
|
||||
dwinc = flip ? (dw.w) : -dw.w;
|
||||
|
||||
if (start < clipy1)
|
||||
{
|
||||
start = clipy1;
|
||||
}
|
||||
if (start >= clipy2)
|
||||
{
|
||||
start = clipy2 - 1;
|
||||
}
|
||||
if (end < clipy1)
|
||||
{
|
||||
end = clipy1;
|
||||
}
|
||||
if (end >= clipy2) // Needed by 40 Winks
|
||||
{
|
||||
end = clipy2 - 1;
|
||||
}
|
||||
|
||||
set_shade_for_tris(shade); // Needed by backgrounds in Top Gear Rally 1
|
||||
|
||||
for (i = start; i <= end; i++)
|
||||
{
|
||||
int xstart = span[i].lx;
|
||||
int xend = span[i].rx;
|
||||
SPAN_PARAM r;
|
||||
SPAN_PARAM g;
|
||||
SPAN_PARAM b;
|
||||
SPAN_PARAM a;
|
||||
SPAN_PARAM z = span[i].z;
|
||||
SPAN_PARAM s = span[i].s;
|
||||
SPAN_PARAM t = span[i].t;
|
||||
SPAN_PARAM w = span[i].w;
|
||||
|
||||
int x;
|
||||
|
||||
int fb_index = fb_width * i;
|
||||
int length;
|
||||
|
||||
if (shade)
|
||||
{
|
||||
r = span[i].r;
|
||||
g = span[i].g;
|
||||
b = span[i].b;
|
||||
a = span[i].a;
|
||||
}
|
||||
|
||||
x = xend;
|
||||
|
||||
length = flip ? (xstart - xend) : (xend - xstart); //Moogly
|
||||
|
||||
for (j = 0; j <= length; j++)
|
||||
{
|
||||
int sr = 0, sg = 0, sb = 0, sa = 0;
|
||||
int ss = s.h.h;
|
||||
int st = t.h.h;
|
||||
int sw = w.h.h;
|
||||
int sz = z.w >> 13;
|
||||
int sss = 0, sst = 0;
|
||||
COLOR c1, c2;
|
||||
if (shade)
|
||||
{
|
||||
sr = r.h.h;
|
||||
sg = g.h.h;
|
||||
sb = b.h.h;
|
||||
sa = a.h.h;
|
||||
}
|
||||
c1.c = 0;
|
||||
c2.c = 0;
|
||||
if (other_modes.z_source_sel)
|
||||
{
|
||||
sz = (((UINT32)primitive_z) << 3) & 0x3ffff;
|
||||
dzpix = primitive_delta_z;
|
||||
}
|
||||
|
||||
|
||||
if (x >= clipx1 && x < clipx2)
|
||||
{
|
||||
int z_compare_result = 1;
|
||||
|
||||
curpixel_cvg=span[i].cvg[x];
|
||||
|
||||
if (curpixel_cvg > 8)
|
||||
{
|
||||
stricterror("render_spans_16: cvg of current pixel is %d", curpixel_cvg);
|
||||
}
|
||||
|
||||
if (curpixel_cvg)
|
||||
{
|
||||
int curpixel = fb_index + x;
|
||||
UINT16* fbcur = &fb[curpixel ^ WORD_ADDR_XOR];
|
||||
UINT16* zbcur = &zb[curpixel ^ WORD_ADDR_XOR];
|
||||
UINT8* hbcur = &hb[curpixel ^ BYTE_ADDR_XOR];
|
||||
UINT8* zhbcur = &zhb[curpixel ^ BYTE_ADDR_XOR];
|
||||
|
||||
if (other_modes.persp_tex_en)
|
||||
{
|
||||
tcdiv(ss, st, sw, &sss, &sst);
|
||||
}
|
||||
else // Hack for Bust-a-Move 2
|
||||
{
|
||||
sss = ss;
|
||||
sst = st;
|
||||
}
|
||||
|
||||
if (other_modes.tex_lod_en)
|
||||
{
|
||||
if (other_modes.persp_tex_en)
|
||||
{
|
||||
nextsw = (w.w + dwinc) >> 16;
|
||||
nexts = (s.w + dsinc) >> 16;
|
||||
nextt = (t.w + dtinc) >> 16;
|
||||
tcdiv(nexts, nextt, nextsw, &nexts, &nextt);
|
||||
}
|
||||
else
|
||||
{
|
||||
nexts = (s.w + dsinc)>>16;
|
||||
nextt = (t.w + dtinc)>>16;
|
||||
}
|
||||
|
||||
lodclamp = 0;
|
||||
|
||||
horstep = SIGN17(nexts & 0x1ffff) - SIGN17(sss & 0x1ffff);
|
||||
vertstep = SIGN17(nextt & 0x1ffff) - SIGN17(sst & 0x1ffff);
|
||||
if (horstep & 0x20000)
|
||||
{
|
||||
horstep = ~horstep & 0x1ffff;
|
||||
}
|
||||
if (vertstep & 0x20000)
|
||||
{
|
||||
vertstep = ~vertstep & 0x1ffff;
|
||||
}
|
||||
LOD = ((horstep >= vertstep) ? horstep : vertstep);
|
||||
LOD = (LOD >= span[0].dymax) ? LOD : span[0].dymax;
|
||||
|
||||
if ((LOD & 0x1c000) || lodclamp)
|
||||
{
|
||||
LOD = 0x7fff;
|
||||
}
|
||||
if (LOD < min_level)
|
||||
{
|
||||
LOD = min_level;
|
||||
}
|
||||
|
||||
magnify = (LOD < 32) ? 1: 0;
|
||||
l_tile = getlog2((LOD >> 5) & 0xff);
|
||||
distant = ((LOD & 0x6000) || (l_tile >= max_level)) ? 1 : 0;
|
||||
|
||||
lod_frac = ((LOD << 3) >> l_tile) & 0xff;
|
||||
|
||||
if (distant)
|
||||
{
|
||||
l_tile = max_level;
|
||||
}
|
||||
if(!other_modes.sharpen_tex_en && !other_modes.detail_tex_en && magnify)
|
||||
{
|
||||
lod_frac = 0;
|
||||
}
|
||||
if(!other_modes.sharpen_tex_en && !other_modes.detail_tex_en && distant)
|
||||
{
|
||||
lod_frac = 0xff;
|
||||
}
|
||||
if(other_modes.sharpen_tex_en && magnify)
|
||||
{
|
||||
lod_frac |= 0x100;
|
||||
}
|
||||
|
||||
if (!other_modes.detail_tex_en)
|
||||
{
|
||||
tilenum = (prim_tile + l_tile);
|
||||
tilenum &= 7;
|
||||
if (other_modes.sharpen_tex_en)
|
||||
{
|
||||
tilenum2 = (tilenum + 1) & 7;
|
||||
}
|
||||
else if (!distant)
|
||||
{
|
||||
tilenum2 = (tilenum + 1) & 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
tilenum2 = tilenum;
|
||||
}
|
||||
tex_tile = &tile[tilenum];
|
||||
tex_tile2 = &tile[tilenum2];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!magnify)
|
||||
{
|
||||
tilenum = (prim_tile + l_tile + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
tilenum = (prim_tile + l_tile);
|
||||
}
|
||||
tilenum &= 7;
|
||||
|
||||
if (!distant && !magnify)
|
||||
{
|
||||
tilenum2 = (prim_tile + l_tile + 2) & 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
tilenum2 = (prim_tile + l_tile + 1) & 7;
|
||||
}
|
||||
tex_tile = &tile[tilenum];
|
||||
tex_tile2 = &tile[tilenum2];
|
||||
}
|
||||
}
|
||||
|
||||
if (shade)
|
||||
{
|
||||
if (sr > 0xff) sr = 0xff;
|
||||
if (sg > 0xff) sg = 0xff;
|
||||
if (sb > 0xff) sb = 0xff;
|
||||
if (sa > 0xff) sa = 0xff;
|
||||
if (sr < 0) sr = 0;
|
||||
if (sg < 0) sg = 0;
|
||||
if (sb < 0) sb = 0;
|
||||
if (sa < 0) sa = 0;
|
||||
shade_color.i.r = sr;
|
||||
shade_color.i.g = sg;
|
||||
shade_color.i.b = sb;
|
||||
shade_color.i.a = sa;
|
||||
}
|
||||
|
||||
if (texture)
|
||||
{
|
||||
TEXTURE_PIPELINE(&texel0_color, sss, sst, tex_tile);
|
||||
TEXTURE_PIPELINE(&texel1_color, sss, sst, tex_tile2);
|
||||
}
|
||||
|
||||
c1 = COLOR_COMBINER2_C0(machine);
|
||||
c2 = COLOR_COMBINER2_C1(machine);
|
||||
|
||||
if ((zbuffer || other_modes.z_source_sel) && other_modes.z_compare_en)
|
||||
{
|
||||
z_compare_result = z_compare(fbcur, hbcur, zbcur, zhbcur, sz, dzpix);
|
||||
}
|
||||
|
||||
if(z_compare_result)
|
||||
{
|
||||
int rendered = 0;
|
||||
int dith = 0;
|
||||
if (!other_modes.rgb_dither_sel)
|
||||
{
|
||||
dith = magic_matrix[(((i) & 3) << 2) + ((x ^ WORD_ADDR_XOR) & 3)];
|
||||
}
|
||||
else if (other_modes.rgb_dither_sel == 1)
|
||||
{
|
||||
dith = bayer_matrix[(((i) & 3) << 2) + ((x ^ WORD_ADDR_XOR) & 3)];
|
||||
}
|
||||
|
||||
rendered = BLENDER2_16(machine, fbcur, hbcur, c1, c2, dith);
|
||||
|
||||
if (other_modes.z_update_en && rendered)
|
||||
{
|
||||
z_store(zbcur, zhbcur, sz, dzpix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shade)
|
||||
{
|
||||
r.w += drinc;
|
||||
g.w += dginc;
|
||||
b.w += dbinc;
|
||||
a.w += dainc;
|
||||
}
|
||||
z.w += dzinc;
|
||||
s.w += dsinc;
|
||||
t.w += dtinc;
|
||||
w.w += dwinc;
|
||||
|
||||
x += xinc;
|
||||
}
|
||||
}
|
||||
}
|
7
src/mame/video/rdpspn16.h
Normal file
7
src/mame/video/rdpspn16.h
Normal file
@ -0,0 +1,7 @@
|
||||
static void render_spans_16_c1(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip);
|
||||
static void render_spans_16_c2(running_machine *machine, int start, int end, TILE* tex_tile, int shade, int texture, int zbuffer, int flip);
|
||||
|
||||
static void (*rdp_render_spans_16_func[4])(running_machine*, int, int, TILE*, int, int, int, int) =
|
||||
{
|
||||
render_spans_16_c1, render_spans_16_c2, render_spans_16_c1, render_spans_16_c1
|
||||
};
|
195
src/mame/video/rdptpipe.c
Normal file
195
src/mame/video/rdptpipe.c
Normal file
@ -0,0 +1,195 @@
|
||||
INLINE void TEXTURE_PIPELINE_BILINEAR_NMID(COLOR* TEX, INT32 SSS, INT32 SST, TILE* tex_tile)
|
||||
{
|
||||
#define RELATIVE(x, y) ((((x) >> 3) - (y)) << 3) | (x & 7);
|
||||
INT32 maxs, maxt;
|
||||
COLOR t0, t1, t2, t3;
|
||||
int sss1, sst1, sss2, sst2;
|
||||
|
||||
INT32 SFRAC = 0, TFRAC = 0, INVSF = 0, INVTF = 0;
|
||||
INT32 R32, G32, B32, A32;
|
||||
INT32 maxs2, maxt2;
|
||||
int upper = 0;
|
||||
|
||||
t0.c = 0;
|
||||
t1.c = 0;
|
||||
t2.c = 0;
|
||||
t3.c = 0;
|
||||
|
||||
sss1 = SSS;
|
||||
sst1 = SST;
|
||||
|
||||
texshift(&sss1, &sst1, &maxs, &maxt, tex_tile);
|
||||
|
||||
sss2 = sss1 + 32; sst2 = sst1 + 32;
|
||||
maxs2 = ((sss2 >> 3) >= tex_tile->sh);
|
||||
maxt2 = ((sst2 >> 3) >= tex_tile->th);
|
||||
|
||||
sss1 = RELATIVE(sss1, tex_tile->sl);
|
||||
sst1 = RELATIVE(sst1, tex_tile->tl);
|
||||
sss2 = RELATIVE(sss2, tex_tile->sl);
|
||||
sst2 = RELATIVE(sst2, tex_tile->tl);
|
||||
|
||||
SFRAC = sss1 & 0x1f;
|
||||
TFRAC = sst1 & 0x1f;
|
||||
|
||||
CLAMP(&sss1, &sst1, &SFRAC, &TFRAC, maxs, maxt, tex_tile);
|
||||
CLAMP_LIGHT(&sss2, &sst2, maxs2, maxt2, tex_tile);
|
||||
|
||||
MASK(&sss1, &sst1, tex_tile);
|
||||
MASK(&sss2, &sst2, tex_tile);
|
||||
|
||||
upper = ((SFRAC + TFRAC) >= 0x20);
|
||||
if (upper)
|
||||
{
|
||||
INVSF = 0x20 - SFRAC;
|
||||
INVTF = 0x20 - TFRAC;
|
||||
}
|
||||
|
||||
if (!upper)
|
||||
{
|
||||
FETCH_TEXEL(&t0, sss1, sst1, tex_tile);
|
||||
}
|
||||
FETCH_TEXEL(&t1, sss2, sst1, tex_tile);
|
||||
FETCH_TEXEL(&t2, sss1, sst2, tex_tile);
|
||||
if (upper)
|
||||
{
|
||||
FETCH_TEXEL(&t3, sss2, sst2, tex_tile);
|
||||
}
|
||||
|
||||
if (upper)
|
||||
{
|
||||
R32 = t3.i.r + ((INVSF*(t2.i.r - t3.i.r))>>5) + ((INVTF*(t1.i.r - t3.i.r))>>5);
|
||||
TEX->i.r = (R32 < 0) ? 0 : R32;
|
||||
G32 = t3.i.g + ((INVSF*(t2.i.g - t3.i.g))>>5) + ((INVTF*(t1.i.g - t3.i.g))>>5);
|
||||
TEX->i.g = (G32 < 0) ? 0 : G32;
|
||||
B32 = t3.i.b + ((INVSF*(t2.i.b - t3.i.b))>>5) + ((INVTF*(t1.i.b - t3.i.b))>>5);
|
||||
TEX->i.b = (B32 < 0) ? 0 : B32;
|
||||
A32 = t3.i.a + ((INVSF*(t2.i.a - t3.i.a))>>5) + ((INVTF*(t1.i.a - t3.i.a))>>5);
|
||||
TEX->i.a = (A32 < 0) ? 0 : A32;
|
||||
}
|
||||
else
|
||||
{
|
||||
R32 = t0.i.r + ((SFRAC*(t1.i.r - t0.i.r))>>5) + ((TFRAC*(t2.i.r - t0.i.r))>>5);
|
||||
TEX->i.r = (R32 < 0) ? 0 : R32;
|
||||
G32 = t0.i.g + ((SFRAC*(t1.i.g - t0.i.g))>>5) + ((TFRAC*(t2.i.g - t0.i.g))>>5);
|
||||
TEX->i.g = (G32 < 0) ? 0 : G32;
|
||||
B32 = t0.i.b + ((SFRAC*(t1.i.b - t0.i.b))>>5) + ((TFRAC*(t2.i.b - t0.i.b))>>5);
|
||||
TEX->i.b = (B32 < 0) ? 0 : B32;
|
||||
A32 = t0.i.a + ((SFRAC*(t1.i.a - t0.i.a))>>5) + ((TFRAC*(t2.i.a - t0.i.a))>>5);
|
||||
TEX->i.a = (A32 < 0) ? 0 : A32;
|
||||
}
|
||||
}
|
||||
|
||||
INLINE void TEXTURE_PIPELINE_BILINEAR_MID(COLOR* TEX, INT32 SSS, INT32 SST, TILE* tex_tile)
|
||||
{
|
||||
#define RELATIVE(x, y) ((((x) >> 3) - (y)) << 3) | (x & 7);
|
||||
INT32 maxs, maxt;
|
||||
COLOR t0, t1, t2, t3;
|
||||
int sss1, sst1, sss2, sst2;
|
||||
|
||||
INT32 SFRAC = 0, TFRAC = 0, INVSF = 0, INVTF = 0;
|
||||
INT32 R32, G32, B32, A32;
|
||||
INT32 maxs2, maxt2;
|
||||
int upper = 0;
|
||||
|
||||
t0.c = 0;
|
||||
t1.c = 0;
|
||||
t2.c = 0;
|
||||
t3.c = 0;
|
||||
|
||||
sss1 = SSS;
|
||||
sst1 = SST;
|
||||
|
||||
texshift(&sss1, &sst1, &maxs, &maxt, tex_tile);
|
||||
|
||||
sss2 = sss1 + 32; sst2 = sst1 + 32;
|
||||
maxs2 = ((sss2 >> 3) >= tex_tile->sh);
|
||||
maxt2 = ((sst2 >> 3) >= tex_tile->th);
|
||||
|
||||
sss1 = RELATIVE(sss1, tex_tile->sl);
|
||||
sst1 = RELATIVE(sst1, tex_tile->tl);
|
||||
sss2 = RELATIVE(sss2, tex_tile->sl);
|
||||
sst2 = RELATIVE(sst2, tex_tile->tl);
|
||||
|
||||
SFRAC = sss1 & 0x1f;
|
||||
TFRAC = sst1 & 0x1f;
|
||||
|
||||
CLAMP(&sss1, &sst1, &SFRAC, &TFRAC, maxs, maxt, tex_tile);
|
||||
CLAMP_LIGHT(&sss2, &sst2, maxs2, maxt2, tex_tile);
|
||||
|
||||
MASK(&sss1, &sst1, tex_tile);
|
||||
MASK(&sss2, &sst2, tex_tile);
|
||||
|
||||
upper = ((SFRAC + TFRAC) >= 0x20);
|
||||
if (upper)
|
||||
{
|
||||
INVSF = 0x20 - SFRAC;
|
||||
INVTF = 0x20 - TFRAC;
|
||||
}
|
||||
|
||||
FETCH_TEXEL(&t0, sss1, sst1, tex_tile);
|
||||
FETCH_TEXEL(&t1, sss2, sst1, tex_tile);
|
||||
FETCH_TEXEL(&t2, sss1, sst2, tex_tile);
|
||||
FETCH_TEXEL(&t3, sss2, sst2, tex_tile);
|
||||
|
||||
if (SFRAC!= 0x10 || TFRAC != 0x10)
|
||||
{
|
||||
if (upper)
|
||||
{
|
||||
R32 = t3.i.r + ((INVSF*(t2.i.r - t3.i.r))>>5) + ((INVTF*(t1.i.r - t3.i.r))>>5);
|
||||
TEX->i.r = (R32 < 0) ? 0 : R32;
|
||||
G32 = t3.i.g + ((INVSF*(t2.i.g - t3.i.g))>>5) + ((INVTF*(t1.i.g - t3.i.g))>>5);
|
||||
TEX->i.g = (G32 < 0) ? 0 : G32;
|
||||
B32 = t3.i.b + ((INVSF*(t2.i.b - t3.i.b))>>5) + ((INVTF*(t1.i.b - t3.i.b))>>5);
|
||||
TEX->i.b = (B32 < 0) ? 0 : B32;
|
||||
A32 = t3.i.a + ((INVSF*(t2.i.a - t3.i.a))>>5) + ((INVTF*(t1.i.a - t3.i.a))>>5);
|
||||
TEX->i.a = (A32 < 0) ? 0 : A32;
|
||||
}
|
||||
else
|
||||
{
|
||||
R32 = t0.i.r + ((SFRAC*(t1.i.r - t0.i.r))>>5) + ((TFRAC*(t2.i.r - t0.i.r))>>5);
|
||||
TEX->i.r = (R32 < 0) ? 0 : R32;
|
||||
G32 = t0.i.g + ((SFRAC*(t1.i.g - t0.i.g))>>5) + ((TFRAC*(t2.i.g - t0.i.g))>>5);
|
||||
TEX->i.g = (G32 < 0) ? 0 : G32;
|
||||
B32 = t0.i.b + ((SFRAC*(t1.i.b - t0.i.b))>>5) + ((TFRAC*(t2.i.b - t0.i.b))>>5);
|
||||
TEX->i.b = (B32 < 0) ? 0 : B32;
|
||||
A32 = t0.i.a + ((SFRAC*(t1.i.a - t0.i.a))>>5) + ((TFRAC*(t2.i.a - t0.i.a))>>5);
|
||||
TEX->i.a = (A32 < 0) ? 0 : A32;
|
||||
}
|
||||
}
|
||||
else // Is this accurate?
|
||||
{
|
||||
TEX->i.r = (t0.i.r + t1.i.r + t2.i.r + t3.i.r) >> 2;
|
||||
TEX->i.g = (t0.i.g + t1.i.g + t2.i.g + t3.i.g) >> 2;
|
||||
TEX->i.b = (t0.i.b + t1.i.b + t2.i.b + t3.i.b) >> 2;
|
||||
TEX->i.a = (t0.i.a + t1.i.a + t2.i.a + t3.i.a) >> 2;
|
||||
}
|
||||
}
|
||||
|
||||
INLINE void TEXTURE_PIPELINE_NEAREST_NMID(COLOR* TEX, INT32 SSS, INT32 SST, TILE* tex_tile)
|
||||
{
|
||||
#define RELATIVE(x, y) ((((x) >> 3) - (y)) << 3) | (x & 7);
|
||||
INT32 maxs, maxt;
|
||||
int sss1, sst1;
|
||||
INT32 SFRAC, TFRAC;
|
||||
|
||||
sss1 = SSS;
|
||||
sst1 = SST;
|
||||
|
||||
texshift(&sss1, &sst1, &maxs, &maxt, tex_tile);
|
||||
sss1 = RELATIVE(sss1, tex_tile->sl);
|
||||
sst1 = RELATIVE(sst1, tex_tile->tl);
|
||||
|
||||
sss1 += 0x10;
|
||||
sst1 += 0x10;
|
||||
|
||||
SFRAC = sss1 & 0x1f;
|
||||
TFRAC = sst1 & 0x1f;
|
||||
|
||||
CLAMP(&sss1, &sst1, &SFRAC, &TFRAC, maxs, maxt, tex_tile);
|
||||
|
||||
MASK(&sss1, &sst1, tex_tile);
|
||||
|
||||
/* point sample */
|
||||
FETCH_TEXEL(TEX, sss1, sst1, tex_tile);
|
||||
}
|
8
src/mame/video/rdptpipe.h
Normal file
8
src/mame/video/rdptpipe.h
Normal file
@ -0,0 +1,8 @@
|
||||
INLINE void TEXTURE_PIPELINE_BILINEAR_NMID(COLOR* TEX, INT32 SSS, INT32 SST, TILE* tex_tile);
|
||||
INLINE void TEXTURE_PIPELINE_BILINEAR_MID(COLOR* TEX, INT32 SSS, INT32 SST, TILE* tex_tile);
|
||||
INLINE void TEXTURE_PIPELINE_NEAREST_NMID(COLOR* TEX, INT32 SSS, INT32 SST, TILE* tex_tile);
|
||||
|
||||
static void (*rdp_texture_pipeline_func[4])(COLOR*, INT32, INT32, TILE*) =
|
||||
{
|
||||
TEXTURE_PIPELINE_NEAREST_NMID, TEXTURE_PIPELINE_BILINEAR_NMID, TEXTURE_PIPELINE_NEAREST_NMID, TEXTURE_PIPELINE_BILINEAR_MID,
|
||||
};
|
1296
src/mame/video/rdptrect.c
Normal file
1296
src/mame/video/rdptrect.c
Normal file
File diff suppressed because it is too large
Load Diff
41
src/mame/video/rdptrect.h
Normal file
41
src/mame/video/rdptrect.h
Normal file
@ -0,0 +1,41 @@
|
||||
static void texture_rectangle_16bit_c1_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c2_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cc_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cf_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c1_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cc_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cf_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c1_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c2_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cc_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cf_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c1_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c2_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cf_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c1_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c2_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cc_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cf_nzc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c1_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c2_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cc_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cf_zc_nzu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c1_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c2_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cc_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cf_nzc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c1_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_c2_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cc_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
static void texture_rectangle_16bit_cf_zc_zu(running_machine *machine, TEX_RECTANGLE *rect);
|
||||
|
||||
static void (*rdp_texture_rectangle_16bit_func[16])(running_machine *, TEX_RECTANGLE *) =
|
||||
{
|
||||
texture_rectangle_16bit_c1_nzc_nzu, texture_rectangle_16bit_c2_nzc_nzu, texture_rectangle_16bit_cc_nzc_nzu, texture_rectangle_16bit_cf_nzc_nzu,
|
||||
texture_rectangle_16bit_c1_zc_nzu, texture_rectangle_16bit_c2_zc_nzu, texture_rectangle_16bit_cc_zc_nzu, texture_rectangle_16bit_cf_zc_nzu,
|
||||
texture_rectangle_16bit_c1_nzc_zu, texture_rectangle_16bit_c2_nzc_zu, texture_rectangle_16bit_cc_nzc_zu, texture_rectangle_16bit_cf_nzc_zu,
|
||||
texture_rectangle_16bit_c1_zc_zu, texture_rectangle_16bit_c2_zc_zu, texture_rectangle_16bit_cc_zc_zu, texture_rectangle_16bit_cf_zc_zu,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user