Changed device name from an overridable function to a parameter passed to

the device_config constructor. In situations where the proper name is not 
known at construction time, a generic name can be specified and then 
overridden later once the configuration is complete.
This commit is contained in:
Aaron Giles 2010-06-25 15:30:51 +00:00
parent 25c5511610
commit 50767de707
34 changed files with 37 additions and 71 deletions

View File

@ -49,8 +49,8 @@
// cpu_device_config - constructor
//-------------------------------------------------
cpu_device_config::cpu_device_config(const machine_config &mconfig, device_type _type, const char *_tag, const device_config *_owner, UINT32 _clock)
: device_config(mconfig, _type, _tag, _owner, _clock),
cpu_device_config::cpu_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, type, name, tag, owner, clock),
device_config_execute_interface(mconfig, *this),
device_config_memory_interface(mconfig, *this),
device_config_state_interface(mconfig, *this),
@ -63,8 +63,8 @@ cpu_device_config::cpu_device_config(const machine_config &mconfig, device_type
// legacy_cpu_device_config - constructor
//-------------------------------------------------
legacy_cpu_device_config::legacy_cpu_device_config(const machine_config &mconfig, device_type _type, const char *_tag, const device_config *_owner, UINT32 _clock)
: cpu_device_config(mconfig, _type, _tag, _owner, _clock),
legacy_cpu_device_config::legacy_cpu_device_config(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock)
: cpu_device_config(mconfig, type, "CPU", tag, owner, clock),
m_cputype(NULL)
{
memset(m_space_config, 0, sizeof(m_space_config));
@ -119,6 +119,7 @@ bool legacy_cpu_device_config::device_process_token(UINT32 entrytype, const mach
m_space_config[spacenum].m_internal_map = reinterpret_cast<const addrmap_token *>(get_legacy_config_ptr(DEVINFO_PTR_INTERNAL_MEMORY_MAP + spacenum));
m_space_config[spacenum].m_default_map = reinterpret_cast<const addrmap_token *>(get_legacy_config_ptr(DEVINFO_PTR_DEFAULT_MEMORY_MAP + spacenum));
}
m_name = get_legacy_config_string(DEVINFO_STR_NAME);
return true;
}

View File

@ -413,7 +413,7 @@ class cpu_device_config : public device_config,
protected:
// construction/destruction
cpu_device_config(const machine_config &mconfig, device_type _type, const char *_tag, const device_config *_owner, UINT32 _clock);
cpu_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock);
};
@ -433,7 +433,6 @@ public:
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return get_legacy_config_string(DEVINFO_STR_NAME); }
virtual const rom_entry *rom_region() const { return reinterpret_cast<const rom_entry *>(get_legacy_config_ptr(DEVINFO_PTR_ROM_REGION)); }
virtual const machine_config_token *machine_config_tokens() const { return reinterpret_cast<const machine_config_token *>(get_legacy_config_ptr(DEVINFO_PTR_MACHINE_CONFIG)); }

View File

@ -301,7 +301,7 @@ bool device_config_interface::interface_validity_check(const game_driver &driver
// device configuration
//-------------------------------------------------
device_config::device_config(const machine_config &mconfig, device_type type, const char *_tag, const device_config *owner, UINT32 clock)
device_config::device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock)
: m_next(NULL),
m_owner(const_cast<device_config *>(owner)),
m_interface_list(NULL),
@ -309,7 +309,8 @@ device_config::device_config(const machine_config &mconfig, device_type type, co
m_clock(clock),
m_machine_config(mconfig),
m_static_config(NULL),
m_tag(_tag)
m_name(name),
m_tag(tag)
{
memset(m_inline_data, 0, sizeof(m_inline_data));

View File

@ -230,7 +230,7 @@ class device_config
protected:
// construction/destruction
device_config(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock);
device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock);
virtual ~device_config();
public:
@ -256,6 +256,7 @@ public:
// basic information getters
device_type type() const { return m_type; }
UINT32 clock() const { return m_clock; }
const char *name() const { return m_name; }
const char *tag() const { return m_tag; }
const void *static_config() const { return m_static_config; }
@ -275,10 +276,7 @@ protected:
virtual void device_config_complete();
virtual bool device_validity_check(const game_driver &driver) const;
// required information overrides
public:
virtual const char *name() const = 0;
// optional information overrides
virtual const rom_entry *rom_region() const;
virtual const machine_config_token *machine_config_tokens() const;
@ -298,6 +296,8 @@ protected:
const void * m_static_config; // static device configuration
UINT64 m_inline_data[16]; // array of inline configuration values
astring m_name; // name of the device
private:
astring m_tag; // tag for this instance
};

