From 5ed8de79e853415201e34c2d2693a84cf59c270a Mon Sep 17 00:00:00 2001 From: RealComboman Date: Tue, 13 Jan 2015 10:40:48 -0400 Subject: [PATCH 1/8] added output so artwork can display current gear settings --- src/mame/drivers/sprint2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mame/drivers/sprint2.c b/src/mame/drivers/sprint2.c index 9082b60688c..b760b905e46 100644 --- a/src/mame/drivers/sprint2.c +++ b/src/mame/drivers/sprint2.c @@ -98,6 +98,8 @@ INTERRUPT_GEN_MEMBER(sprint2_state::sprint2) case 4: m_gear[i] = 3; break; case 8: m_gear[i] = 4; break; } + output_set_value("P1gear", m_gear[0]); + output_set_value("P2gear", m_gear[1]); } } From e5a474fa397f150f3d93cbda22285d0fddc83a8b Mon Sep 17 00:00:00 2001 From: etabeta78 Date: Wed, 14 Jan 2015 07:48:38 +0100 Subject: [PATCH 2/8] ui: split code for input mapping and slot option menus from miscmenu. nw. --- src/emu/emu.mak | 8 +- src/emu/ui/inputmap.c | 946 +++++++++++++++++++++++++++++++++++ src/emu/ui/inputmap.h | 156 ++++++ src/emu/ui/mainmenu.c | 6 +- src/emu/ui/miscmenu.c | 1109 ----------------------------------------- src/emu/ui/miscmenu.h | 154 ------ src/emu/ui/selgame.c | 1 + src/emu/ui/slotopt.c | 199 ++++++++ src/emu/ui/slotopt.h | 36 ++ 9 files changed, 1347 insertions(+), 1268 deletions(-) create mode 100644 src/emu/ui/inputmap.c create mode 100644 src/emu/ui/inputmap.h create mode 100644 src/emu/ui/slotopt.c create mode 100644 src/emu/ui/slotopt.h diff --git a/src/emu/emu.mak b/src/emu/emu.mak index 37c0631fb44..71d20b40168 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -116,16 +116,18 @@ EMUOBJS = \ $(EMUOBJ)/timer.o \ $(EMUOBJ)/uiinput.o \ $(EMUOBJ)/ui/ui.o \ - $(EMUOBJ)/ui/swlist.o \ $(EMUOBJ)/ui/menu.o \ $(EMUOBJ)/ui/mainmenu.o \ $(EMUOBJ)/ui/miscmenu.o \ - $(EMUOBJ)/ui/selgame.o \ + $(EMUOBJ)/ui/barcode.o \ $(EMUOBJ)/ui/filemngr.o \ $(EMUOBJ)/ui/filesel.o \ $(EMUOBJ)/ui/imgcntrl.o \ $(EMUOBJ)/ui/imginfo.o \ - $(EMUOBJ)/ui/barcode.o \ + $(EMUOBJ)/ui/inputmap.o \ + $(EMUOBJ)/ui/selgame.o \ + $(EMUOBJ)/ui/slotopt.o \ + $(EMUOBJ)/ui/swlist.o \ $(EMUOBJ)/ui/tapectrl.o \ $(EMUOBJ)/ui/viewgfx.o \ $(EMUOBJ)/validity.o \ diff --git a/src/emu/ui/inputmap.c b/src/emu/ui/inputmap.c new file mode 100644 index 00000000000..e949a48deaa --- /dev/null +++ b/src/emu/ui/inputmap.c @@ -0,0 +1,946 @@ +/********************************************************************* + + ui/inputmap.c + + Internal menus for input mappings. + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +*********************************************************************/ + +#include "emu.h" + +#include "uiinput.h" +#include "ui/ui.h" +#include "ui/inputmap.h" + + +/*************************************************************************** + CONSTANTS +***************************************************************************/ + +#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 +#define DIP_SWITCH_SPACING 0.01 +#define SINGLE_TOGGLE_SWITCH_FIELD_WIDTH 0.025f +#define SINGLE_TOGGLE_SWITCH_WIDTH 0.020f +/* make the switch 80% of the width space and 1/2 of the switch height */ +#define PERCENTAGE_OF_HALF_FIELD_USED 0.80f +#define SINGLE_TOGGLE_SWITCH_HEIGHT ((DIP_SWITCH_HEIGHT / 2) * PERCENTAGE_OF_HALF_FIELD_USED) + + + +/*------------------------------------------------- + menu_input_groups_populate - populate the + input groups menu +-------------------------------------------------*/ + +ui_menu_input_groups::ui_menu_input_groups(running_machine &machine, render_container *container) : ui_menu(machine, container) +{ +} + +void ui_menu_input_groups::populate() +{ + int player; + + /* build up the menu */ + item_append("User Interface", NULL, 0, (void *)(IPG_UI + 1)); + for (player = 0; player < MAX_PLAYERS; player++) + { + char buffer[40]; + sprintf(buffer, "Player %d Controls", player + 1); + item_append(buffer, NULL, 0, (void *)(FPTR)(IPG_PLAYER1 + player + 1)); + } + item_append("Other Controls", NULL, 0, (void *)(FPTR)(IPG_OTHER + 1)); +} + +ui_menu_input_groups::~ui_menu_input_groups() +{ +} + +/*------------------------------------------------- + menu_input_groups - handle the input groups + menu +-------------------------------------------------*/ + +void ui_menu_input_groups::handle() +{ + /* process the menu */ + const ui_menu_event *menu_event = process(0); + if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_general(machine(), container, int((long long)(menu_event->itemref)-1)))); +} + + + +/*------------------------------------------------- + menu_input_general - handle the general + input menu +-------------------------------------------------*/ + +ui_menu_input_general::ui_menu_input_general(running_machine &machine, render_container *container, int _group) : ui_menu_input(machine, container) +{ + group = _group; +} + +void ui_menu_input_general::populate() +{ + input_item_data *itemlist = NULL; + int suborder[SEQ_TYPE_TOTAL]; + astring tempstring; + int sortorder = 1; + + /* create a mini lookup table for sort order based on sequence type */ + suborder[SEQ_TYPE_STANDARD] = 0; + suborder[SEQ_TYPE_DECREMENT] = 1; + suborder[SEQ_TYPE_INCREMENT] = 2; + + /* iterate over the input ports and add menu items */ + for (input_type_entry *entry = machine().ioport().first_type(); entry != NULL; entry = entry->next()) + + /* add if we match the group and we have a valid name */ + if (entry->group() == group && entry->name() != NULL && entry->name()[0] != 0) + { + input_seq_type seqtype; + + /* loop over all sequence types */ + sortorder++; + for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++) + { + /* build an entry for the standard sequence */ + input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item)); + memset(item, 0, sizeof(*item)); + item->ref = entry; + if(pollingitem && pollingref == entry && pollingseq == seqtype) + pollingitem = item; + item->seqtype = seqtype; + item->seq = machine().ioport().type_seq(entry->type(), entry->player(), seqtype); + item->defseq = &entry->defseq(seqtype); + item->sortorder = sortorder * 4 + suborder[seqtype]; + item->type = ioport_manager::type_is_analog(entry->type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; + item->name = entry->name(); + item->owner_name = NULL; + item->next = itemlist; + itemlist = item; + + /* stop after one, unless we're analog */ + if (item->type == INPUT_TYPE_DIGITAL) + break; + } + } + + /* sort and populate the menu in a standard fashion */ + populate_and_sort(itemlist); +} + +ui_menu_input_general::~ui_menu_input_general() +{ +} + +/*------------------------------------------------- + menu_input_specific - handle the game-specific + input menu +-------------------------------------------------*/ + +ui_menu_input_specific::ui_menu_input_specific(running_machine &machine, render_container *container) : ui_menu_input(machine, container) +{ +} + +void ui_menu_input_specific::populate() +{ + input_item_data *itemlist = NULL; + ioport_field *field; + ioport_port *port; + int suborder[SEQ_TYPE_TOTAL]; + astring tempstring; + + /* create a mini lookup table for sort order based on sequence type */ + suborder[SEQ_TYPE_STANDARD] = 0; + suborder[SEQ_TYPE_DECREMENT] = 1; + suborder[SEQ_TYPE_INCREMENT] = 2; + + /* iterate over the input ports and add menu items */ + for (port = machine().ioport().first_port(); port != NULL; port = port->next()) + for (field = port->first_field(); field != NULL; field = field->next()) + { + const char *name = field->name(); + + /* add if we match the group and we have a valid name */ + if (name != NULL && field->enabled() && + ((field->type() == IPT_OTHER && field->name() != NULL) || machine().ioport().type_group(field->type(), field->player()) != IPG_INVALID)) + { + input_seq_type seqtype; + UINT32 sortorder; + + /* determine the sorting order */ + if (field->type() >= IPT_START1 && field->type() < IPT_ANALOG_LAST) + { + sortorder = (field->type() << 2) | (field->player() << 12); + if (strcmp(field->device().tag(), ":")) + sortorder |= 0x10000; + } + else + sortorder = field->type() | 0xf000; + + /* loop over all sequence types */ + for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++) + { + /* build an entry for the standard sequence */ + input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item)); + memset(item, 0, sizeof(*item)); + item->ref = field; + item->seqtype = seqtype; + if(pollingitem && pollingref == field && pollingseq == seqtype) + pollingitem = item; + item->seq = field->seq(seqtype); + item->defseq = &field->defseq(seqtype); + item->sortorder = sortorder + suborder[seqtype]; + item->type = field->is_analog() ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; + item->name = name; + item->owner_name = field->device().tag(); + item->next = itemlist; + itemlist = item; + + /* stop after one, unless we're analog */ + if (item->type == INPUT_TYPE_DIGITAL) + break; + } + } + } + + /* sort and populate the menu in a standard fashion */ + populate_and_sort(itemlist); +} + +ui_menu_input_specific::~ui_menu_input_specific() +{ +} + +/*------------------------------------------------- + menu_input - display a menu for inputs +-------------------------------------------------*/ +ui_menu_input::ui_menu_input(running_machine &machine, render_container *container) : ui_menu(machine, container) +{ + pollingitem = 0; + pollingref = 0; + pollingseq = SEQ_TYPE_STANDARD; +} + +ui_menu_input::~ui_menu_input() +{ +} + +/*------------------------------------------------- + toggle_none_default - toggle between "NONE" + and the default item +-------------------------------------------------*/ + +void ui_menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq) +{ + /* if we used to be "none", toggle to the default value */ + if (original_seq.length() == 0) + selected_seq = selected_defseq; + + /* otherwise, toggle to "none" */ + else + selected_seq.reset(); +} + +void ui_menu_input::handle() +{ + input_item_data *seqchangeditem = NULL; + const ui_menu_event *menu_event; + int invalidate = false; + + /* process the menu */ + menu_event = process((pollingitem != NULL) ? UI_MENU_PROCESS_NOKEYS : 0); + + /* if we are polling, handle as a special case */ + if (pollingitem != NULL) + { + input_item_data *item = pollingitem; + input_seq newseq; + + /* if UI_CANCEL is pressed, abort */ + if (ui_input_pressed(machine(), IPT_UI_CANCEL)) + { + pollingitem = NULL; + record_next = false; + toggle_none_default(item->seq, starting_seq, *item->defseq); + seqchangeditem = item; + } + + /* poll again; if finished, update the sequence */ + if (machine().input().seq_poll()) + { + pollingitem = NULL; + record_next = true; + item->seq = machine().input().seq_poll_final(); + seqchangeditem = item; + } + } + + /* otherwise, handle the events */ + else if (menu_event != NULL && menu_event->itemref != NULL) + { + input_item_data *item = (input_item_data *)menu_event->itemref; + switch (menu_event->iptkey) + { + /* an item was selected: begin polling */ + case IPT_UI_SELECT: + pollingitem = item; + last_sortorder = item->sortorder; + starting_seq = item->seq; + machine().input().seq_poll_start((item->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &item->seq : NULL); + invalidate = true; + break; + + /* if the clear key was pressed, reset the selected item */ + case IPT_UI_CLEAR: + toggle_none_default(item->seq, item->seq, *item->defseq); + record_next = false; + seqchangeditem = item; + break; + } + + /* if the selection changed, reset the "record next" flag */ + if (item->sortorder != last_sortorder) + record_next = false; + last_sortorder = item->sortorder; + } + + /* if the sequence changed, update it */ + if (seqchangeditem != NULL) + { + update_input(seqchangeditem); + + /* invalidate the menu to force an update */ + invalidate = true; + } + + /* if the menu is invalidated, clear it now */ + if (invalidate) + { + pollingref = NULL; + if (pollingitem != NULL) + { + pollingref = pollingitem->ref; + pollingseq = pollingitem->seqtype; + } + reset(UI_MENU_RESET_REMEMBER_POSITION); + } +} + +void ui_menu_input_general::update_input(struct input_item_data *seqchangeditem) +{ + const input_type_entry *entry = (const input_type_entry *)seqchangeditem->ref; + machine().ioport().set_type_seq(entry->type(), entry->player(), seqchangeditem->seqtype, seqchangeditem->seq); +} + +void ui_menu_input_specific::update_input(struct input_item_data *seqchangeditem) +{ + ioport_field::user_settings settings; + + ((ioport_field *)seqchangeditem->ref)->get_user_settings(settings); + settings.seq[seqchangeditem->seqtype] = seqchangeditem->seq; + ((ioport_field *)seqchangeditem->ref)->set_user_settings(settings); +} + + +/*------------------------------------------------- + menu_input_compare_items - compare two + items for quicksort +-------------------------------------------------*/ + +int ui_menu_input::compare_items(const void *i1, const void *i2) +{ + const input_item_data * const *data1 = (const input_item_data * const *)i1; + const input_item_data * const *data2 = (const input_item_data * const *)i2; + if ((*data1)->sortorder < (*data2)->sortorder) + return -1; + if ((*data1)->sortorder > (*data2)->sortorder) + return 1; + return 0; +} + + +/*------------------------------------------------- + menu_input_populate_and_sort - take a list + of input_item_data objects and build up the + menu from them +-------------------------------------------------*/ + +void ui_menu_input::populate_and_sort(input_item_data *itemlist) +{ + const char *nameformat[INPUT_TYPE_TOTAL] = { 0 }; + input_item_data **itemarray, *item; + int numitems = 0, curitem; + astring text; + astring subtext; + astring prev_owner; + bool first_entry = true; + + /* create a mini lookup table for name format based on type */ + nameformat[INPUT_TYPE_DIGITAL] = "%s"; + nameformat[INPUT_TYPE_ANALOG] = "%s Analog"; + nameformat[INPUT_TYPE_ANALOG_INC] = "%s Analog Inc"; + nameformat[INPUT_TYPE_ANALOG_DEC] = "%s Analog Dec"; + + /* first count the number of items */ + for (item = itemlist; item != NULL; item = item->next) + numitems++; + + /* now allocate an array of items and fill it up */ + itemarray = (input_item_data **)m_pool_alloc(sizeof(*itemarray) * numitems); + for (item = itemlist, curitem = 0; item != NULL; item = item->next) + itemarray[curitem++] = item; + + /* sort it */ + qsort(itemarray, numitems, sizeof(*itemarray), compare_items); + + /* build the menu */ + for (curitem = 0; curitem < numitems; curitem++) + { + UINT32 flags = 0; + + /* generate the name of the item itself, based off the base name and the type */ + item = itemarray[curitem]; + assert(nameformat[item->type] != NULL); + + if (strcmp(item->owner_name, prev_owner.cstr()) != 0) + { + if (first_entry) + first_entry = false; + else + item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + text.printf("[root%s]", item->owner_name); + item_append(text, NULL, 0, NULL); + prev_owner.cpy(item->owner_name); + } + + text.printf(nameformat[item->type], item->name); + + /* if we're polling this item, use some spaces with left/right arrows */ + if (pollingref == item->ref) + { + subtext.cpy(" "); + flags |= MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; + } + + /* otherwise, generate the sequence name and invert it if different from the default */ + else + { + machine().input().seq_name(subtext, item->seq); + flags |= (item->seq != *item->defseq) ? MENU_FLAG_INVERT : 0; + } + + /* add the item */ + item_append(text, subtext, flags, item); + } +} + + +/*------------------------------------------------- + menu_settings_dip_switches - handle the DIP + switches menu +-------------------------------------------------*/ + +ui_menu_settings_dip_switches::ui_menu_settings_dip_switches(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_DIPSWITCH) +{ +} + +ui_menu_settings_dip_switches::~ui_menu_settings_dip_switches() +{ +} + +/*------------------------------------------------- + menu_settings_driver_config - handle the + driver config menu +-------------------------------------------------*/ + +ui_menu_settings_driver_config::ui_menu_settings_driver_config(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_CONFIG) +{ +} + +ui_menu_settings_driver_config::~ui_menu_settings_driver_config() +{ +} + +/*------------------------------------------------- + menu_settings_common - handle one of the + switches menus +-------------------------------------------------*/ + +void ui_menu_settings::handle() +{ + // process the menu + const ui_menu_event *menu_event = process(0); + + // handle events + if (menu_event != NULL && menu_event->itemref != NULL) + { + // reset + if ((FPTR)menu_event->itemref == 1) + { + if (menu_event->iptkey == IPT_UI_SELECT) + machine().schedule_hard_reset(); + } + // actual settings + else + { + ioport_field *field = (ioport_field *)menu_event->itemref; + ioport_field::user_settings settings; + int changed = false; + + switch (menu_event->iptkey) + { + /* if selected, reset to default value */ + case IPT_UI_SELECT: + field->get_user_settings(settings); + settings.value = field->defvalue(); + field->set_user_settings(settings); + changed = true; + break; + + /* left goes to previous setting */ + case IPT_UI_LEFT: + field->select_previous_setting(); + changed = true; + break; + + /* right goes to next setting */ + case IPT_UI_RIGHT: + field->select_next_setting(); + changed = true; + break; + } + + /* if anything changed, rebuild the menu, trying to stay on the same field */ + if (changed) + reset(UI_MENU_RESET_REMEMBER_REF); + } + } +} + + +/*------------------------------------------------- + menu_settings_populate - populate one of the + switches menus +-------------------------------------------------*/ + +ui_menu_settings::ui_menu_settings(running_machine &machine, render_container *container, UINT32 _type) : ui_menu(machine, container) +{ + type = _type; +} + +void ui_menu_settings::populate() +{ + ioport_field *field; + ioport_port *port; + dip_descriptor **diplist_tailptr; + astring prev_owner; + bool first_entry = true; + + /* reset the dip switch tracking */ + dipcount = 0; + diplist = NULL; + diplist_tailptr = &diplist; + + /* loop over input ports and set up the current values */ + for (port = machine().ioport().first_port(); port != NULL; port = port->next()) + for (field = port->first_field(); field != NULL; field = field->next()) + if (field->type() == type && field->enabled()) + { + UINT32 flags = 0; + astring name; + + /* set the left/right flags appropriately */ + if (field->has_previous_setting()) + flags |= MENU_FLAG_LEFT_ARROW; + if (field->has_next_setting()) + flags |= MENU_FLAG_RIGHT_ARROW; + + /* add the menu item */ + if (strcmp(field->device().tag(), prev_owner.cstr()) != 0) + { + if (first_entry) + first_entry = false; + else + item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + name.printf("[root%s]", field->device().tag()); + item_append(name, NULL, 0, NULL); + prev_owner.cpy(field->device().tag()); + } + + name.cpy(field->name()); + + item_append(name, field->setting_name(), flags, (void *)field); + + /* for DIP switches, build up the model */ + if (type == IPT_DIPSWITCH && field->first_diplocation() != NULL) + { + const ioport_diplocation *diploc; + ioport_field::user_settings settings; + UINT32 accummask = field->mask(); + + /* get current settings */ + field->get_user_settings(settings); + + /* iterate over each bit in the field */ + for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next()) + { + UINT32 mask = accummask & ~(accummask - 1); + dip_descriptor *dip; + + /* find the matching switch name */ + for (dip = diplist; dip != NULL; dip = dip->next) + if (strcmp(dip->name, diploc->name()) == 0) + break; + + /* allocate new if none */ + if (dip == NULL) + { + dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip)); + dip->next = NULL; + dip->name = diploc->name(); + dip->mask = dip->state = 0; + *diplist_tailptr = dip; + diplist_tailptr = &dip->next; + dipcount++; + } + + /* apply the bits */ + dip->mask |= 1 << (diploc->number() - 1); + if (((settings.value & mask) != 0 && !diploc->inverted()) || ((settings.value & mask) == 0 && diploc->inverted())) + dip->state |= 1 << (diploc->number() - 1); + + /* clear the relevant bit in the accumulated mask */ + accummask &= ~mask; + } + } + } + if (type == IPT_DIPSWITCH) + custombottom = dipcount ? dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING : 0; + + item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + item_append("Reset", NULL, 0, (void *)1); +} + +ui_menu_settings::~ui_menu_settings() +{ +} + +/*------------------------------------------------- + menu_settings_custom_render - perform our special + rendering +-------------------------------------------------*/ + +void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) +{ + // catch if no diploc has to be drawn + if (bottom == 0) + return; + + // add borders + y1 = y2 + UI_BOX_TB_BORDER; + y2 = y1 + bottom; + + // draw extra menu area + machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); + y1 += (float)DIP_SWITCH_SPACING; + + // iterate over DIP switches + for (dip_descriptor *dip = diplist; dip != NULL; dip = dip->next) + { + const ioport_diplocation *diploc; + UINT32 selectedmask = 0; + + // determine the mask of selected bits + if ((FPTR)selectedref != 1) + { + ioport_field *field = (ioport_field *)selectedref; + + if (field != NULL && field->first_diplocation() != NULL) + for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next()) + if (strcmp(dip->name, diploc->name()) == 0) + selectedmask |= 1 << (diploc->number() - 1); + } + + // draw one switch + custom_render_one(x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask); + y1 += (float)(DIP_SWITCH_SPACING + DIP_SWITCH_HEIGHT); + } +} + + +/*------------------------------------------------- + menu_settings_custom_render_one - draw a single + DIP switch +-------------------------------------------------*/ + +void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask) +{ + float switch_field_width = SINGLE_TOGGLE_SWITCH_FIELD_WIDTH * container->manager().ui_aspect(); + float switch_width = SINGLE_TOGGLE_SWITCH_WIDTH * container->manager().ui_aspect(); + int numtoggles, toggle; + float switch_toggle_gap; + float y1_off, y1_on; + + /* determine the number of toggles in the DIP */ + numtoggles = 32 - count_leading_zeros(dip->mask); + + /* center based on the number of switches */ + x1 += (x2 - x1 - numtoggles * switch_field_width) / 2; + + /* draw the dip switch name */ + machine().ui().draw_text_full( container, + dip->name, + 0, + y1 + (DIP_SWITCH_HEIGHT - UI_TARGET_FONT_HEIGHT) / 2, + x1 - machine().ui().get_string_width(" "), + JUSTIFY_RIGHT, + WRAP_NEVER, + DRAW_NORMAL, + UI_TEXT_COLOR, + PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA), + NULL , + NULL); + + /* compute top and bottom for on and off positions */ + switch_toggle_gap = ((DIP_SWITCH_HEIGHT/2) - SINGLE_TOGGLE_SWITCH_HEIGHT)/2; + y1_off = y1 + UI_LINE_WIDTH + switch_toggle_gap; + y1_on = y1 + DIP_SWITCH_HEIGHT/2 + switch_toggle_gap; + + /* iterate over toggles */ + for (toggle = 0; toggle < numtoggles; toggle++) + { + float innerx1; + + /* first outline the switch */ + machine().ui().draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR); + + /* compute x1/x2 for the inner filled in switch */ + innerx1 = x1 + (switch_field_width - switch_width) / 2; + + /* see if the switch is actually used */ + if (dip->mask & (1 << toggle)) + { + float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off; + container->add_rect(innerx1, innery1, innerx1 + switch_width, innery1 + SINGLE_TOGGLE_SWITCH_HEIGHT, + (selectedmask & (1 << toggle)) ? UI_DIPSW_COLOR : UI_TEXT_COLOR, + PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + } + else + { + container->add_rect(innerx1, y1_off, innerx1 + switch_width, y1_on + SINGLE_TOGGLE_SWITCH_HEIGHT, + UI_UNAVAILABLE_COLOR, + PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + } + + /* advance to the next switch */ + x1 += switch_field_width; + } +} + + +/*------------------------------------------------- + menu_analog - handle the analog settings menu +-------------------------------------------------*/ + +void ui_menu_analog::handle() +{ + /* process the menu */ + const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); + + /* handle events */ + if (menu_event != NULL && menu_event->itemref != NULL) + { + analog_item_data *data = (analog_item_data *)menu_event->itemref; + int newval = data->cur; + + switch (menu_event->iptkey) + { + /* if selected, reset to default value */ + case IPT_UI_SELECT: + newval = data->defvalue; + break; + + /* left decrements */ + case IPT_UI_LEFT: + newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; + break; + + /* right increments */ + case IPT_UI_RIGHT: + newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; + break; + } + + /* clamp to range */ + if (newval < data->min) + newval = data->min; + if (newval > data->max) + newval = data->max; + + /* if things changed, update */ + if (newval != data->cur) + { + ioport_field::user_settings settings; + + /* get the settings and set the new value */ + data->field->get_user_settings(settings); + switch (data->type) + { + case ANALOG_ITEM_KEYSPEED: settings.delta = newval; break; + case ANALOG_ITEM_CENTERSPEED: settings.centerdelta = newval; break; + case ANALOG_ITEM_REVERSE: settings.reverse = newval; break; + case ANALOG_ITEM_SENSITIVITY: settings.sensitivity = newval; break; + } + data->field->set_user_settings(settings); + + /* rebuild the menu */ + reset(UI_MENU_RESET_REMEMBER_POSITION); + } + } +} + + +/*------------------------------------------------- + menu_analog_populate - populate the analog + settings menu +-------------------------------------------------*/ + +ui_menu_analog::ui_menu_analog(running_machine &machine, render_container *container) : ui_menu(machine, container) +{ +} + +void ui_menu_analog::populate() +{ + ioport_field *field; + ioport_port *port; + astring text; + astring subtext; + astring prev_owner; + bool first_entry = true; + + /* loop over input ports and add the items */ + for (port = machine().ioport().first_port(); port != NULL; port = port->next()) + for (field = port->first_field(); field != NULL; field = field->next()) + if (field->is_analog() && field->enabled()) + { + ioport_field::user_settings settings; + int use_autocenter = false; + int type; + + /* based on the type, determine if we enable autocenter */ + switch (field->type()) + { + case IPT_POSITIONAL: + case IPT_POSITIONAL_V: + if (field->analog_wraps()) + break; + + case IPT_AD_STICK_X: + case IPT_AD_STICK_Y: + case IPT_AD_STICK_Z: + case IPT_PADDLE: + case IPT_PADDLE_V: + case IPT_PEDAL: + case IPT_PEDAL2: + case IPT_PEDAL3: + use_autocenter = true; + break; + + default: + break; + } + + /* get the user settings */ + field->get_user_settings(settings); + + /* iterate over types */ + for (type = 0; type < ANALOG_ITEM_COUNT; type++) + if (type != ANALOG_ITEM_CENTERSPEED || use_autocenter) + { + analog_item_data *data; + UINT32 flags = 0; + astring name; + if (strcmp(field->device().tag(), prev_owner.cstr()) != 0) + { + if (first_entry) + first_entry = false; + else + item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + name.printf("[root%s]", field->device().tag()); + item_append(name, NULL, 0, NULL); + prev_owner.cpy(field->device().tag()); + } + + name.cpy(field->name()); + + /* allocate a data item for tracking what this menu item refers to */ + data = (analog_item_data *)m_pool_alloc(sizeof(*data)); + data->field = field; + data->type = type; + + /* determine the properties of this item */ + switch (type) + { + default: + case ANALOG_ITEM_KEYSPEED: + text.printf("%s Digital Speed", name.cstr()); + subtext.printf("%d", settings.delta); + data->min = 0; + data->max = 255; + data->cur = settings.delta; + data->defvalue = field->delta(); + break; + + case ANALOG_ITEM_CENTERSPEED: + text.printf("%s Autocenter Speed", name.cstr()); + subtext.printf("%d", settings.centerdelta); + data->min = 0; + data->max = 255; + data->cur = settings.centerdelta; + data->defvalue = field->centerdelta(); + break; + + case ANALOG_ITEM_REVERSE: + text.printf("%s Reverse", name.cstr()); + subtext.cpy(settings.reverse ? "On" : "Off"); + data->min = 0; + data->max = 1; + data->cur = settings.reverse; + data->defvalue = field->analog_reverse(); + break; + + case ANALOG_ITEM_SENSITIVITY: + text.printf("%s Sensitivity", name.cstr()); + subtext.printf("%d", settings.sensitivity); + data->min = 1; + data->max = 255; + data->cur = settings.sensitivity; + data->defvalue = field->sensitivity(); + break; + } + + /* put on arrows */ + if (data->cur > data->min) + flags |= MENU_FLAG_LEFT_ARROW; + if (data->cur < data->max) + flags |= MENU_FLAG_RIGHT_ARROW; + + /* append a menu item */ + item_append(text, subtext, flags, data); + } + } +} + +ui_menu_analog::~ui_menu_analog() +{ +} diff --git a/src/emu/ui/inputmap.h b/src/emu/ui/inputmap.h new file mode 100644 index 00000000000..2759b3adabc --- /dev/null +++ b/src/emu/ui/inputmap.h @@ -0,0 +1,156 @@ +/*************************************************************************** + + ui/inputmap.h + + Internal menus for input mappings. + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +***************************************************************************/ + +#pragma once + +#ifndef __UI_INPUTMAP_H__ +#define __UI_INPUTMAP_H__ + +//#include "drivenum.h" + +class ui_menu_input_groups : public ui_menu { +public: + ui_menu_input_groups(running_machine &machine, render_container *container); + virtual ~ui_menu_input_groups(); + virtual void populate(); + virtual void handle(); +}; + +class ui_menu_input : public ui_menu { +public: + ui_menu_input(running_machine &machine, render_container *container); + virtual ~ui_menu_input(); + virtual void handle(); + +protected: + enum { + INPUT_TYPE_DIGITAL = 0, + INPUT_TYPE_ANALOG = 1, + INPUT_TYPE_ANALOG_DEC = INPUT_TYPE_ANALOG + SEQ_TYPE_DECREMENT, + INPUT_TYPE_ANALOG_INC = INPUT_TYPE_ANALOG + SEQ_TYPE_INCREMENT, + INPUT_TYPE_TOTAL = INPUT_TYPE_ANALOG + SEQ_TYPE_TOTAL + }; + + /* internal input menu item data */ + struct input_item_data { + input_item_data * next; /* pointer to next item in the list */ + const void * ref; /* reference to type description for global inputs or field for game inputs */ + input_seq_type seqtype; /* sequence type */ + input_seq seq; /* copy of the live sequence */ + const input_seq * defseq; /* pointer to the default sequence */ + const char * name; /* pointer to the base name of the item */ + const char * owner_name; /* pointer to the name of the owner of the item */ + UINT32 sortorder; /* sorting information */ + UINT8 type; /* type of port */ + }; + + void populate_and_sort(struct input_item_data *itemlist); + virtual void update_input(struct input_item_data *seqchangeditem) = 0; + void toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq); + +protected: + const void * pollingref; + input_seq_type pollingseq; + input_item_data * pollingitem; + +private: + UINT16 last_sortorder; + bool record_next; + input_seq starting_seq; + + static int compare_items(const void *i1, const void *i2); +}; + +class ui_menu_input_general : public ui_menu_input { +public: + ui_menu_input_general(running_machine &machine, render_container *container, int group); + virtual ~ui_menu_input_general(); + virtual void populate(); + +protected: + int group; + virtual void update_input(struct input_item_data *seqchangeditem); +}; + +class ui_menu_input_specific : public ui_menu_input { +public: + ui_menu_input_specific(running_machine &machine, render_container *container); + virtual ~ui_menu_input_specific(); + virtual void populate(); + +protected: + virtual void update_input(struct input_item_data *seqchangeditem); +}; + +class ui_menu_settings : public ui_menu { +public: + ui_menu_settings(running_machine &machine, render_container *container, UINT32 type); + virtual ~ui_menu_settings(); + virtual void populate(); + virtual void handle(); + +protected: + /* DIP switch descriptor */ + struct dip_descriptor { + dip_descriptor * next; + const char * name; + UINT32 mask; + UINT32 state; + }; + + dip_descriptor * diplist; + int dipcount; + int type; +}; + +class ui_menu_settings_dip_switches : public ui_menu_settings { +public: + ui_menu_settings_dip_switches(running_machine &machine, render_container *container); + virtual ~ui_menu_settings_dip_switches(); + + virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); +private: + void custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask); +}; + +class ui_menu_settings_driver_config : public ui_menu_settings { +public: + ui_menu_settings_driver_config(running_machine &machine, render_container *container); + virtual ~ui_menu_settings_driver_config(); +}; + +class ui_menu_analog : public ui_menu { +public: + ui_menu_analog(running_machine &machine, render_container *container); + virtual ~ui_menu_analog(); + virtual void populate(); + virtual void handle(); + +private: + enum { + ANALOG_ITEM_KEYSPEED = 0, + ANALOG_ITEM_CENTERSPEED, + ANALOG_ITEM_REVERSE, + ANALOG_ITEM_SENSITIVITY, + ANALOG_ITEM_COUNT + }; + + /* internal analog menu item data */ + struct analog_item_data { + ioport_field *field; + int type; + int min, max; + int cur; + int defvalue; + }; +}; + +#endif /* __UI_INPUTMAP_H__ */ diff --git a/src/emu/ui/mainmenu.c b/src/emu/ui/mainmenu.c index c0cd67e27f1..90418814e21 100644 --- a/src/emu/ui/mainmenu.c +++ b/src/emu/ui/mainmenu.c @@ -19,11 +19,13 @@ #include "ui/filemngr.h" #include "ui/filesel.h" #include "ui/barcode.h" -#include "ui/tapectrl.h" +#include "ui/imginfo.h" +#include "ui/inputmap.h" #include "ui/mainmenu.h" #include "ui/miscmenu.h" -#include "ui/imginfo.h" #include "ui/selgame.h" +#include "ui/slotopt.h" +#include "ui/tapectrl.h" #include "audit.h" #include "crsshair.h" #include diff --git a/src/emu/ui/miscmenu.c b/src/emu/ui/miscmenu.c index f4b83ea6273..bd3b2812e27 100644 --- a/src/emu/ui/miscmenu.c +++ b/src/emu/ui/miscmenu.c @@ -24,23 +24,6 @@ #include "ui/filemngr.h" -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -#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 -#define DIP_SWITCH_SPACING 0.01 -#define SINGLE_TOGGLE_SWITCH_FIELD_WIDTH 0.025f -#define SINGLE_TOGGLE_SWITCH_WIDTH 0.020f -/* make the switch 80% of the width space and 1/2 of the switch height */ -#define PERCENTAGE_OF_HALF_FIELD_USED 0.80f -#define SINGLE_TOGGLE_SWITCH_HEIGHT ((DIP_SWITCH_HEIGHT / 2) * PERCENTAGE_OF_HALF_FIELD_USED) - /*------------------------------------------------- ui_slider_ui_handler - pushes the slider menu on the stack and hands off to the @@ -107,189 +90,6 @@ void ui_menu_keyboard_mode::handle() } -/*------------------------------------------------- - ui_slot_get_current_option - returns --------------------------------------------------*/ -device_slot_option *ui_menu_slot_devices::slot_get_current_option(device_slot_interface *slot) -{ - const char *current; - if (slot->fixed()) - { - current = slot->default_option(); - } - else - { - astring temp; - current = machine().options().main_value(temp, slot->device().tag() + 1); - } - - return slot->option(current); -} - -/*------------------------------------------------- - ui_slot_get_current_index - returns --------------------------------------------------*/ -int ui_menu_slot_devices::slot_get_current_index(device_slot_interface *slot) -{ - const device_slot_option *current = slot_get_current_option(slot); - - if (current != NULL) - { - int val = 0; - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) - { - if (option == current) - return val; - - if (option->selectable()) - val++; - } - } - - return -1; -} - -/*------------------------------------------------- - ui_slot_get_length - returns --------------------------------------------------*/ -int ui_menu_slot_devices::slot_get_length(device_slot_interface *slot) -{ - int val = 0; - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) - if (option->selectable()) - val++; - - return val; -} - -/*------------------------------------------------- - ui_slot_get_next - returns --------------------------------------------------*/ -const char *ui_menu_slot_devices::slot_get_next(device_slot_interface *slot) -{ - int idx = slot_get_current_index(slot); - if (idx < 0) - idx = 0; - else - idx++; - - if (idx >= slot_get_length(slot)) - return ""; - - return slot_get_option(slot, idx); -} - -/*------------------------------------------------- - ui_slot_get_prev - returns --------------------------------------------------*/ -const char *ui_menu_slot_devices::slot_get_prev(device_slot_interface *slot) -{ - int idx = slot_get_current_index(slot); - if (idx < 0) - idx = slot_get_length(slot) - 1; - else - idx--; - - if (idx < 0) - return ""; - - return slot_get_option(slot, idx); -} - -/*------------------------------------------------- - ui_slot_get_option - returns --------------------------------------------------*/ -const char *ui_menu_slot_devices::slot_get_option(device_slot_interface *slot, int index) -{ - if (index >= 0) - { - int val = 0; - for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) - { - if (val == index) - return option->name(); - - if (option->selectable()) - val++; - } - } - - return ""; -} - - -/*------------------------------------------------- - ui_set_use_natural_keyboard - specifies - whether the natural keyboard is active --------------------------------------------------*/ - -void ui_menu_slot_devices::set_slot_device(device_slot_interface *slot, const char *val) -{ - astring error; - machine().options().set_value(slot->device().tag()+1, val, OPTION_PRIORITY_CMDLINE, error); - assert(!error); -} - -/*------------------------------------------------- - menu_slot_devices_populate - populates the main - slot device menu --------------------------------------------------*/ - -ui_menu_slot_devices::ui_menu_slot_devices(running_machine &machine, render_container *container) : ui_menu(machine, container) -{ -} - -void ui_menu_slot_devices::populate() -{ - /* cycle through all devices for this system */ - slot_interface_iterator iter(machine().root_device()); - for (device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next()) - { - /* record the menu item */ - const device_slot_option *option = slot_get_current_option(slot); - astring opt_name; - if (option == NULL) - opt_name.cpy("------"); - else - { - opt_name.cpy(option->name()); - if (slot->fixed() || slot_get_length(slot) == 0) - opt_name.cat(" [internal]"); - } - - item_append(slot->device().tag() + 1, opt_name, (slot->fixed() || slot_get_length(slot) == 0) ? 0 : (MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), (void *)slot); - } - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - item_append("Reset", NULL, 0, (void *)1); -} - -ui_menu_slot_devices::~ui_menu_slot_devices() -{ -} - -/*------------------------------------------------- - ui_menu_slot_devices - menu that --------------------------------------------------*/ - -void ui_menu_slot_devices::handle() -{ - /* process the menu */ - const ui_menu_event *menu_event = process(0); - - if (menu_event != NULL && menu_event->itemref != NULL) - { - if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT) - machine().schedule_hard_reset(); - else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) - { - device_slot_interface *slot = (device_slot_interface *)menu_event->itemref; - const char *val = (menu_event->iptkey == IPT_UI_LEFT) ? slot_get_prev(slot) : slot_get_next(slot); - set_slot_device(slot, val); - reset(UI_MENU_RESET_REMEMBER_REF); - } - } -} - /*------------------------------------------------- ui_menu_bios_selection - populates the main bios selection menu @@ -426,915 +226,6 @@ void ui_menu_network_devices::handle() } } -/*------------------------------------------------- - menu_input_groups_populate - populate the - input groups menu --------------------------------------------------*/ - -ui_menu_input_groups::ui_menu_input_groups(running_machine &machine, render_container *container) : ui_menu(machine, container) -{ -} - -void ui_menu_input_groups::populate() -{ - int player; - - /* build up the menu */ - item_append("User Interface", NULL, 0, (void *)(IPG_UI + 1)); - for (player = 0; player < MAX_PLAYERS; player++) - { - char buffer[40]; - sprintf(buffer, "Player %d Controls", player + 1); - item_append(buffer, NULL, 0, (void *)(FPTR)(IPG_PLAYER1 + player + 1)); - } - item_append("Other Controls", NULL, 0, (void *)(FPTR)(IPG_OTHER + 1)); -} - -ui_menu_input_groups::~ui_menu_input_groups() -{ -} - -/*------------------------------------------------- - menu_input_groups - handle the input groups - menu --------------------------------------------------*/ - -void ui_menu_input_groups::handle() -{ - /* process the menu */ - const ui_menu_event *menu_event = process(0); - if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) - ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_general(machine(), container, int((long long)(menu_event->itemref)-1)))); -} - - - -/*------------------------------------------------- - menu_input_general - handle the general - input menu --------------------------------------------------*/ - -ui_menu_input_general::ui_menu_input_general(running_machine &machine, render_container *container, int _group) : ui_menu_input(machine, container) -{ - group = _group; -} - -void ui_menu_input_general::populate() -{ - input_item_data *itemlist = NULL; - int suborder[SEQ_TYPE_TOTAL]; - astring tempstring; - int sortorder = 1; - - /* create a mini lookup table for sort order based on sequence type */ - suborder[SEQ_TYPE_STANDARD] = 0; - suborder[SEQ_TYPE_DECREMENT] = 1; - suborder[SEQ_TYPE_INCREMENT] = 2; - - /* iterate over the input ports and add menu items */ - for (input_type_entry *entry = machine().ioport().first_type(); entry != NULL; entry = entry->next()) - - /* add if we match the group and we have a valid name */ - if (entry->group() == group && entry->name() != NULL && entry->name()[0] != 0) - { - input_seq_type seqtype; - - /* loop over all sequence types */ - sortorder++; - for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++) - { - /* build an entry for the standard sequence */ - input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item)); - memset(item, 0, sizeof(*item)); - item->ref = entry; - if(pollingitem && pollingref == entry && pollingseq == seqtype) - pollingitem = item; - item->seqtype = seqtype; - item->seq = machine().ioport().type_seq(entry->type(), entry->player(), seqtype); - item->defseq = &entry->defseq(seqtype); - item->sortorder = sortorder * 4 + suborder[seqtype]; - item->type = ioport_manager::type_is_analog(entry->type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; - item->name = entry->name(); - item->owner_name = NULL; - item->next = itemlist; - itemlist = item; - - /* stop after one, unless we're analog */ - if (item->type == INPUT_TYPE_DIGITAL) - break; - } - } - - /* sort and populate the menu in a standard fashion */ - populate_and_sort(itemlist); -} - -ui_menu_input_general::~ui_menu_input_general() -{ -} - -/*------------------------------------------------- - menu_input_specific - handle the game-specific - input menu --------------------------------------------------*/ - -ui_menu_input_specific::ui_menu_input_specific(running_machine &machine, render_container *container) : ui_menu_input(machine, container) -{ -} - -void ui_menu_input_specific::populate() -{ - input_item_data *itemlist = NULL; - ioport_field *field; - ioport_port *port; - int suborder[SEQ_TYPE_TOTAL]; - astring tempstring; - - /* create a mini lookup table for sort order based on sequence type */ - suborder[SEQ_TYPE_STANDARD] = 0; - suborder[SEQ_TYPE_DECREMENT] = 1; - suborder[SEQ_TYPE_INCREMENT] = 2; - - /* iterate over the input ports and add menu items */ - for (port = machine().ioport().first_port(); port != NULL; port = port->next()) - for (field = port->first_field(); field != NULL; field = field->next()) - { - const char *name = field->name(); - - /* add if we match the group and we have a valid name */ - if (name != NULL && field->enabled() && - ((field->type() == IPT_OTHER && field->name() != NULL) || machine().ioport().type_group(field->type(), field->player()) != IPG_INVALID)) - { - input_seq_type seqtype; - UINT32 sortorder; - - /* determine the sorting order */ - if (field->type() >= IPT_START1 && field->type() < IPT_ANALOG_LAST) - { - sortorder = (field->type() << 2) | (field->player() << 12); - if (strcmp(field->device().tag(), ":")) - sortorder |= 0x10000; - } - else - sortorder = field->type() | 0xf000; - - /* loop over all sequence types */ - for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++) - { - /* build an entry for the standard sequence */ - input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item)); - memset(item, 0, sizeof(*item)); - item->ref = field; - item->seqtype = seqtype; - if(pollingitem && pollingref == field && pollingseq == seqtype) - pollingitem = item; - item->seq = field->seq(seqtype); - item->defseq = &field->defseq(seqtype); - item->sortorder = sortorder + suborder[seqtype]; - item->type = field->is_analog() ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; - item->name = name; - item->owner_name = field->device().tag(); - item->next = itemlist; - itemlist = item; - - /* stop after one, unless we're analog */ - if (item->type == INPUT_TYPE_DIGITAL) - break; - } - } - } - - /* sort and populate the menu in a standard fashion */ - populate_and_sort(itemlist); -} - -ui_menu_input_specific::~ui_menu_input_specific() -{ -} - -/*------------------------------------------------- - menu_input - display a menu for inputs --------------------------------------------------*/ -ui_menu_input::ui_menu_input(running_machine &machine, render_container *container) : ui_menu(machine, container) -{ - pollingitem = 0; - pollingref = 0; - pollingseq = SEQ_TYPE_STANDARD; -} - -ui_menu_input::~ui_menu_input() -{ -} - -/*------------------------------------------------- - toggle_none_default - toggle between "NONE" - and the default item --------------------------------------------------*/ - -void ui_menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq) -{ - /* if we used to be "none", toggle to the default value */ - if (original_seq.length() == 0) - selected_seq = selected_defseq; - - /* otherwise, toggle to "none" */ - else - selected_seq.reset(); -} - -void ui_menu_input::handle() -{ - input_item_data *seqchangeditem = NULL; - const ui_menu_event *menu_event; - int invalidate = false; - - /* process the menu */ - menu_event = process((pollingitem != NULL) ? UI_MENU_PROCESS_NOKEYS : 0); - - /* if we are polling, handle as a special case */ - if (pollingitem != NULL) - { - input_item_data *item = pollingitem; - input_seq newseq; - - /* if UI_CANCEL is pressed, abort */ - if (ui_input_pressed(machine(), IPT_UI_CANCEL)) - { - pollingitem = NULL; - record_next = false; - toggle_none_default(item->seq, starting_seq, *item->defseq); - seqchangeditem = item; - } - - /* poll again; if finished, update the sequence */ - if (machine().input().seq_poll()) - { - pollingitem = NULL; - record_next = true; - item->seq = machine().input().seq_poll_final(); - seqchangeditem = item; - } - } - - /* otherwise, handle the events */ - else if (menu_event != NULL && menu_event->itemref != NULL) - { - input_item_data *item = (input_item_data *)menu_event->itemref; - switch (menu_event->iptkey) - { - /* an item was selected: begin polling */ - case IPT_UI_SELECT: - pollingitem = item; - last_sortorder = item->sortorder; - starting_seq = item->seq; - machine().input().seq_poll_start((item->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &item->seq : NULL); - invalidate = true; - break; - - /* if the clear key was pressed, reset the selected item */ - case IPT_UI_CLEAR: - toggle_none_default(item->seq, item->seq, *item->defseq); - record_next = false; - seqchangeditem = item; - break; - } - - /* if the selection changed, reset the "record next" flag */ - if (item->sortorder != last_sortorder) - record_next = false; - last_sortorder = item->sortorder; - } - - /* if the sequence changed, update it */ - if (seqchangeditem != NULL) - { - update_input(seqchangeditem); - - /* invalidate the menu to force an update */ - invalidate = true; - } - - /* if the menu is invalidated, clear it now */ - if (invalidate) - { - pollingref = NULL; - if (pollingitem != NULL) - { - pollingref = pollingitem->ref; - pollingseq = pollingitem->seqtype; - } - reset(UI_MENU_RESET_REMEMBER_POSITION); - } -} - -void ui_menu_input_general::update_input(struct input_item_data *seqchangeditem) -{ - const input_type_entry *entry = (const input_type_entry *)seqchangeditem->ref; - machine().ioport().set_type_seq(entry->type(), entry->player(), seqchangeditem->seqtype, seqchangeditem->seq); -} - -void ui_menu_input_specific::update_input(struct input_item_data *seqchangeditem) -{ - ioport_field::user_settings settings; - - ((ioport_field *)seqchangeditem->ref)->get_user_settings(settings); - settings.seq[seqchangeditem->seqtype] = seqchangeditem->seq; - ((ioport_field *)seqchangeditem->ref)->set_user_settings(settings); -} - - -/*------------------------------------------------- - menu_input_compare_items - compare two - items for quicksort --------------------------------------------------*/ - -int ui_menu_input::compare_items(const void *i1, const void *i2) -{ - const input_item_data * const *data1 = (const input_item_data * const *)i1; - const input_item_data * const *data2 = (const input_item_data * const *)i2; - if ((*data1)->sortorder < (*data2)->sortorder) - return -1; - if ((*data1)->sortorder > (*data2)->sortorder) - return 1; - return 0; -} - - -/*------------------------------------------------- - menu_input_populate_and_sort - take a list - of input_item_data objects and build up the - menu from them --------------------------------------------------*/ - -void ui_menu_input::populate_and_sort(input_item_data *itemlist) -{ - const char *nameformat[INPUT_TYPE_TOTAL] = { 0 }; - input_item_data **itemarray, *item; - int numitems = 0, curitem; - astring text; - astring subtext; - astring prev_owner; - bool first_entry = true; - - /* create a mini lookup table for name format based on type */ - nameformat[INPUT_TYPE_DIGITAL] = "%s"; - nameformat[INPUT_TYPE_ANALOG] = "%s Analog"; - nameformat[INPUT_TYPE_ANALOG_INC] = "%s Analog Inc"; - nameformat[INPUT_TYPE_ANALOG_DEC] = "%s Analog Dec"; - - /* first count the number of items */ - for (item = itemlist; item != NULL; item = item->next) - numitems++; - - /* now allocate an array of items and fill it up */ - itemarray = (input_item_data **)m_pool_alloc(sizeof(*itemarray) * numitems); - for (item = itemlist, curitem = 0; item != NULL; item = item->next) - itemarray[curitem++] = item; - - /* sort it */ - qsort(itemarray, numitems, sizeof(*itemarray), compare_items); - - /* build the menu */ - for (curitem = 0; curitem < numitems; curitem++) - { - UINT32 flags = 0; - - /* generate the name of the item itself, based off the base name and the type */ - item = itemarray[curitem]; - assert(nameformat[item->type] != NULL); - - if (strcmp(item->owner_name, prev_owner.cstr()) != 0) - { - if (first_entry) - first_entry = false; - else - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - text.printf("[root%s]", item->owner_name); - item_append(text, NULL, 0, NULL); - prev_owner.cpy(item->owner_name); - } - - text.printf(nameformat[item->type], item->name); - - /* if we're polling this item, use some spaces with left/right arrows */ - if (pollingref == item->ref) - { - subtext.cpy(" "); - flags |= MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; - } - - /* otherwise, generate the sequence name and invert it if different from the default */ - else - { - machine().input().seq_name(subtext, item->seq); - flags |= (item->seq != *item->defseq) ? MENU_FLAG_INVERT : 0; - } - - /* add the item */ - item_append(text, subtext, flags, item); - } -} - - -/*------------------------------------------------- - menu_settings_dip_switches - handle the DIP - switches menu --------------------------------------------------*/ - -ui_menu_settings_dip_switches::ui_menu_settings_dip_switches(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_DIPSWITCH) -{ -} - -ui_menu_settings_dip_switches::~ui_menu_settings_dip_switches() -{ -} - -/*------------------------------------------------- - menu_settings_driver_config - handle the - driver config menu --------------------------------------------------*/ - -ui_menu_settings_driver_config::ui_menu_settings_driver_config(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_CONFIG) -{ -} - -ui_menu_settings_driver_config::~ui_menu_settings_driver_config() -{ -} - -/*------------------------------------------------- - menu_settings_common - handle one of the - switches menus --------------------------------------------------*/ - -void ui_menu_settings::handle() -{ - // process the menu - const ui_menu_event *menu_event = process(0); - - // handle events - if (menu_event != NULL && menu_event->itemref != NULL) - { - // reset - if ((FPTR)menu_event->itemref == 1) - { - if (menu_event->iptkey == IPT_UI_SELECT) - machine().schedule_hard_reset(); - } - // actual settings - else - { - ioport_field *field = (ioport_field *)menu_event->itemref; - ioport_field::user_settings settings; - int changed = false; - - switch (menu_event->iptkey) - { - /* if selected, reset to default value */ - case IPT_UI_SELECT: - field->get_user_settings(settings); - settings.value = field->defvalue(); - field->set_user_settings(settings); - changed = true; - break; - - /* left goes to previous setting */ - case IPT_UI_LEFT: - field->select_previous_setting(); - changed = true; - break; - - /* right goes to next setting */ - case IPT_UI_RIGHT: - field->select_next_setting(); - changed = true; - break; - } - - /* if anything changed, rebuild the menu, trying to stay on the same field */ - if (changed) - reset(UI_MENU_RESET_REMEMBER_REF); - } - } -} - - -/*------------------------------------------------- - menu_settings_populate - populate one of the - switches menus --------------------------------------------------*/ - -ui_menu_settings::ui_menu_settings(running_machine &machine, render_container *container, UINT32 _type) : ui_menu(machine, container) -{ - type = _type; -} - -void ui_menu_settings::populate() -{ - ioport_field *field; - ioport_port *port; - dip_descriptor **diplist_tailptr; - astring prev_owner; - bool first_entry = true; - - /* reset the dip switch tracking */ - dipcount = 0; - diplist = NULL; - diplist_tailptr = &diplist; - - /* loop over input ports and set up the current values */ - for (port = machine().ioport().first_port(); port != NULL; port = port->next()) - for (field = port->first_field(); field != NULL; field = field->next()) - if (field->type() == type && field->enabled()) - { - UINT32 flags = 0; - astring name; - - /* set the left/right flags appropriately */ - if (field->has_previous_setting()) - flags |= MENU_FLAG_LEFT_ARROW; - if (field->has_next_setting()) - flags |= MENU_FLAG_RIGHT_ARROW; - - /* add the menu item */ - if (strcmp(field->device().tag(), prev_owner.cstr()) != 0) - { - if (first_entry) - first_entry = false; - else - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - name.printf("[root%s]", field->device().tag()); - item_append(name, NULL, 0, NULL); - prev_owner.cpy(field->device().tag()); - } - - name.cpy(field->name()); - - item_append(name, field->setting_name(), flags, (void *)field); - - /* for DIP switches, build up the model */ - if (type == IPT_DIPSWITCH && field->first_diplocation() != NULL) - { - const ioport_diplocation *diploc; - ioport_field::user_settings settings; - UINT32 accummask = field->mask(); - - /* get current settings */ - field->get_user_settings(settings); - - /* iterate over each bit in the field */ - for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next()) - { - UINT32 mask = accummask & ~(accummask - 1); - dip_descriptor *dip; - - /* find the matching switch name */ - for (dip = diplist; dip != NULL; dip = dip->next) - if (strcmp(dip->name, diploc->name()) == 0) - break; - - /* allocate new if none */ - if (dip == NULL) - { - dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip)); - dip->next = NULL; - dip->name = diploc->name(); - dip->mask = dip->state = 0; - *diplist_tailptr = dip; - diplist_tailptr = &dip->next; - dipcount++; - } - - /* apply the bits */ - dip->mask |= 1 << (diploc->number() - 1); - if (((settings.value & mask) != 0 && !diploc->inverted()) || ((settings.value & mask) == 0 && diploc->inverted())) - dip->state |= 1 << (diploc->number() - 1); - - /* clear the relevant bit in the accumulated mask */ - accummask &= ~mask; - } - } - } - if (type == IPT_DIPSWITCH) - custombottom = dipcount ? dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING : 0; - - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - item_append("Reset", NULL, 0, (void *)1); -} - -ui_menu_settings::~ui_menu_settings() -{ -} - -/*------------------------------------------------- - menu_settings_custom_render - perform our special - rendering --------------------------------------------------*/ - -void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) -{ - // catch if no diploc has to be drawn - if (bottom == 0) - return; - - // add borders - y1 = y2 + UI_BOX_TB_BORDER; - y2 = y1 + bottom; - - // draw extra menu area - machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); - y1 += (float)DIP_SWITCH_SPACING; - - // iterate over DIP switches - for (dip_descriptor *dip = diplist; dip != NULL; dip = dip->next) - { - const ioport_diplocation *diploc; - UINT32 selectedmask = 0; - - // determine the mask of selected bits - if ((FPTR)selectedref != 1) - { - ioport_field *field = (ioport_field *)selectedref; - - if (field != NULL && field->first_diplocation() != NULL) - for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next()) - if (strcmp(dip->name, diploc->name()) == 0) - selectedmask |= 1 << (diploc->number() - 1); - } - - // draw one switch - custom_render_one(x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask); - y1 += (float)(DIP_SWITCH_SPACING + DIP_SWITCH_HEIGHT); - } -} - - -/*------------------------------------------------- - menu_settings_custom_render_one - draw a single - DIP switch --------------------------------------------------*/ - -void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask) -{ - float switch_field_width = SINGLE_TOGGLE_SWITCH_FIELD_WIDTH * container->manager().ui_aspect(); - float switch_width = SINGLE_TOGGLE_SWITCH_WIDTH * container->manager().ui_aspect(); - int numtoggles, toggle; - float switch_toggle_gap; - float y1_off, y1_on; - - /* determine the number of toggles in the DIP */ - numtoggles = 32 - count_leading_zeros(dip->mask); - - /* center based on the number of switches */ - x1 += (x2 - x1 - numtoggles * switch_field_width) / 2; - - /* draw the dip switch name */ - machine().ui().draw_text_full( container, - dip->name, - 0, - y1 + (DIP_SWITCH_HEIGHT - UI_TARGET_FONT_HEIGHT) / 2, - x1 - machine().ui().get_string_width(" "), - JUSTIFY_RIGHT, - WRAP_NEVER, - DRAW_NORMAL, - UI_TEXT_COLOR, - PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA), - NULL , - NULL); - - /* compute top and bottom for on and off positions */ - switch_toggle_gap = ((DIP_SWITCH_HEIGHT/2) - SINGLE_TOGGLE_SWITCH_HEIGHT)/2; - y1_off = y1 + UI_LINE_WIDTH + switch_toggle_gap; - y1_on = y1 + DIP_SWITCH_HEIGHT/2 + switch_toggle_gap; - - /* iterate over toggles */ - for (toggle = 0; toggle < numtoggles; toggle++) - { - float innerx1; - - /* first outline the switch */ - machine().ui().draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR); - - /* compute x1/x2 for the inner filled in switch */ - innerx1 = x1 + (switch_field_width - switch_width) / 2; - - /* see if the switch is actually used */ - if (dip->mask & (1 << toggle)) - { - float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off; - container->add_rect(innerx1, innery1, innerx1 + switch_width, innery1 + SINGLE_TOGGLE_SWITCH_HEIGHT, - (selectedmask & (1 << toggle)) ? UI_DIPSW_COLOR : UI_TEXT_COLOR, - PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - } - else - { - container->add_rect(innerx1, y1_off, innerx1 + switch_width, y1_on + SINGLE_TOGGLE_SWITCH_HEIGHT, - UI_UNAVAILABLE_COLOR, - PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - } - - /* advance to the next switch */ - x1 += switch_field_width; - } -} - - -/*------------------------------------------------- - menu_analog - handle the analog settings menu --------------------------------------------------*/ - -void ui_menu_analog::handle() -{ - /* process the menu */ - const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); - - /* handle events */ - if (menu_event != NULL && menu_event->itemref != NULL) - { - analog_item_data *data = (analog_item_data *)menu_event->itemref; - int newval = data->cur; - - switch (menu_event->iptkey) - { - /* if selected, reset to default value */ - case IPT_UI_SELECT: - newval = data->defvalue; - break; - - /* left decrements */ - case IPT_UI_LEFT: - newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; - break; - - /* right increments */ - case IPT_UI_RIGHT: - newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; - break; - } - - /* clamp to range */ - if (newval < data->min) - newval = data->min; - if (newval > data->max) - newval = data->max; - - /* if things changed, update */ - if (newval != data->cur) - { - ioport_field::user_settings settings; - - /* get the settings and set the new value */ - data->field->get_user_settings(settings); - switch (data->type) - { - case ANALOG_ITEM_KEYSPEED: settings.delta = newval; break; - case ANALOG_ITEM_CENTERSPEED: settings.centerdelta = newval; break; - case ANALOG_ITEM_REVERSE: settings.reverse = newval; break; - case ANALOG_ITEM_SENSITIVITY: settings.sensitivity = newval; break; - } - data->field->set_user_settings(settings); - - /* rebuild the menu */ - reset(UI_MENU_RESET_REMEMBER_POSITION); - } - } -} - - -/*------------------------------------------------- - menu_analog_populate - populate the analog - settings menu --------------------------------------------------*/ - -ui_menu_analog::ui_menu_analog(running_machine &machine, render_container *container) : ui_menu(machine, container) -{ -} - -void ui_menu_analog::populate() -{ - ioport_field *field; - ioport_port *port; - astring text; - astring subtext; - astring prev_owner; - bool first_entry = true; - - /* loop over input ports and add the items */ - for (port = machine().ioport().first_port(); port != NULL; port = port->next()) - for (field = port->first_field(); field != NULL; field = field->next()) - if (field->is_analog() && field->enabled()) - { - ioport_field::user_settings settings; - int use_autocenter = false; - int type; - - /* based on the type, determine if we enable autocenter */ - switch (field->type()) - { - case IPT_POSITIONAL: - case IPT_POSITIONAL_V: - if (field->analog_wraps()) - break; - - case IPT_AD_STICK_X: - case IPT_AD_STICK_Y: - case IPT_AD_STICK_Z: - case IPT_PADDLE: - case IPT_PADDLE_V: - case IPT_PEDAL: - case IPT_PEDAL2: - case IPT_PEDAL3: - use_autocenter = true; - break; - - default: - break; - } - - /* get the user settings */ - field->get_user_settings(settings); - - /* iterate over types */ - for (type = 0; type < ANALOG_ITEM_COUNT; type++) - if (type != ANALOG_ITEM_CENTERSPEED || use_autocenter) - { - analog_item_data *data; - UINT32 flags = 0; - astring name; - if (strcmp(field->device().tag(), prev_owner.cstr()) != 0) - { - if (first_entry) - first_entry = false; - else - item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); - name.printf("[root%s]", field->device().tag()); - item_append(name, NULL, 0, NULL); - prev_owner.cpy(field->device().tag()); - } - - name.cpy(field->name()); - - /* allocate a data item for tracking what this menu item refers to */ - data = (analog_item_data *)m_pool_alloc(sizeof(*data)); - data->field = field; - data->type = type; - - /* determine the properties of this item */ - switch (type) - { - default: - case ANALOG_ITEM_KEYSPEED: - text.printf("%s Digital Speed", name.cstr()); - subtext.printf("%d", settings.delta); - data->min = 0; - data->max = 255; - data->cur = settings.delta; - data->defvalue = field->delta(); - break; - - case ANALOG_ITEM_CENTERSPEED: - text.printf("%s Autocenter Speed", name.cstr()); - subtext.printf("%d", settings.centerdelta); - data->min = 0; - data->max = 255; - data->cur = settings.centerdelta; - data->defvalue = field->centerdelta(); - break; - - case ANALOG_ITEM_REVERSE: - text.printf("%s Reverse", name.cstr()); - subtext.cpy(settings.reverse ? "On" : "Off"); - data->min = 0; - data->max = 1; - data->cur = settings.reverse; - data->defvalue = field->analog_reverse(); - break; - - case ANALOG_ITEM_SENSITIVITY: - text.printf("%s Sensitivity", name.cstr()); - subtext.printf("%d", settings.sensitivity); - data->min = 1; - data->max = 255; - data->cur = settings.sensitivity; - data->defvalue = field->sensitivity(); - break; - } - - /* put on arrows */ - if (data->cur > data->min) - flags |= MENU_FLAG_LEFT_ARROW; - if (data->cur < data->max) - flags |= MENU_FLAG_RIGHT_ARROW; - - /* append a menu item */ - item_append(text, subtext, flags, data); - } - } -} - -ui_menu_analog::~ui_menu_analog() -{ -} /*------------------------------------------------- menu_bookkeeping - handle the bookkeeping diff --git a/src/emu/ui/miscmenu.h b/src/emu/ui/miscmenu.h index a0dfbb003d1..dc4898bb920 100644 --- a/src/emu/ui/miscmenu.h +++ b/src/emu/ui/miscmenu.h @@ -25,23 +25,6 @@ public: virtual void handle(); }; -class ui_menu_slot_devices : public ui_menu { -public: - ui_menu_slot_devices(running_machine &machine, render_container *container); - virtual ~ui_menu_slot_devices(); - virtual void populate(); - virtual void handle(); - -private: - device_slot_option *slot_get_current_option(device_slot_interface *slot); - int slot_get_current_index(device_slot_interface *slot); - int slot_get_length(device_slot_interface *slot); - const char *slot_get_next(device_slot_interface *slot); - const char *slot_get_prev(device_slot_interface *slot); - const char *slot_get_option(device_slot_interface *slot, int index); - void set_slot_device(device_slot_interface *slot, const char *val); -}; - class ui_menu_network_devices : public ui_menu { public: ui_menu_network_devices(running_machine &machine, render_container *container); @@ -50,143 +33,6 @@ public: virtual void handle(); }; -class ui_menu_input_groups : public ui_menu { -public: - ui_menu_input_groups(running_machine &machine, render_container *container); - virtual ~ui_menu_input_groups(); - virtual void populate(); - virtual void handle(); -}; - -class ui_menu_input : public ui_menu { -public: - ui_menu_input(running_machine &machine, render_container *container); - virtual ~ui_menu_input(); - virtual void handle(); - -protected: - enum { - INPUT_TYPE_DIGITAL = 0, - INPUT_TYPE_ANALOG = 1, - INPUT_TYPE_ANALOG_DEC = INPUT_TYPE_ANALOG + SEQ_TYPE_DECREMENT, - INPUT_TYPE_ANALOG_INC = INPUT_TYPE_ANALOG + SEQ_TYPE_INCREMENT, - INPUT_TYPE_TOTAL = INPUT_TYPE_ANALOG + SEQ_TYPE_TOTAL - }; - - /* internal input menu item data */ - struct input_item_data { - input_item_data * next; /* pointer to next item in the list */ - const void * ref; /* reference to type description for global inputs or field for game inputs */ - input_seq_type seqtype; /* sequence type */ - input_seq seq; /* copy of the live sequence */ - const input_seq * defseq; /* pointer to the default sequence */ - const char * name; /* pointer to the base name of the item */ - const char * owner_name; /* pointer to the name of the owner of the item */ - UINT32 sortorder; /* sorting information */ - UINT8 type; /* type of port */ - }; - - void populate_and_sort(struct input_item_data *itemlist); - virtual void update_input(struct input_item_data *seqchangeditem) = 0; - void toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq); - -protected: - const void * pollingref; - input_seq_type pollingseq; - input_item_data * pollingitem; - -private: - UINT16 last_sortorder; - bool record_next; - input_seq starting_seq; - - static int compare_items(const void *i1, const void *i2); -}; - -class ui_menu_input_general : public ui_menu_input { -public: - ui_menu_input_general(running_machine &machine, render_container *container, int group); - virtual ~ui_menu_input_general(); - virtual void populate(); - -protected: - int group; - virtual void update_input(struct input_item_data *seqchangeditem); -}; - -class ui_menu_input_specific : public ui_menu_input { -public: - ui_menu_input_specific(running_machine &machine, render_container *container); - virtual ~ui_menu_input_specific(); - virtual void populate(); - -protected: - virtual void update_input(struct input_item_data *seqchangeditem); -}; - -class ui_menu_settings : public ui_menu { -public: - ui_menu_settings(running_machine &machine, render_container *container, UINT32 type); - virtual ~ui_menu_settings(); - virtual void populate(); - virtual void handle(); - -protected: - /* DIP switch descriptor */ - struct dip_descriptor { - dip_descriptor * next; - const char * name; - UINT32 mask; - UINT32 state; - }; - - dip_descriptor * diplist; - int dipcount; - int type; -}; - -class ui_menu_settings_dip_switches : public ui_menu_settings { -public: - ui_menu_settings_dip_switches(running_machine &machine, render_container *container); - virtual ~ui_menu_settings_dip_switches(); - - virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); -private: - void custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask); -}; - -class ui_menu_settings_driver_config : public ui_menu_settings { -public: - ui_menu_settings_driver_config(running_machine &machine, render_container *container); - virtual ~ui_menu_settings_driver_config(); -}; - -class ui_menu_analog : public ui_menu { -public: - ui_menu_analog(running_machine &machine, render_container *container); - virtual ~ui_menu_analog(); - virtual void populate(); - virtual void handle(); - -private: - enum { - ANALOG_ITEM_KEYSPEED = 0, - ANALOG_ITEM_CENTERSPEED, - ANALOG_ITEM_REVERSE, - ANALOG_ITEM_SENSITIVITY, - ANALOG_ITEM_COUNT - }; - - /* internal analog menu item data */ - struct analog_item_data { - ioport_field *field; - int type; - int min, max; - int cur; - int defvalue; - }; -}; - class ui_menu_bookkeeping : public ui_menu { public: ui_menu_bookkeeping(running_machine &machine, render_container *container); diff --git a/src/emu/ui/selgame.c b/src/emu/ui/selgame.c index 0d2b76c7d27..ac35d0b0dae 100644 --- a/src/emu/ui/selgame.c +++ b/src/emu/ui/selgame.c @@ -17,6 +17,7 @@ #include "cheat.h" #include "uiinput.h" #include "ui/selgame.h" +#include "ui/inputmap.h" #include "ui/miscmenu.h" #include "audit.h" #include "crsshair.h" diff --git a/src/emu/ui/slotopt.c b/src/emu/ui/slotopt.c new file mode 100644 index 00000000000..e7258897130 --- /dev/null +++ b/src/emu/ui/slotopt.c @@ -0,0 +1,199 @@ +/********************************************************************* + + ui/slotopt.c + + Internal menu for the slot options. + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +*********************************************************************/ + +#include "emu.h" + +#include "ui/ui.h" +#include "ui/slotopt.h" + + +/*------------------------------------------------- + ui_slot_get_current_option - returns +-------------------------------------------------*/ +device_slot_option *ui_menu_slot_devices::slot_get_current_option(device_slot_interface *slot) +{ + const char *current; + if (slot->fixed()) + { + current = slot->default_option(); + } + else + { + astring temp; + current = machine().options().main_value(temp, slot->device().tag() + 1); + } + + return slot->option(current); +} + +/*------------------------------------------------- + ui_slot_get_current_index - returns +-------------------------------------------------*/ +int ui_menu_slot_devices::slot_get_current_index(device_slot_interface *slot) +{ + const device_slot_option *current = slot_get_current_option(slot); + + if (current != NULL) + { + int val = 0; + for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + { + if (option == current) + return val; + + if (option->selectable()) + val++; + } + } + + return -1; +} + +/*------------------------------------------------- + ui_slot_get_length - returns +-------------------------------------------------*/ +int ui_menu_slot_devices::slot_get_length(device_slot_interface *slot) +{ + int val = 0; + for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + if (option->selectable()) + val++; + + return val; +} + +/*------------------------------------------------- + ui_slot_get_next - returns +-------------------------------------------------*/ +const char *ui_menu_slot_devices::slot_get_next(device_slot_interface *slot) +{ + int idx = slot_get_current_index(slot); + if (idx < 0) + idx = 0; + else + idx++; + + if (idx >= slot_get_length(slot)) + return ""; + + return slot_get_option(slot, idx); +} + +/*------------------------------------------------- + ui_slot_get_prev - returns +-------------------------------------------------*/ +const char *ui_menu_slot_devices::slot_get_prev(device_slot_interface *slot) +{ + int idx = slot_get_current_index(slot); + if (idx < 0) + idx = slot_get_length(slot) - 1; + else + idx--; + + if (idx < 0) + return ""; + + return slot_get_option(slot, idx); +} + +/*------------------------------------------------- + ui_slot_get_option - returns +-------------------------------------------------*/ +const char *ui_menu_slot_devices::slot_get_option(device_slot_interface *slot, int index) +{ + if (index >= 0) + { + int val = 0; + for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next()) + { + if (val == index) + return option->name(); + + if (option->selectable()) + val++; + } + } + + return ""; +} + + +/*------------------------------------------------- + ui_set_use_natural_keyboard - specifies + whether the natural keyboard is active +-------------------------------------------------*/ + +void ui_menu_slot_devices::set_slot_device(device_slot_interface *slot, const char *val) +{ + astring error; + machine().options().set_value(slot->device().tag()+1, val, OPTION_PRIORITY_CMDLINE, error); + assert(!error); +} + +/*------------------------------------------------- + menu_slot_devices_populate - populates the main + slot device menu +-------------------------------------------------*/ + +ui_menu_slot_devices::ui_menu_slot_devices(running_machine &machine, render_container *container) : ui_menu(machine, container) +{ +} + +void ui_menu_slot_devices::populate() +{ + /* cycle through all devices for this system */ + slot_interface_iterator iter(machine().root_device()); + for (device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next()) + { + /* record the menu item */ + const device_slot_option *option = slot_get_current_option(slot); + astring opt_name; + if (option == NULL) + opt_name.cpy("------"); + else + { + opt_name.cpy(option->name()); + if (slot->fixed() || slot_get_length(slot) == 0) + opt_name.cat(" [internal]"); + } + + item_append(slot->device().tag() + 1, opt_name, (slot->fixed() || slot_get_length(slot) == 0) ? 0 : (MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), (void *)slot); + } + item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + item_append("Reset", NULL, 0, (void *)1); +} + +ui_menu_slot_devices::~ui_menu_slot_devices() +{ +} + +/*------------------------------------------------- + ui_menu_slot_devices - menu that +-------------------------------------------------*/ + +void ui_menu_slot_devices::handle() +{ + /* process the menu */ + const ui_menu_event *menu_event = process(0); + + if (menu_event != NULL && menu_event->itemref != NULL) + { + if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT) + machine().schedule_hard_reset(); + else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) + { + device_slot_interface *slot = (device_slot_interface *)menu_event->itemref; + const char *val = (menu_event->iptkey == IPT_UI_LEFT) ? slot_get_prev(slot) : slot_get_next(slot); + set_slot_device(slot, val); + reset(UI_MENU_RESET_REMEMBER_REF); + } + } +} diff --git a/src/emu/ui/slotopt.h b/src/emu/ui/slotopt.h new file mode 100644 index 00000000000..9f73e608fdd --- /dev/null +++ b/src/emu/ui/slotopt.h @@ -0,0 +1,36 @@ +/*************************************************************************** + + ui/slotopt.h + + Internal menu for the slot options. + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +***************************************************************************/ + +#pragma once + +#ifndef __UI_SLOTOPT_H__ +#define __UI_SLOTOPT_H__ + +//#include "drivenum.h" + +class ui_menu_slot_devices : public ui_menu { +public: + ui_menu_slot_devices(running_machine &machine, render_container *container); + virtual ~ui_menu_slot_devices(); + virtual void populate(); + virtual void handle(); + +private: + device_slot_option *slot_get_current_option(device_slot_interface *slot); + int slot_get_current_index(device_slot_interface *slot); + int slot_get_length(device_slot_interface *slot); + const char *slot_get_next(device_slot_interface *slot); + const char *slot_get_prev(device_slot_interface *slot); + const char *slot_get_option(device_slot_interface *slot, int index); + void set_slot_device(device_slot_interface *slot, const char *val); +}; + +#endif /* __UI_SLOTOPT_H__ */ From 9c2d0ed4a390193a80b500a8111e24efc1f18a68 Mon Sep 17 00:00:00 2001 From: etabeta78 Date: Wed, 14 Jan 2015 07:55:37 +0100 Subject: [PATCH 3/8] ui: slightly reworked the File Manager initial menu to show which device each media belongs to, so that if you change slot options (e.g. adding further floppy drives to the emulated machine) you can more easily spot which image is currently mounted in each drive. Next, I plan to group media switches by owner, so to avoid unnecessarily long menus. nw. --- src/emu/ui/filemngr.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/emu/ui/filemngr.c b/src/emu/ui/filemngr.c index 2b635d89b97..b641f40eb81 100644 --- a/src/emu/ui/filemngr.c +++ b/src/emu/ui/filemngr.c @@ -66,21 +66,26 @@ void ui_menu_file_manager::custom_render(void *selectedref, float top, float bot void ui_menu_file_manager::populate() { astring buffer; - astring tmp_name; + bool first = true; // cycle through all devices for this system image_interface_iterator iter(machine().root_device()); for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) { + if (first) + first = false; + else + item_append("", NULL, MENU_FLAG_DISABLE, NULL); + // get the image type/id - buffer.printf( - "%s (%s)", - image->device().name(), image->brief_instance_name()); + buffer.printf("%s (%s)", image->instance_name(), image->brief_instance_name()); + item_append(buffer, "", MENU_FLAG_DISABLE, NULL); + item_append("Device", image->device().tag(), MENU_FLAG_DISABLE, NULL); // get the base name if (image->basename() != NULL) { - tmp_name.cpy(image->basename()); + buffer.cpy(image->basename()); // if the image has been loaded through softlist, also show the loaded part if (image->part_entry() != NULL) @@ -88,23 +93,23 @@ void ui_menu_file_manager::populate() const software_part *tmp = image->part_entry(); if (tmp->name() != NULL) { - tmp_name.cat(" ("); - tmp_name.cat(tmp->name()); + buffer.cat(" ("); + buffer.cat(tmp->name()); // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it if (image->get_feature("part_id") != NULL) { - tmp_name.cat(": "); - tmp_name.cat(image->get_feature("part_id")); + buffer.cat(": "); + buffer.cat(image->get_feature("part_id")); } - tmp_name.cat(")"); + buffer.cat(")"); } } } else - tmp_name.cpy("---"); + buffer.cpy("---"); // record the menu item - item_append(buffer, tmp_name.cstr(), 0, (void *) image); + item_append("Mounted File", buffer, 0, (void *) image); } item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); item_append("Reset", NULL, 0, (void *)1); From 65721319dc13035256604bf315e8356a13c2a80c Mon Sep 17 00:00:00 2001 From: etabeta78 Date: Wed, 14 Jan 2015 07:58:42 +0100 Subject: [PATCH 4/8] nes: fixed game genie passthrough. nw. --- src/emu/bus/nes/ggenie.c | 10 +++++++--- src/emu/bus/nes/ggenie.h | 1 + src/emu/bus/nes/nes_slot.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/emu/bus/nes/ggenie.c b/src/emu/bus/nes/ggenie.c index 00b2b843ae6..6bcc253cf21 100644 --- a/src/emu/bus/nes/ggenie.c +++ b/src/emu/bus/nes/ggenie.c @@ -48,6 +48,13 @@ void nes_ggenie_device::device_start() save_item(NAME(m_gg_bypass)); } +void nes_ggenie_device::pcb_start(running_machine &machine, UINT8 *ciram_ptr, bool cart_mounted) +{ + device_nes_cart_interface::pcb_start(machine, ciram_ptr, cart_mounted); + if (m_ggslot->m_cart) + m_ggslot->pcb_start(m_ciram); +} + void nes_ggenie_device::pcb_reset() { m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; @@ -58,10 +65,7 @@ void nes_ggenie_device::pcb_reset() m_gg_bypass = 0; if (m_ggslot->m_cart) - { - m_ggslot->pcb_start(m_ciram); m_ggslot->m_cart->pcb_reset(); - } } diff --git a/src/emu/bus/nes/ggenie.h b/src/emu/bus/nes/ggenie.h index 1b14c9cd416..8f208f5b54d 100644 --- a/src/emu/bus/nes/ggenie.h +++ b/src/emu/bus/nes/ggenie.h @@ -33,6 +33,7 @@ public: virtual machine_config_constructor device_mconfig_additions() const; virtual void pcb_reset(); + virtual void pcb_start(running_machine &machine, UINT8 *ciram_ptr, bool cart_mounted); private: // emulate the Game Genie! diff --git a/src/emu/bus/nes/nes_slot.h b/src/emu/bus/nes/nes_slot.h index 9c73d95d17d..de504c15eea 100644 --- a/src/emu/bus/nes/nes_slot.h +++ b/src/emu/bus/nes/nes_slot.h @@ -216,7 +216,7 @@ public: virtual void scanline_irq(int scanline, int vblank, int blanked) {} virtual void pcb_reset() {} // many pcb expect specific PRG/CHR banking at start - void pcb_start(running_machine &machine, UINT8 *ciram_ptr, bool cart_mounted); + virtual void pcb_start(running_machine &machine, UINT8 *ciram_ptr, bool cart_mounted); void pcb_reg_postload(running_machine &machine); void nes_banks_restore(); From 8011d411fd9b91c5aa09d025f664f3308bcbbda0 Mon Sep 17 00:00:00 2001 From: Osso13 Date: Wed, 14 Jan 2015 18:32:38 +0100 Subject: [PATCH 5/8] eolith.c, eolith16.c, vegaseo.c: added save state support (nw) delete depend_mame.mak if you have it or it won't compile --- src/mame/drivers/eolith.c | 50 +++++++++++++++++------------------- src/mame/drivers/eolith16.c | 14 ++++++---- src/mame/drivers/eolithsp.c | 50 ++++++++++++++++++------------------ src/mame/drivers/vegaeo.c | 22 ++++++++-------- src/mame/includes/eolith.h | 45 ++++++++++++++++++++------------ src/mame/includes/eolithsp.h | 4 --- src/mame/video/eolith.c | 9 +++---- 7 files changed, 101 insertions(+), 93 deletions(-) delete mode 100644 src/mame/includes/eolithsp.h diff --git a/src/mame/drivers/eolith.c b/src/mame/drivers/eolith.c index dc8cfb7eb40..478a4a9e9b2 100644 --- a/src/mame/drivers/eolith.c +++ b/src/mame/drivers/eolith.c @@ -103,10 +103,6 @@ #include "machine/eepromser.h" #include "includes/eolith.h" -#include "includes/eolithsp.h" - - - /************************************* @@ -125,7 +121,7 @@ READ32_MEMBER(eolith_state::eolith_custom_r) bit 8 = ??? bit 9 = ??? */ - eolith_speedup_read(space); + speedup_read(); return (m_in0->read() & ~0x300) | (machine().rand() & 0x300); } @@ -165,7 +161,7 @@ WRITE32_MEMBER( eolith_state::sound_w ) m_sound_data = data; m_soundcpu->set_input_line(MCS51_INT0_LINE, ASSERT_LINE); - space.machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(250)); + machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(250)); } @@ -1491,13 +1487,15 @@ MACHINE_RESET_MEMBER(eolith_state,eolith) DRIVER_INIT_MEMBER(eolith_state,eolith) { - init_eolith_speedup(machine()); + init_speedup(); // Sound CPU -> QS1000 CPU serial link m_soundcpu->i8051_set_serial_tx_callback(write8_delegate(FUNC(eolith_state::soundcpu_to_qs1000),this)); // Configure the sound ROM banking membank("sound_bank")->configure_entries(0, 16, memregion("sounddata")->base(), 0x8000); + + save_item(NAME(m_sound_data)); } DRIVER_INIT_MEMBER(eolith_state,landbrk) @@ -1569,22 +1567,22 @@ DRIVER_INIT_MEMBER(eolith_state,hidctch3) * *************************************/ -GAME( 1998, linkypip, 0, eolith45, linkypip, eolith_state, eolith, ROT0, "Eolith", "Linky Pipe", GAME_IMPERFECT_SOUND ) -GAME( 1998, ironfort, 0, ironfort, ironfort, eolith_state, eolith, ROT0, "Eolith", "Iron Fortress", GAME_IMPERFECT_SOUND ) -GAME( 1998, ironfortj, ironfort, ironfort, ironfortj, eolith_state, eolith, ROT0, "Eolith", "Iron Fortress (Japan)", GAME_IMPERFECT_SOUND ) -GAME( 1998, hidnctch, 0, eolith45, hidnctch, eolith_state, eolith, ROT0, "Eolith", "Hidden Catch (World) / Tul Lin Gu Lim Chat Ki '98 (Korea) (pcb ver 3.03)", GAME_IMPERFECT_SOUND ) // or Teurrin Geurim Chajgi '98 -GAME( 1998, raccoon, 0, eolith45, raccoon, eolith_state, eolith, ROT0, "Eolith", "Raccoon World", GAME_IMPERFECT_SOUND ) -GAME( 1998, puzzlekg, 0, eolith45, puzzlekg, eolith_state, eolith, ROT0, "Eolith", "Puzzle King (Dance & Puzzle)", GAME_IMPERFECT_SOUND ) -GAME( 1999, candy, 0, eolith50, candy, eolith_state, eolith, ROT0, "Eolith", "Candy Candy", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) -GAME( 1999, hidctch2, 0, eolith50, hidctch2, eolith_state, hidctch2, ROT0, "Eolith", "Hidden Catch 2 (pcb ver 3.03) (Kor/Eng) (AT89c52 protected)", GAME_IMPERFECT_SOUND ) -GAME( 1999, hidctch2a, hidctch2, eolith50, hidctch2, eolith_state, eolith, ROT0, "Eolith", "Hidden Catch 2 (pcb ver 1.00) (Kor/Eng/Jpn/Chi)", GAME_IMPERFECT_SOUND ) -GAME( 1999, hidnc2k, 0, eolith50, hidctch2, eolith_state, hidnc2k, ROT0, "Eolith", "Hidden Catch 2000 (AT89c52 protected)", GAME_IMPERFECT_SOUND ) -GAME( 1999, landbrk, 0, eolith45, landbrk, eolith_state, landbrk, ROT0, "Eolith", "Land Breaker (World) / Miss Tang Ja Ru Gi (Korea) (pcb ver 3.02)", GAME_IMPERFECT_SOUND ) // or Miss Ttang Jjareugi -GAME( 1999, landbrka, landbrk, eolith45, landbrk, eolith_state, landbrka, ROT0, "Eolith", "Land Breaker (World) / Miss Tang Ja Ru Gi (Korea) (pcb ver 3.03) (AT89c52 protected)", GAME_IMPERFECT_SOUND ) // or Miss Ttang Jjareugi -GAME( 1999, nhidctch, 0, eolith45, hidctch2, eolith_state, eolith, ROT0, "Eolith", "New Hidden Catch (World) / New Tul Lin Gu Lim Chat Ki '98 (Korea) (pcb ver 3.02)", GAME_IMPERFECT_SOUND ) // or New Teurrin Geurim Chajgi '98 -GAME( 1999, penfan, 0, eolith45, penfan, eolith_state, eolith, ROT0, "Eolith", "Penfan Girls - Step1. Mild Mind (set 1)", GAME_IMPERFECT_SOUND ) // alt title of Ribbon -GAME( 1999, penfana, penfan, eolith45, penfan, eolith_state, eolith, ROT0, "Eolith", "Penfan Girls - Step1. Mild Mind (set 2)", GAME_IMPERFECT_SOUND ) -GAME( 2000, stealsee, 0, eolith45, stealsee, eolith_state, eolith, ROT0, "Moov Generation / Eolith", "Steal See", GAME_IMPERFECT_SOUND ) -GAME( 2000, hidctch3, 0, eolith50, hidctch3, eolith_state, hidctch3, ROT0, "Eolith", "Hidden Catch 3 (ver 1.00 / pcb ver 3.05)", GAME_IMPERFECT_SOUND ) -GAME( 2001, fort2b, 0, eolith50, common, eolith_state, eolith, ROT0, "Eolith", "Fortress 2 Blue Arcade (ver 1.01 / pcb ver 3.05)", GAME_IMPERFECT_SOUND ) -GAME( 2001, fort2ba, fort2b, eolith50, common, eolith_state, eolith, ROT0, "Eolith", "Fortress 2 Blue Arcade (ver 1.00 / pcb ver 3.05)", GAME_IMPERFECT_SOUND ) +GAME( 1998, linkypip, 0, eolith45, linkypip, eolith_state, eolith, ROT0, "Eolith", "Linky Pipe", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1998, ironfort, 0, ironfort, ironfort, eolith_state, eolith, ROT0, "Eolith", "Iron Fortress", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1998, ironfortj, ironfort, ironfort, ironfortj, eolith_state, eolith, ROT0, "Eolith", "Iron Fortress (Japan)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1998, hidnctch, 0, eolith45, hidnctch, eolith_state, eolith, ROT0, "Eolith", "Hidden Catch (World) / Tul Lin Gu Lim Chat Ki '98 (Korea) (pcb ver 3.03)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) // or Teurrin Geurim Chajgi '98 +GAME( 1998, raccoon, 0, eolith45, raccoon, eolith_state, eolith, ROT0, "Eolith", "Raccoon World", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1998, puzzlekg, 0, eolith45, puzzlekg, eolith_state, eolith, ROT0, "Eolith", "Puzzle King (Dance & Puzzle)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1999, candy, 0, eolith50, candy, eolith_state, eolith, ROT0, "Eolith", "Candy Candy", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1999, hidctch2, 0, eolith50, hidctch2, eolith_state, hidctch2, ROT0, "Eolith", "Hidden Catch 2 (pcb ver 3.03) (Kor/Eng) (AT89c52 protected)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1999, hidctch2a, hidctch2, eolith50, hidctch2, eolith_state, eolith, ROT0, "Eolith", "Hidden Catch 2 (pcb ver 1.00) (Kor/Eng/Jpn/Chi)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1999, hidnc2k, 0, eolith50, hidctch2, eolith_state, hidnc2k, ROT0, "Eolith", "Hidden Catch 2000 (AT89c52 protected)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1999, landbrk, 0, eolith45, landbrk, eolith_state, landbrk, ROT0, "Eolith", "Land Breaker (World) / Miss Tang Ja Ru Gi (Korea) (pcb ver 3.02)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) // or Miss Ttang Jjareugi +GAME( 1999, landbrka, landbrk, eolith45, landbrk, eolith_state, landbrka, ROT0, "Eolith", "Land Breaker (World) / Miss Tang Ja Ru Gi (Korea) (pcb ver 3.03) (AT89c52 protected)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) // or Miss Ttang Jjareugi +GAME( 1999, nhidctch, 0, eolith45, hidctch2, eolith_state, eolith, ROT0, "Eolith", "New Hidden Catch (World) / New Tul Lin Gu Lim Chat Ki '98 (Korea) (pcb ver 3.02)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) // or New Teurrin Geurim Chajgi '98 +GAME( 1999, penfan, 0, eolith45, penfan, eolith_state, eolith, ROT0, "Eolith", "Penfan Girls - Step1. Mild Mind (set 1)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) // alt title of Ribbon +GAME( 1999, penfana, penfan, eolith45, penfan, eolith_state, eolith, ROT0, "Eolith", "Penfan Girls - Step1. Mild Mind (set 2)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 2000, stealsee, 0, eolith45, stealsee, eolith_state, eolith, ROT0, "Moov Generation / Eolith", "Steal See", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 2000, hidctch3, 0, eolith50, hidctch3, eolith_state, hidctch3, ROT0, "Eolith", "Hidden Catch 3 (ver 1.00 / pcb ver 3.05)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 2001, fort2b, 0, eolith50, common, eolith_state, eolith, ROT0, "Eolith", "Fortress 2 Blue Arcade (ver 1.01 / pcb ver 3.05)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 2001, fort2ba, fort2b, eolith50, common, eolith_state, eolith, ROT0, "Eolith", "Fortress 2 Blue Arcade (ver 1.00 / pcb ver 3.05)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/eolith16.c b/src/mame/drivers/eolith16.c index cdf4e2069e2..cd152010b8f 100644 --- a/src/mame/drivers/eolith16.c +++ b/src/mame/drivers/eolith16.c @@ -15,7 +15,6 @@ #include "sound/okim6295.h" #include "includes/eolith.h" -#include "includes/eolithsp.h" class eolith16_state : public eolith_state @@ -26,13 +25,16 @@ public: UINT16 *m_vram; int m_vbuffer; + DECLARE_WRITE16_MEMBER(eeprom_w); DECLARE_READ16_MEMBER(eolith16_custom_r); DECLARE_WRITE16_MEMBER(vram_w); DECLARE_READ16_MEMBER(vram_r); + DECLARE_DRIVER_INIT(eolith16); DECLARE_VIDEO_START(eolith16); DECLARE_PALETTE_INIT(eolith16); + UINT32 screen_update_eolith16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); }; @@ -43,14 +45,14 @@ WRITE16_MEMBER(eolith16_state::eeprom_w) m_vbuffer = (data & 0x80) >> 7; coin_counter_w(machine(), 0, data & 1); - ioport("EEPROMOUT")->write(data, 0xff); + m_eepromoutport->write(data, 0xff); //data & 0x100 and data & 0x004 always set } READ16_MEMBER(eolith16_state::eolith16_custom_r) { - eolith_speedup_read(space); + speedup_read(); return ioport("SPECIAL")->read(); } @@ -113,6 +115,8 @@ INPUT_PORTS_END VIDEO_START_MEMBER(eolith16_state,eolith16) { m_vram = auto_alloc_array(machine(), UINT16, 0x10000); + save_pointer(NAME(m_vram), 0x10000); + save_item(NAME(m_vbuffer)); } UINT32 eolith16_state::screen_update_eolith16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) @@ -253,7 +257,7 @@ ROM_END DRIVER_INIT_MEMBER(eolith16_state,eolith16) { - init_eolith_speedup(machine()); + init_speedup(); } -GAME( 1999, klondkp, 0, eolith16, eolith16, eolith16_state, eolith16, ROT0, "Eolith", "KlonDike+", 0 ) +GAME( 1999, klondkp, 0, eolith16, eolith16, eolith16_state, eolith16, ROT0, "Eolith", "KlonDike+", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/eolithsp.c b/src/mame/drivers/eolithsp.c index 6a2be221534..f570d36395b 100644 --- a/src/mame/drivers/eolithsp.c +++ b/src/mame/drivers/eolithsp.c @@ -9,28 +9,22 @@ */ #include "emu.h" -#include "includes/eolithsp.h" #include "includes/eolith.h" -static int eolith_speedup_address; -static int eolith_speedup_address2; -static int eolith_speedup_resume_scanline; -static int eolith_vblank = 0; -static int eolith_scanline = 0; -void eolith_speedup_read(address_space &space) +void eolith_state::speedup_read() { /* for debug */ - //if ((space.device().safe_pc()!=eolith_speedup_address) && (eolith_vblank!=1) ) - // printf("%s:eolith speedup_read data %02x\n",space.machine().describe_context(), eolith_vblank); + //if ((space.device().safe_pc()!=m_speedup_address) && (m_speedup_vblank!=1) ) + // printf("%s:eolith speedup_read data %02x\n",space.machine().describe_context(), m_speedup_vblank); - if (eolith_vblank==0 && eolith_scanline < eolith_speedup_resume_scanline) + if (m_speedup_vblank==0 && m_speedup_scanline < m_speedup_resume_scanline) { - int pc = space.device().safe_pc(); + int pc = m_maincpu->pc(); - if ((pc==eolith_speedup_address) || (pc==eolith_speedup_address2)) + if ((pc==m_speedup_address) || (pc==m_speedup_address2)) { - space.device().execute().spin_until_trigger(1000); + m_maincpu->spin_until_trigger(1000); } } } @@ -71,22 +65,28 @@ static const struct }; -void init_eolith_speedup(running_machine &machine) +void eolith_state::init_speedup() { int n_game = 0; - eolith_speedup_address = 0; - eolith_speedup_resume_scanline = 0; + m_speedup_address = 0; + m_speedup_address2 = 0; + m_speedup_resume_scanline = 0; + m_speedup_vblank = 0; + m_speedup_scanline = 0; while( eolith_speedup_table[ n_game ].s_name != NULL ) { - if( strcmp( machine.system().name, eolith_speedup_table[ n_game ].s_name ) == 0 ) + if( strcmp( machine().system().name, eolith_speedup_table[ n_game ].s_name ) == 0 ) { - eolith_speedup_address = eolith_speedup_table[ n_game ].speedup_address; - eolith_speedup_address2 = eolith_speedup_table[ n_game ].speedup_address2; - eolith_speedup_resume_scanline = eolith_speedup_table[ n_game ].speedup_resume_scanline; + m_speedup_address = eolith_speedup_table[ n_game ].speedup_address; + m_speedup_address2 = eolith_speedup_table[ n_game ].speedup_address2; + m_speedup_resume_scanline = eolith_speedup_table[ n_game ].speedup_resume_scanline; } n_game++; } + + save_item(NAME(m_speedup_vblank)); + save_item(NAME(m_speedup_scanline)); } /* todo, use timers instead! */ @@ -94,23 +94,23 @@ TIMER_DEVICE_CALLBACK_MEMBER(eolith_state::eolith_speedup) { if (param==0) { - eolith_vblank = 0; + m_speedup_vblank = 0; } - if (param==eolith_speedup_resume_scanline) + if (param==m_speedup_resume_scanline) { machine().scheduler().trigger(1000); } if (param==240) { - eolith_vblank = 1; + m_speedup_vblank = 1; } } CUSTOM_INPUT_MEMBER(eolith_state::eolith_speedup_getvblank) { -// printf("%s:eolith speedup_read data %02x\n",machine().describe_context(), eolith_vblank); +// printf("%s:eolith speedup_read data %02x\n",machine().describe_context(), m_speedup_vblank); return (m_screen->vpos() >= 240); @@ -122,7 +122,7 @@ CUSTOM_INPUT_MEMBER(eolith_state::stealsee_speedup_getvblank) int pc = m_maincpu->pc(); if (pc==0x400081ec) - if(!eolith_vblank) + if(!m_speedup_vblank) m_maincpu->eat_cycles(500); return (m_screen->vpos() >= 240); diff --git a/src/mame/drivers/vegaeo.c b/src/mame/drivers/vegaeo.c index e91250ff0cf..2eb2f4edf36 100644 --- a/src/mame/drivers/vegaeo.c +++ b/src/mame/drivers/vegaeo.c @@ -16,7 +16,6 @@ #include "machine/at28c16.h" #include "sound/qs1000.h" #include "includes/eolith.h" -#include "includes/eolithsp.h" class vegaeo_state : public eolith_state @@ -27,19 +26,20 @@ public: UINT32 *m_vega_vram; UINT8 m_vega_vbuffer; + DECLARE_WRITE32_MEMBER(vega_vram_w); DECLARE_READ32_MEMBER(vega_vram_r); DECLARE_WRITE32_MEMBER(vega_misc_w); DECLARE_READ32_MEMBER(vegaeo_custom_read); DECLARE_WRITE32_MEMBER(soundlatch_w); - DECLARE_READ8_MEMBER(qs1000_p1_r); - DECLARE_WRITE8_MEMBER(qs1000_p1_w); DECLARE_WRITE8_MEMBER(qs1000_p2_w); DECLARE_WRITE8_MEMBER(qs1000_p3_w); + DECLARE_DRIVER_INIT(vegaeo); DECLARE_VIDEO_START(vega); + UINT32 screen_update_vega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); }; @@ -62,12 +62,10 @@ WRITE8_MEMBER( vegaeo_state::qs1000_p3_w ) // ...x .... - ? // ..x. .... - /IRQ clear - qs1000_device *qs1000 = machine().device("qs1000"); - membank("qs1000:bank")->set_entry(data & 0x07); if (!BIT(data, 5)) - qs1000->set_irq(CLEAR_LINE); + m_qs1000->set_irq(CLEAR_LINE); } WRITE32_MEMBER(vegaeo_state::vega_vram_w) @@ -115,16 +113,14 @@ WRITE32_MEMBER(vegaeo_state::vega_misc_w) READ32_MEMBER(vegaeo_state::vegaeo_custom_read) { - eolith_speedup_read(space); + speedup_read(); return ioport("SYSTEM")->read(); } WRITE32_MEMBER(vegaeo_state::soundlatch_w) { - qs1000_device *qs1000 = space.machine().device("qs1000"); - soundlatch_byte_w(space, 0, data); - qs1000->set_irq(ASSERT_LINE); + m_qs1000->set_irq(ASSERT_LINE); machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(100)); } @@ -180,6 +176,8 @@ INPUT_PORTS_END VIDEO_START_MEMBER(vegaeo_state,vega) { m_vega_vram = auto_alloc_array(machine(), UINT32, 0x14000*2/4); + save_pointer(NAME(m_vega_vram), 0x14000*2/4); + save_item(NAME(m_vega_vbuffer)); } UINT32 vegaeo_state::screen_update_vega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) @@ -328,7 +326,7 @@ DRIVER_INIT_MEMBER(vegaeo_state,vegaeo) machine().device("qs1000:cpu")->memory().space(AS_IO).install_read_bank(0x0100, 0xffff, "bank"); membank("qs1000:bank")->configure_entries(0, 8, memregion("qs1000:cpu")->base()+0x100, 0x10000); - init_eolith_speedup(machine()); + init_speedup(); } -GAME( 2002, crazywar, 0, vega, crazywar, vegaeo_state, vegaeo, ROT0, "Eolith", "Crazy War", GAME_IMPERFECT_SOUND ) +GAME( 2002, crazywar, 0, vega, crazywar, vegaeo_state, vegaeo, ROT0, "Eolith", "Crazy War", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/eolith.h b/src/mame/includes/eolith.h index e8fec69abb1..746a79a3bd6 100644 --- a/src/mame/includes/eolith.h +++ b/src/mame/includes/eolith.h @@ -10,36 +10,49 @@ public: m_maincpu(*this, "maincpu"), m_soundcpu(*this, "soundcpu"), m_qs1000(*this, "qs1000"), + m_screen(*this, "screen"), + m_palette(*this, "palette"), m_in0(*this, "IN0"), m_eepromoutport(*this, "EEPROMOUT"), m_penx1port(*this, "PEN_X_P1"), m_peny1port(*this, "PEN_Y_P1"), m_penx2port(*this, "PEN_X_P2"), m_peny2port(*this, "PEN_Y_P2"), - m_sndbank(*this, "sound_bank"), - m_screen(*this, "screen"), - m_palette(*this, "palette") + m_sndbank(*this, "sound_bank") { } - int m_coin_counter_bit; - int m_buffer; - UINT32 *m_vram; - - UINT8 m_sound_data; - UINT8 m_data_to_qs1000; required_device m_maincpu; optional_device m_soundcpu; optional_device m_qs1000; + required_device m_screen; + required_device m_palette; + optional_ioport m_in0; // klondkp doesn't have it optional_ioport m_eepromoutport; optional_ioport m_penx1port; optional_ioport m_peny1port; optional_ioport m_penx2port; optional_ioport m_peny2port; + optional_memory_bank m_sndbank; - required_device m_screen; - required_device m_palette; + + int m_coin_counter_bit; + int m_buffer; + UINT32 *m_vram; + + UINT8 m_sound_data; + + // speedups - see machine/eolithsp.c + int m_speedup_address; + int m_speedup_address2; + int m_speedup_resume_scanline; + int m_speedup_vblank; + int m_speedup_scanline; + void speedup_read(); + void init_speedup(); + DECLARE_CUSTOM_INPUT_MEMBER(eolith_speedup_getvblank); + DECLARE_CUSTOM_INPUT_MEMBER(stealsee_speedup_getvblank); DECLARE_READ32_MEMBER(eolith_custom_r); DECLARE_WRITE32_MEMBER(systemcontrol_w); @@ -48,23 +61,23 @@ public: DECLARE_READ32_MEMBER(hidctch3_pen2_r); DECLARE_WRITE32_MEMBER(eolith_vram_w); DECLARE_READ32_MEMBER(eolith_vram_r); - DECLARE_CUSTOM_INPUT_MEMBER(eolith_speedup_getvblank); - DECLARE_CUSTOM_INPUT_MEMBER(stealsee_speedup_getvblank); - DECLARE_READ8_MEMBER(sound_cmd_r); DECLARE_WRITE8_MEMBER(sound_p1_w); - DECLARE_READ8_MEMBER(qs1000_p1_r); DECLARE_WRITE8_MEMBER(qs1000_p1_w); + DECLARE_WRITE8_MEMBER(soundcpu_to_qs1000); + DECLARE_DRIVER_INIT(eolith); DECLARE_DRIVER_INIT(landbrk); DECLARE_DRIVER_INIT(hidctch3); DECLARE_DRIVER_INIT(hidctch2); DECLARE_DRIVER_INIT(hidnc2k); DECLARE_DRIVER_INIT(landbrka); + DECLARE_MACHINE_RESET(eolith); DECLARE_VIDEO_START(eolith); + UINT32 screen_update_eolith(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + TIMER_DEVICE_CALLBACK_MEMBER(eolith_speedup); - DECLARE_WRITE8_MEMBER(soundcpu_to_qs1000); }; diff --git a/src/mame/includes/eolithsp.h b/src/mame/includes/eolithsp.h deleted file mode 100644 index fb9dc0acf30..00000000000 --- a/src/mame/includes/eolithsp.h +++ /dev/null @@ -1,4 +0,0 @@ -/*----------- defined in drivers/eolithsp.c -----------*/ - -void eolith_speedup_read(address_space &space); -void init_eolith_speedup(running_machine &machine); diff --git a/src/mame/video/eolith.c b/src/mame/video/eolith.c index c504073a0b7..19f633f6006 100644 --- a/src/mame/video/eolith.c +++ b/src/mame/video/eolith.c @@ -33,19 +33,18 @@ READ32_MEMBER(eolith_state::eolith_vram_r) VIDEO_START_MEMBER(eolith_state,eolith) { m_vram = auto_alloc_array(machine(), UINT32, 0x40000*2/4); + save_pointer(NAME(m_vram), 0x40000*2/4); + save_item(NAME(m_buffer)); } UINT32 eolith_state::screen_update_eolith(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - int y; - - for (y = 0; y < 240; y++) + for (int y = 0; y < 240; y++) { - int x; UINT32 *src = &m_vram[(m_buffer ? 0 : 0x10000) | (y * (336 / 2))]; UINT16 *dest = &bitmap.pix16(y); - for (x = 0; x < 320; x += 2) + for (int x = 0; x < 320; x += 2) { dest[0] = (*src >> 16) & 0x7fff; dest[1] = (*src >> 0) & 0x7fff; From a9d9501411582eb20f18244ce41cc4ecb272b34f Mon Sep 17 00:00:00 2001 From: Osso13 Date: Wed, 14 Jan 2015 18:47:59 +0100 Subject: [PATCH 6/8] stadhero.c: enabled save state support, reduced tagmap lookups (nw) --- src/mame/drivers/stadhero.c | 8 ++++---- src/mame/includes/stadhero.h | 22 ++++++++++++++++------ src/mame/video/stadhero.c | 4 +--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/mame/drivers/stadhero.c b/src/mame/drivers/stadhero.c index f8a62c84e8c..be918e4b131 100644 --- a/src/mame/drivers/stadhero.c +++ b/src/mame/drivers/stadhero.c @@ -35,13 +35,13 @@ READ16_MEMBER(stadhero_state::stadhero_control_r) switch (offset<<1) { case 0: - return ioport("INPUTS")->read(); + return m_inputs->read(); case 2: - return ioport("COIN")->read(); + return m_coin->read(); case 4: - return ioport("DSW")->read(); + return m_dsw->read(); } logerror("CPU #0 PC %06x: warning - read unmapped memory address %06x\n",space.device().safe_pc(),0x30c000+offset); @@ -305,4 +305,4 @@ ROM_END /******************************************************************************/ -GAME( 1988, stadhero, 0, stadhero, stadhero, driver_device, 0, ROT0, "Data East Corporation", "Stadium Hero (Japan)", 0 ) +GAME( 1988, stadhero, 0, stadhero, stadhero, driver_device, 0, ROT0, "Data East Corporation", "Stadium Hero (Japan)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/stadhero.h b/src/mame/includes/stadhero.h index 15e212a5596..17bf2f36152 100644 --- a/src/mame/includes/stadhero.h +++ b/src/mame/includes/stadhero.h @@ -10,25 +10,35 @@ public: m_audiocpu(*this, "audiocpu"), m_tilegen1(*this, "tilegen1"), m_spritegen(*this, "spritegen"), + m_gfxdecode(*this, "gfxdecode"), m_spriteram(*this, "spriteram"), m_pf1_data(*this, "pf1_data"), - m_gfxdecode(*this, "gfxdecode") { } + m_inputs(*this, "INPUTS"), + m_coin(*this, "COIN"), + m_dsw(*this, "DSW") { } required_device m_maincpu; required_device m_audiocpu; required_device m_tilegen1; required_device m_spritegen; + required_device m_gfxdecode; + required_shared_ptr m_spriteram; required_shared_ptr m_pf1_data; - required_device m_gfxdecode; + + required_ioport m_inputs; + required_ioport m_coin; + required_ioport m_dsw; tilemap_t *m_pf1_tilemap; - int m_flipscreen; + DECLARE_READ16_MEMBER(stadhero_control_r); DECLARE_WRITE16_MEMBER(stadhero_control_w); DECLARE_WRITE16_MEMBER(stadhero_pf1_data_w); - TILE_GET_INFO_MEMBER(get_pf1_tile_info); - virtual void video_start(); - UINT32 screen_update_stadhero(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); DECLARE_WRITE_LINE_MEMBER(irqhandler); + + virtual void video_start(); + + TILE_GET_INFO_MEMBER(get_pf1_tile_info); + UINT32 screen_update_stadhero(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); }; diff --git a/src/mame/video/stadhero.c b/src/mame/video/stadhero.c index 29b1ab68d69..c9a23775d9f 100644 --- a/src/mame/video/stadhero.c +++ b/src/mame/video/stadhero.c @@ -20,8 +20,6 @@ UINT32 stadhero_state::screen_update_stadhero(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { -// machine().tilemap().set_flip_all(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - flip_screen_set(m_tilegen1->get_flip_state()); m_tilegen1->set_bppmultmask(0x8, 0x7); @@ -56,7 +54,7 @@ TILE_GET_INFO_MEMBER(stadhero_state::get_pf1_tile_info) void stadhero_state::video_start() { - m_pf1_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(stadhero_state::get_pf1_tile_info),this),TILEMAP_SCAN_ROWS, 8, 8,32,32); + m_pf1_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(stadhero_state::get_pf1_tile_info),this),TILEMAP_SCAN_ROWS, 8, 8,32,32); m_pf1_tilemap->set_transparent_pen(0); } From 67d993bf43c63ba468372e008689063f1d323fbe Mon Sep 17 00:00:00 2001 From: Osso13 Date: Wed, 14 Jan 2015 18:55:48 +0100 Subject: [PATCH 7/8] vaportra.h: removed unused memory pointers (nw) --- src/mame/includes/vaportra.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mame/includes/vaportra.h b/src/mame/includes/vaportra.h index 90befb577a1..35c408b0846 100644 --- a/src/mame/includes/vaportra.h +++ b/src/mame/includes/vaportra.h @@ -23,15 +23,6 @@ public: m_generic_paletteram_16(*this, "paletteram"), m_generic_paletteram2_16(*this, "paletteram2") { } - /* memory pointers */ - UINT16 * m_pf1_rowscroll; - UINT16 * m_pf2_rowscroll; - UINT16 * m_pf3_rowscroll; - UINT16 * m_pf4_rowscroll; - - /* misc */ - UINT16 m_priority[2]; - /* devices */ required_device m_maincpu; required_device m_audiocpu; @@ -40,19 +31,26 @@ public: required_device m_spritegen; required_device m_spriteram; required_device m_palette; + required_shared_ptr m_generic_paletteram_16; required_shared_ptr m_generic_paletteram2_16; + /* misc */ + UINT16 m_priority[2]; + DECLARE_WRITE16_MEMBER(vaportra_sound_w); DECLARE_READ16_MEMBER(vaportra_control_r); DECLARE_READ8_MEMBER(vaportra_soundlatch_r); DECLARE_WRITE16_MEMBER(vaportra_priority_w); DECLARE_WRITE16_MEMBER(vaportra_palette_24bit_rg_w); DECLARE_WRITE16_MEMBER(vaportra_palette_24bit_b_w); + DECLARE_DRIVER_INIT(vaportra); virtual void machine_start(); virtual void machine_reset(); + UINT32 screen_update_vaportra(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void update_24bitcol( int offset ); + DECO16IC_BANK_CB_MEMBER(bank_callback); }; From b0264399ef2773be8726d1a35264f1a233e108cb Mon Sep 17 00:00:00 2001 From: Osso13 Date: Wed, 14 Jan 2015 19:12:36 +0100 Subject: [PATCH 8/8] xyonix,c: added save state support (nw) --- src/mame/drivers/xyonix.c | 24 ++++++++++++++++-------- src/mame/includes/xyonix.h | 26 ++++++++++++++++---------- src/mame/video/xyonix.c | 8 ++++---- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/mame/drivers/xyonix.c b/src/mame/drivers/xyonix.c index e6ee7229bac..dce27573187 100644 --- a/src/mame/drivers/xyonix.c +++ b/src/mame/drivers/xyonix.c @@ -25,7 +25,15 @@ TODO: #include "includes/xyonix.h" -WRITE8_MEMBER(xyonix_state::xyonix_irqack_w) +void xyonix_state::machine_start() +{ + save_item(NAME(m_e0_data)); + save_item(NAME(m_credits)); + save_item(NAME(m_coins)); + save_item(NAME(m_prev_coin)); +} + +WRITE8_MEMBER(xyonix_state::irqack_w) { m_maincpu->set_input_line(0, CLEAR_LINE); } @@ -71,7 +79,7 @@ void xyonix_state::handle_coins(int coin) } -READ8_MEMBER(xyonix_state::xyonix_io_r) +READ8_MEMBER(xyonix_state::io_r) { int regPC = space.device().safe_pc(); @@ -122,7 +130,7 @@ READ8_MEMBER(xyonix_state::xyonix_io_r) return 0xff; } -WRITE8_MEMBER(xyonix_state::xyonix_io_w) +WRITE8_MEMBER(xyonix_state::io_w) { //logerror ("xyonix_port_e0_w %02x - PC = %04x\n", data, space.device().safe_pc()); m_e0_data = data; @@ -133,7 +141,7 @@ WRITE8_MEMBER(xyonix_state::xyonix_io_w) static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, xyonix_state ) AM_RANGE(0x0000, 0xbfff) AM_ROM AM_RANGE(0xc000, 0xdfff) AM_RAM - AM_RANGE(0xe000, 0xffff) AM_RAM_WRITE(xyonix_vidram_w) AM_SHARE("vidram") + AM_RANGE(0xe000, 0xffff) AM_RAM_WRITE(vidram_w) AM_SHARE("vidram") ADDRESS_MAP_END static ADDRESS_MAP_START( port_map, AS_IO, 8, xyonix_state ) @@ -141,9 +149,9 @@ static ADDRESS_MAP_START( port_map, AS_IO, 8, xyonix_state ) AM_RANGE(0x20, 0x20) AM_READNOP AM_DEVWRITE("sn1", sn76496_device, write) /* SN76496 ready signal */ AM_RANGE(0x21, 0x21) AM_READNOP AM_DEVWRITE("sn2", sn76496_device, write) AM_RANGE(0x40, 0x40) AM_WRITENOP /* NMI ack? */ - AM_RANGE(0x50, 0x50) AM_WRITE(xyonix_irqack_w) + AM_RANGE(0x50, 0x50) AM_WRITE(irqack_w) AM_RANGE(0x60, 0x61) AM_WRITENOP /* mc6845 */ - AM_RANGE(0xe0, 0xe0) AM_READWRITE(xyonix_io_r, xyonix_io_w) + AM_RANGE(0xe0, 0xe0) AM_READWRITE(io_r, io_w) ADDRESS_MAP_END /* Inputs Ports **************************************************************/ @@ -226,7 +234,7 @@ static MACHINE_CONFIG_START( xyonix, xyonix_state ) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) MCFG_SCREEN_SIZE(80*4, 32*8) MCFG_SCREEN_VISIBLE_AREA(0, 80*4-1, 0, 28*8-1) - MCFG_SCREEN_UPDATE_DRIVER(xyonix_state, screen_update_xyonix) + MCFG_SCREEN_UPDATE_DRIVER(xyonix_state, screen_update) MCFG_SCREEN_PALETTE("palette") MCFG_GFXDECODE_ADD("gfxdecode", "palette", xyonix) @@ -259,4 +267,4 @@ ROM_END /* GAME drivers **************************************************************/ -GAME( 1989, xyonix, 0, xyonix, xyonix, driver_device, 0, ROT0, "Philko", "Xyonix", 0 ) +GAME( 1989, xyonix, 0, xyonix, xyonix, driver_device, 0, ROT0, "Philko", "Xyonix", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/xyonix.h b/src/mame/includes/xyonix.h index fafd21ca4e1..56f2e162047 100644 --- a/src/mame/includes/xyonix.h +++ b/src/mame/includes/xyonix.h @@ -3,26 +3,32 @@ class xyonix_state : public driver_device public: xyonix_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_vidram(*this, "vidram"), m_maincpu(*this, "maincpu"), - m_gfxdecode(*this, "gfxdecode") { } + m_gfxdecode(*this, "gfxdecode"), + m_vidram(*this, "vidram") { } + required_device m_maincpu; + required_device m_gfxdecode; + required_shared_ptr m_vidram; + tilemap_t *m_tilemap; int m_e0_data; int m_credits; int m_coins; int m_prev_coin; - DECLARE_WRITE8_MEMBER(xyonix_irqack_w); - DECLARE_READ8_MEMBER(xyonix_io_r); - DECLARE_WRITE8_MEMBER(xyonix_io_w); - DECLARE_WRITE8_MEMBER(xyonix_vidram_w); - TILE_GET_INFO_MEMBER(get_xyonix_tile_info); + + DECLARE_WRITE8_MEMBER(irqack_w); + DECLARE_READ8_MEMBER(io_r); + DECLARE_WRITE8_MEMBER(io_w); + DECLARE_WRITE8_MEMBER(vidram_w); + + virtual void machine_start(); virtual void video_start(); + TILE_GET_INFO_MEMBER(get_tile_info); DECLARE_PALETTE_INIT(xyonix); - UINT32 screen_update_xyonix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void handle_coins(int coin); - required_device m_maincpu; - required_device m_gfxdecode; }; diff --git a/src/mame/video/xyonix.c b/src/mame/video/xyonix.c index 6a656f9eee6..b83abc325f0 100644 --- a/src/mame/video/xyonix.c +++ b/src/mame/video/xyonix.c @@ -31,7 +31,7 @@ PALETTE_INIT_MEMBER(xyonix_state, xyonix) } -TILE_GET_INFO_MEMBER(xyonix_state::get_xyonix_tile_info) +TILE_GET_INFO_MEMBER(xyonix_state::get_tile_info) { int tileno; int attr = m_vidram[tile_index+0x1000+1]; @@ -41,7 +41,7 @@ TILE_GET_INFO_MEMBER(xyonix_state::get_xyonix_tile_info) SET_TILE_INFO_MEMBER(0,tileno,attr >> 4,0); } -WRITE8_MEMBER(xyonix_state::xyonix_vidram_w) +WRITE8_MEMBER(xyonix_state::vidram_w) { m_vidram[offset] = data; m_tilemap->mark_tile_dirty((offset-1)&0x0fff); @@ -49,10 +49,10 @@ WRITE8_MEMBER(xyonix_state::xyonix_vidram_w) void xyonix_state::video_start() { - m_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(xyonix_state::get_xyonix_tile_info),this), TILEMAP_SCAN_ROWS, 4, 8, 80, 32); + m_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(xyonix_state::get_tile_info),this), TILEMAP_SCAN_ROWS, 4, 8, 80, 32); } -UINT32 xyonix_state::screen_update_xyonix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +UINT32 xyonix_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { m_tilemap->draw(screen, bitmap, cliprect, 0, 0); return 0;