summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2014-03-11 15:54:58 +0000
committer Aaron Giles <aaron@aarongiles.com>2014-03-11 15:54:58 +0000
commit4ea9df02a1daf1893246a01e21ffe201781f9266 (patch)
tree70dcb5feb88dcabe713fc172c30fd159ed1a0a43 /src/emu
parentb05606404a780c5309d39d8ee45411292279f117 (diff)
Moved core template container classes up from emutempl.h to coretmpl.h:
[Aaron Giles] * these classes now no longer take a resource_pool; everything is managed globally -- this means that objects added to lists must be allocated with global_alloc * added new auto_pointer<> template which wraps a pointer and auto-frees it upon destruction; it also defaults to NULL so it doesn't need to be explicitly initialized * moved tagged_list template to tagmap.h Redo of the low-level memory tracking system: [Aaron Giles] * moved low-level tracking out of emu\emualloc into lib\util\corealloc so it can be shared among all components and used by core libraries * global_alloc and friends no longer use a resource pool to track allocations; turns out this was a wholly redundant system that wasted a lot of memory * removed global_resource_pool entirely * added global_free_array to delete arrays allocated with global_alloc_array * added tracking of object versus array allocation; we will now error if you use global_free on an array, or global_free_array on an object Added new utility helper const_string_pool which can be used to efficiently accumulate strings that are not intended to be modified. Used by updated makelist and software list code. [Aaron Giles] Updated png2bdc and makelist tools to not leak memory and use more modern techniques (no more MAX_DRIVERS in makelist, for example). [Aaron Giles] Deprecated auto_strdup and removed all uses by way of caller-managed astrings and the software list rewrite. [Aaron Giles] Rewrote software list management: [Aaron Giles] * removed the notion of a software_list that is separate from a software_list_device; they are one and the same now * moved several functions into device_image_interface since they really didn't belong in the core software list class * lots of simplification as a result of the above changes Additional notes (no whatsnew): Moved definition of FPTR to osdcomm.h. Some changes happened in the OSD code to fix issues, especially regarding freeing arrays. SDL folks may need to fix up some of these. The following devices still are using tokens and should be modernized (I found them because they kept their token as void * and tried to delete it, which you can't): namco_52xx_device (mame/audio/namco52.c) namco_54xx_device (mame/audio/namco54.c) namco_06xx_device (mame/machine/namco06.c) namco_50xx_device (mame/machine/namco50.c) namco_51xx_device (mame/machine/namco51.c) namco_53xx_device (mame/machine/namco53.c) voodoo_device (emu/video/voodoo.c) mos6581_device (emu/sound/mos6581.c) aica_device (emu/sound/aica.c) scsp_device (emu/sound/scsp.c) dmadac_sound_device (emu/sound/dmadac.c) s3c2440_device (emu/machine/s3c2440.c) wd1770_device (emu/machine/wd17xx.c) latch8_device (emu/machine/latch8.c) duart68681_device (emu/machine/68681.c) s3c2400_device (emu/machine/s3c2400.c) s3c2410_device (emu/machine/s3c2410.c) strataflash_device (mess/machine/strata.c) hd63450_device (mess/machine/hd63450.c) tap_990_device (mess/machine/ti99/990_tap.c) omti8621_device (mess/machine/omti8621.c) vdt911_device (mess/video/911_vdt.c) apollo_graphics_15i (mess/video/apollo.c) asr733_device (mess/video/733_asr.c)
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/audit.c14
-rw-r--r--src/emu/bus/adam/exp.c8
-rw-r--r--src/emu/bus/adam/exp.h4
-rw-r--r--src/emu/bus/adamnet/adamnet.c2
-rw-r--r--src/emu/bus/c64/exp.c13
-rw-r--r--src/emu/bus/c64/exp.h4
-rw-r--r--src/emu/bus/cbm2/exp.c8
-rw-r--r--src/emu/bus/cbm2/exp.h4
-rw-r--r--src/emu/bus/cbmiec/cbmiec.c2
-rw-r--r--src/emu/bus/econet/econet.c2
-rw-r--r--src/emu/bus/gameboy/gb_slot.c33
-rw-r--r--src/emu/bus/gameboy/gb_slot.h6
-rw-r--r--src/emu/bus/gba/gba_slot.c20
-rw-r--r--src/emu/bus/gba/gba_slot.h4
-rw-r--r--src/emu/bus/ieee488/ieee488.c2
-rw-r--r--src/emu/bus/iq151/iq151.c8
-rw-r--r--src/emu/bus/iq151/iq151.h4
-rw-r--r--src/emu/bus/iq151/video32.c2
-rw-r--r--src/emu/bus/iq151/video64.c2
-rw-r--r--src/emu/bus/kc/kc.c8
-rw-r--r--src/emu/bus/kc/kc.h4
-rw-r--r--src/emu/bus/megadrive/md_slot.c21
-rw-r--r--src/emu/bus/megadrive/md_slot.h4
-rw-r--r--src/emu/bus/nes/aladdin.c21
-rw-r--r--src/emu/bus/nes/aladdin.h4
-rw-r--r--src/emu/bus/nes/datach.c8
-rw-r--r--src/emu/bus/nes/datach.h4
-rw-r--r--src/emu/bus/nes/karastudio.c8
-rw-r--r--src/emu/bus/nes/karastudio.h4
-rw-r--r--src/emu/bus/nes/nes_ines.inc17
-rw-r--r--src/emu/bus/nes/nes_slot.c25
-rw-r--r--src/emu/bus/nes/nes_slot.h4
-rw-r--r--src/emu/bus/nes/sunsoft_dcs.c8
-rw-r--r--src/emu/bus/nes/sunsoft_dcs.h4
-rw-r--r--src/emu/bus/plus4/exp.c8
-rw-r--r--src/emu/bus/plus4/exp.h4
-rw-r--r--src/emu/bus/saturn/sat_slot.c8
-rw-r--r--src/emu/bus/saturn/sat_slot.h4
-rw-r--r--src/emu/bus/sega8/sega8_slot.c20
-rw-r--r--src/emu/bus/sega8/sega8_slot.h4
-rw-r--r--src/emu/bus/snes/snes_slot.c22
-rw-r--r--src/emu/bus/snes/snes_slot.h4
-rw-r--r--src/emu/bus/vic10/exp.c13
-rw-r--r--src/emu/bus/vic10/exp.h4
-rw-r--r--src/emu/bus/vic20/exp.c8
-rw-r--r--src/emu/bus/vic20/exp.h4
-rw-r--r--src/emu/bus/vidbrain/exp.c8
-rw-r--r--src/emu/bus/vidbrain/exp.h4
-rw-r--r--src/emu/bus/z88/z88.c8
-rw-r--r--src/emu/bus/z88/z88.h4
-rw-r--r--src/emu/cheat.c38
-rw-r--r--src/emu/cheat.h12
-rw-r--r--src/emu/clifront.c275
-rw-r--r--src/emu/clifront.h4
-rw-r--r--src/emu/cpu/drcfe.c2
-rw-r--r--src/emu/cpu/drcuml.c10
-rw-r--r--src/emu/cpu/dsp56k/inst.c24
-rw-r--r--src/emu/cpu/dsp56k/opcode.c6
-rw-r--r--src/emu/cpu/dsp56k/opcode.h4
-rw-r--r--src/emu/cpu/jaguar/jaguar.c4
-rw-r--r--src/emu/crsshair.c4
-rw-r--r--src/emu/crsshair.h6
-rw-r--r--src/emu/debug/debugvw.c124
-rw-r--r--src/emu/debug/debugvw.h42
-rw-r--r--src/emu/debug/dvbpoints.c8
-rw-r--r--src/emu/debug/dvdisasm.c6
-rw-r--r--src/emu/debug/dvmemory.c8
-rw-r--r--src/emu/debug/dvstate.c4
-rw-r--r--src/emu/debug/dvwpoints.c8
-rw-r--r--src/emu/debugger.c2
-rw-r--r--src/emu/debugint/debugint.c6
-rw-r--r--src/emu/devcpu.c2
-rw-r--r--src/emu/devfind.h23
-rw-r--r--src/emu/device.c5
-rw-r--r--src/emu/device.h4
-rw-r--r--src/emu/diimage.c345
-rw-r--r--src/emu/diimage.h47
-rw-r--r--src/emu/dinetwork.c4
-rw-r--r--src/emu/dinetwork.h2
-rw-r--r--src/emu/dislot.c3
-rw-r--r--src/emu/dislot.h2
-rw-r--r--src/emu/drawgfx.c5
-rw-r--r--src/emu/drawgfx.h5
-rw-r--r--src/emu/drivenum.c63
-rw-r--r--src/emu/drivenum.h14
-rw-r--r--src/emu/emualloc.c370
-rw-r--r--src/emu/emualloc.h167
-rw-r--r--src/emu/emucore.h7
-rw-r--r--src/emu/emuopts.c163
-rw-r--r--src/emu/emutempl.h382
-rw-r--r--src/emu/fileio.c49
-rw-r--r--src/emu/fileio.h4
-rw-r--r--src/emu/hashfile.c31
-rw-r--r--src/emu/hashfile.h2
-rw-r--r--src/emu/imagedev/cartslot.h2
-rw-r--r--src/emu/imagedev/cassette.h2
-rw-r--r--src/emu/imagedev/chd_cd.c10
-rw-r--r--src/emu/imagedev/chd_cd.h3
-rw-r--r--src/emu/imagedev/flopdrv.c21
-rw-r--r--src/emu/imagedev/flopdrv.h6
-rw-r--r--src/emu/imagedev/floppy.c45
-rw-r--r--src/emu/imagedev/floppy.h3
-rw-r--r--src/emu/imagedev/harddriv.c10
-rw-r--r--src/emu/imagedev/harddriv.h4
-rw-r--r--src/emu/imagedev/snapquik.h2
-rw-r--r--src/emu/info.c3
-rw-r--r--src/emu/input.c65
-rw-r--r--src/emu/input.h61
-rw-r--r--src/emu/ioport.c10
-rw-r--r--src/emu/ioport.h8
-rw-r--r--src/emu/machine.c34
-rw-r--r--src/emu/machine.h19
-rw-r--r--src/emu/machine/68681.c5
-rw-r--r--src/emu/machine/68681.h6
-rw-r--r--src/emu/machine/intelfsh.c6
-rw-r--r--src/emu/machine/latch8.c5
-rw-r--r--src/emu/machine/latch8.h6
-rw-r--r--src/emu/machine/nscsi_s1410.c3
-rw-r--r--src/emu/machine/s3c2400.c5
-rw-r--r--src/emu/machine/s3c2400.h6
-rw-r--r--src/emu/machine/s3c2410.c5
-rw-r--r--src/emu/machine/s3c2410.h6
-rw-r--r--src/emu/machine/s3c2440.c5
-rw-r--r--src/emu/machine/s3c2440.h6
-rw-r--r--src/emu/machine/tc009xlvc.c2
-rw-r--r--src/emu/machine/wd17xx.c5
-rw-r--r--src/emu/machine/wd17xx.h6
-rw-r--r--src/emu/mame.c2
-rw-r--r--src/emu/mconfig.c6
-rw-r--r--src/emu/mconfig.h2
-rw-r--r--src/emu/memory.c40
-rw-r--r--src/emu/memory.h8
-rw-r--r--src/emu/output.c72
-rw-r--r--src/emu/render.c41
-rw-r--r--src/emu/render.h11
-rw-r--r--src/emu/rendfont.c17
-rw-r--r--src/emu/rendlay.c48
-rw-r--r--src/emu/rendlay.h2
-rw-r--r--src/emu/romload.c81
-rw-r--r--src/emu/romload.h4
-rw-r--r--src/emu/save.c11
-rw-r--r--src/emu/schedule.c3
-rw-r--r--src/emu/softlist.c2798
-rw-r--r--src/emu/softlist.h279
-rw-r--r--src/emu/sound/aica.c5
-rw-r--r--src/emu/sound/aica.h6
-rw-r--r--src/emu/sound/ay8910.c5
-rw-r--r--src/emu/sound/discrete.h2
-rw-r--r--src/emu/sound/dmadac.c5
-rw-r--r--src/emu/sound/dmadac.h6
-rw-r--r--src/emu/sound/mos6581.c4
-rw-r--r--src/emu/sound/mos6581.h2
-rw-r--r--src/emu/sound/scsp.c5
-rw-r--r--src/emu/sound/scsp.h6
-rw-r--r--src/emu/sound/spu.c24
-rw-r--r--src/emu/sound/spureverb.c8
-rw-r--r--src/emu/sound/tiasound.c2
-rw-r--r--src/emu/tilemap.c60
-rw-r--r--src/emu/tilemap.h9
-rw-r--r--src/emu/ui/filemngr.c4
-rw-r--r--src/emu/ui/filesel.c4
-rw-r--r--src/emu/ui/selgame.c7
-rw-r--r--src/emu/ui/selgame.h4
-rw-r--r--src/emu/ui/swlist.c98
-rw-r--r--src/emu/ui/swlist.h8
-rw-r--r--src/emu/validity.c5
-rw-r--r--src/emu/validity.h4
-rw-r--r--src/emu/video.c9
-rw-r--r--src/emu/video.h2
-rw-r--r--src/emu/video/resnet.c88
-rw-r--r--src/emu/video/resnet.h4
-rw-r--r--src/emu/video/voodoo.c5
-rw-r--r--src/emu/video/voodoo.h6
173 files changed, 2461 insertions, 4455 deletions
diff --git a/src/emu/audit.c b/src/emu/audit.c
index 51a92abbf8d..c8ca031243b 100644
--- a/src/emu/audit.c
+++ b/src/emu/audit.c
@@ -188,12 +188,12 @@ media_auditor::summary media_auditor::audit_software(const char *list_name, soft
// store validation for later
m_validation = validation;
- astring combinedpath(swinfo->shortname, ";", list_name, PATH_SEPARATOR, swinfo->shortname);
- astring locationtag(list_name, "%", swinfo->shortname, "%");
- if ( swinfo->parentname )
+ astring combinedpath(swinfo->shortname(), ";", list_name, PATH_SEPARATOR, swinfo->shortname());
+ astring locationtag(list_name, "%", swinfo->shortname(), "%");
+ if (swinfo->parentname() != NULL)
{
- locationtag.cat(swinfo->parentname);
- combinedpath.cat(";").cat(swinfo->parentname).cat(";").cat(list_name).cat(PATH_SEPARATOR).cat(swinfo->parentname);
+ locationtag.cat(swinfo->parentname());
+ combinedpath.cat(";").cat(swinfo->parentname()).cat(";").cat(list_name).cat(PATH_SEPARATOR).cat(swinfo->parentname());
}
m_searchpath = combinedpath;
@@ -201,10 +201,10 @@ media_auditor::summary media_auditor::audit_software(const char *list_name, soft
int required = 0;
// now iterate over software parts
- for ( software_part *part = software_find_part( swinfo, NULL, NULL ); part != NULL; part = software_part_next( part ) )
+ for ( software_part *part = swinfo->first_part(); part != NULL; part = part->next() )
{
// now iterate over regions
- for ( const rom_entry *region = part->romdata; region; region = rom_next_region( region ) )
+ for ( const rom_entry *region = part->romdata(); region; region = rom_next_region( region ) )
{
// now iterate over rom definitions
for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
diff --git a/src/emu/bus/adam/exp.c b/src/emu/bus/adam/exp.c
index 38a4f183f20..8965e7ebacd 100644
--- a/src/emu/bus/adam/exp.c
+++ b/src/emu/bus/adam/exp.c
@@ -197,9 +197,9 @@ bool adam_expansion_slot_device::call_load()
// call_softlist_load -
//-------------------------------------------------
-bool adam_expansion_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool adam_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry);
+ load_software_part_region(*this, swlist, swname, start_entry);
return true;
}
@@ -209,9 +209,9 @@ bool adam_expansion_slot_device::call_softlist_load(char *swlist, char *swname,
// get_default_card_software -
//-------------------------------------------------
-const char * adam_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void adam_expansion_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, "standard");
+ software_get_default_slot(result, "standard");
}
diff --git a/src/emu/bus/adam/exp.h b/src/emu/bus/adam/exp.h
index c2614a41856..0afcaee60b1 100644
--- a/src/emu/bus/adam/exp.h
+++ b/src/emu/bus/adam/exp.h
@@ -84,7 +84,7 @@ protected:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
@@ -98,7 +98,7 @@ protected:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
devcb_resolved_write_line m_out_int_func;
diff --git a/src/emu/bus/adamnet/adamnet.c b/src/emu/bus/adamnet/adamnet.c
index f522930bdbf..132feaa2822 100644
--- a/src/emu/bus/adamnet/adamnet.c
+++ b/src/emu/bus/adamnet/adamnet.c
@@ -114,7 +114,7 @@ void adamnet_device::device_stop()
void adamnet_device::add_device(device_t *target)
{
- daisy_entry *entry = auto_alloc(machine(), daisy_entry(target));
+ daisy_entry *entry = global_alloc(daisy_entry(target));
entry->m_interface->m_bus = this;
diff --git a/src/emu/bus/c64/exp.c b/src/emu/bus/c64/exp.c
index ecafa19c361..1739a672a71 100644
--- a/src/emu/bus/c64/exp.c
+++ b/src/emu/bus/c64/exp.c
@@ -208,9 +208,9 @@ bool c64_expansion_slot_device::call_load()
// call_softlist_load -
//-------------------------------------------------
-bool c64_expansion_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool c64_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry);
+ load_software_part_region(*this, swlist, swname, start_entry);
return true;
}
@@ -220,19 +220,20 @@ bool c64_expansion_slot_device::call_softlist_load(char *swlist, char *swname, r
// get_default_card_software -
//-------------------------------------------------
-const char * c64_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void c64_expansion_slot_device::get_default_card_software(astring &result)
{
- if (open_image_file(options))
+ if (open_image_file(mconfig().options()))
{
if (!mame_stricmp(filetype(), "crt"))
{
- return cbm_crt_get_card(m_file);
+ cbm_crt_get_card(result, m_file);
+ return;
}
clear();
}
- return software_get_default_slot(config, options, this, "standard");
+ software_get_default_slot(result, "standard");
}
diff --git a/src/emu/bus/c64/exp.h b/src/emu/bus/c64/exp.h
index 6f2c199c3be..678441c6260 100644
--- a/src/emu/bus/c64/exp.h
+++ b/src/emu/bus/c64/exp.h
@@ -127,7 +127,7 @@ protected:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
@@ -141,7 +141,7 @@ protected:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
devcb2_read8 m_read_dma_cd;
devcb2_write8 m_write_dma_cd;
diff --git a/src/emu/bus/cbm2/exp.c b/src/emu/bus/cbm2/exp.c
index f19566ab203..93ef2d648e8 100644
--- a/src/emu/bus/cbm2/exp.c
+++ b/src/emu/bus/cbm2/exp.c
@@ -146,9 +146,9 @@ bool cbm2_expansion_slot_device::call_load()
// call_softlist_load -
//-------------------------------------------------
-bool cbm2_expansion_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool cbm2_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry);
+ load_software_part_region(*this, swlist, swname, start_entry);
return true;
}
@@ -158,9 +158,9 @@ bool cbm2_expansion_slot_device::call_softlist_load(char *swlist, char *swname,
// get_default_card_software -
//-------------------------------------------------
-const char * cbm2_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void cbm2_expansion_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, "standard");
+ software_get_default_slot(result, "standard");
}
diff --git a/src/emu/bus/cbm2/exp.h b/src/emu/bus/cbm2/exp.h
index 6b20d47baf1..726f00a5bb3 100644
--- a/src/emu/bus/cbm2/exp.h
+++ b/src/emu/bus/cbm2/exp.h
@@ -85,7 +85,7 @@ protected:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
@@ -99,7 +99,7 @@ protected:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
device_cbm2_expansion_card_interface *m_card;
};
diff --git a/src/emu/bus/cbmiec/cbmiec.c b/src/emu/bus/cbmiec/cbmiec.c
index f466c0ef147..b79556e21fa 100644
--- a/src/emu/bus/cbmiec/cbmiec.c
+++ b/src/emu/bus/cbmiec/cbmiec.c
@@ -342,7 +342,7 @@ void cbm_iec_device::device_stop()
void cbm_iec_device::add_device(cbm_iec_slot_device *slot, device_t *target)
{
- daisy_entry *entry = auto_alloc(machine(), daisy_entry(target));
+ daisy_entry *entry = global_alloc(daisy_entry(target));
entry->m_interface->m_slot = slot;
entry->m_interface->m_bus = this;
diff --git a/src/emu/bus/econet/econet.c b/src/emu/bus/econet/econet.c
index 46701892f30..cdf784e11aa 100644
--- a/src/emu/bus/econet/econet.c
+++ b/src/emu/bus/econet/econet.c
@@ -270,7 +270,7 @@ void econet_device::device_stop()
void econet_device::add_device(device_t *target, int address)
{
- daisy_entry *entry = auto_alloc(machine(), daisy_entry(target));
+ daisy_entry *entry = global_alloc(daisy_entry(target));
entry->m_interface->m_econet = this;
entry->m_interface->m_address = address;
diff --git a/src/emu/bus/gameboy/gb_slot.c b/src/emu/bus/gameboy/gb_slot.c
index 8646440a0f3..ae01c9525ea 100644
--- a/src/emu/bus/gameboy/gb_slot.c
+++ b/src/emu/bus/gameboy/gb_slot.c
@@ -451,9 +451,9 @@ void base_gb_cart_slot_device::setup_ram(UINT8 banks)
call softlist load
-------------------------------------------------*/
-bool base_gb_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool base_gb_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
@@ -574,43 +574,46 @@ int base_gb_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len)
get default card software
-------------------------------------------------*/
-const char * base_gb_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void base_gb_cart_slot_device::get_default_card_software(astring &result)
{
- if (open_image_file(options))
+ if (open_image_file(mconfig().options()))
{
const char *slot_string = "rom";
UINT32 len = core_fsize(m_file), offset = 0;
- UINT8 *ROM = global_alloc_array(UINT8, len);
+ dynamic_buffer rom(len);
int type;
- core_fread(m_file, ROM, len);
+ core_fread(m_file, rom, len);
if ((len % 0x4000) == 512)
offset = 512;
- if (get_mmm01_candidate(ROM + offset, len - offset))
+ if (get_mmm01_candidate(rom + offset, len - offset))
offset += (len - 0x8000);
- type = get_cart_type(ROM + offset, len - offset);
+ type = get_cart_type(rom + offset, len - offset);
slot_string = gb_get_slot(type);
//printf("type: %s\n", slot_string);
- global_free(ROM);
clear();
- return slot_string;
+ result.cpy(slot_string);
+ return;
}
- return software_get_default_slot(config, options, this, "rom");
+ software_get_default_slot(result, "rom");
}
-const char * megaduck_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void megaduck_cart_slot_device::get_default_card_software(astring &result)
{
- if (open_image_file(options))
- return "rom";
+ if (open_image_file(mconfig().options()))
+ {
+ result.cpy("rom");
+ return;
+ }
- return software_get_default_slot(config, options, this, "rom");
+ software_get_default_slot(result, "rom");
}
diff --git a/src/emu/bus/gameboy/gb_slot.h b/src/emu/bus/gameboy/gb_slot.h
index 8c9049f68d5..7a1d651a5f7 100644
--- a/src/emu/bus/gameboy/gb_slot.h
+++ b/src/emu/bus/gameboy/gb_slot.h
@@ -117,7 +117,7 @@ public:
// image-level overrides
virtual bool call_load();
virtual void call_unload();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
int get_type() { return m_type; }
int get_cart_type(UINT8 *ROM, UINT32 len);
@@ -139,7 +139,7 @@ public:
virtual const char *file_extensions() const { return "bin,gb,gbc"; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
// reading and writing
virtual DECLARE_READ8_MEMBER(read_rom);
@@ -180,7 +180,7 @@ public:
virtual const char *file_extensions() const { return "bin"; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
};
diff --git a/src/emu/bus/gba/gba_slot.c b/src/emu/bus/gba/gba_slot.c
index 05c64325686..4ac3f7b8022 100644
--- a/src/emu/bus/gba/gba_slot.c
+++ b/src/emu/bus/gba/gba_slot.c
@@ -240,9 +240,9 @@ void gba_cart_slot_device::call_unload()
call softlist load
-------------------------------------------------*/
-bool gba_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool gba_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
@@ -396,28 +396,28 @@ int gba_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len)
get default card software
-------------------------------------------------*/
-const char * gba_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void gba_cart_slot_device::get_default_card_software(astring &result)
{
- if (open_image_file(options))
+ if (open_image_file(mconfig().options()))
{
const char *slot_string = "gba_rom";
UINT32 len = core_fsize(m_file);
- UINT8 *ROM = global_alloc_array(UINT8, len);
+ dynamic_buffer rom(len);
int type;
- core_fread(m_file, ROM, len);
+ core_fread(m_file, rom, len);
- type = get_cart_type(ROM, len);
+ type = get_cart_type(rom, len);
slot_string = gba_get_slot(type);
//printf("type: %s\n", slot_string);
- global_free(ROM);
clear();
- return slot_string;
+ result.cpy(slot_string);
+ return;
}
- return software_get_default_slot(config, options, this, "gba_rom");
+ software_get_default_slot(result, "gba_rom");
}
/*-------------------------------------------------
diff --git a/src/emu/bus/gba/gba_slot.h b/src/emu/bus/gba/gba_slot.h
index efb3c9077a5..216c2ed0006 100644
--- a/src/emu/bus/gba/gba_slot.h
+++ b/src/emu/bus/gba/gba_slot.h
@@ -67,7 +67,7 @@ public:
// image-level overrides
virtual bool call_load();
virtual void call_unload();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
void install_rom();
@@ -88,7 +88,7 @@ public:
virtual const char *file_extensions() const { return "gba,bin"; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
// reading and writing
virtual DECLARE_READ32_MEMBER(read_rom);
diff --git a/src/emu/bus/ieee488/ieee488.c b/src/emu/bus/ieee488/ieee488.c
index deacdaa58c2..d2ebcee6a1a 100644
--- a/src/emu/bus/ieee488/ieee488.c
+++ b/src/emu/bus/ieee488/ieee488.c
@@ -156,7 +156,7 @@ void ieee488_device::device_stop()
void ieee488_device::add_device(ieee488_slot_device *slot, device_t *target)
{
- daisy_entry *entry = auto_alloc(machine(), daisy_entry(target));
+ daisy_entry *entry = global_alloc(daisy_entry(target));
entry->m_interface->m_bus = this;
entry->m_interface->m_slot = slot;
diff --git a/src/emu/bus/iq151/iq151.c b/src/emu/bus/iq151/iq151.c
index ff334a8ea80..39d13ae4aed 100644
--- a/src/emu/bus/iq151/iq151.c
+++ b/src/emu/bus/iq151/iq151.c
@@ -206,9 +206,9 @@ bool iq151cart_slot_device::call_load()
call softlist load
-------------------------------------------------*/
-bool iq151cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool iq151cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
@@ -216,7 +216,7 @@ bool iq151cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_e
get default card software
-------------------------------------------------*/
-const char * iq151cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void iq151cart_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, NULL);
+ software_get_default_slot(result, NULL);
}
diff --git a/src/emu/bus/iq151/iq151.h b/src/emu/bus/iq151/iq151.h
index 95eff69fe58..27e511168a0 100644
--- a/src/emu/bus/iq151/iq151.h
+++ b/src/emu/bus/iq151/iq151.h
@@ -100,7 +100,7 @@ public:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
virtual bool is_readable() const { return 1; }
@@ -113,7 +113,7 @@ public:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
// reading and writing
virtual void read(offs_t offset, UINT8 &data);
diff --git a/src/emu/bus/iq151/video32.c b/src/emu/bus/iq151/video32.c
index bcc0e84251d..ba37286246f 100644
--- a/src/emu/bus/iq151/video32.c
+++ b/src/emu/bus/iq151/video32.c
@@ -75,7 +75,7 @@ void iq151_video32_device::device_start()
m_videoram = (UINT8*)memregion("videoram")->base();
m_chargen = (UINT8*)memregion("chargen")->base();
- m_gfxdecode->set_gfx(0, auto_alloc(machine(), gfx_element(m_palette, iq151_video32_charlayout, m_chargen, 1, 0)));
+ m_gfxdecode->set_gfx(0, global_alloc(gfx_element(m_palette, iq151_video32_charlayout, m_chargen, 1, 0)));
}
//-------------------------------------------------
diff --git a/src/emu/bus/iq151/video64.c b/src/emu/bus/iq151/video64.c
index 6b67da2bacf..93720651c8f 100644
--- a/src/emu/bus/iq151/video64.c
+++ b/src/emu/bus/iq151/video64.c
@@ -74,7 +74,7 @@ void iq151_video64_device::device_start()
m_videoram = (UINT8*)memregion("videoram")->base();
m_chargen = (UINT8*)memregion("chargen")->base();
- m_gfxdecode->set_gfx(0,auto_alloc(machine(), gfx_element(m_palette, iq151_video64_charlayout, m_chargen, 1, 0)));
+ m_gfxdecode->set_gfx(0,global_alloc(gfx_element(m_palette, iq151_video64_charlayout, m_chargen, 1, 0)));
}
//-------------------------------------------------
diff --git a/src/emu/bus/kc/kc.c b/src/emu/bus/kc/kc.c
index 952152ca8d8..287e1e28825 100644
--- a/src/emu/bus/kc/kc.c
+++ b/src/emu/bus/kc/kc.c
@@ -380,9 +380,9 @@ bool kccart_slot_device::call_load()
call softlist load
-------------------------------------------------*/
-bool kccart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool kccart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
@@ -390,7 +390,7 @@ bool kccart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entr
get default card software
-------------------------------------------------*/
-const char * kccart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void kccart_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, "standard");
+ software_get_default_slot(result, "standard");
}
diff --git a/src/emu/bus/kc/kc.h b/src/emu/bus/kc/kc.h
index 1ec28892cd6..05ab3db5dbd 100644
--- a/src/emu/bus/kc/kc.h
+++ b/src/emu/bus/kc/kc.h
@@ -99,7 +99,7 @@ public:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
virtual bool is_readable() const { return 1; }
@@ -112,7 +112,7 @@ public:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
};
// device type definition
diff --git a/src/emu/bus/megadrive/md_slot.c b/src/emu/bus/megadrive/md_slot.c
index 3dfb90a2aac..25336f1352b 100644
--- a/src/emu/bus/megadrive/md_slot.c
+++ b/src/emu/bus/megadrive/md_slot.c
@@ -682,9 +682,9 @@ void base_md_cart_slot_device::setup_nvram()
call softlist load
-------------------------------------------------*/
-bool base_md_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool base_md_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
@@ -907,30 +907,29 @@ int base_md_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len)
get default card software
-------------------------------------------------*/
-const char * base_md_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void base_md_cart_slot_device::get_default_card_software(astring &result)
{
- if (open_image_file(options))
+ if (open_image_file(mconfig().options()))
{
const char *slot_string = "rom";
UINT32 len = core_fsize(m_file), offset = 0;
- UINT8 *ROM = global_alloc_array(UINT8, len);
+ dynamic_buffer rom(len);
int type;
- core_fread(m_file, ROM, len);
+ core_fread(m_file, rom, len);
- if (genesis_is_SMD(&ROM[0x200], len - 0x200))
+ if (genesis_is_SMD(&rom[0x200], len - 0x200))
offset = 0x200;
- type = get_cart_type(ROM + offset, len - offset);
+ type = get_cart_type(rom + offset, len - offset);
slot_string = md_get_slot(type);
- global_free(ROM);
clear();
- return slot_string;
+ result.cpy(slot_string);
}
else
- return software_get_default_slot(config, options, this, "rom");
+ software_get_default_slot(result, "rom");
}
diff --git a/src/emu/bus/megadrive/md_slot.h b/src/emu/bus/megadrive/md_slot.h
index 879b7dd862e..e4e2ab3dac6 100644
--- a/src/emu/bus/megadrive/md_slot.h
+++ b/src/emu/bus/megadrive/md_slot.h
@@ -155,7 +155,7 @@ public:
// image-level overrides
virtual bool call_load();
virtual void call_unload();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
virtual bool is_readable() const { return 1; }
@@ -166,7 +166,7 @@ public:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
int get_type() { return m_type; }
diff --git a/src/emu/bus/nes/aladdin.c b/src/emu/bus/nes/aladdin.c
index 0ddceeb347d..9a09aba7818 100644
--- a/src/emu/bus/nes/aladdin.c
+++ b/src/emu/bus/nes/aladdin.c
@@ -135,38 +135,37 @@ bool nes_aladdin_slot_device::call_load()
}
-bool nes_aladdin_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool nes_aladdin_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
-const char * nes_aladdin_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void nes_aladdin_slot_device::get_default_card_software(astring &result)
{
- if (open_image_file(options))
+ if (open_image_file(mconfig().options()))
{
const char *slot_string = "algn";
UINT32 len = core_fsize(m_file);
- UINT8 *ROM = global_alloc_array(UINT8, len);
+ dynamic_buffer rom(len);
UINT8 mapper;
- core_fread(m_file, ROM, len);
+ core_fread(m_file, rom, len);
- mapper = (ROM[6] & 0xf0) >> 4;
- mapper |= ROM[7] & 0xf0;
+ mapper = (rom[6] & 0xf0) >> 4;
+ mapper |= rom[7] & 0xf0;
// if (mapper == 71)
// slot_string = "algn";
if (mapper == 232)
slot_string = "algq";
- global_free(ROM);
clear();
- return slot_string;
+ result.cpy(slot_string);
}
else
- return software_get_default_slot(config, options, this, "algn");
+ software_get_default_slot(result, "algn");
}
diff --git a/src/emu/bus/nes/aladdin.h b/src/emu/bus/nes/aladdin.h
index f944c1127b5..922e9778a82 100644
--- a/src/emu/bus/nes/aladdin.h
+++ b/src/emu/bus/nes/aladdin.h
@@ -50,7 +50,7 @@ public:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
virtual bool is_readable() const { return 1; }
@@ -63,7 +63,7 @@ public:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
virtual DECLARE_READ8_MEMBER(read);
void write_prg(UINT32 offset, UINT8 data) { if (m_cart) m_cart->write_prg(offset, data); }
diff --git a/src/emu/bus/nes/datach.c b/src/emu/bus/nes/datach.c
index babd3f94454..b16efe9ffdf 100644
--- a/src/emu/bus/nes/datach.c
+++ b/src/emu/bus/nes/datach.c
@@ -138,16 +138,16 @@ bool nes_datach_slot_device::call_load()
}
-bool nes_datach_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool nes_datach_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
-const char * nes_datach_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void nes_datach_slot_device::get_default_card_software(astring &result)
{
// any way to detect the game with X24C01?
- return software_get_default_slot(config, options, this, "datach_rom");
+ software_get_default_slot(result, "datach_rom");
}
diff --git a/src/emu/bus/nes/datach.h b/src/emu/bus/nes/datach.h
index a65fd683231..6fc8cd5e0b4 100644
--- a/src/emu/bus/nes/datach.h
+++ b/src/emu/bus/nes/datach.h
@@ -52,7 +52,7 @@ public:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
virtual bool is_readable() const { return 1; }
@@ -65,7 +65,7 @@ public:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
virtual DECLARE_READ8_MEMBER(read);
void write_prg_bank(UINT8 bank) { if (m_cart) m_cart->write_prg_bank(bank); }
diff --git a/src/emu/bus/nes/karastudio.c b/src/emu/bus/nes/karastudio.c
index a62dc44ec1b..d331cbdeb4d 100644
--- a/src/emu/bus/nes/karastudio.c
+++ b/src/emu/bus/nes/karastudio.c
@@ -127,15 +127,15 @@ bool nes_kstudio_slot_device::call_load()
}
-bool nes_kstudio_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool nes_kstudio_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
-const char * nes_kstudio_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void nes_kstudio_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, "ks_exp");
+ software_get_default_slot(result, "ks_exp");
}
diff --git a/src/emu/bus/nes/karastudio.h b/src/emu/bus/nes/karastudio.h
index 1acd4fcbe6a..d3c8f2a6568 100644
--- a/src/emu/bus/nes/karastudio.h
+++ b/src/emu/bus/nes/karastudio.h
@@ -49,7 +49,7 @@ public:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
virtual bool is_readable() const { return 1; }
@@ -62,7 +62,7 @@ public:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
virtual DECLARE_READ8_MEMBER(read);
void write_prg_bank(UINT8 bank) { if (m_cart) m_cart->write_prg_bank(bank); }
diff --git a/src/emu/bus/nes/nes_ines.inc b/src/emu/bus/nes/nes_ines.inc
index c564697f982..77c1aca7d4a 100644
--- a/src/emu/bus/nes/nes_ines.inc
+++ b/src/emu/bus/nes/nes_ines.inc
@@ -342,14 +342,11 @@ void nes_cart_slot_device::call_load_ines()
UINT8 header[0x10];
UINT8 mapper, submapper = 0, local_options;
bool ines20 = FALSE, prg16k;
- const char *mapinfo = NULL;
+ astring mapinfo;
int pcb_id = 0, mapint1 = 0, mapint2 = 0, mapint3 = 0, mapint4 = 0;
int crc_hack = 0;
bool bus_conflict = FALSE;
- // check if the image is recognized by nes.hsi
- mapinfo = hashfile_extrainfo(*this);
-
// read out the header
fseek(0, SEEK_SET);
fread(&header, 0x10);
@@ -380,7 +377,7 @@ void nes_cart_slot_device::call_load_ines()
}
// use info from nes.hsi if available!
- if (mapinfo)
+ if (hashfile_extrainfo(*this, mapinfo))
{
if (4 == sscanf(mapinfo,"%d %d %d %d", &mapint1, &mapint2, &mapint3, &mapint4))
{
@@ -395,7 +392,7 @@ void nes_cart_slot_device::call_load_ines()
}
else
{
- logerror("NES: [%s], Invalid mapinfo found\n", mapinfo);
+ logerror("NES: [%s], Invalid mapinfo found\n", mapinfo.cstr());
}
}
else
@@ -818,13 +815,10 @@ const char * nes_cart_slot_device::get_default_card_ines(UINT8 *ROM, UINT32 len)
{
UINT8 mapper, submapper = 0;
bool ines20 = FALSE;
- const char *mapinfo = NULL;
+ astring mapinfo;
int pcb_id = 0, mapint1 = 0, mapint2 = 0, mapint3 = 0, mapint4 = 0;
int crc_hack = 0;
- // check if the image is recognized by nes.hsi
-// mapinfo = hashfile_extrainfo(*this);
-
mapper = (ROM[6] & 0xf0) >> 4;
switch (ROM[7] & 0xc)
@@ -843,7 +837,8 @@ const char * nes_cart_slot_device::get_default_card_ines(UINT8 *ROM, UINT32 len)
}
// use info from nes.hsi if available!
- if (mapinfo)
+// if (hashfile_extrainfo(*this, mapinfo))
+ if (0)
{
if (4 == sscanf(mapinfo,"%d %d %d %d", &mapint1, &mapint2, &mapint3, &mapint4))
{
diff --git a/src/emu/bus/nes/nes_slot.c b/src/emu/bus/nes/nes_slot.c
index 52a80b1618d..a206b4c69a6 100644
--- a/src/emu/bus/nes/nes_slot.c
+++ b/src/emu/bus/nes/nes_slot.c
@@ -957,9 +957,9 @@ void nes_cart_slot_device::call_unload()
call softlist load
-------------------------------------------------*/
-bool nes_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool nes_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
@@ -967,29 +967,28 @@ bool nes_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_en
get default card software
-------------------------------------------------*/
-const char * nes_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void nes_cart_slot_device::get_default_card_software(astring &result)
{
- if (open_image_file(options))
+ if (open_image_file(mconfig().options()))
{
const char *slot_string = "nrom";
UINT32 len = core_fsize(m_file);
- UINT8 *ROM = global_alloc_array(UINT8, len);
+ dynamic_buffer rom(len);
- core_fread(m_file, ROM, len);
+ core_fread(m_file, rom, len);
- if ((ROM[0] == 'N') && (ROM[1] == 'E') && (ROM[2] == 'S'))
- slot_string = get_default_card_ines(ROM, len);
+ if ((rom[0] == 'N') && (rom[1] == 'E') && (rom[2] == 'S'))
+ slot_string = get_default_card_ines(rom, len);
- if ((ROM[0] == 'U') && (ROM[1] == 'N') && (ROM[2] == 'I') && (ROM[3] == 'F'))
- slot_string = get_default_card_unif(ROM, len);
+ if ((rom[0] == 'U') && (rom[1] == 'N') && (rom[2] == 'I') && (rom[3] == 'F'))
+ slot_string = get_default_card_unif(rom, len);
- global_free(ROM);
clear();
- return slot_string;
+ result.cpy(slot_string);
}
else
- return software_get_default_slot(config, options, this, "nrom");
+ software_get_default_slot(result, "nrom");
}
diff --git a/src/emu/bus/nes/nes_slot.h b/src/emu/bus/nes/nes_slot.h
index a264caa64f5..b7a7c633603 100644
--- a/src/emu/bus/nes/nes_slot.h
+++ b/src/emu/bus/nes/nes_slot.h
@@ -346,7 +346,7 @@ public:
// image-level overrides
virtual bool call_load();
virtual void call_unload();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
void call_load_ines();
void call_load_unif();
@@ -364,7 +364,7 @@ public:
virtual device_image_partialhash_func get_partial_hash() const { return &nes_partialhash; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
const char * get_default_card_ines(UINT8 *ROM, UINT32 len);
const char * get_default_card_unif(UINT8 *ROM, UINT32 len);
const char * nes_get_slot(int pcb_id);
diff --git a/src/emu/bus/nes/sunsoft_dcs.c b/src/emu/bus/nes/sunsoft_dcs.c
index 015f45ed055..8150cc255bc 100644
--- a/src/emu/bus/nes/sunsoft_dcs.c
+++ b/src/emu/bus/nes/sunsoft_dcs.c
@@ -106,15 +106,15 @@ bool nes_ntb_slot_device::call_load()
}
-bool nes_ntb_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool nes_ntb_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
-const char * nes_ntb_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void nes_ntb_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, "ntbrom");
+ software_get_default_slot(result, "ntbrom");
}
//-----------------------------------------------
diff --git a/src/emu/bus/nes/sunsoft_dcs.h b/src/emu/bus/nes/sunsoft_dcs.h
index 342af98a1fc..c11794fd640 100644
--- a/src/emu/bus/nes/sunsoft_dcs.h
+++ b/src/emu/bus/nes/sunsoft_dcs.h
@@ -46,7 +46,7 @@ public:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
virtual bool is_readable() const { return 1; }
@@ -59,7 +59,7 @@ public:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
virtual DECLARE_READ8_MEMBER(read);
diff --git a/src/emu/bus/plus4/exp.c b/src/emu/bus/plus4/exp.c
index 6ee8212c236..d49bb98b970 100644
--- a/src/emu/bus/plus4/exp.c
+++ b/src/emu/bus/plus4/exp.c
@@ -148,9 +148,9 @@ bool plus4_expansion_slot_device::call_load()
// call_softlist_load -
//-------------------------------------------------
-bool plus4_expansion_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool plus4_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry);
+ load_software_part_region(*this, swlist, swname, start_entry);
return true;
}
@@ -160,9 +160,9 @@ bool plus4_expansion_slot_device::call_softlist_load(char *swlist, char *swname,
// get_default_card_software -
//-------------------------------------------------
-const char * plus4_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void plus4_expansion_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, "standard");
+ software_get_default_slot(result, "standard");
}
diff --git a/src/emu/bus/plus4/exp.h b/src/emu/bus/plus4/exp.h
index 16bcb8096bf..dcdffcecdfc 100644
--- a/src/emu/bus/plus4/exp.h
+++ b/src/emu/bus/plus4/exp.h
@@ -116,7 +116,7 @@ protected:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
@@ -130,7 +130,7 @@ protected:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
devcb2_write_line m_write_irq;
devcb2_read8 m_read_dma_cd;
diff --git a/src/emu/bus/saturn/sat_slot.c b/src/emu/bus/saturn/sat_slot.c
index cc6d66786e0..8db3368ed4a 100644
--- a/src/emu/bus/saturn/sat_slot.c
+++ b/src/emu/bus/saturn/sat_slot.c
@@ -173,9 +173,9 @@ void sat_cart_slot_device::call_unload()
call softlist load
-------------------------------------------------*/
-bool sat_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool sat_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
@@ -184,9 +184,9 @@ bool sat_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_en
get default card software
-------------------------------------------------*/
-const char * sat_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void sat_cart_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, "rom");
+ software_get_default_slot(result, "rom");
}
diff --git a/src/emu/bus/saturn/sat_slot.h b/src/emu/bus/saturn/sat_slot.h
index d610494e65c..9dc0070cd07 100644
--- a/src/emu/bus/saturn/sat_slot.h
+++ b/src/emu/bus/saturn/sat_slot.h
@@ -72,7 +72,7 @@ public:
// image-level overrides
virtual bool call_load();
virtual void call_unload();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
int get_cart_type();
@@ -87,7 +87,7 @@ public:
virtual const char *file_extensions() const { return "bin"; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
// reading and writing
virtual DECLARE_READ32_MEMBER(read_rom);
diff --git a/src/emu/bus/sega8/sega8_slot.c b/src/emu/bus/sega8/sega8_slot.c
index c8ebf5297cb..e30306f3257 100644
--- a/src/emu/bus/sega8/sega8_slot.c
+++ b/src/emu/bus/sega8/sega8_slot.c
@@ -429,9 +429,9 @@ void sega8_cart_slot_device::call_unload()
call softlist load
-------------------------------------------------*/
-bool sega8_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool sega8_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry);
+ load_software_part_region(*this, swlist, swname, start_entry);
return TRUE;
}
@@ -610,31 +610,31 @@ int sega8_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len)
get default card software
-------------------------------------------------*/
-const char * sega8_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void sega8_cart_slot_device::get_default_card_software(astring &result)
{
- if (open_image_file(options))
+ if (open_image_file(mconfig().options()))
{
const char *slot_string = "rom";
UINT32 len = core_fsize(m_file), offset = 0;
- UINT8 *ROM = global_alloc_array(UINT8, len);
+ dynamic_buffer rom(len);
int type;
- core_fread(m_file, ROM, len);
+ core_fread(m_file, rom, len);
if ((len % 0x4000) == 512)
offset = 512;
- type = get_cart_type(ROM + offset, len - offset);
+ type = get_cart_type(rom + offset, len - offset);
slot_string = sega8_get_slot(type);
//printf("type: %s\n", slot_string);
- global_free(ROM);
clear();
- return slot_string;
+ result.cpy(slot_string);
+ return;
}
- return software_get_default_slot(config, options, this, "rom");
+ software_get_default_slot(result, "rom");
}
diff --git a/src/emu/bus/sega8/sega8_slot.h b/src/emu/bus/sega8/sega8_slot.h
index 5f11457cc5a..c7d32c2e440 100644
--- a/src/emu/bus/sega8/sega8_slot.h
+++ b/src/emu/bus/sega8/sega8_slot.h
@@ -110,7 +110,7 @@ public:
// image-level overrides
virtual bool call_load();
virtual void call_unload();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
int get_type() { return m_type; }
int get_cart_type(UINT8 *ROM, UINT32 len);
@@ -135,7 +135,7 @@ public:
virtual const char *file_extensions() const { return m_extensions; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
// reading and writing
virtual DECLARE_READ8_MEMBER(read_cart);
diff --git a/src/emu/bus/snes/snes_slot.c b/src/emu/bus/snes/snes_slot.c
index 6765685841f..735bfe856a0 100644
--- a/src/emu/bus/snes/snes_slot.c
+++ b/src/emu/bus/snes/snes_slot.c
@@ -909,9 +909,9 @@ void base_sns_cart_slot_device::setup_nvram()
call softlist load
-------------------------------------------------*/
-bool base_sns_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool base_sns_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
@@ -1024,23 +1024,23 @@ void base_sns_cart_slot_device::get_cart_type_addon(UINT8 *ROM, UINT32 len, int
get default card software
-------------------------------------------------*/
-const char * base_sns_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void base_sns_cart_slot_device::get_default_card_software(astring &result)
{
- bool fullpath = open_image_file(options);
+ bool fullpath = open_image_file(mconfig().options());
if (fullpath)
{
const char *slot_string = "lorom";
UINT32 offset = 0;
UINT32 len = core_fsize(m_file);
- UINT8 *ROM = global_alloc_array(UINT8, len);
+ dynamic_buffer rom(len);
int type = 0, addon = 0;
- core_fread(m_file, ROM, len);
+ core_fread(m_file, rom, len);
- offset = snes_skip_header(ROM, len);
+ offset = snes_skip_header(rom, len);
- get_cart_type_addon(ROM + offset, len - offset, type, addon);
+ get_cart_type_addon(rom + offset, len - offset, type, addon);
// here we're from fullpath, so check if it's a DSP game which needs legacy device (i.e. it has no appended DSP dump)
switch (addon)
{
@@ -1081,13 +1081,13 @@ const char * base_sns_cart_slot_device::get_default_card_software(const machine_
slot_string = sns_get_slot(type);
- global_free(ROM);
clear();
- return slot_string;
+ result.cpy(slot_string);
+ return;
}
- return software_get_default_slot(config, options, this, "lorom");
+ software_get_default_slot(result, "lorom");
}
diff --git a/src/emu/bus/snes/snes_slot.h b/src/emu/bus/snes/snes_slot.h
index a5710cda74b..8951fb27a0c 100644
--- a/src/emu/bus/snes/snes_slot.h
+++ b/src/emu/bus/snes/snes_slot.h
@@ -166,7 +166,7 @@ public:
// image-level overrides
virtual bool call_load();
virtual void call_unload();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
void get_cart_type_addon(UINT8 *ROM, UINT32 len, int &type, int &addon);
UINT32 snes_skip_header(UINT8 *ROM, UINT32 snes_rom_size);
@@ -184,7 +184,7 @@ public:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
// reading and writing
virtual DECLARE_READ8_MEMBER(read_l);
diff --git a/src/emu/bus/vic10/exp.c b/src/emu/bus/vic10/exp.c
index 4b698463325..0757af5edf9 100644
--- a/src/emu/bus/vic10/exp.c
+++ b/src/emu/bus/vic10/exp.c
@@ -173,9 +173,9 @@ bool vic10_expansion_slot_device::call_load()
// call_softlist_load -
//-------------------------------------------------
-bool vic10_expansion_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool vic10_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry);
+ load_software_part_region(*this, swlist, swname, start_entry);
return true;
}
@@ -185,19 +185,20 @@ bool vic10_expansion_slot_device::call_softlist_load(char *swlist, char *swname,
// get_default_card_software -
//-------------------------------------------------
-const char * vic10_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void vic10_expansion_slot_device::get_default_card_software(astring &result)
{
- if (open_image_file(options))
+ if (open_image_file(mconfig().options()))
{
if (!mame_stricmp(filetype(), "crt"))
{
- return cbm_crt_get_card(m_file);
+ cbm_crt_get_card(result, m_file);
+ return;
}
clear();
}
- return software_get_default_slot(config, options, this, "standard");
+ software_get_default_slot(result, "standard");
}
diff --git a/src/emu/bus/vic10/exp.h b/src/emu/bus/vic10/exp.h
index 36d92009625..a190fbafd6c 100644
--- a/src/emu/bus/vic10/exp.h
+++ b/src/emu/bus/vic10/exp.h
@@ -115,7 +115,7 @@ protected:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
@@ -129,7 +129,7 @@ protected:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
devcb2_write_line m_write_irq;
devcb2_write_line m_write_res;
diff --git a/src/emu/bus/vic20/exp.c b/src/emu/bus/vic20/exp.c
index 4ce4403e4bf..7f6cf3db6eb 100644
--- a/src/emu/bus/vic20/exp.c
+++ b/src/emu/bus/vic20/exp.c
@@ -158,9 +158,9 @@ bool vic20_expansion_slot_device::call_load()
// call_softlist_load -
//-------------------------------------------------
-bool vic20_expansion_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool vic20_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry);
+ load_software_part_region(*this, swlist, swname, start_entry);
return true;
}
@@ -170,9 +170,9 @@ bool vic20_expansion_slot_device::call_softlist_load(char *swlist, char *swname,
// get_default_card_software -
//-------------------------------------------------
-const char * vic20_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void vic20_expansion_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, "standard");
+ software_get_default_slot(result, "standard");
}
diff --git a/src/emu/bus/vic20/exp.h b/src/emu/bus/vic20/exp.h
index aa9db53acfe..94e0c8fd145 100644
--- a/src/emu/bus/vic20/exp.h
+++ b/src/emu/bus/vic20/exp.h
@@ -108,7 +108,7 @@ protected:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
@@ -122,7 +122,7 @@ protected:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
devcb2_write_line m_write_irq;
devcb2_write_line m_write_nmi;
diff --git a/src/emu/bus/vidbrain/exp.c b/src/emu/bus/vidbrain/exp.c
index 0645280cfc1..f2efbe9d2bd 100644
--- a/src/emu/bus/vidbrain/exp.c
+++ b/src/emu/bus/vidbrain/exp.c
@@ -188,9 +188,9 @@ bool videobrain_expansion_slot_device::call_load()
// call_softlist_load -
//-------------------------------------------------
-bool videobrain_expansion_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool videobrain_expansion_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry);
+ load_software_part_region(*this, swlist, swname, start_entry);
return true;
}
@@ -200,9 +200,9 @@ bool videobrain_expansion_slot_device::call_softlist_load(char *swlist, char *sw
// get_default_card_software -
//-------------------------------------------------
-const char * videobrain_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void videobrain_expansion_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, "standard");
+ software_get_default_slot(result, "standard");
}
diff --git a/src/emu/bus/vidbrain/exp.h b/src/emu/bus/vidbrain/exp.h
index 018038350ec..dc07320b0f6 100644
--- a/src/emu/bus/vidbrain/exp.h
+++ b/src/emu/bus/vidbrain/exp.h
@@ -116,7 +116,7 @@ protected:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
@@ -130,7 +130,7 @@ protected:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
devcb_resolved_write_line m_out_extres_func;
diff --git a/src/emu/bus/z88/z88.c b/src/emu/bus/z88/z88.c
index c3b409c3eb0..1e3645114bb 100644
--- a/src/emu/bus/z88/z88.c
+++ b/src/emu/bus/z88/z88.c
@@ -184,9 +184,9 @@ void z88cart_slot_device::call_unload()
call softlist load
-------------------------------------------------*/
-bool z88cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
+bool z88cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry)
{
- load_software_part_region(this, swlist, swname, start_entry );
+ load_software_part_region(*this, swlist, swname, start_entry );
return TRUE;
}
@@ -194,9 +194,9 @@ bool z88cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_ent
get default card software
-------------------------------------------------*/
-const char * z88cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
+void z88cart_slot_device::get_default_card_software(astring &result)
{
- return software_get_default_slot(config, options, this, "128krom");
+ software_get_default_slot(result, "128krom");
}
diff --git a/src/emu/bus/z88/z88.h b/src/emu/bus/z88/z88.h
index f853ac25d56..754aa0a824f 100644
--- a/src/emu/bus/z88/z88.h
+++ b/src/emu/bus/z88/z88.h
@@ -103,7 +103,7 @@ public:
// image-level overrides
virtual bool call_load();
virtual void call_unload();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry);
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
virtual bool is_readable() const { return 1; }
@@ -116,7 +116,7 @@ public:
virtual const option_guide *create_option_guide() const { return NULL; }
// slot interface overrides
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
+ virtual void get_default_card_software(astring &result);
// reading and writing
virtual DECLARE_READ8_MEMBER(read);
diff --git a/src/emu/cheat.c b/src/emu/cheat.c
index 4d591967d92..bd4e10ca58d 100644
--- a/src/emu/cheat.c
+++ b/src/emu/cheat.c
@@ -136,8 +136,7 @@ inline const char *number_and_format::format(astring &string) const
//-------------------------------------------------
cheat_parameter::cheat_parameter(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node &paramnode)
- : m_value(0),
- m_itemlist(manager.machine().respool())
+ : m_value(0)
{
// read the core attributes
m_minval = number_and_format(xml_get_attribute_int(&paramnode, "min", 0), xml_get_attribute_int_format(&paramnode, "min"));
@@ -160,7 +159,7 @@ cheat_parameter::cheat_parameter(cheat_manager &manager, symbol_table &symbols,
int format = xml_get_attribute_int_format(itemnode, "value");
// allocate and append a new item
- item &curitem = m_itemlist.append(*auto_alloc(manager.machine(), item(itemnode->value, value, format)));
+ item &curitem = m_itemlist.append(*global_alloc(item(itemnode->value, value, format)));
// ensure the maximum expands to suit
m_maxval = MAX(m_maxval, curitem.value());
@@ -317,8 +316,7 @@ bool cheat_parameter::set_next_state()
//-------------------------------------------------
cheat_script::cheat_script(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node &scriptnode)
- : m_entrylist(manager.machine().respool()),
- m_state(SCRIPT_STATE_RUN)
+ : m_state(SCRIPT_STATE_RUN)
{
// read the core attributes
const char *state = xml_get_attribute_string(&scriptnode, "state", "run");
@@ -336,11 +334,11 @@ cheat_script::cheat_script(cheat_manager &manager, symbol_table &symbols, const
{
// handle action nodes
if (strcmp(entrynode->name, "action") == 0)
- m_entrylist.append(*auto_alloc(manager.machine(), script_entry(manager, symbols, filename, *entrynode, true)));
+ m_entrylist.append(*global_alloc(script_entry(manager, symbols, filename, *entrynode, true)));
// handle output nodes
else if (strcmp(entrynode->name, "output") == 0)
- m_entrylist.append(*auto_alloc(manager.machine(), script_entry(manager, symbols, filename, *entrynode, false)));
+ m_entrylist.append(*global_alloc(script_entry(manager, symbols, filename, *entrynode, false)));
// anything else is ignored
else
@@ -402,8 +400,7 @@ void cheat_script::save(emu_file &cheatfile) const
cheat_script::script_entry::script_entry(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node &entrynode, bool isaction)
: m_next(NULL),
m_condition(&symbols),
- m_expression(&symbols),
- m_arglist(manager.machine().respool())
+ m_expression(&symbols)
{
const char *expression = NULL;
try
@@ -446,7 +443,7 @@ cheat_script::script_entry::script_entry(cheat_manager &manager, symbol_table &s
int totalargs = 0;
for (xml_data_node *argnode = xml_get_sibling(entrynode.child, "argument"); argnode != NULL; argnode = xml_get_sibling(argnode->next, "argument"))
{
- output_argument &curarg = m_arglist.append(*auto_alloc(manager.machine(), output_argument(manager, symbols, filename, *argnode)));
+ output_argument &curarg = m_arglist.append(*global_alloc(output_argument(manager, symbols, filename, *argnode)));
// verify we didn't overrun the argument count
totalargs += curarg.count();
@@ -684,7 +681,6 @@ void cheat_script::script_entry::output_argument::save(emu_file &cheatfile) cons
cheat_entry::cheat_entry(cheat_manager &manager, symbol_table &globaltable, const char *filename, xml_data_node &cheatnode)
: m_manager(manager),
m_next(NULL),
- m_parameter(NULL),
m_on_script(NULL),
m_off_script(NULL),
m_change_script(NULL),
@@ -736,7 +732,7 @@ cheat_entry::cheat_entry(cheat_manager &manager, symbol_table &globaltable, cons
if (paramnode != NULL)
{
// load this parameter
- m_parameter = auto_alloc(manager.machine(), cheat_parameter(manager, m_symbols, filename, *paramnode));
+ m_parameter.reset(global_alloc(cheat_parameter(manager, m_symbols, filename, *paramnode)));
// only one parameter allowed
paramnode = xml_get_sibling(paramnode->next, "parameter");
@@ -748,14 +744,14 @@ cheat_entry::cheat_entry(cheat_manager &manager, symbol_table &globaltable, cons
for (xml_data_node *scriptnode = xml_get_sibling(cheatnode.child, "script"); scriptnode != NULL; scriptnode = xml_get_sibling(scriptnode->next, "script"))
{
// load this entry
- cheat_script *curscript = auto_alloc(manager.machine(), cheat_script(manager, m_symbols, filename, *scriptnode));
+ cheat_script *curscript = global_alloc(cheat_script(manager, m_symbols, filename, *scriptnode));
// if we have a script already for this slot, it is an error
- cheat_script *&slot = script_for_state(curscript->state());
+ auto_pointer<cheat_script> &slot = script_for_state(curscript->state());
if (slot != NULL)
mame_printf_warning("%s.xml(%d): only one on script allowed; ignoring additional scripts\n", filename, scriptnode->line);
else
- slot = curscript;
+ slot.reset(curscript);
}
}
catch (emu_fatalerror &)
@@ -773,11 +769,6 @@ cheat_entry::cheat_entry(cheat_manager &manager, symbol_table &globaltable, cons
cheat_entry::~cheat_entry()
{
- auto_free(m_manager.machine(), m_on_script);
- auto_free(m_manager.machine(), m_off_script);
- auto_free(m_manager.machine(), m_change_script);
- auto_free(m_manager.machine(), m_run_script);
- auto_free(m_manager.machine(), m_parameter);
}
@@ -1034,7 +1025,7 @@ bool cheat_entry::set_state(script_state newstate)
// given script pointer
//-------------------------------------------------
-cheat_script *&cheat_entry::script_for_state(script_state state)
+auto_pointer<cheat_script> &cheat_entry::script_for_state(script_state state)
{
switch (state)
{
@@ -1058,7 +1049,6 @@ cheat_script *&cheat_entry::script_for_state(script_state state)
cheat_manager::cheat_manager(running_machine &machine)
: m_machine(machine),
- m_cheatlist(machine.respool()),
m_disabled(true),
m_symtable(&machine)
{
@@ -1411,7 +1401,7 @@ void cheat_manager::load_cheats(const char *filename)
for (xml_data_node *cheatnode = xml_get_sibling(mamecheatnode->child, "cheat"); cheatnode != NULL; cheatnode = xml_get_sibling(cheatnode->next, "cheat"))
{
// load this entry
- cheat_entry *curcheat = auto_alloc(machine(), cheat_entry(*this, m_symtable, filename, *cheatnode));
+ cheat_entry *curcheat = global_alloc(cheat_entry(*this, m_symtable, filename, *cheatnode));
// make sure we're not a duplicate
cheat_entry *scannode = NULL;
@@ -1427,7 +1417,7 @@ void cheat_manager::load_cheats(const char *filename)
if (scannode == NULL)
m_cheatlist.append(*curcheat);
else
- auto_free(machine(), curcheat);
+ global_free(curcheat);
}
// free the file and loop for the next one
diff --git a/src/emu/cheat.h b/src/emu/cheat.h
index 81bfc999496..601687c7882 100644
--- a/src/emu/cheat.h
+++ b/src/emu/cheat.h
@@ -260,18 +260,18 @@ public:
private:
// internal helpers
bool set_state(script_state newstate);
- cheat_script *&script_for_state(script_state state);
+ auto_pointer<cheat_script> &script_for_state(script_state state);
// internal state
cheat_manager & m_manager; // reference to our manager
cheat_entry * m_next; // next cheat entry
astring m_description; // string description/menu title
astring m_comment; // comment data
- cheat_parameter * m_parameter; // parameter
- cheat_script * m_on_script; // script to run when turning on
- cheat_script * m_off_script; // script to run when turning off
- cheat_script * m_change_script; // script to run when value changes
- cheat_script * m_run_script; // script to run each frame when on
+ auto_pointer<cheat_parameter> m_parameter; // parameter
+ auto_pointer<cheat_script> m_on_script; // script to run when turning on
+ auto_pointer<cheat_script> m_off_script; // script to run when turning off
+ auto_pointer<cheat_script> m_change_script; // script to run when value changes
+ auto_pointer<cheat_script> m_run_script; // script to run each frame when on
symbol_table m_symbols; // symbol table for this cheat
script_state m_state; // current cheat state
UINT32 m_numtemp; // number of temporary variables
diff --git a/src/emu/clifront.c b/src/emu/clifront.c
index 6e9846aa0bc..2167d47784d 100644
--- a/src/emu/clifront.c
+++ b/src/emu/clifront.c
@@ -94,7 +94,8 @@ cli_options::cli_options()
cli_frontend::cli_frontend(cli_options &options, osd_interface &osd)
: m_options(options),
m_osd(osd),
- m_result(MAMERR_NONE)
+ m_result(MAMERR_NONE),
+ m_start_memory(next_memory_id())
{
// begin tracking memory
track_memory(true);
@@ -107,10 +108,13 @@ cli_frontend::cli_frontend(cli_options &options, osd_interface &osd)
cli_frontend::~cli_frontend()
{
+ // nuke any device options since they will leak memory
+ m_options.remove_device_options();
+
// report any unfreed memory on clean exits
track_memory(false);
if (m_result == MAMERR_NONE)
- dump_unfreed_mem();
+ dump_unfreed_mem(m_start_memory);
}
@@ -128,6 +132,7 @@ int cli_frontend::execute(int argc, char **argv)
// first parse options to be able to get software from it
astring option_errors;
m_options.parse_command_line(argc, argv, option_errors);
+
// We need to preprocess the config files once to determine the web server's configuration
// and file locations
if (m_options.read_config())
@@ -146,58 +151,56 @@ int cli_frontend::execute(int argc, char **argv)
if (iter.first() == NULL)
throw emu_fatalerror(MAMERR_FATALERROR, "Error: unknown option: %s\n", m_options.software_name());
- bool found = FALSE;
- for (software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
+ bool found = false;
+ for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next())
{
- software_list *list = software_list_open(m_options, swlist->list_name(), FALSE, NULL);
- if (list)
+ software_info *swinfo = swlistdev->find(m_options.software_name());
+ if (swinfo != NULL)
{
- software_info *swinfo = software_list_find(list, m_options.software_name(), NULL);
- if (swinfo != NULL)
+ // loop through all parts
+ for (software_part *swpart = swinfo->first_part(); swpart != NULL; swpart = swpart->next())
{
- // loop through all parts
- for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
+ const char *mount = swpart->feature("automount");
+ if (swpart->is_compatible(*swlistdev))
{
- const char *mount = software_part_get_feature(swpart, "automount");
- if (is_software_compatible(swpart, swlist))
+ if (mount == NULL || strcmp(mount,"no") != 0)
{
- if (mount == NULL || strcmp(mount,"no") != 0)
+ // search for an image device with the right interface
+ image_interface_iterator imgiter(config.root_device());
+ for (device_image_interface *image = imgiter.first(); image != NULL; image = imgiter.next())
{
- // search for an image device with the right interface
- image_interface_iterator imgiter(config.root_device());
- for (device_image_interface *image = imgiter.first(); image != NULL; image = imgiter.next())
+ const char *interface = image->image_interface();
+ if (interface != NULL)
{
- const char *interface = image->image_interface();
- if (interface != NULL)
+ if (swpart->matches_interface(interface))
{
- if (softlist_contain_interface(interface, swpart->interface_))
+ const char *option = m_options.value(image->brief_instance_name());
+
+ // mount only if not already mounted
+ if (*option == 0)
{
- const char *option = m_options.value(image->brief_instance_name());
- // mount only if not already mounted
- if (*option == 0)
- {
- astring val;
- val.printf("%s:%s:%s",swlist->list_name(),m_options.software_name(),swpart->name);
- // call this in order to set slot devices according to mounting
- m_options.parse_slot_devices(argc, argv, option_errors, image->instance_name(), val.cstr());
- break;
- }
+ astring val;
+ val.printf("%s:%s:%s", swlistdev->list_name(), m_options.software_name(), swpart->name());
+
+ // call this in order to set slot devices according to mounting
+ m_options.parse_slot_devices(argc, argv, option_errors, image->instance_name(), val.cstr());
+ break;
}
}
}
}
- found = TRUE;
}
+ found = true;
}
}
- software_list_close(list);
}
- if (found) break;
+ if (found)
+ break;
}
if (!found)
{
- software_display_matches(config,m_options, NULL,m_options.software_name());
+ software_list_device::display_matches(config, NULL, m_options.software_name());
throw emu_fatalerror(MAMERR_FATALERROR, NULL);
}
}
@@ -229,6 +232,7 @@ int cli_frontend::execute(int argc, char **argv)
const game_driver *system = m_options.system();
if (system == NULL && *(m_options.system_name()) != 0)
throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name());
+
// otherwise just run the game
m_result = mame_execute(m_options, m_osd);
}
@@ -963,7 +967,6 @@ void cli_frontend::verifyroms(const char *gamename)
}
const_cast<machine_config &>(config).device_remove(&config.root_device(), temptag.cstr());
- global_free(dev);
}
}
}
@@ -1143,54 +1146,41 @@ void cli_frontend::verifysamples(const char *gamename)
"]>\n\n" \
"<softwarelists>\n"
-void cli_frontend::output_single_softlist(FILE *out,software_list *list, const char *listname)
+void cli_frontend::output_single_softlist(FILE *out, software_list_device &swlistdev)
{
astring tempstr;
- software_list_parse( list, NULL, NULL );
- fprintf(out, "\t<softwarelist name=\"%s\" description=\"%s\">\n", listname, xml_normalize_string(software_list_get_description(list)) );
-
- for ( software_info *swinfo = software_list_find( list, "*", NULL ); swinfo != NULL; swinfo = software_list_find( list, "*", swinfo ) )
+ fprintf(out, "\t<softwarelist name=\"%s\" description=\"%s\">\n", swlistdev.list_name(), xml_normalize_string(swlistdev.description()));
+ for (software_info *swinfo = swlistdev.first_software_info(); swinfo != NULL; swinfo = swinfo->next())
{
- fprintf( out, "\t\t<software name=\"%s\"", swinfo->shortname );
- if ( swinfo->parentname != NULL )
- fprintf( out, " cloneof=\"%s\"", swinfo->parentname );
- if ( swinfo->supported == SOFTWARE_SUPPORTED_PARTIAL )
+ fprintf( out, "\t\t<software name=\"%s\"", swinfo->shortname() );
+ if ( swinfo->parentname() != NULL )
+ fprintf( out, " cloneof=\"%s\"", swinfo->parentname() );
+ if ( swinfo->supported() == SOFTWARE_SUPPORTED_PARTIAL )
fprintf( out, " supported=\"partial\"" );
- if ( swinfo->supported == SOFTWARE_SUPPORTED_NO )
+ if ( swinfo->supported() == SOFTWARE_SUPPORTED_NO )
fprintf( out, " supported=\"no\"" );
fprintf( out, ">\n" );
- fprintf( out, "\t\t\t<description>%s</description>\n", xml_normalize_string(swinfo->longname) );
- fprintf( out, "\t\t\t<year>%s</year>\n", xml_normalize_string( swinfo->year ) );
- fprintf( out, "\t\t\t<publisher>%s</publisher>\n", xml_normalize_string( swinfo->publisher ) );
-
- feature_list *flist = swinfo->other_info;
- while ( flist ) {
- fprintf( out, "\t\t\t<info name=\"%s\" value=\"%s\"/>\n", flist->name, xml_normalize_string( flist->value ) );
- flist = flist->next;
- }
+ fprintf( out, "\t\t\t<description>%s</description>\n", xml_normalize_string(swinfo->longname()) );
+ fprintf( out, "\t\t\t<year>%s</year>\n", xml_normalize_string( swinfo->year() ) );
+ fprintf( out, "\t\t\t<publisher>%s</publisher>\n", xml_normalize_string( swinfo->publisher() ) );
+
+ for (feature_list_item *flist = swinfo->other_info(); flist != NULL; flist = flist->next())
+ fprintf( out, "\t\t\t<info name=\"%s\" value=\"%s\"/>\n", flist->name(), xml_normalize_string( flist->value() ) );
- for ( software_part *part = software_find_part( swinfo, NULL, NULL ); part != NULL; part = software_part_next( part ) )
+ for ( software_part *part = swinfo->first_part(); part != NULL; part = part->next() )
{
- fprintf( out, "\t\t\t<part name=\"%s\"", part->name );
- if ( part->interface_ )
- fprintf( out, " interface=\"%s\"", part->interface_ );
+ fprintf( out, "\t\t\t<part name=\"%s\"", part->name() );
+ if ( part->interface() != NULL )
+ fprintf( out, " interface=\"%s\"", part->interface() );
fprintf( out, ">\n");
- if ( part->featurelist )
- {
- feature_list *flist = part->featurelist;
-
- while( flist )
- {
- fprintf( out, "\t\t\t\t<feature name=\"%s\" value=\"%s\" />\n", flist->name, xml_normalize_string(flist->value) );
- flist = flist->next;
- }
- }
+ for (feature_list_item *flist = part->featurelist(); flist != NULL; flist = flist->next())
+ fprintf( out, "\t\t\t\t<feature name=\"%s\" value=\"%s\" />\n", flist->name(), xml_normalize_string(flist->value()) );
/* TODO: display rom region information */
- for ( const rom_entry *region = part->romdata; region; region = rom_next_region( region ) )
+ for ( const rom_entry *region = part->romdata(); region; region = rom_next_region( region ) )
{
int is_disk = ROMREGION_ISDISKDATA(region);
@@ -1286,7 +1276,7 @@ void cli_frontend::listsoftware(const char *gamename)
{
FILE *out = stdout;
int_map list_map;
- bool isfirst = TRUE;
+ bool isfirst = true;
// determine which drivers to output; return an error if none found
driver_enumerator drivlist(m_options, gamename);
@@ -1296,25 +1286,14 @@ void cli_frontend::listsoftware(const char *gamename)
while (drivlist.next())
{
software_list_device_iterator iter(drivlist.config().root_device());
- for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
- {
- if (swlist->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
- {
- software_list *list = software_list_open(m_options, swlist->list_name(), FALSE, NULL);
-
- if ( list )
- {
- /* Verify if we have encountered this list before */
- if (list_map.add(swlist->list_name(), 0, false) != TMERR_DUPLICATE)
+ for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next())
+ if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
+ if (list_map.add(swlistdev->list_name(), 0, false) != TMERR_DUPLICATE)
+ if (swlistdev->first_software_info() != NULL)
{
- if (isfirst) { fprintf( out, SOFTLIST_XML_BEGIN); isfirst = FALSE; }
- output_single_softlist(out, list, swlist->list_name());
+ if (isfirst) { fprintf(out, SOFTLIST_XML_BEGIN); isfirst = false; }
+ output_single_softlist(out, *swlistdev);
}
-
- software_list_close( list );
- }
- }
- }
}
if (!isfirst)
@@ -1351,25 +1330,15 @@ void cli_frontend::verifysoftware(const char *gamename)
matched++;
software_list_device_iterator iter(drivlist.config().root_device());
- for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
- {
- if (swlist->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
- {
- software_list *list = software_list_open(m_options, swlist->list_name(), FALSE, NULL);
-
- if ( list )
- {
- /* Verify if we have encountered this list before */
- if (list_map.add(swlist->list_name(), 0, false) != TMERR_DUPLICATE)
+ for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next())
+ if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
+ if (list_map.add(swlistdev->list_name(), 0, false) != TMERR_DUPLICATE)
+ if (swlistdev->first_software_info() != NULL)
{
nrlists++;
-
- // Get the actual software list contents
- software_list_parse( list, NULL, NULL );
-
- for ( software_info *swinfo = software_list_find( list, "*", NULL ); swinfo != NULL; swinfo = software_list_find( list, "*", swinfo ) )
+ for (software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next())
{
- media_auditor::summary summary = auditor.audit_software(swlist->list_name(), swinfo, AUDIT_VALIDATE_FAST);
+ media_auditor::summary summary = auditor.audit_software(swlistdev->list_name(), swinfo, AUDIT_VALIDATE_FAST);
// if not found, count that and leave it at that
if (summary == media_auditor::NOTFOUND)
@@ -1381,11 +1350,11 @@ void cli_frontend::verifysoftware(const char *gamename)
{
// output the summary of the audit
astring summary_string;
- auditor.summarize(swinfo->shortname,&summary_string);
+ auditor.summarize(swinfo->shortname(), &summary_string);
mame_printf_info("%s", summary_string.cstr());
// display information about what we discovered
- mame_printf_info("romset %s:%s ", swlist->list_name(), swinfo->shortname);
+ mame_printf_info("romset %s:%s ", swlistdev->list_name(), swinfo->shortname());
// switch off of the result
switch (summary)
@@ -1411,11 +1380,6 @@ void cli_frontend::verifysoftware(const char *gamename)
}
}
}
-
- software_list_close( list );
- }
- }
- }
}
// clear out any cached files
@@ -1454,19 +1418,13 @@ void cli_frontend::getsoftlist(const char *gamename)
while (drivlist.next())
{
software_list_device_iterator iter(drivlist.config().root_device());
- for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
- {
- software_list *list = software_list_open(m_options, swlist->list_name(), FALSE, NULL);
- if ( list )
- {
- if ((mame_strwildcmp(swlist->list_name(),gamename)==0) && list_map.add(swlist->list_name(), 0, false) != TMERR_DUPLICATE)
+ for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next())
+ if (mame_strwildcmp(swlistdev->list_name(), gamename) == 0 && list_map.add(swlistdev->list_name(), 0, false) != TMERR_DUPLICATE)
+ if (swlistdev->first_software_info() != NULL)
{
if (isfirst) { fprintf( out, SOFTLIST_XML_BEGIN); isfirst = FALSE; }
- output_single_softlist(out, list, swlist->list_name());
+ output_single_softlist(out, *swlistdev);
}
- software_list_close( list );
- }
- }
}
if (!isfirst)
@@ -1493,21 +1451,16 @@ void cli_frontend::verifysoftlist(const char *gamename)
while (drivlist.next())
{
software_list_device_iterator iter(drivlist.config().root_device());
- for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
- {
- software_list *list = software_list_open(m_options, swlist->list_name(), FALSE, NULL);
- if ( list )
- {
- if ((mame_strwildcmp(swlist->list_name(),gamename)==0) && list_map.add(swlist->list_name(), 0, false) != TMERR_DUPLICATE)
+ for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next())
+ if (mame_strwildcmp(swlistdev->list_name(), gamename) == 0 && list_map.add(swlistdev->list_name(), 0, false) != TMERR_DUPLICATE)
+ if (swlistdev->first_software_info() != NULL)
{
matched++;
// Get the actual software list contents
- software_list_parse( list, NULL, NULL );
-
- for ( software_info *swinfo = software_list_find( list, "*", NULL ); swinfo != NULL; swinfo = software_list_find( list, "*", swinfo ) )
+ for (software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next())
{
- media_auditor::summary summary = auditor.audit_software(swlist->list_name(), swinfo, AUDIT_VALIDATE_FAST);
+ media_auditor::summary summary = auditor.audit_software(swlistdev->list_name(), swinfo, AUDIT_VALIDATE_FAST);
// if not found, count that and leave it at that
if (summary == media_auditor::NOTFOUND)
@@ -1515,15 +1468,15 @@ void cli_frontend::verifysoftlist(const char *gamename)
notfound++;
}
// else display information about what we discovered
- else if(summary != media_auditor::NONE_NEEDED)
+ else if (summary != media_auditor::NONE_NEEDED)
{
// output the summary of the audit
astring summary_string;
- auditor.summarize(swinfo->shortname,&summary_string);
+ auditor.summarize(swinfo->shortname(), &summary_string);
mame_printf_info("%s", summary_string.cstr());
// display information about what we discovered
- mame_printf_info("romset %s:%s ", swlist->list_name(), swinfo->shortname);
+ mame_printf_info("romset %s:%s ", swlistdev->list_name(), swinfo->shortname());
// switch off of the result
switch (summary)
@@ -1549,9 +1502,6 @@ void cli_frontend::verifysoftlist(const char *gamename)
}
}
}
- software_list_close( list );
- }
- }
}
// clear out any cached files
@@ -1787,8 +1737,8 @@ void media_identifier::identify(const char *filename)
const CSzFileItem *f = _7z->db.db.Files + i;
_7z->curr_file_idx = i;
int namelen = SzArEx_GetFileNameUtf16(&_7z->db, i, NULL);
- UINT16* temp = (UINT16 *)malloc(namelen * sizeof(UINT16));
- void* temp2 = malloc((namelen+1) * sizeof(UINT8));
+ dynamic_array<UINT16> temp(namelen);
+ dynamic_buffer temp2(namelen+1);
UINT8* temp3 = (UINT8*)temp2;
memset(temp3, 0x00, namelen);
SzArEx_GetFileNameUtf16(&_7z->db, i, temp);
@@ -1800,19 +1750,12 @@ void media_identifier::identify(const char *filename)
if (!(f->IsDir) && (f->Size != 0))
{
- UINT8 *data = global_alloc_array(UINT8, f->Size);
- if (data != NULL)
- {
- // decompress data into RAM and identify it
- _7zerr = _7z_file_decompress(_7z, data, f->Size);
- if (_7zerr == _7ZERR_NONE)
- identify_data((const char*)temp2, data, f->Size);
- global_free(data);
- }
+ // decompress data into RAM and identify it
+ dynamic_buffer data(f->Size);
+ _7zerr = _7z_file_decompress(_7z, data, f->Size);
+ if (_7zerr == _7ZERR_NONE)
+ identify_data((const char*)&temp2[0], data, f->Size);
}
-
- free(temp);
- free(temp2);
}
// close up
@@ -1833,15 +1776,11 @@ void media_identifier::identify(const char *filename)
for (const zip_file_header *entry = zip_file_first_file(zip); entry != NULL; entry = zip_file_next_file(zip))
if (entry->uncompressed_length != 0)
{
- UINT8 *data = global_alloc_array(UINT8, entry->uncompressed_length);
- if (data != NULL)
- {
- // decompress data into RAM and identify it
- ziperr = zip_file_decompress(zip, data, entry->uncompressed_length);
- if (ziperr == ZIPERR_NONE)
- identify_data(entry->filename, data, entry->uncompressed_length);
- global_free(data);
- }
+ // decompress data into RAM and identify it
+ dynamic_buffer data(entry->uncompressed_length);
+ ziperr = zip_file_decompress(zip, data, entry->uncompressed_length);
+ if (ziperr == ZIPERR_NONE)
+ identify_data(entry->filename, data, entry->uncompressed_length);
}
// close up
@@ -1927,13 +1866,13 @@ void media_identifier::identify_file(const char *name)
void media_identifier::identify_data(const char *name, const UINT8 *data, int length)
{
// if this is a '.jed' file, process it into raw bits first
- UINT8 *tempjed = NULL;
+ dynamic_buffer tempjed;
jed_data jed;
if (core_filename_ends_with(name, ".jed") && jed_parse(data, length, &jed) == JEDERR_NONE)
{
// now determine the new data length and allocate temporary memory for it
length = jedbin_output(&jed, NULL, 0);
- tempjed = global_alloc_array(UINT8, length);
+ tempjed.resize(length);
jedbin_output(&jed, tempjed, length);
data = tempjed;
}
@@ -1968,9 +1907,6 @@ void media_identifier::identify_data(const char *name, const UINT8 *data, int le
// if we did find it, count it as a match
else
m_matches++;
-
- // free any temporary JED data
- global_free(tempjed);
}
@@ -2008,13 +1944,11 @@ int media_identifier::find_by_hash(const hash_collection &hashes, int length)
// next iterate over softlists
software_list_device_iterator iter(m_drivlist.config().root_device());
- for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
+ for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next())
{
- software_list *list = software_list_open(m_drivlist.options(), swlist->list_name(), FALSE, NULL);
-
- for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
- for (software_part *part = software_find_part(swinfo, NULL, NULL); part != NULL; part = software_part_next(part))
- for (const rom_entry *region = part->romdata; region != NULL; region = rom_next_region(region))
+ for (software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next())
+ for (software_part *part = swinfo->first_part(); part != NULL; part = part->next())
+ for (const rom_entry *region = part->romdata(); region != NULL; region = rom_next_region(region))
for (const rom_entry *rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
{
hash_collection romhashes(ROM_GETHASHDATA(rom));
@@ -2025,11 +1959,10 @@ int media_identifier::find_by_hash(const hash_collection &hashes, int length)
// output information about the match
if (found)
mame_printf_info(" ");
- mame_printf_info("= %s%-20s %s:%s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), swlist->list_name(), swinfo->shortname, swinfo->longname);
+ mame_printf_info("= %s%-20s %s:%s %s\n", baddump ? "(BAD) " : "", ROM_GETNAME(rom), swlistdev->list_name(), swinfo->shortname(), swinfo->longname());
found++;
}
}
- software_list_close(list);
}
}
diff --git a/src/emu/clifront.h b/src/emu/clifront.h
index 9d5381e5b01..dfa2bc721d9 100644
--- a/src/emu/clifront.h
+++ b/src/emu/clifront.h
@@ -72,6 +72,7 @@ private:
class cli_frontend
{
typedef tagmap_t<FPTR> int_map;
+
public:
// construction/destruction
cli_frontend(cli_options &options, osd_interface &osd);
@@ -107,12 +108,13 @@ private:
void execute_commands(const char *exename);
void display_help();
void display_suggestions(const char *gamename);
- void output_single_softlist(FILE *out,software_list *list, const char *listname);
+ void output_single_softlist(FILE *out, software_list_device &swlist);
// internal state
cli_options & m_options;
osd_interface & m_osd;
int m_result;
+ UINT64 m_start_memory;
};
diff --git a/src/emu/cpu/drcfe.c b/src/emu/cpu/drcfe.c
index b1f0957005d..d4bae00ad81 100644
--- a/src/emu/cpu/drcfe.c
+++ b/src/emu/cpu/drcfe.c
@@ -55,8 +55,6 @@ drc_frontend::drc_frontend(device_t &cpu, UINT32 window_start, UINT32 window_end
m_cpudevice(downcast<cpu_device &>(cpu)),
m_program(m_cpudevice.space(AS_PROGRAM)),
m_pageshift(m_cpudevice.space_config(AS_PROGRAM)->m_page_shift),
- m_desc_live_list(cpu.machine().respool()),
- m_desc_allocator(cpu.machine().respool()),
m_desc_array(window_end + window_start + 2, 0)
{
}
diff --git a/src/emu/cpu/drcuml.c b/src/emu/cpu/drcuml.c
index 42519ccd368..9096f0b8d8c 100644
--- a/src/emu/cpu/drcuml.c
+++ b/src/emu/cpu/drcuml.c
@@ -124,9 +124,7 @@ drcuml_state::drcuml_state(device_t &device, drc_cache &cache, UINT32 flags, int
m_beintf((device.machine().options().drc_use_c()) ?
*static_cast<drcbe_interface *>(auto_alloc(device.machine(), drcbe_c(*this, device, cache, flags, modes, addrbits, ignorebits))) :
*static_cast<drcbe_interface *>(auto_alloc(device.machine(), drcbe_native(*this, device, cache, flags, modes, addrbits, ignorebits)))),
- m_umllog(NULL),
- m_blocklist(device.machine().respool()),
- m_symlist(device.machine().respool())
+ m_umllog(NULL)
{
// if we're to log, create the logfile
if (flags & DRCUML_OPTION_LOG_UML)
@@ -201,7 +199,7 @@ drcuml_block *drcuml_state::begin_block(UINT32 maxinst)
// if we failed to find one, allocate a new one
if (bestblock == NULL)
- bestblock = &m_blocklist.append(*auto_alloc(m_device.machine(), drcuml_block(*this, maxinst * 3/2)));
+ bestblock = &m_blocklist.append(*global_alloc(drcuml_block(*this, maxinst * 3/2)));
// start the block
bestblock->begin();
@@ -216,7 +214,7 @@ drcuml_block *drcuml_state::begin_block(UINT32 maxinst)
code_handle *drcuml_state::handle_alloc(const char *name)
{
// allocate the handle, add it to our list, and return it
- return &m_handlelist.append(*auto_alloc(m_device.machine(), code_handle(*this, name)));
+ return &m_handlelist.append(*global_alloc(code_handle(*this, name)));
}
@@ -227,7 +225,7 @@ code_handle *drcuml_state::handle_alloc(const char *name)
void drcuml_state::symbol_add(void *base, UINT32 length, const char *name)
{
- m_symlist.append(*auto_alloc(m_device.machine(), symbol(base, length, name)));
+ m_symlist.append(*global_alloc(symbol(base, length, name)));
}
diff --git a/src/emu/cpu/dsp56k/inst.c b/src/emu/cpu/dsp56k/inst.c
index 58c3bf67aed..1c69cfd21dc 100644
--- a/src/emu/cpu/dsp56k/inst.c
+++ b/src/emu/cpu/dsp56k/inst.c
@@ -26,28 +26,26 @@ Instruction* Instruction::decodeInstruction(const Opcode* opc,
// Avoid "05-- 05--" recursion
if (shifted) return NULL;
- Instruction* op = decodeInstruction(opc, w0, w1, true);
+ auto_pointer<Instruction> op(decodeInstruction(opc, w0, w1, true));
if (op)
{
// This parallel move only works for certain trailing instructions.
- if (dynamic_cast<Add*>(op) ||
- dynamic_cast<Asr*>(op) ||
- dynamic_cast<Eor*>(op) ||
- dynamic_cast<Mac*>(op) ||
- dynamic_cast<Macr*>(op) ||
- dynamic_cast<Mpy*>(op) ||
- dynamic_cast<Neg*>(op) ||
- dynamic_cast<Sub*>(op) ||
- dynamic_cast<Tfr*>(op) ||
- dynamic_cast<Tst*>(op)
+ if (dynamic_cast<Add*>(op.get()) ||
+ dynamic_cast<Asr*>(op.get()) ||
+ dynamic_cast<Eor*>(op.get()) ||
+ dynamic_cast<Mac*>(op.get()) ||
+ dynamic_cast<Macr*>(op.get()) ||
+ dynamic_cast<Mpy*>(op.get()) ||
+ dynamic_cast<Neg*>(op.get()) ||
+ dynamic_cast<Sub*>(op.get()) ||
+ dynamic_cast<Tfr*>(op.get()) ||
+ dynamic_cast<Tst*>(op.get())
/* TODO: More? */)
{
op->m_sizeIncrement = 1;
return op;
}
}
-
- global_free(op);
}
diff --git a/src/emu/cpu/dsp56k/opcode.c b/src/emu/cpu/dsp56k/opcode.c
index d695ec0a501..58ade2b7b30 100644
--- a/src/emu/cpu/dsp56k/opcode.c
+++ b/src/emu/cpu/dsp56k/opcode.c
@@ -6,15 +6,13 @@ namespace DSP56K
{
Opcode::Opcode(UINT16 w0, UINT16 w1) : m_word0(w0)/*, m_word1(w1)*/
{
- m_instruction = Instruction::decodeInstruction(this, w0, w1);
- m_parallelMove = ParallelMove::decodeParallelMove(this, w0, w1);
+ m_instruction.reset(Instruction::decodeInstruction(this, w0, w1));
+ m_parallelMove.reset(ParallelMove::decodeParallelMove(this, w0, w1));
}
Opcode::~Opcode()
{
- global_free(m_instruction);
- global_free(m_parallelMove);
}
diff --git a/src/emu/cpu/dsp56k/opcode.h b/src/emu/cpu/dsp56k/opcode.h
index 75e93885f84..da6a8a87d1b 100644
--- a/src/emu/cpu/dsp56k/opcode.h
+++ b/src/emu/cpu/dsp56k/opcode.h
@@ -32,8 +32,8 @@ public:
const size_t instAccumulatorBitsModified() const;
private:
- Instruction* m_instruction;
- ParallelMove* m_parallelMove;
+ auto_pointer<Instruction> m_instruction;
+ auto_pointer<ParallelMove> m_parallelMove;
UINT16 m_word0;
//UINT16 m_word1;
diff --git a/src/emu/cpu/jaguar/jaguar.c b/src/emu/cpu/jaguar/jaguar.c
index e9a3f3d8dc9..a35492ace44 100644
--- a/src/emu/cpu/jaguar/jaguar.c
+++ b/src/emu/cpu/jaguar/jaguar.c
@@ -441,11 +441,11 @@ jaguar_cpu_device::~jaguar_cpu_device()
return;
if (mirror_table != NULL)
- global_free(mirror_table);
+ global_free_array(mirror_table);
mirror_table = NULL;
if (condition_table != NULL)
- global_free(condition_table);
+ global_free_array(condition_table);
condition_table = NULL;
}
diff --git a/src/emu/crsshair.c b/src/emu/crsshair.c
index 70e9f05ac93..b99a1f5d679 100644
--- a/src/emu/crsshair.c
+++ b/src/emu/crsshair.c
@@ -38,7 +38,7 @@ struct crosshair_global
UINT8 visible[MAX_PLAYERS]; /* visibility per player */
bitmap_argb32 * bitmap[MAX_PLAYERS]; /* bitmap per player */
render_texture * texture[MAX_PLAYERS]; /* texture per player */
- device_t *screen[MAX_PLAYERS]; /* the screen on which this player's crosshair is drawn */
+ screen_device * screen[MAX_PLAYERS]; /* the screen on which this player's crosshair is drawn */
float x[MAX_PLAYERS]; /* current X position */
float y[MAX_PLAYERS]; /* current Y position */
float last_x[MAX_PLAYERS]; /* last X position */
@@ -405,7 +405,7 @@ void crosshair_render(screen_device &screen)
given player's crosshair
-------------------------------------------------*/
-void crosshair_set_screen(running_machine &machine, int player, device_t *screen)
+void crosshair_set_screen(running_machine &machine, int player, screen_device *screen)
{
global.screen[player] = screen;
}
diff --git a/src/emu/crsshair.h b/src/emu/crsshair.h
index af316f55c5d..e572e2f35ee 100644
--- a/src/emu/crsshair.h
+++ b/src/emu/crsshair.h
@@ -19,8 +19,8 @@
CONSTANTS
***************************************************************************/
-#define CROSSHAIR_SCREEN_NONE ((device_t *) 0)
-#define CROSSHAIR_SCREEN_ALL ((device_t *) ~0)
+#define CROSSHAIR_SCREEN_NONE ((screen_device *) 0)
+#define CROSSHAIR_SCREEN_ALL ((screen_device *) ~0)
/* user settings for visibility mode */
#define CROSSHAIR_VISIBILITY_OFF 0
@@ -64,7 +64,7 @@ void crosshair_init(running_machine &machine);
void crosshair_render(screen_device &screen);
/* sets the screen(s) for a given player's crosshair */
-void crosshair_set_screen(running_machine &machine, int player, device_t *screen);
+void crosshair_set_screen(running_machine &machine, int player, screen_device *screen);
/* return TRUE if any crosshairs are used */
int crosshair_get_usage(running_machine &machine);
diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c
index 6d4ff66056c..d00240cc923 100644
--- a/src/emu/debug/debugvw.c
+++ b/src/emu/debug/debugvw.c
@@ -59,115 +59,6 @@ debug_view_source::~debug_view_source()
// DEBUG VIEW SOURCE LIST
//**************************************************************************
-//-------------------------------------------------
-// debug_view_source_list - constructor
-//-------------------------------------------------
-
-debug_view_source_list::debug_view_source_list(running_machine &machine)
- : m_machine(machine),
- m_head(NULL),
- m_tail(NULL),
- m_count(0)
-{
-}
-
-
-//-------------------------------------------------
-// ~debug_view_source_list - destructor
-//-------------------------------------------------
-
-debug_view_source_list::~debug_view_source_list()
-{
- reset();
-}
-
-
-//-------------------------------------------------
-// index - return the index of a source
-//-------------------------------------------------
-
-int debug_view_source_list::index(const debug_view_source &source) const
-{
- int result = 0;
- for (debug_view_source *cursource = m_head; cursource != NULL; cursource = cursource->m_next)
- {
- if (cursource == &source)
- break;
- result++;
- }
- return result;
-}
-
-
-//-------------------------------------------------
-// by_index - return a source given an index
-//-------------------------------------------------
-
-const debug_view_source *debug_view_source_list::by_index(int index) const
-{
- if (m_head == NULL)
- return NULL;
- const debug_view_source *result;
- for (result = m_head; index > 0 && result->m_next != NULL; result = result->m_next)
- index--;
- return result;
-}
-
-
-//-------------------------------------------------
-// reset - free all the view_sources
-//-------------------------------------------------
-
-void debug_view_source_list::reset()
-{
- // free from the head
- while (m_head != NULL)
- {
- debug_view_source *source = m_head;
- m_head = source->m_next;
- auto_free(machine(), source);
- }
-
- // reset the tail pointer and index
- m_tail = NULL;
- m_count = 0;
-}
-
-
-//-------------------------------------------------
-// append - add a view_source to the end of the
-// list
-//-------------------------------------------------
-
-void debug_view_source_list::append(debug_view_source &source)
-{
- // set the next and index values
- source.m_next = NULL;
-
- // append to the end
- if (m_tail == NULL)
- m_head = m_tail = &source;
- else
- m_tail->m_next = &source;
- m_tail = &source;
- m_count++;
-}
-
-
-//-------------------------------------------------
-// match_device - find the first view that
-// matches the given device
-//-------------------------------------------------
-
-const debug_view_source *debug_view_source_list::match_device(device_t *device) const
-{
- for (debug_view_source *source = m_head; source != NULL; source = source->m_next)
- if (device == source->m_device)
- return source;
- return m_head;
-}
-
-
//**************************************************************************
// DEBUG VIEW
@@ -181,7 +72,6 @@ debug_view::debug_view(running_machine &machine, debug_view_type type, debug_vie
: m_next(NULL),
m_type(type),
m_source(NULL),
- m_source_list(machine),
m_osdupdate(osdupdate),
m_osdprivate(osdprivate),
m_visible(10,10),
@@ -342,6 +232,20 @@ void debug_view::set_source(const debug_view_source &source)
//-------------------------------------------------
+// source_for_device - find the first source that
+// matches the given device
+//-------------------------------------------------
+
+const debug_view_source *debug_view::source_for_device(device_t *device) const
+{
+ for (debug_view_source *source = m_source_list.first(); source != NULL; source = source->next())
+ if (device == source->device())
+ return source;
+ return m_source_list.first();
+}
+
+
+//-------------------------------------------------
// adjust_visible_x_for_cursor - adjust a view's
// visible X position to ensure the cursor is
// visible
diff --git a/src/emu/debug/debugvw.h b/src/emu/debug/debugvw.h
index 50f84dd6b57..70db5910448 100644
--- a/src/emu/debug/debugvw.h
+++ b/src/emu/debug/debugvw.h
@@ -113,7 +113,7 @@ class debug_view_source
{
DISABLE_COPYING(debug_view_source);
- friend class debug_view_source_list;
+ friend class simple_list<debug_view_source>;
public:
// construction/destruction
@@ -135,38 +135,6 @@ private:
};
-// a debug_view_source_list contains a list of debug_view_sources
-class debug_view_source_list
-{
- DISABLE_COPYING(debug_view_source_list);
-
-public:
- // construction/destruction
- debug_view_source_list(running_machine &machine);
- ~debug_view_source_list();
-
- // getters
- running_machine &machine() const { return m_machine; }
- const debug_view_source *head() const { return m_head; }
- int count() const { return m_count; }
- int index(const debug_view_source &source) const;
- const debug_view_source *by_index(int index) const;
-
- // operations
- void reset();
- void append(debug_view_source &view_source);
- const debug_view_source *match_device(device_t *device) const;
- int match_device_index(device_t *device) const { return index(*match_device(device)); }
-
-private:
- // internal state
- running_machine & m_machine; // reference to our machine
- debug_view_source * m_head; // head of the list
- debug_view_source * m_tail; // end of the tail
- UINT32 m_count; // number of items in the list
-};
-
-
// debug_view describes a single text-based view
class debug_view
{
@@ -190,7 +158,8 @@ public:
bool cursor_supported() { flush_updates(); return m_supports_cursor; }
bool cursor_visible() { flush_updates(); return m_cursor_visible; }
const debug_view_source *source() const { return m_source; }
- const debug_view_source_list &source_list() const { return m_source_list; }
+ const debug_view_source *first_source() { return m_source_list.first(); }
+ const simple_list<debug_view_source> &source_list() const { return m_source_list; }
// setters
void set_size(int width, int height);
@@ -199,8 +168,11 @@ public:
void set_cursor_position(debug_view_xy pos);
void set_cursor_visible(bool visible = true);
void set_source(const debug_view_source &source);
+
+ // helpers
void process_char(int character) { view_char(character); }
void process_click(int button, debug_view_xy pos) { view_click(button, pos); }
+ const debug_view_source *source_for_device(device_t *device) const;
protected:
// internal updating helpers
@@ -225,7 +197,7 @@ protected:
debug_view * m_next; // link to the next view
debug_view_type m_type; // type of view
const debug_view_source *m_source; // currently selected data source
- debug_view_source_list m_source_list; // list of available data sources
+ simple_list<debug_view_source> m_source_list; // list of available data sources
// OSD data
debug_view_osd_update_func m_osdupdate; // callback for the update
diff --git a/src/emu/debug/dvbpoints.c b/src/emu/debug/dvbpoints.c
index 904e5df0386..9b48bc96787 100644
--- a/src/emu/debug/dvbpoints.c
+++ b/src/emu/debug/dvbpoints.c
@@ -64,11 +64,11 @@ void debug_view_breakpoints::enumerate_sources()
{
astring name;
name.printf("%s '%s'", dasm->device().name(), dasm->device().tag());
- m_source_list.append(*auto_alloc(machine(), debug_view_source(name.cstr(), &dasm->device())));
+ m_source_list.append(*global_alloc(debug_view_source(name.cstr(), &dasm->device())));
}
// reset the source to a known good entry
- set_source(*m_source_list.head());
+ set_source(*m_source_list.first());
}
@@ -262,7 +262,7 @@ int debug_view_breakpoints::breakpoints(SortMode sort, device_debug::breakpoint*
// Alloc
int numBPs = 0;
bpList = NULL;
- for (const debug_view_source *source = m_source_list.head(); source != NULL; source = source->next())
+ for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next())
{
const device_debug& debugInterface = *source->device()->debug();
for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != NULL; bp = bp->next())
@@ -271,7 +271,7 @@ int debug_view_breakpoints::breakpoints(SortMode sort, device_debug::breakpoint*
bpList = new device_debug::breakpoint*[numBPs];
int bpAddIndex = 0;
- for (const debug_view_source *source = m_source_list.head(); source != NULL; source = source->next())
+ for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next())
{
// Collect
device_debug& debugInterface = *source->device()->debug();
diff --git a/src/emu/debug/dvdisasm.c b/src/emu/debug/dvdisasm.c
index ef65d329c71..cba167a2160 100644
--- a/src/emu/debug/dvdisasm.c
+++ b/src/emu/debug/dvdisasm.c
@@ -62,7 +62,7 @@ debug_view_disasm::debug_view_disasm(running_machine &machine, debug_view_osd_up
// count the number of comments
int total_comments = 0;
- for (const debug_view_source *source = m_source_list.head(); source != NULL; source = source->next())
+ for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next())
{
const debug_view_disasm_source &dasmsource = downcast<const debug_view_disasm_source &>(*source);
total_comments += dasmsource.m_device.debug()->comment_count();
@@ -99,11 +99,11 @@ void debug_view_disasm::enumerate_sources()
for (device_disasm_interface *dasm = iter.first(); dasm != NULL; dasm = iter.next())
{
name.printf("%s '%s'", dasm->device().name(), dasm->device().tag());
- m_source_list.append(*auto_alloc(machine(), debug_view_disasm_source(name, dasm->device())));
+ m_source_list.append(*global_alloc(debug_view_disasm_source(name, dasm->device())));
}
// reset the source to a known good entry
- set_source(*m_source_list.head());
+ set_source(*m_source_list.first());
}
diff --git a/src/emu/debug/dvmemory.c b/src/emu/debug/dvmemory.c
index 7f303c84a29..ff38b03717d 100644
--- a/src/emu/debug/dvmemory.c
+++ b/src/emu/debug/dvmemory.c
@@ -131,14 +131,14 @@ void debug_view_memory::enumerate_sources()
{
address_space &space = memintf->space(spacenum);
name.printf("%s '%s' %s space memory", memintf->device().name(), memintf->device().tag(), space.name());
- m_source_list.append(*auto_alloc(machine(), debug_view_memory_source(name, space)));
+ m_source_list.append(*global_alloc(debug_view_memory_source(name, space)));
}
// then add all the memory regions
for (memory_region *region = machine().memory().first_region(); region != NULL; region = region->next())
{
name.printf("Region '%s'", region->name());
- m_source_list.append(*auto_alloc(machine(), debug_view_memory_source(name, *region)));
+ m_source_list.append(*global_alloc(debug_view_memory_source(name, *region)));
}
// finally add all global array symbols
@@ -156,12 +156,12 @@ void debug_view_memory::enumerate_sources()
if (strncmp(itemname, "timer/", 6))
{
name.cpy(itemname);
- m_source_list.append(*auto_alloc(machine(), debug_view_memory_source(name, base, valsize, valcount)));
+ m_source_list.append(*global_alloc(debug_view_memory_source(name, base, valsize, valcount)));
}
}
// reset the source to a known good entry
- set_source(*m_source_list.head());
+ set_source(*m_source_list.first());
}
diff --git a/src/emu/debug/dvstate.c b/src/emu/debug/dvstate.c
index 452f7ef5619..a2f6c24dacc 100644
--- a/src/emu/debug/dvstate.c
+++ b/src/emu/debug/dvstate.c
@@ -79,11 +79,11 @@ void debug_view_state::enumerate_sources()
for (device_state_interface *state = iter.first(); state != NULL; state = iter.next())
{
name.printf("%s '%s'", state->device().name(), state->device().tag());
- m_source_list.append(*auto_alloc(machine(), debug_view_state_source(name, state->device())));
+ m_source_list.append(*global_alloc(debug_view_state_source(name, state->device())));
}
// reset the source to a known good entry
- set_source(*m_source_list.head());
+ set_source(*m_source_list.first());
}
diff --git a/src/emu/debug/dvwpoints.c b/src/emu/debug/dvwpoints.c
index 234080bfe14..e9ff9a8754d 100644
--- a/src/emu/debug/dvwpoints.c
+++ b/src/emu/debug/dvwpoints.c
@@ -63,11 +63,11 @@ void debug_view_watchpoints::enumerate_sources()
{
astring name;
name.printf("%s '%s'", dasm->device().name(), dasm->device().tag());
- m_source_list.append(*auto_alloc(machine(), debug_view_source(name.cstr(), &dasm->device())));
+ m_source_list.append(*global_alloc(debug_view_source(name.cstr(), &dasm->device())));
}
// reset the source to a known good entry
- set_source(*m_source_list.head());
+ set_source(*m_source_list.first());
}
@@ -299,7 +299,7 @@ int debug_view_watchpoints::watchpoints(SortMode sort, device_debug::watchpoint*
// Alloc
int numWPs = 0;
wpList = NULL;
- for (const debug_view_source *source = m_source_list.head(); source != NULL; source = source->next())
+ for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next())
{
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; spacenum++)
{
@@ -312,7 +312,7 @@ int debug_view_watchpoints::watchpoints(SortMode sort, device_debug::watchpoint*
wpList = new device_debug::watchpoint*[numWPs];
int wpAddIndex = 0;
- for (const debug_view_source *source = m_source_list.head(); source != NULL; source = source->next())
+ for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next())
{
// Collect
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; spacenum++)
diff --git a/src/emu/debugger.c b/src/emu/debugger.c
index a89d0328120..4810fcba23b 100644
--- a/src/emu/debugger.c
+++ b/src/emu/debugger.c
@@ -67,7 +67,7 @@ void debugger_init(running_machine &machine)
machine_entry *entry;
/* initialize the submodules */
- machine.m_debug_view = auto_alloc(machine, debug_view_manager(machine));
+ machine.m_debug_view.reset(global_alloc(debug_view_manager(machine)));
debug_cpu_init(machine);
debug_command_init(machine);
debug_console_init(machine);
diff --git a/src/emu/debugint/debugint.c b/src/emu/debugint/debugint.c
index 0d6df253b5c..42c000e3e6a 100644
--- a/src/emu/debugint/debugint.c
+++ b/src/emu/debugint/debugint.c
@@ -956,9 +956,7 @@ static void on_disasm_cpu_activate(DView *dv, const ui_menu_event *event)
{
current = current->next();
if (current == NULL)
- {
- current = dv->view->source_list().head();
- }
+ current = dv->view->first_source();
dv->view->set_source(*current);
dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, TRUE);
dview_set_title(dv, current->name());
@@ -1360,7 +1358,7 @@ static void followers_set_cpu(device_t *device)
{
if (dview_is_state(dv, VIEW_STATE_FOLLOW_CPU))
{
- const debug_view_source *source = dv->view->source_list().match_device(device);
+ const debug_view_source *source = dv->view->source_for_device(device);
switch (dv->type)
{
case DVT_DISASSEMBLY:
diff --git a/src/emu/devcpu.c b/src/emu/devcpu.c
index 802faf1d7a7..5fedea366a7 100644
--- a/src/emu/devcpu.c
+++ b/src/emu/devcpu.c
@@ -103,7 +103,7 @@ legacy_cpu_device::legacy_cpu_device(const machine_config &mconfig, device_type
legacy_cpu_device::~legacy_cpu_device()
{
- global_free(m_token);
+ global_free_array((UINT8 *)m_token);
}
diff --git a/src/emu/devfind.h b/src/emu/devfind.h
index 8afaed9f75a..9f75cde7cb4 100644
--- a/src/emu/devfind.h
+++ b/src/emu/devfind.h
@@ -251,11 +251,8 @@ public:
shared_ptr_finder(device_t &base, const char *tag, UINT8 width = sizeof(_PointerType) * 8)
: object_finder_base<_PointerType>(base, tag),
m_bytes(0),
- m_allocated(false),
m_width(width) { }
- virtual ~shared_ptr_finder() { if (m_allocated) global_free(this->m_target); }
-
// operators to make use transparent
_PointerType operator[](int index) const { return this->m_target[index]; }
_PointerType &operator[](int index) { return this->m_target[index]; }
@@ -270,11 +267,11 @@ public:
// dynamic allocation of a shared pointer
void allocate(UINT32 entries)
{
- assert(!m_allocated);
- m_allocated = true;
- this->m_target = global_alloc_array_clear(_PointerType, entries);
+ assert(m_allocated.count() == 0);
+ m_allocated.resize(entries);
+ this->m_target = m_allocated;
m_bytes = entries * sizeof(_PointerType);
- this->m_base.save_pointer(this->m_target, this->m_tag, entries);
+ this->m_base.save_item(this->m_allocated, this->m_tag);
}
// finder
@@ -288,8 +285,8 @@ public:
protected:
// internal state
size_t m_bytes;
- bool m_allocated;
UINT8 m_width;
+ dynamic_array<_PointerType> m_allocated;
};
// optional shared pointer finder
@@ -322,13 +319,7 @@ public:
shared_ptr_array_finder(device_t &base, const char *basetag, UINT8 width = sizeof(_PointerType) * 8)
{
for (int index = 0; index < _Count; index++)
- m_array[index] = global_alloc(shared_ptr_type(base, m_tag[index].format("%s.%d", basetag, index), width));
- }
-
- virtual ~shared_ptr_array_finder()
- {
- for (int index = 0; index < _Count; index++)
- global_free(m_array[index]);
+ m_array[index].reset(global_alloc(shared_ptr_type(base, m_tag[index].format("%s.%d", basetag, index), width)));
}
// array accessors
@@ -337,7 +328,7 @@ public:
protected:
// internal state
- shared_ptr_type *m_array[_Count+1];
+ auto_pointer<shared_ptr_type> m_array[_Count+1];
astring m_tag[_Count+1];
};
diff --git a/src/emu/device.c b/src/emu/device.c
index 89d9f029466..b4cf54a9e10 100644
--- a/src/emu/device.c
+++ b/src/emu/device.c
@@ -87,7 +87,6 @@ device_t::device_t(const machine_config &mconfig, device_type type, const char *
m_clock_scale(1.0),
m_attoseconds_per_clock((clock == 0) ? 0 : HZ_TO_ATTOSECONDS(clock)),
- m_debug(NULL),
m_region(NULL),
m_machine_config(mconfig),
m_static_config(NULL),
@@ -413,7 +412,7 @@ void device_t::start()
// if we're debugging, create a device_debug object
if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
{
- m_debug = auto_alloc(machine(), device_debug(*this));
+ m_debug.reset(global_alloc(device_debug(*this)));
debug_setup();
}
@@ -445,7 +444,7 @@ void device_t::stop()
intf->interface_post_stop();
// free any debugging info
- auto_free(machine(), m_debug);
+ m_debug.reset();
// we're now officially stopped, and the machine is off-limits
m_started = false;
diff --git a/src/emu/device.h b/src/emu/device.h
index f6928674c4f..604ec1550cf 100644
--- a/src/emu/device.h
+++ b/src/emu/device.h
@@ -116,9 +116,9 @@ class device_t : public delegate_late_bind
protected:
// construction/destruction
device_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
+public:
virtual ~device_t();
-public:
// getters
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
const char *tag() const { return m_tag; }
@@ -270,7 +270,7 @@ protected:
double m_clock_scale; // clock scale factor
attoseconds_t m_attoseconds_per_clock;// period in attoseconds
- device_debug * m_debug;
+ auto_pointer<device_debug> m_debug;
memory_region * m_region; // our device-local region
const machine_config & m_machine_config; // reference to the machine's configuration
const void * m_static_config; // static device configuration
diff --git a/src/emu/diimage.c b/src/emu/diimage.c
index 4b372a185ca..36693a9ad13 100644
--- a/src/emu/diimage.c
+++ b/src/emu/diimage.c
@@ -55,13 +55,10 @@ device_image_interface::device_image_interface(const machine_config &mconfig, de
: device_interface(device),
m_file(NULL),
m_mame_file(NULL),
- m_full_software_name(NULL),
m_software_info_ptr(NULL),
m_software_part_ptr(NULL),
- m_software_list_name(NULL),
m_readonly(false),
m_created(false),
- m_formatlist(NULL),
m_is_loading(FALSE)
{
}
@@ -73,15 +70,6 @@ device_image_interface::device_image_interface(const machine_config &mconfig, de
device_image_interface::~device_image_interface()
{
- image_device_format **formatptr = &m_formatlist;
-
- /* free all entries */
- while (*formatptr != NULL)
- {
- image_device_format *entry = *formatptr;
- *formatptr = entry->m_next;
- global_free(entry);
- }
}
//-------------------------------------------------
@@ -196,22 +184,6 @@ image_error_t device_image_interface::set_image_filename(const char *filename)
****************************************************************************/
/*-------------------------------------------------
- device_get_indexed_creatable_format -
- accesses a specific image format available for
- image creation by index
--------------------------------------------------*/
-
-const image_device_format *device_image_interface::device_get_indexed_creatable_format(int index)
-{
- const image_device_format *format = device_get_creatable_formats();
- while(index-- && (format != NULL))
- format = format->m_next;
- return format;
-}
-
-
-
-/*-------------------------------------------------
device_get_named_creatable_format -
accesses a specific image format available for
image creation by name
@@ -219,10 +191,10 @@ const image_device_format *device_image_interface::device_get_indexed_creatable_
const image_device_format *device_image_interface::device_get_named_creatable_format(const char *format_name)
{
- const image_device_format *format = device_get_creatable_formats();
- while((format != NULL) && strcmp(format->m_name, format_name))
- format = format->m_next;
- return format;
+ for (const image_device_format *format = m_formatlist.first(); format != NULL; format = format->next())
+ if (strcmp(format->name(), format_name) == 0)
+ return format;
+ return NULL;
}
/****************************************************************************
@@ -420,18 +392,7 @@ UINT32 device_image_interface::get_software_region_length(const char *tag)
const char *device_image_interface::get_feature(const char *feature_name)
{
- feature_list *feature;
-
- if ( ! m_software_part_ptr || ! m_software_part_ptr->featurelist )
- return NULL;
-
- for ( feature = m_software_part_ptr->featurelist; feature; feature = feature->next )
- {
- if ( ! strcmp( feature->name, feature_name ) )
- return feature->value;
- }
-
- return NULL;
+ return (m_software_part_ptr == NULL) ? NULL : m_software_part_ptr->feature(feature_name);
}
@@ -786,7 +747,8 @@ static int verify_length_and_hash(emu_file *file, const char *name, UINT32 exple
/*-------------------------------------------------
load_software - software image loading
-------------------------------------------------*/
-bool device_image_interface::load_software(char *swlist, char *swname, rom_entry *start)
+
+bool device_image_interface::load_software(software_list_device &swlist, const char *swname, const rom_entry *start)
{
astring locationtag, breakstr("%");
const rom_entry *region;
@@ -807,38 +769,29 @@ bool device_image_interface::load_software(char *swlist, char *swname, rom_entry
UINT32 crc = 0;
bool has_crc = hash_collection(ROM_GETHASHDATA(romp)).crc(crc);
+ software_info *swinfo = swlist.find(swname);
+ if (swinfo == NULL)
+ return false;
+
+ UINT32 supported = swinfo->supported();
+ if (supported == SOFTWARE_SUPPORTED_PARTIAL)
+ mame_printf_error("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist.list_name());
+ if (supported == SOFTWARE_SUPPORTED_NO)
+ mame_printf_error("WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist.list_name());
+
// attempt reading up the chain through the parents and create a locationtag astring in the format
// " swlist % clonename % parentname "
// below, we have the code to split the elements and to create paths to load from
- software_list *software_list_ptr = software_list_open(device().machine().options(), swlist, FALSE, NULL);
- if (software_list_ptr)
+ while (swinfo != NULL)
{
- for (software_info *swinfo = software_list_find(software_list_ptr, swname, NULL); swinfo != NULL; )
- {
- {
- astring tmp(swinfo->shortname);
- locationtag.cat(tmp);
- locationtag.cat(breakstr);
- //printf("%s\n", locationtag.cstr());
- }
-
- const char *parentname = software_get_clone(device().machine().options(), swlist, swinfo->shortname);
- if (parentname != NULL)
- swinfo = software_list_find(software_list_ptr, parentname, NULL);
- else
- swinfo = NULL;
- }
- // strip the final '%'
- locationtag.del(locationtag.len() - 1, 1);
- software_list_close(software_list_ptr);
+ locationtag.cat(swinfo->shortname()).cat(breakstr);
+ const char *parentname = swinfo->parentname();
+ swinfo = (parentname != NULL) ? swlist.find(parentname) : NULL;
}
+ // strip the final '%'
+ locationtag.del(locationtag.len() - 1, 1);
- if (software_get_support(device().machine().options(), swlist, swname) == SOFTWARE_SUPPORTED_PARTIAL)
- mame_printf_error("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist);
-
- if (software_get_support(device().machine().options(), swlist, swname) == SOFTWARE_SUPPORTED_NO)
- mame_printf_error("WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist);
// check if locationtag actually contains two locations separated by '%'
// (i.e. check if we are dealing with a clone in softwarelist)
@@ -852,10 +805,10 @@ bool device_image_interface::load_software(char *swlist, char *swname, rom_entry
}
// prepare locations where we have to load from: list/parentname & list/clonename
- astring tag1(swlist);
+ astring tag1(swlist.list_name());
tag1.cat(PATH_SEPARATOR);
tag2.cpy(tag1.cat(tag4));
- tag1.cpy(swlist);
+ tag1.cpy(swlist.list_name());
tag1.cat(PATH_SEPARATOR);
tag3.cpy(tag1.cat(tag5));
@@ -933,19 +886,26 @@ bool device_image_interface::load_internal(const char *path, bool is_create, int
/* Check if there's a software list defined for this device and use that if we're not creating an image */
if (!filename_has_period && !just_load)
{
- softload = load_software_part( device().machine().options(), this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name, &m_software_list_name );
- // if we had launched from softlist with a specified part, e.g. "shortname:part"
- // we would have recorded the wrong name, so record it again based on software_info
- if (m_software_info_ptr && m_full_software_name)
- m_err = set_image_filename(m_full_software_name);
-
- // check if image should be read-only
- const char *read_only = get_feature("read_only");
- if (read_only && !strcmp(read_only, "true")) {
- make_readonly();
- }
+ softload = load_software_part(path, m_software_part_ptr);
+ if (softload)
+ {
+ m_software_info_ptr = &m_software_part_ptr->info();
+ m_software_list_name.cpy(m_software_info_ptr->list().list_name());
+ m_full_software_name.cpy(m_software_part_ptr->name());
+
+ // if we had launched from softlist with a specified part, e.g. "shortname:part"
+ // we would have recorded the wrong name, so record it again based on software_info
+ if (m_software_info_ptr && m_full_software_name)
+ m_err = set_image_filename(m_full_software_name);
+
+ // check if image should be read-only
+ const char *read_only = get_feature("read_only");
+ if (read_only && !strcmp(read_only, "true")) {
+ make_readonly();
+ }
- m_from_swlist = TRUE;
+ m_from_swlist = TRUE;
+ }
}
if (is_create || filename_has_period)
@@ -967,14 +927,14 @@ bool device_image_interface::load_internal(const char *path, bool is_create, int
if ( m_software_info_ptr )
{
// sanitize
- if (!m_software_info_ptr->longname || !m_software_info_ptr->publisher || !m_software_info_ptr->year)
+ if (m_software_info_ptr->longname() == NULL || m_software_info_ptr->publisher() == NULL || m_software_info_ptr->year() == NULL)
fatalerror("Each entry in an XML list must have all of the following fields: description, publisher, year!\n");
// store
- m_longname = m_software_info_ptr->longname;
- m_manufacturer = m_software_info_ptr->publisher;
- m_year = m_software_info_ptr->year;
- //m_playable = m_software_info_ptr->supported;
+ m_longname = m_software_info_ptr->longname();
+ m_manufacturer = m_software_info_ptr->publisher();
+ m_year = m_software_info_ptr->year();
+ //m_playable = m_software_info_ptr->supported();
}
/* did we fail to find the file? */
@@ -1107,7 +1067,7 @@ bool device_image_interface::finish_load()
bool device_image_interface::create(const char *path, const image_device_format *create_format, option_resolution *create_args)
{
- int format_index = (create_format != NULL) ? create_format->m_index : 0;
+ int format_index = (create_format != NULL) ? m_formatlist.indexof(*create_format) : 0;
return load_internal(path, TRUE, format_index, create_args, FALSE);
}
@@ -1143,10 +1103,10 @@ void device_image_interface::clear()
m_basename_noext.reset();
m_filetype.reset();
- m_full_software_name = NULL;
+ m_full_software_name.reset();
m_software_info_ptr = NULL;
m_software_part_ptr = NULL;
- m_software_list_name = NULL;
+ m_software_list_name.reset();
}
/*-------------------------------------------------
@@ -1193,6 +1153,173 @@ void device_image_interface::update_names(const device_type device_type, const c
}
}
+//-------------------------------------------------
+// software_name_split - helper that splits a
+// software_list:software:part string into
+// separate software_list, software, and part
+// strings.
+//
+// str1:str2:str3 => swlist_name - str1, swname - str2, swpart - str3
+// str1:str2 => swlist_name - NULL, swname - str1, swpart - str2
+// str1 => swlist_name - NULL, swname - str1, swpart - NULL
+//-------------------------------------------------
+
+void device_image_interface::software_name_split(const char *swlist_swname, astring &swlist_name, astring &swname, astring &swpart)
+{
+ // reset all output parameters
+ swlist_name.reset();
+ swname.reset();
+ swpart.reset();
+
+ // if no colon, this is the swname by itself
+ const char *split1 = strchr(swlist_swname, ':');
+ if (split1 == NULL)
+ {
+ swname.cpy(swlist_swname);
+ return;
+ }
+
+ // if one colon, it is the swname and swpart alone
+ const char *split2 = strchr(split1 + 1, ':');
+ if (split2 == NULL)
+ {
+ swname.cpy(swlist_swname, split1 - swlist_swname);
+ swpart.cpy(split1 + 1);
+ return;
+ }
+
+ // if two colons present, split into 3 parts
+ swlist_name.cpy(swlist_swname, split1 - swlist_swname);
+ swname.cpy(split1 + 1, split2 - (split1 + 1));
+ swpart.cpy(split2 + 1);
+}
+
+
+software_part *device_image_interface::find_software_item(const char *path, bool restrict_to_interface)
+{
+ //
+ // Note: old code would explicitly load swlist_name if it was specified, rather than
+ // searching the devices.
+ //
+ // Also if not found, old code would attempt to open <drivername>.xml and even
+ // <swinfo_name>.xml. Hopefully removing this won't break anything.
+ //
+
+ // split full software name into software list name and short software name
+ astring swlist_name, swinfo_name, swpart_name;
+ software_name_split(path, swlist_name, swinfo_name, swpart_name);
+ bool explicit_name = (swlist_name.len() > 0);
+
+ // determine interface
+ const char *interface = NULL;
+ if (restrict_to_interface)
+ interface = image_interface();
+
+ // find the software list if explicitly specified
+ software_list_device_iterator deviter(device().mconfig().root_device());
+ for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next())
+ if (!explicit_name || swlist_name == swlistdev->list_name())
+ {
+ software_info *info = swlistdev->find(swinfo_name);
+ if (info != NULL)
+ {
+ software_part *part = info->find_part(swpart_name, interface);
+ if (part != NULL)
+ return part;
+ }
+ }
+
+ // if explicitly specified and not found, just error here
+ return NULL;
+}
+
+
+//-------------------------------------------------
+// load_software_part
+//
+// Load a software part for a device. The part to
+// load is determined by the "path", software lists
+// configured for a driver, and the interface
+// supported by the device.
+//
+// returns true if the software could be loaded,
+// false otherwise. If the software could be loaded
+// sw_info and sw_part are also set.
+//-------------------------------------------------
+
+bool device_image_interface::load_software_part(const char *path, software_part *&swpart)
+{
+ // if no match has been found, we suggest similar shortnames
+ swpart = find_software_item(path, true);
+ if (swpart == NULL)
+ {
+ software_list_device::display_matches(device().machine().config(), image_interface(), path);
+ return false;
+ }
+
+ // Load the software part
+ bool result = call_softlist_load(swpart->info().list(), swpart->info().shortname(), swpart->romdata());
+
+ // Tell the world which part we actually loaded
+ astring full_sw_name;
+ full_sw_name.printf("%s:%s:%s", swpart->info().list().list_name(), swpart->info().shortname(), swpart->name());
+
+ // check compatibility
+ if (!swpart->is_compatible(swpart->info().list()))
+ mame_printf_warning("WARNING! the set %s might not work on this system due to missing filter(s) '%s'\n", swpart->info().shortname(), swpart->info().list().filter());
+
+ // check requirements and load those images
+ const char *requirement = swpart->feature("requirement");
+ if (requirement != NULL)
+ {
+ software_part *req_swpart = find_software_item(requirement, false);
+ if (req_swpart != NULL)
+ {
+ image_interface_iterator imgiter(device().machine().root_device());
+ for (device_image_interface *req_image = imgiter.first(); req_image != NULL; req_image = imgiter.next())
+ {
+ const char *interface = req_image->image_interface();
+ if (interface != NULL)
+ {
+ if (req_swpart->matches_interface(interface))
+ {
+ const char *option = device().mconfig().options().value(req_image->brief_instance_name());
+ // mount only if not already mounted
+ if (strlen(option) == 0 && !req_image->filename())
+ {
+ req_image->set_init_phase();
+ req_image->load(requirement);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ return result;
+}
+
+//-------------------------------------------------
+// software_get_default_slot
+//-------------------------------------------------
+
+void device_image_interface::software_get_default_slot(astring &result, const char *default_card_slot)
+{
+ const char *path = device().mconfig().options().value(instance_name());
+ result.reset();
+ if (strlen(path) > 0)
+ {
+ result.cpy(default_card_slot);
+ software_part *swpart = find_software_item(path, true);
+ if (swpart != NULL)
+ {
+ const char *slot = swpart->feature("slot");
+ if (slot != NULL)
+ result.cpy(slot);
+ }
+ }
+}
+
/*-------------------------------------------------
get_selection_menu - create the menu stack
for ui-level image selection
@@ -1200,7 +1327,7 @@ void device_image_interface::update_names(const device_type device_type, const c
ui_menu *device_image_interface::get_selection_menu(running_machine &machine, render_container *container)
{
- return auto_alloc_clear(machine, ui_menu_control_device_image(machine, container, this));
+ return global_alloc_clear(ui_menu_control_device_image(machine, container, this));
}
ui_menu_control_device_image::ui_menu_control_device_image(running_machine &machine, render_container *container, device_image_interface *_image) : ui_menu(machine, container)
@@ -1210,7 +1337,7 @@ ui_menu_control_device_image::ui_menu_control_device_image(running_machine &mach
sld = 0;
if (image->software_list_name()) {
software_list_device_iterator iter(machine.config().root_device());
- for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
+ for (software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
{
if (strcmp(swlist->list_name(),image->software_list_name())==0) sld = swlist;
}
@@ -1296,11 +1423,7 @@ void ui_menu_control_device_image::test_create(bool &can_create, bool &need_conf
void ui_menu_control_device_image::load_software_part()
{
- astring temp_name(sld->list_name());
- temp_name.cat(":");
- temp_name.cat(swi->shortname);
- temp_name.cat(":");
- temp_name.cat(swp->name);
+ astring temp_name(sld->list_name(), ":", swi->shortname(), ":", swp->name());
hook_load(temp_name, true);
}
@@ -1327,20 +1450,20 @@ void ui_menu_control_device_image::handle()
zippath_closedir(directory);
}
submenu_result = -1;
- ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, image, current_directory, current_file, true, image->image_interface()!=NULL, can_create, &submenu_result)));
+ ui_menu::stack_push(global_alloc_clear(ui_menu_file_selector(machine(), container, image, current_directory, current_file, true, image->image_interface()!=NULL, can_create, &submenu_result)));
state = SELECT_FILE;
break;
}
case START_SOFTLIST:
sld = 0;
- ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software(machine(), container, image->image_interface(), &sld)));
+ ui_menu::stack_push(global_alloc_clear(ui_menu_software(machine(), container, image->image_interface(), &sld)));
state = SELECT_SOFTLIST;
break;
case START_OTHER_PART: {
submenu_result = -1;
- ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, swp->interface_, &swp, true, &submenu_result)));
+ ui_menu::stack_push(global_alloc_clear(ui_menu_software_parts(machine(), container, swi, swp->interface(), &swp, true, &submenu_result)));
state = SELECT_OTHER_PART;
break;
}
@@ -1351,22 +1474,20 @@ void ui_menu_control_device_image::handle()
break;
}
software_info_name = "";
- ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, sld, image->image_interface(), software_info_name)));
+ ui_menu::stack_push(global_alloc_clear(ui_menu_software_list(machine(), container, sld, image->image_interface(), software_info_name)));
state = SELECT_PARTLIST;
break;
case SELECT_PARTLIST:
- swl = software_list_open(machine().options(), sld->list_name(), false, NULL);
- swi = software_list_find(swl, software_info_name, NULL);
- if(swinfo_has_multiple_parts(swi, image->image_interface())) {
+ swi = sld->find(software_info_name);
+ if(swi->has_multiple_parts(image->image_interface())) {
submenu_result = -1;
swp = 0;
- ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, image->image_interface(), &swp, false, &submenu_result)));
+ ui_menu::stack_push(global_alloc_clear(ui_menu_software_parts(machine(), container, swi, image->image_interface(), &swp, false, &submenu_result)));
state = SELECT_ONE_PART;
} else {
- swp = software_find_part(swi, NULL, NULL);
+ swp = swi->first_part();
load_software_part();
- software_list_close(swl);
ui_menu::stack_pop(machine());
}
break;
@@ -1375,13 +1496,11 @@ void ui_menu_control_device_image::handle()
switch(submenu_result) {
case ui_menu_software_parts::T_ENTRY: {
load_software_part();
- software_list_close(swl);
ui_menu::stack_pop(machine());
break;
}
case -1: // return to list
- software_list_close(swl);
state = SELECT_SOFTLIST;
break;
@@ -1419,7 +1538,7 @@ void ui_menu_control_device_image::handle()
break;
case ui_menu_file_selector::R_CREATE:
- ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_create(machine(), container, image, current_directory, current_file)));
+ ui_menu::stack_push(global_alloc_clear(ui_menu_file_create(machine(), container, image, current_directory, current_file)));
state = CREATE_FILE;
break;
@@ -1439,7 +1558,7 @@ void ui_menu_control_device_image::handle()
test_create(can_create, need_confirm);
if(can_create) {
if(need_confirm) {
- ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_confirm_save_as(machine(), container, &create_confirmed)));
+ ui_menu::stack_push(global_alloc_clear(ui_menu_confirm_save_as(machine(), container, &create_confirmed)));
state = CREATE_CONFIRM;
} else {
state = DO_CREATE;
diff --git a/src/emu/diimage.h b/src/emu/diimage.h
index aa62485b4d1..fe2ca71461f 100644
--- a/src/emu/diimage.h
+++ b/src/emu/diimage.h
@@ -21,6 +21,8 @@
// TYPE DEFINITIONS
//**************************************************************************
+class software_list;
+
enum iodevice_t
{
/* List of all supported devices. Refer to the device by these names only */
@@ -65,10 +67,26 @@ struct image_device_type_info
const char *m_shortname;
};
-struct image_device_format
+class image_device_format
{
+ friend class simple_list<image_device_format>;
+
+public:
+ image_device_format(const char *name, const char *description, const char *extensions, const char *optspec)
+ : m_next(NULL),
+ m_name(name),
+ m_description(description),
+ m_extensions(extensions),
+ m_optspec(optspec) { }
+
+ image_device_format *next() const { return m_next; }
+ const char *name() const { return m_name; }
+ const char *description() const { return m_description; }
+ const char *extensions() const { return m_extensions; }
+ const char *optspec() const { return m_optspec; }
+
+private:
image_device_format *m_next;
- int m_index;
astring m_name;
astring m_description;
astring m_extensions;
@@ -137,7 +155,7 @@ public:
virtual void device_compute_hash(hash_collection &hashes, const void *data, size_t length, const char *types) const;
virtual bool call_load() { return FALSE; }
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) { return FALSE; }
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { return FALSE; }
virtual bool call_create(int format_type, option_resolution *format_options) { return FALSE; }
virtual void call_unload() { }
virtual void call_display() { }
@@ -156,10 +174,9 @@ public:
virtual ui_menu *get_selection_menu(running_machine &machine, class render_container *container);
- const image_device_format *device_get_indexed_creatable_format(int index);
+ const image_device_format *device_get_indexed_creatable_format(int index) { return m_formatlist.find(index); }
const image_device_format *device_get_named_creatable_format(const char *format_name);
const option_guide *device_get_creation_option_guide() { return create_option_guide(); }
- const image_device_format *device_get_creatable_formats() { return formatlist(); }
const char *error();
void seterror(image_error_t err, const char *message);
@@ -218,16 +235,18 @@ public:
const char *instance_name() const { return m_instance_name; }
const char *brief_instance_name() const { return m_brief_instance_name; }
bool uses_file_extension(const char *file_extension) const;
- image_device_format *formatlist() const { return m_formatlist; }
+ image_device_format *formatlist() const { return m_formatlist.first(); }
bool load(const char *path);
bool open_image_file(emu_options &options);
bool finish_load();
void unload();
bool create(const char *path, const image_device_format *create_format, option_resolution *create_args);
- bool load_software(char *swlist, char *swname, rom_entry *entry);
+ bool load_software(software_list_device &swlist, const char *swname, const rom_entry *entry);
int reopen_for_write(const char *path);
+ static void software_name_split(const char *swlist_swname, astring &swlist_name, astring &swname, astring &swpart);
+
protected:
bool load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args, bool just_load);
void determine_open_plan(int is_create, UINT32 *open_plan);
@@ -248,6 +267,11 @@ protected:
void run_hash(void (*partialhash)(hash_collection &, const unsigned char *, unsigned long, const char *), hash_collection &hashes, const char *types);
void image_checkhash();
void update_names(const device_type device_type = NULL, const char *inst = NULL, const char *brief = NULL);
+
+ software_part *find_software_item(const char *path, bool restrict_to_interface);
+ bool load_software_part(const char *path, software_part *&swpart);
+ void software_get_default_slot(astring &result, const char *default_card_slot);
+
// derived class overrides
// configuration
@@ -270,10 +294,10 @@ protected:
astring m_working_directory;
/* Software information */
- char *m_full_software_name;
+ astring m_full_software_name;
software_info *m_software_info_ptr;
software_part *m_software_part_ptr;
- char *m_software_list_name;
+ astring m_software_list_name;
/* info read from the hash file/software list */
astring m_longname;
@@ -297,7 +321,7 @@ protected:
astring m_instance_name;
/* creation info */
- image_device_format *m_formatlist;
+ simple_list<image_device_format> m_formatlist;
bool m_is_loading;
};
@@ -325,10 +349,9 @@ protected:
int submenu_result;
bool create_confirmed;
bool softlist_done;
- const struct software_list *swl;
const software_info *swi;
const software_part *swp;
- const class software_list_device *sld;
+ class software_list_device *sld;
astring software_info_name;
void test_create(bool &can_create, bool &need_confirm);
diff --git a/src/emu/dinetwork.c b/src/emu/dinetwork.c
index 2702a84bf8f..32c0db9fe26 100644
--- a/src/emu/dinetwork.c
+++ b/src/emu/dinetwork.c
@@ -5,7 +5,6 @@ device_network_interface::device_network_interface(const machine_config &mconfig
: device_interface(device)
{
m_promisc = false;
- m_dev = NULL;
m_bandwidth = bandwidth;
set_mac("\0\0\0\0\0\0");
m_intf = 0;
@@ -13,7 +12,6 @@ device_network_interface::device_network_interface(const machine_config &mconfig
device_network_interface::~device_network_interface()
{
- if(m_dev) global_free(m_dev);
}
int device_network_interface::send(UINT8 *buf, int len)
@@ -40,7 +38,7 @@ void device_network_interface::set_mac(const char *mac)
void device_network_interface::set_interface(int id)
{
- m_dev = open_netdev(id, this, (int)(m_bandwidth*1000000/8.0/1500));
+ m_dev.reset(open_netdev(id, this, (int)(m_bandwidth*1000000/8.0/1500)));
if(!m_dev) {
logerror("Network interface %d not found\n", id);
id = -1;
diff --git a/src/emu/dinetwork.h b/src/emu/dinetwork.h
index b239fe2ceb0..99232a63405 100644
--- a/src/emu/dinetwork.h
+++ b/src/emu/dinetwork.h
@@ -24,7 +24,7 @@ protected:
bool m_promisc;
char m_mac[6];
float m_bandwidth;
- class netdev *m_dev;
+ auto_pointer<class netdev> m_dev;
int m_intf;
};
diff --git a/src/emu/dislot.c b/src/emu/dislot.c
index f2d6f851322..11f179d0a1e 100644
--- a/src/emu/dislot.c
+++ b/src/emu/dislot.c
@@ -46,8 +46,7 @@ void device_slot_interface::static_option_add(device_t &device, const char *name
if (option != NULL)
throw emu_fatalerror("slot '%s' duplicate option '%s\n", device.tag(), name);
- option = pool_alloc(intf.m_options.pool(), device_slot_option(name, devtype));
- intf.m_options.append(name, *option);
+ intf.m_options.append(name, *global_alloc(device_slot_option(name, devtype)));
}
device_slot_option *device_slot_interface::static_option(device_t &device, const char *name)
diff --git a/src/emu/dislot.h b/src/emu/dislot.h
index 7eb05b90fcb..d7df2c451d5 100644
--- a/src/emu/dislot.h
+++ b/src/emu/dislot.h
@@ -116,7 +116,7 @@ public:
const char *default_option() const { return m_default_option; }
device_slot_option *first_option() const { return m_options.first(); }
device_slot_option *option(const char *name) const { if (name) return m_options.find(name); return NULL; }
- virtual const char *get_default_card_software(const machine_config &config, emu_options &options) { return NULL; }
+ virtual void get_default_card_software(astring &result) { result.reset(); }
device_t *get_card_device();
private:
diff --git a/src/emu/drawgfx.c b/src/emu/drawgfx.c
index 7ed78b9906f..0349ef62b0e 100644
--- a/src/emu/drawgfx.c
+++ b/src/emu/drawgfx.c
@@ -76,7 +76,6 @@ gfxdecode_device::gfxdecode_device(const machine_config &mconfig, const char *ta
m_palette(NULL),
m_gfxdecodeinfo(NULL)
{
- memset(m_gfx, 0, sizeof(m_gfx));
}
//**************************************************************************
@@ -94,8 +93,6 @@ void gfxdecode_device::static_set_gfxdecodeinfo(device_t &device, const gfx_deco
void gfxdecode_device::device_stop()
{
- for (int i = 0; i < MAX_GFX_ELEMENTS; i++)
- auto_free(machine(), m_gfx[i]);
}
//-------------------------------------------------
@@ -244,7 +241,7 @@ void gfxdecode_device::device_start()
glcopy.total = total;
// allocate the graphics
- m_gfx[curgfx] = auto_alloc(machine(), gfx_element(m_palette, glcopy, (region_base != NULL) ? region_base + gfxdecode->start : NULL, gfxdecode->total_color_codes, gfxdecode->color_codes_start));
+ m_gfx[curgfx].reset(global_alloc(gfx_element(m_palette, glcopy, (region_base != NULL) ? region_base + gfxdecode->start : NULL, gfxdecode->total_color_codes, gfxdecode->color_codes_start)));
}
}
diff --git a/src/emu/drawgfx.h b/src/emu/drawgfx.h
index 5e82783f7d4..ae594cb665b 100644
--- a/src/emu/drawgfx.h
+++ b/src/emu/drawgfx.h
@@ -452,9 +452,8 @@ public:
static void static_set_palette(device_t &device, const char *tag);
gfx_element * gfx(int index) { assert(index < MAX_GFX_ELEMENTS); return m_gfx[index]; }
- gfx_element ** gfx() { return m_gfx; }
- void set_gfx(int index, gfx_element * val) { assert(index < MAX_GFX_ELEMENTS); m_gfx[index] = val; }
+ void set_gfx(int index, gfx_element * val) { assert(index < MAX_GFX_ELEMENTS); m_gfx[index].reset(val); }
protected:
// device-level overrides
virtual void device_validity_check(validity_checker &valid) const;
@@ -465,7 +464,7 @@ private:
// configuration state
palette_device * m_palette;
const gfx_decode_entry *m_gfxdecodeinfo; // pointer to array of graphics decoding information
- gfx_element * m_gfx[MAX_GFX_ELEMENTS]; // array of pointers to graphic sets (chars, sprites)
+ auto_pointer<gfx_element> m_gfx[MAX_GFX_ELEMENTS]; // array of pointers to graphic sets (chars, sprites)
};
// device type iterator
diff --git a/src/emu/drivenum.c b/src/emu/drivenum.c
index 453f6e6f123..c5d5c6907db 100644
--- a/src/emu/drivenum.c
+++ b/src/emu/drivenum.c
@@ -131,8 +131,8 @@ driver_enumerator::driver_enumerator(emu_options &options)
: m_current(-1),
m_filtered_count(0),
m_options(options),
- m_included(global_alloc_array(UINT8, s_driver_count)),
- m_config(global_alloc_array_clear(machine_config *, s_driver_count))
+ m_included(s_driver_count, 0),
+ m_config(s_driver_count, 0)
{
include_all();
}
@@ -142,8 +142,8 @@ driver_enumerator::driver_enumerator(emu_options &options, const char *string)
: m_current(-1),
m_filtered_count(0),
m_options(options),
- m_included(global_alloc_array(UINT8, s_driver_count)),
- m_config(global_alloc_array_clear(machine_config *, s_driver_count))
+ m_included(s_driver_count, 0),
+ m_config(s_driver_count, 0)
{
filter(string);
}
@@ -153,8 +153,8 @@ driver_enumerator::driver_enumerator(emu_options &options, const game_driver &dr
: m_current(-1),
m_filtered_count(0),
m_options(options),
- m_included(global_alloc_array(UINT8, s_driver_count)),
- m_config(global_alloc_array_clear(machine_config *, s_driver_count))
+ m_included(s_driver_count, 0),
+ m_config(s_driver_count, 0)
{
filter(driver);
}
@@ -166,13 +166,7 @@ driver_enumerator::driver_enumerator(emu_options &options, const game_driver &dr
driver_enumerator::~driver_enumerator()
{
- // free any configs
- for (int index = 0; index < s_driver_count; index++)
- global_free(m_config[index]);
-
- // free the arrays
- global_free(m_included);
- global_free(m_config);
+ // configs are freed by the cache
}
@@ -248,7 +242,10 @@ int driver_enumerator::filter(const game_driver &driver)
void driver_enumerator::include_all()
{
- memset(m_included, 1, sizeof(m_included[0]) * s_driver_count); m_filtered_count = s_driver_count;
+ memset(m_included, 1, sizeof(m_included[0]) * s_driver_count);
+ m_filtered_count = s_driver_count;
+
+ // always exclude the empty driver
int empty = find("___empty");
assert(empty != -1);
m_included[empty] = 0;
@@ -263,6 +260,7 @@ void driver_enumerator::include_all()
bool driver_enumerator::next()
{
// always advance one
+ release_current();
m_current++;
// if we have a filter, scan forward to the next match
@@ -286,6 +284,7 @@ bool driver_enumerator::next()
bool driver_enumerator::next_excluded()
{
// always advance one
+ release_current();
m_current++;
// if we have a filter, scan forward to the next match
@@ -317,7 +316,7 @@ void driver_enumerator::find_approximate_matches(const char *string, int count,
srand(osd_ticks());
// allocate a temporary list
- int *templist = global_alloc_array(int, m_filtered_count);
+ dynamic_array<int> templist(m_filtered_count);
int arrayindex = 0;
for (int index = 0; index < s_driver_count; index++)
if (m_included[index])
@@ -337,13 +336,11 @@ void driver_enumerator::find_approximate_matches(const char *string, int count,
// copy out the first few entries
for (int matchnum = 0; matchnum < count; matchnum++)
results[matchnum] = templist[matchnum % m_filtered_count];
-
- global_free(templist);
return;
}
// allocate memory to track the penalty value
- int *penalty = global_alloc_array(int, count);
+ dynamic_array<int> penalty(count);
// initialize everyone's states
for (int matchnum = 0; matchnum < count; matchnum++)
@@ -382,21 +379,27 @@ void driver_enumerator::find_approximate_matches(const char *string, int count,
penalty[matchnum] = curpenalty;
}
}
-
- // free our temp memory
- global_free(penalty);
}
-driver_enumerator::config_entry::config_entry(machine_config &config, int index)
- : m_next(NULL),
- m_config(&config),
- m_index(index)
-{
-}
-
+//-------------------------------------------------
+// release_current - release bulky memory
+// structures from the current entry because
+// we're done with it
+//-------------------------------------------------
-driver_enumerator::config_entry::~config_entry()
+void driver_enumerator::release_current()
{
- global_free(m_config);
+ // skip if no current entry
+ if (m_current < 0 || m_current >= s_driver_count)
+ return;
+
+ // skip if we haven't cached a config
+ if (m_config[m_current] == NULL)
+ return;
+
+ // iterate over software lists in this entry and reset
+ software_list_device_iterator deviter(m_config[m_current]->root_device());
+ for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next())
+ swlistdev->release();
}
diff --git a/src/emu/drivenum.h b/src/emu/drivenum.h
index c7d58dc3f97..cb23b96b34b 100644
--- a/src/emu/drivenum.h
+++ b/src/emu/drivenum.h
@@ -50,11 +50,11 @@ public:
// static helpers
static bool matches(const char *wildstring, const char *string);
+ static int penalty_compare(const char *source, const char *target);
protected:
// internal helpers
static int driver_sort_callback(const void *elem1, const void *elem2);
- static int penalty_compare(const char *source, const char *target);
// internal state
static int s_driver_count;
@@ -116,6 +116,9 @@ public:
void find_approximate_matches(const char *string, int count, int *results);
private:
+ // internal helpers
+ void release_current();
+
// entry in the config cache
struct config_entry
{
@@ -123,8 +126,7 @@ private:
public:
// construction/destruction
- config_entry(machine_config &config, int index);
- ~config_entry();
+ config_entry(machine_config &config, int index) : m_next(NULL), m_config(&config), m_index(index) { }
// getters
config_entry *next() const { return m_next; }
@@ -134,7 +136,7 @@ private:
private:
// internal state
config_entry * m_next;
- machine_config * m_config;
+ auto_pointer<machine_config> m_config;
int m_index;
};
@@ -144,8 +146,8 @@ private:
int m_current;
int m_filtered_count;
emu_options & m_options;
- UINT8 * m_included;
- machine_config ** m_config;
+ dynamic_array<UINT8> m_included;
+ mutable dynamic_array<machine_config *> m_config;
mutable simple_list<config_entry> m_config_cache;
};
diff --git a/src/emu/emualloc.c b/src/emu/emualloc.c
index 22c0e044fed..adf6cd21419 100644
--- a/src/emu/emualloc.c
+++ b/src/emu/emualloc.c
@@ -21,195 +21,10 @@
//**************************************************************************
-// CONSTANTS
-//**************************************************************************
-
-// align all allocated memory to this size
-//const int memory_align = 16;
-
-// number of memory_entries to allocate in a block
-const int memory_block_alloc_chunk = 256;
-
-
-
-//**************************************************************************
-// MACROS
-//**************************************************************************
-
-// enable deletion
-#undef delete
-
-
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// this struct is allocated in pools to track memory allocations
-// it must be a POD type!!
-class memory_entry
-{
-public:
- memory_entry * m_next; // link to the next entry
- memory_entry * m_prev; // link to the previous entry
- size_t m_size; // size of the allocation (not including this header)
- void * m_base; // base of the allocation
- const char * m_file; // file the allocation was made from
- int m_line; // line number within that file
- UINT64 m_id; // unique id
-
- static const int k_hash_prime = 6151;
-
- static UINT64 s_curid; // current ID
- static osd_lock * s_lock; // lock for managing the list
- static bool s_lock_alloc; // set to true temporarily during lock allocation
- static bool s_tracking; // set to true when tracking is live
- static memory_entry *s_hash[k_hash_prime];// hash table based on pointer
- static memory_entry *s_freehead; // pointer to the head of the free list
-
- static memory_entry *allocate(size_t size, void *base, const char *file, int line);
- static memory_entry *find(void *ptr);
- static void release(memory_entry *entry);
- static void report_unfreed();
-
-private:
- static void acquire_lock();
- static void release_lock();
-};
-
-
-
-//**************************************************************************
// GLOBALS
//**************************************************************************
-// dummy zeromem object
-const zeromem_t zeromem = { };
-
-// globals for memory_entry
-UINT64 memory_entry::s_curid = 1;
-osd_lock *memory_entry::s_lock = NULL;
-bool memory_entry::s_lock_alloc = false;
-bool memory_entry::s_tracking = false;
-memory_entry *memory_entry::s_hash[memory_entry::k_hash_prime] = { NULL };
-memory_entry *memory_entry::s_freehead = NULL;
-
-// wrapper for the global resource pool to help ensure construction order
-resource_pool &global_resource_pool()
-{
- static resource_pool s_pool(6151);
- return s_pool;
-};
-
-
-//**************************************************************************
-// GLOBAL HELPERS
-//**************************************************************************
-
-//-------------------------------------------------
-// malloc_file_line - allocate memory with file
-// and line number information
-//-------------------------------------------------
-
-void *malloc_file_line(size_t size, const char *file, int line)
-{
- // allocate the memory and fail if we can't
- void *result = osd_malloc(size);
- if (result == NULL)
- return NULL;
-
- // add a new entry
- memory_entry::allocate(size, result, file, line);
-
-#if !__has_feature(memory_sanitizer) && defined(MAME_DEBUG)
- memset(result, 0xdd, size);
-#endif
-
- return result;
-}
-
-
-//-------------------------------------------------
-// malloc_array_file_line - allocate memory with
-// file and line number information, and a hint
-// that this object is an array
-//-------------------------------------------------
-
-void *malloc_array_file_line(size_t size, const char *file, int line)
-{
- // allocate the memory and fail if we can't
- void *result = osd_malloc_array(size);
- if (result == NULL)
- return NULL;
-
- // add a new entry
- memory_entry::allocate(size, result, file, line);
-
-#if !__has_feature(memory_sanitizer) && defined(MAME_DEBUG)
- memset(result, 0xdd, size);
-#endif
-
- return result;
-}
-
-
-//-------------------------------------------------
-// free_file_line - free memory with file
-// and line number information
-//-------------------------------------------------
-
-void free_file_line(void *memory, const char *file, int line)
-{
- // ignore NULL frees/deletes
- if (memory == NULL)
- return;
-
- // find the memory entry
- memory_entry *entry = memory_entry::find(memory);
-
- // warn about untracked frees
- if (entry == NULL)
- {
- fprintf(stderr, "Error: attempt to free untracked memory in %s(%d)!\n", file, line);
- osd_break_into_debugger("Error: attempt to free untracked memory");
- return;
- }
-
-#ifdef MAME_DEBUG
- // clear memory to a bogus value
- memset(memory, 0xfc, entry->m_size);
-#endif
-
- // free the entry and the memory
- memory_entry::release(entry);
- osd_free(memory);
-}
-
-
-//-------------------------------------------------
-// dump_unfreed_mem - called from the exit path
-// of any code that wants to check for unfreed
-// memory
-//-------------------------------------------------
-
-void track_memory(bool track)
-{
- memory_entry::s_tracking = track;
-}
-
-
-//-------------------------------------------------
-// dump_unfreed_mem - called from the exit path
-// of any code that wants to check for unfreed
-// memory
-//-------------------------------------------------
-
-void dump_unfreed_mem()
-{
-#ifdef MAME_DEBUG
- memory_entry::report_unfreed();
-#endif
-}
+UINT64 resource_pool::s_id = 0;
@@ -225,11 +40,10 @@ void dump_unfreed_mem()
resource_pool::resource_pool(int hash_size)
: m_hash_size(hash_size),
m_listlock(osd_lock_alloc()),
- m_hash(new resource_pool_item *[hash_size]),
+ m_hash(hash_size, 0),
m_ordered_head(NULL),
m_ordered_tail(NULL)
{
- memset(m_hash, 0, hash_size * sizeof(m_hash[0]));
}
@@ -244,7 +58,6 @@ resource_pool::~resource_pool()
clear();
if (m_listlock != NULL)
osd_lock_free(m_listlock);
- delete[] m_hash;
}
@@ -252,7 +65,7 @@ resource_pool::~resource_pool()
// add - add a new item to the resource pool
//-------------------------------------------------
-void resource_pool::add(resource_pool_item &item)
+void resource_pool::add(resource_pool_item &item, size_t size, const char *type)
{
osd_lock_acquire(m_listlock);
@@ -263,13 +76,9 @@ void resource_pool::add(resource_pool_item &item)
// fetch the ID of this item's pointer; some implementations put hidden data
// before, so if we don't find it, check 4 bytes ahead
- memory_entry *entry = memory_entry::find(item.m_ptr);
- if (entry == NULL)
- entry = memory_entry::find(reinterpret_cast<UINT8 *>(item.m_ptr) - sizeof(size_t));
- assert(entry != NULL);
- item.m_id = entry->m_id;
+ item.m_id = ++s_id;
if (LOG_ALLOCS)
- fprintf(stderr, "#%06d, add %d bytes (%s:%d)\n", (UINT32)entry->m_id, static_cast<UINT32>(entry->m_size), entry->m_file, (int)entry->m_line);
+ fprintf(stderr, "#%06d, add %s, %d bytes\n", (UINT32)item.m_id, type, size);
// find the entry to insert after
resource_pool_item *insert_after;
@@ -340,7 +149,7 @@ void resource_pool::remove(void *ptr)
// delete the object and break
if (LOG_ALLOCS)
fprintf(stderr, "#%06d, delete %d bytes\n", (UINT32)deleteme->m_id, static_cast<UINT32>(deleteme->m_size));
- delete deleteme;
+ global_free(deleteme);
break;
}
@@ -414,170 +223,3 @@ void resource_pool::clear()
osd_lock_release(m_listlock);
}
-
-
-
-//**************************************************************************
-// MEMORY ENTRY
-//**************************************************************************
-
-//-------------------------------------------------
-// acquire_lock - acquire the memory entry lock,
-// creating a new one if needed
-//-------------------------------------------------
-
-void memory_entry::acquire_lock()
-{
- // allocate a lock on first usage
- // note that osd_lock_alloc() may re-enter this path, so protect against recursion!
- if (s_lock == NULL)
- {
- if (s_lock_alloc)
- return;
- s_lock_alloc = true;
- s_lock = osd_lock_alloc();
- s_lock_alloc = false;
- }
- osd_lock_acquire(s_lock);
-}
-
-
-//-------------------------------------------------
-// release_lock - release the memory entry lock
-//-------------------------------------------------
-
-void memory_entry::release_lock()
-{
- osd_lock_release(s_lock);
-}
-
-
-//-------------------------------------------------
-// allocate - allocate a new memory entry
-//-------------------------------------------------
-
-memory_entry *memory_entry::allocate(size_t size, void *base, const char *file, int line)
-{
- acquire_lock();
-
- // if we're out of free entries, allocate a new chunk
- if (s_freehead == NULL)
- {
- // create a new chunk, and fail if we can't
- memory_entry *entry = reinterpret_cast<memory_entry *>(osd_malloc_array(memory_block_alloc_chunk * sizeof(memory_entry)));
- if (entry == NULL)
- {
- release_lock();
- return NULL;
- }
-
- // add all the entries to the list
- for (int entrynum = 0; entrynum < memory_block_alloc_chunk; entrynum++)
- {
- entry->m_next = s_freehead;
- s_freehead = entry++;
- }
- }
-
- // grab a free entry
- memory_entry *entry = s_freehead;
- s_freehead = entry->m_next;
-
- // populate it
- entry->m_size = size;
- entry->m_base = base;
- entry->m_file = s_tracking ? file : NULL;
- entry->m_line = s_tracking ? line : 0;
- entry->m_id = s_curid++;
- if (LOG_ALLOCS)
- fprintf(stderr, "#%06d, alloc %d bytes (%s:%d)\n", (UINT32)entry->m_id, static_cast<UINT32>(entry->m_size), entry->m_file, (int)entry->m_line);
-
- // add it to the alloc list
- int hashval = reinterpret_cast<FPTR>(base) % k_hash_prime;
- entry->m_next = s_hash[hashval];
- if (entry->m_next != NULL)
- entry->m_next->m_prev = entry;
- entry->m_prev = NULL;
- s_hash[hashval] = entry;
-
- release_lock();
- return entry;
-}
-
-
-//-------------------------------------------------
-// find - find a memory entry
-//-------------------------------------------------
-
-memory_entry *memory_entry::find(void *ptr)
-{
- // NULL maps to nothing
- if (ptr == NULL)
- return NULL;
-
- // scan the list under the lock
- acquire_lock();
-
- int hashval = reinterpret_cast<FPTR>(ptr) % k_hash_prime;
- memory_entry *entry;
- for (entry = s_hash[hashval]; entry != NULL; entry = entry->m_next)
- if (entry->m_base == ptr)
- break;
-
- release_lock();
- return entry;
-}
-
-
-//-------------------------------------------------
-// release - release a memory entry
-//-------------------------------------------------
-
-void memory_entry::release(memory_entry *entry)
-{
- acquire_lock();
-
- // remove ourselves from the alloc list
- int hashval = reinterpret_cast<FPTR>(entry->m_base) % k_hash_prime;
- if (entry->m_prev != NULL)
- entry->m_prev->m_next = entry->m_next;
- else
- s_hash[hashval] = entry->m_next;
- if (entry->m_next != NULL)
- entry->m_next->m_prev = entry->m_prev;
-
- // add ourself to the free list
- entry->m_next = s_freehead;
- s_freehead = entry;
-
- release_lock();
-}
-
-
-//-------------------------------------------------
-// report_unfreed - print a list of unfreed
-// memory to the target file
-//-------------------------------------------------
-
-void memory_entry::report_unfreed()
-{
- acquire_lock();
-
- // check for leaked memory
- UINT32 total = 0;
-
- for (int hashnum = 0; hashnum < k_hash_prime; hashnum++)
- for (memory_entry *entry = s_hash[hashnum]; entry != NULL; entry = entry->m_next)
- if (entry->m_file != NULL)
- {
- if (total == 0)
- fprintf(stderr, "--- memory leak warning ---\n");
- total += entry->m_size;
- fprintf(stderr, "#%06d, nofree %d bytes (%s:%d)\n", (UINT32)entry->m_id, static_cast<UINT32>(entry->m_size), entry->m_file, (int)entry->m_line);
- }
-
- release_lock();
-
- if (total > 0)
- fprintf(stderr, "a total of %u bytes were not freed\n", total);
-}
diff --git a/src/emu/emualloc.h b/src/emu/emualloc.h
index 39a02db248f..b39b1c10c64 100644
--- a/src/emu/emualloc.h
+++ b/src/emu/emualloc.h
@@ -15,6 +15,7 @@
#include <new>
#include "osdcore.h"
+#include "coretmpl.h"
//**************************************************************************
@@ -44,133 +45,6 @@
#define pool_alloc_array_clear(_pool, _type, _num) (_pool).add_array(new(__FILE__, __LINE__, zeromem) _type[_num], (_num))
#define pool_free(_pool, v) (_pool).remove(v)
-// global allocation helpers
-#define global_alloc(_type) pool_alloc(global_resource_pool(), _type)
-#define global_alloc_clear(_type) pool_alloc_clear(global_resource_pool(), _type)
-#define global_alloc_array(_type, _num) pool_alloc_array(global_resource_pool(), _type, _num)
-#define global_alloc_array_clear(_type, _num) pool_alloc_array_clear(global_resource_pool(), _type, _num)
-#define global_free(v) pool_free(global_resource_pool(), v)
-
-
-
-//**************************************************************************
-// FUNCTION PROTOTYPES
-//**************************************************************************
-
-// allocate memory with file and line number information
-void *malloc_file_line(size_t size, const char *file, int line);
-void *malloc_array_file_line(size_t size, const char *file, int line);
-
-// free memory with file and line number information
-void free_file_line(void *memory, const char *file, int line);
-
-// called from the exit path of any code that wants to check for unfreed memory
-void track_memory(bool track);
-void dump_unfreed_mem();
-
-
-
-//**************************************************************************
-// INLINE FUNCTIONS
-//**************************************************************************
-
-// zeromem_t is a dummy class used to tell new to zero memory after allocation
-class zeromem_t { };
-
-#ifndef NO_MEM_TRACKING
-
-// standard new/delete operators (try to avoid using)
-ATTR_FORCE_INLINE inline void *operator new(std::size_t size) throw (std::bad_alloc)
-{
- void *result = malloc_file_line(size, NULL, 0);
- if (result == NULL)
- throw std::bad_alloc();
- return result;
-}
-
-ATTR_FORCE_INLINE inline void *operator new[](std::size_t size) throw (std::bad_alloc)
-{
- void *result = malloc_array_file_line(size, NULL, 0);
- if (result == NULL)
- throw std::bad_alloc();
- return result;
-}
-
-ATTR_FORCE_INLINE inline void operator delete(void *ptr) throw()
-{
- if (ptr != NULL)
- free_file_line(ptr, NULL, 0);
-}
-
-ATTR_FORCE_INLINE inline void operator delete[](void *ptr) throw()
-{
- if (ptr != NULL)
- free_file_line(ptr, NULL, 0);
-}
-
-#endif
-
-// file/line new/delete operators
-ATTR_FORCE_INLINE inline void *operator new(std::size_t size, const char *file, int line) throw (std::bad_alloc)
-{
- void *result = malloc_file_line(size, file, line);
- if (result == NULL)
- throw std::bad_alloc();
- return result;
-}
-
-ATTR_FORCE_INLINE inline void *operator new[](std::size_t size, const char *file, int line) throw (std::bad_alloc)
-{
- void *result = malloc_array_file_line(size, file, line);
- if (result == NULL)
- throw std::bad_alloc();
- return result;
-}
-
-ATTR_FORCE_INLINE inline void operator delete(void *ptr, const char *file, int line)
-{
- if (ptr != NULL)
- free_file_line(ptr, file, line);
-}
-
-ATTR_FORCE_INLINE inline void operator delete[](void *ptr, const char *file, int line)
-{
- if (ptr != NULL)
- free_file_line(ptr, file, line);
-}
-
-
-// file/line new/delete operators with zeroing
-ATTR_FORCE_INLINE inline void *operator new(std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc)
-{
- void *result = malloc_file_line(size, file, line);
- if (result == NULL)
- throw std::bad_alloc();
- memset(result, 0, size);
- return result;
-}
-
-ATTR_FORCE_INLINE inline void *operator new[](std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc)
-{
- void *result = malloc_array_file_line(size, file, line);
- if (result == NULL)
- throw std::bad_alloc();
- memset(result, 0, size);
- return result;
-}
-
-ATTR_FORCE_INLINE inline void operator delete(void *ptr, const char *file, int line, const zeromem_t &)
-{
- if (ptr != NULL)
- free_file_line(ptr, file, line);
-}
-
-ATTR_FORCE_INLINE inline void operator delete[](void *ptr, const char *file, int line, const zeromem_t &)
-{
- if (ptr != NULL)
- free_file_line(ptr, file, line);
-}
-
//**************************************************************************
@@ -254,7 +128,7 @@ public:
resource_pool(int hash_size = 193);
virtual ~resource_pool();
- void add(resource_pool_item &item);
+ void add(resource_pool_item &item, size_t size, const char *type);
void remove(resource_pool_item &item) { remove(item.m_ptr); }
void remove(void *ptr);
void remove(const void *ptr) { remove(const_cast<void *>(ptr)); }
@@ -262,46 +136,17 @@ public:
bool contains(void *ptrstart, void *ptrend);
void clear();
- template<class _ObjectClass> _ObjectClass *add_object(_ObjectClass* object) { add(*EMUALLOC_SELF_NEW resource_pool_object<_ObjectClass>(object)); return object; }
- template<class _ObjectClass> _ObjectClass *add_array(_ObjectClass* array, int count) { add(*EMUALLOC_SELF_NEW resource_pool_array<_ObjectClass>(array, count)); return array; }
+ template<class _ObjectClass> _ObjectClass *add_object(_ObjectClass* object) { add(*EMUALLOC_SELF_NEW resource_pool_object<_ObjectClass>(object), sizeof(_ObjectClass), typeid(_ObjectClass).name()); return object; }
+ template<class _ObjectClass> _ObjectClass *add_array(_ObjectClass* array, int count) { add(*EMUALLOC_SELF_NEW resource_pool_array<_ObjectClass>(array, count), sizeof(_ObjectClass), typeid(_ObjectClass).name()); return array; }
private:
int m_hash_size;
osd_lock * m_listlock;
- resource_pool_item ** m_hash;
+ dynamic_array<resource_pool_item *> m_hash;
resource_pool_item * m_ordered_head;
resource_pool_item * m_ordered_tail;
+ static UINT64 s_id;
};
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-// dummy objects to pass to the specialized new variants
-extern const zeromem_t zeromem;
-
-
-resource_pool &global_resource_pool();
-
-
-
-//**************************************************************************
-// ADDDITIONAL MACROS
-//**************************************************************************
-
-#ifndef NO_MEM_TRACKING
-// re-route classic malloc-style allocations
-#undef malloc
-#undef calloc
-#undef realloc
-#undef free
-
-#define malloc(x) malloc_array_file_line(x, __FILE__, __LINE__)
-#define calloc(x,y) __error_use_auto_alloc_clear_or_global_alloc_clear_instead__
-#define realloc(x,y) __error_realloc_is_dangerous__
-#define free(x) free_file_line(x, __FILE__, __LINE__)
-#endif
-
#endif /* __EMUALLOC_H__ */
diff --git a/src/emu/emucore.h b/src/emu/emucore.h
index 4b3330c9e9f..5a1b797a141 100644
--- a/src/emu/emucore.h
+++ b/src/emu/emucore.h
@@ -60,13 +60,6 @@
// genf is a generic function pointer; cast function pointers to this instead of void *
typedef void genf(void);
-// FPTR is used to cast a pointer to a scalar
-#ifdef PTR64
-typedef UINT64 FPTR;
-#else
-typedef UINT32 FPTR;
-#endif
-
// pen_t is used to represent pixel values in bitmaps
typedef UINT32 pen_t;
diff --git a/src/emu/emuopts.c b/src/emu/emuopts.c
index 8495b4e457f..5834a61a0fa 100644
--- a/src/emu/emuopts.c
+++ b/src/emu/emuopts.c
@@ -105,8 +105,6 @@ const options_entry emu_options::s_option_entries[] =
{ OPTION_GAMMA "(0.1-3.0)", "1.0", OPTION_FLOAT, "default game screen gamma correction" },
{ OPTION_PAUSE_BRIGHTNESS "(0.0-1.0)", "0.65", OPTION_FLOAT, "amount to scale the screen brightness when paused" },
{ OPTION_EFFECT, "none", OPTION_STRING, "name of a PNG file to use for visual effects, or 'none'" },
- { OPTION_MINIMUM_WIDTH, "0", OPTION_INTEGER, "minimum screen width" },
- { OPTION_MINIMUM_HEIGHT, "0", OPTION_INTEGER, "minimum screen height" },
// vector options
{ NULL, NULL, OPTION_HEADER, "CORE VECTOR OPTIONS" },
@@ -201,57 +199,51 @@ emu_options::emu_options()
// options for the configured system
//-------------------------------------------------
-bool emu_options::add_slot_options(bool isfirst)
+bool emu_options::add_slot_options(bool isfirstpass)
{
// look up the system configured by name; if no match, do nothing
const game_driver *cursystem = system();
if (cursystem == NULL)
return false;
+ machine_config config(*cursystem, *this);
// iterate through all slot devices
- options_entry entry[2] = { { 0 }, { 0 } };
bool first = true;
+
// create the configuration
- machine_config config(*cursystem, *this);
- bool added = false;
+ int starting_count = options_count();
slot_interface_iterator iter(config.root_device());
for (const device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next())
{
- if (slot->fixed()) continue;
+ // skip fixed slots
+ if (slot->fixed())
+ continue;
+
// first device? add the header as to be pretty
- if (first && isfirst)
- {
- entry[0].name = NULL;
- entry[0].description = "SLOT DEVICES";
- entry[0].flags = OPTION_HEADER | OPTION_FLAG_DEVICE;
- entry[0].defvalue = NULL;
- add_entries(entry);
- }
+ if (isfirstpass && first)
+ add_entry(NULL, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
first = false;
// retrieve info about the device instance
- if (!exists(slot->device().tag() + 1)) {
+ const char *name = slot->device().tag() + 1;
+ if (!exists(name))
+ {
// add the option
- entry[0].name = slot->device().tag() + 1;
- entry[0].description = NULL;
- entry[0].flags = OPTION_STRING | OPTION_FLAG_DEVICE;
- entry[0].defvalue = slot->default_option();
- if ( entry[0].defvalue )
+ UINT32 flags = OPTION_STRING | OPTION_FLAG_DEVICE;
+ const char *defvalue = slot->default_option();
+ if (defvalue != NULL)
{
- const device_slot_option *option = slot->option(entry[0].defvalue);
- if (option && !option->selectable())
- {
- entry[0].flags |= OPTION_FLAG_INTERNAL;
- }
+ const device_slot_option *option = slot->option(defvalue);
+ if (option != NULL && !option->selectable())
+ flags |= OPTION_FLAG_INTERNAL;
}
- add_entries(entry, true);
-
- added = true;
+ add_entry(name, NULL, flags, defvalue, true);
}
}
- return added;
+ return (options_count() != starting_count);
}
+
//-------------------------------------------------
// update_slot_options - update slot values
// depending of image mounted
@@ -263,72 +255,61 @@ void emu_options::update_slot_options()
const game_driver *cursystem = system();
if (cursystem == NULL)
return;
+ machine_config config(*cursystem, *this);
// iterate through all slot devices
- // create the configuration
- machine_config config(*cursystem, *this);
slot_interface_iterator iter(config.root_device());
for (device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next())
{
// retrieve info about the device instance
- if (exists(slot->device().tag()+1)) {
- if (slot->first_option() != NULL) {
- const char *def = slot->get_default_card_software(config,*this);
- if (def)
- {
- set_default_value(slot->device().tag()+1,def);
- const device_slot_option *option = slot->option( def );
- set_flag(slot->device().tag()+1, ~OPTION_FLAG_INTERNAL, option && !option->selectable() ? OPTION_FLAG_INTERNAL : 0 );
- }
+ const char *name = slot->device().tag() + 1;
+ if (exists(name) && slot->first_option() != NULL)
+ {
+ astring defvalue;
+ slot->get_default_card_software(defvalue);
+ if (defvalue.len() > 0)
+ {
+ set_default_value(name, defvalue);
+ const device_slot_option *option = slot->option(defvalue);
+ set_flag(name, ~OPTION_FLAG_INTERNAL, (option != NULL && !option->selectable()) ? OPTION_FLAG_INTERNAL : 0);
}
}
}
}
+
+
//-------------------------------------------------
// add_device_options - add all of the device
// options for the configured system
//-------------------------------------------------
-void emu_options::add_device_options(bool isfirst)
+void emu_options::add_device_options(bool isfirstpass)
{
// look up the system configured by name; if no match, do nothing
const game_driver *cursystem = system();
if (cursystem == NULL)
return;
+ machine_config config(*cursystem, *this);
- // iterate through all slot devices
- options_entry entry[2] = { { 0 }, { 0 } };
- bool first = true;
// iterate through all image devices
- machine_config config(*cursystem, *this);
+ bool first = true;
image_interface_iterator iter(config.root_device());
for (const device_image_interface *image = iter.first(); image != NULL; image = iter.next())
{
// first device? add the header as to be pretty
- if (first && isfirst)
- {
- entry[0].name = NULL;
- entry[0].description = "IMAGE DEVICES";
- entry[0].flags = OPTION_HEADER | OPTION_FLAG_DEVICE;
- entry[0].defvalue = NULL;
- add_entries(entry);
- }
+ if (first && isfirstpass)
+ add_entry(NULL, "IMAGE DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
first = false;
// retrieve info about the device instance
astring option_name;
option_name.printf("%s;%s", image->instance_name(), image->brief_instance_name());
- if (strcmp(image->device_typename(image->image_type()),image->instance_name())==0){
- option_name.printf("%s;%s;%s1;%s1", image->instance_name(), image->brief_instance_name(), image->instance_name(), image->brief_instance_name());
- }
+ if (strcmp(image->device_typename(image->image_type()), image->instance_name()) == 0)
+ option_name.catprintf(";%s1;%s1", image->instance_name(), image->brief_instance_name());
+
// add the option
- if (!exists(image->instance_name())) {
- entry[0].name = option_name;
- entry[0].description = NULL;
- entry[0].flags = OPTION_STRING | OPTION_FLAG_DEVICE;
- entry[0].defvalue = NULL;
- add_entries(entry, true);
- }
+ if (!exists(image->instance_name()))
+ add_entry(option_name, NULL, OPTION_STRING | OPTION_FLAG_DEVICE, NULL, true);
}
}
@@ -360,16 +341,21 @@ void emu_options::remove_device_options()
bool emu_options::parse_slot_devices(int argc, char *argv[], astring &error_string, const char *name, const char *value)
{
- bool isfirst = true;
+ // an initial parse to capture the initial set of values
bool result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
- while (add_slot_options(isfirst)) {
+
+ // keep adding slot options until we stop seeing new stuff
+ bool isfirstpass = true;
+ while (add_slot_options(isfirstpass))
+ {
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
- isfirst = false;
+ isfirstpass = false;
}
+
+ // add device options and reparse
add_device_options(true);
- if (name && exists(name)) {
+ if (name != NULL && exists(name))
set_value(name, value, OPTION_PRIORITY_CMDLINE, error_string);
- }
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
int num = 0;
@@ -379,11 +365,12 @@ bool emu_options::parse_slot_devices(int argc, char *argv[], astring &error_stri
while (add_slot_options(false));
add_device_options(false);
result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
- } while(num != options_count());
+ } while (num != options_count());
return result;
}
+
//-------------------------------------------------
// parse_command_line - parse the command line
// and update the devices
@@ -504,13 +491,12 @@ void emu_options::set_system_name(const char *name)
astring error;
set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE, error);
assert(!error);
- // remove any existing device options
+
+ // remove any existing device options and then add them afresh
remove_device_options();
+ if (add_slot_options(true))
+ while (add_slot_options(false)) { }
- bool isfirst = true;
- while (add_slot_options(isfirst)) {
- isfirst = false;
- }
// then add the options
add_device_options(true);
int num = 0;
@@ -567,26 +553,25 @@ bool emu_options::parse_one_ini(const char *basename, int priority, astring *err
const char *emu_options::main_value(astring &buffer, const char *name) const
{
buffer = value(name);
- int pos = buffer.chr(0,',');
- if (pos!=-1) {
- buffer = buffer.substr(0,pos);
- }
+ int pos = buffer.chr(0, ',');
+ if (pos != -1)
+ buffer = buffer.substr(0, pos);
return buffer.cstr();
}
const char *emu_options::sub_value(astring &buffer, const char *name, const char *subname) const
{
- astring tmp = ",";
- tmp.cat(subname);
- tmp.cat("=");
+ astring tmp(",", subname, "=");
buffer = value(name);
- int pos = buffer.find(0,tmp);
- if (pos!=-1) {
- int endpos = buffer.chr(pos+1,',');
- if(endpos==-1) endpos = buffer.len();
- buffer = buffer.substr(pos+tmp.len(),endpos-pos-tmp.len());
- } else {
- buffer ="";
+ int pos = buffer.find(0, tmp);
+ if (pos != -1)
+ {
+ int endpos = buffer.chr(pos + 1, ',');
+ if (endpos == -1)
+ endpos = buffer.len();
+ buffer = buffer.substr(pos + tmp.len(), endpos - pos - tmp.len());
}
+ else
+ buffer.reset();
return buffer.cstr();
}
diff --git a/src/emu/emutempl.h b/src/emu/emutempl.h
index c0a581f91aa..a56a12de788 100644
--- a/src/emu/emutempl.h
+++ b/src/emu/emutempl.h
@@ -18,387 +18,5 @@
// TYPE DEFINITIONS
//**************************************************************************
-// ======================> simple_list
-
-// a simple_list is a singly-linked list whose 'next' pointer is owned
-// by the object
-template<class _ElementType>
-class simple_list
-{
- // we don't support deep copying
- DISABLE_COPYING(simple_list);
-
-public:
- // construction/destruction
- simple_list(resource_pool &pool = global_resource_pool())
- : m_head(NULL),
- m_tail(NULL),
- m_pool(pool),
- m_count(0) { }
-
- virtual ~simple_list() { reset(); }
-
- // simple getters
- resource_pool &pool() const { return m_pool; }
- _ElementType *first() const { return m_head; }
- _ElementType *last() const { return m_tail; }
- int count() const { return m_count; }
-
- // remove (free) all objects in the list, leaving an empty list
- void reset()
- {
- while (m_head != NULL)
- remove(*m_head);
- }
-
- // add the given object to the head of the list
- _ElementType &prepend(_ElementType &object)
- {
- object.m_next = m_head;
- m_head = &object;
- if (m_tail == NULL)
- m_tail = m_head;
- m_count++;
- return object;
- }
-
- // add the given list to the head of the list
- void prepend_list(simple_list<_ElementType> &list)
- {
- int count = list.count();
- if (count == 0)
- return;
- _ElementType *tail = list.last();
- _ElementType *head = list.detach_all();
- tail->m_next = m_head;
- m_head = head;
- if (m_tail == NULL)
- m_tail = tail;
- m_count += count;
- }
-
- // add the given object to the tail of the list
- _ElementType &append(_ElementType &object)
- {
- object.m_next = NULL;
- if (m_tail != NULL)
- m_tail = m_tail->m_next = &object;
- else
- m_tail = m_head = &object;
- m_count++;
- return object;
- }
-
- // add the given list to the tail of the list
- void append_list(simple_list<_ElementType> &list)
- {
- int count = list.count();
- if (count == 0)
- return;
- _ElementType *tail = list.last();
- _ElementType *head = list.detach_all();
- if (m_tail != NULL)
- m_tail->m_next = head;
- else
- m_head = head;
- m_tail = tail;
- m_count += count;
- }
-
- // insert the given object after a particular object (NULL means prepend)
- _ElementType &insert_after(_ElementType &object, _ElementType *insert_after)
- {
- if (insert_after == NULL)
- return prepend(object);
- object.m_next = insert_after->m_next;
- insert_after->m_next = &object;
- if (m_tail == insert_after)
- m_tail = &object;
- m_count++;
- return object;
- }
-
- // insert the given object before a particular object (NULL means append)
- _ElementType &insert_before(_ElementType &object, _ElementType *insert_before)
- {
- if (insert_before == NULL)
- return append(object);
- for (_ElementType **curptr = &m_head; *curptr != NULL; curptr = &(*curptr)->m_next)
- if (*curptr == insert_before)
- {
- object.m_next = insert_before;
- *curptr = &object;
- if (m_head == insert_before)
- m_head = &object;
- m_count++;
- return object;
- }
- return object;
- }
-
- // replace an item in the list at the same location, and remove it
- _ElementType &replace_and_remove(_ElementType &object, _ElementType &toreplace)
- {
- _ElementType *prev = NULL;
- for (_ElementType *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next)
- if (cur == &toreplace)
- {
- if (prev != NULL)
- prev->m_next = &object;
- else
- m_head = &object;
- if (m_tail == &toreplace)
- m_tail = &object;
- object.m_next = toreplace.m_next;
- pool_free(m_pool, &toreplace);
- return object;
- }
- return append(object);
- }
-
- // detach the head item from the list, but don't free its memory
- _ElementType *detach_head()
- {
- _ElementType *result = m_head;
- if (result != NULL)
- {
- m_head = result->m_next;
- m_count--;
- if (m_head == NULL)
- m_tail = NULL;
- }
- return result;
- }
-
- // detach the given item from the list, but don't free its memory
- _ElementType &detach(_ElementType &object)
- {
- _ElementType *prev = NULL;
- for (_ElementType *cur = m_head; cur != NULL; prev = cur, cur = cur->m_next)
- if (cur == &object)
- {
- if (prev != NULL)
- prev->m_next = object.m_next;
- else
- m_head = object.m_next;
- if (m_tail == &object)
- m_tail = prev;
- m_count--;
- return object;
- }
- return object;
- }
-
- // deatch the entire list, returning the head, but don't free memory
- _ElementType *detach_all()
- {
- _ElementType *result = m_head;
- m_head = m_tail = NULL;
- m_count = 0;
- return result;
- }
-
- // remove the given object and free its memory
- void remove(_ElementType &object)
- {
- detach(object);
- pool_free(m_pool, &object);
- }
-
- // find an object by index in the list
- _ElementType *find(int index) const
- {
- for (_ElementType *cur = m_head; cur != NULL; cur = cur->m_next)
- if (index-- == 0)
- return cur;
- return NULL;
- }
-
- // return the index of the given object in the list
- int indexof(const _ElementType &object) const
- {
- int index = 0;
- for (_ElementType *cur = m_head; cur != NULL; cur = cur->m_next)
- {
- if (cur == &object)
- return index;
- index++;
- }
- return -1;
- }
-
-private:
- // internal state
- _ElementType * m_head; // head of the singly-linked list
- _ElementType * m_tail; // tail of the singly-linked list
- resource_pool & m_pool; // resource pool where objects are freed
- int m_count; // number of objects in the list
-};
-
-
-// ======================> simple_list_wrapper
-
-// a simple_list_wrapper wraps an existing object with a next pointer so it
-// can live in a simple_list without requiring the object to have a next
-// pointer
-template<class _ObjectType>
-class simple_list_wrapper
-{
-public:
- template<class U> friend class simple_list;
-
- // construction/destruction
- simple_list_wrapper(_ObjectType *object)
- : m_next(NULL),
- m_object(object) { }
-
- // operators
- operator _ObjectType *() { return m_object; }
- operator _ObjectType *() const { return m_object; }
- _ObjectType *operator *() { return m_object; }
- _ObjectType *operator *() const { return m_object; }
-
- // getters
- simple_list_wrapper *next() const { return m_next; }
- _ObjectType *object() const { return m_object; }
-
-private:
- // internal state
- simple_list_wrapper * m_next;
- _ObjectType * m_object;
-};
-
-
-// ======================> fixed_allocator
-
-// a fixed_allocator is a simple class that maintains a free pool of objects
-template<class _ItemType>
-class fixed_allocator
-{
- // we don't support deep copying
- DISABLE_COPYING(fixed_allocator);
-
-public:
- // construction/destruction
- fixed_allocator(resource_pool &pool = global_resource_pool())
- : m_freelist(pool) { }
-
- // allocate a new item, either by recycling an old one, or by allocating a new one
- _ItemType *alloc()
- {
- _ItemType *result = m_freelist.detach_head();
- if (result == NULL)
- result = m_freelist.pool().add_object(new _ItemType);
- return result;
- }
-
- // reclaim an item by adding it to the free list
- void reclaim(_ItemType *item) { if (item != NULL) m_freelist.append(*item); }
- void reclaim(_ItemType &item) { m_freelist.append(item); }
-
- // reclaim all items from a list
- void reclaim_all(simple_list<_ItemType> &list) { m_freelist.append_list(list); }
-
-private:
- // internal state
- simple_list<_ItemType> m_freelist; // list of free objects
-};
-
-
-// ======================> tagged_list
-
-// a tagged_list is a class that maintains a list of objects that can be quickly looked up by tag
-template<class _ElementType>
-class tagged_list
-{
- // we don't support deep copying
- DISABLE_COPYING(tagged_list);
-
-public:
- // construction/destruction
- tagged_list(resource_pool &pool = global_resource_pool())
- : m_list(pool) { }
-
- // simple getters
- resource_pool &pool() const { return m_list.pool(); }
- _ElementType *first() const { return m_list.first(); }
- _ElementType *last() const { return m_list.last(); }
- int count() const { return m_list.count(); }
-
- // remove (free) all objects in the list, leaving an empty list
- void reset() { m_list.reset(); m_map.reset(); }
-
- // add the given object to the head of the list
- _ElementType &prepend(const char *tag, _ElementType &object)
- {
- if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE)
- throw emu_fatalerror("Error adding object named '%s'", tag);
- return m_list.prepend(object);
- }
-
- // add the given object to the tail of the list
- _ElementType &append(const char *tag, _ElementType &object)
- {
- if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE)
- throw emu_fatalerror("Error adding object named '%s'", tag);
- return m_list.append(object);
- }
-
- // insert the given object after a particular object (NULL means prepend)
- _ElementType &insert_after(const char *tag, _ElementType &object, _ElementType *insert_after)
- {
- if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE)
- throw emu_fatalerror("Error adding object named '%s'", tag);
- return m_list.insert_after(object, insert_after);
- }
-
- // replace an item in the list at the same location, and remove it
- _ElementType &replace_and_remove(const char *tag, _ElementType &object, _ElementType &toreplace)
- {
- m_map.remove(&toreplace);
- m_list.replace_and_remove(object, toreplace);
- if (m_map.add_unique_hash(tag, &object, false) != TMERR_NONE)
- throw emu_fatalerror("Error replacing object named '%s'", tag);
- return object;
- }
-
- // detach the given item from the list, but don't free its memory
- _ElementType &detach(_ElementType &object)
- {
- m_map.remove(&object);
- return m_list.detach(object);
- }
-
- // remove the given object and free its memory
- void remove(_ElementType &object)
- {
- m_map.remove(&object);
- return m_list.remove(object);
- }
-
- // find an object by index in the list
- _ElementType *find(int index) const
- {
- return m_list.find(index);
- }
-
- // return the index of the given object in the list
- int indexof(const _ElementType &object) const
- {
- return m_list.indexof(object);
- }
-
- // operations by tag
- _ElementType &replace_and_remove(const char *tag, _ElementType &object) { _ElementType *existing = find(tag); return (existing == NULL) ? append(tag, object) : replace_and_remove(tag, object, *existing); }
- void remove(const char *tag) { _ElementType *object = find(tag); if (object != NULL) remove(*object); }
- _ElementType *find(const char *tag) const { return m_map.find_hash_only(tag); }
- int indexof(const char *tag) const { _ElementType *object = find(tag); return (object != NULL) ? m_list.indexof(*object) : NULL; }
-
-private:
- // internal state
- simple_list<_ElementType> m_list;
- tagmap_t<_ElementType *> m_map;
-};
-
#endif /* __EMUTEMPL_H__ */
diff --git a/src/emu/fileio.c b/src/emu/fileio.c
index 8ac8d96598f..4883c199d4a 100644
--- a/src/emu/fileio.c
+++ b/src/emu/fileio.c
@@ -144,10 +144,8 @@ emu_file::emu_file(UINT32 openflags)
m_crc(0),
m_openflags(openflags),
m_zipfile(NULL),
- m_zipdata(NULL),
m_ziplength(0),
m__7zfile(NULL),
- m__7zdata(NULL),
m__7zlength(0),
m_remove_on_close(false)
{
@@ -162,10 +160,8 @@ emu_file::emu_file(const char *searchpath, UINT32 openflags)
m_crc(0),
m_openflags(openflags),
m_zipfile(NULL),
- m_zipdata(NULL),
m_ziplength(0),
m__7zfile(NULL),
- m__7zdata(NULL),
m__7zlength(0),
m_remove_on_close(false)
{
@@ -239,15 +235,15 @@ hash_collection &emu_file::hashes(const char *types)
return m_hashes;
// if we have ZIP data, just hash that directly
- if (m__7zdata != NULL)
+ if (m__7zdata.count() != 0)
{
- m_hashes.compute(m__7zdata, m__7zlength, needed);
+ m_hashes.compute(m__7zdata, m__7zdata.count(), needed);
return m_hashes;
}
- if (m_zipdata != NULL)
+ if (m_zipdata.count() != 0)
{
- m_hashes.compute(m_zipdata, m_ziplength, needed);
+ m_hashes.compute(m_zipdata, m_zipdata.count(), needed);
return m_hashes;
}
@@ -411,13 +407,8 @@ void emu_file::close()
core_fclose(m_file);
m_file = NULL;
- if (m__7zdata != NULL)
- global_free(m__7zdata);
- m__7zdata = NULL;
-
- if (m_zipdata != NULL)
- global_free(m_zipdata);
- m_zipdata = NULL;
+ m__7zdata.reset();
+ m_zipdata.reset();
if (m_remove_on_close)
osd_rmfile(m_fullpath);
@@ -739,27 +730,25 @@ file_error emu_file::attempt_zipped()
file_error emu_file::load_zipped_file()
{
assert(m_file == NULL);
- assert(m_zipdata == NULL);
+ assert(m_zipdata.count() == 0);
assert(m_zipfile != NULL);
// allocate some memory
- m_zipdata = global_alloc_array(UINT8, m_ziplength);
+ m_zipdata.resize(m_ziplength);
// read the data into our buffer and return
- zip_error ziperr = zip_file_decompress(m_zipfile, m_zipdata, m_ziplength);
+ zip_error ziperr = zip_file_decompress(m_zipfile, m_zipdata, m_zipdata.count());
if (ziperr != ZIPERR_NONE)
{
- global_free(m_zipdata);
- m_zipdata = NULL;
+ m_zipdata.reset();
return FILERR_FAILURE;
}
// convert to RAM file
- file_error filerr = core_fopen_ram(m_zipdata, m_ziplength, m_openflags, &m_file);
+ file_error filerr = core_fopen_ram(m_zipdata, m_zipdata.count(), m_openflags, &m_file);
if (filerr != FILERR_NONE)
{
- global_free(m_zipdata);
- m_zipdata = NULL;
+ m_zipdata.reset();
return FILERR_FAILURE;
}
@@ -866,27 +855,25 @@ file_error emu_file::attempt__7zped()
file_error emu_file::load__7zped_file()
{
assert(m_file == NULL);
- assert(m__7zdata == NULL);
+ assert(m__7zdata.count() == 0);
assert(m__7zfile != NULL);
// allocate some memory
- m__7zdata = global_alloc_array(UINT8, m__7zlength);
+ m__7zdata.resize(m__7zlength);
// read the data into our buffer and return
- _7z_error _7zerr = _7z_file_decompress(m__7zfile, m__7zdata, m__7zlength);
+ _7z_error _7zerr = _7z_file_decompress(m__7zfile, m__7zdata, m__7zdata.count());
if (_7zerr != _7ZERR_NONE)
{
- global_free(m__7zdata);
- m__7zdata = NULL;
+ m__7zdata.reset();
return FILERR_FAILURE;
}
// convert to RAM file
- file_error filerr = core_fopen_ram(m__7zdata, m__7zlength, m_openflags, &m_file);
+ file_error filerr = core_fopen_ram(m__7zdata, m__7zdata.count(), m_openflags, &m_file);
if (filerr != FILERR_NONE)
{
- global_free(m__7zdata);
- m__7zdata = NULL;
+ m__7zdata.reset();
return FILERR_FAILURE;
}
diff --git a/src/emu/fileio.h b/src/emu/fileio.h
index 680748d0101..b5781a5d1c3 100644
--- a/src/emu/fileio.h
+++ b/src/emu/fileio.h
@@ -156,11 +156,11 @@ private:
hash_collection m_hashes; // collection of hashes
zip_file * m_zipfile; // ZIP file pointer
- UINT8 * m_zipdata; // ZIP file data
+ dynamic_buffer m_zipdata; // ZIP file data
UINT64 m_ziplength; // ZIP file length
_7z_file * m__7zfile; // 7Z file pointer
- UINT8 * m__7zdata; // 7Z file data
+ dynamic_buffer m__7zdata; // 7Z file data
UINT64 m__7zlength; // 7Z file length
bool m_remove_on_close; // flag: remove the file when closing
diff --git a/src/emu/hashfile.c b/src/emu/hashfile.c
index fb9a4d07a2c..f56504ca783 100644
--- a/src/emu/hashfile.c
+++ b/src/emu/hashfile.c
@@ -537,7 +537,7 @@ const hash_info *hashfile_lookup(hash_file *hashfile, const hash_collection *has
const char *extra_info = NULL;
-const char *read_hash_config(device_image_interface &image, const char *sysname)
+bool read_hash_config(device_image_interface &image, const char *sysname, astring &result)
{
hash_file *hashfile = NULL;
const hash_info *info = NULL;
@@ -545,7 +545,7 @@ const char *read_hash_config(device_image_interface &image, const char *sysname)
/* open the hash file */
hashfile = hashfile_open(image.device().machine().options(), sysname, FALSE, NULL);
if (!hashfile)
- return NULL;
+ return false;
/* look up this entry in the hash file */
info = hashfile_lookup(hashfile, &image.hash());
@@ -553,34 +553,27 @@ const char *read_hash_config(device_image_interface &image, const char *sysname)
if (!info || !info->extrainfo)
{
hashfile_close(hashfile);
- return NULL;
+ return false;
}
- extra_info = auto_strdup(image.device().machine(), info->extrainfo);
- if (!extra_info)
- {
- hashfile_close(hashfile);
- return NULL;
- }
+ result.cpy(info->extrainfo);
/* copy the relevant entries */
hashfile_close(hashfile);
-
- return extra_info;
+ return true;
}
-const char *hashfile_extrainfo(device_image_interface &image)
+bool hashfile_extrainfo(device_image_interface &image, astring &result)
{
- const char *rc;
-
/* now read the hash file */
image.crc();
extra_info = NULL;
int drv = driver_list::find(image.device().machine().system());
int compat, open = drv;
+ bool hashfound;
do
{
- rc = read_hash_config(image, driver_list::driver(open).name);
+ hashfound = read_hash_config(image, driver_list::driver(open).name, result);
// first check if there are compatible systems
compat = driver_list::compatible_with(open);
// if so, try to open its hashfile
@@ -594,8 +587,8 @@ const char *hashfile_extrainfo(device_image_interface &image)
}
}
// if no extrainfo has been found but we can try a compatible or a parent set, go back
- while (rc == NULL && open != -1);
- return rc;
+ while (!hashfound && open != -1);
+ return hashfound;
}
/***************************************************************************
@@ -616,11 +609,11 @@ static void *expat_malloc(size_t size)
static void *expat_realloc(void *ptr, size_t size)
{
- if (ptr) global_free(ptr);
+ if (ptr) global_free_array((UINT8 *)ptr);
return global_alloc_array_clear(UINT8,size);
}
static void expat_free(void *ptr)
{
- global_free(ptr);
+ global_free_array((UINT8 *)ptr);
}
diff --git a/src/emu/hashfile.h b/src/emu/hashfile.h
index c59421487f2..c462b5c74d3 100644
--- a/src/emu/hashfile.h
+++ b/src/emu/hashfile.h
@@ -12,6 +12,6 @@
#include "emu.h"
-const char *hashfile_extrainfo(device_image_interface &image);
+bool hashfile_extrainfo(device_image_interface &image, astring &result);
#endif /* __HASHFILE_H__ */
diff --git a/src/emu/imagedev/cartslot.h b/src/emu/imagedev/cartslot.h
index fee89b2cb70..9b524dbda9f 100644
--- a/src/emu/imagedev/cartslot.h
+++ b/src/emu/imagedev/cartslot.h
@@ -39,7 +39,7 @@ public:
virtual bool call_load();
virtual void call_unload();
virtual void call_display_info() { if (!m_device_image_displayinfo.isnull()) m_device_image_displayinfo(*this); }
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) { load_software_part_region( this, swlist, swname, start_entry ); return TRUE; }
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { load_software_part_region( *this, swlist, swname, start_entry ); return TRUE; }
virtual device_image_partialhash_func get_partial_hash() const { return m_device_image_partialhash; }
virtual iodevice_t image_type() const { return IO_CARTSLOT; }
diff --git a/src/emu/imagedev/cassette.h b/src/emu/imagedev/cassette.h
index 7dcbc77a2bd..7fd6c2ea4fb 100644
--- a/src/emu/imagedev/cassette.h
+++ b/src/emu/imagedev/cassette.h
@@ -65,7 +65,7 @@ public:
virtual void call_unload();
virtual void call_display();
virtual void call_display_info() { if (m_device_displayinfo) m_device_displayinfo(*this); }
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) { return load_software(swlist, swname, start_entry); }
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { return load_software(swlist, swname, start_entry); }
virtual iodevice_t image_type() const { return IO_CASSETTE; }
diff --git a/src/emu/imagedev/chd_cd.c b/src/emu/imagedev/chd_cd.c
index 31b29aa1865..153e9dd3365 100644
--- a/src/emu/imagedev/chd_cd.c
+++ b/src/emu/imagedev/chd_cd.c
@@ -65,15 +65,7 @@ void cdrom_image_device::device_config_complete()
m_extension_list = "chd,cue,toc,nrg,gdi,iso,cdr";
- image_device_format *format = global_alloc_clear(image_device_format);;
- format->m_index = 0;
- format->m_name = "chdcd";
- format->m_description = "CD-ROM drive";
- format->m_extensions = m_extension_list;
- format->m_optspec = cd_option_spec;
- format->m_next = NULL;
-
- m_formatlist = format;
+ m_formatlist.append(*global_alloc(image_device_format("chdcd", "CD-ROM drive", m_extension_list, cd_option_spec)));
// set brief and instance name
update_names();
diff --git a/src/emu/imagedev/chd_cd.h b/src/emu/imagedev/chd_cd.h
index d5f8bdb30b1..1504a28f13f 100644
--- a/src/emu/imagedev/chd_cd.h
+++ b/src/emu/imagedev/chd_cd.h
@@ -38,7 +38,7 @@ public:
virtual bool call_load();
virtual void call_unload();
virtual void call_display_info() { if (m_device_displayinfo) m_device_displayinfo(*this); }
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) { load_software_part_region(this, swlist, swname, start_entry ); return TRUE; }
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; }
virtual iodevice_t image_type() const { return IO_CDROM; }
@@ -61,7 +61,6 @@ protected:
chd_file m_self_chd;
cdrom_file *m_cdrom_handle;
- image_device_format m_format;
const char *m_extension_list;
};
diff --git a/src/emu/imagedev/flopdrv.c b/src/emu/imagedev/flopdrv.c
index c9c97cf5ddc..69b883f585a 100644
--- a/src/emu/imagedev/flopdrv.c
+++ b/src/emu/imagedev/flopdrv.c
@@ -918,31 +918,14 @@ void legacy_floppy_image_device::device_start()
void legacy_floppy_image_device::device_config_complete()
{
- image_device_format **formatptr;
- image_device_format *format;
- formatptr = &m_formatlist;
- int cnt = 0;
-
m_extension_list[0] = '\0';
const struct FloppyFormat *floppy_options = ((floppy_interface*)static_config())->formats;
for (int i = 0; floppy_options[i].construct; i++)
{
// only add if creatable
if (floppy_options[i].param_guidelines) {
- // allocate a new format
- format = global_alloc_clear(image_device_format);
-
- // populate it
- format->m_index = cnt;
- format->m_name = floppy_options[i].name;
- format->m_description = floppy_options[i].description;
- format->m_extensions = floppy_options[i].extensions;
- format->m_optspec = floppy_options[i].param_guidelines;
-
- // and append it to the list
- *formatptr = format;
- formatptr = &format->m_next;
- cnt++;
+ // allocate a new format and append it to the list
+ m_formatlist.append(*global_alloc(image_device_format(floppy_options[i].name, floppy_options[i].description, floppy_options[i].extensions, floppy_options[i].param_guidelines)));
}
image_specify_extension( m_extension_list, 256, floppy_options[i].extensions );
}
diff --git a/src/emu/imagedev/flopdrv.h b/src/emu/imagedev/flopdrv.h
index c59e4d282a2..a5146168d3c 100644
--- a/src/emu/imagedev/flopdrv.h
+++ b/src/emu/imagedev/flopdrv.h
@@ -187,7 +187,7 @@ public:
~legacy_floppy_image_device();
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) { return load_software(swlist, swname, start_entry); }
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { return load_software(swlist, swname, start_entry); }
virtual bool call_create(int format_type, option_resolution *format_options);
virtual void call_unload();
virtual void call_display_info();
@@ -204,13 +204,13 @@ public:
virtual const option_guide *create_option_guide() const { return floppy_option_guide; }
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct floppy_drive *token() const { assert(m_token != NULL); return m_token; }
protected:
// device overrides
virtual void device_config_complete();
virtual void device_start();
- void *m_token;
+ struct floppy_drive *m_token;
char m_extension_list[256];
};
diff --git a/src/emu/imagedev/floppy.c b/src/emu/imagedev/floppy.c
index 911b3271dca..bd32e44a9fc 100644
--- a/src/emu/imagedev/floppy.c
+++ b/src/emu/imagedev/floppy.c
@@ -187,9 +187,6 @@ void floppy_image_device::setup_wpt_cb(wpt_cb cb)
void floppy_image_device::set_formats(const floppy_format_type *formats)
{
- image_device_format **formatptr;
- image_device_format *format;
- formatptr = &m_formatlist;
extension_list[0] = '\0';
fif_list = 0;
for(int cnt=0; formats[cnt]; cnt++)
@@ -201,17 +198,9 @@ void floppy_image_device::set_formats(const floppy_format_type *formats)
else
fif_list->append(fif);
- format = global_alloc_clear(image_device_format);
- format->m_index = cnt;
- format->m_name = fif->name();
- format->m_description = fif->description();
- format->m_extensions = fif->extensions();
- format->m_optspec = "";
+ m_formatlist.append(*global_alloc(image_device_format(fif->name(), fif->description(), fif->extensions(), "")));
image_specify_extension( extension_list, 256, fif->extensions() );
- // and append it to the list
- *formatptr = format;
- formatptr = &format->m_next;
}
// set brief and instance name
@@ -615,7 +604,7 @@ void floppy_image_device::write_flux(attotime start, attotime end, int transitio
int start_pos = find_position(base, start);
int end_pos = find_position(base, end);
- int *trans_pos = transition_count ? global_alloc_array(int, transition_count) : 0;
+ dynamic_array<int> trans_pos(transition_count);
for(int i=0; i != transition_count; i++)
trans_pos[i] = find_position(base, transitions[i]);
@@ -663,9 +652,6 @@ void floppy_image_device::write_flux(attotime start, attotime end, int transitio
}
image->set_track_size(cyl, ss, cells);
-
- if(trans_pos)
- global_free(trans_pos);
}
void floppy_image_device::write_zone(UINT32 *buf, int &cells, int &index, UINT32 spos, UINT32 epos, UINT32 mg)
@@ -839,32 +825,29 @@ astring ui_menu_control_floppy_image::try_file(astring location, astring name, b
void ui_menu_control_floppy_image::hook_load(astring filename, bool softlist)
{
input_filename = filename;
- if(softlist) {
- char *swlist_name, *swname, *swpart;
- software_name_split(filename.cstr(), &swlist_name, &swname, &swpart);
- software_list *sw_list = software_list_open(machine().options(), swlist_name, FALSE, NULL);
- software_info *sw_info = software_list_find(sw_list, swname, NULL);
- software_part *sw_part = software_find_part(sw_info, swpart, NULL);
- const char *parentname = software_get_clone(machine().options(), swlist_name, sw_info->shortname);
- for(const rom_entry *region = sw_part->romdata; region; region = rom_next_region(region)) {
+ if (softlist)
+ {
+ astring swlist_name, swinfo_name, swpart_name;
+ device_image_interface::software_name_split(filename.cstr(), swlist_name, swinfo_name, swpart_name);
+ software_list_device *swlistdev = software_list_device::find_by_name(machine().config(), swlist_name);
+ software_info *swinfo = swlistdev->find(swinfo_name);
+ software_part *swpart = swinfo->find_part(swpart_name);
+ const char *parentname = swinfo->parentname();
+ for(const rom_entry *region = swpart->romdata(); region; region = rom_next_region(region)) {
const rom_entry *romp = region + 1;
UINT32 crc = 0;
bool has_crc = hash_collection(ROM_GETHASHDATA(romp)).crc(crc);
- filename = try_file(astring(swlist_name) + PATH_SEPARATOR + astring(swname), ROM_GETNAME(romp), has_crc, crc);
+ filename = try_file(astring(swlistdev->list_name()) + PATH_SEPARATOR + astring(swinfo_name), ROM_GETNAME(romp), has_crc, crc);
if(filename == "")
filename = try_file(astring(swlist_name) + PATH_SEPARATOR + astring(parentname), ROM_GETNAME(romp), has_crc, crc);
if(filename == "")
- filename = try_file(swname, ROM_GETNAME(romp), has_crc, crc);
+ filename = try_file(swinfo_name, ROM_GETNAME(romp), has_crc, crc);
if(filename == "")
filename = try_file(parentname, ROM_GETNAME(romp), has_crc, crc);
if(filename != "")
- goto found;
+ break;
}
-
- found:
- software_list_close(sw_list);
- global_free(swlist_name);
}
input_format = static_cast<floppy_image_device *>(image)->identify(filename);
diff --git a/src/emu/imagedev/floppy.h b/src/emu/imagedev/floppy.h
index 9646ecde7bb..a7b06749cc7 100644
--- a/src/emu/imagedev/floppy.h
+++ b/src/emu/imagedev/floppy.h
@@ -70,7 +70,7 @@ public:
virtual void call_unload();
virtual bool call_create(int format_type, option_resolution *format_options);
virtual void call_display_info() {}
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) { return load_software(swlist, swname, start_entry); }
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { return load_software(swlist, swname, start_entry); }
virtual const char *image_interface() const = 0;
virtual iodevice_t image_type() const { return IO_FLOPPY; }
@@ -131,7 +131,6 @@ protected:
virtual void setup_characteristics() = 0;
- image_device_format format;
floppy_image_format_t *input_format;
floppy_image_format_t *output_format;
floppy_image *image;
diff --git a/src/emu/imagedev/harddriv.c b/src/emu/imagedev/harddriv.c
index f65be26142c..089d80518a1 100644
--- a/src/emu/imagedev/harddriv.c
+++ b/src/emu/imagedev/harddriv.c
@@ -74,15 +74,7 @@ void harddisk_image_device::device_config_complete()
memset(&m_device_displayinfo, 0, sizeof(m_device_displayinfo));
}
- image_device_format *format = global_alloc_clear(image_device_format);;
- format->m_index = 0;
- format->m_name = "chd";
- format->m_description = "CHD Hard drive";
- format->m_extensions = "chd,hd";
- format->m_optspec = hd_option_spec;
- format->m_next = NULL;
-
- m_formatlist = format;
+ m_formatlist.append(*global_alloc(image_device_format("chd", "CHD Hard drive", "chd,hd", hd_option_spec)));
// set brief and instance name
update_names();
diff --git a/src/emu/imagedev/harddriv.h b/src/emu/imagedev/harddriv.h
index 05e65236365..c44e47bb802 100644
--- a/src/emu/imagedev/harddriv.h
+++ b/src/emu/imagedev/harddriv.h
@@ -41,7 +41,7 @@ public:
virtual bool call_create(int create_format, option_resolution *create_args);
virtual void call_unload();
virtual void call_display_info() { if (m_device_displayinfo) m_device_displayinfo(*this); }
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) { load_software_part_region(this, swlist, swname, start_entry ); return TRUE; }
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { load_software_part_region(*this, swlist, swname, start_entry ); return TRUE; }
virtual iodevice_t image_type() const { return IO_HARDDISK; }
@@ -70,8 +70,6 @@ protected:
chd_file m_origchd; /* handle to the original CHD */
chd_file m_diffchd; /* handle to the diff CHD */
hard_disk_file *m_hard_disk_handle;
-
- image_device_format m_format;
};
// device type definition
diff --git a/src/emu/imagedev/snapquik.h b/src/emu/imagedev/snapquik.h
index adde197320b..909b8c2081c 100644
--- a/src/emu/imagedev/snapquik.h
+++ b/src/emu/imagedev/snapquik.h
@@ -23,7 +23,7 @@ public:
// image-level overrides
virtual bool call_load();
- virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) { return load_software(swlist, swname, start_entry); }
+ virtual bool call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) { return load_software(swlist, swname, start_entry); }
virtual iodevice_t image_type() const { return IO_SNAPSHOT; }
virtual bool is_readable() const { return 1; }
diff --git a/src/emu/info.c b/src/emu/info.c
index a54f73d4cfa..67ece74f50a 100644
--- a/src/emu/info.c
+++ b/src/emu/info.c
@@ -401,7 +401,7 @@ void info_xml_creator::output_devices()
{
astring temptag("_");
temptag.cat(option->name());
- device_t *dev = const_cast<machine_config &>(m_drivlist.config()).device_add(&m_drivlist.config().root_device(), temptag.cstr(), option->devtype(), 0);
+ auto_pointer<device_t> dev(const_cast<machine_config &>(m_drivlist.config()).device_add(&m_drivlist.config().root_device(), temptag.cstr(), option->devtype(), 0));
// notify this device and all its subdevices that they are now configured
device_iterator subiter(*dev);
@@ -413,7 +413,6 @@ void info_xml_creator::output_devices()
output_one_device(*dev, temptag.cstr());
const_cast<machine_config &>(m_drivlist.config()).device_remove(&m_drivlist.config().root_device(), temptag.cstr());
- global_free(dev);
}
}
}
diff --git a/src/emu/input.c b/src/emu/input.c
index f7f7aa93b94..0ebd5d7df3d 100644
--- a/src/emu/input.c
+++ b/src/emu/input.c
@@ -44,54 +44,6 @@ const input_seq input_seq::empty_seq;
// TYPE DEFINITIONS
//**************************************************************************
-// ======================> input_device_item
-
-// a single item on an input device
-class input_device_item
-{
-protected:
- // construction/destruction
- input_device_item(input_device &device, const char *name, void *internal, input_item_id itemid, item_get_state_func getstate, input_item_class itemclass);
- virtual ~input_device_item() { }
-
-public:
- // getters
- input_device &device() const { return m_device; }
- input_manager &manager() const { return m_device.manager(); }
- running_machine &machine() const { return m_device.machine(); }
- const char *name() const { return m_name; }
- void *internal() const { return m_internal; }
- input_item_id itemid() const { return m_itemid; }
- input_item_class itemclass() const { return m_itemclass; }
- const char *token() const { return m_token; }
- INT32 current() const { return m_current; }
- INT32 memory() const { return m_memory; }
-
- // helpers
- INT32 update_value() { return m_current = (*m_getstate)(m_device.internal(), m_internal); }
- void set_memory(INT32 value) { m_memory = value; }
-
- // readers
- virtual INT32 read_as_switch(input_item_modifier modifier) = 0;
- virtual INT32 read_as_relative(input_item_modifier modifier) = 0;
- virtual INT32 read_as_absolute(input_item_modifier modifier) = 0;
-
-protected:
- // internal state
- input_device & m_device; // reference to our owning device
- astring m_name; // string name of item
- void * m_internal; // internal callback pointer
- input_item_id m_itemid; // originally specified item id
- input_item_class m_itemclass; // class of the item
- item_get_state_func m_getstate; // get state callback
- astring m_token; // tokenized name for non-standard items
-
- // live state
- INT32 m_current; // current raw value
- INT32 m_memory; // "memory" value, to remember where we started during polling
-};
-
-
// ======================> input_device_switch_item
// derived input item representing a switch input
@@ -848,9 +800,6 @@ input_device::input_device(input_class &_class, int devindex, const char *name,
m_steadykey_enabled(_class.manager().machine().options().steadykey()),
m_lightgun_reload_button(_class.manager().machine().options().offscreen_reload())
{
- // reset the items
- memset(m_item, 0, sizeof(m_item));
-
// additional work for joysticks
if (devclass() == DEVICE_CLASS_JOYSTICK)
{
@@ -899,15 +848,15 @@ input_item_id input_device::add_item(const char *name, input_item_id itemid, ite
switch (m_class.standard_item_class(originalid))
{
case ITEM_CLASS_SWITCH:
- item = auto_alloc(machine(), input_device_switch_item(*this, name, internal, itemid, getstate));
+ item = global_alloc(input_device_switch_item(*this, name, internal, itemid, getstate));
break;
case ITEM_CLASS_RELATIVE:
- item = auto_alloc(machine(), input_device_relative_item(*this, name, internal, itemid, getstate));
+ item = global_alloc(input_device_relative_item(*this, name, internal, itemid, getstate));
break;
case ITEM_CLASS_ABSOLUTE:
- item = auto_alloc(machine(), input_device_absolute_item(*this, name, internal, itemid, getstate));
+ item = global_alloc(input_device_absolute_item(*this, name, internal, itemid, getstate));
break;
default:
@@ -915,7 +864,7 @@ input_item_id input_device::add_item(const char *name, input_item_id itemid, ite
}
// assign the new slot and update the maximum
- m_item[itemid] = item;
+ m_item[itemid].reset(item);
m_maxitem = MAX(m_maxitem, itemid);
return itemid;
}
@@ -1006,8 +955,6 @@ input_class::input_class(input_manager &manager, input_device_class devclass, bo
m_enabled(enabled),
m_multi(multi)
{
- memset(m_device, 0, sizeof(m_device));
-
// request a per-frame callback for the keyboard class
if (devclass == DEVICE_CLASS_KEYBOARD)
machine().add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(FUNC(input_class::frame_callback), this));
@@ -1038,13 +985,13 @@ input_device *input_class::add_device(int devindex, const char *name, void *inte
assert(m_device[devindex] == NULL);
// allocate a new device
- input_device *device = m_device[devindex] = auto_alloc(machine(), input_device(*this, devindex, name, internal));
+ m_device[devindex].reset(global_alloc(input_device(*this, devindex, name, internal)));
// update the maximum index found
m_maxindex = MAX(m_maxindex, devindex);
mame_printf_verbose("Input: Adding %s #%d: %s\n", (*devclass_string_table)[m_devclass], devindex, name);
- return device;
+ return m_device[devindex];
}
diff --git a/src/emu/input.h b/src/emu/input.h
index 15615a55ace..e35838520ee 100644
--- a/src/emu/input.h
+++ b/src/emu/input.h
@@ -484,6 +484,55 @@ private:
};
+// ======================> input_device_item
+
+// a single item on an input device
+class input_device_item
+{
+protected:
+ // construction/destruction
+ input_device_item(input_device &device, const char *name, void *internal, input_item_id itemid, item_get_state_func getstate, input_item_class itemclass);
+
+public:
+ virtual ~input_device_item() { }
+
+ // getters
+ input_device &device() const { return m_device; }
+ input_manager &manager() const;
+ running_machine &machine() const;
+ const char *name() const { return m_name; }
+ void *internal() const { return m_internal; }
+ input_item_id itemid() const { return m_itemid; }
+ input_item_class itemclass() const { return m_itemclass; }
+ const char *token() const { return m_token; }
+ INT32 current() const { return m_current; }
+ INT32 memory() const { return m_memory; }
+
+ // helpers
+ INT32 update_value();
+ void set_memory(INT32 value) { m_memory = value; }
+
+ // readers
+ virtual INT32 read_as_switch(input_item_modifier modifier) = 0;
+ virtual INT32 read_as_relative(input_item_modifier modifier) = 0;
+ virtual INT32 read_as_absolute(input_item_modifier modifier) = 0;
+
+protected:
+ // internal state
+ input_device & m_device; // reference to our owning device
+ astring m_name; // string name of item
+ void * m_internal; // internal callback pointer
+ input_item_id m_itemid; // originally specified item id
+ input_item_class m_itemclass; // class of the item
+ item_get_state_func m_getstate; // get state callback
+ astring m_token; // tokenized name for non-standard items
+
+ // live state
+ INT32 m_current; // current raw value
+ INT32 m_memory; // "memory" value, to remember where we started during polling
+};
+
+
// ======================> input_device
// a logical device of a given class that can provide input
@@ -522,7 +571,7 @@ private:
input_class & m_class; // reference to our class
astring m_name; // string name of device
int m_devindex; // device index of this device
- input_device_item * m_item[ITEM_ID_ABSOLUTE_MAXIMUM+1]; // array of pointers to items
+ auto_pointer<input_device_item> m_item[ITEM_ID_ABSOLUTE_MAXIMUM+1]; // array of pointers to items
input_item_id m_maxitem; // maximum item index
void * m_internal; // internal callback pointer
@@ -547,7 +596,7 @@ public:
// getters
input_manager &manager() const { return m_manager; }
running_machine &machine() const;
- input_device *device(int index) const { return (index <= m_maxindex) ? m_device[index] : NULL; }
+ input_device *device(int index) const { return (index <= m_maxindex) ? m_device[index].get() : NULL; }
input_device_class devclass() const { return m_devclass; }
int maxindex() const { return m_maxindex; }
bool enabled() const { return m_enabled; }
@@ -570,7 +619,7 @@ private:
// internal state
input_manager & m_manager; // reference to our manager
- input_device * m_device[DEVICE_INDEX_MAXIMUM]; // array of devices in this class
+ auto_pointer<input_device> m_device[DEVICE_INDEX_MAXIMUM]; // array of devices in this class
input_device_class m_devclass; // our device class
int m_maxindex; // maximum populated index
bool m_enabled; // is this class enabled?
@@ -1094,6 +1143,11 @@ extern const char joystick_map_4way_diagonal[];
// INLINE FUNCTIONS
//**************************************************************************
+// input_device_item helpers
+inline input_manager &input_device_item::manager() const { return m_device.manager(); }
+inline running_machine &input_device_item::machine() const { return m_device.machine(); }
+inline INT32 input_device_item::update_value() { return m_current = (*m_getstate)(m_device.internal(), m_internal); }
+
// input_device helpers
inline input_manager &input_device::manager() const { return m_class.manager(); }
inline running_machine &input_device::machine() const { return m_class.machine(); }
@@ -1103,4 +1157,5 @@ inline input_device_class input_device::devclass() const { return m_class.devcla
inline running_machine &input_class::machine() const { return m_manager.machine(); }
+
#endif // __INPUT_H__
diff --git a/src/emu/ioport.c b/src/emu/ioport.c
index eb4e201886d..7d7c5978f39 100644
--- a/src/emu/ioport.c
+++ b/src/emu/ioport.c
@@ -1587,7 +1587,6 @@ ioport_diplocation::ioport_diplocation(const char *name, UINT8 swnum, bool inver
ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value defvalue, ioport_value maskbits, const char *name)
: m_next(NULL),
m_port(port),
- m_live(NULL),
m_modcount(port.modcount()),
m_mask(maskbits),
m_defvalue(defvalue & maskbits),
@@ -1638,7 +1637,6 @@ ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value def
ioport_field::~ioport_field()
{
- global_free(m_live);
}
@@ -2263,7 +2261,7 @@ void ioport_field::init_live_state(analog_field *analog)
m_crosshair_mapper.bind_relative_to(device());
// allocate live state
- m_live = global_alloc(ioport_field_live(*this, analog));
+ m_live.reset(global_alloc(ioport_field_live(*this, analog)));
m_condition.initialize(device());
@@ -2338,8 +2336,7 @@ ioport_port::ioport_port(device_t &owner, const char *tag)
m_device(owner),
m_tag(tag),
m_modcount(0),
- m_active(0),
- m_live(NULL)
+ m_active(0)
{
}
@@ -2350,7 +2347,6 @@ ioport_port::ioport_port(device_t &owner, const char *tag)
ioport_port::~ioport_port()
{
- global_free(m_live);
}
@@ -2530,7 +2526,7 @@ void ioport_port::insert_field(ioport_field &newfield, ioport_value &disallowedb
void ioport_port::init_live_state()
{
- m_live = global_alloc(ioport_port_live(*this));
+ m_live.reset(global_alloc(ioport_port_live(*this)));
}
diff --git a/src/emu/ioport.h b/src/emu/ioport.h
index 1792094264a..602cfebcdd2 100644
--- a/src/emu/ioport.h
+++ b/src/emu/ioport.h
@@ -1090,7 +1090,7 @@ private:
// internal state
ioport_field * m_next; // pointer to next field in sequence
ioport_port & m_port; // reference to the port that owns us
- ioport_field_live * m_live; // live state of field (NULL if not live)
+ auto_pointer<ioport_field_live> m_live; // live state of field (NULL if not live)
int m_modcount; // modification count
simple_list<ioport_setting> m_settinglist; // list of input_setting_configs
simple_list<ioport_diplocation> m_diploclist; // list of locations for various bits
@@ -1138,9 +1138,7 @@ class ioport_list : public tagged_list<ioport_port>
DISABLE_COPYING(ioport_list);
public:
- // construction/destruction
- ioport_list(resource_pool &pool = global_resource_pool())
- : tagged_list<ioport_port>(pool) { }
+ ioport_list() { }
using tagged_list<ioport_port>::append;
void append(device_t &device, astring &errorbuf);
@@ -1195,7 +1193,7 @@ private:
astring m_tag; // copy of this port's tag
int m_modcount; // modification count
ioport_value m_active; // mask of active bits in the port
- ioport_port_live * m_live; // live state of port (NULL if not live)
+ auto_pointer<ioport_port_live> m_live; // live state of port (NULL if not live)
};
diff --git a/src/emu/machine.c b/src/emu/machine.c
index a87433f3e56..2789183b5a6 100644
--- a/src/emu/machine.c
+++ b/src/emu/machine.c
@@ -81,6 +81,7 @@
#include "validity.h"
#include "unzip.h"
#include "debug/debugcon.h"
+#include "debug/debugvw.h"
#include <time.h>
@@ -120,14 +121,6 @@ running_machine::running_machine(const machine_config &_config, osd_interface &o
m_config(_config),
m_system(_config.gamedrv()),
m_osd(osd),
- m_cheat(NULL),
- m_render(NULL),
- m_input(NULL),
- m_sound(NULL),
- m_video(NULL),
- m_ui(NULL),
- m_tilemap(NULL),
- m_debug_view(NULL),
m_current_phase(MACHINE_PHASE_PREINIT),
m_paused(false),
m_hard_reset_pending(false),
@@ -139,11 +132,9 @@ running_machine::running_machine(const machine_config &_config, osd_interface &o
m_ui_active(_config.options().ui_active()),
m_basename(_config.gamedrv().name),
m_sample_rate(_config.options().sample_rate()),
- m_logfile(NULL),
m_saveload_schedule(SLS_NONE),
m_saveload_schedule_time(attotime::zero),
m_saveload_searchpath(NULL),
- m_logerror_list(m_respool),
m_save(*this),
m_memory(*this),
@@ -225,9 +216,9 @@ void running_machine::start()
{
// initialize basic can't-fail systems here
config_init(*this);
- m_input = auto_alloc(*this, input_manager(*this));
+ m_input.reset(global_alloc(input_manager(*this)));
output_init(*this);
- m_render = auto_alloc(*this, render_manager(*this));
+ m_render.reset(global_alloc(render_manager(*this)));
generic_machine_init(*this);
// allocate a soft_reset timer
@@ -237,8 +228,8 @@ void running_machine::start()
m_osd.init(*this);
// create the video manager
- m_video = auto_alloc(*this, video_manager(*this));
- m_ui = auto_alloc(*this, ui_manager(*this));
+ m_video.reset(global_alloc(video_manager(*this)));
+ m_ui.reset(global_alloc(ui_manager(*this)));
// initialize the base time (needed for doing record/playback)
::time(&m_base_time);
@@ -254,7 +245,7 @@ void running_machine::start()
ui_input_init(*this);
// initialize the streams engine before the sound devices start
- m_sound = auto_alloc(*this, sound_manager(*this));
+ m_sound.reset(global_alloc(sound_manager(*this)));
// first load ROMs, then populate memory, and finally initialize CPUs
// these operations must proceed in this order
@@ -270,7 +261,7 @@ void running_machine::start()
// initialize image devices
image_init(*this);
- m_tilemap = auto_alloc(*this, tilemap_manager(*this));
+ m_tilemap.reset(global_alloc(tilemap_manager(*this)));
crosshair_init(*this);
network_init(*this);
@@ -300,7 +291,7 @@ void running_machine::start()
schedule_load("auto");
// set up the cheat engine
- m_cheat = auto_alloc(*this, cheat_manager(*this));
+ m_cheat.reset(global_alloc(cheat_manager(*this)));
// allocate autoboot timer
m_autoboot_timer = scheduler().timer_alloc(timer_expired_delegate(FUNC(running_machine::autoboot_callback), this));
@@ -348,7 +339,7 @@ int running_machine::run(bool firstrun)
// if we have a logfile, set up the callback
if (options().log())
{
- m_logfile = auto_alloc(*this, emu_file(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
+ m_logfile.reset(global_alloc(emu_file(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)));
file_error filerr = m_logfile->open("error.log");
assert_always(filerr == FILERR_NONE, "unable to open log file");
add_logerror_callback(logfile_callback);
@@ -442,7 +433,7 @@ int running_machine::run(bool firstrun)
zip_file_cache_clear();
// close the logfile
- auto_free(*this, m_logfile);
+ m_logfile.reset();
return error;
}
@@ -784,7 +775,7 @@ void running_machine::add_notifier(machine_notification event, machine_notify_de
void running_machine::add_logerror_callback(logerror_callback callback)
{
assert_always(m_current_phase == MACHINE_PHASE_INIT, "Can only call add_logerror_callback at init time!");
- m_logerror_list.append(*auto_alloc(*this, logerror_callback_item(callback)));
+ m_logerror_list.append(*global_alloc(logerror_callback_item(callback)));
}
@@ -1149,9 +1140,6 @@ void running_machine::stop_all_devices()
device_iterator iter(root_device());
for (device_t *device = iter.first(); device != NULL; device = iter.next())
device->stop();
-
- // then nuke the device tree
-// global_free(m_root_device);
}
diff --git a/src/emu/machine.h b/src/emu/machine.h
index 62b64295d4b..81657587965 100644
--- a/src/emu/machine.h
+++ b/src/emu/machine.h
@@ -104,7 +104,6 @@ const int DEBUG_FLAG_OSD_ENABLED = 0x00001000; // The OSD debugger is e
#define auto_bitmap_ind16_alloc(m, w, h) auto_alloc(m, bitmap_ind16(w, h))
#define auto_bitmap_ind32_alloc(m, w, h) auto_alloc(m, bitmap_ind32(w, h))
#define auto_bitmap_rgb32_alloc(m, w, h) auto_alloc(m, bitmap_rgb32(w, h))
-#define auto_strdup(m, s) strcpy(auto_alloc_array(m, char, strlen(s) + 1), s)
@@ -311,14 +310,14 @@ private:
osd_interface & m_osd; // reference to OSD system
// managers
- cheat_manager * m_cheat; // internal data from cheat.c
- render_manager * m_render; // internal data from render.c
- input_manager * m_input; // internal data from input.c
- sound_manager * m_sound; // internal data from sound.c
- video_manager * m_video; // internal data from video.c
- ui_manager * m_ui; // internal data from ui.c
- tilemap_manager * m_tilemap; // internal data from tilemap.c
- debug_view_manager * m_debug_view; // internal data from debugvw.c
+ auto_pointer<cheat_manager> m_cheat; // internal data from cheat.c
+ auto_pointer<render_manager> m_render; // internal data from render.c
+ auto_pointer<input_manager> m_input; // internal data from input.c
+ auto_pointer<sound_manager> m_sound; // internal data from sound.c
+ auto_pointer<video_manager> m_video; // internal data from video.c
+ auto_pointer<ui_manager> m_ui; // internal data from ui.c
+ auto_pointer<tilemap_manager> m_tilemap; // internal data from tilemap.c
+ auto_pointer<debug_view_manager> m_debug_view; // internal data from debugvw.c
// system state
machine_phase m_current_phase; // current execution phase
@@ -341,7 +340,7 @@ private:
astring m_basename; // basename used for game-related paths
astring m_context; // context string buffer
int m_sample_rate; // the digital audio sample rate
- emu_file * m_logfile; // pointer to the active log file
+ auto_pointer<emu_file> m_logfile; // pointer to the active log file
// load/save management
enum saveload_schedule
diff --git a/src/emu/machine/68681.c b/src/emu/machine/68681.c
index 3e489728c87..78d9b4e5d10 100644
--- a/src/emu/machine/68681.c
+++ b/src/emu/machine/68681.c
@@ -912,6 +912,11 @@ duart68681_device::duart68681_device(const machine_config &mconfig, const char *
m_token = global_alloc_clear(duart68681_state);
}
+duart68681_device::~duart68681_device()
+{
+ global_free(m_token);
+}
+
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
diff --git a/src/emu/machine/68681.h b/src/emu/machine/68681.h
index 4e4eb208586..5327e82986d 100644
--- a/src/emu/machine/68681.h
+++ b/src/emu/machine/68681.h
@@ -16,10 +16,10 @@ class duart68681_device : public device_t
{
public:
duart68681_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~duart68681_device() { global_free(m_token); }
+ ~duart68681_device();
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct duart68681_state *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
virtual void device_config_complete();
@@ -27,7 +27,7 @@ protected:
virtual void device_reset();
private:
// internal state
- void *m_token;
+ struct duart68681_state *m_token;
};
extern ATTR_DEPRECATED const device_type DUART68681;
diff --git a/src/emu/machine/intelfsh.c b/src/emu/machine/intelfsh.c
index b77f38ea9f8..33f3a146a0a 100644
--- a/src/emu/machine/intelfsh.c
+++ b/src/emu/machine/intelfsh.c
@@ -496,11 +496,10 @@ void intelfsh_device::nvram_default()
void intelfsh_device::nvram_read(emu_file &file)
{
- UINT8 *buffer = global_alloc_array(UINT8, m_size);
+ dynamic_buffer buffer(m_size);
file.read(buffer, m_size);
for (int byte = 0; byte < m_size; byte++)
m_addrspace[0]->write_byte(byte, buffer[byte]);
- global_free(buffer);
}
@@ -511,11 +510,10 @@ void intelfsh_device::nvram_read(emu_file &file)
void intelfsh_device::nvram_write(emu_file &file)
{
- UINT8 *buffer = global_alloc_array(UINT8, m_size);
+ dynamic_buffer buffer(m_size);
for (int byte = 0; byte < m_size; byte++)
buffer[byte] = m_addrspace[0]->read_byte(byte);
file.write(buffer, m_size);
- global_free(buffer);
}
diff --git a/src/emu/machine/latch8.c b/src/emu/machine/latch8.c
index c4a977828e6..fcd7b2e32b2 100644
--- a/src/emu/machine/latch8.c
+++ b/src/emu/machine/latch8.c
@@ -241,6 +241,11 @@ latch8_device::latch8_device(const machine_config &mconfig, const char *tag, dev
memset((void*)&m_inline_config,0,sizeof(m_inline_config));
}
+latch8_device::~latch8_device()
+{
+ global_free(m_token);
+}
+
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
diff --git a/src/emu/machine/latch8.h b/src/emu/machine/latch8.h
index c35c90d0453..3ee52e5ac8d 100644
--- a/src/emu/machine/latch8.h
+++ b/src/emu/machine/latch8.h
@@ -44,10 +44,10 @@ class latch8_device : public device_t
{
public:
latch8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~latch8_device() { global_free(m_token); }
+ ~latch8_device();
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct latch8_t *token() const { assert(m_token != NULL); return m_token; }
latch8_config m_inline_config;
void set_maskout(UINT32 maskout) { m_inline_config.maskout = maskout; }
@@ -73,7 +73,7 @@ protected:
virtual void device_reset();
private:
// internal state
- void *m_token;
+ struct latch8_t *m_token;
};
extern const device_type LATCH8;
diff --git a/src/emu/machine/nscsi_s1410.c b/src/emu/machine/nscsi_s1410.c
index d3f3defd95e..ce9db745f45 100644
--- a/src/emu/machine/nscsi_s1410.c
+++ b/src/emu/machine/nscsi_s1410.c
@@ -58,7 +58,7 @@ void nscsi_s1410_device::scsi_command()
blocks = (bytes_per_sector == 256) ? 32 : 17;
int track_length = blocks*bytes_per_sector;
- UINT8 *data = global_alloc_array(UINT8,track_length);
+ dynamic_buffer data(track_length);
memset(data, 0xc6, track_length);
if(!hard_disk_write(harddisk, lba, data)) {
@@ -67,7 +67,6 @@ void nscsi_s1410_device::scsi_command()
} else {
scsi_status_complete(SS_GOOD);
}
- global_free(data);
}
break;
diff --git a/src/emu/machine/s3c2400.c b/src/emu/machine/s3c2400.c
index 3256be60d1a..1e0ee2a69ec 100644
--- a/src/emu/machine/s3c2400.c
+++ b/src/emu/machine/s3c2400.c
@@ -76,6 +76,11 @@ s3c2400_device::s3c2400_device(const machine_config &mconfig, const char *tag, d
m_token = global_alloc_clear(s3c24xx_t);
}
+s3c2400_device::~s3c2400_device()
+{
+ global_free(m_token);
+}
+
//-------------------------------------------------
// static_set_palette_tag: Set the tag of the
// palette device
diff --git a/src/emu/machine/s3c2400.h b/src/emu/machine/s3c2400.h
index ec27282b86d..cf33e3d2d52 100644
--- a/src/emu/machine/s3c2400.h
+++ b/src/emu/machine/s3c2400.h
@@ -37,13 +37,13 @@ class s3c2400_device : public device_t
{
public:
s3c2400_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~s3c2400_device() { global_free(m_token); }
+ ~s3c2400_device();
// static configuration
static void static_set_palette_tag(device_t &device, const char *tag);
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct s3c24xx_t *token() const { assert(m_token != NULL); return m_token; }
// device-level overrides
virtual void device_config_complete();
@@ -51,7 +51,7 @@ public:
virtual void device_reset();
private:
// internal state
- void *m_token;
+ struct s3c24xx_t *m_token;
required_device<palette_device> m_palette;
public:
UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
diff --git a/src/emu/machine/s3c2410.c b/src/emu/machine/s3c2410.c
index 774077f8bcf..fee3f06b845 100644
--- a/src/emu/machine/s3c2410.c
+++ b/src/emu/machine/s3c2410.c
@@ -79,6 +79,11 @@ s3c2410_device::s3c2410_device(const machine_config &mconfig, const char *tag, d
m_token = global_alloc_clear(s3c24xx_t);
}
+s3c2410_device::~s3c2410_device()
+{
+ global_free(m_token);
+}
+
//-------------------------------------------------
// static_set_palette_tag: Set the tag of the
// palette device
diff --git a/src/emu/machine/s3c2410.h b/src/emu/machine/s3c2410.h
index 139dad06cc1..f418c388971 100644
--- a/src/emu/machine/s3c2410.h
+++ b/src/emu/machine/s3c2410.h
@@ -45,20 +45,20 @@ class s3c2410_device : public device_t
{
public:
s3c2410_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~s3c2410_device() { global_free(m_token); }
+ ~s3c2410_device();
// static configuration
static void static_set_palette_tag(device_t &device, const char *tag);
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct s3c24xx_t *token() const { assert(m_token != NULL); return m_token; }
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
private:
// internal state
- void *m_token;
+ struct s3c24xx_t *m_token;
required_device<palette_device> m_palette;
public:
UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
diff --git a/src/emu/machine/s3c2440.c b/src/emu/machine/s3c2440.c
index 7019ce89bf8..e0425c9f3fc 100644
--- a/src/emu/machine/s3c2440.c
+++ b/src/emu/machine/s3c2440.c
@@ -81,6 +81,11 @@ s3c2440_device::s3c2440_device(const machine_config &mconfig, const char *tag, d
m_token = global_alloc_clear(s3c24xx_t);
}
+s3c2440_device::~s3c2440_device()
+{
+ global_free(m_token);
+}
+
//-------------------------------------------------
// static_set_palette_tag: Set the tag of the
// palette device
diff --git a/src/emu/machine/s3c2440.h b/src/emu/machine/s3c2440.h
index ebb8f087e6d..901ddd790f1 100644
--- a/src/emu/machine/s3c2440.h
+++ b/src/emu/machine/s3c2440.h
@@ -45,13 +45,13 @@ class s3c2440_device : public device_t
{
public:
s3c2440_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~s3c2440_device() { global_free(m_token); }
+ ~s3c2440_device();
// static configuration
static void static_set_palette_tag(device_t &device, const char *tag);
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct s3c24xx_t *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
virtual void device_config_complete();
@@ -59,7 +59,7 @@ protected:
virtual void device_reset();
private:
// internal state
- void *m_token;
+ struct s3c24xx_t *m_token;
required_device<palette_device> m_palette;
public:
UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
diff --git a/src/emu/machine/tc009xlvc.c b/src/emu/machine/tc009xlvc.c
index 5d14d701b8b..e1ef19afab9 100644
--- a/src/emu/machine/tc009xlvc.c
+++ b/src/emu/machine/tc009xlvc.c
@@ -294,7 +294,7 @@ void tc0091lvc_device::device_start()
//printf("m_gfx_index %d\n", m_gfx_index);
- m_gfxdecode->set_gfx(m_gfx_index, auto_alloc(machine(), gfx_element(m_palette, char_layout, (UINT8 *)m_pcg_ram, m_palette->entries() / 16, 0)));
+ m_gfxdecode->set_gfx(m_gfx_index, global_alloc(gfx_element(m_palette, char_layout, (UINT8 *)m_pcg_ram, m_palette->entries() / 16, 0)));
}
void tc0091lvc_device::device_reset()
diff --git a/src/emu/machine/wd17xx.c b/src/emu/machine/wd17xx.c
index a52af7f5e26..f639803deb6 100644
--- a/src/emu/machine/wd17xx.c
+++ b/src/emu/machine/wd17xx.c
@@ -2254,6 +2254,11 @@ wd1770_device::wd1770_device(const machine_config &mconfig, device_type type, co
m_token = global_alloc_clear(wd1770_state);
}
+wd1770_device::~wd1770_device()
+{
+ global_free(m_token);
+}
+
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
diff --git a/src/emu/machine/wd17xx.h b/src/emu/machine/wd17xx.h
index f25bde784a9..8b41f4c5fbb 100644
--- a/src/emu/machine/wd17xx.h
+++ b/src/emu/machine/wd17xx.h
@@ -20,10 +20,10 @@ class wd1770_device : public device_t
public:
wd1770_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
wd1770_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- ~wd1770_device() { global_free(m_token); }
+ virtual ~wd1770_device();
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct wd1770_state *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
virtual void device_config_complete();
@@ -31,7 +31,7 @@ protected:
virtual void device_reset();
private:
// internal state
- void *m_token;
+ struct wd1770_state *m_token;
};
extern const device_type WD1770;
diff --git a/src/emu/mame.c b/src/emu/mame.c
index 2e00575159d..ab55609f2e2 100644
--- a/src/emu/mame.c
+++ b/src/emu/mame.c
@@ -170,6 +170,7 @@ int mame_execute(emu_options &options, osd_interface &osd)
astring errors;
options.parse_standard_inis(errors);
}
+
// otherwise, perform validity checks before anything else
if (system != NULL)
{
@@ -188,6 +189,7 @@ int mame_execute(emu_options &options, osd_interface &osd)
web.set_machine(machine);
web.push_message("update_machine");
+
// run the machine
error = machine.run(firstrun);
firstrun = false;
diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c
index 1ea7808ce7b..2dab4ad964d 100644
--- a/src/emu/mconfig.c
+++ b/src/emu/mconfig.c
@@ -29,8 +29,7 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
m_memcard_handler(NULL),
m_default_layout(NULL),
m_gamedrv(gamedrv),
- m_options(options),
- m_root_device(NULL)
+ m_options(options)
{
// construct the config
(*gamedrv.machine_config)(*this, NULL, NULL);
@@ -89,7 +88,6 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
machine_config::~machine_config()
{
- global_free(m_root_device);
}
@@ -145,7 +143,7 @@ device_t *machine_config::device_add(device_t *owner, const char *tag, device_ty
// otherwise, allocate the device directly
assert(m_root_device == NULL);
- m_root_device = (*type)(*this, tag, owner, clock);
+ m_root_device.reset((*type)(*this, tag, owner, clock));
// apply any machine configuration owned by the device now
machine_config_constructor additions = m_root_device->machine_config_additions();
diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h
index e82d9a1dcad..e37466e737d 100644
--- a/src/emu/mconfig.h
+++ b/src/emu/mconfig.h
@@ -103,7 +103,7 @@ private:
// internal state
const game_driver & m_gamedrv;
emu_options & m_options;
- device_t * m_root_device;
+ auto_pointer<device_t> m_root_device;
};
diff --git a/src/emu/memory.c b/src/emu/memory.c
index 0b19dc94120..ac5a29068d9 100644
--- a/src/emu/memory.c
+++ b/src/emu/memory.c
@@ -772,7 +772,7 @@ private:
}
// internal state
- handler_entry_read * m_handlers[TOTAL_MEMORY_BANKS]; // array of user-installed handlers
+ auto_pointer<handler_entry_read> m_handlers[TOTAL_MEMORY_BANKS]; // array of user-installed handlers
};
@@ -838,7 +838,7 @@ private:
}
// internal state
- handler_entry_write * m_handlers[TOTAL_MEMORY_BANKS]; // array of user-installed handlers
+ auto_pointer<handler_entry_write> m_handlers[TOTAL_MEMORY_BANKS]; // array of user-installed handlers
};
// ======================> address_table_setoffset
@@ -852,9 +852,7 @@ public:
{
// allocate handlers for each entry, prepopulating the bankptrs for banks
for (int entrynum = 0; entrynum < ARRAY_LENGTH(m_handlers); entrynum++)
- {
- m_handlers[entrynum] = auto_alloc(space.machine(), handler_entry_setoffset());
- }
+ m_handlers[entrynum].reset(global_alloc(handler_entry_setoffset()));
// Watchpoints and unmap states do not make sense for setoffset
m_handlers[STATIC_NOP]->set_delegate(setoffset_delegate(FUNC(address_table_setoffset::nop_so), this));
@@ -863,8 +861,6 @@ public:
~address_table_setoffset()
{
- for (int handnum = 0; handnum < ARRAY_LENGTH(m_handlers); handnum++)
- auto_free(m_space.machine(), m_handlers[handnum]);
}
handler_entry &handler(UINT32 index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; }
@@ -892,7 +888,7 @@ private:
}
// internal state
- handler_entry_setoffset *m_handlers[TOTAL_MEMORY_BANKS]; // array of user-installed handlers
+ auto_pointer<handler_entry_setoffset> m_handlers[TOTAL_MEMORY_BANKS]; // array of user-installed handlers
};
@@ -1723,7 +1719,6 @@ address_space::address_space(memory_manager &manager, device_memory_interface &m
: m_next(NULL),
m_config(*memory.space_config(spacenum)),
m_device(memory.device()),
- m_map(NULL),
m_addrmask(0xffffffffUL >> (32 - m_config.m_addrbus_width)),
m_bytemask(address_to_byte_end(m_addrmask)),
m_logaddrmask(0xffffffffUL >> (32 - m_config.m_logaddr_width)),
@@ -1732,7 +1727,7 @@ address_space::address_space(memory_manager &manager, device_memory_interface &m
m_spacenum(spacenum),
m_debugger_access(false),
m_log_unmap(true),
- m_direct(*auto_alloc(memory.device().machine(), direct_read_data(*this))),
+ m_direct(global_alloc(direct_read_data(*this))),
m_name(memory.space_config(spacenum)->name()),
m_addrchars((m_config.m_addrbus_width + 3) / 4),
m_logaddrchars((m_config.m_logaddr_width + 3) / 4),
@@ -1750,8 +1745,6 @@ address_space::address_space(memory_manager &manager, device_memory_interface &m
address_space::~address_space()
{
- auto_free(m_manager.machine(), &m_direct);
- global_free(m_map);
}
@@ -1869,7 +1862,7 @@ void address_space::prepare_map()
UINT32 devregionsize = (devregion != NULL) ? devregion->bytes() : 0;
// allocate the address map
- m_map = global_alloc(address_map(m_device, m_spacenum));
+ m_map.reset(global_alloc(address_map(m_device, m_spacenum)));
// merge in the submaps
m_map->uplift_submaps(machine(), m_device, *m_device.owner(), endianness());
@@ -1900,7 +1893,7 @@ void address_space::prepare_map()
if (manager().m_sharelist.find(device().siblingtag(fulltag, entry->m_share).cstr()) == NULL)
{
VPRINTF(("Creating share '%s' of length 0x%X\n", fulltag.cstr(), entry->m_byteend + 1 - entry->m_bytestart));
- memory_share *share = auto_alloc(machine(), memory_share(m_map->m_databits, entry->m_byteend + 1 - entry->m_bytestart, endianness()));
+ memory_share *share = global_alloc(memory_share(m_map->m_databits, entry->m_byteend + 1 - entry->m_bytestart, endianness()));
manager().m_sharelist.append(fulltag, *share);
}
}
@@ -2963,7 +2956,7 @@ void address_table::map_range(offs_t addrstart, offs_t addrend, offs_t addrmask,
populate_range_mirrored(bytestart, byteend, bytemirror, entry);
// recompute any direct access on this space if it is a read modification
- m_space.m_direct.force_update(entry);
+ m_space.m_direct->force_update(entry);
// verify_reference_counts();
}
@@ -3089,7 +3082,7 @@ void address_table::setup_range_masked(offs_t addrstart, offs_t addrend, offs_t
entries.push_back(entry);
// recompute any direct access on this space if it is a read modification
- m_space.m_direct.force_update(entry);
+ m_space.m_direct->force_update(entry);
}
// Ranges in range_partial must duplicated then partially changed
@@ -3132,7 +3125,7 @@ void address_table::setup_range_masked(offs_t addrstart, offs_t addrend, offs_t
entries.push_back(entry);
// recompute any direct access on this space if it is a read modification
- m_space.m_direct.force_update(entry);
+ m_space.m_direct->force_update(entry);
}
}
@@ -3310,7 +3303,7 @@ void address_table::populate_range_mirrored(offs_t bytestart, offs_t byteend, of
for (int bit = 0; bit < lmirrorbits; bit++)
if (lmirrorcount & (1 << bit))
lmirrorbase |= lmirrorbit[bit];
- m_space.m_direct.remove_intersecting_ranges(bytestart + lmirrorbase, byteend + lmirrorbase);
+ m_space.m_direct->remove_intersecting_ranges(bytestart + lmirrorbase, byteend + lmirrorbase);
}
// if this is not our first time through, and the level 2 entry matches the previous
@@ -3752,7 +3745,7 @@ address_table_read::address_table_read(address_space &space, bool large)
for (int entrynum = 0; entrynum < ARRAY_LENGTH(m_handlers); entrynum++)
{
UINT8 **bankptr = (entrynum >= STATIC_BANK1 && entrynum <= STATIC_BANKMAX) ? space.manager().bank_pointer_addr(entrynum) : NULL;
- m_handlers[entrynum] = auto_alloc(space.machine(), handler_entry_read(space.data_width(), space.endianness(), bankptr));
+ m_handlers[entrynum].reset(global_alloc(handler_entry_read(space.data_width(), space.endianness(), bankptr)));
}
// we have to allocate different object types based on the data bus width
@@ -3800,8 +3793,6 @@ address_table_read::address_table_read(address_space &space, bool large)
address_table_read::~address_table_read()
{
- for (int handnum = 0; handnum < ARRAY_LENGTH(m_handlers); handnum++)
- auto_free(m_space.machine(), m_handlers[handnum]);
}
@@ -3828,7 +3819,7 @@ address_table_write::address_table_write(address_space &space, bool large)
for (int entrynum = 0; entrynum < ARRAY_LENGTH(m_handlers); entrynum++)
{
UINT8 **bankptr = (entrynum >= STATIC_BANK1 && entrynum <= STATIC_BANKMAX) ? space.manager().bank_pointer_addr(entrynum) : NULL;
- m_handlers[entrynum] = auto_alloc(space.machine(), handler_entry_write(space.data_width(), space.endianness(), bankptr));
+ m_handlers[entrynum].reset(global_alloc(handler_entry_write(space.data_width(), space.endianness(), bankptr)));
}
// we have to allocate different object types based on the data bus width
@@ -3876,8 +3867,6 @@ address_table_write::address_table_write(address_space &space, bool large)
address_table_write::~address_table_write()
{
- for (int handnum = 0; handnum < ARRAY_LENGTH(m_handlers); handnum++)
- auto_free(m_space.machine(), m_handlers[handnum]);
}
@@ -3993,7 +3982,7 @@ direct_read_data::direct_range *direct_read_data::find_range(offs_t byteaddress,
if (range != NULL)
m_freerangelist.detach(*range);
else
- range = auto_alloc(m_space.machine(), direct_range);
+ range = global_alloc(direct_range);
// fill in the range
m_space.read().derive_range(byteaddress, range->m_bytestart, range->m_byteend);
@@ -4168,7 +4157,6 @@ memory_bank::memory_bank(address_space &space, int index, offs_t bytestart, offs
memory_bank::~memory_bank()
{
- auto_free(machine(), m_entry);
}
diff --git a/src/emu/memory.h b/src/emu/memory.h
index da956d4975f..5f72db81e9a 100644
--- a/src/emu/memory.h
+++ b/src/emu/memory.h
@@ -303,7 +303,7 @@ public:
address_spacenum spacenum() const { return m_spacenum; }
address_map *map() const { return m_map; }
- direct_read_data &direct() const { return m_direct; }
+ direct_read_data &direct() const { return *m_direct; }
int data_width() const { return m_config.data_width(); }
int addr_width() const { return m_config.addr_width(); }
@@ -377,7 +377,7 @@ public:
void set_decrypted_region(offs_t addrstart, offs_t addrend, void *base);
// direct access
- direct_update_delegate set_direct_update_handler(direct_update_delegate function) { return m_direct.set_direct_update(function); }
+ direct_update_delegate set_direct_update_handler(direct_update_delegate function) { return m_direct->set_direct_update(function); }
bool set_direct_region(offs_t &byteaddress);
// umap ranges (short form)
@@ -543,7 +543,7 @@ protected:
address_space * m_next; // next address space in the global list
const address_space_config &m_config; // configuration of this space
device_t & m_device; // reference to the owning device
- address_map * m_map; // original memory map
+ auto_pointer<address_map> m_map; // original memory map
offs_t m_addrmask; // physical address mask
offs_t m_bytemask; // byte-converted physical address mask
offs_t m_logaddrmask; // logical address mask
@@ -552,7 +552,7 @@ protected:
address_spacenum m_spacenum; // address space index
bool m_debugger_access; // treat accesses as coming from the debugger
bool m_log_unmap; // log unmapped accesses in this space?
- direct_read_data & m_direct; // fast direct-access read info
+ auto_pointer<direct_read_data> m_direct; // fast direct-access read info
const char * m_name; // friendly name of the address space
UINT8 m_addrchars; // number of characters to use for physical addresses
UINT8 m_logaddrchars; // number of characters to use for logical addresses
diff --git a/src/emu/output.c b/src/emu/output.c
index 363cd1180d1..05fb234b150 100644
--- a/src/emu/output.c
+++ b/src/emu/output.c
@@ -26,22 +26,30 @@
TYPE DEFINITIONS
***************************************************************************/
-struct output_notify
+class output_notify
{
- output_notify * next; /* link to next item */
- output_notifier_func notifier; /* callback to call */
- void * param; /* parameter to pass the callback */
+public:
+ output_notify(output_notifier_func callback, void *param)
+ : m_next(NULL),
+ m_notifier(callback),
+ m_param(param) { }
+
+ output_notify *next() const { return m_next; }
+
+ output_notify * m_next; /* link to next item */
+ output_notifier_func m_notifier; /* callback to call */
+ void * m_param; /* parameter to pass the callback */
};
struct output_item
{
output_item * next; /* next item in list */
- const char * name; /* string name of the item */
+ astring name; /* string name of the item */
UINT32 hash; /* hash for this item name */
UINT32 id; /* unique ID for this item */
INT32 value; /* current value */
- output_notify * notifylist; /* list of notifier callbacks */
+ simple_list<output_notify> notifylist; /* list of notifier callbacks */
};
@@ -51,7 +59,7 @@ struct output_item
***************************************************************************/
static output_item *itemtable[HASH_SIZE];
-static output_notify *global_notifylist;
+static simple_list<output_notify> global_notifylist;
static UINT32 uniqueid = 12345;
@@ -121,11 +129,10 @@ INLINE output_item *create_new_item(const char *outname, INT32 value)
/* fill in the data */
item->next = itemtable[hash % HASH_SIZE];
- item->name = copy_string(outname);
+ item->name.cpy(outname);
item->hash = hash;
item->id = uniqueid++;
item->value = value;
- item->notifylist = NULL;
/* add us to the hash table */
itemtable[hash % HASH_SIZE] = item;
@@ -153,7 +160,7 @@ void output_init(running_machine &machine)
/* reset the lists */
memset(itemtable, 0, sizeof(itemtable));
- global_notifylist = NULL;
+ global_notifylist.reset();
}
@@ -178,7 +185,6 @@ static void output_resume(running_machine &machine)
static void output_exit(running_machine &machine)
{
- output_notify *notify;
output_item *item;
int hash;
@@ -188,28 +194,13 @@ static void output_exit(running_machine &machine)
{
output_item *next = item->next;
- /* remove all notifiers */
- for (notify = item->notifylist; notify != NULL; )
- {
- output_notify *next_notify = notify->next;
- global_free(notify);
- notify = next_notify;
- }
-
/* free the name and the item */
- if (item->name != NULL)
- global_free(item->name);
global_free(item);
item = next;
}
/* remove all global notifiers */
- for (notify = global_notifylist; notify != NULL; )
- {
- output_notify *next = notify->next;
- global_free(notify);
- notify = next;
- }
+ global_notifylist.reset();
}
@@ -220,7 +211,6 @@ static void output_exit(running_machine &machine)
void output_set_value(const char *outname, INT32 value)
{
output_item *item = find_item(outname);
- output_notify *notify;
INT32 oldval;
/* if no item of that name, create a new one and send the item's state */
@@ -241,12 +231,12 @@ void output_set_value(const char *outname, INT32 value)
if (oldval != value)
{
/* call the local notifiers first */
- for (notify = item->notifylist; notify != NULL; notify = notify->next)
- (*notify->notifier)(outname, value, notify->param);
+ for (output_notify *notify = item->notifylist.first(); notify != NULL; notify = notify->next())
+ (*notify->m_notifier)(outname, value, notify->m_param);
/* call the global notifiers next */
- for (notify = global_notifylist; notify != NULL; notify = notify->next)
- (*notify->notifier)(outname, value, notify->param);
+ for (output_notify *notify = global_notifylist.first(); notify != NULL; notify = notify->next())
+ (*notify->m_notifier)(outname, value, notify->m_param);
}
}
@@ -327,8 +317,6 @@ INT32 output_get_indexed_value(const char *basename, int index)
void output_set_notifier(const char *outname, output_notifier_func callback, void *param)
{
- output_notify **headptr;
-
/* if an item is specified, find it */
if (outname != NULL)
{
@@ -337,22 +325,10 @@ void output_set_notifier(const char *outname, output_notifier_func callback, voi
/* if no item of that name, create a new one */
if (item == NULL)
item = create_new_item(outname, 0);
- headptr = &item->notifylist;
+ item->notifylist.append(*global_alloc(output_notify(callback, param)));
}
-
- /* if no item is specified, we add to the global list */
else
- headptr = &global_notifylist;
-
- /* find the end of the list and add to it */
- while (*headptr != NULL)
- headptr = &(*headptr)->next;
- *headptr = global_alloc(output_notify);
-
- /* fill in the new record */
- (*headptr)->next = NULL;
- (*headptr)->notifier = callback;
- (*headptr)->param = param;
+ global_notifylist.append(*global_alloc(output_notify(callback, param)));
}
diff --git a/src/emu/render.c b/src/emu/render.c
index 97bff87b72f..9bdda5219c7 100644
--- a/src/emu/render.c
+++ b/src/emu/render.c
@@ -381,7 +381,7 @@ void render_texture::release()
for (int scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
{
m_manager->invalidate_all(m_scaled[scalenum].bitmap);
- auto_free(m_manager->machine(), m_scaled[scalenum].bitmap);
+ global_free(m_scaled[scalenum].bitmap);
m_scaled[scalenum].bitmap = NULL;
m_scaled[scalenum].seqid = 0;
}
@@ -422,7 +422,7 @@ void render_texture::set_bitmap(bitmap_t &bitmap, const rectangle &sbounds, text
if (m_scaled[scalenum].bitmap != NULL)
{
m_manager->invalidate_all(m_scaled[scalenum].bitmap);
- auto_free(m_manager->machine(), m_scaled[scalenum].bitmap);
+ global_free(m_scaled[scalenum].bitmap);
}
m_scaled[scalenum].bitmap = NULL;
m_scaled[scalenum].seqid = 0;
@@ -506,11 +506,11 @@ bool render_texture::get_scaled(UINT32 dwidth, UINT32 dheight, render_texinfo &t
if (scaled->bitmap != NULL)
{
m_manager->invalidate_all(scaled->bitmap);
- auto_free(m_manager->machine(), scaled->bitmap);
+ global_free(scaled->bitmap);
}
// allocate a new bitmap
- scaled->bitmap = auto_alloc(m_manager->machine(), bitmap_argb32(dwidth, dheight));
+ scaled->bitmap = global_alloc(bitmap_argb32(dwidth, dheight));
scaled->seqid = ++m_curseq;
// let the scaler do the work
@@ -597,12 +597,9 @@ const rgb_t *render_texture::get_adjusted_palette(render_container &container)
render_container::render_container(render_manager &manager, screen_device *screen)
: m_next(NULL),
m_manager(manager),
- m_itemlist(manager.machine().respool()),
- m_item_allocator(manager.machine().respool()),
m_screen(screen),
m_overlaybitmap(NULL),
- m_overlaytexture(NULL),
- m_palclient(NULL)
+ m_overlaytexture(NULL)
{
// all palette entries are opaque by default
for (int color = 0; color < ARRAY_LENGTH(m_bcglookup); color++)
@@ -621,7 +618,7 @@ render_container::render_container(render_manager &manager, screen_device *scree
m_user.m_gamma = manager.machine().options().gamma();
// allocate a client to the main palette
if (m_screen->palette() != NULL)
- m_palclient = global_alloc(palette_client(*m_screen->palette()->palette()));
+ m_palclient.reset(global_alloc(palette_client(*m_screen->palette()->palette())));
}
recompute_lookups();
@@ -639,9 +636,6 @@ render_container::~render_container()
// free the overlay texture
m_manager.texture_free(m_overlaytexture);
-
- // release our palette client
- global_free(m_palclient);
}
@@ -932,7 +926,6 @@ render_target::render_target(render_manager &manager, const char *layoutfile, UI
: m_next(NULL),
m_manager(manager),
m_curview(NULL),
- m_filelist(*auto_alloc(manager.machine(), simple_list<layout_file>(manager.machine().respool()))),
m_flags(flags),
m_listindex(0),
m_width(640),
@@ -943,8 +936,7 @@ render_target::render_target(render_manager &manager, const char *layoutfile, UI
m_base_view(NULL),
m_base_orientation(ROT0),
m_maxtexwidth(65536),
- m_maxtexheight(65536),
- m_debug_containers(manager.machine().respool())
+ m_maxtexheight(65536)
{
// determine the base layer configuration based on options
m_base_layerconfig.set_backdrops_enabled(manager.machine().options().use_backdrops());
@@ -993,7 +985,6 @@ render_target::render_target(render_manager &manager, const char *layoutfile, UI
render_target::~render_target()
{
- auto_free(m_manager.machine(), &m_filelist);
}
@@ -1632,7 +1623,7 @@ bool render_target::load_layout_file(const char *dirname, const char *filename)
bool result = true;
try
{
- m_filelist.append(*auto_alloc(m_manager.machine(), layout_file(m_manager.machine(), *rootnode, dirname)));
+ m_filelist.append(*global_alloc(layout_file(m_manager.machine(), *rootnode, dirname)));
}
catch (emu_fatalerror &err)
{
@@ -2409,12 +2400,9 @@ done:
render_manager::render_manager(running_machine &machine)
: m_machine(machine),
- m_targetlist(machine.respool()),
m_ui_target(NULL),
m_live_textures(0),
- m_texture_allocator(machine.respool()),
- m_ui_container(auto_alloc(machine, render_container(*this))),
- m_screen_container_list(machine.respool())
+ m_ui_container(global_alloc(render_container(*this)))
{
// register callbacks
config_register(machine, "video", config_saveload_delegate(FUNC(render_manager::config_load), this), config_saveload_delegate(FUNC(render_manager::config_save), this));
@@ -2483,7 +2471,7 @@ float render_manager::max_update_rate() const
render_target *render_manager::target_alloc(const char *layoutfile, UINT32 flags)
{
- return &m_targetlist.append(*auto_alloc(machine(), render_target(*this, layoutfile, flags)));
+ return &m_targetlist.append(*global_alloc(render_target(*this, layoutfile, flags)));
}
@@ -2577,7 +2565,7 @@ void render_manager::texture_free(render_texture *texture)
render_font *render_manager::font_alloc(const char *filename)
{
- return auto_alloc(machine(), render_font(*this, filename));
+ return global_alloc(render_font(*this, filename));
}
@@ -2587,7 +2575,7 @@ render_font *render_manager::font_alloc(const char *filename)
void render_manager::font_free(render_font *font)
{
- auto_free(machine(), font);
+ global_free(font);
}
@@ -2614,7 +2602,7 @@ void render_manager::invalidate_all(void *refptr)
render_container *render_manager::container_alloc(screen_device *screen)
{
- render_container *container = auto_alloc(machine(), render_container(*this, screen));
+ render_container *container = global_alloc(render_container(*this, screen));
if (screen != NULL)
m_screen_container_list.append(*container);
return container;
@@ -2627,8 +2615,7 @@ render_container *render_manager::container_alloc(screen_device *screen)
void render_manager::container_free(render_container *container)
{
- m_screen_container_list.detach(*container);
- auto_free(machine(), container);
+ m_screen_container_list.remove(*container);
}
diff --git a/src/emu/render.h b/src/emu/render.h
index 75bea195e95..a0c24ba1868 100644
--- a/src/emu/render.h
+++ b/src/emu/render.h
@@ -246,15 +246,11 @@ class render_screen_list
};
public:
- // construction/destruction
- render_screen_list(resource_pool &pool = global_resource_pool())
- : m_list(pool) { }
-
// getters
int count() const { return m_list.count(); }
// operations
- void add(screen_device &screen) { m_list.append(*pool_alloc(m_list.pool(), item(screen))); }
+ void add(screen_device &screen) { m_list.append(*global_alloc(item(screen))); }
void reset() { m_list.reset(); }
// query
@@ -424,6 +420,7 @@ class render_texture
public:
// getters
int format() const { return m_format; }
+ render_manager *manager() const { return m_manager; }
// configure the texture bitmap
void set_bitmap(bitmap_t &bitmap, const rectangle &sbounds, texture_format format);
@@ -578,7 +575,7 @@ private:
user_settings m_user; // user settings
bitmap_argb32 * m_overlaybitmap; // overlay bitmap
render_texture * m_overlaytexture; // overlay texture
- palette_client * m_palclient; // client to the system palette
+ auto_pointer<palette_client> m_palclient; // client to the system palette
rgb_t m_bcglookup256[0x400]; // lookup table for brightness/contrast/gamma
rgb_t m_bcglookup[0x10000]; // full palette lookup with bcg adjustements
};
@@ -694,7 +691,7 @@ private:
render_target * m_next; // link to next target
render_manager & m_manager; // reference to our owning manager
layout_view * m_curview; // current view
- simple_list<layout_file> &m_filelist; // list of layout files
+ simple_list<layout_file> m_filelist; // list of layout files
UINT32 m_flags; // creation flags
render_primitive_list m_primlist[NUM_PRIMLISTS]; // list of primitives
int m_listindex; // index of next primlist to use
diff --git a/src/emu/rendfont.c b/src/emu/rendfont.c
index 217cff6276e..f6de9822243 100644
--- a/src/emu/rendfont.c
+++ b/src/emu/rendfont.c
@@ -53,9 +53,7 @@ inline render_font::glyph &render_font::get_char(unicode_char chnum)
// grab the table; if none, return the dummy character
if (m_glyphs[chnum / 256].count() == 0 && m_format == FF_OSD)
- {
m_glyphs[chnum / 256].resize(256);
- }
if (m_glyphs[chnum / 256].count() == 0)
return dummy_glyph;
@@ -123,19 +121,12 @@ render_font::~render_font()
{
// free all the subtables
for (int tablenum = 0; tablenum < 256; tablenum++)
- if (m_glyphs[tablenum] != NULL)
+ for (int charnum = 0; charnum < m_glyphs[tablenum].count(); charnum++)
{
- // loop over characters
- for (int charnum = 0; charnum < 256; charnum++)
- {
- glyph &gl = m_glyphs[tablenum][charnum];
- m_manager.texture_free(gl.texture);
- }
+ glyph &gl = m_glyphs[tablenum][charnum];
+ m_manager.texture_free(gl.texture);
}
- // free the raw data and the size itself
- auto_free(m_manager.machine(), m_rawdata);
-
// release the OSD font
if (m_osdfont != NULL)
m_manager.machine().osd().font_close(m_osdfont);
@@ -534,7 +525,7 @@ bool render_font::load_bdf()
}
// make sure all the numbers are the same width
- if (m_glyphs[0] != NULL)
+ if (m_glyphs[0].count() > '9')
{
int maxwidth = 0;
for (int ch = '0'; ch <= '9'; ch++)
diff --git a/src/emu/rendlay.c b/src/emu/rendlay.c
index 9ea4446c8d1..d28322479d2 100644
--- a/src/emu/rendlay.c
+++ b/src/emu/rendlay.c
@@ -402,7 +402,6 @@ static void parse_orientation(running_machine &machine, xml_data_node *orientnod
layout_element::layout_element(running_machine &machine, xml_data_node &elemnode, const char *dirname)
: m_next(NULL),
m_machine(machine),
- m_complist(machine.respool()),
m_defstate(0),
m_maxstate(0)
{
@@ -421,7 +420,7 @@ layout_element::layout_element(running_machine &machine, xml_data_node &elemnode
for (xml_data_node *compnode = elemnode.child; compnode != NULL; compnode = compnode->next)
{
// allocate a new component
- component &newcomp = m_complist.append(*auto_alloc(machine, component(machine, *compnode, dirname)));
+ component &newcomp = m_complist.append(*global_alloc(component(machine, *compnode, dirname)));
// accumulate bounds
if (first)
@@ -571,10 +570,7 @@ layout_element::component::component(running_machine &machine, xml_data_node &co
m_state(0)
{
for (int i=0;i<MAX_BITMAPS;i++)
- {
m_hasalpha[i] = false;
- m_file[i] = NULL;
- }
// fetch common data
m_state = xml_get_attribute_int_with_subst(machine, compnode, "state", -1);
@@ -589,7 +585,7 @@ layout_element::component::component(running_machine &machine, xml_data_node &co
m_dirname = dirname;
m_imagefile[0] = xml_get_attribute_string_with_subst(machine, compnode, "file", "");
m_alphafile[0] = xml_get_attribute_string_with_subst(machine, compnode, "alphafile", "");
- m_file[0] = global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ));
+ m_file[0].reset(global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ)));
}
// text nodes
@@ -657,13 +653,13 @@ layout_element::component::component(running_machine &machine, xml_data_node &co
m_imagefile[i].substr(location+1, m_imagefile[i].len()-(location-1));
//m_alphafile[i] =
- m_file[i] = global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ));
+ m_file[i].reset(global_alloc(emu_file(machine.options().art_path(), OPEN_FLAG_READ)));
}
else
{
//m_imagefile[i] = 0;
//m_alphafile[i] = 0;
- m_file[i] = 0;
+ m_file[i].reset();
}
}
@@ -712,10 +708,6 @@ layout_element::component::component(running_machine &machine, xml_data_node &co
layout_element::component::~component()
{
- for (int i=0;i<MAX_BITMAPS;i++)
- {
- global_free(m_file[i]);
- }
}
@@ -1188,8 +1180,7 @@ void layout_element::component::load_reel_bitmap(int number)
if (!m_bitmap[number].valid())
{
// fallback to text rendering
- global_free(m_file[number]);
- m_file[number] = NULL;
+ m_file[number].reset();
}
}
@@ -1914,14 +1905,7 @@ void layout_element::component::apply_skew(bitmap_argb32 &dest, int skewwidth)
layout_view::layout_view(running_machine &machine, xml_data_node &viewnode, simple_list<layout_element> &elemlist)
: m_next(NULL),
m_aspect(1.0f),
- m_scraspect(1.0f),
- m_screens(machine.respool()),
- m_backdrop_list(machine.respool()),
- m_screen_list(machine.respool()),
- m_overlay_list(machine.respool()),
- m_bezel_list(machine.respool()),
- m_cpanel_list(machine.respool()),
- m_marquee_list(machine.respool())
+ m_scraspect(1.0f)
{
// allocate a copy of the name
m_name = xml_get_attribute_string_with_subst(machine, viewnode, "name", "");
@@ -1934,27 +1918,27 @@ layout_view::layout_view(running_machine &machine, xml_data_node &viewnode, simp
// load backdrop items
for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "backdrop"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "backdrop"))
- m_backdrop_list.append(*auto_alloc(machine, item(machine, *itemnode, elemlist)));
+ m_backdrop_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
// load screen items
for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "screen"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "screen"))
- m_screen_list.append(*auto_alloc(machine, item(machine, *itemnode, elemlist)));
+ m_screen_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
// load overlay items
for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "overlay"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "overlay"))
- m_overlay_list.append(*auto_alloc(machine, item(machine, *itemnode, elemlist)));
+ m_overlay_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
// load bezel items
for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "bezel"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "bezel"))
- m_bezel_list.append(*auto_alloc(machine, item(machine, *itemnode, elemlist)));
+ m_bezel_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
// load cpanel items
for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "cpanel"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "cpanel"))
- m_cpanel_list.append(*auto_alloc(machine, item(machine, *itemnode, elemlist)));
+ m_cpanel_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
// load marquee items
for (xml_data_node *itemnode = xml_get_sibling(viewnode.child, "marquee"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "marquee"))
- m_marquee_list.append(*auto_alloc(machine, item(machine, *itemnode, elemlist)));
+ m_marquee_list.append(*global_alloc(item(machine, *itemnode, elemlist)));
// recompute the data for the view based on a default layer config
recompute(render_layer_config());
@@ -2201,9 +2185,7 @@ int layout_view::item::state() const
//-------------------------------------------------
layout_file::layout_file(running_machine &machine, xml_data_node &rootnode, const char *dirname)
- : m_next(NULL),
- m_elemlist(machine.respool()),
- m_viewlist(machine.respool())
+ : m_next(NULL)
{
// find the layout node
xml_data_node *mamelayoutnode = xml_get_sibling(rootnode.child, "mamelayout");
@@ -2217,11 +2199,11 @@ layout_file::layout_file(running_machine &machine, xml_data_node &rootnode, cons
// parse all the elements
for (xml_data_node *elemnode = xml_get_sibling(mamelayoutnode->child, "element"); elemnode != NULL; elemnode = xml_get_sibling(elemnode->next, "element"))
- m_elemlist.append(*auto_alloc(machine, layout_element(machine, *elemnode, dirname)));
+ m_elemlist.append(*global_alloc(layout_element(machine, *elemnode, dirname)));
// parse all the views
for (xml_data_node *viewnode = xml_get_sibling(mamelayoutnode->child, "view"); viewnode != NULL; viewnode = xml_get_sibling(viewnode->next, "view"))
- m_viewlist.append(*auto_alloc(machine, layout_view(machine, *viewnode, m_elemlist)));
+ m_viewlist.append(*global_alloc(layout_view(machine, *viewnode, m_elemlist)));
}
diff --git a/src/emu/rendlay.h b/src/emu/rendlay.h
index dc46a171542..1de79ef17b9 100644
--- a/src/emu/rendlay.h
+++ b/src/emu/rendlay.h
@@ -136,7 +136,7 @@ private:
int m_textalign; // text alignment to box
bitmap_argb32 m_bitmap[MAX_BITMAPS]; // source bitmap for images
astring m_dirname; // directory name of image file (for lazy loading)
- emu_file * m_file[MAX_BITMAPS]; // file object for reading image/alpha files
+ auto_pointer<emu_file> m_file[MAX_BITMAPS]; // file object for reading image/alpha files
astring m_imagefile[MAX_BITMAPS]; // name of the image file (for lazy loading)
astring m_alphafile[MAX_BITMAPS]; // name of the alpha file (for lazy loading)
bool m_hasalpha[MAX_BITMAPS]; // is there any alpha component present?
diff --git a/src/emu/romload.c b/src/emu/romload.c
index 38485b74b03..e8272d9963c 100644
--- a/src/emu/romload.c
+++ b/src/emu/romload.c
@@ -750,10 +750,7 @@ static int read_rom_data(romload_private *romdata, const rom_entry *parent_regio
/* read as much as we can */
LOG((" Reading %X bytes into buffer\n", bytesleft));
if (rom_fread(romdata, bufptr, bytesleft, parent_region) != bytesleft)
- {
- auto_free(romdata->machine(), tempbuf);
return 0;
- }
numbytes -= bytesleft;
LOG((" Copying to %p\n", base));
@@ -1281,68 +1278,58 @@ static void normalize_flags_for_device(running_machine &machine, const char *rgn
more general process_region_list.
-------------------------------------------------*/
-void load_software_part_region(device_t *device, char *swlist, char *swname, rom_entry *start_region)
+void load_software_part_region(device_t &device, software_list_device &swlist, const char *swname, const rom_entry *start_region)
{
- astring locationtag(swlist), breakstr("%");
- romload_private *romdata = device->machine().romload_data;
+ astring locationtag(swlist.list_name()), breakstr("%");
+ romload_private *romdata = device.machine().romload_data;
const rom_entry *region;
astring regiontag;
- // attempt reading up the chain through the parents and create a locationtag astring in the format
- // " swlist % clonename % parentname "
- // open_rom_file contains the code to split the elements and to create paths to load from
+ romdata->errorstring.reset();
+ romdata->softwarningstring.reset();
+
+ romdata->romstotal = 0;
+ romdata->romstotalsize = 0;
+ romdata->romsloadedsize = 0;
- software_list *software_list_ptr = software_list_open(device->machine().options(), swlist, FALSE, NULL);
- if (software_list_ptr)
+ software_info *swinfo = swlist.find(swname);
+ if (swinfo != NULL)
{
+ UINT32 supported = swinfo->supported();
+ if (supported == SOFTWARE_SUPPORTED_PARTIAL)
+ {
+ romdata->errorstring.catprintf("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist.list_name());
+ romdata->softwarningstring.catprintf("Support for software %s (in list %s) is only partial\n", swname, swlist.list_name());
+ }
+ if (supported == SOFTWARE_SUPPORTED_NO)
+ {
+ romdata->errorstring.catprintf("WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist.list_name());
+ romdata->softwarningstring.catprintf("Support for software %s (in list %s) is only preliminary\n", swname, swlist.list_name());
+ }
+
+ // attempt reading up the chain through the parents and create a locationtag astring in the format
+ // " swlist % clonename % parentname "
+ // open_rom_file contains the code to split the elements and to create paths to load from
+
locationtag.cat(breakstr);
- for (software_info *swinfo = software_list_find(software_list_ptr, swname, NULL); swinfo != NULL; )
+ while (swinfo != NULL)
{
- {
- astring tmp(swinfo->shortname);
- locationtag.cat(tmp);
- locationtag.cat(breakstr);
- // printf("%s\n", locationtag.cstr());
- }
- const char *parentname = software_get_clone(device->machine().options(), swlist, swinfo->shortname);
- if (parentname != NULL)
- swinfo = software_list_find(software_list_ptr, parentname, NULL);
- else
- swinfo = NULL;
+ locationtag.cat(swinfo->shortname()).cat(breakstr);
+ const char *parentname = swinfo->parentname();
+ swinfo = (parentname != NULL) ? swlist.find(parentname) : NULL;
}
// strip the final '%'
locationtag.del(locationtag.len() - 1, 1);
- software_list_close(software_list_ptr);
}
- /* Make sure we are passed a device */
- assert(device != NULL);
-
- romdata->errorstring.reset();
- romdata->softwarningstring.reset();
-
- romdata->romstotal = 0;
- romdata->romstotalsize = 0;
- romdata->romsloadedsize = 0;
-
- if (software_get_support(device->machine().options(), swlist, swname) == SOFTWARE_SUPPORTED_PARTIAL)
- {
- romdata->errorstring.catprintf("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist);
- romdata->softwarningstring.catprintf("Support for software %s (in list %s) is only partial\n", swname, swlist);
- }
- if (software_get_support(device->machine().options(), swlist, swname) == SOFTWARE_SUPPORTED_NO)
- {
- romdata->errorstring.catprintf("WARNING: support for software %s (in list %s) is only preliminary\n", swname, swlist);
- romdata->softwarningstring.catprintf("Support for software %s (in list %s) is only preliminary\n", swname, swlist);
- }
/* loop until we hit the end */
for (region = start_region; region != NULL; region = rom_next_region(region))
{
UINT32 regionlength = ROMREGION_GETLENGTH(region);
- device->subtag(regiontag, ROMREGION_GETTAG(region));
+ device.subtag(regiontag, ROMREGION_GETTAG(region));
LOG(("Processing region \"%s\" (length=%X)\n", regiontag.cstr(), regionlength));
/* the first entry must be a region */
@@ -1388,7 +1375,7 @@ void load_software_part_region(device_t *device, char *swlist, char *swname, rom
/* now process the entries in the region */
if (ROMREGION_ISROMDATA(region))
- process_rom_entries(romdata, locationtag, region, region + 1, device, TRUE);
+ process_rom_entries(romdata, locationtag, region, region + 1, &device, TRUE);
else if (ROMREGION_ISDISKDATA(region))
process_disk_entries(romdata, core_strdup(regiontag.cstr()), region, region + 1, locationtag);
}
@@ -1396,7 +1383,7 @@ void load_software_part_region(device_t *device, char *swlist, char *swname, rom
/* now go back and post-process all the regions */
for (region = start_region; region != NULL; region = rom_next_region(region))
{
- device->subtag(regiontag, ROMREGION_GETTAG(region));
+ device.subtag(regiontag, ROMREGION_GETTAG(region));
region_post_process(romdata, regiontag.cstr(), ROMREGION_ISINVERTED(region));
}
diff --git a/src/emu/romload.h b/src/emu/romload.h
index 19734ea3e28..dbf8f1bce32 100644
--- a/src/emu/romload.h
+++ b/src/emu/romload.h
@@ -122,7 +122,7 @@ enum
class machine_config;
class emu_options;
class chd_file;
-
+class software_list_device;
struct rom_entry
{
@@ -307,6 +307,6 @@ chd_file *get_disk_handle(running_machine &machine, const char *region);
/* set a pointer to the CHD file associated with the given region */
int set_disk_handle(running_machine &machine, const char *region, const char *fullpath);
-void load_software_part_region(device_t *device, char *swlist, char *swname, rom_entry *start_region);
+void load_software_part_region(device_t &device, software_list_device &swlist, const char *swname, const rom_entry *start_region);
#endif /* __ROMLOAD_H__ */
diff --git a/src/emu/save.c b/src/emu/save.c
index b087607d603..d7d8ba57ab5 100644
--- a/src/emu/save.c
+++ b/src/emu/save.c
@@ -62,10 +62,7 @@ enum
save_manager::save_manager(running_machine &machine)
: m_machine(machine),
m_reg_allowed(true),
- m_illegal_regs(0),
- m_entry_list(machine.respool()),
- m_presave_list(machine.respool()),
- m_postload_list(machine.respool())
+ m_illegal_regs(0)
{
}
@@ -120,7 +117,7 @@ void save_manager::register_presave(save_prepost_delegate func)
fatalerror("Duplicate save state function (%s/%s)\n", cb->m_func.name(), func.name());
// allocate a new entry
- m_presave_list.append(*auto_alloc(machine(), state_callback(func)));
+ m_presave_list.append(*global_alloc(state_callback(func)));
}
@@ -141,7 +138,7 @@ void save_manager::register_postload(save_prepost_delegate func)
fatalerror("Duplicate save state function (%s/%s)\n", cb->m_func.name(), func.name());
// allocate a new entry
- m_postload_list.append(*auto_alloc(machine(), state_callback(func)));
+ m_postload_list.append(*global_alloc(state_callback(func)));
}
@@ -186,7 +183,7 @@ void save_manager::save_memory(const char *module, const char *tag, UINT32 index
}
// insert us into the list
- m_entry_list.insert_after(*auto_alloc(machine(), state_entry(val, totalname, valsize, valcount)), insert_after);
+ m_entry_list.insert_after(*global_alloc(state_entry(val, totalname, valsize, valcount)), insert_after);
}
diff --git a/src/emu/schedule.c b/src/emu/schedule.c
index 7e4a817b686..f135821d201 100644
--- a/src/emu/schedule.c
+++ b/src/emu/schedule.c
@@ -315,13 +315,10 @@ device_scheduler::device_scheduler(running_machine &machine) :
m_execute_list(NULL),
m_basetime(attotime::zero),
m_timer_list(NULL),
- m_timer_allocator(machine.respool()),
m_callback_timer(NULL),
m_callback_timer_modified(false),
m_callback_timer_expire_time(attotime::zero),
m_suspend_changes_pending(true),
- m_quantum_list(machine.respool()),
- m_quantum_allocator(machine.respool()),
m_quantum_minimum(ATTOSECONDS_IN_NSEC(1) / 1000)
{
// append a single never-expiring timer so there is always one in the list
diff --git a/src/emu/softlist.c b/src/emu/softlist.c
index 1deb49e85b2..d997dd2c600 100644
--- a/src/emu/softlist.c
+++ b/src/emu/softlist.c
@@ -4,7 +4,6 @@
Software list construction helpers.
-
***************************************************************************/
#include "emu.h"
@@ -12,2154 +11,1297 @@
#include "emuopts.h"
#include "softlist.h"
#include "clifront.h"
+#include "validity.h"
#include <ctype.h>
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
typedef tagmap_t<software_info *> softlist_map;
+// ======================> softlist_parser
+
+class softlist_parser
+{
+public:
+ // construction (== execution)
+ softlist_parser(software_list_device &list, astring &errors);
+
+private:
+ enum parse_position
+ {
+ POS_ROOT,
+ POS_MAIN,
+ POS_SOFT,
+ POS_PART,
+ POS_DATA
+ };
+
+ // internal parsing helpers
+ const char *filename() const { return m_list.filename(); }
+ const char *infoname() const { return (m_current_info != NULL) ? m_current_info->shortname() : "???"; }
+ int line() const { return XML_GetCurrentLineNumber(m_parser); }
+ int column() const { return XML_GetCurrentColumnNumber(m_parser); }
+ const char *parser_error() const { return XML_ErrorString(XML_GetErrorCode(m_parser)); }
+
+ // internal error helpers
+ void ATTR_PRINTF(2,3) parse_error(const char *fmt, ...);
+ void unknown_tag(const char *tagname) { parse_error("Unknown tag: %s", tagname); }
+ void unknown_attribute(const char *attrname) { parse_error("Unknown attribute: %s", attrname); }
+
+ // internal helpers
+ void parse_attributes(const char **attributes, int numattrs, const char *attrlist[], const char *outlist[]);
+ void add_rom_entry(const char *name, const char *hashdata, UINT32 offset, UINT32 length, UINT32 flags);
+
+ // expat callbacks
+ static void *expat_malloc(size_t size);
+ static void *expat_realloc(void *ptr, size_t size);
+ static void expat_free(void *ptr);
+ static void start_handler(void *data, const char *tagname, const char **attributes);
+ static void data_handler(void *data, const XML_Char *s, int len);
+ static void end_handler(void *data, const char *name);
+
+ // internal parsing
+ void parse_root_start(const char *tagname, const char **attributes);
+ void parse_main_start(const char *tagname, const char **attributes);
+ void parse_soft_start(const char *tagname, const char **attributes);
+ void parse_part_start(const char *tagname, const char **attributes);
+ void parse_data_start(const char *tagname, const char **attributes);
+ void parse_soft_end(const char *name);
+
+ // internal parsing state
+ software_list_device & m_list;
+ astring & m_errors;
+ XML_Parser m_parser;
+ bool m_done;
+ bool m_data_accum_expected;
+ astring m_data_accum;
+ software_info * m_current_info;
+ software_part * m_current_part;
+ parse_position m_pos;
+};
+
+
+
//**************************************************************************
-// LIVE DEVICE
+// GLOBAL VARIABLES
//**************************************************************************
-tagmap_t<UINT8> software_list_device::s_checked_lists;
-
// device type definition
const device_type SOFTWARE_LIST = &device_creator<software_list_device>;
-//-------------------------------------------------
-// software_list_device - constructor
-//-------------------------------------------------
-software_list_device::software_list_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, SOFTWARE_LIST, "Software list", tag, owner, clock, "software_list", __FILE__),
- m_list_name(NULL),
- m_list_type(SOFTWARE_LIST_ORIGINAL_SYSTEM),
- m_filter(NULL)
-{
-}
+//**************************************************************************
+// SOFTWARE PART
+//**************************************************************************
//-------------------------------------------------
-// static_set_interface - configuration helper
-// to set the interface
+// software_part - constructor
//-------------------------------------------------
-void software_list_device::static_set_config(device_t &device, const char *list, softlist_type list_type)
+software_part::software_part(software_info &info, const char *name, const char *interface)
+ : m_next(NULL),
+ m_info(info),
+ m_name(name),
+ m_interface(interface)
{
- software_list_device &softlist = downcast<software_list_device &>(device);
- softlist.m_list_name = list;
- softlist.m_list_type = list_type;
+ // ensure strings we are passed are in the string pool
+ assert(info.list().string_pool_contains(name));
+ assert(info.list().string_pool_contains(interface));
}
//-------------------------------------------------
-// static_set_custom_handler - configuration
-// helper to set a custom callback
+// feature - return the value of the given
+// feature, if specified
//-------------------------------------------------
-void software_list_device::static_set_filter(device_t &device, const char *filter)
+const char *software_part::feature(const char *feature_name) const
{
- downcast<software_list_device &>(device).m_filter = filter;
+ assert(feature_name != NULL);
+
+ // scan the feature list for an entry matching feature_name and return the value
+ for (const feature_list_item *feature = m_featurelist.first(); feature != NULL; feature = feature->next())
+ if (strcmp(feature->name(), feature_name) == 0)
+ return feature->value();
+ return NULL;
+
}
//-------------------------------------------------
-// device_start - device-specific startup
+// is_compatible - determine if we are compatible
+// with the given software_list_device
//-------------------------------------------------
-void software_list_device::device_start()
+bool software_part::is_compatible(const software_list_device &swlistdev) const
{
+ // get the compatibility feature and the softlist filter; if either is NULL, assume compatible
+ const char *compatibility = feature("compatibility");
+ const char *filter = swlistdev.filter();
+ if (compatibility == NULL || filter == NULL)
+ return true;
+
+ // copy the comma-delimited strings and ensure they end with a final comma
+ astring comp(compatibility, ",");
+ astring filt(filter, ",");
+
+ // iterate over filter items and see if they exist in the compatibility list; if so, return true
+ for (int start = 0, end = filt.chr(start, ','); end != -1; start = end + 1, end = filt.chr(start, ','))
+ {
+ astring token(filt, start, end - start + 1);
+ if (comp.find(0, token) != -1)
+ return true;
+ }
+ return false;
}
+//-------------------------------------------------
+// matches_interface - determine if we match
+// an interface in the provided list
+//-------------------------------------------------
-/***************************************************************************
- EXPAT INTERFACES
-***************************************************************************/
-
-/*-------------------------------------------------
- expat_malloc/expat_realloc/expat_free -
- wrappers for memory allocation functions so
- that they pass through out memory tracking
- systems
--------------------------------------------------*/
-
-static void *expat_malloc(size_t size)
+bool software_part::matches_interface(const char *interface_list) const
{
- return global_alloc_array_clear(UINT8,size);
+ // if we have no interface, then we match by default
+ if (m_interface == NULL)
+ return true;
+
+ // copy the comma-delimited interface list and ensure it ends with a final comma
+ astring interfaces(interface_list, ",");
+
+ // then add a comma to the end of our interface and return true if we find it in the list string
+ astring our_interface(m_interface, ",");
+ return (interfaces.find(0, our_interface) != -1);
}
-static void *expat_realloc(void *ptr, size_t size)
-{
- if (ptr) global_free(ptr);
- return global_alloc_array_clear(UINT8,size);
-}
-static void expat_free(void *ptr)
-{
- global_free(ptr);
-}
+//**************************************************************************
+// SOFTWARE INFO
+//**************************************************************************
-/*-------------------------------------------------
- parse_error
--------------------------------------------------*/
+//-------------------------------------------------
+// software_info - constructor
+//-------------------------------------------------
-INLINE void ATTR_PRINTF(2,3) parse_error(parse_state *state, const char *fmt, ...)
+software_info::software_info(software_list_device &list, const char *name, const char *parent, const char *supported)
+ : m_next(NULL),
+ m_list(list),
+ m_supported(SOFTWARE_SUPPORTED_YES),
+ m_shortname(name),
+ m_parentname(parent)
{
- char buf[256];
- va_list va;
+ // ensure strings we are passed are in the string pool
+ assert(list.string_pool_contains(name));
+ assert(list.string_pool_contains(parent));
- if (state->error_proc)
+ // handle the supported flag if provided
+ if (supported != NULL)
{
- va_start(va, fmt);
- vsnprintf(buf, ARRAY_LENGTH(buf), fmt, va);
- va_end(va);
- (*state->error_proc)(buf);
+ if (strcmp(supported, "partial") == 0)
+ m_supported = SOFTWARE_SUPPORTED_PARTIAL;
+ else if (strcmp(supported, "no") == 0)
+ m_supported = SOFTWARE_SUPPORTED_NO;
}
}
-/*-------------------------------------------------
- unknown_tag
--------------------------------------------------*/
+//-------------------------------------------------
+// find_part - find a part by name with an
+// optional interface match
+//-------------------------------------------------
-INLINE void unknown_tag(software_list *swlist, const char *tagname)
+software_part *software_info::find_part(const char *partname, const char *interface)
{
- parse_error(&swlist->state, "%s: Unknown tag: %s (line %lu column %lu)\n",
- swlist->file->filename(),
- tagname,
- XML_GetCurrentLineNumber(swlist->state.parser),
- XML_GetCurrentColumnNumber(swlist->state.parser));
-}
+ // if neither partname nor interface supplied, then we just return the first entry
+ if (partname == NULL && interface == NULL)
+ return m_partdata.first();
+
+ // look for the part by name and match against the interface if provided
+ for (software_part *part = m_partdata.first(); part != NULL; part = part->next())
+ if (partname != NULL && strcmp(partname, part->name()) == 0)
+ if (interface == NULL || part->matches_interface(interface))
+ return part;
+ return NULL;
+}
-/*-------------------------------------------------
- unknown_attribute
--------------------------------------------------*/
+//-------------------------------------------------
+// has_multiple_parts - return true if we have
+// more than one part matching the given
+// interface
+//-------------------------------------------------
-INLINE void unknown_attribute(software_list *swlist, const char *attrname)
+bool software_info::has_multiple_parts(const char *interface) const
{
- parse_error(&swlist->state, "%s: Unknown attribute: %s (line %lu column %lu)\n",
- swlist->file->filename(),
- attrname,
- XML_GetCurrentLineNumber(swlist->state.parser),
- XML_GetCurrentColumnNumber(swlist->state.parser));
+ int count = 0;
+
+ // increment the count for each match and stop if we hit more than 1
+ for (software_part *part = first_part(); part != NULL; part = part->next())
+ if (part->matches_interface(interface))
+ if (++count > 1)
+ return true;
+
+ return false;
}
-#if 0
-/*-------------------------------------------------
- unknown_attribute_value
--------------------------------------------------*/
+//**************************************************************************
+// CONST STRING POOL
+//**************************************************************************
-INLINE void unknown_attribute_value(software_list *swlist,
- const char *attrname, const char *attrvalue)
+//-------------------------------------------------
+// const_string_pool - constructor
+//-------------------------------------------------
+
+const_string_pool::const_string_pool()
{
- parse_error(&swlist->state, "%s: Unknown attribute value: %s (line %lu column %lu)\n",
- swlist->file->filename(),
- attrvalue,
- XML_GetCurrentLineNumber(swlist->state.parser),
- XML_GetCurrentColumnNumber(swlist->state.parser));
}
-#endif
-
-
-/*-------------------------------------------------
- software_name_split
- helper; splits a software_list:software:part
- string into separate software_list, software,
- and part strings.
- str1:str2:str3 => swlist_name - str1, swname - str2, swpart - str3
- str1:str2 => swlist_name - NULL, swname - str1, swpart - str2
- str1 => swlist_name - NULL, swname - str1, swpart - NULL
- swlist_namem, swnane and swpart will be global_alloc'ed
- from the global pool. So they should be global_free'ed
- when they are not used anymore.
--------------------------------------------------*/
-
-#define global_strdup(s) strcpy(global_alloc_array(char, strlen(s) + 1), s)
+//-------------------------------------------------
+// add - add a string to the string pool
+//-------------------------------------------------
-void software_name_split(const char *swlist_swname, char **swlist_name, char **swname, char **swpart )
+const char *const_string_pool::add(const char *string)
{
- const char *split_1st_loc = strchr( swlist_swname, ':' );
- const char *split_2nd_loc = ( split_1st_loc ) ? strchr( split_1st_loc + 1, ':' ) : NULL;
-
- *swlist_name = NULL;
- *swname = NULL;
- *swpart = NULL;
+ // if NULL or a small number (for some hash strings), just return as-is
+ if (FPTR(string) < 0x100)
+ return string;
- if ( split_1st_loc )
+ // scan to find space
+ for (pool_chunk *chunk = m_chunklist.first(); chunk != NULL; chunk = chunk->next())
{
- if ( split_2nd_loc )
- {
- int size = split_1st_loc - swlist_swname;
- *swlist_name = global_alloc_array_clear(char,size+1);
- memcpy( *swlist_name, swlist_swname, size );
+ const char *result = chunk->add(string);
+ if (result != NULL)
+ return result;
+ }
+
+ // no space anywhere, create a new pool and prepend it (so it gets used first)
+ const char *result = m_chunklist.prepend(*global_alloc(pool_chunk)).add(string);
+ assert(result != NULL);
+ return result;
+}
- size = split_2nd_loc - ( split_1st_loc + 1 );
- *swname = global_alloc_array_clear(char,size+1);
- memcpy( *swname, split_1st_loc + 1, size );
- size = strlen( swlist_swname ) - ( split_2nd_loc + 1 - swlist_swname );
- *swpart = global_alloc_array_clear(char,size+1);
- memcpy( *swpart, split_2nd_loc + 1, size );
- }
- else
- {
- int size = split_1st_loc - swlist_swname;
- *swname = global_alloc_array_clear(char,size+1);
- memcpy( *swname, swlist_swname, size );
+//-------------------------------------------------
+// contains - determine if the given string
+// pointer lives in the pool
+//-------------------------------------------------
- size = strlen( swlist_swname ) - ( split_1st_loc + 1 - swlist_swname );
- *swpart = global_alloc_array_clear(char,size+1);
- memcpy( *swpart, split_1st_loc + 1, size );
- }
- }
- else
- {
- *swname = global_strdup(swlist_swname);
- }
+bool const_string_pool::contains(const char *string)
+{
+ // if NULL or a small number (for some hash strings), then yes, effectively
+ if (FPTR(string) < 0x100)
+ return true;
+
+ // scan to find it
+ for (pool_chunk *chunk = m_chunklist.first(); chunk != NULL; chunk = chunk->next())
+ if (chunk->contains(string))
+ return true;
+
+ return false;
}
-/*-------------------------------------------------
- add_rom_entry
--------------------------------------------------*/
+//-------------------------------------------------
+// pool_chunk - constructor
+//-------------------------------------------------
-static void add_rom_entry(software_list *swlist, const char *name, const char *hashdata, UINT32 offset, UINT32 length, UINT32 flags)
+const_string_pool::pool_chunk::pool_chunk()
+ : m_next(NULL),
+ m_used(0)
{
- software_part *part = &swlist->softinfo->partdata[swlist->softinfo->current_part_entry-1];
- if ((flags & ROMENTRY_TYPEMASK) == ROMENTRYTYPE_REGION && name!=NULL && part!=NULL) {
- if (swlist->current_rom_entry>0) {
- for (int i=0;i<swlist->current_rom_entry;i++) {
- if ((part->romdata[i]._name != NULL) && (strcmp(part->romdata[i]._name,name)==0)) {
- parse_error(&swlist->state, "%s: Duplicated dataarea %s in %s\n",swlist->file->filename(),name,swlist->current_software_info->shortname);
- }
- }
- }
- }
+}
- if ( part->romdata == NULL )
- {
- /* Allocate initial space to hold the rom information */
- swlist->rom_entries = 3;
- part->romdata = (struct rom_entry *)pool_malloc_lib(swlist->pool, swlist->rom_entries * sizeof(struct rom_entry));
- if ( part->romdata == NULL )
- {
- fatalerror("Unable to claim memory for storing a rom entry\n");
- }
- }
- struct rom_entry *entry = &part->romdata[swlist->current_rom_entry];
+//-------------------------------------------------
+// add - add a string to this pool
+//-------------------------------------------------
- entry->_name = name;
- entry->_hashdata = hashdata;
- entry->_offset = offset;
- entry->_length = length;
- entry->_flags = flags;
+const char *const_string_pool::pool_chunk::add(const char *string)
+{
+ // get the length of the string (no string can be longer than a full pool)
+ int bytes = strlen(string) + 1;
+ assert(bytes < POOL_SIZE);
+
+ // if too big, return NULL
+ if (m_used + bytes > POOL_SIZE)
+ return NULL;
- swlist->current_rom_entry += 1;
+ // allocate, copy, and return the memory
+ char *dest = &m_buffer[m_used];
+ m_used += bytes;
+ memcpy(dest, string, bytes);
+ return dest;
+}
- if ( swlist->current_rom_entry >= swlist->rom_entries )
- {
- struct rom_entry *new_entries;
- swlist->rom_entries += 10;
- new_entries = (struct rom_entry *)pool_realloc_lib(swlist->pool, part->romdata, swlist->rom_entries * sizeof(struct rom_entry) );
- if ( new_entries )
- {
- part->romdata = new_entries;
- }
- else
- {
- /* Allocation error */
- swlist->current_rom_entry -= 1;
- }
- }
-}
+//**************************************************************************
+// SOFTWARE LIST DEVICE
+//**************************************************************************
-/*-------------------------------------------------
- add_feature
--------------------------------------------------*/
+//-------------------------------------------------
+// software_list_device - constructor
+//-------------------------------------------------
-static void add_feature(software_list *swlist, char *feature_name, char *feature_value)
+software_list_device::software_list_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, SOFTWARE_LIST, "Software list", tag, owner, clock, "software_list", __FILE__),
+ m_list_type(SOFTWARE_LIST_ORIGINAL_SYSTEM),
+ m_filter(NULL),
+ m_parsed(false),
+ m_file(mconfig.options().hash_path(), OPEN_FLAG_READ)
{
- software_part *part = &swlist->softinfo->partdata[swlist->softinfo->current_part_entry-1];
- feature_list *new_entry;
+}
- /* First allocate the new entry */
- new_entry = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
- if ( new_entry )
- {
- new_entry->next = NULL;
- new_entry->name = feature_name;
- new_entry->value = feature_value ? feature_value : feature_name;
+//-------------------------------------------------
+// static_set_interface - configuration helper
+// to set the interface
+//-------------------------------------------------
- /* Add new feature to end of feature list */
- if ( part->featurelist )
- {
- feature_list *list = part->featurelist;
- while ( list->next != NULL )
- {
- list = list->next;
- }
- list->next = new_entry;
- }
- else
- {
- part->featurelist = new_entry;
- }
- }
- else
- {
- /* Unable to allocate memory */
- }
+void software_list_device::static_set_config(device_t &device, const char *list, softlist_type list_type)
+{
+ software_list_device &swlistdev = downcast<software_list_device &>(device);
+ swlistdev.m_list_name.cpy(list);
+ swlistdev.m_list_type = list_type;
}
-/*-------------------------------------------------
- add_info (same as add_feature, but its target
- is softinfo->shared_info)
- -------------------------------------------------*/
-static void add_info(software_list *swlist, char *feature_name, char *feature_value)
+//-------------------------------------------------
+// static_set_custom_handler - configuration
+// helper to set a custom callback
+//-------------------------------------------------
+
+void software_list_device::static_set_filter(device_t &device, const char *filter)
{
- software_info *info = swlist->softinfo;
- feature_list *new_entry;
+ downcast<software_list_device &>(device).m_filter = filter;
+}
- /* First allocate the new entry */
- new_entry = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
- if ( new_entry )
- {
- new_entry->next = NULL;
- new_entry->name = feature_name;
- new_entry->value = feature_value ? feature_value : feature_name;
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
- /* Add new feature to end of feature list */
- if ( info->shared_info )
- {
- feature_list *list = info->shared_info;
- while ( list->next != NULL )
- {
- list = list->next;
- }
- list->next = new_entry;
- }
- else
- {
- info->shared_info = new_entry;
- }
- }
- else
- {
- /* Unable to allocate memory */
- }
+void software_list_device::device_start()
+{
}
-/*-------------------------------------------------
- add_other_info (same as add_info, but its target
- is softinfo->other_info)
- -------------------------------------------------*/
-static void add_other_info(software_list *swlist, char *info_name, char *info_value)
-{
- software_info *info = swlist->softinfo;
- feature_list *new_entry;
+//-------------------------------------------------
+// find_approx_matches - search ourselves for
+// a list of possible matches of the given name
+// and optional interface
+//-------------------------------------------------
- /* First allocate the new entry */
- new_entry = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
+void software_list_device::find_approx_matches(const char *name, int matches, software_info **list, const char *interface)
+{
+ // if no name, return
+ if (name == NULL || name[0] == 0)
+ return;
- if ( new_entry )
+ // initialize everyone's states
+ dynamic_array<int> penalty(matches);
+ for (int matchnum = 0; matchnum < matches; matchnum++)
{
- new_entry->next = NULL;
- new_entry->name = info_name;
- new_entry->value = info_value ? info_value : info_name;
+ penalty[matchnum] = 9999;
+ list[matchnum] = NULL;
+ }
- /* Add new feature to end of feature list */
- if ( info->other_info )
+ // iterate over our info (will cause a parse if needed)
+ for (software_info *swinfo = first_software_info(); swinfo != NULL; swinfo = swinfo->next())
+ {
+ software_part *part = swinfo->first_part();
+ if ((interface == NULL || part->matches_interface(interface)) && part->is_compatible(*this))
{
- feature_list *list = info->other_info;
- while ( list->next != NULL )
+ // pick the best match between driver name and description
+ int longpenalty = driver_list::penalty_compare(name, swinfo->longname());
+ int shortpenalty = driver_list::penalty_compare(name, swinfo->shortname());
+ int curpenalty = MIN(longpenalty, shortpenalty);
+
+ // insert into the sorted table of matches
+ for (int matchnum = matches - 1; matchnum >= 0; matchnum--)
{
- list = list->next;
+ // stop if we're worse than the current entry
+ if (curpenalty >= penalty[matchnum])
+ break;
+
+ // as long as this isn't the last entry, bump this one down
+ if (matchnum < matches - 1)
+ {
+ penalty[matchnum + 1] = penalty[matchnum];
+ list[matchnum + 1] = list[matchnum];
+ }
+ list[matchnum] = swinfo;
+ penalty[matchnum] = curpenalty;
}
- list->next = new_entry;
- }
- else
- {
- info->other_info = new_entry;
}
}
- else
- {
- /* Unable to allocate memory */
- }
}
-/*-------------------------------------------------
- add_software_part
--------------------------------------------------*/
-static void add_software_part(software_list *swlist, const char *name, const char *interface)
-{
- software_part *part = &swlist->softinfo->partdata[swlist->softinfo->current_part_entry];
-
- part->name = name;
- part->interface_ = interface;
- part->featurelist = NULL;
- part->romdata = NULL;
+//-------------------------------------------------
+// release - reset to a pre-parsed state
+//-------------------------------------------------
- swlist->softinfo->current_part_entry += 1;
+void software_list_device::release()
+{
+fprintf(stderr, "Resetting %s\n", m_file.filename());
+ m_parsed = false;
+ m_description = NULL;
+ m_errors.reset();
+ m_infolist.reset();
+ m_stringpool.reset();
+}
- if ( swlist->softinfo->current_part_entry >= swlist->softinfo->part_entries )
- {
- software_part *new_parts;
- swlist->softinfo->part_entries += 2;
- new_parts = (software_part *)pool_realloc_lib(swlist->pool, swlist->softinfo->partdata, swlist->softinfo->part_entries * sizeof(software_part) );
+//-------------------------------------------------
+// find_by_name - find a software list by name
+// across all software list devices
+//-------------------------------------------------
- if ( new_parts )
- {
- swlist->softinfo->partdata = new_parts;
- }
- else
- {
- /* Allocation error */
- swlist->softinfo->current_part_entry -= 1;
- }
- }
+software_list_device *software_list_device::find_by_name(const machine_config &config, const char *name)
+{
+ // iterate over each device in the system and find a match
+ software_list_device_iterator deviter(config.root_device());
+ for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next())
+ if (strcmp(swlistdev->list_name(), name) == 0)
+ return swlistdev;
+ return NULL;
}
-/*-------------------------------------------------
- start_handler
--------------------------------------------------*/
+//-------------------------------------------------
+// software_display_matches - display a list of
+// possible matches in the system to the given
+// name, across all software list devices
+//-------------------------------------------------
-static void start_handler(void *data, const char *tagname, const char **attributes)
+void software_list_device::display_matches(const machine_config &config, const char *interface, const char *name)
{
- software_list *swlist = (software_list *) data;
- char **text_dest;
+ // check if there is at least one software list
+ software_list_device_iterator deviter(config.root_device());
+ if (deviter.first())
+ mame_printf_error("\n\"%s\" approximately matches the following\n"
+ "supported software items (best match first):\n\n", name);
- switch(swlist->state.pos)
+ // iterate through lists
+ for (software_list_device *swlistdev = deviter.first(); swlistdev != NULL; swlistdev = deviter.next())
{
- case POS_ROOT:
- if (!strcmp(tagname, "softwarelist"))
- {
- for( ; attributes[0]; attributes += 2 )
- {
- if ( ! strcmp(attributes[0], "name" ) )
- {
- }
- else if ( ! strcmp(attributes[0], "description" ) )
- {
- swlist->description = (const char *)pool_malloc_lib(swlist->pool, (strlen(attributes[1]) + 1) * sizeof(char));
- if (!swlist->description)
- return;
-
- strcpy((char *)swlist->description, attributes[1]);
- } else
- unknown_attribute(swlist, attributes[0]);
- }
- }
- else
- {
- unknown_tag(swlist, tagname);
- }
- break;
+ // get the top 16 approximate matches for the selected device interface (i.e. only carts for cartslot, etc.)
+ software_info *matches[16] = { 0 };
+ swlistdev->find_approx_matches(name, ARRAY_LENGTH(matches), matches, interface);
- case POS_MAIN:
- if ( !strcmp( tagname, "software" ) )
- {
- const char *name = NULL;
- const char *parent = NULL;
- const char *supported = NULL;
-
- for ( ; attributes[0]; attributes += 2 )
- {
- if ( !strcmp( attributes[0], "name" ) )
- {
- name = attributes[1];
- }
- else if ( !strcmp( attributes[0], "cloneof" ) )
- {
- parent = attributes[1];
- }
- else if ( !strcmp( attributes[0], "supported" ) )
- {
- supported = attributes[1];
- }
- else
- unknown_attribute(swlist, attributes[0]);
- }
-
- if ( name )
- {
- struct software_info *elem = (struct software_info *)pool_malloc_lib(swlist->pool,sizeof(struct software_info));
-
- if ( !elem )
- return;
-
- /* Clear element and add element to list */
- memset(elem,0,sizeof(struct software_info));
-
- /* Allocate space to hold the shortname and copy the short name */
- elem->shortname = (const char*)pool_malloc_lib(swlist->pool, ( strlen( name ) + 1 ) * sizeof(char) );
-
- if ( ! elem->shortname )
- return;
-
- strcpy( (char *)elem->shortname, name );
-
- /* Allocate space to hold the parentname and copy the parent name */
- if (parent)
- {
- elem->parentname = (const char*)pool_malloc_lib(swlist->pool, ( strlen(parent) + 1 ) * sizeof(char) );
- strcpy((char *)elem->parentname, parent);
- }
-
- /* Allocate initial space to hold part information */
- elem->part_entries = 2;
- elem->current_part_entry = 0;
- elem->partdata = (software_part *)pool_malloc_lib(swlist->pool, elem->part_entries * sizeof(software_part) );
- if ( !elem->partdata )
- return;
- elem->shared_info = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
- if ( !elem->shared_info )
- return;
- else
- {
- elem->shared_info->next = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
- elem->shared_info->next = NULL;
- elem->shared_info->name = NULL;
- elem->shared_info->value = NULL;
- }
-
- /* Handle the supported flag */
- elem->supported = SOFTWARE_SUPPORTED_YES;
- if ( supported && ! strcmp( supported, "partial" ) )
- elem->supported = SOFTWARE_SUPPORTED_PARTIAL;
- if ( supported && ! strcmp( supported, "no" ) )
- elem->supported = SOFTWARE_SUPPORTED_NO;
-
- /* Add the entry to the end of the list */
- if ( swlist->software_info_list == NULL )
- {
- swlist->software_info_list = elem;
- swlist->current_software_info = elem;
- }
- else
- {
- swlist->current_software_info->next = elem;
- swlist->current_software_info = elem;
- }
-
- /* Quick lookup for setting software information */
- swlist->softinfo = swlist->current_software_info;
- }
- else
- {
- parse_error(&swlist->state, "%s: No name defined for item (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
-
- swlist->softinfo = NULL;
- }
- }
+ // if we found some, print them
+ if (matches[0] != 0)
+ {
+ // different output depending on original system or compatible
+ if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
+ mame_printf_error("* Software list \"%s\" (%s) matches: \n", swlistdev->list_name(), swlistdev->description());
else
- {
- unknown_tag(swlist, tagname);
- }
- break;
-
- case POS_SOFT:
- text_dest = NULL;
-
- if (!strcmp(tagname, "description"))
- text_dest = (char **) &swlist->softinfo->longname;
- else if (!strcmp(tagname, "year"))
- text_dest = (char **) &swlist->softinfo->year;
- else if (!strcmp(tagname, "publisher"))
- text_dest = (char **) &swlist->softinfo->publisher;
- else if (!strcmp(tagname, "info"))
- {
- const char *str_info_name = NULL;
- const char *str_info_value = NULL;
- for ( ; attributes[0]; attributes += 2 )
- {
- if ( !strcmp( attributes[0], "name" ) )
- str_info_name = attributes[1];
- else if ( !strcmp( attributes[0], "value" ) )
- str_info_value = attributes[1];
- else
- unknown_attribute(swlist, attributes[0]);
- }
-
- if ( str_info_name && swlist->softinfo )
- {
- char *name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_info_name ) + 1 ) * sizeof(char) );
- char *value = NULL;
-
- if ( !name )
- return;
+ mame_printf_error("* Compatible software list \"%s\" (%s) matches: \n", swlistdev->list_name(), swlistdev->description());
- strcpy( name, str_info_name );
+ // print them out
+ for (int softnum = 0; softnum < ARRAY_LENGTH(matches); softnum++)
+ if (matches[softnum] != NULL)
+ mame_printf_error("%-18s%s\n", matches[softnum]->shortname(), matches[softnum]->longname());
- if ( str_info_value )
- {
- value = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_info_value ) + 1 ) * sizeof(char) );
-
- if ( !value )
- return;
+ mame_printf_error("\n");
+ }
+ }
+}
- strcpy( value, str_info_value );
- add_other_info( swlist, name, value );
- }
- } else {
- parse_error(&swlist->state, "%s: Incomplete other_info definition (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
- }
- }
- else if (!strcmp(tagname, "sharedfeat"))
- {
- const char *str_feature_name = NULL;
- const char *str_feature_value = NULL;
-
- for ( ; attributes[0]; attributes += 2 )
- {
- if ( !strcmp( attributes[0], "name" ) )
- str_feature_name = attributes[1];
+//-------------------------------------------------
+// find - find an item by name in the software
+// list, using wildcards and optionally starting
+// from an intermediate point
+//-------------------------------------------------
- else if ( !strcmp( attributes[0], "value" ) )
- str_feature_value = attributes[1];
+software_info *software_list_device::find(const char *look_for, software_info *prev)
+{
+ // NULL search returns nothing
+ if (look_for == NULL)
+ return NULL;
- else
- unknown_attribute(swlist, attributes[0]);
- }
+ // find a match (will cause a parse if needed when calling first_software_info)
+ for (prev = (prev != NULL) ? prev->next() : first_software_info(); prev != NULL; prev = prev->next())
+ if (mame_strwildcmp(look_for, prev->shortname()) == 0)
+ break;
- /* Prepare for adding feature to feature list */
- if ( str_feature_name && swlist->softinfo )
- {
- char *name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_feature_name ) + 1 ) * sizeof(char) );
- char *value = NULL;
+ return prev;
+}
- if ( !name )
- return;
- strcpy( name, str_feature_name );
+//-------------------------------------------------
+// parse - parse our softlist file
+//-------------------------------------------------
- if ( str_feature_value )
- {
- value = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_feature_value ) + 1 ) * sizeof(char) );
+void software_list_device::parse()
+{
+ // skip if done
+ if (m_parsed)
+ return;
- if ( !value )
- return;
+ // reset the errors
+ m_errors.reset();
- strcpy( value, str_feature_value );
- }
+ // attempt to open the file
+ file_error filerr = m_file.open(m_list_name, ".xml");
+ if (filerr == FILERR_NONE)
+ {
+ // parse if no error
+ softlist_parser parser(*this, m_errors);
+ m_file.close();
+ }
+ else
+ m_errors.printf("Error opening file: %s\n", filename());
+
+ // indicate that we've been parsed
+ m_parsed = true;
+}
- add_info( swlist, name, value );
- } else {
- parse_error(&swlist->state, "%s: Incomplete sharedfeat definition (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
- }
- }
- else if ( !strcmp(tagname, "part" ) )
- {
- const char *str_name = NULL;
- const char *str_interface = NULL;
- for ( ; attributes[0]; attributes += 2 )
- {
- if ( !strcmp( attributes[0], "name" ) )
- str_name = attributes[1];
+//-------------------------------------------------
+// device_validity_check - validate the device
+// configuration
+//-------------------------------------------------
- else if ( !strcmp( attributes[0], "interface" ) )
- str_interface = attributes[1];
+void software_list_device::device_validity_check(validity_checker &valid) const
+{
+ // add to the global map whenever we check a list so we don't re-check
+ // it in the future
+ if (valid.already_checked(astring("softlist/", m_list_name.cstr())))
+ return;
- else
- unknown_attribute(swlist, attributes[0]);
- }
+ // do device validation only in case of validate command
+ if (strcmp(mconfig().options().command(), CLICOMMAND_VALIDATE) != 0)
+ return;
+
+ // actually do the validate
+ const_cast<software_list_device *>(this)->internal_validity_check(valid);
+}
- if ( str_name && str_interface && strcmp(str_name, "") && strcmp(str_interface, "") )
- {
- if ( swlist->softinfo )
- {
- char *name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_name ) + 1 ) * sizeof(char) );
- char *interface = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_interface ) + 1 ) * sizeof(char) );
- if ( !name || !interface )
- return;
+//-------------------------------------------------
+// internal_validity_check - internal helper to
+// check the list
+//-------------------------------------------------
- strcpy( name, str_name );
- strcpy( interface, str_interface );
+void software_list_device::internal_validity_check(validity_checker &valid)
+{
+ enum { NAME_LEN_PARENT = 8, NAME_LEN_CLONE = 16 };
- add_software_part( swlist, name, interface );
+ // first parse and output core errors if any
+ if (m_errors.len() > 0)
+ {
+ mame_printf_error("%s: Errors parsing software list:\n%s", filename(), errors_string());
+ release();
+ return;
+ }
- /* Set up rom/dataarea information */
- swlist->rom_entries = 0;
- swlist->current_rom_entry = 0;
- swlist->softinfo->partdata[swlist->softinfo->current_part_entry-1].romdata = NULL;
- }
- }
- else
- {
- /* Incomplete/incorrect part definition ("" names are invalid too) */
- parse_error(&swlist->state, "%s: Incomplete part definition (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
- }
- }
- else
- unknown_tag(swlist, tagname);
+ softlist_map names;
+ softlist_map descriptions;
+ for (software_info *swinfo = first_software_info(); swinfo != NULL; swinfo = swinfo->next())
+ {
+ // First, check if the xml got corrupted:
- if (text_dest && swlist->softinfo)
- swlist->state.text_dest = text_dest;
+ // Did we lost any description?
+ if (swinfo->longname() == NULL)
+ {
+ mame_printf_error("%s: %s has no description\n", filename(), swinfo->shortname());
break;
+ }
- case POS_PART:
- if (!strcmp(tagname, "dataarea"))
- {
- const char *str_name = NULL;
- const char *str_size = NULL;
-
- for ( ; attributes[0]; attributes += 2 )
- {
- if ( !strcmp( attributes[0], "name" ) )
- str_name = attributes[1];
+ // Did we lost any year?
+ if (swinfo->year() == NULL)
+ {
+ mame_printf_error("%s: %s has no year\n", filename(), swinfo->shortname());
+ break;
+ }
- else if ( !strcmp( attributes[0], "size") )
- str_size = attributes[1];
+ // Did we lost any publisher?
+ if (swinfo->publisher() == NULL)
+ {
+ mame_printf_error("%s: %s has no publisher\n", filename(), swinfo->shortname());
+ break;
+ }
- else
- unknown_attribute(swlist, attributes[0]);
- }
- if ( str_name && str_size && strcmp(str_name, "") && strcmp(str_size, "") )
- {
- if ( swlist->softinfo )
- {
- UINT32 length = strtol( str_size, NULL, 0 );
- char *s = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_name ) + 1 ) * sizeof(char) );
+ // Second, since the xml is fine, run additional checks:
- if ( !s )
- return;
+ // check for duplicate names
+ if (names.add(swinfo->shortname(), swinfo, false) == TMERR_DUPLICATE)
+ {
+ software_info *match = names.find(swinfo->shortname());
+ mame_printf_error("%s: %s is a duplicate name (%s)\n", filename(), swinfo->shortname(), match->shortname());
+ }
- strcpy( s, str_name );
+ // check for duplicate descriptions
+ if (descriptions.add(astring(swinfo->longname()).makelower().cstr(), swinfo, false) == TMERR_DUPLICATE)
+ mame_printf_error("%s: %s is a duplicate description (%s)\n", filename(), swinfo->longname(), swinfo->shortname());
- /* ROM_REGION( length, "name", flags ) */
- add_rom_entry( swlist, s, NULL, 0, length, ROMENTRYTYPE_REGION );
- }
- }
- else
- {
- /* Missing dataarea name or size ("" are invalid too) */
- parse_error(&swlist->state, "%s: Incomplete dataarea definition (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
- }
- }
- else if (!strcmp(tagname, "diskarea"))
+ bool is_clone = false;
+ if (swinfo->parentname() != NULL)
+ {
+ is_clone = true;
+ if (strcmp(swinfo->parentname(), swinfo->shortname()) == 0)
{
- const char *str_name = NULL;
-
- for ( ; attributes[0]; attributes += 2 )
- {
- if ( !strcmp( attributes[0], "name" ) )
- str_name = attributes[1];
- else
- unknown_attribute(swlist, attributes[0]);
- }
- if ( str_name )
- {
- if ( swlist->softinfo )
- {
- char *s = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_name ) + 1 ) * sizeof(char) );
-
- if ( !s )
- return;
-
- strcpy( s, str_name );
-
- /* ROM_REGION( length, "name", flags ) */
- add_rom_entry( swlist, s, NULL, 0, 1, ROMENTRYTYPE_REGION | ROMREGION_DATATYPEDISK);
- }
- }
- else
- {
- /* Missing dataarea name or size */
- parse_error(&swlist->state, "%s: Incomplete diskarea definition (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
- }
+ mame_printf_error("%s: %s is set as a clone of itself\n", filename(), swinfo->shortname());
+ break;
}
- else if ( !strcmp(tagname, "feature") )
- {
- const char *str_feature_name = NULL;
- const char *str_feature_value = NULL;
-
- for ( ; attributes[0]; attributes += 2 )
- {
- if ( !strcmp( attributes[0], "name" ) )
- str_feature_name = attributes[1];
-
- else if ( !strcmp( attributes[0], "value" ) )
- str_feature_value = attributes[1];
-
- else
- unknown_attribute(swlist, attributes[0]);
- }
-
- /* Prepare for adding feature to feature list */
- if ( str_feature_name && swlist->softinfo )
- {
- char *name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_feature_name ) + 1 ) * sizeof(char) );
- char *value = NULL;
-
- if ( !name )
- return;
- strcpy( name, str_feature_name );
+ // make sure the parent exists
+ software_info *swinfo2 = find(swinfo->parentname());
- if ( str_feature_value )
- {
- value = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_feature_value ) + 1 ) * sizeof(char) );
-
- if ( !value )
- return;
+ if (swinfo2 == NULL)
+ mame_printf_error("%s: parent '%s' software for '%s' not found\n", filename(), swinfo->parentname(), swinfo->shortname());
+ else if (swinfo2->parentname() != NULL)
+ mame_printf_error("%s: %s is a clone of a clone\n", filename(), swinfo->shortname());
+ }
- strcpy( value, str_feature_value );
- }
+ // make sure the driver name is 8 chars or less
+ if ((is_clone && strlen(swinfo->shortname()) > NAME_LEN_CLONE) || (!is_clone && strlen(swinfo->shortname()) > NAME_LEN_PARENT))
+ mame_printf_error("%s: %s %s driver name must be %d characters or less\n", filename(), swinfo->shortname(),
+ is_clone ? "clone" : "parent", is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT);
- add_feature( swlist, name, value );
- } else {
- parse_error(&swlist->state, "%s: Incomplete feature definition (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
- }
- }
- else if (!strcmp(tagname, "dipswitch"))
+ // make sure the year is only digits, '?' or '+'
+ for (const char *s = swinfo->year(); *s != 0; s++)
+ if (!isdigit((UINT8)*s) && *s != '?' && *s != '+')
{
+ mame_printf_error("%s: %s has an invalid year '%s'\n", filename(), swinfo->shortname(), swinfo->year());
+ break;
}
- else
- unknown_tag(swlist, tagname );
- break;
- case POS_DATA:
- if (!strcmp(tagname, "rom"))
- {
- const char *str_name = NULL;
- const char *str_size = NULL;
- const char *str_crc = NULL;
- const char *str_sha1 = NULL;
- const char *str_offset = NULL;
- const char *str_value = NULL;
- const char *str_status = NULL;
- const char *str_loadflag = NULL;
-
- for ( ; attributes[0]; attributes += 2 )
- {
- if ( !strcmp( attributes[0], "name" ) )
- str_name = attributes[1];
- else if ( !strcmp( attributes[0], "size" ) )
- str_size = attributes[1];
- else if ( !strcmp( attributes[0], "crc" ) )
- str_crc = attributes[1];
- else if ( !strcmp( attributes[0], "sha1" ) )
- str_sha1 = attributes[1];
- else if ( !strcmp( attributes[0], "offset" ) )
- str_offset = attributes[1];
- else if ( !strcmp( attributes[0], "value" ) )
- str_value = attributes[1];
- else if ( !strcmp( attributes[0], "status" ) )
- str_status = attributes[1];
- else if ( !strcmp( attributes[0], "loadflag" ) )
- str_loadflag = attributes[1];
- else
- unknown_attribute(swlist, attributes[0]);
- }
- if ( swlist->softinfo )
- {
- if ( str_size && str_offset )
- {
- UINT32 length = strtol( str_size, NULL, 0 );
- UINT32 offset = strtol( str_offset, NULL, 0 );
+ softlist_map part_names;
+ for (software_part *part = swinfo->first_part(); part != NULL; part = part->next())
+ {
+ if (part->interface() == NULL)
+ mame_printf_error("%s: %s has a part (%s) without interface\n", filename(), swinfo->shortname(), part->name());
- if ( str_loadflag && !strcmp(str_loadflag, "reload") )
- {
- /* Handle 'reload' loadflag */
- add_rom_entry( swlist, NULL, NULL, offset, length, ROMENTRYTYPE_RELOAD | ROM_INHERITFLAGS );
- }
- else if ( str_loadflag && !strcmp(str_loadflag, "reload_plain") )
- {
- /* Handle 'reload_plain' loadflag */
- add_rom_entry( swlist, NULL, NULL, offset, length, ROMENTRYTYPE_RELOAD);
- }
- else if ( str_loadflag && !strcmp(str_loadflag, "continue") )
- {
- /* Handle 'continue' loadflag */
- add_rom_entry( swlist, NULL, NULL, offset, length, ROMENTRYTYPE_CONTINUE | ROM_INHERITFLAGS );
- }
- else if ( str_loadflag && !strcmp(str_loadflag, "fill") )
- {
- /* Handle 'fill' loadflag */
- add_rom_entry( swlist, NULL, (const char*)(FPTR)(strtol( str_value, NULL, 0 ) & 0xff), offset, length, ROMENTRYTYPE_FILL );
- }
- else
- {
- if ( str_name)
- {
- char *s_name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_name ) + 1 ) * sizeof(char) );
- int hashsize = 7 + 4;
- if (str_crc) hashsize+= strlen(str_crc);
- if (str_sha1) hashsize+= strlen(str_sha1);
- char *hashdata = (char *)pool_malloc_lib( swlist->pool, sizeof(char) * (hashsize) );
- int baddump = ( str_status && !strcmp(str_status, "baddump") ) ? 1 : 0;
- int nodump = ( str_status && !strcmp(str_status, "nodump" ) ) ? 1 : 0;
- int romflags = 0;
-
- if ( !s_name || !hashdata )
- return;
-
- strcpy( s_name, str_name );
- if (nodump) {
- sprintf( hashdata, "%s", NO_DUMP);
- if (str_crc && str_sha1) {
- parse_error(&swlist->state, "%s: No need for hash definition (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
- }
- } else {
- if (str_crc && str_sha1) {
- sprintf( hashdata, "%c%s%c%s%s", hash_collection::HASH_CRC, str_crc, hash_collection::HASH_SHA1, str_sha1, (baddump ? BAD_DUMP : ""));
- } else {
- parse_error(&swlist->state, "%s: Incomplete rom hash definition (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
- }
- }
-
- /* Handle loadflag attribute */
- if ( str_loadflag && !strcmp(str_loadflag, "load16_word_swap") )
- romflags = ROM_GROUPWORD | ROM_REVERSE;
- else if ( str_loadflag && !strcmp(str_loadflag, "load16_byte") )
- romflags = ROM_SKIP(1);
- else if ( str_loadflag && !strcmp(str_loadflag, "load32_word_swap") )
- romflags = ROM_GROUPWORD | ROM_REVERSE | ROM_SKIP(2);
- else if ( str_loadflag && !strcmp(str_loadflag, "load32_word") )
- romflags = ROM_GROUPWORD | ROM_SKIP(2);
- else if ( str_loadflag && !strcmp(str_loadflag, "load32_byte") )
- romflags = ROM_SKIP(3);
-
- /* ROM_LOAD( name, offset, length, hash ) */
- add_rom_entry( swlist, s_name, hashdata, offset, length, ROMENTRYTYPE_ROM | romflags );
- } else {
- parse_error(&swlist->state, "%s: Rom name missing (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
- }
- }
- }
- else
- {
- /* Missing name, size, crc, sha1, or offset */
- parse_error(&swlist->state, "%s: Incomplete rom definition (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
- }
- }
- }
- else
- if (!strcmp(tagname, "disk"))
- {
- const char *str_name = NULL;
- const char *str_sha1 = NULL;
- const char *str_status = NULL;
- const char *str_writeable = NULL;
+ if (part->romdata() == NULL)
+ mame_printf_error("%s: %s has a part (%s) with no data\n", filename(), swinfo->shortname(), part->name());
- for ( ; attributes[0]; attributes += 2 )
- {
- if ( !strcmp( attributes[0], "name" ) )
- str_name = attributes[1];
- else if ( !strcmp( attributes[0], "sha1" ) )
- str_sha1 = attributes[1];
- else if ( !strcmp( attributes[0], "status" ) )
- str_status = attributes[1];
- else if ( !strcmp( attributes[0], "writeable" ) )
- str_writeable = attributes[1];
- else
- unknown_attribute(swlist, attributes[0]);
- }
- if ( swlist->softinfo )
+ if (part_names.add(part->name(), swinfo, false) == TMERR_DUPLICATE)
+ mame_printf_error("%s: %s has a part (%s) whose name is duplicate\n", filename(), swinfo->shortname(), part->name());
+
+ for (const rom_entry *data = part->romdata(); data->_name != NULL; data++)
+ if (data->_hashdata != NULL)
{
- if ( str_name && str_sha1 )
- {
- char *s_name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_name ) + 1 ) * sizeof(char) );
- char *hashdata = (char *)pool_malloc_lib( swlist->pool, sizeof(char) * ( strlen(str_sha1) + 7 + 4 ) );
- int baddump = ( str_status && !strcmp(str_status, "baddump") ) ? 1 : 0;
- int nodump = ( str_status && !strcmp(str_status, "nodump" ) ) ? 1 : 0;
- int writeable = ( str_writeable && !strcmp(str_writeable, "yes" ) ) ? 1 : 0;
-
- if ( !s_name || !hashdata )
- return;
-
- strcpy( s_name, str_name );
- sprintf( hashdata, "%c%s%s", hash_collection::HASH_SHA1, str_sha1, ( nodump ? NO_DUMP : ( baddump ? BAD_DUMP : "" ) ) );
-
- add_rom_entry( swlist, s_name, hashdata, 0, 0, ROMENTRYTYPE_ROM | (writeable ? DISK_READWRITE : DISK_READONLY ) );
- }
- else
- {
- if (!str_status || strcmp(str_status, "nodump")) // a no_dump chd is not an incomplete entry
+ // make sure it's all lowercase
+ for (const char *str = data->_name; *str; str++)
+ if (tolower((UINT8)*str) != *str)
{
- parse_error(&swlist->state, "%s: Incomplete disk definition (line %lu)\n",
- swlist->file->filename(),XML_GetCurrentLineNumber(swlist->state.parser));
+ mame_printf_error("%s: %s has upper case ROM name %s\n", filename(), swinfo->shortname(), data->_name);
+ break;
}
- }
- }
- }
- else if (!strcmp(tagname, "dipvalue"))
- {
- }
- else
- unknown_tag(swlist, tagname);
- break;
- }
- swlist->state.pos = (softlist_parse_position) (swlist->state.pos + 1);
-}
-
-/*-------------------------------------------------
- end_handler
--------------------------------------------------*/
-
-static void end_handler(void *data, const char *name)
-{
- software_list *swlist = (software_list *) data;
- swlist->state.text_dest = NULL;
-
- swlist->state.pos = (softlist_parse_position) (swlist->state.pos - 1);
- switch(swlist->state.pos)
- {
- case POS_ROOT:
- break;
- case POS_MAIN:
- if ( swlist->softinfo )
- {
- add_software_part( swlist, NULL, NULL );
- }
- break;
-
- case POS_SOFT:
- if ( ! strcmp( name, "part" ) && swlist->softinfo )
- {
- /* Was any dataarea/rom information encountered? */
- if ( swlist->softinfo->partdata[swlist->softinfo->current_part_entry-1].romdata != NULL )
- {
- /* If so, force a ROM_END */
- add_rom_entry( swlist, NULL, NULL, 0, 0, ROMENTRYTYPE_END );
- }
- /* Add shared_info inherited from the software_info level, if any */
- if ( swlist->softinfo && swlist->softinfo->shared_info )
- {
- feature_list *list = swlist->softinfo->shared_info;
-
- while( list->next )
- {
- add_feature( swlist, list->next->name, list->next->value );
- list = list->next;
- }
+ // make sure the hash is valid
+ hash_collection hashes;
+ if (!hashes.from_internal_string(data->_hashdata))
+ mame_printf_error("%s: %s has rom '%s' with an invalid hash string '%s'\n", filename(), swinfo->shortname(), data->_name, data->_hashdata);
}
- }
- break;
-
- case POS_PART:
- break;
- case POS_DATA:
- break;
- }
-}
-
-
-/*-------------------------------------------------
- data_handler
--------------------------------------------------*/
-
-static void data_handler(void *data, const XML_Char *s, int len)
-{
- software_list *swlist = (software_list *) data;
- int text_len;
- char *text;
-
- if (swlist->state.text_dest)
- {
- text = *swlist->state.text_dest;
-
- text_len = text ? strlen(text) : 0;
- text = (char*)pool_realloc_lib(swlist->pool, text, text_len + len + 1);
- if (!text)
- return;
-
- memcpy(&text[text_len], s, len);
- text[text_len + len] = '\0';
- *swlist->state.text_dest = text;
- } else {
- if (swlist->state.error_proc)
- {
- int errcnt = 0;
- for (int i=0;i<len;i++) {
- if (!(s[i]=='\t' || s[i]=='\n' || s[i]=='\r' || s[i]==' ')) errcnt++;
- }
- if (errcnt>0) {
- parse_error(&swlist->state, "%s: Unknown content (line %lu)\n",
- swlist->file->filename(),
- XML_GetCurrentLineNumber(swlist->state.parser));
- }
}
}
-}
-
-/*-------------------------------------------------
- software_list_get_count
- -------------------------------------------------*/
-
-static int software_list_get_count(const software_list *swlist)
-{
- int count = 0;
-
- for (const software_info *swinfo = software_list_find(swlist, "*", NULL); swinfo != NULL; swinfo = software_list_find(swlist, "*", swinfo))
- count++;
-
- return count;
+ // release all the memory
+ release();
}
-/*-------------------------------------------------
- software_get_clone - retrive name string of the
- parent software, if any
- -------------------------------------------------*/
-
-const char *software_get_clone(emu_options &options, char *swlist, const char *swname)
-{
- const software_list *software_list_ptr = software_list_open(options, swlist, FALSE, NULL);
- const char *retval = NULL;
- if (software_list_ptr)
- {
- const software_info *tmp = software_list_find(software_list_ptr, swname, NULL);
- retval = core_strdup(tmp->parentname);
- software_list_close(software_list_ptr);
- }
-
- return retval;
-}
-
-
-/*-------------------------------------------------
- software_get_support - retrive support state of
- the software
- -------------------------------------------------*/
-
-UINT32 software_get_support(emu_options &options, char *swlist, const char *swname)
-{
- const software_list *software_list_ptr = software_list_open(options, swlist, FALSE, NULL);
- UINT32 retval = 0;
-
- if (software_list_ptr)
- {
- const software_info *tmp = software_list_find(software_list_ptr, swname, NULL);
- retval = tmp->supported;
- software_list_close(software_list_ptr);
- }
-
- return retval;
-}
+//**************************************************************************
+// SOFTWARE LIST PARSER
+//**************************************************************************
-/*-------------------------------------------------
- software_list_parse
--------------------------------------------------*/
+//-------------------------------------------------
+// softlist_parser - constructor
+//-------------------------------------------------
-void software_list_parse(software_list *swlist,
- void (*error_proc)(const char *message),
- void *param)
+softlist_parser::softlist_parser(software_list_device &list, astring &errors)
+ : m_list(list),
+ m_errors(errors),
+ m_done(false),
+ m_data_accum_expected(false),
+ m_current_info(NULL),
+ m_current_part(NULL),
+ m_pos(POS_ROOT)
{
- char buf[1024];
- UINT32 len;
+fprintf(stderr, "Parsing %s\n", m_list.m_file.filename());
+ // set up memory callbacks
XML_Memory_Handling_Suite memcallbacks;
-
- swlist->file->seek(0, SEEK_SET);
-
- memset(&swlist->state, 0, sizeof(swlist->state));
- swlist->state.error_proc = error_proc;
- swlist->state.param = param;
-
- /* create the XML parser */
memcallbacks.malloc_fcn = expat_malloc;
memcallbacks.realloc_fcn = expat_realloc;
memcallbacks.free_fcn = expat_free;
- swlist->state.parser = XML_ParserCreate_MM(NULL, &memcallbacks, NULL);
- if (!swlist->state.parser)
- goto done;
- XML_SetUserData(swlist->state.parser, swlist);
- XML_SetElementHandler(swlist->state.parser, start_handler, end_handler);
- XML_SetCharacterDataHandler(swlist->state.parser, data_handler);
+ // create the parser
+ m_parser = XML_ParserCreate_MM(NULL, &memcallbacks, NULL);
+ if (m_parser == NULL)
+ throw std::bad_alloc();
+
+ // set the handlers
+ XML_SetUserData(m_parser, this);
+ XML_SetElementHandler(m_parser, &softlist_parser::start_handler, &softlist_parser::end_handler);
+ XML_SetCharacterDataHandler(m_parser, &softlist_parser::data_handler);
- while(!swlist->state.done)
+ // parse the file contents
+ m_list.m_file.seek(0, SEEK_SET);
+ char buffer[1024];
+ while (!m_done)
{
- len = swlist->file->read(buf, sizeof(buf));
- swlist->state.done = swlist->file->eof();
- if (XML_Parse(swlist->state.parser, buf, len, swlist->state.done) == XML_STATUS_ERROR)
+ UINT32 length = m_list.m_file.read(buffer, sizeof(buffer));
+ m_done = m_list.m_file.eof();
+ if (XML_Parse(m_parser, buffer, length, m_done) == XML_STATUS_ERROR)
{
- parse_error(&swlist->state, "%s: %s (line %lu column %lu)\n",
- swlist->file->filename(),
- XML_ErrorString(XML_GetErrorCode(swlist->state.parser)),
- XML_GetCurrentLineNumber(swlist->state.parser),
- XML_GetCurrentColumnNumber(swlist->state.parser));
- goto done;
+ parse_error("%s", parser_error());
+ break;
}
}
-done:
- if (swlist->state.parser)
- XML_ParserFree(swlist->state.parser);
- swlist->state.parser = NULL;
- swlist->current_software_info = swlist->software_info_list;
- swlist->list_entries = software_list_get_count(swlist);
+ // free the parser
+ XML_ParserFree(m_parser);
+fprintf(stderr, "Parsing complete\n");
}
-/*-------------------------------------------------
- software_list_open
--------------------------------------------------*/
+//-------------------------------------------------
+// expat_malloc/expat_realloc/expat_free -
+// wrappers for memory allocation functions so
+// that they pass through out memory tracking
+// systems
+//-------------------------------------------------
-software_list *software_list_open(emu_options &options, const char *listname, int is_preload,
- void (*error_proc)(const char *message))
+void *softlist_parser::expat_malloc(size_t size)
{
- software_list *swlist = NULL;
- object_pool *pool = NULL;
- file_error filerr;
-
- /* create a pool for this software list file */
- pool = pool_alloc_lib(error_proc);
- if (!pool)
- goto error;
-
- /* allocate space for this software list file */
- swlist = (software_list *) pool_malloc_lib(pool, sizeof(*swlist));
- if (!swlist)
- goto error;
-
- /* set up the software_list structure */
- memset(swlist, 0, sizeof(*swlist));
- swlist->pool = pool;
- swlist->error_proc = error_proc;
-
- /* open a file */
- swlist->file = global_alloc(emu_file(options.hash_path(), OPEN_FLAG_READ));
- filerr = swlist->file->open(listname, ".xml");
- if (filerr != FILERR_NONE)
- goto error;
-
- if (is_preload)
- {
- software_list_parse(swlist, swlist->error_proc, NULL);
- swlist->current_software_info = NULL;
- }
-
- return swlist;
-
-error:
- if (swlist != NULL)
- software_list_close(swlist);
- return NULL;
+ return global_alloc_array_clear(UINT8, size);
}
-
-/*-------------------------------------------------
- software_list_close
--------------------------------------------------*/
-
-void software_list_close(const software_list *swlist)
+void *softlist_parser::expat_realloc(void *ptr, size_t size)
{
- if (swlist == NULL)
- return;
-
- if (swlist->file != NULL)
- global_free(swlist->file);
- pool_free_lib(swlist->pool);
+ if (ptr != NULL) global_free_array((UINT8 *)ptr);
+ return global_alloc_array_clear(UINT8, size);
}
-
-/*-------------------------------------------------
- software_list_get_description
- -------------------------------------------------*/
-
-const char *software_list_get_description(const software_list *swlist)
+void softlist_parser::expat_free(void *ptr)
{
- return swlist->description;
+ global_free_array((UINT8 *)ptr);
}
-#if 0
-/*-------------------------------------------------
- software_list_find_by_number
- -------------------------------------------------*/
+//-------------------------------------------------
+// parse_error - append a parsing error with
+// filename, line and column information
+//-------------------------------------------------
-INLINE software_info *software_list_find_by_number(software_list *swlist, int number)
+void ATTR_PRINTF(2,3) softlist_parser::parse_error(const char *fmt, ...)
{
- int length = swlist->list_entries;
- if (number > length)
- return NULL;
-
- software_info *cur_info = software_list_find(swlist, "*", NULL);
-
- for (int count = 0; count < number; count++)
- cur_info = software_list_find(swlist, "*", cur_info);
-
- return cur_info;
+ // always start with filename(line.column):
+ m_errors.catprintf("%s(%d.%d): ", filename(), line(), column());
+
+ // append the remainder of the string
+ va_list va;
+ va_start(va, fmt);
+ m_errors.catvprintf(fmt, va);
+ va_end(va);
+
+ // append a newline at the end
+ m_errors.cat("\n");
}
-#endif
-/*-------------------------------------------------
- softlist_penalty_compare (borrowed from driver.c)
- -------------------------------------------------*/
+//-------------------------------------------------
+// parse_attributes - helper to parse a set of
+// attributes into a list of strings
+//-------------------------------------------------
-static int softlist_penalty_compare(const char *source, const char *target)
+void softlist_parser::parse_attributes(const char **attributes, int numattrs, const char *attrlist[], const char *outlist[])
{
- int gaps = 1;
- int last = TRUE;
-
- /* scan the strings */
- for ( ; *source && *target; target++)
+ // iterate over attribute/value pairs
+ for( ; attributes[0]; attributes += 2)
{
- /* do a case insensitive match */
- int match = (tolower((UINT8)*source) == tolower((UINT8)*target));
-
- /* if we matched, advance the source */
- if (match)
- source++;
-
- /* if the match state changed, count gaps */
- if (match != last)
- {
- last = match;
- if (!match)
- gaps++;
- }
+ int index;
+
+ // look for a match among the attributes provided
+ for (index = 0; index < numattrs; index++)
+ if (strcmp(attributes[0], attrlist[index]) == 0)
+ {
+ // if found, set the corresponding output entry to the value
+ outlist[index] = attributes[1];
+ break;
+ }
+
+ // if not found, report an unknown attribute
+ if (index == numattrs)
+ unknown_attribute(attributes[0]);
}
-
- /* penalty if short string does not completely fit in */
- for ( ; *source; source++)
- gaps++;
-
- /* if we matched perfectly, gaps == 0 */
- if (gaps == 1 && *source == 0 && *target == 0)
- gaps = 0;
-
- return gaps;
}
-/*-------------------------------------------------
- software_list_find_approx_matches
- -------------------------------------------------*/
+//-------------------------------------------------
+// add_rom_entry - append a new ROM entry to the
+// current part's list
+//-------------------------------------------------
-void software_list_find_approx_matches(software_list_device *swlistdev, software_list *swlist, const char *name, int matches, software_info **list, const char* interface)
+void softlist_parser::add_rom_entry(const char *name, const char *hashdata, UINT32 offset, UINT32 length, UINT32 flags)
{
-#undef rand
-
- int matchnum;
- int *penalty;
-
- /* if no name, return */
- if (name == NULL || name[0] == 0)
- return;
-
- /* allocate some temp memory */
- penalty = global_alloc_array(int, matches);
-
- /* initialize everyone's states */
- for (matchnum = 0; matchnum < matches; matchnum++)
- {
- penalty[matchnum] = 9999;
- list[matchnum] = NULL;
- }
-
- for (software_info *swinfo = software_list_find(swlist, "*", NULL); swinfo != NULL; swinfo = software_list_find(swlist, "*", swinfo))
+ // get the current part
+ if (m_current_part == NULL)
{
- int curpenalty, tmp;
- software_info *candidate = swinfo;
-
- software_part *part = software_find_part(swinfo, NULL, NULL);
- if ((interface==NULL || softlist_contain_interface(interface, part->interface_)) && (is_software_compatible(part, swlistdev)))
- {
- /* pick the best match between driver name and description */
- curpenalty = softlist_penalty_compare(name, candidate->longname);
- tmp = softlist_penalty_compare(name, candidate->shortname);
- curpenalty = MIN(curpenalty, tmp);
-
- /* insert into the sorted table of matches */
- for (matchnum = matches - 1; matchnum >= 0; matchnum--)
- {
- /* stop if we're worse than the current entry */
- if (curpenalty >= penalty[matchnum])
- break;
-
- /* as long as this isn't the last entry, bump this one down */
- if (matchnum < matches - 1)
- {
- penalty[matchnum + 1] = penalty[matchnum];
- list[matchnum + 1] = list[matchnum];
- }
- list[matchnum] = candidate;
- penalty[matchnum] = curpenalty;
- }
- }
+ parse_error("ROM entry added in invalid context");
+ return;
}
- /* free our temp memory */
- global_free(penalty);
+ // make sure we don't add duplicate regions
+ if (name != NULL && (flags & ROMENTRY_TYPEMASK) == ROMENTRYTYPE_REGION)
+ for (int romentry = 0; romentry < m_current_part->m_romdata.count(); romentry++)
+ if (m_current_part->m_romdata[romentry]._name != NULL && strcmp(m_current_part->m_romdata[romentry]._name, name) == 0)
+ parse_error("Duplicated dataarea %s in software %s", name, infoname());
+
+ // create the new entry and append it
+ rom_entry &entry = m_current_part->m_romdata.append();
+ entry._name = m_list.add_string(name);
+ entry._hashdata = m_list.add_string(hashdata);
+ entry._offset = offset;
+ entry._length = length;
+ entry._flags = flags;
}
-/*-------------------------------------------------
- software_list_find
--------------------------------------------------*/
+//-------------------------------------------------
+// start_handler - expat handler for tag start
+//-------------------------------------------------
-const software_info *software_list_find(const software_list *swlist, const char *look_for, const software_info *prev)
+void softlist_parser::start_handler(void *data, const char *tagname, const char **attributes)
{
- if (swlist == NULL)
- return NULL;
-
- if (look_for == NULL)
- return NULL;
+ // switch off the current state
+ softlist_parser *state = reinterpret_cast<softlist_parser *>(data);
+ switch (state->m_pos)
+ {
+ case POS_ROOT:
+ state->parse_root_start(tagname, attributes);
+ break;
- /* If we haven't read in the xml file yet, then do it now */
- /* Just-in-time parsing, hence the const-cast */
- if ( ! swlist->software_info_list )
- software_list_parse( const_cast<software_list *>(swlist), swlist->error_proc, NULL );
+ case POS_MAIN:
+ state->parse_main_start(tagname, attributes);
+ break;
- for ( prev = prev ? prev->next : swlist->software_info_list; prev; prev = prev->next )
- {
- if ( !mame_strwildcmp( look_for, prev->shortname ) )
+ case POS_SOFT:
+ state->parse_soft_start(tagname, attributes);
+ break;
+
+ case POS_PART:
+ state->parse_part_start(tagname, attributes);
+ break;
+
+ case POS_DATA:
+ state->parse_data_start(tagname, attributes);
break;
}
-
- return prev;
+
+ // increment the state since this is a tag start
+ state->m_pos = parse_position(state->m_pos + 1);
}
-software_info *software_list_find(software_list *swlist, const char *look_for, software_info *prev)
-{
- return const_cast<software_info *>(software_list_find(const_cast<const software_list *>(swlist),
- look_for,
- const_cast<const software_info *>(prev)));
-}
-/*-------------------------------------------------
- software_find_romdata (for validation purposes)
- -------------------------------------------------*/
+//-------------------------------------------------
+// end_handler - handle end-of-tag post-processing
+//-------------------------------------------------
-static struct rom_entry *software_find_romdata(software_part *swpart, const char *dataname)
+void softlist_parser::end_handler(void *data, const char *name)
{
- struct rom_entry *data = swpart ? swpart->romdata : NULL;
+ // reset the text destination and bump the position down
+ softlist_parser *state = reinterpret_cast<softlist_parser *>(data);
+ state->m_pos = parse_position(state->m_pos - 1);
- /* If no dataname supplied, then we just return the first entry */
- if (data)
+ // switch off of the new position
+ switch (state->m_pos)
{
- while(data && data->_name)
- {
- if (dataname)
- {
- if (!strcmp(dataname, data->_name))
- {
- break;
- }
- }
- /* No specific dataname supplied, return the first rom_entry */
- else
- break;
-
- data++;
- }
-
- if (data && !data->_name)
- data = NULL;
- }
+ case POS_ROOT:
+ break;
- return data;
-}
+ case POS_MAIN:
+ state->m_current_info = NULL;
+ break;
+ case POS_SOFT:
+ state->parse_soft_end(name);
+ state->m_current_part = NULL;
+ break;
-/*-------------------------------------------------
- software_romdata_next (for validation purposes)
- -------------------------------------------------*/
+ case POS_PART:
+ break;
-static struct rom_entry *software_romdata_next(struct rom_entry *romdata)
-{
- if (romdata && romdata->_name)
- {
- romdata++;
+ case POS_DATA:
+ break;
}
- else
- romdata = NULL;
-
- return romdata;
+
+ // stop accumulating
+ state->m_data_accum_expected = false;
+ state->m_data_accum.reset();
}
-/*-------------------------------------------------
- software_find_part
--------------------------------------------------*/
+//-------------------------------------------------
+// data_handler - expat data handler
+//-------------------------------------------------
-const software_part *software_find_part(const software_info *sw, const char *partname, const char *interface)
+void softlist_parser::data_handler(void *data, const XML_Char *s, int len)
{
- const software_part *part = sw ? sw->partdata : NULL;
+ softlist_parser *state = reinterpret_cast<softlist_parser *>(data);
- /* If neither partname nor interface supplied, then we just return the first entry */
- if ( partname || interface )
- {
- while( part && part->name )
- {
- if ( partname )
- {
- if ( !strcmp(partname, part->name ) )
- {
- if ( interface )
- {
- if ( softlist_contain_interface(interface, part->interface_) )
- {
- break;
- }
- }
- else
- {
- break;
- }
- }
- }
- else
+ // if we have an astring to accumulate data in, do it
+ if (state->m_data_accum_expected)
+ state->m_data_accum.cat(s, len);
+
+ // otherwise, report an error if the data is non-blank
+ else
+ for (int i = 0; i < len; i++)
+ if (!isspace(s[i]))
{
- /* No specific partname supplied, find the first match based on interface */
- if ( interface )
- {
- if ( softlist_contain_interface(interface, part->interface_) )
- {
- break;
- }
- }
+ state->parse_error("Unexpected content");
+ break;
}
- part++;
- }
- }
-
- if ( part && ! part->name )
- part = NULL;
-
- return part;
}
-software_part *software_find_part(software_info *sw, const char *partname, const char *interface)
-{
- return const_cast<software_part *>(software_find_part(const_cast<const software_info *>(sw), partname, interface));
-}
-/*-------------------------------------------------
- software_part_next
--------------------------------------------------*/
+//-------------------------------------------------
+// parse_root_start - handle tag start at the root
+//-------------------------------------------------
-const software_part *software_part_next(const software_part *part)
+void softlist_parser::parse_root_start(const char *tagname, const char **attributes)
{
- if ( part && part->name )
+ // <softwarelist name='' description=''>
+ if (strcmp(tagname, "softwarelist") == 0)
{
- part++;
+ static const char *attrnames[] = { "name", "description" };
+ const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 };
+ parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues);
+
+ if (attrvalues[1] != NULL)
+ m_list.m_description = m_list.add_string(attrvalues[1]);
}
-
- if ( ! part->name )
- part = NULL;
-
- return part;
+ else
+ unknown_tag(tagname);
}
-software_part *software_part_next(software_part *part)
-{
- return const_cast<software_part *>(software_part_next(const_cast<const software_part *>(part)));
-}
-/*-------------------------------------------------
- software_display_matches
--------------------------------------------------*/
+//-------------------------------------------------
+// parse_main_start - handle tag start within
+// a softwarelist tag
+//-------------------------------------------------
-void software_display_matches(const machine_config &config,emu_options &options, const char *interface ,const char *name)
+void softlist_parser::parse_main_start(const char *tagname, const char **attributes)
{
- // check if there is at least a software list
- software_list_device_iterator deviter(config.root_device());
- if (deviter.first())
- {
- mame_printf_error("\n\"%s\" approximately matches the following\n"
- "supported software items (best match first):\n\n", name);
- }
-
- for (software_list_device *swlist = deviter.first(); swlist != NULL; swlist = deviter.next())
+ // <software name='' cloneof='' supported=''>
+ if (strcmp(tagname, "software") == 0)
{
- software_list *list = software_list_open(options, swlist->list_name(), FALSE, NULL);
-
- if (list)
- {
- software_info *matches[16] = { 0 };
- int softnum;
-
- software_list_parse(list, list->error_proc, NULL);
- // get the top 16 approximate matches for the selected device interface (i.e. only carts for cartslot, etc.)
- software_list_find_approx_matches(swlist, list, name, ARRAY_LENGTH(matches), matches, interface);
+ static const char *attrnames[] = { "name", "cloneof", "supported" };
+ const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 };
+ parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues);
- if (matches[0] != 0)
- {
- if (swlist->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
- mame_printf_error("* Software list \"%s\" (%s) matches: \n", swlist->list_name(), software_list_get_description(list));
- else
- mame_printf_error("* Compatible software list \"%s\" (%s) matches: \n", swlist->list_name(), software_list_get_description(list));
-
- // print them out
- for (softnum = 0; softnum < ARRAY_LENGTH(matches); softnum++)
- if (matches[softnum] != NULL)
- mame_printf_error("%-18s%s\n", matches[softnum]->shortname, matches[softnum]->longname);
-
- mame_printf_error("\n");
- }
- software_list_close(list);
- }
+ if (attrvalues[0] != NULL)
+ m_current_info = &m_list.m_infolist.append(*global_alloc(software_info(m_list, m_list.add_string(attrvalues[0]), m_list.add_string(attrvalues[1]), attrvalues[2])));
+ else
+ parse_error("No name defined for item");
}
+ else
+ unknown_tag(tagname);
}
-static void find_software_item(const machine_config &config, emu_options &options, const device_image_interface *image, const char *path, software_list **software_list_ptr, software_info **software_info_ptr,software_part **software_part_ptr, const char **sw_list_name)
-{
- char *swlist_name, *swname, *swpart; //, *swname_bckp;
- *software_list_ptr = NULL;
- *software_info_ptr = NULL;
- *software_part_ptr = NULL;
-
- /* Split full software name into software list name and short software name */
- software_name_split(path, &swlist_name, &swname, &swpart );
-// swname_bckp = swname;
- const char *interface = NULL;
- if (image) interface = image->image_interface();
+//-------------------------------------------------
+// parse_main_start - handle tag start within
+// a software tag
+//-------------------------------------------------
- if ( swlist_name )
+void softlist_parser::parse_soft_start(const char *tagname, const char **attributes)
+{
+ // get the current info; error if none
+ if (m_current_info == NULL)
{
- /* Try to open the software list xml file explicitly named by the user */
- *software_list_ptr = software_list_open( options, swlist_name, FALSE, NULL );
-
- if ( *software_list_ptr )
- {
- *software_info_ptr = software_list_find( *software_list_ptr, swname, NULL );
-
- if ( *software_info_ptr )
- {
- *software_part_ptr = software_find_part( *software_info_ptr, swpart, interface );
- }
- }
+ parse_error("Tag %s found outside of software context", tagname);
+ return;
}
- else
- {
- /* Loop through all the software lists named in the driver */
- software_list_device_iterator deviter(config.root_device());
- for (software_list_device *swlist = deviter.first(); swlist != NULL; swlist = deviter.next())
- {
- swlist_name = (char *)swlist->list_name();
- if (swlist->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
- {
- if ( *software_list_ptr )
- {
- software_list_close( *software_list_ptr );
- }
+ // <description>
+ if (strcmp(tagname, "description") == 0)
+ m_data_accum_expected = true;
- *software_list_ptr = software_list_open( options, swlist_name, FALSE, NULL );
+ // <year>
+ else if (strcmp(tagname, "year") == 0)
+ m_data_accum_expected = true;
- if ( software_list_ptr )
- {
- *software_info_ptr = software_list_find( *software_list_ptr, swname, NULL );
-
- if ( *software_info_ptr )
- {
- *software_part_ptr = software_find_part( *software_info_ptr, swpart, interface );
- if (*software_part_ptr) break;
- }
- }
- }
- }
-
- /* If not found try to load the software list using the driver name */
- if ( ! *software_part_ptr )
- {
- swlist_name = (char *)options.system()->name;
+ // <publisher>
+ else if (strcmp(tagname, "publisher") == 0)
+ m_data_accum_expected = true;
- if ( *software_list_ptr )
- {
- software_list_close( *software_list_ptr );
- }
-
- *software_list_ptr = software_list_open( options, swlist_name, FALSE, NULL );
-
- if ( *software_list_ptr )
- {
- *software_info_ptr = software_list_find( *software_list_ptr, swname, NULL );
-
- if ( *software_info_ptr )
- {
- *software_part_ptr = software_find_part( *software_info_ptr, swpart, interface );
- }
- }
- }
-
- /* If not found try to load the software list using the software name as software */
- /* list name and software part name as software name. */
- if ( ! *software_part_ptr )
- {
- swlist_name = swname;
- swname = swpart;
- swpart = NULL;
-
- if ( *software_list_ptr )
- {
- software_list_close( *software_list_ptr );
- }
-
- *software_list_ptr = software_list_open( options, swlist_name, FALSE, NULL );
-
- if ( software_list_ptr )
- {
- *software_info_ptr = software_list_find( *software_list_ptr, swname, NULL );
-
- if ( *software_info_ptr )
- {
- *software_part_ptr = software_find_part( *software_info_ptr, swpart, interface );
- }
+ // <info name='' value=''>
+ else if (strcmp(tagname, "info") == 0)
+ {
+ static const char *attrnames[] = { "name", "value" };
+ const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 };
+ parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues);
- if ( ! *software_part_ptr )
- {
- software_list_close( *software_list_ptr );
- *software_list_ptr = NULL;
- }
- }
- }
+ if (attrvalues[0] != NULL && attrvalues[1] != NULL)
+ m_current_info->m_other_info.append(*global_alloc(feature_list_item(m_list.add_string(attrvalues[0]), m_list.add_string(attrvalues[1]))));
+ else
+ parse_error("Incomplete other_info definition");
}
- *sw_list_name = global_strdup(swlist_name);
-
- global_free( swlist_name );
- global_free( swname );
- global_free( swpart );
-}
-
-/*-------------------------------------------------
- load_software_part
-
- Load a software part for a device. The part to
- load is determined by the "path", software lists
- configured for a driver, and the interface
- supported by the device.
-
- returns true if the software could be loaded,
- false otherwise. If the software could be loaded
- sw_info and sw_part are also set.
--------------------------------------------------*/
-
-bool load_software_part(emu_options &options, device_image_interface *image, const char *path, software_info **sw_info, software_part **sw_part, char **full_sw_name, char**list_name)
-{
- software_list *software_list_ptr = NULL;
- software_info *software_info_ptr = NULL;
- software_part *software_part_ptr = NULL;
- const char *swlist_name = NULL;
-
- bool result = false;
- *sw_info = NULL;
- *sw_part = NULL;
- *list_name = NULL;
-
- find_software_item(image->device().machine().config(), options, image, path, &software_list_ptr, &software_info_ptr, &software_part_ptr, &swlist_name);
-
- // if no match has been found, we suggest similar shortnames
- if (software_info_ptr == NULL)
+
+ // <sharedfeat name='' value=''>
+ else if (strcmp(tagname, "sharedfeat") == 0)
{
- software_display_matches(image->device().machine().config(),image->device().machine().options(), image->image_interface(), path);
+ static const char *attrnames[] = { "name", "value" };
+ const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 };
+ parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues);
+
+ if (attrvalues[0] != NULL && attrvalues[1] != NULL)
+ m_current_info->m_shared_info.append(*global_alloc(feature_list_item(m_list.add_string(attrvalues[0]), m_list.add_string(attrvalues[1]))));
+ else
+ parse_error("Incomplete sharedfeat definition");
}
-
- if ( software_part_ptr )
+
+ // <part name='' interface=''>
+ else if (strcmp(tagname, "part" ) == 0)
{
- /* Load the software part */
- try {
- result = image->call_softlist_load((char *)swlist_name, (char *)software_info_ptr->shortname, software_part_ptr->romdata );
- }
- catch (emu_fatalerror &fatal)
- {
- software_list_close( software_list_ptr );
- global_free(swlist_name);
- throw fatal;
- }
-
- /* Sanity checks */
- if (software_info_ptr->shortname == NULL)
- throw emu_fatalerror("Software entry is missing the name attribute!\n");
- if (software_info_ptr->longname == NULL)
- throw emu_fatalerror("Software entry '%s' is missing the description element!\n", software_info_ptr->shortname);
-
- /* Create a copy of the software and part information */
- *sw_info = auto_alloc_clear( image->device().machine(), software_info );
- (*sw_info)->shortname = auto_strdup( image->device().machine(), software_info_ptr->shortname );
- (*sw_info)->longname = auto_strdup( image->device().machine(), software_info_ptr->longname );
- if ( software_info_ptr->year )
- (*sw_info)->year = auto_strdup( image->device().machine(), software_info_ptr->year );
- if ( software_info_ptr->publisher )
- (*sw_info)->publisher = auto_strdup( image->device().machine(), software_info_ptr->publisher );
-
- (*sw_info)->partdata = (software_part *)auto_alloc_array_clear(image->device().machine(), UINT8, software_info_ptr->part_entries * sizeof(software_part) );
- software_part *new_part = (*sw_info)->partdata;
- for (software_part *swp = software_find_part(software_info_ptr, NULL, NULL); swp != NULL; swp = software_part_next(swp))
- {
- if (strcmp(software_part_ptr->name,swp->name)==0) *sw_part = new_part;
-
- new_part->name = auto_strdup( image->device().machine(), swp->name );
- if ( swp->interface_ )
- new_part->interface_ = auto_strdup( image->device().machine(), swp->interface_ );
-
- if ( swp->featurelist )
- {
- feature_list *list = swp->featurelist;
- feature_list *new_list = auto_alloc_clear( image->device().machine(), feature_list );
-
- new_part->featurelist = new_list;
-
- new_list->name = auto_strdup( image->device().machine(), list->name );
- new_list->value = auto_strdup( image->device().machine(), list->value );
-
- list = list->next;
-
- while( list )
- {
- new_list->next = auto_alloc_clear( image->device().machine(), feature_list );
- new_list = new_list->next;
- new_list->name = auto_strdup( image->device().machine(), list->name );
- new_list->value = auto_strdup( image->device().machine(), list->value );
+ static const char *attrnames[] = { "name", "interface" };
+ const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 };
+ parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues);
- list = list->next;
- }
- new_list->next = NULL;
- }
- new_part++;
- }
- *list_name = auto_strdup( image->device().machine(), swlist_name );
-
- /* Tell the world which part we actually loaded */
- *full_sw_name = auto_alloc_array( image->device().machine(), char, strlen(swlist_name) + strlen(software_info_ptr->shortname) + strlen(software_part_ptr->name) + 3 );
- sprintf( *full_sw_name, "%s:%s:%s", swlist_name, software_info_ptr->shortname, software_part_ptr->name );
-
- software_list_device_iterator iter(image->device().machine().root_device());
- for (software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
- {
- if (strcmp(swlist->list_name(),swlist_name)==0) {
- if (!is_software_compatible(software_part_ptr, swlist)) {
- mame_printf_warning("WARNING! the set %s might not work on this system due to missing filter(s) '%s'\n",software_info_ptr->shortname,swlist->filter());
- }
- break;
- }
- }
-
- {
- const char *requirement = software_part_get_feature(software_part_ptr, "requirement");
- if (requirement!=NULL) {
- software_list *req_software_list_ptr = NULL;
- software_info *req_software_info_ptr = NULL;
- software_part *req_software_part_ptr = NULL;
- const char *req_swlist_name = NULL;
-
- find_software_item(image->device().machine().config(), options, NULL, requirement, &req_software_list_ptr, &req_software_info_ptr, &req_software_part_ptr, &req_swlist_name);
-
- if ( req_software_list_ptr )
- {
- image_interface_iterator imgiter(image->device().machine().root_device());
- for (device_image_interface *req_image = imgiter.first(); req_image != NULL; req_image = imgiter.next())
- {
- const char *interface = req_image->image_interface();
- if (interface != NULL)
- {
- if (softlist_contain_interface(interface, req_software_part_ptr->interface_))
- {
- const char *option = options.value(req_image->brief_instance_name());
- // mount only if not already mounted
- if (strlen(option)==0 && !req_image->filename()) {
- req_image->set_init_phase();
- req_image->load(requirement);
- }
- break;
- }
- }
- }
- software_list_close( req_software_list_ptr );
- req_software_info_ptr = NULL;
- req_software_list_ptr = NULL;
- global_free(req_swlist_name);
- }
- }
- }
- }
-
- /* Close the software list if it's still open */
- if ( software_list_ptr )
- {
- software_list_close( software_list_ptr );
- software_info_ptr = NULL;
- software_list_ptr = NULL;
+ if (attrvalues[0] != NULL && attrvalues[1] != NULL && strcmp(attrvalues[0], "") != 0 && strcmp(attrvalues[1], "") != 0)
+ m_current_part = &m_current_info->m_partdata.append(*global_alloc(software_part(*m_current_info, m_list.add_string(attrvalues[0]), m_list.add_string(attrvalues[1]))));
+ else
+ parse_error("Incomplete part definition");
}
- global_free(swlist_name);
- return result;
+ else
+ unknown_tag(tagname);
}
-/*-------------------------------------------------
- software_part_get_feature
- -------------------------------------------------*/
+//-------------------------------------------------
+// parse_part_start - handle tag start within
+// a part tag
+//-------------------------------------------------
-const char *software_part_get_feature(const software_part *part, const char *feature_name)
+void softlist_parser::parse_part_start(const char *tagname, const char **attributes)
{
- const feature_list *feature;
-
- if (part == NULL)
- return NULL;
-
- for (feature = part->featurelist; feature; feature = feature->next)
+ // get the current part; error if none
+ if (m_current_part == NULL)
{
- if (!strcmp(feature->name, feature_name))
- return feature->value;
- }
-
- return NULL;
-
-}
-
-/*-------------------------------------------------
- software_get_default_slot
- -------------------------------------------------*/
-
- const char *software_get_default_slot(const machine_config &config, emu_options &options, const device_image_interface *image, const char* default_card_slot)
-{
- const char* retVal = NULL;
- const char* path = options.value(image->instance_name());
- software_list *software_list_ptr = NULL;
- software_info *software_info_ptr = NULL;
- software_part *software_part_ptr = NULL;
- const char *swlist_name = NULL;
-
- if (strlen(path)>0) {
- retVal = default_card_slot;
- find_software_item(config, options, image, path, &software_list_ptr, &software_info_ptr, &software_part_ptr, &swlist_name);
- if (software_part_ptr!=NULL) {
- const char *slot = software_part_get_feature(software_part_ptr, "slot");
- if (slot!=NULL) {
- retVal = core_strdup(slot);
- }
- }
- software_list_close(software_list_ptr);
- global_free(swlist_name);
+ parse_error("Tag %s found outside of part context", tagname);
+ return;
}
- return retVal;
-}
-
-/*-------------------------------------------------
- is_software_compatible
- -------------------------------------------------*/
-bool is_software_compatible(const software_part *swpart, const software_list_device *swlist)
-{
- const char *compatibility = software_part_get_feature(swpart, "compatibility");
- const char *filter = swlist->filter();
- if ((compatibility==NULL) || (filter==NULL)) return TRUE;
- astring comp = astring(compatibility,",");
- char *filt = core_strdup(filter);
- char *token = strtok(filt,",");
- while (token!= NULL)
+ // <dataarea name='' size=''>
+ if (strcmp(tagname, "dataarea") == 0)
{
- if (comp.find(0,astring(token,","))!=-1) return TRUE;
- token = strtok (NULL, ",");
+ static const char *attrnames[] = { "name", "size" };
+ const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 };
+ parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues);
+
+ if (attrvalues[0] != NULL && attrvalues[1] != NULL && strcmp(attrvalues[0], "") != 0 && strcmp(attrvalues[1], "") != 0)
+ add_rom_entry(attrvalues[0], NULL, 0, strtol(attrvalues[1], NULL, 0), ROMENTRYTYPE_REGION);
+ else
+ parse_error("Incomplete dataarea definition");
}
- return FALSE;
-}
-
-/*-------------------------------------------------
- swinfo_has_multiple_parts
- -------------------------------------------------*/
-
-bool swinfo_has_multiple_parts(const software_info *swinfo, const char *interface)
-{
- int count = 0;
+
+ // <diskarea name=''>
+ else if (strcmp(tagname, "diskarea") == 0)
+ {
+ static const char *attrnames[] = { "name" };
+ const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 };
+ parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues);
- for (const software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
+ if (attrvalues[0] != NULL)
+ add_rom_entry(attrvalues[0], NULL, 0, 1, ROMENTRYTYPE_REGION | ROMREGION_DATATYPEDISK);
+ else
+ parse_error("Incomplete diskarea definition");
+ }
+
+ // <feature name='' value=''>
+ else if (strcmp(tagname, "feature") == 0)
{
- if (softlist_contain_interface(interface, swpart->interface_))
- count++;
+ static const char *attrnames[] = { "name", "value" };
+ const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 };
+ parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues);
+
+ if (attrvalues[0] != NULL)
+ m_current_part->m_featurelist.append(*global_alloc(feature_list_item(m_list.add_string(attrvalues[0]), m_list.add_string(attrvalues[1]))));
+ else
+ parse_error("Incomplete feature definition");
}
- return (count > 1) ? true : false;
+
+ // <dipswitch>
+ else if (strcmp(tagname, "dipswitch") == 0)
+ ;
+ else
+ unknown_tag(tagname);
}
-/***************************************************************************
- DEVICE INTERFACE
-***************************************************************************/
-
-void validate_error_proc(const char *message)
-{
- mame_printf_error("%s", message);
-}
+//-------------------------------------------------
+// parse_data_start - handle tag start within a
+// dataarea or diskarea tag
+//-------------------------------------------------
-void software_list_device::device_validity_check(validity_checker &valid) const
+void softlist_parser::parse_data_start(const char *tagname, const char **attributes)
{
- // add to the global map whenever we check a list so we don't re-check
- // it in the future
- if (s_checked_lists.add(m_list_name, 1, false) == TMERR_DUPLICATE)
+ // get the current part; error if none
+ if (m_current_part == NULL)
+ {
+ parse_error("Tag %s found outside of part context", tagname);
return;
+ }
- // do device validation only in case of validate command
- if (strcmp(mconfig().options().command(), CLICOMMAND_VALIDATE) != 0) return;
-
- softlist_map names;
- softlist_map descriptions;
-
- enum { NAME_LEN_PARENT = 8, NAME_LEN_CLONE = 16 };
-
- software_list *list = software_list_open(mconfig().options(), m_list_name, FALSE, NULL);
- if ( list )
+ // <rom name='' size='' crc='' sha1='' offset='' value='' status='' loadflag=''>
+ if (strcmp(tagname, "rom") == 0)
{
- software_list_parse( list, &validate_error_proc, NULL );
-
- for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
+ static const char *attrnames[] = { "name", "size", "crc", "sha1", "offset", "value", "status", "loadflag" };
+ const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 };
+ parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues);
+
+ const char *name = attrvalues[0];
+ const char *sizestr = attrvalues[1];
+ const char *crc = attrvalues[2];
+ const char *sha1 = attrvalues[3];
+ const char *offsetstr = attrvalues[4];
+ const char *value = attrvalues[5];
+ const char *status = attrvalues[6];
+ const char *loadflag = attrvalues[7];
+ if (sizestr != NULL && offsetstr != NULL)
{
- const char *s;
- int is_clone = 0;
-
- /* First, check if the xml got corrupted: */
-
- /* Did we lost any description? */
- if (swinfo->longname == NULL)
+ UINT32 length = strtol(sizestr, NULL, 0);
+ UINT32 offset = strtol(offsetstr, NULL, 0);
+
+ if (loadflag != NULL && strcmp(loadflag, "reload") == 0)
+ add_rom_entry(NULL, NULL, offset, length, ROMENTRYTYPE_RELOAD | ROM_INHERITFLAGS);
+ else if (loadflag != NULL && strcmp(loadflag, "reload_plain") == 0)
+ add_rom_entry(NULL, NULL, offset, length, ROMENTRYTYPE_RELOAD);
+ else if (loadflag != NULL && strcmp(loadflag, "continue") == 0)
+ add_rom_entry(NULL, NULL, offset, length, ROMENTRYTYPE_CONTINUE | ROM_INHERITFLAGS);
+ else if (loadflag != NULL && strcmp(loadflag, "fill") == 0)
+ add_rom_entry(NULL, (const char *)(FPTR)(strtol(value, NULL, 0) & 0xff), offset, length, ROMENTRYTYPE_FILL);
+ else if (name != NULL)
{
- mame_printf_error("%s: %s has no description\n", list->file->filename(), swinfo->shortname);
- break;
- }
-
- /* Did we lost any year? */
- if (swinfo->year == NULL)
- {
- mame_printf_error("%s: %s has no year\n", list->file->filename(), swinfo->shortname);
- break;
- }
-
- /* Did we lost any publisher? */
- if (swinfo->publisher == NULL)
- {
- mame_printf_error("%s: %s has no publisher\n", list->file->filename(), swinfo->shortname);
- break;
- }
-
- /* Second, since the xml is fine, run additional checks: */
-
- /* check for duplicate names */
- if (names.add(swinfo->shortname, swinfo, FALSE) == TMERR_DUPLICATE)
- {
- software_info *match = names.find(swinfo->shortname);
- mame_printf_error("%s: %s is a duplicate name (%s)\n", list->file->filename(), swinfo->shortname, match->shortname);
- }
+ bool baddump = (status != NULL && strcmp(status, "baddump") == 0);
+ bool nodump = (status != NULL && strcmp(status, "nodump") == 0);
- /* check for duplicate descriptions */
- if (descriptions.add(astring(swinfo->longname).makelower().cstr(), swinfo, FALSE) == TMERR_DUPLICATE)
- mame_printf_error("%s: %s is a duplicate description (%s)\n", list->file->filename(), swinfo->longname, swinfo->shortname);
-
- if (swinfo->parentname != NULL)
- {
- is_clone = 1;
-
- if (strcmp(swinfo->parentname, swinfo->shortname) == 0)
+ astring hashdata;
+ if (nodump)
{
- mame_printf_error("%s: %s is set as a clone of itself\n", list->file->filename(), swinfo->shortname);
- break;
+ hashdata.printf("%s", NO_DUMP);
+ if (crc != NULL && sha1 != NULL)
+ parse_error("No need for hash definition");
}
-
- /* make sure the parent exists */
- software_info *swinfo2 = software_list_find(list, swinfo->parentname, NULL );
-
- if (!swinfo2)
- mame_printf_error("%s: parent '%s' software for '%s' not found\n", list->file->filename(), swinfo->parentname, swinfo->shortname);
- else if (swinfo2->parentname != NULL)
- mame_printf_error("%s: %s is a clone of a clone\n", list->file->filename(), swinfo->shortname);
- }
-
- /* make sure the driver name is 8 chars or less */
- if ((is_clone && strlen(swinfo->shortname) > NAME_LEN_CLONE) || ((!is_clone) && strlen(swinfo->shortname) > NAME_LEN_PARENT))
- mame_printf_error("%s: %s %s driver name must be %d characters or less\n", list->file->filename(), swinfo->shortname,
- is_clone ? "clone" : "parent", is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT);
-
- /* make sure the year is only digits, '?' or '+' */
- for (s = swinfo->year; *s; s++)
- if (!isdigit((UINT8)*s) && *s != '?' && *s != '+')
+ else
{
- mame_printf_error("%s: %s has an invalid year '%s'\n", list->file->filename(), swinfo->shortname, swinfo->year);
- break;
+ if (crc != NULL && sha1 != NULL)
+ hashdata.printf("%c%s%c%s%s", hash_collection::HASH_CRC, crc, hash_collection::HASH_SHA1, sha1, (baddump ? BAD_DUMP : ""));
+ else
+ parse_error("Incomplete rom hash definition");
}
- softlist_map part_names;
-
- for (software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
- {
- if (swpart->interface_ == NULL)
- mame_printf_error("%s: %s has a part (%s) without interface\n", list->file->filename(), swinfo->shortname, swpart->name);
-
- if (software_find_romdata(swpart, NULL) == NULL)
- mame_printf_error("%s: %s has a part (%s) with no data\n", list->file->filename(), swinfo->shortname, swpart->name);
-
- if (part_names.add(swpart->name, swinfo, FALSE) == TMERR_DUPLICATE)
- mame_printf_error("%s: %s has a part (%s) whose name is duplicate\n", list->file->filename(), swinfo->shortname, swpart->name);
-
- for (struct rom_entry *swdata = software_find_romdata(swpart, NULL); swdata != NULL; swdata = software_romdata_next(swdata))
- {
- struct rom_entry *data = swdata;
-
- if (data->_name && data->_hashdata)
- {
- const char *str;
-
- /* make sure it's all lowercase */
- for (str = data->_name; *str; str++)
- if (tolower((UINT8)*str) != *str)
- {
- mame_printf_error("%s: %s has upper case ROM name %s\n", list->file->filename(), swinfo->shortname, data->_name);
- break;
- }
-
- /* make sure the hash is valid */
- hash_collection hashes;
- if (!hashes.from_internal_string(data->_hashdata))
- mame_printf_error("%s: %s has rom '%s' with an invalid hash string '%s'\n", list->file->filename(), swinfo->shortname, data->_name, data->_hashdata);
- }
- }
+ // Handle loadflag attribute
+ int romflags = 0;
+ if (loadflag != NULL && strcmp(loadflag, "load16_word_swap") == 0)
+ romflags = ROM_GROUPWORD | ROM_REVERSE;
+ else if (loadflag != NULL && strcmp(loadflag, "load16_byte") == 0)
+ romflags = ROM_SKIP(1);
+ else if (loadflag != NULL && strcmp(loadflag, "load32_word_swap") == 0)
+ romflags = ROM_GROUPWORD | ROM_REVERSE | ROM_SKIP(2);
+ else if (loadflag != NULL && strcmp(loadflag, "load32_word") == 0)
+ romflags = ROM_GROUPWORD | ROM_SKIP(2);
+ else if (loadflag != NULL && strcmp(loadflag, "load32_byte") == 0)
+ romflags = ROM_SKIP(3);
+
+ add_rom_entry(name, hashdata, offset, length, ROMENTRYTYPE_ROM | romflags);
}
+ else
+ parse_error("Rom name missing");
+ }
+ else
+ parse_error("Incomplete rom definition");
+ }
+
+ // <rom name='' sha1='' status='' writeable=''>
+ else if (strcmp(tagname, "disk") == 0)
+ {
+ static const char *attrnames[] = { "name", "sha1", "status", "writeable" };
+ const char *attrvalues[ARRAY_LENGTH(attrnames)] = { 0 };
+ parse_attributes(attributes, ARRAY_LENGTH(attrnames), attrnames, attrvalues);
+
+ const char *name = attrvalues[0];
+ const char *sha1 = attrvalues[1];
+ const char *status = attrvalues[2];
+ const char *writeablestr = attrvalues[3];
+ if (name != NULL && sha1 != NULL)
+ {
+ bool baddump = (status != NULL && strcmp(status, "baddump") == 0);
+ bool nodump = (status != NULL && strcmp(status, "nodump" ) == 0);
+ bool writeable = (writeablestr != NULL && strcmp(writeablestr, "yes") == 0);
+ astring hashdata;
+ hashdata.printf( "%c%s%s", hash_collection::HASH_SHA1, sha1, (nodump ? NO_DUMP : (baddump ? BAD_DUMP : "")));
+
+ add_rom_entry(name, hashdata, 0, 0, ROMENTRYTYPE_ROM | (writeable ? DISK_READWRITE : DISK_READONLY));
}
- software_list_close(list);
+ else if (status == NULL || strcmp(status, "nodump") != NULL) // a no_dump chd is not an incomplete entry
+ parse_error("Incomplete disk definition");
}
+
+ // <dipvalue>
+ else if (strcmp(tagname, "dipvalue") == 0)
+ ;
+ else
+ unknown_tag(tagname);
}
-bool softlist_contain_interface(const char *interface, const char *part_interface)
+
+//-------------------------------------------------
+// parse_soft_end - handle end-of-tag post-
+// processing within the <software> tag
+//-------------------------------------------------
+
+void softlist_parser::parse_soft_end(const char *tagname)
{
- bool result = FALSE;
+ assert(m_current_info != NULL);
+
+ // <description>
+ if (strcmp(tagname, "description") == 0)
+ m_current_info->m_longname = m_list.add_string(m_data_accum);
+
+ // <year>
+ else if (strcmp(tagname, "year") == 0)
+ m_current_info->m_year = m_list.add_string(m_data_accum);
- astring interfaces(interface);
- char *intf = strtok((char*)interfaces.cstr(),",");
- while (intf != NULL)
+ // <publisher>
+ else if (strcmp(tagname, "publisher") == 0)
+ m_current_info->m_publisher = m_list.add_string(m_data_accum);
+
+ // </part>
+ else if (strcmp(tagname, "part") == 0)
{
- if (!strcmp(intf, part_interface))
- {
- result = TRUE;
- break;
- }
- intf = strtok (NULL, ",");
+ // get the last part
+ assert(m_current_part != NULL);
+ if (m_current_part == NULL)
+ return;
+
+ // was any dataarea/rom information encountered? if so, add a terminator
+ if (m_current_part->romdata() != NULL)
+ add_rom_entry(NULL, NULL, 0, 0, ROMENTRYTYPE_END);
+
+ // get the info; if present, copy shared data (we assume name/value strings live
+ // in the string pool and don't need to be reallocated)
+ if (m_current_info != NULL)
+ for (feature_list_item *item = m_current_info->shared_info(); item != NULL; item = item->next())
+ m_current_part->m_featurelist.append(*global_alloc(feature_list_item(item->name(), item->value())));
}
- return result;
}
diff --git a/src/emu/softlist.h b/src/emu/softlist.h
index c0d48b6ac88..5a32e67c1c8 100644
--- a/src/emu/softlist.h
+++ b/src/emu/softlist.h
@@ -11,10 +11,14 @@
#include "ui/menu.h"
#include "expat.h"
-#include "pool.h"
+#include "cstrpool.h"
+//**************************************************************************
+// CONSTANTS
+//**************************************************************************
+
#define SOFTWARE_SUPPORTED_YES 0
#define SOFTWARE_SUPPORTED_PARTIAL 1
#define SOFTWARE_SUPPORTED_NO 2
@@ -25,6 +29,12 @@ enum softlist_type
SOFTWARE_LIST_COMPATIBLE_SYSTEM
};
+
+
+//**************************************************************************
+// MACROS
+//**************************************************************************
+
#define MCFG_SOFTWARE_LIST_CONFIG(_list,_list_type) \
software_list_device::static_set_config(*device, _list, _list_type);
@@ -52,10 +62,129 @@ enum softlist_type
MCFG_DEVICE_REMOVE( _tag )
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> feature_list_item
+
+// an item in a list of name/value pairs
+class feature_list_item
+{
+ friend class simple_list<feature_list_item>;
+
+public:
+ // construction/destruction
+ feature_list_item(const char *name = NULL, const char *value = NULL)
+ : m_next(NULL),
+ m_name(name),
+ m_value(value) { }
+
+ // getters
+ feature_list_item *next() const { return m_next; }
+ const char *name() const { return m_name; }
+ const char *value() const { return m_value; }
+
+private:
+ // internal state
+ feature_list_item * m_next;
+ const char * m_name;
+ const char * m_value;
+};
+
+
+// ======================> software_part
+
+// a single part of a software item
+class software_part
+{
+ friend class softlist_parser;
+ friend class simple_list<software_part>;
+
+public:
+ // construction/destruction
+ software_part(software_info &info, const char *name = NULL, const char *interface = NULL);
+
+ // getters
+ software_part *next() const { return m_next; }
+ software_info &info() const { return m_info; }
+ const char *name() const { return m_name; }
+ const char *interface() const { return m_interface; }
+ feature_list_item *featurelist() const { return m_featurelist.first(); }
+ rom_entry *romdata(int index = 0) { return (index < m_romdata.count()) ? &m_romdata[index] : NULL; }
+
+ // helpers
+ bool is_compatible(const software_list_device &swlist) const;
+ bool matches_interface(const char *interface) const;
+ const char *feature(const char *feature_name) const;
+
+private:
+ // internal state
+ software_part * m_next;
+ software_info & m_info;
+ const char * m_name;
+ const char * m_interface;
+ simple_list<feature_list_item> m_featurelist;
+ dynamic_array<rom_entry> m_romdata;
+};
+
+
+// ======================> software_info
+
+// a single software item
+class software_info
+{
+ friend class softlist_parser;
+ friend class simple_list<software_info>;
+
+public:
+ // construction/destruction
+ software_info(software_list_device &list, const char *name, const char *parent, const char *supported);
+
+ // getters
+ software_info *next() const { return m_next; }
+ software_list_device &list() const { return m_list; }
+ const char *shortname() const { return m_shortname; }
+ const char *longname() const { return m_longname; }
+ const char *parentname() const { return m_parentname; }
+ const char *year() const { return m_year; }
+ const char *publisher() const { return m_publisher; }
+ feature_list_item *other_info() const { return m_other_info.first(); }
+ feature_list_item *shared_info() const { return m_shared_info.first(); }
+ UINT32 supported() const { return m_supported; }
+ int num_parts() const { return m_partdata.count(); }
+ software_part *first_part() const { return m_partdata.first(); }
+ software_part *last_part() const { return m_partdata.last(); }
+
+ // additional operations
+ software_part *find_part(const char *partname, const char *interface = NULL);
+ bool has_multiple_parts(const char *interface) const;
+
+private:
+ // internal state
+ software_info * m_next;
+ software_list_device & m_list;
+ UINT32 m_supported;
+ const char * m_shortname;
+ const char * m_longname;
+ const char * m_parentname;
+ const char * m_year; // Copyright year on title screen, actual release dates can be tracked in external resources
+ const char * m_publisher;
+ simple_list<feature_list_item> m_other_info; // Here we store info like developer, serial #, etc. which belong to the software entry as a whole
+ simple_list<feature_list_item> m_shared_info; // Here we store info like TV standard compatibility, or add-on requirements, etc. which get inherited
+ // by each part of this software entry (after loading these are stored in partdata->featurelist)
+ simple_list<software_part> m_partdata;
+};
+
+
// ======================> software_list_device
+// device representing a software list
class software_list_device : public device_t
{
+ friend class softlist_parser;
+
public:
// construction/destruction
software_list_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
@@ -68,22 +197,48 @@ public:
const char *list_name() const { return m_list_name; }
softlist_type list_type() const { return m_list_type; }
const char *filter() const { return m_filter; }
+ const char *filename() { return m_file.filename(); }
- // validation helpers
- static void reset_checked_lists() { s_checked_lists.reset(); }
+ // getters that may trigger a parse
+ const char *description() { if (!m_parsed) parse(); return m_description; }
+ bool valid() { if (!m_parsed) parse(); return m_infolist.count() > 0; }
+ const char *errors_string() { if (!m_parsed) parse(); return m_errors; }
+
+ // operations
+ software_info *find(const char *look_for, software_info *prev = NULL);
+ software_info *first_software_info() { if (!m_parsed) parse(); return m_infolist.first(); }
+ void find_approx_matches(const char *name, int matches, software_info **list, const char *interface);
+ void release();
+
+ // string pool helpers
+ const char *add_string(const char *string) { return m_stringpool.add(string); }
+ bool string_pool_contains(const char *string) { return m_stringpool.contains(string); }
+
+ // static helpers
+ static software_list_device *find_by_name(const machine_config &mconfig, const char *name);
+ static void display_matches(const machine_config &config, const char *interface, const char *name);
protected:
+ // internal helpers
+ void parse();
+ void internal_validity_check(validity_checker &valid) ATTR_COLD;
+
// device-level overrides
virtual void device_start();
virtual void device_validity_check(validity_checker &valid) const ATTR_COLD;
// configuration state
- const char * m_list_name;
+ astring m_list_name;
softlist_type m_list_type;
const char * m_filter;
- // static state
- static tagmap_t<UINT8> s_checked_lists;
+ // internal state
+ bool m_parsed;
+ emu_file m_file;
+ const char * m_description;
+ astring m_errors;
+ simple_list<software_info> m_infolist;
+ const_string_pool m_stringpool;
};
@@ -94,116 +249,4 @@ extern const device_type SOFTWARE_LIST;
typedef device_type_iterator<&device_creator<software_list_device>, software_list_device> software_list_device_iterator;
-
-/*********************************************************************
-
- Internal structures and XML file handling
-
-*********************************************************************/
-
-/* Replace this with list<string>? */
-struct feature_list
-{
- feature_list *next;
- char *name;
- char *value;
-};
-
-struct software_part
-{
- const char *name;
- const char *interface_;
- feature_list *featurelist;
- struct rom_entry *romdata;
-};
-
-
-/* The software info struct holds basic software information. */
-struct software_info
-{
- const char *shortname;
- const char *longname;
- const char *parentname;
- const char *year; // Copyright year on title screen, actual release dates can be tracked in external resources
- const char *publisher;
- feature_list *other_info; // Here we store info like developer, serial #, etc. which belong to the software entry as a whole
- feature_list *shared_info; // Here we store info like TV standard compatibility, or add-on requirements, etc. which get inherited
- // by each part of this software entry (after loading these are stored in partdata->featurelist)
- UINT32 supported;
- int part_entries;
- int current_part_entry;
- software_part *partdata;
- struct software_info *next; // Used internally
-};
-
-
-enum softlist_parse_position
-{
- POS_ROOT,
- POS_MAIN,
- POS_SOFT,
- POS_PART,
- POS_DATA
-};
-
-
-struct parse_state
-{
- XML_Parser parser;
- int done;
-
- void (*error_proc)(const char *message);
- void *param;
-
- enum softlist_parse_position pos;
- char **text_dest;
-};
-
-
-struct software_list
-{
- emu_file *file;
- object_pool *pool;
- parse_state state;
- const char *description;
- struct software_info *software_info_list;
- struct software_info *current_software_info;
- software_info *softinfo;
- const char *look_for;
- int rom_entries;
- int current_rom_entry;
- void (*error_proc)(const char *message);
- int list_entries;
-};
-
-/* Handling a software list */
-software_list *software_list_open(emu_options &options, const char *listname, int is_preload, void (*error_proc)(const char *message));
-void software_list_close(const software_list *swlist);
-software_info *software_list_find(software_list *swlist, const char *look_for, software_info *prev);
-const char *software_list_get_description(const software_list *swlist);
-void software_list_parse(software_list *swlist, void (*error_proc)(const char *message), void *param);
-
-software_part *software_find_part(software_info *sw, const char *partname, const char *interface_);
-software_part *software_part_next(software_part *part);
-
-const software_info *software_list_find(const software_list *swlist, const char *look_for, const software_info *prev);
-const software_part *software_find_part(const software_info *sw, const char *partname, const char *interface_);
-const software_part *software_part_next(const software_part *part);
-
-/* helpers */
-const char *software_get_clone(emu_options &options, char *swlist, const char *swname);
-UINT32 software_get_support(emu_options &options, char *swlist, const char *swname);
-const char *software_part_get_feature(const software_part *part, const char *feature_name);
-void software_name_split(const char *swlist_swname, char **swlist_name, char **swname, char **swpart);
-
-bool load_software_part(emu_options &options, device_image_interface *image, const char *path, software_info **sw_info, software_part **sw_part, char **full_sw_name, char**list_name);
-
-void software_display_matches(const machine_config &config, emu_options &options,const char *interface,const char *swname_bckp);
-
-const char *software_get_default_slot(const machine_config &config, emu_options &options, const device_image_interface *image, const char* default_card_slot);
-
-bool is_software_compatible(const software_part *swpart, const software_list_device *swlist);
-bool swinfo_has_multiple_parts(const software_info *swinfo, const char *interface);
-
-bool softlist_contain_interface(const char *interface, const char *part_interface);
#endif
diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c
index 8a08654cdce..b3d31568c49 100644
--- a/src/emu/sound/aica.c
+++ b/src/emu/sound/aica.c
@@ -1600,6 +1600,11 @@ aica_device::aica_device(const machine_config &mconfig, const char *tag, device_
m_token = global_alloc_clear(aica_state);
}
+aica_device::~aica_device()
+{
+ global_free(m_token);
+}
+
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
diff --git a/src/emu/sound/aica.h b/src/emu/sound/aica.h
index f47827169fe..3f5b2e029de 100644
--- a/src/emu/sound/aica.h
+++ b/src/emu/sound/aica.h
@@ -30,10 +30,10 @@ class aica_device : public device_t,
{
public:
aica_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~aica_device() { global_free(m_token); }
+ ~aica_device();
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct aica_state *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
virtual void device_config_complete();
@@ -44,7 +44,7 @@ protected:
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
private:
// internal state
- void *m_token;
+ struct aica_state *m_token;
};
extern const device_type AICA;
diff --git a/src/emu/sound/ay8910.c b/src/emu/sound/ay8910.c
index 3245e9e4b04..e42d04af8b8 100644
--- a/src/emu/sound/ay8910.c
+++ b/src/emu/sound/ay8910.c
@@ -333,9 +333,8 @@ INLINE void build_3D_table(double rl, const ay_ym_param *par, const ay_ym_param
int j, j1, j2, j3, e, indx;
double rt, rw, n;
double min = 10.0, max = 0.0;
- double *temp;
- temp = global_alloc_array(double, 8*32*32*32);
+ dynamic_array<double> temp(8*32*32*32);
for (e=0; e < 8; e++)
for (j1=0; j1 < 32; j1++)
@@ -381,8 +380,6 @@ INLINE void build_3D_table(double rl, const ay_ym_param *par, const ay_ym_param
}
/* for (e=0;e<16;e++) printf("%d %d\n",e<<10, tab[e<<10]); */
-
- global_free(temp);
}
INLINE void build_single_table(double rl, const ay_ym_param *par, int normalize, INT32 *tab, int zero_is_off)
diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h
index 775511cbf01..9efba1e95eb 100644
--- a/src/emu/sound/discrete.h
+++ b/src/emu/sound/discrete.h
@@ -3765,7 +3765,7 @@ public:
m_arr = global_alloc_array_clear(_ElementType, m_allocated);
}
~dynamic_array_t() {
- global_free(m_arr);
+ global_free_array(m_arr);
}
_ElementType& operator [] (unsigned int index) const // get array item
{
diff --git a/src/emu/sound/dmadac.c b/src/emu/sound/dmadac.c
index 9e9b7e8ab74..94c33ebb1c9 100644
--- a/src/emu/sound/dmadac.c
+++ b/src/emu/sound/dmadac.c
@@ -245,6 +245,11 @@ dmadac_sound_device::dmadac_sound_device(const machine_config &mconfig, const ch
m_token = global_alloc_clear(dmadac_state);
}
+dmadac_sound_device::~dmadac_sound_device()
+{
+ global_free(m_token);
+}
+
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
diff --git a/src/emu/sound/dmadac.h b/src/emu/sound/dmadac.h
index d7657504022..2c580d1487b 100644
--- a/src/emu/sound/dmadac.h
+++ b/src/emu/sound/dmadac.h
@@ -18,10 +18,10 @@ class dmadac_sound_device : public device_t,
{
public:
dmadac_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~dmadac_sound_device() { global_free(m_token); }
+ ~dmadac_sound_device();
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct dmadac_state *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
virtual void device_config_complete();
@@ -31,7 +31,7 @@ protected:
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
private:
// internal state
- void *m_token;
+ struct dmadac_state *m_token;
};
extern const device_type DMADAC;
diff --git a/src/emu/sound/mos6581.c b/src/emu/sound/mos6581.c
index 8f71603d20a..62ac428a7c1 100644
--- a/src/emu/sound/mos6581.c
+++ b/src/emu/sound/mos6581.c
@@ -60,6 +60,10 @@ mos6581_device::mos6581_device(const machine_config &mconfig, const char *tag, d
m_token = global_alloc_clear(SID6581_t);
}
+mos6581_device::~mos6581_device()
+{
+ global_free(m_token);
+}
//-------------------------------------------------
// mos8580_device - constructor
diff --git a/src/emu/sound/mos6581.h b/src/emu/sound/mos6581.h
index a45a79d5a16..5cc70dfd1d9 100644
--- a/src/emu/sound/mos6581.h
+++ b/src/emu/sound/mos6581.h
@@ -56,7 +56,7 @@ class mos6581_device : public device_t,
public:
mos6581_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT32 variant, const char *shortname, const char *source);
mos6581_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~mos6581_device() { global_free(m_token); }
+ ~mos6581_device();
template<class _potx, class _poty> void set_callbacks(_potx potx, _poty poty) {
m_read_potx.set_callback(potx);
diff --git a/src/emu/sound/scsp.c b/src/emu/sound/scsp.c
index e8ffe42dbda..dc73795629a 100644
--- a/src/emu/sound/scsp.c
+++ b/src/emu/sound/scsp.c
@@ -1519,6 +1519,11 @@ scsp_device::scsp_device(const machine_config &mconfig, const char *tag, device_
m_token = global_alloc_clear(scsp_state);
}
+scsp_device::~scsp_device()
+{
+ global_free(m_token);
+}
+
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
diff --git a/src/emu/sound/scsp.h b/src/emu/sound/scsp.h
index 9c493854833..dbac1bdd200 100644
--- a/src/emu/sound/scsp.h
+++ b/src/emu/sound/scsp.h
@@ -32,10 +32,10 @@ class scsp_device : public device_t,
{
public:
scsp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~scsp_device() { global_free(m_token); }
+ ~scsp_device();
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct scsp_state *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
virtual void device_config_complete();
@@ -45,7 +45,7 @@ protected:
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
private:
// internal state
- void *m_token;
+ struct scsp_state *m_token;
};
extern const device_type SCSP;
diff --git a/src/emu/sound/spu.c b/src/emu/sound/spu.c
index dd4e86358e6..e1a313fd327 100644
--- a/src/emu/sound/spu.c
+++ b/src/emu/sound/spu.c
@@ -473,7 +473,7 @@ public:
*prev;
};
- unsigned char *buffer;
+ dynamic_buffer buffer;
unsigned int head,
tail,
in,
@@ -494,14 +494,12 @@ public:
marker_tail(NULL)
{
buffer_size=sector_size*num_sectors;
- buffer=new unsigned char [buffer_size];
- memset(buffer,0,buffer_size);
+ buffer.resize_and_clear(buffer_size);
}
~stream_buffer()
{
flush_all();
- global_free(buffer);
}
unsigned char *add_sector(const unsigned int sector)
@@ -594,10 +592,10 @@ public:
unsigned int get_bytes_in() const { return in; }
unsigned int get_bytes_free() const { return buffer_size-in; }
- unsigned char *get_tail_ptr() const { return buffer+tail; }
- unsigned char *get_tail_ptr(const unsigned int offset) const
+ unsigned char *get_tail_ptr() { return &buffer[tail]; }
+ unsigned char *get_tail_ptr(const unsigned int offset)
{
- return buffer+((tail+offset)%buffer_size);
+ return &buffer[((tail+offset)%buffer_size)];
}
unsigned int get_tail_offset() const { return tail; }
void increment_tail(const unsigned int offset)
@@ -1003,7 +1001,7 @@ void spu_device::device_start()
save_item(NAME(xa_buffer->sector_size));
save_item(NAME(xa_buffer->num_sectors));
save_item(NAME(xa_buffer->buffer_size));
- save_pointer(NAME(xa_buffer->buffer), xa_sector_size*xa_buffer_sectors);
+ save_item(NAME(xa_buffer->buffer));
save_item(NAME(cdda_buffer->head));
save_item(NAME(cdda_buffer->tail));
@@ -1011,7 +1009,7 @@ void spu_device::device_start()
save_item(NAME(cdda_buffer->sector_size));
save_item(NAME(cdda_buffer->num_sectors));
save_item(NAME(cdda_buffer->buffer_size));
- save_pointer(NAME(cdda_buffer->buffer), cdda_sector_size*cdda_buffer_sectors);
+ save_item(NAME(cdda_buffer->buffer));
}
void spu_device::device_reset()
@@ -1082,16 +1080,16 @@ void spu_device::device_post_load()
void spu_device::device_stop()
{
for (unsigned int i=0; i<4; i++)
- global_free(output_buf[i]);
+ global_free_array(output_buf[i]);
kill_stream();
- global_free(spu_ram);
+ global_free_array(spu_ram);
invalidate_cache(0,spu_ram_size);
- global_free(cache);
+ global_free_array(cache);
global_free(xa_buffer);
global_free(cdda_buffer);
- global_free(voice);
+ global_free_array(voice);
}
//
//
diff --git a/src/emu/sound/spureverb.c b/src/emu/sound/spureverb.c
index ce24d40b550..c9a8407f12f 100644
--- a/src/emu/sound/spureverb.c
+++ b/src/emu/sound/spureverb.c
@@ -57,10 +57,10 @@ reverb::~reverb()
for (int c=0; c<2; c++)
{
for (int f=0; f<4; f++)
- global_free(y[c][f]);
- global_free(x[c]);
- global_free(ax[c]);
- global_free(ay[c]);
+ global_free_array(y[c][f]);
+ global_free_array(x[c]);
+ global_free_array(ax[c]);
+ global_free_array(ay[c]);
}
}
diff --git a/src/emu/sound/tiasound.c b/src/emu/sound/tiasound.c
index 5e01a371a2b..5c4296371af 100644
--- a/src/emu/sound/tiasound.c
+++ b/src/emu/sound/tiasound.c
@@ -588,5 +588,5 @@ void *tia_sound_init(int clock, int sample_rate, int gain)
void tia_sound_free(void *chip)
{
- global_free(chip);
+ global_free((struct tia *)chip);
}
diff --git a/src/emu/tilemap.c b/src/emu/tilemap.c
index b4cfc80b958..4d65fd16c32 100644
--- a/src/emu/tilemap.c
+++ b/src/emu/tilemap.c
@@ -361,10 +361,6 @@ tilemap_t &tilemap_t::init(tilemap_manager &manager, gfxdecode_device &decoder,
// populate logical <-> memory mappings
m_mapper = mapper;
- m_memory_to_logical = NULL;
- m_max_logical_index = 0;
- m_logical_to_memory = NULL;
- m_max_memory_index = 0;
// initialize tile information geters
m_tile_get_info = tile_get_info;
@@ -381,10 +377,8 @@ tilemap_t &tilemap_t::init(tilemap_manager &manager, gfxdecode_device &decoder,
// reset scroll information
m_scrollrows = 1;
m_scrollcols = 1;
- m_rowscroll.resize(m_height);
- memset(&m_rowscroll[0], 0, m_height * sizeof(m_rowscroll[0]));
- m_colscroll.resize(m_width);
- memset(&m_colscroll[0], 0, m_width * sizeof(m_rowscroll[0]));
+ m_rowscroll.resize_and_clear(m_height);
+ m_colscroll.resize_and_clear(m_width);
m_dx = 0;
m_dx_flipped = 0;
m_dy = 0;
@@ -395,7 +389,6 @@ tilemap_t &tilemap_t::init(tilemap_manager &manager, gfxdecode_device &decoder,
// allocate transparency mapping
m_flagsmap.allocate(m_width, m_height);
- m_tileflags = NULL;
memset(m_pen_to_flags, 0, sizeof(m_pen_to_flags));
// create the initial mappings
@@ -408,7 +401,6 @@ tilemap_t &tilemap_t::init(tilemap_manager &manager, gfxdecode_device &decoder,
m_tileinfo.gfxnum = 0xff;
// allocate transparency mapping data
- m_tileflags = auto_alloc_array(machine(), UINT8, m_max_logical_index);
for (int group = 0; group < TILEMAP_NUM_GROUPS; group++)
map_pens_to_layer(group, 0, 0, TILEMAP_PIXEL_LAYER0);
@@ -449,7 +441,7 @@ tilemap_t::~tilemap_t()
void tilemap_t::mark_tile_dirty(tilemap_memory_index memindex)
{
// only mark if within range
- if (memindex < m_max_memory_index)
+ if (memindex < m_memory_to_logical.count())
{
// there may be no logical index for a given memory index
logical_index logindex = m_memory_to_logical[memindex];
@@ -619,21 +611,22 @@ void tilemap_t::postload()
void tilemap_t::mappings_create()
{
// compute the maximum logical index
- m_max_logical_index = m_rows * m_cols;
+ int max_logical_index = m_rows * m_cols;
// compute the maximum memory index
- m_max_memory_index = 0;
+ int max_memory_index = 0;
for (UINT32 row = 0; row < m_rows; row++)
for (UINT32 col = 0; col < m_cols; col++)
{
tilemap_memory_index memindex = memory_index(col, row);
- m_max_memory_index = MAX(m_max_memory_index, memindex);
+ max_memory_index = MAX(max_memory_index, memindex);
}
- m_max_memory_index++;
+ max_memory_index++;
// allocate the necessary mappings
- m_memory_to_logical = auto_alloc_array(machine(), logical_index, m_max_memory_index);
- m_logical_to_memory = auto_alloc_array(machine(), tilemap_memory_index, m_max_logical_index);
+ m_memory_to_logical.resize(max_memory_index);
+ m_logical_to_memory.resize(max_logical_index);
+ m_tileflags.resize(max_logical_index);
// update the mappings
mappings_update();
@@ -648,10 +641,10 @@ void tilemap_t::mappings_create()
void tilemap_t::mappings_update()
{
// initialize all the mappings to invalid values
- memset(m_memory_to_logical, 0xff, m_max_memory_index * sizeof(m_memory_to_logical[0]));
+ memset(&m_memory_to_logical[0], 0xff, m_memory_to_logical.count() * sizeof(m_memory_to_logical[0]));
// now iterate over all logical indexes and populate the memory index
- for (logical_index logindex = 0; logindex < m_max_logical_index; logindex++)
+ for (logical_index logindex = 0; logindex < m_logical_to_memory.count(); logindex++)
{
UINT32 logical_col = logindex % m_cols;
UINT32 logical_row = logindex / m_cols;
@@ -685,7 +678,7 @@ inline void tilemap_t::realize_all_dirty_tiles()
// flush the dirty status to all tiles
if (m_all_tiles_dirty || gfx_elements_changed())
{
- memset(m_tileflags, TILE_FLAG_DIRTY, m_max_logical_index);
+ memset(&m_tileflags[0], TILE_FLAG_DIRTY, m_tileflags.count());
m_all_tiles_dirty = false;
m_gfx_used = 0;
}
@@ -1478,6 +1471,29 @@ tilemap_manager::tilemap_manager(running_machine &machine)
//-------------------------------------------------
+// ~tilemap_manager - destructor
+//-------------------------------------------------
+
+tilemap_manager::~tilemap_manager()
+{
+ // detach all device tilemaps since they will be destroyed
+ // as subdevices elsewhere
+ bool found = true;
+ while (found)
+ {
+ found = false;
+ for (tilemap_t *tmap = m_tilemap_list.first(); tmap != NULL; tmap = tmap->next())
+ if (tmap->device() != NULL)
+ {
+ found = true;
+ m_tilemap_list.detach(*tmap);
+ break;
+ }
+ }
+}
+
+
+//-------------------------------------------------
// set_flip_all - set a global flip for all the
// tilemaps
//-------------------------------------------------
@@ -1501,14 +1517,14 @@ static const struct
tilemap_t &tilemap_manager::create(gfxdecode_device &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows, tilemap_t *allocated)
{
if (allocated == NULL)
- allocated = auto_alloc(machine(), tilemap_t);
+ allocated = global_alloc(tilemap_t);
return m_tilemap_list.append(allocated->init(*this, decoder, tile_get_info, mapper, tilewidth, tileheight, cols, rows));
}
tilemap_t &tilemap_manager::create(gfxdecode_device &decoder, tilemap_get_info_delegate tile_get_info, tilemap_standard_mapper mapper, int tilewidth, int tileheight, int cols, int rows, tilemap_t *allocated)
{
if (allocated == NULL)
- allocated = auto_alloc(machine(), tilemap_t);
+ allocated = global_alloc(tilemap_t);
return m_tilemap_list.append(allocated->init(*this, decoder, tile_get_info, tilemap_mapper_delegate(s_standard_mappers[mapper].func, s_standard_mappers[mapper].name, machine().driver_data()), tilewidth, tileheight, cols, rows));
}
diff --git a/src/emu/tilemap.h b/src/emu/tilemap.h
index 3e6fbf9026b..9a28c2f3cab 100644
--- a/src/emu/tilemap.h
+++ b/src/emu/tilemap.h
@@ -629,10 +629,8 @@ private:
// logical <-> memory mappings
tilemap_mapper_delegate m_mapper; // callback to map a row/column to a memory index
- logical_index * m_memory_to_logical; // map from memory index to logical index
- logical_index m_max_logical_index; // maximum valid logical index
- tilemap_memory_index * m_logical_to_memory; // map from logical index to memory index
- tilemap_memory_index m_max_memory_index; // maximum valid memory index
+ dynamic_array<logical_index> m_memory_to_logical; // map from memory index to logical index
+ dynamic_array<tilemap_memory_index> m_logical_to_memory; // map from logical index to memory index
// callback to interpret video RAM for the tilemap
tilemap_get_info_delegate m_tile_get_info; // callback to get information about a tile
@@ -662,7 +660,7 @@ private:
// transparency mapping
bitmap_ind8 m_flagsmap; // per-pixel flags
- UINT8 * m_tileflags; // per-tile flags
+ dynamic_array<UINT8> m_tileflags; // per-tile flags
UINT8 m_pen_to_flags[MAX_PEN_TO_FLAGS * TILEMAP_NUM_GROUPS]; // mapping of pens to flags
};
@@ -677,6 +675,7 @@ class tilemap_manager
public:
// construction/destuction
tilemap_manager(running_machine &machine);
+ ~tilemap_manager();
// getters
running_machine &machine() const { return m_machine; }
diff --git a/src/emu/ui/filemngr.c b/src/emu/ui/filemngr.c
index 2241e0ab37a..1650145277d 100644
--- a/src/emu/ui/filemngr.c
+++ b/src/emu/ui/filemngr.c
@@ -86,10 +86,10 @@ void ui_menu_file_manager::populate()
if (image->part_entry() != NULL)
{
const software_part *tmp = image->part_entry();
- if (tmp->name != NULL)
+ if (tmp->name() != NULL)
{
tmp_name.cat(" (");
- tmp_name.cat(tmp->name);
+ tmp_name.cat(tmp->name());
// also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it
if (image->get_feature("part_id") != NULL)
{
diff --git a/src/emu/ui/filesel.c b/src/emu/ui/filesel.c
index 6d20c9dfed4..975f66f339d 100644
--- a/src/emu/ui/filesel.c
+++ b/src/emu/ui/filesel.c
@@ -273,10 +273,10 @@ void ui_menu_file_create::populate()
item_append("New Image Name:", new_image_name, 0, ITEMREF_NEW_IMAGE_NAME);
// do we support multiple formats?
- format = m_image->device_get_creatable_formats();
+ format = m_image->formatlist();
if (ENABLE_FORMATS && (format != NULL))
{
- item_append("Image Format:", m_current_format->m_description, 0, ITEMREF_FORMAT);
+ item_append("Image Format:", m_current_format->description(), 0, ITEMREF_FORMAT);
m_current_format = format;
}
diff --git a/src/emu/ui/selgame.c b/src/emu/ui/selgame.c
index c86620aa377..87deeaabf0e 100644
--- a/src/emu/ui/selgame.c
+++ b/src/emu/ui/selgame.c
@@ -27,9 +27,8 @@
// ctor
//-------------------------------------------------
-ui_menu_select_game::ui_menu_select_game(running_machine &machine, render_container *container, const char *gamename) : ui_menu(machine, container)
+ui_menu_select_game::ui_menu_select_game(running_machine &machine, render_container *container, const char *gamename) : ui_menu(machine, container), m_driverlist(driver_list::total() + 1)
{
- m_driverlist = global_alloc_array(const game_driver *, driver_list::total()+1);
build_driver_list();
if(gamename)
strcpy(m_search, gamename);
@@ -43,8 +42,6 @@ ui_menu_select_game::ui_menu_select_game(running_machine &machine, render_contai
ui_menu_select_game::~ui_menu_select_game()
{
- global_free(m_drivlist);
- global_free(m_driverlist);
}
@@ -57,7 +54,7 @@ ui_menu_select_game::~ui_menu_select_game()
void ui_menu_select_game::build_driver_list()
{
// start with an empty list
- m_drivlist = global_alloc(driver_enumerator(machine().options()));
+ m_drivlist.reset(global_alloc(driver_enumerator(machine().options())));
m_drivlist->exclude_all();
// open a path to the ROMs and find them in the array
diff --git a/src/emu/ui/selgame.h b/src/emu/ui/selgame.h
index b1d9b2111dc..94e6f37d43b 100644
--- a/src/emu/ui/selgame.h
+++ b/src/emu/ui/selgame.h
@@ -35,8 +35,8 @@ private:
UINT8 m_rerandomize;
char m_search[40];
int m_matchlist[VISIBLE_GAMES_IN_LIST];
- const game_driver ** m_driverlist;
- driver_enumerator * m_drivlist;
+ dynamic_array<const game_driver *> m_driverlist;
+ auto_pointer<driver_enumerator> m_drivlist;
// internal methods
void build_driver_list();
diff --git a/src/emu/ui/swlist.c b/src/emu/ui/swlist.c
index 454ebb06a97..3eaf3908830 100644
--- a/src/emu/ui/swlist.c
+++ b/src/emu/ui/swlist.c
@@ -56,23 +56,19 @@ ui_menu_software_parts::~ui_menu_software_parts()
void ui_menu_software_parts::populate()
{
- for (const software_part *swpart = software_find_part(m_info, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
+ for (const software_part *swpart = m_info->first_part(); swpart != NULL; swpart = swpart->next())
{
- if (softlist_contain_interface(m_interface, swpart->interface_))
+ if (swpart->matches_interface(m_interface))
{
software_part_menu_entry *entry = (software_part_menu_entry *) m_pool_alloc(sizeof(*entry));
// check if the available parts have specific part_id to be displayed (e.g. "Map Disc", "Bonus Disc", etc.)
// if not, we simply display "part_name"; if yes we display "part_name (part_id)"
- astring menu_part_name(swpart->name);
- if (software_part_get_feature(swpart, "part_id") != NULL)
- {
- menu_part_name.cat(" (");
- menu_part_name.cat(software_part_get_feature(swpart, "part_id"));
- menu_part_name.cat(")");
- }
+ astring menu_part_name(swpart->name());
+ if (swpart->feature("part_id") != NULL)
+ menu_part_name.cat(" (").cat(swpart->feature("part_id")).cat(")");
entry->type = T_ENTRY;
entry->part = swpart;
- item_append(m_info->shortname, menu_part_name.cstr(), 0, entry);
+ item_append(m_info->shortname(), menu_part_name.cstr(), 0, entry);
}
}
@@ -113,7 +109,7 @@ void ui_menu_software_parts::handle()
// ctor
//-------------------------------------------------
-ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_container *container, const software_list_device *swlist, const char *interface, astring &result)
+ui_menu_software_list::ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, astring &result)
: ui_menu(machine, container), m_result(result)
{
m_swlist = swlist;
@@ -181,17 +177,17 @@ ui_menu_software_list::entry_info *ui_menu_software_list::append_software_entry(
bool entry_updated = FALSE;
// check if at least one of the parts has the correct interface and add a menu entry only in this case
- for (const software_part *swpart = software_find_part(swinfo, NULL, NULL); swpart != NULL; swpart = software_part_next(swpart))
+ for (const software_part *swpart = swinfo->first_part(); swpart != NULL; swpart = swpart->next())
{
- if ((softlist_contain_interface(m_interface, swpart->interface_)) && is_software_compatible(swpart, m_swlist))
+ if (swpart->matches_interface(m_interface) && swpart->is_compatible(*m_swlist))
{
entry_updated = TRUE;
// allocate a new entry
entry = (entry_info *) m_pool_alloc(sizeof(*entry));
memset(entry, 0, sizeof(*entry));
- entry->short_name = pool_strdup(swinfo->shortname);
- entry->long_name = pool_strdup(swinfo->longname);
+ entry->short_name = pool_strdup(swinfo->shortname());
+ entry->long_name = pool_strdup(swinfo->longname());
break;
}
}
@@ -219,16 +215,9 @@ ui_menu_software_list::entry_info *ui_menu_software_list::append_software_entry(
void ui_menu_software_list::populate()
{
- const software_list *list = software_list_open(machine().options(), m_swlist->list_name(), false, NULL);
-
// build up the list of entries for the menu
- if (list)
- {
- for (const software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
- append_software_entry(swinfo);
-
- software_list_close(list);
- }
+ for (const software_info *swinfo = m_swlist->first_software_info(); swinfo != NULL; swinfo = swinfo->next())
+ append_software_entry(swinfo);
// add an entry to change ordering
item_append("Switch Item Ordering", NULL, 0, (void *)1);
@@ -378,7 +367,7 @@ void ui_menu_software_list::handle()
// ctor
//-------------------------------------------------
-ui_menu_software::ui_menu_software(running_machine &machine, render_container *container, const char *interface, const software_list_device **result)
+ui_menu_software::ui_menu_software(running_machine &machine, render_container *container, const char *interface, software_list_device **result)
: ui_menu(machine, container)
{
m_interface = interface;
@@ -401,68 +390,39 @@ ui_menu_software::~ui_menu_software()
void ui_menu_software::populate()
{
- bool haveCompatible = false;
+ bool have_compatible = false;
// Add original software lists for this system
software_list_device_iterator iter(machine().config().root_device());
- for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
- {
- if (swlist->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
- {
- const software_list *list = software_list_open(machine().options(), swlist->list_name(), false, NULL);
-
- if (list && m_interface)
+ for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next())
+ if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM)
+ if (swlistdev->first_software_info() != NULL && m_interface != NULL)
{
bool found = false;
- for (const software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
- {
- const software_part *part = software_find_part(swinfo, NULL, NULL);
- if (softlist_contain_interface(m_interface, part->interface_))
+ for (const software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next())
+ if (swinfo->first_part()->matches_interface(m_interface))
found = true;
- }
if (found)
- {
- item_append(list->description, NULL, 0, (void *)swlist);
- }
-
- software_list_close(list);
+ item_append(swlistdev->description(), NULL, 0, (void *)swlistdev);
}
- }
- }
// add compatible software lists for this system
- for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next())
- {
- if (swlist->list_type() == SOFTWARE_LIST_COMPATIBLE_SYSTEM)
- {
- const software_list *list = software_list_open(machine().options(), swlist->list_name(), false, NULL);
-
- if (list && m_interface)
+ for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next())
+ if (swlistdev->list_type() == SOFTWARE_LIST_COMPATIBLE_SYSTEM)
+ if (swlistdev->first_software_info() != NULL && m_interface != NULL)
{
bool found = false;
- for (const software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo))
- {
- const software_part *part = software_find_part(swinfo, NULL, NULL);
- if (softlist_contain_interface(m_interface, part->interface_))
- {
+ for (const software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next())
+ if (swinfo->first_part()->matches_interface(m_interface))
found = true;
- }
- }
-
if (found)
{
- if (!haveCompatible)
+ if (!have_compatible)
item_append("[compatible lists]", NULL, MENU_FLAG_DISABLE, NULL);
-
- item_append(list->description, NULL, 0, (void *)swlist);
+ item_append(swlistdev->description(), NULL, 0, (void *)swlistdev);
}
-
- haveCompatible = true;
- software_list_close(list);
+ have_compatible = true;
}
- }
- }
-
}
diff --git a/src/emu/ui/swlist.h b/src/emu/ui/swlist.h
index e5caaade381..98c5de0d860 100644
--- a/src/emu/ui/swlist.h
+++ b/src/emu/ui/swlist.h
@@ -41,7 +41,7 @@ private:
class ui_menu_software_list : public ui_menu {
public:
- ui_menu_software_list(running_machine &machine, render_container *container, const software_list_device *swlist, const char *interface, astring &result);
+ ui_menu_software_list(running_machine &machine, render_container *container, software_list_device *swlist, const char *interface, astring &result);
virtual ~ui_menu_software_list();
virtual void populate();
virtual void handle();
@@ -55,7 +55,7 @@ private:
};
// variables
- const software_list_device * m_swlist; // currently selected list
+ software_list_device * m_swlist; // currently selected list
const char * m_interface;
astring & m_result;
entry_info * m_entrylist;
@@ -72,14 +72,14 @@ private:
class ui_menu_software : public ui_menu {
public:
- ui_menu_software(running_machine &machine, render_container *container, const char *interface, const software_list_device **result);
+ ui_menu_software(running_machine &machine, render_container *container, const char *interface, software_list_device **result);
virtual ~ui_menu_software();
virtual void populate();
virtual void handle();
private:
const char * m_interface;
- const software_list_device ** m_result;
+ software_list_device ** m_result;
};
#endif /* __UI_SWLIST_H__ */
diff --git a/src/emu/validity.c b/src/emu/validity.c
index d1c2f20b387..66650201e99 100644
--- a/src/emu/validity.c
+++ b/src/emu/validity.c
@@ -237,9 +237,7 @@ void validity_checker::validate_begin()
// reset internal state
m_errors = 0;
m_warnings = 0;
-
- // reset some special case state
- software_list_device::reset_checked_lists();
+ m_already_checked.reset();
}
@@ -1047,7 +1045,6 @@ void validity_checker::validate_devices()
}
const_cast<machine_config &>(*m_current_config).device_remove(&m_current_config->root_device(), temptag.cstr());
- global_free(dev);
}
}
diff --git a/src/emu/validity.h b/src/emu/validity.h
index f1d98cde34e..d59c0003625 100644
--- a/src/emu/validity.h
+++ b/src/emu/validity.h
@@ -48,6 +48,9 @@ public:
void validate_tag(const char *tag);
int region_length(const char *tag) { return m_region_map.find(tag); }
+ // generic registry of already-checked stuff
+ bool already_checked(const char *string) { return (m_already_checked.add(string, 1, false) == TMERR_DUPLICATE); }
+
private:
// internal helpers
const char *ioport_string_from_index(UINT32 index);
@@ -97,6 +100,7 @@ private:
const device_t * m_current_device;
const char * m_current_ioport;
int_map m_region_map;
+ tagmap_t<UINT8> m_already_checked;
// callbacks
output_delegate m_saved_error_output;
diff --git a/src/emu/video.c b/src/emu/video.c
index 49a7c02ea22..576495e0ded 100644
--- a/src/emu/video.c
+++ b/src/emu/video.c
@@ -101,7 +101,6 @@ video_manager::video_manager(running_machine &machine)
m_snap_native(true),
m_snap_width(0),
m_snap_height(0),
- m_mngfile(NULL),
m_avifile(NULL),
m_movie_frame_period(attotime::zero),
m_movie_next_frame_time(attotime::zero),
@@ -422,7 +421,7 @@ void video_manager::begin_recording(const char *name, movie_format format)
else if (format == MF_MNG)
{
// create a new movie file and start recording
- m_mngfile = auto_alloc(machine(), emu_file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
+ m_mngfile.reset(global_alloc(emu_file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)));
file_error filerr;
if (name != NULL)
filerr = m_mngfile->open(name);
@@ -443,8 +442,7 @@ void video_manager::begin_recording(const char *name, movie_format format)
else
{
mame_printf_error("Error creating MNG\n");
- global_free(m_mngfile);
- m_mngfile = NULL;
+ m_mngfile.reset();
}
}
}
@@ -467,8 +465,7 @@ void video_manager::end_recording()
if (m_mngfile != NULL)
{
mng_capture_stop(*m_mngfile);
- auto_free(machine(), m_mngfile);
- m_mngfile = NULL;
+ m_mngfile.reset();
}
// reset the state
diff --git a/src/emu/video.h b/src/emu/video.h
index bfb73b2b46c..c525f066b61 100644
--- a/src/emu/video.h
+++ b/src/emu/video.h
@@ -166,7 +166,7 @@ private:
INT32 m_snap_height; // height of snapshots (0 == auto)
// movie recording
- emu_file * m_mngfile; // handle to the open movie file
+ auto_pointer<emu_file> m_mngfile; // handle to the open movie file
avi_file * m_avifile; // handle to the open movie file
attotime m_movie_frame_period; // period of a single movie frame
attotime m_movie_next_frame_time; // time of next frame
diff --git a/src/emu/video/resnet.c b/src/emu/video/resnet.c
index 863541f00ba..5a00e07f01d 100644
--- a/src/emu/video/resnet.c
+++ b/src/emu/video/resnet.c
@@ -242,8 +242,6 @@ double compute_resistor_net_outputs(
int rescount[MAX_NETS]; /* number of resistors in each of the nets */
double r[MAX_NETS][MAX_RES_PER_NET]; /* resistances */
- double *o; /* calulated outputs */
- double *os; /* calulated, scaled outputss */
int r_pd[MAX_NETS]; /* pulldown resistances */
int r_pu[MAX_NETS]; /* pullup resistances */
@@ -258,8 +256,8 @@ double compute_resistor_net_outputs(
/* parse input parameters */
- o = global_alloc_array(double, (1<<MAX_RES_PER_NET) * MAX_NETS);
- os = global_alloc_array(double, (1<<MAX_RES_PER_NET) * MAX_NETS);
+ dynamic_array<double> o((1<<MAX_RES_PER_NET) * MAX_NETS);
+ dynamic_array<double> os((1<<MAX_RES_PER_NET) * MAX_NETS);
networks_no = 0;
for (n = 0; n < MAX_NETS; n++)
@@ -420,8 +418,6 @@ if (VERBOSE)
}
/* debug end */
- global_free(o);
- global_free(os);
return (scale);
}
@@ -450,25 +446,25 @@ if (VERBOSE)
#define TTL_VOH (4.0)
-int compute_res_net(int inputs, int channel, const res_net_info *di)
+int compute_res_net(int inputs, int channel, const res_net_info &di)
{
double rTotal=0.0;
double v = 0;
int i;
- double vBias = di->rgb[channel].vBias;
- double vOH = di->vOH;
- double vOL = di->vOL;
- double minout = di->rgb[channel].minout;
- double cut = di->rgb[channel].cut;
- double vcc = di->vcc;
+ double vBias = di.rgb[channel].vBias;
+ double vOH = di.vOH;
+ double vOL = di.vOL;
+ double minout = di.rgb[channel].minout;
+ double cut = di.rgb[channel].cut;
+ double vcc = di.vcc;
double ttlHRes = 0;
- double rGnd = di->rgb[channel].rGnd;
- UINT8 OpenCol = di->OpenCol;
+ double rGnd = di.rgb[channel].rGnd;
+ UINT8 OpenCol = di.OpenCol;
/* Global options */
- switch (di->options & RES_NET_AMP_MASK)
+ switch (di.options & RES_NET_AMP_MASK)
{
case RES_NET_AMP_USE_GLOBAL:
/* just ignore */
@@ -492,7 +488,7 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
fatalerror("compute_res_net: Unknown amplifier type\n");
}
- switch (di->options & RES_NET_VCC_MASK)
+ switch (di.options & RES_NET_VCC_MASK)
{
case RES_NET_VCC_5V:
vcc = 5.0;
@@ -504,7 +500,7 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
fatalerror("compute_res_net: Unknown vcc type\n");
}
- switch (di->options & RES_NET_VBIAS_MASK)
+ switch (di.options & RES_NET_VBIAS_MASK)
{
case RES_NET_VBIAS_USE_GLOBAL:
/* just ignore */
@@ -522,7 +518,7 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
fatalerror("compute_res_net: Unknown vcc type\n");
}
- switch (di->options & RES_NET_VIN_MASK)
+ switch (di.options & RES_NET_VIN_MASK)
{
case RES_NET_VIN_OPEN_COL:
OpenCol = 1;
@@ -551,7 +547,7 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
/* Per channel options */
- switch (di->rgb[channel].options & RES_NET_AMP_MASK)
+ switch (di.rgb[channel].options & RES_NET_AMP_MASK)
{
case RES_NET_AMP_USE_GLOBAL:
/* use global defaults */
@@ -575,7 +571,7 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
fatalerror("compute_res_net: Unknown amplifier type\n");
}
- switch (di->rgb[channel].options & RES_NET_VBIAS_MASK)
+ switch (di.rgb[channel].options & RES_NET_VBIAS_MASK)
{
case RES_NET_VBIAS_USE_GLOBAL:
/* use global defaults */
@@ -595,7 +591,7 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
/* Input impedances */
- switch (di->options & RES_NET_MONITOR_MASK)
+ switch (di.options & RES_NET_MONITOR_MASK)
{
case RES_NET_MONITOR_INVERT:
case RES_NET_MONITOR_SANYO_EZV20:
@@ -611,29 +607,29 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
/* compute here - pass a / low inputs */
- for (i=0; i<di->rgb[channel].num; i++)
+ for (i=0; i<di.rgb[channel].num; i++)
{
int level = ((inputs >> i) & 1);
- if (di->rgb[channel].R[i] != 0.0 && !level)
+ if (di.rgb[channel].R[i] != 0.0 && !level)
{
if (OpenCol)
{
- rTotal += 1.0 / di->rgb[channel].R[i];
- v += vOL / di->rgb[channel].R[i];
+ rTotal += 1.0 / di.rgb[channel].R[i];
+ v += vOL / di.rgb[channel].R[i];
}
else
{
- rTotal += 1.0 / di->rgb[channel].R[i];
- v += vOL / di->rgb[channel].R[i];
+ rTotal += 1.0 / di.rgb[channel].R[i];
+ v += vOL / di.rgb[channel].R[i];
}
}
}
/* Mix in rbias and rgnd */
- if ( di->rgb[channel].rBias != 0.0 )
+ if ( di.rgb[channel].rBias != 0.0 )
{
- rTotal += 1.0 / di->rgb[channel].rBias;
- v += vBias / di->rgb[channel].rBias;
+ rTotal += 1.0 / di.rgb[channel].rBias;
+ v += vBias / di.rgb[channel].rBias;
}
if (rGnd != 0.0)
rTotal += 1.0 / rGnd;
@@ -643,7 +639,7 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
* There will be now current into/from the TTL gate
*/
- if ( (di->options & RES_NET_VIN_MASK)==RES_NET_VIN_TTL_OUT)
+ if ( (di.options & RES_NET_VIN_MASK)==RES_NET_VIN_TTL_OUT)
{
if (v / rTotal > vOH)
OpenCol = 1;
@@ -651,10 +647,10 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
/* Second pass - high inputs */
- for (i=0; i<di->rgb[channel].num; i++)
+ for (i=0; i<di.rgb[channel].num; i++)
{
int level = ((inputs >> i) & 1);
- if (di->rgb[channel].R[i] != 0.0 && level)
+ if (di.rgb[channel].R[i] != 0.0 && level)
{
if (OpenCol)
{
@@ -663,8 +659,8 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
}
else
{
- rTotal += 1.0 / (di->rgb[channel].R[i] + ttlHRes);
- v += vOH / (di->rgb[channel].R[i] + ttlHRes);
+ rTotal += 1.0 / (di.rgb[channel].R[i] + ttlHRes);
+ v += vOH / (di.rgb[channel].R[i] + ttlHRes);
}
}
}
@@ -673,7 +669,7 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
v *= rTotal;
v = MAX(minout, v - cut);
- switch (di->options & RES_NET_MONITOR_MASK)
+ switch (di.options & RES_NET_MONITOR_MASK)
{
case RES_NET_MONITOR_INVERT:
v = vcc - v;
@@ -693,30 +689,28 @@ int compute_res_net(int inputs, int channel, const res_net_info *di)
return (int) (v * 255 / vcc + 0.4);
}
-rgb_t *compute_res_net_all(running_machine &machine, const UINT8 *prom, const res_net_decode_info *rdi, const res_net_info *di)
+void compute_res_net_all(dynamic_array<rgb_t> &rgb, const UINT8 *prom, const res_net_decode_info &rdi, const res_net_info &di)
{
UINT8 r,g,b;
int i,j,k;
- rgb_t *rgb;
- rgb = auto_alloc_array(machine, rgb_t, rdi->end - rdi->start + 1);
- for (i=rdi->start; i<=rdi->end; i++)
+ rgb.resize(rdi.end - rdi.start + 1);
+ for (i=rdi.start; i<=rdi.end; i++)
{
UINT8 t[3] = {0,0,0};
int s;
- for (j=0;j<rdi->numcomp;j++)
+ for (j=0;j<rdi.numcomp;j++)
for (k=0; k<3; k++)
{
- s = rdi->shift[3*j+k];
+ s = rdi.shift[3*j+k];
if (s>0)
- t[k] = t[k] | ( (prom[i+rdi->offset[3*j+k]]>>s) & rdi->mask[3*j+k]);
+ t[k] = t[k] | ( (prom[i+rdi.offset[3*j+k]]>>s) & rdi.mask[3*j+k]);
else
- t[k] = t[k] | ( (prom[i+rdi->offset[3*j+k]]<<(0-s)) & rdi->mask[3*j+k]);
+ t[k] = t[k] | ( (prom[i+rdi.offset[3*j+k]]<<(0-s)) & rdi.mask[3*j+k]);
}
r = compute_res_net(t[0], RES_NET_CHAN_RED, di);
g = compute_res_net(t[1], RES_NET_CHAN_GREEN, di);
b = compute_res_net(t[2], RES_NET_CHAN_BLUE, di);
- rgb[i-rdi->start] = rgb_t(r,g,b);
+ rgb[i-rdi.start] = rgb_t(r,g,b);
}
- return rgb;
}
diff --git a/src/emu/video/resnet.h b/src/emu/video/resnet.h
index 9c76d609a9d..3dae2bbb11f 100644
--- a/src/emu/video/resnet.h
+++ b/src/emu/video/resnet.h
@@ -153,11 +153,11 @@ struct res_net_decode_info {
/* return a single value for one channel */
-int compute_res_net(int inputs, int channel, const res_net_info *di);
+int compute_res_net(int inputs, int channel, const res_net_info &di);
/* compute all values */
-rgb_t *compute_res_net_all(running_machine &machine, const UINT8 *prom, const res_net_decode_info *rdi, const res_net_info *di);
+void compute_res_net_all(dynamic_array<rgb_t> &rgb, const UINT8 *prom, const res_net_decode_info &rdi, const res_net_info &di);
/* legacy interface */
diff --git a/src/emu/video/voodoo.c b/src/emu/video/voodoo.c
index 7187ae621d1..55c321fade4 100644
--- a/src/emu/video/voodoo.c
+++ b/src/emu/video/voodoo.c
@@ -5709,6 +5709,11 @@ voodoo_device::voodoo_device(const machine_config &mconfig, device_type type, co
m_token = global_alloc_clear(voodoo_state);
}
+voodoo_device::~voodoo_device()
+{
+ global_free(m_token);
+}
+
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
diff --git a/src/emu/video/voodoo.h b/src/emu/video/voodoo.h
index 5e0b13bf886..e7a2e6d9f2f 100644
--- a/src/emu/video/voodoo.h
+++ b/src/emu/video/voodoo.h
@@ -97,10 +97,10 @@ class voodoo_device : public device_t
{
public:
voodoo_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
- ~voodoo_device() { global_free(m_token); }
+ ~voodoo_device();
// access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
+ struct voodoo_state *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
virtual void device_config_complete();
@@ -108,7 +108,7 @@ protected:
virtual void device_reset();
private:
// internal state
- void *m_token;
+ struct voodoo_state *m_token;
};
class voodoo_1_device : public voodoo_device