Previous 199869 Revisions Next

r26673 Friday 20th December, 2013 at 16:04:11 UTC by Curt Coder
(MESS) Used shared_ptr instead of UINT8* in the Commodore cartridges. (nw)
[src/emu/bus/c64]16kb.c 16kb.h dqbb.c dqbb.h easyflash.c easyflash.h exp.c exp.h fcc.c fcc.h georam.c georam.h ide64.c ide64.h magic_formel.c magic_formel.h neoram.c neoram.h ocean.c pagefox.c pagefox.h partner.c partner.h reu.c reu.h ross.c std.c westermann.c xl80.c xl80.h
[src/emu/bus/cbm2]24k.c 24k.h exp.c exp.h std.c
[src/emu/bus/plus4]exp.c exp.h std.c std.h
[src/emu/bus/vic10]exp.c exp.h std.c std.h
[src/emu/bus/vic20]exp.c exp.h megacart.c megacart.h vic1110.c vic1110.h vic1111.c vic1111.h vic1210.c vic1210.h

trunk/src/emu/bus/plus4/std.c
r26672r26673
5151
5252UINT8 plus4_standard_cartridge_device::plus4_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h)
5353{
54   if (!c1l && m_c1l_mask)
54   if (!c1l && m_c1l.bytes())
5555   {
56      data = m_c1l[offset & m_c1l_mask];
56      data = m_c1l[offset & m_c1l.mask()];
5757   }
58   else if (!c1h && m_c1h_mask)
58   else if (!c1h && m_c1h.bytes())
5959   {
60      data = m_c1h[offset & m_c1h_mask];
60      data = m_c1h[offset & m_c1h.mask()];
6161   }
62   else if (!c2l && m_c2l_mask)
62   else if (!c2l && m_c2l.bytes())
6363   {
64      data = m_c2l[offset & m_c2l_mask];
64      data = m_c2l[offset & m_c2l.mask()];
6565   }
66   else if (!c2h && m_c2h_mask)
66   else if (!c2h && m_c2h.bytes())
6767   {
68      data = m_c2h[offset & m_c2h_mask];
68      data = m_c2h[offset & m_c2h.mask()];
6969   }
7070
7171   return data;
trunk/src/emu/bus/plus4/exp.c
r26672r26673
3939
4040device_plus4_expansion_card_interface::device_plus4_expansion_card_interface(const machine_config &mconfig, device_t &device)
4141   : device_slot_card_interface(mconfig, device),
42      m_c1l(NULL),
43      m_c1h(NULL),
44      m_c2l(NULL),
45      m_c2h(NULL),
46      m_ram(NULL),
47      m_nvram(NULL),
48      m_nvram_size(0),
42      m_c1l(*this, "c1l"),
43      m_c1h(*this, "c1h"),
44      m_c2l(*this, "c2l"),
45      m_c2h(*this, "c2h"),
4946      m_c1l_mask(0),
5047      m_c1h_mask(0),
5148      m_c2l_mask(0),
52      m_c2h_mask(0),
53      m_ram_mask(0)
49      m_c2h_mask(0)
5450{
5551   m_slot = dynamic_cast<plus4_expansion_slot_device *>(device.owner());
5652}
r26672r26673
6561}
6662
6763
68//-------------------------------------------------
69//  plus4_c1l_pointer - get low ROM 1 pointer
70//-------------------------------------------------
7164
72UINT8* device_plus4_expansion_card_interface::plus4_c1l_pointer(running_machine &machine, size_t size)
73{
74   if (m_c1l == NULL)
75   {
76      m_c1l = auto_alloc_array(machine, UINT8, size);
77
78      m_c1l_mask = size - 1;
79   }
80
81   return m_c1l;
82}
83
84
85//-------------------------------------------------
86//  plus4_c1h_pointer - get low ROM 1 pointer
87//-------------------------------------------------
88
89UINT8* device_plus4_expansion_card_interface::plus4_c1h_pointer(running_machine &machine, size_t size)
90{
91   if (m_c1h == NULL)
92   {
93      m_c1h = auto_alloc_array(machine, UINT8, size);
94
95      m_c1h_mask = size - 1;
96   }
97
98   return m_c1h;
99}
100
101
102//-------------------------------------------------
103//  plus4_c2l_pointer - get low ROM 1 pointer
104//-------------------------------------------------
105
106UINT8* device_plus4_expansion_card_interface::plus4_c2l_pointer(running_machine &machine, size_t size)
107{
108   if (m_c2l == NULL)
109   {
110      m_c2l = auto_alloc_array(machine, UINT8, size);
111
112      m_c2l_mask = size - 1;
113   }
114
115   return m_c2l;
116}
117
118
119//-------------------------------------------------
120//  plus4_c2h_pointer - get low ROM 1 pointer
121//-------------------------------------------------
122
123UINT8* device_plus4_expansion_card_interface::plus4_c2h_pointer(running_machine &machine, size_t size)
124{
125   if (m_c2h == NULL)
126   {
127      m_c2h = auto_alloc_array(machine, UINT8, size);
128
129      m_c2h_mask = size - 1;
130   }
131
132   return m_c2h;
133}
134
135
136//-------------------------------------------------
137//  plus4_ram_pointer - get RAM pointer
138//-------------------------------------------------
139
140UINT8* device_plus4_expansion_card_interface::plus4_ram_pointer(running_machine &machine, size_t size)
141{
142   if (m_ram == NULL)
143   {
144      m_ram = auto_alloc_array(machine, UINT8, size);
145
146      m_ram_mask = size - 1;
147   }
148
149   return m_ram;
150}
151
152
153//-------------------------------------------------
154//  plus4_ram_pointer - get NVRAM pointer
155//-------------------------------------------------
156
157UINT8* device_plus4_expansion_card_interface::plus4_nvram_pointer(running_machine &machine, size_t size)
158{
159   if (m_nvram == NULL)
160   {
161      m_nvram = auto_alloc_array(machine, UINT8, size);
162
163      m_nvram_mask = size - 1;
164      m_nvram_size = size;
165   }
166
167   return m_nvram;
168}
169
170
171
17265//**************************************************************************
17366//  LIVE DEVICE
17467//**************************************************************************
r26672r26673
234127{
235128   if (m_card)
236129   {
237      size_t size = 0;
238
239130      if (software_entry() == NULL)
240131      {
241132         // TODO
242133      }
243134      else
244135      {
245         size = get_software_region_length("c1l");
246         if (size) memcpy(m_card->plus4_c1l_pointer(machine(), size), get_software_region("c1l"), size);
247
248         size = get_software_region_length("c1h");
249         if (size) memcpy(m_card->plus4_c1h_pointer(machine(), size), get_software_region("c1h"), size);
250
251         size = get_software_region_length("c2l");
252         if (size) memcpy(m_card->plus4_c2l_pointer(machine(), size), get_software_region("c2l"), size);
253
254         size = get_software_region_length("c2h");
255         if (size) memcpy(m_card->plus4_c2h_pointer(machine(), size), get_software_region("c2h"), size);
256
257         size = get_software_region_length("ram");
258         if (size) memset(m_card->plus4_ram_pointer(machine(), size), 0, size);
259
260         size = get_software_region_length("nvram");
261         if (size) memset(m_card->plus4_nvram_pointer(machine(), size), 0, size);
136         load_software_region("c1l", m_card->m_c1l);
137         load_software_region("c1h", m_card->m_c1h);
138         load_software_region("c2l", m_card->m_c2l);
139         load_software_region("c2h", m_card->m_c2h);
262140      }
263141   }
264142
trunk/src/emu/bus/plus4/std.h
r26672r26673
3939
4040   // device_plus4_expansion_card_interface overrides
4141   virtual UINT8 plus4_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h);
42
43   
4244};
4345
4446
trunk/src/emu/bus/plus4/exp.h
r26672r26673
152152   device_plus4_expansion_card_interface(const machine_config &mconfig, device_t &device);
153153   virtual ~device_plus4_expansion_card_interface();
154154
155   // initialization
156   virtual UINT8* plus4_c1l_pointer(running_machine &machine, size_t size);
157   virtual UINT8* plus4_c1h_pointer(running_machine &machine, size_t size);
158   virtual UINT8* plus4_c2l_pointer(running_machine &machine, size_t size);
159   virtual UINT8* plus4_c2h_pointer(running_machine &machine, size_t size);
160   virtual UINT8* plus4_ram_pointer(running_machine &machine, size_t size);
161   virtual UINT8* plus4_nvram_pointer(running_machine &machine, size_t size);
162
163155   // runtime
164156   virtual UINT8 plus4_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h) { return data; };
165157   virtual void plus4_cd_w(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h) { };
166158
167159protected:
168   plus4_expansion_slot_device *m_slot;
160   optional_shared_ptr<UINT8> m_c1l;
161   optional_shared_ptr<UINT8> m_c1h;
162   optional_shared_ptr<UINT8> m_c2l;
163   optional_shared_ptr<UINT8> m_c2h;
169164
170   UINT8 *m_c1l;
171   UINT8 *m_c1h;
172   UINT8 *m_c2l;
173   UINT8 *m_c2h;
174   UINT8 *m_ram;
175   UINT8 *m_nvram;
176
177   size_t m_nvram_size;
178
179165   size_t m_c1l_mask;
180166   size_t m_c1h_mask;
181167   size_t m_c2l_mask;
182168   size_t m_c2h_mask;
183   size_t m_ram_mask;
184   size_t m_nvram_mask;
169
170   plus4_expansion_slot_device *m_slot;
185171};
186172
187173
trunk/src/emu/bus/vic10/exp.h
r26672r26673
152152   device_vic10_expansion_card_interface(const machine_config &mconfig, device_t &device);
153153   virtual ~device_vic10_expansion_card_interface();
154154
155protected:
156   // initialization
157   virtual UINT8* vic10_exram_pointer(running_machine &machine, size_t size);
158   virtual UINT8* vic10_lorom_pointer(running_machine &machine, size_t size);
159   virtual UINT8* vic10_uprom_pointer(running_machine &machine, size_t size);
160
161   // runtime
162155   virtual UINT8 vic10_cd_r(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram) { return data; };
163156   virtual void vic10_cd_w(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram) { };
164157   virtual int vic10_p0_r() { return 0; };
r26672r26673
166159   virtual void vic10_sp_w(int state) { };
167160   virtual void vic10_cnt_w(int state) { };
168161
169   vic10_expansion_slot_device *m_slot;
162protected:
163   optional_shared_ptr<UINT8> m_lorom;
164   optional_shared_ptr<UINT8> m_exram;
165   optional_shared_ptr<UINT8> m_uprom;
170166
171   UINT8 *m_exram;
172   UINT8 *m_lorom;
173   UINT8 *m_uprom;
167   vic10_expansion_slot_device *m_slot;
174168};
175169
176170
trunk/src/emu/bus/vic10/std.c
r26672r26673
5151
5252UINT8 vic10_standard_cartridge_device::vic10_cd_r(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram)
5353{
54   if (!lorom && (m_lorom != NULL))
54   if (!lorom && m_lorom.bytes())
5555   {
56      data = m_lorom[offset & 0x1fff];
56      data = m_lorom[offset & m_lorom.mask()];
5757   }
58   else if (!exram && (m_exram != NULL))
58   else if (!exram && m_exram.bytes())
5959   {
60      data = m_exram[offset & 0x7ff];
60      data = m_exram[offset & m_exram.mask()];
6161   }
62   else if (!uprom && (m_uprom != NULL))
62   else if (!uprom && m_uprom.bytes())
6363   {
64      data = m_uprom[offset & 0x1fff];
64      data = m_uprom[offset & m_uprom.mask()];
6565   }
6666
6767   return data;
r26672r26673
7474
7575void vic10_standard_cartridge_device::vic10_cd_w(address_space &space, offs_t offset, UINT8 data, int lorom, int uprom, int exram)
7676{
77   if (!exram && (m_exram != NULL))
77   if (!exram && m_exram.bytes())
7878   {
79      m_exram[offset & 0x7ff] = data;
79      m_exram[offset & m_exram.mask()] = data;
8080   }
8181}
trunk/src/emu/bus/vic10/exp.c
r26672r26673
3333
3434device_vic10_expansion_card_interface::device_vic10_expansion_card_interface(const machine_config &mconfig, device_t &device)
3535   : device_slot_card_interface(mconfig,device),
36      m_exram(NULL),
37      m_lorom(NULL),
38      m_uprom(NULL)
36      m_lorom(*this, "lorom"),
37      m_exram(*this, "exram"),
38      m_uprom(*this, "uprom")
3939{
4040   m_slot = dynamic_cast<vic10_expansion_slot_device *>(device.owner());
4141}
r26672r26673
5151
5252
5353
54//-------------------------------------------------
55//  vic10_lorom_pointer - get lower ROM pointer
56//-------------------------------------------------
57
58UINT8* device_vic10_expansion_card_interface::vic10_lorom_pointer(running_machine &machine, size_t size)
59{
60   if (m_lorom == NULL)
61   {
62      m_lorom = auto_alloc_array(machine, UINT8, size);
63   }
64
65   return m_lorom;
66}
67
68
69//-------------------------------------------------
70//  vic10_uprom_pointer - get upper ROM pointer
71//-------------------------------------------------
72
73UINT8* device_vic10_expansion_card_interface::vic10_uprom_pointer(running_machine &machine, size_t size)
74{
75   if (m_uprom == NULL)
76   {
77      m_uprom = auto_alloc_array(machine, UINT8, size);
78   }
79
80   return m_uprom;
81}
82
83
84//-------------------------------------------------
85//  vic10_exram_pointer - get expanded RAM pointer
86//-------------------------------------------------
87
88UINT8* device_vic10_expansion_card_interface::vic10_exram_pointer(running_machine &machine, size_t size)
89{
90   if (m_exram == NULL)
91   {
92      m_exram = auto_alloc_array(machine, UINT8, size);
93   }
94
95   return m_exram;
96}
97
98
99
10054//**************************************************************************
10155//  LIVE DEVICE
10256//**************************************************************************
r26672r26673
170124
171125         if (!mame_stricmp(filetype(), "80"))
172126         {
173            fread(m_card->vic10_lorom_pointer(machine(), 0x2000), 0x2000);
127            fread(m_card->m_lorom, 0x2000);
174128
175129            if (size == 0x4000)
176130            {
177               fread(m_card->vic10_uprom_pointer(machine(), 0x2000), 0x2000);
131               fread(m_card->m_uprom, 0x2000);
178132            }
179133         }
180         else if (!mame_stricmp(filetype(), "e0")) fread(m_card->vic10_uprom_pointer(machine(), size), size);
134         else if (!mame_stricmp(filetype(), "e0"))
135         {
136            fread(m_card->m_uprom, size);
137         }
181138         else if (!mame_stricmp(filetype(), "crt"))
182139         {
183140            size_t roml_size = 0;
r26672r26673
190147               UINT8 *roml = NULL;
191148               UINT8 *romh = NULL;
192149
193               if (roml_size) roml = m_card->vic10_lorom_pointer(machine(), roml_size);
194               if (romh_size) romh = m_card->vic10_uprom_pointer(machine(), romh_size);
150               m_card->m_lorom.allocate(roml_size);
151               m_card->m_uprom.allocate(romh_size);
195152
153               if (roml_size) roml = m_card->m_lorom;
154               if (romh_size) romh = m_card->m_lorom;
155
196156               cbm_crt_read_data(m_file, roml, romh);
197157            }
198158         }
199159      }
200160      else
201161      {
202         size = get_software_region_length("lorom");
203         if (size) memcpy(m_card->vic10_lorom_pointer(machine(), size), get_software_region("lorom"), size);
204
205         size = get_software_region_length("uprom");
206         if (size) memcpy(m_card->vic10_uprom_pointer(machine(), size), get_software_region("uprom"), size);
207
208         size = get_software_region_length("exram");
209         if (size) m_card->vic10_exram_pointer(machine(), size);
162         load_software_region("lorom", m_card->m_lorom);
163         load_software_region("exram", m_card->m_exram);
164         load_software_region("uprom", m_card->m_uprom);
210165      }
211166   }
212167
trunk/src/emu/bus/vic10/std.h
r26672r26673
2626// ======================> vic10_standard_cartridge_device
2727
2828class vic10_standard_cartridge_device :  public device_t,
29                                 public device_vic10_expansion_card_interface
29                              public device_vic10_expansion_card_interface
3030{
3131public:
3232   // construction/destruction
trunk/src/emu/bus/vic20/megacart.c
r26672r26673
2121
2222
2323//-------------------------------------------------
24//  MACHINE_DRIVER( vic1112 )
24//  MACHINE_DRIVER( vic20_megacart )
2525//-------------------------------------------------
2626
27static MACHINE_CONFIG_FRAGMENT( vic1112 )
27static MACHINE_CONFIG_FRAGMENT( vic20_megacart )
2828
2929MACHINE_CONFIG_END
3030
r26672r26673
3636
3737machine_config_constructor vic20_megacart_device::device_mconfig_additions() const
3838{
39   return MACHINE_CONFIG_NAME( vic1112 );
39   return MACHINE_CONFIG_NAME( vic20_megacart );
4040}
4141
4242
r26672r26673
6464
6565void vic20_megacart_device::device_start()
6666{
67   m_nvram.allocate(0x2000);
68
6769   // state saving
6870   save_item(NAME(m_nvram_en));
6971}
trunk/src/emu/bus/vic20/vic1110.c
r26672r26673
7171vic1110_device::vic1110_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
7272   : device_t(mconfig, VIC1110, "VIC1110", tag, owner, clock, "vic1110", __FILE__),
7373      device_vic20_expansion_card_interface(mconfig, *this),
74      m_ram(*this, "ram"),
7475      m_sw(*this, "SW")
7576{
7677}
r26672r26673
8384void vic1110_device::device_start()
8485{
8586   // allocate memory
86   vic20_ram_pointer(machine(), 0x2000);
87   m_ram.allocate(0x2000);
8788}
8889
8990
trunk/src/emu/bus/vic20/vic1111.c
r26672r26673
3131
3232vic1111_device::vic1111_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3333   : device_t(mconfig, VIC1111, "VIC1111", tag, owner, clock, "vic1111", __FILE__),
34      device_vic20_expansion_card_interface(mconfig, *this)
34      device_vic20_expansion_card_interface(mconfig, *this),
35      m_ram(*this, "ram")
3536{
3637}
3738
r26672r26673
4344void vic1111_device::device_start()
4445{
4546   // allocate memory
46   m_ram = auto_alloc_array(machine(), UINT8, 0x4000);
47   m_ram.allocate(0x4000);
4748}
4849
4950
trunk/src/emu/bus/vic20/vic1210.c
r26672r26673
3232
3333vic1210_device::vic1210_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3434   : device_t(mconfig, VIC1210, "VIC1210", tag, owner, clock, "vic1210", __FILE__),
35      device_vic20_expansion_card_interface(mconfig, *this)
35      device_vic20_expansion_card_interface(mconfig, *this),
36      m_ram(*this, "ram")
3637{
3738}
3839
r26672r26673
4445void vic1210_device::device_start()
4546{
4647   // allocate memory
47   m_ram = auto_alloc_array(machine(), UINT8, 0xc00);
48   m_ram.allocate(0xc00);
4849}
4950
5051
trunk/src/emu/bus/vic20/megacart.h
r26672r26673
4343
4444   // device_nvram_interface overrides
4545   virtual void nvram_default() { }
46   virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram_size); } }
47   virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram_size); } }
46   virtual void nvram_read(emu_file &file) { file.read(m_nvram, m_nvram.bytes()); }
47   virtual void nvram_write(emu_file &file) { file.write(m_nvram, m_nvram.bytes()); }
4848
4949   // device_vic20_expansion_card_interface overrides
5050   virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
trunk/src/emu/bus/vic20/vic1110.h
r26672r26673
4444   virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
4545
4646private:
47   optional_shared_ptr<UINT8> m_ram;
4748   required_ioport m_sw;
4849};
4950
trunk/src/emu/bus/vic20/vic1111.h
r26672r26673
3939   // device_vic20_expansion_card_interface overrides
4040   virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
4141   virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
42
43private:
44   optional_shared_ptr<UINT8> m_ram;
4245};
4346
4447
trunk/src/emu/bus/vic20/vic1210.h
r26672r26673
4040   // device_vic20_expansion_card_interface overrides
4141   virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
4242   virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3);
43
44private:
45   optional_shared_ptr<UINT8> m_ram;
4346};
4447
4548
trunk/src/emu/bus/vic20/exp.c
r26672r26673
3333
3434device_vic20_expansion_card_interface::device_vic20_expansion_card_interface(const machine_config &mconfig, device_t &device)
3535   : device_slot_card_interface(mconfig, device),
36      m_blk1(NULL),
37      m_blk2(NULL),
38      m_blk3(NULL),
39      m_blk5(NULL),
40      m_ram(NULL),
41      m_nvram(NULL),
42      m_nvram_size(0)
36      m_blk1(*this, "blk1"),
37      m_blk2(*this, "blk2"),
38      m_blk3(*this, "blk3"),
39      m_blk5(*this, "blk5"),
40      m_nvram(*this, "nvram")
4341{
4442   m_slot = dynamic_cast<vic20_expansion_slot_device *>(device.owner());
4543}
4644
4745
4846//-------------------------------------------------
49//  vic20_blk1_pointer - get block 1 pointer
50//-------------------------------------------------
51
52UINT8* device_vic20_expansion_card_interface::vic20_blk1_pointer(running_machine &machine, size_t size)
53{
54   if (m_blk1 == NULL)
55   {
56      m_blk1 = auto_alloc_array(machine, UINT8, size);
57   }
58
59   return m_blk1;
60}
61
62
63//-------------------------------------------------
64//  vic20_blk2_pointer - get block 2 pointer
65//-------------------------------------------------
66
67UINT8* device_vic20_expansion_card_interface::vic20_blk2_pointer(running_machine &machine, size_t size)
68{
69   if (m_blk2 == NULL)
70   {
71      m_blk2 = auto_alloc_array(machine, UINT8, size);
72   }
73
74   return m_blk2;
75}
76
77
78//-------------------------------------------------
79//  vic20_blk3_pointer - get block 3 pointer
80//-------------------------------------------------
81
82UINT8* device_vic20_expansion_card_interface::vic20_blk3_pointer(running_machine &machine, size_t size)
83{
84   if (m_blk3 == NULL)
85   {
86      m_blk3 = auto_alloc_array(machine, UINT8, size);
87   }
88
89   return m_blk3;
90}
91
92
93//-------------------------------------------------
94//  vic20_blk5_pointer - get block 5 pointer
95//-------------------------------------------------
96
97UINT8* device_vic20_expansion_card_interface::vic20_blk5_pointer(running_machine &machine, size_t size)
98{
99   if (m_blk5 == NULL)
100   {
101      m_blk5 = auto_alloc_array(machine, UINT8, size);
102   }
103
104   return m_blk5;
105}
106
107
108//-------------------------------------------------
109//  vic20_ram_pointer - get RAM pointer
110//-------------------------------------------------
111
112UINT8* device_vic20_expansion_card_interface::vic20_ram_pointer(running_machine &machine, size_t size)
113{
114   if (m_ram == NULL)
115   {
116      m_ram = auto_alloc_array(machine, UINT8, size);
117   }
118
119   return m_ram;
120}
121
122
123//-------------------------------------------------
124//  vic20_nvram_pointer - get NVRAM pointer
125//-------------------------------------------------
126
127UINT8* device_vic20_expansion_card_interface::vic20_nvram_pointer(running_machine &machine, size_t size)
128{
129   if (m_nvram == NULL)
130   {
131      m_nvram = auto_alloc_array(machine, UINT8, size);
132
133      m_nvram_mask = size - 1;
134      m_nvram_size = size;
135   }
136
137   return m_nvram;
138}
139
140
141//-------------------------------------------------
14247//  ~device_vic20_expansion_card_interface - destructor
14348//-------------------------------------------------
14449
r26672r26673
211116{
212117   if (m_card)
213118   {
214      size_t size = 0;
215
216119      if (software_entry() == NULL)
217120      {
218         if (!mame_stricmp(filetype(), "20")) fread(m_card->vic20_blk1_pointer(machine(), 0x2000), 0x2000);
219         else if (!mame_stricmp(filetype(), "40")) fread(m_card->vic20_blk2_pointer(machine(), 0x2000), 0x2000);
220         else if (!mame_stricmp(filetype(), "60")) fread(m_card->vic20_blk3_pointer(machine(), 0x2000), 0x2000);
221         else if (!mame_stricmp(filetype(), "70")) fread(m_card->vic20_blk3_pointer(machine(), 0x2000) + 0x1000, 0x1000);
222         else if (!mame_stricmp(filetype(), "a0")) fread(m_card->vic20_blk5_pointer(machine(), 0x2000), 0x2000);
223         else if (!mame_stricmp(filetype(), "b0")) fread(m_card->vic20_blk5_pointer(machine(), 0x2000) + 0x1000, 0x1000);
121         if (!mame_stricmp(filetype(), "20")) fread(m_card->m_blk1, 0x2000);
122         else if (!mame_stricmp(filetype(), "40")) fread(m_card->m_blk2, 0x2000);
123         else if (!mame_stricmp(filetype(), "60")) fread(m_card->m_blk3, 0x2000);
124         else if (!mame_stricmp(filetype(), "70")) fread(m_card->m_blk3, 0x2000, 0x1000);
125         else if (!mame_stricmp(filetype(), "a0")) fread(m_card->m_blk5, 0x2000);
126         else if (!mame_stricmp(filetype(), "b0")) fread(m_card->m_blk5, 0x2000, 0x1000);
224127         else if (!mame_stricmp(filetype(), "crt"))
225128         {
226129            // read the header
r26672r26673
230133
231134            switch (address)
232135            {
233            case 0x2000: fread(m_card->vic20_blk1_pointer(machine(), 0x2000), 0x2000); break;
234            case 0x4000: fread(m_card->vic20_blk2_pointer(machine(), 0x2000), 0x2000); break;
235            case 0x6000: fread(m_card->vic20_blk3_pointer(machine(), 0x2000), 0x2000); break;
236            case 0x7000: fread(m_card->vic20_blk3_pointer(machine(), 0x2000) + 0x1000, 0x1000); break;
237            case 0xa000: fread(m_card->vic20_blk5_pointer(machine(), 0x2000), 0x2000); break;
238            case 0xb000: fread(m_card->vic20_blk5_pointer(machine(), 0x2000) + 0x1000, 0x1000); break;
136            case 0x2000: fread(m_card->m_blk1, 0x2000); break;
137            case 0x4000: fread(m_card->m_blk2, 0x2000); break;
138            case 0x6000: fread(m_card->m_blk3, 0x2000); break;
139            case 0x7000: fread(m_card->m_blk3, 0x2000, 0x1000); break;
140            case 0xa000: fread(m_card->m_blk5, 0x2000); break;
141            case 0xb000: fread(m_card->m_blk5, 0x2000, 0x1000); break;
239142            default: return IMAGE_INIT_FAIL;
240143            }
241144         }
242145      }
243146      else
244147      {
245         size = get_software_region_length("blk1");
246         if (size) memcpy(m_card->vic20_blk1_pointer(machine(), size), get_software_region("blk1"), size);
247
248         size = get_software_region_length("blk2");
249         if (size) memcpy(m_card->vic20_blk2_pointer(machine(), size), get_software_region("blk2"), size);
250
251         size = get_software_region_length("blk3");
252         if (size) memcpy(m_card->vic20_blk3_pointer(machine(), size), get_software_region("blk3"), size);
253
254         size = get_software_region_length("blk5");
255         if (size) memcpy(m_card->vic20_blk5_pointer(machine(), size), get_software_region("blk5"), size);
256
257         size = get_software_region_length("ram");
258         if (size) memcpy(m_card->vic20_ram_pointer(machine(), size), get_software_region("ram"), size);
259
260         size = get_software_region_length("nvram");
261         if (size) memcpy(m_card->vic20_nvram_pointer(machine(), size), get_software_region("nvram"), size);
262
148         load_software_region("blk1", m_card->m_blk1);
149         load_software_region("blk2", m_card->m_blk2);
150         load_software_region("blk3", m_card->m_blk3);
151         load_software_region("blk5", m_card->m_blk5);
263152      }
264153   }
265154
trunk/src/emu/bus/vic20/exp.h
r26672r26673
144144   device_vic20_expansion_card_interface(const machine_config &mconfig, device_t &device);
145145   virtual ~device_vic20_expansion_card_interface();
146146
147protected:
148   // initialization
149   virtual UINT8* vic20_blk1_pointer(running_machine &machine, size_t size);
150   virtual UINT8* vic20_blk2_pointer(running_machine &machine, size_t size);
151   virtual UINT8* vic20_blk3_pointer(running_machine &machine, size_t size);
152   virtual UINT8* vic20_blk5_pointer(running_machine &machine, size_t size);
153   virtual UINT8* vic20_ram_pointer(running_machine &machine, size_t size);
154   virtual UINT8* vic20_nvram_pointer(running_machine &machine, size_t size);
155
156   // runtime
157147   virtual UINT8 vic20_cd_r(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3) { return data; };
158148   virtual void vic20_cd_w(address_space &space, offs_t offset, UINT8 data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3) { };
159149
160   vic20_expansion_slot_device *m_slot;
150protected:
151   optional_shared_ptr<UINT8> m_blk1;
152   optional_shared_ptr<UINT8> m_blk2;
153   optional_shared_ptr<UINT8> m_blk3;
154   optional_shared_ptr<UINT8> m_blk5;
155   optional_shared_ptr<UINT8> m_nvram;
161156
162   UINT8 *m_blk1;
163   UINT8 *m_blk2;
164   UINT8 *m_blk3;
165   UINT8 *m_blk5;
166   UINT8 *m_ram;
167   UINT8 *m_nvram;
168
169   size_t m_nvram_size;
170
171   size_t m_nvram_mask;
157   vic20_expansion_slot_device *m_slot;
172158};
173159
174160
trunk/src/emu/bus/cbm2/24k.c
r26672r26673
3131
3232cbm2_24k_cartridge_device::cbm2_24k_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
3333   device_t(mconfig, CBM2_24K, "24K RAM/ROM cartridge", tag, owner, clock, "cbm2_24k", __FILE__),
34   device_cbm2_expansion_card_interface(mconfig, *this)
34   device_cbm2_expansion_card_interface(mconfig, *this),
35   m_ram(*this, "ram")
3536{
3637}
3738
r26672r26673
4243
4344void cbm2_24k_cartridge_device::device_start()
4445{
45   cbm2_ram_pointer(machine(), 0x6000);
46   m_ram.allocate(0x6000);
4647}
4748
4849
trunk/src/emu/bus/cbm2/exp.h
r26672r26673
116116   device_cbm2_expansion_card_interface(const machine_config &mconfig, device_t &device);
117117   virtual ~device_cbm2_expansion_card_interface();
118118
119protected:
120   // initialization
121   virtual UINT8* cbm2_bank1_pointer(running_machine &machine, size_t size);
122   virtual UINT8* cbm2_bank2_pointer(running_machine &machine, size_t size);
123   virtual UINT8* cbm2_bank3_pointer(running_machine &machine, size_t size);
124   virtual UINT8* cbm2_ram_pointer(running_machine &machine, size_t size);
125   virtual UINT8* cbm2_nvram_pointer(running_machine &machine, size_t size);
126
127   // runtime
128119   virtual UINT8 cbm2_bd_r(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3) { return data; };
129120   virtual void cbm2_bd_w(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3) { };
130121
131   cbm2_expansion_slot_device *m_slot;
122protected:
123   optional_shared_ptr<UINT8> m_bank1;
124   optional_shared_ptr<UINT8> m_bank2;
125   optional_shared_ptr<UINT8> m_bank3;
132126
133   UINT8 *m_bank1;
134   UINT8 *m_bank2;
135   UINT8 *m_bank3;
136   UINT8 *m_ram;
137   UINT8 *m_nvram;
138
139   size_t m_nvram_size;
140
141   size_t m_bank1_mask;
142   size_t m_bank2_mask;
143   size_t m_bank3_mask;
144   size_t m_ram_mask;
145   size_t m_nvram_mask;
127   cbm2_expansion_slot_device *m_slot;
146128};
147129
148130
trunk/src/emu/bus/cbm2/24k.h
r26672r26673
3939   // device_cbm2_expansion_card_interface overrides
4040   virtual UINT8 cbm2_bd_r(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3);
4141   virtual void cbm2_bd_w(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3);
42
43   optional_shared_ptr<UINT8> m_ram;
4244};
4345
4446
trunk/src/emu/bus/cbm2/std.c
r26672r26673
5151
5252UINT8 cbm2_standard_cartridge_device::cbm2_bd_r(address_space &space, offs_t offset, UINT8 data, int csbank1, int csbank2, int csbank3)
5353{
54   if (!csbank1 && m_bank1_mask)
54   if (!csbank1 && m_bank1.bytes())
5555   {
56      data = m_bank1[offset & m_bank1_mask];
56      data = m_bank1[offset & m_bank1.mask()];
5757   }
58   else if (!csbank2 && m_bank2_mask)
58   else if (!csbank2 && m_bank2.bytes())
5959   {
60      data = m_bank2[offset & m_bank2_mask];
60      data = m_bank2[offset & m_bank2.mask()];
6161   }
62   else if (!csbank3 && m_bank3_mask)
62   else if (!csbank3 && m_bank3.bytes())
6363   {
64      data = m_bank3[offset & m_bank3_mask];
64      data = m_bank3[offset & m_bank3.mask()];
6565   }
6666
6767   return data;
trunk/src/emu/bus/cbm2/exp.c
r26672r26673
3939
4040device_cbm2_expansion_card_interface::device_cbm2_expansion_card_interface(const machine_config &mconfig, device_t &device)
4141   : device_slot_card_interface(mconfig, device),
42      m_bank1(NULL),
43      m_bank2(NULL),
44      m_bank3(NULL),
45      m_ram(NULL),
46      m_nvram(NULL),
47      m_nvram_size(0),
48      m_bank1_mask(0),
49      m_bank2_mask(0),
50      m_bank3_mask(0),
51      m_ram_mask(0)
42      m_bank1(*this, "bank1"),
43      m_bank2(*this, "bank2"),
44      m_bank3(*this, "bank3")
5245{
5346   m_slot = dynamic_cast<cbm2_expansion_slot_device *>(device.owner());
5447}
r26672r26673
6356}
6457
6558
66//-------------------------------------------------
67//  cbm2_bank1_pointer - get bank 1 pointer
68//-------------------------------------------------
6959
70UINT8* device_cbm2_expansion_card_interface::cbm2_bank1_pointer(running_machine &machine, size_t size)
71{
72   if (m_bank1 == NULL)
73   {
74      m_bank1 = auto_alloc_array(machine, UINT8, size);
75
76      m_bank1_mask = size - 1;
77   }
78
79   return m_bank1;
80}
81
82
83//-------------------------------------------------
84//  cbm2_bank2_pointer - get bank 2 pointer
85//-------------------------------------------------
86
87UINT8* device_cbm2_expansion_card_interface::cbm2_bank2_pointer(running_machine &machine, size_t size)
88{
89   if (m_bank2 == NULL)
90   {
91      m_bank2 = auto_alloc_array(machine, UINT8, size);
92
93      m_bank2_mask = size - 1;
94   }
95
96   return m_bank2;
97}
98
99
100//-------------------------------------------------
101//  cbm2_bank3_pointer - get bank 3 pointer
102//-------------------------------------------------
103
104UINT8* device_cbm2_expansion_card_interface::cbm2_bank3_pointer(running_machine &machine, size_t size)
105{
106   if (m_bank3 == NULL)
107   {
108      m_bank3 = auto_alloc_array(machine, UINT8, size);
109
110      m_bank3_mask = size - 1;
111   }
112
113   return m_bank3;
114}
115
116
117//-------------------------------------------------
118//  cbm2_ram_pointer - get RAM pointer
119//-------------------------------------------------
120
121UINT8* device_cbm2_expansion_card_interface::cbm2_ram_pointer(running_machine &machine, size_t size)
122{
123   if (m_ram == NULL)
124   {
125      m_ram = auto_alloc_array(machine, UINT8, size);
126
127      m_ram_mask = size - 1;
128   }
129
130   return m_ram;
131}
132
133
134//-------------------------------------------------
135//  cbm2_ram_pointer - get NVRAM pointer
136//-------------------------------------------------
137
138UINT8* device_cbm2_expansion_card_interface::cbm2_nvram_pointer(running_machine &machine, size_t size)
139{
140   if (m_nvram == NULL)
141   {
142      m_nvram = auto_alloc_array(machine, UINT8, size);
143
144      m_nvram_mask = size - 1;
145      m_nvram_size = size;
146   }
147
148   return m_nvram;
149}
150
151
152
15360//**************************************************************************
15461//  LIVE DEVICE
15562//**************************************************************************
r26672r26673
209116
210117         if (!mame_stricmp(filetype(), "20"))
211118         {
212            fread(m_card->cbm2_bank1_pointer(machine(), size), size);
119            m_card->m_bank1.allocate(size);
120            fread(m_card->m_bank1, size);
213121         }
214122         else if (!mame_stricmp(filetype(), "40"))
215123         {
216            fread(m_card->cbm2_bank2_pointer(machine(), size), size);
124            m_card->m_bank2.allocate(size);
125            fread(m_card->m_bank2, size);
217126         }
218127         else if (!mame_stricmp(filetype(), "60"))
219128         {
220            fread(m_card->cbm2_bank3_pointer(machine(), size), size);
129            m_card->m_bank3.allocate(size);
130            fread(m_card->m_bank3, size);
221131         }
222132      }
223133      else
224134      {
225         size = get_software_region_length("bank1");
226         if (size) memcpy(m_card->cbm2_bank1_pointer(machine(), size), get_software_region("bank1"), size);
227
228         size = get_software_region_length("bank2");
229         if (size) memcpy(m_card->cbm2_bank2_pointer(machine(), size), get_software_region("bank2"), size);
230
231         size = get_software_region_length("bank3");
232         if (size) memcpy(m_card->cbm2_bank3_pointer(machine(), size), get_software_region("bank3"), size);
233
234         size = get_software_region_length("ram");
235         if (size) memset(m_card->cbm2_ram_pointer(machine(), size), 0, size);
236
237         size = get_software_region_length("nvram");
238         if (size) memset(m_card->cbm2_nvram_pointer(machine(), size), 0, size);
135         load_software_region("bank1", m_card->m_bank1);
136         load_software_region("bank2", m_card->m_bank2);
137         load_software_region("bank3", m_card->m_bank3);
239138      }
240139   }
241140
trunk/src/emu/bus/c64/dqbb.h
r26672r26673
4242
4343   // device_nvram_interface overrides
4444   virtual void nvram_default() { }
45   virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram_size); } }
46   virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram_size); } }
45   virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram.bytes()); } }
46   virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram.bytes()); } }
4747
4848   // device_c64_expansion_card_interface overrides
4949   virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
trunk/src/emu/bus/c64/magic_formel.c
r26672r26673
182182   device_t(mconfig, C64_MAGIC_FORMEL, "C64 Magic Formel cartridge", tag, owner, clock, "c64_magic_formel", __FILE__),
183183   device_c64_expansion_card_interface(mconfig, *this),
184184   m_pia(*this, MC6821_TAG),
185   m_ram(*this, "ram"),
185186   m_rom_bank(0),
186187   m_ram_bank(0),
187188   m_pb7_ff(0),
r26672r26673
199200
200201void c64_magic_formel_cartridge_device::device_start()
201202{
203   // allocate memory
204   m_ram.allocate(0x2000);
205
202206   // state saving
203207   save_item(NAME(m_rom_bank));
204208   save_item(NAME(m_ram_bank));
trunk/src/emu/bus/c64/magic_formel.h
r26672r26673
5757
5858private:
5959   required_device<pia6821_device> m_pia;
60   optional_shared_ptr<UINT8> m_ram;
6061
6162   UINT8 m_rom_bank;
6263   UINT8 m_ram_bank;
trunk/src/emu/bus/c64/partner.c
r26672r26673
8282c64_partner_cartridge_device::c64_partner_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
8383   device_t(mconfig, C64_PARTNER, "C64 PARTNER 64 cartridge", tag, owner, clock, "c64_partner", __FILE__),
8484   device_c64_expansion_card_interface(mconfig, *this),
85   m_ram(*this, "ram"),
8586   m_a0(1),
8687   m_a6(1),
8788   m_nmi(0)
r26672r26673
9697void c64_partner_cartridge_device::device_start()
9798{
9899   // allocate memory
99   c64_ram_pointer(machine(), 0x2000);
100   m_ram.allocate(0x2000);
100101}
101102
102103
trunk/src/emu/bus/c64/partner.h
r26672r26673
4848   virtual int c64_game_r(offs_t offset, int sphi2, int ba, int rw);
4949
5050private:
51   optional_shared_ptr<UINT8> m_ram;
52
5153   int m_a0;
5254   int m_a6;
5355   int m_nmi;
trunk/src/emu/bus/c64/ocean.c
r26672r26673
8686
8787UINT8 c64_ocean_cartridge_device::c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2)
8888{
89   if (!roml)
89   if (!roml && m_roml.bytes())
9090   {
9191      offs_t addr = (m_bank << 13) | (offset & 0x1fff);
92      data = m_roml[addr & m_roml_mask];
92      data = m_roml[addr & m_roml.mask()];
9393   }
94   else if (!romh && m_romh)
94   else if (!romh && m_romh.bytes())
9595   {
9696      offs_t addr = (m_bank << 13) | (offset & 0x1fff);
97      data = m_romh[addr & m_romh_mask];
97      data = m_romh[addr & m_romh.mask()];
9898   }
9999   else if (!io1)
100100   {
trunk/src/emu/bus/c64/exp.c
r26672r26673
3131
3232device_c64_expansion_card_interface::device_c64_expansion_card_interface(const machine_config &mconfig, device_t &device)
3333   : device_slot_card_interface(mconfig, device),
34      m_roml(NULL),
35      m_romh(NULL),
36      m_ram(NULL),
37      m_nvram(NULL),
38      m_nvram_size(0),
39      m_roml_mask(0),
40      m_romh_mask(0),
41      m_ram_mask(0),
34      m_roml(*this, "roml"),
35      m_romh(*this, "romh"),
36      m_nvram(*this, "nvram"),
4237      m_game(1),
4338      m_exrom(1)
4439{
r26672r26673
5550}
5651
5752
58//-------------------------------------------------
59//  c64_roml_pointer - get low ROM pointer
60//-------------------------------------------------
6153
62UINT8* device_c64_expansion_card_interface::c64_roml_pointer(running_machine &machine, size_t size)
63{
64   if (m_roml == NULL)
65   {
66      m_roml = auto_alloc_array(machine, UINT8, size);
67
68      m_roml_mask = size - 1;
69   }
70
71   return m_roml;
72}
73
74
75//-------------------------------------------------
76//  c64_romh_pointer - get high ROM pointer
77//-------------------------------------------------
78
79UINT8* device_c64_expansion_card_interface::c64_romh_pointer(running_machine &machine, size_t size)
80{
81   if (m_romh == NULL)
82   {
83      m_romh = auto_alloc_array(machine, UINT8, size);
84
85      m_romh_mask = size - 1;
86   }
87
88   return m_romh;
89}
90
91
92//-------------------------------------------------
93//  c64_ram_pointer - get RAM pointer
94//-------------------------------------------------
95
96UINT8* device_c64_expansion_card_interface::c64_ram_pointer(running_machine &machine, size_t size)
97{
98   if (m_ram == NULL)
99   {
100      m_ram = auto_alloc_array(machine, UINT8, size);
101
102      m_ram_mask = size - 1;
103   }
104
105   return m_ram;
106}
107
108
109//-------------------------------------------------
110//  c64_ram_pointer - get NVRAM pointer
111//-------------------------------------------------
112
113UINT8* device_c64_expansion_card_interface::c64_nvram_pointer(running_machine &machine, size_t size)
114{
115   if (m_nvram == NULL)
116   {
117      m_nvram = auto_alloc_array(machine, UINT8, size);
118
119      m_nvram_mask = size - 1;
120      m_nvram_size = size;
121   }
122
123   return m_nvram;
124}
125
126
127
12854//**************************************************************************
12955//  LIVE DEVICE
13056//**************************************************************************
r26672r26673
202128
203129         if (!mame_stricmp(filetype(), "80"))
204130         {
205            fread(m_card->c64_roml_pointer(machine(), size), size);
131            fread(m_card->m_roml, size);
206132            m_card->m_exrom = (0);
207133
208134            if (size == 0x4000)
r26672r26673
212138         }
213139         else if (!mame_stricmp(filetype(), "a0"))
214140         {
215            fread(m_card->c64_romh_pointer(machine(), 0x2000), 0x2000);
141            fread(m_card->m_romh, 0x2000);
216142
217143            m_card->m_exrom = 0;
218144            m_card->m_game = 0;
219145         }
220146         else if (!mame_stricmp(filetype(), "e0"))
221147         {
222            fread(m_card->c64_romh_pointer(machine(), 0x2000), 0x2000);
148            fread(m_card->m_romh, 0x2000);
223149
224150            m_card->m_game = 0;
225151         }
r26672r26673
235161               UINT8 *roml = NULL;
236162               UINT8 *romh = NULL;
237163
238               if (roml_size) roml = m_card->c64_roml_pointer(machine(), roml_size);
239               if (romh_size) romh = m_card->c64_romh_pointer(machine(), romh_size);
164               m_card->m_roml.allocate(roml_size);
165               m_card->m_romh.allocate(romh_size);
240166
167               if (roml_size) roml = m_card->m_roml;
168               if (romh_size) romh = m_card->m_roml;
169
241170               cbm_crt_read_data(m_file, roml, romh);
242171            }
243172
r26672r26673
252181         if (size)
253182         {
254183            // Ultimax (VIC-10) cartridge
255            memcpy(m_card->c64_romh_pointer(machine(), size), get_software_region("uprom"), size);
184            load_software_region("lorom", m_card->m_roml);
185            load_software_region("uprom", m_card->m_romh);
256186
257            size = get_software_region_length("lorom");
258            if (size) memcpy(m_card->c64_roml_pointer(machine(), size), get_software_region("lorom"), size);
259
260187            m_card->m_exrom = 1;
261188            m_card->m_game = 0;
262189         }
263190         else
264191         {
265192            // Commodore 64/128 cartridge
266            size = get_software_region_length("roml");
267            if (size) memcpy(m_card->c64_roml_pointer(machine(), size), get_software_region("roml"), size);
193            load_software_region("roml", m_card->m_roml);
194            load_software_region("romh", m_card->m_romh);
195            load_software_region("nvram", m_card->m_nvram);
268196
269            size = get_software_region_length("romh");
270            if (size) memcpy(m_card->c64_romh_pointer(machine(), size), get_software_region("romh"), size);
271
272            size = get_software_region_length("ram");
273            if (size) memset(m_card->c64_ram_pointer(machine(), size), 0, size);
274
275            size = get_software_region_length("nvram");
276            if (size) memset(m_card->c64_nvram_pointer(machine(), size), 0, size);
277
278197            if (get_feature("exrom") != NULL) m_card->m_exrom = atol(get_feature("exrom"));
279198            if (get_feature("game") != NULL) m_card->m_game = atol(get_feature("game"));
280199         }
trunk/src/emu/bus/c64/exp.h
r26672r26673
167167   device_c64_expansion_card_interface(const machine_config &mconfig, device_t &device);
168168   virtual ~device_c64_expansion_card_interface();
169169
170protected:
171   // initialization
172   virtual UINT8* c64_roml_pointer(running_machine &machine, size_t size);
173   virtual UINT8* c64_romh_pointer(running_machine &machine, size_t size);
174   virtual UINT8* c64_ram_pointer(running_machine &machine, size_t size);
175   virtual UINT8* c64_nvram_pointer(running_machine &machine, size_t size);
176
177   // runtime
178170   virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2) { return data; };
179171   virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2) { };
180172   virtual int c64_game_r(offs_t offset, int sphi2, int ba, int rw) { return m_game; }
181173   virtual int c64_exrom_r(offs_t offset, int sphi2, int ba, int rw) { return m_exrom; }
182174
183   c64_expansion_slot_device *m_slot;
175protected:
176   optional_shared_ptr<UINT8> m_roml;
177   optional_shared_ptr<UINT8> m_romh;
178   optional_shared_ptr<UINT8> m_nvram;
184179
185   UINT8 *m_roml;
186   UINT8 *m_romh;
187   UINT8 *m_ram;
188   UINT8 *m_nvram;
189
190   size_t m_nvram_size;
191
192   size_t m_roml_mask;
193   size_t m_romh_mask;
194   size_t m_ram_mask;
195   size_t m_nvram_mask;
196
197180   int m_game;
198181   int m_exrom;
182
183   c64_expansion_slot_device *m_slot;
199184};
200185
201186
trunk/src/emu/bus/c64/ide64.c
r26672r26673
103103   m_flash_rom(*this, AT29C010A_TAG),
104104   m_rtc(*this, DS1302_TAG),
105105   m_ata(*this, ATA_TAG),
106   m_jp1(*this, "JP1")
106   m_jp1(*this, "JP1"),
107   m_ram(*this, "ram")
107108{
108109}
109110
r26672r26673
115116void c64_ide64_cartridge_device::device_start()
116117{
117118   // allocate memory
118   c64_ram_pointer(machine(), 0x8000);
119   m_ram.allocate(0x8000);
119120
120121   // state saving
121122   save_item(NAME(m_bank));
trunk/src/emu/bus/c64/ide64.h
r26672r26673
5757   required_device<ds1302_device> m_rtc;
5858   required_device<ata_interface_device> m_ata;
5959   required_ioport m_jp1;
60   optional_shared_ptr<UINT8> m_ram;
6061
6162   UINT8 m_bank;
6263   UINT16 m_ata_data;
trunk/src/emu/bus/c64/xl80.c
r26672r26673
178178   device_t(mconfig, C64_XL80, "XL 80", tag, owner, clock, "c64_xl80", __FILE__),
179179   device_c64_expansion_card_interface(mconfig, *this),
180180   m_crtc(*this, HD46505SP_TAG),
181   m_char_rom(*this, HD46505SP_TAG)
181   m_char_rom(*this, HD46505SP_TAG),
182   m_ram(*this, "ram")
182183{
183184}
184185
r26672r26673
190191void c64_xl80_device::device_start()
191192{
192193   // allocate memory
193   c64_ram_pointer(machine(), RAM_SIZE);
194
195   // state saving
196   save_pointer(NAME(m_ram), RAM_SIZE);
194   m_ram.allocate(RAM_SIZE);
197195}
198196
199197
trunk/src/emu/bus/c64/xl80.h
r26672r26673
5555private:
5656   required_device<h46505_device> m_crtc;
5757   required_memory_region m_char_rom;
58   optional_shared_ptr<UINT8> m_ram;
5859};
5960
6061
trunk/src/emu/bus/c64/ross.c
r26672r26673
7070   {
7171      offs_t addr = (m_bank << 14) | (offset & 0x3fff);
7272
73      data = m_roml[addr & m_roml_mask];
73      data = m_roml[addr & m_roml.mask()];
7474   }
7575
7676   return data;
trunk/src/emu/bus/c64/fcc.c
r26672r26673
244244
245245READ8_MEMBER( c64_final_chesscard_device::nvram_r )
246246{
247   return m_nvram[offset & m_nvram_mask];
247   return m_nvram[offset & m_nvram.mask()];
248248}
249249
250250
r26672r26673
254254
255255WRITE8_MEMBER( c64_final_chesscard_device::nvram_w )
256256{
257   m_nvram[offset & m_nvram_mask] = data;
257   m_nvram[offset & m_nvram.mask()] = data;
258258}
trunk/src/emu/bus/c64/fcc.h
r26672r26673
4949
5050   // device_nvram_interface overrides
5151   virtual void nvram_default() { }
52   virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram_size); } }
53   virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram_size); } }
52   virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram.bytes()); } }
53   virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram.bytes()); } }
5454
5555   // device_c64_expansion_card_interface overrides
5656   virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
trunk/src/emu/bus/c64/16kb.c
r26672r26673
102102c64_16kb_cartridge_device::c64_16kb_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
103103   device_t(mconfig, C64_16KB, "C64 16KB EPROM cartridge", tag, owner, clock, "c64_16kb", __FILE__),
104104   device_c64_expansion_card_interface(mconfig, *this),
105   m_sw1(*this, "SW1")
105   m_sw1(*this, "SW1"),
106   m_rom_low(*this, "roml"),
107   m_rom_high(*this, "romh")
106108{
107109}
108110
r26672r26673
113115
114116void c64_16kb_cartridge_device::device_start()
115117{
116   m_roml = memregion("roml")->base();
117   m_romh = memregion("romh")->base();
118118}
119119
120120
r26672r26673
139139{
140140   if (!roml)
141141   {
142      data = m_roml[offset & 0x1fff];
142      data = m_rom_low->base()[offset & 0x1fff];
143143   }
144144   else if (!romh)
145145   {
146      data = m_romh[offset & 0x1fff];
146      data = m_rom_high->base()[offset & 0x1fff];
147147   }
148148
149149   return data;
trunk/src/emu/bus/c64/16kb.h
r26672r26673
4949
5050private:
5151   required_ioport m_sw1;
52   required_memory_region m_rom_low;
53   required_memory_region m_rom_high;
5254};
5355
5456
trunk/src/emu/bus/c64/westermann.c
r26672r26673
6363{
6464   if (!roml)
6565   {
66      data = m_roml[offset & 0x1fff];
66      data = m_roml[offset & m_roml.mask()];
6767   }
6868   else if (!romh)
6969   {
70      if (m_romh_mask)
70      if (m_romh.bytes())
7171      {
72         data = m_romh[offset & 0x1fff];
72         data = m_romh[offset & m_romh.mask()];
7373      }
7474      else
7575      {
76         data = m_roml[offset & 0x3fff];
76         data = m_roml[offset & m_roml.mask()];
7777      }
7878   }
7979   else if (!io2)
trunk/src/emu/bus/c64/georam.c
r26672r26673
3131
3232c64_georam_cartridge_device::c64_georam_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
3333   device_t(mconfig, C64_GEORAM, "C64 GeoRAM cartridge", tag, owner, clock, "c64_georam", __FILE__),
34   device_c64_expansion_card_interface(mconfig, *this)
34   device_c64_expansion_card_interface(mconfig, *this),
35   m_ram(*this, "ram")
3536{
3637}
3738
r26672r26673
4344void c64_georam_cartridge_device::device_start()
4445{
4546   // allocate memory
46   c64_ram_pointer(machine(), 0x80000);
47   m_ram.allocate(0x80000);
4748
4849   // state saving
4950   save_item(NAME(m_bank));
trunk/src/emu/bus/c64/georam.h
r26672r26673
4343   virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
4444
4545private:
46   optional_shared_ptr<UINT8> m_ram;
47
4648   UINT16 m_bank;
4749};
4850
trunk/src/emu/bus/c64/pagefox.c
r26672r26673
5353
5454c64_pagefox_cartridge_device::c64_pagefox_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
5555   device_t(mconfig, C64_PAGEFOX, "C64 Pagefox cartridge", tag, owner, clock, "c64_pagefox", __FILE__),
56   device_c64_expansion_card_interface(mconfig, *this)
56   device_c64_expansion_card_interface(mconfig, *this),
57   m_ram(*this, "ram")
5758{
5859}
5960
r26672r26673
6465
6566void c64_pagefox_cartridge_device::device_start()
6667{
68   // allocate memory
69   m_ram.allocate(0x8000);
70   
6771   // state saving
6872   save_item(NAME(m_bank));
6973}
trunk/src/emu/bus/c64/std.c
r26672r26673
5151
5252UINT8 c64_standard_cartridge_device::c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2)
5353{
54   if (!roml && m_roml_mask)
54   if (!roml && m_roml.bytes())
5555   {
56      data = m_roml[offset & 0x1fff];
56      data = m_roml[offset & m_roml.mask()];
5757   }
5858   else if (!romh)
5959   {
60      if (m_romh_mask)
60      if (m_romh.bytes())
6161      {
62         data = m_romh[offset & 0x1fff];
62         data = m_romh[offset & m_romh.mask()];
6363      }
64      else if (m_roml_mask == 0x3fff)
64      else if (m_roml.mask() == 0x3fff)
6565      {
66         data = m_roml[offset & 0x3fff];
66         data = m_roml[offset & m_roml.mask()];
6767      }
6868   }
6969
trunk/src/emu/bus/c64/pagefox.h
r26672r26673
4343   virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
4444
4545private:
46   optional_shared_ptr<UINT8> m_ram;
47
4648   UINT8 m_bank;
4749};
4850
trunk/src/emu/bus/c64/easyflash.c
r26672r26673
8989   m_flash_roml(*this, AM29F040_0_TAG),
9090   m_flash_romh(*this, AM29F040_1_TAG),
9191   m_jp1(*this, "JP1"),
92   m_ram(*this, "ram"),
9293   m_bank(0),
9394   m_mode(0)
9495{
r26672r26673
102103void c64_easyflash_cartridge_device::device_start()
103104{
104105   // allocate memory
105   c64_ram_pointer(machine(), 0x100);
106   m_ram.allocate(0x100);
106107
107108   // state saving
108109   save_item(NAME(m_bank));
trunk/src/emu/bus/c64/neoram.c
r26672r26673
4444void c64_neoram_cartridge_device::device_start()
4545{
4646   // allocate memory
47   c64_nvram_pointer(machine(), 0x200000);
47   m_nvram.allocate(0x200000);
4848
4949   // state saving
5050   save_item(NAME(m_bank));
trunk/src/emu/bus/c64/easyflash.h
r26672r26673
5353   required_device<amd_29f040_device> m_flash_roml;
5454   required_device<amd_29f040_device> m_flash_romh;
5555   required_ioport m_jp1;
56   optional_shared_ptr<UINT8> m_ram;
5657
5758   UINT8 m_bank;
5859   UINT8 m_mode;
trunk/src/emu/bus/c64/neoram.h
r26672r26673
4141
4242   // device_nvram_interface overrides
4343   virtual void nvram_default() { }
44   virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram_size); } }
45   virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram_size); } }
44   virtual void nvram_read(emu_file &file) { if (m_nvram != NULL) { file.read(m_nvram, m_nvram.bytes()); } }
45   virtual void nvram_write(emu_file &file) { if (m_nvram != NULL) { file.write(m_nvram, m_nvram.bytes()); } }
4646
4747   // device_c64_expansion_card_interface overrides
4848   virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
trunk/src/emu/bus/c64/reu.c
r26672r26673
8686   device_t(mconfig, type, name, tag, owner, clock, shortname, source),
8787   device_c64_expansion_card_interface(mconfig, *this),
8888   m_dmac(*this, MOS8726R1_TAG),
89   m_rom(*this, "rom"),
90   m_ram(*this, "ram"),
8991   m_variant(variant),
9092   m_jp1(jp1),
9193   m_ram_size(ram_size)
r26672r26673
108110
109111void c64_reu_cartridge_device::device_start()
110112{
111   // find memory region
112   m_roml = memregion("roml")->base();
113
114113   // allocate memory
115   c64_ram_pointer(machine(), m_ram_size);
114   m_ram.allocate(m_ram_size);
116115
117116   // setup DMA controller
118117   m_dmac->set_unscaled_clock(m_slot->phi2());
trunk/src/emu/bus/c64/reu.h
r26672r26673
5656   virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
5757
5858   required_device<mos8726_device> m_dmac;
59   required_memory_region m_rom;
60   optional_shared_ptr<UINT8> m_ram;
5961
6062   int m_variant;
6163   int m_jp1;
trunk/src/emu/bus/c64/dqbb.c
r26672r26673
5353void c64_dqbb_cartridge_device::device_start()
5454{
5555   // allocate memory
56   c64_nvram_pointer(machine(), 0x4000);
56   m_nvram.allocate(0x4000);
5757
5858   // state saving
5959   save_item(NAME(m_cs));

Previous 199869 Revisions Next


© 1997-2024 The MAME Team