summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/tilemap.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/emu/tilemap.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/emu/tilemap.cpp')
-rw-r--r--src/emu/tilemap.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/emu/tilemap.cpp b/src/emu/tilemap.cpp
index fab04e8f162..4252b9259a2 100644
--- a/src/emu/tilemap.cpp
+++ b/src/emu/tilemap.cpp
@@ -860,8 +860,8 @@ u8 tilemap_t::tile_draw(const u8 *pendata, u32 x0, u32 y0, u32 palette_base, u8
u8 andmask = ~0, ormask = 0;
for (u16 ty = 0; ty < m_tileheight; ty++)
{
- u16 *pixptr = &m_pixmap.pix16(y0, x0);
- u8 *flagsptr = &m_flagsmap.pix8(y0, x0);
+ u16 *pixptr = &m_pixmap.pix(y0, x0);
+ u8 *flagsptr = &m_flagsmap.pix(y0, x0);
// pre-advance to the next row
y0 += dy0;
@@ -913,7 +913,7 @@ u8 tilemap_t::tile_apply_bitmask(const u8 *maskdata, u32 x0, u32 y0, u8 category
for (u16 ty = 0; ty < m_tileheight; ty++)
{
// pre-advance to the next row
- u8 *flagsptr = &m_flagsmap.pix8(y0, x0);
+ u8 *flagsptr = &m_flagsmap.pix(y0, x0);
y0 += dy0;
// anywhere the bitmask is 0 should be transparent
@@ -1182,7 +1182,7 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b
// look up priority and destination base addresses for y1
bitmap_ind8 &priority_bitmap = *blit.priority;
- u8 *priority_baseaddr = &priority_bitmap.pix8(y1, xpos);
+ u8 *priority_baseaddr = &priority_bitmap.pix(y1, xpos);
typename _BitmapClass::pixel_t *dest_baseaddr = nullptr;
int dest_rowpixels = 0;
if (dest.valid())
@@ -1198,8 +1198,8 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b
y2 -= ypos;
// get tilemap pixels
- const u16 *source_baseaddr = &m_pixmap.pix16(y1);
- const u8 *mask_baseaddr = &m_flagsmap.pix8(y1);
+ const u16 *source_baseaddr = &m_pixmap.pix(y1);
+ const u8 *mask_baseaddr = &m_flagsmap.pix(y1);
// get start/stop columns, rounding outward
int mincol = x1 / m_tilewidth;
@@ -1396,9 +1396,9 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
u32 cy = starty >> 16;
// get source and priority pointers
- u8 *pri = (priority != 0xff00) ? &priority_bitmap.pix8(sy, sx) : nullptr;
- const u16 *src = &m_pixmap.pix16(cy);
- const u8 *maskptr = &m_flagsmap.pix8(cy);
+ u8 *pri = (priority != 0xff00) ? &priority_bitmap.pix(sy, sx) : nullptr;
+ const u16 *src = &m_pixmap.pix(cy);
+ const u8 *maskptr = &m_flagsmap.pix(cy);
typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx);
// loop over columns
@@ -1440,15 +1440,15 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
// get dest and priority pointers
typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx);
- u8 *pri = (priority != 0xff00) ? &priority_bitmap.pix8(sy, sx) : nullptr;
+ u8 *pri = (priority != 0xff00) ? &priority_bitmap.pix(sy, sx) : nullptr;
// loop over columns
while (x <= ex)
{
// plot if we match the mask
- if ((m_flagsmap.pix8((cy >> 16) & ymask, (cx >> 16) & xmask) & mask) == value)
+ if ((m_flagsmap.pix((cy >> 16) & ymask, (cx >> 16) & xmask) & mask) == value)
{
- ROZ_PLOT_PIXEL(m_pixmap.pix16((cy >> 16) & ymask, (cx >> 16) & xmask));
+ ROZ_PLOT_PIXEL(m_pixmap.pix((cy >> 16) & ymask, (cx >> 16) & xmask));
if (priority != 0xff00)
*pri = (*pri & (priority >> 8)) | priority;
}
@@ -1482,16 +1482,16 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
// get dest and priority pointers
typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx);
- u8 *pri = (priority != 0xff00) ? &priority_bitmap.pix8(sy, sx) : nullptr;
+ u8 *pri = (priority != 0xff00) ? &priority_bitmap.pix(sy, sx) : nullptr;
// loop over columns
while (x <= ex)
{
// plot if we're within the bitmap and we match the mask
if (cx < widthshifted && cy < heightshifted)
- if ((m_flagsmap.pix8(cy >> 16, cx >> 16) & mask) == value)
+ if ((m_flagsmap.pix(cy >> 16, cx >> 16) & mask) == value)
{
- ROZ_PLOT_PIXEL(m_pixmap.pix16(cy >> 16, cx >> 16));
+ ROZ_PLOT_PIXEL(m_pixmap.pix(cy >> 16, cx >> 16));
if (priority != 0xff00)
*pri = (*pri & (priority >> 8)) | priority;
}