| 623 | } |
| 624 | |
| 625 | void Disk2InterfaceCard::ControlStepperDeferred(void) |
| 626 | { |
| 627 | m_deferredStepperEvent = false; |
| 628 | const WORD address = m_deferredStepperAddress; |
| 629 | |
| 630 | FloppyDrive* pDrive = &m_floppyDrive[m_currDrive]; |
| 631 | FloppyDisk* pFloppy = &pDrive->m_disk; |
| 632 | |
| 633 | // check for any stepping effect from a magnet |
| 634 | // - move only when the magnet opposite the cog is off |
| 635 | // - move in the direction of an adjacent magnet if one is on |
| 636 | // - do not move if both adjacent magnets are on (ie. quarter track) |
| 637 | // - timing is accounted for in the case when "two phases [are] turned off in rapid sequence" (UTAIIe page 9-13) (GH#1110) |
| 638 | // momentum is not accounted for ... maybe one day! |
| 639 | int direction = 0; |
| 640 | if (m_magnetStates & (1 << ((pDrive->m_phase + 1) & 3))) |
| 641 | direction += 1; |
| 642 | if (m_magnetStates & (1 << ((pDrive->m_phase + 3) & 3))) |
| 643 | direction -= 1; |
| 644 | |
| 645 | // Only calculate quarterDirection for WOZ, as NIB/DSK don't support half phases. |
| 646 | int quarterDirection = 0; |
| 647 | if (ImageIsWOZ(pFloppy->m_imagehandle)) |
| 648 | { |
| 649 | if ((m_magnetStates == 0xC || // 1100 |
| 650 | m_magnetStates == 0x6 || // 0110 |
| 651 | m_magnetStates == 0x3 || // 0011 |
| 652 | m_magnetStates == 0x9)) // 1001 |
| 653 | { |
| 654 | quarterDirection = direction; |
| 655 | direction = 0; |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | pDrive->m_phase = MAX(0, MIN(79, pDrive->m_phase + direction)); |
| 660 | float newPhasePrecise = (float)(pDrive->m_phase) + (float)quarterDirection * 0.5f; |
| 661 | if (newPhasePrecise < 0) |
| 662 | newPhasePrecise = 0; |
| 663 | |
| 664 | // apply magnet step, if any |
| 665 | if (newPhasePrecise != pDrive->m_phasePrecise) |
| 666 | { |
| 667 | FlushCurrentTrack(m_currDrive); |
| 668 | pDrive->m_phasePrecise = newPhasePrecise; |
| 669 | pFloppy->m_trackimagedata = false; |
| 670 | m_formatTrack.DriveNotWritingTrack(); |
| 671 | GetFrame().FrameDrawDiskStatus(); // Show track status (GH#201) |
| 672 | } |
| 673 | |
| 674 | ControlStepperLogging(address, m_deferredStepperCumulativeCycles); |
| 675 | } |
| 676 | |
| 677 | void Disk2InterfaceCard::ControlStepperLogging(WORD address, unsigned __int64 cumulativeCycles) |
| 678 | { |
no test coverage detected