Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/mame/sega/model2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,8 +1387,6 @@ void model2b_state::model2b_crx_mem(address_map &map)
map(0x11100000, 0x111fffff).ram().share("textureram0").flags(i960_cpu_device::BURST); // texture RAM 0 (2b/2c)
map(0x11200000, 0x112fffff).ram().share("textureram1").flags(i960_cpu_device::BURST); // texture RAM 1 (2b/2c)
map(0x11300000, 0x113fffff).ram().share("textureram1").flags(i960_cpu_device::BURST); // texture RAM 1 (2b/2c)
map(0x11400000, 0x1140ffff).rw(FUNC(model2b_state::lumaram_r), FUNC(model2b_state::lumaram_w)).flags(i960_cpu_device::BURST); // polygon "luma" RAM (2b/2c)
map(0x12800000, 0x1281ffff).rw(FUNC(model2b_state::lumaram_r), FUNC(model2b_state::lumaram_w)).umask32(0x0000ffff).flags(i960_cpu_device::BURST); // polygon "luma" RAM
map(0x11400000, 0x1140ffff).rw(FUNC(model2b_state::lumaram_r), FUNC(model2b_state::lumaram_w)).umask16(0x00ff).flags(i960_cpu_device::BURST); // polygon "luma" RAM (2b/2c)

map(0x01c00000, 0x01c0001f).rw("io", FUNC(sega_315_5649_device::read), FUNC(sega_315_5649_device::write)).umask32(0x00ff00ff);
Expand Down Expand Up @@ -1424,8 +1422,6 @@ void model2c_state::model2c_crx_mem(address_map &map)

map(0x11000000, 0x111fffff).ram().share("textureram0").flags(i960_cpu_device::BURST); // texture RAM 0 (2b/2c)
map(0x11200000, 0x113fffff).ram().share("textureram1").flags(i960_cpu_device::BURST); // texture RAM 1 (2b/2c)
map(0x11400000, 0x1140ffff).rw(FUNC(model2c_state::lumaram_r), FUNC(model2c_state::lumaram_w)).flags(i960_cpu_device::BURST); // polygon "luma" RAM (2b/2c)
map(0x12800000, 0x1281ffff).rw(FUNC(model2c_state::lumaram_r), FUNC(model2c_state::lumaram_w)).umask32(0x0000ffff).flags(i960_cpu_device::BURST); // polygon "luma" RAM
map(0x11400000, 0x1140ffff).rw(FUNC(model2c_state::lumaram_r), FUNC(model2c_state::lumaram_w)).umask16(0x00ff).flags(i960_cpu_device::BURST); // polygon "luma" RAM (2b/2c)

map(0x01c00000, 0x01c0001f).rw("io", FUNC(sega_315_5649_device::read), FUNC(sega_315_5649_device::write)).umask32(0x00ff00ff);
Expand Down
3 changes: 3 additions & 0 deletions src/mame/sega/model2.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,14 @@ class model2_renderer : public poly_manager<float, m2_poly_extra_data, 4>
{ &model2_renderer::draw_scanline_tex<true>, this } },
m_state(state),
m_destmap(512, 512),
m_fillmap(512, 512),
m_xoffs(90),
m_yoffs(-8)
{
}

bitmap_rgb32 &destmap() { return m_destmap; }
bitmap_ind8 &fillmap() { return m_fillmap; }

void model2_3d_render(triangle *tri, const rectangle &cliprect);
void set_xoffset(int16_t xoffs) { m_xoffs = xoffs; }
Expand All @@ -698,6 +700,7 @@ class model2_renderer : public poly_manager<float, m2_poly_extra_data, 4>

model2_state &m_state;
bitmap_rgb32 m_destmap;
bitmap_ind8 m_fillmap;
int16_t m_xoffs, m_yoffs;

template <bool Translucent>
Expand Down
46 changes: 10 additions & 36 deletions src/mame/sega/model2_v.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
maps to do mip mapping. More information can be found on the 2B manual, on the 'Texturing' and 'Data Format' chapters.
- The rasterizer supports 128x128 'microtextures' which are typically used to add more details to a texture when it is
close enough to the viewer.
- Polygons are rendered from front-to-back. A fill buffer is used to track which pixels in the framebuffer have already
been drawn to and prevents them from being overwritten. The real hardware does this to ensure that the polygons closest
to the camera are rendered first, in case the renderer runs out of time and has to skip ahead to the next frame.

*********************************************************************************************************************************/

Expand Down Expand Up @@ -461,12 +464,6 @@ void model2_state::model2_3d_process_quad( raster_state *raster, u32 attr )
/* get our list read to add the triangles */
ztri = raster->tri_sorted_list[object.z];

