From efcbd6106a1bcaa54aa0c30a6e18ecf1f216b641 Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 15 Apr 2021 16:50:17 +0200 Subject: tasc/chessmachine/modular_tm: use install_ram/rom for the bootrom bankswitch (small speed optimization) --- src/devices/machine/chessmachine.cpp | 41 +++++++++++++---------- src/devices/machine/chessmachine.h | 13 ++++---- src/mame/drivers/mephisto_modular_tm.cpp | 23 ++++++++++--- src/mame/drivers/tasc.cpp | 57 ++++++++++++++++++-------------- 4 files changed, 81 insertions(+), 53 deletions(-) diff --git a/src/devices/machine/chessmachine.cpp b/src/devices/machine/chessmachine.cpp index c9a00f33dda..08e45ebb581 100644 --- a/src/devices/machine/chessmachine.cpp +++ b/src/devices/machine/chessmachine.cpp @@ -28,7 +28,7 @@ probably went for this solution to get optimum possible speed for each module. TODO: - PC version still gives a sync error on boot sometimes, probably related to quantum - is interrupt handling correct? -- timer shouldn't be needed for disabling bootstrap, real ARM has already read the next opcode +- timer shouldn't be needed for disabling bootrom, real ARM has already read the next opcode */ @@ -45,9 +45,9 @@ DEFINE_DEVICE_TYPE(CHESSMACHINE, chessmachine_device, "chessmachine", "Tasc Ches chessmachine_device::chessmachine_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, CHESSMACHINE, tag, owner, clock), m_maincpu(*this, "maincpu"), - m_bootstrap(*this, "bootstrap"), + m_bootrom(*this, "bootrom"), m_ram(*this, "ram"), - m_disable_bootstrap(*this, "disable_bootstrap"), + m_disable_bootrom(*this, "disable_bootrom"), m_data_out(*this) { } @@ -63,11 +63,11 @@ void chessmachine_device::device_start() m_data_out.resolve_safe(); // zerofill - m_bootstrap_enabled = false; + m_bootrom_enabled = false; m_latch[0] = m_latch[1] = 0; // register for savestates - save_item(NAME(m_bootstrap_enabled)); + save_item(NAME(m_bootrom_enabled)); save_item(NAME(m_latch)); } @@ -104,8 +104,8 @@ void chessmachine_device::reset_w(int state) { m_maincpu->set_input_line(INPUT_LINE_RESET, state ? ASSERT_LINE : CLEAR_LINE); - if (state) - m_bootstrap_enabled = true; + if (!m_bootrom_enabled && state) + install_bootrom(true); } @@ -114,16 +114,24 @@ void chessmachine_device::reset_w(int state) // internal //------------------------------------------------- -u32 chessmachine_device::bootstrap_r(offs_t offset) +void chessmachine_device::install_bootrom(bool enable) { - return (m_bootstrap_enabled) ? m_bootstrap[offset] : m_ram[offset]; + address_space &program = m_maincpu->space(AS_PROGRAM); + program.unmap_readwrite(0, m_bootrom.bytes() - 1); + + if (enable) + program.install_rom(0, m_bootrom.bytes() - 1, m_bootrom); + else + program.install_ram(0, m_ram.bytes() - 1, m_ram); + + m_bootrom_enabled = enable; } -u32 chessmachine_device::disable_bootstrap_r() +u32 chessmachine_device::disable_bootrom_r() { - // disconnect bootstrap rom from the bus after next opcode - if (m_bootstrap_enabled && !m_disable_bootstrap->enabled() && !machine().side_effects_disabled()) - m_disable_bootstrap->adjust(m_maincpu->cycles_to_attotime(5)); + // disconnect bootrom from the bus after next opcode + if (m_bootrom_enabled && !m_disable_bootrom->enabled() && !machine().side_effects_disabled()) + m_disable_bootrom->adjust(m_maincpu->cycles_to_attotime(5)); return 0; } @@ -131,9 +139,8 @@ u32 chessmachine_device::disable_bootstrap_r() void chessmachine_device::main_map(address_map &map) { map(0x00000000, 0x000fffff).ram().share("ram"); - map(0x00000000, 0x0000007f).r(FUNC(chessmachine_device::bootstrap_r)); map(0x00400000, 0x00400003).mirror(0x003ffffc).rw(FUNC(chessmachine_device::internal_r), FUNC(chessmachine_device::internal_w)).umask32(0x000000ff); - map(0x01800000, 0x01800003).r(FUNC(chessmachine_device::disable_bootstrap_r)); + map(0x01800000, 0x01800003).r(FUNC(chessmachine_device::disable_bootrom_r)); } void chessmachine_device::device_add_mconfig(machine_config &config) @@ -142,7 +149,7 @@ void chessmachine_device::device_add_mconfig(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &chessmachine_device::main_map); m_maincpu->set_copro_type(arm_cpu_device::copro_type::VL86C020); - TIMER(config, "disable_bootstrap").configure_generic(FUNC(chessmachine_device::disable_bootstrap)); + TIMER(config, "disable_bootrom").configure_generic(FUNC(chessmachine_device::disable_bootrom)); } @@ -152,7 +159,7 @@ void chessmachine_device::device_add_mconfig(machine_config &config) //------------------------------------------------- ROM_START( chessmachine ) - ROM_REGION32_LE( 0x80, "bootstrap", 0 ) + ROM_REGION32_LE( 0x80, "bootrom", 0 ) ROM_LOAD32_BYTE( "74s288.1", 0x00, 0x20, CRC(284114e2) SHA1(df4037536d505d7240bb1d70dc58f59a34ab77b4) ) ROM_LOAD32_BYTE( "74s288.2", 0x01, 0x20, CRC(9f239c75) SHA1(aafaf30dac90f36b01f9ee89903649fc4ea0480d) ) ROM_LOAD32_BYTE( "74s288.3", 0x02, 0x20, CRC(0455360b) SHA1(f1486142330f2c39a4d6c479646030d31443d1c8) ) diff --git a/src/devices/machine/chessmachine.h b/src/devices/machine/chessmachine.h index 4d589fc97c3..db670ff8dc6 100644 --- a/src/devices/machine/chessmachine.h +++ b/src/devices/machine/chessmachine.h @@ -34,14 +34,15 @@ protected: virtual void device_start() override; virtual void device_reset_after_children() override { reset_w(1); } virtual void device_add_mconfig(machine_config &config) override; + virtual void device_post_load() override { install_bootrom(m_bootrom_enabled); } virtual const tiny_rom_entry *device_rom_region() const override; private: required_device m_maincpu; - required_region_ptr m_bootstrap; + required_region_ptr m_bootrom; required_shared_ptr m_ram; - required_device m_disable_bootstrap; + required_device m_disable_bootrom; devcb_write_line m_data_out; @@ -49,10 +50,10 @@ private: void sync0_callback(void *ptr, s32 param); void sync1_callback(void *ptr, s32 param); - bool m_bootstrap_enabled; - TIMER_DEVICE_CALLBACK_MEMBER(disable_bootstrap) { m_bootstrap_enabled = false; } - u32 disable_bootstrap_r(); - u32 bootstrap_r(offs_t offset); + bool m_bootrom_enabled; + void install_bootrom(bool enable); + TIMER_DEVICE_CALLBACK_MEMBER(disable_bootrom) { install_bootrom(false); } + u32 disable_bootrom_r(); u8 internal_r() { return m_latch[0]; } void internal_w(u8 data) { m_latch[1] = data & 1; m_data_out(m_latch[1]); } diff --git a/src/mame/drivers/mephisto_modular_tm.cpp b/src/mame/drivers/mephisto_modular_tm.cpp index fadca7622bb..09562d8fe84 100644 --- a/src/mame/drivers/mephisto_modular_tm.cpp +++ b/src/mame/drivers/mephisto_modular_tm.cpp @@ -76,6 +76,7 @@ public: protected: virtual void machine_start() override; virtual void machine_reset() override; + virtual void device_post_load() override { install_bootrom(m_bootrom_enabled); } private: // devices/pointers @@ -90,9 +91,9 @@ private: void mmtm_8m_map(address_map &map); void nvram_map(address_map &map); - bool m_bootrom_enabled; - TIMER_DEVICE_CALLBACK_MEMBER(disable_bootrom) { m_bootrom_enabled = false; } - u32 bootrom_r(offs_t offset) { return (m_bootrom_enabled) ? m_rom[offset] : m_mainram[offset]; } + void install_bootrom(bool enable); + TIMER_DEVICE_CALLBACK_MEMBER(disable_bootrom) { install_bootrom(false); } + bool m_bootrom_enabled = false; void set_cpu_freq(); }; @@ -107,10 +108,23 @@ void mmtm_state::machine_reset() set_cpu_freq(); // disable bootrom after reset - m_bootrom_enabled = true; + install_bootrom(true); m_disable_bootrom->adjust(m_maincpu->cycles_to_attotime(50)); } +void mmtm_state::install_bootrom(bool enable) +{ + address_space &program = m_maincpu->space(AS_PROGRAM); + program.unmap_readwrite(0, std::max(m_rom.bytes(), m_mainram.bytes()) - 1); + + if (enable) + program.install_rom(0, m_rom.bytes() - 1, m_rom); + else + program.install_ram(0, m_mainram.bytes() - 1, m_mainram); + + m_bootrom_enabled = enable; +} + void mmtm_state::set_cpu_freq() { // "Mephisto X" were usually overclocked at tournaments @@ -140,7 +154,6 @@ void mmtm_state::nvram_map(address_map &map) void mmtm_state::mmtm_2m_map(address_map &map) { map(0x00000000, 0x0003ffff).ram().share("mainram"); - map(0x00000000, 0x0000000b).r(FUNC(mmtm_state::bootrom_r)); map(0x80000000, 0x801fffff).ram(); map(0xf0000000, 0xf003ffff).rom().region("maincpu", 0); map(0xfc000000, 0xfc001fff).m("nvram_map", FUNC(address_map_bank_device::amap8)); diff --git a/src/mame/drivers/tasc.cpp b/src/mame/drivers/tasc.cpp index 097be9d0600..2b5053122ce 100644 --- a/src/mame/drivers/tasc.cpp +++ b/src/mame/drivers/tasc.cpp @@ -40,6 +40,7 @@ TODO: ******************************************************************************/ #include "emu.h" + #include "cpu/arm/arm.h" #include "machine/bankdev.h" #include "machine/nvram.h" @@ -47,8 +48,10 @@ TODO: #include "machine/timer.h" #include "video/t6963c.h" #include "sound/spkrdev.h" + #include "speaker.h" +// internal artwork #include "tascr30.lh" @@ -60,11 +63,11 @@ public: tasc_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), + m_rom(*this, "maincpu"), + m_mainram(*this, "mainram"), m_lcd(*this, "lcd"), m_smartboard(*this, "smartboard"), - m_rom(*this, "maincpu"), m_speaker(*this, "speaker"), - m_mainram(*this, "mainram"), m_disable_bootrom(*this, "disable_bootrom"), m_inputs(*this, "IN.%u", 0U), m_out_leds(*this, "pled%u", 0U) @@ -74,16 +77,17 @@ public: protected: virtual void machine_start() override; - virtual void machine_reset() override; + virtual void machine_reset() override { install_bootrom(true); } + virtual void device_post_load() override { install_bootrom(m_bootrom_enabled); } private: // devices/pointers required_device m_maincpu; + required_region_ptr m_rom; + required_shared_ptr m_mainram; required_device m_lcd; required_device m_smartboard; - required_region_ptr m_rom; required_device m_speaker; - required_shared_ptr m_mainram; required_device m_disable_bootrom; required_ioport_array<4> m_inputs; output_finder<2> m_out_leds; @@ -91,49 +95,53 @@ private: void main_map(address_map &map); void nvram_map(address_map &map); - bool m_bootrom_enabled; - uint32_t m_mux; - TIMER_DEVICE_CALLBACK_MEMBER(disable_bootrom) { m_bootrom_enabled = false; } - // I/O handlers - uint32_t bootrom_r(offs_t offset); - uint32_t p1000_r(); - void p1000_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + u32 p1000_r(); + void p1000_w(offs_t offset, u32 data, u32 mem_mask = ~0); + + void install_bootrom(bool enable); + TIMER_DEVICE_CALLBACK_MEMBER(disable_bootrom) { install_bootrom(false); } + bool m_bootrom_enabled = false; + + u32 m_mux = 0; }; void tasc_state::machine_start() { m_out_leds.resolve(); + save_item(NAME(m_bootrom_enabled)); save_item(NAME(m_mux)); } -void tasc_state::machine_reset() -{ - m_bootrom_enabled = true; - m_mux = 0; -} - /****************************************************************************** I/O ******************************************************************************/ -uint32_t tasc_state::bootrom_r(offs_t offset) +void tasc_state::install_bootrom(bool enable) { - return (m_bootrom_enabled) ? m_rom[offset] : m_mainram[offset]; + address_space &program = m_maincpu->space(AS_PROGRAM); + program.unmap_readwrite(0, std::max(m_rom.bytes(), m_mainram.bytes()) - 1); + + if (enable) + program.install_rom(0, m_rom.bytes() - 1, m_rom); + else + program.install_ram(0, m_mainram.bytes() - 1, m_mainram); + + m_bootrom_enabled = enable; } -uint32_t tasc_state::p1000_r() +u32 tasc_state::p1000_r() { // disconnect bootrom from the bus after next opcode if (m_bootrom_enabled && !m_disable_bootrom->enabled() && !machine().side_effects_disabled()) m_disable_bootrom->adjust(m_maincpu->cycles_to_attotime(5)); - uint32_t data = m_smartboard->read(); + u32 data = m_smartboard->read(); - for(int i=0; i<4; i++) + for (int i = 0; i < 4; i++) { if (BIT(m_mux, i)) data |= (m_inputs[i]->read() << 24); @@ -142,7 +150,7 @@ uint32_t tasc_state::p1000_r() return data; } -void tasc_state::p1000_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void tasc_state::p1000_w(offs_t offset, u32 data, u32 mem_mask) { if (ACCESSING_BITS_24_31) { @@ -170,7 +178,6 @@ void tasc_state::p1000_w(offs_t offset, uint32_t data, uint32_t mem_mask) void tasc_state::main_map(address_map &map) { map(0x00000000, 0x0007ffff).ram().share("mainram"); - map(0x00000000, 0x0000000b).r(FUNC(tasc_state::bootrom_r)); map(0x01000000, 0x01000003).rw(FUNC(tasc_state::p1000_r), FUNC(tasc_state::p1000_w)); map(0x02000000, 0x0203ffff).rom().region("maincpu", 0); map(0x03000000, 0x0307ffff).m("nvram_map", FUNC(address_map_bank_device::amap8)).umask32(0x000000ff); -- cgit v1.2.3