@@ -470,32 +470,30 @@ void k053247_device::zdrawgfxzoom32GP(
470470 if (alpha >= 255 ) drawmode &= ~2 ;
471471 }
472472
473- u32 *dst_ptr = &bitmap.pix (0 );
474- const int dst_pitch = bitmap.rowpixels ();
475- const int dst_minx = cliprect.min_x ;
476- const int dst_maxx = cliprect.max_x ;
477- const int dst_miny = cliprect.min_y ;
478- const int dst_maxy = cliprect.max_y ;
479- int dst_x = sx;
480- int dst_y = sy;
481-
482473 // cull off-screen objects
483- if (dst_x > dst_maxx || dst_y > dst_maxy ) return ;
474+ if (sx > cliprect. max_x || sy > cliprect. max_y ) return ;
484475
485476 // fill internal data structure with default values
486- u8 *ozbuf_ptr = gx_objzbuf;
487- u8 *szbuf_ptr = gx_shdzbuf;
477+ u8 *ozbuf_ptr = gx_objzbuf;
478+ u8 *szbuf_ptr = gx_shdzbuf;
488479
489- int src_pitch = 16 ;
490- int src_fw = 16 ;
491- int src_fh = 16 ;
492- const u8 *src_base = m_gfx->get_data (code % m_gfx->elements ());
480+ const u8 *src_base = m_gfx->get_data (code % m_gfx->elements ());
493481
494482 const pen_t *pal_base = palette ().pens () + m_gfx->colorbase () + (color % m_gfx->colors ()) * granularity;
495483 const pen_t *shd_base = palette ().shadow_table ();
496484
485+ u32 *dst_ptr = &bitmap.pix (0 );
486+ const int dst_pitch = bitmap.rowpixels ();
487+ const int dst_minx = cliprect.min_x ;
488+ const int dst_maxx = cliprect.max_x ;
489+ const int dst_miny = cliprect.min_y ;
490+ const int dst_maxy = cliprect.max_y ;
491+ int dst_x = sx;
492+ int dst_y = sy;
493+
497494 int dst_w, dst_h;
498495 int src_fdx, src_fdy;
496+ int src_pitch = 16 , src_fw = 16 , src_fh = 16 ;
499497
500498 const bool nozoom = (scalex == 0x10000 && scaley == 0x10000 );
501499 if (nozoom)
@@ -515,17 +513,27 @@ void k053247_device::zdrawgfxzoom32GP(
515513 src_fdy = src_fh / dst_h;
516514 }
517515 const int dst_lastx = dst_x + dst_w - 1 ;
518- if (dst_lastx < dst_minx) return ;
519516 const int dst_lasty = dst_y + dst_h - 1 ;
520- if (dst_lasty < dst_miny) return ;
517+ if (dst_lastx < dst_minx || dst_lasty < dst_miny) return ;
521518
522519 // clip destination
523520 int dst_skipx = 0 ;
524- int eax = dst_minx; if ((eax -= dst_x) > 0 ) { dst_skipx = eax; dst_w -= eax; dst_x = dst_minx; }
525- eax = dst_lastx; if ((eax -= dst_maxx) > 0 ) dst_w -= eax;
521+ if (int eax = dst_minx - dst_x; eax > 0 )
522+ {
523+ dst_skipx = eax;
524+ dst_w -= eax;
525+ dst_x = dst_minx;
526+ }
527+ if (int eax = dst_lastx - dst_maxx; eax > 0 ) dst_w -= eax;
528+
526529 int dst_skipy = 0 ;
527- eax = dst_miny; if ((eax -= dst_y) > 0 ) { dst_skipy = eax; dst_h -= eax; dst_y = dst_miny; }
528- eax = dst_lasty; if ((eax -= dst_maxy) > 0 ) dst_h -= eax;
530+ if (int eax = dst_miny - dst_y; eax > 0 )
531+ {
532+ dst_skipy = eax;
533+ dst_h -= eax;
534+ dst_y = dst_miny;
535+ }
536+ if (int eax = dst_lasty - dst_maxy; eax > 0 ) dst_h -= eax;
529537
530538 int src_fby, src_fbx;
531539
@@ -544,11 +552,11 @@ void k053247_device::zdrawgfxzoom32GP(
544552 src_fby += dst_skipy * src_fdy;
545553
546554 // adjust insertion points and pre-entry constants
547- eax = (dst_y - dst_miny) * GX_ZBUFW + (dst_x - dst_minx) + dst_w;
548- const u8 z8 = (u8 )zcode;
549- const u8 p8 = (u8 )pri;
555+ const int eax = (dst_y - dst_miny) * GX_ZBUFW + (dst_x - dst_minx) + dst_w;
550556 ozbuf_ptr += eax;
551557 szbuf_ptr += eax << 1 ;
558+ const u8 z8 = (u8 )zcode;
559+ const u8 p8 = (u8 )pri;
552560 dst_ptr += dst_y * dst_pitch + dst_x + dst_w;
553561 dst_w = -dst_w;
554562
0 commit comments