Previous 15994 Revisions Next

r8272 Monday 14th June, 2010 at 20:19:39 UTC by Michael Zapf
Fixed ambiguous ()?-expression
[src/mess/machine]smc92x4.c

src/mess/machine/smc92x4.c
r8271r8272
151151   UINT8 output2;      /* UDC-internal register "output2" */
152152
153153   int   selected_drive_type;
154   /* We need to store the types, although this is not the case in the
155    real hardware. The reason is that poll_drives wants to select the drives
156    without knowing their kinds. In reality this does not matter, since we
157    only check for the seek_complete line, but in our case, floppy and
158    harddrive are pretty different, and we need to know which one to check. */
154   // We need to store the types, although this is not the case in the
155   // real hardware. The reason is that poll_drives wants to select the
156   // drives without knowing their kinds. In reality this does not matter,
157   // since we only check for the seek_complete line, but in our case,
158   // floppy and harddrive are pretty different, and we need to know which
159   // one to check.
159160   int   types[4];
160161   int   head_load_delay_enable;
161162   int   register_pointer;
r8271r8272
248249#if 0
249250static void dump_contents(UINT8 *buffer, int length)
250251{
251        for (int i=0; i < length; i+=16)
252        {
253                for (int j=0; j < 16; j+=2)
254                {
255                        printf("%02x%02x ", buffer[i+j], buffer[i+j+1]);
256                }
257                printf("\n");
258        }
252   for (int i=0; i < length; i+=16)
253   {
254      for (int j=0; j < 16; j+=2)
255      {
256         printf("%02x%02x ", buffer[i+j], buffer[i+j+1]);
257      }
258      printf("\n");
259   }
259260}
260261#endif
261262
r8271r8272
269270
270271static int image_is_single_density(running_device *current_floppy)
271272{
272        floppy_image *image = flopimg_get_image(current_floppy);
273   floppy_image *image = flopimg_get_image(current_floppy);
273274   return (floppy_get_track_size(image, 0, 0)<4000);
274275}
275276
r8271r8272
650651*/
651652static void update_id_regs(running_device *device, chrn_id_hd id)
652653{
653   /* Flags for current head register. Note that the sizes are not in
654       sequence (128, 256, 512, 1024). This is only interesting for AT
655       mode. */
654   // Flags for current head register. Note that the sizes are not in
655   // sequence (128, 256, 512, 1024). This is only interesting for AT
656   // mode.
656657   UINT8 sizeflag[] = { 0x60, 0x00, 0x20, 0x40 };
657658   smc92x4_state *w = get_safe_token(device);
658659
r8271r8272
682683   sync_latches_out(device);
683684   sync_status_in(device);
684685
685   /* Set command termination code. The error code is set first, and
686       on success, it is cleared. */
686   // Set command termination code. The error code is set first, and
687   // on success, it is cleared.
687688   w->register_r[INT_STATUS] |= ST_TC_RDIDERR;
688689
689690   /* Try to find an ID field. */
r8271r8272
784785   int foundsect = FALSE;
785786   int des_cylinder = 0;
786787
787   /* Set command termination code. The error code is set first, and
788       on success, it is cleared. */
788   // Set command termination code. The error code is set first, and
789   // on success, it is cleared.
789790   w->register_r[INT_STATUS] |= ST_TC_SEEKERR;
790791
791792   while (pass < maxtry && !foundsect)
r8271r8272
865866
866867   current_floppy = (*w->intf->current_floppy)();
867868
868   /* Set command termination code. The error code is set first, and
869       on success, it is cleared. */
869   // Set command termination code. The error code is set first, and
870   // on success, it is cleared.
870871   w->register_r[INT_STATUS] |= ST_TC_DATAERR;
871872
872   /* Save the value. Note that the retry count is only in the first four
873    bits, and it is stored in one's complement. In this implementation
874    we don't work with it. */
873   // Save the value. Note that the retry count is only in the first four
874   // bits, and it is stored in one's complement. In this implementation
875   // we don't work with it.
875876   retry = w->register_w[RETRY_COUNT];
876877
877878   /* We are already at the correct sector (found by the verify sequence) */
r8271r8272
961962
962963   current_floppy = (*w->intf->current_floppy)();
963964
964   /* Set command termination code. The error code is set first, and
965       on success, it is cleared. */
965   // Set command termination code. The error code is set first, and
966   // on success, it is cleared.
966967   w->register_r[INT_STATUS] |= ST_TC_DATAERR;
967968
968   /* Save the value. Note that the retry count is only in the first four
969    bits, and it is stored in one's complement. In this implementation
970    we don't work with it. */
969   // Save the value. Note that the retry count is only in the first four
970   // bits, and it is stored in one's complement. In this implementation
971   // we don't work with it.
971972   retry = w->register_w[RETRY_COUNT];
972973
973974   /* Initiate the DMA. We assume the DMARQ is positive. */
r8271r8272
11471148      }
11481149      else
11491150      {
1150/*      printf("smc92x4 read sectors CYL=%02x, HEA=%02x, SEC=%02x, MOD=%02x, CNT=%02x, TRY=%02x\n",
1151            w->register_w[DESIRED_CYLINDER],
1152            w->register_w[DESIRED_HEAD],
1153            w->register_w[DESIRED_SECTOR],
1154            w->register_w[MODE],
1155            w->register_w[SECTOR_COUNT],
1156            w->register_w[RETRY_COUNT]); */
11571151         smc92x4_timed_sector_read_request(device);
11581152      }
11591153   }
r8271r8272
12841278{
12851279   smc92x4_state *w = get_safe_token(device);
12861280   int direction = (w->command & 0x02)? -1 : +1;
1287   /* bit 0: 0 -> command ends after last seek pulse, 1 -> command
1288    ends when the drive asserts the seek complete pin */
1281   // bit 0: 0 -> command ends after last seek pulse, 1 -> command
1282   // ends when the drive asserts the seek complete pin
12891283   int buffered = w->command & 0x01;
12901284
12911285   w->step_direction = direction;
r8271r8272
13431337   w->selected_drive_type = (driveparm>>2) & 0x03;
13441338   w->head_load_delay_enable = (driveparm>>4)&0x01;
13451339
1346   /* We need to store the type of the drive for the poll_drives command
1347       to be able to correctly select the device (floppy or hard disk). */
1340   // We need to store the type of the drive for the poll_drives command
1341   // to be able to correctly select the device (floppy or hard disk).
13481342   w->types[driveparm&0x03] = w->selected_drive_type;
13491343
1350   /* Copy the DMA registers to registers CURRENT_HEAD, CURRENT_CYLINDER,
1351    and CURRENT_IDENT. This is required during formatting (p. 14) as the
1352    format command reuses the registers for formatting parameters. */
1344   // Copy the DMA registers to registers CURRENT_HEAD, CURRENT_CYLINDER,
1345   // and CURRENT_IDENT. This is required during formatting (p. 14) as the
1346   // format command reuses the registers for formatting parameters.
13531347   w->register_r[CURRENT_HEAD] = w->register_r[DMA7_0];
13541348   w->register_r[CURRENT_CYLINDER] = w->register_r[DMA15_8];
13551349   w->register_r[CURRENT_IDENT] = w->register_r[DMA23_16];
r8271r8272
14991493
15001494   UINT8 *buffer;
15011495
1502   /* Determine the track size. We cannot allow different sizes in this
1503    design. */
1496   /* Determine the track size. We cannot allow different sizes in this design. */
15041497   int data_count = 0;
15051498
15061499   sync_status_in(device);
15071500
15081501   current_floppy = (*w->intf->current_floppy)();
1509        floppy = flopimg_get_image(current_floppy);
1502   floppy = flopimg_get_image(current_floppy);
15101503
15111504   if (floppy != NULL)
15121505      data_count = floppy_get_track_size(floppy, 0, 0);
15131506
1514        if (data_count==0)
1515        {
1516                if (controller_set_to_single_density(device))
1517                        data_count = TRKSIZE_SD;
1518                else
1519                   data_count = TRKSIZE_DD;
1520        }
1507   if (data_count==0)
1508   {
1509      if (controller_set_to_single_density(device))
1510         data_count = TRKSIZE_SD;
1511      else
1512         data_count = TRKSIZE_DD;
1513   }
15211514
1522        /* Build buffer */
1523        buffer = (UINT8*)malloc(data_count);
1515   /* Build buffer */
1516   buffer = (UINT8*)malloc(data_count);
15241517
15251518   fm = controller_set_to_single_density(device);
15261519
r8271r8272
15391532      gap4 = (fm)? 247 : 598;
15401533      pre_gap = gap_byte;
15411534      sync1 = sync2;
1542      inam = sync2 + (fm)? 1 : 4;
1535      inam = sync2 + ((fm)? 1 : 4);
15431536   }
15441537   else
15451538   {
r8271r8272
16721665
16731666   sync_status_in(device);
16741667
1675        /* Build buffer */
1676        gap0 = (-w->register_w[DMA7_0])&0xff;
1677        gap1 = (-w->register_w[DMA15_8])&0xff;
1678        gap2 = (-w->register_w[DMA23_16])&0xff;
1679        gap3 = (-w->register_w[DESIRED_SECTOR])&0xff;
1680        gap4 = 340;
1668   /* Build buffer */
1669   gap0 = (-w->register_w[DMA7_0])&0xff;
1670   gap1 = (-w->register_w[DMA15_8])&0xff;
1671   gap2 = (-w->register_w[DMA23_16])&0xff;
1672   gap3 = (-w->register_w[DESIRED_SECTOR])&0xff;
1673   gap4 = 340;
16811674
16821675   sync = (~w->register_w[DESIRED_CYLINDER])&0xff;
16831676   count = (~w->register_w[SECTOR_COUNT])&0xff;
r8271r8272
16851678
16861679   data_count = gap1 + count*(sync+12+gap2+sync+size*128+gap3)+gap4;
16871680
1688        buffer = (UINT8*)malloc(data_count);
1681   buffer = (UINT8*)malloc(data_count);
16891682
16901683   index = 0;
16911684   fm = controller_set_to_single_density(device);
r8271r8272
17741767   running_device *current_floppy = (*w->intf->current_floppy)();
17751768
17761769   floppy_image *floppy;
1777   /* Determine the track size. We cannot allow different sizes in this
1778    design. */
1770   /* Determine the track size. We cannot allow different sizes in this design. */
17791771   int data_count = 0;
17801772   int i;
17811773   UINT8 *buffer;
17821774
17831775   sync_latches_out(device);
17841776
1785        floppy = flopimg_get_image(current_floppy);
1777   floppy = flopimg_get_image(current_floppy);
17861778
1787   /* Determine the track size. We cannot allow different sizes in this
1788    design. */
1779   /* Determine the track size. We cannot allow different sizes in this design. */
17891780   if (floppy != NULL)
17901781      data_count = floppy_get_track_size(floppy, 0, 0);
17911782
1792        if (data_count==0)
1793        {
1794                if (controller_set_to_single_density(device))
1795                        data_count = TRKSIZE_SD;
1796                else
1797                   data_count = TRKSIZE_DD;
1798        }
1783   if (data_count==0)
1784   {
1785      if (controller_set_to_single_density(device))
1786         data_count = TRKSIZE_SD;
1787      else
1788         data_count = TRKSIZE_DD;
1789   }
17991790
18001791   buffer = (UINT8*)malloc(data_count);
18011792
18021793   floppy_drive_read_track_data_info_buffer( current_floppy, w->register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count);
18031794   sync_status_in(device);
18041795
1805   /* Transfer the buffer to the external memory. We assume the memory
1806    pointer has been set appropriately in the registers. */
1796   // Transfer the buffer to the external memory. We assume the memory
1797   // pointer has been set appropriately in the registers.
18071798   set_dma_address(device, DMA23_16, DMA15_8, DMA7_0);
18081799
18091800   if (transfer_only_ids)
r8271r8272
18251816{
18261817   smc92x4_state *w = get_safe_token(device);
18271818
1828   /* Determine the track size. We cannot allow different sizes in this
1829    design. */
1819   /* Determine the track size. We cannot allow different sizes in this design. */
18301820   int i;
18311821   UINT8 *buffer;
18321822   int data_count=0;
r8271r8272
18431833      /* no buffer was allocated */
18441834   }
18451835
1846   /* Transfer the buffer to the external memory. We assume the memory
1847    pointer has been set appropriately in the registers. */
1836   // Transfer the buffer to the external memory. We assume the memory
1837   // pointer has been set appropriately in the registers.
18481838   set_dma_address(device, DMA23_16, DMA15_8, DMA7_0);
18491839
18501840   if (transfer_only_ids)
r8271r8272
19941984   else if (opcode >= 0x02 && opcode <= 0x03)
19951985   {
19961986      /* RESTORE DRIVE */
1997      /* bit 0: 0 -> command ends after last seek pulse, 1 -> command
1998        ends when the drive asserts the seek complete pin */
1987      // bit 0: 0 -> command ends after last seek pulse, 1 -> command
1988      // ends when the drive asserts the seek complete pin
19991989      logerror("smc92x4 info: restore command %X\n", opcode);
20001990      restore_drive(device);
20011991   }
r8271r8272
20272017      /* SETREGPTR */
20282018      logerror("smc92x4 info: setregptr command %X\n", opcode);
20292019      w->register_pointer = opcode & 0xf;
2030      /* Spec does not say anything about the effect of setting an
2031        invalid value (only "care should be taken") */
2020      // Spec does not say anything about the effect of setting an
2021      // invalid value (only "care should be taken")
20322022      if (w->register_pointer > 10)
20332023      {
20342024         logerror("smc92x4 error: set register pointer: Invalid register number: %d. Setting to 10.\n", w->register_pointer);
r8271r8272
20972087   {
20982088      /* status register */
20992089      reply = w->register_r[INT_STATUS];
2100      /* Spec (p.3) : The interrupt pin is reset to its inactive state
2101             when the UDC interrupt status register is read. */
2090      // Spec (p.3) : The interrupt pin is reset to its inactive state
2091      // when the UDC interrupt status register is read.
21022092      // printf("smc92x4 interrupt status read = %02x\n", reply);
21032093      smc92x4_clear_interrupt(device);
21042094      /* Clear the bits due to int status register read. */
r8271r8272
21222112      // printf("smc92x4 register_w[%d] <- %X\n", w->register_pointer, data);
21232113      w->register_w[w->register_pointer] = data;
21242114
2125      /* The DMA registers and the sector register for read and
2126           write are identical. */
2115      // The DMA registers and the sector register for read and
2116      // write are identical.
21272117      if (w->register_pointer < DESIRED_HEAD)
21282118         w->register_r[w->register_pointer] = data;
21292119
r8271r8272
21562146   devcb_resolve_read_line(&w->in_auxbus_func, &w->intf->in_auxbus_func, device);
21572147
21582148   /* allocate timers */
2159   /*
2160    w->timer_data = timer_alloc(device->machine, smc92x4_data_callback, (void *)device); */
2149   /* w->timer_data = timer_alloc(device->machine, smc92x4_data_callback, (void *)device); */
21612150   w->timer_rs = timer_alloc(device->machine, smc92x4_read_sector_callback, (void *)device);
21622151   w->timer_ws = timer_alloc(device->machine, smc92x4_write_sector_callback, (void *)device);
21632152   w->timer_track = timer_alloc(device->machine, smc92x4_track_callback, (void *)device);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team