diff options
| author | 2008-05-15 16:25:03 +0000 | |
|---|---|---|
| committer | 2008-05-15 16:25:03 +0000 | |
| commit | 096331c8562467a67fb5674f46dbb26bb032d2a6 (patch) | |
| tree | 1f9329631b6fb62a81f4bdd894403389d2f70759 | |
| parent | bc4b470ebbee405c6f48253acc225451f52a9b70 (diff) | |
Restructured input port internals and cleaned up inptport.c:
* Input ports are now maintained hierarchically. At the top
level are input ports, which contain a list of fields. Each
field represents one or more bits of the port. Certain fields
such as DIP switches and configuration switches contain a
list of settings, which can be selected. DIP switch fields
can also contain a list of DIP switch locations.
* Normalized behavior of port overrides (via PORT_INCLUDE or
by defining multiple overlapping bits). All fields within a
port are kept in strict increasing bit order, so altered DIP
switches are now kept in the appropriate order. This addresses
MAMETesters bug 01671.
* Live port state is now fully separate from configured
state. This is manifested in a similar way to devices, where
a const list of ports can be managed either offline or live.
Each port has a pointer to an opaque set of live state which
is NULL when offline or valid when live. Each port also has
a running_machine * which is also NULL when offline.
* Because of this new arrangement, the conversion from tokens
to a list of ports now requires reasonably complex memory
allocation, so these port lists must be explicitly allocated
and freed (they are not mantained by automatic resource
allocation).
* Custom and changed callbacks now take a pointer to a field
config instead of a running machine. This provides more
information about what field triggered the change notification.
The machine can be found by referenced field->port->machine.
* The inptport.c module has been cleaned up and many
ambiguities resolved. Most of this is internal, though it did
result in osd_customize_inputport_list() being changed to
osd_customize_input_type_list(). The parameter to this function
is now a linked list instead of an array, and the structures
referenced have been reorganized somewhat.
* Updated config.c to pass machine parameters to its callbacks.
* Updated validity checks, XML output, and UI system to handle
the new structures.
* Moved large table of default input settings to a separate
include file inpttype.h.
* Removed gross hacks in trackfld and hyperspt NVRAM. These
may be broken as a result.
110 files changed, 5205 insertions, 4592 deletions
diff --git a/.gitattributes b/.gitattributes index 658a523eeb5..255f3e011c7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -538,6 +538,7 @@ src/emu/info.c svneol=native#text/plain src/emu/info.h svneol=native#text/plain src/emu/inptport.c svneol=native#text/plain src/emu/inptport.h svneol=native#text/plain +src/emu/inpttype.h svneol=native#text/plain src/emu/input.c svneol=native#text/plain src/emu/input.h svneol=native#text/plain src/emu/inputseq.c svneol=native#text/plain diff --git a/src/emu/cheat.c b/src/emu/cheat.c index adc55b5aa50..633c46b5ae8 100644 --- a/src/emu/cheat.c +++ b/src/emu/cheat.c @@ -751,14 +751,14 @@ static int ShiftKeyPressed(void); static int ControlKeyPressed(void); static int AltKeyPressed(void); -static int UIPressedRepeatThrottle(int code, int baseSpeed); +static int UIPressedRepeatThrottle(running_machine *machine, int code, int baseSpeed); /********** DIRECT KEY INPUT **********/ static int ReadHexInput(void); static char * DoDynamicEditTextField(char * buf); static void DoStaticEditTextField(char * buf, int size); -static UINT32 DoEditHexField(UINT32 data); +static UINT32 DoEditHexField(running_machine *machine, UINT32 data); static UINT32 DoEditHexFieldSigned(UINT32 data, UINT32 mask); static INT32 DoEditDecField(INT32 data, INT32 min, INT32 max); @@ -777,7 +777,7 @@ static void FreeStringTable(void); static char * CreateStringCopy(char * buf); /********** ADDITIONAL MENU FOR CHEAT **********/ -static INT32 UserSelectValueMenu(int selection, CheatEntry * entry); +static INT32 UserSelectValueMenu(running_machine *machine, int selection, CheatEntry * entry); /********** CHEAT MENU **********/ static int EnableDisableCheatMenu(running_machine *machine, int selection, int firstTime); @@ -788,7 +788,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection); // min static int DoSearchMenuClassic(running_machine *machine, int selection); // classic mode static int DoSearchMenu(running_machine *machine, int selection); // advanced mode static int SelectSearchRegions(running_machine *machine, int selection, SearchInfo * search); -static int ViewSearchResults(int selection, int firstTime); +static int ViewSearchResults(running_machine *machine, int selection, int firstTime); static int ChooseWatch(running_machine *machine, int selection); static int EditWatch(running_machine *machine, WatchInfo * entry, int selection); @@ -1187,7 +1187,7 @@ static void old_style_menu(const char **items, const char **subitems, char *flag UIPressedRepoeatThrottle - key repeat handling -------------------------------------------------*/ -static int UIPressedRepeatThrottle(int code, int baseSpeed) +static int UIPressedRepeatThrottle(running_machine *machine, int code, int baseSpeed) { static int lastCode = -1; static int lastSpeed = -1; @@ -1196,7 +1196,7 @@ static int UIPressedRepeatThrottle(int code, int baseSpeed) const int kDelayRampTimer = 10; - if(input_port_type_pressed(code, 0)) + if(input_type_pressed(machine, code, 0)) { if(lastCode != code) // different key pressed { @@ -1227,7 +1227,7 @@ static int UIPressedRepeatThrottle(int code, int baseSpeed) lastCode = -1; } - return input_ui_pressed_repeat(code, lastSpeed); + return input_ui_pressed_repeat(machine, code, lastSpeed); } /*--------------------------------- @@ -1350,7 +1350,7 @@ static void DoStaticEditTextField(char * buf, int size) DoEditHexField - edit hex field with direct key input (unsigned) ------------------------------------------------------------------*/ -static UINT32 DoEditHexField(UINT32 data) +static UINT32 DoEditHexField(running_machine *machine, UINT32 data) { INT8 key; @@ -1363,7 +1363,7 @@ static UINT32 DoEditHexField(UINT32 data) } else { - if(input_ui_pressed(IPT_UI_CLEAR)) + if(input_ui_pressed(machine, IPT_UI_CLEAR)) { data = 0; @@ -1713,7 +1713,7 @@ int cheat_menu(running_machine *machine, int selection) ui_menu_draw(menu_item, total, sel, NULL); /********** KEY HANDLING **********/ - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { if(sel < (total - 1)) sel++; @@ -1721,7 +1721,7 @@ int cheat_menu(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { if(sel > 0) sel--; @@ -1729,7 +1729,7 @@ int cheat_menu(running_machine *machine, int selection) sel = total - 1; } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { switch(sel) { @@ -1750,10 +1750,10 @@ int cheat_menu(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_RELOAD_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT)) ReloadCheatDatabase(machine); - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) { if(sel == kMenu_Return) lastPstn = 0; // if cursor is now on the return item, adjust cursor keeper @@ -1973,7 +1973,7 @@ static char * CreateStringCopy(char * buf) UserSelectValueMenu - management for value-selection menu ------------------------------------------------------------*/ -static INT32 UserSelectValueMenu(int selection, CheatEntry * entry) +static INT32 UserSelectValueMenu(running_machine *machine, int selection, CheatEntry * entry) { char buf[2048]; int sel; @@ -2040,13 +2040,13 @@ static INT32 UserSelectValueMenu(int selection, CheatEntry * entry) ui_draw_message_window(buf); /********** KEY HANDLING **********/ - if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) delta = -1; - if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) delta = 1; - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { /* ### redundant?? probably can be removed ### */ if(!firstTime) @@ -2093,7 +2093,7 @@ static INT32 UserSelectValueMenu(int selection, CheatEntry * entry) sel = -1; } - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) { firstTime = 1; sel = -1; @@ -2161,7 +2161,7 @@ static INT32 UserSelectValueMenu(int selection, CheatEntry * entry) CommentMenu - management comment for code menu -------------------------------------------------*/ -static INT32 CommentMenu(int selection, CheatEntry * entry) +static INT32 CommentMenu(running_machine *machine, int selection, CheatEntry * entry) { char buf[2048]; int sel; @@ -2184,7 +2184,7 @@ static INT32 CommentMenu(int selection, CheatEntry * entry) ui_draw_message_window(buf); /********** KEY HANDLING **********/ - if(input_ui_pressed(IPT_UI_SELECT) || input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_SELECT) || input_ui_pressed(machine, IPT_UI_CANCEL)) sel = -1; return sel + 1; @@ -2221,11 +2221,11 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f switch(submenu_id) { case 1: - submenu_choice = CommentMenu(submenu_choice, &cheatList[sel]); + submenu_choice = CommentMenu(machine, submenu_choice, &cheatList[sel]); break; case 2: - submenu_choice = UserSelectValueMenu(submenu_choice, &cheatList[sel]); + submenu_choice = UserSelectValueMenu(machine, submenu_choice, &cheatList[sel]); break; case 3: @@ -2343,7 +2343,7 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f old_style_menu(menu_item, menu_subitem, flagBuf, sel, 0); /********** KEY HANDLING **********/ - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { sel++; @@ -2358,7 +2358,7 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f } } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { sel--; @@ -2380,7 +2380,7 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f } } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) { sel -= fullMenuPageHeight; @@ -2388,7 +2388,7 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) { sel += fullMenuPageHeight; @@ -2401,7 +2401,7 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f else entry = NULL; - if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) { if((sel < (total - 1)) && entry) { @@ -2460,7 +2460,7 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f } } - if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) { if((sel < (total - 1)) && entry) { @@ -2524,7 +2524,7 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f } } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { if(sel == (total - 1)) { @@ -2574,12 +2574,12 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f } } - if(input_ui_pressed(IPT_UI_WATCH_VALUE)) + if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE)) WatchCheatEntry(entry, 0); if(ShiftKeyPressed()) { - if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) // shift + save = save all codes + if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) // shift + save = save all codes { for(i = 0; i < cheatListLength; i++) SaveCheat(machine, &cheatList[i], 0, 0); @@ -2587,17 +2587,17 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f ui_popup_time(1, "%d cheats saved", cheatListLength); } - if(input_ui_pressed(IPT_UI_ADD_CHEAT)) // shift + add = add new emypty code + if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) // shift + add = add new emypty code AddCheatBefore(sel); - if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) // shift + delete = delete selected code + if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) // shift + delete = delete selected code DeleteCheatAt(sel); } else { if(ControlKeyPressed()) { - if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) // ctrl + save = save activation key + if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) // ctrl + save = save activation key { if((entry->flags & kCheatFlag_HasActivationKey1) || (entry->flags & kCheatFlag_HasActivationKey2)) { @@ -2611,29 +2611,29 @@ static int EnableDisableCheatMenu(running_machine *machine, int selection, int f } else { - if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) SaveCheat(machine, entry, 0, 0); // save current entry } } - if(input_ui_pressed(IPT_UI_EDIT_CHEAT) && entry) // edit selected code + if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT) && entry) // edit selected code { submenu_id = 3; submenu_choice = 1; } - if(input_ui_pressed(IPT_UI_RELOAD_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT)) ReloadCheatDatabase(machine); - if(UIPressedRepeatThrottle(IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) /* ----- quick menu switch : enable/disable -> add/edit ----- */ sel = -3; - if(UIPressedRepeatThrottle(IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) /* ----- quick menu switch : enable/disable -> watchpoint list ----- */ sel = -5; - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) sel = -1; return sel + 1; @@ -2699,7 +2699,7 @@ static int AddEditCheatMenu(running_machine *machine, int selection) old_style_menu(menu_item, NULL, NULL, sel, 0); /********** KEY HANDLING **********/ - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { sel++; @@ -2707,7 +2707,7 @@ static int AddEditCheatMenu(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { sel--; @@ -2715,7 +2715,7 @@ static int AddEditCheatMenu(running_machine *machine, int selection) sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) { sel -= fullMenuPageHeight; @@ -2723,7 +2723,7 @@ static int AddEditCheatMenu(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) { sel += fullMenuPageHeight; @@ -2736,7 +2736,7 @@ static int AddEditCheatMenu(running_machine *machine, int selection) else entry = NULL; - if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) { if(ShiftKeyPressed()) { @@ -2763,16 +2763,16 @@ static int AddEditCheatMenu(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_ADD_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) AddCheatBefore(sel); // insert empty code - if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) DeleteCheatAt(sel); // delete selected code - if(input_ui_pressed(IPT_UI_WATCH_VALUE)) + if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE)) WatchCheatEntry(entry, 0); // watch selected code - if(input_ui_pressed(IPT_UI_EDIT_CHEAT)) // edit selected code + if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT)) // edit selected code { /* ----- if selected item is not return, go to edit menu ----- */ if(sel < (total - 1)) @@ -2782,7 +2782,7 @@ static int AddEditCheatMenu(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { /* ----- if selected item is return, return previous menu ----- */ if(sel >= (total - 1)) @@ -2798,18 +2798,18 @@ static int AddEditCheatMenu(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_RELOAD_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT)) ReloadCheatDatabase(machine); - if(UIPressedRepeatThrottle(IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) /* ----- quick menu switch : add/edit -> search ----- */ sel = -4; - if(UIPressedRepeatThrottle(IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) /* ----- quick menu switch : add/edit -> enable/disable ----- */ sel = -2; - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) sel = -1; return sel + 1; @@ -3706,7 +3706,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index if(ShiftKeyPressed()) increment <<= 16; - if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) { editActive = 0; dirty = 1; @@ -4026,7 +4026,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index } } - if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) { editActive = 0; dirty = 1; @@ -4345,7 +4345,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index } } - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { sel++; @@ -4355,7 +4355,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index editActive = 0; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { sel--; @@ -4365,7 +4365,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index editActive = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) { sel -= fullMenuPageHeight; @@ -4375,7 +4375,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index editActive = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) { sel += fullMenuPageHeight; @@ -4385,7 +4385,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index editActive = 0; } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { if(editActive) { @@ -4447,7 +4447,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index case kType_ActivationKey1: case kType_ActivationKey2: { - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) { if(info->fieldType == kType_ActivationKey1) { @@ -4483,7 +4483,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index } else { - if((code != INPUT_CODE_INVALID) && !input_ui_pressed(IPT_UI_SELECT)) + if((code != INPUT_CODE_INVALID) && !input_ui_pressed(machine, IPT_UI_SELECT)) { if(info->fieldType == kType_ActivationKey1) { @@ -4508,7 +4508,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index UINT32 temp = (action->originalDataField >> 0) & 0xFF; temp++; - temp = DoEditHexField(temp) & 0xFF; + temp = DoEditHexField(machine, temp) & 0xFF; temp--; action->originalDataField = (action->originalDataField & 0xFFFFFF00) | ((temp << 0) & 0x000000FF); @@ -4520,7 +4520,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index { UINT32 temp = (action->originalDataField >> 8) & 0xFF; - temp = DoEditHexField(temp) & 0xFF; + temp = DoEditHexField(machine, temp) & 0xFF; action->originalDataField = (action->originalDataField & 0xFFFF00FF) | ((temp << 8) & 0x0000FF00); action->data = action->originalDataField; @@ -4531,7 +4531,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index { UINT32 temp = (action->originalDataField >> 16) & 0xFF; - temp = DoEditHexField(temp) & 0xFF; + temp = DoEditHexField(machine, temp) & 0xFF; action->originalDataField = (action->originalDataField & 0xFF00FFFF) | ((temp << 16) & 0x00FF0000); action->data = action->originalDataField; @@ -4550,14 +4550,14 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index break; case kType_WriteMask: - action->extendData = DoEditHexField(action->extendData); + action->extendData = DoEditHexField(machine, action->extendData); action->extendData &= info->extraData; break; case kType_AddMaximum: case kType_SubtractMinimum: case kType_WriteMatch: - action->extendData = DoEditHexField(action->extendData); + action->extendData = DoEditHexField(machine, action->extendData); break; case kType_RangeMinimum: @@ -4567,14 +4567,14 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index if(!TEST_FIELD(action->type, BytesUsed)) { temp = (action->extendData >> 8) & 0xFF; - temp = DoEditHexField(temp) & 0xFF; + temp = DoEditHexField(machine, temp) & 0xFF; action->extendData = (action->extendData & 0xFF) | ((temp << 8) & 0xFF00); } else { temp = (action->extendData >> 16) & 0xFFFF; - temp = DoEditHexField(temp) & 0xFFFF; + temp = DoEditHexField(machine, temp) & 0xFFFF; action->extendData = (action->extendData & 0x0000FFFF) | ((temp << 16) & 0xFFFF0000); } @@ -4588,14 +4588,14 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index if(!TEST_FIELD(action->type, BytesUsed)) { temp = action->extendData & 0xFF; - temp = DoEditHexField(temp) & 0xFF; + temp = DoEditHexField(machine, temp) & 0xFF; action->extendData = (action->extendData & 0xFF00) | (temp & 0x00FF); } else { temp = action->extendData & 0xFFFF; - temp = DoEditHexField(temp) & 0xFFFF; + temp = DoEditHexField(machine, temp) & 0xFFFF; action->extendData = (action->extendData & 0xFFFF0000) | (temp & 0x0000FFFF); } @@ -4603,23 +4603,23 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index break; case kType_Data: - action->originalDataField = DoEditHexField(action->originalDataField); + action->originalDataField = DoEditHexField(machine, action->originalDataField); action->originalDataField &= info->extraData; action->data = action->originalDataField; break; case kType_Address: - action->address = DoEditHexField(action->address); + action->address = DoEditHexField(machine, action->address); action->address &= info->extraData; break; } - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) editActive = 0; } else { - if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) { if(ControlKeyPressed()) if((entry->flags & kCheatFlag_HasActivationKey1) || (entry->flags & kCheatFlag_HasActivationKey2)) @@ -4634,13 +4634,13 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index SaveCheat(machine, entry, 0, 0); // save current entry } - if(input_ui_pressed(IPT_UI_WATCH_VALUE)) + if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE)) WatchCheatEntry(entry, 0); - if(input_ui_pressed(IPT_UI_ADD_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) AddActionBefore(entry, info->subcheat); - if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) { if(!info->subcheat) { @@ -4654,7 +4654,7 @@ static int EditCheatMenu(running_machine *machine, CheatEntry * entry, int index } } - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) { sel = -1; editActive = 0; @@ -4745,7 +4745,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) break; case kMenu_ViewResult: - submenuChoice = ViewSearchResults(submenuChoice, firstEntry); + submenuChoice = ViewSearchResults(machine, submenuChoice, firstEntry); break; } @@ -4870,7 +4870,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) old_style_menu(menuItem, menuSubItem, flagBuf, sel, 0); /********** KEY HANDLING **********/ - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { if(editActive) { @@ -4904,7 +4904,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { if(editActive) { @@ -4938,7 +4938,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) { sel -= fullMenuPageHeight; @@ -4946,7 +4946,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) { sel += fullMenuPageHeight; @@ -4954,7 +4954,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) { if(editActive) { @@ -4998,7 +4998,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) { if(editActive) { @@ -5043,7 +5043,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { if(editActive) { @@ -5160,16 +5160,16 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) /* ----- quick menu switch : search -> watchpoint list ----- */ sel = -5; - if(UIPressedRepeatThrottle(IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) /* ----- quick menu switch : search -> add/edit ----- */ sel = -3; /* ----- edit mode ON/OFF ----- */ - if(input_ui_pressed(IPT_UI_EDIT_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT)) { if(editActive) editActive = 0; @@ -5181,14 +5181,14 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) } /* ----- memory save ----- */ - if(input_ui_pressed(IPT_UI_CLEAR)) + if(input_ui_pressed(machine, IPT_UI_CLEAR)) { doneSaveMemory = 0; doSearch = 1; } - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) { if(editActive) editActive = 0; @@ -5237,7 +5237,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) { if(searchItem == kItem_Value) { - search->oldOptions.value = DoEditHexField(search->oldOptions.value); + search->oldOptions.value = DoEditHexField(machine, search->oldOptions.value); search->oldOptions.value &= kSearchByteMaskTable[search->bytes]; } @@ -5245,7 +5245,7 @@ static int DoSearchMenuMinimum(running_machine *machine, int selection) { if(searchItem == kItem_Timer) { - search->oldOptions.delta = DoEditHexField(search->oldOptions.delta); + search->oldOptions.delta = DoEditHexField(machine, search->oldOptions.delta); search->oldOptions.delta &= kSearchByteMaskTable[search->bytes]; } @@ -5366,7 +5366,7 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) break; case kMenu_ViewResult: - submenuChoice = ViewSearchResults(submenuChoice, firstEntry); + submenuChoice = ViewSearchResults(machine, submenuChoice, firstEntry); break; } @@ -5481,7 +5481,7 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) if(AltKeyPressed()) increment <<= 4; - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { sel++; @@ -5493,7 +5493,7 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { sel--; @@ -5505,7 +5505,7 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) { sel -= fullMenuPageHeight; @@ -5513,7 +5513,7 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) { sel += fullMenuPageHeight; @@ -5521,7 +5521,7 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) { switch(sel) { @@ -5575,7 +5575,7 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) { switch(sel) { @@ -5629,7 +5629,7 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { switch(sel) { @@ -5714,16 +5714,16 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) /* ----- quick menu switch : search -> watchpoint list ----- */ sel = -5; - if(UIPressedRepeatThrottle(IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) /* ----- quick menu switch : search -> add/edit ----- */ sel = -3; - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) { /* ----- if cursor is now on the return item, adjust cursor keeper ----- */ if(sel == kMenu_Return) @@ -5766,7 +5766,7 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) /* ----- edit a value if direct key input ----- */ if((sel == kMenu_ValueEqual) || (sel == kMenu_ValueNearTo)) { - search->oldOptions.value = DoEditHexField(search->oldOptions.value); + search->oldOptions.value = DoEditHexField(machine, search->oldOptions.value); search->oldOptions.value &= kSearchByteMaskTable[search->bytes]; } @@ -5774,7 +5774,7 @@ static int DoSearchMenuClassic(running_machine *machine, int selection) { if(sel == kMenu_Time) { - search->oldOptions.delta = DoEditHexField(search->oldOptions.delta); + search->oldOptions.delta = DoEditHexField(machine, search->oldOptions.delta); search->oldOptions.delta &= kSearchByteMaskTable[search->bytes]; } @@ -5884,7 +5884,7 @@ static int DoSearchMenu(running_machine *machine, int selection) break; case kMenu_ViewResult: - submenuChoice = ViewSearchResults(submenuChoice, firstEntry); + submenuChoice = ViewSearchResults(machine, submenuChoice, firstEntry); break; } @@ -6006,7 +6006,7 @@ static int DoSearchMenu(running_machine *machine, int selection) if(ShiftKeyPressed()) increment <<= 16; - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { sel++; @@ -6018,7 +6018,7 @@ static int DoSearchMenu(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { sel--; @@ -6030,7 +6030,7 @@ static int DoSearchMenu(running_machine *machine, int selection) sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) { sel -= fullMenuPageHeight; @@ -6038,7 +6038,7 @@ static int DoSearchMenu(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) { sel += fullMenuPageHeight; @@ -6046,7 +6046,7 @@ static int DoSearchMenu(running_machine *machine, int selection) sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) { switch(sel) { @@ -6106,7 +6106,7 @@ static int DoSearchMenu(running_machine *machine, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) { switch(sel) { @@ -6166,7 +6166,7 @@ static int DoSearchMenu(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { if(editActive) editActive = 0; @@ -6256,7 +6256,7 @@ static int DoSearchMenu(running_machine *machine, int selection) switch(sel) { case kMenu_Value: - search->value = DoEditHexField(search->value); + search->value = DoEditHexField(machine, search->value); search->value &= kSearchByteMaskTable[search->bytes]; break; @@ -6267,7 +6267,7 @@ static int DoSearchMenu(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) sel = -1; /* ----- keep current cursor position ----- */ @@ -6342,7 +6342,7 @@ static int SelectSearchRegions(running_machine *machine, int selection, SearchIn old_style_menu(menuItem, menuSubItem, NULL, sel, 0); /********** KEY HANDLING **********/ - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { sel++; @@ -6350,7 +6350,7 @@ static int SelectSearchRegions(running_machine *machine, int selection, SearchIn sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { sel--; @@ -6358,7 +6358,7 @@ static int SelectSearchRegions(running_machine *machine, int selection, SearchIn sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) { sel -= fullMenuPageHeight; @@ -6366,7 +6366,7 @@ static int SelectSearchRegions(running_machine *machine, int selection, SearchIn sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) { sel += fullMenuPageHeight; @@ -6374,7 +6374,7 @@ static int SelectSearchRegions(running_machine *machine, int selection, SearchIn sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) { if(sel < search->regionListLength) { @@ -6395,7 +6395,7 @@ static int SelectSearchRegions(running_machine *machine, int selection, SearchIn } } - if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) { if(sel < search->regionListLength) { @@ -6416,7 +6416,7 @@ static int SelectSearchRegions(running_machine *machine, int selection, SearchIn } } - if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) { if(ShiftKeyPressed()) // shift + delete = invalid region { @@ -6429,13 +6429,13 @@ static int SelectSearchRegions(running_machine *machine, int selection, SearchIn } } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { if(sel >= total - 1) sel = -1; } - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) sel = -1; return sel + 1; @@ -6445,7 +6445,7 @@ static int SelectSearchRegions(running_machine *machine, int selection, SearchIn ViewSearchResults - management for search result menu --------------------------------------------------------*/ -static int ViewSearchResults(int selection, int firstTime) +static int ViewSearchResults(running_machine *machine, int selection, int firstTime) { enum { @@ -6612,7 +6612,7 @@ static int ViewSearchResults(int selection, int firstTime) old_style_menu(menu_item, NULL, NULL, sel, 0); /********** KEY HANDLING **********/ - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { sel++; @@ -6620,7 +6620,7 @@ static int ViewSearchResults(int selection, int firstTime) sel = kMenu_FirstResult; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { sel--; @@ -6628,7 +6628,7 @@ static int ViewSearchResults(int selection, int firstTime) sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) { if(ShiftKeyPressed()) search->currentResultsPage = numPages - 1; // shift + right = go to last PAGE @@ -6648,7 +6648,7 @@ static int ViewSearchResults(int selection, int firstTime) sel = kMenu_FirstResult; } - if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) { if(ShiftKeyPressed()) search->currentResultsPage = 0; // shift + left = go to first PAGE @@ -6668,7 +6668,7 @@ static int ViewSearchResults(int selection, int firstTime) sel = kMenu_FirstResult; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kHorizontalFastKeyRepeatRate)) { sel -=fullMenuPageHeight; @@ -6676,7 +6676,7 @@ static int ViewSearchResults(int selection, int firstTime) sel = kMenu_FirstResult; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kHorizontalFastKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kHorizontalFastKeyRepeatRate)) { sel +=fullMenuPageHeight; @@ -6690,7 +6690,7 @@ static int ViewSearchResults(int selection, int firstTime) if(input_code_pressed_once(KEYCODE_HOME)) search->currentResultsPage = 0; // go to first PAGE - if(UIPressedRepeatThrottle(IPT_UI_PREV_GROUP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PREV_GROUP, kVerticalKeyRepeatRate)) { search->currentRegionIdx--; // go to previous REGION @@ -6700,7 +6700,7 @@ static int ViewSearchResults(int selection, int firstTime) sel = kMenu_FirstResult; } - if(UIPressedRepeatThrottle(IPT_UI_NEXT_GROUP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_NEXT_GROUP, kVerticalKeyRepeatRate)) { search->currentRegionIdx++; // go to next REGION @@ -6780,13 +6780,13 @@ static int ViewSearchResults(int selection, int firstTime) if(selectedAddressGood) { - if(input_ui_pressed(IPT_UI_WATCH_VALUE)) + if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE)) AddWatchFromResult(search, region, selectedAddress); // watch selected result - if(input_ui_pressed(IPT_UI_ADD_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) AddCheatFromResult(search, region, selectedAddress); // add selected result as new code to cheat list - if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) { InvalidateRegionOffset(search, region, selectedOffset); // delete selected result search->numResults--; @@ -6794,7 +6794,7 @@ static int ViewSearchResults(int selection, int firstTime) } } - if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) { if(ShiftKeyPressed()) { @@ -6807,7 +6807,7 @@ static int ViewSearchResults(int selection, int firstTime) } } - if((input_ui_pressed(IPT_UI_SELECT) && (sel == total - 1)) || input_ui_pressed(IPT_UI_CANCEL)) + if((input_ui_pressed(machine, IPT_UI_SELECT) && (sel == total - 1)) || input_ui_pressed(machine, IPT_UI_CANCEL)) sel = -1; return sel + 1; @@ -6882,7 +6882,7 @@ static int ChooseWatch(running_machine *machine, int selection) watch = NULL; /********** KEY HANDLING **********/ - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { sel++; @@ -6890,7 +6890,7 @@ static int ChooseWatch(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { sel--; @@ -6898,7 +6898,7 @@ static int ChooseWatch(running_machine *machine, int selection) sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) { sel -= fullMenuPageHeight; @@ -6906,7 +6906,7 @@ static int ChooseWatch(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) { sel += fullMenuPageHeight; @@ -6916,15 +6916,15 @@ static int ChooseWatch(running_machine *machine, int selection) if(ShiftKeyPressed()) { - if(input_ui_pressed(IPT_UI_ADD_CHEAT)) // shift + add = add new watchpoint + if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) // shift + add = add new watchpoint AddWatchBefore(sel); - if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) // shift + delete = delete selected watchpoint + if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) // shift + delete = delete selected watchpoint DeleteWatchAt(sel); } else { - if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) // save = save selected watchpoint as watchpoint code + if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) // save = save selected watchpoint as watchpoint code { if(watch) { @@ -6938,7 +6938,7 @@ static int ChooseWatch(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_ADD_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) { if(watch) { @@ -6954,7 +6954,7 @@ static int ChooseWatch(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) { if(ControlKeyPressed()) { @@ -6969,7 +6969,7 @@ static int ChooseWatch(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_EDIT_CHEAT)) // edit = edit selected watchpoint + if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT)) // edit = edit selected watchpoint { if(sel < (total - 1)) { @@ -6978,7 +6978,7 @@ static int ChooseWatch(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { if(sel == (total - 1)) // return previous menu { @@ -6995,7 +6995,7 @@ static int ChooseWatch(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_CLEAR)) + if(input_ui_pressed(machine, IPT_UI_CLEAR)) { /* ----- reset all watchpoints ----- */ for(i = 0; i < watchListLength; i++) @@ -7019,15 +7019,15 @@ static int ChooseWatch(running_machine *machine, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) /* ----- quick menu switch : watchpoint list -> enable/disable ----- */ sel = -2; - if(UIPressedRepeatThrottle(IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) /* ----- quick menu switch : watchpoint list -> search ----- */ sel = -4; - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) sel = -1; return sel + 1; @@ -7195,7 +7195,7 @@ static int EditWatch(running_machine *machine, WatchInfo * entry, int selection) if(ShiftKeyPressed()) increment <<= 16; - if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) { editActive = 0; @@ -7296,7 +7296,7 @@ static int EditWatch(running_machine *machine, WatchInfo * entry, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) { editActive = 0; @@ -7389,7 +7389,7 @@ static int EditWatch(running_machine *machine, WatchInfo * entry, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { sel++; @@ -7399,7 +7399,7 @@ static int EditWatch(running_machine *machine, WatchInfo * entry, int selection) editActive = 0; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { sel--; @@ -7409,7 +7409,7 @@ static int EditWatch(running_machine *machine, WatchInfo * entry, int selection) editActive = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) { sel -= fullMenuPageHeight; @@ -7419,7 +7419,7 @@ static int EditWatch(running_machine *machine, WatchInfo * entry, int selection) editActive = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) { sel += fullMenuPageHeight; @@ -7429,7 +7429,7 @@ static int EditWatch(running_machine *machine, WatchInfo * entry, int selection) editActive = 0; } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { if(editActive) editActive = 0; @@ -7463,7 +7463,7 @@ static int EditWatch(running_machine *machine, WatchInfo * entry, int selection) { case kMenu_Address: entry->address = DoShift(entry->address, entry->addressShift); - entry->address = DoEditHexField(entry->address); + entry->address = DoEditHexField(machine, entry->address); entry->address = DoShift(entry->address, -entry->addressShift); entry->address &= cpuInfoList[entry->cpu].addressMask; break; @@ -7502,23 +7502,23 @@ static int EditWatch(running_machine *machine, WatchInfo * entry, int selection) break; case kMenu_XOR: - entry->xor = DoEditHexField(entry->xor); + entry->xor = DoEditHexField(machine, entry->xor); entry->xor &= kSearchByteMaskTable[kWatchSizeConversionTable[entry->elementBytes]]; break; } - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) editActive = 0; } else { - if(input_ui_pressed(IPT_UI_ADD_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) AddCheatFromWatch(entry); - if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) entry->numElements = 0; - if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) { CheatEntry tempEntry; @@ -7530,7 +7530,7 @@ static int EditWatch(running_machine *machine, WatchInfo * entry, int selection) } } - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) sel = -1; return sel + 1; @@ -7630,7 +7630,7 @@ static int SelectOptions(running_machine *machine, int selection) old_style_menu(menuItem, menuSubItem, NULL, sel, 0); /********** KEY HANDLING **********/ - if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) { switch(sel) { @@ -7667,7 +7667,7 @@ static int SelectOptions(running_machine *machine, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) { switch(sel) { @@ -7704,7 +7704,7 @@ static int SelectOptions(running_machine *machine, int selection) } } - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { if(sel < (kMenu_Max - 1)) sel++; @@ -7712,7 +7712,7 @@ static int SelectOptions(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { if(sel > 0) sel--; @@ -7720,7 +7720,7 @@ static int SelectOptions(running_machine *machine, int selection) sel = kMenu_Max - 1; } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { switch(sel) { @@ -7735,17 +7735,17 @@ static int SelectOptions(running_machine *machine, int selection) } } - if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) { SaveCheat(machine, NULL, 0, 2); ui_popup_time(1, "command code saved"); } - if(input_ui_pressed(IPT_UI_RELOAD_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT)) ReloadCheatDatabase(machine); - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) sel = -1; return sel + 1; @@ -7808,7 +7808,7 @@ static int SelectSearch(running_machine *machine, int selection) old_style_menu(menuItem, NULL, NULL, sel, 0); /********** KEY HANDLING **********/ - if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) { sel++; @@ -7816,7 +7816,7 @@ static int SelectSearch(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) { sel--; @@ -7824,7 +7824,7 @@ static int SelectSearch(running_machine *machine, int selection) sel = total - 1; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) { sel -= fullMenuPageHeight; @@ -7832,7 +7832,7 @@ static int SelectSearch(running_machine *machine, int selection) sel = 0; } - if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) + if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) { sel += fullMenuPageHeight; @@ -7840,7 +7840,7 @@ static int SelectSearch(running_machine *machine, int selection) sel = total - 1; } - if(input_ui_pressed(IPT_UI_ADD_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) { AddSearchBefore(sel); @@ -7848,19 +7848,19 @@ static int SelectSearch(running_machine *machine, int selection) AllocateSearchRegions(&searchList[sel]); } - if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) { if(searchListLength > 1) DeleteSearchAt(sel); } - if(input_ui_pressed(IPT_UI_EDIT_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT)) { if(sel < total - 1) currentSearchIdx = sel; } - if(input_ui_pressed(IPT_UI_SELECT)) + if(input_ui_pressed(machine, IPT_UI_SELECT)) { if(sel >= total - 1) sel = -1; @@ -7868,7 +7868,7 @@ static int SelectSearch(running_machine *machine, int selection) currentSearchIdx = sel; } - if(input_ui_pressed(IPT_UI_CANCEL)) + if(input_ui_pressed(machine, IPT_UI_CANCEL)) sel = -1; return sel + 1; @@ -7882,7 +7882,7 @@ static TIMER_CALLBACK( cheat_periodic ) { int i; - if(input_ui_pressed(IPT_UI_TOGGLE_CHEAT)) + if(input_ui_pressed(machine, IPT_UI_TOGGLE_CHEAT)) { if(ShiftKeyPressed()) { diff --git a/src/emu/config.c b/src/emu/config.c index 7da3baf3115..651aa1c80ce 100644 --- a/src/emu/config.c +++ b/src/emu/config.c @@ -86,7 +86,7 @@ void config_init(running_machine *machine) * *************************************/ -void config_register(const char *nodename, config_callback_func load, config_callback_func save) +void config_register(running_machine *machine, const char *nodename, config_callback_func load, config_callback_func save) { config_type *newtype; config_type **ptype; @@ -122,7 +122,7 @@ int config_load_settings(running_machine *machine) /* loop over all registrants and call their init function */ for (type = typelist; type; type = type->next) - (*type->load)(CONFIG_TYPE_INIT, NULL); + (*type->load)(machine, CONFIG_TYPE_INIT, NULL); /* now load the controller file */ if (controller[0] != 0) @@ -162,7 +162,7 @@ int config_load_settings(running_machine *machine) /* loop over all registrants and call their final function */ for (type = typelist; type; type = type->next) - (*type->load)(CONFIG_TYPE_FINAL, NULL); + (*type->load)(machine, CONFIG_TYPE_FINAL, NULL); /* if we didn't find a saved config, return 0 so the main core knows that it */ /* is the first time the game is run and it should diplay the disclaimer. */ @@ -179,7 +179,7 @@ void config_save_settings(running_machine *machine) /* loop over all registrants and call their init function */ for (type = typelist; type; type = type->next) - (*type->save)(CONFIG_TYPE_INIT, NULL); + (*type->save)(machine, CONFIG_TYPE_INIT, NULL); /* save the defaults file */ filerr = mame_fopen(SEARCHPATH_CONFIG, "default.cfg", OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); @@ -202,7 +202,7 @@ void config_save_settings(running_machine *machine) /* loop over all registrants and call their final function */ for (type = typelist; type; type = type->next) - (*type->save)(CONFIG_TYPE_FINAL, NULL); + (*type->save)(machine, CONFIG_TYPE_FINAL, NULL); } @@ -288,7 +288,7 @@ static int config_load_xml(running_machine *machine, mame_file *file, int which_ /* loop over all registrants and call their load function */ for (type = typelist; type; type = type->next) - (*type->load)(which_type, xml_get_sibling(systemnode->child, type->name)); + (*type->load)(machine, which_type, xml_get_sibling(systemnode->child, type->name)); count++; } @@ -343,7 +343,7 @@ static int config_save_xml(running_machine *machine, mame_file *file, int which_ xml_data_node *curnode = xml_add_child(systemnode, type->name, NULL); if (!curnode) goto error; - (*type->save)(which_type, curnode); + (*type->save)(machine, which_type, curnode); /* if nothing was added, just nuke the node */ if (!curnode->value && !curnode->child) diff --git a/src/emu/config.h b/src/emu/config.h index 364c0460257..11d6daa802b 100644 --- a/src/emu/config.h +++ b/src/emu/config.h @@ -43,7 +43,7 @@ enum * *************************************/ -typedef void (*config_callback_func)(int config_type, xml_data_node *parentnode); +typedef void (*config_callback_func)(running_machine *machine, int config_type, xml_data_node *parentnode); @@ -54,7 +54,7 @@ typedef void (*config_callback_func)(int config_type, xml_data_node *parentnode) *************************************/ void config_init(running_machine *machine); -void config_register(const char *nodename, config_callback_func load, config_callback_func save); +void config_register(running_machine *machine, const char *nodename, config_callback_func load, config_callback_func save); int config_load_settings(running_machine *machine); void config_save_settings(running_machine *machine); diff --git a/src/emu/crsshair.c b/src/emu/crsshair.c index da6d084abee..5210553ead0 100644 --- a/src/emu/crsshair.c +++ b/src/emu/crsshair.c @@ -182,7 +182,8 @@ static void create_bitmap(int player) void crosshair_init(running_machine *machine) { - input_port_entry *ipt; + const input_port_config *port; + const input_field_config *field; /* request a callback upon exiting */ add_exit_callback(machine, crosshair_exit); @@ -191,22 +192,23 @@ void crosshair_init(running_machine *machine) memset(&global, 0, sizeof(global)); /* determine who needs crosshairs */ - for (ipt = machine->input_ports; ipt->type != IPT_END; ipt++) - if (ipt->analog.crossaxis != CROSSHAIR_AXIS_NONE) - { - int player = ipt->player; + for (port = machine->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + if (field->crossaxis != CROSSHAIR_AXIS_NONE) + { + int player = field->player; - assert(player < MAX_PLAYERS); + assert(player < MAX_PLAYERS); - /* mark as used and visible */ - global.used[player] = TRUE; - global.visible[player] = TRUE; + /* mark as used and visible */ + global.used[player] = TRUE; + global.visible[player] = TRUE; - /* for now, use the main screen */ - global.screen[player] = machine->primary_screen; + /* for now, use the main screen */ + global.screen[player] = machine->primary_screen; - create_bitmap(player); - } + create_bitmap(player); + } /* register the animation callback */ if (machine->primary_screen != NULL) @@ -272,8 +274,7 @@ void crosshair_toggle(running_machine *machine) static void animate(const device_config *device, int vblank_state) { - input_port_entry *ipt; - int portnum = -1; + int player; /* increment animation counter */ global.animation_counter += 0x04; @@ -285,39 +286,9 @@ static void animate(const device_config *device, int vblank_state) global.fade = 0xa0 + (0x60 * (~global.animation_counter & 0x7f) / 0x80); /* read all the lightgun values */ - for (ipt = device->machine->input_ports; ipt->type != IPT_END; ipt++) - { - /* keep track of the port number */ - if (ipt->type == IPT_PORT) - portnum++; - - /* compute the values */ - if (ipt->analog.crossaxis != CROSSHAIR_AXIS_NONE) - { - float value = (float)(get_crosshair_pos(portnum, ipt->player, ipt->analog.crossaxis) - ipt->analog.min) / (float)(ipt->analog.max - ipt->analog.min); - if (ipt->analog.crossscale < 0) - value = -(1.0 - value) * ipt->analog.crossscale; - else - value *= ipt->analog.crossscale; - value += ipt->analog.crossoffset; - - /* switch off the axis */ - switch (ipt->analog.crossaxis) - { - case CROSSHAIR_AXIS_X: - global.x[ipt->player] = value; - if (ipt->analog.crossaltaxis != 0) - global.y[ipt->player] = ipt->analog.crossaltaxis; - break; - - case CROSSHAIR_AXIS_Y: - global.y[ipt->player] = value; - if (ipt->analog.crossaltaxis != 0) - global.x[ipt->player] = ipt->analog.crossaltaxis; - break; - } - } - } + for (player = 0; player < MAX_PLAYERS; player++) + if (global.used[player]) + input_port_get_crosshair_position(device->machine, player, &global.x[player], &global.y[player]); } diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index e2d60e79ad3..9fad76f48a3 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -828,7 +828,7 @@ void mame_debug_hook(offs_t curpc) if (execution_state != EXECUTION_STATE_STOPPED && ++key_check_counter > 10000) { key_check_counter = 0; - if (input_ui_pressed(IPT_UI_DEBUG_BREAK)) + if (input_ui_pressed(Machine, IPT_UI_DEBUG_BREAK)) { execution_state = EXECUTION_STATE_STOPPED; debug_console_printf("User-initiated break\n"); diff --git a/src/emu/info.c b/src/emu/info.c index c13605e4fb9..dbc22c06201 100644 --- a/src/emu/info.c +++ b/src/emu/info.c @@ -36,34 +36,33 @@ settings for a game -------------------------------------------------*/ -static void print_game_switches(FILE *out, const game_driver *game, const input_port_entry *input) +static void print_game_switches(FILE *out, const game_driver *game, const input_port_config *portlist) { - /* iterate over input entries until we run out */ - while (input->type != IPT_END) - { - /* once we hit a name entry, start outputting */ - if (input->type == IPT_DIPSWITCH_NAME) - { - int def = input->default_value; + const input_port_config *port; + const input_field_config *field; + + /* iterate looking for DIP switches */ + for (port = portlist; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + if (field->type == IPT_DIPSWITCH) + { + const input_setting_config *setting; - /* output the switch name information */ - fprintf(out, "\t\t<dipswitch name=\"%s\">\n", xml_normalize_string(input->name)); + /* output the switch name information */ + fprintf(out, "\t\t<dipswitch name=\"%s\">\n", xml_normalize_string(input_field_name(field))); - /* loop over settings */ - for (input++; input->type == IPT_DIPSWITCH_SETTING; input++) - { - fprintf(out, "\t\t\t<dipvalue name=\"%s\"", xml_normalize_string(input->name)); - if (def == input->default_value) - fprintf(out, " default=\"yes\""); - fprintf(out, "/>\n"); - } + /* loop over settings */ + for (setting = field->settinglist; setting != NULL; setting = setting->next) + { + fprintf(out, "\t\t\t<dipvalue name=\"%s\"", xml_normalize_string(setting->name)); + if (setting->value == field->defvalue) + fprintf(out, " default=\"yes\""); + fprintf(out, "/>\n"); + } - /* terminate the switch entry */ - fprintf(out, "\t\t</dipswitch>\n"); - } - else - ++input; - } + /* terminate the switch entry */ + fprintf(out, "\t\t</dipswitch>\n"); + } } @@ -72,7 +71,7 @@ static void print_game_switches(FILE *out, const game_driver *game, const input_ input -------------------------------------------------*/ -static void print_game_input(FILE *out, const game_driver *game, const input_port_entry *input) +static void print_game_input(FILE *out, const game_driver *game, const input_port_config *portlist) { /* fix me -- this needs to be cleaned up to match the core style */ @@ -97,6 +96,8 @@ enum {cjoy, cdoublejoy, cAD_stick, cdial, ctrackball, cpaddle, clightgun, cpedal int keydelta; /* default analog keydelta */ int reverse; /* default analog reverse setting */ } control[ENDCONTROLTYPES]; + const input_port_config *port; + const input_field_config *field; for (i=0;i<ENDCONTROLTYPES;i++) { @@ -110,204 +111,178 @@ enum {cjoy, cdoublejoy, cAD_stick, cdial, ctrackball, cpaddle, clightgun, cpedal control[i].reverse = 0; } - while (input->type != IPT_END) - { - if (nplayer < input->player+1) - nplayer = input->player+1; - - switch (input->type) + for (port = portlist; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) { - case IPT_JOYSTICK_LEFT: - case IPT_JOYSTICK_RIGHT: - - /* if control not defined, start it off as horizontal 2-way */ - if (control[cjoy].Xway == NULL) - control[cjoy].Xway = "joy2way"; - else if (strcmp(control[cjoy].Xway,"joy2way") == 0) - ; - /* if already defined as vertical, make it 4 or 8 way */ - else if (strcmp(control[cjoy].Xway,"vjoy2way") == 0) - { - if (input->way == 4) - control[cjoy].Xway = "joy4way"; - else - control[cjoy].Xway = "joy8way"; - } - controlsyes = 1; - break; + if (nplayer < field->player+1) + nplayer = field->player+1; - case IPT_JOYSTICK_UP: - case IPT_JOYSTICK_DOWN: - - /* if control not defined, start it off as vertical 2-way */ - if (control[cjoy].Xway == NULL) - control[cjoy].Xway = "vjoy2way"; - else if (strcmp(control[cjoy].Xway,"vjoy2way") == 0) - ; - /* if already defined as horiz, make it 4 or 8way */ - else if (strcmp(control[cjoy].Xway,"joy2way") == 0) - { - if (input->way == 4) - control[cjoy].Xway = "joy4way"; - else - control[cjoy].Xway = "joy8way"; - } - controlsyes = 1; - break; - - case IPT_JOYSTICKRIGHT_UP: - case IPT_JOYSTICKRIGHT_DOWN: - case IPT_JOYSTICKLEFT_UP: - case IPT_JOYSTICKLEFT_DOWN: - - /* if control not defined, start it off as vertical 2way */ - if (control[cdoublejoy].Xway == NULL) - control[cdoublejoy].Xway = "vdoublejoy2way"; - else if (strcmp(control[cdoublejoy].Xway,"vdoublejoy2way") == 0) - ; - /* if already defined as horiz, make it 4 or 8 way */ - else if (strcmp(control[cdoublejoy].Xway,"doublejoy2way") == 0) - { - if (input->way == 4) - control[cdoublejoy].Xway = "doublejoy4way"; - else - control[cdoublejoy].Xway = "doublejoy8way"; - } - controlsyes = 1; - break; + switch (field->type) + { + case IPT_JOYSTICK_LEFT: + case IPT_JOYSTICK_RIGHT: + + /* if control not defined, start it off as horizontal 2-way */ + if (control[cjoy].Xway == NULL) + control[cjoy].Xway = "joy2way"; + else if (strcmp(control[cjoy].Xway,"joy2way") == 0) + ; + /* if already defined as vertical, make it 4 or 8 way */ + else if (strcmp(control[cjoy].Xway,"vjoy2way") == 0) + { + if (field->way == 4) + control[cjoy].Xway = "joy4way"; + else + control[cjoy].Xway = "joy8way"; + } + controlsyes = 1; + break; + + case IPT_JOYSTICK_UP: + case IPT_JOYSTICK_DOWN: + + /* if control not defined, start it off as vertical 2-way */ + if (control[cjoy].Xway == NULL) + control[cjoy].Xway = "vjoy2way"; + else if (strcmp(control[cjoy].Xway,"vjoy2way") == 0) + ; + /* if already defined as horiz, make it 4 or 8way */ + else if (strcmp(control[cjoy].Xway,"joy2way") == 0) + { + if (field->way == 4) + control[cjoy].Xway = "joy4way"; + else + control[cjoy].Xway = "joy8way"; + } + controlsyes = 1; + break; + + case IPT_JOYSTICKRIGHT_UP: + case IPT_JOYSTICKRIGHT_DOWN: + case IPT_JOYSTICKLEFT_UP: + case IPT_JOYSTICKLEFT_DOWN: + + /* if control not defined, start it off as vertical 2way */ + if (control[cdoublejoy].Xway == NULL) + control[cdoublejoy].Xway = "vdoublejoy2way"; + else if (strcmp(control[cdoublejoy].Xway,"vdoublejoy2way") == 0) + ; + /* if already defined as horiz, make it 4 or 8 way */ + else if (strcmp(control[cdoublejoy].Xway,"doublejoy2way") == 0) + { + if (field->way == 4) + control[cdoublejoy].Xway = "doublejoy4way"; + else + control[cdoublejoy].Xway = "doublejoy8way"; + } + controlsyes = 1; + break; + + case IPT_JOYSTICKRIGHT_LEFT: + case IPT_JOYSTICKRIGHT_RIGHT: + case IPT_JOYSTICKLEFT_LEFT: + case IPT_JOYSTICKLEFT_RIGHT: + + /* if control not defined, start it off as horiz 2-way */ + if (control[cdoublejoy].Xway == NULL) + control[cdoublejoy].Xway = "doublejoy2way"; + else if (strcmp(control[cdoublejoy].Xway,"doublejoy2way") == 0) + ; + /* if already defined as vertical, make it 4 or 8 way */ + else if (strcmp(control[cdoublejoy].Xway,"vdoublejoy2way") == 0) + { + if (field->way == 4) + control[cdoublejoy].Xway = "doublejoy4way"; + else + control[cdoublejoy].Xway = "doublejoy8way"; + } + controlsyes = 1; + break; + + /* mark as an analog input, and get analog stats after switch */ + case IPT_PADDLE: + analogcontrol = cpaddle; + break; + case IPT_DIAL: + analogcontrol = cdial; + break; + case IPT_TRACKBALL_X: + case IPT_TRACKBALL_Y: + analogcontrol = ctrackball; + break; + case IPT_AD_STICK_X: + case IPT_AD_STICK_Y: + analogcontrol = cAD_stick; + break; + case IPT_LIGHTGUN_X: + case IPT_LIGHTGUN_Y: + analogcontrol = clightgun; + break; + case IPT_PEDAL: + case IPT_PEDAL2: + case IPT_PEDAL3: + analogcontrol = cpedal; + break; + + case IPT_BUTTON1: + case IPT_BUTTON2: + case IPT_BUTTON3: + case IPT_BUTTON4: + case IPT_BUTTON5: + case IPT_BUTTON6: + case IPT_BUTTON7: + case IPT_BUTTON8: + case IPT_BUTTON9: + case IPT_BUTTON10: + case IPT_BUTTON11: + case IPT_BUTTON12: + case IPT_BUTTON13: + case IPT_BUTTON14: + case IPT_BUTTON15: + case IPT_BUTTON16: + nbutton = MAX(nbutton, field->type - IPT_BUTTON1 + 1); + break; + + case IPT_COIN1: + case IPT_COIN2: + case IPT_COIN3: + case IPT_COIN4: + case IPT_COIN5: + case IPT_COIN6: + case IPT_COIN7: + case IPT_COIN8: + ncoin = MAX(ncoin, field->type - IPT_COIN1 + 1); + + case IPT_SERVICE : + service = "yes"; + break; + + case IPT_TILT : + tilt = "yes"; + break; + } - case IPT_JOYSTICKRIGHT_LEFT: - case IPT_JOYSTICKRIGHT_RIGHT: - case IPT_JOYSTICKLEFT_LEFT: - case IPT_JOYSTICKLEFT_RIGHT: - - /* if control not defined, start it off as horiz 2-way */ - if (control[cdoublejoy].Xway == NULL) - control[cdoublejoy].Xway = "doublejoy2way"; - else if (strcmp(control[cdoublejoy].Xway,"doublejoy2way") == 0) - ; - /* if already defined as vertical, make it 4 or 8 way */ - else if (strcmp(control[cdoublejoy].Xway,"vdoublejoy2way") == 0) - { - if (input->way == 4) - control[cdoublejoy].Xway = "doublejoy4way"; - else - control[cdoublejoy].Xway = "doublejoy8way"; - } + /* get the analog stats */ + if (analogcontrol) + { controlsyes = 1; - break; - - /* mark as an analog input, and get analog stats after switch */ - case IPT_PADDLE: - analogcontrol = cpaddle; - break; - case IPT_DIAL: - analogcontrol = cdial; - break; - case IPT_TRACKBALL_X: - case IPT_TRACKBALL_Y: - analogcontrol = ctrackball; - break; - case IPT_AD_STICK_X: - case IPT_AD_STICK_Y: - analogcontrol = cAD_stick; - break; - case IPT_LIGHTGUN_X: - case IPT_LIGHTGUN_Y: - analogcontrol = clightgun; - break; - case IPT_PEDAL: - case IPT_PEDAL2: - case IPT_PEDAL3: - analogcontrol = cpedal; - break; - - case IPT_BUTTON1: - if (nbutton<1) nbutton = 1; - break; - case IPT_BUTTON2: - if (nbutton<2) nbutton = 2; - break; - case IPT_BUTTON3: - if (nbutton<3) nbutton = 3; - break; - case IPT_BUTTON4: - if (nbutton<4) nbutton = 4; - break; - case IPT_BUTTON5: - if (nbutton<5) nbutton = 5; - break; - case IPT_BUTTON6: - if (nbutton<6) nbutton = 6; - break; - case IPT_BUTTON7: - if (nbutton<7) nbutton = 7; - break; - case IPT_BUTTON8: - if (nbutton<8) nbutton = 8; - break; - case IPT_BUTTON9: - if (nbutton<9) nbutton = 9; - break; - case IPT_BUTTON10: - if (nbutton<10) nbutton = 10; - break; - - case IPT_COIN1: - if (ncoin < 1) ncoin = 1; - break; - case IPT_COIN2: - if (ncoin < 2) ncoin = 2; - break; - case IPT_COIN3: - if (ncoin < 3) ncoin = 3; - break; - case IPT_COIN4: - if (ncoin < 4) ncoin = 4; - break; - case IPT_COIN5: - if (ncoin < 5) ncoin = 5; - break; - case IPT_COIN6: - if (ncoin < 6) ncoin = 6; - break; - case IPT_COIN7: - if (ncoin < 7) ncoin = 7; - break; - case IPT_COIN8: - if (ncoin < 8) ncoin = 8; - break; - case IPT_SERVICE : - service = "yes"; - break; - case IPT_TILT : - tilt = "yes"; - break; - } - - /* get the analog stats */ - if (analogcontrol) - { - controlsyes = 1; - control[analogcontrol].analog = 1; - - if (input->analog.min) - control[analogcontrol].min = input->analog.min; - if (input->analog.max) - control[analogcontrol].max = input->analog.max; - if (input->analog.sensitivity) - control[analogcontrol].sensitivity = input->analog.sensitivity; - if (input->analog.delta) - control[analogcontrol].keydelta = input->analog.delta; - if (input->analog.reverse) - control[analogcontrol].reverse = 1; - - analogcontrol = 0; + control[analogcontrol].analog = 1; + + if (field->min) + control[analogcontrol].min = field->min; + if (field->max) + control[analogcontrol].max = field->max; + if (field->sensitivity) + control[analogcontrol].sensitivity = field->sensitivity; + if (field->delta) + control[analogcontrol].keydelta = field->delta; + if (field->flags & ANALOG_FLAG_REVERSE) + control[analogcontrol].reverse = 1; + + analogcontrol = 0; + } } - ++input; - } - fprintf(out, "\t\t<input"); fprintf(out, " players=\"%d\"", nplayer); if (nbutton != 0) @@ -856,7 +831,7 @@ static void print_game_driver(FILE *out, const game_driver *game, const machine_ static void print_game_info(FILE *out, const game_driver *game) { - const input_port_entry *input; + const input_port_config *portconfig; const game_driver *clone_of; machine_config *config; const char *start; @@ -866,13 +841,12 @@ static void print_game_info(FILE *out, const game_driver *game) return; /* start tracking resources and allocate the machine and input configs */ - begin_resource_tracking(); config = machine_config_alloc(game->machine_config); #ifdef MESS /* temporary hook until MESS device transition is complete */ mess_devices_setup(config, game); #endif /* MESS */ - input = input_port_allocate(game->ipt, NULL); + portconfig = input_port_config_alloc(game->ipt); /* print the header and the game name */ fprintf(out, "\t<" XML_TOP); @@ -922,8 +896,8 @@ static void print_game_info(FILE *out, const game_driver *game) print_game_chips(out, game, config); print_game_display(out, game, config); print_game_sound(out, game, config); - print_game_input(out, game, input); - print_game_switches(out, game, input); + print_game_input(out, game, portconfig); + print_game_switches(out, game, portconfig); print_game_driver(out, game, config); #ifdef MESS print_game_device(out, game, config); @@ -933,8 +907,7 @@ static void print_game_info(FILE *out, const game_driver *game) /* close the topmost tag */ fprintf(out, "\t</" XML_TOP ">\n"); - /* release resources */ - end_resource_tracking(); + input_port_config_free(portconfig); machine_config_free(config); } diff --git a/src/emu/inptport.c b/src/emu/inptport.c index 8f994727f58..ce2e2ac345f 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -130,92 +130,132 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef struct _analog_port_info analog_port_info; -struct _analog_port_info -{ - analog_port_info * next; /* linked list */ - input_port_entry * portentry; /* pointer to the input port entry referenced */ - INT32 accum; /* accumulated value (including relative adjustments) */ - INT32 previous; /* previous adjusted value */ - INT32 previousanalog; /* previous analog value */ - INT32 minimum; /* minimum adjusted value */ - INT32 maximum; /* maximum adjusted value */ - INT32 center; /* center adjusted value for autocentering */ - INT32 reverse_val; /* value where we subtract from to reverse directions */ - INT64 scalepos; /* scale factor to apply to positive adjusted values */ - INT64 scaleneg; /* scale factor to apply to negative adjusted values */ - INT64 keyscalepos; /* scale factor to apply to the key delta field when pos */ - INT64 keyscaleneg; /* scale factor to apply to the key delta field when neg */ - INT64 positionalscale; /* scale factor to divide a joystick into positions */ - UINT8 shift; /* left shift to apply to the final result */ - UINT8 bits; /* how many bits of resolution are expected? */ - UINT8 absolute; /* is this an absolute or relative input? */ - UINT8 wraps; /* does the control wrap around? */ - UINT8 one_of_x; /* is this a 1 of X positional input? */ - UINT8 autocenter; /* autocenter this input? */ - UINT8 single_scale; /* scale joystick differently if default is between min/max */ - UINT8 interpolate; /* should we do linear interpolation for mid-frame reads? */ - UINT8 lastdigital; /* was the last modification caused by a digital form? */ +/* live analog field information */ +typedef struct _analog_field_state analog_field_state; +struct _analog_field_state +{ + analog_field_state * next; /* link to the next analog state for this port */ + const input_field_config * field; /* pointer to the input field referenced */ + + /* adjusted values (right-justified and tweaked) */ + UINT8 shift; /* shift to align final value in the port */ + INT32 adjdefvalue; /* adjusted default value from the config */ + INT32 adjmin; /* adjusted minimum value from the config */ + INT32 adjmax; /* adjusted maximum value from the config */ + + /* live values of configurable parameters */ + INT32 sensitivity; /* current live sensitivity (100=normal) */ + UINT8 reverse; /* current live reverse flag */ + INT32 delta; /* current live delta to apply each frame a digital inc/dec key is pressed */ + INT32 centerdelta; /* current live delta to apply each frame no digital inputs are pressed */ + + /* live analog value tracking */ + INT32 accum; /* accumulated value (including relative adjustments) */ + INT32 previous; /* previous adjusted value */ + INT32 previousanalog; /* previous analog value */ + + /* parameters for modifying live values */ + INT32 minimum; /* minimum adjusted value */ + INT32 maximum; /* maximum adjusted value */ + INT32 center; /* center adjusted value for autocentering */ + INT32 reverse_val; /* value where we subtract from to reverse directions */ + + /* scaling factors */ + INT64 scalepos; /* scale factor to apply to positive adjusted values */ + INT64 scaleneg; /* scale factor to apply to negative adjusted values */ + INT64 keyscalepos; /* scale factor to apply to the key delta field when pos */ + INT64 keyscaleneg; /* scale factor to apply to the key delta field when neg */ + INT64 positionalscale; /* scale factor to divide a joystick into positions */ + + /* misc flags */ + UINT8 absolute; /* is this an absolute or relative input? */ + UINT8 wraps; /* does the control wrap around? */ + UINT8 autocenter; /* autocenter this input? */ + UINT8 single_scale; /* scale joystick differently if default is between min/max */ + UINT8 interpolate; /* should we do linear interpolation for mid-frame reads? */ + UINT8 lastdigital; /* was the last modification caused by a digital form? */ }; -typedef struct _custom_port_info custom_port_info; -struct _custom_port_info +/* shared digital joystick state */ +typedef struct _digital_joystick_state digital_joystick_state; +struct _digital_joystick_state { - custom_port_info * next; /* linked list */ - input_port_entry * portentry; /* pointer to the input port entry referenced */ - UINT8 shift; /* left shift to apply to the final result */ + const input_field_config * field[4]; /* input field for up, down, left, right respectively */ + UINT8 inuse; /* is this joystick used? */ + UINT8 current; /* current value */ + UINT8 current4way; /* current 4-way value */ + UINT8 previous; /* previous value */ }; -typedef struct _changed_port_info changed_port_info; -struct _changed_port_info +/* live custom/changed field information */ +typedef struct _callback_field_info callback_field_info; +struct _callback_field_info { - changed_port_info * next; /* linked list */ - input_port_entry * portentry; /* pointer to the input port entry referenced */ - UINT8 shift; /* right shift to apply before calling callback */ + callback_field_info * next; /* linked list of info for this port */ + const input_field_config * field; /* pointer to the input field referenced */ + UINT8 shift; /* shift to apply to the final result */ }; -typedef struct _input_bit_info input_bit_info; -struct _input_bit_info +/* internal live state of an input field */ +struct _input_field_state { - input_port_entry * portentry; /* port entry for this input */ - UINT8 impulse; /* counter for impulse controls */ - UINT8 last; /* were we pressed last time? */ + analog_field_state * analog; /* pointer to live analog data if this is an analog field */ + digital_joystick_state * joystick; /* pointer to digital joystick information */ + input_seq seq[SEQ_TYPE_TOTAL];/* currently configured input sequences */ + input_port_value value; /* current value of this port */ + UINT8 impulse; /* counter for impulse controls */ + UINT8 last; /* were we pressed last time? */ + UINT8 toggle; /* current toggle state */ + UINT8 joydir; /* digital joystick direction index */ }; -typedef struct _input_port_info input_port_info; -struct _input_port_info +/* internal live state of an input port */ +struct _input_port_state { - const char * tag; /* tag for this port */ - UINT32 defvalue; /* default value of all the bits */ - UINT32 digital; /* value from digital inputs */ - UINT32 vblank; /* value of all IPT_VBLANK bits */ - input_bit_info bit[MAX_BITS_PER_PORT]; /* info about each bit in the port */ - analog_port_info * analoginfo; /* pointer to linked list of analog port info */ - custom_port_info * custominfo; /* pointer to linked list of custom port info */ - changed_port_info * changedinfo; /* pointer to linked list of changed port info */ + analog_field_state * analoglist; /* pointer to list of analog port info */ + callback_field_info * customlist; /* pointer to list of custom port info */ + callback_field_info * changedlist; /* pointer to list of changed port info */ + input_port_value defvalue; /* combined default value across the port */ + input_port_value digital; /* current value from all digital inputs */ + input_port_value vblank; /* value of all IPT_VBLANK bits */ + input_port_value lastvalue; /* last value of the port, to detect changes */ }; -typedef struct _digital_joystick_info digital_joystick_info; -struct _digital_joystick_info +/* internal live state of an input type */ +typedef struct _input_type_state input_type_state; +struct _input_type_state { - input_port_entry * portentry[4]; /* port entry for up,down,left,right respectively */ - UINT8 inuse; /* is this joystick used? */ - UINT8 current; /* current value */ - UINT8 current4way; /* current 4-way value */ - UINT8 previous; /* previous value */ + input_type_state * next; /* pointer to the next live state in the list */ + input_type_desc typedesc; /* copy of the original description, modified by the OSD */ + input_seq seq[SEQ_TYPE_TOTAL];/* currently configured sequences */ }; -struct _input_port_init_params -{ - input_port_entry * ports; /* base of the port array */ - int max_ports; /* maximum number of ports we can support */ - int current_port; /* current port index */ +/* private input port state */ +struct _input_port_private +{ + /* types */ + input_type_state * typestatelist; /* list of live type states */ + input_type_state * type_to_typestate[__ipt_max][MAX_PLAYERS]; /* map from type/player to type state */ + + /* specific special global input states */ + digital_joystick_state joystick_info[MAX_PLAYERS][DIGITAL_JOYSTICKS_PER_PLAYER]; /* joystick states */ + osd_ticks_t ui_memory[__ipt_max];/* keypress timing for UI */ + + /* frame time tracking */ + attotime last_frame_time; /* time of the last frame callback */ + attoseconds_t last_delta_nsec; /* nanoseconds that passed since the previous callback */ + + /* playback/record information */ + mame_file * record_file; /* recording file (NULL if not recording) */ + mame_file * playback_file; /* playback file (NULL if not recording) */ + UINT64 playback_accumulated_speed;/* accumulated speed during playback */ + UINT32 playback_accumulated_frames;/* accumulated frames during playback */ }; @@ -224,11 +264,6 @@ struct _input_port_init_params MACROS ***************************************************************************/ -#define IS_ANALOG(in) ((in)->type >= __ipt_analog_start && (in)->type <= __ipt_analog_end) -#define IS_DIGITAL_JOYSTICK(in) ((in)->type >= __ipt_digital_joystick_start && (in)->type <= __ipt_digital_joystick_end) -#define JOYSTICK_INFO_FOR_PORT(in) (&joystick_info[(in)->player][((in)->type - __ipt_digital_joystick_start) / 4]) -#define JOYSTICK_DIR_FOR_PORT(in) (((in)->type - __ipt_digital_joystick_start) % 4) - #define APPLY_SENSITIVITY(x,s) (((INT64)(x) * (s)) / 100) #define APPLY_INVERSE_SENSITIVITY(x,s) (((INT64)(x) * 100) / (s)) @@ -242,29 +277,9 @@ struct _input_port_init_params GLOBAL VARIABLES ***************************************************************************/ -/* current value of all the ports */ -static input_port_info port_info[MAX_INPUT_PORTS]; - -/* additiona tracking information for special types of controls */ -static digital_joystick_info joystick_info[MAX_PLAYERS][DIGITAL_JOYSTICKS_PER_PLAYER]; - -/* memory for UI keys */ -static UINT8 ui_memory[__ipt_max]; - /* XML attributes for the different types */ static const char *const seqtypestrings[] = { "standard", "decrement", "increment" }; -/* original input_ports without modifications */ -static input_port_entry *input_ports_default; - -/* for scaling analog ports */ -static attotime last_update; -static attoseconds_t last_delta; - -/* playback information */ -static UINT64 playback_accumulated_speed; -static UINT32 playback_accumulated_frames; - /*************************************************************************** @@ -434,595 +449,10 @@ static const struct /*************************************************************************** - DEFAULT INPUT PORTS + BUILT-IN CORE MAPPINGS ***************************************************************************/ -#define INPUT_PORT_DIGITAL_DEF(player_,group_,type_,name_,seq_) \ - { IPT_##type_, group_, (player_ == 0) ? player_ : (player_) - 1, (player_ == 0) ? #type_ : ("P" #player_ "_" #type_), name_, seq_, SEQ_DEF_0, SEQ_DEF_0 }, - -#define INPUT_PORT_ANALOG_DEF(player_,group_,type_,name_,seq_,decseq_,incseq_) \ - { IPT_##type_, group_, (player_ == 0) ? player_ : (player_) - 1, (player_ == 0) ? #type_ : ("P" #player_ "_" #type_), name_, seq_, incseq_, decseq_ }, - -#define INDEXED(a,b) INPUT_CODE_SET_DEVINDEX(a,b) - -static const input_port_default_entry default_ports_builtin[] = -{ - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_UP, "P1 Up", SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_DOWN, "P1 Down", SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_LEFT, "P1 Left", SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_RIGHT, "P1 Right", SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_UP, "P1 Right/Up", SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_DOWN, "P1 Right/Down", SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_LEFT, "P1 Right/Left", SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_RIGHT,"P1 Right/Right", SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKLEFT_UP, "P1 Left/Up", SEQ_DEF_3(KEYCODE_E, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKLEFT_DOWN, "P1 Left/Down", SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKLEFT_LEFT, "P1 Left/Left", SEQ_DEF_3(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKLEFT_RIGHT, "P1 Left/Right", SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON1, "P1 Button 1", SEQ_DEF_7(KEYCODE_LCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON1, 0), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON2, "P1 Button 2", SEQ_DEF_7(KEYCODE_LALT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON3, 0), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON3, "P1 Button 3", SEQ_DEF_5(KEYCODE_SPACE, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON2, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON4, "P1 Button 4", SEQ_DEF_3(KEYCODE_LSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON5, "P1 Button 5", SEQ_DEF_3(KEYCODE_Z, SEQCODE_OR, INDEXED(JOYCODE_BUTTON5, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON6, "P1 Button 6", SEQ_DEF_3(KEYCODE_X, SEQCODE_OR, INDEXED(JOYCODE_BUTTON6, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON7, "P1 Button 7", SEQ_DEF_3(KEYCODE_C, SEQCODE_OR, INDEXED(JOYCODE_BUTTON7, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON8, "P1 Button 8", SEQ_DEF_3(KEYCODE_V, SEQCODE_OR, INDEXED(JOYCODE_BUTTON8, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON9, "P1 Button 9", SEQ_DEF_3(KEYCODE_B, SEQCODE_OR, INDEXED(JOYCODE_BUTTON9, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON10, "P1 Button 10", SEQ_DEF_3(KEYCODE_N, SEQCODE_OR, INDEXED(JOYCODE_BUTTON10, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON11, "P1 Button 11", SEQ_DEF_3(KEYCODE_M, SEQCODE_OR, INDEXED(JOYCODE_BUTTON11, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON12, "P1 Button 12", SEQ_DEF_3(KEYCODE_COMMA, SEQCODE_OR, INDEXED(JOYCODE_BUTTON12, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON13, "P1 Button 13", SEQ_DEF_3(KEYCODE_STOP, SEQCODE_OR, INDEXED(JOYCODE_BUTTON13, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON14, "P1 Button 14", SEQ_DEF_3(KEYCODE_SLASH, SEQCODE_OR, INDEXED(JOYCODE_BUTTON14, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON15, "P1 Button 15", SEQ_DEF_3(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON15, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON16, "P1 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, START, "P1 Start", SEQ_DEF_3(KEYCODE_1, SEQCODE_OR, INDEXED(JOYCODE_START, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, SELECT, "P1 Select", SEQ_DEF_3(KEYCODE_5, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 0)) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_A, "P1 Mahjong A", SEQ_DEF_1(KEYCODE_A) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_B, "P1 Mahjong B", SEQ_DEF_1(KEYCODE_B) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_C, "P1 Mahjong C", SEQ_DEF_1(KEYCODE_C) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_D, "P1 Mahjong D", SEQ_DEF_1(KEYCODE_D) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_E, "P1 Mahjong E", SEQ_DEF_1(KEYCODE_E) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_F, "P1 Mahjong F", SEQ_DEF_1(KEYCODE_F) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_G, "P1 Mahjong G", SEQ_DEF_1(KEYCODE_G) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_H, "P1 Mahjong H", SEQ_DEF_1(KEYCODE_H) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_I, "P1 Mahjong I", SEQ_DEF_1(KEYCODE_I) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_J, "P1 Mahjong J", SEQ_DEF_1(KEYCODE_J) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_K, "P1 Mahjong K", SEQ_DEF_1(KEYCODE_K) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_L, "P1 Mahjong L", SEQ_DEF_1(KEYCODE_L) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_M, "P1 Mahjong M", SEQ_DEF_1(KEYCODE_M) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_N, "P1 Mahjong N", SEQ_DEF_1(KEYCODE_N) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_O, "P1 Mahjong O", SEQ_DEF_1(KEYCODE_O) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_P, "P1 Mahjong P", SEQ_DEF_1(KEYCODE_COLON) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_Q, "P1 Mahjong Q", SEQ_DEF_1(KEYCODE_Q) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_KAN, "P1 Mahjong Kan", SEQ_DEF_1(KEYCODE_LCONTROL) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_PON, "P1 Mahjong Pon", SEQ_DEF_1(KEYCODE_LALT) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_CHI, "P1 Mahjong Chi", SEQ_DEF_1(KEYCODE_SPACE) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_REACH, "P1 Mahjong Reach", SEQ_DEF_1(KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_RON, "P1 Mahjong Ron", SEQ_DEF_1(KEYCODE_Z) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_BET, "P1 Mahjong Bet", SEQ_DEF_1(KEYCODE_2) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_LAST_CHANCE,"P1 Mahjong Last Chance",SEQ_DEF_1(KEYCODE_RALT) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_SCORE, "P1 Mahjong Score", SEQ_DEF_1(KEYCODE_RCONTROL) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_DOUBLE_UP, "P1 Mahjong Double Up", SEQ_DEF_1(KEYCODE_RSHIFT) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_FLIP_FLOP, "P1 Mahjong Flip Flop", SEQ_DEF_1(KEYCODE_Y) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_BIG, "P1 Mahjong Big", SEQ_DEF_1(KEYCODE_ENTER) ) - INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_SMALL, "P1 Mahjong Small", SEQ_DEF_1(KEYCODE_BACKSPACE) ) - - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_UP, "P2 Up", SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_DOWN, "P2 Down", SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_LEFT, "P2 Left", SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_RIGHT, "P2 Right", SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_UP, "P2 Right/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_DOWN, "P2 Right/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_LEFT, "P2 Right/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_RIGHT,"P2 Right/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKLEFT_UP, "P2 Left/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKLEFT_DOWN, "P2 Left/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKLEFT_LEFT, "P2 Left/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKLEFT_RIGHT, "P2 Left/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON1, "P2 Button 1", SEQ_DEF_7(KEYCODE_A, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON1, 1), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON2, "P2 Button 2", SEQ_DEF_7(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON3, 1), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON3, "P2 Button 3", SEQ_DEF_5(KEYCODE_Q, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON2, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON4, "P2 Button 4", SEQ_DEF_3(KEYCODE_W, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON5, "P2 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON6, "P2 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON7, "P2 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON8, "P2 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON9, "P2 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON10, "P2 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON11, "P2 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON12, "P2 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON13, "P2 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON14, "P2 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON15, "P2 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON16, "P2 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, START, "P2 Start", SEQ_DEF_3(KEYCODE_2, SEQCODE_OR, INDEXED(JOYCODE_START, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, SELECT, "P2 Select", SEQ_DEF_3(KEYCODE_6, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 1)) ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_A, "P2 Mahjong A", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_B, "P2 Mahjong B", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_C, "P2 Mahjong C", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_D, "P2 Mahjong D", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_E, "P2 Mahjong E", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_F, "P2 Mahjong F", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_G, "P2 Mahjong G", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_H, "P2 Mahjong H", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_I, "P2 Mahjong I", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_J, "P2 Mahjong J", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_K, "P2 Mahjong K", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_L, "P2 Mahjong L", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_M, "P2 Mahjong M", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_N, "P2 Mahjong N", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_O, "P2 Mahjong O", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_P, "P2 Mahjong P", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_Q, "P2 Mahjong Q", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_KAN, "P2 Mahjong Kan", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_PON, "P2 Mahjong Pon", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_CHI, "P2 Mahjong Chi", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_REACH, "P2 Mahjong Reach", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_RON, "P2 Mahjong Ron", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_BET, "P2 Mahjong Bet", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_LAST_CHANCE,"P2 Mahjong Last Chance",SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_SCORE, "P2 Mahjong Score", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_DOUBLE_UP, "P2 Mahjong Double Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_FLIP_FLOP, "P2 Mahjong Flip Flop", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_BIG, "P2 Mahjong Big", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_SMALL, "P2 Mahjong Small", SEQ_DEF_0 ) - - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICK_UP, "P3 Up", SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICK_DOWN, "P3 Down", SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICK_LEFT, "P3 Left", SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICK_RIGHT, "P3 Right", SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKRIGHT_UP, "P3 Right/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKRIGHT_DOWN, "P3 Right/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKRIGHT_LEFT, "P3 Right/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKRIGHT_RIGHT,"P3 Right/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKLEFT_UP, "P3 Left/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKLEFT_DOWN, "P3 Left/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKLEFT_LEFT, "P3 Left/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKLEFT_RIGHT, "P3 Left/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON1, "P3 Button 1", SEQ_DEF_5(KEYCODE_RCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 2), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON2, "P3 Button 2", SEQ_DEF_5(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 2), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON3, "P3 Button 3", SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON4, "P3 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON5, "P3 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON6, "P3 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON7, "P3 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON8, "P3 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON9, "P3 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON10, "P3 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON11, "P3 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON12, "P3 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON13, "P3 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON14, "P3 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON15, "P3 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON16, "P3 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, START, "P3 Start", SEQ_DEF_3(KEYCODE_3, SEQCODE_OR, INDEXED(JOYCODE_START, 2)) ) - INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, SELECT, "P3 Select", SEQ_DEF_3(KEYCODE_7, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 2)) ) - - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICK_UP, "P4 Up", SEQ_DEF_3(KEYCODE_8_PAD, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICK_DOWN, "P4 Down", SEQ_DEF_3(KEYCODE_2_PAD, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICK_LEFT, "P4 Left", SEQ_DEF_3(KEYCODE_4_PAD, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICK_RIGHT, "P4 Right", SEQ_DEF_3(KEYCODE_6_PAD, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKRIGHT_UP, "P4 Right/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKRIGHT_DOWN, "P4 Right/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKRIGHT_LEFT, "P4 Right/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKRIGHT_RIGHT,"P4 Right/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKLEFT_UP, "P4 Left/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKLEFT_DOWN, "P4 Left/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKLEFT_LEFT, "P4 Left/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKLEFT_RIGHT, "P4 Left/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON1, "P4 Button 1", SEQ_DEF_3(KEYCODE_0_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON2, "P4 Button 2", SEQ_DEF_3(KEYCODE_DEL_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON3, "P4 Button 3", SEQ_DEF_3(KEYCODE_ENTER_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON4, "P4 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON5, "P4 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON6, "P4 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON7, "P4 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON8, "P4 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON9, "P4 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON10, "P4 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON11, "P4 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON12, "P4 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON13, "P4 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON14, "P4 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON15, "P4 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON16, "P4 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, START, "P4 Start", SEQ_DEF_3(KEYCODE_4, SEQCODE_OR, INDEXED(JOYCODE_START, 3)) ) - INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, SELECT, "P4 Select", SEQ_DEF_3(KEYCODE_8, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 3)) ) - - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICK_UP, "P5 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICK_DOWN, "P5 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICK_LEFT, "P5 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICK_RIGHT, "P5 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKRIGHT_UP, "P5 Right/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKRIGHT_DOWN, "P5 Right/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKRIGHT_LEFT, "P5 Right/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKRIGHT_RIGHT,"P5 Right/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKLEFT_UP, "P5 Left/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKLEFT_DOWN, "P5 Left/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKLEFT_LEFT, "P5 Left/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKLEFT_RIGHT, "P5 Left/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON1, "P5 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON2, "P5 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON3, "P5 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON4, "P5 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON5, "P5 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON6, "P5 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON7, "P5 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON8, "P5 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON9, "P5 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON10, "P5 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON11, "P5 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON12, "P5 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON13, "P5 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON14, "P5 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON15, "P5 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON16, "P5 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 4)) ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, START, "P5 Start", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, SELECT, "P5 Select", SEQ_DEF_0 ) - - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICK_UP, "P6 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICK_DOWN, "P6 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICK_LEFT, "P6 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICK_RIGHT, "P6 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKRIGHT_UP, "P6 Right/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKRIGHT_DOWN, "P6 Right/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKRIGHT_LEFT, "P6 Right/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKRIGHT_RIGHT,"P6 Right/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKLEFT_UP, "P6 Left/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKLEFT_DOWN, "P6 Left/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKLEFT_LEFT, "P6 Left/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKLEFT_RIGHT, "P6 Left/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON1, "P6 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON2, "P6 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON3, "P6 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON4, "P6 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON5, "P6 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON6, "P6 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON7, "P6 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON8, "P6 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON9, "P6 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON10, "P6 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON11, "P6 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON12, "P6 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON13, "P6 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON14, "P6 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON15, "P6 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON16, "P6 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 5)) ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, START, "P6 Start", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, SELECT, "P6 Select", SEQ_DEF_0 ) - - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICK_UP, "P7 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICK_DOWN, "P7 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICK_LEFT, "P7 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICK_RIGHT, "P7 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKRIGHT_UP, "P7 Right/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKRIGHT_DOWN, "P7 Right/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKRIGHT_LEFT, "P7 Right/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKRIGHT_RIGHT,"P7 Right/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKLEFT_UP, "P7 Left/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKLEFT_DOWN, "P7 Left/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKLEFT_LEFT, "P7 Left/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKLEFT_RIGHT, "P7 Left/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON1, "P7 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON2, "P7 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON3, "P7 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON4, "P7 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON5, "P7 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON6, "P7 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON7, "P7 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON8, "P7 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON9, "P7 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON10, "P7 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON11, "P7 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON12, "P7 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON13, "P7 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON14, "P7 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON15, "P7 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON16, "P7 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 6)) ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, START, "P7 Start", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, SELECT, "P7 Select", SEQ_DEF_0 ) - - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICK_UP, "P8 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICK_DOWN, "P8 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICK_LEFT, "P8 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICK_RIGHT, "P8 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKRIGHT_UP, "P8 Right/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKRIGHT_DOWN, "P8 Right/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKRIGHT_LEFT, "P8 Right/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKRIGHT_RIGHT,"P8 Right/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKLEFT_UP, "P8 Left/Up", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKLEFT_DOWN, "P8 Left/Down", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKLEFT_LEFT, "P8 Left/Left", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKLEFT_RIGHT, "P8 Left/Right", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON1, "P8 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON2, "P8 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON3, "P8 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON4, "P8 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON5, "P8 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON6, "P8 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON7, "P8 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON8, "P8 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON9, "P8 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON10, "P8 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON11, "P8 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON12, "P8 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON13, "P8 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON14, "P8 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON15, "P8 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON16, "P8 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 7)) ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, START, "P8 Start", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, SELECT, "P8 Select", SEQ_DEF_0 ) - - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START1, "1 Player Start", SEQ_DEF_3(KEYCODE_1, SEQCODE_OR, INDEXED(JOYCODE_START, 0)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START2, "2 Players Start", SEQ_DEF_3(KEYCODE_2, SEQCODE_OR, INDEXED(JOYCODE_START, 1)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START3, "3 Players Start", SEQ_DEF_3(KEYCODE_3, SEQCODE_OR, INDEXED(JOYCODE_START, 2)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START4, "4 Players Start", SEQ_DEF_3(KEYCODE_4, SEQCODE_OR, INDEXED(JOYCODE_START, 3)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START5, "5 Players Start", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START6, "6 Players Start", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START7, "7 Players Start", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START8, "8 Players Start", SEQ_DEF_0 ) - - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN1, "Coin 1", SEQ_DEF_3(KEYCODE_5, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 0)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN2, "Coin 2", SEQ_DEF_3(KEYCODE_6, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 1)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN3, "Coin 3", SEQ_DEF_3(KEYCODE_7, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 2)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN4, "Coin 4", SEQ_DEF_3(KEYCODE_8, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 3)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN5, "Coin 5", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN6, "Coin 6", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN7, "Coin 7", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN8, "Coin 8", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, BILL1, "Bill 1", SEQ_DEF_1(KEYCODE_BACKSPACE) ) - - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, SERVICE1, "Service 1", SEQ_DEF_1(KEYCODE_9) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, SERVICE2, "Service 2", SEQ_DEF_1(KEYCODE_0) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, SERVICE3, "Service 3", SEQ_DEF_1(KEYCODE_MINUS) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, SERVICE4, "Service 4", SEQ_DEF_1(KEYCODE_EQUALS) ) - - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, SERVICE, "Service", SEQ_DEF_1(KEYCODE_F2) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, TILT, "Tilt", SEQ_DEF_1(KEYCODE_T) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, INTERLOCK, "Door Interlock", SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, VOLUME_DOWN, "Volume Down", SEQ_DEF_1(KEYCODE_MINUS) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, VOLUME_UP, "Volume Up", SEQ_DEF_1(KEYCODE_EQUALS) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, PEDAL, "P1 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 0)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_LCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, PEDAL, "P2 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 1)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_A, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, PEDAL, "P3 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 2)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_RCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, PEDAL, "P4 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 3)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_0_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, PEDAL, "P5 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 4)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, PEDAL, "P6 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 5)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, PEDAL, "P7 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 6)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, PEDAL, "P8 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 7)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, PEDAL2, "P1 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 0)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_LALT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, PEDAL2, "P2 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 1)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, PEDAL2, "P3 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 2)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, PEDAL2, "P4 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 3)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_DEL_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, PEDAL2, "P5 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 4)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, PEDAL2, "P6 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 5)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, PEDAL2, "P7 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 6)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, PEDAL2, "P8 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 7)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, PEDAL3, "P1 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_SPACE, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, PEDAL3, "P2 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_Q, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, PEDAL3, "P3 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, PEDAL3, "P4 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_ENTER_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, PEDAL3, "P5 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, PEDAL3, "P6 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, PEDAL3, "P7 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, PEDAL3, "P8 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, PADDLE, "Paddle", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, PADDLE, "Paddle 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, PADDLE, "Paddle 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, PADDLE, "Paddle 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, PADDLE, "Paddle 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, PADDLE, "Paddle 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, PADDLE, "Paddle 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, PADDLE, "Paddle 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, PADDLE_V, "Paddle V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, PADDLE_V, "Paddle V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, PADDLE_V, "Paddle V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, PADDLE_V, "Paddle V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, PADDLE_V, "Paddle V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, PADDLE_V, "Paddle V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, PADDLE_V, "Paddle V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, PADDLE_V, "Paddle V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, POSITIONAL, "Positional", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, POSITIONAL, "Positional 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, POSITIONAL, "Positional 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, POSITIONAL, "Positional 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, POSITIONAL, "Positional 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, POSITIONAL, "Positional 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, POSITIONAL, "Positional 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, POSITIONAL, "Positional 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, POSITIONAL_V, "Positional V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, POSITIONAL_V, "Positional V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, POSITIONAL_V, "Positional V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, POSITIONAL_V, "Positional V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, POSITIONAL_V, "Positional V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, POSITIONAL_V, "Positional V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, POSITIONAL_V, "Positional V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, POSITIONAL_V, "Positional V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, DIAL, "Dial", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, DIAL, "Dial 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, DIAL, "Dial 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, DIAL, "Dial 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, DIAL, "Dial 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, DIAL, "Dial 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, DIAL, "Dial 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, DIAL, "Dial 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, DIAL_V, "Dial V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, DIAL_V, "Dial V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, DIAL_V, "Dial V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, DIAL_V, "Dial V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, DIAL_V, "Dial V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, DIAL_V, "Dial V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, DIAL_V, "Dial V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, DIAL_V, "Dial V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, TRACKBALL_X, "Track X", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, TRACKBALL_X, "Track X 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, TRACKBALL_X, "Track X 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, TRACKBALL_X, "Track X 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, TRACKBALL_X, "Track X 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, TRACKBALL_X, "Track X 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, TRACKBALL_X, "Track X 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, TRACKBALL_X, "Track X 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, TRACKBALL_Y, "Track Y", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, TRACKBALL_Y, "Track Y 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, TRACKBALL_Y, "Track Y 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, TRACKBALL_Y, "Track Y 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, TRACKBALL_Y, "Track Y 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, TRACKBALL_Y, "Track Y 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, TRACKBALL_Y, "Track Y 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, TRACKBALL_Y, "Track Y 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, AD_STICK_X, "AD Stick X", SEQ_DEF_3(INDEXED(JOYCODE_X, 0), SEQCODE_OR, INDEXED(MOUSECODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, AD_STICK_X, "AD Stick X 2", SEQ_DEF_3(INDEXED(JOYCODE_X, 1), SEQCODE_OR, INDEXED(MOUSECODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, AD_STICK_X, "AD Stick X 3", SEQ_DEF_3(INDEXED(JOYCODE_X, 2), SEQCODE_OR, INDEXED(MOUSECODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, AD_STICK_X, "AD Stick X 4", SEQ_DEF_3(INDEXED(JOYCODE_X, 3), SEQCODE_OR, INDEXED(MOUSECODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, AD_STICK_X, "AD Stick X 5", SEQ_DEF_3(INDEXED(JOYCODE_X, 4), SEQCODE_OR, INDEXED(MOUSECODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, AD_STICK_X, "AD Stick X 6", SEQ_DEF_3(INDEXED(JOYCODE_X, 5), SEQCODE_OR, INDEXED(MOUSECODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, AD_STICK_X, "AD Stick X 7", SEQ_DEF_3(INDEXED(JOYCODE_X, 6), SEQCODE_OR, INDEXED(MOUSECODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, AD_STICK_X, "AD Stick X 8", SEQ_DEF_3(INDEXED(JOYCODE_X, 7), SEQCODE_OR, INDEXED(MOUSECODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, AD_STICK_Y, "AD Stick Y", SEQ_DEF_3(INDEXED(JOYCODE_Y, 0), SEQCODE_OR, INDEXED(MOUSECODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, AD_STICK_Y, "AD Stick Y 2", SEQ_DEF_3(INDEXED(JOYCODE_Y, 1), SEQCODE_OR, INDEXED(MOUSECODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, AD_STICK_Y, "AD Stick Y 3", SEQ_DEF_3(INDEXED(JOYCODE_Y, 2), SEQCODE_OR, INDEXED(MOUSECODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, AD_STICK_Y, "AD Stick Y 4", SEQ_DEF_3(INDEXED(JOYCODE_Y, 3), SEQCODE_OR, INDEXED(MOUSECODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, AD_STICK_Y, "AD Stick Y 5", SEQ_DEF_3(INDEXED(JOYCODE_Y, 4), SEQCODE_OR, INDEXED(MOUSECODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, AD_STICK_Y, "AD Stick Y 6", SEQ_DEF_3(INDEXED(JOYCODE_Y, 5), SEQCODE_OR, INDEXED(MOUSECODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, AD_STICK_Y, "AD Stick Y 7", SEQ_DEF_3(INDEXED(JOYCODE_Y, 6), SEQCODE_OR, INDEXED(MOUSECODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, AD_STICK_Y, "AD Stick Y 8", SEQ_DEF_3(INDEXED(JOYCODE_Y, 7), SEQCODE_OR, INDEXED(MOUSECODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, AD_STICK_Z, "AD Stick Z", SEQ_DEF_1(INDEXED(JOYCODE_Z, 0)), SEQ_DEF_0, SEQ_DEF_0 ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, AD_STICK_Z, "AD Stick Z 2", SEQ_DEF_1(INDEXED(JOYCODE_Z, 1)), SEQ_DEF_0, SEQ_DEF_0 ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, AD_STICK_Z, "AD Stick Z 3", SEQ_DEF_1(INDEXED(JOYCODE_Z, 2)), SEQ_DEF_0, SEQ_DEF_0 ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, AD_STICK_Z, "AD Stick Z 4", SEQ_DEF_1(INDEXED(JOYCODE_Z, 3)), SEQ_DEF_0, SEQ_DEF_0 ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, AD_STICK_Z, "AD Stick Z 5", SEQ_DEF_1(INDEXED(JOYCODE_Z, 4)), SEQ_DEF_0, SEQ_DEF_0 ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, AD_STICK_Z, "AD Stick Z 6", SEQ_DEF_1(INDEXED(JOYCODE_Z, 5)), SEQ_DEF_0, SEQ_DEF_0 ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, AD_STICK_Z, "AD Stick Z 7", SEQ_DEF_1(INDEXED(JOYCODE_Z, 6)), SEQ_DEF_0, SEQ_DEF_0 ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, AD_STICK_Z, "AD Stick Z 8", SEQ_DEF_1(INDEXED(JOYCODE_Z, 7)), SEQ_DEF_0, SEQ_DEF_0 ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, LIGHTGUN_X, "Lightgun X", SEQ_DEF_5(INDEXED(GUNCODE_X, 0), SEQCODE_OR, INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, LIGHTGUN_X, "Lightgun X 2", SEQ_DEF_5(INDEXED(GUNCODE_X, 1), SEQCODE_OR, INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, LIGHTGUN_X, "Lightgun X 3", SEQ_DEF_5(INDEXED(GUNCODE_X, 2), SEQCODE_OR, INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, LIGHTGUN_X, "Lightgun X 4", SEQ_DEF_5(INDEXED(GUNCODE_X, 3), SEQCODE_OR, INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, LIGHTGUN_X, "Lightgun X 5", SEQ_DEF_5(INDEXED(GUNCODE_X, 4), SEQCODE_OR, INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, LIGHTGUN_X, "Lightgun X 6", SEQ_DEF_5(INDEXED(GUNCODE_X, 5), SEQCODE_OR, INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, LIGHTGUN_X, "Lightgun X 7", SEQ_DEF_5(INDEXED(GUNCODE_X, 6), SEQCODE_OR, INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, LIGHTGUN_X, "Lightgun X 8", SEQ_DEF_5(INDEXED(GUNCODE_X, 7), SEQCODE_OR, INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, LIGHTGUN_Y, "Lightgun Y", SEQ_DEF_5(INDEXED(GUNCODE_Y, 0), SEQCODE_OR, INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, LIGHTGUN_Y, "Lightgun Y 2", SEQ_DEF_5(INDEXED(GUNCODE_Y, 1), SEQCODE_OR, INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, LIGHTGUN_Y, "Lightgun Y 3", SEQ_DEF_5(INDEXED(GUNCODE_Y, 2), SEQCODE_OR, INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, LIGHTGUN_Y, "Lightgun Y 4", SEQ_DEF_5(INDEXED(GUNCODE_Y, 3), SEQCODE_OR, INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, LIGHTGUN_Y, "Lightgun Y 5", SEQ_DEF_5(INDEXED(GUNCODE_Y, 4), SEQCODE_OR, INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, LIGHTGUN_Y, "Lightgun Y 6", SEQ_DEF_5(INDEXED(GUNCODE_Y, 5), SEQCODE_OR, INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, LIGHTGUN_Y, "Lightgun Y 7", SEQ_DEF_5(INDEXED(GUNCODE_Y, 6), SEQCODE_OR, INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, LIGHTGUN_Y, "Lightgun Y 8", SEQ_DEF_5(INDEXED(GUNCODE_Y, 7), SEQCODE_OR, INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, MOUSE_X, "Mouse X", SEQ_DEF_1(INDEXED(MOUSECODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, MOUSE_X, "Mouse X 2", SEQ_DEF_1(INDEXED(MOUSECODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, MOUSE_X, "Mouse X 3", SEQ_DEF_1(INDEXED(MOUSECODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, MOUSE_X, "Mouse X 4", SEQ_DEF_1(INDEXED(MOUSECODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, MOUSE_X, "Mouse X 5", SEQ_DEF_1(INDEXED(MOUSECODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, MOUSE_X, "Mouse X 6", SEQ_DEF_1(INDEXED(MOUSECODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, MOUSE_X, "Mouse X 7", SEQ_DEF_1(INDEXED(MOUSECODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, MOUSE_X, "Mouse X 8", SEQ_DEF_1(INDEXED(MOUSECODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) - - INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, MOUSE_Y, "Mouse Y", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) - INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, MOUSE_Y, "Mouse Y 2", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) - INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, MOUSE_Y, "Mouse Y 3", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) - INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, MOUSE_Y, "Mouse Y 4", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) - INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, MOUSE_Y, "Mouse Y 5", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) - INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, MOUSE_Y, "Mouse Y 6", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) - INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, MOUSE_Y, "Mouse Y 7", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) - INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, MOUSE_Y, "Mouse Y 8", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) - - INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, KEYBOARD, "Keyboard", SEQ_DEF_0 ) - - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_ON_SCREEN_DISPLAY,"On Screen Display", SEQ_DEF_1(KEYCODE_TILDE) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_DEBUG_BREAK, "Break in Debugger", SEQ_DEF_1(KEYCODE_TILDE) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_CONFIGURE, "Config Menu", SEQ_DEF_1(KEYCODE_TAB) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_PAUSE, "Pause", SEQ_DEF_1(KEYCODE_P) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_RESET_MACHINE, "Reset Game", SEQ_DEF_2(KEYCODE_F3, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SOFT_RESET, "Soft Reset", SEQ_DEF_3(KEYCODE_F3, SEQCODE_NOT, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SHOW_GFX, "Show Gfx", SEQ_DEF_1(KEYCODE_F4) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_FRAMESKIP_DEC, "Frameskip Dec", SEQ_DEF_1(KEYCODE_F8) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_FRAMESKIP_INC, "Frameskip Inc", SEQ_DEF_1(KEYCODE_F9) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_THROTTLE, "Throttle", SEQ_DEF_1(KEYCODE_F10) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_FAST_FORWARD, "Fast Forward", SEQ_DEF_1(KEYCODE_INSERT) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SHOW_FPS, "Show FPS", SEQ_DEF_5(KEYCODE_F11, SEQCODE_NOT, KEYCODE_LCONTROL, SEQCODE_NOT, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SNAPSHOT, "Save Snapshot", SEQ_DEF_3(KEYCODE_F12, SEQCODE_NOT, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_RECORD_MOVIE, "Record Movie", SEQ_DEF_2(KEYCODE_F12, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_TOGGLE_CHEAT, "Toggle Cheat", SEQ_DEF_1(KEYCODE_F6) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_UP, "UI Up", SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_DOWN, "UI Down", SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_LEFT, "UI Left", SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_RIGHT, "UI Right", SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_HOME, "UI Home", SEQ_DEF_1(KEYCODE_HOME) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_END, "UI End", SEQ_DEF_1(KEYCODE_END) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_PAGE_UP, "UI Page Up", SEQ_DEF_1(KEYCODE_PGUP) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_PAGE_DOWN, "UI Page Down", SEQ_DEF_1(KEYCODE_PGDN) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SELECT, "UI Select", SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_CANCEL, "UI Cancel", SEQ_DEF_1(KEYCODE_ESC) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_CLEAR, "UI Clear", SEQ_DEF_1(KEYCODE_DEL) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_ZOOM_IN, "UI Zoom In", SEQ_DEF_1(KEYCODE_EQUALS) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_ZOOM_OUT, "UI Zoom Out", SEQ_DEF_1(KEYCODE_MINUS) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_PREV_GROUP, "UI Previous Group", SEQ_DEF_1(KEYCODE_OPENBRACE) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_NEXT_GROUP, "UI Next Group", SEQ_DEF_1(KEYCODE_CLOSEBRACE) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_ROTATE, "UI Rotate", SEQ_DEF_1(KEYCODE_R) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SHOW_PROFILER, "Show Profiler", SEQ_DEF_2(KEYCODE_F11, KEYCODE_LSHIFT) ) -#ifdef MESS - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_TOGGLE_UI, "UI Toggle", SEQ_DEF_3(KEYCODE_SCRLOCK, SEQCODE_NOT, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_PASTE, "UI Paste Text", SEQ_DEF_2(KEYCODE_SCRLOCK, KEYCODE_LSHIFT) ) -#endif /* MESS */ - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_TOGGLE_DEBUG, "Toggle Debugger", SEQ_DEF_1(KEYCODE_F5) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SAVE_STATE, "Save State", SEQ_DEF_2(KEYCODE_F7, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_LOAD_STATE, "Load State", SEQ_DEF_3(KEYCODE_F7, SEQCODE_NOT, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_ADD_CHEAT, "Add Cheat", SEQ_DEF_1(KEYCODE_A) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_DELETE_CHEAT, "Delete Cheat", SEQ_DEF_1(KEYCODE_D) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SAVE_CHEAT, "Save Cheat", SEQ_DEF_1(KEYCODE_S) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_WATCH_VALUE, "Watch Value", SEQ_DEF_1(KEYCODE_W) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_EDIT_CHEAT, "Edit Cheat", SEQ_DEF_1(KEYCODE_E) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_RELOAD_CHEAT, "Reload Database", SEQ_DEF_1(KEYCODE_L) ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_TOGGLE_CROSSHAIR, "Toggle Crosshair", SEQ_DEF_1(KEYCODE_F1) ) - - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_1, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_2, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_3, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_4, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_5, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_6, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_7, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_8, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_9, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_10, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_11, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_12, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_13, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_14, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_15, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_16, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, UNKNOWN, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, SPECIAL, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, OTHER, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, DIPSWITCH_NAME, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, CONFIG_NAME, NULL, SEQ_DEF_0 ) - INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, END, NULL, SEQ_DEF_0 ) -}; - - -static input_port_default_entry default_ports[ARRAY_LENGTH(default_ports_builtin)]; -static input_port_default_entry default_ports_backup[ARRAY_LENGTH(default_ports_builtin)]; -static const int input_port_count = ARRAY_LENGTH(default_ports_builtin); -static int default_ports_lookup[__ipt_max][MAX_PLAYERS]; +#include "inpttype.h" @@ -1030,117 +460,178 @@ static int default_ports_lookup[__ipt_max][MAX_PLAYERS]; FUNCTION PROTOTYPES ***************************************************************************/ +/* core system management */ static void input_port_exit(running_machine *machine); -static void input_port_frame(running_machine *machine); -static void input_port_frame_update(running_machine *machine); -static void input_port_load(int config_type, xml_data_node *parentnode); -static void input_port_save(int config_type, xml_data_node *parentnode); -static void update_digital_joysticks(running_machine *machine); -static void update_analog_port(int port); -static void autoselect_device(const input_port_entry *ipt, int type1, int type2, int type3, const char *option, const char *ananame); - -/* playback and record */ + +/* port reading */ +static INT32 apply_analog_settings(INT32 current, analog_field_state *analog); + +/* initialization helpers */ +static void init_port_types(running_machine *machine); +static void init_port_state(running_machine *machine); +static void init_autoselect_devices(const input_port_config *portlist, int type1, int type2, int type3, const char *option, const char *ananame); +static callback_field_info *init_field_callback_info(const input_field_config *field); +static analog_field_state *init_field_analog_state(const input_field_config *field); + +/* once-per-frame updates */ +static void frame_update_callback(running_machine *machine); +static void frame_update(running_machine *machine); +static void frame_update_digital_joysticks(running_machine *machine); +static void frame_update_analog_field(analog_field_state *analog); +static int frame_get_digital_field_state(const input_field_config *field); + +/* port configuration helpers */ +static input_port_config *port_config_detokenize(input_port_config *listhead, const input_port_token *ipt); +static input_port_config *port_config_alloc(const input_port_config **listhead); +static void port_config_free(const input_port_config **portptr); +static input_port_config *port_config_find(const input_port_config *listhead, const char *tag); +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_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); +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); +static int token_to_seq_type(const char *string); + +/* settings load */ +static void load_config_callback(running_machine *machine, int config_type, xml_data_node *parentnode); +static void load_remap_table(running_machine *machine, xml_data_node *parentnode); +static int load_default_config(running_machine *machine, xml_data_node *portnode, int type, int player, const input_seq *newseq); +static int load_game_config(running_machine *machine, xml_data_node *portnode, int type, int player, const input_seq *newseq); + +/* settings save */ +static void save_config_callback(running_machine *machine, int config_type, xml_data_node *parentnode); +static void save_sequence(xml_data_node *parentnode, int type, int porttype, const input_seq *seq); +static int save_this_input_field_type(int type); +static void save_default_inputs(running_machine *machine, xml_data_node *parentnode); +static void save_game_inputs(running_machine *machine, xml_data_node *parentnode); + +/* input playback */ static time_t playback_init(running_machine *machine); -static void record_init(running_machine *machine); static void playback_end(running_machine *machine, const char *message); -static void record_end(running_machine *machine, const char *message); static void playback_frame(running_machine *machine, attotime curtime); +static void playback_port(const input_port_config *port); + +/* input recording */ +static void record_init(running_machine *machine); +static void record_end(running_machine *machine, const char *message); static void record_frame(running_machine *machine, attotime curtime); -static void playback_port(running_machine *machine, input_port_info *portinfo); -static void record_port(running_machine *machine, input_port_info *portinfo); +static void record_port(const input_port_config *port); /*************************************************************************** - CORE IMPLEMENTATION + INLINE FUNCTIONS ***************************************************************************/ -/************************************* - * - * Input port initialize - * - *************************************/ +/*------------------------------------------------- + apply_analog_min_max - clamp the given input + value to the appropriate min/max for the + analog control +-------------------------------------------------*/ -time_t input_port_init(running_machine *machine, const input_port_token *ipt) +INLINE INT32 apply_analog_min_max(const analog_field_state *analog, INT32 value) { - int ipnum, player; - time_t basetime; + /* take the analog minimum and maximum values and apply the inverse of the */ + /* sensitivity so that we can clamp against them before applying sensitivity */ + INT32 adjmin = APPLY_INVERSE_SENSITIVITY(analog->minimum, analog->sensitivity); + INT32 adjmax = APPLY_INVERSE_SENSITIVITY(analog->maximum, analog->sensitivity); - /* add an exit callback */ - add_exit_callback(machine, input_port_exit); - add_frame_callback(machine, input_port_frame); + /* for absolute devices, clamp to the bounds absolutely */ + if (!analog->wraps) + { + if (value > adjmax) + value = adjmax; + else if (value < adjmin) + value = adjmin; + } - /* reset the pointers */ - memset(&joystick_info, 0, sizeof(joystick_info)); + /* for relative devices, wrap around when we go past the edge */ + else + { + INT32 adj1 = APPLY_INVERSE_SENSITIVITY(512, analog->sensitivity); + INT32 adjdif = adjmax - adjmin + adj1; - /* start with the raw defaults and ask the OSD to customize them in the backup array */ - memcpy(default_ports_backup, default_ports_builtin, sizeof(default_ports_backup)); - osd_customize_inputport_list(default_ports_backup); + if (analog->reverse) + { + while (value <= adjmin - adj1) + value += adjdif; + while (value > adjmax) + value -= adjdif; + } + else + { + while (value >= adjmax + adj1) + value -= adjdif; + while (value < adjmin) + value += adjdif; + } + } - /* propogate these changes forward to the final input list */ - memcpy(default_ports, default_ports_backup, sizeof(default_ports)); + return value; +} - /* make a lookup table mapping type/player to the default port list entry */ - for (ipnum = 0; ipnum < __ipt_max; ipnum++) - for (player = 0; player < MAX_PLAYERS; player++) - default_ports_lookup[ipnum][player] = -1; - for (ipnum = 0; default_ports[ipnum].type != IPT_END; ipnum++) - default_ports_lookup[default_ports[ipnum].type][default_ports[ipnum].player] = ipnum; - /* reset the port info */ - memset(port_info, 0, sizeof(port_info)); +/*------------------------------------------------- + get_port_index - return an index for the + given port tag +-------------------------------------------------*/ - /* if we have inputs, process them now */ - if (ipt != NULL) +INLINE int get_port_index(const input_port_config *portlist, const char *tag) +{ + const input_port_config *port; + int index = 0; + + for (port = portlist; port != NULL; port = port->next) { - const char *joystick_map_default = options_get_string(mame_options(), OPTION_JOYSTICK_MAP); - input_port_entry *portentry; - int portnum; - - /* allocate input ports */ - machine->input_ports = input_port_allocate(ipt, NULL); - - /* allocate default input ports */ - input_ports_default = input_port_allocate(ipt, NULL); - - /* handle autoselection of devices */ - autoselect_device(machine->input_ports, IPT_PADDLE, IPT_PADDLE_V, 0, OPTION_PADDLE_DEVICE, "paddle"); - autoselect_device(machine->input_ports, IPT_AD_STICK_X, IPT_AD_STICK_Y, IPT_AD_STICK_Z, OPTION_ADSTICK_DEVICE, "analog joystick"); - autoselect_device(machine->input_ports, IPT_LIGHTGUN_X, IPT_LIGHTGUN_Y, 0, OPTION_LIGHTGUN_DEVICE, "lightgun"); - autoselect_device(machine->input_ports, IPT_PEDAL, IPT_PEDAL2, IPT_PEDAL3, OPTION_PEDAL_DEVICE, "pedal"); - autoselect_device(machine->input_ports, IPT_DIAL, IPT_DIAL_V, 0, OPTION_DIAL_DEVICE, "dial"); - autoselect_device(machine->input_ports, IPT_TRACKBALL_X, IPT_TRACKBALL_Y, 0, OPTION_TRACKBALL_DEVICE, "trackball"); - autoselect_device(machine->input_ports, IPT_POSITIONAL, IPT_POSITIONAL_V, 0, OPTION_POSITIONAL_DEVICE, "positional"); - autoselect_device(machine->input_ports, IPT_MOUSE_X, IPT_MOUSE_Y, 0, OPTION_MOUSE_DEVICE, "mouse"); - - /* 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 (portentry = machine->input_ports; portentry->type != IPT_END; portentry++) - if (IS_DIGITAL_JOYSTICK(portentry) && portentry->way == 4) - { - input_device_set_joystick_map(-1, portentry->rotated ? joystick_map_4way_diagonal : joystick_map_4way_sticky); - break; - } + if (port->tag != NULL && strcmp(tag, port->tag) == 0) + return index; + index++; + } + return -1; +} - /* identify all the tagged ports up front so the memory system can access them */ - portnum = 0; - for (portentry = machine->input_ports; portentry->type != IPT_END; portentry++) - if (portentry->type == IPT_PORT) - port_info[portnum++].tag = portentry->start.tag; - /* look up all the tags referenced in conditions */ - for (portentry = machine->input_ports; portentry->type != IPT_END; portentry++) - if (portentry->condition.tag) - { - int tag = port_tag_to_index(portentry->condition.tag); - if (tag == -1) - fatalerror("Conditional port references invalid tag '%s'", portentry->condition.tag); - portentry->condition.portnum = tag; - } + +/*************************************************************************** + CORE SYSTEM MANAGEMENT +***************************************************************************/ + +/*------------------------------------------------- + input_port_init - initialize the input port + system +-------------------------------------------------*/ + +time_t input_port_init(running_machine *machine, const input_port_token *tokens) +{ + input_port_private *portdata; + time_t basetime; + + /* allocate memory for our data structure */ + machine->input_port_data = auto_malloc(sizeof(*machine->input_port_data)); + memset(machine->input_port_data, 0, sizeof(*machine->input_port_data)); + portdata = machine->input_port_data; + + /* add an exit callback and a frame callback */ + add_exit_callback(machine, input_port_exit); + add_frame_callback(machine, frame_update_callback); + + /* initialize the default port info from the OSD */ + init_port_types(machine); + + /* if we have a token list, proceed */ + if (tokens != NULL) + { + machine->portconfig = input_port_config_alloc(tokens); + init_port_state(machine); } /* register callbacks for when we load configurations */ - config_register("input", input_port_load, input_port_save); + config_register(machine, "input", load_config_callback, save_config_callback); /* open playback and record files if specified */ basetime = playback_init(machine); @@ -1150,732 +641,1585 @@ time_t input_port_init(running_machine *machine, const input_port_token *ipt) } +/*------------------------------------------------- + input_port_exit - exit callback to ensure + we clean up and close our files +-------------------------------------------------*/ -/************************************* - * - * Input port exit - * - *************************************/ - -void input_port_exit(running_machine *machine) +static void input_port_exit(running_machine *machine) { /* close any playback or recording files */ playback_end(machine, NULL); record_end(machine, NULL); + + /* free our allocated config */ + if (machine->portconfig != NULL) + input_port_config_free(machine->portconfig); } -/************************************* - * - * Input port initialization - * - *************************************/ +/*************************************************************************** + PORT CONFIGURATIONS +***************************************************************************/ -static void input_port_postload(void) +/*------------------------------------------------- + input_port_config_alloc - allocate a list of + input ports from the given token list +-------------------------------------------------*/ + +const input_port_config *input_port_config_alloc(const input_port_token *tokens) +{ + return port_config_detokenize(NULL, tokens); +} + + +/*------------------------------------------------- + input_port_config_alloc - free memory + allocated from input_port_alloc +-------------------------------------------------*/ + +void input_port_config_free(const input_port_config *portlist) { - input_port_entry *portentry; - int portnum, bitnum; - UINT32 mask; + /* iterate over all ports and free them */ + while (portlist != NULL) + port_config_free(&portlist); +} + + +/*------------------------------------------------- + input_port_by_tag - return a pointer to the + port_config associated with the given port + tag +-------------------------------------------------*/ + +const input_port_config *input_port_by_tag(const input_port_config *portlist, const char *tag) +{ + const input_port_config *port; + + /* loop over ports until we hit the index or run out */ + for (port = portlist; port != NULL; port = port->next) + if (strcmp(port->tag, tag) == 0) + return port; + + return NULL; +} + + +/*------------------------------------------------- + input_port_by_index - return a pointer to the + port_config associated with the given port + index +-------------------------------------------------*/ + +const input_port_config *input_port_by_index(const input_port_config *portlist, int index) +{ + const input_port_config *port; + + /* loop over ports until we hit the index or run out */ + for (port = portlist; port != NULL; port = port->next) + if (index-- == 0) + return port; + + return NULL; +} + - /* loop over the ports and identify all the analog inputs */ - portnum = -1; - bitnum = 0; - for (portentry = Machine->input_ports; portentry->type != IPT_END; portentry++) + +/*************************************************************************** + ACCESSORS FOR INPUT FIELDS +***************************************************************************/ + +/*------------------------------------------------- + input_field_name - return the field name for + a given input field +-------------------------------------------------*/ + +const char *input_field_name(const input_field_config *field) +{ + /* if we have a non-default name, use that */ + if (field->name != NULL) + return field->name; + + /* otherwise, return the name associated with the type */ + return input_type_name(field->port->machine, field->type, field->player); +} + + +/*------------------------------------------------- + input_field_seq - return the input sequence + for the given input field +-------------------------------------------------*/ + +const input_seq *input_field_seq(const input_field_config *field, input_seq_type seqtype) +{ + static const input_seq ip_none = SEQ_DEF_0; + const input_seq *portseq = &ip_none; + + /* if the field is disabled, return no key */ + if (field->flags & FIELD_FLAG_UNUSED) + return portseq; + + /* select either the live or config state depending on whether we have live state */ + portseq = (field->state == NULL) ? &field->seq[seqtype] : &field->state->seq[seqtype]; + + /* 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); + + /* otherwise, return the sequence as-is */ + return portseq; +} + + +/*------------------------------------------------- + input_field_get_user_settings - return the current + settings for the given input field +-------------------------------------------------*/ + +void input_field_get_user_settings(const input_field_config *field, input_field_user_settings *settings) +{ + int seqtype; + + /* zap the entire structure */ + memset(settings, 0, sizeof(*settings)); + + /* copy the basics */ + for (seqtype = 0; seqtype < ARRAY_LENGTH(settings->seq); seqtype++) + 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) + settings->value = field->state->value; + + /* if there's analog data, extract the analog settings */ + if (field->state->analog != NULL) { - /* if this is IPT_PORT, increment the port number */ - if (portentry->type == IPT_PORT) - { - portnum++; - bitnum = 0; - } + settings->sensitivity = field->state->analog->sensitivity; + settings->delta = field->state->analog->delta; + settings->centerdelta = field->state->analog->centerdelta; + settings->reverse = field->state->analog->reverse; + } +} - /* if this is not a DIP setting or config setting, add it to the list */ - else if (portentry->type != IPT_DIPSWITCH_SETTING && portentry->type != IPT_CONFIG_SETTING) - { - /* fatal error if we didn't hit an IPT_PORT */ - if (portnum < 0) - fatalerror("Error in InputPort definition: expecting PORT_START"); - /* fatal error if too many bits */ - if (bitnum >= MAX_BITS_PER_PORT) - fatalerror("Error in InputPort definition: too many bits for a port (%d max)", MAX_BITS_PER_PORT); +/*------------------------------------------------- + input_field_set_user_settings - modify the current + settings for the given input field +-------------------------------------------------*/ - /* fill in the bit info */ - port_info[portnum].bit[bitnum].portentry = portentry; - port_info[portnum].bit[bitnum].impulse = 0; - port_info[portnum].bit[bitnum++].last = 0; +void input_field_set_user_settings(const input_field_config *field, const input_field_user_settings *settings) +{ + static const input_seq default_seq = SEQ_DEF_1(SEQCODE_DEFAULT); + int seqtype; - /* if this is a custom input, add it to the list */ - if (portentry->custom != NULL) - { - custom_port_info *info; + /* 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, seqtype); + if (input_seq_cmp(defseq, &settings->seq[seqtype]) == 0) + field->state->seq[seqtype] = default_seq; + else + field->state->seq[seqtype] = settings->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) + field->state->value = settings->value; + + /* if there's analog data, extract the analog settings */ + if (field->state->analog != NULL) + { + field->state->analog->sensitivity = settings->sensitivity; + field->state->analog->delta = settings->delta; + field->state->analog->centerdelta = settings->centerdelta; + field->state->analog->reverse = settings->reverse; + } +} - /* allocate memory */ - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - /* fill in the data */ - info->portentry = portentry; - for (mask = portentry->mask; !(mask & 1); mask >>= 1) - info->shift++; - /* hook in the list */ - info->next = port_info[portnum].custominfo; - port_info[portnum].custominfo = info; - } +/*************************************************************************** + ACCESSORS FOR INPUT TYPES +***************************************************************************/ - /* if this is a changed input, add it to the list */ - else if (portentry->changed != NULL) - { - changed_port_info *info; +/*------------------------------------------------- + input_type_is_analog - return TRUE if + the given type represents an analog control +-------------------------------------------------*/ - /* allocate memory */ - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); +int input_type_is_analog(int type) +{ + return (type >= __ipt_analog_start && type <= __ipt_analog_end); +} - /* fill in the data */ - info->portentry = portentry; - for (mask = portentry->mask; !(mask & 1); mask >>= 1) - info->shift++; - /* hook in the list */ - info->next = port_info[portnum].changedinfo; - port_info[portnum].changedinfo = info; - } +/*------------------------------------------------- + input_type_name - return the name + for the given type/player +-------------------------------------------------*/ - /* if this is an analog port, create an info struct for it */ - else if (IS_ANALOG(portentry)) +const char *input_type_name(running_machine *machine, int type, int player) +{ + /* if we have a machine, use the live state and quick lookup */ + if (machine != NULL) + { + input_port_private *portdata = machine->input_port_data; + input_type_state *typestate = portdata->type_to_typestate[type][player]; + if (typestate != NULL) + return typestate->typedesc.name; + } + + /* if no machine, fall back to brute force searching */ + else + { + int typenum; + for (typenum = 0; typenum < ARRAY_LENGTH(core_types); typenum++) + if (core_types[typenum].type == type && core_types[typenum].player == player) + return core_types[typenum].name; + } + + /* if we find nothing, return an invalid group */ + return "???"; +} + + +/*------------------------------------------------- + input_type_group - return the group + for the given type/player +-------------------------------------------------*/ + +int input_type_group(running_machine *machine, int type, int player) +{ + /* if we have a machine, use the live state and quick lookup */ + if (machine != NULL) + { + input_port_private *portdata = machine->input_port_data; + input_type_state *typestate = portdata->type_to_typestate[type][player]; + if (typestate != NULL) + return typestate->typedesc.group; + } + + /* if no machine, fall back to brute force searching */ + else + { + int typenum; + for (typenum = 0; typenum < ARRAY_LENGTH(core_types); typenum++) + if (core_types[typenum].type == type && core_types[typenum].player == player) + return core_types[typenum].group; + } + + /* if we find nothing, return an invalid group */ + return IPG_INVALID; +} + + +/*------------------------------------------------- + input_type_seq - return the input + sequence for the given type/player +-------------------------------------------------*/ + +const input_seq *input_type_seq(running_machine *machine, int type, int player, input_seq_type seqtype) +{ + static const input_seq ip_none = SEQ_DEF_0; + + /* if we have a machine, use the live state and quick lookup */ + if (machine != NULL) + { + input_port_private *portdata = machine->input_port_data; + input_type_state *typestate = portdata->type_to_typestate[type][player]; + if (typestate != NULL) + return &typestate->seq[seqtype]; + } + + /* if no machine, fall back to brute force searching */ + else + { + int typenum; + for (typenum = 0; typenum < ARRAY_LENGTH(core_types); typenum++) + if (core_types[typenum].type == type && core_types[typenum].player == player) + return &core_types[typenum].seq[seqtype]; + } + + /* if we find nothing, return an empty sequence */ + return &ip_none; +} + + +/*------------------------------------------------- + input_type_set_seq - change the input + sequence for the given type/player +-------------------------------------------------*/ + +void input_type_set_seq(running_machine *machine, int type, int player, input_seq_type seqtype, const input_seq *newseq) +{ + input_port_private *portdata = machine->input_port_data; + input_type_state *typestate = portdata->type_to_typestate[type][player]; + if (typestate != NULL) + typestate->seq[seqtype] = *newseq; +} + + +/*------------------------------------------------- + input_type_pressed - return TRUE if + the sequence for the given input type/player + is pressed +-------------------------------------------------*/ + +int input_type_pressed(running_machine *machine, int type, int player) +{ + return input_seq_pressed(input_type_seq(machine, type, player, SEQ_TYPE_STANDARD)); +} + + +/*------------------------------------------------- + input_type_list - return the list of types +-------------------------------------------------*/ + +const input_type_desc *input_type_list(running_machine *machine) +{ + input_port_private *portdata = machine->input_port_data; + return &portdata->typestatelist->typedesc; +} + + + +/*************************************************************************** + USER INTERFACE SEQUENCE READING +***************************************************************************/ + +/*------------------------------------------------- + input_ui_pressed - return TRUE if a key down + for the given user interface sequence is + detected +-------------------------------------------------*/ + +int input_ui_pressed(running_machine *machine, int code) +{ + return input_ui_pressed_repeat(machine, code, 0); +} + + +/*------------------------------------------------- + input_ui_pressed_r - return TRUE if a key down + for the given user interface sequence is + detected, or if autorepeat at the given speed + is triggered +-------------------------------------------------*/ + +int input_ui_pressed_repeat(running_machine *machine, int code, int speed) +{ + input_port_private *portdata = machine->input_port_data; + int pressed; + +profiler_mark(PROFILER_INPUT); + + /* get the status of this key (assumed to be only in the defaults) */ + assert(code >= IPT_UI_CONFIGURE && code <= IPT_OSD_16); + pressed = input_seq_pressed(input_type_seq(machine, code, 0, SEQ_TYPE_STANDARD)); + + /* if down, handle it specially */ + if (pressed) + { + osd_ticks_t tps = osd_ticks_per_second(); + + /* if this is the first press, set a 3x delay and leave pressed = 1 */ + if (portdata->ui_memory[code] == 0) + portdata->ui_memory[code] = osd_ticks() + 3 * speed * tps / 60; + + /* if this is an autorepeat case, set a 1x delay and leave pressed = 1 */ + else if (speed > 0 && (osd_ticks() + tps - portdata->ui_memory[code]) >= tps) + portdata->ui_memory[code] += 1 * speed * tps / 60; + + /* otherwise, reset pressed = 0 */ + else + pressed = 0; + } + + /* if we're not pressed, reset the memory field */ + else + portdata->ui_memory[code] = 0; + +profiler_mark(PROFILER_END); + + return pressed; +} + + + +/*************************************************************************** + PORT READING +***************************************************************************/ + +/*------------------------------------------------- + input_port_read_direct - return the value of + an input port +-------------------------------------------------*/ + +input_port_value input_port_read_direct(const input_port_config *port) +{ + input_port_private *portdata = port->machine->input_port_data; + analog_field_state *analog; + callback_field_info *custom; + input_port_value result; + + /* start with the digital */ + result = port->state->digital; + + /* update custom values */ + for (custom = port->state->customlist; custom != NULL; custom = custom->next) + if (input_condition_true(port->machine, &custom->field->condition)) + { + /* replace the bits with bits from the custom routine */ + input_port_value newbits = (*custom->field->custom)(custom->field, custom->field->custom_param); + result = (result & ~custom->field->mask) | ((newbits << custom->shift) & custom->field->mask); + } + + + /* update VBLANK bits */ + if (port->state->vblank != 0) + { + if (video_screen_get_vblank(port->machine->primary_screen)) + result |= port->state->vblank; + else + result &= ~port->state->vblank; + } + + /* apply active high/low state to digital, custom, and VBLANK inputs */ + result ^= port->state->defvalue; + + /* merge in analog portions */ + for (analog = port->state->analoglist; analog != NULL; analog = analog->next) + if (input_condition_true(port->machine, &analog->field->condition)) + { + /* start with the raw value */ + INT32 value = analog->accum; + + /* interpolate if appropriate and if time has passed since the last update */ + if (analog->interpolate && !(analog->field->flags & ANALOG_FLAG_RESET) && portdata->last_delta_nsec != 0) { - analog_port_info *info; - - /* allocate memory */ - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - - /* fill in the data */ - info->portentry = portentry; - for (mask = portentry->mask; !(mask & 1); mask >>= 1) - info->shift++; - for ( ; mask & 1; mask >>= 1) - info->bits++; - - /* based on the port type determine if we need absolute or relative coordinates */ - info->minimum = INPUT_ABSOLUTE_MIN; - info->maximum = INPUT_ABSOLUTE_MAX; - info->interpolate = 1; - - /* adjust default, min, and max so they fall in the bitmask range */ - portentry->default_value = (portentry->default_value & portentry->mask) >> info->shift; - if (portentry->type != IPT_POSITIONAL && portentry->type != IPT_POSITIONAL_V) - { - portentry->analog.min = (portentry->analog.min & portentry->mask) >> info->shift; - portentry->analog.max = (portentry->analog.max & portentry->mask) >> info->shift; - } + attoseconds_t nsec_since_last = attotime_to_attoseconds(attotime_sub(timer_get_time(), portdata->last_frame_time)) / ATTOSECONDS_PER_NANOSECOND; + value = analog->previous + ((INT64)(analog->accum - analog->previous) * nsec_since_last / portdata->last_delta_nsec); + } - switch (portentry->type) - { - /* pedals start at and autocenter to the min range*/ - case IPT_PEDAL: - case IPT_PEDAL2: - case IPT_PEDAL3: - info->center = INPUT_ABSOLUTE_MIN; - /* force pedals to start at their scaled minimum */ - info->accum = APPLY_INVERSE_SENSITIVITY(info->center, portentry->analog.sensitivity); - /* fall through to complete setup */ - - /* pedals, paddles and analog joysticks are absolute and autocenter */ - case IPT_AD_STICK_X: - case IPT_AD_STICK_Y: - case IPT_AD_STICK_Z: - case IPT_PADDLE: - case IPT_PADDLE_V: - info->absolute = 1; - info->autocenter = 1; - break; + /* apply standard analog settings */ + value = apply_analog_settings(value, analog); - /* lightguns are absolute as well, but don't autocenter and don't interpolate their values */ - case IPT_LIGHTGUN_X: - case IPT_LIGHTGUN_Y: - info->absolute = 1; - info->interpolate = 0; - break; + /* remap the value if needed */ + if (analog->field->remap_table != NULL) + value = analog->field->remap_table[value]; - /* dials, mice and trackballs are relative devices */ - /* these have fixed "min" and "max" values based on how many bits are in the port */ - /* in addition, we set the wrap around min/max values to 512 * the min/max values */ - /* this takes into account the mapping that one mouse unit ~= 512 analog units */ - case IPT_DIAL: - case IPT_DIAL_V: - case IPT_MOUSE_X: - case IPT_MOUSE_Y: - case IPT_TRACKBALL_X: - case IPT_TRACKBALL_Y: - info->absolute = 0; - info->wraps = 1; - break; + /* invert bits if needed */ + if (analog->field->flags & ANALOG_FLAG_INVERT) + value = ~value; - /* positional devices are abolute, but can also wrap like relative devices */ - /* set each position to be 512 units */ - case IPT_POSITIONAL: - case IPT_POSITIONAL_V: - info->positionalscale = COMPUTE_SCALE(portentry->analog.max, INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN); - /* force to only use PORT_POSITIONS data */ - portentry->analog.min = 0; - portentry->analog.max--; - info->autocenter = !portentry->analog.wraps; - info->wraps = portentry->analog.wraps; - break; + /* insert into the port */ + result = (result & ~analog->field->mask) | ((value << analog->shift) & analog->field->mask); + } - default: - fatalerror("Unknown analog port type -- don't know if it is absolute or not"); - break; - } + return result; +} - if (info->absolute) - { - /* if we are receiving data from the OSD input as absolute, - * and the emulated port type is absolute, - * and the default port value is between min/max, - * we need to scale differently for the +/- directions. - * All other absolute types use a 1:1 scale */ - info->single_scale = (portentry->default_value == portentry->analog.min) || (portentry->default_value == portentry->analog.max); - - if (!info->single_scale) - { - /* axis moves in both directions from the default value */ - /* unsigned */ - info->scalepos = COMPUTE_SCALE(portentry->analog.max - portentry->default_value, INPUT_ABSOLUTE_MAX - 0); - info->scaleneg = COMPUTE_SCALE(portentry->default_value - portentry->analog.min, 0 - INPUT_ABSOLUTE_MIN); +/*------------------------------------------------- + input_port_read - return the value of + an input port specified by tag +-------------------------------------------------*/ - if (portentry->analog.min > portentry->analog.max) - { - /* signed */ - info->scaleneg *= -1; - } +input_port_value input_port_read(running_machine *machine, const char *tag) +{ + const input_port_config *port = input_port_by_tag(machine->portconfig, tag); + if (port == NULL) + fatalerror("Unable to locate input port '%s'", tag); + return input_port_read_direct(port); +} - /* reverse from center */ - info->reverse_val = 0; - } - else - { - /* single axis that increases from default */ - info->scalepos = COMPUTE_SCALE(portentry->analog.max - portentry->analog.min, INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN); - /* move from default */ - if (portentry->default_value == portentry->analog.max) - info->scalepos *= -1; +/*------------------------------------------------- + input_port_read_indexed - return the value of + an input port specified by tag, or a default + value if the port does not exist +-------------------------------------------------*/ - /* make the scaling the same for easier coding when we need to scale */ - info->scaleneg = info->scalepos; +input_port_value input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue) +{ + const input_port_config *port = input_port_by_tag(machine->portconfig, tag); + return (port == NULL) ? defvalue : input_port_read_direct(port); +} - /* reverse from max */ - info->reverse_val = info->maximum; - } - } - /* relative and positional controls all map directly with a 512x scale factor */ - else +/*------------------------------------------------- + input_port_read_indexed - return the value of + an input port specified by index +-------------------------------------------------*/ + +input_port_value input_port_read_indexed(running_machine *machine, int portnum) +{ + const input_port_config *port = input_port_by_index(machine->portconfig, portnum); + return (port == NULL) ? 0 : input_port_read_direct(port); +} + + +/*------------------------------------------------- + input_port_read_crosshair - return the + extracted crosshair values for the given + player +-------------------------------------------------*/ + +int input_port_get_crosshair_position(running_machine *machine, int player, float *x, float *y) +{ + const input_port_config *port; + const input_field_config *field; + int gotx = FALSE, goty = FALSE; + + /* read all the lightgun values */ + for (port = machine->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + if (field->player == player && field->crossaxis != CROSSHAIR_AXIS_NONE) + if (input_condition_true(machine, &field->condition)) { - /* The relative code is set up to allow specifing PORT_MINMAX and default values. */ - /* The validity checks are purposely set up to not allow you to use anything other */ - /* a default of 0 and PORT_MINMAX(0,mask). This is in case the need arises to use */ - /* this feature in the future. Keeping the code in does not hurt anything. */ - if (portentry->analog.min > portentry->analog.max) - /* adjust for signed */ - portentry->analog.min *= -1; - - info->minimum = (portentry->analog.min - portentry->default_value) * 512; - info->maximum = (portentry->analog.max - portentry->default_value) * 512; - - /* make the scaling the same for easier coding when we need to scale */ - info->scaleneg = info->scalepos = COMPUTE_SCALE(1, 512); - - if (portentry->analog.reset) - /* delta values reverse from center */ - info->reverse_val = 0; + analog_field_state *analog = field->state->analog; + INT32 rawvalue = apply_analog_settings(analog->accum, analog) & (analog->field->mask >> analog->shift); + float value = (float)(rawvalue - field->state->analog->adjmin) / (float)(field->state->analog->adjmax - field->state->analog->adjmin); + + /* apply the scale and offset */ + if (field->crossscale < 0) + value = -(1.0 - value) * field->crossscale; else + value *= field->crossscale; + value += field->crossoffset; + + /* handle X axis */ + if (field->crossaxis == CROSSHAIR_AXIS_X) { - /* positional controls reverse from their max range */ - info->reverse_val = info->maximum + info->minimum; + *x = value; + gotx = TRUE; + if (field->crossaltaxis != 0) + { + *y = field->crossaltaxis; + goty = TRUE; + } + } - /* relative controls reverse from 1 past their max range */ - if (info->positionalscale == 0) - info->reverse_val += 512; + /* handle Y axis */ + else + { + *y = value; + goty = TRUE; + if (field->crossaltaxis != 0) + { + *x = field->crossaltaxis; + gotx = TRUE; + } } + + /* if we got both, stop */ + if (gotx && goty) + break; } - /* compute scale for keypresses */ - info->keyscalepos = RECIP_SCALE(info->scalepos); - info->keyscaleneg = RECIP_SCALE(info->scaleneg); + return (gotx && goty); +} - /* hook in the list */ - info->next = port_info[portnum].analoginfo; - port_info[portnum].analoginfo = info; - } - /* if this is a digital joystick port, update info on it */ - else if (IS_DIGITAL_JOYSTICK(portentry)) - { - digital_joystick_info *info = JOYSTICK_INFO_FOR_PORT(portentry); - info->portentry[JOYSTICK_DIR_FOR_PORT(portentry)] = portentry; - info->inuse = 1; - } +/*------------------------------------------------- + input_port_update_defaults - force an update + to the input port values based on current + conditions +-------------------------------------------------*/ + +void input_port_update_defaults(running_machine *machine) +{ + int loopnum; + + /* two passes to catch conditionals properly */ + for (loopnum = 0; loopnum < 2; loopnum++) + { + const input_port_config *port; + + /* loop over all input ports */ + for (port = machine->portconfig; port != NULL; port = port->next) + { + const input_field_config *field; + + /* only clear on the first pass */ + if (loopnum == 0) + port->state->defvalue = 0; + + /* first compute the default value for the entire port */ + for (field = port->fieldlist; 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); } } +} + + +/*------------------------------------------------- + apply_analog_settings - return the value of + an input port +-------------------------------------------------*/ + +static INT32 apply_analog_settings(INT32 value, analog_field_state *analog) +{ + /* apply the min/max and then the sensitivity */ + value = apply_analog_min_max(analog, value); + value = APPLY_SENSITIVITY(value, analog->sensitivity); - /* run an initial update */ - input_port_frame_update(Machine); + /* apply reversal if needed */ + if (analog->reverse) + value = analog->reverse_val - value; + else if (analog->single_scale) + /* it's a pedal or the default value is equal to min/max */ + /* so we need to adjust the center to the minimum */ + value -= INPUT_ABSOLUTE_MIN; + + /* map differently for positive and negative values */ + if (value >= 0) + value = APPLY_SCALE(value, analog->scalepos); + else + value = APPLY_SCALE(value, analog->scaleneg); + value += analog->adjdefvalue; + + return value; } -/************************************* - * - * Identifies which port types are - * saved/loaded - * - *************************************/ +/*************************************************************************** + MISC HELPER FUNCTIONS +***************************************************************************/ -static int save_this_port_type(int type) -{ - switch (type) +/*------------------------------------------------- + input_condition_true - return the TRUE + if the given condition attached is true +-------------------------------------------------*/ + +int input_condition_true(running_machine *machine, const input_condition *condition) +{ + input_port_value condvalue; + + /* always condition is always true */ + if (condition->condition == PORTCOND_ALWAYS) + return TRUE; + + /* otherwise, read the referenced port */ + condvalue = input_port_read(machine, condition->tag); + + /* based on the condition encoded, determine truth */ + switch (condition->condition) { - case IPT_UNUSED: - case IPT_END: - case IPT_PORT: - case IPT_DIPSWITCH_SETTING: - case IPT_CONFIG_SETTING: - case IPT_CATEGORY_SETTING: - case IPT_VBLANK: - case IPT_UNKNOWN: - return 0; + case PORTCOND_EQUALS: + return ((condvalue & condition->mask) == condition->value); + + case PORTCOND_NOTEQUALS: + return ((condvalue & condition->mask) != condition->value); } - return 1; + return TRUE; } +/*------------------------------------------------- + input_port_string_from_token - convert an + input_port_token to a default string +-------------------------------------------------*/ -/************************************* - * - * Input port configuration read - * - *************************************/ - -#ifdef UNUSED_FUNCTION -INLINE input_code get_default_code(int config_type, int type) +const char *input_port_string_from_token(const input_port_token token) { - switch (type) - { - case IPT_DIPSWITCH_NAME: - case IPT_CATEGORY_NAME: - return SEQCODE_END; + int index; - default: - if (config_type != CONFIG_TYPE_GAME) - return SEQCODE_END; - else - return SEQCODE_DEFAULT; - } - return SEQCODE_END; + /* 0 is an invalid index */ + if (token.i == 0) + 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; + + /* 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) + return input_port_default_strings[index].string; + return "(Unknown Default)"; } -#endif -INLINE int string_to_seq_index(const char *string) + +/*------------------------------------------------- + input_port_read_handler* - return a memory + handler corresponding to a given input port + tag +-------------------------------------------------*/ + +read8_machine_func input_port_read_handler8(const input_port_config *portlist, const char *tag) { - int seqindex; + int portnum = get_port_index(portlist, tag); + return (portnum == -1) ? SMH_NOP : port_handler8[portnum]; +} - for (seqindex = 0; seqindex < ARRAY_LENGTH(seqtypestrings); seqindex++) - if (!mame_stricmp(string, seqtypestrings[seqindex])) - return seqindex; - return -1; +read16_machine_func input_port_read_handler16(const input_port_config *portlist, const char *tag) +{ + int portnum = get_port_index(portlist, tag); + return (portnum == -1) ? SMH_NOP : port_handler16[portnum]; } -static void apply_remaps(int count, const input_code *oldtable, const input_code *newtable) +read32_machine_func input_port_read_handler32(const input_port_config *portlist, const char *tag) { - int remapnum; + int portnum = get_port_index(portlist, tag); + return (portnum == -1) ? SMH_NOP : port_handler32[portnum]; +} + + +read64_machine_func input_port_read_handler64(const input_port_config *portlist, const char *tag) +{ + return SMH_NOP; +} + + + +/*************************************************************************** + INITIALIZATION HELPERS +***************************************************************************/ + +/*------------------------------------------------- + init_port_types - initialize the default + type list +-------------------------------------------------*/ - /* loop over the remapping table, operating only if something was specified */ - for (remapnum = 0; remapnum < count; remapnum++) +static void init_port_types(running_machine *machine) +{ + input_port_private *portdata = machine->input_port_data; + input_type_state **stateptr; + input_type_state *curtype; + input_type_desc *lasttype = NULL; + int seqtype, typenum; + + /* convert the array into a list of type states that can be modified */ + portdata->typestatelist = NULL; + stateptr = &portdata->typestatelist; + for (typenum = 0; typenum < ARRAY_LENGTH(core_types); typenum++) { - input_code oldcode = oldtable[remapnum]; - input_code newcode = newtable[remapnum]; - int portnum; + /* allocate memory for the state and link it to the end of the list */ + *stateptr = auto_malloc(sizeof(**stateptr)); + memset(*stateptr, 0, sizeof(**stateptr)); + + /* copy the type description and link the previous description to it */ + (*stateptr)->typedesc = core_types[typenum]; + if (lasttype != NULL) + lasttype->next = &(*stateptr)->typedesc; + lasttype = &(*stateptr)->typedesc; + + /* advance */ + stateptr = &(*stateptr)->next; + } - /* loop over all default ports, remapping the requested keys */ - for (portnum = 0; default_ports[portnum].type != IPT_END; portnum++) - { - input_port_default_entry *defport = &default_ports[portnum]; - int seqnum; - - /* remap anything in the default sequences */ - for (seqnum = 0; seqnum < ARRAY_LENGTH(defport->defaultseq.code); seqnum++) - if (defport->defaultseq.code[seqnum] == oldcode) - defport->defaultseq.code[seqnum] = newcode; - for (seqnum = 0; seqnum < ARRAY_LENGTH(defport->defaultdecseq.code); seqnum++) - if (defport->defaultdecseq.code[seqnum] == oldcode) - defport->defaultdecseq.code[seqnum] = newcode; - for (seqnum = 0; seqnum < ARRAY_LENGTH(defport->defaultincseq.code); seqnum++) - if (defport->defaultincseq.code[seqnum] == oldcode) - defport->defaultincseq.code[seqnum] = newcode; - } + /* ask the OSD to customize the list */ + osd_customize_input_type_list(&portdata->typestatelist->typedesc); + + /* now iterate over the OSD-modified types */ + for (curtype = portdata->typestatelist; curtype != NULL; curtype = curtype->next) + { + /* first copy all the OSD-updated sequences into our current state */ + for (seqtype = 0; seqtype < ARRAY_LENGTH(curtype->seq); seqtype++) + curtype->seq[seqtype] = curtype->typedesc.seq[seqtype]; + + /* also make a lookup table mapping type/player to the appropriate type list entry */ + portdata->type_to_typestate[curtype->typedesc.type][curtype->typedesc.player] = curtype; } } +/*------------------------------------------------- + init_port_state - initialize the live port + states based on the tokens +-------------------------------------------------*/ -static int apply_config_to_default(xml_data_node *portnode, int type, int player, input_seq *newseq) +static void init_port_state(running_machine *machine) { - int portnum; + const char *joystick_map_default = options_get_string(mame_options(), OPTION_JOYSTICK_MAP); + input_port_private *portdata = machine->input_port_data; + const input_field_config *field; + const input_port_config *port; - /* find a matching port in the list */ - for (portnum = 0; portnum < ARRAY_LENGTH(default_ports_backup); portnum++) + /* allocate live structures to mirror the configuration */ + for (port = machine->portconfig; port != NULL; port = port->next) { - input_port_default_entry *updateport = &default_ports[portnum]; - if (updateport->type == type && updateport->player == player) + analog_field_state **analogstatetail; + callback_field_info **custominfotail; + callback_field_info **changedinfotail; + input_port_state *portstate; + + /* allocate a new input_port_info structure */ + portstate = auto_malloc(sizeof(*portstate)); + memset(portstate, 0, sizeof(*portstate)); + ((input_port_config *)port)->state = portstate; + ((input_port_config *)port)->machine = machine; + + /* start with tail pointers to all the data */ + analogstatetail = &portstate->analoglist; + custominfotail = &portstate->customlist; + changedinfotail = &portstate->changedlist; + + /* iterate over fields */ + for (field = port->fieldlist; field != NULL; field = field->next) { - /* copy the sequence(s) that were specified */ - if (input_seq_get_1(&newseq[0]) != INPUT_CODE_INVALID) - updateport->defaultseq = newseq[0]; - if (input_seq_get_1(&newseq[1]) != INPUT_CODE_INVALID) - updateport->defaultdecseq = newseq[1]; - if (input_seq_get_1(&newseq[2]) != INPUT_CODE_INVALID) - updateport->defaultincseq = newseq[2]; - return 1; + input_field_state *fieldstate; + int seqtype; + + /* allocate a new input_field_info structure */ + fieldstate = auto_malloc(sizeof(*fieldstate)); + memset(fieldstate, 0, sizeof(*fieldstate)); + ((input_field_config *)field)->state = fieldstate; + + /* fill in the basic values */ + for (seqtype = 0; seqtype < ARRAY_LENGTH(fieldstate->seq); seqtype++) + fieldstate->seq[seqtype] = field->seq[seqtype]; + fieldstate->value = field->defvalue; + + /* if this is an analog field, allocate memory for the analog data */ + if (field->type >= __ipt_analog_start && field->type <= __ipt_analog_end) + { + *analogstatetail = fieldstate->analog = init_field_analog_state(field); + analogstatetail = &(*analogstatetail)->next; + } + + /* if this is a digital joystick field, make a note of it */ + if (field->type >= __ipt_digital_joystick_start && field->type <= __ipt_digital_joystick_end) + { + fieldstate->joystick = &portdata->joystick_info[field->player][(field->type - __ipt_digital_joystick_start) / 4]; + fieldstate->joydir = (field->type - __ipt_digital_joystick_start) % 4; + fieldstate->joystick->field[fieldstate->joydir] = field; + fieldstate->joystick->inuse = TRUE; + } + + /* if this entry has custom callback, allocate memory for the tracking structure */ + if (field->custom != NULL) + { + *custominfotail = init_field_callback_info(field); + custominfotail = &(*custominfotail)->next; + } + + /* if this entry has changed callback, allocate memory for the tracking structure */ + if (field->changed != NULL) + { + *changedinfotail = init_field_callback_info(field); + changedinfotail = &(*changedinfotail)->next; + } } } - return 0; + + /* handle autoselection of devices */ + init_autoselect_devices(machine->portconfig, IPT_PADDLE, IPT_PADDLE_V, 0, OPTION_PADDLE_DEVICE, "paddle"); + init_autoselect_devices(machine->portconfig, IPT_AD_STICK_X, IPT_AD_STICK_Y, IPT_AD_STICK_Z, OPTION_ADSTICK_DEVICE, "analog joystick"); + init_autoselect_devices(machine->portconfig, IPT_LIGHTGUN_X, IPT_LIGHTGUN_Y, 0, OPTION_LIGHTGUN_DEVICE, "lightgun"); + init_autoselect_devices(machine->portconfig, IPT_PEDAL, IPT_PEDAL2, IPT_PEDAL3, OPTION_PEDAL_DEVICE, "pedal"); + init_autoselect_devices(machine->portconfig, IPT_DIAL, IPT_DIAL_V, 0, OPTION_DIAL_DEVICE, "dial"); + init_autoselect_devices(machine->portconfig, IPT_TRACKBALL_X, IPT_TRACKBALL_Y, 0, OPTION_TRACKBALL_DEVICE, "trackball"); + init_autoselect_devices(machine->portconfig, IPT_POSITIONAL, IPT_POSITIONAL_V, 0, OPTION_POSITIONAL_DEVICE, "positional"); + init_autoselect_devices(machine->portconfig, IPT_MOUSE_X, IPT_MOUSE_Y, 0, OPTION_MOUSE_DEVICE, "mouse"); + + /* 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->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + if (field->state->joystick != NULL && field->way == 4) + { + input_device_set_joystick_map(-1, (field->flags & FIELD_FLAG_ROTATED) ? joystick_map_4way_diagonal : joystick_map_4way_sticky); + break; + } } -static int apply_config_to_current(xml_data_node *portnode, int type, int player, input_seq *newseq) -{ - input_port_entry *updateport; - int mask, defvalue, index; +/*------------------------------------------------- + init_autoselect_devices - autoselect a single + device based on the input port list passed + in and the corresponding option +-------------------------------------------------*/ - /* read the mask, index, and defvalue attributes */ - index = xml_get_attribute_int(portnode, "index", 0); - mask = xml_get_attribute_int(portnode, "mask", 0); - defvalue = xml_get_attribute_int(portnode, "defvalue", 0); +static void init_autoselect_devices(const input_port_config *portlist, int type1, int type2, int type3, const char *option, const char *ananame) +{ + const char *stemp = options_get_string(mame_options(), option); + input_device_class autoenable = DEVICE_CLASS_KEYBOARD; + const char *autostring = "keyboard"; + const input_field_config *field; + const input_port_config *port; - /* find the indexed port; we scan the array to make sure we don't read past the end */ - for (updateport = input_ports_default; updateport->type != IPT_END; updateport++) - if (index-- == 0) - break; + /* if nothing specified, ignore the option */ + if (stemp[0] == 0) + return; - /* verify that it matches */ - if (updateport->type == type && updateport->player == player && - updateport->mask == mask && (updateport->default_value & mask) == (defvalue & mask)) + /* extract valid strings */ + if (strcmp(stemp, "mouse") == 0) + { + autoenable = DEVICE_CLASS_MOUSE; + autostring = "mouse"; + } + else if (strcmp(stemp, "joystick") == 0) + { + autoenable = DEVICE_CLASS_JOYSTICK; + autostring = "joystick"; + } + else if (strcmp(stemp, "lightgun") == 0) + { + autoenable = DEVICE_CLASS_LIGHTGUN; + autostring = "lightgun"; + } + else if (strcmp(stemp, "none") == 0) { - const char *revstring; - - /* point to the real port */ - updateport = Machine->input_ports + (updateport - input_ports_default); - - /* fill in the data from the attributes */ - if (!port_type_is_analog(updateport->type)) - updateport->default_value = xml_get_attribute_int(portnode, "value", updateport->default_value); - updateport->analog.delta = xml_get_attribute_int(portnode, "keydelta", updateport->analog.delta); - updateport->analog.centerdelta = xml_get_attribute_int(portnode, "centerdelta", updateport->analog.centerdelta); - updateport->analog.sensitivity = xml_get_attribute_int(portnode, "sensitivity", updateport->analog.sensitivity); - revstring = xml_get_attribute_string(portnode, "reverse", NULL); - if (revstring) - updateport->analog.reverse = (strcmp(revstring, "yes") == 0); - - /* copy the sequence(s) that were specified */ - if (input_seq_get_1(&newseq[0]) != INPUT_CODE_INVALID) - updateport->seq = newseq[0]; - if (input_seq_get_1(&newseq[1]) != INPUT_CODE_INVALID) - updateport->analog.decseq = newseq[1]; - if (input_seq_get_1(&newseq[2]) != INPUT_CODE_INVALID) - updateport->analog.incseq = newseq[2]; - return 1; + /* nothing specified */ + return; } - return 0; + else if (strcmp(stemp, "keyboard") != 0) + mame_printf_error("Invalid %s value %s; reverting to keyboard\n", option, stemp); + + /* only scan the list if we haven't already enabled this class of control */ + if (!input_device_class_enabled(autoenable)) + for (port = portlist; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + + /* if this port type is in use, apply the autoselect criteria */ + if ((type1 != 0 && field->type == type1) || + (type2 != 0 && field->type == type2) || + (type3 != 0 && field->type == type3)) + { + mame_printf_verbose("Input: Autoenabling %s due to presence of a %s\n", autostring, ananame); + input_device_class_enable(autoenable, TRUE); + break; + } } -static void input_port_load(int config_type, xml_data_node *parentnode) +/*------------------------------------------------- + init_field_callback_info - allocate and populate + information about a changed or custom + callback +-------------------------------------------------*/ + +static callback_field_info *init_field_callback_info(const input_field_config *field) { - xml_data_node *portnode; - int seqnum; + callback_field_info *info; + input_port_value mask; - /* in the completion phase, we finish the initialization with the final ports */ - if (config_type == CONFIG_TYPE_FINAL) - input_port_postload(); + /* allocate memory */ + info = auto_malloc(sizeof(*info)); + memset(info, 0, sizeof(*info)); - /* early exit if no data to parse */ - if (!parentnode) - return; + /* fill in the data */ + info->field = field; + for (mask = field->mask; !(mask & 1); mask >>= 1) + info->shift++; + + return info; +} - /* iterate over all the remap nodes for controller configs only */ - if (config_type == CONFIG_TYPE_CONTROLLER) + +/*------------------------------------------------- + init_field_analog_state - allocate and populate + information about an analog port +-------------------------------------------------*/ + +static analog_field_state *init_field_analog_state(const input_field_config *field) +{ + analog_field_state *state; + input_port_value mask; + + /* allocate memory */ + state = auto_malloc(sizeof(*state)); + memset(state, 0, sizeof(*state)); + + /* compute the shift amount and number of bits */ + for (mask = field->mask; !(mask & 1); mask >>= 1) + state->shift++; + + /* initialize core data */ + state->field = field; + state->adjdefvalue = (field->defvalue & field->mask) >> state->shift; + state->adjmin = (field->min & field->mask) >> state->shift; + state->adjmax = (field->max & field->mask) >> state->shift; + state->sensitivity = field->sensitivity; + state->reverse = ((field->flags & ANALOG_FLAG_REVERSE) != 0); + state->delta = field->delta; + state->centerdelta = field->centerdelta; + state->minimum = INPUT_ABSOLUTE_MIN; + state->maximum = INPUT_ABSOLUTE_MAX; + + /* set basic parameters based on the configured type */ + switch (field->type) { - input_code *oldtable, *newtable; - xml_data_node *remapnode; - int count; + /* pedals start at and autocenter to the min range */ + case IPT_PEDAL: + case IPT_PEDAL2: + case IPT_PEDAL3: + state->center = INPUT_ABSOLUTE_MIN; + state->accum = APPLY_INVERSE_SENSITIVITY(state->center, state->sensitivity); + state->absolute = TRUE; + state->autocenter = TRUE; + state->interpolate = TRUE; + break; - /* count items first so we can allocate */ - count = 0; - for (remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode; remapnode = xml_get_sibling(remapnode->next, "remap")) - count++; + /* paddles and analog joysticks are absolute and autocenter */ + case IPT_AD_STICK_X: + case IPT_AD_STICK_Y: + case IPT_AD_STICK_Z: + case IPT_PADDLE: + case IPT_PADDLE_V: + state->absolute = TRUE; + state->autocenter = TRUE; + state->interpolate = TRUE; + break; - /* if we have some, deal with them */ - if (count > 0) - { - /* allocate tables */ - oldtable = malloc_or_die(count * sizeof(*oldtable)); - newtable = malloc_or_die(count * sizeof(*newtable)); + /* lightguns are absolute as well, but don't autocenter and don't interpolate their values */ + case IPT_LIGHTGUN_X: + case IPT_LIGHTGUN_Y: + state->absolute = TRUE; + state->autocenter = FALSE; + state->interpolate = FALSE; + break; - /* build up the remap table */ - count = 0; - for (remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode; remapnode = xml_get_sibling(remapnode->next, "remap")) - { - input_code origcode = input_code_from_token(xml_get_attribute_string(remapnode, "origcode", "")); - input_code newcode = input_code_from_token(xml_get_attribute_string(remapnode, "newcode", "")); - if (origcode != INPUT_CODE_INVALID && newcode != INPUT_CODE_INVALID) - { - oldtable[count] = origcode; - newtable[count] = newcode; - count++; - } - } + /* dials, mice and trackballs are relative devices */ + /* these have fixed "min" and "max" values based on how many bits are in the port */ + /* in addition, we set the wrap around min/max values to 512 * the min/max values */ + /* this takes into account the mapping that one mouse unit ~= 512 analog units */ + case IPT_DIAL: + case IPT_DIAL_V: + case IPT_MOUSE_X: + case IPT_MOUSE_Y: + case IPT_TRACKBALL_X: + case IPT_TRACKBALL_Y: + state->absolute = FALSE; + state->wraps = TRUE; + state->interpolate = TRUE; + break; - /* apply it then free the tables */ - apply_remaps(count, oldtable, newtable); - free(oldtable); - free(newtable); - } + /* positional devices are abolute, but can also wrap like relative devices */ + /* set each position to be 512 units */ + case IPT_POSITIONAL: + case IPT_POSITIONAL_V: + state->positionalscale = COMPUTE_SCALE(state->adjmax, INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN); + state->adjmin = 0; + state->adjmax--; + state->wraps = ((field->flags & ANALOG_FLAG_WRAPS) != 0); + state->autocenter = !state->wraps; + break; + + default: + fatalerror("Unknown analog port type -- don't know if it is absolute or not"); + break; } - /* iterate over all the port nodes */ - for (portnode = xml_get_sibling(parentnode->child, "port"); portnode; portnode = xml_get_sibling(portnode->next, "port")) + /* further processing for absolute controls */ + if (state->absolute) { - input_seq newseq[3], tempseq; - xml_data_node *seqnode; - int type, player; + /* if the default value is pegged at the min or max, use a single scale value for the whole axis */ + state->single_scale = (state->adjdefvalue == state->adjmin) || (state->adjdefvalue == state->adjmax); - /* get the basic port info from the attributes */ - type = token_to_port_type(xml_get_attribute_string(portnode, "type", ""), &player); + /* if not "single scale", compute separate scales for each side of the default */ + if (!state->single_scale) + { + /* unsigned */ + state->scalepos = COMPUTE_SCALE(state->adjmax - state->adjdefvalue, INPUT_ABSOLUTE_MAX - 0); + state->scaleneg = COMPUTE_SCALE(state->adjdefvalue - state->adjmin, 0 - INPUT_ABSOLUTE_MIN); - /* initialize sequences to invalid defaults */ - for (seqnum = 0; seqnum < 3; seqnum++) - input_seq_set_1(&newseq[seqnum], INPUT_CODE_INVALID); + if (state->adjmin > state->adjmax) + state->scaleneg = -state->scaleneg; - /* loop over new sequences */ - for (seqnode = xml_get_sibling(portnode->child, "newseq"); seqnode; seqnode = xml_get_sibling(seqnode->next, "newseq")) + /* reverse point is at center */ + state->reverse_val = 0; + } + else { - /* with a valid type, parse out the new sequence */ - seqnum = string_to_seq_index(xml_get_attribute_string(seqnode, "type", "")); - if (seqnum != -1) - if (seqnode->value != NULL) - { - if (strcmp(seqnode->value, "NONE") == 0) - input_seq_set_0(&newseq[seqnum]); - else if (input_seq_from_tokens(seqnode->value, &tempseq) != 0) - newseq[seqnum] = tempseq; - } + /* single axis that increases from default */ + state->scalepos = COMPUTE_SCALE(state->adjmax - state->adjmin, INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN); + + /* move from default */ + if (state->adjdefvalue == state->adjmax) + state->scalepos = -state->scalepos; + + /* make the scaling the same for easier coding when we need to scale */ + state->scaleneg = state->scalepos; + + /* reverse point is at max */ + state->reverse_val = state->maximum; } + } - /* if we're loading default ports, apply to the default_ports */ - if (config_type != CONFIG_TYPE_GAME) - apply_config_to_default(portnode, type, player, newseq); + /* relative and positional controls all map directly with a 512x scale factor */ + else + { + /* The relative code is set up to allow specifing PORT_MINMAX and default values. */ + /* The validity checks are purposely set up to not allow you to use anything other */ + /* a default of 0 and PORT_MINMAX(0,mask). This is in case the need arises to use */ + /* this feature in the future. Keeping the code in does not hurt anything. */ + if (state->adjmin > state->adjmax) + /* adjust for signed */ + state->adjmin = -state->adjmin; + + state->minimum = (state->adjmin - state->adjdefvalue) * 512; + state->maximum = (state->adjmax - state->adjdefvalue) * 512; + + /* make the scaling the same for easier coding when we need to scale */ + state->scaleneg = state->scalepos = COMPUTE_SCALE(1, 512); + + if (field->flags & ANALOG_FLAG_RESET) + /* delta values reverse from center */ + state->reverse_val = 0; else - apply_config_to_current(portnode, type, player, newseq); + { + /* positional controls reverse from their max range */ + state->reverse_val = state->maximum + state->minimum; + + /* relative controls reverse from 1 past their max range */ + if (state->positionalscale == 0) + state->reverse_val += 512; + } } - /* after applying the controller config, push that back into the backup, since that is */ - /* what we will diff against */ - if (config_type == CONFIG_TYPE_CONTROLLER) - memcpy(default_ports_backup, default_ports, sizeof(default_ports_backup)); + /* compute scale for keypresses */ + state->keyscalepos = RECIP_SCALE(state->scalepos); + state->keyscaleneg = RECIP_SCALE(state->scaleneg); + + return state; } -/************************************* - * - * Input port configuration write - * - *************************************/ +/*************************************************************************** + ONCE-PER-FRAME UPDATES +***************************************************************************/ -static void add_sequence(xml_data_node *parentnode, int type, int porttype, const input_seq *seq) -{ - astring *seqstring = astring_alloc(); - xml_data_node *seqnode; +/*------------------------------------------------- + frame_update_callback - system-wide callback to + update the input ports once per frame, but + only if we are not paused +-------------------------------------------------*/ - /* get the string for the sequence */ - if (input_seq_get_1(seq) == SEQCODE_END) - astring_cpyc(seqstring, "NONE"); - else - input_seq_to_tokens(seqstring, seq); +static void frame_update_callback(running_machine *machine) +{ + /* if we're paused, don't do anything */ + if (mame_is_paused(machine)) + return; - /* add the new node */ - seqnode = xml_add_child(parentnode, "newseq", astring_c(seqstring)); - if (seqnode) - xml_set_attribute(seqnode, "type", seqtypestrings[type]); - astring_free(seqstring); + /* otherwise, use the common code */ + frame_update(machine); } -static void save_default_inputs(xml_data_node *parentnode) +/*------------------------------------------------- + frame_update - core logic for per-frame input + port updating +-------------------------------------------------*/ + +static void frame_update(running_machine *machine) { - int portnum; + input_port_private *portdata = machine->input_port_data; + int ui_visible = ui_is_menu_active() || ui_is_slider_active(); + attotime curtime = timer_get_time(); + const input_port_config *port; - /* iterate over ports */ - for (portnum = 0; portnum < ARRAY_LENGTH(default_ports_backup); portnum++) +profiler_mark(PROFILER_INPUT); + + /* record/playback information about the current frame */ + playback_frame(machine, curtime); + record_frame(machine, curtime); + + /* track the duration of the previous frame */ + portdata->last_delta_nsec = attotime_to_attoseconds(attotime_sub(curtime, portdata->last_frame_time)) / ATTOSECONDS_PER_NANOSECOND; + portdata->last_frame_time = curtime; + + /* update the digital joysticks */ + frame_update_digital_joysticks(machine); + + /* compute default values for all the ports */ + input_port_update_defaults(machine); + + /* loop over all input ports */ + for (port = machine->portconfig; port != NULL; port = port->next) { - input_port_default_entry *defport = &default_ports_backup[portnum]; - input_port_default_entry *curport = &default_ports[portnum]; - - /* only save if something has changed and this port is a type we save */ - if (save_this_port_type(defport->type) && - (input_seq_cmp(&defport->defaultseq, &curport->defaultseq) != 0 || - input_seq_cmp(&defport->defaultdecseq, &curport->defaultdecseq) != 0 || - input_seq_cmp(&defport->defaultincseq, &curport->defaultincseq) != 0)) + const input_field_config *field; + callback_field_info *changed; + input_port_value newvalue; + + /* start with 0 values for the digital and VBLANK bits */ + port->state->digital = 0; + port->state->vblank = 0; + + /* now loop back and modify based on the inputs */ + for (field = port->fieldlist; field != NULL; field = field->next) + if (input_condition_true(port->machine, &field->condition)) + { + /* accumulate VBLANK bits */ + if (field->type == IPT_VBLANK) + port->state->vblank ^= field->mask; + + /* handle analog inputs */ + else if (field->state->analog != NULL) + frame_update_analog_field(field->state->analog); + + /* handle non-analog types, but only when the UI isn't visible */ + else if (!ui_visible && frame_get_digital_field_state(field)) + port->state->digital |= field->mask; + } + +#ifdef MESS + /* hook for MESS's natural keyboard support */ + mess_input_port_update_hook(machine, port, &portinfo->digital); +#endif /* MESS */ + + /* call changed handlers */ + newvalue = input_port_read_direct(port); + for (changed = port->state->changedlist; changed; changed = changed->next) + if (input_condition_true(port->machine, &changed->field->condition)) + { + input_port_value oldbits = (port->state->lastvalue & changed->field->mask) >> changed->shift; + input_port_value newbits = (newvalue & changed->field->mask) >> changed->shift; + + /* if the bits have changed, call the handler */ + if (oldbits != newbits) + (*changed->field->changed)(changed->field, changed->field->changed_param, oldbits, newbits); + } + + /* remember the last value */ + port->state->lastvalue = newvalue; + } + + /* handle playback/record */ + for (port = machine->portconfig; port != NULL; port = port->next) + { + playback_port(port); + record_port(port); + } + +profiler_mark(PROFILER_END); +} + + +/*------------------------------------------------- + frame_update_digital_joysticks - update the + state of digital joysticks prior to + accumulating the results in a port +-------------------------------------------------*/ + +static void frame_update_digital_joysticks(running_machine *machine) +{ + input_port_private *portdata = machine->input_port_data; + int player, joyindex; + + /* loop over all the joysticks */ + for (player = 0; player < MAX_PLAYERS; player++) + for (joyindex = 0; joyindex < DIGITAL_JOYSTICKS_PER_PLAYER; joyindex++) { - /* add a new port node */ - xml_data_node *portnode = xml_add_child(parentnode, "port", NULL); - if (portnode) + digital_joystick_state *joystick = &portdata->joystick_info[player][joyindex]; + if (joystick->inuse) { - /* add the port information and attributes */ - xml_set_attribute(portnode, "type", port_type_to_token(defport->type, defport->player)); - - /* add only the sequences that have changed from the defaults */ - if (input_seq_cmp(&defport->defaultseq, &curport->defaultseq) != 0) - add_sequence(portnode, 0, defport->type, &curport->defaultseq); - if (input_seq_cmp(&defport->defaultdecseq, &curport->defaultdecseq) != 0) - add_sequence(portnode, 1, defport->type, &curport->defaultdecseq); - if (input_seq_cmp(&defport->defaultincseq, &curport->defaultincseq) != 0) - add_sequence(portnode, 2, defport->type, &curport->defaultincseq); + joystick->previous = joystick->current; + joystick->current = 0; + + /* read all the associated ports */ + if (joystick->field[JOYDIR_UP] != NULL && input_seq_pressed(input_field_seq(joystick->field[JOYDIR_UP], SEQ_TYPE_STANDARD))) + joystick->current |= JOYDIR_UP_BIT; + if (joystick->field[JOYDIR_DOWN] != NULL && input_seq_pressed(input_field_seq(joystick->field[JOYDIR_DOWN], SEQ_TYPE_STANDARD))) + joystick->current |= JOYDIR_DOWN_BIT; + if (joystick->field[JOYDIR_LEFT] != NULL && input_seq_pressed(input_field_seq(joystick->field[JOYDIR_LEFT], SEQ_TYPE_STANDARD))) + joystick->current |= JOYDIR_LEFT_BIT; + if (joystick->field[JOYDIR_RIGHT] != NULL && input_seq_pressed(input_field_seq(joystick->field[JOYDIR_RIGHT], SEQ_TYPE_STANDARD))) + joystick->current |= JOYDIR_RIGHT_BIT; + + /* lock out opposing directions (left + right or up + down) */ + if ((joystick->current & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) == (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) + joystick->current &= ~(JOYDIR_UP_BIT | JOYDIR_DOWN_BIT); + if ((joystick->current & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT)) == (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT)) + joystick->current &= ~(JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT); + + /* only update 4-way case if joystick has moved */ + if (joystick->current != joystick->previous) + { + joystick->current4way = joystick->current; + + /* + If joystick is pointing at a diagonal, acknowledge that the player moved + the joystick by favoring a direction change. This minimizes frustration + when using a keyboard for input, and maximizes responsiveness. + + For example, if you are holding "left" then switch to "up" (where both left + and up are briefly pressed at the same time), we'll transition immediately + to "up." + + Zero any switches that didn't change from the previous to current state. + */ + if ((joystick->current4way & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) && + (joystick->current4way & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT))) + { + joystick->current4way ^= joystick->current4way & joystick->previous; + } + + /* + If we are still pointing at a diagonal, we are in an indeterminant state. + + This could happen if the player moved the joystick from the idle position directly + to a diagonal, or from one diagonal directly to an extreme diagonal. + + The chances of this happening with a keyboard are slim, but we still need to + constrain this case. + + For now, just resolve randomly. + */ + if ((joystick->current4way & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) && + (joystick->current4way & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT))) + { + if (mame_rand(machine) & 1) + joystick->current4way &= ~(JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT); + else + joystick->current4way &= ~(JOYDIR_UP_BIT | JOYDIR_DOWN_BIT); + } + } } } - } } -static void save_game_inputs(xml_data_node *parentnode) +/*------------------------------------------------- + frame_update_analog_field - update the + internals of a single analog field +-------------------------------------------------*/ + +static void frame_update_analog_field(analog_field_state *analog) { - int portnum; + input_item_class itemclass; + int keypressed = FALSE; + INT64 keyscale; + INT32 rawvalue; + INT32 delta = 0; - /* iterate over ports */ - for (portnum = 0; input_ports_default[portnum].type != IPT_END; portnum++) + /* clamp the previous value to the min/max range and remember it */ + analog->previous = analog->accum = apply_analog_min_max(analog, analog->accum); + + /* get the new raw analog value and its type */ + rawvalue = input_seq_axis_value(input_field_seq(analog->field, SEQ_TYPE_STANDARD), &itemclass); + + /* if we got an absolute input, it overrides everything else */ + if (itemclass == ITEM_CLASS_ABSOLUTE) { - input_port_entry *defport = &input_ports_default[portnum]; - input_port_entry *curport = &Machine->input_ports[portnum]; - - /* only save if something has changed and this port is a type we save */ - if (save_this_port_type(defport->type) && - ((!port_type_is_analog(defport->type) && (defport->default_value & defport->mask) != (curport->default_value & defport->mask)) || - defport->analog.delta != curport->analog.delta || - defport->analog.centerdelta != curport->analog.centerdelta || - defport->analog.sensitivity != curport->analog.sensitivity || - defport->analog.reverse != curport->analog.reverse || - input_seq_cmp(&defport->seq, &curport->seq) != 0 || - input_seq_cmp(&defport->analog.decseq, &curport->analog.decseq) != 0 || - input_seq_cmp(&defport->analog.incseq, &curport->analog.incseq) != 0)) + if (analog->previousanalog != rawvalue) { - /* add a new port node */ - xml_data_node *portnode = xml_add_child(parentnode, "port", NULL); - if (portnode) + /* only update if analog value changed */ + analog->previousanalog = rawvalue; + + /* apply the inverse of the sensitivity to the raw value so that */ + /* it will still cover the full min->max range requested after */ + /* we apply the sensitivity adjustment */ + if (analog->absolute || (analog->field->flags & ANALOG_FLAG_RESET)) { - /* add the port information and attributes */ - xml_set_attribute(portnode, "type", port_type_to_token(defport->type, defport->player)); - xml_set_attribute_int(portnode, "mask", defport->mask); - xml_set_attribute_int(portnode, "index", portnum); - xml_set_attribute_int(portnode, "defvalue", defport->default_value & defport->mask); - - /* if the value has changed, add it as well */ - if (!port_type_is_analog(defport->type) && defport->default_value != curport->default_value) - xml_set_attribute_int(portnode, "value", curport->default_value & defport->mask); - - /* add analog-specific attributes if they have changed */ - if (port_type_is_analog(defport->type)) + /* if port is absolute, then just return the absolute data supplied */ + analog->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, analog->sensitivity); + } + else if (analog->positionalscale != 0) + { + /* if port is positional, we will take the full analog control and divide it */ + /* into positions, that way as the control is moved full scale, */ + /* it moves through all the positions */ + rawvalue = APPLY_SCALE(rawvalue - INPUT_ABSOLUTE_MIN, analog->positionalscale) * 512 + analog->minimum; + + /* clamp the high value so it does not roll over */ + rawvalue = MIN(rawvalue, analog->maximum); + analog->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, analog->sensitivity); + } + else + /* if port is relative, we use the value to simulate the speed of relative movement */ + /* sensitivity adjustment is allowed for this mode */ + analog->accum += rawvalue; + + analog->lastdigital = 0; + /* do not bother with other control types if the analog data is changing */ + return; + } + else + { + /* we still have to update fake relative from joystick control */ + if (!analog->absolute && analog->positionalscale == 0) + analog->accum += rawvalue; + } + } + + /* if we got it from a relative device, use that as the starting delta */ + /* also note that the last input was not a digital one */ + if (itemclass == ITEM_CLASS_RELATIVE && rawvalue != 0) + { + delta = rawvalue; + analog->lastdigital = 0; + } + + keyscale = (analog->accum >= 0) ? analog->keyscalepos : analog->keyscaleneg; + + /* if the decrement code sequence is pressed, add the key delta to */ + /* the accumulated delta; also note that the last input was a digital one */ + if (input_seq_pressed(input_field_seq(analog->field, SEQ_TYPE_DECREMENT))) + { + keypressed = TRUE; + if (analog->field->delta != 0) + delta -= APPLY_SCALE(analog->field->delta, keyscale); + else if (analog->lastdigital != 1) + /* decrement only once when first pressed */ + delta -= APPLY_SCALE(1, keyscale); + analog->lastdigital = 1; + } + + /* same for the increment code sequence */ + if (input_seq_pressed(input_field_seq(analog->field, SEQ_TYPE_INCREMENT))) + { + keypressed = TRUE; + if (analog->field->delta) + delta += APPLY_SCALE(analog->field->delta, keyscale); + else if (analog->lastdigital != 2) + /* increment only once when first pressed */ + delta += APPLY_SCALE(1, keyscale); + analog->lastdigital = 2; + } + + /* if resetting is requested, clear the accumulated position to 0 before */ + /* applying the deltas so that we only return this frame's delta */ + /* note that centering only works for relative controls */ + /* no need to check if absolute here because it is checked by the validity tests */ + if (analog->field->flags & ANALOG_FLAG_RESET) + analog->accum = 0; + + /* apply the delta to the accumulated value */ + analog->accum += delta; + + /* if our last movement was due to a digital input, and if this control */ + /* type autocenters, and if neither the increment nor the decrement seq */ + /* was pressed, apply autocentering */ + if (analog->autocenter) + { + INT32 center = APPLY_INVERSE_SENSITIVITY(analog->center, analog->sensitivity); + if (analog->lastdigital != 0 && !keypressed) + { + /* autocenter from positive values */ + if (analog->accum >= center) + { + analog->accum -= APPLY_SCALE(analog->field->centerdelta, analog->keyscalepos); + if (analog->accum < center) { - if (defport->analog.delta != curport->analog.delta) - xml_set_attribute_int(portnode, "keydelta", curport->analog.delta); - if (defport->analog.centerdelta != curport->analog.centerdelta) - xml_set_attribute_int(portnode, "centerdelta", curport->analog.centerdelta); - if (defport->analog.sensitivity != curport->analog.sensitivity) - xml_set_attribute_int(portnode, "sensitivity", curport->analog.sensitivity); - if (defport->analog.reverse != curport->analog.reverse) - xml_set_attribute(portnode, "reverse", curport->analog.reverse ? "yes" : "no"); + analog->accum = center; + analog->lastdigital = 0; } + } - /* add only the sequences that have changed from the defaults */ - if (input_seq_cmp(&defport->seq, &curport->seq) != 0) - add_sequence(portnode, 0, defport->type, &curport->seq); - if (input_seq_cmp(&defport->analog.decseq, &curport->analog.decseq) != 0) - add_sequence(portnode, 1, defport->type, &curport->analog.decseq); - if (input_seq_cmp(&defport->analog.incseq, &curport->analog.incseq) != 0) - add_sequence(portnode, 2, defport->type, &curport->analog.incseq); + /* autocenter from negative values */ + else + { + analog->accum += APPLY_SCALE(analog->field->centerdelta, analog->keyscaleneg); + if (analog->accum > center) + { + analog->accum = center; + analog->lastdigital = 0; + } } } } + else if (!keypressed) + analog->lastdigital = 0; } -static void input_port_save(int config_type, xml_data_node *parentnode) +/*------------------------------------------------- + frame_get_digital_field_state - get the state + of a digital field +-------------------------------------------------*/ + +static int frame_get_digital_field_state(const input_field_config *field) { - if (parentnode) + int curstate = input_seq_pressed(input_field_seq(field, SEQ_TYPE_STANDARD)); + int changed = FALSE; + + /* if the state changed, look for switch down/switch up */ + if (curstate != field->state->last) { - /* default ports save differently */ - if (config_type == CONFIG_TYPE_DEFAULT) - save_default_inputs(parentnode); - else - save_game_inputs(parentnode); + field->state->last = curstate; + changed = TRUE; } -} + +#ifdef MESS + /* (MESS-specific) check for disabled keyboard */ + if (field->type == IPT_KEYBOARD && osd_keyboard_disabled()) + return FALSE; +#endif /* MESS */ + /* skip locked-out coin inputs */ + if (field->type >= IPT_COIN1 && field->type <= IPT_COIN8 && coinlockedout[field->type - IPT_COIN1]) + { + ui_popup_time(3, "Coinlock disabled %s.", input_field_name(field)); + return FALSE; + } + /* skip locked-out service inputs */ + if (field->type >= IPT_SERVICE1 && field->type <= IPT_SERVICE4 && servicecoinlockedout[field->type - IPT_SERVICE1]) + { + ui_popup_time(3, "Coinlock disabled %s.", input_field_name(field)); + return FALSE; + } + + /* if this is a switch-down event, handle impulse and toggle */ + if (changed && curstate) + { + /* impluse controls: reset the impulse counter */ + if (field->impulse != 0 && field->state->impulse == 0) + field->state->impulse = field->impulse; -/************************************* - * - * Token to default string - * - *************************************/ + /* toggle controls: flip the toggle state */ + if (field->flags & FIELD_FLAG_TOGGLE) + field->state->toggle = !field->state->toggle; + } + + /* update the current state with the impulse state */ + if (field->impulse != 0 && field->state->impulse != 0) + { + field->state->impulse--; + curstate = TRUE; + } -const char *input_port_string_from_token(const input_port_token token) -{ - int index; + /* update the current state with the toggle state */ + if (field->flags & FIELD_FLAG_TOGGLE) + curstate = field->state->toggle; - if (token.i == 0) - return NULL; - if (token.i >= INPUT_STRING_COUNT) - return token.stringptr; - for (index = 0; index < ARRAY_LENGTH(input_port_default_strings); index++) - if (input_port_default_strings[index].id == token.i) - return input_port_default_strings[index].string; - return "(Unknown Default)"; + /* additional logic to restrict digital joysticks */ + if (curstate && field->state->joystick != NULL && field->way != 16) + { + UINT8 mask = (field->way == 4) ? field->state->joystick->current4way : field->state->joystick->current; + if (!(mask & (1 << field->state->joydir))) + curstate = FALSE; + } + + return curstate; } -/************************************* - * - * Input port detokenizer - * - *************************************/ +/*************************************************************************** + PORT CONFIGURATION HELPERS +***************************************************************************/ -static void input_port_detokenize(input_port_init_params *param, const input_port_token *ipt) +/*------------------------------------------------- + port_config_detokenize - recursively + detokenize a series of input port tokens +-------------------------------------------------*/ + +static input_port_config *port_config_detokenize(input_port_config *listhead, const input_port_token *ipt) { UINT32 entrytype = INPUT_TOKEN_INVALID; - input_port_entry *portentry = NULL; - const char *modify_tag = NULL; - int seq_index[3] = {0}; - + input_setting_config *cursetting = NULL; + input_field_config *curfield = NULL; + input_port_config *curport = NULL; + /* loop over tokens until we hit the end */ while (entrytype != INPUT_TOKEN_END) { UINT32 mask, defval, type, val; input_port_token temptoken; - int hasdiploc, strindex; -#ifdef MESS - UINT16 category; -#endif /* MESS */ + input_condition condition; + int hasdiploc; + int index; /* unpack the token from the first entry */ TOKEN_GET_UINT32_UNPACK1(ipt, entrytype, 8); @@ -1887,80 +2231,148 @@ static void input_port_detokenize(input_port_init_params *param, const input_por /* including */ case INPUT_TOKEN_INCLUDE: - input_port_detokenize(param, TOKEN_GET_PTR(ipt, tokenptr)); + listhead = port_config_detokenize(listhead, TOKEN_GET_PTR(ipt, tokenptr)); break; /* start of a new input port */ case INPUT_TOKEN_START: case INPUT_TOKEN_START_TAG: - modify_tag = NULL; - portentry = input_port_initialize(param, IPT_PORT, NULL, 0, 0); + curport = port_config_alloc((const input_port_config **)&listhead); if (entrytype == INPUT_TOKEN_START_TAG) - portentry->start.tag = TOKEN_GET_STRING(ipt); + curport->tag = TOKEN_GET_STRING(ipt); + curfield = NULL; + cursetting = NULL; break; /* modify an existing port */ case INPUT_TOKEN_MODIFY: - modify_tag = TOKEN_GET_STRING(ipt); + curport = port_config_find(listhead, TOKEN_GET_STRING(ipt)); break; - /* input bit definition */ - case INPUT_TOKEN_BIT: + /* input field definition */ + case INPUT_TOKEN_FIELD: + if (curport == NULL) + fatalerror("INPUT_TOKEN_FIELD encountered with no active port"); + TOKEN_UNGET_UINT32(ipt); TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, type, 24); TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - portentry = input_port_initialize(param, type, modify_tag, mask, defval); - seq_index[0] = seq_index[1] = seq_index[2] = 0; + + curfield = field_config_alloc(curport, type, defval, mask); + cursetting = NULL; break; - case INPUT_TOKEN_SPECIAL_ONOFF: + /* field or setting condition */ + case INPUT_TOKEN_CONDITION: + if (curfield == NULL && cursetting == NULL) + fatalerror("INPUT_TOKEN_CONDITION encountered with no active field or setting"); + TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, hasdiploc, 1, strindex, 23); - TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); + 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; - portentry = input_port_initialize(param, IPT_DIPSWITCH_NAME, modify_tag, mask, mask & defval); - temptoken.i = strindex; - portentry->name = input_port_string_from_token(temptoken); - if (strindex == INPUT_STRING_Service_Mode) - { - portentry->toggle = TRUE; - portentry->seq.code[0] = KEYCODE_F2; - } - if (hasdiploc) - input_port_parse_diplocation(portentry, TOKEN_GET_STRING(ipt)); + /* 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) + fatalerror("INPUT_TOKEN_PLAYERn encountered with no active field"); + curfield->player = entrytype - INPUT_TOKEN_PLAYER1; + break; - portentry = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, mask & defval); - temptoken.i = INPUT_STRING_Off; - portentry->name = input_port_string_from_token(temptoken); + /* field category */ + case INPUT_TOKEN_CATEGORY: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_CATEGORY encountered with no active field"); + TOKEN_UNGET_UINT32(ipt); + TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->category, 24); + break; - portentry = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, mask & ~defval); - temptoken.i = INPUT_STRING_On; - portentry->name = input_port_string_from_token(temptoken); + /* field flags */ + case INPUT_TOKEN_UNUSED: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_UNUSED encountered with no active field"); + curfield->flags |= FIELD_FLAG_UNUSED; break; - /* append a code */ - case INPUT_TOKEN_CODE: - TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); - if (seq_index[0] > 0) - portentry->seq.code[seq_index[0]++] = SEQCODE_OR; - portentry->seq.code[seq_index[0]++] = val; + case INPUT_TOKEN_COCKTAIL: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_COCKTAIL encountered with no active field"); + curfield->flags |= FIELD_FLAG_COCKTAIL; + curfield->player = 1; break; - case INPUT_TOKEN_CODE_DEC: + case INPUT_TOKEN_ROTATED: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_ROTATED encountered with no active field"); + curfield->flags |= FIELD_FLAG_ROTATED; + break; + + case INPUT_TOKEN_TOGGLE: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_TOGGLE encountered with no active field"); + curfield->flags |= FIELD_FLAG_TOGGLE; + break; + + /* field impulse */ + case INPUT_TOKEN_IMPULSE: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_IMPULSE encountered with no active field"); TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); - if (seq_index[1] > 0) - portentry->analog.decseq.code[seq_index[1]++] = SEQCODE_OR; - portentry->analog.decseq.code[seq_index[1]++] = val; + TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->impulse, 24); break; - case INPUT_TOKEN_CODE_INC: + /* field name */ + case INPUT_TOKEN_NAME: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_NAME encountered with no active field"); + curfield->name = input_port_string_from_token(*ipt++); + break; + + /* field code sequence */ + case INPUT_TOKEN_CODE: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_CODE encountered with no active field"); + TOKEN_UNGET_UINT32(ipt); TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); - if (seq_index[2] > 0) - portentry->analog.incseq.code[seq_index[2]++] = SEQCODE_OR; - portentry->analog.incseq.code[seq_index[2]++] = val; + + input_seq_append_or(&curfield->seq[SEQ_TYPE_STANDARD], val); + break; + + /* field custom callback */ + case INPUT_TOKEN_CUSTOM: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_CUSTOM encountered with no active field"); + 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) + fatalerror("INPUT_TOKEN_CHANGED encountered with no active field"); + 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) + fatalerror("INPUT_TOKEN_DIPLOCATION encountered with no active field"); + curfield->diploclist = diplocation_list_alloc(curfield, TOKEN_GET_STRING(ipt)); break; /* joystick flags */ @@ -1968,455 +2380,589 @@ static void input_port_detokenize(input_port_init_params *param, const input_por case INPUT_TOKEN_4WAY: case INPUT_TOKEN_8WAY: case INPUT_TOKEN_16WAY: - portentry->way = 2 << (entrytype - INPUT_TOKEN_2WAY); + if (curfield == NULL) + fatalerror("INPUT_TOKEN_nWAY encountered with no active field"); + curfield->way = 2 << (entrytype - INPUT_TOKEN_2WAY); break; - case INPUT_TOKEN_ROTATED: - portentry->rotated = TRUE; - break; + /* (MESS) natural keyboard support */ + case INPUT_TOKEN_CHAR: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_CHAR encountered with no active field"); - /* general flags */ - case INPUT_TOKEN_NAME: - portentry->name = input_port_string_from_token(*ipt++); + TOKEN_UNGET_UINT32(ipt); + TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, val, 24); + + for (index = 0; index < ARRAY_LENGTH(curfield->chars); index++) + if (curfield->chars[index] == 0) + { + curfield->chars[index] = (unicode_char)val; + break; + } break; - 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: - portentry->player = entrytype - INPUT_TOKEN_PLAYER1; + /* analog minimum/maximum */ + case INPUT_TOKEN_MINMAX: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_MINMAX encountered with no active field"); + TOKEN_GET_UINT64_UNPACK2(ipt, curfield->min, 32, curfield->max, 32); break; - case INPUT_TOKEN_COCKTAIL: - portentry->cocktail = TRUE; - portentry->player = 1; + /* analog sensitivity */ + case INPUT_TOKEN_SENSITIVITY: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_SENSITIVITY encountered with no active field"); + TOKEN_UNGET_UINT32(ipt); + TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->sensitivity, 24); break; - case INPUT_TOKEN_TOGGLE: - portentry->toggle = TRUE; + /* analog keyboard delta */ + case INPUT_TOKEN_KEYDELTA: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_KEYDELTA encountered with no active field"); + TOKEN_UNGET_UINT32(ipt); + TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->delta, -24); + curfield->centerdelta = curfield->delta; break; - case INPUT_TOKEN_IMPULSE: + /* analog autocenter delta */ + case INPUT_TOKEN_CENTERDELTA: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_CENTERDELTA encountered with no active field"); TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->impulse, 24); + TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->centerdelta, -24); break; + /* analog reverse flags */ case INPUT_TOKEN_REVERSE: - portentry->analog.reverse = TRUE; + if (curfield == NULL) + fatalerror("INPUT_TOKEN_REVERSE encountered with no active field"); + curfield->flags |= ANALOG_FLAG_REVERSE; break; case INPUT_TOKEN_RESET: - portentry->analog.reset = TRUE; + if (curfield == NULL) + fatalerror("INPUT_TOKEN_RESET encountered with no active field"); + curfield->flags |= ANALOG_FLAG_RESET; break; - case INPUT_TOKEN_UNUSED: - portentry->unused = TRUE; + case INPUT_TOKEN_WRAPS: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_WRAPS encountered with no active field"); + curfield->flags |= ANALOG_FLAG_WRAPS; break; - /* analog settings */ - case INPUT_TOKEN_MINMAX: - TOKEN_GET_UINT64_UNPACK2(ipt, portentry->analog.min, 32, portentry->analog.max, 32); + case INPUT_TOKEN_INVERT: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_INVERT encountered with no active field"); + curfield->flags |= ANALOG_FLAG_INVERT; break; - case INPUT_TOKEN_SENSITIVITY: - TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.sensitivity, 24); - break; + /* analog crosshair parameters */ + case INPUT_TOKEN_CROSSHAIR: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_CROSSHAIR encountered with no active field"); - case INPUT_TOKEN_KEYDELTA: TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.delta, -24); - portentry->analog.centerdelta = portentry->analog.delta; + 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; - case INPUT_TOKEN_CENTERDELTA: + /* analog decrement sequence */ + case INPUT_TOKEN_CODE_DEC: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_CODE_DEC encountered with no active field"); + index = entrytype - INPUT_TOKEN_CODE; + TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.centerdelta, -24); + TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); + + input_seq_append_or(&curfield->seq[SEQ_TYPE_DECREMENT], val); break; - case INPUT_TOKEN_CROSSHAIR: + /* analog increment sequence */ + case INPUT_TOKEN_CODE_INC: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_CODE_INC encountered with no active field"); + index = entrytype - INPUT_TOKEN_CODE; + TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, portentry->analog.crossaxis, 4, portentry->analog.crossaltaxis, -20); - TOKEN_GET_UINT64_UNPACK2(ipt, portentry->analog.crossscale, -32, portentry->analog.crossoffset, -32); - portentry->analog.crossaltaxis *= 1.0f / 65536.0f; - portentry->analog.crossscale *= 1.0f / 65536.0f; - portentry->analog.crossoffset *= 1.0f / 65536.0f; + TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); + + input_seq_append_or(&curfield->seq[SEQ_TYPE_INCREMENT], val); break; + /* analog wraps flag */ + case INPUT_TOKEN_FULL_TURN_COUNT: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_FULL_TURN_COUNT encountered with no active field"); TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.full_turn_count, 24); + TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->full_turn_count, 24); break; case INPUT_TOKEN_POSITIONS: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_POSITIONS encountered with no active field"); TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.max, 24); - break; - - case INPUT_TOKEN_WRAPS: - portentry->analog.wraps = TRUE; + TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->max, 24); break; case INPUT_TOKEN_REMAP_TABLE: - portentry->analog.remap_table = TOKEN_GET_PTR(ipt, ui32ptr); + if (curfield == NULL) + fatalerror("INPUT_TOKEN_REMAP_TABLE encountered with no active field"); + curfield->remap_table = TOKEN_GET_PTR(ipt, ui32ptr); break; - case INPUT_TOKEN_INVERT: - portentry->analog.invert = TRUE; - break; + /* DIP switch definition */ + case INPUT_TOKEN_DIPNAME: + if (curport == NULL) + fatalerror("INPUT_TOKEN_DIPNAME encountered with no active port"); - /* custom callbacks */ - case INPUT_TOKEN_CUSTOM: - portentry->custom = TOKEN_GET_PTR(ipt, customptr); - portentry->custom_param = (void *)TOKEN_GET_PTR(ipt, voidptr); - break; + TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - /* changed callbacks */ - case INPUT_TOKEN_CHANGED: - portentry->changed = TOKEN_GET_PTR(ipt, changedptr); - portentry->changed_param = (void *)TOKEN_GET_PTR(ipt, voidptr); - break; + curfield = field_config_alloc(curport, IPT_DIPSWITCH, defval, mask); + cursetting = NULL; - /* dip switch definition */ - case INPUT_TOKEN_DIPNAME: - TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - portentry = input_port_initialize(param, IPT_DIPSWITCH_NAME, modify_tag, mask, defval); - seq_index[0] = seq_index[1] = seq_index[2] = 0; - portentry->name = input_port_string_from_token(*ipt++); + curfield->name = input_port_string_from_token(*ipt++); break; + /* DIP switch setting */ case INPUT_TOKEN_DIPSETTING: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_DIPSETTING encountered with no active field"); + TOKEN_UNGET_UINT32(ipt); TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); - portentry = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, defval); - seq_index[0] = seq_index[1] = seq_index[2] = 0; - portentry->name = input_port_string_from_token(*ipt++); + + cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++)); break; - /* physical location */ - case INPUT_TOKEN_DIPLOCATION: - input_port_parse_diplocation(portentry, TOKEN_GET_STRING(ipt)); - break; + /* special DIP switch with on/off values */ + case INPUT_TOKEN_SPECIAL_ONOFF: + if (curport == NULL) + fatalerror("INPUT_TOKEN_SPECIAL_ONOFF encountered with no active port"); - /* conditionals for dip switch settings */ - case INPUT_TOKEN_CONDITION: TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->condition.condition, 24); - TOKEN_GET_UINT64_UNPACK2(ipt, portentry->condition.mask, 32, portentry->condition.value, 32); - portentry->condition.tag = TOKEN_GET_STRING(ipt); - break; + TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, hasdiploc, 1, temptoken.i, 23); + TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - /* analog adjuster definition */ - case INPUT_TOKEN_ADJUSTER: - TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); - portentry = input_port_initialize(param, IPT_ADJUSTER, modify_tag, 0xff, defval | (defval << 8)); - seq_index[0] = seq_index[1] = seq_index[2] = 0; - portentry->name = TOKEN_GET_STRING(ipt); + 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) + curfield->diploclist = diplocation_list_alloc(curfield, TOKEN_GET_STRING(ipt)); + + 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)); break; /* configuration definition */ case INPUT_TOKEN_CONFNAME: + if (curport == NULL) + fatalerror("INPUT_TOKEN_CONFNAME encountered with no active port"); + TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - portentry = input_port_initialize(param, IPT_CONFIG_NAME, modify_tag, mask, defval); - seq_index[0] = seq_index[1] = seq_index[2] = 0; - portentry->name = input_port_string_from_token(*ipt++); + + 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: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_CONFSETTING encountered with no active field"); + TOKEN_UNGET_UINT32(ipt); TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); - portentry = input_port_initialize(param, IPT_CONFIG_SETTING, modify_tag, 0, defval); - seq_index[0] = seq_index[1] = seq_index[2] = 0; - portentry->name = input_port_string_from_token(*ipt++); + + cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++)); break; -#ifdef MESS - case INPUT_TOKEN_CHAR: - TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); - { - int ch; - for (ch = 0; portentry->keyboard.chars[ch] != 0; ch++) - ; - portentry->keyboard.chars[ch] = (unicode_char) val; - } + /* configuration definition */ + case INPUT_TOKEN_CATEGORY_NAME: + if (curport == NULL) + fatalerror("INPUT_TOKEN_CATEGORY_NAME encountered with no active port"); + + TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); + + curfield = field_config_alloc(curport, IPT_CATEGORY, defval, mask); + cursetting = NULL; + + curfield->name = input_port_string_from_token(*ipt++); break; - /* category definition */ - case INPUT_TOKEN_CATEGORY: + /* configuration setting */ + case INPUT_TOKEN_CATEGORY_SETTING: + if (curfield == NULL) + fatalerror("INPUT_TOKEN_CATEGORY_SETTING encountered with no active field"); + TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->category, 24); + TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); + + cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++)); break; - case INPUT_TOKEN_CATEGORY_NAME: - TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); - portentry = input_port_initialize(param, IPT_CATEGORY_NAME, modify_tag, mask, defval); - seq_index[0] = seq_index[1] = seq_index[2] = 0; - portentry->name = input_port_string_from_token(*ipt++); - break; + /* analog adjuster definition */ + case INPUT_TOKEN_ADJUSTER: + if (curport == NULL) + fatalerror("INPUT_TOKEN_ADJUSTER encountered with no active port"); - case INPUT_TOKEN_CATEGORY_SETTING: TOKEN_UNGET_UINT32(ipt); - TOKEN_GET_UINT64_UNPACK3(ipt, entrytype, 8, defval, 32, category, 16); - portentry = input_port_initialize(param, IPT_CATEGORY_SETTING, modify_tag, 0, defval); - seq_index[0] = seq_index[1] = seq_index[2] = 0; - portentry->name = input_port_string_from_token(*ipt++); - portentry->category = category; + TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); + + curfield = field_config_alloc(curport, IPT_ADJUSTER, defval, 0xff); + cursetting = NULL; + + curfield->name = TOKEN_GET_STRING(ipt); break; -#endif /* MESS */ default: fatalerror("Invalid token %d in input ports\n", entrytype); break; } } + + return listhead; } +/*------------------------------------------------- + port_config_alloc - allocate a new input + port config and append to the end of the + given list +-------------------------------------------------*/ + +static input_port_config *port_config_alloc(const input_port_config **listhead) +{ + const input_port_config * const *tailptr; + input_port_config *config; + + /* allocate memory */ + config = malloc_or_die(sizeof(*config)); + memset(config, 0, sizeof(*config)); + + /* add it to the tail */ + for (tailptr = listhead; *tailptr != NULL; tailptr = &(*tailptr)->next) ; + *(input_port_config **)tailptr = config; + + return config; +} + -/************************************* - * - * Input port construction - * - *************************************/ +/*------------------------------------------------- + port_config_free - free an allocated input + port configuration +-------------------------------------------------*/ -input_port_entry *input_port_initialize(input_port_init_params *iip, UINT32 type, const char *tag, UINT32 mask, UINT32 defval) +static void port_config_free(const input_port_config **portptr) { - /* this function is used within an INPUT_PORT callback to set up a single port */ - input_port_entry *portentry; - input_code code; + input_port_config *port = (input_port_config *)*portptr; + + /* free any field configs first */ + while (port->fieldlist != NULL) + field_config_free((input_field_config **)&port->fieldlist); + + /* remove ourself from the list */ + *portptr = port->next; + + /* free ourself */ + free(port); +} - /* are we modifying an existing port? */ - if (tag != NULL) - { - int portnum, deleting; - /* find the matching port */ - for (portnum = 0; portnum < iip->current_port; portnum++) - if (iip->ports[portnum].type == IPT_PORT && iip->ports[portnum].start.tag != NULL && !strcmp(iip->ports[portnum].start.tag, tag)) - break; - if (portnum >= iip->current_port) - fatalerror("Could not find port to modify: '%s'", tag); +/*------------------------------------------------- + port_config_find - locate an existing port + configuration by tag +-------------------------------------------------*/ - /* nuke any matching masks */ - for (portnum++, deleting = 0; portnum < iip->current_port && iip->ports[portnum].type != IPT_PORT; portnum++) - { - deleting = (iip->ports[portnum].mask & mask) || (deleting && iip->ports[portnum].mask == 0); - if (deleting) - { - iip->current_port--; - memmove(&iip->ports[portnum], &iip->ports[portnum + 1], (iip->current_port - portnum) * sizeof(iip->ports[0])); - portnum--; - } - } +static input_port_config *port_config_find(const input_port_config *listhead, const char *tag) +{ + const input_port_config *scanport; - /* allocate space for a new port at the end of this entry */ - if (iip->current_port >= iip->max_ports) - fatalerror("Too many input ports"); - if (portnum < iip->current_port) - { - memmove(&iip->ports[portnum + 1], &iip->ports[portnum], (iip->current_port - portnum) * sizeof(iip->ports[0])); - iip->current_port++; - portentry = &iip->ports[portnum]; - } - else - portentry = &iip->ports[iip->current_port++]; - } + /* scan for a matching tag and return the matching port */ + for (scanport = listhead; scanport != NULL; scanport = scanport->next) + if (scanport->tag != NULL && strcmp(scanport->tag, tag) == 0) + return (input_port_config *)scanport; + + /* failure is fatal */ + fatalerror("port_config_find failed to find a matching port '%s'", tag); +} - /* otherwise, just allocate a new one from the end */ - else - { - if (iip->current_port >= iip->max_ports) - fatalerror("Too many input ports"); - portentry = &iip->ports[iip->current_port++]; - } - /* set up defaults */ - memset(portentry, 0, sizeof(*portentry)); - portentry->name = IP_NAME_DEFAULT; - portentry->type = type; - portentry->mask = mask; - portentry->default_value = defval; +/*------------------------------------------------- + field_config_alloc - allocate a new input + port field config, replacing any intersecting + fields already present and inserting at the + correct sorted location +-------------------------------------------------*/ - /* default min to 0 and max to the mask value */ - /* they can be overwritten by PORT_MINMAX */ - if (port_type_is_analog(portentry->type) && !portentry->analog.min && !portentry->analog.max) - portentry->analog.max = portentry->mask; +static input_field_config *field_config_alloc(input_port_config *port, int type, input_port_value defvalue, input_port_value maskbits) +{ + const input_field_config * const *scanfieldptr; + const input_field_config * const *scanfieldnextptr; + input_field_config *config; + input_port_value lowbit; + int seqtype; - /* sets up default port codes */ - switch (portentry->type) + /* first modify/nuke any entries that intersect our maskbits */ + for (scanfieldptr = &port->fieldlist; *scanfieldptr != NULL; scanfieldptr = scanfieldnextptr) { - case IPT_DIPSWITCH_NAME: - case IPT_DIPSWITCH_SETTING: - case IPT_CONFIG_NAME: - case IPT_CONFIG_SETTING: - code = SEQCODE_END; - break; - - default: - code = SEQCODE_DEFAULT; - break; + scanfieldnextptr = &(*scanfieldptr)->next; + if (((*scanfieldptr)->mask & maskbits) != 0) + { + /* reduce the mask of the field we found */ + config = (input_field_config *)*scanfieldptr; + config->mask &= ~maskbits; + + /* if the new entry fully overrides the previous one, we nuke */ + if (config->mask == 0) + { + field_config_free((input_field_config **)scanfieldptr); + scanfieldnextptr = scanfieldptr; + } + } } - - /* set the default codes */ - input_seq_set_1(&portentry->seq, code); - input_seq_set_1(&portentry->analog.incseq, code); - input_seq_set_1(&portentry->analog.decseq, code); - return portentry; + + /* make a mask of just the low bit */ + lowbit = (maskbits ^ (maskbits - 1)) & maskbits; + + /* scan forward to find where to insert ourselves */ + for (scanfieldptr = (const input_field_config * const *)&port->fieldlist; *scanfieldptr != NULL; scanfieldptr = &(*scanfieldptr)->next) + if ((*scanfieldptr)->mask > lowbit) + break; + + /* allocate memory */ + config = malloc_or_die(sizeof(*config)); + memset(config, 0, sizeof(*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); + + /* insert it into the list */ + config->next = *scanfieldptr; + *(input_field_config **)scanfieldptr = config; + + return config; } -input_port_entry *input_port_allocate(const input_port_token *ipt, input_port_entry *memory) +/*------------------------------------------------- + field_config_free - free an allocated input + field configuration +-------------------------------------------------*/ + +static void field_config_free(input_field_config **fieldptr) { - input_port_init_params iip; + 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 */ + free(field); +} - /* set up the port parameter structure */ - iip.max_ports = MAX_INPUT_PORTS * MAX_BITS_PER_PORT; - iip.current_port = 0; - /* allocate memory for the input ports */ - if (memory == NULL) - iip.ports = (input_port_entry *)auto_malloc(iip.max_ports * sizeof(*iip.ports)); - else - iip.ports = memory; - memset(iip.ports, 0, iip.max_ports * sizeof(*iip.ports)); +/*------------------------------------------------- + setting_config_alloc - allocate a new input + port setting and append it to the end of the + list +-------------------------------------------------*/ - /* construct the ports */ - input_port_detokenize(&iip, ipt); +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 = malloc_or_die(sizeof(*config)); + memset(config, 0, sizeof(*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; +} - /* append final IPT_END */ - input_port_initialize(&iip, IPT_END, NULL, 0, 0); -#ifdef MESS - /* process MESS specific extensions to the port */ - inputx_handle_mess_extensions(iip.ports); -#endif +/*------------------------------------------------- + setting_config_free - free an allocated input + setting configuration +-------------------------------------------------*/ - return iip.ports; +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 */ + free(setting); } -void input_port_parse_diplocation(input_port_entry *in, const char *location) +/*------------------------------------------------- + diplocation_expand - expand a string-based + DIP location into a linked list of + descriptions +-------------------------------------------------*/ + +static const input_field_diplocation *diplocation_list_alloc(const input_field_config *field, const char *location) { - char *curname = NULL, tempbuf[100]; - const char *entry; - int index, val, bits; - UINT32 temp; + 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) - return; - memset(in->diploc, 0, sizeof(in->diploc)); + if (location == NULL) + return NULL; /* parse the string */ - for (index = 0, entry = location; *entry && index < ARRAY_LENGTH(in->diploc); index++) + while (*curentry != 0) { const char *comma, *colon, *number; + + /* allocate a new entry */ + *tailptr = malloc_or_die(sizeof(**tailptr)); + memset(*tailptr, 0, sizeof(**tailptr)); + entries++; /* find the end of this entry */ - comma = strchr(entry, ','); + comma = strchr(curentry, ','); if (comma == NULL) - comma = entry + strlen(entry); + comma = curentry + strlen(curentry); /* extract it to tempbuf */ - strncpy(tempbuf, entry, comma - entry); - tempbuf[comma - entry] = 0; + strncpy(tempbuf, curentry, comma - curentry); + tempbuf[comma - curentry] = 0; /* first extract the switch name if present */ number = tempbuf; colon = strchr(tempbuf, ':'); + + /* allocate and copy the name if it is present */ if (colon != NULL) { - curname = auto_malloc(colon - tempbuf + 1); - strncpy(curname, tempbuf, colon - tempbuf); - curname[colon - tempbuf] = 0; + (*tailptr)->swname = lastname = malloc_or_die(colon - tempbuf + 1); + strncpy(lastname, tempbuf, colon - tempbuf); + lastname[colon - tempbuf] = 0; number = colon + 1; } - - /* if we don't have a name by now, we're screwed */ - if (curname == NULL) - fatalerror("Switch location '%s' missing switch name!", location); + + /* otherwise, just copy the last name */ + else + { + char *namecopy; + if (lastname == NULL) + fatalerror("Switch location '%s' missing switch name!", location); + (*tailptr)->swname = namecopy = malloc_or_die(strlen(lastname) + 1); + strcpy(namecopy, lastname); + } /* if the number is preceded by a '!' it's active high */ + (*tailptr)->invert = FALSE; if (*number == '!') { - in->diploc[index].invert = 1; + (*tailptr)->invert = TRUE; number++; } - else - in->diploc[index].invert = 0; /* now scan the switch number */ if (sscanf(number, "%d", &val) != 1) fatalerror("Switch location '%s' has invalid format!", location); - - /* fill the entry and bump the index */ - in->diploc[index].swname = curname; - in->diploc[index].swnum = val; + (*tailptr)->swnum = val; /* advance to the next item */ - entry = comma; - if (*entry) - entry++; + curentry = comma; + if (*curentry != 0) + curentry++; + tailptr = &(*tailptr)->next; } /* then verify the number of bits in the mask matches */ - for (bits = 0, temp = in->mask; temp && bits < 32; bits++) + for (bits = 0, temp = field->mask; temp != 0 && bits < 32; bits++) temp &= temp - 1; - if (bits != index) - fatalerror("Switch location '%s' does not describe enough bits for mask %X\n", location, in->mask); + if (bits != entries) + fatalerror("Switch location '%s' does not describe enough bits for mask %X\n", location, field->mask); + return head; } +/*------------------------------------------------- + diplocation_free - free an allocated dip + location +-------------------------------------------------*/ -/************************************* - * - * List access - * - *************************************/ - -input_port_default_entry *get_input_port_list(void) -{ - return default_ports; -} - - -const input_port_default_entry *get_input_port_list_defaults(void) +static void diplocation_free(input_field_diplocation **diplocptr) { - return default_ports_backup; + input_field_diplocation *diploc = (input_field_diplocation *)*diplocptr; + + /* free the name */ + if (diploc->swname != NULL) + free((void *)diploc->swname); + + /* remove ourself from the list */ + *diplocptr = (input_field_diplocation *)diploc->next; + + /* free ourself */ + free(diploc); } -/************************************* - * - * Input port tokens - * - *************************************/ - -const char *port_type_to_token(int type, int player) -{ - static char tempbuf[32]; - int defindex; - - /* look up the port and return the token */ - defindex = default_ports_lookup[type][player]; - if (defindex != -1) - return default_ports[defindex].token; - - /* if that fails, carry on */ - sprintf(tempbuf, "TYPE_OTHER(%d,%d)", type, player); - return tempbuf; -} +/*************************************************************************** + TOKENIZATION HELPERS +***************************************************************************/ +/*------------------------------------------------- + token_to_input_field_type - convert a string + token to an input field type and player +-------------------------------------------------*/ -int token_to_port_type(const char *string, int *player) +static int token_to_input_field_type(running_machine *machine, const char *string, int *player) { + input_port_private *portdata = machine->input_port_data; + const input_type_desc *typedesc; int ipnum; /* check for our failsafe case first */ @@ -2424,11 +2970,11 @@ int token_to_port_type(const char *string, int *player) return ipnum; /* find the token in the list */ - for (ipnum = 0; ipnum < input_port_count; ipnum++) - if (default_ports[ipnum].token != NULL && !strcmp(default_ports[ipnum].token, string)) + for (typedesc = &portdata->typestatelist->typedesc; typedesc != NULL; typedesc = typedesc->next) + if (typedesc->token != NULL && !strcmp(typedesc->token, string)) { - *player = default_ports[ipnum].player; - return default_ports[ipnum].type; + *player = typedesc->player; + return typedesc->type; } /* if we fail, return IPT_UNKNOWN */ @@ -2437,1127 +2983,717 @@ int token_to_port_type(const char *string, int *player) } +/*------------------------------------------------- + input_field_type_to_token - convert an input + field type and player to a string token +-------------------------------------------------*/ -/************************************* - * - * Input port getters - * - *************************************/ - -int input_port_active(const input_port_entry *portentry) -{ - return (input_port_name(portentry) != NULL && !portentry->unused); -} - - -int port_type_is_analog(int type) +static const char *input_field_type_to_token(running_machine *machine, int type, int player) { - return (type >= __ipt_analog_start && type <= __ipt_analog_end); -} + input_port_private *portdata = machine->input_port_data; + input_type_state *typestate; + static char tempbuf[32]; + /* look up the port and return the token */ + typestate = portdata->type_to_typestate[type][player]; + if (typestate != NULL) + return typestate->typedesc.token; -int port_type_is_analog_absolute(int type) -{ - return (type >= __ipt_analog_absolute_start && type <= __ipt_analog_absolute_end); + /* if that fails, carry on */ + sprintf(tempbuf, "TYPE_OTHER(%d,%d)", type, player); + return tempbuf; } -int port_type_in_use(int type) -{ - input_port_entry *portentry; - for (portentry = Machine->input_ports; portentry->type != IPT_END; portentry++) - if (portentry->type == type) - return 1; - return 0; -} - +/*------------------------------------------------- + token_to_seq_type - convert a string to + a sequence type +-------------------------------------------------*/ -int port_type_to_group(int type, int player) +static int token_to_seq_type(const char *string) { - int defindex = default_ports_lookup[type][player]; - if (defindex != -1) - return default_ports[defindex].group; - return IPG_INVALID; -} - + int seqindex; -int port_tag_to_index(const char *tag) -{ - int portnum; + /* look up the string in the table of possible sequence types and return the index */ + for (seqindex = 0; seqindex < ARRAY_LENGTH(seqtypestrings); seqindex++) + if (!mame_stricmp(string, seqtypestrings[seqindex])) + return seqindex; - /* find the matching tag */ - for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) - if (port_info[portnum].tag != NULL && !strcmp(port_info[portnum].tag, tag)) - return portnum; return -1; } -read8_machine_func port_tag_to_handler8(const char *tag) -{ - int portnum = port_tag_to_index(tag); - return (portnum == -1) ? SMH_NOP : port_handler8[portnum]; -} - -read16_machine_func port_tag_to_handler16(const char *tag) -{ - int portnum = port_tag_to_index(tag); - return (portnum == -1) ? SMH_NOP : port_handler16[portnum]; -} - - -read32_machine_func port_tag_to_handler32(const char *tag) -{ - int portnum = port_tag_to_index(tag); - return (portnum == -1) ? SMH_NOP : port_handler32[portnum]; -} - - -read64_machine_func port_tag_to_handler64(const char *tag) -{ - return SMH_NOP; -} +/*************************************************************************** + SETTINGS LOAD +***************************************************************************/ +/*------------------------------------------------- + load_config_callback - callback to extract + configuration data from the XML nodes +-------------------------------------------------*/ -const char *input_port_name(const input_port_entry *portentry) +static void load_config_callback(running_machine *machine, int config_type, xml_data_node *parentnode) { - int defindex; - - /* if we have a non-default name, use that */ - if (portentry->name != IP_NAME_DEFAULT) - return portentry->name; - - /* if the port exists, return the default name */ - defindex = default_ports_lookup[portentry->type][portentry->player]; - if (defindex != -1) - return default_ports[defindex].name; - - /* should never get here */ - return NULL; -} + input_port_private *portdata = machine->input_port_data; + xml_data_node *portnode; + int seqtype; + /* in the completion phase, we finish the initialization with the final ports */ + if (config_type == CONFIG_TYPE_FINAL) + frame_update(machine); -const input_seq *input_port_seq(input_port_entry *portentry, input_seq_type seqtype) -{ - static const input_seq ip_none = SEQ_DEF_0; - input_seq *portseq; + /* early exit if no data to parse */ + if (parentnode == NULL) + return; - /* if port is disabled, return no key */ - if (portentry->unused) - return &ip_none; + /* iterate over all the remap nodes for controller configs only */ + if (config_type == CONFIG_TYPE_CONTROLLER) + load_remap_table(machine, parentnode); - /* handle the various seq types */ - switch (seqtype) + /* iterate over all the port nodes */ + for (portnode = xml_get_sibling(parentnode->child, "port"); portnode; portnode = xml_get_sibling(portnode->next, "port")) { - case SEQ_TYPE_STANDARD: - portseq = &portentry->seq; - break; - - case SEQ_TYPE_INCREMENT: - if (!IS_ANALOG(portentry)) - return &ip_none; - portseq = &portentry->analog.incseq; - break; - - case SEQ_TYPE_DECREMENT: - if (!IS_ANALOG(portentry)) - return &ip_none; - portseq = &portentry->analog.decseq; - break; - - default: - return &ip_none; - } - - /* does this override the default? if so, return it directly */ - if (input_seq_get_1(portseq) != SEQCODE_DEFAULT) - return portseq; - - /* otherwise find the default setting */ - return input_port_default_seq(portentry->type, portentry->player, seqtype); -} + input_seq newseq[SEQ_TYPE_TOTAL], tempseq; + xml_data_node *seqnode; + int type, player; + /* get the basic port info from the attributes */ + type = token_to_input_field_type(machine, xml_get_attribute_string(portnode, "type", ""), &player); -const input_seq *input_port_default_seq(int type, int player, input_seq_type seqtype) -{ - static const input_seq ip_none = SEQ_DEF_0; + /* initialize sequences to invalid defaults */ + for (seqtype = 0; seqtype < ARRAY_LENGTH(newseq); seqtype++) + input_seq_set_1(&newseq[seqtype], INPUT_CODE_INVALID); - /* find the default setting */ - int defindex = default_ports_lookup[type][player]; - if (defindex != -1) - { - switch (seqtype) + /* loop over new sequences */ + for (seqnode = xml_get_sibling(portnode->child, "newseq"); seqnode; seqnode = xml_get_sibling(seqnode->next, "newseq")) { - case SEQ_TYPE_STANDARD: - return &default_ports[defindex].defaultseq; - case SEQ_TYPE_INCREMENT: - return &default_ports[defindex].defaultincseq; - case SEQ_TYPE_DECREMENT: - return &default_ports[defindex].defaultdecseq; + /* with a valid type, parse out the new sequence */ + seqtype = token_to_seq_type(xml_get_attribute_string(seqnode, "type", "")); + if (seqtype != -1 && seqnode->value != NULL) + { + if (strcmp(seqnode->value, "NONE") == 0) + input_seq_set_0(&newseq[seqtype]); + else if (input_seq_from_tokens(seqnode->value, &tempseq) != 0) + newseq[seqtype] = tempseq; + } } - } - return &ip_none; -} + /* if we're loading default ports, apply to the defaults */ + if (config_type != CONFIG_TYPE_GAME) + load_default_config(machine, portnode, type, player, newseq); + else + load_game_config(machine, portnode, type, player, newseq); + } -int input_port_condition(const input_port_entry *in) -{ - switch (in->condition.condition) + /* after applying the controller config, push that back into the backup, since that is */ + /* what we will diff against */ + if (config_type == CONFIG_TYPE_CONTROLLER) { - case PORTCOND_EQUALS: - return ((input_port_read_indexed(Machine, in->condition.portnum) & in->condition.mask) == in->condition.value); - case PORTCOND_NOTEQUALS: - return ((input_port_read_indexed(Machine, in->condition.portnum) & in->condition.mask) != in->condition.value); + input_type_state *typestate; + int seqtype; + + for (typestate = portdata->typestatelist; typestate != NULL; typestate = typestate->next) + for (seqtype = 0; seqtype < ARRAY_LENGTH(typestate->typedesc.seq); seqtype++) + typestate->typedesc.seq[seqtype] = typestate->seq[seqtype]; } - return 1; } +/*------------------------------------------------- + load_remap_table - extract and apply the + global remapping table +-------------------------------------------------*/ -/************************************* - * - * Key sequence handlers - * - *************************************/ - -int input_port_type_pressed(int type, int player) -{ - int defindex = default_ports_lookup[type][player]; - if (defindex != -1) - return input_seq_pressed(&default_ports[defindex].defaultseq); - - return 0; -} - - -int input_ui_pressed(int code) +static void load_remap_table(running_machine *machine, xml_data_node *parentnode) { - int pressed; + input_port_private *portdata = machine->input_port_data; + input_code *oldtable, *newtable; + xml_data_node *remapnode; + int count; -profiler_mark(PROFILER_INPUT); + /* count items first so we can allocate */ + count = 0; + for (remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode != NULL; remapnode = xml_get_sibling(remapnode->next, "remap")) + count++; - /* get the status of this key (assumed to be only in the defaults) */ - pressed = input_seq_pressed(input_port_default_seq(code, 0, SEQ_TYPE_STANDARD)); - - /* if pressed, handle it specially */ - if (pressed) + /* if we have some, deal with them */ + if (count > 0) { - /* if this is the first press, leave pressed = 1 */ - if (ui_memory[code] == 0) - ui_memory[code] = 1; - - /* otherwise, reset pressed = 0 */ - else - pressed = 0; - } - - /* if we're not pressed, reset the memory field */ - else - ui_memory[code] = 0; + int remapnum; -profiler_mark(PROFILER_END); - - return pressed; -} + /* allocate tables */ + oldtable = malloc_or_die(count * sizeof(*oldtable)); + newtable = malloc_or_die(count * sizeof(*newtable)); - -int input_ui_pressed_repeat(int code, int speed) -{ - static osd_ticks_t lastdown; - static osd_ticks_t keydelay; - int pressed; - -profiler_mark(PROFILER_INPUT); - - /* get the status of this key (assumed to be only in the defaults) */ - pressed = input_seq_pressed(input_port_default_seq(code, 0, SEQ_TYPE_STANDARD)); - - /* if so, handle it specially */ - if (pressed) - { - /* if this is the first press, set a 3x delay and leave pressed = 1 */ - if (ui_memory[code] == 0) + /* build up the remap table */ + count = 0; + for (remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode != NULL; remapnode = xml_get_sibling(remapnode->next, "remap")) { - ui_memory[code] = 1; - lastdown = osd_ticks(); - keydelay = 3 * speed * osd_ticks_per_second() / 60; + input_code origcode = input_code_from_token(xml_get_attribute_string(remapnode, "origcode", "")); + input_code newcode = input_code_from_token(xml_get_attribute_string(remapnode, "newcode", "")); + if (origcode != INPUT_CODE_INVALID && newcode != INPUT_CODE_INVALID) + { + oldtable[count] = origcode; + newtable[count] = newcode; + count++; + } } - /* if this is an autorepeat case, set a 1x delay and leave pressed = 1 */ - else if (osd_ticks() - lastdown >= keydelay) + /* loop over the remapping table, operating only if something was specified */ + for (remapnum = 0; remapnum < count; remapnum++) { - lastdown += keydelay; - keydelay = 1 * speed * osd_ticks_per_second() / 60; - } + input_code oldcode = oldtable[remapnum]; + input_code newcode = newtable[remapnum]; + input_type_state *typestate; - /* otherwise, reset pressed = 0 */ - else - pressed = 0; - } - - /* if we're not pressed, reset the memory field */ - else - ui_memory[code] = 0; + /* loop over all default ports, remapping the requested keys */ + for (typestate = portdata->typestatelist; typestate != NULL; typestate = typestate->next) + { + int seqtype, codenum; -profiler_mark(PROFILER_END); + /* remap anything in the default sequences */ + for (seqtype = 0; seqtype < ARRAY_LENGTH(typestate->seq); seqtype++) + for (codenum = 0; codenum < ARRAY_LENGTH(typestate->seq[0].code); codenum++) + if (typestate->seq[seqtype].code[codenum] == oldcode) + typestate->seq[seqtype].code[codenum] = newcode; + } + } - return pressed; + /* release the tables */ + free(oldtable); + free(newtable); + } } +/*------------------------------------------------- + load_default_config - apply configuration + data to the default mappings +-------------------------------------------------*/ -/************************************* - * - * Update default ports - * - *************************************/ - -void input_port_update_defaults(void) +static int load_default_config(running_machine *machine, xml_data_node *portnode, int type, int player, const input_seq *newseq) { - int loopnum, portnum; + input_port_private *portdata = machine->input_port_data; + input_type_state *typestate; + int seqtype; - /* two passes to catch conditionals properly */ - for (loopnum = 0; loopnum < 2; loopnum++) - - /* loop over all input ports */ - for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) + /* find a matching port in the list */ + for (typestate = portdata->typestatelist; typestate != NULL; typestate = typestate->next) + if (typestate->typedesc.type == type && typestate->typedesc.player == player) { - input_port_info *portinfo = &port_info[portnum]; - input_bit_info *info; - int bitnum; - - /* only clear on the first pass */ - if (loopnum == 0) - portinfo->defvalue = 0; - - /* first compute the default value for the entire port */ - for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->portentry; bitnum++, info++) - if (input_port_condition(info->portentry)) - portinfo->defvalue = (portinfo->defvalue & ~info->portentry->mask) | (info->portentry->default_value & info->portentry->mask); + for (seqtype = 0; seqtype < ARRAY_LENGTH(typestate->seq); seqtype++) + if (input_seq_get_1(&newseq[seqtype]) != INPUT_CODE_INVALID) + typestate->seq[seqtype] = newseq[seqtype]; + return TRUE; } -} - - -/************************************* - * - * VBLANK start routine - * - *************************************/ - -static void input_port_frame(running_machine *machine) -{ - /* if we're paused, don't do anything */ - if (mame_is_paused(machine)) - return; - - /* otherwise, use the common code */ - input_port_frame_update(machine); + return FALSE; } -static void input_port_frame_update(running_machine *machine) -{ - int ui_visible = ui_is_menu_active() || ui_is_slider_active(); - attotime curtime = timer_get_time(); - int portnum, bitnum; - -profiler_mark(PROFILER_INPUT); - - /* record/playback information about the current frame */ - playback_frame(machine, curtime); - record_frame(machine, curtime); - - /* track the duration of the previous frame */ - last_delta = attotime_to_attoseconds(attotime_sub(curtime, last_update)) / ATTOSECONDS_PER_SECOND_SQRT; - last_update = curtime; - - /* update all analog ports if the UI isn't visible */ - if (!ui_visible) - for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) - update_analog_port(portnum); - - /* update the digital joysticks first */ - update_digital_joysticks(machine); - - /* compute default values for all the ports */ - input_port_update_defaults(); - - /* loop over all input ports */ - for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) - { - input_port_info *portinfo = &port_info[portnum]; - input_bit_info *info; - changed_port_info *changed; - - /* compute the VBLANK mask */ - portinfo->vblank = 0; - for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->portentry; bitnum++, info++) - if (input_port_condition(info->portentry) && info->portentry->type == IPT_VBLANK) - portinfo->vblank ^= info->portentry->mask; +/*------------------------------------------------- + load_game_config - apply configuration + data to the current set of input ports +-------------------------------------------------*/ - /* now loop back and modify based on the inputs */ - portinfo->digital = 0; - for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->portentry; bitnum++, info++) - if (input_port_condition(info->portentry)) - { - input_port_entry *portentry = info->portentry; +static int load_game_config(running_machine *machine, xml_data_node *portnode, int type, int player, const input_seq *newseq) +{ + input_port_value mask, defvalue; + const input_field_config *field; + const input_port_config *port; + const char *tag; - /* handle non-analog types, but only when the UI isn't visible */ - if (portentry->type != IPT_VBLANK && !IS_ANALOG(portentry) && !ui_visible) + /* read the mask, index, and defvalue attributes */ + tag = xml_get_attribute_string(portnode, "port", NULL); + mask = xml_get_attribute_int(portnode, "mask", 0); + defvalue = xml_get_attribute_int(portnode, "defvalue", 0); + + /* find the port we want; if no tag, search them all */ + for (port = machine->portconfig; port != NULL; port = port->next) + if (tag == NULL || (port->tag != NULL && strcmp(port->tag, tag) == 0)) + for (field = port->fieldlist; field != NULL; field = field->next) + + /* find the matching mask and defvalue */ + if (field->type == type && field->player == player && + field->mask == mask && (field->defvalue & mask) == (defvalue & mask)) { - /* if the sequence for this port is currently pressed.... */ - if (input_seq_pressed(input_port_seq(portentry, SEQ_TYPE_STANDARD))) - { -#ifdef MESS - /* (MESS-specific) check for disabled keyboard */ - if (portentry->type == IPT_KEYBOARD && osd_keyboard_disabled()) - continue; -#endif /* MESS */ - /* skip locked-out coin inputs */ - if (portentry->type >= IPT_COIN1 && portentry->type <= IPT_COIN8 && coinlockedout[portentry->type - IPT_COIN1]) - { - ui_popup_time(3, "Coinlock disabled %s.", input_port_name(portentry)); - continue; - } - if (portentry->type >= IPT_SERVICE1 && portentry->type <= IPT_SERVICE4 && servicecoinlockedout[portentry->type - IPT_SERVICE1]) - { - ui_popup_time(3, "Coinlock disabled %s.", input_port_name(portentry)); - continue; - } - /* if this is a downward press and we're an impulse control, reset the count */ - if (portentry->impulse) - { - if (info->last == 0) - info->impulse = portentry->impulse; - } - - /* if this is a downward press and we're a toggle control, toggle the value */ - else if (portentry->toggle) - { - if (info->last == 0) - { - portentry->default_value ^= portentry->mask; - portinfo->digital ^= portentry->mask; - } - } + const char *revstring; + int seqtype; - /* if this is a digital joystick type, apply either standard or 4-way rules */ - else if (IS_DIGITAL_JOYSTICK(portentry)) - { - digital_joystick_info *joyinfo = JOYSTICK_INFO_FOR_PORT(portentry); - UINT8 mask; - switch( portentry->way ) - { - case 4: - mask = joyinfo->current4way; - break; - case 16: - mask = 0xff; - break; - default: - mask = joyinfo->current; - break; - } - if ((mask >> JOYSTICK_DIR_FOR_PORT(portentry)) & 1) - portinfo->digital ^= portentry->mask; - } + /* if a sequence was specified, copy it in */ + for (seqtype = 0; seqtype < ARRAY_LENGTH(field->state->seq); seqtype++) + if (input_seq_get_1(&newseq[seqtype]) != INPUT_CODE_INVALID) + field->state->seq[seqtype] = newseq[seqtype]; - /* otherwise, just set it raw */ - else - portinfo->digital ^= portentry->mask; + /* for non-analog fields, fetch the value */ + if (field->state->analog == NULL) + field->state->value = xml_get_attribute_int(portnode, "value", field->defvalue); - /* track the last value */ - info->last = 1; - } + /* for analog fields, fetch configurable analog attributes */ else - info->last = 0; - - /* handle the impulse countdown */ - if (portentry->impulse && info->impulse > 0) { - info->impulse--; - info->last = 1; - portinfo->digital ^= portentry->mask; + /* get base attributes */ + field->state->analog->delta = xml_get_attribute_int(portnode, "keydelta", field->delta); + field->state->analog->centerdelta = xml_get_attribute_int(portnode, "centerdelta", field->centerdelta); + field->state->analog->sensitivity = xml_get_attribute_int(portnode, "sensitivity", field->sensitivity); + + /* fetch yes/no for reverse setting */ + revstring = xml_get_attribute_string(portnode, "reverse", NULL); + if (revstring != NULL) + field->state->analog->reverse = (strcmp(revstring, "yes") == 0); } + return TRUE; } - /* note that analog ports are handled instantaneously at port read time */ - } - -#ifdef MESS - /* hook for MESS's natural keyboard support */ - mess_input_port_update_hook(machine, portnum, &portinfo->digital); -#endif /* MESS */ + return FALSE; +} - /* call changed handlers */ - for (changed = portinfo->changedinfo; changed; changed = changed->next) - if (input_port_condition(changed->portentry)) - { - input_port_entry *portentry = changed->portentry; - UINT32 new_unmasked_value = input_port_read_indexed(machine, portnum); - UINT32 newval = (new_unmasked_value & portentry->mask) >> changed->shift; - UINT32 oldval = (portentry->changed_last_value & portentry->mask) >> changed->shift; - if (newval != oldval) - (*portentry->changed)(machine, portentry->changed_param, oldval, newval); +/*************************************************************************** + SETTINGS SAVE +***************************************************************************/ - portentry->changed_last_value = new_unmasked_value; - } - } +/*------------------------------------------------- + save_config_callback - config callback for + saving input port configuration +-------------------------------------------------*/ - /* handle playback/record */ - for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) - { - playback_port(machine, &port_info[portnum]); - record_port(machine, &port_info[portnum]); - } +static void save_config_callback(running_machine *machine, int config_type, xml_data_node *parentnode) +{ + /* if no parentnode, ignore */ + if (parentnode == NULL) + return; -profiler_mark(PROFILER_END); + /* default ports save differently */ + if (config_type == CONFIG_TYPE_DEFAULT) + save_default_inputs(machine, parentnode); + else + save_game_inputs(machine, parentnode); } +/*------------------------------------------------- + save_sequence - add a node for an input + sequence +-------------------------------------------------*/ -/************************************* - * - * Digital joystick updating - * - *************************************/ - -static void update_digital_joysticks(running_machine *machine) +static void save_sequence(xml_data_node *parentnode, int type, int porttype, const input_seq *seq) { - int player, joyindex; - - /* loop over all the joysticks */ - for (player = 0; player < MAX_PLAYERS; player++) - for (joyindex = 0; joyindex < DIGITAL_JOYSTICKS_PER_PLAYER; joyindex++) - { - digital_joystick_info *info = &joystick_info[player][joyindex]; - if (info->inuse) - { - info->previous = info->current; - info->current = 0; - - /* read all the associated ports */ - if (info->portentry[JOYDIR_UP] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_UP], SEQ_TYPE_STANDARD))) - info->current |= JOYDIR_UP_BIT; - if (info->portentry[JOYDIR_DOWN] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_DOWN], SEQ_TYPE_STANDARD))) - info->current |= JOYDIR_DOWN_BIT; - if (info->portentry[JOYDIR_LEFT] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_LEFT], SEQ_TYPE_STANDARD))) - info->current |= JOYDIR_LEFT_BIT; - if (info->portentry[JOYDIR_RIGHT] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_RIGHT], SEQ_TYPE_STANDARD))) - info->current |= JOYDIR_RIGHT_BIT; - - /* lock out opposing directions (left + right or up + down) */ - if ((info->current & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) == (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) - info->current &= ~(JOYDIR_UP_BIT | JOYDIR_DOWN_BIT); - if ((info->current & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT)) == (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT)) - info->current &= ~(JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT); - - /* only update 4-way case if joystick has moved */ - if (info->current != info->previous) - { - info->current4way = info->current; - - /* - If joystick is pointing at a diagonal, acknowledge that the player moved - the joystick by favoring a direction change. This minimizes frustration - when using a keyboard for input, and maximizes responsiveness. - - For example, if you are holding "left" then switch to "up" (where both left - and up are briefly pressed at the same time), we'll transition immediately - to "up." - - Zero any switches that didn't change from the previous to current state. - */ - if ((info->current4way & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) && - (info->current4way & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT))) - { - info->current4way ^= info->current4way & info->previous; - } - - /* - If we are still pointing at a diagonal, we are in an indeterminant state. - - This could happen if the player moved the joystick from the idle position directly - to a diagonal, or from one diagonal directly to an extreme diagonal. + astring *seqstring = astring_alloc(); + xml_data_node *seqnode; - The chances of this happening with a keyboard are slim, but we still need to - constrain this case. + /* get the string for the sequence */ + if (input_seq_get_1(seq) == SEQCODE_END) + astring_cpyc(seqstring, "NONE"); + else + input_seq_to_tokens(seqstring, seq); - For now, just resolve randomly. - */ - if ((info->current4way & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) && - (info->current4way & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT))) - { - if (mame_rand(machine) & 1) - info->current4way &= ~(JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT); - else - info->current4way &= ~(JOYDIR_UP_BIT | JOYDIR_DOWN_BIT); - } - } - } - } + /* add the new node */ + seqnode = xml_add_child(parentnode, "newseq", astring_c(seqstring)); + if (seqnode != NULL) + xml_set_attribute(seqnode, "type", seqtypestrings[type]); + astring_free(seqstring); } +/*------------------------------------------------- + save_this_input_field_type - determine if the given + port type is worth saving +-------------------------------------------------*/ -/************************************* - * - * Analog minimum/maximum clamping - * - *************************************/ - -INLINE INT32 apply_analog_min_max(const analog_port_info *info, INT32 value) +static int save_this_input_field_type(int type) { - const input_port_entry *portentry = info->portentry; - INT32 adjmax, adjmin, adj1, adjdif; - - /* take the analog minimum and maximum values and apply the inverse of the */ - /* sensitivity so that we can clamp against them before applying sensitivity */ - adjmin = APPLY_INVERSE_SENSITIVITY(info->minimum, portentry->analog.sensitivity); - adjmax = APPLY_INVERSE_SENSITIVITY(info->maximum, portentry->analog.sensitivity); - adj1 = APPLY_INVERSE_SENSITIVITY(512, portentry->analog.sensitivity); - - /* for absolute devices, clamp to the bounds absolutely */ - if (!info->wraps) - { - if (value > adjmax) - value = adjmax; - else if (value < adjmin) - value = adjmin; - } - - /* for relative devices, wrap around when we go past the edge */ - else + switch (type) { - adjdif = adjmax - adjmin + adj1; - if (portentry->analog.reverse) - { - while (value <= adjmin - adj1) - value += adjdif; - while (value > adjmax) - value -= adjdif; - } - else - { - while (value >= adjmax + adj1) - value -= adjdif; - while (value < adjmin) - value += adjdif; - } + case IPT_UNUSED: + case IPT_END: + case IPT_PORT: + case IPT_VBLANK: + case IPT_UNKNOWN: + return FALSE; } - - return value; + return TRUE; } +/*------------------------------------------------- + save_default_inputs - add nodes for any default + mappings that have changed +-------------------------------------------------*/ -/************************************* - * - * Analog port updating - * - *************************************/ - -static void update_analog_port(int portnum) +static void save_default_inputs(running_machine *machine, xml_data_node *parentnode) { - analog_port_info *info; + input_port_private *portdata = machine->input_port_data; + input_type_state *typestate; - /* loop over all analog ports in this port number */ - for (info = port_info[portnum].analoginfo; info != NULL; info = info->next) + /* iterate over ports */ + for (typestate = portdata->typestatelist; typestate != NULL; typestate = typestate->next) { - input_port_entry *portentry = info->portentry; - INT32 rawvalue; - INT32 delta = 0; - INT64 keyscale; - int keypressed = FALSE; - input_item_class itemclass; - - /* clamp the previous value to the min/max range and remember it */ - info->previous = info->accum = apply_analog_min_max(info, info->accum); - - /* get the new raw analog value and its type */ - rawvalue = input_seq_axis_value(input_port_seq(portentry, SEQ_TYPE_STANDARD), &itemclass); - - /* if we got an absolute input, it overrides everything else */ - if (itemclass == ITEM_CLASS_ABSOLUTE) + /* only save if this port is a type we save */ + if (save_this_input_field_type(typestate->typedesc.type)) { - if (info->previousanalog != rawvalue) - { - /* only update if analog value changed */ - info->previousanalog = rawvalue; + int seqtype; + + /* see if any of the sequences have changed */ + for (seqtype = 0; seqtype < ARRAY_LENGTH(typestate->seq); seqtype++) + if (input_seq_cmp(&typestate->seq[seqtype], &typestate->typedesc.seq[seqtype]) != 0) + break; - /* apply the inverse of the sensitivity to the raw value so that */ - /* it will still cover the full min->max range requested after */ - /* we apply the sensitivity adjustment */ - if (info->absolute || portentry->analog.reset) - { - /* if port is absolute, then just return the absolute data supplied */ - info->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, portentry->analog.sensitivity); - } - else if (info->positionalscale != 0) + /* if so, we need to add a node */ + if (seqtype < ARRAY_LENGTH(typestate->seq)) + { + /* add a new port node */ + xml_data_node *portnode = xml_add_child(parentnode, "port", NULL); + if (portnode != NULL) { - /* if port is positional, we will take the full analog control and divide it */ - /* into positions, that way as the control is moved full scale, */ - /* it moves through all the positions */ - rawvalue = APPLY_SCALE(rawvalue - INPUT_ABSOLUTE_MIN, info->positionalscale) * 512 + info->minimum; - - /* clamp the high value so it does not roll over */ - rawvalue = MIN(rawvalue, info->maximum); - info->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, portentry->analog.sensitivity); - } - else - /* if port is relative, we use the value to simulate the speed of relative movement */ - /* sensitivity adjustment is allowed for this mode */ - info->accum += rawvalue; + /* add the port information and attributes */ + xml_set_attribute(portnode, "type", input_field_type_to_token(machine, typestate->typedesc.type, typestate->typedesc.player)); - info->lastdigital = FALSE; - /* do not bother with other control types if the analog data is changing */ - continue; - } - else - { - /* we still have to update fake relative from joystick control */ - if (!info->absolute && info->positionalscale == 0) - info->accum += rawvalue; + /* add only the sequences that have changed from the defaults */ + for (seqtype = 0; seqtype < ARRAY_LENGTH(typestate->seq); seqtype++) + if (input_seq_cmp(&typestate->seq[seqtype], &typestate->typedesc.seq[seqtype]) != 0) + save_sequence(portnode, seqtype, typestate->typedesc.type, &typestate->seq[seqtype]); + } } } + } +} - /* if we got it from a relative device, use that as the starting delta */ - /* also note that the last input was not a digital one */ - if (itemclass == ITEM_CLASS_RELATIVE && rawvalue != 0) - { - delta = rawvalue; - info->lastdigital = 0; - } - - keyscale = (info->accum >= 0) ? info->keyscalepos : info->keyscaleneg; - /* if the decrement code sequence is pressed, add the key delta to */ - /* the accumulated delta; also note that the last input was a digital one */ - if (input_seq_pressed(input_port_seq(info->portentry, SEQ_TYPE_DECREMENT))) - { - keypressed = TRUE; - if (portentry->analog.delta) - delta -= APPLY_SCALE(portentry->analog.delta, keyscale); - else if (info->lastdigital != 1) - /* decrement only once when first pressed */ - delta -= APPLY_SCALE(1, keyscale); - info->lastdigital = 1; - } - - /* same for the increment code sequence */ - if (input_seq_pressed(input_port_seq(info->portentry, SEQ_TYPE_INCREMENT))) - { - keypressed = TRUE; - if (portentry->analog.delta) - delta += APPLY_SCALE(portentry->analog.delta, keyscale); - else if (info->lastdigital != 2) - /* increment only once when first pressed */ - delta += APPLY_SCALE(1, keyscale); - info->lastdigital = 2; - } - - /* if resetting is requested, clear the accumulated position to 0 before */ - /* applying the deltas so that we only return this frame's delta */ - /* note that centering only works for relative controls */ - /* no need to check if absolute here because it is checked by the validity tests */ - if (portentry->analog.reset) - info->accum = 0; +/*------------------------------------------------- + save_game_inputs - add nodes for any game + mappings that have changed +-------------------------------------------------*/ - /* apply the delta to the accumulated value */ - info->accum += delta; +static void save_game_inputs(running_machine *machine, xml_data_node *parentnode) +{ + const input_field_config *field; + const input_port_config *port; - /* if our last movement was due to a digital input, and if this control */ - /* type autocenters, and if neither the increment nor the decrement seq */ - /* was pressed, apply autocentering */ - if (info->autocenter) - { - INT32 center = APPLY_INVERSE_SENSITIVITY(info->center, portentry->analog.sensitivity); - if (info->lastdigital && !keypressed) + /* iterate over ports */ + for (port = machine->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + if (save_this_input_field_type(field->type)) { - /* autocenter from positive values */ - if (info->accum >= center) + int changed = FALSE; + int seqtype; + + /* determine if we changed */ + for (seqtype = 0; seqtype < ARRAY_LENGTH(field->state->seq); seqtype++) + changed |= (input_seq_cmp(&field->state->seq[seqtype], &field->seq[seqtype]) != 0); + + /* non-analog changes */ + if (field->state->analog == NULL) + changed |= ((field->state->value & field->mask) != (field->defvalue & field->mask)); + + /* analog changes */ + else { - info->accum -= APPLY_SCALE(portentry->analog.centerdelta, info->keyscalepos); - if (info->accum < center) - { - info->accum = center; - info->lastdigital = 0; - } + changed |= (field->state->analog->delta != field->delta); + changed |= (field->state->analog->centerdelta != field->centerdelta); + changed |= (field->state->analog->sensitivity != field->sensitivity); + changed |= (field->state->analog->reverse != ((field->flags & ANALOG_FLAG_REVERSE) != 0)); } - - /* autocenter from negative values */ - else + + /* if we did change, add a new node */ + if (changed) { - info->accum += APPLY_SCALE(portentry->analog.centerdelta, info->keyscaleneg); - if (info->accum > center) + /* add a new port node */ + xml_data_node *portnode = xml_add_child(parentnode, "port", NULL); + if (portnode != NULL) { - info->accum = center; - info->lastdigital = 0; + /* add the identifying information and attributes */ + xml_set_attribute(portnode, "tag", port->tag); + xml_set_attribute(portnode, "type", input_field_type_to_token(machine, field->type, field->player)); + xml_set_attribute_int(portnode, "mask", field->mask); + xml_set_attribute_int(portnode, "defvalue", field->defvalue & field->mask); + + /* add sequences if changed */ + for (seqtype = 0; seqtype < ARRAY_LENGTH(field->state->seq); seqtype++) + if (input_seq_cmp(&field->state->seq[seqtype], &field->seq[seqtype]) != 0) + save_sequence(portnode, seqtype, field->type, &field->state->seq[seqtype]); + + /* write out non-analog changes */ + if (field->state->analog == NULL) + { + if ((field->state->value & field->mask) != (field->defvalue & field->mask)) + xml_set_attribute_int(portnode, "value", field->state->value & field->mask); + } + + /* write out analog changes */ + else + { + if (field->state->analog->delta != field->delta) + xml_set_attribute_int(portnode, "keydelta", field->state->analog->delta); + if (field->state->analog->centerdelta != field->centerdelta) + xml_set_attribute_int(portnode, "centerdelta", field->state->analog->centerdelta); + if (field->state->analog->sensitivity != field->sensitivity) + xml_set_attribute_int(portnode, "sensitivity", field->state->analog->sensitivity); + if (field->state->analog->reverse != ((field->flags & ANALOG_FLAG_REVERSE) != 0)) + xml_set_attribute(portnode, "reverse", field->state->analog->reverse ? "yes" : "no"); + } } } } - } - else if (!keypressed) - info->lastdigital = 0; - } } -/************************************* - * - * Apply analogue port settings - * - *************************************/ - -INT32 apply_analogue_settings(INT32 current, analog_port_info *info) -{ - INT32 value; - input_port_entry *portentry = info->portentry; - - /* apply the min/max and then the sensitivity */ - current = apply_analog_min_max(info, current); - current = APPLY_SENSITIVITY(current, portentry->analog.sensitivity); - - /* apply reversal if needed */ - if (portentry->analog.reverse) - current = info->reverse_val - current; - else if (info->single_scale) - /* it's a pedal or the default value is equal to min/max */ - /* so we need to adjust the center to the minimum */ - current -= INPUT_ABSOLUTE_MIN; - - /* map differently for positive and negative values */ - if (current >= 0) - value = APPLY_SCALE(current, info->scalepos); - else - value = APPLY_SCALE(current, info->scaleneg); - value += portentry->default_value; - - return value; -} - - +/*************************************************************************** + INPUT PLAYBACK +***************************************************************************/ -/************************************* - * - * Analog port interpolation - * - *************************************/ +/*------------------------------------------------- + playback_read_uint8 - read an 8-bit value + from the playback file +-------------------------------------------------*/ -static UINT32 merge_interpolated_analog_data(int portnum, UINT32 digital) +static UINT8 playback_read_uint8(running_machine *machine) { - analog_port_info *info; - UINT32 result = digital; + input_port_private *portdata = machine->input_port_data; + UINT8 result; -profiler_mark(PROFILER_INPUT); + /* protect against NULL handles if previous reads fail */ + if (portdata->playback_file == NULL) + return 0; - /* loop over all analog ports in this port number */ - for (info = port_info[portnum].analoginfo; info != NULL; info = info->next) + /* read the value; if we fail, end playback */ + if (mame_fread(portdata->playback_file, &result, sizeof(result)) != sizeof(result)) { - input_port_entry *portentry = info->portentry; - - if (input_port_condition(portentry)) - { - INT32 current; - INT32 value; - - /* interpolate or not */ - if (info->interpolate && !portentry->analog.reset && last_delta != 0) - { - attoseconds_t time_since_last = attotime_to_attoseconds(attotime_sub(timer_get_time(), last_update)) / ATTOSECONDS_PER_SECOND_SQRT; - current = info->previous + ((INT64)(info->accum - info->previous) * time_since_last / last_delta); - } - else - current = info->accum; - - value = apply_analogue_settings(current, info); - - /* remap the value if needed */ - if (portentry->analog.remap_table) - value = info->portentry->analog.remap_table[value]; - - /* invert bits if needed */ - if (portentry->analog.invert) - value = ~value; - - /* insert into the port */ - result = (result & ~portentry->mask) | ((value << info->shift) & portentry->mask); - } + playback_end(machine, "End of file"); + return 0; } -profiler_mark(PROFILER_END); + /* return the appropriate value */ return result; } +/*------------------------------------------------- + playback_read_uint32 - read a 32-bit value + from the playback file +-------------------------------------------------*/ -/************************************* - * - * Input port reading - * - *************************************/ - -UINT32 input_port_read_indexed(running_machine *machine, int portnum) +static UINT32 playback_read_uint32(running_machine *machine) { - input_port_info *portinfo = &port_info[portnum]; - custom_port_info *custom; + input_port_private *portdata = machine->input_port_data; UINT32 result; - /* start with the digital */ - result = portinfo->defvalue ^ portinfo->digital; - - /* merge in analog portions */ - result = merge_interpolated_analog_data(portnum, result); - - /* update custom values */ - for (custom = portinfo->custominfo; custom; custom = custom->next) - if (input_port_condition(custom->portentry)) - { - /* replace the bits with bits from the custom routine */ - input_port_entry *portentry = custom->portentry; - result &= ~portentry->mask; - result |= ((*portentry->custom)(machine, portentry->custom_param) << custom->shift) & portentry->mask; - } + /* protect against NULL handles if previous reads fail */ + if (portdata->playback_file == NULL) + return 0; - /* handle VBLANK bits */ - if (portinfo->vblank) + /* read the value; if we fail, end playback */ + if (mame_fread(portdata->playback_file, &result, sizeof(result)) != sizeof(result)) { - /* reset the VBLANK bits to their default value, regardless of inputs */ - result = (result & ~portinfo->vblank) | (portinfo->defvalue & portinfo->vblank); - - /* toggle VBLANK if we're in a VBLANK state */ - if (video_screen_get_vblank(machine->primary_screen)) - result ^= portinfo->vblank; + playback_end(machine, "End of file"); + return 0; } - return result; -} - -UINT32 input_port_read(running_machine *machine, const char *tag) -{ - int portnum = port_tag_to_index(tag); - if (portnum != -1) - return input_port_read_indexed(machine, portnum); - - /* otherwise fail horribly */ - fatalerror("Unable to locate input port '%s'", tag); - return -1; -} - - -UINT32 input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue) -{ - int portnum = port_tag_to_index(tag); - if (portnum != -1) - return input_port_read_indexed(machine, portnum); - return defvalue; + /* return the appropriate value */ + return LITTLE_ENDIANIZE_INT32(result); } +/*------------------------------------------------- + playback_read_uint64 - read a 64-bit value + from the playback file +-------------------------------------------------*/ -/************************************* - * - * Return position of crosshair axis - * - *************************************/ - -UINT32 get_crosshair_pos(int port_num, UINT8 player, UINT8 axis) +static UINT64 playback_read_uint64(running_machine *machine) { - input_port_info *portinfo = &port_info[port_num]; - analog_port_info *info; - input_port_entry *portentry; - UINT32 result = 0; + input_port_private *portdata = machine->input_port_data; + UINT64 result; - for (info = portinfo->analoginfo; info; info = info->next) + /* protect against NULL handles if previous reads fail */ + if (portdata->playback_file == NULL) + return 0; + + /* read the value; if we fail, end playback */ + if (mame_fread(portdata->playback_file, &result, sizeof(result)) != sizeof(result)) { - portentry = info->portentry; - if (portentry->player == player && portentry->analog.crossaxis == axis && input_port_condition(portentry)) - { - result = apply_analogue_settings(info->accum, info) & (portentry->mask >> info->shift); - break; - } + playback_end(machine, "End of file"); + return 0; } - return result; + /* return the appropriate value */ + return LITTLE_ENDIANIZE_INT64(result); } /*------------------------------------------------- - autoselect_device - autoselect a single - device based on the input port list passed - in and the corresponding option + playback_init - initialize INP playback -------------------------------------------------*/ -static void autoselect_device(const input_port_entry *ipt, int type1, int type2, int type3, const char *option, const char *ananame) +static time_t playback_init(running_machine *machine) { - const char *stemp = options_get_string(mame_options(), option); - input_device_class autoenable = DEVICE_CLASS_KEYBOARD; - const char *autostring = "keyboard"; + const char *filename = options_get_string(mame_options(), OPTION_PLAYBACK); + input_port_private *portdata = machine->input_port_data; + UINT8 header[INP_HEADER_SIZE]; + file_error filerr; + time_t basetime; - /* if nothing specified, ignore the option */ - if (stemp[0] == 0) - return; + /* if no file, nothing to do */ + if (filename[0] == 0) + return 0; - /* extract valid strings */ - if (strcmp(stemp, "mouse") == 0) - { - autoenable = DEVICE_CLASS_MOUSE; - autostring = "mouse"; - } - else if (strcmp(stemp, "joystick") == 0) - { - autoenable = DEVICE_CLASS_JOYSTICK; - autostring = "joystick"; - } - else if (strcmp(stemp, "lightgun") == 0) - { - autoenable = DEVICE_CLASS_LIGHTGUN; - autostring = "lightgun"; - } - else if (strcmp(stemp, "none") == 0) - { - /* nothing specified */ - return; - } - else if (strcmp(stemp, "keyboard") != 0) - mame_printf_error("Invalid %s value %s; reverting to keyboard\n", option, stemp); + /* open the playback file */ + filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_READ, &portdata->playback_file); + assert_always(filerr == FILERR_NONE, "Failed to open file for playback"); - /* only scan the list if we haven't already enabled this class of control */ - if (!input_device_class_enabled(autoenable)) - for ( ; ipt->type != IPT_END; ipt++) + /* read the header and verify that it is a modern version; if not, print an error */ + if (mame_fread(portdata->playback_file, header, sizeof(header)) != sizeof(header)) + fatalerror("Input file is corrupt or invalid (missing header)"); + if (memcmp(header, "MAMEINP\0", 8) != 0) + fatalerror("Input file invalid or in an older, unsupported format"); + if (header[0x10] != INP_HEADER_MAJVERSION) + fatalerror("Input file format version mismatch"); - /* if this port type is in use, apply the autoselect criteria */ - if ((type1 != 0 && ipt->type == type1) || - (type2 != 0 && ipt->type == type2) || - (type3 != 0 && ipt->type == type3)) - { - mame_printf_verbose("Input: Autoenabling %s due to presence of a %s\n", autostring, ananame); - input_device_class_enable(autoenable, TRUE); - break; - } -} + /* output info to console */ + mame_printf_info("Input file: %s\n", filename); + mame_printf_info("INP version %d.%d\n", header[0x10], header[0x11]); + basetime = header[0x08] | (header[0x09] << 8) | (header[0x0a] << 16) | (header[0x0b] << 24) | + ((UINT64)header[0x0c] << 32) | ((UINT64)header[0x0d] << 40) | ((UINT64)header[0x0e] << 48) | ((UINT64)header[0x0f] << 56); + mame_printf_info("Created %s", ctime(&basetime)); + mame_printf_info("Recorded using %s\n", header + 0x20); + /* verify the header against the current game */ + if (memcmp(machine->gamedrv->name, header + 0x14, strlen(machine->gamedrv->name) + 1) != 0) + fatalerror("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", header + 0x14, machine->gamedrv->name); + return basetime; +} -/*************************************************************************** - PLAYBACK AND RECORD -***************************************************************************/ /*------------------------------------------------- - playback_read_uint8 - read an 8-bit value - from the playback file + playback_end - end INP playback -------------------------------------------------*/ -static UINT8 playback_read_uint8(running_machine *machine) +static void playback_end(running_machine *machine, const char *message) { - UINT8 result; - - /* protect against NULL handles if previous reads fail */ - if (machine->playback_file == NULL) - return 0; + input_port_private *portdata = machine->input_port_data; - /* read the value; if we fail, end playback */ - if (mame_fread(machine->playback_file, &result, sizeof(result)) != sizeof(result)) + /* only applies if we have a live file */ + if (portdata->playback_file != NULL) { - playback_end(machine, "End of file"); - return 0; - } + /* close the file */ + mame_fclose(portdata->playback_file); + portdata->playback_file = NULL; - /* return the appropriate value */ - return result; + /* pop a message */ + if (message != NULL) + popmessage("Playback Ended\nReason: %s", message); + + /* display speed stats */ + portdata->playback_accumulated_speed /= portdata->playback_accumulated_frames; + mame_printf_info("Total playback frames: %d\n", (UINT32)portdata->playback_accumulated_frames); + mame_printf_info("Average recorded speed: %d%%\n", (UINT32)((portdata->playback_accumulated_speed * 200 + 1) >> 21)); + } } /*------------------------------------------------- - record_write_uint8 - write an 8-bit value - to the record file + playback_frame - start of frame callback for + playback -------------------------------------------------*/ -static void record_write_uint8(running_machine *machine, UINT8 data) +static void playback_frame(running_machine *machine, attotime curtime) { - UINT8 result = data; + input_port_private *portdata = machine->input_port_data; - /* protect against NULL handles if previous reads fail */ - if (machine->record_file == NULL) - return; + /* if playing back, fetch the information and verify */ + if (portdata->playback_file != NULL) + { + attotime readtime; - /* read the value; if we fail, end playback */ - if (mame_fwrite(machine->record_file, &result, sizeof(result)) != sizeof(result)) - record_end(machine, "Out of space"); + /* first the absolute time */ + readtime.seconds = playback_read_uint32(machine); + readtime.attoseconds = playback_read_uint64(machine); + if (attotime_compare(readtime, curtime) != 0) + playback_end(machine, "Out of sync"); + + /* then the speed */ + portdata->playback_accumulated_speed += playback_read_uint32(machine); + portdata->playback_accumulated_frames++; + } } /*------------------------------------------------- - playback_read_uint32 - read a 32-bit value - from the playback file + playback_port - per-port callback for playback -------------------------------------------------*/ -static UINT32 playback_read_uint32(running_machine *machine) +static void playback_port(const input_port_config *port) { - UINT32 result; - - /* protect against NULL handles if previous reads fail */ - if (machine->playback_file == NULL) - return 0; + input_port_private *portdata = port->machine->input_port_data; - /* read the value; if we fail, end playback */ - if (mame_fread(machine->playback_file, &result, sizeof(result)) != sizeof(result)) + /* if playing back, fetch information about this port */ + if (portdata->playback_file != NULL) { - playback_end(machine, "End of file"); - return 0; - } + analog_field_state *analog; - /* return the appropriate value */ - return LITTLE_ENDIANIZE_INT32(result); + /* read the digital value */ + port->state->digital = playback_read_uint32(port->machine); + + /* loop over analog ports and save their data */ + for (analog = port->state->analoglist; analog != NULL; analog = analog->next) + { + /* read current and previous values */ + analog->accum = playback_read_uint32(port->machine); + analog->previous = playback_read_uint32(port->machine); + + /* read configuration information */ + analog->sensitivity = playback_read_uint32(port->machine); + analog->reverse = playback_read_uint8(port->machine); + } + } } + +/*************************************************************************** + INPUT RECORDING +***************************************************************************/ + /*------------------------------------------------- - record_write_uint32 - write a 32-bit value + record_write_uint8 - write an 8-bit value to the record file -------------------------------------------------*/ -static void record_write_uint32(running_machine *machine, UINT32 data) +static void record_write_uint8(running_machine *machine, UINT8 data) { - UINT32 result = LITTLE_ENDIANIZE_INT32(data); + input_port_private *portdata = machine->input_port_data; + UINT8 result = data; /* protect against NULL handles if previous reads fail */ - if (machine->record_file == NULL) + if (portdata->record_file == NULL) return; /* read the value; if we fail, end playback */ - if (mame_fwrite(machine->record_file, &result, sizeof(result)) != sizeof(result)) + if (mame_fwrite(portdata->record_file, &result, sizeof(result)) != sizeof(result)) record_end(machine, "Out of space"); } /*------------------------------------------------- - playback_read_uint64 - read a 64-bit value - from the playback file + record_write_uint32 - write a 32-bit value + to the record file -------------------------------------------------*/ -static UINT64 playback_read_uint64(running_machine *machine) +static void record_write_uint32(running_machine *machine, UINT32 data) { - UINT64 result; + input_port_private *portdata = machine->input_port_data; + UINT32 result = LITTLE_ENDIANIZE_INT32(data); /* protect against NULL handles if previous reads fail */ - if (machine->playback_file == NULL) - return 0; + if (portdata->record_file == NULL) + return; /* read the value; if we fail, end playback */ - if (mame_fread(machine->playback_file, &result, sizeof(result)) != sizeof(result)) - { - playback_end(machine, "End of file"); - return 0; - } - - /* return the appropriate value */ - return LITTLE_ENDIANIZE_INT64(result); + if (mame_fwrite(portdata->record_file, &result, sizeof(result)) != sizeof(result)) + record_end(machine, "Out of space"); } @@ -3568,68 +3704,27 @@ static UINT64 playback_read_uint64(running_machine *machine) static void record_write_uint64(running_machine *machine, UINT64 data) { + input_port_private *portdata = machine->input_port_data; UINT64 result = LITTLE_ENDIANIZE_INT64(data); /* protect against NULL handles if previous reads fail */ - if (machine->record_file == NULL) + if (portdata->record_file == NULL) return; /* read the value; if we fail, end playback */ - if (mame_fwrite(machine->record_file, &result, sizeof(result)) != sizeof(result)) + if (mame_fwrite(portdata->record_file, &result, sizeof(result)) != sizeof(result)) record_end(machine, "Out of space"); } /*------------------------------------------------- - playback_init - initialize INP playback --------------------------------------------------*/ - -static time_t playback_init(running_machine *machine) -{ - const char *filename = options_get_string(mame_options(), OPTION_PLAYBACK); - UINT8 header[INP_HEADER_SIZE]; - file_error filerr; - time_t basetime; - - /* if no file, nothing to do */ - if (filename[0] == 0) - return 0; - - /* open the playback file */ - filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_READ, &machine->playback_file); - assert_always(filerr == FILERR_NONE, "Failed to open file for playback"); - - /* read the header and verify that it is a modern version; if not, print an error */ - if (mame_fread(machine->playback_file, header, sizeof(header)) != sizeof(header)) - fatalerror("Input file is corrupt or invalid (missing header)"); - if (memcmp(header, "MAMEINP\0", 8) != 0) - fatalerror("Input file invalid or in an older, unsupported format"); - if (header[0x10] != INP_HEADER_MAJVERSION) - fatalerror("Input file format version mismatch"); - - /* output info to console */ - mame_printf_info("Input file: %s\n", filename); - mame_printf_info("INP version %d.%d\n", header[0x10], header[0x11]); - basetime = header[0x08] | (header[0x09] << 8) | (header[0x0a] << 16) | (header[0x0b] << 24) | - ((UINT64)header[0x0c] << 32) | ((UINT64)header[0x0d] << 40) | ((UINT64)header[0x0e] << 48) | ((UINT64)header[0x0f] << 56); - mame_printf_info("Created %s", ctime(&basetime)); - mame_printf_info("Recorded using %s\n", header + 0x20); - - /* verify the header against the current game */ - if (memcmp(machine->gamedrv->name, header + 0x14, strlen(machine->gamedrv->name) + 1) != 0) - fatalerror("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", header + 0x14, machine->gamedrv->name); - - return basetime; -} - - -/*------------------------------------------------- record_init - initialize INP recording -------------------------------------------------*/ static void record_init(running_machine *machine) { const char *filename = options_get_string(mame_options(), OPTION_RECORD); + input_port_private *portdata = machine->input_port_data; UINT8 header[INP_HEADER_SIZE]; mame_system_time systime; file_error filerr; @@ -3639,7 +3734,7 @@ static void record_init(running_machine *machine) return; /* open the record file */ - filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &machine->record_file); + filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &portdata->record_file); assert_always(filerr == FILERR_NONE, "Failed to open file for recording"); /* get the base time */ @@ -3662,32 +3757,7 @@ static void record_init(running_machine *machine) sprintf((char *)header + 0x20, APPNAME " %s", build_version); /* write it */ - mame_fwrite(machine->record_file, header, sizeof(header)); -} - - -/*------------------------------------------------- - playback_end - end INP playback --------------------------------------------------*/ - -static void playback_end(running_machine *machine, const char *message) -{ - /* only applies if we have a live file */ - if (machine->playback_file != NULL) - { - /* close the file */ - mame_fclose(machine->playback_file); - machine->playback_file = NULL; - - /* pop a message */ - if (message != NULL) - popmessage("Playback Ended\nReason: %s", message); - - /* display speed stats */ - playback_accumulated_speed /= playback_accumulated_frames; - mame_printf_info("Total playback frames: %d\n", (UINT32)playback_accumulated_frames); - mame_printf_info("Average recorded speed: %d%%\n", (UINT32)((playback_accumulated_speed * 200 + 1) >> 21)); - } + mame_fwrite(portdata->record_file, header, sizeof(header)); } @@ -3697,12 +3767,14 @@ static void playback_end(running_machine *machine, const char *message) static void record_end(running_machine *machine, const char *message) { + input_port_private *portdata = machine->input_port_data; + /* only applies if we have a live file */ - if (machine->record_file != NULL) + if (portdata->record_file != NULL) { /* close the file */ - mame_fclose(machine->record_file); - machine->record_file = NULL; + mame_fclose(portdata->record_file); + portdata->record_file = NULL; /* pop a message */ if (message != NULL) @@ -3712,39 +3784,16 @@ static void record_end(running_machine *machine, const char *message) /*------------------------------------------------- - playback_frame - start of frame callback for - playback --------------------------------------------------*/ - -static void playback_frame(running_machine *machine, attotime curtime) -{ - /* if playing back, fetch the information and verify */ - if (machine->playback_file != NULL) - { - attotime readtime; - - /* first the absolute time */ - readtime.seconds = playback_read_uint32(machine); - readtime.attoseconds = playback_read_uint64(machine); - if (attotime_compare(readtime, curtime) != 0) - playback_end(machine, "Out of sync"); - - /* then the speed */ - playback_accumulated_speed += playback_read_uint32(machine); - playback_accumulated_frames++; - } -} - - -/*------------------------------------------------- record_frame - start of frame callback for recording -------------------------------------------------*/ static void record_frame(running_machine *machine, attotime curtime) { + input_port_private *portdata = machine->input_port_data; + /* if recording, record information about the current frame */ - if (machine->record_file != NULL) + if (portdata->record_file != NULL) { /* first the absolute time */ record_write_uint32(machine, curtime.seconds); @@ -3757,58 +3806,31 @@ static void record_frame(running_machine *machine, attotime curtime) /*------------------------------------------------- - playback_port - per-port callback for playback --------------------------------------------------*/ - -static void playback_port(running_machine *machine, input_port_info *portinfo) -{ - /* if playing back, fetch information about this port */ - if (machine->playback_file != NULL) - { - analog_port_info *analog; - - /* read the digital value */ - portinfo->digital = playback_read_uint32(machine); - - /* loop over analog ports and save their data */ - for (analog = portinfo->analoginfo; analog != NULL; analog = analog->next) - { - /* read current and previous values */ - analog->accum = playback_read_uint32(machine); - analog->previous = playback_read_uint32(machine); - - /* read configuration information */ - analog->portentry->analog.sensitivity = playback_read_uint32(machine); - analog->portentry->analog.reverse = playback_read_uint8(machine); - } - } -} - - -/*------------------------------------------------- record_port - per-port callback for record -------------------------------------------------*/ -static void record_port(running_machine *machine, input_port_info *portinfo) +static void record_port(const input_port_config *port) { + input_port_private *portdata = port->machine->input_port_data; + /* if recording, store information about this port */ - if (machine->record_file != NULL) + if (portdata->record_file != NULL) { - analog_port_info *analog; + analog_field_state *analog; /* store the digital value */ - record_write_uint32(machine, portinfo->digital); + record_write_uint32(port->machine, port->state->digital); /* loop over analog ports and save their data */ - for (analog = portinfo->analoginfo; analog != NULL; analog = analog->next) + for (analog = port->state->analoglist; analog != NULL; analog = analog->next) { /* store current and previous values */ - record_write_uint32(machine, analog->accum); - record_write_uint32(machine, analog->previous); + record_write_uint32(port->machine, analog->accum); + record_write_uint32(port->machine, analog->previous); /* store configuration information */ - record_write_uint32(machine, analog->portentry->analog.sensitivity); - record_write_uint8(machine, analog->portentry->analog.reverse); + record_write_uint32(port->machine, analog->sensitivity); + record_write_uint8(port->machine, analog->reverse); } } } diff --git a/src/emu/inptport.h b/src/emu/inptport.h index 1c870614213..9821adadb5a 100644 --- a/src/emu/inptport.h +++ b/src/emu/inptport.h @@ -19,10 +19,7 @@ #include "memory.h" #include "inputseq.h" #include "tokenize.h" - -#ifdef MESS #include "unicode.h" -#endif @@ -30,35 +27,36 @@ CONSTANTS ***************************************************************************/ -#define MAX_INPUT_PORTS 32 #define MAX_PLAYERS 8 -#define MAX_BITS_PER_PORT 32 #define IP_ACTIVE_HIGH 0x00000000 #define IP_ACTIVE_LOW 0xffffffff -#define INPUT_PORT_PAIR_ENTRIES (sizeof(FPTR) / sizeof(UINT32)) -#define INPUT_PORT_PAIR_TOKENS (2 * sizeof(UINT32) / sizeof(FPTR)) + +/* flags for input_field_configs */ +#define FIELD_FLAG_UNUSED 0x01 /* set if this field is unused but relevant to other games on the same hw */ +#define FIELD_FLAG_COCKTAIL 0x02 /* set if this field is relevant only for cocktail cabinets */ +#define FIELD_FLAG_TOGGLE 0x04 /* set if this field should behave as a toggle */ +#define FIELD_FLAG_ROTATED 0x08 /* set if this field represents a rotated control */ +#define ANALOG_FLAG_REVERSE 0x10 /* analog only: reverse the sense of the axis */ +#define ANALOG_FLAG_RESET 0x20 /* analog only: always preload in->default for relative axes, returning only deltas */ +#define ANALOG_FLAG_WRAPS 0x40 /* analog only: positional count wraps around */ +#define ANALOG_FLAG_INVERT 0x80 /* analog only: bitwise invert bits */ +/* INP file information */ #define INP_HEADER_SIZE 64 #define INP_HEADER_MAJVERSION 2 #define INP_HEADER_MINVERSION 0 -/* macro for a custom callback functions (PORT_CUSTOM) */ -#define CUSTOM_INPUT(name) UINT32 name(running_machine *machine, void *param) - -/* macro for port changed callback functions (PORT_CHANGED) */ -#define INPUT_CHANGED(name) void name(running_machine *machine, void *param, UINT32 oldval, UINT32 newval) - - /* sequence types for input_port_seq() call */ enum _input_seq_type { SEQ_TYPE_STANDARD = 0, - SEQ_TYPE_INCREMENT = 1, - SEQ_TYPE_DECREMENT = 2 + SEQ_TYPE_INCREMENT, + SEQ_TYPE_DECREMENT, + SEQ_TYPE_TOTAL }; typedef enum _input_seq_type input_seq_type; @@ -108,13 +106,10 @@ enum IPT_END, IPT_UNKNOWN, IPT_PORT, - IPT_DIPSWITCH_NAME, - IPT_DIPSWITCH_SETTING, + IPT_DIPSWITCH, IPT_VBLANK, - IPT_CONFIG_NAME, /* MESS only */ - IPT_CONFIG_SETTING, /* MESS only */ - IPT_CATEGORY_NAME, /* MESS only */ - IPT_CATEGORY_SETTING, /* MESS only */ + IPT_CONFIG, + IPT_CATEGORY, /* MESS only */ /* start buttons */ IPT_START1, @@ -249,6 +244,7 @@ enum IPT_ADJUSTER, /* the following are special codes for user interface handling - not to be used by drivers! */ +#define __ipt_ui_start IPT_UI_CONFIGURE IPT_UI_CONFIGURE, IPT_UI_ON_SCREEN_DISPLAY, IPT_UI_DEBUG_BREAK, @@ -311,6 +307,7 @@ enum IPT_OSD_14, IPT_OSD_15, IPT_OSD_16, +#define __ipt_ui_end IPT_OSD_16 /* other meaning not mapped to standard defaults */ IPT_OTHER, @@ -331,7 +328,7 @@ enum INPUT_TOKEN_START, INPUT_TOKEN_START_TAG, INPUT_TOKEN_MODIFY, - INPUT_TOKEN_BIT, + INPUT_TOKEN_FIELD, INPUT_TOKEN_SPECIAL_ONOFF, INPUT_TOKEN_CODE, INPUT_TOKEN_CODE_DEC, @@ -375,12 +372,10 @@ enum INPUT_TOKEN_ADJUSTER, INPUT_TOKEN_CONFNAME, INPUT_TOKEN_CONFSETTING, -#ifdef MESS INPUT_TOKEN_CHAR, INPUT_TOKEN_CATEGORY, INPUT_TOKEN_CATEGORY_NAME, - INPUT_TOKEN_CATEGORY_SETTING, -#endif /* MESS */ + INPUT_TOKEN_CATEGORY_SETTING }; @@ -505,13 +500,25 @@ enum TYPE DEFINITIONS ***************************************************************************/ -/* this is an opaque type */ -typedef struct _input_port_init_params input_port_init_params; +/* input ports support up to 32 bits each */ +typedef UINT32 input_port_value; + + +/* opaque types pointing to live state */ +typedef struct _input_port_state input_port_state; +typedef struct _input_field_state input_field_state; + + +/* forward declarations */ +typedef struct _input_port_config input_port_config; +typedef struct _input_field_config input_field_config; + +/* custom input port callback function */ +typedef UINT32 (*input_field_custom_func)(const input_field_config *field, void *param); -/* a custom input port callback function */ -typedef UINT32 (*input_port_custom_func)(running_machine *machine, void *param); -typedef void (*input_port_changed_func)(running_machine *machine, void *param, UINT32 oldval, UINT32 newval); +/* input port changed callback function */ +typedef void (*input_field_changed_func)(const input_field_config *field, void *param, UINT32 oldval, UINT32 newval); /* this type is used to encode input port definitions */ @@ -519,141 +526,164 @@ typedef union _input_port_token input_port_token; union _input_port_token { TOKEN_COMMON_FIELDS - const input_port_token *tokenptr; - input_port_custom_func customptr; - input_port_changed_func changedptr; + const input_port_token * tokenptr; + input_field_custom_func customptr; + input_field_changed_func changedptr; +}; + + +/* encapsulates a condition on a port field or setting */ +typedef struct _input_condition input_condition; +struct _input_condition +{ + const char * tag; /* tag of port whose condition is to be tested */ + input_port_value mask; /* mask to apply to the port */ + input_port_value value; /* value to compare against */ + UINT8 condition; /* condition to use */ +}; + + +/* a single setting for a configuration or DIP switch */ +typedef struct _input_setting_config input_setting_config; +struct _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 */ + 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 */ +}; + + +/* a mapping from a bit to a physical DIP switch description */ +typedef struct _input_field_diplocation input_field_diplocation; +struct _input_field_diplocation +{ + input_field_diplocation * next; /* pointer to the next bit */ + const char * swname; /* name of the physical DIP switch */ + UINT8 swnum; /* physical switch number */ + UINT8 invert; /* is this an active-high DIP? */ }; -/* In mamecore.h: typedef struct _input_port_default_entry input_port_default_entry; */ -struct _input_port_default_entry +/* a single bitfield within an input port */ +struct _input_field_config { - UINT32 type; /* type of port; see enum above */ - UINT8 group; /* which group the port belongs to */ - UINT8 player; /* player number (0 is player 1) */ - const char *token; /* token used to store settings */ - const char *name; /* user-friendly name */ - input_seq defaultseq; /* default input sequence */ - input_seq defaultincseq; /* default input sequence to increment (analog ports only) */ - input_seq defaultdecseq; /* default input sequence to decrement (analog ports only) */ + /* 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 */ + UINT32 type; /* IPT_* type for this port */ + UINT8 player; /* player number (0-based) */ + UINT16 category; /* (MESS-specific) category */ + UINT32 flags; /* combination of FIELD_FLAG_* and ANALOG_FLAG_* above */ + 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 */ + 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 */ + + /* data relevant to analog control types */ + INT32 min; /* minimum value for absolute axes */ + INT32 max; /* maximum value for absolute axes */ + INT32 sensitivity; /* sensitivity (100=normal) */ + INT32 delta; /* delta to apply each frame a digital inc/dec key is pressed */ + INT32 centerdelta; /* delta to apply each frame no digital inputs are pressed */ + UINT8 crossaxis; /* crosshair axis */ + float crossscale; /* crosshair scale */ + float crossoffset; /* crosshair offset */ + float crossaltaxis; /* crosshair alternate axis value */ + UINT16 full_turn_count;/* number of optical counts for 1 full turn of the original control */ + 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) */ }; -/* In mamecore.h: typedef struct _input_port_entry input_port_entry; */ -struct _input_port_entry +/* user-controllable settings for a field */ +typedef struct _input_field_user_settings input_field_user_settings; +struct _input_field_user_settings { - UINT32 mask; /* bits affected */ - UINT32 default_value; /* default value for the bits affected */ - /* you can also use one of the IP_ACTIVE defines above */ - UINT32 type; /* see enum above */ - UINT8 unused; /* The bit is not used by this game, but is used */ - /* by other games running on the same hardware. */ - /* This is different from IPT_UNUSED, which marks */ - /* bits not connected to anything. */ - UINT8 cocktail; /* the bit is used in cocktail mode only */ - UINT8 player; /* the player associated with this port; note that */ - /* player 1 is '0' */ - UINT8 toggle; /* When this is set, the key acts as a toggle - press */ - /* it once and it goes on, press it again and it goes off. */ - /* useful e.g. for some Test Mode dip switches. */ - UINT8 impulse; /* When this is set, when the key corresponding to */ - /* the input bit is pressed it will be reported as */ - /* pressed for a certain number of video frames and */ - /* then released, regardless of the real status of */ - /* the key. This is useful e.g. for some coin inputs. */ - /* The number of frames the signal should stay active */ - /* is specified in the "arg" field. */ - UINT8 way; /* Joystick modes of operation. 8WAY is the default, */ - /* it prevents left/right or up/down to be pressed at */ - /* the same time. 4WAY prevents diagonal directions. */ - /* 2WAY should be used for joysticks wich move only */ - /* on one axis (e.g. Battle Zone) */ - UINT8 rotated; /* Indicates the control is rotated 45 degrees. This */ - /* is used as a hint for joystick mapping. */ - UINT16 category; /* (MESS-specific) category */ - const char *name; /* user-friendly name to display */ - input_seq seq; /* input sequence affecting the input bits */ - input_port_custom_func custom;/* custom callback routine */ - void * custom_param; /* parameter for custom callback routine */ - input_port_changed_func changed;/* changed callback routine */ - void * changed_param; /* parameter for changed callback routine */ - UINT32 changed_last_value; /* the last value for changed detection purposes */ - - /* valid if type is between __ipt_analog_start and __ipt_analog_end */ - struct - { - INT32 min; /* minimum value for absolute axes */ - INT32 max; /* maximum value for absolute axes */ - INT32 sensitivity; /* sensitivity (100=normal) */ - INT32 delta; /* delta to apply each frame a digital inc/dec key is pressed */ - INT32 centerdelta; /* delta to apply each frame no digital inputs are pressed */ - UINT8 reverse; /* reverse the sense of the analog axis */ - UINT8 reset; /* always preload in->default for relative axes, returning only deltas */ - UINT8 crossaxis; /* crosshair axis */ - float crossscale; /* crosshair scale */ - float crossoffset; /* crosshair offset */ - float crossaltaxis; /* crosshair alternate axis value */ - input_seq incseq; /* increment sequence */ - input_seq decseq; /* decrement sequence */ - UINT8 wraps; /* positional count wraps around */ - UINT8 invert; /* bitwise invert bits */ - UINT16 full_turn_count; /* number of optical counts for 1 full turn of the original control */ - const UINT32 *remap_table; /* pointer to an array that remaps the port value */ - } analog; - - /* valid if type is IPT_PORT */ - struct - { - const char *tag; /* used to tag PORT_START declarations */ - } start; - - /* valid for most types */ - struct - { - const char *tag; /* port tag to use for condition */ - UINT8 portnum; /* port number for condition */ - UINT8 condition; /* condition to use */ - UINT32 mask; /* mask to apply to the port */ - UINT32 value; /* value to compare against */ - } condition; - - /* valid for IPT_DIPNAME */ - struct - { - const char *swname; /* name of the physical DIP switch */ - UINT8 swnum; /* physical switch number */ - UINT8 invert; /* is this an active-high DIP? */ - } diploc[8]; - - /* valid if type is IPT_KEYBOARD */ -#ifdef MESS - struct - { - unicode_char chars[3]; /* (MESS-specific) unicode key data */ - } keyboard; -#endif /* MESS */ + input_port_value value; /* for DIP switches */ + input_seq seq[SEQ_TYPE_TOTAL];/* sequences of all types */ + INT32 sensitivity; /* for analog controls */ + INT32 delta; /* for analog controls */ + INT32 centerdelta; /* for analog controls */ + UINT8 reverse; /* for analog controls */ }; +/* a single input port configuration */ +struct _input_port_config +{ + const input_port_config * next; /* pointer to next port */ + const char * tag; /* pointer to this port's tag */ + const input_field_config * fieldlist; /* list of input_field_configs */ + + /* these two fields are only valid if the port is live */ + input_port_state * state; /* live state of port (NULL if not live) */ + running_machine * machine; /* machine if port is live */ +}; + + +/* describes a fundamental input type, including default input sequences */ +typedef struct _input_type_desc input_type_desc; +struct _input_type_desc +{ + input_type_desc * next; /* next description in the list */ + UINT32 type; /* IPT_* for this entry */ + UINT8 group; /* which group the port belongs to */ + UINT8 player; /* player number (0 is player 1) */ + const char * token; /* token used to store settings */ + const char * name; /* user-friendly name */ + input_seq seq[SEQ_TYPE_TOTAL];/* default input sequence */ +}; + + +/* heaeder at the front of INP files */ typedef struct _inp_header inp_header; struct _inp_header { - char header[8]; /* +00: 8 byte header - must be "MAMEINP\0" */ - UINT64 basetime; /* +08: base time of recording */ - UINT8 majversion; /* +10: major INP version */ - UINT8 minversion; /* +11: minor INP version */ - UINT8 reserved[2]; /* +12: must be zero */ - char gamename[12]; /* +14: game name string, NULL-terminated */ - char version[32]; /* +20: system version string, NULL-terminated */ + char header[8]; /* +00: 8 byte header - must be "MAMEINP\0" */ + UINT64 basetime; /* +08: base time of recording */ + UINT8 majversion; /* +10: major INP version */ + UINT8 minversion; /* +11: minor INP version */ + UINT8 reserved[2]; /* +12: must be zero */ + char gamename[12]; /* +14: game name string, NULL-terminated */ + char version[32]; /* +20: system version string, NULL-terminated */ }; /*************************************************************************** - MACROS FOR BUILDING INPUT PORTS + MACROS ***************************************************************************/ -#define IP_NAME_DEFAULT NULL +/* macro for a custom callback functions (PORT_CUSTOM) */ +#define CUSTOM_INPUT(name) UINT32 name(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 wrapping a default string */ +#define DEF_STR(str_num) ((const char *)INPUT_STRING_##str_num) + + + +/*************************************************************************** + MACROS FOR BUILDING INPUT PORTS +***************************************************************************/ /* start of table */ #define INPUT_PORTS_START(_name) \ @@ -688,7 +718,7 @@ struct _inp_header /* input bit definition */ #define PORT_BIT(_mask, _default, _type) \ - TOKEN_UINT32_PACK2(INPUT_TOKEN_BIT, 8, _type, 24), \ + TOKEN_UINT32_PACK2(INPUT_TOKEN_FIELD, 8, _type, 24), \ TOKEN_UINT64_PACK2(_mask, 32, _default, 32), #define PORT_SPECIAL_ONOFF(_mask, _default, _strindex) \ @@ -845,7 +875,6 @@ struct _inp_header TOKEN_UINT64_PACK2(INPUT_TOKEN_CONFSETTING, 8, _default, 32), \ TOKEN_STRING(_name), -#ifdef MESS /* keyboard chars */ #define PORT_CHAR(_ch) \ TOKEN_UINT64_PACK2(INPUT_TOKEN_CHAR, 8, _ch, 32), \ @@ -862,7 +891,6 @@ struct _inp_header #define PORT_CATEGORY_ITEM(_default, _name, _category) \ TOKEN_UINT64_PACK3(INPUT_TOKEN_CATEGORY_SETTING, 8, _default, 32, _category, 16), \ TOKEN_STRING(_name), -#endif /* MESS */ @@ -894,54 +922,120 @@ struct _inp_header /*************************************************************************** - GLOBAL VARIABLES + FUNCTION PROTOTYPES ***************************************************************************/ -#define DEF_STR(str_num) ((const char *)INPUT_STRING_##str_num) +/* ----- core system management ----- */ -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ +/* initialize the input ports, processing the given token list */ +time_t input_port_init(running_machine *machine, const input_port_token *tokens); + + + +/* ----- port configurations ----- */ + +/* allocate a list of input ports from the given token list */ +const input_port_config *input_port_config_alloc(const input_port_token *tokens); + +/* free memory allocated from input_port_alloc */ +void input_port_config_free(const input_port_config *portlist); + +/* return the config that matches the given tag */ +const input_port_config *input_port_by_tag(const input_port_config *portlist, const char *tag); + +/* return the config that matches the given tag */ +const input_port_config *input_port_by_index(const input_port_config *portlist, int index); + + + +/* ----- accessors for input types ----- */ + +/* return TRUE if the given type represents an analog control */ +int input_type_is_analog(int type); + +/* return the name for the given type/player */ +const char *input_type_name(running_machine *machine, int type, int player); + +/* return the group for the given type/player */ +int input_type_group(running_machine *machine, int type, int player); + +/* return the global input mapping sequence for the given type/player */ +const input_seq *input_type_seq(running_machine *machine, int type, int player, input_seq_type seqtype); + +/* change the global input sequence for the given type/player */ +void input_type_set_seq(running_machine *machine, int type, int player, input_seq_type seqtype, const input_seq *newseq); + +/* return TRUE if the sequence for the given input type/player is pressed */ +int input_type_pressed(running_machine *machine, int type, int player); + +/* return the list of default mappings */ +const input_type_desc *input_type_list(running_machine *machine); + + + +/* ----- accessors for input fields ----- */ -time_t input_port_init(running_machine *machine, const input_port_token *ipt); +/* return the expanded string name of the field */ +const char *input_field_name(const input_field_config *field); + +/* return the input sequence for the given input field */ +const input_seq *input_field_seq(const input_field_config *field, input_seq_type seqtype); + +/* return the current settings for the given input field */ +void input_field_get_user_settings(const input_field_config *field, input_field_user_settings *settings); + +/* modify the current settings for the given input field */ +void input_field_set_user_settings(const input_field_config *field, const input_field_user_settings *settings); + + + +/* ----- user interface sequence reading ----- */ + +/* return TRUE if a key down for the given user interface sequence is detected */ +int input_ui_pressed(running_machine *machine, int code); + +/* return TRUE if a key down for the given user interface sequence is detected, or if + autorepeat at the given speed is triggered */ +int input_ui_pressed_repeat(running_machine *machine, int code, int speed); + + + +/* ----- port reading ----- */ + +/* return the value of an input port */ +input_port_value input_port_read_direct(const input_port_config *port); + +/* return the value of an input port specified by tag */ +input_port_value input_port_read(running_machine *machine, const char *tag); + +/* return the value of an input port specified by tag, or a default value if the port does not exist */ +input_port_value input_port_read_safe(running_machine *machine, const char *tag, input_port_value defvalue); + +/* return the value of an input port specified by index */ +input_port_value input_port_read_indexed(running_machine *machine, int portnum); + +/* return the extracted crosshair values for the given player */ +int input_port_get_crosshair_position(running_machine *machine, int player, float *x, float *y); + +/* force an update to the input port values based on current conditions */ +void input_port_update_defaults(running_machine *machine); + + + +/* ----- misc helper functions ----- */ + +/* return the TRUE if the given condition attached is true */ +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); -input_port_entry *input_port_initialize(input_port_init_params *params, UINT32 type, const char *tag, UINT32 mask, UINT32 defval); -input_port_entry *input_port_allocate(const input_port_token *ipt, input_port_entry *memory); -void input_port_parse_diplocation(input_port_entry *in, const char *location); - -input_port_default_entry *get_input_port_list(void); -const input_port_default_entry *get_input_port_list_defaults(void); - -int input_port_active(const input_port_entry *in); -int port_type_is_analog(int type); -int port_type_is_analog_absolute(int type); -int port_type_in_use(int type); -int port_type_to_group(int type, int player); -int port_tag_to_index(const char *tag); -read8_machine_func port_tag_to_handler8(const char *tag); -read16_machine_func port_tag_to_handler16(const char *tag); -read32_machine_func port_tag_to_handler32(const char *tag); -read64_machine_func port_tag_to_handler64(const char *tag); -const char *input_port_name(const input_port_entry *in); -const input_seq *input_port_seq(input_port_entry *in, input_seq_type seqtype); -const input_seq *input_port_default_seq(int type, int player, input_seq_type seqtype); -int input_port_condition(const input_port_entry *in); - -const char *port_type_to_token(int type, int player); -int token_to_port_type(const char *string, int *player); - -int input_port_type_pressed(int type, int player); -int input_ui_pressed(int code); -int input_ui_pressed_repeat(int code, int speed); - -void input_port_update_defaults(void); - -UINT32 get_crosshair_pos(int port_num, UINT8 player, UINT8 axis); - -UINT32 input_port_read_indexed(running_machine *machine, int port); -UINT32 input_port_read(running_machine *machine, const char *tag); -UINT32 input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue); +/* return a memory handler corresponding to a given input port tag */ +read8_machine_func input_port_read_handler8(const input_port_config *portlist, const char *tag); +read16_machine_func input_port_read_handler16(const input_port_config *portlist, const char *tag); +read32_machine_func input_port_read_handler32(const input_port_config *portlist, const char *tag); +read64_machine_func input_port_read_handler64(const input_port_config *portlist, const char *tag); + #endif /* __INPTPORT_H__ */ diff --git a/src/emu/inpttype.h b/src/emu/inpttype.h new file mode 100644 index 00000000000..844d8bfa136 --- /dev/null +++ b/src/emu/inpttype.h @@ -0,0 +1,598 @@ +/*************************************************************************** + + inpttype.h + + Array of core-defined input types and default mappings. + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +***************************************************************************/ + + +/*************************************************************************** + BUILT-IN CORE MAPPINGS +***************************************************************************/ + +#define INPUT_PORT_DIGITAL_TYPE(_player,_group,_type,_name,_seq) \ + { NULL, IPT_##_type, IPG_##_group, (_player == 0) ? _player : (_player) - 1, (_player == 0) ? #_type : ("P" #_player "_" #_type), _name, { _seq, SEQ_DEF_0, SEQ_DEF_0 } }, + +#define INPUT_PORT_ANALOG_TYPE(_player,_group,_type,_name,_seq,_decseq,_incseq) \ + { NULL, IPT_##_type, IPG_##_group, (_player == 0) ? _player : (_player) - 1, (_player == 0) ? #_type : ("P" #_player "_" #_type), _name, { _seq, _incseq, _decseq } }, + +#define INDEXED(a,b) INPUT_CODE_SET_DEVINDEX(a,b) + +static const input_type_desc core_types[] = +{ + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICK_UP, "P1 Up", SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICK_DOWN, "P1 Down", SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICK_LEFT, "P1 Left", SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICK_RIGHT, "P1 Right", SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKRIGHT_UP, "P1 Right/Up", SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKRIGHT_DOWN, "P1 Right/Down", SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKRIGHT_LEFT, "P1 Right/Left", SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKRIGHT_RIGHT, "P1 Right/Right", SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKLEFT_UP, "P1 Left/Up", SEQ_DEF_3(KEYCODE_E, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKLEFT_DOWN, "P1 Left/Down", SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKLEFT_LEFT, "P1 Left/Left", SEQ_DEF_3(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKLEFT_RIGHT, "P1 Left/Right", SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON1, "P1 Button 1", SEQ_DEF_7(KEYCODE_LCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON1, 0), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON2, "P1 Button 2", SEQ_DEF_7(KEYCODE_LALT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON3, 0), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON3, "P1 Button 3", SEQ_DEF_5(KEYCODE_SPACE, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON2, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON4, "P1 Button 4", SEQ_DEF_3(KEYCODE_LSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON5, "P1 Button 5", SEQ_DEF_3(KEYCODE_Z, SEQCODE_OR, INDEXED(JOYCODE_BUTTON5, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON6, "P1 Button 6", SEQ_DEF_3(KEYCODE_X, SEQCODE_OR, INDEXED(JOYCODE_BUTTON6, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON7, "P1 Button 7", SEQ_DEF_3(KEYCODE_C, SEQCODE_OR, INDEXED(JOYCODE_BUTTON7, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON8, "P1 Button 8", SEQ_DEF_3(KEYCODE_V, SEQCODE_OR, INDEXED(JOYCODE_BUTTON8, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON9, "P1 Button 9", SEQ_DEF_3(KEYCODE_B, SEQCODE_OR, INDEXED(JOYCODE_BUTTON9, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON10, "P1 Button 10", SEQ_DEF_3(KEYCODE_N, SEQCODE_OR, INDEXED(JOYCODE_BUTTON10, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON11, "P1 Button 11", SEQ_DEF_3(KEYCODE_M, SEQCODE_OR, INDEXED(JOYCODE_BUTTON11, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON12, "P1 Button 12", SEQ_DEF_3(KEYCODE_COMMA, SEQCODE_OR, INDEXED(JOYCODE_BUTTON12, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON13, "P1 Button 13", SEQ_DEF_3(KEYCODE_STOP, SEQCODE_OR, INDEXED(JOYCODE_BUTTON13, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON14, "P1 Button 14", SEQ_DEF_3(KEYCODE_SLASH, SEQCODE_OR, INDEXED(JOYCODE_BUTTON14, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON15, "P1 Button 15", SEQ_DEF_3(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON15, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON16, "P1 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, START, "P1 Start", SEQ_DEF_3(KEYCODE_1, SEQCODE_OR, INDEXED(JOYCODE_START, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, SELECT, "P1 Select", SEQ_DEF_3(KEYCODE_5, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_A, "P1 Mahjong A", SEQ_DEF_1(KEYCODE_A) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_B, "P1 Mahjong B", SEQ_DEF_1(KEYCODE_B) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_C, "P1 Mahjong C", SEQ_DEF_1(KEYCODE_C) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_D, "P1 Mahjong D", SEQ_DEF_1(KEYCODE_D) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_E, "P1 Mahjong E", SEQ_DEF_1(KEYCODE_E) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_F, "P1 Mahjong F", SEQ_DEF_1(KEYCODE_F) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_G, "P1 Mahjong G", SEQ_DEF_1(KEYCODE_G) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_H, "P1 Mahjong H", SEQ_DEF_1(KEYCODE_H) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_I, "P1 Mahjong I", SEQ_DEF_1(KEYCODE_I) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_J, "P1 Mahjong J", SEQ_DEF_1(KEYCODE_J) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_K, "P1 Mahjong K", SEQ_DEF_1(KEYCODE_K) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_L, "P1 Mahjong L", SEQ_DEF_1(KEYCODE_L) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_M, "P1 Mahjong M", SEQ_DEF_1(KEYCODE_M) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_N, "P1 Mahjong N", SEQ_DEF_1(KEYCODE_N) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_O, "P1 Mahjong O", SEQ_DEF_1(KEYCODE_O) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_P, "P1 Mahjong P", SEQ_DEF_1(KEYCODE_COLON) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_Q, "P1 Mahjong Q", SEQ_DEF_1(KEYCODE_Q) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_KAN, "P1 Mahjong Kan", SEQ_DEF_1(KEYCODE_LCONTROL) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_PON, "P1 Mahjong Pon", SEQ_DEF_1(KEYCODE_LALT) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_CHI, "P1 Mahjong Chi", SEQ_DEF_1(KEYCODE_SPACE) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_REACH, "P1 Mahjong Reach", SEQ_DEF_1(KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_RON, "P1 Mahjong Ron", SEQ_DEF_1(KEYCODE_Z) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_BET, "P1 Mahjong Bet", SEQ_DEF_1(KEYCODE_2) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_LAST_CHANCE, "P1 Mahjong Last Chance", SEQ_DEF_1(KEYCODE_RALT) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_SCORE, "P1 Mahjong Score", SEQ_DEF_1(KEYCODE_RCONTROL) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_DOUBLE_UP, "P1 Mahjong Double Up", SEQ_DEF_1(KEYCODE_RSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_FLIP_FLOP, "P1 Mahjong Flip Flop", SEQ_DEF_1(KEYCODE_Y) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_BIG, "P1 Mahjong Big", SEQ_DEF_1(KEYCODE_ENTER) ) + INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_SMALL, "P1 Mahjong Small", SEQ_DEF_1(KEYCODE_BACKSPACE) ) + + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICK_UP, "P2 Up", SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICK_DOWN, "P2 Down", SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICK_LEFT, "P2 Left", SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICK_RIGHT, "P2 Right", SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKRIGHT_UP, "P2 Right/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKRIGHT_DOWN, "P2 Right/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKRIGHT_LEFT, "P2 Right/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKRIGHT_RIGHT, "P2 Right/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKLEFT_UP, "P2 Left/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKLEFT_DOWN, "P2 Left/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKLEFT_LEFT, "P2 Left/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKLEFT_RIGHT, "P2 Left/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON1, "P2 Button 1", SEQ_DEF_7(KEYCODE_A, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON1, 1), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON2, "P2 Button 2", SEQ_DEF_7(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON3, 1), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON3, "P2 Button 3", SEQ_DEF_5(KEYCODE_Q, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON2, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON4, "P2 Button 4", SEQ_DEF_3(KEYCODE_W, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON5, "P2 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON6, "P2 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON7, "P2 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON8, "P2 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON9, "P2 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON10, "P2 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON11, "P2 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON12, "P2 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON13, "P2 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON14, "P2 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON15, "P2 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON16, "P2 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, START, "P2 Start", SEQ_DEF_3(KEYCODE_2, SEQCODE_OR, INDEXED(JOYCODE_START, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, SELECT, "P2 Select", SEQ_DEF_3(KEYCODE_6, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_A, "P2 Mahjong A", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_B, "P2 Mahjong B", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_C, "P2 Mahjong C", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_D, "P2 Mahjong D", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_E, "P2 Mahjong E", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_F, "P2 Mahjong F", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_G, "P2 Mahjong G", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_H, "P2 Mahjong H", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_I, "P2 Mahjong I", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_J, "P2 Mahjong J", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_K, "P2 Mahjong K", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_L, "P2 Mahjong L", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_M, "P2 Mahjong M", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_N, "P2 Mahjong N", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_O, "P2 Mahjong O", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_P, "P2 Mahjong P", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_Q, "P2 Mahjong Q", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_KAN, "P2 Mahjong Kan", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_PON, "P2 Mahjong Pon", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_CHI, "P2 Mahjong Chi", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_REACH, "P2 Mahjong Reach", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_RON, "P2 Mahjong Ron", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_BET, "P2 Mahjong Bet", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_LAST_CHANCE, "P2 Mahjong Last Chance", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_SCORE, "P2 Mahjong Score", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_DOUBLE_UP, "P2 Mahjong Double Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_FLIP_FLOP, "P2 Mahjong Flip Flop", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_BIG, "P2 Mahjong Big", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_SMALL, "P2 Mahjong Small", SEQ_DEF_0 ) + + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICK_UP, "P3 Up", SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICK_DOWN, "P3 Down", SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICK_LEFT, "P3 Left", SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICK_RIGHT, "P3 Right", SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKRIGHT_UP, "P3 Right/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKRIGHT_DOWN, "P3 Right/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKRIGHT_LEFT, "P3 Right/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKRIGHT_RIGHT, "P3 Right/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKLEFT_UP, "P3 Left/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKLEFT_DOWN, "P3 Left/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKLEFT_LEFT, "P3 Left/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKLEFT_RIGHT, "P3 Left/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON1, "P3 Button 1", SEQ_DEF_5(KEYCODE_RCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 2), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON2, "P3 Button 2", SEQ_DEF_5(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 2), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON3, "P3 Button 3", SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON4, "P3 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON5, "P3 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON6, "P3 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON7, "P3 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON8, "P3 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON9, "P3 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON10, "P3 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON11, "P3 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON12, "P3 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON13, "P3 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON14, "P3 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON15, "P3 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON16, "P3 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, START, "P3 Start", SEQ_DEF_3(KEYCODE_3, SEQCODE_OR, INDEXED(JOYCODE_START, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, SELECT, "P3 Select", SEQ_DEF_3(KEYCODE_7, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 2)) ) + + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICK_UP, "P4 Up", SEQ_DEF_3(KEYCODE_8_PAD, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICK_DOWN, "P4 Down", SEQ_DEF_3(KEYCODE_2_PAD, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICK_LEFT, "P4 Left", SEQ_DEF_3(KEYCODE_4_PAD, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICK_RIGHT, "P4 Right", SEQ_DEF_3(KEYCODE_6_PAD, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKRIGHT_UP, "P4 Right/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKRIGHT_DOWN, "P4 Right/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKRIGHT_LEFT, "P4 Right/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKRIGHT_RIGHT, "P4 Right/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKLEFT_UP, "P4 Left/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKLEFT_DOWN, "P4 Left/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKLEFT_LEFT, "P4 Left/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKLEFT_RIGHT, "P4 Left/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON1, "P4 Button 1", SEQ_DEF_3(KEYCODE_0_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON2, "P4 Button 2", SEQ_DEF_3(KEYCODE_DEL_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON3, "P4 Button 3", SEQ_DEF_3(KEYCODE_ENTER_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON4, "P4 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON5, "P4 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON6, "P4 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON7, "P4 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON8, "P4 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON9, "P4 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON10, "P4 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON11, "P4 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON12, "P4 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON13, "P4 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON14, "P4 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON15, "P4 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON16, "P4 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, START, "P4 Start", SEQ_DEF_3(KEYCODE_4, SEQCODE_OR, INDEXED(JOYCODE_START, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, SELECT, "P4 Select", SEQ_DEF_3(KEYCODE_8, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 3)) ) + + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICK_UP, "P5 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICK_DOWN, "P5 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICK_LEFT, "P5 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICK_RIGHT, "P5 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKRIGHT_UP, "P5 Right/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKRIGHT_DOWN, "P5 Right/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKRIGHT_LEFT, "P5 Right/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKRIGHT_RIGHT, "P5 Right/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKLEFT_UP, "P5 Left/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKLEFT_DOWN, "P5 Left/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKLEFT_LEFT, "P5 Left/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKLEFT_RIGHT, "P5 Left/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON1, "P5 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON2, "P5 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON3, "P5 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON4, "P5 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON5, "P5 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON6, "P5 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON7, "P5 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON8, "P5 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON9, "P5 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON10, "P5 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON11, "P5 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON12, "P5 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON13, "P5 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON14, "P5 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON15, "P5 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON16, "P5 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 4)) ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, START, "P5 Start", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, SELECT, "P5 Select", SEQ_DEF_0 ) + + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICK_UP, "P6 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICK_DOWN, "P6 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICK_LEFT, "P6 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICK_RIGHT, "P6 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKRIGHT_UP, "P6 Right/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKRIGHT_DOWN, "P6 Right/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKRIGHT_LEFT, "P6 Right/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKRIGHT_RIGHT, "P6 Right/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKLEFT_UP, "P6 Left/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKLEFT_DOWN, "P6 Left/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKLEFT_LEFT, "P6 Left/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKLEFT_RIGHT, "P6 Left/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON1, "P6 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON2, "P6 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON3, "P6 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON4, "P6 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON5, "P6 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON6, "P6 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON7, "P6 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON8, "P6 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON9, "P6 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON10, "P6 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON11, "P6 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON12, "P6 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON13, "P6 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON14, "P6 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON15, "P6 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON16, "P6 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 5)) ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, START, "P6 Start", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, SELECT, "P6 Select", SEQ_DEF_0 ) + + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICK_UP, "P7 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICK_DOWN, "P7 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICK_LEFT, "P7 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICK_RIGHT, "P7 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKRIGHT_UP, "P7 Right/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKRIGHT_DOWN, "P7 Right/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKRIGHT_LEFT, "P7 Right/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKRIGHT_RIGHT, "P7 Right/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKLEFT_UP, "P7 Left/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKLEFT_DOWN, "P7 Left/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKLEFT_LEFT, "P7 Left/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKLEFT_RIGHT, "P7 Left/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON1, "P7 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON2, "P7 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON3, "P7 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON4, "P7 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON5, "P7 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON6, "P7 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON7, "P7 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON8, "P7 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON9, "P7 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON10, "P7 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON11, "P7 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON12, "P7 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON13, "P7 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON14, "P7 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON15, "P7 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON16, "P7 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 6)) ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, START, "P7 Start", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, SELECT, "P7 Select", SEQ_DEF_0 ) + + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICK_UP, "P8 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICK_DOWN, "P8 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICK_LEFT, "P8 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICK_RIGHT, "P8 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKRIGHT_UP, "P8 Right/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKRIGHT_DOWN, "P8 Right/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKRIGHT_LEFT, "P8 Right/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKRIGHT_RIGHT, "P8 Right/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKLEFT_UP, "P8 Left/Up", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKLEFT_DOWN, "P8 Left/Down", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKLEFT_LEFT, "P8 Left/Left", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKLEFT_RIGHT, "P8 Left/Right", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON1, "P8 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON2, "P8 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON3, "P8 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON4, "P8 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON5, "P8 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON6, "P8 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON7, "P8 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON8, "P8 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON9, "P8 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON10, "P8 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON11, "P8 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON12, "P8 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON13, "P8 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON14, "P8 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON15, "P8 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON16, "P8 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 7)) ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, START, "P8 Start", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, SELECT, "P8 Select", SEQ_DEF_0 ) + + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START1, "1 Player Start", SEQ_DEF_3(KEYCODE_1, SEQCODE_OR, INDEXED(JOYCODE_START, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START2, "2 Players Start", SEQ_DEF_3(KEYCODE_2, SEQCODE_OR, INDEXED(JOYCODE_START, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START3, "3 Players Start", SEQ_DEF_3(KEYCODE_3, SEQCODE_OR, INDEXED(JOYCODE_START, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START4, "4 Players Start", SEQ_DEF_3(KEYCODE_4, SEQCODE_OR, INDEXED(JOYCODE_START, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START5, "5 Players Start", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START6, "6 Players Start", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START7, "7 Players Start", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START8, "8 Players Start", SEQ_DEF_0 ) + + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN1, "Coin 1", SEQ_DEF_3(KEYCODE_5, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN2, "Coin 2", SEQ_DEF_3(KEYCODE_6, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 1)) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN3, "Coin 3", SEQ_DEF_3(KEYCODE_7, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 2)) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN4, "Coin 4", SEQ_DEF_3(KEYCODE_8, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 3)) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN5, "Coin 5", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN6, "Coin 6", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN7, "Coin 7", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN8, "Coin 8", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, BILL1, "Bill 1", SEQ_DEF_1(KEYCODE_BACKSPACE) ) + + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, SERVICE1, "Service 1", SEQ_DEF_1(KEYCODE_9) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, SERVICE2, "Service 2", SEQ_DEF_1(KEYCODE_0) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, SERVICE3, "Service 3", SEQ_DEF_1(KEYCODE_MINUS) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, SERVICE4, "Service 4", SEQ_DEF_1(KEYCODE_EQUALS) ) + + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, SERVICE, "Service", SEQ_DEF_1(KEYCODE_F2) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, TILT, "Tilt", SEQ_DEF_1(KEYCODE_T) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, INTERLOCK, "Door Interlock", SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, VOLUME_DOWN, "Volume Down", SEQ_DEF_1(KEYCODE_MINUS) ) + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, VOLUME_UP, "Volume Up", SEQ_DEF_1(KEYCODE_EQUALS) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, PEDAL, "P1 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 0)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_LCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, PEDAL, "P2 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 1)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_A, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, PEDAL, "P3 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 2)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_RCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, PEDAL, "P4 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 3)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_0_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, PEDAL, "P5 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 4)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, PEDAL, "P6 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 5)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, PEDAL, "P7 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 6)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, PEDAL, "P8 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 7)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, PEDAL2, "P1 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 0)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_LALT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, PEDAL2, "P2 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 1)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, PEDAL2, "P3 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 2)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, PEDAL2, "P4 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 3)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_DEL_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, PEDAL2, "P5 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 4)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, PEDAL2, "P6 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 5)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, PEDAL2, "P7 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 6)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, PEDAL2, "P8 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 7)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, PEDAL3, "P1 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_SPACE, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, PEDAL3, "P2 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_Q, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, PEDAL3, "P3 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, PEDAL3, "P4 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_ENTER_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, PEDAL3, "P5 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, PEDAL3, "P6 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, PEDAL3, "P7 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, PEDAL3, "P8 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, PADDLE, "Paddle", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, PADDLE, "Paddle 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, PADDLE, "Paddle 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, PADDLE, "Paddle 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, PADDLE, "Paddle 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, PADDLE, "Paddle 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, PADDLE, "Paddle 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, PADDLE, "Paddle 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, PADDLE_V, "Paddle V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, PADDLE_V, "Paddle V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, PADDLE_V, "Paddle V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, PADDLE_V, "Paddle V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, PADDLE_V, "Paddle V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, PADDLE_V, "Paddle V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, PADDLE_V, "Paddle V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, PADDLE_V, "Paddle V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, POSITIONAL, "Positional", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, POSITIONAL, "Positional 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, POSITIONAL, "Positional 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, POSITIONAL, "Positional 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, POSITIONAL, "Positional 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, POSITIONAL, "Positional 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, POSITIONAL, "Positional 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, POSITIONAL, "Positional 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, POSITIONAL_V, "Positional V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, POSITIONAL_V, "Positional V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, POSITIONAL_V, "Positional V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, POSITIONAL_V, "Positional V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, POSITIONAL_V, "Positional V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, POSITIONAL_V, "Positional V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, POSITIONAL_V, "Positional V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, POSITIONAL_V, "Positional V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, DIAL, "Dial", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, DIAL, "Dial 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, DIAL, "Dial 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, DIAL, "Dial 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, DIAL, "Dial 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, DIAL, "Dial 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, DIAL, "Dial 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, DIAL, "Dial 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, DIAL_V, "Dial V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, DIAL_V, "Dial V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, DIAL_V, "Dial V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, DIAL_V, "Dial V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, DIAL_V, "Dial V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, DIAL_V, "Dial V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, DIAL_V, "Dial V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, DIAL_V, "Dial V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, TRACKBALL_X, "Track X", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, TRACKBALL_X, "Track X 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, TRACKBALL_X, "Track X 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, TRACKBALL_X, "Track X 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, TRACKBALL_X, "Track X 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, TRACKBALL_X, "Track X 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, TRACKBALL_X, "Track X 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, TRACKBALL_X, "Track X 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, TRACKBALL_Y, "Track Y", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, TRACKBALL_Y, "Track Y 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, TRACKBALL_Y, "Track Y 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, TRACKBALL_Y, "Track Y 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, TRACKBALL_Y, "Track Y 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, TRACKBALL_Y, "Track Y 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, TRACKBALL_Y, "Track Y 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, TRACKBALL_Y, "Track Y 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, AD_STICK_X, "AD Stick X", SEQ_DEF_3(INDEXED(JOYCODE_X, 0), SEQCODE_OR, INDEXED(MOUSECODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, AD_STICK_X, "AD Stick X 2", SEQ_DEF_3(INDEXED(JOYCODE_X, 1), SEQCODE_OR, INDEXED(MOUSECODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, AD_STICK_X, "AD Stick X 3", SEQ_DEF_3(INDEXED(JOYCODE_X, 2), SEQCODE_OR, INDEXED(MOUSECODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, AD_STICK_X, "AD Stick X 4", SEQ_DEF_3(INDEXED(JOYCODE_X, 3), SEQCODE_OR, INDEXED(MOUSECODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, AD_STICK_X, "AD Stick X 5", SEQ_DEF_3(INDEXED(JOYCODE_X, 4), SEQCODE_OR, INDEXED(MOUSECODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, AD_STICK_X, "AD Stick X 6", SEQ_DEF_3(INDEXED(JOYCODE_X, 5), SEQCODE_OR, INDEXED(MOUSECODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, AD_STICK_X, "AD Stick X 7", SEQ_DEF_3(INDEXED(JOYCODE_X, 6), SEQCODE_OR, INDEXED(MOUSECODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, AD_STICK_X, "AD Stick X 8", SEQ_DEF_3(INDEXED(JOYCODE_X, 7), SEQCODE_OR, INDEXED(MOUSECODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, AD_STICK_Y, "AD Stick Y", SEQ_DEF_3(INDEXED(JOYCODE_Y, 0), SEQCODE_OR, INDEXED(MOUSECODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, AD_STICK_Y, "AD Stick Y 2", SEQ_DEF_3(INDEXED(JOYCODE_Y, 1), SEQCODE_OR, INDEXED(MOUSECODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, AD_STICK_Y, "AD Stick Y 3", SEQ_DEF_3(INDEXED(JOYCODE_Y, 2), SEQCODE_OR, INDEXED(MOUSECODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, AD_STICK_Y, "AD Stick Y 4", SEQ_DEF_3(INDEXED(JOYCODE_Y, 3), SEQCODE_OR, INDEXED(MOUSECODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, AD_STICK_Y, "AD Stick Y 5", SEQ_DEF_3(INDEXED(JOYCODE_Y, 4), SEQCODE_OR, INDEXED(MOUSECODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, AD_STICK_Y, "AD Stick Y 6", SEQ_DEF_3(INDEXED(JOYCODE_Y, 5), SEQCODE_OR, INDEXED(MOUSECODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, AD_STICK_Y, "AD Stick Y 7", SEQ_DEF_3(INDEXED(JOYCODE_Y, 6), SEQCODE_OR, INDEXED(MOUSECODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, AD_STICK_Y, "AD Stick Y 8", SEQ_DEF_3(INDEXED(JOYCODE_Y, 7), SEQCODE_OR, INDEXED(MOUSECODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, AD_STICK_Z, "AD Stick Z", SEQ_DEF_1(INDEXED(JOYCODE_Z, 0)), SEQ_DEF_0, SEQ_DEF_0 ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, AD_STICK_Z, "AD Stick Z 2", SEQ_DEF_1(INDEXED(JOYCODE_Z, 1)), SEQ_DEF_0, SEQ_DEF_0 ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, AD_STICK_Z, "AD Stick Z 3", SEQ_DEF_1(INDEXED(JOYCODE_Z, 2)), SEQ_DEF_0, SEQ_DEF_0 ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, AD_STICK_Z, "AD Stick Z 4", SEQ_DEF_1(INDEXED(JOYCODE_Z, 3)), SEQ_DEF_0, SEQ_DEF_0 ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, AD_STICK_Z, "AD Stick Z 5", SEQ_DEF_1(INDEXED(JOYCODE_Z, 4)), SEQ_DEF_0, SEQ_DEF_0 ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, AD_STICK_Z, "AD Stick Z 6", SEQ_DEF_1(INDEXED(JOYCODE_Z, 5)), SEQ_DEF_0, SEQ_DEF_0 ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, AD_STICK_Z, "AD Stick Z 7", SEQ_DEF_1(INDEXED(JOYCODE_Z, 6)), SEQ_DEF_0, SEQ_DEF_0 ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, AD_STICK_Z, "AD Stick Z 8", SEQ_DEF_1(INDEXED(JOYCODE_Z, 7)), SEQ_DEF_0, SEQ_DEF_0 ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, LIGHTGUN_X, "Lightgun X", SEQ_DEF_5(INDEXED(GUNCODE_X, 0), SEQCODE_OR, INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, LIGHTGUN_X, "Lightgun X 2", SEQ_DEF_5(INDEXED(GUNCODE_X, 1), SEQCODE_OR, INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, LIGHTGUN_X, "Lightgun X 3", SEQ_DEF_5(INDEXED(GUNCODE_X, 2), SEQCODE_OR, INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, LIGHTGUN_X, "Lightgun X 4", SEQ_DEF_5(INDEXED(GUNCODE_X, 3), SEQCODE_OR, INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, LIGHTGUN_X, "Lightgun X 5", SEQ_DEF_5(INDEXED(GUNCODE_X, 4), SEQCODE_OR, INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, LIGHTGUN_X, "Lightgun X 6", SEQ_DEF_5(INDEXED(GUNCODE_X, 5), SEQCODE_OR, INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, LIGHTGUN_X, "Lightgun X 7", SEQ_DEF_5(INDEXED(GUNCODE_X, 6), SEQCODE_OR, INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, LIGHTGUN_X, "Lightgun X 8", SEQ_DEF_5(INDEXED(GUNCODE_X, 7), SEQCODE_OR, INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, LIGHTGUN_Y, "Lightgun Y", SEQ_DEF_5(INDEXED(GUNCODE_Y, 0), SEQCODE_OR, INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, LIGHTGUN_Y, "Lightgun Y 2", SEQ_DEF_5(INDEXED(GUNCODE_Y, 1), SEQCODE_OR, INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, LIGHTGUN_Y, "Lightgun Y 3", SEQ_DEF_5(INDEXED(GUNCODE_Y, 2), SEQCODE_OR, INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, LIGHTGUN_Y, "Lightgun Y 4", SEQ_DEF_5(INDEXED(GUNCODE_Y, 3), SEQCODE_OR, INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, LIGHTGUN_Y, "Lightgun Y 5", SEQ_DEF_5(INDEXED(GUNCODE_Y, 4), SEQCODE_OR, INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, LIGHTGUN_Y, "Lightgun Y 6", SEQ_DEF_5(INDEXED(GUNCODE_Y, 5), SEQCODE_OR, INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, LIGHTGUN_Y, "Lightgun Y 7", SEQ_DEF_5(INDEXED(GUNCODE_Y, 6), SEQCODE_OR, INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, LIGHTGUN_Y, "Lightgun Y 8", SEQ_DEF_5(INDEXED(GUNCODE_Y, 7), SEQCODE_OR, INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, MOUSE_X, "Mouse X", SEQ_DEF_1(INDEXED(MOUSECODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, MOUSE_X, "Mouse X 2", SEQ_DEF_1(INDEXED(MOUSECODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, MOUSE_X, "Mouse X 3", SEQ_DEF_1(INDEXED(MOUSECODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, MOUSE_X, "Mouse X 4", SEQ_DEF_1(INDEXED(MOUSECODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, MOUSE_X, "Mouse X 5", SEQ_DEF_1(INDEXED(MOUSECODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, MOUSE_X, "Mouse X 6", SEQ_DEF_1(INDEXED(MOUSECODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, MOUSE_X, "Mouse X 7", SEQ_DEF_1(INDEXED(MOUSECODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, MOUSE_X, "Mouse X 8", SEQ_DEF_1(INDEXED(MOUSECODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) + + INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, MOUSE_Y, "Mouse Y", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) + INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, MOUSE_Y, "Mouse Y 2", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) + INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, MOUSE_Y, "Mouse Y 3", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) + INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, MOUSE_Y, "Mouse Y 4", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) + INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, MOUSE_Y, "Mouse Y 5", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) + INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, MOUSE_Y, "Mouse Y 6", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) + INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, MOUSE_Y, "Mouse Y 7", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) + INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, MOUSE_Y, "Mouse Y 8", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) + + INPUT_PORT_DIGITAL_TYPE( 0, OTHER, KEYBOARD, "Keyboard", SEQ_DEF_0 ) + + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ON_SCREEN_DISPLAY,"On Screen Display", SEQ_DEF_1(KEYCODE_TILDE) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DEBUG_BREAK, "Break in Debugger", SEQ_DEF_1(KEYCODE_TILDE) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_CONFIGURE, "Config Menu", SEQ_DEF_1(KEYCODE_TAB) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PAUSE, "Pause", SEQ_DEF_1(KEYCODE_P) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RESET_MACHINE, "Reset Game", SEQ_DEF_2(KEYCODE_F3, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SOFT_RESET, "Soft Reset", SEQ_DEF_3(KEYCODE_F3, SEQCODE_NOT, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SHOW_GFX, "Show Gfx", SEQ_DEF_1(KEYCODE_F4) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FRAMESKIP_DEC, "Frameskip Dec", SEQ_DEF_1(KEYCODE_F8) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FRAMESKIP_INC, "Frameskip Inc", SEQ_DEF_1(KEYCODE_F9) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_THROTTLE, "Throttle", SEQ_DEF_1(KEYCODE_F10) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FAST_FORWARD, "Fast Forward", SEQ_DEF_1(KEYCODE_INSERT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SHOW_FPS, "Show FPS", SEQ_DEF_5(KEYCODE_F11, SEQCODE_NOT, KEYCODE_LCONTROL, SEQCODE_NOT, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SNAPSHOT, "Save Snapshot", SEQ_DEF_3(KEYCODE_F12, SEQCODE_NOT, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RECORD_MOVIE, "Record Movie", SEQ_DEF_2(KEYCODE_F12, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_CHEAT, "Toggle Cheat", SEQ_DEF_1(KEYCODE_F6) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_UP, "UI Up", SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DOWN, "UI Down", SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_LEFT, "UI Left", SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RIGHT, "UI Right", SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_HOME, "UI Home", SEQ_DEF_1(KEYCODE_HOME) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_END, "UI End", SEQ_DEF_1(KEYCODE_END) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PAGE_UP, "UI Page Up", SEQ_DEF_1(KEYCODE_PGUP) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PAGE_DOWN, "UI Page Down", SEQ_DEF_1(KEYCODE_PGDN) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SELECT, "UI Select", SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_CANCEL, "UI Cancel", SEQ_DEF_1(KEYCODE_ESC) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_CLEAR, "UI Clear", SEQ_DEF_1(KEYCODE_DEL) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ZOOM_IN, "UI Zoom In", SEQ_DEF_1(KEYCODE_EQUALS) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ZOOM_OUT, "UI Zoom Out", SEQ_DEF_1(KEYCODE_MINUS) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PREV_GROUP, "UI Previous Group", SEQ_DEF_1(KEYCODE_OPENBRACE) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_NEXT_GROUP, "UI Next Group", SEQ_DEF_1(KEYCODE_CLOSEBRACE) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ROTATE, "UI Rotate", SEQ_DEF_1(KEYCODE_R) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SHOW_PROFILER, "Show Profiler", SEQ_DEF_2(KEYCODE_F11, KEYCODE_LSHIFT) ) +#ifdef MESS + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_UI, "UI Toggle", SEQ_DEF_3(KEYCODE_SCRLOCK, SEQCODE_NOT, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PASTE, "UI Paste Text", SEQ_DEF_2(KEYCODE_SCRLOCK, KEYCODE_LSHIFT) ) +#endif /* MESS */ + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_DEBUG, "Toggle Debugger", SEQ_DEF_1(KEYCODE_F5) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SAVE_STATE, "Save State", SEQ_DEF_2(KEYCODE_F7, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_LOAD_STATE, "Load State", SEQ_DEF_3(KEYCODE_F7, SEQCODE_NOT, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ADD_CHEAT, "Add Cheat", SEQ_DEF_1(KEYCODE_A) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DELETE_CHEAT, "Delete Cheat", SEQ_DEF_1(KEYCODE_D) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SAVE_CHEAT, "Save Cheat", SEQ_DEF_1(KEYCODE_S) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_WATCH_VALUE, "Watch Value", SEQ_DEF_1(KEYCODE_W) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_EDIT_CHEAT, "Edit Cheat", SEQ_DEF_1(KEYCODE_E) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RELOAD_CHEAT, "Reload Database", SEQ_DEF_1(KEYCODE_L) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_CROSSHAIR, "Toggle Crosshair", SEQ_DEF_1(KEYCODE_F1) ) + + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_1, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_2, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_3, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_4, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_5, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_6, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_7, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_8, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_9, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_10, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_11, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_12, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_13, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_14, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_15, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_16, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, UNKNOWN, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, UNUSED, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, SPECIAL, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, OTHER, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, ADJUSTER, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, DIPSWITCH, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, CONFIG, NULL, SEQ_DEF_0 ) + INPUT_PORT_DIGITAL_TYPE( 0, INVALID, CATEGORY, NULL, SEQ_DEF_0 ) +}; diff --git a/src/emu/inputseq.h b/src/emu/inputseq.h index f74b2c42279..e91b41cef85 100644 --- a/src/emu/inputseq.h +++ b/src/emu/inputseq.h @@ -174,4 +174,32 @@ INLINE int input_seq_cmp(const input_seq *seqa, const input_seq *seqb) return 0; } + +/*------------------------------------------------- + input_seq_append_or - append a code to a + sequence; if the sequence is non-empty, insert + an OR before the new code +-------------------------------------------------*/ + +INLINE void input_seq_append_or(input_seq *seq, input_code code) +{ + int codenum; + if (seq->code[0] == SEQCODE_END || seq->code[0] == SEQCODE_DEFAULT) + { + seq->code[0] = code; + seq->code[1] = SEQCODE_END; + } + else + { + for (codenum = 0; codenum < ARRAY_LENGTH(seq->code) - 2; codenum++) + if (seq->code[codenum] == SEQCODE_END) + { + seq->code[codenum++] = SEQCODE_OR; + seq->code[codenum++] = code; + seq->code[codenum++] = SEQCODE_END; + } + } +} + + #endif /* __INPUTSEQ_H__ */ diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c index c7a1e38b539..39c4479daeb 100644 --- a/src/emu/machine/generic.c +++ b/src/emu/machine/generic.c @@ -46,8 +46,8 @@ static UINT8 interrupt_enable[MAX_CPU]; FUNCTION PROTOTYPES ***************************************************************************/ -static void counters_load(int config_type, xml_data_node *parentnode); -static void counters_save(int config_type, xml_data_node *parentnode); +static void counters_load(running_machine *machine, int config_type, xml_data_node *parentnode); +static void counters_save(running_machine *machine, int config_type, xml_data_node *parentnode); static void interrupt_reset(running_machine *machine); @@ -93,7 +93,7 @@ void generic_machine_init(running_machine *machine) state_save_register_item_array("cpu", 0, interrupt_enable); /* register for configuration */ - config_register("counters", counters_load, counters_save); + config_register(machine, "counters", counters_load, counters_save); /* for memory cards, request save state and an exit callback */ if (machine->config->memcard_handler != NULL) @@ -114,7 +114,7 @@ void generic_machine_init(running_machine *machine) and tickets -------------------------------------------------*/ -static void counters_load(int config_type, xml_data_node *parentnode) +static void counters_load(running_machine *machine, int config_type, xml_data_node *parentnode) { xml_data_node *coinnode, *ticketnode; @@ -153,7 +153,7 @@ static void counters_load(int config_type, xml_data_node *parentnode) and tickets -------------------------------------------------*/ -static void counters_save(int config_type, xml_data_node *parentnode) +static void counters_save(running_machine *machine, int config_type, xml_data_node *parentnode) { int i; diff --git a/src/emu/mame.c b/src/emu/mame.c index 9aa9b8ceaa3..2732995256b 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -1467,9 +1467,7 @@ static void prepare_machine(running_machine *machine) machine->sample_rate = options_get_int(mame_options(), OPTION_SAMPLERATE); /* input-related information */ - machine->input_ports = NULL; - machine->record_file = NULL; - machine->playback_file = NULL; + machine->portconfig = NULL; /* debugger-related information */ #ifdef ENABLE_DEBUGGER @@ -1598,9 +1596,12 @@ static void init_machine(running_machine *machine) #endif /* call the driver's _START callbacks */ - if (machine->config->machine_start != NULL) (*machine->config->machine_start)(machine); - if (machine->config->sound_start != NULL) (*machine->config->sound_start)(machine); - if (machine->config->video_start != NULL) (*machine->config->video_start)(machine); + if (machine->config->machine_start != NULL) + (*machine->config->machine_start)(machine); + if (machine->config->sound_start != NULL) + (*machine->config->sound_start)(machine); + if (machine->config->video_start != NULL) + (*machine->config->video_start)(machine); /* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */ for (num = 0; num < MAX_MEMORY_REGIONS; num++) @@ -1895,7 +1896,6 @@ static void get_tm_time(struct tm *t, mame_system_tm *systm) } - /*------------------------------------------------- fill_systime - fills out a mame_system_time structure @@ -1909,7 +1909,6 @@ static void fill_systime(mame_system_time *systime, time_t t) } - /*------------------------------------------------- mame_get_base_datetime - retrieve the time of the host system; useful for RTC implementations @@ -1922,7 +1921,6 @@ void mame_get_base_datetime(running_machine *machine, mame_system_time *systime) } - /*------------------------------------------------- mame_get_current_datetime - retrieve the current time (offsetted by the baes); useful for RTC diff --git a/src/emu/mame.h b/src/emu/mame.h index 50042b87ad3..2190e54d065 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -17,6 +17,7 @@ #include "crsshair.h" #include "restrack.h" #include "options.h" +#include "inptport.h" #include <stdarg.h> #ifdef MESS @@ -166,15 +167,19 @@ typedef struct _mame_private mame_private; typedef struct _palette_private palette_private; typedef struct _streams_private streams_private; typedef struct _devices_private devices_private; +typedef struct _input_port_private input_port_private; /* description of the currently-running machine */ /* typedef struct _running_machine running_machine; -- in mamecore.h */ struct _running_machine { + /* configuration data */ + const machine_config * config; /* points to the constructed machine_config */ + const input_port_config *portconfig; /* points to a list of input port configurations */ + /* game-related information */ const game_driver * gamedrv; /* points to the definition of the game machine */ - const machine_config * config; /* points to the constructed machine_config */ const char * basename; /* basename used for game-related paths */ /* video-related information */ @@ -190,11 +195,6 @@ struct _running_machine /* audio-related information */ int sample_rate; /* the digital audio sample rate */ - /* input-related information */ - input_port_entry * input_ports; /* the input ports definition from the driver is copied here and modified */ - mame_file * record_file; /* recording file (NULL if not recording) */ - mame_file * playback_file; /* playback file (NULL if not recording) */ - /* debugger-related information */ int debug_mode; /* was debug mode enabled? */ @@ -203,6 +203,7 @@ struct _running_machine palette_private * palette_data; /* internal data from palette.c */ streams_private * streams_data; /* internal data from streams.c */ devices_private * devices_data; /* internal data from devices.c */ + input_port_private * input_port_data; /* internal data from inptport.c */ #ifdef MESS images_private * images_data; /* internal data from image.c */ #endif /* MESS */ diff --git a/src/emu/mamecore.h b/src/emu/mamecore.h index 8b68b46d6e9..5d3953edac4 100644 --- a/src/emu/mamecore.h +++ b/src/emu/mamecore.h @@ -66,8 +66,6 @@ typedef struct _machine_config machine_config; typedef struct _rom_load_data rom_load_data; typedef struct _osd_create_params osd_create_params; typedef struct _gfx_element gfx_element; -typedef struct _input_port_entry input_port_entry; -typedef struct _input_port_default_entry input_port_default_entry; typedef struct _mame_file mame_file; diff --git a/src/emu/memory.c b/src/emu/memory.c index c3d87bd1b25..62966a357ef 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -706,8 +706,6 @@ static void address_map_detokenize(address_map *map, const addrmap_token *tokens /* loop over tokens until we hit the end */ while (entrytype != ADDRMAP_TOKEN_END) { - const char *tag; - /* unpack the token from the first entry */ TOKEN_GET_UINT32_UNPACK1(tokens, entrytype, 8); switch (entrytype) @@ -785,16 +783,7 @@ static void address_map_detokenize(address_map *map, const addrmap_token *tokens break; case ADDRMAP_TOKEN_READ_PORT: - tag = TOKEN_GET_STRING(tokens); - switch (map->databits) - { - case 8: entry->read.mhandler8 = port_tag_to_handler8(tag); break; - case 16: entry->read.mhandler16 = port_tag_to_handler16(tag); break; - case 32: entry->read.mhandler32 = port_tag_to_handler32(tag); break; - case 64: entry->read.mhandler64 = port_tag_to_handler64(tag); break; - } - if (entry->read.generic == NULL) - fatalerror("Non-existent port referenced: '%s'\n", tag); + entry->read_porttag = TOKEN_GET_STRING(tokens); break; case ADDRMAP_TOKEN_REGION: @@ -1556,12 +1545,31 @@ static void memory_init_populate(running_machine *machine) while (last_entry != space->map->entrylist) { const address_map_entry *entry; + read_handler rhandler; + write_handler whandler; /* find the entry before the last one we processed */ for (entry = space->map->entrylist; entry->next != last_entry; entry = entry->next) ; last_entry = entry; + rhandler = entry->read; + whandler = entry->write; + + /* if we have a read port tag, look it up */ + if (entry->read_porttag != NULL) + { + switch (space->dbits) + { + case 8: rhandler.mhandler8 = input_port_read_handler8(machine->portconfig, entry->read_porttag); break; + case 16: rhandler.mhandler16 = input_port_read_handler16(machine->portconfig, entry->read_porttag); break; + case 32: rhandler.mhandler32 = input_port_read_handler32(machine->portconfig, entry->read_porttag); break; + case 64: rhandler.mhandler64 = input_port_read_handler64(machine->portconfig, entry->read_porttag); break; + } + if (rhandler.generic == NULL) + fatalerror("Non-existent port referenced: '%s'\n", entry->read_porttag); + } - if (entry->read.generic != NULL) + /* install the read handler if present */ + if (rhandler.generic != NULL) { int bits = (entry->read_bits == 0) ? space->dbits : entry->read_bits; void *object = machine; @@ -1571,9 +1579,11 @@ static void memory_init_populate(running_machine *machine) if (object == NULL) fatalerror("Unidentified object in memory map: type=%s tag=%s\n", devtype_name(entry->read_devtype), entry->read_devtag); } - space_map_range_private(space, ROW_READ, bits, entry->read_mask, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, entry->read.generic, object, entry->read_name); + space_map_range_private(space, ROW_READ, bits, entry->read_mask, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, rhandler.generic, object, entry->read_name); } - if (entry->write.generic != NULL) + + /* install the write handler if present */ + if (whandler.generic != NULL) { int bits = (entry->write_bits == 0) ? space->dbits : entry->write_bits; void *object = machine; @@ -1583,7 +1593,7 @@ static void memory_init_populate(running_machine *machine) if (object == NULL) fatalerror("Unidentified object in memory map: type=%s tag=%s\n", devtype_name(entry->write_devtype), entry->write_devtag); } - space_map_range_private(space, ROW_WRITE, bits, entry->write_mask, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, entry->write.generic, object, entry->write_name); + space_map_range_private(space, ROW_WRITE, bits, entry->write_mask, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, whandler.generic, object, entry->write_name); } } } diff --git a/src/emu/memory.h b/src/emu/memory.h index f4194b2769c..75c739ba39f 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -212,6 +212,7 @@ struct _address_map_entry const char * read_name; /* read handler callback name */ device_type read_devtype; /* read device type for device references */ const char * read_devtag; /* read tag for the relevant device */ + const char * read_porttag; /* tag for input port reading */ write_handler write; /* write handler callback */ UINT8 write_bits; /* bits for the write handler callback (0=default, 1=8, 2=16, 3=32) */ UINT8 write_mask; /* mask bits indicating which subunits to process */ diff --git a/src/emu/render.c b/src/emu/render.c index 8425e4892cf..75933a435fe 100644 --- a/src/emu/render.c +++ b/src/emu/render.c @@ -252,8 +252,8 @@ static const render_quad_texuv oriented_texcoords[8] = /* core system */ static void render_exit(running_machine *machine); -static void render_load(int config_type, xml_data_node *parentnode); -static void render_save(int config_type, xml_data_node *parentnode); +static void render_load(running_machine *machine, int config_type, xml_data_node *parentnode); +static void render_save(running_machine *machine, int config_type, xml_data_node *parentnode); /* render targets */ static void release_render_list(render_primitive_list *list); @@ -537,7 +537,7 @@ void render_init(running_machine *machine) *current_container_ptr = NULL; /* register callbacks */ - config_register("video", render_load, render_save); + config_register(machine, "video", render_load, render_save); } @@ -615,7 +615,7 @@ static void render_exit(running_machine *machine) configuration file -------------------------------------------------*/ -static void render_load(int config_type, xml_data_node *parentnode) +static void render_load(running_machine *machine, int config_type, xml_data_node *parentnode) { xml_data_node *targetnode; xml_data_node *screennode; @@ -733,7 +733,7 @@ static void render_load(int config_type, xml_data_node *parentnode) file -------------------------------------------------*/ -static void render_save(int config_type, xml_data_node *parentnode) +static void render_save(running_machine *machine, int config_type, xml_data_node *parentnode) { render_target *target; render_container *container; diff --git a/src/emu/sound.c b/src/emu/sound.c index d57a8d82bab..128efd84364 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -114,8 +114,8 @@ static wav_file *wavfile; static void sound_reset(running_machine *machine); static void sound_exit(running_machine *machine); static void sound_pause(running_machine *machine, int pause); -static void sound_load(int config_type, xml_data_node *parentnode); -static void sound_save(int config_type, xml_data_node *parentnode); +static void sound_load(running_machine *machine, int config_type, xml_data_node *parentnode); +static void sound_save(running_machine *machine, int config_type, xml_data_node *parentnode); static TIMER_CALLBACK( sound_update ); static void start_sound_chips(void); static void route_sound(void); @@ -223,7 +223,7 @@ void sound_init(running_machine *machine) sound_set_attenuation(options_get_int(mame_options(), OPTION_VOLUME)); /* register callbacks */ - config_register("mixer", sound_load, sound_save); + config_register(machine, "mixer", sound_load, sound_save); add_pause_callback(machine, sound_pause); add_reset_callback(machine, sound_reset); add_exit_callback(machine, sound_exit); @@ -577,7 +577,7 @@ void sound_global_enable(int enable) configuration file -------------------------------------------------*/ -static void sound_load(int config_type, xml_data_node *parentnode) +static void sound_load(running_machine *machine, int config_type, xml_data_node *parentnode) { xml_data_node *channelnode; int mixernum; @@ -610,7 +610,7 @@ static void sound_load(int config_type, xml_data_node *parentnode) file -------------------------------------------------*/ -static void sound_save(int config_type, xml_data_node *parentnode) +static void sound_save(running_machine *machine, int config_type, xml_data_node *parentnode) { int mixernum; diff --git a/src/emu/sound/disc_inp.c b/src/emu/sound/disc_inp.c index 5b4c8d2035b..48572b6aebe 100644 --- a/src/emu/sound/disc_inp.c +++ b/src/emu/sound/disc_inp.c @@ -22,7 +22,7 @@ struct dss_adjustment_context { - INT32 port; + const input_port_config *port; INT32 lastpval; INT32 pmin; double pscale; @@ -122,7 +122,7 @@ static void dss_adjustment_step(node_description *node) if (DSS_ADJUSTMENT__ENABLE) { struct dss_adjustment_context *context = node->context; - INT32 rawportval = input_port_read_indexed(Machine, context->port); + INT32 rawportval = input_port_read_direct(context->port); /* only recompute if the value changed from last time */ if (rawportval != context->lastpval) @@ -150,12 +150,12 @@ static void dss_adjustment_reset(node_description *node) if (node->custom) { - context->port = port_tag_to_index(node->custom); - if (context->port == -1) + context->port = input_port_by_tag(Machine->portconfig, node->custom); + if (context->port == NULL) fatalerror("DISCRETE_ADJUSTMENT_TAG - NODE_%d has invalid tag", node->node-NODE_00); } else - context->port = DSS_ADJUSTMENT__PORT; + context->port = input_port_by_index(Machine->portconfig, DSS_ADJUSTMENT__PORT); context->lastpval = 0x7fffffff; context->pmin = DSS_ADJUSTMENT__PMIN; diff --git a/src/emu/ui.c b/src/emu/ui.c index 901ee29e8fe..3724e21abd0 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -71,8 +71,8 @@ struct _slider_state INT32 defval; /* default value */ INT32 maxval; /* maximum value */ INT32 incval; /* increment value */ - INT32 (*update)(running_machine *machine, INT32 newval, char *buffer, int arg); /* callback */ - int arg; /* argument */ + INT32 (*update)(running_machine *machine, INT32 newval, char *buffer, void *arg); /* callback */ + void * arg; /* argument */ }; @@ -138,24 +138,24 @@ static UINT32 handler_load_save(running_machine *machine, UINT32 state); static void slider_init(running_machine *machine); static void slider_display(const char *text, int minval, int maxval, int defval, int curval); static void slider_draw_bar(float leftx, float topy, float width, float height, float percentage, float default_percentage); -static INT32 slider_volume(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_mixervol(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_adjuster(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_overclock(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_refresh(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_brightness(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_contrast(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_gamma(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_xscale(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_yscale(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_xoffset(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_yoffset(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_flicker(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_beam(running_machine *machine, INT32 newval, char *buffer, int arg); +static INT32 slider_volume(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_mixervol(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_adjuster(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_overclock(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_refresh(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_brightness(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_contrast(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_gamma(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_xscale(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_yscale(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_xoffset(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_yoffset(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_flicker(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_beam(running_machine *machine, INT32 newval, char *buffer, void *arg); static char *slider_get_screen_desc(const device_config *screen); #ifdef MAME_DEBUG -static INT32 slider_crossscale(running_machine *machine, INT32 newval, char *buffer, int arg); -static INT32 slider_crossoffset(running_machine *machine, INT32 newval, char *buffer, int arg); +static INT32 slider_crossscale(running_machine *machine, INT32 newval, char *buffer, void *arg); +static INT32 slider_crossoffset(running_machine *machine, INT32 newval, char *buffer, void *arg); #endif @@ -181,7 +181,7 @@ INLINE UINT32 ui_set_handler(UINT32 (*callback)(running_machine *, UINT32), UINT -------------------------------------------------*/ INLINE void slider_config(slider_state *state, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, - INT32 (*update)(running_machine *, INT32, char *, int), int arg) + INT32 (*update)(running_machine *, INT32, char *, void *), void *arg) { state->minval = minval; state->defval = defval; @@ -1166,15 +1166,15 @@ static UINT32 handler_messagebox_ok(running_machine *machine, UINT32 state) ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor); /* an 'O' or left joystick kicks us to the next state */ - if (state == 0 && (input_code_pressed_once(KEYCODE_O) || input_ui_pressed(IPT_UI_LEFT))) + if (state == 0 && (input_code_pressed_once(KEYCODE_O) || input_ui_pressed(machine, IPT_UI_LEFT))) state++; /* a 'K' or right joystick exits the state */ - else if (state == 1 && (input_code_pressed_once(KEYCODE_K) || input_ui_pressed(IPT_UI_RIGHT))) + else if (state == 1 && (input_code_pressed_once(KEYCODE_K) || input_ui_pressed(machine, IPT_UI_RIGHT))) state = UI_HANDLER_CANCEL; /* if the user cancels, exit out completely */ - else if (input_ui_pressed(IPT_UI_CANCEL)) + else if (input_ui_pressed(machine, IPT_UI_CANCEL)) { mame_schedule_exit(machine); state = UI_HANDLER_CANCEL; @@ -1196,7 +1196,7 @@ static UINT32 handler_messagebox_anykey(running_machine *machine, UINT32 state) ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor); /* if the user cancels, exit out completely */ - if (input_ui_pressed(IPT_UI_CANCEL)) + if (input_ui_pressed(machine, IPT_UI_CANCEL)) { mame_schedule_exit(machine); state = UI_HANDLER_CANCEL; @@ -1255,25 +1255,25 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state) #endif /* MESS */ /* if the user pressed ESC, stop the emulation */ - if (input_ui_pressed(IPT_UI_CANCEL)) + if (input_ui_pressed(machine, IPT_UI_CANCEL)) mame_schedule_exit(machine); /* turn on menus if requested */ - if (input_ui_pressed(IPT_UI_CONFIGURE)) + if (input_ui_pressed(machine, IPT_UI_CONFIGURE)) return ui_set_handler(ui_menu_ui_handler, 0); /* if the on-screen display isn't up and the user has toggled it, turn it on */ - if (!machine->debug_mode && input_ui_pressed(IPT_UI_ON_SCREEN_DISPLAY)) + if (!machine->debug_mode && input_ui_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY)) return ui_set_handler(handler_slider, 0); /* handle a reset request */ - if (input_ui_pressed(IPT_UI_RESET_MACHINE)) + if (input_ui_pressed(machine, IPT_UI_RESET_MACHINE)) mame_schedule_hard_reset(machine); - if (input_ui_pressed(IPT_UI_SOFT_RESET)) + if (input_ui_pressed(machine, IPT_UI_SOFT_RESET)) mame_schedule_soft_reset(machine); /* handle a request to display graphics/palette */ - if (input_ui_pressed(IPT_UI_SHOW_GFX)) + if (input_ui_pressed(machine, IPT_UI_SHOW_GFX)) { if (!is_paused) mame_pause(machine, TRUE); @@ -1281,25 +1281,25 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state) } /* handle a save state request */ - if (input_ui_pressed(IPT_UI_SAVE_STATE)) + if (input_ui_pressed(machine, IPT_UI_SAVE_STATE)) { mame_pause(machine, TRUE); return ui_set_handler(handler_load_save, LOADSAVE_SAVE); } /* handle a load state request */ - if (input_ui_pressed(IPT_UI_LOAD_STATE)) + if (input_ui_pressed(machine, IPT_UI_LOAD_STATE)) { mame_pause(machine, TRUE); return ui_set_handler(handler_load_save, LOADSAVE_LOAD); } /* handle a save snapshot request */ - if (input_ui_pressed(IPT_UI_SNAPSHOT)) + if (input_ui_pressed(machine, IPT_UI_SNAPSHOT)) video_save_active_screen_snapshots(machine); /* toggle pause */ - if (input_ui_pressed(IPT_UI_PAUSE)) + if (input_ui_pressed(machine, IPT_UI_PAUSE)) { /* with a shift key, it is single step */ if (is_paused && (input_code_pressed(KEYCODE_LSHIFT) || input_code_pressed(KEYCODE_RSHIFT))) @@ -1312,7 +1312,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state) } /* toggle movie recording */ - if (input_ui_pressed(IPT_UI_RECORD_MOVIE)) + if (input_ui_pressed(machine, IPT_UI_RECORD_MOVIE)) { if (!video_mng_is_movie_active(machine->primary_screen)) { @@ -1327,19 +1327,19 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state) } /* toggle profiler display */ - if (input_ui_pressed(IPT_UI_SHOW_PROFILER)) + if (input_ui_pressed(machine, IPT_UI_SHOW_PROFILER)) ui_set_show_profiler(!ui_get_show_profiler()); /* toggle FPS display */ - if (input_ui_pressed(IPT_UI_SHOW_FPS)) + if (input_ui_pressed(machine, IPT_UI_SHOW_FPS)) ui_set_show_fps(!ui_get_show_fps()); /* toggle crosshair display */ - if (input_ui_pressed(IPT_UI_TOGGLE_CROSSHAIR)) + if (input_ui_pressed(machine, IPT_UI_TOGGLE_CROSSHAIR)) crosshair_toggle(machine); /* increment frameskip? */ - if (input_ui_pressed(IPT_UI_FRAMESKIP_INC)) + if (input_ui_pressed(machine, IPT_UI_FRAMESKIP_INC)) { /* get the current value and increment it */ int newframeskip = video_get_frameskip() + 1; @@ -1352,7 +1352,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state) } /* decrement frameskip? */ - if (input_ui_pressed(IPT_UI_FRAMESKIP_DEC)) + if (input_ui_pressed(machine, IPT_UI_FRAMESKIP_DEC)) { /* get the current value and decrement it */ int newframeskip = video_get_frameskip() - 1; @@ -1365,11 +1365,11 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state) } /* toggle throttle? */ - if (input_ui_pressed(IPT_UI_THROTTLE)) + if (input_ui_pressed(machine, IPT_UI_THROTTLE)) video_set_throttle(!video_get_throttle()); /* check for fast forward */ - if (input_port_type_pressed(IPT_UI_FAST_FORWARD, 0)) + if (input_type_pressed(machine, IPT_UI_FAST_FORWARD, 0)) { video_set_fastforward(TRUE); ui_show_fps_temp(0.5); @@ -1379,7 +1379,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state) #ifdef MESS /* paste? */ - if (input_ui_pressed(IPT_UI_PASTE)) + if (input_ui_pressed(machine, IPT_UI_PASTE)) ui_paste(machine); #endif /* MESS */ @@ -1399,9 +1399,9 @@ static UINT32 handler_slider(running_machine *machine, UINT32 state) char textbuf[256]; /* left/right control the increment */ - if (input_ui_pressed_repeat(IPT_UI_LEFT,6)) + if (input_ui_pressed_repeat(machine, IPT_UI_LEFT,6)) increment = -cur->incval; - if (input_ui_pressed_repeat(IPT_UI_RIGHT,6)) + if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT,6)) increment = cur->incval; /* alt goes to 1, shift goes 10x smaller, control goes 10x larger */ @@ -1419,7 +1419,7 @@ static UINT32 handler_slider(running_machine *machine, UINT32 state) newval = (*cur->update)(machine, 0, NULL, cur->arg) + increment; /* select resets to the default value */ - if (input_ui_pressed(IPT_UI_SELECT)) + if (input_ui_pressed(machine, IPT_UI_SELECT)) newval = cur->defval; /* clamp within bounds */ @@ -1435,17 +1435,17 @@ static UINT32 handler_slider(running_machine *machine, UINT32 state) slider_display(textbuf, cur->minval, cur->maxval, cur->defval, newval); /* up/down select which slider to control */ - if (input_ui_pressed_repeat(IPT_UI_DOWN,6)) + if (input_ui_pressed_repeat(machine, IPT_UI_DOWN,6)) slider_current = (slider_current + 1) % slider_count; - if (input_ui_pressed_repeat(IPT_UI_UP,6)) + if (input_ui_pressed_repeat(machine, IPT_UI_UP,6)) slider_current = (slider_current + slider_count - 1) % slider_count; /* the slider toggle or ESC will cancel out of our display */ - if (input_ui_pressed(IPT_UI_ON_SCREEN_DISPLAY) || input_ui_pressed(IPT_UI_CANCEL)) + if (input_ui_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY) || input_ui_pressed(machine, IPT_UI_CANCEL)) return UI_HANDLER_CANCEL; /* the menu key will take us directly to the menu */ - if (input_ui_pressed(IPT_UI_CONFIGURE)) + if (input_ui_pressed(machine, IPT_UI_CONFIGURE)) return ui_set_handler(ui_menu_ui_handler, 0); return 0; @@ -1474,7 +1474,7 @@ static UINT32 handler_load_save(running_machine *machine, UINT32 state) ui_draw_message_window("Select position to load from"); /* check for cancel key */ - if (input_ui_pressed(IPT_UI_CANCEL)) + if (input_ui_pressed(machine, IPT_UI_CANCEL)) { /* display a popup indicating things were cancelled */ if (state == LOADSAVE_SAVE) @@ -1534,14 +1534,15 @@ static UINT32 handler_load_save(running_machine *machine, UINT32 state) static void slider_init(running_machine *machine) { int numscreens = video_screen_count(machine->config); + const input_port_config *port; + const input_field_config *field; const device_config *device; int numitems, item; - input_port_entry *in; slider_count = 0; /* add overall volume */ - slider_config(&slider_list[slider_count++], -32, 0, 0, 1, slider_volume, 0); + slider_config(&slider_list[slider_count++], -32, 0, 0, 1, slider_volume, NULL); /* add per-channel volume */ numitems = sound_get_user_gain_count(); @@ -1553,43 +1554,49 @@ static void slider_init(running_machine *machine) if (defval > 1000) maxval = 2 * defval; - slider_config(&slider_list[slider_count++], 0, defval, maxval, 20, slider_mixervol, item); + slider_config(&slider_list[slider_count++], 0, defval, maxval, 20, slider_mixervol, (void *)item); } /* add analog adjusters */ - for (in = machine->input_ports; in && in->type != IPT_END; in++) - if ((in->type & 0xff) == IPT_ADJUSTER) - slider_config(&slider_list[slider_count++], 0, in->default_value >> 8, 100, 1, slider_adjuster, in - machine->input_ports); + for (port = machine->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + if (field->type == IPT_ADJUSTER) + { + void *param = (void *)field; + slider_config(&slider_list[slider_count++], 0, field->defvalue, 100, 1, slider_adjuster, param); + } if (options_get_bool(mame_options(), OPTION_CHEAT)) { /* add CPU overclocking */ numitems = cpu_gettotalcpu(); for (item = 0; item < numitems; item++) - slider_config(&slider_list[slider_count++], 10, 1000, 2000, 1, slider_overclock, item); + slider_config(&slider_list[slider_count++], 10, 1000, 2000, 1, slider_overclock, (void *)item); /* add refresh rate tweaker */ - slider_config(&slider_list[slider_count++], -10000, 0, 10000, 1000, slider_refresh, 0); + slider_config(&slider_list[slider_count++], -10000, 0, 10000, 1000, slider_refresh, NULL); } for (item = 0; item < numscreens; item++) { - const screen_config *scrconfig = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, item)->inline_config; + const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, item); + const screen_config *scrconfig = screen->inline_config; int defxscale = floor(scrconfig->xscale * 1000.0f + 0.5f); int defyscale = floor(scrconfig->yscale * 1000.0f + 0.5f); int defxoffset = floor(scrconfig->xoffset * 1000.0f + 0.5f); int defyoffset = floor(scrconfig->yoffset * 1000.0f + 0.5f); + void *param = (void *)screen; /* add standard brightness/contrast/gamma controls per-screen */ - slider_config(&slider_list[slider_count++], 100, 1000, 2000, 10, slider_brightness, item); - slider_config(&slider_list[slider_count++], 100, 1000, 2000, 50, slider_contrast, item); - slider_config(&slider_list[slider_count++], 100, 1000, 3000, 50, slider_gamma, item); + slider_config(&slider_list[slider_count++], 100, 1000, 2000, 10, slider_brightness, param); + slider_config(&slider_list[slider_count++], 100, 1000, 2000, 50, slider_contrast, param); + slider_config(&slider_list[slider_count++], 100, 1000, 3000, 50, slider_gamma, param); /* add scale and offset controls per-screen */ - slider_config(&slider_list[slider_count++], 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_xscale, item); - slider_config(&slider_list[slider_count++], -500, defxoffset, 500, 2, slider_xoffset, item); - slider_config(&slider_list[slider_count++], 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_yscale, item); - slider_config(&slider_list[slider_count++], -500, defyoffset, 500, 2, slider_yoffset, item); + slider_config(&slider_list[slider_count++], 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_xscale, param); + slider_config(&slider_list[slider_count++], -500, defxoffset, 500, 2, slider_xoffset, param); + slider_config(&slider_list[slider_count++], 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_yscale, param); + slider_config(&slider_list[slider_count++], -500, defyoffset, 500, 2, slider_yoffset, param); } for (device = video_screen_first(machine->config); device != NULL; device = video_screen_next(device)) @@ -1598,20 +1605,21 @@ static void slider_init(running_machine *machine) if (scrconfig->type == SCREEN_TYPE_VECTOR) { /* add flicker control */ - slider_config(&slider_list[slider_count++], 0, 0, 1000, 10, slider_flicker, 0); - slider_config(&slider_list[slider_count++], 10, 100, 1000, 10, slider_beam, 0); + slider_config(&slider_list[slider_count++], 0, 0, 1000, 10, slider_flicker, NULL); + slider_config(&slider_list[slider_count++], 10, 100, 1000, 10, slider_beam, NULL); break; } } #ifdef MAME_DEBUG /* add crosshair adjusters */ - for (in = machine->input_ports; in && in->type != IPT_END; in++) - if (in->analog.crossaxis != CROSSHAIR_AXIS_NONE && in->player == 0) - { - slider_config(&slider_list[slider_count++], -3000, 1000, 3000, 100, slider_crossscale, in->analog.crossaxis); - slider_config(&slider_list[slider_count++], -3000, 0, 3000, 100, slider_crossoffset, in->analog.crossaxis); - } + for (port = machine->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + if (field->crossaxis != CROSSHAIR_AXIS_NONE && field->player == 0) + { + slider_config(&slider_list[slider_count++], -3000, 1000, 3000, 100, slider_crossscale, (void *)field); + slider_config(&slider_list[slider_count++], -3000, 0, 3000, 100, slider_crossoffset, (void *)field); + } #endif } @@ -1686,7 +1694,7 @@ static void slider_draw_bar(float leftx, float topy, float width, float height, slider_volume - global volume slider callback -------------------------------------------------*/ -static INT32 slider_volume(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_volume(running_machine *machine, INT32 newval, char *buffer, void *arg) { if (buffer != NULL) { @@ -1702,14 +1710,15 @@ static INT32 slider_volume(running_machine *machine, INT32 newval, char *buffer, slider callback -------------------------------------------------*/ -static INT32 slider_mixervol(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_mixervol(running_machine *machine, INT32 newval, char *buffer, void *arg) { + int which = (FPTR)arg; if (buffer != NULL) { - sound_set_user_gain(arg, (float)newval * 0.001f); - sprintf(buffer, "%s Volume %4.2f", sound_get_user_gain_name(arg), sound_get_user_gain(arg)); + sound_set_user_gain(which, (float)newval * 0.001f); + sprintf(buffer, "%s Volume %4.2f", sound_get_user_gain_name(which), sound_get_user_gain(which)); } - return floor(sound_get_user_gain(arg) * 1000.0f + 0.5f); + return floor(sound_get_user_gain(which) * 1000.0f + 0.5f); } @@ -1718,15 +1727,19 @@ static INT32 slider_mixervol(running_machine *machine, INT32 newval, char *buffe callback -------------------------------------------------*/ -static INT32 slider_adjuster(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_adjuster(running_machine *machine, INT32 newval, char *buffer, void *arg) { - input_port_entry *in = &machine->input_ports[arg]; + const input_field_config *field = arg; + input_field_user_settings settings; + + input_field_get_user_settings(field, &settings); if (buffer != NULL) { - in->default_value = (in->default_value & ~0xff) | (newval & 0xff); - sprintf(buffer, "%s %d%%", in->name, in->default_value & 0xff); + settings.value = newval; + input_field_set_user_settings(field, &settings); + sprintf(buffer, "%s %d%%", field->name, settings.value); } - return in->default_value & 0xff; + return settings.value; } @@ -1735,14 +1748,15 @@ static INT32 slider_adjuster(running_machine *machine, INT32 newval, char *buffe callback -------------------------------------------------*/ -static INT32 slider_overclock(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_overclock(running_machine *machine, INT32 newval, char *buffer, void *arg) { + int which = (FPTR)arg; if (buffer != NULL) { - cpunum_set_clockscale(machine, arg, (float)newval * 0.001f); - sprintf(buffer, "Overclock CPU %d %3.0f%%", arg, floor(cpunum_get_clockscale(arg) * 100.0f + 0.5f)); + cpunum_set_clockscale(machine, which, (float)newval * 0.001f); + sprintf(buffer, "Overclock CPU %d %3.0f%%", which, floor(cpunum_get_clockscale(which) * 100.0f + 0.5f)); } - return floor(cpunum_get_clockscale(arg) * 1000.0f + 0.5f); + return floor(cpunum_get_clockscale(which) * 1000.0f + 0.5f); } @@ -1750,15 +1764,15 @@ static INT32 slider_overclock(running_machine *machine, INT32 newval, char *buff slider_refresh - refresh rate slider callback -------------------------------------------------*/ -static INT32 slider_refresh(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_refresh(running_machine *machine, INT32 newval, char *buffer, void *arg) { - const screen_config *scrconfig = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg)->inline_config; + const device_config *screen = arg; + const screen_config *scrconfig = screen->inline_config; double defrefresh = ATTOSECONDS_TO_HZ(scrconfig->refresh); double refresh; if (buffer != NULL) { - const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg); int width = video_screen_get_width(screen); int height = video_screen_get_height(screen); const rectangle *visarea = video_screen_get_visible_area(screen); @@ -1776,9 +1790,9 @@ static INT32 slider_refresh(running_machine *machine, INT32 newval, char *buffer callback -------------------------------------------------*/ -static INT32 slider_brightness(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_brightness(running_machine *machine, INT32 newval, char *buffer, void *arg) { - const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg); + const device_config *screen = arg; render_container *container = render_container_get_screen(screen); if (buffer != NULL) { @@ -1794,9 +1808,9 @@ static INT32 slider_brightness(running_machine *machine, INT32 newval, char *buf callback -------------------------------------------------*/ -static INT32 slider_contrast(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_contrast(running_machine *machine, INT32 newval, char *buffer, void *arg) { - const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg); + const device_config *screen = arg; render_container *container = render_container_get_screen(screen); if (buffer != NULL) { @@ -1811,9 +1825,9 @@ static INT32 slider_contrast(running_machine *machine, INT32 newval, char *buffe slider_gamma - screen gamma slider callback -------------------------------------------------*/ -static INT32 slider_gamma(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_gamma(running_machine *machine, INT32 newval, char *buffer, void *arg) { - const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg); + const device_config *screen = arg; render_container *container = render_container_get_screen(screen); if (buffer != NULL) { @@ -1829,9 +1843,9 @@ static INT32 slider_gamma(running_machine *machine, INT32 newval, char *buffer, callback -------------------------------------------------*/ -static INT32 slider_xscale(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_xscale(running_machine *machine, INT32 newval, char *buffer, void *arg) { - const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg); + const device_config *screen = arg; render_container *container = render_container_get_screen(screen); if (buffer != NULL) { @@ -1847,9 +1861,9 @@ static INT32 slider_xscale(running_machine *machine, INT32 newval, char *buffer, callback -------------------------------------------------*/ -static INT32 slider_yscale(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_yscale(running_machine *machine, INT32 newval, char *buffer, void *arg) { - const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg); + const device_config *screen = arg; render_container *container = render_container_get_screen(screen); if (buffer != NULL) { @@ -1865,9 +1879,9 @@ static INT32 slider_yscale(running_machine *machine, INT32 newval, char *buffer, slider callback -------------------------------------------------*/ -static INT32 slider_xoffset(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_xoffset(running_machine *machine, INT32 newval, char *buffer, void *arg) { - const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg); + const device_config *screen = arg; render_container *container = render_container_get_screen(screen); if (buffer != NULL) { @@ -1883,9 +1897,9 @@ static INT32 slider_xoffset(running_machine *machine, INT32 newval, char *buffer slider callback -------------------------------------------------*/ -static INT32 slider_yoffset(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_yoffset(running_machine *machine, INT32 newval, char *buffer, void *arg) { - const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg); + const device_config *screen = arg; render_container *container = render_container_get_screen(screen); if (buffer != NULL) { @@ -1901,7 +1915,7 @@ static INT32 slider_yoffset(running_machine *machine, INT32 newval, char *buffer callback -------------------------------------------------*/ -static INT32 slider_flicker(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_flicker(running_machine *machine, INT32 newval, char *buffer, void *arg) { if (buffer != NULL) { @@ -1917,7 +1931,7 @@ static INT32 slider_flicker(running_machine *machine, INT32 newval, char *buffer callback -------------------------------------------------*/ -static INT32 slider_beam(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_beam(running_machine *machine, INT32 newval, char *buffer, void *arg) { if (buffer != NULL) { @@ -1953,24 +1967,16 @@ static char *slider_get_screen_desc(const device_config *screen) -------------------------------------------------*/ #ifdef MAME_DEBUG -static INT32 slider_crossscale(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_crossscale(running_machine *machine, INT32 newval, char *buffer, void *arg) { - input_port_entry *in; + input_field_config *field = arg; if (buffer != NULL) { - for (in = machine->input_ports; in && in->type != IPT_END; in++) - if (in->analog.crossaxis == arg) - { - in->analog.crossscale = (float)newval * 0.001f; - break; - } - sprintf(buffer, "%s %s %1.3f", "Crosshair Scale", (in->analog.crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f); + field->crossscale = (float)newval * 0.001f; + sprintf(buffer, "%s %s %1.3f", "Crosshair Scale", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f); } - for (in = machine->input_ports; in && in->type != IPT_END; in++) - if (in->analog.crossaxis == arg) - return floor(in->analog.crossscale * 1000.0f + 0.5f); - return 0; + return floor(field->crossscale * 1000.0f + 0.5f); } #endif @@ -1981,23 +1987,15 @@ static INT32 slider_crossscale(running_machine *machine, INT32 newval, char *buf -------------------------------------------------*/ #ifdef MAME_DEBUG -static INT32 slider_crossoffset(running_machine *machine, INT32 newval, char *buffer, int arg) +static INT32 slider_crossoffset(running_machine *machine, INT32 newval, char *buffer, void *arg) { - input_port_entry *in; + input_field_config *field = arg; if (buffer != NULL) { - for (in = machine->input_ports; in && in->type != IPT_END; in++) - if (in->analog.crossaxis == arg) - { - in->analog.crossoffset = (float)newval * 0.001f; - break; - } - sprintf(buffer, "%s %s %1.3f", "Crosshair Offset", (in->analog.crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f); + field->crossoffset = (float)newval * 0.001f; + sprintf(buffer, "%s %s %1.3f", "Crosshair Offset", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f); } - for (in = machine->input_ports; in && in->type != IPT_END; in++) - if (in->analog.crossaxis == arg) - return floor(in->analog.crossoffset * 1000.0f + 0.5f); - return 0; + return field->crossoffset; } #endif diff --git a/src/emu/uigfx.c b/src/emu/uigfx.c index 68becf050ec..ce165fcb95c 100644 --- a/src/emu/uigfx.c +++ b/src/emu/uigfx.c @@ -78,19 +78,19 @@ static ui_gfx_state ui_gfx; static void ui_gfx_exit(running_machine *machine); /* palette handling */ -static void palette_handle_keys(ui_gfx_state *state); -static void palette_handler(ui_gfx_state *state); +static void palette_handle_keys(running_machine *machine, ui_gfx_state *state); +static void palette_handler(running_machine *machine, ui_gfx_state *state); /* graphics set handling */ -static void gfxset_handle_keys(ui_gfx_state *state, int xcells, int ycells); +static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, int xcells, int ycells); static void gfxset_draw_item(const gfx_element *gfx, int index, bitmap_t *bitmap, int dstx, int dsty, int color, int rotate); static void gfxset_update_bitmap(ui_gfx_state *state, int xcells, int ycells, gfx_element *gfx); -static void gfxset_handler(ui_gfx_state *state); +static void gfxset_handler(running_machine *machine, ui_gfx_state *state); /* tilemap handling */ -static void tilemap_handle_keys(ui_gfx_state *state, int viswidth, int visheight); +static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, int viswidth, int visheight); static void tilemap_update_bitmap(ui_gfx_state *state, int width, int height); -static void tilemap_handler(ui_gfx_state *state); +static void tilemap_handler(running_machine *machine, ui_gfx_state *state); @@ -170,7 +170,7 @@ again: /* if we have a palette, display it */ if (machine->config->total_colors > 0) { - palette_handler(state); + palette_handler(machine, state); break; } @@ -181,7 +181,7 @@ again: /* if we have graphics sets, display them */ if (machine->gfx[0] != NULL) { - gfxset_handler(state); + gfxset_handler(machine, state); break; } @@ -192,7 +192,7 @@ again: /* if we have tilemaps, display them */ if (tilemap_count() > 0) { - tilemap_handler(state); + tilemap_handler(machine, state); break; } @@ -201,16 +201,16 @@ again: } /* handle keys */ - if (input_ui_pressed(IPT_UI_SELECT)) + if (input_ui_pressed(machine, IPT_UI_SELECT)) { state->mode = (state->mode + 1) % 3; state->bitmap_dirty = TRUE; } - if (input_ui_pressed(IPT_UI_PAUSE)) + if (input_ui_pressed(machine, IPT_UI_PAUSE)) mame_pause(machine, !mame_is_paused(machine)); - if (input_ui_pressed(IPT_UI_CANCEL) || input_ui_pressed(IPT_UI_SHOW_GFX)) + if (input_ui_pressed(machine, IPT_UI_CANCEL) || input_ui_pressed(machine, IPT_UI_SHOW_GFX)) goto cancel; return uistate; @@ -233,7 +233,7 @@ cancel: viewer -------------------------------------------------*/ -static void palette_handler(ui_gfx_state *state) +static void palette_handler(running_machine *machine, ui_gfx_state *state) { int total = state->palette.which ? colortable_palette_get_size(Machine->colortable) : Machine->config->total_colors; const char *title = state->palette.which ? "COLORTABLE" : "PALETTE"; @@ -344,7 +344,7 @@ static void palette_handler(ui_gfx_state *state) } /* handle keys */ - palette_handle_keys(state); + palette_handle_keys(machine, state); } @@ -353,15 +353,15 @@ static void palette_handler(ui_gfx_state *state) palette viewer -------------------------------------------------*/ -static void palette_handle_keys(ui_gfx_state *state) +static void palette_handle_keys(running_machine *machine, ui_gfx_state *state) { int rowcount, screencount; int total; /* handle zoom (minus,plus) */ - if (input_ui_pressed(IPT_UI_ZOOM_OUT)) + if (input_ui_pressed(machine, IPT_UI_ZOOM_OUT)) state->palette.count /= 2; - if (input_ui_pressed(IPT_UI_ZOOM_IN)) + if (input_ui_pressed(machine, IPT_UI_ZOOM_IN)) state->palette.count *= 2; /* clamp within range */ @@ -371,9 +371,9 @@ static void palette_handle_keys(ui_gfx_state *state) state->palette.count = 64; /* handle colormap selection (open bracket,close bracket) */ - if (input_ui_pressed(IPT_UI_PREV_GROUP)) + if (input_ui_pressed(machine, IPT_UI_PREV_GROUP)) state->palette.which--; - if (input_ui_pressed(IPT_UI_NEXT_GROUP)) + if (input_ui_pressed(machine, IPT_UI_NEXT_GROUP)) state->palette.which++; /* clamp within range */ @@ -390,17 +390,17 @@ static void palette_handle_keys(ui_gfx_state *state) screencount = rowcount * rowcount; /* handle keyboard navigation */ - if (input_ui_pressed_repeat(IPT_UI_UP, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_UP, 4)) state->palette.offset -= rowcount; - if (input_ui_pressed_repeat(IPT_UI_DOWN, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 4)) state->palette.offset += rowcount; - if (input_ui_pressed_repeat(IPT_UI_PAGE_UP, 6)) + if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_UP, 6)) state->palette.offset -= screencount; - if (input_ui_pressed_repeat(IPT_UI_PAGE_DOWN, 6)) + if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6)) state->palette.offset += screencount; - if (input_ui_pressed_repeat(IPT_UI_HOME, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_HOME, 4)) state->palette.offset = 0; - if (input_ui_pressed_repeat(IPT_UI_END, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_END, 4)) state->palette.offset = total; /* clamp within range */ @@ -421,7 +421,7 @@ static void palette_handle_keys(ui_gfx_state *state) viewer -------------------------------------------------*/ -static void gfxset_handler(ui_gfx_state *state) +static void gfxset_handler(running_machine *machine, ui_gfx_state *state) { render_font *ui_font = ui_get_font(); int set = state->gfxset.set; @@ -578,23 +578,23 @@ static void gfxset_handler(ui_gfx_state *state) ARGB_WHITE, state->texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); /* handle keyboard navigation before drawing */ - gfxset_handle_keys(state, xcells, ycells); + gfxset_handle_keys(machine, state, xcells, ycells); } /*------------------------------------------------- - gfxset_handler - handle keys for the graphics - viewer + gfxset_handle_keys - handle keys for the + graphics viewer -------------------------------------------------*/ -static void gfxset_handle_keys(ui_gfx_state *state, int xcells, int ycells) +static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, int xcells, int ycells) { ui_gfx_state oldstate = *state; gfx_element *gfx; int temp, set; /* handle gfxset selection (open bracket,close bracket) */ - if (input_ui_pressed(IPT_UI_PREV_GROUP)) + if (input_ui_pressed(machine, IPT_UI_PREV_GROUP)) { for (temp = state->gfxset.set - 1; temp >= 0; temp--) if (Machine->gfx[temp] != NULL) @@ -602,7 +602,7 @@ static void gfxset_handle_keys(ui_gfx_state *state, int xcells, int ycells) if (temp >= 0) state->gfxset.set = temp; } - if (input_ui_pressed(IPT_UI_NEXT_GROUP)) + if (input_ui_pressed(machine, IPT_UI_NEXT_GROUP)) { for (temp = state->gfxset.set + 1; temp < MAX_GFX_ELEMENTS; temp++) if (Machine->gfx[temp] != NULL) @@ -616,9 +616,9 @@ static void gfxset_handle_keys(ui_gfx_state *state, int xcells, int ycells) gfx = Machine->gfx[set]; /* handle cells per line (minus,plus) */ - if (input_ui_pressed(IPT_UI_ZOOM_OUT)) + if (input_ui_pressed(machine, IPT_UI_ZOOM_OUT)) state->gfxset.count[set] = xcells - 1; - if (input_ui_pressed(IPT_UI_ZOOM_IN)) + if (input_ui_pressed(machine, IPT_UI_ZOOM_IN)) state->gfxset.count[set] = xcells + 1; /* clamp within range */ @@ -628,21 +628,21 @@ static void gfxset_handle_keys(ui_gfx_state *state, int xcells, int ycells) state->gfxset.count[set] = 32; /* handle rotation (R) */ - if (input_ui_pressed(IPT_UI_ROTATE)) + if (input_ui_pressed(machine, IPT_UI_ROTATE)) state->gfxset.rotate[set] = orientation_add(ROT90, state->gfxset.rotate[set]); /* handle navigation within the cells (up,down,pgup,pgdown) */ - if (input_ui_pressed_repeat(IPT_UI_UP, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_UP, 4)) state->gfxset.offset[set] -= xcells; - if (input_ui_pressed_repeat(IPT_UI_DOWN, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 4)) state->gfxset.offset[set] += xcells; - if (input_ui_pressed_repeat(IPT_UI_PAGE_UP, 6)) + if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_UP, 6)) state->gfxset.offset[set] -= xcells * ycells; - if (input_ui_pressed_repeat(IPT_UI_PAGE_DOWN, 6)) + if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6)) state->gfxset.offset[set] += xcells * ycells; - if (input_ui_pressed_repeat(IPT_UI_HOME, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_HOME, 4)) state->gfxset.offset[set] = 0; - if (input_ui_pressed_repeat(IPT_UI_END, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_END, 4)) state->gfxset.offset[set] = gfx->total_elements; /* clamp within range */ @@ -652,9 +652,9 @@ static void gfxset_handle_keys(ui_gfx_state *state, int xcells, int ycells) state->gfxset.offset[set] = 0; /* handle color selection (left,right) */ - if (input_ui_pressed_repeat(IPT_UI_LEFT, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_LEFT, 4)) state->gfxset.color[set] -= 1; - if (input_ui_pressed_repeat(IPT_UI_RIGHT, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT, 4)) state->gfxset.color[set] += 1; /* clamp within range */ @@ -838,7 +838,7 @@ static void gfxset_draw_item(const gfx_element *gfx, int index, bitmap_t *bitmap viewer -------------------------------------------------*/ -static void tilemap_handler(ui_gfx_state *state) +static void tilemap_handler(running_machine *machine, ui_gfx_state *state) { render_font *ui_font = ui_get_font(); float chwidth, chheight; @@ -939,7 +939,7 @@ static void tilemap_handler(ui_gfx_state *state) PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(state->tilemap.rotate)); /* handle keyboard input */ - tilemap_handle_keys(state, mapboxwidth, mapboxheight); + tilemap_handle_keys(machine, state, mapboxwidth, mapboxheight); } @@ -948,16 +948,16 @@ static void tilemap_handler(ui_gfx_state *state) tilemap view -------------------------------------------------*/ -static void tilemap_handle_keys(ui_gfx_state *state, int viswidth, int visheight) +static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, int viswidth, int visheight) { ui_gfx_state oldstate = *state; UINT32 mapwidth, mapheight; int step; /* handle tilemap selection (open bracket,close bracket) */ - if (input_ui_pressed(IPT_UI_PREV_GROUP)) + if (input_ui_pressed(machine, IPT_UI_PREV_GROUP)) state->tilemap.which--; - if (input_ui_pressed(IPT_UI_NEXT_GROUP)) + if (input_ui_pressed(machine, IPT_UI_NEXT_GROUP)) state->tilemap.which++; /* clamp within range */ @@ -970,9 +970,9 @@ static void tilemap_handle_keys(ui_gfx_state *state, int viswidth, int visheight tilemap_size_by_index(state->tilemap.which, &mapwidth, &mapheight); /* handle zoom (minus,plus) */ - if (input_ui_pressed(IPT_UI_ZOOM_OUT)) + if (input_ui_pressed(machine, IPT_UI_ZOOM_OUT)) state->tilemap.zoom--; - if (input_ui_pressed(IPT_UI_ZOOM_IN)) + if (input_ui_pressed(machine, IPT_UI_ZOOM_IN)) state->tilemap.zoom++; /* clamp within range */ @@ -989,20 +989,20 @@ static void tilemap_handle_keys(ui_gfx_state *state, int viswidth, int visheight } /* handle rotation (R) */ - if (input_ui_pressed(IPT_UI_ROTATE)) + if (input_ui_pressed(machine, IPT_UI_ROTATE)) state->tilemap.rotate = orientation_add(ROT90, state->tilemap.rotate); /* handle navigation (up,down,left,right) */ step = 8; if (input_code_pressed(KEYCODE_LSHIFT)) step = 1; if (input_code_pressed(KEYCODE_LCONTROL)) step = 64; - if (input_ui_pressed_repeat(IPT_UI_UP, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_UP, 4)) state->tilemap.yoffs -= step; - if (input_ui_pressed_repeat(IPT_UI_DOWN, 4)) + if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 4)) state->tilemap.yoffs += step; - if (input_ui_pressed_repeat(IPT_UI_LEFT, 6)) + if (input_ui_pressed_repeat(machine, IPT_UI_LEFT, 6)) state->tilemap.xoffs -= step; - if (input_ui_pressed_repeat(IPT_UI_RIGHT, 6)) + if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT, 6)) state->tilemap.xoffs += step; /* clamp within range */ diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c index 94d5ed5ef27..9e964f0f484 100644 --- a/src/emu/uimenu.c +++ b/src/emu/uimenu.c @@ -39,6 +39,8 @@ #define VISIBLE_GAMES_IN_LIST 15 #define MAX_PHYSICAL_DIPS 10 +#define MAX_INPUT_PORTS 32 +#define MAX_BITS_PER_PORT 32 /* DIP switch rendering parameters */ #define DIP_SWITCH_HEIGHT 0.05f @@ -84,13 +86,16 @@ struct _menu_state typedef struct _input_item_data input_item_data; struct _input_item_data { - input_seq * seq; /* pointer to the sequence we are operating on */ - const input_seq *defseq; /* pointer to the sequence we are operating on */ + const input_type_desc *typedesc; /* reference to type description for global inputs */ + const input_field_config *field; /* reference to field for game inputs */ + int seqtype; /* sequence type */ + input_seq seq; /* copy of the live sequence */ + const input_seq *defseq; /* pointer to the default sequence */ const char * name; const char * seqname; - UINT16 sortorder; /* sorting information */ - UINT8 type; /* type of port */ - UINT8 invert; /* type of port */ + UINT16 sortorder; /* sorting information */ + UINT8 type; /* type of port */ + UINT8 invert; /* type of port */ }; @@ -152,42 +157,41 @@ static const rgb_t sel_bgcolor = MAKE_ARGB(0xe0,0x80,0x80,0x00); static void ui_menu_exit(running_machine *machine); /* menu handlers */ -static UINT32 menu_main(UINT32 state); -static UINT32 menu_input_groups(UINT32 state); -static UINT32 menu_input(UINT32 state); -static UINT32 menu_switches(UINT32 state); -static UINT32 menu_analog(UINT32 state); +static UINT32 menu_main(running_machine *machine, UINT32 state); +static UINT32 menu_input_groups(running_machine *machine, UINT32 state); +static UINT32 menu_input(running_machine *machine, UINT32 state); +static UINT32 menu_switches(running_machine *machine, UINT32 state); +static UINT32 menu_analog(running_machine *machine, UINT32 state); #ifndef MESS -static UINT32 menu_bookkeeping(UINT32 state); +static UINT32 menu_bookkeeping(running_machine *machine, UINT32 state); #endif -static UINT32 menu_game_info(UINT32 state); -static UINT32 menu_cheat(UINT32 state); -static UINT32 menu_memory_card(UINT32 state); -static UINT32 menu_video(UINT32 state); -static UINT32 menu_quit_game(UINT32 state); -static UINT32 menu_select_game(UINT32 state); +static UINT32 menu_game_info(running_machine *machine, UINT32 state); +static UINT32 menu_cheat(running_machine *machine, UINT32 state); +static UINT32 menu_memory_card(running_machine *machine, UINT32 state); +static UINT32 menu_video(running_machine *machine, UINT32 state); +static UINT32 menu_quit_game(running_machine *machine, UINT32 state); +static UINT32 menu_select_game(running_machine *machine, UINT32 state); #ifdef MESS -static UINT32 menu_file_manager(UINT32 state); +static UINT32 menu_file_manager(running_machine *machine, UINT32 state); #if HAS_WAVE -static UINT32 menu_tape_control(UINT32 state); +static UINT32 menu_tape_control(running_machine *machine, UINT32 state); #endif /* HAS_WAVE */ #endif /* MESS */ /* menu helpers */ static void menu_render_triangle(bitmap_t *dest, const bitmap_t *source, const rectangle *sbounds, void *param); -static int input_menu_get_items(input_item_data *itemlist, int group); -static int input_menu_get_game_items(input_item_data *itemlist); +static int input_menu_get_items(running_machine *machine, input_item_data *itemlist, int group); +static int input_menu_get_game_items(running_machine *machine, input_item_data *itemlist); static void input_menu_toggle_none_default(input_seq *selected_seq, input_seq *original_seq, const input_seq *selected_defseq); static int input_menu_compare_items(const void *i1, const void *i2); -static void switches_menu_add_item(ui_menu_item *item, const input_port_entry *in, int switch_entry, void *ref); -static void switches_menu_select_previous(input_port_entry *in, int switch_entry); -static void switches_menu_select_next(input_port_entry *in, int switch_entry); -//static int switches_menu_compare_items(const void *i1, const void *i2); -static void analog_menu_add_item(ui_menu_item *item, const input_port_entry *in, const char *append_string, int which_item); +static void switches_menu_add_item(ui_menu_item *item, const input_field_config *field); +static void switches_menu_select_previous(const input_field_config *field); +static void switches_menu_select_next(const input_field_config *field); +static void analog_menu_add_item(ui_menu_item *item, const input_field_config *field, const char *append_string, int which_item); /* DIP switch helpers */ -static void dip_switch_build_model(input_port_entry *entry, int item_is_selected); +static void dip_switch_build_model(const input_field_config *field, int item_is_selected); static void dip_switch_draw_one(float dip_menu_x1, float dip_menu_y1, float dip_menu_x2, float dip_menu_y2, int model_index); static void dip_switch_render(const menu_extra *extra, float x1, float y1, float x2, float y2); @@ -591,25 +595,25 @@ static void ui_menu_draw_text_box(const char *text) keys for a menu -------------------------------------------------*/ -int ui_menu_generic_keys(UINT32 *selected, int num_items, int visible_items) +int ui_menu_generic_keys(running_machine *machine, UINT32 *selected, int num_items, int visible_items) { /* hitting cancel or selecting the last item returns to the previous menu */ - if (input_ui_pressed(IPT_UI_CANCEL) || (*selected == num_items - 1 && input_ui_pressed(IPT_UI_SELECT))) + if (input_ui_pressed(machine, IPT_UI_CANCEL) || (*selected == num_items - 1 && input_ui_pressed(machine, IPT_UI_SELECT))) { *selected = ui_menu_stack_pop(); return 1; } /* up backs up by one item */ - if (input_ui_pressed_repeat(IPT_UI_UP, 6)) + if (input_ui_pressed_repeat(machine, IPT_UI_UP, 6)) *selected = (*selected + num_items - 1) % num_items; /* down advances by one item */ - if (input_ui_pressed_repeat(IPT_UI_DOWN, 6)) + if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 6)) *selected = (*selected + 1) % num_items; /* page up backs up by visible_items */ - if (input_ui_pressed_repeat(IPT_UI_PAGE_UP, 6)) + if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_UP, 6)) { if (*selected >= visible_items - 1) *selected -= visible_items - 1; @@ -618,7 +622,7 @@ int ui_menu_generic_keys(UINT32 *selected, int num_items, int visible_items) } /* page down advances by visible_items */ - if (input_ui_pressed_repeat(IPT_UI_PAGE_DOWN, 6)) + if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6)) { *selected += visible_items - 1; if (*selected >= num_items) @@ -626,15 +630,15 @@ int ui_menu_generic_keys(UINT32 *selected, int num_items, int visible_items) } /* home goes to the start */ - if (input_ui_pressed(IPT_UI_HOME)) + if (input_ui_pressed(machine, IPT_UI_HOME)) *selected = 0; /* end goes to the last */ - if (input_ui_pressed(IPT_UI_END)) + if (input_ui_pressed(machine, IPT_UI_END)) *selected = num_items - 1; /* pause enables/disables pause */ - if (input_ui_pressed(IPT_UI_PAUSE)) + if (input_ui_pressed(machine, IPT_UI_PAUSE)) mame_pause(Machine, !mame_is_paused(Machine)); return 0; @@ -694,11 +698,11 @@ UINT32 ui_menu_ui_handler(running_machine *machine, UINT32 state) ui_menu_stack_push(menu_main, 0); /* update the menu state */ - newstate = (*menu_stack[menu_stack_index].handler)(menu_stack[menu_stack_index].state); + newstate = (*menu_stack[menu_stack_index].handler)(machine, menu_stack[menu_stack_index].state); menu_stack[menu_stack_index].state = newstate; /* if the menus are to be hidden, return a cancel here */ - if ((input_ui_pressed(IPT_UI_CONFIGURE) && !ui_menu_is_force_game_select()) || menu_stack[menu_stack_index].handler == NULL) + if ((input_ui_pressed(machine, IPT_UI_CONFIGURE) && !ui_menu_is_force_game_select()) || menu_stack[menu_stack_index].handler == NULL) return UI_HANDLER_CANCEL; return 0; @@ -752,7 +756,7 @@ int ui_menu_is_force_game_select(void) menu_main - main UI menu -------------------------------------------------*/ -static UINT32 menu_main(UINT32 state) +static UINT32 menu_main(running_machine *machine, UINT32 state) { #define ADD_MENU(name, _handler, _param) \ do { \ @@ -762,28 +766,29 @@ do { \ menu_items++; \ } while (0) + const input_port_config *port; + const input_field_config *field; menu_state handler_list[20]; ui_menu_item item_list[20]; int has_categories = FALSE; int has_configs = FALSE; int has_analog = FALSE; int has_dips = FALSE; - input_port_entry *in; int menu_items = 0; int visible_items; /* scan the input port array to see what options we need to enable */ - for (in = Machine->input_ports; in->type != IPT_END; in++) - if (input_port_active(in)) + for (port = machine->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) { - if (in->type == IPT_DIPSWITCH_NAME) + if (field->type == IPT_DIPSWITCH) has_dips = TRUE; - if (port_type_is_analog(in->type)) - has_analog = TRUE; - if (in->type == IPT_CONFIG_NAME) + if (field->type == IPT_CONFIG) has_configs = TRUE; - if (in->category > 0) + if (field->category > 0) has_categories = TRUE; + if (input_type_is_analog(field->type)) + has_analog = TRUE; } /* reset the menu */ @@ -795,12 +800,12 @@ do { \ /* add optional input-related menus */ if (has_dips) - ADD_MENU("Dip Switches", menu_switches, (IPT_DIPSWITCH_NAME << 16) | (IPT_DIPSWITCH_SETTING << 24)); + ADD_MENU("Dip Switches", menu_switches, IPT_DIPSWITCH << 16); if (has_configs) - ADD_MENU("Driver Configuration", menu_switches, (IPT_CONFIG_NAME << 16) | (IPT_CONFIG_SETTING << 24)); + ADD_MENU("Driver Configuration", menu_switches, IPT_CONFIG << 16); #ifdef MESS if (has_categories) - ADD_MENU("Categories", menu_switches, (IPT_CATEGORY_NAME << 16) | (IPT_CATEGORY_SETTING << 24)); + ADD_MENU("Categories", menu_switches, IPT_CATEGORY << 16); #endif if (has_analog) ADD_MENU("Analog Controls", menu_analog, 0); @@ -822,7 +827,7 @@ do { \ #if HAS_WAVE /* add tape control menu */ - if (device_find_from_machine(Machine, IO_CASSETTE)) + if (device_find_from_machine(machine, IO_CASSETTE)) ADD_MENU("Tape Control", menu_tape_control, 1); #endif /* HAS_WAVE */ #endif /* MESS */ @@ -835,7 +840,7 @@ do { \ ADD_MENU("Cheat", menu_cheat, 1); /* add memory card menu */ - if (Machine->config->memcard_handler != NULL) + if (machine->config->memcard_handler != NULL) ADD_MENU("Memory Card", menu_memory_card, 0); /* add reset and exit menus */ @@ -846,9 +851,9 @@ do { \ visible_items = ui_menu_draw(item_list, menu_items, state, NULL); /* handle the keys */ - if (ui_menu_generic_keys(&state, menu_items, visible_items)) + if (ui_menu_generic_keys(machine, &state, menu_items, visible_items)) return state; - if (input_ui_pressed(IPT_UI_SELECT)) + if (input_ui_pressed(machine, IPT_UI_SELECT)) return ui_menu_stack_push(handler_list[state].handler, handler_list[state].state); return state; @@ -862,7 +867,7 @@ do { \ groups -------------------------------------------------*/ -static UINT32 menu_input_groups(UINT32 state) +static UINT32 menu_input_groups(running_machine *machine, UINT32 state) { ui_menu_item item_list[IPG_TOTAL_GROUPS + 2]; int menu_items = 0; @@ -885,9 +890,9 @@ static UINT32 menu_input_groups(UINT32 state) visible_items = ui_menu_draw(item_list, menu_items, state, NULL); /* handle the keys */ - if (ui_menu_generic_keys(&state, menu_items, visible_items)) + if (ui_menu_generic_keys(machine, &state, menu_items, visible_items)) return state; - if (input_ui_pressed(IPT_UI_SELECT)) + if (input_ui_pressed(machine, IPT_UI_SELECT)) return ui_menu_stack_push(menu_input, state << 16); return state; @@ -898,7 +903,7 @@ static UINT32 menu_input_groups(UINT32 state) menu_input - display a menu for inputs -------------------------------------------------*/ -static UINT32 menu_input(UINT32 state) +static UINT32 menu_input(running_machine *machine, UINT32 state) { ui_menu_item item_list[MAX_INPUT_PORTS * MAX_BITS_PER_PORT / 2]; input_item_data item_data[MAX_INPUT_PORTS * MAX_BITS_PER_PORT / 2]; @@ -907,13 +912,19 @@ static UINT32 menu_input(UINT32 state) int record_next = (state >> 14) & 1; int polling = (state >> 15) & 1; int group = state >> 16; + int changed = FALSE; int visible_items; int menu_items; int item; /* get the list of items */ menu_string_pool_offset = 0; - menu_items = input_menu_get_items(item_data, group); + + /* an out of range group is special; it just means the game-specific inputs */ + if (group > IPG_TOTAL_GROUPS) + menu_items = input_menu_get_game_items(machine, item_data); + else + menu_items = input_menu_get_items(machine, item_data, group); /* build the menu */ memset(item_list, 0, sizeof(item_list)); @@ -954,10 +965,11 @@ static UINT32 menu_input(UINT32 state) input_seq newseq; /* if UI_CANCEL is pressed, abort */ - if (input_ui_pressed(IPT_UI_CANCEL)) + if (input_ui_pressed(machine, IPT_UI_CANCEL)) { record_next = polling = FALSE; - input_menu_toggle_none_default(selected_item_data->seq, &starting_seq, selected_item_data->defseq); + input_menu_toggle_none_default(&selected_item_data->seq, &starting_seq, selected_item_data->defseq); + changed = TRUE; } /* poll again; if finished, update the sequence */ @@ -965,7 +977,8 @@ static UINT32 menu_input(UINT32 state) { record_next = TRUE; polling = FALSE; - *selected_item_data->seq = newseq; + selected_item_data->seq = newseq; + changed = TRUE; } } @@ -975,28 +988,47 @@ static UINT32 menu_input(UINT32 state) int prevsel = selected; /* handle generic menu keys */ - if (ui_menu_generic_keys(&selected, menu_items, visible_items)) + if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) return selected; /* if an item was selected, start polling on it */ - if (input_ui_pressed(IPT_UI_SELECT)) + if (input_ui_pressed(machine, IPT_UI_SELECT)) { - input_seq_poll_start((selected_item_data->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? selected_item_data->seq : NULL); - starting_seq = *selected_item_data->seq; + input_seq_poll_start((selected_item_data->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &selected_item_data->seq : NULL); + starting_seq = selected_item_data->seq; polling = TRUE; } /* if the clear key was pressed, reset the selected item */ - if (input_ui_pressed(IPT_UI_CLEAR)) + if (input_ui_pressed(machine, IPT_UI_CLEAR)) { - input_menu_toggle_none_default(selected_item_data->seq, selected_item_data->seq, selected_item_data->defseq); + input_menu_toggle_none_default(&selected_item_data->seq, &selected_item_data->seq, selected_item_data->defseq); record_next = FALSE; + changed = TRUE; } /* if the selection changed, update and reset the "record first" flag */ if (selected != prevsel) record_next = FALSE; } + + /* if the sequence changed, update it */ + if (changed) + { + if (group > IPG_TOTAL_GROUPS) + { + input_field_user_settings settings; + + input_field_get_user_settings(selected_item_data->field, &settings); + settings.seq[selected_item_data->seqtype] = selected_item_data->seq; + input_field_set_user_settings(selected_item_data->field, &settings); + } + else + { + const input_type_desc *typedesc = selected_item_data->typedesc; + input_type_set_seq(machine, typedesc->type, typedesc->player, selected_item_data->seqtype, &selected_item_data->seq); + } + } return selected | (record_next << 14) | (polling << 15) | (group << 16); } @@ -1007,14 +1039,14 @@ static UINT32 menu_input(UINT32 state) switches -------------------------------------------------*/ -static UINT32 menu_switches(UINT32 state) +static UINT32 menu_switches(running_machine *machine, UINT32 state) { ui_menu_item item_list[MAX_INPUT_PORTS * MAX_BITS_PER_PORT / 2]; - int switch_entry = (state >> 24) & 0xff; int switch_name = (state >> 16) & 0xff; UINT32 selected = state & 0xffff; - input_port_entry *selected_in = NULL; - input_port_entry *in; + const input_port_config *port; + const input_field_config *field; + const input_field_config *selected_field = NULL; int menu_items = 0; int changed = FALSE; int visible_items; @@ -1026,18 +1058,18 @@ static UINT32 menu_switches(UINT32 state) memset(dip_switch_model, 0, sizeof(dip_switch_model)); /* loop over input ports and set up the current values */ - for (in = Machine->input_ports; in->type != IPT_END; in++) - if (in->type == switch_name && input_port_active(in) && input_port_condition(in)) - { - switches_menu_add_item(&item_list[menu_items], in, switch_entry, in); - if (in->type == IPT_DIPSWITCH_NAME) - dip_switch_build_model(in, menu_items == selected); - menu_items++; - } + for (port = machine->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + if (field->type == switch_name && input_condition_true(machine, &field->condition)) + { + switches_menu_add_item(&item_list[menu_items], field); + if (field->type == IPT_DIPSWITCH) + dip_switch_build_model(field, menu_items == selected); + menu_items++; + } /* sort the list */ -// qsort(item_list, menu_items, sizeof(item_list[0]), switches_menu_compare_items); - selected_in = item_list[selected].ref; + selected_field = item_list[selected].ref; /* add an item to return */ item_list[menu_items++].text = "Return to Prior Menu"; @@ -1052,18 +1084,18 @@ static UINT32 menu_switches(UINT32 state) visible_items = ui_menu_draw(item_list, menu_items, selected, (dip_switch_model[0].dip_name) ? &extra : NULL); /* handle generic menu keys */ - if (ui_menu_generic_keys(&selected, menu_items, visible_items)) + if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) return selected; /* handle left/right arrows */ - if (input_ui_pressed(IPT_UI_LEFT) && (item_list[selected].flags & MENU_FLAG_LEFT_ARROW)) + if (input_ui_pressed(machine, IPT_UI_LEFT) && (item_list[selected].flags & MENU_FLAG_LEFT_ARROW)) { - switches_menu_select_previous(selected_in, switch_entry); + switches_menu_select_previous(selected_field); changed = TRUE; } - if (input_ui_pressed(IPT_UI_RIGHT) && (item_list[selected].flags & MENU_FLAG_RIGHT_ARROW)) + if (input_ui_pressed(machine, IPT_UI_RIGHT) && (item_list[selected].flags & MENU_FLAG_RIGHT_ARROW)) { - switches_menu_select_next(selected_in, switch_entry); + switches_menu_select_next(selected_field); changed = TRUE; } @@ -1071,21 +1103,21 @@ static UINT32 menu_switches(UINT32 state) /* due to conditional DIPs changing things */ if (changed) { - int newsel = 0; - input_port_update_defaults(); - for (in = Machine->input_ports; in->type != IPT_END; in++) - if (in->type == switch_name && input_port_active(in) && input_port_condition(in)) - { - if (selected_in == in) + int newselected = 0; + for (port = machine->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + if (field->type == switch_name && input_condition_true(machine, &field->condition)) { - selected = newsel; - break; + if (field == selected_field) + { + selected = newselected; + break; + } + newselected++; } - newsel++; - } } - return selected | (switch_name << 16) | (switch_entry << 24); + return selected | (switch_name << 16); } @@ -1094,11 +1126,12 @@ static UINT32 menu_switches(UINT32 state) control settings -------------------------------------------------*/ -static UINT32 menu_analog(UINT32 state) +static UINT32 menu_analog(running_machine *machine, UINT32 state) { ui_menu_item item_list[MAX_INPUT_PORTS * 4 * ANALOG_ITEM_COUNT]; - input_port_entry *selected_in = NULL; - input_port_entry *in; + const input_port_config *port; + const input_field_config *field; + const input_field_config *selected_field = NULL; int menu_items = 0; int selected_item = 0; int visible_items; @@ -1110,45 +1143,48 @@ static UINT32 menu_analog(UINT32 state) menu_string_pool_offset = 0; /* loop over input ports and add the items */ - for (in = Machine->input_ports; in->type != IPT_END; in++) - if (port_type_is_analog(in->type)) - { - use_autocenter = 0; - switch (in->type) + for (port = Machine->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + if (input_type_is_analog(field->type)) { - /* Autocenter Speed is only used for these devices */ - case IPT_POSITIONAL: - case IPT_POSITIONAL_V: - if (in->analog.wraps) break; - - case IPT_PEDAL: - case IPT_PEDAL2: - case IPT_PEDAL3: - case IPT_PADDLE: - case IPT_PADDLE_V: - case IPT_AD_STICK_X: - case IPT_AD_STICK_Y: - case IPT_AD_STICK_Z: - use_autocenter = 1; - break; - } + use_autocenter = FALSE; + switch (field->type) + { + /* Autocenter Speed is only used for these devices */ + case IPT_POSITIONAL: + case IPT_POSITIONAL_V: + if (field->flags & ANALOG_FLAG_WRAPS) + break; + + case IPT_PEDAL: + case IPT_PEDAL2: + case IPT_PEDAL3: + case IPT_PADDLE: + case IPT_PADDLE_V: + case IPT_AD_STICK_X: + case IPT_AD_STICK_Y: + case IPT_AD_STICK_Z: + use_autocenter = TRUE; + break; + } - /* track the selected item */ - if (state >= menu_items && state < menu_items + 3 + use_autocenter) - { - selected_in = in; - selected_item = state - menu_items; - // shift menu for missing Autocenter - if (selected_item && !use_autocenter) selected_item++; - } + /* track the selected item */ + if (state >= menu_items && state < menu_items + 3 + use_autocenter) + { + selected_field = field; + selected_item = state - menu_items; + // shift menu for missing Autocenter + if (selected_item && !use_autocenter) + selected_item++; + } - /* add the needed items for each analog input */ - analog_menu_add_item(&item_list[menu_items++], in, "Digital Speed", ANALOG_ITEM_KEYSPEED); - if (use_autocenter) - analog_menu_add_item(&item_list[menu_items++], in, "Autocenter Speed", ANALOG_ITEM_CENTERSPEED); - analog_menu_add_item(&item_list[menu_items++], in, "Reverse", ANALOG_ITEM_REVERSE); - analog_menu_add_item(&item_list[menu_items++], in, "Sensitivity", ANALOG_ITEM_SENSITIVITY); - } + /* add the needed items for each analog input */ + analog_menu_add_item(&item_list[menu_items++], field, "Digital Speed", ANALOG_ITEM_KEYSPEED); + if (use_autocenter) + analog_menu_add_item(&item_list[menu_items++], field, "Autocenter Speed", ANALOG_ITEM_CENTERSPEED); + analog_menu_add_item(&item_list[menu_items++], field, "Reverse", ANALOG_ITEM_REVERSE); + analog_menu_add_item(&item_list[menu_items++], field, "Sensitivity", ANALOG_ITEM_SENSITIVITY); + } /* add an item to return */ item_list[menu_items++].text = "Return to Prior Menu"; @@ -1157,26 +1193,32 @@ static UINT32 menu_analog(UINT32 state) visible_items = ui_menu_draw(item_list, menu_items, state, NULL); /* handle generic menu keys */ - if (ui_menu_generic_keys(&state, menu_items, visible_items)) + if (ui_menu_generic_keys(machine, &state, menu_items, visible_items)) return state; /* handle left/right arrows */ - if (input_ui_pressed_repeat(IPT_UI_LEFT,6) && (item_list[state].flags & MENU_FLAG_LEFT_ARROW)) + if (input_ui_pressed_repeat(machine, IPT_UI_LEFT,6) && (item_list[state].flags & MENU_FLAG_LEFT_ARROW)) delta = -1; - if (input_ui_pressed_repeat(IPT_UI_RIGHT,6) && (item_list[state].flags & MENU_FLAG_RIGHT_ARROW)) + if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT,6) && (item_list[state].flags & MENU_FLAG_RIGHT_ARROW)) delta = 1; if (input_code_pressed(KEYCODE_LSHIFT)) delta *= 10; /* adjust the appropriate value */ - if (delta != 0 && selected_in) + if (delta != 0 && selected_field != NULL) + { + input_field_user_settings settings; + + input_field_get_user_settings(selected_field, &settings); switch (selected_item) { - case ANALOG_ITEM_KEYSPEED: selected_in->analog.delta += delta; break; - case ANALOG_ITEM_CENTERSPEED: selected_in->analog.centerdelta += delta; break; - case ANALOG_ITEM_REVERSE: selected_in->analog.reverse += delta; break; - case ANALOG_ITEM_SENSITIVITY: selected_in->analog.sensitivity += delta; break; + case ANALOG_ITEM_KEYSPEED: settings.delta += delta; break; + case ANALOG_ITEM_CENTERSPEED: settings.centerdelta += delta; break; + case ANALOG_ITEM_REVERSE: settings.reverse += delta; break; + case ANALOG_ITEM_SENSITIVITY: settings.sensitivity += delta; break; } + input_field_set_user_settings(selected_field, &settings); + } return state; } @@ -1188,7 +1230,7 @@ static UINT32 menu_analog(UINT32 state) -------------------------------------------------*/ #ifndef MESS -static UINT32 menu_bookkeeping(UINT32 state) +static UINT32 menu_bookkeeping(running_machine *machine, UINT32 state) { char buf[2048]; char *bufptr = buf; @@ -1230,7 +1272,7 @@ static UINT32 menu_bookkeeping(UINT32 state) ui_menu_draw_text_box(buf); /* handle the keys */ - ui_menu_generic_keys(&selected, 1, 0); + ui_menu_generic_keys(machine, &selected, 1, 0); return selected; } #endif @@ -1241,20 +1283,20 @@ static UINT32 menu_bookkeeping(UINT32 state) game information -------------------------------------------------*/ -static UINT32 menu_game_info(UINT32 state) +static UINT32 menu_game_info(running_machine *machine, UINT32 state) { char buf[2048]; char *bufptr = buf; UINT32 selected = 0; /* add the game info */ - bufptr += sprintf_game_info(Machine, bufptr); + bufptr += sprintf_game_info(machine, bufptr); /* draw the text */ ui_menu_draw_text_box(buf); /* handle the keys */ - ui_menu_generic_keys(&selected, 1, 0); + ui_menu_generic_keys(machine, &selected, 1, 0); return selected; } @@ -1263,9 +1305,9 @@ static UINT32 menu_game_info(UINT32 state) menu_cheat - display a menu for cheat options -------------------------------------------------*/ -static UINT32 menu_cheat(UINT32 state) +static UINT32 menu_cheat(running_machine *machine, UINT32 state) { - int result = cheat_menu(Machine, state); + int result = cheat_menu(machine, state); if (result == 0) return ui_menu_stack_pop(); return result; @@ -1277,7 +1319,7 @@ static UINT32 menu_cheat(UINT32 state) card options -------------------------------------------------*/ -static UINT32 menu_memory_card(UINT32 state) +static UINT32 menu_memory_card(running_machine *machine, UINT32 state) { ui_menu_item item_list[5]; int menu_items = 0; @@ -1312,15 +1354,15 @@ static UINT32 menu_memory_card(UINT32 state) visible_items = ui_menu_draw(item_list, menu_items, selected, NULL); /* handle the keys */ - if (ui_menu_generic_keys(&selected, menu_items, visible_items)) + if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) return selected; - if (selected == 0 && input_ui_pressed(IPT_UI_LEFT) && cardnum > 0) + if (selected == 0 && input_ui_pressed(machine, IPT_UI_LEFT) && cardnum > 0) cardnum--; - if (selected == 0 && input_ui_pressed(IPT_UI_RIGHT) && cardnum < 1000) + if (selected == 0 && input_ui_pressed(machine, IPT_UI_RIGHT) && cardnum < 1000) cardnum++; /* handle actions */ - if (input_ui_pressed(IPT_UI_SELECT)) + if (input_ui_pressed(machine, IPT_UI_SELECT)) { /* handle load */ if (selected == insertindex) @@ -1338,7 +1380,7 @@ static UINT32 menu_memory_card(UINT32 state) /* handle eject */ else if (selected == ejectindex) { - memcard_eject(Machine); + memcard_eject(machine); popmessage("Memory card ejected"); } @@ -1360,7 +1402,7 @@ static UINT32 menu_memory_card(UINT32 state) menu_video - display a menu for video options -------------------------------------------------*/ -static UINT32 menu_video(UINT32 state) +static UINT32 menu_video(running_machine *machine, UINT32 state) { ui_menu_item item_list[100]; render_target *targetlist[16]; @@ -1391,7 +1433,7 @@ static UINT32 menu_video(UINT32 state) /* if we only ended up with one, auto-select it */ if (menu_items == 1) - return menu_video(0 << 16 | render_target_get_view(render_target_get_indexed(0))); + return menu_video(machine, 0 << 16 | render_target_get_view(render_target_get_indexed(0))); /* add an item for moving the UI */ item_list[menu_items++].text = "Move User Interface"; @@ -1403,11 +1445,11 @@ static UINT32 menu_video(UINT32 state) visible_items = ui_menu_draw(item_list, menu_items, selected, NULL); /* handle the keys */ - if (ui_menu_generic_keys(&selected, menu_items, visible_items)) + if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) return selected; /* handle actions */ - if (input_ui_pressed(IPT_UI_SELECT)) + if (input_ui_pressed(machine, IPT_UI_SELECT)) { if (selected == menu_items - 2) { @@ -1478,11 +1520,11 @@ static UINT32 menu_video(UINT32 state) visible_items = ui_menu_draw(item_list, menu_items, selected, NULL); /* handle the keys */ - if (ui_menu_generic_keys(&selected, menu_items, visible_items)) + if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) return selected; /* handle actions */ - if (input_ui_pressed(IPT_UI_SELECT)) + if (input_ui_pressed(machine, IPT_UI_SELECT)) { /* rotate */ if (selected == menu_items - 6) @@ -1535,10 +1577,10 @@ static UINT32 menu_video(UINT32 state) quitting the game -------------------------------------------------*/ -static UINT32 menu_quit_game(UINT32 state) +static UINT32 menu_quit_game(running_machine *machine, UINT32 state) { /* request a reset */ - mame_schedule_exit(Machine); + mame_schedule_exit(machine); /* reset the menu stack */ ui_menu_stack_reset(); @@ -1551,7 +1593,7 @@ static UINT32 menu_quit_game(UINT32 state) menu -------------------------------------------------*/ -static UINT32 menu_select_game(UINT32 state) +static UINT32 menu_select_game(running_machine *machine, UINT32 state) { ui_menu_item item_list[VISIBLE_GAMES_IN_LIST + 2]; int error = (state >> 17) & 1; @@ -1649,7 +1691,7 @@ static UINT32 menu_select_game(UINT32 state) recompute |= select_game_handle_key(curkey, curkey - KEYCODE_0_PAD + '0'); /* escape pressed with non-empty text clears the text */ - if (input_ui_pressed(IPT_UI_CANCEL)) + if (input_ui_pressed(machine, IPT_UI_CANCEL)) { if (select_game_buffer[0] == 0) return ui_menu_stack_pop(); @@ -1665,14 +1707,14 @@ static UINT32 menu_select_game(UINT32 state) selected = 0; /* ignore pause keys by swallowing them */ - input_ui_pressed(IPT_UI_PAUSE); + input_ui_pressed(machine, IPT_UI_PAUSE); /* handle the generic keys */ - if (!recompute && ui_menu_generic_keys(&selected, menu_items, visible_items)) + if (!recompute && ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) return selected; /* handle actions */ - if (input_ui_pressed(IPT_UI_SELECT)) + if (input_ui_pressed(machine, IPT_UI_SELECT)) { /* control config */ if (ui_menu_is_force_game_select() && selected == menu_items - 2) @@ -1694,7 +1736,7 @@ static UINT32 menu_select_game(UINT32 state) /* if everything looks good, schedule the new driver */ if (audit_result == CORRECT || audit_result == BEST_AVAILABLE) { - mame_schedule_new_driver(Machine, select_game_list[selected]); + mame_schedule_new_driver(machine, select_game_list[selected]); ui_menu_stack_reset(); return 0; } @@ -1718,7 +1760,7 @@ static UINT32 menu_select_game(UINT32 state) -------------------------------------------------*/ #ifdef MESS -static UINT32 menu_file_manager(UINT32 state) +static UINT32 menu_file_manager(running_machine *machine, UINT32 state) { int result = filemanager(state); if (result == 0) @@ -1734,7 +1776,7 @@ static UINT32 menu_file_manager(UINT32 state) #ifdef MESS #if HAS_WAVE -static UINT32 menu_tape_control(UINT32 state) +static UINT32 menu_tape_control(running_machine *machine, UINT32 state) { int result = tapecontrol(state); if (result == 0) @@ -1810,55 +1852,56 @@ static void menu_render_triangle(bitmap_t *dest, const bitmap_t *source, const r for a given group of inputs -------------------------------------------------*/ -static int input_menu_get_items(input_item_data *itemlist, int group) +static int input_menu_get_items(running_machine *machine, input_item_data *itemlist, int group) { input_item_data *item = itemlist; - const input_port_default_entry *indef; - input_port_default_entry *in; + const input_type_desc *typedesc; astring *seqstring; - /* an out of range group is special; it just means the game-specific inputs */ - if (group > IPG_TOTAL_GROUPS) - return input_menu_get_game_items(itemlist); - /* iterate over the input ports and add menu items */ seqstring = astring_alloc(); - for (in = get_input_port_list(), indef = get_input_port_list_defaults(); in->type != IPT_END; in++, indef++) + for (typedesc = input_type_list(machine); typedesc != NULL; typedesc = typedesc->next) /* add if we match the group and we have a valid name */ - if (in->group == group && in->name && in->name[0] != 0) + if (typedesc->group == group && typedesc->name != NULL && typedesc->name[0] != 0) { /* build an entry for the standard sequence */ - item->seq = &in->defaultseq; - item->defseq = &indef->defaultseq; + item->typedesc = typedesc; + item->seqtype = SEQ_TYPE_STANDARD; + item->seq = *input_type_seq(machine, typedesc->type, typedesc->player, item->seqtype); + item->defseq = &typedesc->seq[item->seqtype]; item->sortorder = item - itemlist; - item->type = port_type_is_analog(in->type) ? INPUT_TYPE_ANALOG : INPUT_TYPE_DIGITAL; - item->name = menu_string_pool_add(input_format[item->type], in->name); - item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, item->seq))); - item->invert = input_seq_cmp(item->seq, item->defseq); + item->type = input_type_is_analog(typedesc->type) ? INPUT_TYPE_ANALOG : INPUT_TYPE_DIGITAL; + item->name = menu_string_pool_add(input_format[item->type], typedesc->name); + item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); + item->invert = input_seq_cmp(&item->seq, item->defseq); item++; /* if we're analog, add more entries */ if (item[-1].type == INPUT_TYPE_ANALOG) { /* build an entry for the decrement sequence */ - item->seq = &in->defaultdecseq; - item->defseq = &indef->defaultdecseq; + item->typedesc = typedesc; + item->seqtype = SEQ_TYPE_DECREMENT; + item->seq = *input_type_seq(machine, typedesc->type, typedesc->player, item->seqtype); + item->defseq = &typedesc->seq[item->seqtype]; item->sortorder = item - itemlist; item->type = INPUT_TYPE_ANALOG_DEC; - item->name = menu_string_pool_add(input_format[item->type], in->name); - item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, item->seq))); - item->invert = input_seq_cmp(item->seq, item->defseq); + item->name = menu_string_pool_add(input_format[item->type], typedesc->name); + item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); + item->invert = input_seq_cmp(&item->seq, item->defseq); item++; /* build an entry for the increment sequence */ - item->seq = &in->defaultincseq; - item->defseq = &indef->defaultincseq; + item->typedesc = typedesc; + item->seqtype = SEQ_TYPE_INCREMENT; + item->seq = *input_type_seq(machine, typedesc->type, typedesc->player, item->seqtype); + item->defseq = &typedesc->seq[item->seqtype]; item->sortorder = item - itemlist; item->type = INPUT_TYPE_ANALOG_INC; - item->name = menu_string_pool_add(input_format[item->type], in->name); - item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, item->seq))); - item->invert = input_seq_cmp(item->seq, item->defseq); + item->name = menu_string_pool_add(input_format[item->type], typedesc->name); + item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); + item->invert = input_seq_cmp(&item->seq, item->defseq); item++; } } @@ -1870,85 +1913,93 @@ static int input_menu_get_items(input_item_data *itemlist, int group) /*------------------------------------------------- + get_field_default_seq - return a pointer + to the default sequence for the given field +-------------------------------------------------*/ + +static const input_seq *get_field_default_seq(const input_field_config *field, int seqtype) +{ + if (input_seq_get_1(&field->seq[seqtype]) == SEQCODE_DEFAULT) + return input_type_seq(field->port->machine, field->type, field->player, seqtype); + else + return &field->seq[seqtype]; +} + + +/*------------------------------------------------- input_menu_get_game_items - build a list of items for the game-specific inputs -------------------------------------------------*/ -static int input_menu_get_game_items(input_item_data *itemlist) +static int input_menu_get_game_items(running_machine *machine, input_item_data *itemlist) { - static const input_seq default_seq = SEQ_DEF_1(SEQCODE_DEFAULT); astring *seqstring = astring_alloc(); input_item_data *item = itemlist; - input_port_entry *in; + const input_port_config *port; + const input_field_config *field; /* iterate over the input ports and add menu items */ - for (in = Machine->input_ports; in->type != IPT_END; in++) - { - const char *name = input_port_name(in); + for (port = machine->portconfig; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) + { + const char *name = input_field_name(field); - /* add if we match the group and we have a valid name */ - if ((name != NULL) && (input_port_condition(in)) && + /* add if we match the group and we have a valid name */ + if (name != NULL && input_condition_true(machine, &field->condition) && #ifdef MESS - (in->category == 0 || input_category_active(Machine, in->category)) && + (field->category == 0 || input_category_active(machine, field->category)) && #endif /* MESS */ - ((in->type == IPT_OTHER && in->name != IP_NAME_DEFAULT) || port_type_to_group(in->type, in->player) != IPG_INVALID)) - { - UINT16 sortorder; - const input_seq *curseq, *defseq; - - /* determine the sorting order */ - if (in->type >= IPT_START1 && in->type <= __ipt_analog_end) - sortorder = (in->type << 2) | (in->player << 12); - else - sortorder = in->type | 0xf000; - - /* fetch data for the standard sequence */ - curseq = input_port_seq(in, SEQ_TYPE_STANDARD); - defseq = input_port_default_seq(in->type, in->player, SEQ_TYPE_STANDARD); - - /* build an entry for the standard sequence */ - item->seq = &in->seq; - item->defseq = &default_seq; - item->sortorder = sortorder; - item->type = port_type_is_analog(in->type) ? INPUT_TYPE_ANALOG : INPUT_TYPE_DIGITAL; - item->name = menu_string_pool_add(input_format[item->type], name); - item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, curseq))); - item->invert = input_seq_cmp(curseq, defseq); - item++; - - /* if we're analog, add more entries */ - if (item[-1].type == INPUT_TYPE_ANALOG) + ((field->type == IPT_OTHER && field->name != NULL) || input_type_group(machine, field->type, field->player) != IPG_INVALID)) { - /* fetch data for the decrement sequence */ - curseq = input_port_seq(in, SEQ_TYPE_DECREMENT); - defseq = input_port_default_seq(in->type, in->player, SEQ_TYPE_DECREMENT); - - /* build an entry for the decrement sequence */ - item->seq = &in->analog.decseq; - item->defseq = &default_seq; - item->sortorder = sortorder; - item->type = INPUT_TYPE_ANALOG_DEC; - item->name = menu_string_pool_add(input_format[item->type], name); - item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, curseq))); - item->invert = input_seq_cmp(curseq, defseq); - item++; + UINT16 sortorder; - /* fetch data for the increment sequence */ - curseq = input_port_seq(in, SEQ_TYPE_INCREMENT); - defseq = input_port_default_seq(in->type, in->player, SEQ_TYPE_INCREMENT); + /* determine the sorting order */ + if (field->type >= IPT_START1 && field->type <= __ipt_analog_end) + sortorder = (field->type << 2) | (field->player << 12); + else + sortorder = field->type | 0xf000; - /* build an entry for the increment sequence */ - item->seq = &in->analog.incseq; - item->defseq = &default_seq; + /* build an entry for the standard sequence */ + item->field = field; + item->seqtype = SEQ_TYPE_STANDARD; + item->seq = *input_field_seq(field, item->seqtype); + item->defseq = get_field_default_seq(field, item->seqtype); item->sortorder = sortorder; - item->type = INPUT_TYPE_ANALOG_INC; + item->type = input_type_is_analog(field->type) ? INPUT_TYPE_ANALOG : INPUT_TYPE_DIGITAL; item->name = menu_string_pool_add(input_format[item->type], name); - item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, curseq))); - item->invert = input_seq_cmp(curseq, defseq); + item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); + item->invert = input_seq_cmp(&item->seq, item->defseq); item++; + + /* if we're analog, add more entries */ + if (item[-1].type == INPUT_TYPE_ANALOG) + { + /* build an entry for the decrement sequence */ + item->field = field; + item->seqtype = SEQ_TYPE_DECREMENT; + item->seq = *input_field_seq(field, item->seqtype); + item->defseq = get_field_default_seq(field, item->seqtype); + item->sortorder = sortorder; + item->type = INPUT_TYPE_ANALOG_DEC; + item->name = menu_string_pool_add(input_format[item->type], name); + item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); + item->invert = input_seq_cmp(&item->seq, item->defseq); + item++; + + /* build an entry for the increment sequence */ + item->field = field; + item->seqtype = SEQ_TYPE_INCREMENT; + item->seq = *input_field_seq(field, item->seqtype); + item->defseq = get_field_default_seq(field, item->seqtype); + item->sortorder = sortorder; + item->type = INPUT_TYPE_ANALOG_INC; + item->name = menu_string_pool_add(input_format[item->type], name); + item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); + item->invert = input_seq_cmp(&item->seq, item->defseq); + item++; + } } } - } /* return the number of items */ astring_free(seqstring); @@ -2001,24 +2052,26 @@ static int input_menu_compare_items(const void *i1, const void *i2) switches menu list -------------------------------------------------*/ -static void switches_menu_add_item(ui_menu_item *item, const input_port_entry *in, int switch_entry, void *ref) +static void switches_menu_add_item(ui_menu_item *item, const input_field_config *field) { - const input_port_entry *tin; + const input_setting_config *setting; + input_field_user_settings settings; /* set the text to the name and the subitem text to invalid */ - item->text = input_port_name(in); + input_field_get_user_settings(field, &settings); + item->text = input_field_name(field); item->subtext = NULL; /* scan for the current selection in the list */ - for (tin = in + 1; tin->type == switch_entry; tin++) - if (input_port_condition(tin)) + for (setting = field->settinglist; setting != NULL; setting = setting->next) + if (input_condition_true(field->port->machine, &setting->condition)) { /* if this is a match, set the subtext */ - if (in->default_value == tin->default_value) - item->subtext = input_port_name(tin); + if (setting->value == settings.value) + item->subtext = setting->name; /* else if we haven't seen a match yet, show a left arrow */ - else if (!item->subtext) + else if (item->subtext == NULL) item->flags |= MENU_FLAG_LEFT_ARROW; /* else if we have seen a match, show a right arrow */ @@ -2027,11 +2080,11 @@ static void switches_menu_add_item(ui_menu_item *item, const input_port_entry *i } /* if no matches, we're invalid */ - if (!item->subtext) + if (item->subtext == NULL) item->subtext = "INVALID"; /* stash our reference */ - item->ref = ref; + item->ref = (void *)field; } @@ -2040,26 +2093,41 @@ static void switches_menu_add_item(ui_menu_item *item, const input_port_entry *i previous item in the switches list -------------------------------------------------*/ -static void switches_menu_select_previous(input_port_entry *in, int switch_entry) +static void switches_menu_select_previous(const input_field_config *field) { - int last_value = in->default_value; - const input_port_entry *tin; - - /* scan for the current selection in the list */ - for (tin = in + 1; tin->type == switch_entry; tin++) - if (input_port_condition(tin)) + const input_setting_config *setting, *prevsetting; + input_field_user_settings settings; + int found_match = FALSE; + + /* get the current configured settings */ + input_field_get_user_settings(field, &settings); + + /* 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 (setting->value == settings.value) { - /* if this is a match, we're done */ - if (in->default_value == tin->default_value) - { - in->default_value = last_value; - return; - } - - /* otherwise, keep track of last one found */ - else - last_value = tin->default_value; + found_match = TRUE; + if (prevsetting != NULL) + break; } + if (input_condition_true(field->port->machine, &setting->condition)) + prevsetting = setting; + } + + /* 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)) + break; + } + + /* update the value to the previous one */ + if (prevsetting != NULL) + settings.value = prevsetting->value; + input_field_set_user_settings(field, &settings); } @@ -2068,44 +2136,37 @@ static void switches_menu_select_previous(input_port_entry *in, int switch_entry next item in the switches list -------------------------------------------------*/ -static void switches_menu_select_next(input_port_entry *in, int switch_entry) -{ - const input_port_entry *tin; - int foundit = FALSE; - - /* scan for the current selection in the list */ - for (tin = in + 1; tin->type == switch_entry; tin++) - if (input_port_condition(tin)) - { - /* if we found the current selection, we pick the next one */ - if (foundit) - { - in->default_value = tin->default_value; - return; - } - - /* if this is a match, note it */ - if (in->default_value == tin->default_value) - foundit = TRUE; - } -} - - -/*------------------------------------------------- - switches_menu_compare_items - compare two - switches items for quicksort purposes --------------------------------------------------*/ - -/* -static int switches_menu_compare_items(const void *i1, const void *i2) +static void switches_menu_select_next(const input_field_config *field) { - const ui_menu_item *item1 = i1; - const ui_menu_item *item2 = i2; - const input_port_entry *data1 = item1->ref; - const input_port_entry *data2 = item2->ref; - return strcmp(input_port_name(data1), input_port_name(data2)); + const input_setting_config *setting, *nextsetting; + input_field_user_settings settings; + + /* get the current configured settings */ + input_field_get_user_settings(field, &settings); + + /* 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 (setting->value == settings.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)) + 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)) + break; + + /* update the value to the previous one */ + if (nextsetting != NULL) + settings.value = nextsetting->value; + input_field_set_user_settings(field, &settings); } -*/ /*------------------------------------------------- @@ -2113,40 +2174,43 @@ static int switches_menu_compare_items(const void *i1, const void *i2) analog controls menu -------------------------------------------------*/ -static void analog_menu_add_item(ui_menu_item *item, const input_port_entry *in, const char *append_string, int which_item) +static void analog_menu_add_item(ui_menu_item *item, const input_field_config *field, const char *append_string, int which_item) { + input_field_user_settings settings; int value, minval, maxval; + input_field_get_user_settings(field, &settings); + /* set the item text using the formatting string provided */ - item->text = menu_string_pool_add("%s %s", input_port_name(in), append_string); + item->text = menu_string_pool_add("%s %s", input_field_name(field), append_string); /* set the subitem text */ switch (which_item) { default: case ANALOG_ITEM_KEYSPEED: - value = in->analog.delta; + value = settings.delta; minval = 0; maxval = 255; item->subtext = menu_string_pool_add("%d", value); break; case ANALOG_ITEM_CENTERSPEED: - value = in->analog.centerdelta; + value = settings.centerdelta; minval = 0; maxval = 255; item->subtext = menu_string_pool_add("%d", value); break; case ANALOG_ITEM_REVERSE: - value = in->analog.reverse; + value = settings.reverse; minval = 0; maxval = 1; item->subtext = value ? "On" : "Off"; break; case ANALOG_ITEM_SENSITIVITY: - value = in->analog.sensitivity; + value = settings.sensitivity; minval = 1; maxval = 255; item->subtext = menu_string_pool_add("%d%%", value); @@ -2166,40 +2230,44 @@ static void analog_menu_add_item(ui_menu_item *item, const input_port_entry *in, for DIP switches -------------------------------------------------*/ -static void dip_switch_build_model(input_port_entry *entry, int item_is_selected) +static void dip_switch_build_model(const input_field_config *field, int item_is_selected) { - int dip_declaration_index = 0; - int value_mask_temp = entry->mask; + input_port_value value_mask_temp = field->mask; + const input_field_diplocation *diploc; + input_port_value toggle_switch_mask; + input_field_user_settings settings; int value_mask_bit = 0; - int toggle_switch_mask; - int model_index = 0; + int model_index; int toggle_num; - if (entry->diploc[dip_declaration_index].swname == NULL) + diploc = field->diploclist; + if (diploc == NULL || diploc->swname == NULL) return; + + input_field_get_user_settings(field, &settings); /* get the entry in the model to work with */ - do + for (model_index = 0; model_index < MAX_PHYSICAL_DIPS; model_index++) { /* use this entry if it's not used */ if (dip_switch_model[model_index].dip_name == NULL) { - dip_switch_model[model_index].dip_name = entry->diploc[dip_declaration_index].swname; + dip_switch_model[model_index].dip_name = diploc->swname; break; } /* reuse this entry if the switch name matches */ - if (!strcmp(entry->diploc[dip_declaration_index].swname, dip_switch_model[model_index].dip_name)) + if (!strcmp(diploc->swname, dip_switch_model[model_index].dip_name)) break; // todo: add a check here to see if we go over the max dips and throw an error. - } while (++model_index < MAX_PHYSICAL_DIPS); + } /* Create a mask depicting the number of toggles on the physical switch */ - while (entry->diploc[dip_declaration_index].swname) + for ( ; diploc != NULL; diploc = diploc->next) { /* get the Nth DIP toggle number */ - toggle_num = entry->diploc[dip_declaration_index].swnum; + toggle_num = diploc->swnum; /* get the Nth mask bit - * should probably put a check here to avoid bad driver definitions @@ -2218,18 +2286,16 @@ static void dip_switch_build_model(input_port_entry *entry, int item_is_selected dip_switch_model[model_index].total_dip_mask |= toggle_switch_mask; /* if it's inverted, mark it as such */ - if (entry->diploc[dip_declaration_index].invert) + if (diploc->invert) dip_switch_model[model_index].dip_invert_mask |= toggle_switch_mask; /* if isolated bit is on, set the toggle on */ - if ((1 << value_mask_bit) & entry->default_value) + if ((1 << value_mask_bit) & settings.value) dip_switch_model[model_index].total_dip_settings |= toggle_switch_mask; /* indicate if the toggle is selected */ if (item_is_selected) dip_switch_model[model_index].selected_dip_feature_mask |= toggle_switch_mask; - - ++dip_declaration_index; } } diff --git a/src/emu/uimenu.h b/src/emu/uimenu.h index 45f41720cdb..aba3d110bb2 100644 --- a/src/emu/uimenu.h +++ b/src/emu/uimenu.h @@ -32,7 +32,7 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef UINT32 (*ui_menu_handler_func)(UINT32 state); +typedef UINT32 (*ui_menu_handler_func)(running_machine *machine, UINT32 state); typedef struct _ui_menu_item ui_menu_item; struct _ui_menu_item @@ -69,7 +69,7 @@ int ui_menu_draw(const ui_menu_item *items, int numitems, int selected, const me UINT32 ui_menu_ui_handler(running_machine *machine, UINT32 state); /* menu keyboard handling */ -int ui_menu_generic_keys(UINT32 *selected, int num_items, int visible_items); +int ui_menu_generic_keys(running_machine *machine, UINT32 *selected, int num_items, int visible_items); /* menu stack management */ void ui_menu_stack_reset(void); diff --git a/src/emu/validity.c b/src/emu/validity.c index d87d103f033..d0f9a464b23 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -947,359 +947,341 @@ static int validate_gfx(int drivnum, const machine_config *config, const UINT32 /*------------------------------------------------- - display_valid_coin_order - display the - correct coin order + get_defstr_index - return the index of the + string assuming it is one of the default + strings -------------------------------------------------*/ -static void display_valid_coin_order(int drivnum, const input_port_entry *memory) +static int get_defstr_index(const char *name, const game_driver *driver, int *error) { - const game_driver *driver = drivers[drivnum]; - const input_port_entry *inp; - int coin_list[1024]; - int coin_len = 0; - int i, j; + UINT32 crc = quark_string_crc(name); quark_entry *entry; - - for (inp = memory; inp->type != IPT_END; inp++) - { - int strindex = 0; - UINT32 crc; - - if ( !inp->name || inp->name == IP_NAME_DEFAULT ) - continue; - - /* hash the string and look it up in the string table */ - crc = quark_string_crc(inp->name); - for (entry = quark_table_get_first(defstr_table, crc); entry; entry = entry->next) - if (entry->crc == crc && !strcmp(inp->name, input_port_string_from_index(entry - defstr_table->entry))) - { - strindex = entry - defstr_table->entry; - break; - } - - /* if its a coin entry, add it to our list, avoiding repetitions */ - if ( strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C ) + int strindex = 0; + + /* scan the quark table of input port strings */ + for (entry = quark_table_get_first(defstr_table, crc); entry != NULL; entry = entry->next) + if (entry->crc == crc && strcmp(name, input_port_string_from_index(entry - defstr_table->entry)) == 0) { - j = 1; - - for( i = 0; i < coin_len; i++ ) - { - if ( coin_list[i] == strindex ) - { - j = 0; - break; - } - } - - if ( j ) - coin_list[coin_len++] = strindex; + strindex = entry - defstr_table->entry; + break; } - } - /* now display the proper coin entry list */ - mame_printf_error( "%s: %s proper coin sort order should be:\n", driver->source_file, driver->name ); - for (i = INPUT_STRING_9C_1C; i <= INPUT_STRING_1C_9C; i++) - for (j = 0; j < coin_len; j++) - /* if it's on our list, display it */ - if (coin_list[j] == i) - mame_printf_error("%s\n", input_port_string_from_index(i)); + /* check for strings that should be DEF_STR */ + if (strindex != 0 && name != input_port_string_from_index(strindex) && error != NULL) + { + mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver->source_file, driver->name, name); + *error = TRUE; + } + + return strindex; } /*------------------------------------------------- - validate_inputs - validate input configuration + validate_analog_input_field - validate an + analog input field -------------------------------------------------*/ -static int validate_inputs(int drivnum, const machine_config *config, input_port_entry **memory) +static void validate_analog_input_field(const input_field_config *field, const game_driver *driver, int *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); - const input_port_entry *inp, *last_dipname_entry = NULL; - const game_driver *driver = drivers[drivnum]; - const char *tag[MAX_INPUT_PORTS] = { 0 }; - int portnum = 0; - int empty_string_found = FALSE; - int last_strindex = 0; - quark_entry *entry; - int error = FALSE; - int coin_error = FALSE; - UINT32 crc; + INT32 analog_max = field->max; + INT32 analog_min = field->min; + int shift; - /* skip if no ports */ - if (!driver->ipt) - return FALSE; + if (field->type == IPT_POSITIONAL || field->type == IPT_POSITIONAL_V) + { + for (shift = 0; (shift <= 31) && (~field->mask & (1 << shift)); shift++) ; + /* convert the positional max value to be in the bitmask for testing */ + analog_max = (analog_max - 1) << shift; - /* skip if we already validated these ports */ - crc = (FPTR)driver->ipt; - for (entry = quark_table_get_first(inputs_table, crc); entry; entry = entry->next) - if (entry->crc == crc && driver->ipt == drivers[entry - inputs_table->entry]->ipt) - return FALSE; + /* positional port size must fit in bits used */ + if (((field->mask >> shift) + 1) < field->max) + { + mame_printf_error("%s: %s has an analog port with a positional port size bigger then the mask size\n", driver->source_file, driver->name); + *error = TRUE; + } + } + else + { + /* only positional controls use PORT_WRAPS */ + if (field->flags & ANALOG_FLAG_WRAPS) + { + mame_printf_error("%s: %s only positional analog ports use PORT_WRAPS\n", driver->source_file, driver->name); + *error = TRUE; + } + } - /* otherwise, add ourself to the list */ - quark_add(inputs_table, drivnum, crc); + /* analog ports must have a valid sensitivity */ + if (field->sensitivity == 0) + { + mame_printf_error("%s: %s has an analog port with zero sensitivity\n", driver->source_file, driver->name); + *error = TRUE; + } - /* allocate the input ports */ - *memory = input_port_allocate(driver->ipt, *memory); + /* check that the default falls in the bitmask range */ + if (field->defvalue & ~field->mask) + { + mame_printf_error("%s: %s has an analog port with a default value out of the bitmask range\n", driver->source_file, driver->name); + *error = TRUE; + } - /* iterate over the results */ - for (inp = *memory; inp->type != IPT_END; inp++) + /* tests for absolute devices */ + if (field->type >= __ipt_analog_absolute_start && field->type <= __ipt_analog_absolute_end) { - int strindex = 0; + INT32 default_value = field->defvalue; - /* check for duplicate tags */ - if (inp->type == IPT_PORT) + /* adjust for signed values */ + if (analog_min > analog_max) { - if (inp->start.tag != NULL && portnum < ARRAY_LENGTH(tag)) - { - int scanport; - - for (scanport = 0; scanport < portnum - 1; scanport++) - if (strcmp(inp->start.tag, tag[scanport]) == 0) - { - mame_printf_error("%s: %s has a duplicate input port tag \"%s\"\n", driver->source_file, driver->name, inp->start.tag); - error = TRUE; - } - tag[portnum++] = inp->start.tag; - } - continue; + analog_min = -analog_min; + if (default_value > analog_max) + default_value = -default_value; } - if (port_type_is_analog(inp->type)) + /* check that the default falls in the MINMAX range */ + if (default_value < analog_min || default_value > analog_max) { - INT32 analog_max = inp->analog.max; - INT32 analog_min = inp->analog.min; - int shift; - - if (inp->type == IPT_POSITIONAL || inp->type == IPT_POSITIONAL_V) - { - for (shift = 0; (shift <= 31) && (~inp->mask & (1 << shift)); shift++); - /* convert the positional max value to be in the bitmask for testing */ - analog_max = (analog_max - 1) << shift; + mame_printf_error("%s: %s has an analog port with a default value out PORT_MINMAX range\n", driver->source_file, driver->name); + *error = TRUE; + } - /* positional port size must fit in bits used */ - if (((inp->mask >> shift) + 1) < inp->analog.max) - { - mame_printf_error("%s: %s has an analog port with a positional port size bigger then the mask size\n", driver->source_file, driver->name); - error = TRUE; - } - } - else - { - /* only positional controls use PORT_WRAPS */ - if (inp->analog.wraps) - { - mame_printf_error("%s: %s only positional analog ports use PORT_WRAPS\n", driver->source_file, driver->name); - error = TRUE; - } - } + /* check that the MINMAX falls in the bitmask range */ + /* we use the unadjusted min for testing */ + if (field->min & ~field->mask || analog_max & ~field->mask) + { + mame_printf_error("%s: %s has an analog port with a PORT_MINMAX value out of the bitmask range\n", driver->source_file, driver->name); + *error = TRUE; + } + /* absolute analog ports do not use PORT_RESET */ + if (field->flags & ANALOG_FLAG_RESET) + { + mame_printf_error("%s: %s - absolute analog ports do not use PORT_RESET\n", driver->source_file, driver->name); + *error = TRUE; + } + } - /* analog ports must have a valid sensitivity */ - if (inp->analog.sensitivity == 0) + /* tests for relative devices */ + else + { + /* tests for non IPT_POSITIONAL relative devices */ + if (field->type != IPT_POSITIONAL && field->type != IPT_POSITIONAL_V) + { + /* relative devices do not use PORT_MINMAX */ + if (field->min != 0 || field->max != field->mask) { - mame_printf_error("%s: %s has an analog port with zero sensitivity\n", driver->source_file, driver->name); - error = TRUE; + mame_printf_error("%s: %s - relative ports do not use PORT_MINMAX\n", driver->source_file, driver->name); + *error = TRUE; } - /* check that the default falls in the bitmask range */ - if (inp->default_value & ~inp->mask) + /* relative devices do not use a default value */ + /* the counter is at 0 on power up */ + if (field->defvalue != 0) { - mame_printf_error("%s: %s has an analog port with a default value out of the bitmask range\n", driver->source_file, driver->name); - error = TRUE; - } - - /* tests for absolute devices */ - if (port_type_is_analog_absolute(inp->type)) - { - INT32 default_value = inp->default_value; - - /* adjust for signed values */ - if (analog_min > analog_max) - { - analog_min = -analog_min; - if (default_value > analog_max) - default_value = -default_value; - } - - /* check that the default falls in the MINMAX range */ - if (default_value < analog_min || default_value > analog_max) - { - mame_printf_error("%s: %s has an analog port with a default value out PORT_MINMAX range\n", driver->source_file, driver->name); - error = TRUE; - } - - /* check that the MINMAX falls in the bitmask range */ - /* we use the unadjusted min for testing */ - if (inp->analog.min & ~inp->mask || analog_max & ~inp->mask) - { - mame_printf_error("%s: %s has an analog port with a PORT_MINMAX value out of the bitmask range\n", driver->source_file, driver->name); - error = TRUE; - } - - /* absolute analog ports do not use PORT_RESET */ - if (inp->analog.reset) - { - mame_printf_error("%s: %s - absolute analog ports do not use PORT_RESET\n", driver->source_file, driver->name); - error = TRUE; - } - } - else - /* tests for relative devices */ - { - /* tests for non IPT_POSITIONAL relative devices */ - if (inp->type != IPT_POSITIONAL && inp->type != IPT_POSITIONAL_V) - { - /* relative devices do not use PORT_MINMAX */ - if (inp->analog.min || inp->analog.max != inp->mask) - { - mame_printf_error("%s: %s - relative ports do not use PORT_MINMAX\n", driver->source_file, driver->name); - error = TRUE; - } - - /* relative devices do not use a default value */ - /* the counter is at 0 on power up */ - if (inp->default_value) - { - mame_printf_error("%s: %s - relative ports do not use a default value other then 0\n", driver->source_file, driver->name); - error = TRUE; - } - } + mame_printf_error("%s: %s - relative ports do not use a default value other then 0\n", driver->source_file, driver->name); + *error = TRUE; } } + } +} - /* clear the DIP switch tracking when we hit the first non-DIP entry */ - if (last_dipname_entry != NULL && inp->type != IPT_DIPSWITCH_SETTING) - last_dipname_entry = NULL; - - /* look for invalid (0) types which should be mapped to IPT_OTHER */ - if (inp->type == IPT_INVALID) - { - mame_printf_error("%s: %s has an input port with an invalid type (0); use IPT_OTHER instead\n", driver->source_file, driver->name); - error = TRUE; - } - /* if this entry doesn't have a name, we don't care about the rest of this stuff */ - if (inp->name == NULL || inp->name == IP_NAME_DEFAULT) - { - /* not allowed for dipswitches */ - if (inp->type == IPT_DIPSWITCH_NAME || inp->type == IPT_DIPSWITCH_SETTING) - { - mame_printf_error("%s: %s has a DIP switch name or setting with no name\n", driver->source_file, driver->name); - error = TRUE; - } - last_strindex = 0; - continue; - } +/*------------------------------------------------- + validate_dip_settings - validate a DIP switch + setting +-------------------------------------------------*/ - /* check for empty string */ - if (inp->name[0] == 0 && !empty_string_found) +static void validate_dip_settings(const input_field_config *field, const game_driver *driver, int *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); + UINT8 coin_list[INPUT_STRING_1C_9C - INPUT_STRING_9C_1C] = { 0 }; + const input_setting_config *setting; + int coin_error = FALSE; + + /* iterate through the settings */ + for (setting = field->settinglist; setting != NULL; setting = setting->next) + { + int strindex = get_defstr_index(setting->name, driver, error); + + /* note any coinage strings */ + if (strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C) + coin_list[strindex - INPUT_STRING_9C_1C] = 1; + + /* make sure demo sounds default to on */ + if (field->name == demo_sounds && strindex == INPUT_STRING_On && field->defvalue != setting->value) { - mame_printf_error("%s: %s has an input with an empty string\n", driver->source_file, driver->name); - error = TRUE; - empty_string_found = TRUE; + mame_printf_error("%s: %s Demo Sounds must default to On\n", driver->source_file, driver->name); + *error = TRUE; } - /* check for trailing spaces */ - if (inp->name[0] != 0 && inp->name[strlen(inp->name) - 1] == ' ') + /* check for bad demo sounds options */ + if (field->name == demo_sounds && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) { - mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver->source_file, driver->name, inp->name); - error = TRUE; + mame_printf_error("%s: %s has wrong Demo Sounds option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name); + *error = TRUE; } - /* check for invalid UTF-8 */ - if (!utf8_is_valid_string(inp->name)) + /* check for bad flip screen options */ + if (field->name == flipscreen && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) { - mame_printf_error("%s: %s input '%s' has invalid characters\n", driver->source_file, driver->name, inp->name); - error = TRUE; + mame_printf_error("%s: %s has wrong Flip Screen option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name); + *error = TRUE; } - /* hash the string and look it up in the string table */ - crc = quark_string_crc(inp->name); - for (entry = quark_table_get_first(defstr_table, crc); entry; entry = entry->next) - if (entry->crc == crc && !strcmp(inp->name, input_port_string_from_index(entry - defstr_table->entry))) - { - strindex = entry - defstr_table->entry; - break; - } - - /* check for strings that should be DEF_STR */ - if (strindex != 0 && inp->name != input_port_string_from_index(strindex)) + /* if we have a neighbor, compare ourselves to him */ + if (setting->next != NULL) { - mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver->source_file, driver->name, inp->name); - error = TRUE; - } - - /* track the last dipswitch we encountered */ - if (inp->type == IPT_DIPSWITCH_NAME) - last_dipname_entry = inp; + int next_strindex = get_defstr_index(setting->next->name, driver, error); - /* check for dipswitch ordering against the last entry */ - if (inp[0].type == IPT_DIPSWITCH_SETTING && inp[-1].type == IPT_DIPSWITCH_SETTING && last_strindex != 0 && strindex != 0) - { /* check for inverted off/on dispswitch order */ - if (last_strindex == INPUT_STRING_On && strindex == INPUT_STRING_Off) + if (strindex == INPUT_STRING_On && next_strindex == INPUT_STRING_Off) { mame_printf_error("%s: %s has inverted Off/On dipswitch order\n", driver->source_file, driver->name); - error = TRUE; + *error = TRUE; } /* check for inverted yes/no dispswitch order */ - else if (last_strindex == INPUT_STRING_Yes && strindex == INPUT_STRING_No) + else if (strindex == INPUT_STRING_Yes && next_strindex == INPUT_STRING_No) { mame_printf_error("%s: %s has inverted No/Yes dipswitch order\n", driver->source_file, driver->name); - error = TRUE; + *error = TRUE; } /* check for inverted upright/cocktail dispswitch order */ - else if (last_strindex == INPUT_STRING_Cocktail && strindex == INPUT_STRING_Upright) + else if (strindex == INPUT_STRING_Cocktail && next_strindex == INPUT_STRING_Upright) { mame_printf_error("%s: %s has inverted Upright/Cocktail dipswitch order\n", driver->source_file, driver->name); - error = TRUE; + *error = TRUE; } /* check for proper coin ordering */ - else if (last_strindex >= INPUT_STRING_9C_1C && last_strindex <= INPUT_STRING_1C_9C && strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C && - last_strindex >= strindex && !memcmp(&inp[-1].condition, &inp[0].condition, sizeof(inp[-1].condition))) + 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) { - mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver->source_file, driver->name, inp[-1].name, inp[0].name); - error = TRUE; - coin_error = TRUE; + 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; } } + } + + /* if we have a coin error, demonstrate the correct way */ + if (coin_error) + { + int entry; + + mame_printf_error("%s: %s proper coin sort order should be:\n", driver->source_file, driver->name); + for (entry = 0; entry < ARRAY_LENGTH(coin_list); entry++) + if (coin_list[entry]) + mame_printf_error("%s\n", input_port_string_from_index(INPUT_STRING_9C_1C + entry)); + } +} + - /* check for invalid DIP switch entries */ - if (last_dipname_entry && inp->type == IPT_DIPSWITCH_SETTING) +/*------------------------------------------------- + validate_inputs - validate input configuration +-------------------------------------------------*/ + +static int validate_inputs(int drivnum, const machine_config *config) +{ + const input_port_config *portlist; + const input_port_config *scanport; + const input_port_config *port; + const input_field_config *field; + const game_driver *driver = drivers[drivnum]; + int empty_string_found = FALSE; + quark_entry *entry; + int error = FALSE; + UINT32 crc; + + /* skip if no ports */ + if (driver->ipt == NULL) + return FALSE; + + /* skip if we already validated these ports */ + crc = (FPTR)driver->ipt; + for (entry = quark_table_get_first(inputs_table, crc); entry != NULL; entry = entry->next) + if (entry->crc == crc && driver->ipt == drivers[entry - inputs_table->entry]->ipt) + return FALSE; + + /* otherwise, add ourself to the list */ + quark_add(inputs_table, drivnum, crc); + + /* allocate the input ports */ + portlist = input_port_config_alloc(driver->ipt); + + /* check for duplicate tags */ + for (port = portlist; 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; + } + + /* iterate over the results */ + for (port = portlist; port != NULL; port = port->next) + for (field = port->fieldlist; field != NULL; field = field->next) { - /* make sure demo sounds default to on */ - if (last_dipname_entry->name == demo_sounds && strindex == INPUT_STRING_On && - last_dipname_entry->default_value != inp->default_value) + int strindex = 0; + + /* verify analog inputs */ + if (input_type_is_analog(field->type)) + validate_analog_input_field(field, driver, &error); + + /* verify dip switches */ + if (field->type == IPT_DIPSWITCH) { - mame_printf_error("%s: %s Demo Sounds must default to On\n", driver->source_file, driver->name); - error = TRUE; + /* dip switch fields must have a name */ + if (field->name == NULL) + { + mame_printf_error("%s: %s has a DIP switch name or setting with no name\n", driver->source_file, driver->name); + error = TRUE; + } + + /* verify the settings list */ + validate_dip_settings(field, driver, &error); } - - /* check for bad flip screen options */ - if (last_dipname_entry->name == flipscreen && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) + + /* look for invalid (0) types which should be mapped to IPT_OTHER */ + if (field->type == IPT_INVALID) { - mame_printf_error("%s: %s has wrong Flip Screen option %s (must be Off/On)\n", driver->source_file, driver->name, inp->name); + mame_printf_error("%s: %s has an input port with an invalid type (0); use IPT_OTHER instead\n", driver->source_file, driver->name); error = TRUE; } - /* check for bad demo sounds options */ - if (last_dipname_entry->name == demo_sounds && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) + /* verify names */ + if (field->name != NULL) { - mame_printf_error("%s: %s has wrong Demo Sounds option %s (must be Off/On)\n", driver->source_file, driver->name, inp->name); - error = TRUE; - } - } + /* check for empty string */ + if (field->name[0] == 0 && !empty_string_found) + { + mame_printf_error("%s: %s has an input with an empty string\n", driver->source_file, driver->name); + empty_string_found = error = TRUE; + } - /* remember the last string index */ - last_strindex = strindex; - } + /* check for trailing spaces */ + if (field->name[0] != 0 && field->name[strlen(field->name) - 1] == ' ') + { + mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver->source_file, driver->name, field->name); + error = TRUE; + } - if ( coin_error ) - display_valid_coin_order(drivnum, *memory); + /* check for invalid UTF-8 */ + if (!utf8_is_valid_string(field->name)) + { + mame_printf_error("%s: %s input '%s' has invalid characters\n", driver->source_file, driver->name, field->name); + error = TRUE; + } + /* look up the string and print an error if default strings are not used */ + strindex = get_defstr_index(field->name, driver, &error); + } + } + + /* free the config */ + input_port_config_free(portlist); return error; } @@ -1393,7 +1375,6 @@ int mame_validitychecks(const game_driver *curdriver) osd_ticks_t mess_checks = 0; #endif - input_port_entry *inputports = NULL; int drivnum; int error = FALSE; UINT16 lsbtest; @@ -1487,7 +1468,7 @@ int mame_validitychecks(const game_driver *curdriver) /* validate input ports */ input_checks -= osd_profiling_ticks(); - error = validate_inputs(drivnum, config, &inputports) || error; + error = validate_inputs(drivnum, config) || error; input_checks += osd_profiling_ticks(); /* validate sounds and speakers */ diff --git a/src/mame/audio/jedi.c b/src/mame/audio/jedi.c index 9b2194561f7..406c5212071 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 = machine->driver_data; + jedi_state *state = field->port->machine->driver_data; return *state->audio_comm_stat >> 6; } diff --git a/src/mame/drivers/acefruit.c b/src/mame/drivers/acefruit.c index 7fe1288e33c..8cd4a499718 100644 --- a/src/mame/drivers/acefruit.c +++ b/src/mame/drivers/acefruit.c @@ -146,9 +146,9 @@ static CUSTOM_INPUT( sidewndr_payout_r ) switch (bit_mask) { case 0x01: - return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 0); + return ((input_port_read(field->port->machine, "PAYOUT") & bit_mask) >> 0); case 0x02: - return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 1); + return ((input_port_read(field->port->machine, "PAYOUT") & bit_mask) >> 1); default: logerror("sidewndr_payout_r : invalid %02X bit_mask\n",bit_mask); return 0; @@ -162,13 +162,13 @@ static CUSTOM_INPUT( starspnr_coinage_r ) switch (bit_mask) { case 0x01: - return ((input_port_read(machine, "COINAGE") & bit_mask) >> 0); + return ((input_port_read(field->port->machine, "COINAGE") & bit_mask) >> 0); case 0x02: - return ((input_port_read(machine, "COINAGE") & bit_mask) >> 1); + return ((input_port_read(field->port->machine, "COINAGE") & bit_mask) >> 1); case 0x04: - return ((input_port_read(machine, "COINAGE") & bit_mask) >> 2); + return ((input_port_read(field->port->machine, "COINAGE") & bit_mask) >> 2); case 0x08: - return ((input_port_read(machine, "COINAGE") & bit_mask) >> 3); + return ((input_port_read(field->port->machine, "COINAGE") & bit_mask) >> 3); default: logerror("starspnr_coinage_r : invalid %02X bit_mask\n",bit_mask); return 0; @@ -182,11 +182,11 @@ static CUSTOM_INPUT( starspnr_payout_r ) switch (bit_mask) { case 0x01: - return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 0); + return ((input_port_read(field->port->machine, "PAYOUT") & bit_mask) >> 0); case 0x02: - return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 1); + return ((input_port_read(field->port->machine, "PAYOUT") & bit_mask) >> 1); case 0x04: - return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 2); + return ((input_port_read(field->port->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 d14232cdd69..90497a7ac20 100644 --- a/src/mame/drivers/alg.c +++ b/src/mame/drivers/alg.c @@ -244,7 +244,7 @@ static CUSTOM_INPUT( lightgun_pos_r ) int x = 0, y = 0; /* get the position based on the input select */ - get_lightgun_pos(machine->primary_screen, input_select, &x, &y); + get_lightgun_pos(field->port->machine->primary_screen, input_select, &x, &y); return (y << 8) | (x >> 2); } @@ -252,14 +252,14 @@ static CUSTOM_INPUT( lightgun_pos_r ) static CUSTOM_INPUT( lightgun_trigger_r ) { /* read the trigger control based on the input select */ - return (input_port_read(machine, "TRIGGERS") >> input_select) & 1; + return (input_port_read(field->port->machine, "TRIGGERS") >> input_select) & 1; } static CUSTOM_INPUT( lightgun_holster_r ) { /* read the holster control based on the input select */ - return (input_port_read(machine, "TRIGGERS") >> (2 + input_select)) & 1; + return (input_port_read(field->port->machine, "TRIGGERS") >> (2 + input_select)) & 1; } diff --git a/src/mame/drivers/argus.c b/src/mame/drivers/argus.c index 1922c0697f4..9b6a35bb284 100644 --- a/src/mame/drivers/argus.c +++ b/src/mame/drivers/argus.c @@ -554,7 +554,7 @@ static INPUT_PORTS_START( butasan ) PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW1:2" ) /* Listed as "Unused" */ PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW1:1" ) /* Listed as "Unused" */ - PORT_START_TAG("DSW2") + PORT_MODIFY("DSW2") PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW2:8") PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) diff --git a/src/mame/drivers/astinvad.c b/src/mame/drivers/astinvad.c index 74b45c8fcba..6d7cedad01d 100644 --- a/src/mame/drivers/astinvad.c +++ b/src/mame/drivers/astinvad.c @@ -212,7 +212,7 @@ static MACHINE_START( kamikaze ) static INPUT_CHANGED( spaceint_coin_inserted ) { /* coin insertion causes an NMI */ - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); } diff --git a/src/mame/drivers/astrocde.c b/src/mame/drivers/astrocde.c index d7453577f2b..716feb81dce 100644 --- a/src/mame/drivers/astrocde.c +++ b/src/mame/drivers/astrocde.c @@ -258,7 +258,7 @@ static WRITE8_HANDLER( seawolf2_sound_2_w ) // Port 41 static CUSTOM_INPUT( ebases_trackball_r ) { static const char *const names[] = { "TRACKX2", "TRACKY2", "TRACKX1", "TRACKY1" }; - return input_port_read(machine, names[input_select]); + return input_port_read(field->port->machine, names[input_select]); } @@ -474,7 +474,7 @@ static READ8_HANDLER( demndrgn_io_r ) static CUSTOM_INPUT( demndragn_joystick_r ) { static const char *const names[] = { "MOVEX", "MOVEY" }; - return input_port_read(machine, names[input_select]); + return input_port_read(field->port->machine, names[input_select]); } @@ -1740,8 +1740,8 @@ static DRIVER_INIT( demndrgn ) { astrocade_video_config = 0x00; memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x14, 0x14, 0x1fff, 0xff00, demndrgn_io_r); - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x1c, 0x1c, 0x0000, 0xff00, port_tag_to_handler8("FIREX")); - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x1d, 0x1d, 0x0000, 0xff00, port_tag_to_handler8("FIREY")); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x1c, 0x1c, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "FIREX")); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x1d, 0x1d, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "FIREY")); memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x97, 0x97, 0x0000, 0xff00, demndrgn_sound_w); /* reset banking */ @@ -1753,11 +1753,11 @@ static DRIVER_INIT( demndrgn ) static DRIVER_INIT( tenpindx ) { astrocade_video_config = 0x00; - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x60, 0x60, 0x0000, 0xff00, port_tag_to_handler8("P60")); - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x61, 0x61, 0x0000, 0xff00, port_tag_to_handler8("P61")); - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x62, 0x62, 0x0000, 0xff00, port_tag_to_handler8("P62")); - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x63, 0x63, 0x0000, 0xff00, port_tag_to_handler8("P63")); - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x64, 0x64, 0x0000, 0xff00, port_tag_to_handler8("P64")); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x60, 0x60, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "P60")); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x61, 0x61, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "P61")); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x62, 0x62, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "P62")); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x63, 0x63, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "P63")); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x64, 0x64, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "P64")); memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x65, 0x66, 0x0000, 0xff00, tenpindx_lamp_w); memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x67, 0x67, 0x0000, 0xff00, tenpindx_counter_w); memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x68, 0x68, 0x0000, 0xff00, tenpindx_lights_w); diff --git a/src/mame/drivers/astrof.c b/src/mame/drivers/astrof.c index bf88dc58566..f7e90b4c603 100644 --- a/src/mame/drivers/astrof.c +++ b/src/mame/drivers/astrof.c @@ -109,7 +109,7 @@ static TIMER_DEVICE_CALLBACK( irq_callback ) static INPUT_CHANGED( coin_inserted ) { /* coin insertion causes an NMI */ - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); coin_counter_w(0, newval); } @@ -117,13 +117,13 @@ static INPUT_CHANGED( coin_inserted ) static INPUT_CHANGED( service_coin_inserted ) { /* service coin insertion causes an NMI */ - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); } static CUSTOM_INPUT( astrof_p1_controls_r ) { - return input_port_read(machine, "P1"); + return input_port_read(field->port->machine, "P1"); } @@ -134,10 +134,10 @@ static CUSTOM_INPUT( astrof_p2_controls_r ) /* on an upright cabinets, a single set of controls is connected to both sets of pins on the edge connector */ - if (input_port_read(machine, "CAB")) - ret = input_port_read(machine, "P2"); + if (input_port_read(field->port->machine, "CAB")) + ret = input_port_read(field->port->machine, "P2"); else - ret = input_port_read(machine, "P1"); + ret = input_port_read(field->port->machine, "P1"); return ret; } diff --git a/src/mame/drivers/berzerk.c b/src/mame/drivers/berzerk.c index 81ddecc1ccc..15b565580cc 100644 --- a/src/mame/drivers/berzerk.c +++ b/src/mame/drivers/berzerk.c @@ -665,10 +665,10 @@ static INPUT_PORTS_START( berzerk ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_START /* IN3 */ - PORT_BIT( 0x01, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Input Test Mode") PORT_CODE(KEYCODE_F2) PORT_TOGGLE PORT_DIPLOCATION("F3:1") + PORT_DIPNAME( 0x01, 0x00, "Input Test Mode" ) PORT_CODE(KEYCODE_F2) PORT_TOGGLE PORT_DIPLOCATION("F3:1") PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) - PORT_BIT( 0x02, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Crosshair Pattern") PORT_CODE(KEYCODE_F4) PORT_TOGGLE PORT_DIPLOCATION("F3:2") + PORT_DIPNAME( 0x02, 0x00, "Crosshair Pattern" ) PORT_CODE(KEYCODE_F4) PORT_TOGGLE PORT_DIPLOCATION("F3:2") PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x02, DEF_STR( On ) ) PORT_BIT( 0x3c, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -679,7 +679,7 @@ static INPUT_PORTS_START( berzerk ) PORT_DIPSETTING( 0xc0, DEF_STR( Spanish ) ) PORT_START /* IN4 */ - PORT_BIT( 0x03, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Color Test") PORT_CODE(KEYCODE_F5) PORT_TOGGLE PORT_DIPLOCATION("F2:1,2") + PORT_DIPNAME( 0x03, 0x00, "Color Test" ) PORT_CODE(KEYCODE_F5) PORT_TOGGLE PORT_DIPLOCATION("F2:1,2") PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x03, DEF_STR( On ) ) PORT_BIT( 0x3c, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -768,10 +768,10 @@ static INPUT_PORTS_START( frenzy ) PORT_START /* IN4 */ PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Bit 0 does some more hardware tests */ - PORT_BIT( 0x04, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Input Test Mode") PORT_CODE(KEYCODE_F2) PORT_TOGGLE + PORT_DIPNAME( 0x04, 0x00, "Input Test Mode" ) PORT_CODE(KEYCODE_F2) PORT_TOGGLE PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x04, DEF_STR( On ) ) - PORT_BIT( 0x08, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Crosshair Pattern") PORT_CODE(KEYCODE_F4) PORT_TOGGLE + PORT_DIPNAME( 0x08, 0x00, "Crosshair Pattern" ) PORT_CODE(KEYCODE_F4) PORT_TOGGLE PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x08, DEF_STR( On ) ) PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED ) diff --git a/src/mame/drivers/brkthru.c b/src/mame/drivers/brkthru.c index cff1666f429..484b9ab3399 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 ) { /* coin insertion causes an IRQ */ - cpunum_set_input_line(machine, 0, 0, newval ? CLEAR_LINE : ASSERT_LINE); + cpunum_set_input_line(field->port->machine, 0, 0, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/btime.c b/src/mame/drivers/btime.c index 468ebeea80e..0845bae0b60 100644 --- a/src/mame/drivers/btime.c +++ b/src/mame/drivers/btime.c @@ -386,18 +386,18 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted_irq_hi ) { if (newval) - cpunum_set_input_line(machine, 0, 0, HOLD_LINE); + cpunum_set_input_line(field->port->machine, 0, 0, HOLD_LINE); } static INPUT_CHANGED( coin_inserted_irq_lo ) { if (!newval) - cpunum_set_input_line(machine, 0, 0, HOLD_LINE); + cpunum_set_input_line(field->port->machine, 0, 0, HOLD_LINE); } static INPUT_CHANGED( coin_inserted_nmi_lo ) { - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/ccastles.c b/src/mame/drivers/ccastles.c index 64976cee4f1..1014ce17625 100644 --- a/src/mame/drivers/ccastles.c +++ b/src/mame/drivers/ccastles.c @@ -187,7 +187,7 @@ static TIMER_CALLBACK( clock_irq ) static CUSTOM_INPUT( get_vblank ) { - int scanline = video_screen_get_vpos(machine->primary_screen); + int scanline = video_screen_get_vpos(field->port->machine->primary_screen); return syncprom[scanline & 0xff] & 1; } diff --git a/src/mame/drivers/cclimber.c b/src/mame/drivers/cclimber.c index cb16faa3f5e..f47bb0b0970 100644 --- a/src/mame/drivers/cclimber.c +++ b/src/mame/drivers/cclimber.c @@ -466,7 +466,7 @@ static INPUT_PORTS_START( cclimber ) PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) ) // Look code at 0x03c4 : 0x8076 is never tested ! PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x04, DEF_STR( On ) ) - PORT_BIT( 0x08, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x08, 0x00, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x08, DEF_STR( On ) ) PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) @@ -497,7 +497,7 @@ static INPUT_PORTS_START( cclimbrj ) PORT_DIPNAME( 0x04, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x00, "30000" ) PORT_DIPSETTING( 0x04, "50000" ) - PORT_BIT( 0x08, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x08, 0x00, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x08, DEF_STR( On ) ) PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) diff --git a/src/mame/drivers/cheekyms.c b/src/mame/drivers/cheekyms.c index e5d95831eb7..c9a05bdefd2 100644 --- a/src/mame/drivers/cheekyms.c +++ b/src/mame/drivers/cheekyms.c @@ -26,7 +26,7 @@ static INPUT_CHANGED( coin_inserted ) { /* this starts a 556 one-shot timer (and triggers a sound effect) */ if (newval) - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, PULSE_LINE); } diff --git a/src/mame/drivers/cidelsa.c b/src/mame/drivers/cidelsa.c index 59c2ab6ae71..a459957423d 100644 --- a/src/mame/drivers/cidelsa.c +++ b/src/mame/drivers/cidelsa.c @@ -373,14 +373,14 @@ ADDRESS_MAP_END static CUSTOM_INPUT( cdp1869_pcb_r ) { - cidelsa_state *state = machine->driver_data; + cidelsa_state *state = field->port->machine->driver_data; return state->cdp1869_pcb; } static CUSTOM_INPUT( cdp1869_predisplay_r ) { - cidelsa_state *state = machine->driver_data; + cidelsa_state *state = field->port->machine->driver_data; return state->cdp1869_prd; } diff --git a/src/mame/drivers/cinemat.c b/src/mame/drivers/cinemat.c index 3952cdbefb4..1ca649365fd 100644 --- a/src/mame/drivers/cinemat.c +++ b/src/mame/drivers/cinemat.c @@ -151,12 +151,8 @@ static WRITE8_HANDLER( mux_select_w ) static UINT8 joystick_read(void) { - if (port_tag_to_index("ANALOGX") != -1) - { - int xval = (INT16)(cpunum_get_reg(0, CCPU_X) << 4) >> 4; - return (input_port_read(Machine, mux_select ? "ANALOGX" : "ANALOGY") - xval) < 0x800; - } - return 0; + int xval = (INT16)(cpunum_get_reg(0, CCPU_X) << 4) >> 4; + return (input_port_read_safe(Machine, mux_select ? "ANALOGX" : "ANALOGY", 0) - xval) < 0x800; } diff --git a/src/mame/drivers/cloud9.c b/src/mame/drivers/cloud9.c index 722cd923150..4ee4d3f0649 100644 --- a/src/mame/drivers/cloud9.c +++ b/src/mame/drivers/cloud9.c @@ -154,7 +154,7 @@ static TIMER_CALLBACK( clock_irq ) static CUSTOM_INPUT( get_vblank ) { - int scanline = video_screen_get_vpos(machine->primary_screen); + int scanline = video_screen_get_vpos(field->port->machine->primary_screen); return (~syncprom[scanline & 0xff] >> 1) & 1; } diff --git a/src/mame/drivers/crbaloon.c b/src/mame/drivers/crbaloon.c index c4fd3ba595d..a88c111258f 100644 --- a/src/mame/drivers/crbaloon.c +++ b/src/mame/drivers/crbaloon.c @@ -75,7 +75,7 @@ static CUSTOM_INPUT( pc3092_r ) /* enable coin & start input? Wild guess!!! */ if (pc3092_data[1] & 0x02) - ret = input_port_read(machine, "PC3092"); + ret = input_port_read(field->port->machine, "PC3092"); else ret = 0x00; diff --git a/src/mame/drivers/dorachan.c b/src/mame/drivers/dorachan.c index db12498e9d8..c75e04aa802 100644 --- a/src/mame/drivers/dorachan.c +++ b/src/mame/drivers/dorachan.c @@ -119,7 +119,7 @@ static CUSTOM_INPUT( dorachan_v128_r ) { /* to avoid resetting (when player 2 starts) bit 0 need to be inverted when screen is flipped */ - return ((video_screen_get_vpos(machine->primary_screen) >> 7) & 0x01) ^ dorachan_flip_screen; + return ((video_screen_get_vpos(field->port->machine->primary_screen) >> 7) & 0x01) ^ dorachan_flip_screen; } diff --git a/src/mame/drivers/enigma2.c b/src/mame/drivers/enigma2.c index 4a0a410f3c4..46ae89e3be6 100644 --- a/src/mame/drivers/enigma2.c +++ b/src/mame/drivers/enigma2.c @@ -375,16 +375,16 @@ static WRITE8_HANDLER( enigma2_flip_screen_w ) static CUSTOM_INPUT( p1_controls_r ) { - return input_port_read(machine, "P1CONTROLS"); + return input_port_read(field->port->machine, "P1CONTROLS"); } static CUSTOM_INPUT( p2_controls_r ) { if (engima2_flip_screen) - return input_port_read(machine, "P2CONTROLS"); + return input_port_read(field->port->machine, "P2CONTROLS"); else - return input_port_read(machine, "P1CONTROLS"); + return input_port_read(field->port->machine, "P1CONTROLS"); } diff --git a/src/mame/drivers/exerion.c b/src/mame/drivers/exerion.c index 4c22a05d70d..b669a13791d 100644 --- a/src/mame/drivers/exerion.c +++ b/src/mame/drivers/exerion.c @@ -38,7 +38,7 @@ static READ8_HANDLER( exerion_port01_r ) static INPUT_CHANGED( coin_inserted ) { /* coin insertion causes an NMI */ - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/exidy.c b/src/mame/drivers/exidy.c index b35732c76cd..b65463849b9 100644 --- a/src/mame/drivers/exidy.c +++ b/src/mame/drivers/exidy.c @@ -145,7 +145,7 @@ static UINT8 last_dial; static CUSTOM_INPUT( teetert_input_direction_r ) { int result = 0; - UINT8 dial = input_port_read(machine, "DIAL"); + UINT8 dial = input_port_read(field->port->machine, "DIAL"); if (dial != last_dial) { @@ -164,7 +164,7 @@ static CUSTOM_INPUT( teetert_input_direction_r ) static CUSTOM_INPUT( teetert_input_movement_r ) { - UINT8 dial = input_port_read(machine, "DIAL"); + UINT8 dial = input_port_read(field->port->machine, "DIAL"); return (dial != last_dial) ? 1 : 0; } @@ -500,7 +500,7 @@ static INPUT_PORTS_START( mtrap ) PORT_START_TAG("IN2") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Yellow Button") PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Red Button") - PORT_BIT( 0x04, 0x04, IPT_DIPSWITCH_NAME ) PORT_NAME( DEF_STR( Free_Play )) + PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) ) PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Blue Button") diff --git a/src/mame/drivers/exidy440.c b/src/mame/drivers/exidy440.c index 6605bc1f3b1..ae0e76f5d68 100644 --- a/src/mame/drivers/exidy440.c +++ b/src/mame/drivers/exidy440.c @@ -264,7 +264,7 @@ static INPUT_CHANGED( coin_inserted ) { /* if we got a coin, set the IRQ on the main CPU */ if (newval == 0) - cpunum_set_input_line(machine, 0, 0, ASSERT_LINE); + cpunum_set_input_line(field->port->machine, 0, 0, ASSERT_LINE); } @@ -290,7 +290,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(machine, "HITNMISS_BUTTON1"); + UINT32 button1 = input_port_read(field->port->machine, "HITNMISS_BUTTON1"); return (button1 << 1) | button1; } diff --git a/src/mame/drivers/fantland.c b/src/mame/drivers/fantland.c index 2c2ad7f0be1..2b47de0ab26 100644 --- a/src/mame/drivers/fantland.c +++ b/src/mame/drivers/fantland.c @@ -696,7 +696,7 @@ INPUT_PORTS_END static CUSTOM_INPUT( wheelrun_wheel_r ) { int player = (FPTR)param; - int delta = input_port_read_indexed(machine, 4 + player); + int delta = input_port_read_indexed(field->port->machine, 4 + player); 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 75abbca4c16..bc640aa63cd 100644 --- a/src/mame/drivers/fcombat.c +++ b/src/mame/drivers/fcombat.c @@ -61,7 +61,7 @@ extern int fcombat_sv; static INPUT_CHANGED( coin_inserted ) { /* coin insertion causes an NMI */ - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/firetrk.c b/src/mame/drivers/firetrk.c index 9f8e6035d9a..cddaa39c7ba 100644 --- a/src/mame/drivers/firetrk.c +++ b/src/mame/drivers/firetrk.c @@ -34,13 +34,13 @@ static void set_service_mode(running_machine *machine, int enable) static INPUT_CHANGED( service_mode_switch_changed ) { - set_service_mode(machine, newval); + set_service_mode(field->port->machine, newval); } static INPUT_CHANGED( firetrk_horn_changed ) { - discrete_sound_w(machine, FIRETRUCK_HORN_EN, newval); + discrete_sound_w(field->port->machine, FIRETRUCK_HORN_EN, newval); } diff --git a/src/mame/drivers/flstory.c b/src/mame/drivers/flstory.c index c494b7bee76..10014e6dcab 100644 --- a/src/mame/drivers/flstory.c +++ b/src/mame/drivers/flstory.c @@ -373,7 +373,7 @@ static INPUT_PORTS_START( flstory ) PORT_DIPNAME( 0x20, 0x20, "Leave Off") // Check code at 0x7859 PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) // (must be OFF or the game will PORT_DIPSETTING( 0x00, DEF_STR( On ) ) // hang after the game is over !) - PORT_BIT( 0x40, 0x40, IPT_DIPSWITCH_NAME ) PORT_NAME("Invulnerability (Cheat)") + PORT_DIPNAME( 0x40, 0x40, "Invulnerability (Cheat)" ) PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x80, "Coin Slots" ) diff --git a/src/mame/drivers/galaxian.c b/src/mame/drivers/galaxian.c index 91fa3e4fcd5..8d81d684bd6 100644 --- a/src/mame/drivers/galaxian.c +++ b/src/mame/drivers/galaxian.c @@ -841,13 +841,13 @@ static INPUT_CHANGED( gmgalax_game_changed ) /* select the bank and graphics bank based on it */ memory_set_bank(1, gmgalax_selected_game); - galaxian_gfxbank_w(machine, 0, gmgalax_selected_game); + galaxian_gfxbank_w(field->port->machine, 0, gmgalax_selected_game); /* reset the starts */ - galaxian_stars_enable_w(machine, 0, 0); + galaxian_stars_enable_w(field->port->machine, 0, 0); /* reset the CPU */ - cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, PULSE_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_RESET, PULSE_LINE); } @@ -856,7 +856,7 @@ static CUSTOM_INPUT( gmgalax_port_r ) const char *portname = param; if (gmgalax_selected_game != 0) portname += strlen(portname) + 1; - return input_port_read(machine, portname); + return input_port_read(field->port->machine, portname); } @@ -912,7 +912,7 @@ static WRITE8_HANDLER( zigzag_ay8910_w ) static CUSTOM_INPUT( azurian_port_r ) { - return (input_port_read(machine, "FAKE") >> (FPTR)param) & 1; + return (input_port_read(field->port->machine, "FAKE") >> (FPTR)param) & 1; } @@ -926,7 +926,7 @@ static CUSTOM_INPUT( azurian_port_r ) static CUSTOM_INPUT( kingball_muxbit_r ) { /* multiplex the service mode switch with a speech DIP switch */ - return (input_port_read(machine, "FAKE") >> kingball_speech_dip) & 1; + return (input_port_read(field->port->machine, "FAKE") >> kingball_speech_dip) & 1; } @@ -935,7 +935,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 mame_rand(machine) & 1; + return mame_rand(field->port->machine) & 1; } @@ -2323,7 +2323,7 @@ static DRIVER_INIT( gmgalax ) memory_configure_bank(1, 0, 2, memory_region(REGION_CPU1) + 0x10000, 0x4000); /* callback when the game select is toggled */ - gmgalax_game_changed(machine, NULL, 0, 0); + gmgalax_game_changed(machine->portconfig->fieldlist, NULL, 0, 0); state_save_register_global(gmgalax_selected_game); } diff --git a/src/mame/drivers/galdrvr.c b/src/mame/drivers/galdrvr.c index 5c8d9a482de..41e3e9d3a2b 100644 --- a/src/mame/drivers/galdrvr.c +++ b/src/mame/drivers/galdrvr.c @@ -755,7 +755,7 @@ INPUT_PORTS_START( gmgalax ) PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START_TAG("GAMESEL") /* fake - game select */ - PORT_BIT( 0x01, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Game Select") PORT_CODE(KEYCODE_F1) PORT_TOGGLE PORT_CHANGED(gmgalax_game_changed, NULL) + PORT_DIPNAME( 0x01, 0x00, "Game Select") PORT_CODE(KEYCODE_F1) PORT_TOGGLE PORT_CHANGED(gmgalax_game_changed, NULL) PORT_DIPSETTING( 0x00, "Ghost Muncher" ) PORT_DIPSETTING( 0x01, "Galaxian" ) INPUT_PORTS_END diff --git a/src/mame/drivers/gauntlet.c b/src/mame/drivers/gauntlet.c index 588c6d92737..1fa9c5785e6 100644 --- a/src/mame/drivers/gauntlet.c +++ b/src/mame/drivers/gauntlet.c @@ -378,7 +378,6 @@ ADDRESS_MAP_END static INPUT_PORTS_START( gauntlet ) PORT_START_TAG("IN0") /* 803000 */ - PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -389,7 +388,6 @@ static INPUT_PORTS_START( gauntlet ) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START_TAG("IN1") /* 803002 */ - PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -400,7 +398,6 @@ static INPUT_PORTS_START( gauntlet ) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START_TAG("IN2") /* 803004 */ - PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START3 ) PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3) PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3) PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -411,7 +408,6 @@ static INPUT_PORTS_START( gauntlet ) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START_TAG("IN3") /* 803006 */ - PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START4 ) PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(4) PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(4) PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED ) diff --git a/src/mame/drivers/hyperspt.c b/src/mame/drivers/hyperspt.c index 7f81174219f..edea39f0c6e 100644 --- a/src/mame/drivers/hyperspt.c +++ b/src/mame/drivers/hyperspt.c @@ -63,71 +63,13 @@ static READ8_HANDLER( konami_IN1_r ) */ static UINT8 *nvram; static size_t nvram_size; -static int we_flipped_the_switch; static NVRAM_HANDLER( hyperspt ) { if (read_or_write) - { mame_fwrite(file,nvram,nvram_size); - - if (we_flipped_the_switch) - { - input_port_entry *in; - - - /* find the dip switch which resets the high score table, and set it */ - /* back to off. */ - in = machine->input_ports; - - while (in->type != IPT_END) - { - if (in->name != NULL && in->name != IP_NAME_DEFAULT && - strcmp(in->name,"World Records") == 0) - { - if (in->default_value == 0) - in->default_value = in->mask; - break; - } - - in++; - } - - we_flipped_the_switch = 0; - } - } - else - { - if (file) - { - mame_fread(file,nvram,nvram_size); - we_flipped_the_switch = 0; - } - else - { - input_port_entry *in; - - - /* find the dip switch which resets the high score table, and set it on */ - in = machine->input_ports; - - while (in->type != IPT_END) - { - if (in->name != NULL && in->name != IP_NAME_DEFAULT && - strcmp(in->name,"World Records") == 0) - { - if (in->default_value == in->mask) - { - in->default_value = 0; - we_flipped_the_switch = 1; - } - break; - } - - in++; - } - } - } + else if (file) + mame_fread(file,nvram,nvram_size); } diff --git a/src/mame/drivers/jrpacman.c b/src/mame/drivers/jrpacman.c index 6abaf659d7b..3d77f80f74d 100644 --- a/src/mame/drivers/jrpacman.c +++ b/src/mame/drivers/jrpacman.c @@ -160,7 +160,7 @@ static INPUT_PORTS_START( jrpacman ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY - PORT_BIT( 0x10, 0x10, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x10, 0x10, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) diff --git a/src/mame/drivers/ksys573.c b/src/mame/drivers/ksys573.c index 4c34482b950..9df11277b4c 100644 --- a/src/mame/drivers/ksys573.c +++ b/src/mame/drivers/ksys573.c @@ -1880,7 +1880,7 @@ static void gn845pwbb_clk_w( int offset, int data ) static CUSTOM_INPUT( gn845pwbb_read ) { - return input_port_read(machine, "STAGE" ) & stage_mask; + return input_port_read(field->port->machine, "STAGE" ) & stage_mask; } static void gn845pwbb_output_callback( int offset, int data ) diff --git a/src/mame/drivers/ladybug.c b/src/mame/drivers/ladybug.c index 526c9805e0a..86b9258daf9 100644 --- a/src/mame/drivers/ladybug.c +++ b/src/mame/drivers/ladybug.c @@ -138,14 +138,14 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin1_inserted ) { /* left coin insertion causes an NMI */ - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); } static INPUT_CHANGED( coin2_inserted ) { /* right coin insertion causes an IRQ */ if (newval) - cpunum_set_input_line(machine, 0, 0, HOLD_LINE); + cpunum_set_input_line(field->port->machine, 0, 0, HOLD_LINE); } @@ -154,7 +154,7 @@ static INPUT_CHANGED( coin2_inserted ) static CUSTOM_INPUT( ladybug_p1_control_r ) { - return input_port_read(machine, LADYBUG_P1_CONTROL_PORT_TAG); + return input_port_read(field->port->machine, LADYBUG_P1_CONTROL_PORT_TAG); } static CUSTOM_INPUT( ladybug_p2_control_r ) @@ -162,10 +162,10 @@ static CUSTOM_INPUT( ladybug_p2_control_r ) UINT32 ret; /* upright cabinet only uses a single set of controls */ - if (input_port_read(machine, "DSW0") & 0x20) - ret = input_port_read(machine, LADYBUG_P2_CONTROL_PORT_TAG); + if (input_port_read(field->port->machine, "DSW0") & 0x20) + ret = input_port_read(field->port->machine, LADYBUG_P2_CONTROL_PORT_TAG); else - ret = input_port_read(machine, LADYBUG_P1_CONTROL_PORT_TAG); + ret = input_port_read(field->port->machine, LADYBUG_P1_CONTROL_PORT_TAG); return ret; } @@ -202,7 +202,7 @@ static INPUT_PORTS_START( ladybug ) PORT_DIPNAME( 0x04, 0x04, "High Score Names" ) PORT_DIPSETTING( 0x00, "3 Letters" ) PORT_DIPSETTING( 0x04, "10 Letters" ) - PORT_BIT( 0x08, 0x08, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x08, 0x08, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x10, 0x10, "Freeze" ) @@ -474,7 +474,7 @@ static INPUT_PORTS_START( dorodon ) PORT_DIPNAME( 0x04, 0x04, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x04, "20000" ) PORT_DIPSETTING( 0x00, "30000" ) - PORT_BIT( 0x08, 0x08, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x08, 0x08, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x10, 0x10, "Freeze" ) diff --git a/src/mame/drivers/lasso.c b/src/mame/drivers/lasso.c index 3c07046a558..f18676fe3b8 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 ) { /* coin insertion causes an NMI */ - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/lethalj.c b/src/mame/drivers/lethalj.c index 8d7d733f3e3..a288c073c60 100644 --- a/src/mame/drivers/lethalj.c +++ b/src/mame/drivers/lethalj.c @@ -64,13 +64,13 @@ Note 2: Lethal Justice uses a TMS34010FNL-50 instead of the TMS34010FNL-40 static CUSTOM_INPUT( ticket_status ) { - return ticket_dispenser_0_r(machine, 0) >> 7; + return ticket_dispenser_0_r(field->port->machine, 0) >> 7; } static CUSTOM_INPUT( cclownz_paddle ) { - int value = input_port_read(machine, "PADDLE"); + int value = input_port_read(field->port->machine, "PADDLE"); return ((value << 4) & 0xf00) | (value & 0x00f); } diff --git a/src/mame/drivers/m10.c b/src/mame/drivers/m10.c index a6d11fef97d..80ecdf41b9d 100644 --- a/src/mame/drivers/m10.c +++ b/src/mame/drivers/m10.c @@ -429,7 +429,7 @@ static READ8_HANDLER( m11_a700_r ) static INPUT_CHANGED( coin_inserted ) { /* coin insertion causes an NMI */ - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); } diff --git a/src/mame/drivers/m62.c b/src/mame/drivers/m62.c index e1ce755b366..535310898f6 100644 --- a/src/mame/drivers/m62.c +++ b/src/mame/drivers/m62.c @@ -853,7 +853,7 @@ static INPUT_PORTS_START( ldrun4 ) PORT_DIPNAME( 0x40, 0x40, "Invulnerability (Cheat)") PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_BIT( 0x80, 0x80, IPT_DIPSWITCH_NAME ) PORT_NAME("Service Mode (must set 2P game to No)") PORT_TOGGLE PORT_CODE(KEYCODE_F2) + PORT_DIPNAME( 0x80, 0x80, "Service Mode (must set 2P game to No)" ) PORT_TOGGLE PORT_CODE(KEYCODE_F2) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) INPUT_PORTS_END diff --git a/src/mame/drivers/madalien.c b/src/mame/drivers/madalien.c index 33dee8294fc..f49877b897f 100644 --- a/src/mame/drivers/madalien.c +++ b/src/mame/drivers/madalien.c @@ -22,7 +22,7 @@ static UINT8 *shift_lo; static INPUT_CHANGED( coin_inserted ) { /* coin insertion causes an NMI */ - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/mappy.c b/src/mame/drivers/mappy.c index 299fd760925..d47ff25c273 100644 --- a/src/mame/drivers/mappy.c +++ b/src/mame/drivers/mappy.c @@ -1260,7 +1260,7 @@ NAMCO_56DSW0 PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x20, DEF_STR( On ) ) - PORT_BIT( 0x40, 0x40, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x40, 0x40, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x80, "Freeze" ) diff --git a/src/mame/drivers/maxaflex.c b/src/mame/drivers/maxaflex.c index cd49fd451fc..c5f4b303865 100644 --- a/src/mame/drivers/maxaflex.c +++ b/src/mame/drivers/maxaflex.c @@ -226,7 +226,7 @@ static MACHINE_RESET(supervisor_board) static INPUT_CHANGED( coin_inserted ) { if (!newval) - cpunum_set_input_line(machine, 1, M6805_IRQ_LINE, HOLD_LINE ); + cpunum_set_input_line(field->port->machine, 1, M6805_IRQ_LINE, HOLD_LINE ); } int atari_input_disabled(void) diff --git a/src/mame/drivers/mcr3.c b/src/mame/drivers/mcr3.c index b2ca4d686c3..49d38376807 100644 --- a/src/mame/drivers/mcr3.c +++ b/src/mame/drivers/mcr3.c @@ -718,7 +718,7 @@ static INPUT_PORTS_START( rampage ) PORT_DIPSETTING( 0x40, DEF_STR( 1C_4C ) ) PORT_DIPSETTING( 0x30, DEF_STR( 1C_5C ) ) PORT_DIPSETTING( 0x20, DEF_STR( 1C_6C ) ) - PORT_BIT( 0x80, 0x80, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Advance (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x80, 0x80, "Rack Advance (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -779,7 +779,7 @@ static INPUT_PORTS_START( powerdrv ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) - PORT_BIT( 0x80, 0x80, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Advance (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x80, 0x80, "Rack Advance (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) diff --git a/src/mame/drivers/mcr68.c b/src/mame/drivers/mcr68.c index 3443e819e07..778998be2a6 100644 --- a/src/mame/drivers/mcr68.c +++ b/src/mame/drivers/mcr68.c @@ -561,7 +561,7 @@ static INPUT_PORTS_START( spyhunt2 ) PORT_DIPSETTING( 0x0040, "45 sec" ) PORT_DIPSETTING( 0x0060, "60 sec" ) PORT_DIPSETTING( 0x0020, "90 sec" ) - PORT_BIT( 0x0080, 0x0080, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Advance (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x0080, 0x0080, "Rack Advance (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -626,7 +626,7 @@ static INPUT_PORTS_START( blasted ) PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0040, DEF_STR( On ) ) - PORT_BIT( 0x0080, 0x0080, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Advance (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x0080, 0x0080, "Rack Advance (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) diff --git a/src/mame/drivers/meadows.c b/src/mame/drivers/meadows.c index d82f29c0ea9..6c6b1e7daf8 100644 --- a/src/mame/drivers/meadows.c +++ b/src/mame/drivers/meadows.c @@ -207,7 +207,7 @@ static WRITE8_HANDLER( meadows_audio_w ) static INPUT_CHANGED( coin_inserted ) { - cpunum_set_input_line_and_vector(machine, 0, 0, (newval ? ASSERT_LINE : CLEAR_LINE), 0x82); + cpunum_set_input_line_and_vector(field->port->machine, 0, 0, (newval ? ASSERT_LINE : CLEAR_LINE), 0x82); } diff --git a/src/mame/drivers/midzeus.c b/src/mame/drivers/midzeus.c index 1aec80aa113..6e66a6afb79 100644 --- a/src/mame/drivers/midzeus.c +++ b/src/mame/drivers/midzeus.c @@ -451,7 +451,7 @@ static CUSTOM_INPUT( custom_49way_r ) static const UINT8 translate49[7] = { 0x8, 0xc, 0xe, 0xf, 0x3, 0x1, 0x0 }; const char *namex = param; const char *namey = namex + strlen(namex) + 1; - return (translate49[input_port_read(machine, namey) >> 4] << 4) | translate49[input_port_read(machine, namex) >> 4]; + return (translate49[input_port_read(field->port->machine, namey) >> 4] << 4) | translate49[input_port_read(field->port->machine, namex) >> 4]; } @@ -464,7 +464,7 @@ static WRITE32_HANDLER( keypad_select_w ) static CUSTOM_INPUT( keypad_r ) { - UINT32 bits = input_port_read(machine, param); + UINT32 bits = input_port_read(field->port->machine, param); UINT8 select = keypad_select; while ((select & 1) != 0) { diff --git a/src/mame/drivers/missile.c b/src/mame/drivers/missile.c index 492eaca824f..3ca8589f0c1 100644 --- a/src/mame/drivers/missile.c +++ b/src/mame/drivers/missile.c @@ -328,7 +328,7 @@ static TIMER_CALLBACK( clock_irq ) static CUSTOM_INPUT( get_vblank ) { - int v = scanline_to_v(video_screen_get_vpos(machine->primary_screen)); + int v = scanline_to_v(video_screen_get_vpos(field->port->machine->primary_screen)); return v < 24; } diff --git a/src/mame/drivers/mw8080bw.c b/src/mame/drivers/mw8080bw.c index bc64e67bca0..5688249bad2 100644 --- a/src/mame/drivers/mw8080bw.c +++ b/src/mame/drivers/mw8080bw.c @@ -318,8 +318,8 @@ static WRITE8_HANDLER( seawolf_periscope_lamp_w ) static CUSTOM_INPUT( seawolf_erase_input_r ) { - return input_port_read(machine, SEAWOLF_ERASE_SW_PORT_TAG) & - input_port_read(machine, SEAWOLF_ERASE_DIP_PORT_TAG); + return input_port_read(field->port->machine, SEAWOLF_ERASE_SW_PORT_TAG) & + input_port_read(field->port->machine, SEAWOLF_ERASE_DIP_PORT_TAG); } @@ -549,7 +549,7 @@ UINT8 tornbase_get_cabinet_type(running_machine *machine) static CUSTOM_INPUT( tornbase_hit_left_input_r ) { - return input_port_read(machine, TORNBASE_L_HIT_PORT_TAG); + return input_port_read(field->port->machine, TORNBASE_L_HIT_PORT_TAG); } @@ -557,16 +557,16 @@ static CUSTOM_INPUT( tornbase_hit_right_input_r ) { UINT32 ret; - switch (tornbase_get_cabinet_type(machine)) + switch (tornbase_get_cabinet_type(field->port->machine)) { case TORNBASE_CAB_TYPE_UPRIGHT_OLD: - ret = input_port_read(machine, TORNBASE_L_HIT_PORT_TAG); + ret = input_port_read(field->port->machine, TORNBASE_L_HIT_PORT_TAG); break; case TORNBASE_CAB_TYPE_UPRIGHT_NEW: case TORNBASE_CAB_TYPE_COCKTAIL: default: - ret = input_port_read(machine, TORNBASE_R_HIT_PORT_TAG); + ret = input_port_read(field->port->machine, TORNBASE_R_HIT_PORT_TAG); break; } @@ -578,16 +578,16 @@ static CUSTOM_INPUT( tornbase_pitch_left_input_r ) { UINT32 ret; - switch (tornbase_get_cabinet_type(machine)) + switch (tornbase_get_cabinet_type(field->port->machine)) { case TORNBASE_CAB_TYPE_UPRIGHT_OLD: case TORNBASE_CAB_TYPE_UPRIGHT_NEW: - ret = input_port_read(machine, TORNBASE_L_PITCH_PORT_TAG); + ret = input_port_read(field->port->machine, TORNBASE_L_PITCH_PORT_TAG); break; case TORNBASE_CAB_TYPE_COCKTAIL: default: - ret = input_port_read(machine, TORNBASE_R_PITCH_PORT_TAG); + ret = input_port_read(field->port->machine, TORNBASE_R_PITCH_PORT_TAG); break; } @@ -597,14 +597,14 @@ static CUSTOM_INPUT( tornbase_pitch_left_input_r ) static CUSTOM_INPUT( tornbase_pitch_right_input_r ) { - return input_port_read(machine, TORNBASE_L_PITCH_PORT_TAG); + return input_port_read(field->port->machine, TORNBASE_L_PITCH_PORT_TAG); } static CUSTOM_INPUT( tornbase_score_input_r ) { - return input_port_read(machine, TORNBASE_SCORE_SW_PORT_TAG) & - input_port_read(machine, TORNBASE_SCORE_DIP_PORT_TAG); + return input_port_read(field->port->machine, TORNBASE_SCORE_SW_PORT_TAG) & + input_port_read(field->port->machine, TORNBASE_SCORE_DIP_PORT_TAG); } @@ -1181,9 +1181,9 @@ static CUSTOM_INPUT( desertgu_gun_input_r ) UINT32 ret; if (desertgu_controller_select) - ret = input_port_read(machine, DESERTGU_GUN_X_PORT_TAG); + ret = input_port_read(field->port->machine, DESERTGU_GUN_X_PORT_TAG); else - ret = input_port_read(machine, DESERTGU_GUN_Y_PORT_TAG); + ret = input_port_read(field->port->machine, DESERTGU_GUN_Y_PORT_TAG); return ret; } @@ -1194,9 +1194,9 @@ static CUSTOM_INPUT( desertgu_dip_sw_0_1_r ) UINT32 ret; if (desertgu_controller_select) - ret = input_port_read(machine, DESERTGU_DIP_SW_0_1_SET_2_TAG); + ret = input_port_read(field->port->machine, DESERTGU_DIP_SW_0_1_SET_2_TAG); else - ret = input_port_read(machine, DESERTGU_DIP_SW_0_1_SET_1_TAG); + ret = input_port_read(field->port->machine, DESERTGU_DIP_SW_0_1_SET_1_TAG); return ret; } @@ -1307,10 +1307,10 @@ static CUSTOM_INPUT( dplay_pitch_left_input_r ) { UINT32 ret; - if (input_port_read(machine, DPLAY_CAB_TYPE_PORT_TAG) == DPLAY_CAB_TYPE_UPRIGHT) - ret = input_port_read(machine, DPLAY_L_PITCH_PORT_TAG); + 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); else - ret = input_port_read(machine, DPLAY_R_PITCH_PORT_TAG); + ret = input_port_read(field->port->machine, DPLAY_R_PITCH_PORT_TAG); return ret; } @@ -1318,7 +1318,7 @@ static CUSTOM_INPUT( dplay_pitch_left_input_r ) static CUSTOM_INPUT( dplay_pitch_right_input_r ) { - return input_port_read(machine, DPLAY_L_PITCH_PORT_TAG); + return input_port_read(field->port->machine, DPLAY_L_PITCH_PORT_TAG); } @@ -1697,11 +1697,11 @@ static CUSTOM_INPUT( clowns_controller_r ) if (clowns_controller_select) { - ret = input_port_read(machine, CLOWNS_CONTROLLER_P2_TAG); + ret = input_port_read(field->port->machine, CLOWNS_CONTROLLER_P2_TAG); } else { - ret = input_port_read(machine, CLOWNS_CONTROLLER_P1_TAG); + ret = input_port_read(field->port->machine, CLOWNS_CONTROLLER_P1_TAG); } return ret; @@ -2446,7 +2446,7 @@ void invaders_set_flip_screen(UINT8 data) static CUSTOM_INPUT( invaders_coin_input_r ) { - UINT32 ret = input_port_read(machine, INVADERS_COIN_INPUT_PORT_TAG); + UINT32 ret = input_port_read(field->port->machine, INVADERS_COIN_INPUT_PORT_TAG); coin_counter_w(0, !ret); @@ -2461,10 +2461,10 @@ static CUSTOM_INPUT( invaders_sw6_sw7_r ) /* upright PCB : switches visible cocktail PCB: HI */ - if (invaders_is_cabinet_cocktail(machine)) + if (invaders_is_cabinet_cocktail(field->port->machine)) ret = 0x03; else - ret = input_port_read(machine, INVADERS_SW6_SW7_PORT_TAG); + ret = input_port_read(field->port->machine, INVADERS_SW6_SW7_PORT_TAG); return ret; } @@ -2477,10 +2477,10 @@ static CUSTOM_INPUT( invaders_sw5_r ) /* upright PCB : switch visible cocktail PCB: HI */ - if (invaders_is_cabinet_cocktail(machine)) + if (invaders_is_cabinet_cocktail(field->port->machine)) ret = 0x01; else - ret = input_port_read(machine, INVADERS_SW5_PORT_TAG); + ret = input_port_read(field->port->machine, INVADERS_SW5_PORT_TAG); return ret; } @@ -2493,10 +2493,10 @@ static CUSTOM_INPUT( invaders_in0_control_r ) /* upright PCB : P1 controls cocktail PCB: HI */ - if (invaders_is_cabinet_cocktail(machine)) + if (invaders_is_cabinet_cocktail(field->port->machine)) ret = 0x07; else - ret = input_port_read(machine, INVADERS_P1_CONTROL_PORT_TAG); + ret = input_port_read(field->port->machine, INVADERS_P1_CONTROL_PORT_TAG); return ret; } @@ -2509,10 +2509,10 @@ CUSTOM_INPUT( invaders_in2_control_r ) /* upright PCB : P1 controls cocktail PCB: P2 controls */ - if (invaders_is_cabinet_cocktail(machine)) - ret = input_port_read(machine, INVADERS_P2_CONTROL_PORT_TAG); + if (invaders_is_cabinet_cocktail(field->port->machine)) + ret = input_port_read(field->port->machine, INVADERS_P2_CONTROL_PORT_TAG); else - ret = input_port_read(machine, INVADERS_P1_CONTROL_PORT_TAG); + ret = input_port_read(field->port->machine, INVADERS_P1_CONTROL_PORT_TAG); return ret; } @@ -2646,7 +2646,7 @@ MACHINE_DRIVER_END static CUSTOM_INPUT( blueshrk_coin_input_r ) { - UINT32 ret = input_port_read(machine, BLUESHRK_COIN_INPUT_PORT_TAG); + UINT32 ret = input_port_read(field->port->machine, BLUESHRK_COIN_INPUT_PORT_TAG); coin_counter_w(0, !ret); diff --git a/src/mame/drivers/mystston.c b/src/mame/drivers/mystston.c index d0052cd8287..d0291e16d7f 100644 --- a/src/mame/drivers/mystston.c +++ b/src/mame/drivers/mystston.c @@ -58,7 +58,7 @@ static WRITE8_HANDLER( irq_clear_w ) static INPUT_CHANGED( coin_inserted ) { /* coin insertion causes an NMI */ - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); } diff --git a/src/mame/drivers/namcos12.c b/src/mame/drivers/namcos12.c index c0369c594d4..6fd69ada80b 100644 --- a/src/mame/drivers/namcos12.c +++ b/src/mame/drivers/namcos12.c @@ -1382,10 +1382,10 @@ static WRITE8_HANDLER( s12_mcu_settings_w ) static READ8_HANDLER( s12_mcu_gun_h_r ) { - int index = port_tag_to_index("IN3"); - if( index != -1 ) + const input_port_config *port = input_port_by_tag(machine->portconfig, "IN3"); + if( port != NULL ) { - int rv = input_port_read_indexed(machine, index ) << 6; + int rv = input_port_read_direct( port ) << 6; if( ( offset & 1 ) != 0 ) { @@ -1401,10 +1401,10 @@ static READ8_HANDLER( s12_mcu_gun_h_r ) static READ8_HANDLER( s12_mcu_gun_v_r ) { - int index = port_tag_to_index("IN4"); - if( index != -1 ) + const input_port_config *port = input_port_by_tag(machine->portconfig, "IN4"); + if( port != NULL ) { - int rv = input_port_read_indexed(machine, index ) << 6; + int rv = input_port_read_direct( port ) << 6; if( ( offset & 1 ) != 0 ) { diff --git a/src/mame/drivers/neodrvr.c b/src/mame/drivers/neodrvr.c index 738553778bb..4a0d6c1efe4 100644 --- a/src/mame/drivers/neodrvr.c +++ b/src/mame/drivers/neodrvr.c @@ -7202,8 +7202,8 @@ static DRIVER_INIT( jockeygp ) memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x200000, 0x201fff, 0, 0, SMH_BANK8, SMH_BANK8); memory_set_bankptr(NEOGEO_BANK_EXTRA_RAM, extra_ram); -// memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x280000, 0x280001, 0, 0, port_tag_to_handler16("IN5") ); -// memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2c0000, 0x2c0001, 0, 0, port_tag_to_handler16("IN6") ); +// memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x280000, 0x280001, 0, 0, input_port_read_handler16(machine->portconfig, "IN5") ); +// memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2c0000, 0x2c0001, 0, 0, input_port_read_handler16(machine->portconfig, "IN6") ); DRIVER_INIT_CALL(neogeo); } @@ -7219,8 +7219,8 @@ static DRIVER_INIT( vliner ) memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x200000, 0x201fff, 0, 0, SMH_BANK8, SMH_BANK8); memory_set_bankptr(NEOGEO_BANK_EXTRA_RAM, extra_ram); - memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x280000, 0x280001, 0, 0, port_tag_to_handler16("IN5") ); - memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2c0000, 0x2c0001, 0, 0, port_tag_to_handler16("IN6") ); + memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x280000, 0x280001, 0, 0, input_port_read_handler16(machine->portconfig, "IN5") ); + memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2c0000, 0x2c0001, 0, 0, input_port_read_handler16(machine->portconfig, "IN6") ); DRIVER_INIT_CALL(neogeo); } @@ -7229,7 +7229,7 @@ static DRIVER_INIT( vliner ) static DRIVER_INIT( kog ) { /* overlay cartridge ROM */ - memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0ffffe, 0x0fffff, 0, 0, port_tag_to_handler16("JUMPER") ); + memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0ffffe, 0x0fffff, 0, 0, input_port_read_handler16(machine->portconfig, "JUMPER") ); kog_px_decrypt(); neogeo_bootleg_sx_decrypt(1); diff --git a/src/mame/drivers/neogeo.c b/src/mame/drivers/neogeo.c index c2f3550850d..5d0ab73a928 100644 --- a/src/mame/drivers/neogeo.c +++ b/src/mame/drivers/neogeo.c @@ -332,7 +332,7 @@ static CUSTOM_INPUT( multiplexed_controller_r ) sprintf(tag, "IN%s-%d", (const char *)param, controller_select & 0x01); - return input_port_read(machine, tag); + return input_port_read(field->port->machine, tag); } @@ -351,10 +351,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(machine, "MAHJONG1"); break; - case 0x12: ret = input_port_read(machine, "MAHJONG2"); break; - case 0x1b: ret = input_port_read(machine, "MAHJONG3"); break; /* player 1 normal inputs? */ - case 0x24: ret = input_port_read(machine, "MAHJONG4"); break; + 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; } return ret; @@ -444,7 +444,7 @@ static void calendar_clock(void) static CUSTOM_INPUT( get_calendar_status ) { - return (pd4990a_databit_r(machine, 0) << 1) | pd4990a_testbit_r(machine, 0); + return (pd4990a_databit_r(field->port->machine, 0) << 1) | pd4990a_testbit_r(field->port->machine, 0); } diff --git a/src/mame/drivers/pacman.c b/src/mame/drivers/pacman.c index e611626a35c..1eedc04ed52 100644 --- a/src/mame/drivers/pacman.c +++ b/src/mame/drivers/pacman.c @@ -402,13 +402,9 @@ static INTERRUPT_GEN( pacman_interrupt ) /* and that the speedup button is pressed */ else { - int portnum = port_tag_to_index("FAKE"); - if (portnum != -1) - { - UINT8 value = input_port_read_indexed(machine, portnum); - if ((value & 7) == 5 || (value & 6) == 2) - irq0_line_hold(machine, cpunum); - } + UINT8 value = input_port_read_safe(machine, "FAKE", 0); + if ((value & 7) == 5 || (value & 6) == 2) + irq0_line_hold(machine, cpunum); } } @@ -1285,7 +1281,7 @@ static INPUT_PORTS_START( mspacman ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY - PORT_BIT( 0x10, 0x10, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x10, 0x10, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) @@ -1346,7 +1342,7 @@ static INPUT_PORTS_START( mspacpls ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY - PORT_BIT( 0x10, 0x10, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x10, 0x10, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) @@ -1397,7 +1393,7 @@ static INPUT_PORTS_START( mschamp ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY - PORT_BIT( 0x10, 0x10, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x10, 0x10, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) @@ -2065,7 +2061,7 @@ static INPUT_PORTS_START( vanvan ) PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) - PORT_BIT( 0x02, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Invulnerability (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x02, 0x00, "Invulnerability (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x02, DEF_STR( On ) ) PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) ) @@ -2139,7 +2135,7 @@ static INPUT_PORTS_START( vanvank ) PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) - PORT_BIT( 0x02, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Invulnerability (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x02, 0x00, "Invulnerability (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x02, DEF_STR( On ) ) PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) ) @@ -2226,9 +2222,9 @@ static INPUT_PORTS_START( alibaba ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY - PORT_BIT(0x10, 0x10, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) - PORT_DIPSETTING(0x10, DEF_STR( Off ) ) - PORT_DIPSETTING(0x00, DEF_STR( On ) ) + PORT_DIPNAME( 0x10, 0x10, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) + PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) @@ -2553,7 +2549,7 @@ static INPUT_PORTS_START( nmouse ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY - PORT_BIT( 0x10, 0x10, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x10, 0x10, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) @@ -2606,7 +2602,7 @@ static INPUT_PORTS_START( woodpek ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY - PORT_BIT( 0x10, 0x10, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x10, 0x10, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) diff --git a/src/mame/drivers/pengo.c b/src/mame/drivers/pengo.c index 62910f82f69..e611ae76990 100644 --- a/src/mame/drivers/pengo.c +++ b/src/mame/drivers/pengo.c @@ -190,7 +190,7 @@ static INPUT_PORTS_START( pengo ) PORT_DIPSETTING( 0x10, "3" ) PORT_DIPSETTING( 0x08, "4" ) PORT_DIPSETTING( 0x00, "5" ) - PORT_BIT( 0x20, 0x20, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x20, 0x20, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Difficulty ) ) @@ -274,7 +274,7 @@ static INPUT_PORTS_START( jrpacmbl ) PORT_DIPSETTING( 0x10, "15000" ) PORT_DIPSETTING( 0x20, "20000" ) PORT_DIPSETTING( 0x30, "30000" ) - PORT_BIT( 0x40, 0x40, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x40, 0x40, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) ) diff --git a/src/mame/drivers/phoenix.c b/src/mame/drivers/phoenix.c index 9143d5ccf74..f6647bdf021 100644 --- a/src/mame/drivers/phoenix.c +++ b/src/mame/drivers/phoenix.c @@ -1022,7 +1022,7 @@ ROM_END static DRIVER_INIT( condor ) { /* additional inputs for coinage */ - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x5000, 0x5000, 0, 0, port_tag_to_handler8("DSW1") ); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x5000, 0x5000, 0, 0, input_port_read_handler8(machine->portconfig, "DSW1") ); } static DRIVER_INIT( survival ) diff --git a/src/mame/drivers/rollrace.c b/src/mame/drivers/rollrace.c index 48bc7e38501..ce681de6b67 100644 --- a/src/mame/drivers/rollrace.c +++ b/src/mame/drivers/rollrace.c @@ -151,7 +151,7 @@ static INPUT_PORTS_START( rollrace ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) /* PORT_DIPNAME( 0x80, 0x00, "Free Run" ) */ - PORT_BIT( 0x80, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Invulnerability (Cheat)") + PORT_DIPNAME( 0x80, 0x00, "Invulnerability (Cheat)" ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) /* test mode, you are invulnerable */ PORT_DIPSETTING( 0x80, DEF_STR( On ) ) /* to 'static' objects */ diff --git a/src/mame/drivers/scramble.c b/src/mame/drivers/scramble.c index d046e4eeb55..206024ab928 100644 --- a/src/mame/drivers/scramble.c +++ b/src/mame/drivers/scramble.c @@ -928,7 +928,7 @@ static INPUT_PORTS_START( triplep ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_SERVICE( 0x20, IP_ACTIVE_HIGH ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY - PORT_BIT( 0x80, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x80, 0x00, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) INPUT_PORTS_END diff --git a/src/mame/drivers/segag80r.c b/src/mame/drivers/segag80r.c index c9b6090a61b..2b9ebf51376 100644 --- a/src/mame/drivers/segag80r.c +++ b/src/mame/drivers/segag80r.c @@ -160,7 +160,7 @@ static INPUT_CHANGED( service_switch ) { /* pressing the service switch sends an NMI */ if (newval) - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, PULSE_LINE); } diff --git a/src/mame/drivers/segag80v.c b/src/mame/drivers/segag80v.c index b8cf34bcb53..791aae52ac2 100644 --- a/src/mame/drivers/segag80v.c +++ b/src/mame/drivers/segag80v.c @@ -182,7 +182,7 @@ static INPUT_CHANGED( service_switch ) { /* pressing the service switch sends an NMI */ if (newval) - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, PULSE_LINE); } @@ -313,7 +313,7 @@ static READ8_HANDLER( spinner_input_r ) static CUSTOM_INPUT( elim4_joint_coin_r ) { - return (input_port_read(machine, "COINS") & 0xf) != 0xf; + return (input_port_read(field->port->machine, "COINS") & 0xf) != 0xf; } diff --git a/src/mame/drivers/slapfght.c b/src/mame/drivers/slapfght.c index e490733cb8f..ac37b7a3328 100644 --- a/src/mame/drivers/slapfght.c +++ b/src/mame/drivers/slapfght.c @@ -462,7 +462,7 @@ COMMON_START PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_SERVICE( 0x40, IP_ACTIVE_LOW ) /* Actually, the following DIPSW doesnt seem to do anything */ - PORT_BIT( 0x20, 0x20, IPT_DIPSWITCH_NAME ) PORT_NAME("Screen Test") PORT_CODE(KEYCODE_F1) PORT_TOGGLE + PORT_DIPNAME( 0x20, 0x20, "Screen Test" ) PORT_CODE(KEYCODE_F1) PORT_TOGGLE PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Cabinet ) ) @@ -575,7 +575,7 @@ COMMON_START PORT_DIPNAME( 0x10, 0x10, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x10, DEF_STR( On ) ) - PORT_BIT( 0x20, 0x20, IPT_DIPSWITCH_NAME ) PORT_NAME("Screen Test") PORT_CODE(KEYCODE_F1) PORT_TOGGLE + PORT_DIPNAME( 0x20, 0x20, "Screen Test" ) PORT_CODE(KEYCODE_F1) PORT_TOGGLE PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) ) diff --git a/src/mame/drivers/stactics.c b/src/mame/drivers/stactics.c index 74f6fbebb82..78632a6706e 100644 --- a/src/mame/drivers/stactics.c +++ b/src/mame/drivers/stactics.c @@ -54,7 +54,7 @@ Verify Color PROM resistor values (Last 8 colors) static CUSTOM_INPUT( get_motor_not_ready ) { - stactics_state *state = machine->driver_data; + stactics_state *state = field->port->machine->driver_data; /* if the motor is self-centering, but not centered yet */ return ((*state->motor_on & 0x01) == 0) && @@ -129,7 +129,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 mame_rand(machine) & 0x07; + return mame_rand(field->port->machine) & 0x07; } diff --git a/src/mame/drivers/suprridr.c b/src/mame/drivers/suprridr.c index 5d2e6a7d87a..71043d0cefe 100644 --- a/src/mame/drivers/suprridr.c +++ b/src/mame/drivers/suprridr.c @@ -228,9 +228,9 @@ static CUSTOM_INPUT( suprridr_control_r ) /* screen flip multiplexes controls */ if (suprridr_is_screen_flipped()) - ret = input_port_read(machine, SUPRRIDR_P2_CONTROL_PORT_TAG); + ret = input_port_read(field->port->machine, SUPRRIDR_P2_CONTROL_PORT_TAG); else - ret = input_port_read(machine, SUPRRIDR_P1_CONTROL_PORT_TAG); + ret = input_port_read(field->port->machine, SUPRRIDR_P1_CONTROL_PORT_TAG); return ret; } diff --git a/src/mame/drivers/taito_b.c b/src/mame/drivers/taito_b.c index 39b9127ed7b..2e31027ecd2 100644 --- a/src/mame/drivers/taito_b.c +++ b/src/mame/drivers/taito_b.c @@ -1380,7 +1380,7 @@ static INPUT_PORTS_START( crimecj ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_START_TAG("IN0") + PORT_START_TAG("IN1") TAITO_B_PLAYERS_INPUT( 2 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) diff --git a/src/mame/drivers/taitoair.c b/src/mame/drivers/taitoair.c index dc12afc0cc1..d3014adff48 100644 --- a/src/mame/drivers/taitoair.c +++ b/src/mame/drivers/taitoair.c @@ -439,7 +439,7 @@ static INPUT_PORTS_START( topland ) TAITO_COINAGE_WORLD_LOC(SWA) /* 0xa00202 -> 0x0c0d7e (-$7283,A5) */ - PORT_START_TAG("DSWA") + PORT_START_TAG("DSWB") TAITO_DIFFICULTY_LOC(SWA) PORT_DIPUNUSED_DIPLOC( 0x04, IP_ACTIVE_LOW, "SWB:3" ) PORT_DIPUNUSED_DIPLOC( 0x08, IP_ACTIVE_LOW, "SWB:4" ) diff --git a/src/mame/drivers/taitosj.c b/src/mame/drivers/taitosj.c index dfb4349696b..4c2f28c24ef 100644 --- a/src/mame/drivers/taitosj.c +++ b/src/mame/drivers/taitosj.c @@ -336,9 +336,9 @@ static CUSTOM_INPUT( kikstart_gear_r ) port_tag = "GEARP2"; /* gear MUST be 1, 2 or 3 */ - if (input_port_read(machine, port_tag) & 0x01) kikstart_gears[player] = 0x02; - if (input_port_read(machine, port_tag) & 0x02) kikstart_gears[player] = 0x03; - if (input_port_read(machine, port_tag) & 0x04) kikstart_gears[player] = 0x01; + if (input_port_read(field->port->machine, port_tag) & 0x01) kikstart_gears[player] = 0x02; + if (input_port_read(field->port->machine, port_tag) & 0x02) kikstart_gears[player] = 0x03; + if (input_port_read(field->port->machine, port_tag) & 0x04) kikstart_gears[player] = 0x01; return kikstart_gears[player]; } diff --git a/src/mame/drivers/tempest.c b/src/mame/drivers/tempest.c index 6ebdcb7004d..0cdb78cbd21 100644 --- a/src/mame/drivers/tempest.c +++ b/src/mame/drivers/tempest.c @@ -320,11 +320,11 @@ static CUSTOM_INPUT( tempest_knob_r ) if (tempest_player_select) { - ret = input_port_read(machine, TEMPEST_KNOB_P2_TAG); + ret = input_port_read(field->port->machine, TEMPEST_KNOB_P2_TAG); } else { - ret = input_port_read(machine, TEMPEST_KNOB_P1_TAG); + ret = input_port_read(field->port->machine, TEMPEST_KNOB_P1_TAG); } return ret; @@ -336,11 +336,11 @@ static CUSTOM_INPUT( tempest_buttons_r ) if (tempest_player_select) { - ret = input_port_read(machine, TEMPEST_BUTTONS_P2_TAG); + ret = input_port_read(field->port->machine, TEMPEST_BUTTONS_P2_TAG); } else { - ret = input_port_read(machine, TEMPEST_BUTTONS_P1_TAG); + ret = input_port_read(field->port->machine, TEMPEST_BUTTONS_P1_TAG); } return ret; diff --git a/src/mame/drivers/toaplan1.c b/src/mame/drivers/toaplan1.c index 17c99f6cfeb..bc3c209086e 100644 --- a/src/mame/drivers/toaplan1.c +++ b/src/mame/drivers/toaplan1.c @@ -1104,6 +1104,7 @@ static INPUT_PORTS_START( vimanan ) PORT_INCLUDE( vimana ) PORT_MODIFY("DSWA") /* DSW A */ + PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unused ) ) PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unused ) ) diff --git a/src/mame/drivers/trackfld.c b/src/mame/drivers/trackfld.c index 93e48e63917..d2bff966b65 100644 --- a/src/mame/drivers/trackfld.c +++ b/src/mame/drivers/trackfld.c @@ -53,71 +53,13 @@ WRITE8_HANDLER( hyprolyb_ADPCM_data_w ); */ static UINT8 *nvram; static size_t nvram_size; -static int we_flipped_the_switch; static NVRAM_HANDLER( trackfld ) { if (read_or_write) - { mame_fwrite(file,nvram,nvram_size); - - if (we_flipped_the_switch) - { - input_port_entry *in; - - - /* find the dip switch which resets the high score table, and set it */ - /* back to off. */ - in = machine->input_ports; - - while (in->type != IPT_END) - { - if (in->name != NULL && in->name != IP_NAME_DEFAULT && - strcmp(in->name,"World Records") == 0) - { - if (in->default_value == 0) - in->default_value = in->mask; - break; - } - - in++; - } - - we_flipped_the_switch = 0; - } - } - else - { - if (file) - { - mame_fread(file,nvram,nvram_size); - we_flipped_the_switch = 0; - } - else - { - input_port_entry *in; - - - /* find the dip switch which resets the high score table, and set it on */ - in = machine->input_ports; - - while (in->type != IPT_END) - { - if (in->name != NULL && in->name != IP_NAME_DEFAULT && - strcmp(in->name,"World Records") == 0) - { - if (in->default_value == in->mask) - { - in->default_value = 0; - we_flipped_the_switch = 1; - } - break; - } - - in++; - } - } - } + else if (file) + mame_fread(file,nvram,nvram_size); } static NVRAM_HANDLER( mastkin ) diff --git a/src/mame/drivers/triplhnt.c b/src/mame/drivers/triplhnt.c index 286b92738dd..749bead0bad 100644 --- a/src/mame/drivers/triplhnt.c +++ b/src/mame/drivers/triplhnt.c @@ -197,7 +197,7 @@ static INPUT_PORTS_START( triplhnt ) PORT_START /* 0C48 */ // default to service enabled to make users calibrate gun // PORT_SERVICE( 0x40, IP_ACTIVE_LOW ) - PORT_BIT( 0x40, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME( DEF_STR( Service_Mode )) PORT_TOGGLE PORT_CODE(KEYCODE_F2) + PORT_DIPNAME( 0x40, 0x00, DEF_STR( Service_Mode )) PORT_TOGGLE PORT_CODE(KEYCODE_F2) PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) diff --git a/src/mame/drivers/tsamurai.c b/src/mame/drivers/tsamurai.c index f59369ed809..94119467424 100644 --- a/src/mame/drivers/tsamurai.c +++ b/src/mame/drivers/tsamurai.c @@ -563,7 +563,7 @@ TS_IN1 TS_IN2 TS_DSW1 - PORT_START_TAG("DSW1") + PORT_START_TAG("DSW2") PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) diff --git a/src/mame/drivers/ultratnk.c b/src/mame/drivers/ultratnk.c index ece2564824d..ae360da8fbc 100644 --- a/src/mame/drivers/ultratnk.c +++ b/src/mame/drivers/ultratnk.c @@ -28,7 +28,7 @@ static CUSTOM_INPUT( get_collision ) static CUSTOM_INPUT( get_joystick ) { - UINT8 joy = input_port_read(machine, param) & 3; + UINT8 joy = input_port_read(field->port->machine, param) & 3; if (joy == 1) { diff --git a/src/mame/drivers/undrfire.c b/src/mame/drivers/undrfire.c index ecb994b2152..bf30750a1b7 100644 --- a/src/mame/drivers/undrfire.c +++ b/src/mame/drivers/undrfire.c @@ -600,7 +600,7 @@ static INPUT_PORTS_START( undrfire ) PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(20) PORT_KEYDELTA(25) PORT_PLAYER(2) PORT_START_TAG("FAKE") - PORT_BIT( 0x01, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Show gun target") PORT_CODE(KEYCODE_F1) PORT_TOGGLE + PORT_DIPNAME( 0x01, 0x00, "Show gun target" ) PORT_CODE(KEYCODE_F1) PORT_TOGGLE PORT_DIPSETTING( 0x00, DEF_STR( No ) ) PORT_DIPSETTING( 0x01, DEF_STR( Yes ) ) INPUT_PORTS_END diff --git a/src/mame/drivers/vicdual.c b/src/mame/drivers/vicdual.c index d90229e69bf..0b2dac66b02 100644 --- a/src/mame/drivers/vicdual.c +++ b/src/mame/drivers/vicdual.c @@ -95,10 +95,10 @@ static INPUT_CHANGED( coin_changed ) coin_counter_w(0, 1); coin_counter_w(0, 0); - cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, PULSE_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_RESET, PULSE_LINE); /* simulate the coin switch being closed for a while */ - timer_set(double_to_attotime(4 * attotime_to_double(video_screen_get_frame_period(machine->primary_screen))), NULL, 0, clear_coin_status); + timer_set(double_to_attotime(4 * attotime_to_double(video_screen_get_frame_period(field->port->machine->primary_screen))), NULL, 0, clear_coin_status); } } @@ -142,19 +142,19 @@ static int get_vcounter(running_machine *machine) static CUSTOM_INPUT( vicdual_get_64v ) { - return (get_vcounter(machine) >> 6) & 0x01; + return (get_vcounter(field->port->machine) >> 6) & 0x01; } static CUSTOM_INPUT( vicdual_get_vblank_comp ) { - return (get_vcounter(machine) < VICDUAL_VBSTART); + return (get_vcounter(field->port->machine) < VICDUAL_VBSTART); } static CUSTOM_INPUT( vicdual_get_composite_blank_comp ) { - return (vicdual_get_vblank_comp(machine, 0) && !video_screen_get_hblank(machine->primary_screen)); + return (vicdual_get_vblank_comp(field, 0) && !video_screen_get_hblank(field->port->machine->primary_screen)); } @@ -2023,7 +2023,7 @@ static INPUT_PORTS_START( samurai ) PORT_DIPNAME( 0x04, 0x04, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x04, "3" ) PORT_DIPSETTING( 0x00, "4" ) - PORT_BIT( 0x08, 0x08, IPT_DIPSWITCH_NAME ) PORT_NAME("Infinite Lives") + PORT_DIPNAME( 0x08, 0x08, "Infinite Lives" ) PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY diff --git a/src/mame/drivers/vsnes.c b/src/mame/drivers/vsnes.c index 263bf64e664..2914eec7379 100644 --- a/src/mame/drivers/vsnes.c +++ b/src/mame/drivers/vsnes.c @@ -1022,7 +1022,7 @@ static INPUT_PORTS_START( iceclmrj ) PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) - PORT_BIT( 0x80, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Service Mode (Left Side)") PORT_TOGGLE PORT_CODE(KEYCODE_F2) + PORT_DIPNAME( 0x80, 0x00, "Service Mode (Left Side)" ) PORT_TOGGLE PORT_CODE(KEYCODE_F2) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) @@ -1049,7 +1049,7 @@ static INPUT_PORTS_START( iceclmrj ) PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) - PORT_BIT( 0x80, 0x00, IPT_DIPSWITCH_NAME ) PORT_NAME("Service Mode (Right Side)") PORT_TOGGLE PORT_CODE(KEYCODE_F1) + PORT_DIPNAME( 0x80, 0x00, "Service Mode (Right Side)" ) PORT_TOGGLE PORT_CODE(KEYCODE_F1) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) INPUT_PORTS_END diff --git a/src/mame/drivers/zac2650.c b/src/mame/drivers/zac2650.c index 9628c397419..8a596c1315a 100644 --- a/src/mame/drivers/zac2650.c +++ b/src/mame/drivers/zac2650.c @@ -217,7 +217,7 @@ static INPUT_PORTS_START( dodgem ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) PORT_START_TAG("1E86") - PORT_BIT( 0x01, 0x01, IPT_DIPSWITCH_NAME ) PORT_NAME("Collision Detection (Cheat)") + PORT_DIPNAME( 0x01, 0x01, "Collision Detection (Cheat)" ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) diff --git a/src/mame/drivers/zaxxon.c b/src/mame/drivers/zaxxon.c index 8d650a09667..188545ac879 100644 --- a/src/mame/drivers/zaxxon.c +++ b/src/mame/drivers/zaxxon.c @@ -358,7 +358,7 @@ static INPUT_CHANGED( service_switch ) { /* pressing the service switch sends an NMI */ if (newval) - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); + cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, PULSE_LINE); } @@ -421,7 +421,7 @@ static CUSTOM_INPUT( razmataz_dial_r ) int num = (FPTR)param; int delta, res; - delta = input_port_read(machine, dialname[num]); + delta = input_port_read(field->port->machine, dialname[num]); if (delta < 0x80) { @@ -1469,9 +1469,9 @@ static DRIVER_INIT( razmataz ) nprinces_decode(); /* additional input ports are wired */ - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc004, 0xc004, 0, 0x18f3, port_tag_to_handler8("SW04")); - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc008, 0xc008, 0, 0x18f3, port_tag_to_handler8("SW08")); - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc00c, 0xc00c, 0, 0x18f3, port_tag_to_handler8("SW0C")); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc004, 0xc004, 0, 0x18f3, input_port_read_handler8(machine->portconfig, "SW04")); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc008, 0xc008, 0, 0x18f3, input_port_read_handler8(machine->portconfig, "SW08")); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc00c, 0xc00c, 0, 0x18f3, input_port_read_handler8(machine->portconfig, "SW0C")); /* unknown behavior expected here */ memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc80a, 0xc80a, 0, 0, razmataz_counter_r); diff --git a/src/mame/machine/amiga.c b/src/mame/machine/amiga.c index 1f08008c6fd..43291ef70b2 100644 --- a/src/mame/machine/amiga.c +++ b/src/mame/machine/amiga.c @@ -462,7 +462,7 @@ static TIMER_CALLBACK( amiga_irq_proc ) CUSTOM_INPUT( amiga_joystick_convert ) { - UINT8 bits = input_port_read(machine, param); + UINT8 bits = input_port_read(field->port->machine, param); int up = (bits >> 0) & 1; int down = (bits >> 1) & 1; int left = (bits >> 2) & 1; diff --git a/src/mame/machine/atari.c b/src/mame/machine/atari.c index eda6e80c433..0ac13287b03 100644 --- a/src/mame/machine/atari.c +++ b/src/mame/machine/atari.c @@ -742,7 +742,7 @@ static void atari_machine_start(running_machine *machine, int type, const pia682 /* GTIA */ memset(>ia_intf, 0, sizeof(gtia_intf)); - if (port_tag_to_index("console") >= 0) + if (input_port_by_tag(machine->portconfig, "console") != NULL) gtia_intf.console_read = console_read; if (sndti_exists(SOUND_DAC, 0)) gtia_intf.console_write = console_write; diff --git a/src/mame/machine/pckeybrd.c b/src/mame/machine/pckeybrd.c index 2d5f4e54f45..b92de25a402 100644 --- a/src/mame/machine/pckeybrd.c +++ b/src/mame/machine/pckeybrd.c @@ -188,7 +188,7 @@ typedef struct at_keyboard int scan_code_set; int last_code; - int ports[8]; + const input_port_config *ports[8]; } at_keyboard; static at_keyboard keyboard; @@ -343,7 +343,7 @@ void at_keyboard_init(AT_KEYBOARD_TYPE type) for (i = 0; i < sizeof(keyboard.ports) / sizeof(keyboard.ports[0]); i++) { sprintf(buf, "pc_keyboard_%d", i); - keyboard.ports[i] = port_tag_to_index(buf); + keyboard.ports[i] = input_port_by_tag(Machine->portconfig, buf); } #ifdef MESS @@ -508,8 +508,8 @@ static void at_keyboard_extended_scancode_insert(int code, int pressed) static UINT32 at_keyboard_readport(int port) { UINT32 result = 0; - if (keyboard.ports[port] >= 0) - result = input_port_read_indexed(Machine, keyboard.ports[port]); + if (keyboard.ports[port] != NULL) + result = input_port_read_direct(keyboard.ports[port]); return result; } diff --git a/src/mame/video/dkong.c b/src/mame/video/dkong.c index 01e8c082d82..86be39460f6 100644 --- a/src/mame/video/dkong.c +++ b/src/mame/video/dkong.c @@ -834,13 +834,13 @@ static TIMER_CALLBACK( scanline_callback ) static void check_palette(running_machine *machine) { dkong_state *state = machine->driver_data; + const input_port_config *port; int newset; - int num; - num = port_tag_to_index("VIDHW"); - if (num>=0) + port = input_port_by_tag(machine->portconfig, "VIDHW"); + if (port != NULL) { - newset = input_port_read_indexed(machine, num); + newset = input_port_read_direct(port); if (newset != state->vidhw) { state->vidhw = newset; diff --git a/src/mame/video/exidy440.c b/src/mame/video/exidy440.c index 3f089547c3b..c66232b50a1 100644 --- a/src/mame/video/exidy440.c +++ b/src/mame/video/exidy440.c @@ -5,7 +5,6 @@ ***************************************************************************/ #include "driver.h" -#include "deprecat.h" #include "exidy440.h" @@ -154,7 +153,7 @@ READ8_HANDLER( exidy440_horizontal_pos_r ) { /* clear the FIRQ on a read here */ exidy440_firq_beam = 0; - exidy440_update_firq(Machine); + exidy440_update_firq(machine); /* according to the schems, this value is only latched on an FIRQ * caused by collision or beam */ @@ -208,7 +207,7 @@ WRITE8_HANDLER( exidy440_control_w ) palettebank_vis = data & 1; /* update the FIRQ in case we enabled something */ - exidy440_update_firq(Machine); + exidy440_update_firq(machine); /* if we're swapping palettes, change all the colors */ if (oldvis != palettebank_vis) @@ -231,7 +230,7 @@ WRITE8_HANDLER( exidy440_interrupt_clear_w ) { /* clear the VBLANK FIRQ on a write here */ exidy440_firq_vblank = 0; - exidy440_update_firq(Machine); + exidy440_update_firq(machine); } diff --git a/src/mame/video/phoenix.c b/src/mame/video/phoenix.c index a09c2805a82..c808950d5e0 100644 --- a/src/mame/video/phoenix.c +++ b/src/mame/video/phoenix.c @@ -293,9 +293,9 @@ WRITE8_HANDLER( phoenix_scroll_w ) CUSTOM_INPUT( player_input_r ) { if (cocktail_mode) - return (input_port_read(machine, "CTRL") & 0xf0) >> 4; + return (input_port_read(field->port->machine, "CTRL") & 0xf0) >> 4; else - return (input_port_read(machine, "CTRL") & 0x0f) >> 0; + return (input_port_read(field->port->machine, "CTRL") & 0x0f) >> 0; } CUSTOM_INPUT( pleiads_protection_r ) diff --git a/src/mame/video/stactics.c b/src/mame/video/stactics.c index c27e2e1eb93..af2457fa61d 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 = machine->driver_data; + stactics_state *state = field->port->machine->driver_data; return (state->frame_count >> 3) & 0x01; } @@ -172,7 +172,7 @@ WRITE8_HANDLER( stactics_shot_flag_clear_w ) CUSTOM_INPUT( stactics_get_shot_standby ) { - stactics_state *state = machine->driver_data; + stactics_state *state = field->port->machine->driver_data; return state->shot_standby; } @@ -180,7 +180,7 @@ CUSTOM_INPUT( stactics_get_shot_standby ) CUSTOM_INPUT( stactics_get_not_shot_arrive ) { - stactics_state *state = machine->driver_data; + stactics_state *state = field->port->machine->driver_data; return !state->shot_arrive; } diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h index 7687ee49752..0daddb4be82 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -40,6 +40,7 @@ #include "mamecore.h" #include "osdcore.h" +#include "inptport.h" #include "timer.h" @@ -145,7 +146,7 @@ void osd_set_mastervolume(int attenuation); This function is called on startup, before reading the configuration from disk. Scan the list, and change the keys/joysticks you want. */ -void osd_customize_inputport_list(input_port_default_entry *defaults); +void osd_customize_input_type_list(input_type_desc *typelist); diff --git a/src/osd/windows/debugwin.c b/src/osd/windows/debugwin.c index a33d5687ae0..f23c2a8f899 100644 --- a/src/osd/windows/debugwin.c +++ b/src/osd/windows/debugwin.c @@ -427,7 +427,7 @@ void debugwin_update_during_game(void) { // see if the interrupt key is pressed and break if it is temporarily_fake_that_we_are_not_visible = TRUE; - if (input_ui_pressed(IPT_UI_DEBUG_BREAK)) + if (input_ui_pressed(Machine, IPT_UI_DEBUG_BREAK)) { debugwin_info *info; HWND focuswnd = GetFocus(); @@ -2891,7 +2891,7 @@ static int global_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam) int ignoreme; /* ignore any keys that are received while the debug key is down */ - ignoreme = input_ui_pressed(IPT_UI_DEBUG_BREAK); + ignoreme = input_ui_pressed(Machine, IPT_UI_DEBUG_BREAK); if (ignoreme) return 1; diff --git a/src/osd/windows/input.c b/src/osd/windows/input.c index a6a89eda717..619877ad22b 100644 --- a/src/osd/windows/input.c +++ b/src/osd/windows/input.c @@ -699,42 +699,42 @@ BOOL wininput_handle_raw(HANDLE device) //============================================================ -// osd_customize_inputport_list +// osd_customize_mapping_list //============================================================ -void osd_customize_inputport_list(input_port_default_entry *defaults) +void osd_customize_input_type_list(input_type_desc *typelist) { - input_port_default_entry *idef = defaults; - - // loop over all the defaults - for (idef = defaults; idef->type != IPT_END; idef++) - switch (idef->type) + input_type_desc *typedesc; + + // loop over the defaults + for (typedesc = typelist; typedesc != NULL; typedesc = typedesc->next) + switch (typedesc->type) { // disable the config menu if the ALT key is down // (allows ALT-TAB to switch between windows apps) case IPT_UI_CONFIGURE: - input_seq_set_5(&idef->defaultseq, KEYCODE_TAB, SEQCODE_NOT, KEYCODE_LALT, SEQCODE_NOT, KEYCODE_RALT); + input_seq_set_5(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_TAB, SEQCODE_NOT, KEYCODE_LALT, SEQCODE_NOT, KEYCODE_RALT); break; // alt-enter for fullscreen case IPT_OSD_1: - idef->token = "TOGGLE_FULLSCREEN"; - idef->name = "Toggle Fullscreen"; - input_seq_set_2(&idef->defaultseq, KEYCODE_LALT, KEYCODE_ENTER); + typedesc->token = "TOGGLE_FULLSCREEN"; + typedesc->name = "Toggle Fullscreen"; + input_seq_set_2(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_LALT, KEYCODE_ENTER); break; #ifdef MESS case IPT_OSD_2: if (mess_use_new_ui()) { - idef->token = "TOGGLE_MENUBAR"; - idef->name = "Toggle Menubar"; - input_seq_set_1 (&idef->defaultseq, KEYCODE_SCRLOCK); + typedesc->token = "TOGGLE_MENUBAR"; + typedesc->name = "Toggle Menubar"; + input_seq_set_1 (&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_SCRLOCK); } break; case IPT_UI_THROTTLE: - input_seq_set_0(&idef->defaultseq); + input_seq_set_0(&typedesc->seq[SEQ_TYPE_STANDARD]); break; #endif /* MESS */ } diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c index 944f9cbdb0c..c180da0587c 100644 --- a/src/osd/windows/video.c +++ b/src/osd/windows/video.c @@ -71,7 +71,7 @@ static void init_monitors(void); static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data); static win_monitor_info *pick_monitor(int index); -static void check_osd_inputs(void); +static void check_osd_inputs(running_machine *machine); static void extract_video_config(running_machine *machine); static void load_effect_overlay(running_machine *machine, const char *filename); @@ -211,7 +211,7 @@ void osd_update(running_machine *machine, int skip_redraw) // poll the joystick values here winwindow_process_events(machine, TRUE); wininput_poll(machine); - check_osd_inputs(); + check_osd_inputs(machine); } @@ -352,15 +352,15 @@ finishit: // check_osd_inputs //============================================================ -static void check_osd_inputs(void) +static void check_osd_inputs(running_machine *machine) { // check for toggling fullscreen mode - if (input_ui_pressed(IPT_OSD_1)) + if (input_ui_pressed(machine, IPT_OSD_1)) winwindow_toggle_full_screen(); #ifdef MESS // check for toggling menu bar - if (input_ui_pressed(IPT_OSD_2)) + if (input_ui_pressed(machine, IPT_OSD_2)) win_toggle_menubar(); #endif } |
