--- xmil/io/fdc.c 2004/08/15 07:52:16 1.16 +++ xmil/io/fdc.c 2004/08/18 08:08:13 1.19 @@ -12,6 +12,28 @@ static const UINT8 fdctype[] = {1,1,1,1,1,1,1,1,2,2,2,2,3,4,3,3}; +enum { + TAO_MODE_GAP = 0x4e, + TAO_MODE_SYNC = 0x00, + TAO_MODE_AM = 0xf5, + TAO_MODE_IM = 0xf6, + TAO_MODE_ID = 0xfe, + TAO_MODE_DATA = 0xfb, + TAO_ENDOFDATA = 0xf7, + + TAO_CMD_GAP = 0x4e, + TAO_CMD_SYNC = 0x00, + TAO_CMD_IM_IN = 0xf6, + TAO_CMD_IM = 0xfc, + TAO_CMD_AM_IN = 0xf5, + TAO_CMD_IAM = 0xfe, + TAO_CMD_DAM = 0xfb, + TAO_CMD_DDAM = 0xf8, + TAO_CMD_CRC = 0xf7 +}; + + +// ---- void neitem_fdcbusy(UINT id) { @@ -35,6 +57,7 @@ static void setbusy(SINT32 clock) { } } +#if defined(SUPPORT_MOTORRISEUP) static void setmotor(REG8 drvcmd) { UINT drv; @@ -80,6 +103,25 @@ void fdc_callback(void) { } } +static SINT32 motorwait(REG8 drv) { + + SINT32 curclock; + SINT32 nextclock; + + if (fdc.s.motorevent[drv] == FDCMOTOR_STARTING) { + curclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK; + curclock -= fdc.s.motorclock[drv]; + if (curclock < (SINT32)pccore.realclock) { + nextclock = pccore.realclock - curclock; +// TRACEOUT(("motor starting busy %d", nextclock)); + return(nextclock); + } + } + return(0); +} +#endif + + static REG8 getstat(void) { FDDFILE fdd; @@ -149,8 +191,8 @@ static REG8 type2cmd(REG8 sc) { FDDFILE fdd; UINT size; REG8 stat; -#if defined(SUPPORT_DISKEXT) SINT32 clock; +#if defined(SUPPORT_DISKEXT) SINT32 curclock; SINT32 nextclock; UINT32 secinfo; @@ -190,18 +232,11 @@ static REG8 type2cmd(REG8 sc) { fdc.s.bufsize = size; fdc.s.curtime = 0; -#if defined(SUPPORT_DISKEXT) - // ウェイト値を計算 clock = 0; - if (fdc.s.motorevent[fdc.s.drv] == FDCMOTOR_STARTING) { - curclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK; - curclock -= fdc.s.motorclock[fdc.s.drv]; - if (curclock < (SINT32)pccore.realclock) { - nextclock = pccore.realclock - curclock; -// TRACEOUT(("motor starting busy %d", nextclock)); - clock += nextclock; - } - } +#if defined(SUPPORT_MOTORRISEUP) + clock += motorwait(fdc.s.drv); +#endif +#if defined(SUPPORT_DISKEXT) secinfo = fdd->sec(fdd, fdc.s.media, track, sc); if (secinfo) { nextclock = LOW16(secinfo); @@ -216,10 +251,8 @@ static REG8 type2cmd(REG8 sc) { // LOW16(secinfo), LOW16(secinfo >> 16))); clock += nextclock; } - setbusy(max(clock, 500)); -#else - setbusy(500); #endif + setbusy(max(clock, 500)); return(stat); } @@ -310,7 +343,7 @@ void IOOUTCALL fdc_o(UINT port, REG8 val if ((port & (~7)) != 0x0ff8) { return; } -// TRACEOUT(("fdc %.4x,%.2x [%.4x]", port, value, Z80_PC)); + TRACEOUT(("fdc %.4x,%.2x [%.4x]", port, value, Z80_PC)); switch(port & 7) { case 0: // コマンド fdc.s.cmd = value; @@ -440,7 +473,9 @@ void IOOUTCALL fdc_o(UINT port, REG8 val fdc.s.r = 0; // SACOM TELENET fdc.s.rreg = 0; } +#if defined(SUPPORT_MOTORRISEUP) setmotor(value); +#endif break; } }