mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
Replaced hack code for saving nc200 ram with legacy nvram saving, you can now shut down the emulation and start it up without losing everything. However you must press the on button before exiting (default END key). [smf]
This commit is contained in:
parent
97d7730a30
commit
4afe8297bd
@ -107,6 +107,7 @@
|
||||
#include "sound/beep.h"
|
||||
#include "machine/ram.h"
|
||||
#include "rendlay.h"
|
||||
#include "mcfglgcy.h"
|
||||
|
||||
#define VERBOSE 0
|
||||
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
|
||||
@ -405,76 +406,24 @@ void nc_state::nc_refresh_memory_config()
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* restore a block of memory from the nvram file */
|
||||
void nc_state::nc_common_restore_memory_from_stream()
|
||||
static NVRAM_HANDLER( nc )
|
||||
{
|
||||
UINT32 stored_size;
|
||||
UINT32 restore_size;
|
||||
nc_state *state = machine.driver_data<nc_state>();
|
||||
|
||||
if (!m_file)
|
||||
return;
|
||||
|
||||
LOG(("restoring nc memory\n"));
|
||||
/* get size of memory data stored */
|
||||
if (m_file->read(&stored_size, sizeof(UINT32)) != sizeof(UINT32))
|
||||
stored_size = 0;
|
||||
|
||||
if (stored_size > m_ram->size())
|
||||
restore_size = m_ram->size();
|
||||
if (read_or_write)
|
||||
{
|
||||
file->write(state->m_ram->pointer(), state->m_ram->size());
|
||||
}
|
||||
else if (file)
|
||||
{
|
||||
file->read(state->m_ram->pointer(), state->m_ram->size());
|
||||
}
|
||||
else
|
||||
restore_size = stored_size;
|
||||
|
||||
/* read as much as will fit into memory */
|
||||
m_file->read(m_ram->pointer(), restore_size);
|
||||
/* seek over remaining data */
|
||||
m_file->seek(SEEK_CUR,stored_size - restore_size);
|
||||
{
|
||||
// leave whatever ram device defaulted to
|
||||
}
|
||||
}
|
||||
|
||||
/* store a block of memory to the nvram file */
|
||||
void nc_state::nc_common_store_memory_to_stream()
|
||||
{
|
||||
UINT32 size = m_ram->size();
|
||||
if (!m_file)
|
||||
return;
|
||||
|
||||
LOG(("storing nc memory\n"));
|
||||
/* write size of memory data */
|
||||
m_file->write(&size, sizeof(UINT32));
|
||||
|
||||
/* write data block */
|
||||
m_file->write(m_ram->pointer(), size);
|
||||
}
|
||||
|
||||
void nc_state::nc_common_open_stream_for_reading()
|
||||
{
|
||||
char filename[MAX_DRIVER_NAME_CHARS + 5];
|
||||
|
||||
sprintf(filename,"%s.hack", machine().system().name);
|
||||
|
||||
m_file = global_alloc(emu_file(machine().options().memcard_directory(), OPEN_FLAG_WRITE));
|
||||
m_file->open(filename);
|
||||
}
|
||||
|
||||
void nc_state::nc_common_open_stream_for_writing()
|
||||
{
|
||||
char filename[MAX_DRIVER_NAME_CHARS + 5];
|
||||
|
||||
sprintf(filename,"%s.hack", machine().system().name);
|
||||
|
||||
m_file = global_alloc(emu_file(machine().options().memcard_directory(), OPEN_FLAG_WRITE));
|
||||
m_file->open(filename);
|
||||
}
|
||||
|
||||
|
||||
void nc_state::nc_common_close_stream()
|
||||
{
|
||||
if (m_file)
|
||||
global_free(m_file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(nc_state::dummy_timer_callback)
|
||||
{
|
||||
@ -907,27 +856,14 @@ void nc_state::machine_reset()
|
||||
|
||||
nc_common_init_machine();
|
||||
|
||||
nc_common_open_stream_for_reading();
|
||||
nc_common_restore_memory_from_stream();
|
||||
nc_common_close_stream();
|
||||
|
||||
/* serial */
|
||||
m_irq_latch_mask = (1<<0) | (1<<1);
|
||||
}
|
||||
|
||||
void nc_state::nc100_machine_stop()
|
||||
{
|
||||
nc_common_open_stream_for_writing();
|
||||
nc_common_store_memory_to_stream();
|
||||
nc_common_close_stream();
|
||||
}
|
||||
|
||||
void nc_state::machine_start()
|
||||
{
|
||||
m_type = NC_TYPE_1xx;
|
||||
|
||||
machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(nc_state::nc100_machine_stop),this));
|
||||
|
||||
/* keyboard timer */
|
||||
m_keyboard_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nc_state::nc_keyboard_timer_callback),this));
|
||||
m_keyboard_timer->adjust(attotime::from_msec(10));
|
||||
@ -1280,29 +1216,16 @@ MACHINE_RESET_MEMBER(nc_state,nc200)
|
||||
|
||||
m_nc200_uart_interrupt_irq = 0;
|
||||
|
||||
nc_common_open_stream_for_reading();
|
||||
nc_common_restore_memory_from_stream();
|
||||
nc_common_close_stream();
|
||||
|
||||
/* fdc, serial */
|
||||
m_irq_latch_mask = /*(1<<5) |*/ (1<<2);
|
||||
|
||||
nc200_video_set_backlight(0);
|
||||
}
|
||||
|
||||
void nc_state::nc200_machine_stop()
|
||||
{
|
||||
nc_common_open_stream_for_writing();
|
||||
nc_common_store_memory_to_stream();
|
||||
nc_common_close_stream();
|
||||
}
|
||||
|
||||
MACHINE_START_MEMBER(nc_state,nc200)
|
||||
{
|
||||
m_type = NC_TYPE_200;
|
||||
|
||||
machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(nc_state::nc200_machine_stop),this));
|
||||
|
||||
/* keyboard timer */
|
||||
m_keyboard_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nc_state::nc_keyboard_timer_callback),this));
|
||||
m_keyboard_timer->adjust(attotime::from_msec(10));
|
||||
@ -1600,6 +1523,7 @@ static MACHINE_CONFIG_START( nc100, nc_state )
|
||||
/* internal ram */
|
||||
MCFG_RAM_ADD(RAM_TAG)
|
||||
MCFG_RAM_DEFAULT_SIZE("64K")
|
||||
MCFG_NVRAM_HANDLER(nc)
|
||||
|
||||
/* dummy timer */
|
||||
MCFG_TIMER_DRIVER_ADD_PERIODIC("dummy_timer", nc_state, dummy_timer_callback, attotime::from_hz(50))
|
||||
|
@ -49,7 +49,6 @@ public:
|
||||
int m_irq_latch;
|
||||
int m_irq_latch_mask;
|
||||
int m_sound_channel_periods[2];
|
||||
emu_file *m_file;
|
||||
int m_previous_inputport_10_state;
|
||||
int m_previous_alarm_state;
|
||||
UINT8 m_nc200_uart_interrupt_irq;
|
||||
@ -104,8 +103,6 @@ public:
|
||||
DECLARE_DEVICE_IMAGE_LOAD_MEMBER( nc_pcmcia_card );
|
||||
DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER( nc_pcmcia_card );
|
||||
|
||||
void nc100_machine_stop();
|
||||
void nc200_machine_stop();
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<ram_device> m_ram;
|
||||
required_device<beep_device> m_beeper1;
|
||||
@ -119,11 +116,6 @@ public:
|
||||
void nc_update_interrupts();
|
||||
void nc_refresh_memory_bank_config(int bank);
|
||||
void nc_refresh_memory_config();
|
||||
void nc_common_restore_memory_from_stream();
|
||||
void nc_common_store_memory_to_stream();
|
||||
void nc_common_open_stream_for_reading();
|
||||
void nc_common_open_stream_for_writing();
|
||||
void nc_common_close_stream();
|
||||
void nc_common_init_machine();
|
||||
void nc_sound_update(int channel);
|
||||
void nc_printer_update(UINT8 data);
|
||||
|
Loading…
Reference in New Issue
Block a user