diff --git a/.gitattributes b/.gitattributes index eb432259418..7dceb321d95 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1224,7 +1224,6 @@ src/emu/tilemap.c svneol=native#text/plain src/emu/tilemap.h svneol=native#text/plain src/emu/timer.c svneol=native#text/plain src/emu/timer.h svneol=native#text/plain -src/emu/tokenize.h svneol=native#text/plain src/emu/ui.c svneol=native#text/plain src/emu/ui.h svneol=native#text/plain src/emu/uigfx.c svneol=native#text/plain diff --git a/src/emu/crsshair.c b/src/emu/crsshair.c index 38a37a6cf36..40bd09a6445 100644 --- a/src/emu/crsshair.c +++ b/src/emu/crsshair.c @@ -220,8 +220,8 @@ void crosshair_init(running_machine &machine) global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT; /* determine who needs crosshairs */ - for (const input_port_config *port = machine.m_portlist.first(); port != NULL; port = port->next()) - for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next) + for (input_port_config *port = machine.m_portlist.first(); port != NULL; port = port->next()) + for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next()) if (field->crossaxis != CROSSHAIR_AXIS_NONE) { int player = field->player; diff --git a/src/emu/devcpu.h b/src/emu/devcpu.h index fecc9dd9bdc..f77ce912609 100644 --- a/src/emu/devcpu.h +++ b/src/emu/devcpu.h @@ -368,7 +368,7 @@ protected: // device-level overrides virtual const rom_entry *device_rom_region() const { return reinterpret_cast(get_legacy_ptr(DEVINFO_PTR_ROM_REGION)); } virtual machine_config_constructor device_mconfig_additions() const { return reinterpret_cast(get_legacy_ptr(DEVINFO_PTR_MACHINE_CONFIG)); } - virtual const input_port_token *device_input_ports() const { return reinterpret_cast(get_legacy_ptr(DEVINFO_PTR_INPUT_PORTS)); } + virtual ioport_constructor device_input_ports() const { return reinterpret_cast(get_legacy_ptr(DEVINFO_PTR_INPUT_PORTS)); } virtual void device_start(); virtual void device_reset(); virtual void device_stop(); diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index c2e757d0ab6..26edada5c8b 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -809,7 +809,7 @@ machine_config_constructor device_t::device_mconfig_additions() const // input ports description for this device //------------------------------------------------- -const input_port_token *device_t::device_input_ports() const +ioport_constructor device_t::device_input_ports() const { // none by default return NULL; diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index c0141209296..2c23399267d 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -93,7 +93,6 @@ class device_state_interface; struct rom_entry; class machine_config; class emu_timer; -typedef union _input_port_token input_port_token; typedef struct _input_device_default input_device_default; @@ -207,7 +206,7 @@ public: const input_device_default *input_ports_defaults() const { return m_input_defaults; } const rom_entry *rom_region() const { return device_rom_region(); } machine_config_constructor machine_config_additions() const { return device_mconfig_additions(); } - const input_port_token *input_ports() const { return device_input_ports(); } + ioport_constructor input_ports() const { return device_input_ports(); } // iteration helpers device_t *next() const { return m_next; } @@ -296,7 +295,7 @@ protected: // device-level overrides virtual const rom_entry *device_rom_region() const; virtual machine_config_constructor device_mconfig_additions() const; - virtual const input_port_token *device_input_ports() const; + virtual ioport_constructor device_input_ports() const; virtual void device_config_complete(); virtual bool device_validity_check(emu_options &options, const game_driver &driver) const; virtual void device_start() = 0; diff --git a/src/emu/devlegcy.h b/src/emu/devlegcy.h index 14d0b104935..38e99db407d 100644 --- a/src/emu/devlegcy.h +++ b/src/emu/devlegcy.h @@ -390,7 +390,7 @@ union deviceinfo device_nvram_func nvram; // DEVINFO_FCT_NVRAM const rom_entry * romregion; // DEVINFO_PTR_ROM_REGION machine_config_constructor machine_config; // DEVINFO_PTR_MACHINE_CONFIG - const input_port_token *ipt; // DEVINFO_PTR_INPUT_PORTS + ioport_constructor ipt; // DEVINFO_PTR_INPUT_PORTS address_map_constructor internal_map8; // DEVINFO_PTR_INTERNAL_MEMORY_MAP address_map_constructor internal_map16; // DEVINFO_PTR_INTERNAL_MEMORY_MAP address_map_constructor internal_map32; // DEVINFO_PTR_INTERNAL_MEMORY_MAP @@ -428,7 +428,7 @@ protected: // device-level overrides virtual const rom_entry *device_rom_region() const { return reinterpret_cast(get_legacy_ptr(DEVINFO_PTR_ROM_REGION)); } virtual machine_config_constructor device_mconfig_additions() const { return reinterpret_cast(get_legacy_ptr(DEVINFO_PTR_MACHINE_CONFIG)); } - virtual const input_port_token *device_input_ports() const { return reinterpret_cast(get_legacy_ptr(DEVINFO_PTR_INPUT_PORTS)); } + virtual ioport_constructor device_input_ports() const { return reinterpret_cast(get_legacy_ptr(DEVINFO_PTR_INPUT_PORTS)); } virtual bool device_validity_check(emu_options &options, const game_driver &driver) const; virtual void device_start(); virtual void device_reset(); diff --git a/src/emu/driver.h b/src/emu/driver.h index bdb3544309f..3e66e7fee39 100644 --- a/src/emu/driver.h +++ b/src/emu/driver.h @@ -100,7 +100,7 @@ struct game_driver const char * year; /* year the game was released */ const char * manufacturer; /* manufacturer of the game */ machine_config_constructor machine_config; /* machine driver tokens */ - const input_port_token *ipt; /* pointer to array of input port tokens */ + ioport_constructor ipt; /* pointer to array of input port tokens */ void (*driver_init)(running_machine &machine); /* DRIVER_INIT callback */ const rom_entry * rom; /* pointer to list of ROMs for the game */ const char * compatible_with; diff --git a/src/emu/emu.h b/src/emu/emu.h index 3b99efa38de..5364a0c350a 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -64,7 +64,6 @@ #include "attotime.h" #include "hash.h" #include "fileio.h" // remove me once NVRAM is implemented as device -#include "tokenize.h" #include "delegate.h" // memory and address spaces @@ -80,6 +79,12 @@ class machine_config; typedef device_t * (*machine_config_constructor)(machine_config &config, device_t *owner); +// I/O +#include "input.h" +#include "inputseq.h" +#include "inptport.h" +#include "output.h" + // devices and callbacks #include "devintrf.h" #include "distate.h" @@ -95,12 +100,6 @@ typedef device_t * (*machine_config_constructor)(machine_config &config, device_ #include "schedule.h" #include "timer.h" -// I/O -#include "input.h" -#include "inputseq.h" -#include "inptport.h" -#include "output.h" - // timers, CPU and scheduling #include "devcpu.h" #include "watchdog.h" diff --git a/src/emu/emutempl.h b/src/emu/emutempl.h index 820bb95476f..fcd89c03eb7 100644 --- a/src/emu/emutempl.h +++ b/src/emu/emutempl.h @@ -141,10 +141,30 @@ public: return prepend(object); object.m_next = insert_after->m_next; insert_after->m_next = &object; + if (m_tail == insert_after) + m_tail = &object; m_count++; return object; } + // insert the given object before a particular object (NULL means append) + _ElementType &insert_before(_ElementType &object, _ElementType *insert_before) + { + if (insert_before == NULL) + return append(object); + for (_ElementType **curptr = &m_head; *curptr != NULL; curptr = &(*curptr)->m_next) + if (*curptr == insert_before) + { + object.m_next = insert_before; + *curptr = &object; + if (m_head == insert_before) + m_head = &object; + m_count++; + return object; + } + return object; + } + // replace an item in the list at the same location, and remove it _ElementType &replace_and_remove(_ElementType &object, _ElementType &toreplace) { diff --git a/src/emu/info.c b/src/emu/info.c index d3529dfc2aa..15f47742011 100644 --- a/src/emu/info.c +++ b/src/emu/info.c @@ -248,9 +248,9 @@ void info_xml_creator::output_one() // allocate input ports machine_config &config = m_drivlist.config(); ioport_list portlist; + astring errors; for (device_t *device = config.devicelist().first(); device != NULL; device = device->next()) - if (device->input_ports() != NULL) - input_port_list_init(portlist, device->input_ports(), NULL, 0, FALSE, device); + input_port_list_init(*device, portlist, errors); // print the header and the game name fprintf(m_output, "\t<" XML_TOP); @@ -693,8 +693,8 @@ void info_xml_creator::output_input(const ioport_list &portlist) bool keyboard = false; // iterate over the ports - for (const input_port_config *port = portlist.first(); port != NULL; port = port->next()) - for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next) + for (input_port_config *port = portlist.first(); port != NULL; port = port->next()) + for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next()) { int analogtype = -1; @@ -889,18 +889,18 @@ void info_xml_creator::output_input(const ioport_list &portlist) void info_xml_creator::output_switches(const ioport_list &portlist, int type, const char *outertag, const char *innertag) { // iterate looking for DIP switches - for (const input_port_config *port = portlist.first(); port != NULL; port = port->next()) - for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next) + for (input_port_config *port = portlist.first(); port != NULL; port = port->next()) + for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next()) if (field->type == type) { // output the switch name information fprintf(m_output, "\t\t<%s name=\"%s\"", outertag, xml_normalize_string(input_field_name(field))); - fprintf(m_output, " tag=\"%s\"", xml_normalize_string(field->port->tag)); + fprintf(m_output, " tag=\"%s\"", xml_normalize_string(field->port().tag())); fprintf(m_output, " mask=\"%u\"", field->mask); fprintf(m_output, ">\n"); // loop over settings - for (const input_setting_config *setting = field->settinglist; setting != NULL; setting = setting->next) + for (input_setting_config *setting = field->settinglist().first(); setting != NULL; setting = setting->next()) { fprintf(m_output, "\t\t\t<%s name=\"%s\"", innertag, xml_normalize_string(setting->name)); fprintf(m_output, " value=\"%u\"", setting->value); @@ -923,8 +923,8 @@ void info_xml_creator::output_switches(const ioport_list &portlist, int type, co void info_xml_creator::output_adjusters(const ioport_list &portlist) { // iterate looking for Adjusters - for (const input_port_config *port = portlist.first(); port != NULL; port = port->next()) - for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next) + for (input_port_config *port = portlist.first(); port != NULL; port = port->next()) + for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next()) if (field->type == IPT_ADJUSTER) fprintf(m_output, "\t\t\n", xml_normalize_string(input_field_name(field)), field->defvalue); } @@ -1002,15 +1002,15 @@ void info_xml_creator::output_driver() void info_xml_creator::output_categories(const ioport_list &portlist) { // iterate looking for Categories - for (const input_port_config *port = portlist.first(); port != NULL; port = port->next()) - for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next) + for (input_port_config *port = portlist.first(); port != NULL; port = port->next()) + for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next()) if (field->type == IPT_CATEGORY) { // output the category name information fprintf(m_output, "\t\t\n", xml_normalize_string(input_field_name(field))); // loop over item settings - for (const input_setting_config *setting = field->settinglist; setting != NULL; setting = setting->next) + for (input_setting_config *setting = field->settinglist().first(); setting != NULL; setting = setting->next()) { fprintf(m_output, "\t\t\tname)); if (setting->value == field->defvalue) diff --git a/src/emu/inptport.c b/src/emu/inptport.c index ff27742bb7b..e20f5059840 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -787,16 +787,6 @@ static void frame_update_digital_joysticks(running_machine &machine); static void frame_update_analog_field(running_machine &machine, analog_field_state *analog); static int frame_get_digital_field_state(const input_field_config *field, int mouse_down); -/* port configuration helpers */ -static void port_config_detokenize(ioport_list &portlist, const input_port_token *ipt, char *errorbuf, int errorbuflen, device_t *owner); -static input_field_config *field_config_alloc(input_port_config *port, int type, input_port_value defvalue, input_port_value maskbits); -static void field_config_insert(input_field_config *field, input_port_value *disallowedbits, char *errorbuf, int errorbuflen); -static void field_config_free(input_field_config **fieldptr); -static input_setting_config *setting_config_alloc(input_field_config *field, input_port_value value, const char *name); -static void setting_config_free(input_setting_config **settingptr); -static const input_field_diplocation *diplocation_list_alloc(const input_field_config *field, const char *location, char *errorbuf, int errorbuflen); -static void diplocation_free(input_field_diplocation **diplocptr); - /* tokenization helpers */ static int token_to_input_field_type(running_machine &machine, const char *string, int *player); static const char *input_field_type_to_token(running_machine &machine, int type, int player); @@ -885,39 +875,7 @@ INLINE INT32 apply_analog_min_max(const analog_field_state *analog, INT32 value) INLINE const char *get_port_tag(const input_port_config *port, char *tempbuffer) { - const input_port_config *curport; - int index = 0; - - if (port->tag != NULL) - return port->tag; - for (curport = port->machine().m_portlist.first(); curport != NULL; curport = curport->next()) - { - if (curport == port) - break; - index++; - } - sprintf(tempbuffer, "(PORT#%d)", index); - return tempbuffer; -} - - -/*------------------------------------------------- - error_buf_append - append text to an error - buffer --------------------------------------------------*/ - -INLINE void* ATTR_PRINTF(3,4) error_buf_append(char *errorbuf, int errorbuflen, const char *format, ...) -{ - int curlen = (errorbuf != NULL) ? strlen(errorbuf) : 0; - int bytesleft = errorbuflen - curlen; - va_list va; - - va_start(va, format); - if (strlen(format) + 25 < bytesleft) - vsprintf(&errorbuf[curlen], format, va); - va_end(va); - - return NULL; + return port->tag(); } @@ -933,37 +891,6 @@ INLINE int condition_equal(const input_condition *cond1, const input_condition * -/*************************************************************************** - CUSTOM DEVICE I/O -***************************************************************************/ - -/*------------------------------------------------- - custom_read_line_device - device handler - stub to process PORT_CUSTOM behavior --------------------------------------------------*/ - -static READ_LINE_DEVICE_HANDLER( custom_read_line_device ) -{ - const device_field_info *device_field = (const device_field_info *) device; - - return (*device_field->field->custom)(device_field->field, device_field->field->custom_param); -} - - -/*------------------------------------------------- - changed_write_line_device - device handler - stub to process PORT_CHANGED behavior --------------------------------------------------*/ - -static WRITE_LINE_DEVICE_HANDLER( changed_write_line_device ) -{ - const device_field_info *device_field = (const device_field_info *) device; - - (*device_field->field->changed)(device_field->field, device_field->field->changed_param, device_field->oldval, state); -} - - - /*************************************************************************** CORE SYSTEM MANAGEMENT ***************************************************************************/ @@ -973,10 +900,9 @@ static WRITE_LINE_DEVICE_HANDLER( changed_write_line_device ) system -------------------------------------------------*/ -time_t input_port_init(running_machine &machine, const device_list &devicelist) +time_t input_port_init(running_machine &machine) { //input_port_private *portdata; - char errorbuf[1024]; time_t basetime; /* allocate memory for our data structure */ @@ -991,13 +917,13 @@ time_t input_port_init(running_machine &machine, const device_list &devicelist) init_port_types(machine); /* if we have a token list, proceed */ - for (device_t *device = devicelist.first(); device != NULL; device = device->next()) - if (device->input_ports() != NULL) - { - input_port_list_init(machine.m_portlist, device->input_ports(), errorbuf, sizeof(errorbuf), TRUE, device); - if (errorbuf[0] != 0) - mame_printf_error("Input port errors:\n%s", errorbuf); - } + for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next()) + { + astring errors; + input_port_list_init(*device, machine.m_portlist, errors); + if (errors) + mame_printf_error("Input port errors:\n%s", errors.cstr()); + } init_port_state(machine); /* register callbacks for when we load configurations */ @@ -1035,18 +961,22 @@ static void input_port_exit(running_machine &machine) according to the given tokens -------------------------------------------------*/ -void input_port_list_init(ioport_list &portlist, const input_port_token *tokens, char *errorbuf, int errorbuflen, int allocmap, device_t *owner) +void input_port_list_init(device_t &device, ioport_list &portlist, astring &errorbuf) { - /* no tokens, no list */ - if (tokens == NULL) + /* no constructor, no list */ + ioport_constructor constructor = device.input_ports(); + if (constructor == NULL) return; /* reset error buffer */ - if (errorbuf != NULL) - *errorbuf = 0; + errorbuf.reset(); /* detokenize into the list */ - port_config_detokenize(portlist, tokens, errorbuf, errorbuflen, owner); + (*constructor)(device, portlist, errorbuf); + + // collapse fields and sort the list + for (input_port_config *port = portlist.first(); port != NULL; port = port->next()) + port->collapse_fields(errorbuf); } @@ -1062,7 +992,7 @@ const input_field_config *input_field_by_tag_and_mask(const ioport_list &portlis /* if we got the port, look for the field */ if (port != NULL) - for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next) + for (const input_field_config *field = port->first_field(); field != NULL; field = field->next()) if ((field->mask & mask) != 0) return field; @@ -1089,7 +1019,7 @@ const char *input_field_name(const input_field_config *field) return field->name; /* otherwise, return the name associated with the type */ - return input_type_name(field->port->machine(), field->type, field->player); + return input_type_name(field->machine(), field->type, field->player); } @@ -1112,7 +1042,7 @@ const input_seq *input_field_seq(const input_field_config *field, input_seq_type /* if the portseq is the special default code, return the expanded default value */ if (input_seq_get_1(portseq) == SEQCODE_DEFAULT) - return input_type_seq(field->port->machine(), field->type, field->player, seqtype); + return input_type_seq(field->machine(), field->type, field->player, seqtype); /* otherwise, return the sequence as-is */ return portseq; @@ -1136,7 +1066,7 @@ void input_field_get_user_settings(const input_field_config *field, input_field_ settings->seq[seqtype] = field->state->seq[seqtype]; /* if there's a list of settings or we're an adjuster, copy the current value */ - if (field->settinglist != NULL || field->type == IPT_ADJUSTER) + if (field->settinglist().count() != 0 || field->type == IPT_ADJUSTER) settings->value = field->state->value; /* if there's analog data, extract the analog settings */ @@ -1163,7 +1093,7 @@ void input_field_set_user_settings(const input_field_config *field, const input_ /* copy the basics */ for (seqtype = 0; seqtype < ARRAY_LENGTH(settings->seq); seqtype++) { - const input_seq *defseq = input_type_seq(field->port->machine(), field->type, field->player, (input_seq_type)seqtype); + const input_seq *defseq = input_type_seq(field->machine(), field->type, field->player, (input_seq_type)seqtype); if (input_seq_cmp(defseq, &settings->seq[seqtype]) == 0) field->state->seq[seqtype] = default_seq; else @@ -1171,7 +1101,7 @@ void input_field_set_user_settings(const input_field_config *field, const input_ } /* if there's a list of settings or we're an adjuster, copy the current value */ - if (field->settinglist != NULL || field->type == IPT_ADJUSTER) + if (field->settinglist().count() != 0 || field->type == IPT_ADJUSTER) field->state->value = settings->value; /* if there's analog data, extract the analog settings */ @@ -1195,11 +1125,11 @@ const char *input_field_setting_name(const input_field_config *field) const input_setting_config *setting; /* only makes sense if we have settings */ - assert(field->settinglist != NULL); + assert(field->settinglist().count() != 0); /* scan the list of settings looking for a match on the current value */ - for (setting = field->settinglist; setting != NULL; setting = setting->next) - if (input_condition_true(field->port->machine(), &setting->condition)) + for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) + if (input_condition_true(field->machine(), &setting->condition)) if (setting->value == field->state->value) return setting->name; @@ -1217,11 +1147,11 @@ int input_field_has_previous_setting(const input_field_config *field) const input_setting_config *setting; /* only makes sense if we have settings */ - assert(field->settinglist != NULL); + assert(field->settinglist().count() != 0); /* scan the list of settings looking for a match on the current value */ - for (setting = field->settinglist; setting != NULL; setting = setting->next) - if (input_condition_true(field->port->machine(), &setting->condition)) + for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) + if (input_condition_true(field->machine(), &setting->condition)) return (setting->value != field->state->value); return FALSE; @@ -1240,12 +1170,12 @@ void input_field_select_previous_setting(const input_field_config *field) int found_match = FALSE; /* only makes sense if we have settings */ - assert(field->settinglist != NULL); + assert(field->settinglist().count() != 0); /* scan the list of settings looking for a match on the current value */ prevsetting = NULL; - for (setting = field->settinglist; setting != NULL; setting = setting->next) - if (input_condition_true(field->port->machine(), &setting->condition)) + for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) + if (input_condition_true(field->machine(), &setting->condition)) { if (setting->value == field->state->value) { @@ -1259,8 +1189,8 @@ void input_field_select_previous_setting(const input_field_config *field) /* if we didn't find a matching value, select the first */ if (!found_match) { - for (prevsetting = field->settinglist; prevsetting != NULL; prevsetting = prevsetting->next) - if (input_condition_true(field->port->machine(), &prevsetting->condition)) + for (prevsetting = field->settinglist().first(); prevsetting != NULL; prevsetting = prevsetting->next()) + if (input_condition_true(field->machine(), &prevsetting->condition)) break; } @@ -1281,11 +1211,11 @@ int input_field_has_next_setting(const input_field_config *field) int found = FALSE; /* only makes sense if we have settings */ - assert(field->settinglist != NULL); + assert(field->settinglist().count() != 0); /* scan the list of settings looking for a match on the current value */ - for (setting = field->settinglist; setting != NULL; setting = setting->next) - if (input_condition_true(field->port->machine(), &setting->condition)) + for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) + if (input_condition_true(field->machine(), &setting->condition)) { if (found) return TRUE; @@ -1308,25 +1238,25 @@ void input_field_select_next_setting(const input_field_config *field) const input_setting_config *setting, *nextsetting; /* only makes sense if we have settings */ - assert(field->settinglist != NULL); + assert(field->settinglist().count() != 0); /* scan the list of settings looking for a match on the current value */ nextsetting = NULL; - for (setting = field->settinglist; setting != NULL; setting = setting->next) - if (input_condition_true(field->port->machine(), &setting->condition)) + for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) + if (input_condition_true(field->machine(), &setting->condition)) if (setting->value == field->state->value) break; /* if we found one, scan forward for the next valid one */ if (setting != NULL) - for (nextsetting = setting->next; nextsetting != NULL; nextsetting = nextsetting->next) - if (input_condition_true(field->port->machine(), &nextsetting->condition)) + for (nextsetting = setting->next(); nextsetting != NULL; nextsetting = nextsetting->next()) + if (input_condition_true(field->machine(), &nextsetting->condition)) break; /* if we hit the end, search from the beginning */ if (nextsetting == NULL) - for (nextsetting = field->settinglist; nextsetting != NULL; nextsetting = nextsetting->next) - if (input_condition_true(field->port->machine(), &nextsetting->condition)) + for (nextsetting = field->settinglist().first(); nextsetting != NULL; nextsetting = nextsetting->next()) + if (input_condition_true(field->machine(), &nextsetting->condition)) break; /* update the value to the previous one */ @@ -1551,12 +1481,12 @@ input_port_value input_port_read_direct(const input_port_config *port) /* start with the digital */ result = port->state->digital; - /* update custom values */ + /* update read values */ for (device_field = port->state->readdevicelist; device_field != NULL; device_field = device_field->next) if (input_condition_true(port->machine(), &device_field->field->condition)) { /* replace the bits with bits from the device */ - input_port_value newval = (*device_field->field->read_line_device)(device_field->device); + input_port_value newval = (*device_field->field->read)(*device_field->device, device_field->field, device_field->field->read_param); device_field->oldval = newval; result = (result & ~device_field->field->mask) | ((newval << device_field->shift) & device_field->field->mask); } @@ -1570,7 +1500,7 @@ input_port_value input_port_read_direct(const input_port_config *port) result &= ~port->state->vblank; } - /* apply active high/low state to digital, custom, and VBLANK inputs */ + /* apply active high/low state to digital, read, and VBLANK inputs */ result ^= port->state->defvalue; /* merge in analog portions */ @@ -1662,7 +1592,7 @@ int input_port_get_crosshair_position(running_machine &machine, int player, floa /* read all the lightgun values */ for (port = machine.m_portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) if (field->player == player && field->crossaxis != CROSSHAIR_AXIS_NONE) if (input_condition_true(machine, &field->condition)) { @@ -1739,7 +1669,7 @@ void input_port_update_defaults(running_machine &machine) port->state->defvalue = 0; /* first compute the default value for the entire port */ - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) if (input_condition_true(machine, &field->condition)) port->state->defvalue = (port->state->defvalue & ~field->mask) | (field->state->value & field->mask); } @@ -1789,7 +1719,7 @@ static INT32 apply_analog_settings(INT32 value, analog_field_state *analog) void input_port_write_direct(const input_port_config *port, input_port_value data, input_port_value mem_mask) { - /* call device line changed handlers */ + /* call device line write handlers */ device_field_info *device_field; COMBINE_DATA(&port->state->outputvalue); @@ -1799,10 +1729,10 @@ void input_port_write_direct(const input_port_config *port, input_port_value dat { input_port_value newval = ( (port->state->outputvalue ^ device_field->field->defvalue ) & device_field->field->mask) >> device_field->shift; - /* if the bits have changed, call the handler */ + /* if the bits have write, call the handler */ if (device_field->oldval != newval) { - (*device_field->field->write_line_device)(device_field->device, newval); + (*device_field->field->write)(*device_field->device, device_field->field, device_field->field->write_param, device_field->oldval, newval); device_field->oldval = newval; } @@ -1888,21 +1818,21 @@ int input_condition_true(running_machine &machine, const input_condition *condit input_port_token to a default string -------------------------------------------------*/ -const char *input_port_string_from_token(const input_port_token token) +const char *input_port_string_from_token(const char *string) { int index; /* 0 is an invalid index */ - if (token.i == 0) + if (string == NULL) return NULL; /* if the index is greater than the count, assume it to be a pointer */ - if (token.i >= INPUT_STRING_COUNT) - return token.stringptr; + if (FPTR(string) >= INPUT_STRING_COUNT) + return string; /* otherwise, scan the list for a matching string and return it */ for (index = 0; index < ARRAY_LENGTH(input_port_default_strings); index++) - if (input_port_default_strings[index].id == token.i) + if (input_port_default_strings[index].id == FPTR(string)) return input_port_default_strings[index].string; return "(Unknown Default)"; } @@ -2090,7 +2020,6 @@ static void init_port_state(running_machine &machine) /* allocate a new input_port_info structure */ portstate = auto_alloc_clear(machine, input_port_state); ((input_port_config *)port)->state = portstate; - ((input_port_config *)port)->set_machine(machine); /* start with tail pointers to all the data */ analogstatetail = &portstate->analoglist; @@ -2098,7 +2027,7 @@ static void init_port_state(running_machine &machine) writedevicetail = &portstate->writedevicelist; /* iterate over fields */ - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) { input_field_state *fieldstate; int seqtype; @@ -2129,16 +2058,16 @@ static void init_port_state(running_machine &machine) } /* if this entry has device input, allocate memory for the tracking structure */ - if (field->read_line_device != NULL) + if (field->read != NULL) { - *readdevicetail = init_field_device_info(field,field->read_device_name); + *readdevicetail = init_field_device_info(field,field->read_device); readdevicetail = &(*readdevicetail)->next; } /* if this entry has device output, allocate memory for the tracking structure */ - if (field->write_line_device != NULL) + if (field->write != NULL) { - *writedevicetail = init_field_device_info(field,field->write_device_name); + *writedevicetail = init_field_device_info(field,field->write_device); writedevicetail = &(*writedevicetail)->next; } @@ -2168,7 +2097,7 @@ static void init_port_state(running_machine &machine) /* look for 4-way joysticks and change the default map if we find any */ if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0) for (port = machine.m_portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) if (field->state->joystick != NULL && field->way == 4) { input_device_set_joystick_map(machine, -1, (field->flags & FIELD_FLAG_ROTATED) ? joystick_map_4way_diagonal : joystick_map_4way_sticky); @@ -2223,7 +2152,7 @@ static void init_autoselect_devices(running_machine &machine, int type1, int typ /* only scan the list if we haven't already enabled this class of control */ if (portlist.first() != NULL && !input_device_class_enabled(portlist.first()->machine(), autoenable)) for (port = portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) /* if this port type is in use, apply the autoselect criteria */ if ((type1 != 0 && field->type == type1) || @@ -2248,7 +2177,7 @@ static device_field_info *init_field_device_info(const input_field_config *field input_port_value mask; /* allocate memory */ - info = auto_alloc_clear(field->port->machine(), device_field_info); + info = auto_alloc_clear(field->machine(), device_field_info); /* fill in the data */ info->field = field; @@ -2256,9 +2185,9 @@ static device_field_info *init_field_device_info(const input_field_config *field info->shift++; if (device_name != NULL) - info->device = field->port->machine().device(device_name); + info->device = field->machine().device(device_name); else - info->device = (device_t *) info; + info->device = &field->port().owner(); info->oldval = field->defvalue >> info->shift; return info; @@ -2276,7 +2205,7 @@ static analog_field_state *init_field_analog_state(const input_field_config *fie input_port_value mask; /* allocate memory */ - state = auto_alloc_clear(field->port->machine(), analog_field_state); + state = auto_alloc_clear(field->machine(), analog_field_state); /* compute the shift amount and number of bits */ for (mask = field->mask; !(mask & 1); mask >>= 1) @@ -2506,7 +2435,7 @@ static void input_port_update_hook(running_machine &machine, const input_port_co { for (i = 0; i < ARRAY_LENGTH(code->field) && (code->field[i] != NULL); i++) { - if (code->field[i]->port == port) + if (&code->field[i]->port() == port) { value = code->field[i]->mask; *digital |= value; @@ -2574,7 +2503,7 @@ g_profiler.start(PROFILER_INPUT); port->state->vblank = 0; /* now loop back and modify based on the inputs */ - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) if (input_condition_true(port->machine(), &field->condition)) { /* accumulate VBLANK bits */ @@ -2597,17 +2526,17 @@ g_profiler.start(PROFILER_INPUT); playback_port(port); record_port(port); - /* call device line changed handlers */ + /* call device line write handlers */ newvalue = input_port_read_direct(port); for (device_field = port->state->writedevicelist; device_field; device_field = device_field->next) if (device_field->field->type != IPT_OUTPUT && input_condition_true(port->machine(), &device_field->field->condition)) { input_port_value newval = (newvalue & device_field->field->mask) >> device_field->shift; - /* if the bits have changed, call the handler */ + /* if the bits have write, call the handler */ if (device_field->oldval != newval) { - (*device_field->field->write_line_device)(device_field->device, newval); + (*device_field->field->write)(*device_field->device, device_field->field, device_field->field->write_param, device_field->oldval, newval); device_field->oldval = newval; } @@ -2853,7 +2782,7 @@ static void frame_update_analog_field(running_machine &machine, analog_field_sta static int frame_get_digital_field_state(const input_field_config *field, int mouse_down) { - int curstate = mouse_down || input_seq_pressed(field->port->machine(), input_field_seq(field, SEQ_TYPE_STANDARD)); + int curstate = mouse_down || input_seq_pressed(field->machine(), input_field_seq(field, SEQ_TYPE_STANDARD)); int changed = FALSE; /* if the state changed, look for switch down/switch up */ @@ -2863,7 +2792,7 @@ static int frame_get_digital_field_state(const input_field_config *field, int mo changed = TRUE; } - if (field->type == IPT_KEYBOARD && ui_get_use_natural_keyboard(field->port->machine())) + if (field->type == IPT_KEYBOARD && ui_get_use_natural_keyboard(field->machine())) return FALSE; /* if this is a switch-down event, handle impulse and toggle */ @@ -2876,7 +2805,7 @@ static int frame_get_digital_field_state(const input_field_config *field, int mo /* toggle controls: flip the toggle state or advance to the next setting */ if (field->flags & FIELD_FLAG_TOGGLE) { - if (field->settinglist == NULL) + if (field->settinglist().count() == 0) field->state->value ^= field->mask; else input_field_select_next_setting(field); @@ -2909,7 +2838,7 @@ static int frame_get_digital_field_state(const input_field_config *field, int mo } /* skip locked-out coin inputs */ - if (curstate && field->type >= IPT_COIN1 && field->type <= IPT_COIN12 && coin_lockout_get_state(field->port->machine(), field->type - IPT_COIN1) && field->port->machine().options().coin_lockout()) + if (curstate && field->type >= IPT_COIN1 && field->type <= IPT_COIN12 && coin_lockout_get_state(field->machine(), field->type - IPT_COIN1) && field->machine().options().coin_lockout()) { ui_popup_time(3, "Coinlock disabled %s.", input_field_name(field)); return FALSE; @@ -2928,761 +2857,106 @@ static int frame_get_digital_field_state(const input_field_config *field, int mo of port settings according to device settings -------------------------------------------------*/ -static UINT32 port_default_value(const char *fulltag, UINT32 mask, UINT32 defval, device_t *owner) +UINT32 port_default_value(const char *fulltag, UINT32 mask, UINT32 defval, device_t &owner) { astring tempstring; const input_device_default *def = NULL; - if (owner!=NULL) { - def = owner->input_ports_defaults(); - if (def!=NULL) { - while (def->tag!=NULL) { - if ((strcmp(fulltag,owner->subtag(tempstring,def->tag))==0) && (def->mask == mask)) { - return def->defvalue; - } - def++; + def = owner.input_ports_defaults(); + if (def!=NULL) { + while (def->tag!=NULL) { + if ((strcmp(fulltag,owner.subtag(tempstring,def->tag))==0) && (def->mask == mask)) { + return def->defvalue; } + def++; } } return defval; } -/*------------------------------------------------- - port_config_detokenize - recursively - detokenize a series of input port tokens --------------------------------------------------*/ - -static void port_config_detokenize(ioport_list &portlist, const input_port_token *ipt, char *errorbuf, int errorbuflen, device_t *owner) -{ - UINT32 entrytype = INPUT_TOKEN_INVALID; - input_setting_config *cursetting = NULL; - input_field_config *curfield = NULL; - input_port_config *curport = NULL; - input_port_value maskbits = 0; - astring tempstring; - const char *fulltag = NULL; - UINT16 category; /* (MESS-specific) category */ - - /* loop over tokens until we hit the end */ - while (entrytype != INPUT_TOKEN_END) - { - UINT32 mask, defval, type, val; - input_port_token temptoken; - input_condition condition; - const char *string; - int hasdiploc; - int index; - - /* unpack the token from the first entry */ - TOKEN_GET_UINT32_UNPACK1(ipt, entrytype, 8); - switch (entrytype) - { - /* end */ - case INPUT_TOKEN_END: - break; - - /* including */ - case INPUT_TOKEN_INCLUDE: - if (curfield != NULL) - field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); - maskbits = 0; - - port_config_detokenize(portlist, TOKEN_GET_PTR(ipt, tokenptr), errorbuf, errorbuflen, owner); - curport = NULL; - curfield = NULL; - cursetting = NULL; - break; - - /* start of a new input port */ - case INPUT_TOKEN_START: - if (curfield != NULL) - field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); - maskbits = 0; - - string = TOKEN_GET_STRING(ipt); - if (owner!=NULL) { - fulltag = core_strdup(owner->subtag(tempstring, string)); - } else { - fulltag = string; - } - curport = &portlist.append(fulltag, *global_alloc(input_port_config(fulltag))); - curfield = NULL; - cursetting = NULL; - break; - - /* modify an existing port */ - case INPUT_TOKEN_MODIFY: - if (curfield != NULL) - field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); - maskbits = 0; - - curport = portlist.find(TOKEN_GET_STRING(ipt)); - curfield = NULL; - cursetting = NULL; - break; - - /* input field definition */ - case INPUT_TOKEN_FIELD: - TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, type, 24); - TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - - if (curport == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_FIELD encountered with no active port (mask=%X defval=%X)\n", mask, defval); - return; - } - - if (type != IPT_UNKNOWN && type != IPT_UNUSED) - curport->active |= mask; - - if (curfield != NULL) - field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); - curfield = field_config_alloc(curport, type, defval, mask); - cursetting = NULL; - break; - - /* field or setting condition */ - case INPUT_TOKEN_CONDITION: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL && cursetting == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CONDITION encountered with no active field or setting\n"); - TOKEN_SKIP_UINT32(ipt); - TOKEN_SKIP_UINT64(ipt); - break; - } - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, condition.condition, 24); - TOKEN_GET_UINT64_UNPACK2(ipt, condition.mask, 32, condition.value, 32); - condition.tag = TOKEN_GET_STRING(ipt); - - if (cursetting != NULL) - cursetting->condition = condition; - else - curfield->condition = condition; - break; - - /* field player select */ - case INPUT_TOKEN_PLAYER1: - case INPUT_TOKEN_PLAYER2: - case INPUT_TOKEN_PLAYER3: - case INPUT_TOKEN_PLAYER4: - case INPUT_TOKEN_PLAYER5: - case INPUT_TOKEN_PLAYER6: - case INPUT_TOKEN_PLAYER7: - case INPUT_TOKEN_PLAYER8: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_PLAYERn encountered with no active field\n"); - break; - } - curfield->player = entrytype - INPUT_TOKEN_PLAYER1; - break; - - /* field category */ - case INPUT_TOKEN_CATEGORY: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CATEGORY encountered with no active field\n"); - TOKEN_SKIP_UINT32(ipt); - break; - } - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->category, 24); - break; - - /* field flags */ - case INPUT_TOKEN_UNUSED: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_UNUSED encountered with no active field\n"); - break; - } - curfield->flags |= FIELD_FLAG_UNUSED; - break; - - case INPUT_TOKEN_COCKTAIL: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_COCKTAIL encountered with no active field\n"); - break; - } - curfield->flags |= FIELD_FLAG_COCKTAIL; - curfield->player = 1; - break; - - case INPUT_TOKEN_ROTATED: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_ROTATED encountered with no active field\n"); - break; - } - curfield->flags |= FIELD_FLAG_ROTATED; - break; - - case INPUT_TOKEN_TOGGLE: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_TOGGLE encountered with no active field\n"); - break; - } - curfield->flags |= FIELD_FLAG_TOGGLE; - break; - - /* field impulse */ - case INPUT_TOKEN_IMPULSE: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_IMPULSE encountered with no active field\n"); - TOKEN_SKIP_UINT32(ipt); - break; - } - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->impulse, 24); - break; - - /* field name */ - case INPUT_TOKEN_NAME: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_NAME encountered with no active field\n"); - TOKEN_SKIP_STRING(ipt); - break; - } - curfield->name = input_port_string_from_token(*ipt++); - break; - - /* field code sequence */ - case INPUT_TOKEN_CODE: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CODE encountered with no active field\n"); - TOKEN_SKIP_UINT64(ipt); - break; - } - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); - input_seq_append_or(&curfield->seq[SEQ_TYPE_STANDARD], val); - break; - - /* field custom callback */ - case INPUT_TOKEN_CUSTOM: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CUSTOM encountered with no active field\n"); - TOKEN_SKIP_PTR(ipt); - TOKEN_SKIP_PTR(ipt); - break; - } - curfield->read_line_device = custom_read_line_device; - curfield->read_device_name = NULL; - curfield->custom = TOKEN_GET_PTR(ipt, customptr); - curfield->custom_param = (void *)TOKEN_GET_PTR(ipt, voidptr); - break; - - /* field changed callback */ - case INPUT_TOKEN_CHANGED: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CHANGED encountered with no active field\n"); - TOKEN_SKIP_PTR(ipt); - TOKEN_SKIP_PTR(ipt); - break; - } - curfield->write_line_device = changed_write_line_device; - curfield->write_device_name = NULL; - curfield->changed = TOKEN_GET_PTR(ipt, changedptr); - curfield->changed_param = (void *)TOKEN_GET_PTR(ipt, voidptr); - break; - - /* DIP switch location */ - case INPUT_TOKEN_DIPLOCATION: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_DIPLOCATION encountered with no active field\n"); - TOKEN_SKIP_STRING(ipt); - break; - } - if (curfield->diploclist != NULL) - { - error_buf_append(errorbuf, errorbuflen, "multiple INPUT_TOKEN_DIPLOCATIONs encountered for a single field\n"); - TOKEN_SKIP_STRING(ipt); - break; - } - curfield->diploclist = diplocation_list_alloc(curfield, TOKEN_GET_STRING(ipt), errorbuf, errorbuflen); - break; - - /* joystick flags */ - case INPUT_TOKEN_2WAY: - case INPUT_TOKEN_4WAY: - case INPUT_TOKEN_8WAY: - case INPUT_TOKEN_16WAY: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_nWAY encountered with no active field\n"); - break; - } - curfield->way = 2 << (entrytype - INPUT_TOKEN_2WAY); - break; - - /* (MESS) natural keyboard support */ - case INPUT_TOKEN_CHAR: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CHAR encountered with no active field\n"); - TOKEN_SKIP_UINT64(ipt); - break; - } - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); - for (index = 0; index < ARRAY_LENGTH(curfield->chars); index++) - if (curfield->chars[index] == 0) - { - curfield->chars[index] = (unicode_char)val; - break; - } - break; - - /* analog minimum/maximum */ - case INPUT_TOKEN_MINMAX: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_MINMAX encountered with no active field\n"); - TOKEN_SKIP_UINT64(ipt); - break; - } - TOKEN_GET_UINT64_UNPACK2(ipt, curfield->min, 32, curfield->max, 32); - break; - - /* analog sensitivity */ - case INPUT_TOKEN_SENSITIVITY: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_SENSITIVITY encountered with no active field\n"); - TOKEN_SKIP_UINT32(ipt); - break; - } - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->sensitivity, 24); - break; - - /* analog keyboard delta */ - case INPUT_TOKEN_KEYDELTA: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_KEYDELTA encountered with no active field\n"); - TOKEN_SKIP_UINT32(ipt); - break; - } - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->delta, -24); - curfield->centerdelta = curfield->delta; - break; - - /* analog autocenter delta */ - case INPUT_TOKEN_CENTERDELTA: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CENTERDELTA encountered with no active field\n"); - TOKEN_SKIP_UINT32(ipt); - break; - } - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->centerdelta, -24); - break; - - /* analog reverse flags */ - case INPUT_TOKEN_REVERSE: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_REVERSE encountered with no active field\n"); - break; - } - curfield->flags |= ANALOG_FLAG_REVERSE; - break; - - case INPUT_TOKEN_RESET: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_RESET encountered with no active field\n"); - break; - } - curfield->flags |= ANALOG_FLAG_RESET; - break; - - case INPUT_TOKEN_WRAPS: - if (curfield == NULL) - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_WRAPS encountered with no active field\n"); - curfield->flags |= ANALOG_FLAG_WRAPS; - break; - - case INPUT_TOKEN_INVERT: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_INVERT encountered with no active field\n"); - break; - } - curfield->flags |= ANALOG_FLAG_INVERT; - break; - - /* analog crosshair parameters */ - case INPUT_TOKEN_CROSSHAIR: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CROSSHAIR encountered with no active field\n"); - TOKEN_SKIP_UINT32(ipt); - TOKEN_SKIP_UINT64(ipt); - break; - } - TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, curfield->crossaxis, 4, curfield->crossaltaxis, -20); - TOKEN_GET_UINT64_UNPACK2(ipt, curfield->crossscale, -32, curfield->crossoffset, -32); - curfield->crossaltaxis *= 1.0f / 65536.0f; - curfield->crossscale *= 1.0f / 65536.0f; - curfield->crossoffset *= 1.0f / 65536.0f; - break; - - /* crosshair mapper callback */ - case INPUT_TOKEN_CROSSHAIR_MAPPER: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CROSSHAIR_MAPPER encountered with no active field\n"); - TOKEN_SKIP_PTR(ipt); - break; - } - curfield->crossmapper = TOKEN_GET_PTR(ipt, crossmapptr); - break; - - /* analog decrement sequence */ - case INPUT_TOKEN_CODE_DEC: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CODE_DEC encountered with no active field\n"); - TOKEN_SKIP_UINT64(ipt); - break; - } - index = entrytype - INPUT_TOKEN_CODE; - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); - input_seq_append_or(&curfield->seq[SEQ_TYPE_DECREMENT], val); - break; - - /* analog increment sequence */ - case INPUT_TOKEN_CODE_INC: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - TOKEN_SKIP_UINT64(ipt); - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CODE_INC encountered with no active field\n"); - break; - } - index = entrytype - INPUT_TOKEN_CODE; - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); - input_seq_append_or(&curfield->seq[SEQ_TYPE_INCREMENT], val); - break; - - /* analog full turn count */ - case INPUT_TOKEN_FULL_TURN_COUNT: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_FULL_TURN_COUNT encountered with no active field\n"); - TOKEN_SKIP_UINT32(ipt); - break; - } - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->full_turn_count, 24); - break; - - case INPUT_TOKEN_POSITIONS: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_POSITIONS encountered with no active field\n"); - TOKEN_SKIP_UINT32(ipt); - break; - } - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->max, 24); - break; - - case INPUT_TOKEN_REMAP_TABLE: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_REMAP_TABLE encountered with no active field\n"); - TOKEN_SKIP_PTR(ipt); - break; - } - curfield->remap_table = TOKEN_GET_PTR(ipt, ui32ptr); - break; - - /* DIP switch definition */ - case INPUT_TOKEN_DIPNAME: - if (curport == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_DIPNAME encountered with no active port\n"); - TOKEN_SKIP_UINT64(ipt); - TOKEN_SKIP_STRING(ipt); - break; - } - TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - if (curfield != NULL) - field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); - defval = port_default_value(fulltag,mask,defval,owner); - curfield = field_config_alloc(curport, IPT_DIPSWITCH, defval, mask); - cursetting = NULL; - curfield->name = input_port_string_from_token(*ipt++); - break; - - /* DIP switch setting */ - case INPUT_TOKEN_DIPSETTING: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_DIPSETTING encountered with no active field\n"); - TOKEN_SKIP_UINT64(ipt); - TOKEN_SKIP_STRING(ipt); - break; - } - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); - cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++)); - break; - - /* special DIP switch with on/off values */ - case INPUT_TOKEN_SPECIAL_ONOFF: - TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, hasdiploc, 1, temptoken.i, 23); - TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - - if (curport == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_SPECIAL_ONOFF encountered with no active port\n"); - TOKEN_SKIP_UINT32(ipt); - TOKEN_SKIP_UINT64(ipt); - if (hasdiploc) - TOKEN_SKIP_STRING(ipt); - break; - } - if (curfield != NULL) - field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); - curfield = field_config_alloc(curport, IPT_DIPSWITCH, defval, mask); - cursetting = NULL; - - curfield->name = input_port_string_from_token(temptoken); - if (temptoken.i == INPUT_STRING_Service_Mode) - { - curfield->flags |= FIELD_FLAG_TOGGLE; - curfield->seq[SEQ_TYPE_STANDARD].code[0] = KEYCODE_F2; - } - if (hasdiploc) - { - if (curfield->diploclist != NULL) - { - error_buf_append(errorbuf, errorbuflen, "multiple INPUT_TOKEN_DIPLOCATIONs encountered for a single field\n"); - TOKEN_SKIP_STRING(ipt); - break; - } - curfield->diploclist = diplocation_list_alloc(curfield, TOKEN_GET_STRING(ipt), errorbuf, errorbuflen); - } - - temptoken.i = INPUT_STRING_Off; - cursetting = setting_config_alloc(curfield, defval & mask, input_port_string_from_token(temptoken)); - - temptoken.i = INPUT_STRING_On; - cursetting = setting_config_alloc(curfield, ~defval & mask, input_port_string_from_token(temptoken)); - - /* reset cursetting to NULL to allow subsequent conditions to apply to the field */ - cursetting = NULL; - break; - - /* configuration definition */ - case INPUT_TOKEN_CONFNAME: - if (curport == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CONFNAME encountered with no active port\n"); - TOKEN_SKIP_UINT64(ipt); - TOKEN_SKIP_STRING(ipt); - break; - } - TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - if (curfield != NULL) - field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); - defval = port_default_value(fulltag,mask,defval,owner); - curfield = field_config_alloc(curport, IPT_CONFIG, defval, mask); - cursetting = NULL; - curfield->name = input_port_string_from_token(*ipt++); - break; - - /* configuration setting */ - case INPUT_TOKEN_CONFSETTING: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CONFSETTING encountered with no active field\n"); - TOKEN_SKIP_UINT64(ipt); - TOKEN_SKIP_STRING(ipt); - break; - } - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); - cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++)); - break; - - /* configuration definition */ - case INPUT_TOKEN_CATEGORY_NAME: - if (curport == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CATEGORY_NAME encountered with no active port\n"); - TOKEN_SKIP_UINT64(ipt); - TOKEN_SKIP_STRING(ipt); - break; - } - TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - if (curfield != NULL) - field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); - defval = port_default_value(fulltag,mask,defval,owner); - curfield = field_config_alloc(curport, IPT_CATEGORY, defval, mask); - cursetting = NULL; - curfield->name = input_port_string_from_token(*ipt++); - break; - - /* category setting */ - case INPUT_TOKEN_CATEGORY_SETTING: - TOKEN_UNGET_UINT32(ipt); - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CATEGORY_SETTING encountered with no active field\n"); - TOKEN_SKIP_UINT64(ipt); - TOKEN_SKIP_STRING(ipt); - break; - } - TOKEN_GET_UINT64_UNPACK3(ipt, entrytype, 8, defval, 32, category, 16); - cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++)); - cursetting->category = category; - break; - - /* analog adjuster definition */ - case INPUT_TOKEN_ADJUSTER: - TOKEN_UNGET_UINT32(ipt); - if (curport == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_ADJUSTER encountered with no active port\n"); - TOKEN_SKIP_UINT64(ipt); - TOKEN_SKIP_STRING(ipt); - break; - } - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); - if (curfield != NULL) - field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); - curfield = field_config_alloc(curport, IPT_ADJUSTER, defval, 0xff); - cursetting = NULL; - curfield->name = TOKEN_GET_STRING(ipt); - break; - - /* input device handler */ - case INPUT_TOKEN_READ_LINE_DEVICE: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_READ_LINE_DEVICE encountered with no active field\n"); - TOKEN_SKIP_STRING(ipt); - TOKEN_SKIP_PTR(ipt); - break; - } - curfield->read_device_name = TOKEN_GET_STRING(ipt); - if (!strcmp(curfield->read_device_name, DEVICE_SELF)) - { - if (owner) - curfield->read_device_name = owner->tag(); - else - error_buf_append(errorbuf, errorbuflen, "DEVICE_SELF used while not in device context\n"); - } - curfield->read_line_device = TOKEN_GET_PTR(ipt, read_line_device); - break; - - /* output device handler */ - case INPUT_TOKEN_WRITE_LINE_DEVICE: - if (curfield == NULL) - { - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_WRITE_LINE_DEVICE encountered with no active field\n"); - TOKEN_SKIP_STRING(ipt); - TOKEN_SKIP_PTR(ipt); - break; - } - curfield->write_device_name = TOKEN_GET_STRING(ipt); - if (!strcmp(curfield->write_device_name, DEVICE_SELF)) - { - if (owner) - curfield->write_device_name = owner->tag(); - else - error_buf_append(errorbuf, errorbuflen, "DEVICE_SELF used while not in device context\n"); - } - curfield->write_line_device = TOKEN_GET_PTR(ipt, write_line_device); - break; - - default: - error_buf_append(errorbuf, errorbuflen, "Invalid token %d in input ports\n", entrytype); - break; - } - } - - /* insert any pending fields */ - if (curfield != NULL) - field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); -} - /*------------------------------------------------- input_port_config - constructor for an I/O port configuration object -------------------------------------------------*/ -input_port_config::input_port_config(const char *_tag) - : m_next(NULL), - tag(_tag), - fieldlist(NULL), - state(NULL), - owner(NULL), +input_port_config::input_port_config(device_t &owner, const char *tag) + : state(NULL), active(0), - m_machine(NULL) + m_next(NULL), + m_owner(owner), + m_tag(tag), + m_modcount(0) { } -/*------------------------------------------------- - ~input_port_config - destructor for an - I/O port configuration object --------------------------------------------------*/ - -input_port_config::~input_port_config() +running_machine &input_port_config::machine() const { - while (fieldlist != NULL) - field_config_free((input_field_config **)&fieldlist); + return m_owner.machine(); } - /*------------------------------------------------- field_config_alloc - allocate a new input port field config -------------------------------------------------*/ -static input_field_config *field_config_alloc(input_port_config *port, int type, input_port_value defvalue, input_port_value maskbits) +input_field_config::input_field_config(input_port_config &port, int _type, input_port_value _defvalue, input_port_value _maskbits, const char *_name) + : mask(_maskbits), + defvalue(_defvalue & _maskbits), + type(_type), + player(0), + category(0), + flags(0), + impulse(0), + name(_name), + read(NULL), + read_param(NULL), + read_device(NULL), + write(NULL), + write_param(NULL), + write_device(NULL), + min(0), + max(_maskbits), + sensitivity(0), + delta(0), + centerdelta(0), + crossaxis(0), + crossscale(0), + crossoffset(0), + crossaltaxis(0), + crossmapper(NULL), + full_turn_count(0), + remap_table(NULL), + way(0), + state(NULL), + m_next(NULL), + m_port(port), + m_modcount(port.modcount()) { - input_field_config *config; - int seqtype; - - /* allocate memory */ - config = global_alloc_clear(input_field_config); - - /* fill in the basic field values */ - config->port = port; - config->type = type; - config->mask = maskbits; - config->defvalue = defvalue & maskbits; - config->max = maskbits; - for (seqtype = 0; seqtype < ARRAY_LENGTH(config->seq); seqtype++) - input_seq_set_1(&config->seq[seqtype], SEQCODE_DEFAULT); - - return config; + memset(&condition, 0, sizeof(condition)); + for (int seqtype = 0; seqtype < ARRAY_LENGTH(seq); seqtype++) + input_seq_set_1(&seq[seqtype], SEQCODE_DEFAULT); } +input_setting_config::input_setting_config(input_field_config &field, input_port_value _value, const char *_name) + : value(_value), + name(_name), + category(0), + m_field(field), + m_next(NULL) +{ + memset(&condition, 0, sizeof(condition)); +} + +input_field_diplocation::input_field_diplocation(const char *string, UINT8 _swnum, bool _invert) + : swname(string), + swnum(_swnum), + invert(_invert) +{ +} + /*------------------------------------------------- field_config_insert - insert an allocated input port field config, replacing any @@ -3690,120 +2964,65 @@ static input_field_config *field_config_alloc(input_port_config *port, int type, inserting at the correct sorted location -------------------------------------------------*/ -static void field_config_insert(input_field_config *field, input_port_value *disallowedbits, char *errorbuf, int errorbuflen) +void input_port_config::collapse_fields(astring &errorbuf) { - const input_field_config * const *scanfieldptr; - const input_field_config * const *scanfieldnextptr; - input_field_config *config; - input_port_value lowbit; - - /* verify against the disallowed bits, but only if we are condition-free */ - if (field->condition.condition == PORTCOND_ALWAYS) + input_field_config *list = m_fieldlist.detach_all(); + input_port_value maskbits = 0; + int lastmodcount = -1; + while (list != NULL) { - if ((field->mask & *disallowedbits) != 0) - error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_FIELD specifies duplicate port bits (mask=%X)\n", field->mask); - *disallowedbits |= field->mask; + if (list->modcount() != lastmodcount) + { + lastmodcount = list->modcount(); + maskbits = 0; + } + input_field_config *current = list; + list = list->next(); + field_config_insert(*current, maskbits, errorbuf); + } +} + +void field_config_insert(input_field_config &newfield, input_port_value &disallowedbits, astring &errorbuf) +{ + input_port_value lowbit; + + /* verify against the disallowed bits, but only if we are condition-free */ + if (newfield.condition.condition == PORTCOND_ALWAYS) + { + if ((newfield.mask & disallowedbits) != 0) + errorbuf.catprintf("INPUT_TOKEN_FIELD specifies duplicate port bits (port=%s mask=%X)\n", newfield.port().tag(), newfield.mask); + disallowedbits |= newfield.mask; } /* first modify/nuke any entries that intersect our maskbits */ - for (scanfieldptr = &field->port->fieldlist; *scanfieldptr != NULL; scanfieldptr = scanfieldnextptr) + input_field_config *nextfield; + for (input_field_config *field = newfield.port().fieldlist().first(); field != NULL; field = nextfield) { - scanfieldnextptr = &(*scanfieldptr)->next; - if (((*scanfieldptr)->mask & field->mask) != 0 && (field->condition.condition == PORTCOND_ALWAYS || - (*scanfieldptr)->condition.condition == PORTCOND_ALWAYS || - condition_equal(&(*scanfieldptr)->condition, &field->condition))) + nextfield = field->next(); + if ((field->mask & newfield.mask) != 0 && (newfield.condition.condition == PORTCOND_ALWAYS || + field->condition.condition == PORTCOND_ALWAYS || + condition_equal(&field->condition, &newfield.condition))) { /* reduce the mask of the field we found */ - config = (input_field_config *)*scanfieldptr; - config->mask &= ~field->mask; + field->mask &= ~newfield.mask; /* if the new entry fully overrides the previous one, we nuke */ - if (INPUT_PORT_OVERRIDE_FULLY_NUKES_PREVIOUS || config->mask == 0) - { - field_config_free((input_field_config **)scanfieldptr); - scanfieldnextptr = scanfieldptr; - } + if (INPUT_PORT_OVERRIDE_FULLY_NUKES_PREVIOUS || field->mask == 0) + newfield.port().fieldlist().remove(*field); } } /* make a mask of just the low bit */ - lowbit = (field->mask ^ (field->mask - 1)) & field->mask; + lowbit = (newfield.mask ^ (newfield.mask - 1)) & newfield.mask; /* scan forward to find where to insert ourselves */ - for (scanfieldptr = (const input_field_config * const *)&field->port->fieldlist; *scanfieldptr != NULL; scanfieldptr = &(*scanfieldptr)->next) - if ((*scanfieldptr)->mask > lowbit) + input_field_config *field; + for (field = newfield.port().fieldlist().first(); field != NULL; field = field->next()) + if (field->mask > lowbit) break; /* insert it into the list */ - field->next = *scanfieldptr; - *(input_field_config **)scanfieldptr = field; -} - - -/*------------------------------------------------- - field_config_free - free an allocated input - field configuration --------------------------------------------------*/ - -static void field_config_free(input_field_config **fieldptr) -{ - input_field_config *field = *fieldptr; - - /* free any settings and DIP locations first */ - while (field->settinglist != NULL) - setting_config_free((input_setting_config **)&field->settinglist); - while (field->diploclist != NULL) - diplocation_free((input_field_diplocation **)&field->diploclist); - - /* remove ourself from the list */ - *fieldptr = (input_field_config *)field->next; - - /* free ourself */ - global_free(field); -} - - -/*------------------------------------------------- - setting_config_alloc - allocate a new input - port setting and append it to the end of the - list --------------------------------------------------*/ - -static input_setting_config *setting_config_alloc(input_field_config *field, input_port_value value, const char *name) -{ - const input_setting_config * const *tailptr; - input_setting_config *config; - - /* allocate memory */ - config = global_alloc_clear(input_setting_config); - - /* fill in the basic setting values */ - config->field = field; - config->value = value; - config->name = name; - - /* add it to the tail */ - for (tailptr = &field->settinglist; *tailptr != NULL; tailptr = &(*tailptr)->next) ; - *(input_setting_config **)tailptr = config; - - return config; -} - - -/*------------------------------------------------- - setting_config_free - free an allocated input - setting configuration --------------------------------------------------*/ - -static void setting_config_free(input_setting_config **settingptr) -{ - input_setting_config *setting = (input_setting_config *)*settingptr; - - /* remove ourself from the list */ - *settingptr = (input_setting_config *)setting->next; - - /* free ourself */ - global_free(setting); + newfield.port().fieldlist().insert_before(newfield, field); } @@ -3813,113 +3032,82 @@ static void setting_config_free(input_setting_config **settingptr) descriptions -------------------------------------------------*/ -static const input_field_diplocation *diplocation_list_alloc(const input_field_config *field, const char *location, char *errorbuf, int errorbuflen) +void diplocation_list_alloc(input_field_config &field, const char *location, astring &errorbuf) { - input_field_diplocation *head = NULL; - input_field_diplocation **tailptr = &head; - const char *curentry = location; - char *lastname = NULL; - char tempbuf[100]; - input_port_value temp; - int entries = 0; - int val, bits; - /* if nothing present, bail */ if (location == NULL) - return NULL; + return; + + field.diploclist().reset(); /* parse the string */ + const char *lastname = NULL; + const char *curentry = location; + int entries = 0; while (*curentry != 0) { - const char *comma, *colon, *number; - - /* allocate a new entry */ - *tailptr = global_alloc_clear(input_field_diplocation); - entries++; - /* find the end of this entry */ - comma = strchr(curentry, ','); + const char *comma = strchr(curentry, ','); if (comma == NULL) comma = curentry + strlen(curentry); /* extract it to tempbuf */ - strncpy(tempbuf, curentry, comma - curentry); - tempbuf[comma - curentry] = 0; + astring tempstr; + tempstr.cpy(curentry, comma - curentry); /* first extract the switch name if present */ - number = tempbuf; - colon = strchr(tempbuf, ':'); + const char *number = tempstr; + const char *colon = strchr(tempstr, ':'); /* allocate and copy the name if it is present */ + astring name; if (colon != NULL) { - (*tailptr)->swname = lastname = global_alloc_array(char, colon - tempbuf + 1); - strncpy(lastname, tempbuf, colon - tempbuf); - lastname[colon - tempbuf] = 0; + lastname = name.cpy(number, colon - number); number = colon + 1; } /* otherwise, just copy the last name */ else { - char *namecopy; if (lastname == NULL) { - error_buf_append(errorbuf, errorbuflen, "Switch location '%s' missing switch name!\n", location); + errorbuf.catprintf("Switch location '%s' missing switch name!\n", location); lastname = (char *)"UNK"; } - (*tailptr)->swname = namecopy = global_alloc_array(char, strlen(lastname) + 1); - strcpy(namecopy, lastname); + name.cpy(lastname); } /* if the number is preceded by a '!' it's active high */ - (*tailptr)->invert = FALSE; + bool invert = false; if (*number == '!') { - (*tailptr)->invert = TRUE; + invert = true; number++; } /* now scan the switch number */ - if (sscanf(number, "%d", &val) != 1) - error_buf_append(errorbuf, errorbuflen, "Switch location '%s' has invalid format!\n", location); - else - (*tailptr)->swnum = val; + int swnum = -1; + if (sscanf(number, "%d", &swnum) != 1) + errorbuf.catprintf("Switch location '%s' has invalid format!\n", location); + + /* allocate a new entry */ + field.diploclist().append(*global_alloc(input_field_diplocation(name, swnum, invert))); + entries++; /* advance to the next item */ curentry = comma; if (*curentry != 0) curentry++; - tailptr = &(*tailptr)->next; } /* then verify the number of bits in the mask matches */ - for (bits = 0, temp = field->mask; temp != 0 && bits < 32; bits++) + input_port_value temp; + int bits; + for (bits = 0, temp = field.mask; temp != 0 && bits < 32; bits++) temp &= temp - 1; if (bits != entries) - error_buf_append(errorbuf, errorbuflen, "Switch location '%s' does not describe enough bits for mask %X\n", location, field->mask); - return head; -} - - -/*------------------------------------------------- - diplocation_free - free an allocated dip - location --------------------------------------------------*/ - -static void diplocation_free(input_field_diplocation **diplocptr) -{ - input_field_diplocation *diploc = (input_field_diplocation *)*diplocptr; - - /* free the name */ - if (diploc->swname != NULL) - global_free(diploc->swname); - - /* remove ourself from the list */ - *diplocptr = (input_field_diplocation *)diploc->next; - - /* free ourself */ - global_free(diploc); + errorbuf.catprintf("Switch location '%s' does not describe enough bits for mask %X\n", location, field.mask); } @@ -4190,7 +3378,7 @@ static int load_game_config(running_machine &machine, xml_data_node *portnode, i /* find the port we want; if no tag, search them all */ for (port = machine.m_portlist.first(); port != NULL; port = port->next()) if (tag == NULL || strcmp(get_port_tag(port, tempbuffer), tag) == 0) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) /* find the matching mask and defvalue */ if (field->type == type && field->player == player && @@ -4351,7 +3539,7 @@ static void save_game_inputs(running_machine &machine, xml_data_node *parentnode /* iterate over ports */ for (port = machine.m_portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) if (save_this_input_field_type(field->type)) { int changed = FALSE; @@ -4829,7 +4017,7 @@ int input_machine_has_keyboard(running_machine &machine) const input_port_config *port; for (port = machine.m_portlist.first(); port != NULL; port = port->next()) { - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) { if (field->type == IPT_KEYBOARD) { @@ -4908,7 +4096,7 @@ static int scan_keys(running_machine &machine, const input_port_config *portconf for (port = portconfig; port != NULL; port = port->next()) { - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) { if (field->type == IPT_KEYBOARD) { @@ -5537,7 +4725,7 @@ int input_has_input_class(running_machine &machine, int inputclass) for (port = machine.m_portlist.first(); port != NULL; port = port->next()) { - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) { if (input_classify_port(field) == inputclass) return TRUE; @@ -5562,7 +4750,7 @@ int input_count_players(running_machine &machine) joystick_count = 0; for (port = machine.m_portlist.first(); port != NULL; port = port->next()) { - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) { if (input_classify_port(field) == INPUT_CLASS_CONTROLLER) { @@ -5593,7 +4781,7 @@ int input_category_active(running_machine &machine, int category) /* loop through the input ports */ for (port = machine.m_portlist.first(); port != NULL; port = port->next()) { - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->first_field(); field != NULL; field = field->next()) { /* is this field a category? */ if (field->type == IPT_CATEGORY) @@ -5601,7 +4789,7 @@ int input_category_active(running_machine &machine, int category) /* get the settings value */ input_field_get_user_settings(field, &settings); - for (setting = field->settinglist; setting != NULL; setting = setting->next) + for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) { /* is this the category we want? if so, is this settings value correct? */ if ((setting->category == category) && (settings.value == setting->value)) @@ -5703,3 +4891,70 @@ static void execute_dumpkbd(running_machine &machine, int ref, int params, const fclose(file); } + + + +input_port_config *ioconfig_alloc_port(ioport_list &portlist, device_t &device, const char *tag) +{ + astring fulltag; + device.subtag(fulltag, tag); + return &portlist.append(fulltag, *global_alloc(input_port_config(device, fulltag))); +} + +input_port_config *ioconfig_modify_port(ioport_list &portlist, device_t &device, const char *tag) +{ + astring fulltag; + device.subtag(fulltag, tag); + input_port_config *port = portlist.find(fulltag.cstr()); + if (port == NULL) + throw emu_fatalerror("Requested to modify nonexistent port '%s'", fulltag.cstr()); + port->bump_modcount(); + return port; +} + +input_field_config *ioconfig_alloc_field(input_port_config &port, int type, input_port_value defval, input_port_value mask, const char *name) +{ + if (&port == NULL) + throw emu_fatalerror("INPUT_TOKEN_FIELD encountered with no active port (mask=%X defval=%X)\n", mask, defval); \ + if (type != IPT_UNKNOWN && type != IPT_UNUSED) + port.active |= mask; + if (type == IPT_DIPSWITCH || type == IPT_CONFIG || type == IPT_CATEGORY) + defval = port_default_value(port.tag(), mask, defval, port.owner()); + return &port.fieldlist().append(*global_alloc(input_field_config(port, type, defval, mask, input_port_string_from_token(name)))); +} + +input_field_config *ioconfig_alloc_onoff(input_port_config &port, const char *name, input_port_value defval, input_port_value mask, const char *diplocation, astring &errorbuf) +{ + input_field_config *curfield = ioconfig_alloc_field(port, IPT_DIPSWITCH, defval, mask, name); + if (name == DEF_STR(Service_Mode)) + { + curfield->flags |= FIELD_FLAG_TOGGLE; + curfield->seq[SEQ_TYPE_STANDARD].code[0] = KEYCODE_F2; + } + if (diplocation != NULL) + diplocation_list_alloc(*curfield, diplocation, errorbuf); + ioconfig_alloc_setting(*curfield, defval & mask, DEF_STR(Off)); + ioconfig_alloc_setting(*curfield, ~defval & mask, DEF_STR(On)); + return curfield; +} + +input_setting_config *ioconfig_alloc_setting(input_field_config &field, input_port_value value, const char *name) +{ + return &field.settinglist().append(*global_alloc(input_setting_config(field, value, input_port_string_from_token(name)))); +} + +void ioconfig_field_add_char(input_field_config &field, unicode_char ch, astring &errorbuf) +{ + for (int index = 0; index < ARRAY_LENGTH(field.chars); index++) + if (field.chars[index] == 0) + { + field.chars[index] = ch; + break; + } +} + +void ioconfig_add_code(input_field_config &field, int which, input_code code) +{ + input_seq_append_or(&field.seq[which], code); +} + diff --git a/src/emu/inptport.h b/src/emu/inptport.h index 238d10e3af2..3c9c34495d6 100644 --- a/src/emu/inptport.h +++ b/src/emu/inptport.h @@ -373,68 +373,6 @@ enum }; -/* token types */ -enum -{ - INPUT_TOKEN_INVALID, - INPUT_TOKEN_END, - INPUT_TOKEN_INCLUDE, - INPUT_TOKEN_START, - INPUT_TOKEN_MODIFY, - INPUT_TOKEN_FIELD, - INPUT_TOKEN_SPECIAL_ONOFF, - INPUT_TOKEN_CODE, - INPUT_TOKEN_CODE_DEC, - INPUT_TOKEN_CODE_INC, - INPUT_TOKEN_2WAY, - INPUT_TOKEN_4WAY, - INPUT_TOKEN_8WAY, - INPUT_TOKEN_16WAY, - INPUT_TOKEN_ROTATED, - INPUT_TOKEN_PLAYER1, - INPUT_TOKEN_PLAYER2, - INPUT_TOKEN_PLAYER3, - INPUT_TOKEN_PLAYER4, - INPUT_TOKEN_PLAYER5, - INPUT_TOKEN_PLAYER6, - INPUT_TOKEN_PLAYER7, - INPUT_TOKEN_PLAYER8, - INPUT_TOKEN_COCKTAIL, - INPUT_TOKEN_TOGGLE, - INPUT_TOKEN_NAME, - INPUT_TOKEN_IMPULSE, - INPUT_TOKEN_REVERSE, - INPUT_TOKEN_RESET, - INPUT_TOKEN_MINMAX, - INPUT_TOKEN_SENSITIVITY, - INPUT_TOKEN_KEYDELTA, - INPUT_TOKEN_CENTERDELTA, - INPUT_TOKEN_CROSSHAIR, - INPUT_TOKEN_CROSSHAIR_MAPPER, - INPUT_TOKEN_FULL_TURN_COUNT, - INPUT_TOKEN_POSITIONS, - INPUT_TOKEN_WRAPS, - INPUT_TOKEN_REMAP_TABLE, - INPUT_TOKEN_INVERT, - INPUT_TOKEN_UNUSED, - INPUT_TOKEN_CUSTOM, - INPUT_TOKEN_CHANGED, - INPUT_TOKEN_DIPNAME, - INPUT_TOKEN_DIPSETTING, - INPUT_TOKEN_DIPLOCATION, - INPUT_TOKEN_CONDITION, - INPUT_TOKEN_ADJUSTER, - INPUT_TOKEN_CONFNAME, - INPUT_TOKEN_CONFSETTING, - INPUT_TOKEN_CHAR, - INPUT_TOKEN_CATEGORY, - INPUT_TOKEN_CATEGORY_NAME, - INPUT_TOKEN_CATEGORY_SETTING, - INPUT_TOKEN_READ_LINE_DEVICE, - INPUT_TOKEN_WRITE_LINE_DEVICE, -}; - - /* default strings used in port definitions */ enum { @@ -595,37 +533,23 @@ typedef struct _input_field_state input_field_state; /* forward declarations */ class input_port_config; -typedef struct _input_field_config input_field_config; +class input_field_config; /* template specializations */ typedef tagged_list ioport_list; -/* custom input port callback function */ -typedef UINT32 (*input_field_custom_func)(const input_field_config *field, void *param); +/* read input port callback function */ +typedef UINT32 (*input_field_read_func)(device_t &device, const input_field_config *field, void *param); -/* input port changed callback function */ -typedef void (*input_field_changed_func)(const input_field_config *field, void *param, UINT32 oldval, UINT32 newval); +/* input port write callback function */ +typedef void (*input_field_write_func)(device_t &device, const input_field_config *field, void *param, UINT32 oldval, UINT32 newval); /* crosshair mapping function */ typedef float (*input_field_crossmap_func)(const input_field_config *field, float linear_value); -/* this type is used to encode input port definitions */ -typedef union _input_port_token input_port_token; -union _input_port_token -{ - TOKEN_COMMON_FIELDS - const input_port_token * tokenptr; - input_field_custom_func customptr; - input_field_changed_func changedptr; - input_field_crossmap_func crossmapptr; - read_line_device_func read_line_device; - write_line_device_func write_line_device; -}; - - /* encapsulates a condition on a port field or setting */ typedef struct _input_condition input_condition; struct _input_condition @@ -638,35 +562,63 @@ struct _input_condition /* a single setting for a configuration or DIP switch */ -typedef struct _input_setting_config input_setting_config; -struct _input_setting_config +class input_setting_config { - const input_setting_config *next; /* pointer to next setting in sequence */ - const input_field_config * field; /* pointer back to the field that owns us */ + DISABLE_COPYING(input_setting_config); + friend class simple_list; + +public: + input_setting_config(input_field_config &field, input_port_value value, const char *name); + input_setting_config *next() const { return m_next; } + input_port_value value; /* value of the bits in this setting */ input_condition condition; /* condition under which this setting is valid */ const char * name; /* user-friendly name to display */ UINT16 category; /* (MESS-specific) category */ + +private: + input_field_config & m_field; /* pointer back to the field that owns us */ + input_setting_config * m_next; /* pointer to next setting in sequence */ }; /* a mapping from a bit to a physical DIP switch description */ -typedef struct _input_field_diplocation input_field_diplocation; -struct _input_field_diplocation +class input_field_diplocation { - input_field_diplocation * next; /* pointer to the next bit */ - const char * swname; /* name of the physical DIP switch */ + DISABLE_COPYING(input_field_diplocation); + friend class simple_list; + +public: + input_field_diplocation(const char *string, UINT8 swnum, bool invert); + input_field_diplocation *next() const { return m_next; } + + astring swname; /* name of the physical DIP switch */ UINT8 swnum; /* physical switch number */ - UINT8 invert; /* is this an active-high DIP? */ + bool invert; /* is this an active-high DIP? */ + +private: + input_field_diplocation * m_next; /* pointer to the next bit */ }; /* a single bitfield within an input port */ -struct _input_field_config +class input_field_config { + DISABLE_COPYING(input_field_config); + friend class simple_list; + +public: + input_field_config(input_port_config &port, int type, input_port_value defvalue, input_port_value maskbits, const char *name = NULL); + + input_field_config *next() const { return m_next; } + input_port_config &port() const { return m_port; } + running_machine &machine() const; + simple_list &settinglist() { return m_settinglist; } + const simple_list &settinglist() const { return m_settinglist; } + simple_list &diploclist() { return m_diploclist; } + int modcount() const { return m_modcount; } + /* generally-applicable data */ - const input_field_config * next; /* pointer to next field in sequence */ - const input_port_config * port; /* pointer back to the port that owns us */ input_port_value mask; /* mask of bits belonging to the field */ input_port_value defvalue; /* default value of these bits */ input_condition condition; /* condition under which this field is relevant */ @@ -677,14 +629,12 @@ struct _input_field_config UINT8 impulse; /* number of frames before reverting to defvalue */ const char * name; /* user-friendly name to display */ input_seq seq[SEQ_TYPE_TOTAL];/* sequences of all types */ - read_line_device_func read_line_device; /* input device handler */ - const char * read_device_name; /* input device name */ - write_line_device_func write_line_device; /* output device handler */ - const char * write_device_name; /* input device name */ - input_field_custom_func custom; /* custom callback routine */ - void * custom_param; /* parameter for custom callback routine */ - input_field_changed_func changed; /* changed callback routine */ - void * changed_param; /* parameter for changed callback routine */ + input_field_read_func read; /* read callback routine */ + void * read_param; /* parameter for read callback routine */ + const char * read_device; /* parameter for read callback routine */ + input_field_write_func write; /* write callback routine */ + void * write_param; /* parameter for write callback routine */ + const char * write_device; /* parameter for write callback routine */ /* data relevant to analog control types */ INT32 min; /* minimum value for absolute axes */ @@ -701,13 +651,18 @@ struct _input_field_config const input_port_value * remap_table; /* pointer to an array that remaps the port value */ /* data relevant to other specific types */ - const input_setting_config *settinglist; /* list of input_setting_configs */ - const input_field_diplocation *diploclist; /* list of locations for various bits */ UINT8 way; /* digital joystick 2/4/8-way descriptions */ unicode_char chars[3]; /* (MESS-specific) unicode key data */ /* this field is only valid if the device is live */ input_field_state * state; /* live state of field (NULL if not live) */ + +private: + input_field_config * m_next; /* pointer to next field in sequence */ + input_port_config & m_port; /* pointer back to the port that owns us */ + int m_modcount; + simple_list m_settinglist; /* list of input_setting_configs */ + simple_list m_diploclist; /* list of locations for various bits */ }; @@ -731,30 +686,40 @@ struct _input_device_default input_port_value mask; /* mask to apply to the port */ input_port_value defvalue; /* new default value */ }; + /* a single input port configuration */ class input_port_config { DISABLE_COPYING(input_port_config); + friend class simple_list; public: - input_port_config(const char *tag); - ~input_port_config(); + // construction/destruction + input_port_config(device_t &owner, const char *tag); + // getters input_port_config *next() const { return m_next; } - running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } - void set_machine(running_machine &machine) { m_machine = &machine; } - - input_port_config * m_next; /* pointer to next port */ - const char * tag; /* pointer to this port's tag */ - const input_field_config * fieldlist; /* list of input_field_configs */ + device_t &owner() const { return m_owner; } + running_machine &machine() const; + input_field_config *first_field() const { return m_fieldlist.first(); } + simple_list &fieldlist() { return m_fieldlist; } + const char *tag() const { return m_tag; } + int modcount() const { return m_modcount; } + + void bump_modcount() { m_modcount++; } + + void collapse_fields(astring &errorbuf); /* these fields are only valid if the port is live */ input_port_state * state; /* live state of port (NULL if not live) */ - device_t * owner; /* associated device, when appropriate */ input_port_value active; /* mask of active bits in the port */ private: - running_machine * m_machine; /* machine if port is live */ + input_port_config * m_next; /* pointer to next port */ + device_t & m_owner; /* associated device, when appropriate */ + simple_list m_fieldlist; /* list of input_field_configs */ + astring m_tag; /* pointer to this port's tag */ + int m_modcount; }; @@ -791,11 +756,11 @@ struct _inp_header MACROS ***************************************************************************/ -/* macro for a custom callback functions (PORT_CUSTOM) */ -#define CUSTOM_INPUT(name) UINT32 name(const input_field_config *field, void *param) +/* macro for a read callback function (PORT_CUSTOM) */ +#define CUSTOM_INPUT(name) input_port_value name(device_t &device, const input_field_config *field, void *param) -/* macro for port changed callback functions (PORT_CHANGED) */ -#define INPUT_CHANGED(name) void name(const input_field_config *field, void *param, UINT32 oldval, UINT32 newval) +/* macro for port write callback functions (PORT_CHANGED) */ +#define INPUT_CHANGED(name) void name(device_t &device, const input_field_config *field, void *param, input_port_value oldval, input_port_value newval) /* macro for port changed callback functions (PORT_CROSSHAIR_MAPPER) */ #define CROSSHAIR_MAPPER(name) float name(const input_field_config *field, float linear_value) @@ -804,235 +769,255 @@ struct _inp_header #define DEF_STR(str_num) ((const char *)INPUT_STRING_##str_num) +template +input_port_value ioport_read_line_wrapper(device_t &device, const input_field_config *field, void *param) +{ + return (*_ReadLine)(&device); +} + +template +void ioport_write_line_wrapper(device_t &device, const input_field_config *field, void *param, input_port_value oldval, input_port_value newval) +{ + return (*_WriteLine)(&device, newval); +} + + /*************************************************************************** MACROS FOR BUILDING INPUT PORTS ***************************************************************************/ +typedef void (*ioport_constructor)(device_t &owner, ioport_list &portlist, astring &errorbuf); + /* so that "0" can be used for unneeded input ports */ -#define ipt_0 NULL +#define construct_ioport_0 NULL /* name of table */ -#define INPUT_PORTS_NAME(_name) ipt_##_name +#define INPUT_PORTS_NAME(_name) construct_ioport_##_name /* start of table */ #define INPUT_PORTS_START(_name) \ - const input_port_token INPUT_PORTS_NAME(_name)[] = { +void INPUT_PORTS_NAME(_name)(device_t &owner, ioport_list &portlist, astring &errorbuf) \ +{ \ + astring fulltag; \ + input_setting_config *cursetting = NULL; \ + input_field_config *curfield = NULL; \ + input_port_config *curport = NULL; \ + input_port_value maskbits = 0; \ + (void)cursetting; (void)curfield; (void)curport; (void)maskbits; \ /* end of table */ #define INPUT_PORTS_END \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_END, 8) }; +} /* aliasing */ #define INPUT_PORTS_EXTERN(_name) \ - extern const input_port_token INPUT_PORTS_NAME(_name)[] + extern void INPUT_PORTS_NAME(_name)(device_t &owner, ioport_list &portlist, astring &errorbuf) /* including */ #define PORT_INCLUDE(_name) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_INCLUDE, 8), \ - TOKEN_PTR(tokenptr, &INPUT_PORTS_NAME(_name)[0]), + INPUT_PORTS_NAME(_name)(owner, portlist, errorbuf); \ /* start of a new input port (with included tag) */ #define PORT_START(_tag) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_START, 8), \ - TOKEN_STRING(_tag), + curport = ioconfig_alloc_port(portlist, owner, _tag); \ + curfield = NULL; \ + cursetting = NULL; \ + maskbits = 0; \ /* modify an existing port */ #define PORT_MODIFY(_tag) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_MODIFY, 8), \ - TOKEN_STRING(_tag), + curport = ioconfig_modify_port(portlist, owner, _tag); \ + curfield = NULL; \ + cursetting = NULL; \ + maskbits = 0; \ /* input bit definition */ #define PORT_BIT(_mask, _default, _type) \ - TOKEN_UINT32_PACK2(INPUT_TOKEN_FIELD, 8, _type, 24), \ - TOKEN_UINT64_PACK2(_mask, 32, _default, 32), + curfield = ioconfig_alloc_field(*curport, (_type), (_default), (_mask)); \ + cursetting = NULL; -#define PORT_SPECIAL_ONOFF(_mask, _default, _strindex) \ - TOKEN_UINT32_PACK3(INPUT_TOKEN_SPECIAL_ONOFF, 8, FALSE, 1, INPUT_STRING_##_strindex, 23), \ - TOKEN_UINT64_PACK2(_mask, 32, _default, 32), +#define PORT_SPECIAL_ONOFF(_mask, _default, _strindex) PORT_SPECIAL_ONOFF_DIPLOC(_mask, _default, _strindex, NULL) #define PORT_SPECIAL_ONOFF_DIPLOC(_mask, _default, _strindex, _diploc) \ - TOKEN_UINT32_PACK3(INPUT_TOKEN_SPECIAL_ONOFF, 8, TRUE, 1, INPUT_STRING_##_strindex, 23), \ - TOKEN_UINT64_PACK2(_mask, 32, _default, 32), \ - TOKEN_STRING(_diploc), + curfield = ioconfig_alloc_onoff(*curport, DEF_STR(_strindex), _default, _mask, _diploc, errorbuf); \ + cursetting = NULL; /* append a code */ #define PORT_CODE(_code) \ - TOKEN_UINT64_PACK2(INPUT_TOKEN_CODE, 8, _code, 32), + ioconfig_add_code(*curfield, SEQ_TYPE_STANDARD, _code); #define PORT_CODE_DEC(_code) \ - TOKEN_UINT64_PACK2(INPUT_TOKEN_CODE_DEC, 8, _code, 32), + ioconfig_add_code(*curfield, SEQ_TYPE_DECREMENT, _code); #define PORT_CODE_INC(_code) \ - TOKEN_UINT64_PACK2(INPUT_TOKEN_CODE_INC, 8, _code, 32), + ioconfig_add_code(*curfield, SEQ_TYPE_INCREMENT, _code); /* joystick flags */ #define PORT_2WAY \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_2WAY, 8), + curfield->way = 2; #define PORT_4WAY \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_4WAY, 8), + curfield->way = 4; #define PORT_8WAY \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_8WAY, 8), + curfield->way = 8; #define PORT_16WAY \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_16WAY, 8), + curfield->way = 16; #define PORT_ROTATED \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_ROTATED, 8), + curfield->flags |= FIELD_FLAG_ROTATED /* general flags */ #define PORT_NAME(_name) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_NAME, 8), \ - TOKEN_STRING(_name), + curfield->name = input_port_string_from_token(_name); -#define PORT_PLAYER(player_) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_PLAYER1 + (((player_) - 1) % MAX_PLAYERS), 8), +#define PORT_PLAYER(_player) \ + curfield->player = (_player) - 1; #define PORT_COCKTAIL \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_COCKTAIL, 8), + curfield->flags |= FIELD_FLAG_COCKTAIL; \ + curfield->player = 1; #define PORT_TOGGLE \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_TOGGLE, 8), + curfield->flags |= FIELD_FLAG_TOGGLE; #define PORT_IMPULSE(_duration) \ - TOKEN_UINT32_PACK2(INPUT_TOKEN_IMPULSE, 8, _duration, 24), + curfield->impulse = _duration; #define PORT_REVERSE \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_REVERSE, 8), + curfield->flags |= ANALOG_FLAG_REVERSE; #define PORT_RESET \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_RESET, 8), + curfield->flags |= ANALOG_FLAG_RESET; #define PORT_UNUSED \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_UNUSED, 8), + curfield->flags |= FIELD_FLAG_UNUSED; /* analog settings */ /* if this macro is not used, the minimum defaluts to 0 and maximum defaults to the mask value */ #define PORT_MINMAX(_min, _max) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_MINMAX, 8), \ - TOKEN_UINT64_PACK2(_min, 32, _max, 32), + curfield->min = _min; \ + curfield->max = _max; #define PORT_SENSITIVITY(_sensitivity) \ - TOKEN_UINT32_PACK2(INPUT_TOKEN_SENSITIVITY, 8, _sensitivity, 24), + curfield->sensitivity = _sensitivity; #define PORT_KEYDELTA(_delta) \ - TOKEN_UINT32_PACK2(INPUT_TOKEN_KEYDELTA, 8, _delta, 24), + curfield->delta = curfield->centerdelta = _delta; /* note that PORT_CENTERDELTA must appear after PORT_KEYDELTA */ #define PORT_CENTERDELTA(_delta) \ - TOKEN_UINT32_PACK2(INPUT_TOKEN_CENTERDELTA, 8, _delta, 24), + curfield->delta = curfield->centerdelta = _delta; #define PORT_CROSSHAIR(axis, scale, offset, altaxis) \ - TOKEN_UINT32_PACK3(INPUT_TOKEN_CROSSHAIR, 8, CROSSHAIR_AXIS_##axis, 4, (INT32)((altaxis) * 65536.0f), 20), \ - TOKEN_UINT64_PACK2((INT32)((scale) * 65536.0f), 32, (INT32)((offset) * 65536.0f), 32), + curfield->crossaxis = CROSSHAIR_AXIS_##axis; \ + curfield->crossaltaxis = altaxis; \ + curfield->crossscale = scale; \ + curfield->crossoffset = offset; #define PORT_CROSSHAIR_MAPPER(_callback) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_CROSSHAIR_MAPPER, 8), \ - TOKEN_PTR(crossmapptr, _callback), + curfield->crossmapper = _callback; /* how many optical counts for 1 full turn of the control */ #define PORT_FULL_TURN_COUNT(_count) \ - TOKEN_UINT32_PACK2(INPUT_TOKEN_FULL_TURN_COUNT, 8, _count, 24), + curfield->full_turn_count = _count; /* positional controls can be binary or 1 of X */ /* 1 of X not completed yet */ /* if it is specified as PORT_REMAP_TABLE then it is binary, but remapped */ /* otherwise it is binary */ #define PORT_POSITIONS(_positions) \ - TOKEN_UINT32_PACK2(INPUT_TOKEN_POSITIONS, 8, _positions, 24), + curfield->max = _positions; /* positional control wraps at min/max */ #define PORT_WRAPS \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_WRAPS, 8), + curfield->flags |= ANALOG_FLAG_WRAPS; /* positional control uses this remap table */ #define PORT_REMAP_TABLE(_table) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_REMAP_TABLE, 8), \ - TOKEN_PTR(ui32ptr, _table), + curfield->remap_table = _table; /* positional control bits are active low */ #define PORT_INVERT \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_INVERT, 8), + curfield->flags |= ANALOG_FLAG_INVERT; -/* custom callbacks */ +/* read callbacks */ #define PORT_CUSTOM(_callback, _param) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_CUSTOM, 8), \ - TOKEN_PTR(customptr, _callback), \ - TOKEN_PTR(voidptr, _param), + curfield->read = _callback; \ + curfield->read_param = (void *)(_param); \ + curfield->read_device = NULL; -/* changed callbacks */ +/* write callbacks */ #define PORT_CHANGED(_callback, _param) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_CHANGED, 8), \ - TOKEN_PTR(changedptr, _callback), \ - TOKEN_PTR(voidptr, _param), + curfield->write = _callback; \ + curfield->write_param = (void *)(_param); \ + curfield->write_device = NULL; /* input device handler */ #define PORT_READ_LINE_DEVICE(_device, _read_line_device) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_READ_LINE_DEVICE, 8), \ - TOKEN_STRING(_device), \ - TOKEN_PTR(read_line_device, _read_line_device), + curfield->read = &ioport_read_line_wrapper<_read_line_device>; \ + curfield->read_param = NULL; \ + curfield->read_device = _device; /* output device handler */ #define PORT_WRITE_LINE_DEVICE(_device, _write_line_device) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_WRITE_LINE_DEVICE, 8), \ - TOKEN_STRING(_device), \ - TOKEN_PTR(write_line_device, _write_line_device), + curfield->write = &ioport_write_line_wrapper<_write_line_device>; \ + curfield->write_param = NULL; \ + curfield->write_device = _device; /* dip switch definition */ #define PORT_DIPNAME(_mask, _default, _name) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_DIPNAME, 8), \ - TOKEN_UINT64_PACK2(_mask, 32, _default, 32), \ - TOKEN_STRING(_name), + curfield = ioconfig_alloc_field(*curport, IPT_DIPSWITCH, (_default), (_mask), (_name)); \ + cursetting = NULL; #define PORT_DIPSETTING(_default, _name) \ - TOKEN_UINT64_PACK2(INPUT_TOKEN_DIPSETTING, 8, _default, 32), \ - TOKEN_STRING(_name), + cursetting = ioconfig_alloc_setting(*curfield, (_default) & curfield->mask, (_name)); /* physical location, of the form: name:[!]sw,[name:][!]sw,... */ /* note that these are specified LSB-first */ #define PORT_DIPLOCATION(_location) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_DIPLOCATION, 8), \ - TOKEN_STRING(_location), + diplocation_list_alloc(*curfield, _location, errorbuf); /* conditionals for dip switch settings */ #define PORT_CONDITION(_tag, _mask, _condition, _value) \ - TOKEN_UINT32_PACK2(INPUT_TOKEN_CONDITION, 8, _condition, 24), \ - TOKEN_UINT64_PACK2(_mask, 32, _value, 32), \ - TOKEN_STRING(_tag), +{ \ + input_condition &condition = (cursetting != NULL) ? cursetting->condition : curfield->condition; \ + condition.tag = (_tag); \ + condition.mask = (_mask); \ + condition.condition = (_condition); \ + condition.value = (_value); \ +} /* analog adjuster definition */ #define PORT_ADJUSTER(_default, _name) \ - TOKEN_UINT64_PACK2(INPUT_TOKEN_ADJUSTER, 8, _default, 32), \ - TOKEN_STRING(_name), + curfield = ioconfig_alloc_field(*curport, IPT_ADJUSTER, (_default), 0xff, (_name)); \ + cursetting = NULL; \ /* config definition */ #define PORT_CONFNAME(_mask, _default, _name) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_CONFNAME, 8), \ - TOKEN_UINT64_PACK2(_mask, 32, _default, 32), \ - TOKEN_STRING(_name), + curfield = ioconfig_alloc_field(*curport, IPT_CONFIG, (_default), (_mask), (_name)); \ + cursetting = NULL; \ #define PORT_CONFSETTING(_default, _name) \ - TOKEN_UINT64_PACK2(INPUT_TOKEN_CONFSETTING, 8, _default, 32), \ - TOKEN_STRING(_name), + cursetting = ioconfig_alloc_setting(*curfield, (_default) & curfield->mask, (_name)); /* keyboard chars */ #define PORT_CHAR(_ch) \ - TOKEN_UINT64_PACK2(INPUT_TOKEN_CHAR, 8, _ch, 32), \ + ioconfig_field_add_char(*curfield, _ch, errorbuf); /* categories */ #define PORT_CATEGORY(_category) \ - TOKEN_UINT32_PACK2(INPUT_TOKEN_CATEGORY, 8, _category, 24), + curfield->category = (_category); #define PORT_CATEGORY_CLASS(_mask, _default, _name) \ - TOKEN_UINT32_PACK1(INPUT_TOKEN_CATEGORY_NAME, 8), \ - TOKEN_UINT64_PACK2(_mask, 32, _default, 32), \ - TOKEN_STRING(_name), + curfield = ioconfig_alloc_field(*curport, IPT_CATEGORY, (_default), (_mask), (_name)); \ + cursetting = NULL; #define PORT_CATEGORY_ITEM(_default, _name, _category) \ - TOKEN_UINT64_PACK3(INPUT_TOKEN_CATEGORY_SETTING, 8, _default, 32, _category, 16), \ - TOKEN_STRING(_name), + cursetting = ioconfig_alloc_setting(*curfield, (_default) & curfield->mask, (_name)); \ + cursetting->category = (_category); /* name of table */ @@ -1085,14 +1070,14 @@ struct _inp_header /* ----- core system management ----- */ /* initialize the input ports, processing the given token list */ -time_t input_port_init(running_machine &machine, const device_list &devicelist); +time_t input_port_init(running_machine &machine); /* ----- port configurations ----- */ /* initialize an input port list structure and allocate ports according to the given tokens */ -void input_port_list_init(ioport_list &portlist, const input_port_token *tokens, char *errorbuf, int errorbuflen, int allocmap, device_t *owner); +void input_port_list_init(device_t &device, ioport_list &portlist, astring &errorbuf); /* return the field that matches the given tag and mask */ const input_field_config *input_field_by_tag_and_mask(const ioport_list &portlist, const char *tag, input_port_value mask); @@ -1207,7 +1192,7 @@ void input_port_write_safe(running_machine &machine, const char *tag, input_port int input_condition_true(running_machine &machine, const input_condition *condition); /* convert an input_port_token to a default string */ -const char *input_port_string_from_token(const input_port_token token); +const char *input_port_string_from_token(const char *token); /* return TRUE if machine use full keyboard emulation */ int input_machine_has_keyboard(running_machine &machine); @@ -1240,4 +1225,24 @@ int input_player_number(const input_field_config *field); int input_count_players(running_machine &machine); int input_category_active(running_machine &machine, int category); + +inline running_machine &input_field_config::machine() const +{ + return m_port.machine(); +} + + +// temporary construction helpers +void field_config_insert(input_field_config &newfield, input_port_value &disallowedbits, astring &errorbuf); +void diplocation_list_alloc(input_field_config &field, const char *location, astring &errorbuf); + + +input_port_config *ioconfig_alloc_port(ioport_list &portlist, device_t &device, const char *tag); +input_port_config *ioconfig_modify_port(ioport_list &portlist, device_t &device, const char *tag); +input_field_config *ioconfig_alloc_field(input_port_config &port, int type, input_port_value defval, input_port_value mask, const char *name = NULL); +input_field_config *ioconfig_alloc_onoff(input_port_config &port, const char *name, input_port_value defval, input_port_value mask, const char *diplocation, astring &errorbuf); +input_setting_config *ioconfig_alloc_setting(input_field_config &field, input_port_value value, const char *name); +void ioconfig_field_add_char(input_field_config &field, unicode_char ch, astring &errorbuf); +void ioconfig_add_code(input_field_config &field, int which, input_code code); + #endif /* __INPTPORT_H__ */ diff --git a/src/emu/machine.c b/src/emu/machine.c index 87f76ea0193..7d5c8efa1ce 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -279,7 +279,7 @@ void running_machine::start() // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags - time_t newbase = input_port_init(*this, devicelist()); + time_t newbase = input_port_init(*this); if (newbase != 0) m_base_time = newbase; @@ -1145,7 +1145,7 @@ const rom_entry *driver_device::device_rom_region() const // game's input ports //------------------------------------------------- -const input_port_token *driver_device::device_input_ports() const +ioport_constructor driver_device::device_input_ports() const { return m_system->ipt; } diff --git a/src/emu/machine.h b/src/emu/machine.h index abdd6e0ffa7..9fb7ad26498 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -576,7 +576,7 @@ protected: // device-level overrides virtual const rom_entry *device_rom_region() const; - virtual const input_port_token *device_input_ports() const; + virtual ioport_constructor device_input_ports() const; virtual void device_start(); virtual void device_reset(); diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c index 93613f2b46b..95eefa60b1d 100644 --- a/src/emu/machine/generic.c +++ b/src/emu/machine/generic.c @@ -748,5 +748,5 @@ READ32_HANDLER( watchdog_reset32_r ) { watchdog_reset(space->machine()); return CUSTOM_INPUT( custom_port_read ) { const char *tag = (const char *)param; - return input_port_read(field->port->machine(), tag); + return input_port_read(field->machine(), tag); } diff --git a/src/emu/memory.c b/src/emu/memory.c index ea139da4c8f..bf9cfbd23df 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -4592,13 +4592,13 @@ void handler_entry_read::set_ioport(const input_port_config &ioport) { m_ioport = &ioport; if (m_datawidth == 8) - set_delegate(read8_delegate(&handler_entry_read::read_stub_ioport, ioport.tag, this)); + set_delegate(read8_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 16) - set_delegate(read16_delegate(&handler_entry_read::read_stub_ioport, ioport.tag, this)); + set_delegate(read16_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 32) - set_delegate(read32_delegate(&handler_entry_read::read_stub_ioport, ioport.tag, this)); + set_delegate(read32_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 64) - set_delegate(read64_delegate(&handler_entry_read::read_stub_ioport, ioport.tag, this)); + set_delegate(read64_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); } @@ -4919,13 +4919,13 @@ void handler_entry_write::set_ioport(const input_port_config &ioport) { m_ioport = &ioport; if (m_datawidth == 8) - set_delegate(write8_delegate(&handler_entry_write::write_stub_ioport, ioport.tag, this)); + set_delegate(write8_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 16) - set_delegate(write16_delegate(&handler_entry_write::write_stub_ioport, ioport.tag, this)); + set_delegate(write16_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 32) - set_delegate(write32_delegate(&handler_entry_write::write_stub_ioport, ioport.tag, this)); + set_delegate(write32_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 64) - set_delegate(write64_delegate(&handler_entry_write::write_stub_ioport, ioport.tag, this)); + set_delegate(write64_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); } diff --git a/src/emu/tokenize.h b/src/emu/tokenize.h deleted file mode 100644 index af35c6a35a5..00000000000 --- a/src/emu/tokenize.h +++ /dev/null @@ -1,258 +0,0 @@ -/*************************************************************************** - - tokenize.h - - Common definitions and macros for tokenizing definitions. - - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. - -***************************************************************************/ - -#pragma once - -#ifndef __TOKENIZE_H__ -#define __TOKENIZE_H__ - - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -/* tokens per item */ -#define TOKENS_PER_PTR (1) -#define TOKENS_PER_UINT32 (1) -#define TOKENS_PER_UINT64 (8 / sizeof(FPTR)) -#define TOKENS_PER_ATTOTIME (TOKENS_PER_UINT32 + TOKENS_PER_UINT64) - - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -/* include this at the top of your union to get the standard fields */ -#define TOKEN_COMMON_FIELDS \ - FPTR i; \ - const char * stringptr; \ - const void * voidptr; \ - const UINT8 * ui8ptr; \ - const INT8 * i8ptr; \ - const UINT16 * ui16ptr; \ - const INT16 * i16ptr; \ - const UINT32 * ui32ptr; \ - const INT32 * i32ptr; \ - const UINT64 * ui64ptr; \ - const INT64 * i64ptr; \ - - -/* generic_token can be used when there are no particularly special types */ -typedef struct _generic_token generic_token; -struct _generic_token -{ - TOKEN_COMMON_FIELDS -}; - - - -/*************************************************************************** - MACROS -***************************************************************************/ - -/* ----- compile-time token generation macros ----- */ - -/* GCC and C99 compilers can use designated initializers for type safety */ -#if (defined(__GNUC__) && (__GNUC__ >= 3) && !defined(__cplusplus)) || (defined(_STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) -#define TOKEN_VALUE(field,a) { .field = (a) } -#else -#define TOKEN_VALUE(field,a) { (FPTR)(a) } -#endif - -/* token output primitives */ -/* note that regardless of the endianness, UINT64s are packed LSW first */ -#define TOKEN_PTR(field,p) TOKEN_VALUE(field, p) -#define TOKEN_STRING(p) TOKEN_VALUE(stringptr, p) -#define TOKEN_UINT32(a) TOKEN_VALUE(i, a) -#ifdef PTR64 -#define TOKEN_UINT64(a) TOKEN_VALUE(i, a) -#else -#define TOKEN_UINT64(a) TOKEN_VALUE(i, (UINT32)(a)), TOKEN_VALUE(i, (UINT32)((a) >> 32)) -#endif - -/* mask a value to a fixed number of bits and then shift it */ -#define SHIFT_AND_MASK32(val, bits, shift) (((UINT32)(val) & ((1 << (bits)) - 1)) << (shift)) -#define SHIFT_AND_MASK64(val, bits, shift) (((UINT64)(val) & (((UINT64)1 << (bits)) - 1)) << (shift)) - -/* 32-bit integer packing */ -#define TOKEN_UINT32_PACK1(val1, bits1) \ - TOKEN_UINT32(SHIFT_AND_MASK32((val1), (bits1), 0)) - -#define TOKEN_UINT32_PACK2(val1, bits1, val2, bits2) \ - TOKEN_UINT32(SHIFT_AND_MASK32((val1), (bits1), 0) | \ - SHIFT_AND_MASK32((val2), (bits2), (bits1))) - -#define TOKEN_UINT32_PACK3(val1, bits1, val2, bits2, val3, bits3) \ - TOKEN_UINT32(SHIFT_AND_MASK32((val1), (bits1), 0) | \ - SHIFT_AND_MASK32((val2), (bits2), (bits1)) | \ - SHIFT_AND_MASK32((val3), (bits3), (bits1)+(bits2))) - -#define TOKEN_UINT32_PACK4(val1, bits1, val2, bits2, val3, bits3, val4, bits4) \ - TOKEN_UINT32(SHIFT_AND_MASK32((val1), (bits1), 0) | \ - SHIFT_AND_MASK32((val2), (bits2), (bits1)) | \ - SHIFT_AND_MASK32((val3), (bits3), (bits1)+(bits2)) | \ - SHIFT_AND_MASK32((val4), (bits4), (bits1)+(bits2)+(bits3))) - -/* 64-bit integer packing */ -#define TOKEN_UINT64_PACK1(val1, bits1) \ - TOKEN_UINT64(SHIFT_AND_MASK64((val1), (bits1), 0)) - -#define TOKEN_UINT64_PACK2(val1, bits1, val2, bits2) \ - TOKEN_UINT64(SHIFT_AND_MASK64((val1), (bits1), 0) | \ - SHIFT_AND_MASK64((val2), (bits2), (bits1))) - -#define TOKEN_UINT64_PACK3(val1, bits1, val2, bits2, val3, bits3) \ - TOKEN_UINT64(SHIFT_AND_MASK64((val1), (bits1), 0) | \ - SHIFT_AND_MASK64((val2), (bits2), (bits1)) | \ - SHIFT_AND_MASK64((val3), (bits3), (bits1)+(bits2))) - -#define TOKEN_UINT64_PACK4(val1, bits1, val2, bits2, val3, bits3, val4, bits4) \ - TOKEN_UINT64(SHIFT_AND_MASK64((val1), (bits1), 0) | \ - SHIFT_AND_MASK64((val2), (bits2), (bits1)) | \ - SHIFT_AND_MASK64((val3), (bits3), (bits1)+(bits2)) | \ - SHIFT_AND_MASK64((val4), (bits4), (bits1)+(bits2)+(bits3))) - - - -/* ----- run-time token extraction macros ----- */ - -/* token fetch and advance primitives */ -#define TOKEN_GET_PTR(tp,field) (((tp)++)->field) -#define TOKEN_GET_STRING(tp) (((tp)++)->stringptr) -#define TOKEN_GET_UINT32(tp) (((tp)++)->i) -#ifdef PTR64 -#define TOKEN_EXTRACT_UINT64(tp,a) do { (a) = (tp)->i; (tp)++; } while (0) -#else -#define TOKEN_EXTRACT_UINT64(tp,a) do { (a) = (tp)[0].i | ((UINT64)(tp)[1].i << 32); (tp) += 2; } while (0) -#endif - -/* token unfetch primitives */ -#define TOKEN_UNGET_PTR(tp) ((tp)--) -#define TOKEN_UNGET_STRING(tp) ((tp)--) -#define TOKEN_UNGET_UINT32(tp) ((tp)--) -#define TOKEN_UNGET_UINT64(tp) ((tp) -= 8 / sizeof(FPTR)) - -/* token skip primitives */ -#define TOKEN_SKIP_PTR(tp) ((tp)++) -#define TOKEN_SKIP_STRING(tp) ((tp)++) -#define TOKEN_SKIP_UINT32(tp) ((tp)++) -#define TOKEN_SKIP_UINT64(tp) ((tp) += 8 / sizeof(FPTR)) - -/* extract a value from a fixed number of bits; if bits is negative, treat it as a signed value */ -#define UNSHIFT_AND_MASK32(src, val, bits, shift) do { \ - if ((bits) < 0) \ - (val) = token_sign_extend32((src) >> (shift), (UINT8)-(bits)); \ - else \ - (val) = token_zero_extend32((src) >> (shift), (UINT8)(bits)); \ -} while (0) - -#define UNSHIFT_AND_MASK64(src, val, bits, shift) do { \ - if ((bits) < 0) \ - (val) = token_sign_extend64((src) >> (shift), (UINT8)-(bits)); \ - else \ - (val) = token_zero_extend64((src) >> (shift), (UINT8)(bits)); \ -} while (0) - -/* cheesy inline absolute value */ -#define TOKENABS(v) (((v) < 0) ? -(v) : (v)) - -/* 32-bit integer unpacking */ -#define TOKEN_GET_UINT32_UNPACK1(tp, val1, bits1) do { \ - UINT32 token32 = TOKEN_GET_UINT32(tp); \ - UNSHIFT_AND_MASK32(token32, val1, (bits1), 0); \ -} while (0) - -#define TOKEN_GET_UINT32_UNPACK2(tp, val1, bits1, val2, bits2) do { \ - UINT32 token32 = TOKEN_GET_UINT32(tp); \ - UINT8 shift = 0; \ - UNSHIFT_AND_MASK32(token32, val1, (bits1), shift); shift += TOKENABS(bits1); \ - UNSHIFT_AND_MASK32(token32, val2, (bits2), shift); \ -} while (0) - -#define TOKEN_GET_UINT32_UNPACK3(tp, val1, bits1, val2, bits2, val3, bits3) do { \ - UINT32 token32 = TOKEN_GET_UINT32(tp); \ - UINT8 shift = 0; \ - UNSHIFT_AND_MASK32(token32, val1, (bits1), shift); shift += TOKENABS(bits1); \ - UNSHIFT_AND_MASK32(token32, val2, (bits2), shift); shift += TOKENABS(bits2); \ - UNSHIFT_AND_MASK32(token32, val3, (bits3), shift); \ -} while (0) - -#define TOKEN_GET_UINT32_UNPACK4(tp, val1, bits1, val2, bits2, val3, bits3, val4, bits4) do { \ - UINT32 token32 = TOKEN_GET_UINT32(tp); \ - UINT8 shift = 0; \ - UNSHIFT_AND_MASK32(token32, val1, (bits1), shift); shift += TOKENABS(bits1); \ - UNSHIFT_AND_MASK32(token32, val2, (bits2), shift); shift += TOKENABS(bits2); \ - UNSHIFT_AND_MASK32(token32, val3, (bits3), shift); shift += TOKENABS(bits3); \ - UNSHIFT_AND_MASK32(token32, val4, (bits4), shift); \ -} while (0) - -/* 64-bit integer unpacking */ -#define TOKEN_GET_UINT64_UNPACK1(tp, val1, bits1) do { \ - UINT64 token64; \ - TOKEN_EXTRACT_UINT64(tp, token64); \ - UNSHIFT_AND_MASK64(token64, val1, (bits1), 0); \ -} while (0) - -#define TOKEN_GET_UINT64_UNPACK2(tp, val1, bits1, val2, bits2) do { \ - UINT64 token64; \ - UINT8 shift = 0; \ - TOKEN_EXTRACT_UINT64(tp, token64); \ - UNSHIFT_AND_MASK64(token64, val1, (bits1), shift); shift += TOKENABS(bits1); \ - UNSHIFT_AND_MASK64(token64, val2, (bits2), shift); \ -} while (0) - -#define TOKEN_GET_UINT64_UNPACK3(tp, val1, bits1, val2, bits2, val3, bits3) do { \ - UINT64 token64; \ - UINT8 shift = 0; \ - TOKEN_EXTRACT_UINT64(tp, token64); \ - UNSHIFT_AND_MASK64(token64, val1, (bits1), shift); shift += TOKENABS(bits1); \ - UNSHIFT_AND_MASK64(token64, val2, (bits2), shift); shift += TOKENABS(bits2); \ - UNSHIFT_AND_MASK64(token64, val3, (bits3), shift); \ -} while (0) - -#define TOKEN_GET_UINT64_UNPACK4(tp, val1, bits1, val2, bits2, val3, bits3, val4, bits4) do { \ - UINT64 token64; \ - UINT8 shift = 0; \ - TOKEN_EXTRACT_UINT64(tp, token64); \ - UNSHIFT_AND_MASK64(token64, val1, (bits1), shift); shift += TOKENABS(bits1); \ - UNSHIFT_AND_MASK64(token64, val2, (bits2), shift); shift += TOKENABS(bits2); \ - UNSHIFT_AND_MASK64(token64, val3, (bits3), shift); shift += TOKENABS(bits3); \ - UNSHIFT_AND_MASK64(token64, val4, (bits4), shift); \ -} while (0) - - - -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ - -INLINE UINT32 token_zero_extend32(UINT32 val, UINT8 bits) -{ - return val & (((UINT32)1 << bits) - 1); -} - -INLINE INT32 token_sign_extend32(UINT32 val, UINT8 bits) -{ - return (INT32)(val << (32 - bits)) >> (32 - bits); -} - -INLINE UINT64 token_zero_extend64(UINT64 val, UINT8 bits) -{ - return val & (((UINT64)1 << bits) - 1); -} - -INLINE INT64 token_sign_extend64(UINT64 val, UINT8 bits) -{ - return (INT64)(val << (64 - bits)) >> (64 - bits); -} - -#endif diff --git a/src/emu/ui.c b/src/emu/ui.c index a9c4911b8e7..e1f4c47a919 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -1595,8 +1595,8 @@ static slider_state *slider_alloc(running_machine &machine, const char *title, I static slider_state *slider_init(running_machine &machine) { - const input_field_config *field; - const input_port_config *port; + input_field_config *field; + input_port_config *port; device_t *device; slider_state *listhead = NULL; slider_state **tailptr = &listhead; @@ -1625,7 +1625,7 @@ static slider_state *slider_init(running_machine &machine) /* add analog adjusters */ for (port = machine.m_portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->fieldlist().first(); field != NULL; field = field->next()) if (field->type == IPT_ADJUSTER) { void *param = (void *)field; @@ -1730,7 +1730,7 @@ static slider_state *slider_init(running_machine &machine) #ifdef MAME_DEBUG /* add crosshair adjusters */ for (port = machine.m_portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->fieldlist().first(); field != NULL; field = field->next()) if (field->crossaxis != CROSSHAIR_AXIS_NONE && field->player == 0) { void *param = (void *)field; diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c index f3a36c86ca3..81f00f0fe1d 100644 --- a/src/emu/uimenu.c +++ b/src/emu/uimenu.c @@ -168,7 +168,7 @@ struct _input_item_data typedef struct _analog_item_data analog_item_data; struct _analog_item_data { - const input_field_config *field; + input_field_config *field; int type; int min, max; int cur; @@ -327,10 +327,10 @@ static void menu_settings_custom_render(running_machine &machine, ui_menu *menu, to the default sequence for the given field -------------------------------------------------*/ -INLINE const input_seq *get_field_default_seq(const input_field_config *field, input_seq_type seqtype) +INLINE const input_seq *get_field_default_seq(input_field_config *field, input_seq_type seqtype) { if (input_seq_get_1(&field->seq[seqtype]) == SEQCODE_DEFAULT) - return input_type_seq(field->port->machine(), field->type, field->player, seqtype); + return input_type_seq(field->machine(), field->type, field->player, seqtype); else return &field->seq[seqtype]; } @@ -1625,8 +1625,8 @@ static void ui_menu_slot_devices(running_machine &machine, ui_menu *menu, void * static void menu_main_populate(running_machine &machine, ui_menu *menu, void *state) { - const input_field_config *field; - const input_port_config *port; + input_field_config *field; + input_port_config *port; int has_categories = FALSE; int has_configs = FALSE; int has_analog = FALSE; @@ -1634,7 +1634,7 @@ static void menu_main_populate(running_machine &machine, ui_menu *menu, void *st /* scan the input port array to see what options we need to enable */ for (port = machine.m_portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->fieldlist().first(); field != NULL; field = field->next()) { if (field->type == IPT_DIPSWITCH) has_dips = TRUE; @@ -1844,8 +1844,8 @@ static void menu_input_specific(running_machine &machine, ui_menu *menu, void *p static void menu_input_specific_populate(running_machine &machine, ui_menu *menu, input_menu_state *menustate) { input_item_data *itemlist = NULL; - const input_field_config *field; - const input_port_config *port; + input_field_config *field; + input_port_config *port; int suborder[SEQ_TYPE_TOTAL]; astring tempstring; @@ -1856,7 +1856,7 @@ static void menu_input_specific_populate(running_machine &machine, ui_menu *menu /* iterate over the input ports and add menu items */ for (port = machine.m_portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->fieldlist().first(); field != NULL; field = field->next()) { const char *name = input_field_name(field); @@ -1999,9 +1999,9 @@ static void menu_input_common(running_machine &machine, ui_menu *menu, void *par { input_field_user_settings settings; - input_field_get_user_settings((const input_field_config *)seqchangeditem->ref, &settings); + input_field_get_user_settings((input_field_config *)seqchangeditem->ref, &settings); settings.seq[seqchangeditem->seqtype] = seqchangeditem->seq; - input_field_set_user_settings((const input_field_config *)seqchangeditem->ref, &settings); + input_field_set_user_settings((input_field_config *)seqchangeditem->ref, &settings); } /* invalidate the menu to force an update */ @@ -2156,7 +2156,7 @@ static void menu_settings_common(running_machine &machine, ui_menu *menu, void * /* handle events */ if (menu_event != NULL && menu_event->itemref != NULL) { - const input_field_config *field = (const input_field_config *)menu_event->itemref; + input_field_config *field = (input_field_config *)menu_event->itemref; input_field_user_settings settings; int changed = FALSE; @@ -2197,8 +2197,8 @@ static void menu_settings_common(running_machine &machine, ui_menu *menu, void * static void menu_settings_populate(running_machine &machine, ui_menu *menu, settings_menu_state *menustate, UINT32 type) { - const input_field_config *field; - const input_port_config *port; + input_field_config *field; + input_port_config *port; dip_descriptor **diplist_tailptr; int dipcount = 0; @@ -2208,7 +2208,7 @@ static void menu_settings_populate(running_machine &machine, ui_menu *menu, sett /* loop over input ports and set up the current values */ for (port = machine.m_portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->fieldlist().first(); field != NULL; field = field->next()) if (field->type == type && input_condition_true(machine, &field->condition)) { UINT32 flags = 0; @@ -2223,7 +2223,7 @@ static void menu_settings_populate(running_machine &machine, ui_menu *menu, sett ui_menu_item_append(menu, input_field_name(field), input_field_setting_name(field), flags, (void *)field); /* for DIP switches, build up the model */ - if (type == IPT_DIPSWITCH && field->diploclist != NULL) + if (type == IPT_DIPSWITCH && field->diploclist().count() != 0) { const input_field_diplocation *diploc; input_field_user_settings settings; @@ -2233,7 +2233,7 @@ static void menu_settings_populate(running_machine &machine, ui_menu *menu, sett input_field_get_user_settings(field, &settings); /* iterate over each bit in the field */ - for (diploc = field->diploclist; diploc != NULL; diploc = diploc->next) + for (diploc = field->diploclist().first(); diploc != NULL; diploc = diploc->next()) { UINT32 mask = accummask & ~(accummask - 1); dip_descriptor *dip; @@ -2279,7 +2279,7 @@ static void menu_settings_populate(running_machine &machine, ui_menu *menu, sett static void menu_settings_custom_render(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) { - const input_field_config *field = (const input_field_config *)selectedref; + input_field_config *field = (input_field_config *)selectedref; settings_menu_state *menustate = (settings_menu_state *)state; dip_descriptor *dip; @@ -2299,7 +2299,7 @@ static void menu_settings_custom_render(running_machine &machine, ui_menu *menu, /* determine the mask of selected bits */ if (field != NULL) - for (diploc = field->diploclist; diploc != NULL; diploc = diploc->next) + for (diploc = field->diploclist().first(); diploc != NULL; diploc = diploc->next()) if (strcmp(dip->name, diploc->swname) == 0) selectedmask |= 1 << (diploc->swnum - 1); @@ -2455,14 +2455,14 @@ static void menu_analog(running_machine &machine, ui_menu *menu, void *parameter static void menu_analog_populate(running_machine &machine, ui_menu *menu) { - const input_field_config *field; - const input_port_config *port; + input_field_config *field; + input_port_config *port; astring subtext; astring text; /* loop over input ports and add the items */ for (port = machine.m_portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->fieldlist().first(); field != NULL; field = field->next()) if (input_type_is_analog(field->type) && input_condition_true(machine, &field->condition)) { input_field_user_settings settings; diff --git a/src/emu/validity.c b/src/emu/validity.c index a263a59ef14..6c77a8b7a3f 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -75,9 +75,7 @@ public: INLINE const char *input_port_string_from_index(UINT32 index) { - input_port_token token; - token.i = index; - return input_port_string_from_token(token); + return input_port_string_from_token((const char *)index); } @@ -741,7 +739,7 @@ static int get_defstr_index(int_map &defstr_map, const char *name, const game_dr analog input field -------------------------------------------------*/ -static void validate_analog_input_field(const input_field_config *field, const game_driver &driver, bool *error) +static void validate_analog_input_field(input_field_config *field, const game_driver &driver, bool *error) { INT32 analog_max = field->max; INT32 analog_min = field->min; @@ -850,7 +848,7 @@ static void validate_analog_input_field(const input_field_config *field, const g setting -------------------------------------------------*/ -static void validate_dip_settings(const input_field_config *field, const game_driver &driver, int_map &defstr_map, bool *error) +static void validate_dip_settings(input_field_config *field, const game_driver &driver, int_map &defstr_map, bool *error) { const char *demo_sounds = input_port_string_from_index(INPUT_STRING_Demo_Sounds); const char *flipscreen = input_port_string_from_index(INPUT_STRING_Flip_Screen); @@ -859,7 +857,7 @@ static void validate_dip_settings(const input_field_config *field, const game_dr int coin_error = FALSE; /* iterate through the settings */ - for (setting = field->settinglist; setting != NULL; setting = setting->next) + for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) { int strindex = get_defstr_index(defstr_map, setting->name, driver, error); @@ -889,9 +887,9 @@ static void validate_dip_settings(const input_field_config *field, const game_dr } /* if we have a neighbor, compare ourselves to him */ - if (setting->next != NULL) + if (setting->next() != NULL) { - int next_strindex = get_defstr_index(defstr_map, setting->next->name, driver, error); + int next_strindex = get_defstr_index(defstr_map, setting->next()->name, driver, error); /* check for inverted off/on dispswitch order */ if (strindex == INPUT_STRING_On && next_strindex == INPUT_STRING_Off) @@ -916,9 +914,9 @@ static void validate_dip_settings(const input_field_config *field, const game_dr /* check for proper coin ordering */ else if (strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C && next_strindex >= INPUT_STRING_9C_1C && next_strindex <= INPUT_STRING_1C_9C && - strindex >= next_strindex && memcmp(&setting->condition, &setting->next->condition, sizeof(setting->condition)) == 0) + strindex >= next_strindex && memcmp(&setting->condition, &setting->next()->condition, sizeof(setting->condition)) == 0) { - mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver.source_file, driver.name, setting->name, setting->next->name); + mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver.source_file, driver.name, setting->name, setting->next()->name); coin_error = *error = true; } } @@ -943,14 +941,14 @@ static void validate_dip_settings(const input_field_config *field, const game_dr static bool validate_inputs(driver_enumerator &drivlist, int_map &defstr_map, ioport_list &portlist) { - const input_port_config *scanport; - const input_port_config *port; - const input_field_config *field; + input_port_config *scanport; + input_port_config *port; + input_field_config *field; const game_driver &driver = drivlist.driver(); const machine_config &config = drivlist.config(); int empty_string_found = FALSE; - char errorbuf[1024]; bool error = false; + astring errorbuf; /* skip if no ports */ if (driver.ipt == NULL) @@ -958,31 +956,29 @@ static bool validate_inputs(driver_enumerator &drivlist, int_map &defstr_map, io /* allocate the input ports */ for (device_t *cfg = config.devicelist().first(); cfg != NULL; cfg = cfg->next()) - if (cfg->input_ports() != NULL) + { + input_port_list_init(*cfg, portlist, errorbuf); + if (errorbuf) { - input_port_list_init(portlist, cfg->input_ports(), errorbuf, sizeof(errorbuf), FALSE, cfg); - if (errorbuf[0] != 0) - { - mame_printf_error("%s: %s has input port errors:\n%s\n", driver.source_file, driver.name, errorbuf); - error = true; - } + mame_printf_error("%s: %s has input port errors:\n%s\n", driver.source_file, driver.name, errorbuf.cstr()); + error = true; } + } /* check for duplicate tags */ for (port = portlist.first(); port != NULL; port = port->next()) - if (port->tag != NULL) - for (scanport = port->next(); scanport != NULL; scanport = scanport->next()) - if (scanport->tag != NULL && strcmp(port->tag, scanport->tag) == 0) - { - mame_printf_error("%s: %s has a duplicate input port tag '%s'\n", driver.source_file, driver.name, port->tag); - error = true; - } + for (scanport = port->next(); scanport != NULL; scanport = scanport->next()) + if (strcmp(port->tag(), scanport->tag()) == 0) + { + mame_printf_error("%s: %s has a duplicate input port tag '%s'\n", driver.source_file, driver.name, port->tag()); + error = true; + } /* iterate over the results */ for (port = portlist.first(); port != NULL; port = port->next()) - for (field = port->fieldlist; field != NULL; field = field->next) + for (field = port->fieldlist().first(); field != NULL; field = field->next()) { - const input_setting_config *setting; + input_setting_config *setting; //int strindex = 0; /* verify analog inputs */ @@ -1043,7 +1039,7 @@ static bool validate_inputs(driver_enumerator &drivlist, int_map &defstr_map, io { /* find a matching port */ for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next()) - if (scanport->tag != NULL && strcmp(field->condition.tag, scanport->tag) == 0) + if (strcmp(field->condition.tag, scanport->tag()) == 0) break; /* if none, error */ @@ -1055,12 +1051,12 @@ static bool validate_inputs(driver_enumerator &drivlist, int_map &defstr_map, io } /* verify conditions on the settings */ - for (setting = field->settinglist; setting != NULL; setting = setting->next) + for (setting = field->settinglist().first(); setting != NULL; setting = setting->next()) if (setting->condition.tag != NULL) { /* find a matching port */ for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next()) - if (scanport->tag != NULL && strcmp(setting->condition.tag, scanport->tag) == 0) + if (strcmp(setting->condition.tag, scanport->tag()) == 0) break; /* if none, error */ diff --git a/src/mame/audio/cchasm.c b/src/mame/audio/cchasm.c index f6d3bb2595f..3559f728ab1 100644 --- a/src/mame/audio/cchasm.c +++ b/src/mame/audio/cchasm.c @@ -24,7 +24,7 @@ WRITE8_HANDLER( cchasm_reset_coin_flag_w ) INPUT_CHANGED( cchasm_set_coin_flag ) { - cchasm_state *state = field->port->machine().driver_data(); + cchasm_state *state = field->machine().driver_data(); if (!newval && !state->m_coin_flag) { state->m_coin_flag = 1; diff --git a/src/mame/audio/gorf.c b/src/mame/audio/gorf.c index b7fafb07ce3..3d88d4411cc 100644 --- a/src/mame/audio/gorf.c +++ b/src/mame/audio/gorf.c @@ -177,6 +177,6 @@ READ8_HANDLER( gorf_speech_r ) CUSTOM_INPUT( gorf_speech_status_r ) { - device_t *samples = field->port->machine().device("samples"); + device_t *samples = field->machine().device("samples"); return !sample_playing(samples, 0); } diff --git a/src/mame/audio/gottlieb.c b/src/mame/audio/gottlieb.c index 80b5902794f..2c4377819f5 100644 --- a/src/mame/audio/gottlieb.c +++ b/src/mame/audio/gottlieb.c @@ -466,7 +466,7 @@ static WRITE8_HANDLER( nmi_rate_w ) static CUSTOM_INPUT( speech_drq_custom_r ) { - return sp0250_drq_r(field->port->machine().device("spsnd")); + return sp0250_drq_r(field->machine().device("spsnd")); } diff --git a/src/mame/audio/jedi.c b/src/mame/audio/jedi.c index 9856866a738..41632a294ef 100644 --- a/src/mame/audio/jedi.c +++ b/src/mame/audio/jedi.c @@ -103,7 +103,7 @@ static READ8_HANDLER( audio_latch_r ) CUSTOM_INPUT( jedi_audio_comm_stat_r ) { - jedi_state *state = field->port->machine().driver_data(); + jedi_state *state = field->machine().driver_data(); return *state->m_audio_comm_stat >> 6; } diff --git a/src/mame/audio/wow.c b/src/mame/audio/wow.c index fcfe574ea12..89aabbf61a7 100644 --- a/src/mame/audio/wow.c +++ b/src/mame/audio/wow.c @@ -171,6 +171,6 @@ READ8_HANDLER( wow_speech_r ) CUSTOM_INPUT( wow_speech_status_r ) { - device_t *samples = field->port->machine().device("samples"); + device_t *samples = field->machine().device("samples"); return !sample_playing(samples, 0); } diff --git a/src/mame/drivers/8080bw.c b/src/mame/drivers/8080bw.c index ad62c0c788d..28714d99f81 100644 --- a/src/mame/drivers/8080bw.c +++ b/src/mame/drivers/8080bw.c @@ -1155,7 +1155,7 @@ MACHINE_CONFIG_END static CUSTOM_INPUT( sflush_80_r ) { - return (field->port->machine().primary_screen->vpos() & 0x80) ? 1 : 0; + return (field->machine().primary_screen->vpos() & 0x80) ? 1 : 0; } static ADDRESS_MAP_START( sflush_map, AS_PROGRAM, 8 ) diff --git a/src/mame/drivers/acefruit.c b/src/mame/drivers/acefruit.c index 2e7500b6dd4..e62712526c4 100644 --- a/src/mame/drivers/acefruit.c +++ b/src/mame/drivers/acefruit.c @@ -168,9 +168,9 @@ static CUSTOM_INPUT( sidewndr_payout_r ) switch (bit_mask) { case 0x01: - return ((input_port_read(field->port->machine(), "PAYOUT") & bit_mask) >> 0); + return ((input_port_read(field->machine(), "PAYOUT") & bit_mask) >> 0); case 0x02: - return ((input_port_read(field->port->machine(), "PAYOUT") & bit_mask) >> 1); + return ((input_port_read(field->machine(), "PAYOUT") & bit_mask) >> 1); default: logerror("sidewndr_payout_r : invalid %02X bit_mask\n",bit_mask); return 0; @@ -184,13 +184,13 @@ static CUSTOM_INPUT( starspnr_coinage_r ) switch (bit_mask) { case 0x01: - return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 0); + return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 0); case 0x02: - return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 1); + return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 1); case 0x04: - return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 2); + return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 2); case 0x08: - return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 3); + return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 3); default: logerror("starspnr_coinage_r : invalid %02X bit_mask\n",bit_mask); return 0; @@ -204,11 +204,11 @@ static CUSTOM_INPUT( starspnr_payout_r ) switch (bit_mask) { case 0x01: - return ((input_port_read(field->port->machine(), "PAYOUT") & bit_mask) >> 0); + return ((input_port_read(field->machine(), "PAYOUT") & bit_mask) >> 0); case 0x02: - return ((input_port_read(field->port->machine(), "PAYOUT") & bit_mask) >> 1); + return ((input_port_read(field->machine(), "PAYOUT") & bit_mask) >> 1); case 0x04: - return ((input_port_read(field->port->machine(), "PAYOUT") & bit_mask) >> 2); + return ((input_port_read(field->machine(), "PAYOUT") & bit_mask) >> 2); default: logerror("starspnr_payout_r : invalid %02X bit_mask\n",bit_mask); return 0; diff --git a/src/mame/drivers/alg.c b/src/mame/drivers/alg.c index 4589baf11e4..cad77d6b598 100644 --- a/src/mame/drivers/alg.c +++ b/src/mame/drivers/alg.c @@ -185,30 +185,30 @@ static void alg_potgo_w(running_machine &machine, UINT16 data) static CUSTOM_INPUT( lightgun_pos_r ) { - alg_state *state = field->port->machine().driver_data(); + alg_state *state = field->machine().driver_data(); int x = 0, y = 0; /* get the position based on the input select */ - get_lightgun_pos(*field->port->machine().primary_screen, state->m_input_select, &x, &y); + get_lightgun_pos(*field->machine().primary_screen, state->m_input_select, &x, &y); return (y << 8) | (x >> 2); } static CUSTOM_INPUT( lightgun_trigger_r ) { - alg_state *state = field->port->machine().driver_data(); + alg_state *state = field->machine().driver_data(); /* read the trigger control based on the input select */ - return (input_port_read(field->port->machine(), "TRIGGERS") >> state->m_input_select) & 1; + return (input_port_read(field->machine(), "TRIGGERS") >> state->m_input_select) & 1; } static CUSTOM_INPUT( lightgun_holster_r ) { - alg_state *state = field->port->machine().driver_data(); + alg_state *state = field->machine().driver_data(); /* read the holster control based on the input select */ - return (input_port_read(field->port->machine(), "TRIGGERS") >> (2 + state->m_input_select)) & 1; + return (input_port_read(field->machine(), "TRIGGERS") >> (2 + state->m_input_select)) & 1; } diff --git a/src/mame/drivers/arcadia.c b/src/mame/drivers/arcadia.c index f1e8a5374f6..c673d5e4cdf 100644 --- a/src/mame/drivers/arcadia.c +++ b/src/mame/drivers/arcadia.c @@ -157,7 +157,7 @@ static WRITE8_DEVICE_HANDLER( arcadia_cia_0_portb_w ) static CUSTOM_INPUT( coin_counter_r ) { int coin = (FPTR)param; - UINT8 *coin_counter = field->port->machine().driver_data()->coin_counter; + UINT8 *coin_counter = field->machine().driver_data()->coin_counter; /* return coin counter values */ return coin_counter[coin] & 3; @@ -167,7 +167,7 @@ static CUSTOM_INPUT( coin_counter_r ) static INPUT_CHANGED( coin_changed_callback ) { int coin = (FPTR)param; - UINT8 *coin_counter = field->port->machine().driver_data()->coin_counter; + UINT8 *coin_counter = field->machine().driver_data()->coin_counter; /* check for a 0 -> 1 transition */ if (!oldval && newval && coin_counter[coin] < 3) diff --git a/src/mame/drivers/artmagic.c b/src/mame/drivers/artmagic.c index 2b9a665d42c..707a15fa0bd 100644 --- a/src/mame/drivers/artmagic.c +++ b/src/mame/drivers/artmagic.c @@ -387,7 +387,7 @@ static void stonebal_protection(running_machine &machine) static CUSTOM_INPUT( prot_r ) { - artmagic_state *state = field->port->machine().driver_data(); + artmagic_state *state = field->machine().driver_data(); return state->m_prot_output_bit; } diff --git a/src/mame/drivers/asteroid.c b/src/mame/drivers/asteroid.c index b4584fa3cda..c371ddb32d9 100644 --- a/src/mame/drivers/asteroid.c +++ b/src/mame/drivers/asteroid.c @@ -308,7 +308,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( clock_r ) { - return (field->port->machine().device("maincpu")->total_cycles() & 0x100) ? 1 : 0; + return (field->machine().device("maincpu")->total_cycles() & 0x100) ? 1 : 0; } static INPUT_PORTS_START( asteroid ) diff --git a/src/mame/drivers/astinvad.c b/src/mame/drivers/astinvad.c index bb59d2fd4d6..c5b5e4796dc 100644 --- a/src/mame/drivers/astinvad.c +++ b/src/mame/drivers/astinvad.c @@ -275,7 +275,7 @@ static MACHINE_RESET( spaceint ) static INPUT_CHANGED( spaceint_coin_inserted ) { - astinvad_state *state = field->port->machine().driver_data(); + astinvad_state *state = field->machine().driver_data(); /* coin insertion causes an NMI */ device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); } diff --git a/src/mame/drivers/astrocde.c b/src/mame/drivers/astrocde.c index f35e702d414..ccc87c514bf 100644 --- a/src/mame/drivers/astrocde.c +++ b/src/mame/drivers/astrocde.c @@ -259,9 +259,9 @@ static WRITE8_HANDLER( seawolf2_sound_2_w ) // Port 41 static CUSTOM_INPUT( ebases_trackball_r ) { - astrocde_state *state = field->port->machine().driver_data(); + astrocde_state *state = field->machine().driver_data(); static const char *const names[] = { "TRACKX2", "TRACKY2", "TRACKX1", "TRACKY1" }; - return input_port_read(field->port->machine(), names[state->m_input_select]); + return input_port_read(field->machine(), names[state->m_input_select]); } @@ -487,9 +487,9 @@ static READ8_HANDLER( demndrgn_io_r ) static CUSTOM_INPUT( demndragn_joystick_r ) { - astrocde_state *state = field->port->machine().driver_data(); + astrocde_state *state = field->machine().driver_data(); static const char *const names[] = { "MOVEX", "MOVEY" }; - return input_port_read(field->port->machine(), names[state->m_input_select]); + return input_port_read(field->machine(), names[state->m_input_select]); } @@ -841,7 +841,7 @@ INPUT_PORTS_END static INPUT_CHANGED( spacezap_monitor ) { - astrocde_state *state = field->port->machine().driver_data(); + astrocde_state *state = field->machine().driver_data(); if (newval) state->m_video_config &= ~AC_MONITOR_BW; else diff --git a/src/mame/drivers/astrocdh.c b/src/mame/drivers/astrocdh.c index 2abaeefc1ed..f253a81c8aa 100644 --- a/src/mame/drivers/astrocdh.c +++ b/src/mame/drivers/astrocdh.c @@ -90,8 +90,8 @@ ADDRESS_MAP_END static INPUT_CHANGED( set_write_protect ) // run when RAM expansion write protect switch is changed { int ram_expansion_installed = 0, write_protect_on = 0, expansion_ram_start = 0, expansion_ram_end = 0, shadow_ram_end = 0; - address_space *space = field->port->machine().device("maincpu")->memory().space(AS_PROGRAM); - UINT8 *expram = ram_get_ptr(field->port->machine().device("ram_tag")); + address_space *space = field->machine().device("maincpu")->memory().space(AS_PROGRAM); + UINT8 *expram = ram_get_ptr(field->machine().device("ram_tag")); get_ram_expansion_settings(space, ram_expansion_installed, write_protect_on, expansion_ram_start, expansion_ram_end, shadow_ram_end); // passing by reference diff --git a/src/mame/drivers/astrof.c b/src/mame/drivers/astrof.c index b98616cc22c..f50407960b8 100644 --- a/src/mame/drivers/astrof.c +++ b/src/mame/drivers/astrof.c @@ -104,17 +104,17 @@ static TIMER_DEVICE_CALLBACK( irq_callback ) static INPUT_CHANGED( coin_inserted ) { - astrof_state *state = field->port->machine().driver_data(); + astrof_state *state = field->machine().driver_data(); /* coin insertion causes an NMI */ device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); - coin_counter_w(field->port->machine(), 0, newval); + coin_counter_w(field->machine(), 0, newval); } static INPUT_CHANGED( service_coin_inserted ) { - astrof_state *state = field->port->machine().driver_data(); + astrof_state *state = field->machine().driver_data(); /* service coin insertion causes an NMI */ device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); @@ -123,7 +123,7 @@ static INPUT_CHANGED( service_coin_inserted ) static CUSTOM_INPUT( astrof_p1_controls_r ) { - return input_port_read(field->port->machine(), "P1"); + return input_port_read(field->machine(), "P1"); } @@ -134,10 +134,10 @@ static CUSTOM_INPUT( astrof_p2_controls_r ) /* on an upright cabinet, a single set of controls is connected to both sets of pins on the edge connector */ - if (input_port_read(field->port->machine(), "CAB")) - ret = input_port_read(field->port->machine(), "P2"); + if (input_port_read(field->machine(), "CAB")) + ret = input_port_read(field->machine(), "P2"); else - ret = input_port_read(field->port->machine(), "P1"); + ret = input_port_read(field->machine(), "P1"); return ret; } @@ -146,16 +146,16 @@ static CUSTOM_INPUT( astrof_p2_controls_r ) static CUSTOM_INPUT( tomahawk_controls_r ) { UINT32 ret; - astrof_state *state = field->port->machine().driver_data(); + astrof_state *state = field->machine().driver_data(); /* on a cocktail cabinet, two sets of controls are multiplexed on a single set of inputs (not verified on pcb) */ if (state->m_flipscreen) - ret = input_port_read(field->port->machine(), "P2"); + ret = input_port_read(field->machine(), "P2"); else - ret = input_port_read(field->port->machine(), "P1"); + ret = input_port_read(field->machine(), "P1"); return ret; } diff --git a/src/mame/drivers/battlex.c b/src/mame/drivers/battlex.c index 54edc0ddf3b..03ae0620ab1 100644 --- a/src/mame/drivers/battlex.c +++ b/src/mame/drivers/battlex.c @@ -57,11 +57,11 @@ static INTERRUPT_GEN( battlex_interrupt ) static CUSTOM_INPUT( battlex_in0_b4_r ) { - battlex_state *state = field->port->machine().driver_data(); + battlex_state *state = field->machine().driver_data(); UINT32 ret = state->m_in0_b4; if (state->m_in0_b4) { - cputag_set_input_line(field->port->machine(), "maincpu", 0, CLEAR_LINE); + cputag_set_input_line(field->machine(), "maincpu", 0, CLEAR_LINE); state->m_in0_b4 = 0; } diff --git a/src/mame/drivers/bfm_sc2.c b/src/mame/drivers/bfm_sc2.c index a1837ff275d..b11b29bee04 100644 --- a/src/mame/drivers/bfm_sc2.c +++ b/src/mame/drivers/bfm_sc2.c @@ -2864,7 +2864,7 @@ static ADDRESS_MAP_START( memmap_sc2_dm01, AS_PROGRAM, 8 ) AM_RANGE(0x8000, 0xFFFF) AM_ROM ADDRESS_MAP_END - +#ifdef UNREFERENCED_CODE static INPUT_PORTS_START( scorpion2 ) PORT_START("COINS") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(3) @@ -3008,6 +3008,7 @@ static INPUT_PORTS_START( scorpion2 ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x10, DEF_STR( On ) ) INPUT_PORTS_END +#endif static INPUT_PORTS_START( bbrkfst ) PORT_START("COINS") diff --git a/src/mame/drivers/brkthru.c b/src/mame/drivers/brkthru.c index 764f7689929..a97c9a6154d 100644 --- a/src/mame/drivers/brkthru.c +++ b/src/mame/drivers/brkthru.c @@ -92,7 +92,7 @@ static WRITE8_HANDLER( brkthru_soundlatch_w ) static INPUT_CHANGED( coin_inserted ) { - brkthru_state *state = field->port->machine().driver_data(); + brkthru_state *state = field->machine().driver_data(); /* coin insertion causes an IRQ */ device_set_input_line(state->m_maincpu, 0, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/btime.c b/src/mame/drivers/btime.c index 13f702dc58b..3faee18f13f 100644 --- a/src/mame/drivers/btime.c +++ b/src/mame/drivers/btime.c @@ -525,7 +525,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted_irq_hi ) { - btime_state *state = field->port->machine().driver_data(); + btime_state *state = field->machine().driver_data(); if (newval) device_set_input_line(state->m_maincpu, 0, HOLD_LINE); @@ -533,7 +533,7 @@ static INPUT_CHANGED( coin_inserted_irq_hi ) static INPUT_CHANGED( coin_inserted_irq_lo ) { - btime_state *state = field->port->machine().driver_data(); + btime_state *state = field->machine().driver_data(); if (!newval) device_set_input_line(state->m_maincpu, 0, HOLD_LINE); @@ -541,7 +541,7 @@ static INPUT_CHANGED( coin_inserted_irq_lo ) static INPUT_CHANGED( coin_inserted_nmi_lo ) { - btime_state *state = field->port->machine().driver_data(); + btime_state *state = field->machine().driver_data(); device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/btoads.c b/src/mame/drivers/btoads.c index 10d31f2ac90..86c8c7b8164 100644 --- a/src/mame/drivers/btoads.c +++ b/src/mame/drivers/btoads.c @@ -72,13 +72,13 @@ READ16_MEMBER( btoads_state::main_sound_r ) CUSTOM_INPUT( btoads_state::static_main_to_sound_r ) { - return field->port->machine().driver_data()->m_main_to_sound_ready; + return field->machine().driver_data()->m_main_to_sound_ready; } CUSTOM_INPUT( btoads_state::static_sound_to_main_r ) { - return field->port->machine().driver_data()->m_sound_to_main_ready; + return field->machine().driver_data()->m_sound_to_main_ready; } diff --git a/src/mame/drivers/bwidow.c b/src/mame/drivers/bwidow.c index b16079cc968..ad5816b1557 100644 --- a/src/mame/drivers/bwidow.c +++ b/src/mame/drivers/bwidow.c @@ -316,7 +316,7 @@ static READ8_HANDLER( spacduel_IN3_r ) static CUSTOM_INPUT( clock_r ) { - return (field->port->machine().device("maincpu")->total_cycles() & 0x100) ? 1 : 0; + return (field->machine().device("maincpu")->total_cycles() & 0x100) ? 1 : 0; } diff --git a/src/mame/drivers/bwing.c b/src/mame/drivers/bwing.c index 38259ad6538..c1af6452764 100644 --- a/src/mame/drivers/bwing.c +++ b/src/mame/drivers/bwing.c @@ -200,12 +200,12 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted ) { - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } static INPUT_CHANGED( tilt_pressed ) { - cputag_set_input_line(field->port->machine(), "maincpu", M6809_FIRQ_LINE, newval ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(field->machine(), "maincpu", M6809_FIRQ_LINE, newval ? ASSERT_LINE : CLEAR_LINE); } static INPUT_PORTS_START( bwing ) diff --git a/src/mame/drivers/bzone.c b/src/mame/drivers/bzone.c index 4769cc505ce..353cb7a6ad0 100644 --- a/src/mame/drivers/bzone.c +++ b/src/mame/drivers/bzone.c @@ -258,7 +258,7 @@ static INTERRUPT_GEN( bzone_interrupt ) static CUSTOM_INPUT( clock_r ) { - return (field->port->machine().device("maincpu")->total_cycles() & 0x100) ? 1 : 0; + return (field->machine().device("maincpu")->total_cycles() & 0x100) ? 1 : 0; } diff --git a/src/mame/drivers/calomega.c b/src/mame/drivers/calomega.c index 2491623af0e..d219ca37857 100644 --- a/src/mame/drivers/calomega.c +++ b/src/mame/drivers/calomega.c @@ -1024,6 +1024,7 @@ static INPUT_PORTS_START( stand903 ) PORT_DIPSETTING( 0x00, "50Hz." ) INPUT_PORTS_END +#ifdef UNREFERENCED_CODE static INPUT_PORTS_START( stand904 ) PORT_START("IN0-0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("0-1") PORT_CODE(KEYCODE_1) @@ -1128,6 +1129,7 @@ static INPUT_PORTS_START( stand904 ) PORT_DIPSETTING( 0x80, "60Hz." ) PORT_DIPSETTING( 0x00, "50Hz." ) INPUT_PORTS_END +#endif static INPUT_PORTS_START( stand905 ) PORT_START("IN0-0") diff --git a/src/mame/drivers/cave.c b/src/mame/drivers/cave.c index cc18a5e5e43..4f70af85af0 100644 --- a/src/mame/drivers/cave.c +++ b/src/mame/drivers/cave.c @@ -692,7 +692,7 @@ static WRITE16_DEVICE_HANDLER( korokoro_eeprom_msb_w ) static CUSTOM_INPUT( korokoro_hopper_r ) { - cave_state *state = field->port->machine().driver_data(); + cave_state *state = field->machine().driver_data(); return state->m_hopper ? 1 : 0; } @@ -928,8 +928,8 @@ static WRITE16_HANDLER( tjumpman_leds_w ) static CUSTOM_INPUT( tjumpman_hopper_r ) { - cave_state *state = field->port->machine().driver_data(); - return (state->m_hopper && !(field->port->machine().primary_screen->frame_number() % 10)) ? 0 : 1; + cave_state *state = field->machine().driver_data(); + return (state->m_hopper && !(field->machine().primary_screen->frame_number() % 10)) ? 0 : 1; } static ADDRESS_MAP_START( tjumpman_map, AS_PROGRAM, 16 ) diff --git a/src/mame/drivers/ccastles.c b/src/mame/drivers/ccastles.c index 00e1e6e8b65..bd28ec8390c 100644 --- a/src/mame/drivers/ccastles.c +++ b/src/mame/drivers/ccastles.c @@ -173,8 +173,8 @@ static TIMER_CALLBACK( clock_irq ) static CUSTOM_INPUT( get_vblank ) { - ccastles_state *state = field->port->machine().driver_data(); - int scanline = field->port->machine().primary_screen->vpos(); + ccastles_state *state = field->machine().driver_data(); + int scanline = field->machine().primary_screen->vpos(); return state->m_syncprom[scanline & 0xff] & 1; } diff --git a/src/mame/drivers/cd32.c b/src/mame/drivers/cd32.c index abf7fd42e64..ee590f6e97d 100644 --- a/src/mame/drivers/cd32.c +++ b/src/mame/drivers/cd32.c @@ -230,8 +230,8 @@ static UINT16 handle_joystick_potgor(running_machine &machine, UINT16 potgor) static CUSTOM_INPUT(cubo_input) { - cd32_state *state = field->port->machine().driver_data(); - return handle_joystick_potgor(field->port->machine(), state->m_potgo_value) >> 10; + cd32_state *state = field->machine().driver_data(); + return handle_joystick_potgor(field->machine(), state->m_potgo_value) >> 10; } static INPUT_PORTS_START( cd32 ) diff --git a/src/mame/drivers/cdi.c b/src/mame/drivers/cdi.c index f86af5b1d67..38946227c90 100644 --- a/src/mame/drivers/cdi.c +++ b/src/mame/drivers/cdi.c @@ -81,49 +81,49 @@ ADDRESS_MAP_END static INPUT_CHANGED( mcu_input ) { - cdi_state *state = field->port->machine().driver_data(); + cdi_state *state = field->machine().driver_data(); scc68070_regs_t *scc68070 = &state->m_scc68070_regs; bool send = false; switch((FPTR)param) { case 0x39: - if(input_port_read(field->port->machine(), "INPUT1") & 0x01) send = true; + if(input_port_read(field->machine(), "INPUT1") & 0x01) send = true; break; case 0x37: - if(input_port_read(field->port->machine(), "INPUT1") & 0x02) send = true; + if(input_port_read(field->machine(), "INPUT1") & 0x02) send = true; break; case 0x31: - if(input_port_read(field->port->machine(), "INPUT1") & 0x04) send = true; + if(input_port_read(field->machine(), "INPUT1") & 0x04) send = true; break; case 0x32: - if(input_port_read(field->port->machine(), "INPUT1") & 0x08) send = true; + if(input_port_read(field->machine(), "INPUT1") & 0x08) send = true; break; case 0x33: - if(input_port_read(field->port->machine(), "INPUT1") & 0x10) send = true; + if(input_port_read(field->machine(), "INPUT1") & 0x10) send = true; break; case 0x30: - if(input_port_read(field->port->machine(), "INPUT2") & 0x01) send = true; + if(input_port_read(field->machine(), "INPUT2") & 0x01) send = true; break; case 0x38: - if(input_port_read(field->port->machine(), "INPUT2") & 0x02) send = true; + if(input_port_read(field->machine(), "INPUT2") & 0x02) send = true; break; case 0x34: - if(input_port_read(field->port->machine(), "INPUT2") & 0x04) send = true; + if(input_port_read(field->machine(), "INPUT2") & 0x04) send = true; break; case 0x35: - if(input_port_read(field->port->machine(), "INPUT2") & 0x08) send = true; + if(input_port_read(field->machine(), "INPUT2") & 0x08) send = true; break; case 0x36: - if(input_port_read(field->port->machine(), "INPUT2") & 0x10) send = true; + if(input_port_read(field->machine(), "INPUT2") & 0x10) send = true; break; } if(send) { UINT8 data = (UINT8)((FPTR)param & 0x000000ff); - scc68070_quizard_rx(field->port->machine(), scc68070, data); + scc68070_quizard_rx(field->machine(), scc68070, data); } } diff --git a/src/mame/drivers/champbas.c b/src/mame/drivers/champbas.c index 5304e8c1a2c..3fb31fdcdd2 100644 --- a/src/mame/drivers/champbas.c +++ b/src/mame/drivers/champbas.c @@ -119,7 +119,7 @@ static WRITE8_HANDLER( champbas_watchdog_reset_w ) static CUSTOM_INPUT( champbas_watchdog_bit2 ) { - champbas_state *state = field->port->machine().driver_data(); + champbas_state *state = field->machine().driver_data(); return BIT(state->m_watchdog_count, 2); } diff --git a/src/mame/drivers/cheekyms.c b/src/mame/drivers/cheekyms.c index 8e8b7dba6f0..78ba38f0d57 100644 --- a/src/mame/drivers/cheekyms.c +++ b/src/mame/drivers/cheekyms.c @@ -14,7 +14,7 @@ static INPUT_CHANGED( coin_inserted ) { - cheekyms_state *state = field->port->machine().driver_data(); + cheekyms_state *state = field->machine().driver_data(); /* this starts a 556 one-shot timer (and triggers a sound effect) */ if (newval) diff --git a/src/mame/drivers/cidelsa.c b/src/mame/drivers/cidelsa.c index 4aaf43af327..ccc9cc26304 100644 --- a/src/mame/drivers/cidelsa.c +++ b/src/mame/drivers/cidelsa.c @@ -272,14 +272,14 @@ ADDRESS_MAP_END static CUSTOM_INPUT( cdp1869_pcb_r ) { - cidelsa_state *state = field->port->machine().driver_data(); + cidelsa_state *state = field->machine().driver_data(); return state->m_cdp1869_pcb; } static INPUT_CHANGED( ef_w ) { - cputag_set_input_line(field->port->machine(), CDP1802_TAG, (int)(FPTR)param, newval); + cputag_set_input_line(field->machine(), CDP1802_TAG, (int)(FPTR)param, newval); } static INPUT_PORTS_START( destryer ) diff --git a/src/mame/drivers/cinemat.c b/src/mame/drivers/cinemat.c index 266b710d987..4f57c2becc8 100644 --- a/src/mame/drivers/cinemat.c +++ b/src/mame/drivers/cinemat.c @@ -99,7 +99,7 @@ static READ8_HANDLER( switches_r ) static INPUT_CHANGED( coin_inserted ) { - cinemat_state *state = field->port->machine().driver_data(); + cinemat_state *state = field->machine().driver_data(); /* on the falling edge of a new coin, set the coin_detected flag */ if (newval == 0) state->m_coin_detected = 1; diff --git a/src/mame/drivers/cloud9.c b/src/mame/drivers/cloud9.c index 2870e5bed21..d6677eb80f3 100644 --- a/src/mame/drivers/cloud9.c +++ b/src/mame/drivers/cloud9.c @@ -142,8 +142,8 @@ static TIMER_CALLBACK( clock_irq ) static CUSTOM_INPUT( get_vblank ) { - cloud9_state *state = field->port->machine().driver_data(); - int scanline = field->port->machine().primary_screen->vpos(); + cloud9_state *state = field->machine().driver_data(); + int scanline = field->machine().primary_screen->vpos(); return (~state->m_syncprom[scanline & 0xff] >> 1) & 1; } diff --git a/src/mame/drivers/cntsteer.c b/src/mame/drivers/cntsteer.c index 0ee37b8648f..fd5c8bcd5ad 100644 --- a/src/mame/drivers/cntsteer.c +++ b/src/mame/drivers/cntsteer.c @@ -672,7 +672,7 @@ INPUT_PORTS_END static INPUT_CHANGED( coin_inserted ) { - cntsteer_state *state = field->port->machine().driver_data(); + cntsteer_state *state = field->machine().driver_data(); device_set_input_line(state->m_subcpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/cop01.c b/src/mame/drivers/cop01.c index 6c1f569e73d..d642745b927 100644 --- a/src/mame/drivers/cop01.c +++ b/src/mame/drivers/cop01.c @@ -100,7 +100,7 @@ static READ8_HANDLER( cop01_sound_command_r ) static CUSTOM_INPUT( mightguy_area_r ) { int bit_mask = (FPTR)param; - return (input_port_read(field->port->machine(), "FAKE") & bit_mask) ? 0x01 : 0x00; + return (input_port_read(field->machine(), "FAKE") & bit_mask) ? 0x01 : 0x00; } static WRITE8_HANDLER( cop01_irq_ack_w ) diff --git a/src/mame/drivers/copsnrob.c b/src/mame/drivers/copsnrob.c index 93e2378be00..4bb7fbe4f15 100644 --- a/src/mame/drivers/copsnrob.c +++ b/src/mame/drivers/copsnrob.c @@ -134,7 +134,7 @@ ADDRESS_MAP_END * *************************************/ -static const int gun_table[] = {0x3f, 0x5f, 0x6f, 0x77, 0x7b, 0x7d, 0x7e}; +static const input_port_value gun_table[] = {0x3f, 0x5f, 0x6f, 0x77, 0x7b, 0x7d, 0x7e}; static INPUT_PORTS_START( copsnrob ) PORT_START("IN0") diff --git a/src/mame/drivers/cosmic.c b/src/mame/drivers/cosmic.c index 21ad088a845..38e37f6f7f5 100644 --- a/src/mame/drivers/cosmic.c +++ b/src/mame/drivers/cosmic.c @@ -414,7 +414,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( panic_coin_inserted ) { - panic_sound_output_w(field->port->machine().device("maincpu")->memory().space(AS_PROGRAM), 17, newval == 0); + panic_sound_output_w(field->machine().device("maincpu")->memory().space(AS_PROGRAM), 17, newval == 0); } static INPUT_PORTS_START( panic ) @@ -475,7 +475,7 @@ INPUT_PORTS_END static INPUT_CHANGED( cosmica_coin_inserted ) { - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); } static INPUT_PORTS_START( cosmica ) @@ -530,7 +530,7 @@ INPUT_PORTS_END static INPUT_CHANGED( cosmicg_coin_inserted ) { - cputag_set_input_line_and_vector(field->port->machine(), "maincpu", 0, newval ? ASSERT_LINE : CLEAR_LINE, 6); + cputag_set_input_line_and_vector(field->machine(), "maincpu", 0, newval ? ASSERT_LINE : CLEAR_LINE, 6); } static INPUT_PORTS_START( cosmicg ) @@ -577,12 +577,12 @@ INPUT_PORTS_END static INPUT_CHANGED( coin_inserted_irq0 ) { - cputag_set_input_line(field->port->machine(), "maincpu", 0, newval ? HOLD_LINE : CLEAR_LINE); + cputag_set_input_line(field->machine(), "maincpu", 0, newval ? HOLD_LINE : CLEAR_LINE); } static INPUT_CHANGED( coin_inserted_nmi ) { - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); } static INPUT_PORTS_START( magspot ) diff --git a/src/mame/drivers/crbaloon.c b/src/mame/drivers/crbaloon.c index ceacb5d8f8b..bb018d4f43d 100644 --- a/src/mame/drivers/crbaloon.c +++ b/src/mame/drivers/crbaloon.c @@ -70,16 +70,16 @@ static WRITE8_HANDLER( pc3092_w ) static CUSTOM_INPUT( pc3092_r ) { - crbaloon_state *state = field->port->machine().driver_data(); + crbaloon_state *state = field->machine().driver_data(); UINT32 ret; /* enable coin & start input? Wild guess!!! */ if (state->m_pc3092_data[1] & 0x02) - ret = input_port_read(field->port->machine(), "PC3092"); + ret = input_port_read(field->machine(), "PC3092"); else ret = 0x00; - if (LOG_PC3092) logerror("%s: read PC3092 = 0x%02x\n", field->port->machine().describe_context(), ret); + if (LOG_PC3092) logerror("%s: read PC3092 = 0x%02x\n", field->machine().describe_context(), ret); return ret; } diff --git a/src/mame/drivers/crshrace.c b/src/mame/drivers/crshrace.c index aaf31bfc493..e35633bea21 100644 --- a/src/mame/drivers/crshrace.c +++ b/src/mame/drivers/crshrace.c @@ -174,7 +174,7 @@ static WRITE16_HANDLER( sound_command_w ) static CUSTOM_INPUT( country_sndpending_r ) { - crshrace_state *state = field->port->machine().driver_data(); + crshrace_state *state = field->machine().driver_data(); return state->m_pending_command; } diff --git a/src/mame/drivers/dacholer.c b/src/mame/drivers/dacholer.c index bf2aa16e784..f136f1d1321 100644 --- a/src/mame/drivers/dacholer.c +++ b/src/mame/drivers/dacholer.c @@ -142,7 +142,7 @@ static WRITE8_HANDLER( snd_ack_w ) static CUSTOM_INPUT( snd_ack_r ) { - dacholer_state *state = field->port->machine().driver_data(); + dacholer_state *state = field->machine().driver_data(); return state->m_snd_ack; //guess ... } diff --git a/src/mame/drivers/dcheese.c b/src/mame/drivers/dcheese.c index 19d89f7e952..e4271cd1557 100644 --- a/src/mame/drivers/dcheese.c +++ b/src/mame/drivers/dcheese.c @@ -119,7 +119,7 @@ static MACHINE_START( dcheese ) static CUSTOM_INPUT( sound_latch_state_r ) { - dcheese_state *state = field->port->machine().driver_data(); + dcheese_state *state = field->machine().driver_data(); return state->m_soundlatch_full; } diff --git a/src/mame/drivers/ddayjlc.c b/src/mame/drivers/ddayjlc.c index e1cdb8afa85..680095cf449 100644 --- a/src/mame/drivers/ddayjlc.c +++ b/src/mame/drivers/ddayjlc.c @@ -130,7 +130,7 @@ static const UINT8 prot_data[0x10] = static CUSTOM_INPUT( prot_r ) { - ddayjlc_state *state = field->port->machine().driver_data(); + ddayjlc_state *state = field->machine().driver_data(); return prot_data[state->m_prot_addr]; } diff --git a/src/mame/drivers/ddenlovr.c b/src/mame/drivers/ddenlovr.c index f29ea80fbea..f7cbd5b7de5 100644 --- a/src/mame/drivers/ddenlovr.c +++ b/src/mame/drivers/ddenlovr.c @@ -1409,7 +1409,7 @@ SCREEN_UPDATE(ddenlovr) static CUSTOM_INPUT( ddenlovr_special_r ) { - dynax_state *state = field->port->machine().driver_data(); + dynax_state *state = field->machine().driver_data(); return state->m_ddenlovr_blitter_irq_flag; } @@ -1781,7 +1781,7 @@ static WRITE16_HANDLER( ddenlovj_coincounter_w ) static CUSTOM_INPUT( ddenlovj_blitter_r ) { - dynax_state *state = field->port->machine().driver_data(); + dynax_state *state = field->machine().driver_data(); return state->m_ddenlovr_blitter_irq_flag ? 0x03 : 0x00; // bit 4 = 1 -> blitter busy } @@ -1921,7 +1921,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( nettoqc_special_r ) { - dynax_state *state = field->port->machine().driver_data(); + dynax_state *state = field->machine().driver_data(); return state->m_ddenlovr_blitter_irq_flag ? 0x03 : 0x00; } @@ -3446,7 +3446,7 @@ static READ8_HANDLER( mjflove_keyb_r ) static CUSTOM_INPUT( mjflove_blitter_r ) { - dynax_state *state = field->port->machine().driver_data(); + dynax_state *state = field->machine().driver_data(); // bit 7 = 1 -> blitter busy // bit 6 = 0 -> VBLANK? diff --git a/src/mame/drivers/ddragon.c b/src/mame/drivers/ddragon.c index a4158c916cb..bdb179f2f77 100644 --- a/src/mame/drivers/ddragon.c +++ b/src/mame/drivers/ddragon.c @@ -357,7 +357,7 @@ static void irq_handler( device_t *device, int irq ) static CUSTOM_INPUT( sub_cpu_busy ) { - ddragon_state *state = field->port->machine().driver_data(); + ddragon_state *state = field->machine().driver_data(); return state->m_dd_sub_cpu_busy; } diff --git a/src/mame/drivers/dlair.c b/src/mame/drivers/dlair.c index 41afa24f2f2..f3ba3ce5a29 100644 --- a/src/mame/drivers/dlair.c +++ b/src/mame/drivers/dlair.c @@ -316,7 +316,7 @@ static WRITE8_HANDLER( led_den2_w ) static CUSTOM_INPUT( laserdisc_status_r ) { - dlair_state *state = field->port->machine().driver_data(); + dlair_state *state = field->machine().driver_data(); switch (laserdisc_get_type(state->m_laserdisc)) { case LASERDISC_TYPE_PIONEER_PR7820: @@ -334,7 +334,7 @@ static CUSTOM_INPUT( laserdisc_status_r ) static CUSTOM_INPUT( laserdisc_command_r ) { - dlair_state *state = field->port->machine().driver_data(); + dlair_state *state = field->machine().driver_data(); switch (laserdisc_get_type(state->m_laserdisc)) { case LASERDISC_TYPE_PIONEER_PR7820: diff --git a/src/mame/drivers/dorachan.c b/src/mame/drivers/dorachan.c index 27634a1c144..bdc01c6e315 100644 --- a/src/mame/drivers/dorachan.c +++ b/src/mame/drivers/dorachan.c @@ -41,7 +41,7 @@ public: static CUSTOM_INPUT( dorachan_protection_r ) { - dorachan_state *state = field->port->machine().driver_data(); + dorachan_state *state = field->machine().driver_data(); UINT8 ret = 0; switch (cpu_get_previouspc(state->m_main_cpu)) @@ -129,10 +129,10 @@ static WRITE8_HANDLER(dorachan_ctrl_w) static CUSTOM_INPUT( dorachan_v128_r ) { - dorachan_state *state = field->port->machine().driver_data(); + dorachan_state *state = field->machine().driver_data(); /* to avoid resetting (when player 2 starts) bit 0 need to be inverted when screen is flipped */ - return ((field->port->machine().primary_screen->vpos() >> 7) & 0x01) ^ state->m_flip_screen; + return ((field->machine().primary_screen->vpos() >> 7) & 0x01) ^ state->m_flip_screen; } diff --git a/src/mame/drivers/dynax.c b/src/mame/drivers/dynax.c index 1d99536e950..5b47677e5a4 100644 --- a/src/mame/drivers/dynax.c +++ b/src/mame/drivers/dynax.c @@ -2047,6 +2047,7 @@ static INPUT_PORTS_START( HANAFUDA_KEYS_BET ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL ) PORT_PLAYER(2) // "s" INPUT_PORTS_END +#ifdef UNREFERENCED_CODE static INPUT_PORTS_START( HANAFUDA_KEYS_BET_ALT ) PORT_START("KEY0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_A ) PORT_PLAYER(1) @@ -2132,7 +2133,7 @@ static INPUT_PORTS_START( HANAFUDA_KEYS_BET_ALT ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END - +#endif static INPUT_PORTS_START( hanamai ) PORT_START("DSW0") diff --git a/src/mame/drivers/enigma2.c b/src/mame/drivers/enigma2.c index cac3719696b..92e2863c8f9 100644 --- a/src/mame/drivers/enigma2.c +++ b/src/mame/drivers/enigma2.c @@ -416,17 +416,17 @@ static WRITE8_HANDLER( enigma2_flip_screen_w ) static CUSTOM_INPUT( p1_controls_r ) { - return input_port_read(field->port->machine(), "P1CONTROLS"); + return input_port_read(field->machine(), "P1CONTROLS"); } static CUSTOM_INPUT( p2_controls_r ) { - enigma2_state *state = field->port->machine().driver_data(); + enigma2_state *state = field->machine().driver_data(); if (state->m_flip_screen) - return input_port_read(field->port->machine(), "P2CONTROLS"); + return input_port_read(field->machine(), "P2CONTROLS"); else - return input_port_read(field->port->machine(), "P1CONTROLS"); + return input_port_read(field->machine(), "P1CONTROLS"); } diff --git a/src/mame/drivers/equites.c b/src/mame/drivers/equites.c index 40975593fe2..1f333c8c9d7 100644 --- a/src/mame/drivers/equites.c +++ b/src/mame/drivers/equites.c @@ -657,7 +657,7 @@ static READ16_HANDLER(hvoltage_debug_r) static CUSTOM_INPUT( gekisou_unknown_status ) { - equites_state *state = field->port->machine().driver_data(); + equites_state *state = field->machine().driver_data(); return state->m_unknown_bit; } diff --git a/src/mame/drivers/esripsys.c b/src/mame/drivers/esripsys.c index 879fb0b2f33..6547e9a48a4 100644 --- a/src/mame/drivers/esripsys.c +++ b/src/mame/drivers/esripsys.c @@ -414,23 +414,23 @@ static WRITE8_HANDLER( g_ioadd_w ) static INPUT_CHANGED( keypad_interrupt ) { - esripsys_state *state = field->port->machine().driver_data(); + esripsys_state *state = field->machine().driver_data(); if (newval == 0) { state->m_io_firq_status |= 2; state->m_keypad_status |= 0x20; - cputag_set_input_line(field->port->machine(), "game_cpu", M6809_FIRQ_LINE, HOLD_LINE); + cputag_set_input_line(field->machine(), "game_cpu", M6809_FIRQ_LINE, HOLD_LINE); } } static INPUT_CHANGED( coin_interrupt ) { - esripsys_state *state = field->port->machine().driver_data(); + esripsys_state *state = field->machine().driver_data(); if (newval == 1) { state->m_io_firq_status |= 2; - state->m_coin_latch = input_port_read(field->port->machine(), "COINS") << 2; - cputag_set_input_line(field->port->machine(), "game_cpu", M6809_FIRQ_LINE, HOLD_LINE); + state->m_coin_latch = input_port_read(field->machine(), "COINS") << 2; + cputag_set_input_line(field->machine(), "game_cpu", M6809_FIRQ_LINE, HOLD_LINE); } } diff --git a/src/mame/drivers/exerion.c b/src/mame/drivers/exerion.c index d4e93cf7ab5..5e02b213096 100644 --- a/src/mame/drivers/exerion.c +++ b/src/mame/drivers/exerion.c @@ -133,14 +133,14 @@ Stephh's notes (based on the games Z80 code and some tests) : static CUSTOM_INPUT( exerion_controls_r ) { static const char *const inname[2] = { "P1", "P2" }; - exerion_state *state = field->port->machine().driver_data(); - return input_port_read(field->port->machine(), inname[state->m_cocktail_flip]) & 0x3f; + exerion_state *state = field->machine().driver_data(); + return input_port_read(field->machine(), inname[state->m_cocktail_flip]) & 0x3f; } static INPUT_CHANGED( coin_inserted ) { - exerion_state *state = field->port->machine().driver_data(); + exerion_state *state = field->machine().driver_data(); /* coin insertion causes an NMI */ device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/exidy.c b/src/mame/drivers/exidy.c index 481f3a3c44b..cb8a939d472 100644 --- a/src/mame/drivers/exidy.c +++ b/src/mame/drivers/exidy.c @@ -157,8 +157,8 @@ Fax 1982 6502 FXL, FLA static CUSTOM_INPUT( teetert_input_r ) { - exidy_state *state = field->port->machine().driver_data(); - UINT8 dial = input_port_read(field->port->machine(), "DIAL"); + exidy_state *state = field->machine().driver_data(); + UINT8 dial = input_port_read(field->machine(), "DIAL"); int result = 0; result = (dial != state->m_last_dial) << 4; diff --git a/src/mame/drivers/exidy440.c b/src/mame/drivers/exidy440.c index 8b2f7b74a42..824b08901e6 100644 --- a/src/mame/drivers/exidy440.c +++ b/src/mame/drivers/exidy440.c @@ -256,7 +256,7 @@ static INPUT_CHANGED( coin_inserted ) { /* if we got a coin, set the IRQ on the main CPU */ if (newval == 0) - cputag_set_input_line(field->port->machine(), "maincpu", 0, ASSERT_LINE); + cputag_set_input_line(field->machine(), "maincpu", 0, ASSERT_LINE); } @@ -269,14 +269,14 @@ static INPUT_CHANGED( coin_inserted ) static CUSTOM_INPUT( firq_beam_r ) { - exidy440_state *state = field->port->machine().driver_data(); + exidy440_state *state = field->machine().driver_data(); return state->m_firq_beam; } static CUSTOM_INPUT( firq_vblank_r ) { - exidy440_state *state = field->port->machine().driver_data(); + exidy440_state *state = field->machine().driver_data(); return state->m_firq_vblank; } @@ -284,7 +284,7 @@ static CUSTOM_INPUT( firq_vblank_r ) static CUSTOM_INPUT( hitnmiss_button1_r ) { /* button 1 shows up in two bits */ - UINT32 button1 = input_port_read(field->port->machine(), "HITNMISS_BUTTON1"); + UINT32 button1 = input_port_read(field->machine(), "HITNMISS_BUTTON1"); return (button1 << 1) | button1; } diff --git a/src/mame/drivers/exprraid.c b/src/mame/drivers/exprraid.c index 6e9fd37646c..9dc7720800b 100644 --- a/src/mame/drivers/exprraid.c +++ b/src/mame/drivers/exprraid.c @@ -280,13 +280,13 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted_deco16 ) { - exprraid_state *state = field->port->machine().driver_data(); + exprraid_state *state = field->machine().driver_data(); device_set_input_line(state->m_maincpu, DECO16_IRQ_LINE, newval ? CLEAR_LINE : ASSERT_LINE); } static INPUT_CHANGED( coin_inserted_nmi ) { - exprraid_state *state = field->port->machine().driver_data(); + exprraid_state *state = field->machine().driver_data(); device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/fantland.c b/src/mame/drivers/fantland.c index 26fd6845e7f..1400a48b25c 100644 --- a/src/mame/drivers/fantland.c +++ b/src/mame/drivers/fantland.c @@ -730,7 +730,7 @@ INPUT_PORTS_END static CUSTOM_INPUT( wheelrun_wheel_r ) { int player = (FPTR)param; - int delta = input_port_read(field->port->machine(), player ? "WHEEL1" : "WHEEL0"); + int delta = input_port_read(field->machine(), player ? "WHEEL1" : "WHEEL0"); delta = (delta & 0x7f) - (delta & 0x80) + 4; if (delta > 7) delta = 7; diff --git a/src/mame/drivers/fcombat.c b/src/mame/drivers/fcombat.c index bde6436000e..38255c22b45 100644 --- a/src/mame/drivers/fcombat.c +++ b/src/mame/drivers/fcombat.c @@ -36,7 +36,7 @@ inputs + notes by stephh static INPUT_CHANGED( coin_inserted ) { - fcombat_state *state = field->port->machine().driver_data(); + fcombat_state *state = field->machine().driver_data(); /* coin insertion causes an NMI */ device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); diff --git a/src/mame/drivers/fgoal.c b/src/mame/drivers/fgoal.c index 1bd348b262a..b9fbc6870fb 100644 --- a/src/mame/drivers/fgoal.c +++ b/src/mame/drivers/fgoal.c @@ -106,7 +106,7 @@ static READ8_HANDLER( fgoal_analog_r ) static CUSTOM_INPUT( fgoal_80_r ) { - UINT8 ret = (field->port->machine().primary_screen->vpos() & 0x80) ? 1 : 0; + UINT8 ret = (field->machine().primary_screen->vpos() & 0x80) ? 1 : 0; return ret; } diff --git a/src/mame/drivers/firefox.c b/src/mame/drivers/firefox.c index f3bcaf499f5..01e4899ee20 100644 --- a/src/mame/drivers/firefox.c +++ b/src/mame/drivers/firefox.c @@ -265,13 +265,13 @@ static WRITE8_HANDLER( firefox_objram_bank_w ) static CUSTOM_INPUT( mainflag_r ) { - firefox_state *state = field->port->machine().driver_data(); + firefox_state *state = field->machine().driver_data(); return state->m_main_to_sound_flag; } static CUSTOM_INPUT( soundflag_r ) { - firefox_state *state = field->port->machine().driver_data(); + firefox_state *state = field->machine().driver_data(); return state->m_sound_to_main_flag; } diff --git a/src/mame/drivers/firetrk.c b/src/mame/drivers/firetrk.c index 19204bd82ae..6cfe2819cce 100644 --- a/src/mame/drivers/firetrk.c +++ b/src/mame/drivers/firetrk.c @@ -29,20 +29,20 @@ static void set_service_mode(running_machine &machine, int enable) static INPUT_CHANGED( service_mode_switch_changed ) { - set_service_mode(field->port->machine(), newval); + set_service_mode(field->machine(), newval); } static INPUT_CHANGED( firetrk_horn_changed ) { - device_t *discrete = field->port->machine().device("discrete"); + device_t *discrete = field->machine().device("discrete"); discrete_sound_w(discrete, FIRETRUCK_HORN_EN, newval); } static INPUT_CHANGED( gear_changed ) { - firetrk_state *state = field->port->machine().driver_data(); + firetrk_state *state = field->machine().driver_data(); if (newval) state->m_gear = (FPTR)param; } @@ -200,21 +200,21 @@ static READ8_HANDLER( montecar_dip_r ) static CUSTOM_INPUT( steer_dir_r ) { - firetrk_state *state = field->port->machine().driver_data(); + firetrk_state *state = field->machine().driver_data(); return state->m_steer_dir[(FPTR)param]; } static CUSTOM_INPUT( steer_flag_r ) { - firetrk_state *state = field->port->machine().driver_data(); + firetrk_state *state = field->machine().driver_data(); return state->m_steer_flag[(FPTR)param]; } static CUSTOM_INPUT( skid_r ) { - firetrk_state *state = field->port->machine().driver_data(); + firetrk_state *state = field->machine().driver_data(); UINT32 ret; int which = (FPTR)param; @@ -229,7 +229,7 @@ static CUSTOM_INPUT( skid_r ) static CUSTOM_INPUT( crash_r ) { - firetrk_state *state = field->port->machine().driver_data(); + firetrk_state *state = field->machine().driver_data(); UINT32 ret; int which = (FPTR)param; @@ -244,7 +244,7 @@ static CUSTOM_INPUT( crash_r ) static CUSTOM_INPUT( gear_r ) { - firetrk_state *state = field->port->machine().driver_data(); + firetrk_state *state = field->machine().driver_data(); return (state->m_gear == (FPTR)param) ? 1 : 0; } diff --git a/src/mame/drivers/flstory.c b/src/mame/drivers/flstory.c index b698bc0acc9..c131836d75f 100644 --- a/src/mame/drivers/flstory.c +++ b/src/mame/drivers/flstory.c @@ -124,7 +124,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( victnine_mcu_status_bit01_r ) { - flstory_state *state = field->port->machine().driver_data(); + flstory_state *state = field->machine().driver_data(); address_space *space = state->m_maincpu->memory().space(AS_PROGRAM); return (victnine_mcu_status_r(space, 0) & 3); diff --git a/src/mame/drivers/fromanc2.c b/src/mame/drivers/fromanc2.c index c8f0a03ba32..312e0693b9d 100644 --- a/src/mame/drivers/fromanc2.c +++ b/src/mame/drivers/fromanc2.c @@ -75,19 +75,19 @@ static READ16_HANDLER( fromanc2_keymatrix_r ) static CUSTOM_INPUT( subcpu_int_r ) { - fromanc2_state *state = field->port->machine().driver_data(); + fromanc2_state *state = field->machine().driver_data(); return state->m_subcpu_int_flag & 0x01; } static CUSTOM_INPUT( sndcpu_nmi_r ) { - fromanc2_state *state = field->port->machine().driver_data(); + fromanc2_state *state = field->machine().driver_data(); return state->m_sndcpu_nmi_flag & 0x01; } static CUSTOM_INPUT( subcpu_nmi_r ) { - fromanc2_state *state = field->port->machine().driver_data(); + fromanc2_state *state = field->machine().driver_data(); return state->m_subcpu_nmi_flag & 0x01; } @@ -416,6 +416,7 @@ static INPUT_PORTS_START( fromanc2 ) PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eeprom_set_cs_line) INPUT_PORTS_END +#ifdef UNREFERENCED_CODE static INPUT_PORTS_START( fromancr ) PORT_INCLUDE( fromanc2 ) @@ -424,6 +425,7 @@ static INPUT_PORTS_START( fromancr ) PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eeprom_set_clock_line) PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eeprom_set_cs_line) INPUT_PORTS_END +#endif static INPUT_PORTS_START( fromanc4 ) PORT_INCLUDE( fromanc2 ) diff --git a/src/mame/drivers/gaelco3d.c b/src/mame/drivers/gaelco3d.c index e976f409357..0475b6bde0d 100644 --- a/src/mame/drivers/gaelco3d.c +++ b/src/mame/drivers/gaelco3d.c @@ -409,7 +409,7 @@ static WRITE16_HANDLER( sound_status_w ) static CUSTOM_INPUT( analog_bit_r ) { - gaelco3d_state *state = field->port->machine().driver_data(); + gaelco3d_state *state = field->machine().driver_data(); int which = (FPTR)param; return (state->m_analog_ports[which] >> 7) & 0x01; } diff --git a/src/mame/drivers/galaga.c b/src/mame/drivers/galaga.c index 314020dcdb3..a1a98784191 100644 --- a/src/mame/drivers/galaga.c +++ b/src/mame/drivers/galaga.c @@ -779,7 +779,7 @@ static WRITE8_HANDLER( bosco_latch_w ) } } -static CUSTOM_INPUT( shifted_port_r ) { return input_port_read(field->port->machine(), (const char *)param) >> 4; } +static CUSTOM_INPUT( shifted_port_r ) { return input_port_read(field->machine(), (const char *)param) >> 4; } static WRITE8_DEVICE_HANDLER( out_0 ) { diff --git a/src/mame/drivers/galastrm.c b/src/mame/drivers/galastrm.c index 7f821e9bcab..b4c72645fb2 100644 --- a/src/mame/drivers/galastrm.c +++ b/src/mame/drivers/galastrm.c @@ -92,13 +92,13 @@ static WRITE32_HANDLER( galastrm_tc0610_1_w ) static CUSTOM_INPUT( frame_counter_r ) { - galastrm_state *state = field->port->machine().driver_data(); + galastrm_state *state = field->machine().driver_data(); return state->m_frame_counter; } static CUSTOM_INPUT( coin_word_r ) { - galastrm_state *state = field->port->machine().driver_data(); + galastrm_state *state = field->machine().driver_data(); return state->m_coin_word; } diff --git a/src/mame/drivers/galaxi.c b/src/mame/drivers/galaxi.c index 5b491c7738f..f2907896ea7 100644 --- a/src/mame/drivers/galaxi.c +++ b/src/mame/drivers/galaxi.c @@ -261,14 +261,14 @@ static WRITE16_HANDLER( galaxi_500004_w ) static CUSTOM_INPUT( ticket_r ) { - galaxi_state *state = field->port->machine().driver_data(); - return state->m_ticket && !(field->port->machine().primary_screen->frame_number() % 10); + galaxi_state *state = field->machine().driver_data(); + return state->m_ticket && !(field->machine().primary_screen->frame_number() % 10); } static CUSTOM_INPUT( hopper_r ) { - galaxi_state *state = field->port->machine().driver_data(); - return state->m_hopper && !(field->port->machine().primary_screen->frame_number() % 10); + galaxi_state *state = field->machine().driver_data(); + return state->m_hopper && !(field->machine().primary_screen->frame_number() % 10); } diff --git a/src/mame/drivers/galaxian.c b/src/mame/drivers/galaxian.c index 7373e75b4b4..fc16912abf4 100644 --- a/src/mame/drivers/galaxian.c +++ b/src/mame/drivers/galaxian.c @@ -728,7 +728,7 @@ static READ8_DEVICE_HANDLER( scramble_protection_r ) static CUSTOM_INPUT( scramble_protection_alt_r ) { - galaxian_state *state = field->port->machine().driver_data(); + galaxian_state *state = field->machine().driver_data(); /* There are two additional bits that are derived from bit 7 of the protection result. This is just a guess but works well enough @@ -1008,31 +1008,31 @@ static const ppi8255_interface scorpion_ppi8255_1_intf = static INPUT_CHANGED( gmgalax_game_changed ) { - galaxian_state *state = field->port->machine().driver_data(); - address_space *space = field->port->machine().device("maincpu")->memory().space(AS_PROGRAM); + galaxian_state *state = field->machine().driver_data(); + address_space *space = field->machine().device("maincpu")->memory().space(AS_PROGRAM); /* new value is the selected game */ state->m_gmgalax_selected_game = newval; /* select the bank and graphics bank based on it */ - memory_set_bank(field->port->machine(), "bank1", state->m_gmgalax_selected_game); + memory_set_bank(field->machine(), "bank1", state->m_gmgalax_selected_game); galaxian_gfxbank_w(space, 0, state->m_gmgalax_selected_game); /* reset the stars */ galaxian_stars_enable_w(space, 0, 0); /* reset the CPU */ - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE); } static CUSTOM_INPUT( gmgalax_port_r ) { - galaxian_state *state = field->port->machine().driver_data(); + galaxian_state *state = field->machine().driver_data(); const char *portname = (const char *)param; if (state->m_gmgalax_selected_game != 0) portname += strlen(portname) + 1; - return input_port_read(field->port->machine(), portname); + return input_port_read(field->machine(), portname); } @@ -1084,7 +1084,7 @@ static WRITE8_HANDLER( zigzag_ay8910_w ) static CUSTOM_INPUT( azurian_port_r ) { - return (input_port_read(field->port->machine(), "FAKE") >> (FPTR)param) & 1; + return (input_port_read(field->machine(), "FAKE") >> (FPTR)param) & 1; } @@ -1097,9 +1097,9 @@ static CUSTOM_INPUT( azurian_port_r ) static CUSTOM_INPUT( kingball_muxbit_r ) { - galaxian_state *state = field->port->machine().driver_data(); + galaxian_state *state = field->machine().driver_data(); /* multiplex the service mode switch with a speech DIP switch */ - return (input_port_read(field->port->machine(), "FAKE") >> state->m_kingball_speech_dip) & 1; + return (input_port_read(field->machine(), "FAKE") >> state->m_kingball_speech_dip) & 1; } @@ -1108,7 +1108,7 @@ static CUSTOM_INPUT( kingball_noise_r ) /* bit 5 is the NOISE line from the sound circuit. The code just verifies that it's working, doesn't actually use return value, so we can just use rand() */ - return field->port->machine().rand() & 1; + return field->machine().rand() & 1; } @@ -2689,7 +2689,7 @@ static DRIVER_INIT( gmgalax ) memory_configure_bank(machine, "bank1", 0, 2, machine.region("maincpu")->base() + 0x10000, 0x4000); /* callback when the game select is toggled */ - gmgalax_game_changed(machine.m_portlist.first()->fieldlist, NULL, 0, 0); + gmgalax_game_changed(*state, machine.m_portlist.first()->fieldlist().first(), NULL, 0, 0); state_save_register_global(machine, state->m_gmgalax_selected_game); } diff --git a/src/mame/drivers/galaxold.c b/src/mame/drivers/galaxold.c index 37ce51346d5..a009c1f6f93 100644 --- a/src/mame/drivers/galaxold.c +++ b/src/mame/drivers/galaxold.c @@ -917,9 +917,9 @@ static CUSTOM_INPUT( vpool_lives_r ) switch (bit_mask) { case 0x40: /* vpool : IN1 (0xa800) bit 6 */ - return ((input_port_read(field->port->machine(), "LIVES") & bit_mask) >> 6); + return ((input_port_read(field->machine(), "LIVES") & bit_mask) >> 6); case 0x01: /* vpool : DSW (0xb000) bit 0 */ - return ((input_port_read(field->port->machine(), "LIVES") & bit_mask) >> 0); + return ((input_port_read(field->machine(), "LIVES") & bit_mask) >> 0); default: logerror("vpool_lives_r : invalid %02X bit_mask\n",bit_mask); @@ -1064,14 +1064,14 @@ static CUSTOM_INPUT( ckongg_coinage_r ) switch (bit_mask) { case 0x0c: /* ckongg : DSW (0xc800) bits 2 and 3 */ - return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 2); + return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 2); case 0x40: /* ckongg : IN1 (0xc400) bit 6 */ - return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 6); + return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 6); case 0xc0: /* ckongmc : IN1 (0xa800) bits 6 and 7 */ - return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 6); + return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 6); case 0x01: /* ckongmc : DSW (0xb000) bit 0 */ - return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 0); + return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 0); default: logerror("ckongg_coinage_r : invalid %02X bit_mask\n",bit_mask); @@ -1432,9 +1432,9 @@ static CUSTOM_INPUT( dkongjrm_coinage_r ) switch (bit_mask) { case 0xc0: /* dkongjrm : IN1 (0xa8??) bits 6 and 7 */ - return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 6); + return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 6); case 0x01: /* dkongjrm : DSW (0xb0??) bit 0 */ - return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 0); + return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 0); default: logerror("dkongjrm_coinage_r : invalid %02X bit_mask\n",bit_mask); diff --git a/src/mame/drivers/galdrvr.c b/src/mame/drivers/galdrvr.c index ee8ee10755e..ffc3d339b8a 100644 --- a/src/mame/drivers/galdrvr.c +++ b/src/mame/drivers/galdrvr.c @@ -2354,14 +2354,14 @@ INPUT_PORTS_END static CUSTOM_INPUT( moonwar_dial_r ) { - galaxian_state *state = field->port->machine().driver_data(); + galaxian_state *state = field->machine().driver_data(); static const char *const dialname[2] = { "P1_DIAL", "P2_DIAL" }; int p = (~state->m_moonwar_port_select >> 4) & 1; // see http://www.cityofberwyn.com/schematics/stern/MoonWar_opto.tiff for schematic // I.e. a 74ls161 counts from 0 to 15 which is the absolute number of bars passed on the quadrature - signed char dialread = input_port_read(field->port->machine(), dialname[p]); + signed char dialread = input_port_read(field->machine(), dialname[p]); UINT8 ret; diff --git a/src/mame/drivers/gottlieb.c b/src/mame/drivers/gottlieb.c index 34eb1bba034..8f20800d412 100644 --- a/src/mame/drivers/gottlieb.c +++ b/src/mame/drivers/gottlieb.c @@ -295,11 +295,11 @@ static MACHINE_RESET( gottlieb ) static CUSTOM_INPUT( analog_delta_r ) { - gottlieb_state *state = field->port->machine().driver_data(); + gottlieb_state *state = field->machine().driver_data(); const char *string = (const char *)param; int which = string[0] - '0'; - return input_port_read(field->port->machine(), &string[1]) - state->m_track[which]; + return input_port_read(field->machine(), &string[1]) - state->m_track[which]; } @@ -314,9 +314,9 @@ static WRITE8_HANDLER( gottlieb_analog_reset_w ) static CUSTOM_INPUT( stooges_joystick_r ) { - gottlieb_state *state = field->port->machine().driver_data(); + gottlieb_state *state = field->machine().driver_data(); static const char *const joyport[] = { "P2JOY", "P3JOY", "P1JOY", NULL }; - return (joyport[state->m_joystick_select & 3] != NULL) ? input_port_read(field->port->machine(), joyport[state->m_joystick_select & 3]) : 0xff; + return (joyport[state->m_joystick_select & 3] != NULL) ? input_port_read(field->machine(), joyport[state->m_joystick_select & 3]) : 0xff; } diff --git a/src/mame/drivers/groundfx.c b/src/mame/drivers/groundfx.c index 6cb41a488c9..ea7ea1f2c8b 100644 --- a/src/mame/drivers/groundfx.c +++ b/src/mame/drivers/groundfx.c @@ -126,13 +126,13 @@ static const eeprom_interface groundfx_eeprom_interface = static CUSTOM_INPUT( frame_counter_r ) { - groundfx_state *state = field->port->machine().driver_data(); + groundfx_state *state = field->machine().driver_data(); return state->m_frame_counter; } static CUSTOM_INPUT( coin_word_r ) { - groundfx_state *state = field->port->machine().driver_data(); + groundfx_state *state = field->machine().driver_data(); return state->m_coin_word; } diff --git a/src/mame/drivers/gstream.c b/src/mame/drivers/gstream.c index d506503afb9..ec3476de1cf 100644 --- a/src/mame/drivers/gstream.c +++ b/src/mame/drivers/gstream.c @@ -168,7 +168,7 @@ static CUSTOM_INPUT( gstream_mirror_service_r ) int result; /* PORT_SERVICE_NO_TOGGLE */ - result = (input_port_read(field->port->machine(), "IN0") & 0x8000) >> 15; + result = (input_port_read(field->machine(), "IN0") & 0x8000) >> 15; return ~result; } @@ -178,15 +178,15 @@ static CUSTOM_INPUT( gstream_mirror_r ) int result; /* IPT_COIN1 */ - result = ((input_port_read(field->port->machine(), "IN0") & 0x200) >> 9) << 0; + result = ((input_port_read(field->machine(), "IN0") & 0x200) >> 9) << 0; /* IPT_COIN2 */ - result |= ((input_port_read(field->port->machine(), "IN1") & 0x200) >> 9) << 1; + result |= ((input_port_read(field->machine(), "IN1") & 0x200) >> 9) << 1; /* IPT_START1 */ - result |= ((input_port_read(field->port->machine(), "IN0") & 0x400) >> 10) << 2; + result |= ((input_port_read(field->machine(), "IN0") & 0x400) >> 10) << 2; /* IPT_START2 */ - result |= ((input_port_read(field->port->machine(), "IN1") & 0x400) >> 10) << 3; + result |= ((input_port_read(field->machine(), "IN1") & 0x400) >> 10) << 3; /* PORT_SERVICE_NO_TOGGLE */ - result |= ((input_port_read(field->port->machine(), "IN0") & 0x8000) >> 15) << 6; + result |= ((input_port_read(field->machine(), "IN0") & 0x8000) >> 15) << 6; return ~result; } diff --git a/src/mame/drivers/guab.c b/src/mame/drivers/guab.c index cfaf8389b2b..8ea94993b48 100644 --- a/src/mame/drivers/guab.c +++ b/src/mame/drivers/guab.c @@ -594,7 +594,7 @@ static INPUT_CHANGED( coin_inserted ) if (newval == 0) { UINT32 credit; - address_space *space = field->port->machine().device("maincpu")->memory().space(AS_PROGRAM); + address_space *space = field->machine().device("maincpu")->memory().space(AS_PROGRAM); /* Get the current credit value and add the new coin value */ credit = space->read_dword(0x8002c) + (UINT32)(FPTR)param; diff --git a/src/mame/drivers/gunbustr.c b/src/mame/drivers/gunbustr.c index 8551b718c78..323f14cdf8a 100644 --- a/src/mame/drivers/gunbustr.c +++ b/src/mame/drivers/gunbustr.c @@ -80,7 +80,7 @@ static WRITE32_HANDLER( gunbustr_palette_w ) static CUSTOM_INPUT( coin_word_r ) { - gunbustr_state *state = field->port->machine().driver_data(); + gunbustr_state *state = field->machine().driver_data(); return state->m_coin_word; } diff --git a/src/mame/drivers/homerun.c b/src/mame/drivers/homerun.c index ee9ab5b5ad1..145f5f0f701 100644 --- a/src/mame/drivers/homerun.c +++ b/src/mame/drivers/homerun.c @@ -64,7 +64,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( homerun_40_r ) { - UINT8 ret = (field->port->machine().primary_screen->vpos() > 116) ? 1 : 0; + UINT8 ret = (field->machine().primary_screen->vpos() > 116) ? 1 : 0; return ret; } diff --git a/src/mame/drivers/igs009.c b/src/mame/drivers/igs009.c index 31db6fbd458..37e82f4c823 100644 --- a/src/mame/drivers/igs009.c +++ b/src/mame/drivers/igs009.c @@ -342,8 +342,8 @@ static SCREEN_UPDATE(jingbell) static CUSTOM_INPUT( hopper_r ) { - igs009_state *state = field->port->machine().driver_data(); - return state->m_hopper && !(field->port->machine().primary_screen->frame_number()%10); + igs009_state *state = field->machine().driver_data(); + return state->m_hopper && !(field->machine().primary_screen->frame_number()%10); } diff --git a/src/mame/drivers/igs011.c b/src/mame/drivers/igs011.c index 51aaede3507..9ff2b7f444c 100644 --- a/src/mame/drivers/igs011.c +++ b/src/mame/drivers/igs011.c @@ -466,8 +466,8 @@ static WRITE16_HANDLER( igs011_blit_flags_w ) static CUSTOM_INPUT( igs_hopper_r ) { - igs011_state *state = field->port->machine().driver_data(); - return (state->m_igs_hopper && ((field->port->machine().primary_screen->frame_number()/5)&1)) ? 0x0000 : 0x0001; + igs011_state *state = field->machine().driver_data(); + return (state->m_igs_hopper && ((field->machine().primary_screen->frame_number()/5)&1)) ? 0x0000 : 0x0001; } static WRITE16_HANDLER( igs_dips_w ) diff --git a/src/mame/drivers/igspoker.c b/src/mame/drivers/igspoker.c index bd53532bf98..a71185936bf 100644 --- a/src/mame/drivers/igspoker.c +++ b/src/mame/drivers/igspoker.c @@ -320,9 +320,9 @@ static WRITE8_HANDLER( custom_io_w ) static CUSTOM_INPUT( hopper_r ) { - igspoker_state *state = field->port->machine().driver_data(); - if (state->m_hopper) return !(field->port->machine().primary_screen->frame_number()%10); - return input_code_pressed(field->port->machine(), KEYCODE_H); + igspoker_state *state = field->machine().driver_data(); + if (state->m_hopper) return !(field->machine().primary_screen->frame_number()%10); + return input_code_pressed(field->machine(), KEYCODE_H); } static READ8_HANDLER( exp_rom_r ) diff --git a/src/mame/drivers/inufuku.c b/src/mame/drivers/inufuku.c index f1576075cd6..c2be0268a59 100644 --- a/src/mame/drivers/inufuku.c +++ b/src/mame/drivers/inufuku.c @@ -115,7 +115,7 @@ static WRITE8_HANDLER( inufuku_soundrombank_w ) static CUSTOM_INPUT( soundflag_r ) { - inufuku_state *state = field->port->machine().driver_data(); + inufuku_state *state = field->machine().driver_data(); UINT16 soundflag = state->m_pending_command ? 0 : 1; return soundflag; diff --git a/src/mame/drivers/itech32.c b/src/mame/drivers/itech32.c index b29d9a8c7dd..0d4f1b49a54 100644 --- a/src/mame/drivers/itech32.c +++ b/src/mame/drivers/itech32.c @@ -466,7 +466,7 @@ static MACHINE_RESET( drivedge ) static CUSTOM_INPUT( special_port_r ) { - itech32_state *state = field->port->machine().driver_data(); + itech32_state *state = field->machine().driver_data(); if (state->m_sound_int_state) state->m_special_result ^= 1; diff --git a/src/mame/drivers/itech8.c b/src/mame/drivers/itech8.c index 278fcce963c..e82a105955a 100644 --- a/src/mame/drivers/itech8.c +++ b/src/mame/drivers/itech8.c @@ -728,7 +728,7 @@ static WRITE8_HANDLER( rimrockn_bank_w ) static CUSTOM_INPUT( special_r ) { - itech8_state *state = field->port->machine().driver_data(); + itech8_state *state = field->machine().driver_data(); return state->m_pia_portb_data & 0x01; } @@ -1102,7 +1102,7 @@ static CUSTOM_INPUT( gtg_mux ) { const char *tag1 = (const char *)param; const char *tag2 = tag1 + strlen(tag1) + 1; - return input_port_read(field->port->machine(), tag1) & input_port_read(field->port->machine(), tag2); + return input_port_read(field->machine(), tag1) & input_port_read(field->machine(), tag2); } static INPUT_PORTS_START( gtg ) diff --git a/src/mame/drivers/jack.c b/src/mame/drivers/jack.c index 1371c80238a..04b87aa58fb 100644 --- a/src/mame/drivers/jack.c +++ b/src/mame/drivers/jack.c @@ -83,10 +83,10 @@ static WRITE8_HANDLER( joinem_misc_w ) static CUSTOM_INPUT( sound_check_r ) { - jack_state *state = field->port->machine().driver_data(); + jack_state *state = field->machine().driver_data(); UINT8 ret = 0; - if ((input_port_read(field->port->machine(), "IN2") & 0x80) && !state->m_joinem_snd_bit) + if ((input_port_read(field->machine(), "IN2") & 0x80) && !state->m_joinem_snd_bit) ret = 1; return ret; diff --git a/src/mame/drivers/jackie.c b/src/mame/drivers/jackie.c index be867cf61a9..5574e77e1f9 100644 --- a/src/mame/drivers/jackie.c +++ b/src/mame/drivers/jackie.c @@ -391,9 +391,9 @@ ADDRESS_MAP_END static CUSTOM_INPUT( hopper_r ) { - jackie_state *state = field->port->machine().driver_data(); - if (state->m_hopper) return !(field->port->machine().primary_screen->frame_number()%10); - return input_code_pressed(field->port->machine(), KEYCODE_H); + jackie_state *state = field->machine().driver_data(); + if (state->m_hopper) return !(field->machine().primary_screen->frame_number()%10); + return input_code_pressed(field->machine(), KEYCODE_H); } static INPUT_PORTS_START( jackie ) diff --git a/src/mame/drivers/jpmsys5.c b/src/mame/drivers/jpmsys5.c index cc4ba7c2659..14825983949 100644 --- a/src/mame/drivers/jpmsys5.c +++ b/src/mame/drivers/jpmsys5.c @@ -368,15 +368,15 @@ static TIMER_CALLBACK( touch_cb ) static INPUT_CHANGED( touchscreen_press ) { - jpmsys5_state *state = field->port->machine().driver_data(); + jpmsys5_state *state = field->machine().driver_data(); if (newval == 0) { attotime rx_period = attotime::from_hz(10000) * 16; /* Each touch screen packet is 3 bytes */ state->m_touch_data[0] = 0x2a; - state->m_touch_data[1] = 0x7 - (input_port_read(field->port->machine(), "TOUCH_Y") >> 5) + 0x30; - state->m_touch_data[2] = (input_port_read(field->port->machine(), "TOUCH_X") >> 5) + 0x30; + state->m_touch_data[1] = 0x7 - (input_port_read(field->machine(), "TOUCH_Y") >> 5) + 0x30; + state->m_touch_data[2] = (input_port_read(field->machine(), "TOUCH_X") >> 5) + 0x30; /* Start sending the data to the 68000 serially */ state->m_touch_data_count = 0; diff --git a/src/mame/drivers/kopunch.c b/src/mame/drivers/kopunch.c index cb3132b2e04..f7c1a12759d 100644 --- a/src/mame/drivers/kopunch.c +++ b/src/mame/drivers/kopunch.c @@ -70,7 +70,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( left_coin_inserted ) { - kopunch_state *state = field->port->machine().driver_data(); + kopunch_state *state = field->machine().driver_data(); /* left coin insertion causes a rst6.5 (vector 0x34) */ if (newval) @@ -79,7 +79,7 @@ static INPUT_CHANGED( left_coin_inserted ) static INPUT_CHANGED( right_coin_inserted ) { - kopunch_state *state = field->port->machine().driver_data(); + kopunch_state *state = field->machine().driver_data(); /* right coin insertion causes a rst5.5 (vector 0x2c) */ if (newval) diff --git a/src/mame/drivers/ksys573.c b/src/mame/drivers/ksys573.c index cc92026cd34..59d0e9f0de6 100644 --- a/src/mame/drivers/ksys573.c +++ b/src/mame/drivers/ksys573.c @@ -1653,9 +1653,9 @@ static void gn845pwbb_clk_w( running_machine &machine, int offset, int data ) static CUSTOM_INPUT( gn845pwbb_read ) { - ksys573_state *state = field->port->machine().driver_data(); + ksys573_state *state = field->machine().driver_data(); - return input_port_read(field->port->machine(), "STAGE") & state->m_stage_mask; + return input_port_read(field->machine(), "STAGE") & state->m_stage_mask; } static void gn845pwbb_output_callback( running_machine &machine, int offset, int data ) @@ -2881,7 +2881,7 @@ static WRITE32_HANDLER( gunmania_w ) static CUSTOM_INPUT( gunmania_tank_shutter_sensor ) { - ksys573_state *state = field->port->machine().driver_data(); + ksys573_state *state = field->machine().driver_data(); if( state->m_tank_shutter_position == 0 ) { @@ -2893,7 +2893,7 @@ static CUSTOM_INPUT( gunmania_tank_shutter_sensor ) static CUSTOM_INPUT( gunmania_cable_holder_sensor ) { - ksys573_state *state = field->port->machine().driver_data(); + ksys573_state *state = field->machine().driver_data(); return state->m_cable_holder_release; } diff --git a/src/mame/drivers/ladybug.c b/src/mame/drivers/ladybug.c index 17bec4aab28..0e5a3236b4f 100644 --- a/src/mame/drivers/ladybug.c +++ b/src/mame/drivers/ladybug.c @@ -189,7 +189,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin1_inserted ) { - ladybug_state *state = field->port->machine().driver_data(); + ladybug_state *state = field->machine().driver_data(); /* left coin insertion causes an NMI */ device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); @@ -197,7 +197,7 @@ static INPUT_CHANGED( coin1_inserted ) static INPUT_CHANGED( coin2_inserted ) { - ladybug_state *state = field->port->machine().driver_data(); + ladybug_state *state = field->machine().driver_data(); /* right coin insertion causes an IRQ */ if (newval) @@ -210,7 +210,7 @@ static INPUT_CHANGED( coin2_inserted ) static CUSTOM_INPUT( ladybug_p1_control_r ) { - return input_port_read(field->port->machine(), LADYBUG_P1_CONTROL_PORT_TAG); + return input_port_read(field->machine(), LADYBUG_P1_CONTROL_PORT_TAG); } static CUSTOM_INPUT( ladybug_p2_control_r ) @@ -218,10 +218,10 @@ static CUSTOM_INPUT( ladybug_p2_control_r ) UINT32 ret; /* upright cabinet only uses a single set of controls */ - if (input_port_read(field->port->machine(), "DSW0") & 0x20) - ret = input_port_read(field->port->machine(), LADYBUG_P2_CONTROL_PORT_TAG); + if (input_port_read(field->machine(), "DSW0") & 0x20) + ret = input_port_read(field->machine(), LADYBUG_P2_CONTROL_PORT_TAG); else - ret = input_port_read(field->port->machine(), LADYBUG_P1_CONTROL_PORT_TAG); + ret = input_port_read(field->machine(), LADYBUG_P1_CONTROL_PORT_TAG); return ret; } diff --git a/src/mame/drivers/lasso.c b/src/mame/drivers/lasso.c index 283b17766e7..8e4a9c5b4cf 100644 --- a/src/mame/drivers/lasso.c +++ b/src/mame/drivers/lasso.c @@ -38,7 +38,7 @@ DIP locations verified for: static INPUT_CHANGED( coin_inserted ) { - lasso_state *state = field->port->machine().driver_data(); + lasso_state *state = field->machine().driver_data(); /* coin insertion causes an NMI */ device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); diff --git a/src/mame/drivers/lethalj.c b/src/mame/drivers/lethalj.c index 8d1a4ccc506..9840f79716b 100644 --- a/src/mame/drivers/lethalj.c +++ b/src/mame/drivers/lethalj.c @@ -161,7 +161,7 @@ Pin #11(+) | | R | static CUSTOM_INPUT( cclownz_paddle ) { - int value = input_port_read(field->port->machine(), "PADDLE"); + int value = input_port_read(field->machine(), "PADDLE"); return ((value << 4) & 0xf00) | (value & 0x00f); } diff --git a/src/mame/drivers/limenko.c b/src/mame/drivers/limenko.c index d275215e831..2c26fe5fe70 100644 --- a/src/mame/drivers/limenko.c +++ b/src/mame/drivers/limenko.c @@ -112,7 +112,7 @@ static WRITE32_HANDLER( spotty_soundlatch_w ) static CUSTOM_INPUT( spriteram_bit_r ) { - limenko_state *state = field->port->machine().driver_data(); + limenko_state *state = field->machine().driver_data(); return state->m_spriteram_bit; } diff --git a/src/mame/drivers/m10.c b/src/mame/drivers/m10.c index 4362007c488..09ecb30d7fd 100644 --- a/src/mame/drivers/m10.c +++ b/src/mame/drivers/m10.c @@ -508,7 +508,7 @@ static READ8_HANDLER( m11_a700_r ) static INPUT_CHANGED( coin_inserted ) { - m10_state *state = field->port->machine().driver_data(); + m10_state *state = field->machine().driver_data(); /* coin insertion causes an NMI */ device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); } diff --git a/src/mame/drivers/m14.c b/src/mame/drivers/m14.c index b0296450ac5..3dd2e792dc5 100644 --- a/src/mame/drivers/m14.c +++ b/src/mame/drivers/m14.c @@ -222,7 +222,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( left_coin_inserted ) { - m14_state *state = field->port->machine().driver_data(); + m14_state *state = field->machine().driver_data(); /* left coin insertion causes a rst6.5 (vector 0x34) */ if (newval) device_set_input_line(state->m_maincpu, I8085_RST65_LINE, HOLD_LINE); @@ -230,7 +230,7 @@ static INPUT_CHANGED( left_coin_inserted ) static INPUT_CHANGED( right_coin_inserted ) { - m14_state *state = field->port->machine().driver_data(); + m14_state *state = field->machine().driver_data(); /* right coin insertion causes a rst5.5 (vector 0x2c) */ if (newval) device_set_input_line(state->m_maincpu, I8085_RST55_LINE, HOLD_LINE); diff --git a/src/mame/drivers/m92.c b/src/mame/drivers/m92.c index b0189a12b5b..cd0a4356360 100644 --- a/src/mame/drivers/m92.c +++ b/src/mame/drivers/m92.c @@ -289,7 +289,7 @@ static WRITE16_HANDLER( m92_bankswitch_w ) static CUSTOM_INPUT( m92_sprite_busy_r ) { - m92_state *state = field->port->machine().driver_data(); + m92_state *state = field->machine().driver_data(); return state->m_sprite_buffer_busy; } diff --git a/src/mame/drivers/madalien.c b/src/mame/drivers/madalien.c index 0ca0a37b5e9..454dd2b61c2 100644 --- a/src/mame/drivers/madalien.c +++ b/src/mame/drivers/madalien.c @@ -19,7 +19,7 @@ static INPUT_CHANGED( coin_inserted ) { /* coin insertion causes an NMI */ - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/mainsnk.c b/src/mame/drivers/mainsnk.c index bb4bde8eb8a..dd46d7acef9 100644 --- a/src/mame/drivers/mainsnk.c +++ b/src/mame/drivers/mainsnk.c @@ -136,7 +136,7 @@ static READ8_HANDLER( sound_ack_r ) static CUSTOM_INPUT( mainsnk_sound_r ) { - mainsnk_state *state = field->port->machine().driver_data(); + mainsnk_state *state = field->machine().driver_data(); return (state->m_sound_cpu_busy) ? 0x01 : 0x00; } diff --git a/src/mame/drivers/maxaflex.c b/src/mame/drivers/maxaflex.c index a25b8c122b7..5139f16a664 100644 --- a/src/mame/drivers/maxaflex.c +++ b/src/mame/drivers/maxaflex.c @@ -256,7 +256,7 @@ static MACHINE_RESET(supervisor_board) static INPUT_CHANGED( coin_inserted ) { if (!newval) - cputag_set_input_line(field->port->machine(), "mcu", M6805_IRQ_LINE, HOLD_LINE ); + cputag_set_input_line(field->machine(), "mcu", M6805_IRQ_LINE, HOLD_LINE ); } int atari_input_disabled(running_machine &machine) diff --git a/src/mame/drivers/meadows.c b/src/mame/drivers/meadows.c index d6032286032..002a395d8c5 100644 --- a/src/mame/drivers/meadows.c +++ b/src/mame/drivers/meadows.c @@ -199,7 +199,7 @@ static WRITE8_HANDLER( meadows_audio_w ) static INPUT_CHANGED( coin_inserted ) { - cputag_set_input_line_and_vector(field->port->machine(), "maincpu", 0, (newval ? ASSERT_LINE : CLEAR_LINE), 0x82); + cputag_set_input_line_and_vector(field->machine(), "maincpu", 0, (newval ? ASSERT_LINE : CLEAR_LINE), 0x82); } diff --git a/src/mame/drivers/merit.c b/src/mame/drivers/merit.c index 01718589991..0e8f3a9393e 100644 --- a/src/mame/drivers/merit.c +++ b/src/mame/drivers/merit.c @@ -346,7 +346,7 @@ static WRITE8_HANDLER(casino5_bank_w) static CUSTOM_INPUT(rndbit_r) { - return field->port->machine().rand(); + return field->machine().rand(); } static ADDRESS_MAP_START( pitboss_map, AS_PROGRAM, 8 ) diff --git a/src/mame/drivers/metro.c b/src/mame/drivers/metro.c index 24f7eed73f6..4f202561aa2 100644 --- a/src/mame/drivers/metro.c +++ b/src/mame/drivers/metro.c @@ -379,7 +379,7 @@ static READ16_HANDLER( metro_soundstatus_r ) static CUSTOM_INPUT( custom_soundstatus_r ) { - metro_state *state = field->port->machine().driver_data(); + metro_state *state = field->machine().driver_data(); return (state->m_busy_sndcpu ? 0x01 : 0x00); } diff --git a/src/mame/drivers/mhavoc.c b/src/mame/drivers/mhavoc.c index 90dc791ffa9..09faf9df585 100644 --- a/src/mame/drivers/mhavoc.c +++ b/src/mame/drivers/mhavoc.c @@ -320,7 +320,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( clock_r ) { /* 2.4kHz (divide 2.5MHz by 1024) */ - return (field->port->machine().device("alpha")->total_cycles() & 0x400) ? 0 : 1; + return (field->machine().device("alpha")->total_cycles() & 0x400) ? 0 : 1; } diff --git a/src/mame/drivers/midyunit.c b/src/mame/drivers/midyunit.c index e2ae740ccaf..ea6cc2f8b86 100644 --- a/src/mame/drivers/midyunit.c +++ b/src/mame/drivers/midyunit.c @@ -152,19 +152,19 @@ static WRITE8_DEVICE_HANDLER( yawdim_oki_bank_w ) static CUSTOM_INPUT( narc_talkback_strobe_r ) { - return (williams_narc_talkback_r(field->port->machine()) >> 8) & 1; + return (williams_narc_talkback_r(field->machine()) >> 8) & 1; } static CUSTOM_INPUT( narc_talkback_data_r ) { - return williams_narc_talkback_r(field->port->machine()) & 0xff; + return williams_narc_talkback_r(field->machine()) & 0xff; } static CUSTOM_INPUT( adpcm_irq_state_r ) { - return williams_adpcm_sound_irq_r(field->port->machine()) & 1; + return williams_adpcm_sound_irq_r(field->machine()) & 1; } diff --git a/src/mame/drivers/midzeus.c b/src/mame/drivers/midzeus.c index 89748d9348d..7fd788525c1 100644 --- a/src/mame/drivers/midzeus.c +++ b/src/mame/drivers/midzeus.c @@ -432,7 +432,7 @@ static CUSTOM_INPUT( custom_49way_r ) static const UINT8 translate49[7] = { 0x8, 0xc, 0xe, 0xf, 0x3, 0x1, 0x0 }; const char *namex = (const char *)param; const char *namey = namex + strlen(namex) + 1; - return (translate49[input_port_read(field->port->machine(), namey) >> 4] << 4) | translate49[input_port_read(field->port->machine(), namex) >> 4]; + return (translate49[input_port_read(field->machine(), namey) >> 4] << 4) | translate49[input_port_read(field->machine(), namex) >> 4]; } @@ -445,7 +445,7 @@ static WRITE32_HANDLER( keypad_select_w ) static CUSTOM_INPUT( keypad_r ) { - UINT32 bits = input_port_read(field->port->machine(), (const char *)param); + UINT32 bits = input_port_read(field->machine(), (const char *)param); UINT8 select = keypad_select; while ((select & 1) != 0) { diff --git a/src/mame/drivers/missile.c b/src/mame/drivers/missile.c index f5e4f6488ae..15b06f6b446 100644 --- a/src/mame/drivers/missile.c +++ b/src/mame/drivers/missile.c @@ -450,8 +450,8 @@ static TIMER_CALLBACK( clock_irq ) static CUSTOM_INPUT( get_vblank ) { - missile_state *state = field->port->machine().driver_data(); - int v = scanline_to_v(state, field->port->machine().primary_screen->vpos()); + missile_state *state = field->machine().driver_data(); + int v = scanline_to_v(state, field->machine().primary_screen->vpos()); return v < 24; } diff --git a/src/mame/drivers/model2.c b/src/mame/drivers/model2.c index f5f0a40f7ed..289dbf5ef4d 100644 --- a/src/mame/drivers/model2.c +++ b/src/mame/drivers/model2.c @@ -460,8 +460,8 @@ static READ32_HANDLER( videoctl_r ) static CUSTOM_INPUT( _1c00000_r ) { - model2_state *state = field->port->machine().driver_data(); - UINT32 ret = input_port_read(field->port->machine(), "IN0"); + model2_state *state = field->machine().driver_data(); + UINT32 ret = input_port_read(field->machine(), "IN0"); if(state->m_ctrlmode == 0) { @@ -470,18 +470,18 @@ static CUSTOM_INPUT( _1c00000_r ) else { ret &= ~0x0030; - return ret | 0x00d0 | (eeprom_read_bit(field->port->machine().device("eeprom")) << 5); + return ret | 0x00d0 | (eeprom_read_bit(field->machine().device("eeprom")) << 5); } } static CUSTOM_INPUT( _1c0001c_r ) { - model2_state *state = field->port->machine().driver_data(); + model2_state *state = field->machine().driver_data(); UINT32 iptval = 0x00ff; if(state->m_analog_channel < 4) { static const char *const ports[] = { "ANA0", "ANA1", "ANA2", "ANA3" }; - iptval = input_port_read_safe(field->port->machine(), ports[state->m_analog_channel], 0); + iptval = input_port_read_safe(field->machine(), ports[state->m_analog_channel], 0); ++state->m_analog_channel; } return iptval; diff --git a/src/mame/drivers/ms32.c b/src/mame/drivers/ms32.c index f7188b7eacc..afbc0dec218 100644 --- a/src/mame/drivers/ms32.c +++ b/src/mame/drivers/ms32.c @@ -176,25 +176,25 @@ Super Strong Warriors static CUSTOM_INPUT( mahjong_ctrl_r ) { - ms32_state *state = field->port->machine().driver_data(); + ms32_state *state = field->machine().driver_data(); UINT32 mj_input; switch (state->m_mahjong_input_select[0]) { case 0x01: - mj_input = input_port_read(field->port->machine(), "MJ0"); + mj_input = input_port_read(field->machine(), "MJ0"); break; case 0x02: - mj_input = input_port_read(field->port->machine(), "MJ1"); + mj_input = input_port_read(field->machine(), "MJ1"); break; case 0x04: - mj_input = input_port_read(field->port->machine(), "MJ2"); + mj_input = input_port_read(field->machine(), "MJ2"); break; case 0x08: - mj_input = input_port_read(field->port->machine(), "MJ3"); + mj_input = input_port_read(field->machine(), "MJ3"); break; case 0x10: - mj_input = input_port_read(field->port->machine(), "MJ4"); + mj_input = input_port_read(field->machine(), "MJ4"); break; default: mj_input = 0; diff --git a/src/mame/drivers/msx.c b/src/mame/drivers/msx.c index c7e5294905c..749357849ce 100644 --- a/src/mame/drivers/msx.c +++ b/src/mame/drivers/msx.c @@ -659,6 +659,7 @@ static INPUT_PORTS_START( msx ) PORT_INCLUDE( msx_dips ) INPUT_PORTS_END +#ifdef UNREFERENCED_CODE static INPUT_PORTS_START( msxuk ) PORT_START("KEY0") KEYB_ROW0 @@ -692,6 +693,7 @@ static INPUT_PORTS_START( msxuk ) PORT_INCLUDE( msx_dips ) INPUT_PORTS_END +#endif #define KEYB_JAP_ROW0 \ PORT_BIT (0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') \ diff --git a/src/mame/drivers/multfish.c b/src/mame/drivers/multfish.c index 6b4e396ba3e..53af3c1efb2 100644 --- a/src/mame/drivers/multfish.c +++ b/src/mame/drivers/multfish.c @@ -378,7 +378,7 @@ static READ8_HANDLER( ray_r ) static CUSTOM_INPUT( multfish_hopper_r ) { - multfish_state *state = field->port->machine().driver_data(); + multfish_state *state = field->machine().driver_data(); if ( state->m_hopper_motor != 0 ) { diff --git a/src/mame/drivers/multigam.c b/src/mame/drivers/multigam.c index a2faa4c2ca5..58f98828791 100644 --- a/src/mame/drivers/multigam.c +++ b/src/mame/drivers/multigam.c @@ -262,7 +262,7 @@ static READ8_HANDLER( multigam_IN1_r ) static CUSTOM_INPUT( multigam_inputs_r ) { - multigam_state *state = field->port->machine().driver_data(); + multigam_state *state = field->machine().driver_data(); /* bit 0: serial input (dsw) bit 1: coin */ return (state->m_in_dsw >> state->m_in_dsw_shift++) & 0x01; diff --git a/src/mame/drivers/mw8080bw.c b/src/mame/drivers/mw8080bw.c index f187a6be66a..3a2fb0caaeb 100644 --- a/src/mame/drivers/mw8080bw.c +++ b/src/mame/drivers/mw8080bw.c @@ -319,8 +319,8 @@ static WRITE8_HANDLER( seawolf_periscope_lamp_w ) static CUSTOM_INPUT( seawolf_erase_input_r ) { - return input_port_read(field->port->machine(), SEAWOLF_ERASE_SW_PORT_TAG) & - input_port_read(field->port->machine(), SEAWOLF_ERASE_DIP_PORT_TAG); + return input_port_read(field->machine(), SEAWOLF_ERASE_SW_PORT_TAG) & + input_port_read(field->machine(), SEAWOLF_ERASE_DIP_PORT_TAG); } @@ -559,7 +559,7 @@ UINT8 tornbase_get_cabinet_type(running_machine &machine) static CUSTOM_INPUT( tornbase_hit_left_input_r ) { - return input_port_read(field->port->machine(), TORNBASE_L_HIT_PORT_TAG); + return input_port_read(field->machine(), TORNBASE_L_HIT_PORT_TAG); } @@ -567,16 +567,16 @@ static CUSTOM_INPUT( tornbase_hit_right_input_r ) { UINT32 ret; - switch (tornbase_get_cabinet_type(field->port->machine())) + switch (tornbase_get_cabinet_type(field->machine())) { case TORNBASE_CAB_TYPE_UPRIGHT_OLD: - ret = input_port_read(field->port->machine(), TORNBASE_L_HIT_PORT_TAG); + ret = input_port_read(field->machine(), TORNBASE_L_HIT_PORT_TAG); break; case TORNBASE_CAB_TYPE_UPRIGHT_NEW: case TORNBASE_CAB_TYPE_COCKTAIL: default: - ret = input_port_read(field->port->machine(), TORNBASE_R_HIT_PORT_TAG); + ret = input_port_read(field->machine(), TORNBASE_R_HIT_PORT_TAG); break; } @@ -588,16 +588,16 @@ static CUSTOM_INPUT( tornbase_pitch_left_input_r ) { UINT32 ret; - switch (tornbase_get_cabinet_type(field->port->machine())) + switch (tornbase_get_cabinet_type(field->machine())) { case TORNBASE_CAB_TYPE_UPRIGHT_OLD: case TORNBASE_CAB_TYPE_UPRIGHT_NEW: - ret = input_port_read(field->port->machine(), TORNBASE_L_PITCH_PORT_TAG); + ret = input_port_read(field->machine(), TORNBASE_L_PITCH_PORT_TAG); break; case TORNBASE_CAB_TYPE_COCKTAIL: default: - ret = input_port_read(field->port->machine(), TORNBASE_R_PITCH_PORT_TAG); + ret = input_port_read(field->machine(), TORNBASE_R_PITCH_PORT_TAG); break; } @@ -607,14 +607,14 @@ static CUSTOM_INPUT( tornbase_pitch_left_input_r ) static CUSTOM_INPUT( tornbase_pitch_right_input_r ) { - return input_port_read(field->port->machine(), TORNBASE_L_PITCH_PORT_TAG); + return input_port_read(field->machine(), TORNBASE_L_PITCH_PORT_TAG); } static CUSTOM_INPUT( tornbase_score_input_r ) { - return input_port_read(field->port->machine(), TORNBASE_SCORE_SW_PORT_TAG) & - input_port_read(field->port->machine(), TORNBASE_SCORE_DIP_PORT_TAG); + return input_port_read(field->machine(), TORNBASE_SCORE_SW_PORT_TAG) & + input_port_read(field->machine(), TORNBASE_SCORE_DIP_PORT_TAG); } @@ -1194,13 +1194,13 @@ static MACHINE_START( desertgu ) static CUSTOM_INPUT( desertgu_gun_input_r ) { - mw8080bw_state *state = field->port->machine().driver_data(); + mw8080bw_state *state = field->machine().driver_data(); UINT32 ret; if (state->m_desertgun_controller_select) - ret = input_port_read(field->port->machine(), DESERTGU_GUN_X_PORT_TAG); + ret = input_port_read(field->machine(), DESERTGU_GUN_X_PORT_TAG); else - ret = input_port_read(field->port->machine(), DESERTGU_GUN_Y_PORT_TAG); + ret = input_port_read(field->machine(), DESERTGU_GUN_Y_PORT_TAG); return ret; } @@ -1208,13 +1208,13 @@ static CUSTOM_INPUT( desertgu_gun_input_r ) static CUSTOM_INPUT( desertgu_dip_sw_0_1_r ) { - mw8080bw_state *state = field->port->machine().driver_data(); + mw8080bw_state *state = field->machine().driver_data(); UINT32 ret; if (state->m_desertgun_controller_select) - ret = input_port_read(field->port->machine(), DESERTGU_DIP_SW_0_1_SET_2_TAG); + ret = input_port_read(field->machine(), DESERTGU_DIP_SW_0_1_SET_2_TAG); else - ret = input_port_read(field->port->machine(), DESERTGU_DIP_SW_0_1_SET_1_TAG); + ret = input_port_read(field->machine(), DESERTGU_DIP_SW_0_1_SET_1_TAG); return ret; } @@ -1327,10 +1327,10 @@ static CUSTOM_INPUT( dplay_pitch_left_input_r ) { UINT32 ret; - if (input_port_read(field->port->machine(), DPLAY_CAB_TYPE_PORT_TAG) == DPLAY_CAB_TYPE_UPRIGHT) - ret = input_port_read(field->port->machine(), DPLAY_L_PITCH_PORT_TAG); + if (input_port_read(field->machine(), DPLAY_CAB_TYPE_PORT_TAG) == DPLAY_CAB_TYPE_UPRIGHT) + ret = input_port_read(field->machine(), DPLAY_L_PITCH_PORT_TAG); else - ret = input_port_read(field->port->machine(), DPLAY_R_PITCH_PORT_TAG); + ret = input_port_read(field->machine(), DPLAY_R_PITCH_PORT_TAG); return ret; } @@ -1338,7 +1338,7 @@ static CUSTOM_INPUT( dplay_pitch_left_input_r ) static CUSTOM_INPUT( dplay_pitch_right_input_r ) { - return input_port_read(field->port->machine(), DPLAY_L_PITCH_PORT_TAG); + return input_port_read(field->machine(), DPLAY_L_PITCH_PORT_TAG); } @@ -1716,16 +1716,16 @@ static MACHINE_START( clowns ) static CUSTOM_INPUT( clowns_controller_r ) { - mw8080bw_state *state = field->port->machine().driver_data(); + mw8080bw_state *state = field->machine().driver_data(); UINT32 ret; if (state->m_clowns_controller_select) { - ret = input_port_read(field->port->machine(), CLOWNS_CONTROLLER_P2_TAG); + ret = input_port_read(field->machine(), CLOWNS_CONTROLLER_P2_TAG); } else { - ret = input_port_read(field->port->machine(), CLOWNS_CONTROLLER_P1_TAG); + ret = input_port_read(field->machine(), CLOWNS_CONTROLLER_P1_TAG); } return ret; @@ -2548,9 +2548,9 @@ static MACHINE_START( invaders ) static CUSTOM_INPUT( invaders_coin_input_r ) { - UINT32 ret = input_port_read(field->port->machine(), INVADERS_COIN_INPUT_PORT_TAG); + UINT32 ret = input_port_read(field->machine(), INVADERS_COIN_INPUT_PORT_TAG); - coin_counter_w(field->port->machine(), 0, !ret); + coin_counter_w(field->machine(), 0, !ret); return ret; } @@ -2563,10 +2563,10 @@ static CUSTOM_INPUT( invaders_sw6_sw7_r ) /* upright PCB : switches visible cocktail PCB: HI */ - if (invaders_is_cabinet_cocktail(field->port->machine())) + if (invaders_is_cabinet_cocktail(field->machine())) ret = 0x03; else - ret = input_port_read(field->port->machine(), INVADERS_SW6_SW7_PORT_TAG); + ret = input_port_read(field->machine(), INVADERS_SW6_SW7_PORT_TAG); return ret; } @@ -2579,10 +2579,10 @@ static CUSTOM_INPUT( invaders_sw5_r ) /* upright PCB : switch visible cocktail PCB: HI */ - if (invaders_is_cabinet_cocktail(field->port->machine())) + if (invaders_is_cabinet_cocktail(field->machine())) ret = 0x01; else - ret = input_port_read(field->port->machine(), INVADERS_SW5_PORT_TAG); + ret = input_port_read(field->machine(), INVADERS_SW5_PORT_TAG); return ret; } @@ -2595,10 +2595,10 @@ static CUSTOM_INPUT( invaders_in0_control_r ) /* upright PCB : P1 controls cocktail PCB: HI */ - if (invaders_is_cabinet_cocktail(field->port->machine())) + if (invaders_is_cabinet_cocktail(field->machine())) ret = 0x07; else - ret = input_port_read(field->port->machine(), INVADERS_P1_CONTROL_PORT_TAG); + ret = input_port_read(field->machine(), INVADERS_P1_CONTROL_PORT_TAG); return ret; } @@ -2606,7 +2606,7 @@ static CUSTOM_INPUT( invaders_in0_control_r ) CUSTOM_INPUT( invaders_in1_control_r ) { - return input_port_read(field->port->machine(), INVADERS_P1_CONTROL_PORT_TAG); + return input_port_read(field->machine(), INVADERS_P1_CONTROL_PORT_TAG); } @@ -2617,10 +2617,10 @@ CUSTOM_INPUT( invaders_in2_control_r ) /* upright PCB : P1 controls cocktail PCB: P2 controls */ - if (invaders_is_cabinet_cocktail(field->port->machine())) - ret = input_port_read(field->port->machine(), INVADERS_P2_CONTROL_PORT_TAG); + if (invaders_is_cabinet_cocktail(field->machine())) + ret = input_port_read(field->machine(), INVADERS_P2_CONTROL_PORT_TAG); else - ret = input_port_read(field->port->machine(), INVADERS_P1_CONTROL_PORT_TAG); + ret = input_port_read(field->machine(), INVADERS_P1_CONTROL_PORT_TAG); return ret; } @@ -2755,9 +2755,9 @@ MACHINE_CONFIG_END static CUSTOM_INPUT( blueshrk_coin_input_r ) { - UINT32 ret = input_port_read(field->port->machine(), BLUESHRK_COIN_INPUT_PORT_TAG); + UINT32 ret = input_port_read(field->machine(), BLUESHRK_COIN_INPUT_PORT_TAG); - coin_counter_w(field->port->machine(), 0, !ret); + coin_counter_w(field->machine(), 0, !ret); return ret; } diff --git a/src/mame/drivers/mystston.c b/src/mame/drivers/mystston.c index e1f8dbf5ce4..9d23a80393d 100644 --- a/src/mame/drivers/mystston.c +++ b/src/mame/drivers/mystston.c @@ -59,7 +59,7 @@ static WRITE8_HANDLER( irq_clear_w ) static INPUT_CHANGED( coin_inserted ) { /* coin insertion causes an NMI */ - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/namcos22.c b/src/mame/drivers/namcos22.c index 6f0c35b12f5..6f513d0a80f 100644 --- a/src/mame/drivers/namcos22.c +++ b/src/mame/drivers/namcos22.c @@ -5290,8 +5290,8 @@ INPUT_PORTS_END /* Time Crisis */ static CUSTOM_INPUT( acedrvr_shift_read ) { - namcos22_state *state = field->port->machine().driver_data(); - int shift = input_port_read(field->port->machine(), "SHIFT"); + namcos22_state *state = field->machine().driver_data(); + int shift = input_port_read(field->machine(), "SHIFT"); if (shift > 0 && shift != state->m_prev_stick_state) { @@ -5471,8 +5471,8 @@ INPUT_PORTS_END /* Victory Lap */ static CUSTOM_INPUT( ridger_gear_read ) { - namcos22_state *state = field->port->machine().driver_data(); - int gear = input_port_read(field->port->machine(), "GEARS"); + namcos22_state *state = field->machine().driver_data(); + int gear = input_port_read(field->machine(), "GEARS"); if (gear > 0 && gear != state->m_prev_stick_state) { diff --git a/src/mame/drivers/naughtyb.c b/src/mame/drivers/naughtyb.c index 8b4b92a15c4..9f1fccd78c3 100644 --- a/src/mame/drivers/naughtyb.c +++ b/src/mame/drivers/naughtyb.c @@ -284,7 +284,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted ) { - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); } static INPUT_PORTS_START( naughtyb ) diff --git a/src/mame/drivers/neogeo.c b/src/mame/drivers/neogeo.c index aca495f0f92..08698bc5b45 100644 --- a/src/mame/drivers/neogeo.c +++ b/src/mame/drivers/neogeo.c @@ -428,7 +428,7 @@ static void select_controller( running_machine &machine, UINT8 data ) static CUSTOM_INPUT( multiplexed_controller_r ) { - neogeo_state *state = field->port->machine().driver_data(); + neogeo_state *state = field->machine().driver_data(); int port = (FPTR)param; static const char *const cntrl[2][2] = @@ -436,13 +436,13 @@ static CUSTOM_INPUT( multiplexed_controller_r ) { "IN0-0", "IN0-1" }, { "IN1-0", "IN1-1" } }; - return input_port_read_safe(field->port->machine(), cntrl[port][state->m_controller_select & 0x01], 0x00); + return input_port_read_safe(field->machine(), cntrl[port][state->m_controller_select & 0x01], 0x00); } static CUSTOM_INPUT( mahjong_controller_r ) { - neogeo_state *state = field->port->machine().driver_data(); + neogeo_state *state = field->machine().driver_data(); UINT32 ret; /* @@ -456,10 +456,10 @@ cpu #0 (PC=00C18C40): unmapped memory word write to 00380000 = 0000 & 00FF { default: case 0x00: ret = 0x0000; break; /* nothing? */ - case 0x09: ret = input_port_read(field->port->machine(), "MAHJONG1"); break; - case 0x12: ret = input_port_read(field->port->machine(), "MAHJONG2"); break; - case 0x1b: ret = input_port_read(field->port->machine(), "MAHJONG3"); break; /* player 1 normal inputs? */ - case 0x24: ret = input_port_read(field->port->machine(), "MAHJONG4"); break; + case 0x09: ret = input_port_read(field->machine(), "MAHJONG1"); break; + case 0x12: ret = input_port_read(field->machine(), "MAHJONG2"); break; + case 0x1b: ret = input_port_read(field->machine(), "MAHJONG3"); break; /* player 1 normal inputs? */ + case 0x24: ret = input_port_read(field->machine(), "MAHJONG4"); break; } return ret; @@ -525,7 +525,7 @@ READ16_HANDLER( neogeo_unmapped_r ) static CUSTOM_INPUT( get_calendar_status ) { - neogeo_state *state = field->port->machine().driver_data(); + neogeo_state *state = field->machine().driver_data(); return (upd4990a_databit_r(state->m_upd4990a, 0) << 1) | upd4990a_testbit_r(state->m_upd4990a, 0); } @@ -567,7 +567,7 @@ static CUSTOM_INPUT( get_memcard_status ) { /* D0 and D1 are memcard presence indicators, D2 indicates memcard write protect status (we are always write enabled) */ - return (memcard_present(field->port->machine()) == -1) ? 0x07 : 0x00; + return (memcard_present(field->machine()) == -1) ? 0x07 : 0x00; } @@ -663,10 +663,10 @@ static WRITE8_HANDLER( audio_result_w ) static CUSTOM_INPUT( get_audio_result ) { - neogeo_state *state = field->port->machine().driver_data(); + neogeo_state *state = field->machine().driver_data(); UINT32 ret = state->m_audio_result; -// if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(field->port->machine().device("maincpu")), ret); +// if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(field->machine().device("maincpu")), ret); return ret; } diff --git a/src/mame/drivers/ng_aes.c b/src/mame/drivers/ng_aes.c index c809ce34863..8164b4680a6 100644 --- a/src/mame/drivers/ng_aes.c +++ b/src/mame/drivers/ng_aes.c @@ -315,7 +315,7 @@ static CUSTOM_INPUT( multiplexed_controller_r ) { "IN0-0", "IN0-1" }, { "IN1-0", "IN1-1" } }; - return input_port_read_safe(field->port->machine(), cntrl[port][controller_select & 0x01], 0x00); + return input_port_read_safe(field->machine(), cntrl[port][controller_select & 0x01], 0x00); } @@ -334,10 +334,10 @@ cpu #0 (PC=00C18C40): unmapped memory word write to 00380000 = 0000 & 00FF { default: case 0x00: ret = 0x0000; break; /* nothing? */ - case 0x09: ret = input_port_read(field->port->machine(), "MAHJONG1"); break; - case 0x12: ret = input_port_read(field->port->machine(), "MAHJONG2"); break; - case 0x1b: ret = input_port_read(field->port->machine(), "MAHJONG3"); break; /* player 1 normal inputs? */ - case 0x24: ret = input_port_read(field->port->machine(), "MAHJONG4"); break; + case 0x09: ret = input_port_read(field->machine(), "MAHJONG1"); break; + case 0x12: ret = input_port_read(field->machine(), "MAHJONG2"); break; + case 0x1b: ret = input_port_read(field->machine(), "MAHJONG3"); break; /* player 1 normal inputs? */ + case 0x24: ret = input_port_read(field->machine(), "MAHJONG4"); break; } return ret; @@ -430,7 +430,7 @@ static void calendar_clock(void) static CUSTOM_INPUT( get_calendar_status ) { - neogeo_state *state = field->port->machine().driver_data(); + neogeo_state *state = field->machine().driver_data(); return (upd4990a_databit_r(state->m_upd4990a, 0) << 1) | upd4990a_testbit_r(state->m_upd4990a, 0); } @@ -487,10 +487,10 @@ static CUSTOM_INPUT( get_memcard_status ) { /* D0 and D1 are memcard presence indicators, D2 indicates memcard write protect status (we are always write enabled) */ - if(strcmp((char*)field->port->machine().system().name,"aes") != 0) + if(strcmp((char*)field->machine().system().name,"aes") != 0) return 0x00; // On the Neo Geo CD, the memory card is internal and therefore always present. else - return (memcard_present(field->port->machine()) == -1) ? 0x07 : 0x00; + return (memcard_present(field->machine()) == -1) ? 0x07 : 0x00; } static READ16_HANDLER( memcard_r ) @@ -604,10 +604,10 @@ static WRITE8_HANDLER( audio_result_w ) static CUSTOM_INPUT( get_audio_result ) { - neogeo_state *state = field->port->machine().driver_data(); + neogeo_state *state = field->machine().driver_data(); UINT32 ret = state->m_audio_result; -// if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(field->port->machine().device("maincpu")), ret); +// if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(field->machine().device("maincpu")), ret); return ret; } diff --git a/src/mame/drivers/niyanpai.c b/src/mame/drivers/niyanpai.c index 4be4bb313aa..ce3d03e0e0f 100644 --- a/src/mame/drivers/niyanpai.c +++ b/src/mame/drivers/niyanpai.c @@ -337,8 +337,8 @@ static READ16_HANDLER( musobana_inputport_0_r ) static CUSTOM_INPUT( musobana_outcoin_flag_r ) { - niyanpai_state *state = field->port->machine().driver_data(); - address_space *space = field->port->machine().device("maincpu")->memory().space(AS_PROGRAM); + niyanpai_state *state = field->machine().driver_data(); + address_space *space = field->machine().device("maincpu")->memory().space(AS_PROGRAM); // tmp68301_parallel_interface[0x05] // bit 0 coin counter // bit 2 motor on diff --git a/src/mame/drivers/nova2001.c b/src/mame/drivers/nova2001.c index de81e572acf..93c6f3d0388 100644 --- a/src/mame/drivers/nova2001.c +++ b/src/mame/drivers/nova2001.c @@ -134,7 +134,7 @@ e000 - e7ff R/W Work RAM static CUSTOM_INPUT( ninjakun_io_A002_ctrl_r ) { - nova2001_state *state = field->port->machine().driver_data(); + nova2001_state *state = field->machine().driver_data(); return state->m_ninjakun_io_a002_ctrl; } diff --git a/src/mame/drivers/pastelg.c b/src/mame/drivers/pastelg.c index e04dd5d6d9c..657f58b172c 100644 --- a/src/mame/drivers/pastelg.c +++ b/src/mame/drivers/pastelg.c @@ -217,7 +217,7 @@ INPUT_PORTS_END // stops the game hanging.. static CUSTOM_INPUT( nb1413m3_hackbusyflag_r ) { - return field->port->machine().rand() & 3; + return field->machine().rand() & 3; } static INPUT_PORTS_START( threeds ) diff --git a/src/mame/drivers/peplus.c b/src/mame/drivers/peplus.c index a660bf5d42c..414e375411d 100644 --- a/src/mame/drivers/peplus.c +++ b/src/mame/drivers/peplus.c @@ -799,7 +799,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( peplus_input_r ) { UINT8 inp_ret = 0x00; - UINT8 inp_read = input_port_read(field->port->machine(), (const char *)param); + UINT8 inp_read = input_port_read(field->machine(), (const char *)param); if (inp_read & 0x01) inp_ret = 0x01; if (inp_read & 0x02) inp_ret = 0x02; diff --git a/src/mame/drivers/pirates.c b/src/mame/drivers/pirates.c index 2895c5dda54..fe006f051ed 100644 --- a/src/mame/drivers/pirates.c +++ b/src/mame/drivers/pirates.c @@ -132,14 +132,14 @@ static CUSTOM_INPUT( prot_r ) // offs_t pc; int bit; -// logerror("%s: IN1_r\n",field->port->machine().describe_context()); +// logerror("%s: IN1_r\n",field->machine().describe_context()); #if 0 /* Pirates protection workaround. It more complicated than this... see code at 602e and 62a6 */ /* For Genix, see 6576 for setting values and 67c2,d3b4 and dbc2 for tests. */ - pc = cpu_get_pc(field->port->machine().device("main")); + pc = cpu_get_pc(field->machine().device("main")); if (pc == 0x6134) { bit = prot & 1; diff --git a/src/mame/drivers/polepos.c b/src/mame/drivers/polepos.c index f51dc57ff95..6be13180a77 100644 --- a/src/mame/drivers/polepos.c +++ b/src/mame/drivers/polepos.c @@ -348,11 +348,11 @@ static WRITE16_HANDLER( polepos_z8002_nvi_enable_w ) } -static CUSTOM_INPUT( high_port_r ) { return input_port_read(field->port->machine(), (const char *)param) >> 4; } -static CUSTOM_INPUT( low_port_r ) { return input_port_read(field->port->machine(), (const char *)param) & 0x0f; } +static CUSTOM_INPUT( high_port_r ) { return input_port_read(field->machine(), (const char *)param) >> 4; } +static CUSTOM_INPUT( low_port_r ) { return input_port_read(field->machine(), (const char *)param) & 0x0f; } static CUSTOM_INPUT( auto_start_r ) { - polepos_state *state = field->port->machine().driver_data(); + polepos_state *state = field->machine().driver_data(); return state->m_auto_start_mask; } diff --git a/src/mame/drivers/policetr.c b/src/mame/drivers/policetr.c index d22f19ec7be..9a1b4859d8b 100644 --- a/src/mame/drivers/policetr.c +++ b/src/mame/drivers/policetr.c @@ -183,7 +183,7 @@ static WRITE32_HANDLER( policetr_bsmt2000_data_w ) static CUSTOM_INPUT( bsmt_status_r ) { - return field->port->machine().device("bsmt")->read_status(); + return field->machine().device("bsmt")->read_status(); } diff --git a/src/mame/drivers/progolf.c b/src/mame/drivers/progolf.c index 5c93764b4e5..b5c0fa93e38 100644 --- a/src/mame/drivers/progolf.c +++ b/src/mame/drivers/progolf.c @@ -268,7 +268,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted ) { - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } static INPUT_PORTS_START( progolf ) diff --git a/src/mame/drivers/psikyo.c b/src/mame/drivers/psikyo.c index 0160cc1c44c..389b6a7612d 100644 --- a/src/mame/drivers/psikyo.c +++ b/src/mame/drivers/psikyo.c @@ -79,7 +79,7 @@ This was pointed out by Bart Puype static CUSTOM_INPUT( z80_nmi_r ) { - psikyo_state *state = field->port->machine().driver_data(); + psikyo_state *state = field->machine().driver_data(); int ret = 0x00; if (state->m_z80_nmi) @@ -88,7 +88,7 @@ static CUSTOM_INPUT( z80_nmi_r ) /* main CPU might be waiting for sound CPU to finish NMI, so set a timer to give sound CPU a chance to run */ - field->port->machine().scheduler().synchronize(); + field->machine().scheduler().synchronize(); // logerror("%s - Read coin port during Z80 NMI\n", machine.describe_context()); } @@ -97,7 +97,7 @@ static CUSTOM_INPUT( z80_nmi_r ) static CUSTOM_INPUT( mcu_status_r ) { - psikyo_state *state = field->port->machine().driver_data(); + psikyo_state *state = field->machine().driver_data(); int ret = 0x00; /* Don't know exactly what this bit is, but s1945 and tengai diff --git a/src/mame/drivers/psikyo4.c b/src/mame/drivers/psikyo4.c index 9de37eadadb..439dfaf5214 100644 --- a/src/mame/drivers/psikyo4.c +++ b/src/mame/drivers/psikyo4.c @@ -198,20 +198,20 @@ static INTERRUPT_GEN(psikyosh_interrupt) static CUSTOM_INPUT( system_port_r ) { - return input_port_read(field->port->machine(), "SYSTEM"); + return input_port_read(field->machine(), "SYSTEM"); } static CUSTOM_INPUT( mahjong_ctrl_r ) /* used by hotgmck/hgkairak */ { - psikyo4_state *state = field->port->machine().driver_data(); + psikyo4_state *state = field->machine().driver_data(); int player = (FPTR)param; int sel = (state->m_io_select[0] & 0x0000ff00) >> 8; int ret = 0xff; - if (sel & 1) ret &= input_port_read(field->port->machine(), player ? "KEY4" : "KEY0" ); - if (sel & 2) ret &= input_port_read(field->port->machine(), player ? "KEY5" : "KEY1" ); - if (sel & 4) ret &= input_port_read(field->port->machine(), player ? "KEY6" : "KEY2" ); - if (sel & 8) ret &= input_port_read(field->port->machine(), player ? "KEY7" : "KEY3" ); + if (sel & 1) ret &= input_port_read(field->machine(), player ? "KEY4" : "KEY0" ); + if (sel & 2) ret &= input_port_read(field->machine(), player ? "KEY5" : "KEY1" ); + if (sel & 4) ret &= input_port_read(field->machine(), player ? "KEY6" : "KEY2" ); + if (sel & 8) ret &= input_port_read(field->machine(), player ? "KEY7" : "KEY3" ); return ret; } diff --git a/src/mame/drivers/punchout.c b/src/mame/drivers/punchout.c index 8ba6a39e0ba..9c78967d0a2 100644 --- a/src/mame/drivers/punchout.c +++ b/src/mame/drivers/punchout.c @@ -122,7 +122,7 @@ DIP locations verified for: static CUSTOM_INPUT( punchout_vlm5030_busy_r ) { /* bit 4 of DSW1 is busy pin level */ - return (vlm5030_bsy(field->port->machine().device("vlm"))) ? 0x00 : 0x01; + return (vlm5030_bsy(field->machine().device("vlm"))) ? 0x00 : 0x01; } static WRITE8_DEVICE_HANDLER( punchout_speech_reset_w ) diff --git a/src/mame/drivers/pzletime.c b/src/mame/drivers/pzletime.c index 074f7c9c161..da824c7fc21 100644 --- a/src/mame/drivers/pzletime.c +++ b/src/mame/drivers/pzletime.c @@ -202,8 +202,8 @@ static WRITE16_DEVICE_HANDLER( oki_bank_w ) static CUSTOM_INPUT( ticket_status_r ) { - pzletime_state *state = field->port->machine().driver_data(); - return (state->m_ticket && !(field->port->machine().primary_screen->frame_number() % 128)); + pzletime_state *state = field->machine().driver_data(); + return (state->m_ticket && !(field->machine().primary_screen->frame_number() % 128)); } static ADDRESS_MAP_START( pzletime_map, AS_PROGRAM, 16 ) diff --git a/src/mame/drivers/qdrmfgp.c b/src/mame/drivers/qdrmfgp.c index 98a8195bb65..a53dc30e352 100644 --- a/src/mame/drivers/qdrmfgp.c +++ b/src/mame/drivers/qdrmfgp.c @@ -37,10 +37,10 @@ GP1 HDD data contents: static CUSTOM_INPUT( inputs_r ) { - qdrmfgp_state *state = field->port->machine().driver_data(); + qdrmfgp_state *state = field->machine().driver_data(); const char *tag1 = (const char *)param; const char *tag2 = tag1 + strlen(tag1) + 1; - return input_port_read(field->port->machine(), (state->m_control & 0x0080) ? tag1 : tag2); + return input_port_read(field->machine(), (state->m_control & 0x0080) ? tag1 : tag2); } static CUSTOM_INPUT( battery_sensor_r ) diff --git a/src/mame/drivers/r2dtank.c b/src/mame/drivers/r2dtank.c index 737cfbce2ed..7779afd08af 100644 --- a/src/mame/drivers/r2dtank.c +++ b/src/mame/drivers/r2dtank.c @@ -228,7 +228,7 @@ static WRITE8_DEVICE_HANDLER( ttl74123_output_changed ) static CUSTOM_INPUT( get_ttl74123_output ) { - r2dtank_state *state = field->port->machine().driver_data(); + r2dtank_state *state = field->machine().driver_data(); return state->m_ttl74123_output; } diff --git a/src/mame/drivers/redclash.c b/src/mame/drivers/redclash.c index de19cf7052b..299b5918513 100644 --- a/src/mame/drivers/redclash.c +++ b/src/mame/drivers/redclash.c @@ -78,7 +78,7 @@ ADDRESS_MAP_END */ static INPUT_CHANGED( left_coin_inserted ) { - ladybug_state *state = field->port->machine().driver_data(); + ladybug_state *state = field->machine().driver_data(); if(newval) device_set_input_line(state->m_maincpu, 0, ASSERT_LINE); @@ -86,7 +86,7 @@ static INPUT_CHANGED( left_coin_inserted ) static INPUT_CHANGED( right_coin_inserted ) { - ladybug_state *state = field->port->machine().driver_data(); + ladybug_state *state = field->machine().driver_data(); if(newval) device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, PULSE_LINE); diff --git a/src/mame/drivers/renegade.c b/src/mame/drivers/renegade.c index caa782261ee..a530fc74527 100644 --- a/src/mame/drivers/renegade.c +++ b/src/mame/drivers/renegade.c @@ -608,7 +608,7 @@ static READ8_HANDLER( mcu_r ) static CUSTOM_INPUT( mcu_status_r ) { - renegade_state *state = field->port->machine().driver_data(); + renegade_state *state = field->machine().driver_data(); UINT8 res = 0; if (state->m_mcu_sim == TRUE) diff --git a/src/mame/drivers/rgum.c b/src/mame/drivers/rgum.c index 85797b26de8..55aae67ccbb 100644 --- a/src/mame/drivers/rgum.c +++ b/src/mame/drivers/rgum.c @@ -81,7 +81,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( rgum_heartbeat_r ) { - rgum_state *state = field->port->machine().driver_data(); + rgum_state *state = field->machine().driver_data(); state->m_hbeat ^= 1; diff --git a/src/mame/drivers/rpunch.c b/src/mame/drivers/rpunch.c index 5cd60db4876..b35464636d6 100644 --- a/src/mame/drivers/rpunch.c +++ b/src/mame/drivers/rpunch.c @@ -146,7 +146,7 @@ static MACHINE_RESET( rpunch ) static CUSTOM_INPUT( hi_bits_r ) { - return input_port_read(field->port->machine(), "SERVICE"); + return input_port_read(field->machine(), "SERVICE"); } diff --git a/src/mame/drivers/scobra.c b/src/mame/drivers/scobra.c index 6f8b9355359..d568a971bcd 100644 --- a/src/mame/drivers/scobra.c +++ b/src/mame/drivers/scobra.c @@ -264,7 +264,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( stratgyx_coinage_r ) { int bit_mask = (FPTR)param; - return (input_port_read(field->port->machine(), "IN4") & bit_mask) ? 0x01 : 0x00; + return (input_port_read(field->machine(), "IN4") & bit_mask) ? 0x01 : 0x00; } diff --git a/src/mame/drivers/scramble.c b/src/mame/drivers/scramble.c index edcf9bbdb2e..c7fee5ec03b 100644 --- a/src/mame/drivers/scramble.c +++ b/src/mame/drivers/scramble.c @@ -475,7 +475,7 @@ INPUT_PORTS_END static CUSTOM_INPUT( ckongs_coinage_r ) { int bit_mask = (FPTR)param; - return (input_port_read(field->port->machine(), "FAKE") & bit_mask) ? 0x01 : 0x00; + return (input_port_read(field->machine(), "FAKE") & bit_mask) ? 0x01 : 0x00; } diff --git a/src/mame/drivers/segag80r.c b/src/mame/drivers/segag80r.c index cd76fa5e32b..506dc484330 100644 --- a/src/mame/drivers/segag80r.c +++ b/src/mame/drivers/segag80r.c @@ -149,7 +149,7 @@ static INPUT_CHANGED( service_switch ) { /* pressing the service switch sends an NMI */ if (newval) - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); } diff --git a/src/mame/drivers/segag80v.c b/src/mame/drivers/segag80v.c index 61ad31161c0..1d04b049522 100644 --- a/src/mame/drivers/segag80v.c +++ b/src/mame/drivers/segag80v.c @@ -162,7 +162,7 @@ static INPUT_CHANGED( service_switch ) { /* pressing the service switch sends an NMI */ if (newval) - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); } @@ -293,7 +293,7 @@ static READ8_HANDLER( spinner_input_r ) static CUSTOM_INPUT( elim4_joint_coin_r ) { - return (input_port_read(field->port->machine(), "COINS") & 0xf) != 0xf; + return (input_port_read(field->machine(), "COINS") & 0xf) != 0xf; } diff --git a/src/mame/drivers/seibuspi.c b/src/mame/drivers/seibuspi.c index 3cd28d6f65e..166df4fc2f0 100644 --- a/src/mame/drivers/seibuspi.c +++ b/src/mame/drivers/seibuspi.c @@ -936,21 +936,21 @@ static READ32_HANDLER( spi_controls2_r ) static CUSTOM_INPUT( ejsakura_keyboard_r ) { - seibuspi_state *state = field->port->machine().driver_data(); + seibuspi_state *state = field->machine().driver_data(); switch(state->m_ejsakura_input_port) { case 0x01: - return input_port_read(field->port->machine(), "INPUT01"); + return input_port_read(field->machine(), "INPUT01"); case 0x02: - return input_port_read(field->port->machine(), "INPUT02"); + return input_port_read(field->machine(), "INPUT02"); case 0x04: - return input_port_read(field->port->machine(), "INPUT04"); + return input_port_read(field->machine(), "INPUT04"); case 0x08: - return input_port_read(field->port->machine(), "INPUT08"); + return input_port_read(field->machine(), "INPUT08"); case 0x10: - return input_port_read(field->port->machine(), "INPUT10"); + return input_port_read(field->machine(), "INPUT10"); default: - return input_port_read(field->port->machine(), "SYSTEM"); + return input_port_read(field->machine(), "SYSTEM"); } return 0xffffffff; } @@ -1295,7 +1295,7 @@ INPUT_PORTS_END static CUSTOM_INPUT( ejanhs_encode ) { static const UINT8 encoding[] = { 0x02, 0x10, 0x03, 0x18, 0x04, 0x20, 0x05, 0x28, 0x06, 0x30, 0x07 }; - input_port_value state = input_port_read(field->port->machine(), (const char *)param); + input_port_value state = input_port_read(field->machine(), (const char *)param); int bit; for (bit = 0; bit < ARRAY_LENGTH(encoding); bit++) diff --git a/src/mame/drivers/sfbonus.c b/src/mame/drivers/sfbonus.c index 7bde1f23e85..60701d6d8e5 100644 --- a/src/mame/drivers/sfbonus.c +++ b/src/mame/drivers/sfbonus.c @@ -927,7 +927,7 @@ static SCREEN_UPDATE(sfbonus) int globalyscroll = (state->m_vregs[2] | state->m_vregs[3]<<8); int globalxscroll = (state->m_vregs[0] | state->m_vregs[1]<<8); UINT8* front_rowscroll = &state->m_videoram[0x200]; - const input_port_token *ipt; + ioport_constructor ipt; int i; // align to 0 diff --git a/src/mame/drivers/sg1000.c b/src/mame/drivers/sg1000.c index f5cb55802a0..3255e12b33b 100644 --- a/src/mame/drivers/sg1000.c +++ b/src/mame/drivers/sg1000.c @@ -242,7 +242,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( trigger_nmi ) { - cputag_set_input_line(field->port->machine(), Z80_TAG, INPUT_LINE_NMI, (input_port_read(field->port->machine(), "NMI") ? CLEAR_LINE : ASSERT_LINE)); + cputag_set_input_line(field->machine(), Z80_TAG, INPUT_LINE_NMI, (input_port_read(field->machine(), "NMI") ? CLEAR_LINE : ASSERT_LINE)); } /*------------------------------------------------- diff --git a/src/mame/drivers/shootout.c b/src/mame/drivers/shootout.c index f440fa9e320..2637e8e0e37 100644 --- a/src/mame/drivers/shootout.c +++ b/src/mame/drivers/shootout.c @@ -107,7 +107,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted ) { - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); } static INPUT_PORTS_START( shootout ) diff --git a/src/mame/drivers/skyfox.c b/src/mame/drivers/skyfox.c index 78d6ff6ed56..e3af091670c 100644 --- a/src/mame/drivers/skyfox.c +++ b/src/mame/drivers/skyfox.c @@ -84,7 +84,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted ) { - skyfox_state *state = field->port->machine().driver_data(); + skyfox_state *state = field->machine().driver_data(); device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/snes.c b/src/mame/drivers/snes.c index dd6498bd539..3a4522be326 100644 --- a/src/mame/drivers/snes.c +++ b/src/mame/drivers/snes.c @@ -113,7 +113,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( snes_mouse_speed_input ) { - snes_state *state = field->port->machine().driver_data(); + snes_state *state = field->machine().driver_data(); int port = (FPTR)param; if (snes_ram[OLDJOY1] & 0x1) @@ -128,7 +128,7 @@ static CUSTOM_INPUT( snes_mouse_speed_input ) static CUSTOM_INPUT( snes_superscope_offscreen_input ) { - snes_state *state = field->port->machine().driver_data(); + snes_state *state = field->machine().driver_data(); int port = (FPTR)param; static const char *const portnames[2][3] = { @@ -136,8 +136,8 @@ static CUSTOM_INPUT( snes_superscope_offscreen_input ) { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" }, }; - INT16 x = input_port_read(field->port->machine(), portnames[port][1]); - INT16 y = input_port_read(field->port->machine(), portnames[port][2]); + INT16 x = input_port_read(field->machine(), portnames[port][1]); + INT16 y = input_port_read(field->machine(), portnames[port][2]); /* these are the theoretical boundaries, but we currently are always onscreen... */ if (x < 0 || x >= SNES_SCR_WIDTH || y < 0 || y >= snes_ppu.beam.last_visible_line) diff --git a/src/mame/drivers/snk.c b/src/mame/drivers/snk.c index 63a638cee58..5f32263ae3d 100644 --- a/src/mame/drivers/snk.c +++ b/src/mame/drivers/snk.c @@ -333,7 +333,7 @@ static READ8_HANDLER( marvins_soundlatch_r ) static CUSTOM_INPUT( marvins_sound_busy ) { - snk_state *state = field->port->machine().driver_data(); + snk_state *state = field->machine().driver_data(); return state->m_marvins_sound_busy_flag; } @@ -500,7 +500,7 @@ static WRITE8_HANDLER( snk_soundlatch_w ) static CUSTOM_INPUT( snk_sound_busy ) { - snk_state *state = field->port->machine().driver_data(); + snk_state *state = field->machine().driver_data(); return (state->m_sound_status & 4) ? 1 : 0; } @@ -752,10 +752,10 @@ hand, always returning 0xf inbetween valid values confuses the game. static CUSTOM_INPUT( gwar_rotary ) { - snk_state *state = field->port->machine().driver_data(); + snk_state *state = field->machine().driver_data(); static const char *const ports[] = { "P1ROT", "P2ROT" }; int which = (int)(FPTR)param; - int value = input_port_read(field->port->machine(), ports[which]); + int value = input_port_read(field->machine(), ports[which]); if ((state->m_last_value[which] == 0x5 && value == 0x6) || (state->m_last_value[which] == 0x6 && value == 0x5)) { @@ -770,9 +770,9 @@ static CUSTOM_INPUT( gwar_rotary ) static CUSTOM_INPUT( gwarb_rotary ) { - if (input_port_read(field->port->machine(), "JOYSTICK_MODE") == 1) + if (input_port_read(field->machine(), "JOYSTICK_MODE") == 1) { - return gwar_rotary(field, param); + return gwar_rotary(device, field, param); } else { @@ -819,16 +819,16 @@ static WRITE8_HANDLER( countryc_trackball_w ) static CUSTOM_INPUT( countryc_trackball_x ) { - snk_state *state = field->port->machine().driver_data(); + snk_state *state = field->machine().driver_data(); - return input_port_read(field->port->machine(), state->m_countryc_trackball ? "TRACKBALLX2" : "TRACKBALLX1"); + return input_port_read(field->machine(), state->m_countryc_trackball ? "TRACKBALLX2" : "TRACKBALLX1"); } static CUSTOM_INPUT( countryc_trackball_y ) { - snk_state *state = field->port->machine().driver_data(); + snk_state *state = field->machine().driver_data(); - return input_port_read(field->port->machine(), state->m_countryc_trackball ? "TRACKBALLY2" : "TRACKBALLY1"); + return input_port_read(field->machine(), state->m_countryc_trackball ? "TRACKBALLY2" : "TRACKBALLY1"); } @@ -841,14 +841,14 @@ static CUSTOM_INPUT( snk_bonus_r ) switch (bit_mask) { case 0x01: /* older games : "Occurence" Dip Switch (DSW2:1) */ - return ((input_port_read(field->port->machine(), "BONUS") & bit_mask) >> 0); + return ((input_port_read(field->machine(), "BONUS") & bit_mask) >> 0); case 0xc0: /* older games : "Bonus Life" Dip Switches (DSW1:7,8) */ - return ((input_port_read(field->port->machine(), "BONUS") & bit_mask) >> 6); + return ((input_port_read(field->machine(), "BONUS") & bit_mask) >> 6); case 0x04: /* later games : "Occurence" Dip Switch (DSW1:3) */ - return ((input_port_read(field->port->machine(), "BONUS") & bit_mask) >> 2); + return ((input_port_read(field->machine(), "BONUS") & bit_mask) >> 2); case 0x30: /* later games : "Bonus Life" Dip Switches (DSW2:5,6) */ - return ((input_port_read(field->port->machine(), "BONUS") & bit_mask) >> 4); + return ((input_port_read(field->machine(), "BONUS") & bit_mask) >> 4); default: logerror("snk_bonus_r : invalid %02X bit_mask\n",bit_mask); diff --git a/src/mame/drivers/snk6502.c b/src/mame/drivers/snk6502.c index 8e3c383014c..aae0ed82eea 100644 --- a/src/mame/drivers/snk6502.c +++ b/src/mame/drivers/snk6502.c @@ -306,12 +306,12 @@ static void sasuke_start_counter(running_machine &machine) static CUSTOM_INPUT( snk6502_music0_r ) { - return (snk6502_music0_playing(field->port->machine()) ? 0x01 : 0x00); + return (snk6502_music0_playing(field->machine()) ? 0x01 : 0x00); } static CUSTOM_INPUT( sasuke_count_r ) { - snk6502_state *state = field->port->machine().driver_data(); + snk6502_state *state = field->machine().driver_data(); return (state->m_sasuke_counter >> 4); } diff --git a/src/mame/drivers/spoker.c b/src/mame/drivers/spoker.c index b12a671ba81..9b2a208bbb1 100644 --- a/src/mame/drivers/spoker.c +++ b/src/mame/drivers/spoker.c @@ -105,7 +105,7 @@ static SCREEN_UPDATE(spoker) static CUSTOM_INPUT( hopper_r ) { - running_machine &machine = field->port->machine(); + running_machine &machine = field->machine(); spoker_state *state = machine.driver_data(); if (state->m_hopper) return !(machine.primary_screen->frame_number()%10); diff --git a/src/mame/drivers/sprint4.c b/src/mame/drivers/sprint4.c index 3a4a3cde813..8c073f35f4b 100644 --- a/src/mame/drivers/sprint4.c +++ b/src/mame/drivers/sprint4.c @@ -19,7 +19,7 @@ Atari Sprint 4 driver static CUSTOM_INPUT( get_lever ) { - sprint4_state *state = field->port->machine().driver_data(); + sprint4_state *state = field->machine().driver_data(); int n = (FPTR) param; return 4 * state->m_gear[n] > state->m_da_latch; @@ -28,7 +28,7 @@ static CUSTOM_INPUT( get_lever ) static CUSTOM_INPUT( get_wheel ) { - sprint4_state *state = field->port->machine().driver_data(); + sprint4_state *state = field->machine().driver_data(); int n = (FPTR) param; return 8 * state->m_steer_FF1[n] + 8 * state->m_steer_FF2[n] > state->m_da_latch; @@ -37,7 +37,7 @@ static CUSTOM_INPUT( get_wheel ) static CUSTOM_INPUT( get_collision ) { - sprint4_state *state = field->port->machine().driver_data(); + sprint4_state *state = field->machine().driver_data(); int n = (FPTR) param; return state->m_collision[n]; diff --git a/src/mame/drivers/ssingles.c b/src/mame/drivers/ssingles.c index f932cfa6acf..9af828de095 100644 --- a/src/mame/drivers/ssingles.c +++ b/src/mame/drivers/ssingles.c @@ -288,7 +288,7 @@ static WRITE8_HANDLER(c001_w) static CUSTOM_INPUT(controls_r) { int data = 7; - switch(input_port_read(field->port->machine(), "EXTRA")) //multiplexed + switch(input_port_read(field->machine(), "EXTRA")) //multiplexed { case 0x01: data = 1; break; case 0x02: data = 2; break; diff --git a/src/mame/drivers/ssozumo.c b/src/mame/drivers/ssozumo.c index 749393d5c0a..00ed3119c6f 100644 --- a/src/mame/drivers/ssozumo.c +++ b/src/mame/drivers/ssozumo.c @@ -51,7 +51,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted ) { - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } static INPUT_PORTS_START( ssozumo ) diff --git a/src/mame/drivers/stactics.c b/src/mame/drivers/stactics.c index 4d0fe3964b9..a15b91167b5 100644 --- a/src/mame/drivers/stactics.c +++ b/src/mame/drivers/stactics.c @@ -55,7 +55,7 @@ Verify Color PROM resistor values (Last 8 colors) static CUSTOM_INPUT( get_motor_not_ready ) { - stactics_state *state = field->port->machine().driver_data(); + stactics_state *state = field->machine().driver_data(); /* if the motor is self-centering, but not centered yet */ return ((*state->m_motor_on & 0x01) == 0) && @@ -130,7 +130,7 @@ static void move_motor(running_machine &machine, stactics_state *state) static CUSTOM_INPUT( get_rng ) { /* this is a 555 timer, but cannot read one of the resistor values */ - return field->port->machine().rand() & 0x07; + return field->machine().rand() & 0x07; } diff --git a/src/mame/drivers/starshp1.c b/src/mame/drivers/starshp1.c index 56ac222bdeb..a588fa13065 100644 --- a/src/mame/drivers/starshp1.c +++ b/src/mame/drivers/starshp1.c @@ -67,22 +67,22 @@ static WRITE8_HANDLER( starshp1_collision_reset_w ) static CUSTOM_INPUT( starshp1_analog_r ) { - starshp1_state *state = field->port->machine().driver_data(); + starshp1_state *state = field->machine().driver_data(); int val = 0; switch (state->m_analog_in_select) { case 0: - val = input_port_read(field->port->machine(), "STICKY"); + val = input_port_read(field->machine(), "STICKY"); break; case 1: - val = input_port_read(field->port->machine(), "STICKX"); + val = input_port_read(field->machine(), "STICKX"); break; case 2: val = 0x20; /* DAC feedback, not used */ break; case 3: - val = input_port_read(field->port->machine(), "PLAYTIME"); + val = input_port_read(field->machine(), "PLAYTIME"); break; } @@ -92,7 +92,7 @@ static CUSTOM_INPUT( starshp1_analog_r ) static CUSTOM_INPUT( collision_latch_r ) { - starshp1_state *state = field->port->machine().driver_data(); + starshp1_state *state = field->machine().driver_data(); return state->m_collision_latch & 0x0f; } diff --git a/src/mame/drivers/statriv2.c b/src/mame/drivers/statriv2.c index 9f8a62d42da..27e289634b1 100644 --- a/src/mame/drivers/statriv2.c +++ b/src/mame/drivers/statriv2.c @@ -244,7 +244,7 @@ static READ8_HANDLER( question_data_r ) static CUSTOM_INPUT( latched_coin_r ) { - statriv2_state *state = field->port->machine().driver_data(); + statriv2_state *state = field->machine().driver_data(); return state->m_latched_coin; } diff --git a/src/mame/drivers/suprnova.c b/src/mame/drivers/suprnova.c index 6b13c6fb163..bf5e484074b 100644 --- a/src/mame/drivers/suprnova.c +++ b/src/mame/drivers/suprnova.c @@ -438,7 +438,7 @@ static INTERRUPT_GEN(skns_interrupt) static CUSTOM_INPUT( paddle_r ) { const char *tag = (const char *)param; - return input_port_read(field->port->machine(), tag); + return input_port_read(field->machine(), tag); } static INPUT_PORTS_START( skns ) /* 3 buttons, 2 players */ diff --git a/src/mame/drivers/suprridr.c b/src/mame/drivers/suprridr.c index ab8d9d7bc20..824e9c74cfe 100644 --- a/src/mame/drivers/suprridr.c +++ b/src/mame/drivers/suprridr.c @@ -228,10 +228,10 @@ static CUSTOM_INPUT( suprridr_control_r ) UINT32 ret; /* screen flip multiplexes controls */ - if (suprridr_is_screen_flipped(field->port->machine())) - ret = input_port_read(field->port->machine(), SUPRRIDR_P2_CONTROL_PORT_TAG); + if (suprridr_is_screen_flipped(field->machine())) + ret = input_port_read(field->machine(), SUPRRIDR_P2_CONTROL_PORT_TAG); else - ret = input_port_read(field->port->machine(), SUPRRIDR_P1_CONTROL_PORT_TAG); + ret = input_port_read(field->machine(), SUPRRIDR_P1_CONTROL_PORT_TAG); return ret; } diff --git a/src/mame/drivers/system1.c b/src/mame/drivers/system1.c index 264aed7e1ba..1bdbbd4d069 100644 --- a/src/mame/drivers/system1.c +++ b/src/mame/drivers/system1.c @@ -428,15 +428,15 @@ static WRITE8_HANDLER( videomode_w ) static CUSTOM_INPUT( dakkochn_mux_data_r ) { - system1_state *state = field->port->machine().driver_data(); + system1_state *state = field->machine().driver_data(); static const char *const ports[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6" }; - return input_port_read(field->port->machine(), ports[state->m_dakkochn_mux_data]); + return input_port_read(field->machine(), ports[state->m_dakkochn_mux_data]); } static CUSTOM_INPUT( dakkochn_mux_status_r ) { - system1_state *state = field->port->machine().driver_data(); + system1_state *state = field->machine().driver_data(); /* reads from here indicate which mux port is selected */ return 1 << (state->m_dakkochn_mux_data); } diff --git a/src/mame/drivers/taito_f3.c b/src/mame/drivers/taito_f3.c index b7312c93078..830c05d285a 100644 --- a/src/mame/drivers/taito_f3.c +++ b/src/mame/drivers/taito_f3.c @@ -51,14 +51,14 @@ static CUSTOM_INPUT( f3_analog_r ) const char *tag = (const char *)param; UINT32 ipt = 0; - ipt = ((input_port_read(field->port->machine(), tag) & 0xf)<<12) | ((input_port_read(field->port->machine(), tag) & 0xff0)>>4); + ipt = ((input_port_read(field->machine(), tag) & 0xf)<<12) | ((input_port_read(field->machine(), tag) & 0xff0)>>4); return ipt; } static CUSTOM_INPUT( f3_coin_r ) { - taito_f3_state *state = field->port->machine().driver_data(); + taito_f3_state *state = field->machine().driver_data(); int num = (FPTR)param; return state->m_coin_word[num]; } diff --git a/src/mame/drivers/taitosj.c b/src/mame/drivers/taitosj.c index b1752e3120d..ba5af69e391 100644 --- a/src/mame/drivers/taitosj.c +++ b/src/mame/drivers/taitosj.c @@ -193,7 +193,7 @@ static WRITE8_DEVICE_HANDLER( input_port_4_f0_w ) static CUSTOM_INPUT( input_port_4_f0_r ) { - taitosj_state *state = field->port->machine().driver_data(); + taitosj_state *state = field->machine().driver_data(); return state->m_input_port_4_f0; } @@ -282,7 +282,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( kikstart_gear_r ) { - taitosj_state *state = field->port->machine().driver_data(); + taitosj_state *state = field->machine().driver_data(); const char *port_tag; int player = (int)(FPTR)param; @@ -293,9 +293,9 @@ static CUSTOM_INPUT( kikstart_gear_r ) port_tag = "GEARP2"; /* gear MUST be 1, 2 or 3 */ - if (input_port_read(field->port->machine(), port_tag) & 0x01) state->m_kikstart_gears[player] = 0x02; - if (input_port_read(field->port->machine(), port_tag) & 0x02) state->m_kikstart_gears[player] = 0x03; - if (input_port_read(field->port->machine(), port_tag) & 0x04) state->m_kikstart_gears[player] = 0x01; + if (input_port_read(field->machine(), port_tag) & 0x01) state->m_kikstart_gears[player] = 0x02; + if (input_port_read(field->machine(), port_tag) & 0x02) state->m_kikstart_gears[player] = 0x03; + if (input_port_read(field->machine(), port_tag) & 0x04) state->m_kikstart_gears[player] = 0x01; return state->m_kikstart_gears[player]; } diff --git a/src/mame/drivers/tankbatt.c b/src/mame/drivers/tankbatt.c index 8f90ab554c3..89ebfb8ce89 100644 --- a/src/mame/drivers/tankbatt.c +++ b/src/mame/drivers/tankbatt.c @@ -194,7 +194,7 @@ static INTERRUPT_GEN( tankbatt_interrupt ) static INPUT_CHANGED( coin_inserted ) { - cputag_set_input_line(field->port->machine(), "maincpu", 0, ASSERT_LINE); + cputag_set_input_line(field->machine(), "maincpu", 0, ASSERT_LINE); } static INPUT_PORTS_START( tankbatt ) diff --git a/src/mame/drivers/tempest.c b/src/mame/drivers/tempest.c index c4b77801847..cd5b6248b2f 100644 --- a/src/mame/drivers/tempest.c +++ b/src/mame/drivers/tempest.c @@ -332,15 +332,15 @@ static WRITE8_HANDLER( wdclr_w ) static CUSTOM_INPUT( tempest_knob_r ) { - tempest_state *state = field->port->machine().driver_data(); - return input_port_read(field->port->machine(), (state->m_player_select == 0) ? + tempest_state *state = field->machine().driver_data(); + return input_port_read(field->machine(), (state->m_player_select == 0) ? TEMPEST_KNOB_P1_TAG : TEMPEST_KNOB_P2_TAG); } static CUSTOM_INPUT( tempest_buttons_r ) { - tempest_state *state = field->port->machine().driver_data(); - return input_port_read(field->port->machine(), (state->m_player_select == 0) ? + tempest_state *state = field->machine().driver_data(); + return input_port_read(field->machine(), (state->m_player_select == 0) ? TEMPEST_BUTTONS_P1_TAG : TEMPEST_BUTTONS_P2_TAG); } @@ -348,7 +348,7 @@ static CUSTOM_INPUT( tempest_buttons_r ) static CUSTOM_INPUT( clock_r ) { /* Emulate the 3kHz source on bit 7 (divide 1.5MHz by 512) */ - return (field->port->machine().device("maincpu")->total_cycles() & 0x100) ? 1 : 0; + return (field->machine().device("maincpu")->total_cycles() & 0x100) ? 1 : 0; } diff --git a/src/mame/drivers/tetrisp2.c b/src/mame/drivers/tetrisp2.c index f68d8842cfe..0390f1a8174 100644 --- a/src/mame/drivers/tetrisp2.c +++ b/src/mame/drivers/tetrisp2.c @@ -267,7 +267,7 @@ static WRITE16_HANDLER( rocknms_main2sub_w ) static CUSTOM_INPUT( rocknms_main2sub_status_r ) { - tetrisp2_state *state = field->port->machine().driver_data(); + tetrisp2_state *state = field->machine().driver_data(); return state->m_rocknms_sub2main & 0x0003; } diff --git a/src/mame/drivers/thayers.c b/src/mame/drivers/thayers.c index 1f6d8232211..67a65c0b213 100644 --- a/src/mame/drivers/thayers.c +++ b/src/mame/drivers/thayers.c @@ -614,7 +614,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( laserdisc_enter_r ) { - thayers_state *state = field->port->machine().driver_data(); + thayers_state *state = field->machine().driver_data(); switch (laserdisc_get_type(state->m_laserdisc)) { case LASERDISC_TYPE_PIONEER_PR7820: @@ -629,7 +629,7 @@ static CUSTOM_INPUT( laserdisc_enter_r ) static CUSTOM_INPUT( laserdisc_ready_r ) { - thayers_state *state = field->port->machine().driver_data(); + thayers_state *state = field->machine().driver_data(); switch (laserdisc_get_type(state->m_laserdisc)) { case LASERDISC_TYPE_PIONEER_PR7820: diff --git a/src/mame/drivers/toaplan1.c b/src/mame/drivers/toaplan1.c index 88d5d1b54ec..d5e376305a6 100644 --- a/src/mame/drivers/toaplan1.c +++ b/src/mame/drivers/toaplan1.c @@ -674,6 +674,7 @@ static INPUT_PORTS_START( toaplan1_2b ) PORT_BIT( 0xfffe, IP_ACTIVE_HIGH, IPT_UNKNOWN ) INPUT_PORTS_END +#ifdef UNREFERENCED_CODE static INPUT_PORTS_START( toaplan1_3b ) PORT_INCLUDE( toaplan1_2b ) @@ -683,7 +684,7 @@ static INPUT_PORTS_START( toaplan1_3b ) PORT_MODIFY("P2") TOAPLAN_JOY_UDLR_3_BUTTONS( 2 ) INPUT_PORTS_END - +#endif #define TOAPLAN1_PLAYER_INPUT( player, button3, options ) \ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(player) options PORT_8WAY \ diff --git a/src/mame/drivers/toaplan2.c b/src/mame/drivers/toaplan2.c index 97ea5b76473..2ee53a9dc68 100644 --- a/src/mame/drivers/toaplan2.c +++ b/src/mame/drivers/toaplan2.c @@ -713,7 +713,7 @@ static WRITE16_HANDLER( toaplan2_hd647180_cpu_w ) static CUSTOM_INPUT( c2map_r ) { - toaplan2_state *state = field->port->machine().driver_data(); + toaplan2_state *state = field->machine().driver_data(); // For Teki Paki hardware // bit 4 high signifies secondary CPU is ready diff --git a/src/mame/drivers/tryout.c b/src/mame/drivers/tryout.c index f7f74c60411..3e8a37d052e 100644 --- a/src/mame/drivers/tryout.c +++ b/src/mame/drivers/tryout.c @@ -84,7 +84,7 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted ) { if(newval != oldval) - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, ASSERT_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, ASSERT_LINE); } static INPUT_PORTS_START( tryout ) diff --git a/src/mame/drivers/ultratnk.c b/src/mame/drivers/ultratnk.c index 513ae239810..6785dae323a 100644 --- a/src/mame/drivers/ultratnk.c +++ b/src/mame/drivers/ultratnk.c @@ -20,15 +20,15 @@ Atari Ultra Tank driver static CUSTOM_INPUT( get_collision ) { - ultratnk_state *state = field->port->machine().driver_data(); + ultratnk_state *state = field->machine().driver_data(); return state->m_collision[(FPTR) param]; } static CUSTOM_INPUT( get_joystick ) { - ultratnk_state *state = field->port->machine().driver_data(); - UINT8 joy = input_port_read(field->port->machine(), (const char *)param) & 3; + ultratnk_state *state = field->machine().driver_data(); + UINT8 joy = input_port_read(field->machine(), (const char *)param) & 3; if (joy == 1) { diff --git a/src/mame/drivers/ultrsprt.c b/src/mame/drivers/ultrsprt.c index 175fc6dd0fb..0383567f2fa 100644 --- a/src/mame/drivers/ultrsprt.c +++ b/src/mame/drivers/ultrsprt.c @@ -83,7 +83,7 @@ static WRITE32_HANDLER( eeprom_w ) static CUSTOM_INPUT( analog_ctrl_r ) { const char *tag = (const char *)param; - return input_port_read(field->port->machine(), tag) & 0xfff; + return input_port_read(field->machine(), tag) & 0xfff; } static WRITE32_HANDLER( int_ack_w ) diff --git a/src/mame/drivers/undrfire.c b/src/mame/drivers/undrfire.c index ed7136706dd..12320a2b734 100644 --- a/src/mame/drivers/undrfire.c +++ b/src/mame/drivers/undrfire.c @@ -253,7 +253,7 @@ static const eeprom_interface undrfire_eeprom_interface = static CUSTOM_INPUT(frame_counter_r) { - undrfire_state *state = field->port->machine().driver_data(); + undrfire_state *state = field->machine().driver_data(); return state->m_frame_counter; } diff --git a/src/mame/drivers/vicdual.c b/src/mame/drivers/vicdual.c index 65021c19dac..5a6a58aa47d 100644 --- a/src/mame/drivers/vicdual.c +++ b/src/mame/drivers/vicdual.c @@ -83,7 +83,7 @@ static void assert_coin_status(running_machine &machine) static CUSTOM_INPUT( vicdual_read_coin_status ) { - vicdual_state *state = field->port->machine().driver_data(); + vicdual_state *state = field->machine().driver_data(); return state->m_coin_status; } @@ -93,13 +93,13 @@ static INPUT_CHANGED( coin_changed ) if (newval && !oldval) { /* increment the coin counter */ - coin_counter_w(field->port->machine(), 0, 1); - coin_counter_w(field->port->machine(), 0, 0); + coin_counter_w(field->machine(), 0, 1); + coin_counter_w(field->machine(), 0, 0); - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE); /* simulate the coin switch being closed for a while */ - field->port->machine().scheduler().timer_set(4 * field->port->machine().primary_screen->frame_period(), FUNC(clear_coin_status)); + field->machine().scheduler().timer_set(4 * field->machine().primary_screen->frame_period(), FUNC(clear_coin_status)); } } @@ -137,26 +137,26 @@ static int get_vcounter(running_machine &machine) static CUSTOM_INPUT( vicdual_get_64v ) { - return (get_vcounter(field->port->machine()) >> 6) & 0x01; + return (get_vcounter(field->machine()) >> 6) & 0x01; } static CUSTOM_INPUT( vicdual_get_vblank_comp ) { - return (get_vcounter(field->port->machine()) < VICDUAL_VBSTART); + return (get_vcounter(field->machine()) < VICDUAL_VBSTART); } static CUSTOM_INPUT( vicdual_get_composite_blank_comp ) { - return (vicdual_get_vblank_comp(field, 0) && !field->port->machine().primary_screen->hblank()); + return (vicdual_get_vblank_comp(device, field, 0) && !field->machine().primary_screen->hblank()); } static CUSTOM_INPUT( vicdual_get_timer_value ) { /* return the state of the timer (old code claims "4MHz square wave", but it was toggled once every 2msec, or 500Hz) */ - return field->port->machine().time().as_ticks(500) & 1; + return field->machine().time().as_ticks(500) & 1; } @@ -1632,7 +1632,7 @@ INPUT_PORTS_END static CUSTOM_INPUT( brdrline_lives ) { int bit_mask = (FPTR)param; - return (input_port_read(field->port->machine(), "FAKE_LIVES") & bit_mask) ? 0x00 : 0x01; + return (input_port_read(field->machine(), "FAKE_LIVES") & bit_mask) ? 0x00 : 0x01; } static INPUT_PORTS_START( brdrline ) @@ -2053,7 +2053,7 @@ static WRITE8_HANDLER( samurai_protection_w ) static CUSTOM_INPUT( samurai_protection_r ) { - vicdual_state *state = field->port->machine().driver_data(); + vicdual_state *state = field->machine().driver_data(); int offset = (FPTR)param; UINT32 answer = 0; diff --git a/src/mame/drivers/welltris.c b/src/mame/drivers/welltris.c index a0692f1ab3e..9b039296757 100644 --- a/src/mame/drivers/welltris.c +++ b/src/mame/drivers/welltris.c @@ -342,7 +342,7 @@ static WRITE16_HANDLER( sound_command_w ) static CUSTOM_INPUT( pending_sound_r ) { - welltris_state *state = field->port->machine().driver_data(); + welltris_state *state = field->machine().driver_data(); return state->m_pending_command ? 1 : 0; } diff --git a/src/mame/drivers/wolfpack.c b/src/mame/drivers/wolfpack.c index 13f3fa302f3..7c76e5fb048 100644 --- a/src/mame/drivers/wolfpack.c +++ b/src/mame/drivers/wolfpack.c @@ -33,7 +33,7 @@ static MACHINE_RESET( wolfpack ) static CUSTOM_INPUT( wolfpack_dial_r ) { int bit = (FPTR)param; - return ((input_port_read(field->port->machine(), "DIAL") + bit) / 2) & 0x01; + return ((input_port_read(field->machine(), "DIAL") + bit) / 2) & 0x01; } diff --git a/src/mame/drivers/wwfsstar.c b/src/mame/drivers/wwfsstar.c index 6665bf4646c..cce7002e65d 100644 --- a/src/mame/drivers/wwfsstar.c +++ b/src/mame/drivers/wwfsstar.c @@ -274,7 +274,7 @@ static TIMER_DEVICE_CALLBACK( wwfsstar_scanline ) static CUSTOM_INPUT( wwfsstar_vblank_r ) { - wwfsstar_state *state = field->port->machine().driver_data(); + wwfsstar_state *state = field->machine().driver_data(); return state->m_vblank; } diff --git a/src/mame/drivers/wwfwfest.c b/src/mame/drivers/wwfwfest.c index 244c0613860..ac5f1227102 100644 --- a/src/mame/drivers/wwfwfest.c +++ b/src/mame/drivers/wwfwfest.c @@ -181,13 +181,13 @@ static WRITE16_HANDLER ( wwfwfest_soundwrite ) static CUSTOM_INPUT( dsw_3f_r ) { const char *tag = (const char *)param; - return input_port_read(field->port->machine(), tag) & 0x3f; + return input_port_read(field->machine(), tag) & 0x3f; } static CUSTOM_INPUT( dsw_c0_r ) { const char *tag = (const char *)param; - return (input_port_read(field->port->machine(), tag) & 0xc0) >> 6; + return (input_port_read(field->machine(), tag) & 0xc0) >> 6; } diff --git a/src/mame/drivers/xain.c b/src/mame/drivers/xain.c index a535d75d6d4..4a9f78c9f1e 100644 --- a/src/mame/drivers/xain.c +++ b/src/mame/drivers/xain.c @@ -276,7 +276,7 @@ static WRITE8_HANDLER( xain_68705_w ) static CUSTOM_INPUT( xain_vblank_r ) { - xain_state *state = field->port->machine().driver_data(); + xain_state *state = field->machine().driver_data(); return state->m_vblank; } @@ -368,10 +368,10 @@ WRITE8_HANDLER( xain_68705_ddr_c_w ) static CUSTOM_INPUT( mcu_status_r ) { - xain_state *state = field->port->machine().driver_data(); + xain_state *state = field->machine().driver_data(); UINT8 res = 0; - if (field->port->machine().device("mcu") != NULL) + if (field->machine().device("mcu") != NULL) { if (state->m_mcu_ready == 1) res |= 0x01; diff --git a/src/mame/drivers/xmen.c b/src/mame/drivers/xmen.c index cd61203543d..d31b14639be 100644 --- a/src/mame/drivers/xmen.c +++ b/src/mame/drivers/xmen.c @@ -258,7 +258,7 @@ INPUT_PORTS_END static CUSTOM_INPUT( xmen_frame_r ) { - xmen_state *state = field->port->machine().driver_data(); + xmen_state *state = field->machine().driver_data(); return state->m_current_frame; } diff --git a/src/mame/drivers/xxmissio.c b/src/mame/drivers/xxmissio.c index f98c3269948..198dfca8677 100644 --- a/src/mame/drivers/xxmissio.c +++ b/src/mame/drivers/xxmissio.c @@ -21,7 +21,7 @@ static WRITE8_HANDLER( xxmissio_bank_sel_w ) static CUSTOM_INPUT( xxmissio_status_r ) { - xxmissio_state *state = field->port->machine().driver_data(); + xxmissio_state *state = field->machine().driver_data(); int bit_mask = (FPTR)param; return (state->m_status & bit_mask) ? 1 : 0; } diff --git a/src/mame/drivers/yiear.c b/src/mame/drivers/yiear.c index d8c66ffcb19..0d43d1b33e7 100644 --- a/src/mame/drivers/yiear.c +++ b/src/mame/drivers/yiear.c @@ -159,7 +159,7 @@ static INPUT_PORTS_START( yiear ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CODE("NONE") + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) /*WTF? PORT_CODE("NONE")*/ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START("P2") @@ -169,7 +169,7 @@ static INPUT_PORTS_START( yiear ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_COCKTAIL PORT_CODE("NONE") + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_COCKTAIL /*WTF? PORT_CODE("NONE")*/ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START("DSW1") diff --git a/src/mame/drivers/zaccaria.c b/src/mame/drivers/zaccaria.c index 51bfad785be..24472ffa4b3 100644 --- a/src/mame/drivers/zaccaria.c +++ b/src/mame/drivers/zaccaria.c @@ -342,7 +342,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( acs_r ) { - zaccaria_state *state = field->port->machine().driver_data(); + zaccaria_state *state = field->machine().driver_data(); return (state->m_acs & 0x08) ? 1 : 0; } diff --git a/src/mame/drivers/zaxxon.c b/src/mame/drivers/zaxxon.c index 72fab15618b..b17497e8c3f 100644 --- a/src/mame/drivers/zaxxon.c +++ b/src/mame/drivers/zaxxon.c @@ -293,7 +293,7 @@ static INPUT_CHANGED( service_switch ) { /* pressing the service switch sends an NMI */ if (newval) - cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); + cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); } @@ -355,12 +355,12 @@ static READ8_HANDLER( razmataz_counter_r ) static CUSTOM_INPUT( razmataz_dial_r ) { - zaxxon_state *state = field->port->machine().driver_data(); + zaxxon_state *state = field->machine().driver_data(); static const char *const dialname[2] = { "DIAL0", "DIAL1" }; int num = (FPTR)param; int delta, res; - delta = input_port_read(field->port->machine(), dialname[num]); + delta = input_port_read(field->machine(), dialname[num]); if (delta < 0x80) { @@ -408,7 +408,7 @@ static INPUT_CHANGED( zaxxon_coin_inserted ) { if (newval) { - zaxxon_state *state = field->port->machine().driver_data(); + zaxxon_state *state = field->machine().driver_data(); state->m_coin_status[(int)(FPTR)param] = state->m_coin_enable[(int)(FPTR)param]; } @@ -417,7 +417,7 @@ static INPUT_CHANGED( zaxxon_coin_inserted ) static CUSTOM_INPUT( zaxxon_coin_r ) { - zaxxon_state *state = field->port->machine().driver_data(); + zaxxon_state *state = field->machine().driver_data(); return state->m_coin_status[(int)(FPTR)param]; } diff --git a/src/mame/drivers/zn.c b/src/mame/drivers/zn.c index cbf5b85ae5f..b816b249576 100644 --- a/src/mame/drivers/zn.c +++ b/src/mame/drivers/zn.c @@ -2066,7 +2066,7 @@ static WRITE32_DEVICE_HANDLER( jdredd_ide_w ) static CUSTOM_INPUT( jdredd_gun_mux_read ) { - zn_state *state = field->port->machine().driver_data(); + zn_state *state = field->machine().driver_data(); return state->m_jdredd_gun_mux; } diff --git a/src/mame/machine/amiga.c b/src/mame/machine/amiga.c index 70595042695..e2a7c0988d6 100644 --- a/src/mame/machine/amiga.c +++ b/src/mame/machine/amiga.c @@ -413,7 +413,7 @@ static TIMER_CALLBACK( amiga_irq_proc ) CUSTOM_INPUT( amiga_joystick_convert ) { - UINT8 bits = input_port_read(field->port->machine(), (const char *)param); + UINT8 bits = input_port_read(field->machine(), (const char *)param); int up = (bits >> 0) & 1; int down = (bits >> 1) & 1; int left = (bits >> 2) & 1; diff --git a/src/mame/machine/amigakbd.c b/src/mame/machine/amigakbd.c index 1b776d26d22..5a38d10cded 100644 --- a/src/mame/machine/amigakbd.c +++ b/src/mame/machine/amigakbd.c @@ -68,11 +68,11 @@ static INPUT_CHANGED( kbd_update ) /* Special case Page UP, which we will use as Action Replay button */ if ( (index == 3) && ( delta & 0x80000000 ) && ( newvalue & 0x80000000 ) ) { - const amiga_machine_interface *amiga_intf = amiga_get_interface(field->port->machine()); + const amiga_machine_interface *amiga_intf = amiga_get_interface(field->machine()); if ( amiga_intf != NULL && amiga_intf->nmi_callback ) { - (*amiga_intf->nmi_callback)(field->port->machine()); + (*amiga_intf->nmi_callback)(field->machine()); } } else @@ -96,7 +96,7 @@ static INPUT_CHANGED( kbd_update ) /* if the buffer was empty and we have new data, start a timer to send the keystrokes */ if ( key_buf_was_empty && ( kbd.buf_pos != kbd.cur_pos ) ) { - kbd.timer->adjust(field->port->machine().primary_screen->frame_period() / 4); + kbd.timer->adjust(field->machine().primary_screen->frame_period() / 4); } } } diff --git a/src/mame/machine/arkanoid.c b/src/mame/machine/arkanoid.c index 5721eddcd86..e56c8e83a4a 100644 --- a/src/mame/machine/arkanoid.c +++ b/src/mame/machine/arkanoid.c @@ -106,7 +106,7 @@ WRITE8_HANDLER( arkanoid_68705_ddr_c_w ) CUSTOM_INPUT( arkanoid_68705_input_r ) { - arkanoid_state *state = field->port->machine().driver_data(); + arkanoid_state *state = field->machine().driver_data(); int res = 0; /* bit 0x40 of comes from the sticky bit */ @@ -122,10 +122,10 @@ CUSTOM_INPUT( arkanoid_68705_input_r ) CUSTOM_INPUT( arkanoid_input_mux ) { - arkanoid_state *state = field->port->machine().driver_data(); + arkanoid_state *state = field->machine().driver_data(); const char *tag1 = (const char *)param; const char *tag2 = tag1 + strlen(tag1) + 1; - return input_port_read(field->port->machine(), (state->m_paddle_select == 0) ? tag1 : tag2); + return input_port_read(field->machine(), (state->m_paddle_select == 0) ? tag1 : tag2); } /* diff --git a/src/mame/machine/balsente.c b/src/mame/machine/balsente.c index ea9a8487dc1..f423c877531 100644 --- a/src/mame/machine/balsente.c +++ b/src/mame/machine/balsente.c @@ -1110,7 +1110,7 @@ WRITE8_HANDLER( balsente_register_addr_w ) CUSTOM_INPUT( nstocker_bits_r ) { - balsente_state *state = field->port->machine().driver_data(); + balsente_state *state = field->machine().driver_data(); return state->m_nstocker_bits; } diff --git a/src/mame/machine/cdislave.c b/src/mame/machine/cdislave.c index 917b95eaef2..99deb691b24 100644 --- a/src/mame/machine/cdislave.c +++ b/src/mame/machine/cdislave.c @@ -119,7 +119,7 @@ void cdislave_device::perform_mouse_update() INPUT_CHANGED( cdislave_device::mouse_update ) { - cdislave_device *slave = static_cast(field->port->machine().device("slave")); + cdislave_device *slave = static_cast(field->machine().device("slave")); slave->perform_mouse_update(); } diff --git a/src/mame/machine/gaelco2.c b/src/mame/machine/gaelco2.c index 3a58f7ecf73..36ddec33399 100644 --- a/src/mame/machine/gaelco2.c +++ b/src/mame/machine/gaelco2.c @@ -223,7 +223,7 @@ INTERRUPT_GEN( bang_interrupt ) CUSTOM_INPUT( wrally2_analog_bit_r ) { - gaelco2_state *state = field->port->machine().driver_data(); + gaelco2_state *state = field->machine().driver_data(); int which = (FPTR)param; return (state->m_analog_ports[which] >> 7) & 0x01; } diff --git a/src/mame/machine/galaxold.c b/src/mame/machine/galaxold.c index c2c9e75b8f1..74b3314d52d 100644 --- a/src/mame/machine/galaxold.c +++ b/src/mame/machine/galaxold.c @@ -257,11 +257,11 @@ WRITE8_HANDLER( _4in1_bank_w ) CUSTOM_INPUT( _4in1_fake_port_r ) { - galaxold_state *state = field->port->machine().driver_data(); + galaxold_state *state = field->machine().driver_data(); static const char *const portnames[] = { "FAKE1", "FAKE2", "FAKE3", "FAKE4" }; int bit_mask = (FPTR)param; - return (input_port_read(field->port->machine(), portnames[state->m__4in1_bank]) & bit_mask) ? 0x01 : 0x00; + return (input_port_read(field->machine(), portnames[state->m__4in1_bank]) & bit_mask) ? 0x01 : 0x00; } #ifdef UNUSED_FUNCTION diff --git a/src/mame/machine/jvs13551.c b/src/mame/machine/jvs13551.c index 83b18fd24c0..63acafaaa16 100644 --- a/src/mame/machine/jvs13551.c +++ b/src/mame/machine/jvs13551.c @@ -2,13 +2,13 @@ const device_type SEGA_837_13551 = &device_creator; -static WRITE_LINE_DEVICE_HANDLER(coin_1_w) +WRITE_LINE_DEVICE_HANDLER(jvs13551_coin_1_w) { if(state) downcast(device)->inc_coin(0); } -static WRITE_LINE_DEVICE_HANDLER(coin_2_w) +WRITE_LINE_DEVICE_HANDLER(jvs13551_coin_2_w) { if(state) downcast(device)->inc_coin(1); @@ -16,8 +16,8 @@ static WRITE_LINE_DEVICE_HANDLER(coin_2_w) static INPUT_PORTS_START(sega_837_13551_coins) PORT_START("COINS") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_COIN1) PORT_WRITE_LINE_DEVICE(DEVICE_SELF, coin_1_w) - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_COIN2) PORT_WRITE_LINE_DEVICE(DEVICE_SELF, coin_2_w) + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_COIN1) PORT_WRITE_LINE_DEVICE(DEVICE_SELF, jvs13551_coin_1_w) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_COIN2) PORT_WRITE_LINE_DEVICE(DEVICE_SELF, jvs13551_coin_2_w) INPUT_PORTS_END void sega_837_13551::static_set_port_tag(device_t &device, int port, const char *tag) @@ -26,7 +26,7 @@ void sega_837_13551::static_set_port_tag(device_t &device, int port, const char ctrl.port_tag[port] = tag; } -const input_port_token *sega_837_13551::device_input_ports() const +ioport_constructor sega_837_13551::device_input_ports() const { return INPUT_PORTS_NAME(sega_837_13551_coins); } diff --git a/src/mame/machine/jvs13551.h b/src/mame/machine/jvs13551.h index 373b057a690..6eba6c6f475 100644 --- a/src/mame/machine/jvs13551.h +++ b/src/mame/machine/jvs13551.h @@ -26,7 +26,7 @@ class sega_837_13551 : public jvs_device public: sega_837_13551(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); static void static_set_port_tag(device_t &device, int port, const char *tag); - const input_port_token *device_input_ports() const; + ioport_constructor device_input_ports() const; void inc_coin(int coin); diff --git a/src/mame/machine/mhavoc.c b/src/mame/machine/mhavoc.c index 962dc41f975..d2dea551f53 100644 --- a/src/mame/machine/mhavoc.c +++ b/src/mame/machine/mhavoc.c @@ -213,41 +213,41 @@ WRITE8_HANDLER( mhavoc_rom_banksel_w ) CUSTOM_INPUT( tms5220_r ) { - return tms5220_readyq_r(field->port->machine().device("tms")) ? 1 : 0; + return tms5220_readyq_r(field->machine().device("tms")) ? 1 : 0; } CUSTOM_INPUT( mhavoc_bit67_r ) { - mhavoc_state *state = field->port->machine().driver_data(); + mhavoc_state *state = field->machine().driver_data(); const char *tag1 = (const char *)param; const char *tag2 = tag1 + strlen(tag1) + 1; - return input_port_read(field->port->machine(), state->m_player_1 ? tag2 : tag1) & 0x03; + return input_port_read(field->machine(), state->m_player_1 ? tag2 : tag1) & 0x03; } CUSTOM_INPUT( gamma_rcvd_r ) { - mhavoc_state *state = field->port->machine().driver_data(); + mhavoc_state *state = field->machine().driver_data(); /* Gamma rcvd flag */ return state->m_gamma_rcvd; } CUSTOM_INPUT( gamma_xmtd_r ) { - mhavoc_state *state = field->port->machine().driver_data(); + mhavoc_state *state = field->machine().driver_data(); /* Gamma xmtd flag */ return state->m_gamma_xmtd; } CUSTOM_INPUT( alpha_rcvd_r ) { - mhavoc_state *state = field->port->machine().driver_data(); + mhavoc_state *state = field->machine().driver_data(); /* Alpha rcvd flag */ return (state->m_has_gamma_cpu && state->m_alpha_rcvd); } CUSTOM_INPUT( alpha_xmtd_r ) { - mhavoc_state *state = field->port->machine().driver_data(); + mhavoc_state *state = field->machine().driver_data(); /* Alpha xmtd flag */ return (state->m_has_gamma_cpu && state->m_alpha_xmtd); } diff --git a/src/mame/machine/micro3d.c b/src/mame/machine/micro3d.c index ff87e021e7b..cbd50732884 100644 --- a/src/mame/machine/micro3d.c +++ b/src/mame/machine/micro3d.c @@ -545,7 +545,7 @@ WRITE16_HANDLER( micro3d_adc_w ) CUSTOM_INPUT( botssa_hwchk_r ) { - micro3d_state *state = field->port->machine().driver_data(); + micro3d_state *state = field->machine().driver_data(); return state->m_botssa_latch; } diff --git a/src/mame/machine/playch10.c b/src/mame/machine/playch10.c index 9061907afd8..a83b88e5992 100644 --- a/src/mame/machine/playch10.c +++ b/src/mame/machine/playch10.c @@ -93,7 +93,7 @@ MACHINE_START( playch10_hboard ) CUSTOM_INPUT( pc10_int_detect_r ) { - playch10_state *state = field->port->machine().driver_data(); + playch10_state *state = field->machine().driver_data(); return ~state->m_pc10_int_detect & 1; } diff --git a/src/mame/machine/scramble.c b/src/mame/machine/scramble.c index d4e9db3f319..6fe214161a7 100644 --- a/src/mame/machine/scramble.c +++ b/src/mame/machine/scramble.c @@ -43,7 +43,7 @@ CUSTOM_INPUT( darkplnt_custom_r ) 0x2b, 0x2a, 0x28, 0x29, 0x09, 0x08, 0x0a, 0x0b, 0x0f, 0x0e, 0x0c, 0x0d, 0x2d, 0x2c, 0x2e, 0x2f, 0x27, 0x26, 0x24, 0x25, 0x05, 0x04, 0x06, 0x07 }; - UINT8 val = input_port_read(field->port->machine(), (const char *)param); + UINT8 val = input_port_read(field->machine(), (const char *)param); return remap[val >> 2]; } diff --git a/src/mame/machine/segasms.c b/src/mame/machine/segasms.c index be79559a118..ffd7dd6b0ac 100644 --- a/src/mame/machine/segasms.c +++ b/src/mame/machine/segasms.c @@ -319,24 +319,24 @@ static TIMER_CALLBACK( lphaser_2_callback ) INPUT_CHANGED( lgun1_changed ) { - sms_state *state = field->port->machine().driver_data(); + sms_state *state = field->machine().driver_data(); if (!state->m_lphaser_1_timer || - (input_port_read_safe(field->port->machine(), "CTRLSEL", 0x00) & 0x0f) != 0x01) + (input_port_read_safe(field->machine(), "CTRLSEL", 0x00) & 0x0f) != 0x01) return; if (newval != oldval) - lphaser1_sensor_check(field->port->machine()); + lphaser1_sensor_check(field->machine()); } INPUT_CHANGED( lgun2_changed ) { - sms_state *state = field->port->machine().driver_data(); + sms_state *state = field->machine().driver_data(); if (!state->m_lphaser_2_timer || - (input_port_read_safe(field->port->machine(), "CTRLSEL", 0x00) & 0xf0) != 0x10) + (input_port_read_safe(field->machine(), "CTRLSEL", 0x00) & 0xf0) != 0x10) return; if (newval != oldval) - lphaser2_sensor_check(field->port->machine()); + lphaser2_sensor_check(field->machine()); } diff --git a/src/mame/machine/starwars.c b/src/mame/machine/starwars.c index 15a1066565c..2e789eca5ab 100644 --- a/src/mame/machine/starwars.c +++ b/src/mame/machine/starwars.c @@ -110,7 +110,7 @@ WRITE8_HANDLER( starwars_out_w ) CUSTOM_INPUT( matrix_flag_r ) { - starwars_state *state = field->port->machine().driver_data(); + starwars_state *state = field->machine().driver_data(); /* set the matrix processor flag */ return state->m_math_run ? 1 : 0; } diff --git a/src/mame/machine/williams.c b/src/mame/machine/williams.c index 5fec0700750..28e312d08da 100644 --- a/src/mame/machine/williams.c +++ b/src/mame/machine/williams.c @@ -577,13 +577,13 @@ WRITE8_DEVICE_HANDLER( williams_port_select_w ) CUSTOM_INPUT( williams_mux_r ) { - williams_state *state = field->port->machine().driver_data(); + williams_state *state = field->machine().driver_data(); const char *tag = (const char *)param; if (state->m_port_select != 0) tag += strlen(tag) + 1; - return input_port_read(field->port->machine(), tag); + return input_port_read(field->machine(), tag); } /* diff --git a/src/mame/video/phoenix.c b/src/mame/video/phoenix.c index 01fffcbc86c..b25afcd9c1f 100644 --- a/src/mame/video/phoenix.c +++ b/src/mame/video/phoenix.c @@ -310,16 +310,16 @@ WRITE8_HANDLER( phoenix_scroll_w ) CUSTOM_INPUT( player_input_r ) { - phoenix_state *state = field->port->machine().driver_data(); + phoenix_state *state = field->machine().driver_data(); if (state->m_cocktail_mode) - return (input_port_read(field->port->machine(), "CTRL") & 0xf0) >> 4; + return (input_port_read(field->machine(), "CTRL") & 0xf0) >> 4; else - return (input_port_read(field->port->machine(), "CTRL") & 0x0f) >> 0; + return (input_port_read(field->machine(), "CTRL") & 0x0f) >> 0; } CUSTOM_INPUT( pleiads_protection_r ) { - phoenix_state *state = field->port->machine().driver_data(); + phoenix_state *state = field->machine().driver_data(); /* handle Pleiads protection */ switch (state->m_pleiads_protection_question) { @@ -332,7 +332,7 @@ CUSTOM_INPUT( pleiads_protection_r ) /* Bit 3 is 1 */ return 1; default: - logerror("%s:Unknown protection question %02X\n", field->port->machine().describe_context(), state->m_pleiads_protection_question); + logerror("%s:Unknown protection question %02X\n", field->machine().describe_context(), state->m_pleiads_protection_question); return 0; } } diff --git a/src/mame/video/stactics.c b/src/mame/video/stactics.c index dba7ffe2d0e..f5ae8e7e37e 100644 --- a/src/mame/video/stactics.c +++ b/src/mame/video/stactics.c @@ -114,7 +114,7 @@ WRITE8_HANDLER( stactics_scroll_ram_w ) CUSTOM_INPUT( stactics_get_frame_count_d3 ) { - stactics_state *state = field->port->machine().driver_data(); + stactics_state *state = field->machine().driver_data(); return (state->m_frame_count >> 3) & 0x01; } @@ -172,7 +172,7 @@ WRITE8_HANDLER( stactics_shot_flag_clear_w ) CUSTOM_INPUT( stactics_get_shot_standby ) { - stactics_state *state = field->port->machine().driver_data(); + stactics_state *state = field->machine().driver_data(); return state->m_shot_standby; } @@ -180,7 +180,7 @@ CUSTOM_INPUT( stactics_get_shot_standby ) CUSTOM_INPUT( stactics_get_not_shot_arrive ) { - stactics_state *state = field->port->machine().driver_data(); + stactics_state *state = field->machine().driver_data(); return !state->m_shot_arrive; }