contra.cpp: catch and fix spriteram buffer overflow [Angelo Salese]

This commit is contained in:
angelosa 2018-09-29 15:11:45 +02:00 committed by Angelo Salese
parent 96bfa5f2a0
commit 064401bf00
3 changed files with 7 additions and 5 deletions

View File

@ -86,11 +86,11 @@ void contra_state::contra_map(address_map &map)
map(0x2400, 0x27ff).w(FUNC(contra_state::contra_fg_vram_w)).share("fg_vram"); map(0x2400, 0x27ff).w(FUNC(contra_state::contra_fg_vram_w)).share("fg_vram");
map(0x2800, 0x2bff).w(FUNC(contra_state::contra_text_cram_w)).share("tx_cram"); map(0x2800, 0x2bff).w(FUNC(contra_state::contra_text_cram_w)).share("tx_cram");
map(0x2c00, 0x2fff).w(FUNC(contra_state::contra_text_vram_w)).share("tx_vram"); map(0x2c00, 0x2fff).w(FUNC(contra_state::contra_text_vram_w)).share("tx_vram");
map(0x3000, 0x37ff).writeonly().share("spriteram");/* 2nd bank is at 0x5000 */ map(0x3000, 0x3fff).ram().share("spriteram");
map(0x3800, 0x3fff).writeonly(); // second sprite buffer
map(0x4000, 0x43ff).w(FUNC(contra_state::contra_bg_cram_w)).share("bg_cram"); map(0x4000, 0x43ff).w(FUNC(contra_state::contra_bg_cram_w)).share("bg_cram");
map(0x4400, 0x47ff).w(FUNC(contra_state::contra_bg_vram_w)).share("bg_vram"); map(0x4400, 0x47ff).w(FUNC(contra_state::contra_bg_vram_w)).share("bg_vram");
map(0x4800, 0x5fff).writeonly(); map(0x4800, 0x4fff).ram();
map(0x5000, 0x5fff).ram().share("spriteram_2");
map(0x6000, 0x7fff).bankr("bank1"); map(0x6000, 0x7fff).bankr("bank1");
map(0x7000, 0x7000).w(FUNC(contra_state::contra_bankswitch_w)); map(0x7000, 0x7000).w(FUNC(contra_state::contra_bankswitch_w));

View File

@ -20,6 +20,7 @@ public:
m_tx_cram(*this, "tx_cram"), m_tx_cram(*this, "tx_cram"),
m_tx_vram(*this, "tx_vram"), m_tx_vram(*this, "tx_vram"),
m_spriteram(*this, "spriteram"), m_spriteram(*this, "spriteram"),
m_spriteram_2(*this, "spriteram_2"),
m_bg_cram(*this, "bg_cram"), m_bg_cram(*this, "bg_cram"),
m_bg_vram(*this, "bg_vram"), m_bg_vram(*this, "bg_vram"),
m_audiocpu(*this, "audiocpu"), m_audiocpu(*this, "audiocpu"),
@ -38,6 +39,7 @@ public:
required_shared_ptr<uint8_t> m_tx_cram; required_shared_ptr<uint8_t> m_tx_cram;
required_shared_ptr<uint8_t> m_tx_vram; required_shared_ptr<uint8_t> m_tx_vram;
required_shared_ptr<uint8_t> m_spriteram; required_shared_ptr<uint8_t> m_spriteram;
required_shared_ptr<uint8_t> m_spriteram_2;
required_shared_ptr<uint8_t> m_bg_cram; required_shared_ptr<uint8_t> m_bg_cram;
required_shared_ptr<uint8_t> m_bg_vram; required_shared_ptr<uint8_t> m_bg_vram;

View File

@ -239,9 +239,9 @@ WRITE8_MEMBER(contra_state::contra_K007121_ctrl_1_w)
if (offset == 3) if (offset == 3)
{ {
if ((data & 0x8) == 0) if ((data & 0x8) == 0)
memcpy(m_buffered_spriteram_2.get(), m_spriteram + 0x2800, 0x800); memcpy(m_buffered_spriteram_2.get(), m_spriteram_2 + 0x800, 0x800);
else else
memcpy(m_buffered_spriteram_2.get(), m_spriteram + 0x2000, 0x800); memcpy(m_buffered_spriteram_2.get(), m_spriteram_2 + 0x000, 0x800);
} }
if (offset == 6) if (offset == 6)
{ {