From 58275daa44da111650185117b61e57098cee4f7c Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Tue, 21 May 2013 08:35:40 +0000 Subject: [PATCH] Added NVRAMs for devices in software item named folder [Miodrag Milanovic] out of whatsnew: This should help storing per game eeproms and other nvrams. NVRAM of root device is only stored in main folder in this case, since that is main machine nvram if any --- src/emu/machine/generic.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c index fc8fadfae5f..94525bce436 100644 --- a/src/emu/machine/generic.c +++ b/src/emu/machine/generic.c @@ -280,18 +280,23 @@ void coin_lockout_global_w(running_machine &machine, int on) NVRAM depending of selected BIOS -------------------------------------------------*/ -static astring &nvram_filename(astring &result, device_t &device) +static astring &nvram_filename(astring &result, device_t &device, const char *software) { running_machine &machine = device.machine(); // start with either basename or basename_biosnum - result.cpy(machine.basename()); + result.cpy(machine.basename()); if (device.machine().root_device().system_bios() != 0 && device.machine().root_device().default_bios() != device.machine().root_device().system_bios()) result.catprintf("_%d", device.machine().root_device().system_bios() - 1); // device-based NVRAM gets its own name in a subdirectory if (&device != &device.machine().root_device()) { + // add per software nvrams into one folder + if (software!=NULL && strlen(software)>0) + { + result.cat('\\').cat(software); + } astring tag(device.tag()); tag.del(0, 1).replacechr(':', '_'); result.cat('\\').cat(tag); @@ -309,7 +314,7 @@ void nvram_load(running_machine &machine) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ); - if (file.open(nvram_filename(filename, machine.root_device()), ".nv") == FILERR_NONE) + if (file.open(nvram_filename(filename, machine.root_device(),NULL), ".nv") == FILERR_NONE) { (*machine.config().m_nvram_handler)(machine, &file, FALSE); file.close(); @@ -325,7 +330,7 @@ void nvram_load(running_machine &machine) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ); - if (file.open(nvram_filename(filename, nvram->device())) == FILERR_NONE) + if (file.open(nvram_filename(filename, nvram->device(),machine.options().software_name())) == FILERR_NONE) { nvram->nvram_load(file); file.close(); @@ -346,7 +351,7 @@ void nvram_save(running_machine &machine) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); - if (file.open(nvram_filename(filename, machine.root_device()), ".nv") == FILERR_NONE) + if (file.open(nvram_filename(filename, machine.root_device(),NULL), ".nv") == FILERR_NONE) { (*machine.config().m_nvram_handler)(machine, &file, TRUE); file.close(); @@ -358,7 +363,7 @@ void nvram_save(running_machine &machine) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); - if (file.open(nvram_filename(filename, nvram->device())) == FILERR_NONE) + if (file.open(nvram_filename(filename, nvram->device(),machine.options().software_name())) == FILERR_NONE) { nvram->nvram_save(file); file.close();