made neogeo card an image device (nw)

This commit is contained in:
Miodrag Milanovic 2014-04-17 13:16:05 +00:00
parent cb62b01e3b
commit 78f658987f
15 changed files with 173 additions and 420 deletions

4
.gitattributes vendored
View File

@ -2497,8 +2497,6 @@ 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
@ -6563,6 +6561,8 @@ src/mame/machine/nb1414m4.c svneol=native#text/plain
src/mame/machine/neoboot.c svneol=native#text/plain
src/mame/machine/neocrypt.c svneol=native#text/plain
src/mame/machine/neoprot.c svneol=native#text/plain
src/mame/machine/ng_memcard.c svneol=native#text/plain
src/mame/machine/ng_memcard.h svneol=native#text/plain
src/mame/machine/nitedrvr.c svneol=native#text/plain
src/mame/machine/nmk004.c svneol=native#text/plain
src/mame/machine/nmk004.h svneol=native#text/plain

View File

@ -167,7 +167,6 @@ EMUMACHINEOBJS = \
$(EMUMACHINE)/keyboard.o \
$(EMUMACHINE)/laserdsc.o \
$(EMUMACHINE)/latch.o \
$(EMUMACHINE)/memcard.o \
$(EMUMACHINE)/netlist.o \
$(EMUMACHINE)/nvram.o \
$(EMUMACHINE)/ram.o \

View File

@ -1,191 +0,0 @@
/*********************************************************************
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;
}

View File

@ -1,82 +0,0 @@
/*********************************************************************
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__ */

View File

@ -30,7 +30,6 @@
#include "imagedev/cassette.h"
#include "imagedev/bitbngr.h"
#include "machine/bcreader.h"
#include "machine/memcard.h"
/***************************************************************************
@ -130,13 +129,6 @@ void ui_menu_main::populate()
if (machine().options().cheat() && machine().cheat().first() != NULL)
item_append("Cheat", NULL, 0, (void *)CHEAT);
/* add memory card menu */
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());
item_append(menu_text.cstr(), NULL, 0, (void *)SELECT_GAME);
@ -228,10 +220,6 @@ void ui_menu_main::handle()
ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_cheat(machine(), container)));
break;
case MEMORY_CARD:
ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_memory_card(machine(), container)));
break;
case SELECT_GAME:
ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, 0)));
break;

View File

@ -44,7 +44,6 @@ private:
VIDEO_OPTIONS,
CROSSHAIR,
CHEAT,
MEMORY_CARD,
SELECT_GAME,
BIOS_SELECTION,
BARCODE_READ,

View File

@ -23,7 +23,6 @@
#include <ctype.h>
#include "imagedev/cassette.h"
#include "imagedev/bitbngr.h"
#include "machine/memcard.h"
@ -1484,112 +1483,6 @@ ui_menu_cheat::~ui_menu_cheat()
{
}
/*-------------------------------------------------
menu_memory_card - handle the memory card
menu
-------------------------------------------------*/
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)
{
FPTR item = (FPTR)menu_event->itemref;
/* select executes actions on some of the items */
if (menu_event->iptkey == IPT_UI_SELECT)
{
switch (item)
{
/* handle card loading; if we succeed, clear the menus */
case MEMCARD_ITEM_LOAD:
if (memcard->insert(cardnum) == 0)
{
popmessage("Memory card loaded");
ui_menu::stack_reset(machine());
}
else
popmessage("Error loading memory card");
break;
/* handle card ejecting */
case MEMCARD_ITEM_EJECT:
memcard->eject();
popmessage("Memory card ejected");
break;
/* handle card creating */
case MEMCARD_ITEM_CREATE:
if (memcard->create(cardnum, false) == 0)
popmessage("Memory card created");
else
popmessage("Error creating memory card\n(Card may already exist)");
break;
}
}
/* the select item has extra keys */
else if (item == MEMCARD_ITEM_SELECT)
{
switch (menu_event->iptkey)
{
/* left decrements the card number */
case IPT_UI_LEFT:
cardnum -= 1;
reset(UI_MENU_RESET_REMEMBER_REF);
break;
/* right decrements the card number */
case IPT_UI_RIGHT:
cardnum += 1;
reset(UI_MENU_RESET_REMEMBER_REF);
break;
}
}
}
}
/*-------------------------------------------------
menu_memory_card_populate - populate the
memory card menu
-------------------------------------------------*/
ui_menu_memory_card::ui_menu_memory_card(running_machine &machine, render_container *container) : ui_menu(machine, container)
{
}
void ui_menu_memory_card::populate()
{
memcard_device_iterator memiter(machine().root_device());
memcard_device *memcard = memiter.first();
char tempstring[20];
UINT32 flags = 0;
/* add the card select menu */
sprintf(tempstring, "%d", cardnum);
if (cardnum > 0)
flags |= MENU_FLAG_LEFT_ARROW;
if (cardnum < 1000)
flags |= MENU_FLAG_RIGHT_ARROW;
item_append("Card Number:", tempstring, flags, (void *)MEMCARD_ITEM_SELECT);
/* add the remaining items */
item_append("Load Selected Card", NULL, 0, (void *)MEMCARD_ITEM_LOAD);
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);
}
ui_menu_memory_card::~ui_menu_memory_card()
{
}
/*-------------------------------------------------
menu_sliders - handle the sliders menu
-------------------------------------------------*/

