Previous 199869 Revisions Next

r20376 Sunday 20th January, 2013 at 19:40:52 UTC by smf
uses a devcb2 for cpu to cd controller communication, the address decoding is internal to the cpu & the cd controller is on it's own 8 bit bus. [smf]
[src/emu/cpu/psx]psx.c psx.h
[src/mess/drivers]psx.c
[src/mess/machine]psxcd.c psxcd.h

trunk/src/emu/cpu/psx/psx.c
r20375r20376
15351535   AM_RANGE(0x1f801070, 0x1f801077) AM_DEVREADWRITE( "irq", psxirq_device, read, write )
15361536   AM_RANGE(0x1f801080, 0x1f8010ff) AM_DEVREADWRITE( "dma", psxdma_device, read, write )
15371537   AM_RANGE(0x1f801100, 0x1f80112f) AM_DEVREADWRITE( "rcnt", psxrcnt_device, read, write )
1538   /* 1f801800-1f801803 cd */
1538   AM_RANGE(0x1f801800, 0x1f801803) AM_READWRITE8( cd_r, cd_w, 0xffffffff )
15391539   AM_RANGE(0x1f801810, 0x1f801817) AM_READWRITE( gpu_r, gpu_w )
15401540   AM_RANGE(0x1f801820, 0x1f801827) AM_DEVREADWRITE( "mdec", psxmdec_device, read, write )
15411541   AM_RANGE(0x1f801c00, 0x1f801dff) AM_READWRITE16_LEGACY( spu_r, spu_w, 0xffffffff )
r20375r20376
15631563   AM_RANGE(0x1f801070, 0x1f801077) AM_DEVREADWRITE( "irq", psxirq_device, read, write )
15641564   AM_RANGE(0x1f801080, 0x1f8010ff) AM_DEVREADWRITE( "dma", psxdma_device, read, write )
15651565   AM_RANGE(0x1f801100, 0x1f80112f) AM_DEVREADWRITE( "rcnt", psxrcnt_device, read, write )
1566   AM_RANGE(0x1f801800, 0x1f801803) AM_READWRITE8( cd_r, cd_w, 0xffffffff )
15661567   AM_RANGE(0x1f801810, 0x1f801817) AM_READWRITE( gpu_r, gpu_w )
15671568   AM_RANGE(0x1f801820, 0x1f801827) AM_DEVREADWRITE( "mdec", psxmdec_device, read, write )
15681569   AM_RANGE(0x1f801c00, 0x1f801dff) AM_READWRITE16_LEGACY( spu_r, spu_w, 0xffffffff )
r20375r20376
15881589   cpu_device(mconfig, type, name, tag, owner, clock),
15891590   m_program_config("program", ENDIANNESS_LITTLE, 32, 32, 0, internal_map),
15901591   m_gpu_read_handler(*this),
1591   m_gpu_write_handler(*this)
1592   m_gpu_write_handler(*this),
1593   m_cd_read_handler(*this),
1594   m_cd_write_handler(*this)
15921595{
15931596}
15941597
r20375r20376
17751778
17761779   m_gpu_read_handler.resolve_safe(0);
17771780   m_gpu_write_handler.resolve_safe();
1781   m_cd_read_handler.resolve_safe(0);
1782   m_cd_write_handler.resolve_safe();
17781783}
17791784
17801785
r20375r20376
31733178   m_gpu_write_handler( space, offset, data, mem_mask );
31743179}
31753180
3181READ8_HANDLER( psxcpu_device::cd_r )
3182{
3183   return m_cd_read_handler( space, offset, mem_mask );
3184}
3185
3186WRITE8_HANDLER( psxcpu_device::cd_w )
3187{
3188   m_cd_write_handler( space, offset, data, mem_mask );
3189}
3190
31763191WRITE32_HANDLER( psxcpu_device::com_delay_w )
31773192{
31783193   COMBINE_DATA( &m_com_delay );
trunk/src/emu/cpu/psx/psx.h
r20375r20376
115115#define MCFG_PSX_GPU_WRITE_HANDLER(_devcb) \
116116   devcb = &psxcpu_device::set_gpu_write_handler(*device, DEVCB2_##_devcb);
117117
118#define MCFG_PSX_CD_READ_HANDLER(_devcb) \
119   devcb = &psxcpu_device::set_cd_read_handler(*device, DEVCB2_##_devcb);
120#define MCFG_PSX_CD_WRITE_HANDLER(_devcb) \
121   devcb = &psxcpu_device::set_cd_write_handler(*device, DEVCB2_##_devcb);
122
118123//**************************************************************************
119124//  TYPE DEFINITIONS
120125//**************************************************************************
r20375r20376
130135   // static configuration helpers
131136   template<class _Object> static devcb2_base &set_gpu_read_handler(device_t &device, _Object object) { return downcast<psxcpu_device &>(device).m_gpu_read_handler.set_callback(object); }
132137   template<class _Object> static devcb2_base &set_gpu_write_handler(device_t &device, _Object object) { return downcast<psxcpu_device &>(device).m_gpu_write_handler.set_callback(object); }
138   template<class _Object> static devcb2_base &set_cd_read_handler(device_t &device, _Object object) { return downcast<psxcpu_device &>(device).m_cd_read_handler.set_callback(object); }
139   template<class _Object> static devcb2_base &set_cd_write_handler(device_t &device, _Object object) { return downcast<psxcpu_device &>(device).m_cd_write_handler.set_callback(object); }
133140
134141   // public interfaces
135142   DECLARE_WRITE32_MEMBER( biu_w );
r20375r20376
140147   DECLARE_WRITE32_MEMBER( gpu_w );
141148   DECLARE_READ32_MEMBER( gpu_r );
142149
150   DECLARE_WRITE8_MEMBER( cd_w );
151   DECLARE_READ8_MEMBER( cd_r );
152
143153   DECLARE_WRITE32_MEMBER( com_delay_w );
144154   DECLARE_READ32_MEMBER( com_delay_r );
145155
r20375r20376
281291
282292   devcb2_read32 m_gpu_read_handler;
283293   devcb2_write32 m_gpu_write_handler;
294   devcb2_read8 m_cd_read_handler;
295   devcb2_write8 m_cd_write_handler;
284296};
285297
286298class cxd8530aq_device : public psxcpu_device
trunk/src/mess/drivers/psx.c
r20375r20376
3737   UINT8 m_cd_io_status;
3838   UINT8 m_cd_param[8];
3939   UINT8 m_cd_result[8];
40   DECLARE_READ8_MEMBER(psx_cd_r);
41   DECLARE_WRITE8_MEMBER(psx_cd_w);
4240   DECLARE_DIRECT_UPDATE_MEMBER(psx_default);
4341   DECLARE_DIRECT_UPDATE_MEMBER(psx_setopbase);
4442   DECLARE_DRIVER_INIT(psx);
r20375r20376
477475   printf("cd_dma_write?!: addr %x, size %x\n", n_address, n_size);
478476}
479477
480READ8_MEMBER(psx1_state::psx_cd_r)
481{
482   psxcd_device *psxcd = machine().device<psxcd_device>(PSXCD_TAG);
483
484   return psxcd->read_byte(offset);
485}
486
487WRITE8_MEMBER(psx1_state::psx_cd_w)
488{
489   psxcd_device *psxcd = machine().device<psxcd_device>(PSXCD_TAG);
490
491   psxcd->write_byte(offset, data);
492}
493
494478static ADDRESS_MAP_START( psx_map, AS_PROGRAM, 32, psx1_state )
495479   AM_RANGE(0x00000000, 0x001fffff) AM_RAM AM_MIRROR(0x00600000) AM_SHARE("share1") /* ram */
496   AM_RANGE(0x1f801800, 0x1f801803) AM_READWRITE8(psx_cd_r, psx_cd_w, 0xffffffff)
497480   AM_RANGE(0x1fc00000, 0x1fc7ffff) AM_ROM AM_SHARE("share2") AM_REGION("user1", 0) /* bios */
498481   AM_RANGE(0x80000000, 0x801fffff) AM_RAM AM_MIRROR(0x00600000) AM_SHARE("share1") /* ram mirror */
499482   AM_RANGE(0x9fc00000, 0x9fc7ffff) AM_ROM AM_SHARE("share2") /* bios mirror */
r20375r20376
535518   MCFG_CDROM_ADD("cdrom",psx_cdrom)
536519   MCFG_SOFTWARE_LIST_ADD("cd_list","psx")
537520
521   MCFG_DEVICE_MODIFY( "maincpu" )
522   MCFG_PSX_CD_READ_HANDLER( DEVREAD8( PSXCD_TAG, psxcd_device, read ) )
523   MCFG_PSX_CD_WRITE_HANDLER( DEVWRITE8( PSXCD_TAG, psxcd_device, write ) )
524
538525   MCFG_PSXCD_ADD("cdrom")
539526   MCFG_PSXCD_IRQ_HANDLER(DEVWRITELINE("maincpu:irq", psxirq_device, intin2))
540527   MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 3, psx_dma_read_delegate( FUNC( cd_dma_read ), (psxcd_device *) device ) )
r20375r20376
566553   MCFG_CDROM_ADD("cdrom",psx_cdrom)
567554   MCFG_SOFTWARE_LIST_ADD("cd_list","psx")
568555
556   MCFG_DEVICE_MODIFY( "maincpu" )
557   MCFG_PSX_CD_READ_HANDLER( DEVREAD8( PSXCD_TAG, psxcd_device, read ) )
558   MCFG_PSX_CD_WRITE_HANDLER( DEVWRITE8( PSXCD_TAG, psxcd_device, write ) )
559
569560   MCFG_PSXCD_ADD("cdrom")
570561   MCFG_PSXCD_IRQ_HANDLER(DEVWRITELINE("maincpu:irq", psxirq_device, intin2))
571562   MCFG_PSX_DMA_CHANNEL_READ( "maincpu", 3, psx_dma_read_delegate( FUNC( cd_dma_read ), (psxcd_device *) device ) )
trunk/src/mess/machine/psxcd.c
r20375r20376
194194//
195195//
196196
197unsigned char psxcd_device::read_byte(const unsigned int addr)
197READ8_MEMBER( psxcd_device::read )
198198{
199199   unsigned char ret = 0;
200200
201   switch (addr&3)
201   switch (offset&3)
202202   {
203203      case 0: ret=sr; break;
204204      case 1:
r20375r20376
233233//
234234//
235235
236void psxcd_device::write_byte(const unsigned int addr, const unsigned char byte)
236WRITE8_MEMBER( psxcd_device::write )
237237{
238238   #ifdef debug_cdrom_registers
239239      printf("cdrom: write byte %08x = %02x (PC=%x)\n",addr,byte,machine().device("maincpu")->safe_pc());
240240   #endif
241241
242   switch (addr&3)
242   switch (offset&3)
243243   {
244244      case 0:
245         cmdmode=byte&1;
245         cmdmode=data&1;
246246         if (cmdmode==0)
247247         {
248248            cbp=cmdbuf;
r20375r20376
295295      case 1:
296296         if (cmdmode==0)
297297         {
298            write_command(byte);
298            write_command(data);
299299         }
300300         break;
301301
302302      case 2:
303303         if (cmdmode==0)
304304         {
305            *cbp++=byte;
305            *cbp++=data;
306306         } else
307307         {
308308            // ?flush buffer?
r20375r20376
310310         break;
311311
312312      case 3:
313         if (byte==0x07)
313         if (data==0x07)
314314         {
315315            if (cur_res)
316316            {
trunk/src/mess/machine/psxcd.h
r20375r20376
3333
3434#define MCFG_PSXCD_DEVNAME(_name) \
3535   psxcd_device::static_set_devname(*device, _name);
36
3637struct psxcd_interface
3738{
3839};
r20375r20376
154155
155156   void start_dma(UINT8 *mainram, UINT32 size);
156157
157   unsigned char read_byte(const unsigned int addr);
158   void write_byte(const unsigned int addr, const unsigned char byte);
158   DECLARE_WRITE8_MEMBER( write );
159   DECLARE_READ8_MEMBER( read );
159160
160161private:
161162   emu_timer *m_timer;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team