model1.cpp, model2.cpp: Eliminate auto_alloc (nw)

This commit is contained in:
AJR 2019-09-11 10:45:22 -04:00
parent 48e3eb4174
commit 80f1348e62
4 changed files with 85 additions and 86 deletions

View File

@ -390,11 +390,11 @@ private:
};
std::unique_ptr<view_t> m_view;
point_t *m_pointdb;
std::unique_ptr<point_t[]> m_pointdb;
point_t *m_pointpt;
quad_t *m_quaddb;
std::unique_ptr<quad_t[]> m_quaddb;
quad_t *m_quadpt;
quad_t **m_quadind;
std::unique_ptr<quad_t *[]> m_quadind;
offs_t m_pushpc;
u32 m_copro_hle_active_list_pos, m_copro_hle_active_list_length;
typedef void (model1_state::*tgp_func)();

View File

@ -71,7 +71,7 @@ public:
std::unique_ptr<uint16_t[]> m_colorxlat;
std::unique_ptr<uint16_t[]> m_lumaram;
uint8_t m_gamma_table[256];
model2_renderer *m_poly;
std::unique_ptr<model2_renderer> m_poly;
/* Public for access by the ioports */
DECLARE_CUSTOM_INPUT_MEMBER(daytona_gearbox_r);
@ -139,8 +139,8 @@ protected:
uint32_t m_geo_read_start_address;
uint32_t m_geo_write_start_address;
raster_state *m_raster;
geo_state *m_geo;
std::unique_ptr<raster_state> m_raster;
std::unique_ptr<geo_state> m_geo;
bitmap_rgb32 m_sys24_bitmap;
// uint32_t m_soundack;
void model2_check_irq_state();
@ -760,4 +760,59 @@ struct quad_m2
uint8_t luma;
};
/*******************************************
*
* Hardware 3D Rasterizer Internal State
*
*******************************************/
#define MAX_TRIANGLES 32768
struct raster_state
{
// uint32_t mode; /* bit 0 = Test Mode, bit 2 = Switch 60Hz(1)/30Hz(0) operation */
uint16_t *texture_rom; /* Texture ROM pointer */
uint32_t texture_rom_mask; /* Texture ROM mask */
int16_t viewport[4]; /* View port (startx,starty,endx,endy) */
int16_t center[4][2]; /* Centers (eye 0[x,y],1[x,y],2[x,y],3[x,y]) */
uint16_t center_sel; /* Selected center */
uint32_t reverse; /* Left/Right Reverse */
float z_adjust; /* ZSort Mode */
float triangle_z; /* Current Triangle z value */
uint8_t master_z_clip; /* Master Z-Clip value */
uint32_t cur_command; /* Current command */
uint32_t command_buffer[32]; /* Command buffer */
uint32_t command_index; /* Command buffer index */
triangle tri_list[MAX_TRIANGLES]; /* Triangle list */
uint32_t tri_list_index; /* Triangle list index */
triangle *tri_sorted_list[0x10000]; /* Sorted Triangle list */
uint16_t min_z; /* Minimum sortable Z value */
uint16_t max_z; /* Maximum sortable Z value */
uint16_t texture_ram[0x10000]; /* Texture 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;
};
#endif // MAME_INCLUDES_MODEL2_H

View File

@ -451,20 +451,20 @@ int model1_state::quad_t::compare(const model1_state::quad_t* other) const
void model1_state::sort_quads() const
{
const int count = m_quadpt - m_quaddb;
const int count = m_quadpt - &m_quaddb[0];
for (int i = 0; i < count; i++)
{
m_quadind[i] = m_quaddb + i;
m_quadind[i] = &m_quaddb[i];
}
qsort(m_quadind, count, sizeof(model1_state::quad_t*), comp_quads);
qsort(&m_quadind[0], count, sizeof(model1_state::quad_t*), comp_quads);
}
void model1_state::unsort_quads() const
{
const int count = m_quadpt - m_quaddb;
const int count = m_quadpt - &m_quaddb[0];
for (int i = 0; i < count; i++)
{
m_quadind[i] = m_quaddb + i;
m_quadind[i] = &m_quaddb[i];
}
}
@ -472,7 +472,7 @@ void model1_state::unsort_quads() const
void model1_state::draw_quads(bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
view_t *view = m_view.get();
int count = m_quadpt - m_quaddb;
int count = m_quadpt - &m_quaddb[0];
/* clip to the cliprect */
int save_x1 = view->x1;
@ -1176,15 +1176,15 @@ int model1_state::skip_direct(int list_offset) const
void model1_state::draw_objects(bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
if (m_quadpt != m_quaddb)
if (m_quadpt != &m_quaddb[0])
{
LOG_TGP(("VIDEO: sort&draw\n"));
sort_quads();
draw_quads(bitmap, cliprect);
}
m_quadpt = m_quaddb;
m_pointpt = m_pointdb;
m_quadpt = &m_quaddb[0];
m_pointpt = &m_pointdb[0];
}
@ -1199,8 +1199,8 @@ int model1_state::draw_direct(bitmap_rgb32 &bitmap, const rectangle &cliprect, i
unsort_quads();
draw_quads(bitmap, cliprect);
m_quadpt = m_quaddb;
m_pointpt = m_pointdb;
m_quadpt = &m_quaddb[0];
m_pointpt = &m_pointdb[0];
return list_offset;
}
@ -1568,12 +1568,12 @@ void model1_state::video_start()
m_poly_ram = make_unique_clear<uint32_t[]>(0x400000);
m_tgp_ram = make_unique_clear<uint16_t[]>(0x100000-0x40000);
m_pointdb = auto_alloc_array_clear(machine(), model1_state::point_t, 1000000*2);
m_quaddb = auto_alloc_array_clear(machine(), model1_state::quad_t, 1000000);
m_quadind = auto_alloc_array_clear(machine(), model1_state::quad_t *, 1000000);
m_pointdb = make_unique_clear<model1_state::point_t[]>(1000000*2);
m_quaddb = make_unique_clear<model1_state::quad_t[]>(1000000);
m_quadind = make_unique_clear<model1_state::quad_t *[]>(1000000);
m_pointpt = m_pointdb;
m_quadpt = m_quaddb;
m_pointpt = &m_pointdb[0];
m_quadpt = &m_quaddb[0];
m_listctl[0] = m_listctl[1] = 0;
m_clipfn[0].m_isclipped = &model1_state::fclip_isc_bottom;

View File

@ -99,62 +99,6 @@
/*******************************************
*
* Hardware 3D Rasterizer Internal State
*
*******************************************/
#define MAX_TRIANGLES 32768
struct raster_state
{
// uint32_t mode; /* bit 0 = Test Mode, bit 2 = Switch 60Hz(1)/30Hz(0) operation */
uint16_t *texture_rom; /* Texture ROM pointer */
uint32_t texture_rom_mask; /* Texture ROM mask */
int16_t viewport[4]; /* View port (startx,starty,endx,endy) */
int16_t center[4][2]; /* Centers (eye 0[x,y],1[x,y],2[x,y],3[x,y]) */
uint16_t center_sel; /* Selected center */
uint32_t reverse; /* Left/Right Reverse */
float z_adjust; /* ZSort Mode */
float triangle_z; /* Current Triangle z value */
uint8_t master_z_clip; /* Master Z-Clip value */
uint32_t cur_command; /* Current command */
uint32_t command_buffer[32]; /* Command buffer */
uint32_t command_index; /* Command buffer index */
triangle tri_list[MAX_TRIANGLES]; /* Triangle list */
uint32_t tri_list_index; /* Triangle list index */
triangle *tri_sorted_list[0x10000]; /* Sorted Triangle list */
uint16_t min_z; /* Minimum sortable Z value */
uint16_t max_z; /* Maximum sortable Z value */
uint16_t texture_ram[0x10000]; /* Texture 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;
};
/*******************************************
*
* Generic 3D Math Functions
@ -341,7 +285,7 @@ inline bool model2_state::check_culling( raster_state *raster, uint32_t attr, fl
void model2_state::raster_init( memory_region *texture_rom )
{
m_raster = auto_alloc_clear(machine(), <raster_state>());
m_raster = make_unique_clear<raster_state>();
m_raster->texture_rom = (uint16_t *)texture_rom->base();
m_raster->texture_rom_mask = (texture_rom->bytes() / 2) - 1;
@ -826,7 +770,7 @@ void model2_state::model2_3d_process_triangle( raster_state *raster, uint32_t at
void model2_renderer::model2_3d_render(triangle *tri, const rectangle &cliprect)
{
model2_renderer *poly = m_state.m_poly;
model2_renderer *poly = m_state.m_poly.get();
m2_poly_extra_data& extra = poly->object_data_alloc();
uint8_t renderer;
@ -942,7 +886,7 @@ inline void model2_state::model2_3d_project( triangle *tri )
/* 3D Rasterizer frame start: Resets frame variables */
void model2_state::model2_3d_frame_start( void )
{
raster_state *raster = m_raster;
raster_state *raster = m_raster.get();
/* reset the triangle list index */
raster->tri_list_index = 0;
@ -957,7 +901,7 @@ void model2_state::model2_3d_frame_start( void )
void model2_state::model2_3d_frame_end( bitmap_rgb32 &bitmap, const rectangle &cliprect )
{
raster_state *raster = m_raster;
raster_state *raster = m_raster.get();
int32_t z;
/* if we have nothing to render, bail */
@ -1216,10 +1160,10 @@ void model2_state::model2_3d_push( raster_state *raster, uint32_t input )
void model2_state::geo_init(memory_region *polygon_rom)
{
m_geo = auto_alloc_clear(machine(), <geo_state>());
m_geo = make_unique_clear<geo_state>();
m_geo->state = this;
m_geo->raster = m_raster;
m_geo->raster = m_raster.get();
m_geo->polygon_rom = (uint32_t *)polygon_rom->base();
m_geo->polygon_rom_mask = (polygon_rom->bytes() / 4) - 1;
@ -2599,7 +2543,7 @@ void model2_state::geo_parse( void )
}
/* process it */
input = geo_process_command( m_geo, opcode, input, &end_code );
input = geo_process_command( m_geo.get(), opcode, input, &end_code );
}
}
@ -2614,7 +2558,7 @@ void model2_state::video_start()
m_sys24_bitmap.allocate(width, height+4);
m_poly = auto_alloc(machine(), model2_renderer(*this));
m_poly = std::make_unique<model2_renderer>(*this);
/* initialize the hardware rasterizer */
raster_init( memregion("textures") );