mirror of
https://github.com/holub/mame
synced 2025-04-19 23:12:11 +03:00
Created memcard as device and removed it from machine/generic (nw)
This should be image device instead but did not wish to change behavior for now
This commit is contained in:
parent
3f4c65b8ee
commit
cd93e416fe
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -2497,6 +2497,8 @@ src/emu/machine/mccs1850.c svneol=native#text/plain
|
||||
src/emu/machine/mccs1850.h svneol=native#text/plain
|
||||
src/emu/machine/mcf5206e.c svneol=native#text/plain
|
||||
src/emu/machine/mcf5206e.h svneol=native#text/plain
|
||||
src/emu/machine/memcard.c svneol=native#text/plain
|
||||
src/emu/machine/memcard.h svneol=native#text/plain
|
||||
src/emu/machine/microtch.c svneol=native#text/plain
|
||||
src/emu/machine/microtch.h svneol=native#text/plain
|
||||
src/emu/machine/mm58167.c svneol=native#text/plain
|
||||
|
@ -167,6 +167,7 @@ EMUMACHINEOBJS = \
|
||||
$(EMUMACHINE)/keyboard.o \
|
||||
$(EMUMACHINE)/laserdsc.o \
|
||||
$(EMUMACHINE)/latch.o \
|
||||
$(EMUMACHINE)/memcard.o \
|
||||
$(EMUMACHINE)/netlist.o \
|
||||
$(EMUMACHINE)/nvram.o \
|
||||
$(EMUMACHINE)/ram.o \
|
||||
|
@ -35,9 +35,6 @@ struct generic_machine_private
|
||||
UINT32 coin_count[COIN_COUNTERS];
|
||||
UINT32 coinlockedout[COIN_COUNTERS];
|
||||
UINT32 lastcoin[COIN_COUNTERS];
|
||||
|
||||
/* memory card status */
|
||||
int memcard_inserted;
|
||||
};
|
||||
|
||||
|
||||
@ -72,18 +69,8 @@ void generic_machine_init(running_machine &machine)
|
||||
machine.save().save_item(NAME(state->coinlockedout));
|
||||
machine.save().save_item(NAME(state->lastcoin));
|
||||
|
||||
/* reset memory card info */
|
||||
state->memcard_inserted = -1;
|
||||
|
||||
/* register for configuration */
|
||||
config_register(machine, "counters", config_saveload_delegate(FUNC(counters_load), &machine), config_saveload_delegate(FUNC(counters_save), &machine));
|
||||
|
||||
/* for memory cards, request save state and an exit callback */
|
||||
if (machine.config().m_memcard_handler != NULL)
|
||||
{
|
||||
machine.save().save_item(NAME(state->memcard_inserted));
|
||||
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(memcard_eject), &machine));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -270,137 +257,6 @@ void coin_lockout_global_w(running_machine &machine, int on)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
MEMORY CARD MANAGEMENT
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
memcard_name - determine the name of a memcard
|
||||
file
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void memcard_name(int index, char *buffer)
|
||||
{
|
||||
sprintf(buffer, "memcard.%03d", index);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
memcard_create - create a new memory card with
|
||||
the given index
|
||||
-------------------------------------------------*/
|
||||
|
||||
int memcard_create(running_machine &machine, int index, int overwrite)
|
||||
{
|
||||
char name[16];
|
||||
|
||||
/* create a name */
|
||||
memcard_name(index, name);
|
||||
|
||||
/* if we can't overwrite, fail if the file already exists */
|
||||
astring fname(machine.basename(), PATH_SEPARATOR, name);
|
||||
if (!overwrite)
|
||||
{
|
||||
emu_file testfile(machine.options().memcard_directory(), OPEN_FLAG_READ);
|
||||
if (testfile.open(fname) == FILERR_NONE)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* create a new file */
|
||||
emu_file file(machine.options().memcard_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
file_error filerr = file.open(fname);
|
||||
if (filerr != FILERR_NONE)
|
||||
return 1;
|
||||
|
||||
/* initialize and then save the card */
|
||||
if (machine.config().m_memcard_handler)
|
||||
(*machine.config().m_memcard_handler)(machine, file, MEMCARD_CREATE);
|
||||
|
||||
/* close the file */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
memcard_insert - insert an existing memory card
|
||||
with the given index
|
||||
-------------------------------------------------*/
|
||||
|
||||
int memcard_insert(running_machine &machine, int index)
|
||||
{
|
||||
generic_machine_private *state = machine.generic_machine_data;
|
||||
char name[16];
|
||||
|
||||
/* if a card is already inserted, eject it first */
|
||||
if (state->memcard_inserted != -1)
|
||||
memcard_eject(machine);
|
||||
assert(state->memcard_inserted == -1);
|
||||
|
||||
/* create a name */
|
||||
memcard_name(index, name);
|
||||
|
||||
/* open the file; if we can't, it's an error */
|
||||
emu_file file(machine.options().memcard_directory(), OPEN_FLAG_READ);
|
||||
file_error filerr = file.open(machine.basename(), PATH_SEPARATOR, name);
|
||||
if (filerr != FILERR_NONE)
|
||||
return 1;
|
||||
|
||||
/* initialize and then load the card */
|
||||
if (machine.config().m_memcard_handler)
|
||||
(*machine.config().m_memcard_handler)(machine, file, MEMCARD_INSERT);
|
||||
|
||||
/* close the file */
|
||||
state->memcard_inserted = index;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
memcard_eject - eject a memory card, saving
|
||||
its contents along the way
|
||||
-------------------------------------------------*/
|
||||
|
||||
void memcard_eject(running_machine &machine)
|
||||
{
|
||||
generic_machine_private *state = machine.generic_machine_data;
|
||||
char name[16];
|
||||
|
||||
/* if no card is preset, just ignore */
|
||||
if (state->memcard_inserted == -1)
|
||||
return;
|
||||
|
||||
/* create a name */
|
||||
memcard_name(state->memcard_inserted, name);
|
||||
|
||||
/* open the file; if we can't, it's an error */
|
||||
emu_file file(machine.options().memcard_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
file_error filerr = file.open(machine.basename(), PATH_SEPARATOR, name);
|
||||
if (filerr != FILERR_NONE)
|
||||
return;
|
||||
|
||||
/* initialize and then load the card */
|
||||
if (machine.config().m_memcard_handler)
|
||||
(*machine.config().m_memcard_handler)(machine, file, MEMCARD_EJECT);
|
||||
|
||||
/* close the file */
|
||||
state->memcard_inserted = -1;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
memcard_present - return the currently loaded
|
||||
card index, or -1 if none
|
||||
-------------------------------------------------*/
|
||||
|
||||
int memcard_present(running_machine &machine)
|
||||
{
|
||||
generic_machine_private *state = machine.generic_machine_data;
|
||||
return state->memcard_inserted;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
LED CODE
|
||||
***************************************************************************/
|
||||
|
@ -23,13 +23,6 @@
|
||||
/* total # of coin counters */
|
||||
#define COIN_COUNTERS 8
|
||||
|
||||
/* memory card actions */
|
||||
#define MEMCARD_CREATE 0
|
||||
#define MEMCARD_INSERT 1
|
||||
#define MEMCARD_EJECT 2
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
FUNCTION PROTOTYPES
|
||||
***************************************************************************/
|
||||
@ -69,23 +62,6 @@ int coin_lockout_get_state(running_machine &machine, int num);
|
||||
/* enable/disable global coin lockout */
|
||||
void coin_lockout_global_w(running_machine &machine, int on);
|
||||
|
||||
|
||||
/* ----- memory card management ----- */
|
||||
|
||||
/* create a new memory card with the given index */
|
||||
int memcard_create(running_machine &machine, int index, int overwrite);
|
||||
|
||||
/* "insert" a memory card with the given index and load its data */
|
||||
int memcard_insert(running_machine &machine, int index);
|
||||
|
||||
/* "eject" a memory card and save its data */
|
||||
void memcard_eject(running_machine &machine);
|
||||
|
||||
/* returns the index of the current memory card, or -1 if none */
|
||||
int memcard_present(running_machine &machine);
|
||||
|
||||
|
||||
|
||||
/* ----- miscellaneous bits & pieces ----- */
|
||||
|
||||
/* set the status of an LED */
|
||||
|
191
src/emu/machine/memcard.c
Normal file
191
src/emu/machine/memcard.c
Normal file
@ -0,0 +1,191 @@
|
||||
/*********************************************************************
|
||||
|
||||
memcard.c
|
||||
|
||||
Memory card functions.
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "emuopts.h"
|
||||
#include "memcard.h"
|
||||
|
||||
// device type definition
|
||||
const device_type MEMCARD = &device_creator<memcard_device>;
|
||||
|
||||
//-------------------------------------------------
|
||||
// memcard_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
memcard_device::memcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, MEMCARD, "MEMCARD", tag, owner, clock, "memcard", __FILE__),
|
||||
m_memcard_inserted(-1)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// static_set_interface - configuration helper
|
||||
// to set the interface
|
||||
//-------------------------------------------------
|
||||
|
||||
void memcard_device::static_set_size(device_t &device, int value)
|
||||
{
|
||||
memcard_device &card = downcast<memcard_device &>(device);
|
||||
card.m_size = value;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void memcard_device::device_start()
|
||||
{
|
||||
/* initialize the memcard data structure */
|
||||
m_memcard_data = auto_alloc_array_clear(machine(), UINT8, m_size);
|
||||
save_pointer(NAME(m_memcard_data), m_size);
|
||||
save_item(NAME(m_memcard_inserted));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_stop - device-specific shutdown
|
||||
//-------------------------------------------------
|
||||
|
||||
void memcard_device::device_stop()
|
||||
{
|
||||
eject();
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
memcard_name - determine the name of a memcard
|
||||
file
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE void memcard_name(int index, char *buffer)
|
||||
{
|
||||
sprintf(buffer, "memcard.%03d", index);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
memcard_create - create a new memory card with
|
||||
the given index
|
||||
-------------------------------------------------*/
|
||||
|
||||
int memcard_device::create(int index, int overwrite)
|
||||
{
|
||||
char name[16];
|
||||
|
||||
/* create a name */
|
||||
memcard_name(index, name);
|
||||
|
||||
/* if we can't overwrite, fail if the file already exists */
|
||||
astring fname(machine().basename(), PATH_SEPARATOR, name);
|
||||
if (!overwrite)
|
||||
{
|
||||
emu_file testfile(machine().options().memcard_directory(), OPEN_FLAG_READ);
|
||||
if (testfile.open(fname) == FILERR_NONE)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* create a new file */
|
||||
emu_file file(machine().options().memcard_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
file_error filerr = file.open(fname);
|
||||
if (filerr != FILERR_NONE)
|
||||
return 1;
|
||||
|
||||
/* initialize and then save the card */
|
||||
memset(m_memcard_data, 0, m_size);
|
||||
file.write(m_memcard_data, m_size);
|
||||
|
||||
|
||||
/* close the file */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
memcard_insert - insert an existing memory card
|
||||
with the given index
|
||||
-------------------------------------------------*/
|
||||
|
||||
int memcard_device::insert(int index)
|
||||
{
|
||||
char name[16];
|
||||
|
||||
/* if a card is already inserted, eject it first */
|
||||
if (m_memcard_inserted != -1)
|
||||
eject();
|
||||
assert(m_memcard_inserted == -1);
|
||||
|
||||
/* create a name */
|
||||
memcard_name(index, name);
|
||||
|
||||
/* open the file; if we can't, it's an error */
|
||||
emu_file file(machine().options().memcard_directory(), OPEN_FLAG_READ);
|
||||
file_error filerr = file.open(machine().basename(), PATH_SEPARATOR, name);
|
||||
if (filerr != FILERR_NONE)
|
||||
return 1;
|
||||
|
||||
/* initialize and then load the card */
|
||||
file.read(m_memcard_data, m_size);
|
||||
|
||||
/* close the file */
|
||||
m_memcard_inserted = index;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
memcard_eject - eject a memory card, saving
|
||||
its contents along the way
|
||||
-------------------------------------------------*/
|
||||
|
||||
void memcard_device::eject()
|
||||
{
|
||||
char name[16];
|
||||
|
||||
/* if no card is preset, just ignore */
|
||||
if (m_memcard_inserted == -1)
|
||||
return;
|
||||
|
||||
/* create a name */
|
||||
memcard_name(m_memcard_inserted, name);
|
||||
|
||||
/* open the file; if we can't, it's an error */
|
||||
emu_file file(machine().options().memcard_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
file_error filerr = file.open(machine().basename(), PATH_SEPARATOR, name);
|
||||
if (filerr != FILERR_NONE)
|
||||
return;
|
||||
|
||||
/* initialize and then load the card */
|
||||
file.write(m_memcard_data, m_size);
|
||||
|
||||
/* close the file */
|
||||
m_memcard_inserted = -1;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
memcard_present - return the currently loaded
|
||||
card index, or -1 if none
|
||||
-------------------------------------------------*/
|
||||
|
||||
int memcard_device::present()
|
||||
{
|
||||
return m_memcard_inserted;
|
||||
}
|
||||
|
||||
|
||||
READ8_MEMBER(memcard_device::read)
|
||||
{
|
||||
return m_memcard_data[offset];
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(memcard_device::write)
|
||||
{
|
||||
m_memcard_data[offset] = data;
|
||||
}
|
82
src/emu/machine/memcard.h
Normal file
82
src/emu/machine/memcard.h
Normal file
@ -0,0 +1,82 @@
|
||||
/*********************************************************************
|
||||
|
||||
memcard.h
|
||||
|
||||
Memory card functions.
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __MEMCARD_H__
|
||||
#define __MEMCARD_H__
|
||||
|
||||
//**************************************************************************
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_MEMCARD_ADD(_tag,_size) \
|
||||
MCFG_DEVICE_ADD(_tag, MEMCARD, 0) \
|
||||
memcard_device::static_set_size(*device, _size);
|
||||
|
||||
/***************************************************************************
|
||||
CONSTANTS
|
||||
***************************************************************************/
|
||||
|
||||
/* memory card actions */
|
||||
#define MEMCARD_CREATE 0
|
||||
#define MEMCARD_INSERT 1
|
||||
#define MEMCARD_EJECT 2
|
||||
|
||||
/***************************************************************************
|
||||
FUNCTION PROTOTYPES
|
||||
***************************************************************************/
|
||||
|
||||
// ======================> memcard_device
|
||||
|
||||
class memcard_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
memcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
static void static_set_size(device_t &device, int value);
|
||||
|
||||
DECLARE_READ8_MEMBER(read);
|
||||
DECLARE_WRITE8_MEMBER(write);
|
||||
|
||||
/* create a new memory card with the given index */
|
||||
int create(int index, int overwrite);
|
||||
|
||||
/* "insert" a memory card with the given index and load its data */
|
||||
int insert(int index);
|
||||
|
||||
/* "eject" a memory card and save its data */
|
||||
void eject();
|
||||
|
||||
/* returns the index of the current memory card, or -1 if none */
|
||||
int present();
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_stop();
|
||||
|
||||
// memory card status
|
||||
int m_memcard_inserted;
|
||||
UINT8 *m_memcard_data;
|
||||
int m_size;
|
||||
};
|
||||
|
||||
|
||||
// device type definition
|
||||
extern const device_type MEMCARD;
|
||||
|
||||
// device iterator
|
||||
typedef device_type_iterator<&device_creator<memcard_device>, memcard_device> memcard_device_iterator;
|
||||
|
||||
|
||||
#endif /* __MEMCARD_H__ */
|
@ -16,7 +16,5 @@
|
||||
// core functions
|
||||
#define MCFG_NVRAM_HANDLER(_func) \
|
||||
config.m_nvram_handler = NVRAM_HANDLER_NAME(_func);
|
||||
#define MCFG_MEMCARD_HANDLER(_func) \
|
||||
config.m_memcard_handler = MEMCARD_HANDLER_NAME(_func);
|
||||
|
||||
#endif /* __MCFGLGCY_H__ */
|
||||
|
@ -26,7 +26,6 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
|
||||
m_watchdog_vblank_count(0),
|
||||
m_watchdog_time(attotime::zero),
|
||||
m_nvram_handler(NULL),
|
||||
m_memcard_handler(NULL),
|
||||
m_default_layout(NULL),
|
||||
m_gamedrv(gamedrv),
|
||||
m_options(options)
|
||||
|
@ -30,14 +30,8 @@
|
||||
#define NVRAM_HANDLER(name) void NVRAM_HANDLER_NAME(name)(running_machine &machine, emu_file *file, int read_or_write)
|
||||
#define NVRAM_HANDLER_CALL(name) NVRAM_HANDLER_NAME(name)(machine, file, read_or_write)
|
||||
|
||||
#define MEMCARD_HANDLER_NAME(name) memcard_handler_##name
|
||||
#define MEMCARD_HANDLER(name) void MEMCARD_HANDLER_NAME(name)(running_machine &machine, emu_file &file, int action)
|
||||
#define MEMCARD_HANDLER_CALL(name) MEMCARD_HANDLER_NAME(name)(machine, file, action)
|
||||
|
||||
|
||||
// NULL versions
|
||||
#define nvram_handler_0 NULL
|
||||
#define memcard_handler_0 NULL
|
||||
|
||||
|
||||
|
||||
@ -54,8 +48,6 @@ class screen_device;
|
||||
|
||||
// various callback functions
|
||||
typedef void (*nvram_handler_func)(running_machine &machine, emu_file *file, int read_or_write);
|
||||
typedef void (*memcard_handler_func)(running_machine &machine, emu_file &file, int action);
|
||||
|
||||
|
||||
|
||||
// ======================> machine_config
|
||||
@ -88,7 +80,6 @@ public:
|
||||
|
||||
// legacy callbacks
|
||||
nvram_handler_func m_nvram_handler; // NVRAM save/load callback
|
||||
memcard_handler_func m_memcard_handler; // memory card save/load callback
|
||||
|
||||
// other parameters
|
||||
const char * m_default_layout; // default layout for this machine
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "imagedev/cassette.h"
|
||||
#include "imagedev/bitbngr.h"
|
||||
#include "machine/bcreader.h"
|
||||
|
||||
#include "machine/memcard.h"
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@ -131,8 +131,11 @@ void ui_menu_main::populate()
|
||||
item_append("Cheat", NULL, 0, (void *)CHEAT);
|
||||
|
||||
/* add memory card menu */
|
||||
if (machine().config().m_memcard_handler != NULL)
|
||||
memcard_device_iterator memiter(machine().root_device());
|
||||
if (memiter.first() != NULL)
|
||||
{
|
||||
item_append("Memory Card", NULL, 0, (void *)MEMORY_CARD);
|
||||
}
|
||||
|
||||
/* add reset and exit menus */
|
||||
menu_text.printf("Select New %s",emulator_info::get_capstartgamenoun());
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <ctype.h>
|
||||
#include "imagedev/cassette.h"
|
||||
#include "imagedev/bitbngr.h"
|
||||
#include "machine/memcard.h"
|
||||
|
||||
|
||||
|
||||
@ -1492,6 +1493,8 @@ void ui_menu_memory_card::handle()
|
||||
{
|
||||
/* process the menu */
|
||||
const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT);
|
||||
memcard_device_iterator memiter(machine().root_device());
|
||||
memcard_device *memcard = memiter.first();
|
||||
|
||||
/* if something was selected, act on it */
|
||||
if (menu_event != NULL && menu_event->itemref != NULL)
|
||||
@ -1505,7 +1508,7 @@ void ui_menu_memory_card::handle()
|
||||
{
|
||||
/* handle card loading; if we succeed, clear the menus */
|
||||
case MEMCARD_ITEM_LOAD:
|
||||
if (memcard_insert(machine(), cardnum) == 0)
|
||||
if (memcard->insert(cardnum) == 0)
|
||||
{
|
||||
popmessage("Memory card loaded");
|
||||
ui_menu::stack_reset(machine());
|
||||
@ -1516,13 +1519,13 @@ void ui_menu_memory_card::handle()
|
||||
|
||||
/* handle card ejecting */
|
||||
case MEMCARD_ITEM_EJECT:
|
||||
memcard_eject(machine());
|
||||
memcard->eject();
|
||||
popmessage("Memory card ejected");
|
||||
break;
|
||||
|
||||
/* handle card creating */
|
||||
case MEMCARD_ITEM_CREATE:
|
||||
if (memcard_create(machine(), cardnum, false) == 0)
|
||||
if (memcard->create(cardnum, false) == 0)
|
||||
popmessage("Memory card created");
|
||||
else
|
||||
popmessage("Error creating memory card\n(Card may already exist)");
|
||||
@ -1563,6 +1566,8 @@ ui_menu_memory_card::ui_menu_memory_card(running_machine &machine, render_contai
|
||||
|
||||
void ui_menu_memory_card::populate()
|
||||
{
|
||||
memcard_device_iterator memiter(machine().root_device());
|
||||
memcard_device *memcard = memiter.first();
|
||||
char tempstring[20];
|
||||
UINT32 flags = 0;
|
||||
|
||||
@ -1576,7 +1581,7 @@ void ui_menu_memory_card::populate()
|
||||
|
||||
/* add the remaining items */
|
||||
item_append("Load Selected Card", NULL, 0, (void *)MEMCARD_ITEM_LOAD);
|
||||
if (memcard_present(machine()) != -1)
|
||||
if (memcard->present() != -1)
|
||||
item_append("Eject Current Card", NULL, 0, (void *)MEMCARD_ITEM_EJECT);
|
||||
item_append("Create New Card", NULL, 0, (void *)MEMCARD_ITEM_CREATE);
|
||||
}
|
||||
|
@ -773,14 +773,11 @@ WRITE16_MEMBER(neogeo_state::save_ram_w)
|
||||
*
|
||||
*************************************/
|
||||
|
||||
#define MEMCARD_SIZE 0x0800
|
||||
|
||||
|
||||
CUSTOM_INPUT_MEMBER(neogeo_state::get_memcard_status)
|
||||
{
|
||||
// D0 and D1 are memcard 1 and 2 presence indicators, D2 indicates memcard
|
||||
// write protect status (we are always write enabled)
|
||||
return (memcard_present(machine()) == -1) ? 0x07 : 0x00;
|
||||
return (m_memcard->present() == -1) ? 0x07 : 0x00;
|
||||
}
|
||||
|
||||
|
||||
@ -790,8 +787,8 @@ READ16_MEMBER(neogeo_state::memcard_r)
|
||||
|
||||
UINT16 ret;
|
||||
|
||||
if (memcard_present(machine()) != -1)
|
||||
ret = m_memcard_data[offset] | 0xff00;
|
||||
if (m_memcard->present() != -1)
|
||||
ret = m_memcard->read(space, offset) | 0xff00;
|
||||
else
|
||||
ret = 0xffff;
|
||||
|
||||
@ -805,34 +802,11 @@ WRITE16_MEMBER(neogeo_state::memcard_w)
|
||||
|
||||
if (ACCESSING_BITS_0_7)
|
||||
{
|
||||
if (memcard_present(machine()) != -1)
|
||||
m_memcard_data[offset] = data;
|
||||
if (m_memcard->present() != -1)
|
||||
m_memcard->write(space, offset, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MEMCARD_HANDLER( neogeo )
|
||||
{
|
||||
neogeo_state *state = machine.driver_data<neogeo_state>();
|
||||
switch (action)
|
||||
{
|
||||
case MEMCARD_CREATE:
|
||||
memset(state->m_memcard_data, 0, MEMCARD_SIZE);
|
||||
file.write(state->m_memcard_data, MEMCARD_SIZE);
|
||||
break;
|
||||
|
||||
case MEMCARD_INSERT:
|
||||
file.read(state->m_memcard_data, MEMCARD_SIZE);
|
||||
break;
|
||||
|
||||
case MEMCARD_EJECT:
|
||||
file.write(state->m_memcard_data, MEMCARD_SIZE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Inter-CPU communications
|
||||
@ -1138,9 +1112,6 @@ void neogeo_state::machine_start()
|
||||
|
||||
create_interrupt_timers();
|
||||
|
||||
/* initialize the memcard data structure */
|
||||
m_memcard_data = auto_alloc_array_clear(machine(), UINT8, MEMCARD_SIZE);
|
||||
|
||||
/* irq levels for MVS / AES */
|
||||
m_vblank_level = 1;
|
||||
m_raster_level = 2;
|
||||
@ -1166,7 +1137,6 @@ void neogeo_state::machine_start()
|
||||
save_item(NAME(m_controller_select));
|
||||
save_item(NAME(m_main_cpu_bank_address));
|
||||
save_item(NAME(m_save_ram_unlocked));
|
||||
save_pointer(NAME(m_memcard_data), 0x800);
|
||||
save_item(NAME(m_output_data));
|
||||
save_item(NAME(m_output_latch));
|
||||
save_item(NAME(m_el_value));
|
||||
@ -1835,7 +1805,7 @@ static MACHINE_CONFIG_DERIVED( neogeo, neogeo_base )
|
||||
MCFG_UPD4990A_ADD("upd4990a", XTAL_32_768kHz, NULL, NULL)
|
||||
|
||||
MCFG_NVRAM_ADD_0FILL("saveram")
|
||||
MCFG_MEMCARD_HANDLER(neogeo)
|
||||
MCFG_MEMCARD_ADD("memcard", 0x800)
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
static MACHINE_CONFIG_DERIVED( mvs, neogeo )
|
||||
|
@ -5,6 +5,7 @@
|
||||
*************************************************************************/
|
||||
|
||||
#include "machine/upd1990a.h"
|
||||
#include "machine/memcard.h"
|
||||
|
||||
#define NEOGEO_MASTER_CLOCK (24000000)
|
||||
#define NEOGEO_MAIN_CPU_CLOCK (NEOGEO_MASTER_CLOCK / 2)
|
||||
@ -37,7 +38,8 @@ public:
|
||||
m_upd4990a(*this, "upd4990a"),
|
||||
m_save_ram(*this, "saveram"),
|
||||
m_screen(*this, "screen"),
|
||||
m_palette(*this, "palette")
|
||||
m_palette(*this, "palette"),
|
||||
m_memcard(*this, "memcard")
|
||||
{ }
|
||||
|
||||
DECLARE_WRITE8_MEMBER(io_control_w);
|
||||
@ -141,10 +143,6 @@ public:
|
||||
DECLARE_INPUT_CHANGED_MEMBER(select_bios);
|
||||
|
||||
UINT32 screen_update_neogeo(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
|
||||
// this has to be public for the legacy MEMCARD_HANDLER
|
||||
UINT8 *m_memcard_data;
|
||||
|
||||
protected:
|
||||
void neogeo_postload();
|
||||
void update_interrupts();
|
||||
@ -333,7 +331,8 @@ protected:
|
||||
|
||||
required_device<screen_device> m_screen;
|
||||
optional_device<palette_device> m_palette;
|
||||
|
||||
optional_device<memcard_device> m_memcard;
|
||||
|
||||
// configuration
|
||||
enum {NEOGEO_MVS, NEOGEO_AES, NEOGEO_CD} m_type;
|
||||
|
||||
@ -423,4 +422,3 @@ protected:
|
||||
/*----------- defined in drivers/neogeo.c -----------*/
|
||||
|
||||
MACHINE_CONFIG_EXTERN( neogeo_base );
|
||||
MEMCARD_HANDLER( neogeo );
|
||||
|
@ -194,6 +194,7 @@ public:
|
||||
|
||||
IRQ_CALLBACK_MEMBER(neocd_int_callback);
|
||||
|
||||
UINT8 *m_meminternal_data;
|
||||
protected:
|
||||
required_ioport m_io_in2;
|
||||
required_ioport m_io_in0;
|
||||
@ -229,7 +230,7 @@ protected:
|
||||
/* The NeoCD has an 8kB internal memory card, instead of memcard slots like the MVS and AES */
|
||||
READ16_MEMBER(ng_aes_state::neocd_memcard_r)
|
||||
{
|
||||
return m_memcard_data[offset] | 0xff00;
|
||||
return m_meminternal_data[offset] | 0xff00;
|
||||
}
|
||||
|
||||
|
||||
@ -237,7 +238,7 @@ WRITE16_MEMBER(ng_aes_state::neocd_memcard_w)
|
||||
{
|
||||
if (ACCESSING_BITS_0_7)
|
||||
{
|
||||
m_memcard_data[offset] = data;
|
||||
m_meminternal_data[offset] = data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1021,10 +1022,6 @@ MACHINE_START_MEMBER(ng_aes_state,neogeo)
|
||||
{
|
||||
m_type = NEOGEO_AES;
|
||||
common_machine_start();
|
||||
|
||||
/* initialize the memcard data structure */
|
||||
m_memcard_data = auto_alloc_array_clear(machine(), UINT8, MEMCARD_SIZE);
|
||||
save_pointer(NAME(m_memcard_data), 0x800);
|
||||
}
|
||||
|
||||
MACHINE_START_MEMBER(ng_aes_state,neocd)
|
||||
@ -1038,9 +1035,9 @@ MACHINE_START_MEMBER(ng_aes_state,neocd)
|
||||
|
||||
/* initialize the memcard data structure */
|
||||
/* NeoCD doesn't have memcard slots, rather, it has a larger internal memory which works the same */
|
||||
m_memcard_data = auto_alloc_array_clear(machine(), UINT8, 0x2000);
|
||||
machine().device<nvram_device>("saveram")->set_base(m_memcard_data, 0x2000);
|
||||
save_pointer(NAME(m_memcard_data), 0x2000);
|
||||
m_meminternal_data = auto_alloc_array_clear(machine(), UINT8, 0x2000);
|
||||
machine().device<nvram_device>("saveram")->set_base(m_meminternal_data, 0x2000);
|
||||
save_pointer(NAME(m_meminternal_data), 0x2000);
|
||||
|
||||
// for custom vectors
|
||||
m_maincpu->set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(ng_aes_state::neocd_int_callback),this));
|
||||
@ -1376,7 +1373,7 @@ static MACHINE_CONFIG_DERIVED_CLASS( aes, neogeo_base, ng_aes_state )
|
||||
MCFG_CPU_MODIFY("maincpu")
|
||||
MCFG_CPU_PROGRAM_MAP(aes_main_map)
|
||||
|
||||
MCFG_MEMCARD_HANDLER(neogeo)
|
||||
MCFG_MEMCARD_ADD("memcard", 0x800)
|
||||
|
||||
MCFG_MACHINE_START_OVERRIDE(ng_aes_state, neogeo)
|
||||
MCFG_MACHINE_RESET_OVERRIDE(ng_aes_state, neogeo)
|
||||
|
Loading…
Reference in New Issue
Block a user