summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/emu/audit.c26
-rw-r--r--src/emu/cheat.c199
-rw-r--r--src/emu/cheat.h2
-rw-r--r--src/emu/clifront.c42
-rw-r--r--src/emu/config.c17
-rw-r--r--src/emu/cpu/x86log.c7
-rw-r--r--src/emu/cpu/z80/z80daisy.c3
-rw-r--r--src/emu/debug/debugcmd.c10
-rw-r--r--src/emu/debug/debugcmt.c12
-rw-r--r--src/emu/debug/debugvw.c59
-rw-r--r--src/emu/devintrf.c33
-rw-r--r--src/emu/devintrf.h4
-rw-r--r--src/emu/fileio.c75
-rw-r--r--src/emu/fileio.h2
-rw-r--r--src/emu/inptport.c7
-rw-r--r--src/emu/input.c69
-rw-r--r--src/emu/input.h4
-rw-r--r--src/emu/inputseq.c39
-rw-r--r--src/emu/inputseq.h4
-rw-r--r--src/emu/machine/generic.c27
-rw-r--r--src/emu/machine/ldpr8210.c6
-rw-r--r--src/emu/machine/ldv1000.c3
-rw-r--r--src/emu/machine/ldvp931.c3
-rw-r--r--src/emu/machine/z80ctc.c4
-rw-r--r--src/emu/machine/z80sio.c4
-rw-r--r--src/emu/mame.c81
-rw-r--r--src/emu/mame.h1
-rw-r--r--src/emu/mconfig.c6
-rw-r--r--src/emu/memory.c20
-rw-r--r--src/emu/memory.h4
-rw-r--r--src/emu/profiler.c16
-rw-r--r--src/emu/profiler.h2
-rw-r--r--src/emu/rendlay.c12
-rw-r--r--src/emu/rendutil.c9
-rw-r--r--src/emu/romload.c115
-rw-r--r--src/emu/romload.h2
-rw-r--r--src/emu/sound.c11
-rw-r--r--src/emu/sound/2610intf.c9
-rw-r--r--src/emu/sound/samples.c11
-rw-r--r--src/emu/state.c19
-rw-r--r--src/emu/ui.c227
-rw-r--r--src/emu/ui.h2
-rw-r--r--src/emu/uimenu.c102
-rw-r--r--src/emu/validity.c30
-rw-r--r--src/emu/video.c50
-rw-r--r--src/ldplayer/ldplayer.c7
-rw-r--r--src/lib/util/astring.c6
-rw-r--r--src/lib/util/astring.h103
-rw-r--r--src/mame/audio/namco52.c3
-rw-r--r--src/mame/audio/namco54.c3
-rw-r--r--src/mame/machine/namco50.c3
-rw-r--r--src/mame/machine/namco51.c3
-rw-r--r--src/mame/machine/namco53.c3
53 files changed, 680 insertions, 841 deletions
diff --git a/src/emu/audit.c b/src/emu/audit.c
index 0a9aa420c64..afca856eefe 100644
--- a/src/emu/audit.c
+++ b/src/emu/audit.c
@@ -192,19 +192,17 @@ int audit_samples(core_options *options, const game_driver *gamedrv, audit_recor
{
file_error filerr;
mame_file *file;
- astring *fname;
/* attempt to access the file from the game driver name */
- fname = astring_assemble_3(astring_alloc(), gamedrv->name, PATH_SEPARATOR, intf->samplenames[sampnum]);
- filerr = mame_fopen_options(options, SEARCHPATH_SAMPLE, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
+ astring fname(gamedrv->name, PATH_SEPARATOR, intf->samplenames[sampnum]);
+ filerr = mame_fopen_options(options, SEARCHPATH_SAMPLE, fname, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
/* attempt to access the file from the shared driver name */
if (filerr != FILERR_NONE && sharedname != NULL)
{
- astring_assemble_3(fname, sharedname, PATH_SEPARATOR, intf->samplenames[sampnum]);
- filerr = mame_fopen_options(options, SEARCHPATH_SAMPLE, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
+ fname.cpy(sharedname).cat(PATH_SEPARATOR).cat(intf->samplenames[sampnum]);
+ filerr = mame_fopen_options(options, SEARCHPATH_SAMPLE, fname, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
}
- astring_free(fname);
/* fill in the record */
record->type = AUDIT_FILE_SAMPLE;
@@ -353,15 +351,13 @@ static void audit_one_rom(core_options *options, const rom_entry *rom, const cha
{
file_error filerr;
mame_file *file;
- astring *fname;
/* open the file if we can */
- fname = astring_assemble_3(astring_alloc(), drv->name, PATH_SEPARATOR, ROM_GETNAME(rom));
+ astring fname(drv->name, PATH_SEPARATOR, ROM_GETNAME(rom));
if (has_crc)
- filerr = mame_fopen_crc_options(options, SEARCHPATH_ROM, astring_c(fname), crc, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
+ filerr = mame_fopen_crc_options(options, SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
else
- filerr = mame_fopen_options(options, SEARCHPATH_ROM, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
- astring_free(fname);
+ filerr = mame_fopen_options(options, SEARCHPATH_ROM, fname, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
/* if we got it, extract the hash and length */
if (filerr == FILERR_NONE)
@@ -378,15 +374,13 @@ static void audit_one_rom(core_options *options, const rom_entry *rom, const cha
{
file_error filerr;
mame_file *file;
- astring *fname;
/* open the file if we can */
- fname = astring_assemble_3(astring_alloc(), regiontag, PATH_SEPARATOR, ROM_GETNAME(rom));
+ astring fname(regiontag, PATH_SEPARATOR, ROM_GETNAME(rom));
if (has_crc)
- filerr = mame_fopen_crc_options(options, SEARCHPATH_ROM, astring_c(fname), crc, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
+ filerr = mame_fopen_crc_options(options, SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
else
- filerr = mame_fopen_options(options, SEARCHPATH_ROM, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
- astring_free(fname);
+ filerr = mame_fopen_options(options, SEARCHPATH_ROM, fname, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
/* if we got it, extract the hash and length */
if (filerr == FILERR_NONE)
diff --git a/src/emu/cheat.c b/src/emu/cheat.c
index 130f84738f8..96698f3747a 100644
--- a/src/emu/cheat.c
+++ b/src/emu/cheat.c
@@ -123,10 +123,10 @@ typedef struct _parameter_item parameter_item;
struct _parameter_item
{
parameter_item * next; /* next item in list */
- astring * text; /* name of the item */
+ astring text; /* name of the item */
UINT64 value; /* value of the item */
int valformat; /* format of value */
- astring * curtext; /* name of the current item */
+ astring curtext; /* name of the current item */
};
@@ -163,7 +163,7 @@ struct _script_entry
script_entry * next; /* link to next entry */
parsed_expression * condition; /* condition under which this is executed */
parsed_expression * expression; /* expression to execute */
- astring * format; /* string format to print */
+ astring format; /* string format to print */
output_argument * arglist; /* list of arguments */
INT8 line; /* which line to print on */
UINT8 justify; /* justification when printing */
@@ -184,8 +184,8 @@ typedef struct _cheat_entry cheat_entry;
struct _cheat_entry
{
cheat_entry * next; /* next cheat entry */
- astring * description; /* string description/menu title */
- astring * comment; /* comment data */
+ astring description; /* string description/menu title */
+ astring comment; /* comment data */
cheat_parameter * parameter; /* parameter */
cheat_script * script[SCRIPT_STATE_COUNT]; /* up to 1 script for each state */
symbol_table * symbols; /* symbol table for this cheat */
@@ -201,7 +201,7 @@ struct _cheat_private
{
cheat_entry * cheatlist; /* cheat list */
UINT64 framecount; /* frame count */
- astring * output[UI_TARGET_FONT_ROWS*2]; /* array of output strings */
+ astring output[UI_TARGET_FONT_ROWS*2]; /* array of output strings */
UINT8 justify[UI_TARGET_FONT_ROWS*2]; /* justification for each string */
UINT8 numlines; /* number of lines available for output */
INT8 lastline; /* last line used for output */
@@ -234,7 +234,7 @@ static script_entry *script_entry_load(running_machine *machine, const char *fil
static void script_entry_save(mame_file *cheatfile, const script_entry *entry);
static void script_entry_free(running_machine *machine, script_entry *entry);
-static astring *quote_astring_expression(astring *string, int isattribute);
+static astring &quote_astring_expression(astring &string, int isattribute);
static int validate_format(const char *filename, int line, const script_entry *entry);
static UINT64 cheat_variable_get(void *globalref, void *ref);
static void cheat_variable_set(void *globalref, void *ref, UINT64 value);
@@ -336,28 +336,28 @@ INLINE int is_oneshot_parameter_cheat(const cheat_entry *cheat)
the format
-------------------------------------------------*/
-INLINE const char *format_int(astring *string, UINT64 value, int format)
+INLINE const char *format_int(astring &string, UINT64 value, int format)
{
switch (format)
{
default:
case XML_INT_FORMAT_DECIMAL:
- astring_printf(string, "%d", (UINT32)value);
+ string.printf("%d", (UINT32)value);
break;
case XML_INT_FORMAT_DECIMAL_POUND:
- astring_printf(string, "#%d", (UINT32)value);
+ string.printf("#%d", (UINT32)value);
break;
case XML_INT_FORMAT_HEX_DOLLAR:
- astring_printf(string, "$%X", (UINT32)value);
+ string.printf("$%X", (UINT32)value);
break;
case XML_INT_FORMAT_HEX_C:
- astring_printf(string, "0x%X", (UINT32)value);
+ string.printf("0x%X", (UINT32)value);
break;
}
- return astring_c(string);
+ return string;
}
@@ -406,7 +406,8 @@ void cheat_reload(running_machine *machine)
cheat_exit(machine);
/* reset our memory */
- memset(cheatinfo, 0, sizeof(*cheatinfo));
+ auto_free(machine, cheatinfo);
+ cheatinfo = machine->cheat_data = auto_alloc_clear(machine, cheat_private);
/* load the cheat file, MESS will load a crc32.xml ( eg. 01234567.xml )
and MAME will load gamename.xml */
@@ -434,16 +435,10 @@ void cheat_reload(running_machine *machine)
static void cheat_exit(running_machine *machine)
{
cheat_private *cheatinfo = machine->cheat_data;
- int linenum;
/* free the list of cheats */
if (cheatinfo->cheatlist != NULL)
cheat_list_free(machine, cheatinfo->cheatlist);
-
- /* free any text strings */
- for (linenum = 0; linenum < ARRAY_LENGTH(cheatinfo->output); linenum++)
- if (cheatinfo->output[linenum] != NULL)
- astring_free(cheatinfo->output[linenum]);
}
@@ -524,7 +519,7 @@ void cheat_render_text(running_machine *machine)
if (cheatinfo->output[linenum] != NULL)
{
/* output the text */
- ui_draw_text_full(astring_c(cheatinfo->output[linenum]),
+ ui_draw_text_full(cheatinfo->output[linenum],
0.0f, (float)linenum * ui_get_line_height(), 1.0f,
cheatinfo->justify[linenum], WRAP_NEVER, DRAW_OPAQUE,
ARGB_WHITE, ARGB_BLACK, NULL, NULL);
@@ -552,7 +547,7 @@ void *cheat_get_next_menu_entry(running_machine *machine, void *previous, const
/* description is standard */
if (description != NULL)
- *description = astring_c(cheat->description);
+ *description = cheat->description;
/* some cheat entries are just text for display */
if (is_text_only_cheat(cheat))
@@ -632,7 +627,7 @@ void *cheat_get_next_menu_entry(running_machine *machine, void *previous, const
if (item->value == cheat->parameter->value)
break;
if (state != NULL)
- *state = (item != NULL) ? astring_c(item->text) : "??Invalid??";
+ *state = (item != NULL) ? item->text.cstr() : "??Invalid??";
if (flags != NULL)
{
*flags = MENU_FLAG_LEFT_ARROW;
@@ -667,7 +662,7 @@ int cheat_activate(running_machine *machine, void *entry)
{
cheat_execute_script(cheatinfo, cheat, SCRIPT_STATE_ON);
changed = TRUE;
- popmessage("Activated %s", astring_c(cheat->description));
+ popmessage("Activated %s", cheat->description.cstr());
}
/* if we have no run or off script, but we do have parameter and change scripts and it's not in the off state, it's a oneshot list or selectable value cheat */
@@ -676,9 +671,9 @@ int cheat_activate(running_machine *machine, void *entry)
cheat_execute_script(cheatinfo, cheat, SCRIPT_STATE_CHANGE);
changed = TRUE;
if (cheat->parameter->itemlist != NULL)
- popmessage("Activated\n %s = %s", astring_c(cheat->description), astring_c(cheat->parameter->itemlist->curtext) );
+ popmessage("Activated\n %s = %s", cheat->description.cstr(), cheat->parameter->itemlist->curtext.cstr() );
else
- popmessage("Activated\n %s = %d (0x%X)", astring_c(cheat->description), (UINT32)cheat->parameter->value, (UINT32)cheat->parameter->value );
+ popmessage("Activated\n %s = %d (0x%X)", cheat->description.cstr(), (UINT32)cheat->parameter->value, (UINT32)cheat->parameter->value );
}
return changed;
@@ -880,7 +875,7 @@ int cheat_select_next_state(running_machine *machine, void *entry)
to help render displayable comments
-------------------------------------------------*/
-astring *cheat_get_comment(void *entry)
+astring &cheat_get_comment(void *entry)
{
cheat_entry *cheat = (cheat_entry *)entry;
return cheat->comment;
@@ -907,11 +902,7 @@ static void cheat_frame(running_machine *machine)
cheatinfo->numlines = floor(1.0f / ui_get_line_height());
cheatinfo->numlines = MIN(cheatinfo->numlines, ARRAY_LENGTH(cheatinfo->output));
for (linenum = 0; linenum < ARRAY_LENGTH(cheatinfo->output); linenum++)
- if (cheatinfo->output[linenum] != NULL)
- {
- astring_free(cheatinfo->output[linenum]);
- cheatinfo->output[linenum] = NULL;
- }
+ cheatinfo->output[linenum].reset();
/* iterate over running cheats and execute them */
for (cheat = cheatinfo->cheatlist; cheat != NULL; cheat = cheat->next)
@@ -963,11 +954,10 @@ static void cheat_execute_script(cheat_private *cheatinfo, cheat_entry *cheat, s
}
/* if there is a string to display, compute it */
- if (entry->format != NULL)
+ if (entry->format.len() != 0)
{
UINT64 params[MAX_ARGUMENTS];
output_argument *arg;
- astring *string;
int curarg = 0;
int row;
@@ -990,13 +980,11 @@ static void cheat_execute_script(cheat_private *cheatinfo, cheat_entry *cheat, s
row = MIN(row, cheatinfo->numlines - 1);
/* either re-use or allocate a string */
- string = cheatinfo->output[row];
- if (string == NULL)
- string = cheatinfo->output[row] = astring_alloc();
+ astring &string = cheatinfo->output[row];
cheatinfo->justify[row] = entry->justify;
/* generate the astring */
- astring_printf(string, astring_c(entry->format),
+ string.printf(entry->format,
(UINT32)params[0], (UINT32)params[1], (UINT32)params[2], (UINT32)params[3],
(UINT32)params[4], (UINT32)params[5], (UINT32)params[6], (UINT32)params[7],
(UINT32)params[8], (UINT32)params[9], (UINT32)params[10], (UINT32)params[11],
@@ -1027,11 +1015,10 @@ static cheat_entry *cheat_list_load(running_machine *machine, const char *filena
cheat_entry **cheattailptr = &cheatlist;
mame_file *cheatfile = NULL;
file_error filerr;
- astring *fname;
/* open the file with the proper name */
- fname = astring_assemble_2(astring_alloc(), filename, ".xml");
- filerr = mame_fopen(SEARCHPATH_CHEAT, astring_c(fname), OPEN_FLAG_READ, &cheatfile);
+ astring fname(filename, ".xml");
+ filerr = mame_fopen(SEARCHPATH_CHEAT, fname, OPEN_FLAG_READ, &cheatfile);
/* loop over all instrances of the files found in our search paths */
while (filerr == FILERR_NONE)
@@ -1042,7 +1029,7 @@ static cheat_entry *cheat_list_load(running_machine *machine, const char *filena
cheat_entry *scannode;
int version;
- mame_printf_verbose("Loading cheats file from %s\n", mame_file_full_name(cheatfile));
+ mame_printf_verbose("Loading cheats file from %s\n", mame_file_full_name(cheatfile).cstr());
/* read the XML file into internal data structures */
memset(&options, 0, sizeof(options));
@@ -1084,9 +1071,9 @@ static cheat_entry *cheat_list_load(running_machine *machine, const char *filena
scannode = NULL;
if (REMOVE_DUPLICATE_CHEATS)
for (scannode = cheatlist; scannode != NULL; scannode = scannode->next)
- if (astring_cmp(scannode->description, curcheat->description) == 0)
+ if (scannode->description.cmp(curcheat->description) == 0)
{
- mame_printf_verbose("Ignoring duplicate cheat '%s' from file %s\n", astring_c(curcheat->description), mame_file_full_name(cheatfile));
+ mame_printf_verbose("Ignoring duplicate cheat '%s' from file %s\n", curcheat->description.cstr(), mame_file_full_name(cheatfile).cstr());
break;
}
@@ -1102,11 +1089,10 @@ static cheat_entry *cheat_list_load(running_machine *machine, const char *filena
xml_file_free(rootnode);
/* open the next file in sequence */
- filerr = mame_fclose_and_open_next(&cheatfile, astring_c(fname), OPEN_FLAG_READ);
+ filerr = mame_fclose_and_open_next(&cheatfile, fname, OPEN_FLAG_READ);
}
- /* release memory and return the cheat list */
- astring_free(fname);
+ /* return the cheat list */
return cheatlist;
error:
@@ -1114,7 +1100,6 @@ error:
xml_file_free(rootnode);
if (cheatfile != NULL)
mame_fclose(cheatfile);
- astring_free(fname);
return NULL;
}
@@ -1128,12 +1113,10 @@ static int cheat_list_save(const char *filename, const cheat_entry *cheatlist)
{
mame_file *cheatfile;
file_error filerr;
- astring *fname;
/* open the file with the proper name */
- fname = astring_assemble_2(astring_alloc(), filename, ".xml");
- filerr = mame_fopen(SEARCHPATH_CHEAT, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &cheatfile);
- astring_free(fname);
+ astring fname(filename, ".xml");
+ filerr = mame_fopen(SEARCHPATH_CHEAT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &cheatfile);
/* if that failed, return nothing */
if (filerr != FILERR_NONE)
@@ -1203,7 +1186,7 @@ static cheat_entry *cheat_entry_load(running_machine *machine, const char *filen
mame_printf_error("%s.xml(%d): empty or missing desc attribute on cheat\n", filename, cheatnode->line);
return NULL;
}
- cheat->description = astring_dupc(description);
+ cheat->description.cpy(description);
/* create the symbol table */
cheat->symbols = symtable_alloc(NULL, machine);
@@ -1223,7 +1206,7 @@ static cheat_entry *cheat_entry_load(running_machine *machine, const char *filen
if (commentnode != NULL)
{
if (commentnode->value != NULL && commentnode->value[0] != 0)
- cheat->comment = astring_dupc(commentnode->value);
+ cheat->comment.cpy(commentnode->value);
/* only one comment is kept */
commentnode = xml_get_sibling(commentnode->next, "comment");
@@ -1294,18 +1277,18 @@ static void cheat_entry_save(mame_file *cheatfile, const cheat_entry *cheat)
scriptcount++;
/* output the cheat tag */
- mame_fprintf(cheatfile, "\t<cheat desc=\"%s\"", astring_c(cheat->description));
+ mame_fprintf(cheatfile, "\t<cheat desc=\"%s\"", cheat->description.cstr());
if (cheat->numtemp != DEFAULT_TEMP_VARIABLES)
mame_fprintf(cheatfile, " tempvariables=\"%d\"", cheat->numtemp);
- if (cheat->comment == NULL && cheat->parameter == NULL && scriptcount == 0)
+ if (cheat->comment.len() == 0 && cheat->parameter == NULL && scriptcount == 0)
mame_fprintf(cheatfile, " />\n");
else
{
mame_fprintf(cheatfile, ">\n");
/* save the comment */
- if (cheat->comment != NULL)
- mame_fprintf(cheatfile, "\t\t<comment><![CDATA[\n%s\n\t\t]]></comment>\n", astring_c(cheat->comment));
+ if (cheat->comment.len() != 0)
+ mame_fprintf(cheatfile, "\t\t<comment><![CDATA[\n%s\n\t\t]]></comment>\n", cheat->comment.cstr());
/* output the parameter, if present */
if (cheat->parameter != NULL)
@@ -1330,12 +1313,6 @@ static void cheat_entry_free(running_machine *machine, cheat_entry *cheat)
{
script_state state;
- if (cheat->description != NULL)
- astring_free(cheat->description);
-
- if (cheat->comment != NULL)
- astring_free(cheat->comment);
-
if (cheat->parameter != NULL)
cheat_parameter_free(machine, cheat->parameter);
@@ -1388,7 +1365,7 @@ static cheat_parameter *cheat_parameter_load(running_machine *machine, const cha
mame_printf_error("%s.xml(%d): item is missing text\n", filename, itemnode->line);
goto error;
}
- curitem->text = astring_dupc(itemnode->value);
+ curitem->text.cpy(itemnode->value);
/* read the attributes */
if (xml_get_attribute(itemnode, "value") == NULL)
@@ -1425,12 +1402,11 @@ error:
static void cheat_parameter_save(mame_file *cheatfile, const cheat_parameter *param)
{
- astring *string = astring_alloc();
-
/* output the parameter tag */
mame_fprintf(cheatfile, "\t\t<parameter");
/* if no items, just output min/max/step */
+ astring string;
if (param->itemlist == NULL)
{
if (param->minval != 0)
@@ -1448,10 +1424,9 @@ static void cheat_parameter_save(mame_file *cheatfile, const cheat_parameter *pa
const parameter_item *curitem;
for (curitem = param->itemlist; curitem != NULL; curitem = curitem->next)
- mame_fprintf(cheatfile, "\t\t\t<item value=\"%s\">%s</item>\n", format_int(string, curitem->value, curitem->valformat), astring_c(curitem->text));
+ mame_fprintf(cheatfile, "\t\t\t<item value=\"%s\">%s</item>\n", format_int(string, curitem->value, curitem->valformat), curitem->text.cstr());
mame_fprintf(cheatfile, "\t\t</parameter>\n");
}
- astring_free(string);
}
@@ -1467,8 +1442,6 @@ static void cheat_parameter_free(running_machine *machine, cheat_parameter *para
parameter_item *item = param->itemlist;
param->itemlist = item->next;
- if (item->text != NULL)
- astring_free(item->text);
auto_free(machine, item);
}
@@ -1650,7 +1623,7 @@ static script_entry *script_entry_load(running_machine *machine, const char *fil
mame_printf_error("%s.xml(%d): missing format in output tag\n", filename, entrynode->line);
goto error;
}
- entry->format = astring_dupc(format);
+ entry->format.cpy(format);
/* extract other attributes */
entry->line = xml_get_attribute_int(entrynode, "line", 0);
@@ -1724,7 +1697,7 @@ error:
static void script_entry_save(mame_file *cheatfile, const script_entry *entry)
{
- astring *tempstring = astring_alloc();
+ astring tempstring;
/* output an action */
if (entry->format == NULL)
@@ -1732,21 +1705,21 @@ static void script_entry_save(mame_file *cheatfile, const script_entry *entry)
mame_fprintf(cheatfile, "\t\t\t<action");
if (entry->condition != NULL)
{
- quote_astring_expression(astring_cpyc(tempstring, expression_original_string(entry->condition)), TRUE);
- mame_fprintf(cheatfile, " condition=\"%s\"", astring_c(tempstring));
+ quote_astring_expression(tempstring.cpy(expression_original_string(entry->condition)), TRUE);
+ mame_fprintf(cheatfile, " condition=\"%s\"", tempstring.cstr());
}
- quote_astring_expression(astring_cpyc(tempstring, expression_original_string(entry->expression)), FALSE);
- mame_fprintf(cheatfile, ">%s</action>\n", astring_c(tempstring));
+ quote_astring_expression(tempstring.cpy(expression_original_string(entry->expression)), FALSE);
+ mame_fprintf(cheatfile, ">%s</action>\n", tempstring.cstr());
}
/* output an output */
else
{
- mame_fprintf(cheatfile, "\t\t\t<output format=\"%s\"", astring_c(entry->format));
+ mame_fprintf(cheatfile, "\t\t\t<output format=\"%s\"", entry->format.cstr());
if (entry->condition != NULL)
{
- quote_astring_expression(astring_cpyc(tempstring, expression_original_string(entry->condition)), TRUE);
- mame_fprintf(cheatfile, " condition=\"%s\"", astring_c(tempstring));
+ quote_astring_expression(tempstring.cpy(expression_original_string(entry->condition)), TRUE);
+ mame_fprintf(cheatfile, " condition=\"%s\"", tempstring.cstr());
}
if (entry->line != 0)
mame_fprintf(cheatfile, " line=\"%d\"", entry->line);
@@ -1768,14 +1741,12 @@ static void script_entry_save(mame_file *cheatfile, const script_entry *entry)
mame_fprintf(cheatfile, "\t\t\t\t<argument");
if (curarg->count != 1)
mame_fprintf(cheatfile, " count=\"%d\"", (int)curarg->count);
- quote_astring_expression(astring_cpyc(tempstring, expression_original_string(curarg->expression)), FALSE);
- mame_fprintf(cheatfile, ">%s</argument>\n", astring_c(tempstring));
+ quote_astring_expression(tempstring.cpy(expression_original_string(curarg->expression)), FALSE);
+ mame_fprintf(cheatfile, ">%s</argument>\n", tempstring.cstr());
}
mame_fprintf(cheatfile, "\t\t\t</output>\n");
}
}
-
- astring_free(tempstring);
}
@@ -1790,8 +1761,6 @@ static void script_entry_free(running_machine *machine, script_entry *entry)
expression_free(entry->condition);
if (entry->expression != NULL)
expression_free(entry->expression);
- if (entry->format != NULL)
- astring_free(entry->format);
while (entry->arglist != NULL)
{
@@ -1818,32 +1787,32 @@ static void script_entry_free(running_machine *machine, script_entry *entry)
document
-------------------------------------------------*/
-static astring *quote_astring_expression(astring *string, int isattribute)
+static astring &quote_astring_expression(astring &string, int isattribute)
{
- astring_replacec(string, 0, " && ", " and ");
- astring_replacec(string, 0, " &&", " and ");
- astring_replacec(string, 0, "&& ", " and ");
- astring_replacec(string, 0, "&&", " and ");
-
- astring_replacec(string, 0, " & ", " band ");
- astring_replacec(string, 0, " &", " band ");
- astring_replacec(string, 0, "& ", " band ");
- astring_replacec(string, 0, "&", " band ");
-
- astring_replacec(string, 0, " <= ", " le ");
- astring_replacec(string, 0, " <=", " le ");
- astring_replacec(string, 0, "<= ", " le ");
- astring_replacec(string, 0, "<=", " le ");
-
- astring_replacec(string, 0, " < ", " lt ");
- astring_replacec(string, 0, " <", " lt ");
- astring_replacec(string, 0, "< ", " lt ");
- astring_replacec(string, 0, "<", " lt ");
-
- astring_replacec(string, 0, " << ", " lshift ");
- astring_replacec(string, 0, " <<", " lshift ");
- astring_replacec(string, 0, "<< ", " lshift ");
- astring_replacec(string, 0, "<<", " lshift ");
+ string.replace(0, " && ", " and ");
+ string.replace(0, " &&", " and ");
+ string.replace(0, "&& ", " and ");
+ string.replace(0, "&&", " and ");
+
+ string.replace(0, " & ", " band ");
+ string.replace(0, " &", " band ");
+ string.replace(0, "& ", " band ");
+ string.replace(0, "&", " band ");
+
+ string.replace(0, " <= ", " le ");
+ string.replace(0, " <=", " le ");
+ string.replace(0, "<= ", " le ");
+ string.replace(0, "<=", " le ");
+
+ string.replace(0, " < ", " lt ");
+ string.replace(0, " <", " lt ");
+ string.replace(0, "< ", " lt ");
+ string.replace(0, "<", " lt ");
+
+ string.replace(0, " << ", " lshift ");
+ string.replace(0, " <<", " lshift ");
+ string.replace(0, "<< ", " lshift ");
+ string.replace(0, "<<", " lshift ");
return string;
}
@@ -1856,7 +1825,7 @@ static astring *quote_astring_expression(astring *string, int isattribute)
static int validate_format(const char *filename, int line, const script_entry *entry)
{
- const char *p = astring_c(entry->format);
+ const char *p = entry->format;
const output_argument *curarg;
int argsprovided;
int argscounted;
@@ -1879,7 +1848,7 @@ static int validate_format(const char *filename, int line, const script_entry *e
/* look for a valid type */
if (strchr("cdiouxX", *p) == NULL)
{
- mame_printf_error("%s.xml(%d): invalid format specification \"%s\"\n", filename, line, astring_c(entry->format));
+ mame_printf_error("%s.xml(%d): invalid format specification \"%s\"\n", filename, line, entry->format.cstr());
return FALSE;
}
argscounted++;
@@ -1891,12 +1860,12 @@ static int validate_format(const char *filename, int line, const script_entry *e
/* did we match? */
if (argscounted < argsprovided)
{
- mame_printf_error("%s.xml(%d): too many arguments provided (%d) for format \"%s\"\n", filename, line, argsprovided, astring_c(entry->format));
+ mame_printf_error("%s.xml(%d): too many arguments provided (%d) for format \"%s\"\n", filename, line, argsprovided, entry->format.cstr());
return FALSE;
}
if (argscounted > argsprovided)
{
- mame_printf_error("%s.xml(%d): not enough arguments provided (%d) for format \"%s\"\n", filename, line, argsprovided, astring_c(entry->format));
+ mame_printf_error("%s.xml(%d): not enough arguments provided (%d) for format \"%s\"\n", filename, line, argsprovided, entry->format.cstr());
return FALSE;
}
return TRUE;
diff --git a/src/emu/cheat.h b/src/emu/cheat.h
index e7ff2fd9081..5f9af834d85 100644
--- a/src/emu/cheat.h
+++ b/src/emu/cheat.h
@@ -60,7 +60,7 @@ int cheat_select_previous_state(running_machine *machine, void *entry);
int cheat_select_next_state(running_machine *machine, void *entry);
/* return the displayable comment of the current cheat */
-astring *cheat_get_comment(void *entry);
+astring &cheat_get_comment(void *entry);
#endif /* __CHEAT_H__ */
diff --git a/src/emu/clifront.c b/src/emu/clifront.c
index 91f05f3ecda..4c772a348aa 100644
--- a/src/emu/clifront.c
+++ b/src/emu/clifront.c
@@ -114,11 +114,11 @@ static const options_entry cli_options[] =
int cli_execute(int argc, char **argv, const options_entry *osd_options)
{
core_options *options = NULL;
- astring *gamename = astring_alloc();
- astring *exename = astring_alloc();
const char *gamename_option;
const game_driver *driver;
int result = MAMERR_FATALERROR;
+ astring gamename;
+ astring exename;
try
{
@@ -134,18 +134,18 @@ int cli_execute(int argc, char **argv, const options_entry *osd_options)
}
/* parse the simple commmands before we go any further */
- core_filename_extract_base(exename, argv[0], TRUE);
- result = execute_simple_commands(options, astring_c(exename));
+ core_filename_extract_base(&exename, argv[0], TRUE);
+ result = execute_simple_commands(options, exename);
if (result != -1)
goto error;
/* find out what game we might be referring to */
gamename_option = options_get_string(options, OPTION_GAMENAME);
- core_filename_extract_base(gamename, gamename_option, TRUE);
- driver = driver_get_name(astring_c(gamename));
+ core_filename_extract_base(&gamename, gamename_option, TRUE);
+ driver = driver_get_name(gamename);
/* execute any commands specified */
- result = execute_commands(options, astring_c(exename), driver);
+ result = execute_commands(options, exename, driver);
if (result != -1)
goto error;
@@ -196,8 +196,6 @@ error:
/* free our options and exit */
if (options != NULL)
options_free(options);
- astring_free(gamename);
- astring_free(exename);
/* report any unfreed memory */
dump_unfreed_mem();
@@ -398,20 +396,19 @@ int cli_info_listfull(core_options *options, const char *gamename)
int cli_info_listsource(core_options *options, const char *gamename)
{
- astring *filename = astring_alloc();
int drvindex, count = 0;
+ astring filename;
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
/* output the remaining information */
- mame_printf_info("%-16s %s\n", drivers[drvindex]->name, astring_c(core_filename_extract_base(filename, drivers[drvindex]->source_file, FALSE)));
+ mame_printf_info("%-16s %s\n", drivers[drvindex]->name, core_filename_extract_base(&filename, drivers[drvindex]->source_file, FALSE)->cstr());
count++;
}
/* return an error if none found */
- astring_free(filename);
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
}
@@ -456,11 +453,9 @@ int cli_info_listclones(core_options *options, const char *gamename)
int cli_info_listbrothers(core_options *options, const char *gamename)
{
- UINT8 *didit = global_alloc_array(UINT8, driver_list_get_count(drivers));
- astring *filename = astring_alloc();
+ UINT8 *didit = global_alloc_array_clear(UINT8, driver_list_get_count(drivers));
int drvindex, count = 0;
-
- memset(didit, 0, driver_list_get_count(drivers));
+ astring filename;
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
@@ -471,7 +466,7 @@ int cli_info_listbrothers(core_options *options, const char *gamename)
didit[drvindex] = TRUE;
if (count > 0)
mame_printf_info("\n");
- mame_printf_info("%s ... other drivers in %s:\n", drivers[drvindex]->name, astring_c(core_filename_extract_base(filename, drivers[drvindex]->source_file, FALSE)));
+ mame_printf_info("%s ... other drivers in %s:\n", drivers[drvindex]->name, core_filename_extract_base(&filename, drivers[drvindex]->source_file, FALSE)->cstr());
/* now iterate again over drivers, finding those with the same source file */
for (matchindex = 0; drivers[matchindex]; matchindex++)
@@ -491,7 +486,6 @@ int cli_info_listbrothers(core_options *options, const char *gamename)
}
/* return an error if none found */
- astring_free(filename);
global_free(didit);
return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
}
@@ -920,9 +914,8 @@ static void romident(const char *filename, romident_status *status)
while ((entry = osd_readdir(directory)) != NULL)
if (entry->type == ENTTYPE_FILE)
{
- astring *curfile = astring_assemble_3(astring_alloc(), filename, PATH_SEPARATOR, entry->name);
- identify_file(astring_c(curfile), status);
- astring_free(curfile);
+ astring curfile(filename, PATH_SEPARATOR, entry->name);
+ identify_file(curfile, status);
}
osd_closedir(directory);
}
@@ -1005,7 +998,7 @@ static void identify_data(const char *name, const UINT8 *data, int length, romid
{
char hash[HASH_BUF_SIZE];
UINT8 *tempjed = NULL;
- astring *basename;
+ astring basename;
int found = 0;
jed_data jed;
@@ -1029,9 +1022,8 @@ static void identify_data(const char *name, const UINT8 *data, int length, romid
/* output the name */
status->total++;
- basename = core_filename_extract_base(astring_alloc(), name, FALSE);
- mame_printf_info("%-20s", astring_c(basename));
- astring_free(basename);
+ core_filename_extract_base(&basename, name, FALSE);
+ mame_printf_info("%-20s", basename.cstr());
/* see if we can find a match in the ROMs */
match_roms(hash, length, &found);
diff --git a/src/emu/config.c b/src/emu/config.c
index a2290fb1216..72061ce6905 100644
--- a/src/emu/config.c
+++ b/src/emu/config.c
@@ -118,7 +118,6 @@ int config_load_settings(running_machine *machine)
config_type *type;
mame_file *file;
int loaded = 0;
- astring *fname;
/* loop over all registrants and call their init function */
for (type = typelist; type; type = type->next)
@@ -128,9 +127,8 @@ int config_load_settings(running_machine *machine)
if (controller[0] != 0)
{
/* open the config file */
- fname = astring_assemble_2(astring_alloc(), controller, ".cfg");
- filerr = mame_fopen(SEARCHPATH_CTRLR, astring_c(fname), OPEN_FLAG_READ, &file);
- astring_free(fname);
+ astring fname(controller, ".cfg");
+ filerr = mame_fopen(SEARCHPATH_CTRLR, fname, OPEN_FLAG_READ, &file);
if (filerr != FILERR_NONE)
throw emu_fatalerror("Could not load controller file %s.cfg", controller);
@@ -150,9 +148,8 @@ int config_load_settings(running_machine *machine)
}
/* finally, load the game-specific file */
- fname = astring_assemble_2(astring_alloc(), machine->basename, ".cfg");
- filerr = mame_fopen(SEARCHPATH_CONFIG, astring_c(fname), OPEN_FLAG_READ, &file);
- astring_free(fname);
+ astring fname(machine->basename, ".cfg");
+ filerr = mame_fopen(SEARCHPATH_CONFIG, fname, OPEN_FLAG_READ, &file);
if (filerr == FILERR_NONE)
{
@@ -175,7 +172,6 @@ void config_save_settings(running_machine *machine)
file_error filerr;
config_type *type;
mame_file *file;
- astring *fname;
/* loop over all registrants and call their init function */
for (type = typelist; type; type = type->next)
@@ -190,9 +186,8 @@ void config_save_settings(running_machine *machine)
}
/* finally, save the game-specific file */
- fname = astring_assemble_2(astring_alloc(), machine->basename, ".cfg");
- filerr = mame_fopen(SEARCHPATH_CONFIG, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
- astring_free(fname);
+ astring fname(machine->basename, ".cfg");
+ filerr = mame_fopen(SEARCHPATH_CONFIG, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
if (filerr == FILERR_NONE)
{
diff --git a/src/emu/cpu/x86log.c b/src/emu/cpu/x86log.c
index 5af2b8dad0e..e4727b132d2 100644
--- a/src/emu/cpu/x86log.c
+++ b/src/emu/cpu/x86log.c
@@ -54,7 +54,7 @@ struct _data_range_t
/* the code logging context */
struct _x86log_context
{
- astring * filename; /* name of the file */
+ astring filename; /* name of the file */
FILE * file; /* file we are logging to */
data_range_t data_range[MAX_DATA_RANGES]; /* list of data ranges */
@@ -94,7 +94,7 @@ x86log_context *x86log_create_context(const char *filename)
log = global_alloc_clear(x86log_context);
/* allocate the filename */
- log->filename = astring_dupc(filename);
+ log->filename.cpy(filename);
/* reset things */
reset_log(log);
@@ -113,7 +113,6 @@ void x86log_free_context(x86log_context *log)
fclose(log->file);
/* free the structure */
- astring_free(log->filename);
global_free(log);
}
@@ -276,7 +275,7 @@ void x86log_printf(x86log_context *log, const char *format, ...)
/* open the file, creating it if necessary */
if (log->file == NULL)
- log->file = fopen(astring_c(log->filename), "w");
+ log->file = fopen(log->filename, "w");
if (log->file == NULL)
return;
diff --git a/src/emu/cpu/z80/z80daisy.c b/src/emu/cpu/z80/z80daisy.c
index bcfd2640d54..35da85ccb8b 100644
--- a/src/emu/cpu/z80/z80daisy.c
+++ b/src/emu/cpu/z80/z80daisy.c
@@ -22,7 +22,7 @@ struct _z80_daisy_state
z80_daisy_state *z80daisy_init(const device_config *cpudevice, const z80_daisy_chain *daisy)
{
- astring *tempstring = astring_alloc();
+ astring tempstring;
z80_daisy_state *head = NULL;
z80_daisy_state **tailptr = &head;
@@ -40,7 +40,6 @@ z80_daisy_state *z80daisy_init(const device_config *cpudevice, const z80_daisy_c
tailptr = &(*tailptr)->next;
}
- astring_free(tempstring);
return head;
}
diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c
index 56dd599d1f0..6db207d7fb7 100644
--- a/src/emu/debug/debugcmd.c
+++ b/src/emu/debug/debugcmd.c
@@ -2502,7 +2502,6 @@ static void execute_snap(running_machine *machine, int ref, int params, const ch
mame_file *fp;
const char *filename = param[0];
int scrnum = (params > 1) ? atoi(param[1]) : 0;
- astring *fname;
const device_config *screen = device_list_find_by_index(&machine->config->devicelist, VIDEO_SCREEN, scrnum);
@@ -2512,11 +2511,10 @@ static void execute_snap(running_machine *machine, int ref, int params, const ch
return;
}
- fname = astring_dupc(filename);
- if (astring_findc(fname, 0, ".png") == -1)
- astring_catc(fname, ".png");
- filerr = mame_fopen(SEARCHPATH_SCREENSHOT, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &fp);
- astring_free(fname);
+ astring fname(filename);
+ if (fname.find(0, ".png") == -1)
+ fname.cat(".png");
+ filerr = mame_fopen(SEARCHPATH_SCREENSHOT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &fp);
if (filerr != FILERR_NONE)
{
diff --git a/src/emu/debug/debugcmt.c b/src/emu/debug/debugcmt.c
index 7f24d481e5f..b5bffd50462 100644
--- a/src/emu/debug/debugcmt.c
+++ b/src/emu/debug/debugcmt.c
@@ -411,12 +411,10 @@ int debug_comment_save(running_machine *machine)
if (total_comments > 0)
{
file_error filerr;
- astring *fname;
mame_file *fp;
- fname = astring_assemble_2(astring_alloc(), machine->basename, ".cmt");
- filerr = mame_fopen(SEARCHPATH_COMMENT, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &fp);
- astring_free(fname);
+ astring fname(machine->basename, ".cmt");
+ filerr = mame_fopen(SEARCHPATH_COMMENT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &fp);
if (filerr == FILERR_NONE)
{
@@ -443,11 +441,9 @@ int debug_comment_load(running_machine *machine)
{
file_error filerr;
mame_file *fp;
- astring *fname;
- fname = astring_assemble_2(astring_alloc(), machine->basename, ".cmt");
- filerr = mame_fopen(SEARCHPATH_COMMENT, astring_c(fname), OPEN_FLAG_READ, &fp);
- astring_free(fname);
+ astring fname(machine->basename, ".cmt");
+ filerr = mame_fopen(SEARCHPATH_COMMENT, fname, OPEN_FLAG_READ, &fp);
if (filerr != FILERR_NONE) return 0;
debug_comment_load_xml(machine, fp);
diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c
index 7602df76e40..7b15f78b8e0 100644
--- a/src/emu/debug/debugvw.c
+++ b/src/emu/debug/debugvw.c
@@ -79,7 +79,7 @@ struct _debug_view_expression
{
UINT64 result; /* last result from the expression */
parsed_expression * parsed; /* parsed expression data */
- astring * string; /* copy of the expression string */
+ astring string; /* copy of the expression string */
UINT8 dirty; /* true if the expression needs to be re-evaluated */
};
@@ -787,7 +787,6 @@ void debug_view_set_cursor_visible(debug_view *view, int visible)
static void debug_view_expression_alloc(debug_view_expression *expression)
{
- expression->string = astring_alloc();
}
@@ -800,8 +799,6 @@ static void debug_view_expression_free(debug_view_expression *expression)
{
if (expression->parsed != NULL)
expression_free(expression->parsed);
- if (expression->string != NULL)
- astring_free(expression->string);
}
@@ -812,7 +809,7 @@ static void debug_view_expression_free(debug_view_expression *expression)
static void debug_view_expression_set(debug_view_expression *expression, const char *string)
{
- astring_cpyc(expression->string, string);
+ expression->string.cpy(string);
expression->dirty = TRUE;
}
@@ -835,7 +832,7 @@ static int debug_view_expression_changed_value(debug_view *view, debug_view_expr
parsed_expression *expr;
/* parse the new expression */
- exprerr = expression_parse(astring_c(expression->string), symtable, &debug_expression_callbacks, view->machine, &expr);
+ exprerr = expression_parse(expression->string, symtable, &debug_expression_callbacks, view->machine, &expr);
/* if it worked, update the expression */
if (exprerr == EXPRERR_NONE)
@@ -1027,7 +1024,7 @@ static void textbuf_view_notify(debug_view *view, view_notification type)
static const registers_subview_item *registers_view_enumerate_subviews(running_machine *machine)
{
- astring *tempstring = astring_alloc();
+ astring tempstring;
registers_subview_item *head = NULL;
registers_subview_item **tailptr = &head;
const device_config *cpu;
@@ -1039,22 +1036,20 @@ static const registers_subview_item *registers_view_enumerate_subviews(running_m
registers_subview_item *subview;
/* determine the string and allocate a subview large enough */
- astring_printf(tempstring, "CPU '%s' (%s)", cpu->tag, cpu_get_name(cpu));
- subview = (registers_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + astring_len(tempstring));
+ tempstring.printf("CPU '%s' (%s)", cpu->tag, cpu_get_name(cpu));
+ subview = (registers_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + tempstring.len());
/* populate the subview */
subview->next = NULL;
subview->index = curindex++;
subview->device = cpu;
- strcpy(subview->name, astring_c(tempstring));
+ strcpy(subview->name, tempstring);
/* add to the list */
*tailptr = subview;
tailptr = &subview->next;
}
- /* free the temporary string */
- astring_free(tempstring);
return head;
}
@@ -1490,7 +1485,7 @@ void registers_view_set_subview(debug_view *view, int index)
static const disasm_subview_item *disasm_view_enumerate_subviews(running_machine *machine)
{
- astring *tempstring = astring_alloc();
+ astring tempstring;
disasm_subview_item *head = NULL;
disasm_subview_item **tailptr = &head;
const device_config *cpu;
@@ -1505,14 +1500,14 @@ static const disasm_subview_item *disasm_view_enumerate_subviews(running_machine
disasm_subview_item *subview;
/* determine the string and allocate a subview large enough */
- astring_printf(tempstring, "CPU '%s' (%s)", cpu->tag, cpu_get_name(cpu));
- subview = (disasm_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + astring_len(tempstring));
+ tempstring.printf("CPU '%s' (%s)", cpu->tag, cpu_get_name(cpu));
+ subview = (disasm_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + tempstring.len());
/* populate the subview */
subview->next = NULL;
subview->index = curindex++;
subview->space = space;
- strcpy(subview->name, astring_c(tempstring));
+ strcpy(subview->name, tempstring);
/* add to the list */
*tailptr = subview;
@@ -1520,8 +1515,6 @@ static const disasm_subview_item *disasm_view_enumerate_subviews(running_machine
}
}
- /* free the temporary string */
- astring_free(tempstring);
return head;
}
@@ -1935,7 +1928,7 @@ static void disasm_view_update(debug_view *view)
parsed_expression *expr;
/* parse the new expression */
- exprerr = expression_parse(astring_c(dasmdata->expression.string), debug_cpu_get_symtable(space->cpu), &debug_expression_callbacks, space->machine, &expr);
+ exprerr = expression_parse(dasmdata->expression.string, debug_cpu_get_symtable(space->cpu), &debug_expression_callbacks, space->machine, &expr);
/* if it worked, update the expression */
if (exprerr == EXPRERR_NONE)
@@ -2152,7 +2145,7 @@ const char *disasm_view_get_expression(debug_view *view)
assert(view->type == DVT_DISASSEMBLY);
debug_view_begin_update(view);
debug_view_end_update(view);
- return astring_c(dasmdata->expression.string);
+ return dasmdata->expression.string;
}
@@ -2369,7 +2362,7 @@ void disasm_view_set_selected_address(debug_view *view, offs_t address)
static const memory_subview_item *memory_view_enumerate_subviews(running_machine *machine)
{
- astring *tempstring = astring_alloc();
+ astring tempstring;
memory_subview_item *head = NULL;
memory_subview_item **tailptr = &head;
const device_config *device;
@@ -2389,10 +2382,10 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
/* determine the string and allocate a subview large enough */
if (device->type == CPU)
- astring_printf(tempstring, "CPU '%s' (%s) %s memory", device->tag, device_get_name(device), space->name);
+ tempstring.printf("CPU '%s' (%s) %s memory", device->tag, device_get_name(device), space->name);
else
- astring_printf(tempstring, "%s '%s' space #%d memory", device_get_name(device), device->tag, spacenum);
- subview = (memory_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + astring_len(tempstring));
+ tempstring.printf("%s '%s' space #%d memory", device_get_name(device), device->tag, spacenum);
+ subview = (memory_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + tempstring.len());
/* populate the subview */
subview->next = NULL;
@@ -2400,7 +2393,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
subview->space = space;
subview->endianness = space->endianness;
subview->prefsize = space->dbits / 8;
- strcpy(subview->name, astring_c(tempstring));
+ strcpy(subview->name, tempstring);
/* add to the list */
*tailptr = subview;
@@ -2420,8 +2413,8 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
memory_subview_item *subview;
/* determine the string and allocate a subview large enough */
- astring_printf(tempstring, "Region '%s'", rgntag);
- subview = (memory_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + astring_len(tempstring));
+ tempstring.printf("Region '%s'", rgntag);
+ subview = (memory_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + tempstring.len());
/* populate the subview */
subview->next = NULL;
@@ -2431,7 +2424,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
subview->offsetxor = NATIVE_ENDIAN_VALUE_LE_BE(width - 1, 0);
subview->endianness = little_endian ? ENDIANNESS_LITTLE : ENDIANNESS_BIG;
subview->prefsize = MIN(width, 8);
- strcpy(subview->name, astring_c(tempstring));
+ strcpy(subview->name, tempstring);
/* add to the list */
*tailptr = subview;
@@ -2457,8 +2450,8 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
memory_subview_item *subview;
/* determine the string and allocate a subview large enough */
- astring_printf(tempstring, "%s", strrchr(name, '/') + 1);
- subview = (memory_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + astring_len(tempstring));
+ tempstring.printf("%s", strrchr(name, '/') + 1);
+ subview = (memory_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + tempstring.len());
/* populate the subview */
subview->next = NULL;
@@ -2468,7 +2461,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
subview->offsetxor = 0;
subview->endianness = ENDIANNESS_NATIVE;
subview->prefsize = MIN(valsize, 8);
- strcpy(subview->name, astring_c(tempstring));
+ strcpy(subview->name, tempstring);
/* add to the list */
*tailptr = subview;
@@ -2476,8 +2469,6 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
}
}
- /* free the temporary string */
- astring_free(tempstring);
return head;
}
@@ -3118,7 +3109,7 @@ const char *memory_view_get_expression(debug_view *view)
assert(view->type == DVT_MEMORY);
debug_view_begin_update(view);
debug_view_end_update(view);
- return astring_c(memdata->expression.string);
+ return memdata->expression.string;
}
diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c
index a8a6b95a3d9..96f50319a23 100644
--- a/src/emu/devintrf.c
+++ b/src/emu/devintrf.c
@@ -181,7 +181,7 @@ device_config *device_list_add(device_list *devlist, const device_config *owner,
device->clock = device->owner->clock * ((device->clock >> 12) & 0xfff) / ((device->clock >> 0) & 0xfff);
}
device->static_config = NULL;
- device->inline_config = (configlen == 0) ? NULL : global_alloc_array(UINT8, configlen);
+ device->inline_config = (configlen == 0) ? NULL : global_alloc_array_clear(UINT8, configlen);
/* ensure live fields are all cleared */
device->machine = NULL;
@@ -196,10 +196,6 @@ device_config *device_list_add(device_list *devlist, const device_config *owner,
/* append the tag */
strcpy(device->tag, tag);
- /* reset the inline_config to 0 */
- if (configlen > 0)
- memset(device->inline_config, 0, configlen);
-
/* fetch function pointers to the core functions */
/* before adding us to the global list, add us to the end of the type list */
@@ -270,17 +266,13 @@ void device_list_remove(device_list *devlist, const char *tag)
the device's name and the given tag
-------------------------------------------------*/
-const char *device_build_tag(astring *dest, const device_config *device, const char *tag)
+astring &device_build_tag(astring &dest, const device_config *device, const char *tag)
{
if (device != NULL)
- {
- astring_cpyc(dest, device->tag);
- astring_catc(dest, ":");
- astring_catc(dest, tag);
- }
+ dest.cpy(device->tag).cat(":").cat(tag);
else
- astring_cpyc(dest, tag);
- return astring_c(dest);
+ dest.cpy(tag);
+ return dest;
}
@@ -289,17 +281,14 @@ const char *device_build_tag(astring *dest, const device_config *device, const c
device prefix as the source tag
-------------------------------------------------*/
-const char *device_inherit_tag(astring *dest, const char *sourcetag, const char *tag)
+astring &device_inherit_tag(astring &dest, const char *sourcetag, const char *tag)
{
const char *divider = strrchr(sourcetag, ':');
if (divider != NULL)
- {
- astring_cpych(dest, sourcetag, divider + 1 - sourcetag);
- astring_catc(dest, tag);
- }
+ dest.cpy(sourcetag, divider + 1 - sourcetag).cat(tag);
else
- astring_cpyc(dest, tag);
- return astring_c(dest);
+ dest.cpy(tag);
+ return dest;
}
@@ -421,15 +410,13 @@ const device_config *device_list_find_by_tag_slow(const device_list *devlist, co
const device_config *device_find_child_by_tag(const device_config *owner, const char *tag)
{
- astring *tempstring;
const device_config *child;
assert(owner != NULL);
assert(tag != NULL);
- tempstring = astring_alloc();
+ astring tempstring;
child = device_list_find_by_tag(&owner->machine->config->devicelist, device_build_tag(tempstring, owner, tag));
- astring_free(tempstring);
return child;
}
diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h
index d238dd90dca..b283fcb5d63 100644
--- a/src/emu/devintrf.h
+++ b/src/emu/devintrf.h
@@ -359,10 +359,10 @@ device_config *device_list_add(device_list *devlist, const device_config *owner,
void device_list_remove(device_list *devlist, const char *tag);
/* build a tag that combines the device's name and the given tag */
-const char *device_build_tag(astring *dest, const device_config *device, const char *tag);
+astring &device_build_tag(astring &dest, const device_config *device, const char *tag);
/* build a tag with the same device prefix as the source tag*/
-const char *device_inherit_tag(astring *dest, const char *sourcetag, const char *tag);
+astring &device_inherit_tag(astring &dest, const char *sourcetag, const char *tag);
/* find a given contract on a device */
const device_contract *device_get_contract(const device_config *device, const char *name);
diff --git a/src/emu/fileio.c b/src/emu/fileio.c
index 7cf8cc19d1f..65f675dbfd9 100644
--- a/src/emu/fileio.c
+++ b/src/emu/fileio.c
@@ -54,7 +54,7 @@ struct _mame_file
#ifdef DEBUG_COOKIE
UINT32 debug_cookie; /* sanity checking for debugging */
#endif
- astring * filename; /* full filename */
+ astring filename; /* full filename */
core_file * file; /* core file pointer */
path_iterator iterator; /* iterator for paths */
UINT32 openflags; /* flags we used for the open */
@@ -70,7 +70,7 @@ struct _mame_path
{
path_iterator iterator;
osd_directory * curdir;
- astring * pathbuffer;
+ astring pathbuffer;
int buflen;
};
@@ -85,15 +85,15 @@ static void fileio_exit(running_machine *machine);
/* file open/close */
static file_error fopen_internal(core_options *opts, path_iterator *iterator, const char *filename, UINT32 crc, UINT32 flags, mame_file **file);
-static file_error fopen_attempt_zipped(astring *fullname, UINT32 crc, UINT32 openflags, mame_file *file);
+static file_error fopen_attempt_zipped(astring &fullname, UINT32 crc, UINT32 openflags, mame_file *file);
/* path iteration */
static void path_iterator_init(path_iterator *iterator, core_options *opts, const char *searchpath);
-static int path_iterator_get_next(path_iterator *iterator, astring *buffer);
+static int path_iterator_get_next(path_iterator *iterator, astring &buffer);
/* misc helpers */
static file_error load_zipped_file(mame_file *file);
-static int zip_filename_match(const zip_file_header *header, const astring *afilename);
+static int zip_filename_match(const zip_file_header *header, const astring &afilename);
static int zip_header_is_path(const zip_file_header *header);
@@ -191,10 +191,9 @@ file_error mame_fopen_ram(const void *data, UINT32 length, UINT32 openflags, mam
file_error filerr;
/* allocate the file itself */
- *file = global_alloc(mame_file);
+ *file = global_alloc_clear(mame_file);
/* reset the file handle */
- memset(*file, 0, sizeof(**file));
(*file)->openflags = openflags;
#ifdef DEBUG_COOKIE
(*file)->debug_cookie = DEBUG_COOKIE;
@@ -229,26 +228,24 @@ static file_error fopen_internal(core_options *opts, path_iterator *iterator, co
return FILERR_INVALID_ACCESS;
/* allocate the file itself */
- *file = global_alloc(mame_file);
+ *file = global_alloc_clear(mame_file);
/* reset the file handle */
- memset(*file, 0, sizeof(**file));
(*file)->openflags = openflags;
#ifdef DEBUG_COOKIE
(*file)->debug_cookie = DEBUG_COOKIE;
#endif
/* loop over paths */
- (*file)->filename = astring_alloc();
while (path_iterator_get_next(iterator, (*file)->filename))
{
/* compute the full pathname */
- if (astring_len((*file)->filename) > 0)
- astring_catc((*file)->filename, PATH_SEPARATOR);
- astring_catc((*file)->filename, filename);
+ if ((*file)->filename.len() > 0)
+ (*file)->filename.cat(PATH_SEPARATOR);
+ (*file)->filename.cat(filename);
/* attempt to open the file directly */
- filerr = core_fopen(astring_c((*file)->filename), openflags, &(*file)->file);
+ filerr = core_fopen((*file)->filename, openflags, &(*file)->file);
if (filerr == FILERR_NONE)
break;
@@ -280,9 +277,9 @@ static file_error fopen_internal(core_options *opts, path_iterator *iterator, co
ZIPped file
-------------------------------------------------*/
-static file_error fopen_attempt_zipped(astring *fullname, UINT32 crc, UINT32 openflags, mame_file *file)
+static file_error fopen_attempt_zipped(astring &fullname, UINT32 crc, UINT32 openflags, mame_file *file)
{
- astring *filename = astring_alloc();
+ astring filename;
zip_error ziperr;
zip_file *zip;
@@ -293,27 +290,23 @@ static file_error fopen_attempt_zipped(astring *fullname, UINT32 crc, UINT32 ope
int dirsep;
/* find the final path separator */
- dirsep = astring_rchr(fullname, 0, PATH_SEPARATOR[0]);
+ dirsep = fullname.rchr(0, PATH_SEPARATOR[0]);
if (dirsep == -1)
- {
- astring_free(filename);
return FILERR_NOT_FOUND;
- }
/* insert the part from the right of the separator into the head of the filename */
- if (astring_len(filename) > 0)
- astring_insc(filename, 0, "/");
- astring_inssubstr(filename, 0, fullname, dirsep + 1, -1);
+ if (filename.len() > 0)
+ filename.ins(0, "/");
+ filename.inssubstr(0, fullname, dirsep + 1, -1);
/* remove this part of the filename and append a .zip extension */
- astring_substr(fullname, 0, dirsep);
- astring_catc(fullname, ".zip");
+ fullname.substr(0, dirsep).cat(".zip");
/* attempt to open the ZIP file */
- ziperr = zip_file_open(astring_c(fullname), &zip);
+ ziperr = zip_file_open(fullname, &zip);
/* chop the .zip back off the filename before continuing */
- astring_substr(fullname, 0, dirsep);
+ fullname.substr(0, dirsep);
/* if we failed to open this file, continue scanning */
if (ziperr != ZIPERR_NONE)
@@ -353,7 +346,6 @@ static file_error fopen_attempt_zipped(astring *fullname, UINT32 crc, UINT32 ope
crcs[3] = header->crc >> 0;
hash_data_insert_binary_checksum(file->hash, HASH_CRC, crcs);
- astring_free(filename);
if (openflags & OPEN_FLAG_NO_PRELOAD)
return FILERR_NONE;
else
@@ -384,8 +376,6 @@ void mame_fclose(mame_file *file)
core_fclose(file->file);
if (file->zipdata != NULL)
global_free(file->zipdata);
- if (file->filename != NULL)
- astring_free(file->filename);
global_free(file);
}
@@ -673,8 +663,6 @@ mame_path *mame_openpath(core_options *opts, const char *searchpath)
/* initialize the iterator */
path_iterator_init(&path->iterator, opts, searchpath);
- /* allocate a buffer to hold the current path */
- path->pathbuffer = astring_alloc();
return path;
}
@@ -699,7 +687,7 @@ const osd_directory_entry *mame_readpath(mame_path *path)
return NULL;
/* open the path */
- path->curdir = osd_opendir(astring_c(path->pathbuffer));
+ path->curdir = osd_opendir(path->pathbuffer);
}
/* get the next entry from the current directory */
@@ -725,8 +713,6 @@ void mame_closepath(mame_path *path)
osd_closedir(path->curdir);
/* free memory */
- if (path->pathbuffer != NULL)
- astring_free(path->pathbuffer);
global_free(path);
}
@@ -760,12 +746,9 @@ core_file *mame_core_file(mame_file *file)
for a given mame_file
-------------------------------------------------*/
-const char *mame_file_full_name(mame_file *file)
+const astring &mame_file_full_name(mame_file *file)
{
- /* return a pointer to the string if we have one; otherwise, return NULL */
- if (file->filename != NULL)
- return astring_c(file->filename);
- return NULL;
+ return file->filename;
}
@@ -816,9 +799,9 @@ const char *mame_fhash(mame_file *file, UINT32 functions)
static void path_iterator_init(path_iterator *iterator, core_options *opts, const char *searchpath)
{
/* reset the structure */
- memset(iterator, 0, sizeof(*iterator));
iterator->base = (searchpath != NULL && !osd_is_absolute_path(searchpath)) ? options_get_string(opts, searchpath) : "";
iterator->cur = iterator->base;
+ iterator->index = 0;
}
@@ -827,7 +810,7 @@ static void path_iterator_init(path_iterator *iterator, core_options *opts, cons
in a multipath sequence
-------------------------------------------------*/
-static int path_iterator_get_next(path_iterator *iterator, astring *buffer)
+static int path_iterator_get_next(path_iterator *iterator, astring &buffer)
{
const char *semi;
@@ -839,7 +822,7 @@ static int path_iterator_get_next(path_iterator *iterator, astring *buffer)
semi = strchr(iterator->cur, ';');
if (semi == NULL)
semi = iterator->cur + strlen(iterator->cur);
- astring_cpych(buffer, iterator->cur, semi - iterator->cur);
+ buffer.cpy(iterator->cur, semi - iterator->cur);
iterator->cur = (*semi == 0) ? semi : semi + 1;
/* bump the index and return TRUE */
@@ -899,11 +882,11 @@ static file_error load_zipped_file(mame_file *file)
to expected filename, ignoring any directory
-------------------------------------------------*/
-static int zip_filename_match(const zip_file_header *header, const astring *filename)
+static int zip_filename_match(const zip_file_header *header, const astring &filename)
{
- const char *zipfile = header->filename + header->filename_length - astring_len(filename);
+ const char *zipfile = header->filename + header->filename_length - filename.len();
- return (zipfile >= header->filename && astring_icmpc(filename, zipfile) == 0 &&
+ return (zipfile >= header->filename && filename.icmp(zipfile) == 0 &&
(zipfile == header->filename || zipfile[-1] == '/'));
}
diff --git a/src/emu/fileio.h b/src/emu/fileio.h
index 3e77fffe2d5..d2b00bd4189 100644
--- a/src/emu/fileio.h
+++ b/src/emu/fileio.h
@@ -171,7 +171,7 @@ void mame_closepath(mame_path *path);
core_file *mame_core_file(mame_file *file);
/* return the full filename for a given mame_file */
-const char *mame_file_full_name(mame_file *file);
+const astring &mame_file_full_name(mame_file *file);
/* return a hash string for the file with the given functions */
const char *mame_fhash(mame_file *file, UINT32 functions);
diff --git a/src/emu/inptport.c b/src/emu/inptport.c
index b36ef2d8afa..596106f50ec 100644
--- a/src/emu/inptport.c
+++ b/src/emu/inptport.c
@@ -3746,20 +3746,19 @@ static void save_config_callback(running_machine *machine, int config_type, xml_
static void save_sequence(running_machine *machine, xml_data_node *parentnode, int type, int porttype, const input_seq *seq)
{
- astring *seqstring = astring_alloc();
+ astring seqstring;
xml_data_node *seqnode;
/* get the string for the sequence */
if (input_seq_get_1(seq) == SEQCODE_END)
- astring_cpyc(seqstring, "NONE");
+ seqstring.cpy("NONE");
else
input_seq_to_tokens(machine, seqstring, seq);
/* add the new node */
- seqnode = xml_add_child(parentnode, "newseq", astring_c(seqstring));
+ seqnode = xml_add_child(parentnode, "newseq", seqstring);
if (seqnode != NULL)
xml_set_attribute(seqnode, "type", seqtypestrings[type]);
- astring_free(seqstring);
}
diff --git a/src/emu/input.c b/src/emu/input.c
index 89d19bff793..14868d0dad6 100644
--- a/src/emu/input.c
+++ b/src/emu/input.c
@@ -54,8 +54,8 @@ struct _input_device_item
{
input_device_class devclass; /* device class of parent item */
int devindex; /* device index of parent item */
- astring * name; /* string name of item */
- astring * token; /* tokenized name for non-standard items */
+ astring name; /* string name of item */
+ astring token; /* tokenized name for non-standard items */
void * internal; /* internal callback pointer */
input_item_class itemclass; /* class of the item */
input_item_id itemid; /* originally specified item id */
@@ -82,7 +82,7 @@ struct _joystick_map
struct _input_device
{
running_machine * machine; /* machine we are attached to */
- astring * name; /* string name of device */
+ astring name; /* string name of device */
input_device_class devclass; /* class of this device */
int devindex; /* device index of this device */
input_device_item * item[ITEM_ID_ABSOLUTE_MAXIMUM]; /* array of pointers to items */
@@ -759,17 +759,16 @@ input_device *input_device_add(running_machine *machine, input_device_class devc
assert(devclass != DEVICE_CLASS_INVALID && devclass < DEVICE_CLASS_MAXIMUM);
/* allocate a new device */
- input_device *newlist = auto_alloc_array(machine, input_device, devlist->count + 1);
+ input_device *newlist = auto_alloc_array_clear(machine, input_device, devlist->count + 1);
for (int devnum = 0; devnum < devlist->count; devnum++)
newlist[devnum] = devlist->list[devnum];
auto_free(machine, devlist->list);
devlist->list = newlist;
device = &devlist->list[devlist->count++];
- memset(device, 0, sizeof(*device));
/* fill in the data */
device->machine = machine;
- device->name = astring_cpyc(auto_astring_alloc(machine), name);
+ device->name.cpy(name);
device->devclass = devclass;
device->devindex = devlist->count - 1;
device->internal = internal;
@@ -781,7 +780,7 @@ input_device *input_device_add(running_machine *machine, input_device_class devc
device->lastmap = JOYSTICK_MAP_NEUTRAL;
}
- mame_printf_verbose("Input: Adding %s #%d: %s\n", code_to_string(devclass_string_table, devclass), devlist->count, astring_c(device->name));
+ mame_printf_verbose("Input: Adding %s #%d: %s\n", code_to_string(devclass_string_table, devclass), devlist->count, device->name.cstr());
return device;
}
@@ -819,8 +818,7 @@ void input_device_item_add(input_device *device, const char *name, void *interna
/* copy in the data passed in from the item list */
item->devclass = device->devclass;
item->devindex = device->devindex;
- item->name = astring_cpyc(auto_astring_alloc(device->machine), name);
- item->token = NULL;
+ item->name.cpy(name);
item->internal = internal;
item->itemclass = input_item_standard_class(device->devclass, itemid_std);
item->itemid = itemid;
@@ -830,9 +828,7 @@ void input_device_item_add(input_device *device, const char *name, void *interna
if (itemid > ITEM_ID_MAXIMUM)
{
/* copy the item name, removing spaces/underscores and making all caps */
- item->token = astring_toupper(astring_cpyc(auto_astring_alloc(device->machine), name));
- astring_delchr(item->token, ' ');
- astring_delchr(item->token, '_');
+ item->token.cpy(name).toupper().delchr(' ').delchr('_');
}
/* otherwise, make sure we have a valid standard token */
@@ -1280,7 +1276,7 @@ input_code input_code_poll_axes(running_machine *machine, int reset)
a friendly name
-------------------------------------------------*/
-astring *input_code_name(running_machine *machine, astring *string, input_code code)
+astring &input_code_name(running_machine *machine, astring &string, input_code code)
{
input_device_list *device_list = machine->input_data->device_list;
input_device_item *item = input_code_item(machine, code);
@@ -1291,7 +1287,7 @@ astring *input_code_name(running_machine *machine, astring *string, input_code c
/* if nothing there, return an empty string */
if (item == NULL)
- return astring_reset(string);
+ return string.reset();
/* determine the devclass part */
devclass = code_to_string(devclass_string_table, INPUT_CODE_DEVCLASS(code));
@@ -1311,7 +1307,7 @@ astring *input_code_name(running_machine *machine, astring *string, input_code c
}
/* devcode part comes from the item name */
- devcode = astring_c(item->name);
+ devcode = item->name;
/* determine the modifier part */
modifier = code_to_string(modifier_string_table, INPUT_CODE_MODIFIER(code));
@@ -1322,16 +1318,16 @@ astring *input_code_name(running_machine *machine, astring *string, input_code c
devcode = "";
/* concatenate the strings */
- astring_cpyc(string, devclass);
+ string.cpy(devclass);
if (devindex[0] != 0)
- astring_catc(astring_catc(string, " "), devindex);
+ string.cat(" ").cat(devindex);
if (devcode[0] != 0)
- astring_catc(astring_catc(string, " "), devcode);
+ string.cat(" ").cat(devcode);
if (modifier[0] != 0)
- astring_catc(astring_catc(string, " "), modifier);
+ string.cat(" ").cat(modifier);
/* delete any leading spaces */
- return astring_trimspace(string);
+ return string.trimspace();
}
@@ -1340,7 +1336,7 @@ astring *input_code_name(running_machine *machine, astring *string, input_code c
a given code
-------------------------------------------------*/
-astring *input_code_to_token(running_machine *machine, astring *string, input_code code)
+astring &input_code_to_token(running_machine *machine, astring &string, input_code code)
{
input_device_item *item = input_code_item(machine, code);
const char *devclass;
@@ -1359,7 +1355,7 @@ astring *input_code_to_token(running_machine *machine, astring *string, input_co
/* determine the itemid part; look up in the table if we don't have a token */
if (item != NULL && item->token != NULL)
- devcode = astring_c(item->token);
+ devcode = item->token;
else
{
devcode = code_to_string(itemid_token_table, INPUT_CODE_ITEMID(code));
@@ -1377,15 +1373,15 @@ astring *input_code_to_token(running_machine *machine, astring *string, input_co
itemclass = code_to_string(itemclass_token_table, INPUT_CODE_ITEMCLASS(code));
/* concatenate the strings */
- astring_cpyc(string, devclass);
+ string.cpy(devclass);
if (devindex[0] != 0)
- astring_catc(astring_catc(string, "_"), devindex);
+ string.cat("_").cat(devindex);
if (devcode[0] != 0)
- astring_catc(astring_catc(string, "_"), devcode);
+ string.cat("_").cat(devcode);
if (modifier[0] != 0)
- astring_catc(astring_catc(string, "_"), modifier);
+ string.cat("_").cat(modifier);
if (itemclass[0] != 0)
- astring_catc(astring_catc(string, "_"), itemclass);
+ string.cat("_").cat(itemclass);
return string;
}
@@ -1400,7 +1396,7 @@ input_code input_code_from_token(running_machine *machine, const char *_token)
UINT32 devclass, itemid, devindex, modifier, standard;
UINT32 itemclass = ITEM_CLASS_INVALID;
input_code code = INPUT_CODE_INVALID;
- astring *token[6] = { NULL };
+ astring token[6];
int numtokens, curtok;
/* copy the token and break it into pieces */
@@ -1408,7 +1404,7 @@ input_code input_code_from_token(running_machine *machine, const char *_token)
{
/* make a token up to the next underscore */
char *score = (char *)strchr(_token, '_');
- token[numtokens++] = astring_dupch(_token, (score == NULL) ? strlen(_token) : (score - _token));
+ token[numtokens++].cpy(_token, (score == NULL) ? strlen(_token) : (score - _token));
/* if we hit the end, we're done, else advance our pointer */
if (score == NULL)
@@ -1418,13 +1414,13 @@ input_code input_code_from_token(running_machine *machine, const char *_token)
/* first token should be the devclass */
curtok = 0;
- devclass = string_to_code(devclass_token_table, astring_c(token[curtok++]));
+ devclass = string_to_code(devclass_token_table, token[curtok++]);
if (devclass == ~0)
goto exit;
/* second token might be index; look for number */
devindex = 0;
- if (numtokens > 2 && sscanf(astring_c(token[curtok]), "%d", &devindex) == 1)
+ if (numtokens > 2 && sscanf(token[curtok], "%d", &devindex) == 1)
{
curtok++;
devindex--;
@@ -1433,7 +1429,7 @@ input_code input_code_from_token(running_machine *machine, const char *_token)
goto exit;
/* next token is the item ID */
- itemid = string_to_code(itemid_token_table, astring_c(token[curtok]));
+ itemid = string_to_code(itemid_token_table, token[curtok]);
standard = (itemid != ~0);
/* if we're a standard code, default the itemclass based on it */
@@ -1455,7 +1451,7 @@ input_code input_code_from_token(running_machine *machine, const char *_token)
for (itemid = ITEM_ID_FIRST_VALID; itemid <= device->maxitem; itemid++)
{
input_device_item *item = device->item[itemid];
- if (item != NULL && item->token != NULL && astring_cmp(token[curtok], item->token) == 0)
+ if (item != NULL && item->token != NULL && token[curtok].cmp(item->token) == 0)
{
/* take the itemclass from the item */
itemclass = item->itemclass;
@@ -1473,7 +1469,7 @@ input_code input_code_from_token(running_machine *machine, const char *_token)
modifier = ITEM_MODIFIER_NONE;
if (curtok < numtokens)
{
- modifier = string_to_code(modifier_token_table, astring_c(token[curtok]));
+ modifier = string_to_code(modifier_token_table, token[curtok]);
if (modifier != ~0)
curtok++;
else
@@ -1483,7 +1479,7 @@ input_code input_code_from_token(running_machine *machine, const char *_token)
/* if we have another token, it is the item class */
if (curtok < numtokens)
{
- UINT32 temp = string_to_code(itemclass_token_table, astring_c(token[curtok]));
+ UINT32 temp = string_to_code(itemclass_token_table, token[curtok]);
if (temp != ~0)
{
curtok++;
@@ -1499,9 +1495,6 @@ input_code input_code_from_token(running_machine *machine, const char *_token)
code = INPUT_CODE(devclass, devindex, itemclass, modifier, itemid);
exit:
- for (curtok = 0; curtok < ARRAY_LENGTH(token); curtok++)
- if (token[curtok] != NULL)
- astring_free(token[curtok]);
return code;
}
diff --git a/src/emu/input.h b/src/emu/input.h
index d1d5f55760c..1ef605396e2 100644
--- a/src/emu/input.h
+++ b/src/emu/input.h
@@ -631,10 +631,10 @@ input_code input_code_poll_axes(running_machine *machine, int reset);
/* ----- strings and tokenization ----- */
/* generate the friendly name of an input code, returning the length (buffer can be NULL) */
-astring *input_code_name(running_machine *machine, astring *buffer, input_code code);
+astring &input_code_name(running_machine *machine, astring &buffer, input_code code);
/* convert an input code to a token, returning the length (buffer can be NULL) */
-astring *input_code_to_token(running_machine *machine, astring *buffer, input_code code);
+astring &input_code_to_token(running_machine *machine, astring &buffer, input_code code);
/* convert a token back to an input code */
input_code input_code_from_token(running_machine *machine, const char *_token);
diff --git a/src/emu/inputseq.c b/src/emu/inputseq.c
index 81ec4104a40..f064522c618 100644
--- a/src/emu/inputseq.c
+++ b/src/emu/inputseq.c
@@ -406,9 +406,9 @@ int input_seq_poll(running_machine *machine, input_seq *finalseq)
of a sequence
-------------------------------------------------*/
-astring *input_seq_name(running_machine *machine, astring *string, const input_seq *seq)
+astring &input_seq_name(running_machine *machine, astring &string, const input_seq *seq)
{
- astring *codestr = astring_alloc();
+ astring codestr;
int codenum, copycodenum;
input_seq seqcopy;
@@ -418,7 +418,7 @@ astring *input_seq_name(running_machine *machine, astring *string, const input_s
input_code code = seq->code[codenum];
/* if this is a code item which is not valid, don't copy it and remove any preceding ORs/NOTs */
- if (!INPUT_CODE_IS_INTERNAL(code) && astring_len(input_code_name(machine, codestr, code)) == 0)
+ if (!INPUT_CODE_IS_INTERNAL(code) && input_code_name(machine, codestr, code).len() == 0)
{
while (copycodenum > 0 && INPUT_CODE_IS_INTERNAL(seqcopy.code[copycodenum - 1]))
copycodenum--;
@@ -430,13 +430,10 @@ astring *input_seq_name(running_machine *machine, astring *string, const input_s
/* special case: empty */
if (copycodenum == 0)
- {
- astring_free(codestr);
- return astring_cpyc(string, (seq->code[0] == SEQCODE_END) ? "None" : "n/a");
- }
+ return string.cpy((seq->code[0] == SEQCODE_END) ? "None" : "n/a");
/* start with an empty buffer */
- astring_reset(string);
+ string.reset();
/* loop until we hit the end */
for (codenum = 0; codenum < ARRAY_LENGTH(seqcopy.code) && seqcopy.code[codenum] != SEQCODE_END; codenum++)
@@ -445,20 +442,19 @@ astring *input_seq_name(running_machine *machine, astring *string, const input_s
/* append a space if not the first code */
if (codenum != 0)
- astring_catc(string, " ");
+ string.cat(" ");
/* handle OR/NOT codes here */
if (code == SEQCODE_OR)
- astring_catc(string, "or");
+ string.cat("or");
else if (code == SEQCODE_NOT)
- astring_catc(string, "not");
+ string.cat("not");
/* otherwise, assume it is an input code and ask the input system to generate it */
else
- astring_cat(string, input_code_name(machine, codestr, code));
+ string.cat(input_code_name(machine, codestr, code));
}
- astring_free(codestr);
return string;
}
@@ -468,13 +464,13 @@ astring *input_seq_name(running_machine *machine, astring *string, const input_s
form of a sequence
-------------------------------------------------*/
-astring *input_seq_to_tokens(running_machine *machine, astring *string, const input_seq *seq)
+astring &input_seq_to_tokens(running_machine *machine, astring &string, const input_seq *seq)
{
- astring *codestr = astring_alloc();
+ astring codestr;
int codenum;
/* start with an empty buffer */
- astring_reset(string);
+ string.reset();
/* loop until we hit the end */
for (codenum = 0; codenum < ARRAY_LENGTH(seq->code) && seq->code[codenum] != SEQCODE_END; codenum++)
@@ -483,22 +479,21 @@ astring *input_seq_to_tokens(running_machine *machine, astring *string, const in
/* append a space if not the first code */
if (codenum != 0)
- astring_catc(string, " ");
+ string.cat(" ");
/* handle OR/NOT codes here */
if (code == SEQCODE_OR)
- astring_catc(string, "OR");
+ string.cat("OR");
else if (code == SEQCODE_NOT)
- astring_catc(string, "NOT");
+ string.cat("NOT");
else if (code == SEQCODE_DEFAULT)
- astring_catc(string, "DEFAULT");
+ string.cat("DEFAULT");
/* otherwise, assume it is an input code and ask the input system to generate it */
else
- astring_cat(string, input_code_to_token(machine, codestr, code));
+ string.cat(input_code_to_token(machine, codestr, code));
}
- astring_free(codestr);
return string;
}
diff --git a/src/emu/inputseq.h b/src/emu/inputseq.h
index f9de770000e..d9b5e32aa99 100644
--- a/src/emu/inputseq.h
+++ b/src/emu/inputseq.h
@@ -89,10 +89,10 @@ int input_seq_poll(running_machine *machine, input_seq *finalseq);
/* ----- strings and tokenization ----- */
/* generate the friendly name of an input sequence */
-astring *input_seq_name(running_machine *machine, astring *string, const input_seq *seq);
+astring &input_seq_name(running_machine *machine, astring &string, const input_seq *seq);
/* convert an input sequence to tokens, returning the length */
-astring *input_seq_to_tokens(running_machine *machine, astring *string, const input_seq *seq);
+astring &input_seq_to_tokens(running_machine *machine, astring &string, const input_seq *seq);
/* convert a set of tokens back to an input sequence */
int input_seq_from_tokens(running_machine *machine, const char *string, input_seq *seq);
diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c
index fb43c68c165..194647e7f99 100644
--- a/src/emu/machine/generic.c
+++ b/src/emu/machine/generic.c
@@ -313,11 +313,9 @@ mame_file *nvram_fopen(running_machine *machine, UINT32 openflags)
{
file_error filerr;
mame_file *file;
- astring *fname;
- fname = astring_assemble_2(astring_alloc(), machine->basename, ".nv");
- filerr = mame_fopen(SEARCHPATH_NVRAM, astring_c(fname), openflags, &file);
- astring_free(fname);
+ astring fname(machine->basename, ".nv");
+ filerr = mame_fopen(SEARCHPATH_NVRAM, fname, openflags, &file);
return (filerr == FILERR_NONE) ? file : NULL;
}
@@ -473,28 +471,25 @@ int memcard_create(running_machine *machine, int index, int overwrite)
{
file_error filerr;
mame_file *file;
- astring *fname;
char name[16];
/* create a name */
memcard_name(index, name);
/* if we can't overwrite, fail if the file already exists */
- fname = astring_assemble_3(astring_alloc(), machine->basename, PATH_SEPARATOR, name);
+ astring fname(machine->basename, PATH_SEPARATOR, name);
if (!overwrite)
{
- filerr = mame_fopen(SEARCHPATH_MEMCARD, astring_c(fname), OPEN_FLAG_READ, &file);
+ filerr = mame_fopen(SEARCHPATH_MEMCARD, fname, OPEN_FLAG_READ, &file);
if (filerr == FILERR_NONE)
{
mame_fclose(file);
- astring_free(fname);
return 1;
}
}
/* create a new file */
- filerr = mame_fopen(SEARCHPATH_MEMCARD, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
- astring_free(fname);
+ filerr = mame_fopen(SEARCHPATH_MEMCARD, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
if (filerr != FILERR_NONE)
return 1;
@@ -519,7 +514,6 @@ int memcard_insert(running_machine *machine, int index)
file_error filerr;
mame_file *file;
char name[16];
- astring *fname;
/* if a card is already inserted, eject it first */
if (state->memcard_inserted != -1)
@@ -528,11 +522,10 @@ int memcard_insert(running_machine *machine, int index)
/* create a name */
memcard_name(index, name);
- fname = astring_assemble_3(astring_alloc(), machine->basename, PATH_SEPARATOR, name);
+ astring fname(machine->basename, PATH_SEPARATOR, name);
/* open the file; if we can't, it's an error */
- filerr = mame_fopen(SEARCHPATH_MEMCARD, astring_c(fname), OPEN_FLAG_READ, &file);
- astring_free(fname);
+ filerr = mame_fopen(SEARCHPATH_MEMCARD, fname, OPEN_FLAG_READ, &file);
if (filerr != FILERR_NONE)
return 1;
@@ -558,7 +551,6 @@ void memcard_eject(running_machine *machine)
file_error filerr;
mame_file *file;
char name[16];
- astring *fname;
/* if no card is preset, just ignore */
if (state->memcard_inserted == -1)
@@ -566,11 +558,10 @@ void memcard_eject(running_machine *machine)
/* create a name */
memcard_name(state->memcard_inserted, name);
- fname = astring_assemble_3(astring_alloc(), machine->basename, PATH_SEPARATOR, name);
+ astring fname(machine->basename, PATH_SEPARATOR, name);
/* open the file; if we can't, it's an error */
- filerr = mame_fopen(SEARCHPATH_MEMCARD, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
- astring_free(fname);
+ filerr = mame_fopen(SEARCHPATH_MEMCARD, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
if (filerr != FILERR_NONE)
{
mame_fclose(file);
diff --git a/src/emu/machine/ldpr8210.c b/src/emu/machine/ldpr8210.c
index eae443eb851..fbaf1a41d47 100644
--- a/src/emu/machine/ldpr8210.c
+++ b/src/emu/machine/ldpr8210.c
@@ -338,7 +338,7 @@ const ldplayer_interface pr8210_interface =
static void pr8210_init(laserdisc_state *ld)
{
- astring *tempstring = astring_alloc();
+ astring tempstring;
attotime curtime = timer_get_time(ld->device->machine);
ldplayer_data *player = ld->player;
@@ -351,7 +351,6 @@ static void pr8210_init(laserdisc_state *ld)
/* find our CPU */
player->cpu = devtag_get_device(ld->device->machine, device_build_tag(tempstring, ld->device, "pr8210"));
- astring_free(tempstring);
/* we don't have the Simutrek player overrides */
player->simutrek.cpu = NULL;
@@ -1071,7 +1070,7 @@ void simutrek_set_audio_squelch(const device_config *device, int state)
static void simutrek_init(laserdisc_state *ld)
{
- astring *tempstring = astring_alloc();
+ astring tempstring;
ldplayer_data *player = ld->player;
/* standard PR-8210 initialization */
@@ -1083,7 +1082,6 @@ static void simutrek_init(laserdisc_state *ld)
/* find the Simutrek CPU */
player->simutrek.cpu = devtag_get_device(ld->device->machine, device_build_tag(tempstring, ld->device, "simutrek"));
- astring_free(tempstring);
}
diff --git a/src/emu/machine/ldv1000.c b/src/emu/machine/ldv1000.c
index 302e05f768b..5003f7138d6 100644
--- a/src/emu/machine/ldv1000.c
+++ b/src/emu/machine/ldv1000.c
@@ -226,7 +226,7 @@ const ldplayer_interface ldv1000_interface =
static void ldv1000_init(laserdisc_state *ld)
{
- astring *tempstring = astring_alloc();
+ astring tempstring;
ldplayer_data *player = ld->player;
/* reset our state */
@@ -237,7 +237,6 @@ static void ldv1000_init(laserdisc_state *ld)
player->ctc = devtag_get_device(ld->device->machine, device_build_tag(tempstring, ld->device, "ldvctc"));
player->multitimer = devtag_get_device(ld->device->machine, device_build_tag(tempstring, ld->device, "multitimer"));
timer_device_set_ptr(player->multitimer, ld);
- astring_free(tempstring);
}
diff --git a/src/emu/machine/ldvp931.c b/src/emu/machine/ldvp931.c
index cb2c0ab4245..7e668b22e47 100644
--- a/src/emu/machine/ldvp931.c
+++ b/src/emu/machine/ldvp931.c
@@ -204,7 +204,7 @@ void vp931_set_data_ready_callback(const device_config *device, vp931_data_ready
static void vp931_init(laserdisc_state *ld)
{
- astring *tempstring = astring_alloc();
+ astring tempstring;
ldplayer_data *player = ld->player;
vp931_data_ready_func cbsave;
@@ -217,7 +217,6 @@ static void vp931_init(laserdisc_state *ld)
player->cpu = devtag_get_device(ld->device->machine, device_build_tag(tempstring, ld->device, "vp931"));
player->tracktimer = devtag_get_device(ld->device->machine, device_build_tag(tempstring, ld->device, "tracktimer"));
timer_device_set_ptr(player->tracktimer, ld);
- astring_free(tempstring);
}
diff --git a/src/emu/machine/z80ctc.c b/src/emu/machine/z80ctc.c
index bc869d6fba2..d85ed91589e 100644
--- a/src/emu/machine/z80ctc.c
+++ b/src/emu/machine/z80ctc.c
@@ -459,8 +459,8 @@ static void z80ctc_irq_reti(const device_config *device)
static DEVICE_START( z80ctc )
{
const z80ctc_interface *intf = (const z80ctc_interface *)device->static_config;
- astring *tempstring = astring_alloc();
z80ctc *ctc = get_safe_token(device);
+ astring tempstring;
int ch;
ctc->period16 = attotime_mul(ATTOTIME_IN_HZ(device->clock), 16);
@@ -490,8 +490,6 @@ static DEVICE_START( z80ctc )
state_save_register_device_item(device, ch, channel->extclk);
state_save_register_device_item(device, ch, channel->int_state);
}
-
- astring_free(tempstring);
}
diff --git a/src/emu/machine/z80sio.c b/src/emu/machine/z80sio.c
index 278f8026ae1..5f690d09d78 100644
--- a/src/emu/machine/z80sio.c
+++ b/src/emu/machine/z80sio.c
@@ -783,9 +783,9 @@ static void z80sio_irq_reti(const device_config *device)
static DEVICE_START( z80sio )
{
const z80sio_interface *intf = (const z80sio_interface *)device->static_config;
- astring *tempstring = astring_alloc();
z80sio *sio = get_safe_token(device);
void *ptr = (void *)device;
+ astring tempstring;
sio->chan[0].receive_timer = timer_alloc(device->machine, serial_callback, ptr);
sio->chan[1].receive_timer = timer_alloc(device->machine, serial_callback, ptr);
@@ -796,8 +796,6 @@ static DEVICE_START( z80sio )
sio->break_changed_cb = intf->break_changed_cb;
sio->transmit_cb = intf->transmit_cb;
sio->receive_poll_cb = intf->receive_poll_cb;
-
- astring_free(tempstring);
}
diff --git a/src/emu/mame.c b/src/emu/mame.c
index fed4262b2c6..d2167cfac4c 100644
--- a/src/emu/mame.c
+++ b/src/emu/mame.c
@@ -101,11 +101,10 @@ typedef struct _region_info region_info;
struct _region_info
{
region_info * next;
- astring * name;
+ astring name;
UINT32 length;
UINT32 flags;
- UINT8 padding[32 - 2 * sizeof(void *) - 2 * sizeof(UINT32)];
- UINT8 base[1];
+ UINT8 * base;
};
@@ -133,7 +132,7 @@ struct _mame_private
UINT8 hard_reset_pending;
UINT8 exit_pending;
const game_driver *new_driver_pending;
- astring * saveload_pending_file;
+ astring saveload_pending_file;
const char * saveload_searchpath;
emu_timer * soft_reset_timer;
mame_file * logfile;
@@ -250,15 +249,14 @@ int mame_execute(core_options *options)
running_machine *machine;
mame_private *mame;
callback_item *cb;
- astring *gamename;
+ astring gamename;
/* specify the mame_options */
mame_opts = options;
/* convert the specified gamename to a driver */
- gamename = core_filename_extract_base(astring_alloc(), options_get_string(mame_options(), OPTION_GAMENAME), TRUE);
- driver = driver_get_name(astring_c(gamename));
- astring_free(gamename);
+ core_filename_extract_base(&gamename, options_get_string(mame_options(), OPTION_GAMENAME), TRUE);
+ driver = driver_get_name(gamename);
/* if no driver, use the internal empty driver */
if (driver == NULL)
@@ -321,7 +319,7 @@ int mame_execute(core_options *options)
/* run the CPUs until a reset or exit */
mame->hard_reset_pending = FALSE;
- while ((!mame->hard_reset_pending && !mame->exit_pending) || mame->saveload_pending_file != NULL)
+ while ((!mame->hard_reset_pending && !mame->exit_pending) || mame->saveload_pending_file.len() != 0)
{
profiler_mark_start(PROFILER_EXTRA);
@@ -629,18 +627,15 @@ static void set_saveload_filename(running_machine *machine, const char *filename
mame_private *mame = machine->mame_data;
/* free any existing request and allocate a copy of the requested name */
- if (mame->saveload_pending_file != NULL)
- astring_free(mame->saveload_pending_file);
-
if (osd_is_absolute_path(filename))
{
mame->saveload_searchpath = NULL;
- mame->saveload_pending_file = astring_dupc(filename);
+ mame->saveload_pending_file.cpy(filename);
}
else
{
mame->saveload_searchpath = SEARCHPATH_STATE;
- mame->saveload_pending_file = astring_assemble_4(astring_alloc(), machine->basename, PATH_SEPARATOR, filename, ".sta");
+ mame->saveload_pending_file.cpy(machine->basename).cat(PATH_SEPARATOR).cat(filename).cat(".sta");
}
}
@@ -697,7 +692,7 @@ int mame_is_save_or_load_pending(running_machine *machine)
/* we can't check for saveload_pending_file here because it will bypass */
/* required UI screens if a state is queued from the command line */
mame_private *mame = machine->mame_data;
- return (mame->saveload_pending_file != NULL);
+ return (mame->saveload_pending_file.len() != 0);
}
@@ -764,22 +759,23 @@ UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 le
/* make sure we don't have a region of the same name; also find the end of the list */
for (infoptr = &mame->regionlist; *infoptr != NULL; infoptr = &(*infoptr)->next)
- if (astring_cmpc((*infoptr)->name, name) == 0)
+ if ((*infoptr)->name.cmp(name) == 0)
fatalerror("memory_region_alloc called with duplicate region name \"%s\"\n", name);
/* allocate the region */
- info = (region_info *)auto_alloc_array(machine, UINT8, sizeof(*info) + length);
+ info = auto_alloc(machine, region_info);
info->next = NULL;
- info->name = astring_dupc(name);
+ info->name.cpy(name);
info->length = length;
info->flags = flags;
+ info->base = auto_alloc_array(machine, UINT8, length);
/* attempt to put is in the hash table */
tagerr = tagmap_add_unique_hash(mame->regionmap, name, info, FALSE);
if (tagerr == TMERR_DUPLICATE)
{
region_info *match = (region_info *)tagmap_find_hash_only(mame->regionmap, name);
- fatalerror("Memory region '%s' has same hash as tag '%s'; please change one of them", name, astring_c(match->name));
+ fatalerror("Memory region '%s' has same hash as tag '%s'; please change one of them", name, match->name.cstr());
}
/* hook us into the list */
@@ -800,16 +796,16 @@ void memory_region_free(running_machine *machine, const char *name)
/* find the region */
for (infoptr = &mame->regionlist; *infoptr != NULL; infoptr = &(*infoptr)->next)
- if (astring_cmpc((*infoptr)->name, name) == 0)
+ if ((*infoptr)->name.cmp(name) == 0)
{
region_info *info = *infoptr;
/* remove us from the list and the map */
*infoptr = info->next;
- tagmap_remove(mame->regionmap, astring_c(info->name));
+ tagmap_remove(mame->regionmap, info->name);
/* free the region */
- astring_free(info->name);
+ auto_free(machine, info->base);
auto_free(machine, info);
break;
}
@@ -892,11 +888,11 @@ const char *memory_region_next(running_machine *machine, const char *name)
/* NULL means return the first */
if (name == NULL)
- return astring_c(mame->regionlist->name);
+ return mame->regionlist->name;
/* look up the region and return the next guy */
info = (region_info *)tagmap_find_hash_only(mame->regionmap, name);
- return (info != NULL && info->next != NULL) ? astring_c(info->next->name) : NULL;
+ return (info != NULL && info->next != NULL) ? info->next->name.cstr() : NULL;
}
@@ -1243,7 +1239,6 @@ void mame_parse_ini_files(core_options *options, const game_driver *driver)
const game_driver *gparent = (parent != NULL) ? driver_get_clone(parent) : NULL;
const device_config *device;
machine_config *config;
- astring *sourcename;
/* parse "vertical.ini" or "horizont.ini" */
if (driver->flags & ORIENTATION_SWAP_XY)
@@ -1265,14 +1260,13 @@ void mame_parse_ini_files(core_options *options, const game_driver *driver)
machine_config_free(config);
/* next parse "source/<sourcefile>.ini"; if that doesn't exist, try <sourcefile>.ini */
- sourcename = core_filename_extract_base(astring_alloc(), driver->source_file, TRUE);
- astring_insc(sourcename, 0, "source" PATH_SEPARATOR);
- if (!parse_ini_file(options, astring_c(sourcename), OPTION_PRIORITY_SOURCE_INI))
+ astring sourcename;
+ core_filename_extract_base(&sourcename, driver->source_file, TRUE)->ins(0, "source" PATH_SEPARATOR);
+ if (!parse_ini_file(options, sourcename, OPTION_PRIORITY_SOURCE_INI))
{
- core_filename_extract_base(sourcename, driver->source_file, TRUE);
- parse_ini_file(options, astring_c(sourcename), OPTION_PRIORITY_SOURCE_INI);
+ core_filename_extract_base(&sourcename, driver->source_file, TRUE);
+ parse_ini_file(options, sourcename, OPTION_PRIORITY_SOURCE_INI);
}
- astring_free(sourcename);
/* then parent the grandparent, parent, and game-specific INIs */
if (gparent != NULL)
@@ -1293,16 +1287,14 @@ static int parse_ini_file(core_options *options, const char *name, int priority)
{
file_error filerr;
mame_file *file;
- astring *fname;
/* don't parse if it has been disabled */
if (!options_get_bool(options, OPTION_READCONFIG))
return FALSE;
/* open the file; if we fail, that's ok */
- fname = astring_assemble_2(astring_alloc(), name, ".ini");
- filerr = mame_fopen_options(options, SEARCHPATH_INI, astring_c(fname), OPEN_FLAG_READ, &file);
- astring_free(fname);
+ astring fname(name, ".ini");
+ filerr = mame_fopen_options(options, SEARCHPATH_INI, fname, OPEN_FLAG_READ, &file);
if (filerr != FILERR_NONE)
return FALSE;
@@ -1601,7 +1593,7 @@ static void handle_save(running_machine *machine)
mame_file *file;
/* if no name, bail */
- if (mame->saveload_pending_file == NULL)
+ if (mame->saveload_pending_file.len() == 0)
{
mame->saveload_schedule_callback = NULL;
return;
@@ -1620,10 +1612,10 @@ static void handle_save(running_machine *machine)
}
/* open the file */
- filerr = mame_fopen(mame->saveload_searchpath, astring_c(mame->saveload_pending_file), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
+ filerr = mame_fopen(mame->saveload_searchpath, mame->saveload_pending_file, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
if (filerr == FILERR_NONE)
{
- astring *fullname = astring_dupc(mame_file_full_name(file));
+ astring fullname(mame_file_full_name(file));
state_save_error staterr;
/* write the save state */
@@ -1655,17 +1647,15 @@ static void handle_save(running_machine *machine)
/* close and perhaps delete the file */
mame_fclose(file);
if (staterr != STATERR_NONE)
- osd_rmfile(astring_c(fullname));
- astring_free(fullname);
+ osd_rmfile(fullname);
}
else
popmessage("Error: Failed to create save state file.");
/* unschedule the save */
cancel:
- astring_free(mame->saveload_pending_file);
+ mame->saveload_pending_file.reset();
mame->saveload_searchpath = NULL;
- mame->saveload_pending_file = NULL;
mame->saveload_schedule_callback = NULL;
}
@@ -1681,7 +1671,7 @@ static void handle_load(running_machine *machine)
mame_file *file;
/* if no name, bail */
- if (mame->saveload_pending_file == NULL)
+ if (mame->saveload_pending_file.len() == 0)
{
mame->saveload_schedule_callback = NULL;
return;
@@ -1701,7 +1691,7 @@ static void handle_load(running_machine *machine)
}
/* open the file */
- filerr = mame_fopen(mame->saveload_searchpath, astring_c(mame->saveload_pending_file), OPEN_FLAG_READ, &file);
+ filerr = mame_fopen(mame->saveload_searchpath, mame->saveload_pending_file, OPEN_FLAG_READ, &file);
if (filerr == FILERR_NONE)
{
state_save_error staterr;
@@ -1744,8 +1734,7 @@ static void handle_load(running_machine *machine)
/* unschedule the load */
cancel:
- astring_free(mame->saveload_pending_file);
- mame->saveload_pending_file = NULL;
+ mame->saveload_pending_file.reset();
mame->saveload_schedule_callback = NULL;
}
diff --git a/src/emu/mame.h b/src/emu/mame.h
index 65c38c295be..d1a3bfe2299 100644
--- a/src/emu/mame.h
+++ b/src/emu/mame.h
@@ -125,7 +125,6 @@ typedef enum _output_channel output_channel;
#define auto_alloc_array_clear(m, t, c) pool_alloc_array_clear(static_cast<running_machine *>(m)->respool, t, c)
#define auto_free(m, v) pool_free(static_cast<running_machine *>(m)->respool, v)
-#define auto_astring_alloc(m) auto_alloc(m, astring)
#define auto_bitmap_alloc(m, w, h, f) auto_alloc(m, bitmap_t(w, h, f))
#define auto_strdup(m, s) strcpy(auto_alloc_array(m, char, strlen(s) + 1), s)
diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c
index 67f36990c7e..b1960c31fbd 100644
--- a/src/emu/mconfig.c
+++ b/src/emu/mconfig.c
@@ -108,8 +108,8 @@ void machine_config_free(machine_config *config)
static void machine_config_detokenize(machine_config *config, const machine_config_token *tokens, const device_config *owner, int depth)
{
UINT32 entrytype = MCONFIG_TOKEN_INVALID;
- astring *tempstring = astring_alloc();
device_config *device = NULL;
+ astring tempstring;
/* loop over tokens until we hit the end */
while (entrytype != MCONFIG_TOKEN_END)
@@ -153,7 +153,7 @@ static void machine_config_detokenize(machine_config *config, const machine_conf
tag = TOKEN_GET_STRING(tokens);
device = (device_config *)device_list_find_by_tag(&config->devicelist, device_build_tag(tempstring, owner, tag));
if (device == NULL)
- fatalerror("Unable to find device: tag=%s\n", astring_c(tempstring));
+ fatalerror("Unable to find device: tag=%s\n", tempstring.cstr());
break;
case MCONFIG_TOKEN_DEVICE_CLOCK:
@@ -335,6 +335,4 @@ static void machine_config_detokenize(machine_config *config, const machine_conf
if (tokens != NULL)
machine_config_detokenize(config, tokens, device, depth + 1);
}
-
- astring_free(tempstring);
}
diff --git a/src/emu/memory.c b/src/emu/memory.c
index 7655df3ced4..77a879e55a4 100644
--- a/src/emu/memory.c
+++ b/src/emu/memory.c
@@ -894,12 +894,6 @@ void address_map_free(address_map *map)
{
address_map_entry *entry = map->entrylist;
map->entrylist = entry->next;
- if (entry->read.derived_tag != NULL)
- astring_free(entry->read.derived_tag);
- if (entry->write.derived_tag != NULL)
- astring_free(entry->write.derived_tag);
- if (entry->region_string != NULL)
- astring_free(entry->region_string);
global_free(entry);
}
@@ -2339,11 +2333,7 @@ static void map_detokenize(memory_private *memdata, address_map *map, const game
entry->read.name = TOKEN_GET_STRING(tokens);
}
if (entry->read.type == AMH_DEVICE_HANDLER || entry->read.type == AMH_PORT || entry->read.type == AMH_BANK)
- {
- if (entry->read.derived_tag == NULL)
- entry->read.derived_tag = astring_alloc();
entry->read.tag = device_inherit_tag(entry->read.derived_tag, devtag, TOKEN_GET_STRING(tokens));
- }
break;
case ADDRMAP_TOKEN_WRITE:
@@ -2357,11 +2347,7 @@ static void map_detokenize(memory_private *memdata, address_map *map, const game
entry->write.name = TOKEN_GET_STRING(tokens);
}
if (entry->write.type == AMH_DEVICE_HANDLER || entry->write.type == AMH_PORT || entry->write.type == AMH_BANK)
- {
- if (entry->write.derived_tag == NULL)
- entry->write.derived_tag = astring_alloc();
entry->write.tag = device_inherit_tag(entry->write.derived_tag, devtag, TOKEN_GET_STRING(tokens));
- }
break;
case ADDRMAP_TOKEN_READWRITE:
@@ -2382,11 +2368,7 @@ static void map_detokenize(memory_private *memdata, address_map *map, const game
if (entry->read.type == AMH_DEVICE_HANDLER || entry->read.type == AMH_PORT || entry->read.type == AMH_BANK)
{
const char *basetag = TOKEN_GET_STRING(tokens);
- if (entry->read.derived_tag == NULL)
- entry->read.derived_tag = astring_alloc();
entry->read.tag = device_inherit_tag(entry->read.derived_tag, devtag, basetag);
- if (entry->write.derived_tag == NULL)
- entry->write.derived_tag = astring_alloc();
entry->write.tag = device_inherit_tag(entry->write.derived_tag, devtag, basetag);
}
break;
@@ -2395,8 +2377,6 @@ static void map_detokenize(memory_private *memdata, address_map *map, const game
check_entry_field(region);
TOKEN_UNGET_UINT32(tokens);
TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->rgnoffs, 32);
- if (entry->region_string == NULL)
- entry->region_string = astring_alloc();
entry->region = device_inherit_tag(entry->region_string, devtag, TOKEN_GET_STRING(tokens));
break;
diff --git a/src/emu/memory.h b/src/emu/memory.h
index 408d7e1d5f1..66fbe8a63dc 100644
--- a/src/emu/memory.h
+++ b/src/emu/memory.h
@@ -215,7 +215,7 @@ struct _map_handler_data
memory_handler handler; /* a memory handler */
const char * name; /* name of the handler */
const char * tag; /* tag pointing to a reference */
- astring * derived_tag; /* string used to hold derived names */
+ astring derived_tag; /* string used to hold derived names */
};
@@ -224,7 +224,7 @@ typedef struct _address_map_entry address_map_entry;
struct _address_map_entry
{
address_map_entry * next; /* pointer to the next entry */
- astring * region_string; /* string used to hold derived names */
+ astring region_string; /* string used to hold derived names */
offs_t addrstart; /* start address */
offs_t addrend; /* end address */
diff --git a/src/emu/profiler.c b/src/emu/profiler.c
index 0d521e6318c..374afa45478 100644
--- a/src/emu/profiler.c
+++ b/src/emu/profiler.c
@@ -111,7 +111,7 @@ void _profiler_mark_end(void)
in an astring
-------------------------------------------------*/
-astring *_profiler_get_text(running_machine *machine, astring *string)
+astring &_profiler_get_text(running_machine *machine, astring &string)
{
static const profile_string names[] =
{
@@ -161,7 +161,7 @@ astring *_profiler_get_text(running_machine *machine, astring *string)
/* this becomes the total; if we end up with 0 for anything, we were just started, so return empty */
total = computed;
- astring_reset(string);
+ string.reset();
if (total == 0 || normalize == 0)
goto out;
@@ -179,25 +179,25 @@ astring *_profiler_get_text(running_machine *machine, astring *string)
int nameindex;
/* start with the un-normalized percentage */
- astring_catprintf(string, "%02d%% ", (int)((computed * 100 + total/2) / total));
+ string.catprintf("%02d%% ", (int)((computed * 100 + total/2) / total));
/* followed by the normalized percentage for everything but profiler and idle */
if (curtype < PROFILER_PROFILER)
- astring_catprintf(string, "%02d%% ", (int)((computed * 100 + normalize/2) / normalize));
+ string.catprintf("%02d%% ", (int)((computed * 100 + normalize/2) / normalize));
/* and then the text */
if (curtype >= PROFILER_CPU_FIRST && curtype <= PROFILER_CPU_MAX)
- astring_catprintf(string, "CPU '%s'", device_list_find_by_index(&machine->config->devicelist, CPU, curtype - PROFILER_CPU_FIRST)->tag);
+ string.catprintf("CPU '%s'", device_list_find_by_index(&machine->config->devicelist, CPU, curtype - PROFILER_CPU_FIRST)->tag);
else
for (nameindex = 0; nameindex < ARRAY_LENGTH(names); nameindex++)
if (names[nameindex].type == curtype)
{
- astring_catc(string, names[nameindex].string);
+ string.cat(names[nameindex].string);
break;
}
/* followed by a carriage return */
- astring_catc(string, "\n");
+ string.cat("\n");
}
}
@@ -207,7 +207,7 @@ astring *_profiler_get_text(running_machine *machine, astring *string)
switches = 0;
for (curmem = 0; curmem < ARRAY_LENGTH(global_profiler.data); curmem++)
switches += global_profiler.data[curmem].context_switches;
- astring_catprintf(string, "%d CPU switches\n", switches / (int) ARRAY_LENGTH(global_profiler.data));
+ string.catprintf("%d CPU switches\n", switches / (int) ARRAY_LENGTH(global_profiler.data));
}
/* advance to the next dataset and reset it to 0 */
diff --git a/src/emu/profiler.h b/src/emu/profiler.h
index 791e172d9f0..b192ea641ab 100644
--- a/src/emu/profiler.h
+++ b/src/emu/profiler.h
@@ -150,7 +150,7 @@ void _profiler_mark_start(int type);
void _profiler_mark_end(void);
/* return the current text in an astring */
-astring *_profiler_get_text(running_machine *machine, astring *string);
+astring &_profiler_get_text(running_machine *machine, astring &string);
#endif /* __PROFILER_H__ */
diff --git a/src/emu/rendlay.c b/src/emu/rendlay.c
index 548c74f4845..4c4d6b94a47 100644
--- a/src/emu/rendlay.c
+++ b/src/emu/rendlay.c
@@ -1487,16 +1487,12 @@ layout_file *layout_file_load(const machine_config *config, const char *dirname,
{
file_error filerr;
mame_file *layoutfile;
- astring *fname;
- fname = astring_assemble_2(astring_alloc(), filename, ".lay");
+ astring fname(filename, ".lay");
if (dirname != NULL)
- {
- astring_insc(fname, 0, PATH_SEPARATOR);
- astring_insc(fname, 0, dirname);
- }
- filerr = mame_fopen(SEARCHPATH_ARTWORK, astring_c(fname), OPEN_FLAG_READ, &layoutfile);
- astring_free(fname);
+ fname.ins(0, PATH_SEPARATOR).ins(0, dirname);
+
+ filerr = mame_fopen(SEARCHPATH_ARTWORK, fname, OPEN_FLAG_READ, &layoutfile);
if (filerr != FILERR_NONE)
return NULL;
diff --git a/src/emu/rendutil.c b/src/emu/rendutil.c
index 16e91d9aa2d..eac515c40dc 100644
--- a/src/emu/rendutil.c
+++ b/src/emu/rendutil.c
@@ -565,16 +565,15 @@ bitmap_t *render_load_png(const char *path, const char *dirname, const char *fil
file_error filerr;
mame_file *file;
png_info png;
- astring *fname;
png_error result;
/* open the file */
+ astring fname;
if (dirname == NULL)
- fname = astring_dupc(filename);
+ fname.cpy(filename);
else
- fname = astring_assemble_3(astring_alloc(), dirname, PATH_SEPARATOR, filename);
- filerr = mame_fopen(path, astring_c(fname), OPEN_FLAG_READ, &file);
- astring_free(fname);
+ fname.cpy(dirname).cat(PATH_SEPARATOR).cat(filename);
+ filerr = mame_fopen(path, fname, OPEN_FLAG_READ, &file);
if (filerr != FILERR_NONE)
return NULL;
diff --git a/src/emu/romload.c b/src/emu/romload.c
index d3d4e7a6a90..847149810e3 100644
--- a/src/emu/romload.c
+++ b/src/emu/romload.c
@@ -68,7 +68,7 @@ struct _romload_private
UINT8 * regionbase; /* base of current region */
UINT32 regionlength; /* length of current region */
- astring * errorstring; /* error string */
+ astring errorstring; /* error string */
};
@@ -267,14 +267,14 @@ const rom_entry *rom_next_file(const rom_entry *romp)
for a rom region
-------------------------------------------------*/
-astring *rom_region_name(astring *result, const game_driver *drv, const rom_source *source, const rom_entry *romp)
+astring &rom_region_name(astring &result, const game_driver *drv, const rom_source *source, const rom_entry *romp)
{
if (rom_source_is_gamedrv(drv, source))
- astring_cpyc(result, ROMREGION_GETTAG(romp));
+ result.cpy(ROMREGION_GETTAG(romp));
else
{
const device_config *device = (const device_config *)source;
- astring_printf(result, "%s:%s", device->tag, ROMREGION_GETTAG(romp));
+ result.printf("%s:%s", device->tag, ROMREGION_GETTAG(romp));
}
return result;
}
@@ -372,7 +372,7 @@ static void determine_bios_rom(rom_load_data *romdata)
/* if we got neither an empty string nor 'default' then warn the user */
if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL)
{
- astring_catprintf(romdata->errorstring, "%s: invalid bios\n", specbios);
+ romdata->errorstring.catprintf("%s: invalid bios\n", specbios);
romdata->warnings++;
}
@@ -432,21 +432,21 @@ static void handle_missing_file(rom_load_data *romdata, const rom_entry *romp)
/* optional files are okay */
if (ROM_ISOPTIONAL(romp))
{
- astring_catprintf(romdata->errorstring, "OPTIONAL %s NOT FOUND\n", ROM_GETNAME(romp));
+ romdata->errorstring.catprintf("OPTIONAL %s NOT FOUND\n", ROM_GETNAME(romp));
romdata->warnings++;
}
/* no good dumps are okay */
else if (ROM_NOGOODDUMP(romp))
{
- astring_catprintf(romdata->errorstring, "%s NOT FOUND (NO GOOD DUMP KNOWN)\n", ROM_GETNAME(romp));
+ romdata->errorstring.catprintf("%s NOT FOUND (NO GOOD DUMP KNOWN)\n", ROM_GETNAME(romp));
romdata->warnings++;
}
/* anything else is bad */
else
{
- astring_catprintf(romdata->errorstring, "%s NOT FOUND\n", ROM_GETNAME(romp));
+ romdata->errorstring.catprintf("%s NOT FOUND\n", ROM_GETNAME(romp));
romdata->errors++;
}
}
@@ -468,13 +468,13 @@ static void dump_wrong_and_correct_checksums(rom_load_data *romdata, const char
found_functions = hash_data_used_functions(hash) & hash_data_used_functions(acthash);
hash_data_print(hash, found_functions, chksum);
- astring_catprintf(romdata->errorstring, " EXPECTED: %s\n", chksum);
+ romdata->errorstring.catprintf(" EXPECTED: %s\n", chksum);
/* We dump informations only of the functions for which MAME provided
a correct checksum. Other functions we might have calculated are
useless here */
hash_data_print(acthash, found_functions, chksum);
- astring_catprintf(romdata->errorstring, " FOUND: %s\n", chksum);
+ romdata->errorstring.catprintf(" FOUND: %s\n", chksum);
/* For debugging purposes, we check if the checksums available in the
driver are correctly specified or not. This can be done by checking
@@ -491,7 +491,7 @@ static void dump_wrong_and_correct_checksums(rom_load_data *romdata, const char
for (i = 0; i < HASH_NUM_FUNCTIONS; i++)
if (wrong_functions & (1 << i))
{
- astring_catprintf(romdata->errorstring,
+ romdata->errorstring.catprintf(
"\tInvalid %s checksum treated as 0 (check leading zeros)\n",
hash_function_name(1 << i));
@@ -522,21 +522,21 @@ static void verify_length_and_hash(rom_load_data *romdata, const char *name, UIN
/* verify length */
if (explength != actlength)
{
- astring_catprintf(romdata->errorstring, "%s WRONG LENGTH (expected: %08x found: %08x)\n", name, explength, actlength);
+ romdata->errorstring.catprintf("%s WRONG LENGTH (expected: %08x found: %08x)\n", name, explength, actlength);
romdata->warnings++;
}
/* If there is no good dump known, write it */
if (hash_data_has_info(hash, HASH_INFO_NO_DUMP))
{
- astring_catprintf(romdata->errorstring, "%s NO GOOD DUMP KNOWN\n", name);
+ romdata->errorstring.catprintf("%s NO GOOD DUMP KNOWN\n", name);
romdata->warnings++;
}
/* verify checksums */
else if (!hash_data_is_equal(hash, acthash, 0))
{
/* otherwise, it's just bad */
- astring_catprintf(romdata->errorstring, "%s WRONG CHECKSUMS:\n", name);
+ romdata->errorstring.catprintf("%s WRONG CHECKSUMS:\n", name);
dump_wrong_and_correct_checksums(romdata, hash, acthash);
@@ -545,7 +545,7 @@ static void verify_length_and_hash(rom_load_data *romdata, const char *name, UIN
/* If it matches, but it is actually a bad dump, write it */
else if (hash_data_has_info(hash, HASH_INFO_BAD_DUMP))
{
- astring_catprintf(romdata->errorstring, "%s ROM NEEDS REDUMP\n",name);
+ romdata->errorstring.catprintf("%s ROM NEEDS REDUMP\n",name);
romdata->warnings++;
}
}
@@ -592,16 +592,15 @@ static void display_rom_load_results(rom_load_data *romdata)
}
/* create the error message and exit fatally */
- mame_printf_error("%s", astring_c(romdata->errorstring));
- astring_free(romdata->errorstring);
+ mame_printf_error("%s", romdata->errorstring.cstr());
fatalerror_exitcode(romdata->machine, MAMERR_MISSING_FILES, "ERROR: required files are missing, the "GAMENOUN" cannot be run.");
}
/* if we had warnings, output them, but continue */
if (romdata->warnings)
{
- astring_catc(romdata->errorstring, "WARNING: the "GAMENOUN" might not run correctly.");
- mame_printf_warning("%s\n", astring_c(romdata->errorstring));
+ romdata->errorstring.cat("WARNING: the "GAMENOUN" might not run correctly.");
+ mame_printf_warning("%s\n", romdata->errorstring.cstr());
}
}
@@ -674,23 +673,21 @@ static int open_rom_file(rom_load_data *romdata, const char *regiontag, const ro
for (drv = romdata->machine->gamedrv; romdata->file == NULL && drv != NULL; drv = driver_get_clone(drv))
if (drv->name != NULL && *drv->name != 0)
{
- astring *fname = astring_assemble_3(astring_alloc(), drv->name, PATH_SEPARATOR, ROM_GETNAME(romp));
+ astring fname(drv->name, PATH_SEPARATOR, ROM_GETNAME(romp));
if (has_crc)
- filerr = mame_fopen_crc(SEARCHPATH_ROM, astring_c(fname), crc, OPEN_FLAG_READ, &romdata->file);
+ filerr = mame_fopen_crc(SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ, &romdata->file);
else
- filerr = mame_fopen(SEARCHPATH_ROM, astring_c(fname), OPEN_FLAG_READ, &romdata->file);
- astring_free(fname);
+ filerr = mame_fopen(SEARCHPATH_ROM, fname, OPEN_FLAG_READ, &romdata->file);
}
/* if the region is load by name, load the ROM from there */
if (romdata->file == NULL && regiontag != NULL)
{
- astring *fname = astring_assemble_3(astring_alloc(), regiontag, PATH_SEPARATOR, ROM_GETNAME(romp));
+ astring fname(regiontag, PATH_SEPARATOR, ROM_GETNAME(romp));
if (has_crc)
- filerr = mame_fopen_crc(SEARCHPATH_ROM, astring_c(fname), crc, OPEN_FLAG_READ, &romdata->file);
+ filerr = mame_fopen_crc(SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ, &romdata->file);
else
- filerr = mame_fopen(SEARCHPATH_ROM, astring_c(fname), OPEN_FLAG_READ, &romdata->file);
- astring_free(fname);
+ filerr = mame_fopen(SEARCHPATH_ROM, fname, OPEN_FLAG_READ, &romdata->file);
}
/* update counters */
@@ -1029,16 +1026,14 @@ chd_error open_disk_image_options(core_options *options, const game_driver *game
filerr = FILERR_NOT_FOUND;
for (searchdrv = gamedrv; searchdrv != NULL && filerr != FILERR_NONE; searchdrv = driver_get_clone(searchdrv))
{
- astring *fname = astring_assemble_4(astring_alloc(), searchdrv->name, PATH_SEPARATOR, ROM_GETNAME(romp), ".chd");
- filerr = mame_fopen_options(options, SEARCHPATH_IMAGE, astring_c(fname), OPEN_FLAG_READ, image_file);
- astring_free(fname);
+ astring fname(searchdrv->name, PATH_SEPARATOR, ROM_GETNAME(romp), ".chd");
+ filerr = mame_fopen_options(options, SEARCHPATH_IMAGE, fname, OPEN_FLAG_READ, image_file);
}
if (filerr != FILERR_NONE)
{
- astring *fname = astring_assemble_2(astring_alloc(), ROM_GETNAME(romp), ".chd");
- filerr = mame_fopen_options(options, SEARCHPATH_IMAGE, astring_c(fname), OPEN_FLAG_READ, image_file);
- astring_free(fname);
+ astring fname(ROM_GETNAME(romp), ".chd");
+ filerr = mame_fopen_options(options, SEARCHPATH_IMAGE, fname, OPEN_FLAG_READ, image_file);
}
/* did the file open succeed? */
@@ -1072,16 +1067,14 @@ chd_error open_disk_image_options(core_options *options, const game_driver *game
filerr = FILERR_NOT_FOUND;
for (searchdrv = drv; searchdrv != NULL && filerr != FILERR_NONE; searchdrv = driver_get_clone(searchdrv))
{
- astring *fname = astring_assemble_4(astring_alloc(), searchdrv->name, PATH_SEPARATOR, ROM_GETNAME(rom), ".chd");
- filerr = mame_fopen_options(options, SEARCHPATH_IMAGE, astring_c(fname), OPEN_FLAG_READ, image_file);
- astring_free(fname);
+ astring fname(searchdrv->name, PATH_SEPARATOR, ROM_GETNAME(rom), ".chd");
+ filerr = mame_fopen_options(options, SEARCHPATH_IMAGE, fname, OPEN_FLAG_READ, image_file);
}
if (filerr != FILERR_NONE)
{
- astring *fname = astring_assemble_2(astring_alloc(), ROM_GETNAME(rom), ".chd");
- filerr = mame_fopen_options(options, SEARCHPATH_IMAGE, astring_c(fname), OPEN_FLAG_READ, image_file);
- astring_free(fname);
+ astring fname(ROM_GETNAME(rom), ".chd");
+ filerr = mame_fopen_options(options, SEARCHPATH_IMAGE, fname, OPEN_FLAG_READ, image_file);
}
/* did the file open succeed? */
@@ -1108,7 +1101,7 @@ chd_error open_disk_image_options(core_options *options, const game_driver *game
static chd_error open_disk_diff(const game_driver *drv, const rom_entry *romp, chd_file *source, mame_file **diff_file, chd_file **diff_chd)
{
- astring *fname = astring_assemble_2(astring_alloc(), ROM_GETNAME(romp), ".dif");
+ astring fname(ROM_GETNAME(romp), ".dif");
file_error filerr;
chd_error err;
@@ -1116,13 +1109,13 @@ static chd_error open_disk_diff(const game_driver *drv, const rom_entry *romp, c
*diff_chd = NULL;
/* try to open the diff */
- LOG(("Opening differencing image file: %s\n", astring_c(fname)));
- filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_WRITE, diff_file);
+ LOG(("Opening differencing image file: %s\n", fname.cstr()));
+ filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, fname, OPEN_FLAG_READ | OPEN_FLAG_WRITE, diff_file);
if (filerr != FILERR_NONE)
{
/* didn't work; try creating it instead */
- LOG(("Creating differencing image: %s\n", astring_c(fname)));
- filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, astring_c(fname), OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, diff_file);
+ LOG(("Creating differencing image: %s\n", fname.cstr()));
+ filerr = mame_fopen(SEARCHPATH_IMAGE_DIFF, fname, OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, diff_file);
if (filerr != FILERR_NONE)
{
err = CHDERR_FILE_NOT_FOUND;
@@ -1135,13 +1128,12 @@ static chd_error open_disk_diff(const game_driver *drv, const rom_entry *romp, c
goto done;
}
- LOG(("Opening differencing image file: %s\n", astring_c(fname)));
+ LOG(("Opening differencing image file: %s\n", fname.cstr()));
err = chd_open_file(mame_core_file(*diff_file), CHD_OPEN_READWRITE, source, diff_chd);
if (err != CHDERR_NONE)
goto done;
done:
- astring_free(fname);
if ((err != CHDERR_NONE) && (*diff_file != NULL))
{
mame_fclose(*diff_file);
@@ -1158,8 +1150,6 @@ done:
static void process_disk_entries(rom_load_data *romdata, const char *regiontag, const rom_entry *romp)
{
- astring *filename = astring_alloc();
-
/* loop until we hit the end of this region */
for ( ; !ROMENTRY_ISREGIONEND(romp); romp++)
{
@@ -1175,17 +1165,17 @@ static void process_disk_entries(rom_load_data *romdata, const char *regiontag,
chd.region = regiontag;
/* make the filename of the source */
- filename = astring_assemble_2(filename, ROM_GETNAME(romp), ".chd");
+ astring filename(ROM_GETNAME(romp), ".chd");
/* first open the source drive */
- LOG(("Opening disk image: %s\n", astring_c(filename)));
+ LOG(("Opening disk image: %s\n", filename.cstr()));
err = open_disk_image(romdata->machine->gamedrv, romp, &chd.origfile, &chd.origchd);
if (err != CHDERR_NONE)
{
if (err == CHDERR_FILE_NOT_FOUND)
- astring_catprintf(romdata->errorstring, "%s NOT FOUND\n", astring_c(filename));
+ romdata->errorstring.catprintf("%s NOT FOUND\n", filename.cstr());
else
- astring_catprintf(romdata->errorstring, "%s CHD ERROR: %s\n", astring_c(filename), chd_error_string(err));
+ romdata->errorstring.catprintf("%s CHD ERROR: %s\n", filename.cstr(), chd_error_string(err));
/* if this is NO_DUMP, keep going, though the system may not be able to handle it */
if (hash_data_has_info(ROM_GETHASHDATA(romp), HASH_INFO_NO_DUMP) || DISK_ISOPTIONAL(romp))
@@ -1203,13 +1193,13 @@ static void process_disk_entries(rom_load_data *romdata, const char *regiontag,
/* verify the hash */
if (!hash_data_is_equal(ROM_GETHASHDATA(romp), acthash, 0))
{
- astring_catprintf(romdata->errorstring, "%s WRONG CHECKSUMS:\n", astring_c(filename));
+ romdata->errorstring.catprintf("%s WRONG CHECKSUMS:\n", filename.cstr());
dump_wrong_and_correct_checksums(romdata, ROM_GETHASHDATA(romp), acthash);
romdata->warnings++;
}
else if (hash_data_has_info(ROM_GETHASHDATA(romp), HASH_INFO_BAD_DUMP))
{
- astring_catprintf(romdata->errorstring, "%s CHD NEEDS REDUMP\n", astring_c(filename));
+ romdata->errorstring.catprintf("%s CHD NEEDS REDUMP\n", filename.cstr());
romdata->warnings++;
}
@@ -1220,7 +1210,7 @@ static void process_disk_entries(rom_load_data *romdata, const char *regiontag,
err = open_disk_diff(romdata->machine->gamedrv, romp, chd.origchd, &chd.difffile, &chd.diffchd);
if (err != CHDERR_NONE)
{
- astring_catprintf(romdata->errorstring, "%s DIFF CHD ERROR: %s\n", astring_c(filename), chd_error_string(err));
+ romdata->errorstring.catprintf("%s DIFF CHD ERROR: %s\n", filename.cstr(), chd_error_string(err));
romdata->errors++;
continue;
}
@@ -1231,7 +1221,6 @@ static void process_disk_entries(rom_load_data *romdata, const char *regiontag,
add_disk_handle(romdata->machine, &chd);
}
}
- astring_free(filename);
}
@@ -1276,7 +1265,7 @@ static UINT32 normalize_flags_for_device(running_machine *machine, UINT32 startf
static void process_region_list(rom_load_data *romdata)
{
- astring *regiontag = astring_alloc();
+ astring regiontag;
const rom_source *source;
const rom_entry *region;
@@ -1288,17 +1277,17 @@ static void process_region_list(rom_load_data *romdata)
UINT32 regionflags = ROMREGION_GETFLAGS(region);
rom_region_name(regiontag, romdata->machine->gamedrv, source, region);
- LOG(("Processing region \"%s\" (length=%X)\n", astring_c(regiontag), regionlength));
+ LOG(("Processing region \"%s\" (length=%X)\n", regiontag.cstr(), regionlength));
/* the first entry must be a region */
assert(ROMENTRY_ISREGION(region));
/* if this is a device region, override with the device width and endianness */
- if (devtag_get_device(romdata->machine, astring_c(regiontag)) != NULL)
- regionflags = normalize_flags_for_device(romdata->machine, regionflags, astring_c(regiontag));
+ if (devtag_get_device(romdata->machine, regiontag) != NULL)
+ regionflags = normalize_flags_for_device(romdata->machine, regionflags, regiontag);
/* remember the base and length */
- romdata->regionbase = memory_region_alloc(romdata->machine, astring_c(regiontag), regionlength, regionflags);
+ romdata->regionbase = memory_region_alloc(romdata->machine, regiontag, regionlength, regionflags);
romdata->regionlength = regionlength;
LOG(("Allocated %X bytes @ %p\n", romdata->regionlength, romdata->regionbase));
@@ -1327,8 +1316,6 @@ static void process_region_list(rom_load_data *romdata)
for (source = rom_first_source(romdata->machine->gamedrv, romdata->machine->config); source != NULL; source = rom_next_source(romdata->machine->gamedrv, romdata->machine->config, source))
for (region = rom_first_region(romdata->machine->gamedrv, source); region != NULL; region = rom_next_region(region))
region_post_process(romdata, ROMREGION_GETTAG(region));
-
- astring_free(regiontag);
}
@@ -1349,7 +1336,6 @@ void rom_init(running_machine *machine)
/* reset the romdata struct */
romdata->machine = machine;
- romdata->errorstring = astring_alloc();
/* figure out which BIOS we are using */
determine_bios_rom(romdata);
@@ -1366,7 +1352,6 @@ void rom_init(running_machine *machine)
/* display the results and exit */
display_rom_load_results(romdata);
- astring_free(romdata->errorstring);
}
diff --git a/src/emu/romload.h b/src/emu/romload.h
index a18cac123c0..19eec69ca09 100644
--- a/src/emu/romload.h
+++ b/src/emu/romload.h
@@ -307,7 +307,7 @@ int rom_source_is_gamedrv(const game_driver *drv, const rom_source *source);
UINT32 rom_file_size(const rom_entry *romp);
/* return the appropriate name for a rom region */
-astring *rom_region_name(astring *result, const game_driver *drv, const rom_source *source, const rom_entry *romp);
+astring &rom_region_name(astring &result, const game_driver *drv, const rom_source *source, const rom_entry *romp);
diff --git a/src/emu/sound.c b/src/emu/sound.c
index 13ce05c91e7..84f19475ced 100644
--- a/src/emu/sound.c
+++ b/src/emu/sound.c
@@ -421,9 +421,9 @@ DEVICE_GET_INFO( sound )
static void route_sound(running_machine *machine)
{
- astring *tempstring = astring_alloc();
const device_config *curspeak;
const device_config *sound;
+ astring tempstring;
int outputnum;
/* first count up the inputs for each speaker */
@@ -488,14 +488,14 @@ static void route_sound(running_machine *machine)
speaker_info *speakerinfo = get_safe_token(target_device);
/* generate text for the UI */
- astring_printf(tempstring, "Speaker '%s': %s '%s'", target_device->tag, device_get_name(sound), sound->tag);
+ tempstring.printf("Speaker '%s': %s '%s'", target_device->tag, device_get_name(sound), sound->tag);
if (numoutputs > 1)
- astring_catprintf(tempstring, " Ch.%d", outputnum);
+ tempstring.catprintf(" Ch.%d", outputnum);
/* fill in the input data on this speaker */
speakerinfo->input[speakerinfo->inputs].gain = route->gain;
speakerinfo->input[speakerinfo->inputs].default_gain = route->gain;
- speakerinfo->input[speakerinfo->inputs].name = auto_strdup(machine, astring_c(tempstring));
+ speakerinfo->input[speakerinfo->inputs].name = auto_strdup(machine, tempstring);
/* connect the output to the input */
if (stream_device_output_to_stream_output(sound, outputnum, &stream, &streamoutput))
@@ -515,9 +515,6 @@ static void route_sound(running_machine *machine)
}
}
}
-
- /* free up our temporary string */
- astring_free(tempstring);
}
diff --git a/src/emu/sound/2610intf.c b/src/emu/sound/2610intf.c
index 4070e56556e..af84bd12e41 100644
--- a/src/emu/sound/2610intf.c
+++ b/src/emu/sound/2610intf.c
@@ -150,7 +150,7 @@ static DEVICE_START( ym2610 )
void *pcmbufa,*pcmbufb;
int pcmsizea,pcmsizeb;
ym2610_state *info = get_safe_token(device);
- astring *name = astring_alloc();
+ astring name;
sound_type type = sound_get_type(device);
info->intf = intf;
@@ -167,10 +167,9 @@ static DEVICE_START( ym2610 )
/* setup adpcm buffers */
pcmbufa = device->region;
pcmsizea = device->regionbytes;
- astring_printf(name, "%s.deltat", device->tag);
- pcmbufb = (void *)(memory_region(device->machine, astring_c(name)));
- pcmsizeb = memory_region_length(device->machine, astring_c(name));
- astring_free(name);
+ name.printf("%s.deltat", device->tag);
+ pcmbufb = (void *)(memory_region(device->machine, name));
+ pcmsizeb = memory_region_length(device->machine, name);
if (pcmbufb == NULL || pcmsizeb == 0)
{
pcmbufb = pcmbufa;
diff --git a/src/emu/sound/samples.c b/src/emu/sound/samples.c
index 28aa3ea8f88..e0413c430bf 100644
--- a/src/emu/sound/samples.c
+++ b/src/emu/sound/samples.c
@@ -210,23 +210,20 @@ loaded_samples *readsamples(running_machine *machine, const char *const *samplen
{
file_error filerr;
mame_file *f;
- astring *fname;
- fname = astring_assemble_3(astring_alloc(), basename, PATH_SEPARATOR, samplenames[i+skipfirst]);
- filerr = mame_fopen(SEARCHPATH_SAMPLE, astring_c(fname), OPEN_FLAG_READ, &f);
+ astring fname(basename, PATH_SEPARATOR, samplenames[i+skipfirst]);
+ filerr = mame_fopen(SEARCHPATH_SAMPLE, fname, OPEN_FLAG_READ, &f);
if (filerr != FILERR_NONE && skipfirst)
{
- astring_assemble_3(fname, samplenames[0] + 1, PATH_SEPARATOR, samplenames[i+skipfirst]);
- filerr = mame_fopen(SEARCHPATH_SAMPLE, astring_c(fname), OPEN_FLAG_READ, &f);
+ astring fname(samplenames[0] + 1, PATH_SEPARATOR, samplenames[i+skipfirst]);
+ filerr = mame_fopen(SEARCHPATH_SAMPLE, fname, OPEN_FLAG_READ, &f);
}
if (filerr == FILERR_NONE)
{
read_wav_sample(machine, f, &samples->sample[i]);
mame_fclose(f);
}
-
- astring_free(fname);
}
return samples;
diff --git a/src/emu/state.c b/src/emu/state.c
index 499a4e64819..7be6eb2b19b 100644
--- a/src/emu/state.c
+++ b/src/emu/state.c
@@ -66,7 +66,7 @@ struct _state_entry
state_entry * next; /* pointer to next entry */
running_machine * machine; /* pointer back to the owning machine */
void * data; /* pointer to the memory to save/restore */
- astring * name; /* full name */
+ astring name; /* full name */
UINT8 typesize; /* size of the raw data type */
UINT32 typecount; /* number of items */
UINT32 offset; /* offset within the final structure */
@@ -229,7 +229,7 @@ void state_save_register_memory(running_machine *machine, const char *module, co
{
state_private *global = machine->state_data;
state_entry **entryptr, *next;
- astring *totalname;
+ astring totalname;
assert(valsize == 1 || valsize == 2 || valsize == 4 || valsize == 8);
@@ -244,23 +244,22 @@ void state_save_register_memory(running_machine *machine, const char *module, co
}
/* create the full name */
- totalname = auto_astring_alloc(machine);
if (tag != NULL)
- astring_printf(totalname, "%s/%s/%X/%s", module, tag, index, name);
+ totalname.printf("%s/%s/%X/%s", module, tag, index, name);
else
- astring_printf(totalname, "%s/%X/%s", module, index, name);
+ totalname.printf("%s/%X/%s", module, index, name);
/* look for duplicates and an entry to insert in front of */
for (entryptr = &global->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next)
{
/* stop if the next guy's string is greater than ours */
- int cmpval = astring_cmp((*entryptr)->name, totalname);
+ int cmpval = (*entryptr)->name.cmp(totalname);
if (cmpval > 0)
break;
/* error if we are equal */
if (cmpval == 0)
- fatalerror("Duplicate save state registration entry (%s)", astring_c(totalname));
+ fatalerror("Duplicate save state registration entry (%s)", totalname.cstr());
}
/* didn't find one; allocate a new one */
@@ -375,7 +374,7 @@ static UINT32 get_signature(running_machine *machine)
UINT32 temp[2];
/* add the entry name to the CRC */
- crc = crc32(crc, (UINT8 *)astring_c(entry->name), astring_len(entry->name));
+ crc = crc32(crc, (UINT8 *)entry->name.cstr(), entry->name.len());
/* add the type and size to the CRC */
temp[0] = LITTLE_ENDIANIZE_INT32(entry->typecount);
@@ -590,7 +589,7 @@ const char *state_save_get_indexed_item(running_machine *machine, int index, voi
*valsize = ss->typesize;
if (valcount != NULL)
*valcount = ss->typecount;
- return astring_c(ss->name);
+ return ss->name;
}
return NULL;
@@ -608,6 +607,6 @@ void state_save_dump_registry(running_machine *machine)
state_entry *entry;
for (entry = global->entrylist; entry; entry=entry->next)
- LOG(("%s: %d x %d\n", astring_c(entry->name), entry->typesize, entry->typecount));
+ LOG(("%s: %d x %d\n", entry->name.cstr(), entry->typesize, entry->typecount));
}
diff --git a/src/emu/ui.c b/src/emu/ui.c
index 04daa3c9c21..db385e93171 100644
--- a/src/emu/ui.c
+++ b/src/emu/ui.c
@@ -70,7 +70,7 @@ static int show_profiler;
static osd_ticks_t popup_text_end;
/* messagebox buffer */
-static astring *messagebox_text;
+static astring messagebox_text;
static rgb_t messagebox_backcolor;
/* slider info */
@@ -86,8 +86,8 @@ static slider_state *slider_current;
static void ui_exit(running_machine *machine);
/* text generators */
-static astring *disclaimer_string(running_machine *machine, astring *buffer);
-static astring *warnings_string(running_machine *machine, astring *buffer);
+static astring &disclaimer_string(running_machine *machine, astring &buffer);
+static astring &warnings_string(running_machine *machine, astring &buffer);
/* UI handlers */
static UINT32 handler_messagebox(running_machine *machine, UINT32 state);
@@ -198,7 +198,6 @@ int ui_init(running_machine *machine)
/* allocate the font and messagebox string */
ui_font = render_font_alloc("ui.bdf");
- messagebox_text = astring_alloc();
/* initialize the other UI bits */
ui_menu_init(machine);
@@ -221,11 +220,6 @@ static void ui_exit(running_machine *machine)
if (ui_font != NULL)
render_font_free(ui_font);
ui_font = NULL;
-
- /* free the messagebox string */
- if (messagebox_text != NULL)
- astring_free(messagebox_text);
- messagebox_text = NULL;
}
@@ -265,12 +259,12 @@ int ui_display_startup_screens(running_machine *machine, int first_time, int sho
switch (state)
{
case 0:
- if (show_disclaimer && astring_len(disclaimer_string(machine, messagebox_text)) > 0)
+ if (show_disclaimer && disclaimer_string(machine, messagebox_text).len() > 0)
ui_set_handler(handler_messagebox_ok, 0);
break;
case 1:
- if (show_warnings && astring_len(warnings_string(machine, messagebox_text)) > 0)
+ if (show_warnings && warnings_string(machine, messagebox_text).len() > 0)
{
ui_set_handler(handler_messagebox_ok, 0);
if (machine->gamedrv->flags & (GAME_WRONG_COLORS | GAME_IMPERFECT_COLORS | GAME_REQUIRES_ARTWORK | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NO_SOUND))
@@ -281,7 +275,7 @@ int ui_display_startup_screens(running_machine *machine, int first_time, int sho
break;
case 2:
- if (show_gameinfo && astring_len(game_info_astring(machine, messagebox_text)) > 0)
+ if (show_gameinfo && game_info_astring(machine, messagebox_text).len() > 0)
ui_set_handler(handler_messagebox_anykey, 0);
break;
#ifdef MESS
@@ -322,7 +316,7 @@ void ui_set_startup_text(running_machine *machine, const char *text, int force)
osd_ticks_t curtime = osd_ticks();
/* copy in the new text */
- astring_cpyc(messagebox_text, text);
+ messagebox_text.cpy(text);
messagebox_backcolor = UI_BACKGROUND_COLOR;
/* don't update more than 4 times/second */
@@ -365,7 +359,7 @@ void ui_update_and_render(running_machine *machine)
/* display any popup messages */
if (osd_ticks() < popup_text_end)
- ui_draw_text_box(astring_c(messagebox_text), JUSTIFY_CENTER, 0.5f, 0.9f, messagebox_backcolor);
+ ui_draw_text_box(messagebox_text, JUSTIFY_CENTER, 0.5f, 0.9f, messagebox_backcolor);
else
popup_text_end = 0;
@@ -737,7 +731,7 @@ void CLIB_DECL ui_popup_time(int seconds, const char *text, ...)
/* extract the text */
va_start(arg,text);
- astring_vprintf(messagebox_text, text, arg);
+ messagebox_text.vprintf(text, arg);
messagebox_backcolor = UI_BACKGROUND_COLOR;
va_end(arg);
@@ -845,11 +839,11 @@ int ui_is_menu_active(void)
text to the given buffer
-------------------------------------------------*/
-static astring *disclaimer_string(running_machine *machine, astring *string)
+static astring &disclaimer_string(running_machine *machine, astring &string)
{
- astring_cpyc(string, "Usage of emulators in conjunction with ROMs you don't own is forbidden by copyright law.\n\n");
- astring_catprintf(string, "IF YOU ARE NOT LEGALLY ENTITLED TO PLAY \"%s\" ON THIS EMULATOR, PRESS ESC.\n\n", machine->gamedrv->description);
- astring_catc(string, "Otherwise, type OK or move the joystick left then right to continue");
+ string.cpy("Usage of emulators in conjunction with ROMs you don't own is forbidden by copyright law.\n\n");
+ string.catprintf("IF YOU ARE NOT LEGALLY ENTITLED TO PLAY \"%s\" ON THIS EMULATOR, PRESS ESC.\n\n", machine->gamedrv->description);
+ string.cat("Otherwise, type OK or move the joystick left then right to continue");
return string;
}
@@ -859,7 +853,7 @@ static astring *disclaimer_string(running_machine *machine, astring *string)
text to the given buffer
-------------------------------------------------*/
-static astring *warnings_string(running_machine *machine, astring *string)
+static astring &warnings_string(running_machine *machine, astring &string)
{
#define WARNING_FLAGS ( GAME_NOT_WORKING | \
GAME_UNEMULATED_PROTECTION | \
@@ -872,7 +866,7 @@ static astring *warnings_string(running_machine *machine, astring *string)
GAME_NO_COCKTAIL)
int i;
- astring_reset(string);
+ string.reset();
/* if no warnings, nothing to return */
if (rom_load_warnings(machine) == 0 && !(machine->gamedrv->flags & WARNING_FLAGS))
@@ -881,37 +875,37 @@ static astring *warnings_string(running_machine *machine, astring *string)
/* add a warning if any ROMs were loaded with warnings */
if (rom_load_warnings(machine) > 0)
{
- astring_catc(string, "One or more ROMs/CHDs for this game are incorrect. The " GAMENOUN " may not run correctly.\n");
+ string.cat("One or more ROMs/CHDs for this game are incorrect. The " GAMENOUN " may not run correctly.\n");
if (machine->gamedrv->flags & WARNING_FLAGS)
- astring_catc(string, "\n");
+ string.cat("\n");
}
/* if we have at least one warning flag, print the general header */
if (machine->gamedrv->flags & WARNING_FLAGS)
{
- astring_catc(string, "There are known problems with this " GAMENOUN "\n\n");
+ string.cat("There are known problems with this " GAMENOUN "\n\n");
/* add one line per warning flag */
#ifdef MESS
if (machine->gamedrv->flags & GAME_COMPUTER)
- astring_catc(string, "The emulated system is a computer:\n\nThe keyboard emulation may not be 100% accurate.\n");
+ string.cat("The emulated system is a computer:\n\nThe keyboard emulation may not be 100% accurate.\n");
#endif
if (machine->gamedrv->flags & GAME_IMPERFECT_COLORS)
- astring_catc(string, "The colors aren't 100% accurate.\n");
+ string.cat("The colors aren't 100% accurate.\n");
if (machine->gamedrv->flags & GAME_WRONG_COLORS)
- astring_catc(string, "The colors are completely wrong.\n");
+ string.cat("The colors are completely wrong.\n");
if (machine->gamedrv->flags & GAME_IMPERFECT_GRAPHICS)
- astring_catc(string, "The video emulation isn't 100% accurate.\n");
+ string.cat("The video emulation isn't 100% accurate.\n");
if (machine->gamedrv->flags & GAME_IMPERFECT_SOUND)
- astring_catc(string, "The sound emulation isn't 100% accurate.\n");
+ string.cat("The sound emulation isn't 100% accurate.\n");
if (machine->gamedrv->flags & GAME_NO_SOUND)
- astring_catc(string, "The game lacks sound.\n");
+ string.cat("The game lacks sound.\n");
if (machine->gamedrv->flags & GAME_NO_COCKTAIL)
- astring_catc(string, "Screen flipping in cocktail mode is not supported.\n");
+ string.cat("Screen flipping in cocktail mode is not supported.\n");
/* check if external artwork is present before displaying this warning? */
if (machine->gamedrv->flags & GAME_REQUIRES_ARTWORK)
- astring_catc(string, "The game requires external artwork files\n");
+ string.cat("The game requires external artwork files\n");
/* if there's a NOT WORKING or UNEMULATED PROTECTION warning, make it stronger */
if (machine->gamedrv->flags & (GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION))
@@ -922,9 +916,9 @@ static astring *warnings_string(running_machine *machine, astring *string)
/* add the strings for these warnings */
if (machine->gamedrv->flags & GAME_UNEMULATED_PROTECTION)
- astring_catc(string, "The game has protection which isn't fully emulated.\n");
+ string.cat("The game has protection which isn't fully emulated.\n");
if (machine->gamedrv->flags & GAME_NOT_WORKING)
- astring_catc(string, "THIS " CAPGAMENOUN " DOESN'T WORK. The emulation for this game is not yet complete. "
+ string.cat("THIS " CAPGAMENOUN " DOESN'T WORK. The emulation for this game is not yet complete. "
"There is nothing you can do to fix this problem except wait for the developers to improve the emulation.\n");
/* find the parent of this driver */
@@ -942,20 +936,20 @@ static astring *warnings_string(running_machine *machine, astring *string)
{
/* this one works, add a header and display the name of the clone */
if (!foundworking)
- astring_catc(string, "\n\nThere are working clones of this game: ");
+ string.cat("\n\nThere are working clones of this game: ");
else
- astring_catc(string, ", ");
- astring_catc(string, drivers[i]->name);
+ string.cat(", ");
+ string.cat(drivers[i]->name);
foundworking = TRUE;
}
if (foundworking)
- astring_catc(string, "\n");
+ string.cat("\n");
}
}
/* add the 'press OK' string */
- astring_catc(string, "\n\nType OK or move the joystick left then right to continue");
+ string.cat("\n\nType OK or move the joystick left then right to continue");
return string;
}
@@ -965,7 +959,7 @@ static astring *warnings_string(running_machine *machine, astring *string)
string with the game info text
-------------------------------------------------*/
-astring *game_info_astring(running_machine *machine, astring *string)
+astring &game_info_astring(running_machine *machine, astring &string)
{
int scrcount = video_screen_count(machine->config);
const device_config *scandevice;
@@ -974,7 +968,7 @@ astring *game_info_astring(running_machine *machine, astring *string)
int count;
/* print description, manufacturer, and CPU: */
- astring_printf(string, "%s\n%s %s\n\nCPU:\n", machine->gamedrv->description, machine->gamedrv->year, machine->gamedrv->manufacturer);
+ string.printf("%s\n%s %s\n\nCPU:\n", machine->gamedrv->description, machine->gamedrv->year, machine->gamedrv->manufacturer);
/* loop over all CPUs */
for (device = machine->firstcpu; device != NULL; device = scandevice)
@@ -993,14 +987,14 @@ astring *game_info_astring(running_machine *machine, astring *string)
/* if more than one, prepend a #x in front of the CPU name */
if (count > 1)
- astring_catprintf(string, "%d" UTF8_MULTIPLY, count);
- astring_catc(string, cpu_get_name(device));
+ string.catprintf("%d" UTF8_MULTIPLY, count);
+ string.cat(cpu_get_name(device));
/* display clock in kHz or MHz */
if (clock >= 1000000)
- astring_catprintf(string, " %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
+ string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
else
- astring_catprintf(string, " %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
+ string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
}
/* loop over all sound chips */
@@ -1008,7 +1002,7 @@ astring *game_info_astring(running_machine *machine, astring *string)
{
/* append the Sound: string */
if (!found_sound)
- astring_catc(string, "\nSound:\n");
+ string.cat("\nSound:\n");
found_sound = TRUE;
/* count how many identical sound chips we have */
@@ -1022,22 +1016,22 @@ astring *game_info_astring(running_machine *machine, astring *string)
/* if more than one, prepend a #x in front of the CPU name */
if (count > 1)
- astring_catprintf(string, "%d" UTF8_MULTIPLY, count);
- astring_catc(string, device_get_name(device));
+ string.catprintf("%d" UTF8_MULTIPLY, count);
+ string.cat(device_get_name(device));
/* display clock in kHz or MHz */
if (device->clock >= 1000000)
- astring_catprintf(string, " %d.%06d" UTF8_NBSP "MHz\n", device->clock / 1000000, device->clock % 1000000);
+ string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", device->clock / 1000000, device->clock % 1000000);
else if (device->clock != 0)
- astring_catprintf(string, " %d.%03d" UTF8_NBSP "kHz\n", device->clock / 1000, device->clock % 1000);
+ string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", device->clock / 1000, device->clock % 1000);
else
- astring_catc(string, "\n");
+ string.cat("\n");
}
/* display screen information */
- astring_catc(string, "\nVideo:\n");
+ string.cat("\nVideo:\n");
if (scrcount == 0)
- astring_catc(string, "None\n");
+ string.cat("None\n");
else
{
const device_config *screen;
@@ -1048,17 +1042,17 @@ astring *game_info_astring(running_machine *machine, astring *string)
if (scrcount > 1)
{
- astring_catc(string, slider_get_screen_desc(screen));
- astring_catc(string, ": ");
+ string.cat(slider_get_screen_desc(screen));
+ string.cat(": ");
}
if (scrconfig->type == SCREEN_TYPE_VECTOR)
- astring_catc(string, "Vector\n");
+ string.cat("Vector\n");
else
{
const rectangle *visarea = video_screen_get_visible_area(screen);
- astring_catprintf(string, "%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n",
+ string.catprintf("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n",
visarea->max_x - visarea->min_x + 1,
visarea->max_y - visarea->min_y + 1,
(machine->gamedrv->flags & ORIENTATION_SWAP_XY) ? "V" : "H",
@@ -1083,7 +1077,7 @@ astring *game_info_astring(running_machine *machine, astring *string)
static UINT32 handler_messagebox(running_machine *machine, UINT32 state)
{
- ui_draw_text_box(astring_c(messagebox_text), JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
+ ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
return 0;
}
@@ -1096,7 +1090,7 @@ static UINT32 handler_messagebox(running_machine *machine, UINT32 state)
static UINT32 handler_messagebox_ok(running_machine *machine, UINT32 state)
{
/* draw a standard message window */
- ui_draw_text_box(astring_c(messagebox_text), JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
+ ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
/* an 'O' or left joystick kicks us to the next state */
if (state == 0 && (input_code_pressed_once(machine, KEYCODE_O) || ui_input_pressed(machine, IPT_UI_LEFT)))
@@ -1126,7 +1120,7 @@ static UINT32 handler_messagebox_ok(running_machine *machine, UINT32 state)
static UINT32 handler_messagebox_anykey(running_machine *machine, UINT32 state)
{
/* draw a standard message window */
- ui_draw_text_box(astring_c(messagebox_text), JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
+ ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor);
/* if the user cancels, exit out completely */
if (ui_input_pressed(machine, IPT_UI_CANCEL))
@@ -1164,9 +1158,9 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
/* draw the profiler if visible */
if (show_profiler)
{
- astring *profilertext = profiler_get_text(machine, astring_alloc());
- ui_draw_text_full(astring_c(profilertext), 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
- astring_free(profilertext);
+ astring profilertext;
+ profiler_get_text(machine, profilertext);
+ ui_draw_text_full(profilertext, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
}
/* if we're single-stepping, pause now */
@@ -1425,7 +1419,7 @@ static slider_state *slider_init(running_machine *machine)
const device_config *device;
slider_state *listhead = NULL;
slider_state **tailptr = &listhead;
- astring *string = astring_alloc();
+ astring string;
int numitems, item;
/* add overall volume */
@@ -1442,8 +1436,8 @@ static slider_state *slider_init(running_machine *machine)
if (defval > 1000)
maxval = 2 * defval;
- astring_printf(string, "%s Volume", sound_get_user_gain_name(machine, item));
- *tailptr = slider_alloc(machine, astring_c(string), 0, defval, maxval, 20, slider_mixervol, (void *)(FPTR)item);
+ string.printf("%s Volume", sound_get_user_gain_name(machine, item));
+ *tailptr = slider_alloc(machine, string, 0, defval, maxval, 20, slider_mixervol, (void *)(FPTR)item);
tailptr = &(*tailptr)->next;
}
@@ -1463,8 +1457,8 @@ static slider_state *slider_init(running_machine *machine)
for (device = machine->firstcpu; device != NULL; device = cpu_next(device))
{
void *param = (void *)device;
- astring_printf(string, "Overclock CPU %s", device->tag);
- *tailptr = slider_alloc(machine, astring_c(string), 10, 1000, 2000, 1, slider_overclock, param);
+ string.printf("Overclock CPU %s", device->tag);
+ *tailptr = slider_alloc(machine, string, 10, 1000, 2000, 1, slider_overclock, param);
tailptr = &(*tailptr)->next;
}
}
@@ -1482,34 +1476,34 @@ static slider_state *slider_init(running_machine *machine)
/* add refresh rate tweaker */
if (options_get_bool(mame_options(), OPTION_CHEAT))
{
- astring_printf(string, "%s Refresh Rate", slider_get_screen_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), -10000, 0, 10000, 1000, slider_refresh, param);
+ string.printf("%s Refresh Rate", slider_get_screen_desc(device));
+ *tailptr = slider_alloc(machine, string, -10000, 0, 10000, 1000, slider_refresh, param);
tailptr = &(*tailptr)->next;
}
/* add standard brightness/contrast/gamma controls per-screen */
- astring_printf(string, "%s Brightness", slider_get_screen_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), 100, 1000, 2000, 10, slider_brightness, param);
+ string.printf("%s Brightness", slider_get_screen_desc(device));
+ *tailptr = slider_alloc(machine, string, 100, 1000, 2000, 10, slider_brightness, param);
tailptr = &(*tailptr)->next;
- astring_printf(string, "%s Contrast", slider_get_screen_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), 100, 1000, 2000, 50, slider_contrast, param);
+ string.printf("%s Contrast", slider_get_screen_desc(device));
+ *tailptr = slider_alloc(machine, string, 100, 1000, 2000, 50, slider_contrast, param);
tailptr = &(*tailptr)->next;
- astring_printf(string, "%s Gamma", slider_get_screen_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), 100, 1000, 3000, 50, slider_gamma, param);
+ string.printf("%s Gamma", slider_get_screen_desc(device));
+ *tailptr = slider_alloc(machine, string, 100, 1000, 3000, 50, slider_gamma, param);
tailptr = &(*tailptr)->next;
/* add scale and offset controls per-screen */
- astring_printf(string, "%s Horiz Stretch", slider_get_screen_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_xscale, param);
+ string.printf("%s Horiz Stretch", slider_get_screen_desc(device));
+ *tailptr = slider_alloc(machine, string, 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_xscale, param);
tailptr = &(*tailptr)->next;
- astring_printf(string, "%s Horiz Position", slider_get_screen_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), -500, defxoffset, 500, 2, slider_xoffset, param);
+ string.printf("%s Horiz Position", slider_get_screen_desc(device));
+ *tailptr = slider_alloc(machine, string, -500, defxoffset, 500, 2, slider_xoffset, param);
tailptr = &(*tailptr)->next;
- astring_printf(string, "%s Vert Stretch", slider_get_screen_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_yscale, param);
+ string.printf("%s Vert Stretch", slider_get_screen_desc(device));
+ *tailptr = slider_alloc(machine, string, 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_yscale, param);
tailptr = &(*tailptr)->next;
- astring_printf(string, "%s Vert Position", slider_get_screen_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), -500, defyoffset, 500, 2, slider_yoffset, param);
+ string.printf("%s Vert Position", slider_get_screen_desc(device));
+ *tailptr = slider_alloc(machine, string, -500, defyoffset, 500, 2, slider_yoffset, param);
tailptr = &(*tailptr)->next;
}
@@ -1525,17 +1519,17 @@ static slider_state *slider_init(running_machine *machine)
void *param = (void *)device;
/* add scale and offset controls per-overlay */
- astring_printf(string, "%s Horiz Stretch", slider_get_laserdisc_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_overxscale, param);
+ string.printf("%s Horiz Stretch", slider_get_laserdisc_desc(device));
+ *tailptr = slider_alloc(machine, string, 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_overxscale, param);
tailptr = &(*tailptr)->next;
- astring_printf(string, "%s Horiz Position", slider_get_laserdisc_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), -500, defxoffset, 500, 2, slider_overxoffset, param);
+ string.printf("%s Horiz Position", slider_get_laserdisc_desc(device));
+ *tailptr = slider_alloc(machine, string, -500, defxoffset, 500, 2, slider_overxoffset, param);
tailptr = &(*tailptr)->next;
- astring_printf(string, "%s Vert Stretch", slider_get_laserdisc_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_overyscale, param);
+ string.printf("%s Vert Stretch", slider_get_laserdisc_desc(device));
+ *tailptr = slider_alloc(machine, string, 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_overyscale, param);
tailptr = &(*tailptr)->next;
- astring_printf(string, "%s Vert Position", slider_get_laserdisc_desc(device));
- *tailptr = slider_alloc(machine, astring_c(string), -500, defyoffset, 500, 2, slider_overyoffset, param);
+ string.printf("%s Vert Position", slider_get_laserdisc_desc(device));
+ *tailptr = slider_alloc(machine, string, -500, defyoffset, 500, 2, slider_overyoffset, param);
tailptr = &(*tailptr)->next;
}
}
@@ -1561,16 +1555,15 @@ static slider_state *slider_init(running_machine *machine)
if (field->crossaxis != CROSSHAIR_AXIS_NONE && field->player == 0)
{
void *param = (void *)field;
- astring_printf(string, "Crosshair Scale %s", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y");
- *tailptr = slider_alloc(machine, astring_c(string), -3000, 1000, 3000, 100, slider_crossscale, param);
+ string.printf("Crosshair Scale %s", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y");
+ *tailptr = slider_alloc(machine, string, -3000, 1000, 3000, 100, slider_crossscale, param);
tailptr = &(*tailptr)->next;
- astring_printf(string, "Crosshair Offset %s", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y");
- *tailptr = slider_alloc(machine, astring_c(string), -3000, 0, 3000, 100, slider_crossoffset, param);
+ string.printf("Crosshair Offset %s", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y");
+ *tailptr = slider_alloc(machine, string, -3000, 0, 3000, 100, slider_crossoffset, param);
tailptr = &(*tailptr)->next;
}
#endif
- astring_free(string);
return listhead;
}
@@ -1584,7 +1577,7 @@ static INT32 slider_volume(running_machine *machine, void *arg, astring *string,
if (newval != SLIDER_NOCHANGE)
sound_set_attenuation(machine, newval);
if (string != NULL)
- astring_printf(string, "%3ddB", sound_get_attenuation(machine));
+ string->printf("%3ddB", sound_get_attenuation(machine));
return sound_get_attenuation(machine);
}
@@ -1600,7 +1593,7 @@ static INT32 slider_mixervol(running_machine *machine, void *arg, astring *strin
if (newval != SLIDER_NOCHANGE)
sound_set_user_gain(machine, which, (float)newval * 0.001f);
if (string != NULL)
- astring_printf(string, "%4.2f", sound_get_user_gain(machine, which));
+ string->printf("%4.2f", sound_get_user_gain(machine, which));
return floor(sound_get_user_gain(machine, which) * 1000.0f + 0.5f);
}
@@ -1622,7 +1615,7 @@ static INT32 slider_adjuster(running_machine *machine, void *arg, astring *strin
input_field_set_user_settings(field, &settings);
}
if (string != NULL)
- astring_printf(string, "%d%%", settings.value);
+ string->printf("%d%%", settings.value);
return settings.value;
}
@@ -1638,7 +1631,7 @@ static INT32 slider_overclock(running_machine *machine, void *arg, astring *stri
if (newval != SLIDER_NOCHANGE)
cpu_set_clockscale(cpu, (float)newval * 0.001f);
if (string != NULL)
- astring_printf(string, "%3.0f%%", floor(cpu_get_clockscale(cpu) * 100.0f + 0.5f));
+ string->printf("%3.0f%%", floor(cpu_get_clockscale(cpu) * 100.0f + 0.5f));
return floor(cpu_get_clockscale(cpu) * 1000.0f + 0.5f);
}
@@ -1663,7 +1656,7 @@ static INT32 slider_refresh(running_machine *machine, void *arg, astring *string
video_screen_configure(screen, width, height, visarea, HZ_TO_ATTOSECONDS(defrefresh + (double)newval * 0.001));
}
if (string != NULL)
- astring_printf(string, "%.3ffps", ATTOSECONDS_TO_HZ(video_screen_get_frame_period(machine->primary_screen).attoseconds));
+ string->printf("%.3ffps", ATTOSECONDS_TO_HZ(video_screen_get_frame_period(machine->primary_screen).attoseconds));
refresh = ATTOSECONDS_TO_HZ(video_screen_get_frame_period(machine->primary_screen).attoseconds);
return floor((refresh - defrefresh) * 1000.0f + 0.5f);
}
@@ -1687,7 +1680,7 @@ static INT32 slider_brightness(running_machine *machine, void *arg, astring *str
render_container_set_user_settings(container, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.brightness);
+ string->printf("%.3f", settings.brightness);
return floor(settings.brightness * 1000.0f + 0.5f);
}
@@ -1710,7 +1703,7 @@ static INT32 slider_contrast(running_machine *machine, void *arg, astring *strin
render_container_set_user_settings(container, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.contrast);
+ string->printf("%.3f", settings.contrast);
return floor(settings.contrast * 1000.0f + 0.5f);
}
@@ -1732,7 +1725,7 @@ static INT32 slider_gamma(running_machine *machine, void *arg, astring *string,
render_container_set_user_settings(container, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.gamma);
+ string->printf("%.3f", settings.gamma);
return floor(settings.gamma * 1000.0f + 0.5f);
}
@@ -1755,7 +1748,7 @@ static INT32 slider_xscale(running_machine *machine, void *arg, astring *string,
render_container_set_user_settings(container, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.xscale);
+ string->printf("%.3f", settings.xscale);
return floor(settings.xscale * 1000.0f + 0.5f);
}
@@ -1778,7 +1771,7 @@ static INT32 slider_yscale(running_machine *machine, void *arg, astring *string,
render_container_set_user_settings(container, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.yscale);
+ string->printf("%.3f", settings.yscale);
return floor(settings.yscale * 1000.0f + 0.5f);
}
@@ -1801,7 +1794,7 @@ static INT32 slider_xoffset(running_machine *machine, void *arg, astring *string
render_container_set_user_settings(container, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.xoffset);
+ string->printf("%.3f", settings.xoffset);
return floor(settings.xoffset * 1000.0f + 0.5f);
}
@@ -1824,7 +1817,7 @@ static INT32 slider_yoffset(running_machine *machine, void *arg, astring *string
render_container_set_user_settings(container, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.yoffset);
+ string->printf("%.3f", settings.yoffset);
return floor(settings.yoffset * 1000.0f + 0.5f);
}
@@ -1846,7 +1839,7 @@ static INT32 slider_overxscale(running_machine *machine, void *arg, astring *str
laserdisc_set_config(laserdisc, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.overscalex);
+ string->printf("%.3f", settings.overscalex);
return floor(settings.overscalex * 1000.0f + 0.5f);
}
@@ -1868,7 +1861,7 @@ static INT32 slider_overyscale(running_machine *machine, void *arg, astring *str
laserdisc_set_config(laserdisc, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.overscaley);
+ string->printf("%.3f", settings.overscaley);
return floor(settings.overscaley * 1000.0f + 0.5f);
}
@@ -1890,7 +1883,7 @@ static INT32 slider_overxoffset(running_machine *machine, void *arg, astring *st
laserdisc_set_config(laserdisc, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.overposx);
+ string->printf("%.3f", settings.overposx);
return floor(settings.overposx * 1000.0f + 0.5f);
}
@@ -1912,7 +1905,7 @@ static INT32 slider_overyoffset(running_machine *machine, void *arg, astring *st
laserdisc_set_config(laserdisc, &settings);
}
if (string != NULL)
- astring_printf(string, "%.3f", settings.overposy);
+ string->printf("%.3f", settings.overposy);
return floor(settings.overposy * 1000.0f + 0.5f);
}
@@ -1927,7 +1920,7 @@ static INT32 slider_flicker(running_machine *machine, void *arg, astring *string
if (newval != SLIDER_NOCHANGE)
vector_set_flicker((float)newval * 0.1f);
if (string != NULL)
- astring_printf(string, "%1.2f", vector_get_flicker());
+ string->printf("%1.2f", vector_get_flicker());
return floor(vector_get_flicker() * 10.0f + 0.5f);
}
@@ -1942,7 +1935,7 @@ static INT32 slider_beam(running_machine *machine, void *arg, astring *string, I
if (newval != SLIDER_NOCHANGE)
vector_set_beam((float)newval * 0.01f);
if (string != NULL)
- astring_printf(string, "%1.2f", vector_get_beam());
+ string->printf("%1.2f", vector_get_beam());
return floor(vector_get_beam() * 100.0f + 0.5f);
}
@@ -1998,7 +1991,7 @@ static INT32 slider_crossscale(running_machine *machine, void *arg, astring *str
if (newval != SLIDER_NOCHANGE)
field->crossscale = (float)newval * 0.001f;
if (string != NULL)
- astring_printf(string, "%s %s %1.3f", "Crosshair Scale", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f);
+ string->printf("%s %s %1.3f", "Crosshair Scale", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f);
return floor(field->crossscale * 1000.0f + 0.5f);
}
#endif
@@ -2017,7 +2010,7 @@ static INT32 slider_crossoffset(running_machine *machine, void *arg, astring *st
if (newval != SLIDER_NOCHANGE)
field->crossoffset = (float)newval * 0.001f;
if (string != NULL)
- astring_printf(string, "%s %s %1.3f", "Crosshair Offset", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f);
+ string->printf("%s %s %1.3f", "Crosshair Offset", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f);
return field->crossoffset;
}
#endif
diff --git a/src/emu/ui.h b/src/emu/ui.h
index 153ca711a4d..1ab46256d0c 100644
--- a/src/emu/ui.h
+++ b/src/emu/ui.h
@@ -175,7 +175,7 @@ void ui_show_menu(void);
int ui_is_menu_active(void);
/* print the game info string into a buffer */
-astring *game_info_astring(running_machine *machine, astring *string);
+astring &game_info_astring(running_machine *machine, astring &string);
/* get the list of sliders */
const slider_state *ui_get_slider_list(void);
diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c
index d804f9b5850..93790edbc71 100644
--- a/src/emu/uimenu.c
+++ b/src/emu/uimenu.c
@@ -1587,10 +1587,10 @@ static void menu_input_general(running_machine *machine, ui_menu *menu, void *pa
static void menu_input_general_populate(running_machine *machine, ui_menu *menu, input_menu_state *menustate, int group)
{
- astring *tempstring = astring_alloc();
input_item_data *itemlist = NULL;
const input_type_desc *typedesc;
int suborder[SEQ_TYPE_TOTAL];
+ astring tempstring;
int sortorder = 1;
/* create a mini lookup table for sort order based on sequence type */
@@ -1631,7 +1631,6 @@ static void menu_input_general_populate(running_machine *machine, ui_menu *menu,
/* sort and populate the menu in a standard fashion */
menu_input_populate_and_sort(machine, menu, itemlist, menustate);
- astring_free(tempstring);
}
@@ -1653,11 +1652,11 @@ static void menu_input_specific(running_machine *machine, ui_menu *menu, void *p
static void menu_input_specific_populate(running_machine *machine, ui_menu *menu, input_menu_state *menustate)
{
- astring *tempstring = astring_alloc();
input_item_data *itemlist = NULL;
const input_field_config *field;
const input_port_config *port;
int suborder[SEQ_TYPE_TOTAL];
+ astring tempstring;
/* create a mini lookup table for sort order based on sequence type */
suborder[SEQ_TYPE_STANDARD] = 0;
@@ -1711,7 +1710,6 @@ static void menu_input_specific_populate(running_machine *machine, ui_menu *menu
/* sort and populate the menu in a standard fashion */
menu_input_populate_and_sort(machine, menu, itemlist, menustate);
- astring_free(tempstring);
}
@@ -1859,9 +1857,9 @@ static void menu_input_populate_and_sort(running_machine *machine, ui_menu *menu
{
const char *nameformat[INPUT_TYPE_TOTAL] = { 0 };
input_item_data **itemarray, *item;
- astring *subtext = astring_alloc();
- astring *text = astring_alloc();
int numitems = 0, curitem;
+ astring subtext;
+ astring text;
/* create a mini lookup table for name format based on type */
nameformat[INPUT_TYPE_DIGITAL] = "%s";
@@ -1889,12 +1887,12 @@ static void menu_input_populate_and_sort(running_machine *machine, ui_menu *menu
/* generate the name of the item itself, based off the base name and the type */
item = itemarray[curitem];
assert(nameformat[item->type] != NULL);
- astring_printf(text, nameformat[item->type], item->name);
+ text.printf(nameformat[item->type], item->name);
/* if we're polling this item, use some spaces with left/right arrows */
if (menustate->pollingref == item->ref)
{
- astring_cpyc(subtext, " ");
+ subtext.cpy(" ");
flags |= MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW;
}
@@ -1906,12 +1904,8 @@ static void menu_input_populate_and_sort(running_machine *machine, ui_menu *menu
}
/* add the item */
- ui_menu_item_append(menu, astring_c(text), astring_c(subtext), flags, item);
+ ui_menu_item_append(menu, text, subtext, flags, item);
}
-
- /* free our temporary strings */
- astring_free(subtext);
- astring_free(text);
}
@@ -2271,10 +2265,10 @@ static void menu_analog(running_machine *machine, ui_menu *menu, void *parameter
static void menu_analog_populate(running_machine *machine, ui_menu *menu)
{
- astring *subtext = astring_alloc();
- astring *text = astring_alloc();
const input_field_config *field;
const input_port_config *port;
+ astring subtext;
+ astring text;
/* loop over input ports and add the items */
for (port = machine->portlist.head; port != NULL; port = port->next)
@@ -2325,8 +2319,8 @@ static void menu_analog_populate(running_machine *machine, ui_menu *menu)
{
default:
case ANALOG_ITEM_KEYSPEED:
- astring_printf(text, "%s Digital Speed", input_field_name(field));
- astring_printf(subtext, "%d", settings.delta);
+ text.printf("%s Digital Speed", input_field_name(field));
+ subtext.printf("%d", settings.delta);
data->min = 0;
data->max = 255;
data->cur = settings.delta;
@@ -2334,8 +2328,8 @@ static void menu_analog_populate(running_machine *machine, ui_menu *menu)
break;
case ANALOG_ITEM_CENTERSPEED:
- astring_printf(text, "%s Autocenter Speed", input_field_name(field));
- astring_printf(subtext, "%d", settings.centerdelta);
+ text.printf("%s Autocenter Speed", input_field_name(field));
+ subtext.printf("%d", settings.centerdelta);
data->min = 0;
data->max = 255;
data->cur = settings.centerdelta;
@@ -2343,8 +2337,8 @@ static void menu_analog_populate(running_machine *machine, ui_menu *menu)
break;
case ANALOG_ITEM_REVERSE:
- astring_printf(text, "%s Reverse", input_field_name(field));
- astring_cpyc(subtext, settings.reverse ? "On" : "Off");
+ text.printf("%s Reverse", input_field_name(field));
+ subtext.cpy(settings.reverse ? "On" : "Off");
data->min = 0;
data->max = 1;
data->cur = settings.reverse;
@@ -2352,8 +2346,8 @@ static void menu_analog_populate(running_machine *machine, ui_menu *menu)
break;
case ANALOG_ITEM_SENSITIVITY:
- astring_printf(text, "%s Sensitivity", input_field_name(field));
- astring_printf(subtext, "%d", settings.sensitivity);
+ text.printf("%s Sensitivity", input_field_name(field));
+ subtext.printf("%d", settings.sensitivity);
data->min = 1;
data->max = 255;
data->cur = settings.sensitivity;
@@ -2368,13 +2362,9 @@ static void menu_analog_populate(running_machine *machine, ui_menu *menu)
flags |= MENU_FLAG_RIGHT_ARROW;
/* append a menu item */
- ui_menu_item_append(menu, astring_c(text), astring_c(subtext), flags, data);
+ ui_menu_item_append(menu, text, subtext, flags, data);
}
}
-
- /* release our temporary strings */
- astring_free(subtext);
- astring_free(text);
}
@@ -2418,18 +2408,18 @@ static void menu_bookkeeping(running_machine *machine, ui_menu *menu, void *para
static void menu_bookkeeping_populate(running_machine *machine, ui_menu *menu, attotime *curtime)
{
int tickets = get_dispensed_tickets(machine);
- astring *tempstring = astring_alloc();
+ astring tempstring;
int ctrnum;
/* show total time first */
if (curtime->seconds >= 60 * 60)
- astring_catprintf(tempstring, "Uptime: %d:%02d:%02d\n\n", curtime->seconds / (60*60), (curtime->seconds / 60) % 60, curtime->seconds % 60);
+ tempstring.catprintf("Uptime: %d:%02d:%02d\n\n", curtime->seconds / (60*60), (curtime->seconds / 60) % 60, curtime->seconds % 60);
else
- astring_catprintf(tempstring, "Uptime: %d:%02d\n\n", (curtime->seconds / 60) % 60, curtime->seconds % 60);
+ tempstring.catprintf("Uptime: %d:%02d\n\n", (curtime->seconds / 60) % 60, curtime->seconds % 60);
/* show tickets at the top */
if (tickets > 0)
- astring_catprintf(tempstring, "Tickets dispensed: %d\n\n", tickets);
+ tempstring.catprintf("Tickets dispensed: %d\n\n", tickets);
/* loop over coin counters */
for (ctrnum = 0; ctrnum < COIN_COUNTERS; ctrnum++)
@@ -2437,23 +2427,22 @@ static void menu_bookkeeping_populate(running_machine *machine, ui_menu *menu, a
int count = coin_counter_get_count(machine, ctrnum);
/* display the coin counter number */
- astring_catprintf(tempstring, "Coin %c: ", ctrnum + 'A');
+ tempstring.catprintf("Coin %c: ", ctrnum + 'A');
/* display how many coins */
if (count == 0)
- astring_catc(tempstring, "NA");
+ tempstring.cat("NA");
else
- astring_catprintf(tempstring, "%d", count);
+ tempstring.catprintf("%d", count);
/* display whether or not we are locked out */
if (coin_lockout_get_state(machine, ctrnum))
- astring_catc(tempstring, " (locked)");
- astring_catc(tempstring, "\n");
+ tempstring.cat(" (locked)");
+ tempstring.cat("\n");
}
/* append the single item */
- ui_menu_item_append(menu, astring_c(tempstring), NULL, MENU_FLAG_MULTILINE, NULL);
- astring_free(tempstring);
+ ui_menu_item_append(menu, tempstring, NULL, MENU_FLAG_MULTILINE, NULL);
}
#endif
@@ -2468,9 +2457,8 @@ static void menu_game_info(running_machine *machine, ui_menu *menu, void *parame
/* if the menu isn't built, populate now */
if (!ui_menu_populated(menu))
{
- astring *tempstring = game_info_astring(machine, astring_alloc());
- ui_menu_item_append(menu, astring_c(tempstring), NULL, MENU_FLAG_MULTILINE, NULL);
- astring_free(tempstring);
+ astring tempstring;
+ ui_menu_item_append(menu, game_info_astring(machine, tempstring), NULL, MENU_FLAG_MULTILINE, NULL);
}
/* process the menu */
@@ -2544,7 +2532,7 @@ static void menu_cheat(running_machine *machine, ui_menu *menu, void *parameter,
case IPT_UI_UP:
case IPT_UI_DOWN:
if (cheat_get_comment(event->itemref) != NULL)
- popmessage("Cheat Comment:\n%s", astring_c(cheat_get_comment(event->itemref)));
+ popmessage("Cheat Comment:\n%s", cheat_get_comment(event->itemref).cstr());
break;
}
}
@@ -2819,26 +2807,25 @@ static void menu_sliders(running_machine *machine, ui_menu *menu, void *paramete
static void menu_sliders_populate(running_machine *machine, ui_menu *menu, int menuless_mode)
{
- astring *tempstring = astring_alloc();
const slider_state *curslider;
+ astring tempstring;
/* add all sliders */
for (curslider = ui_get_slider_list(); curslider != NULL; curslider = curslider->next)
{
- INT32 curval = (*curslider->update)(machine, curslider->arg, tempstring, SLIDER_NOCHANGE);
+ INT32 curval = (*curslider->update)(machine, curslider->arg, &tempstring, SLIDER_NOCHANGE);
UINT32 flags = 0;
if (curval > curslider->minval)
flags |= MENU_FLAG_LEFT_ARROW;
if (curval < curslider->maxval)
flags |= MENU_FLAG_RIGHT_ARROW;
- ui_menu_item_append(menu, curslider->description, astring_c(tempstring), flags, (void *)curslider);
+ ui_menu_item_append(menu, curslider->description, tempstring, flags, (void *)curslider);
if (menuless_mode)
break;
}
ui_menu_set_custom_render(menu, menu_sliders_custom_render, 0.0f, 2.0f * ui_get_line_height() + 2.0f * UI_BOX_TB_BORDER);
- astring_free(tempstring);
}
@@ -2854,21 +2841,20 @@ static void menu_sliders_custom_render(running_machine *machine, ui_menu *menu,
{
float bar_left, bar_area_top, bar_width, bar_area_height, bar_top, bar_bottom, default_x, current_x;
float line_height = ui_get_line_height();
- astring *tempstring = astring_alloc();
float percentage, default_percentage;
+ astring tempstring;
float text_height;
INT32 curval;
/* determine the current value and text */
- curval = (*curslider->update)(machine, curslider->arg, tempstring, SLIDER_NOCHANGE);
+ curval = (*curslider->update)(machine, curslider->arg, &tempstring, SLIDER_NOCHANGE);
/* compute the current and default percentages */
percentage = (float)(curval - curslider->minval) / (float)(curslider->maxval - curslider->minval);
default_percentage = (float)(curslider->defval - curslider->minval) / (float)(curslider->maxval - curslider->minval);
/* assemble the the text */
- astring_insc(tempstring, 0, " ");
- astring_insc(tempstring, 0, curslider->description);
+ tempstring.ins(0, " ").ins(0, curslider->description);
/* move us to the bottom of the screen, and expand to full width */
y2 = 1.0f - UI_BOX_TB_BORDER;
@@ -2881,7 +2867,7 @@ static void menu_sliders_custom_render(running_machine *machine, ui_menu *menu,
y1 += UI_BOX_TB_BORDER;
/* determine the text height */
- ui_draw_text_full(astring_c(tempstring), 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
+ ui_draw_text_full(tempstring, 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, NULL, &text_height);
/* draw the thermometer */
@@ -2908,10 +2894,8 @@ static void menu_sliders_custom_render(running_machine *machine, ui_menu *menu,
render_ui_add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
/* draw the actual text */
- ui_draw_text_full(astring_c(tempstring), x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
+ ui_draw_text_full(tempstring, x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, &text_height);
-
- astring_free(tempstring);
}
}
@@ -3037,8 +3021,8 @@ static void menu_video_options(running_machine *machine, ui_menu *menu, void *pa
static void menu_video_options_populate(running_machine *machine, ui_menu *menu, render_target *target)
{
int layermask = render_target_get_layer_config(target);
- astring *tempstring = astring_alloc();
const char *subtext = "";
+ astring tempstring;
int viewnum;
int enabled;
@@ -3050,8 +3034,8 @@ static void menu_video_options_populate(running_machine *machine, ui_menu *menu,
break;
/* create a string for the item, replacing underscores with spaces */
- astring_replacec(astring_cpyc(tempstring, name), 0, "_", " ");
- ui_menu_item_append(menu, astring_c(tempstring), NULL, 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum));
+ tempstring.cpy(name).replace(0, "_", " ");
+ ui_menu_item_append(menu, tempstring, NULL, 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum));
}
/* add a separator */
@@ -3082,8 +3066,6 @@ static void menu_video_options_populate(running_machine *machine, ui_menu *menu,
/* cropping */
enabled = layermask & LAYER_CONFIG_ZOOM_TO_SCREEN;
ui_menu_item_append(menu, "View", enabled ? "Cropped" : "Full", enabled ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)LAYER_CONFIG_ZOOM_TO_SCREEN);
-
- astring_free(tempstring);
}
diff --git a/src/emu/validity.c b/src/emu/validity.c
index 906b3cf95f0..628f665e6f6 100644
--- a/src/emu/validity.c
+++ b/src/emu/validity.c
@@ -47,17 +47,20 @@ UINT8 your_ptr64_flag_is_wrong[(int)(5 - sizeof(void *))];
TYPE DEFINITIONS
***************************************************************************/
-typedef struct _region_entry region_entry;
-struct _region_entry
+class region_entry
{
- astring *tag;
+public:
+ region_entry()
+ : length(0) { }
+
+ astring tag;
UINT32 length;
};
-typedef struct _region_info region_info;
-struct _region_info
+class region_info
{
+public:
region_entry entries[256];
};
@@ -463,10 +466,11 @@ static int validate_roms(int drivnum, const machine_config *config, region_info
/* find any empty entry, checking for duplicates */
else
{
- astring *fulltag = rom_region_name(astring_alloc(), driver, source, romp);
+ astring fulltag;
int rgnnum;
/* iterate over all regions found so far */
+ rom_region_name(fulltag, driver, source, romp);
for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries); rgnnum++)
{
/* stop when we hit an empty */
@@ -479,11 +483,10 @@ static int validate_roms(int drivnum, const machine_config *config, region_info
}
/* fail if we hit a duplicate */
- if (astring_cmp(fulltag, rgninfo->entries[rgnnum].tag) == 0)
+ if (fulltag.cmp(rgninfo->entries[rgnnum].tag) == 0)
{
- mame_printf_error("%s: %s has duplicate ROM_REGION tag '%s'\n", driver->source_file, driver->name, astring_c(fulltag));
+ mame_printf_error("%s: %s has duplicate ROM_REGION tag '%s'\n", driver->source_file, driver->name, fulltag.cstr());
error = TRUE;
- astring_free(fulltag);
break;
}
}
@@ -746,7 +749,7 @@ static int validate_gfx(int drivnum, const machine_config *config, region_info *
}
/* if we hit a match, check against the length */
- if (astring_cmpc(rgninfo->entries[rgnnum].tag, region) == 0)
+ if (rgninfo->entries[rgnnum].tag.cmp(region) == 0)
{
/* if we have a valid region, and we're not using auto-sizing, check the decode against the region length */
if (!IS_FRAC(total))
@@ -1367,7 +1370,7 @@ static int validate_devices(int drivnum, const machine_config *config, const inp
}
/* if we hit a match, check against the length */
- if (astring_cmpc(rgninfo->entries[rgnnum].tag, entry->region) == 0)
+ if (rgninfo->entries[rgnnum].tag.cmp(entry->region) == 0)
{
offs_t length = rgninfo->entries[rgnnum].length;
if (entry->rgnoffs + (byteend - bytestart + 1) > length)
@@ -1507,12 +1510,10 @@ int mame_validitychecks(const game_driver *curdriver)
input_port_list portlist;
machine_config *config;
region_info rgninfo;
- int rgnnum;
/* non-debug builds only care about games in the same driver */
if (curdriver != NULL && strcmp(curdriver->source_file, driver->source_file) != 0)
continue;
- memset(&rgninfo, 0, sizeof(rgninfo));
/* expand the machine driver */
expansion -= get_profile_ticks();
@@ -1559,9 +1560,6 @@ int mame_validitychecks(const game_driver *curdriver)
error = validate_devices(drivnum, config, &portlist, &rgninfo) || error;
device_checks += get_profile_ticks();
- for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo.entries); rgnnum++)
- if (rgninfo.entries[rgnnum].tag != NULL)
- astring_free(rgninfo.entries[rgnnum].tag);
input_port_list_deinit(&portlist);
machine_config_free(config);
}
diff --git a/src/emu/video.c b/src/emu/video.c
index e82511ade46..5bc7ec1381d 100644
--- a/src/emu/video.c
+++ b/src/emu/video.c
@@ -1957,18 +1957,17 @@ static void recompute_speed(running_machine *machine, attotime emutime)
{
if (machine->primary_screen != NULL)
{
- astring *fname = astring_assemble_2(astring_alloc(), machine->basename, PATH_SEPARATOR "final.png");
+ astring fname(machine->basename, PATH_SEPARATOR "final.png");
file_error filerr;
mame_file *file;
/* create a final screenshot */
- filerr = mame_fopen(SEARCHPATH_SCREENSHOT, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
+ filerr = mame_fopen(SEARCHPATH_SCREENSHOT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
if (filerr == FILERR_NONE)
{
video_screen_save_snapshot(machine, machine->primary_screen, file);
mame_fclose(file);
}
- astring_free(fname);
}
/* schedule our demise */
@@ -2112,30 +2111,29 @@ static void create_snapshot_bitmap(const device_config *screen)
static file_error mame_fopen_next(running_machine *machine, const char *pathoption, const char *extension, mame_file **file)
{
const char *snapname = options_get_string(mame_options(), OPTION_SNAPNAME);
- astring *snapstr = astring_alloc();
- astring *fname = astring_alloc();
file_error filerr;
+ astring snapstr;
+ astring fname;
int index;
/* handle defaults */
if (snapname == NULL || snapname[0] == 0)
snapname = "%g/%i";
- astring_cpyc(snapstr, snapname);
+ snapstr.cpy(snapname);
/* strip any extension in the provided name and add our own */
- index = astring_rchr(snapstr, 0, '.');
+ index = snapstr.rchr(0, '.');
if (index != -1)
- astring_substr(snapstr, 0, index);
- astring_catc(snapstr, ".");
- astring_catc(snapstr, extension);
+ snapstr.substr(0, index);
+ snapstr.cat(".").cat(extension);
/* substitute path and gamename up front */
- astring_replacec(snapstr, 0, "/", PATH_SEPARATOR);
- astring_replacec(snapstr, 0, "%g", machine->basename);
+ snapstr.replace(0, "/", PATH_SEPARATOR);
+ snapstr.replace(0, "%g", machine->basename);
/* determine if the template has an index; if not, we always use the same name */
- if (astring_findc(snapstr, 0, "%i") == -1)
- astring_cpy(fname, snapstr);
+ if (snapstr.find(0, "%i") == -1)
+ snapstr.cpy(snapstr);
/* otherwise, we scan for the next available filename */
else
@@ -2151,11 +2149,10 @@ static file_error mame_fopen_next(running_machine *machine, const char *pathopti
sprintf(seqtext, "%04d", seq);
/* build up the filename */
- astring_cpy(fname, snapstr);
- astring_replacec(fname, 0, "%i", seqtext);
+ fname.cpy(snapstr).replace(0, "%i", seqtext);
/* try to open the file; stop when we fail */
- filerr = mame_fopen(pathoption, astring_c(fname), OPEN_FLAG_READ, file);
+ filerr = mame_fopen(pathoption, fname, OPEN_FLAG_READ, file);
if (filerr != FILERR_NONE)
break;
mame_fclose(*file);
@@ -2163,12 +2160,7 @@ static file_error mame_fopen_next(running_machine *machine, const char *pathopti
}
/* create the final file */
- filerr = mame_fopen(pathoption, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, file);
-
- /* free the name and get out */
- astring_free(fname);
- astring_free(snapstr);
- return filerr;
+ return mame_fopen(pathoption, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, file);
}
@@ -2366,12 +2358,11 @@ void video_avi_begin_recording(running_machine *machine, const char *name)
/* if we succeeded, make a copy of the name and create the real file over top */
if (filerr == FILERR_NONE)
{
- astring *fullname = astring_dupc(mame_file_full_name(tempfile));
+ astring fullname(mame_file_full_name(tempfile));
mame_fclose(tempfile);
/* create the file and free the string */
- avierr = avi_create(astring_c(fullname), &info, &global.avifile);
- astring_free(fullname);
+ avierr = avi_create(fullname, &info, &global.avifile);
}
}
@@ -2545,7 +2536,7 @@ static void video_finalize_burnin(const device_config *screen)
screen_state *state = get_safe_token(screen);
if (state->burnin != NULL)
{
- astring *fname = astring_alloc();
+ astring fname;
rectangle scaledvis;
bitmap_t *finalmap;
UINT64 minval = ~(UINT64)0;
@@ -2591,8 +2582,8 @@ static void video_finalize_burnin(const device_config *screen)
/* write the final PNG */
/* compute the name and create the file */
- astring_printf(fname, "%s" PATH_SEPARATOR "burnin-%s.png", screen->machine->basename, screen->tag);
- filerr = mame_fopen(SEARCHPATH_SCREENSHOT, astring_c(fname), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
+ fname.printf("%s" PATH_SEPARATOR "burnin-%s.png", screen->machine->basename, screen->tag);
+ filerr = mame_fopen(SEARCHPATH_SCREENSHOT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file);
if (filerr == FILERR_NONE)
{
png_info pnginfo = { 0 };
@@ -2612,7 +2603,6 @@ static void video_finalize_burnin(const device_config *screen)
png_free(&pnginfo);
mame_fclose(file);
}
- astring_free(fname);
bitmap_free(finalmap);
}
}
diff --git a/src/ldplayer/ldplayer.c b/src/ldplayer/ldplayer.c
index 4ce6d6998bc..258addf33f1 100644
--- a/src/ldplayer/ldplayer.c
+++ b/src/ldplayer/ldplayer.c
@@ -62,7 +62,7 @@ enum
*
*************************************/
-static astring *filename;
+static astring filename;
static input_port_value last_controls;
static UINT8 playing;
@@ -83,7 +83,6 @@ static void (*execute_command)(const device_config *laserdisc, int command);
static void free_string(running_machine *machine)
{
- astring_free(filename);
}
@@ -123,7 +122,7 @@ static chd_file *get_disc(const device_config *device)
if (chderr == CHDERR_NONE)
{
set_disk_handle(device->machine, "laserdisc", image_file, image_chd);
- filename = astring_dupc(dir->name);
+ filename.cpy(dir->name);
add_exit_callback(device->machine, free_string);
break;
}
@@ -264,7 +263,7 @@ static MACHINE_RESET( ldplayer )
timer_set(machine, attotime_zero, NULL, 0, autoplay);
/* indicate the name of the file we opened */
- popmessage("Opened %s\n", astring_c(filename));
+ popmessage("Opened %s\n", filename.cstr());
}
diff --git a/src/lib/util/astring.c b/src/lib/util/astring.c
index 7ce911dfa30..6ccda117905 100644
--- a/src/lib/util/astring.c
+++ b/src/lib/util/astring.c
@@ -138,15 +138,15 @@ INLINE void normalize_substr(int *start, int *count, int length)
#ifdef __cplusplus
/*-------------------------------------------------
- astring - basic constructor
+ init - constructor helper
-------------------------------------------------*/
-astring::astring()
+astring &astring::init()
{
- /* initialize base fields by hand */
text = smallbuf;
alloclen = ARRAY_LENGTH(smallbuf);
smallbuf[0] = 0;
+ return *this;
}
diff --git a/src/lib/util/astring.h b/src/lib/util/astring.h
index 84cd030cf47..889360cae9f 100644
--- a/src/lib/util/astring.h
+++ b/src/lib/util/astring.h
@@ -60,25 +60,11 @@ struct _astring_base
};
+/* class for C++, direct map for C */
#ifdef __cplusplus
-
-/* class for C++ */
-class astring : public astring_base
-{
-private:
- astring(const astring &);
- astring &operator=(const astring &);
-
-public:
- astring();
- ~astring();
-};
-
+class astring;
#else
-
-/* direct map for C */
typedef astring_base astring;
-
#endif
@@ -301,4 +287,89 @@ INLINE astring *astring_assemble_5(astring *dst, const char *src1, const char *s
}
+
+/***************************************************************************
+ C++ WRAPPERS
+***************************************************************************/
+
+#ifdef __cplusplus
+
+/* derived class for C++ */
+class astring : public astring_base
+{
+private:
+ astring &init();
+
+public:
+ astring() { init(); }
+ ~astring();
+
+ astring(const char *string) { init().cpy(string); }
+ astring(const char *str1, const char *str2) { init().cpy(str1).cat(str2); }
+ astring(const char *str1, const char *str2, const char *str3) { init().cpy(str1).cat(str2).cat(str3); }
+ astring(const char *str1, const char *str2, const char *str3, const char *str4) { init().cpy(str1).cat(str2).cat(str3).cat(str4); }
+ astring(const char *str1, const char *str2, const char *str3, const char *str4, const char *str5) { init().cpy(str1).cat(str2).cat(str3).cat(str4).cat(str5); }
+ astring(const astring &string) { init().cpy(string); }
+
+ astring &operator=(const char *string) { return cpy(string); }
+ astring &operator=(const astring &string) { return cpy(string); }
+
+ astring &reset() { return cpy(""); }
+
+ operator const char *() const { return astring_c(this); }
+ const char *cstr() const { return astring_c(this); }
+ int len() const { return astring_len(this); }
+
+ astring &cpy(const astring &src) { return *astring_cpy(this, &src); }
+ astring &cpy(const char *src) { return *astring_cpyc(this, src); }
+ astring &cpy(const char *src, int count) { return *astring_cpych(this, src, count); }
+ astring &cpysubstr(const astring &src, int start, int count) { return *astring_cpysubstr(this, &src, start, count); }
+
+ astring &cat(const astring &src) { return ins(-1, src); }
+ astring &cat(const char *src) { return ins(-1, src); }
+ astring &cat(const char *src, int count) { return ins(-1, src, count); }
+ astring &catsubstr(const astring &src, int start, int count) { return inssubstr(-1, src, start, count); }
+
+ astring &ins(int insbefore, const astring &src) { return *astring_ins(this, insbefore, &src); }
+ astring &ins(int insbefore, const char *src) { return *astring_insc(this, insbefore, src); }
+ astring &ins(int insbefore, const char *src, int count) { return *astring_insch(this, insbefore, src, count); }
+ astring &inssubstr(int insbefore, const astring &src, int start, int count) { return *astring_inssubstr(this, insbefore, &src, start, count); }
+
+ astring &substr(int start, int count) { return *astring_substr(this, start, count); }
+ astring &del(int start, int count) { return *astring_del(this, start, count); }
+
+ int printf(const char *format, ...) { va_list ap; va_start(ap, format); int result = astring_vprintf(this, format, ap); va_end(ap); return result; }
+ int vprintf(const char *format, va_list args) { return astring_vprintf(this, format, args); }
+ int catprintf(const char *format, ...) { va_list ap; va_start(ap, format); int result = astring_catvprintf(this, format, ap); va_end(ap); return result; }
+ int catvprintf(const char *format, va_list args) { return astring_catvprintf(this, format, args); }
+
+ int cmp(const astring &str2) const { return astring_cmp(this, &str2); }
+ int cmp(const char *str2) const { return astring_cmpc(this, str2); }
+ int cmp(const char *str2, int count) const { return astring_cmpch(this, str2, count); }
+ int cmpsubstr(const astring &str2, int start, int count) const { return astring_cmpsubstr(this, &str2, start, count); }
+
+ int icmp(const astring &str2) const { return astring_icmp(this, &str2); }
+ int icmp(const char *str2) const { return astring_icmpc(this, str2); }
+ int icmp(const char *str2, int count) const { return astring_icmpch(this, str2, count); }
+ int icmpsubstr(const astring &str2, int start, int count) const { return astring_icmpsubstr(this, &str2, start, count); }
+
+ int chr(int start, int ch) const { return astring_chr(this, start, ch); }
+ int rchr(int start, int ch) const { return astring_rchr(this, start, ch); }
+
+ int find(int start, const astring &search) const { return astring_find(this, start, &search); }
+ int find(int start, const char *search) const { return astring_findc(this, start, search); }
+
+ int replace(int start, const astring &search, const astring &replace) { return astring_replace(this, start, &search, &replace); }
+ int replace(int start, const char *search, const char *replace) { return astring_replacec(this, start, search, replace); }
+
+ astring &delchr(int ch) { return *astring_delchr(this, ch); }
+ astring &replacechr(int ch, int newch) { return *astring_replacechr(this, ch, newch); }
+ astring &toupper() { return *astring_toupper(this); }
+ astring &tolower() { return *astring_tolower(this); }
+ astring &trimspace() { return *astring_trimspace(this); }
+};
+
+#endif
+
+
#endif /* __ASTRING_H__ */
diff --git a/src/mame/audio/namco52.c b/src/mame/audio/namco52.c
index 2a749072937..a100c438f78 100644
--- a/src/mame/audio/namco52.c
+++ b/src/mame/audio/namco52.c
@@ -203,12 +203,11 @@ static DEVICE_START( namco_52xx )
{
namco_52xx_interface *intf = (namco_52xx_interface *)device->static_config;
namco_52xx_state *state = get_safe_token(device);
- astring *tempstring = astring_alloc();
+ astring tempstring;
/* find our CPU */
state->cpu = devtag_get_device(device->machine, device_build_tag(tempstring, device, "mcu"));
assert(state->cpu != NULL);
- astring_free(tempstring);
/* find the attached discrete sound device */
assert(intf->discrete != NULL);
diff --git a/src/mame/audio/namco54.c b/src/mame/audio/namco54.c
index ab30227648b..368e874a840 100644
--- a/src/mame/audio/namco54.c
+++ b/src/mame/audio/namco54.c
@@ -167,12 +167,11 @@ static DEVICE_START( namco_54xx )
{
namco_54xx_config *config = (namco_54xx_config *)device->inline_config;
namco_54xx_state *state = get_safe_token(device);
- astring *tempstring = astring_alloc();
+ astring tempstring;
/* find our CPU */
state->cpu = devtag_get_device(device->machine, device_build_tag(tempstring, device, "mcu"));
assert(state->cpu != NULL);
- astring_free(tempstring);
/* find the attached discrete sound device */
assert(config->discrete != NULL);
diff --git a/src/mame/machine/namco50.c b/src/mame/machine/namco50.c
index 836d411853d..448a13914d3 100644
--- a/src/mame/machine/namco50.c
+++ b/src/mame/machine/namco50.c
@@ -281,12 +281,11 @@ ROM_END
static DEVICE_START( namco_50xx )
{
namco_50xx_state *state = get_safe_token(device);
- astring *tempstring = astring_alloc();
+ astring tempstring;
/* find our CPU */
state->cpu = devtag_get_device(device->machine, device_build_tag(tempstring, device, "mcu"));
assert(state->cpu != NULL);
- astring_free(tempstring);
}
diff --git a/src/mame/machine/namco51.c b/src/mame/machine/namco51.c
index 75faabf2068..f1deaa9eaa0 100644
--- a/src/mame/machine/namco51.c
+++ b/src/mame/machine/namco51.c
@@ -379,14 +379,13 @@ static DEVICE_START( namco_51xx )
{
const namco_51xx_interface *config = (const namco_51xx_interface *)device->static_config;
namco_51xx_state *state = get_safe_token(device);
- astring *tempstring = astring_alloc();
+ astring tempstring;
assert(config != NULL);
/* find our CPU */
state->cpu = devtag_get_device(device->machine, device_build_tag(tempstring, device, "mcu"));
assert(state->cpu != NULL);
- astring_free(tempstring);
/* resolve our read callbacks */
devcb_resolve_read8(&state->in[0], &config->in[0], device);
diff --git a/src/mame/machine/namco53.c b/src/mame/machine/namco53.c
index 2ae0cc1380e..b1a10b414e4 100644
--- a/src/mame/machine/namco53.c
+++ b/src/mame/machine/namco53.c
@@ -173,14 +173,13 @@ static DEVICE_START( namco_53xx )
{
const namco_53xx_interface *config = (const namco_53xx_interface *)device->static_config;
namco_53xx_state *state = get_safe_token(device);
- astring *tempstring = astring_alloc();
+ astring tempstring;
assert(config != NULL);
/* find our CPU */
state->cpu = devtag_get_device(device->machine, device_build_tag(tempstring, device, "mcu"));
assert(state->cpu != NULL);
- astring_free(tempstring);
/* resolve our read/write callbacks */
devcb_resolve_read8(&state->k, &config->k, device);