Previous 199869 Revisions Next

r34397 Wednesday 14th January, 2015 at 19:52:22 UTC by Couriersud
Merge branch 'master' of https://github.com/mamedev/mame.git
[src/emu]emu.mak
[src/emu/bus/nes]ggenie.c ggenie.h nes_slot.h
[src/emu/ui]filemngr.c inputmap.c* inputmap.h* mainmenu.c miscmenu.c miscmenu.h selgame.c slotopt.c* slotopt.h*
[src/mame/drivers]eolith.c eolith16.c eolithsp.c sprint2.c stadhero.c vegaeo.c xyonix.c
[src/mame/includes]eolith.h eolithsp.h stadhero.h vaportra.h xyonix.h
[src/mame/video]eolith.c stadhero.c xyonix.c

trunk/src/emu/bus/nes/ggenie.c
r242908r242909
4848   save_item(NAME(m_gg_bypass));
4949}
5050
51void nes_ggenie_device::pcb_start(running_machine &machine, UINT8 *ciram_ptr, bool cart_mounted)
52{
53   device_nes_cart_interface::pcb_start(machine, ciram_ptr, cart_mounted);
54   if (m_ggslot->m_cart)
55      m_ggslot->pcb_start(m_ciram);
56}
57
5158void nes_ggenie_device::pcb_reset()
5259{
5360   m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
r242908r242909
5865   m_gg_bypass = 0;
5966
6067   if (m_ggslot->m_cart)
61   {
62      m_ggslot->pcb_start(m_ciram);
6368      m_ggslot->m_cart->pcb_reset();
64   }
6569}
6670
6771
trunk/src/emu/bus/nes/ggenie.h
r242908r242909
3333   virtual machine_config_constructor device_mconfig_additions() const;
3434
3535   virtual void pcb_reset();
36   virtual void pcb_start(running_machine &machine, UINT8 *ciram_ptr, bool cart_mounted);
3637
3738private:
3839   // emulate the Game Genie!
trunk/src/emu/bus/nes/nes_slot.h
r242908r242909
216216   virtual void scanline_irq(int scanline, int vblank, int blanked) {}
217217
218218   virtual void pcb_reset() {} // many pcb expect specific PRG/CHR banking at start
219   void pcb_start(running_machine &machine, UINT8 *ciram_ptr, bool cart_mounted);
219   virtual void pcb_start(running_machine &machine, UINT8 *ciram_ptr, bool cart_mounted);
220220   void pcb_reg_postload(running_machine &machine);
221221   void nes_banks_restore();
222222
trunk/src/emu/emu.mak
r242908r242909
116116   $(EMUOBJ)/timer.o \
117117   $(EMUOBJ)/uiinput.o \
118118   $(EMUOBJ)/ui/ui.o \
119   $(EMUOBJ)/ui/swlist.o \
120119   $(EMUOBJ)/ui/menu.o \
121120   $(EMUOBJ)/ui/mainmenu.o \
122121   $(EMUOBJ)/ui/miscmenu.o \
123   $(EMUOBJ)/ui/selgame.o \
122   $(EMUOBJ)/ui/barcode.o \
124123   $(EMUOBJ)/ui/filemngr.o \
125124   $(EMUOBJ)/ui/filesel.o \
126125   $(EMUOBJ)/ui/imgcntrl.o \
127126   $(EMUOBJ)/ui/imginfo.o \
128   $(EMUOBJ)/ui/barcode.o \
127   $(EMUOBJ)/ui/inputmap.o \
128   $(EMUOBJ)/ui/selgame.o \
129   $(EMUOBJ)/ui/slotopt.o \
130   $(EMUOBJ)/ui/swlist.o \
129131   $(EMUOBJ)/ui/tapectrl.o \
130132   $(EMUOBJ)/ui/viewgfx.o \
131133   $(EMUOBJ)/validity.o \
trunk/src/emu/ui/filemngr.c
r242908r242909
6666void ui_menu_file_manager::populate()
6767{
6868   astring buffer;
69   astring tmp_name;
69   bool first = true;
7070
7171   // cycle through all devices for this system
7272   image_interface_iterator iter(machine().root_device());
7373   for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
7474   {
75      if (first)
76         first = false;
77      else
78         item_append("", NULL, MENU_FLAG_DISABLE, NULL);
79
7580      // get the image type/id
76      buffer.printf(
77         "%s (%s)",
78         image->device().name(), image->brief_instance_name());
81      buffer.printf("%s (%s)", image->instance_name(), image->brief_instance_name());
82      item_append(buffer, "", MENU_FLAG_DISABLE, NULL);
83      item_append("Device", image->device().tag(), MENU_FLAG_DISABLE, NULL);
7984
8085      // get the base name
8186      if (image->basename() != NULL)
8287      {
83         tmp_name.cpy(image->basename());
88         buffer.cpy(image->basename());
8489
8590         // if the image has been loaded through softlist, also show the loaded part
8691         if (image->part_entry() != NULL)
r242908r242909
8893            const software_part *tmp = image->part_entry();
8994            if (tmp->name() != NULL)
9095            {
91               tmp_name.cat(" (");
92               tmp_name.cat(tmp->name());
96               buffer.cat(" (");
97               buffer.cat(tmp->name());
9398               // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it
9499               if (image->get_feature("part_id") != NULL)
95100               {
96                  tmp_name.cat(": ");
97                  tmp_name.cat(image->get_feature("part_id"));
101                  buffer.cat(": ");
102                  buffer.cat(image->get_feature("part_id"));
98103               }
99               tmp_name.cat(")");
104               buffer.cat(")");
100105            }
101106         }
102107      }
103108      else
104         tmp_name.cpy("---");
109         buffer.cpy("---");
105110
106111      // record the menu item
107      item_append(buffer, tmp_name.cstr(), 0, (void *) image);
112      item_append("Mounted File", buffer, 0, (void *) image);
108113   }
109114   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
110115   item_append("Reset",  NULL, 0, (void *)1);
trunk/src/emu/ui/inputmap.c
r0r242909
1/*********************************************************************
2
3    ui/inputmap.c
4
5    Internal menus for input mappings.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10*********************************************************************/
11
12#include "emu.h"
13
14#include "uiinput.h"
15#include "ui/ui.h"
16#include "ui/inputmap.h"
17
18
19/***************************************************************************
20    CONSTANTS
21***************************************************************************/
22
23#define MAX_PHYSICAL_DIPS       10
24#define MAX_INPUT_PORTS         32
25#define MAX_BITS_PER_PORT       32
26
27/* DIP switch rendering parameters */
28#define DIP_SWITCH_HEIGHT       0.05f
29#define DIP_SWITCH_SPACING      0.01
30#define SINGLE_TOGGLE_SWITCH_FIELD_WIDTH 0.025f
31#define SINGLE_TOGGLE_SWITCH_WIDTH 0.020f
32/* make the switch 80% of the width space and 1/2 of the switch height */
33#define PERCENTAGE_OF_HALF_FIELD_USED 0.80f
34#define SINGLE_TOGGLE_SWITCH_HEIGHT ((DIP_SWITCH_HEIGHT / 2) * PERCENTAGE_OF_HALF_FIELD_USED)
35
36
37
38/*-------------------------------------------------
39    menu_input_groups_populate - populate the
40    input groups menu
41-------------------------------------------------*/
42
43ui_menu_input_groups::ui_menu_input_groups(running_machine &machine, render_container *container) : ui_menu(machine, container)
44{
45}
46
47void ui_menu_input_groups::populate()
48{
49   int player;
50
51   /* build up the menu */
52   item_append("User Interface", NULL, 0, (void *)(IPG_UI + 1));
53   for (player = 0; player < MAX_PLAYERS; player++)
54   {
55      char buffer[40];
56      sprintf(buffer, "Player %d Controls", player + 1);
57      item_append(buffer, NULL, 0, (void *)(FPTR)(IPG_PLAYER1 + player + 1));
58   }
59   item_append("Other Controls", NULL, 0, (void *)(FPTR)(IPG_OTHER + 1));
60}
61
62ui_menu_input_groups::~ui_menu_input_groups()
63{
64}
65
66/*-------------------------------------------------
67    menu_input_groups - handle the input groups
68    menu
69-------------------------------------------------*/
70
71void ui_menu_input_groups::handle()
72{
73   /* process the menu */
74   const ui_menu_event *menu_event = process(0);
75   if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT)
76      ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_general(machine(), container, int((long long)(menu_event->itemref)-1))));
77}
78
79
80
81/*-------------------------------------------------
82    menu_input_general - handle the general
83    input menu
84-------------------------------------------------*/
85
86ui_menu_input_general::ui_menu_input_general(running_machine &machine, render_container *container, int _group) : ui_menu_input(machine, container)
87{
88   group = _group;
89}
90
91void ui_menu_input_general::populate()
92{
93   input_item_data *itemlist = NULL;
94   int suborder[SEQ_TYPE_TOTAL];
95   astring tempstring;
96   int sortorder = 1;
97
98   /* create a mini lookup table for sort order based on sequence type */
99   suborder[SEQ_TYPE_STANDARD] = 0;
100   suborder[SEQ_TYPE_DECREMENT] = 1;
101   suborder[SEQ_TYPE_INCREMENT] = 2;
102
103   /* iterate over the input ports and add menu items */
104   for (input_type_entry *entry = machine().ioport().first_type(); entry != NULL; entry = entry->next())
105
106      /* add if we match the group and we have a valid name */
107      if (entry->group() == group && entry->name() != NULL && entry->name()[0] != 0)
108      {
109         input_seq_type seqtype;
110
111         /* loop over all sequence types */
112         sortorder++;
113         for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++)
114         {
115            /* build an entry for the standard sequence */
116            input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item));
117            memset(item, 0, sizeof(*item));
118            item->ref = entry;
119            if(pollingitem && pollingref == entry && pollingseq == seqtype)
120               pollingitem = item;
121            item->seqtype = seqtype;
122            item->seq = machine().ioport().type_seq(entry->type(), entry->player(), seqtype);
123            item->defseq = &entry->defseq(seqtype);
124            item->sortorder = sortorder * 4 + suborder[seqtype];
125            item->type = ioport_manager::type_is_analog(entry->type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL;
126            item->name = entry->name();
127            item->owner_name = NULL;
128            item->next = itemlist;
129            itemlist = item;
130
131            /* stop after one, unless we're analog */
132            if (item->type == INPUT_TYPE_DIGITAL)
133               break;
134         }
135      }
136
137   /* sort and populate the menu in a standard fashion */
138   populate_and_sort(itemlist);
139}
140
141ui_menu_input_general::~ui_menu_input_general()
142{
143}
144
145/*-------------------------------------------------
146    menu_input_specific - handle the game-specific
147    input menu
148-------------------------------------------------*/
149
150ui_menu_input_specific::ui_menu_input_specific(running_machine &machine, render_container *container) : ui_menu_input(machine, container)
151{
152}
153
154void ui_menu_input_specific::populate()
155{
156   input_item_data *itemlist = NULL;
157   ioport_field *field;
158   ioport_port *port;
159   int suborder[SEQ_TYPE_TOTAL];
160   astring tempstring;
161
162   /* create a mini lookup table for sort order based on sequence type */
163   suborder[SEQ_TYPE_STANDARD] = 0;
164   suborder[SEQ_TYPE_DECREMENT] = 1;
165   suborder[SEQ_TYPE_INCREMENT] = 2;
166
167   /* iterate over the input ports and add menu items */
168   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
169      for (field = port->first_field(); field != NULL; field = field->next())
170      {
171         const char *name = field->name();
172
173         /* add if we match the group and we have a valid name */
174         if (name != NULL && field->enabled() &&
175            ((field->type() == IPT_OTHER && field->name() != NULL) || machine().ioport().type_group(field->type(), field->player()) != IPG_INVALID))
176         {
177            input_seq_type seqtype;
178            UINT32 sortorder;
179
180            /* determine the sorting order */
181            if (field->type() >= IPT_START1 && field->type() < IPT_ANALOG_LAST)
182            {
183               sortorder = (field->type() << 2) | (field->player() << 12);
184               if (strcmp(field->device().tag(), ":"))
185                  sortorder |= 0x10000;
186            }
187            else
188               sortorder = field->type() | 0xf000;
189
190            /* loop over all sequence types */
191            for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++)
192            {
193               /* build an entry for the standard sequence */
194               input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item));
195               memset(item, 0, sizeof(*item));
196               item->ref = field;
197               item->seqtype = seqtype;
198               if(pollingitem && pollingref == field && pollingseq == seqtype)
199                  pollingitem = item;
200               item->seq = field->seq(seqtype);
201               item->defseq = &field->defseq(seqtype);
202               item->sortorder = sortorder + suborder[seqtype];
203               item->type = field->is_analog() ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL;
204               item->name = name;
205               item->owner_name = field->device().tag();
206               item->next = itemlist;
207               itemlist = item;
208
209               /* stop after one, unless we're analog */
210               if (item->type == INPUT_TYPE_DIGITAL)
211                  break;
212            }
213         }
214      }
215
216   /* sort and populate the menu in a standard fashion */
217   populate_and_sort(itemlist);
218}
219
220ui_menu_input_specific::~ui_menu_input_specific()
221{
222}
223
224/*-------------------------------------------------
225    menu_input - display a menu for inputs
226-------------------------------------------------*/
227ui_menu_input::ui_menu_input(running_machine &machine, render_container *container) : ui_menu(machine, container)
228{
229   pollingitem = 0;
230   pollingref = 0;
231   pollingseq = SEQ_TYPE_STANDARD;
232}
233
234ui_menu_input::~ui_menu_input()
235{
236}
237
238/*-------------------------------------------------
239    toggle_none_default - toggle between "NONE"
240    and the default item
241-------------------------------------------------*/
242
243void ui_menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq)
244{
245   /* if we used to be "none", toggle to the default value */
246   if (original_seq.length() == 0)
247      selected_seq = selected_defseq;
248
249   /* otherwise, toggle to "none" */
250   else
251      selected_seq.reset();
252}
253
254void ui_menu_input::handle()
255{
256   input_item_data *seqchangeditem = NULL;
257   const ui_menu_event *menu_event;
258   int invalidate = false;
259
260   /* process the menu */
261   menu_event = process((pollingitem != NULL) ? UI_MENU_PROCESS_NOKEYS : 0);
262
263   /* if we are polling, handle as a special case */
264   if (pollingitem != NULL)
265   {
266      input_item_data *item = pollingitem;
267      input_seq newseq;
268
269      /* if UI_CANCEL is pressed, abort */
270      if (ui_input_pressed(machine(), IPT_UI_CANCEL))
271      {
272         pollingitem = NULL;
273         record_next = false;
274         toggle_none_default(item->seq, starting_seq, *item->defseq);
275         seqchangeditem = item;
276      }
277
278      /* poll again; if finished, update the sequence */
279      if (machine().input().seq_poll())
280      {
281         pollingitem = NULL;
282         record_next = true;
283         item->seq = machine().input().seq_poll_final();
284         seqchangeditem = item;
285      }
286   }
287
288   /* otherwise, handle the events */
289   else if (menu_event != NULL && menu_event->itemref != NULL)
290   {
291      input_item_data *item = (input_item_data *)menu_event->itemref;
292      switch (menu_event->iptkey)
293      {
294         /* an item was selected: begin polling */
295         case IPT_UI_SELECT:
296            pollingitem = item;
297            last_sortorder = item->sortorder;
298            starting_seq = item->seq;
299            machine().input().seq_poll_start((item->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &item->seq : NULL);
300            invalidate = true;
301            break;
302
303         /* if the clear key was pressed, reset the selected item */
304         case IPT_UI_CLEAR:
305            toggle_none_default(item->seq, item->seq, *item->defseq);
306            record_next = false;
307            seqchangeditem = item;
308            break;
309      }
310
311      /* if the selection changed, reset the "record next" flag */
312      if (item->sortorder != last_sortorder)
313         record_next = false;
314      last_sortorder = item->sortorder;
315   }
316
317   /* if the sequence changed, update it */
318   if (seqchangeditem != NULL)
319   {
320      update_input(seqchangeditem);
321
322      /* invalidate the menu to force an update */
323      invalidate = true;
324   }
325
326   /* if the menu is invalidated, clear it now */
327   if (invalidate)
328   {
329      pollingref = NULL;
330      if (pollingitem != NULL)
331      {
332         pollingref = pollingitem->ref;
333         pollingseq = pollingitem->seqtype;
334      }
335      reset(UI_MENU_RESET_REMEMBER_POSITION);
336   }
337}
338
339void ui_menu_input_general::update_input(struct input_item_data *seqchangeditem)
340{
341   const input_type_entry *entry = (const input_type_entry *)seqchangeditem->ref;
342   machine().ioport().set_type_seq(entry->type(), entry->player(), seqchangeditem->seqtype, seqchangeditem->seq);
343}
344
345void ui_menu_input_specific::update_input(struct input_item_data *seqchangeditem)
346{
347   ioport_field::user_settings settings;
348
349   ((ioport_field *)seqchangeditem->ref)->get_user_settings(settings);
350   settings.seq[seqchangeditem->seqtype] = seqchangeditem->seq;
351   ((ioport_field *)seqchangeditem->ref)->set_user_settings(settings);
352}
353
354
355/*-------------------------------------------------
356    menu_input_compare_items - compare two
357    items for quicksort
358-------------------------------------------------*/
359
360int ui_menu_input::compare_items(const void *i1, const void *i2)
361{
362   const input_item_data * const *data1 = (const input_item_data * const *)i1;
363   const input_item_data * const *data2 = (const input_item_data * const *)i2;
364   if ((*data1)->sortorder < (*data2)->sortorder)
365      return -1;
366   if ((*data1)->sortorder > (*data2)->sortorder)
367      return 1;
368   return 0;
369}
370
371
372/*-------------------------------------------------
373    menu_input_populate_and_sort - take a list
374    of input_item_data objects and build up the
375    menu from them
376-------------------------------------------------*/
377
378void ui_menu_input::populate_and_sort(input_item_data *itemlist)
379{
380   const char *nameformat[INPUT_TYPE_TOTAL] = { 0 };
381   input_item_data **itemarray, *item;
382   int numitems = 0, curitem;
383   astring text;
384   astring subtext;
385   astring prev_owner;
386   bool first_entry = true;
387
388   /* create a mini lookup table for name format based on type */
389   nameformat[INPUT_TYPE_DIGITAL] = "%s";
390   nameformat[INPUT_TYPE_ANALOG] = "%s Analog";
391   nameformat[INPUT_TYPE_ANALOG_INC] = "%s Analog Inc";
392   nameformat[INPUT_TYPE_ANALOG_DEC] = "%s Analog Dec";
393
394   /* first count the number of items */
395   for (item = itemlist; item != NULL; item = item->next)
396      numitems++;
397
398   /* now allocate an array of items and fill it up */
399   itemarray = (input_item_data **)m_pool_alloc(sizeof(*itemarray) * numitems);
400   for (item = itemlist, curitem = 0; item != NULL; item = item->next)
401      itemarray[curitem++] = item;
402
403   /* sort it */
404   qsort(itemarray, numitems, sizeof(*itemarray), compare_items);
405
406   /* build the menu */
407   for (curitem = 0; curitem < numitems; curitem++)
408   {
409      UINT32 flags = 0;
410
411      /* generate the name of the item itself, based off the base name and the type */
412      item = itemarray[curitem];
413      assert(nameformat[item->type] != NULL);
414
415      if (strcmp(item->owner_name, prev_owner.cstr()) != 0)
416      {
417         if (first_entry)
418            first_entry = false;
419         else
420            item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
421         text.printf("[root%s]", item->owner_name);
422         item_append(text, NULL, 0, NULL);
423         prev_owner.cpy(item->owner_name);
424      }
425
426      text.printf(nameformat[item->type], item->name);
427
428      /* if we're polling this item, use some spaces with left/right arrows */
429      if (pollingref == item->ref)
430      {
431         subtext.cpy("   ");
432         flags |= MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW;
433      }
434
435      /* otherwise, generate the sequence name and invert it if different from the default */
436      else
437      {
438         machine().input().seq_name(subtext, item->seq);
439         flags |= (item->seq != *item->defseq) ? MENU_FLAG_INVERT : 0;
440      }
441
442      /* add the item */
443      item_append(text, subtext, flags, item);
444   }
445}
446
447
448/*-------------------------------------------------
449    menu_settings_dip_switches - handle the DIP
450    switches menu
451-------------------------------------------------*/
452
453ui_menu_settings_dip_switches::ui_menu_settings_dip_switches(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_DIPSWITCH)
454{
455}
456
457ui_menu_settings_dip_switches::~ui_menu_settings_dip_switches()
458{
459}
460
461/*-------------------------------------------------
462    menu_settings_driver_config - handle the
463    driver config menu
464-------------------------------------------------*/
465
466ui_menu_settings_driver_config::ui_menu_settings_driver_config(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_CONFIG)
467{
468}
469
470ui_menu_settings_driver_config::~ui_menu_settings_driver_config()
471{
472}
473
474/*-------------------------------------------------
475    menu_settings_common - handle one of the
476    switches menus
477-------------------------------------------------*/
478
479void ui_menu_settings::handle()
480{
481   // process the menu
482   const ui_menu_event *menu_event = process(0);
483
484   // handle events
485   if (menu_event != NULL && menu_event->itemref != NULL)
486   {
487      // reset
488      if ((FPTR)menu_event->itemref == 1)
489      {
490         if (menu_event->iptkey == IPT_UI_SELECT)
491            machine().schedule_hard_reset();
492      }
493      // actual settings
494      else
495      {
496         ioport_field *field = (ioport_field *)menu_event->itemref;
497         ioport_field::user_settings settings;
498         int changed = false;
499         
500         switch (menu_event->iptkey)
501         {
502            /* if selected, reset to default value */
503            case IPT_UI_SELECT:
504               field->get_user_settings(settings);
505               settings.value = field->defvalue();
506               field->set_user_settings(settings);
507               changed = true;
508               break;
509               
510            /* left goes to previous setting */
511            case IPT_UI_LEFT:
512               field->select_previous_setting();
513               changed = true;
514               break;
515               
516            /* right goes to next setting */
517            case IPT_UI_RIGHT:
518               field->select_next_setting();
519               changed = true;
520               break;
521         }
522         
523         /* if anything changed, rebuild the menu, trying to stay on the same field */
524         if (changed)
525            reset(UI_MENU_RESET_REMEMBER_REF);
526      }
527   }
528}
529
530
531/*-------------------------------------------------
532    menu_settings_populate - populate one of the
533    switches menus
534-------------------------------------------------*/
535
536ui_menu_settings::ui_menu_settings(running_machine &machine, render_container *container, UINT32 _type) : ui_menu(machine, container)
537{
538   type = _type;
539}
540
541void ui_menu_settings::populate()
542{
543   ioport_field *field;
544   ioport_port *port;
545   dip_descriptor **diplist_tailptr;
546   astring prev_owner;
547   bool first_entry = true;
548
549   /* reset the dip switch tracking */
550   dipcount = 0;
551   diplist = NULL;
552   diplist_tailptr = &diplist;
553
554   /* loop over input ports and set up the current values */
555   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
556      for (field = port->first_field(); field != NULL; field = field->next())
557         if (field->type() == type && field->enabled())
558         {
559            UINT32 flags = 0;
560            astring name;
561
562            /* set the left/right flags appropriately */
563            if (field->has_previous_setting())
564               flags |= MENU_FLAG_LEFT_ARROW;
565            if (field->has_next_setting())
566               flags |= MENU_FLAG_RIGHT_ARROW;
567
568            /* add the menu item */
569            if (strcmp(field->device().tag(), prev_owner.cstr()) != 0)
570            {
571               if (first_entry)
572                  first_entry = false;
573               else
574                  item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
575               name.printf("[root%s]", field->device().tag());
576               item_append(name, NULL, 0, NULL);
577               prev_owner.cpy(field->device().tag());
578            }
579
580            name.cpy(field->name());
581
582            item_append(name, field->setting_name(), flags, (void *)field);
583
584            /* for DIP switches, build up the model */
585            if (type == IPT_DIPSWITCH && field->first_diplocation() != NULL)
586            {
587               const ioport_diplocation *diploc;
588               ioport_field::user_settings settings;
589               UINT32 accummask = field->mask();
590
591               /* get current settings */
592               field->get_user_settings(settings);
593
594               /* iterate over each bit in the field */
595               for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next())
596               {
597                  UINT32 mask = accummask & ~(accummask - 1);
598                  dip_descriptor *dip;
599
600                  /* find the matching switch name */
601                  for (dip = diplist; dip != NULL; dip = dip->next)
602                     if (strcmp(dip->name, diploc->name()) == 0)
603                        break;
604
605                  /* allocate new if none */
606                  if (dip == NULL)
607                  {
608                     dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip));
609                     dip->next = NULL;
610                     dip->name = diploc->name();
611                     dip->mask = dip->state = 0;
612                     *diplist_tailptr = dip;
613                     diplist_tailptr = &dip->next;
614                     dipcount++;
615                  }
616
617                  /* apply the bits */
618                  dip->mask |= 1 << (diploc->number() - 1);
619                  if (((settings.value & mask) != 0 && !diploc->inverted()) || ((settings.value & mask) == 0 && diploc->inverted()))
620                     dip->state |= 1 << (diploc->number() - 1);
621
622                  /* clear the relevant bit in the accumulated mask */
623                  accummask &= ~mask;
624               }
625            }
626         }
627   if (type == IPT_DIPSWITCH)
628      custombottom = dipcount ? dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING : 0;
629   
630   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
631   item_append("Reset",  NULL, 0, (void *)1);
632}
633
634ui_menu_settings::~ui_menu_settings()
635{
636}
637
638/*-------------------------------------------------
639    menu_settings_custom_render - perform our special
640    rendering
641-------------------------------------------------*/
642
643void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2)
644{
645   // catch if no diploc has to be drawn
646   if (bottom == 0)
647      return;
648
649   // add borders
650   y1 = y2 + UI_BOX_TB_BORDER;
651   y2 = y1 + bottom;
652
653   // draw extra menu area
654   machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
655   y1 += (float)DIP_SWITCH_SPACING;
656
657   // iterate over DIP switches
658   for (dip_descriptor *dip = diplist; dip != NULL; dip = dip->next)
659   {
660      const ioport_diplocation *diploc;
661      UINT32 selectedmask = 0;
662     
663      // determine the mask of selected bits
664      if ((FPTR)selectedref != 1)
665      {
666         ioport_field *field = (ioport_field *)selectedref;
667         
668         if (field != NULL && field->first_diplocation() != NULL)
669            for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next())
670               if (strcmp(dip->name, diploc->name()) == 0)
671                  selectedmask |= 1 << (diploc->number() - 1);
672      }
673     
674      // draw one switch
675      custom_render_one(x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask);
676      y1 += (float)(DIP_SWITCH_SPACING + DIP_SWITCH_HEIGHT);
677   }
678}
679
680
681/*-------------------------------------------------
682    menu_settings_custom_render_one - draw a single
683    DIP switch
684-------------------------------------------------*/
685
686void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask)
687{
688   float switch_field_width = SINGLE_TOGGLE_SWITCH_FIELD_WIDTH * container->manager().ui_aspect();
689   float switch_width = SINGLE_TOGGLE_SWITCH_WIDTH * container->manager().ui_aspect();
690   int numtoggles, toggle;
691   float switch_toggle_gap;
692   float y1_off, y1_on;
693
694   /* determine the number of toggles in the DIP */
695   numtoggles = 32 - count_leading_zeros(dip->mask);
696
697   /* center based on the number of switches */
698   x1 += (x2 - x1 - numtoggles * switch_field_width) / 2;
699
700   /* draw the dip switch name */
701   machine().ui().draw_text_full(  container,
702                  dip->name,
703                  0,
704                  y1 + (DIP_SWITCH_HEIGHT - UI_TARGET_FONT_HEIGHT) / 2,
705                  x1 - machine().ui().get_string_width(" "),
706                  JUSTIFY_RIGHT,
707                  WRAP_NEVER,
708                  DRAW_NORMAL,
709                  UI_TEXT_COLOR,
710                  PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA),
711                  NULL ,
712                  NULL);
713
714   /* compute top and bottom for on and off positions */
715   switch_toggle_gap = ((DIP_SWITCH_HEIGHT/2) - SINGLE_TOGGLE_SWITCH_HEIGHT)/2;
716   y1_off = y1 + UI_LINE_WIDTH + switch_toggle_gap;
717   y1_on = y1 + DIP_SWITCH_HEIGHT/2 + switch_toggle_gap;
718
719   /* iterate over toggles */
720   for (toggle = 0; toggle < numtoggles; toggle++)
721   {
722      float innerx1;
723
724      /* first outline the switch */
725      machine().ui().draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR);
726
727      /* compute x1/x2 for the inner filled in switch */
728      innerx1 = x1 + (switch_field_width - switch_width) / 2;
729
730      /* see if the switch is actually used */
731      if (dip->mask & (1 << toggle))
732      {
733         float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off;
734         container->add_rect(innerx1, innery1, innerx1 + switch_width, innery1 + SINGLE_TOGGLE_SWITCH_HEIGHT,
735                        (selectedmask & (1 << toggle)) ? UI_DIPSW_COLOR : UI_TEXT_COLOR,
736                        PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
737      }
738      else
739      {
740         container->add_rect(innerx1, y1_off, innerx1 + switch_width, y1_on + SINGLE_TOGGLE_SWITCH_HEIGHT,
741                        UI_UNAVAILABLE_COLOR,
742                        PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
743      }
744
745      /* advance to the next switch */
746      x1 += switch_field_width;
747   }
748}
749
750
751/*-------------------------------------------------
752    menu_analog - handle the analog settings menu
753-------------------------------------------------*/
754
755void ui_menu_analog::handle()
756{
757   /* process the menu */
758   const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT);
759
760   /* handle events */
761   if (menu_event != NULL && menu_event->itemref != NULL)
762   {
763      analog_item_data *data = (analog_item_data *)menu_event->itemref;
764      int newval = data->cur;
765
766      switch (menu_event->iptkey)
767      {
768         /* if selected, reset to default value */
769         case IPT_UI_SELECT:
770            newval = data->defvalue;
771            break;
772
773         /* left decrements */
774         case IPT_UI_LEFT:
775            newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1;
776            break;
777
778         /* right increments */
779         case IPT_UI_RIGHT:
780            newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1;
781            break;
782      }
783
784      /* clamp to range */
785      if (newval < data->min)
786         newval = data->min;
787      if (newval > data->max)
788         newval = data->max;
789
790      /* if things changed, update */
791      if (newval != data->cur)
792      {
793         ioport_field::user_settings settings;
794
795         /* get the settings and set the new value */
796         data->field->get_user_settings(settings);
797         switch (data->type)
798         {
799            case ANALOG_ITEM_KEYSPEED:      settings.delta = newval;        break;
800            case ANALOG_ITEM_CENTERSPEED:   settings.centerdelta = newval;  break;
801            case ANALOG_ITEM_REVERSE:       settings.reverse = newval;      break;
802            case ANALOG_ITEM_SENSITIVITY:   settings.sensitivity = newval;  break;
803         }
804         data->field->set_user_settings(settings);
805
806         /* rebuild the menu */
807         reset(UI_MENU_RESET_REMEMBER_POSITION);
808      }
809   }
810}
811
812
813/*-------------------------------------------------
814    menu_analog_populate - populate the analog
815    settings menu
816-------------------------------------------------*/
817
818ui_menu_analog::ui_menu_analog(running_machine &machine, render_container *container) : ui_menu(machine, container)
819{
820}
821
822void ui_menu_analog::populate()
823{
824   ioport_field *field;
825   ioport_port *port;
826   astring text;
827   astring subtext;
828   astring prev_owner;
829   bool first_entry = true;
830
831   /* loop over input ports and add the items */
832   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
833      for (field = port->first_field(); field != NULL; field = field->next())
834         if (field->is_analog() && field->enabled())
835         {
836            ioport_field::user_settings settings;
837            int use_autocenter = false;
838            int type;
839
840            /* based on the type, determine if we enable autocenter */
841            switch (field->type())
842            {
843               case IPT_POSITIONAL:
844               case IPT_POSITIONAL_V:
845                  if (field->analog_wraps())
846                     break;
847
848               case IPT_AD_STICK_X:
849               case IPT_AD_STICK_Y:
850               case IPT_AD_STICK_Z:
851               case IPT_PADDLE:
852               case IPT_PADDLE_V:
853               case IPT_PEDAL:
854               case IPT_PEDAL2:
855               case IPT_PEDAL3:
856                  use_autocenter = true;
857                  break;
858
859               default:
860                  break;
861            }
862
863            /* get the user settings */
864            field->get_user_settings(settings);
865
866            /* iterate over types */
867            for (type = 0; type < ANALOG_ITEM_COUNT; type++)
868               if (type != ANALOG_ITEM_CENTERSPEED || use_autocenter)
869               {
870                  analog_item_data *data;
871                  UINT32 flags = 0;
872                  astring name;
873                  if (strcmp(field->device().tag(), prev_owner.cstr()) != 0)
874                  {
875                     if (first_entry)
876                        first_entry = false;
877                     else
878                        item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
879                     name.printf("[root%s]", field->device().tag());
880                     item_append(name, NULL, 0, NULL);
881                     prev_owner.cpy(field->device().tag());
882                  }
883
884                  name.cpy(field->name());
885                 
886                  /* allocate a data item for tracking what this menu item refers to */
887                  data = (analog_item_data *)m_pool_alloc(sizeof(*data));
888                  data->field = field;
889                  data->type = type;
890
891                  /* determine the properties of this item */
892                  switch (type)
893                  {
894                     default:
895                     case ANALOG_ITEM_KEYSPEED:
896                        text.printf("%s Digital Speed", name.cstr());
897                        subtext.printf("%d", settings.delta);
898                        data->min = 0;
899                        data->max = 255;
900                        data->cur = settings.delta;
901                        data->defvalue = field->delta();
902                        break;
903
904                     case ANALOG_ITEM_CENTERSPEED:
905                        text.printf("%s Autocenter Speed", name.cstr());
906                        subtext.printf("%d", settings.centerdelta);
907                        data->min = 0;
908                        data->max = 255;
909                        data->cur = settings.centerdelta;
910                        data->defvalue = field->centerdelta();
911                        break;
912
913                     case ANALOG_ITEM_REVERSE:
914                        text.printf("%s Reverse", name.cstr());
915                        subtext.cpy(settings.reverse ? "On" : "Off");
916                        data->min = 0;
917                        data->max = 1;
918                        data->cur = settings.reverse;
919                        data->defvalue = field->analog_reverse();
920                        break;
921
922                     case ANALOG_ITEM_SENSITIVITY:
923                        text.printf("%s Sensitivity", name.cstr());
924                        subtext.printf("%d", settings.sensitivity);
925                        data->min = 1;
926                        data->max = 255;
927                        data->cur = settings.sensitivity;
928                        data->defvalue = field->sensitivity();
929                        break;
930                  }
931
932                  /* put on arrows */
933                  if (data->cur > data->min)
934                     flags |= MENU_FLAG_LEFT_ARROW;
935                  if (data->cur < data->max)
936                     flags |= MENU_FLAG_RIGHT_ARROW;
937
938                  /* append a menu item */
939                  item_append(text, subtext, flags, data);
940               }
941         }
942}
943
944ui_menu_analog::~ui_menu_analog()
945{
946}
trunk/src/emu/ui/inputmap.h
r0r242909
1/***************************************************************************
2
3    ui/inputmap.h
4
5    Internal menus for input mappings.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10***************************************************************************/
11
12#pragma once
13
14#ifndef __UI_INPUTMAP_H__
15#define __UI_INPUTMAP_H__
16
17//#include "drivenum.h"
18
19class ui_menu_input_groups : public ui_menu {
20public:
21   ui_menu_input_groups(running_machine &machine, render_container *container);
22   virtual ~ui_menu_input_groups();
23   virtual void populate();
24   virtual void handle();
25};
26
27class ui_menu_input : public ui_menu {
28public:
29   ui_menu_input(running_machine &machine, render_container *container);
30   virtual ~ui_menu_input();
31   virtual void handle();
32
33protected:
34   enum {
35      INPUT_TYPE_DIGITAL = 0,
36      INPUT_TYPE_ANALOG = 1,
37      INPUT_TYPE_ANALOG_DEC = INPUT_TYPE_ANALOG + SEQ_TYPE_DECREMENT,
38      INPUT_TYPE_ANALOG_INC = INPUT_TYPE_ANALOG + SEQ_TYPE_INCREMENT,
39      INPUT_TYPE_TOTAL = INPUT_TYPE_ANALOG + SEQ_TYPE_TOTAL
40   };
41
42   /* internal input menu item data */
43   struct input_item_data {
44      input_item_data *   next;               /* pointer to next item in the list */
45      const void *        ref;                /* reference to type description for global inputs or field for game inputs */
46      input_seq_type      seqtype;            /* sequence type */
47      input_seq           seq;                /* copy of the live sequence */
48      const input_seq *   defseq;             /* pointer to the default sequence */
49      const char *        name;               /* pointer to the base name of the item */
50      const char *        owner_name;         /* pointer to the name of the owner of the item */
51      UINT32              sortorder;          /* sorting information */
52      UINT8               type;               /* type of port */
53   };
54
55   void populate_and_sort(struct input_item_data *itemlist);
56   virtual void update_input(struct input_item_data *seqchangeditem) = 0;
57   void toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq);
58
59protected:
60   const void *        pollingref;
61   input_seq_type      pollingseq;
62   input_item_data *   pollingitem;
63
64private:
65   UINT16              last_sortorder;
66   bool                record_next;
67   input_seq           starting_seq;
68
69   static int compare_items(const void *i1, const void *i2);
70};
71
72class ui_menu_input_general : public ui_menu_input {
73public:
74   ui_menu_input_general(running_machine &machine, render_container *container, int group);
75   virtual ~ui_menu_input_general();
76   virtual void populate();
77
78protected:
79   int group;
80   virtual void update_input(struct input_item_data *seqchangeditem);
81};
82
83class ui_menu_input_specific : public ui_menu_input {
84public:
85   ui_menu_input_specific(running_machine &machine, render_container *container);
86   virtual ~ui_menu_input_specific();
87   virtual void populate();
88
89protected:
90   virtual void update_input(struct input_item_data *seqchangeditem);
91};
92
93class ui_menu_settings : public ui_menu {
94public:
95   ui_menu_settings(running_machine &machine, render_container *container, UINT32 type);
96   virtual ~ui_menu_settings();
97   virtual void populate();
98   virtual void handle();
99
100protected:
101   /* DIP switch descriptor */
102   struct dip_descriptor {
103      dip_descriptor *    next;
104      const char *        name;
105      UINT32              mask;
106      UINT32              state;
107   };
108
109   dip_descriptor *    diplist;
110   int dipcount;
111   int type;
112};
113
114class ui_menu_settings_dip_switches : public ui_menu_settings {
115public:
116   ui_menu_settings_dip_switches(running_machine &machine, render_container *container);
117   virtual ~ui_menu_settings_dip_switches();
118
119   virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
120private:
121   void custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask);
122};
123
124class ui_menu_settings_driver_config : public ui_menu_settings {
125public:
126   ui_menu_settings_driver_config(running_machine &machine, render_container *container);
127   virtual ~ui_menu_settings_driver_config();
128};
129
130class ui_menu_analog : public ui_menu {
131public:
132   ui_menu_analog(running_machine &machine, render_container *container);
133   virtual ~ui_menu_analog();
134   virtual void populate();
135   virtual void handle();
136
137private:
138   enum {
139      ANALOG_ITEM_KEYSPEED = 0,
140      ANALOG_ITEM_CENTERSPEED,
141      ANALOG_ITEM_REVERSE,
142      ANALOG_ITEM_SENSITIVITY,
143      ANALOG_ITEM_COUNT
144   };
145
146   /* internal analog menu item data */
147   struct analog_item_data {
148      ioport_field *field;
149      int                 type;
150      int                 min, max;
151      int                 cur;
152      int                 defvalue;
153   };
154};
155
156#endif  /* __UI_INPUTMAP_H__ */
trunk/src/emu/ui/mainmenu.c
r242908r242909
1919#include "ui/filemngr.h"
2020#include "ui/filesel.h"
2121#include "ui/barcode.h"
22#include "ui/tapectrl.h"
22#include "ui/imginfo.h"
23#include "ui/inputmap.h"
2324#include "ui/mainmenu.h"
2425#include "ui/miscmenu.h"
25#include "ui/imginfo.h"
2626#include "ui/selgame.h"
27#include "ui/slotopt.h"
28#include "ui/tapectrl.h"
2729#include "audit.h"
2830#include "crsshair.h"
2931#include <ctype.h>
trunk/src/emu/ui/miscmenu.c
r242908r242909
2424#include "ui/filemngr.h"
2525
2626
27/***************************************************************************
28    CONSTANTS
29***************************************************************************/
30
31#define MAX_PHYSICAL_DIPS       10
32#define MAX_INPUT_PORTS         32
33#define MAX_BITS_PER_PORT       32
34
35/* DIP switch rendering parameters */
36#define DIP_SWITCH_HEIGHT       0.05f
37#define DIP_SWITCH_SPACING      0.01
38#define SINGLE_TOGGLE_SWITCH_FIELD_WIDTH 0.025f
39#define SINGLE_TOGGLE_SWITCH_WIDTH 0.020f
40/* make the switch 80% of the width space and 1/2 of the switch height */
41#define PERCENTAGE_OF_HALF_FIELD_USED 0.80f
42#define SINGLE_TOGGLE_SWITCH_HEIGHT ((DIP_SWITCH_HEIGHT / 2) * PERCENTAGE_OF_HALF_FIELD_USED)
43
4427/*-------------------------------------------------
4528    ui_slider_ui_handler - pushes the slider
4629    menu on the stack and hands off to the
r242908r242909
10891
10992
11093/*-------------------------------------------------
111    ui_slot_get_current_option - returns
112-------------------------------------------------*/
113device_slot_option *ui_menu_slot_devices::slot_get_current_option(device_slot_interface *slot)
114{
115   const char *current;
116   if (slot->fixed())
117   {
118      current = slot->default_option();
119   }
120   else
121   {
122      astring temp;
123      current = machine().options().main_value(temp, slot->device().tag() + 1);
124   }
125
126   return slot->option(current);
127}
128
129/*-------------------------------------------------
130    ui_slot_get_current_index - returns
131-------------------------------------------------*/
132int ui_menu_slot_devices::slot_get_current_index(device_slot_interface *slot)
133{
134   const device_slot_option *current = slot_get_current_option(slot);
135
136   if (current != NULL)
137   {
138      int val = 0;
139      for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next())
140      {
141         if (option == current)
142            return val;
143
144         if (option->selectable())
145            val++;
146      }
147   }
148
149   return -1;
150}
151
152/*-------------------------------------------------
153    ui_slot_get_length - returns
154-------------------------------------------------*/
155int ui_menu_slot_devices::slot_get_length(device_slot_interface *slot)
156{
157   int val = 0;
158   for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next())
159      if (option->selectable())
160         val++;
161
162   return val;
163}
164
165/*-------------------------------------------------
166    ui_slot_get_next - returns
167-------------------------------------------------*/
168const char *ui_menu_slot_devices::slot_get_next(device_slot_interface *slot)
169{
170   int idx = slot_get_current_index(slot);
171   if (idx < 0)
172      idx = 0;
173   else
174      idx++;
175
176   if (idx >= slot_get_length(slot))
177      return "";
178
179   return slot_get_option(slot, idx);
180}
181
182/*-------------------------------------------------
183    ui_slot_get_prev - returns
184-------------------------------------------------*/
185const char *ui_menu_slot_devices::slot_get_prev(device_slot_interface *slot)
186{
187   int idx = slot_get_current_index(slot);
188   if (idx < 0)
189      idx = slot_get_length(slot) - 1;
190   else
191      idx--;
192
193   if (idx < 0)
194      return "";
195
196   return slot_get_option(slot, idx);
197}
198
199/*-------------------------------------------------
200    ui_slot_get_option - returns
201-------------------------------------------------*/
202const char *ui_menu_slot_devices::slot_get_option(device_slot_interface *slot, int index)
203{
204   if (index >= 0)
205   {
206      int val = 0;
207      for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next())
208      {
209         if (val == index)
210            return option->name();
211
212         if (option->selectable())
213            val++;
214      }
215   }
216
217   return "";
218}
219
220
221/*-------------------------------------------------
222    ui_set_use_natural_keyboard - specifies
223    whether the natural keyboard is active
224-------------------------------------------------*/
225
226void ui_menu_slot_devices::set_slot_device(device_slot_interface *slot, const char *val)
227{
228   astring error;
229   machine().options().set_value(slot->device().tag()+1, val, OPTION_PRIORITY_CMDLINE, error);
230   assert(!error);
231}
232
233/*-------------------------------------------------
234    menu_slot_devices_populate - populates the main
235    slot device menu
236-------------------------------------------------*/
237
238ui_menu_slot_devices::ui_menu_slot_devices(running_machine &machine, render_container *container) : ui_menu(machine, container)
239{
240}
241
242void ui_menu_slot_devices::populate()
243{
244   /* cycle through all devices for this system */
245   slot_interface_iterator iter(machine().root_device());
246   for (device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next())
247   {
248      /* record the menu item */
249      const device_slot_option *option = slot_get_current_option(slot);
250      astring opt_name;
251      if (option == NULL)
252         opt_name.cpy("------");
253      else
254      {
255         opt_name.cpy(option->name());
256         if (slot->fixed() || slot_get_length(slot) == 0)
257            opt_name.cat(" [internal]");
258      }
259
260      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);
261   }
262   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
263   item_append("Reset",  NULL, 0, (void *)1);
264}
265
266ui_menu_slot_devices::~ui_menu_slot_devices()
267{
268}
269
270/*-------------------------------------------------
271    ui_menu_slot_devices - menu that
272-------------------------------------------------*/
273
274void ui_menu_slot_devices::handle()
275{
276   /* process the menu */
277   const ui_menu_event *menu_event = process(0);
278
279   if (menu_event != NULL && menu_event->itemref != NULL)
280   {
281      if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT)
282         machine().schedule_hard_reset();
283      else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
284      {
285         device_slot_interface *slot = (device_slot_interface *)menu_event->itemref;
286         const char *val = (menu_event->iptkey == IPT_UI_LEFT) ? slot_get_prev(slot) : slot_get_next(slot);
287         set_slot_device(slot, val);
288         reset(UI_MENU_RESET_REMEMBER_REF);
289      }
290   }
291}
292
293/*-------------------------------------------------
29494    ui_menu_bios_selection - populates the main
29595    bios selection menu
29696-------------------------------------------------*/
r242908r242909
426226   }
427227}
428228
429/*-------------------------------------------------
430    menu_input_groups_populate - populate the
431    input groups menu
432-------------------------------------------------*/
433229
434ui_menu_input_groups::ui_menu_input_groups(running_machine &machine, render_container *container) : ui_menu(machine, container)
435{
436}
437
438void ui_menu_input_groups::populate()
439{
440   int player;
441
442   /* build up the menu */
443   item_append("User Interface", NULL, 0, (void *)(IPG_UI + 1));
444   for (player = 0; player < MAX_PLAYERS; player++)
445   {
446      char buffer[40];
447      sprintf(buffer, "Player %d Controls", player + 1);
448      item_append(buffer, NULL, 0, (void *)(FPTR)(IPG_PLAYER1 + player + 1));
449   }
450   item_append("Other Controls", NULL, 0, (void *)(FPTR)(IPG_OTHER + 1));
451}
452
453ui_menu_input_groups::~ui_menu_input_groups()
454{
455}
456
457230/*-------------------------------------------------
458    menu_input_groups - handle the input groups
459    menu
460-------------------------------------------------*/
461
462void ui_menu_input_groups::handle()
463{
464   /* process the menu */
465   const ui_menu_event *menu_event = process(0);
466   if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT)
467      ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_general(machine(), container, int((long long)(menu_event->itemref)-1))));
468}
469
470
471
472/*-------------------------------------------------
473    menu_input_general - handle the general
474    input menu
475-------------------------------------------------*/
476
477ui_menu_input_general::ui_menu_input_general(running_machine &machine, render_container *container, int _group) : ui_menu_input(machine, container)
478{
479   group = _group;
480}
481
482void ui_menu_input_general::populate()
483{
484   input_item_data *itemlist = NULL;
485   int suborder[SEQ_TYPE_TOTAL];
486   astring tempstring;
487   int sortorder = 1;
488
489   /* create a mini lookup table for sort order based on sequence type */
490   suborder[SEQ_TYPE_STANDARD] = 0;
491   suborder[SEQ_TYPE_DECREMENT] = 1;
492   suborder[SEQ_TYPE_INCREMENT] = 2;
493
494   /* iterate over the input ports and add menu items */
495   for (input_type_entry *entry = machine().ioport().first_type(); entry != NULL; entry = entry->next())
496
497      /* add if we match the group and we have a valid name */
498      if (entry->group() == group && entry->name() != NULL && entry->name()[0] != 0)
499      {
500         input_seq_type seqtype;
501
502         /* loop over all sequence types */
503         sortorder++;
504         for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++)
505         {
506            /* build an entry for the standard sequence */
507            input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item));
508            memset(item, 0, sizeof(*item));
509            item->ref = entry;
510            if(pollingitem && pollingref == entry && pollingseq == seqtype)
511               pollingitem = item;
512            item->seqtype = seqtype;
513            item->seq = machine().ioport().type_seq(entry->type(), entry->player(), seqtype);
514            item->defseq = &entry->defseq(seqtype);
515            item->sortorder = sortorder * 4 + suborder[seqtype];
516            item->type = ioport_manager::type_is_analog(entry->type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL;
517            item->name = entry->name();
518            item->owner_name = NULL;
519            item->next = itemlist;
520            itemlist = item;
521
522            /* stop after one, unless we're analog */
523            if (item->type == INPUT_TYPE_DIGITAL)
524               break;
525         }
526      }
527
528   /* sort and populate the menu in a standard fashion */
529   populate_and_sort(itemlist);
530}
531
532ui_menu_input_general::~ui_menu_input_general()
533{
534}
535
536/*-------------------------------------------------
537    menu_input_specific - handle the game-specific
538    input menu
539-------------------------------------------------*/
540
541ui_menu_input_specific::ui_menu_input_specific(running_machine &machine, render_container *container) : ui_menu_input(machine, container)
542{
543}
544
545void ui_menu_input_specific::populate()
546{
547   input_item_data *itemlist = NULL;
548   ioport_field *field;
549   ioport_port *port;
550   int suborder[SEQ_TYPE_TOTAL];
551   astring tempstring;
552
553   /* create a mini lookup table for sort order based on sequence type */
554   suborder[SEQ_TYPE_STANDARD] = 0;
555   suborder[SEQ_TYPE_DECREMENT] = 1;
556   suborder[SEQ_TYPE_INCREMENT] = 2;
557
558   /* iterate over the input ports and add menu items */
559   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
560      for (field = port->first_field(); field != NULL; field = field->next())
561      {
562         const char *name = field->name();
563
564         /* add if we match the group and we have a valid name */
565         if (name != NULL && field->enabled() &&
566            ((field->type() == IPT_OTHER && field->name() != NULL) || machine().ioport().type_group(field->type(), field->player()) != IPG_INVALID))
567         {
568            input_seq_type seqtype;
569            UINT32 sortorder;
570
571            /* determine the sorting order */
572            if (field->type() >= IPT_START1 && field->type() < IPT_ANALOG_LAST)
573            {
574               sortorder = (field->type() << 2) | (field->player() << 12);
575               if (strcmp(field->device().tag(), ":"))
576                  sortorder |= 0x10000;
577            }
578            else
579               sortorder = field->type() | 0xf000;
580
581            /* loop over all sequence types */
582            for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++)
583            {
584               /* build an entry for the standard sequence */
585               input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item));
586               memset(item, 0, sizeof(*item));
587               item->ref = field;
588               item->seqtype = seqtype;
589               if(pollingitem && pollingref == field && pollingseq == seqtype)
590                  pollingitem = item;
591               item->seq = field->seq(seqtype);
592               item->defseq = &field->defseq(seqtype);
593               item->sortorder = sortorder + suborder[seqtype];
594               item->type = field->is_analog() ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL;
595               item->name = name;
596               item->owner_name = field->device().tag();
597               item->next = itemlist;
598               itemlist = item;
599
600               /* stop after one, unless we're analog */
601               if (item->type == INPUT_TYPE_DIGITAL)
602                  break;
603            }
604         }
605      }
606
607   /* sort and populate the menu in a standard fashion */
608   populate_and_sort(itemlist);
609}
610
611ui_menu_input_specific::~ui_menu_input_specific()
612{
613}
614
615/*-------------------------------------------------
616    menu_input - display a menu for inputs
617-------------------------------------------------*/
618ui_menu_input::ui_menu_input(running_machine &machine, render_container *container) : ui_menu(machine, container)
619{
620   pollingitem = 0;
621   pollingref = 0;
622   pollingseq = SEQ_TYPE_STANDARD;
623}
624
625ui_menu_input::~ui_menu_input()
626{
627}
628
629/*-------------------------------------------------
630    toggle_none_default - toggle between "NONE"
631    and the default item
632-------------------------------------------------*/
633
634void ui_menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq)
635{
636   /* if we used to be "none", toggle to the default value */
637   if (original_seq.length() == 0)
638      selected_seq = selected_defseq;
639
640   /* otherwise, toggle to "none" */
641   else
642      selected_seq.reset();
643}
644
645void ui_menu_input::handle()
646{
647   input_item_data *seqchangeditem = NULL;
648   const ui_menu_event *menu_event;
649   int invalidate = false;
650
651   /* process the menu */
652   menu_event = process((pollingitem != NULL) ? UI_MENU_PROCESS_NOKEYS : 0);
653
654   /* if we are polling, handle as a special case */
655   if (pollingitem != NULL)
656   {
657      input_item_data *item = pollingitem;
658      input_seq newseq;
659
660      /* if UI_CANCEL is pressed, abort */
661      if (ui_input_pressed(machine(), IPT_UI_CANCEL))
662      {
663         pollingitem = NULL;
664         record_next = false;
665         toggle_none_default(item->seq, starting_seq, *item->defseq);
666         seqchangeditem = item;
667      }
668
669      /* poll again; if finished, update the sequence */
670      if (machine().input().seq_poll())
671      {
672         pollingitem = NULL;
673         record_next = true;
674         item->seq = machine().input().seq_poll_final();
675         seqchangeditem = item;
676      }
677   }
678
679   /* otherwise, handle the events */
680   else if (menu_event != NULL && menu_event->itemref != NULL)
681   {
682      input_item_data *item = (input_item_data *)menu_event->itemref;
683      switch (menu_event->iptkey)
684      {
685         /* an item was selected: begin polling */
686         case IPT_UI_SELECT:
687            pollingitem = item;
688            last_sortorder = item->sortorder;
689            starting_seq = item->seq;
690            machine().input().seq_poll_start((item->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &item->seq : NULL);
691            invalidate = true;
692            break;
693
694         /* if the clear key was pressed, reset the selected item */
695         case IPT_UI_CLEAR:
696            toggle_none_default(item->seq, item->seq, *item->defseq);
697            record_next = false;
698            seqchangeditem = item;
699            break;
700      }
701
702      /* if the selection changed, reset the "record next" flag */
703      if (item->sortorder != last_sortorder)
704         record_next = false;
705      last_sortorder = item->sortorder;
706   }
707
708   /* if the sequence changed, update it */
709   if (seqchangeditem != NULL)
710   {
711      update_input(seqchangeditem);
712
713      /* invalidate the menu to force an update */
714      invalidate = true;
715   }
716
717   /* if the menu is invalidated, clear it now */
718   if (invalidate)
719   {
720      pollingref = NULL;
721      if (pollingitem != NULL)
722      {
723         pollingref = pollingitem->ref;
724         pollingseq = pollingitem->seqtype;
725      }
726      reset(UI_MENU_RESET_REMEMBER_POSITION);
727   }
728}
729
730void ui_menu_input_general::update_input(struct input_item_data *seqchangeditem)
731{
732   const input_type_entry *entry = (const input_type_entry *)seqchangeditem->ref;
733   machine().ioport().set_type_seq(entry->type(), entry->player(), seqchangeditem->seqtype, seqchangeditem->seq);
734}
735
736void ui_menu_input_specific::update_input(struct input_item_data *seqchangeditem)
737{
738   ioport_field::user_settings settings;
739
740   ((ioport_field *)seqchangeditem->ref)->get_user_settings(settings);
741   settings.seq[seqchangeditem->seqtype] = seqchangeditem->seq;
742   ((ioport_field *)seqchangeditem->ref)->set_user_settings(settings);
743}
744
745
746/*-------------------------------------------------
747    menu_input_compare_items - compare two
748    items for quicksort
749-------------------------------------------------*/
750
751int ui_menu_input::compare_items(const void *i1, const void *i2)
752{
753   const input_item_data * const *data1 = (const input_item_data * const *)i1;
754   const input_item_data * const *data2 = (const input_item_data * const *)i2;
755   if ((*data1)->sortorder < (*data2)->sortorder)
756      return -1;
757   if ((*data1)->sortorder > (*data2)->sortorder)
758      return 1;
759   return 0;
760}
761
762
763/*-------------------------------------------------
764    menu_input_populate_and_sort - take a list
765    of input_item_data objects and build up the
766    menu from them
767-------------------------------------------------*/
768
769void ui_menu_input::populate_and_sort(input_item_data *itemlist)
770{
771   const char *nameformat[INPUT_TYPE_TOTAL] = { 0 };
772   input_item_data **itemarray, *item;
773   int numitems = 0, curitem;
774   astring text;
775   astring subtext;
776   astring prev_owner;
777   bool first_entry = true;
778
779   /* create a mini lookup table for name format based on type */
780   nameformat[INPUT_TYPE_DIGITAL] = "%s";
781   nameformat[INPUT_TYPE_ANALOG] = "%s Analog";
782   nameformat[INPUT_TYPE_ANALOG_INC] = "%s Analog Inc";
783   nameformat[INPUT_TYPE_ANALOG_DEC] = "%s Analog Dec";
784
785   /* first count the number of items */
786   for (item = itemlist; item != NULL; item = item->next)
787      numitems++;
788
789   /* now allocate an array of items and fill it up */
790   itemarray = (input_item_data **)m_pool_alloc(sizeof(*itemarray) * numitems);
791   for (item = itemlist, curitem = 0; item != NULL; item = item->next)
792      itemarray[curitem++] = item;
793
794   /* sort it */
795   qsort(itemarray, numitems, sizeof(*itemarray), compare_items);
796
797   /* build the menu */
798   for (curitem = 0; curitem < numitems; curitem++)
799   {
800      UINT32 flags = 0;
801
802      /* generate the name of the item itself, based off the base name and the type */
803      item = itemarray[curitem];
804      assert(nameformat[item->type] != NULL);
805
806      if (strcmp(item->owner_name, prev_owner.cstr()) != 0)
807      {
808         if (first_entry)
809            first_entry = false;
810         else
811            item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
812         text.printf("[root%s]", item->owner_name);
813         item_append(text, NULL, 0, NULL);
814         prev_owner.cpy(item->owner_name);
815      }
816
817      text.printf(nameformat[item->type], item->name);
818
819      /* if we're polling this item, use some spaces with left/right arrows */
820      if (pollingref == item->ref)
821      {
822         subtext.cpy("   ");
823         flags |= MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW;
824      }
825
826      /* otherwise, generate the sequence name and invert it if different from the default */
827      else
828      {
829         machine().input().seq_name(subtext, item->seq);
830         flags |= (item->seq != *item->defseq) ? MENU_FLAG_INVERT : 0;
831      }
832
833      /* add the item */
834      item_append(text, subtext, flags, item);
835   }
836}
837
838
839/*-------------------------------------------------
840    menu_settings_dip_switches - handle the DIP
841    switches menu
842-------------------------------------------------*/
843
844ui_menu_settings_dip_switches::ui_menu_settings_dip_switches(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_DIPSWITCH)
845{
846}
847
848ui_menu_settings_dip_switches::~ui_menu_settings_dip_switches()
849{
850}
851
852/*-------------------------------------------------
853    menu_settings_driver_config - handle the
854    driver config menu
855-------------------------------------------------*/
856
857ui_menu_settings_driver_config::ui_menu_settings_driver_config(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_CONFIG)
858{
859}
860
861ui_menu_settings_driver_config::~ui_menu_settings_driver_config()
862{
863}
864
865/*-------------------------------------------------
866    menu_settings_common - handle one of the
867    switches menus
868-------------------------------------------------*/
869
870void ui_menu_settings::handle()
871{
872   // process the menu
873   const ui_menu_event *menu_event = process(0);
874
875   // handle events
876   if (menu_event != NULL && menu_event->itemref != NULL)
877   {
878      // reset
879      if ((FPTR)menu_event->itemref == 1)
880      {
881         if (menu_event->iptkey == IPT_UI_SELECT)
882            machine().schedule_hard_reset();
883      }
884      // actual settings
885      else
886      {
887         ioport_field *field = (ioport_field *)menu_event->itemref;
888         ioport_field::user_settings settings;
889         int changed = false;
890         
891         switch (menu_event->iptkey)
892         {
893            /* if selected, reset to default value */
894            case IPT_UI_SELECT:
895               field->get_user_settings(settings);
896               settings.value = field->defvalue();
897               field->set_user_settings(settings);
898               changed = true;
899               break;
900               
901            /* left goes to previous setting */
902            case IPT_UI_LEFT:
903               field->select_previous_setting();
904               changed = true;
905               break;
906               
907            /* right goes to next setting */
908            case IPT_UI_RIGHT:
909               field->select_next_setting();
910               changed = true;
911               break;
912         }
913         
914         /* if anything changed, rebuild the menu, trying to stay on the same field */
915         if (changed)
916            reset(UI_MENU_RESET_REMEMBER_REF);
917      }
918   }
919}
920
921
922/*-------------------------------------------------
923    menu_settings_populate - populate one of the
924    switches menus
925-------------------------------------------------*/
926
927ui_menu_settings::ui_menu_settings(running_machine &machine, render_container *container, UINT32 _type) : ui_menu(machine, container)
928{
929   type = _type;
930}
931
932void ui_menu_settings::populate()
933{
934   ioport_field *field;
935   ioport_port *port;
936   dip_descriptor **diplist_tailptr;
937   astring prev_owner;
938   bool first_entry = true;
939
940   /* reset the dip switch tracking */
941   dipcount = 0;
942   diplist = NULL;
943   diplist_tailptr = &diplist;
944
945   /* loop over input ports and set up the current values */
946   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
947      for (field = port->first_field(); field != NULL; field = field->next())
948         if (field->type() == type && field->enabled())
949         {
950            UINT32 flags = 0;
951            astring name;
952
953            /* set the left/right flags appropriately */
954            if (field->has_previous_setting())
955               flags |= MENU_FLAG_LEFT_ARROW;
956            if (field->has_next_setting())
957               flags |= MENU_FLAG_RIGHT_ARROW;
958
959            /* add the menu item */
960            if (strcmp(field->device().tag(), prev_owner.cstr()) != 0)
961            {
962               if (first_entry)
963                  first_entry = false;
964               else
965                  item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
966               name.printf("[root%s]", field->device().tag());
967               item_append(name, NULL, 0, NULL);
968               prev_owner.cpy(field->device().tag());
969            }
970
971            name.cpy(field->name());
972
973            item_append(name, field->setting_name(), flags, (void *)field);
974
975            /* for DIP switches, build up the model */
976            if (type == IPT_DIPSWITCH && field->first_diplocation() != NULL)
977            {
978               const ioport_diplocation *diploc;
979               ioport_field::user_settings settings;
980               UINT32 accummask = field->mask();
981
982               /* get current settings */
983               field->get_user_settings(settings);
984
985               /* iterate over each bit in the field */
986               for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next())
987               {
988                  UINT32 mask = accummask & ~(accummask - 1);
989                  dip_descriptor *dip;
990
991                  /* find the matching switch name */
992                  for (dip = diplist; dip != NULL; dip = dip->next)
993                     if (strcmp(dip->name, diploc->name()) == 0)
994                        break;
995
996                  /* allocate new if none */
997                  if (dip == NULL)
998                  {
999                     dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip));
1000                     dip->next = NULL;
1001                     dip->name = diploc->name();
1002                     dip->mask = dip->state = 0;
1003                     *diplist_tailptr = dip;
1004                     diplist_tailptr = &dip->next;
1005                     dipcount++;
1006                  }
1007
1008                  /* apply the bits */
1009                  dip->mask |= 1 << (diploc->number() - 1);
1010                  if (((settings.value & mask) != 0 && !diploc->inverted()) || ((settings.value & mask) == 0 && diploc->inverted()))
1011                     dip->state |= 1 << (diploc->number() - 1);
1012
1013                  /* clear the relevant bit in the accumulated mask */
1014                  accummask &= ~mask;
1015               }
1016            }
1017         }
1018   if (type == IPT_DIPSWITCH)
1019      custombottom = dipcount ? dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING : 0;
1020   
1021   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
1022   item_append("Reset",  NULL, 0, (void *)1);
1023}
1024
1025ui_menu_settings::~ui_menu_settings()
1026{
1027}
1028
1029/*-------------------------------------------------
1030    menu_settings_custom_render - perform our special
1031    rendering
1032-------------------------------------------------*/
1033
1034void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2)
1035{
1036   // catch if no diploc has to be drawn
1037   if (bottom == 0)
1038      return;
1039
1040   // add borders
1041   y1 = y2 + UI_BOX_TB_BORDER;
1042   y2 = y1 + bottom;
1043
1044   // draw extra menu area
1045   machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
1046   y1 += (float)DIP_SWITCH_SPACING;
1047
1048   // iterate over DIP switches
1049   for (dip_descriptor *dip = diplist; dip != NULL; dip = dip->next)
1050   {
1051      const ioport_diplocation *diploc;
1052      UINT32 selectedmask = 0;
1053     
1054      // determine the mask of selected bits
1055      if ((FPTR)selectedref != 1)
1056      {
1057         ioport_field *field = (ioport_field *)selectedref;
1058         
1059         if (field != NULL && field->first_diplocation() != NULL)
1060            for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next())
1061               if (strcmp(dip->name, diploc->name()) == 0)
1062                  selectedmask |= 1 << (diploc->number() - 1);
1063      }
1064     
1065      // draw one switch
1066      custom_render_one(x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask);
1067      y1 += (float)(DIP_SWITCH_SPACING + DIP_SWITCH_HEIGHT);
1068   }
1069}
1070
1071
1072/*-------------------------------------------------
1073    menu_settings_custom_render_one - draw a single
1074    DIP switch
1075-------------------------------------------------*/
1076
1077void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask)
1078{
1079   float switch_field_width = SINGLE_TOGGLE_SWITCH_FIELD_WIDTH * container->manager().ui_aspect();
1080   float switch_width = SINGLE_TOGGLE_SWITCH_WIDTH * container->manager().ui_aspect();
1081   int numtoggles, toggle;
1082   float switch_toggle_gap;
1083   float y1_off, y1_on;
1084
1085   /* determine the number of toggles in the DIP */
1086   numtoggles = 32 - count_leading_zeros(dip->mask);
1087
1088   /* center based on the number of switches */
1089   x1 += (x2 - x1 - numtoggles * switch_field_width) / 2;
1090
1091   /* draw the dip switch name */
1092   machine().ui().draw_text_full(  container,
1093                  dip->name,
1094                  0,
1095                  y1 + (DIP_SWITCH_HEIGHT - UI_TARGET_FONT_HEIGHT) / 2,
1096                  x1 - machine().ui().get_string_width(" "),
1097                  JUSTIFY_RIGHT,
1098                  WRAP_NEVER,
1099                  DRAW_NORMAL,
1100                  UI_TEXT_COLOR,
1101                  PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA),
1102                  NULL ,
1103                  NULL);
1104
1105   /* compute top and bottom for on and off positions */
1106   switch_toggle_gap = ((DIP_SWITCH_HEIGHT/2) - SINGLE_TOGGLE_SWITCH_HEIGHT)/2;
1107   y1_off = y1 + UI_LINE_WIDTH + switch_toggle_gap;
1108   y1_on = y1 + DIP_SWITCH_HEIGHT/2 + switch_toggle_gap;
1109
1110   /* iterate over toggles */
1111   for (toggle = 0; toggle < numtoggles; toggle++)
1112   {
1113      float innerx1;
1114
1115      /* first outline the switch */
1116      machine().ui().draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR);
1117
1118      /* compute x1/x2 for the inner filled in switch */
1119      innerx1 = x1 + (switch_field_width - switch_width) / 2;
1120
1121      /* see if the switch is actually used */
1122      if (dip->mask & (1 << toggle))
1123      {
1124         float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off;
1125         container->add_rect(innerx1, innery1, innerx1 + switch_width, innery1 + SINGLE_TOGGLE_SWITCH_HEIGHT,
1126                        (selectedmask & (1 << toggle)) ? UI_DIPSW_COLOR : UI_TEXT_COLOR,
1127                        PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
1128      }
1129      else
1130      {
1131         container->add_rect(innerx1, y1_off, innerx1 + switch_width, y1_on + SINGLE_TOGGLE_SWITCH_HEIGHT,
1132                        UI_UNAVAILABLE_COLOR,
1133                        PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
1134      }
1135
1136      /* advance to the next switch */
1137      x1 += switch_field_width;
1138   }
1139}
1140
1141
1142/*-------------------------------------------------
1143    menu_analog - handle the analog settings menu
1144-------------------------------------------------*/
1145
1146void ui_menu_analog::handle()
1147{
1148   /* process the menu */
1149   const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT);
1150
1151   /* handle events */
1152   if (menu_event != NULL && menu_event->itemref != NULL)
1153   {
1154      analog_item_data *data = (analog_item_data *)menu_event->itemref;
1155      int newval = data->cur;
1156
1157      switch (menu_event->iptkey)
1158      {
1159         /* if selected, reset to default value */
1160         case IPT_UI_SELECT:
1161            newval = data->defvalue;
1162            break;
1163
1164         /* left decrements */
1165         case IPT_UI_LEFT:
1166            newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1;
1167            break;
1168
1169         /* right increments */
1170         case IPT_UI_RIGHT:
1171            newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1;
1172            break;
1173      }
1174
1175      /* clamp to range */
1176      if (newval < data->min)
1177         newval = data->min;
1178      if (newval > data->max)
1179         newval = data->max;
1180
1181      /* if things changed, update */
1182      if (newval != data->cur)
1183      {
1184         ioport_field::user_settings settings;
1185
1186         /* get the settings and set the new value */
1187         data->field->get_user_settings(settings);
1188         switch (data->type)
1189         {
1190            case ANALOG_ITEM_KEYSPEED:      settings.delta = newval;        break;
1191            case ANALOG_ITEM_CENTERSPEED:   settings.centerdelta = newval;  break;
1192            case ANALOG_ITEM_REVERSE:       settings.reverse = newval;      break;
1193            case ANALOG_ITEM_SENSITIVITY:   settings.sensitivity = newval;  break;
1194         }
1195         data->field->set_user_settings(settings);
1196
1197         /* rebuild the menu */
1198         reset(UI_MENU_RESET_REMEMBER_POSITION);
1199      }
1200   }
1201}
1202
1203
1204/*-------------------------------------------------
1205    menu_analog_populate - populate the analog
1206    settings menu
1207-------------------------------------------------*/
1208
1209ui_menu_analog::ui_menu_analog(running_machine &machine, render_container *container) : ui_menu(machine, container)
1210{
1211}
1212
1213void ui_menu_analog::populate()
1214{
1215   ioport_field *field;
1216   ioport_port *port;
1217   astring text;
1218   astring subtext;
1219   astring prev_owner;
1220   bool first_entry = true;
1221
1222   /* loop over input ports and add the items */
1223   for (port = machine().ioport().first_port(); port != NULL; port = port->next())
1224      for (field = port->first_field(); field != NULL; field = field->next())
1225         if (field->is_analog() && field->enabled())
1226         {
1227            ioport_field::user_settings settings;
1228            int use_autocenter = false;
1229            int type;
1230
1231            /* based on the type, determine if we enable autocenter */
1232            switch (field->type())
1233            {
1234               case IPT_POSITIONAL:
1235               case IPT_POSITIONAL_V:
1236                  if (field->analog_wraps())
1237                     break;
1238
1239               case IPT_AD_STICK_X:
1240               case IPT_AD_STICK_Y:
1241               case IPT_AD_STICK_Z:
1242               case IPT_PADDLE:
1243               case IPT_PADDLE_V:
1244               case IPT_PEDAL:
1245               case IPT_PEDAL2:
1246               case IPT_PEDAL3:
1247                  use_autocenter = true;
1248                  break;
1249
1250               default:
1251                  break;
1252            }
1253
1254            /* get the user settings */
1255            field->get_user_settings(settings);
1256
1257            /* iterate over types */
1258            for (type = 0; type < ANALOG_ITEM_COUNT; type++)
1259               if (type != ANALOG_ITEM_CENTERSPEED || use_autocenter)
1260               {
1261                  analog_item_data *data;
1262                  UINT32 flags = 0;
1263                  astring name;
1264                  if (strcmp(field->device().tag(), prev_owner.cstr()) != 0)
1265                  {
1266                     if (first_entry)
1267                        first_entry = false;
1268                     else
1269                        item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
1270                     name.printf("[root%s]", field->device().tag());
1271                     item_append(name, NULL, 0, NULL);
1272                     prev_owner.cpy(field->device().tag());
1273                  }
1274
1275                  name.cpy(field->name());
1276                 
1277                  /* allocate a data item for tracking what this menu item refers to */
1278                  data = (analog_item_data *)m_pool_alloc(sizeof(*data));
1279                  data->field = field;
1280                  data->type = type;
1281
1282                  /* determine the properties of this item */
1283                  switch (type)
1284                  {
1285                     default:
1286                     case ANALOG_ITEM_KEYSPEED:
1287                        text.printf("%s Digital Speed", name.cstr());
1288                        subtext.printf("%d", settings.delta);
1289                        data->min = 0;
1290                        data->max = 255;
1291                        data->cur = settings.delta;
1292                        data->defvalue = field->delta();
1293                        break;
1294
1295                     case ANALOG_ITEM_CENTERSPEED:
1296                        text.printf("%s Autocenter Speed", name.cstr());
1297                        subtext.printf("%d", settings.centerdelta);
1298                        data->min = 0;
1299                        data->max = 255;
1300                        data->cur = settings.centerdelta;
1301                        data->defvalue = field->centerdelta();
1302                        break;
1303
1304                     case ANALOG_ITEM_REVERSE:
1305                        text.printf("%s Reverse", name.cstr());
1306                        subtext.cpy(settings.reverse ? "On" : "Off");
1307                        data->min = 0;
1308                        data->max = 1;
1309                        data->cur = settings.reverse;
1310                        data->defvalue = field->analog_reverse();
1311                        break;
1312
1313                     case ANALOG_ITEM_SENSITIVITY:
1314                        text.printf("%s Sensitivity", name.cstr());
1315                        subtext.printf("%d", settings.sensitivity);
1316                        data->min = 1;
1317                        data->max = 255;
1318                        data->cur = settings.sensitivity;
1319                        data->defvalue = field->sensitivity();
1320                        break;
1321                  }
1322
1323                  /* put on arrows */
1324                  if (data->cur > data->min)
1325                     flags |= MENU_FLAG_LEFT_ARROW;
1326                  if (data->cur < data->max)
1327                     flags |= MENU_FLAG_RIGHT_ARROW;
1328
1329                  /* append a menu item */
1330                  item_append(text, subtext, flags, data);
1331               }
1332         }
1333}
1334
1335ui_menu_analog::~ui_menu_analog()
1336{
1337}
1338
1339/*-------------------------------------------------
1340231    menu_bookkeeping - handle the bookkeeping
1341232    information menu
1342233-------------------------------------------------*/
trunk/src/emu/ui/miscmenu.h
r242908r242909
2525   virtual void handle();
2626};
2727
28class ui_menu_slot_devices : public ui_menu {
29public:
30   ui_menu_slot_devices(running_machine &machine, render_container *container);
31   virtual ~ui_menu_slot_devices();
32   virtual void populate();
33   virtual void handle();
34
35private:
36   device_slot_option *slot_get_current_option(device_slot_interface *slot);
37   int slot_get_current_index(device_slot_interface *slot);
38   int slot_get_length(device_slot_interface *slot);
39   const char *slot_get_next(device_slot_interface *slot);
40   const char *slot_get_prev(device_slot_interface *slot);
41   const char *slot_get_option(device_slot_interface *slot, int index);
42   void set_slot_device(device_slot_interface *slot, const char *val);
43};
44
4528class ui_menu_network_devices : public ui_menu {
4629public:
4730   ui_menu_network_devices(running_machine &machine, render_container *container);
r242908r242909
5033   virtual void handle();
5134};
5235
53class ui_menu_input_groups : public ui_menu {
54public:
55   ui_menu_input_groups(running_machine &machine, render_container *container);
56   virtual ~ui_menu_input_groups();
57   virtual void populate();
58   virtual void handle();
59};
60
61class ui_menu_input : public ui_menu {
62public:
63   ui_menu_input(running_machine &machine, render_container *container);
64   virtual ~ui_menu_input();
65   virtual void handle();
66
67protected:
68   enum {
69      INPUT_TYPE_DIGITAL = 0,
70      INPUT_TYPE_ANALOG = 1,
71      INPUT_TYPE_ANALOG_DEC = INPUT_TYPE_ANALOG + SEQ_TYPE_DECREMENT,
72      INPUT_TYPE_ANALOG_INC = INPUT_TYPE_ANALOG + SEQ_TYPE_INCREMENT,
73      INPUT_TYPE_TOTAL = INPUT_TYPE_ANALOG + SEQ_TYPE_TOTAL
74   };
75
76   /* internal input menu item data */
77   struct input_item_data {
78      input_item_data *   next;               /* pointer to next item in the list */
79      const void *        ref;                /* reference to type description for global inputs or field for game inputs */
80      input_seq_type      seqtype;            /* sequence type */
81      input_seq           seq;                /* copy of the live sequence */
82      const input_seq *   defseq;             /* pointer to the default sequence */
83      const char *        name;               /* pointer to the base name of the item */
84      const char *        owner_name;         /* pointer to the name of the owner of the item */
85      UINT32              sortorder;          /* sorting information */
86      UINT8               type;               /* type of port */
87   };
88
89   void populate_and_sort(struct input_item_data *itemlist);
90   virtual void update_input(struct input_item_data *seqchangeditem) = 0;
91   void toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq);
92
93protected:
94   const void *        pollingref;
95   input_seq_type      pollingseq;
96   input_item_data *   pollingitem;
97
98private:
99   UINT16              last_sortorder;
100   bool                record_next;
101   input_seq           starting_seq;
102
103   static int compare_items(const void *i1, const void *i2);
104};
105
106class ui_menu_input_general : public ui_menu_input {
107public:
108   ui_menu_input_general(running_machine &machine, render_container *container, int group);
109   virtual ~ui_menu_input_general();
110   virtual void populate();
111
112protected:
113   int group;
114   virtual void update_input(struct input_item_data *seqchangeditem);
115};
116
117class ui_menu_input_specific : public ui_menu_input {
118public:
119   ui_menu_input_specific(running_machine &machine, render_container *container);
120   virtual ~ui_menu_input_specific();
121   virtual void populate();
122
123protected:
124   virtual void update_input(struct input_item_data *seqchangeditem);
125};
126
127class ui_menu_settings : public ui_menu {
128public:
129   ui_menu_settings(running_machine &machine, render_container *container, UINT32 type);
130   virtual ~ui_menu_settings();
131   virtual void populate();
132   virtual void handle();
133
134protected:
135   /* DIP switch descriptor */
136   struct dip_descriptor {
137      dip_descriptor *    next;
138      const char *        name;
139      UINT32              mask;
140      UINT32              state;
141   };
142
143   dip_descriptor *    diplist;
144   int dipcount;
145   int type;
146};
147
148class ui_menu_settings_dip_switches : public ui_menu_settings {
149public:
150   ui_menu_settings_dip_switches(running_machine &machine, render_container *container);
151   virtual ~ui_menu_settings_dip_switches();
152
153   virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
154private:
155   void custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask);
156};
157
158class ui_menu_settings_driver_config : public ui_menu_settings {
159public:
160   ui_menu_settings_driver_config(running_machine &machine, render_container *container);
161   virtual ~ui_menu_settings_driver_config();
162};
163
164class ui_menu_analog : public ui_menu {
165public:
166   ui_menu_analog(running_machine &machine, render_container *container);
167   virtual ~ui_menu_analog();
168   virtual void populate();
169   virtual void handle();
170
171private:
172   enum {
173      ANALOG_ITEM_KEYSPEED = 0,
174      ANALOG_ITEM_CENTERSPEED,
175      ANALOG_ITEM_REVERSE,
176      ANALOG_ITEM_SENSITIVITY,
177      ANALOG_ITEM_COUNT
178   };
179
180   /* internal analog menu item data */
181   struct analog_item_data {
182      ioport_field *field;
183      int                 type;
184      int                 min, max;
185      int                 cur;
186      int                 defvalue;
187   };
188};
189
19036class ui_menu_bookkeeping : public ui_menu {
19137public:
19238   ui_menu_bookkeeping(running_machine &machine, render_container *container);
trunk/src/emu/ui/selgame.c
r242908r242909
1717#include "cheat.h"
1818#include "uiinput.h"
1919#include "ui/selgame.h"
20#include "ui/inputmap.h"
2021#include "ui/miscmenu.h"
2122#include "audit.h"
2223#include "crsshair.h"
trunk/src/emu/ui/slotopt.c
r0r242909
1/*********************************************************************
2
3    ui/slotopt.c
4
5    Internal menu for the slot options.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10*********************************************************************/
11
12#include "emu.h"
13
14#include "ui/ui.h"
15#include "ui/slotopt.h"
16
17
18/*-------------------------------------------------
19    ui_slot_get_current_option - returns
20-------------------------------------------------*/
21device_slot_option *ui_menu_slot_devices::slot_get_current_option(device_slot_interface *slot)
22{
23   const char *current;
24   if (slot->fixed())
25   {
26      current = slot->default_option();
27   }
28   else
29   {
30      astring temp;
31      current = machine().options().main_value(temp, slot->device().tag() + 1);
32   }
33
34   return slot->option(current);
35}
36
37/*-------------------------------------------------
38    ui_slot_get_current_index - returns
39-------------------------------------------------*/
40int ui_menu_slot_devices::slot_get_current_index(device_slot_interface *slot)
41{
42   const device_slot_option *current = slot_get_current_option(slot);
43
44   if (current != NULL)
45   {
46      int val = 0;
47      for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next())
48      {
49         if (option == current)
50            return val;
51
52         if (option->selectable())
53            val++;
54      }
55   }
56
57   return -1;
58}
59
60/*-------------------------------------------------
61    ui_slot_get_length - returns
62-------------------------------------------------*/
63int ui_menu_slot_devices::slot_get_length(device_slot_interface *slot)
64{
65   int val = 0;
66   for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next())
67      if (option->selectable())
68         val++;
69
70   return val;
71}
72
73/*-------------------------------------------------
74    ui_slot_get_next - returns
75-------------------------------------------------*/
76const char *ui_menu_slot_devices::slot_get_next(device_slot_interface *slot)
77{
78   int idx = slot_get_current_index(slot);
79   if (idx < 0)
80      idx = 0;
81   else
82      idx++;
83
84   if (idx >= slot_get_length(slot))
85      return "";
86
87   return slot_get_option(slot, idx);
88}
89
90/*-------------------------------------------------
91    ui_slot_get_prev - returns
92-------------------------------------------------*/
93const char *ui_menu_slot_devices::slot_get_prev(device_slot_interface *slot)
94{
95   int idx = slot_get_current_index(slot);
96   if (idx < 0)
97      idx = slot_get_length(slot) - 1;
98   else
99      idx--;
100
101   if (idx < 0)
102      return "";
103
104   return slot_get_option(slot, idx);
105}
106
107/*-------------------------------------------------
108    ui_slot_get_option - returns
109-------------------------------------------------*/
110const char *ui_menu_slot_devices::slot_get_option(device_slot_interface *slot, int index)
111{
112   if (index >= 0)
113   {
114      int val = 0;
115      for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next())
116      {
117         if (val == index)
118            return option->name();
119
120         if (option->selectable())
121            val++;
122      }
123   }
124
125   return "";
126}
127
128
129/*-------------------------------------------------
130    ui_set_use_natural_keyboard - specifies
131    whether the natural keyboard is active
132-------------------------------------------------*/
133
134void ui_menu_slot_devices::set_slot_device(device_slot_interface *slot, const char *val)
135{
136   astring error;
137   machine().options().set_value(slot->device().tag()+1, val, OPTION_PRIORITY_CMDLINE, error);
138   assert(!error);
139}
140
141/*-------------------------------------------------
142    menu_slot_devices_populate - populates the main
143    slot device menu
144-------------------------------------------------*/
145
146ui_menu_slot_devices::ui_menu_slot_devices(running_machine &machine, render_container *container) : ui_menu(machine, container)
147{
148}
149
150void ui_menu_slot_devices::populate()
151{
152   /* cycle through all devices for this system */
153   slot_interface_iterator iter(machine().root_device());
154   for (device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next())
155   {
156      /* record the menu item */
157      const device_slot_option *option = slot_get_current_option(slot);
158      astring opt_name;
159      if (option == NULL)
160         opt_name.cpy("------");
161      else
162      {
163         opt_name.cpy(option->name());
164         if (slot->fixed() || slot_get_length(slot) == 0)
165            opt_name.cat(" [internal]");
166      }
167
168      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);
169   }
170   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
171   item_append("Reset",  NULL, 0, (void *)1);
172}
173
174ui_menu_slot_devices::~ui_menu_slot_devices()
175{
176}
177
178/*-------------------------------------------------
179    ui_menu_slot_devices - menu that
180-------------------------------------------------*/
181
182void ui_menu_slot_devices::handle()
183{
184   /* process the menu */
185   const ui_menu_event *menu_event = process(0);
186
187   if (menu_event != NULL && menu_event->itemref != NULL)
188   {
189      if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT)
190         machine().schedule_hard_reset();
191      else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
192      {
193         device_slot_interface *slot = (device_slot_interface *)menu_event->itemref;
194         const char *val = (menu_event->iptkey == IPT_UI_LEFT) ? slot_get_prev(slot) : slot_get_next(slot);
195         set_slot_device(slot, val);
196         reset(UI_MENU_RESET_REMEMBER_REF);
197      }
198   }
199}
trunk/src/emu/ui/slotopt.h
r0r242909
1/***************************************************************************
2
3    ui/slotopt.h
4 
5    Internal menu for the slot options.
6 
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10***************************************************************************/
11
12#pragma once
13
14#ifndef __UI_SLOTOPT_H__
15#define __UI_SLOTOPT_H__
16
17//#include "drivenum.h"
18
19class ui_menu_slot_devices : public ui_menu {
20public:
21   ui_menu_slot_devices(running_machine &machine, render_container *container);
22   virtual ~ui_menu_slot_devices();
23   virtual void populate();
24   virtual void handle();
25
26private:
27   device_slot_option *slot_get_current_option(device_slot_interface *slot);
28   int slot_get_current_index(device_slot_interface *slot);
29   int slot_get_length(device_slot_interface *slot);
30   const char *slot_get_next(device_slot_interface *slot);
31   const char *slot_get_prev(device_slot_interface *slot);
32   const char *slot_get_option(device_slot_interface *slot, int index);
33   void set_slot_device(device_slot_interface *slot, const char *val);
34};
35
36#endif  /* __UI_SLOTOPT_H__ */
trunk/src/mame/drivers/eolith.c
r242908r242909
103103
104104#include "machine/eepromser.h"
105105#include "includes/eolith.h"
106#include "includes/eolithsp.h"
107106
108107
109
110
111
112108/*************************************
113109 *
114110 *  Control
r242908r242909
125121       bit 8 = ???
126122       bit 9 = ???
127123   */
128   eolith_speedup_read(space);
124   speedup_read();
129125
130126   return (m_in0->read() & ~0x300) | (machine().rand() & 0x300);
131127}
r242908r242909
165161   m_sound_data = data;
166162   m_soundcpu->set_input_line(MCS51_INT0_LINE, ASSERT_LINE);
167163
168   space.machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(250));
164   machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(250));
169165}
170166
171167
r242908r242909
14911487
14921488DRIVER_INIT_MEMBER(eolith_state,eolith)
14931489{
1494   init_eolith_speedup(machine());
1490   init_speedup();
14951491
14961492   // Sound CPU -> QS1000 CPU serial link
14971493   m_soundcpu->i8051_set_serial_tx_callback(write8_delegate(FUNC(eolith_state::soundcpu_to_qs1000),this));
14981494
14991495   // Configure the sound ROM banking
15001496   membank("sound_bank")->configure_entries(0, 16, memregion("sounddata")->base(), 0x8000);
1497   
1498   save_item(NAME(m_sound_data));
15011499}
15021500
15031501DRIVER_INIT_MEMBER(eolith_state,landbrk)
r242908r242909
15691567 *
15701568 *************************************/
15711569
1572GAME( 1998, linkypip,  0,        eolith45, linkypip,  eolith_state, eolith,   ROT0, "Eolith", "Linky Pipe", GAME_IMPERFECT_SOUND )
1573GAME( 1998, ironfort,  0,        ironfort, ironfort,  eolith_state, eolith,   ROT0, "Eolith", "Iron Fortress", GAME_IMPERFECT_SOUND )
1574GAME( 1998, ironfortj, ironfort, ironfort, ironfortj, eolith_state, eolith,   ROT0, "Eolith", "Iron Fortress (Japan)", GAME_IMPERFECT_SOUND )
1575GAME( 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
1576GAME( 1998, raccoon,   0,        eolith45, raccoon,   eolith_state, eolith,   ROT0, "Eolith", "Raccoon World", GAME_IMPERFECT_SOUND )
1577GAME( 1998, puzzlekg,  0,        eolith45, puzzlekg,  eolith_state, eolith,   ROT0, "Eolith", "Puzzle King (Dance & Puzzle)",  GAME_IMPERFECT_SOUND )
1578GAME( 1999, candy,     0,        eolith50, candy,     eolith_state, eolith,   ROT0, "Eolith", "Candy Candy",  GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
1579GAME( 1999, hidctch2,  0,        eolith50, hidctch2,  eolith_state, hidctch2, ROT0, "Eolith", "Hidden Catch 2 (pcb ver 3.03) (Kor/Eng) (AT89c52 protected)", GAME_IMPERFECT_SOUND )
1580GAME( 1999, hidctch2a, hidctch2, eolith50, hidctch2,  eolith_state, eolith,   ROT0, "Eolith", "Hidden Catch 2 (pcb ver 1.00) (Kor/Eng/Jpn/Chi)", GAME_IMPERFECT_SOUND )
1581GAME( 1999, hidnc2k,   0,        eolith50, hidctch2,  eolith_state, hidnc2k,  ROT0, "Eolith", "Hidden Catch 2000 (AT89c52 protected)", GAME_IMPERFECT_SOUND )
1582GAME( 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
1583GAME( 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
1584GAME( 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
1585GAME( 1999, penfan,    0,        eolith45, penfan,    eolith_state, eolith,   ROT0, "Eolith", "Penfan Girls - Step1. Mild Mind (set 1)",  GAME_IMPERFECT_SOUND ) // alt title of Ribbon
1586GAME( 1999, penfana,   penfan,   eolith45, penfan,    eolith_state, eolith,   ROT0, "Eolith", "Penfan Girls - Step1. Mild Mind (set 2)",  GAME_IMPERFECT_SOUND )
1587GAME( 2000, stealsee,  0,        eolith45, stealsee,  eolith_state, eolith,   ROT0, "Moov Generation / Eolith", "Steal See",  GAME_IMPERFECT_SOUND )
1588GAME( 2000, hidctch3,  0,        eolith50, hidctch3,  eolith_state, hidctch3, ROT0, "Eolith", "Hidden Catch 3 (ver 1.00 / pcb ver 3.05)", GAME_IMPERFECT_SOUND )
1589GAME( 2001, fort2b,    0,        eolith50, common,    eolith_state, eolith,   ROT0, "Eolith", "Fortress 2 Blue Arcade (ver 1.01 / pcb ver 3.05)",  GAME_IMPERFECT_SOUND )
1590GAME( 2001, fort2ba,   fort2b,   eolith50, common,    eolith_state, eolith,   ROT0, "Eolith", "Fortress 2 Blue Arcade (ver 1.00 / pcb ver 3.05)",  GAME_IMPERFECT_SOUND )
1570GAME( 1998, linkypip,  0,        eolith45, linkypip,  eolith_state, eolith,   ROT0, "Eolith", "Linky Pipe", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1571GAME( 1998, ironfort,  0,        ironfort, ironfort,  eolith_state, eolith,   ROT0, "Eolith", "Iron Fortress", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1572GAME( 1998, ironfortj, ironfort, ironfort, ironfortj, eolith_state, eolith,   ROT0, "Eolith", "Iron Fortress (Japan)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1573GAME( 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
1574GAME( 1998, raccoon,   0,        eolith45, raccoon,   eolith_state, eolith,   ROT0, "Eolith", "Raccoon World", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1575GAME( 1998, puzzlekg,  0,        eolith45, puzzlekg,  eolith_state, eolith,   ROT0, "Eolith", "Puzzle King (Dance & Puzzle)",  GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1576GAME( 1999, candy,     0,        eolith50, candy,     eolith_state, eolith,   ROT0, "Eolith", "Candy Candy",  GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1577GAME( 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 )
1578GAME( 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 )
1579GAME( 1999, hidnc2k,   0,        eolith50, hidctch2,  eolith_state, hidnc2k,  ROT0, "Eolith", "Hidden Catch 2000 (AT89c52 protected)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1580GAME( 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
1581GAME( 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
1582GAME( 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
1583GAME( 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
1584GAME( 1999, penfana,   penfan,   eolith45, penfan,    eolith_state, eolith,   ROT0, "Eolith", "Penfan Girls - Step1. Mild Mind (set 2)",  GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1585GAME( 2000, stealsee,  0,        eolith45, stealsee,  eolith_state, eolith,   ROT0, "Moov Generation / Eolith", "Steal See",  GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1586GAME( 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 )
1587GAME( 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 )
1588GAME( 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 )
trunk/src/mame/drivers/eolith16.c
r242908r242909
1515
1616#include "sound/okim6295.h"
1717#include "includes/eolith.h"
18#include "includes/eolithsp.h"
1918
2019
2120class eolith16_state : public eolith_state
r242908r242909
2625
2726   UINT16 *m_vram;
2827   int m_vbuffer;
28   
2929   DECLARE_WRITE16_MEMBER(eeprom_w);
3030   DECLARE_READ16_MEMBER(eolith16_custom_r);
3131   DECLARE_WRITE16_MEMBER(vram_w);
3232   DECLARE_READ16_MEMBER(vram_r);
33   
3334   DECLARE_DRIVER_INIT(eolith16);
3435   DECLARE_VIDEO_START(eolith16);
3536   DECLARE_PALETTE_INIT(eolith16);
37   
3638   UINT32 screen_update_eolith16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3739};
3840
r242908r242909
4345   m_vbuffer = (data & 0x80) >> 7;
4446   coin_counter_w(machine(), 0, data & 1);
4547
46   ioport("EEPROMOUT")->write(data, 0xff);
48   m_eepromoutport->write(data, 0xff);
4749
4850   //data & 0x100 and data & 0x004 always set
4951}
5052
5153READ16_MEMBER(eolith16_state::eolith16_custom_r)
5254{
53   eolith_speedup_read(space);
55   speedup_read();
5456   return ioport("SPECIAL")->read();
5557}
5658
r242908r242909
113115VIDEO_START_MEMBER(eolith16_state,eolith16)
114116{
115117   m_vram = auto_alloc_array(machine(), UINT16, 0x10000);
118   save_pointer(NAME(m_vram), 0x10000);
119   save_item(NAME(m_vbuffer));
116120}
117121
118122UINT32 eolith16_state::screen_update_eolith16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r242908r242909
253257
254258DRIVER_INIT_MEMBER(eolith16_state,eolith16)
255259{
256   init_eolith_speedup(machine());
260   init_speedup();
257261}
258262
259GAME( 1999, klondkp, 0, eolith16, eolith16, eolith16_state, eolith16, ROT0, "Eolith", "KlonDike+", 0 )
263GAME( 1999, klondkp, 0, eolith16, eolith16, eolith16_state, eolith16, ROT0, "Eolith", "KlonDike+", GAME_SUPPORTS_SAVE )
trunk/src/mame/drivers/eolithsp.c
r242908r242909
99*/
1010
1111#include "emu.h"
12#include "includes/eolithsp.h"
1312#include "includes/eolith.h"
1413
15static int eolith_speedup_address;
16static int eolith_speedup_address2;
17static int eolith_speedup_resume_scanline;
18static int eolith_vblank = 0;
19static int eolith_scanline = 0;
2014
21void eolith_speedup_read(address_space &space)
15void eolith_state::speedup_read()
2216{
2317   /* for debug */
24   //if ((space.device().safe_pc()!=eolith_speedup_address) && (eolith_vblank!=1) )
25   //    printf("%s:eolith speedup_read data %02x\n",space.machine().describe_context(), eolith_vblank);
18   //if ((space.device().safe_pc()!=m_speedup_address) && (m_speedup_vblank!=1) )
19   //    printf("%s:eolith speedup_read data %02x\n",space.machine().describe_context(), m_speedup_vblank);
2620
27   if (eolith_vblank==0 && eolith_scanline < eolith_speedup_resume_scanline)
21   if (m_speedup_vblank==0 && m_speedup_scanline < m_speedup_resume_scanline)
2822   {
29      int pc = space.device().safe_pc();
23      int pc = m_maincpu->pc();
3024
31      if ((pc==eolith_speedup_address) || (pc==eolith_speedup_address2))
25      if ((pc==m_speedup_address) || (pc==m_speedup_address2))
3226      {
33         space.device().execute().spin_until_trigger(1000);
27         m_maincpu->spin_until_trigger(1000);
3428      }
3529   }
3630}
r242908r242909
7165};
7266
7367
74void init_eolith_speedup(running_machine &machine)
68void eolith_state::init_speedup()
7569{
7670   int n_game = 0;
77   eolith_speedup_address = 0;
78   eolith_speedup_resume_scanline = 0;
71   m_speedup_address = 0;
72   m_speedup_address2 = 0;
73   m_speedup_resume_scanline = 0;
74   m_speedup_vblank = 0;
75   m_speedup_scanline = 0;
7976
8077   while( eolith_speedup_table[ n_game ].s_name != NULL )
8178   {
82      if( strcmp( machine.system().name, eolith_speedup_table[ n_game ].s_name ) == 0 )
79      if( strcmp( machine().system().name, eolith_speedup_table[ n_game ].s_name ) == 0 )
8380      {
84         eolith_speedup_address = eolith_speedup_table[ n_game ].speedup_address;
85         eolith_speedup_address2 = eolith_speedup_table[ n_game ].speedup_address2;
86         eolith_speedup_resume_scanline = eolith_speedup_table[ n_game ].speedup_resume_scanline;
81         m_speedup_address = eolith_speedup_table[ n_game ].speedup_address;
82         m_speedup_address2 = eolith_speedup_table[ n_game ].speedup_address2;
83         m_speedup_resume_scanline = eolith_speedup_table[ n_game ].speedup_resume_scanline;
8784      }
8885      n_game++;
8986   }
87   
88   save_item(NAME(m_speedup_vblank));
89   save_item(NAME(m_speedup_scanline));
9090}
9191
9292/* todo, use timers instead! */
r242908r242909
9494{
9595   if (param==0)
9696   {
97      eolith_vblank = 0;
97      m_speedup_vblank = 0;
9898   }
9999
100   if (param==eolith_speedup_resume_scanline)
100   if (param==m_speedup_resume_scanline)
101101   {
102102      machine().scheduler().trigger(1000);
103103   }
104104
105105   if (param==240)
106106   {
107      eolith_vblank = 1;
107      m_speedup_vblank = 1;
108108   }
109109}
110110
111111CUSTOM_INPUT_MEMBER(eolith_state::eolith_speedup_getvblank)
112112{
113//  printf("%s:eolith speedup_read data %02x\n",machine().describe_context(), eolith_vblank);
113//  printf("%s:eolith speedup_read data %02x\n",machine().describe_context(), m_speedup_vblank);
114114
115115
116116   return (m_screen->vpos() >= 240);
r242908r242909
122122   int pc = m_maincpu->pc();
123123
124124   if (pc==0x400081ec)
125      if(!eolith_vblank)
125      if(!m_speedup_vblank)
126126         m_maincpu->eat_cycles(500);
127127
128128   return (m_screen->vpos() >= 240);
trunk/src/mame/drivers/sprint2.c
r242908r242909
9898         case 4: m_gear[i] = 3; break;
9999         case 8: m_gear[i] = 4; break;
100100         }
101         output_set_value("P1gear", m_gear[0]);
102         output_set_value("P2gear", m_gear[1]);
101103      }
102104   }
103105
trunk/src/mame/drivers/stadhero.c
r242908r242909
3535   switch (offset<<1)
3636   {
3737      case 0:
38         return ioport("INPUTS")->read();
38         return m_inputs->read();
3939
4040      case 2:
41         return ioport("COIN")->read();
41         return m_coin->read();
4242
4343      case 4:
44         return ioport("DSW")->read();
44         return m_dsw->read();
4545   }
4646
4747   logerror("CPU #0 PC %06x: warning - read unmapped memory address %06x\n",space.device().safe_pc(),0x30c000+offset);
r242908r242909
305305
306306/******************************************************************************/
307307
308GAME( 1988, stadhero, 0, stadhero, stadhero, driver_device, 0, ROT0, "Data East Corporation", "Stadium Hero (Japan)", 0 )
308GAME( 1988, stadhero, 0, stadhero, stadhero, driver_device, 0, ROT0, "Data East Corporation", "Stadium Hero (Japan)", GAME_SUPPORTS_SAVE )
trunk/src/mame/drivers/vegaeo.c
r242908r242909
1616#include "machine/at28c16.h"
1717#include "sound/qs1000.h"
1818#include "includes/eolith.h"
19#include "includes/eolithsp.h"
2019
2120
2221class vegaeo_state : public eolith_state
r242908r242909
2726
2827   UINT32 *m_vega_vram;
2928   UINT8 m_vega_vbuffer;
29   
3030   DECLARE_WRITE32_MEMBER(vega_vram_w);
3131   DECLARE_READ32_MEMBER(vega_vram_r);
3232   DECLARE_WRITE32_MEMBER(vega_misc_w);
3333   DECLARE_READ32_MEMBER(vegaeo_custom_read);
3434   DECLARE_WRITE32_MEMBER(soundlatch_w);
35
3635   DECLARE_READ8_MEMBER(qs1000_p1_r);
37
3836   DECLARE_WRITE8_MEMBER(qs1000_p1_w);
3937   DECLARE_WRITE8_MEMBER(qs1000_p2_w);
4038   DECLARE_WRITE8_MEMBER(qs1000_p3_w);
39
4140   DECLARE_DRIVER_INIT(vegaeo);
4241   DECLARE_VIDEO_START(vega);
42
4343   UINT32 screen_update_vega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4444};
4545
r242908r242909
6262   // ...x .... - ?
6363   // ..x. .... - /IRQ clear
6464
65   qs1000_device *qs1000 = machine().device<qs1000_device>("qs1000");
66
6765   membank("qs1000:bank")->set_entry(data & 0x07);
6866
6967   if (!BIT(data, 5))
70      qs1000->set_irq(CLEAR_LINE);
68      m_qs1000->set_irq(CLEAR_LINE);
7169}
7270
7371WRITE32_MEMBER(vegaeo_state::vega_vram_w)
r242908r242909
115113
116114READ32_MEMBER(vegaeo_state::vegaeo_custom_read)
117115{
118   eolith_speedup_read(space);
116   speedup_read();
119117   return ioport("SYSTEM")->read();
120118}
121119
122120WRITE32_MEMBER(vegaeo_state::soundlatch_w)
123121{
124   qs1000_device *qs1000 = space.machine().device<qs1000_device>("qs1000");
125
126122   soundlatch_byte_w(space, 0, data);
127   qs1000->set_irq(ASSERT_LINE);
123   m_qs1000->set_irq(ASSERT_LINE);
128124
129125   machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(100));
130126}
r242908r242909
180176VIDEO_START_MEMBER(vegaeo_state,vega)
181177{
182178   m_vega_vram = auto_alloc_array(machine(), UINT32, 0x14000*2/4);
179   save_pointer(NAME(m_vega_vram), 0x14000*2/4);
180   save_item(NAME(m_vega_vbuffer));
183181}
184182
185183UINT32 vegaeo_state::screen_update_vega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r242908r242909
328326   machine().device("qs1000:cpu")->memory().space(AS_IO).install_read_bank(0x0100, 0xffff, "bank");
329327   membank("qs1000:bank")->configure_entries(0, 8, memregion("qs1000:cpu")->base()+0x100, 0x10000);
330328
331   init_eolith_speedup(machine());
329   init_speedup();
332330}
333331
334GAME( 2002, crazywar, 0, vega, crazywar, vegaeo_state, vegaeo, ROT0, "Eolith", "Crazy War", GAME_IMPERFECT_SOUND )
332GAME( 2002, crazywar, 0, vega, crazywar, vegaeo_state, vegaeo, ROT0, "Eolith", "Crazy War", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
trunk/src/mame/drivers/xyonix.c
r242908r242909
2525#include "includes/xyonix.h"
2626
2727
28WRITE8_MEMBER(xyonix_state::xyonix_irqack_w)
28void xyonix_state::machine_start()
2929{
30   save_item(NAME(m_e0_data));
31   save_item(NAME(m_credits));
32   save_item(NAME(m_coins));
33   save_item(NAME(m_prev_coin));
34}
35
36WRITE8_MEMBER(xyonix_state::irqack_w)
37{
3038   m_maincpu->set_input_line(0, CLEAR_LINE);
3139}
3240
r242908r242909
7179}
7280
7381
74READ8_MEMBER(xyonix_state::xyonix_io_r)
82READ8_MEMBER(xyonix_state::io_r)
7583{
7684   int regPC = space.device().safe_pc();
7785
r242908r242909
122130   return 0xff;
123131}
124132
125WRITE8_MEMBER(xyonix_state::xyonix_io_w)
133WRITE8_MEMBER(xyonix_state::io_w)
126134{
127135   //logerror ("xyonix_port_e0_w %02x - PC = %04x\n", data, space.device().safe_pc());
128136   m_e0_data = data;
r242908r242909
133141static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, xyonix_state )
134142   AM_RANGE(0x0000, 0xbfff) AM_ROM
135143   AM_RANGE(0xc000, 0xdfff) AM_RAM
136   AM_RANGE(0xe000, 0xffff) AM_RAM_WRITE(xyonix_vidram_w) AM_SHARE("vidram")
144   AM_RANGE(0xe000, 0xffff) AM_RAM_WRITE(vidram_w) AM_SHARE("vidram")
137145ADDRESS_MAP_END
138146
139147static ADDRESS_MAP_START( port_map, AS_IO, 8, xyonix_state )
r242908r242909
141149   AM_RANGE(0x20, 0x20) AM_READNOP AM_DEVWRITE("sn1", sn76496_device, write)   /* SN76496 ready signal */
142150   AM_RANGE(0x21, 0x21) AM_READNOP AM_DEVWRITE("sn2", sn76496_device, write)
143151   AM_RANGE(0x40, 0x40) AM_WRITENOP        /* NMI ack? */
144   AM_RANGE(0x50, 0x50) AM_WRITE(xyonix_irqack_w)
152   AM_RANGE(0x50, 0x50) AM_WRITE(irqack_w)
145153   AM_RANGE(0x60, 0x61) AM_WRITENOP        /* mc6845 */
146   AM_RANGE(0xe0, 0xe0) AM_READWRITE(xyonix_io_r, xyonix_io_w)
154   AM_RANGE(0xe0, 0xe0) AM_READWRITE(io_r, io_w)
147155ADDRESS_MAP_END
148156
149157/* Inputs Ports **************************************************************/
r242908r242909
226234   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
227235   MCFG_SCREEN_SIZE(80*4, 32*8)
228236   MCFG_SCREEN_VISIBLE_AREA(0, 80*4-1, 0, 28*8-1)
229   MCFG_SCREEN_UPDATE_DRIVER(xyonix_state, screen_update_xyonix)
237   MCFG_SCREEN_UPDATE_DRIVER(xyonix_state, screen_update)
230238   MCFG_SCREEN_PALETTE("palette")
231239
232240   MCFG_GFXDECODE_ADD("gfxdecode", "palette", xyonix)
r242908r242909
259267
260268/* GAME drivers **************************************************************/
261269
262GAME( 1989, xyonix, 0, xyonix, xyonix, driver_device, 0, ROT0, "Philko", "Xyonix", 0 )
270GAME( 1989, xyonix, 0, xyonix, xyonix, driver_device, 0, ROT0, "Philko", "Xyonix", GAME_SUPPORTS_SAVE )
trunk/src/mame/includes/eolith.h
r242908r242909
1010         m_maincpu(*this, "maincpu"),
1111         m_soundcpu(*this, "soundcpu"),
1212         m_qs1000(*this, "qs1000"),
13         m_screen(*this, "screen"),
14         m_palette(*this, "palette"),
1315         m_in0(*this, "IN0"),
1416         m_eepromoutport(*this, "EEPROMOUT"),
1517         m_penx1port(*this, "PEN_X_P1"),
1618         m_peny1port(*this, "PEN_Y_P1"),
1719         m_penx2port(*this, "PEN_X_P2"),
1820         m_peny2port(*this, "PEN_Y_P2"),
19         m_sndbank(*this, "sound_bank"),
20         m_screen(*this, "screen"),
21         m_palette(*this, "palette")
21         m_sndbank(*this, "sound_bank")
2222      { }
2323
24   int m_coin_counter_bit;
25   int m_buffer;
26   UINT32 *m_vram;
2724
28   UINT8 m_sound_data;
29   UINT8 m_data_to_qs1000;
30
3125   required_device<cpu_device> m_maincpu;
3226   optional_device<i8032_device> m_soundcpu;
3327   optional_device<qs1000_device> m_qs1000;
28   required_device<screen_device> m_screen;
29   required_device<palette_device> m_palette;
30   
3431   optional_ioport m_in0; // klondkp doesn't have it
3532   optional_ioport m_eepromoutport;
3633   optional_ioport m_penx1port;
3734   optional_ioport m_peny1port;
3835   optional_ioport m_penx2port;
3936   optional_ioport m_peny2port;
37   
4038   optional_memory_bank m_sndbank;
41   required_device<screen_device> m_screen;
42   required_device<palette_device> m_palette;
39   
40   int m_coin_counter_bit;
41   int m_buffer;
42   UINT32 *m_vram;
4343
44   UINT8 m_sound_data;
45   
46   // speedups - see machine/eolithsp.c
47   int m_speedup_address;
48   int m_speedup_address2;
49   int m_speedup_resume_scanline;
50   int m_speedup_vblank;
51   int m_speedup_scanline;
52   void speedup_read();
53   void init_speedup();
54   DECLARE_CUSTOM_INPUT_MEMBER(eolith_speedup_getvblank);
55   DECLARE_CUSTOM_INPUT_MEMBER(stealsee_speedup_getvblank);
56
4457   DECLARE_READ32_MEMBER(eolith_custom_r);
4558   DECLARE_WRITE32_MEMBER(systemcontrol_w);
4659   DECLARE_WRITE32_MEMBER(sound_w);
r242908r242909
4861   DECLARE_READ32_MEMBER(hidctch3_pen2_r);
4962   DECLARE_WRITE32_MEMBER(eolith_vram_w);
5063   DECLARE_READ32_MEMBER(eolith_vram_r);
51   DECLARE_CUSTOM_INPUT_MEMBER(eolith_speedup_getvblank);
52   DECLARE_CUSTOM_INPUT_MEMBER(stealsee_speedup_getvblank);
53
5464   DECLARE_READ8_MEMBER(sound_cmd_r);
5565   DECLARE_WRITE8_MEMBER(sound_p1_w);
56
5766   DECLARE_READ8_MEMBER(qs1000_p1_r);
5867   DECLARE_WRITE8_MEMBER(qs1000_p1_w);
68   DECLARE_WRITE8_MEMBER(soundcpu_to_qs1000);
69   
5970   DECLARE_DRIVER_INIT(eolith);
6071   DECLARE_DRIVER_INIT(landbrk);
6172   DECLARE_DRIVER_INIT(hidctch3);
6273   DECLARE_DRIVER_INIT(hidctch2);
6374   DECLARE_DRIVER_INIT(hidnc2k);
6475   DECLARE_DRIVER_INIT(landbrka);
76   
6577   DECLARE_MACHINE_RESET(eolith);
6678   DECLARE_VIDEO_START(eolith);
79   
6780   UINT32 screen_update_eolith(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
81   
6882   TIMER_DEVICE_CALLBACK_MEMBER(eolith_speedup);
69   DECLARE_WRITE8_MEMBER(soundcpu_to_qs1000);
7083};
trunk/src/mame/includes/eolithsp.h
r242908r242909
1/*----------- defined in drivers/eolithsp.c -----------*/
2
3void eolith_speedup_read(address_space &space);
4void init_eolith_speedup(running_machine &machine);
trunk/src/mame/includes/stadhero.h
r242908r242909
1010      m_audiocpu(*this, "audiocpu"),
1111      m_tilegen1(*this, "tilegen1"),
1212      m_spritegen(*this, "spritegen"),
13      m_gfxdecode(*this, "gfxdecode"),
1314      m_spriteram(*this, "spriteram"),
1415      m_pf1_data(*this, "pf1_data"),
15      m_gfxdecode(*this, "gfxdecode") { }
16      m_inputs(*this, "INPUTS"),
17      m_coin(*this, "COIN"),
18      m_dsw(*this, "DSW") { }
1619
1720   required_device<cpu_device> m_maincpu;
1821   required_device<cpu_device> m_audiocpu;
1922   required_device<deco_bac06_device> m_tilegen1;
2023   required_device<deco_mxc06_device> m_spritegen;
24   required_device<gfxdecode_device> m_gfxdecode;
25   
2126   required_shared_ptr<UINT16> m_spriteram;
2227   required_shared_ptr<UINT16> m_pf1_data;
23   required_device<gfxdecode_device> m_gfxdecode;
28   
29   required_ioport m_inputs;
30   required_ioport m_coin;
31   required_ioport m_dsw;
2432
2533   tilemap_t *m_pf1_tilemap;
26   int m_flipscreen;
34   
2735   DECLARE_READ16_MEMBER(stadhero_control_r);
2836   DECLARE_WRITE16_MEMBER(stadhero_control_w);
2937   DECLARE_WRITE16_MEMBER(stadhero_pf1_data_w);
38   DECLARE_WRITE_LINE_MEMBER(irqhandler);
39   
40   virtual void video_start();
41   
3042   TILE_GET_INFO_MEMBER(get_pf1_tile_info);
31   virtual void video_start();
3243   UINT32 screen_update_stadhero(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
33   DECLARE_WRITE_LINE_MEMBER(irqhandler);
3444};
trunk/src/mame/includes/vaportra.h
r242908r242909
2323      m_generic_paletteram_16(*this, "paletteram"),
2424      m_generic_paletteram2_16(*this, "paletteram2") { }
2525
26   /* memory pointers */
27   UINT16 *  m_pf1_rowscroll;
28   UINT16 *  m_pf2_rowscroll;
29   UINT16 *  m_pf3_rowscroll;
30   UINT16 *  m_pf4_rowscroll;
31
32   /* misc */
33   UINT16    m_priority[2];
34
3526   /* devices */
3627   required_device<cpu_device> m_maincpu;
3728   required_device<cpu_device> m_audiocpu;
r242908r242909
4031   required_device<deco_mxc06_device> m_spritegen;
4132   required_device<buffered_spriteram16_device> m_spriteram;
4233   required_device<palette_device> m_palette;
34
4335   required_shared_ptr<UINT16> m_generic_paletteram_16;
4436   required_shared_ptr<UINT16> m_generic_paletteram2_16;
4537
38   /* misc */
39   UINT16    m_priority[2];
40
4641   DECLARE_WRITE16_MEMBER(vaportra_sound_w);
4742   DECLARE_READ16_MEMBER(vaportra_control_r);
4843   DECLARE_READ8_MEMBER(vaportra_soundlatch_r);
4944   DECLARE_WRITE16_MEMBER(vaportra_priority_w);
5045   DECLARE_WRITE16_MEMBER(vaportra_palette_24bit_rg_w);
5146   DECLARE_WRITE16_MEMBER(vaportra_palette_24bit_b_w);
47   
5248   DECLARE_DRIVER_INIT(vaportra);
5349   virtual void machine_start();
5450   virtual void machine_reset();
51   
5552   UINT32 screen_update_vaportra(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5653   void update_24bitcol( int offset );
54   
5755   DECO16IC_BANK_CB_MEMBER(bank_callback);
5856};
trunk/src/mame/includes/xyonix.h
r242908r242909
33public:
44   xyonix_state(const machine_config &mconfig, device_type type, const char *tag)
55      : driver_device(mconfig, type, tag),
6      m_vidram(*this, "vidram"),
76      m_maincpu(*this, "maincpu"),
8      m_gfxdecode(*this, "gfxdecode") { }
7      m_gfxdecode(*this, "gfxdecode"),
8      m_vidram(*this, "vidram") { }
99
10   required_device<cpu_device> m_maincpu;
11   required_device<gfxdecode_device> m_gfxdecode;
12   
1013   required_shared_ptr<UINT8> m_vidram;
14   
1115   tilemap_t *m_tilemap;
1216
1317   int m_e0_data;
1418   int m_credits;
1519   int m_coins;
1620   int m_prev_coin;
17   DECLARE_WRITE8_MEMBER(xyonix_irqack_w);
18   DECLARE_READ8_MEMBER(xyonix_io_r);
19   DECLARE_WRITE8_MEMBER(xyonix_io_w);
20   DECLARE_WRITE8_MEMBER(xyonix_vidram_w);
21   TILE_GET_INFO_MEMBER(get_xyonix_tile_info);
21   
22   DECLARE_WRITE8_MEMBER(irqack_w);
23   DECLARE_READ8_MEMBER(io_r);
24   DECLARE_WRITE8_MEMBER(io_w);
25   DECLARE_WRITE8_MEMBER(vidram_w);
26   
27   virtual void machine_start();
2228   virtual void video_start();
29   TILE_GET_INFO_MEMBER(get_tile_info);
2330   DECLARE_PALETTE_INIT(xyonix);
24   UINT32 screen_update_xyonix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
31   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
32   
2533   void handle_coins(int coin);
26   required_device<cpu_device> m_maincpu;
27   required_device<gfxdecode_device> m_gfxdecode;
2834};
trunk/src/mame/video/eolith.c
r242908r242909
3333VIDEO_START_MEMBER(eolith_state,eolith)
3434{
3535   m_vram = auto_alloc_array(machine(), UINT32, 0x40000*2/4);
36   save_pointer(NAME(m_vram), 0x40000*2/4);
37   save_item(NAME(m_buffer));
3638}
3739
3840UINT32 eolith_state::screen_update_eolith(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
3941{
40   int y;
41
42   for (y = 0; y < 240; y++)
42   for (int y = 0; y < 240; y++)
4343   {
44      int x;
4544      UINT32 *src = &m_vram[(m_buffer ? 0 : 0x10000) | (y * (336 / 2))];
4645      UINT16 *dest = &bitmap.pix16(y);
4746
48      for (x = 0; x < 320; x += 2)
47      for (int x = 0; x < 320; x += 2)
4948      {
5049         dest[0] = (*src >> 16) & 0x7fff;
5150         dest[1] = (*src >>  0) & 0x7fff;
trunk/src/mame/video/stadhero.c
r242908r242909
2020
2121UINT32 stadhero_state::screen_update_stadhero(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
2222{
23//  machine().tilemap().set_flip_all(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
24
2523   flip_screen_set(m_tilegen1->get_flip_state());
2624
2725   m_tilegen1->set_bppmultmask(0x8, 0x7);
r242908r242909
5654
5755void stadhero_state::video_start()
5856{
59   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);
57   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);
6058   m_pf1_tilemap->set_transparent_pen(0);
6159}
6260
trunk/src/mame/video/xyonix.c
r242908r242909
3131}
3232
3333
34TILE_GET_INFO_MEMBER(xyonix_state::get_xyonix_tile_info)
34TILE_GET_INFO_MEMBER(xyonix_state::get_tile_info)
3535{
3636   int tileno;
3737   int attr = m_vidram[tile_index+0x1000+1];
r242908r242909
4141   SET_TILE_INFO_MEMBER(0,tileno,attr >> 4,0);
4242}
4343
44WRITE8_MEMBER(xyonix_state::xyonix_vidram_w)
44WRITE8_MEMBER(xyonix_state::vidram_w)
4545{
4646   m_vidram[offset] = data;
4747   m_tilemap->mark_tile_dirty((offset-1)&0x0fff);
r242908r242909
4949
5050void xyonix_state::video_start()
5151{
52   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);
52   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);
5353}
5454
55UINT32 xyonix_state::screen_update_xyonix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
55UINT32 xyonix_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
5656{
5757   m_tilemap->draw(screen, bitmap, cliprect, 0, 0);
5858   return 0;


Previous 199869 Revisions Next


© 1997-2024 The MAME Team