mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
- Added void state_save_combine_module_and_tag(char *dest, const char *module, const char *tag);
Its purpose is to create a unique name for state saving purposes in modules that are tag based (no index) - Updated MC6845 to make use of this
This commit is contained in:
parent
0ab1b992b7
commit
e619861862
@ -946,6 +946,53 @@ const char *state_save_get_indexed_item(int index, void **base, UINT32 *valsize,
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
state_save_combine_module_and_tag - creates
|
||||
a name from a given module and tag that can
|
||||
be used as the first agrument to the
|
||||
state_save_register_item family of functions
|
||||
-------------------------------------------------*/
|
||||
|
||||
void state_save_combine_module_and_tag(char *dest, const char *module, const char *tag)
|
||||
{
|
||||
astring *module_lower;
|
||||
astring *tag_lower;
|
||||
astring *combined;
|
||||
|
||||
/* validate arguments */
|
||||
assert(dest != NULL);
|
||||
assert(module != NULL);
|
||||
assert(tag != NULL);
|
||||
assert(strlen(module) > 0);
|
||||
assert(strlen(tag) > 0);
|
||||
|
||||
/* allocate objects */
|
||||
module_lower = astring_alloc();
|
||||
tag_lower = astring_alloc();
|
||||
combined = astring_alloc();
|
||||
|
||||
/* convert both arguments to lower case for case insenstive comparisson */
|
||||
astring_tolower(astring_cpyc(module_lower, module));
|
||||
astring_tolower(astring_cpyc(tag_lower, tag));
|
||||
|
||||
/* if the tag contains the module name, just use the tag as the combined name */
|
||||
if (astring_find(tag_lower, 0, module_lower) >= 0)
|
||||
astring_cpyc(combined, tag);
|
||||
|
||||
/* otherwise combine the module and the tag */
|
||||
else
|
||||
astring_assemble_3(combined, module, ".", tag);
|
||||
|
||||
/* copy the result to the destination array */
|
||||
strcpy(dest, astring_c(combined));
|
||||
|
||||
/* free the objects */
|
||||
astring_free(module_lower);
|
||||
astring_free(tag_lower);
|
||||
astring_free(combined);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
state_save_dump_registry - dump the registry
|
||||
to the logfile
|
||||
|
@ -111,6 +111,9 @@ void state_save_load_continue(void);
|
||||
void state_save_save_finish(void);
|
||||
void state_save_load_finish(void);
|
||||
|
||||
/* Helper function for creating a unique name */
|
||||
void state_save_combine_module_and_tag(char *dest, const char *module, const char *tag);
|
||||
|
||||
/* Display function */
|
||||
void state_save_dump_registry(void);
|
||||
|
||||
|
@ -413,8 +413,12 @@ void mc6845_update(mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *clipr
|
||||
static void *mc6845_start(running_machine *machine, const char *tag, const void *static_config, const void *inline_config)
|
||||
{
|
||||
mc6845_t *mc6845;
|
||||
char unique_tag[30];
|
||||
|
||||
/* validate arguments */
|
||||
assert(machine != NULL);
|
||||
assert(tag != NULL);
|
||||
assert(strlen(tag) < 20);
|
||||
|
||||
/* allocate the object that holds the state */
|
||||
mc6845 = auto_malloc(sizeof(*mc6845));
|
||||
@ -429,24 +433,26 @@ static void *mc6845_start(running_machine *machine, const char *tag, const void
|
||||
mc6845->display_enable_changed_timer = timer_alloc(display_enable_changed_timer_cb, mc6845);
|
||||
|
||||
/* register for state saving */
|
||||
state_save_combine_module_and_tag(unique_tag, "mc6845", tag);
|
||||
|
||||
state_save_register_func_postload_ptr(mc6845_state_save_postload, mc6845);
|
||||
|
||||
state_save_register_item("mc6845", 0, mc6845->address_latch);
|
||||
state_save_register_item("mc6845", 0, mc6845->horiz_total);
|
||||
state_save_register_item("mc6845", 0, mc6845->horiz_disp);
|
||||
state_save_register_item("mc6845", 0, mc6845->horiz_sync_pos);
|
||||
state_save_register_item("mc6845", 0, mc6845->sync_width);
|
||||
state_save_register_item("mc6845", 0, mc6845->vert_total);
|
||||
state_save_register_item("mc6845", 0, mc6845->vert_total_adj);
|
||||
state_save_register_item("mc6845", 0, mc6845->vert_disp);
|
||||
state_save_register_item("mc6845", 0, mc6845->vert_sync_pos);
|
||||
state_save_register_item("mc6845", 0, mc6845->intl_skew);
|
||||
state_save_register_item("mc6845", 0, mc6845->max_ras_addr);
|
||||
state_save_register_item("mc6845", 0, mc6845->cursor_start_ras);
|
||||
state_save_register_item("mc6845", 0, mc6845->cursor_end_ras);
|
||||
state_save_register_item("mc6845", 0, mc6845->start_addr);
|
||||
state_save_register_item("mc6845", 0, mc6845->cursor);
|
||||
state_save_register_item("mc6845", 0, mc6845->light_pen);
|
||||
state_save_register_item(unique_tag, 0, mc6845->address_latch);
|
||||
state_save_register_item(unique_tag, 0, mc6845->horiz_total);
|
||||
state_save_register_item(unique_tag, 0, mc6845->horiz_disp);
|
||||
state_save_register_item(unique_tag, 0, mc6845->horiz_sync_pos);
|
||||
state_save_register_item(unique_tag, 0, mc6845->sync_width);
|
||||
state_save_register_item(unique_tag, 0, mc6845->vert_total);
|
||||
state_save_register_item(unique_tag, 0, mc6845->vert_total_adj);
|
||||
state_save_register_item(unique_tag, 0, mc6845->vert_disp);
|
||||
state_save_register_item(unique_tag, 0, mc6845->vert_sync_pos);
|
||||
state_save_register_item(unique_tag, 0, mc6845->intl_skew);
|
||||
state_save_register_item(unique_tag, 0, mc6845->max_ras_addr);
|
||||
state_save_register_item(unique_tag, 0, mc6845->cursor_start_ras);
|
||||
state_save_register_item(unique_tag, 0, mc6845->cursor_end_ras);
|
||||
state_save_register_item(unique_tag, 0, mc6845->start_addr);
|
||||
state_save_register_item(unique_tag, 0, mc6845->cursor);
|
||||
state_save_register_item(unique_tag, 0, mc6845->light_pen);
|
||||
|
||||
return mc6845;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user