View File

@ -50,7 +50,7 @@
//-------------------------------------------------
legacy_device_config_base::legacy_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config)
: device_config(mconfig, type, tag, owner, clock),
: device_config(mconfig, type, "Legacy Device", tag, owner, clock),
m_get_config_func(get_config),
m_inline_config(NULL)
{
@ -58,6 +58,9 @@ legacy_device_config_base::legacy_device_config_base(const machine_config &mconf
UINT32 configlen = (UINT32)get_legacy_config_int(DEVINFO_INT_INLINE_CONFIG_BYTES);
if (configlen != 0)
m_inline_config = global_alloc_array_clear(UINT8, configlen);
// set the proper name
m_name = get_legacy_config_string(DEVINFO_STR_NAME);
}

View File

@ -430,7 +430,6 @@ protected:
// basic information getters
public:
virtual const char *name() const { return get_legacy_config_string(DEVINFO_STR_NAME); }
virtual const rom_entry *rom_region() const { return reinterpret_cast<const rom_entry *>(get_legacy_config_ptr(DEVINFO_PTR_ROM_REGION)); }
virtual const machine_config_token *machine_config_tokens() const { return reinterpret_cast<const machine_config_token *>(get_legacy_config_ptr(DEVINFO_PTR_MACHINE_CONFIG)); }
@ -577,7 +576,6 @@ class legacy_image_device_config_base : public legacy_device_config_base,
public device_config_image_interface
{
public:
virtual const char *name() const { return get_legacy_config_string(DEVINFO_STR_NAME); }
virtual iodevice_t image_type() const { return m_type; }
virtual const char *image_type_name() const { return device_typename(m_type); }
virtual iodevice_t image_type_direct() const { return static_cast<iodevice_t>(get_legacy_config_int(DEVINFO_INT_IMAGE_TYPE)); }

View File

@ -149,7 +149,6 @@ public:
virtual ~device_config_image_interface();
// public accessors... for now
virtual const char *name() const = 0;
virtual iodevice_t image_type() const = 0;
virtual const char *image_type_name() const = 0;
virtual iodevice_t image_type_direct() const = 0;

View File

@ -234,7 +234,7 @@ void image_device_init(running_machine *machine)
image_unload_all(machine);
fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s",
image->image_config().name(),
image->image_config().devconfig().name(),
image_basename_str,
image_err);
}
@ -274,7 +274,7 @@ void image_postdevice_init(running_machine *machine)
image_unload_all(machine);
fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s",
image->image_config().name(),
image->image_config().devconfig().name(),
image_basename_str,
image_err);
}
@ -405,7 +405,7 @@ astring *image_info_astring(running_machine *machine, astring *string)
base_filename_noextension = strip_extension(base_filename);
/* display device type and filename */
astring_catprintf(string, "%s: %s\n", image->image_config().name(), base_filename);
astring_catprintf(string, "%s: %s\n", image->image_config().devconfig().name(), base_filename);
/* display long filename, if present and doesn't correspond to name */
info = image->longname();
@ -433,7 +433,7 @@ astring *image_info_astring(running_machine *machine, astring *string)
}
else
{
astring_catprintf(string, "%s: ---\n", image->image_config().name());
astring_catprintf(string, "%s: ---\n", image->image_config().devconfig().name());
}
}
return string;

