From f37b2db1c9f8c7d9957a1238626583e1c481acbb Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Tue, 14 Sep 2010 01:17:36 +0000 Subject: [PATCH] Couple more NVRAM handlers gone. --- src/mame/drivers/peplus.c | 41 ++++++++++----------------------------- src/mame/drivers/pgm.c | 32 +++++++++--------------------- 2 files changed, 19 insertions(+), 54 deletions(-) diff --git a/src/mame/drivers/peplus.c b/src/mame/drivers/peplus.c index 38a1748117d..dffd4ac8c67 100644 --- a/src/mame/drivers/peplus.c +++ b/src/mame/drivers/peplus.c @@ -162,6 +162,7 @@ Stephh's log (2007.11.28) : #include "emu.h" #include "sound/ay8910.h" +#include "machine/nvram.h" #include "cpu/mcs51/mcs51.h" #include "machine/i2cmem.h" #include "video/mc6845.h" @@ -178,9 +179,11 @@ class peplus_state : public driver_device { public: peplus_state(running_machine &machine, const driver_device_config_base &config) - : driver_device(machine, config) { } + : driver_device(machine, config), + cmos_ram(*this, "cmos") { } UINT8 *videoram; + required_shared_ptr cmos_ram; }; @@ -197,7 +200,6 @@ static UINT8 jumper_e16_e17; /* Set this to TRUE when CG chips are 27c512 instea /* Pointers to External RAM */ static UINT8 *program_ram; -static UINT8 *cmos_ram; static UINT8 *s3000_ram; static UINT8 *s5000_ram; static UINT8 *s7000_ram; @@ -225,7 +227,6 @@ static UINT8 coin_out_state = 0; static int sda_dir = 0; /* Static Variables */ -#define CMOS_NVRAM_SIZE 0x2000 #define eeprom_NVRAM_SIZE 0x200 // 4k Bit /* EEPROM is a X2404P 4K-bit Serial I2C Bus */ @@ -271,30 +272,6 @@ static void peplus_load_superdata(running_machine *machine, const char *bank_nam } -/***************** -* NVRAM Handlers * -******************/ - -static NVRAM_HANDLER( peplus ) -{ - if (read_or_write) - { - mame_fwrite(file, cmos_ram, CMOS_NVRAM_SIZE); - } - else - { - if (file) - { - mame_fread(file, cmos_ram, CMOS_NVRAM_SIZE); - } - else - { - memset(cmos_ram, 0, CMOS_NVRAM_SIZE); - } - } -} - - /***************** * Write Handlers * ******************/ @@ -392,6 +369,7 @@ static WRITE8_HANDLER( peplus_duart_w ) static WRITE8_HANDLER( peplus_cmos_w ) { + peplus_state *state = space->machine->driver_data(); char bank_name[6]; /* Test for Wingboard PAL Trigger Condition */ @@ -401,7 +379,7 @@ static WRITE8_HANDLER( peplus_cmos_w ) peplus_load_superdata(space->machine, bank_name); } - cmos_ram[offset] = data; + state->cmos_ram[offset] = data; } static WRITE8_HANDLER( peplus_s3000_w ) @@ -499,7 +477,8 @@ static READ8_HANDLER( peplus_duart_r ) static READ8_HANDLER( peplus_cmos_r ) { - return cmos_ram[offset]; + peplus_state *state = space->machine->driver_data(); + return state->cmos_ram[offset]; } static READ8_HANDLER( peplus_s3000_r ) @@ -748,7 +727,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( peplus_iomap, ADDRESS_SPACE_IO, 8 ) // Battery-backed RAM (0x1000-0x01fff Extended RAM for Superboards Only) - AM_RANGE(0x0000, 0x1fff) AM_READWRITE(peplus_cmos_r, peplus_cmos_w) AM_BASE(&cmos_ram) + AM_RANGE(0x0000, 0x1fff) AM_READWRITE(peplus_cmos_r, peplus_cmos_w) AM_SHARE("cmos") // CRT Controller AM_RANGE(0x2008, 0x2008) AM_DEVWRITE("crtc", peplus_crtc_mode_w) @@ -1043,7 +1022,7 @@ static MACHINE_CONFIG_START( peplus, peplus_state ) MDRV_CPU_IO_MAP(peplus_iomap) MDRV_MACHINE_RESET(peplus) - MDRV_NVRAM_HANDLER(peplus) + MDRV_NVRAM_ADD_0FILL("cmos") // video hardware MDRV_SCREEN_ADD("screen", RASTER) diff --git a/src/mame/drivers/pgm.c b/src/mame/drivers/pgm.c index 17282364f92..5f8930d7de3 100644 --- a/src/mame/drivers/pgm.c +++ b/src/mame/drivers/pgm.c @@ -298,6 +298,7 @@ Notes: #include "deprecat.h" #include "sound/ics2115.h" #include "cpu/arm7/arm7core.h" +#include "machine/nvram.h" #include "includes/pgm.h" UINT16 *pgm_mainram; @@ -558,21 +559,6 @@ static WRITE16_HANDLER( pgm_calendar_w ) } } -static NVRAM_HANDLER( pgm ) -{ - if (read_or_write) - /* save the SRAM settings */ - mame_fwrite(file, pgm_mainram, 0x20000); - else - { - /* load the SRAM settings */ - if (file) - mame_fread(file, pgm_mainram, 0x20000); - else - memset(pgm_mainram, 0, 0x20000); - } -} - /*** Memory Maps *************************************************************/ static ADDRESS_MAP_START( pgm_mem, ADDRESS_SPACE_PROGRAM, 16) @@ -581,7 +567,7 @@ static ADDRESS_MAP_START( pgm_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog? - AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ + AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) AM_SHARE("sram") /* Main Ram */ // AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ // AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ @@ -612,7 +598,7 @@ static ADDRESS_MAP_START( killbld_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog? - AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ + AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) AM_SHARE("sram") /* Main Ram */ // AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ // AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ @@ -643,7 +629,7 @@ static ADDRESS_MAP_START( olds_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog? - AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ + AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) AM_SHARE("sram") /* Main Ram */ // AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ // AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ @@ -673,7 +659,7 @@ static ADDRESS_MAP_START( kov2_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog? - AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ + AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) AM_SHARE("sram") /* Main Ram */ // AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ // AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ @@ -707,7 +693,7 @@ static ADDRESS_MAP_START( cavepgm_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog? - AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ + AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) AM_SHARE("sram") /* Main Ram */ // AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ // AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ @@ -840,7 +826,7 @@ static ADDRESS_MAP_START( kovsh_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog? - AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ + AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) AM_SHARE("sram") /* Main Ram */ // AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ // AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ @@ -955,7 +941,7 @@ static ADDRESS_MAP_START( svg_68k_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog? - AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ + AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) AM_SHARE("sram") /* Main Ram */ // AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ // AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ @@ -1379,7 +1365,7 @@ static MACHINE_CONFIG_START( pgm, pgm_state ) MDRV_MACHINE_START( pgm ) MDRV_MACHINE_RESET( pgm ) - MDRV_NVRAM_HANDLER( pgm ) + MDRV_NVRAM_ADD_0FILL("sram") /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER)