notaz.gp2x.de
/
pcsx_rearmed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unai: Use 8.8 RGB triplet format for gouraud shading
[pcsx_rearmed.git]
/
plugins
/
gpu_unai
/
gpu_inner.h
diff --git
a/plugins/gpu_unai/gpu_inner.h
b/plugins/gpu_unai/gpu_inner.h
index
8cb4bd5
..
1a93a39
100644
(file)
--- a/
plugins/gpu_unai/gpu_inner.h
+++ b/
plugins/gpu_unai/gpu_inner.h
@@
-59,20
+59,15
@@
#include "gpu_inner_blend_arm.h"
#include "gpu_inner_light_arm.h"
#define gpuBlending gpuBlendingARM
#include "gpu_inner_blend_arm.h"
#include "gpu_inner_light_arm.h"
#define gpuBlending gpuBlendingARM
-#define gpuLightingRGB gpuLightingRGBARM
#define gpuLightingTXT gpuLightingTXTARM
#define gpuLightingTXT gpuLightingTXTARM
-#define gpuLightingTXTGouraud gpuLightingTXTGouraudARM
-// Non-dithering lighting and blending functions preserve uSrc
-// MSB. This saves a few operations and useless load/stores.
-#define MSB_PRESERVED (!CF_DITHER)
#else
#define gpuBlending gpuBlendingGeneric
#else
#define gpuBlending gpuBlendingGeneric
-#define gpuLightingRGB gpuLightingRGBGeneric
#define gpuLightingTXT gpuLightingTXTGeneric
#define gpuLightingTXT gpuLightingTXTGeneric
-#define gpuLightingTXTGouraud gpuLightingTXTGouraudGeneric
-#define MSB_PRESERVED 0
#endif
#endif
+// Non-dithering lighting and blending functions preserve uSrc
+// MSB. This saves a few operations and useless load/stores.
+#define MSB_PRESERVED (!CF_DITHER)
// If defined, Gouraud colors are fixed-point 5.11, otherwise they are 8.16
// This is only for debugging/verification of low-precision colors in C.
// If defined, Gouraud colors are fixed-point 5.11, otherwise they are 8.16
// This is only for debugging/verification of low-precision colors in C.
@@
-123,12
+118,8
@@
static inline u16 gpuGouraudColor15bpp(u32 r, u32 g, u32 b)
// rectangles) to use the same set of functions. Since tiles are always
// monochrome, they simply wouldn't use the extra set of 32 gouraud-shaded
// gpuPixelSpanFn functions (TODO?).
// rectangles) to use the same set of functions. Since tiles are always
// monochrome, they simply wouldn't use the extra set of 32 gouraud-shaded
// gpuPixelSpanFn functions (TODO?).
-//
-// NOTE: While the PS1 framebuffer is 16 bit, we use 8-bit pointers here,
-// so that pDst can be incremented directly by 'incr' parameter
-// without having to shift it before use.
template<int CF>
template<int CF>
-static
u8* gpuPixelSpanFn(u8
* pDst, uintptr_t data, ptrdiff_t incr, size_t len)
+static
le16_t* gpuPixelSpanFn(le16_t
* pDst, uintptr_t data, ptrdiff_t incr, size_t len)
{
// Blend func can save an operation if it knows uSrc MSB is
// unset. For untextured prims, this is always true.
{
// Blend func can save an operation if it knows uSrc MSB is
// unset. For untextured prims, this is always true.
@@
-139,6
+130,9
@@
static u8* gpuPixelSpanFn(u8* pDst, uintptr_t data, ptrdiff_t incr, size_t len)
u32 r, g, b;
s32 r_incr, g_incr, b_incr;
u32 r, g, b;
s32 r_incr, g_incr, b_incr;
+ // Caller counts in bytes, we count in pixels
+ incr /= 2;
+
if (CF_GOURAUD) {
gcPtr = (GouraudColor*)data;
r = gcPtr->r; r_incr = gcPtr->r_incr;
if (CF_GOURAUD) {
gcPtr = (GouraudColor*)data;
r = gcPtr->r; r_incr = gcPtr->r_incr;
@@
-152,15
+146,15
@@
static u8* gpuPixelSpanFn(u8* pDst, uintptr_t data, ptrdiff_t incr, size_t len)
if (!CF_GOURAUD)
{ // NO GOURAUD
if (!CF_MASKCHECK && !CF_BLEND) {
if (!CF_GOURAUD)
{ // NO GOURAUD
if (!CF_MASKCHECK && !CF_BLEND) {
- if (CF_MASKSET) { *
(u16*)pDst = col | 0x8000
; }
- else { *
(u16*)pDst = col
; }
+ if (CF_MASKSET) { *
pDst = u16_to_le16(col | 0x8000)
; }
+ else { *
pDst = u16_to_le16(col)
; }
} else if (CF_MASKCHECK && !CF_BLEND) {
} else if (CF_MASKCHECK && !CF_BLEND) {
- if (!(
*(u16*)pDst & 0x8000
)) {
- if (CF_MASKSET) { *
(u16*)pDst = col | 0x8000
; }
- else { *
(u16*)pDst = col
; }
+ if (!(
le16_raw(*pDst) & HTOLE16(0x8000)
)) {
+ if (CF_MASKSET) { *
pDst = u16_to_le16(col | 0x8000)
; }
+ else { *
pDst = u16_to_le16(col)
; }
}
} else {
}
} else {
- uint_fast16_t uDst =
*(u16*)pDst
;
+ uint_fast16_t uDst =
le16_to_u16(*pDst)
;
if (CF_MASKCHECK) { if (uDst & 0x8000) goto endpixel; }
uint_fast16_t uSrc = col;
if (CF_MASKCHECK) { if (uDst & 0x8000) goto endpixel; }
uint_fast16_t uSrc = col;
@@
-168,8
+162,8
@@
static u8* gpuPixelSpanFn(u8* pDst, uintptr_t data, ptrdiff_t incr, size_t len)
if (CF_BLEND)
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
if (CF_BLEND)
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
- if (CF_MASKSET) { *
(u16*)pDst = uSrc | 0x8000
; }
- else { *
(u16*)pDst = uSrc
; }
+ if (CF_MASKSET) { *
pDst = u16_to_le16(uSrc | 0x8000)
; }
+ else { *
pDst = u16_to_le16(uSrc)
; }
}
} else
}
} else
@@
-177,16
+171,16
@@
static u8* gpuPixelSpanFn(u8* pDst, uintptr_t data, ptrdiff_t incr, size_t len)
if (!CF_MASKCHECK && !CF_BLEND) {
col = gpuGouraudColor15bpp(r, g, b);
if (!CF_MASKCHECK && !CF_BLEND) {
col = gpuGouraudColor15bpp(r, g, b);
- if (CF_MASKSET) { *
(u16*)pDst = col | 0x8000
; }
- else { *
(u16*)pDst = col
; }
+ if (CF_MASKSET) { *
pDst = u16_to_le16(col | 0x8000)
; }
+ else { *
pDst = u16_to_le16(col)
; }
} else if (CF_MASKCHECK && !CF_BLEND) {
col = gpuGouraudColor15bpp(r, g, b);
} else if (CF_MASKCHECK && !CF_BLEND) {
col = gpuGouraudColor15bpp(r, g, b);
- if (!(
*(u16*)pDst & 0x8000
)) {
- if (CF_MASKSET) { *
(u16*)pDst = col | 0x8000
; }
- else { *
(u16*)pDst = col
; }
+ if (!(
le16_raw(*pDst) & HTOLE16(0x8000)
)) {
+ if (CF_MASKSET) { *
pDst = u16_to_le16(col | 0x8000)
; }
+ else { *
pDst = u16_to_le16(col)
; }
}
} else {
}
} else {
- uint_fast16_t uDst =
*(u16*)pDst
;
+ uint_fast16_t uDst =
le16_to_u16(*pDst)
;
if (CF_MASKCHECK) { if (uDst & 0x8000) goto endpixel; }
col = gpuGouraudColor15bpp(r, g, b);
if (CF_MASKCHECK) { if (uDst & 0x8000) goto endpixel; }
col = gpuGouraudColor15bpp(r, g, b);
@@
-199,8
+193,8
@@
static u8* gpuPixelSpanFn(u8* pDst, uintptr_t data, ptrdiff_t incr, size_t len)
if (CF_BLEND)
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
if (CF_BLEND)
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
- if (CF_MASKSET) { *
(u16*)pDst = uSrc | 0x8000
; }
- else { *
(u16*)pDst = uSrc
; }
+ if (CF_MASKSET) { *
pDst = u16_to_le16(uSrc | 0x8000)
; }
+ else { *
pDst = u16_to_le16(uSrc)
; }
}
}
}
}
@@
-228,7
+222,7
@@
endpixel:
return pDst;
}
return pDst;
}
-static
u8* PixelSpanNULL(u8
* pDst, uintptr_t data, ptrdiff_t incr, size_t len)
+static
le16_t* PixelSpanNULL(le16_t
* pDst, uintptr_t data, ptrdiff_t incr, size_t len)
{
#ifdef ENABLE_GPU_LOG_SUPPORT
fprintf(stdout,"PixelSpanNULL()\n");
{
#ifdef ENABLE_GPU_LOG_SUPPORT
fprintf(stdout,"PixelSpanNULL()\n");
@@
-238,7
+232,7
@@
static u8* PixelSpanNULL(u8* pDst, uintptr_t data, ptrdiff_t incr, size_t len)
///////////////////////////////////////////////////////////////////////////////
// PixelSpan (lines) innerloops driver
///////////////////////////////////////////////////////////////////////////////
// PixelSpan (lines) innerloops driver
-typedef
u8* (*PSD)(u8
* dst, uintptr_t data, ptrdiff_t incr, size_t len);
+typedef
le16_t* (*PSD)(le16_t
* dst, uintptr_t data, ptrdiff_t incr, size_t len);
const PSD gpuPixelSpanDrivers[64] =
{
const PSD gpuPixelSpanDrivers[64] =
{
@@
-282,14
+276,26
@@
const PSD gpuPixelSpanDrivers[64] =
// GPU Tiles innerloops generator
template<int CF>
// GPU Tiles innerloops generator
template<int CF>
-static void gpuTileSpanFn(
u16
*pDst, u32 count, u16 data)
+static void gpuTileSpanFn(
le16_t
*pDst, u32 count, u16 data)
{
{
+ le16_t ldata;
+
if (!CF_MASKCHECK && !CF_BLEND) {
if (!CF_MASKCHECK && !CF_BLEND) {
- if (CF_MASKSET) { data = data | 0x8000; }
- do { *pDst++ = data; } while (--count);
+ if (CF_MASKSET)
+ ldata = u16_to_le16(data | 0x8000);
+ else
+ ldata = u16_to_le16(data);
+ do { *pDst++ = ldata; } while (--count);
} else if (CF_MASKCHECK && !CF_BLEND) {
} else if (CF_MASKCHECK && !CF_BLEND) {
- if (CF_MASKSET) { data = data | 0x8000; }
- do { if (!(*pDst&0x8000)) { *pDst = data; } pDst++; } while (--count);
+ if (CF_MASKSET)
+ ldata = u16_to_le16(data | 0x8000);
+ else
+ ldata = u16_to_le16(data);
+ do {
+ if (!(le16_raw(*pDst) & HTOLE16(0x8000)))
+ *pDst = ldata;
+ pDst++;
+ } while (--count);
} else
{
// Blend func can save an operation if it knows uSrc MSB is
} else
{
// Blend func can save an operation if it knows uSrc MSB is
@@
-299,16
+305,16
@@
static void gpuTileSpanFn(u16 *pDst, u32 count, u16 data)
uint_fast16_t uSrc, uDst;
do
{
uint_fast16_t uSrc, uDst;
do
{
- if (CF_MASKCHECK || CF_BLEND) { uDst =
*pDst
; }
- if (CF_MASKCHECK)
{ if (uDst&0x8000)
goto endtile; }
+ if (CF_MASKCHECK || CF_BLEND) { uDst =
le16_to_u16(*pDst)
; }
+ if (CF_MASKCHECK)
if (uDst&0x8000) {
goto endtile; }
uSrc = data;
if (CF_BLEND)
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
uSrc = data;
if (CF_BLEND)
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
- if (CF_MASKSET) { *pDst = u
Src | 0x8000
; }
- else { *pDst = u
Src
; }
+ if (CF_MASKSET) { *pDst = u
16_to_le16(uSrc | 0x8000)
; }
+ else { *pDst = u
16_to_le16(uSrc)
; }
//senquack - Did not apply "Silent Hill" mask-bit fix to here.
// It is hard to tell from scarce documentation available and
//senquack - Did not apply "Silent Hill" mask-bit fix to here.
// It is hard to tell from scarce documentation available and
@@
-322,7
+328,7
@@
endtile:
}
}
}
}
-static void TileNULL(
u16
*pDst, u32 count, u16 data)
+static void TileNULL(
le16_t
*pDst, u32 count, u16 data)
{
#ifdef ENABLE_GPU_LOG_SUPPORT
fprintf(stdout,"TileNULL()\n");
{
#ifdef ENABLE_GPU_LOG_SUPPORT
fprintf(stdout,"TileNULL()\n");
@@
-331,7
+337,7
@@
static void TileNULL(u16 *pDst, u32 count, u16 data)
///////////////////////////////////////////////////////////////////////////////
// Tiles innerloops driver
///////////////////////////////////////////////////////////////////////////////
// Tiles innerloops driver
-typedef void (*PT)(
u16
*pDst, u32 count, u16 data);
+typedef void (*PT)(
le16_t
*pDst, u32 count, u16 data);
// Template instantiation helper macros
#define TI(cf) gpuTileSpanFn<(cf)>
// Template instantiation helper macros
#define TI(cf) gpuTileSpanFn<(cf)>
@@
-355,7
+361,7
@@
const PT gpuTileSpanDrivers[32] = {
// GPU Sprites innerloops generator
template<int CF>
// GPU Sprites innerloops generator
template<int CF>
-static void gpuSpriteSpanFn(
u16
*pDst, u32 count, u8* pTxt, u32 u0)
+static void gpuSpriteSpanFn(
le16_t
*pDst, u32 count, u8* pTxt, u32 u0)
{
// Blend func can save an operation if it knows uSrc MSB is unset.
// Untextured prims can always skip (source color always comes with MSB=0).
{
// Blend func can save an operation if it knows uSrc MSB is unset.
// Untextured prims can always skip (source color always comes with MSB=0).
@@
-364,13
+370,13
@@
static void gpuSpriteSpanFn(u16 *pDst, u32 count, u8* pTxt, u32 u0)
uint_fast16_t uSrc, uDst, srcMSB;
bool should_blend;
uint_fast16_t uSrc, uDst, srcMSB;
bool should_blend;
- u32 u0_mask = gpu_
senquack
.TextureWindow[2];
+ u32 u0_mask = gpu_
unai
.TextureWindow[2];
u8 r5, g5, b5;
if (CF_LIGHT) {
u8 r5, g5, b5;
if (CF_LIGHT) {
- r5 = gpu_
senquack
.r5;
- g5 = gpu_
senquack
.g5;
- b5 = gpu_
senquack
.b5;
+ r5 = gpu_
unai
.r5;
+ g5 = gpu_
unai
.g5;
+ b5 = gpu_
unai
.b5;
}
if (CF_TEXTMODE==3) {
}
if (CF_TEXTMODE==3) {
@@
-378,22
+384,22
@@
static void gpuSpriteSpanFn(u16 *pDst, u32 count, u8* pTxt, u32 u0)
u0_mask <<= 1;
}
u0_mask <<= 1;
}
- const
u16 *CBA_; if (CF_TEXTMODE!=3) CBA_ = gpu_senquack
.CBA;
+ const
le16_t *CBA_; if (CF_TEXTMODE!=3) CBA_ = gpu_unai
.CBA;
do
{
do
{
- if (CF_MASKCHECK || CF_BLEND) { uDst =
*pDst
; }
+ if (CF_MASKCHECK || CF_BLEND) { uDst =
le16_to_u16(*pDst)
; }
if (CF_MASKCHECK) if (uDst&0x8000) { goto endsprite; }
if (CF_TEXTMODE==1) { // 4bpp (CLUT)
u8 rgb = pTxt[(u0 & u0_mask)>>1];
if (CF_MASKCHECK) if (uDst&0x8000) { goto endsprite; }
if (CF_TEXTMODE==1) { // 4bpp (CLUT)
u8 rgb = pTxt[(u0 & u0_mask)>>1];
- uSrc =
CBA_[(rgb>>((u0&1)<<2))&0xf]
;
+ uSrc =
le16_to_u16(CBA_[(rgb>>((u0&1)<<2))&0xf])
;
}
if (CF_TEXTMODE==2) { // 8bpp (CLUT)
}
if (CF_TEXTMODE==2) { // 8bpp (CLUT)
- uSrc =
CBA_[pTxt[u0 & u0_mask]]
;
+ uSrc =
le16_to_u16(CBA_[pTxt[u0 & u0_mask]])
;
}
if (CF_TEXTMODE==3) { // 16bpp
}
if (CF_TEXTMODE==3) { // 16bpp
- uSrc =
*(u16*)(&pTxt[u0 & u0_mask]
);
+ uSrc =
le16_to_u16(*(le16_t*)(&pTxt[u0 & u0_mask])
);
}
if (!uSrc) goto endsprite;
}
if (!uSrc) goto endsprite;
@@
-410,9
+416,9
@@
static void gpuSpriteSpanFn(u16 *pDst, u32 count, u8* pTxt, u32 u0)
if (CF_BLEND && should_blend)
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
if (CF_BLEND && should_blend)
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
- if (CF_MASKSET) { *pDst = u
Src | 0x8000
; }
- else if (!MSB_PRESERVED && (CF_BLEND || CF_LIGHT)) { *pDst = u
Src | srcMSB
; }
- else { *pDst = u
Src
; }
+ if (CF_MASKSET) { *pDst = u
16_to_le16(uSrc | 0x8000)
; }
+ else if (!MSB_PRESERVED && (CF_BLEND || CF_LIGHT)) { *pDst = u
16_to_le16(uSrc | srcMSB)
; }
+ else { *pDst = u
16_to_le16(uSrc)
; }
endsprite:
u0 += (CF_TEXTMODE==3) ? 2 : 1;
endsprite:
u0 += (CF_TEXTMODE==3) ? 2 : 1;
@@
-421,7
+427,7
@@
endsprite:
while (--count);
}
while (--count);
}
-static void SpriteNULL(
u16
*pDst, u32 count, u8* pTxt, u32 u0)
+static void SpriteNULL(
le16_t
*pDst, u32 count, u8* pTxt, u32 u0)
{
#ifdef ENABLE_GPU_LOG_SUPPORT
fprintf(stdout,"SpriteNULL()\n");
{
#ifdef ENABLE_GPU_LOG_SUPPORT
fprintf(stdout,"SpriteNULL()\n");
@@
-432,7
+438,7
@@
static void SpriteNULL(u16 *pDst, u32 count, u8* pTxt, u32 u0)
///////////////////////////////////////////////////////////////////////////////
// Sprite innerloops driver
///////////////////////////////////////////////////////////////////////////////
// Sprite innerloops driver
-typedef void (*PS)(
u16
*pDst, u32 count, u8* pTxt, u32 u0);
+typedef void (*PS)(
le16_t
*pDst, u32 count, u8* pTxt, u32 u0);
// Template instantiation helper macros
#define TI(cf) gpuSpriteSpanFn<(cf)>
// Template instantiation helper macros
#define TI(cf) gpuSpriteSpanFn<(cf)>
@@
-485,7
+491,7
@@
const PS gpuSpriteSpanDrivers[256] = {
// relevant blend/light headers.
// (see README_senquack.txt)
template<int CF>
// relevant blend/light headers.
// (see README_senquack.txt)
template<int CF>
-static void gpuPolySpanFn(const gpu_
senquack_t &gpu_senquack, u16
*pDst, u32 count)
+static void gpuPolySpanFn(const gpu_
unai_t &gpu_unai, le16_t
*pDst, u32 count)
{
// Blend func can save an operation if it knows uSrc MSB is unset.
// Untextured prims can always skip this (src color MSB is always 0).
{
// Blend func can save an operation if it knows uSrc MSB is unset.
// Untextured prims can always skip this (src color MSB is always 0).
@@
-493,14
+499,14
@@
static void gpuPolySpanFn(const gpu_senquack_t &gpu_senquack, u16 *pDst, u32 cou
const bool skip_uSrc_mask = MSB_PRESERVED ? (!CF_TEXTMODE) : (!CF_TEXTMODE) || CF_LIGHT;
bool should_blend;
const bool skip_uSrc_mask = MSB_PRESERVED ? (!CF_TEXTMODE) : (!CF_TEXTMODE) || CF_LIGHT;
bool should_blend;
- u32 bMsk; if (CF_BLITMASK) bMsk = gpu_
senquack
.blit_mask;
+ u32 bMsk; if (CF_BLITMASK) bMsk = gpu_
unai
.blit_mask;
if (!CF_TEXTMODE)
{
if (!CF_GOURAUD)
{
// UNTEXTURED, NO GOURAUD
if (!CF_TEXTMODE)
{
if (!CF_GOURAUD)
{
// UNTEXTURED, NO GOURAUD
- const u16 pix15 = gpu_
senquack
.PixelData;
+ const u16 pix15 = gpu_
unai
.PixelData;
do {
uint_fast16_t uSrc, uDst;
do {
uint_fast16_t uSrc, uDst;
@@
-509,7
+515,7
@@
static void gpuPolySpanFn(const gpu_senquack_t &gpu_senquack, u16 *pDst, u32 cou
// gravestone text at end of Medieval intro sequence. -senquack
//if (CF_BLITMASK) { if ((bMsk>>((((uintptr_t)pDst)>>1)&7))&1) { goto endpolynotextnogou; } }
// gravestone text at end of Medieval intro sequence. -senquack
//if (CF_BLITMASK) { if ((bMsk>>((((uintptr_t)pDst)>>1)&7))&1) { goto endpolynotextnogou; } }
- if (CF_BLEND || CF_MASKCHECK) uDst =
*pDst
;
+ if (CF_BLEND || CF_MASKCHECK) uDst =
le16_to_u16(*pDst)
;
if (CF_MASKCHECK) { if (uDst&0x8000) { goto endpolynotextnogou; } }
uSrc = pix15;
if (CF_MASKCHECK) { if (uDst&0x8000) { goto endpolynotextnogou; } }
uSrc = pix15;
@@
-517,8
+523,8
@@
static void gpuPolySpanFn(const gpu_senquack_t &gpu_senquack, u16 *pDst, u32 cou
if (CF_BLEND)
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
if (CF_BLEND)
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
- if (CF_MASKSET) { *pDst = u
Src | 0x8000
; }
- else { *pDst = u
Src
; }
+ if (CF_MASKSET) { *pDst = u
16_to_le16(uSrc | 0x8000)
; }
+ else { *pDst = u
16_to_le16(uSrc)
; }
endpolynotextnogou:
pDst++;
endpolynotextnogou:
pDst++;
@@
-527,8
+533,8
@@
endpolynotextnogou:
else
{
// UNTEXTURED, GOURAUD
else
{
// UNTEXTURED, GOURAUD
-
u32 l_gCol = gpu_senquack
.gCol;
-
u32 l_gInc = gpu_senquack
.gInc;
+
gcol_t l_gCol = gpu_unai
.gCol;
+
gcol_t l_gInc = gpu_unai
.gInc;
do {
uint_fast16_t uDst, uSrc;
do {
uint_fast16_t uDst, uSrc;
@@
-536,7
+542,7
@@
endpolynotextnogou:
// See note in above loop regarding CF_BLITMASK
//if (CF_BLITMASK) { if ((bMsk>>((((uintptr_t)pDst)>>1)&7))&1) goto endpolynotextgou; }
// See note in above loop regarding CF_BLITMASK
//if (CF_BLITMASK) { if ((bMsk>>((((uintptr_t)pDst)>>1)&7))&1) goto endpolynotextgou; }
- if (CF_BLEND || CF_MASKCHECK) uDst =
*pDst
;
+ if (CF_BLEND || CF_MASKCHECK) uDst =
le16_to_u16(*pDst)
;
if (CF_MASKCHECK) { if (uDst&0x8000) goto endpolynotextgou; }
if (CF_DITHER) {
if (CF_MASKCHECK) { if (uDst&0x8000) goto endpolynotextgou; }
if (CF_DITHER) {
@@
-555,12
+561,12
@@
endpolynotextnogou:
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
}
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
}
- if (CF_MASKSET) { *pDst = u
Src | 0x8000
; }
- else { *pDst = u
Src
; }
+ if (CF_MASKSET) { *pDst = u
16_to_le16(uSrc | 0x8000)
; }
+ else { *pDst = u
16_to_le16(uSrc)
; }
endpolynotextgou:
pDst++;
endpolynotextgou:
pDst++;
- l_gCol
+= l_gInc
;
+ l_gCol
.raw += l_gInc.raw
;
}
while (--count);
}
}
while (--count);
}
@@
-571,34
+577,34
@@
endpolynotextgou:
uint_fast16_t uDst, uSrc, srcMSB;
uint_fast16_t uDst, uSrc, srcMSB;
- //senquack - note: original UNAI code had gpu_
senquack
.{u4/v4} packed into
+ //senquack - note: original UNAI code had gpu_
unai
.{u4/v4} packed into
// one 32-bit unsigned int, but this proved to lose too much accuracy
// (pixel drouputs noticeable in NFS3 sky), so now are separate vars.
// one 32-bit unsigned int, but this proved to lose too much accuracy
// (pixel drouputs noticeable in NFS3 sky), so now are separate vars.
- u32 l_u_msk = gpu_
senquack.u_msk; u32 l_v_msk = gpu_senquack
.v_msk;
- u32 l_u = gpu_
senquack.u & l_u_msk; u32 l_v = gpu_senquack
.v & l_v_msk;
- s32 l_u_inc = gpu_
senquack.u_inc; s32 l_v_inc = gpu_senquack
.v_inc;
+ u32 l_u_msk = gpu_
unai.u_msk; u32 l_v_msk = gpu_unai
.v_msk;
+ u32 l_u = gpu_
unai.u & l_u_msk; u32 l_v = gpu_unai
.v & l_v_msk;
+ s32 l_u_inc = gpu_
unai.u_inc; s32 l_v_inc = gpu_unai
.v_inc;
- const
u16* TBA_ = gpu_senquack
.TBA;
- const
u16* CBA_; if (CF_TEXTMODE!=3) CBA_ = gpu_senquack
.CBA;
+ const
le16_t* TBA_ = gpu_unai
.TBA;
+ const
le16_t* CBA_; if (CF_TEXTMODE!=3) CBA_ = gpu_unai
.CBA;
u8 r5, g5, b5;
u8 r8, g8, b8;
u8 r5, g5, b5;
u8 r8, g8, b8;
-
u32
l_gInc, l_gCol;
+
gcol_t
l_gInc, l_gCol;
if (CF_LIGHT) {
if (CF_GOURAUD) {
if (CF_LIGHT) {
if (CF_GOURAUD) {
- l_gInc = gpu_
senquack
.gInc;
- l_gCol = gpu_
senquack
.gCol;
+ l_gInc = gpu_
unai
.gInc;
+ l_gCol = gpu_
unai
.gCol;
} else {
if (CF_DITHER) {
} else {
if (CF_DITHER) {
- r8 = gpu_
senquack
.r8;
- g8 = gpu_
senquack
.g8;
- b8 = gpu_
senquack
.b8;
+ r8 = gpu_
unai
.r8;
+ g8 = gpu_
unai
.g8;
+ b8 = gpu_
unai
.b8;
} else {
} else {
- r5 = gpu_
senquack
.r5;
- g5 = gpu_
senquack
.g5;
- b5 = gpu_
senquack
.b5;
+ r5 = gpu_
unai
.r5;
+ g5 = gpu_
unai
.g5;
+ b5 = gpu_
unai
.b5;
}
}
}
}
}
}
@@
-606,7
+612,7
@@
endpolynotextgou:
do
{
if (CF_BLITMASK) { if ((bMsk>>((((uintptr_t)pDst)>>1)&7))&1) goto endpolytext; }
do
{
if (CF_BLITMASK) { if ((bMsk>>((((uintptr_t)pDst)>>1)&7))&1) goto endpolytext; }
- if (CF_MASKCHECK || CF_BLEND) { uDst =
*pDst
; }
+ if (CF_MASKCHECK || CF_BLEND) { uDst =
le16_to_u16(*pDst)
; }
if (CF_MASKCHECK) if (uDst&0x8000) { goto endpolytext; }
//senquack - adapted to work with new 22.10 fixed point routines:
if (CF_MASKCHECK) if (uDst&0x8000) { goto endpolytext; }
//senquack - adapted to work with new 22.10 fixed point routines:
@@
-615,15
+621,15
@@
endpolynotextgou:
u32 tu=(l_u>>10);
u32 tv=(l_v<<1)&(0xff<<11);
u8 rgb=((u8*)TBA_)[tv+(tu>>1)];
u32 tu=(l_u>>10);
u32 tv=(l_v<<1)&(0xff<<11);
u8 rgb=((u8*)TBA_)[tv+(tu>>1)];
- uSrc=
CBA_[(rgb>>((tu&1)<<2))&0xf]
;
+ uSrc=
le16_to_u16(CBA_[(rgb>>((tu&1)<<2))&0xf])
;
if (!uSrc) goto endpolytext;
}
if (CF_TEXTMODE==2) { // 8bpp (CLUT)
if (!uSrc) goto endpolytext;
}
if (CF_TEXTMODE==2) { // 8bpp (CLUT)
- uSrc =
CBA_[(((u8*)TBA_)[(l_u>>10)+((l_v<<1)&(0xff<<11))])]
;
+ uSrc =
le16_to_u16(CBA_[(((u8*)TBA_)[(l_u>>10)+((l_v<<1)&(0xff<<11))])])
;
if (!uSrc) goto endpolytext;
}
if (CF_TEXTMODE==3) { // 16bpp
if (!uSrc) goto endpolytext;
}
if (CF_TEXTMODE==3) { // 16bpp
- uSrc =
TBA_[(l_u>>10)+((l_v)&(0xff<<10))]
;
+ uSrc =
le16_to_u16(TBA_[(l_u>>10)+((l_v)&(0xff<<10))])
;
if (!uSrc) goto endpolytext;
}
if (!uSrc) goto endpolytext;
}
@@
-661,20
+667,21
@@
endpolynotextgou:
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
}
uSrc = gpuBlending<CF_BLENDMODE, skip_uSrc_mask>(uSrc, uDst);
}
- if (CF_MASKSET) { *pDst = u
Src | 0x8000
; }
- else if (!MSB_PRESERVED && (CF_BLEND || CF_LIGHT)) { *pDst = u
Src | srcMSB
; }
- else { *pDst = u
Src
; }
+ if (CF_MASKSET) { *pDst = u
16_to_le16(uSrc | 0x8000)
; }
+ else if (!MSB_PRESERVED && (CF_BLEND || CF_LIGHT)) { *pDst = u
16_to_le16(uSrc | srcMSB)
; }
+ else { *pDst = u
16_to_le16(uSrc)
; }
endpolytext:
pDst++;
l_u = (l_u + l_u_inc) & l_u_msk;
l_v = (l_v + l_v_inc) & l_v_msk;
endpolytext:
pDst++;
l_u = (l_u + l_u_inc) & l_u_msk;
l_v = (l_v + l_v_inc) & l_v_msk;
- if (CF_LIGHT && CF_GOURAUD) l_gCol += l_gInc;
+ if (CF_LIGHT && CF_GOURAUD)
+ l_gCol.raw += l_gInc.raw;
}
while (--count);
}
}
}
while (--count);
}
}
-static void PolyNULL(const gpu_
senquack_t &gpu_senquack, u16
*pDst, u32 count)
+static void PolyNULL(const gpu_
unai_t &gpu_unai, le16_t
*pDst, u32 count)
{
#ifdef ENABLE_GPU_LOG_SUPPORT
fprintf(stdout,"PolyNULL()\n");
{
#ifdef ENABLE_GPU_LOG_SUPPORT
fprintf(stdout,"PolyNULL()\n");
@@
-683,7
+690,7
@@
static void PolyNULL(const gpu_senquack_t &gpu_senquack, u16 *pDst, u32 count)
///////////////////////////////////////////////////////////////////////////////
// Polygon innerloops driver
///////////////////////////////////////////////////////////////////////////////
// Polygon innerloops driver
-typedef void (*PP)(const gpu_
senquack_t &gpu_senquack, u16
*pDst, u32 count);
+typedef void (*PP)(const gpu_
unai_t &gpu_unai, le16_t
*pDst, u32 count);
// Template instantiation helper macros
#define TI(cf) gpuPolySpanFn<(cf)>
// Template instantiation helper macros
#define TI(cf) gpuPolySpanFn<(cf)>