Previous 199869 Revisions Next

r18983 Friday 16th November, 2012 at 09:16:15 UTC by O. Galibert
(mess) upd765: Add read fm sector support [O. Galibert]
[src/emu/imagedev]floppy.c floppy.h
[src/lib/formats]imd_dsk.c
[src/mess/drivers]apc.c
[src/mess/machine]upd765.c upd765.h

trunk/src/lib/formats/imd_dsk.c
r18982r18983
475475            int cpos;
476476            UINT16 crc;
477477            // sync and IDAM and gap 2
478            for(int j=0; j< 6; j++) fm_w(track_data, tpos, 8, 0xff);
478            for(int j=0; j< 6; j++) fm_w(track_data, tpos, 8, 0x00);
479479            cpos = tpos;
480            raw_w(track_data, tpos, 8, 0xf57e);
480            raw_w(track_data, tpos, 16, 0xf57e);
481481            fm_w (track_data, tpos, 8, tnum ? tnum[i] : track);
482482            fm_w (track_data, tpos, 8, hnum ? hnum[i] : head);
483483            fm_w (track_data, tpos, 8, snum[i]);
r18982r18983
491491
492492            else {
493493               // sync, DAM, data and gap 3
494               for(int j=0; j< 6; j++) fm_w(track_data, tpos, 8, 0xff);
494               for(int j=0; j< 6; j++) fm_w(track_data, tpos, 8, 0x00);
495495               cpos = tpos;
496               raw_w(track_data, tpos, 8, stype == 3 || stype == 4 || stype == 7 || stype == 8 ? 0xf56a : 0xf56f);
496               raw_w(track_data, tpos, 16, stype == 3 || stype == 4 || stype == 7 || stype == 8 ? 0xf56a : 0xf56f);
497497               if(stype == 2 || stype == 4 || stype == 6 || stype == 8) {
498498                  for(int j=0; j<size; j++) fm_w(track_data, tpos, 8, img[pos]);
499499                  pos++;
trunk/src/emu/imagedev/floppy.c
r18982r18983
2323const device_type FLOPPY_525_QD = &device_creator<floppy_525_qd>;
2424const device_type FLOPPY_525_HD = &device_creator<floppy_525_hd>;
2525const device_type FLOPPY_8_SSSD = &device_creator<floppy_8_sssd>;
26const device_type FLOPPY_8_DSDD = &device_creator<floppy_8_dsdd>;
2627
2728floppy_connector::floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
2829   device_t(mconfig, FLOPPY_CONNECTOR, "Floppy drive connector abstraction", tag, owner, clock),
r18982r18983
174175void floppy_image_device::device_start()
175176{
176177   rpm = 0;
178   motor_always_on = false;
177179   setup_characteristics();
178180
179181   idx = 0;
r18982r18983
194196   revolution_start_time = attotime::never;
195197   revolution_count = 0;
196198   mon = 1;
199   if(motor_always_on)
200      mon_w(0);
197201}
198202
199203void floppy_image_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
r18982r18983
10321036   form_factor = floppy_image::FF_8;
10331037   tracks = 77;
10341038   sides = 1;
1035   set_rpm(300);
1039   motor_always_on = true;
1040   set_rpm(360);
10361041}
10371042
10381043void floppy_8_sssd::handled_variants(UINT32 *variants, int &var_count) const
r18982r18983
10401045   var_count = 0;
10411046   variants[var_count++] = floppy_image::SSSD;
10421047}
1048
1049floppy_8_dsdd::floppy_8_dsdd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
1050   floppy_image_device(mconfig, FLOPPY_8_DSDD, "8\" double density double sided floppy drive", tag, owner, clock)
1051{
1052}
1053
1054floppy_8_dsdd::~floppy_8_dsdd()
1055{
1056}
1057
1058void floppy_8_dsdd::setup_characteristics()
1059{
1060   form_factor = floppy_image::FF_8;
1061   tracks = 77;
1062   sides = 2;
1063   motor_always_on = true;
1064   set_rpm(360);
1065}
1066
1067void floppy_8_dsdd::handled_variants(UINT32 *variants, int &var_count) const
1068{
1069   var_count = 0;
1070   variants[var_count++] = floppy_image::SSSD;
1071   variants[var_count++] = floppy_image::SSDD;
1072   variants[var_count++] = floppy_image::DSDD;
1073}
trunk/src/emu/imagedev/floppy.h
r18982r18983
110110   int tracks; /* addressable tracks */
111111   int sides;  /* number of heads */
112112   UINT32 form_factor; /* 3"5, 5"25, etc */
113   bool motor_always_on;
113114
114115   /* state of input lines */
115116   int dir;  /* direction */
r18982r18983
282283   virtual void setup_characteristics();
283284};
284285
286class floppy_8_dsdd : public floppy_image_device {
287public:
288   floppy_8_dsdd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
289   virtual ~floppy_8_dsdd();
290   virtual void handled_variants(UINT32 *variants, int &var_count) const;
291   virtual void device_config_complete() { m_shortname = "floppy_8_dsdd"; }
292   virtual const char *image_interface() const { return "floppy_8"; }
293protected:
294   virtual void setup_characteristics();
295};
296
285297class floppy_connector: public device_t,
286298                  public device_slot_interface
287299{
r18982r18983
314326extern const device_type FLOPPY_525_QD;
315327extern const device_type FLOPPY_525_HD;
316328extern const device_type FLOPPY_8_SSSD;
329extern const device_type FLOPPY_8_DSDD;
317330
318331#endif /* FLOPPY_H */
trunk/src/mess/machine/upd765.c
r18982r18983
195195bool upd765_family_device::get_ready(int fid)
196196{
197197   if(ready_connected)
198      return flopi[fid].dev ? flopi[fid].dev->ready_r() : false;
198      return flopi[fid].dev ? !flopi[fid].dev->ready_r() : false;
199199   return external_ready;
200200}
201201
r18982r18983
438438void upd765_family_device::fifo_push(UINT8 data, bool internal)
439439{
440440   if(fifo_pos == 16) {
441      if(internal)
441      if(internal) {
442         if(!(st1 & ST1_OR))
443            logerror("%s: Fifo overrun\n", tag());
442444         st1 |= ST1_OR;
445      }
443446      return;
444447   }
445448   fifo[fifo_pos++] = data;
r18982r18983
456459UINT8 upd765_family_device::fifo_pop(bool internal)
457460{
458461   if(!fifo_pos) {
459      if(internal)
462      if(internal) {
463         if(!(st1 & ST1_OR))
464            logerror("%s: Fifo underrun\n", tag());
460465         st1 |= ST1_OR;
466      }
461467      return 0;
462468   }
463469   UINT8 r = fifo[0];
r18982r18983
668674         break;
669675      }
670676
677      case SEARCH_ADDRESS_MARK_HEADER_FM:
678         if(read_one_bit(limit))
679            return;
680#if 0
681         fprintf(stderr, "%s: shift = %04x data=%02x c=%d\n", tts(cur_live.tm).cstr(), cur_live.shift_reg,
682               (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) |
683               (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) |
684               (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) |
685               (cur_live.shift_reg & 0x0100 ? 0x10 : 0x00) |
686               (cur_live.shift_reg & 0x0040 ? 0x08 : 0x00) |
687               (cur_live.shift_reg & 0x0010 ? 0x04 : 0x00) |
688               (cur_live.shift_reg & 0x0004 ? 0x02 : 0x00) |
689               (cur_live.shift_reg & 0x0001 ? 0x01 : 0x00),
690               cur_live.bit_counter);
691#endif
692
693         if(cur_live.shift_reg == 0xf57e) {
694            cur_live.crc = 0xef21;
695            cur_live.data_separator_phase = false;
696            cur_live.bit_counter = 0;
697            cur_live.state = READ_ID_BLOCK;
698         }
699         break;
700
671701      case READ_ID_BLOCK: {
672702         if(read_one_bit(limit))
673703            return;
r18982r18983
757787         cur_live.state = IDLE;
758788         return;
759789
790      case SEARCH_ADDRESS_MARK_DATA_FM:
791         if(read_one_bit(limit))
792            return;
793#if 0
794         fprintf(stderr, "%s: shift = %04x data=%02x c=%d.%x\n", tts(cur_live.tm).cstr(), cur_live.shift_reg,
795               (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) |
796               (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) |
797               (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) |
798               (cur_live.shift_reg & 0x0100 ? 0x10 : 0x00) |
799               (cur_live.shift_reg & 0x0040 ? 0x08 : 0x00) |
800               (cur_live.shift_reg & 0x0010 ? 0x04 : 0x00) |
801               (cur_live.shift_reg & 0x0004 ? 0x02 : 0x00) |
802               (cur_live.shift_reg & 0x0001 ? 0x01 : 0x00),
803               cur_live.bit_counter >> 4, cur_live.bit_counter & 15);
804#endif
805         if(cur_live.bit_counter > 23*16) {
806            live_delay(SEARCH_ADDRESS_MARK_DATA_FAILED);
807            return;
808         }
809
810         if(cur_live.bit_counter >= 11*16 && (cur_live.shift_reg == 0xf56a || cur_live.shift_reg == 0xf56f)) {
811            cur_live.crc = cur_live.shift_reg == 0xf56a ? 0x8fe7 : 0xbf84;
812            cur_live.data_separator_phase = false;
813            cur_live.bit_counter = 0;
814            cur_live.state = READ_SECTOR_DATA;
815         }
816         break;
817
760818      case READ_SECTOR_DATA: {
761819         if(read_one_bit(limit))
762820            return;
r18982r18983
13311389      case SEEK_DONE:
13321390         fi.counter = 0;
13331391         fi.sub_state = SCAN_ID;
1334         live_start(fi, SEARCH_ADDRESS_MARK_HEADER);
1392         live_start(fi, command[0] & 0x40 ? SEARCH_ADDRESS_MARK_HEADER : SEARCH_ADDRESS_MARK_HEADER_FM);
13351393         return;
13361394
13371395      case SCAN_ID:
r18982r18983
13641422         sector_size = calc_sector_size(cur_live.idbuf[3]);
13651423         fifo_expect(sector_size, false);
13661424         fi.sub_state = SECTOR_READ;
1367         live_start(fi, SEARCH_ADDRESS_MARK_DATA);
1425         live_start(fi, command[0] & 0x40 ? SEARCH_ADDRESS_MARK_DATA : SEARCH_ADDRESS_MARK_DATA_FM);
13681426         return;
13691427
13701428      case SCAN_ID_FAILED:
r18982r18983
20192077   //  logerror("write %02x   %04x %04x\n", mfm, cur_live.crc, raw);
20202078}
20212079
2080void upd765_family_device::live_write_fm(UINT8 fm)
2081{
2082   bool context = cur_live.data_bit_context;
2083   UINT16 raw = 0;
2084   for(int i=0; i<8; i++) {
2085      bool bit = fm & (0x80 >> i);
2086      raw |= 0x8000 >> (2*i);
2087      if(bit)
2088         raw |= 0x4000 >> (2*i);
2089      context = bit;
2090   }
2091   cur_live.data_reg = fm;
2092   cur_live.shift_reg = raw;
2093   cur_live.data_bit_context = context;
2094   //  logerror("write %02x   %04x %04x\n", fm, cur_live.crc, raw);
2095}
2096
20222097bool upd765_family_device::sector_matches() const
20232098{
20242099   return
trunk/src/mess/machine/upd765.h
r18982r18983
208208
209209      // Live states
210210      SEARCH_ADDRESS_MARK_HEADER,
211      SEARCH_ADDRESS_MARK_HEADER_FM,
211212      READ_HEADER_BLOCK_HEADER,
212213      READ_DATA_BLOCK_HEADER,
213214      READ_ID_BLOCK,
214215      SEARCH_ADDRESS_MARK_DATA,
216      SEARCH_ADDRESS_MARK_DATA_FM,
215217      SEARCH_ADDRESS_MARK_DATA_FAILED,
216218      READ_SECTOR_DATA,
217219      READ_SECTOR_DATA_BYTE,
r18982r18983
374376   void live_sync();
375377   void live_run(attotime limit = attotime::never);
376378   void live_write_raw(UINT16 raw);
379   void live_write_fm(UINT8 fm);
377380   void live_write_mfm(UINT8 mfm);
378381
379382   bool read_one_bit(attotime limit);
trunk/src/mess/drivers/apc.c
r18982r18983
613613};
614614
615615static SLOT_INTERFACE_START( apc_floppies )
616   SLOT_INTERFACE( "8sd", FLOPPY_8_SSSD ) // TODO: Ok?
616   SLOT_INTERFACE( "8", FLOPPY_8_DSDD )
617617SLOT_INTERFACE_END
618618
619619PALETTE_INIT_MEMBER(apc_state,apc)
r18982r18983
641641   MCFG_I8237_ADD("8237dma", MAIN_CLOCK, dma8237_config)
642642
643643   MCFG_UPD765A_ADD("upd765", true, true)
644   MCFG_FLOPPY_DRIVE_ADD("upd765:0", apc_floppies, "8sd", 0, apc_floppy_formats)
645   MCFG_FLOPPY_DRIVE_ADD("upd765:1", apc_floppies, "8sd", 0, apc_floppy_formats)
644   MCFG_FLOPPY_DRIVE_ADD("upd765:0", apc_floppies, "8", 0, apc_floppy_formats)
645   MCFG_FLOPPY_DRIVE_ADD("upd765:1", apc_floppies, "8", 0, apc_floppy_formats)
646646
647647   /* video hardware */
648648   MCFG_SCREEN_ADD("screen", RASTER)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team