diff --git a/src/mame/drivers/rampart.cpp b/src/mame/drivers/rampart.cpp index 291c291eeee..c264881793b 100644 --- a/src/mame/drivers/rampart.cpp +++ b/src/mame/drivers/rampart.cpp @@ -51,32 +51,20 @@ TIMER_DEVICE_CALLBACK_MEMBER(rampart_state::scanline_interrupt) } -void rampart_state::scanline_int_ack_w(uint16_t data) +void rampart_state::scanline_int_ack_w(u16 data) { m_maincpu->set_input_line(M68K_IRQ_4, CLEAR_LINE); } -/************************************* - * - * Initialization - * - *************************************/ - -void rampart_state::machine_reset() -{ -} - - - /************************************* * * Latch write * *************************************/ -void rampart_state::latch_w(offs_t offset, uint16_t data, uint16_t mem_mask) +void rampart_state::latch_w(offs_t offset, u16 data, u16 mem_mask) { /* bit layout in this register: @@ -128,7 +116,7 @@ void rampart_state::main_map(address_map &map) { map.global_mask(0x7fffff); map(0x000000, 0x0fffff).rom(); - map(0x140000, 0x147fff).mirror(0x438000).rom(); /* slapstic goes here */ + map(0x140000, 0x141fff).mirror(0x43e000).bankr(m_slapstic_bank); /* slapstic goes here */ map(0x200000, 0x21ffff).ram().share("bitmap"); map(0x220000, 0x3bffff).nopw(); /* the code blasts right through this when initializing */ map(0x3c0000, 0x3c07ff).mirror(0x019800).rw("palette", FUNC(palette_device::read8), FUNC(palette_device::write8)).umask16(0xff00).share("palette"); @@ -381,7 +369,7 @@ void rampart_state::rampart(machine_config &config) *************************************/ ROM_START( rampart ) - ROM_REGION( 0x148000, "maincpu", 0 ) + ROM_REGION( 0x100000, "maincpu", 0 ) ROM_LOAD16_BYTE( "136082-1033.13l", 0x00000, 0x80000, CRC(5c36795f) SHA1(2f3dcdfd6b04d851aa1082848624687ac0cec9e2) ) ROM_LOAD16_BYTE( "136082-1032.13j", 0x00001, 0x80000, CRC(ec7bc38c) SHA1(72d4dbb11e92c69cb560bbb39d7bbd5e845b1e4d) ) ROM_LOAD16_BYTE( "136082-2031.13l", 0x00000, 0x10000, CRC(07650c7e) SHA1(0a8eec76aefd4fd1515c1a0d5b96f71c674cdce7) ) @@ -408,7 +396,7 @@ ROM_END ROM_START( rampart2p ) - ROM_REGION( 0x148000, "maincpu", 0 ) + ROM_REGION( 0x100000, "maincpu", 0 ) ROM_LOAD16_BYTE( "136082-1033.13l", 0x00000, 0x80000, CRC(5c36795f) SHA1(2f3dcdfd6b04d851aa1082848624687ac0cec9e2) ) ROM_LOAD16_BYTE( "136082-1032.13j", 0x00001, 0x80000, CRC(ec7bc38c) SHA1(72d4dbb11e92c69cb560bbb39d7bbd5e845b1e4d) ) ROM_LOAD16_BYTE( "136082-2051.13kl", 0x00000, 0x20000, CRC(d4e26d0f) SHA1(5106549e6d003711bfd390aa2e19e6e5f33f2cf9) ) @@ -435,7 +423,7 @@ ROM_END ROM_START( rampart2pa ) // original Atari PCB but with mostly hand-written labels, uses smaller ROMs for the main CPU - ROM_REGION( 0x148000, "maincpu", 0 ) + ROM_REGION( 0x100000, "maincpu", 0 ) ROM_LOAD16_BYTE( "0h.13k-l", 0x00000, 0x20000, CRC(d4e26d0f) SHA1(5106549e6d003711bfd390aa2e19e6e5f33f2cf9) ) ROM_LOAD16_BYTE( "0l.13h", 0x00001, 0x20000, CRC(ed2a49bd) SHA1(b97ee41b7f930ba7b8b113c1b19c7729a5880b1f) ) ROM_LOAD16_BYTE( "1h.13l", 0x40000, 0x20000, CRC(b232b807) SHA1(1e405371595d97d44dec97387a0dedc6bc1ad1d2) ) @@ -466,7 +454,7 @@ ROM_END ROM_START( rampartj ) - ROM_REGION( 0x148000, "maincpu", 0 ) + ROM_REGION( 0x100000, "maincpu", 0 ) ROM_LOAD16_BYTE( "136082-3451.bin", 0x00000, 0x20000, CRC(c6596d32) SHA1(3e3e0cbb3b5fc6dd9685bbc4b18c22e0858d9282) ) ROM_LOAD16_BYTE( "136082-3450.bin", 0x00001, 0x20000, CRC(563b33cc) SHA1(8b454bc19644f1d3d76e4a13f08071cf5eab36e2) ) ROM_LOAD16_BYTE( "136082-1463.bin", 0x40000, 0x20000, CRC(65fe3491) SHA1(3aa3b98fb7fe808ef89e100b5e1ee1c99c4312b6) ) @@ -503,14 +491,26 @@ ROM_END * *************************************/ -void rampart_state::init_rampart() +void rampart_state::slapstic_tweak(offs_t offset, u16 &, u16) { - uint8_t *rom = memregion("maincpu")->base(); - - memcpy(&rom[0x140000], &rom[0x40000], 0x8000); - m_slapstic->legacy_configure(*m_maincpu, 0x140000, 0x438000, memregion("maincpu")->base() + 0x140000); + m_slapstic->slapstic_tweak(m_maincpu->space(AS_PROGRAM), (offset >> 1) & 0x3fff); + m_slapstic_bank->set_entry(m_slapstic->slapstic_bank()); } +void rampart_state::machine_start() +{ + m_slapstic->slapstic_init(); + m_slapstic_bank->configure_entries(0, 4, memregion("maincpu")->base() + 0x40000, 0x2000); + m_maincpu->space(AS_PROGRAM).install_readwrite_tap(0x140000, 0x147fff, 0x438000, "slapstic", + [this](offs_t offset, u16 &data, u16 mem_mask) { slapstic_tweak(offset, data, mem_mask); }, + [this](offs_t offset, u16 &data, u16 mem_mask) { slapstic_tweak(offset, data, mem_mask); }); +} + +void rampart_state::machine_reset() +{ + m_slapstic->slapstic_reset(); + m_slapstic_bank->set_entry(m_slapstic->slapstic_bank()); +} /************************************* @@ -519,7 +519,7 @@ void rampart_state::init_rampart() * *************************************/ -GAME( 1990, rampart, 0, rampart, rampart, rampart_state, init_rampart, ROT0, "Atari Games", "Rampart (Trackball)", MACHINE_SUPPORTS_SAVE ) -GAME( 1990, rampart2p, rampart, rampart, ramprt2p, rampart_state, init_rampart, ROT0, "Atari Games", "Rampart (Joystick, bigger ROMs)", MACHINE_SUPPORTS_SAVE ) -GAME( 1990, rampart2pa, rampart, rampart, ramprt2p, rampart_state, init_rampart, ROT0, "Atari Games", "Rampart (Joystick, smaller ROMs)", MACHINE_SUPPORTS_SAVE ) -GAME( 1990, rampartj, rampart, rampart, rampartj, rampart_state, init_rampart, ROT0, "Atari Games", "Rampart (Japan, Joystick)", MACHINE_SUPPORTS_SAVE ) +GAME( 1990, rampart, 0, rampart, rampart, rampart_state, empty_init, ROT0, "Atari Games", "Rampart (Trackball)", MACHINE_SUPPORTS_SAVE ) +GAME( 1990, rampart2p, rampart, rampart, ramprt2p, rampart_state, empty_init, ROT0, "Atari Games", "Rampart (Joystick, bigger ROMs)", MACHINE_SUPPORTS_SAVE ) +GAME( 1990, rampart2pa, rampart, rampart, ramprt2p, rampart_state, empty_init, ROT0, "Atari Games", "Rampart (Joystick, smaller ROMs)", MACHINE_SUPPORTS_SAVE ) +GAME( 1990, rampartj, rampart, rampart, rampartj, rampart_state, empty_init, ROT0, "Atari Games", "Rampart (Japan, Joystick)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/includes/rampart.h b/src/mame/includes/rampart.h index 7ee6c0eff43..c1d59bc4152 100644 --- a/src/mame/includes/rampart.h +++ b/src/mame/includes/rampart.h @@ -24,6 +24,7 @@ public: driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_slapstic(*this, "slapstic"), + m_slapstic_bank(*this, "slapstic_bank"), m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), m_mob(*this, "mob"), @@ -36,29 +37,33 @@ public: void rampart(machine_config &config); protected: + virtual void machine_start() override; virtual void machine_reset() override; virtual void video_start() override; private: TIMER_DEVICE_CALLBACK_MEMBER(scanline_interrupt); - void scanline_int_ack_w(uint16_t data); - void latch_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint32_t screen_update_rampart(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void scanline_int_ack_w(u16 data); + void latch_w(offs_t offset, u16 data, u16 mem_mask = ~0); + u32 screen_update_rampart(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void rampart_bitmap_render(bitmap_ind16 &bitmap, const rectangle &cliprect); void main_map(address_map &map); required_device m_maincpu; required_device m_slapstic; + required_memory_bank m_slapstic_bank; required_device m_gfxdecode; required_device m_screen; required_device m_mob; required_device m_oki; required_device m_ym2413; - required_shared_ptr m_bitmap; + required_shared_ptr m_bitmap; static const atari_motion_objects_config s_mob_config; + + void slapstic_tweak(offs_t offset, u16 &, u16); }; #endif // MAME_INCLUDES_RAMPART_H diff --git a/src/mame/machine/slapstic.cpp b/src/mame/machine/slapstic.cpp index 2bf689ead19..dba5e00f780 100644 --- a/src/mame/machine/slapstic.cpp +++ b/src/mame/machine/slapstic.cpp @@ -194,7 +194,7 @@ * *************************************/ -#define LOG_SLAPSTIC (0) +#define LOG_SLAPSTIC (1) @@ -1086,7 +1086,7 @@ int atari_slapstic_device::slapstic_tweak(address_space &space, offs_t offset) /* log this access */ if (LOG_SLAPSTIC) - slapstic_log(machine(), offset); + slapstic_log(offset); /* return the active bank */ return current_bank; @@ -1100,59 +1100,25 @@ int atari_slapstic_device::slapstic_tweak(address_space &space, offs_t offset) * *************************************/ -void atari_slapstic_device::slapstic_log(running_machine &machine, offs_t offset) +void atari_slapstic_device::slapstic_log(offs_t offset) { - static attotime last_time; - - if (!slapsticlog) - slapsticlog = fopen("slapstic.log", "w"); - if (slapsticlog) + const char *mode = "UNKNOWN"; + switch (state) { - attotime time = machine.time(); - - if ((time - last_time) > attotime::from_seconds(1)) - fprintf(slapsticlog, "------------------------------------\n"); - last_time = time; - - fprintf(slapsticlog, "%s: %04X B=%d ", machine.describe_context().c_str(), offset, current_bank); - switch (state) - { - case DISABLED: - fprintf(slapsticlog, "DISABLED\n"); - break; - case ENABLED: - fprintf(slapsticlog, "ENABLED\n"); - break; - case ALTERNATE1: - fprintf(slapsticlog, "ALTERNATE1\n"); - break; - case ALTERNATE2: - fprintf(slapsticlog, "ALTERNATE2\n"); - break; - case ALTERNATE3: - fprintf(slapsticlog, "ALTERNATE3\n"); - break; - case BITWISE1: - fprintf(slapsticlog, "BITWISE1\n"); - break; - case BITWISE2: - fprintf(slapsticlog, "BITWISE2\n"); - break; - case BITWISE3: - fprintf(slapsticlog, "BITWISE3\n"); - break; - case ADDITIVE1: - fprintf(slapsticlog, "ADDITIVE1\n"); - break; - case ADDITIVE2: - fprintf(slapsticlog, "ADDITIVE2\n"); - break; - case ADDITIVE3: - fprintf(slapsticlog, "ADDITIVE3\n"); - break; - } - fflush(slapsticlog); + case DISABLED: mode = "DISABLED"; break; + case ENABLED: mode = "ENABLED"; break; + case ALTERNATE1: mode = "ALTERNATE1"; break; + case ALTERNATE2: mode = "ALTERNATE2"; break; + case ALTERNATE3: mode = "ALTERNATE3"; break; + case BITWISE1: mode = "BITWISE1"; break; + case BITWISE2: mode = "BITWISE2"; break; + case BITWISE3: mode = "BITWISE3"; break; + case ADDITIVE1: mode = "ADDITIVE1"; break; + case ADDITIVE2: mode = "ADDITIVE2"; break; + case ADDITIVE3: mode = "ADDITIVE3"; break; } + + logerror("%s: %04x B=%d AB=%d %s %s\n", machine().time().as_string(), offset, current_bank, add_bank, mode, machine().describe_context()); } @@ -1213,7 +1179,7 @@ void atari_slapstic_device::slapstic_w(offs_t offset, u16 data, u16 mem_mask) { assert(m_legacy_configured); - legacy_update_bank(slapstic_tweak(*m_legacy_space, offset)); + // legacy_update_bank(slapstic_tweak(*m_legacy_space, offset)); } diff --git a/src/mame/machine/slapstic.h b/src/mame/machine/slapstic.h index 33a12ba72f7..97b6cdd5858 100644 --- a/src/mame/machine/slapstic.h +++ b/src/mame/machine/slapstic.h @@ -144,8 +144,7 @@ public: struct slapstic_data slapstic; - void slapstic_log(running_machine &machine, offs_t offset); - FILE *slapsticlog; + void slapstic_log(offs_t offset); // legacy interface void legacy_configure(cpu_device &device, offs_t base, offs_t mirror, u8 *mem);