Previous 15994 Revisions Next

r8723 Friday 6th August, 2010 at 15:43:23 UTC by Angelo Salese
[SMC-777]: Made FDC ready line to check if a floppy is present or not, fixes 'disk error' at start-up if no disk is inserted
[src/mess/drivers]smc777.c

src/mess/drivers/smc777.c
r8722r8723
244244static UINT8 fdc_irq_flag;
245245static UINT8 fdc_drq_flag;
246246
247static READ8_HANDLER( smc777_fdc_r )
247static void check_floppy_inserted(running_machine *machine)
248248{
249   int f_num;
250   floppy_image *floppy;
251
252   /* check if a floppy is there, automatically disconnect the ready line if so (HW doesn't control the ready line) */
253   /* FIXME: floppy drive 1 doesn't work? */
254   for(f_num=0;f_num<2;f_num++)
255   {
256      floppy = flopimg_get_image(floppy_get_device(machine, f_num));
257      floppy_mon_w(floppy_get_device(machine, f_num), (floppy != NULL) ? 0 : 1);
258      floppy_drive_set_ready_state(floppy_get_device(machine, f_num), (floppy != NULL) ? 1 : 0,0);
259   }
260}
261
262static READ8_HANDLER( smc777_fdc1_r )
263{
249264   running_device* dev = space->machine->device("fdc");
250   //UINT8 ret = 0;
251265
252   switch(offset+0x30)
266   check_floppy_inserted(space->machine);
267
268   switch(offset)
253269   {
254      case 0x30:
270      case 0x00:
255271         return wd17xx_status_r(dev,offset);
256      case 0x31:
272      case 0x01:
257273         return wd17xx_track_r(dev,offset);
258      case 0x32:
274      case 0x02:
259275         return wd17xx_sector_r(dev,offset);
260      case 0x33:
276      case 0x03:
261277         return wd17xx_data_r(dev,offset);
262      case 0x34: //irq / drq status
263         popmessage("%02x %02x\n",fdc_irq_flag,fdc_drq_flag);
278      case 0x04: //irq / drq status
279         //popmessage("%02x %02x\n",fdc_irq_flag,fdc_drq_flag);
264280
265281         return (fdc_irq_flag ? 0x80 : 0x00) | (fdc_drq_flag ? 0x00 : 0x40);
266282   }
r8722r8723
268284   return 0x00;
269285}
270286
271static WRITE8_HANDLER( smc777_fdc_w )
287static WRITE8_HANDLER( smc777_fdc1_w )
272288{
273289   running_device* dev = space->machine->device("fdc");
274290
275   switch(offset+0x30)
291   check_floppy_inserted(space->machine);
292
293   switch(offset)
276294   {
277      case 0x30:
295      case 0x00:
278296         wd17xx_command_w(dev,offset,data);
279297         break;
280      case 0x31:
298      case 0x01:
281299         wd17xx_track_w(dev,offset,data);
282300         break;
283      case 0x32:
301      case 0x02:
284302         wd17xx_sector_w(dev,offset,data);
285303         break;
286      case 0x33:
304      case 0x03:
287305         wd17xx_data_w(dev,offset,data);
288306         break;
289      case 0x34:
290      //   wd17xx_set_drive(dev,data & 3);
291         /* TODO: understand the conditions of this */
292         floppy_mon_w(floppy_get_device(space->machine, 0), !BIT(data, 7));
293         floppy_drive_set_ready_state(floppy_get_device(space->machine, 0), 1,0);
294      //   wd17xx_set_side(dev,(data & 0x10)>>4);
295         if(data)
307      case 0x04:
308         // ---- xxxx select floppy drive (yes, 15 of them, A to P)
309         wd17xx_set_drive(dev,data & 0x01);
310         //   wd17xx_set_side(dev,(data & 0x10)>>4);
311         if(data & 0xf0)
296312         printf("%02x\n",data);
297313         break;
298314   }
r8722r8723
421437//   AM_RANGE(0x26, 0x26) AM_WRITENOP //RS232C RX / TX
422438//   AM_RANGE(0x27, 0x27) AM_WRITENOP //RS232C Mode / Command / Status
423439
424//   AM_RANGE(0x28, 0x2c) AM_NOP //fdc 2, MB8876 -> FD1791
440//   AM_RANGE(0x28, 0x2c) AM_READWRITE(smc777_fdc_r,smc777_fdc_w) //fdc 2, MB8876 -> FD1791
425441//   AM_RANGE(0x2d, 0x2f) AM_NOP //rs-232c no. 2
426   AM_RANGE(0x30, 0x34) AM_READWRITE(smc777_fdc_r,smc777_fdc_w) //fdc 1, MB8876 -> FD1791
442   AM_RANGE(0x30, 0x34) AM_READWRITE(smc777_fdc1_r,smc777_fdc1_w) //fdc 1, MB8876 -> FD1791
427443//   AM_RANGE(0x35, 0x37) AM_NOP //rs-232c no. 3
428444//   AM_RANGE(0x38, 0x3b) AM_NOP //cache disk unit
429445//   AM_RANGE(0x3c, 0x3d) AM_NOP //RGB Superimposer

Previous 15994 Revisions Next


© 1998-2018 The MESS Team