Previous 15994 Revisions Next

r6020 Thursday 8th October, 2009 at 14:19:06 UTC by Dirk Best
[WD17XX] Documentation update and some wip changes
[src/mess/machine]wd17xx.c

src/mess/machine/wd17xx.c
r6019r6020
22
33    wd17xx.c
44
5    Implementations of the Western Digital 17xx and 19xx families of
5    Implementations of the Western Digital 17xx and 27xx families of
66    floppy disk controllers
77
88
9    Models:
10
11              DAL   DD   Side   Clock       Remark
12      ---------------------------------------------------------
13      FD1771                    1 or 2 MHz  First model
14      FD1781         x          1 or 2 MHz
15      FD1791         x          1 or 2 MHz
16      FD1792                    1 or 2 MHz
17      FD1793   x     x          1 or 2 MHz
18      FD1794   x                1 or 2 MHz
19      FD1795         x     x    1 or 2 MHz
20      FD1797   x     x     x    1 or 2 MHz
21      FD1761         x          1 MHz
22      FD1762                    1 MHz       ?
23      FD1763   x     x          1 MHz
24      FD1764   x                1 MHz       ?
25      FD1765         x     x    1 MHz
26      FD1767   x     x     x    1 MHz
27      WD2791         x          1 or 2 MHz  Internal data separator
28      WD2793   x     x          1 or 2 MHz  Internal data separator
29      WD2795         x     x    1 or 2 MHz  Internal data separator
30      WD2797   x     x     x    1 or 2 MHz  Internal data separator
31      WD1770         x          8 MHz       Motor On signal
32      WD1772         x          8 MHz       Motor On signal, Faster stepping rates
33      WD1773         x          8 MHz       Enable precomp line
34
35      Notes: - In general, later models include all features of earlier models
36             - DAL: Data access lines, x = TRUE; otherwise inverted
37             - DD: Double density support
38             - Side: Has side select support
39             - ?: Unknown if it really exists
40
41    Clones:
42
43      - SMC FD179x
44      - Fujitsu MB8876 -> FD1791, MB8877 -> FD1793
45      - VLSI VL177x
46
47
48    Changelog:
49
950    Kevin Thacker
1051        - Removed disk image code and replaced it with floppy drive functions.
1152          Any disc image is now useable with this code.
r6019r6020
239280   devcb_resolved_write_line out_intrq_func;
240281   devcb_resolved_write_line out_drq_func;
241282
242   /* state of input lines */
243   int rdy;      /* ready, enable precomp */
244   int tr00;     /* track 00 */
245   int idx;      /* index */
246   int wprt;     /* write protect */
283   /* input lines */
284   int mr;            /* master reset */
285   int rdy;           /* ready, enable precomp */
286   int tr00;          /* track 00 */
287   int idx;           /* index */
288   int wprt;          /* write protect */
289   int dden;          /* double density */
247290
248   /* state of output lines */
249   int mo;       /* motor on */
250   int dirc;     /* direction */
251   int drq;      /* data request */
252   int intrq;    /* interrupt request */
291   /* output lines */
292   int mo;            /* motor on */
293   int dirc;          /* direction */
294   int drq;           /* data request */
295   int intrq;         /* interrupt request */
253296
297   /* register */
298   UINT8 data_shift;
299   UINT8 data;
300   UINT8 track;
301   UINT8 sector;
302   UINT8 command;
303   UINT8 status;
304
254305   int stepping_rate[4];  /* track stepping rate in ms */
255306
307
256308   DENSITY   density;            /* FM/MFM, single / double density */
257309   wd17xx_type_t type;
258310   UINT8   track_reg;            /* value of track register */
259   UINT8   data;               /* value of data register */
260   UINT8   command;            /* last command written */
261311   UINT8   command_type;         /* last command type */
262   UINT8   sector;             /* current sector # */
263312   UINT8   head;               /* current head # */
264313
265314   UINT8   read_cmd;            /* last read command issued */
266315   UINT8   write_cmd;            /* last write command issued */
267316   INT8   direction;            /* last step direction */
268317
269   UINT8   status;             /* status register */
270318   UINT8   status_drq;          /* status register data request bit */
271319   UINT8   status_ipl;          /* status register toggle index pulse bit */
272320   UINT8   busy_count;          /* how long to keep busy bit set */
r6019r6020
465513
466514/* BUSY COUNT DOESN'T WORK PROPERLY! */
467515
468static void wd17xx_restore(const device_config *device)
516static void wd17xx_command_restore(const device_config *device)
469517{
470518   wd1770_state *w = get_safe_token(device);
471519   UINT8 step_counter;
r6019r6020
500548   }
501549
502550   /* update track reg */
503   w->track_reg = 0;
551   w->track = 0;
504552#if 0
505553   /* simulate seek time busy signal */
506554   w->busy_count = 0;   //w->busy_count * ((w->data & FDC_STEP_RATE) + 1);
r6019r6020
724772   {
725773      /* record not found */
726774      w->status |= STA_2_REC_N_FND;
727      //w->sector = w->track_reg;
775      //w->sector = w->track;
728776      if (VERBOSE)
729777         logerror("read id failed\n");
730778
r6019r6020
764812      if (floppy_drive_get_next_id(w->drive, w->hd, &id))
765813      {
766814         /* compare track */
767         if (id.C == w->track_reg)
815         if (id.C == w->track)
768816         {
769817            /* compare head, if we were asked to */
770818            if (!wd17xx_has_side_select(device) || (id.H == w->head) || (w->head == (UINT8) ~0))
r6019r6020
808856   w->status |= STA_2_REC_N_FND;
809857
810858   if (VERBOSE)
811      logerror("track %d sector %d not found!\n", w->track_reg, w->sector);
859      logerror("track %d sector %d not found!\n", w->track, w->sector);
812860
813861   wd17xx_complete_command(device, DELAY_ERROR);
814862
r6019r6020
949997      if (floppy_drive_get_next_id(w->drive, w->hd, &id))
950998      {
951999         /* compare track */
952         if (id.C == w->track_reg)
1000         if (id.C == w->track)
9531001         {
9541002            if (VERBOSE)
9551003               logerror("seek verify succeeded!\n");
r6019r6020
11411189    DEVICE HANDLERS
11421190***************************************************************************/
11431191
1192/* master reset */
1193WRITE_LINE_DEVICE_HANDLER( wd17xx_mr_w )
1194{
1195   wd1770_state *w = get_safe_token(device);
1196
1197   /* reset device when going from high to low */
1198   if (w->mr && state == CLEAR_LINE)
1199   {
1200      w->command = 0x03;
1201      w->status &= ~STA_1_NOT_READY; /* ? */
1202   }
1203
1204   /* execute restore command when going from low to high */
1205   if (w->mr == CLEAR_LINE && state)
1206   {
1207      wd17xx_command_restore(device);
1208      w->sector = 0x01;
1209   }
1210
1211   w->mr = state;
1212}
1213
1214/* ready and enable precomp (1773 only) */
11441215WRITE_LINE_DEVICE_HANDLER( wd17xx_rdy_w )
11451216{
11461217   wd1770_state *w = get_safe_token(device);
11471218   w->rdy = state;
11481219}
11491220
1221/* motor on, 1770 and 1772 only */
11501222READ_LINE_DEVICE_HANDLER( wd17xx_mo_r )
11511223{
11521224   wd1770_state *w = get_safe_token(device);
11531225   return w->mo;
11541226}
11551227
1228/* track zero */
11561229WRITE_LINE_DEVICE_HANDLER( wd17xx_tr00_w )
11571230{
11581231   wd1770_state *w = get_safe_token(device);
11591232   w->tr00 = state;
11601233}
11611234
1235/* index pulse */
11621236WRITE_LINE_DEVICE_HANDLER( wd17xx_idx_w )
11631237{
11641238   wd1770_state *w = get_safe_token(device);
11651239   w->idx = state;
11661240}
11671241
1242/* write protect status */
11681243WRITE_LINE_DEVICE_HANDLER( wd17xx_wprt_w )
11691244{
11701245   wd1770_state *w = get_safe_token(device);
11711246   w->wprt = state;
11721247}
11731248
1249/* data request */
11741250READ_LINE_DEVICE_HANDLER( wd17xx_drq_r )
11751251{
11761252   wd1770_state *w = get_safe_token(device);
11771253   return w->drq;
11781254}
11791255
1256/* interrupt request */
11801257READ_LINE_DEVICE_HANDLER( wd17xx_intrq_r )
11811258{
11821259   wd1770_state *w = get_safe_token(device);
r6019r6020
12461323   wd1770_state *w = get_safe_token(device);
12471324
12481325   if (VERBOSE)
1249      logerror("wd17xx_track_r: $%02X\n", w->track_reg);
1326      logerror("wd17xx_track_r: $%02X\n", w->track);
12501327
1251   return w->track_reg;
1328   return w->track;
12521329}
12531330
12541331/* read the FDC sector register */
r6019r6020
15091586      if (VERBOSE)
15101587         logerror("wd17xx_command_w $%02X RESTORE\n", data);
15111588
1512      wd17xx_restore(device);
1589      wd17xx_command_restore(device);
15131590   }
15141591
15151592   if ((data & ~FDC_MASK_TYPE_I) == FDC_SEEK)
r6019r6020
15171594      UINT8 newtrack;
15181595
15191596      if (VERBOSE)
1520         logerror("old track: $%02x new track: $%02x\n", w->track_reg, w->data);
1597         logerror("old track: $%02x new track: $%02x\n", w->track, w->data);
15211598      w->command_type = TYPE_I;
15221599
15231600      /* setup step direction */
1524      if (w->track_reg < w->data)
1601      if (w->track < w->data)
15251602      {
15261603         if (VERBOSE)
15271604            logerror("direction: +1\n");
15281605
15291606         w->direction = 1;
15301607      }
1531      else if (w->track_reg > w->data)
1608      else if (w->track > w->data)
15321609      {
15331610         if (VERBOSE)
15341611            logerror("direction: -1\n");
r6019r6020
15441621      w->busy_count = 0;
15451622
15461623      /* keep stepping until reached track programmed */
1547      while (w->track_reg != newtrack)
1624      while (w->track != newtrack)
15481625      {
15491626         /* update time to simulate seek time busy signal */
15501627         w->busy_count++;
15511628
15521629         /* update track reg */
1553         w->track_reg += w->direction;
1630         w->track += w->direction;
15541631
15551632         floppy_drive_seek(w->drive, w->direction);
15561633      }
r6019r6020
15771654      floppy_drive_seek(w->drive, w->direction);
15781655
15791656      if (data & FDC_STEP_UPDATE)
1580         w->track_reg += w->direction;
1657         w->track += w->direction;
15811658
15821659#if 0
15831660      wd17xx_set_intrq(device);
r6019r6020
16001677      floppy_drive_seek(w->drive, w->direction);
16011678
16021679      if (data & FDC_STEP_UPDATE)
1603         w->track_reg += w->direction;
1680         w->track += w->direction;
16041681#if 0
16051682      wd17xx_set_intrq(device);
16061683#endif
r6019r6020
16221699      floppy_drive_seek(w->drive, w->direction);
16231700
16241701      if (data & FDC_STEP_UPDATE)
1625         w->track_reg += w->direction;
1702         w->track += w->direction;
16261703
16271704#if 0
16281705      wd17xx_set_intrq(device);
r6019r6020
16541731{
16551732   wd1770_state *w = get_safe_token(device);
16561733
1657   w->track_reg = data;
1734   w->track = data;
16581735
16591736   if (VERBOSE)
16601737      logerror("wd17xx_track_w $%02X\n", data);
r6019r6020
17641841   /* model specific values */
17651842   w->type = WD_TYPE_1770;
17661843
1844   /* stepping rate depends on the clock */
17671845   w->stepping_rate[0] = 6;
17681846   w->stepping_rate[1] = 12;
17691847   w->stepping_rate[2] = 20;
r6019r6020
17871865
17881866   w->type = WD_TYPE_1772;
17891867
1868   /* the 1772 has faster track stepping rates */
17901869   w->stepping_rate[0] = 6;
17911870   w->stepping_rate[1] = 12;
1792   w->stepping_rate[2] = 20;
1793   w->stepping_rate[3] = 30;
1871   w->stepping_rate[2] = 2;
1872   w->stepping_rate[3] = 3;
17941873}
17951874
17961875static DEVICE_START( wd1773 )
r6019r6020
18001879   DEVICE_START_CALL(wd1770);
18011880
18021881   w->type = WD_TYPE_1773;
1803
1804   w->stepping_rate[0] = 6;
1805   w->stepping_rate[1] = 12;
1806   w->stepping_rate[2] = 2;
1807   w->stepping_rate[3] = 3;
18081882}
18091883
18101884static DEVICE_START( wd179x )
r6019r6020
18571931   wd1770_state *w = get_safe_token(device);
18581932   int i;
18591933
1934   /* set the default state of some input lines */
1935   w->mr = ASSERT_LINE;
1936   w->wprt = ASSERT_LINE;
1937   w->dden = ASSERT_LINE;
1938
18601939   for (i = 0; i < 4; i++)
18611940   {
18621941      if(w->intf->floppy_drive_tags[i]!=NULL) {
r6019r6020
18741953   w->hd = 0;
18751954   w->hld_count = 0;
18761955
1877   wd17xx_restore(device);
1956   wd17xx_command_restore(device);
18781957}
18791958
18801959void wd17xx_reset(const device_config *device)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team