Ejemplo n.º 1
0
 private void CDRead(int lba, IntPtr dest, bool audio)
 {
     if (audio)
     {
         byte[] data = new byte[2352];
         if (lba < _cd.Session1.LeadoutLBA && lba >= _cd.Session1.Tracks[2].LBA)
         {
             _cdReader.ReadLBA_2352(lba, data, 0);
         }
         Marshal.Copy(data, 0, dest, 2352);
     }
     else
     {
         byte[] data = new byte[2048];
         _cdReader.ReadLBA_2048(lba, data, 0);
         Marshal.Copy(data, 0, dest, 2048);
         DriveLightOn = true;
     }
 }
Ejemplo n.º 2
0
        public void Think()
        {
            if (RST)
            {
                ResetDevice();
                return;
            }

            if (DataReadInProgress && pce.Cpu.TotalExecutedCycles > DataReadWaitTimer)
            {
                if (SectorsLeftToRead > 0)
                {
                    pce.DriveLightOn = true;
                }

                if (DataIn.Count == 0)
                {
                    // read in a sector and shove it in the queue
                    DiscSystem.DiscSectorReader dsr = new DiscSectorReader(disc);                     //TODO - cache reader
                    dsr.ReadLBA_2048(CurrentReadingSector, DataIn.GetBuffer(), 0);
                    DataIn.SignalBufferFilled(2048);
                    CurrentReadingSector++;
                    SectorsLeftToRead--;

                    pce.IntDataTransferReady = true;

                    // If more sectors, should set the next think-clock to however long it takes to read 1 sector
                    // but I dont. I dont think transfers actually happen sector by sector
                    // like this, they probably become available as the bits come off the disc.
                    // but lets get some basic functionality before we go crazy.
                    //  Idunno, maybe they do come in a sector at a time.

                    //note to vecna: maybe not at the sector level, but at a level > 1 sample and <= 1 sector, samples come out in blocks
                    //due to the way they are jumbled up (seriously, like put into a blender) for error correction purposes.
                    //we may as well assume that the cd audio decoding magic works at the level of one sector, but it isnt one sample.

                    if (SectorsLeftToRead == 0)
                    {
                        DataReadInProgress  = false;
                        DataTransferWasDone = true;
                    }
                    SetPhase(BusPhase_DataIn);
                }
            }

            do
            {
                signalsChanged  = false;
                busPhaseChanged = false;

                if (SEL && !BSY)
                {
                    SetPhase(BusPhase_Command);
                }
                else if (ATN && !REQ && !ACK)
                {
                    SetPhase(BusPhase_MessageOut);
                }
                else
                {
                    switch (Phase)
                    {
                    case BusPhase_Command: ThinkCommandPhase(); break;

                    case BusPhase_DataIn: ThinkDataInPhase(); break;

                    case BusPhase_DataOut: ThinkDataOutPhase(); break;

                    case BusPhase_MessageIn: ThinkMessageInPhase(); break;

                    case BusPhase_MessageOut: ThinkMessageOutPhase(); break;

                    case BusPhase_Status: ThinkStatusPhase(); break;

                    default: break;
                    }
                }
            } while (signalsChanged || busPhaseChanged);
        }