if ( ztri != nullptr )
{
while( ztri->next != nullptr )
ztri = (triangle *)ztri->next;
}

/* go through the clipped vertex list, adding triangles */
for( i = 2; i < clipped_verts; i++ )
{
Expand Down Expand Up @@ -506,17 +503,8 @@ void model2_state::model2_3d_process_quad( raster_state *raster, u32 attr )
memcpy( &tri->v[2], &verts_out[i], sizeof( poly_vertex ) );

/* add to our sorted list */
tri->next = nullptr;

if ( ztri == nullptr )
{
raster->tri_sorted_list[object.z] = tri;
}
else
{
ztri->next = tri;
}

raster->tri_sorted_list[object.z] = tri;
tri->next = ztri;
ztri = tri;
}

Expand Down Expand Up @@ -693,12 +681,6 @@ void model2_state::model2_3d_process_triangle( raster_state *raster, u32 attr )
/* get our list read to add the triangles */
ztri = raster->tri_sorted_list[object.z];

if ( ztri != nullptr )
{
while( ztri->next != nullptr )
ztri = (triangle *)ztri->next;
}

/* go through the clipped vertex list, adding triangles */
for( i = 2; i < clipped_verts; i++ )
{
Expand Down Expand Up @@ -738,17 +720,8 @@ void model2_state::model2_3d_process_triangle( raster_state *raster, u32 attr )
memcpy( &tri->v[2], &verts_out[i], sizeof( poly_vertex ) );

/* add to our sorted list */
tri->next = nullptr;

if ( ztri == nullptr )
{
raster->tri_sorted_list[object.z] = tri;
}
else
{
ztri->next = tri;
}

raster->tri_sorted_list[object.z] = tri;
tri->next = ztri;
ztri = tri;
}

Expand Down Expand Up @@ -927,11 +900,12 @@ void model2_state::model2_3d_frame_end( bitmap_rgb32 &bitmap, const rectangle &c
return;

m_poly->destmap().fill(0x00000000, cliprect);
m_poly->fillmap().fill(0x00, cliprect);

for (u8 window = 0; window <= raster->cur_window; window++)
for (int window = raster->cur_window; window >= 0; window--)
{
/* go through the Z levels, and render each bucket */
for ( z = raster->max_z; z >= raster->min_z; z-- )
for (z = raster->min_z; z <= raster->max_z; z++)
{
/* see if we have items at this z level */
if ( raster->tri_sorted_list[z] != nullptr )
Expand Down
14 changes: 13 additions & 1 deletion src/mame/sega/model2rd.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void model2_renderer::draw_scanline_solid(int32_t scanline, const extent_t& exte
{
model2_state *state = object.state;
u32 *const p = &m_destmap.pix(scanline);
u8 *const fill = &m_fillmap.pix(scanline);
u8 *gamma_value = &state->m_gamma_table[0];

// extract color information
Expand Down Expand Up @@ -59,7 +60,13 @@ void model2_renderer::draw_scanline_solid(int32_t scanline, const extent_t& exte
x++;

for (; x < extent.stopx; x += dx)
p[x] = color;
{
if (fill[x] == 0)
{
p[x] = color;
fill[x] = 0xff;
}
}
}

#define LERP(X, Y, A) (((X) + ((((Y) - (X)) * (A)) >> 8)) & 0x00ff00ff)
Expand Down Expand Up @@ -206,6 +213,7 @@ void model2_renderer::draw_scanline_tex(int32_t scanline, const extent_t &extent
{
model2_state *state = object.state;
u32 *const p = &m_destmap.pix(scanline);
u8 *const fill = &m_fillmap.pix(scanline);

/* extract color information */
const u16 *colortable_r = &state->m_colorxlat[0x0000/2];
Expand Down Expand Up @@ -246,6 +254,9 @@ void model2_renderer::draw_scanline_tex(int32_t scanline, const extent_t &extent

for ( ; x < extent.stopx; x += dx, ooz += dooz, uoz += duoz, voz += dvoz)
{
if (fill[x] > 0)
continue;

float z = recip_approx(ooz);

s32 mml = -object.texlod + fast_log2(z); // equivalent to log2(z^2)
Expand Down Expand Up @@ -297,6 +308,7 @@ void model2_renderer::draw_scanline_tex(int32_t scanline, const extent_t &extent
tb = gamma_value[tb];

p[x] = rgb_t(tr, tg, tb);
fill[x] = 0xff;
}
}

Expand Down
Loading