Beispiel #1
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 #2
0
void __stdcall Disk2InterfaceCard::ControlStepper(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles)
{
	FloppyDrive* pDrive = &m_floppyDrive[m_currDrive];
	FloppyDisk* pFloppy = &pDrive->m_disk;

	if (!m_floppyMotorOn)	// GH#525
	{
		if (!pDrive->m_spinning)
		{
#if LOG_DISK_PHASES
			LOG_DISK("stepper accessed whilst motor is off and not spinning\r\n");
#endif
			return;
		}

#if LOG_DISK_PHASES
		LOG_DISK("stepper accessed whilst motor is off, but still spinning\r\n");
#endif
	}

	int phase = (address >> 1) & 3;
	int phase_bit = (1 << phase);

#if 1
	// update the magnet states
	if (address & 1)
	{
		// phase on
		m_phases |= phase_bit;
	}
	else
	{
		// phase off
		m_phases &= ~phase_bit;
	}

	// 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 (m_phases & (1 << ((pDrive->m_phase + 1) & 3)))
		direction += 1;
	if (m_phases & (1 << ((pDrive->m_phase + 3) & 3)))
		direction -= 1;

	// apply magnet step, if any
	if (direction)
	{
		pDrive->m_phase = MAX(0, MIN(79, pDrive->m_phase + direction));
		const int nNumTracksInImage = ImageGetNumTracks(pFloppy->m_imagehandle);
		const int newtrack = (nNumTracksInImage == 0)	? 0
														: MIN(nNumTracksInImage-1, pDrive->m_phase >> 1); // (round half tracks down)
		if (newtrack != pDrive->m_track)
		{
			FlushCurrentTrack(m_currDrive);
			pDrive->m_track = newtrack;
			pFloppy->m_trackimagedata = false;

			m_formatTrack.DriveNotWritingTrack();
		}

		// Feature Request #201 Show track status
		// https://github.com/AppleWin/AppleWin/issues/201
		FrameDrawDiskStatus( (HDC)0 );
	}
#else
	// substitute alternate stepping code here to test
#endif

#if LOG_DISK_PHASES
	LOG_DISK("track $%02X%s phases %d%d%d%d phase %d %s address $%4X\r\n",
		pDrive->m_phase >> 1,
		(pDrive->m_phase & 1) ? ".5" : "  ",
		(m_phases >> 3) & 1,
		(m_phases >> 2) & 1,
		(m_phases >> 1) & 1,
		(m_phases >> 0) & 1,
		phase,
		(address & 1) ? "on " : "off",
		address);
#endif
}