Previous 15994 Revisions Next

r6069 Wednesday 14th October, 2009 at 08:15:53 UTC by Dirk Best
Added some floppy drive select logic WIP
[src/mess/devices]flopdrv.c flopdrv.h

src/mess/devices/flopdrv.c
r6068r6069
3939   devcb_resolved_write_line out_wpt_func;
4040   devcb_resolved_write_line out_rdy_func;
4141
42   /* state of input lines */
43   int drtn; /* direction */
44   int stp;  /* step */
45   int wtg;  /* write gate */
46
4247   /* state of output lines */
4348   int idx;  /* index pulse */
4449   int tk00; /* track 00 */
4550   int wpt;  /* write protect */
4651   int rdy;  /* ready */
4752
53   /* drive select logic */
54   int drive_id;
55   int active;
56
4857   const floppy_config   *config;
4958
5059   /* flags */
r6068r6069
704713   floppy->config = device->static_config;
705714   floppy_drive_init(device);
706715
716   floppy->drive_id = floppy_get_drive(device);
717   floppy->active = FALSE;
718
707719   /* resolve callbacks */
708720   devcb_resolve_write_line(&floppy->out_idx_func, &floppy->config->out_idx_func, device);
709721   devcb_resolve_read_line(&floppy->in_mon_func, &floppy->config->in_mon_func, device);
r6068r6069
864876   return cnt;
865877}
866878
879
880/* drive select 0 */
881WRITE_LINE_DEVICE_HANDLER( floppy_ds0_w )
882{
883   floppy_drive *drive = get_safe_token(device);
884
885   if (state == CLEAR_LINE)
886      drive->active = (drive->drive_id == 0);
887}
888
889/* drive select 1 */
890WRITE_LINE_DEVICE_HANDLER( floppy_ds1_w )
891{
892   floppy_drive *drive = get_safe_token(device);
893
894   if (state == CLEAR_LINE)
895      drive->active = (drive->drive_id == 1);
896}
897
898/* drive select 2 */
899WRITE_LINE_DEVICE_HANDLER( floppy_ds2_w )
900{
901   floppy_drive *drive = get_safe_token(device);
902
903   if (state == CLEAR_LINE)
904      drive->active = (drive->drive_id == 2);
905}
906
907/* drive select 3 */
908WRITE_LINE_DEVICE_HANDLER( floppy_ds3_w )
909{
910   floppy_drive *drive = get_safe_token(device);
911
912   if (state == CLEAR_LINE)
913      drive->active = (drive->drive_id == 3);
914}
915
916/* shortcut to write all four ds lines */
917WRITE8_DEVICE_HANDLER( floppy_ds_w )
918{
919   floppy_ds0_w(device, BIT(data, 0));
920   floppy_ds1_w(device, BIT(data, 1));
921   floppy_ds2_w(device, BIT(data, 2));
922   floppy_ds3_w(device, BIT(data, 3));
923}
924
925/* direction */
926WRITE_LINE_DEVICE_HANDLER( floppy_drtn_w )
927{
928   floppy_drive *drive = get_safe_token(device);
929   drive->drtn = state;
930}
931
932/* write data */
933WRITE_LINE_DEVICE_HANDLER( floppy_wtd_w )
934{
935
936}
937
938/* step */
939WRITE_LINE_DEVICE_HANDLER( floppy_stp_w )
940{
941   floppy_drive *drive = get_safe_token(device);
942
943   /* move head one track when going from high to low and write gate is high */
944   if (drive->active && drive->stp && state == CLEAR_LINE && drive->wtg)
945   {
946      /* move head according to the direction line */
947      if (drive->drtn)
948      {
949         /* move head outward */
950         drive->current_track--;
951
952         /* are we at track 0 now? */
953         if (drive->current_track <= 0)
954         {
955            drive->current_track = 0;
956            drive->tk00 = CLEAR_LINE;
957         }
958         else
959            drive->tk00 = ASSERT_LINE;
960      }
961      else
962      {
963         /* move head inward */
964         drive->current_track++;
965
966         /* are we over the maximum? */
967         if (drive->current_track >= drive->max_track)
968            drive->current_track = drive->max_track - 1;
969
970         /* we can't be at track 0 here, so reset the line */
971         drive->tk00 = ASSERT_LINE;
972      }
973
974      /* update track 0 line with new status */
975      devcb_call_write_line(&drive->out_tk00_func, drive->tk00);
976   }
977
978   drive->stp = state;
979}
980
981/* write gate */
982WRITE_LINE_DEVICE_HANDLER( floppy_wtg_w )
983{
984   floppy_drive *drive = get_safe_token(device);
985   drive->wtg = state;
986}
987
867988/* write protect signal, active low */
868989READ_LINE_DEVICE_HANDLER( floppy_wpt_r )
869990{
870   if (floppy_drive_get_flag_state(device, FLOPPY_DRIVE_DISK_WRITE_PROTECTED))
871      return CLEAR_LINE;
872   else
873      return ASSERT_LINE;
991   floppy_drive *drive = get_safe_token(device);
992   return drive->wpt;
874993}
875994
995
876996/*************************************
877997 *
878998 *  Device specification function
src/mess/devices/flopdrv.h
r6068r6069
135135
136136void floppy_drive_set_geometry(const device_config *img, floppy_type type);
137137
138/* drive select lines */
139WRITE_LINE_DEVICE_HANDLER( floppy_ds0_w );
140WRITE_LINE_DEVICE_HANDLER( floppy_ds1_w );
141WRITE_LINE_DEVICE_HANDLER( floppy_ds2_w );
142WRITE_LINE_DEVICE_HANDLER( floppy_ds3_w );
143WRITE8_DEVICE_HANDLER( floppy_ds_w );
144
138145READ_LINE_DEVICE_HANDLER( floppy_idx_r );
139146WRITE_LINE_DEVICE_HANDLER( floppy_mon_w );
147WRITE_LINE_DEVICE_HANDLER( floppy_drtn_w );
148WRITE_LINE_DEVICE_HANDLER( floppy_stp_w );
149WRITE_LINE_DEVICE_HANDLER( floppy_wtd_w );
150WRITE_LINE_DEVICE_HANDLER( floppy_wtg_w );
140151READ_LINE_DEVICE_HANDLER( floppy_tk00_r );
141152READ_LINE_DEVICE_HANDLER( floppy_wpt_r );
142153READ_LINE_DEVICE_HANDLER( floppy_rdy_r );

Previous 15994 Revisions Next


© 1998-2018 The MESS Team