Previous 199869 Revisions Next

r18925 Saturday 10th November, 2012 at 18:53:00 UTC by smf
replaced usage of psx_sio_install_handler & psx_sio_input with devices. [smf]
[src/emu/cpu]cpu.mak
[src/emu/cpu/psx]psx.c psx.h sio.c sio.h siodev.c* siodev.h*
[src/mame]mame.mak
[src/mame/drivers]ksys573.c taitogn.c zn.c
[src/mame/includes]psx.h
[src/mame/machine]k573cass.c* k573cass.h* psx.c zndip.c* zndip.h* znsec.c znsec.h
[src/mess]mess.mak
[src/mess/drivers]psx.c
[src/mess/machine]psxcport.c* psxcport.h*

trunk/src/emu/cpu/psx/psx.c
r18924r18925
31673167   return downcast<psxcpu_device *>( device.subdevice( cputag ) );
31683168}
31693169
3170void psxcpu_device::install_sio_handler( device_t &device, const char *cputag, int n_port, psx_sio_handler p_f_sio_handler )
3171{
3172   psxsio_device *sio;
3173
3174   switch( n_port )
3175   {
3176   case 0:
3177      sio = getcpu( device, cputag )->subdevice<psxsio_device>("sio0");
3178      break;
3179   case 1:
3180      sio = getcpu( device, cputag )->subdevice<psxsio_device>("sio1");
3181      break;
3182   default:
3183      return;
3184   }
3185
3186   sio->install_handler( p_f_sio_handler );
3187}
3188
3189void psxcpu_device::sio_input( device_t &device, const char *cputag, int n_port, int n_mask, int n_data )
3190{
3191   psxsio_device *sio;
3192
3193   switch( n_port )
3194   {
3195   case 0:
3196      sio = getcpu( device, cputag )->subdevice<psxsio_device>("sio0");
3197      break;
3198   case 1:
3199      sio = getcpu( device, cputag )->subdevice<psxsio_device>("sio1");
3200      break;
3201   default:
3202      return;
3203   }
3204
3205   sio->input( n_mask, n_data );
3206}
3207
32083170READ32_HANDLER( psxcpu_device::gpu_r )
32093171{
32103172   return m_gpu_read_handler( space, offset, mem_mask );
trunk/src/emu/cpu/psx/psx.h
r18924r18925
143143   DECLARE_READ32_MEMBER( gpu_r );
144144
145145   static psxcpu_device *getcpu( device_t &device, const char *cputag );
146   static void install_sio_handler( device_t &device, const char *cputag, int n_port, psx_sio_handler p_f_sio_handler );
147   static void sio_input( device_t &device, const char *cputag, int n_port, int n_mask, int n_data );
148146
149147protected:
150148   psxcpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, address_map_constructor internal_map);
trunk/src/emu/cpu/psx/siodev.c
r0r18925
1#include "sio.h"
2#include "siodev.h"
3
4psxsiodev_device::psxsiodev_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) :
5   device_t(mconfig, type, name, tag, owner, clock)
6{
7}
8
9void psxsiodev_device::device_start()
10{
11   m_dataout = 0;
12}
13
14void psxsiodev_device::data_out( int data, int mask )
15{
16   m_dataout = ( m_dataout & ~mask ) | ( data & mask );
17
18   m_psxsio->input_update();
19}
trunk/src/emu/cpu/psx/sio.c
r18924r18925
66 */
77
88#include "sio.h"
9#include "includes/psx.h"
109
1110#define VERBOSE_LEVEL ( 0 )
1211
r18924r18925
3837
3938psxsio_device::psxsio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock) :
4039   device_t(mconfig, type, "PSX SIO", tag, owner, clock),
41   m_fn_handler(NULL),
4240   m_irq_handler(*this)
4341{
4442}
r18924r18925
8280   save_item( NAME( m_tx_shift ) );
8381   save_item( NAME( m_rx_bits ) );
8482   save_item( NAME( m_tx_bits ) );
85}
8683
87void psxsio_device::install_handler( psx_sio_handler p_f_sio_handler )
88{
89   m_fn_handler = p_f_sio_handler;
84   deviceCount = 0;
85
86   for( device_t *device = first_subdevice(); device != NULL; device = device->next() )
87   {
88      psxsiodev_device *psxsiodev = dynamic_cast<psxsiodev_device *>(device);
89      if( psxsiodev != NULL )
90      {
91         devices[ deviceCount++ ] = psxsiodev;
92         psxsiodev->m_psxsio = this;
93      }
94   }
95
96   input_update();
9097}
9198
9299void psxsio_device::sio_interrupt()
r18924r18925
140147   m_timer->adjust( n_time );
141148}
142149
150void psxsio_device::output( int data, int mask )
151{
152   int new_outputdata = ( m_outputdata & ~mask ) | ( data & mask );
153   int new_mask = m_outputdata ^ new_outputdata;
154
155   if( new_mask != 0 )
156   {
157      m_outputdata = new_outputdata;
158
159      for( int i = 0; i < deviceCount; i++ )
160      {
161         devices[ i ]->data_in( m_outputdata, new_mask );
162      }
163   }
164}
165
143166void psxsio_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
144167{
145168   verboselog( machine(), 2, "sio tick\n" );
r18924r18925
167190      m_tx_shift >>= 1;
168191      m_tx_bits--;
169192
170      if( m_fn_handler != NULL )
193      if( type() == PSX_SIO0 )
171194      {
172         if( type() == PSX_SIO0 )
173         {
174            m_tx &= ~PSX_SIO_OUT_CLOCK;
175            (*m_fn_handler)( machine(), m_tx );
176            m_tx |= PSX_SIO_OUT_CLOCK;
177         }
178
179         (*m_fn_handler)( machine(), m_tx );
195         m_tx &= ~PSX_SIO_OUT_CLOCK;
196         output( m_tx, PSX_SIO_OUT_CLOCK | PSX_SIO_OUT_DATA );
197         m_tx |= PSX_SIO_OUT_CLOCK;
180198      }
181199
200      output( m_tx, PSX_SIO_OUT_CLOCK | PSX_SIO_OUT_DATA );
201
182202      if( m_tx_bits == 0 &&
183203         ( m_control & SIO_CONTROL_TX_IENA ) != 0 )
184204      {
r18924r18925
259279            m_tx &= ~PSX_SIO_OUT_DTR;
260280         }
261281
262         if( ( ( m_tx ^ m_tx_prev ) & PSX_SIO_OUT_DTR ) != 0 )
263         {
264            if( m_fn_handler != NULL )
265            {
266               (*m_fn_handler)( machine(), m_tx );
267            }
268         }
282         output( m_tx, PSX_SIO_OUT_DTR );
269283
270284         m_tx_prev = m_tx;
271285
r18924r18925
341355   return data;
342356}
343357
344void psxsio_device::input( int n_mask, int n_data )
358void psxsio_device::input_update()
345359{
346   verboselog( machine(), 1, "psx_sio_input( %s, %02x, %02x )\n", tag(), n_mask, n_data );
347   m_rx = ( m_rx & ~n_mask ) | ( n_data & n_mask );
360   int data = 0;
348361
362   for( int i = 0; i < deviceCount; i++ )
363   {
364      data |= devices[ i ]->m_dataout;
365   }
366
367   int mask = data ^ m_rx;
368
369   verboselog( machine(), 1, "input_update( %s, %02x, %02x )\n", tag(), mask, data );
370
371   m_rx = data;
372
349373   if( ( m_rx & PSX_SIO_IN_DSR ) != 0 )
350374   {
351375      m_status |= SIO_STATUS_DSR;
trunk/src/emu/cpu/psx/siodev.h
r0r18925
1#pragma once
2
3#include "emu.h"
4
5#ifndef _PSXSIODEV_H_
6#define _PSXSIODEV_H_
7
8#define PSX_SIO_OUT_DATA ( 1 )   /* COMMAND */
9#define PSX_SIO_OUT_DTR ( 2 )   /* ATT */
10#define PSX_SIO_OUT_RTS ( 4 )
11#define PSX_SIO_OUT_CLOCK ( 8 )   /* CLOCK */
12#define PSX_SIO_IN_DATA ( 1 )   /* DATA */
13#define PSX_SIO_IN_DSR ( 2 )   /* ACK */
14#define PSX_SIO_IN_CTS ( 4 )
15
16class psxsio_device;
17
18class psxsiodev_device : public device_t
19{
20   friend class psxsio_device;
21
22public:
23   // construction/destruction
24   psxsiodev_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
25
26protected:
27   // device-level overrides
28   virtual void device_start();
29
30   void data_out( int data, int mask );
31
32private:
33   psxsio_device *m_psxsio;
34
35   virtual void data_in( int data, int mask ) = 0;
36   int m_dataout;
37};
38
39#endif
trunk/src/emu/cpu/psx/sio.h
r18924r18925
1111#define __PSXSIO_H__
1212
1313#include "emu.h"
14#include "siodev.h"
1415
1516extern const device_type PSX_SIO0;
1617extern const device_type PSX_SIO1;
1718
18typedef void ( *psx_sio_handler )( running_machine &, int );
19
2019#define MCFG_PSX_SIO_IRQ_HANDLER(_devcb) \
2120   devcb = &psxsio_device::set_irq_handler(*device, DEVCB2_##_devcb); \
2221
23#define PSX_SIO_OUT_DATA ( 1 )   /* COMMAND */
24#define PSX_SIO_OUT_DTR ( 2 )   /* ATT */
25#define PSX_SIO_OUT_RTS ( 4 )
26#define PSX_SIO_OUT_CLOCK ( 8 )   /* CLOCK */
27#define PSX_SIO_IN_DATA ( 1 )   /* DATA */
28#define PSX_SIO_IN_DSR ( 2 )   /* ACK */
29#define PSX_SIO_IN_CTS ( 4 )
30
3122#define SIO_BUF_SIZE ( 8 )
3223
3324#define SIO_STATUS_TX_RDY ( 1 << 0 )
r18924r18925
5344   // static configuration helpers
5445   template<class _Object> static devcb2_base &set_irq_handler(device_t &device, _Object object) { return downcast<psxsio_device &>(device).m_irq_handler.set_callback(object); }
5546
56   void install_handler( psx_sio_handler p_f_sio_handler );
57
5847   DECLARE_WRITE32_MEMBER( write );
5948   DECLARE_READ32_MEMBER( read );
6049
61   void input( int n_mask, int n_data );
50   void input_update();
6251
6352protected:
6453   // device-level overrides
r18924r18925
6756   virtual void device_post_load();
6857
6958private:
59   void output( int data, int mask );
7060   void sio_interrupt();
7161   void sio_timer_adjust();
7262
r18924r18925
8676   UINT32 m_rx_bits;
8777
8878   emu_timer *m_timer;
89   psx_sio_handler m_fn_handler;
9079
9180   devcb2_write_line m_irq_handler;
81
82   psxsiodev_device *devices[ 10 ];
83   int deviceCount;
84
85   int m_outputdata;
86   int m_inputdata;
9287};
9388
9489class psxsio0_device : public psxsio_device
trunk/src/emu/cpu/cpu.mak
r18924r18925
931931
932932ifneq ($(filter PSX,$(CPUS)),)
933933OBJDIRS += $(CPUOBJ)/psx
934CPUOBJS += $(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
934CPUOBJS += $(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
935935DASMOBJS += $(CPUOBJ)/psx/psxdasm.o
936936endif
937937
trunk/src/mess/drivers/psx.c
r18924r18925
1818#include "zlib.h"
1919#include "machine/psxcd.h"
2020#include "machine/psxcard.h"
21#include "machine/psxcport.h"
2122
22struct pad_t
23{
24   UINT8 n_shiftin;
25   UINT8 n_shiftout;
26   int n_bits;
27   int n_state;
28   int n_byte;
29   int b_lastclock;
30   int b_ack;
31};
32
33
3423class psx1_state : public psx_state
3524{
3625public:
r18924r18925
3928
4029   UINT8 *m_exe_buffer;
4130   int m_exe_size;
42   pad_t m_pad[ 2 ];
4331   int m_cd_param_p;
4432   int m_cd_result_p;
4533   int m_cd_result_c;
r18924r18925
5543   DECLARE_DIRECT_UPDATE_MEMBER(psx_setopbase);
5644   DECLARE_DRIVER_INIT(psx);
5745   DECLARE_MACHINE_RESET(psx);
58   TIMER_CALLBACK_MEMBER(psx_pad_ack);
5946};
6047
6148
r18924r18925
476463   return IMAGE_INIT_PASS;
477464}
478465
479/* PAD emulation */
480
481#define PAD_STATE_IDLE ( 0 )
482#define PAD_STATE_LISTEN ( 1 )
483#define PAD_STATE_ACTIVE ( 2 )
484#define PAD_STATE_READ ( 3 )
485#define PAD_STATE_UNLISTEN ( 4 )
486#define PAD_STATE_MEMCARD ( 5 )
487
488#define PAD_TYPE_STANDARD ( 4 )
489#define PAD_BYTES_STANDARD ( 2 )
490
491#define PAD_CMD_START ( 0x01 )
492#define PAD_CMD_READ  ( 0x42 ) /* B */
493
494#define PAD_DATA_OK   ( 0x5a ) /* Z */
495#define PAD_DATA_IDLE ( 0xff )
496
497TIMER_CALLBACK_MEMBER(psx1_state::psx_pad_ack)
498{
499   int n_port = param;
500   pad_t *pad = &m_pad[ n_port ];
501
502   if( pad->n_state != PAD_STATE_IDLE )
503   {
504      psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, pad->b_ack * PSX_SIO_IN_DSR );
505      if( !pad->b_ack )
506      {
507         pad->b_ack = 1;
508         machine().scheduler().timer_set(attotime::from_usec( 2 ), timer_expired_delegate(FUNC(psx1_state::psx_pad_ack),this) , n_port);
509      }
510   }
511}
512
513static void psx_pad( running_machine &machine, int n_port, int n_data )
514{
515   psx1_state *state = machine.driver_data<psx1_state>();
516   pad_t *pad = &state->m_pad[ n_port ];
517   int b_sel;
518   int b_clock;
519   int b_data;
520   int b_ack;
521   int b_ready;
522   static const char *const portnames[] = { "IN0", "IN1", "IN2", "IN3" };
523   psxcard_device *psxcard = NULL;
524
525   if (n_port == 0)
526   {
527      psxcard = machine.device<psxcard_device>("card1");
528   }
529   else
530   {
531      psxcard = machine.device<psxcard_device>("card2");
532   }
533
534   b_sel = ( n_data & PSX_SIO_OUT_DTR ) / PSX_SIO_OUT_DTR;
535   b_clock = ( n_data & PSX_SIO_OUT_CLOCK ) / PSX_SIO_OUT_CLOCK;
536   b_data = ( n_data & PSX_SIO_OUT_DATA ) / PSX_SIO_OUT_DATA;
537   b_ready = 0;
538   b_ack = 0;
539
540   if( b_sel )
541   {
542      pad->n_state = PAD_STATE_IDLE;
543   }
544
545   switch( pad->n_state )
546   {
547   case PAD_STATE_LISTEN:
548   case PAD_STATE_ACTIVE:
549   case PAD_STATE_READ:
550   case PAD_STATE_MEMCARD:
551      if( pad->b_lastclock && !b_clock )
552      {
553         psx_sio_input( machine, 0, PSX_SIO_IN_DATA, ( pad->n_shiftout & 1 ) * PSX_SIO_IN_DATA );
554         pad->n_shiftout >>= 1;
555      }
556      if( !pad->b_lastclock && b_clock )
557      {
558         pad->n_shiftin >>= 1;
559         pad->n_shiftin |= b_data << 7;
560         pad->n_bits++;
561
562         if( pad->n_bits == 8 )
563         {
564            pad->n_bits = 0;
565            b_ready = 1;
566         }
567      }
568      break;
569   }
570
571   pad->b_lastclock = b_clock;
572
573   switch( pad->n_state )
574   {
575   case PAD_STATE_IDLE:
576      if( !b_sel )
577      {
578         pad->n_state = PAD_STATE_LISTEN;
579         pad->n_shiftout = PAD_DATA_IDLE;
580         pad->n_bits = 0;
581      }
582      break;
583   case PAD_STATE_LISTEN:
584      if( b_ready )
585      {
586         if( pad->n_shiftin == PAD_CMD_START )
587         {
588            pad->n_state = PAD_STATE_ACTIVE;
589            pad->n_shiftout = ( PAD_TYPE_STANDARD << 4 ) | ( PAD_BYTES_STANDARD >> 1 );
590            b_ack = 1;
591         }
592         else if( psxcard->transfer(pad->n_shiftin, &pad->n_shiftout) )
593         {
594            pad->n_state = PAD_STATE_MEMCARD;
595            b_ack = 1;
596         }
597         else
598         {
599            pad->n_state = PAD_STATE_UNLISTEN;
600         }
601      }
602      break;
603   case PAD_STATE_MEMCARD:
604      if( b_ready )
605      {
606         if( psxcard->transfer(pad->n_shiftin, &pad->n_shiftout) )
607         {
608            b_ack = 1;
609         }
610         else
611         {
612            b_ack = 0;
613            pad->n_state = PAD_STATE_IDLE;
614         }
615      }
616      break;
617   case PAD_STATE_ACTIVE:
618      if( b_ready )
619      {
620         if( pad->n_shiftin == PAD_CMD_READ )
621         {
622            pad->n_state = PAD_STATE_READ;
623            pad->n_shiftout = PAD_DATA_OK;
624            pad->n_byte = 0;
625            b_ack = 1;
626         }
627         else
628         {
629            pad->n_state = PAD_STATE_UNLISTEN;
630         }
631      }
632      break;
633   case PAD_STATE_READ:
634      if( b_ready )
635      {
636         if( pad->n_byte < PAD_BYTES_STANDARD )
637         {
638            pad->n_shiftout = machine.root_device().ioport(portnames[pad->n_byte + ( n_port * PAD_BYTES_STANDARD )])->read();
639            pad->n_byte++;
640            b_ack = 1;
641         }
642         else
643         {
644            pad->n_state = PAD_STATE_LISTEN;
645         }
646      }
647      break;
648   }
649
650   if( b_ack )
651   {
652      pad->b_ack = 0;
653      machine.scheduler().timer_set(attotime::from_usec( 10 ), timer_expired_delegate(FUNC(psx1_state::psx_pad_ack),state), n_port);
654   }
655}
656
657static void psx_sio0( running_machine &machine, int n_data )
658{
659   /* todo: raise data & ack when nothing is driving it low */
660   psx_pad( machine, 0, n_data );
661   psx_pad( machine, 1, n_data ^ PSX_SIO_OUT_DTR );
662}
663
664466/* ----------------------------------------------------------------------- */
665467
666468static void cd_dma_read( psxcd_device *psxcd, UINT32 n_address, INT32 n_size )
r18924r18925
701503   AM_RANGE(0xfffe0130, 0xfffe0133) AM_WRITENOP
702504ADDRESS_MAP_END
703505
704
705MACHINE_RESET_MEMBER(psx1_state,psx)
706{
707   psx_sio_install_handler( machine(), 0, psx_sio0 );
708}
709
710506DRIVER_INIT_MEMBER(psx1_state,psx)
711507{
712508   psx_driver_init(machine());
r18924r18925
765561   MCFG_CPU_ADD( "maincpu", CXD8530CQ, XTAL_67_7376MHz )
766562   MCFG_CPU_PROGRAM_MAP( psx_map )
767563
768   MCFG_MACHINE_RESET_OVERRIDE(psx1_state, psx )
564   MCFG_DEVICE_ADD("maincpu:sio0:controllers", PSXCONTROLLERPORTS, 0)
769565
770566   /* video hardware */
771567   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0x100000, XTAL_53_693175MHz )
r18924r18925
796592   MCFG_CPU_ADD( "maincpu", CXD8530AQ, XTAL_67_7376MHz )
797593   MCFG_CPU_PROGRAM_MAP( psx_map)
798594
799   MCFG_MACHINE_RESET_OVERRIDE(psx1_state, psx )
800
801595   /* video hardware */
802596   /* TODO: visible area and refresh rate */
803597   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0x100000, XTAL_53_693175MHz )
trunk/src/mess/mess.mak
r18924r18925
16681668
16691669$(MESSOBJ)/sony.a:            \
16701670   $(MESS_DRIVERS)/psx.o      \
1671   $(MESS_MACHINE)/psxcport.o   \
16711672   $(MESS_MACHINE)/psxcd.o      \
16721673   $(MESS_MACHINE)/psxcddrv.o   \
16731674   $(MESS_MACHINE)/psxcard.o   \
trunk/src/mess/machine/psxcport.c
r0r18925
1/* PAD emulation */
2
3#include "psxcport.h"
4#include "machine/psxcard.h"
5
6#define PAD_STATE_IDLE ( 0 )
7#define PAD_STATE_LISTEN ( 1 )
8#define PAD_STATE_ACTIVE ( 2 )
9#define PAD_STATE_READ ( 3 )
10#define PAD_STATE_UNLISTEN ( 4 )
11#define PAD_STATE_MEMCARD ( 5 )
12
13#define PAD_TYPE_STANDARD ( 4 )
14#define PAD_BYTES_STANDARD ( 2 )
15
16#define PAD_CMD_START ( 0x01 )
17#define PAD_CMD_READ  ( 0x42 ) /* B */
18
19#define PAD_DATA_OK   ( 0x5a ) /* Z */
20#define PAD_DATA_IDLE ( 0xff )
21
22const device_type PSXCONTROLLERPORTS = &device_creator<psxcontrollerports_device>;
23
24psxcontrollerports_device::psxcontrollerports_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
25   psxsiodev_device(mconfig, PSXCONTROLLERPORTS, "PSXCONTROLLERPORTS", tag, owner, clock)
26{
27}
28
29void psxcontrollerports_device::device_start()
30{
31   psxsiodev_device::device_start();
32
33   m_ack_timer = timer_alloc( 0 );
34}
35
36void psxcontrollerports_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
37{
38   int n_port = param;
39   pad_t *pad = &m_pad[ n_port ];
40
41   if( pad->n_state != PAD_STATE_IDLE )
42   {
43      data_out( pad->b_ack * PSX_SIO_IN_DSR, PSX_SIO_IN_DSR );
44
45      if( !pad->b_ack )
46      {
47         pad->b_ack = 1;
48         m_ack_timer->adjust( attotime::from_usec( 2 ), n_port );
49      }
50   }
51}
52
53void psxcontrollerports_device::psx_pad( int n_port, int n_data )
54{
55   pad_t *pad = &m_pad[ n_port ];
56   int b_sel;
57   int b_clock;
58   int b_data;
59   int b_ack;
60   int b_ready;
61   static const char *const portnames[] = { ":IN0", ":IN1", ":IN2", ":IN3" };
62   psxcard_device *psxcard = NULL;
63
64   if (n_port == 0)
65   {
66      psxcard = machine().device<psxcard_device>(":card1");
67   }
68   else
69   {
70      psxcard = machine().device<psxcard_device>(":card2");
71   }
72
73   b_sel = ( n_data & PSX_SIO_OUT_DTR ) / PSX_SIO_OUT_DTR;
74   b_clock = ( n_data & PSX_SIO_OUT_CLOCK ) / PSX_SIO_OUT_CLOCK;
75   b_data = ( n_data & PSX_SIO_OUT_DATA ) / PSX_SIO_OUT_DATA;
76   b_ready = 0;
77   b_ack = 0;
78
79   if( b_sel )
80   {
81      pad->n_state = PAD_STATE_IDLE;
82   }
83
84   switch( pad->n_state )
85   {
86   case PAD_STATE_LISTEN:
87   case PAD_STATE_ACTIVE:
88   case PAD_STATE_READ:
89   case PAD_STATE_MEMCARD:
90      if( pad->b_lastclock && !b_clock )
91      {
92         data_out( ( pad->n_shiftout & 1 ) * PSX_SIO_IN_DATA, PSX_SIO_IN_DATA );
93         pad->n_shiftout >>= 1;
94      }
95      if( !pad->b_lastclock && b_clock )
96      {
97         pad->n_shiftin >>= 1;
98         pad->n_shiftin |= b_data << 7;
99         pad->n_bits++;
100
101         if( pad->n_bits == 8 )
102         {
103            pad->n_bits = 0;
104            b_ready = 1;
105         }
106      }
107      break;
108   }
109
110   pad->b_lastclock = b_clock;
111
112   switch( pad->n_state )
113   {
114   case PAD_STATE_IDLE:
115      if( !b_sel )
116      {
117         pad->n_state = PAD_STATE_LISTEN;
118         pad->n_shiftout = PAD_DATA_IDLE;
119         pad->n_bits = 0;
120      }
121      break;
122   case PAD_STATE_LISTEN:
123      if( b_ready )
124      {
125         if( pad->n_shiftin == PAD_CMD_START )
126         {
127            pad->n_state = PAD_STATE_ACTIVE;
128            pad->n_shiftout = ( PAD_TYPE_STANDARD << 4 ) | ( PAD_BYTES_STANDARD >> 1 );
129            b_ack = 1;
130         }
131         else if( psxcard->transfer(pad->n_shiftin, &pad->n_shiftout) )
132         {
133            pad->n_state = PAD_STATE_MEMCARD;
134            b_ack = 1;
135         }
136         else
137         {
138            pad->n_state = PAD_STATE_UNLISTEN;
139         }
140      }
141      break;
142   case PAD_STATE_MEMCARD:
143      if( b_ready )
144      {
145         if( psxcard->transfer(pad->n_shiftin, &pad->n_shiftout) )
146         {
147            b_ack = 1;
148         }
149         else
150         {
151            b_ack = 0;
152            pad->n_state = PAD_STATE_IDLE;
153         }
154      }
155      break;
156   case PAD_STATE_ACTIVE:
157      if( b_ready )
158      {
159         if( pad->n_shiftin == PAD_CMD_READ )
160         {
161            pad->n_state = PAD_STATE_READ;
162            pad->n_shiftout = PAD_DATA_OK;
163            pad->n_byte = 0;
164            b_ack = 1;
165         }
166         else
167         {
168            pad->n_state = PAD_STATE_UNLISTEN;
169         }
170      }
171      break;
172   case PAD_STATE_READ:
173      if( b_ready )
174      {
175         if( pad->n_byte < PAD_BYTES_STANDARD )
176         {
177            pad->n_shiftout = ioport(portnames[pad->n_byte + ( n_port * PAD_BYTES_STANDARD )])->read();
178            pad->n_byte++;
179            b_ack = 1;
180         }
181         else
182         {
183            pad->n_state = PAD_STATE_LISTEN;
184         }
185      }
186      break;
187   }
188
189   if( b_ack )
190   {
191      pad->b_ack = 0;
192      m_ack_timer->adjust( attotime::from_usec( 10 ), n_port );
193   }
194}
195
196void psxcontrollerports_device::data_in( int data, int mask )
197{
198   /* todo: raise data & ack when nothing is driving it low */
199   psx_pad( 0, data );
200   psx_pad( 1, data ^ PSX_SIO_OUT_DTR );
201}
trunk/src/mess/machine/psxcport.h
r0r18925
1#pragma once
2
3#ifndef __PSXCPORT_H__
4#define __PSXCPORT_H__
5
6#include "cpu/psx/siodev.h"
7
8extern const device_type PSXCONTROLLERPORTS;
9
10struct pad_t
11{
12   UINT8 n_shiftin;
13   UINT8 n_shiftout;
14   int n_bits;
15   int n_state;
16   int n_byte;
17   int b_lastclock;
18   int b_ack;
19};
20
21class psxcontrollerports_device : public psxsiodev_device
22{
23public:
24   psxcontrollerports_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
25
26protected:
27   void device_start();
28   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
29
30private:
31   void psx_pad( int n_port, int n_data );
32   virtual void data_in( int data, int mask );
33
34   pad_t m_pad[ 2 ];
35   emu_timer *m_ack_timer;
36};
37
38#endif
trunk/src/mame/machine/znsec.c
r18924r18925
8787const device_type ZNSEC = &device_creator<znsec_device>;
8888
8989znsec_device::znsec_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
90   device_t(mconfig, ZNSEC, "ZNSEC", tag, owner, clock)
90   psxsiodev_device(mconfig, ZNSEC, "ZNSEC", tag, owner, clock)
9191{
9292}
9393
9494void znsec_device::device_start()
9595{
96   psxsiodev_device::device_start();
97
9698   save_item(NAME(m_select));
9799   save_item(NAME(m_state));
98100   save_item(NAME(m_bit));
r18924r18925
159161
160162void znsec_device::select(int select)
161163{
162   if (m_select && !select)
164   if (m_select != select)
163165   {
164      m_state = 0xfc;
165      m_bit = 0;
166      if (!select)
167      {
168         m_state = 0xfc;
169         m_bit = 0;
170      }
171      else
172      {
173         data_out(0, PSX_SIO_IN_DATA);
174      }
175   
176      m_select = select;
166177   }
167   
168   m_select = select;
169178}
170179
171UINT8 znsec_device::step(UINT8 input)
180void znsec_device::data_in( int data, int mask )
172181{
173   UINT8 res;
174182   static const UINT8 initial_sbox[8] = { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x7f };
175183
176   if (m_bit==0)
184   if ( !m_select && (mask & PSX_SIO_OUT_CLOCK) != 0 && (data & PSX_SIO_OUT_CLOCK) == 0)
177185   {
178      // Apply the initial sbox
179      apply_sbox(initial_sbox);
180   }
186      if (m_bit==0)
187      {
188         // Apply the initial sbox
189         apply_sbox(initial_sbox);
190      }
181191
182   // Compute the output and change the state
183   res = (m_state >> m_bit) & 1;
184   if((input & 1)==0)
185      apply_bit_sbox(m_bit);
192      // 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);
186194
187   m_bit++;
188   m_bit&=7;
189   return res;
195      if((data & PSX_SIO_OUT_DATA)==0)
196         apply_bit_sbox(m_bit);
197
198      m_bit++;
199      m_bit&=7;
200   }
190201}
trunk/src/mame/machine/znsec.h
r18924r18925
55#ifndef __ZNSEC_H__
66#define __ZNSEC_H__
77
8#include "emu.h"
8#include "cpu/psx/siodev.h"
99
1010extern const device_type ZNSEC;
1111
12class znsec_device : public device_t
12class znsec_device : public psxsiodev_device
1313{
1414public:
1515   znsec_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
1616
1717   void init(const UINT8 *transform);
1818   void select(int select);
19   UINT8 step(UINT8 input);
2019
2120protected:
2221   void device_start();
2322
2423private:
24   virtual void data_in( int data, int mask );
25
2526   UINT8 compute_sbox_coef(int sel, int bit);
2627   void apply_bit_sbox(int sel);
2728   void apply_sbox(const UINT8 *sbox);
trunk/src/mame/machine/k573cass.c
r0r18925
1#include "k573cass.h"
2
3const device_type KONAMI573CASSETTE = &device_creator<konami573cassette_device>;
4
5konami573cassette_device::konami573cassette_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
6   psxsiodev_device(mconfig, KONAMI573CASSETTE, "KONAMI 573 CASSETTE", tag, owner, clock)
7{
8}
9
10void konami573cassette_device::device_start()
11{
12   psxsiodev_device::device_start();
13
14   data_out( PSX_SIO_IN_DSR, PSX_SIO_IN_DSR );
15}
16
17void konami573cassette_device::data_in( int data, int mask )
18{
19}
trunk/src/mame/machine/k573cass.h
r0r18925
1#pragma once
2
3#ifndef __K573CASS_H__
4#define __K573CASS_H__
5
6#include "cpu/psx/siodev.h"
7
8extern const device_type KONAMI573CASSETTE;
9
10class konami573cassette_device : public psxsiodev_device
11{
12public:
13   konami573cassette_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
14
15protected:
16   void device_start();
17
18private:
19   virtual void data_in( int data, int mask );
20};
21
22#endif
trunk/src/mame/machine/psx.c
r18924r18925
4848   verboselog( p_psx, 1, "psx_com_delay_r( %08x )\n", mem_mask );
4949   return p_psx->n_com_delay;
5050}
51
52/* SIO */
53
54void psx_sio_install_handler( running_machine &machine, int n_port, psx_sio_handler p_f_sio_handler )
55{
56   psxcpu_device::install_sio_handler( *machine.device("maincpu^"), "maincpu", n_port, p_f_sio_handler );
57}
58
59void psx_sio_input( running_machine &machine, int n_port, int n_mask, int n_data )
60{
61   psxcpu_device::sio_input( *machine.device("maincpu^"), "maincpu", n_port, n_mask, n_data );
62}
trunk/src/mame/machine/zndip.c
r0r18925
1#include "zndip.h"
2
3const device_type ZNDIP = &device_creator<zndip_device>;
4
5zndip_device::zndip_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
6   psxsiodev_device(mconfig, ZNDIP, "ZNDIP", tag, owner, clock),
7   m_data_handler(*this)
8{
9}
10
11void zndip_device::device_start()
12{
13   psxsiodev_device::device_start();
14
15   m_data_handler.resolve_safe( 0 );
16
17   m_dip_timer = timer_alloc( 0 );
18}
19
20void zndip_device::select(int select)
21{
22   if (m_select != select)
23   {
24      if (!select)
25      {
26         m_bit = 0;
27         m_dip_timer->adjust( attotime::from_usec( 100 ), 1 );
28      }
29      else
30      {
31         data_out(0, PSX_SIO_IN_DATA | PSX_SIO_IN_DSR);
32      }
33   
34      m_select = select;
35   }
36}
37
38void zndip_device::data_in( int data, int mask )
39{
40   if( !m_select && ( mask & PSX_SIO_OUT_CLOCK ) != 0 && ( data & PSX_SIO_OUT_CLOCK ) == 0)
41   {
42      int dip = m_data_handler();
43      int bit = ( ( dip >> m_bit ) & 1 );
44//      verboselog( machine, 2, "read dip %02x -> %02x\n", n_data, bit * PSX_SIO_IN_DATA );
45      data_out( bit * PSX_SIO_IN_DATA, PSX_SIO_IN_DATA );
46      m_bit++;
47      m_bit &= 7;
48   }
49}
50
51void zndip_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
52{
53   data_out( param * PSX_SIO_IN_DSR, PSX_SIO_IN_DSR );
54
55   if( param )
56   {
57      m_dip_timer->adjust( attotime::from_usec( 50 ), 0 );
58   }
59}
trunk/src/mame/machine/zndip.h
r0r18925
1#pragma once
2
3#ifndef __ZNDIP_H__
4#define __ZNDIP_H__
5
6#include "cpu/psx/siodev.h"
7
8extern const device_type ZNDIP;
9
10#define MCFG_ZNDIP_DATA_HANDLER(_devcb) \
11   devcb = &zndip_device::set_data_handler(*device, DEVCB2_##_devcb); \
12
13class zndip_device : public psxsiodev_device
14{
15public:
16   zndip_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
17
18   // static configuration helpers
19   template<class _Object> static devcb2_base &set_data_handler(device_t &device, _Object object) { return downcast<zndip_device &>(device).m_data_handler.set_callback(object); }
20
21   void select(int select);
22
23protected:
24   void device_start();
25   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
26
27private:
28   virtual void data_in( int data, int mask );
29
30   devcb2_read8 m_data_handler;
31
32   int m_select;
33   UINT8 m_bit;
34   emu_timer *m_dip_timer;
35};
36
37#endif
trunk/src/mame/includes/psx.h
r18924r18925
2727extern void psx_driver_init( running_machine &machine );
2828DECLARE_WRITE32_HANDLER( psx_com_delay_w );
2929DECLARE_READ32_HANDLER( psx_com_delay_r );
30extern void psx_sio_install_handler( running_machine &, int, psx_sio_handler );
31extern void psx_sio_input( running_machine &, int, int, int );
3230
3331#define PSX_H ( 1 )
3432#endif
trunk/src/mame/mame.mak
r18924r18925
920920   $(DRIVERS)/konamim2.o \
921921   $(DRIVERS)/kontest.o \
922922   $(DRIVERS)/konendev.o \
923   $(DRIVERS)/ksys573.o $(MACHINE)/zs01.o \
923   $(DRIVERS)/ksys573.o $(MACHINE)/k573cass.o $(MACHINE)/zs01.o \
924924   $(DRIVERS)/labyrunr.o $(VIDEO)/labyrunr.o \
925925   $(DRIVERS)/lethal.o $(VIDEO)/lethal.o \
926926   $(DRIVERS)/mainevt.o $(VIDEO)/mainevt.o \
r18924r18925
13661366   $(DRIVERS)/snk68.o $(VIDEO)/snk68.o \
13671367
13681368$(MAMEOBJ)/sony.a: \
1369   $(DRIVERS)/zn.o $(MACHINE)/znsec.o \
1369   $(DRIVERS)/zn.o $(MACHINE)/zndip.o $(MACHINE)/znsec.o \
13701370   $(MACHINE)/psx.o
13711371
13721372$(MAMEOBJ)/stern.a: \
trunk/src/mame/drivers/zn.c
r18924r18925
1818#include "machine/nvram.h"
1919#include "machine/mb3773.h"
2020#include "machine/znsec.h"
21#include "machine/zndip.h"
2122#include "machine/idectrl.h"
2223#include "audio/taitosnd.h"
2324#include "sound/2610intf.h"
r18924r18925
3536   zn_state(const machine_config &mconfig, device_type type, const char *tag) :
3637      psx_state(mconfig, type, tag),
3738      m_gpu(*this, "gpu"),
38      m_znsec0(*this,"znsec0"),
39      m_znsec1(*this,"znsec1")
39      m_znsec0(*this,"maincpu:sio0:znsec0"),
40      m_znsec1(*this,"maincpu:sio0:znsec1"),
41      m_zndip(*this,"maincpu:sio0:zndip")
4042   {
4143   }
4244
4345   required_device<psxgpu_device> m_gpu;
4446   required_device<znsec_device> m_znsec0;
4547   required_device<znsec_device> m_znsec1;
48   required_device<zndip_device> m_zndip;
4649   UINT32 m_n_znsecsel;
47   UINT32 m_b_znsecport;
48   int m_n_dip_bit;
49   int m_b_lastclock;
50   emu_timer *m_dip_timer;
5150
5251   size_t m_taitofx1_eeprom_size1;
5352   UINT8 *m_taitofx1_eeprom1;
r18924r18925
126125   DECLARE_MACHINE_RESET(coh1002v);
127126   DECLARE_MACHINE_RESET(coh1002m);
128127   INTERRUPT_GEN_MEMBER(qsound_interrupt);
129   TIMER_CALLBACK_MEMBER(dip_timer_fired);
130128};
131129
132130INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level, const char *s_fmt, ... )
r18924r18925
319317   return m_n_znsecsel;
320318}
321319
322static void sio_znsec0_handler( running_machine &machine, int n_data )
323{
324   zn_state *state = machine.driver_data<zn_state>();
325
326   if( ( n_data & PSX_SIO_OUT_CLOCK ) == 0 )
327   {
328      if( state->m_b_lastclock )
329      {
330         psx_sio_input( machine, 0, PSX_SIO_IN_DATA, ( state->m_znsec0->step( ( n_data & PSX_SIO_OUT_DATA ) != 0 ) != 0 ) * PSX_SIO_IN_DATA );
331      }
332
333      state->m_b_lastclock = 0;
334   }
335   else
336   {
337      state->m_b_lastclock = 1;
338   }
339}
340
341static void sio_znsec1_handler( running_machine &machine, int n_data )
342{
343   zn_state *state = machine.driver_data<zn_state>();
344
345   if( ( n_data & PSX_SIO_OUT_CLOCK ) == 0 )
346   {
347      if( state->m_b_lastclock )
348      {
349         psx_sio_input( machine, 0, PSX_SIO_IN_DATA, ( state->m_znsec1->step( ( n_data & PSX_SIO_OUT_DATA ) != 0 ) != 0 ) * PSX_SIO_IN_DATA );
350      }
351
352      state->m_b_lastclock = 0;
353   }
354   else
355   {
356      state->m_b_lastclock = 1;
357   }
358}
359
360static void sio_pad_handler( running_machine &machine, int n_data )
361{
362   zn_state *state = machine.driver_data<zn_state>();
363
364   if( ( n_data & PSX_SIO_OUT_DTR ) != 0 )
365   {
366      state->m_b_znsecport = 1;
367   }
368   else
369   {
370      state->m_b_znsecport = 0;
371   }
372
373   verboselog( machine, 2, "read pad %04x %04x %02x\n", state->m_n_znsecsel, state->m_b_znsecport, n_data );
374   psx_sio_input( machine, 0, PSX_SIO_IN_DATA | PSX_SIO_IN_DSR, PSX_SIO_IN_DATA | PSX_SIO_IN_DSR );
375}
376
377static void sio_dip_handler( running_machine &machine, int n_data )
378{
379   zn_state *state = machine.driver_data<zn_state>();
380
381   if( ( n_data & PSX_SIO_OUT_CLOCK ) == 0 )
382   {
383      if( state->m_b_lastclock )
384      {
385         int bit = ( ( state->ioport("DSW")->read() >> state->m_n_dip_bit ) & 1 );
386         verboselog( machine, 2, "read dip %02x -> %02x\n", n_data, bit * PSX_SIO_IN_DATA );
387         psx_sio_input( machine, 0, PSX_SIO_IN_DATA, bit * PSX_SIO_IN_DATA );
388         state->m_n_dip_bit++;
389         state->m_n_dip_bit &= 7;
390      }
391      state->m_b_lastclock = 0;
392   }
393   else
394   {
395      state->m_b_lastclock = 1;
396   }
397}
398
399320WRITE32_MEMBER(zn_state::znsecsel_w)
400321{
401322   COMBINE_DATA( &m_n_znsecsel );
402323
403324   m_znsec0->select( ( m_n_znsecsel >> 2 ) & 1 );
404325   m_znsec1->select( ( m_n_znsecsel >> 3 ) & 1 );
326   m_zndip->select( ( m_n_znsecsel & 0x8c ) != 0x8c );
405327
406   if( ( m_n_znsecsel & 0x80 ) == 0 )
407   {
408      psx_sio_install_handler( machine(), 0, sio_pad_handler );
409      psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
410   }
411   else if( ( m_n_znsecsel & 0x08 ) == 0 )
412   {
413      psx_sio_install_handler( machine(), 0, sio_znsec1_handler );
414      psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
415   }
416   else if( ( m_n_znsecsel & 0x04 ) == 0 )
417   {
418      psx_sio_install_handler( machine(), 0, sio_znsec0_handler );
419      psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
420   }
421   else
422   {
423      m_n_dip_bit = 0;
424      m_b_lastclock = 1;
425
426      psx_sio_install_handler( machine(), 0, sio_dip_handler );
427      psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
428
429      m_dip_timer->adjust( downcast<cpu_device *>(&space.device())->cycles_to_attotime( 100 ), 1 );
430   }
431
432328   verboselog( machine(), 2, "znsecsel_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
433329}
434330
435TIMER_CALLBACK_MEMBER(zn_state::dip_timer_fired)
436{
437   psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, param * PSX_SIO_IN_DSR );
438
439   if( param )
440   {
441      m_dip_timer->adjust( machine().device<cpu_device>( "maincpu" )->cycles_to_attotime(50 ) );
442   }
443}
444
445331READ32_MEMBER(zn_state::boardconfig_r)
446332{
447333   /*
r18924r18925
536422      {
537423         state->m_znsec0->init( zn_config_table[ n_game ].p_n_mainsec );
538424         state->m_znsec1->init( zn_config_table[ n_game ].p_n_gamesec );
539         psx_sio_install_handler( machine, 0, sio_pad_handler );
425//         psx_sio_install_handler( machine, 0, sio_pad_handler );
540426         break;
541427      }
542428      n_game++;
543429   }
544
545   state->m_dip_timer = machine.scheduler().timer_alloc( timer_expired_delegate(FUNC(zn_state::dip_timer_fired),state), NULL );
546430}
547431
548static void zn_machine_init( running_machine &machine )
549{
550   zn_state *state = machine.driver_data<zn_state>();
551
552   state->m_n_dip_bit = 0;
553   state->m_b_lastclock = 1;
554}
555
556432static MACHINE_CONFIG_START( zn1_1mb_vram, zn_state )
557433   /* basic machine hardware */
558434   MCFG_CPU_ADD( "maincpu", CXD8530CQ, XTAL_67_7376MHz )
559435   MCFG_CPU_PROGRAM_MAP( zn_map)
560436
561   MCFG_DEVICE_ADD("znsec0", ZNSEC, 0)
562   MCFG_DEVICE_ADD("znsec1", ZNSEC, 0)
437   MCFG_DEVICE_ADD("maincpu:sio0:znsec0", ZNSEC, 0)
438   MCFG_DEVICE_ADD("maincpu:sio0:znsec1", ZNSEC, 0)
439   MCFG_DEVICE_ADD("maincpu:sio0:zndip", ZNDIP, 0)
440   MCFG_ZNDIP_DATA_HANDLER(IOPORT(":DSW"))
563441
564442   /* video hardware */
565443   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561Q, 0x100000, XTAL_53_693175MHz )
r18924r18925
583461   MCFG_CPU_ADD( "maincpu", CXD8661R, XTAL_100MHz )
584462   MCFG_CPU_PROGRAM_MAP( zn_map)
585463
586   MCFG_DEVICE_ADD("znsec0", ZNSEC, 0)
587   MCFG_DEVICE_ADD("znsec1", ZNSEC, 0)
464   MCFG_DEVICE_ADD("maincpu:sio0:znsec0", ZNSEC, 0)
465   MCFG_DEVICE_ADD("maincpu:sio0:znsec1", ZNSEC, 0)
466   MCFG_DEVICE_ADD("maincpu:sio0:zndip", ZNDIP, 0)
467   MCFG_ZNDIP_DATA_HANDLER(IOPORT(":DSW"))
588468
589469   /* video hardware */
590470   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8654Q, 0x200000, XTAL_53_693175MHz )
r18924r18925
767647   machine().root_device().membank( "bank1" )->set_base( machine().root_device().memregion( "user2" )->base() ); /* fixed game rom */
768648   machine().root_device().membank( "bank2" )->set_base( machine().root_device().memregion( "user2" )->base() + 0x400000 ); /* banked game rom */
769649   machine().root_device().membank( "bank3" )->set_base( machine().root_device().memregion( "user3" )->base() ); /* country rom */
770   zn_machine_init(machine());
771650}
772651
773652static ADDRESS_MAP_START( qsound_map, AS_PROGRAM, 8, zn_state )
r18924r18925
975854   machine().root_device().membank( "bank1" )->set_base( machine().root_device().memregion( "user2" )->base() ); /* fixed game rom */
976855   machine().root_device().membank( "bank2" )->set_base( machine().root_device().memregion( "user2" )->base() + 0x400000 ); /* banked game rom */
977856   machine().root_device().membank( "bank3" )->set_base( machine().root_device().memregion( "user3" )->base() ); /* country rom */
978   zn_machine_init(machine());
979857}
980858
981859static MACHINE_CONFIG_DERIVED( coh3002c, zn2 )
r18924r18925
12601138{
12611139   membank( "bank1" )->set_base( memregion( "user2" )->base() ); /* banked game rom */
12621140   membank( "bank2" )->set_base( m_taitofx1_eeprom1 );
1263   zn_machine_init(machine());
12641141}
12651142
12661143static ADDRESS_MAP_START( fx1a_sound_map, AS_PROGRAM, 8, zn_state )
r18924r18925
13501227
13511228MACHINE_RESET_MEMBER(zn_state,coh1000tb)
13521229{
1353
13541230   membank( "bank1" )->set_base( memregion( "user2" )->base() ); /* banked game rom */
13551231   membank( "bank2" )->set_base( m_taitofx1_eeprom1 );
13561232   membank( "bank3" )->set_base( m_taitofx1_eeprom2 );
1357   zn_machine_init(machine());
13581233}
13591234
13601235static MACHINE_CONFIG_DERIVED( coh1000tb, zn1_2mb_vram )
r18924r18925
15301405MACHINE_RESET_MEMBER(zn_state,coh1000w)
15311406{
15321407   machine().root_device().membank( "bank1" )->set_base( machine().root_device().memregion( "user2" )->base() ); /* fixed game rom */
1533   zn_machine_init(machine());
15341408
15351409   machine().device("ide")->reset();
15361410}
r18924r18925
17181592MACHINE_RESET_MEMBER(zn_state,coh1002e)
17191593{
17201594   machine().root_device().membank( "bank1" )->set_base( machine().root_device().memregion( "user2" )->base() ); /* banked game rom */
1721   zn_machine_init(machine());
17221595}
17231596
17241597static ADDRESS_MAP_START( psarc_snd_map, AS_PROGRAM, 16, zn_state )
r18924r18925
18621735{
18631736   machine().root_device().membank( "bank1" )->set_base( machine().root_device().memregion( "user2" )->base() ); /* fixed game rom */
18641737   machine().root_device().membank( "bank2" )->set_base( machine().root_device().memregion( "user2" )->base() + 0x400000 ); /* banked game rom */
1865
1866   zn_machine_init(machine());
18671738}
18681739
18691740static MACHINE_CONFIG_DERIVED( bam2, zn1_2mb_vram )
r18924r18925
21902061MACHINE_RESET_MEMBER(zn_state,coh1000a)
21912062{
21922063   machine().root_device().membank( "bank1" )->set_base( machine().root_device().memregion( "user2" )->base() ); /* fixed game rom */
2193   zn_machine_init(machine());
21942064   if( ( !strcmp( machine().system().name, "jdredd" ) ) ||
21952065      ( !strcmp( machine().system().name, "jdreddb" ) ) )
21962066   {
r18924r18925
23462216MACHINE_RESET_MEMBER(zn_state,coh1001l)
23472217{
23482218   machine().root_device().membank( "bank1" )->set_base( machine().root_device().memregion( "user2" )->base() ); /* banked rom */
2349   zn_machine_init(machine());
23502219}
23512220
23522221static MACHINE_CONFIG_DERIVED( coh1001l, zn1_2mb_vram )
r18924r18925
23902259{
23912260   machine().root_device().membank( "bank1" )->set_base( machine().root_device().memregion( "user2" )->base() ); /* fixed game rom */
23922261   machine().root_device().membank( "bank2" )->set_base( machine().root_device().memregion( "user3" )->base() ); /* banked rom */
2393   zn_machine_init(machine());
23942262}
23952263
23962264static MACHINE_CONFIG_DERIVED( coh1002v, zn1_2mb_vram )
r18924r18925
25922460MACHINE_RESET_MEMBER(zn_state,coh1002m)
25932461{
25942462   machine().root_device().membank( "bank1" )->set_base( machine().root_device().memregion( "user2" )->base() );
2595   zn_machine_init(machine());
25962463}
25972464
25982465READ8_MEMBER(zn_state::cbaj_z80_latch_r)
trunk/src/mame/drivers/ksys573.c
r18924r18925
444444#include "sound/cdda.h"
445445#include "sound/mas3507d.h"
446446#include "cdrom.h"
447#include "machine/k573cass.h"
447448
448449#define VERBOSE_LEVEL ( 0 )
449450
r18924r18925
13901391
13911392DRIVER_INIT_MEMBER(ksys573_state,konami573)
13921393{
1393
13941394   psx_driver_init(machine());
13951395   atapi_init(machine());
13961396
r18924r18925
14011401
14021402MACHINE_RESET_MEMBER(ksys573_state,konami573)
14031403{
1404
1405   if( machine().device<device_secure_serial_flash>("install_eeprom") )
1406   {
1407      /* security cart */
1408      psx_sio_input( machine(), 1, PSX_SIO_IN_DSR, PSX_SIO_IN_DSR );
1409   }
1410
14111404   m_flash_bank = -1;
14121405
14131406   update_mode(machine());
r18924r18925
31463139// Up to two carts can be used
31473140
31483141static MACHINE_CONFIG_DERIVED( konami573x, konami573 )
3142   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31493143   MCFG_X76F041_ADD( "install_eeprom" )
31503144MACHINE_CONFIG_END
31513145
31523146static MACHINE_CONFIG_DERIVED( konami573y, konami573 )
3147   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31533148   MCFG_X76F100_ADD( "install_eeprom" )
31543149MACHINE_CONFIG_END
31553150
31563151static MACHINE_CONFIG_DERIVED( konami573yi, konami573 )
3152   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31573153   MCFG_X76F100_ADD( "install_eeprom" )
31583154   MCFG_DS2401_ADD(  "install_id" )
31593155MACHINE_CONFIG_END
31603156
31613157static MACHINE_CONFIG_DERIVED( konami573zi, konami573 )
3158   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31623159   MCFG_ZS01_ADD(    "install_eeprom", "install_id" )
31633160   MCFG_DS2401_ADD(  "install_id" )
31643161MACHINE_CONFIG_END
31653162
31663163static MACHINE_CONFIG_DERIVED( k573baitx, k573bait )
3164   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31673165   MCFG_X76F041_ADD( "install_eeprom" )
31683166MACHINE_CONFIG_END
31693167
31703168static MACHINE_CONFIG_DERIVED( k573dx, k573d )
3169   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31713170   MCFG_X76F041_ADD( "install_eeprom" )
31723171MACHINE_CONFIG_END
31733172
31743173static MACHINE_CONFIG_DERIVED( k573dxi, k573d )
3174   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31753175   MCFG_X76F041_ADD( "install_eeprom" )
31763176   MCFG_DS2401_ADD(  "install_id" )
31773177MACHINE_CONFIG_END
31783178
31793179static MACHINE_CONFIG_DERIVED( k573dxzi, k573d )
3180   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31803181   MCFG_X76F041_ADD( "install_eeprom" )
31813182   MCFG_DS2401_ADD(  "install_id" )
31823183   MCFG_ZS01_ADD(    "game_eeprom", "game_id" )
r18924r18925
31843185MACHINE_CONFIG_END
31853186
31863187static MACHINE_CONFIG_DERIVED( k573dyi, k573d )
3188   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31873189   MCFG_X76F100_ADD( "install_eeprom" )
31883190   MCFG_DS2401_ADD(  "install_id" )
31893191MACHINE_CONFIG_END
31903192
31913193static MACHINE_CONFIG_DERIVED( k573dyyi, k573d )
3194   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31923195   MCFG_X76F100_ADD( "install_eeprom" )
31933196   MCFG_DS2401_ADD(  "install_id" )
31943197   MCFG_X76F100_ADD( "game_eeprom" )
r18924r18925
31963199MACHINE_CONFIG_END
31973200
31983201static MACHINE_CONFIG_DERIVED( k573dzi, k573d )
3202   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
31993203   MCFG_ZS01_ADD(    "install_eeprom", "install_id" )
32003204   MCFG_DS2401_ADD(  "install_id" )
32013205MACHINE_CONFIG_END
32023206
32033207static MACHINE_CONFIG_DERIVED( pccard1x, pccard1 )
3208   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
32043209   MCFG_X76F041_ADD( "install_eeprom" )
32053210MACHINE_CONFIG_END
32063211
32073212static MACHINE_CONFIG_DERIVED( pccard1xi, pccard1 )
3213   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
32083214   MCFG_X76F041_ADD( "install_eeprom" )
32093215   MCFG_DS2401_ADD(  "install_id" )
32103216MACHINE_CONFIG_END
32113217
32123218static MACHINE_CONFIG_DERIVED( pccard1yi, pccard1 )
3219   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
32133220   MCFG_X76F100_ADD( "install_eeprom" )
32143221   MCFG_DS2401_ADD(  "install_id" )
32153222MACHINE_CONFIG_END
32163223
32173224static MACHINE_CONFIG_DERIVED( pccard1dxzi, pccard1d )
3225   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
32183226   MCFG_X76F041_ADD( "install_eeprom" )
32193227   MCFG_DS2401_ADD(  "install_id" )
32203228   MCFG_ZS01_ADD(    "game_eeprom", "game_id" )
r18924r18925
32223230MACHINE_CONFIG_END
32233231
32243232static MACHINE_CONFIG_DERIVED( pccard1dzi, pccard1d )
3233   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
32253234   MCFG_ZS01_ADD(    "install_eeprom", "install_id" )
32263235   MCFG_DS2401_ADD(  "install_id" )
32273236MACHINE_CONFIG_END
32283237
32293238static MACHINE_CONFIG_DERIVED( pccard2yyi, pccard2 )
3239   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
32303240   MCFG_X76F100_ADD( "install_eeprom" )
32313241   MCFG_DS2401_ADD(  "install_id" )
32323242   MCFG_X76F100_ADD( "game_eeprom" )
r18924r18925
32343244MACHINE_CONFIG_END
32353245
32363246static MACHINE_CONFIG_DERIVED( pccard2dxzi, pccard2d )
3247   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
32373248   MCFG_X76F041_ADD( "install_eeprom" )
32383249   MCFG_DS2401_ADD(  "install_id" )
32393250   MCFG_ZS01_ADD(    "game_eeprom", "game_id" )
r18924r18925
32413252MACHINE_CONFIG_END
32423253
32433254static MACHINE_CONFIG_DERIVED( pccard2dyyi, pccard2d )
3255   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
32443256   MCFG_X76F100_ADD( "install_eeprom" )
32453257   MCFG_DS2401_ADD(  "install_id" )
32463258   MCFG_X76F100_ADD( "game_eeprom" )
r18924r18925
32483260MACHINE_CONFIG_END
32493261
32503262static MACHINE_CONFIG_DERIVED( pccard2dzi, pccard2d )
3263   MCFG_DEVICE_ADD("maincpu:sio1:k573cass", KONAMI573CASSETTE, 0)
32513264   MCFG_ZS01_ADD(    "install_eeprom", "install_id" )
32523265   MCFG_DS2401_ADD(  "install_id" )
32533266MACHINE_CONFIG_END
trunk/src/mame/drivers/taitogn.c
r18924r18925
324324#include "machine/at28c16.h"
325325#include "machine/intelfsh.h"
326326#include "machine/znsec.h"
327#include "machine/zndip.h"
327328#include "machine/idectrl.h"
328329#include "machine/mb3773.h"
329330#include "sound/spu.h"
r18924r18925
334335public:
335336   taitogn_state(const machine_config &mconfig, device_type type, const char *tag) :
336337      psx_state(mconfig, type, tag),
337      m_znsec0(*this,"znsec0"),
338      m_znsec1(*this,"znsec1")
338      m_znsec0(*this,"maincpu:sio0:znsec0"),
339      m_znsec1(*this,"maincpu:sio0:znsec1"),
340      m_zndip(*this,"maincpu:sio0:zndip")
339341   {
340342   }
341343
342344   required_device<znsec_device> m_znsec0;
343345   required_device<znsec_device> m_znsec1;
346   required_device<zndip_device> m_zndip;
344347
345348   intel_te28f160_device *m_biosflash;
346349   intel_e28f400_device *m_pgmflash;
r18924r18925
357360   int m_v;
358361
359362   UINT32 m_n_znsecsel;
360   UINT32 m_b_znsecport;
361   int m_n_dip_bit;
362   int m_b_lastclock;
363   emu_timer *m_dip_timer;
364363
365364   UINT32 m_coin_info;
366365   UINT32 m_mux_data;
r18924r18925
395394   DECLARE_DRIVER_INIT(coh3002t_mp);
396395   DECLARE_DRIVER_INIT(coh3002t);
397396   DECLARE_MACHINE_RESET(coh3002t);
398   TIMER_CALLBACK_MEMBER(dip_timer_fired);
399397};
400398
401399
r18924r18925
692690   return m_n_znsecsel;
693691}
694692
695static void sio_znsec0_handler( running_machine &machine, int n_data )
696{
697   taitogn_state *state = machine.driver_data<taitogn_state>();
698
699   if( ( n_data & PSX_SIO_OUT_CLOCK ) == 0 )
700   {
701      if( state->m_b_lastclock )
702         psx_sio_input( machine, 0, PSX_SIO_IN_DATA, ( state->m_znsec0->step( ( n_data & PSX_SIO_OUT_DATA ) != 0 ) != 0 ) * PSX_SIO_IN_DATA );
703
704      state->m_b_lastclock = 0;
705   }
706   else
707   {
708      state->m_b_lastclock = 1;
709   }
710}
711
712static void sio_znsec1_handler( running_machine &machine, int n_data )
713{
714   taitogn_state *state = machine.driver_data<taitogn_state>();
715
716   if( ( n_data & PSX_SIO_OUT_CLOCK ) == 0 )
717   {
718      if( state->m_b_lastclock )
719         psx_sio_input( machine, 0, PSX_SIO_IN_DATA, ( state->m_znsec1->step( ( n_data & PSX_SIO_OUT_DATA ) != 0 ) != 0 ) * PSX_SIO_IN_DATA );
720
721      state->m_b_lastclock = 0;
722   }
723   else
724   {
725      state->m_b_lastclock = 1;
726   }
727}
728
729static void sio_pad_handler( running_machine &machine, int n_data )
730{
731   taitogn_state *state = machine.driver_data<taitogn_state>();
732
733   if( ( n_data & PSX_SIO_OUT_DTR ) != 0 )
734   {
735      state->m_b_znsecport = 1;
736   }
737   else
738   {
739      state->m_b_znsecport = 0;
740   }
741
742   psx_sio_input( machine, 0, PSX_SIO_IN_DATA | PSX_SIO_IN_DSR, PSX_SIO_IN_DATA | PSX_SIO_IN_DSR );
743}
744
745static void sio_dip_handler( running_machine &machine, int n_data )
746{
747   taitogn_state *state = machine.driver_data<taitogn_state>();
748
749   if( ( n_data & PSX_SIO_OUT_CLOCK ) == 0 )
750   {
751      if( state->m_b_lastclock )
752      {
753         int bit = ( ( state->ioport("DSW")->read() >> state->m_n_dip_bit ) & 1 );
754         psx_sio_input( machine, 0, PSX_SIO_IN_DATA, bit * PSX_SIO_IN_DATA );
755         state->m_n_dip_bit++;
756         state->m_n_dip_bit &= 7;
757      }
758      state->m_b_lastclock = 0;
759   }
760   else
761   {
762      state->m_b_lastclock = 1;
763   }
764}
765
766693WRITE32_MEMBER(taitogn_state::znsecsel_w)
767694{
768695   COMBINE_DATA( &m_n_znsecsel );
769696
770697   m_znsec0->select( ( m_n_znsecsel >> 2 ) & 1 );
771698   m_znsec1->select( ( m_n_znsecsel >> 3 ) & 1 );
772
773   if( ( m_n_znsecsel & 0x80 ) == 0 )
774   {
775      psx_sio_install_handler( machine(), 0, sio_pad_handler );
776      psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
777   }
778   else if( ( m_n_znsecsel & 0x08 ) == 0 )
779   {
780      psx_sio_install_handler( machine(), 0, sio_znsec1_handler );
781      psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
782   }
783   else if( ( m_n_znsecsel & 0x04 ) == 0 )
784   {
785      psx_sio_install_handler( machine(), 0, sio_znsec0_handler );
786      psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
787   }
788   else
789   {
790      m_n_dip_bit = 0;
791      m_b_lastclock = 1;
792
793      psx_sio_install_handler( machine(), 0, sio_dip_handler );
794      psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
795
796      m_dip_timer->adjust( downcast<cpu_device *>(&space.device())->cycles_to_attotime( 100 ), 1 );
797   }
699   m_zndip->select( ( m_n_znsecsel & 0x8c ) != 0x8c );
798700}
799701
800TIMER_CALLBACK_MEMBER(taitogn_state::dip_timer_fired)
801{
802
803   psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, param * PSX_SIO_IN_DSR );
804
805   if( param )
806   {
807      m_dip_timer->adjust(machine().device<cpu_device>("maincpu")->cycles_to_attotime(50));
808   }
809}
810
811
812702READ32_MEMBER(taitogn_state::boardconfig_r)
813703{
814704   /*
r18924r18925
881771   psx_driver_init(machine());
882772   m_znsec0->init(tt10);
883773   m_znsec1->init(tt16);
884   psx_sio_install_handler(machine(), 0, sio_pad_handler);
885   m_dip_timer = machine().scheduler().timer_alloc( timer_expired_delegate(FUNC(taitogn_state::dip_timer_fired),this), NULL );
886774
887775   UINT32 metalength;
888776   memset(m_cis, 0xff, 512);
r18924r18925
898786
899787MACHINE_RESET_MEMBER(taitogn_state,coh3002t)
900788{
901
902   m_b_lastclock = 1;
903789   m_locked = 0x1ff;
904790   install_handlers(machine(), 0);
905791   m_control = 0;
r18924r18925
951837   MCFG_CPU_ADD( "maincpu", CXD8661R, XTAL_100MHz )
952838   MCFG_CPU_PROGRAM_MAP(taitogn_map)
953839
954   MCFG_DEVICE_ADD("znsec0", ZNSEC, 0)
955   MCFG_DEVICE_ADD("znsec1", ZNSEC, 0)
840   MCFG_DEVICE_ADD("maincpu:sio0:znsec0", ZNSEC, 0)
841   MCFG_DEVICE_ADD("maincpu:sio0:znsec1", ZNSEC, 0)
842   MCFG_DEVICE_ADD("maincpu:sio0:zndip", ZNDIP, 0)
843   MCFG_ZNDIP_DATA_HANDLER(IOPORT(":DSW"))
956844
957845   /* video hardware */
958846   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8654Q, 0x200000, XTAL_53_693175MHz )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team