View File

@ -213,24 +213,6 @@ public:
virtual void handle();
};
class ui_menu_memory_card : public ui_menu {
public:
ui_menu_memory_card(running_machine &machine, render_container *container);
virtual ~ui_menu_memory_card();
virtual void populate();
virtual void handle();
private:
enum {
MEMCARD_ITEM_SELECT = 1,
MEMCARD_ITEM_LOAD,
MEMCARD_ITEM_EJECT,
MEMCARD_ITEM_CREATE
};
int cardnum;
};
class ui_menu_sliders : public ui_menu {
public:
ui_menu_sliders(running_machine &machine, render_container *container, bool menuless_mode = false);

View File

@ -443,7 +443,6 @@
#include "cpu/z80/z80.h"
#include "sound/2610intf.h"
#include "imagedev/cartslot.h"
#include "mcfglgcy.h"
#include "neogeo.lh"
@ -1805,7 +1804,7 @@ static MACHINE_CONFIG_DERIVED( neogeo, neogeo_base )
MCFG_UPD4990A_ADD("upd4990a", XTAL_32_768kHz, NULL, NULL)
MCFG_NVRAM_ADD_0FILL("saveram")
MCFG_MEMCARD_ADD("memcard", 0x800)
MCFG_NEOGEO_MEMCARD_ADD("memcard")
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( mvs, neogeo )

View File

@ -5,7 +5,7 @@
*************************************************************************/
#include "machine/upd1990a.h"
#include "machine/memcard.h"
#include "machine/ng_memcard.h"
#define NEOGEO_MASTER_CLOCK (24000000)
#define NEOGEO_MAIN_CPU_CLOCK (NEOGEO_MASTER_CLOCK / 2)
@ -331,7 +331,7 @@ protected:
required_device<screen_device> m_screen;
optional_device<palette_device> m_palette;
optional_device<memcard_device> m_memcard;
optional_device<ng_memcard_device> m_memcard;
// configuration
enum {NEOGEO_MVS, NEOGEO_AES, NEOGEO_CD} m_type;

View File

@ -0,0 +1,96 @@
/*********************************************************************
ng_memcard.c
NEOGEO 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 "ng_memcard.h"
// device type definition
const device_type NG_MEMCARD = &device_creator<ng_memcard_device>;
//-------------------------------------------------
// ng_memcard_device - constructor
//-------------------------------------------------
ng_memcard_device::ng_memcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, NG_MEMCARD, "NEOGEO Memory Card", tag, owner, clock, "ng_memcard", __FILE__),
device_image_interface(mconfig, *this)
{
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void ng_memcard_device::device_config_complete()
{
// set brief and instance name
update_names();
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void ng_memcard_device::device_start()
{
save_item(NAME(m_memcard_data));
}
/*-------------------------------------------------
memcard_insert - insert an existing memory card
with the given index
-------------------------------------------------*/
bool ng_memcard_device::call_load()
{
if(length() != 0x800)
return IMAGE_INIT_FAIL;
fseek(0, SEEK_SET);
size_t ret = fread(m_memcard_data, 0x800);
if(ret != 0x800)
return IMAGE_INIT_FAIL;
return IMAGE_INIT_PASS;
}
void ng_memcard_device::call_unload()
{
fseek(0, SEEK_SET);
fwrite(m_memcard_data, 0x800);
}
bool ng_memcard_device::call_create(int format_type, option_resolution *format_options)
{
memset(m_memcard_data, 0, 0x800);
size_t ret = fwrite(m_memcard_data, 0x800);
if(ret != 0x800)
return IMAGE_INIT_FAIL;
return IMAGE_INIT_PASS;
}
READ8_MEMBER(ng_memcard_device::read)
{
return m_memcard_data[offset];
}
WRITE8_MEMBER(ng_memcard_device::write)
{
m_memcard_data[offset] = data;
}

View File

@ -0,0 +1,69 @@
/*********************************************************************
ng_memcard.h
NEOGEO Memory card functions.
Copyright Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
*********************************************************************/
#pragma once
#ifndef __NG_MEMCARD_H__
#define __NG_MEMCARD_H__
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_NEOGEO_MEMCARD_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, NG_MEMCARD, 0)
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
// ======================> ng_memcard_device
class ng_memcard_device : public device_t,
public device_image_interface
{
public:
// construction/destruction
ng_memcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
virtual iodevice_t image_type() const { return IO_MEMCARD; }
virtual bool is_readable() const { return 1; }
virtual bool is_writeable() const { return 1; }
virtual bool is_creatable() const { return 1; }
virtual bool must_be_loaded() const { return 0; }
virtual bool is_reset_on_load() const { return 0; }
virtual const char *file_extensions() const { return "neo"; }
virtual const option_guide *create_option_guide() const { return NULL; }
virtual bool call_load();
virtual void call_unload();
virtual bool call_create(int format_type, option_resolution *format_options);
// device-level overrides
virtual void device_start();
virtual void device_config_complete();
DECLARE_READ8_MEMBER(read);
DECLARE_WRITE8_MEMBER(write);
/* returns the index of the current memory card, or -1 if none */
int present() { return is_loaded() ? 0 : -1; }
private:
UINT8 m_memcard_data[0x800];
};
// device type definition
extern const device_type NG_MEMCARD;
#endif /* __NG_MEMCARD_H__ */

