mirror of
https://github.com/holub/mame
synced 2025-04-20 23:42:22 +03:00
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)
This commit is contained in:
parent
b05606404a
commit
4ea9df02a1
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -3615,6 +3615,8 @@ src/lib/util/chdcd.c svneol=native#text/plain
|
||||
src/lib/util/chdcd.h svneol=native#text/plain
|
||||
src/lib/util/chdcodec.c svneol=native#text/plain
|
||||
src/lib/util/chdcodec.h svneol=native#text/plain
|
||||
src/lib/util/corealloc.c svneol=native#text/plain
|
||||
src/lib/util/corealloc.h svneol=native#text/plain
|
||||
src/lib/util/corefile.c svneol=native#text/plain
|
||||
src/lib/util/corefile.h svneol=native#text/plain
|
||||
src/lib/util/corestr.c svneol=native#text/plain
|
||||
@ -3622,6 +3624,8 @@ src/lib/util/corestr.h svneol=native#text/plain
|
||||
src/lib/util/coretmpl.h svneol=native#text/plain
|
||||
src/lib/util/coreutil.c svneol=native#text/plain
|
||||
src/lib/util/coreutil.h svneol=native#text/plain
|
||||
src/lib/util/cstrpool.c svneol=native#text/plain
|
||||
src/lib/util/cstrpool.h svneol=native#text/plain
|
||||
src/lib/util/flac.c svneol=native#text/plain
|
||||
src/lib/util/flac.h svneol=native#text/plain
|
||||
src/lib/util/harddisk.c svneol=native#text/plain
|
||||
|
@ -12,15 +12,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "corefile.h"
|
||||
#include "cstrpool.h"
|
||||
|
||||
|
||||
#define MAX_DRIVERS 65536
|
||||
#define MAX_IGNORE 512
|
||||
|
||||
static const char *drivlist[MAX_DRIVERS];
|
||||
static int drivcount;
|
||||
static const char *ignorelst[MAX_IGNORE];
|
||||
static int ignorecount;
|
||||
static dynamic_array<const char *> drivlist;
|
||||
static dynamic_array<const char *> ignorelst;
|
||||
static const_string_pool string_pool;
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -42,11 +39,9 @@ int sort_callback(const void *elem1, const void *elem2)
|
||||
|
||||
bool isignored(const char *drivname)
|
||||
{
|
||||
if (ignorecount>0) {
|
||||
for(int i=0;i<ignorecount;i++) {
|
||||
if (strcmp(ignorelst[i],drivname)==0) return true;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < ignorelst.count(); i++)
|
||||
if (strcmp(ignorelst[i], drivname) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,9 +53,8 @@ bool isignored(const char *drivname)
|
||||
int parse_file(const char *srcfile)
|
||||
{
|
||||
// read source file
|
||||
void *buffer;
|
||||
UINT32 length;
|
||||
file_error filerr = core_fload(srcfile, &buffer, &length);
|
||||
dynamic_buffer buffer;
|
||||
file_error filerr = core_fload(srcfile, buffer);
|
||||
if (filerr != FILERR_NONE)
|
||||
{
|
||||
fprintf(stderr, "Unable to read source file '%s'\n", srcfile);
|
||||
@ -68,8 +62,8 @@ int parse_file(const char *srcfile)
|
||||
}
|
||||
|
||||
// rip through it to find all drivers
|
||||
char *srcptr = (char *)buffer;
|
||||
char *endptr = srcptr + length;
|
||||
char *srcptr = (char *)&buffer[0];
|
||||
char *endptr = srcptr + buffer.count();
|
||||
int linenum = 1;
|
||||
bool in_comment = false;
|
||||
while (srcptr < endptr)
|
||||
@ -141,9 +135,7 @@ int parse_file(const char *srcfile)
|
||||
drivname[pos+1] = 0;
|
||||
}
|
||||
fprintf(stderr, "Place driver '%s' to ignore list\n", drivname);
|
||||
char *name = (char *)malloc(strlen(drivname) + 1);
|
||||
strcpy(name, drivname);
|
||||
ignorelst[ignorecount++] = name;
|
||||
ignorelst.append(string_pool.add(drivname));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -167,16 +159,10 @@ int parse_file(const char *srcfile)
|
||||
}
|
||||
|
||||
// add it to the list
|
||||
if(!isignored(drivname))
|
||||
{
|
||||
char *name = (char *)malloc(strlen(drivname) + 1);
|
||||
strcpy(name, drivname);
|
||||
drivlist[drivcount++] = name;
|
||||
}
|
||||
if (!isignored(drivname))
|
||||
drivlist.append(string_pool.add(drivname));
|
||||
}
|
||||
|
||||
osd_free(buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -201,44 +187,42 @@ int main(int argc, char *argv[])
|
||||
const char *srcfile = argv[1];
|
||||
|
||||
// parse the root file, exit early upon failure
|
||||
drivcount = 0;
|
||||
ignorecount = 0;
|
||||
if (parse_file(srcfile))
|
||||
return 1;
|
||||
|
||||
// output a count
|
||||
if (drivcount == 0)
|
||||
if (drivlist.count() == 0)
|
||||
{
|
||||
fprintf(stderr, "No drivers found\n");
|
||||
return 1;
|
||||
}
|
||||
fprintf(stderr, "%d drivers found\n", drivcount);
|
||||
fprintf(stderr, "%d drivers found\n", drivlist.count());
|
||||
|
||||
// add a reference to the ___empty driver
|
||||
drivlist[drivcount++] = "___empty";
|
||||
drivlist.append("___empty");
|
||||
|
||||
// sort the list
|
||||
qsort(drivlist, drivcount, sizeof(*drivlist), sort_callback);
|
||||
qsort(drivlist, drivlist.count(), sizeof(drivlist[0]), sort_callback);
|
||||
|
||||
// start with a header
|
||||
printf("#include \"emu.h\"\n\n");
|
||||
printf("#include \"drivenum.h\"\n\n");
|
||||
|
||||
// output the list of externs first
|
||||
for (int index = 0; index < drivcount; index++)
|
||||
for (int index = 0; index < drivlist.count(); index++)
|
||||
printf("GAME_EXTERN(%s);\n", drivlist[index]);
|
||||
printf("\n");
|
||||
|
||||
// then output the array
|
||||
printf("const game_driver * const driver_list::s_drivers_sorted[%d] =\n", drivcount);
|
||||
printf("const game_driver * const driver_list::s_drivers_sorted[%d] =\n", drivlist.count());
|
||||
printf("{\n");
|
||||
for (int index = 0; index < drivcount; index++)
|
||||
printf("\t&GAME_NAME(%s)%s\n", drivlist[index], (index == drivcount - 1) ? "" : ",");
|
||||
for (int index = 0; index < drivlist.count(); index++)
|
||||
printf("\t&GAME_NAME(%s)%s\n", drivlist[index], (index == drivlist.count() - 1) ? "" : ",");
|
||||
printf("};\n");
|
||||
printf("\n");
|
||||
|
||||
// also output a global count
|
||||
printf("int driver_list::s_driver_count = %d;\n", drivcount);
|
||||
printf("int driver_list::s_driver_count = %d;\n", drivlist.count());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Aaron Giles
|
||||
/***************************************************************************
|
||||
|
||||
png2bdc.c
|
||||
|
||||
Super-simple PNG to BDC file generator
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
****************************************************************************
|
||||
|
||||
Format of PNG data:
|
||||
@ -54,227 +53,219 @@
|
||||
#include "png.h"
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
CONSTANTS & DEFINES
|
||||
***************************************************************************/
|
||||
//**************************************************************************
|
||||
// CONSTANTS & DEFINES
|
||||
//**************************************************************************
|
||||
|
||||
#define CACHED_CHAR_SIZE 12
|
||||
#define CACHED_HEADER_SIZE 16
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
/* a render_font contains information about a single character in a font */
|
||||
// a render_font contains information about a single character in a font
|
||||
struct render_font_char
|
||||
{
|
||||
INT32 width; /* width from this character to the next */
|
||||
INT32 xoffs, yoffs; /* X and Y offset from baseline to top,left of bitmap */
|
||||
INT32 bmwidth, bmheight; /* width and height of bitmap */
|
||||
bitmap_argb32 * bitmap; /* pointer to the bitmap containing the raw data */
|
||||
render_font_char() : width(0), xoffs(0), yoffs(0), bmwidth(0), bmheight(0) { }
|
||||
|
||||
INT32 width; // width from this character to the next
|
||||
INT32 xoffs, yoffs; // X and Y offset from baseline to top,left of bitmap
|
||||
INT32 bmwidth, bmheight; // width and height of bitmap
|
||||
bitmap_argb32 * bitmap; // pointer to the bitmap containing the raw data
|
||||
};
|
||||
|
||||
|
||||
/* a render_font contains information about a font */
|
||||
// a render_font contains information about a font
|
||||
struct render_font
|
||||
{
|
||||
int height; /* height of the font, from ascent to descent */
|
||||
int yoffs; /* y offset from baseline to descent */
|
||||
render_font_char chars[65536]; /* array of characters */
|
||||
render_font() : height(0), yoffs(0) { }
|
||||
|
||||
int height; // height of the font, from ascent to descent
|
||||
int yoffs; // y offset from baseline to descent
|
||||
render_font_char chars[65536]; // array of characters
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
INLINE FUNCTIONS
|
||||
***************************************************************************/
|
||||
//**************************************************************************
|
||||
// INLINE FUNCTIONS
|
||||
//**************************************************************************
|
||||
|
||||
INLINE int pixel_is_set(bitmap_argb32 &bitmap, int y, int x)
|
||||
inline int pixel_is_set(bitmap_argb32 &bitmap, int y, int x)
|
||||
{
|
||||
return (bitmap.pix32(y, x) & 0xffffff) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
MAIN
|
||||
***************************************************************************/
|
||||
//**************************************************************************
|
||||
// MAIN
|
||||
//**************************************************************************
|
||||
|
||||
static int render_font_save_cached(render_font *font, const char *filename, UINT32 hash)
|
||||
//-------------------------------------------------
|
||||
// write_data - write data to the given file and
|
||||
// throw an exception if an error occurs
|
||||
//-------------------------------------------------
|
||||
|
||||
static void write_data(core_file &file, UINT8 *base, UINT8 *end)
|
||||
{
|
||||
file_error filerr;
|
||||
render_font_char *ch;
|
||||
UINT32 bytes_written;
|
||||
UINT8 *tempbuffer;
|
||||
UINT8 *chartable;
|
||||
core_file *file;
|
||||
int numchars;
|
||||
UINT8 *dest;
|
||||
int tableindex;
|
||||
int chnum;
|
||||
|
||||
/* attempt to open the file */
|
||||
filerr = core_fopen(filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file);
|
||||
if (filerr != FILERR_NONE)
|
||||
return 1;
|
||||
|
||||
/* determine the number of characters */
|
||||
numchars = 0;
|
||||
for (chnum = 0; chnum < 65536; chnum++)
|
||||
if (font->chars[chnum].width > 0)
|
||||
numchars++;
|
||||
|
||||
/* allocate an array to hold the character data */
|
||||
chartable = (UINT8 *)malloc(numchars * CACHED_CHAR_SIZE);
|
||||
|
||||
/* allocate a temp buffer to compress into */
|
||||
tempbuffer = (UINT8 *)malloc(65536);
|
||||
if (chartable == NULL || tempbuffer == NULL)
|
||||
goto error;
|
||||
|
||||
memset(chartable, 0, numchars * CACHED_CHAR_SIZE);
|
||||
|
||||
/* write the header */
|
||||
dest = tempbuffer;
|
||||
*dest++ = 'f';
|
||||
*dest++ = 'o';
|
||||
*dest++ = 'n';
|
||||
*dest++ = 't';
|
||||
*dest++ = hash >> 24;
|
||||
*dest++ = hash >> 16;
|
||||
*dest++ = hash >> 8;
|
||||
*dest++ = hash & 0xff;
|
||||
*dest++ = font->height >> 8;
|
||||
*dest++ = font->height & 0xff;
|
||||
*dest++ = font->yoffs >> 8;
|
||||
*dest++ = font->yoffs & 0xff;
|
||||
*dest++ = numchars >> 24;
|
||||
*dest++ = numchars >> 16;
|
||||
*dest++ = numchars >> 8;
|
||||
*dest++ = numchars & 0xff;
|
||||
bytes_written = core_fwrite(file, tempbuffer, dest - tempbuffer);
|
||||
if (bytes_written != dest - tempbuffer)
|
||||
goto error;
|
||||
|
||||
/* write the empty table to the beginning of the file */
|
||||
bytes_written = core_fwrite(file, chartable, numchars * CACHED_CHAR_SIZE);
|
||||
if (bytes_written != numchars * CACHED_CHAR_SIZE)
|
||||
goto error;
|
||||
|
||||
/* loop over all characters */
|
||||
tableindex = 0;
|
||||
for (chnum = 0; chnum < 65536; chnum++)
|
||||
UINT32 bytes_written = core_fwrite(&file, base, end - base);
|
||||
if (bytes_written != end - base)
|
||||
{
|
||||
ch = &font->chars[chnum];
|
||||
if (ch->width > 0)
|
||||
{
|
||||
UINT8 accum, accbit;
|
||||
int x, y;
|
||||
|
||||
/* write out a bit-compressed bitmap if we have one */
|
||||
if (ch->bitmap != NULL)
|
||||
{
|
||||
/* write the data to the tempbuffer */
|
||||
dest = tempbuffer;
|
||||
accum = 0;
|
||||
accbit = 7;
|
||||
|
||||
/* bit-encode the character data */
|
||||
for (y = 0; y < ch->bmheight; y++)
|
||||
{
|
||||
int desty = y + font->height + font->yoffs - ch->yoffs - ch->bmheight;
|
||||
const UINT32 *src = (desty >= 0 && desty < font->height) ? &ch->bitmap->pix32(desty) : NULL;
|
||||
for (x = 0; x < ch->bmwidth; x++)
|
||||
{
|
||||
if (src != NULL && src[x] != 0)
|
||||
accum |= 1 << accbit;
|
||||
if (accbit-- == 0)
|
||||
{
|
||||
*dest++ = accum;
|
||||
accum = 0;
|
||||
accbit = 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* flush any extra */
|
||||
if (accbit != 7)
|
||||
*dest++ = accum;
|
||||
|
||||
/* write the data */
|
||||
bytes_written = core_fwrite(file, tempbuffer, dest - tempbuffer);
|
||||
if (bytes_written != dest - tempbuffer)
|
||||
goto error;
|
||||
|
||||
/* free the bitmap and texture */
|
||||
delete ch->bitmap;
|
||||
ch->bitmap = NULL;
|
||||
}
|
||||
|
||||
/* compute the table entry */
|
||||
dest = &chartable[tableindex++ * CACHED_CHAR_SIZE];
|
||||
*dest++ = chnum >> 8;
|
||||
*dest++ = chnum & 0xff;
|
||||
*dest++ = ch->width >> 8;
|
||||
*dest++ = ch->width & 0xff;
|
||||
*dest++ = ch->xoffs >> 8;
|
||||
*dest++ = ch->xoffs & 0xff;
|
||||
*dest++ = ch->yoffs >> 8;
|
||||
*dest++ = ch->yoffs & 0xff;
|
||||
*dest++ = ch->bmwidth >> 8;
|
||||
*dest++ = ch->bmwidth & 0xff;
|
||||
*dest++ = ch->bmheight >> 8;
|
||||
*dest++ = ch->bmheight & 0xff;
|
||||
}
|
||||
fprintf(stderr, "Error writing to destination file\n");
|
||||
throw;
|
||||
}
|
||||
|
||||
/* seek back to the beginning and rewrite the table */
|
||||
core_fseek(file, CACHED_HEADER_SIZE, SEEK_SET);
|
||||
bytes_written = core_fwrite(file, chartable, numchars * CACHED_CHAR_SIZE);
|
||||
if (bytes_written != numchars * CACHED_CHAR_SIZE)
|
||||
goto error;
|
||||
|
||||
/* all done */
|
||||
core_fclose(file);
|
||||
free(tempbuffer);
|
||||
free(chartable);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
core_fclose(file);
|
||||
osd_rmfile(filename);
|
||||
free(tempbuffer);
|
||||
free(chartable);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
bitmap_to_chars - convert a bitmap to
|
||||
characters in the given font
|
||||
-------------------------------------------------*/
|
||||
//-------------------------------------------------
|
||||
// render_font_save_cached - write the cached
|
||||
// data out to the file
|
||||
//-------------------------------------------------
|
||||
|
||||
static int bitmap_to_chars(bitmap_argb32 &bitmap, render_font *font)
|
||||
static bool render_font_save_cached(render_font &font, const char *filename, UINT32 hash)
|
||||
{
|
||||
int rowstart = 0;
|
||||
int x, y;
|
||||
// attempt to open the file
|
||||
core_file *file;
|
||||
file_error filerr = core_fopen(filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &file);
|
||||
if (filerr != FILERR_NONE)
|
||||
return true;
|
||||
|
||||
/* loop over rows */
|
||||
try
|
||||
{
|
||||
// determine the number of characters
|
||||
int numchars = 0;
|
||||
for (int chnum = 0; chnum < 65536; chnum++)
|
||||
if (font.chars[chnum].width > 0)
|
||||
numchars++;
|
||||
|
||||
// write the header
|
||||
dynamic_buffer tempbuffer(65536);
|
||||
UINT8 *dest = &tempbuffer[0];
|
||||
*dest++ = 'f';
|
||||
*dest++ = 'o';
|
||||
*dest++ = 'n';
|
||||
*dest++ = 't';
|
||||
*dest++ = hash >> 24;
|
||||
*dest++ = hash >> 16;
|
||||
*dest++ = hash >> 8;
|
||||
*dest++ = hash & 0xff;
|
||||
*dest++ = font.height >> 8;
|
||||
*dest++ = font.height & 0xff;
|
||||
*dest++ = font.yoffs >> 8;
|
||||
*dest++ = font.yoffs & 0xff;
|
||||
*dest++ = numchars >> 24;
|
||||
*dest++ = numchars >> 16;
|
||||
*dest++ = numchars >> 8;
|
||||
*dest++ = numchars & 0xff;
|
||||
write_data(*file, tempbuffer, dest);
|
||||
|
||||
// write the empty table to the beginning of the file
|
||||
dynamic_buffer chartable(numchars * CACHED_CHAR_SIZE + 1, 0);
|
||||
write_data(*file, &chartable[0], &chartable[numchars * CACHED_CHAR_SIZE]);
|
||||
|
||||
// loop over all characters
|
||||
int tableindex = 0;
|
||||
for (int chnum = 0; chnum < 65536; chnum++)
|
||||
{
|
||||
render_font_char &ch = font.chars[chnum];
|
||||
if (ch.width > 0)
|
||||
{
|
||||
// write out a bit-compressed bitmap if we have one
|
||||
if (ch.bitmap != NULL)
|
||||
{
|
||||
// write the data to the tempbuffer
|
||||
dest = tempbuffer;
|
||||
UINT8 accum = 0;
|
||||
UINT8 accbit = 7;
|
||||
|
||||
// bit-encode the character data
|
||||
for (int y = 0; y < ch.bmheight; y++)
|
||||
{
|
||||
int desty = y + font.height + font.yoffs - ch.yoffs - ch.bmheight;
|
||||
const UINT32 *src = (desty >= 0 && desty < font.height) ? &ch.bitmap->pix32(desty) : NULL;
|
||||
for (int x = 0; x < ch.bmwidth; x++)
|
||||
{
|
||||
if (src != NULL && src[x] != 0)
|
||||
accum |= 1 << accbit;
|
||||
if (accbit-- == 0)
|
||||
{
|
||||
*dest++ = accum;
|
||||
accum = 0;
|
||||
accbit = 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// flush any extra
|
||||
if (accbit != 7)
|
||||
*dest++ = accum;
|
||||
|
||||
// write the data
|
||||
write_data(*file, tempbuffer, dest);
|
||||
|
||||
// free the bitmap and texture
|
||||
global_free(ch.bitmap);
|
||||
ch.bitmap = NULL;
|
||||
}
|
||||
|
||||
// compute the table entry
|
||||
dest = &chartable[tableindex++ * CACHED_CHAR_SIZE];
|
||||
*dest++ = chnum >> 8;
|
||||
*dest++ = chnum & 0xff;
|
||||
*dest++ = ch.width >> 8;
|
||||
*dest++ = ch.width & 0xff;
|
||||
*dest++ = ch.xoffs >> 8;
|
||||
*dest++ = ch.xoffs & 0xff;
|
||||
*dest++ = ch.yoffs >> 8;
|
||||
*dest++ = ch.yoffs & 0xff;
|
||||
*dest++ = ch.bmwidth >> 8;
|
||||
*dest++ = ch.bmwidth & 0xff;
|
||||
*dest++ = ch.bmheight >> 8;
|
||||
*dest++ = ch.bmheight & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
// seek back to the beginning and rewrite the table
|
||||
core_fseek(file, CACHED_HEADER_SIZE, SEEK_SET);
|
||||
write_data(*file, &chartable[0], &chartable[numchars * CACHED_CHAR_SIZE]);
|
||||
|
||||
// all done
|
||||
core_fclose(file);
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
core_fclose(file);
|
||||
osd_rmfile(filename);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// bitmap_to_chars - convert a bitmap to
|
||||
// characters in the given font
|
||||
//-------------------------------------------------
|
||||
|
||||
static bool bitmap_to_chars(bitmap_argb32 &bitmap, render_font &font)
|
||||
{
|
||||
// loop over rows
|
||||
int rowstart = 0;
|
||||
while (rowstart < bitmap.height())
|
||||
{
|
||||
int rowend, baseline, colstart;
|
||||
int chstart;
|
||||
|
||||
/* find the top of the row */
|
||||
// find the top of the row
|
||||
for ( ; rowstart < bitmap.height(); rowstart++)
|
||||
if (pixel_is_set(bitmap, rowstart, 0))
|
||||
break;
|
||||
if (rowstart >= bitmap.height())
|
||||
break;
|
||||
|
||||
/* find the bottom of the row */
|
||||
// find the bottom of the row
|
||||
int rowend;
|
||||
for (rowend = rowstart + 1; rowend < bitmap.height(); rowend++)
|
||||
if (!pixel_is_set(bitmap, rowend, 0))
|
||||
{
|
||||
@ -282,7 +273,8 @@ static int bitmap_to_chars(bitmap_argb32 &bitmap, render_font *font)
|
||||
break;
|
||||
}
|
||||
|
||||
/* find the baseline */
|
||||
// find the baseline
|
||||
int baseline;
|
||||
for (baseline = rowstart; baseline <= rowend; baseline++)
|
||||
if (pixel_is_set(bitmap, baseline, 1))
|
||||
break;
|
||||
@ -292,50 +284,50 @@ static int bitmap_to_chars(bitmap_argb32 &bitmap, render_font *font)
|
||||
break;
|
||||
}
|
||||
|
||||
/* set or confirm the height */
|
||||
if (font->height == 0)
|
||||
// set or confirm the height
|
||||
if (font.height == 0)
|
||||
{
|
||||
font->height = rowend - rowstart + 1;
|
||||
font->yoffs = baseline - rowend;
|
||||
font.height = rowend - rowstart + 1;
|
||||
font.yoffs = baseline - rowend;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (font->height != rowend - rowstart + 1)
|
||||
if (font.height != rowend - rowstart + 1)
|
||||
{
|
||||
fprintf(stderr, "Inconsistent font height at rows %d-%d\n", rowstart, rowend);
|
||||
break;
|
||||
}
|
||||
if (font->yoffs != baseline - rowend)
|
||||
if (font.yoffs != baseline - rowend)
|
||||
{
|
||||
fprintf(stderr, "Inconsistent baseline at rows %d-%d\n", rowstart, rowend);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* decode the starting character */
|
||||
chstart = 0;
|
||||
for (x = 0; x < 4; x++)
|
||||
for (y = 0; y < 4; y++)
|
||||
// decode the starting character
|
||||
int chstart = 0;
|
||||
for (int x = 0; x < 4; x++)
|
||||
for (int y = 0; y < 4; y++)
|
||||
chstart = (chstart << 1) | pixel_is_set(bitmap, rowstart + y, 2 + x);
|
||||
|
||||
/* print info */
|
||||
// print info
|
||||
// printf("Row %d-%d, baseline %d, character start %X\n", rowstart, rowend, baseline, chstart);
|
||||
|
||||
/* scan the column to find characters */
|
||||
colstart = 0;
|
||||
// scan the column to find characters
|
||||
int colstart = 0;
|
||||
while (colstart < bitmap.width())
|
||||
{
|
||||
render_font_char *ch = &font->chars[chstart];
|
||||
int colend;
|
||||
render_font_char &ch = font.chars[chstart];
|
||||
|
||||
/* find the start of the character */
|
||||
// find the start of the character
|
||||
for ( ; colstart < bitmap.width(); colstart++)
|
||||
if (pixel_is_set(bitmap, rowend + 2, colstart))
|
||||
break;
|
||||
if (colstart >= bitmap.width())
|
||||
break;
|
||||
|
||||
/* find the end of the character */
|
||||
// find the end of the character
|
||||
int colend;
|
||||
for (colend = colstart + 1; colend < bitmap.width(); colend++)
|
||||
if (!pixel_is_set(bitmap, rowend + 2, colend))
|
||||
{
|
||||
@ -344,82 +336,68 @@ static int bitmap_to_chars(bitmap_argb32 &bitmap, render_font *font)
|
||||
}
|
||||
|
||||
// skip char which code is already registered
|
||||
if (ch->width <= 0)
|
||||
if (ch.width <= 0)
|
||||
{
|
||||
/* print info */
|
||||
// print info
|
||||
// printf(" Character %X - width = %d\n", chstart, colend - colstart + 1);
|
||||
|
||||
/* allocate a bitmap */
|
||||
ch->bitmap = new(std::nothrow) bitmap_argb32(colend - colstart + 1, font->height);
|
||||
if (ch->bitmap == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error allocating character bitmap (%dx%d)\n", colend - colstart + 1, font->height);
|
||||
continue;
|
||||
}
|
||||
// allocate a bitmap
|
||||
ch.bitmap = global_alloc(bitmap_argb32(colend - colstart + 1, font.height));
|
||||
|
||||
/* plot the character */
|
||||
for (y = rowstart; y <= rowend; y++)
|
||||
for (x = colstart; x <= colend; x++)
|
||||
ch->bitmap->pix32(y - rowstart, x - colstart) = pixel_is_set(bitmap, y, x) ? 0xffffffff : 0x00000000;
|
||||
// plot the character
|
||||
for (int y = rowstart; y <= rowend; y++)
|
||||
for (int x = colstart; x <= colend; x++)
|
||||
ch.bitmap->pix32(y - rowstart, x - colstart) = pixel_is_set(bitmap, y, x) ? 0xffffffff : 0x00000000;
|
||||
|
||||
/* set the character parameters */
|
||||
ch->width = colend - colstart + 1;
|
||||
ch->xoffs = 0;
|
||||
ch->yoffs = font->yoffs;
|
||||
ch->bmwidth = ch->bitmap->width();
|
||||
ch->bmheight = ch->bitmap->height();
|
||||
// set the character parameters
|
||||
ch.width = colend - colstart + 1;
|
||||
ch.xoffs = 0;
|
||||
ch.yoffs = font.yoffs;
|
||||
ch.bmwidth = ch.bitmap->width();
|
||||
ch.bmheight = ch.bitmap->height();
|
||||
}
|
||||
|
||||
/* next character */
|
||||
// next character
|
||||
chstart++;
|
||||
colstart = colend + 1;
|
||||
}
|
||||
|
||||
/* next row */
|
||||
// next row
|
||||
rowstart = rowend + 1;
|
||||
}
|
||||
|
||||
/* return non-zero (TRUE) if we errored */
|
||||
// return non-zero (TRUE) if we errored
|
||||
return (rowstart < bitmap.height());
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
main - main entry point
|
||||
-------------------------------------------------*/
|
||||
//-------------------------------------------------
|
||||
// main - main entry point
|
||||
//-------------------------------------------------
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *bdcname;
|
||||
render_font *font;
|
||||
int error = FALSE;
|
||||
int curarg;
|
||||
|
||||
/* validate arguments */
|
||||
// validate arguments
|
||||
if (argc < 3)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n%s <input.png> [<input2.png> [...]] <output.bdc>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
bdcname = argv[argc - 1];
|
||||
const char *bdcname = argv[argc - 1];
|
||||
|
||||
/* allocate a font */
|
||||
font = (render_font *)malloc(sizeof(*font));
|
||||
if (font == NULL)
|
||||
return 1;
|
||||
memset(font, 0, sizeof(*font));
|
||||
|
||||
/* iterate over input files */
|
||||
for (curarg = 1; curarg < argc - 1; curarg++)
|
||||
// iterate over input files
|
||||
static render_font font;
|
||||
bool error = false;
|
||||
for (int curarg = 1; curarg < argc - 1; curarg++)
|
||||
{
|
||||
/* load the png file */
|
||||
// load the png file
|
||||
const char *pngname = argv[curarg];
|
||||
core_file *file;
|
||||
file_error filerr = core_fopen(pngname, OPEN_FLAG_READ, &file);
|
||||
if (filerr != FILERR_NONE)
|
||||
{
|
||||
fprintf(stderr, "Error %d attempting to open PNG file\n", filerr);
|
||||
error = TRUE;
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -429,21 +407,20 @@ int main(int argc, char *argv[])
|
||||
if (pngerr != PNGERR_NONE)
|
||||
{
|
||||
fprintf(stderr, "Error %d reading PNG file\n", pngerr);
|
||||
error = TRUE;
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
/* parse the PNG into characters */
|
||||
// parse the PNG into characters
|
||||
error = bitmap_to_chars(bitmap, font);
|
||||
if (error)
|
||||
break;
|
||||
}
|
||||
|
||||
/* write out the resulting font */
|
||||
// write out the resulting font
|
||||
if (!error)
|
||||
render_font_save_cached(font, bdcname, 0);
|
||||
error = render_font_save_cached(font, bdcname, 0);
|
||||
|
||||
/* cleanup after ourselves */
|
||||
free(font);
|
||||
return error;
|
||||
// cleanup after ourselves
|
||||
return error ? 1 : 0;
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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); }
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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); }
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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); }
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 ¶mnode)
|
||||
: m_value(0),
|
||||
m_itemlist(manager.machine().respool())
|
||||
: m_value(0)
|
||||
{
|
||||
// read the core attributes
|
||||
m_minval = number_and_format(xml_get_attribute_int(¶mnode, "min", 0), xml_get_attribute_int_format(¶mnode, "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
|
||||
|
@ -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
|
||||
|
@ -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 ) );
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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),
|
||||
@ -341,6 +231,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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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++)
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -195,22 +183,6 @@ image_error_t device_image_interface::set_image_filename(const char *filename)
|
||||
CREATION FORMATS
|
||||
****************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
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
|
||||
@ -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);
|
||||
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();
|
||||
// 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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
//-------------------------------------------------
|
||||
|
||||
void driver_enumerator::release_current()
|
||||
{
|
||||
}
|
||||
// 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;
|
||||
|
||||
|
||||
driver_enumerator::config_entry::~config_entry()
|
||||
{
|
||||
global_free(m_config);
|
||||
// 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();
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -20,196 +20,11 @@
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// 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);
|
||||
}
|
||||
|
@ -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__ */
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
// iterate through all slot devices
|
||||
options_entry entry[2] = { { 0 }, { 0 } };
|
||||
bool first = true;
|
||||
// iterate through all image devices
|
||||
machine_config config(*cursystem, *this);
|
||||
|
||||
// iterate through all image devices
|
||||
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();
|
||||
}
|
||||
|
@ -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__ */
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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__ */
|
||||
|
@ -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; }
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user