Previous 15994 Revisions Next

r3313 Sunday 21st September, 2008 at 23:10:46 UTC by Fabio Priuli
[CBM] added small bits here and there
[src/mess/includes]vc1541.h
[src/mess/machine]vc1541.c

src/mess/includes/vc1541.h
r3312r3313
3030};
3131
3232enum {
33format_d64 = 0,
34format_d64_err,
35format_d64_40t,
36format_d64_40t_err,
37format_d67,
38format_d71,
39format_d71_err,
40format_d81,
41format_d80,
42format_d82,
43format_g64,
33format_d64 = 0,         /* 1541 image, 35 tracks */
34format_d64_err,         /* 1541 image, 35 tracks + error table */
35format_d64_40t,         /* 1541 image, 40 tracks */
36format_d64_40t_err,      /* 1541 image, 40 tracks + error table */
37format_d67,            /* 2040 image, 35 tracks DOS1 format */
38format_d71,            /* 1571 image, 70 tracks */
39format_d71_err,         /* 1571 image, 70 tracks + error table */
40format_d81,            /* 1581 image, 80 tracks */
41format_d80,            /* 8050 image, 77 tracks */
42format_d82,            /* 8250 image, 154 tracks (read as 77?) */
43format_g64,            /* 1541 image in GCR format */
4444};
4545
4646
r3312r3313
4848void drive_reset(void);
4949
5050void vc1541_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
51void c2031_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
5251void c1551_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
5352void c1571_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
53/* the ones below are still not used in any drivers */
54void c1581_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
55void c2031_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
56void c2040_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
57void c8050_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
58void c8250_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
5459
60
5561MACHINE_DRIVER_EXTERN( cpu_vc1540 );
5662MACHINE_DRIVER_EXTERN( cpu_vc1541 );
5763MACHINE_DRIVER_EXTERN( cpu_c2031 );
src/mess/machine/vc1541.c
r3312r3313
9797
9898 */
9999/* 2008-09 FP
100started some work on the floppy emulation code:
100Started some work on the floppy emulation code:
101101   + made the functions / structs less vc1541-centric & d64-centric
102102   + unified config & reset functions, using type variable
103103      to choose the actions to be done
104104   + moved GCR encoding at loading time (wip untested code)
105105 
106a limitation is clear: only a single occurrence of emulated drive
106A limitation is clear: only a single occurrence of emulated drive
107107is expected.
108at a later stage, at least drive_config & drive_reset will need
108At a later stage, at least drive_config & drive_reset will need
109109an index to choose between the drives
110In the end, we could also split the floppy drives emulation from the
111disk image handling...
110112
111current status:
113Current status:
112114   + preliminary vc1541 & c1551 implementation (seems very slow)
113115   + no support for other drive types (even if now I list all
114116      the variants supported by Vice in the enum)
115117   + communications between the drive CPU and the computer CPU have
116118      to be checked, debugged and improved
117   + most functions / constants are d64 independent, even if other
118      formats are not supported yet!
119   + all but .g64 images should be correctly encoded at loading time
120      (I actually have doubts about some .d82 details)
121   + error maps are not still used, even if their presence is
122      acknowledged
119123   + the floppy handling still uses CBM_Drive_Emu struct instead of
120124      functions similar to other floppy formats
121125*/
126/*
127Informations on the fileformats (which the code is based on)
122128
129D64 - http://ist.uwaterloo.ca/~schepers/formats/D64.TXT
130D71 - http://ist.uwaterloo.ca/~schepers/formats/D71.TXT
131D81 - http://ist.uwaterloo.ca/~schepers/formats/D81.TXT
132D80 & D82 - http://ist.uwaterloo.ca/~schepers/formats/D80-D82.TXT
133G64 & GCR - http://ist.uwaterloo.ca/~schepers/formats/G64.TXT
134GCR - http://www.baltissen.org/newhtm/1541c.htm
135
136*/
137
138
123139#include "driver.h"
124140#include "deprecat.h"
125141#include "image.h"
r3312r3313
199215
200216   struct {
201217      int sync;            // active after > 9 '1's
218      int ones_count;
202219      int ready;            // needed for 1551
203      int ones_count;         // still needed?
204220      UINT8 data[0x500000];   // entire d64 image encoded at loading time
205221   } gcr;
206222} CBM_Drive_Emu;
r3312r3313
228244   19, 19, 19, 19, 19, 19, 19,
229245   18, 18, 18, 18, 18, 18,
230246   17, 17, 17, 17, 17,
231   17, 17, 17, 17, 17      /* only for 40 tracks d64 */
247   17, 17, 17, 17, 17,      /* only for 40 tracks d64 */
248   17, 17               /* in principle the drive could read 42 tracks */
232249};
233250
234251#define D71_MAX_TRACKS 70
r3312r3313
261278};
262279
263280
281/* Still have to investigate if these are read as 154 or as 77 in the drive... */
282/* For now we assume it's 154, but I'm not sure */
264283#define D82_MAX_TRACKS 154
265284
266285static const int d82_sectors_per_track[] =
r3312r3313
278297};
279298
280299
300static const int max_tracks_per_format[] =
301{
302D64_MAX_TRACKS,
303D64_MAX_TRACKS,
304D64_40T_MAX_TRACKS,
305D64_40T_MAX_TRACKS,
306D64_MAX_TRACKS,
307D71_MAX_TRACKS,
308D71_MAX_TRACKS,
309D81_MAX_TRACKS,
310D80_MAX_TRACKS,
311D82_MAX_TRACKS,
3120      /* Still to add support for .g64 */
313};
314
281315static int image_offset[IMAGE_MAX_TRACKS] = { 0 };
282316
283317
r3312r3313
299333   {
300334      case format_d64:
301335      case format_d64_err:
336      case format_d67:
302337         for (i = 1; i <= D64_MAX_TRACKS; i++)
303338            image_offset[i] = image_offset[i - 1] + d64_sectors_per_track[i - 1] * 256;
304339         break;
r3312r3313
331366         break;
332367
333368      default:
334         /* Still have to work on d67 & g64 images */
369         /* Still have to work on g64 images */
335370         logerror("Unsupported format\n");
336371         break;
337372   }
r3312r3313
389424      case format_d64_err:
390425      case format_d64_40t:
391426      case format_d64_40t_err:
427      case format_d67:
392428      case format_d71:
393429      case format_d71_err:
394430         id1 = image_tracksector2offset(18, 0) + 0xa2;
r3312r3313
404440         break;
405441
406442      default:
407         /* Still have to work on d67 & g64 images */
443         /* Still have to work on g64 images */
408444         logerror("Unsupported format\n");
409445         break;
410446   }
r3312r3313
423459      case format_d64_err:
424460      case format_d64_40t:
425461      case format_d64_40t_err:
462      case format_d67:
426463      case format_d71:
427464      case format_d71_err:
428465         id2 = image_tracksector2offset(18, 0) + 0xa3;
r3312r3313
438475         break;
439476
440477      default:
441         /* Still have to work on d67 & g64 images */
478         /* Still have to work on g64 images */
442479         logerror("Unsupported format\n");
443480         break;
444481   }
r3312r3313
14501487            return INIT_FAIL;
14511488      }
14521489   }
1490   else if (!mame_stricmp (filetype, "d67"))
1491      format = format_d67;
14531492   else if (!mame_stricmp (filetype, "d81"))
14541493      format = format_d81;
14551494   else if (!mame_stricmp (filetype, "d80"))
r3312r3313
14581497      format = format_d82;
14591498   else
14601499   {
1461      /* Still have to work on d67 & g64 images */
1500      /* Still have to work on g64 images */
14621501      logerror("Unsupported format\n");
14631502      return INIT_FAIL;
14641503   }
r3312r3313
14761515   format_id_1 = temp_copy[disk_id1(format)];   // can be modified by error code 29 -> ^ 0xff
14771516   format_id_2 = temp_copy[disk_id2(format)];
14781517
1479   for (k = 1; k <= D64_MAX_TRACKS; k++)
1518   for (k = 1; k <= max_tracks_per_format[format]; k++)
14801519   {
14811520/*      logerror("decoding track %d offset %d %d %d %d %d\n", k,
14821521                  image_tracksector2offset(k, 0) / (16*16*16*16),
r3312r3313
16091648
16101649void c1551_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
16111650{
1651   vc1541_device_getinfo(devclass, state, info);
1652}
1653
1654
1655void c1571_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
1656{
16121657   switch(state)
16131658   {
1614      /* --- the following bits of info are returned as pointers to data or functions --- */
1615      case MESS_DEVINFO_PTR_DEV_SPECIFIC:         info->f = (genf *) drive_config; break;
1659      /* --- the following bits of info are returned as NULL-terminated strings --- */
1660      case MESS_DEVINFO_STR_FILE_EXTENSIONS:      strcpy(info->s = device_temp_str(), "d71"); break;
16161661
1617      default: vc1541_device_getinfo(devclass, state, info); break;
1662      default:                           vc1541_device_getinfo(devclass, state, info);
16181663   }
16191664}
16201665
1666void c1581_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
1667{
1668   switch(state)
1669   {
1670      /* --- the following bits of info are returned as NULL-terminated strings --- */
1671      case MESS_DEVINFO_STR_FILE_EXTENSIONS:      strcpy(info->s = device_temp_str(), "d81"); break;
16211672
1622void c1571_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
1673      default:                           vc1541_device_getinfo(devclass, state, info);
1674   }
1675}
1676
1677void c8050_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
16231678{
1624   vc1541_device_getinfo(devclass, state, info);
1679   switch(state)
1680   {
1681      /* --- the following bits of info are returned as NULL-terminated strings --- */
1682      case MESS_DEVINFO_STR_FILE_EXTENSIONS:      strcpy(info->s = device_temp_str(), "d80"); break;
1683
1684      default:                           vc1541_device_getinfo(devclass, state, info);
1685   }
16251686}
1687
1688void c8250_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
1689{
1690   switch(state)
1691   {
1692      /* --- the following bits of info are returned as NULL-terminated strings --- */
1693      case MESS_DEVINFO_STR_FILE_EXTENSIONS:      strcpy(info->s = device_temp_str(), "d82"); break;
1694
1695      default:                           vc1541_device_getinfo(devclass, state, info);
1696   }
1697}
1698
1699void c2040_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
1700{
1701   switch(state)
1702   {
1703      /* --- the following bits of info are returned as NULL-terminated strings --- */
1704      case MESS_DEVINFO_STR_FILE_EXTENSIONS:      strcpy(info->s = device_temp_str(), "d67"); break;
1705
1706      default:                           vc1541_device_getinfo(devclass, state, info);
1707   }
1708}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team