Previous 15994 Revisions Next

r15333 Monday 28th May, 2012 at 12:51:10 UTC by Robbbert
micropolis - minor updates (nw)
[src/mess/machine]micropolis.c

src/mess/machine/micropolis.c
r15332r15333
1212
1313ToDo:
1414- Rewrite to be a standard device able to be used in a general way
15- Support the ability to write to disk.
15- Fix bug where if you run a program on drive B,C,D then exit, you
16  get a disk error.
17- Enable the ability to write to disk when above bug gets fixed.
18- When the controller is reset via command 5, what exactly gets reset?
1619
1720
1821Ports:
1922BE00 and BE01 can be used as command registers (they are identical),
2023              and they are also used as status registers (different).
2124
22BE02 - read data
23BE03 - unknown
25BE02 and BE03 - read data, write data
2426
25Write data is unknown but could either be BE02 or BE03.
26
2727***************************************************************************/
2828
2929
r15332r15333
3737***************************************************************************/
3838
3939
40#define STAT_MOTOR_ON   0x20
40#define STAT_RFC   0x20
4141#define STAT_TRACK0     0x08
4242#define STAT_READY      0x80
4343
r15332r15333
158158    INTERFACE
159159***************************************************************************/
160160
161/* use this to determine which drive is controlled by WD */
161/* select a drive */
162162void micropolis_set_drive(device_t *device, UINT8 drive)
163163{
164164   micropolis_state *w = get_safe_token(device);
r15332r15333
166166   if (VERBOSE)
167167      logerror("micropolis_set_drive: $%02x\n", drive);
168168
169   if (w->intf->floppy_drive_tags[drive] != NULL)
170   {
171      if (device->owner() != NULL) {
172         w->drive = device->owner()->subdevice(w->intf->floppy_drive_tags[drive]);
173         if (w->drive == NULL) {
174            w->drive = device->machine().device(w->intf->floppy_drive_tags[drive]);
175         }
176      }
177      else
178         w->drive = device->machine().device(w->intf->floppy_drive_tags[drive]);
179   }
169   if (w->intf->floppy_drive_tags[drive])
170      w->drive = device->siblingdevice(w->intf->floppy_drive_tags[drive]);
180171}
181172
182173
r15332r15333
195186      return w->status | w->drive_num;
196187   else
197188   {
189      // FIXME - find out what controls current sector
198190      w->sector = (w->sector + 3 + inv) & 15;
199191      micropolis_read_sector(device);
200192      inv ^= 1;
r15332r15333
217209/* write the FDC command register */
218210WRITE8_DEVICE_HANDLER( micropolis_command_w )
219211{
212/* List of commands:
213Command (bits 5,6,7)      Options (bits 0,1,2,3,4)
2140    Not used
2151    Drive/head select    bits 0,1 select drive 0-3; bit 4 chooses a side
2162    INT sector control   bit 0 LO = disable; HI = enable
2173    Step                 bit 0 LO step out; HI = step in (increment track number)
2184    Set Write
2195    Reset controller
2206    Not used
2217    Not used */
222
220223   micropolis_state *w = get_safe_token(device);
221224   int direction = 0;
222225
223   if ((data & 0x60)==0x20)
226   switch (data >> 5)
224227   {
228   case 1:
225229      w->drive_num = data & 3;
226      floppy_mon_w(w->drive, ASSERT_LINE); // turn off the old drive
230      floppy_mon_w(w->drive, 1); // turn off the old drive
227231      micropolis_set_drive(device, w->drive_num); // select new drive
228      floppy_mon_w(w->drive, CLEAR_LINE); // turn it on
232      floppy_mon_w(w->drive, 0); // turn it on
233      break;
234   case 2:  // not emulated, not used in sorcerer
235      break;
236   case 3:
237      if (BIT(data, 0))
238      {
239         if (w->track < 77)
240         {
241            w->track++;
242            direction = 1;
243         }
244      }
245      else
246      {
247         if (w->track)
248         {
249            w->track--;
250            direction = -1;
251         }
252      }
253      break;
254   case 4: // not emulated, to be done
255      break;
256   case 5: // not emulated, to be done
257      break;
229258   }
230259
231   w->status = 0;
232260
261   w->status = STAT_RFC;
262
233263   if (BIT(data, 5))
234      w->status = STAT_MOTOR_ON | STAT_READY;
264      w->status |= STAT_READY;
235265
236266   floppy_drive_set_ready_state(w->drive, 1,0);
237267
238   if ((data & 0x41) == 0x41)
239   {
240      if (w->track < 77)
241      {
242         w->track++;
243         direction = 1;
244      }
245   }
246   else
247   if ((data & 0x41) == 0x40)
248   {
249      if (w->track)
250      {
251         w->track--;
252         direction = -1;
253      }
254   }
255268
256269   if (!w->track)
257270      w->status |= STAT_TRACK0;
r15332r15333
296309   {
297310   case 0: data = micropolis_status_r(device, 0); break;
298311   case 1:   data = micropolis_status_r(device, 1); break;
299   case 2:   data = micropolis_data_r(device, 0); break;
300   case 3:   data = 0; break;
312   case 2:
313   case 3:   data = micropolis_data_r(device, 0); break;
301314   }
302315
303316   return data;
r15332r15333
307320{
308321   switch (offset & 0x03)
309322   {
310   case 0: micropolis_command_w(device, 0, data); break;
311   case 1:   micropolis_command_w(device, 1, data); break;
312   case 2:     break;
323   case 0:
324   case 1:   micropolis_command_w(device, 0, data); break;
325   case 2:
313326   case 3: micropolis_data_w(device, 0, data);    break;
314327   }
315328}
r15332r15333
333346   micropolis_state *w = get_safe_token(device);
334347   int i;
335348
336   /* set the default state of some input lines */
337349   for (i = 0; i < 4; i++)
338350   {
339      if(w->intf->floppy_drive_tags[i]!=NULL) {
351      if(w->intf->floppy_drive_tags[i])
352      {
340353         device_t *img = NULL;
341354
342         if (device->owner() != NULL)
343            img = device->owner()->subdevice(w->intf->floppy_drive_tags[i]);
344            if (img == NULL) {
345               img = device->machine().device(w->intf->floppy_drive_tags[i]);
346            }
355         img = device->siblingdevice(w->intf->floppy_drive_tags[i]);
347356
348         else
349            img = device->machine().device(w->intf->floppy_drive_tags[i]);
350
351         if (img!=NULL) {
357         if (img)
358         {
352359            floppy_drive_set_controller(img,device);
360            //floppy_drive_set_index_pulse_callback(img, wd17xx_index_pulse_callback);
353361            floppy_drive_set_rpm( img, 300.);
354362         }
355363      }
r15332r15333
361369   w->sector = 0;
362370   w->track = 0;
363371   w->sector_length = 270;
364   w->status = 0;
372   w->status = STAT_TRACK0;
365373}
366374
367375void micropolis_reset(device_t *device)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team