View File

@ -75,7 +75,7 @@ ADDRESS_MAP_END
//-------------------------------------------------
eeprom_device_config::eeprom_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "EEPROM", tag, owner, clock),
device_config_memory_interface(mconfig, *this),
device_config_nvram_interface(mconfig, *this),
m_default_data(NULL),

View File

@ -76,9 +76,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "EEPROM"; }
// inline configuration indexes
enum
{

View File

@ -77,7 +77,7 @@ const int WAITING_FOR_TRIG = 0x100;
//-------------------------------------------------
z80ctc_device_config::z80ctc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "Zilog Z80 CTC", tag, owner, clock),
device_config_z80daisy_interface(mconfig, *this)
{
}

View File

@ -72,9 +72,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "Zilog Z80 CTC"; }
protected:
// device_config overrides
virtual void device_config_complete();

View File

@ -150,7 +150,7 @@ const int Z80DART_WR5_DTR = 0x80;
//-------------------------------------------------
z80dart_device_config::z80dart_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "Zilog Z80 DART", tag, owner, clock),
device_config_z80daisy_interface(mconfig, *this)
{
}

View File

@ -111,9 +111,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "Zilog Z80 DART"; }
protected:
// device_config overrides
virtual void device_config_complete();

View File

@ -142,7 +142,7 @@ const int TM_SEARCH_TRANSFER = 0x03;
//-------------------------------------------------
z80dma_device_config::z80dma_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "Z8410", tag, owner, clock),
device_config_z80daisy_interface(mconfig, *this)
{
}

View File

@ -89,9 +89,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "Z8410"; }
protected:
// device_config overrides
virtual void device_config_complete();

View File

@ -54,7 +54,7 @@ const int ICW_MASK_FOLLOWS = 0x10;
//-------------------------------------------------
z80pio_device_config::z80pio_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "Z8420", tag, owner, clock),
device_config_z80daisy_interface(mconfig, *this)
{
}

View File

@ -87,9 +87,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "Z8420"; }
protected:
// device_config overrides
virtual void device_config_complete();

View File

@ -295,7 +295,7 @@ inline attotime z80sio_device::sio_channel::compute_time_per_character()
//-------------------------------------------------
z80sio_device_config::z80sio_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "Zilog Z80 SIO", tag, owner, clock),
device_config_z80daisy_interface(mconfig, *this)
{
}

View File

@ -58,9 +58,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "Zilog Z80 SIO"; }
protected:
// device_config overrides
virtual void device_config_complete();

View File

@ -144,7 +144,7 @@ static const int PRESCALER[] = { 0, 4, 10, 16, 50, 64, 100, 200 };
//-------------------------------------------------
z80sti_device_config::z80sti_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "Mostek MK3801", tag, owner, clock),
device_config_z80daisy_interface(mconfig, *this)
{
}

View File

@ -106,9 +106,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "Mostek MK3801"; }
protected:
// device_config overrides
virtual void device_config_complete();

View File

@ -461,7 +461,7 @@ static TIMER_CALLBACK( sound_update )
//-------------------------------------------------
speaker_device_config::speaker_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "Speaker", tag, owner, clock),
m_x(0.0),
m_y(0.0),
m_z(0.0)

View File

@ -49,9 +49,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "Speaker"; }
// indexes to inline data
enum
{

View File

@ -88,7 +88,7 @@ ADDRESS_MAP_END
//-------------------------------------------------
okim6295_device_config::okim6295_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "OKI6295", tag, owner, clock),
device_config_sound_interface(mconfig, *this),
device_config_memory_interface(mconfig, *this),
m_space_config("samples", ENDIANNESS_LITTLE, 8, 18, 0, NULL, *ADDRESS_MAP_NAME(okim6295))

