Reverted floppy disk operation to what it was in build 274, with a slight cleanup;

Sound Blaster 16 and AWE32 IRQ, base address, and DMA configuration is back;
The Intel Advanced/ATX now requires version 1.00.06 of the BIOS rather than 1.00.05.
This commit is contained in:
OBattler
2016-11-10 21:16:24 +01:00
parent 02014df53a
commit 971eeedde7
7 changed files with 386 additions and 433 deletions

176
src/fdc.c
View File

@@ -16,30 +16,26 @@ extern int motoron[2];
int ui_writeprot[2] = {0, 0};
/* Bit 0 = Has drive select
Bit 1 = Is read/write
Bit 2 = Has head select */
int command_flags[256] = { [0x02] = 7, /* READ TRACK */
[0x04] = 7, /* SENSE DRIVE STATUS */
[0x05] = 7, /* WRITE DATA */
[0x06] = 7, /* READ DATA */
int command_has_drivesel[256] = { [0x02] = 1, /* READ TRACK */
[0x04] = 1, /* SENSE DRIVE STATUS */
[0x05] = 1, /* WRITE DATA */
[0x06] = 1, /* READ DATA */
[0x07] = 1, /* RECALIBRATE */
[0x09] = 7, /* WRITE DELETED DATA */
[0x0A] = 7, /* READ ID */
[0x0C] = 7, /* READ DELETED DATA */
[0x0D] = 7, /* FORMAT TRACK */
[0x0F] = 7, /* SEEK, RELATIVE SEEK */
[0x11] = 7, /* SCAN EQUAL */
[0x16] = 7, /* VERIFY */
[0x19] = 7, /* SCAN LOW OR EQUAL */
[0x1D] = 7 }; /* SCAN HIGH OR EQUAL */
[0x09] = 1, /* WRITE DELETED DATA */
[0x0A] = 1, /* READ ID */
[0x0C] = 1, /* READ DELETED DATA */
[0x0D] = 1, /* FORMAT TRACK */
[0x0F] = 1, /* SEEK, RELATIVE SEEK */
[0x11] = 1, /* SCAN EQUAL */
[0x16] = 1, /* VERIFY */
[0x19] = 1, /* SCAN LOW OR EQUAL */
[0x1D] = 1 }; /* SCAN HIGH OR EQUAL */
static int fdc_reset_stat = 0;
/*FDC*/
typedef struct FDC
{
uint8_t dor,tdr,stat,command,dat,st0;
uint8_t dor,stat,command,dat,st0;
int head,track[256],sector,drive,lastdrive;
int rw_track;
int pos;
@@ -200,68 +196,31 @@ int fdc_is_mfm()
return fdc.mfm ? 1 : 0;
}
double fdc_get_bit_period()
{
double bcp = 4.0;
switch(fdc_get_bit_rate())
{
case 0:
bcp = 2.0;
break;
case 1:
bcp = 20.0 / 6.0;
break;
case 2:
default:
bcp = 4.0;
break;
case 3:
bcp = 1.0;
break;
case 5:
bcp = 0.5;
break;
}
if (!fdc_is_mfm())
{
bcp *= 2.0;
}
return bcp;
}
#if 0
double fdc_get_hut()
{
int hut = (fdc.specify[0] & 0xF);
double dusec;
double bcp;
double dhut;
if (!hut)
{
hut = 0x10;
}
dhut = (double) hut;
bcp = fdc_get_bit_period() * 8.0;
double bcp = ((double) fdc_get_bitcell_period()) / 250.0;
double dhut = (double) hut;
if (fdc_get_bitcell_period() == 3333) bcp = 160.0 / 6.0;
if (hut == 0) dhut = 16.0;
dusec = (double) TIMER_USEC;
return (dhut * bcp * 1000.0 * dusec);
return (bcp * dhut * dusec * 1000.0);
}
double fdc_get_hlt()
{
int hlt = (fdc.specify[1] >> 1);
double dusec;
double bcp;
double dhlt;
if (!hlt)
{
hlt = 0x80;
}
dhlt = (double) hlt;
bcp = fdc_get_bit_period() * 8.0;
double bcp = ((double) fdc_get_bitcell_period()) / 2000.0;
double dhlt = (double) hlt;
if (fdc_get_bitcell_period() == 3333) bcp = 20.0 / 6.0;
if (hlt == 0) dhlt = 256.0;
dusec = (double) TIMER_USEC;
return (dhlt * bcp * 1000.0 * dusec);
return (bcp * dhlt * dusec * 1000.0);
}
#endif
void fdc_request_next_sector_id()
{
@@ -342,7 +301,9 @@ void fdc_fifo_buf_dummy()
static void fdc_int()
{
if (!fdc.pcjr)
{
picint(1 << 6);
}
}
static void fdc_watchdog_poll(void *p)
@@ -580,7 +541,7 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv)
{
// pclog("Write FDC %04X %02X %04X:%04X %i %02X %i rate=%i %i\n",addr,val,cs>>4,pc,ins,fdc.st0,ins,fdc.rate, fdc.data_ready);
int drive;
int seek_time;
int seek_time, seek_time_base;
switch (addr&7)
{
@@ -652,7 +613,6 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv)
return;
case 3:
/* TDR */
fdc.tdr = val & 3;
if (fdc.enh_mode)
{
drive = (fdc.dor & 1) ^ fdd_swap;
@@ -660,7 +620,6 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv)
}
return;
case 4:
val &= 0xdf; /* Bit 5 is hardwired to 0. */
if (val & 0x80)
{
timer_process();
@@ -861,19 +820,10 @@ bad_command:
timer_process();
disctime = 1024 * (1 << TIMER_SHIFT);
timer_update_outstanding();
if (command_flags[discint & 0x1F] & 1)
if (command_has_drivesel[discint & 0x1F])
{
fdc.drive = fdc.params[0] & 3;
}
if (command_flags[discint & 0x1F] & 4)
{
fdd_set_head(fdc.drive, (fdc.params[0] & 4) ? 1 : 0);
if (command_flags[discint & 0x1F] & 2)
{
// pclog("Command %02X, loading head...\n", fdc.command);
disc_head_load(fdc.drive, fdd_get_head(fdc.drive ^ fdd_swap));
}
}
fdc_reset_stat = 0;
switch (discint & 0x1F)
{
@@ -1038,6 +988,7 @@ bad_command:
break;
case 7: /*Recalibrate*/
seek_time_base = fdd_doublestep_40(fdc.drive ^ fdd_swap) ? 10 : 5;
fdc.stat = 1 << fdc.drive;
disctime = 0;
if (((fdc.drive ^ fdd_swap) == 1) && !fdc.drv2en)
@@ -1046,7 +997,7 @@ bad_command:
{
fdc_seek(fdc.drive, -fdc.max_track);
}
disctime = fdc.max_track * 10 * TIMER_USEC;
disctime = fdc.max_track * seek_time_base * TIMER_USEC;
break;
case 0x0d: /*Format*/
@@ -1068,6 +1019,7 @@ bad_command:
fdc.head = (fdc.params[0] & 4) ? 1 : 0;
fdd_set_head(fdc.drive, (fdc.params[0] & 4) ? 1 : 0);
disctime = 0;
seek_time_base = fdd_doublestep_40(fdc.drive ^ fdd_swap) ? 10 : 5;
if (fdc.command & 0x80)
{
if (!fdc.params[1])
@@ -1086,19 +1038,19 @@ bad_command:
/* Relative seek outwards. */
fdc_seek(fdc.drive, -fdc.params[1]);
}
disctime = ((int) fdc.params[1]) * 10 * TIMER_USEC;
disctime = ((int) fdc.params[1]) * seek_time * TIMER_USEC;
}
else
{
disctime = 10 * TIMER_USEC;
disctime = seek_time_base * TIMER_USEC;
}
}
else
{
seek_time = ((int) (fdc.params[1] - fdc.track[fdc.drive])) * 10 * TIMER_USEC;
seek_time = ((int) (fdc.params[1] - fdc.track[fdc.drive])) * seek_time_base * TIMER_USEC;
if (!seek_time)
{
disctime = 10 * TIMER_USEC;
disctime = seek_time_base * TIMER_USEC;
break;
}
fdc_seek(fdc.drive, fdc.params[1] - fdc.track[fdc.drive]);
@@ -1161,17 +1113,17 @@ uint8_t fdc_read(uint16_t addr, void *priv)
presumably implemented outside the FDC on one of the
motherboard's support chips.*/
if (fdd_is_525(drive))
temp = 0x20 | fdc.tdr;
temp = 0x20;
else if (fdd_is_ed(drive))
temp = 0x10 | fdc.tdr;
temp = 0x10;
else
temp = 0x00 | fdc.tdr;
temp = 0x00;
}
else if (!fdc.enh_mode)
temp = fdc.tdr;
temp = 0x20;
else
{
temp = (fdc.rwc[drive] << 4) | fdc.tdr;
temp = fdc.rwc[drive] << 4;
}
break;
case 4: /*Status*/
@@ -1242,13 +1194,8 @@ uint8_t fdc_read(uint16_t addr, void *priv)
return temp;
}
void fdc_poll_common_finish(int st5, int compare)
void fdc_poll_common_finish(int compare, int st5)
{
fdc.inread = 0;
// discint=-2;
disctime=0;
// pclog("Poll common finish (%02X)...\n", st5);
disc_head_unload(fdc.drive, fdd_get_head(fdc.drive ^ fdd_swap));
fdc_int();
fdc.stat=0xD0;
fdc.res[4]=(fdd_get_head(fdc.drive ^ fdd_swap)?4:0)|fdc.drive;
@@ -1291,12 +1238,17 @@ void fdc_poll_common_finish(int st5, int compare)
void fdc_poll_readwrite_finish(int compare)
{
fdc_poll_common_finish(0, compare);
fdc.inread = 0;
discint=-2;
fdc_poll_common_finish(compare, 0);
}
void fdc_no_dma_end(int compare)
{
fdc_poll_common_finish(0x80, compare);
disctime = 0;
fdc_poll_common_finish(compare, 0x80);
}
void fdc_callback()
@@ -1340,7 +1292,6 @@ void fdc_callback()
fdc.inread = 1;
return;
case 4: /*Sense drive status*/
disc_head_unload(fdc.drive, fdd_get_head(fdc.drive ^ fdd_swap));
fdc.res[10] = (fdc.params[0] & 7) | 0x28;
if (((fdc.drive ^ fdd_swap) != 1) || fdc.drv2en)
{
@@ -1648,22 +1599,19 @@ void fdc_error(int st5, int st6)
{
disctime = 0;
// pclog("Error (%02X, %02X)...\n", st5, st6);
disc_head_unload(fdc.drive, fdd_get_head(fdc.drive ^ fdd_swap));
// discint=-2;
fdc_int();
fdc.stat=0xD0;
fdc.res[4]=0x40|(fdd_get_head(fdc.drive ^ fdd_swap)?4:0)|fdc.drive;
fdc.res[5]=st5;
fdc.res[5]=st5; /*Overrun*/
fdc.res[6]=st6;
fdc.res[7]=0;
fdc.res[8]=0;
fdc.res[9]=0;
fdc.res[10]=0;
paramstogo=7;
// rpclog("c82c711_fdc_notfound\n");
}
void fdc_overrun()
{
disc_stop(fdc.drive);
@@ -1739,28 +1687,17 @@ int fdc_data(uint8_t data)
return 0;
}
/* void fdc_finishcompare(int satisfying)
{
fdc.satisfying_sectors++;
fdc.inread = 0;
// disc_head_unload(fdc.drive, fdd_get_head(fdc.drive ^ fdd_swap));
disctime = 200 * TIMER_USEC;
// rpclog("fdc_finishread\n");
}
void fdc_finishread()
{
fdc.inread = 0;
// disc_head_unload(fdc.drive, fdd_get_head(fdc.drive ^ fdd_swap));
disctime = 200 * TIMER_USEC;
// rpclog("fdc_finishread\n");
} */
}
void fdc_track_finishread(int condition)
{
fdc.satisfying_sectors |= condition;
fdc.inread = 0;
// disc_head_unload(fdc.drive, fdd_get_head(fdc.drive ^ fdd_swap));
fdc_callback();
// rpclog("fdc_finishread\n");
}
@@ -1769,7 +1706,6 @@ void fdc_sector_finishcompare(int satisfying)
{
fdc.satisfying_sectors++;
fdc.inread = 0;
// disc_head_unload(fdc.drive, fdd_get_head(fdc.drive ^ fdd_swap));
fdc_callback();
// rpclog("fdc_finishread\n");
}
@@ -1777,7 +1713,6 @@ void fdc_sector_finishcompare(int satisfying)
void fdc_sector_finishread()
{
fdc.inread = 0;
// disc_head_unload(fdc.drive, fdd_get_head(fdc.drive ^ fdd_swap));
fdc_callback();
// rpclog("fdc_finishread\n");
}
@@ -1862,10 +1797,7 @@ int fdc_getdata(int last)
void fdc_sectorid(uint8_t track, uint8_t side, uint8_t sector, uint8_t size, uint8_t crc1, uint8_t crc2)
{
// pclog("SectorID %i %i %i %i\n", track, side, sector, size);
fdc.inread = 0;
disc_head_unload(fdc.drive, fdd_get_head(fdc.drive ^ fdd_swap));
disctime = 0;
// pclog("SectorID %i %i %i %i\n", track, side, sector, size);
fdc_int();
fdc.stat=0xD0;
fdc.res[4]=(fdd_get_head(fdc.drive ^ fdd_swap)?4:0)|fdc.drive;