Пример #1
0
	void CommandQueue::Update(float ms)
	{
		if(_currentCommand != 0)
		{
			_currentCommand->Update(ms);

			if( _currentCommand->IsFinished() ||
				_currentCommand->IsSuspended() )
			{
				ExecuteNext();
			}
		}
		else
			ExecuteNext();
	}
// =======================================================================
// Abstract Logging Thread
// =======================================================================
void AbstractLoggingThread::MainLoop() {
  while (true) {
    while (!go) {
      std::chrono::milliseconds sleep_time(1);
      std::this_thread::sleep_for(sleep_time);
    };
    ExecuteNext();
    if (cur_seq == (int)schedule->operations.size()) {
      go = false;
      return;
    }
    go = false;
  }
}
Пример #3
0
BYTE CDrive::In (WORD wPort_)
{
    BYTE bRet = 0x00;

    // Continue command execution if we're busy but not transferring data
    if ((m_sRegs.bStatus & (BUSY|DRQ)) == BUSY)
        ExecuteNext();

    // Register to read from is the bottom 3 bits of the port
    switch (wPort_ & 0x03)
    {
        case regStatus:
        {
            // Return value is the status byte
            bRet = m_sRegs.bStatus;

            // Type 1 command mode uses more status bits
            if ((m_sRegs.bCommand & FDC_COMMAND_MASK) <= STEP_OUT_UPD)
            {
                // Set the track 0 bit state
                if (!m_bHeadCyl)
                {
                    bRet |= TRACK00;
                    m_sRegs.bTrack = 0;         // this is updated even in non-update mode!
                }

                // The following only apply if there's a disk in the drive
                if (m_pDisk)
                {
                    // Set the write protect bit if the disk is read-only
                    if (m_pDisk->IsReadOnly())
                        bRet |= WRITE_PROTECT;

                    // If spin-up wasn't disabled, flag it complete
                    if (!(m_sRegs.bCommand & CMD_FLAG_SPINUP))
                        bRet |= SPIN_UP;

                    // Toggle the index pulse status bit periodically to show the disk is spinning
                    static int n = 0;
                    if (IsMotorOn() && !(++n % 1024))   // FIXME: use an event for the correct index timing
                        bRet |= INDEX_PULSE;
                }
            }

            // SAM DICE relies on a strange error condition, which requires special handling
            else if ((m_sRegs.bCommand & FDC_COMMAND_MASK) == READ_ADDRESS)
            {
                static int nBusyTimeout = 0;

                // Clear busy after 16 polls of the status port
                if (!(bRet & BUSY))
                    nBusyTimeout = 0;
                else if (!(++nBusyTimeout & 0x0f))
                {
                    ModifyStatus(0, BUSY);
                    m_bSectorIndex = 0;
                }
            }

            break;
        }

        case regTrack:
            // Return the current track register value (may not match the current physical head position)
            bRet = m_sRegs.bTrack;
            TRACE("Disk track: returning %#02x\n", bRet);
            break;

        case regSector:
            // Return the current sector register value
            bRet = m_sRegs.bSector;
//          TRACE("Disk sector: returning %#02x\n", byte);
            break;

        case regData:
        {
            // Data available?
            if (m_uBuffer)
            {
                // Read the next byte into the data register
                m_sRegs.bData = *m_pbBuffer++;
                m_uBuffer--;

                // Has all the data been read?
                if (!m_uBuffer)
                {
                    // Reset BUSY and DRQ to show we're done
                    ModifyStatus(0, BUSY|DRQ);

                    // Some commands require additional handling
                    switch (m_sRegs.bCommand & FDC_COMMAND_MASK)
                    {
                        case READ_ADDRESS:
                            break;

                        case READ_TRACK:
                            // No more data available
                            ModifyStatus(RECORD_NOT_FOUND, 0);
                            break;

                        case READ_1SECTOR:
                            // Set the data read status to include data CRC errors
                            ModifyStatus(m_bDataStatus, 0);
                            break;

                        case READ_MSECTOR:
                            // Set the data read status to include data CRC errors, and only continue if ok
                            ModifyStatus(m_bDataStatus, 0);
                            if (!m_bDataStatus)
                            {
                                IDFIELD id;

                                // Advance the sector number
                                m_sRegs.bSector++;

                                // Are there any more sectors to return?
                                if (FindSector(&id))
                                {
                                    TRACE("FDC: Multiple-sector read moving to sector %d\n", id.bSector);

                                    // Read the data, reporting anything but CRC errors now
                                    m_bDataStatus = ReadSector(m_pbBuffer = m_abBuffer, &m_uBuffer);
                                    ModifyReadStatus();
                                }
                            }
                            break;

                        default:
                            TRACE("Data requested for unknown command (%d)!\n", m_sRegs.bCommand);
                    }
                }
            }

            // Return the data register value
            bRet = m_sRegs.bData;
        }
    }

    return bRet;
}