Skip to content

Commit c41a16b

Browse files
committed
amiga/amiga_v.cpp: guard against out of bounds bitmap writes
- fix: #9936 - fix: MT8483
1 parent 2224f3d commit c41a16b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/mame/amiga/amiga_v.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ void amiga_state::render_scanline(bitmap_rgb32 &bitmap, int scanline)
550550
for (int x = 0; x < (amiga_state::SCREEN_WIDTH / 2) + 10; x++)
551551
{
552552
int sprpix;
553+
const bool out_of_beam = x >= amiga_state::SCREEN_WIDTH / 2;
553554

554555
/* time to execute the copper? */
555556
if (x == next_copper_x)
@@ -600,9 +601,11 @@ void amiga_state::render_scanline(bitmap_rgb32 &bitmap, int scanline)
600601
}
601602

602603
/* clear the target pixels to the background color as a starting point */
603-
if (dst != nullptr)
604+
if (dst != nullptr && !out_of_beam)
605+
{
604606
dst[x*2+0] =
605607
dst[x*2+1] = m_palette->pen(CUSTOM_REG(REG_COLOR00));
608+
}
606609

607610
/* if we hit the first fetch pixel, reset the counters and latch the delays */
608611
if (x == ddf_start_pixel)
@@ -742,7 +745,7 @@ void amiga_state::render_scanline(bitmap_rgb32 &bitmap, int scanline)
742745
CUSTOM_REG(REG_CLXDAT) |= 0x001;
743746

744747
/* if we are within the display region, render */
745-
if (dst != nullptr && x >= m_diw.left() && x < m_diw.right())
748+
if (dst != nullptr && x >= m_diw.left() && x < m_diw.right() && !out_of_beam)
746749
{
747750
int pix, pri;
748751

src/mame/amiga/amigaaga.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
549549
for (int x = 0; x < (amiga_state::SCREEN_WIDTH / 2) + offset_hack[bitplane_fmode]; x++)
550550
{
551551
int sprpix;
552+
const bool out_of_beam = x >= amiga_state::SCREEN_WIDTH / 2;
552553

553554
/* time to execute the copper? */
554555
if (x == next_copper_x)
@@ -620,7 +621,7 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
620621
}
621622

622623
/* clear the target pixels to the background color as a starting point */
623-
if (dst != nullptr)
624+
if (dst != nullptr && !out_of_beam)
624625
dst[x*2+0] =
625626
dst[x*2+1] = aga_palette[0];
626627

@@ -783,7 +784,7 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
783784
// TODO: CLXCON2
784785

785786
/* if we are within the display region, render */
786-
if (dst != nullptr && x >= m_diw.left() && x < m_diw.right())
787+
if (dst != nullptr && x >= m_diw.left() && x < m_diw.right() && !out_of_beam)
787788
{
788789
int pix, pri;
789790

0 commit comments

Comments
 (0)