Previous 15994 Revisions Next

r6633 Monday 14th December, 2009 at 21:29:50 UTC by Curt Coder
[C1571] Added device skeleton.
[src/mess]mess.mak
[src/mess/machine]c1541.c c1541.h c1571.c* c1571.h*

src/mess/machine/c1541.c
r6632r6633
1/**********************************************************************
2
3    Commodore 1540/1541 Single Disk Drive emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
110/*
211
312   1540/1541/1541A/SX-64 Parts
r6632r6633
209218{
210219   assert(device != NULL);
211220   assert(device->token != NULL);
212   assert(device->type == C1541);
221   assert((device->type == C1540) || (device->type == C1541));
213222   return (c1541_t *)device->token;
214223}
215224
216225INLINE c1541_config *get_safe_config(const device_config *device)
217226{
218227   assert(device != NULL);
219   assert(device->type == C1541);
228   assert((device->type == C1540) || (device->type == C1541));
220229   return (c1541_config *)device->inline_config;
221230}
222231
r6632r6633
703712   ROM_LOAD( "901229-03.uab5", 0xe000, 0x2000, CRC(9126e74a) SHA1(03d17bd745066f1ead801c5183ac1d3af7809744) )
704713   ROM_LOAD( "901229-04.uab5", 0xe000, 0x2000, NO_DUMP )
705714   ROM_LOAD( "901229-05 ae.uab5", 0xe000, 0x2000, CRC(361c9f37) SHA1(f5d60777440829e46dc91285e662ba072acd2d8b) )
706//   ROM_LOAD( "901229-06 aa.uab5", 0xe000, 0x2000, CRC(3a235039) SHA1(c7f94f4f51d6de4cdc21ecbb7e57bb209f0530c0) )
715   ROM_LOAD( "901229-06 aa.uab5", 0xe000, 0x2000, CRC(3a235039) SHA1(c7f94f4f51d6de4cdc21ecbb7e57bb209f0530c0) )
707716ROM_END
708717
709718/*-------------------------------------------------
src/mess/machine/c1541.h
r6632r6633
11/**********************************************************************
22
3    Commodore 1541 Single Disk Drive emulation
3    Commodore 1540/1541 Single Disk Drive emulation
44
55    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
src/mess/machine/c1571.c
r0r6633
1/**********************************************************************
2 
3    Commodore 1570/1571/1571CR Single Disk Drive emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************/
9 
10#include "driver.h"
11#include "c1571.h"
12#include "cpu/m6502/m6502.h"
13#include "devices/flopdrv.h"
14#include "formats/g64_dsk.h"
15#include "machine/6522via.h"
16#include "machine/6526cia.h"
17#include "machine/cbmserial.h"
18#include "machine/wd17xx.h"
19 
20/***************************************************************************
21    PARAMETERS
22***************************************************************************/
23 
24#define LOG 0
25 
26#define M6502_TAG      "u1"
27#define M6522_0_TAG      "u4"
28#define M6522_1_TAG      "u9"
29#define M6526_TAG      "u20"
30#define WD1770_TAG      "u11"
31 
32#define FLOPPY_TAG      "c1571_floppy"
33 
34/***************************************************************************
35    TYPE DEFINITIONS
36***************************************************************************/
37 
38typedef struct _c1571_t c1571_t;
39struct _c1571_t
40{
41   /* devices */
42   const device_config *cpu;
43   const device_config *via0;
44   const device_config *via1;
45   const device_config *cia;
46   const device_config *wd1770;
47   const device_config *serial_bus;
48   const device_config *image;
49};
50 
51/***************************************************************************
52    INLINE FUNCTIONS
53***************************************************************************/
54 
55INLINE c1571_t *get_safe_token(const device_config *device)
56{
57   assert(device != NULL);
58   assert(device->token != NULL);
59   assert((device->type == C1570) || (device->type == C1571) || (device->type == C1571CR));
60   return (c1571_t *)device->token;
61}
62 
63INLINE c1571_config *get_safe_config(const device_config *device)
64{
65   assert(device != NULL);
66   assert((device->type == C1570) || (device->type == C1571) || (device->type == C1571CR));
67   return (c1571_config *)device->inline_config;
68}
69 
70/***************************************************************************
71    IMPLEMENTATION
72***************************************************************************/
73 
74/*-------------------------------------------------
75    ADDRESS_MAP( c1570_map )
76-------------------------------------------------*/
77 
78static ADDRESS_MAP_START( c1570_map, ADDRESS_SPACE_PROGRAM, 8 )
79   AM_RANGE(0x0000, 0x07ff) AM_RAM
80   AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
81   AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
82   AM_RANGE(0x2000, 0x2003) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w)
83   AM_RANGE(0x4000, 0x400f) AM_DEVREADWRITE(M6526_TAG, cia_r, cia_w)
84   AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1570", 0)
85ADDRESS_MAP_END
86 
87/*-------------------------------------------------
88    ADDRESS_MAP( c1571_map )
89-------------------------------------------------*/
90 
91static ADDRESS_MAP_START( c1571_map, ADDRESS_SPACE_PROGRAM, 8 )
92   AM_RANGE(0x0000, 0x07ff) AM_RAM
93   AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
94   AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
95   AM_RANGE(0x2000, 0x2003) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w)
96   AM_RANGE(0x4000, 0x400f) AM_DEVREADWRITE(M6526_TAG, cia_r, cia_w)
97   AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1571", 0)
98ADDRESS_MAP_END
99 
100/*-------------------------------------------------
101    ADDRESS_MAP( c1571cr_map )
102-------------------------------------------------*/
103 
104static ADDRESS_MAP_START( c1571cr_map, ADDRESS_SPACE_PROGRAM, 8 )
105   AM_RANGE(0x0000, 0x07ff) AM_RAM
106   AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w)
107   AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w)
108//   AM_RANGE(0x2000, 0x2005) 5710 FDC
109//   AM_RANGE(0x400c, 0x400e) 5710 CIA
110//   AM_RANGE(0x4010, 0x4017) 5710 CIA
111//   AM_RANGE(0x6000, 0x7fff) RAM mirrors
112   AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1571cr", 0)
113ADDRESS_MAP_END
114 
115/*-------------------------------------------------
116    via6522_interface c1571_via0_intf
117-------------------------------------------------*/
118 
119static const via6522_interface c1571_via0_intf =
120{
121   DEVCB_NULL,
122   DEVCB_NULL,
123   DEVCB_NULL,
124   DEVCB_NULL,
125   DEVCB_NULL,
126   DEVCB_NULL,
127 
128   DEVCB_NULL,
129   DEVCB_NULL,
130   DEVCB_NULL,
131   DEVCB_NULL,
132   DEVCB_NULL,
133   DEVCB_NULL,
134 
135   DEVCB_NULL
136};
137 
138/*-------------------------------------------------
139    via6522_interface c1571_via1_intf
140-------------------------------------------------*/
141 
142static const via6522_interface c1571_via1_intf =
143{
144   DEVCB_NULL,
145   DEVCB_NULL,
146   DEVCB_NULL,
147   DEVCB_NULL,
148   DEVCB_NULL,
149   DEVCB_NULL,
150 
151   DEVCB_NULL,
152   DEVCB_NULL,
153   DEVCB_NULL,
154   DEVCB_NULL,
155   DEVCB_NULL,
156   DEVCB_NULL,
157 
158   DEVCB_NULL
159};
160 
161/*-------------------------------------------------
162    cia6526_interface c1571_cia_intf
163-------------------------------------------------*/
164 
165static const cia6526_interface c1571_cia_intf =
166{
167   DEVCB_NULL,
168   DEVCB_NULL,
169   10, /* 1/10 second */
170   {
171      { DEVCB_NULL, DEVCB_NULL },
172      { DEVCB_NULL, DEVCB_NULL }
173   }
174};
175 
176/*-------------------------------------------------
177    wd17xx_interface c1571_wd1770_intf
178-------------------------------------------------*/
179 
180static const wd17xx_interface c1571_wd1770_intf =
181{
182   DEVCB_NULL,
183   DEVCB_NULL,
184   { FLOPPY_0, NULL, NULL, NULL }
185};
186 
187/*-------------------------------------------------
188    FLOPPY_OPTIONS( c1571 )
189-------------------------------------------------*/
190 
191static FLOPPY_OPTIONS_START( c1571 )
192//   FLOPPY_OPTION( c1571, "d64", "Commodore 1541 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL )
193//   FLOPPY_OPTION( c1571, "d71", "Commodore 1571 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL )
194   FLOPPY_OPTION( c1571, "g64", "Commodore 1571 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL )
195FLOPPY_OPTIONS_END
196 
197/*-------------------------------------------------
198    floppy_config c1570_floppy_config
199-------------------------------------------------*/
200 
201static const floppy_config c1570_floppy_config =
202{
203   DEVCB_NULL,
204   DEVCB_NULL,
205   DEVCB_NULL,
206   DEVCB_NULL,
207   DEVCB_NULL,
208   FLOPPY_DRIVE_SS_80,
209   FLOPPY_OPTIONS_NAME(c1571),
210   DO_NOT_KEEP_GEOMETRY
211};
212 
213/*-------------------------------------------------
214    floppy_config c1571_floppy_config
215-------------------------------------------------*/
216 
217static const floppy_config c1571_floppy_config =
218{
219   DEVCB_NULL,
220   DEVCB_NULL,
221   DEVCB_NULL,
222   DEVCB_NULL,
223   DEVCB_NULL,
224   FLOPPY_DRIVE_DS_80,
225   FLOPPY_OPTIONS_NAME(c1571),
226   DO_NOT_KEEP_GEOMETRY
227};
228 
229/*-------------------------------------------------
230    MACHINE_DRIVER( c1570 )
231-------------------------------------------------*/
232 
233static MACHINE_DRIVER_START( c1570 )
234   MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
235   MDRV_CPU_PROGRAM_MAP(c1570_map)
236 
237   MDRV_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/16, c1571_via0_intf)
238   MDRV_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/16, c1571_via1_intf)
239   MDRV_CIA6526_ADD(M6526_TAG, CIA6526R1, XTAL_16MHz/16, c1571_cia_intf)
240   MDRV_WD1770_ADD(WD1770_TAG, c1571_wd1770_intf)
241 
242   MDRV_FLOPPY_DRIVE_ADD(FLOPPY_TAG, c1570_floppy_config)
243MACHINE_DRIVER_END
244 
245/*-------------------------------------------------
246    MACHINE_DRIVER( c1571 )
247-------------------------------------------------*/
248 
249static MACHINE_DRIVER_START( c1571 )
250   MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
251   MDRV_CPU_PROGRAM_MAP(c1571_map)
252 
253   MDRV_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/16, c1571_via0_intf)
254   MDRV_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/16, c1571_via1_intf)
255   MDRV_CIA6526_ADD(M6526_TAG, CIA6526R1, XTAL_16MHz/16, c1571_cia_intf)
256   MDRV_WD1770_ADD(WD1770_TAG, c1571_wd1770_intf)
257 
258   MDRV_FLOPPY_DRIVE_ADD(FLOPPY_TAG, c1571_floppy_config)
259MACHINE_DRIVER_END
260 
261/*-------------------------------------------------
262    MACHINE_DRIVER( c1571cr )
263-------------------------------------------------*/
264 
265static MACHINE_DRIVER_START( c1571cr )
266   MDRV_CPU_ADD(M6502_TAG, M6502, XTAL_16MHz/16)
267   MDRV_CPU_PROGRAM_MAP(c1571cr_map)
268 
269   MDRV_VIA6522_ADD(M6522_0_TAG, XTAL_16MHz/16, c1571_via0_intf)
270   MDRV_VIA6522_ADD(M6522_1_TAG, XTAL_16MHz/16, c1571_via1_intf)
271   MDRV_CIA6526_ADD(M6526_TAG, CIA6526R1, XTAL_16MHz/16, c1571_cia_intf)
272   MDRV_WD1770_ADD(WD1770_TAG, c1571_wd1770_intf)
273 
274   MDRV_FLOPPY_DRIVE_ADD(FLOPPY_TAG, c1571_floppy_config)
275MACHINE_DRIVER_END
276 
277/*-------------------------------------------------
278    ROM( c1570 )
279-------------------------------------------------*/
280 
281ROM_START( c1570 )
282   ROM_REGION( 0x8000, "c1570", ROMREGION_LOADBYNAME )
283   ROM_LOAD( "315090-01.u2", 0x0000, 0x8000, CRC(5a0c7937) SHA1(5fc06dc82ff6840f183bd43a4d9b8a16956b2f56) )
284ROM_END
285 
286/*-------------------------------------------------
287    ROM( c1571 )
288-------------------------------------------------*/
289 
290ROM_START( c1571 )
291   ROM_REGION( 0x8000, "c1571", ROMREGION_LOADBYNAME )
292   ROM_LOAD( "310654-03.u2", 0x0000, 0x8000, CRC(3889b8b8) SHA1(e649ef4419d65829d2afd65e07d31f3ce147d6eb) )
293   ROM_LOAD( "310654-05.u2", 0x0000, 0x8000, CRC(5755bae3) SHA1(f1be619c106641a685f6609e4d43d6fc9eac1e70) )
294ROM_END
295 
296/*-------------------------------------------------
297    ROM( c1571cr )
298-------------------------------------------------*/
299 
300ROM_START( c1571cr )
301   ROM_REGION( 0x8000, "c1571cr", ROMREGION_LOADBYNAME )
302   ROM_LOAD( "318047-01.", 0x0000, 0x8000, CRC(f24efcc4) SHA1(14ee7a0fb7e1c59c51fbf781f944387037daa3ee) )
303ROM_END
304 
305/*-------------------------------------------------
306    DEVICE_START( c1571 )
307-------------------------------------------------*/
308 
309static DEVICE_START( c1571 )
310{
311}
312 
313/*-------------------------------------------------
314    DEVICE_RESET( c1571 )
315-------------------------------------------------*/
316 
317static DEVICE_RESET( c1571 )
318{
319}
320 
321/*-------------------------------------------------
322    DEVICE_GET_INFO( c1570 )
323-------------------------------------------------*/
324 
325DEVICE_GET_INFO( c1570 )
326{
327   switch (state)
328   {
329      /* --- the following bits of info are returned as 64-bit signed integers --- */
330      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(c1571_t);                           break;
331      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(c1571_config);                        break;
332      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                     break;
333 
334      /* --- the following bits of info are returned as pointers --- */
335      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c1570);                     break;
336      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_DRIVER_NAME(c1570);         break;
337 
338      /* --- the following bits of info are returned as pointers to data or functions --- */
339      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(c1571);                  break;
340      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
341      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(c1571);                  break;
342 
343      /* --- the following bits of info are returned as NULL-terminated strings --- */
344      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 1570");                     break;
345      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Commodore 1571");                     break;
346      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
347      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
348      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
349   }
350}
351 
352/*-------------------------------------------------
353    DEVICE_GET_INFO( c1571 )
354-------------------------------------------------*/
355 
356DEVICE_GET_INFO( c1571 )
357{
358   switch (state)
359   {
360      /* --- the following bits of info are returned as 64-bit signed integers --- */
361      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(c1571_t);                           break;
362      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(c1571_config);                        break;
363      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                     break;
364 
365      /* --- the following bits of info are returned as pointers --- */
366      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c1571);                     break;
367      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_DRIVER_NAME(c1571);         break;
368 
369      /* --- the following bits of info are returned as pointers to data or functions --- */
370      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(c1571);                  break;
371      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
372      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(c1571);                  break;
373 
374      /* --- the following bits of info are returned as NULL-terminated strings --- */
375      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 1571");                     break;
376      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Commodore 1571");                     break;
377      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
378      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
379      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
380   }
381}
382 
383 
384/*-------------------------------------------------
385    DEVICE_GET_INFO( c1571cr )
386-------------------------------------------------*/
387 
388DEVICE_GET_INFO( c1571cr )
389{
390   switch (state)
391   {
392      /* --- the following bits of info are returned as 64-bit signed integers --- */
393      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(c1571_t);                           break;
394      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(c1571_config);                        break;
395      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                     break;
396 
397      /* --- the following bits of info are returned as pointers --- */
398      case DEVINFO_PTR_ROM_REGION:               info->romregion = ROM_NAME(c1571);                     break;
399      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_DRIVER_NAME(c1571);         break;
400 
401      /* --- the following bits of info are returned as pointers to data or functions --- */
402      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(c1571);                  break;
403      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
404      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(c1571);                  break;
405 
406      /* --- the following bits of info are returned as NULL-terminated strings --- */
407      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore 1571CR");                  break;
408      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Commodore 1571");                     break;
409      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
410      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
411      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
412   }
413}
src/mess/machine/c1571.h
r0r6633
1/**********************************************************************
2 
3    Commodore 1570/1571/1571CR Single Disk Drive emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8**********************************************************************/
9 
10#ifndef __C1571__
11#define __C1571__
12 
13#include "driver.h"
14 
15/***************************************************************************
16    MACROS / CONSTANTS
17***************************************************************************/
18 
19#define C1570 DEVICE_GET_INFO_NAME( c1570 )
20#define C1571 DEVICE_GET_INFO_NAME( c1571 )
21#define C1571CR DEVICE_GET_INFO_NAME( c1571cr )
22 
23#define MDRV_C1570_ADD(_tag, _serial_bus_tag, _address) \
24   MDRV_DEVICE_ADD(_tag, C1570, 0) \
25   MDRV_DEVICE_CONFIG_DATAPTR(c1571_config, serial_bus_tag, _serial_bus_tag) \
26   MDRV_DEVICE_CONFIG_DATA32(c1571_config, address, _address)
27 
28#define MDRV_C1571_ADD(_tag, _serial_bus_tag, _address) \
29   MDRV_DEVICE_ADD(_tag, C1571, 0) \
30   MDRV_DEVICE_CONFIG_DATAPTR(c1571_config, serial_bus_tag, _serial_bus_tag) \
31   MDRV_DEVICE_CONFIG_DATA32(c1571_config, address, _address)
32 
33#define MDRV_C1571CR_ADD(_tag, _serial_bus_tag, _address) \
34   MDRV_DEVICE_ADD(_tag, C1571CR, 0) \
35   MDRV_DEVICE_CONFIG_DATAPTR(c1571_config, serial_bus_tag, _serial_bus_tag) \
36   MDRV_DEVICE_CONFIG_DATA32(c1571_config, address, _address)
37 
38/***************************************************************************
39    TYPE DEFINITIONS
40***************************************************************************/
41 
42typedef struct _c1571_config c1571_config;
43struct _c1571_config
44{
45   const char *serial_bus_tag;   /* serial bus device */
46   int address;            /* serial address */
47};
48 
49/***************************************************************************
50    PROTOTYPES
51***************************************************************************/
52 
53/* device interface */
54DEVICE_GET_INFO( c1570 );
55DEVICE_GET_INFO( c1571 );
56DEVICE_GET_INFO( c1571cr );
57 
58#endif
src/mess/mess.mak
r6632r6633
687687   $(MESS_VIDEO)/vic6560.o      \
688688   $(MESS_MACHINE)/cbmserial.o   \
689689   $(MESS_MACHINE)/c1541.o      \
690   $(MESS_MACHINE)/c1571.o      \
690691   $(MESS_FORMATS)/g64_dsk.o   \
691692
692693$(MESSOBJ)/cbmshare.a:         \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team