Beispiel #1
0
void Disk2InterfaceCard::FlushCurrentTrack(const int drive)
{
	FloppyDisk* pFloppy = &m_floppyDrive[drive].m_disk;

	if (pFloppy->m_trackimage && pFloppy->m_trackimagedirty)
		WriteTrack(drive);
}
Beispiel #2
0
/*************
 * DESCRIPTION:   write brush to scene file
 * INPUT:         iff      iff handler
 * OUTPUT:        FALSE if failed else TRUE
 *************/
BOOL BRUSH_OBJECT::WriteObject(struct IFFHandle *iff)
{
	VECTOR v[3];

	if(PushChunk(iff, ID_BRSH, ID_FORM, IFFSIZE_UNKNOWN))
		return FALSE;

	if(!WriteLongChunk(iff, ID_POSI, &pos, 3))
		return FALSE;

	v[0] = orient_x;
	v[1] = orient_y;
	v[2] = orient_z;
	if(!WriteLongChunk(iff, ID_ALGN, v, 9))
		return FALSE;

	if(!WriteLongChunk(iff, ID_SIZE, &size, 3))
		return FALSE;

	if(!WriteTrack(iff))
		return FALSE;

	if(!WriteFlags(iff))
		return FALSE;

	if(PopChunk(iff))
		return FALSE;

	return TRUE;
}
void
MovieWriter::WriteOnStop()
{
    CAutoLock lock(&m_csWrite);
	ASSERT(m_bStopped);

	// loop writing as long as there are blocks queued at the pins
	for (;;)
	{
		LONGLONG tReady = 0;
		int idxReady = -1;
		// find the earliest
        for (UINT i = 0; i < m_Tracks.size(); i++)
        {
            LONGLONG tHead;
            if (m_Tracks[i]->GetHeadTime(&tHead))
            {
				if ((idxReady == -1) ||
					(tHead < tReady))
				{
					idxReady = i;
					tReady = tHead;
				}
			}
		}
	
		if (idxReady == -1)
		{
			// all done
			return;
		}

		WriteTrack(idxReady);
	}
}
Beispiel #4
0
void Context::InitSegment()
{
    m_segment_pos = m_file.GetPosition();

    m_file.WriteID4(0x18538067);  //Segment ID

#if 0
    m_file.Write8UInt(0);         //will need to be filled in later
#else
    m_file.Serialize8UInt(0x01FFFFFFFFFFFFFFLL);
#endif

    InitFirstSeekHead();  //Meta Seek
    InitInfo();      //Segment Info
    WriteTrack();
}
Beispiel #5
0
//===========================================================================
BYTE __stdcall DiskControlStepper (WORD, BYTE address, BYTE, BYTE, ULONG) {
  Disk_t * fptr = &g_aFloppyDisk[currdrive];
  if (address & 1) {
    int phase     = (address >> 1) & 3;
    int direction = 0;
    if (phase == ((fptr->phase+1) & 3))
      direction = 1;
    if (phase == ((fptr->phase+3) & 3))
      direction = -1;
    if (direction) {
      fptr->phase = MAX(0,MIN(79,fptr->phase+direction));
      if (!(fptr->phase & 1)) {
        int newtrack = MIN(TRACKS-1,fptr->phase >> 1);
        if (newtrack != fptr->track) {
          if (fptr->trackimage && fptr->trackimagedirty)
            WriteTrack(currdrive);
          fptr->track          = newtrack;
          fptr->trackimagedata = 0;
        }
      }
    }
Beispiel #6
0
//===========================================================================
static void RemoveDisk (int iDrive)
{
	Disk_t *pFloppy = &g_aFloppyDisk[iDrive];

	if (pFloppy->imagehandle)
	{
		if (pFloppy->trackimage && pFloppy->trackimagedirty)
			WriteTrack( iDrive);

		ImageClose(pFloppy->imagehandle);
		pFloppy->imagehandle = (HIMAGE)0;
	}

	if (pFloppy->trackimage)
	{
		VirtualFree(pFloppy->trackimage,0,MEM_RELEASE);
		pFloppy->trackimage     = NULL;
		pFloppy->trackimagedata = 0;
	}

	memset( pFloppy->imagename, 0, MAX_DISK_IMAGE_NAME+1 );
	memset( pFloppy->fullname , 0, MAX_DISK_FULL_NAME +1 );
}
Beispiel #7
0
static BYTE __stdcall DiskControlStepper(WORD, WORD address, BYTE, BYTE, ULONG)
{
	Disk_t * fptr = &g_aFloppyDisk[currdrive];
#if 1
	int phase     = (address >> 1) & 3;
	int phase_bit = (1 << phase);

	// update the magnet states
	if (address & 1)
	{
		// phase on
		phases |= phase_bit;
		LOG_DISK("track %02X phases %X phase %d on  address $C0E%X\r", fptr->phase, phases, phase, address & 0xF);
	}
	else
	{
		// phase off
		phases &= ~phase_bit;
		LOG_DISK("track %02X phases %X phase %d off address $C0E%X\r", fptr->phase, phases, phase, address & 0xF);
	}

	// check for any stepping effect from a magnet
	// - move only when the magnet opposite the cog is off
	// - move in the direction of an adjacent magnet if one is on
	// - do not move if both adjacent magnets are on
	// momentum and timing are not accounted for ... maybe one day!
	int direction = 0;
	if (phases & (1 << ((fptr->phase + 1) & 3)))
		direction += 1;
	if (phases & (1 << ((fptr->phase + 3) & 3)))
		direction -= 1;

	// apply magnet step, if any
	if (direction)
	{
		fptr->phase = MAX(0, MIN(79, fptr->phase + direction));
		const int nNumTracksInImage = ImageGetNumTracks(fptr->imagehandle);
		const int newtrack = (nNumTracksInImage == 0)	? 0
														: MIN(nNumTracksInImage-1, fptr->phase >> 1); // (round half tracks down)
		LOG_DISK("newtrack %2X%s\r", newtrack, (fptr->phase & 1) ? ".5" : "");
		if (newtrack != fptr->track)
		{
			if (fptr->trackimage && fptr->trackimagedirty)
			{
				WriteTrack(currdrive);
			}
			fptr->track          = newtrack;
			fptr->trackimagedata = 0;
		}

		// Feature Request #201 Show track status
		// https://github.com/AppleWin/AppleWin/issues/201
		FrameDrawDiskStatus( (HDC)0 );
	}
#else	// Old 1.13.1 code for Chessmaster 2000 to work! (see bug#18109)
	const int nNumTracksInImage = ImageGetNumTracks(fptr->imagehandle);
	if (address & 1) {
		int phase = (address >> 1) & 3;
		int direction = 0;
		if (phase == ((fptr->phase+1) & 3))
			direction = 1;
		if (phase == ((fptr->phase+3) & 3))
			direction = -1;
		if (direction) {
			fptr->phase = MAX(0,MIN(79,fptr->phase+direction));
			if (!(fptr->phase & 1)) {
				int newtrack = MIN(nNumTracksInImage-1,fptr->phase >> 1);
				if (newtrack != fptr->track) {
					if (fptr->trackimage && fptr->trackimagedirty)
						WriteTrack(currdrive);
					fptr->track = newtrack;
					fptr->trackimagedata = 0;
				}
			}
		}
Beispiel #8
0
bool 
MovieWriter::CheckQueues()
{
    CAutoLock lock(&m_csWrite);
    if (m_bStopped)
    {
        return false;
    }

    // threading notes: we don't lock the
    // individual track queues except during the
    // actual access functions. The tracks are free to
    // add data to the end of the queue. The head of the queue 
    // will not be removed except during Stop and by us. The
    // m_bStopped flag ensures that we are not running when the
    // tracks enter Stop.

    // we need to return true if the whole set is at EOS
    // and all queues emptied
    bool bAllFinished;
    for(;;)
    {
        bAllFinished = true; // ... until proven otherwise

        // scan tracks to find which if any should write a chunk
        bool bSomeNotReady = false;
        bool bSomeAtEOS = false;
        LONGLONG tEarliestNotReady = -1;
        LONGLONG tEarliestReady = -1;
        int indexReady = -1;
        for (UINT i = 0; i < m_Tracks.size(); i++)
        {
            LONGLONG tHead;
            if (!m_Tracks[i]->GetHeadTime(&tHead))
            {
                // no chunk ready -- ok if finished
                if (!m_Tracks[i]->IsAtEOS())
                {
                    bAllFinished = false;

                    // note last write time
                    bSomeNotReady = true;
                    LONGLONG tWritten = m_Tracks[i]->LastWrite();
                    if ((tEarliestNotReady == -1) || (tWritten < tEarliestNotReady))
                    {
                        // remember the time of the track that is furthest
                        // behind
                        tEarliestNotReady = tWritten;
                    }
                } else {
                    bSomeAtEOS = true;
                }
            } else {

                bAllFinished = false;  // queue not empty -> not finished

                // remember the earliest of the ready blocks
                if ((tEarliestReady == -1) || (tHead < tEarliestReady))
                {
                    tEarliestReady = tHead;
                    indexReady = i;
                }
            }
        }

        // is there anything to write
        if (indexReady < 0)
        {
            break;
        }
        
        // mustn't get too far ahead of any blocked tracks (unless we have reached EOS)
		if (!bSomeAtEOS && bSomeNotReady)
        {
            // wait for more data on earliest-not-ready track
            break;
        }

		WriteTrack(indexReady);
    }

    return bAllFinished;
}