Previous 15994 Revisions Next

r14266 Monday 30th January, 2012 at 12:34:25 UTC by Curt Coder
[C64] Added user port emulation, not connected to driver yet. (nw)
[src/mess]mess.mak
[src/mess/machine]c64user.c* c64user.h* cbmipt.c cbmipt.h

src/mess/machine/cbmipt.c
r14265r14266
11381138   SLOT_INTERFACE("standard", C64_STD)
11391139   SLOT_INTERFACE("xl80", C64_XL80)
11401140SLOT_INTERFACE_END
1141
1142SLOT_INTERFACE_START( c64_user_port_cards )
1143SLOT_INTERFACE_END
src/mess/machine/cbmipt.h
r14265r14266
8989extern const slot_interface slot_interface_cbm_ieee488_devices[];
9090extern const slot_interface slot_interface_vic20_expansion_cards[];
9191extern const slot_interface slot_interface_c64_expansion_cards[];
92extern const slot_interface slot_interface_c64_user_port_cards[];
9293
9394
9495
src/mess/machine/c64user.c
r0r14266
1/**********************************************************************
2
3    Commodore 64 User Port emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "machine/c64user.h"
11
12
13
14//**************************************************************************
15//  GLOBAL VARIABLES
16//**************************************************************************
17
18const device_type C64_USER_PORT = &device_creator<c64_user_port_device>;
19
20
21
22//**************************************************************************
23//  CARD INTERFACE
24//**************************************************************************
25
26//-------------------------------------------------
27//  device_c64_user_port_interface - constructor
28//-------------------------------------------------
29
30device_c64_user_port_interface::device_c64_user_port_interface(const machine_config &mconfig, device_t &device)
31   : device_slot_card_interface(mconfig,device)
32{
33   m_slot = dynamic_cast<c64_user_port_device *>(device.owner());
34}
35
36
37//-------------------------------------------------
38//  ~device_c64_user_port_interface - destructor
39//-------------------------------------------------
40
41device_c64_user_port_interface::~device_c64_user_port_interface()
42{
43}
44
45
46
47//**************************************************************************
48//  LIVE DEVICE
49//**************************************************************************
50
51//-------------------------------------------------
52//  c64_user_port_device - constructor
53//-------------------------------------------------
54
55c64_user_port_device::c64_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
56        device_t(mconfig, C64_USER_PORT, "C64 user port", tag, owner, clock),
57      device_slot_interface(mconfig, *this)
58{
59}
60
61
62//-------------------------------------------------
63//  c64_user_port_device - destructor
64//-------------------------------------------------
65
66c64_user_port_device::~c64_user_port_device()
67{
68}
69
70
71//-------------------------------------------------
72//  device_config_complete - perform any
73//  operations now that the configuration is
74//  complete
75//-------------------------------------------------
76
77void c64_user_port_device::device_config_complete()
78{
79   // inherit a copy of the static data
80   const c64_user_port_interface *intf = reinterpret_cast<const c64_user_port_interface *>(static_config());
81   if (intf != NULL)
82   {
83      *static_cast<c64_user_port_interface *>(this) = *intf;
84   }
85
86   // or initialize to defaults if none provided
87   else
88   {
89       memset(&m_out_cnt1_cb, 0, sizeof(m_out_cnt1_cb));
90       memset(&m_out_sp1_cb, 0, sizeof(m_out_sp1_cb));
91       memset(&m_out_cnt2_cb, 0, sizeof(m_out_cnt2_cb));
92       memset(&m_out_sp2_cb, 0, sizeof(m_out_sp2_cb));
93       memset(&m_out_flag2_cb, 0, sizeof(m_out_flag2_cb));
94       memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb));
95   }
96}
97
98
99//-------------------------------------------------
100//  device_start - device-specific startup
101//-------------------------------------------------
102
103void c64_user_port_device::device_start()
104{
105   m_cart = dynamic_cast<device_c64_user_port_interface *>(get_card_device());
106
107   // resolve callbacks
108   m_out_cnt1_func.resolve(m_out_cnt1_cb, *this);
109   m_out_sp1_func.resolve(m_out_sp1_cb, *this);
110   m_out_cnt2_func.resolve(m_out_cnt2_cb, *this);
111   m_out_sp2_func.resolve(m_out_sp2_cb, *this);
112   m_out_flag2_func.resolve(m_out_flag2_cb, *this);
113   m_out_reset_func.resolve(m_out_reset_cb, *this);
114}
115
116
117//-------------------------------------------------
118//  device_reset - device-specific reset
119//-------------------------------------------------
120
121void c64_user_port_device::device_reset()
122{
123}
124
125
126READ8_MEMBER( c64_user_port_device::pb_r ) { UINT8 data = 0; if (m_cart != NULL) data = m_cart->c64_pb_r(space, offset); return data; }
127WRITE8_MEMBER( c64_user_port_device::pb_w ) { if (m_cart != NULL) m_cart->c64_pb_w(space, offset, data); }
128READ_LINE_MEMBER( c64_user_port_device::pa2_r ) { int state = 0; if (m_cart != NULL) state = m_cart->c64_pa2_r(); return state; }
129WRITE_LINE_MEMBER( c64_user_port_device::pa2_w ) { if (m_cart != NULL) m_cart->c64_pa2_w(state); }
130WRITE_LINE_MEMBER( c64_user_port_device::pc2_w ) { if (m_cart != NULL) m_cart->c64_pc2_w(state); }
131
132WRITE_LINE_MEMBER( c64_user_port_device::cnt1_w ) { m_out_cnt1_func(state); }
133WRITE_LINE_MEMBER( c64_user_port_device::sp1_w ) { m_out_sp1_func(state); }
134WRITE_LINE_MEMBER( c64_user_port_device::cnt2_w ) { m_out_cnt2_func(state); }
135WRITE_LINE_MEMBER( c64_user_port_device::sp2_w ) { m_out_sp2_func(state); }
136WRITE_LINE_MEMBER( c64_user_port_device::flag2_w ) { m_out_flag2_func(state); }
137WRITE_LINE_MEMBER( c64_user_port_device::reset_w ) { m_out_reset_func(state); }
src/mess/machine/c64user.h
r0r14266
1/**********************************************************************
2
3    Commodore 64 User Port emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9
10                    GND       1      A       GND
11                    +5V       2      B       /FLAG2
12                 /RESET       3      C       PB0
13                   CNT1       4      D       PB1
14                    SP1       5      E       PB2
15                   CNT2       6      F       PB3
16                    SP2       7      H       PB4
17                   /PC2       8      J       PB5
18                    ATN       9      K       PB6
19                  +9VAC      10      L       PB7
20                  +9VAC      11      M       PA2
21                    GND      12      N       GND
22
23**********************************************************************/
24
25#pragma once
26
27#ifndef __C64_USER_PORT__
28#define __C64_USER_PORT__
29
30#include "emu.h"
31
32
33
34//**************************************************************************
35//  CONSTANTS
36//**************************************************************************
37
38#define C64_USER_PORT_TAG      "user"
39
40
41
42//**************************************************************************
43//  INTERFACE CONFIGURATION MACROS
44//**************************************************************************
45
46#define C64_USER_PORT_INTERFACE(_name) \
47   const c64_user_port_interface (_name) =
48
49
50#define MCFG_C64_USER_PORT_ADD(_tag, _config, _slot_intf, _def_slot, _def_inp) \
51    MCFG_DEVICE_ADD(_tag, C64_USER_PORT, 0) \
52    MCFG_DEVICE_CONFIG(_config) \
53   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp)
54
55
56
57//**************************************************************************
58//  TYPE DEFINITIONS
59//**************************************************************************
60
61// ======================> c64_user_port_interface
62
63struct c64_user_port_interface
64{
65   devcb_write_line   m_out_cnt1_cb;
66   devcb_write_line   m_out_sp1_cb;
67   devcb_write_line   m_out_cnt2_cb;
68   devcb_write_line   m_out_sp2_cb;
69   devcb_write_line   m_out_flag2_cb;
70    devcb_write_line   m_out_reset_cb;
71};
72
73
74// ======================> c64_user_port_device
75
76class device_c64_user_port_interface;
77
78class c64_user_port_device : public device_t,
79                       public c64_user_port_interface,
80                       public device_slot_interface
81{
82public:
83   // construction/destruction
84   c64_user_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
85   virtual ~c64_user_port_device();
86
87   DECLARE_READ8_MEMBER( pb_r );
88   DECLARE_WRITE8_MEMBER( pb_w );
89   DECLARE_READ_LINE_MEMBER( pa2_r );
90   DECLARE_WRITE_LINE_MEMBER( pa2_w );
91   DECLARE_WRITE_LINE_MEMBER( pc2_w );
92
93   DECLARE_WRITE_LINE_MEMBER( sp1_w );
94   DECLARE_WRITE_LINE_MEMBER( cnt1_w );
95   DECLARE_WRITE_LINE_MEMBER( sp2_w );
96   DECLARE_WRITE_LINE_MEMBER( cnt2_w );
97   DECLARE_WRITE_LINE_MEMBER( flag2_w );
98   DECLARE_WRITE_LINE_MEMBER( reset_w );
99
100protected:
101   // device-level overrides
102   virtual void device_start();
103   virtual void device_reset();
104   virtual void device_config_complete();
105
106   devcb_resolved_write_line   m_out_cnt1_func;
107   devcb_resolved_write_line   m_out_sp1_func;
108   devcb_resolved_write_line   m_out_cnt2_func;
109   devcb_resolved_write_line   m_out_sp2_func;
110   devcb_resolved_write_line   m_out_flag2_func;
111    devcb_resolved_write_line   m_out_reset_func;
112
113   device_c64_user_port_interface *m_cart;
114};
115
116
117// ======================> device_c64_user_port_interface
118
119// class representing interface-specific live c64_expansion card
120class device_c64_user_port_interface : public device_slot_card_interface
121{
122public:
123   // construction/destruction
124   device_c64_user_port_interface(const machine_config &mconfig, device_t &device);
125   virtual ~device_c64_user_port_interface();
126
127   virtual UINT8 c64_pb_r(address_space &space, offs_t offset) { return 0; };
128   virtual void c64_pb_w(address_space &space, offs_t offset, UINT8 data) { };
129
130   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
138   // reset
139   virtual void c64_reset_w(int level) { };
140   
141protected:
142   c64_user_port_device *m_slot;
143};
144
145
146// device type definition
147extern const device_type C64_USER_PORT;
148
149
150
151#endif
src/mess/mess.mak
r14265r14266
748748   $(MESS_MACHINE)/pet.o      \
749749   $(MESS_DRIVERS)/c64.o      \
750750   $(MESS_MACHINE)/c64exp.o   \
751   $(MESS_MACHINE)/c64user.o   \
751752   $(MESS_MACHINE)/c64_std.o   \
752753   $(MESS_MACHINE)/c64_xl80.o   \
753754   $(MESS_MACHINE)/interpod.o   \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team