nvram devices each have their own file.
This commit is contained in:
parent
4e5f8f0c06
commit
3d42b012fd
@ -326,42 +326,61 @@ static astring nvram_filename(running_machine &machine, astring &result)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------
|
||||||
|
nvram_filename - returns filename of system's
|
||||||
|
NVRAM depending of selected BIOS
|
||||||
|
-------------------------------------------------*/
|
||||||
|
|
||||||
|
static astring nvram_filename(device_t &device, astring &result)
|
||||||
|
{
|
||||||
|
running_machine &machine = device.machine();
|
||||||
|
if (rom_system_bios(machine) == 0 || rom_default_bios(machine) == rom_system_bios(machine)) {
|
||||||
|
result.printf("%s\\%s",machine.basename(),device.tag());
|
||||||
|
} else {
|
||||||
|
result.printf("%s_%d\\%s",machine.basename(),rom_system_bios(machine) - 1,device.tag());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
nvram_load - load a system's NVRAM
|
nvram_load - load a system's NVRAM
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
void nvram_load(running_machine &machine)
|
void nvram_load(running_machine &machine)
|
||||||
{
|
{
|
||||||
// only need to do something if we have an NVRAM device or an nvram_handler
|
if (machine.config().m_nvram_handler != NULL)
|
||||||
device_nvram_interface *nvram = NULL;
|
{
|
||||||
if (!machine.devicelist().first(nvram) && machine.config().m_nvram_handler == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// open the file; if it exists, call everyone to read from it
|
|
||||||
astring filename;
|
astring filename;
|
||||||
emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ);
|
emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ);
|
||||||
if (file.open(nvram_filename(machine,filename), ".nv") == FILERR_NONE)
|
if (file.open(nvram_filename(machine,filename),".nv") == FILERR_NONE)
|
||||||
{
|
{
|
||||||
// read data from general NVRAM handler first
|
|
||||||
if (machine.config().m_nvram_handler != NULL)
|
|
||||||
(*machine.config().m_nvram_handler)(machine, &file, FALSE);
|
(*machine.config().m_nvram_handler)(machine, &file, FALSE);
|
||||||
|
file.close();
|
||||||
// find all devices with NVRAM handlers, and read from them next
|
|
||||||
for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram))
|
|
||||||
nvram->nvram_load(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, tell everyone to initialize their NVRAM areas
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// initialize via the general NVRAM handler first
|
|
||||||
if (machine.config().m_nvram_handler != NULL)
|
|
||||||
(*machine.config().m_nvram_handler)(machine, NULL, FALSE);
|
(*machine.config().m_nvram_handler)(machine, NULL, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// find all devices with NVRAM handlers, and read from them next
|
device_nvram_interface *nvram = NULL;
|
||||||
|
if (machine.devicelist().first(nvram))
|
||||||
|
{
|
||||||
for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram))
|
for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram))
|
||||||
|
{
|
||||||
|
astring filename;
|
||||||
|
emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ);
|
||||||
|
if (file.open(nvram_filename(nvram->device(),filename)) == FILERR_NONE)
|
||||||
|
{
|
||||||
|
nvram->nvram_load(file);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
nvram->nvram_reset();
|
nvram->nvram_reset();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -371,23 +390,30 @@ void nvram_load(running_machine &machine)
|
|||||||
|
|
||||||
void nvram_save(running_machine &machine)
|
void nvram_save(running_machine &machine)
|
||||||
{
|
{
|
||||||
// only need to do something if we have an NVRAM device or an nvram_handler
|
if (machine.config().m_nvram_handler != NULL)
|
||||||
device_nvram_interface *nvram = NULL;
|
{
|
||||||
if (!machine.devicelist().first(nvram) && machine.config().m_nvram_handler == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// open the file; if it exists, call everyone to read from it
|
|
||||||
astring filename;
|
astring filename;
|
||||||
emu_file file(machine.options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
emu_file file(machine.options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||||
if (file.open(nvram_filename(machine,filename), ".nv") == FILERR_NONE)
|
if (file.open(nvram_filename(machine,filename), ".nv") == FILERR_NONE)
|
||||||
{
|
{
|
||||||
// write data via general NVRAM handler first
|
|
||||||
if (machine.config().m_nvram_handler != NULL)
|
|
||||||
(*machine.config().m_nvram_handler)(machine, &file, TRUE);
|
(*machine.config().m_nvram_handler)(machine, &file, TRUE);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// find all devices with NVRAM handlers, and tell them to write next
|
device_nvram_interface *nvram = NULL;
|
||||||
|
if (machine.devicelist().first(nvram))
|
||||||
|
{
|
||||||
for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram))
|
for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram))
|
||||||
|
{
|
||||||
|
astring filename;
|
||||||
|
emu_file file(machine.options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||||
|
if (file.open(nvram_filename(nvram->device(),filename)) == FILERR_NONE)
|
||||||
|
{
|
||||||
nvram->nvram_save(file);
|
nvram->nvram_save(file);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user