mirror of
https://github.com/holub/mame
synced 2025-10-06 17:08:28 +03:00
model2.cpp: apply focus in a specific function, one liners ftw (nw)
This commit is contained in:
parent
d1e647f8eb
commit
214e0d3bdf
@ -131,6 +131,28 @@ struct raster_state
|
|||||||
uint8_t log_ram[0x40000]; /* Log RAM pointer */
|
uint8_t log_ram[0x40000]; /* Log RAM pointer */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*******************************************
|
||||||
|
*
|
||||||
|
* Geometry Engine Internal State
|
||||||
|
*
|
||||||
|
*******************************************/
|
||||||
|
|
||||||
|
struct geo_state
|
||||||
|
{
|
||||||
|
raster_state * raster;
|
||||||
|
uint32_t mode; /* bit 0 = Enable Specular, bit 1 = Calculate Normals */
|
||||||
|
uint32_t * polygon_rom; /* Polygon ROM pointer */
|
||||||
|
uint32_t polygon_rom_mask; /* Polygon ROM mask */
|
||||||
|
float matrix[12]; /* Current Transformation Matrix */
|
||||||
|
poly_vertex focus; /* Focus (x,y) */
|
||||||
|
poly_vertex light; /* Light Vector */
|
||||||
|
float lod; /* LOD */
|
||||||
|
float coef_table[32]; /* Distane Coefficient table */
|
||||||
|
texture_parameter texture_parameters[32]; /* Texture parameters */
|
||||||
|
uint32_t polygon_ram0[0x8000]; /* Fast Polygon RAM pointer */
|
||||||
|
uint32_t polygon_ram1[0x8000]; /* Slow Polygon RAM pointer */
|
||||||
|
model2_state *state;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************
|
/*******************************************
|
||||||
@ -191,6 +213,12 @@ static inline void vector_cross3( poly_vertex *dst, poly_vertex *v0, poly_vertex
|
|||||||
dst->pz = (p1.x * p2.y) - (p1.y * p2.x);
|
dst->pz = (p1.x * p2.y) - (p1.y * p2.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void apply_focus( geo_state *geo, poly_vertex *p0)
|
||||||
|
{
|
||||||
|
p0->x *= geo->focus.x;
|
||||||
|
p0->y *= geo->focus.y;
|
||||||
|
}
|
||||||
|
|
||||||
/* 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 */
|
||||||
inline uint16_t model2_state::float_to_zval( float floatval )
|
inline uint16_t model2_state::float_to_zval( float floatval )
|
||||||
{
|
{
|
||||||
@ -1160,32 +1188,6 @@ void model2_state::model2_3d_push( raster_state *raster, uint32_t input )
|
|||||||
|
|
||||||
/***********************************************************************************************/
|
/***********************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************
|
|
||||||
*
|
|
||||||
* Geometry Engine Internal State
|
|
||||||
*
|
|
||||||
*******************************************/
|
|
||||||
|
|
||||||
struct geo_state
|
|
||||||
{
|
|
||||||
raster_state * raster;
|
|
||||||
uint32_t mode; /* bit 0 = Enable Specular, bit 1 = Calculate Normals */
|
|
||||||
uint32_t * polygon_rom; /* Polygon ROM pointer */
|
|
||||||
uint32_t polygon_rom_mask; /* Polygon ROM mask */
|
|
||||||
float matrix[12]; /* Current Transformation Matrix */
|
|
||||||
poly_vertex focus; /* Focus (x,y) */
|
|
||||||
poly_vertex light; /* Light Vector */
|
|
||||||
float lod; /* LOD */
|
|
||||||
float coef_table[32]; /* Distane Coefficient table */
|
|
||||||
texture_parameter texture_parameters[32]; /* Texture parameters */
|
|
||||||
uint32_t polygon_ram0[0x8000]; /* Fast Polygon RAM pointer */
|
|
||||||
uint32_t polygon_ram1[0x8000]; /* Slow Polygon RAM pointer */
|
|
||||||
model2_state *state;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************
|
/*******************************************
|
||||||
*
|
*
|
||||||
* Geometry Engine Initialization
|
* Geometry Engine Initialization
|
||||||
@ -1231,8 +1233,7 @@ void model2_state::geo_parse_np_ns( geo_state *geo, uint32_t *input, uint32_t co
|
|||||||
transform_point( &point, geo->matrix );
|
transform_point( &point, geo->matrix );
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push it to the 3d rasterizer */
|
/* push it to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1248,8 +1249,7 @@ void model2_state::geo_parse_np_ns( geo_state *geo, uint32_t *input, uint32_t co
|
|||||||
transform_point( &point, geo->matrix );
|
transform_point( &point, geo->matrix );
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push it to the 3d rasterizer */
|
/* push it to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1295,8 +1295,7 @@ void model2_state::geo_parse_np_ns( geo_state *geo, uint32_t *input, uint32_t co
|
|||||||
dotp = dot_product( &normal, &point );
|
dotp = dot_product( &normal, &point );
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* determine whether this is the front or the back of the polygon */
|
/* determine whether this is the front or the back of the polygon */
|
||||||
face = 0x100; /* rear */
|
face = 0x100; /* rear */
|
||||||
@ -1343,8 +1342,7 @@ void model2_state::geo_parse_np_ns( geo_state *geo, uint32_t *input, uint32_t co
|
|||||||
transform_point( &point, geo->matrix );
|
transform_point( &point, geo->matrix );
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push to the 3d rasterizer */
|
/* push to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1383,8 +1381,7 @@ void model2_state::geo_parse_np_s( geo_state *geo, uint32_t *input, uint32_t cou
|
|||||||
transform_point( &point, geo->matrix );
|
transform_point( &point, geo->matrix );
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push it to the 3d rasterizer */
|
/* push it to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1400,8 +1397,7 @@ void model2_state::geo_parse_np_s( geo_state *geo, uint32_t *input, uint32_t cou
|
|||||||
transform_point( &point, geo->matrix );
|
transform_point( &point, geo->matrix );
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push it to the 3d rasterizer */
|
/* push it to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1447,8 +1443,7 @@ void model2_state::geo_parse_np_s( geo_state *geo, uint32_t *input, uint32_t cou
|
|||||||
dotp = dot_product( &normal, &point );
|
dotp = dot_product( &normal, &point );
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* determine whether this is the front or the back of the polygon */
|
/* determine whether this is the front or the back of the polygon */
|
||||||
face = 0x100; /* rear */
|
face = 0x100; /* rear */
|
||||||
@ -1504,8 +1499,7 @@ void model2_state::geo_parse_np_s( geo_state *geo, uint32_t *input, uint32_t cou
|
|||||||
transform_point( &point, geo->matrix );
|
transform_point( &point, geo->matrix );
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push to the 3d rasterizer */
|
/* push to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1547,8 +1541,7 @@ void model2_state::geo_parse_nn_ns( geo_state *geo, uint32_t *input, uint32_t co
|
|||||||
p0.x = point.x; p0.y = point.y; p0.pz = point.pz;
|
p0.x = point.x; p0.y = point.y; p0.pz = point.pz;
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push it to the 3d rasterizer */
|
/* push it to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1567,8 +1560,7 @@ void model2_state::geo_parse_nn_ns( geo_state *geo, uint32_t *input, uint32_t co
|
|||||||
p1.x = point.x; p1.y = point.y; p1.pz = point.pz;
|
p1.x = point.x; p1.y = point.y; p1.pz = point.pz;
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push it to the 3d rasterizer */
|
/* push it to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1618,8 +1610,7 @@ void model2_state::geo_parse_nn_ns( geo_state *geo, uint32_t *input, uint32_t co
|
|||||||
dotp = dot_product( &normal, &point );
|
dotp = dot_product( &normal, &point );
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* determine whether this is the front or the back of the polygon */
|
/* determine whether this is the front or the back of the polygon */
|
||||||
face = 0x100; /* rear */
|
face = 0x100; /* rear */
|
||||||
@ -1669,8 +1660,7 @@ void model2_state::geo_parse_nn_ns( geo_state *geo, uint32_t *input, uint32_t co
|
|||||||
p3.x = point.x; p3.y = point.y; p3.pz = point.pz;
|
p3.x = point.x; p3.y = point.y; p3.pz = point.pz;
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push to the 3d rasterizer */
|
/* push to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1742,8 +1732,7 @@ void model2_state::geo_parse_nn_s( geo_state *geo, uint32_t *input, uint32_t cou
|
|||||||
p0.x = point.x; p0.y = point.y; p0.pz = point.pz;
|
p0.x = point.x; p0.y = point.y; p0.pz = point.pz;
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push it to the 3d rasterizer */
|
/* push it to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1762,8 +1751,7 @@ void model2_state::geo_parse_nn_s( geo_state *geo, uint32_t *input, uint32_t cou
|
|||||||
p1.x = point.x; p1.y = point.y; p1.pz = point.pz;
|
p1.x = point.x; p1.y = point.y; p1.pz = point.pz;
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push it to the 3d rasterizer */
|
/* push it to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
@ -1813,8 +1801,7 @@ void model2_state::geo_parse_nn_s( geo_state *geo, uint32_t *input, uint32_t cou
|
|||||||
dotp = dot_product( &normal, &point );
|
dotp = dot_product( &normal, &point );
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* determine whether this is the front or the back of the polygon */
|
/* determine whether this is the front or the back of the polygon */
|
||||||
face = 0x100; /* rear */
|
face = 0x100; /* rear */
|
||||||
@ -1873,8 +1860,7 @@ void model2_state::geo_parse_nn_s( geo_state *geo, uint32_t *input, uint32_t cou
|
|||||||
p3.x = point.x; p3.y = point.y; p3.pz = point.pz;
|
p3.x = point.x; p3.y = point.y; p3.pz = point.pz;
|
||||||
|
|
||||||
/* apply focus */
|
/* apply focus */
|
||||||
point.x *= geo->focus.x;
|
apply_focus( geo, &point );
|
||||||
point.y *= geo->focus.y;
|
|
||||||
|
|
||||||
/* push to the 3d rasterizer */
|
/* push to the 3d rasterizer */
|
||||||
model2_3d_push( raster, f2u(point.x) >> 8 );
|
model2_3d_push( raster, f2u(point.x) >> 8 );
|
||||||
|
Loading…
Reference in New Issue
Block a user