Previous 199869 Revisions Next

r20447 Thursday 24th January, 2013 at 19:18:01 UTC by smf
cache cpu & spu lookup. [smf]
[src/mess/machine]psxcd.c psxcd.h

trunk/src/mess/machine/psxcd.c
r20446r20447
1
12#include "emu.h"
23#include "psxcd.h"
3#include "sound/spu.h"
44#include "debugger.h"
55
66//
r20446r20447
114114{
115115   m_irq_handler.resolve_safe();
116116
117   unsigned int sysclk=machine().device<cpu_device>("maincpu")->clock()/2;
117   m_maincpu = machine().device<cpu_device>("maincpu");
118   m_spu = machine().device<spu_device>("spu");
119
120   unsigned int sysclk=m_maincpu->clock()/2;
118121   start_read_delay=(sysclk/60);
119122   read_sector_cycles=(sysclk/75);
120123   preread_delay=(read_sector_cycles>>2)-500;
r20446r20447
223226   }
224227
225228   #ifdef debug_cdrom_registers
226      printf("cdrom: read byte %08x = %02x (PC=%x)\n",offset,ret,machine().device("maincpu")->safe_pc());
229      printf("cdrom: read byte %08x = %02x (PC=%x)\n",offset,ret,m_maincpu->safe_pc());
227230   #endif
228231
229232   return ret;
r20446r20447
236239WRITE8_MEMBER( psxcd_device::write )
237240{
238241   #ifdef debug_cdrom_registers
239      printf("cdrom: write byte %08x = %02x (PC=%x)\n",offset,data,machine().device("maincpu")->safe_pc());
242      printf("cdrom: write byte %08x = %02x (PC=%x)\n",offset,data,m_maincpu->safe_pc());
240243   #endif
241244
242245   switch (offset&3)
r20446r20447
972975   // Avoid returning results after sector read results -
973976   // delay the sector read slightly if necessary
974977
975   UINT64 systime = machine().device<cpu_device>("maincpu")->total_cycles();
978   UINT64 systime = m_maincpu->total_cycles();
976979   if ((next_read_event) && ((systime+ev->t)>(next_sector_t)))
977980   {
978981      UINT32 hz = m_sysclock / (delay + 2000);
r20446r20447
11351138                  if (xa_prefetch_sector==-1)
11361139                  {
11371140                     xa_prefetch_sector=cursec;
1138                     machine().device<spu_device>("spu")->flush_xa();
1141                     m_spu->flush_xa();
11391142                  }
11401143
11411144                  unsigned char *xaptr;
r20446r20447
11661169                              ((xasub->file==sub->file) &&
11671170                              (xasub->channel==sub->channel))))
11681171                     {
1169                        if (! machine().device<spu_device>("spu")->play_xa(xa_prefetch_sector,xaptr))
1172                        if (! m_spu->play_xa(xa_prefetch_sector,xaptr))
11701173                           break;
11711174                     }
11721175                     xa_prefetch_sector++;
11731176                  }
11741177               #else
1175                  machine().device<spu_device>("spu")->play_xa(0,rawsec+16);
1178                  m_spu->play_xa(0,rawsec+16);
11761179               #endif
11771180
11781181               status|=status_playing;
r20446r20447
12531256
12541257bool psxcd_device::play_cdda_sector(const unsigned int sector, unsigned char *rawsec)
12551258{
1256   return machine().device<spu_device>("spu")->play_cdda(sector,rawsec);
1259   return m_spu->play_cdda(sector,rawsec);
12571260}
12581261
12591262//
r20446r20447
12801283         if (cdda_prefetch_sector==-1)
12811284         {
12821285            cdda_prefetch_sector=cursec;
1283            machine().device<spu_device>("spu")->flush_cdda();
1286            m_spu->flush_cdda();
12841287         }
12851288
12861289         unsigned char *cddaptr;
r20446r20447
13601363      unsigned int cyc=read_sector_cycles;
13611364
13621365      event *ev=new event;
1363      ev->t=next_sector_t - machine().device<cpu_device>("maincpu")->total_cycles();
1366      ev->t=next_sector_t - m_maincpu->total_cycles();
13641367      ev->type=event_play_sector;
13651368
13661369      next_sector_t+=cyc>>1;
r20446r20447
13941397
13951398      unsigned int cyc=read_sector_cycles;
13961399      if (mode&mode_double_speed) cyc>>=1;
1397      next_sector_t=ev->t+(cyc-preread_delay)+machine().device<cpu_device>("maincpu")->total_cycles();
1400      next_sector_t=ev->t+(cyc-preread_delay)+m_maincpu->total_cycles();
13981401   } else
13991402   {
14001403      memcpy(lastsechdr,buf+12,8);
r20446r20447
14141417
14151418      //
14161419
1417      ev->t=next_sector_t - machine().device<cpu_device>("maincpu")->total_cycles();
1420      ev->t=next_sector_t - m_maincpu->total_cycles();
14181421      ev->type=event_read_sector;
14191422
14201423      //read_next_sector();
r20446r20447
14441447   unsigned int cyc=read_sector_cycles;
14451448   if (mode&mode_double_speed) cyc>>=1;
14461449
1447   INT64 systime=machine().device<cpu_device>("maincpu")->total_cycles();
1450   INT64 systime=m_maincpu->total_cycles();
14481451
14491452   systime+=start_read_delay;
14501453
r20446r20447
14951498
14961499   unsigned int cyc=read_sector_cycles;
14971500
1498   next_sector_t=machine().device<cpu_device>("maincpu")->total_cycles()+cyc;
1501   next_sector_t=m_maincpu->total_cycles()+cyc;
14991502
15001503   event *ev=new event;
1501   ev->t=next_sector_t - machine().device<cpu_device>("maincpu")->total_cycles();
1504   ev->t=next_sector_t - m_maincpu->total_cycles();
15021505   ev->type=event_play_sector;
15031506
15041507   next_sector_t+=cyc>>1;
r20446r20447
15391542   }
15401543
15411544   unsigned int sector=msf_to_sector(curpos);
1542   machine().device<spu_device>("spu")->flush_xa(sector);
1543   machine().device<spu_device>("spu")->flush_cdda(sector);
1545   m_spu->flush_xa(sector);
1546   m_spu->flush_cdda(sector);
15441547}
15451548
15461549//
trunk/src/mess/machine/psxcd.h
r20446r20447
33
44#include "imagedev/chd_cd.h"
55#include "psxcddrv.h"
6#include "sound/spu.h"
67
78#define MAX_PSXCD_TIMERS    (4)
89
r20446r20447
171172   void add_system_event(event *ev);
172173
173174   devcb2_write_line m_irq_handler;
175   cpu_device *m_maincpu;
176   spu_device *m_spu;
174177};
175178
176179

Previous 199869 Revisions Next


© 1997-2024 The MAME Team