Previous 15994 Revisions Next

r14198 Thursday 26th January, 2012 at 14:34:46 UTC by Curt Coder
[VIC20] Implemented the expansion port. You can now plug in an IEEE-488 cartridge and any of the CBM IEEE floppy/hard drives. (e.g. mess vic20p -exp ieee488 -exp:ieee488:ieee9 c4040 -flop2 diskimage.d64; SYS 45065; LOAD "$",9) [Curt Coder]
[src/mess]mess.mak
[src/mess/drivers]vic20.c
[src/mess/includes]vic20.h
[src/mess/machine]vic1112.c vic1112.h vic20exp.c* vic20exp.h*

src/mess/machine/vic20exp.c
r0r14198
1/**********************************************************************
2
3    Commodore VIC-20 Expansion Port emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "emu.h"
11#include "emuopts.h"
12#include "machine/vic20exp.h"
13
14
15//**************************************************************************
16//  GLOBAL VARIABLES
17//**************************************************************************
18
19const device_type VIC20_EXPANSION_SLOT = &device_creator<vic20_expansion_slot_device>;
20
21
22//**************************************************************************
23//  DEVICE VIC20_EXPANSION CARD INTERFACE
24//**************************************************************************
25
26//-------------------------------------------------
27//  device_vic20_expansion_card_interface - constructor
28//-------------------------------------------------
29
30device_vic20_expansion_card_interface::device_vic20_expansion_card_interface(const machine_config &mconfig, device_t &device)
31   : device_slot_card_interface(mconfig,device)
32{
33   m_slot = dynamic_cast<vic20_expansion_slot_device *>(device.owner());
34}
35
36
37//-------------------------------------------------
38//  ~device_vic20_expansion_card_interface - destructor
39//-------------------------------------------------
40
41device_vic20_expansion_card_interface::~device_vic20_expansion_card_interface()
42{
43}
44
45
46
47//**************************************************************************
48//  LIVE DEVICE
49//**************************************************************************
50
51//-------------------------------------------------
52//  vic20_expansion_slot_device - constructor
53//-------------------------------------------------
54
55vic20_expansion_slot_device::vic20_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
56        device_t(mconfig, VIC20_EXPANSION_SLOT, "VIC-20 expansion port", tag, owner, clock),
57      device_slot_interface(mconfig, *this),
58      device_image_interface(mconfig, *this)
59{
60}
61
62
63//-------------------------------------------------
64//  vic20_expansion_slot_device - destructor
65//-------------------------------------------------
66
67vic20_expansion_slot_device::~vic20_expansion_slot_device()
68{
69}
70
71
72//-------------------------------------------------
73//  device_config_complete - perform any
74//  operations now that the configuration is
75//  complete
76//-------------------------------------------------
77
78void vic20_expansion_slot_device::device_config_complete()
79{
80   // inherit a copy of the static data
81   const vic20_expansion_slot_interface *intf = reinterpret_cast<const vic20_expansion_slot_interface *>(static_config());
82   if (intf != NULL)
83   {
84      *static_cast<vic20_expansion_slot_interface *>(this) = *intf;
85   }
86
87   // or initialize to defaults if none provided
88   else
89   {
90       memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb));
91       memset(&m_out_nmi_cb, 0, sizeof(m_out_nmi_cb));
92       memset(&m_out_res_cb, 0, sizeof(m_out_res_cb));
93   }
94}
95
96
97//-------------------------------------------------
98//  device_start - device-specific startup
99//-------------------------------------------------
100
101void vic20_expansion_slot_device::device_start()
102{
103   m_cart = dynamic_cast<device_vic20_expansion_card_interface *>(get_card_device());
104
105   // resolve callbacks
106   m_out_irq_func.resolve(m_out_irq_cb, *this);
107   m_out_nmi_func.resolve(m_out_nmi_cb, *this);
108   m_out_res_func.resolve(m_out_res_cb, *this);
109}
110
111
112//-------------------------------------------------
113//  device_reset - device-specific reset
114//-------------------------------------------------
115
116void vic20_expansion_slot_device::device_reset()
117{
118}
119
120
121//-------------------------------------------------
122//  call_load -
123//-------------------------------------------------
124
125bool vic20_expansion_slot_device::call_load()
126{
127   // TODO
128   return IMAGE_INIT_FAIL;
129}
130
131
132//-------------------------------------------------
133//  call_softlist_load -
134//-------------------------------------------------
135
136bool vic20_expansion_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
137{
138   load_software_part_region(this, swlist, swname, start_entry);
139
140   return true;
141}
142
143
144//-------------------------------------------------
145//  get_default_card_software -
146//-------------------------------------------------
147
148const char * vic20_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options) const
149{
150   return software_get_default_slot(config, options, this, "standard");
151}
152
153
154//-------------------------------------------------
155//  get_cart_base -
156//-------------------------------------------------
157
158UINT8* vic20_expansion_slot_device::get_cart_base()
159{
160   return NULL;
161}
162
163
164//-------------------------------------------------
165//  screen_update -
166//-------------------------------------------------
167
168UINT32 vic20_expansion_slot_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
169{
170   bool value = false;
171
172   if (m_cart != NULL)
173   {
174      value = m_cart->vic20_screen_update(screen, bitmap, cliprect);
175   }
176
177   return value;
178}
179
180
181READ8_MEMBER( vic20_expansion_slot_device::ram1_r ) { UINT8 data = 0; if (m_cart != NULL) data = m_cart->vic20_ram1_r(space, offset); return data; }
182WRITE8_MEMBER( vic20_expansion_slot_device::ram1_w ) { if (m_cart != NULL) m_cart->vic20_ram1_w(space, offset, data); }
183READ8_MEMBER( vic20_expansion_slot_device::ram2_r ) { UINT8 data = 0; if (m_cart != NULL) data = m_cart->vic20_ram2_r(space, offset); return data; }
184WRITE8_MEMBER( vic20_expansion_slot_device::ram2_w ) { if (m_cart != NULL) m_cart->vic20_ram2_w(space, offset, data); }
185READ8_MEMBER( vic20_expansion_slot_device::ram3_r ) { UINT8 data = 0; if (m_cart != NULL) data = m_cart->vic20_ram3_r(space, offset); return data; }
186WRITE8_MEMBER( vic20_expansion_slot_device::ram3_w ) { if (m_cart != NULL) m_cart->vic20_ram3_w(space, offset, data); }
187READ8_MEMBER( vic20_expansion_slot_device::blk1_r ) { UINT8 data = 0; if (m_cart != NULL) data = m_cart->vic20_blk1_r(space, offset); return data; }
188WRITE8_MEMBER( vic20_expansion_slot_device::blk1_w ) { if (m_cart != NULL) m_cart->vic20_blk1_w(space, offset, data); }
189READ8_MEMBER( vic20_expansion_slot_device::blk2_r ) { UINT8 data = 0; if (m_cart != NULL) data = m_cart->vic20_blk2_r(space, offset); return data; }
190WRITE8_MEMBER( vic20_expansion_slot_device::blk2_w ) { if (m_cart != NULL) m_cart->vic20_blk2_w(space, offset, data); }
191READ8_MEMBER( vic20_expansion_slot_device::blk3_r ) { UINT8 data = 0; if (m_cart != NULL) data = m_cart->vic20_blk3_r(space, offset); return data; }
192WRITE8_MEMBER( vic20_expansion_slot_device::blk3_w ) { if (m_cart != NULL) m_cart->vic20_blk3_w(space, offset, data); }
193READ8_MEMBER( vic20_expansion_slot_device::blk5_r ) { UINT8 data = 0; if (m_cart != NULL) data = m_cart->vic20_blk5_r(space, offset); return data; }
194WRITE8_MEMBER( vic20_expansion_slot_device::blk5_w ) { if (m_cart != NULL) m_cart->vic20_blk5_w(space, offset, data); }
195READ8_MEMBER( vic20_expansion_slot_device::io2_r ) { UINT8 data = 0; if (m_cart != NULL) data = m_cart->vic20_io2_r(space, offset); return data; }
196WRITE8_MEMBER( vic20_expansion_slot_device::io2_w ) { if (m_cart != NULL) m_cart->vic20_io2_w(space, offset, data); }
197READ8_MEMBER( vic20_expansion_slot_device::io3_r ) { UINT8 data = 0; if (m_cart != NULL) data = m_cart->vic20_io3_r(space, offset); return data; }
198WRITE8_MEMBER( vic20_expansion_slot_device::io3_w ) { if (m_cart != NULL) m_cart->vic20_io3_w(space, offset, data); }
199
200WRITE_LINE_MEMBER( vic20_expansion_slot_device::irq_w ) { m_out_irq_func(state); }
201WRITE_LINE_MEMBER( vic20_expansion_slot_device::nmi_w ) { m_out_nmi_func(state); }
202WRITE_LINE_MEMBER( vic20_expansion_slot_device::res_w ) { m_out_res_func(state); }
src/mess/machine/vic20exp.h
r0r14198
1/**********************************************************************
2
3    Commodore VIC-20 Expansion 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                    CD0       2      B       CA0
12                    CD1       3      C       CA1
13                    CD2       4      D       CA2
14                    CD3       5      E       CA3
15                    CD4       6      F       CA4
16                    CD5       7      H       CA5
17                    CD6       8      J       CA6
18                    CD7       9      K       CA7
19                   BLK1      10      L       CA8
20                   BLK2      11      M       CA9
21                   BLK3      12      N       CA10
22                   BLK5      13      P       CA11
23                  _RAM1      14      R       CA12
24                  _RAM2      15      S       CA13
25                  _RAM3      16      T       _I/O2
26                   VR/W      17      U       _I/O3
27                   CR/W      18      V       Sphi2
28                   _IRQ      19      W       _NMI
29                   N.C.      20      X       _RES
30                    +5V      21      Y       N.C.
31                    GND      22      Z       GND
32
33**********************************************************************/
34
35#pragma once
36
37#ifndef __VIC20_EXPANSION_SLOT__
38#define __VIC20_EXPANSION_SLOT__
39
40#include "emu.h"
41
42
43
44//**************************************************************************
45//  CONSTANTS
46//**************************************************************************
47
48#define VIC20_EXPANSION_SLOT_TAG      "exp"
49
50
51
52//**************************************************************************
53//  INTERFACE CONFIGURATION MACROS
54//**************************************************************************
55
56#define VIC20_EXPANSION_INTERFACE(_name) \
57   const vic20_expansion_slot_interface (_name) =
58
59
60#define MCFG_VIC20_EXPANSION_SLOT_ADD(_tag, _config, _slot_intf, _def_slot, _def_inp) \
61    MCFG_DEVICE_ADD(_tag, VIC20_EXPANSION_SLOT, 0) \
62    MCFG_DEVICE_CONFIG(_config) \
63   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp)
64
65
66
67//**************************************************************************
68//  TYPE DEFINITIONS
69//**************************************************************************
70
71// ======================> vic20_expansion_slot_interface
72
73struct vic20_expansion_slot_interface
74{
75    devcb_write_line   m_out_irq_cb;
76    devcb_write_line   m_out_nmi_cb;
77    devcb_write_line   m_out_res_cb;
78};
79
80
81// ======================> vic20_expansion_slot_device
82
83class device_vic20_expansion_card_interface;
84
85class vic20_expansion_slot_device : public device_t,
86                            public vic20_expansion_slot_interface,
87                            public device_slot_interface,
88                            public device_image_interface
89{
90public:
91   // construction/destruction
92   vic20_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
93   virtual ~vic20_expansion_slot_device();
94
95   DECLARE_READ8_MEMBER( ram1_r );
96   DECLARE_WRITE8_MEMBER( ram1_w );
97   DECLARE_READ8_MEMBER( ram2_r );
98   DECLARE_WRITE8_MEMBER( ram2_w );
99   DECLARE_READ8_MEMBER( ram3_r );
100   DECLARE_WRITE8_MEMBER( ram3_w );
101   DECLARE_READ8_MEMBER( blk1_r );
102   DECLARE_WRITE8_MEMBER( blk1_w );
103   DECLARE_READ8_MEMBER( blk2_r );
104   DECLARE_WRITE8_MEMBER( blk2_w );
105   DECLARE_READ8_MEMBER( blk3_r );
106   DECLARE_WRITE8_MEMBER( blk3_w );
107   DECLARE_READ8_MEMBER( blk5_r );
108   DECLARE_WRITE8_MEMBER( blk5_w );
109   DECLARE_READ8_MEMBER( io2_r );
110   DECLARE_WRITE8_MEMBER( io2_w );
111   DECLARE_READ8_MEMBER( io3_r );
112   DECLARE_WRITE8_MEMBER( io3_w );
113
114   DECLARE_WRITE_LINE_MEMBER( irq_w );
115   DECLARE_WRITE_LINE_MEMBER( nmi_w );
116   DECLARE_WRITE_LINE_MEMBER( res_w );
117
118   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
119
120protected:
121   // device-level overrides
122   virtual void device_start();
123   virtual void device_reset();
124   virtual void device_config_complete();
125
126   // image-level overrides
127   virtual bool call_load();
128   virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
129
130   virtual iodevice_t image_type() const { return IO_CARTSLOT; }
131
132   virtual bool is_readable()  const { return 1; }
133   virtual bool is_writeable() const { return 0; }
134   virtual bool is_creatable() const { return 0; }
135   virtual bool must_be_loaded() const { return 0; }
136   virtual bool is_reset_on_load() const { return 1; }
137   virtual const char *image_interface() const { return "vic20_cart"; }
138   virtual const char *file_extensions() const { return "20,40,60,70,a0,b0"; }
139   virtual const option_guide *create_option_guide() const { return NULL; }
140
141   // slot interface overrides
142   virtual const char * get_default_card_software(const machine_config &config, emu_options &options) const;
143
144   virtual UINT8* get_cart_base();
145
146   devcb_resolved_write_line   m_out_irq_func;
147   devcb_resolved_write_line   m_out_nmi_func;
148   devcb_resolved_write_line   m_out_res_func;
149
150   device_vic20_expansion_card_interface *m_cart;
151};
152
153
154// device type definition
155extern const device_type VIC20_EXPANSION_SLOT;
156
157
158// ======================> device_vic20_expansion_card_interface
159
160// class representing interface-specific live vic20_expansion card
161class device_vic20_expansion_card_interface : public device_slot_card_interface
162{
163public:
164   // construction/destruction
165   device_vic20_expansion_card_interface(const machine_config &mconfig, device_t &device);
166   virtual ~device_vic20_expansion_card_interface();
167
168   // RAM
169   virtual UINT8 vic20_ram1_r(address_space &space, offs_t offset) { return 0; };
170   virtual void vic20_ram1_w(address_space &space, offs_t offset, UINT8 data) { };
171
172   virtual UINT8 vic20_ram2_r(address_space &space, offs_t offset) { return 0; };
173   virtual void vic20_ram2_w(address_space &space, offs_t offset, UINT8 data) { };
174
175   virtual UINT8 vic20_ram3_r(address_space &space, offs_t offset) { return 0; };
176   virtual void vic20_ram3_w(address_space &space, offs_t offset, UINT8 data) { };
177
178   // ROM
179   virtual UINT8 vic20_blk1_r(address_space &space, offs_t offset) { return 0; };
180   virtual void vic20_blk1_w(address_space &space, offs_t offset, UINT8 data) { };
181
182   virtual UINT8 vic20_blk2_r(address_space &space, offs_t offset) { return 0; };
183   virtual void vic20_blk2_w(address_space &space, offs_t offset, UINT8 data) { };
184
185   virtual UINT8 vic20_blk3_r(address_space &space, offs_t offset) { return 0; };
186   virtual void vic20_blk3_w(address_space &space, offs_t offset, UINT8 data) { };
187
188   virtual UINT8 vic20_blk5_r(address_space &space, offs_t offset) { return 0; };
189   virtual void vic20_blk5_w(address_space &space, offs_t offset, UINT8 data) { };
190
191   // I/O
192   virtual UINT8 vic20_io2_r(address_space &space, offs_t offset) { return 0; };
193   virtual void vic20_io2_w(address_space &space, offs_t offset, UINT8 data) { };
194
195   virtual UINT8 vic20_io3_r(address_space &space, offs_t offset) { return 0; };
196   virtual void vic20_io3_w(address_space &space, offs_t offset, UINT8 data) { };
197
198   // video
199   virtual UINT32 vic20_screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { return false; }
200
201   virtual UINT8* get_cart_base() { return NULL; }
202   
203protected:
204   vic20_expansion_slot_device *m_slot;
205};
206
207
208
209#endif
src/mess/machine/vic1112.c
r14197r14198
3131//  IEEE488_INTERFACE( ieee488_intf )
3232//-------------------------------------------------
3333
34static SLOT_INTERFACE_START( cbm_ieee488_devices )
35   SLOT_INTERFACE("c2040", C2040)
36   SLOT_INTERFACE("c3040", C3040)
37   SLOT_INTERFACE("c4040", C4040)
38   SLOT_INTERFACE("c8050", C8050)
39   SLOT_INTERFACE("c8250", C8250)
40   SLOT_INTERFACE("sfd1001", SFD1001)
41   SLOT_INTERFACE("c2031", C2031)
42   SLOT_INTERFACE("c8280", C8280)
43   SLOT_INTERFACE("d9060", D9060)
44   SLOT_INTERFACE("d9090", D9090)
45SLOT_INTERFACE_END
46
47IEEE488_INTERFACE( ieee488_intf )
34static IEEE488_INTERFACE( ieee488_intf )
4835{
4936   DEVCB_NULL,
5037   DEVCB_NULL,
r14197r14198
6249//-------------------------------------------------
6350
6451ROM_START( vic1112 )
65   ROM_REGION( 0x800, VIC1112_TAG, 0 )
52   ROM_REGION( 0x800, "blk5", 0 )
6653   ROM_LOAD( "325329-03.u2", 0x000, 0x800, CRC(d37b6335) SHA1(828c965829d21c60e8c2d083caee045c639a270f) )
6754ROM_END
6855
r14197r14198
8572{
8673   m_via0_irq = state;
8774
88   device_set_input_line(machine().firstcpu, M6502_IRQ_LINE, (m_via0_irq | m_via1_irq) ? ASSERT_LINE : CLEAR_LINE);
75   m_slot->irq_w(m_via0_irq | m_via1_irq);
8976}
9077
91
9278READ8_MEMBER( vic1112_device::via0_pb_r )
9379{
9480   /*
9581
9682        bit     description
9783
98        PB0     _DAV OUT
99        PB1     _NRFD OUT
100        PB2     _NDAC OUT
84        PB0     
85        PB1     
86        PB2     
10187        PB3     _EOI
10288        PB4     _DAV IN
10389        PB5     _NRFD IN
r14197r14198
10894
10995   UINT8 data = 0;
11096
111   /* end or identify */
11297   data |= m_bus->eoi_r() << 3;
113
114   /* data valid in */
11598   data |= m_bus->dav_r() << 4;
116
117   /* not ready for data in */
11899   data |= m_bus->nrfd_r() << 5;
119
120   /* not data accepted in */
121100   data |= m_bus->ndac_r() << 6;
122
123   /* attention in */
124101   data |= m_bus->atn_r() << 7;
125102
126103   return data;
127104}
128105
129
130106WRITE8_MEMBER( vic1112_device::via0_pb_w )
131107{
132108   /*
r14197r14198
136112        PB0     _DAV OUT
137113        PB1     _NRFD OUT
138114        PB2     _NDAC OUT
139        PB3     _EOI IN
140        PB4     _DAV IN
141        PB5     _NRFD IN
142        PB6     _NDAC IN
143        PB7     _ATN IN
115        PB3     
116        PB4     
117        PB5     
118        PB6     
119        PB7     
144120
145121    */
146122
147   /* data valid out */
148123   m_bus->dav_w(BIT(data, 0));
149
150   /* not ready for data out */
151124   m_bus->nrfd_w(BIT(data, 1));
152
153   /* not data accepted out */
154125   m_bus->ndac_w(BIT(data, 2));
155126}
156127
157
158128static const via6522_interface via0_intf =
159129{
160130   DEVCB_NULL,
r14197r14198
183153{
184154   m_via1_irq = state;
185155
186   device_set_input_line(machine().firstcpu, M6502_IRQ_LINE, (m_via0_irq | m_via1_irq) ? ASSERT_LINE : CLEAR_LINE);
156   m_slot->irq_w(m_via0_irq | m_via1_irq);
187157}
188158
189READ8_MEMBER( vic1112_device::dio_r )
190{
191   /*
192
193        bit     description
194
195        PB0     DI1
196        PB1     DI2
197        PB2     DI3
198        PB3     DI4
199        PB4     DI5
200        PB5     DI6
201        PB6     DI7
202        PB7     DI8
203
204    */
205
206   return m_bus->dio_r();
207}
208
209
210WRITE8_MEMBER( vic1112_device::dio_w )
211{
212   /*
213
214        bit     description
215
216        PA0     DO1
217        PA1     DO2
218        PA2     DO3
219        PA3     DO4
220        PA4     DO5
221        PA5     DO6
222        PA6     DO7
223        PA7     DO8
224
225    */
226
227   m_bus->dio_w(data);
228}
229
230
231WRITE_LINE_MEMBER( vic1112_device::atn_w )
232{
233   /* attention out */
234   m_bus->atn_w(state);
235}
236
237
238READ_LINE_MEMBER( vic1112_device::srq_r )
239{
240   /* service request in */
241   return m_bus->srq_r();
242}
243
244
245WRITE_LINE_MEMBER( vic1112_device::eoi_w )
246{
247   /* end or identify out */
248   m_bus->eoi_w(state);
249}
250
251
252159static const via6522_interface via1_intf =
253160{
254161   DEVCB_NULL,
255   DEVCB_MEMBER(vic1112_device, dio_r),
162   DEVCB_DEVICE_MEMBER(IEEE488_TAG, ieee488_device, dio_r),
256163   DEVCB_NULL,
257   DEVCB_LINE_MEMBER(vic1112_device, srq_r),
164   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, srq_r),
258165   DEVCB_NULL,
259166   DEVCB_NULL,
260167
261   DEVCB_MEMBER(vic1112_device, dio_w),
168   DEVCB_DEVICE_MEMBER(IEEE488_TAG, ieee488_device, dio_w),
262169   DEVCB_NULL,
263170   DEVCB_NULL,
264171   DEVCB_NULL,
265   DEVCB_LINE_MEMBER(vic1112_device, atn_w),
266   DEVCB_LINE_MEMBER(vic1112_device, eoi_w),
172   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, atn_w),
173   DEVCB_DEVICE_LINE_MEMBER(IEEE488_TAG, ieee488_device, eoi_w),
267174
268175   DEVCB_LINE_MEMBER(vic1112_device, via1_irq_w)
269176};
r14197r14198
277184   MCFG_VIA6522_ADD(M6522_0_TAG, 0, via0_intf)
278185   MCFG_VIA6522_ADD(M6522_1_TAG, 0, via1_intf)
279186
280   MCFG_IEEE488_BUS_ADD(ieee488_intf)
281   MCFG_IEEE488_SLOT_ADD("ieee8", 8, cbm_ieee488_devices, NULL, NULL)
282   MCFG_IEEE488_SLOT_ADD("ieee9", 9, cbm_ieee488_devices, NULL, NULL)
283   MCFG_IEEE488_SLOT_ADD("ieee10", 10, cbm_ieee488_devices, NULL, NULL)
284   MCFG_IEEE488_SLOT_ADD("ieee11", 11, cbm_ieee488_devices, NULL, NULL)
187   MCFG_CBM_IEEE488_ADD(ieee488_intf, NULL)
285188MACHINE_CONFIG_END
286189
287190
r14197r14198
307210
308211vic1112_device::vic1112_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
309212    : device_t(mconfig, VIC1112, "VIC1112", tag, owner, clock),
213     device_vic20_expansion_card_interface(mconfig, *this),
310214     m_via0(*this, M6522_0_TAG),
311215     m_via1(*this, M6522_1_TAG),
312216     m_bus(*this, IEEE488_TAG)
r14197r14198
320224
321225void vic1112_device::device_start()
322226{
323   address_space *program = machine().firstcpu->memory().space(AS_PROGRAM);
324
325   // map VIAs to VIC-20 address space
326   program->install_readwrite_handler(0x9800, 0x980f, 0, 0, read8_delegate(FUNC(via6522_device::read), (via6522_device*)m_via0), write8_delegate(FUNC(via6522_device::write), (via6522_device*)m_via0));
327   program->install_readwrite_handler(0x9810, 0x981f, 0, 0, read8_delegate(FUNC(via6522_device::read), (via6522_device*)m_via1), write8_delegate(FUNC(via6522_device::write), (via6522_device*)m_via1));
328
329   // map ROM to VIC-20 address space
330   program->install_rom(0xb000, 0xb7ff, subregion(VIC1112_TAG)->base());
331
227   // find memory regions
228   m_rom = subregion("blk5")->base();
229   
332230   // state saving
333231   save_item(NAME(m_via0_irq));
334232   save_item(NAME(m_via1_irq));
r14197r14198
344242   m_bus->ifc_w(0);
345243   m_bus->ifc_w(1);
346244}
245
246
247//-------------------------------------------------
248//  vic20_io2_r - I/O 2 read
249//-------------------------------------------------
250
251UINT8 vic1112_device::vic20_io2_r(address_space &space, offs_t offset)
252{
253   UINT8 data = 0;
254   
255   if (offset & 0x10)
256   {
257      data = m_via1->read(space, offset & 0x0f);
258   }
259   else
260   {
261      data = m_via0->read(space, offset & 0x0f);
262   }
263   
264   return data;
265}
266
267
268//-------------------------------------------------
269//  vic20_io2_r - I/O 2 write
270//-------------------------------------------------
271
272void vic1112_device::vic20_io2_w(address_space &space, offs_t offset, UINT8 data)
273{
274   if (offset & 0x10)
275   {
276      m_via1->write(space, offset & 0x0f, data);
277   }
278   else
279   {
280      m_via0->write(space, offset & 0x0f, data);
281   }
282}
283
284
285//-------------------------------------------------
286//  vic20_blk5_r - block 5 read
287//-------------------------------------------------
288
289UINT8 vic1112_device::vic20_blk5_r(address_space &space, offs_t offset)
290{
291   UINT8 data = 0;
292   
293   if (offset & 0x1000)
294   {
295      data = m_rom[offset & 0x7ff];
296   }
297   
298   return data;
299}
src/mess/machine/vic1112.h
r14197r14198
1919#include "emu.h"
2020#include "cpu/m6502/m6502.h"
2121#include "machine/6522via.h"
22#include "machine/cbmipt.h"
2223#include "machine/ieee488.h"
23#include "machine/c2031.h"
24#include "machine/c2040.h"
25#include "machine/c8280.h"
26#include "machine/d9060.h"
24#include "machine/vic20exp.h"
2725
2826
2927
r14197r14198
4846//  TYPE DEFINITIONS
4947//**************************************************************************
5048
51// ======================> vic1112_interface
52
53struct vic1112_interface
54{
55   const char *m_bus_tag;
56};
57
5849// ======================> vic1112_device
5950
6051class vic1112_device :  public device_t,
61                  public vic1112_interface
52                  public device_vic20_expansion_card_interface
6253{
6354public:
6455    // construction/destruction
6556    vic1112_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
6657
58   // optional information overrides
59   virtual const rom_entry *device_rom_region() const;
60   virtual machine_config_constructor device_mconfig_additions() const;
61
6762   // not really public
6863   DECLARE_WRITE_LINE_MEMBER( via0_irq_w );
6964   DECLARE_READ8_MEMBER( via0_pb_r );
7065   DECLARE_WRITE8_MEMBER( via0_pb_w );
7166   DECLARE_WRITE_LINE_MEMBER( via1_irq_w );
72   DECLARE_READ8_MEMBER( dio_r );
73   DECLARE_WRITE8_MEMBER( dio_w );
74   DECLARE_WRITE_LINE_MEMBER( atn_w );
75   DECLARE_READ_LINE_MEMBER( srq_r );
76   DECLARE_WRITE_LINE_MEMBER( eoi_w );
77
78   // optional information overrides
79   virtual const rom_entry *device_rom_region() const;
80   virtual machine_config_constructor device_mconfig_additions() const;
67   
8168protected:
8269    // device-level overrides
8370    virtual void device_start();
8471   virtual void device_reset();
8572    virtual void device_config_complete() { m_shortname = "vic1112"; }
73   
74   // device_vic20_expansion_card_interface overrides
75   virtual UINT8 vic20_io2_r(address_space &space, offs_t offset);
76   virtual void vic20_io2_w(address_space &space, offs_t offset, UINT8 data);
77   virtual UINT8 vic20_blk5_r(address_space &space, offs_t offset);
8678
8779private:
8880   required_device<via6522_device> m_via0;
8981   required_device<via6522_device> m_via1;
9082   required_device<ieee488_device> m_bus;
9183
84   UINT8 *m_rom;
85
9286   int m_via0_irq;
9387   int m_via1_irq;
94
95   const char *m_bus_tag;
9688};
9789
9890
src/mess/includes/vic20.h
r14197r14198
1515#include "machine/cbmipt.h"
1616#include "machine/ieee488.h"
1717#include "machine/ram.h"
18#include "machine/vic20exp.h"
1819#include "machine/vic1112.h"
1920#include "sound/dac.h"
2021#include "sound/mos6560.h"
src/mess/mess.mak
r14197r14198
752752   $(MESS_MACHINE)/c64_xl80.o   \
753753   $(MESS_MACHINE)/interpod.o   \
754754   $(MESS_DRIVERS)/vic20.o      \
755   $(MESS_MACHINE)/vic20exp.o   \
755756   $(MESS_MACHINE)/vic1112.o   \
756757   $(MESS_AUDIO)/ted7360.o      \
757758   $(MESS_AUDIO)/t6721.o      \
src/mess/drivers/vic20.c
r14197r14198
5656
5757    TODO:
5858
59   - load cartridges with expansion port device
60   - implement RAM expansion with expansion port device
5961    - C1540 is not working currently
60    - clean up inputs
61    - clean up VIA interface
6262    - access violation in mos6560.c
6363        * In the Chips (Japan, USA).60
6464        * K-Star Patrol (Europe).60
r14197r14198
222222
223223static ADDRESS_MAP_START( vic20_mem, AS_PROGRAM, 8, vic20_state )
224224   AM_RANGE(0x0000, 0x03ff) AM_RAM
225//  AM_RANGE(0x0400, 0x07ff) RAM1
226//  AM_RANGE(0x0800, 0x0bff) RAM2
227//  AM_RANGE(0x0c00, 0x0fff) RAM3
225   AM_RANGE(0x0400, 0x07ff) AM_DEVREADWRITE(VIC20_EXPANSION_SLOT_TAG, vic20_expansion_slot_device, ram1_r, ram1_w)
226   AM_RANGE(0x0800, 0x0bff) AM_DEVREADWRITE(VIC20_EXPANSION_SLOT_TAG, vic20_expansion_slot_device, ram2_r, ram2_w)
227   AM_RANGE(0x0c00, 0x0fff) AM_DEVREADWRITE(VIC20_EXPANSION_SLOT_TAG, vic20_expansion_slot_device, ram3_r, ram3_w)
228228   AM_RANGE(0x1000, 0x1fff) AM_RAM
229//  AM_RANGE(0x2000, 0x3fff) BLK1
230//  AM_RANGE(0x4000, 0x5fff) BLK2
231//  AM_RANGE(0x6000, 0x7fff) BLK3
229   AM_RANGE(0x2000, 0x3fff) AM_DEVREADWRITE(VIC20_EXPANSION_SLOT_TAG, vic20_expansion_slot_device, blk1_r, blk1_w)
230   AM_RANGE(0x4000, 0x5fff) AM_DEVREADWRITE(VIC20_EXPANSION_SLOT_TAG, vic20_expansion_slot_device, blk2_r, blk2_w)
231   AM_RANGE(0x6000, 0x7fff) AM_DEVREADWRITE(VIC20_EXPANSION_SLOT_TAG, vic20_expansion_slot_device, blk3_r, blk3_w)
232232   AM_RANGE(0x8000, 0x8fff) AM_ROM
233233   AM_RANGE(0x9000, 0x900f) AM_DEVREADWRITE_LEGACY(M6560_TAG, mos6560_port_r, mos6560_port_w)
234234   AM_RANGE(0x9110, 0x911f) AM_DEVREADWRITE(M6522_0_TAG, via6522_device, read, write)
235235   AM_RANGE(0x9120, 0x912f) AM_DEVREADWRITE(M6522_1_TAG, via6522_device, read, write)
236236   AM_RANGE(0x9400, 0x97ff) AM_RAM
237//  AM_RANGE(0x9800, 0x9bff) I/O2
238//  AM_RANGE(0x9c00, 0x9fff) I/O3
239//  AM_RANGE(0xa000, 0xbfff) BLK5
237   AM_RANGE(0x9800, 0x9bff) AM_DEVREADWRITE(VIC20_EXPANSION_SLOT_TAG, vic20_expansion_slot_device, io2_r, io2_w)
238   AM_RANGE(0x9c00, 0x9fff) AM_DEVREADWRITE(VIC20_EXPANSION_SLOT_TAG, vic20_expansion_slot_device, io3_r, io3_w)
239   AM_RANGE(0xa000, 0xbfff) AM_DEVREADWRITE(VIC20_EXPANSION_SLOT_TAG, vic20_expansion_slot_device, blk5_r, blk5_w)
240240   AM_RANGE(0xc000, 0xffff) AM_ROM
241241ADDRESS_MAP_END
242242
r14197r14198
679679};
680680
681681
682//-------------------------------------------------
683//  VIC20_EXPANSION_INTERFACE( expansion_intf )
684//-------------------------------------------------
682685
686static SLOT_INTERFACE_START( vic20_expansion_cards )
687   SLOT_INTERFACE("ieee488", VIC1112)
688SLOT_INTERFACE_END
689
690static VIC20_EXPANSION_INTERFACE( expansion_intf )
691{
692   DEVCB_CPU_INPUT_LINE(M6502_TAG, INPUT_LINE_IRQ0),
693   DEVCB_CPU_INPUT_LINE(M6502_TAG, INPUT_LINE_NMI),
694   DEVCB_CPU_INPUT_LINE(M6502_TAG, INPUT_LINE_RESET)
695};
696
697
683698//**************************************************************************
684699//  MACHINE INITIALIZATION
685700//**************************************************************************
r14197r14198
736751   MCFG_CASSETTE_ADD(CASSETTE_TAG, cbm_cassette_interface )
737752
738753   MCFG_CBM_IEC_ADD(cbm_iec_intf, "c1541")
739#ifdef INCLUDE_VIC1112
740    MCFG_VIC1112_ADD()
741#endif
754
742755   MCFG_CARTSLOT_ADD("cart")
743756   MCFG_CARTSLOT_EXTENSION_LIST("20,40,60,70,a0,b0")
744757   MCFG_CARTSLOT_NOT_MANDATORY
745758   MCFG_CARTSLOT_INTERFACE("vic1001_cart")
746759   MCFG_CARTSLOT_LOAD(vic20_cart)
760   
761   MCFG_VIC20_EXPANSION_SLOT_ADD(VIC20_EXPANSION_SLOT_TAG, expansion_intf, vic20_expansion_cards, NULL, NULL)
747762
748763   // software lists
749764   MCFG_SOFTWARE_LIST_ADD("cart_list", "vic1001_cart")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team