Previous 15994 Revisions Next

r11459 Friday 6th May, 2011 at 19:37:54 UTC by Curt Coder
[C64] Cartridge WIP. (nw)
[src/mess]mess.mak
[src/mess/drivers]c64.c
[src/mess/machine]c64.c c64crtstd.c c64crtstd.h c64expp.c c64expp.h

src/mess/machine/c64crtstd.c
r11458r11459
1/**********************************************************************
2
3    Commodore 64 standard 8K/16K cartridge emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "c64crtstd.h"
11
12
13
14//**************************************************************************
15//  DEVICE DEFINITIONS
16//**************************************************************************
17
18const device_type C64_CARTRIDGE_STANDARD = &device_creator<c64_cartridge_standard_device>;
19
20
21//-------------------------------------------------
22//  static_set_config - configuration helper
23//-------------------------------------------------
24
25void c64_cartridge_standard_device::static_set_config(device_t &device, const UINT8 *roml, size_t roml_size, const UINT8 *romh, size_t romh_size)
26{
27   c64_cartridge_standard_device &cartridge = downcast<c64_cartridge_standard_device &>(device);
28
29   cartridge.m_roml = roml;
30   cartridge.m_roml_mask = roml_size - 1;
31   cartridge.m_romh = romh;
32   cartridge.m_romh_mask = romh_size - 1;
33}
34
35
36//**************************************************************************
37//  LIVE DEVICE
38//**************************************************************************
39
40//-------------------------------------------------
41//  c64_cartridge_standard_device - constructor
42//-------------------------------------------------
43
44c64_cartridge_standard_device::c64_cartridge_standard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
45    : device_t(mconfig, C64_CARTRIDGE_STANDARD, "Standard 8K/16K cartridge", tag, owner, clock),
46     device_c64_expansion_port_interface(mconfig, *this),
47     m_roml(NULL),
48     m_romh(NULL),
49     m_roml_mask(0x1fff),
50     m_romh_mask(0x1fff)
51{
52}
53
54
55//-------------------------------------------------
56//  device_start - device-specific startup
57//-------------------------------------------------
58
59void c64_cartridge_standard_device::device_start()
60{
61}
src/mess/machine/c64crtstd.h
r11458r11459
1/**********************************************************************
2
3    Commodore 64 standard 8K/16K cartridge 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_CARTRIDGE_STANDARD__
13#define __C64_CARTRIDGE_STANDARD__
14
15#include "emu.h"
16#include "c64expp.h"
17
18
19
20//**************************************************************************
21//  INTERFACE CONFIGURATION MACROS
22//**************************************************************************
23
24#define MCFG_C64_CARTRIDGE_8K_ADD(_tag, _roml, _roml_size) \
25   MCFG_DEVICE_ADD(_tag, C64_CARTRIDGE_STANDARD, 0) \
26   c64_cartridge_standard_device::static_set_config(*device, _roml, _roml_size, NULL, 0);
27
28
29#define MCFG_C64_CARTRIDGE_16K_ADD(_tag, _roml, _roml_size, _romh, _romh_size) \
30   MCFG_DEVICE_ADD(_tag, C64_CARTRIDGE_STANDARD, 0) \
31   c64_cartridge_standard_device::static_set_config(*device, _roml, _roml_size, _romh, _romh_size);
32
33   
34
35//**************************************************************************
36//  TYPE DEFINITIONS
37//**************************************************************************
38
39// ======================> c64_cartridge_standard_device
40
41class c64_cartridge_standard_device :  public device_t,
42                              public device_c64_expansion_port_interface
43{
44public:
45    // construction/destruction
46    c64_cartridge_standard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
47
48   // inline configuration helpers
49   static void static_set_config(device_t &device, const UINT8 *roml, size_t roml_size, const UINT8 *romh, size_t romh_size);
50
51protected:
52    // device-level overrides
53    virtual void device_start();
54
55   // device_c64_expansion_port_interface overrides
56   int c64_game_r() { return 0; }
57   int c64_exrom_r() { return 0; }
58   UINT8 c64_roml_r(offs_t offset) { if (m_roml != NULL) return m_roml[offset & m_roml_mask]; else return 0; }
59   UINT8 c64_romh_r(offs_t offset) { if (m_romh != NULL) return m_romh[offset & m_romh_mask]; else return 0; }
60   
61private:
62   const UINT8 *m_roml;
63   const UINT8 *m_romh;
64   
65   size_t m_roml_mask;
66   size_t m_romh_mask;
67};
68
69
70// device type definition
71extern const device_type C64_CARTRIDGE_STANDARD;
72
73
74
75#endif
src/mess/machine/c64expp.c
r11458r11459
1/**********************************************************************
2
3    Commodore 64 expansion port emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "machine/c64expp.h"
11
12
13
14//**************************************************************************
15//  MACROS / CONSTANTS
16//**************************************************************************
17
18#define LOG 1
19
20
21
22//**************************************************************************
23//  DEVICE DEFINITIONS
24//**************************************************************************
25
26const device_type C64_EXPANSION_PORT = &device_creator<c64_expansion_port_device>;
27
28
29
30//**************************************************************************
31//  DEVICE INTERFACE
32//**************************************************************************
33
34//-------------------------------------------------
35//  device_c64_expansion_port_interface - constructor
36//-------------------------------------------------
37
38device_c64_expansion_port_interface::device_c64_expansion_port_interface(const machine_config &mconfig, device_t &device)
39   : device_interface(device)
40{
41}
42
43
44//-------------------------------------------------
45//  ~device_c64_expansion_port_interface - destructor
46//-------------------------------------------------
47
48device_c64_expansion_port_interface::~device_c64_expansion_port_interface()
49{
50}
51
52
53
54//**************************************************************************
55//  LIVE DEVICE
56//**************************************************************************
57
58//-------------------------------------------------
59//  c64_expansion_port_device - constructor
60//-------------------------------------------------
61
62c64_expansion_port_device::c64_expansion_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
63    : device_t(mconfig, C64_EXPANSION_PORT, "C64 expansion port", tag, owner, clock),
64   m_device(NULL),
65   m_interface(NULL)
66{
67}
68
69
70//-------------------------------------------------
71//  device_start - device-specific startup
72//-------------------------------------------------
73
74void c64_expansion_port_device::device_start()
75{
76   // resolve callbacks
77   m_out_game_func.resolve(m_out_game_cb, *this);
78   m_out_exrom_func.resolve(m_out_exrom_cb, *this);
79   m_out_irq_func.resolve(m_out_irq_cb, *this);
80   m_out_dma_func.resolve(m_out_dma_cb, *this);
81   m_out_nmi_func.resolve(m_out_nmi_cb, *this);
82   m_out_reset_func.resolve(m_out_reset_cb, *this);
83}
84
85
86//-------------------------------------------------
87//  insert_cartridge -
88//-------------------------------------------------
89
90void c64_expansion_port_device::insert_cartridge(device_t *device)
91{
92   device_c64_expansion_port_interface *intf;
93
94   if (!device->interface(intf))
95      fatalerror("Device '%s' does not implement the C64 expansion port interface!", device->tag());
96
97   m_device = device;
98   device->interface(m_interface);
99}
100
101
102//-------------------------------------------------
103//  remove_cartridge -
104//-------------------------------------------------
105
106void c64_expansion_port_device::remove_cartridge()
107{
108   m_device = NULL;
109   m_interface = NULL;
110}
111
112
113//-------------------------------------------------
114//  io1_r - I/O 1 read
115//-------------------------------------------------
116
117READ8_MEMBER( c64_expansion_port_device::io1_r )
118{
119   UINT8 data = 0;
120
121   if (m_interface)
122      data = m_interface->c64_io1_r(offset);
123
124   return data;
125}
126
127
128//-------------------------------------------------
129//  io1_w - I/O 1 write
130//-------------------------------------------------
131
132WRITE8_MEMBER( c64_expansion_port_device::io1_w )
133{
134   if (m_interface)
135      m_interface->c64_io1_w(offset, data);
136}
137
138
139//-------------------------------------------------
140//  io2_r - I/O 2 read
141//-------------------------------------------------
142
143READ8_MEMBER( c64_expansion_port_device::io2_r )
144{
145   UINT8 data = 0;
146
147   if (m_interface)
148      data = m_interface->c64_io2_r(offset);
149
150   return data;
151}
152
153
154//-------------------------------------------------
155//  io2_w - I/O 2 write
156//-------------------------------------------------
157
158WRITE8_MEMBER( c64_expansion_port_device::io2_w )
159{
160   if (m_interface)
161      m_interface->c64_io2_w(offset, data);
162}
163
164
165//-------------------------------------------------
166//  roml_r - ROM low read
167//-------------------------------------------------
168
169READ8_MEMBER( c64_expansion_port_device::roml_r )
170{
171   UINT8 data = 0;
172
173   if (m_interface)
174      data = m_interface->c64_roml_r(offset);
175
176   return data;
177}
178
179
180//-------------------------------------------------
181//  roml_w - ROM low write
182//-------------------------------------------------
183
184WRITE8_MEMBER( c64_expansion_port_device::roml_w )
185{
186   if (m_interface)
187      m_interface->c64_roml_w(offset, data);
188}
189
190
191//-------------------------------------------------
192//  romh_r - ROM high read
193//-------------------------------------------------
194
195READ8_MEMBER( c64_expansion_port_device::romh_r )
196{
197   UINT8 data = 0;
198
199   if (m_interface)
200      data = m_interface->c64_romh_r(offset);
201
202   return data;
203}
204
205
206//-------------------------------------------------
207//  romh_w - ROM high write
208//-------------------------------------------------
209
210WRITE8_MEMBER( c64_expansion_port_device::romh_w )
211{
212   if (m_interface)
213      m_interface->c64_romh_w(offset, data);
214}
215
216
217//-------------------------------------------------
218//  game_r - GAME read
219//-------------------------------------------------
220
221READ_LINE_MEMBER( c64_expansion_port_device::game_r )
222{
223   if (m_interface)
224      return m_interface->c64_game_r();
225   else
226      return 1;
227}
228
229
230//-------------------------------------------------
231//  game_w - GAME write
232//-------------------------------------------------
233
234WRITE_LINE_MEMBER( c64_expansion_port_device::game_w )
235{
236   m_out_game_func(state);
237}
238
239
240//-------------------------------------------------
241//  exrom_r - EXROM read
242//-------------------------------------------------
243
244READ_LINE_MEMBER( c64_expansion_port_device::exrom_r )
245{
246   if (m_interface)
247      return m_interface->c64_exrom_r();
248   else
249      return 1;
250}
251
252
253//-------------------------------------------------
254//  exrom_w - EXROM write
255//-------------------------------------------------
256
257WRITE_LINE_MEMBER( c64_expansion_port_device::exrom_w )
258{
259   m_out_exrom_func(state);
260}
261
262
263//-------------------------------------------------
264//  irq_w - interrupt request write
265//-------------------------------------------------
266
267WRITE_LINE_MEMBER( c64_expansion_port_device::irq_w )
268{
269   m_out_irq_func(state);
270}
271
272
273//-------------------------------------------------
274//  nmi_w - non-maskable interrupt write
275//-------------------------------------------------
276
277WRITE_LINE_MEMBER( c64_expansion_port_device::nmi_w )
278{
279   m_out_nmi_func(state);
280}
281
282
283//-------------------------------------------------
284//  dma_w - direct memory access write
285//-------------------------------------------------
286
287WRITE_LINE_MEMBER( c64_expansion_port_device::dma_w )
288{
289   m_out_dma_func(state);
290}
291
292
293//-------------------------------------------------
294//  reset_w - reset write
295//-------------------------------------------------
296
297WRITE_LINE_MEMBER( c64_expansion_port_device::reset_w )
298{
299   m_out_reset_func(state);
300}
src/mess/machine/c64expp.h
r11458r11459
1/**********************************************************************
2
3    Commodore 64 expansion port emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9
10   1   GND      Ground            A   GND      Ground
11   2   +5V      +5 Volts DC         B   /ROMH   ROM High
12   3   +5V      +5 Volts DC         C   /RESET   Reset
13   4   /IRQ   Interrupt Request   D   /NMI   Non Maskable Interrupt
14   5   /CR/W                  E   S02   
15   6   DOTCLK   Dot Clock         F   CA15   Cartridge Address 15
16   7   I/O 1                  H   CA14   Cartridge Address 14
17   8   /GAME   Game            J   CA13   Cartridge Address 13
18   9   /EXROM                  K   CA12   Cartridge Address 12
19   10   I/O 2                  L   CA11   Cartridge Address 11
20   11   /ROML   ROM Low            M   CA10   Cartridge Address 10
21   12   BA                     N   CA9      Cartridge Address 9
22   13   /DMA                  P   CA8      Cartridge Address 8
23   14   CD7      Cartridge Data 7   R   CA7      Cartridge Address 7
24   15   CD6      Cartridge Data 6   S   CA6      Cartridge Address 6
25   16   CD5      Cartridge Data 5   T   CA5      Cartridge Address 5
26   17   CD4      Cartridge Data 4   U   CA4      Cartridge Address 4
27   18   CD3      Cartridge Data 3   V   CA3      Cartridge Address 3
28   19   CD2      Cartridge Data 2   W   CA2      Cartridge Address 2
29   20   CD1      Cartridge Data 1   X   CA1      Cartridge Address 1
30   21   CD0      Cartridge Data 0   Y   CA0      Cartridge Address 0
31   22   GND      Ground            Z   GND      Ground
32
33**********************************************************************/
34
35#pragma once
36
37#ifndef __C64_EXPANSION_PORT__
38#define __C64_EXPANSION_PORT__
39
40#include "emu.h"
41
42
43
44//**************************************************************************
45//  MACROS / CONSTANTS
46//**************************************************************************
47
48#define C64_EXPANSION_PORT_TAG   "c64expport"
49
50
51
52//**************************************************************************
53//  INTERFACE CONFIGURATION MACROS
54//**************************************************************************
55
56#define MCFG_C64_EXPANSION_PORT_ADD(_config) \
57   MCFG_DEVICE_ADD(C64_EXPANSION_PORT_TAG, C64_EXPANSION_PORT, 0) \
58   MCFG_DEVICE_CONFIG(_config)
59
60#define C64_EXPANSION_PORT_INTERFACE(name) \
61   const c64_expansion_port_interface (name) =
62
63
64
65//**************************************************************************
66//  TYPE DEFINITIONS
67//**************************************************************************
68
69// ======================> c64_expansion_port_interface
70
71struct c64_expansion_port_interface
72{
73   devcb_write_line   m_out_game_cb;
74   devcb_write_line   m_out_exrom_cb;
75   devcb_write_line   m_out_irq_cb;
76   devcb_write_line   m_out_dma_cb;
77   devcb_write_line   m_out_nmi_cb;
78   devcb_write_line   m_out_reset_cb;
79};
80
81
82// ======================> device_c64_expansion_port_interface
83
84class device_c64_expansion_port_interface : public device_interface
85{
86public:
87   // construction/destruction
88   device_c64_expansion_port_interface(const machine_config &mconfig, device_t &device);
89   virtual ~device_c64_expansion_port_interface();
90
91   // required operation overrides
92   virtual int c64_game_r() = 0;
93   virtual int c64_exrom_r() = 0;
94
95   // optional operation overrides
96   virtual void c64_reset_w(int state) { };
97   virtual UINT8 c64_io1_r(offs_t offset) { return 0; };
98   virtual void c64_io1_w(offs_t offset, UINT8 data) { };
99   virtual UINT8 c64_io2_r(offs_t offset) { return 0; };
100   virtual void c64_io2_w(offs_t offset, UINT8 data) { };
101   virtual UINT8 c64_roml_r(offs_t offset) { return 0; };
102   virtual void c64_roml_w(offs_t offset, UINT8 data) { };
103   virtual UINT8 c64_romh_r(offs_t offset) { return 0; };
104   virtual void c64_romh_w(offs_t offset, UINT8 data) { };
105};
106
107
108// ======================> c64_expansion_port_device
109
110class c64_expansion_port_device :  public device_t,
111                           public c64_expansion_port_interface
112{
113public:
114    // construction/destruction
115    c64_expansion_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
116
117   void insert_cartridge(device_t *device);
118   void remove_cartridge();
119
120   // I/O 1 ($DE00-$DEFF)
121   DECLARE_READ8_MEMBER( io1_r );
122   DECLARE_WRITE8_MEMBER( io1_w );
123
124   // I/O 2 ($DF00-$DFFF)
125   DECLARE_READ8_MEMBER( io2_r );
126   DECLARE_WRITE8_MEMBER( io2_w );
127
128   // ROML ($8000-$9FFF)
129   DECLARE_READ8_MEMBER( roml_r );
130   DECLARE_WRITE8_MEMBER( roml_w );
131
132   // ROMH ($A000-$BFFF or $E000-$FFFF)
133   DECLARE_READ8_MEMBER( romh_r );
134   DECLARE_WRITE8_MEMBER( romh_w );
135
136   // GAME
137   DECLARE_READ_LINE_MEMBER( game_r );
138   DECLARE_WRITE_LINE_MEMBER( game_w );
139
140   // EXROM
141   DECLARE_READ_LINE_MEMBER( exrom_r );
142   DECLARE_WRITE_LINE_MEMBER( exrom_w );
143
144   // interrupts
145   DECLARE_WRITE_LINE_MEMBER( irq_w );
146   DECLARE_WRITE_LINE_MEMBER( nmi_w );
147
148   // DMA
149   DECLARE_WRITE_LINE_MEMBER( dma_w );
150
151   // reset
152   DECLARE_WRITE_LINE_MEMBER( reset_w );
153
154protected:
155    // device-level overrides
156    virtual void device_start();
157   
158   devcb_resolved_write_line   m_out_game_func;
159   devcb_resolved_write_line   m_out_exrom_func;
160   devcb_resolved_write_line   m_out_irq_func;
161   devcb_resolved_write_line   m_out_dma_func;
162   devcb_resolved_write_line   m_out_nmi_func;
163   devcb_resolved_write_line   m_out_reset_func;
164
165   device_t *                        m_device;      // connected cartridge device
166   device_c64_expansion_port_interface *   m_interface;   // connected cartridge device's interface
167};
168
169
170// device type definition
171extern const device_type C64_EXPANSION_PORT;
172
173
174#endif
src/mess/machine/c64.c
r11458r11459
2020#include "sound/sid6581.h"
2121#include "machine/6526cia.h"
2222#include "machine/cbmiec.h"
23#include "machine/c64expp.h"
2423#include "video/vic6567.h"
2524
2625#include "includes/cbm.h"
src/mess/drivers/c64.c
r11458r11459
334334#include "machine/6526cia.h"
335335
336336#include "machine/cbmipt.h"
337#include "machine/c64expp.h"
338337#include "video/vic6567.h"
339338
340339/* devices config */
r11458r11459
682681   c64_rdy_cb
683682};
684683
685static C64_EXPANSION_PORT_INTERFACE( expansion_intf )
686{
687   DEVCB_NULL, // GAME
688   DEVCB_NULL, // EXROM
689   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_IRQ0),
690   DEVCB_NULL, // DMA
691   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_NMI),
692   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_RESET)
693};
694684
695
696685/*************************************
697686 *
698687 *  Machine driver
r11458r11459
748737   MCFG_C1541_ADD(C1541_TAG, 8)
749738
750739   MCFG_FRAGMENT_ADD(c64_cartslot)
751
752   // expansion port
753   MCFG_C64_EXPANSION_PORT_ADD(expansion_intf)
754740MACHINE_CONFIG_END
755741
756742static MACHINE_CONFIG_START( c64pal, c64_state )
r11458r11459
805791#endif
806792
807793   MCFG_FRAGMENT_ADD(c64_cartslot)
808
809   // expansion port
810   MCFG_C64_EXPANSION_PORT_ADD(expansion_intf)
811794MACHINE_CONFIG_END
812795
813796static MACHINE_CONFIG_DERIVED( ultimax, c64 )
src/mess/mess.mak
r11458r11459
735735   $(MESS_DRIVERS)/pet.o      \
736736   $(MESS_MACHINE)/pet.o      \
737737   $(MESS_DRIVERS)/c64.o      \
738   $(MESS_MACHINE)/c64expp.o   \
739   $(MESS_MACHINE)/c64crtstd.o   \
740738   $(MESS_MACHINE)/interpod.o   \
741739   $(MESS_DRIVERS)/vic20.o      \
742740   $(MESS_MACHINE)/vic1112.o   \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team