From a5acda1a60ed04d8a2c9b1278d30ead2c1423887 Mon Sep 17 00:00:00 2001 From: 0kmg <9137159+0kmg@users.noreply.github.com> Date: Wed, 15 Dec 2021 08:06:00 -0900 Subject: [PATCH] machine/nes.cpp: Accomodate games that don't initialize RAM. (#8986) Software list items promoted to working (nes.xml) --------------------------------------- Minna no Taabou no Nakayoshi Daisakusen (Japan) [kmg] --- hash/nes.xml | 7 +++---- src/mame/drivers/nes.cpp | 2 +- src/mame/includes/nes.h | 2 ++ src/mame/machine/nes.cpp | 9 +++++++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/hash/nes.xml b/hash/nes.xml index 122ec649bc9..21093cb1898 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -25164,14 +25164,13 @@ license:CC0 - - - Minna no Taabou no Nakayoshi Daisakusen (Jpn) + + Minna no Taabou no Nakayoshi Daisakusen (Japan) 1991 Character Soft - + diff --git a/src/mame/drivers/nes.cpp b/src/mame/drivers/nes.cpp index ee86ce570c3..20ca8933276 100644 --- a/src/mame/drivers/nes.cpp +++ b/src/mame/drivers/nes.cpp @@ -27,7 +27,7 @@ void nes_state::nes_vh_sprite_dma_w(address_space &space, uint8_t data) void nes_state::nes_map(address_map &map) { - map(0x0000, 0x07ff).ram().mirror(0x1800); // RAM + map(0x0000, 0x07ff).ram().mirror(0x1800).share("mainram"); // RAM map(0x2000, 0x3fff).rw(m_ppu, FUNC(ppu2c0x_device::read), FUNC(ppu2c0x_device::write)); // PPU registers map(0x4014, 0x4014).w(FUNC(nes_state::nes_vh_sprite_dma_w)); // stupid address space hole map(0x4016, 0x4016).rw(FUNC(nes_state::nes_in0_r), FUNC(nes_state::nes_in0_w)); // IN0 - input port 1 diff --git a/src/mame/includes/nes.h b/src/mame/includes/nes.h index c05a4e5126e..72ad3edb939 100644 --- a/src/mame/includes/nes.h +++ b/src/mame/includes/nes.h @@ -72,6 +72,7 @@ class nes_state : public nes_base_state public: nes_state(const machine_config &mconfig, device_type type, const char *tag) : nes_base_state(mconfig, type, tag), + m_mainram(*this, "mainram"), m_ppu(*this, "ppu"), m_screen(*this, "screen"), m_exp(*this, "exp"), @@ -125,6 +126,7 @@ private: uint8_t *m_vram; std::unique_ptr m_ciram; //PPU nametable RAM - external to PPU! + required_shared_ptr m_mainram; required_device m_ppu; required_device m_screen; diff --git a/src/mame/machine/nes.cpp b/src/mame/machine/nes.cpp index fd8c87848b5..8b3530cbe55 100644 --- a/src/mame/machine/nes.cpp +++ b/src/mame/machine/nes.cpp @@ -43,6 +43,15 @@ void nes_state::machine_start() { address_space &space = m_maincpu->space(AS_PROGRAM); + // Fill main RAM with an arbitrary pattern (alternating 0x00/0xff) for software that depends on its contents at boot up (tsk tsk!) + // The fill value is a compromise since certain games malfunction with zero-filled memory, others with one-filled memory + // Examples: Minna no Taabou won't boot with all 0x00, Sachen's Dancing Block won't boot with all 0xff, Terminator 2 skips its copyright screen with all 0x00 + for (int i = 0; i < 0x800; i += 2) + { + m_mainram[i] = 0x00; + m_mainram[i + 1] = 0xff; + } + // CIRAM (Character Internal RAM) // NES has 2KB of internal RAM which can be used to fill the 4x1KB banks of PPU RAM at $2000-$2fff // Line A10 is exposed to the carts, so that games can change CIRAM mapping in PPU (we emulate this with the set_nt_mirroring