mirror of
https://github.com/holub/mame
synced 2025-10-07 01:16:22 +03:00
model2.cpp: stateize float_to_zval, fix z code (nw)
This commit is contained in:
parent
6047d3a629
commit
45a09141c8
@ -318,6 +318,8 @@ private:
|
|||||||
|
|
||||||
// inliners
|
// inliners
|
||||||
inline void model2_3d_project( triangle *tri );
|
inline void model2_3d_project( triangle *tri );
|
||||||
|
inline uint16_t float_to_zval( float floatval );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
|
@ -157,7 +157,7 @@ static inline void vector_cross3( poly_vertex *dst, poly_vertex *v0, poly_vertex
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 1.8.23 float to 4.12 float converter, courtesy of Aaron Giles */
|
/* 1.8.23 float to 4.12 float converter, courtesy of Aaron Giles */
|
||||||
static uint16_t float_to_zval( float floatval )
|
inline uint16_t model2_state::float_to_zval( float floatval )
|
||||||
{
|
{
|
||||||
int32_t fpint = f2u(floatval);
|
int32_t fpint = f2u(floatval);
|
||||||
int32_t exponent = ((fpint >> 23) & 0xff) - 127;
|
int32_t exponent = ((fpint >> 23) & 0xff) - 127;
|
||||||
@ -327,7 +327,7 @@ READ32_MEMBER(model2_state::polygon_count_r)
|
|||||||
* Hardware 3D Rasterizer Processing
|
* Hardware 3D Rasterizer Processing
|
||||||
*
|
*
|
||||||
*******************************************/
|
*******************************************/
|
||||||
|
|
||||||
void model2_state::model2_3d_process_quad( raster_state *raster, uint32_t attr )
|
void model2_state::model2_3d_process_quad( raster_state *raster, uint32_t attr )
|
||||||
{
|
{
|
||||||
quad_m2 object;
|
quad_m2 object;
|
||||||
@ -438,21 +438,25 @@ void model2_state::model2_3d_process_quad( raster_state *raster, uint32_t attr )
|
|||||||
/* set the object's z value */
|
/* set the object's z value */
|
||||||
zvalue = raster->triangle_z;
|
zvalue = raster->triangle_z;
|
||||||
|
|
||||||
/* see if we need to recompute min/max z */
|
/* set the object's z value */
|
||||||
if ( (attr >> 10) & 3 )
|
switch((attr >> 10) & 3)
|
||||||
{
|
{
|
||||||
if ( (attr >> 10) & 1 ) /* min value */
|
case 0: // old value
|
||||||
{
|
zvalue = raster->triangle_z;
|
||||||
|
break;
|
||||||
|
case 1: // min z
|
||||||
zvalue = min_z;
|
zvalue = min_z;
|
||||||
}
|
break;
|
||||||
else if ( (attr >> 10) & 2 ) /* max value */
|
case 2: // max z
|
||||||
{
|
|
||||||
zvalue = max_z;
|
zvalue = max_z;
|
||||||
}
|
break;
|
||||||
|
case 3: // error
|
||||||
raster->triangle_z = zvalue;
|
zvalue = 0.0f;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
raster->triangle_z = zvalue;
|
||||||
|
|
||||||
if ( cull == 0 )
|
if ( cull == 0 )
|
||||||
{
|
{
|
||||||
int32_t clipped_verts;
|
int32_t clipped_verts;
|
||||||
@ -672,23 +676,24 @@ void model2_state::model2_3d_process_triangle( raster_state *raster, uint32_t at
|
|||||||
cull = 1;
|
cull = 1;
|
||||||
|
|
||||||
/* set the object's z value */
|
/* set the object's z value */
|
||||||
zvalue = raster->triangle_z;
|
switch((attr >> 10) & 3)
|
||||||
|
|
||||||
/* see if we need to recompute min/max z */
|
|
||||||
if ( (attr >> 10) & 3 )
|
|
||||||
{
|
{
|
||||||
if ( (attr >> 10) & 1 ) /* min value */
|
case 0: // old value
|
||||||
{
|
zvalue = raster->triangle_z;
|
||||||
|
break;
|
||||||
|
case 1: // min z
|
||||||
zvalue = min_z;
|
zvalue = min_z;
|
||||||
}
|
break;
|
||||||
else if ( (attr >> 10) & 2 ) /* max value */
|
case 2: // max z
|
||||||
{
|
|
||||||
zvalue = max_z;
|
zvalue = max_z;
|
||||||
}
|
break;
|
||||||
|
case 3: // error
|
||||||
raster->triangle_z = zvalue;
|
zvalue = 0.0f;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
raster->triangle_z = zvalue;
|
||||||
|
|
||||||
/* if we're not culling, do z-clip and add to out triangle list */
|
/* if we're not culling, do z-clip and add to out triangle list */
|
||||||
if ( cull == 0 )
|
if ( cull == 0 )
|
||||||
{
|
{
|
||||||
@ -1160,7 +1165,7 @@ void model2_state::model2_3d_push( raster_state *raster, uint32_t input )
|
|||||||
raster->center_sel = ( input >> 6 ) & 3;
|
raster->center_sel = ( input >> 6 ) & 3;
|
||||||
|
|
||||||
/* reset the triangle z value */
|
/* reset the triangle z value */
|
||||||
raster->triangle_z = 0;
|
raster->triangle_z = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user