Previous 15994 Revisions Next

r4825 Monday 25th May, 2009 at 08:09:35 UTC by Fabio Priuli
[CBM] Converted Commodore Serial Bus to be a device. The rest of the implementation has not been changed. Hence, do not expect astounding improvements. More work is definitely needed (see comments at top of machine/cbmserb.c)
[src/mess/drivers]c128.c c16.c c64.c c65.c primo.c vc20.c
[src/mess/includes]cbmdrive.h cbmserb.h vc1541.h
[src/mess/machine]c128.c c16.c c64.c c65.c cbmdrive.c cbmserb.c primo.c vc1541.c vc20.c

src/mess/includes/cbmserb.h
r4824r4825
99
1010/*----------- defined in machine/cbmserb.c -----------*/
1111
12/* through this interface, we choose between simulated and emulated drives */
13/* this is temporarily needed in order to be able to compile the code for both, without breaking anything */
14typedef struct _cbm_serial_interface cbm_serial_interface;
15struct _cbm_serial_interface
12#include "devcb.h"
13
14/***************************************************************************
15    MACROS / CONSTANTS
16***************************************************************************/
17
18#define CBM_SERBUS      DEVICE_GET_INFO_NAME(cbm_serial_bus)
19
20#define MDRV_CBM_SERBUS_ADD(_tag, _config) \
21   MDRV_DEVICE_ADD(_tag, CBM_SERBUS, 0) \
22   MDRV_DEVICE_CONFIG(_config)
23
24#define MDRV_CBM_SERBUS_REMOVE(_tag) \
25   MDRV_DEVICE_REMOVE(_tag)
26
27/***************************************************************************
28    TYPE DEFINITIONS
29***************************************************************************/
30
31typedef struct _cbm_serial_bus_interface cbm_serial_bus_interface;
32struct _cbm_serial_bus_interface
1633{
17   int serial;         /* This is just a parameter, to log which interface is in use */
18   void (*serial_reset_write)(running_machine *machine, int level);
19   int (*serial_request_read)(running_machine *machine);
20   void (*serial_request_write)(running_machine *machine, int level);
21   int (*serial_atn_read)(running_machine *machine);
22   int (*serial_data_read)(running_machine *machine);
23   int (*serial_clock_read)(running_machine *machine);
24   void (*serial_atn_write)(running_machine *machine, int level);
25   void (*serial_data_write)(running_machine *machine, int level);
26   void (*serial_clock_write)(running_machine *machine, int level);
34   devcb_read8 read_atn_func;
35   devcb_read8 read_clock_func;
36   devcb_read8 read_data_func;
37   devcb_read8 read_request_func;
38   devcb_write8 write_atn_func;
39   devcb_write8 write_clock_func;
40   devcb_write8 write_data_func;
41   devcb_write8 write_request_func;
42
43   devcb_write8 write_reset_func;
2744};
2845
29void cbm_serial_config(running_machine *machine, const cbm_serial_interface *intf);
46/***************************************************************************
47    PROTOTYPES
48***************************************************************************/
3049
31extern const cbm_serial_interface cbm_sim_drive_interface;      /* serial = 1 */
32extern const cbm_serial_interface cbm_emu_drive_interface;      /* serial = 2 */
33extern const cbm_serial_interface cbm_fake_drive_interface;   /* serial = 3 */
50/* device interface */
51DEVICE_GET_INFO( cbm_serial_bus );
3452
53READ8_DEVICE_HANDLER( cbm_serial_request_read );
54READ8_DEVICE_HANDLER( cbm_serial_atn_read );
55READ8_DEVICE_HANDLER( cbm_serial_data_read );
56READ8_DEVICE_HANDLER( cbm_serial_clock_read );
3557
36/* Serial bus for vic20, c64 & c16 with vc1541 and some printer */
58WRITE8_DEVICE_HANDLER( cbm_serial_request_write );
59WRITE8_DEVICE_HANDLER( cbm_serial_atn_write );
60WRITE8_DEVICE_HANDLER( cbm_serial_data_write );
61WRITE8_DEVICE_HANDLER( cbm_serial_clock_write );
3762
38/* To be passed directly to the drivers */
39void cbm_serial_reset_write (running_machine *machine, int level);
40int cbm_serial_atn_read (running_machine *machine);
41void cbm_serial_atn_write (running_machine *machine, int level);
42int cbm_serial_data_read (running_machine *machine);
43void cbm_serial_data_write (running_machine *machine, int level);
44int cbm_serial_clock_read (running_machine *machine);
45void cbm_serial_clock_write (running_machine *machine, int level);
46int cbm_serial_request_read (running_machine *machine);
47void cbm_serial_request_write (running_machine *machine, int level);
4863
49
5064#endif /* CBMSERB_H_ */
src/mess/includes/vc1541.h
r4824r4825
8282READ8_DEVICE_HANDLER( c1551x_read_status );
8383
8484
85/* serial bus for vic20, c64 & c16 with vc1541 and some printer */
86
87/* To be passed to serial bus emulation */
88void vc1541_serial_reset_write(running_machine *machine, int which, int level);
89int vc1541_serial_atn_read(running_machine *machine, int which);
90void vc1541_serial_atn_write(running_machine *machine, int which, int level);
91int vc1541_serial_data_read(running_machine *machine, int which);
92void vc1541_serial_data_write(running_machine *machine, int which, int level);
93int vc1541_serial_clock_read(running_machine *machine, int which);
94void vc1541_serial_clock_write(running_machine *machine, int which, int level);
95int vc1541_serial_request_read(running_machine *machine, int which);
96void vc1541_serial_request_write(running_machine *machine, int which, int level);
97
98
99
10085/* Floppy drive ROMs */
10186
10287/****************************************************************************
src/mess/includes/cbmdrive.h
r4824r4825
8585extern CBM_Serial cbm_serial;
8686
8787
88void cbm_drive_open_helper (void);
89void c1551_state (running_machine *machine, CBM_Drive * drive);
90void vc1541_state (running_machine *machine, CBM_Drive * drive);
91void c2031_state (running_machine *machine, CBM_Drive *drive);
88void cbm_drive_open_helper(void);
89void c1551_state(running_machine *machine, CBM_Drive * drive);
90void vc1541_state(running_machine *machine, CBM_Drive * drive);
91void c2031_state(running_machine *machine, CBM_Drive *drive);
9292
93void cbm_drive_0_config (int interface, int serialnr);
94void cbm_drive_1_config (int interface, int serialnr);
93void cbm_drive_0_config(int interface, int serialnr);
94void cbm_drive_1_config(int interface, int serialnr);
9595
9696
9797/* IEC interface for c16 with c1551 */
r4824r4825
110110READ8_DEVICE_HANDLER( c1551_1_read_status );
111111
112112
113/* Serial bus for vic20, c64 & c16 with vc1541 and some printer */
113MACHINE_DRIVER_EXTERN( simulated_drive );
114114
115/* To be passed to serial bus emulation */
116void drive_reset_write (CBM_Drive * drive, int level);
117int vc1541_atn_read (running_machine *machine, CBM_Drive * drive);
118int vc1541_data_read (running_machine *machine, CBM_Drive * drive);
119int vc1541_clock_read (running_machine *machine, CBM_Drive * drive);
120void vc1541_atn_write (running_machine *machine, CBM_Drive * drive, int level);
121void vc1541_data_write (running_machine *machine, CBM_Drive * drive, int level);
122void vc1541_clock_write (running_machine *machine, CBM_Drive * drive, int level);
123
124
125115void cbmfloppy_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
126116
127117
src/mess/machine/c65.c
r4824r4825
187187static READ8_DEVICE_HANDLER( c65_cia1_port_a_r )
188188{
189189   UINT8 value = 0xff;
190   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
190191
191   if (!serial_clock || !cbm_serial_clock_read (device->machine))
192   if (!serial_clock || !cbm_serial_clock_read(serbus, 0))
192193      value &= ~0x40;
193194
194   if (!serial_data || !cbm_serial_data_read (device->machine))
195   if (!serial_data || !cbm_serial_data_read(serbus, 0))
195196      value &= ~0x80;
196197
197198   return value;
r4824r4825
200201static WRITE8_DEVICE_HANDLER( c65_cia1_port_a_w )
201202{
202203   static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000};
204   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
203205
204   cbm_serial_clock_write (device->machine, serial_clock = !(data & 0x10));
205   cbm_serial_data_write (device->machine, serial_data = !(data & 0x20));
206   cbm_serial_atn_write (device->machine, serial_atn = !(data & 0x08));
206   cbm_serial_clock_write(serbus, 0, serial_clock = !(data & 0x10));
207   cbm_serial_data_write(serbus, 0, serial_data = !(data & 0x20));
208   cbm_serial_atn_write(serbus, 0, serial_atn = !(data & 0x08));
207209   c64_vicaddr = c64_memory + helper[data & 0x03];
208210}
209211
r4824r4825
10401042   /* clear upper memory */
10411043   memset(mess_ram + 128*1024, 0xff, mess_ram_size -  128*1024);
10421044
1043   cbm_serial_config(machine, &cbm_sim_drive_interface);
1044   cbm_serial_reset_write (machine, 0);
10451045   cbm_drive_0_config (SERIAL, 10);
10461046   cbm_drive_1_config (SERIAL, 11);
10471047   c64_vicaddr = c64_memory;
src/mess/machine/vc1541.c
r4824r4825
156156#include "cpu/m6502/m6502.h"
157157#include "machine/6525tpi.h"
158158#include "machine/6522via.h"
159#include "includes/cbmserb.h"
159160
160161#include "includes/vc1541.h"
161162
r4824r4825
703704}
704705
705706
707/**************************************
708
709   VC1541 Serial Bus Device Interface
710
711**************************************/
712
713/* 2009-05 FP - Note: I could use directly these functions as DEVICE_HANDLERs for
714the serial bus device, but these are also used in the VIA interface above, so I
715prefer to keep the handlers separated at this stage. Further work on the serial
716bus emulation should allow to remove the duplicated code. */
717
718static void vc1541_serial_reset_write( running_machine *machine, int which, int level )
719{
720}
721
722static UINT8 vc1541_serial_atn_read( running_machine *machine, int which )
723{
724/* there is no more cpu_getactivecpu! */
725#ifdef CPU_SYNC
726      if (cpu_getactivecpu()==0) cpu_sync();
727#endif
728   return serial.atn[0];
729}
730
731static void vc1541_serial_atn_write( running_machine *machine, int which, int level )
732{
733   const device_config *via_0 = devtag_get_device(machine, "_1541_via_0");
734#if 0
735   int value;
736#endif
737   if (serial.atn[1 + which] != level)
738   {
739/* there is no more cpu_getactivecpu! */
740#ifdef CPU_SYNC
741      if (cpu_getactivecpu()==0) cpu_sync();
742#endif
743      serial.atn[1 + which] = level;
744      if (serial.atn[0] != level)
745      {
746         serial.atn[0] = serial.atn[1] && serial.atn[2];
747         if (serial.atn[0] == level)
748         {
749         #if 0
750            DBG_LOG(machine, 1, "vc1541",("%d:%.4x atn %s\n",
751                            cpu_getactivecpu (),
752                            activecpu_get_pc(),
753                            serial.atn[0]?"ATN":"atn"));
754         #endif
755            via_ca1_w (via_0, 0, !level);
756#if 0
757            value = vc1541_drive->vc1541_serial.data;
758            if (vc1541_drive->vc1541_serial.acka != !level)
759               value = 0;
760            if (value != serial.data[2])
761            {
762               serial.data[2] = value;
763               if (serial.data[0] != value)
764               {
765                  serial.data[0] = serial.data[1] && serial.data[2];
766               }
767            }
768#endif
769         }
770      }
771   }
772}
773
774static UINT8 vc1541_serial_data_read( running_machine *machine, int which )
775{
776/* there is no more cpu_getactivecpu! */
777#ifdef CPU_SYNC
778      if (cpu_getactivecpu()==0) cpu_sync();
779#endif
780   return serial.data[0];
781}
782
783static void vc1541_serial_data_write( running_machine *machine, int which, int level )
784{
785   if (serial.data[1 + which] != level)
786   {
787/* there is no more cpu_getactivecpu! */
788#ifdef CPU_SYNC
789      if (cpu_getactivecpu()==0) cpu_sync();
790#endif
791      serial.data[1 + which] = level;
792      if (serial.data[0] != level)
793      {
794         serial.data[0] = serial.data[1] && serial.data[2];
795         #if 0
796         if (serial.data[0] == level)
797         {
798            DBG_LOG(machine, 1, "vc1541",("%d:%.4x data %s\n",
799                            cpu_getactivecpu (),
800                            activecpu_get_pc(),
801                            serial.data[0]?"DATA":"data"));
802         }
803         #endif
804      }
805   }
806}
807
808static UINT8 vc1541_serial_clock_read( running_machine *machine, int which )
809{
810/* there is no more cpu_getactivecpu! */
811#ifdef CPU_SYNC
812      if (cpu_getactivecpu()==0) cpu_sync();
813#endif
814   return serial.clock[0];
815}
816
817static void vc1541_serial_clock_write( running_machine *machine, int which, int level )
818{
819   if (serial.clock[1 + which] != level)
820   {
821/* there is no more cpu_getactivecpu! */
822#ifdef CPU_SYNC
823      if (cpu_getactivecpu()==0) cpu_sync();
824#endif
825      serial.clock[1 + which] = level;
826      if (serial.clock[0] != level)
827      {
828         serial.clock[0] = serial.clock[1] && serial.clock[2];
829         if (serial.clock[0] == level)
830         {
831/*            DBG_LOG(machine, 1, "vc1541",("%d:%.4x clock %s\n",
832                            cpu_getactivecpu (),
833                            activecpu_get_pc(),
834                            serial.clock[0]?"CLOCK":"clock"));*/
835         }
836      }
837   }
838}
839
840static UINT8 vc1541_serial_request_read( running_machine *machine, int which )
841{
842   return 1;
843}
844
845static void vc1541_serial_request_write( running_machine *machine, int which, int level )
846{
847}
848
849
850/* 2009-05 FP - TODO: better implementation of the DEVICE_HANDLERs below. Right now they are
851redundant (see also my Note above)  */
852static READ8_DEVICE_HANDLER( emu_drive_atn_read )
853{
854   return vc1541_serial_atn_read(device->machine, 0);
855}
856
857static READ8_DEVICE_HANDLER( emu_drive_clock_read )
858{
859   return vc1541_serial_clock_read(device->machine, 0);
860}
861
862static READ8_DEVICE_HANDLER( emu_drive_data_read )
863{
864   return vc1541_serial_data_read(device->machine, 0);
865}
866
867static READ8_DEVICE_HANDLER( emu_drive_request_read )
868{
869   return vc1541_serial_request_read(device->machine, 0);
870}
871   
872static WRITE8_DEVICE_HANDLER( emu_drive_atn_write )
873{
874   vc1541_serial_atn_write(device->machine, 0, data);
875}
876
877static WRITE8_DEVICE_HANDLER( emu_drive_clock_write )
878{
879   vc1541_serial_clock_write(device->machine, 0, data);
880}
881
882static WRITE8_DEVICE_HANDLER( emu_drive_data_write )
883{
884   vc1541_serial_data_write(device->machine, 0, data);
885}
886
887static WRITE8_DEVICE_HANDLER( emu_drive_request_write )
888{
889   vc1541_serial_request_write(device->machine, 0, data);
890}
891
892static WRITE8_DEVICE_HANDLER( emu_drive_reset_write )
893{
894   vc1541_serial_reset_write(device->machine, 0, data);
895}
896
897
898static const cbm_serial_bus_interface cbm_emu_drive_interface =
899{
900   DEVCB_HANDLER(emu_drive_atn_read),
901   DEVCB_HANDLER(emu_drive_clock_read),
902   DEVCB_HANDLER(emu_drive_data_read),
903   DEVCB_HANDLER(emu_drive_request_read),
904   DEVCB_HANDLER(emu_drive_atn_write),
905   DEVCB_HANDLER(emu_drive_clock_write),
906   DEVCB_HANDLER(emu_drive_data_write),
907   DEVCB_HANDLER(emu_drive_request_write),
908
909   DEVCB_HANDLER(emu_drive_reset_write)
910};
911
912
913
706914/**************************************************************************
707915 *   VIA 6522 at 0x1800
708916 *
r4824r4825
10151223};
10161224
10171225
1018void vc1541_serial_reset_write( running_machine *machine, int which, int level )
1019{
1020}
1021
1022int vc1541_serial_atn_read( running_machine *machine, int which )
1023{
1024/* there is no more cpu_getactivecpu! */
1025#ifdef CPU_SYNC
1026      if (cpu_getactivecpu()==0) cpu_sync();
1027#endif
1028   return serial.atn[0];
1029}
1030
1031void vc1541_serial_atn_write( running_machine *machine, int which, int level )
1032{
1033   const device_config *via_0 = devtag_get_device(machine, "_1541_via_0");
1034#if 0
1035   int value;
1036#endif
1037   if (serial.atn[1 + which] != level)
1038   {
1039/* there is no more cpu_getactivecpu! */
1040#ifdef CPU_SYNC
1041      if (cpu_getactivecpu()==0) cpu_sync();
1042#endif
1043      serial.atn[1 + which] = level;
1044      if (serial.atn[0] != level)
1045      {
1046         serial.atn[0] = serial.atn[1] && serial.atn[2];
1047         if (serial.atn[0] == level)
1048         {
1049         #if 0
1050            DBG_LOG(machine, 1, "vc1541",("%d:%.4x atn %s\n",
1051                            cpu_getactivecpu (),
1052                            activecpu_get_pc(),
1053                            serial.atn[0]?"ATN":"atn"));
1054         #endif
1055            via_ca1_w (via_0, 0, !level);
1056#if 0
1057            value = vc1541_drive->vc1541_serial.data;
1058            if (vc1541_drive->vc1541_serial.acka != !level)
1059               value = 0;
1060            if (value != serial.data[2])
1061            {
1062               serial.data[2] = value;
1063               if (serial.data[0] != value)
1064               {
1065                  serial.data[0] = serial.data[1] && serial.data[2];
1066               }
1067            }
1068#endif
1069         }
1070      }
1071   }
1072}
1073
1074int vc1541_serial_data_read( running_machine *machine, int which )
1075{
1076/* there is no more cpu_getactivecpu! */
1077#ifdef CPU_SYNC
1078      if (cpu_getactivecpu()==0) cpu_sync();
1079#endif
1080   return serial.data[0];
1081}
1082
1083void vc1541_serial_data_write( running_machine *machine, int which, int level )
1084{
1085   if (serial.data[1 + which] != level)
1086   {
1087/* there is no more cpu_getactivecpu! */
1088#ifdef CPU_SYNC
1089      if (cpu_getactivecpu()==0) cpu_sync();
1090#endif
1091      serial.data[1 + which] = level;
1092      if (serial.data[0] != level)
1093      {
1094         serial.data[0] = serial.data[1] && serial.data[2];
1095         #if 0
1096         if (serial.data[0] == level)
1097         {
1098            DBG_LOG(machine, 1, "vc1541",("%d:%.4x data %s\n",
1099                            cpu_getactivecpu (),
1100                            activecpu_get_pc(),
1101                            serial.data[0]?"DATA":"data"));
1102         }
1103         #endif
1104      }
1105   }
1106}
1107
1108int vc1541_serial_clock_read( running_machine *machine, int which )
1109{
1110/* there is no more cpu_getactivecpu! */
1111#ifdef CPU_SYNC
1112      if (cpu_getactivecpu()==0) cpu_sync();
1113#endif
1114   return serial.clock[0];
1115}
1116
1117void vc1541_serial_clock_write( running_machine *machine, int which, int level )
1118{
1119   if (serial.clock[1 + which] != level)
1120   {
1121/* there is no more cpu_getactivecpu! */
1122#ifdef CPU_SYNC
1123      if (cpu_getactivecpu()==0) cpu_sync();
1124#endif
1125      serial.clock[1 + which] = level;
1126      if (serial.clock[0] != level)
1127      {
1128         serial.clock[0] = serial.clock[1] && serial.clock[2];
1129         if (serial.clock[0] == level)
1130         {
1131/*            DBG_LOG(machine, 1, "vc1541",("%d:%.4x clock %s\n",
1132                            cpu_getactivecpu (),
1133                            activecpu_get_pc(),
1134                            serial.clock[0]?"CLOCK":"clock"));*/
1135         }
1136      }
1137   }
1138}
1139
1140int vc1541_serial_request_read( running_machine *machine, int which )
1141{
1142   return 1;
1143}
1144
1145void vc1541_serial_request_write( running_machine *machine, int which, int level )
1146{
1147}
1148
1149
11501226/**************************************
11511227
11521228   1541 / 1541B / 1541C / 1541II /
r4824r4825
13411417            + (int)(2 * (c1551_drive->track - (int)c1551_drive->track)) * 184 / 2;   // half track if needed (again, 184 comes from out loading choices)
13421418         }
13431419
1344         if ( (c1551_drive->motor != (data & 0x04)) || (c1551_drive->frequency != (data & 0x60)) )
1420         if ((c1551_drive->motor != (data & 0x04)) || (c1551_drive->frequency != (data & 0x60)))
13451421         {
13461422            double tme;
13471423            c1551_drive->motor = data & 0x04;
r4824r4825
15411617
15421618   MDRV_VIA6522_ADD("_1541_via_0", 0, vc1541_via0)
15431619   MDRV_VIA6522_ADD("_1541_via_1", 0, vc1541_via1)
1620
1621   MDRV_CBM_SERBUS_ADD("serial_bus", cbm_emu_drive_interface)
15441622MACHINE_DRIVER_END
15451623
15461624MACHINE_DRIVER_START( cpu_vc1541 )
r4824r4825
15531631
15541632   MDRV_VIA6522_ADD("_1541_via_0", 0, vc1541_via0)
15551633   MDRV_VIA6522_ADD("_1541_via_1", 0, vc1541_via1)
1634
1635   MDRV_CBM_SERBUS_ADD("serial_bus", cbm_emu_drive_interface)
15561636MACHINE_DRIVER_END
15571637
15581638MACHINE_DRIVER_START( cpu_c1571cr )
r4824r4825
15611641
15621642   MDRV_VIA6522_ADD("_1541_via_0", 0, vc1541_via0)
15631643   MDRV_VIA6522_ADD("_1541_via_1", 0, vc1541_via1)
1644
1645   MDRV_CBM_SERBUS_ADD("serial_bus", cbm_emu_drive_interface)
15641646MACHINE_DRIVER_END
15651647
15661648MACHINE_DRIVER_START( cpu_c1581 )
r4824r4825
15821664
15831665   /* tpi */
15841666   MDRV_TPI6525_ADD("c1551_tpi", c1551_tpi_intf)
1667
1668   MDRV_CBM_SERBUS_ADD("serial_bus", cbm_emu_drive_interface)   // in the current code, serial bus device is tied to the floppy drive
1669                                                // and c16 reads/writes to serial bus in m7501_port_r/w!
15851670MACHINE_DRIVER_END
15861671
15871672
src/mess/machine/c128.c
r4824r4825
237237static READ8_DEVICE_HANDLER( c128_cia1_port_a_r )
238238{
239239   UINT8 value = 0xff;
240   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
240241
241   if (!serial_clock || !cbm_serial_clock_read (device->machine))
242   if (!serial_clock || !cbm_serial_clock_read(serbus, 0))
242243      value &= ~0x40;
243244
244   if (!serial_data || !cbm_serial_data_read (device->machine))
245   if (!serial_data || !cbm_serial_data_read(serbus, 0))
245246      value &= ~0x80;
246247
247248   return value;
r4824r4825
250251static WRITE8_DEVICE_HANDLER( c128_cia1_port_a_w )
251252{
252253   static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000};
254   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
253255
254   cbm_serial_clock_write (device->machine, serial_clock = !(data & 0x10));
255   cbm_serial_data_write (device->machine, serial_data = !(data & 0x20));
256   cbm_serial_atn_write (device->machine, serial_atn = !(data & 0x08));
256   cbm_serial_clock_write(serbus, 0, serial_clock = !(data & 0x10));
257   cbm_serial_data_write(serbus, 0, serial_data = !(data & 0x20));
258   cbm_serial_atn_write(serbus, 0, serial_atn = !(data & 0x08));
257259   c64_vicaddr = c64_memory + helper[data & 0x03];
258260   c128_vicaddr = c64_memory + helper[data & 0x03] + c128_va1617;
259261}
r4824r4825
11941196{
11951197   if (emulated_drive)
11961198   {
1197      cbm_serial_config(machine, &cbm_emu_drive_interface);
11981199      drive_reset();
11991200   }
12001201   else if (c128_cia1_on)
12011202   {
1202      cbm_serial_config(machine, &cbm_sim_drive_interface);
1203      cbm_serial_reset_write(machine, 0);
12041203      cbm_drive_0_config(SERIAL, 8);
12051204      cbm_drive_1_config(SERIAL, 9);
12061205      serial_clock = serial_data = serial_atn = 1;
src/mess/machine/c16.c
r4824r4825
112112
113113void c16_m7501_port_write(const device_config *device, UINT8 direction, UINT8 data)
114114{
115   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
115116   int dat, atn, clk;
116117
117118   /* bit zero then output 0 */
118   cbm_serial_atn_write (device->machine, atn = !(data & 0x04));
119   cbm_serial_clock_write (device->machine, clk = !(data & 0x02));
120   cbm_serial_data_write (device->machine, dat = !(data & 0x01));
119   cbm_serial_atn_write(serbus, 0, atn = !(data & 0x04));
120   cbm_serial_clock_write(serbus, 0, clk = !(data & 0x02));
121   cbm_serial_data_write(serbus, 0, dat = !(data & 0x01));
121122
122123   cassette_output(devtag_get_device(device->machine, "cassette"), !(data & 0x02) ? -(0x5a9e >> 1) : +(0x5a9e >> 1));
123124   
r4824r4825
128129{
129130   UINT8 data = 0xff;
130131   UINT8 c16_port7501 = (UINT8) devtag_get_info_int(device->machine, "maincpu", CPUINFO_INT_M6510_PORT);
132   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
131133
132   if ((c16_port7501 & 0x01) || !cbm_serial_data_read(device->machine))
134   if ((c16_port7501 & 0x01) || !cbm_serial_data_read(serbus, 0))
133135      data &= ~0x80;
134136
135   if ((c16_port7501 & 0x02) || !cbm_serial_clock_read(device->machine))
137   if ((c16_port7501 & 0x02) || !cbm_serial_clock_read(serbus, 0))
136138      data &= ~0x40;
137139
138140//   data &= ~0x20; // port bit not in pinout
r4824r4825
566568   }
567569   if (has_vc1541)      /* vc1541 */
568570   {
569      cbm_serial_config(machine, &cbm_emu_drive_interface);
570571      drive_reset();
571572   }
572573   else                        /* simulated drives */
573574   {
574      cbm_serial_config(machine, &cbm_sim_drive_interface);
575      cbm_serial_reset_write(machine, 0);
576575      cbm_drive_0_config(SERIAL, 8);
577576      cbm_drive_1_config(SERIAL, 9);
578577   }
src/mess/machine/cbmdrive.c
r4824r4825
1010#include "includes/cbmdrive.h"
1111
1212#define VERBOSE_LEVEL 0
13#define DBG_LOG(MACHINE,N,M,A) \
13#define DBG_LOG( MACHINE, N, M, A ) \
1414   do { \
1515      if(VERBOSE_LEVEL >= N) \
1616      { \
r4824r4825
6969static int d64_offset[D64_MAX_TRACKS];         /* offset of begin of track in d64 file */
7070
7171/* must be called before other functions */
72void cbm_drive_open_helper (void)
72void cbm_drive_open_helper( void )
7373{
7474   int i;
7575
r4824r4825
7979}
8080
8181/* calculates offset to beginning of d64 file for sector beginning */
82static int d64_tracksector2offset (int track, int sector)
82static int d64_tracksector2offset( int track, int sector )
8383{
8484   return d64_offset[track - 1] + sector * 256;
8585}
8686
87static int cbm_compareNames (unsigned char *left, unsigned char *right)
87static int cbm_compareNames( unsigned char *left, unsigned char *right )
8888{
8989   int i;
9090
r4824r4825
106106/* searches program with given name in directory
107107 * delivers -1 if not found
108108 * or pos in image of directory node */
109static int d64_find (CBM_Drive * drive, unsigned char *name)
109static int d64_find( CBM_Drive * drive, unsigned char *name )
110110{
111111   int pos, track, sector, i;
112112
113   pos = d64_tracksector2offset (18, 0);
113   pos = d64_tracksector2offset(18, 0);
114114   track = drive->image[pos];
115115   sector = drive->image[pos + 1];
116116
117117   while ((track >= 1) && (track <= 35))
118118   {
119      pos = d64_tracksector2offset (track, sector);
119      pos = d64_tracksector2offset(track, sector);
120120      for (i = 2; i < 256; i += 32)
121121      {
122122         if (drive->image[pos + i] & 0x80)
123123         {
124            if (mame_stricmp ((char *) name, (char *) "*") == 0)
124            if (mame_stricmp((char *) name, (char *) "*") == 0)
125125               return pos + i;
126            if (cbm_compareNames (name, drive->image + pos + i + 3))
126            if (cbm_compareNames(name, drive->image + pos + i + 3))
127127               return pos + i;
128128         }
129129      }
r4824r4825
134134}
135135
136136/* reads file into buffer */
137static void d64_readprg (running_machine *machine, CBM_Drive * drive, int pos)
137static void d64_readprg( running_machine *machine, CBM_Drive * drive, int pos )
138138{
139139   int i;
140140
141141   for (i = 0; i < 16; i++)
142      drive->filename[i] = toupper (drive->image[pos + i + 3]);
142      drive->filename[i] = toupper(drive->image[pos + i + 3]);
143143
144144   drive->filename[i] = 0;
145145
146   pos = d64_tracksector2offset (drive->image[pos + 1], drive->image[pos + 2]);
146   pos = d64_tracksector2offset(drive->image[pos + 1], drive->image[pos + 2]);
147147
148148   i = pos;
149149   drive->size = 0;
150150   while (drive->image[i] != 0)
151151   {
152152      drive->size += 254;
153      i = d64_tracksector2offset (drive->image[i], drive->image[i + 1]);
153      i = d64_tracksector2offset(drive->image[i], drive->image[i + 1]);
154154   }
155155   drive->size += drive->image[i + 1];
156156
157   DBG_LOG (machine, 3, "d64 readprg", ("size %d\n", drive->size));
157   DBG_LOG(machine, 3, "d64 readprg", ("size %d\n", drive->size));
158158
159   drive->buffer = (UINT8*)realloc (drive->buffer, drive->size);
159   drive->buffer = (UINT8*)realloc(drive->buffer, drive->size);
160160   if (!drive->buffer)
161161      fatalerror("out of memory %s %d\n", __FILE__, __LINE__);
162162
163163   drive->size--;
164164
165   DBG_LOG (machine, 3, "d64 readprg", ("track: %d sector: %d\n",
165   DBG_LOG(machine, 3, "d64 readprg", ("track: %d sector: %d\n",
166166                        drive->image[pos + 1],
167167                        drive->image[pos + 2]));
168168
r4824r4825
170170   {
171171      if (i + 254 < drive->size)
172172      {                        /* not last sector */
173         memcpy (drive->buffer + i, drive->image + pos + 2, 254);
174         pos = d64_tracksector2offset (drive->image[pos + 0],
173         memcpy(drive->buffer + i, drive->image + pos + 2, 254);
174         pos = d64_tracksector2offset(drive->image[pos + 0],
175175                             drive->image[pos + 1]);
176         DBG_LOG (machine, 3, "d64 readprg", ("track: %d sector: %d\n",
176         DBG_LOG(machine, 3, "d64 readprg", ("track: %d sector: %d\n",
177177                              drive->image[pos],
178178                              drive->image[pos + 1]));
179179      }
180180      else
181181      {
182         memcpy (drive->buffer + i, drive->image + pos + 2, drive->size - i);
182         memcpy(drive->buffer + i, drive->image + pos + 2, drive->size - i);
183183      }
184184   }
185185}
186186
187187/* reads sector into buffer */
188static void d64_read_sector (CBM_Drive * drive, int track, int sector)
188static void d64_read_sector( CBM_Drive * drive, int track, int sector )
189189{
190190   int pos;
191191
192   snprintf (drive->filename, sizeof (drive->filename),
192   snprintf(drive->filename, sizeof (drive->filename),
193193           "track %d sector %d", track, sector);
194194
195195   pos = d64_tracksector2offset (track, sector);
196196
197   drive->buffer = (UINT8*)realloc (drive->buffer,256);
197   drive->buffer = (UINT8*)realloc(drive->buffer,256);
198198   if (!drive->buffer)
199199      fatalerror("out of memory %s %d\n", __FILE__, __LINE__);
200200
201201   logerror("d64 read track %d sector %d\n", track, sector);
202202
203   memcpy (drive->buffer, drive->image + pos, 256);
203   memcpy(drive->buffer, drive->image + pos, 256);
204204   drive->size = 256;
205205   drive->pos = 0;
206206}
207207
208208/* reads directory into buffer */
209static void d64_read_directory (CBM_Drive * drive)
209static void d64_read_directory( CBM_Drive * drive )
210210{
211211   int pos, track, sector, i, j, blocksfree, addr = 0x0101/*0x1001*/;
212212
213   drive->buffer = (UINT8*)realloc (drive->buffer, 8 * 18 * 25);
213   drive->buffer = (UINT8*)realloc(drive->buffer, 8 * 18 * 25);
214214   if (!drive->buffer)
215215      fatalerror("out of memory %s %d\n", __FILE__, __LINE__);
216216
217217   drive->size = 0;
218218
219   pos = d64_tracksector2offset (18, 0);
219   pos = d64_tracksector2offset(18, 0);
220220   track = drive->image[pos];
221221   sector = drive->image[pos + 1];
222222
r4824r4825
247247
248248   while ((track >= 1) && (track <= 35))
249249   {
250      pos = d64_tracksector2offset (track, sector);
250      pos = d64_tracksector2offset(track, sector);
251251      for (i = 2; i < 256; i += 32)
252252      {
253253         if (drive->image[pos + i] & 0x80)
r4824r4825
256256            + 256 * drive->image[pos + i + 29];
257257            char dummy[10];
258258
259            sprintf (dummy, "%d", blocks);
259            sprintf(dummy, "%d", blocks);
260260            len = strlen (dummy);
261261            addr += 29 - len;
262262            drive->buffer[drive->size++] = addr & 0xff;
r4824r4825
309309   drive->buffer[drive->size++] = addr >> 8;
310310   drive->buffer[drive->size++] = blocksfree & 0xff;
311311   drive->buffer[drive->size++] = blocksfree >> 8;
312   memcpy (drive->buffer + drive->size, "BLOCKS FREE", 11);
312   memcpy(drive->buffer + drive->size, "BLOCKS FREE", 11);
313313   drive->size += 11;
314314   drive->buffer[drive->size++] = 0;
315315
316   strcpy (drive->filename, "$");
316   strcpy(drive->filename, "$");
317317}
318318
319static int d64_command (running_machine *machine, CBM_Drive * drive, unsigned char *name)
319static int d64_command( running_machine *machine, CBM_Drive * drive, unsigned char *name )
320320{
321321   int pos;
322322
323323   /* name eventuell mit 0xa0 auffuellen */
324324
325   if (mame_stricmp ((char *) name, (char *) "$") == 0)
325   if (mame_stricmp((char *) name, (char *) "$") == 0)
326326   {
327      d64_read_directory (drive);
327      d64_read_directory(drive);
328328   }
329329   else
330330   {
r4824r4825
332332      {
333333         return 1;
334334      }
335      d64_readprg (machine, drive, pos);
335      d64_readprg(machine, drive, pos);
336336   }
337337   return 0;
338338}
r4824r4825
390390 load
391391  20 f0 name 3f
392392 */
393static void cbm_command (running_machine *machine, CBM_Drive * drive)
393static void cbm_command( running_machine *machine, CBM_Drive * drive )
394394{
395395   unsigned char name[20], type = 'P', mode = 0;
396396   int channel, head, track, sector;
r4824r4825
447447         drive->state = OPEN;
448448         drive->pos = 0;
449449      }
450      DBG_LOG (machine, 1, "cbm_open", ("%s %s type:%c %c\n", name,
450      DBG_LOG(machine, 1, "cbm_open", ("%s %s type:%c %c\n", name,
451451                         rc ? "failed" : "success", type, mode ? mode : ' '));
452452   }
453453   else if ((drive->cmdpos == 1) && (drive->cmdbuffer[0] == 0x5f))
r4824r4825
526526  * status 3 for file not found
527527  * or filedata ended with status 3
528528  */
529void c1551_state (running_machine *machine, CBM_Drive * drive)
529void c1551_state( running_machine *machine, CBM_Drive * drive )
530530{
531531   static int oldstate;
532532
r4824r4825
666666         drive->i.iec.state++;
667667         if ((drive->state == 0) || (drive->state == OPEN))
668668         {
669            DBG_LOG (machine, 1, "c1551", ("taken data %.2x\n",
669            DBG_LOG(machine, 1, "c1551", ("taken data %.2x\n",
670670                             drive->i.iec.datain));
671671            if (drive->cmdpos < sizeof (drive->cmdbuffer))
672672               drive->cmdbuffer[drive->cmdpos++] = drive->i.iec.datain;
673673         }
674674         else if (drive->state == WRITING)
675675         {
676            DBG_LOG (machine, 1, "c1551", ("written data %.2x\n", drive->i.iec.datain));
676            DBG_LOG(machine, 1, "c1551", ("written data %.2x\n", drive->i.iec.datain));
677677         }
678678         drive->i.iec.handshakeout = 1;
679679      }
r4824r4825
703703      threshold) > 0;
704704}
705705
706void vc1541_state (running_machine *machine, CBM_Drive * drive)
706void vc1541_state( running_machine *machine, CBM_Drive * drive )
707707{
708708   int oldstate = drive->i.serial.state;
709709
r4824r4825
858858            ((drive->i.serial.value == 0x3f) || (drive->i.serial.value == 0x5f)
859859             || ((drive->i.serial.value & 0xf0) == 0x60)))
860860         {
861            cbm_command (machine, drive);
861            cbm_command(machine, drive);
862862         }
863863         drive->i.serial.time = timer_get_time(machine);
864864         drive->i.serial.data = 0;
r4824r4825
13261326   switch (drive->i.ieee.state)
13271327   {
13281328   case 0:
1329      if (!cbm_ieee_dav_r(machine)) {
1330         drive->i.ieee.state=10;
1331      } else if (!cbm_ieee_atn_r(machine)) {
1332         drive->i.ieee.state=11;
1329      if (!cbm_ieee_dav_r(machine))
1330      {
1331         drive->i.ieee.state = 10;
1332      }
1333      else if (!cbm_ieee_atn_r(machine))
1334      {
1335         drive->i.ieee.state = 11;
13331336         cbm_ieee_ndac_w(machine, 1, 0);
13341337         logerror("arsch\n");
13351338      }
r4824r4825
13371340   case 1:
13381341      break;
13391342   case 10:
1340      if (cbm_ieee_dav_r(machine)) {
1343      if (cbm_ieee_dav_r(machine))
1344      {
13411345         drive->i.ieee.state++;
13421346         cbm_ieee_nrfd_w(machine, 1, 1);
13431347         cbm_ieee_ndac_w(machine, 1, 0);
13441348      }
13451349      break;
13461350   case 11:
1347      if (!cbm_ieee_dav_r(machine)) {
1351      if (!cbm_ieee_dav_r(machine))
1352      {
13481353         cbm_ieee_nrfd_w(machine, 1, 0);
1349         data=cbm_ieee_data_r(machine)^0xff;
1354         data = cbm_ieee_data_r(machine) ^ 0xff;
13501355         cbm_ieee_ndac_w(machine, 1, 1);
13511356         logerror("byte received %.2x\n",data);
1352         if (!cbm_ieee_atn_r(machine)&&((data&0x0f)==drive->i.ieee.device) ) {
1353            if ((data&0xf0)==0x40)
1354               drive->i.ieee.state=30;
1357         if (!cbm_ieee_atn_r(machine) && ((data & 0x0f) == drive->i.ieee.device))
1358         {
1359            if ((data & 0xf0) == 0x40)
1360               drive->i.ieee.state = 30;
13551361            else
1356               drive->i.ieee.state=20;
1362               drive->i.ieee.state = 20;
13571363            if (drive->cmdpos < sizeof (drive->cmdbuffer))
13581364               drive->cmdbuffer[drive->cmdpos++] = data;
1359         } else if ((data&0xf)==0xf) {
1365         }
1366         else if ((data&0xf) == 0xf)
1367         {
13601368            drive->i.ieee.state--;
1361         } else {
1369         }
1370         else
1371         {
13621372            drive->i.ieee.state++;
13631373         }
13641374      }
13651375      break;
13661376      /* wait until atn is released */
13671377   case 12:
1368      if (cbm_ieee_atn_r(machine)) {
1378      if (cbm_ieee_atn_r(machine))
1379      {
13691380         drive->i.ieee.state++;
13701381         cbm_ieee_nrfd_w(machine, 1, 0);
13711382      }
13721383      break;
13731384   case 13:
1374      if (!cbm_ieee_atn_r(machine)) {
1375         drive->i.ieee.state=10;
1385      if (!cbm_ieee_atn_r(machine))
1386      {
1387         drive->i.ieee.state = 10;
13761388/*         cbm_ieee_nrfd_w(machine, 1, 0); */
13771389      }
13781390      break;
13791391
13801392      /* receiving rest of command */
13811393   case 20:
1382      if (cbm_ieee_dav_r(machine)) {
1394      if (cbm_ieee_dav_r(machine))
1395      {
13831396         drive->i.ieee.state++;
13841397         cbm_ieee_nrfd_w(machine, 1, 1);
13851398         cbm_ieee_ndac_w(machine, 1, 0);
13861399      }
13871400      break;
13881401   case 21:
1389      if (!cbm_ieee_dav_r(machine)) {
1402      if (!cbm_ieee_dav_r(machine))
1403      {
13901404         cbm_ieee_nrfd_w(machine, 1, 0);
1391         data=cbm_ieee_data_r(machine)^0xff;
1405         data = cbm_ieee_data_r(machine) ^ 0xff;
13921406         logerror("byte received %.2x\n",data);
13931407         if (drive->cmdpos < sizeof (drive->cmdbuffer))
13941408            drive->cmdbuffer[drive->cmdpos++] = data;
1395         if (!cbm_ieee_atn_r(machine)&&((data&0xf)==0xf)) {
1409         if (!cbm_ieee_atn_r(machine) && ((data & 0xf) == 0xf))
1410         {
13961411            cbm_command(machine, drive);
1397            drive->i.ieee.state=10;
1398         } else
1399            drive->i.ieee.state=20;
1412            drive->i.ieee.state = 10;
1413         }
1414         else
1415            drive->i.ieee.state = 20;
1416
14001417         cbm_ieee_ndac_w(machine, 1, 1);
14011418      }
14021419      break;
14031420
14041421      /* read command */
14051422   case 30:
1406      if (cbm_ieee_dav_r(machine)) {
1423      if (cbm_ieee_dav_r(machine))
1424      {
14071425         drive->i.ieee.state++;
14081426         cbm_ieee_nrfd_w(machine, 1, 1);
14091427         cbm_ieee_ndac_w(machine, 1, 0);
14101428      }
14111429      break;
14121430   case 31:
1413      if (!cbm_ieee_dav_r(machine)) {
1431      if (!cbm_ieee_dav_r(machine))
1432      {
14141433         cbm_ieee_nrfd_w(machine, 1, 0);
1415         data=cbm_ieee_data_r(machine)^0xff;
1416         logerror("byte received %.2x\n",data);
1434         data = cbm_ieee_data_r(machine) ^ 0xff;
1435         logerror("byte received %.2x\n", data);
14171436         if (drive->cmdpos < sizeof (drive->cmdbuffer))
14181437            drive->cmdbuffer[drive->cmdpos++] = data;
14191438         cbm_command(machine, drive);
1420         if (drive->state==READING)
1439         if (drive->state == READING)
14211440            drive->i.ieee.state++;
14221441         else
1423            drive->i.ieee.state=10;
1442            drive->i.ieee.state = 10;
14241443         cbm_ieee_ndac_w(machine, 1, 1);
14251444      }
14261445      break;
14271446   case 32:
1428      if (cbm_ieee_dav_r(machine)) {
1447      if (cbm_ieee_dav_r(machine))
1448      {
14291449         cbm_ieee_nrfd_w(machine, 1, 1);
1430         drive->i.ieee.state=40;
1450         drive->i.ieee.state = 40;
14311451      }
14321452      break;
14331453   case 40:
1434      if (!cbm_ieee_ndac_r(machine)) {
1435         cbm_ieee_data_w(machine, 1, drive->buffer[drive->pos++]^0xff);
1436         if (drive->pos>=drive->size)
1454      if (!cbm_ieee_ndac_r(machine))
1455      {
1456         cbm_ieee_data_w(machine, 1, drive->buffer[drive->pos++] ^ 0xff);
1457         if (drive->pos >= drive->size)
14371458            cbm_ieee_eoi_w(machine, 1, 0);
14381459         cbm_ieee_dav_w(machine, 1, 0);
14391460         drive->i.ieee.state++;
14401461      }
14411462      break;
14421463   case 41:
1443      if (!cbm_ieee_nrfd_r(machine)) {
1464      if (!cbm_ieee_nrfd_r(machine))
1465      {
14441466         drive->i.ieee.state++;
14451467      }
14461468      break;
14471469   case 42:
1448      if (cbm_ieee_ndac_r(machine)) {
1470      if (cbm_ieee_ndac_r(machine))
1471      {
14491472         if (cbm_ieee_eoi_r(machine))
1450            drive->i.ieee.state=40;
1451         else {
1473            drive->i.ieee.state = 40;
1474
1475         else
1476         {
14521477            cbm_ieee_data_w(machine, 1, 0xff);
14531478            cbm_ieee_ndac_w(machine, 1, 0);
14541479            cbm_ieee_nrfd_w(machine, 1, 0);
14551480            cbm_ieee_eoi_w(machine, 1, 1);
1456            drive->i.ieee.state=10;
1481            drive->i.ieee.state = 10;
14571482         }
14581483         cbm_ieee_dav_w(machine, 1, 1);
14591484      }
r4824r4825
14681493             );
14691494}
14701495
1471/***********************************************
14721496
1473   Drive handling
1474
1475***********************************************/
1476
1477CBM_Drive cbm_drive[2];
1478
1479CBM_Serial cbm_serial;
1480
1481/* must be called before other functions */
1482static void cbm_drive_open (void)
1483{
1484   int i;
1485
1486   memset(cbm_drive, 0, sizeof(cbm_drive));
1487   memset(&cbm_serial, 0, sizeof(cbm_serial));
1488
1489   cbm_drive_open_helper ();
1490
1491   cbm_serial.count = 0;
1492   for (i = 0; i < sizeof (cbm_serial.atn) / sizeof (int); i++)
1493
1494   {
1495      cbm_serial.atn[i] =
1496         cbm_serial.data[i] =
1497         cbm_serial.clock[i] = 1;
1498   }
1499}
1500
1501static void cbm_drive_close (void)
1502{
1503   int i;
1504
1505   cbm_serial.count = 0;
1506   for (i = 0; i < sizeof (cbm_drive) / sizeof (CBM_Drive); i++)
1507   {
1508      cbm_drive[i].interface = 0;
1509     
1510      if( cbm_drive[i].buffer ) {
1511         free(cbm_drive[i].buffer);
1512         cbm_drive[i].buffer = NULL;
1513      }
1514
1515      if (cbm_drive[i].drive == D64_IMAGE)
1516         cbm_drive[i].image = NULL;
1517      cbm_drive[i].drive = 0;
1518   }
1519}
1520
1521
1522
1523static void cbm_drive_config (CBM_Drive * drive, int interface, int serialnr)
1524{
1525   int i;
1526
1527   if (interface==SERIAL)
1528      drive->i.serial.device=serialnr;
1529
1530   if (interface==IEEE)
1531      drive->i.ieee.device=serialnr;
1532
1533   if (drive->interface == interface)
1534      return;
1535
1536   if (drive->interface == SERIAL)
1537   {
1538      for (i = 0; (i < cbm_serial.count) && (cbm_serial.drives[i] != drive); i++) ;
1539      for (; i + 1 < cbm_serial.count; i++)
1540         cbm_serial.drives[i] = cbm_serial.drives[i + 1];
1541      cbm_serial.count--;
1542   }
1543
1544   drive->interface = interface;
1545
1546   if (drive->interface == IEC)
1547   {
1548      drive->i.iec.handshakein =
1549         drive->i.iec.handshakeout = 0;
1550      drive->i.iec.status = 0;
1551      drive->i.iec.dataout = drive->i.iec.datain = 0xff;
1552      drive->i.iec.state = 0;
1553   }
1554   else if (drive->interface == SERIAL)
1555   {
1556      cbm_serial.drives[cbm_serial.count++] = drive;
1557      drive_reset_write(drive, 0);
1558   }
1559}
1560
1561void cbm_drive_0_config (int interface, int serialnr)
1562{
1563   cbm_drive_config (cbm_drive, interface, serialnr);
1564}
1565void cbm_drive_1_config (int interface, int serialnr)
1566{
1567   cbm_drive_config (cbm_drive + 1, interface, serialnr);
1568}
1569
1570
1571void drive_reset_write (CBM_Drive * drive, int level)
1572{
1573   if (level == 0)
1574   {
1575      drive->i.serial.data =
1576         drive->i.serial.clock =
1577         drive->i.serial.atn = 1;
1578      drive->i.serial.state = 0;
1579   }
1580}
1581
1582
15831497/**************************************
15841498
15851499   C1551 handlers
r4824r4825
16711585
16721586/**************************************
16731587
1674   VC1541
1588   VC1541 Serial Bus Device Interface
16751589
16761590**************************************/
16771591
1678int vc1541_atn_read (running_machine *machine, CBM_Drive * drive)
1592static UINT8 vc1541_atn_read( running_machine *machine, CBM_Drive * drive )
16791593{
1680   vc1541_state (machine, drive);
1594   vc1541_state(machine, drive);
16811595   return drive->i.serial.atn;
16821596}
16831597
1684int vc1541_data_read (running_machine *machine, CBM_Drive * drive)
1598static UINT8 vc1541_data_read( running_machine *machine, CBM_Drive * drive )
16851599{
1686   vc1541_state (machine, drive);
1600   vc1541_state(machine, drive);
16871601   return drive->i.serial.data;
16881602}
16891603
1690int vc1541_clock_read (running_machine *machine, CBM_Drive * drive)
1604static UINT8 vc1541_clock_read( running_machine *machine, CBM_Drive * drive )
16911605{
1692   vc1541_state (machine, drive);
1606   vc1541_state(machine, drive);
16931607   return drive->i.serial.clock;
16941608}
16951609
1696void vc1541_data_write (running_machine *machine, CBM_Drive * drive, int level)
1610static void vc1541_data_write( running_machine *machine, CBM_Drive * drive, int level )
16971611{
1698   vc1541_state (machine, drive);
1612   vc1541_state(machine, drive);
16991613}
17001614
1701void vc1541_clock_write (running_machine *machine, CBM_Drive * drive, int level)
1615static void vc1541_clock_write( running_machine *machine, CBM_Drive * drive, int level )
17021616{
1703   vc1541_state (machine, drive);
1617   vc1541_state(machine, drive);
17041618}
17051619
1706void vc1541_atn_write (running_machine *machine, CBM_Drive * drive, int level)
1620static void vc1541_atn_write( running_machine *machine, CBM_Drive * drive, int level )
17071621{
1708   vc1541_state (machine, drive);
1622   vc1541_state(machine, drive);
17091623}
17101624
1625void drive_reset_write( CBM_Drive * drive, int level )
1626{
1627   if (level == 0)
1628   {
1629      drive->i.serial.data =
1630         drive->i.serial.clock =
1631         drive->i.serial.atn = 1;
1632      drive->i.serial.state = 0;
1633   }
1634}
17111635
1636static READ8_DEVICE_HANDLER( sim_drive_atn_read )
1637{
1638   int i;
1639
1640   cbm_serial.atn[0] = cbm_serial.atn[1];
1641   for (i = 0; i < cbm_serial.count; i++)
1642      cbm_serial.atn[0] &= cbm_serial.atn[i + 2] =
1643         vc1541_atn_read(device->machine, cbm_serial.drives[i]);
1644   return cbm_serial.atn[0];
1645}
1646
1647static READ8_DEVICE_HANDLER( sim_drive_clock_read )
1648{
1649   int i;
1650
1651   cbm_serial.clock[0] = cbm_serial.clock[1];
1652   for (i = 0; i < cbm_serial.count; i++)
1653      cbm_serial.clock[0] &= cbm_serial.clock[i + 2] =
1654         vc1541_clock_read(device->machine, cbm_serial.drives[i]);
1655   return cbm_serial.clock[0];
1656}
1657
1658static READ8_DEVICE_HANDLER( sim_drive_data_read )
1659{
1660   int i;
1661
1662   cbm_serial.data[0] = cbm_serial.data[1];
1663   for (i = 0; i < cbm_serial.count; i++)
1664      cbm_serial.data[0] &= cbm_serial.data[i + 2] =
1665         vc1541_data_read(device->machine, cbm_serial.drives[i]);
1666   return cbm_serial.data[0];
1667}
1668
1669static READ8_DEVICE_HANDLER( sim_drive_request_read )
1670{
1671   /* in c16 not connected */
1672   return 1;
1673}
1674
1675static WRITE8_DEVICE_HANDLER( sim_drive_atn_write )
1676{
1677   int i;
1678
1679   cbm_serial.atn[0] =
1680      cbm_serial.atn[1] = data;
1681   /* update line */
1682   for (i = 0; i < cbm_serial.count; i++)
1683      cbm_serial.atn[0] &= cbm_serial.atn[i + 2];
1684   /* inform drives */
1685   for (i = 0; i < cbm_serial.count; i++)
1686      vc1541_atn_write(device->machine, cbm_serial.drives[i], cbm_serial.atn[0]);
1687}
1688
1689static WRITE8_DEVICE_HANDLER( sim_drive_clock_write )
1690{
1691   int i;
1692
1693   cbm_serial.clock[0] =
1694      cbm_serial.clock[1] = data;
1695   /* update line */
1696   for (i = 0; i < cbm_serial.count; i++)
1697      cbm_serial.clock[0] &= cbm_serial.clock[i + 2];
1698   /* inform drives */
1699   for (i = 0; i < cbm_serial.count; i++)
1700      vc1541_clock_write(device->machine, cbm_serial.drives[i], cbm_serial.clock[0]);
1701}
1702
1703static WRITE8_DEVICE_HANDLER( sim_drive_data_write )
1704{
1705   int i;
1706
1707   cbm_serial.data[0] =
1708      cbm_serial.data[1] = data;
1709   /* update line */
1710   for (i = 0; i < cbm_serial.count; i++)
1711      cbm_serial.data[0] &= cbm_serial.data[i + 2];
1712   /* inform drives */
1713   for (i = 0; i < cbm_serial.count; i++)
1714      vc1541_data_write(device->machine, cbm_serial.drives[i], cbm_serial.data[0]);
1715}
1716
1717static WRITE8_DEVICE_HANDLER( sim_drive_request_write )
1718{
1719}
1720
1721static WRITE8_DEVICE_HANDLER( sim_drive_reset_write )
1722{
1723   int i;
1724
1725   for (i = 0; i < cbm_serial.count; i++)
1726      drive_reset_write(cbm_serial.drives[i], data);
1727   /* init bus signals */
1728}
1729
1730static const cbm_serial_bus_interface cbm_sim_drive_interface =
1731{
1732   DEVCB_HANDLER(sim_drive_atn_read),
1733   DEVCB_HANDLER(sim_drive_clock_read),
1734   DEVCB_HANDLER(sim_drive_data_read),
1735   DEVCB_HANDLER(sim_drive_request_read),
1736   DEVCB_HANDLER(sim_drive_atn_write),
1737   DEVCB_HANDLER(sim_drive_clock_write),
1738   DEVCB_HANDLER(sim_drive_data_write),
1739   DEVCB_HANDLER(sim_drive_request_write),
1740
1741   DEVCB_HANDLER(sim_drive_reset_write)
1742};
1743
1744
1745MACHINE_DRIVER_START( simulated_drive )
1746   MDRV_CBM_SERBUS_ADD("serial_bus", cbm_sim_drive_interface)
1747MACHINE_DRIVER_END
1748
1749
1750
1751/***********************************************
1752
1753   Drive handling
1754
1755***********************************************/
1756
1757CBM_Drive cbm_drive[2];
1758
1759CBM_Serial cbm_serial;
1760
1761/* must be called before other functions */
1762static void cbm_drive_open (void)
1763{
1764   int i;
1765
1766   memset(cbm_drive, 0, sizeof(cbm_drive));
1767   memset(&cbm_serial, 0, sizeof(cbm_serial));
1768
1769   cbm_drive_open_helper ();
1770
1771   cbm_serial.count = 0;
1772   for (i = 0; i < sizeof(cbm_serial.atn) / sizeof(int); i++)
1773
1774   {
1775      cbm_serial.atn[i] =
1776         cbm_serial.data[i] =
1777         cbm_serial.clock[i] = 1;
1778   }
1779}
1780
1781static void cbm_drive_close (void)
1782{
1783   int i;
1784
1785   cbm_serial.count = 0;
1786   for (i = 0; i < sizeof(cbm_drive) / sizeof(CBM_Drive); i++)
1787   {
1788      cbm_drive[i].interface = 0;
1789     
1790      if( cbm_drive[i].buffer )
1791      {
1792         free(cbm_drive[i].buffer);
1793         cbm_drive[i].buffer = NULL;
1794      }
1795
1796      if (cbm_drive[i].drive == D64_IMAGE)
1797         cbm_drive[i].image = NULL;
1798      cbm_drive[i].drive = 0;
1799   }
1800}
1801
1802
1803
1804static void cbm_drive_config( CBM_Drive * drive, int interface, int serialnr )
1805{
1806   int i;
1807
1808   if (interface == SERIAL)
1809      drive->i.serial.device = serialnr;
1810
1811   if (interface == IEEE)
1812      drive->i.ieee.device = serialnr;
1813
1814   if (drive->interface == interface)
1815      return;
1816
1817   if (drive->interface == SERIAL)
1818   {
1819      for (i = 0; (i < cbm_serial.count) && (cbm_serial.drives[i] != drive); i++);
1820      for (; i + 1 < cbm_serial.count; i++)
1821         cbm_serial.drives[i] = cbm_serial.drives[i + 1];
1822      cbm_serial.count--;
1823   }
1824
1825   drive->interface = interface;
1826
1827   if (drive->interface == IEC)
1828   {
1829      drive->i.iec.handshakein =
1830         drive->i.iec.handshakeout = 0;
1831      drive->i.iec.status = 0;
1832      drive->i.iec.dataout = drive->i.iec.datain = 0xff;
1833      drive->i.iec.state = 0;
1834   }
1835   else if (drive->interface == SERIAL)
1836   {
1837      cbm_serial.drives[cbm_serial.count++] = drive;
1838      drive_reset_write(drive, 0);
1839   }
1840}
1841
1842void cbm_drive_0_config( int interface, int serialnr )
1843{
1844   cbm_drive_config(cbm_drive, interface, serialnr);
1845}
1846
1847void cbm_drive_1_config( int interface, int serialnr )
1848{
1849   cbm_drive_config(cbm_drive + 1, interface, serialnr);
1850}
1851
1852
17121853/**************************************
17131854
1714   Device configurations
1855   Floppy device configurations
17151856
17161857**************************************/
17171858
src/mess/machine/primo.c
r4824r4825
107107READ8_HANDLER( primo_be_2_r )
108108{
109109   UINT8 data = 0xff;
110   const device_config *serbus = devtag_get_device(space->machine, "serial_bus");
110111
111112   // bit 7, 6 - not used
112113
113114   // bit 5 - SCLK
114   if (!serial_clock || !cbm_serial_clock_read (space->machine))
115   if (!serial_clock || !cbm_serial_clock_read(serbus, 0))
115116      data &= ~0x20;
116117
117118   // bit 4 - SDATA
118   if (!serial_data || !cbm_serial_data_read (space->machine))
119   if (!serial_data || !cbm_serial_data_read(serbus, 0))
119120      data &= ~0x10;
120121
121122   // bit 3 - SRQ
122//   data &= (!cbm_serial_request_read ()) ? ~0x08 : ~0x00;
123//   data &= (!cbm_serial_request_read(serbus, 0)) ? ~0x08 : ~0x00;
123124
124125   // bit 2 - joystic 2 (not implemeted yet)
125126
126127   // bit 1 - ATN
127   if (!serial_atn || !cbm_serial_atn_read (space->machine))
128   if (!serial_atn || !cbm_serial_atn_read(serbus, 0))
128129      data &= ~0x02;
129130
130131   // bit 0 - joystic 1 (not implemeted yet)
r4824r4825
172173
173174WRITE8_HANDLER( primo_ki_2_w )
174175{
176   const device_config *serbus = devtag_get_device(space->machine, "serial_bus");
177
175178   // bit 7, 6 - not used
176179
177180   // bit 5 - SCLK
178   cbm_serial_clock_write (space->machine, serial_clock = !(data & 0x20));
181   cbm_serial_clock_write(serbus, 0, serial_clock = !(data & 0x20));
179182   logerror ("W - SCLK: %d ", serial_clock ? 1 : 0);
180183
181184   // bit 4 - SDATA
182   cbm_serial_data_write (space->machine, serial_data = !(data & 0x10));
185   cbm_serial_data_write(serbus, 0, serial_data = !(data & 0x10));
183186   logerror ("SDATA: %d ", serial_data ? 1 : 0);
184187
185188   // bit 3 - not used
186189
187190   // bit 2 - SRQ
188   cbm_serial_request_write (space->machine, !(data & 0x04));
191   cbm_serial_request_write(serbus, 0, !(data & 0x04));
189192
190193   // bit 1 - ATN
191   cbm_serial_atn_write (space->machine, serial_atn = !(data & 0x02));
194   cbm_serial_atn_write(serbus, 0, serial_atn = !(data & 0x02));
192195   logerror ("ATN: %d\n", serial_atn ? 1 : 0);
193196
194197   // bit 0 - not used
r4824r4825
259262{
260263   primo_common_machine_init(machine);
261264
262   cbm_serial_config(machine, &cbm_sim_drive_interface);   
263   cbm_serial_reset_write (machine, 0);
264   cbm_drive_0_config (SERIAL, 8);
265   cbm_drive_1_config (SERIAL, 9);
265   cbm_drive_0_config(SERIAL, 8);
266   cbm_drive_1_config(SERIAL, 9);
266267}
267268
268269/*******************************************************************************
src/mess/machine/cbmserb.c
r4824r4825
1#include <stdio.h>
2#include <stdlib.h>
3#include <ctype.h>
4#include <string.h>
5#include "driver.h"
6#include "image.h"
1/***************************************************************************
72
8#include "includes/cbmserb.h"
3    Commodore Serial Bus
94
10/* with these we include the handlers for the interfaces below */
11#include "includes/vc1541.h"
12#include "includes/cbmdrive.h"
135
146
15/**************************************
7    2009-05 FP: Changed the implementation to be a MAME device. However,
8    the main code has been kept the same as before (to reduce the risk of
9    regressions, at this early stage). More work will be eventually done
10    to improve emulation and to allow more devices (possibly of different
11    kinds) to be connected to the bus like in the real thing.
12    Notice that, imho, the current implementation is not very satisfactory:
13    it is not really emulating the serial bus, but (in some sense) the plug
14    of the devices which would be connected to the serial bus. Hence, the
15    provided handlers pass the serial state of the floppy drives to the CPU
16    of the main machine.
17    As a byproduct of this implementation, the serial_bus device is currently
18    tied to the floppy drives (i.e. you will find MDRV_CBM_SERBUS_ADD used
19    in the floppy drive MACHINE_DRIVERs, not in the main computer ones)
1620
17   Handlers for the simulated drive
21    In other words, don't use this driver as an example of the right way
22    to implement serial devices in MAME/MESS!
1823
19**************************************/
24***************************************************************************/
2025
26#include "driver.h"
2127
22static void sim_drive_reset_write (running_machine *machine, int level)
23{
24   int i;
28#include "includes/cbmserb.h"
2529
26   for (i = 0; i < cbm_serial.count; i++)
27      drive_reset_write (cbm_serial.drives[i], level);
28   /* init bus signals */
29}
3030
31static int sim_drive_request_read (running_machine *machine)
32{
33   /* in c16 not connected */
34   return 1;
35}
31/***************************************************************************
32    TYPE DEFINITIONS
33***************************************************************************/
3634
37static void sim_drive_request_write (running_machine *machine, int level)
35typedef struct _cbm_serial_bus_t cbm_serial_bus_t;
36struct _cbm_serial_bus_t
3837{
39}
38   devcb_resolved_read8 read_atn_func;
39   devcb_resolved_read8 read_clock_func;
40   devcb_resolved_read8 read_data_func;
41   devcb_resolved_read8 read_request_func;
42   devcb_resolved_write8 write_atn_func;
43   devcb_resolved_write8 write_clock_func;
44   devcb_resolved_write8 write_data_func;
45   devcb_resolved_write8 write_request_func;
4046
41static int sim_drive_atn_read (running_machine *machine)
42{
43   int i;
47   devcb_resolved_write8 write_reset_func;
48};
4449
45   cbm_serial.atn[0] = cbm_serial.atn[1];
46   for (i = 0; i < cbm_serial.count; i++)
47      cbm_serial.atn[0] &= cbm_serial.atn[i + 2] =
48         vc1541_atn_read (machine, cbm_serial.drives[i]);
49   return cbm_serial.atn[0];
50}
50/***************************************************************************
51    INLINE FUNCTIONS
52***************************************************************************/
5153
52static int sim_drive_data_read (running_machine *machine)
54INLINE cbm_serial_bus_t *get_safe_token(const device_config *device)
5355{
54   int i;
55
56   cbm_serial.data[0] = cbm_serial.data[1];
57   for (i = 0; i < cbm_serial.count; i++)
58      cbm_serial.data[0] &= cbm_serial.data[i + 2] =
59         vc1541_data_read (machine, cbm_serial.drives[i]);
60   return cbm_serial.data[0];
56   assert(device != NULL);
57   assert(device->token != NULL);
58   assert(device->type == CBM_SERBUS);
59   return (cbm_serial_bus_t *)device->token;
6160}
6261
63static int sim_drive_clock_read (running_machine *machine)
62INLINE const cbm_serial_bus_interface *get_interface(const device_config *device)
6463{
65   int i;
66
67   cbm_serial.clock[0] = cbm_serial.clock[1];
68   for (i = 0; i < cbm_serial.count; i++)
69      cbm_serial.clock[0] &= cbm_serial.clock[i + 2] =
70         vc1541_clock_read (machine, cbm_serial.drives[i]);
71   return cbm_serial.clock[0];
64   assert(device != NULL);
65   assert((device->type == CBM_SERBUS));
66   return (const cbm_serial_bus_interface *) device->static_config;
7267}
7368
74static void sim_drive_data_write (running_machine *machine, int level)
75{
76   int i;
69/***************************************************************************
70    IMPLEMENTATION
71***************************************************************************/
7772
78   cbm_serial.data[0] =
79      cbm_serial.data[1] = level;
80   /* update line */
81   for (i = 0; i < cbm_serial.count; i++)
82      cbm_serial.data[0] &= cbm_serial.data[i + 2];
83   /* inform drives */
84   for (i = 0; i < cbm_serial.count; i++)
85      vc1541_data_write (machine, cbm_serial.drives[i], cbm_serial.data[0]);
86}
8773
88static void sim_drive_clock_write (running_machine *machine, int level)
74/* bus handling */
75READ8_DEVICE_HANDLER( cbm_serial_request_read )
8976{
90   int i;
77   cbm_serial_bus_t *serbus = get_safe_token(device);
78   UINT8 val;
9179
92   cbm_serial.clock[0] =
93      cbm_serial.clock[1] = level;
94   /* update line */
95   for (i = 0; i < cbm_serial.count; i++)
96      cbm_serial.clock[0] &= cbm_serial.clock[i + 2];
97   /* inform drives */
98   for (i = 0; i < cbm_serial.count; i++)
99      vc1541_clock_write (machine, cbm_serial.drives[i], cbm_serial.clock[0]);
100}
80   if (serbus->read_request_func.read != NULL)
81      val = devcb_call_read8(&serbus->read_request_func, offset);
82   else
83   {
84      logerror("%s:Serial Bus %s: Request is being read but has no handler\n", cpuexec_describe_context(device->machine), device->tag);
85      val = 0;
86   }
10187
102static void sim_drive_atn_write (running_machine *machine, int level)
103{
104   int i;
105
106   cbm_serial.atn[0] =
107      cbm_serial.atn[1] = level;
108   /* update line */
109   for (i = 0; i < cbm_serial.count; i++)
110      cbm_serial.atn[0] &= cbm_serial.atn[i + 2];
111   /* inform drives */
112   for (i = 0; i < cbm_serial.count; i++)
113      vc1541_atn_write (machine, cbm_serial.drives[i], cbm_serial.atn[0]);
88   return val;
11489}
11590
116
117const cbm_serial_interface cbm_sim_drive_interface =
91WRITE8_DEVICE_HANDLER( cbm_serial_request_write )
11892{
119   1,
120   sim_drive_reset_write,
121   sim_drive_request_read,
122   sim_drive_request_write,
123   sim_drive_atn_read,
124   sim_drive_data_read,
125   sim_drive_clock_read,
126   sim_drive_atn_write,
127   sim_drive_data_write,
128   sim_drive_clock_write
129};
93   cbm_serial_bus_t *serbus = get_safe_token(device);
13094
131
132/**************************************
133
134   Handlers for the emulated drive
135
136**************************************/
137
138
139static void emu_drive_reset_write( running_machine *machine, int level )
140{
141   vc1541_serial_reset_write(machine, 0, level);
95   if (serbus->write_request_func.write != NULL)
96      devcb_call_write8(&serbus->write_request_func, offset, data);
97   else
98      logerror("%s:Serial Bus %s: Request is being written but has no handler\n", cpuexec_describe_context(device->machine), device->tag);
14299}
143100
144static int emu_drive_request_read( running_machine *machine )   
101READ8_DEVICE_HANDLER( cbm_serial_atn_read )
145102{
146   return vc1541_serial_request_read(machine, 0);
147}
148   
149static void emu_drive_request_write( running_machine *machine, int level )
150{
151   vc1541_serial_request_write(machine, 0, level);
152}
103   cbm_serial_bus_t *serbus = get_safe_token(device);
104   UINT8 val;
153105
154static int emu_drive_atn_read( running_machine *machine )
155{
156   return vc1541_serial_atn_read(machine, 0);
157}
106   if (serbus->read_atn_func.read != NULL)
107      val = devcb_call_read8(&serbus->read_atn_func, offset);
108   else
109   {
110      logerror("%s:Serial Bus %s: ATN is being read but has no handler\n", cpuexec_describe_context(device->machine), device->tag);
111      val = 0;
112   }
158113
159static int emu_drive_data_read( running_machine *machine )
160{
161   return vc1541_serial_data_read(machine, 0);
114   return val;
162115}
163116
164static int emu_drive_clock_read( running_machine *machine )
117READ8_DEVICE_HANDLER( cbm_serial_data_read )
165118{
166   return vc1541_serial_clock_read(machine, 0);
167}
119   cbm_serial_bus_t *serbus = get_safe_token(device);
120   UINT8 val;
168121
169static void emu_drive_atn_write( running_machine *machine, int level )
170{
171   vc1541_serial_atn_write(machine, 0, level);
172}
122   if (serbus->read_data_func.read != NULL)
123      val = devcb_call_read8(&serbus->read_data_func, offset);
124   else
125   {
126      logerror("%s:Serial Bus %s: Data is being read but has no handler\n", cpuexec_describe_context(device->machine), device->tag);
127      val = 0;
128   }
173129
174static void emu_drive_data_write( running_machine *machine, int level )
175{
176   vc1541_serial_data_write(machine, 0, level);
130   return val;
177131}
178132
179static void emu_drive_clock_write( running_machine *machine, int level )
133READ8_DEVICE_HANDLER( cbm_serial_clock_read )
180134{
181   vc1541_serial_clock_write(machine, 0, level);
182}
135   cbm_serial_bus_t *serbus = get_safe_token(device);
136   UINT8 val;
183137
184const cbm_serial_interface cbm_emu_drive_interface =
185{
186   2,
187   emu_drive_reset_write,
188   emu_drive_request_read,
189   emu_drive_request_write,
190   emu_drive_atn_read,
191   emu_drive_data_read,
192   emu_drive_clock_read,
193   emu_drive_atn_write,
194   emu_drive_data_write,
195   emu_drive_clock_write
196};
138   if (serbus->read_clock_func.read != NULL)
139      val = devcb_call_read8(&serbus->read_clock_func, offset);
140   else
141   {
142      logerror("%s:Serial Bus %s: Clock is being read but has no handler\n", cpuexec_describe_context(device->machine), device->tag);
143      val = 0;
144   }
197145
198
199/**************************************
200
201   Empty handlers
202
203**************************************/
204
205
206/* In sx64, c16v & vic20v we use these while fixing handlers for real emulation */
207
208static void fake_drive_reset_write( running_machine *machine, int level )
209{
146   return val;
210147}
211148
212static int fake_drive_request_read( running_machine *machine )   
149WRITE8_DEVICE_HANDLER( cbm_serial_atn_write )
213150{
214   return 0;
215}
216   
217static void fake_drive_request_write( running_machine *machine, int level )
218{
219}
151   cbm_serial_bus_t *serbus = get_safe_token(device);
220152
221static int fake_drive_atn_read( running_machine *machine )
222{
223   return 0;
153   if (serbus->write_atn_func.write != NULL)
154      devcb_call_write8(&serbus->write_atn_func, offset, data);
155   else
156      logerror("%s:Serial Bus %s: ATN is being written but has no handler\n", cpuexec_describe_context(device->machine), device->tag);
224157}
225158
226static int fake_drive_data_read( running_machine *machine )
159WRITE8_DEVICE_HANDLER( cbm_serial_data_write )
227160{
228   return 0;
229}
161   cbm_serial_bus_t *serbus = get_safe_token(device);
230162
231static int fake_drive_clock_read( running_machine *machine )
232{
233   return 0;
163   if (serbus->write_data_func.write != NULL)
164      devcb_call_write8(&serbus->write_data_func, offset, data);
165   else
166      logerror("%s:Serial Bus %s: Data is being written but has no handler\n", cpuexec_describe_context(device->machine), device->tag);
234167}
235168
236static void fake_drive_atn_write( running_machine *machine, int level )
169WRITE8_DEVICE_HANDLER( cbm_serial_clock_write )
237170{
238}
171   cbm_serial_bus_t *serbus = get_safe_token(device);
239172
240static void fake_drive_data_write( running_machine *machine, int level )
241{
173   if (serbus->write_clock_func.write != NULL)
174      devcb_call_write8(&serbus->write_clock_func, offset, data);
175   else
176      logerror("%s:Serial Bus %s: Clock is being written but has no handler\n", cpuexec_describe_context(device->machine), device->tag);
242177}
243178
244static void fake_drive_clock_write( running_machine *machine, int level )
245{
246}
247179
248const cbm_serial_interface cbm_fake_drive_interface =
249{
250   3,
251   fake_drive_reset_write,
252   fake_drive_request_read,
253   fake_drive_request_write,
254   fake_drive_atn_read,
255   fake_drive_data_read,
256   fake_drive_clock_read,
257   fake_drive_atn_write,
258   fake_drive_data_write,
259   fake_drive_clock_write
260};   
261   
262/**************************************
180/*-------------------------------------------------
181    DEVICE_START( cbm_serial_bus )
182-------------------------------------------------*/
263183
264   Serial communications
265
266**************************************/
267
268/* 2008-09 FP:
269   To make possible to test code for both simulated floppy drive and emulated floppy drive, I
270   created this interface for the serial bus emulation. The implementation is maybe not the cleanest
271   possible, but it works.
272   This is necessary because using simulation we support two drives (see the handlers above) while
273   the emulation only supports one drive (the handlers have a 'which' parameter, but the reset and
274   config functions are strictly for 1 drive).
275   Eventually, we will remove the simulation and here we will have only the emu_drive_*** above
276   renamed as cbm_serial_*** and the whole interface will be trashed.
277 */
278/* To Do: Can we pass more directly the handlers from the interface to the drivers?   */
279
280static cbm_serial_interface serial_intf_static= { 0 }, *serial_intf = &serial_intf_static;
281
282void cbm_serial_config(running_machine *machine, const cbm_serial_interface *intf)
184static DEVICE_START( cbm_serial_bus )
283185{
284   serial_intf->serial = intf->serial;
285   serial_intf->serial_reset_write = intf->serial_reset_write;
286   serial_intf->serial_request_read = intf->serial_request_read;
287   serial_intf->serial_request_write = intf->serial_request_write;
288   serial_intf->serial_atn_read = intf->serial_atn_read;
289   serial_intf->serial_data_read = intf->serial_data_read;
290   serial_intf->serial_clock_read = intf->serial_clock_read;
291   serial_intf->serial_atn_write = intf->serial_atn_write;
292   serial_intf->serial_data_write = intf->serial_data_write;
293   serial_intf->serial_clock_write = intf->serial_clock_write;
186   cbm_serial_bus_t *serbus = get_safe_token(device);
187   const cbm_serial_bus_interface *intf = get_interface(device);
294188
295   logerror("Serial interface in use: %d\n", serial_intf->serial);
296}
189   memset(serbus, 0, sizeof(*serbus));
297190
191   devcb_resolve_read8(&serbus->read_atn_func, &intf->read_atn_func, device);
192   devcb_resolve_read8(&serbus->read_clock_func, &intf->read_clock_func, device);
193   devcb_resolve_read8(&serbus->read_data_func, &intf->read_data_func, device);
194   devcb_resolve_read8(&serbus->read_request_func, &intf->read_request_func, device);
195   devcb_resolve_write8(&serbus->write_atn_func, &intf->write_atn_func, device);
196   devcb_resolve_write8(&serbus->write_clock_func, &intf->write_clock_func, device);
197   devcb_resolve_write8(&serbus->write_data_func, &intf->write_data_func, device);
198   devcb_resolve_write8(&serbus->write_request_func, &intf->write_request_func, device);
298199
299/* bus handling */
300void cbm_serial_reset_write (running_machine *machine, int level)
301{
302   serial_intf->serial_reset_write(machine, level);
200   devcb_resolve_write8(&serbus->write_reset_func, &intf->write_reset_func, device);
303201}
304202
305int cbm_serial_request_read (running_machine *machine)
306{
307   return serial_intf->serial_request_read(machine);
308}
203/*-------------------------------------------------
204    DEVICE_RESET( cbm_serial_bus )
205-------------------------------------------------*/
309206
310void cbm_serial_request_write (running_machine *machine, int level)
207static DEVICE_RESET( cbm_serial_bus )
311208{
312   serial_intf->serial_request_write(machine, level);
313}
209   cbm_serial_bus_t *serbus = get_safe_token(device);
314210
315int cbm_serial_atn_read (running_machine *machine)
316{
317   return serial_intf->serial_atn_read(machine);
211   if (serbus->write_reset_func.write != NULL)
212      devcb_call_write8(&serbus->write_reset_func, 0, 0);
213   else
214      logerror("%s:Serial Bus %s: Reset is being written but has no handler\n", cpuexec_describe_context(device->machine), device->tag);
318215}
319216
320int cbm_serial_data_read (running_machine *machine)
321{
322   return serial_intf->serial_data_read(machine);
323}
217/*-------------------------------------------------
218    DEVICE_GET_INFO( cbm_serial_bus )
219-------------------------------------------------*/
324220
325int cbm_serial_clock_read (running_machine *machine)
221DEVICE_GET_INFO( cbm_serial_bus )
326222{
327   return serial_intf->serial_clock_read(machine);
328}
223   switch (state)
224   {
225      /* --- the following bits of info are returned as 64-bit signed integers --- */
226      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(cbm_serial_bus_t);         break;
227      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
228      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
329229
330void cbm_serial_data_write (running_machine *machine, int level)
331{
332   serial_intf->serial_data_write(machine, level);
333}
230      /* --- the following bits of info are returned as pointers to data or functions --- */
231      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(cbm_serial_bus);   break;
232      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
233      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(cbm_serial_bus);   break;
334234
335void cbm_serial_clock_write (running_machine *machine, int level)
336{
337   serial_intf->serial_clock_write(machine, level);
235      /* --- the following bits of info are returned as NULL-terminated strings --- */
236      case DEVINFO_STR_NAME:                     strcpy(info->s, "Commodore Serial Bus");   break;
237      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Commodore Serial Bus");   break;
238      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
239      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
240      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
241   }
338242}
339
340void cbm_serial_atn_write (running_machine *machine, int level)
341{
342   serial_intf->serial_atn_write(machine, level);
343}
src/mess/machine/vc20.c
r4824r4825
109109static READ8_DEVICE_HANDLER( vc20_via0_read_porta )
110110{
111111   UINT8 value = 0xff;
112   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
112113
113114   value &= ~(input_port_read(device->machine, "JOY") & 0x3c);
114115
r4824r4825
116117   /* should be reduced to about 1 or 2 microseconds */
117118   /*  if ((input_port_read(space->machine, "CTRLSEL") & 0x20 ) && (input_port_read(space->machine, "JOY") & 0x40) )  // i.e. LIGHTPEN_BUTTON
118119      value &= ~0x20; */
119   if (!serial_clock || !cbm_serial_clock_read (device->machine))
120   if (!serial_clock || !cbm_serial_clock_read(serbus, 0))
120121      value &= ~0x01;
121   if (!serial_data || !cbm_serial_data_read (device->machine))
122   if (!serial_data || !cbm_serial_data_read(serbus, 0))
122123      value &= ~0x02;
123124
124125   if ((cassette_get_state(devtag_get_device(device->machine, "cassette")) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED)
r4824r4825
131132
132133static WRITE8_DEVICE_HANDLER( vc20_via0_write_porta )
133134{
134   running_machine *machine = device->machine;
135   cbm_serial_atn_write (machine, serial_atn = !(data & 0x80));
136   DBG_LOG (1, "serial out", ("atn %s\n", serial_atn ? "high" : "low"));
135   running_machine *machine = device->machine;      // used in DBG_LOG
136   const device_config *serbus = devtag_get_device(machine, "serial_bus");
137
138   cbm_serial_atn_write(serbus, 0, serial_atn = !(data & 0x80));
139   DBG_LOG(1, "serial out", ("atn %s\n", serial_atn ? "high" : "low"));
137140}
138141
139142/* via 1 addr 0x9120
r4824r4825
191194
192195static WRITE8_DEVICE_HANDLER( vc20_via1_write_ca2 )
193196{
194   cbm_serial_clock_write (device->machine, serial_clock = !data);
197   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
198
199   cbm_serial_clock_write(serbus, 0, serial_clock = !data);
195200}
196201
197202static READ8_DEVICE_HANDLER( vc20_via1_read_portb )
r4824r4825
330335
331336static READ8_DEVICE_HANDLER( vc20_via1_read_cb1 )
332337{
333   running_machine *machine = device->machine;
334   DBG_LOG (1, "serial in", ("request read\n"));
335   return cbm_serial_request_read (device->machine);
338   running_machine *machine = device->machine;      // used in DBG_LOG
339   const device_config *serbus = devtag_get_device(machine, "serial_bus");
340
341   DBG_LOG(1, "serial in", ("request read\n"));
342   return cbm_serial_request_read(serbus, 0);
336343}
337344
338345static WRITE8_DEVICE_HANDLER( vc20_via1_write_cb2 )
339346{
340   cbm_serial_data_write (device->machine, serial_data = !data);
347   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
348   cbm_serial_data_write(serbus, 0, serial_data = !data);
341349}
342350
343351/* ieee 6522 number 1 (via4)
r4824r4825
621629
622630   if (has_vc1541)
623631   {
624      cbm_serial_config(machine, &cbm_emu_drive_interface);
625632      drive_reset();
626633   }
627634   else
628635   {
629      cbm_serial_config(machine, &cbm_sim_drive_interface);
630      cbm_serial_reset_write(machine, 0);
631
632636      if (ieee)
633637      {
634638         cbm_drive_0_config(IEEE, 8);
src/mess/machine/c64.c
r4824r4825
201201static READ8_DEVICE_HANDLER( c64_cia1_port_a_r )
202202{
203203   UINT8 value = 0xff;
204   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
204205
205   if (!serial_clock || !cbm_serial_clock_read (device->machine))
206   if (!serial_clock || !cbm_serial_clock_read(serbus, 0))
206207      value &= ~0x40;
207208
208   if (!serial_data || !cbm_serial_data_read (device->machine))
209   if (!serial_data || !cbm_serial_data_read(serbus, 0))
209210      value &= ~0x80;
210211
211212   return value;
r4824r4825
214215static WRITE8_DEVICE_HANDLER( c64_cia1_port_a_w )
215216{
216217   static const int helper[4] = {0xc000, 0x8000, 0x4000, 0x0000};
218   const device_config *serbus = devtag_get_device(device->machine, "serial_bus");
217219
218   cbm_serial_clock_write (device->machine, serial_clock = !(data & 0x10));
219   cbm_serial_data_write (device->machine, serial_data = !(data & 0x20));
220   cbm_serial_atn_write (device->machine, serial_atn = !(data & 0x08));
220   cbm_serial_clock_write(serbus, 0, serial_clock = !(data & 0x10));
221   cbm_serial_data_write(serbus, 0, serial_data = !(data & 0x20));
222   cbm_serial_atn_write(serbus, 0, serial_atn = !(data & 0x08));
221223   c64_vicaddr = c64_memory + helper[data & 0x03];
222224}
223225
r4824r4825
858860{
859861   if (is_sx64)
860862   {
861      cbm_serial_config(machine, &cbm_emu_drive_interface);
862863      drive_reset();
863864   }
864865
865866   else if (c64_cia1_on)
866867   {
867      cbm_serial_config(machine, &cbm_sim_drive_interface);
868      cbm_serial_reset_write(machine, 0);
869868      cbm_drive_0_config(SERIAL, 8);
870869      cbm_drive_1_config(SERIAL, 9);
871870      serial_clock = serial_data = serial_atn = 1;
src/mess/drivers/c65.c
r4824r4825
243243   MDRV_CIA6526_ADD("cia_0", CIA6526R1, 3500000, c65_ntsc_cia0)
244244   MDRV_CIA6526_ADD("cia_1", CIA6526R1, 3500000, c65_ntsc_cia1)
245245   
246   /* floppy from serial bus */
247   MDRV_IMPORT_FROM(simulated_drive)
248
246249   MDRV_IMPORT_FROM(c64_cartslot)
247250MACHINE_DRIVER_END
248251
src/mess/drivers/c128.c
r4824r4825
180180#include "machine/cbmipt.h"
181181#include "video/vic6567.h"
182182#include "video/vdc8563.h"
183#include "includes/vc1541.h"
184183
185184/* devices config */
186185#include "includes/cbm.h"
186#include "includes/cbmserb.h"   // needed for MDRV_CBM_SERBUS_REMOVE
187187#include "includes/cbmdrive.h"
188#include "includes/vc1541.h"
188189
189190#include "includes/c128.h"
190191#include "includes/c64.h"
r4824r4825
635636   MDRV_CIA6526_ADD("cia_0", CIA6526R1, VIC6567_CLOCK, c128_ntsc_cia0)
636637   MDRV_CIA6526_ADD("cia_1", CIA6526R1, VIC6567_CLOCK, c128_ntsc_cia1)
637638   
639   /* floppy from serial bus */
640   MDRV_IMPORT_FROM(simulated_drive)
641
638642   MDRV_IMPORT_FROM(c64_cartslot)
639643MACHINE_DRIVER_END
640644
641645
642646static MACHINE_DRIVER_START( c128d )
643647   MDRV_IMPORT_FROM( c128 )
648
649   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
644650   MDRV_IMPORT_FROM( cpu_c1571 )
645651MACHINE_DRIVER_END
646652
647653static MACHINE_DRIVER_START( c128dcr )
648654   MDRV_IMPORT_FROM( c128 )
655
656   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
649657   MDRV_IMPORT_FROM( cpu_c1571cr )
650658MACHINE_DRIVER_END
651659
652660static MACHINE_DRIVER_START( c128d81 )
653661   MDRV_IMPORT_FROM( c128 )
662
663   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
654664   MDRV_IMPORT_FROM( cpu_c1581 )
655665MACHINE_DRIVER_END
656666
r4824r4825
678688
679689static MACHINE_DRIVER_START( c128dpal )
680690   MDRV_IMPORT_FROM( c128pal )
691
692   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
681693   MDRV_IMPORT_FROM( cpu_c1571 )
682694MACHINE_DRIVER_END
683695
684696static MACHINE_DRIVER_START( c128dcrp )
685697   MDRV_IMPORT_FROM( c128pal )
698
699   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
686700   MDRV_IMPORT_FROM( cpu_c1571cr )
687701MACHINE_DRIVER_END
688702
src/mess/drivers/c16.c
r4824r4825
129129/* devices config */
130130#include "includes/cbm.h"
131131#include "includes/cbmdrive.h"
132#include "includes/cbmserb.h"   // needed for MDRV_CBM_SERBUS_REMOVE
132133
133134#include "includes/c16.h"
134135
r4824r4825
449450   /* cassette */
450451   MDRV_CASSETTE_ADD( "cassette", cbm_cassette_config )
451452
453   /* floppy from serial bus */
454   MDRV_IMPORT_FROM(simulated_drive)
455
452456   /* tpi */
453457   MDRV_TPI6525_ADD("tpi6535_tpi_2", c16_tpi6525_tpi_2_intf)
454458   MDRV_TPI6525_ADD("tpi6535_tpi_3", c16_tpi6525_tpi_3_intf)
r4824r4825
468472   /* emulation code currently supports only one drive */
469473   MDRV_TPI6525_REMOVE("tpi6535_tpi_3")
470474
475   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
471476   MDRV_IMPORT_FROM( cpu_c1551 )
472477#ifdef CPU_SYNC
473478   MDRV_QUANTUM_TIME(HZ(60))
r4824r4825
479484
480485static MACHINE_DRIVER_START( c16v )
481486   MDRV_IMPORT_FROM( c16 )
487
488   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
482489   MDRV_IMPORT_FROM( cpu_vc1541 )
483490#ifdef CPU_SYNC
484491   MDRV_QUANTUM_TIME(HZ(60))
r4824r4825
513520   MDRV_TPI6525_ADD("tpi6535_tpi_2", c16_tpi6525_tpi_2_c1551_intf)
514521
515522   /* emulation code currently supports only one drive */
523   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
516524   MDRV_TPI6525_REMOVE("tpi6535_tpi_3")
517525
518526   MDRV_IMPORT_FROM( cpu_c1551 )
r4824r4825
529537
530538static MACHINE_DRIVER_START( plus4v )
531539   MDRV_IMPORT_FROM( plus4 )
540
541   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
532542   MDRV_IMPORT_FROM( cpu_vc1541 )
533543
534544   MDRV_SCREEN_MODIFY("screen")
r4824r4825
733743
734744COMP( 1984, c232,    c16,   0,  c16,    c16,    c16,    c16,     "Commodore Business Machines Co.",  "Commodore 232 (Prototype)", 0)
735745COMP( 1984, c264,    c16,   0,  c16,    plus4,  c16,    plus,    "Commodore Business Machines Co.",  "Commodore 264 (Prototype)", 0)
736COMP( 1984, c364,    c16,   0,  c364,   plus4,  c16,    plusv,   "Commodore Business Machines Co.",  "Commodore V364 (Prototype)", GAME_IMPERFECT_SOUND)
746COMP( 1984, c364,    c16,   0,  c364,   plus4,  c16,    plus,    "Commodore Business Machines Co.",  "Commodore V364 (Prototype)", GAME_IMPERFECT_SOUND)
src/mess/drivers/vc20.c
r4824r4825
8787#include "sound/dac.h"
8888
8989#include "machine/6522via.h"
90#include "includes/vc1541.h"
9190#include "machine/cbmipt.h"
9291#include "video/vic6560.h"
9392
9493/* devices config */
9594#include "includes/cbm.h"
95#include "includes/cbmserb.h"   // needed for MDRV_CBM_SERBUS_REMOVE
9696#include "includes/cbmdrive.h"
97#include "includes/vc1541.h"
9798
9899#include "includes/vc20.h"
99100
r4824r4825
287288   /* cassette */
288289   MDRV_CASSETTE_ADD( "cassette", cbm_cassette_config )
289290
291   /* floppy from serial bus */
292   MDRV_IMPORT_FROM(simulated_drive)
293
290294   /* via */
291295   MDRV_VIA6522_ADD("via6522_0", 0, vc20_via0)
292296   MDRV_VIA6522_ADD("via6522_1", 0, vc20_via1)
r4824r4825
299303
300304static MACHINE_DRIVER_START( vic20v )
301305   MDRV_IMPORT_FROM( vic20 )
306
307   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
302308   MDRV_IMPORT_FROM( cpu_vc1540 )
303309#ifdef CPU_SYNC
304310   MDRV_QUANTUM_TIME(HZ(60))
r4824r4825
337343
338344static MACHINE_DRIVER_START( vc20v )
339345   MDRV_IMPORT_FROM( vc20 )
346
347   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
340348   MDRV_IMPORT_FROM( cpu_vc1540 )
341349#ifdef CPU_SYNC
342350   MDRV_QUANTUM_TIME(HZ(60))
src/mess/drivers/primo.c
r4824r4825
111111#include "devices/cartslot.h"
112112#include "formats/primoptp.h"
113113
114#include "includes/cbmdrive.h"
115
114116static ADDRESS_MAP_START( primoa_port, ADDRESS_SPACE_IO, 8 )
115117   ADDRESS_MAP_GLOBAL_MASK(0xff)
116118   AM_RANGE( 0x00, 0x3f ) AM_READWRITE( primo_be_1_r, primo_ki_1_w )
r4824r4825
275277
276278   MDRV_CASSETTE_ADD( "cassette", primo_cassette_config )
277279
280   /* floppy from serial bus */
281   /* for some reason machine/primo.c sets up the serial bus
282   but no floppy drive has been apparently added... incomplete driver? */
283   MDRV_IMPORT_FROM(simulated_drive)
284
278285   /* cartridge */
279286   MDRV_CARTSLOT_ADD("cart1")
280287   MDRV_CARTSLOT_EXTENSION_LIST("rom")
src/mess/drivers/c64.c
r4824r4825
330330
331331#include "machine/cbmipt.h"
332332#include "video/vic6567.h"
333#include "includes/vc1541.h"
334333
335334/* devices config */
336335#include "includes/cbm.h"
336#include "includes/cbmserb.h"   // needed for MDRV_CBM_SERBUS_REMOVE
337337#include "includes/cbmdrive.h"
338#include "includes/vc1541.h"
338339
339340#include "includes/c64.h"
340341
r4824r4825
520521   MDRV_CIA6526_ADD("cia_0", CIA6526R1, VIC6567_CLOCK, c64_ntsc_cia0)
521522   MDRV_CIA6526_ADD("cia_1", CIA6526R1, VIC6567_CLOCK, c64_ntsc_cia1)
522523
524   /* floppy from serial bus */
525   MDRV_IMPORT_FROM(simulated_drive)
526
523527   MDRV_IMPORT_FROM(c64_cartslot)
524528MACHINE_DRIVER_END
525529
r4824r4825
558562   MDRV_CIA6526_ADD("cia_0", CIA6526R1, VIC6569_CLOCK, c64_pal_cia0)
559563   MDRV_CIA6526_ADD("cia_1", CIA6526R1, VIC6569_CLOCK, c64_pal_cia1)
560564   
565   /* floppy from serial bus */
566   MDRV_IMPORT_FROM(simulated_drive)
567
561568   MDRV_IMPORT_FROM(c64_cartslot)
562569MACHINE_DRIVER_END
563570
r4824r4825
571578   MDRV_SOUND_CONFIG(c64_sound_interface)
572579   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
573580   
581   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
574582   MDRV_CARTSLOT_REMOVE("cart1")
575583   MDRV_CARTSLOT_REMOVE("cart2")
584
576585   MDRV_IMPORT_FROM(ultimax_cartslot)
577586MACHINE_DRIVER_END
578587
r4824r4825
593602static MACHINE_DRIVER_START( sx64 )
594603   MDRV_IMPORT_FROM( c64pal )
595604
596   MDRV_IMPORT_FROM( cpu_vc1541 )
605   MDRV_CBM_SERBUS_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
606   MDRV_IMPORT_FROM( cpu_vc1541 )         // so we need to remove the one from MDRV_IMPORT_FROM(simulated_drive)!
607
597608   MDRV_SOUND_REMOVE( "dac" )
598609   MDRV_CASSETTE_REMOVE( "cassette" )
599610#ifdef CPU_SYNC

Previous 15994 Revisions Next


© 1998-2018 The MESS Team