/* floppy disc interface set drive */ void FDI_SetPhysicalDrive(unsigned long Value) { /* map fdc drive output to physical drive selects */ fdi.PhysicalDrive = Value & FDI_DriveMask; fdi.PhysicalDrive = fdi.PhysicalDrive ^ FDI_DriveSwitch; fdi.drive = FDD_GetDrive(fdi.PhysicalDrive); }
void FDD_Initialise(int Drive) { FDD *drive = FDD_GetDrive(Drive); /* set default side */ // drive->PhysicalSide = 0; drive->Flags |= FDD_FLAGS_DRIVE_ENABLED; drive->Flags &= ~(FDD_FLAGS_DISK_PRESENT | FDD_FLAGS_WRITE_PROTECTED); }
/* the disc light comes on for a read/write operation only */ void FDD_LED_SetState(unsigned long Drive, int LedState) { FDD *drive = FDD_GetDrive(Drive); if (LedState) { drive->Flags &=~FDD_FLAGS_LED_ON; } else { drive->Flags |= FDD_FLAGS_LED_ON; } }
void FDD_Enable(int Drive, BOOL bState) { FDD *drive = FDD_GetDrive(Drive); if (bState) { drive->Flags |= FDD_FLAGS_DRIVE_ENABLED; } else { drive->Flags &=~FDD_FLAGS_DRIVE_ENABLED; } }
void FDD_Initialise(int Drive) { FDD *drive = FDD_GetDrive(Drive); drive->CurrentTrack = 1; drive->CurrentIDIndex = 0; /* set default side */ drive->PhysicalSide = 0; /* set flags */ drive->Flags = 0; FDD_RefreshWriteProtect(Drive); FDD_RefreshMotorState(Drive); }
/* insert or remove a disk from a drive */ void FDD_InsertDisk(int Drive,BOOL Status) { FDD *drive = FDD_GetDrive(Drive); /* say disk is or isn't present */ drive->Flags &=~FDD_FLAGS_DISK_PRESENT; if (Status) { drive->Flags |= FDD_FLAGS_DISK_PRESENT; } /* set appropiate drive status */ // FDC_SetDriveStatus(Drive); /* setup initial parameters for when a disk is present */ drive->CurrentIDIndex = 0; }
/* insert or remove a disk from a drive */ void FDD_InsertDisk(int Drive,BOOL Status) { FDD *drive = FDD_GetDrive(Drive); /* say disk is or isn't present */ drive->Flags &=~FDD_FLAGS_DISK_PRESENT; if (Status) { drive->Flags |= FDD_FLAGS_DISK_PRESENT; } /* setup initial parameters for when a disk is present */ drive->CurrentIDIndex = 0; /* refresh motor state */ FDD_RefreshMotorState(Drive); /* refresh write protect status that is reported */ FDD_RefreshWriteProtect(Drive); }
/* perform the actual step */ void FDD_PerformStep(unsigned long DriveIndex, signed int StepDirection) { FDD *theDrive; int CurrentTrack; int Flags; theDrive = FDD_GetDrive(DriveIndex); /* perform step */ CurrentTrack = theDrive->CurrentTrack; CurrentTrack += StepDirection; /* range check head position */ if (CurrentTrack<0) { CurrentTrack = 0; } else if (CurrentTrack>=theDrive->NumberOfTracks) { CurrentTrack = theDrive->NumberOfTracks-1; } Flags = theDrive->Flags; Flags &= ~FDD_FLAGS_HEAD_AT_TRACK_0; /* head at track 0? */ if (CurrentTrack == 0) { /* yes */ Flags |= FDD_FLAGS_HEAD_AT_TRACK_0; } theDrive->Flags = Flags; theDrive->CurrentTrack = CurrentTrack; theDrive->CurrentIDIndex = 0; }
void FDD_SetMotorState(int Drive, int MotorState) { BOOL bReady = FALSE; FDD *drive = FDD_GetDrive(Drive); /* drive enabled? */ if (drive->Flags & FDD_FLAGS_DRIVE_ENABLED) { /* disk present? */ if (drive->Flags & FDD_FLAGS_DISK_PRESENT) { /* motor on? */ if (MotorState!=0) bReady = TRUE; } } if (bReady) drive->Flags |=FDD_FLAGS_DRIVE_READY; else drive->Flags &=~FDD_FLAGS_DRIVE_READY; }
void FDD_RefreshMotorState(int Drive) { /* really need a delay before drive becomes ready! */ BOOL bReady = FALSE; FDD *drive = FDD_GetDrive(Drive); /* drive enabled? */ if (drive->Flags & FDD_FLAGS_DRIVE_ENABLED) { /* disk present? */ if (drive->Flags & FDD_FLAGS_DISK_PRESENT) { /* motor on? */ if (FDI_GetMotorState()) bReady = TRUE; } } if (bReady) drive->Flags |=FDD_FLAGS_DRIVE_READY; else drive->Flags &=~FDD_FLAGS_DRIVE_READY; }
int FDD_LED_GetState(unsigned long Drive) { FDD *drive = FDD_GetDrive(Drive); return ((drive->Flags & FDD_FLAGS_LED_ON)!=0); }
/* turn disk in the drive */ void FDD_TurnDisk(int Drive) { FDD *drive = FDD_GetDrive(Drive); // drive->PhysicalSide^=0x01; }
BOOL FDD_IsDiskPresent(int Drive) { return FDD_GetDrive(Drive)->Flags & FDD_FLAGS_DISK_PRESENT; }
BOOL FDD_GetDiskSideA(int Drive) { FDD *drive = FDD_GetDrive(Drive); return (drive->PhysicalSide==0); }
BOOL FDD_IsEnabled(int Drive) { FDD *drive = FDD_GetDrive(Drive); return ((drive->Flags & FDD_FLAGS_DRIVE_ENABLED)!=0); }
int FDD_GetPhysicalSide(int Drive) { FDD *drive = FDD_GetDrive(Drive); return drive->PhysicalSide; }