diff --git a/src/cpu/808x.c b/src/cpu/808x.c index 95e3e5b..8b90f1c 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -18,7 +18,7 @@ * 2 clocks - fetch opcode 1 2 clocks - execute * 2 clocks - fetch opcode 2 etc * - * Version: @(#)808x.c 1.0.5 2018/05/06 + * Version: @(#)808x.c 1.0.6 2018/09/22 * * Authors: Sarah Walker, * Miran Grca, @@ -182,23 +182,6 @@ FETCH(void) { uint8_t temp; -#if 0 - temp=prefetchqueue[0]; - prefetchqueue[0]=prefetchqueue[1]; - prefetchqueue[1]=prefetchqueue[2]; - prefetchqueue[2]=prefetchqueue[3]; - prefetchqueue[3]=prefetchqueue[4]; - prefetchqueue[4]=prefetchqueue[5]; - if (prefetchw<=((is8086)?4:3)) - { - prefetchqueue[prefetchw++]=readmembf(cs+prefetchpc); prefetchpc++; - if (is8086 && (prefetchpc&1)) - { - prefetchqueue[prefetchw++]=readmembf(cs+prefetchpc); prefetchpc++; - } - } -#endif - if (prefetchw==0) { cycles-=(4-(fetchcycles&3)); @@ -219,8 +202,10 @@ FETCH(void) prefetchqueue[0]=prefetchqueue[1]; prefetchqueue[1]=prefetchqueue[2]; prefetchqueue[2]=prefetchqueue[3]; - prefetchqueue[3]=prefetchqueue[4]; - prefetchqueue[4]=prefetchqueue[5]; + if (is8086) { + prefetchqueue[3]=prefetchqueue[4]; + prefetchqueue[4]=prefetchqueue[5]; + } prefetchw--; fetchcycles-=4; cpu_state.pc++; @@ -234,7 +219,7 @@ FETCHADD(int c) { int d; if (c<0) return; - if (prefetchw>((is8086)?4:3)) return; + if (prefetchw>((is8086)?5:3)) return; d=c+(fetchcycles&3); while (d>3 && prefetchw<((is8086)?6:4)) { @@ -245,7 +230,7 @@ FETCHADD(int c) prefetchpc++; prefetchw++; } - if (prefetchw<6) + if (prefetchw<(is8086)?6:4) { prefetchqueue[prefetchw]=readmembf(cs+prefetchpc); prefetchpc++; @@ -271,7 +256,7 @@ void FETCHCOMPLETE(void) { if (!(fetchcycles&3)) return; - if (prefetchw>((is8086)?4:3)) return; + if (prefetchw>((is8086)?5:3)) return; if (!prefetchw) nextcyc=(4-(fetchcycles&3)); cycles-=(4-(fetchcycles&3)); fetchclocks+=(4-(fetchcycles&3)); @@ -281,7 +266,7 @@ FETCHCOMPLETE(void) prefetchpc++; prefetchw++; } - if (prefetchw<6) + if (prefetchw<(is8086)?6:4) { prefetchqueue[prefetchw]=readmembf(cs+prefetchpc); prefetchpc++; diff --git a/src/devices/floppy/fdc.c b/src/devices/floppy/fdc.c index f752761..b3d131a 100644 --- a/src/devices/floppy/fdc.c +++ b/src/devices/floppy/fdc.c @@ -9,7 +9,7 @@ * Implementation of the NEC uPD-765 and compatible floppy disk * controller. * - * Version: @(#)fdc.c 1.0.15 2018/09/21 + * Version: @(#)fdc.c 1.0.16 2018/09/22 * * Authors: Miran Grca, * Sarah Walker, @@ -1341,21 +1341,35 @@ fdc_read(uint16_t addr, void *priv) case 7: /*Disk change*/ drive = real_drive(fdc, fdc->dor & 3); - ret = 0x00; - - if (fdc->flags & FDC_FLAG_TOSHIBA) { - /* - * T1200 only has the DSCH bit set for the - * internal 3.5" drive, otherwise it is 0. - */ - if ((drive == 0) && (fdc->dor & (0x10 << drive))) - ret = (fdd_changed[drive] || drive_empty[drive]) ? 0x80 : 0x00; + if (fdc->flags & FDC_FLAG_PS1) { + if (fdc->dor & (0x10 << drive)) { + ret = (fdd_changed[drive] || drive_empty[drive]) ? 0x00 : 0x80; + ret |= (fdc->dor & 0x08); + ret |= (fdc->rate & 0x03); + } else + ret = 0x00; } else { - if (fdc->dor & (0x10 << drive)) - ret = (fdd_changed[drive] || drive_empty[drive])?0x80:0; + if (fdc->dor & (0x10 << drive)) { + /* + * T1200 only has the DSCH bit set for the + * internal 3.5" drive, otherwise it is 0. + */ + if ((drive == 1) && (fdc->flags & FDC_FLAG_TOSHIBA)) + ret = 0x00; + else + ret = (fdd_changed[drive] || drive_empty[drive]) ? 0x80 : 0x00; + } else + ret = 0x00; + + /* Some controllers reverse this bit. */ if (fdc->flags & FDC_FLAG_DISKCHG_ACTLOW) ret ^= 0x80; - ret |= 0x01; + + if (fdc->flags & FDC_FLAG_TOSHIBA) { + /* 1=ExtFDD off, 2=ExtFDD =A, 3=ExtFDD = B */ + ret |= (0x03 << 5); + } else + ret |= 0x01; } break; diff --git a/src/pc.c b/src/pc.c index efc76f8..339b353 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Main emulator module where most things are controlled. * - * Version: @(#)pc.c 1.0.53 2018/09/03 + * Version: @(#)pc.c 1.0.54 2018/09/22 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -366,6 +366,13 @@ fatal(const char *fmt, ...) dumppic(); dumpregs(1); + /* + * Attempt to perform a clean exit by terminating the + * main loop of the emulator, which hopefully also do + * a shutdown of all running threads. + */ + plat_stop(); + /* Make sure the message does not have a trailing newline. */ if ((sp = strchr(temp, '\n')) != NULL) *sp = '\0';