Previous 199869 Revisions Next

r22085 Monday 25th March, 2013 at 16:40:26 UTC by Carl
(mess) psxcd: small cleanups (nw)
[src/mess/machine]psxcd.c psxcd.h

trunk/src/mess/machine/psxcd.c
r22084r22085
5858   status_seeking=0x40,
5959   status_reading=0x20,
6060   status_shellopen=0x10,
61   status_invalid=0x08,
6162   status_seekerror=0x04,
6263   status_standby=0x02,
6364   status_error=0x01
r22084r22085
130131   streaming = false;
131132   sechead = 0;
132133   sectail = 0;
133   secin = 0;
134134   secskip = 0;
135135   next_read_event = -1;
136136   cbp = cmdbuf;
137   first_open = true;
138137
139   status=status_standby;
138   status=status_shellopen;
140139   sr=8|1;
141140   res=0;
142141   ir=0;
r22084r22085
200199   stop_read();
201200   cdrom_image_device::call_unload();
202201   open = true;
202   status = status_shellopen;
203203   send_result(intr_diskerror);
204204}
205205
r22084r22085
416416   send_result(intr_acknowledge);
417417}
418418
419static int open_nops=10;
420
421419void psxcd_device::cdcmd_nop()
422420{
423421   #ifdef debug_cdrom
r22084r22085
427425   //stop_read();
428426
429427   if (!open)
430   {
431      if (open_nops!=0)
432         open_nops--;
433   }
428      status &= ~status_shellopen;
434429
435430   send_result(intr_complete);
436431}
r22084r22085
740735      send_result(intr_complete,data,3);
741736   }
742737   else
738   {
739      status |= status_error;
743740      send_result(intr_diskerror);
741   }
744742}
745743
746744void psxcd_device::cdcmd_gettd()
r22084r22085
830828      static unsigned char gamedata[8] = { 0x00, 0x00, 0x00, 0x00, 'S', 'C', 'E', 'A' };
831829      static unsigned char audiodata[8] = { 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // drops into the audio CD player.  08 80 goes to the menu.
832830
833      if (cdrom_get_track_type(m_cdrom_handle, 0) == CD_TRACK_AUDIO)
831      if(status & status_invalid)
834832      {
835         audiodata[0] = status | 8;
833         audiodata[0] = status;
836834         send_result(intr_acknowledge,audiodata,8);
837835      }
838836      else
r22084r22085
842840      }
843841   } else
844842   {
845      status=status_error|status_shellopen;
843      status |= status_error;
846844      send_result(intr_diskerror);
847845   }
848846}
r22084r22085
949947                                          const unsigned int sz,
950948                                             const unsigned int delay)
951949{
952   // Update shell open status
953
954   if (open)
955   {
956      status=status_error|status_shellopen;
957   }
958   else
959   {
960      if (status&status_shellopen)
961         status=status_standby;
962   }
963
964
965950   command_result *cr=global_alloc(command_result);
966951
967952   cr->res=res;
r22084r22085
10281013bool psxcd_device::read_next_sector()
10291014{
10301015   UINT32 pos=msf_to_lba_ps(curpos.w);
1031   unsigned char *buf=&secbuf[sechead*raw_sector_size];
1032   assert(secin<sector_buffer_size);
1016   unsigned char *buf=secbuf[sechead];
10331017
10341018//  printf("read_next_sector: sec %d, sechead %d, raw_sector_size %d\n", pos, sechead, raw_sector_size);
10351019   if (cdrom_read_data(m_cdrom_handle, pos, buf, CD_TRACK_RAW_DONTCARE))
r22084r22085
10371021//      printf("buf contents = %02x %02x | %02x %02x\n", buf[0], buf[1], buf[0x20], buf[0x21]);
10381022
10391023      sechead=(sechead+1)&(sector_buffer_size-1);
1040      secin++;
10411024
1042      memcpy(lastsechdr,&secbuf[raw_sector_size*sectail]+12,8);
1025      memcpy(lastsechdr,&secbuf[sectail][12],8);
10431026
10441027      return true;
10451028   } else
r22084r22085
10661049
10671050         if ((mode&mode_adpcm) && (streaming))
10681051         {
1069            rawsec=&secbuf[raw_sector_size*sectail];
1052            rawsec=secbuf[sectail];
10701053            secptr=rawsec+24;
10711054            secleft=2048;
10721055         }
10731056         else
10741057         {
1075            rawsec=&secbuf[raw_sector_size*sectail];
1058            rawsec=secbuf[sectail];
10761059            secptr=rawsec+secskip;
10771060            secleft=secsize;
10781061         }
10791062
1080         bool isxa=false;
1081
1082         secin--;
10831063         sectail=(sectail+1)&(sector_buffer_size-1);
10841064
10851065         subheader *sub=(subheader *)(rawsec+16);
r22084r22085
10971077         #endif
10981078
10991079         status&=~status_playing;
1100         isxa=((mode&mode_adpcm) && (sub->submode&submode_audio));
1080         bool isxa=((mode&mode_adpcm) && (sub->submode&submode_audio));
11011081
11021082         if (((mode&mode_channel)==0) ||
11031083               ((sub->file==filter_file) && (sub->channel==filter_channel)))
r22084r22085
11681148//
11691149//
11701150
1171bool psxcd_device::play_cdda_sector(const unsigned int sector, unsigned char *rawsec)
1172{
1173   return m_spu->play_cdda(sector,rawsec);
1174}
1175
1176//
1177//
1178//
1179
11801151void psxcd_device::play_sector()
11811152{
11821153   next_read_event=-1;
11831154
11841155   if (status&status_playing)
11851156   {
1186      unsigned char *rawsec=&secbuf[raw_sector_size*sectail];
1187      secin--;
11881157      sectail=(sectail+1)&(sector_buffer_size-1);
1189      play_cdda_sector(0,rawsec);
1158      m_spu->play_cdda(0,secbuf[sectail]);
11901159
11911160      curpos.b[F]++;
11921161      if (curpos.b[F]==75)
r22084r22085
12841253   //
12851254
12861255   UINT32 pos=msf_to_lba_ps(curpos.w);
1287   unsigned char *buf=&secbuf[sechead*raw_sector_size];
1256   unsigned char *buf=secbuf[sechead];
12881257   if (! cdrom_read_data(m_cdrom_handle, pos, buf, CD_TRACK_RAW_DONTCARE))
12891258   {
12901259      next_clock=(m_sysclock/60);
r22084r22085
13351304
13361305   status|=status_reading;
13371306
1338   secin=sechead=sectail=0;
1307   sechead=sectail=0;
13391308
13401309   unsigned int cyc=read_sector_cycles;
13411310   if (mode&mode_double_speed) cyc>>=1;
r22084r22085
13721341
13731342   status|=status_playing;
13741343
1375   secin=sechead=sectail=0;
1344   sechead=sectail=0;
13761345
13771346   if (mode&mode_autopause)
13781347   {
r22084r22085
14491418
14501419      case event_change_disk:
14511420         open = false;
1421         status |= status_standby;
1422         if(cdrom_get_track_type(m_cdrom_handle, 0) == CD_TRACK_AUDIO)
1423            status |= status_invalid;
14521424         break;
14531425   }
14541426}
trunk/src/mess/machine/psxcd.h
r22084r22085
4343   unsigned char sr,res,ir,cmdmode,
4444                        cmdbuf[64],*cbp,
4545                        mode,
46                        secbuf[raw_sector_size*sector_buffer_size],
46                        secbuf[sector_buffer_size][raw_sector_size],
4747                        *secptr,
4848                        filter_file,
4949                        filter_channel,
5050                        lastsechdr[8],
5151                        status;
5252   int rdp,secsize,secleft,secskip,
53         sechead,sectail,
54         secin;
53         sechead,sectail;
5554   command_result *res_queue,
5655                           *cur_res;
5756
r22084r22085
7675#endif
7776
7877   bool open,
79            streaming,
80            first_open;
78            streaming;
8179   device_timer_id next_read_event;
8280   INT64 next_sector_t;
8381   unsigned int autopause_sector,
r22084r22085
140138   void stop_read();
141139   void read_sector();
142140   bool read_next_sector();
143   bool play_cdda_sector(const unsigned int sector, unsigned char *rawsec);
144141   void play_sector();
145142   void preread_sector();
146143   UINT32 sub_loc(CDPOS src1, CDPOS src2);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team