Previous 15994 Revisions Next

r6689 Thursday 17th December, 2009 at 14:44:35 UTC by Dirk Best
[WD17XX] Cleanups
[src/mess/machine]wd17xx.c

src/mess/machine/wd17xx.c
r6688r6689
158158#define STA_1_SEEK_ERR   0x10   /* seek error */
159159#define STA_1_HD_LOADED 0x20   /* head loaded */
160160#define STA_1_WRITE_PRO 0x40   /* floppy is write protected */
161#define STA_1_NOT_READY 0x80   /* controller not ready */
161#define STA_1_NOT_READY 0x80   /* drive not ready */
162#define STA_1_MOTOR_ON   0x80   /* status of the Motor On output (WD1770 and WD1772 only) */
162163
163164/* Type II and III additional flags */
164165#define FDC_DELETED_AM   0x01   /* read/write deleted address mark */
r6688r6689
316317   INT8   direction;            /* last step direction */
317318
318319   UINT8   status_drq;          /* status register data request bit */
319   UINT8   status_ipl;          /* status register toggle index pulse bit */
320320   UINT8   busy_count;          /* how long to keep busy bit set */
321321
322322   UINT8   buffer[6144];         /* I/O buffer (holds up to a whole track) */
r6688r6689
335335   emu_timer   *timer, *timer_rs, *timer_ws, *timer_rid;
336336   int      data_direction;
337337
338   UINT8   ipl;               /* index pulse */
339338   int     hld_count;            /* head loaded counter */
340339
341340   emu_timer *busy_timer;
r6688r6689
807806   if (img != w->drive)
808807      return;
809808
810   w->ipl = state;
809   w->idx = state;
811810
812811   if (w->hld_count)
813812      w->hld_count--;
r6688r6689
12881287READ8_DEVICE_HANDLER( wd17xx_status_r )
12891288{
12901289   wd1770_state *w = get_safe_token(device);
1291   int result = w->status;
1290   int result;
12921291
12931292   wd17xx_clear_intrq(device);
12941293
1294   /* bit 7, 'not ready' or 'motor on' */
1295   if (device->type == WD1770 || device->type == WD1772)
1296   {
1297      w->status &= ~STA_1_MOTOR_ON;
1298      w->status |= w->mo << 7;
1299   }
1300   else
1301   {
1302      w->status &= ~STA_1_NOT_READY;
1303      if (!floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY))
1304         w->status |= STA_1_NOT_READY;
1305   }
1306
1307   result = w->status;
1308
12951309   /* type 1 command or force int command? */
12961310   if ((w->command_type==TYPE_I) || (w->command_type==TYPE_IV))
12971311   {
1298      /* toggle index pulse */
1299      result &= ~STA_1_IPL;
1300      if (w->ipl) result |= STA_1_IPL;
1312      result &= ~(STA_1_IPL | STA_1_TRACK0);
13011313
1302      /* set track 0 state */
1303      result &=~STA_1_TRACK0;
1304      if (floppy_tk00_r(w->drive) == CLEAR_LINE)
1305         result |= STA_1_TRACK0;
1314      /* bit 1, index pulse */
1315      result |= w->idx << 1;
13061316
1307   //  floppy_drive_set_ready_state(w->drive, 1,1);
1308      w->status &= ~STA_1_NOT_READY;
1317      /* bit 2, track 0 state, inverted */
1318      result |= !floppy_tk00_r(w->drive) << 2;
13091319
1310      /* TODO: What is this?  We need some more info on this */
1311      if ((w->type == WD_TYPE_179X) || (w->type == WD_TYPE_1793) || (w->type == WD_TYPE_1773) || (w->type == WD_TYPE_1771))
1312      {
1313         if (!floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY))
1314            w->status |= STA_1_NOT_READY;
1315      }
1316      else
1317      {
1318         if (floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY))
1319            w->status |= STA_1_NOT_READY;
1320      }
1321
13221320      if (w->command_type==TYPE_I)
13231321      {
13241322         if (w->hld_count)
r6688r6689
13261324         else
13271325            w->status &= ~ STA_1_HD_LOADED;
13281326      }
1327
13291328      if (w->command_type==TYPE_IV) result &= 0x63; /* to allow microbee to boot up */
13301329   }
13311330
r6688r6689
14451444{
14461445   wd1770_state *w = get_safe_token(device);
14471446
1448   floppy_mon_w(w->drive, CLEAR_LINE);
1447   /* only the WD1770 and WD1772 have a 'motor on' line */
1448   if (device->type == WD1770 || device->type == WD1772)
1449   {
1450      w->mo = ASSERT_LINE;
1451      floppy_mon_w(w->drive, CLEAR_LINE);
1452   }
1453
14491454   floppy_drive_set_ready_state(w->drive, 1,0);
14501455
14511456   /* also cleared by writing command */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team