Previous 199869 Revisions Next

r19402 Saturday 8th December, 2012 at 10:05:46 UTC by O. Galibert
wd_fdc: Fix sector sizes and (most) timings [O. Galibert]

Still need to fix up the timings w.r.t head loading and settling time.
[src/emu/machine]wd_fdc.c wd_fdc.h

trunk/src/emu/machine/wd_fdc.c
r19401r19402
263263            track += last_dir ? -1 : 1;
264264         counter++;
265265         sub_state = SEEK_WAIT_STEP_TIME;
266         delay_cycles(t_gen, step_time(command & 3));
266         delay_cycles(t_gen, step_times[command & 3]);
267267         return;
268268
269269      case SEEK_WAIT_STEP_TIME:
r19401r19402
429429            live_start(SEARCH_ADDRESS_MARK_HEADER);
430430            return;
431431         }
432         // TODO WD2795/7 alternate sector size
433         sector_size = 128 << (cur_live.idbuf[3] & 3);
432         sector_size = calc_sector_size(cur_live.idbuf[3], command);
434433         sub_state = SECTOR_READ;
435434         live_start(SEARCH_ADDRESS_MARK_DATA);
436435         return;
r19401r19402
747746            live_start(SEARCH_ADDRESS_MARK_HEADER);
748747            return;
749748         }
750         // TODO WD2795/7 alternate sector size
751         sector_size = 128 << (cur_live.idbuf[3] & 3);
749         sector_size = calc_sector_size(cur_live.idbuf[3], command);
752750         sub_state = SECTOR_WRITE;
753751         live_start(WRITE_SECTOR_PRE);
754752         return;
r19401r19402
911909
912910   cmd_buffer = val;
913911
914   delay_cycles(t_cmd, dden ? 1 : 1);
912   delay_cycles(t_cmd, dden ? delay_command_commit*2 : delay_command_commit);
915913}
916914
917915UINT8 wd_fdc_t::status_r()
r19401r19402
972970      return;
973971
974972   track_buffer = val;
975   delay_cycles(t_track, dden ? 32 : 16);
973   delay_cycles(t_track, dden ? delay_register_commit*2 : delay_register_commit);
976974}
977975
978976UINT8 wd_fdc_t::track_r()
r19401r19402
998996      return;
999997
1000998   sector_buffer = val;
1001   delay_cycles(t_sector, dden ? 32 : 16);
999   delay_cycles(t_sector, dden ? delay_register_commit*2 : delay_register_commit);
10021000}
10031001
10041002UINT8 wd_fdc_t::sector_r()
r19401r19402
19011899   }
19021900}
19031901
1904int wd_fdc_t::step_time(int mode) const
1902int wd_fdc_t::calc_sector_size(UINT8 size, UINT8 command) const
19051903{
1906   const static int step_times[4] = { 12000, 24000, 40000, 60000 };
1907   return step_times[mode]/10;
1904   return 128 << (size & 3);
19081905}
19091906
19101907int wd_fdc_t::settle_time() const
r19401r19402
19651962   clock_ratio = 4;
19661963}
19671964
1965const int wd_fdc_digital_t::wd_digital_step_times[4] = { 12000, 24000, 40000, 60000 };
1966
19681967void wd_fdc_digital_t::pll_reset(bool fm, attotime when)
19691968{
19701969   cur_pll.reset(when);
r19401r19402
21632162
21642163fd1771_t::fd1771_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1771x, "FD1771", tag, owner, clock)
21652164{
2165   const static int fd1771_step_times[4] = { 12000, 12000, 20000, 40000 };
2166
2167   step_times = fd1771_step_times;
2168   delay_register_commit = 16;
2169   delay_command_commit = 20; // x2 due to fm
21662170   disable_mfm = true;
21672171   inverted_bus = true;
21682172   side_control = false;
r19401r19402
21722176   ready_hooked = true;
21732177}
21742178
2179int fd1771_t::calc_sector_size(UINT8 size, UINT8 command) const
2180{
2181   if(command & 0x08)
2182      return 128 << (size & 3);
2183   else
2184      return size ? size << 4 : 4096;
2185}
2186
21752187fd1781_t::fd1781_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1781x, "FD1781", tag, owner, clock)
21762188{
2189   const static int fd1781_step_times[4] = { 6000, 12000, 20000, 40000 };
2190
2191   step_times = fd1781_step_times;
2192   delay_register_commit = 16;
2193   delay_command_commit = 12;
21772194   disable_mfm = false;
21782195   inverted_bus = true;
21792196   side_control = false;
r19401r19402
21832200   ready_hooked = true;
21842201}
21852202
2203int fd1781_t::calc_sector_size(UINT8 size, UINT8 command) const
2204{
2205   if(command & 0x08)
2206      return 128 << (size & 3);
2207   else
2208      return size ? size << 4 : 4096;
2209}
2210
2211const int wd_fdc_t::fd179x_step_times[4] = {  6000, 12000, 20000, 30000 };
2212const int wd_fdc_t::fd176x_step_times[4] = { 12000, 24000, 40000, 60000 };
2213
21862214fd1791_t::fd1791_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1791x, "FD1791", tag, owner, clock)
21872215{
2216   step_times = fd179x_step_times;
2217   delay_register_commit = 16;
2218   delay_command_commit = 12;
21882219   disable_mfm = false;
21892220   inverted_bus = true;
21902221   side_control = false;
r19401r19402
21962227
21972228fd1792_t::fd1792_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1792x, "FD1792", tag, owner, clock)
21982229{
2230   step_times = fd179x_step_times;
2231   delay_register_commit = 16;
2232   delay_command_commit = 12;
21992233   disable_mfm = true;
22002234   inverted_bus = true;
22012235   side_control = false;
r19401r19402
22072241
22082242fd1793_t::fd1793_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1793x, "FD1793", tag, owner, clock)
22092243{
2244   step_times = fd179x_step_times;
2245   delay_register_commit = 16;
2246   delay_command_commit = 12;
22102247   disable_mfm = false;
22112248   inverted_bus = false;
22122249   side_control = false;
r19401r19402
22182255
22192256fd1794_t::fd1794_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1794x, "FD1794", tag, owner, clock)
22202257{
2258   step_times = fd179x_step_times;
2259   delay_register_commit = 16;
2260   delay_command_commit = 12;
22212261   disable_mfm = true;
22222262   inverted_bus = false;
22232263   side_control = false;
r19401r19402
22292269
22302270fd1795_t::fd1795_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1795x, "FD1795", tag, owner, clock)
22312271{
2272   step_times = fd179x_step_times;
2273   delay_register_commit = 16;
2274   delay_command_commit = 12;
22322275   disable_mfm = false;
22332276   inverted_bus = true;
22342277   side_control = true;
r19401r19402
22382281   ready_hooked = true;
22392282}
22402283
2284int fd1795_t::calc_sector_size(UINT8 size, UINT8 command) const
2285{
2286   if(command & 0x08)
2287      return 128 << (size & 3);
2288   else
2289      return 128 << ((size + 1) & 3);
2290}
2291
22412292fd1797_t::fd1797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1797x, "FD1797", tag, owner, clock)
22422293{
2294   step_times = fd179x_step_times;
2295   delay_register_commit = 16;
2296   delay_command_commit = 12;
22432297   disable_mfm = false;
22442298   inverted_bus = false;
22452299   side_control = true;
r19401r19402
22492303   ready_hooked = true;
22502304}
22512305
2306int fd1797_t::calc_sector_size(UINT8 size, UINT8 command) const
2307{
2308   if(command & 0x08)
2309      return 128 << (size & 3);
2310   else
2311      return 128 << ((size + 1) & 3);
2312}
2313
22522314mb8866_t::mb8866_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, MB8866x, "MB8866", tag, owner, clock)
22532315{
2316   step_times = fd179x_step_times;
2317   delay_register_commit = 16;
2318   delay_command_commit = 12;
22542319   disable_mfm = false;
22552320   inverted_bus = true;
22562321   side_control = false;
r19401r19402
22622327
22632328mb8876_t::mb8876_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, MB8876x, "MB8876", tag, owner, clock)
22642329{
2330   step_times = fd179x_step_times;
2331   delay_register_commit = 16;
2332   delay_command_commit = 12;
22652333   disable_mfm = false;
22662334   inverted_bus = true;
22672335   side_control = false;
r19401r19402
22732341
22742342mb8877_t::mb8877_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, MB8877x, "MB8877", tag, owner, clock)
22752343{
2344   step_times = fd179x_step_times;
2345   delay_register_commit = 16;
2346   delay_command_commit = 12;
22762347   disable_mfm = false;
22772348   inverted_bus = false;
22782349   side_control = false;
r19401r19402
22842355
22852356fd1761_t::fd1761_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1761x, "FD1761", tag, owner, clock)
22862357{
2358   step_times = fd176x_step_times;
2359   delay_register_commit = 16;
2360   delay_command_commit = 12;
22872361   disable_mfm = false;
22882362   inverted_bus = true;
22892363   side_control = false;
r19401r19402
22952369
22962370fd1763_t::fd1763_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1763x, "FD1763", tag, owner, clock)
22972371{
2372   step_times = fd176x_step_times;
2373   delay_register_commit = 16;
2374   delay_command_commit = 12;
22982375   disable_mfm = false;
22992376   inverted_bus = false;
23002377   side_control = false;
r19401r19402
23062383
23072384fd1765_t::fd1765_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1765x, "FD1765", tag, owner, clock)
23082385{
2386   step_times = fd176x_step_times;
2387   delay_register_commit = 16;
2388   delay_command_commit = 12;
23092389   disable_mfm = false;
23102390   inverted_bus = true;
23112391   side_control = true;
r19401r19402
23152395   ready_hooked = true;
23162396}
23172397
2398int fd1765_t::calc_sector_size(UINT8 size, UINT8 command) const
2399{
2400   if(command & 0x08)
2401      return 128 << (size & 3);
2402   else
2403      return 128 << ((size + 1) & 3);
2404}
2405
23182406fd1767_t::fd1767_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, FD1767x, "FD1767", tag, owner, clock)
23192407{
2408   step_times = fd179x_step_times;
2409   delay_register_commit = 16;
2410   delay_command_commit = 12;
23202411   disable_mfm = false;
23212412   inverted_bus = false;
23222413   side_control = true;
r19401r19402
23262417   ready_hooked = true;
23272418}
23282419
2420int fd1767_t::calc_sector_size(UINT8 size, UINT8 command) const
2421{
2422   if(command & 0x08)
2423      return 128 << (size & 3);
2424   else
2425      return 128 << ((size + 1) & 3);
2426}
2427
23292428wd2791_t::wd2791_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, WD2791x, "WD2791", tag, owner, clock)
23302429{
2430   step_times = fd179x_step_times;
2431   delay_register_commit = 16;
2432   delay_command_commit = 12;
23312433   disable_mfm = false;
23322434   inverted_bus = true;
23332435   side_control = false;
r19401r19402
23392441
23402442wd2793_t::wd2793_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, WD2793x, "WD2793", tag, owner, clock)
23412443{
2444   step_times = fd179x_step_times;
2445   delay_register_commit = 16;
2446   delay_command_commit = 12;
23422447   disable_mfm = false;
23432448   inverted_bus = false;
23442449   side_control = false;
r19401r19402
23502455
23512456wd2795_t::wd2795_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, WD2795x, "WD2795", tag, owner, clock)
23522457{
2458   step_times = fd179x_step_times;
2459   delay_register_commit = 16;
2460   delay_command_commit = 12;
23532461   disable_mfm = false;
23542462   inverted_bus = true;
23552463   side_control = true;
r19401r19402
23592467   ready_hooked = true;
23602468}
23612469
2470int wd2795_t::calc_sector_size(UINT8 size, UINT8 command) const
2471{
2472   if(command & 0x08)
2473      return 128 << (size & 3);
2474   else
2475      return 128 << ((size + 1) & 3);
2476}
2477
23622478wd2797_t::wd2797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_analog_t(mconfig, WD2797x, "WD2797", tag, owner, clock)
23632479{
2480   step_times = fd179x_step_times;
2481   delay_register_commit = 16;
2482   delay_command_commit = 12;
23642483   disable_mfm = false;
23652484   inverted_bus = false;
23662485   side_control = true;
r19401r19402
23702489   ready_hooked = true;
23712490}
23722491
2492int wd2797_t::calc_sector_size(UINT8 size, UINT8 command) const
2493{
2494   if(command & 0x08)
2495      return 128 << (size & 3);
2496   else
2497      return 128 << ((size + 1) & 3);
2498}
2499
23732500wd1770_t::wd1770_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_digital_t(mconfig, WD1770x, "WD1770", tag, owner, clock)
23742501{
2502   step_times = wd_digital_step_times;
2503   delay_register_commit = 32;
2504   delay_command_commit = 48;
23752505   disable_mfm = false;
23762506   inverted_bus = false;
23772507   side_control = false;
r19401r19402
23832513
23842514wd1772_t::wd1772_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_digital_t(mconfig, WD1772x, "WD1772", tag, owner, clock)
23852515{
2516   const static int wd1772_step_times[4] = { 12000, 24000, 4000, 6000 };
2517
2518   step_times = wd1772_step_times;
2519   delay_register_commit = 32;
2520   delay_command_commit = 48;
23862521   disable_mfm = false;
23872522   inverted_bus = false;
23882523   side_control = false;
r19401r19402
23922527   ready_hooked = false;
23932528}
23942529
2395int wd1772_t::step_time(int mode) const
2396{
2397   const static int step_times[4] = { 12000, 24000, 4000, 6000 };
2398   return step_times[mode];
2399}
2400
24012530int wd1772_t::settle_time() const
24022531{
24032532   return 30000;
r19401r19402
24052534
24062535wd1773_t::wd1773_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_digital_t(mconfig, WD1773x, "WD1773", tag, owner, clock)
24072536{
2537   step_times = wd_digital_step_times;
2538   delay_register_commit = 32;
2539   delay_command_commit = 48;
24082540   disable_mfm = false;
24092541   inverted_bus = false;
24102542   side_control = false;
trunk/src/emu/machine/wd_fdc.h
r19401r19402
164164   bool motor_control;
165165   bool ready_hooked;
166166   int clock_ratio;
167   const int *step_times;
168   int delay_register_commit;
169   int delay_command_commit;
167170
171   static const int fd179x_step_times[4];
172   static const int fd176x_step_times[4];
173
168174   virtual void device_start();
169175   virtual void device_reset();
170176   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
171177
172   virtual int step_time(int mode) const;
178   virtual int calc_sector_size(UINT8 size, UINT8 command) const;
173179   virtual int settle_time() const;
174180
175181   virtual void pll_reset(bool fm, attotime when) = 0;
r19401r19402
429435   wd_fdc_digital_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
430436
431437protected:
438   static const int wd_digital_step_times[4];
439
432440   virtual void pll_reset(bool fm, attotime when);
433441   virtual void pll_start_writing(attotime tm);
434442   virtual void pll_commit(floppy_image_device *floppy, attotime tm);
r19401r19402
469477class fd1771_t : public wd_fdc_analog_t {
470478public:
471479   fd1771_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
480
481protected:
482   virtual int calc_sector_size(UINT8 size, UINT8 command) const;
472483};
473484
474485class fd1781_t : public wd_fdc_analog_t {
475486public:
476487   fd1781_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
488
489protected:
490   virtual int calc_sector_size(UINT8 size, UINT8 command) const;
477491};
478492
479493class fd1791_t : public wd_fdc_analog_t {
r19401r19402
499513class fd1795_t : public wd_fdc_analog_t {
500514public:
501515   fd1795_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
516
517protected:
518   virtual int calc_sector_size(UINT8 size, UINT8 command) const;
502519};
503520
504521class fd1797_t : public wd_fdc_analog_t {
505522public:
506523   fd1797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
524
525protected:
526   virtual int calc_sector_size(UINT8 size, UINT8 command) const;
507527};
508528
509529class mb8866_t : public wd_fdc_analog_t {
r19401r19402
534554class fd1765_t : public wd_fdc_analog_t {
535555public:
536556   fd1765_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
557
558protected:
559   virtual int calc_sector_size(UINT8 size, UINT8 command) const;
537560};
538561
539562class fd1767_t : public wd_fdc_analog_t {
540563public:
541564   fd1767_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
565
566protected:
567   virtual int calc_sector_size(UINT8 size, UINT8 command) const;
542568};
543569
544570class wd2791_t : public wd_fdc_analog_t {
r19401r19402
554580class wd2795_t : public wd_fdc_analog_t {
555581public:
556582   wd2795_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
583
584protected:
585   virtual int calc_sector_size(UINT8 size, UINT8 command) const;
557586};
558587
559588class wd2797_t : public wd_fdc_analog_t {
560589public:
561590   wd2797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
591
592protected:
593   virtual int calc_sector_size(UINT8 size, UINT8 command) const;
562594};
563595
564596class wd1770_t : public wd_fdc_digital_t {
r19401r19402
571603   wd1772_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
572604
573605protected:
574   virtual int step_time(int mode) const;
575606   virtual int settle_time() const;
576607};
577608

Previous 199869 Revisions Next


© 1997-2024 The MAME Team