Previous 199869 Revisions Next

r32973 Sunday 26th October, 2014 at 10:32:58 UTC by smf
Convert PSX sio to use devcb. [smf]
[src/emu/bus/psx]ctlrport.c ctlrport.h
[src/emu/cpu]cpu.mak
[src/emu/cpu/psx]sio.c sio.h siodev.c siodev.h
[src/mame/drivers]ksys573.c taitogn.c zn.c
[src/mame/machine]cat702.c cat702.h k573cass.c k573cass.h zndip.c zndip.h
[src/mess/drivers]psx.c

trunk/src/emu/bus/psx/ctlrport.c
r241484r241485
3737
3838const device_type PSXCONTROLLERPORTS = &device_creator<psxcontrollerports_device>;
3939
40psxcontrollerports_device::psxcontrollerports_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
41      psxsiodev_device(mconfig, PSXCONTROLLERPORTS, "PSXCONTROLLERPORTS", tag, owner, clock, "psxcontrollerports", __FILE__)
40psxcontrollerports_device::psxcontrollerports_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
41   : device_t(mconfig, PSXCONTROLLERPORTS, "PSXCONTROLLERPORTS", tag, owner, clock, "psxcontrollerports", __FILE__),
42   m_dsr_handler(*this),
43   m_rxd_handler(*this)
4244{
4345}
4446
4547void psxcontrollerports_device::device_start()
4648{
49   m_dsr_handler.resolve_safe();
50   m_rxd_handler.resolve_safe();
51
4752   m_port0 = machine().device<psx_controller_port_device>("port1");
4853   m_port1 = machine().device<psx_controller_port_device>("port2");
4954   m_port0->setup_ack_cb(psx_controller_port_device::void_cb(FUNC(psxcontrollerports_device::ack), this));
5055   m_port1->setup_ack_cb(psx_controller_port_device::void_cb(FUNC(psxcontrollerports_device::ack), this));
51   psxsiodev_device::device_start();
5256}
5357
5458// add controllers to define so they can be connected to the multitap
r241484r241485
6670   PSX_CONTROLLERS
6771SLOT_INTERFACE_END
6872
69void psxcontrollerports_device::data_in( int data, int mask )
73WRITE_LINE_MEMBER(psxcontrollerports_device::write_dtr)
7074{
71   m_port0->sel_w((data & PSX_SIO_OUT_DTR)?1:0);
72   m_port0->tx_w((data & PSX_SIO_OUT_DATA)?1:0);
73   m_port0->clock_w((data & PSX_SIO_OUT_CLOCK)?1:0); // clock must be last
75   m_port0->sel_w(!state);
76   m_port1->sel_w(state);
77}
7478
75   m_port1->tx_w((data & PSX_SIO_OUT_DATA)?1:0);
76   m_port1->sel_w((data & PSX_SIO_OUT_DTR)?0:1); // not dtr
77   m_port1->clock_w((data & PSX_SIO_OUT_CLOCK)?1:0);
79WRITE_LINE_MEMBER(psxcontrollerports_device::write_sck)
80{
81   m_port0->clock_w(state);
82   m_port1->clock_w(state);
83   m_rxd_handler(m_port0->rx_r() && m_port1->rx_r());
84}
7885
79   data_out(((m_port0->rx_r() && m_port1->rx_r()) * PSX_SIO_IN_DATA), PSX_SIO_IN_DATA);
86WRITE_LINE_MEMBER(psxcontrollerports_device::write_txd)
87{
88   m_port0->tx_w(state);
89   m_port1->tx_w(state);
8090}
8191
8292void psxcontrollerports_device::ack()
8393{
84   data_out((!(m_port0->ack_r() && m_port1->ack_r()) * PSX_SIO_IN_DSR), PSX_SIO_IN_DSR);
94   m_dsr_handler(m_port0->ack_r() && m_port1->ack_r());
8595}
8696
8797device_psx_controller_interface::device_psx_controller_interface(const machine_config &mconfig, device_t &device) :
trunk/src/emu/bus/psx/ctlrport.h
r241484r241485
33#ifndef __PSXCPORT_H__
44#define __PSXCPORT_H__
55
6#include "cpu/psx/siodev.h"
76#include "memcard.h"
87
98#define MCFG_PSX_CTRL_PORT_ADD(_tag, _slot_intf, _def_slot) \
r241484r241485
2524   device_psx_controller_interface(const machine_config &mconfig, device_t &device);
2625   virtual ~device_psx_controller_interface();
2726
28   void clock_w(bool state) { if(m_clock && !m_sel && !state && !m_memcard) do_pad(); m_clock = state; }
27   void clock_w(bool state) { if(!m_clock && !m_sel && state && !m_memcard) do_pad(); m_clock = state; }
2928   void sel_w(bool state);
3029
3130   bool rx_r() { return m_rx; }
r241484r241485
7877   required_ioport m_pad1;
7978};
8079
81class psxcontrollerports_device : public psxsiodev_device
80#define MCFG_PSX_CONTROLLER_PORTS_DSR_HANDLER(_devcb) \
81   devcb = &psxcontrollerports_device::set_dsr_handler(*device, DEVCB_##_devcb);
82
83#define MCFG_PSX_CONTROLLER_PORTS_RXD_HANDLER(_devcb) \
84   devcb = &psxcontrollerports_device::set_rxd_handler(*device, DEVCB_##_devcb);
85
86class psxcontrollerports_device : public device_t
8287{
8388public:
8489   psxcontrollerports_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
8590   void ack();
8691
92   template<class _Object> static devcb_base &set_dsr_handler(device_t &device, _Object object) { return downcast<psxcontrollerports_device &>(device).m_dsr_handler.set_callback(object); }
93   template<class _Object> static devcb_base &set_rxd_handler(device_t &device, _Object object) { return downcast<psxcontrollerports_device &>(device).m_rxd_handler.set_callback(object); }
94
95   DECLARE_WRITE_LINE_MEMBER(write_sck);
96   DECLARE_WRITE_LINE_MEMBER(write_dtr);
97   DECLARE_WRITE_LINE_MEMBER(write_txd);
98
8799protected:
88100   virtual void device_start();
89101
90102private:
91   virtual void data_in(int data, int mask);
92
93103   psx_controller_port_device *m_port0;
94104   psx_controller_port_device *m_port1;
105
106   devcb_write_line m_dsr_handler;
107   devcb_write_line m_rxd_handler;
95108};
96109
97110class psx_controller_port_device :  public device_t,
trunk/src/emu/cpu/cpu.mak
r241484r241485
11741174
11751175ifneq ($(filter PSX,$(CPUS)),)
11761176OBJDIRS += $(CPUOBJ)/psx
1177CPUOBJS += $(CPUOBJ)/psx/psx.o $(CPUOBJ)/psx/gte.o $(CPUOBJ)/psx/dma.o $(CPUOBJ)/psx/irq.o $(CPUOBJ)/psx/mdec.o $(CPUOBJ)/psx/rcnt.o $(CPUOBJ)/psx/sio.o $(CPUOBJ)/psx/siodev.o
1177CPUOBJS += $(CPUOBJ)/psx/psx.o $(CPUOBJ)/psx/gte.o $(CPUOBJ)/psx/dma.o $(CPUOBJ)/psx/irq.o $(CPUOBJ)/psx/mdec.o $(CPUOBJ)/psx/rcnt.o $(CPUOBJ)/psx/sio.o
11781178DASMOBJS += $(CPUOBJ)/psx/psxdasm.o
11791179endif
11801180
trunk/src/emu/cpu/psx/sio.c
r241484r241485
3939
4040psxsio_device::psxsio_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
4141   device_t(mconfig, type, name, tag, owner, clock, shortname, source),
42   m_irq_handler(*this)
42   m_status(SIO_STATUS_TX_EMPTY | SIO_STATUS_TX_RDY),
43   m_rxd(1),
44   m_irq_handler(*this),
45   m_sck_handler(*this),
46   m_txd_handler(*this),
47   m_dtr_handler(*this),
48   m_rts_handler(*this)
4349{
4450}
4551
r241484r241485
5157void psxsio_device::device_start()
5258{
5359   m_irq_handler.resolve_safe();
60   m_sck_handler.resolve_safe();
61   m_txd_handler.resolve_safe();
62   m_dtr_handler.resolve_safe();
63   m_rts_handler.resolve_safe();
5464
5565   m_timer = timer_alloc( 0 );
56   m_status = SIO_STATUS_TX_EMPTY | SIO_STATUS_TX_RDY;
5766   m_mode = 0;
5867   m_control = 0;
5968   m_baud = 0;
60   m_tx = 0;
61   m_rx = 0;
62   m_tx_prev = 0;
63   m_rx_prev = 0;
6469   m_rx_data = 0;
6570   m_tx_data = 0;
6671   m_rx_shift = 0;
r241484r241485
7277   save_item( NAME( m_mode ) );
7378   save_item( NAME( m_control ) );
7479   save_item( NAME( m_baud ) );
75   save_item( NAME( m_tx ) );
76   save_item( NAME( m_rx ) );
77   save_item( NAME( m_tx_prev ) );
78   save_item( NAME( m_rx_prev ) );
80   save_item( NAME( m_rxd ) );
7981   save_item( NAME( m_rx_data ) );
8082   save_item( NAME( m_tx_data ) );
8183   save_item( NAME( m_rx_shift ) );
8284   save_item( NAME( m_tx_shift ) );
8385   save_item( NAME( m_rx_bits ) );
8486   save_item( NAME( m_tx_bits ) );
85
86   deviceCount = 0;
87
88   for( device_t *device = first_subdevice(); device != NULL; device = device->next() )
89   {
90      psxsiodev_device *psxsiodev = dynamic_cast<psxsiodev_device *>(device);
91      if( psxsiodev != NULL )
92      {
93         devices[ deviceCount++ ] = psxsiodev;
94         psxsiodev->m_psxsio = this;
95      }
96   }
97
98   input_update();
9987}
10088
10189void psxsio_device::sio_interrupt()
r241484r241485
149137   m_timer->adjust( n_time );
150138}
151139
152void psxsio_device::output( int data, int mask )
153{
154   int new_outputdata = ( m_outputdata & ~mask ) | ( data & mask );
155   int new_mask = m_outputdata ^ new_outputdata;
156
157   if( new_mask != 0 )
158   {
159      m_outputdata = new_outputdata;
160
161      for( int i = 0; i < deviceCount; i++ )
162      {
163         devices[ i ]->data_in( m_outputdata, new_mask );
164      }
165   }
166}
167
168140void psxsio_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
169141{
170142   verboselog( machine(), 2, "sio tick\n" );
r241484r241485
188160
189161   if( m_tx_bits != 0 )
190162   {
191      m_tx = ( m_tx & ~PSX_SIO_OUT_DATA ) | ( ( m_tx_shift & 1 ) * PSX_SIO_OUT_DATA );
163      if( type() == PSX_SIO0 )
164      {
165         m_sck_handler(0);
166      }
167
168      m_txd_handler( m_tx_shift & 1 );
192169      m_tx_shift >>= 1;
193170      m_tx_bits--;
194171
195172      if( type() == PSX_SIO0 )
196173      {
197         m_tx &= ~PSX_SIO_OUT_CLOCK;
198         output( m_tx, PSX_SIO_OUT_CLOCK | PSX_SIO_OUT_DATA );
199         m_tx |= PSX_SIO_OUT_CLOCK;
174         m_sck_handler(1);
200175      }
201176
202      output( m_tx, PSX_SIO_OUT_CLOCK | PSX_SIO_OUT_DATA );
203
204177      if( m_tx_bits == 0 &&
205178         ( m_control & SIO_CONTROL_TX_IENA ) != 0 )
206179      {
r241484r241485
210183
211184   if( m_rx_bits != 0 )
212185   {
213      m_rx_shift = ( m_rx_shift >> 1 ) | ( ( ( m_rx & PSX_SIO_IN_DATA ) / PSX_SIO_IN_DATA ) << 7 );
186      m_rx_shift = ( m_rx_shift >> 1 ) | ( m_rxd << 7 );
214187      m_rx_bits--;
215188
216189      if( m_rx_bits == 0 )
r241484r241485
265238            verboselog( machine(), 1, "psx_sio_w reset\n" );
266239            m_status |= SIO_STATUS_TX_EMPTY | SIO_STATUS_TX_RDY;
267240            m_status &= ~( SIO_STATUS_RX_RDY | SIO_STATUS_OVERRUN | SIO_STATUS_IRQ );
241            m_irq_handler(0);
268242
269243            // toggle DTR to reset controllers, Star Ocean 2, at least, requires it
270244            // the precise mechanism of the reset is unknown
271245            // maybe it's related to the bottom 2 bits of control which are usually set
272            output( m_tx ^ PSX_SIO_OUT_DTR, PSX_SIO_OUT_DTR );
246            m_dtr_handler(0);
247            m_dtr_handler(1);
248
249            m_tx_bits = 0;
250            m_rx_bits = 0;
251            m_txd_handler(1);
273252         }
274253         if( ( m_control & SIO_CONTROL_IACK ) != 0 )
275254         {
276255            verboselog( machine(), 1, "psx_sio_w iack\n" );
277256            m_status &= ~( SIO_STATUS_IRQ );
278257            m_control &= ~( SIO_CONTROL_IACK );
258            m_irq_handler(0);
279259         }
280260         if( ( m_control & SIO_CONTROL_DTR ) != 0 )
281261         {
282            m_tx |= PSX_SIO_OUT_DTR;
262            m_dtr_handler(0);
283263         }
284264         else
285265         {
286            m_tx &= ~PSX_SIO_OUT_DTR;
266            m_dtr_handler(1);
287267         }
288
289         output( m_tx, PSX_SIO_OUT_DTR );
290
291         m_tx_prev = m_tx;
292
293268      }
294269      break;
295270   case 3:
r241484r241485
362337   return data;
363338}
364339
365void psxsio_device::input_update()
340WRITE_LINE_MEMBER(psxsio_device::write_rxd)
366341{
367   int data = 0;
342   m_rxd = state;
343}
368344
369   for( int i = 0; i < deviceCount; i++ )
345WRITE_LINE_MEMBER(psxsio_device::write_dsr)
346{
347   if (state)
370348   {
371      data |= devices[ i ]->m_dataout;
349      m_status &= ~SIO_STATUS_DSR;
372350   }
373
374   int mask = data ^ m_rx;
375
376   verboselog( machine(), 1, "input_update( %s, %02x, %02x )\n", tag(), mask, data );
377
378   m_rx = data;
379
380   if( ( m_rx & PSX_SIO_IN_DSR ) != 0 )
351   else if ((m_status & SIO_STATUS_DSR) == 0)
381352   {
382353      m_status |= SIO_STATUS_DSR;
383      if( ( m_rx_prev & PSX_SIO_IN_DSR ) == 0 &&
384         ( m_control & SIO_CONTROL_DSR_IENA ) != 0 )
354
355      if( ( m_control & SIO_CONTROL_DSR_IENA ) != 0 )
385356      {
386357         sio_interrupt();
387358      }
388359   }
389   else
390   {
391      m_status &= ~SIO_STATUS_DSR;
392   }
393   m_rx_prev = m_rx;
394360}
trunk/src/emu/cpu/psx/sio.h
r241484r241485
1313#define __PSXSIO_H__
1414
1515#include "emu.h"
16#include "siodev.h"
1716
1817extern const device_type PSX_SIO0;
1918extern const device_type PSX_SIO1;
2019
2120#define MCFG_PSX_SIO_IRQ_HANDLER(_devcb) \
2221   devcb = &psxsio_device::set_irq_handler(*device, DEVCB_##_devcb);
22
23#define MCFG_PSX_SIO_SCK_HANDLER(_devcb) \
24   devcb = &psxsio_device::set_sck_handler(*device, DEVCB_##_devcb);
25
26#define MCFG_PSX_SIO_TXD_HANDLER(_devcb) \
27   devcb = &psxsio_device::set_txd_handler(*device, DEVCB_##_devcb);
28
29#define MCFG_PSX_SIO_DTR_HANDLER(_devcb) \
30   devcb = &psxsio_device::set_dtr_handler(*device, DEVCB_##_devcb);
31
32#define MCFG_PSX_SIO_RTS_HANDLER(_devcb) \
33   devcb = &psxsio_device::set_rts_handler(*device, DEVCB_##_devcb);
34
2335#define SIO_BUF_SIZE ( 8 )
2436
2537#define SIO_STATUS_TX_RDY ( 1 << 0 )
r241484r241485
4456
4557   // static configuration helpers
4658   template<class _Object> static devcb_base &set_irq_handler(device_t &device, _Object object) { return downcast<psxsio_device &>(device).m_irq_handler.set_callback(object); }
59   template<class _Object> static devcb_base &set_sck_handler(device_t &device, _Object object) { return downcast<psxsio_device &>(device).m_sck_handler.set_callback(object); }
60   template<class _Object> static devcb_base &set_txd_handler(device_t &device, _Object object) { return downcast<psxsio_device &>(device).m_txd_handler.set_callback(object); }
61   template<class _Object> static devcb_base &set_dtr_handler(device_t &device, _Object object) { return downcast<psxsio_device &>(device).m_dtr_handler.set_callback(object); }
62   template<class _Object> static devcb_base &set_rts_handler(device_t &device, _Object object) { return downcast<psxsio_device &>(device).m_rts_handler.set_callback(object); }
4763
4864   DECLARE_WRITE32_MEMBER( write );
4965   DECLARE_READ32_MEMBER( read );
5066
51   void input_update();
67   DECLARE_WRITE_LINE_MEMBER(write_rxd);
68   DECLARE_WRITE_LINE_MEMBER(write_dsr);
69   DECLARE_WRITE_LINE_MEMBER(write_cts);
5270
5371protected:
5472   // device-level overrides
r241484r241485
5775   virtual void device_post_load();
5876
5977private:
60   void output( int data, int mask );
6178   void sio_interrupt();
6279   void sio_timer_adjust();
6380
r241484r241485
6582   UINT32 m_mode;
6683   UINT32 m_control;
6784   UINT32 m_baud;
68   UINT32 m_tx;
69   UINT32 m_rx;
70   UINT32 m_tx_prev;
71   UINT32 m_rx_prev;
85   int m_rxd;
7286   UINT32 m_tx_data;
7387   UINT32 m_rx_data;
7488   UINT32 m_tx_shift;
r241484r241485
7993   emu_timer *m_timer;
8094
8195   devcb_write_line m_irq_handler;
82
83   psxsiodev_device *devices[ 10 ];
84   int deviceCount;
85
86   int m_outputdata;
87   //int m_inputdata;
96   devcb_write_line m_sck_handler;
97   devcb_write_line m_txd_handler;
98   devcb_write_line m_dtr_handler;
99   devcb_write_line m_rts_handler;
88100};
89101
90102class psxsio0_device : public psxsio_device
trunk/src/emu/cpu/psx/siodev.c
r241484r241485
1// license:MAME
2// copyright-holders:smf
3#include "sio.h"
4#include "siodev.h"
5
6psxsiodev_device::psxsiodev_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
7   device_t(mconfig, type, name, tag, owner, clock, shortname, source),
8   m_dataout(0)
9{
10}
11
12void psxsiodev_device::device_start()
13{
14   m_dataout = 0;
15}
16
17void psxsiodev_device::data_out( int data, int mask )
18{
19   m_dataout = ( m_dataout & ~mask ) | ( data & mask );
20
21   m_psxsio->input_update();
22}
trunk/src/emu/cpu/psx/siodev.h
r241484r241485
1// license:MAME
2// copyright-holders:smf
3#pragma once
4
5#include "emu.h"
6
7#ifndef _PSXSIODEV_H_
8#define _PSXSIODEV_H_
9
10#define PSX_SIO_OUT_DATA ( 1 )  /* COMMAND */
11#define PSX_SIO_OUT_DTR ( 2 )   /* ATT */
12#define PSX_SIO_OUT_RTS ( 4 )
13#define PSX_SIO_OUT_CLOCK ( 8 ) /* CLOCK */
14#define PSX_SIO_IN_DATA ( 1 )   /* DATA */
15#define PSX_SIO_IN_DSR ( 2 )    /* ACK */
16#define PSX_SIO_IN_CTS ( 4 )
17
18class psxsio_device;
19
20class psxsiodev_device : public device_t
21{
22   friend class psxsio_device;
23
24public:
25   // construction/destruction
26   psxsiodev_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
27
28protected:
29   // device-level overrides
30   virtual void device_start();
31
32   void data_out( int data, int mask );
33
34private:
35   psxsio_device *m_psxsio;
36
37   virtual void data_in( int data, int mask ) = 0;
38   int m_dataout;
39};
40
41#endif
trunk/src/mame/drivers/ksys573.c
r241484r241485
20382038   MCFG_SLOT_OPTION_MACHINE_CONFIG( "cr589", cr589_config )
20392039   MCFG_SLOT_DEFAULT_OPTION( "cr589" )
20402040
2041   MCFG_DEVICE_ADD( "maincpu:sio1:cassette", KONAMI573_CASSETTE_SLOT_SERIAL, 0 )
2042
20432041   MCFG_DEVICE_ADD( "cassette", KONAMI573_CASSETTE_SLOT, 0 )
2042   MCFG_KONAMI573_CASSETTE_DSR_HANDLER(DEVWRITELINE( "maincpu:sio1", psxsio1_device, write_dsr ) )
20442043
20452044   // onboard flash
20462045   MCFG_FUJITSU_29F016A_ADD( "29f016a.31m" )
trunk/src/mame/drivers/taitogn.c
r241484r241485
346346public:
347347   taitogn_state(const machine_config &mconfig, device_type type, const char *tag) :
348348      driver_device(mconfig, type, tag),
349      m_cat702_1(*this,"maincpu:sio0:cat702_1"),
350      m_cat702_2(*this,"maincpu:sio0:cat702_2"),
351      m_zndip(*this,"maincpu:sio0:zndip"),
349      m_sio0(*this, "maincpu:sio0"),
350      m_cat702_1(*this, "cat702_1"),
351      m_cat702_2(*this, "cat702_2"),
352      m_zndip(*this, "zndip"),
352353      m_maincpu(*this, "maincpu"),
353354      m_mn10200(*this, "mn10200"),
354355      m_flashbank(*this, "flashbank"),
r241484r241485
358359      m_sndflash0(*this, "sndflash0"),
359360      m_sndflash1(*this, "sndflash1"),
360361      m_sndflash2(*this, "sndflash2"),
361      m_has_zoom(true)
362      m_has_zoom(true),
363      m_cat702_1_dataout(1),
364      m_cat702_2_dataout(1),
365      m_zndip_dataout(1)
362366   {
363367   }
364368
369   DECLARE_WRITE_LINE_MEMBER(sio0_sck){ m_cat702_1->write_clock(state);  m_cat702_2->write_clock(state); m_zndip->write_clock(state); }
370   DECLARE_WRITE_LINE_MEMBER(sio0_txd){ m_cat702_1->write_datain(state);  m_cat702_2->write_datain(state); }
371   DECLARE_WRITE_LINE_MEMBER(cat702_1_dataout){ m_cat702_1_dataout = state; update_sio0_rxd(); }
372   DECLARE_WRITE_LINE_MEMBER(cat702_2_dataout){ m_cat702_2_dataout = state; update_sio0_rxd(); }
373   DECLARE_WRITE_LINE_MEMBER(zndip_dataout){ m_zndip_dataout = state; update_sio0_rxd(); }
374   void update_sio0_rxd() { m_sio0->write_rxd(m_cat702_1_dataout && m_cat702_2_dataout && m_zndip_dataout); }
365375   DECLARE_READ8_MEMBER(control_r);
366376   DECLARE_WRITE8_MEMBER(control_w);
367377   DECLARE_WRITE16_MEMBER(control2_w);
r241484r241485
384394   virtual void machine_reset();
385395
386396private:
397   required_device<psxsio0_device> m_sio0;
387398   required_device<cat702_device> m_cat702_1;
388399   required_device<cat702_device> m_cat702_2;
389400   required_device<zndip_device> m_zndip;
r241484r241485
406417   UINT8 m_n_znsecsel;
407418
408419   UINT8 m_coin_info;
420
421   int m_cat702_1_dataout;
422   int m_cat702_2_dataout;
423   int m_zndip_dataout;
409424};
410425
411426
r241484r241485
511526
512527WRITE8_MEMBER(taitogn_state::znsecsel_w)
513528{
514   m_cat702_1->select( ( data >> 2 ) & 1 );
515   m_cat702_2->select( ( data >> 3 ) & 1 );
516   m_zndip->select( ( data & 0x8c ) != 0x8c );
529   m_cat702_1->write_select((data >> 2) & 1);
530   m_cat702_2->write_select((data >> 3) & 1);
531   m_zndip->write_select((data & 0x8c) != 0x8c);
517532
518533   m_n_znsecsel = data;
519534}
r241484r241485
657672   MCFG_RAM_MODIFY("maincpu:ram")
658673   MCFG_RAM_DEFAULT_SIZE("4M")
659674
660   MCFG_DEVICE_ADD("maincpu:sio0:cat702_1", CAT702, 0)
661   MCFG_DEVICE_ADD("maincpu:sio0:cat702_2", CAT702, 0)
662   MCFG_DEVICE_ADD("maincpu:sio0:zndip", ZNDIP, 0)
675   MCFG_DEVICE_MODIFY("maincpu:sio0")
676   MCFG_PSX_SIO_SCK_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, taitogn_state, sio0_sck))
677   MCFG_PSX_SIO_TXD_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, taitogn_state, sio0_txd))
678
679   MCFG_DEVICE_ADD("cat702_1", CAT702, 0)
680   MCFG_CAT702_DATAOUT_HANDLER(WRITELINE(taitogn_state, cat702_1_dataout))
681
682   MCFG_DEVICE_ADD("cat702_2", CAT702, 0)
683   MCFG_CAT702_DATAOUT_HANDLER(WRITELINE(taitogn_state, cat702_2_dataout))
684
685   MCFG_DEVICE_ADD("zndip", ZNDIP, 0)
686   MCFG_ZNDIP_DATAOUT_HANDLER(WRITELINE(taitogn_state, zndip_dataout))
687   MCFG_ZNDIP_DSR_HANDLER(DEVWRITELINE("maincpu:sio0", psxsio0_device, write_dsr))
663688   MCFG_ZNDIP_DATA_HANDLER(IOPORT(":DSW"))
664689
665690   MCFG_AT28C16_ADD( "at28c16", 0 )
trunk/src/mame/drivers/zn.c
r241484r241485
3838      driver_device(mconfig, type, tag),
3939      m_gpu(*this, "gpu"),
4040      m_gpu_screen(*this, "gpu:screen"),
41      m_cat702_1(*this,"maincpu:sio0:cat702_1"),
42      m_cat702_2(*this,"maincpu:sio0:cat702_2"),
43      m_zndip(*this,"maincpu:sio0:zndip"),
41      m_sio0(*this, "maincpu:sio0"),
42      m_cat702_1(*this, "cat702_1"),
43      m_cat702_2(*this, "cat702_2"),
44      m_zndip(*this, "zndip"),
4445      m_maincpu(*this, "maincpu"),
4546      m_audiocpu(*this, "audiocpu"),
4647      m_ram(*this, "maincpu:ram"),
r241484r241485
4849      m_cbaj_fifo2(*this, "cbaj_fifo2"),
4950      m_mb3773(*this, "mb3773"),
5051      m_zoom(*this, "taito_zoom"),
51      m_vt83c461(*this, "ide")
52      m_vt83c461(*this, "ide"),
53      m_cat702_1_dataout(1),
54      m_cat702_2_dataout(1),
55      m_zndip_dataout(1)
5256   {
5357   }
5458
59   DECLARE_WRITE_LINE_MEMBER(sio0_sck){ m_cat702_1->write_clock(state);  m_cat702_2->write_clock(state); m_zndip->write_clock(state); }
60   DECLARE_WRITE_LINE_MEMBER(sio0_txd){ m_cat702_1->write_datain(state);  m_cat702_2->write_datain(state); }
61   DECLARE_WRITE_LINE_MEMBER(cat702_1_dataout){ m_cat702_1_dataout = state; update_sio0_rxd(); }
62   DECLARE_WRITE_LINE_MEMBER(cat702_2_dataout){ m_cat702_2_dataout = state; update_sio0_rxd(); }
63   DECLARE_WRITE_LINE_MEMBER(zndip_dataout){ m_zndip_dataout = state; update_sio0_rxd(); }
64   void update_sio0_rxd() { m_sio0->write_rxd( m_cat702_1_dataout && m_cat702_2_dataout && m_zndip_dataout ); }
5565   DECLARE_CUSTOM_INPUT_MEMBER(jdredd_gun_mux_read);
5666   DECLARE_READ8_MEMBER(znsecsel_r);
5767   DECLARE_WRITE8_MEMBER(znsecsel_w);
r241484r241485
124134
125135   required_device<psxgpu_device> m_gpu;
126136   required_device<screen_device> m_gpu_screen;
137   required_device<psxsio0_device> m_sio0;
127138   required_device<cat702_device> m_cat702_1;
128139   required_device<cat702_device> m_cat702_2;
129140   required_device<zndip_device> m_zndip;
r241484r241485
135146   optional_device<mb3773_device> m_mb3773;
136147   optional_device<taito_zoom_device> m_zoom;
137148   optional_device<vt83c461_device> m_vt83c461;
149
150   int m_cat702_1_dataout;
151   int m_cat702_2_dataout;
152   int m_zndip_dataout;
138153};
139154
140155inline void ATTR_PRINTF(3,4) zn_state::verboselog( int n_level, const char *s_fmt, ... )
r241484r241485
333348{
334349   verboselog(2, "znsecsel_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
335350
336   m_cat702_1->select( ( data >> 2 ) & 1 );
337   m_cat702_2->select( ( data >> 3 ) & 1 );
338   m_zndip->select( ( data & 0x8c ) != 0x8c );
351   m_cat702_1->write_select((data >> 2) & 1);
352   m_cat702_2->write_select((data >> 3) & 1);
353   m_zndip->write_select((data & 0x8c) != 0x8c);
339354
340355   m_n_znsecsel = data;
341356}
r241484r241485
449464   MCFG_RAM_MODIFY("maincpu:ram")
450465   MCFG_RAM_DEFAULT_SIZE("4M")
451466
452   MCFG_DEVICE_ADD("maincpu:sio0:cat702_1", CAT702, 0)
453   MCFG_DEVICE_ADD("maincpu:sio0:cat702_2", CAT702, 0)
454   MCFG_DEVICE_ADD("maincpu:sio0:zndip", ZNDIP, 0)
467   MCFG_DEVICE_MODIFY("maincpu:sio0")
468   MCFG_PSX_SIO_SCK_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, zn_state, sio0_sck))
469   MCFG_PSX_SIO_TXD_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, zn_state, sio0_txd))
470
471   MCFG_DEVICE_ADD("cat702_1", CAT702, 0)
472   MCFG_CAT702_DATAOUT_HANDLER(WRITELINE(zn_state, cat702_1_dataout))
473
474   MCFG_DEVICE_ADD("cat702_2", CAT702, 0)
475   MCFG_CAT702_DATAOUT_HANDLER(WRITELINE(zn_state, cat702_2_dataout))
476
477   MCFG_DEVICE_ADD("zndip", ZNDIP, 0)
478   MCFG_ZNDIP_DATAOUT_HANDLER(WRITELINE(zn_state, zndip_dataout))
479   MCFG_ZNDIP_DSR_HANDLER(DEVWRITELINE("maincpu:sio0", psxsio0_device, write_dsr))
455480   MCFG_ZNDIP_DATA_HANDLER(IOPORT(":DSW"))
456481
457482   // 5MHz NEC uPD78081 MCU:
r241484r241485
483508   MCFG_RAM_MODIFY("maincpu:ram")
484509   MCFG_RAM_DEFAULT_SIZE("4M")
485510
486   MCFG_DEVICE_ADD("maincpu:sio0:cat702_1", CAT702, 0)
487   MCFG_DEVICE_ADD("maincpu:sio0:cat702_2", CAT702, 0)
488   MCFG_DEVICE_ADD("maincpu:sio0:zndip", ZNDIP, 0)
511   MCFG_DEVICE_MODIFY("maincpu:sio0")
512   MCFG_PSX_SIO_SCK_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, zn_state, sio0_sck))
513   MCFG_PSX_SIO_TXD_HANDLER(DEVWRITELINE(DEVICE_SELF_OWNER, zn_state, sio0_txd))
514
515   MCFG_DEVICE_ADD("cat702_1", CAT702, 0)
516   MCFG_CAT702_DATAOUT_HANDLER(WRITELINE(zn_state, cat702_1_dataout))
517
518   MCFG_DEVICE_ADD("cat702_2", CAT702, 0)
519   MCFG_CAT702_DATAOUT_HANDLER(WRITELINE(zn_state, cat702_2_dataout))
520
521   MCFG_DEVICE_ADD("zndip", ZNDIP, 0)
522   MCFG_ZNDIP_DATAOUT_HANDLER(WRITELINE(zn_state, zndip_dataout))
523   MCFG_ZNDIP_DSR_HANDLER(DEVWRITELINE("maincpu:sio0", psxsio0_device, write_dsr))
489524   MCFG_ZNDIP_DATA_HANDLER(IOPORT(":DSW"))
490525
491526   // 5MHz NEC uPD78081 MCU:
trunk/src/mame/machine/cat702.c
r241484r241485
8787const device_type CAT702 = &device_creator<cat702_device>;
8888
8989cat702_device::cat702_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
90   psxsiodev_device(mconfig, CAT702, "CAT702", tag, owner, clock, "cat702", __FILE__)
90   device_t(mconfig, CAT702, "CAT702", tag, owner, clock, "cat702", __FILE__),
91   m_dataout_handler(*this)
9192{
9293}
9394
9495void cat702_device::device_start()
9596{
96   psxsiodev_device::device_start();
97   m_dataout_handler.resolve_safe();
9798
9899   save_item(NAME(m_select));
99100   save_item(NAME(m_state));
100101   save_item(NAME(m_bit));
102
103   m_dataout_handler(1);
101104}
102105
103106// Given the value for x7..x0 and linear transform coefficients a7..a0
r241484r241485
159162   m_transform = transform;
160163}
161164
162void cat702_device::select(int select)
165WRITE_LINE_MEMBER(cat702_device::write_select)
163166{
164   if (m_select != select)
167   if (m_select != state)
165168   {
166      if (!select)
169      if (!state)
167170      {
168171         m_state = 0xfc;
169172         m_bit = 0;
170173      }
171174      else
172175      {
173         data_out(0, PSX_SIO_IN_DATA);
176         m_dataout_handler(1);
174177      }
175178
176      m_select = select;
179      m_select = state;
177180   }
178181}
179182
180void cat702_device::data_in( int data, int mask )
183WRITE_LINE_MEMBER(cat702_device::write_clock)
181184{
182185   static const UINT8 initial_sbox[8] = { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x7f };
183186
184   if ( !m_select && (mask & PSX_SIO_OUT_CLOCK) != 0 && (data & PSX_SIO_OUT_CLOCK) == 0)
187   if (!state && m_clock && !m_select)
185188   {
186189      if (m_bit==0)
187190      {
r241484r241485
190193      }
191194
192195      // Compute the output and change the state
193      data_out(((m_state >> m_bit) & 1) != 0 ? PSX_SIO_IN_DATA : 0, PSX_SIO_IN_DATA);
196      m_dataout_handler(((m_state >> m_bit) & 1) != 0);
197   }
194198
195      if((data & PSX_SIO_OUT_DATA)==0)
199   if (state && !m_clock && !m_select)
200   {
201      if (!m_datain)
196202         apply_bit_sbox(m_bit);
197203
198204      m_bit++;
199205      m_bit&=7;
200206   }
207
208   m_clock = state;
201209}
210
211WRITE_LINE_MEMBER(cat702_device::write_datain)
212{
213   m_datain = state;
214}
trunk/src/mame/machine/cat702.h
r241484r241485
1/*  CAT702 ZN security chip */
1/*  CAT702 security chip */
22
33#pragma once
44
55#ifndef __CAT702_H__
66#define __CAT702_H__
77
8#include "cpu/psx/siodev.h"
8#include "emu.h"
99
1010extern const device_type CAT702;
1111
12class cat702_device : public psxsiodev_device
12#define MCFG_CAT702_DATAOUT_HANDLER(_devcb) \
13   devcb = &cat702_device::set_dataout_handler(*device, DEVCB_##_devcb);
14
15class cat702_device : public device_t
1316{
1417public:
1518   cat702_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
1619
17   void init(const UINT8 *transform);
18   void select(int select);
20   // static configuration helpers
21   template<class _Object> static devcb_base &set_dataout_handler(device_t &device, _Object object) { return downcast<cat702_device &>(device).m_dataout_handler.set_callback(object); }
1922
23   void init(const UINT8 *transform); // TODO: region
24
25   DECLARE_WRITE_LINE_MEMBER(write_select);
26   DECLARE_WRITE_LINE_MEMBER(write_datain);
27   DECLARE_WRITE_LINE_MEMBER(write_clock);
28
2029protected:
2130   virtual void device_start();
2231
2332private:
24   virtual void data_in( int data, int mask );
25
2633   UINT8 compute_sbox_coef(int sel, int bit);
2734   void apply_bit_sbox(int sel);
2835   void apply_sbox(const UINT8 *sbox);
2936
3037   const UINT8 *m_transform;
3138   int m_select;
39   int m_clock;
40   int m_datain;
3241   UINT8 m_state;
3342   UINT8 m_bit;
43
44   devcb_write_line m_dataout_handler;
3445};
3546
3647#endif
trunk/src/mame/machine/k573cass.c
r241484r241485
77
88#include "k573cass.h"
99
10// class konami573_cassette_interface
11
12konami573_cassette_interface::konami573_cassette_interface(const machine_config &mconfig, device_t &device)
13   : device_slot_card_interface(mconfig, device)
14{
15   m_slot = dynamic_cast<konami573_cassette_slot_device *>(device.owner());
16}
17
18konami573_cassette_interface::~konami573_cassette_interface()
19{
20}
21
22
23
1024WRITE_LINE_MEMBER(konami573_cassette_interface::write_line_d0)
1125{
1226}
r241484r241485
3145{
3246}
3347
34READ_LINE_MEMBER(konami573_cassette_interface::read_line_dsr)
35{
36   return 1;
37}
38
3948READ_LINE_MEMBER(konami573_cassette_interface::read_line_ds2401)
4049{
4150   return 0;
r241484r241485
5665
5766konami573_cassette_x_device::konami573_cassette_x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
5867   device_t(mconfig, KONAMI573_CASSETTE_X, "Konami 573 Cassette X", tag, owner, clock, "k573cassx", __FILE__),
59   device_slot_card_interface(mconfig, *this),
68   konami573_cassette_interface(mconfig, *this),
6069   m_x76f041(*this, "eeprom")
6170{
6271}
6372
6473konami573_cassette_x_device::konami573_cassette_x_device(const machine_config &mconfig, const device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
6574   device_t(mconfig, type, name, tag, owner, clock, shortname, __FILE__),
66   device_slot_card_interface(mconfig, *this),
75   konami573_cassette_interface(mconfig, *this),
6776   m_x76f041(*this, "eeprom")
6877{
6978}
r241484r241485
7988
8089void konami573_cassette_x_device::device_start()
8190{
91   output_dsr(0);
8292}
8393
8494WRITE_LINE_MEMBER(konami573_cassette_x_device::write_line_d0)
r241484r241485
171181
172182konami573_cassette_y_device::konami573_cassette_y_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
173183   device_t(mconfig, KONAMI573_CASSETTE_Y, "Konami 573 Cassette Y", tag, owner, clock, "k573cassy", __FILE__),
174   device_slot_card_interface(mconfig, *this),
184   konami573_cassette_interface(mconfig, *this),
175185   m_x76f100(*this, "eeprom"),
176186   m_d0_handler(*this),
177187   m_d1_handler(*this),
r241484r241485
186196
187197konami573_cassette_y_device::konami573_cassette_y_device(const machine_config &mconfig, const device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
188198   device_t(mconfig, type, name, tag, owner, clock, shortname, __FILE__),
189   device_slot_card_interface(mconfig, *this),
199   konami573_cassette_interface(mconfig, *this),
190200   m_x76f100(*this, "eeprom"),
191201   m_d0_handler(*this),
192202   m_d1_handler(*this),
r241484r241485
218228   m_d5_handler.resolve_safe();
219229   m_d6_handler.resolve_safe();
220230   m_d7_handler.resolve_safe();
231
232   output_dsr(0);
221233}
222234
223235READ_LINE_MEMBER(konami573_cassette_y_device::read_line_secflash_sda)
r241484r241485
305317
306318konami573_cassette_zi_device::konami573_cassette_zi_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
307319   device_t(mconfig, KONAMI573_CASSETTE_ZI, "Konami 573 Cassette ZI", tag, owner, clock, "k573casszi", __FILE__),
308   device_slot_card_interface(mconfig, *this),
320   konami573_cassette_interface(mconfig, *this),
309321   m_zs01(*this,"eeprom"),
310322   m_ds2401(*this, "id")
311323{
r241484r241485
324336
325337void konami573_cassette_zi_device::device_start()
326338{
339   output_dsr(0);
327340}
328341
329342WRITE_LINE_MEMBER(konami573_cassette_zi_device::write_line_d1)
r241484r241485
362375}
363376
364377
365const device_type KONAMI573_CASSETTE_SLOT_SERIAL = &device_creator<konami573_cassette_slot_serial_device>;
366
367konami573_cassette_slot_serial_device::konami573_cassette_slot_serial_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
368   psxsiodev_device(mconfig, KONAMI573_CASSETTE_SLOT, "Konami 573 Cassette Slot (SERIAL)", tag, owner, clock, "k573cassslotserial", __FILE__)
369{
370}
371
372void konami573_cassette_slot_serial_device::device_start()
373{
374   psxsiodev_device::device_start();
375}
376
377void konami573_cassette_slot_serial_device::_data_out( int data, int mask )
378{
379   data_out( data, mask );
380}
381
382void konami573_cassette_slot_serial_device::data_in( int data, int mask )
383{
384}
385
386
387378const device_type KONAMI573_CASSETTE_SLOT = &device_creator<konami573_cassette_slot_device>;
388379
389380konami573_cassette_slot_device::konami573_cassette_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
390381   device_t(mconfig, KONAMI573_CASSETTE_SLOT, "Konami 573 Cassette Slot", tag, owner, clock, "k573cassslot", __FILE__),
391382   device_slot_interface(mconfig, *this),
392   m_serial(*this, ":maincpu:sio1:cassette") /// HACK: this shouldn't know where the actual slot is.
383   m_dsr_handler(*this)
393384{
394385}
395386
396387void konami573_cassette_slot_device::device_start()
397388{
398   m_cassette = dynamic_cast<konami573_cassette_interface *>(get_card_device());
389   m_dsr_handler.resolve_safe();
399390
400   if( m_cassette != NULL && m_cassette->read_line_dsr() )
401   {
402      m_serial->_data_out( PSX_SIO_IN_DSR, PSX_SIO_IN_DSR );
403   }
404   else
405   {
406      m_serial->_data_out( PSX_SIO_IN_DSR, 0 );
407   }
391   m_dev = dynamic_cast<konami573_cassette_interface *>(get_card_device());
408392}
409393
410394WRITE_LINE_MEMBER(konami573_cassette_slot_device::write_line_d0)
411395{
412   if( m_cassette )
396   if( m_dev )
413397   {
414      m_cassette->write_line_d0( state );
398      m_dev->write_line_d0( state );
415399   }
416400}
417401
418402WRITE_LINE_MEMBER(konami573_cassette_slot_device::write_line_d1)
419403{
420   if( m_cassette )
404   if( m_dev )
421405   {
422      m_cassette->write_line_d1( state );
406      m_dev->write_line_d1( state );
423407   }
424408}
425409
426410WRITE_LINE_MEMBER(konami573_cassette_slot_device::write_line_d2)
427411{
428   if( m_cassette )
412   if( m_dev )
429413   {
430      m_cassette->write_line_d2( state );
414      m_dev->write_line_d2( state );
431415   }
432416}
433417
434418WRITE_LINE_MEMBER(konami573_cassette_slot_device::write_line_d3)
435419{
436   if( m_cassette )
420   if( m_dev )
437421   {
438      m_cassette->write_line_d3( state );
422      m_dev->write_line_d3( state );
439423   }
440424}
441425
442426WRITE_LINE_MEMBER(konami573_cassette_slot_device::write_line_d4)
443427{
444   if( m_cassette )
428   if( m_dev )
445429   {
446      m_cassette->write_line_d4( state );
430      m_dev->write_line_d4( state );
447431   }
448432}
449433
450434WRITE_LINE_MEMBER(konami573_cassette_slot_device::write_line_d5)
451435{
452   if( m_cassette )
436   if( m_dev )
453437   {
454      m_cassette->write_line_d5( state );
438      m_dev->write_line_d5( state );
455439   }
456440}
457441
458442WRITE_LINE_MEMBER(konami573_cassette_slot_device::write_line_d6)
459443{
460   if( m_cassette )
444   if( m_dev )
461445   {
462      m_cassette->write_line_d6( state );
446      m_dev->write_line_d6( state );
463447   }
464448}
465449
466450WRITE_LINE_MEMBER(konami573_cassette_slot_device::write_line_d7)
467451{
468   if( m_cassette )
452   if( m_dev )
469453   {
470      m_cassette->write_line_d7( state );
454      m_dev->write_line_d7( state );
471455   }
472456}
473457
474458WRITE_LINE_MEMBER(konami573_cassette_slot_device::write_line_zs01_sda)
475459{
476   if( m_cassette )
460   if( m_dev )
477461   {
478      m_cassette->write_line_zs01_sda( state );
462      m_dev->write_line_zs01_sda( state );
479463   }
480464}
481465
482466READ_LINE_MEMBER(konami573_cassette_slot_device::read_line_ds2401)
483467{
484   if( m_cassette )
468   if( m_dev )
485469   {
486      return m_cassette->read_line_ds2401();
470      return m_dev->read_line_ds2401();
487471   }
488472
489473   return 0;
r241484r241485
491475
492476READ_LINE_MEMBER(konami573_cassette_slot_device::read_line_secflash_sda)
493477{
494   if( m_cassette )
478   if( m_dev )
495479   {
496      return m_cassette->read_line_secflash_sda();
480      return m_dev->read_line_secflash_sda();
497481   }
498482
499483   return 0;
r241484r241485
501485
502486READ_LINE_MEMBER(konami573_cassette_slot_device::read_line_adc083x_do)
503487{
504   if( m_cassette )
488   if( m_dev )
505489   {
506      return m_cassette->read_line_adc083x_do();
490      return m_dev->read_line_adc083x_do();
507491   }
508492
509493   return 0;
r241484r241485
511495
512496READ_LINE_MEMBER(konami573_cassette_slot_device::read_line_adc083x_sars)
513497{
514   if( m_cassette )
498   if( m_dev )
515499   {
516      return m_cassette->read_line_adc083x_sars();
500      return m_dev->read_line_adc083x_sars();
517501   }
518502
519503   return 0;
trunk/src/mame/machine/k573cass.h
r241484r241485
1010#ifndef __K573CASS_H__
1111#define __K573CASS_H__
1212
13#include "cpu/psx/siodev.h"
1413#include "machine/adc083x.h"
1514#include "machine/ds2401.h"
1615#include "machine/x76f041.h"
1716#include "machine/x76f100.h"
1817#include "machine/zs01.h"
1918
20class konami573_cassette_interface
19#define MCFG_KONAMI573_CASSETTE_DSR_HANDLER(_devcb) \
20   devcb = &konami573_cassette_slot_device::set_dsr_handler(*device, DEVCB_##_devcb);
21
22
23extern const device_type KONAMI573_CASSETTE_SLOT;
24
25class konami573_cassette_interface;
26
27class konami573_cassette_slot_device : public device_t,
28   public device_slot_interface
2129{
30   friend class konami573_cassette_interface;
31
2232public:
33   konami573_cassette_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
34
35   template<class _Object> static devcb_base &set_dsr_handler(device_t &device, _Object object) { return downcast<konami573_cassette_slot_device &>(device).m_dsr_handler.set_callback(object); }
36
37   DECLARE_WRITE_LINE_MEMBER(write_line_d0);
38   DECLARE_WRITE_LINE_MEMBER(write_line_d1);
39   DECLARE_WRITE_LINE_MEMBER(write_line_d2);
40   DECLARE_WRITE_LINE_MEMBER(write_line_d3);
41   DECLARE_WRITE_LINE_MEMBER(write_line_d4);
42   DECLARE_WRITE_LINE_MEMBER(write_line_d5);
43   DECLARE_WRITE_LINE_MEMBER(write_line_d6);
44   DECLARE_WRITE_LINE_MEMBER(write_line_d7);
45   DECLARE_WRITE_LINE_MEMBER(write_line_zs01_sda);
46   DECLARE_READ_LINE_MEMBER(read_line_ds2401);
47   DECLARE_READ_LINE_MEMBER(read_line_secflash_sda);
48   DECLARE_READ_LINE_MEMBER(read_line_adc083x_do);
49   DECLARE_READ_LINE_MEMBER(read_line_adc083x_sars);
50
51protected:
52   virtual void device_start();
53
54   devcb_write_line m_dsr_handler;
55
56private:
57   konami573_cassette_interface *m_dev;
58};
59
60class konami573_cassette_interface : public device_slot_card_interface
61{
62   friend class konami573_cassette_slot_device;
63
64public:
65   konami573_cassette_interface(const machine_config &mconfig, device_t &device);
66   virtual ~konami573_cassette_interface();
67
68   DECLARE_WRITE_LINE_MEMBER(output_dsr) { m_slot->m_dsr_handler(state); }
69
2370   virtual DECLARE_WRITE_LINE_MEMBER(write_line_d0);
2471   virtual DECLARE_WRITE_LINE_MEMBER(write_line_d1) = 0;
2572   virtual DECLARE_WRITE_LINE_MEMBER(write_line_d2) = 0;
r241484r241485
3178   virtual DECLARE_WRITE_LINE_MEMBER(write_line_zs01_sda);
3279   virtual DECLARE_READ_LINE_MEMBER(read_line_ds2401);
3380   virtual DECLARE_READ_LINE_MEMBER(read_line_secflash_sda) = 0;
34   virtual DECLARE_READ_LINE_MEMBER(read_line_dsr);
3581   virtual DECLARE_READ_LINE_MEMBER(read_line_adc083x_do);
3682   virtual DECLARE_READ_LINE_MEMBER(read_line_adc083x_sars);
3783
38   virtual ~konami573_cassette_interface() {}
84   konami573_cassette_slot_device *m_slot;
3985};
4086
4187
4288extern const device_type KONAMI573_CASSETTE_X;
4389
4490class konami573_cassette_x_device: public device_t,
45   public konami573_cassette_interface,
46   public device_slot_card_interface
91   public konami573_cassette_interface
4792{
4893public:
4994   konami573_cassette_x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
r241484r241485
119164   devcb = &konami573_cassette_y_device::set_d7_handler(*device, DEVCB_##_devcb);
120165
121166class konami573_cassette_y_device: public device_t,
122   public konami573_cassette_interface,
123   public device_slot_card_interface
167   public konami573_cassette_interface
124168{
125169public:
126170   konami573_cassette_y_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
r241484r241485
184228extern const device_type KONAMI573_CASSETTE_ZI;
185229
186230class konami573_cassette_zi_device: public device_t,
187   public konami573_cassette_interface,
188   public device_slot_card_interface
231   public konami573_cassette_interface
189232{
190233public:
191234   konami573_cassette_zi_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
r241484r241485
208251};
209252
210253
211extern const device_type KONAMI573_CASSETTE_SLOT_SERIAL;
212
213class konami573_cassette_slot_serial_device : public psxsiodev_device
214{
215public:
216   konami573_cassette_slot_serial_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
217
218   void _data_out( int data, int mask );
219
220protected:
221   virtual void device_start();
222
223private:
224   virtual void data_in( int data, int mask );
225};
226
227
228extern const device_type KONAMI573_CASSETTE_SLOT;
229
230class konami573_cassette_slot_device : public device_t,
231   public device_slot_interface
232{
233public:
234   konami573_cassette_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
235
236   DECLARE_WRITE_LINE_MEMBER(write_line_d0);
237   DECLARE_WRITE_LINE_MEMBER(write_line_d1);
238   DECLARE_WRITE_LINE_MEMBER(write_line_d2);
239   DECLARE_WRITE_LINE_MEMBER(write_line_d3);
240   DECLARE_WRITE_LINE_MEMBER(write_line_d4);
241   DECLARE_WRITE_LINE_MEMBER(write_line_d5);
242   DECLARE_WRITE_LINE_MEMBER(write_line_d6);
243   DECLARE_WRITE_LINE_MEMBER(write_line_d7);
244   DECLARE_WRITE_LINE_MEMBER(write_line_zs01_sda);
245   DECLARE_READ_LINE_MEMBER(read_line_ds2401);
246   DECLARE_READ_LINE_MEMBER(read_line_secflash_sda);
247   DECLARE_READ_LINE_MEMBER(read_line_adc083x_do);
248   DECLARE_READ_LINE_MEMBER(read_line_adc083x_sars);
249
250protected:
251   virtual void device_start();
252
253private:
254   required_device<konami573_cassette_slot_serial_device> m_serial;
255   konami573_cassette_interface *m_cassette;
256};
257
258
259254#endif
trunk/src/mame/machine/zndip.c
r241484r241485
55const device_type ZNDIP = &device_creator<zndip_device>;
66
77zndip_device::zndip_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
8   psxsiodev_device(mconfig, ZNDIP, "ZNDIP", tag, owner, clock, "zndip", __FILE__),
9   m_data_handler(*this)
8   device_t(mconfig, ZNDIP, "ZNDIP", tag, owner, clock, "zndip", __FILE__),
9   m_data_handler(*this),
10   m_dataout_handler(*this),
11   m_dsr_handler(*this)
1012{
1113}
1214
1315void zndip_device::device_start()
1416{
15   psxsiodev_device::device_start();
16
1717   m_data_handler.resolve_safe( 0 );
18   m_dataout_handler.resolve_safe();
19   m_dsr_handler.resolve_safe();
1820
1921   m_dip_timer = timer_alloc( 0 );
22
23   m_dataout_handler(1);
24   m_dsr_handler(1);
2025}
2126
22void zndip_device::select(int select)
27WRITE_LINE_MEMBER(zndip_device::write_select)
2328{
24   if (m_select != select)
29   if (!state && m_select)
2530   {
26      if (!select)
27      {
28         m_bit = 0;
29         m_dip_timer->adjust( attotime::from_usec( 100 ), 1 );
30      }
31      else
32      {
33         data_out(0, PSX_SIO_IN_DATA | PSX_SIO_IN_DSR);
34      }
31      m_bit = 0;
32      m_dip_timer->adjust( attotime::from_usec( 100 ), 0 );
33   }
34   else
35   {
36      m_dataout_handler(1);
37      m_dsr_handler(1);
38   }
3539
36      m_select = select;
37   }
40   m_select = state;
3841}
3942
40void zndip_device::data_in( int data, int mask )
43WRITE_LINE_MEMBER(zndip_device::write_clock)
4144{
42   if( !m_select && ( mask & PSX_SIO_OUT_CLOCK ) != 0 && ( data & PSX_SIO_OUT_CLOCK ) == 0)
45   if (!state && m_clock && !m_select)
4346   {
4447      int dip = m_data_handler();
4548      int bit = ( ( dip >> m_bit ) & 1 );
4649//      verboselog( machine, 2, "read dip %02x -> %02x\n", n_data, bit * PSX_SIO_IN_DATA );
47      data_out( bit * PSX_SIO_IN_DATA, PSX_SIO_IN_DATA );
50      m_dataout_handler(bit);
4851      m_bit++;
4952      m_bit &= 7;
5053   }
54
55   m_clock = state;
5156}
5257
5358void zndip_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
5459{
55   data_out( param * PSX_SIO_IN_DSR, PSX_SIO_IN_DSR );
60   m_dsr_handler(param);
5661
57   if( param )
62   if( !param )
5863   {
59      m_dip_timer->adjust( attotime::from_usec( 50 ), 0 );
64      m_dip_timer->adjust( attotime::from_usec( 50 ), 1 );
6065   }
6166}
trunk/src/mame/machine/zndip.h
r241484r241485
55#ifndef __ZNDIP_H__
66#define __ZNDIP_H__
77
8#include "cpu/psx/siodev.h"
8#include "emu.h"
99
1010extern const device_type ZNDIP;
1111
12#define MCFG_ZNDIP_DATAOUT_HANDLER(_devcb) \
13   devcb = &zndip_device::set_dataout_handler(*device, DEVCB_##_devcb);
14
15#define MCFG_ZNDIP_DSR_HANDLER(_devcb) \
16   devcb = &zndip_device::set_dsr_handler(*device, DEVCB_##_devcb);
17
1218#define MCFG_ZNDIP_DATA_HANDLER(_devcb) \
1319   devcb = &zndip_device::set_data_handler(*device, DEVCB_##_devcb);
14class zndip_device : public psxsiodev_device
20
21class zndip_device : public device_t
1522{
1623public:
1724   zndip_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
1825
1926   // static configuration helpers
2027   template<class _Object> static devcb_base &set_data_handler(device_t &device, _Object object) { return downcast<zndip_device &>(device).m_data_handler.set_callback(object); }
28   template<class _Object> static devcb_base &set_dataout_handler(device_t &device, _Object object) { return downcast<zndip_device &>(device).m_dataout_handler.set_callback(object); }
29   template<class _Object> static devcb_base &set_dsr_handler(device_t &device, _Object object) { return downcast<zndip_device &>(device).m_dsr_handler.set_callback(object); }
2130
22   void select(int select);
31   WRITE_LINE_MEMBER(write_select);
32   WRITE_LINE_MEMBER(write_clock);
2333
2434protected:
2535   virtual void device_start();
2636   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
2737
2838private:
29   virtual void data_in( int data, int mask );
30
3139   devcb_read8 m_data_handler;
40   devcb_write_line m_dataout_handler;
41   devcb_write_line m_dsr_handler;
3242
3343   int m_select;
44   int m_clock;
45   int m_datain;
46
3447   UINT8 m_bit;
3548   emu_timer *m_dip_timer;
3649};
trunk/src/mess/drivers/psx.c
r241484r241485
493493   MCFG_RAM_MODIFY("maincpu:ram")
494494   MCFG_RAM_DEFAULT_SIZE("2M")
495495
496   MCFG_DEVICE_ADD("maincpu:sio0:controllers", PSXCONTROLLERPORTS, 0)
496   MCFG_DEVICE_ADD("controllers", PSXCONTROLLERPORTS, 0)
497   MCFG_PSX_CONTROLLER_PORTS_RXD_HANDLER(DEVWRITELINE("maincpu:sio0", psxsio0_device, write_rxd))
498   MCFG_PSX_CONTROLLER_PORTS_DSR_HANDLER(DEVWRITELINE("maincpu:sio0", psxsio0_device, write_dsr))
497499   MCFG_PSX_CTRL_PORT_ADD("port1", psx_controllers, "digital_pad")
498500   MCFG_PSX_CTRL_PORT_ADD("port2", psx_controllers, "digital_pad")
499501
502   MCFG_DEVICE_MODIFY("maincpu:sio0")
503   MCFG_PSX_SIO_DTR_HANDLER(DEVWRITELINE("^controllers", psxcontrollerports_device, write_dtr))
504   MCFG_PSX_SIO_SCK_HANDLER(DEVWRITELINE("^controllers", psxcontrollerports_device, write_sck))
505   MCFG_PSX_SIO_TXD_HANDLER(DEVWRITELINE("^controllers", psxcontrollerports_device, write_txd))
506
500507   /* video hardware */
501508   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0x100000, XTAL_53_693175MHz )
502509
r241484r241485
534541   MCFG_RAM_MODIFY("maincpu:ram")
535542   MCFG_RAM_DEFAULT_SIZE("2M")
536543
537   MCFG_DEVICE_ADD("maincpu:sio0:controllers", PSXCONTROLLERPORTS, 0)
544   MCFG_DEVICE_ADD("controllers", PSXCONTROLLERPORTS, 0)
545   MCFG_PSX_CONTROLLER_PORTS_RXD_HANDLER(DEVWRITELINE("maincpu:sio0", psxsio0_device, write_rxd))
546   MCFG_PSX_CONTROLLER_PORTS_DSR_HANDLER(DEVWRITELINE("maincpu:sio0", psxsio0_device, write_dsr))
538547   MCFG_PSX_CTRL_PORT_ADD("port1", psx_controllers, "digital_pad")
539548   MCFG_PSX_CTRL_PORT_ADD("port2", psx_controllers, "digital_pad")
540549
550   MCFG_DEVICE_MODIFY("maincpu:sio0")
551   MCFG_PSX_SIO_DTR_HANDLER(DEVWRITELINE("^controllers", psxcontrollerports_device, write_dtr))
552   MCFG_PSX_SIO_SCK_HANDLER(DEVWRITELINE("^controllers", psxcontrollerports_device, write_sck))
553   MCFG_PSX_SIO_TXD_HANDLER(DEVWRITELINE("^controllers", psxcontrollerports_device, write_txd))
554
541555   /* video hardware */
542556   /* TODO: visible area and refresh rate */
543557   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0x100000, XTAL_53_693175MHz )


Previous 199869 Revisions Next


© 1997-2024 The MAME Team