summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author smf- <smf-@users.noreply.github.com>2018-09-12 16:30:06 +0100
committer smf- <smf-@users.noreply.github.com>2018-09-12 16:30:39 +0100
commitf4848d1da64b0bb87208128e08cab50d30341c0d (patch)
tree7a20b5095b6f2035091ef38843be988f6bb080b0
parent8aed8123a1efce4cc34ed62c9ce0371f2207d572 (diff)
PSX GPU Implement transparent dots & lines (which fixes MT 06528) & declare variables on first use. [smf]
-rw-r--r--src/devices/video/psx.cpp1354
1 files changed, 469 insertions, 885 deletions
diff --git a/src/devices/video/psx.cpp b/src/devices/video/psx.cpp
index 0b5ad06948a..464e2a1fd59 100644
--- a/src/devices/video/psx.cpp
+++ b/src/devices/video/psx.cpp
@@ -89,12 +89,12 @@ cxd8654q_device::cxd8654q_device(const machine_config &mconfig, const char *tag,
{
}
-static const uint16_t m_p_n_nextpointlist4[] = { 1, 3, 0, 2 };
-static const uint16_t m_p_n_prevpointlist4[] = { 2, 0, 3, 1 };
-static const uint16_t m_p_n_nextpointlist4b[] = { 0, 3, 1, 2 };
-static const uint16_t m_p_n_prevpointlist4b[] = { 0, 2, 3, 1 };
-static const uint16_t m_p_n_nextpointlist3[] = { 1, 2, 0 };
-static const uint16_t m_p_n_prevpointlist3[] = { 2, 0, 1 };
+static const int m_p_n_nextpointlist4[] = { 1, 3, 0, 2 };
+static const int m_p_n_prevpointlist4[] = { 2, 0, 3, 1 };
+static const int m_p_n_nextpointlist4b[] = { 0, 3, 1, 2 };
+static const int m_p_n_prevpointlist4b[] = { 0, 2, 3, 1 };
+static const int m_p_n_nextpointlist3[] = { 1, 2, 0 };
+static const int m_p_n_prevpointlist3[] = { 2, 0, 1 };
#define SINT11( x ) ( ( (int32_t)( x ) << 21 ) >> 21 )
@@ -140,8 +140,6 @@ void psxgpu_device::DebugMeshInit()
void psxgpu_device::DebugMesh( int n_coordx, int n_coordy )
{
- int n_coord;
- int n_colour;
int width = screen().width();
int height = screen().height();
@@ -154,7 +152,9 @@ void psxgpu_device::DebugMesh( int n_coordx, int n_coordy )
m_debug.b_clear = 0;
}
- n_colour = 0x1f;
+ int n_coord;
+ int n_colour = 0x1f;
+
for( n_coord = 0; n_coord < m_debug.n_coord; n_coord++ )
{
if( n_coordx != m_debug.n_coordx[ n_coord ] ||
@@ -163,26 +163,17 @@ void psxgpu_device::DebugMesh( int n_coordx, int n_coordy )
break;
}
}
+
if( n_coord == m_debug.n_coord && m_debug.n_coord > 1 )
{
n_colour = 0xffff;
}
+
for( n_coord = 0; n_coord < m_debug.n_coord; n_coord++ )
{
- PAIR n_x;
- PAIR n_y;
- int32_t n_xstart;
- int32_t n_ystart;
- int32_t n_xend;
- int32_t n_yend;
+ int32_t n_xstart = m_debug.n_coordx[ n_coord ];
+ int32_t n_xend = n_coordx;
int32_t n_xlen;
- int32_t n_ylen;
- int32_t n_len;
- int32_t n_dx;
- int32_t n_dy;
-
- n_xstart = m_debug.n_coordx[ n_coord ];
- n_xend = n_coordx;
if( n_xend > n_xstart )
{
n_xlen = n_xend - n_xstart;
@@ -192,8 +183,9 @@ void psxgpu_device::DebugMesh( int n_coordx, int n_coordy )
n_xlen = n_xstart - n_xend;
}
- n_ystart = m_debug.n_coordy[ n_coord ];
- n_yend = n_coordy;
+ int32_t n_ystart = m_debug.n_coordy[ n_coord ];
+ int32_t n_yend = n_coordy;
+ int32_t n_ylen;
if( n_yend > n_ystart )
{
n_ylen = n_yend - n_ystart;
@@ -203,6 +195,7 @@ void psxgpu_device::DebugMesh( int n_coordx, int n_coordy )
n_ylen = n_ystart - n_yend;
}
+ int32_t n_len;
if( n_xlen > n_ylen )
{
n_len = n_xlen;
@@ -212,16 +205,17 @@ void psxgpu_device::DebugMesh( int n_coordx, int n_coordy )
n_len = n_ylen;
}
- n_x.sw.h = n_xstart; n_x.sw.l = 0;
- n_y.sw.h = n_ystart; n_y.sw.l = 0;
+ PAIR n_x; n_x.sw.h = n_xstart; n_x.sw.l = 0;
+ PAIR n_y; n_y.sw.h = n_ystart; n_y.sw.l = 0;
if( n_len == 0 )
{
n_len = 1;
}
- n_dx = (int32_t)( ( n_xend << 16 ) - n_x.d ) / n_len;
- n_dy = (int32_t)( ( n_yend << 16 ) - n_y.d ) / n_len;
+ int32_t n_dx = (int32_t)( ( n_xend << 16 ) - n_x.d ) / n_len;
+ int32_t n_dy = (int32_t)( ( n_yend << 16 ) - n_y.d ) / n_len;
+
while( n_len > 0 )
{
if( (int16_t)n_x.w.h >= 0 &&
@@ -229,9 +223,10 @@ void psxgpu_device::DebugMesh( int n_coordx, int n_coordy )
(int16_t)n_x.w.h <= width - 1 &&
(int16_t)n_y.w.h <= height - 1 )
{
- if( m_debug.mesh->pix16(n_y.w.h, n_x.w.h) != 0xffff )
- m_debug.mesh->pix16(n_y.w.h, n_x.w.h) = n_colour;
+ if( m_debug.mesh->pix16( n_y.w.h, n_x.w.h ) != 0xffff )
+ m_debug.mesh->pix16( n_y.w.h, n_x.w.h ) = n_colour;
}
+
n_x.d += n_dx;
n_y.d += n_dy;
n_len--;
@@ -295,29 +290,27 @@ void psxgpu_device::DebugCheckKeys()
#if 0
if( machine().input().code_pressed_once( KEYCODE_D ) )
{
- FILE *f;
- int n_x;
- f = fopen( "dump.txt", "w" );
- for( n_y = 256; n_y < 512; n_y++ )
- for( n_x = 640; n_x < 1024; n_x++ )
+ FILE *f = fopen( "dump.txt", "w" );
+ for( int n_y = 256; n_y < 512; n_y++ )
+ for( int n_x = 640; n_x < 1024; n_x++ )
fprintf( f, "%04u,%04u = %04x\n", n_y, n_x, p_p_vram[ n_y ][ n_x ] );
fclose( f );
}
if( machine().input().code_pressed_once( KEYCODE_S ) )
{
- FILE *f;
popmessage( "saving..." );
- f = fopen( "VRAM.BIN", "wb" );
- for( n_y = 0; n_y < 1024; n_y++ )
+
+ FILE *f = fopen( "VRAM.BIN", "wb" );
+ for( int n_y = 0; n_y < 1024; n_y++ )
fwrite( p_p_vram[ n_y ], 1024 * 2, 1, f );
fclose( f );
}
if( machine().input().code_pressed_once( KEYCODE_L ) )
{
- FILE *f;
popmessage( "loading..." );
- f = fopen( "VRAM.BIN", "rb" );
- for( n_y = 0; n_y < 1024; n_y++ )
+
+ FILE *f = fopen( "VRAM.BIN", "rb" );
+ for( int n_y = 0; n_y < 1024; n_y++ )
fread( p_p_vram[ n_y ], 1024 * 2, 1, f );
fclose( f );
}
@@ -328,31 +321,30 @@ int psxgpu_device::DebugMeshDisplay( bitmap_rgb32 &bitmap, const rectangle &clip
{
if( m_debug.b_mesh )
{
- for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
- draw_scanline16( bitmap, cliprect.min_x, y, cliprect.max_x+1-cliprect.min_x, &m_debug.mesh->pix16(y), pens() );
+ for( int y = cliprect.min_y; y <= cliprect.max_y; y++ )
+ draw_scanline16( bitmap, cliprect.min_x, y, cliprect.max_x + 1 - cliprect.min_x, &m_debug.mesh->pix16( y ), pens() );
}
+
m_debug.b_clear = 1;
return m_debug.b_mesh;
}
int psxgpu_device::DebugTextureDisplay( bitmap_rgb32 &bitmap )
{
- uint32_t n_y;
-
if( m_debug.b_texture )
{
int width = screen().width();
int height = screen().height();
- for( n_y = 0; n_y < height; n_y++ )
+ for( int n_y = 0; n_y < height; n_y++ )
{
- int n_x;
- int n_xi;
- int n_yi;
uint16_t p_n_interleave[ 1024 ];
- for( n_x = 0; n_x < width; n_x++ )
+ for( int n_x = 0; n_x < width; n_x++ )
{
+ int n_xi;
+ int n_yi;
+
if( m_debug.n_interleave == 0 )
{
n_xi = ( n_x & ~0x3c ) + ( ( n_y << 2 ) & 0x3c );
@@ -368,11 +360,14 @@ int psxgpu_device::DebugTextureDisplay( bitmap_rgb32 &bitmap )
n_xi = n_x;
n_yi = n_y;
}
+
p_n_interleave[ n_x ] = p_p_vram[ n_yi ][ n_xi ];
}
+
draw_scanline16( bitmap, 0, n_y, width, p_n_interleave, pens() );
}
}
+
return m_debug.b_texture;
}
@@ -457,11 +452,6 @@ void psxgpu_device::updatevisiblearea()
void psxgpu_device::psx_gpu_init( int n_gputype )
{
- int n_line;
- int n_level;
- int n_level2;
- int n_shade;
- int n_shaded;
int width = 1024;
int height = ( vramSize / width ) / sizeof( uint16_t );
@@ -480,17 +470,17 @@ void psxgpu_device::psx_gpu_init( int n_gputype )
p_vram = make_unique_clear<uint16_t[]>(width * height );
- for( n_line = 0; n_line < 1024; n_line++ )
+ for( int n_line = 0; n_line < 1024; n_line++ )
{
p_p_vram[ n_line ] = &p_vram[ ( n_line % height ) * width ];
}
- for( n_level = 0; n_level < MAX_LEVEL; n_level++ )
+ for( int n_level = 0; n_level < MAX_LEVEL; n_level++ )
{
- for( n_shade = 0; n_shade < MAX_SHADE; n_shade++ )
+ for( int n_shade = 0; n_shade < MAX_SHADE; n_shade++ )
{
/* shaded */
- n_shaded = ( n_level * n_shade ) / MID_SHADE;
+ int n_shaded = ( n_level * n_shade ) / MID_SHADE;
if( n_shaded > MAX_LEVEL - 1 )
{
n_shaded = MAX_LEVEL - 1;
@@ -527,7 +517,7 @@ void psxgpu_device::psx_gpu_init( int n_gputype )
}
}
- for( n_level = 0; n_level < 0x10000; n_level++ )
+ for( int n_level = 0; n_level < 0x10000; n_level++ )
{
p_n_redlevel[ n_level ] = ( n_level & ( MAX_LEVEL - 1 ) ) * MAX_SHADE;
p_n_greenlevel[ n_level ] = ( ( n_level >> 5 ) & ( MAX_LEVEL - 1 ) ) * MAX_SHADE;
@@ -550,12 +540,12 @@ void psxgpu_device::psx_gpu_init( int n_gputype )
p_n_b1g1[ n_level ] = ( ( ( n_level >> 8 ) & 0xff ) << 0 ) | ( ( ( n_level >> 0 ) & 0xff ) << 8 );
}
- for( n_level = 0; n_level < MAX_LEVEL; n_level++ )
+ for( int n_level = 0; n_level < MAX_LEVEL; n_level++ )
{
- for( n_level2 = 0; n_level2 < MAX_LEVEL; n_level2++ )
+ for( int n_level2 = 0; n_level2 < MAX_LEVEL; n_level2++ )
{
/* add transparency */
- n_shaded = ( n_level + n_level2 );
+ int n_shaded = ( n_level + n_level2 );
if( n_shaded > MAX_LEVEL - 1 )
{
n_shaded = MAX_LEVEL - 1;
@@ -773,7 +763,7 @@ uint32_t psxgpu_device::update_screen(screen_device &screen, bitmap_rgb32 &bitma
return 0;
}
-#define WRITE_PIXEL( p ) *( p_vram ) = p
+#define WRITE_PIXEL( p ) *( p_vram ) = p;
/*
type 1
@@ -836,6 +826,7 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
}
#define SPRITESETUP \
+ int n_dv; \
if( n_iy != 0 ) \
{ \
n_dv = -1; \
@@ -844,6 +835,7 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
{ \
n_dv = 1; \
} \
+ int n_du; \
if( n_ix != 0 ) \
{ \
n_du = -1; \
@@ -854,13 +846,13 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
}
#define TRANSPARENCYSETUP \
- p_n_f = p_n_f1; \
- p_n_redb = p_n_redb1; \
- p_n_greenb = p_n_greenb1; \
- p_n_blueb = p_n_blueb1; \
- p_n_redtrans = p_n_redaddtrans; \
- p_n_greentrans = p_n_greenaddtrans; \
- p_n_bluetrans = p_n_blueaddtrans; \
+ uint16_t *p_n_f = p_n_f1; \
+ uint16_t *p_n_redb = p_n_redb1; \
+ uint16_t *p_n_greenb = p_n_greenb1; \
+ uint16_t *p_n_blueb = p_n_blueb1; \
+ uint16_t *p_n_redtrans = p_n_redaddtrans; \
+ uint16_t *p_n_greentrans = p_n_greenaddtrans; \
+ uint16_t *p_n_bluetrans = p_n_blueaddtrans; \
\
switch( n_cmd & 0x02 ) \
{ \
@@ -915,9 +907,9 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
TRANSPARENCYSETUP
#define TEXTURESETUP \
- n_tx = m_n_tx; \
- n_ty = m_n_ty; \
- p_clut = p_p_vram[ n_cluty ] + n_clutx; \
+ int n_tx = m_n_tx; \
+ int n_ty = m_n_ty; \
+ uint16_t *p_clut = p_p_vram[ n_cluty ] + n_clutx; \
switch( n_tp ) \
{ \
case 0: \
@@ -947,7 +939,7 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
{ \
n_distance = ( n_drawarea_x2 - drawx ) + 1; \
} \
- p_vram = p_p_vram[ drawy ] + drawx; \
+ uint16_t *p_vram = p_p_vram[ drawy ] + drawx; \
\
switch( n_cmd & 0x02 ) \
{ \
@@ -958,7 +950,7 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
WRITE_PIXEL( \
p_n_redshade[ MID_LEVEL | n_r.w.h ] | \
p_n_greenshade[ MID_LEVEL | n_g.w.h ] | \
- p_n_blueshade[ MID_LEVEL | n_b.w.h ] ); \
+ p_n_blueshade[ MID_LEVEL | n_b.w.h ] ) \
p_vram++; \
PIXELUPDATE \
n_distance--; \
@@ -971,7 +963,7 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
WRITE_PIXEL( \
p_n_redtrans[ p_n_f[ MID_LEVEL | n_r.w.h ] | p_n_redb[ *( p_vram ) ] ] | \
p_n_greentrans[ p_n_f[ MID_LEVEL | n_g.w.h ] | p_n_greenb[ *( p_vram ) ] ] | \
- p_n_bluetrans[ p_n_f[ MID_LEVEL | n_b.w.h ] | p_n_blueb[ *( p_vram ) ] ] ); \
+ p_n_bluetrans[ p_n_f[ MID_LEVEL | n_b.w.h ] | p_n_blueb[ *( p_vram ) ] ] ) \
p_vram++; \
PIXELUPDATE \
n_distance--; \
@@ -1001,15 +993,15 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
#define TEXTURE4BIT( TXV, TXU ) \
TEXTURE_LOOP \
- n_bgr = p_clut[ ( *( p_p_vram[ n_ty + TXV ] + n_tx + ( TXU >> 2 ) ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ];
+ uint16_t n_bgr = p_clut[ ( *( p_p_vram[ n_ty + TXV ] + n_tx + ( TXU >> 2 ) ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ];
#define TEXTURE8BIT( TXV, TXU ) \
TEXTURE_LOOP \
- n_bgr = p_clut[ ( *( p_p_vram[ n_ty + TXV ] + n_tx + ( TXU >> 1 ) ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff ];
+ uint16_t n_bgr = p_clut[ ( *( p_p_vram[ n_ty + TXV ] + n_tx + ( TXU >> 1 ) ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff ];
#define TEXTURE15BIT( TXV, TXU ) \
TEXTURE_LOOP \
- n_bgr = *( p_p_vram[ n_ty + TXV ] + n_tx + TXU );
+ uint16_t n_bgr = *( p_p_vram[ n_ty + TXV ] + n_tx + TXU );
#define TEXTUREWINDOW4BIT( TXV, TXU ) TEXTURE4BIT( ( TXV & n_twh ), ( TXU & n_tww ) )
#define TEXTUREWINDOW8BIT( TXV, TXU ) TEXTURE8BIT( ( TXV & n_twh ), ( TXU & n_tww ) )
@@ -1019,19 +1011,19 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
TEXTURE_LOOP \
int n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c ); \
int n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf ); \
- n_bgr = p_clut[ ( *( p_p_vram[ n_ty + n_yi ] + n_tx + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ];
+ uint16_t n_bgr = p_clut[ ( *( p_p_vram[ n_ty + n_yi ] + n_tx + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ];
#define TEXTUREINTERLEAVED8BIT( TXV, TXU ) \
TEXTURE_LOOP \
int n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 ); \
int n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 ); \
- n_bgr = p_clut[ ( *( p_p_vram[ n_ty + n_yi ] + n_tx + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff ];
+ uint16_t n_bgr = p_clut[ ( *( p_p_vram[ n_ty + n_yi ] + n_tx + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff ];
#define TEXTUREINTERLEAVED15BIT( TXV, TXU ) \
TEXTURE_LOOP \
int n_xi = TXU; \
int n_yi = TXV; \
- n_bgr = *( p_p_vram[ n_ty + n_yi ] + n_tx + n_xi );
+ uint16_t n_bgr = *( p_p_vram[ n_ty + n_yi ] + n_tx + n_xi );
#define TEXTUREWINDOWINTERLEAVED4BIT( TXV, TXU ) TEXTUREINTERLEAVED4BIT( ( TXV & n_twh ), ( TXU & n_tww ) )
#define TEXTUREWINDOWINTERLEAVED8BIT( TXV, TXU ) TEXTUREINTERLEAVED8BIT( ( TXV & n_twh ), ( TXU & n_tww ) )
@@ -1043,7 +1035,7 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
WRITE_PIXEL( \
p_n_redshade[ p_n_redlevel[ n_bgr ] | n_r.w.h ] | \
p_n_greenshade[ p_n_greenlevel[ n_bgr ] | n_g.w.h ] | \
- p_n_blueshade[ p_n_bluelevel[ n_bgr ] | n_b.w.h ] ); \
+ p_n_blueshade[ p_n_bluelevel[ n_bgr ] | n_b.w.h ] ) \
} \
p_vram++; \
PIXELUPDATE \
@@ -1058,14 +1050,14 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
WRITE_PIXEL( \
p_n_redtrans[ p_n_f[ p_n_redlevel[ n_bgr ] | n_r.w.h ] | p_n_redb[ *( p_vram ) ] ] | \
p_n_greentrans[ p_n_f[ p_n_greenlevel[ n_bgr ] | n_g.w.h ] | p_n_greenb[ *( p_vram ) ] ] | \
- p_n_bluetrans[ p_n_f[ p_n_bluelevel[ n_bgr ] | n_b.w.h ] | p_n_blueb[ *( p_vram ) ] ] ); \
+ p_n_bluetrans[ p_n_f[ p_n_bluelevel[ n_bgr ] | n_b.w.h ] | p_n_blueb[ *( p_vram ) ] ] ) \
} \
else \
{ \
WRITE_PIXEL( \
p_n_redshade[ p_n_redlevel[ n_bgr ] | n_r.w.h ] | \
p_n_greenshade[ p_n_greenlevel[ n_bgr ] | n_g.w.h ] | \
- p_n_blueshade[ p_n_bluelevel[ n_bgr ] | n_b.w.h ] ); \
+ p_n_blueshade[ p_n_bluelevel[ n_bgr ] | n_b.w.h ] ) \
} \
} \
p_vram++; \
@@ -1078,7 +1070,7 @@ void psxgpu_device::decode_tpage( uint32_t tpage )
{ \
n_distance = ( n_drawarea_x2 - drawx ) + 1; \
} \
- p_vram = p_p_vram[ drawy ] + drawx; \
+ uint16_t *p_vram = p_p_vram[ drawy ] + drawx; \
\
if( n_ti != 0 ) \
{ \
@@ -1317,12 +1309,14 @@ static inline int CullVertex( int a, int b )
)
#define FINDTOPLEFT( PacketType ) \
- for( n_point = 0; n_point < n_points; n_point++ ) \
+ for( int n_point = 0; n_point < n_points; n_point++ ) \
{ \
GET_COORD( m_packet.PacketType.vertex[ n_point ].n_coord ); \
} \
\
- n_leftpoint = 0; \
+ const int *p_n_rightpointlist; \
+ const int *p_n_leftpointlist; \
+ int n_leftpoint = 0; \
if( n_points == 4 ) \
{ \
if( CULLTRIANGLE( PacketType, 0 ) ) \
@@ -1358,7 +1352,7 @@ static inline int CullVertex( int a, int b )
p_n_leftpointlist = m_p_n_prevpointlist3; \
} \
\
- for( n_point = n_leftpoint + 1; n_point < n_points; n_point++ ) \
+ for( int n_point = n_leftpoint + 1; n_point < n_points; n_point++ ) \
{ \
if( COORD_Y( m_packet.PacketType.vertex[ n_point ].n_coord ) < COORD_Y( m_packet.PacketType.vertex[ n_leftpoint ].n_coord ) || \
( COORD_Y( m_packet.PacketType.vertex[ n_point ].n_coord ) == COORD_Y( m_packet.PacketType.vertex[ n_leftpoint ].n_coord ) && \
@@ -1367,70 +1361,39 @@ static inline int CullVertex( int a, int b )
n_leftpoint = n_point; \
} \
} \
- n_rightpoint = n_leftpoint;
+ int n_rightpoint = n_leftpoint;
void psxgpu_device::FlatPolygon( int n_points )
{
- int16_t n_y;
- int16_t n_x;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
-
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
- PAIR n_cx1;
- PAIR n_cx2;
- int32_t n_dx1;
- int32_t n_dx2;
-
- uint8_t n_cmd;
-
- int32_t n_distance;
-
- uint16_t n_point;
- uint16_t n_rightpoint;
- uint16_t n_leftpoint;
- const uint16_t *p_n_rightpointlist;
- const uint16_t *p_n_leftpointlist;
-
- uint16_t *p_vram;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 1 )
{
return;
}
- for( n_point = 0; n_point < n_points; n_point++ )
+ for( int n_point = 0; n_point < n_points; n_point++ )
{
DebugMesh( SINT11( COORD_X( m_packet.FlatPolygon.vertex[ n_point ].n_coord ) ) + n_drawoffset_x, SINT11( COORD_Y( m_packet.FlatPolygon.vertex[ n_point ].n_coord ) ) + n_drawoffset_y );
}
DebugMeshEnd();
#endif
- n_cmd = BGR_C( m_packet.FlatPolygon.n_bgr );
+ uint8_t n_cmd = BGR_C( m_packet.FlatPolygon.n_bgr );
- n_cx1.d = 0;
- n_cx2.d = 0;
+ PAIR n_cx1; n_cx1.d = 0;
+ PAIR n_cx2; n_cx2.d = 0;
SOLIDSETUP
- n_r.w.h = BGR_R( m_packet.FlatPolygon.n_bgr ); n_r.w.l = 0;
- n_g.w.h = BGR_G( m_packet.FlatPolygon.n_bgr ); n_g.w.l = 0;
- n_b.w.h = BGR_B( m_packet.FlatPolygon.n_bgr ); n_b.w.l = 0;
+ PAIR n_r; n_r.w.h = BGR_R( m_packet.FlatPolygon.n_bgr ); n_r.w.l = 0;
+ PAIR n_g; n_g.w.h = BGR_G( m_packet.FlatPolygon.n_bgr ); n_g.w.l = 0;
+ PAIR n_b; n_b.w.h = BGR_B( m_packet.FlatPolygon.n_bgr ); n_b.w.l = 0;
FINDTOPLEFT( FlatPolygon )
- n_dx1 = 0;
- n_dx2 = 0;
+ int32_t n_dx1 = 0;
+ int32_t n_dx2 = 0;
- n_y = COORD_Y( m_packet.FlatPolygon.vertex[ n_rightpoint ].n_coord );
+ int16_t n_y = COORD_Y( m_packet.FlatPolygon.vertex[ n_rightpoint ].n_coord );
for( ;; )
{
@@ -1444,15 +1407,19 @@ void psxgpu_device::FlatPolygon( int n_points )
break;
}
}
+
n_cx1.sw.h = COORD_X( m_packet.FlatPolygon.vertex[ n_leftpoint ].n_coord ); n_cx1.sw.l = 0;
n_leftpoint = p_n_leftpointlist[ n_leftpoint ];
- n_distance = COORD_Y( m_packet.FlatPolygon.vertex[ n_leftpoint ].n_coord ) - n_y;
+
+ int32_t n_distance = COORD_Y( m_packet.FlatPolygon.vertex[ n_leftpoint ].n_coord ) - n_y;
if( n_distance < 1 )
{
break;
}
+
n_dx1 = (int32_t)( ( COORD_X( m_packet.FlatPolygon.vertex[ n_leftpoint ].n_coord ) << 16 ) - n_cx1.d ) / n_distance;
}
+
if( n_y == COORD_Y( m_packet.FlatPolygon.vertex[ n_rightpoint ].n_coord ) )
{
while( n_y == COORD_Y( m_packet.FlatPolygon.vertex[ p_n_rightpointlist[ n_rightpoint ] ].n_coord ) )
@@ -1463,13 +1430,16 @@ void psxgpu_device::FlatPolygon( int n_points )
break;
}
}
+
n_cx2.sw.h = COORD_X( m_packet.FlatPolygon.vertex[ n_rightpoint ].n_coord ); n_cx2.sw.l = 0;
n_rightpoint = p_n_rightpointlist[ n_rightpoint ];
- n_distance = COORD_Y( m_packet.FlatPolygon.vertex[ n_rightpoint ].n_coord ) - n_y;
+
+ int32_t n_distance = COORD_Y( m_packet.FlatPolygon.vertex[ n_rightpoint ].n_coord ) - n_y;
if( n_distance < 1 )
{
break;
}
+
n_dx2 = (int32_t)( ( COORD_X( m_packet.FlatPolygon.vertex[ n_rightpoint ].n_coord ) << 16 ) - n_cx2.d ) / n_distance;
}
@@ -1477,6 +1447,9 @@ void psxgpu_device::FlatPolygon( int n_points )
if( (int16_t)n_cx1.sw.h != (int16_t)n_cx2.sw.h && drawy >= (int32_t)n_drawarea_y1 && drawy <= (int32_t)n_drawarea_y2 )
{
+ int16_t n_x;
+ int32_t n_distance;
+
if( (int16_t)n_cx1.sw.h < (int16_t)n_cx2.sw.h )
{
n_x = n_cx1.sw.h;
@@ -1498,6 +1471,7 @@ void psxgpu_device::FlatPolygon( int n_points )
SOLIDFILL( FLATPOLYGONUPDATE )
}
+
n_cx1.d += n_dx1;
n_cx2.d += n_dx2;
n_y++;
@@ -1506,109 +1480,47 @@ void psxgpu_device::FlatPolygon( int n_points )
void psxgpu_device::FlatTexturedPolygon( int n_points )
{
- int16_t n_y;
- int16_t n_x;
- int n_tx;
- int n_ty;
-
- uint8_t n_cmd;
-
- uint32_t n_clutx;
- uint32_t n_cluty;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
-
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
- PAIR n_u;
- PAIR n_v;
-
- PAIR n_cx1;
- PAIR n_cx2;
- PAIR n_cu1;
- PAIR n_cv1;
- PAIR n_cu2;
- PAIR n_cv2;
- int32_t n_du;
- int32_t n_dv;
- int32_t n_dx1;
- int32_t n_dx2;
- int32_t n_du1;
- int32_t n_dv1;
- int32_t n_du2;
- int32_t n_dv2;
-
- int32_t n_distance;
- uint16_t n_point;
- uint16_t n_rightpoint;
- uint16_t n_leftpoint;
- const uint16_t *p_n_rightpointlist;
- const uint16_t *p_n_leftpointlist;
- uint16_t *p_clut;
- uint16_t *p_vram;
- uint32_t n_bgr;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 2 )
{
return;
}
- for( n_point = 0; n_point < n_points; n_point++ )
+ for( int n_point = 0; n_point < n_points; n_point++ )
{
DebugMesh( SINT11( COORD_X( m_packet.FlatTexturedPolygon.vertex[ n_point ].n_coord ) ) + n_drawoffset_x, SINT11( COORD_Y( m_packet.FlatTexturedPolygon.vertex[ n_point ].n_coord ) ) + n_drawoffset_y );
}
DebugMeshEnd();
#endif
- n_cmd = BGR_C( m_packet.FlatTexturedPolygon.n_bgr );
+ uint8_t n_cmd = BGR_C( m_packet.FlatTexturedPolygon.n_bgr );
- n_clutx = ( m_packet.FlatTexturedPolygon.vertex[ 0 ].n_texture.w.h & 0x3f ) << 4;
- n_cluty = ( m_packet.FlatTexturedPolygon.vertex[ 0 ].n_texture.w.h >> 6 ) & 0x3ff;
+ uint32_t n_clutx = ( m_packet.FlatTexturedPolygon.vertex[ 0 ].n_texture.w.h & 0x3f ) << 4;
+ uint32_t n_cluty = ( m_packet.FlatTexturedPolygon.vertex[ 0 ].n_texture.w.h >> 6 ) & 0x3ff;
- n_r.d = 0;
- n_g.d = 0;
- n_b.d = 0;
- n_cx1.d = 0;
- n_cu1.d = 0;
- n_cv1.d = 0;
- n_cx2.d = 0;
- n_cu2.d = 0;
- n_cv2.d = 0;
+ PAIR n_cx1; n_cx1.d = 0;
+ PAIR n_cu1; n_cu1.d = 0;
+ PAIR n_cv1; n_cv1.d = 0;
+ PAIR n_cx2; n_cx2.d = 0;
+ PAIR n_cu2; n_cu2.d = 0;
+ PAIR n_cv2; n_cv2.d = 0;
decode_tpage( m_packet.FlatTexturedPolygon.vertex[ 1 ].n_texture.w.h );
TEXTURESETUP
- switch( n_cmd & 0x01 )
- {
- case 0:
- n_r.w.h = BGR_R( m_packet.FlatTexturedPolygon.n_bgr ); n_r.w.l = 0;
- n_g.w.h = BGR_G( m_packet.FlatTexturedPolygon.n_bgr ); n_g.w.l = 0;
- n_b.w.h = BGR_B( m_packet.FlatTexturedPolygon.n_bgr ); n_b.w.l = 0;
- break;
- case 1:
- n_r.w.h = 0x80; n_r.w.l = 0;
- n_g.w.h = 0x80; n_g.w.l = 0;
- n_b.w.h = 0x80; n_b.w.l = 0;
- break;
- }
+ PAIR n_r; n_r.w.h = n_cmd & 0x01 ? 0x80 : BGR_R( m_packet.FlatTexturedPolygon.n_bgr ); n_r.w.l = 0;
+ PAIR n_g; n_g.w.h = n_cmd & 0x01 ? 0x80 : BGR_G( m_packet.FlatTexturedPolygon.n_bgr ); n_g.w.l = 0;
+ PAIR n_b; n_b.w.h = n_cmd & 0x01 ? 0x80 : BGR_B( m_packet.FlatTexturedPolygon.n_bgr ); n_b.w.l = 0;
FINDTOPLEFT( FlatTexturedPolygon )
- n_dx1 = 0;
- n_dx2 = 0;
- n_du1 = 0;
- n_du2 = 0;
- n_dv1 = 0;
- n_dv2 = 0;
+ int32_t n_dx1 = 0;
+ int32_t n_dx2 = 0;
+ int32_t n_du1 = 0;
+ int32_t n_du2 = 0;
+ int32_t n_dv1 = 0;
+ int32_t n_dv2 = 0;
- n_y = COORD_Y( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_coord );
+ int16_t n_y = COORD_Y( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_coord );
for( ;; )
{
@@ -1622,19 +1534,23 @@ void psxgpu_device::FlatTexturedPolygon( int n_points )
break;
}
}
+
n_cx1.sw.h = COORD_X( m_packet.FlatTexturedPolygon.vertex[ n_leftpoint ].n_coord ); n_cx1.sw.l = 0;
n_cu1.w.h = TEXTURE_U( m_packet.FlatTexturedPolygon.vertex[ n_leftpoint ].n_texture ); n_cu1.w.l = 0;
n_cv1.w.h = TEXTURE_V( m_packet.FlatTexturedPolygon.vertex[ n_leftpoint ].n_texture ); n_cv1.w.l = 0;
n_leftpoint = p_n_leftpointlist[ n_leftpoint ];
- n_distance = COORD_Y( m_packet.FlatTexturedPolygon.vertex[ n_leftpoint ].n_coord ) - n_y;
+
+ int32_t n_distance = COORD_Y( m_packet.FlatTexturedPolygon.vertex[ n_leftpoint ].n_coord ) - n_y;
if( n_distance < 1 )
{
break;
}
+
n_dx1 = (int32_t)( ( COORD_X( m_packet.FlatTexturedPolygon.vertex[ n_leftpoint ].n_coord ) << 16 ) - n_cx1.d ) / n_distance;
n_du1 = (int32_t)( ( TEXTURE_U( m_packet.FlatTexturedPolygon.vertex[ n_leftpoint ].n_texture ) << 16 ) - n_cu1.d ) / n_distance;
n_dv1 = (int32_t)( ( TEXTURE_V( m_packet.FlatTexturedPolygon.vertex[ n_leftpoint ].n_texture ) << 16 ) - n_cv1.d ) / n_distance;
}
+
if( n_y == COORD_Y( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_coord ) )
{
while( n_y == COORD_Y( m_packet.FlatTexturedPolygon.vertex[ p_n_rightpointlist[ n_rightpoint ] ].n_coord ) )
@@ -1645,15 +1561,18 @@ void psxgpu_device::FlatTexturedPolygon( int n_points )
break;
}
}
+
n_cx2.sw.h = COORD_X( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_coord ); n_cx2.sw.l = 0;
n_cu2.w.h = TEXTURE_U( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_texture ); n_cu2.w.l = 0;
n_cv2.w.h = TEXTURE_V( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_texture ); n_cv2.w.l = 0;
n_rightpoint = p_n_rightpointlist[ n_rightpoint ];
- n_distance = COORD_Y( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_coord ) - n_y;
+
+ int32_t n_distance = COORD_Y( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_coord ) - n_y;
if( n_distance < 1 )
{
break;
}
+
n_dx2 = (int32_t)( ( COORD_X( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_coord ) << 16 ) - n_cx2.d ) / n_distance;
n_du2 = (int32_t)( ( TEXTURE_U( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_texture ) << 16 ) - n_cu2.d ) / n_distance;
n_dv2 = (int32_t)( ( TEXTURE_V( m_packet.FlatTexturedPolygon.vertex[ n_rightpoint ].n_texture ) << 16 ) - n_cv2.d ) / n_distance;
@@ -1663,6 +1582,13 @@ void psxgpu_device::FlatTexturedPolygon( int n_points )
if( (int16_t)n_cx1.sw.h != (int16_t)n_cx2.sw.h && drawy >= (int32_t)n_drawarea_y1 && drawy <= (int32_t)n_drawarea_y2 )
{
+ int16_t n_x;
+ int32_t n_distance;
+ PAIR n_u;
+ PAIR n_v;
+ int32_t n_du;
+ int32_t n_dv;
+
if( (int16_t)n_cx1.sw.h < (int16_t)n_cx2.sw.h )
{
n_x = n_cx1.sw.h;
@@ -1696,6 +1622,7 @@ void psxgpu_device::FlatTexturedPolygon( int n_points )
TEXTUREFILL( FLATTEXTUREDPOLYGONUPDATE, n_u.w.h, n_v.w.h );
}
+
n_cx1.d += n_dx1;
n_cu1.d += n_du1;
n_cv1.d += n_dv1;
@@ -1708,89 +1635,43 @@ void psxgpu_device::FlatTexturedPolygon( int n_points )
void psxgpu_device::GouraudPolygon( int n_points )
{
- int16_t n_y;
- int16_t n_x;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
-
- uint8_t n_cmd;
-
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
- PAIR n_cx1;
- PAIR n_cx2;
- PAIR n_cr1;
- PAIR n_cg1;
- PAIR n_cb1;
- PAIR n_cr2;
- PAIR n_cg2;
- PAIR n_cb2;
- int32_t n_dr;
- int32_t n_dg;
- int32_t n_db;
- int32_t n_dx1;
- int32_t n_dx2;
- int32_t n_dr1;
- int32_t n_dg1;
- int32_t n_db1;
- int32_t n_dr2;
- int32_t n_dg2;
- int32_t n_db2;
-
- int32_t n_distance;
-
- uint16_t n_point;
- uint16_t n_rightpoint;
- uint16_t n_leftpoint;
- const uint16_t *p_n_rightpointlist;
- const uint16_t *p_n_leftpointlist;
-
- uint16_t *p_vram;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 3 )
{
return;
}
- for( n_point = 0; n_point < n_points; n_point++ )
+ for( int n_point = 0; n_point < n_points; n_point++ )
{
DebugMesh( SINT11( COORD_X( m_packet.GouraudPolygon.vertex[ n_point ].n_coord ) ) + n_drawoffset_x, SINT11( COORD_Y( m_packet.GouraudPolygon.vertex[ n_point ].n_coord ) ) + n_drawoffset_y );
}
DebugMeshEnd();
#endif
- n_cmd = BGR_C( m_packet.GouraudPolygon.vertex[ 0 ].n_bgr );
+ uint8_t n_cmd = BGR_C( m_packet.GouraudPolygon.vertex[ 0 ].n_bgr );
- n_cx1.d = 0;
- n_cr1.d = 0;
- n_cg1.d = 0;
- n_cb1.d = 0;
- n_cx2.d = 0;
- n_cr2.d = 0;
- n_cg2.d = 0;
- n_cb2.d = 0;
+ PAIR n_cx1; n_cx1.d = 0;
+ PAIR n_cr1; n_cr1.d = 0;
+ PAIR n_cg1; n_cg1.d = 0;
+ PAIR n_cb1; n_cb1.d = 0;
+ PAIR n_cx2; n_cx2.d = 0;
+ PAIR n_cr2; n_cr2.d = 0;
+ PAIR n_cg2; n_cg2.d = 0;
+ PAIR n_cb2; n_cb2.d = 0;
SOLIDSETUP
FINDTOPLEFT( GouraudPolygon )
- n_dx1 = 0;
- n_dx2 = 0;
- n_dr1 = 0;
- n_dr2 = 0;
- n_dg1 = 0;
- n_dg2 = 0;
- n_db1 = 0;
- n_db2 = 0;
+ int32_t n_dx1 = 0;
+ int32_t n_dx2 = 0;
+ int32_t n_dr1 = 0;
+ int32_t n_dr2 = 0;
+ int32_t n_dg1 = 0;
+ int32_t n_dg2 = 0;
+ int32_t n_db1 = 0;
+ int32_t n_db2 = 0;
- n_y = COORD_Y( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_coord );
+ int16_t n_y = COORD_Y( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_coord );
for( ;; )
{
@@ -1804,21 +1685,25 @@ void psxgpu_device::GouraudPolygon( int n_points )
break;
}
}
+
n_cx1.sw.h = COORD_X( m_packet.GouraudPolygon.vertex[ n_leftpoint ].n_coord ); n_cx1.sw.l = 0;
n_cr1.w.h = BGR_R( m_packet.GouraudPolygon.vertex[ n_leftpoint ].n_bgr ); n_cr1.w.l = 0;
n_cg1.w.h = BGR_G( m_packet.GouraudPolygon.vertex[ n_leftpoint ].n_bgr ); n_cg1.w.l = 0;
n_cb1.w.h = BGR_B( m_packet.GouraudPolygon.vertex[ n_leftpoint ].n_bgr ); n_cb1.w.l = 0;
n_leftpoint = p_n_leftpointlist[ n_leftpoint ];
- n_distance = COORD_Y( m_packet.GouraudPolygon.vertex[ n_leftpoint ].n_coord ) - n_y;
+
+ int32_t n_distance = COORD_Y( m_packet.GouraudPolygon.vertex[ n_leftpoint ].n_coord ) - n_y;
if( n_distance < 1 )
{
break;
}
+
n_dx1 = (int32_t)( ( COORD_X( m_packet.GouraudPolygon.vertex[ n_leftpoint ].n_coord ) << 16 ) - n_cx1.d ) / n_distance;
n_dr1 = (int32_t)( ( BGR_R( m_packet.GouraudPolygon.vertex[ n_leftpoint ].n_bgr ) << 16 ) - n_cr1.d ) / n_distance;
n_dg1 = (int32_t)( ( BGR_G( m_packet.GouraudPolygon.vertex[ n_leftpoint ].n_bgr ) << 16 ) - n_cg1.d ) / n_distance;
n_db1 = (int32_t)( ( BGR_B( m_packet.GouraudPolygon.vertex[ n_leftpoint ].n_bgr ) << 16 ) - n_cb1.d ) / n_distance;
}
+
if( n_y == COORD_Y( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_coord ) )
{
while( n_y == COORD_Y( m_packet.GouraudPolygon.vertex[ p_n_rightpointlist[ n_rightpoint ] ].n_coord ) )
@@ -1829,16 +1714,19 @@ void psxgpu_device::GouraudPolygon( int n_points )
break;
}
}
+
n_cx2.sw.h = COORD_X( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_coord ); n_cx2.sw.l = 0;
n_cr2.w.h = BGR_R( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_bgr ); n_cr2.w.l = 0;
n_cg2.w.h = BGR_G( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_bgr ); n_cg2.w.l = 0;
n_cb2.w.h = BGR_B( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_bgr ); n_cb2.w.l = 0;
n_rightpoint = p_n_rightpointlist[ n_rightpoint ];
- n_distance = COORD_Y( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_coord ) - n_y;
+
+ int32_t n_distance = COORD_Y( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_coord ) - n_y;
if( n_distance < 1 )
{
break;
}
+
n_dx2 = (int32_t)( ( COORD_X( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_coord ) << 16 ) - n_cx2.d ) / n_distance;
n_dr2 = (int32_t)( ( BGR_R( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_bgr ) << 16 ) - n_cr2.d ) / n_distance;
n_dg2 = (int32_t)( ( BGR_G( m_packet.GouraudPolygon.vertex[ n_rightpoint ].n_bgr ) << 16 ) - n_cg2.d ) / n_distance;
@@ -1849,6 +1737,15 @@ void psxgpu_device::GouraudPolygon( int n_points )
if( (int16_t)n_cx1.sw.h != (int16_t)n_cx2.sw.h && drawy >= (int32_t)n_drawarea_y1 && drawy <= (int32_t)n_drawarea_y2 )
{
+ int16_t n_x;
+ int32_t n_distance;
+ PAIR n_r;
+ PAIR n_g;
+ PAIR n_b;
+ int32_t n_dr;
+ int32_t n_dg;
+ int32_t n_db;
+
if( (int16_t)n_cx1.sw.h < (int16_t)n_cx2.sw.h )
{
n_x = n_cx1.sw.h;
@@ -1887,6 +1784,7 @@ void psxgpu_device::GouraudPolygon( int n_points )
SOLIDFILL( GOURAUDPOLYGONUPDATE )
}
+
n_cx1.d += n_dx1;
n_cr1.d += n_dr1;
n_cg1.d += n_dg1;
@@ -1901,119 +1799,55 @@ void psxgpu_device::GouraudPolygon( int n_points )
void psxgpu_device::GouraudTexturedPolygon( int n_points )
{
- int16_t n_y;
- int16_t n_x;
- int n_tx;
- int n_ty;
-
- uint8_t n_cmd;
-
- uint32_t n_clutx;
- uint32_t n_cluty;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
-
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
- PAIR n_u;
- PAIR n_v;
-
- PAIR n_cx1;
- PAIR n_cx2;
- PAIR n_cu1;
- PAIR n_cv1;
- PAIR n_cu2;
- PAIR n_cv2;
- PAIR n_cr1;
- PAIR n_cg1;
- PAIR n_cb1;
- PAIR n_cr2;
- PAIR n_cg2;
- PAIR n_cb2;
- int32_t n_dr;
- int32_t n_dg;
- int32_t n_db;
- int32_t n_du;
- int32_t n_dv;
- int32_t n_dx1;
- int32_t n_dx2;
- int32_t n_dr1;
- int32_t n_dg1;
- int32_t n_db1;
- int32_t n_dr2;
- int32_t n_dg2;
- int32_t n_db2;
- int32_t n_du1;
- int32_t n_dv1;
- int32_t n_du2;
- int32_t n_dv2;
-
- int32_t n_distance;
- uint16_t n_point;
- uint16_t n_rightpoint;
- uint16_t n_leftpoint;
- const uint16_t *p_n_rightpointlist;
- const uint16_t *p_n_leftpointlist;
- uint16_t *p_clut;
- uint16_t *p_vram;
- uint32_t n_bgr;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 4 )
{
return;
}
- for( n_point = 0; n_point < n_points; n_point++ )
+ for( int n_point = 0; n_point < n_points; n_point++ )
{
DebugMesh( SINT11( COORD_X( m_packet.GouraudTexturedPolygon.vertex[ n_point ].n_coord ) ) + n_drawoffset_x, SINT11( COORD_Y( m_packet.GouraudTexturedPolygon.vertex[ n_point ].n_coord ) ) + n_drawoffset_y );
}
DebugMeshEnd();
#endif
- n_cmd = BGR_C( m_packet.GouraudTexturedPolygon.vertex[ 0 ].n_bgr );
+ uint8_t n_cmd = BGR_C( m_packet.GouraudTexturedPolygon.vertex[ 0 ].n_bgr );
- n_clutx = ( m_packet.GouraudTexturedPolygon.vertex[ 0 ].n_texture.w.h & 0x3f ) << 4;
- n_cluty = ( m_packet.GouraudTexturedPolygon.vertex[ 0 ].n_texture.w.h >> 6 ) & 0x3ff;
+ uint32_t n_clutx = ( m_packet.GouraudTexturedPolygon.vertex[ 0 ].n_texture.w.h & 0x3f ) << 4;
+ uint32_t n_cluty = ( m_packet.GouraudTexturedPolygon.vertex[ 0 ].n_texture.w.h >> 6 ) & 0x3ff;
- n_cx1.d = 0;
- n_cr1.d = 0;
- n_cg1.d = 0;
- n_cb1.d = 0;
- n_cu1.d = 0;
- n_cv1.d = 0;
- n_cx2.d = 0;
- n_cr2.d = 0;
- n_cg2.d = 0;
- n_cb2.d = 0;
- n_cu2.d = 0;
- n_cv2.d = 0;
+ PAIR n_cx1; n_cx1.d = 0;
+ PAIR n_cr1; n_cr1.d = 0;
+ PAIR n_cg1; n_cg1.d = 0;
+ PAIR n_cb1; n_cb1.d = 0;
+ PAIR n_cu1; n_cu1.d = 0;
+ PAIR n_cv1; n_cv1.d = 0;
+ PAIR n_cx2; n_cx2.d = 0;
+ PAIR n_cr2; n_cr2.d = 0;
+ PAIR n_cg2; n_cg2.d = 0;
+ PAIR n_cb2; n_cb2.d = 0;
+ PAIR n_cu2; n_cu2.d = 0;
+ PAIR n_cv2; n_cv2.d = 0;
decode_tpage( m_packet.GouraudTexturedPolygon.vertex[ 1 ].n_texture.w.h );
TEXTURESETUP
FINDTOPLEFT( GouraudTexturedPolygon )
- n_dx1 = 0;
- n_dx2 = 0;
- n_du1 = 0;
- n_du2 = 0;
- n_dr1 = 0;
- n_dr2 = 0;
- n_dg1 = 0;
- n_dg2 = 0;
- n_db1 = 0;
- n_db2 = 0;
- n_dv1 = 0;
- n_dv2 = 0;
-
- n_y = COORD_Y( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_coord );
+ int32_t n_dx1 = 0;
+ int32_t n_dx2 = 0;
+ int32_t n_du1 = 0;
+ int32_t n_du2 = 0;
+ int32_t n_dr1 = 0;
+ int32_t n_dr2 = 0;
+ int32_t n_dg1 = 0;
+ int32_t n_dg2 = 0;
+ int32_t n_db1 = 0;
+ int32_t n_db2 = 0;
+ int32_t n_dv1 = 0;
+ int32_t n_dv2 = 0;
+
+ int16_t n_y = COORD_Y( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_coord );
for( ;; )
{
@@ -2027,45 +1861,29 @@ void psxgpu_device::GouraudTexturedPolygon( int n_points )
break;
}
}
+
n_cx1.sw.h = COORD_X( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_coord ); n_cx1.sw.l = 0;
- switch( n_cmd & 0x01 )
- {
- case 0x00:
- n_cr1.w.h = BGR_R( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ); n_cr1.w.l = 0;
- n_cg1.w.h = BGR_G( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ); n_cg1.w.l = 0;
- n_cb1.w.h = BGR_B( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ); n_cb1.w.l = 0;
- break;
- case 0x01:
- n_cr1.w.h = 0x80; n_cr1.w.l = 0;
- n_cg1.w.h = 0x80; n_cg1.w.l = 0;
- n_cb1.w.h = 0x80; n_cb1.w.l = 0;
- break;
- }
+ n_cr1.w.h = n_cmd & 0x01 ? 0x80 : BGR_R( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ); n_cr1.w.l = 0;
+ n_cg1.w.h = n_cmd & 0x01 ? 0x80 : BGR_G( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ); n_cg1.w.l = 0;
+ n_cb1.w.h = n_cmd & 0x01 ? 0x80 : BGR_B( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ); n_cb1.w.l = 0;
n_cu1.w.h = TEXTURE_U( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_texture ); n_cu1.w.l = 0;
n_cv1.w.h = TEXTURE_V( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_texture ); n_cv1.w.l = 0;
n_leftpoint = p_n_leftpointlist[ n_leftpoint ];
- n_distance = COORD_Y( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_coord ) - n_y;
+
+ int32_t n_distance = COORD_Y( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_coord ) - n_y;
if( n_distance < 1 )
{
break;
}
+
n_dx1 = (int32_t)( ( COORD_X( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_coord ) << 16 ) - n_cx1.d ) / n_distance;
- switch( n_cmd & 0x01 )
- {
- case 0x00:
- n_dr1 = (int32_t)( ( BGR_R( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ) << 16 ) - n_cr1.d ) / n_distance;
- n_dg1 = (int32_t)( ( BGR_G( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ) << 16 ) - n_cg1.d ) / n_distance;
- n_db1 = (int32_t)( ( BGR_B( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ) << 16 ) - n_cb1.d ) / n_distance;
- break;
- case 0x01:
- n_dr1 = 0;
- n_dg1 = 0;
- n_db1 = 0;
- break;
- }
+ n_dr1 = n_cmd & 0x01 ? 0 : (int32_t)( ( BGR_R( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ) << 16 ) - n_cr1.d ) / n_distance;
+ n_dg1 = n_cmd & 0x01 ? 0 : (int32_t)( ( BGR_G( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ) << 16 ) - n_cg1.d ) / n_distance;
+ n_db1 = n_cmd & 0x01 ? 0 : (int32_t)( ( BGR_B( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_bgr ) << 16 ) - n_cb1.d ) / n_distance;
n_du1 = (int32_t)( ( TEXTURE_U( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_texture ) << 16 ) - n_cu1.d ) / n_distance;
n_dv1 = (int32_t)( ( TEXTURE_V( m_packet.GouraudTexturedPolygon.vertex[ n_leftpoint ].n_texture ) << 16 ) - n_cv1.d ) / n_distance;
}
+
if( n_y == COORD_Y( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_coord ) )
{
while( n_y == COORD_Y( m_packet.GouraudTexturedPolygon.vertex[ p_n_rightpointlist[ n_rightpoint ] ].n_coord ) )
@@ -2076,42 +1894,25 @@ void psxgpu_device::GouraudTexturedPolygon( int n_points )
break;
}
}
+
n_cx2.sw.h = COORD_X( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_coord ); n_cx2.sw.l = 0;
- switch( n_cmd & 0x01 )
- {
- case 0x00:
- n_cr2.w.h = BGR_R( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ); n_cr2.w.l = 0;
- n_cg2.w.h = BGR_G( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ); n_cg2.w.l = 0;
- n_cb2.w.h = BGR_B( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ); n_cb2.w.l = 0;
- break;
- case 0x01:
- n_cr2.w.h = 0x80; n_cr2.w.l = 0;
- n_cg2.w.h = 0x80; n_cg2.w.l = 0;
- n_cb2.w.h = 0x80; n_cb2.w.l = 0;
- break;
- }
+ n_cr2.w.h = n_cmd & 0x01 ? 0x80 : BGR_R( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ); n_cr2.w.l = 0;
+ n_cg2.w.h = n_cmd & 0x01 ? 0x80 : BGR_G( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ); n_cg2.w.l = 0;
+ n_cb2.w.h = n_cmd & 0x01 ? 0x80 : BGR_B( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ); n_cb2.w.l = 0;
n_cu2.w.h = TEXTURE_U( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_texture ); n_cu2.w.l = 0;
n_cv2.w.h = TEXTURE_V( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_texture ); n_cv2.w.l = 0;
n_rightpoint = p_n_rightpointlist[ n_rightpoint ];
- n_distance = COORD_Y( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_coord ) - n_y;
+
+ int32_t n_distance = COORD_Y( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_coord ) - n_y;
if( n_distance < 1 )
{
break;
}
+
n_dx2 = (int32_t)( ( COORD_X( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_coord ) << 16 ) - n_cx2.d ) / n_distance;
- switch( n_cmd & 0x01 )
- {
- case 0x00:
- n_dr2 = (int32_t)( ( BGR_R( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ) << 16 ) - n_cr2.d ) / n_distance;
- n_dg2 = (int32_t)( ( BGR_G( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ) << 16 ) - n_cg2.d ) / n_distance;
- n_db2 = (int32_t)( ( BGR_B( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ) << 16 ) - n_cb2.d ) / n_distance;
- break;
- case 0x01:
- n_dr2 = 0;
- n_dg2 = 0;
- n_db2 = 0;
- break;
- }
+ n_dr2 = n_cmd & 0x01 ? 0 : (int32_t)( ( BGR_R( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ) << 16 ) - n_cr2.d ) / n_distance;
+ n_dg2 = n_cmd & 0x01 ? 0 : (int32_t)( ( BGR_G( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ) << 16 ) - n_cg2.d ) / n_distance;
+ n_db2 = n_cmd & 0x01 ? 0 : (int32_t)( ( BGR_B( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_bgr ) << 16 ) - n_cb2.d ) / n_distance;
n_du2 = (int32_t)( ( TEXTURE_U( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_texture ) << 16 ) - n_cu2.d ) / n_distance;
n_dv2 = (int32_t)( ( TEXTURE_V( m_packet.GouraudTexturedPolygon.vertex[ n_rightpoint ].n_texture ) << 16 ) - n_cv2.d ) / n_distance;
}
@@ -2120,6 +1921,19 @@ void psxgpu_device::GouraudTexturedPolygon( int n_points )
if( (int16_t)n_cx1.sw.h != (int16_t)n_cx2.sw.h && drawy >= (int32_t)n_drawarea_y1 && drawy <= (int32_t)n_drawarea_y2 )
{
+ int16_t n_x;
+ int32_t n_distance;
+ PAIR n_r;
+ PAIR n_g;
+ PAIR n_b;
+ PAIR n_u;
+ PAIR n_v;
+ int32_t n_dr;
+ int32_t n_dg;
+ int32_t n_db;
+ int32_t n_du;
+ int32_t n_dv;
+
if( (int16_t)n_cx1.sw.h < (int16_t)n_cx2.sw.h )
{
n_x = n_cx1.sw.h;
@@ -2168,6 +1982,7 @@ void psxgpu_device::GouraudTexturedPolygon( int n_points )
TEXTUREFILL( GOURAUDTEXTUREDPOLYGONUPDATE, n_u.w.h, n_v.w.h );
}
+
n_cx1.d += n_dx1;
n_cr1.d += n_dr1;
n_cg1.d += n_dg1;
@@ -2186,22 +2001,6 @@ void psxgpu_device::GouraudTexturedPolygon( int n_points )
void psxgpu_device::MonochromeLine()
{
- PAIR n_x;
- PAIR n_y;
- int32_t n_dx;
- int32_t n_dy;
- int32_t n_len;
- int32_t n_xlen;
- int32_t n_ylen;
- int32_t n_xstart;
- int32_t n_ystart;
- int32_t n_xend;
- int32_t n_yend;
- uint32_t n_r;
- uint32_t n_g;
- uint32_t n_b;
- uint16_t *p_vram;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 5 )
{
@@ -2212,15 +2011,19 @@ void psxgpu_device::MonochromeLine()
DebugMeshEnd();
#endif
- n_xstart = SINT11( COORD_X( m_packet.MonochromeLine.vertex[ 0 ].n_coord ) );
- n_xend = SINT11( COORD_X( m_packet.MonochromeLine.vertex[ 1 ].n_coord ) );
- n_ystart = SINT11( COORD_Y( m_packet.MonochromeLine.vertex[ 0 ].n_coord ) );
- n_yend = SINT11( COORD_Y( m_packet.MonochromeLine.vertex[ 1 ].n_coord ) );
+ int32_t n_xstart = SINT11( COORD_X( m_packet.MonochromeLine.vertex[ 0 ].n_coord ) );
+ int32_t n_xend = SINT11( COORD_X( m_packet.MonochromeLine.vertex[ 1 ].n_coord ) );
+ int32_t n_ystart = SINT11( COORD_Y( m_packet.MonochromeLine.vertex[ 0 ].n_coord ) );
+ int32_t n_yend = SINT11( COORD_Y( m_packet.MonochromeLine.vertex[ 1 ].n_coord ) );
- n_r = BGR_R( m_packet.MonochromeLine.n_bgr );
- n_g = BGR_G( m_packet.MonochromeLine.n_bgr );
- n_b = BGR_B( m_packet.MonochromeLine.n_bgr );
+ uint8_t n_cmd = BGR_C( m_packet.MonochromeLine.n_bgr );
+ uint8_t n_r = BGR_R( m_packet.MonochromeLine.n_bgr );
+ uint8_t n_g = BGR_G( m_packet.MonochromeLine.n_bgr );
+ uint8_t n_b = BGR_B( m_packet.MonochromeLine.n_bgr );
+ TRANSPARENCYSETUP
+
+ int32_t n_xlen;
if( n_xend > n_xstart )
{
n_xlen = n_xend - n_xstart;
@@ -2230,6 +2033,7 @@ void psxgpu_device::MonochromeLine()
n_xlen = n_xstart - n_xend;
}
+ int32_t n_ylen;
if( n_yend > n_ystart )
{
n_ylen = n_yend - n_ystart;
@@ -2239,6 +2043,7 @@ void psxgpu_device::MonochromeLine()
n_ylen = n_ystart - n_yend;
}
+ int32_t n_len;
if( n_xlen > n_ylen )
{
n_len = n_xlen;
@@ -2253,11 +2058,11 @@ void psxgpu_device::MonochromeLine()
n_len = 1;
}
- n_x.sw.h = n_xstart; n_x.sw.l = 0;
- n_y.sw.h = n_ystart; n_y.sw.l = 0;
+ PAIR n_x; n_x.sw.h = n_xstart; n_x.sw.l = 0;
+ PAIR n_y; n_y.sw.h = n_ystart; n_y.sw.l = 0;
- n_dx = (int32_t)( ( n_xend << 16 ) - n_x.d ) / n_len;
- n_dy = (int32_t)( ( n_yend << 16 ) - n_y.d ) / n_len;
+ int32_t n_dx = (int32_t)( ( n_xend << 16 ) - n_x.d ) / n_len;
+ int32_t n_dy = (int32_t)( ( n_yend << 16 ) - n_y.d ) / n_len;
while( n_len > 0 )
{
@@ -2267,12 +2072,27 @@ void psxgpu_device::MonochromeLine()
if( drawx >= (int32_t)n_drawarea_x1 && drawy >= (int32_t)n_drawarea_y1 &&
drawx <= (int32_t)n_drawarea_x2 && drawy <= (int32_t)n_drawarea_y2 )
{
- p_vram = p_p_vram[ drawy ] + drawx;
- WRITE_PIXEL(
- p_n_redshade[ MID_LEVEL | n_r ] |
- p_n_greenshade[ MID_LEVEL | n_g ] |
- p_n_blueshade[ MID_LEVEL | n_b ] );
+ uint16_t *p_vram = p_p_vram[ drawy ] + drawx;
+
+ switch( n_cmd & 0x02 )
+ {
+ case 0x00:
+ /* transparency off */
+ WRITE_PIXEL(
+ p_n_redshade[ MID_LEVEL | n_r ] |
+ p_n_greenshade[ MID_LEVEL | n_g ] |
+ p_n_blueshade[ MID_LEVEL | n_b ] )
+ break;
+ case 0x02:
+ /* transparency on */
+ WRITE_PIXEL(
+ p_n_redtrans[ p_n_f[ MID_LEVEL | n_r ] | p_n_redb[ *( p_vram ) ] ] |
+ p_n_greentrans[ p_n_f[ MID_LEVEL | n_g ] | p_n_greenb[ *( p_vram ) ] ] |
+ p_n_bluetrans[ p_n_f[ MID_LEVEL | n_b ] | p_n_blueb[ *( p_vram ) ] ] )
+ break;
+ }
}
+
n_x.d += n_dx;
n_y.d += n_dy;
n_len--;
@@ -2281,31 +2101,6 @@ void psxgpu_device::MonochromeLine()
void psxgpu_device::GouraudLine()
{
- PAIR n_x;
- PAIR n_y;
- int32_t n_dx;
- int32_t n_dy;
- int32_t n_dr;
- int32_t n_dg;
- int32_t n_db;
- int32_t n_distance;
- int32_t n_xlen;
- int32_t n_ylen;
- int32_t n_xstart;
- int32_t n_ystart;
- int32_t n_xend;
- int32_t n_yend;
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
- PAIR n_cr1;
- PAIR n_cg1;
- PAIR n_cb1;
- PAIR n_cr2;
- PAIR n_cg2;
- PAIR n_cb2;
- uint16_t *p_vram;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 6 )
{
@@ -2316,24 +2111,30 @@ void psxgpu_device::GouraudLine()
DebugMeshEnd();
#endif
- n_xstart = SINT11( COORD_X( m_packet.GouraudLine.vertex[ 0 ].n_coord ) );
- n_ystart = SINT11( COORD_Y( m_packet.GouraudLine.vertex[ 0 ].n_coord ) );
- n_cr1.w.h = BGR_R( m_packet.GouraudLine.vertex[ 0 ].n_bgr ); n_cr1.w.l = 0;
- n_cg1.w.h = BGR_G( m_packet.GouraudLine.vertex[ 0 ].n_bgr ); n_cg1.w.l = 0;
- n_cb1.w.h = BGR_B( m_packet.GouraudLine.vertex[ 0 ].n_bgr ); n_cb1.w.l = 0;
+ uint8_t n_cmd = BGR_C( m_packet.GouraudLine.vertex[ 0 ].n_bgr );
+
+ TRANSPARENCYSETUP
+
+ int32_t n_xstart = SINT11( COORD_X( m_packet.GouraudLine.vertex[ 0 ].n_coord ) );
+ int32_t n_ystart = SINT11( COORD_Y( m_packet.GouraudLine.vertex[ 0 ].n_coord ) );
+ PAIR n_cr1; n_cr1.w.h = BGR_R( m_packet.GouraudLine.vertex[ 0 ].n_bgr ); n_cr1.w.l = 0;
+ PAIR n_cg1; n_cg1.w.h = BGR_G( m_packet.GouraudLine.vertex[ 0 ].n_bgr ); n_cg1.w.l = 0;
+ PAIR n_cb1; n_cb1.w.h = BGR_B( m_packet.GouraudLine.vertex[ 0 ].n_bgr ); n_cb1.w.l = 0;
- n_xend = SINT11( COORD_X( m_packet.GouraudLine.vertex[ 1 ].n_coord ) );
- n_yend = SINT11( COORD_Y( m_packet.GouraudLine.vertex[ 1 ].n_coord ) );
- n_cr2.w.h = BGR_R( m_packet.GouraudLine.vertex[ 1 ].n_bgr ); n_cr2.w.l = 0;
- n_cg2.w.h = BGR_G( m_packet.GouraudLine.vertex[ 1 ].n_bgr ); n_cg2.w.l = 0;
- n_cb2.w.h = BGR_B( m_packet.GouraudLine.vertex[ 1 ].n_bgr ); n_cb2.w.l = 0;
+ int32_t n_xend = SINT11( COORD_X( m_packet.GouraudLine.vertex[ 1 ].n_coord ) );
+ int32_t n_yend = SINT11( COORD_Y( m_packet.GouraudLine.vertex[ 1 ].n_coord ) );
+ PAIR n_cr2; n_cr2.w.h = BGR_R( m_packet.GouraudLine.vertex[ 1 ].n_bgr ); n_cr2.w.l = 0;
+ PAIR n_cg2; n_cg2.w.h = BGR_G( m_packet.GouraudLine.vertex[ 1 ].n_bgr ); n_cg2.w.l = 0;
+ PAIR n_cb2; n_cb2.w.h = BGR_B( m_packet.GouraudLine.vertex[ 1 ].n_bgr ); n_cb2.w.l = 0;
- n_x.sw.h = n_xstart; n_x.sw.l = 0;
- n_y.sw.h = n_ystart; n_y.sw.l = 0;
- n_r.d = n_cr1.d;
- n_g.d = n_cg1.d;
- n_b.d = n_cb1.d;
+ PAIR n_x; n_x.sw.h = n_xstart; n_x.sw.l = 0;
+ PAIR n_y; n_y.sw.h = n_ystart; n_y.sw.l = 0;
+ PAIR n_r; n_r.d = n_cr1.d;
+ PAIR n_g; n_g.d = n_cg1.d;
+ PAIR n_b; n_b.d = n_cb1.d;
+
+ int32_t n_xlen;
if( n_xend > n_xstart )
{
n_xlen = n_xend - n_xstart;
@@ -2343,6 +2144,7 @@ void psxgpu_device::GouraudLine()
n_xlen = n_xstart - n_xend;
}
+ int32_t n_ylen;
if( n_yend > n_ystart )
{
n_ylen = n_yend - n_ystart;
@@ -2352,6 +2154,7 @@ void psxgpu_device::GouraudLine()
n_ylen = n_ystart - n_yend;
}
+ int32_t n_distance;
if( n_xlen > n_ylen )
{
n_distance = n_xlen;
@@ -2366,11 +2169,11 @@ void psxgpu_device::GouraudLine()
n_distance = 1;
}
- n_dx = (int32_t)( ( n_xend << 16 ) - n_x.sd ) / n_distance;
- n_dy = (int32_t)( ( n_yend << 16 ) - n_y.sd ) / n_distance;
- n_dr = (int32_t)( n_cr2.d - n_cr1.d ) / n_distance;
- n_dg = (int32_t)( n_cg2.d - n_cg1.d ) / n_distance;
- n_db = (int32_t)( n_cb2.d - n_cb1.d ) / n_distance;
+ int32_t n_dx = (int32_t)( ( n_xend << 16 ) - n_x.sd ) / n_distance;
+ int32_t n_dy = (int32_t)( ( n_yend << 16 ) - n_y.sd ) / n_distance;
+ int32_t n_dr = (int32_t)( n_cr2.d - n_cr1.d ) / n_distance;
+ int32_t n_dg = (int32_t)( n_cg2.d - n_cg1.d ) / n_distance;
+ int32_t n_db = (int32_t)( n_cb2.d - n_cb1.d ) / n_distance;
while( n_distance > 0 )
{
@@ -2380,12 +2183,27 @@ void psxgpu_device::GouraudLine()
if( drawx >= (int32_t)n_drawarea_x1 && drawy >= (int32_t)n_drawarea_y1 &&
drawx <= (int32_t)n_drawarea_x2 && drawy <= (int32_t)n_drawarea_y2 )
{
- p_vram = p_p_vram[ drawy ] + drawx;
- WRITE_PIXEL(
- p_n_redshade[ MID_LEVEL | n_r.w.h ] |
- p_n_greenshade[ MID_LEVEL | n_g.w.h ] |
- p_n_blueshade[ MID_LEVEL | n_b.w.h ] );
+ uint16_t *p_vram = p_p_vram[ drawy ] + drawx;
+
+ switch( n_cmd & 0x02 )
+ {
+ case 0x00:
+ /* transparency off */
+ WRITE_PIXEL(
+ p_n_redshade[ MID_LEVEL | n_r.w.h ] |
+ p_n_greenshade[ MID_LEVEL | n_g.w.h ] |
+ p_n_blueshade[ MID_LEVEL | n_b.w.h ] )
+ break;
+ case 0x02:
+ /* transparency on */
+ WRITE_PIXEL(
+ p_n_redtrans[ p_n_f[ MID_LEVEL | n_r.w.h ] | p_n_redb[ *( p_vram ) ] ] |
+ p_n_greentrans[ p_n_f[ MID_LEVEL | n_g.w.h ] | p_n_greenb[ *( p_vram ) ] ] |
+ p_n_bluetrans[ p_n_f[ MID_LEVEL | n_b.w.h ] | p_n_blueb[ *( p_vram ) ] ] )
+ break;
+ }
}
+
n_x.sd += n_dx;
n_y.sd += n_dy;
n_r.d += n_dr;
@@ -2397,15 +2215,6 @@ void psxgpu_device::GouraudLine()
void psxgpu_device::FrameBufferRectangleDraw()
{
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
- int32_t n_distance;
- int32_t n_h;
- int16_t n_y;
- int16_t n_x;
- uint16_t *p_vram;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 7 )
{
@@ -2418,28 +2227,28 @@ void psxgpu_device::FrameBufferRectangleDraw()
DebugMeshEnd();
#endif
- n_r.w.h = BGR_R( m_packet.FlatRectangle.n_bgr ); n_r.w.l = 0;
- n_g.w.h = BGR_G( m_packet.FlatRectangle.n_bgr ); n_g.w.l = 0;
- n_b.w.h = BGR_B( m_packet.FlatRectangle.n_bgr ); n_b.w.l = 0;
+ PAIR n_r; n_r.w.h = BGR_R( m_packet.FlatRectangle.n_bgr ); n_r.w.l = 0;
+ PAIR n_g; n_g.w.h = BGR_G( m_packet.FlatRectangle.n_bgr ); n_g.w.l = 0;
+ PAIR n_b; n_b.w.h = BGR_B( m_packet.FlatRectangle.n_bgr ); n_b.w.l = 0;
- n_y = COORD_Y( m_packet.FlatRectangle.n_coord );
- n_h = SIZE_H( m_packet.FlatRectangle.n_size );
+ int16_t n_y = COORD_Y( m_packet.FlatRectangle.n_coord );
+ int32_t n_h = SIZE_H( m_packet.FlatRectangle.n_size );
while( n_h > 0 )
{
- n_x = COORD_X( m_packet.FlatRectangle.n_coord );
+ int16_t n_x = COORD_X( m_packet.FlatRectangle.n_coord );
+ int32_t n_distance = SIZE_W( m_packet.FlatRectangle.n_size );
- n_distance = SIZE_W( m_packet.FlatRectangle.n_size );
while( n_distance > 0 )
{
- p_vram = p_p_vram[ n_y & 1023 ] + ( n_x & 1023 );
- WRITE_PIXEL(
+ p_p_vram[ n_y & 1023 ][ n_x & 1023 ] =
p_n_redshade[ MID_LEVEL | n_r.w.h ] |
p_n_greenshade[ MID_LEVEL | n_g.w.h ] |
- p_n_blueshade[ MID_LEVEL | n_b.w.h ] );
+ p_n_blueshade[ MID_LEVEL | n_b.w.h ];
n_x++;
n_distance--;
}
+
n_y++;
n_h--;
}
@@ -2447,27 +2256,6 @@ void psxgpu_device::FrameBufferRectangleDraw()
void psxgpu_device::FlatRectangle()
{
- int16_t n_y;
- int16_t n_x;
-
- uint8_t n_cmd;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
-
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
-
- int32_t n_distance;
- int32_t n_h;
- uint16_t *p_vram;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 8 )
{
@@ -2480,22 +2268,21 @@ void psxgpu_device::FlatRectangle()
DebugMeshEnd();
#endif
- n_cmd = BGR_C( m_packet.FlatRectangle.n_bgr );
+ uint8_t n_cmd = BGR_C( m_packet.FlatRectangle.n_bgr );
SOLIDSETUP
- n_r.w.h = BGR_R( m_packet.FlatRectangle.n_bgr ); n_r.w.l = 0;
- n_g.w.h = BGR_G( m_packet.FlatRectangle.n_bgr ); n_g.w.l = 0;
- n_b.w.h = BGR_B( m_packet.FlatRectangle.n_bgr ); n_b.w.l = 0;
+ PAIR n_r; n_r.w.h = BGR_R( m_packet.FlatRectangle.n_bgr ); n_r.w.l = 0;
+ PAIR n_g; n_g.w.h = BGR_G( m_packet.FlatRectangle.n_bgr ); n_g.w.l = 0;
+ PAIR n_b; n_b.w.h = BGR_B( m_packet.FlatRectangle.n_bgr ); n_b.w.l = 0;
- n_x = SINT11( COORD_X( m_packet.FlatRectangle.n_coord ) );
- n_y = SINT11( COORD_Y( m_packet.FlatRectangle.n_coord ) );
- n_h = SIZE_H( m_packet.FlatRectangle.n_size );
+ int16_t n_x = SINT11( COORD_X( m_packet.FlatRectangle.n_coord ) );
+ int16_t n_y = SINT11( COORD_Y( m_packet.FlatRectangle.n_coord ) );
+ int32_t n_h = SIZE_H( m_packet.FlatRectangle.n_size );
while( n_h > 0 )
{
- n_distance = SIZE_W( m_packet.FlatRectangle.n_size );
-
+ int32_t n_distance = SIZE_W( m_packet.FlatRectangle.n_size );
int drawy = n_y + n_drawoffset_y;
if( n_distance > 0 && drawy >= (int32_t)n_drawarea_y1 && drawy <= (int32_t)n_drawarea_y2 )
@@ -2510,6 +2297,7 @@ void psxgpu_device::FlatRectangle()
SOLIDFILL( FLATRECTANGEUPDATE )
}
+
n_y++;
n_h--;
}
@@ -2517,27 +2305,6 @@ void psxgpu_device::FlatRectangle()
void psxgpu_device::FlatRectangle8x8()
{
- int16_t n_y;
- int16_t n_x;
-
- uint8_t n_cmd;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
-
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
-
- int32_t n_distance;
- int32_t n_h;
- uint16_t *p_vram;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 9 )
{
@@ -2550,22 +2317,21 @@ void psxgpu_device::FlatRectangle8x8()
DebugMeshEnd();
#endif
- n_cmd = BGR_C( m_packet.FlatRectangle8x8.n_bgr );
+ uint8_t n_cmd = BGR_C( m_packet.FlatRectangle8x8.n_bgr );
SOLIDSETUP
- n_r.w.h = BGR_R( m_packet.FlatRectangle8x8.n_bgr ); n_r.w.l = 0;
- n_g.w.h = BGR_G( m_packet.FlatRectangle8x8.n_bgr ); n_g.w.l = 0;
- n_b.w.h = BGR_B( m_packet.FlatRectangle8x8.n_bgr ); n_b.w.l = 0;
+ PAIR n_r; n_r.w.h = BGR_R( m_packet.FlatRectangle8x8.n_bgr ); n_r.w.l = 0;
+ PAIR n_g; n_g.w.h = BGR_G( m_packet.FlatRectangle8x8.n_bgr ); n_g.w.l = 0;
+ PAIR n_b; n_b.w.h = BGR_B( m_packet.FlatRectangle8x8.n_bgr ); n_b.w.l = 0;
- n_x = SINT11( COORD_X( m_packet.FlatRectangle8x8.n_coord ) );
- n_y = SINT11( COORD_Y( m_packet.FlatRectangle8x8.n_coord ) );
- n_h = 8;
+ int16_t n_x = SINT11( COORD_X( m_packet.FlatRectangle8x8.n_coord ) );
+ int16_t n_y = SINT11( COORD_Y( m_packet.FlatRectangle8x8.n_coord ) );
+ int32_t n_h = 8;
while( n_h > 0 )
{
- n_distance = 8;
-
+ int32_t n_distance = 8;
int drawy = n_y + n_drawoffset_y;
if( n_distance > 0 && drawy >= (int32_t)n_drawarea_y1 && drawy <= (int32_t)n_drawarea_y2 )
@@ -2580,6 +2346,7 @@ void psxgpu_device::FlatRectangle8x8()
SOLIDFILL( FLATRECTANGEUPDATE )
}
+
n_y++;
n_h--;
}
@@ -2587,27 +2354,6 @@ void psxgpu_device::FlatRectangle8x8()
void psxgpu_device::FlatRectangle16x16()
{
- int16_t n_y;
- int16_t n_x;
-
- uint8_t n_cmd;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
-
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
-
- int32_t n_distance;
- int32_t n_h;
- uint16_t *p_vram;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 10 )
{
@@ -2620,22 +2366,21 @@ void psxgpu_device::FlatRectangle16x16()
DebugMeshEnd();
#endif
- n_cmd = BGR_C( m_packet.FlatRectangle16x16.n_bgr );
+ uint8_t n_cmd = BGR_C( m_packet.FlatRectangle16x16.n_bgr );
SOLIDSETUP
- n_r.w.h = BGR_R( m_packet.FlatRectangle16x16.n_bgr ); n_r.w.l = 0;
- n_g.w.h = BGR_G( m_packet.FlatRectangle16x16.n_bgr ); n_g.w.l = 0;
- n_b.w.h = BGR_B( m_packet.FlatRectangle16x16.n_bgr ); n_b.w.l = 0;
+ PAIR n_r; n_r.w.h = BGR_R( m_packet.FlatRectangle16x16.n_bgr ); n_r.w.l = 0;
+ PAIR n_g; n_g.w.h = BGR_G( m_packet.FlatRectangle16x16.n_bgr ); n_g.w.l = 0;
+ PAIR n_b; n_b.w.h = BGR_B( m_packet.FlatRectangle16x16.n_bgr ); n_b.w.l = 0;
- n_x = SINT11( COORD_X( m_packet.FlatRectangle16x16.n_coord ) );
- n_y = SINT11( COORD_Y( m_packet.FlatRectangle16x16.n_coord ) );
- n_h = 16;
+ int16_t n_x = SINT11( COORD_X( m_packet.FlatRectangle16x16.n_coord ) );
+ int16_t n_y = SINT11( COORD_Y( m_packet.FlatRectangle16x16.n_coord ) );
+ int32_t n_h = 16;
while( n_h > 0 )
{
- n_distance = 16;
-
+ int32_t n_distance = 16;
int drawy = n_y + n_drawoffset_y;
if( n_distance > 0 && n_y >= (int32_t)n_drawarea_y1 && n_y <= (int32_t)n_drawarea_y2 )
@@ -2650,6 +2395,7 @@ void psxgpu_device::FlatRectangle16x16()
SOLIDFILL( FLATRECTANGEUPDATE )
}
+
n_y++;
n_h--;
}
@@ -2657,38 +2403,6 @@ void psxgpu_device::FlatRectangle16x16()
void psxgpu_device::FlatTexturedRectangle()
{
- int16_t n_y;
- int16_t n_x;
- int n_tx;
- int n_ty;
-
- uint8_t n_cmd;
-
- uint32_t n_clutx;
- uint32_t n_cluty;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
-
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
- uint8_t n_u;
- uint8_t n_v;
- int n_du;
- int n_dv;
-
- int16_t n_distance;
- uint32_t n_h;
- uint16_t *p_vram;
- uint16_t *p_clut;
- uint16_t n_bgr;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 11 )
{
@@ -2701,42 +2415,27 @@ void psxgpu_device::FlatTexturedRectangle()
DebugMeshEnd();
#endif
- n_cmd = BGR_C( m_packet.FlatTexturedRectangle.n_bgr );
+ uint8_t n_cmd = BGR_C( m_packet.FlatTexturedRectangle.n_bgr );
- n_clutx = ( m_packet.FlatTexturedRectangle.n_texture.w.h & 0x3f ) << 4;
- n_cluty = ( m_packet.FlatTexturedRectangle.n_texture.w.h >> 6 ) & 0x3ff;
-
- n_r.d = 0;
- n_g.d = 0;
- n_b.d = 0;
+ uint32_t n_clutx = ( m_packet.FlatTexturedRectangle.n_texture.w.h & 0x3f ) << 4;
+ uint32_t n_cluty = ( m_packet.FlatTexturedRectangle.n_texture.w.h >> 6 ) & 0x3ff;
TEXTURESETUP
SPRITESETUP
- switch( n_cmd & 0x01 )
- {
- case 0:
- n_r.w.h = BGR_R( m_packet.FlatTexturedRectangle.n_bgr ); n_r.w.l = 0;
- n_g.w.h = BGR_G( m_packet.FlatTexturedRectangle.n_bgr ); n_g.w.l = 0;
- n_b.w.h = BGR_B( m_packet.FlatTexturedRectangle.n_bgr ); n_b.w.l = 0;
- break;
- case 1:
- n_r.w.h = 0x80; n_r.w.l = 0;
- n_g.w.h = 0x80; n_g.w.l = 0;
- n_b.w.h = 0x80; n_b.w.l = 0;
- break;
- }
+ PAIR n_r; n_r.w.h = n_cmd & 0x01 ? 0x80 : BGR_R( m_packet.FlatTexturedRectangle.n_bgr ); n_r.w.l = 0;
+ PAIR n_g; n_g.w.h = n_cmd & 0x01 ? 0x80 : BGR_G( m_packet.FlatTexturedRectangle.n_bgr ); n_g.w.l = 0;
+ PAIR n_b; n_b.w.h = n_cmd & 0x01 ? 0x80 : BGR_B( m_packet.FlatTexturedRectangle.n_bgr ); n_b.w.l = 0;
- n_x = SINT11( COORD_X( m_packet.FlatTexturedRectangle.n_coord ) );
- n_y = SINT11( COORD_Y( m_packet.FlatTexturedRectangle.n_coord ) );
- n_v = TEXTURE_V( m_packet.FlatTexturedRectangle.n_texture );
- n_h = SIZE_H( m_packet.FlatTexturedRectangle.n_size );
+ int16_t n_x = SINT11( COORD_X( m_packet.FlatTexturedRectangle.n_coord ) );
+ int16_t n_y = SINT11( COORD_Y( m_packet.FlatTexturedRectangle.n_coord ) );
+ uint8_t n_v = TEXTURE_V( m_packet.FlatTexturedRectangle.n_texture );
+ uint32_t n_h = SIZE_H( m_packet.FlatTexturedRectangle.n_size );
while( n_h > 0 )
{
- n_u = TEXTURE_U( m_packet.FlatTexturedRectangle.n_texture );
- n_distance = SIZE_W( m_packet.FlatTexturedRectangle.n_size );
-
+ uint8_t n_u = TEXTURE_U( m_packet.FlatTexturedRectangle.n_texture );
+ int16_t n_distance = SIZE_W( m_packet.FlatTexturedRectangle.n_size );
int drawy = n_y + n_drawoffset_y;
if( n_distance > 0 && drawy >= (int32_t)n_drawarea_y1 && drawy <= (int32_t)n_drawarea_y2 )
@@ -2752,6 +2451,7 @@ void psxgpu_device::FlatTexturedRectangle()
TEXTUREFILL( FLATTEXTUREDRECTANGLEUPDATE, n_u, n_v );
}
+
n_v += n_dv;
n_y++;
n_h--;
@@ -2760,38 +2460,6 @@ void psxgpu_device::FlatTexturedRectangle()
void psxgpu_device::Sprite8x8()
{
- int16_t n_y;
- int16_t n_x;
- int n_tx;
- int n_ty;
-
- uint8_t n_cmd;
-
- uint32_t n_clutx;
- uint32_t n_cluty;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
-
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
- uint8_t n_u;
- uint8_t n_v;
- int n_du;
- int n_dv;
-
- int16_t n_distance;
- uint32_t n_h;
- uint16_t *p_vram;
- uint16_t *p_clut;
- uint16_t n_bgr;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 12 )
{
@@ -2804,41 +2472,27 @@ void psxgpu_device::Sprite8x8()
DebugMeshEnd();
#endif
- n_cmd = BGR_C( m_packet.Sprite8x8.n_bgr );
-
- n_clutx = ( m_packet.Sprite8x8.n_texture.w.h & 0x3f ) << 4;
- n_cluty = ( m_packet.Sprite8x8.n_texture.w.h >> 6 ) & 0x3ff;
+ uint8_t n_cmd = BGR_C( m_packet.Sprite8x8.n_bgr );
- n_r.d = 0;
- n_g.d = 0;
- n_b.d = 0;
+ uint32_t n_clutx = ( m_packet.Sprite8x8.n_texture.w.h & 0x3f ) << 4;
+ uint32_t n_cluty = ( m_packet.Sprite8x8.n_texture.w.h >> 6 ) & 0x3ff;
TEXTURESETUP
SPRITESETUP
- switch( n_cmd & 0x01 )
- {
- case 0:
- n_r.w.h = BGR_R( m_packet.Sprite8x8.n_bgr ); n_r.w.l = 0;
- n_g.w.h = BGR_G( m_packet.Sprite8x8.n_bgr ); n_g.w.l = 0;
- n_b.w.h = BGR_B( m_packet.Sprite8x8.n_bgr ); n_b.w.l = 0;
- break;
- case 1:
- n_r.w.h = 0x80; n_r.w.l = 0;
- n_g.w.h = 0x80; n_g.w.l = 0;
- n_b.w.h = 0x80; n_b.w.l = 0;
- break;
- }
+ PAIR n_r; n_r.w.h = n_cmd & 0x01 ? 0x80 : BGR_R( m_packet.Sprite8x8.n_bgr ); n_r.w.l = 0;
+ PAIR n_g; n_g.w.h = n_cmd & 0x01 ? 0x80 : BGR_G( m_packet.Sprite8x8.n_bgr ); n_g.w.l = 0;
+ PAIR n_b; n_b.w.h = n_cmd & 0x01 ? 0x80 : BGR_B( m_packet.Sprite8x8.n_bgr ); n_b.w.l = 0;
- n_x = SINT11( COORD_X( m_packet.Sprite8x8.n_coord ) );
- n_y = SINT11( COORD_Y( m_packet.Sprite8x8.n_coord ) );
- n_v = TEXTURE_V( m_packet.Sprite8x8.n_texture );
- n_h = 8;
+ int16_t n_x = SINT11( COORD_X( m_packet.Sprite8x8.n_coord ) );
+ int16_t n_y = SINT11( COORD_Y( m_packet.Sprite8x8.n_coord ) );
+ uint8_t n_v = TEXTURE_V( m_packet.Sprite8x8.n_texture );
+ uint32_t n_h = 8;
while( n_h > 0 )
{
- n_u = TEXTURE_U( m_packet.Sprite8x8.n_texture );
- n_distance = 8;
+ uint8_t n_u = TEXTURE_U( m_packet.Sprite8x8.n_texture );
+ int16_t n_distance = 8;
int drawy = n_y + n_drawoffset_y;
@@ -2855,6 +2509,7 @@ void psxgpu_device::Sprite8x8()
TEXTUREFILL( FLATTEXTUREDRECTANGLEUPDATE, n_u, n_v );
}
+
n_v += n_dv;
n_y++;
n_h--;
@@ -2863,38 +2518,6 @@ void psxgpu_device::Sprite8x8()
void psxgpu_device::Sprite16x16()
{
- int16_t n_y;
- int16_t n_x;
- int n_tx;
- int n_ty;
-
- uint8_t n_cmd;
-
- uint32_t n_clutx;
- uint32_t n_cluty;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
-
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
- uint8_t n_u;
- uint8_t n_v;
- int n_du;
- int n_dv;
-
- int16_t n_distance;
- uint32_t n_h;
- uint16_t *p_vram;
- uint16_t *p_clut;
- uint16_t n_bgr;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 13 )
{
@@ -2907,41 +2530,27 @@ void psxgpu_device::Sprite16x16()
DebugMeshEnd();
#endif
- n_cmd = BGR_C( m_packet.Sprite16x16.n_bgr );
-
- n_clutx = ( m_packet.Sprite16x16.n_texture.w.h & 0x3f ) << 4;
- n_cluty = ( m_packet.Sprite16x16.n_texture.w.h >> 6 ) & 0x3ff;
+ uint8_t n_cmd = BGR_C( m_packet.Sprite16x16.n_bgr );
- n_r.d = 0;
- n_g.d = 0;
- n_b.d = 0;
+ uint32_t n_clutx = ( m_packet.Sprite16x16.n_texture.w.h & 0x3f ) << 4;
+ uint32_t n_cluty = ( m_packet.Sprite16x16.n_texture.w.h >> 6 ) & 0x3ff;
TEXTURESETUP
SPRITESETUP
- switch( n_cmd & 0x01 )
- {
- case 0:
- n_r.w.h = BGR_R( m_packet.Sprite16x16.n_bgr ); n_r.w.l = 0;
- n_g.w.h = BGR_G( m_packet.Sprite16x16.n_bgr ); n_g.w.l = 0;
- n_b.w.h = BGR_B( m_packet.Sprite16x16.n_bgr ); n_b.w.l = 0;
- break;
- case 1:
- n_r.w.h = 0x80; n_r.w.l = 0;
- n_g.w.h = 0x80; n_g.w.l = 0;
- n_b.w.h = 0x80; n_b.w.l = 0;
- break;
- }
+ PAIR n_r; n_r.w.h = n_cmd & 0x01 ? 0x80 : BGR_R( m_packet.Sprite16x16.n_bgr ); n_r.w.l = 0;
+ PAIR n_g; n_g.w.h = n_cmd & 0x01 ? 0x80 : BGR_G( m_packet.Sprite16x16.n_bgr ); n_g.w.l = 0;
+ PAIR n_b; n_b.w.h = n_cmd & 0x01 ? 0x80 : BGR_B( m_packet.Sprite16x16.n_bgr ); n_b.w.l = 0;
- n_x = SINT11( COORD_X( m_packet.Sprite16x16.n_coord ) );
- n_y = SINT11( COORD_Y( m_packet.Sprite16x16.n_coord ) );
- n_v = TEXTURE_V( m_packet.Sprite16x16.n_texture );
- n_h = 16;
+ int16_t n_x = SINT11( COORD_X( m_packet.Sprite16x16.n_coord ) );
+ int16_t n_y = SINT11( COORD_Y( m_packet.Sprite16x16.n_coord ) );
+ uint8_t n_v = TEXTURE_V( m_packet.Sprite16x16.n_texture );
+ uint32_t n_h = 16;
while( n_h > 0 )
{
- n_u = TEXTURE_U( m_packet.Sprite16x16.n_texture );
- n_distance = 16;
+ uint8_t n_u = TEXTURE_U( m_packet.Sprite16x16.n_texture );
+ int16_t n_distance = 16;
int drawy = n_y + n_drawoffset_y;
@@ -2958,6 +2567,7 @@ void psxgpu_device::Sprite16x16()
TEXTUREFILL( FLATTEXTUREDRECTANGLEUPDATE, n_u, n_v );
}
+
n_v += n_dv;
n_y++;
n_h--;
@@ -2966,13 +2576,6 @@ void psxgpu_device::Sprite16x16()
void psxgpu_device::Dot()
{
- int32_t n_x;
- int32_t n_y;
- uint32_t n_r;
- uint32_t n_g;
- uint32_t n_b;
- uint16_t *p_vram;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 14 )
{
@@ -2982,11 +2585,14 @@ void psxgpu_device::Dot()
DebugMeshEnd();
#endif
- n_r = BGR_R( m_packet.Dot.n_bgr );
- n_g = BGR_G( m_packet.Dot.n_bgr );
- n_b = BGR_B( m_packet.Dot.n_bgr );
- n_x = SINT11( COORD_X( m_packet.Dot.vertex.n_coord ) );
- n_y = SINT11( COORD_Y( m_packet.Dot.vertex.n_coord ) );
+ uint8_t n_cmd = BGR_C( m_packet.Dot.n_bgr );
+ uint8_t n_r = BGR_R( m_packet.Dot.n_bgr );
+ uint8_t n_g = BGR_G( m_packet.Dot.n_bgr );
+ uint8_t n_b = BGR_B( m_packet.Dot.n_bgr );
+ int32_t n_x = SINT11( COORD_X( m_packet.Dot.vertex.n_coord ) );
+ int32_t n_y = SINT11( COORD_Y( m_packet.Dot.vertex.n_coord ) );
+
+ TRANSPARENCYSETUP
int drawx = n_x + n_drawoffset_x;
int drawy = n_y + n_drawoffset_y;
@@ -2994,11 +2600,25 @@ void psxgpu_device::Dot()
if( drawx >= (int32_t)n_drawarea_x1 && drawy >= (int32_t)n_drawarea_y1 &&
drawx <= (int32_t)n_drawarea_x2 && drawy <= (int32_t)n_drawarea_y2 )
{
- p_vram = p_p_vram[ drawy ] + drawx;
- WRITE_PIXEL(
- p_n_redshade[ MID_LEVEL | n_r ] |
- p_n_greenshade[ MID_LEVEL | n_g ] |
- p_n_blueshade[ MID_LEVEL | n_b ] );
+ uint16_t *p_vram = p_p_vram[ drawy ] + drawx;
+
+ switch( n_cmd & 0x02 )
+ {
+ case 0x00:
+ /* transparency off */
+ WRITE_PIXEL(
+ p_n_redshade[ MID_LEVEL | n_r ] |
+ p_n_greenshade[ MID_LEVEL | n_g ] |
+ p_n_blueshade[ MID_LEVEL | n_b ] )
+ break;
+ case 0x02:
+ /* transparency on */
+ WRITE_PIXEL(
+ p_n_redtrans[ p_n_f[ MID_LEVEL | n_r ] | p_n_redb[ *( p_vram ) ] ] |
+ p_n_greentrans[ p_n_f[ MID_LEVEL | n_g ] | p_n_greenb[ *( p_vram ) ] ] |
+ p_n_bluetrans[ p_n_f[ MID_LEVEL | n_b ] | p_n_blueb[ *( p_vram ) ] ] )
+ break;
+ }
}
}
@@ -3009,73 +2629,39 @@ void psxgpu_device::TexturedDot()
{
return;
}
- DebugMesh(SINT11(COORD_X(m_packet.TexturedDot.vertex.n_coord)) + n_drawoffset_x, SINT11(COORD_Y(m_packet.TexturedDot.vertex.n_coord)) + n_drawoffset_y);
+ DebugMesh( SINT11( COORD_X( m_packet.TexturedDot.vertex.n_coord ) ) + n_drawoffset_x, SINT11( COORD_Y( m_packet.TexturedDot.vertex.n_coord ) ) + n_drawoffset_y );
DebugMeshEnd();
#endif
- uint8_t n_cmd = BGR_C(m_packet.TexturedDot.n_bgr);
+ uint8_t n_cmd = BGR_C( m_packet.TexturedDot.n_bgr );
- PAIR n_r;
- PAIR n_g;
- PAIR n_b;
-
- switch (n_cmd & 0x01)
- {
- case 0:
- n_r.w.h = BGR_R(m_packet.TexturedDot.n_bgr); n_r.w.l = 0;
- n_g.w.h = BGR_G(m_packet.TexturedDot.n_bgr); n_g.w.l = 0;
- n_b.w.h = BGR_B(m_packet.TexturedDot.n_bgr); n_b.w.l = 0;
- break;
- case 1:
- n_r.w.h = 0x80; n_r.w.l = 0;
- n_g.w.h = 0x80; n_g.w.l = 0;
- n_b.w.h = 0x80; n_b.w.l = 0;
- break;
- }
+ PAIR n_r; n_r.w.h = n_cmd & 0x01 ? 0x80 : BGR_R( m_packet.TexturedDot.n_bgr ); n_r.w.l = 0;
+ PAIR n_g; n_g.w.h = n_cmd & 0x01 ? 0x80 : BGR_G( m_packet.TexturedDot.n_bgr ); n_g.w.l = 0;
+ PAIR n_b; n_b.w.h = n_cmd & 0x01 ? 0x80 : BGR_B( m_packet.TexturedDot.n_bgr ); n_b.w.l = 0;
- int32_t n_x = SINT11(COORD_X(m_packet.TexturedDot.vertex.n_coord));
- int32_t n_y = SINT11(COORD_Y(m_packet.TexturedDot.vertex.n_coord));
- uint8_t n_u = TEXTURE_U(m_packet.TexturedDot.vertex.n_texture);
- uint8_t n_v = TEXTURE_V(m_packet.TexturedDot.vertex.n_texture);
- uint32_t n_clutx = (m_packet.TexturedDot.vertex.n_texture.w.h & 0x3f) << 4;
- uint32_t n_cluty = (m_packet.TexturedDot.vertex.n_texture.w.h >> 6) & 0x3ff;
-
- uint16_t *p_n_f;
- uint16_t *p_n_redb;
- uint16_t *p_n_greenb;
- uint16_t *p_n_blueb;
- uint16_t *p_n_redtrans;
- uint16_t *p_n_greentrans;
- uint16_t *p_n_bluetrans;
- int n_tx;
- int n_ty;
- uint32_t n_bgr;
- uint16_t *p_clut;
- int32_t n_distance = 1;
+ int32_t n_x = SINT11( COORD_X( m_packet.TexturedDot.vertex.n_coord ) );
+ int32_t n_y = SINT11( COORD_Y( m_packet.TexturedDot.vertex.n_coord ) );
+ uint8_t n_u = TEXTURE_U(m_packet.TexturedDot.vertex.n_texture );
+ uint8_t n_v = TEXTURE_V(m_packet.TexturedDot.vertex.n_texture );
+ uint32_t n_clutx = ( m_packet.TexturedDot.vertex.n_texture.w.h & 0x3f ) << 4;
+ uint32_t n_cluty = ( m_packet.TexturedDot.vertex.n_texture.w.h >> 6 ) & 0x3ff;
TEXTURESETUP
+ int32_t n_distance = 1;
+
int drawx = n_x + n_drawoffset_x;
int drawy = n_y + n_drawoffset_y;
- if (drawx >= (int32_t)n_drawarea_x1 && drawy >= (int32_t)n_drawarea_y1 &&
- drawx <= (int32_t)n_drawarea_x2 && drawy <= (int32_t)n_drawarea_y2)
+ if( drawx >= (int32_t)n_drawarea_x1 && drawy >= (int32_t)n_drawarea_y1 &&
+ drawx <= (int32_t)n_drawarea_x2 && drawy <= (int32_t)n_drawarea_y2 )
{
- uint16_t *p_vram = p_p_vram[drawy] + drawx;
- TEXTUREFILL({}, n_u, n_v);
+ TEXTUREFILL( {}, n_u, n_v );
}
}
void psxgpu_device::MoveImage()
{
- int16_t n_w;
- int16_t n_h;
- int16_t n_srcx;
- int16_t n_srcy;
- int16_t n_dsty;
- int16_t n_dstx;
- uint16_t *p_vram;
-
#if PSXGPU_DEBUG_VIEWER
if( m_debug.n_skip == 16 )
{
@@ -3088,23 +2674,25 @@ void psxgpu_device::MoveImage()
DebugMeshEnd();
#endif
- n_srcy = COORD_Y( m_packet.MoveImage.vertex[ 0 ].n_coord );
- n_dsty = COORD_Y( m_packet.MoveImage.vertex[ 1 ].n_coord );
- n_h = SIZE_H( m_packet.MoveImage.n_size );
+ int16_t n_srcy = COORD_Y( m_packet.MoveImage.vertex[ 0 ].n_coord );
+ int16_t n_dsty = COORD_Y( m_packet.MoveImage.vertex[ 1 ].n_coord );
+ int16_t n_h = SIZE_H( m_packet.MoveImage.n_size );
while( n_h > 0 )
{
- n_srcx = COORD_X( m_packet.MoveImage.vertex[ 0 ].n_coord );
- n_dstx = COORD_X( m_packet.MoveImage.vertex[ 1 ].n_coord );
- n_w = SIZE_W( m_packet.MoveImage.n_size );
+ int16_t n_srcx = COORD_X( m_packet.MoveImage.vertex[ 0 ].n_coord );
+ int16_t n_dstx = COORD_X( m_packet.MoveImage.vertex[ 1 ].n_coord );
+ int16_t n_w = SIZE_W( m_packet.MoveImage.n_size );
+
while( n_w > 0 )
{
- p_vram = p_p_vram[ n_dsty & 1023 ] + ( n_dstx & 1023 );
- WRITE_PIXEL( *( p_p_vram[ n_srcy & 1023 ] + ( n_srcx & 1023 ) ) );
+ uint16_t *p_vram = p_p_vram[ n_dsty & 1023 ] + ( n_dstx & 1023 );
+ WRITE_PIXEL( *( p_p_vram[ n_srcy & 1023 ] + ( n_srcx & 1023 ) ) )
n_srcx++;
n_dstx++;
n_w--;
}
+
n_srcy++;
n_dsty++;
n_h--;
@@ -3412,9 +3000,9 @@ void psxgpu_device::gpu_write( uint32_t *p_ram, int32_t n_size )
else
{
verboselog(*this, 1, "%02x: textured dot %d,%d %08x\n",
- m_packet.n_entry[0] >> 24,
- (int16_t)(m_packet.n_entry[1] & 0xffff), (int16_t)(m_packet.n_entry[1] >> 16),
- m_packet.n_entry[0] & 0xffffff);
+ m_packet.n_entry[ 0 ] >> 24,
+ (int16_t)( m_packet.n_entry[ 1 ] & 0xffff ), (int16_t)( m_packet.n_entry[ 1 ] >> 16 ),
+ m_packet.n_entry[ 0 ] & 0xffffff );
TexturedDot();
n_gpu_buffer_offset = 0;
}
@@ -3504,18 +3092,15 @@ void psxgpu_device::gpu_write( uint32_t *p_ram, int32_t n_size )
}
else
{
- uint32_t n_pixel;
- for( n_pixel = 0; n_pixel < 2; n_pixel++ )
+ for( int n_pixel = 0; n_pixel < 2; n_pixel++ )
{
- uint16_t *p_vram;
-
verboselog( *this, 2, "send image to framebuffer ( pixel %u,%u = %u )\n",
( n_vramx + m_packet.n_entry[ 1 ] ) & 1023,
( n_vramy + ( m_packet.n_entry[ 1 ] >> 16 ) ) & 1023,
data & 0xffff );
- p_vram = p_p_vram[ ( n_vramy + ( m_packet.n_entry[ 1 ] >> 16 ) ) & 1023 ] + ( ( n_vramx + m_packet.n_entry[ 1 ] ) & 1023 );
- WRITE_PIXEL( data & 0xffff );
+ uint16_t *p_vram = p_p_vram[ ( n_vramy + ( m_packet.n_entry[ 1 ] >> 16 ) ) & 1023 ] + ( ( n_vramx + m_packet.n_entry[ 1 ] ) & 1023 );
+ WRITE_PIXEL( data & 0xffff )
n_vramx++;
if( n_vramx >= ( m_packet.n_entry[ 2 ] & 0xffff ) )
{
@@ -3780,12 +3365,11 @@ void psxgpu_device::gpu_read( uint32_t *p_ram, int32_t n_size )
{
if( ( n_gpustatus & ( 1L << 0x1b ) ) != 0 )
{
- uint32_t n_pixel;
PAIR data;
verboselog( *this, 2, "copy image from frame buffer ( %d, %d )\n", n_vramx, n_vramy );
data.d = 0;
- for( n_pixel = 0; n_pixel < 2; n_pixel++ )
+ for( int n_pixel = 0; n_pixel < 2; n_pixel++ )
{
data.w.l = data.w.h;
data.w.h = *( p_p_vram[ ( n_vramy + ( m_packet.n_entry[ 1 ] >> 16 ) ) & 0x3ff ] + ( ( n_vramx + ( m_packet.n_entry[ 1 ] & 0xffff ) ) & 0x3ff ) );