From a8e009eee6c1f1d6843cc67c4766ced3396ee8e9 Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 4 Nov 2024 11:53:25 +0100 Subject: coolpool: add vram mirror, merge driver files --- src/devices/cpu/tms32010/tms32010.cpp | 12 +- src/mame/misc/coolpool.cpp | 207 ++++++++++++++++++++++++++++++---- src/mame/misc/coolpool.h | 166 --------------------------- 3 files changed, 189 insertions(+), 196 deletions(-) delete mode 100644 src/mame/misc/coolpool.h diff --git a/src/devices/cpu/tms32010/tms32010.cpp b/src/devices/cpu/tms32010/tms32010.cpp index 4afaee0cdef..bd2d0271054 100644 --- a/src/devices/cpu/tms32010/tms32010.cpp +++ b/src/devices/cpu/tms32010/tms32010.cpp @@ -870,12 +870,8 @@ void tms3201x_base_device::device_start() save_item(NAME(m_ALU.d)); save_item(NAME(m_Preg.d)); save_item(NAME(m_Treg)); - save_item(NAME(m_AR[0])); - save_item(NAME(m_AR[1])); - save_item(NAME(m_STACK[0])); - save_item(NAME(m_STACK[1])); - save_item(NAME(m_STACK[2])); - save_item(NAME(m_STACK[3])); + save_item(NAME(m_AR)); + save_item(NAME(m_STACK)); save_item(NAME(m_INTF)); save_item(NAME(m_opcode.d)); save_item(NAME(m_oldacc.d)); @@ -987,7 +983,7 @@ int tms3201x_base_device::Ext_IRQ() { if (INTM == 0) { - logerror("TMS32010: EXT INTERRUPT\n"); + standard_irq_callback(0, m_PC); m_INTF = TMS32010_INT_NONE; SET_FLAG(INTM_FLAG); PUSH_STACK(m_PC); @@ -1008,7 +1004,7 @@ void tms3201x_base_device::execute_run() do { if (m_INTF) { - /* Dont service INT if previous instruction was MPY, MPYK or EINT */ + /* Don't service INT if previous instruction was MPY, MPYK or EINT */ if ((m_opcode.b.h != 0x6d) && ((m_opcode.b.h & 0xe0) != 0x80) && (m_opcode.w.l != 0x7f82)) m_icount -= Ext_IRQ(); } diff --git a/src/mame/misc/coolpool.cpp b/src/mame/misc/coolpool.cpp index 365383a5026..3f165a3da97 100644 --- a/src/mame/misc/coolpool.cpp +++ b/src/mame/misc/coolpool.cpp @@ -28,12 +28,17 @@ ***************************************************************************/ #include "emu.h" -#include "coolpool.h" #include "cpu/tms32010/tms32010.h" #include "cpu/tms32025/tms32025.h" +#include "cpu/tms34010/tms34010.h" +#include "machine/gen_latch.h" #include "machine/nvram.h" +#include "machine/timer.h" #include "sound/dac.h" +#include "video/tlc34076.h" + +#include "emupal.h" #include "screen.h" #include "speaker.h" @@ -50,14 +55,168 @@ #define LOGPORT(...) LOGMASKED(LOG_PORT, __VA_ARGS__) #define LOGINPUT(...) LOGMASKED(LOG_INPUT, __VA_ARGS__) + +namespace { + +class coolpool_base_state : public driver_device +{ +protected: + coolpool_base_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + , m_dsp(*this, "dsp") + , m_main2dsp(*this, "main2dsp") + , m_dsp2main(*this, "dsp2main") + , m_nvram_timer(*this, "nvram_timer") + , m_vram_base(*this, "vram_base") + , m_nvram(*this, "nvram") + , m_dsp_rom(*this, "dspdata") + { } + + virtual void machine_start() override ATTR_COLD; + virtual void machine_reset() override ATTR_COLD; + + static constexpr unsigned NVRAM_UNLOCK_SEQ_LEN = 10; + + required_device m_maincpu; + required_device m_dsp; + + required_device m_main2dsp; + required_device m_dsp2main; + + required_device m_nvram_timer; + + required_shared_ptr m_vram_base; + required_shared_ptr m_nvram; + required_region_ptr m_dsp_rom; + + uint32_t m_iop_romaddr = 0; + + uint8_t m_newx[3]{}; + uint8_t m_newy[3]{}; + uint8_t m_oldx[3]{}; + uint8_t m_oldy[3]{}; + int m_dx[3]{}; + int m_dy[3]{}; + + uint16_t m_result = 0U; + uint16_t m_lastresult = 0U; + + uint16_t m_nvram_write_seq[NVRAM_UNLOCK_SEQ_LEN]{}; + uint8_t m_nvram_write_enable = 0U; + uint8_t m_same_cmd_count = 0U; + + void nvram_thrash_w(offs_t offset, uint16_t data); + void nvram_data_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void nvram_thrash_data_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + + uint16_t dsp_rom_r(); + void dsp_romaddr_w(offs_t offset, uint16_t data); + + TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg); + TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg); + + TIMER_DEVICE_CALLBACK_MEMBER(nvram_write_timeout); +}; + +class amerdart_state : public coolpool_base_state +{ +public: + amerdart_state(const machine_config &mconfig, device_type type, const char *tag) + : coolpool_base_state(mconfig, type, tag) + , m_palette(*this, "palette") + , m_in_xaxis(*this, "XAXIS%u", 1U) + , m_in_yaxis(*this, "YAXIS%u", 1U) + { } + + void amerdart(machine_config &config); + +protected: + virtual void machine_start() override ATTR_COLD; + +private: + required_device m_palette; + + required_ioport_array<2> m_in_xaxis; + required_ioport_array<2> m_in_yaxis; + + bool m_old_cmd = false; + + void misc_w(uint16_t data); + int dsp_bio_line_r(); + uint16_t amerdart_trackball_r(offs_t offset); + + TMS340X0_SCANLINE_RGB32_CB_MEMBER(scanline); + + TIMER_DEVICE_CALLBACK_MEMBER(amerdart_audio_int_gen); + + int amerdart_trackball_direction(int num, int data); + + void dsp_io_map(address_map &map) ATTR_COLD; + void dsp_pgm_map(address_map &map) ATTR_COLD; + void main_map(address_map &map) ATTR_COLD; +}; + +class _9ballsht_state : public coolpool_base_state +{ +public: + _9ballsht_state(const machine_config &mconfig, device_type type, const char *tag) + : coolpool_base_state(mconfig, type, tag) + , m_tlc34076(*this, "tlc34076") + { } + + void _9ballsht(machine_config &config); + + void init_9ballsht(); + +protected: + required_device m_tlc34076; + + void misc_w(uint16_t data); + uint16_t dsp_bio_line_r(); + uint16_t dsp_hold_line_r(); + + TMS340X0_SCANLINE_RGB32_CB_MEMBER(scanline); + + void dsp_io_base_map(address_map &map) ATTR_COLD; + void dsp_pgm_map(address_map &map) ATTR_COLD; + +private: + void nballsht_dsp_io_map(address_map &map) ATTR_COLD; + void nballsht_map(address_map &map) ATTR_COLD; +}; + +class coolpool_state : public _9ballsht_state +{ +public: + coolpool_state(const machine_config &mconfig, device_type type, const char *tag) + : _9ballsht_state(mconfig, type, tag) + , m_in1(*this, "IN1") + , m_xaxis(*this, "XAXIS") + , m_yaxis(*this, "YAXIS") + { } + + void coolpool(machine_config &config); + +private: + required_ioport m_in1; + required_ioport m_xaxis; + required_ioport m_yaxis; + + uint16_t coolpool_input_r(offs_t offset); + + void coolpool_dsp_io_map(address_map &map) ATTR_COLD; + void coolpool_map(address_map &map) ATTR_COLD; +}; + + + /************************************* * * Local variables * *************************************/ - - static const uint16_t nvram_unlock_seq[] = { 0x3fb, 0x3fb, 0x3f8, 0x3fc, 0x3fa, 0x3fe, 0x3f9, 0x3fd, 0x3fb, 0x3ff @@ -267,6 +426,7 @@ int amerdart_state::dsp_bio_line_r() return m_main2dsp->pending_r() ? CLEAR_LINE : ASSERT_LINE; } + /************************************* * * Ameri Darts trackball inputs @@ -429,9 +589,8 @@ uint16_t amerdart_state::amerdart_trackball_r(offs_t offset) // Determine Trackball 2 direction state m_result = (m_result & 0x0fff) | (amerdart_trackball_direction(2, ((m_result >> 12) & 0xf)) << 12); - -// LOGINPUT("%08X:read port 6 (X=%02X Y=%02X oldX=%02X oldY=%02X oldRes=%04X Res=%04X)\n", m_dsp->pc(), m_newx, m_newy, m_oldx, m_oldy, m_lastresult, m_result); - + LOGINPUT("%08X:read port 6 (X=%02X Y=%02X oldX=%02X oldY=%02X oldRes=%04X Res=%04X)\n", m_dsp->pc(), + m_newx, m_newy, m_oldx, m_oldy, m_lastresult, m_result); m_lastresult = m_result; } @@ -565,8 +724,8 @@ uint16_t coolpool_state::coolpool_input_r(offs_t offset) } } -// LOGINPUT("%08X:read port 7 (X=%02X Y=%02X oldX=%02X oldY=%02X res=%04X)\n", m_dsp->pc(), -// m_newx[1], m_newy[1], m_oldx[1], m_oldy[1], m_result); + LOGINPUT("%08X:read port 7 (X=%02X Y=%02X oldX=%02X oldY=%02X res=%04X)\n", m_dsp->pc(), + m_newx[1], m_newy[1], m_oldx[1], m_oldy[1], m_result); m_lastresult = m_result; } return m_result; @@ -582,7 +741,7 @@ uint16_t coolpool_state::coolpool_input_r(offs_t offset) void amerdart_state::main_map(address_map &map) { - map(0x00000000, 0x000fffff).ram().share(m_vram_base); + map(0x00000000, 0x000fffff).mirror(0x00300000).ram().share(m_vram_base); map(0x04000000, 0x0400000f).w(FUNC(amerdart_state::misc_w)); map(0x05000000, 0x0500000f).r(m_dsp2main, FUNC(generic_latch_16_device::read)).w(m_main2dsp, FUNC(generic_latch_16_device::write)); map(0x06000000, 0x06007fff).ram().w(FUNC(amerdart_state::nvram_thrash_data_w)).share("nvram"); @@ -592,8 +751,8 @@ void amerdart_state::main_map(address_map &map) void coolpool_state::coolpool_map(address_map &map) { - map(0x00000000, 0x001fffff).ram().share(m_vram_base); - map(0x01000000, 0x010000ff).rw(m_tlc34076, FUNC(tlc34076_device::read), FUNC(tlc34076_device::write)).umask16(0x00ff); // IMSG176P-40 + map(0x00000000, 0x001fffff).mirror(0x00200000).ram().share(m_vram_base); + map(0x01000000, 0x010000ff).rw(m_tlc34076, FUNC(tlc34076_device::read), FUNC(tlc34076_device::write)).umask16(0x00ff); // IMSG176P-40 map(0x02000000, 0x020000ff).r(m_dsp2main, FUNC(generic_latch_16_device::read)).w(m_main2dsp, FUNC(generic_latch_16_device::write)); map(0x03000000, 0x0300000f).w(FUNC(coolpool_state::misc_w)); map(0x03000000, 0x03ffffff).rom().region("maingfx", 0); @@ -604,10 +763,10 @@ void coolpool_state::coolpool_map(address_map &map) void _9ballsht_state::nballsht_map(address_map &map) { - map(0x00000000, 0x001fffff).ram().share(m_vram_base); + map(0x00000000, 0x001fffff).mirror(0x00200000).ram().share(m_vram_base); map(0x02000000, 0x020000ff).r(m_dsp2main, FUNC(generic_latch_16_device::read)).w(m_main2dsp, FUNC(generic_latch_16_device::write)); map(0x03000000, 0x0300000f).w(FUNC(_9ballsht_state::misc_w)); - map(0x04000000, 0x040000ff).rw(m_tlc34076, FUNC(tlc34076_device::read), FUNC(tlc34076_device::write)).umask16(0x00ff); // IMSG176P-40 + map(0x04000000, 0x040000ff).rw(m_tlc34076, FUNC(tlc34076_device::read), FUNC(tlc34076_device::write)).umask16(0x00ff); // IMSG176P-40 map(0x06000000, 0x0601ffff).mirror(0x00020000).ram().w(FUNC(_9ballsht_state::nvram_thrash_data_w)).share("nvram"); map(0xff000000, 0xff7fffff).rom().region("maingfx", 0); map(0xffc00000, 0xffffffff).rom().region("maincpu", 0); @@ -659,6 +818,7 @@ void _9ballsht_state::dsp_io_base_map(address_map &map) void coolpool_state::coolpool_dsp_io_map(address_map &map) { dsp_io_base_map(map); + map(0x06, 0x06).unmapr(); map(0x07, 0x07).r(FUNC(coolpool_state::coolpool_input_r)); } @@ -829,9 +989,9 @@ void _9ballsht_state::_9ballsht(machine_config &config) // dsp.hold_ack_out_cb().set(FUNC(_9ballsht_state::dsp_HOLDA_signal_w)); GENERIC_LATCH_16(config, m_main2dsp); - m_main2dsp->data_pending_callback().set_inputline(m_dsp, 0); // ??? I have no idea who should generate this! - // the DSP polls the status bit so it isn't strictly - // necessary to also have an IRQ + // ??? I have no idea who should generate this! + // The DSP polls the status bit so it isn't strictly necessary to also have an IRQ + m_main2dsp->data_pending_callback().set_inputline(m_dsp, 0); GENERIC_LATCH_16(config, m_dsp2main); m_dsp2main->data_pending_callback().set_inputline(m_maincpu, 1); @@ -1093,7 +1253,6 @@ ROM_END - /************************************* * * Driver init @@ -1134,6 +1293,8 @@ void _9ballsht_state::init_9ballsht() } } +} // anonymous namespace + /************************************* @@ -1145,8 +1306,10 @@ void _9ballsht_state::init_9ballsht() GAME( 1989, amerdart, 0, amerdart, amerdart, amerdart_state, empty_init, ROT0, "Ameri", "AmeriDarts (set 1)", MACHINE_SUPPORTS_SAVE ) GAME( 1989, amerdart2, amerdart, amerdart, amerdart, amerdart_state, empty_init, ROT0, "Ameri", "AmeriDarts (set 2)", MACHINE_SUPPORTS_SAVE ) GAME( 1989, amerdart3, amerdart, amerdart, amerdart, amerdart_state, empty_init, ROT0, "Ameri", "AmeriDarts (set 3)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, coolpool, 0, coolpool, coolpool, coolpool_state, empty_init, ROT0, "Catalina", "Cool Pool", 0 ) -GAME( 1993, 9ballsht, 0, _9ballsht, 9ballsht, _9ballsht_state, init_9ballsht, ROT0, "E-Scape EnterMedia (Bundra license)", "9-Ball Shootout (set 1)", 0 ) -GAME( 1993, 9ballsht2, 9ballsht, _9ballsht, 9ballsht, _9ballsht_state, init_9ballsht, ROT0, "E-Scape EnterMedia (Bundra license)", "9-Ball Shootout (set 2)", 0 ) -GAME( 1993, 9ballsht3, 9ballsht, _9ballsht, 9ballsht, _9ballsht_state, init_9ballsht, ROT0, "E-Scape EnterMedia (Bundra license)", "9-Ball Shootout (set 3)", 0 ) -GAME( 1993, 9ballshtc, 9ballsht, _9ballsht, 9ballsht, _9ballsht_state, init_9ballsht, ROT0, "E-Scape EnterMedia (Bundra license)", "9-Ball Shootout Championship", 0 ) + +GAME( 1992, coolpool, 0, coolpool, coolpool, coolpool_state, empty_init, ROT0, "Catalina", "Cool Pool", MACHINE_SUPPORTS_SAVE ) + +GAME( 1993, 9ballsht, 0, _9ballsht, 9ballsht, _9ballsht_state, init_9ballsht, ROT0, "E-Scape EnterMedia (Bundra license)", "9-Ball Shootout (set 1)", MACHINE_SUPPORTS_SAVE ) +GAME( 1993, 9ballsht2, 9ballsht, _9ballsht, 9ballsht, _9ballsht_state, init_9ballsht, ROT0, "E-Scape EnterMedia (Bundra license)", "9-Ball Shootout (set 2)", MACHINE_SUPPORTS_SAVE ) +GAME( 1993, 9ballsht3, 9ballsht, _9ballsht, 9ballsht, _9ballsht_state, init_9ballsht, ROT0, "E-Scape EnterMedia (Bundra license)", "9-Ball Shootout (set 3)", MACHINE_SUPPORTS_SAVE ) +GAME( 1993, 9ballshtc, 9ballsht, _9ballsht, 9ballsht, _9ballsht_state, init_9ballsht, ROT0, "E-Scape EnterMedia (Bundra license)", "9-Ball Shootout Championship", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/misc/coolpool.h b/src/mame/misc/coolpool.h deleted file mode 100644 index 574e971eebd..00000000000 --- a/src/mame/misc/coolpool.h +++ /dev/null @@ -1,166 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles,Nicola Salmoria -#ifndef MAME_MISC_COOLPOOL_H -#define MAME_MISC_COOLPOOL_H - -#pragma once - -#include "cpu/tms34010/tms34010.h" -#include "machine/gen_latch.h" -#include "machine/timer.h" -#include "video/tlc34076.h" - -#include "emupal.h" - -class coolpool_base_state : public driver_device -{ -protected: - coolpool_base_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag) - , m_maincpu(*this, "maincpu") - , m_dsp(*this, "dsp") - , m_main2dsp(*this, "main2dsp") - , m_dsp2main(*this, "dsp2main") - , m_nvram_timer(*this, "nvram_timer") - , m_vram_base(*this, "vram_base") - , m_nvram(*this, "nvram") - , m_dsp_rom(*this, "dspdata") - { } - - virtual void machine_start() override ATTR_COLD; - virtual void machine_reset() override ATTR_COLD; - - static constexpr unsigned NVRAM_UNLOCK_SEQ_LEN = 10; - - required_device m_maincpu; - required_device m_dsp; - - required_device m_main2dsp; - required_device m_dsp2main; - - required_device m_nvram_timer; - - required_shared_ptr m_vram_base; - required_shared_ptr m_nvram; - required_region_ptr m_dsp_rom; - - int m_iop_romaddr = 0; - - uint8_t m_newx[3]{}; - uint8_t m_newy[3]{}; - uint8_t m_oldx[3]{}; - uint8_t m_oldy[3]{}; - int m_dx[3]{}; - int m_dy[3]{}; - - uint16_t m_result = 0U; - uint16_t m_lastresult = 0U; - - uint16_t m_nvram_write_seq[NVRAM_UNLOCK_SEQ_LEN]{}; - uint8_t m_nvram_write_enable = 0U; - uint8_t m_same_cmd_count = 0U; - - void nvram_thrash_w(offs_t offset, uint16_t data); - void nvram_data_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void nvram_thrash_data_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - - uint16_t dsp_rom_r(); - void dsp_romaddr_w(offs_t offset, uint16_t data); - - TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg); - TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg); - - TIMER_DEVICE_CALLBACK_MEMBER(nvram_write_timeout); -}; - -class amerdart_state : public coolpool_base_state -{ -public: - amerdart_state(const machine_config &mconfig, device_type type, const char *tag) - : coolpool_base_state(mconfig, type, tag) - , m_palette(*this, "palette") - , m_in_xaxis(*this, "XAXIS%u", 1U) - , m_in_yaxis(*this, "YAXIS%u", 1U) - { } - - void amerdart(machine_config &config); - -protected: - virtual void machine_start() override ATTR_COLD; - -private: - required_device m_palette; - - required_ioport_array<2> m_in_xaxis; - required_ioport_array<2> m_in_yaxis; - - bool m_old_cmd = false; - - void misc_w(uint16_t data); - int dsp_bio_line_r(); - uint16_t amerdart_trackball_r(offs_t offset); - - TMS340X0_SCANLINE_RGB32_CB_MEMBER(scanline); - - TIMER_DEVICE_CALLBACK_MEMBER(amerdart_audio_int_gen); - - int amerdart_trackball_direction(int num, int data); - - void dsp_io_map(address_map &map) ATTR_COLD; - void dsp_pgm_map(address_map &map) ATTR_COLD; - void main_map(address_map &map) ATTR_COLD; -}; - -class _9ballsht_state : public coolpool_base_state -{ -public: - _9ballsht_state(const machine_config &mconfig, device_type type, const char *tag) - : coolpool_base_state(mconfig, type, tag) - , m_tlc34076(*this, "tlc34076") - { } - - void _9ballsht(machine_config &config); - - void init_9ballsht(); - -protected: - required_device m_tlc34076; - - void misc_w(uint16_t data); - uint16_t dsp_bio_line_r(); - uint16_t dsp_hold_line_r(); - - TMS340X0_SCANLINE_RGB32_CB_MEMBER(scanline); - - void dsp_io_base_map(address_map &map) ATTR_COLD; - void dsp_pgm_map(address_map &map) ATTR_COLD; - -private: - void nballsht_dsp_io_map(address_map &map) ATTR_COLD; - void nballsht_map(address_map &map) ATTR_COLD; -}; - -class coolpool_state : public _9ballsht_state -{ -public: - coolpool_state(const machine_config &mconfig, device_type type, const char *tag) - : _9ballsht_state(mconfig, type, tag) - , m_in1(*this, "IN1") - , m_xaxis(*this, "XAXIS") - , m_yaxis(*this, "YAXIS") - { } - - void coolpool(machine_config &config); - -private: - required_ioport m_in1; - required_ioport m_xaxis; - required_ioport m_yaxis; - - uint16_t coolpool_input_r(offs_t offset); - - void coolpool_dsp_io_map(address_map &map) ATTR_COLD; - void coolpool_map(address_map &map) ATTR_COLD; -}; - -#endif // MAME_MISC_COOLPOOL_H -- cgit v1.2.3