tilemap.cpp: Relax assert and do some sanity checks (fixes mtrain and strain with DEBUG=1)

Note that opengolf is still broken, with a segmentation fault occurring at some point.
This commit is contained in:
AJR 2019-10-26 01:20:52 -04:00
parent 4798bcda89
commit cc1d52e6fd

View File

@ -999,10 +999,10 @@ void tilemap_t::draw_common(screen_device &screen, _BitmapClass &dest, const rec
g_profiler.start(PROFILER_TILEMAP_DRAW); g_profiler.start(PROFILER_TILEMAP_DRAW);
// configure the blit parameters based on the input parameters // configure the blit parameters based on the input parameters
assert(dest.cliprect().contains(cliprect));
assert(screen.cliprect().contains(cliprect));
blit_parameters blit; blit_parameters blit;
configure_blit_parameters(blit, screen.priority(), cliprect, flags, priority, priority_mask); configure_blit_parameters(blit, screen.priority(), cliprect, flags, priority, priority_mask);
assert(dest.cliprect().contains(cliprect));
assert(screen.cliprect().contains(cliprect) || blit.tilemap_priority_code == 0xff00);
// flush the dirty state to all tiles as appropriate // flush the dirty state to all tiles as appropriate
realize_all_dirty_tiles(); realize_all_dirty_tiles();
@ -1136,10 +1136,10 @@ void tilemap_t::draw_roz_common(screen_device &screen, _BitmapClass &dest, const
g_profiler.start(PROFILER_TILEMAP_DRAW_ROZ); g_profiler.start(PROFILER_TILEMAP_DRAW_ROZ);
// configure the blit parameters // configure the blit parameters
assert(dest.cliprect().contains(cliprect));
assert(screen.cliprect().contains(cliprect));
blit_parameters blit; blit_parameters blit;
configure_blit_parameters(blit, screen.priority(), cliprect, flags, priority, priority_mask); configure_blit_parameters(blit, screen.priority(), cliprect, flags, priority, priority_mask);
assert(dest.cliprect().contains(cliprect));
assert(screen.cliprect().contains(cliprect) || blit.tilemap_priority_code == 0xff00);
// get the full pixmap for the tilemap // get the full pixmap for the tilemap
pixmap(); pixmap();
@ -1355,7 +1355,7 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
const int ymask = m_pixmap.height() - 1; const int ymask = m_pixmap.height() - 1;
const int widthshifted = m_pixmap.width() << 16; const int widthshifted = m_pixmap.width() << 16;
const int heightshifted = m_pixmap.height() << 16; const int heightshifted = m_pixmap.height() << 16;
u32 priority = blit.tilemap_priority_code; const u32 priority = blit.tilemap_priority_code;
u8 mask = blit.mask; u8 mask = blit.mask;
u8 value = blit.value; u8 value = blit.value;
u8 alpha = blit.alpha; u8 alpha = blit.alpha;
@ -1396,7 +1396,7 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
u32 cy = starty >> 16; u32 cy = starty >> 16;
// get source and priority pointers // get source and priority pointers
u8 *pri = &priority_bitmap.pix8(sy, sx); u8 *pri = (priority != 0xff00) ? &priority_bitmap.pix8(sy, sx) : nullptr;
const u16 *src = &m_pixmap.pix16(cy); const u16 *src = &m_pixmap.pix16(cy);
const u8 *maskptr = &m_flagsmap.pix8(cy); const u8 *maskptr = &m_flagsmap.pix8(cy);
typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx); typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx);
@ -1408,14 +1408,16 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
if ((maskptr[cx >> 16] & mask) == value) if ((maskptr[cx >> 16] & mask) == value)
{ {
ROZ_PLOT_PIXEL(src[cx >> 16]); ROZ_PLOT_PIXEL(src[cx >> 16]);
*pri = (*pri & (priority >> 8)) | priority; if (priority != 0xff00)
*pri = (*pri & (priority >> 8)) | priority;
} }
// advance in X // advance in X
cx += incxx; cx += incxx;
x++; x++;
++dest; ++dest;
pri++; if (priority != 0xff00)
pri++;
} }
} }
@ -1438,7 +1440,7 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
// get dest and priority pointers // get dest and priority pointers
typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx); typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx);
u8 *pri = &priority_bitmap.pix8(sy, sx); u8 *pri = (priority != 0xff00) ? &priority_bitmap.pix8(sy, sx) : nullptr;
// loop over columns // loop over columns
while (x <= ex) while (x <= ex)
@ -1447,7 +1449,8 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
if ((m_flagsmap.pix8((cy >> 16) & ymask, (cx >> 16) & xmask) & mask) == value) if ((m_flagsmap.pix8((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.pix16((cy >> 16) & ymask, (cx >> 16) & xmask));
*pri = (*pri & (priority >> 8)) | priority; if (priority != 0xff00)
*pri = (*pri & (priority >> 8)) | priority;
} }
// advance in X // advance in X
@ -1455,7 +1458,8 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
cy += incxy; cy += incxy;
x++; x++;
++dest; ++dest;
pri++; if (priority != 0xff00)
pri++;
} }
// advance in Y // advance in Y
@ -1478,7 +1482,7 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
// get dest and priority pointers // get dest and priority pointers
typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx); typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx);
u8 *pri = &priority_bitmap.pix8(sy, sx); u8 *pri = (priority != 0xff00) ? &priority_bitmap.pix8(sy, sx) : nullptr;
// loop over columns // loop over columns
while (x <= ex) while (x <= ex)
@ -1488,7 +1492,8 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
if ((m_flagsmap.pix8(cy >> 16, cx >> 16) & mask) == value) if ((m_flagsmap.pix8(cy >> 16, cx >> 16) & mask) == value)
{ {
ROZ_PLOT_PIXEL(m_pixmap.pix16(cy >> 16, cx >> 16)); ROZ_PLOT_PIXEL(m_pixmap.pix16(cy >> 16, cx >> 16));
*pri = (*pri & (priority >> 8)) | priority; if (priority != 0xff00)
*pri = (*pri & (priority >> 8)) | priority;
} }
// advance in X // advance in X
@ -1496,7 +1501,8 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c
cy += incxy; cy += incxy;
x++; x++;
++dest; ++dest;
pri++; if (priority != 0xff00)
pri++;
} }
// advance in Y // advance in Y