int num_tracks, write_num_tracks, num_secs, num_heads;
int hard_num_cyls;
bool dskeject;
+ int dskeject_time;
bool dskchange;
int dskchange_time;
bool dskready;
#define MIN_STEPLIMIT_CYCLE (CYCLE_UNIT * 140)
+static const TCHAR *drivetypes[] = {
+ _T("none"),
+ _T("35dd"),
+ _T("35hd"),
+ _T("525sd"),
+ _T("35ddescom"),
+ _T("pc525_40"),
+ _T("pc525_80"),
+ _T("pc525_4080"),
+ _T("525dd"),
+ _T("floppybridge"),
+ NULL
+};
+
static uae_u16 bigmfmbufw[0x4000 * DDHDMULT];
static drive floppy[MAX_FLOPPY_DRIVES];
static TCHAR dfxhistory[HISTORY_MAX][MAX_PREVIOUS_IMAGES][MAX_DPATH];
if (num == 0 && currprefs.floppyslots[num].dfxtype == 0)
drv->indexhackmode = 1;
drv->dskchange_time = 0;
+ drv->dskeject_time = 0;
drv->dskchange = false;
drv->dskready_down_time = 0;
drv->dskready_up_time = 0;
drv->steplimitcycle = get_cycles();
}
-static bool drive_empty (drive * drv)
+static bool drive_empty(drive * drv)
{
+ if (drv->dskeject_time > 0) {
+ return true;
+ }
#ifdef FLOPPYBRIDGE
if (drv->bridge) {
bool v = drv->bridge->isDiskInDrive();
return drv->diskfile == 0 && drv->dskchange_time >= 0;
}
-static void drive_step (drive *drv, int step_direction)
+static void drive_step(drive *drv, int step_direction)
{
#ifdef CATWEASEL
if (drv->catweasel) {
write_log (_T(" ->step %d"), drv->cyl);
}
-static bool drive_track0 (drive * drv)
+static bool drive_track0(drive * drv)
{
#ifdef FLOPPYBRIDGE
if (drv->bridge) {
static bool drive_diskchange(drive *drv)
{
+ if (drv->dskeject_time > 0 && drv->dskchange) {
+ return true;
+ }
#ifdef FLOPPYBRIDGE
if (drv->bridge) {
bool v = drv->bridge->hasDiskChanged();
currprefs.floppy_read_only = changed_prefs.floppy_read_only;
for (int i = 0; i < MAX_FLOPPY_DRIVES; i++) {
drive *drv = floppy + i;
+ bool dc = false;
+
if (drv->dskeject) {
drive_eject(drv);
/* set dskchange_time, disk_insert() will be
*/
setdskchangetime(drv, 2 * 50 * 312);
}
+
+ if (_tcscmp(currprefs.floppyslots[i].dfxprofile, changed_prefs.floppyslots[i].dfxprofile)) {
+ TCHAR tmp[256];
+ _tcscpy(tmp, changed_prefs.floppyslots[i].dfxprofile);
+ const TCHAR *idx = _tcschr(tmp, ':');
+ if (idx) {
+ tmp[idx - tmp] = 0;
+ }
+ for (int j = 0; drivetypes[j]; j++) {
+ if (!_tcsicmp(tmp, drivetypes[j])) {
+ changed_prefs.floppyslots[i].dfxtype = j - 1;
+ if (j > 0) {
+ dc = true;
+ }
+ }
+ }
+ }
+
if (currprefs.floppyslots[i].dfxtype != changed_prefs.floppyslots[i].dfxtype ||
+ _tcscmp(currprefs.floppyslots[i].dfxprofile, changed_prefs.floppyslots[i].dfxprofile) ||
currprefs.floppyslots[i].dfxsubtype != changed_prefs.floppyslots[i].dfxsubtype) {
int old = currprefs.floppyslots[i].dfxtype;
currprefs.floppyslots[i].dfxtype = changed_prefs.floppyslots[i].dfxtype;
if (old >= DRV_FB || currprefs.floppyslots[i].dfxtype >= DRV_FB) {
floppybridge_getsetprofile(i);
floppybridge_init(&currprefs);
+ dc = true;
}
#endif
- reset_drive (i);
+ reset_drive(i);
+ if (dc) {
+ drv->dskeject_time = 2 * 50 * 312;
+ drv->dskchange = true;
+ }
#ifdef RETROPLATFORM
rp_floppy_device_enable (i, currprefs.floppyslots[i].dfxtype >= 0);
#endif
}
}
-void DISK_vsync (void)
+void DISK_vsync(void)
{
- DISK_check_change ();
+ DISK_check_change();
for (int i = 0; i < MAX_FLOPPY_DRIVES; i++) {
drive *drv = floppy + i;
if (drv->selected_delay > 0) {
drv->selected_delay--;
}
if (drv->dskchange_time == 0 && _tcscmp (currprefs.floppyslots[i].df, changed_prefs.floppyslots[i].df))
- disk_insert (i, changed_prefs.floppyslots[i].df, changed_prefs.floppyslots[i].forcedwriteprotect);
+ disk_insert(i, changed_prefs.floppyslots[i].df, changed_prefs.floppyslots[i].forcedwriteprotect);
}
}
dsklength--;
if (dsklength <= 0) {
// delay write DMA finished state until bridge has all pending data written
+#ifdef FLOPPYBRIDGE
if (!wasBridge) {
disk_dmafinished();
}
+#endif
for (int dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) {
drive *drv = &floppy[dr];
drv->writtento = 0;
/* this is very unoptimized. DSKBYTR is used very rarely, so it should not matter. */
-uae_u16 DSKBYTR (int hpos)
+uae_u16 DSKBYTR(int hpos)
{
uae_u16 v;
- DISK_update (hpos);
+ DISK_update(hpos);
v = dskbytr_val;
dskbytr_val &= ~0x8000;
if (word == dsksync && cycles_in_range(dsksync_cycles)) {
if (dsklen & 0x4000)
v |= 0x2000;
if (disk_debug_logging > 2)
- write_log (_T("DSKBYTR=%04X hpos=%d\n"), v, hpos);
+ write_log(_T("DSKBYTR=%04X PC=%08x\n"), v, M68K_GETPC);
for (int dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
drive *drv = &floppy[dr];
if (drv->motoroff)
drv->track_access_done = true;
if (disk_debug_mode & DISK_DEBUG_PIO) {
if (disk_debug_track < 0 || disk_debug_track == 2 * drv->cyl + side) {
- disk_dma_debugmsg ();
- write_log (_T("DSKBYTR=%04X\n"), v);
- activate_debugger ();
+ disk_dma_debugmsg();
+ write_log(_T("DSKBYTR=%04X\n"), v);
+ activate_debugger();
break;
}
}
return v;
}
-static void DISK_start (void)
+static void DISK_start(void)
{
int dr;
if (dskdmaen == DSKDMA_WRITE) {
drv->tracklen = floppy_writemode > 0 ? FLOPPY_WRITE_MAXLEN : FLOPPY_WRITE_LEN * drv->ddhd * 8 * 2;
- drv->trackspeed = get_floppy_speed ();
+ drv->trackspeed = get_floppy_speed();
drv->skipoffset = -1;
updatemfmpos (drv);
}
if (drv->dskready_up_time == 0 && !drv->motoroff)
drv->dskready = true;
}
+ if (drv->dskeject_time > 0) {
+ drv->dskeject_time--;
+ }
/* delay until new disk image is inserted */
if (drv->dskchange_time > 0) {
drv->dskchange_time--;
if (drv->dskchange_time == 0) {
- drive_insert (drv, &currprefs, dr, drv->newname, false, drv->newnamewriteprotected);
+ drive_insert(drv, &currprefs, dr, drv->newname, false, drv->newnamewriteprotected);
if (disk_debug_logging > 0)
- write_log (_T("delayed insert, drive %d, image '%s'\n"), dr, drv->newname);
- update_drive_gui (dr, false);
+ write_log(_T("delayed insert, drive %d, image '%s'\n"), dr, drv->newname);
+ update_drive_gui(dr, false);
}
}
int cycles;
if (disk_hpos < 0) {
- disk_hpos = - disk_hpos;
+ disk_hpos = -disk_hpos;
return;
}
if (tohpos != maxhpos || cycles / 256 != maxhpos)
write_log (_T("%d %d %d\n"), tohpos, cycles / 256, disk_hpos / 256);
#endif
- if (cycles <= 0)
+ if (cycles <= 0) {
return;
+ }
disk_hpos += cycles;
- if (disk_hpos >= (maxhpos << 8))
+ if (disk_hpos >= (maxhpos << 8)) {
disk_hpos %= 1 << 8;
+ }
for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
drive *drv = &floppy[dr];
static void floppybridge_init2(struct uae_prefs *p)
{
- floppybridge_init3();
+ static const TCHAR *floppybridgeprofile = _T("FloppyBridge:");
bool needbridge = false;
+
+ floppybridge_init3();
for (int i = 0; i < MAX_FLOPPY_DRIVES; i++) {
+ TCHAR *profile = p->floppyslots[i].dfxprofile;
int type = p->floppyslots[i].dfxtype;
- if (type >= DRV_FB) {
+ if (type >= DRV_FB || !_tcsncmp(profile, floppybridgeprofile, _tcslen(floppybridgeprofile))) {
needbridge = true;
}
}
return;
}
for (int dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
+ TCHAR *profile = p->floppyslots[dr].dfxprofile;
+ if (!_tcsncmp(profile, floppybridgeprofile, _tcslen(floppybridgeprofile))) {
+ profile += _tcslen(floppybridgeprofile);
+ if (p->floppyslots[dr].dfxtype != DRV_FB) {
+ p->floppyslots[dr].dfxtype = DRV_FB;
+ changed_prefs.floppyslots[dr].dfxtype = DRV_FB;
+ }
+ }
int type = p->floppyslots[dr].dfxtype;
if (type == DRV_FB) {
if (floppy[dr].bridge == NULL || type != bridge_type[dr]) {
bridge_driver[dr] = NULL;
bridge_type[dr] = type;
FloppyBridgeAPI *bridge = NULL;
- int id = _tstol(p->floppyslots[dr].dfxsubtypeid);
- if (p->floppyslots[dr].dfxprofile[0]) {
- char *a = ua(p->floppyslots[dr].dfxprofile);
+ if (profile[0]) {
+ char *a = ua(profile);
bridge = FloppyBridgeAPI::createDriverFromString(a);
+ if (!bridge) {
+ write_log(_T("FB profile '%s' failed\n"), profile);
+ }
xfree(a);
}
if (!bridge) {
const TCHAR *name = _tcschr(p->floppyslots[dr].dfxsubtypeid, ':');
if (name) {
+ int id = _tstol(p->floppyslots[dr].dfxsubtypeid);
name++;
for (int i = 0; i < bridgeprofiles.size(); i++) {
FloppyBridgeAPI::FloppyBridgeProfileInformation fbpi = bridgeprofiles.at(i);
}
}
}
- if (!bridge) {
+ if (!bridge && p->floppyslots[dr].dfxsubtypeid[0]) {
+ int id = _tstol(p->floppyslots[dr].dfxsubtypeid);
bridge = FloppyBridgeAPI::createDriverFromProfileID(id);
}
if (bridge) {