Previous 15994 Revisions Next

r14780 Tuesday 20th March, 2012 at 15:49:35 UTC by Curt Coder
[C64] Added support for the geoCable Centronics cable. [Curt Coder]
[C64] Added preliminary support for the 1541 parallel cable. (nw)
[src/emu/machine]6526cia.c 6526cia.h
[src/mess]mess.mak
[src/mess/machine]c1541.c c1541.h c64_bn1541.c* c64_bn1541.h* c64_geocable.c* c64_geocable.h* c64user.h cbmipt.c cbmipt.h

src/emu/machine/6526cia.c
r14779r14780
1010#include "emu.h"
1111#include "6526cia.h"
1212
13/***************************************************************************
14    CONSTANTS
15***************************************************************************/
1613
14
15//**************************************************************************
16//   MACROS / CONSTANTS
17//**************************************************************************
18
1719/* CIA registers */
1820#define CIA_PRA         0
1921#define CIA_PRB         1
r14779r14780
4143#define   CIA_CRA_SPMODE   0x40
4244#define   CIA_CRA_TODIN   0x80
4345
44//**************************************************************************
45//  DEVICE CONFIGURATION
46//**************************************************************************
4746
4847
4948//**************************************************************************
50//  LIVE DEVICE
49//  DEVICE CONFIGURATION
5150//**************************************************************************
5251
5352// device type definition
r14779r14780
5554const device_type MOS6526R2 = &device_creator<mos6526r2_device>;
5655const device_type MOS8520 = &device_creator<mos8520_device>;
5756
57
58
59//**************************************************************************
60//  INLINE HELPERS
61//**************************************************************************
62
63inline attotime mos6526_device::cycles_to_time(int c)
64{
65   return attotime::from_hz(clock()) * c;
66}
67
68
69
70//**************************************************************************
71//  LIVE DEVICE
72//**************************************************************************
73
5874//-------------------------------------------------
5975//  mos6526_device - constructor
6076//-------------------------------------------------
r14779r14780
174190   }
175191
176192   /* setup timers */
193   m_pc_timer = timer_alloc(TIMER_PC);
194
177195   for (int t = 0; t < (sizeof(m_timer) / sizeof(m_timer[0])); t++)
178196   {
179197      cia_timer *timer = &m_timer[t];
r14779r14780
225243}
226244
227245
246//-------------------------------------------------
247//  device_timer - handler timer events
248//-------------------------------------------------
249
250void mos6526_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
251{
252   switch (id)
253   {
254   case TIMER_PC:
255      m_out_pc_func(1);
256      break;
257   }
258}
259
260
228261/*-------------------------------------------------
229262    set_port_mask_value
230263-------------------------------------------------*/
r14779r14780
240273
241274void mos6526_device::update_pc()
242275{
243   /* this should really be one cycle long */
244276   m_out_pc_func(0);
245   m_out_pc_func(1);
277
278   m_pc_timer->adjust(cycles_to_time(1));
246279}
247280
248281/*-------------------------------------------------
src/emu/machine/6526cia.h
r14779r14780
132132    virtual void device_reset();
133133    virtual void device_post_load() { }
134134    virtual void device_clock_changed() { }
135   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
135136
136137   static TIMER_CALLBACK( timer_proc );
137138   static TIMER_CALLBACK( clock_tod_callback );
138139
139140private:
141   static const device_timer_id TIMER_PC = 0;
140142
143    inline attotime cycles_to_time(int c);
141144   void update_pc();
142145   void update_interrupts();
143146   void timer_bump(int timer);
r14779r14780
201204   UINT8         m_cnt;
202205   UINT8         m_shift;
203206   UINT8         m_serial;
207
208   emu_timer *m_pc_timer;
204209};
205210
206211class mos6526r1_device : public mos6526_device
src/mess/machine/cbmipt.c
r14779r14780
11921192   SLOT_INTERFACE("4dxh", C64_4DXH)
11931193   SLOT_INTERFACE("4ksa", C64_4KSA)
11941194   SLOT_INTERFACE("4tba", C64_4TBA)
1195   SLOT_INTERFACE("bn1541", C64_BN1541)
1196   SLOT_INTERFACE("geocable", C64_GEOCABLE)
11951197SLOT_INTERFACE_END
src/mess/machine/cbmipt.h
r14779r14780
77#include "machine/c64_4dxh.h"
88#include "machine/c64_4ksa.h"
99#include "machine/c64_4tba.h"
10#include "machine/c64_bn1541.h"
1011#include "machine/c64_comal80.h"
1112#include "machine/c64_dela_ep256.h"
1213#include "machine/c64_dela_ep64.h"
r14779r14780
2021#include "machine/c64_final.h"
2122#include "machine/c64_final3.h"
2223#include "machine/c64_fun_play.h"
24#include "machine/c64_geocable.h"
2325#include "machine/c64_georam.h"
2426#include "machine/c64_ieee488.h"
2527#include "machine/c64_kingsoft.h"
src/mess/machine/c64_geocable.c
r0r14780
1/**********************************************************************
2
3    geoCable Centronics Cable emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "c64_geocable.h"
11
12
13
14//**************************************************************************
15//  MACROS / CONSTANTS
16//**************************************************************************
17
18#define CENTRONICS_TAG "centronics"
19
20
21
22//**************************************************************************
23//  DEVICE DEFINITIONS
24//**************************************************************************
25
26const device_type C64_GEOCABLE = &device_creator<c64_geocable_device>;
27
28
29//-------------------------------------------------
30//  centronics_interface centronics_intf
31//-------------------------------------------------
32
33WRITE_LINE_MEMBER( c64_geocable_device::busy_w )
34{
35   m_slot->flag2_w(state);
36}
37
38static const centronics_interface centronics_intf =
39{
40   DEVCB_NULL,
41   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF, c64_geocable_device, busy_w),
42   DEVCB_NULL
43};
44
45
46//-------------------------------------------------
47//  MACHINE_CONFIG_FRAGMENT( c64_geocable )
48//-------------------------------------------------
49
50static MACHINE_CONFIG_FRAGMENT( c64_geocable )
51   MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, centronics_intf)
52MACHINE_CONFIG_END
53
54
55//-------------------------------------------------
56//  machine_config_additions - device-specific
57//  machine configurations
58//-------------------------------------------------
59
60machine_config_constructor c64_geocable_device::device_mconfig_additions() const
61{
62   return MACHINE_CONFIG_NAME( c64_geocable );
63}
64
65
66
67//**************************************************************************
68//  LIVE DEVICE
69//**************************************************************************
70
71//-------------------------------------------------
72//  c64_geocable_device - constructor
73//-------------------------------------------------
74
75c64_geocable_device::c64_geocable_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
76   device_t(mconfig, C64_GEOCABLE, "C64 geoCable", tag, owner, clock),
77   device_c64_user_port_interface(mconfig, *this),
78   m_centronics(*this, CENTRONICS_TAG)
79{
80}
81
82
83//-------------------------------------------------
84//  device_start - device-specific startup
85//-------------------------------------------------
86
87void c64_geocable_device::device_start()
88{
89}
90
91
92//-------------------------------------------------
93//  c64_pb_w - port B write
94//-------------------------------------------------
95
96void c64_geocable_device::c64_pb_w(address_space &space, offs_t offset, UINT8 data)
97{
98   m_centronics->write(data);
99}
100
101
102//-------------------------------------------------
103//  c64_pb_w - port B write
104//-------------------------------------------------
105
106void c64_geocable_device::c64_pa2_w(int level)
107{
108   m_centronics->strobe_w(level);
109}
src/mess/machine/c64_geocable.h
r0r14780
1/**********************************************************************
2
3    geoCable Centronics Cable emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __C64_GEOCABLE__
13#define __C64_GEOCABLE__
14
15#define ADDRESS_MAP_MODERN
16
17#include "emu.h"
18#include "machine/c64user.h"
19#include "machine/ctronics.h"
20
21
22
23//**************************************************************************
24//  TYPE DEFINITIONS
25//**************************************************************************
26
27// ======================> c64_geocable_device
28
29class c64_geocable_device : public device_t,
30                     public device_c64_user_port_interface
31{
32public:
33   // construction/destruction
34   c64_geocable_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
35
36   // optional information overrides
37   virtual machine_config_constructor device_mconfig_additions() const;
38
39   // not really public
40   DECLARE_WRITE_LINE_MEMBER( busy_w );
41
42protected:
43   // device-level overrides
44   virtual void device_start();
45   virtual void device_config_complete() { m_shortname = "c64_geocable"; }
46
47   // device_c64_user_port_interface overrides
48   virtual void c64_pb_w(address_space &space, offs_t offset, UINT8 data);
49   virtual void c64_pa2_w(int level);
50
51private:
52   required_device<centronics_printer_device> m_centronics;
53};
54
55
56// device type definition
57extern const device_type C64_GEOCABLE;
58
59
60#endif
src/mess/machine/c1541.c
r14779r14780
348348//  via6522_interface via0_intf
349349//-------------------------------------------------
350350
351void c1541_device::parallel_connect(c64_bn1541_device *device)
352{
353    logerror("C64 parallel cable connected!\n");
354    m_parallel_cable = device;
355}
356
357
358void c1541_device::parallel_data_w(UINT8 data)
359{
360    logerror("C64 parallel data %02x\n", data);
361    m_parallel_data = data;
362}
363
364
365void c1541_device::parallel_strobe_w(int state)
366{
367    logerror("C64 parallel strobe %u\n", state);
368    m_via0->write_cb1(state);
369}
370
371
351372WRITE_LINE_MEMBER( c1541_device::via0_irq_w )
352373{
353374   m_via0_irq = state;
r14779r14780
359380READ8_MEMBER( c1541_device::via0_pa_r )
360381{
361382   // dummy read to acknowledge ATN IN interrupt
362   return 0;
383   return m_parallel_data;
363384}
364385
365386
387WRITE8_MEMBER( c1541_device::via0_pa_w )
388{
389    if (m_parallel_cable != NULL)
390    {
391        m_parallel_cable->parallel_data_w(data);
392    }
393}
394
395
366396READ8_MEMBER( c1541_device::via0_pb_r )
367397{
368398   /*
r14779r14780
432462}
433463
434464
465WRITE_LINE_MEMBER( c1541_device::via0_ca2_w )
466{
467    if (m_parallel_cable != NULL)
468    {
469        m_parallel_cable->parallel_strobe_w(state);
470    }
471}
472
473
435474static const via6522_interface c1541_via0_intf =
436475{
437476   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c1541_device, via0_pa_r),
r14779r14780
441480   DEVCB_NULL,
442481   DEVCB_NULL,
443482
444   DEVCB_NULL,
483    DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c1541_device, via0_pa_w),
445484   DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, c1541_device, via0_pb_w),
446485   DEVCB_NULL,
447486   DEVCB_NULL,
487   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1541_device, via0_ca2_w),
448488   DEVCB_NULL,
449   DEVCB_NULL,
450489
451490   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c1541_device, via0_irq_w)
452491};
r14779r14780
727766     m_via1(*this, M6522_1_TAG),
728767     m_ga(*this, C64H156_TAG),
729768     m_image(*this, FLOPPY_0),
769      m_parallel_cable(NULL),
730770     m_data_out(1),
731771     m_via0_irq(0),
732772     m_via1_irq(0)
r14779r14780
743783     m_via1(*this, M6522_1_TAG),
744784     m_ga(*this, C64H156_TAG),
745785     m_image(*this, FLOPPY_0),
786      m_parallel_cable(NULL),
746787     m_data_out(1),
747788     m_via0_irq(0),
748789     m_via1_irq(0)
src/mess/machine/c1541.h
r14779r14780
2222#include "machine/64h156.h"
2323#include "machine/6522via.h"
2424#include "machine/cbmiec.h"
25#include "machine/c64_bn1541.h"
2526
2627
2728
r14779r14780
3940
4041// ======================> c1541_device
4142
43class c64_bn1541_device;
44
4245class c1541_device :  public device_t,
4346                 public device_cbm_iec_interface
4447{
r14779r14780
5760      TYPE_OC118
5861   };
5962
63   void parallel_connect(c64_bn1541_device *device);
64   void parallel_data_w(UINT8 data);
65   void parallel_strobe_w(int state);
66
6067   // not really public
6168   static void on_disk_change(device_image_interface &image);
6269
r14779r14780
6572   DECLARE_WRITE8_MEMBER( via0_pa_w );
6673   DECLARE_READ8_MEMBER( via0_pb_r );
6774   DECLARE_WRITE8_MEMBER( via0_pb_w );
75   DECLARE_WRITE_LINE_MEMBER( via0_ca2_w );
6876   DECLARE_READ_LINE_MEMBER( atn_in_r );
6977   DECLARE_WRITE_LINE_MEMBER( via1_irq_w );
7078   DECLARE_READ8_MEMBER( via1_pb_r );
r14779r14780
93101   required_device<via6522_device> m_via1;
94102   required_device<c64h156_device> m_ga;
95103   required_device<device_t> m_image;
104   c64_bn1541_device *m_parallel_cable;
96105
97106   // IEC bus
98107   int m_data_out;                     // serial data out
99108
109   // parallel cable
110   UINT8 m_parallel_data;
111
100112   // interrupts
101113   int m_via0_irq;                     // VIA #0 interrupt request
102114   int m_via1_irq;                     // VIA #1 interrupt request
src/mess/machine/c64user.h
r14779r14780
128128   virtual void c64_pb_w(address_space &space, offs_t offset, UINT8 data) { };
129129
130130   virtual int c64_pa2_r() { return 0; };
131   virtual void c64_pa2_w(int level) { };
132   virtual void c64_cnt1_w(int level) { };
133   virtual void c64_sp1_w(int level) { };
134   virtual void c64_pc2_w(int level) { };
135   virtual void c64_cnt2_w(int level) { };
136   virtual void c64_sp2_w(int level) { };
137   virtual void c64_atn_w(int level) { };
131   virtual void c64_pa2_w(int state) { };
132   virtual void c64_cnt1_w(int state) { };
133   virtual void c64_sp1_w(int state) { };
134   virtual void c64_pc2_w(int state) { };
135   virtual void c64_cnt2_w(int state) { };
136   virtual void c64_sp2_w(int state) { };
137   virtual void c64_atn_w(int state) { };
138138
139139   // reset
140   virtual void c64_reset_w(int level) { };
140   virtual void c64_reset_w(int state) { };
141141
142142protected:
143143   c64_user_port_device *m_slot;
src/mess/machine/c64_bn1541.c
r0r14780
1/**********************************************************************
2
3    Burst Nibbler 1541 Parallel Cable emulation
4
5    http://sta.c64.org/cbmparc2.html
6
7    Copyright MESS Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10**********************************************************************/
11
12#include "c64_bn1541.h"
13
14
15
16//**************************************************************************
17//  DEVICE DEFINITIONS
18//**************************************************************************
19
20const device_type C64_BN1541 = &device_creator<c64_bn1541_device>;
21
22
23
24//**************************************************************************
25//  LIVE DEVICE
26//**************************************************************************
27
28//-------------------------------------------------
29//  c64_bn1541_device - constructor
30//-------------------------------------------------
31
32c64_bn1541_device::c64_bn1541_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
33   device_t(mconfig, C64_BN1541, "C64 Burst Nibbler 1541 Parallel Cable", tag, owner, clock),
34   device_c64_user_port_interface(mconfig, *this),
35   m_drive(NULL)
36{
37}
38
39
40//-------------------------------------------------
41//  device_start - device-specific startup
42//-------------------------------------------------
43
44void c64_bn1541_device::device_start()
45{
46   device_iterator iter(machine().root_device());
47
48   for (device_t *device = iter.first(); device != NULL; device = iter.next())
49   {
50      if (device->subdevice(C1541_TAG) != NULL)
51      {
52         // grab the first 1541 and run to the hills
53         m_drive = device->subdevice<c1541_device>(C1541_TAG);
54         break;
55      }
56   }
57
58   assert(m_drive);
59}
60
61
62//-------------------------------------------------
63//  device_reset - device-specific reset
64//-------------------------------------------------
65
66void c64_bn1541_device::device_reset()
67{
68   if (m_drive != NULL)
69   {
70      m_drive->parallel_connect(downcast<c64_bn1541_device *>(this));
71   }
72}
73
74
75//-------------------------------------------------
76//  parallel_data_w -
77//-------------------------------------------------
78
79void c64_bn1541_device::parallel_data_w(UINT8 data)
80{
81    logerror("1541 parallel data %02x\n", data);
82   m_data = data;
83}
84
85
86//-------------------------------------------------
87//  parallel_strobe_w -
88//-------------------------------------------------
89
90void c64_bn1541_device::parallel_strobe_w(int state)
91{
92    logerror("1541 parallel strobe %u\n", state);
93   m_slot->flag2_w(state);
94}
95
96
97//-------------------------------------------------
98//  c64_pb_r - port B read
99//-------------------------------------------------
100
101UINT8 c64_bn1541_device::c64_pb_r(address_space &space, offs_t offset)
102{
103   return m_data;
104}
105
106
107//-------------------------------------------------
108//  c64_pb_w - port B write
109//-------------------------------------------------
110
111void c64_bn1541_device::c64_pb_w(address_space &space, offs_t offset, UINT8 data)
112{
113   if (m_drive != NULL)
114   {
115      m_drive->parallel_data_w(data);
116   }
117}
118
119
120//-------------------------------------------------
121//  c64_pc2_w - CIA2 PC write
122//-------------------------------------------------
123
124void c64_bn1541_device::c64_pc2_w(int state)
125{
126   if (m_drive != NULL)
127   {
128      m_drive->parallel_strobe_w(state);
129   }
130}
src/mess/machine/c64_bn1541.h
r0r14780
1/**********************************************************************
2
3    geoCable Centronics Cable emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __C64_BN1541__
13#define __C64_BN1541__
14
15#define ADDRESS_MAP_MODERN
16
17#include "emu.h"
18#include "machine/c64user.h"
19#include "machine/c1541.h"
20
21
22
23//**************************************************************************
24//  TYPE DEFINITIONS
25//**************************************************************************
26
27// ======================> c64_bn1541_device
28
29class c1541_device;
30
31class c64_bn1541_device : public device_t,
32                    public device_c64_user_port_interface
33{
34public:
35   // construction/destruction
36   c64_bn1541_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
37
38   void parallel_data_w(UINT8 data);
39   void parallel_strobe_w(int state);
40
41protected:
42   // device-level overrides
43   virtual void device_start();
44   virtual void device_reset();
45   virtual void device_config_complete() { m_shortname = "c64_bn1541"; }
46
47   // device_c64_user_port_interface overrides
48   virtual UINT8 c64_pb_r(address_space &space, offs_t offset);
49   virtual void c64_pb_w(address_space &space, offs_t offset, UINT8 data);
50   virtual void c64_pc2_w(int level);
51
52private:
53   c1541_device *m_drive;
54
55   UINT8 m_data;
56};
57
58
59// device type definition
60extern const device_type C64_BN1541;
61
62
63#endif
src/mess/mess.mak
r14779r14780
776776   $(MESS_MACHINE)/c64_4dxh.o   \
777777   $(MESS_MACHINE)/c64_4ksa.o   \
778778   $(MESS_MACHINE)/c64_4tba.o   \
779   $(MESS_MACHINE)/c64_bn1541.o   \
779780   $(MESS_MACHINE)/c64_comal80.o   \
780781   $(MESS_MACHINE)/c64_dela_ep256.o   \
781782   $(MESS_MACHINE)/c64_dela_ep64.o   \
r14779r14780
789790   $(MESS_MACHINE)/c64_final.o   \
790791   $(MESS_MACHINE)/c64_final3.o   \
791792   $(MESS_MACHINE)/c64_fun_play.o   \
793   $(MESS_MACHINE)/c64_geocable.o   \
792794   $(MESS_MACHINE)/c64_georam.o   \
793795   $(MESS_MACHINE)/c64_ieee488.o   \
794796   $(MESS_MACHINE)/c64_kingsoft.o   \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team