Previous 199869 Revisions Next

r18990 Friday 16th November, 2012 at 18:34:35 UTC by Curt Coder
(MESS) bw2: Added expansion slot interface and RAMCARD expansion device. [Curt Coder]
[src/mess]mess.mak
[src/mess/machine]bw2_ramcard.c* bw2_ramcard.h* bw2exp.c* bw2exp.h*

trunk/src/mess/mess.mak
r18989r18990
778778
779779$(MESSOBJ)/bondwell.a:         \
780780   $(MESS_DRIVERS)/bw2.o      \
781   $(MESS_MACHINE)/bw2exp.o   \
782   $(MESS_MACHINE)/bw2_ramcard.o   \
781783   $(MESS_DRIVERS)/bw12.o      \
782784
783785$(MESSOBJ)/booth.a:            \
trunk/src/mess/machine/bw2_ramcard.c
r0r18990
1/**********************************************************************
2
3    Bondwell 2 RAMCARD emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "bw2_ramcard.h"
11
12
13
14//**************************************************************************
15//  DEVICE DEFINITIONS
16//**************************************************************************
17
18const device_type BW2_RAMCARD = &device_creator<bw2_ramcard_device>;
19
20
21//-------------------------------------------------
22//  ROM( bw2_ramcard )
23//-------------------------------------------------
24
25ROM_START( bw2_ramcard )
26   ROM_REGION( 0x4000, "ramcard", 0 )
27   ROM_LOAD( "ramcard-10.ic10", 0x0000, 0x4000, CRC(68cde1ba) SHA1(a776a27d64f7b857565594beb63aa2cd692dcf04) )
28ROM_END
29
30
31//-------------------------------------------------
32//  rom_region - device-specific ROM region
33//-------------------------------------------------
34
35const rom_entry *bw2_ramcard_device::device_rom_region() const
36{
37   return ROM_NAME( bw2_ramcard );
38}
39
40
41
42//**************************************************************************
43//  LIVE DEVICE
44//**************************************************************************
45
46//-------------------------------------------------
47//  bw2_ramcard_device - constructor
48//-------------------------------------------------
49
50bw2_ramcard_device::bw2_ramcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
51   : device_t(mconfig, BW2_RAMCARD, "RAMCARD", tag, owner, clock),
52      device_bw2_expansion_slot_interface(mconfig, *this),
53      m_ram(*this, "ram"),
54      m_en(0),
55      m_bank(0)
56{
57}
58
59
60//-------------------------------------------------
61//  device_start - device-specific startup
62//-------------------------------------------------
63
64void bw2_ramcard_device::device_start()
65{
66   // find memory regions
67   m_rom = memregion("ramcard")->base();
68
69   // allocate memory
70   m_ram.allocate(512 * 1024);
71
72   // state saving
73   save_item(NAME(m_en));
74   save_item(NAME(m_bank));
75}
76
77
78//-------------------------------------------------
79//  device_reset - device-specific reset
80//-------------------------------------------------
81
82void bw2_ramcard_device::device_reset()
83{
84   m_en = 0;
85   m_bank = 0;
86}
87
88
89//-------------------------------------------------
90//  bw2_cd_r - cartridge data read
91//-------------------------------------------------
92
93UINT8 bw2_ramcard_device::bw2_cd_r(address_space &space, offs_t offset, UINT8 data, int ram2, int ram3, int ram4, int ram5, int ram6)
94{
95   if (!ram2)
96   {
97      data = m_rom[offset & 0x3fff];
98   }
99   else if (m_en && !ram5)
100   {
101      data = m_ram[(m_bank << 15) | offset];
102   }
103
104   return data;
105}
106
107
108//-------------------------------------------------
109//  bw2_cd_r - cartridge data write
110//-------------------------------------------------
111
112void bw2_ramcard_device::bw2_cd_w(address_space &space, offs_t offset, UINT8 data, int ram2, int ram3, int ram4, int ram5, int ram6)
113{
114   if (m_en && !ram5)
115   {
116      m_ram[(m_bank << 15) | offset] = data;
117   }
118}
119
120
121//-------------------------------------------------
122//  bw2_slot_w - slot write
123//-------------------------------------------------
124
125void bw2_ramcard_device::bw2_slot_w(address_space &space, offs_t offset, UINT8 data)
126{
127   m_en = 1;
128   m_bank = data & 0x0f;
129}
trunk/src/mess/machine/bw2_ramcard.h
r0r18990
1/**********************************************************************
2
3    Bondwell 2 RAMCARD 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 __BW2_RAMCARD__
13#define __BW2_RAMCARD__
14
15#include "emu.h"
16#include "machine/bw2exp.h"
17
18
19
20//**************************************************************************
21//  TYPE DEFINITIONS
22//**************************************************************************
23
24// ======================> bw2_ramcard_device
25
26class bw2_ramcard_device :  public device_t,
27                     public device_bw2_expansion_slot_interface
28{
29public:
30   // construction/destruction
31   bw2_ramcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
32
33   // optional information overrides
34   virtual const rom_entry *device_rom_region() const;
35
36protected:
37   // device-level overrides
38   virtual void device_config_complete() { m_shortname = "bw2_ramcard"; }
39   virtual void device_start();
40   virtual void device_reset();
41
42   // device_bw2_expansion_slot_interface overrides
43   virtual UINT8 bw2_cd_r(address_space &space, offs_t offset, UINT8 data, int ram2, int ram3, int ram4, int ram5, int ram6);
44   virtual void bw2_cd_w(address_space &space, offs_t offset, UINT8 data, int ram2, int ram3, int ram4, int ram5, int ram6);
45   virtual void bw2_slot_w(address_space &space, offs_t offset, UINT8 data);
46
47private:
48   optional_shared_ptr<UINT8> m_ram;
49   const UINT8 *m_rom;
50
51   int m_en;
52   UINT8 m_bank;
53};
54
55
56// device type definition
57extern const device_type BW2_RAMCARD;
58
59
60
61#endif
trunk/src/mess/machine/bw2exp.c
r0r18990
1/**********************************************************************
2
3    Bondwell 2 Expansion Port emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "machine/bw2exp.h"
11
12
13
14//**************************************************************************
15//  GLOBAL VARIABLES
16//**************************************************************************
17
18const device_type BW2_EXPANSION_SLOT = &device_creator<bw2_expansion_slot_device>;
19
20
21
22//**************************************************************************
23//  CARD INTERFACE
24//**************************************************************************
25
26//-------------------------------------------------
27//  device_bw2_expansion_slot_interface - constructor
28//-------------------------------------------------
29
30device_bw2_expansion_slot_interface::device_bw2_expansion_slot_interface(const machine_config &mconfig, device_t &device)
31   : device_slot_card_interface(mconfig,device)
32{
33   m_slot = dynamic_cast<bw2_expansion_slot_device *>(device.owner());
34}
35
36
37//-------------------------------------------------
38//  ~device_bw2_expansion_slot_interface - destructor
39//-------------------------------------------------
40
41device_bw2_expansion_slot_interface::~device_bw2_expansion_slot_interface()
42{
43}
44
45
46
47//**************************************************************************
48//  LIVE DEVICE
49//**************************************************************************
50
51//-------------------------------------------------
52//  bw2_expansion_slot_device - constructor
53//-------------------------------------------------
54
55bw2_expansion_slot_device::bw2_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
56   device_t(mconfig, BW2_EXPANSION_SLOT, "Bondwell 2 expansion port", tag, owner, clock),
57   device_slot_interface(mconfig, *this)
58{
59}
60
61
62//-------------------------------------------------
63//  bw2_expansion_slot_device - destructor
64//-------------------------------------------------
65
66bw2_expansion_slot_device::~bw2_expansion_slot_device()
67{
68}
69
70
71//-------------------------------------------------
72//  device_start - device-specific startup
73//-------------------------------------------------
74
75void bw2_expansion_slot_device::device_start()
76{
77   m_cart = dynamic_cast<device_bw2_expansion_slot_interface *>(get_card_device());
78}
79
80
81//-------------------------------------------------
82//  device_reset - device-specific reset
83//-------------------------------------------------
84
85void bw2_expansion_slot_device::device_reset()
86{
87   if (m_cart != NULL)
88   {
89      m_cart->device().reset();
90   }
91}
92
93
94//-------------------------------------------------
95//  cd_r - cartridge data read
96//-------------------------------------------------
97
98UINT8 bw2_expansion_slot_device::cd_r(address_space &space, offs_t offset, UINT8 data, int ram2, int ram3, int ram4, int ram5, int ram6)
99{
100   if (m_cart != NULL)
101   {
102      data = m_cart->bw2_cd_r(space, offset, data, ram2, ram3, ram4, ram5, ram6);
103   }
104
105   return data;
106}
107
108
109//-------------------------------------------------
110//  cd_w - cartridge data write
111//-------------------------------------------------
112
113void bw2_expansion_slot_device::cd_w(address_space &space, offs_t offset, UINT8 data, int ram2, int ram3, int ram4, int ram5, int ram6)
114{
115   if (m_cart != NULL)
116   {
117      m_cart->bw2_cd_w(space, offset, data, ram2, ram3, ram4, ram5, ram6);
118   }
119}
120
121
122//-------------------------------------------------
123//  slot_r - slot read
124//-------------------------------------------------
125
126READ8_MEMBER( bw2_expansion_slot_device::slot_r )
127{
128   UINT8 data = 0xff;
129
130   if (m_cart != NULL)
131   {
132      data = m_cart->bw2_slot_r(space, offset);
133   }
134
135   return data;
136}
137
138
139//-------------------------------------------------
140//  slot_w - slot write
141//-------------------------------------------------
142
143WRITE8_MEMBER( bw2_expansion_slot_device::slot_w )
144{
145   if (m_cart != NULL)
146   {
147      m_cart->bw2_slot_w(space, offset, data);
148   }
149}
150
151
152//-------------------------------------------------
153//  modsel_r - modsel read
154//-------------------------------------------------
155
156READ8_MEMBER( bw2_expansion_slot_device::modsel_r )
157{
158   UINT8 data = 0xff;
159
160   if (m_cart != NULL)
161   {
162      data = m_cart->bw2_modsel_r(space, offset);
163   }
164
165   return data;
166}
167
168
169//-------------------------------------------------
170//  modsel_w - modsel write
171//-------------------------------------------------
172
173WRITE8_MEMBER( bw2_expansion_slot_device::modsel_w )
174{
175   if (m_cart != NULL)
176   {
177      m_cart->bw2_modsel_w(space, offset, data);
178   }
179}
180
181
182//-------------------------------------------------
183//  SLOT_INTERFACE( bw2_expansion_cards )
184//-------------------------------------------------
185
186SLOT_INTERFACE_START( bw2_expansion_cards )
187   SLOT_INTERFACE("ramcard", BW2_RAMCARD)
188SLOT_INTERFACE_END
trunk/src/mess/machine/bw2exp.h
r0r18990
1/**********************************************************************
2
3    Bondwell 2 Expansion Port emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9
10                     5V       1      26      12V
11                     D3       2      27      12V
12                     A1       3      28      A3
13                     A2       4      29      A4
14                  _CTSB       5      30      A5
15                   _RST       6      31      A6
16                _MODSEL       7      32      A7
17                  16MHZ       8      33      A8
18                  _IORQ       9      34      A9
19                    _RD      10      35      A10
20                     D0      11      36      A11
21                     D1      12      37      A12
22                     D2      13      38      A13
23                     A0      14      39      A14
24                     D4      15      40      _RAM6
25                     D5      16      41      _RAM5
26                     D6      17      42      _RFSH
27                     D7      18      43      _WR
28                   DCDB      19      44      SELECT
29                  _DTRB      20      45      _RAM2
30                  _RTSB      21      46      _RAM3
31                  _DSRB      22      47      _RAM4
32                   TXDB      23      48      _SLOT
33                   RXDB      24      49      GND
34                    GND      25      50      5V
35
36**********************************************************************/
37
38#pragma once
39
40#ifndef __BW2_EXPANSION_SLOT__
41#define __BW2_EXPANSION_SLOT__
42
43#include "emu.h"
44
45
46
47//**************************************************************************
48//  CONSTANTS
49//**************************************************************************
50
51#define BW2_EXPANSION_SLOT_TAG      "exp"
52
53
54
55//**************************************************************************
56//  INTERFACE CONFIGURATION MACROS
57//**************************************************************************
58
59#define MCFG_BW2_EXPANSION_SLOT_ADD(_tag, _clock, _slot_intf, _def_slot, _def_inp) \
60   MCFG_DEVICE_ADD(_tag, BW2_EXPANSION_SLOT, _clock) \
61   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp, false)
62
63
64
65//**************************************************************************
66//  TYPE DEFINITIONS
67//**************************************************************************
68
69// ======================> bw2_expansion_slot_device
70
71class device_bw2_expansion_slot_interface;
72
73class bw2_expansion_slot_device : public device_t,
74                           public device_slot_interface
75{
76public:
77   // construction/destruction
78   bw2_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
79   virtual ~bw2_expansion_slot_device();
80
81   // computer interface
82   UINT8 cd_r(address_space &space, offs_t offset, UINT8 data, int ram2, int ram3, int ram4, int ram5, int ram6);
83   void cd_w(address_space &space, offs_t offset, UINT8 data, int ram2, int ram3, int ram4, int ram5, int ram6);
84
85   DECLARE_READ8_MEMBER( slot_r );
86   DECLARE_WRITE8_MEMBER( slot_w );
87
88   DECLARE_READ8_MEMBER( modsel_r );
89   DECLARE_WRITE8_MEMBER( modsel_w );
90
91protected:
92   // device-level overrides
93   virtual void device_start();
94   virtual void device_reset();
95
96   device_bw2_expansion_slot_interface *m_cart;
97};
98
99
100// ======================> device_bw2_expansion_slot_interface
101
102// class representing interface-specific live bw2_expansion card
103class device_bw2_expansion_slot_interface : public device_slot_card_interface
104{
105public:
106   // construction/destruction
107   device_bw2_expansion_slot_interface(const machine_config &mconfig, device_t &device);
108   virtual ~device_bw2_expansion_slot_interface();
109
110   virtual UINT8 bw2_cd_r(address_space &space, offs_t offset, UINT8 data, int ram2, int ram3, int ram4, int ram5, int ram6) { return data; };
111   virtual void bw2_cd_w(address_space &space, offs_t offset, UINT8 data, int ram2, int ram3, int ram4, int ram5, int ram6) { };
112
113   virtual UINT8 bw2_slot_r(address_space &space, offs_t offset) { return 0xff; }
114   virtual void bw2_slot_w(address_space &space, offs_t offset, UINT8 data) { }
115
116   virtual UINT8 bw2_modsel_r(address_space &space, offs_t offset) { return 0xff; }
117   virtual void bw2_modsel_w(address_space &space, offs_t offset, UINT8 data) { }
118
119protected:
120   bw2_expansion_slot_device *m_slot;
121};
122
123
124// device type definition
125extern const device_type BW2_EXPANSION_SLOT;
126
127
128// slot devices
129#include "machine/bw2_ramcard.h"
130
131SLOT_INTERFACE_EXTERN( bw2_expansion_cards );
132
133
134
135#endif

Previous 199869 Revisions Next


© 1997-2024 The MAME Team