diff options
author | Vas Crabb <vas@vastheman.com> | 2017-01-01 20:31:44 +1100 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2017-01-01 20:34:22 +1100 |
commit | 1069cc36dc7862ae9e4c888b3d4c5ef98c19baa6 (patch) | |
tree | 73cdadece017964417d14a4eea729334d8221bf2 | |
parent | dbd42936930bee762332f206b60dc65c269fb275 (diff) |
josvolly: running the MCUs faster gets it back to the state it was in with the MCU simulation
-rw-r--r-- | src/mame/drivers/gsword.cpp | 6 | ||||
-rw-r--r-- | src/mame/machine/tait8741.cpp | 180 | ||||
-rw-r--r-- | src/mame/machine/tait8741.h | 77 |
3 files changed, 3 insertions, 260 deletions
diff --git a/src/mame/drivers/gsword.cpp b/src/mame/drivers/gsword.cpp index b131e3ecf4d..3d50ca8a73e 100644 --- a/src/mame/drivers/gsword.cpp +++ b/src/mame/drivers/gsword.cpp @@ -850,7 +850,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_START( josvolly, josvolly_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", Z80, 18000000/6) /* ? */ + MCFG_CPU_ADD("maincpu", Z80, 18000000/4) /* ? */ MCFG_CPU_PROGRAM_MAP(cpu1_map) MCFG_CPU_IO_MAP(josvolly_cpu1_io_map) MCFG_CPU_PERIODIC_INT_DRIVER(josvolly_state, irq0_line_hold, 2*60) @@ -860,10 +860,10 @@ static MACHINE_CONFIG_START( josvolly, josvolly_state ) MCFG_CPU_IO_MAP(josvolly_cpu2_io_map) MCFG_CPU_VBLANK_INT_DRIVER("screen", josvolly_state, irq0_line_assert) - MCFG_DEVICE_ADD("mcu1", I8741, 18000000/6) /* ? */ + MCFG_DEVICE_ADD("mcu1", I8741, 18000000/2) /* ? */ MCFG_CPU_IO_MAP(josvolly_mcu1_io_map) - MCFG_DEVICE_ADD("mcu2", I8741, 12000000/4) /* ? */ + MCFG_DEVICE_ADD("mcu2", I8741, 12000000/2) /* ? */ MCFG_CPU_IO_MAP(josvolly_mcu2_io_map) MCFG_DEVICE_ADD("aa_007", I8255, 0) diff --git a/src/mame/machine/tait8741.cpp b/src/mame/machine/tait8741.cpp index 612831749f7..3ea6607b1b0 100644 --- a/src/mame/machine/tait8741.cpp +++ b/src/mame/machine/tait8741.cpp @@ -332,183 +332,3 @@ uint8_t taito8741_4pack_device::port_read(int num, int offset) default : return 0; } } - -/**************************************************************************** - -joshi Vollyball set. - - Only the chip of the communication between MAIN and the SUB. - For the I/O, there may be I8741 of the addition. - - MCU code is not dumped. - There is some HACK operation because the emulation is imperfect. - -****************************************************************************/ - -const device_type JOSVOLLY8741_4PACK = &device_creator<josvolly8741_4pack_device>; - -josvolly8741_4pack_device::josvolly8741_4pack_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, JOSVOLLY8741_4PACK, "I8741 MCU Simulation (Joshi Volleyball)", tag, owner, clock, "josvolly8741_4pack", __FILE__), - m_port_handler_0_r(*this), - m_port_handler_1_r(*this), - m_port_handler_2_r(*this), - m_port_handler_3_r(*this) -{ -} - -void josvolly8741_4pack_device::device_start() -{ - m_port_handler_0_r.resolve_safe(0); - m_port_handler_1_r.resolve_safe(0); - m_port_handler_2_r.resolve_safe(0); - m_port_handler_3_r.resolve_safe(0); - - for (int i = 0; i < 4; i++) - { - save_item(NAME(m_i8741[i].cmd), i); - save_item(NAME(m_i8741[i].sts), i); - save_item(NAME(m_i8741[i].txd), i); - //save_item(NAME(m_i8741[i].outport), i); //currently initialized to 0xff, never changed - save_item(NAME(m_i8741[i].rxd), i); - save_item(NAME(m_i8741[i].rst), i); - }; - - save_item(NAME(m_nmi_enable)); -} - - -void josvolly8741_4pack_device::device_reset() -{ - m_nmi_enable = 0; - - for(auto & elem : m_i8741) - { - elem.cmd = 0; - elem.sts = 0; // 0xf0; /* init flag */ - elem.txd = 0; - elem.outport = 0xff; - elem.rxd = 0; - - elem.rst = 1; - } -} - -/* transmit data finish callback */ -TIMER_CALLBACK_MEMBER( josvolly8741_4pack_device::tx ) -{ - int num = param; - JV8741 *src = &m_i8741[num]; - JV8741 *dst = &m_i8741[src->connect]; - - dst->rxd = src->txd; - - src->sts &= ~0x02; /* TX full ? */ - dst->sts |= 0x01; /* RX ready ? */ -} - -void josvolly8741_4pack_device::update(int num) -{ - if( (m_i8741[num].sts & 0x02) ) - { - /* transmit data */ - machine().scheduler().timer_set (attotime::from_usec(1), timer_expired_delegate(FUNC(josvolly8741_4pack_device::tx),this), num); - } -} - -void josvolly8741_4pack_device::write(int num, int offset, int data) -{ - JV8741 *mcu = &m_i8741[num]; - - if(offset==1) - { - LOG(("%s:8741[%d] CW %02X\n", machine().describe_context(), num, data)); - - /* read pointer */ - mcu->cmd = data; - /* CMD */ - switch(data) - { - case 0: - mcu->txd = data ^ 0x40; - mcu->sts |= 0x02; - break; - case 1: - mcu->txd = data ^ 0x40; - mcu->sts |= 0x02; -#if 1 - /* ?? */ - mcu->rxd = 0; /* SBSTS ( DIAG ) , killed */ - mcu->sts |= 0x01; /* RD ready */ -#endif - break; - case 2: -#if 1 - mcu->rxd = port_read(1); - mcu->sts |= 0x01; /* RD ready */ -#endif - break; - case 3: /* normal mode ? */ - break; - - case 0xf0: /* clear main sts ? */ - mcu->txd = data ^ 0x40; - mcu->sts |= 0x02; - break; - } - } - else - { - /* data */ - LOG(("%s:8741[%d] DW %02X\n", machine().describe_context(), num, data)); - - mcu->txd = data ^ 0x40; /* parity reverce ? */ - mcu->sts |= 0x02; /* TXD busy */ -#if 1 - /* interrupt ? */ - if(num == 0) - { - if(m_nmi_enable) - { - machine().device("audiocpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE); - m_nmi_enable = 0; - } - } -#endif - } - update(num); -} - -uint8_t josvolly8741_4pack_device::read(int num,int offset) -{ - JV8741 *mcu = &m_i8741[num]; - int ret; - - if(offset==1) - { - if(mcu->rst) - mcu->rxd = port_read(num); /* port in */ - ret = mcu->sts; - LOG(("%s:8741[%d] SR %02X\n",machine().describe_context(),num,ret)); - } - else - { - /* clear status port */ - mcu->sts &= ~0x01; /* RD ready */ - ret = mcu->rxd; - LOG(("%s:8741[%d] DR %02X\n",machine().describe_context(),num,ret)); - mcu->rst = 0; - } - return ret; -} - -uint8_t josvolly8741_4pack_device::port_read(int num) -{ - switch(num) - { - case 0 : return m_port_handler_0_r(0); - case 1 : return m_port_handler_1_r(0); - case 2 : return m_port_handler_2_r(0); - case 3 : return m_port_handler_3_r(0); - default : return 0; - } -} diff --git a/src/mame/machine/tait8741.h b/src/mame/machine/tait8741.h index abf87272503..77e2c6338f7 100644 --- a/src/mame/machine/tait8741.h +++ b/src/mame/machine/tait8741.h @@ -109,81 +109,4 @@ private: extern const device_type TAITO8741_4PACK; - -/**************************************************************************** - joshi Volleyball set. -****************************************************************************/ - -#define MCFG_JOSVOLLY8741_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, JOSVOLLY8741_4PACK, 0) - -#define MCFG_JOSVOLLY8741_PORT_HANDLERS(_devcb0, _devcb1, _devcb2, _devcb3) \ - devcb = &josvolly8741_4pack_device::set_port_handler_0_callback(*device, DEVCB_##_devcb0); \ - devcb = &josvolly8741_4pack_device::set_port_handler_1_callback(*device, DEVCB_##_devcb1); \ - devcb = &josvolly8741_4pack_device::set_port_handler_2_callback(*device, DEVCB_##_devcb2); \ - devcb = &josvolly8741_4pack_device::set_port_handler_3_callback(*device, DEVCB_##_devcb3); - -#define MCFG_JOSVOLLY8741_CONNECT(_con0, _con1, _con2, _con3) \ - josvolly8741_4pack_device::static_set_connect(*device, 0, _con0); \ - josvolly8741_4pack_device::static_set_connect(*device, 1, _con1); \ - josvolly8741_4pack_device::static_set_connect(*device, 2, _con2); \ - josvolly8741_4pack_device::static_set_connect(*device, 3, _con3); - - -class josvolly8741_4pack_device : public device_t -{ - struct JV8741 { - uint8_t cmd; - uint8_t sts; - uint8_t txd; - uint8_t outport; - uint8_t rxd; - uint8_t connect; - uint8_t rst; - }; - -public: - josvolly8741_4pack_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - ~josvolly8741_4pack_device() {} - - template<class _Object> static devcb_base &set_port_handler_0_callback(device_t &device, _Object object) { return downcast<josvolly8741_4pack_device &>(device).m_port_handler_0_r.set_callback(object); } - template<class _Object> static devcb_base &set_port_handler_1_callback(device_t &device, _Object object) { return downcast<josvolly8741_4pack_device &>(device).m_port_handler_1_r.set_callback(object); } - template<class _Object> static devcb_base &set_port_handler_2_callback(device_t &device, _Object object) { return downcast<josvolly8741_4pack_device &>(device).m_port_handler_2_r.set_callback(object); } - template<class _Object> static devcb_base &set_port_handler_3_callback(device_t &device, _Object object) { return downcast<josvolly8741_4pack_device &>(device).m_port_handler_3_r.set_callback(object); } - - static void static_set_connect(device_t &device, int num, int conn) { downcast<josvolly8741_4pack_device &>(device).m_i8741[num].connect = conn; } - - DECLARE_READ8_MEMBER( read_0 ) { return read(0,offset); } - DECLARE_WRITE8_MEMBER( write_0 ) { write(0,offset,data); } - DECLARE_READ8_MEMBER( read_1 ) { return read(1,offset); } - DECLARE_WRITE8_MEMBER( write_1 ) { write(1,offset,data); } - - DECLARE_WRITE8_MEMBER( nmi_enable_w ) { m_nmi_enable = 1; } - - TIMER_CALLBACK_MEMBER( tx ); -protected: - // device-level overrides - virtual void device_start() override; - virtual void device_reset() override; - -private: - void update(int num); - void write(int num, int offset, int data); - uint8_t read(int num,int offset); - uint8_t port_read(int num); - - // internal state - JV8741 m_i8741[4]; - int m_nmi_enable; - - devcb_read8 m_port_handler_0_r; - devcb_read8 m_port_handler_1_r; - devcb_read8 m_port_handler_2_r; - devcb_read8 m_port_handler_3_r; -}; - - -extern const device_type JOSVOLLY8741_4PACK; - - #endif |