View File

@ -1394,6 +1394,7 @@ $(MAMEOBJ)/neogeo.a: \
$(MACHINE)/neoboot.o \
$(MACHINE)/neocrypt.o \
$(MACHINE)/neoprot.o \
$(MACHINE)/ng_memcard.o \
$(MAMEOBJ)/nichibut.a: \
$(DRIVERS)/armedf.o $(VIDEO)/armedf.o \

View File

@ -57,7 +57,6 @@
#include "imagedev/chd_cd.h"
#include "sound/cdda.h"
#include "machine/megacdcd.h"
#include "mcfglgcy.h"
extern const char layout_neogeo[];
@ -1373,7 +1372,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_ADD("memcard", 0x800)
MCFG_NEOGEO_MEMCARD_ADD("memcard")
MCFG_MACHINE_START_OVERRIDE(ng_aes_state, neogeo)
MCFG_MACHINE_RESET_OVERRIDE(ng_aes_state, neogeo)

View File

@ -823,6 +823,7 @@ $(MESSOBJ)/mame.a: \
$(MAME_VIDEO)/neogeo.o \
$(MAME_MACHINE)/neoprot.o \
$(MAME_MACHINE)/neocrypt.o \
$(MAME_MACHINE)/ng_memcard.o \
$(MAME_DRIVERS)/cdi.o \
$(MAME_MACHINE)/cdi070.o \
$(MAME_MACHINE)/cdicdic.o \