Exemple #1
0
// Set the status of a read operation before the data has been read by the CPU
inline void CDrive::ModifyReadStatus ()
{
    // Report errors (other than CRC errors) and busy status (from asynchronous operations)
    if (m_bDataStatus & ~CRC_ERROR)
        ModifyStatus(m_bDataStatus, BUSY);

    // Otherwise signal that data is available for reading
    else
        ModifyStatus(DRQ, 0);
}
Exemple #2
0
INT PageHeap_Execute()
{
    if (!Set && !Unset)
    {
        DisplayStatus();
    }
    else
    {
        ModifyStatus();
    }

    return 0;
}
Exemple #3
0
LRESULT CDUITreeNode::ProcessEvent(const DUIEvent& info, BOOL& bHandled)
{
	LRESULT lRet(S_OK);
	switch(info.dwEventType)
	{
	case DUI_EVENT_MOUSEENTER:
		ModifyStatus(0, CONTROL_STATUS_HOVER);
		if(m_pParentControl != NULL)
		{
			DUIEvent event = info;
			event.pSender = this;
			event.dwEventType = DUI_EVENT_ELE_ITEM_MOUSEENTER;
			m_pParentControl->OnDUIEvent(event, bHandled);
		}
		
		break;
		
	case DUI_EVENT_MOUSELEAVE:
		ModifyStatus(CONTROL_STATUS_HOVER, 0);
		if(m_pParentControl != NULL)
		{
			DUIEvent event = info;
			event.pSender = this;
			event.dwEventType = DUI_EVENT_ELE_ITEM_MOUSELEAVE;
			m_pParentControl->OnDUIEvent(event, bHandled);
		}
		break;
		
	case DUI_EVENT_LBUTTONDOWN:
		ModifyStatus(0, CONTROL_STATUS_PRESSED);
		if(m_pParentControl != NULL)
		{
			m_pParentControl->SetFocus(TRUE);
		}
		break;
		
	case DUI_EVENT_LBUTTONDBCLK:
		ModifyStatus(0, CONTROL_STATUS_PRESSED);
		if(m_pParentControl != NULL)
		{
			DUIEvent event = info;
			event.pSender = this;
			event.dwEventType = DUI_EVENT_ELE_ITEM_DBCLICK;
			m_pParentControl->OnDUIEvent(event, bHandled);
		}
		
		break;		
		
	case DUI_EVENT_LBUTTONUP:
		ModifyStatus(CONTROL_STATUS_PRESSED, 0);
		if(PtInRect(&m_rtControl, info.ptMouse))
		{
// 			if(m_pParentControl != NULL)
// 			{
 				DUIEvent event = info;
 				event.pSender = this;
 				event.dwEventType = DUI_EVENT_ELE_ITEM_CLICK;
// 				m_pParentControl->OnDUIEvent(event, bHandled);
// 			}
			FireNotifyToTreeView(event,bHandled);
		}
		break;
		
	default:
		break;
	}
	
	if(bHandled) return lRet; 
	
	return theBase::ProcessEvent(info, bHandled);
}
Exemple #4
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;
}
Exemple #5
0
void CDrive::ExecuteNext ()
{
    BYTE bStatus = m_sRegs.bStatus;

    // Nothing to do if there's no disk in the drive
    if (!m_pDisk)
        return;

    // Continue processing the background
    if (m_pDisk->IsBusy(&bStatus))
    {
        // Keep the drive motor on as we're busy
        ModifyStatus(MOTOR_ON, 0);
        return;
    }

    // Some commands require additional handling
    switch (m_sRegs.bCommand & FDC_COMMAND_MASK)
    {
        case READ_1SECTOR:
        case READ_MSECTOR:
        {
            IDFIELD id;

            if (!FindSector(&id))
                ModifyStatus(RECORD_NOT_FOUND, BUSY);
            else
            {
                // Read the data, reporting anything but CRC errors now, as we can't check the CRC until we reach it at the end of the data on the disk
                m_bDataStatus = ReadSector(m_pbBuffer = m_abBuffer, &m_uBuffer);
                ModifyReadStatus();

                // Just for fun ;-)
                if (m_sRegs.bTrack == 4 && m_sRegs.bSector == 1 && m_abBuffer[0x016] == 0xC3 && CrcBlock(m_abBuffer, m_uBuffer) == 0x6c54)
                    m_abBuffer[0x016] -= 0x37;
            }
            break;
        }

        case WRITE_1SECTOR:
        case WRITE_MSECTOR:
        {
            if (m_nState == 0)
            {
                IDFIELD id;

                // Locate the sector, reset busy and signal record not found if we couldn't find it
                if (!FindSector(&id))
                    ModifyStatus(RECORD_NOT_FOUND, BUSY);
                else if (m_pDisk->IsReadOnly())
                    ModifyStatus(WRITE_PROTECT, BUSY);
                else
                {
                    // Prepare data pointer to receive data, and the amount we're expecting
                    m_pbBuffer = m_abBuffer;
                    m_uBuffer = 128U << (id.bSize & 3);

                    // Signal that data is now requested for writing
                    ModifyStatus(DRQ, 0);
                    m_nState++;
                }
            }
            else
            {
                // Write complete, so set its status and clear busy
                ModifyStatus(bStatus, BUSY);
            }

            break;
        }

        case READ_ADDRESS:
        {
            // Read an ID field into our general buffer
            IDFIELD* pId = reinterpret_cast<IDFIELD*>(m_pbBuffer = m_abBuffer);
            BYTE bReadStatus = ReadAddress(pId);

            // If successful set up the number of bytes available to read
            if (!(bReadStatus & TYPE23_ERROR_MASK))
            {
                m_sRegs.bSector = pId->bTrack;

                m_uBuffer = sizeof(IDFIELD);
                ModifyStatus(bStatus|DRQ, 0);   // Don't clear BUSY yet!
            }

            // Set the error status, resetting BUSY so the client sees the error
            else
            {
                ModifyStatus(bStatus, BUSY);
                m_uBuffer = 0;
            }

            break;
        }

        case READ_TRACK:
        {
            // Prepare a semi-convincing raw track
            ReadTrack(m_pbBuffer = m_abBuffer, m_uBuffer = sizeof(m_abBuffer));
            ModifyStatus(DRQ, 0);
            break;
        }

        case WRITE_TRACK:
        {
            ModifyStatus(bStatus, BUSY);
            break;
        }
    }
}