Previous 199869 Revisions Next

r32299 Tuesday 23rd September, 2014 at 06:18:02 UTC by Fabio Priuli
fixed multisession crash when the new cart needed a dynamic buffer/array
larger than the original one. this got introduced when converting from
auto_alloc_array to dynamic buffers, because such buffers are not made
NULL at reset, but got unnoticed/unreported up to now. many thanks to
Trebor for catching it! nw.
[src/emu/bus/a7800]a78_slot.c a78_slot.h
[src/emu/bus/a800]a800_slot.c a800_slot.h
[src/emu/bus/gameboy]gb_slot.c
[src/emu/bus/gba]gba_slot.c
[src/emu/bus/megadrive]md_slot.c md_slot.h
[src/emu/bus/nes]nes_slot.c
[src/emu/bus/pce]pce_slot.c
[src/emu/bus/saturn]sat_slot.c
[src/emu/bus/sega8]sega8_slot.c
[src/emu/bus/snes]snes_slot.c
[src/emu/bus/vcs]vcs_slot.c
[src/mess/drivers]a7800.c atari400.c

trunk/src/emu/bus/gameboy/gb_slot.c
r32298r32299
5757
5858void device_gb_cart_interface::rom_alloc(UINT32 size)
5959{
60   if (m_rom == NULL)
61      m_rom.resize(size);
60   m_rom.resize(size);
6261}
6362
6463
r32298r32299
6867
6968void device_gb_cart_interface::ram_alloc(UINT32 size)
7069{
71   if (m_ram == NULL)
72   {
73      m_ram.resize(size);
74      device().save_item(NAME(m_ram));
75   }
70   m_ram.resize(size);
71   device().save_item(NAME(m_ram));
7672}
7773
7874
r32298r32299
447443
448444bool base_gb_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
449445{
450   load_software_part_region(*this, swlist, swname, start_entry );
446   load_software_part_region(*this, swlist, swname, start_entry);
451447   return true;
452448}
453449
trunk/src/emu/bus/a7800/a78_slot.c
r32298r32299
6262
6363void device_a78_cart_interface::rom_alloc(UINT32 size)
6464{
65   if (m_rom == NULL)
66   {
67      m_rom.resize(size);
68     
69      // setup other helpers
70      if ((size / 0x4000) & 1) // compensate for SuperGame carts with 9 x 16K banks (to my knowledge no other cart has m_bank_mask != power of 2)
71         m_bank_mask = (size / 0x4000) - 2;
72      else
73         m_bank_mask = (size / 0x4000) - 1;
74     
75      // the rom is mapped to the top of the memory area
76      // so we store the starting point of data to simplify
77      // the access handling
78      m_base_rom = 0x10000 - size;
79   }
65   m_rom.resize(size);
66   
67   // setup other helpers
68   if ((size / 0x4000) & 1) // compensate for SuperGame carts with 9 x 16K banks (to my knowledge no other cart has m_bank_mask != power of 2)
69      m_bank_mask = (size / 0x4000) - 2;
70   else
71      m_bank_mask = (size / 0x4000) - 1;
72   
73   // the rom is mapped to the top of the memory area
74   // so we store the starting point of data to simplify
75   // the access handling
76   m_base_rom = 0x10000 - size;
8077}
8178
8279//-------------------------------------------------
r32298r32299
8582
8683void device_a78_cart_interface::ram_alloc(UINT32 size)
8784{
88   if (m_ram == NULL)
89   {
90      m_ram.resize(size);
91      device().save_item(NAME(m_ram));
92   }
85   m_ram.resize(size);
86   device().save_item(NAME(m_ram));
9387}
9488
9589
r32298r32299
9993
10094void device_a78_cart_interface::nvram_alloc(UINT32 size)
10195{
102   if (m_nvram == NULL)
103   {
104      m_nvram.resize(size);
105      device().save_item(NAME(m_nvram));
106   }
96   m_nvram.resize(size);
97   device().save_item(NAME(m_nvram));
10798}
10899
109100
r32298r32299
120111                  device_image_interface(mconfig, *this),
121112                  device_slot_interface(mconfig, *this)
122113{
123   m_type = A78_NOCART;
124114}
125115
126116
r32298r32299
321311   { A78_TYPE1_POK450, "a78_p450_t1" },
322312   { A78_TYPE6_POK450, "a78_p450_t6" },
323313   { A78_TYPEA_POK450, "a78_p450_ta" },
324   { A78_VERSA_POK450, "a78_p450_vb" },
325   { A78_NOCART,     "empty" },   // the code should never get here, of course...
314   { A78_VERSA_POK450, "a78_p450_vb" }
326315};
327316
328317static int a78_get_pcb_id(const char *slot)
r32298r32299
508497
509498bool a78_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
510499{
511   load_software_part_region(*this, swlist, swname, start_entry );
500   load_software_part_region(*this, swlist, swname, start_entry);
512501   return TRUE;
513502}
514503
trunk/src/emu/bus/a7800/a78_slot.h
r32298r32299
3030   A78_TYPE1_POK450 = 0x21,
3131   A78_TYPE6_POK450 = 0x24,
3232   A78_TYPEA_POK450 = 0x25,
33   A78_VERSA_POK450 = 0x30,
34   A78_NOCART
33   A78_VERSA_POK450 = 0x30
3534};
3635
3736
trunk/src/emu/bus/pce/pce_slot.c
r32298r32299
4444
4545void device_pce_cart_interface::rom_alloc(UINT32 size)
4646{
47   if (m_rom == NULL)
48      m_rom.resize(size);
47   m_rom.resize(size);
4948}
5049
5150
r32298r32299
5554
5655void device_pce_cart_interface::ram_alloc(UINT32 size)
5756{
58   if (m_ram == NULL)
59   {
60      m_ram.resize(size);
61      device().save_item(NAME(m_ram));
62   }
57   m_ram.resize(size);
58   device().save_item(NAME(m_ram));
6359}
6460
6561//-------------------------------------------------
r32298r32299
6965
7066void device_pce_cart_interface::rom_map_setup(UINT32 size)
7167{
72   int i;
73
7468   if (size == 0x60000)
7569   {
7670      // HuCard 384K are mapped with mirrored pieces
r32298r32299
8579   }
8680   else
8781   {
82      int i;
83
8884      // setup the rom_bank_map array to faster ROM read
8985      for (i = 0; i < size / 0x20000 && i < 8; i++)
9086         rom_bank_map[i] = i;
r32298r32299
281277
282278bool pce_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
283279{
284   load_software_part_region(*this, swlist, swname, start_entry );
280   load_software_part_region(*this, swlist, swname, start_entry);
285281   return TRUE;
286282}
287283
trunk/src/emu/bus/saturn/sat_slot.c
r32298r32299
5454
5555void device_sat_cart_interface::rom_alloc(UINT32 size)
5656{
57   if (m_rom == NULL)
58      m_rom.resize(size/sizeof(UINT32));
57   m_rom.resize(size/sizeof(UINT32));
5958}
6059
6160
r32298r32299
164163
165164bool sat_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
166165{
167   load_software_part_region(*this, swlist, swname, start_entry );
166   load_software_part_region(*this, swlist, swname, start_entry);
168167   return TRUE;
169168}
170169
trunk/src/emu/bus/gba/gba_slot.c
r32298r32299
4646
4747void device_gba_cart_interface::nvram_alloc(UINT32 size)
4848{
49   if (m_nvram == NULL)
50   {
51      m_nvram.resize(size/sizeof(UINT32));
52      device().save_item(NAME(m_nvram));
53   }
49   m_nvram.resize(size/sizeof(UINT32));
50   device().save_item(NAME(m_nvram));
5451}
5552
5653
r32298r32299
239236
240237bool gba_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
241238{
242   load_software_part_region(*this, swlist, swname, start_entry );
239   load_software_part_region(*this, swlist, swname, start_entry);
243240   return TRUE;
244241}
245242
trunk/src/emu/bus/vcs/vcs_slot.c
r32298r32299
4747
4848void device_vcs_cart_interface::rom_alloc(UINT32 size)
4949{
50   if (m_rom == NULL)
51      m_rom.resize(size);
50   m_rom.resize(size);
5251}
5352
5453//-------------------------------------------------
r32298r32299
5756
5857void device_vcs_cart_interface::ram_alloc(UINT32 size)
5958{
60   if (m_ram == NULL)
61   {
62      m_ram.resize(size);
63      device().save_item(NAME(m_ram));
64   }
59   m_ram.resize(size);
60   device().save_item(NAME(m_ram));
6561}
6662
6763
trunk/src/emu/bus/a800/a800_slot.h
r32298r32299
3737   A5200_16K,
3838   A5200_32K,
3939   A5200_16K_2CHIPS,
40   A5200_BBSB,
41   A800_NOCART
40   A5200_BBSB
4241};
4342
4443
trunk/src/emu/bus/a800/a800_slot.c
r32298r32299
5959
6060void device_a800_cart_interface::rom_alloc(UINT32 size)
6161{
62   if (m_rom == NULL)
63   {
64      m_rom.resize(size);
65     
66      // setup other helpers
67      m_bank_mask = (size / 0x2000) - 1;   // code for XEGS carts makes use of this to simplify banking
68   }
62   m_rom.resize(size);
63   
64   // setup other helpers
65   m_bank_mask = (size / 0x2000) - 1;   // code for XEGS carts makes use of this to simplify banking
6966}
7067
7168//-------------------------------------------------
r32298r32299
7471
7572void device_a800_cart_interface::ram_alloc(UINT32 size)
7673{
77   if (m_ram == NULL)
78   {
79      m_ram.resize(size);
80      device().save_item(NAME(m_ram));
81   }
74   m_ram.resize(size);
75   device().save_item(NAME(m_ram));
8276}
8377
8478
r32298r32299
8882
8983void device_a800_cart_interface::nvram_alloc(UINT32 size)
9084{
91   if (m_nvram == NULL)
92   {
93      m_nvram.resize(size);
94      device().save_item(NAME(m_nvram));
95   }
85   m_nvram.resize(size);
86   device().save_item(NAME(m_nvram));
9687}
9788
9889
r32298r32299
109100                  device_image_interface(mconfig, *this),
110101                  device_slot_interface(mconfig, *this)
111102{
112   m_type = A800_NOCART;
113103}
114104
115105a800_cart_slot_device::a800_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
r32298r32299
117107                  device_image_interface(mconfig, *this),
118108                  device_slot_interface(mconfig, *this)
119109{
120   m_type = A800_NOCART;
121110}
122111
123112
r32298r32299
215204   { A5200_32K,      "a5200" },
216205   { A5200_16K_2CHIPS, "a5200_2chips" },
217206   { A5200_32K,      "a5200" },
218   { A5200_BBSB,     "a5200_bbsb" },
219   { A800_NOCART,    "empty" },
207   { A5200_BBSB,     "a5200_bbsb" }
220208};
221209
222210
r32298r32299
314302
315303bool a800_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
316304{
317   load_software_part_region(*this, swlist, swname, start_entry );
305   load_software_part_region(*this, swlist, swname, start_entry);
318306   return TRUE;
319307}
320308
trunk/src/emu/bus/sega8/sega8_slot.c
r32298r32299
7272
7373void device_sega8_cart_interface::rom_alloc(UINT32 size)
7474{
75   if (m_rom == NULL)
76   {
77      m_rom.resize(size);
78      m_rom_page_count = size / 0x4000;
79      if (!m_rom_page_count)
80         m_rom_page_count = 1;   // we compute rom pages through (XXX % m_rom_page_count)!
81      late_bank_setup();
82   }
75   m_rom.resize(size);
76   m_rom_page_count = size / 0x4000;
77   if (!m_rom_page_count)
78      m_rom_page_count = 1;   // we compute rom pages through (XXX % m_rom_page_count)!
79   late_bank_setup();
8380}
8481
8582
r32298r32299
8986
9087void device_sega8_cart_interface::ram_alloc(UINT32 size)
9188{
92   if (m_ram == NULL)
93   {
94      m_ram.resize(size);
95      device().save_item(NAME(m_ram));
96   }
89   m_ram.resize(size);
90   device().save_item(NAME(m_ram));
9791}
9892
9993
trunk/src/emu/bus/snes/snes_slot.c
r32298r32299
8686
8787void device_sns_cart_interface::rom_alloc(UINT32 size)
8888{
89   if (m_rom == NULL)
90      m_rom.resize(size);
89   m_rom.resize(size);
9190}
9291
9392
r32298r32299
9796
9897void device_sns_cart_interface::nvram_alloc(UINT32 size)
9998{
100   if (m_nvram == NULL)
101   {
102      m_nvram.resize(size);
103      device().save_item(NAME(m_nvram));
104   }
99   m_nvram.resize(size);
100   device().save_item(NAME(m_nvram));
105101}
106102
107103
r32298r32299
114110
115111void device_sns_cart_interface::rtc_ram_alloc(UINT32 size)
116112{
117   if (m_rtc_ram == NULL)
118   {
119      m_rtc_ram.resize(size);
120      device().save_item(NAME(m_rtc_ram));
121   }
113   m_rtc_ram.resize(size);
114   device().save_item(NAME(m_rtc_ram));
122115}
123116
124117
r32298r32299
129122
130123void device_sns_cart_interface::addon_bios_alloc(UINT32 size)
131124{
132   if (m_bios == NULL)
133      m_bios.resize(size);
125   m_bios.resize(size);
134126}
135127
136128
trunk/src/emu/bus/nes/nes_slot.c
r32298r32299
142142
143143void device_nes_cart_interface::prg_alloc(size_t size)
144144{
145   if (m_prg == NULL)
145   m_prg.resize(size);
146   m_prg_chunks = size / 0x4000;
147   if (size % 0x2000)
146148   {
147      m_prg.resize(size);
148      m_prg_chunks = size / 0x4000;
149      if (size % 0x2000)
150      {
151         // A few pirate carts have PRG made of 32K + 2K or some weird similar config
152         // in this case we treat the banking as if this 'extra' PRG is not present and
153         // the pcb code has to handle it by accessing directly m_prg!
154         printf("Warning! The loaded PRG has size not a multiple of 8KB (0x%X)\n", (UINT32)size);
155         m_prg_chunks--;
156      }
157
158      m_prg_mask = ((m_prg_chunks << 1) - 1);
159
149      // A few pirate carts have PRG made of 32K + 2K or some weird similar config
150      // in this case we treat the banking as if this 'extra' PRG is not present and
151      // the pcb code has to handle it by accessing directly m_prg!
152      printf("Warning! The loaded PRG has size not a multiple of 8KB (0x%X)\n", (UINT32)size);
153      m_prg_chunks--;
154   }
155   
156   m_prg_mask = ((m_prg_chunks << 1) - 1);
157   
160158//      printf("first mask %x!\n", m_prg_mask);
161      if ((m_prg_chunks << 1) & m_prg_mask)
162      {
163         int mask_bits = 0, temp = (m_prg_chunks << 1), mapsize;
164         // contrary to what happens with later systems, like e.g. SNES or MD,
165         // only half a dozen of NES carts have PRG which is not a power of 2
166         // so we use this bank_map only as an exception
159   if ((m_prg_chunks << 1) & m_prg_mask)
160   {
161      int mask_bits = 0, temp = (m_prg_chunks << 1), mapsize;
162      // contrary to what happens with later systems, like e.g. SNES or MD,
163      // only half a dozen of NES carts have PRG which is not a power of 2
164      // so we use this bank_map only as an exception
167165//          printf("uneven rom!\n");
168
169         // 1. redefine mask as (next power of 2)-1
170         for (; temp; )
171         {
172            mask_bits++;
173            temp >>= 1;
174         }
175         m_prg_mask = (1 << mask_bits) - 1;
166     
167      // 1. redefine mask as (next power of 2)-1
168      for (; temp; )
169      {
170         mask_bits++;
171         temp >>= 1;
172      }
173      m_prg_mask = (1 << mask_bits) - 1;
176174//          printf("new mask %x!\n", m_prg_mask);
177         mapsize = (1 << mask_bits)/2;
178
179         // 2. create a bank_map for banks in the range mask/2 -> mask
180         m_prg_bank_map.resize(mapsize);
181
182         // 3. fill the bank_map accounting for mirrors
183         int j;
184         for (j = mapsize; j < (m_prg_chunks << 1); j++)
185            m_prg_bank_map[j - mapsize] = j;
186
187         while (j % mapsize)
188         {
189            int k = 0, repeat_banks;
190            while ((j % (mapsize >> k)) && k < mask_bits)
191               k++;
192            repeat_banks = j % (mapsize >> (k - 1));
193            for (int l = 0; l < repeat_banks; l++)
194               m_prg_bank_map[(j - mapsize) + l] = m_prg_bank_map[(j - mapsize) + l - repeat_banks];
195            j += repeat_banks;
196         }
197
198         // check bank map!
175      mapsize = (1 << mask_bits)/2;
176     
177      // 2. create a bank_map for banks in the range mask/2 -> mask
178      m_prg_bank_map.resize(mapsize);
179     
180      // 3. fill the bank_map accounting for mirrors
181      int j;
182      for (j = mapsize; j < (m_prg_chunks << 1); j++)
183         m_prg_bank_map[j - mapsize] = j;
184     
185      while (j % mapsize)
186      {
187         int k = 0, repeat_banks;
188         while ((j % (mapsize >> k)) && k < mask_bits)
189            k++;
190         repeat_banks = j % (mapsize >> (k - 1));
191         for (int l = 0; l < repeat_banks; l++)
192            m_prg_bank_map[(j - mapsize) + l] = m_prg_bank_map[(j - mapsize) + l - repeat_banks];
193         j += repeat_banks;
194      }
195     
196// check bank map!
199197//          for (int i = 0; i < mapsize; i++)
200198//          {
201199//              printf("bank %3d = %3d\t", i, m_prg_bank_map[i]);
202200//              if ((i%8) == 7)
203201//                  printf("\n");
204202//          }
205      }
206203   }
207204}
208205
209206void device_nes_cart_interface::prgram_alloc(size_t size)
210207{
211   if (m_prgram == NULL)
212      m_prgram.resize(size);
208   m_prgram.resize(size);
213209}
214210
215211void device_nes_cart_interface::vrom_alloc(size_t size)
216212{
217   if (m_vrom == NULL)
218   {
219      m_vrom.resize(size);
220      m_vrom_chunks = size / 0x2000;
221   }
213   m_vrom.resize(size);
214   m_vrom_chunks = size / 0x2000;
222215}
223216
224217void device_nes_cart_interface::vram_alloc(size_t size)
225218{
226   if (m_vram == NULL)
227   {
228      m_vram.resize(size);
229      m_vram_chunks = size / 0x2000;
230   }
219   m_vram.resize(size);
220   m_vram_chunks = size / 0x2000;
231221}
232222
233223void device_nes_cart_interface::battery_alloc(size_t size)
234224{
235   if (m_battery == NULL)
236      m_battery.resize(size);
225   m_battery.resize(size);
237226}
238227
239228
r32298r32299
905894
906895bool nes_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
907896{
908   load_software_part_region(*this, swlist, swname, start_entry );
897   load_software_part_region(*this, swlist, swname, start_entry);
909898   return TRUE;
910899}
911900
trunk/src/emu/bus/megadrive/md_slot.h
r32298r32299
7878};
7979
8080
81// ======================> md_cart_interface
82
83struct md_cart_interface
84{
85};
86
87
8881// ======================> device_md_cart_interface
8982
9083class device_md_cart_interface : public device_slot_card_interface
r32298r32299
138131// ======================> base_md_cart_slot_device
139132
140133class base_md_cart_slot_device : public device_t,
141                        public md_cart_interface,
142134                        public device_image_interface,
143135                        public device_slot_interface
144136{
trunk/src/emu/bus/megadrive/md_slot.c
r32298r32299
9898
9999void device_md_cart_interface::nvram_alloc(size_t size)
100100{
101   if (m_nvram == NULL)
102   {
103      m_nvram.resize(size/sizeof(UINT16));
104      device().save_item(NAME(m_nvram));
105   }
101   m_nvram.resize(size/sizeof(UINT16));
102   device().save_item(NAME(m_nvram));
106103}
107104
108105//-------------------------------------------------
r32298r32299
684681
685682bool base_md_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
686683{
687   load_software_part_region(*this, swlist, swname, start_entry );
684   load_software_part_region(*this, swlist, swname, start_entry);
688685   return TRUE;
689686}
690687
trunk/src/mess/drivers/atari400.c
r32298r32299
17351735
17361736WRITE8_MEMBER(a400_state::disable_cart)
17371737{
1738   switch (m_cartslot->get_cart_type())
1738   switch (m_cartslot->exists() && m_cartslot->get_cart_type())
17391739   {
17401740      case A800_PHOENIX:
17411741      case A800_BLIZZARD:
r32298r32299
18341834   m_cart_disabled = 0;
18351835   m_last_offs = -1;
18361836
1837   switch (slot->get_cart_type())
1837   switch (slot->exists() && slot->get_cart_type())
18381838   {
18391839      case A800_8K:
18401840         m_maincpu->space(AS_PROGRAM).install_read_handler(0xa000, 0xbfff, read8_delegate(FUNC(a800_cart_slot_device::read_80xx),(a800_cart_slot_device*)slot));
trunk/src/mess/drivers/a7800.c
r32298r32299
13151315   save_item(NAME(m_maria_flag));
13161316   
13171317   // install additional handlers, if needed
1318   switch (m_cartslot->get_cart_type())
1318   switch (m_cartslot->exists() && m_cartslot->get_cart_type())
13191319   {
13201320      case A78_HSC:
13211321         // ROM+NVRAM accesses for HiScore

Previous 199869 Revisions Next


© 1997-2024 The MAME Team