Previous 199869 Revisions Next

r21592 Tuesday 5th March, 2013 at 12:01:47 UTC by Fabio Priuli
srccleaned + minor fixes. nw.
[src/mess/drivers]snes.c
[src/mess/machine]snescart.c sns_bsx.c sns_bsx.h sns_rom.c sns_rom.h sns_rom21.c sns_rom21.h sns_sdd1.c sns_sdd1.h sns_sfx.c sns_sfx.h sns_slot.c sns_slot.h sns_spc7110.c sns_spc7110.h sns_sufami.c sns_sufami.h sns_upd.c sns_upd.h

trunk/src/mess/drivers/snes.c
r21591r21592
7373{
7474   UINT16 temp = state->m_upd96050->dataram_r(addr/2);
7575   UINT8 res;
76   
76
7777   if (addr & 1)
7878   {
7979      res = temp>>8;
r21591r21592
8282   {
8383      res = temp & 0xff;
8484   }
85   
85
8686   return res;
8787}
8888
8989void st010_write_ram(snes_state *state, UINT16 addr, UINT8 data)
9090{
9191   UINT16 temp = state->m_upd96050->dataram_r(addr/2);
92   
92
9393   if (addr & 1)
9494   {
9595      temp &= 0xff;
r21591r21592
100100      temp &= 0xff00;
101101      temp |= data;
102102   }
103   
103
104104   state->m_upd96050->dataram_w(addr/2, temp);
105105}
106106
r21591r21592
111111   UINT16 address = offset & 0xffff;
112112
113113   // take care of add-on chip access
114   if (state->m_has_addon_chip == HAS_OBC1
114   if (state->m_has_addon_chip == HAS_OBC1
115115      && (offset < 0x400000 && address >= 0x6000 && address < 0x8000))
116116      return obc1_read(space, offset, mem_mask);
117   if (state->m_has_addon_chip == HAS_CX4
117   if (state->m_has_addon_chip == HAS_CX4
118118      && (offset < 0x400000 && address >= 0x6000 && address < 0x8000))
119119      return CX4_read(address - 0x6000);
120120   if (state->m_has_addon_chip == HAS_RTC
r21591r21592
127127      if (offset == 0x600000 || offset == 0x600001)
128128         return (offset & 1) ? st010_get_sr() : st010_get_dr();
129129   }
130   if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1
130   if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1
131131      && (offset < 0x200000 && address >= 0x6000 && address < 0x8000))
132132      return (address < 0x7000) ? dsp_get_dr() : dsp_get_sr();
133133   if (state->m_cart[0].mode == SNES_MODE_20 && state->m_has_addon_chip == HAS_DSP1)
r21591r21592
136136         return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
137137      if (offset >= 0x600000 && offset < 0x700000 && (offset & 0x8000) == 0x0000)
138138         return (address < 0x4000) ? dsp_get_dr() : dsp_get_sr();
139   }   
139   }
140140   if ((state->m_has_addon_chip == HAS_DSP2 || state->m_has_addon_chip == HAS_DSP3)
141141      && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
142142      return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
143   if (state->m_has_addon_chip == HAS_DSP4
143   if (state->m_has_addon_chip == HAS_DSP4
144144      && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
145145      return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
146146   if (state->m_has_addon_chip == HAS_SDD1
r21591r21592
148148      return sdd1_mmio_read(space, (UINT32)address);
149149   if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
150150      && offset < 0x400000)
151   {   
151   {
152152      UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
153153      if (address >= 0x4800 && address <= limit)
154154         return spc7110_mmio_read(space, (UINT32)address);
r21591r21592
162162      return spc7110_mmio_read(space, 0x4800);
163163   if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL
164164      && offset < 0x400000)
165   {   
165   {
166166      if (address >= 0x3000 && address < 0x3300)
167167         return superfx_mmio_read(state->m_superfx, address);
168      if (address >= 0x6000 && address < 0x8000)    // here it should be snes_ram[0xe00000+...] but there are mirroring issues
168      if (address >= 0x6000 && address < 0x8000)  // here it should be snes_ram[0xe00000+...] but there are mirroring issues
169169         return superfx_access_ram(state->m_superfx) ? snes_ram[0xf00000 + (offset & 0x1fff)] : snes_open_bus_r(space, 0);
170170   }
171171   if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL
r21591r21592
185185   if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL
186186      && offset >= 0x600000)
187187      return superfx_access_ram(state->m_superfx) ? snes_ram[0x800000 + offset] : snes_open_bus_r(space, 0);
188   
188
189189   // base cart access
190190   if (offset < 0x300000)
191191      return snes_r_bank1(space, offset, 0xff);
r21591r21592
197197      return snes_r_bank4(space, offset - 0x600000, 0xff);
198198   else
199199      return snes_r_bank5(space, offset - 0x700000, 0xff);
200}   
200}
201201
202202static READ8_HANDLER( snes_hi_r )
203203{
204204   snes_state *state = space.machine().driver_data<snes_state>();
205205   UINT16 address = offset & 0xffff;
206   
206
207207   // take care of add-on chip access
208   if (state->m_has_addon_chip == HAS_OBC1
208   if (state->m_has_addon_chip == HAS_OBC1
209209      && (offset < 0x400000 && address >= 0x6000 && address < 0x8000))
210210      return obc1_read(space, offset, mem_mask);
211   if (state->m_has_addon_chip == HAS_CX4
211   if (state->m_has_addon_chip == HAS_CX4
212212      && (offset < 0x400000 && address >= 0x6000 && address < 0x8000))
213213      return CX4_read(address - 0x6000);
214214   if (state->m_has_addon_chip == HAS_RTC
r21591r21592
221221      if (offset == 0x600000 || offset == 0x600001)
222222         return (offset & 1) ? st010_get_sr() : st010_get_dr();
223223   }
224   if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1
224   if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1
225225      && (offset < 0x200000 && address >= 0x6000 && address < 0x8000))
226226      return (address < 0x7000) ? dsp_get_dr() : dsp_get_sr();
227227   if (state->m_cart[0].mode == SNES_MODE_20 && state->m_has_addon_chip == HAS_DSP1)
r21591r21592
234234   if ((state->m_has_addon_chip == HAS_DSP2 || state->m_has_addon_chip == HAS_DSP3)
235235      && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
236236      return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
237   if (state->m_has_addon_chip == HAS_DSP4
237   if (state->m_has_addon_chip == HAS_DSP4
238238      && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
239239      return (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
240240   if (state->m_has_addon_chip == HAS_SDD1
r21591r21592
244244      return sdd1_read(space.machine(), offset - 0x400000);
245245   if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
246246      && offset < 0x400000)
247   {   
247   {
248248      UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
249249      if (address >= 0x4800 && address <= limit)
250250         return spc7110_mmio_read(space, (UINT32)address);
r21591r21592
253253      if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000)
254254         return snes_ram[0x306000 + (address & 0x1fff)];
255255   }
256   if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
256   if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
257257      && offset >= 0x500000)
258258      return spc7110_bank7_read(space, offset - 0x400000);
259259   if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL)
260      return space.read_byte(offset);      // [80-ff] same as [00-7f]
261   
260      return space.read_byte(offset);     // [80-ff] same as [00-7f]
261
262262   // base cart access
263263   if (offset < 0x400000)
264264      return snes_r_bank6(space, offset, 0xff);
265265   else
266266      return snes_r_bank7(space, offset - 0x400000, 0xff);
267}   
267}
268268
269269static WRITE8_HANDLER( snes_lo_w )
270270{
271271   snes_state *state = space.machine().driver_data<snes_state>();
272272   UINT16 address = offset & 0xffff;
273   
273
274274   // take care of add-on chip access
275   if (state->m_has_addon_chip == HAS_OBC1
275   if (state->m_has_addon_chip == HAS_OBC1
276276      && (offset < 0x400000 && address >= 0x6000 && address < 0x8000))
277   {   obc1_write(space, offset, data, mem_mask);   return;   }
278   if (state->m_has_addon_chip == HAS_CX4
277   {   obc1_write(space, offset, data, mem_mask);  return; }
278   if (state->m_has_addon_chip == HAS_CX4
279279      && (offset < 0x400000 && address >= 0x6000 && address < 0x8000))
280   {   CX4_write(space.machine(), address - 0x6000, data);   return;   }
280   {   CX4_write(space.machine(), address - 0x6000, data); return; }
281281   if (state->m_has_addon_chip == HAS_RTC
282282      && (offset < 0x400000 && (address == 0x2800 || address == 0x2801)))
283   {   srtc_write(space.machine(), offset, data);   return;   }
283   {   srtc_write(space.machine(), offset, data);  return; }
284284   if (state->m_has_addon_chip == HAS_ST010 || state->m_has_addon_chip == HAS_ST011)
285285   {
286286      if (offset >= 0x680000 && offset < 0x700000 && address < 0x1000)
287      {   st010_write_ram(state, address, data);   return;   }
287      {   st010_write_ram(state, address, data);  return; }
288288      if (offset == 0x600000)
289      {   st010_set_dr(data);   return;   }
289      {   st010_set_dr(data); return; }
290290      if (offset == 0x600001)
291      {   st010_set_sr(data);   return;   }
291      {   st010_set_sr(data); return; }
292292   }
293   if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1
293   if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1
294294      && (offset < 0x200000 && address >= 0x6000 && address < 0x8000))
295   {   dsp_set_dr(data);   return;   }
295   {   dsp_set_dr(data);   return; }
296296   if (state->m_cart[0].mode == SNES_MODE_20 && state->m_has_addon_chip == HAS_DSP1)
297297   {
298298      if (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)
299      {   dsp_set_dr(data);   return;   }
299      {   dsp_set_dr(data);   return; }
300300      if (offset >= 0x600000 && offset < 0x700000 && (offset & 0x8000) == 0x0000)
301      {   dsp_set_dr(data);   return;   }
301      {   dsp_set_dr(data);   return; }
302302   }
303303   if ((state->m_has_addon_chip == HAS_DSP2 || state->m_has_addon_chip == HAS_DSP3)
304304      && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
305305   {
306306      if (address < 0xc000)
307      {   dsp_set_dr(data);   return;   }
307      {   dsp_set_dr(data);   return; }
308308      else
309      {   dsp_set_sr(data);   return;   }
309      {   dsp_set_sr(data);   return; }
310310   }
311   if (state->m_has_addon_chip == HAS_DSP4
311   if (state->m_has_addon_chip == HAS_DSP4
312312      && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
313313   {
314314      if (address < 0xc000)
315      {   dsp_set_dr(data);   return;   }
315      {   dsp_set_dr(data);   return; }
316316      else
317      {   dsp_set_sr(data);   return;   }
317      {   dsp_set_sr(data);   return; }
318318   }
319319   if (state->m_has_addon_chip == HAS_SDD1 && offset < 0x400000)
320320   {
r21591r21592
325325      }
326326   }
327327   if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) && offset < 0x400000)
328   {   
328   {
329329      UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
330330      if (address >= 0x4800 && address <= limit)
331      {   spc7110_mmio_write(space.machine(), (UINT32)address, data);   return;   }
331      {   spc7110_mmio_write(space.machine(), (UINT32)address, data); return; }
332332      if (offset < 0x10000 && address >= 0x6000 && address < 0x8000)
333      {   snes_ram[0x306000 + (address & 0x1fff)] = data;   return;   }
333      {   snes_ram[0x306000 + (address & 0x1fff)] = data; return; }
334334      if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000)
335      {   snes_ram[0x306000 + (address & 0x1fff)] = data;   return;   }
335      {   snes_ram[0x306000 + (address & 0x1fff)] = data; return; }
336336   }
337337   if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL
338       && offset < 0x400000)
339   {   
338         && offset < 0x400000)
339   {
340340      if (address >= 0x3000 && address < 0x3300)
341      {   superfx_mmio_write(state->m_superfx, address, data);   return;   }
342      if (address >= 0x6000 && address < 0x8000)    // here it should be snes_ram[0xe00000+...] but there are mirroring issues
343      {   snes_ram[0xf00000 + (offset & 0x1fff)] = data;   return;   }
341      {   superfx_mmio_write(state->m_superfx, address, data);    return; }
342      if (address >= 0x6000 && address < 0x8000)   // here it should be snes_ram[0xe00000+...] but there are mirroring issues
343      {   snes_ram[0xf00000 + (offset & 0x1fff)] = data;  return; }
344344   }
345345   if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL
346346      && offset >= 0x600000)
347   {   snes_ram[0x800000 + offset] = data;   return;   }
348   
347   {   snes_ram[0x800000 + offset] = data; return; }
348
349349   // base cart access
350350   if (offset < 0x300000)
351351      snes_w_bank1(space, offset, data, 0xff);
r21591r21592
357357      snes_w_bank4(space, offset - 0x600000, data, 0xff);
358358   else
359359      snes_w_bank5(space, offset - 0x700000, data, 0xff);
360}   
360}
361361
362362static WRITE8_HANDLER( snes_hi_w )
363363{
364364   snes_state *state = space.machine().driver_data<snes_state>();
365365   UINT16 address = offset & 0xffff;
366   
366
367367   // take care of add-on chip access
368   if (state->m_has_addon_chip == HAS_OBC1
368   if (state->m_has_addon_chip == HAS_OBC1
369369      && (offset < 0x400000 && address >= 0x6000 && address < 0x8000))
370   {   obc1_write(space, offset, data, mem_mask);   return;   }
371   if (state->m_has_addon_chip == HAS_CX4
370   {   obc1_write(space, offset, data, mem_mask);  return; }
371   if (state->m_has_addon_chip == HAS_CX4
372372      && (offset < 0x400000 && address >= 0x6000 && address < 0x8000))
373   {   CX4_write(space.machine(), address - 0x6000, data);   return;   }
373   {   CX4_write(space.machine(), address - 0x6000, data); return; }
374374   if (state->m_has_addon_chip == HAS_RTC
375375      && (offset < 0x400000 && (address == 0x2800 || address == 0x2801)))
376   {   srtc_write(space.machine(), offset, data);   return;   }
376   {   srtc_write(space.machine(), offset, data);  return; }
377377   if (state->m_has_addon_chip == HAS_ST010 || state->m_has_addon_chip == HAS_ST011)
378378   {
379379      if (offset >= 0x680000 && offset < 0x700000 && address < 0x1000)
380      {   st010_write_ram(state, address, data);   return;   }
380      {   st010_write_ram(state, address, data);  return; }
381381      if (offset == 0x600000)
382      {   st010_set_dr(data);   return;   }
382      {   st010_set_dr(data); return; }
383383      if (offset == 0x600001)
384      {   st010_set_sr(data);   return;   }
384      {   st010_set_sr(data); return; }
385385   }
386   if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1
386   if (state->m_cart[0].mode == SNES_MODE_21 && state->m_has_addon_chip == HAS_DSP1
387387      && (offset < 0x200000 && address >= 0x6000 && address < 0x8000))
388   {   dsp_set_dr(data);   return;   }
388   {   dsp_set_dr(data);   return; }
389389   if (state->m_cart[0].mode == SNES_MODE_20 && state->m_has_addon_chip == HAS_DSP1)
390390   {
391391      if (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000)
392      {   dsp_set_dr(data);   return;   }
392      {   dsp_set_dr(data);   return; }
393393      if (offset >= 0x600000 && offset < 0x700000 && (offset & 0x8000) == 0x0000)
394      {   dsp_set_dr(data);   return;   }
395   }   
394      {   dsp_set_dr(data);   return; }
395   }
396396   if ((state->m_has_addon_chip == HAS_DSP2 || state->m_has_addon_chip == HAS_DSP3)
397397      && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
398398   {
399399      if (address < 0xc000)
400      {   dsp_set_dr(data);   return;   }
400      {   dsp_set_dr(data);   return; }
401401      else
402      {   dsp_set_sr(data);   return;   }
402      {   dsp_set_sr(data);   return; }
403403   }
404   if (state->m_has_addon_chip == HAS_DSP4
404   if (state->m_has_addon_chip == HAS_DSP4
405405      && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
406406   {
407407      if (address < 0xc000)
408      {   dsp_set_dr(data);   return;   }
408      {   dsp_set_dr(data);   return; }
409409      else
410      {   dsp_set_sr(data);   return;   }
410      {   dsp_set_sr(data);   return; }
411411   }
412412   if (state->m_has_addon_chip == HAS_SDD1 && offset < 0x400000)
413413   {
r21591r21592
418418      }
419419   }
420420   if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) && offset < 0x400000)
421   {   
421   {
422422      UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
423423      if (address >= 0x4800 && address <= limit)
424      {   spc7110_mmio_write(space.machine(), (UINT32)address, data);   return;   }
424      {   spc7110_mmio_write(space.machine(), (UINT32)address, data); return; }
425425      if (offset < 0x10000 && address >= 0x6000 && address < 0x8000)
426      {   snes_ram[0x306000 + (address & 0x1fff)] = data;   return;   }
426      {   snes_ram[0x306000 + (address & 0x1fff)] = data; return; }
427427      if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000)
428      {   snes_ram[0x306000 + (address & 0x1fff)] = data;   return;   }
428      {   snes_ram[0x306000 + (address & 0x1fff)] = data; return; }
429429   }
430430   if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL)
431   {   space.write_byte(offset, data);   return;   }      // [80-ff] same as [00-7f]
432   
431   {   space.write_byte(offset, data); return; }       // [80-ff] same as [00-7f]
432
433433   // base cart access
434434   if (offset < 0x400000)
435435      snes_w_bank6(space, offset, data, 0xff);
436436   else
437437      snes_w_bank7(space, offset, data - 0x400000, 0xff);
438}   
438}
439439
440440static READ8_HANDLER( superfx_r_bank1 )
441441{
r21591r21592
11001100
11011101   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(snes_machine_stop),&machine));
11021102   MACHINE_START_CALL(snes);
1103   
1103
11041104   switch (state->m_has_addon_chip)
11051105   {
11061106      case HAS_SDD1:
r21591r21592
11331133
11341134   // see if there's a uPD7725 DSP in the machine config
11351135   state->m_upd7725 = machine.device<upd7725_device>("dsp");
1136   
1136
11371137   // if we have a DSP, halt it for the moment
11381138   if (state->m_upd7725)
11391139      machine.device("dsp")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
1140   
1140
11411141   // ditto for a uPD96050 (Seta ST-010 or ST-011)
11421142   state->m_upd96050 = machine.device<upd96050_device>("setadsp");
11431143   if (state->m_upd96050)
11441144      machine.device("setadsp")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
1145   
1145
11461146   switch (state->m_has_addon_chip)
11471147   {
11481148      case HAS_DSP1:
r21591r21592
11581158            state->m_has_addon_chip = HAS_NONE; // prevent crash trying to access NULL device
11591159         }
11601160         break;
1161         
1161
11621162      case HAS_RTC:
11631163         srtc_init(machine);
11641164         break;
1165         
1165
11661166      case HAS_OBC1:
11671167         obc1_init(machine);
11681168         break;
1169         
1169
11701170      case HAS_ST010:
11711171      case HAS_ST011:
11721172         // cartridge uses the DSP, let 'er rip
r21591r21592
11781178            state->m_has_addon_chip = HAS_NONE; // prevent crash trying to access NULL device
11791179         }
11801180         break;
1181         
1181
11821182      default:
11831183         break;
11841184   }
r21591r21592
14701470   snsnew_state(const machine_config &mconfig, device_type type, const char *tag)
14711471      : snes_state(mconfig, type, tag),
14721472      m_slotcart(*this, "snsslot")
1473   { }   
1474   
1473   { }
1474
14751475   optional_device<sns_cart_slot_device> m_slotcart;
14761476   int m_type;
14771477};
r21591r21592
14891489{
14901490   snsnew_state *state = space.machine().driver_data<snsnew_state>();
14911491   UINT16 address = offset & 0xffff;
1492   
1492
14931493   if (offset < 0x400000)
14941494   {
14951495      if (address < 0x2000)
r21591r21592
14981498         return snes_r_io(space, address);
14991499      if (address >= 0x6000 && address < 0x8000)
15001500         return snes_open_bus_r(space, 0);
1501      if (address >= 0x8000)         
1501      if (address >= 0x8000)
15021502         return state->m_slotcart->m_cart->read_h(space, offset);
15031503   }
15041504   else if (offset < 0x700000)
r21591r21592
15081508      else
15091509         return state->m_slotcart->m_cart->read_h(space, offset);
15101510   }
1511   
1511
15121512   // ROM & NVRAM access
15131513   return state->m_slotcart->m_cart->read_h(space, offset);
1514}   
1514}
15151515
15161516static WRITE8_HANDLER( snes20_hi_w )
15171517{
r21591r21592
15241524      if (address >= 0x2000 && address < 0x6000)
15251525         snes_w_io(space, address, data);
15261526   }
1527   else if (offset >= 0x700000)   // NVRAM access
1527   else if (offset >= 0x700000)    // NVRAM access
15281528   {
15291529      state->m_slotcart->m_cart->write_h(space, offset, data);
15301530   }
1531}   
1531}
15321532
15331533static READ8_HANDLER( snes20_lo_r )
15341534{
15351535   snsnew_state *state = space.machine().driver_data<snsnew_state>();
15361536   UINT16 address = offset & 0xffff;
1537   
1537
15381538   if (offset < 0x400000)
15391539   {
15401540      if (address < 0x2000)
r21591r21592
15431543         return snes_r_io(space, address);
15441544      if (address >= 0x6000 && address < 0x8000)
15451545         return snes_open_bus_r(space, 0);
1546      if (address >= 0x8000)         
1546      if (address >= 0x8000)
15471547         return state->m_slotcart->m_cart->read_l(space, offset);
15481548   }
15491549   else if (offset < 0x700000)
r21591r21592
15531553      else
15541554         return state->m_slotcart->m_cart->read_l(space, offset);
15551555   }
1556   
1556
15571557   // ROM & NVRAM access
15581558   return state->m_slotcart->m_cart->read_l(space, offset);
1559}   
1559}
15601560
15611561static WRITE8_HANDLER( snes20_lo_w )
15621562{
15631563   snes20_hi_w(space, offset, data, 0xff);
1564}   
1564}
15651565
15661566
15671567// HiROM
r21591r21592
15701570{
15711571   snsnew_state *state = space.machine().driver_data<snsnew_state>();
15721572   UINT16 address = offset & 0xffff;
1573   
1573
15741574   if (offset < 0x400000)
15751575   {
15761576      if (address < 0x2000)
r21591r21592
15901590      if (address >= 0x8000)
15911591         return state->m_slotcart->m_cart->read_l(space, offset);
15921592   }
1593   
1593
15941594   // ROM & NVRAM access
15951595   return state->m_slotcart->m_cart->read_l(space, offset);
1596}   
1596}
15971597
15981598static WRITE8_HANDLER( snes21_lo_w )
15991599{
r21591r21592
16151615         }
16161616      }
16171617   }
1618   else if (offset >= 0x700000)   // NVRAM access
1618   else if (offset >= 0x700000)    // NVRAM access
16191619      state->m_slotcart->m_cart->write_l(space, offset, data);
1620}   
1620}
16211621
16221622static READ8_HANDLER( snes21_hi_r )
16231623{
16241624   snsnew_state *state = space.machine().driver_data<snsnew_state>();
16251625   UINT16 address = offset & 0xffff;
1626   
1626
16271627   if (offset < 0x400000)
16281628   {
16291629      if (address < 0x2000)
r21591r21592
16431643      if (address >= 0x8000)
16441644         return state->m_slotcart->m_cart->read_h(space, offset);
16451645   }
1646   
1646
16471647   // ROM & NVRAM access
16481648   return state->m_slotcart->m_cart->read_h(space, offset);
1649}   
1649}
16501650
16511651static WRITE8_HANDLER( snes21_hi_w )
16521652{
r21591r21592
16681668         }
16691669      }
16701670   }
1671   else if (offset >= 0x700000)   // NVRAM access
1671   else if (offset >= 0x700000)    // NVRAM access
16721672      state->m_slotcart->m_cart->write_h(space, offset, data);
1673}   
1673}
16741674
16751675// SuperFX / GSU
16761676
r21591r21592
16781678{
16791679   snsnew_state *state = space.machine().driver_data<snsnew_state>();
16801680   UINT16 address = offset & 0xffff;
1681   
1681
16821682   if (offset < 0x400000)
16831683   {
16841684      if (address < 0x2000)
r21591r21592
16921692      }
16931693      if (address >= 0x6000 && address < 0x8000)
16941694      {
1695         return state->m_slotcart->m_cart->read_h(space, offset);   //RAM
1695         return state->m_slotcart->m_cart->read_h(space, offset);    //RAM
16961696      }
16971697      if (address >= 0x8000)
1698         return state->m_slotcart->m_cart->read_h(space, offset);   //ROM
1698         return state->m_slotcart->m_cart->read_h(space, offset);    //ROM
16991699   }
17001700   else if (offset < 0x600000)
1701      return state->m_slotcart->m_cart->read_h(space, offset);   //ROM
1702   
1703   return state->m_slotcart->m_cart->read_h(space, offset);   //RAM
1704}   
1701      return state->m_slotcart->m_cart->read_h(space, offset);    //ROM
17051702
1703   return state->m_slotcart->m_cart->read_h(space, offset);    //RAM
1704}
1705
17061706static READ8_HANDLER( snesfx_lo_r )
17071707{
17081708   snsnew_state *state = space.machine().driver_data<snsnew_state>();
17091709   UINT16 address = offset & 0xffff;
1710   
1710
17111711   if (offset < 0x400000)
17121712   {
17131713      if (address < 0x2000)
r21591r21592
17211721      }
17221722      if (address >= 0x6000 && address < 0x8000)
17231723      {
1724         return state->m_slotcart->m_cart->read_l(space, offset);   //RAM
1724         return state->m_slotcart->m_cart->read_l(space, offset);    //RAM
17251725      }
17261726      if (address >= 0x8000)
1727         return state->m_slotcart->m_cart->read_l(space, offset);   //ROM
1727         return state->m_slotcart->m_cart->read_l(space, offset);    //ROM
17281728   }
17291729   else if (offset < 0x600000)
1730      return state->m_slotcart->m_cart->read_l(space, offset);   //ROM
1731   
1732   return state->m_slotcart->m_cart->read_l(space, offset);   //RAM
1733}   
1730      return state->m_slotcart->m_cart->read_l(space, offset);    //ROM
17341731
1732   return state->m_slotcart->m_cart->read_l(space, offset);    //RAM
1733}
1734
17351735static WRITE8_HANDLER( snesfx_hi_w )
17361736{
17371737   snsnew_state *state = space.machine().driver_data<snsnew_state>();
r21591r21592
17521752   }
17531753   else
17541754      state->m_slotcart->m_cart->write_h(space, offset, data);
1755}   
1755}
17561756
17571757static WRITE8_HANDLER( snesfx_lo_w )
17581758{
r21591r21592
17741774   }
17751775   else
17761776      state->m_slotcart->m_cart->write_l(space, offset, data);
1777}   
1777}
17781778
17791779// SPC-7110
17801780
r21591r21592
17821782{
17831783   snsnew_state *state = space.machine().driver_data<snsnew_state>();
17841784   UINT16 address = offset & 0xffff;
1785   
1785
17861786   if (offset < 0x400000)
17871787   {
17881788      if (address < 0x2000)
r21591r21592
17921792         UINT16 limit = (state->m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840;
17931793         if (address >= 0x4800 && address < limit)
17941794            return state->m_slotcart->m_cart->chip_read(space, address);
1795         
1795
17961796         return snes_r_io(space, address);
17971797      }
17981798      if (address >= 0x6000 && address < 0x8000)
r21591r21592
18061806         return state->m_slotcart->m_cart->read_h(space, offset);
18071807   }
18081808   return state->m_slotcart->m_cart->read_h(space, offset);
1809}   
1809}
18101810
18111811static READ8_HANDLER( snespc7110_lo_r )
18121812{
18131813   snsnew_state *state = space.machine().driver_data<snsnew_state>();
18141814   UINT16 address = offset & 0xffff;
1815   
1815
18161816   if (offset < 0x400000)
18171817   {
18181818      if (address < 0x2000)
r21591r21592
18221822         UINT16 limit = (state->m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840;
18231823         if (address >= 0x4800 && address < limit)
18241824            return state->m_slotcart->m_cart->chip_read(space, address);
1825         
1825
18261826         return snes_r_io(space, address);
18271827      }
18281828      if (address >= 0x6000 && address < 0x8000)
r21591r21592
18391839      return state->m_slotcart->m_cart->chip_read(space, 0x4800);
18401840
18411841   return snes_open_bus_r(space, 0);
1842}   
1842}
18431843
18441844static WRITE8_HANDLER( snespc7110_hi_w )
18451845{
r21591r21592
18671867            state->m_slotcart->m_cart->write_l(space, offset, data);
18681868      }
18691869   }
1870}   
1870}
18711871
18721872static WRITE8_HANDLER( snespc7110_lo_w )
18731873{
r21591r21592
18951895            state->m_slotcart->m_cart->write_l(space, offset, data);
18961896      }
18971897   }
1898}   
1898}
18991899
19001900
19011901// S-DD1
r21591r21592
19041904{
19051905   snsnew_state *state = space.machine().driver_data<snsnew_state>();
19061906   UINT16 address = offset & 0xffff;
1907   
1907
19081908   if (offset < 0x400000)
19091909   {
19101910      if (address < 0x2000)
r21591r21592
19131913      {
19141914         if (address >= 0x4800 && address < 0x4808)
19151915            return state->m_slotcart->m_cart->chip_read(space, address);
1916         
1916
19171917         return snes_r_io(space, address);
19181918      }
19191919      if (address >= 0x6000 && address < 0x8000)
r21591r21592
19211921      if (address >= 0x8000)
19221922         return state->m_slotcart->m_cart->read_l(space, offset);
19231923   }
1924   
1924
19251925   // ROM & NVRAM access
19261926   return state->m_slotcart->m_cart->read_l(space, offset);
1927}   
1927}
19281928
19291929static WRITE8_HANDLER( snesdd1_lo_w )
19301930{
r21591r21592
19511951   }
19521952   if (offset >= 0x700000 && address < 0x8000 && state->m_slotcart->m_cart->get_nvram_size())
19531953      return state->m_slotcart->m_cart->write_l(space, offset, data);
1954}   
1954}
19551955
19561956static READ8_HANDLER( snesdd1_hi_r )
19571957{
19581958   snsnew_state *state = space.machine().driver_data<snsnew_state>();
1959   
1959
19601960   if (offset >= 0x400000)
19611961      return state->m_slotcart->m_cart->read_h(space, offset);
1962   else     
1962   else
19631963      return snesdd1_lo_r(space, offset, 0xff);
1964}   
1964}
19651965
19661966static WRITE8_HANDLER( snesdd1_hi_w )
19671967{
19681968   snesdd1_lo_w(space, offset, data, 0xff);
1969}   
1969}
19701970
19711971
19721972// BS-X
r21591r21592
19751975{
19761976   snsnew_state *state = space.machine().driver_data<snsnew_state>();
19771977   UINT16 address = offset & 0xffff;
1978   
1978
19791979   if (offset < 0x400000)
19801980   {
19811981      if (address < 0x2000)
r21591r21592
19901990      }
19911991      if (address >= 0x6000 && address < 0x8000)
19921992      {
1993         if (offset >= 0x200000)         
1993         if (offset >= 0x200000)
19941994            return state->m_slotcart->m_cart->read_l(space, offset);
19951995         else
19961996            return snes_open_bus_r(space, 0);
19971997      }
1998      if (address >= 0x8000)         
1998      if (address >= 0x8000)
19991999         return state->m_slotcart->m_cart->read_l(space, offset);
20002000   }
20012001   return state->m_slotcart->m_cart->read_l(space, offset);
2002}   
2002}
20032003
20042004static WRITE8_HANDLER( snesbsx_hi_w )
20052005{
r21591r21592
20252025      }
20262026      if (address >= 0x6000 && address < 0x8000)
20272027      {
2028         if (offset >= 0x200000)         
2028         if (offset >= 0x200000)
20292029            return state->m_slotcart->m_cart->write_l(space, offset, data);
20302030      }
2031      if (address >= 0x8000)         
2031      if (address >= 0x8000)
20322032         return state->m_slotcart->m_cart->write_l(space, offset, data);
20332033   }
20342034   return state->m_slotcart->m_cart->write_l(space, offset, data);
2035}   
2035}
20362036
20372037static READ8_HANDLER( snesbsx_lo_r )
20382038{
20392039   return snesbsx_hi_r(space, offset, 0xff);
2040}   
2040}
20412041
20422042static WRITE8_HANDLER( snesbsx_lo_w )
20432043{
20442044   snesbsx_hi_w(space, offset, data, 0xff);
2045}   
2045}
20462046
20472047
20482048static READ8_HANDLER( snesnew_lo_r )
r21591r21592
20502050   snsnew_state *state = space.machine().driver_data<snsnew_state>();
20512051
20522052   // take care of add-on IO
2053   if (state->m_slotcart->get_type() == SNES_DSP
2053   if (state->m_slotcart->get_type() == SNES_DSP
20542054      && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
20552055      return state->m_slotcart->m_cart->chip_read(space, offset & 0x7fff);
2056   else if (state->m_slotcart->get_type() == SNES_DSP_MODE21
2057          && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
2056   else if (state->m_slotcart->get_type() == SNES_DSP_MODE21
2057            && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
20582058      return state->m_slotcart->m_cart->chip_read(space, offset & 0x1fff);
2059   else if (state->m_slotcart->get_type() == SNES_DSP4
2060          && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
2059   else if (state->m_slotcart->get_type() == SNES_DSP4
2060            && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
20612061      return state->m_slotcart->m_cart->chip_read(space, offset & 0x7fff);
2062   else if (state->m_slotcart->get_type() == SNES_OBC1
2063          && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
2062   else if (state->m_slotcart->get_type() == SNES_OBC1
2063            && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
20642064      return state->m_slotcart->m_cart->chip_read(space, offset);
2065   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2066          && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000))
2065   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2066            && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000))
20672067      return state->m_slotcart->m_cart->chip_read(space, offset);
20682068   else if (state->m_slotcart->get_type() == SNES_SRTC
2069          && (offset < 0x400000 && (offset & 0xffff) == 0x2800))
2069            && (offset < 0x400000 && (offset & 0xffff) == 0x2800))
20702070         return state->m_slotcart->m_cart->chip_read(space, offset & 0xffff);
20712071   else
20722072   {
r21591r21592
20842084         case SNES_POKEMON:
20852085         case SNES_BANANA:
20862086            return snes20_lo_r(space, offset, 0xff);
2087           
2087
20882088         case SNES_MODE21:
20892089         case SNES_DSP_MODE21:
20902090         case SNES_SRTC:
20912091         case SNES_BSXHI:
20922092            return snes21_lo_r(space, offset, 0xff);
2093           
2093
20942094         case SNES_SFX:
20952095            return snesfx_lo_r(space, offset, 0xff);
2096           
2096
20972097         case SNES_SPC7110:
20982098         case SNES_SPC7110_RTC:
20992099            return snespc7110_lo_r(space, offset, 0xff);
2100           
2100
21012101         case SNES_SDD1:
21022102            return snesdd1_lo_r(space, offset, 0xff);
2103           
2103
21042104         case SNES_BSX:
21052105            return snesbsx_lo_r(space, offset, 0xff);
21062106      }
21072107   }
21082108   return snes_open_bus_r(space, 0);
2109}   
2109}
21102110
21112111static READ8_HANDLER( snesnew_hi_r )
21122112{
21132113   snsnew_state *state = space.machine().driver_data<snsnew_state>();
2114   
2114
21152115   // take care of add-on IO
21162116   if (state->m_slotcart->get_type() == SNES_DSP
21172117      && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
21182118      return state->m_slotcart->m_cart->chip_read(space, offset & 0x7fff);
2119   else if (state->m_slotcart->get_type() == SNES_DSP_MODE21
2120          && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
2119   else if (state->m_slotcart->get_type() == SNES_DSP_MODE21
2120            && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
21212121      return state->m_slotcart->m_cart->chip_read(space, offset & 0x1fff);
2122   else if (state->m_slotcart->get_type() == SNES_DSP4
2123          && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
2122   else if (state->m_slotcart->get_type() == SNES_DSP4
2123            && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
21242124      return state->m_slotcart->m_cart->chip_read(space, offset & 0x7fff);
2125   else if (state->m_slotcart->get_type() == SNES_OBC1
2126          && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
2125   else if (state->m_slotcart->get_type() == SNES_OBC1
2126            && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
21272127      return state->m_slotcart->m_cart->chip_read(space, offset);
2128   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2129          && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000))
2128   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2129            && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000))
21302130      return state->m_slotcart->m_cart->chip_read(space, offset);
2131   else if (state->m_slotcart->get_type() == SNES_SRTC
2132          && (offset < 0x400000 && (offset & 0xffff) == 0x2800))
2131   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2132          && (offset == 0x600000 || offset == 0x600001))
2133      return state->m_slotcart->m_cart->chip_read(space, offset);
2134   else if (state->m_slotcart->get_type() == SNES_SRTC
2135            && (offset < 0x400000 && (offset & 0xffff) == 0x2800))
21332136         return state->m_slotcart->m_cart->chip_read(space, offset & 0xffff);
21342137   else if ((state->m_slotcart->get_type() == SNES_POKEMON || state->m_slotcart->get_type() == SNES_BANANA)
2135          && (offset & 0x70000) == 0x0000)
2138            && (offset & 0x70000) == 0x0000)
21362139   {
2137//      printf("hi read %x\n", offset);
2140//      printf("hi read %x\n", offset);
21382141      return state->m_slotcart->m_cart->chip_read(space, offset);
21392142   }
21402143   else
r21591r21592
21532156         case SNES_POKEMON:
21542157         case SNES_BANANA:
21552158            return snes20_hi_r(space, offset, 0xff);
2156           
2159
21572160         case SNES_MODE21:
21582161         case SNES_DSP_MODE21:
21592162         case SNES_SRTC:
21602163         case SNES_BSXHI:
21612164            return snes21_hi_r(space, offset, 0xff);
2162           
2165
21632166         case SNES_SFX:
21642167            return snesfx_hi_r(space, offset, 0xff);
2165           
2168
21662169         case SNES_SPC7110:
21672170         case SNES_SPC7110_RTC:
21682171            return snespc7110_hi_r(space, offset, 0xff);
2169           
2172
21702173         case SNES_SDD1:
21712174            return snesdd1_hi_r(space, offset, 0xff);
2172           
2175
21732176         case SNES_BSX:
21742177            return snesbsx_hi_r(space, offset, 0xff);
21752178      }
21762179   }
21772180   return snes_open_bus_r(space, 0);
2178}   
2181}
21792182
21802183static WRITE8_HANDLER( snesnew_lo_w )
21812184{
21822185   snsnew_state *state = space.machine().driver_data<snsnew_state>();
2183   
2186
21842187   // take care of add-on IO
21852188   if (state->m_slotcart->get_type() == SNES_DSP
21862189      && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
21872190      state->m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data);
2188   else if (state->m_slotcart->get_type() == SNES_DSP_MODE21
2189          && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
2191   else if (state->m_slotcart->get_type() == SNES_DSP_MODE21
2192            && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
21902193      state->m_slotcart->m_cart->chip_write(space, offset & 0x1fff, data);
2191   else if (state->m_slotcart->get_type() == SNES_DSP4
2192          && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
2194   else if (state->m_slotcart->get_type() == SNES_DSP4
2195            && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
21932196      state->m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data);
2194   else if (state->m_slotcart->get_type() == SNES_OBC1
2195          && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
2197   else if (state->m_slotcart->get_type() == SNES_OBC1
2198            && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
21962199      state->m_slotcart->m_cart->chip_write(space, offset, data);
2197   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2198          && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000))
2200   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2201            && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000))
21992202      state->m_slotcart->m_cart->chip_write(space, offset, data);
2203   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2204          && (offset == 0x600000 || offset == 0x600001))
2205      state->m_slotcart->m_cart->chip_write(space, offset, data);
22002206   else if (state->m_slotcart->get_type() == SNES_SRTC
2201          && (offset < 0x400000 && (offset & 0xffff) == 0x2801))
2207            && (offset < 0x400000 && (offset & 0xffff) == 0x2801))
22022208      state->m_slotcart->m_cart->chip_write(space, offset & 0xffff, data);
22032209   else if (state->m_slotcart->get_type() == SNES_BANANA
2204          && (offset & 0x78000) == 0x8000)
2205   {   
2206//      printf("lo write %x\n", offset);
2210            && (offset & 0x78000) == 0x8000)
2211   {
2212//      printf("lo write %x\n", offset);
22072213      state->m_slotcart->m_cart->chip_write(space, offset, data);
22082214   }
22092215   else
r21591r21592
22232229         case SNES_BANANA:
22242230            snes20_lo_w(space, offset, data, 0xff);
22252231            break;
2226           
2232
22272233         case SNES_MODE21:
22282234         case SNES_DSP_MODE21:
22292235         case SNES_SRTC:
22302236         case SNES_BSXHI:
22312237            snes21_lo_w(space, offset, data, 0xff);
22322238            break;
2233           
2239
22342240         case SNES_SFX:
22352241            snesfx_lo_w(space, offset, data, 0xff);
22362242            break;
2237           
2243
22382244         case SNES_SPC7110:
22392245         case SNES_SPC7110_RTC:
22402246            snespc7110_lo_w(space, offset, data, 0xff);
22412247            break;
2242           
2248
22432249         case SNES_SDD1:
22442250            snesdd1_lo_w(space, offset, data, 0xff);
22452251            break;
2246           
2252
22472253         case SNES_BSX:
22482254            snesbsx_lo_w(space, offset, data, 0xff);
22492255            break;
22502256      }
22512257   }
2252}   
2258}
22532259
22542260static WRITE8_HANDLER( snesnew_hi_w )
22552261{
22562262   snsnew_state *state = space.machine().driver_data<snsnew_state>();
2257   
2263
22582264   // take care of add-on IO
22592265   if (state->m_slotcart->get_type() == SNES_DSP
22602266      && (offset >= 0x200000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
22612267      state->m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data);
2262   else if (state->m_slotcart->get_type() == SNES_DSP_MODE21
2263          && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
2268   else if (state->m_slotcart->get_type() == SNES_DSP_MODE21
2269            && (offset < 0x200000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
22642270      state->m_slotcart->m_cart->chip_write(space, offset & 0x1fff, data);
2265   else if (state->m_slotcart->get_type() == SNES_DSP4
2266          && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
2271   else if (state->m_slotcart->get_type() == SNES_DSP4
2272            && (offset >= 0x300000 && offset < 0x400000 && (offset & 0x8000) == 0x8000))
22672273      state->m_slotcart->m_cart->chip_write(space, offset & 0x7fff, data);
2268   else if (state->m_slotcart->get_type() == SNES_OBC1
2269          && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
2274   else if (state->m_slotcart->get_type() == SNES_OBC1
2275            && (offset < 0x400000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000))
22702276      return state->m_slotcart->m_cart->chip_write(space, offset, data);
2271   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2272          && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000))
2277   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2278            && (offset >= 0x680000 && offset < 0x700000 && (offset & 0xffff) < 0x1000))
22732279      state->m_slotcart->m_cart->chip_write(space, offset, data);
2280   else if ((state->m_slotcart->get_type() == SNES_ST010 || state->m_slotcart->get_type() == SNES_ST011)
2281          && (offset == 0x600000 || offset == 0x600001))
2282      state->m_slotcart->m_cart->chip_write(space, offset, data);
22742283   else if (state->m_slotcart->get_type() == SNES_SRTC
2275          && (offset < 0x400000 && (offset & 0xffff) == 0x2801))
2284            && (offset < 0x400000 && (offset & 0xffff) == 0x2801))
22762285      state->m_slotcart->m_cart->chip_write(space, offset & 0xffff, data);
22772286   else if ((state->m_slotcart->get_type() == SNES_POKEMON)
2278          && (offset & 0x70000) == 0x0000)
2279   {   
2280//      printf("hi write %x\n", offset);
2287            && (offset & 0x70000) == 0x0000)
2288   {
2289//      printf("hi write %x\n", offset);
22812290      state->m_slotcart->m_cart->chip_write(space, offset, data);
22822291   }
22832292   else
r21591r21592
22972306         case SNES_BANANA:
22982307            snes20_hi_w(space, offset, data, 0xff);
22992308            break;
2300           
2309
23012310         case SNES_MODE21:
23022311         case SNES_DSP_MODE21:
23032312         case SNES_SRTC:
23042313         case SNES_BSXHI:
23052314            snes21_hi_w(space, offset, data, 0xff);
23062315            break;
2307           
2316
23082317         case SNES_SFX:
23092318            snesfx_hi_w(space, offset, data, 0xff);
23102319            break;
2311           
2320
23122321         case SNES_SPC7110:
23132322         case SNES_SPC7110_RTC:
23142323            snespc7110_hi_w(space, offset, data, 0xff);
23152324            break;
2316           
2325
23172326         case SNES_SDD1:
23182327            snesdd1_hi_w(space, offset, data, 0xff);
23192328            break;
2320           
2329
23212330         case SNES_BSX:
23222331            snesbsx_hi_w(space, offset, data, 0xff);
23232332            break;
23242333      }
23252334   }
2326}   
2335}
23272336
23282337
23292338static ADDRESS_MAP_START( snesnew_map, AS_PROGRAM, 8, snsnew_state )
r21591r21592
23342343
23352344static SLOT_INTERFACE_START(snes_cart)
23362345   SLOT_INTERFACE_INTERNAL("lorom",         SNS_LOROM)
2337   SLOT_INTERFACE_INTERNAL("lorom_bsx",     SNS_LOROM_BSX)   // LoROM + BS-X slot - unsupported
2338   SLOT_INTERFACE_INTERNAL("lorom_cx4",     SNS_LOROM)   // Cart + CX4 - unsupported
2346   SLOT_INTERFACE_INTERNAL("lorom_bsx",     SNS_LOROM_BSX) // LoROM + BS-X slot - unsupported
2347   SLOT_INTERFACE_INTERNAL("lorom_cx4",     SNS_LOROM) // Cart + CX4 - unsupported
23392348   SLOT_INTERFACE_INTERNAL("lorom_dsp",     SNS_LOROM_NECDSP)
23402349   SLOT_INTERFACE_INTERNAL("lorom_dsp4",    SNS_LOROM_NECDSP)
23412350   SLOT_INTERFACE_INTERNAL("lorom_obc1",    SNS_LOROM_OBC1)
2342   SLOT_INTERFACE_INTERNAL("lorom_sa1",     SNS_LOROM)   // Cart + SA1 - unsupported
2351   SLOT_INTERFACE_INTERNAL("lorom_sa1",     SNS_LOROM) // Cart + SA1 - unsupported
23432352   SLOT_INTERFACE_INTERNAL("lorom_sdd1",    SNS_LOROM_SDD1)
23442353   SLOT_INTERFACE_INTERNAL("lorom_sfx",     SNS_LOROM_SUPERFX)
2345   SLOT_INTERFACE_INTERNAL("lorom_sgb",     SNS_LOROM)   // SuperGB base cart - unsupported
2354   SLOT_INTERFACE_INTERNAL("lorom_sgb",     SNS_LOROM) // SuperGB base cart - unsupported
23462355   SLOT_INTERFACE_INTERNAL("lorom_st010",   SNS_LOROM_SETA10)
23472356   SLOT_INTERFACE_INTERNAL("lorom_st011",   SNS_LOROM_SETA11)
2348   SLOT_INTERFACE_INTERNAL("lorom_st018",   SNS_LOROM)   // Cart + ST018 - unsupported
2349   SLOT_INTERFACE_INTERNAL("lorom_sufami",  SNS_LOROM_SUFAMI)   // Sufami Turbo base cart
2357   SLOT_INTERFACE_INTERNAL("lorom_st018",   SNS_LOROM) // Cart + ST018 - unsupported
2358   SLOT_INTERFACE_INTERNAL("lorom_sufami",  SNS_LOROM_SUFAMI)  // Sufami Turbo base cart
23502359   SLOT_INTERFACE_INTERNAL("hirom",         SNS_HIROM)
2351   SLOT_INTERFACE_INTERNAL("hirom_bsx",     SNS_HIROM_BSX)   // HiROM + BS-X slot - unsupported
2360   SLOT_INTERFACE_INTERNAL("hirom_bsx",     SNS_HIROM_BSX) // HiROM + BS-X slot - unsupported
23522361   SLOT_INTERFACE_INTERNAL("hirom_dsp",     SNS_HIROM_NECDSP)
23532362   SLOT_INTERFACE_INTERNAL("hirom_spc7110", SNS_HIROM_SPC7110)
23542363   SLOT_INTERFACE_INTERNAL("hirom_spcrtc",  SNS_HIROM_SPC7110_RTC)
23552364   SLOT_INTERFACE_INTERNAL("hirom_srtc",    SNS_HIROM_SRTC)
2356   SLOT_INTERFACE_INTERNAL("bsxrom",        SNS_ROM_BSX)   // BS-X base cart - partial support only
2365   SLOT_INTERFACE_INTERNAL("bsxrom",        SNS_ROM_BSX)   // BS-X base cart - partial support only
23572366   // pirate carts
23582367   SLOT_INTERFACE_INTERNAL("lorom_poke",    SNS_LOROM_POKEMON)
23592368SLOT_INTERFACE_END
r21591r21592
23652374
23662375   state->m_type = state->m_slotcart->get_type();
23672376
2368   MACHINE_START_CALL(snes);
2377   MACHINE_START_CALL(snes_mess);
23692378
2370   // FIXME: why installing handlers here does not work? it would allow to clean up handlers above...
2379   // in progress...
23712380   switch (state->m_type)
23722381   {
23732382      case SNES_MODE21:
2374      case SNES_MODE25:
2375      case SNES_DSP_MODE21:
23762383         machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x000000, 0x7dffff, FUNC(snes21_lo_r), FUNC(snes21_lo_w));
23772384         machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x800000, 0xffffff, FUNC(snes21_hi_r), FUNC(snes21_hi_w));
23782385         set_5a22_map(*state->m_maincpu);
23792386         break;
2387      case SNES_DSP_MODE21:
2388//         machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x000000, 0x7dffff, FUNC(snes21_lo_r), FUNC(snes21_lo_w));
2389//         machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x800000, 0xffffff, FUNC(snes21_hi_r), FUNC(snes21_hi_w));
2390//         machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x006000, 0x007fff, 0x1f0000, 0, read8_delegate(FUNC(device_sns_cart_interface::chip_read),state->m_slotcart->m_cart));
2391//         machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x006000, 0x007fff, 0x1f0000, 0, write8_delegate(FUNC(device_sns_cart_interface::chip_write),state->m_slotcart->m_cart));
2392//         set_5a22_map(*state->m_maincpu);
2393         break;
2394      case SNES_SRTC:
2395//         machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x000000, 0x7dffff, FUNC(snes21_lo_r), FUNC(snes21_lo_w));
2396//         machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x800000, 0xffffff, FUNC(snes21_hi_r), FUNC(snes21_hi_w));
2397//         machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x002800, 0x002800, 0x3f0000, 0, read8_delegate(FUNC(device_sns_cart_interface::chip_read),state->m_slotcart->m_cart));
2398//         machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x002801, 0x002801, 0x3f0000, 0, write8_delegate(FUNC(device_sns_cart_interface::chip_write),state->m_slotcart->m_cart));
2399//         set_5a22_map(*state->m_maincpu);
2400         break;
23802401   }
23812402}
23822403
trunk/src/mess/machine/sns_upd.c
r21591r21592
11/***********************************************************************************************************
2
2
33 UPD7725 / UPD96050 add-on chip emulation (for SNES/SFC)
44 used in carts with DSP-1, DSP-1A, DSP-1B, DSP-2, DSP-3, DSP-4, ST-010 & ST-011 add-on chips
5
5
66 Copyright MESS Team.
77 Visit http://mamedev.org for licensing and usage restrictions.
8
8
99 ***********************************************************************************************************/
1010
1111
r21591r21592
2424
2525sns_rom20_necdsp_device::sns_rom20_necdsp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2626               : sns_rom_device(mconfig, SNS_LOROM_NECDSP, "SNES Cart (LoROM) + NEC DSP", tag, owner, clock),
27                 m_upd7725(*this, "dsp")
27                  m_upd7725(*this, "dsp")
2828{
2929}
3030
3131sns_rom21_necdsp_device::sns_rom21_necdsp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3232               : sns_rom21_device(mconfig, SNS_HIROM_NECDSP, "SNES Cart (HiROM) + NEC DSP", tag, owner, clock),
33                 m_upd7725(*this, "dsp")
33                  m_upd7725(*this, "dsp")
3434{
3535}
3636
3737sns_rom_setadsp_device::sns_rom_setadsp_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
3838               : sns_rom_device(mconfig, type, name, tag, owner, clock),
39                 m_upd96050(*this, "dsp")
39                  m_upd96050(*this, "dsp")
4040{
4141}
4242
r21591r21592
223223      else
224224         return temp & 0xff;
225225   }
226   if (offset == 0x600000 || offset == 0x600001)
227      return (offset & 1) ? m_upd96050->snesdsp_read(FALSE) : m_upd96050->snesdsp_read(TRUE);
228
226229   return 0xff;
227230}
228231
r21591r21592
233236   {
234237      UINT16 address = offset & 0xffff;
235238      UINT16 temp = m_upd96050->dataram_r(address/2);
236     
239
237240      if (offset & 1)
238241      {
239242         temp &= 0xff;
r21591r21592
244247         temp &= 0xff00;
245248         temp |= data;
246249      }
247     
250
248251      m_upd96050->dataram_w(address/2, temp);
249252      return;
250253   }
254   if (offset == 0x600000)
255      m_upd96050->snesdsp_write(TRUE, data);
256   if (offset == 0x600001)
257      m_upd96050->snesdsp_write(FALSE, data);
251258}
252259
253260
r21591r21592
316323{
317324   return MACHINE_CONFIG_NAME( snes_st011 );
318325}
319
trunk/src/mess/machine/sns_upd.h
r21591r21592
1313public:
1414   // construction/destruction
1515   sns_rom20_necdsp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
16   
16
1717   // device-level overrides
1818   virtual void device_start();
1919   virtual void device_config_complete() { m_shortname = "sns_rom_necdsp"; }
2020   virtual machine_config_constructor device_mconfig_additions() const;
21   
21
2222   required_device<upd7725_device> m_upd7725;
23   
23
2424   // additional reading and writing
2525   virtual DECLARE_READ8_MEMBER(chip_read);
2626   virtual DECLARE_WRITE8_MEMBER(chip_write);
27   
27
2828   virtual DECLARE_READ32_MEMBER(necdsp_prg_r);
2929   virtual DECLARE_READ16_MEMBER(necdsp_data_r);
3030};
r21591r21592
3636public:
3737   // construction/destruction
3838   sns_rom21_necdsp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
39   
39
4040   // device-level overrides
4141   virtual void device_start();
4242   virtual void device_config_complete() { m_shortname = "sns_rom21_necdsp"; }
4343   virtual machine_config_constructor device_mconfig_additions() const;
44   
44
4545   required_device<upd7725_device> m_upd7725;
46   
46
4747   // additional reading and writing
4848   virtual DECLARE_READ8_MEMBER(chip_read);
4949   virtual DECLARE_WRITE8_MEMBER(chip_write);
50   
50
5151   virtual DECLARE_READ32_MEMBER(necdsp_prg_r);
5252   virtual DECLARE_READ16_MEMBER(necdsp_data_r);
5353};
r21591r21592
5959public:
6060   // construction/destruction
6161   sns_rom_setadsp_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
62   
62
6363   // device-level overrides
6464   virtual void device_start();
6565   virtual void device_config_complete() { m_shortname = "sns_rom_setadsp"; }
66   
66
6767   required_device<upd96050_device> m_upd96050;
68   
68
6969   // additional reading and writing
7070   virtual DECLARE_READ8_MEMBER(chip_read);
7171   virtual DECLARE_WRITE8_MEMBER(chip_write);
72   
72
7373   virtual DECLARE_READ32_MEMBER(setadsp_prg_r);
7474   virtual DECLARE_READ16_MEMBER(setadsp_data_r);
7575};
r21591r21592
8181public:
8282   // construction/destruction
8383   sns_rom_seta10dsp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
84   
84
8585   // device-level overrides
8686   virtual void device_config_complete() { m_shortname = "sns_rom_seta10"; }
8787   virtual machine_config_constructor device_mconfig_additions() const;
r21591r21592
9494public:
9595   // construction/destruction
9696   sns_rom_seta11dsp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
97   
97
9898   // device-level overrides
9999   virtual void device_config_complete() { m_shortname = "sns_rom_seta11"; }
100100   virtual machine_config_constructor device_mconfig_additions() const;
trunk/src/mess/machine/sns_sfx.c
r21591r21592
11/***********************************************************************************************************
2
2
33 SuperFX add-on chip emulation (for SNES/SFC)
4
4
55 Copyright MESS Team.
66 Visit http://mamedev.org for licensing and usage restrictions.
7
7
88 ***********************************************************************************************************/
99
1010
r21591r21592
110110READ8_MEMBER( sns_rom_superfx_device::read_l )
111111{
112112   UINT16 address = offset & 0xffff;
113   
113
114114   if (offset < 0x400000)
115115   {
116116      if (address >= 0x6000 && address < 0x8000)
117117      {
118118         if (superfx_access_ram(m_superfx))
119            return    sfx_ram[offset & 0x1fff];
119            return sfx_ram[offset & 0x1fff];
120120      }
121121      if (address >= 0x8000)
122122         return m_rom[rom_bank_map[offset / 0x10000] * 0x8000 + (offset & 0x7fff)];
r21591r21592
139139   else
140140   {
141141      if (superfx_access_ram(m_superfx))
142         return    sfx_ram[offset & 0xfffff];
142         return sfx_ram[offset & 0xfffff];
143143   }
144   
145   return 0xff;   // should be open bus...
144
145   return 0xff;    // should be open bus...
146146}
147147
148148
r21591r21592
167167READ8_MEMBER(sns_rom_superfx_device::read_h)
168168{
169169   UINT16 address = offset & 0xffff;
170   
170
171171   if (offset < 0x400000)
172172   {
173173      if (address >= 0x6000 && address < 0x8000)
174174      {
175175         if (superfx_access_ram(m_superfx))
176            return    sfx_ram[offset & 0x1fff];
176            return sfx_ram[offset & 0x1fff];
177177      }
178178      if (address >= 0x8000)
179179         return m_rom[rom_bank_map[offset / 0x10000] * 0x8000 + (offset & 0x7fff)];
r21591r21592
196196   else
197197   {
198198      if (superfx_access_ram(m_superfx))
199         return    sfx_ram[offset & 0xfffff];
199         return sfx_ram[offset & 0xfffff];
200200   }
201   
202   return 0xff;   // should be open bus...
201
202   return 0xff;    // should be open bus...
203203}
204204
205205WRITE8_MEMBER( sns_rom_superfx_device::write_h )
r21591r21592
219219         sfx_ram[offset & 0xfffff] = data;
220220   }
221221}
222
trunk/src/mess/machine/sns_sfx.h
r21591r21592
1313public:
1414   // construction/destruction
1515   sns_rom_superfx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
16   
16
1717   // device-level overrides
1818   virtual void device_start();
1919   virtual void device_config_complete() { m_shortname = "sns_rom_superfx"; }
2020   virtual machine_config_constructor device_mconfig_additions() const;
21   
21
2222   required_device<device_t> m_superfx;
23   
23
2424   // additional reading and writing
2525   virtual DECLARE_READ8_MEMBER(read_l);
2626   virtual DECLARE_WRITE8_MEMBER(write_l);
r21591r21592
2828   virtual DECLARE_WRITE8_MEMBER(write_h);
2929   virtual DECLARE_READ8_MEMBER(chip_read);
3030   virtual DECLARE_WRITE8_MEMBER(chip_write);
31   
31
3232   virtual DECLARE_READ8_MEMBER(superfx_r_bank1);
3333   virtual DECLARE_READ8_MEMBER(superfx_r_bank2);
3434   virtual DECLARE_READ8_MEMBER(superfx_r_bank3);
r21591r21592
3636   virtual DECLARE_WRITE8_MEMBER(superfx_w_bank2);
3737   virtual DECLARE_WRITE8_MEMBER(superfx_w_bank3);
3838   virtual DECLARE_WRITE_LINE_MEMBER(snes_extern_irq_w);
39   
40   
39
40
4141   UINT8 sfx_ram[0x200000];
4242};
4343
trunk/src/mess/machine/sns_rom.c
r21591r21592
11/***********************************************************************************************************
2
2
33 Super NES/Famicom (LoROM) cartridge emulation (for SNES/SFC)
4
4
55 Copyright MESS Team.
66 Visit http://mamedev.org for licensing and usage restrictions.
7
7
88 ***********************************************************************************************************/
99
1010
r21591r21592
6262   // or from rom?
6363   m_offset  = (m_ram[0x1ff5] & 0x01) ? 0x1800 : 0x1c00;
6464   m_address = (m_ram[0x1ff6] & 0x7f);
65   m_shift   = (m_ram[0x1ff6] & 0x03) << 1;   
65   m_shift   = (m_ram[0x1ff6] & 0x03) << 1;
6666
6767   save_item(NAME(m_ram));
6868   save_item(NAME(m_address));
r21591r21592
8484{
8585   UINT8 value = 0xff;
8686   UINT16 address = offset & 0xffff;
87   
87
8888   if (offset < 0x700000)
8989   {
9090      int bank = offset / 0x10000;
r21591r21592
107107            value = m_nvram[offset & mask];
108108         }
109109         else
110            value = 0xff;   // this should never happened...
110            value = 0xff;   // this should never happened...
111111      }
112112      else
113113      {
r21591r21592
125125
126126WRITE8_MEMBER(sns_rom_device::write_h)
127127{
128   if (offset >= 0x700000)   // SRAM
128   if (offset >= 0x700000) // SRAM
129129   {
130130      if (m_nvram_size > 0x8000)
131131      {
r21591r21592
161161// same as above but additional read/write handling for the add-on chip
162162
163163/***************************************************************************
164
164
165165 Based on C++ implementation by Byuu in BSNES.
166
166
167167 Byuu's code is released under GNU General Public License
168168 version 2 as published by the Free Software Foundation.
169
169
170170 The implementation below is released under the MAME license
171171 for use in MAME, MESS and derivatives by permission of Byuu
172
172
173173 Copyright (for the implementation below) MESS Team.
174174 Visit http://mamedev.org for licensing and usage restrictions.
175
175
176176 ***********************************************************************************************************/
177177
178178
r21591r21592
180180{
181181   UINT16 address = offset & 0x1fff;
182182   UINT8 value;
183   
183
184184   switch (address)
185185   {
186186      case 0x1ff0:
187187         value = m_ram[m_offset + (m_address << 2) + 0];
188188         break;
189         
189
190190      case 0x1ff1:
191191         value = m_ram[m_offset + (m_address << 2) + 1];
192192         break;
193         
193
194194      case 0x1ff2:
195195         value = m_ram[m_offset + (m_address << 2) + 2];
196196         break;
197         
197
198198      case 0x1ff3:
199199         value = m_ram[m_offset + (m_address << 2) + 3];
200200         break;
201         
201
202202      case 0x1ff4:
203203         value = m_ram[m_offset + (m_address >> 2) + 0x200];
204204         break;
205         
205
206206      default:
207207         value = m_ram[address];
208208         break;
209209   }
210   
210
211211   return value;
212212}
213213
r21591r21592
216216{
217217   UINT16 address = offset & 0x1fff;
218218   UINT8 temp;
219   
219
220220   switch(address)
221221   {
222222      case 0x1ff0:
223223         m_ram[m_offset + (m_address << 2) + 0] = data;
224224         break;
225         
225
226226      case 0x1ff1:
227227         m_ram[m_offset + (m_address << 2) + 1] = data;
228228         break;
229         
229
230230      case 0x1ff2:
231231         m_ram[m_offset + (m_address << 2) + 2] = data;
232232         break;
233         
233
234234      case 0x1ff3:
235235         m_ram[m_offset + (m_address << 2) + 3] = data;
236236         break;
237         
237
238238      case 0x1ff4:
239239         temp = m_ram[m_offset + (m_address >> 2) + 0x200];
240240         temp = (temp & ~(3 << m_shift)) | ((data & 0x03) << m_shift);
241241         m_ram[m_offset + (m_address >> 2) + 0x200] = temp;
242242         break;
243         
243
244244      case 0x1ff5:
245245         m_offset = (data & 0x01) ? 0x1800 : 0x1c00;
246246         m_ram[address & 0x1fff] = data;
247247         break;
248         
248
249249      case 0x1ff6:
250250         m_address = data & 0x7f;
251251         m_shift = (data & 0x03) << 1;
252252         m_ram[address & 0x1fff] = data;
253253         break;
254         
254
255255      default:
256256         m_ram[address & 0x1fff] = data;
257257         break;
258258   }
259259}
260
trunk/src/mess/machine/sns_rom.h
r21591r21592
77// ======================> sns_rom_device
88
99class sns_rom_device : public device_t,
10                 public device_sns_cart_interface
10                  public device_sns_cart_interface
1111{
1212public:
1313   // construction/destruction
1414   sns_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
1515   sns_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
16   
16
1717   // device-level overrides
1818   virtual void device_start();
1919   virtual void device_config_complete() { m_shortname = "sns_rom"; }
r21591r21592
3232public:
3333   // construction/destruction
3434   sns_rom_pokemon_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
35   
35
3636   // device-level overrides
3737   virtual void device_start();
3838   virtual void device_config_complete() { m_shortname = "sns_rom_pokemon"; }
39   
39
4040   // reading and writing
41   virtual DECLARE_READ8_MEMBER(chip_read);   // protection device
42   virtual DECLARE_WRITE8_MEMBER(chip_write);   // protection device
41   virtual DECLARE_READ8_MEMBER(chip_read);    // protection device
42   virtual DECLARE_WRITE8_MEMBER(chip_write);  // protection device
4343   UINT8 m_latch;
4444};
4545
r21591r21592
5050public:
5151   // construction/destruction
5252   sns_rom_obc1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
53   
53
5454   // device-level overrides
5555   virtual void device_start();
5656   virtual void device_config_complete() { m_shortname = "sns_rom_obc1"; }
57   
57
5858   // additional reading and writing
5959   virtual DECLARE_READ8_MEMBER(chip_read);
6060   virtual DECLARE_WRITE8_MEMBER(chip_write);
61   
61
6262   int m_address;
6363   int m_offset;
6464   int m_shift;
trunk/src/mess/machine/sns_bsx.c
r21591r21592
11/***********************************************************************************************************
2
2
33 BS-X Satellaview cartridge emulation (for SNES/SFC)
4
4
55 Copyright MESS Team.
66 Visit http://mamedev.org for licensing and usage restrictions.
77
r21591r21592
8989   m_command = 0;
9090   m_write_old = 0;
9191   m_write_new = 0;
92   
92
9393   m_flash_enable = 0;
9494   m_read_enable = 0;
9595   m_write_enable = 0;
r21591r21592
129129      mame_printf_debug("BS-X Base Unit reg read outside correct range!\n");
130130      return 0x00;
131131   }
132   
133   switch (offset)
134   {         
132
133   switch (offset)
134   {
135135      // no 218b? no 218d? no 2191? no 2195? no 219a-219f?
136      case 0x2192:
136      case 0x2192:
137137      {
138138         UINT8 counter = r2192_counter++;
139         if (r2192_counter >= 18)
139         if (r2192_counter >= 18)
140140            r2192_counter = 0;
141         
142         if (counter == 0)
141
142         if (counter == 0)
143143         {
144144            system_time curtime, *systime = &curtime;
145            m_machine.current_datetime(curtime);           
145            m_machine.current_datetime(curtime);
146146            r2192_hour   = systime->local_time.hour;
147147            r2192_minute = systime->local_time.minute;
148148            r2192_second = systime->local_time.second;
149149         }
150         
151         switch (counter)
150
151         switch (counter)
152152         {
153153            case  0: return 0x00;  //???
154154            case  1: return 0x00;  //???
r21591r21592
169169            case 16: return 0x00;  //???
170170            case 17: return 0x00;  //???
171171         }
172      }
172      }
173173         break;
174174
175175      case 0x2193:
r21591r21592
191191      mame_printf_debug("BS-X Base Unit reg write outside correct range!\n");
192192      return;
193193   }
194   
195   switch(offset)
194
195   switch(offset)
196196   {
197197      // no 218d? no 2190? no 2195? no 2196? no 2198? no 219a-219f?
198198      case 0x218f:
199         regs[6] >>= 1;   // 0x218e
200         regs[6] = regs[7] - regs[6];   // 0x218f - 0x218e
201         regs[7] >>= 1;   // 0x218f
199         regs[6] >>= 1;  // 0x218e
200         regs[6] = regs[7] - regs[6];    // 0x218f - 0x218e
201         regs[7] >>= 1;  // 0x218f
202202         break;
203         
203
204204      case 0x2191:
205205         regs[offset - 0x2188] = data;
206206         r2192_counter = 0;
207207         break;
208         
208
209209      case 0x2192:
210         regs[8] = data;   // sets 0x2190
210         regs[8] = data; // sets 0x2190
211211         break;
212         
212
213213      default:
214214         regs[offset - 0x2188] = data;
215215         break;
r21591r21592
266266      rom_access = 0;
267267   else
268268   {
269//      rom_access = BIT(m_cart_regs[0x02], 7) + 1;
270      rom_access = 1;   // for whatever reason bsxsore changes access mode here and then fails to read the ROM properly!
269//      rom_access = BIT(m_cart_regs[0x02], 7) + 1;
270      rom_access = 1; // for whatever reason bsxsore changes access mode here and then fails to read the ROM properly!
271271      printf("rom_access %s\n", !BIT(m_cart_regs[0x02], 7) ? "Lo" : "Hi");
272272   }
273273}
r21591r21592
317317      int bank = (rom_access == 1) ? (offset / 0x10000) : (offset / 0x8000);
318318      return m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
319319   }
320   
320
321321   return 0x00;
322322}
323323
r21591r21592
330330      if (m_slot->m_cart && m_slot->m_cart->get_rom_size())
331331         return m_slot->m_cart->read_l(space, offset);
332332   }
333   
333
334334   // if not in any of the cases above...
335335   //$00-3f|80-bf:8000-ffff
336336   //$40-7f|c0-ff:0000-ffff
r21591r21592
341341      int bank = (rom_access == 1) ? (offset / 0x10000) : (offset / 0x8000);
342342      return m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
343343   }
344   
344
345345   return 0x00;
346346}
347347
r21591r21592
378378      // 0x70-0x77:0x0000-0xffff -> PRAM
379379      m_pram[offset & 0x7ffff] = data;
380380   }
381   
381
382382   // if not in any of the cases above...
383383   //$00-3f|80-bf:8000-ffff
384384   //$40-7f|c0-ff:0000-ffff
r21591r21592
394394      // write to cart...
395395      return;
396396   }
397   
397
398398   // if not in any of the cases above...
399399   //$00-3f|80-bf:8000-ffff
400400   //$40-7f|c0-ff:0000-ffff
r21591r21592
407407{
408408   if ((offset & 0xffff) >= 0x2188 && (offset & 0xffff) < 0x21a0)
409409      return m_base_unit->read(offset & 0xffff);
410   
411   if ((offset & 0xf0ffff) == 0x005000)   //$[00-0f]:5000 reg access
410
411   if ((offset & 0xf0ffff) == 0x005000)    //$[00-0f]:5000 reg access
412412   {
413413      UINT8 n = (offset >> 16) & 0x0f;
414414      return m_cart_regs[n];
415415   }
416   
417   if ((offset & 0xf8f000) == 0x105000)   //$[10-17]:[5000-5fff] SRAM access
416
417   if ((offset & 0xf8f000) == 0x105000)    //$[10-17]:[5000-5fff] SRAM access
418418   {
419419      return m_nvram[((offset >> 16) & 7) * 0x1000 + (offset & 0xfff)];
420420   }
421   
421
422422   return 0x00;
423423}
424424
r21591r21592
426426{
427427   if ((offset & 0xffff) >= 0x2188 && (offset & 0xffff) < 0x21a0)
428428      m_base_unit->write(offset & 0xffff, data);
429   
430   if ((offset & 0xf0ffff) == 0x005000)   //$[00-0f]:5000 reg access
429
430   if ((offset & 0xf0ffff) == 0x005000)    //$[00-0f]:5000 reg access
431431   {
432432      UINT8 n = (offset >> 16) & 0x0f;
433433      m_cart_regs[n] = data;
434434      if (n == 0x0e && data & 0x80)
435435         access_update();
436436   }
437   
438   if ((offset & 0xf8f000) == 0x105000)   //$[10-17]:[5000-5fff] SRAM access
437
438   if ((offset & 0xf8f000) == 0x105000)    //$[10-17]:[5000-5fff] SRAM access
439439   {
440440      m_nvram[((offset >> 16) & 7) * 0x1000 + (offset & 0xfff)] = data;
441441   }
r21591r21592
583583WRITE8_MEMBER(sns_rom_bsmempak_device::write_l)
584584{
585585}
586
trunk/src/mess/machine/sns_bsx.h
r21591r21592
1717
1818private:
1919   // regs
20   UINT8 regs[0x18];      // 0x2188-0x219f
20   UINT8 regs[0x18];       // 0x2188-0x219f
2121
2222   // counter + clock
2323   UINT8 r2192_counter;
r21591r21592
3434   // construction/destruction
3535   sns_rom_bsx_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
3636   sns_rom_bsx_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
37   
37
3838   // device-level overrides
3939   virtual void device_start();
4040   virtual void device_config_complete() { m_shortname = "sns_rom_bsx"; }
4141   virtual machine_config_constructor device_mconfig_additions() const;
42   
42
4343   // additional reading and writing
4444   virtual DECLARE_READ8_MEMBER(read_l);
4545   virtual DECLARE_READ8_MEMBER(read_h);
r21591r21592
4747   virtual DECLARE_WRITE8_MEMBER(write_h);
4848   virtual DECLARE_READ8_MEMBER(chip_read);
4949   virtual DECLARE_WRITE8_MEMBER(chip_write);
50   
50
5151   // base regs
5252   BSX_base *m_base_unit;
53   
53
5454   // cart regs
5555   UINT8 m_cart_regs[16];
56   UINT8 access_00_1f;   // 1 = CART, 0 = NOTHING
57   UINT8 access_80_9f;   // 1 = CART, 0 = NOTHING
58   UINT8 access_40_4f;   // 1 = NOTHING, 0 = PRAM
59   UINT8 access_50_5f;   // 1 = NOTHING, 0 = PRAM
60   UINT8 access_60_6f;   // 1 = PRAM, 0 = NOTHING
61   UINT8 rom_access;   // 2 = HiROM, 1 = LoROM, 0 = PRAM
56   UINT8 access_00_1f; // 1 = CART, 0 = NOTHING
57   UINT8 access_80_9f; // 1 = CART, 0 = NOTHING
58   UINT8 access_40_4f; // 1 = NOTHING, 0 = PRAM
59   UINT8 access_50_5f; // 1 = NOTHING, 0 = PRAM
60   UINT8 access_60_6f; // 1 = PRAM, 0 = NOTHING
61   UINT8 rom_access;   // 2 = HiROM, 1 = LoROM, 0 = PRAM
6262   void access_update();
63   
64   
63
64
6565   UINT8 m_pram[0x80000];
66   
66
6767private:
6868   required_device<sns_bsx_cart_slot_device> m_slot;
6969};
r21591r21592
7575public:
7676   // construction/destruction
7777   sns_rom_bsxlo_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
78   
78
7979   // device-level overrides
8080   virtual void device_start();
8181   virtual void device_config_complete() { m_shortname = "sns_rom_bsxlo"; }
8282   virtual machine_config_constructor device_mconfig_additions() const;
83   
83
8484   // additional reading and writing
8585   virtual DECLARE_READ8_MEMBER(read_l);
8686   virtual DECLARE_READ8_MEMBER(read_h);
87//   virtual DECLARE_WRITE8_MEMBER(write_l);
88//   virtual DECLARE_WRITE8_MEMBER(write_h);
89//   virtual DECLARE_READ8_MEMBER(chip_read);
90//   virtual DECLARE_WRITE8_MEMBER(chip_write);
91   
87//  virtual DECLARE_WRITE8_MEMBER(write_l);
88//  virtual DECLARE_WRITE8_MEMBER(write_h);
89//  virtual DECLARE_READ8_MEMBER(chip_read);
90//  virtual DECLARE_WRITE8_MEMBER(chip_write);
91
9292private:
9393   required_device<sns_bsx_cart_slot_device> m_slot;
9494};
r21591r21592
100100public:
101101   // construction/destruction
102102   sns_rom_bsxhi_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
103   
103
104104   // device-level overrides
105105   virtual void device_start();
106106   virtual void device_config_complete() { m_shortname = "sns_rom_bsxhi"; }
107107   virtual machine_config_constructor device_mconfig_additions() const;
108   
108
109109   // additional reading and writing
110110   virtual DECLARE_READ8_MEMBER(read_l);
111111   virtual DECLARE_READ8_MEMBER(read_h);
112112   virtual DECLARE_WRITE8_MEMBER(write_l);
113113   virtual DECLARE_WRITE8_MEMBER(write_h);
114   //   virtual DECLARE_READ8_MEMBER(chip_read);
115   //   virtual DECLARE_WRITE8_MEMBER(chip_write);
116   
114   //  virtual DECLARE_READ8_MEMBER(chip_read);
115   //  virtual DECLARE_WRITE8_MEMBER(chip_write);
116
117117private:
118118   required_device<sns_bsx_cart_slot_device> m_slot;
119119};
r21591r21592
126126public:
127127   // construction/destruction
128128   sns_rom_bsmempak_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
129   
129
130130   // device-level overrides
131131   virtual void device_start();
132132   virtual void device_config_complete() { m_shortname = "sns_bsmempak"; }
133   
133
134134   // additional reading and writing
135135   virtual DECLARE_READ8_MEMBER(read_l);
136136   virtual DECLARE_READ8_MEMBER(read_h);
137137   virtual DECLARE_WRITE8_MEMBER(write_l);
138//   virtual DECLARE_WRITE8_MEMBER(write_h);
139//   virtual DECLARE_READ8_MEMBER(chip_read);
140//   virtual DECLARE_WRITE8_MEMBER(chip_write);
141   
138//  virtual DECLARE_WRITE8_MEMBER(write_h);
139//  virtual DECLARE_READ8_MEMBER(chip_read);
140//  virtual DECLARE_WRITE8_MEMBER(chip_write);
141
142142   // flash regs
143143   UINT32 m_command;
144144   UINT8 m_write_old;
145145   UINT8 m_write_new;
146   
146
147147   int m_flash_enable;
148148   int m_read_enable;
149149   int m_write_enable;
trunk/src/mess/machine/sns_spc7110.c
r21591r21592
11/***********************************************************************************************************
2
2
33 SPC-7110 add-on chip emulation (for SNES/SFC)
4
4
55 Based on C++ implementation by Byuu in BSNES.
6
6
77 Byuu's code is released under GNU General Public License
88 version 2 as published by the Free Software Foundation.
99
1010 The implementation below is released under the MAME license
1111 for use in MAME, MESS and derivatives by permission of Byuu
12
12
1313 Copyright (for the implementation below) MESS Team.
1414 Visit http://mamedev.org for licensing and usage restrictions.
15
15
1616 ***********************************************************************************************************/
1717
1818
r21591r21592
5959   m_r480a = 0x00;
6060   m_r480b = 0x00;
6161   m_r480c = 0x00;
62   
62
6363   m_r4811 = 0x00;
6464   m_r4812 = 0x00;
6565   m_r4813 = 0x00;
r21591r21592
6868   m_r4816 = 0x00;
6969   m_r4817 = 0x00;
7070   m_r4818 = 0x00;
71   
71
7272   m_r481x = 0x00;
7373   m_r4814_latch = 0;
7474   m_r4815_latch = 0;
75   
75
7676   m_r4820 = 0x00;
7777   m_r4821 = 0x00;
7878   m_r4822 = 0x00;
r21591r21592
8989   m_r482d = 0x00;
9090   m_r482e = 0x00;
9191   m_r482f = 0x00;
92   
92
9393   m_r4830 = 0x00;
9494   m_r4831 = 0;
95   m_dx_offset = spc7110_datarom_addr(0 * 0x100000, 0x200000);   // we would need the rom length here...
95   m_dx_offset = spc7110_datarom_addr(0 * 0x100000, 0x200000); // we would need the rom length here...
9696   m_r4832 = 1;
97   m_ex_offset = spc7110_datarom_addr(1 * 0x100000, 0x200000);   // we would need the rom length here...
97   m_ex_offset = spc7110_datarom_addr(1 * 0x100000, 0x200000); // we would need the rom length here...
9898   m_r4833 = 2;
99   m_fx_offset = spc7110_datarom_addr(2 * 0x100000, 0x200000);   // we would need the rom length here...
99   m_fx_offset = spc7110_datarom_addr(2 * 0x100000, 0x200000); // we would need the rom length here...
100100   m_r4834 = 0x00;
101   
101
102102   m_r4840 = 0x00;
103103   m_r4841 = 0x00;
104104   m_r4842 = 0x00;
105   
105
106106   m_decomp = auto_alloc(machine(), SPC7110_Decomp(machine()));
107107
108108   save_item(NAME(m_ram));
r21591r21592
169169void sns_rom_spc7110rtc_device::device_start()
170170{
171171   memset(rom_bank_map, 0, sizeof(rom_bank_map));
172   
172
173173   spc7110_start();
174174
175175   // RTC
r21591r21592
179179   m_rtc_offset = 0;
180180
181181// at this stage, rtc_ram is not yet allocated. this will be fixed when converting RTC to be a separate device.
182//   spc7110_update_time(0);
183   
182//  spc7110_update_time(0);
183
184184   save_item(NAME(m_rtc_state));
185185   save_item(NAME(m_rtc_mode));
186186   save_item(NAME(m_rtc_index));
r21591r21592
202202   { 0x08, 10,  4, 0 },
203203   { 0x03, 12,  5, 0 },
204204   { 0x01, 15,  5, 0 },
205   
205
206206   { 0x5a,  7,  7, 1 },
207207   { 0x3f, 19,  8, 0 },
208208   { 0x2c, 21,  9, 0 },
r21591r21592
216216   { 0x04, 32, 17, 0 },
217217   { 0x03, 34, 18, 0 },
218218   { 0x02, 35,  5, 0 },
219   
219
220220   { 0x5a, 20, 20, 1 },
221221   { 0x48, 39, 21, 0 },
222222   { 0x3a, 40, 22, 0 },
r21591r21592
237237   { 0x03, 34, 37, 0 },
238238   { 0x02, 35, 38, 0 },
239239   { 0x02, 36,  5, 0 },
240   
240
241241   { 0x58, 39, 40, 1 },
242242   { 0x4d, 47, 41, 0 },
243243   { 0x43, 48, 42, 0 },
r21591r21592
246246   { 0x2e, 51, 45, 0 },
247247   { 0x29, 44, 46, 0 },
248248   { 0x25, 45, 24, 0 },
249   
249
250250   { 0x56, 47, 48, 1 },
251251   { 0x4f, 47, 49, 0 },
252252   { 0x47, 48, 50, 0 },
r21591r21592
258258static const UINT8 spc7110_mode2_context_table[32][2] =
259259{
260260   {  1,  2 },
261   
261
262262   {  3,  8 },
263263   { 13, 14 },
264   
264
265265   { 15, 16 },
266266   { 17, 18 },
267267   { 19, 20 },
r21591r21592
274274   { 25, 26 },
275275   { 27, 28 },
276276   { 29, 30 },
277   
277
278278   { 31, 31 },
279279   { 31, 31 },
280280   { 31, 31 },
r21591r21592
291291   { 31, 31 },
292292   { 31, 31 },
293293   { 31, 31 },
294   
294
295295   { 31, 31 },
296296};
297297
r21591r21592
300300{
301301   m_decomp_buffer = (UINT8*)auto_alloc_array(machine, UINT8, SPC7110_DECOMP_BUFFER_SIZE);
302302   reset();
303   
303
304304   for (int i = 0; i < 256; i++)
305305   {
306306#define map(x, y) (((i >> x) & 1) << y)
r21591r21592
327327   //mode 3 is invalid; this is treated as a special case to always return 0x00
328328   //set to mode 3 so that reading decomp port before starting first decomp will return 0x00
329329   m_decomp_mode = 3;
330   
330
331331   m_decomp_buffer_rdoffset = 0;
332332   m_decomp_buffer_wroffset = 0;
333333   m_decomp_buffer_length   = 0;
r21591r21592
337337{
338338   m_decomp_mode = mode;
339339   m_decomp_offset = offset;
340   
340
341341   m_decomp_buffer_rdoffset = 0;
342342   m_decomp_buffer_wroffset = 0;
343343   m_decomp_buffer_length   = 0;
344   
344
345345   //reset context states
346346   for (int i = 0; i < 32; i++)
347347   {
348348      m_context[i].index  = 0;
349349      m_context[i].invert = 0;
350350   }
351   
351
352352   switch (m_decomp_mode)
353353   {
354354      case 0: mode0(1, ROM, len); break;
355355      case 1: mode1(1, ROM, len); break;
356356      case 2: mode2(1, ROM, len); break;
357357   }
358   
358
359359   //decompress up to requested output data index
360360   while (index--)
361361   {
r21591r21592
366366UINT8 SPC7110_Decomp::read(UINT8 *ROM, UINT32 len)
367367{
368368   UINT8 data;
369   
369
370370   if (m_decomp_buffer_length == 0)
371371   {
372372      //decompress at least (SPC7110_DECOMP_BUFFER_SIZE / 2) bytes to the buffer
r21591r21592
375375         case 0:
376376            mode0(0, ROM, len);
377377            break;
378           
378
379379         case 1:
380380            mode1(0, ROM, len);
381381            break;
382           
382
383383         case 2:
384384            mode2(0, ROM, len);
385385            break;
386           
386
387387         default:
388388            return 0x00;
389389      }
390390   }
391   
391
392392   data = m_decomp_buffer[m_decomp_buffer_rdoffset++];
393393   m_decomp_buffer_rdoffset &= SPC7110_DECOMP_BUFFER_SIZE - 1;
394394   m_decomp_buffer_length--;
r21591r21592
416416{
417417   static UINT8 val, in, span;
418418   static INT32 out, inverts, lps, in_count;
419   
419
420420   if (init == 1)
421421   {
422422      out = inverts = lps = 0;
r21591r21592
426426      in_count = 8;
427427      return;
428428   }
429   
429
430430   while (m_decomp_buffer_length < (SPC7110_DECOMP_BUFFER_SIZE >> 1))
431431   {
432432      for (int bit = 0; bit < 8; bit++)
r21591r21592
440440         {
441441            con += 15;
442442         }
443         
443
444444         //get prob and mps
445445         prob = probability(con);
446446         mps = (((out >> 15) & 1) ^ m_context[con].invert);
447         
447
448448         //get bit
449449         if (val <= span - prob) //mps
450450         {
r21591r21592
459459            out = (out << 1) + 1 - mps;
460460            flag_lps = 1;
461461         }
462         
462
463463         //renormalize
464464         while (span < 0x7f)
465465         {
466466            shift++;
467           
467
468468            span = (span << 1) + 1;
469469            val = (val << 1) + (in >> 7);
470           
470
471471            in <<= 1;
472472            if (--in_count == 0)
473473            {
r21591r21592
475475               in_count = 8;
476476            }
477477         }
478         
478
479479         //update processing info
480480         lps = (lps << 1) + flag_lps;
481481         inverts = (inverts << 1) + m_context[con].invert;
482         
482
483483         //update context state
484484         if (flag_lps & toggle_invert(con))
485485         {
r21591r21592
494494            m_context[con].index = next_mps(con);
495495         }
496496      }
497     
497
498498      //save byte
499499      write(out);
500500   }
r21591r21592
505505   static INT32 pixelorder[4], realorder[4];
506506   static UINT8 in, val, span;
507507   static INT32 out, inverts, lps, in_count;
508   
508
509509   if (init == 1)
510510   {
511511      for (int i = 0; i < 4; i++)
r21591r21592
519519      in_count = 8;
520520      return;
521521   }
522   
522
523523   while (m_decomp_buffer_length < (SPC7110_DECOMP_BUFFER_SIZE >> 1))
524524   {
525525      UINT16 data;
r21591r21592
530530         UINT32 b = ((out >> (7 * 2)) & 3);
531531         UINT32 c = ((out >> (8 * 2)) & 3);
532532         UINT32 con = (a == b) ? (b != c) : (b == c) ? 2 : 4 - (a == c);
533         
533
534534         //update pixel order
535535         UINT32 m, n;
536536         for (m = 0; m < 4; m++)
r21591r21592
545545            pixelorder[n] = pixelorder[n - 1];
546546         }
547547         pixelorder[0] = a;
548         
548
549549         //calculate the real pixel order
550550         for (m = 0; m < 4; m++)
551551         {
552552            realorder[m] = pixelorder[m];
553553         }
554         
554
555555         //rotate reference pixel c value to top
556556         for (m = 0; m < 4; m++)
557557         {
r21591r21592
565565            realorder[n] = realorder[n - 1];
566566         }
567567         realorder[0] = c;
568         
568
569569         //rotate reference pixel b value to top
570570         for (m = 0; m < 4; m++)
571571         {
r21591r21592
579579            realorder[n] = realorder[n - 1];
580580         }
581581         realorder[0] = b;
582         
582
583583         //rotate reference pixel a value to top
584584         for (m = 0; m < 4; m++)
585585         {
r21591r21592
593593            realorder[n] = realorder[n - 1];
594594         }
595595         realorder[0] = a;
596         
596
597597         //get 2 symbols
598598         for (int bit = 0; bit < 2; bit++)
599599         {
600600            //get prob
601601            UINT32 prob = probability(con);
602602            UINT32 shift = 0;
603           
603
604604            //get symbol
605605            UINT32 flag_lps;
606606            if (val <= span - prob) //mps
r21591r21592
614614               span = prob - 1;
615615               flag_lps = 1;
616616            }
617           
617
618618            //renormalize
619619            while (span < 0x7f)
620620            {
621621               shift++;
622               
622
623623               span = (span << 1) + 1;
624624               val = (val << 1) + (in >> 7);
625               
625
626626               in <<= 1;
627627               if (--in_count == 0)
628628               {
r21591r21592
630630                  in_count = 8;
631631               }
632632            }
633           
633
634634            //update processing info
635635            lps = (lps << 1) + flag_lps;
636636            inverts = (inverts << 1) + m_context[con].invert;
637           
637
638638            //update context state
639639            if (flag_lps & toggle_invert(con))
640640            {
r21591r21592
648648            {
649649               m_context[con].index = next_mps(con);
650650            }
651           
651
652652            //get next context
653653            con = 5 + (con << 1) + ((lps ^ inverts) & 1);
654654         }
655         
655
656656         //get pixel
657657         b = realorder[(lps ^ inverts) & 3];
658658         out = (out << 2) + b;
659659      }
660     
660
661661      //turn pixel data into bitplanes
662662      data = morton_2x8(out);
663663      write(data >> 8);
r21591r21592
671671   static UINT8 bitplanebuffer[16], buffer_index;
672672   static UINT8 in, val, span;
673673   static INT32 out0, out1, inverts, lps, in_count;
674   
674
675675   if (init == 1)
676676   {
677677      for (int i = 0; i < 16; i++)
r21591r21592
686686      in_count = 8;
687687      return;
688688   }
689   
689
690690   while (m_decomp_buffer_length < (SPC7110_DECOMP_BUFFER_SIZE >> 1))
691691   {
692692      UINT32 data;
r21591r21592
698698         UINT32 c = ((out1 >> (0 * 4)) & 15);
699699         UINT32 con = 0;
700700         UINT32 refcon = (a == b) ? (b != c) : (b == c) ? 2 : 4 - (a == c);
701         
701
702702         //update pixel order
703703         UINT32 m, n;
704704         for (m = 0; m < 16; m++)
r21591r21592
713713            pixelorder[n] = pixelorder[n - 1];
714714         }
715715         pixelorder[0] = a;
716         
716
717717         //calculate the real pixel order
718718         for (m = 0; m < 16; m++)
719719         {
720720            realorder[m] = pixelorder[m];
721721         }
722         
722
723723         //rotate reference pixel c value to top
724724         for (m = 0; m < 16; m++)
725725         {
r21591r21592
733733            realorder[n] = realorder[n - 1];
734734         }
735735         realorder[0] = c;
736         
736
737737         //rotate reference pixel b value to top
738738         for (m = 0; m < 16; m++)
739739         {
r21591r21592
747747            realorder[n] = realorder[n - 1];
748748         }
749749         realorder[0] = b;
750         
750
751751         //rotate reference pixel a value to top
752752         for (m = 0; m < 16; m++)
753753         {
r21591r21592
761761            realorder[n] = realorder[n - 1];
762762         }
763763         realorder[0] = a;
764         
764
765765         //get 4 symbols
766766         for (int bit = 0; bit < 4; bit++)
767767         {
768768            UINT32 invertbit, shift;
769           
769
770770            //get prob
771771            UINT32 prob = probability(con);
772           
772
773773            //get symbol
774774            UINT32 flag_lps;
775775            if (val <= span - prob) //mps
r21591r21592
783783               span = prob - 1;
784784               flag_lps = 1;
785785            }
786           
786
787787            //renormalize
788788            shift = 0;
789789            while (span < 0x7f)
790790            {
791791               shift++;
792               
792
793793               span = (span << 1) + 1;
794794               val = (val << 1) + (in >> 7);
795               
795
796796               in <<= 1;
797797               if (--in_count == 0)
798798               {
r21591r21592
800800                  in_count = 8;
801801               }
802802            }
803           
803
804804            //update processing info
805805            lps = (lps << 1) + flag_lps;
806806            invertbit = m_context[con].invert;
807807            inverts = (inverts << 1) + invertbit;
808           
808
809809            //update context state
810810            if (flag_lps & toggle_invert(con))
811811            {
r21591r21592
819819            {
820820               m_context[con].index = next_mps(con);
821821            }
822           
822
823823            //get next context
824824            con = spc7110_mode2_context_table[con][flag_lps ^ invertbit] + (con == 1 ? refcon : 0);
825825         }
826         
826
827827         //get pixel
828828         b = realorder[(lps ^ inverts) & 0x0f];
829829         out1 = (out1 << 4) + ((out0 >> 28) & 0x0f);
830830         out0 = (out0 << 4) + b;
831831      }
832     
832
833833      //convert pixel data into bitplanes
834834      data = morton_4x8(out0);
835835      write(data >> 24);
836836      write(data >> 16);
837837      bitplanebuffer[buffer_index++] = data >> 8;
838838      bitplanebuffer[buffer_index++] = data >> 0;
839     
839
840840      if (buffer_index == 16)
841841      {
842842         for (int i = 0; i < 16; i++)
r21591r21592
937937   system_time curtime, *systime = &curtime;
938938   machine().current_datetime(curtime);
939939   int update = 1;
940   
940
941941   m_rtc_offset += offset;
942   
942
943943   // TEST: can we go beyond 24hrs of rounding?!? I doubt it will ever go beyond 3600, but I could be wrong...
944944   assert(m_rtc_offset < 86400);
945   
945
946946   /* do not update if CR0 or CR2 timer disable flags are set */
947947   if ((m_rtc_ram[13] & 0x01) || (m_rtc_ram[15] & 0x03))
948948      update = 0;
949   
949
950950   if (update)
951951   {
952952      /* update time with offset, assuming offset < 3600s */
r21591r21592
954954      UINT8 minute = systime->local_time.minute;
955955      UINT8 hour = systime->local_time.hour;
956956      UINT8 mday = systime->local_time.mday;
957     
957
958958      while (m_rtc_offset >= 3600)
959959      {
960960         m_rtc_offset -= 3600;
961961         hour++;
962         
962
963963         if (hour == 24)
964964         {
965965            mday++;
966966            hour = 0;
967967         }
968968      }
969     
969
970970      while (m_rtc_offset >= 60)
971971      {
972972         m_rtc_offset -= 60;
973973         minute++;
974         
974
975975         if (minute == 60)
976976         {
977977            hour++;
978978            minute = 0;
979979         }
980980      }
981     
981
982982      while (m_rtc_offset)
983983      {
984984         m_rtc_offset -= 1;
985985         second++;
986         
986
987987         if (second == 60)
988988         {
989989            minute++;
990990            second = 0;
991991         }
992992      }
993     
993
994994      m_rtc_ram[0] = second % 10;
995995      m_rtc_ram[1] = second / 10;
996996      m_rtc_ram[2] = minute % 10;
r21591r21592
10231023      if (address >= 0x8000)
10241024         return m_rom[rom_bank_map[offset / 0x8000] * 0x8000 + (offset & 0x7fff)];
10251025   }
1026   
1026
10271027   return 0xff;
10281028}
10291029
10301030READ8_MEMBER(sns_rom_spc7110_device::read_h)
10311031{
10321032   UINT16 address = offset & 0xfffff;
1033   
1033
10341034   if (offset < 0x400000)
10351035   {
10361036      if (address >= 0x6000 && address < 0x8000)
r21591r21592
10741074   UINT8 *ROM = get_rom_base();
10751075   UINT32 len = get_rom_size();
10761076   UINT16 addr = offset & 0xffff;
1077   
1077
10781078   switch (addr)
10791079   {
10801080      //==================
10811081      //decompression unit
10821082      //==================
1083         
1083
10841084      case 0x4800:
10851085      {
10861086         UINT16 counter = (m_r4809 + (m_r480a << 8));
r21591r21592
11061106         m_r480c &= 0x7f;
11071107         return status;
11081108      }
1109         
1109
11101110      //==============
11111111      //data port unit
11121112      //==============
1113         
1113
11141114      case 0x4810:
11151115      {
11161116         UINT8 data;
11171117         UINT32 address, adjust, adjustaddr;
1118         
1118
11191119         if (m_r481x != 0x07) return 0x00;
1120         
1120
11211121         address = spc7110_data_pointer();
11221122         adjust = spc7110_data_adjust();
11231123         if (m_r4818 & 8)
11241124         {
11251125            adjust = (INT16)adjust;  //16-bit sign extend
11261126         }
1127         
1127
11281128         adjustaddr = address;
11291129         if (m_r4818 & 2)
11301130         {
11311131            adjustaddr += adjust;
11321132            spc7110_set_data_adjust(adjust + 1);
11331133         }
1134         
1134
11351135         data = ROM[spc7110_datarom_addr(adjustaddr, len)];
11361136         if (!(m_r4818 & 2))
11371137         {
r21591r21592
11401140            {
11411141               increment = (INT16)increment;  //16-bit sign extend
11421142            }
1143           
1143
11441144            if ((m_r4818 & 16) == 0)
11451145            {
11461146               spc7110_set_data_pointer(address + increment);
r21591r21592
11501150               spc7110_set_data_adjust(adjust + increment);
11511151            }
11521152         }
1153         
1153
11541154         return data;
11551155      }
11561156      case 0x4811: return m_r4811;
r21591r21592
11691169         {
11701170            return 0x00;
11711171         }
1172         
1172
11731173         address = spc7110_data_pointer();
11741174         adjust = spc7110_data_adjust();
11751175         if (m_r4818 & 8)
11761176         {
11771177            adjust = (INT16)adjust;  //16-bit sign extend
11781178         }
1179         
1179
11801180         data = ROM[spc7110_datarom_addr(address + adjust, len)];
11811181         if ((m_r4818 & 0x60) == 0x60)
11821182         {
r21591r21592
11891189               spc7110_set_data_adjust(adjust + adjust);
11901190            }
11911191         }
1192         
1192
11931193         return data;
11941194      }
1195         
1195
11961196      //=========
11971197      //math unit
11981198      //=========
1199         
1199
12001200      case 0x4820: return m_r4820;
12011201      case 0x4821: return m_r4821;
12021202      case 0x4822: return m_r4822;
r21591r21592
12181218         m_r482f &= 0x7f;
12191219         return status;
12201220      }
1221         
1221
12221222      //===================
12231223      //memory mapping unit
12241224      //===================
1225         
1225
12261226      case 0x4830: return m_r4830;
12271227      case 0x4831: return m_r4831;
12281228      case 0x4832: return m_r4832;
12291229      case 0x4833: return m_r4833;
12301230      case 0x4834: return m_r4834;
1231         
1231
12321232      //====================
12331233      //real-time clock unit
12341234      //====================
r21591r21592
12381238         UINT8 data = 0;
12391239         if (m_rtc_state == RTCS_Inactive || m_rtc_state == RTCS_ModeSelect)
12401240            return 0x00;
1241         
1241
12421242         m_r4842 = 0x80;
12431243         data = m_rtc_ram[m_rtc_index];
12441244         m_rtc_index = (m_rtc_index + 1) & 15;
r21591r21592
12601260   UINT8 *ROM = get_rom_base();
12611261   UINT32 len = get_rom_size();
12621262   UINT16 addr = offset & 0xffff;
1263   
1263
12641264   switch (addr)
12651265   {
12661266      //==================
12671267      //decompression unit
12681268      //==================
1269         
1269
12701270      case 0x4801: m_r4801 = data; break;
12711271      case 0x4802: m_r4802 = data; break;
12721272      case 0x4803: m_r4803 = data; break;
r21591r21592
12761276      {
12771277         UINT32 table, index, address, mode, offset;
12781278         m_r4806 = data;
1279         
1279
12801280         table   = (m_r4801 + (m_r4802 << 8) + (m_r4803 << 16));
12811281         index   = (m_r4804 << 2);
12821282         //length  = (m_r4809 + (m_r480a << 8));
r21591r21592
12851285         offset  = (ROM[address + 1] << 16)
12861286         + (ROM[address + 2] <<  8)
12871287         + (ROM[address + 3] <<  0);
1288         
1288
12891289         m_decomp->init(machine(), ROM, len, mode, offset, (m_r4805 + (m_r4806 << 8)) << mode);
12901290         m_r480c = 0x80;
12911291      }
12921292         break;
1293         
1293
12941294      case 0x4807: m_r4807 = data; break;
12951295      case 0x4808: m_r4808 = data; break;
12961296      case 0x4809: m_r4809 = data; break;
12971297      case 0x480a: m_r480a = data; break;
12981298      case 0x480b: m_r480b = data; break;
1299         
1299
13001300      //==============
13011301      //data port unit
13021302      //==============
1303         
1303
13041304      case 0x4811: m_r4811 = data; m_r481x |= 0x01; break;
13051305      case 0x4812: m_r4812 = data; m_r481x |= 0x02; break;
13061306      case 0x4813: m_r4813 = data; m_r481x |= 0x04; break;
r21591r21592
13201320         {
13211321            break;
13221322         }
1323         
1323
13241324         if ((m_r4818 & 0x60) == 0x20)
13251325         {
13261326            UINT32 increment = spc7110_data_adjust() & 0xff;
r21591r21592
13411341         }
13421342         break;
13431343      }
1344         
1344
13451345      case 0x4815:
13461346      {
13471347         m_r4815 = data;
r21591r21592
13581358         {
13591359            break;
13601360         }
1361         
1361
13621362         if ((m_r4818 & 0x60) == 0x20)
13631363         {
13641364            UINT32 increment = spc7110_data_adjust() & 0xff;
r21591r21592
13791379         }
13801380         break;
13811381      }
1382         
1382
13831383      case 0x4816: m_r4816 = data; break;
13841384      case 0x4817: m_r4817 = data; break;
13851385      case 0x4818:
13861386      {
13871387         if (m_r481x != 0x07)
13881388            break;
1389         
1389
13901390         m_r4818 = data;
13911391         m_r4814_latch = m_r4815_latch = 0;
13921392         break;
13931393      }
1394         
1394
13951395      //=========
13961396      //math unit
13971397      //=========
1398         
1398
13991399      case 0x4820: m_r4820 = data; break;
14001400      case 0x4821: m_r4821 = data; break;
14011401      case 0x4822: m_r4822 = data; break;
r21591r21592
14041404      case 0x4825:
14051405      {
14061406         m_r4825 = data;
1407         
1407
14081408         if (m_r482e & 1)
14091409         {
14101410            //signed 16-bit x 16-bit multiplication
14111411            INT16 r0 = (INT16)(m_r4824 + (m_r4825 << 8));
14121412            INT16 r1 = (INT16)(m_r4820 + (m_r4821 << 8));
1413           
1413
14141414            INT32 result = r0 * r1;
14151415            m_r4828 = result;
14161416            m_r4829 = result >> 8;
r21591r21592
14221422            //unsigned 16-bit x 16-bit multiplication
14231423            UINT16 r0 = (UINT16)(m_r4824 + (m_r4825 << 8));
14241424            UINT16 r1 = (UINT16)(m_r4820 + (m_r4821 << 8));
1425           
1425
14261426            UINT32 result = r0 * r1;
14271427            m_r4828 = result;
14281428            m_r4829 = result >> 8;
14291429            m_r482a = result >> 16;
14301430            m_r482b = result >> 24;
14311431         }
1432         
1432
14331433         m_r482f = 0x80;
14341434         break;
14351435      }
1436         
1436
14371437      case 0x4826: m_r4826 = data; break;
14381438      case 0x4827:
14391439      {
14401440         m_r4827 = data;
1441         
1441
14421442         if (m_r482e & 1)
14431443         {
14441444            //signed 32-bit x 16-bit division
14451445            INT32 dividend = (INT32)(m_r4820 + (m_r4821 << 8) + (m_r4822 << 16) + (m_r4823 << 24));
14461446            INT16 divisor  = (INT16)(m_r4826 + (m_r4827 << 8));
1447           
1447
14481448            INT32 quotient;
14491449            INT16 remainder;
1450           
1450
14511451            if (divisor)
14521452            {
14531453               quotient  = (INT32)(dividend / divisor);
r21591r21592
14591459               quotient  = 0;
14601460               remainder = dividend & 0xffff;
14611461            }
1462           
1462
14631463            m_r4828 = quotient;
14641464            m_r4829 = quotient >> 8;
14651465            m_r482a = quotient >> 16;
14661466            m_r482b = quotient >> 24;
1467           
1467
14681468            m_r482c = remainder;
14691469            m_r482d = remainder >> 8;
14701470         }
r21591r21592
14731473            //unsigned 32-bit x 16-bit division
14741474            UINT32 dividend = (UINT32)(m_r4820 + (m_r4821 << 8) + (m_r4822 << 16) + (m_r4823 << 24));
14751475            UINT16 divisor  = (UINT16)(m_r4826 + (m_r4827 << 8));
1476           
1476
14771477            UINT32 quotient;
14781478            UINT16 remainder;
1479           
1479
14801480            if (divisor)
14811481            {
14821482               quotient  = (UINT32)(dividend / divisor);
r21591r21592
14881488               quotient  = 0;
14891489               remainder = dividend & 0xffff;
14901490            }
1491           
1491
14921492            m_r4828 = quotient;
14931493            m_r4829 = quotient >> 8;
14941494            m_r482a = quotient >> 16;
14951495            m_r482b = quotient >> 24;
1496           
1496
14971497            m_r482c = remainder;
14981498            m_r482d = remainder >> 8;
14991499         }
1500         
1500
15011501         m_r482f = 0x80;
15021502         break;
15031503      }
1504         
1504
15051505      case 0x482e:
15061506      {
15071507         //reset math unit
r21591r21592
15091509         m_r4824 = m_r4825 = m_r4826 = m_r4827 = 0;
15101510         m_r4828 = m_r4829 = m_r482a = m_r482b = 0;
15111511         m_r482c = m_r482d = 0;
1512         
1512
15131513         m_r482e = data;
15141514         break;
15151515      }
1516         
1516
15171517      //===================
15181518      //memory mapping unit
15191519      //===================
1520         
1520
15211521      case 0x4830: m_r4830 = data; break;
1522         
1522
15231523      case 0x4831:
15241524      {
15251525         m_r4831 = data;
15261526         m_dx_offset = spc7110_datarom_addr(data * 0x100000, len);
15271527         break;
15281528      }
1529         
1529
15301530      case 0x4832:
15311531      {
15321532         m_r4832 = data;
15331533         m_ex_offset = spc7110_datarom_addr(data * 0x100000, len);
15341534         break;
15351535      }
1536         
1536
15371537      case 0x4833:
15381538      {
15391539         m_r4833 = data;
15401540         m_fx_offset = spc7110_datarom_addr(data * 0x100000, len);
15411541         break;
15421542      }
1543         
1543
15441544      case 0x4834: m_r4834 = data; break;
1545         
1545
15461546      //====================
15471547      //real-time clock unit
15481548      //====================
1549         
1549
15501550      case 0x4840:
15511551      {
15521552         m_r4840 = data;
1553         
1553
15541554         if (!(m_r4840 & 1))
15551555         {
15561556            //disable RTC
r21591r21592
15651565         }
15661566      }
15671567         break;
1568         
1568
15691569      case 0x4841:
15701570      {
15711571         m_r4841 = data;
1572         
1572
15731573         switch (m_rtc_state)
15741574         {
15751575            case RTCS_ModeSelect:
r21591r21592
15811581                  m_rtc_index = 0;
15821582               }
15831583               break;
1584               
1584
15851585            case RTCS_IndexSelect:
15861586               m_r4842 = 0x80;
15871587               m_rtc_index = data & 15;
15881588               if (m_rtc_mode == RTCM_Linear)
15891589                  m_rtc_state = RTCS_Write;
15901590               break;
1591               
1591
15921592            case RTCS_Write:
15931593               m_r4842 = 0x80;
1594               
1594
15951595               //control register 0
15961596               if (m_rtc_index == 13)
15971597               {
15981598                  //increment second counter
15991599                  if (data & 2)
16001600                     spc7110_update_time(1);
1601                 
1601
16021602                  //round minute counter
16031603                  if (data & 8)
16041604                  {
16051605                     spc7110_update_time(0);
1606                     
1606
16071607                     UINT8 second = m_rtc_ram[0] + m_rtc_ram[1] * 10;
16081608                     //clear seconds
16091609                     m_rtc_ram[0] = 0;
16101610                     m_rtc_ram[1] = 0;
1611                     
1611
16121612                     if (second >= 30)
16131613                        spc7110_update_time(60);
16141614                  }
16151615               }
1616               
1616
16171617               //control register 2
16181618               if (m_rtc_index == 15)
16191619               {
r21591r21592
16211621                  if ((data & 1) && !(m_rtc_ram[15]  & 1))
16221622                  {
16231623                     spc7110_update_time(0);
1624                     
1624
16251625                     //clear seconds
16261626                     m_rtc_ram[0] = 0;
16271627                     m_rtc_ram[1] = 0;
16281628                  }
1629                 
1629
16301630                  //disable timer
16311631                  if ((data & 2) && !(m_rtc_ram[15] & 2))
16321632                     spc7110_update_time(0);
16331633               }
1634               
1634
16351635               m_rtc_ram[m_rtc_index] = data & 15;
16361636               m_rtc_index = (m_rtc_index + 1) & 15;
16371637               break;
r21591r21592
16401640         break;
16411641   }
16421642}
1643
trunk/src/mess/machine/sns_spc7110.h
r21591r21592
2323{
2424public:
2525   SPC7110_Decomp(running_machine &machine);
26   
26
2727   running_machine &machine() const { return m_machine; }
28   
28
2929   void init(running_machine &machine, UINT8 *ROM, UINT32 len, UINT32 mode, UINT32 offset, UINT32 index);
3030   void reset();
31   
31
3232   UINT8 read(UINT8 *ROM, UINT32 len);
3333   void write(UINT8 data);
3434   void mode0(UINT8 init, UINT8 *ROM, UINT32 len);
3535   void mode1(UINT8 init, UINT8 *ROM, UINT32 len);
3636   void mode2(UINT8 init, UINT8 *ROM, UINT32 len);
37   
37
3838   UINT8 dataread(UINT8 *ROM, UINT32 len);
3939   UINT8 probability(UINT32 n);
4040   UINT8 next_lps(UINT32 n);
r21591r21592
4242   UINT8 toggle_invert(UINT32 n);
4343   UINT32 morton_2x8(UINT32 data);
4444   UINT32 morton_4x8(UINT32 data);
45   
45
4646   UINT32 m_decomp_mode;
4747   UINT32 m_decomp_offset;
48   
48
4949   UINT8 *m_decomp_buffer;
5050   UINT32 m_decomp_buffer_rdoffset;
5151   UINT32 m_decomp_buffer_wroffset;
5252   UINT32 m_decomp_buffer_length;
53   
53
5454   struct ContextState
5555   {
5656      UINT8 index;
5757      UINT8 invert;
5858   } m_context[32];
59   
59
6060   UINT32 m_morton16[2][256];
6161   UINT32 m_morton32[4][256];
62   
63   
62
63
6464private:
6565   running_machine& m_machine;
6666   UINT32 m_rom_size;
r21591r21592
7474   // construction/destruction
7575   sns_rom_spc7110_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
7676   sns_rom_spc7110_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
77   
77
7878   // device-level overrides
7979   virtual void device_start();
8080   virtual void device_config_complete() { m_shortname = "sns_rom_spc7110"; }
r21591r21592
9595   void spc7110_set_data_pointer(UINT32 addr);
9696   void spc7110_set_data_adjust(UINT32 addr);
9797   void spc7110_update_time(UINT8 offset);
98   
9998
99
100100   //==================
101101   //decompression unit
102102   //==================
r21591r21592
112112   UINT8 m_r480a;        // compression length high
113113   UINT8 m_r480b;        // decompression control register
114114   UINT8 m_r480c;        // decompression status
115   
115
116116   SPC7110_Decomp* m_decomp;
117   
117
118118   UINT8 m_r4811;        // data pointer low
119119   UINT8 m_r4812;        // data pointer high
120120   UINT8 m_r4813;        // data pointer bank
r21591r21592
123123   UINT8 m_r4816;        // data increment low
124124   UINT8 m_r4817;        // data increment high
125125   UINT8 m_r4818;        // data port control register
126   
126
127127   UINT8 m_r481x;
128   
128
129129   UINT8 m_r4814_latch;
130130   UINT8 m_r4815_latch;
131   
131
132132   //=========
133133   //math unit
134134   //=========
r21591r21592
148148   UINT8 m_r482d;        // 16-bit remainder B1
149149   UINT8 m_r482e;        // math control register
150150   UINT8 m_r482f;        // math status
151   
151
152152   //===================
153153   //memory mapping unit
154154   //===================
r21591r21592
157157   UINT8 m_r4832;        // $[e0-ef]:[0000-ffff] mapping
158158   UINT8 m_r4833;        // $[f0-ff]:[0000-ffff] mapping
159159   UINT8 m_r4834;        // ???
160   
160
161161   UINT32 m_dx_offset;
162162   UINT32 m_ex_offset;
163163   UINT32 m_fx_offset;
164   
164
165165   //====================
166166   //real-time clock unit
167167   //====================
168168   UINT8 m_r4840;        // RTC latch
169169   UINT8 m_r4841;        // RTC index/data port
170170   UINT8 m_r4842;        // RTC status
171   
171
172172   UINT32 m_rtc_state;
173173   UINT32 m_rtc_mode;
174174   UINT32 m_rtc_index;
175   
175
176176   UINT64 m_rtc_offset;
177177
178178   //this is now allocated in the main snes cart class, to allow saving to nvram
179179   //UINT8 m_rtc_ram[16];  // 0-12 secs, min, hrs, etc.; 13-14-15 control registers
180   
180
181181   UINT8 m_ram[0x2000];
182182};
183183
r21591r21592
188188public:
189189   // construction/destruction
190190   sns_rom_spc7110rtc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
191   
191
192192   // device-level overrides
193193   virtual void device_start();
194194   virtual void device_config_complete() { m_shortname = "sns_rom_spc7110rtc"; }
195   
195
196196   // reading and writing
197197
198198// we just use the spc7110 ones for the moment, pending the split of regs 0x4840-0x4842 (RTC) from the base add-on
199//   virtual DECLARE_READ8_MEMBER(read_l);
200//   virtual DECLARE_READ8_MEMBER(read_h);
201//   virtual DECLARE_WRITE8_MEMBER(write_l);
202   
203//   virtual DECLARE_READ8_MEMBER(chip_read);
204//   virtual DECLARE_WRITE8_MEMBER(chip_write);
199//  virtual DECLARE_READ8_MEMBER(read_l);
200//  virtual DECLARE_READ8_MEMBER(read_h);
201//  virtual DECLARE_WRITE8_MEMBER(write_l);
202
203//  virtual DECLARE_READ8_MEMBER(chip_read);
204//  virtual DECLARE_WRITE8_MEMBER(chip_write);
205205};
206   
206
207207// device type definition
208208extern const device_type SNS_HIROM_SPC7110;
209209extern const device_type SNS_HIROM_SPC7110_RTC;
trunk/src/mess/machine/sns_sufami.c
r21591r21592
11/***********************************************************************************************************
2
2
33 Bandai Sufami Turbo cartridge emulation (for SNES/SFC)
4
4
55 Copyright MESS Team.
66 Visit http://mamedev.org for licensing and usage restrictions.
7
7
88 This is basically a standard LoROM cart with two slots for ST minicarts
99 The content of each slot (with ROM and RAM) is mapped to a separate memory range
1010 Slot 1: ROM [20-3f][8000-ffff], RAM [60-63][8000-ffff]
1111 Slot 2: ROM [40-5f][8000-ffff], RAM [70-73][8000-ffff]
12
12
1313 ***********************************************************************************************************/
1414
1515
r21591r21592
8181
8282READ8_MEMBER(sns_rom_sufami_device::read_h)
8383{
84   if (offset < 0x200000)      // SUFAMI TURBO ROM
84   if (offset < 0x200000)      // SUFAMI TURBO ROM
8585   {
8686      int bank = offset / 0x10000;
8787      return m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
8888   }
89   if (offset >= 0x200000 && offset < 0x400000)   // SLOT1 STROM
89   if (offset >= 0x200000 && offset < 0x400000)    // SLOT1 STROM
9090   {
9191      if (m_slot1->m_cart)
9292         return m_slot1->m_cart->read_l(space, offset - 0x200000);
9393   }
94   if (offset >= 0x400000 && offset < 0x600000)   // SLOT2 STROM
94   if (offset >= 0x400000 && offset < 0x600000)    // SLOT2 STROM
9595   {
9696      if (m_slot2->m_cart)
9797         return m_slot2->m_cart->read_l(space, offset - 0x400000);
9898   }
99   if (offset >= 0x600000 && offset < 0x640000)   // SLOT1 RAM
99   if (offset >= 0x600000 && offset < 0x640000)    // SLOT1 RAM
100100   {
101101      if (m_slot1->m_cart && (offset & 0xffff) > 0x8000)
102102         return m_slot1->m_cart->read_h(space, offset - 0x600000);
103103   }
104   if (offset >= 0x700000 && offset < 0x740000)   // SLOT2 RAM
104   if (offset >= 0x700000 && offset < 0x740000)    // SLOT2 RAM
105105   {
106106      if (m_slot2->m_cart && (offset & 0xffff) > 0x8000)
107107         return m_slot2->m_cart->read_h(space, offset - 0x700000);
108108   }
109   
109
110110   return 0xff;
111111}
112112
r21591r21592
117117
118118WRITE8_MEMBER(sns_rom_sufami_device::write_h)
119119{
120   if (offset >= 0x600000 && offset < 0x640000)   // SLOT1 RAM
120   if (offset >= 0x600000 && offset < 0x640000)    // SLOT1 RAM
121121   {
122122      if (m_slot1->m_cart && (offset & 0xffff) > 0x8000)
123123         return m_slot1->m_cart->write_h(space, offset - 0x600000, data);
124124   }
125   
126   if (offset >= 0x700000 && offset < 0x740000)   // SLOT2 RAM
125
126   if (offset >= 0x700000 && offset < 0x740000)    // SLOT2 RAM
127127   {
128128      if (m_slot2->m_cart && (offset & 0xffff) > 0x8000)
129129         return m_slot2->m_cart->write_h(space, offset - 0x700000, data);
130130   }
131   
131
132132}
133133
134134/*-------------------------------------------------
r21591r21592
172172      m_nvram[bank * 0x8000 + (offset & 0x7fff)] = data;
173173   }
174174}
175
176
trunk/src/mess/machine/sns_sufami.h
r21591r21592
1212public:
1313   // construction/destruction
1414   sns_rom_sufami_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
15   
15
1616   // device-level overrides
1717   virtual void device_start();
1818   virtual void device_config_complete() { m_shortname = "sns_rom_sufami"; }
1919   virtual machine_config_constructor device_mconfig_additions() const;
20   
20
2121   // additional reading and writing
2222   virtual DECLARE_READ8_MEMBER(read_l);
2323   virtual DECLARE_READ8_MEMBER(read_h);
r21591r21592
3636public:
3737   // construction/destruction
3838   sns_rom_strom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
39   
39
4040   // device-level overrides
4141   virtual void device_start();
4242   virtual void device_config_complete() { m_shortname = "sns_strom"; }
43   
43
4444   // additional reading and writing
45   virtual DECLARE_READ8_MEMBER(read_l);   // used for ROM
46   virtual DECLARE_READ8_MEMBER(read_h);   // used for ROM
47   virtual DECLARE_WRITE8_MEMBER(write_l);   // used for RAM
48   virtual DECLARE_WRITE8_MEMBER(write_h);   // used for RAM
45   virtual DECLARE_READ8_MEMBER(read_l);   // used for ROM
46   virtual DECLARE_READ8_MEMBER(read_h);   // used for ROM
47   virtual DECLARE_WRITE8_MEMBER(write_l); // used for RAM
48   virtual DECLARE_WRITE8_MEMBER(write_h); // used for RAM
4949};
5050
5151
trunk/src/mess/machine/sns_sdd1.c
r21591r21592
11/***********************************************************************************************************
2
2
33 S-DD1 add-on chip emulation (for SNES/SFC)
4
4
55 Based on Andreas Naive Public Domain code.
66 Code ported by MooglyGuy and updated to slots by Fabio Priuli.
7
7
88 Copyright MESS Team.
99 Visit http://mamedev.org for licensing and usage restrictions.
10
10
1111 ***********************************************************************************************************/
1212
1313
r21591r21592
3030UINT8 SDD1__IM::IM_getCodeword(UINT8 *ROM, UINT32 *mmc, const UINT8 code_len)
3131{
3232   UINT8 codeword = ROM[SSD1_ADD(m_byte_ptr)] << m_bit_count;
33   
33
3434   ++m_bit_count;
35   
35
3636   if (codeword & 0x80)
3737   {
3838      codeword |= ROM[SSD1_ADD((m_byte_ptr + 1))] >> (9 - m_bit_count);
3939      m_bit_count += code_len;
4040   }
41   
41
4242   if (m_bit_count & 0x08)
4343   {
4444      m_byte_ptr++;
4545      m_bit_count &= 0x07;
4646   }
47   
47
4848   return codeword;
4949}
5050
r21591r21592
8787      0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08,
8888      0x70, 0x30, 0x50, 0x10, 0x60, 0x20, 0x40, 0x00,
8989   };
90   
90
9191   UINT8 codeword = m_IM->IM_getCodeword(ROM, mmc, code_num);
92   
92
9393   if (codeword & 0x80)
9494   {
9595      *LPSind = 1;
r21591r21592
112112UINT8 SDD1__BG::BG_getBit(UINT8 *ROM, UINT32 *mmc, UINT8* endOfRun)
113113{
114114   UINT8 bit;
115   
115
116116   if (!(m_MPScount || m_LPSind))
117117   {
118118      m_GCD->GCD_getRunCount(ROM, mmc, m_code_num, &(m_MPScount), &(m_LPSind));
119119   }
120   
120
121121   if (m_MPScount)
122122   {
123123      bit = 0;
r21591r21592
128128      bit = 1;
129129      m_LPSind = 0;
130130   }
131   
131
132132   if (m_MPScount || m_LPSind)
133133   {
134134      (*endOfRun) = 0;
r21591r21592
137137   {
138138      (*endOfRun) = 1;
139139   }
140   
140
141141   return bit;
142142}
143143
r21591r21592
200200{
201201   UINT8 endOfRun;
202202   UINT8 bit;
203   
203
204204   SDD1__PEM_ContextInfo *pContInfo = &(m_contextInfo)[context];
205205   UINT8 currStatus = pContInfo->status;
206206   const SDD1__PEM_state* pState = &(PEM_evolution_table[currStatus]);
207207   UINT8 currentMPS = pContInfo->MPS;
208   
208
209209   bit = m_BG[pState->code_num]->BG_getBit(ROM, mmc, &endOfRun);
210   
210
211211   if (endOfRun)
212212   {
213213      if (bit)
r21591r21592
223223         pContInfo->status = pState->nextIfMPS;
224224      }
225225   }
226   
226
227227   return bit ^ currentMPS;
228228}
229229
r21591r21592
258258   UINT8 currContext;
259259   UINT16 *context_bits;
260260   UINT8 bit = 0;
261   
261
262262   switch (m_bitplanesInfo)
263263   {
264264      case 0x00:
r21591r21592
278278         m_currBitplane = m_bit_number & 0x07;
279279         break;
280280   }
281   
281
282282   context_bits = &(m_prevBitplaneBits)[m_currBitplane];
283   
283
284284   currContext = (m_currBitplane & 0x01) << 4;
285285   switch (m_contextBitsInfo)
286286   {
r21591r21592
297297         currContext |= ((*context_bits & 0x0180) >> 5) | (*context_bits & 0x0003);
298298         break;
299299   }
300   
300
301301   bit = m_PEM->PEM_getBit(ROM, mmc, currContext);
302   
302
303303   *context_bits <<= 1;
304304   *context_bits |= bit;
305   
305
306306   m_bit_number++;
307   
307
308308   return bit;
309309}
310310
r21591r21592
321321{
322322   UINT8 i;
323323   UINT8 register1 = 0, register2 = 0;
324   
324
325325   switch (m_bitplanesInfo)
326326   {
327327      case 0x00:
r21591r21592
341341               {
342342                  if (m_CM->CM_getBit(ROM, mmc))
343343                     register1 |= i;
344                 
344
345345                  if (m_CM->CM_getBit(ROM, mmc))
346346                     register2 |= i;
347347               }
r21591r21592
381381   m_BG6 = auto_alloc(machine, SDD1__BG(m_GCD, 6));
382382   m_BG7 = auto_alloc(machine, SDD1__BG(m_GCD, 7));
383383   m_PEM = auto_alloc(machine, SDD1__PEM(m_BG0, m_BG1, m_BG2, m_BG3,
384                              m_BG4, m_BG5, m_BG6, m_BG7));
384                                 m_BG4, m_BG5, m_BG6, m_BG7));
385385   m_CM = auto_alloc(machine, SDD1__CM(m_PEM));
386386   m_OL = auto_alloc(machine, SDD1__OL(m_CM));
387387}
r21591r21592
400400   m_PEM->PEM_prepareDecomp();
401401   m_CM->CM_prepareDecomp(ROM, mmc, in_buf);
402402   m_OL->OL_prepareDecomp(ROM, mmc, in_buf, out_len, out_buf);
403   
403
404404   m_OL->OL_launch(ROM, mmc);
405405}
406406
r21591r21592
428428void sns_rom_sdd1_device::device_start()
429429{
430430   UINT8 i;
431   
431
432432   m_sdd1_enable = 0x00;
433433   m_xfer_enable = 0x00;
434   
434
435435   m_mmc[0] = 0 << 20;
436436   m_mmc[1] = 1 << 20;
437437   m_mmc[2] = 2 << 20;
438438   m_mmc[3] = 3 << 20;
439   
439
440440   for(i = 0; i < 8; i++)
441441   {
442442      m_dma[i].addr = 0;
443443      m_dma[i].size = 0;
444444   }
445   
445
446446   m_sdd1emu = auto_alloc(machine(), SDD1__emu(machine()));
447   
447
448448   m_buffer.data = (UINT8*)auto_alloc_array(machine(), UINT8, 0x10000);
449449   m_buffer.ready = 0;
450450
r21591r21592
461461READ8_MEMBER( sns_rom_sdd1_device::chip_read )
462462{
463463   UINT16 addr = offset & 0xffff;
464   
464
465465   switch (addr)
466466   {
467467      case 0x4804:
r21591r21592
473473      case 0x4807:
474474         return (m_mmc[3] >> 20) & 7;
475475   }
476   
477//   we should never get here, but...
476
477//  we should never get here, but...
478478   return 0;
479479}
480480
r21591r21592
482482WRITE8_MEMBER( sns_rom_sdd1_device::chip_write )
483483{
484484   UINT16 addr = offset & 0xffff;
485   
485
486486   if ((addr & 0x4380) == 0x4300)
487487   {
488488      UINT8 channel = (addr >> 4) & 7;
r21591r21592
507507      }
508508      return;
509509   }
510   
510
511511   switch(addr)
512512   {
513513      case 0x4800:
r21591r21592
516516      case 0x4801:
517517         m_xfer_enable = data;
518518         break;
519         
519
520520      case 0x4804:
521521         m_mmc[0] = (data & 7) << 20;
522522         break;
r21591r21592
530530         m_mmc[3] = (data & 7) << 20;
531531         break;
532532   }
533   
533
534534}
535535
536536UINT8 sns_rom_sdd1_device::read_helper(UINT32 addr)
r21591r21592
552552                  // this really should stream byte-by-byte, but it's not necessary since the size is known
553553                  m_buffer.offset = 0;
554554                  m_buffer.size = m_dma[i].size ? m_dma[i].size : 65536;
555                 
555
556556                  // SDD1_emu calls this function; it needs to access uncompressed data;
557557                  // so temporarily disable decompression mode for decompress() call.
558558                  m_sdd1emu->SDD1emu_decompress(m_rom, m_mmc, addr, m_buffer.size, m_buffer.data);
559                 
559
560560                  m_buffer.ready = 1;
561561               }
562               
562
563563               // fetch a decompressed byte; once buffer is depleted, disable channel and invalidate buffer
564564               data = m_buffer.data[(UINT16)m_buffer.offset++];
565565               if (m_buffer.offset >= m_buffer.size)
r21591r21592
567567                  m_buffer.ready = 0;
568568                  m_xfer_enable &= ~(1 << i);
569569               }
570               
570
571571               return data;
572572            }
573573         }
r21591r21592
597597
598598WRITE8_MEMBER(sns_rom_sdd1_device::write_l)
599599{
600   if (offset >= 0x700000 && (offset & 0xffff) < 0x8000 && m_nvram_size > 0)   // SRAM
600   if (offset >= 0x700000 && (offset & 0xffff) < 0x8000 && m_nvram_size > 0)   // SRAM
601601      m_nvram[offset & 0x1fff] = data;
602602}
trunk/src/mess/machine/sns_sdd1.h
r21591r21592
99{
1010public:
1111   SDD1__IM() {}
12   
12
1313   UINT32 m_byte_ptr;
1414   UINT8 m_bit_count;
15   
15
1616   void IM_prepareDecomp(UINT32 in_buf);
1717   UINT8 IM_getCodeword(UINT8 *ROM, UINT32 *mmc, const UINT8 code_len);
1818};
r21591r21592
2222public:
2323   SDD1__GCD(SDD1__IM* associatedIM)
2424   : m_IM(associatedIM) { }
25   
25
2626   SDD1__IM* m_IM;
27   
27
2828   void GCD_getRunCount(UINT8 *ROM, UINT32 *mmc, UINT8 code_num, UINT8* MPScount, UINT8* LPSind);
2929};
3030
r21591r21592
3434   SDD1__BG(SDD1__GCD* associatedGCD, UINT8 code)
3535   : m_code_num(code),
3636   m_GCD(associatedGCD) { }
37   
37
3838   UINT8 m_code_num;
3939   UINT8 m_MPScount;
4040   UINT8 m_LPSind;
4141   SDD1__GCD* m_GCD;
42   
42
4343   void BG_prepareDecomp();
4444   UINT8 BG_getBit(UINT8 *ROM, UINT32 *mmc, UINT8* endOfRun);
4545} ;
r21591r21592
5454{
5555public:
5656   SDD1__PEM(
57          SDD1__BG* associatedBG0, SDD1__BG* associatedBG1,
58          SDD1__BG* associatedBG2, SDD1__BG* associatedBG3,
59          SDD1__BG* associatedBG4, SDD1__BG* associatedBG5,
60          SDD1__BG* associatedBG6, SDD1__BG* associatedBG7)
57            SDD1__BG* associatedBG0, SDD1__BG* associatedBG1,
58            SDD1__BG* associatedBG2, SDD1__BG* associatedBG3,
59            SDD1__BG* associatedBG4, SDD1__BG* associatedBG5,
60            SDD1__BG* associatedBG6, SDD1__BG* associatedBG7)
6161   {
6262      m_BG[0] = associatedBG0;
6363      m_BG[1] = associatedBG1;
r21591r21592
6868      m_BG[6] = associatedBG6;
6969      m_BG[7] = associatedBG7;
7070   }
71   
71
7272   SDD1__PEM_ContextInfo m_contextInfo[32];
7373   SDD1__BG* m_BG[8];
74   
74
7575   void PEM_prepareDecomp();
7676   UINT8 PEM_getBit(UINT8 *ROM, UINT32 *mmc, UINT8 context);
7777} ;
r21591r21592
8282public:
8383   SDD1__CM(SDD1__PEM* associatedPEM)
8484   : m_PEM(associatedPEM) { }
85   
85
8686   UINT8 m_bitplanesInfo;
8787   UINT8 m_contextBitsInfo;
8888   UINT8 m_bit_number;
8989   UINT8 m_currBitplane;
9090   UINT16 m_prevBitplaneBits[8];
9191   SDD1__PEM* m_PEM;
92   
92
9393   void CM_prepareDecomp(UINT8 *ROM, UINT32 *mmc, UINT32 first_byte);
9494   UINT8 CM_getBit(UINT8 *ROM, UINT32 *mmc);
9595} ;
r21591r21592
100100public:
101101   SDD1__OL(SDD1__CM* associatedCM)
102102   : m_CM(associatedCM) { }
103   
103
104104   UINT8 m_bitplanesInfo;
105105   UINT16 m_length;
106106   UINT8* m_buffer;
107107   SDD1__CM* m_CM;
108   
108
109109   void OL_prepareDecomp(UINT8 *ROM, UINT32 *mmc, UINT32 first_byte, UINT16 out_len, UINT8 *out_buf);
110110   void OL_launch(UINT8 *ROM, UINT32 *mmc);
111111} ;
r21591r21592
114114{
115115public:
116116   SDD1__emu(running_machine &machine);
117   
117
118118   running_machine &machine() const { return m_machine; }
119   
119
120120   SDD1__IM* m_IM;
121121   SDD1__GCD* m_GCD;
122122   SDD1__BG* m_BG0;   SDD1__BG* m_BG1;   SDD1__BG* m_BG2;   SDD1__BG* m_BG3;
r21591r21592
124124   SDD1__PEM* m_PEM;
125125   SDD1__CM* m_CM;
126126   SDD1__OL* m_OL;
127   
127
128128   void SDD1emu_decompress(UINT8 *ROM, UINT32 *mmc, UINT32 in_buf, UINT16 out_len, UINT8 *out_buf);
129   
129
130130private:
131131   running_machine& m_machine;
132132};
r21591r21592
136136// ======================> sns_rom_sdd1_device
137137
138138class sns_rom_sdd1_device : public device_t,
139                 public device_sns_cart_interface
139                  public device_sns_cart_interface
140140{
141141public:
142142   // construction/destruction
143143   sns_rom_sdd1_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
144144   sns_rom_sdd1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
145   
145
146146   // device-level overrides
147147   virtual void device_start();
148148   virtual void device_config_complete() { m_shortname = "sns_rom_sdd1"; }
r21591r21592
159159   UINT8 m_sdd1_enable;  // channel bit-mask
160160   UINT8 m_xfer_enable;  // channel bit-mask
161161   UINT32 m_mmc[4];      // memory map controller ROM indices
162   
162
163163   struct
164164   {
165165      UINT32 addr;    // $43x2-$43x4 -- DMA transfer address
166166      UINT16 size;    // $43x5-$43x6 -- DMA transfer size
167167   } m_dma[8];
168   
168
169169   SDD1__emu* m_sdd1emu;
170170
171171   struct
trunk/src/mess/machine/sns_rom21.c
r21591r21592
11/***********************************************************************************************************
2
2
33 Super NES/Famicom (HiROM) cartridge emulation (for SNES/SFC)
4
4
55 Copyright MESS Team.
66 Visit http://mamedev.org for licensing and usage restrictions.
7
7
88 ***********************************************************************************************************/
99
1010
r21591r21592
5151   m_index = -1;
5252
5353// at this stage, rtc_ram is not yet allocated. this will be fixed when converting RTC to be a separate device.
54//   update_time();
54//  update_time();
5555
5656   save_item(NAME(m_mode));
5757   save_item(NAME(m_index));
r21591r21592
6666READ8_MEMBER(sns_rom21_device::read_l)
6767{
6868   UINT16 address = offset & 0xffff;
69   
69
7070   if (offset >= 0x300000 && offset < 0x400000 && address < 0x8000)
7171   {
7272      if (m_nvram_size > 0)
r21591r21592
7777         return m_nvram[(offset - 0x6000) & mask];
7878      }
7979   }
80   
80
8181   // here ROM banks from 128 to 255, mirrored twice
8282   int bank = (offset & 0x3fffff) / 0x8000;
8383   return m_rom[rom_bank_map[bank + 0x80] * 0x8000 + (offset & 0x7fff)];
r21591r21592
8686READ8_MEMBER(sns_rom21_device::read_h)
8787{
8888   UINT16 address = offset & 0xffff;
89   
89
9090   if (offset >= 0x300000 && offset < 0x400000 && address < 0x8000)
9191   {
9292      if (m_nvram_size > 0)
r21591r21592
9797         return m_nvram[(offset - 0x6000) & mask];
9898      }
9999   }
100   
100
101101   // here ROM banks from 0 to 127, mirrored twice
102102   int bank = (offset & 0x3fffff) / 0x8000;
103103   return m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
r21591r21592
111111WRITE8_MEMBER(sns_rom21_device::write_h)
112112{
113113   UINT16 address = offset & 0xffff;
114   
114
115115   if (offset >= 0x300000 && offset < 0x400000 && address < 0x8000)
116116   {
117117      if (m_nvram_size > 0)
r21591r21592
127127// Hi-ROM + S-RTC (used by Daikaijuu Monogatari II)
128128// same as above but additional read/write handling for the RTC
129129/***************************************************************************
130
130
131131 Based on C++ implementation by Byuu in BSNES.
132
132
133133 Byuu's code is released under GNU General Public License
134134 version 2 as published by the Free Software Foundation.
135
135
136136 The implementation below is released under the MAME license
137137 for use in MAME, MESS and derivatives by permission of Byuu
138
138
139139 Copyright (for the implementation below) MESS Team.
140140 Visit http://mamedev.org for licensing and usage restrictions.
141
141
142142 ***************************************************************************/
143143
144144static const UINT8 srtc_months[12] =
r21591r21592
175175{
176176   UINT32 y = 1900, m = 1; // Epoch is 1900-01-01
177177   UINT32 sum = 0;         // Number of days passed since epoch
178   
178
179179   year = MAX(1900, year);
180180   month = MAX(1, MIN(12, month));
181181   day = MAX(1, MIN(31, day));
182   
182
183183   while (y < year)
184184   {
185185      UINT8 leapyear = 0;
r21591r21592
194194      sum += leapyear ? 366 : 365;
195195      y++;
196196   }
197   
197
198198   while (m < month)
199199   {
200200      UINT32 days = srtc_months[m - 1];
r21591r21592
214214      sum += days;
215215      m++;
216216   }
217   
217
218218   sum += day - 1;
219219   return (sum + 1) % 7; // 1900-01-01 was a Monday
220220}
221221
222222
223223// this gets called only for accesses at 0x2800,
224// because for 0x2801 open bus gets returned...   
224// because for 0x2801 open bus gets returned...
225225READ8_MEMBER(sns_rom21_srtc_device::chip_read)
226226{
227227   if (m_mode != RTCM_Read)
228228      return 0x00;
229     
229
230230   if (m_index < 0)
231231   {
232232      update_time();
r21591r21592
246246WRITE8_MEMBER(sns_rom21_srtc_device::chip_write)
247247{
248248   data &= 0x0f;   // Only the low four bits are used
249   
249
250250   if (data == 0x0d)
251251   {
252252      m_mode = RTCM_Read;
253253      m_index = -1;
254254      return;
255255   }
256   
256
257257   if (data == 0x0e)
258258   {
259259      m_mode = RTCM_Command;
260260      return;
261261   }
262   
262
263263   if (data == 0x0f)
264264      return; // Unknown behaviour
265   
265
266266   if (m_mode == RTCM_Write)
267267   {
268268      if (m_index >= 0 && m_index < 12)
269269      {
270270         m_rtc_ram[m_index++] = data;
271         
271
272272         if (m_index == 12)
273273         {
274274            // Day of week is automatically calculated and written
r21591r21592
276276            UINT32 month = m_rtc_ram[8];
277277            UINT32 year  = m_rtc_ram[9] + m_rtc_ram[10] * 10 + m_rtc_ram[11] * 100;
278278            year += 1000;
279           
279
280280            m_rtc_ram[m_index++] = srtc_weekday(year, month, day);
281281         }
282282      }
r21591r21592
303303      }
304304   }
305305}
306
trunk/src/mess/machine/sns_rom21.h
r21591r21592
77// ======================> sns_rom21_device
88
99class sns_rom21_device : public device_t,
10                 public device_sns_cart_interface
10                  public device_sns_cart_interface
1111{
1212public:
1313   // construction/destruction
1414   sns_rom21_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
1515   sns_rom21_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
16   
16
1717   // device-level overrides
1818   virtual void device_start();
1919   virtual void device_config_complete() { m_shortname = "sns_rom21"; }
r21591r21592
3232public:
3333   // construction/destruction
3434   sns_rom21_srtc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
35   
35
3636   // device-level overrides
3737   virtual void device_start();
3838   virtual void device_config_complete() { m_shortname = "sns_rom21_srtc"; }
39   
39
4040   // reading and writing
4141   virtual DECLARE_READ8_MEMBER(chip_read);
4242   virtual DECLARE_WRITE8_MEMBER(chip_write);
r21591r21592
4949      RTCM_Read,
5050      RTCM_Write
5151   };
52   
52
5353   void update_time();
5454   UINT8 srtc_weekday(UINT32 year, UINT32 month, UINT32 day);
55   
55
5656   //this is now allocated in the main snes cart class, to allow saving to nvram
5757   //UINT8  m_rtc_ram[13];
5858   INT32  m_mode;
trunk/src/mess/machine/sns_slot.c
r21591r21592
11/***********************************************************************************************************
2 
32
3
44    SNES cart emulation
55    (through slot devices)
66
77
8
8
99 ***********************************************************************************************************/
1010
1111
r21591r21592
9696
9797
9898//-------------------------------------------------
99//  addon_bios_alloc - alloc the space for the
99//  addon_bios_alloc - alloc the space for the
100100//  (optional) add-on CPU bios
101101//-------------------------------------------------
102102
r21591r21592
111111
112112
113113//-------------------------------------------------
114//  rom_map_setup - setup map of rom banks in 32K
114//  rom_map_setup - setup map of rom banks in 32K
115115//  blocks, so to simplify ROM access
116116//-------------------------------------------------
117117
118118void device_sns_cart_interface::rom_map_setup(UINT32 size)
119119{
120120   int i;
121   // setup the rom_bank_map array to faster ROM read
121   // setup the rom_bank_map array to faster ROM read
122122   for (i = 0; i < size / 0x8000; i++)
123123      rom_bank_map[i] = i;
124   
124
125125   // fill up remaining blocks with mirrors
126126   while (i % 256)
127127   {
r21591r21592
135135   }
136136
137137// check bank map!
138//   for (i = 0; i < 256; i++)
139//   {
140//      printf("bank %3d = %3d\t", i, rom_bank_map[i]);
141//      if ((i%8) == 7)
142//         printf("\n");
143//   }
138//  for (i = 0; i < 256; i++)
139//  {
140//      printf("bank %3d = %3d\t", i, rom_bank_map[i]);
141//      if ((i%8) == 7)
142//          printf("\n");
143//  }
144144}
145145
146146//**************************************************************************
r21591r21592
244244   { SNES_STROM,       "strom"},
245245   // pirate carts
246246   { SNES_POKEMON,     "lorom_poke"},
247   { SNES_BANANA,      "lorom_paja"},   // wip
248   { SNES_SOULBLAD,    "lorom_sbld"}   // wip
247   { SNES_BANANA,      "lorom_paja"},  // wip
248   { SNES_SOULBLAD,    "lorom_sbld"}   // wip
249249};
250250
251251static int sns_get_pcb_id(const char *slot)
r21591r21592
255255      if (!mame_stricmp(slot_list[i].slot_option, slot))
256256         return slot_list[i].pcb_id;
257257   }
258   
258
259259   return 0;
260260}
261261
r21591r21592
266266      if (slot_list[i].pcb_id == type)
267267         return slot_list[i].slot_option;
268268   }
269   
269
270270   return "lorom";
271271}
272272
r21591r21592
285285{
286286   UINT8 header[512];
287287   UINT32 offset = 512;
288   
288
289289   /* Check for a header (512 bytes) */
290290   memcpy(header, ROM, 512);
291   
291
292292   if ((header[8] == 0xaa) && (header[9] == 0xbb) && (header[10] == 0x04))
293293   {
294294      /* Found an SWC identifier */
r21591r21592
310310      logerror("No header found.\n");
311311      offset = 0;
312312   }
313   
313
314314   return offset;
315315}
316316
r21591r21592
326326   UINT16 ichecksum    = infoblock[offset + 0x1c] | (infoblock[offset + 0x1d] << 8);
327327   UINT8 reset_opcode  = infoblock[(offset & ~0x7fff) | (reset_vector & 0x7fff)];  //first opcode executed upon reset
328328   UINT8 mapper        = infoblock[offset + 0x15] & ~0x10;                         //mask off irrelevant FastROM-capable bit
329   
329
330330   /* $00:[000-7fff] contains uninitialized RAM and MMIO.
331331    reset vector must point to ROM at $00:[8000-ffff] to be considered valid. */
332332   if (reset_vector < 0x8000)
333333      return 0;
334   
334
335335   /* some images duplicate the header in multiple locations, and others have completely
336336    invalid header information that cannot be relied upon. The code below will analyze
337337    the first opcode executed at the specified reset vector to determine the probability
338338    that this is the correct header. Score is assigned accordingly. */
339   
339
340340   /* most likely opcodes */
341341   if (reset_opcode == 0x78        //sei
342342      || reset_opcode == 0x18     //clc (clc; xce)
r21591r21592
346346      || reset_opcode == 0x5c     //jml $nnnnnn
347347      )
348348      score += 8;
349   
349
350350   /* plausible opcodes */
351351   if (reset_opcode == 0xc2        //rep #$nn
352352      || reset_opcode == 0xe2     //sep #$nn
r21591r21592
361361      || reset_opcode == 0x22     //jsl $nnnnnn
362362      )
363363      score += 4;
364   
364
365365   /* implausible opcodes */
366366   if (reset_opcode == 0x40        //rti
367367      || reset_opcode == 0x60     //rts
r21591r21592
371371      || reset_opcode == 0xcc     //cpy $nnnn
372372      )
373373      score -= 4;
374   
374
375375   /* least likely opcodes */
376376   if (reset_opcode == 0x00        //brk #$nn
377377      || reset_opcode == 0x02     //cop #$nn
r21591r21592
380380      || reset_opcode == 0xff     //sbc $nnnnnn,x
381381      )
382382      score -= 8;
383   
383
384384   /* Sometimes, both the header and reset vector's first opcode will match ...
385385    fallback and rely on info validity in these cases to determine more likely header. */
386   
386
387387   /* a valid checksum is the biggest indicator of a valid header. */
388388   if ((checksum + ichecksum) == 0xffff && (checksum != 0) && (ichecksum != 0))
389389      score += 4;
390   
390
391391   /* then there are the expected mapper values */
392392   if (offset == 0x007fc0 && mapper == 0x20)   // 0x20 is usually LoROM
393393      score += 2;
394   
394
395395   if (offset == 0x00ffc0 && mapper == 0x21)   // 0x21 is usually HiROM
396396      score += 2;
397   
397
398398   if (offset == 0x007fc0 && mapper == 0x22)   // 0x22 is usually ExLoROM
399399      score += 2;
400   
400
401401   if (offset == 0x40ffc0 && mapper == 0x25)   // 0x25 is usually ExHiROM
402402      score += 2;
403   
403
404404   /* finally, there are valid values in the Company, Region etc. fields */
405405   if (infoblock[offset + 0x1a] == 0x33)           // Company field: 0x33 indicates extended header
406406      score += 2;
407   
407
408408   if (infoblock[offset + 0x16] < 0x08)            // ROM Type field
409409      score++;
410   
410
411411   if (infoblock[offset + 0x17] < 0x10)            // ROM Size field
412412      score++;
413   
413
414414   if (infoblock[offset + 0x18] < 0x08)            // SRAM Size field
415415      score++;
416   
416
417417   if (infoblock[offset + 0x19] < 14)              // Region field
418418      score++;
419   
419
420420   /* do we still have a positive score? */
421421   if (score < 0)
422422      score = 0;
423   
423
424424   return score;
425425}
426426
r21591r21592
445445   /* Images larger than 32mbits are likely ExHiRom */
446446   if (valid_mode25)
447447      valid_mode25 += 4;
448   
448
449449   if ((valid_mode20 >= valid_mode21) && (valid_mode20 >= valid_mode25))
450      retvalue = 0x007fc0;     
450      retvalue = 0x007fc0;
451451   else if (valid_mode21 >= valid_mode25)
452452      retvalue = 0x00ffc0;
453453   else
454454      retvalue = 0x40ffc0;
455   
455
456456   logerror( "\t HiROM/LoROM id: %s (LoROM: %d , HiROM: %d, ExHiROM: %d)\n",
457          (retvalue == 0x007fc0) ? "LoROM" :
458          (retvalue == 0x00ffc0) ? "HiROM" :
459          (retvalue == 0x40ffc0) ? "ExHiROM" : "Other",
460          valid_mode20, valid_mode21, valid_mode25);
461   
457            (retvalue == 0x007fc0) ? "LoROM" :
458            (retvalue == 0x00ffc0) ? "HiROM" :
459            (retvalue == 0x40ffc0) ? "ExHiROM" : "Other",
460            valid_mode20, valid_mode21, valid_mode25);
461
462462   return retvalue;
463463}
464464
r21591r21592
472472      case 0x01:
473473      case 0x02:
474474         break;
475         
475
476476      case 0x03:
477477         if (buffer[start_offs + 0x15] == 0x30)
478478            return SNES_DSP4;
479479         else
480480            return SNES_DSP;
481         
481
482482      case 0x04:
483483         return SNES_DSP;
484         
484
485485      case 0x05:
486486         // DSP2 can be detected by (buffer[start_offs + 0x15] == 0x20)
487         // DSP3 is harder to detect, and one has to rely on the manufacturer (Bandai)
487         // DSP3 is harder to detect, and one has to rely on the manufacturer (Bandai)
488488         //      by checking (buffer[start_offs + 0x15] == 0x30) && (buffer[start_offs + 0x1a] == 0xb2)
489489         // in other cases is DSP1, but we do treat all these together...
490490         return SNES_DSP;
491         
491
492492      case 0x13:  // Mario Chip 1
493493      case 0x14:  // GSU-x
494494      case 0x15:  // GSU-x
r21591r21592
496496         if (buffer[start_offs + 0x15] == 0x20)
497497            return SNES_SFX;
498498         break;
499         
499
500500      case 0x25:
501501         return SNES_OBC1;
502         
502
503503      case 0x32:  // needed by a Sample game (according to ZSNES)
504504      case 0x34:
505505      case 0x35:
506506         if (buffer[start_offs + 0x15] == 0x23)
507507            return SNES_SA1;
508508         break;
509         
509
510510      case 0x43:
511511      case 0x45:
512512         if (buffer[start_offs + 0x15] == 0x32)
513513            return SNES_SDD1;
514514         break;
515         
515
516516      case 0x55:
517517         if (buffer[start_offs + 0x15] == 0x35)
518518            return SNES_SRTC;
519519         break;
520         
520
521521      case 0xe3:
522522         return SNES_Z80GB;
523         
523
524524      case 0xf3:
525525         return SNES_CX4;
526         
526
527527      case 0xf5:
528528         if (buffer[start_offs + 0x15] == 0x30)
529529            return SNES_ST018;
530530         else if (buffer[start_offs + 0x15] == 0x3a)
531531            return SNES_SPC7110;
532532         break;
533         
533
534534      case 0xf6:
535535         /* These Seta ST-01X chips have both 0x30 at 0xffd5,
536536          they only differ for the 'size' at 0xffd7 */
r21591r21592
538538            return SNES_ST011;
539539         else
540540            return SNES_ST010;
541         
541
542542      case 0xf9:
543543         if (buffer[start_offs + 0x15] == 0x3a)
544544            return SNES_SPC7110_RTC;
545545         break;
546         
546
547547      default:
548548         break;
549549   }
r21591r21592
585585
586586      m_cart->rom_map_setup(len);
587587
588      // check for on-cart CPU bios
588      // check for on-cart CPU bios
589589      if (software_entry() != NULL)
590590      {
591591         if (get_software_region("addon"))
r21591r21592
605605         else
606606            m_type = sns_get_pcb_id(slot_name);
607607      }
608     
609608
609
610610      setup_custom_mappers();
611         
611
612612      setup_nvram();
613613
614614      if (m_cart->get_nvram_size() || m_cart->get_rtc_ram_size())
r21591r21592
620620            memcpy(m_cart->get_nvram_base(), temp_nvram, m_cart->get_nvram_size());
621621         if (m_cart->get_rtc_ram_size())
622622            memcpy(m_cart->get_rtc_ram_base(), temp_nvram + m_cart->get_nvram_size(), m_cart->get_rtc_ram_size());
623         
623
624624         if (temp_nvram)
625625            auto_free(machine(), temp_nvram);
626626      }
627     
627
628628      printf("Type %d\n", m_type);
629629
630630      internal_header_logging(ROM, len);
631631
632632      return IMAGE_INIT_PASS;
633633   }
634   
634
635635   return IMAGE_INIT_PASS;
636636}
637637
r21591r21592
652652            memcpy(temp_nvram, m_cart->get_nvram_base(), m_cart->get_nvram_size());
653653         if (m_cart->get_rtc_ram_size())
654654            memcpy(temp_nvram + m_cart->get_nvram_size(), m_cart->get_rtc_ram_base(), m_cart->get_rtc_ram_size());
655         
655
656656         battery_save(temp_nvram, tot_size);
657657         if (temp_nvram)
658658            auto_free(machine(), temp_nvram);
r21591r21592
676676      UINT8 sram_size = (m_type == SNES_SFX) ? (ROM[0x00ffbd] & 0x07) : (ROM[hilo_mode + 0x18] & 0x07);
677677      if (sram_size)
678678      {
679         UINT32 max = (hilo_mode == 0x007fc0) ? 0x80000 : 0x20000;   // MODE20 vs MODE21
679         UINT32 max = (hilo_mode == 0x007fc0) ? 0x80000 : 0x20000;   // MODE20 vs MODE21
680680         size = 1024 << (ROM[0x00ffbd] & 0x07);
681681         if (size > max)
682682            size = max;
r21591r21592
729729         break;
730730      case 0x00ffc0: // HiRom
731731      case 0x40ffc0: // ExHiRom
732         type = SNES_MODE21;
732         type = SNES_MODE21;
733733         break;
734734      default:
735735         break;
736736   }
737   
737
738738   // detect Sufami Turbo...
739739   if (type == SNES_MODE20 && !memcmp(ROM, "BANDAI SFC-ADX", 14))
740740   {
r21591r21592
757757            type = SNES_BSMEMPAK;
758758      }
759759   }
760   
760
761761   // check for add-on chips...
762762   if (len >= hilo_mode + 0x1a)
763763   {
r21591r21592
808808      int type;
809809
810810      core_fread(m_file, ROM, len);
811     
811
812812      type = get_cart_type(ROM, len);
813813      slot_string = sns_get_slot(type);
814     
814
815815      global_free(ROM);
816816      clear();
817   
817
818818      return slot_string;
819819   }
820820
r21591r21592
882882static int char_to_int_conv( char id )
883883{
884884   int value;
885   
885
886886   if (id == '1') value = 0x01;
887887   else if (id == '2') value = 0x02;
888888   else if (id == '3') value = 0x03;
r21591r21592
899899   else if (id == 'E') value = 0x0e;
900900   else if (id == 'F') value = 0x0f;
901901   else value = 0x00;
902   
902
903903   return value;
904904}
905905
r21591r21592
939939      UNK,
940940      UNK
941941   };
942   
942
943943   /* Some known countries */
944944   static const char *const countries[] =
945945   {
r21591r21592
948948      /* 8*/  "Spain (PAL)", "Germany, Austria & Switzerland (PAL)", "Italy (PAL)", "Hong Kong & China (PAL)",
949949      /* c*/  "Indonesia (PAL)", "South Korea (NTSC)", UNK, UNK,
950950   };
951   
951
952952   /* Some known companies (integrations to the list from Snes9x) */
953953   static const char *const companies[] =
954954   {
r21591r21592
10071007      default:
10081008         break;
10091009   }
1010   
1010
10111011   // detect Sufami Turbo...
10121012   if (type == SNES_MODE20 && !memcmp(ROM, "BANDAI SFC-ADX", 14))
10131013   {
r21591r21592
10161016      else
10171017         type = SNES_STROM;
10181018   }
1019   
1019
10201020   // detect BS-X Base Cart
10211021   if (!memcmp(ROM + hilo_mode, "Satellaview BS-X     ", 21))
10221022      type = SNES_BSX;
r21591r21592
10301030            type = SNES_BSMEMPAK;
10311031      }
10321032   }
1033   
1033
10341034   addon = snes_find_addon_chip(ROM, hilo_mode);
10351035   if (addon != -1)
10361036   {
r21591r21592
10411041      else
10421042         type = addon;
10431043   }
1044   
1044
10451045   /* Company */
10461046   for (int i = 0; i < 2; i++)
10471047      company_id[i] = ROM[hilo_mode - 0x10 + i];
10481048   company = (char_to_int_conv(company_id[0]) << 4) + char_to_int_conv(company_id[1]);
10491049   if (company == 0)
10501050      company = ROM[hilo_mode + 0x1a];
1051   
1051
10521052   /* ROM ID */
10531053   for(int i = 0; i < 4; i++ )
10541054      rom_id[i] = ROM[hilo_mode - 0x0d + i];
1055   
1055
10561056   /* Title */
10571057   for(int i = 0; i < 21; i++ )
10581058      title[i] = ROM[hilo_mode + i];
1059   
1059
10601060   /* RAM */
10611061   if (((ROM[hilo_mode + 0x16] & 0xf) == 1) ||
10621062      ((ROM[hilo_mode + 0x16] & 0xf) == 2) ||
10631063      ((ROM[hilo_mode + 0x16] & 0xf) == 4) ||
10641064      ((ROM[hilo_mode + 0x16] & 0xf) == 5))
10651065      has_ram = 1;
1066   
1066
10671067   /* SRAM */
10681068   if (((ROM[hilo_mode + 0x16] & 0xf) == 2) ||
10691069      ((ROM[hilo_mode + 0x16] & 0xf) == 5) ||
10701070      ((ROM[hilo_mode + 0x16] & 0xf) == 6))
10711071      has_sram = 1;
1072   
1072
10731073   logerror( "ROM DETAILS\n" );
10741074   logerror( "===========\n\n" );
10751075   logerror( "\tTotal blocks:  0x%x\n", len);
10761076   logerror( "\tROM bank size: %s \n",
1077          (type == SNES_MODE20) ? "LoROM" :
1078          (type == SNES_MODE21) ? "HiROM" :
1079          (type == SNES_MODE22) ? "ExLoROM" :
1080          (type == SNES_MODE25) ? "ExHiROM" : "Other (BSX or ST)" );
1077            (type == SNES_MODE20) ? "LoROM" :
1078            (type == SNES_MODE21) ? "HiROM" :
1079            (type == SNES_MODE22) ? "ExLoROM" :
1080            (type == SNES_MODE25) ? "ExHiROM" : "Other (BSX or ST)" );
10811081   logerror( "\tCompany:       %s [%.2s]\n", companies[company], company_id );
10821082   logerror( "\tROM ID:        %.4s\n\n", rom_id );
1083   
1083
10841084   logerror( "HEADER DETAILS\n" );
10851085   logerror( "==============\n\n" );
10861086   logerror( "\tName:          %.21s\n", title );
10871087   logerror( "\tSpeed:         %s [%d]\n", (ROM[hilo_mode + 0x15] & 0xf0) ? "FastROM" : "SlowROM", (ROM[hilo_mode + 0x15] & 0xf0) >> 4);
10881088   logerror( "\tBank size:     %s [%d]\n", (ROM[hilo_mode + 0x15] & 0xf) ? "HiROM" : "LoROM", ROM[hilo_mode + 0x15] & 0xf);
1089   
1089
10901090   logerror( "\tType:          %s", cart_types[type]);
10911091   if (has_ram)
10921092      logerror( ", RAM");
10931093   if (has_sram)
10941094      logerror( ", SRAM");
10951095   logerror( " [%d]\n", ROM[hilo_mode + 0x16]);
1096   
1096
10971097   logerror( "\tSize:          %d megabits [%d]\n", 1 << (ROM[hilo_mode + 0x17] - 7), ROM[hilo_mode + 0x17]);
10981098   logerror( "\tSRAM:          %d kilobits [%d]\n", ROM[hilo_mode + 0x18] * 8, ROM[hilo_mode + 0x18] );
10991099   logerror( "\tCountry:       %s [%d]\n", countries[ROM[hilo_mode + 0x19]], ROM[hilo_mode + 0x19]);
r21591r21592
11031103   logerror( "\tChecksum:      %X %X\n", ROM[hilo_mode + 0x1f], ROM[hilo_mode + 0x1e]);
11041104   logerror( "\tNMI Address:   %2X%2Xh\n", ROM[hilo_mode + 0x2b], ROM[hilo_mode + 0x2a]);
11051105   logerror( "\tStart Address: %2X%2Xh\n\n", ROM[hilo_mode + 0x2d], ROM[hilo_mode + 0x2c]);
1106   
1106
11071107   logerror( "\tMode: %d\n", type);
11081108}
trunk/src/mess/machine/sns_slot.h
r21591r21592
1111{
1212   SNES_MODE20 = 0,
1313   SNES_MODE21,
14   SNES_MODE22,   // ExLoROM - not used anymore in emulation (only to log info), will be removed
15   SNES_MODE25,   // ExHiROM - not used anymore in emulation (only to log info), will be removed
14   SNES_MODE22,    // ExLoROM - not used anymore in emulation (only to log info), will be removed
15   SNES_MODE25,    // ExHiROM - not used anymore in emulation (only to log info), will be removed
1616   SNES_CX4,
1717   SNES_DSP,
1818   SNES_DSP_MODE21,
r21591r21592
3636   SNES_STROM,
3737   // pirate carts
3838   SNES_POKEMON,
39   SNES_BANANA,   // wip
40   SNES_SOULBLAD   // wip
39   SNES_BANANA,    // wip
40   SNES_SOULBLAD   // wip
4141};
4242
4343
r21591r21592
7979   virtual UINT32 get_rtc_ram_size() { return m_rtc_ram_size; };
8080
8181   virtual void rom_map_setup(UINT32 size);
82   
82
8383   // internal state
8484   UINT8      *m_rom;
8585   UINT8      *m_nvram;
8686   UINT8      *m_bios;
87   UINT8      *m_rtc_ram;   // temp pointer to save RTC ram to nvram (will disappear when RTCs become devices)
87   UINT8      *m_rtc_ram;  // temp pointer to save RTC ram to nvram (will disappear when RTCs become devices)
8888   UINT32 m_rom_size;
8989   UINT32 m_nvram_size;
9090   UINT32 m_bios_size;
91   UINT32 m_rtc_ram_size;   // temp
91   UINT32 m_rtc_ram_size;  // temp
9292
93   UINT8 rom_bank_map[256];   // 32K chunks of rom
93   UINT8 rom_bank_map[256];    // 32K chunks of rom
9494};
9595
9696
r21591r21592
105105   // construction/destruction
106106   base_sns_cart_slot_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
107107   virtual ~base_sns_cart_slot_device();
108   
108
109109   // device-level overrides
110110   virtual void device_start();
111111   virtual void device_config_complete();
112   
112
113113   // image-level overrides
114114   virtual bool call_load();
115115   virtual void call_unload();
r21591r21592
146146// this should be private, but then there is some problem installing delegates in the driver...
147147//private:
148148
149   device_sns_cart_interface*      m_cart;
150   
149   device_sns_cart_interface*      m_cart;
150
151151   int m_type;
152152};
153153
trunk/src/mess/machine/snescart.c
r21591r21592
13121312#include "machine/snesrtc.c"
13131313#include "machine/snessdd1.c"
13141314#include "machine/snes7110.c"
1315

Previous 199869 Revisions Next


© 1997-2024 The MAME Team