summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/model3.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-09-27 14:00:42 +1000
committer Vas Crabb <vas@vastheman.com>2020-09-27 14:00:42 +1000
commita1d35e5abf431e03e06d55b96379a3b14753ed4d (patch)
tree506ffe906e707f50eca2306da80b1657644e0507 /src/mame/video/model3.cpp
parentd294948a3bb8c6e8fdbc96841ceae30ec6687870 (diff)
Cleaned up bitmap API.
Made const-qualified pixel accessors (pix, pixt, raw_pixptr) return const-qualified references/pointers to pixesl, and added non-const versions. This makes bitmap more like standard library containers where const protects the content as well as the dimensions. Made the templated pixt accessor protected - having it public makes it too easy to inadvertently get a pointer to the wrong location. Removed the pix(8|16|32|64) accessors from the specific bitmaps. You could only use the "correct" one anyway, and having the "incorrect" ones available prevented explicit instantiations of the class template because the static assertions would fail. You can still see the pixel type in the bitmap class names, and you can't assign the result of &pix(y, x) to the wrong kind of pointer without a cast. Added fill member functions to the specific bitmap template, and added a explicit instantiations. This allows the bitmap size check to be skipped on most bitmap fills, although the clipping check is still there. Also fixed a couple of places that were trying to fill an indexed 16-bit bitmap with rgb_t::black() exposed by this (replaced with zero to get the same net effect). The explicit template instantiations in the .cpp file mean the compiler can inline the function if necessary, but don't need to generate a local out-of-line body if it chooses not to. Extended the size of the fill value parameter in the base bitmap class to 64 bits so it works correctly for 64-bit bitmaps. Fixed places where IE15 and VGM visualiser weren't accounting for row bytes potentially being larger than width. Fixed an off-by-one in an HP-DIO card where it was treating the Topcat cursor right edge as exclusive. Updated everything to work with the API changes, reduced the scope of many variables, added more const, and replaced a few fill/copy loops with stuff from <algorithm>.
Diffstat (limited to 'src/mame/video/model3.cpp')
-rw-r--r--src/mame/video/model3.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/src/mame/video/model3.cpp b/src/mame/video/model3.cpp
index d2ebec94fa9..918653160ca 100644
--- a/src/mame/video/model3.cpp
+++ b/src/mame/video/model3.cpp
@@ -245,12 +245,11 @@ TILE_GET_INFO_MEMBER(model3_state::tile_info_layer3_8bit) { MODEL3_TILE_INFO8(0x
#ifdef UNUSED_FUNCTION
void model3_state::draw_texture_sheet(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- int x,y;
- for(y = cliprect.min_y; y <= cliprect.max_y; y++)
+ for(int y = cliprect.min_y; y <= cliprect.max_y; y++)
{
- uint16_t *d = &bitmap.pix16(y);
+ uint16_t *const d = &bitmap.pix(y);
int index = (y*2)*2048;
- for(x = cliprect.min_x; x <= cliprect.max_x; x++) {
+ for(int x = cliprect.min_x; x <= cliprect.max_x; x++) {
uint16_t pix = m_texture_ram[0][index];
index+=4;
if(pix != 0) {
@@ -292,8 +291,8 @@ void model3_state::draw_layer(bitmap_rgb32 &bitmap, const rectangle &cliprect, i
for (int y = y1; y <= y2; y++)
{
- uint32_t* dst = &bitmap.pix32(y);
- uint16_t* src = &pixmap.pix16(iy & 0x1ff);
+ uint32_t *const dst = &bitmap.pix(y);
+ uint16_t const *const src = &pixmap.pix(iy & 0x1ff);
int rowscroll = BYTE_REVERSE16(rowscroll_ram[((layer * 0x200) + y) ^ NATIVE_ENDIAN_VALUE_LE_BE(3,0)]) & 0x7fff;
if (rowscroll & 0x100)
@@ -2024,14 +2023,12 @@ void model3_state::real3d_traverse_display_list()
void model3_renderer::draw(bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
- int i, j;
-
- for (j = cliprect.min_y; j <= cliprect.max_y; ++j)
+ for (int j = cliprect.min_y; j <= cliprect.max_y; ++j)
{
- uint32_t *dst = &bitmap.pix32(j);
- uint32_t *src = &m_fb->pix32(j);
+ uint32_t *const dst = &bitmap.pix(j);
+ uint32_t const *const src = &m_fb->pix(j);
- for (i = cliprect.min_x; i <= cliprect.max_x; ++i)
+ for (int i = cliprect.min_x; i <= cliprect.max_x; ++i)
{
if (src[i] & 0xff000000)
{
@@ -2191,8 +2188,8 @@ void model3_renderer::draw_alpha_triangles(const m3_triangle* tris, int num_tris
void model3_renderer::draw_scanline_solid(int32_t scanline, const extent_t &extent, const model3_polydata &polydata, int threadid)
{
- uint32_t *fb = &m_fb->pix32(scanline);
- float *zb = (float*)&m_zb->pix32(scanline);
+ uint32_t *const fb = &m_fb->pix(scanline);
+ float *const zb = (float*)&m_zb->pix(scanline);
float z = extent.param[0].start;
float dz = extent.param[0].dpdx;
@@ -2221,8 +2218,8 @@ void model3_renderer::draw_scanline_solid(int32_t scanline, const extent_t &exte
void model3_renderer::draw_scanline_solid_trans(int32_t scanline, const extent_t &extent, const model3_polydata &polydata, int threadid)
{
- uint32_t *fb = &m_fb->pix32(scanline);
- float *zb = (float*)&m_zb->pix32(scanline);
+ uint32_t *const fb = &m_fb->pix(scanline);
+ float *const zb = (float*)&m_zb->pix(scanline);
float z = extent.param[0].start;
float dz = extent.param[0].dpdx;
@@ -2289,8 +2286,8 @@ do {
void model3_renderer::draw_scanline_tex(int32_t scanline, const extent_t &extent, const model3_polydata &polydata, int threadid)
{
- uint32_t *fb = &m_fb->pix32(scanline);
- float *zb = (float*)&m_zb->pix32(scanline);
+ uint32_t *const fb = &m_fb->pix(scanline);
+ float *const zb = (float*)&m_zb->pix(scanline);
const cached_texture *texture = polydata.texture;
float z = extent.param[0].start;
@@ -2333,8 +2330,8 @@ void model3_renderer::draw_scanline_tex(int32_t scanline, const extent_t &extent
void model3_renderer::draw_scanline_tex_colormod(int32_t scanline, const extent_t &extent, const model3_polydata &polydata, int threadid)
{
- uint32_t *fb = &m_fb->pix32(scanline);
- float *zb = (float*)&m_zb->pix32(scanline);
+ uint32_t *const fb = &m_fb->pix(scanline);
+ float *const zb = (float*)&m_zb->pix(scanline);
const cached_texture *texture = polydata.texture;
float z = extent.param[0].start;
@@ -2380,8 +2377,8 @@ void model3_renderer::draw_scanline_tex_colormod(int32_t scanline, const extent_
void model3_renderer::draw_scanline_tex_contour(int32_t scanline, const extent_t &extent, const model3_polydata &polydata, int threadid)
{
- uint32_t *fb = &m_fb->pix32(scanline);
- float *zb = (float*)&m_zb->pix32(scanline);
+ uint32_t *const fb = &m_fb->pix(scanline);
+ float *const zb = (float*)&m_zb->pix(scanline);
const cached_texture *texture = polydata.texture;
float z = extent.param[0].start;
@@ -2432,8 +2429,8 @@ void model3_renderer::draw_scanline_tex_contour(int32_t scanline, const extent_t
void model3_renderer::draw_scanline_tex_trans(int32_t scanline, const extent_t &extent, const model3_polydata &polydata, int threadid)
{
- uint32_t *fb = &m_fb->pix32(scanline);
- float *zb = (float*)&m_zb->pix32(scanline);
+ uint32_t *const fb = &m_fb->pix(scanline);
+ float *const zb = (float*)&m_zb->pix(scanline);
const cached_texture *texture = polydata.texture;
float z = extent.param[0].start;
@@ -2481,8 +2478,8 @@ void model3_renderer::draw_scanline_tex_trans(int32_t scanline, const extent_t &
void model3_renderer::draw_scanline_tex_alpha(int32_t scanline, const extent_t &extent, const model3_polydata &polydata, int threadid)
{
- uint32_t *fb = &m_fb->pix32(scanline);
- float *zb = (float*)&m_zb->pix32(scanline);
+ uint32_t *const fb = &m_fb->pix(scanline);
+ float *const zb = (float*)&m_zb->pix(scanline);
const cached_texture *texture = polydata.texture;
float z = extent.param[0].start;