Previous 199869 Revisions Next

r22513 Wednesday 24th April, 2013 at 03:25:52 UTC by Carl
(mess) getid and readtoc generate 2 interrupts (nw)
--
Fixes booting of later bioses which are more strict about that
[src/mess/machine]psxcd.c psxcd.h

trunk/src/mess/machine/psxcd.c
r22512r22513
125125
126126void psxcd_device::device_reset()
127127{
128   next_read_event = -1;
128129   stop_read();
129130
130131   for (int i = 0; i < MAX_PSXCD_TIMERS; i++)
r22512r22513
149150   m_regs.imr = 0x1f;
150151   sechead = 0;
151152   sectail = 0;
152   next_read_event = -1;
153153   m_mute = false;
154154   m_dmaload = false;
155155   curpos.w = 0;
r22512r22513
470470      start_read();
471471   } else
472472   {
473      send_result(intr_diskerror);
473      send_result(intr_diskerror, NULL, 0, 0x80);
474474   }
475475}
476476
r22512r22513
609609      decimal_to_bcd(loc.b[F])  // aframe
610610   };
611611
612      verboselog(machine(), 1, "psxcd: getlocp [%02x %02x %02x %02x %02x %02x %02x %02x]\n",
613                     data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
612   verboselog(machine(), 1, "psxcd: getlocp [%02x %02x %02x %02x %02x %02x %02x %02x]\n",
613                  data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
614614
615615   send_result(intr_complete,data,8);
616616}
r22512r22513
624624   {
625625      unsigned char data[3]=
626626      {
627            status,
628            decimal_to_bcd(1),
629            decimal_to_bcd(cdrom_get_last_track(m_cdrom_handle))
627         status,
628         decimal_to_bcd(1),
629         decimal_to_bcd(cdrom_get_last_track(m_cdrom_handle))
630630      };
631631
632632      send_result(intr_complete,data,3);
633633   }
634634   else
635635   {
636      status |= status_error;
637      send_result(intr_diskerror);
636      send_result(intr_diskerror, NULL, 0, 0x80);
638637   }
639638}
640639
r22512r22513
663662   }
664663   else
665664   {
666      status |= status_error;
667      send_result(intr_diskerror);
665      send_result(intr_diskerror, NULL, 0, 0x80);
668666   }
669667}
670668
r22512r22513
688686
689687void psxcd_device::cdcmd_test()
690688{
691   verboselog(machine(), 1, "psxcd: test %08x\n",cmdbuf[0]);
689   verboselog(machine(), 1, "psxcd: test %02x\n", cmdbuf[0]);
692690
693   static unsigned char data[4]=
691   switch(cmdbuf[0])
694692   {
695      0x95,
696      0x07,
697      0x06,
698      0xff
699   };
693      case 0x20:
694         static unsigned char data[4]=
695         {
696            0x95,
697            0x07,
698            0x06,
699            0xff
700         };
700701
701   send_result(intr_complete,data,4);
702         send_result(intr_complete,data,4);
703         break;
704
705      default:
706         verboselog(machine(), 0, "psxcd: unimplemented test cmd %02x", cmdbuf[0]);
707         cmd_complete(prepare_result(intr_diskerror, NULL, 0, 0x10));
708         break;
709   }
702710}
703711
704712void psxcd_device::cdcmd_id()
r22512r22513
707715
708716   if (!open)
709717   {
710      static unsigned char gamedata[8] = { 0x00, 0x00, 0x00, 0x00, 'S', 'C', 'E', 'A' };
711      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.
718      UINT8 cdid[8];
719      int irq;
720      memset(cdid, '\0', 8);
712721
722      send_result(intr_complete);
713723      if(cdrom_get_track_type(m_cdrom_handle, 0) == CD_TRACK_AUDIO)
714724      {
715         audiodata[0] = status | status_invalid;
716         send_result(intr_acknowledge,audiodata,8);
725         irq = intr_diskerror;
726         cdid[0] = status | status_invalid;
727         cdid[1] = 0x90;
717728      }
718729      else
719730      {
720         gamedata[0] = status;
721         send_result(intr_acknowledge,gamedata,8);
731         irq = intr_acknowledge;
732         cdid[0] = status;
733         cdid[4] = 'S';
734         cdid[5] = 'C';
735         cdid[6] = 'E';
736         cdid[7] = 'A';
722737      }
723   } else
738      send_result(irq,cdid,8,default_irq_delay*3);
739   }
740   else
724741   {
725      status |= status_error;
726      send_result(intr_diskerror);
742      send_result(intr_diskerror, NULL, 0, 0x80);
727743   }
728744}
729745
r22512r22513
739755      start_read();
740756   } else
741757   {
742      send_result(intr_diskerror);
758      send_result(intr_diskerror, NULL, 0, 0x80);
743759   }
744760}
745761
r22512r22513
753769   verboselog(machine(), 1, "psxcd: readtoc\n");
754770
755771   send_result(intr_complete);
772   send_result(intr_acknowledge, NULL, 0, default_irq_delay*3); // ?
756773}
757774
758775void psxcd_device::cdcmd_unknown12()
r22512r22513
762779   if(cmdbuf[0] == 1)
763780      send_result(intr_complete);
764781   else
765   {
766      status |= status_error;
767      send_result(intr_diskerror);
768   }
782      send_result(intr_diskerror, NULL, 0, 0x40);
769783}
770784
771785void psxcd_device::cdcmd_illegal17()
r22512r22513
786800void psxcd_device::illegalcmd(UINT8 cmd)
787801{
788802   verboselog(machine(), 0, "psxcd: unimplemented cd command %02x\n", cmd);
789   command_result *res=global_alloc(command_result);
790   res->res=intr_diskerror;
791   res->data[0]=status | status_error;
792   res->data[1]=0x40; //invalid command
793   res->sz=2;
794   cmd_complete(res);
803
804   send_result(intr_diskerror, NULL, 0, 0x40);
795805}
796806
797807void psxcd_device::cmd_complete(command_result *res)
r22512r22513
808818   else
809819   {
810820      res_queue = res;
811      m_regs.ir = res_queue->res & m_regs.imr; // or should it not trigger a masked irq?
812      if(m_regs.ir)
821      m_regs.ir = res_queue->res;
822      if(m_regs.ir & m_regs.imr)
813823         m_irq_handler(1);
814824      m_regs.sr |= 0x20;
815825   }
816826   res->next = NULL;
817827}
818828
819void psxcd_device::send_result(UINT8 res, UINT8 *data, int sz, int delay)
829psxcd_device::command_result *psxcd_device::prepare_result(UINT8 res, UINT8 *data, int sz, UINT8 errcode)
820830{
821831   command_result *cr=global_alloc(command_result);
822832
r22512r22513
828838      cr->sz=sz;
829839   } else
830840   {
831      cr->data[0]=status;
832      cr->sz=1;
841      if((res == intr_diskerror) && errcode)
842      {
843         cr->data[0] = status | status_error;
844         cr->data[1] = errcode;
845         cr->sz = 2;
846      }
847      else
848      {
849         cr->data[0]=status;
850         cr->sz=1;
851      }
833852   }
834853   status &= ~status_error;
835854
855   return cr;
856}
857
858void psxcd_device::send_result(UINT8 res, UINT8 *data, int sz, int delay, UINT8 errcode)
859{
836860   // Avoid returning results after sector read results -
837861   // delay the sector read slightly if necessary
838862
r22512r22513
843867      m_timers[next_read_event]->adjust(attotime::from_hz(hz), 0, attotime::never);
844868   }
845869
846   add_system_event(event_cmd_complete, delay, (void *)cr);
870   add_system_event(event_cmd_complete, delay, prepare_result(res, data, sz, errcode));
847871}
848872
849873void psxcd_device::start_dma(UINT8 *mainram, UINT32 size)
r22512r22513
895919         }
896920         else
897921         {
898            command_result *res=global_alloc(command_result);
899            res->res=intr_dataready;
900            res->data[0]=status;
901            res->sz=1;
902            cmd_complete(res);
922            cmd_complete(prepare_result(intr_dataready));
903923            sectail++;
904924            sectail %= sector_buffer_size;
905925
r22512r22513
936956      {
937957         verboselog(machine(), 1, "psxcd: autopause xa\n");
938958
939         command_result *res=global_alloc(command_result);
940         res->res=intr_dataend;
941         res->data[0]=status;
942         res->sz=1;
943         cmd_complete(res);
959         cmd_complete(prepare_result(intr_dataend));
944960         stop_read();
945961      }
946962   }
r22512r22513
964980         if(!cdrom_read_data(m_cdrom_handle, sector, secbuf[sectail], CD_TRACK_RAW_DONTCARE))
965981         {
966982            stop_read(); // assume we've reached the end
967            command_result *res=global_alloc(command_result);
968            res->res=intr_dataend;
969            res->data[0]=status;
970            res->sz=1;
971            cmd_complete(res);
983            cmd_complete(prepare_result(intr_dataend));
972984            return;
973985         }
974986      }
r22512r22513
9971009            verboselog(machine(), 1, "psxcd: autopause cdda\n");
9981010
9991011            stop_read();
1000            command_result *res=global_alloc(command_result);
1001            res->res=intr_dataend;
1002            res->data[0]=status;
1003            res->sz=1;
1004            cmd_complete(res);
1012            cmd_complete(prepare_result(intr_dataend));
10051013            return;
10061014         }
10071015      }
r22512r22513
10531061   if(!(mode & mode_cdda) && (cdrom_get_track_type(m_cdrom_handle, cdrom_get_track(m_cdrom_handle, sector + 150)) == CD_TRACK_AUDIO))
10541062   {
10551063      stop_read();
1056      command_result *res=global_alloc(command_result);
1057      res->res=intr_diskerror;
1058      res->data[0]=status | status_error;
1059      res->data[1]=0x40;
1060      res->sz=2;
1061      cmd_complete(res);
1064      cmd_complete(prepare_result(intr_diskerror, NULL, 0, 0x40));
10621065      return;
10631066   }
10641067   send_result(intr_complete);
trunk/src/mess/machine/psxcd.h
r22512r22513
8686   void illegalcmd(UINT8 cmd);
8787
8888   void cmd_complete(command_result *res);
89   void send_result(UINT8 res, UINT8 *data=NULL, int sz=0, int delay=default_irq_delay);
89   void send_result(UINT8 res, UINT8 *data=NULL, int sz=0, int delay=default_irq_delay, UINT8 errcode = 0);
90   command_result *prepare_result(UINT8 res, UINT8 *data=NULL, int sz=0, UINT8 errcode = 0);
9091
9192   void start_read();
9293   void start_play();

Previous 199869 Revisions Next


© 1997-2024 The MAME Team