Previous 15994 Revisions Next

r7238 Tuesday 2nd February, 2010 at 12:29:59 UTC by Curt Coder
[C8050] WIP
[src/mess/formats]d64_dsk.c d64_dsk.h g64_dsk.c g64_dsk.h
[src/mess/machine]c1541.c c1551.c c1571.c c2040.c

src/mess/machine/c2040.c
r7237r7238
1111
1212   TODO:
1313
14   - 8050 clock generator
14   - 8050 e27
15   - save state
16   - remove via_pb_r
1517   - write to disk
16   - save state
18   - alloca buffers
19   - activity/error LEDs
1720
1821*/
1922
r7237r7238
4750#define C8050_REGION   "c8050"
4851#define SFD1001_REGION   "sfd1001"
4952
50static const double C2040_BITRATE[4] =
51{
52   XTAL_16MHz/13.0,   /* tracks 1-17 */
53   XTAL_16MHz/14.0,   /* tracks 18-24 */
54   XTAL_16MHz/15.0,    /* tracks 25-30 */
55   XTAL_16MHz/16.0      /* tracks 31-42 */
56};
53#define SYNC \
54   (!(((c2040->sr & G64_SYNC_MARK) == G64_SYNC_MARK) & c2040->rw))
5755
58#define SYNC_MARK         0x3ff      /* 10 consecutive 1-bits */
56#define ERROR \
57   (!(c2040->ready | BIT(c2040->e, 3)))
5958
60#define TRACK_BUFFER_SIZE   8194      /* 2 bytes track length + maximum of 8192 bytes of GCR encoded data */
61#define TRACK_DATA_START   2
62
63#define SYNC   (!(((c2040->sr & SYNC_MARK) == SYNC_MARK) & c2040->rw))
64#define ERROR   (!(c2040->ready | BIT(c2040->e, 3)))
65
6659/***************************************************************************
6760    TYPE DEFINITIONS
6861***************************************************************************/
r7237r7238
7366   int stp;                        /* stepper motor phase */
7467
7568   /* track */
76   UINT8 track_buffer[TRACK_BUFFER_SIZE];   /* track data buffer */
69   UINT8 track_buffer[G64_BUFFER_SIZE];   /* track data buffer */
7770   int track_len;                     /* track length */
7871   int buffer_pos;                     /* byte position within track buffer */
7972   int bit_pos;                     /* bit position within track buffer byte */
r7237r7238
218211      int ready = !(c2040->bit_count==9);
219212      int error = !(ready | BIT(c2040->e, 3));
220213
221      logerror("offs %04x/%04x G64 %02x READY %u PA %02x DATA %03x GCR %02x SYNC %u ERROR %u I %04x\n", c2040->unit[c2040->drive].buffer_pos-1, c2040->unit[c2040->drive].track_len,
214      logerror("d %u offs %04x/%04x G64 %02x READY %u PA %02x DATA %03x GCR %02x SYNC %u ERROR %u I %04x\n", c2040->drive, c2040->unit[c2040->drive].buffer_pos-1, c2040->unit[c2040->drive].track_len,
222215         c2040->unit[c2040->drive].track_buffer[c2040->unit[c2040->drive].buffer_pos],
223216         ready, pa, c2040->sr & 0x3ff, c2040->e, SYNC, error, c2040->i);
224217   }
r7237r7238
257250      if (c2040->unit[c2040->drive].buffer_pos == c2040->unit[c2040->drive].track_len + 2)
258251      {
259252         /* loop to the start of the track */
260         c2040->unit[c2040->drive].buffer_pos = TRACK_DATA_START;
253         c2040->unit[c2040->drive].buffer_pos = G64_DATA_START;
261254      }
262255   }
263256
r7237r7238
280273      c2040->ready = ready;
281274   }
282275
276   if ((device->type == C8050) || (device->type == C8250) || (device->type == SFD1001))
277   {
278      cpu_set_input_line(c2040->cpu_fdc, M6502_SET_OVERFLOW, ready);
279   }
280
283281   via_ca1_w(c2040->via, ready);
284282   via_cb1_w(c2040->via, ERROR);
285283}
r7237r7238
335333   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
336334   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
337335   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w)
338   AM_RANGE(0x0080, 0x009f) AM_MIRROR(0x0320) AM_DEVREADWRITE(M6530_TAG, miot6530_r, miot6530_w)
336   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, miot6530_r, miot6530_w)
339337   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
340338   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
341339   AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3")
r7237r7238
368366   ADDRESS_MAP_GLOBAL_MASK(0x1fff)
369367   AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530
370368   AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w)
371   AM_RANGE(0x0080, 0x009f) AM_MIRROR(0x0320) AM_DEVREADWRITE(M6530_TAG, miot6530_r, miot6530_w)
369   AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, miot6530_r, miot6530_w)
372370   AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1")
373371   AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2")
374372   AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3")
r7237r7238
710708
711709      if (tracks != 0)
712710      {
713         c2040->unit[unit].track_len = TRACK_BUFFER_SIZE;
714         c2040->unit[unit].buffer_pos = TRACK_DATA_START;
711         c2040->unit[unit].track_len = G64_BUFFER_SIZE;
712         c2040->unit[unit].buffer_pos = G64_DATA_START;
715713         c2040->unit[unit].bit_pos = 7;
716714         c2040->bit_count = 0;
717715
r7237r7238
722720         floppy_drive_read_track_data_info_buffer(c2040->unit[unit].image, c2040->side, c2040->unit[unit].track_buffer, &c2040->unit[unit].track_len);
723721
724722         /* extract track length */
725         c2040->unit[unit].track_len = 2 + ((c2040->unit[unit].track_buffer[1] << 8) | c2040->unit[unit].track_buffer[0]);
723         c2040->unit[unit].track_len = G64_DATA_START + ((c2040->unit[unit].track_buffer[1] << 8) | c2040->unit[unit].track_buffer[0]);
726724      }
727725
728726      c2040->unit[unit].stp = stp;
r7237r7238
10721070
10731071   c2040_t *c2040 = get_safe_token(device->owner);
10741072
1075   miot_pb_w(device, 0, newdata);
1073   /* drive select */
1074   if ((device->type == C8050) || (device->type == C8250))
1075   {
1076//TODO   c2040->drive = BIT(newdata, 0);
1077   }
10761078
1079   /* density select */
1080   int ds = (newdata >> 1) & 0x03;
1081
1082   if (c2040->ds != ds)
1083   {
1084      timer_adjust_periodic(c2040->bit_timer, attotime_zero, 0, ATTOTIME_IN_HZ(C8050_BITRATE[ds]));
1085      c2040->ds = ds;
1086   }
1087
10771088   /* side select */
1078   c2040->side = !BIT(newdata, 4);
1089   if ((device->type == C8250) || (device->type == SFD1001))
1090   {
1091      c2040->side = !BIT(newdata, 4);
1092   }
10791093
10801094   /* interrupt */
1081   cpu_set_input_line(c2040->cpu_fdc, M6502_IRQ_LINE, BIT(newdata, 7) ? CLEAR_LINE : ASSERT_LINE);
1095   if (c2040->miot_irq != BIT(newdata, 7))
1096   {
1097      cpu_set_input_line(c2040->cpu_fdc, M6502_IRQ_LINE, BIT(newdata, 7) ? CLEAR_LINE : ASSERT_LINE);
1098      c2040->miot_irq = BIT(newdata, 7);
1099   }
10821100}
10831101
10841102static const miot6530_interface c8050_miot_intf =
r7237r7238
13011319    ROM( c2040 )
13021320-------------------------------------------------*/
13031321
1304ROM_START( c2040 )
1322ROM_START( c2040 ) // schematic 320806
13051323   ROM_REGION( 0x2c00, C2040_REGION, ROMREGION_LOADBYNAME )
13061324   /* DOS 1.0 */
13071325   ROM_LOAD( "901468-06.ul1", 0x0000, 0x1000, CRC(25b5eed5) SHA1(4d9658f2e6ff3276e5c6e224611a66ce44b16fc7) )
r7237r7238
13111329   ROM_LOAD( "901466-02.uk3", 0x2000, 0x0400, NO_DUMP )
13121330
13131331   /* ROM GCR */
1314   ROM_LOAD( "901467.uk6", 0x2400, 0x0800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
1332   ROM_LOAD( "901467.uk6",    0x2400, 0x0800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
13151333ROM_END
13161334
13171335/*-------------------------------------------------
13181336    ROM( c4040 )
13191337-------------------------------------------------*/
13201338
1321ROM_START( c4040 )
1339ROM_START( c4040 ) // schematic ?
13221340   ROM_REGION( 0x3c00, C4040_REGION, ROMREGION_LOADBYNAME )
13231341   /* DOS 2.1 */
13241342   ROM_LOAD( "901468-11.uj1", 0x0000, 0x1000, CRC(b7157458) SHA1(8415f3159dea73161e0cef7960afa6c76953b6f8) )
r7237r7238
13331351   ROM_LOAD( "901466-04.uk3", 0x3000, 0x0400, CRC(0ab338dc) SHA1(6645fa40b81be1ff7d1384e9b52df06a26ab0bfb) )
13341352
13351353   /* ROM GCR */
1336   ROM_LOAD( "901467.uk6", 0x3400, 0x800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
1354   ROM_LOAD( "901467.uk6",    0x3400, 0x0800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
13371355ROM_END
13381356
13391357/*-------------------------------------------------
r7237r7238
13681386   ROM_LOAD( "901888-01.uh1", 0x2000, 0x2000, CRC(de9b6132) SHA1(2e6c2d7ca934e5c550ad14bd5e9e7749686b7af4) )
13691387
13701388   /* controller */
1371   ROM_LOAD( "901483-03.uk3", 0x4000, 0x400, CRC(9e83fa70) SHA1(e367ea8a5ddbd47f13570088427293138a10784b) )
1372   ROM_LOAD( "901483-04.uk3", 0x4000, 0x400, NO_DUMP )
1373   ROM_LOAD( "901884-01.uk3", 0x4000, 0x400, NO_DUMP )
1374   ROM_LOAD( "901885-04.uk3", 0x4000, 0x400, CRC(bab998c9) SHA1(0dc9a3b60f1b866c63eebd882403532fc59fe57f) )
1375   ROM_LOAD( "901869-01.uk3", 0x4000, 0x400, CRC(2915327a) SHA1(3a9a80f72ce76e5f5c72513f8ef7553212912ae3) )
1389   ROM_LOAD( "901483-03.uk3", 0x4000, 0x0400, CRC(9e83fa70) SHA1(e367ea8a5ddbd47f13570088427293138a10784b) )
1390   ROM_LOAD( "901483-04.uk3", 0x4000, 0x0400, NO_DUMP )
1391   ROM_LOAD( "901884-01.uk3", 0x4000, 0x0400, NO_DUMP )
1392   ROM_LOAD( "901885-04.uk3", 0x4000, 0x0400, CRC(bab998c9) SHA1(0dc9a3b60f1b866c63eebd882403532fc59fe57f) )
1393   ROM_LOAD( "901869-01.uk3", 0x4000, 0x0400, CRC(2915327a) SHA1(3a9a80f72ce76e5f5c72513f8ef7553212912ae3) )
13761394   
13771395   /* GCR decoder */
1378   ROM_LOAD( "901467.uk6", 0x4400, 0x800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
1396   ROM_LOAD( "901467.uk6",    0x4400, 0x0800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
13791397ROM_END
13801398
13811399/*-------------------------------------------------
13821400    ROM( sfd1001 )
13831401-------------------------------------------------*/
13841402
1385ROM_START( sfd1001 ) // schematic
1403ROM_START( sfd1001 ) // schematic 251406
13861404   ROM_REGION( 0x5000, SFD1001_REGION, ROMREGION_LOADBYNAME )
1387   ROM_LOAD( "901887-01.1j", 0x0000, 0x2000, CRC(0073b8b2) SHA1(b10603195f240118fe5fb6c6dfe5c5097463d890) )
1388   ROM_LOAD( "901888-01.3j", 0x2000, 0x2000, CRC(de9b6132) SHA1(2e6c2d7ca934e5c550ad14bd5e9e7749686b7af4) )
1405   ROM_LOAD( "901887-01.1j",  0x0000, 0x2000, CRC(0073b8b2) SHA1(b10603195f240118fe5fb6c6dfe5c5097463d890) )
1406   ROM_LOAD( "901888-01.3j",  0x2000, 0x2000, CRC(de9b6132) SHA1(2e6c2d7ca934e5c550ad14bd5e9e7749686b7af4) )
13891407
13901408   /* controller */
13911409   ROM_LOAD( "251257-02a.u2", 0x4000, 0x0800, CRC(b51150de) SHA1(3b954eb34f7ea088eed1d33ebc6d6e83a3e9be15) )
13921410
13931411   /* GCR decoder */
1394   ROM_LOAD( "901467.5c", 0x4800, 0x800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
1412   ROM_LOAD( "901467.5c",     0x4800, 0x0800, CRC(a23337eb) SHA1(97df576397608455616331f8e837cb3404363fa2) )
13951413ROM_END
13961414
13971415/*-------------------------------------------------
r7237r7238
14651483   c2040->miot->reset();
14661484   c2040->via->reset();
14671485
1468   /* toggle SO */
1486   /* toggle M6502 SO */
14691487   cpu_set_input_line(c2040->cpu_dos, M6502_SET_OVERFLOW, ASSERT_LINE);
14701488   cpu_set_input_line(c2040->cpu_dos, M6502_SET_OVERFLOW, CLEAR_LINE);
14711489}
src/mess/machine/c1541.c
r7237r7238
158158#define M6522_1_TAG      "ucd4"
159159#define TIMER_BIT_TAG   "ue7"
160160
161static const double C1541_BITRATE[4] =
162{
163   XTAL_16MHz/13.0,   /* tracks 1-17 */
164   XTAL_16MHz/14.0,   /* tracks 18-24 */
165   XTAL_16MHz/15.0,    /* tracks 25-30 */
166   XTAL_16MHz/16.0      /* tracks 31-42 */
167};
168
169#define SYNC_MARK         0x3ff      /* 10 consecutive 1-bits */
170
171#define TRACK_BUFFER_SIZE   8194      /* 2 bytes track length + maximum of 8192 bytes of GCR encoded data */
172#define TRACK_DATA_START   2
173
174161/***************************************************************************
175162    TYPE DEFINITIONS
176163***************************************************************************/
r7237r7238
180167{
181168   /* abstractions */
182169   int address;                  /* serial bus address - 8 */
183   UINT8 track_buffer[TRACK_BUFFER_SIZE];            /* track data buffer */
170   UINT8 track_buffer[G64_BUFFER_SIZE];            /* track data buffer */
184171   int track_len;                  /* track length */
185172   int buffer_pos;                  /* current byte position within track buffer */
186173   int bit_pos;                  /* current bit position within track buffer byte */
r7237r7238
263250      if (c1541->buffer_pos > c1541->track_len + 1)
264251      {
265252         /* loop to the start of the track */
266         c1541->buffer_pos = TRACK_DATA_START;
253         c1541->buffer_pos = G64_DATA_START;
267254      }
268255   }
269256
270   if ((c1541->data & SYNC_MARK) == SYNC_MARK)
257   if ((c1541->data & G64_SYNC_MARK) == G64_SYNC_MARK)
271258   {
272259      /* SYNC detected */
273260      c1541->bit_count = 0;
r7237r7238
822809   data |= !floppy_wpt_r(c1541->image) << 4;
823810
824811   /* SYNC detect line */
825   data |= !(c1541->mode && ((c1541->data & SYNC_MARK) == SYNC_MARK)) << 7;
812   data |= !(c1541->mode && ((c1541->data & G64_SYNC_MARK) == G64_SYNC_MARK)) << 7;
826813
827814   return data;
828815}
r7237r7238
865852
866853      if (tracks != 0)
867854      {
868         c1541->track_len = TRACK_BUFFER_SIZE;
869         c1541->buffer_pos = TRACK_DATA_START;
855         c1541->track_len = G64_BUFFER_SIZE;
856         c1541->buffer_pos = G64_DATA_START;
870857         c1541->bit_pos = 7;
871858         c1541->bit_count = 0;
872859
r7237r7238
877864         floppy_drive_read_track_data_info_buffer(c1541->image, 0, c1541->track_buffer, &c1541->track_len);
878865
879866         /* extract track length */
880         c1541->track_len = (c1541->track_buffer[1] << 8) | c1541->track_buffer[0];
867         c1541->track_len = G64_DATA_START + ((c1541->track_buffer[1] << 8) | c1541->track_buffer[0]);
881868      }
882869
883870      c1541->stp = stp;
r7237r7238
892879   /* density select */
893880   if (c1541->ds != ds)
894881   {
895      timer_adjust_periodic(c1541->bit_timer, attotime_zero, 0, ATTOTIME_IN_HZ(C1541_BITRATE[ds]/4));
882      timer_adjust_periodic(c1541->bit_timer, attotime_zero, 0, ATTOTIME_IN_HZ(C2040_BITRATE[ds]/4));
896883      c1541->ds = ds;
897884   }
898885}
r7237r7238
11081095   c1541->image = device->subdevice(FLOPPY_0);
11091096
11101097   /* allocate track buffer */
1111//  c1541->track_buffer = auto_alloc_array(device->machine, UINT8, TRACK_BUFFER_SIZE);
1098//  c1541->track_buffer = auto_alloc_array(device->machine, UINT8, G64_BUFFER_SIZE);
11121099
11131100   /* allocate data timer */
11141101   c1541->bit_timer = timer_alloc(device->machine, bit_tick, (void *)device);
11151102
11161103   /* register for state saving */
1117//  state_save_register_device_item_pointer(device, 0, c1541->track_buffer, TRACK_BUFFER_SIZE);
1104//  state_save_register_device_item_pointer(device, 0, c1541->track_buffer, G64_BUFFER_SIZE);
11181105   state_save_register_device_item(device, 0, c1541->address);
11191106   state_save_register_device_item(device, 0, c1541->track_len);
11201107   state_save_register_device_item(device, 0, c1541->buffer_pos);
src/mess/machine/c1551.c
r7237r7238
3737
3838#define FLOPPY_TAG      "c1551_floppy"
3939
40static const double C1551_BITRATE[4] =
41{
42   XTAL_16MHz/13.0,   /* tracks 1-17 */
43   XTAL_16MHz/14.0,   /* tracks 18-24 */
44   XTAL_16MHz/15.0,    /* tracks 25-30 */
45   XTAL_16MHz/16.0      /* tracks 31-42 */
46};
47
48#define SYNC_MARK         0x3ff      /* 10 consecutive 1-bits */
49
50#define TRACK_BUFFER_SIZE   8194      /* 2 bytes track length + maximum of 8192 bytes of GCR encoded data */
51#define TRACK_DATA_START   2
52
5340/***************************************************************************
5441    TYPE DEFINITIONS
5542***************************************************************************/
r7237r7238
5744typedef struct _c1551_t c1551_t;
5845struct _c1551_t
5946{
60   UINT8 track_buffer[TRACK_BUFFER_SIZE];            /* track data buffer */
47   UINT8 track_buffer[G64_BUFFER_SIZE];            /* track data buffer */
6148   int track_len;                  /* track length */
6249   int buffer_pos;                  /* current byte position within track buffer */
6350   int bit_pos;                  /* current bit position within track buffer byte */
r7237r7238
123110      if (c1551->buffer_pos > c1551->track_len + 1)
124111      {
125112         /* loop to the start of the track */
126         c1551->buffer_pos = TRACK_DATA_START;
113         c1551->buffer_pos = G64_DATA_START;
127114      }
128115   }
129116
130   if ((c1551->data & SYNC_MARK) == SYNC_MARK)
117   if ((c1551->data & G64_SYNC_MARK) == G64_SYNC_MARK)
131118   {
132119      /* SYNC detected */
133120      c1551->bit_count = 0;
r7237r7238
224211
225212      if (tracks != 0)
226213      {
227         c1551->track_len = TRACK_BUFFER_SIZE;
228         c1551->buffer_pos = TRACK_DATA_START;
214         c1551->track_len = G64_BUFFER_SIZE;
215         c1551->buffer_pos = G64_DATA_START;
229216         c1551->bit_pos = 7;
230217         c1551->bit_count = 0;
231218
r7237r7238
236223         floppy_drive_read_track_data_info_buffer(c1551->image, 0, c1551->track_buffer, &c1551->track_len);
237224
238225         /* extract track length */
239         c1551->track_len = (c1551->track_buffer[1] << 8) | c1551->track_buffer[0];
226         c1551->track_len = G64_DATA_START + ((c1551->track_buffer[1] << 8) | c1551->track_buffer[0]);
240227      }
241228
242229      c1551->stp = stp;
r7237r7238
251238   /* density select */
252239   if (c1551->ds != ds)
253240   {
254      timer_adjust_periodic(c1551->bit_timer, attotime_zero, 0, ATTOTIME_IN_HZ(C1551_BITRATE[ds]/4));
241      timer_adjust_periodic(c1551->bit_timer, attotime_zero, 0, ATTOTIME_IN_HZ(C2040_BITRATE[ds]/4));
255242      c1551->ds = ds;
256243   }
257244}
r7237r7238
374361   UINT8 data = 0;
375362
376363   /* SYNC detect line */
377   data |= !(c1551->mode && ((c1551->data & SYNC_MARK) == SYNC_MARK)) << 6;
364   data |= !(c1551->mode && ((c1551->data & G64_SYNC_MARK) == G64_SYNC_MARK)) << 6;
378365
379366   return data;
380367}
r7237r7238
480467   c1551->image = device->subdevice(FLOPPY_0);
481468
482469   /* allocate track buffer */
483//  c1551->track_buffer = auto_alloc_array(device->machine, UINT8, TRACK_BUFFER_SIZE);
470//  c1551->track_buffer = auto_alloc_array(device->machine, UINT8, G64_BUFFER_SIZE);
484471
485472   /* allocate data timer */
486473   c1551->bit_timer = timer_alloc(device->machine, bit_tick, (void *)device);
487474
488475   /* register for state saving */
489//  state_save_register_device_item_pointer(device, 0, c1551->track_buffer, TRACK_BUFFER_SIZE);
476//  state_save_register_device_item_pointer(device, 0, c1551->track_buffer, G64_BUFFER_SIZE);
490477   state_save_register_device_item(device, 0, c1551->track_len);
491478   state_save_register_device_item(device, 0, c1551->buffer_pos);
492479   state_save_register_device_item(device, 0, c1551->bit_pos);
src/mess/machine/c1571.c
r7237r7238
1414   - 1541/1571 Alignment shows drive speed as 266 rpm, should be 310
1515   - toggle WPRT line on disk change
1616   - save state
17   - D71 disks
1817   - CP/M disks
1918    - power LED
2019    - activity LED
r7237r7238
4443#define M6526_TAG      "u20"
4544#define WD1770_TAG      "u11"
4645
47static const double C1571_BITRATE[4] =
48{
49   XTAL_16MHz/13.0,   /* tracks 1-17 */
50   XTAL_16MHz/14.0,   /* tracks 18-24 */
51   XTAL_16MHz/15.0,    /* tracks 25-30 */
52   XTAL_16MHz/16.0      /* tracks 31-42 */
53};
54
55#define SYNC_MARK         0x3ff      /* 10 consecutive 1-bits */
56
57#define TRACK_BUFFER_SIZE   8194      /* 2 bytes track length + maximum of 8192 bytes of GCR encoded data */
58#define TRACK_DATA_START   2
59
6046/***************************************************************************
6147    TYPE DEFINITIONS
6248***************************************************************************/
r7237r7238
6652{
6753   /* abstractions */
6854   int address;                  /* device number */
69   UINT8 track_buffer[TRACK_BUFFER_SIZE];            /* track data buffer */
55   UINT8 track_buffer[G64_BUFFER_SIZE];            /* track data buffer */
7056   int track_len;                  /* track length */
7157   int buffer_pos;                  /* current byte position within track buffer */
7258   int bit_pos;                  /* current bit position within track buffer byte */
r7237r7238
179165      if (c1571->buffer_pos > c1571->track_len + 1)
180166      {
181167         /* loop to the start of the track */
182         c1571->buffer_pos = TRACK_DATA_START;
168         c1571->buffer_pos = G64_DATA_START;
183169      }
184170   }
185171
186   if ((c1571->data & SYNC_MARK) == SYNC_MARK)
172   if ((c1571->data & G64_SYNC_MARK) == G64_SYNC_MARK)
187173   {
188174      /* SYNC detected */
189175      c1571->bit_count = 0;
r7237r7238
549535   data |= !floppy_wpt_r(c1571->image) << 4;
550536
551537   /* SYNC detect line */
552   data |= !((c1571->data & SYNC_MARK) == SYNC_MARK) << 7;
538   data |= !((c1571->data & G64_SYNC_MARK) == G64_SYNC_MARK) << 7;
553539
554540   return data;
555541}
r7237r7238
591577
592578      if (tracks != 0)
593579      {
594         c1571->track_len = TRACK_BUFFER_SIZE;
595         c1571->buffer_pos = TRACK_DATA_START;
580         c1571->track_len = G64_BUFFER_SIZE;
581         c1571->buffer_pos = G64_DATA_START;
596582         c1571->bit_pos = 7;
597583         c1571->bit_count = 0;
598584
r7237r7238
603589         floppy_drive_read_track_data_info_buffer(c1571->image, c1571->side, c1571->track_buffer, &c1571->track_len);
604590
605591         /* extract track length */
606         c1571->track_len = (c1571->track_buffer[1] << 8) | c1571->track_buffer[0];
592         c1571->track_len = G64_DATA_START + ((c1571->track_buffer[1] << 8) | c1571->track_buffer[0]);
607593      }
608594
609595      c1571->stp = stp;
r7237r7238
618604   /* density select */
619605   if (c1571->ds != ds)
620606   {
621      timer_adjust_periodic(c1571->bit_timer, attotime_zero, 0, ATTOTIME_IN_HZ(C1571_BITRATE[ds]/4));
607      timer_adjust_periodic(c1571->bit_timer, attotime_zero, 0, ATTOTIME_IN_HZ(C2040_BITRATE[ds]/4));
622608      c1571->ds = ds;
623609   }
624610}
src/mess/formats/d64_dsk.c
r7237r7238
1/*
1/*********************************************************************
22
3   Commodore sector format
3   formats/d64_dsk.c
44
5   SYNC                  FF * 5
6   08
7   CHECKSUM               sector ^ track ^ id2 ^ id1
8   SECTOR                  0..20 (2040), 0..28 (8050)
9   TRACK                  1..35 (2040), 1..77 (8050), 1..70 (1571)
10   ID2
11   ID1
12   GAP 1                  55 * 9 (2040), 55 * 8 (1541)
5    Floppy format code for Commodore 2040/8050 type disk images
136
14   SYNC                  FF * 5
15   07
16   NEXT TRACK
17   NEXT SECTOR
18   254 BYTES OF DATA
19   CHECKSUM
20   GAP 2                  55 * 8..19
7*********************************************************************/
218
22*/
23
249/*
2510
26 Commodore GCR format
27
28Original    Encoded
294 bits      5 bits
30
310000    ->  01010 = 0x0a
320001    ->  01011 = 0x0b
330010    ->  10010 = 0x12
340011    ->  10011 = 0x13
350100    ->  01110 = 0x0e
360101    ->  01111 = 0x0f
370110    ->  10110 = 0x16
380111    ->  10111 = 0x17
391000    ->  01001 = 0x09
401001    ->  11001 = 0x19
411010    ->  11010 = 0x1a
421011    ->  11011 = 0x1b
431100    ->  01101 = 0x0d
441101    ->  11101 = 0x1d
451110    ->  11110 = 0x1e
461111    ->  10101 = 0x15
47
48We use the encoded values in bytes because we use them to encode
49groups of 4 bytes into groups of 5 bytes, below.
50
51*/
52
53/*
54
5511    TODO:
5612
13   - D81 geometry translation
5714    - disk errors
5815   - variable gaps
5916
r7237r7238
6421#include "formats/d64_dsk.h"
6522#include "devices/flopdrv.h"
6623
24/***************************************************************************
25    PARAMETERS
26***************************************************************************/
27
6728#define LOG 0
6829
6930#define MAX_HEADS         2
r7237r7238
7435
7536#define INVALID_OFFSET      0xbadbad
7637
38#define D64_SIZE_35_TRACKS             174848
39#define D64_SIZE_35_TRACKS_WITH_ERRORS    175531
40#define D64_SIZE_40_TRACKS             196608
41#define D64_SIZE_40_TRACKS_WITH_ERRORS    197376
42#define D64_SIZE_42_TRACKS             205312
43#define D64_SIZE_42_TRACKS_WITH_ERRORS    206114
44#define D67_SIZE_35_TRACKS             176640
45#define D71_SIZE_70_TRACKS             349696
46#define D71_SIZE_70_TRACKS_WITH_ERRORS    351062
47#define D80_SIZE_77_TRACKS             533248
48#define D82_SIZE_154_TRACKS            1066496
49
7750enum
7851{
7952   DOS1,
8053   DOS2,
81   DOS27
54   DOS25
8255};
8356
57static const char *const DOS_VERSION[] = { "1.0", "2.0", "2.5" };
58
8459enum
8560{
8661   ERROR_00 = 1,
r7237r7238
9772   ERROR_74,      /* disk not ready (no device 1) */
9873};
9974
100#define D64_SIZE_35_TRACKS             174848
101#define D64_SIZE_35_TRACKS_WITH_ERRORS    175531
102#define D64_SIZE_40_TRACKS             196608
103#define D64_SIZE_40_TRACKS_WITH_ERRORS    197376
104#define D64_SIZE_42_TRACKS             205312
105#define D64_SIZE_42_TRACKS_WITH_ERRORS    206114
106#define D67_SIZE_35_TRACKS             176640
107#define D71_SIZE_70_TRACKS             349696
108#define D71_SIZE_70_TRACKS_WITH_ERRORS    351062
109#define D80_SIZE_77_TRACKS             533248
110#define D82_SIZE_154_TRACKS            1066496
75static const UINT8 bin_2_gcr[] =
76{
77   0x0a, 0x0b, 0x12, 0x13, 0x0e, 0x0f, 0x16, 0x17,
78   0x09, 0x19, 0x1a, 0x1b, 0x0d, 0x1d, 0x1e, 0x15
79};
11180
81/* This could be of use if we ever implement saving in .d64 format, to convert back GCR -> d64 */
82/*
83static const int gcr_2_bin[] =
84{
85    -1, -1,   -1,   -1,
86    -1, -1,   -1,   -1,
87    -1, 0x08, 0x00, 0x01,
88    -1, 0x0c, 0x04, 0x05,
89    -1, -1,   0x02, 0x03,
90    -1, 0x0f, 0x06, 0x07,
91    -1, 0x09, 0x0a, 0x0b,
92    -1, 0x0d, 0x0e, -1
93};
94*/
95
11296static const int DOS1_SECTORS_PER_TRACK[] =
11397{
11498   21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
r7237r7238
139123   17, 17
140124};
141125
142static const int DOS27_SECTORS_PER_TRACK[] =
126static const int DOS25_SECTORS_PER_TRACK[] =
143127{
144128   29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
145129   29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,      /* 1-39 */
r7237r7238
149133   23, 23, 23, 23, 23, 23, 23                                          /* 78-84 */
150134};
151135
152static const int DOS27_SPEED_ZONE[] =
136static const int DOS25_SPEED_ZONE[] =
153137{
154138   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
155139   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,   /* 1-39 */
r7237r7238
159143   0, 0, 0, 0, 0, 0, 0                                 /* 78-84 */
160144};
161145
146/***************************************************************************
147    TYPE DEFINITIONS
148***************************************************************************/
149
162150struct d64dsk_tag
163151{
164152   int dos;                           /* CBM DOS version */
r7237r7238
172160   UINT8 id1, id2;                        /* DOS disk format ID */
173161};
174162
175INLINE float get_dos_track(int track)
163/***************************************************************************
164    INLINE FUNCTIONS
165***************************************************************************/
166
167INLINE struct d64dsk_tag *get_tag(floppy_image *floppy)
176168{
177   return ((float)track / 2) + 1;
169   return (d64dsk_tag *)floppy_tag(floppy);
178170}
179171
180static struct d64dsk_tag *get_tag(floppy_image *floppy)
172INLINE float get_dos_track(int track)
181173{
182   struct d64dsk_tag *tag;
183   tag = (d64dsk_tag *)floppy_tag(floppy);
184   return tag;
174   return ((float)track / 2) + 1;
185175}
186176
177/***************************************************************************
178    IMPLEMENTATION
179***************************************************************************/
180
181/*-------------------------------------------------
182    d64_get_heads_per_disk - returns the number
183   of heads in the disk image
184-------------------------------------------------*/
185
187186static int d64_get_heads_per_disk(floppy_image *floppy)
188187{
189188   return get_tag(floppy)->heads;
190189}
191190
191/*-------------------------------------------------
192    d64_get_tracks_per_disk - returns the number
193   of DOS tracks in the disk image
194-------------------------------------------------*/
195
192196static int d64_get_tracks_per_disk(floppy_image *floppy)
193197{
194198   return get_tag(floppy)->tracks;
195199}
196200
201/*-------------------------------------------------
202    d64_get_sectors_per_track - returns the number
203   of sectors per given track
204-------------------------------------------------*/
205
197206static int d64_get_sectors_per_track(floppy_image *floppy, int head, int track)
198207{
199208   int sectors_per_track = 0;
r7237r7238
202211   {
203212   case DOS1:   sectors_per_track = DOS1_SECTORS_PER_TRACK[track / 2]; break;
204213   case DOS2:   sectors_per_track = DOS2_SECTORS_PER_TRACK[track / 2]; break;
205   case DOS27:   sectors_per_track = DOS27_SECTORS_PER_TRACK[track];     break;
214   case DOS25:   sectors_per_track = DOS25_SECTORS_PER_TRACK[track];    break;
206215   }
207216
208217   return sectors_per_track;
209218}
210219
220/*-------------------------------------------------
221    get_track_offset - returns the offset within
222   the disk image for a given track
223-------------------------------------------------*/
224
211225static floperr_t get_track_offset(floppy_image *floppy, int head, int track, UINT64 *offset)
212226{
213227   struct d64dsk_tag *tag = get_tag(floppy);
r7237r7238
224238   return FLOPPY_ERROR_SUCCESS;
225239}
226240
227static const int bin_2_gcr[] =
228{
229   0x0a, 0x0b, 0x12, 0x13, 0x0e, 0x0f, 0x16, 0x17,
230   0x09, 0x19, 0x1a, 0x1b, 0x0d, 0x1d, 0x1e, 0x15
231};
241/*-------------------------------------------------
242    gcr_double_2_gcr - GCR decodes given data
243-------------------------------------------------*/
232244
233/* This could be of use if we ever implement saving in .d64 format, to convert back GCR -> d64 */
234/*
235static const int gcr_2_bin[] =
236{
237    -1, -1,   -1,   -1,
238    -1, -1,   -1,   -1,
239    -1, 0x08, 0x00, 0x01,
240    -1, 0x0c, 0x04, 0x05,
241    -1, -1,   0x02, 0x03,
242    -1, 0x0f, 0x06, 0x07,
243    -1, 0x09, 0x0a, 0x0b,
244    -1, 0x0d, 0x0e, -1
245};
246*/
247
248245/* gcr_double_2_gcr takes 4 bytes (a, b, c, d) and shuffles their nibbles to obtain 5 bytes in dest */
249246/* The result is basically res = (enc(a) << 15) | (enc(b) << 10) | (enc(c) << 5) | enc(d)
250247 * with res being 5 bytes long and enc(x) being the GCR encode of x.
251248 * In fact, we store the result as five separate bytes in the dest argument
252249 */
250
251/*
252
253 Commodore GCR format
254
255Original    Encoded
2564 bits      5 bits
257
2580000    ->  01010 = 0x0a
2590001    ->  01011 = 0x0b
2600010    ->  10010 = 0x12
2610011    ->  10011 = 0x13
2620100    ->  01110 = 0x0e
2630101    ->  01111 = 0x0f
2640110    ->  10110 = 0x16
2650111    ->  10111 = 0x17
2661000    ->  01001 = 0x09
2671001    ->  11001 = 0x19
2681010    ->  11010 = 0x1a
2691011    ->  11011 = 0x1b
2701100    ->  01101 = 0x0d
2711101    ->  11101 = 0x1d
2721110    ->  11110 = 0x1e
2731111    ->  10101 = 0x15
274
275We use the encoded values in bytes because we use them to encode
276groups of 4 bytes into groups of 5 bytes, below.
277
278*/
279
253280static void gcr_double_2_gcr(UINT8 a, UINT8 b, UINT8 c, UINT8 d, UINT8 *dest)
254281{
255282   UINT8 gcr[8];
r7237r7238
272299   dest[4] = (gcr[6] << 5) | gcr[7];
273300}
274301
302/*-------------------------------------------------
303    d64_read_track - reads a full track from the
304   disk image
305-------------------------------------------------*/
306
307/*
308
309   Commodore sector format
310
311   SYNC                  FF * 5
312   08
313   CHECKSUM               sector ^ track ^ id2 ^ id1
314   SECTOR                  0..20 (2040), 0..28 (8050)
315   TRACK                  1..35 (2040), 1..77 (8050), 1..70 (1571)
316   ID2
317   ID1
318   GAP 1                  55 * 9 (2040), 55 * 8 (1541)
319
320   SYNC                  FF * 5
321   07
322   NEXT TRACK
323   NEXT SECTOR
324   254 BYTES OF DATA
325   CHECKSUM
326   GAP 2                  55 * 8..19
327
328*/
329
275330static floperr_t d64_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen)
276331{
277332   struct d64dsk_tag *tag = get_tag(floppy);
r7237r7238
298353      /* determine logical track number */
299354      int dos_track = get_dos_track(track);
300355     
301      if (tag->dos == DOS27)
356      if (tag->dos == DOS25)
302357      {
303358         dos_track = track + 1;
304359      }
r7237r7238
422477   return FLOPPY_ERROR_SUCCESS;
423478}
424479
480/*-------------------------------------------------
481    d64_write_track - writes a full track to the
482   disk image
483-------------------------------------------------*/
484
425485static floperr_t d64_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen)
426486{
427487   return FLOPPY_ERROR_UNSUPPORTED;
428488}
429489
490/*-------------------------------------------------
491    d64_identify - identifies the disk image
492-------------------------------------------------*/
493
430494static void d64_identify(floppy_image *floppy, int *dos, int *heads, int *tracks, bool *has_errors)
431495{
432496   switch (floppy_image_size(floppy))
r7237r7238
447511   case D71_SIZE_70_TRACKS_WITH_ERRORS:   *dos = DOS2;  *heads = 2; *tracks = 35; *has_errors = true;  break;
448512
449513   /* 8050 */
450   case D80_SIZE_77_TRACKS:            *dos = DOS27; *heads = 1; *tracks = 77; *has_errors = false; break;
514   case D80_SIZE_77_TRACKS:            *dos = DOS25; *heads = 1; *tracks = 77; *has_errors = false; break;
451515
452516   /* 8250/SFD1001 */
453   case D82_SIZE_154_TRACKS:            *dos = DOS27; *heads = 2; *tracks = 77; *has_errors = false; break;
517   case D82_SIZE_154_TRACKS:            *dos = DOS25; *heads = 2; *tracks = 77; *has_errors = false; break;
454518   }
455519}
456520
521/*-------------------------------------------------
522    FLOPPY_IDENTIFY( d64_dsk_identify )
523-------------------------------------------------*/
524
457525FLOPPY_IDENTIFY( d64_dsk_identify )
458526{
459527   int dos = 0, heads, tracks;
r7237r7238
471539   return FLOPPY_ERROR_SUCCESS;
472540}
473541
542/*-------------------------------------------------
543    FLOPPY_IDENTIFY( d67_dsk_identify )
544-------------------------------------------------*/
545
474546FLOPPY_IDENTIFY( d67_dsk_identify )
475547{
476548   *vote = 0;
r7237r7238
483555   return FLOPPY_ERROR_SUCCESS;
484556}
485557
558/*-------------------------------------------------
559    FLOPPY_IDENTIFY( d71_dsk_identify )
560-------------------------------------------------*/
561
486562FLOPPY_IDENTIFY( d71_dsk_identify )
487563{
488564   int heads = 0, tracks = 0, dos;
r7237r7238
500576   return FLOPPY_ERROR_SUCCESS;
501577}
502578
579/*-------------------------------------------------
580    FLOPPY_IDENTIFY( d80_dsk_identify )
581-------------------------------------------------*/
582
503583FLOPPY_IDENTIFY( d80_dsk_identify )
504584{
505585   *vote = 0;
r7237r7238
512592   return FLOPPY_ERROR_SUCCESS;
513593}
514594
595/*-------------------------------------------------
596    FLOPPY_IDENTIFY( d82_dsk_identify )
597-------------------------------------------------*/
598
515599FLOPPY_IDENTIFY( d82_dsk_identify )
516600{
517601   *vote = 0;
r7237r7238
524608   return FLOPPY_ERROR_SUCCESS;
525609}
526610
611/*-------------------------------------------------
612    FLOPPY_CONSTRUCT( d64_dsk_construct )
613-------------------------------------------------*/
614
527615FLOPPY_CONSTRUCT( d64_dsk_construct )
528616{
529617   struct FloppyCallbacks *callbacks;
r7237r7238
559647      logerror("D64 size: %04x\n", (UINT32)floppy_image_size(floppy));
560648      logerror("D64 heads: %u\n", heads);
561649      logerror("D64 tracks: %u\n", dos_tracks);
650      logerror("D64 DOS version: %s\n", DOS_VERSION[dos]);
562651   }
563652
564653   /* determine track data offsets */
r7237r7238
566655   {
567656      for (track = 0; track < tag->tracks; track++)
568657      {
569         if (dos == DOS27)
658         if (dos == DOS25)
570659         {
571660            if (track >= dos_tracks)
572661            {
r7237r7238
576665            else
577666            {
578667               tag->track_offset[head][track] = track_offset;
579               track_offset += DOS27_SECTORS_PER_TRACK[track] * SECTOR_SIZE;
668               track_offset += DOS25_SECTORS_PER_TRACK[track] * SECTOR_SIZE;
580669   
581               if (LOG) logerror("D64 head %u track %u data offset: %04x\n", head, track, tag->track_offset[head][track]);
670               if (LOG) logerror("D64 head %u track %u data offset: %04x\n", head, track + 1, tag->track_offset[head][track]);
582671            }
583672         }
584673         else
r7237r7238
607696   /* determine speed zones */
608697   for (track = 0; track < tag->tracks; track++)
609698   {
610      if (dos == DOS27)
699      if (dos == DOS25)
611700      {
612         tag->speed_zone[track] = DOS27_SPEED_ZONE[track];
701         tag->speed_zone[track] = DOS25_SPEED_ZONE[track];
613702
614         if (LOG) logerror("D64 track %u speed zone: %u\n", track, tag->speed_zone[track]);
703         if (LOG) logerror("D64 track %u speed zone: %u\n", track + 1, tag->speed_zone[track]);
615704      }
616705      else
617706      {
r7237r7238
622711   }
623712
624713   /* read format ID from directory */
625   if (dos == DOS27)
714   /*
715   id1, id2 are the same for extended d64 (i.e. with error tables), for d67 and for d71
716
717   for d81 they are at track 40 bytes 0x17 & 0x18
718   for d80 & d82 they are at track 39 bytes 0x18 & 0x19
719   */
720   if (dos == DOS25)
626721      floppy_image_read(floppy, id, tag->track_offset[0][39] + 0x18, 2);
627722   else
628723      floppy_image_read(floppy, id, tag->track_offset[0][34] + 0xa2, 2);
r7237r7238
642737
643738   return FLOPPY_ERROR_SUCCESS;
644739}
645
646/*
647id1, id2 are the same for extended d64 (i.e. with error tables), for d67 and for d71
648
649for d81 they are at track 40 bytes 0x17 & 0x18
650for d80 & d82 they are at track 39 bytes 0x18 & 0x19
651*/
src/mess/formats/g64_dsk.c
r7237r7238
1/*
1/*********************************************************************
22
3  Bytes: $0000-0007: File signature "GCR-1541"
4               0008: G64 version (presently only $00 defined)
5               0009: Number of tracks in image (usually $54, decimal 84)
6          000A-000B: Size of each stored track in bytes (usually  7928,  or
7                     $1EF8 in LO/HI format.
3    formats/g64_dsk.c
84
9  Bytes: $000C-000F: Offset  to  stored  track  1.0  ($000002AC,  in  LO/HI
10                     format, see below for more)
11          0010-0013: Offset to stored track 1.5 ($00000000)
12          0014-0017: Offset to stored track 2.0 ($000021A6)
13             ...
14          0154-0157: Offset to stored track 42.0 ($0004F8B6)
15          0158-015B: Offset to stored track 42.5 ($00000000)
5    Floppy format code for Commodore 1541 GCR disk images
166
17  Bytes: $015C-015F: Speed zone entry for track 1 ($03,  in  LO/HI  format,
18                     see below for more)
19          0160-0163: Speed zone entry for track 1.5 ($03)
20             ...
21          02A4-02A7: Speed zone entry for track 42 ($00)
22          02A8-02AB: Speed zone entry for track 42.5 ($00)
7*********************************************************************/
238
24  Bytes: $02AC-02AD: Actual size of stored track (7692 or $1E0C,  in  LO/HI
25                     format)
26          02AE-02AE+$1E0C: Track data
27
28*/
29
309/*
3110
3211    TODO:
r7237r7238
4019#include "formats/flopimg.h"
4120#include "devices/flopdrv.h"
4221
22/***************************************************************************
23    PARAMETERS
24***************************************************************************/
25
4326#define LOG 0
4427
4528#define HEADER_LENGTH   0x2ac            /* standard length for 84 half tracks */
4629#define MAX_TRACKS      84
4730
31/***************************************************************************
32    TYPE DEFINITIONS
33***************************************************************************/
34
4835struct g64dsk_tag
4936{
5037   int version;
38   int heads;                        /* number of physical heads */
5139   int tracks;                        /* number of physical tracks */
5240   UINT16 track_size;                  /* size of each track */
5341   UINT32 track_offset[MAX_TRACKS];      /* offset within data for each track */
5442   UINT32 speed_zone_offset[MAX_TRACKS];   /* offset within data for each track */
5543};
5644
57INLINE float get_dos_track(int track)
45/***************************************************************************
46    INLINE FUNCTIONS
47***************************************************************************/
48
49INLINE struct g64dsk_tag *get_tag(floppy_image *floppy)
5850{
59   return ((float)track / 2) + 1;
51   return (g64dsk_tag *)floppy_tag(floppy);
6052}
6153
62static struct g64dsk_tag *get_tag(floppy_image *floppy)
54INLINE float get_dos_track(int track)
6355{
64   struct g64dsk_tag *tag = (g64dsk_tag *)floppy_tag(floppy);
65   return tag;
56   return ((float)track / 2) + 1;
6657}
6758
59/***************************************************************************
60    IMPLEMENTATION
61***************************************************************************/
62
63/*-------------------------------------------------
64    g64_get_heads_per_disk - returns the number
65   of heads in the disk image
66-------------------------------------------------*/
67
6868static int g64_get_heads_per_disk(floppy_image *floppy)
6969{
70   return 1;
70   return get_tag(floppy)->heads;
7171}
7272
73/*-------------------------------------------------
74    g64_get_tracks_per_disk - returns the number
75   of DOS tracks in the disk image
76-------------------------------------------------*/
77
7378static int g64_get_tracks_per_disk(floppy_image *floppy)
7479{
7580   return get_tag(floppy)->tracks;
7681}
7782
83/*-------------------------------------------------
84    get_track_offset - returns the offset within
85   the disk image for a given track
86-------------------------------------------------*/
87
7888static floperr_t get_track_offset(floppy_image *floppy, int track, UINT64 *offset)
7989{
8090   struct g64dsk_tag *tag = get_tag(floppy);
r7237r7238
91101   return FLOPPY_ERROR_SUCCESS;
92102}
93103
104/*-------------------------------------------------
105   g64_read_track - reads a full track from the
106   disk image
107-------------------------------------------------*/
108
94109static floperr_t g64_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen)
95110{
96111   struct g64dsk_tag *tag = get_tag(floppy);
r7237r7238
122137   return FLOPPY_ERROR_SUCCESS;
123138}
124139
140/*-------------------------------------------------
141   g64_write_track - writes a full track to the
142   disk image
143-------------------------------------------------*/
144
125145static floperr_t g64_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen)
126146{
127147   return FLOPPY_ERROR_UNSUPPORTED;
128148}
129149
150/*-------------------------------------------------
151   FLOPPY_IDENTIFY( g64_dsk_identify )
152-------------------------------------------------*/
153
130154FLOPPY_IDENTIFY( g64_dsk_identify )
131155{
132156   UINT8 header[8];
r7237r7238
145169   return FLOPPY_ERROR_SUCCESS;
146170}
147171
172/*-------------------------------------------------
173   FLOPPY_CONSTRUCT( g64_dsk_construct )
174-------------------------------------------------*/
175
176/*
177
178   G64 File Header Format
179
180  Bytes: $0000-0007: File signature "GCR-1541"
181               0008: G64 version (presently only $00 defined)
182               0009: Number of tracks in image (usually $54, decimal 84)
183          000A-000B: Size of each stored track in bytes (usually  7928,  or
184                     $1EF8 in LO/HI format.
185
186  Bytes: $000C-000F: Offset  to  stored  track  1.0  ($000002AC,  in  LO/HI
187                     format, see below for more)
188          0010-0013: Offset to stored track 1.5 ($00000000)
189          0014-0017: Offset to stored track 2.0 ($000021A6)
190             ...
191          0154-0157: Offset to stored track 42.0 ($0004F8B6)
192          0158-015B: Offset to stored track 42.5 ($00000000)
193
194  Bytes: $015C-015F: Speed zone entry for track 1 ($03,  in  LO/HI  format,
195                     see below for more)
196          0160-0163: Speed zone entry for track 1.5 ($03)
197             ...
198          02A4-02A7: Speed zone entry for track 42 ($00)
199          02A8-02AB: Speed zone entry for track 42.5 ($00)
200
201  Bytes: $02AC-02AD: Actual size of stored track (7692 or $1E0C,  in  LO/HI
202                     format)
203          02AE-02AE+$1E0C: Track data
204
205*/
206
148207FLOPPY_CONSTRUCT( g64_dsk_construct )
149208{
150209   struct FloppyCallbacks *callbacks;
r7237r7238
169228   if (LOG) logerror("G64 version: %u\n", tag->version);
170229
171230   /* number of half tracks */
231   tag->heads = 1;
172232   tag->tracks = header[9];
173233   if (LOG) logerror("G64 tracks: %u\n", tag->tracks);
174234
src/mess/formats/d64_dsk.h
r7237r7238
22
33    formats/d64_dsk.h
44
5    Floppy format code for Commodore 1541 D64 disk images
5    Floppy format code for Commodore 2040/8050 type disk images
66
77*********************************************************************/
88
r7237r7238
1111
1212#include "formats/flopimg.h"
1313
14/***************************************************************************
15    PROTOTYPES
16***************************************************************************/
17
1418FLOPPY_IDENTIFY( d64_dsk_identify );
1519FLOPPY_IDENTIFY( d67_dsk_identify );
1620FLOPPY_IDENTIFY( d71_dsk_identify );
src/mess/formats/g64_dsk.h
r7237r7238
1111
1212#include "formats/flopimg.h"
1313
14/***************************************************************************
15    MACROS / CONSTANTS
16***************************************************************************/
17
18#define G64_SYNC_MARK      0x3ff      /* 10 consecutive 1-bits */
19
20#define G64_BUFFER_SIZE      16384
21#define G64_DATA_START      2
22
23const int C2040_BITRATE[] =
24{
25   XTAL_16MHz/13,   /* tracks 31-42 */
26   XTAL_16MHz/14,   /* tracks 25-30 */
27   XTAL_16MHz/15,    /* tracks 18-24 */
28   XTAL_16MHz/16   /* tracks  1-17 */
29};
30
31const int C8050_BITRATE[] =
32{
33   XTAL_12MHz/3/4,   /* tracks 65-84 */
34   XTAL_12MHz/3/5,   /* tracks 54-65 */
35   XTAL_12MHz/3/6, /* tracks 40-53 */
36   XTAL_12MHz/3/7   /* tracks  1-39 */
37};
38
39/***************************************************************************
40    PROTOTYPES
41***************************************************************************/
42
1443FLOPPY_IDENTIFY( g64_dsk_identify );
1544FLOPPY_CONSTRUCT( g64_dsk_construct );
1645

Previous 15994 Revisions Next


© 1998-2018 The MESS Team