View File

@ -89,9 +89,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "OKI6295"; }
// inline configuration indexes
enum
{

View File

@ -939,7 +939,7 @@ void timer_print_first_timer(running_machine *machine)
//-------------------------------------------------
timer_device_config::timer_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "Timer", tag, owner, clock),
m_type(TIMER_TYPE_GENERIC),
m_callback(NULL),
m_ptr(NULL),

View File

@ -233,9 +233,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "Timer"; }
// indexes to inline data
enum
{

View File

@ -898,7 +898,7 @@ static void menu_file_manager_populate(running_machine *machine, ui_menu *menu,
/* get the image type/id */
snprintf(buffer, ARRAY_LENGTH(buffer),
"%s",
image->image_config().name());
image->image_config().devconfig().name());
/* get the base name */
entry_basename = image->basename();

View File

@ -1688,7 +1688,7 @@ const attotime screen_device::k_default_frame_period = STATIC_ATTOTIME_IN_HZ(k_d
//-------------------------------------------------
screen_device_config::screen_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "Video Screen", tag, owner, clock),
m_type(SCREEN_TYPE_RASTER),
m_width(0),
m_height(0),

View File

@ -94,9 +94,6 @@ public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
// basic information getters
virtual const char *name() const { return "Video Screen"; }
// configuration readers
screen_type_enum screen_type() const { return m_type; }
int width() const { return m_width; }

View File

@ -172,7 +172,6 @@ public:
return auto_alloc(&machine, littlerb_vdp_device(machine, *this));
}
virtual const char *name() const { return "LITTLERBVDP"; }
protected:
virtual const address_space_config *memory_space_config(int spacenum = 0) const
{
@ -190,7 +189,7 @@ littlerb_vdp_device::littlerb_vdp_device(running_machine &_machine, const little
}
littlerb_vdp_device_config::littlerb_vdp_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "LITTLERBVDP", tag, owner, clock),
device_config_memory_interface(mconfig, *this),
m_space_config("littlerb_vdp", ENDIANNESS_LITTLE, 16,32, 0, NULL, *ADDRESS_MAP_NAME(littlerb_vdp_map8))
{

View File

@ -72,7 +72,6 @@ class janshi_vdp_device_config : public device_config,
public:
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
virtual device_t *alloc_device(running_machine &machine) const;
virtual const char *name() const { return "JANSHIVDP"; }
protected:
virtual void device_config_complete();
virtual bool device_validity_check(const game_driver &driver) const;
@ -95,7 +94,7 @@ protected:
const device_type JANSHIVDP = janshi_vdp_device_config::static_alloc_device_config;
janshi_vdp_device_config::janshi_vdp_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, tag, owner, clock),
: device_config(mconfig, static_alloc_device_config, "JANSHIVDP", tag, owner, clock),
device_config_memory_interface(mconfig, *this),
m_space_config("janshi_vdp", ENDIANNESS_LITTLE, 8,24, 0, NULL, *ADDRESS_MAP_NAME(janshi_vdp_map8))
{

View File

@ -1778,7 +1778,7 @@ static void memory_create_window(running_machine *machine)
for (const debug_view_source *source = info->view[0].view->source_list().head(); source != NULL; source = source->next())
{
TCHAR *t_name = tstring_from_utf8(source->name());
int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name);
SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name);
osd_free(t_name);
}
const debug_view_source *source = info->view[0].view->source_list().match_device(curcpu);
@ -2085,7 +2085,7 @@ static void disasm_create_window(running_machine *machine)
for (const debug_view_source *source = info->view[0].view->source_list().head(); source != NULL; source = source->next())
{
TCHAR *t_name = tstring_from_utf8(source->name());
int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name);
SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name);
osd_free(t_name);
}
const debug_view_source *source = info->view[0].view->source_list().match_device(curcpu);