Previous 15994 Revisions Next

r5850 Tuesday 22nd September, 2009 at 14:49:07 UTC by Miodrag Milanović
Some floppy code cleanup, removed not needed settings and moved routines to proper place
[src/mess/devices]flopdrv.c flopdrv.h
[src/mess/drivers]amstrad.c enterp.c exidy.c pcw.c sord.c specpls3.c
[src/mess/includes]exidy.h
[src/mess/machine]amstrad.c exidy.c pc_fdc.c wd17xx.c wd17xx.h

src/mess/includes/exidy.h
r5849r5850
1919WRITE8_HANDLER(exidy_fd_w);
2020WRITE8_HANDLER(exidy_fe_w);
2121WRITE8_HANDLER(exidy_ff_w);
22MACHINE_START( exidyd );
2322MACHINE_START( exidy );
24MACHINE_RESET( exidyd );
2523MACHINE_RESET( exidy );
2624Z80BIN_EXECUTE( exidy );
2725
src/mess/machine/amstrad.c
r5849r5850
32613261   else
32623262      cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), 0, 0x00);
32633263
3264   if(amstrad_system_type != SYSTEM_GX4000)
3265   {
3266      floppy_drive_set_geometry(floppy_get_device(machine, 0),  FLOPPY_DRIVE_SS_40);
3267      floppy_drive_set_geometry(floppy_get_device(machine, 1),  FLOPPY_DRIVE_SS_40);
3268   }
3269
32703264   /* The opcode timing in the Amstrad is different to the opcode
32713265    timing in the core for the Z80 CPU.
32723266
r5849r5850
34383432   Amstrad_ROM_Table[7] = &rom[0x018000];  // AMSDOS
34393433   amstrad_common_init(machine);
34403434   amstrad_reset_machine(machine);
3441
3442   floppy_drive_set_geometry(floppy_get_device(machine, 0),  FLOPPY_DRIVE_DS_80);
3443   floppy_drive_set_geometry(floppy_get_device(machine, 1),  FLOPPY_DRIVE_DS_80);
34443435}
34453436
34463437
src/mess/machine/wd17xx.c
r5849r5850
866866   timer_reset(w->timer, attotime_never);
867867}
868868
869int wd17xx_get_datarate_in_us(DENSITY density)
870{
871   int usecs;
872   /* 64 for single density */
873   switch (density)
874   {
875      case DEN_FM_LO:
876      {
877         usecs = 128;
878      }
879      break;
869880
881      case DEN_FM_HI:
882      {
883         usecs = 64;
884      }
885      break;
870886
887      default:
888      case DEN_MFM_LO:
889      {
890         usecs = 32;
891      }
892      break;
893
894      case DEN_MFM_HI:
895      {
896         usecs = 16;
897      }
898      break;
899   }
900
901   return usecs;
902}
903
871904/* called on error, or when command is actually completed */
872905/* KT - I have used a timer for systems that use interrupt driven transfers.
873906A interrupt occurs after the last byte has been read. If it occurs at the time
r5849r5850
890923   /* Robbbert - adjusted delay value (see notes above) to fix the osborne1 */
891924   w->status &= ~STA_2_BUSY;
892925
893   usecs = floppy_drive_get_datarate_in_us(w->density);
926   usecs = wd17xx_get_datarate_in_us(w->density);
894927   usecs *= delay;
895928#endif
896929
r5849r5850
10831116   int usecs;
10841117   wd17xx_t *w = get_safe_token(device);
10851118
1086   usecs = floppy_drive_get_datarate_in_us(w->density);
1119   usecs = wd17xx_get_datarate_in_us(w->density);
10871120
10881121   /* set new timer */
10891122   timer_adjust_oneshot(w->timer, ATTOTIME_IN_USEC(usecs), MISCCALLBACK_DATA);
src/mess/machine/wd17xx.h
r5849r5850
3838   WD17XX_DRQ_SET
3939} wd17xx_state_t;
4040
41typedef enum
42{
43   DEN_FM_LO = 0,
44   DEN_FM_HI,
45   DEN_MFM_LO,
46   DEN_MFM_HI
47} DENSITY;
4148
4249typedef void (*wd17xx_callback_func)(const device_config *device, wd17xx_state_t state, void *param);
4350#define WD17XX_CALLBACK(name)   void name(const device_config *device, wd17xx_state_t state, void *param )
src/mess/machine/exidy.c
r5849r5850
390390   }
391391}
392392
393MACHINE_START( exidyd )
393MACHINE_START( exidy )
394394{
395395//   serial_timer = timer_alloc(machine, exidy_serial_timer_callback, NULL);
396396   cassette_timer = timer_alloc(machine, exidy_cassette_tc, NULL);
397397}
398398
399MACHINE_START( exidy )
399MACHINE_RESET( exidy )
400400{
401   MACHINE_START_CALL( exidyd );
402}
403
404MACHINE_RESET( exidyd )
405{
406401   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
407402
408403   /* Initialize cassette interface */
r5849r5850
418413   timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, exidy_reset);
419414   memory_set_bank(machine, 1, 1);
420415}
421
422MACHINE_RESET( exidy )
423{
424   floppy_drive_set_geometry(floppy_get_device(machine, 0), FLOPPY_DRIVE_DS_80);
425   MACHINE_RESET_CALL( exidyd );
426}
src/mess/machine/pc_fdc.c
r5849r5850
112112
113113void pc_fdc_init(running_machine *machine, const struct pc_fdc_interface *iface)
114114{
115   int i;
116   const device_config *img;
117
118115   /* initialize fdc structure */
119116   fdc = auto_alloc_clear(machine, struct pc_fdc);
120117
r5849r5850
122119   if (iface)
123120      memcpy(&fdc->fdc_interface, iface, sizeof(fdc->fdc_interface));
124121
125   /* setup nec765 interface */
126   //nec765_init(machine, &pc_fdc_nec765_interface, iface->nec765_type, iface->nec765_rdy_pin);
127
128122   fdc->watchdog = timer_alloc(machine,  watchdog_timeout, NULL );
129123
130124   pc_fdc_reset(machine);
131
132   for (i = 0; i < 4; i++)
133   {
134      img = floppy_get_device(machine, i);
135      if (img) {
136         floppy_drive_set_geometry(img, FLOPPY_DRIVE_DS_80);
137      }
138   }
139125}
140126
141127
src/mess/devices/flopdrv.c
r5849r5850
214214   image_fsize_thunk
215215};
216216
217void floppy_drive_set_geometry_absolute(const device_config *img, int tracks, int sides)
218{
219   floppy_drive *pDrive = get_safe_token( img );
220   pDrive->max_track = tracks;
221   pDrive->num_sides = sides;
222}
217223
224void floppy_drive_set_geometry(const device_config *img, floppy_type type)
225{
226   int max_track, num_sides;
227
228   switch (type) {
229   case FLOPPY_DRIVE_SS_40:   /* single sided, 40 track drive e.g. Amstrad CPC internal 3" drive */
230      max_track = 42;
231      num_sides = 1;
232      break;
233
234   case FLOPPY_DRIVE_DS_80:
235      max_track = 83;
236      num_sides = 2;
237      break;
238
239   default:
240      assert(0);
241      return;
242   }
243   floppy_drive_set_geometry_absolute(img, max_track, num_sides);
244}
245
218246static TIMER_CALLBACK(floppy_drive_index_callback);
219247
220248/* this is called on device init */
r5849r5850
229257   pDrive->index_timer = timer_alloc(img->machine, floppy_drive_index_callback, (void *) img);
230258   pDrive->index = 0;
231259
232   /* all drives are double-sided 80 track - can be overriden in driver! */
233   floppy_drive_set_geometry(img, FLOPPY_DRIVE_DS_80);
260   floppy_drive_set_geometry(img, ((floppy_config*)img->static_config)->floppy_type);
234261
235262   /* initialise id index - not so important */
236263   pDrive->id_index = 0;
r5849r5850
460487}
461488
462489
463void floppy_drive_set_geometry(const device_config *img, floppy_type type)
464{
465   int max_track, num_sides;
466
467   switch (type) {
468   case FLOPPY_DRIVE_SS_40:   /* single sided, 40 track drive e.g. Amstrad CPC internal 3" drive */
469      max_track = 42;
470      num_sides = 1;
471      break;
472
473   case FLOPPY_DRIVE_DS_80:
474      max_track = 83;
475      num_sides = 2;
476      break;
477
478   default:
479      assert(0);
480      return;
481   }
482   floppy_drive_set_geometry_absolute(img, max_track, num_sides);
483}
484
485490void floppy_drive_seek(const device_config *img, signed int signed_tracks)
486491{
487492   floppy_drive *pDrive;
r5849r5850
623628   }
624629}
625630
626int floppy_drive_get_datarate_in_us(DENSITY density)
627{
628   int usecs;
629   /* 64 for single density */
630   switch (density)
631   {
632      case DEN_FM_LO:
633      {
634         usecs = 128;
635      }
636      break;
637
638      case DEN_FM_HI:
639      {
640         usecs = 64;
641      }
642      break;
643
644      default:
645      case DEN_MFM_LO:
646      {
647         usecs = 32;
648      }
649      break;
650
651      case DEN_MFM_HI:
652      {
653         usecs = 16;
654      }
655      break;
656   }
657
658   return usecs;
659}
660
661631void floppy_install_load_proc(const device_config *image, void (*proc)(const device_config *image))
662632{
663633   floppy_drive *flopimg = get_safe_token( image );
r5849r5850
690660   pDrive->ready_state_change_callback = callback;
691661}
692662
693void floppy_drive_set_geometry_absolute(const device_config *img, int tracks, int sides)
694{
695   floppy_drive *pDrive = get_safe_token( img );
696   pDrive->max_track = tracks;
697   pDrive->num_sides = sides;
698}
699
700663int   floppy_drive_get_current_track(const device_config *img)
701664{
702665   floppy_drive *drv = get_safe_token( img );
src/mess/devices/flopdrv.h
r5849r5850
3636   keep_geometry keep_drive_geometry;   
3737};
3838
39typedef enum
40{
41   DEN_FM_LO = 0,
42   DEN_FM_HI,
43   DEN_MFM_LO,
44   DEN_MFM_HI
45} DENSITY;
46
4739/* sector has a deleted data address mark */
4840#define ID_FLAG_DELETED_DATA   0x0001
4941/* CRC error in id field */
r5849r5850
8678/* get current physical track drive is on */
8779int floppy_drive_get_current_track(const device_config *img);
8880
89void floppy_drive_set_geometry(const device_config *img, floppy_type type);
90void floppy_drive_set_geometry_absolute(const device_config *img, int tracks, int sides);
91
9281/* get next id from track, 1 if got a id, 0 if no id was got */
9382int floppy_drive_get_next_id(const device_config *img, int side, chrn_id *);
9483/* set ready state of drive. If flag == 1, set ready state only if drive present,
r5849r5850
10594void floppy_drive_format_sector(const device_config *img, int side, int sector_index, int c, int h, int r, int n, int filler);
10695void floppy_drive_read_sector_data(const device_config *img, int side, int index1, void *pBuffer, int length);
10796void floppy_drive_write_sector_data(const device_config *img, int side, int index1, const void *pBuffer, int length, int ddam);
108int   floppy_drive_get_datarate_in_us(DENSITY density);
10997
11098/* set motor speed to get correct index pulses
11199   standard RPM are 300 RPM (common) and 360 RPM
src/mess/drivers/pcw.c
r5849r5850
733733static MACHINE_START( pcw )
734734{
735735   fdc_interrupt_code = 2;
736   floppy_drive_set_geometry(floppy_get_device(machine, 0), FLOPPY_DRIVE_DS_80);
737   floppy_drive_set_geometry(floppy_get_device(machine, 1), FLOPPY_DRIVE_DS_80);
738736}
739737
740738static MACHINE_RESET( pcw )
src/mess/drivers/amstrad.c
r5849r5850
845845
846846static const floppy_config aleste_floppy_config =
847847{
848   FLOPPY_DRIVE_SS_40,
848   FLOPPY_DRIVE_DS_80,
849849   FLOPPY_OPTIONS_NAME(msx),
850850   DO_NOT_KEEP_GEOMETRY
851851};
src/mess/drivers/sord.c
r5849r5850
175175
176176static MACHINE_RESET( sord_m5_fd5 )
177177{
178   floppy_drive_set_geometry(floppy_get_device(machine,0), FLOPPY_DRIVE_SS_40);
179   floppy_drive_set_geometry(floppy_get_device(machine,1), FLOPPY_DRIVE_SS_40);
180178   MACHINE_RESET_CALL(sord_m5);
181179   ppi8255_set_port_c(devtag_get_device(machine, "ppi8255"), 0x50);
182180}
r5849r5850
571569
572570static const floppy_config sordm5_floppy_config =
573571{
574   FLOPPY_DRIVE_DS_80,
572   FLOPPY_DRIVE_SS_40,
575573   FLOPPY_OPTIONS_NAME(sordm5),
576574   DO_NOT_KEEP_GEOMETRY
577575};
src/mess/drivers/specpls3.c
r5849r5850
351351{
352352   memset(mess_ram,0,128*1024);
353353   
354   floppy_drive_set_geometry(floppy_get_device(machine, 0), FLOPPY_DRIVE_SS_40);
355   floppy_drive_set_geometry(floppy_get_device(machine, 1), FLOPPY_DRIVE_SS_40);
356
357354   /* Initial configuration */
358355   spectrum_128_port_7ffd_data = 0;
359356   spectrum_plus3_port_1ffd_data = 0;
r5849r5850
364361
365362static const floppy_config specpls3_floppy_config =
366363{
367   FLOPPY_DRIVE_DS_80,
364   FLOPPY_DRIVE_SS_40,
368365   FLOPPY_OPTIONS_NAME(default),
369366   DO_NOT_KEEP_GEOMETRY
370367};
src/mess/drivers/exidy.c
r5849r5850
413413   MDRV_CPU_MODIFY("maincpu")
414414   MDRV_CPU_PROGRAM_MAP(exidyd_mem)
415415
416   MDRV_MACHINE_START( exidyd )
417   MDRV_MACHINE_RESET( exidyd )
416   MDRV_MACHINE_START( exidy )
417   MDRV_MACHINE_RESET( exidy )
418418   
419419   MDRV_FLOPPY_4_DRIVES_REMOVE()
420420MACHINE_DRIVER_END
src/mess/drivers/enterp.c
r5849r5850
176176   const device_config *fdc = devtag_get_device(machine, "wd1770");
177177   cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), 0, 0xff);
178178
179   floppy_drive_set_geometry(floppy_get_device(machine, 0), FLOPPY_DRIVE_DS_80);
180179   wd17xx_set_density(fdc, DEN_FM_HI);
181180}
182181

Previous 15994 Revisions Next


© 1998-2018 The MESS Team