Previous 199869 Revisions Next

r34396 Wednesday 14th January, 2015 at 02:35:10 UTC by Couriersud
Removed some machine() references
[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]aleck64.c 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
[src/osd/sdl]input.c osdsdl.h sdlmain.c video.c window.c

trunk/src/emu/bus/nes/ggenie.c
r242907r242908
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
5851void nes_ggenie_device::pcb_reset()
5952{
6053   m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
r242907r242908
6558   m_gg_bypass = 0;
6659
6760   if (m_ggslot->m_cart)
61   {
62      m_ggslot->pcb_start(m_ciram);
6863      m_ggslot->m_cart->pcb_reset();
64   }
6965}
7066
7167
trunk/src/emu/bus/nes/ggenie.h
r242907r242908
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);
3736
3837private:
3938   // emulate the Game Genie!
trunk/src/emu/bus/nes/nes_slot.h
r242907r242908
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   virtual void pcb_start(running_machine &machine, UINT8 *ciram_ptr, bool cart_mounted);
219   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
r242907r242908
116116   $(EMUOBJ)/timer.o \
117117   $(EMUOBJ)/uiinput.o \
118118   $(EMUOBJ)/ui/ui.o \
119   $(EMUOBJ)/ui/swlist.o \
119120   $(EMUOBJ)/ui/menu.o \
120121   $(EMUOBJ)/ui/mainmenu.o \
121122   $(EMUOBJ)/ui/miscmenu.o \
122   $(EMUOBJ)/ui/barcode.o \
123   $(EMUOBJ)/ui/selgame.o \
123124   $(EMUOBJ)/ui/filemngr.o \
124125   $(EMUOBJ)/ui/filesel.o \
125126   $(EMUOBJ)/ui/imgcntrl.o \
126127   $(EMUOBJ)/ui/imginfo.o \
127   $(EMUOBJ)/ui/inputmap.o \
128   $(EMUOBJ)/ui/selgame.o \
129   $(EMUOBJ)/ui/slotopt.o \
130   $(EMUOBJ)/ui/swlist.o \
128   $(EMUOBJ)/ui/barcode.o \
131129   $(EMUOBJ)/ui/tapectrl.o \
132130   $(EMUOBJ)/ui/viewgfx.o \
133131   $(EMUOBJ)/validity.o \
trunk/src/emu/ui/filemngr.c
r242907r242908
6666void ui_menu_file_manager::populate()
6767{
6868   astring buffer;
69   bool first = true;
69   astring tmp_name;
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
8075      // get the image type/id
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);
76      buffer.printf(
77         "%s (%s)",
78         image->device().name(), image->brief_instance_name());
8479
8580      // get the base name
8681      if (image->basename() != NULL)
8782      {
88         buffer.cpy(image->basename());
83         tmp_name.cpy(image->basename());
8984
9085         // if the image has been loaded through softlist, also show the loaded part
9186         if (image->part_entry() != NULL)
r242907r242908
9388            const software_part *tmp = image->part_entry();
9489            if (tmp->name() != NULL)
9590            {
96               buffer.cat(" (");
97               buffer.cat(tmp->name());
91               tmp_name.cat(" (");
92               tmp_name.cat(tmp->name());
9893               // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it
9994               if (image->get_feature("part_id") != NULL)
10095               {
101                  buffer.cat(": ");
102                  buffer.cat(image->get_feature("part_id"));
96                  tmp_name.cat(": ");
97                  tmp_name.cat(image->get_feature("part_id"));
10398               }
104               buffer.cat(")");
99               tmp_name.cat(")");
105100            }
106101         }
107102      }
108103      else
109         buffer.cpy("---");
104         tmp_name.cpy("---");
110105
111106      // record the menu item
112      item_append("Mounted File", buffer, 0, (void *) image);
107      item_append(buffer, tmp_name.cstr(), 0, (void *) image);
113108   }
114109   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
115110   item_append("Reset",  NULL, 0, (void *)1);
trunk/src/emu/ui/inputmap.c
r242907r242908
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 (item->owner_name && 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
r242907r242908
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
r242907r242908
1919#include "ui/filemngr.h"
2020#include "ui/filesel.h"
2121#include "ui/barcode.h"
22#include "ui/imginfo.h"
23#include "ui/inputmap.h"
22#include "ui/tapectrl.h"
2423#include "ui/mainmenu.h"
2524#include "ui/miscmenu.h"
25#include "ui/imginfo.h"
2626#include "ui/selgame.h"
27#include "ui/slotopt.h"
28#include "ui/tapectrl.h"
2927#include "audit.h"
3028#include "crsshair.h"
3129#include <ctype.h>
trunk/src/emu/ui/miscmenu.c
r242907r242908
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
2744/*-------------------------------------------------
2845    ui_slider_ui_handler - pushes the slider
2946    menu on the stack and hands off to the
r242907r242908
91108
92109
93110/*-------------------------------------------------
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/*-------------------------------------------------
94294    ui_menu_bios_selection - populates the main
95295    bios selection menu
96296-------------------------------------------------*/
r242907r242908
226426   }
227427}
228428
429/*-------------------------------------------------
430    menu_input_groups_populate - populate the
431    input groups menu
432-------------------------------------------------*/
229433
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
230457/*-------------------------------------------------
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/*-------------------------------------------------
2311340    menu_bookkeeping - handle the bookkeeping
2321341    information menu
2331342-------------------------------------------------*/
trunk/src/emu/ui/miscmenu.h
r242907r242908
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
2845class ui_menu_network_devices : public ui_menu {
2946public:
3047   ui_menu_network_devices(running_machine &machine, render_container *container);
r242907r242908
3350   virtual void handle();
3451};
3552
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
36190class ui_menu_bookkeeping : public ui_menu {
37191public:
38192   ui_menu_bookkeeping(running_machine &machine, render_container *container);
trunk/src/emu/ui/selgame.c
r242907r242908
1717#include "cheat.h"
1818#include "uiinput.h"
1919#include "ui/selgame.h"
20#include "ui/inputmap.h"
2120#include "ui/miscmenu.h"
2221#include "audit.h"
2322#include "crsshair.h"
trunk/src/emu/ui/slotopt.c
r242907r242908
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
r242907r242908
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/aleck64.c
r242907r242908
881881   PIF_BOOTROM
882882
883883   ROM_REGION32_BE( 0x4000000, "user2", 0 )
884   ROM_LOAD16_WORD_SWAP( "nus-zhaj.u3", 0x000000, 0x0800000, CRC(02faa8a7) SHA1(824911452639cedf6a8186c05cd046e61fc98896) )
884   ROM_LOAD16_WORD_SWAP( "nus-zhaj.u3", 0x000000, 0x0800000, BAD_DUMP CRC(95258ba2) SHA1(0299b8fb9a8b1b24428d0f340f6bf1cfaf99c672) )
885885
886886   ROM_REGION16_BE( 0x80, "normpoint", 0 )
887887   ROM_LOAD( "normpnt.rom", 0x00, 0x80, CRC(e7f2a005) SHA1(c27b4a364a24daeee6e99fd286753fd6216362b4) )
trunk/src/mame/drivers/eolith.c
r242907r242908
103103
104104#include "machine/eepromser.h"
105105#include "includes/eolith.h"
106#include "includes/eolithsp.h"
106107
107108
109
110
111
108112/*************************************
109113 *
110114 *  Control
r242907r242908
121125       bit 8 = ???
122126       bit 9 = ???
123127   */
124   speedup_read();
128   eolith_speedup_read(space);
125129
126130   return (m_in0->read() & ~0x300) | (machine().rand() & 0x300);
127131}
r242907r242908
161165   m_sound_data = data;
162166   m_soundcpu->set_input_line(MCS51_INT0_LINE, ASSERT_LINE);
163167
164   machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(250));
168   space.machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(250));
165169}
166170
167171
r242907r242908
14871491
14881492DRIVER_INIT_MEMBER(eolith_state,eolith)
14891493{
1490   init_speedup();
1494   init_eolith_speedup(machine());
14911495
14921496   // Sound CPU -> QS1000 CPU serial link
14931497   m_soundcpu->i8051_set_serial_tx_callback(write8_delegate(FUNC(eolith_state::soundcpu_to_qs1000),this));
14941498
14951499   // Configure the sound ROM banking
14961500   membank("sound_bank")->configure_entries(0, 16, memregion("sounddata")->base(), 0x8000);
1497   
1498   save_item(NAME(m_sound_data));
14991501}
15001502
15011503DRIVER_INIT_MEMBER(eolith_state,landbrk)
r242907r242908
15671569 *
15681570 *************************************/
15691571
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 )
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 )
trunk/src/mame/drivers/eolith16.c
r242907r242908
1515
1616#include "sound/okim6295.h"
1717#include "includes/eolith.h"
18#include "includes/eolithsp.h"
1819
1920
2021class eolith16_state : public eolith_state
r242907r242908
2526
2627   UINT16 *m_vram;
2728   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   
3433   DECLARE_DRIVER_INIT(eolith16);
3534   DECLARE_VIDEO_START(eolith16);
3635   DECLARE_PALETTE_INIT(eolith16);
37   
3836   UINT32 screen_update_eolith16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3937};
4038
r242907r242908
4543   m_vbuffer = (data & 0x80) >> 7;
4644   coin_counter_w(machine(), 0, data & 1);
4745
48   m_eepromoutport->write(data, 0xff);
46   ioport("EEPROMOUT")->write(data, 0xff);
4947
5048   //data & 0x100 and data & 0x004 always set
5149}
5250
5351READ16_MEMBER(eolith16_state::eolith16_custom_r)
5452{
55   speedup_read();
53   eolith_speedup_read(space);
5654   return ioport("SPECIAL")->read();
5755}
5856
r242907r242908
115113VIDEO_START_MEMBER(eolith16_state,eolith16)
116114{
117115   m_vram = auto_alloc_array(machine(), UINT16, 0x10000);
118   save_pointer(NAME(m_vram), 0x10000);
119   save_item(NAME(m_vbuffer));
120116}
121117
122118UINT32 eolith16_state::screen_update_eolith16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r242907r242908
257253
258254DRIVER_INIT_MEMBER(eolith16_state,eolith16)
259255{
260   init_speedup();
256   init_eolith_speedup(machine());
261257}
262258
263GAME( 1999, klondkp, 0, eolith16, eolith16, eolith16_state, eolith16, ROT0, "Eolith", "KlonDike+", GAME_SUPPORTS_SAVE )
259GAME( 1999, klondkp, 0, eolith16, eolith16, eolith16_state, eolith16, ROT0, "Eolith", "KlonDike+", 0 )
trunk/src/mame/drivers/eolithsp.c
r242907r242908
99*/
1010
1111#include "emu.h"
12#include "includes/eolithsp.h"
1213#include "includes/eolith.h"
1314
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;
1420
15void eolith_state::speedup_read()
21void eolith_speedup_read(address_space &space)
1622{
1723   /* for debug */
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);
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);
2026
21   if (m_speedup_vblank==0 && m_speedup_scanline < m_speedup_resume_scanline)
27   if (eolith_vblank==0 && eolith_scanline < eolith_speedup_resume_scanline)
2228   {
23      int pc = m_maincpu->pc();
29      int pc = space.device().safe_pc();
2430
25      if ((pc==m_speedup_address) || (pc==m_speedup_address2))
31      if ((pc==eolith_speedup_address) || (pc==eolith_speedup_address2))
2632      {
27         m_maincpu->spin_until_trigger(1000);
33         space.device().execute().spin_until_trigger(1000);
2834      }
2935   }
3036}
r242907r242908
6571};
6672
6773
68void eolith_state::init_speedup()
74void init_eolith_speedup(running_machine &machine)
6975{
7076   int n_game = 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;
77   eolith_speedup_address = 0;
78   eolith_speedup_resume_scanline = 0;
7679
7780   while( eolith_speedup_table[ n_game ].s_name != NULL )
7881   {
79      if( strcmp( machine().system().name, eolith_speedup_table[ n_game ].s_name ) == 0 )
82      if( strcmp( machine.system().name, eolith_speedup_table[ n_game ].s_name ) == 0 )
8083      {
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;
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;
8487      }
8588      n_game++;
8689   }
87   
88   save_item(NAME(m_speedup_vblank));
89   save_item(NAME(m_speedup_scanline));
9090}
9191
9292/* todo, use timers instead! */
r242907r242908
9494{
9595   if (param==0)
9696   {
97      m_speedup_vblank = 0;
97      eolith_vblank = 0;
9898   }
9999
100   if (param==m_speedup_resume_scanline)
100   if (param==eolith_speedup_resume_scanline)
101101   {
102102      machine().scheduler().trigger(1000);
103103   }
104104
105105   if (param==240)
106106   {
107      m_speedup_vblank = 1;
107      eolith_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(), m_speedup_vblank);
113//  printf("%s:eolith speedup_read data %02x\n",machine().describe_context(), eolith_vblank);
114114
115115
116116   return (m_screen->vpos() >= 240);
r242907r242908
122122   int pc = m_maincpu->pc();
123123
124124   if (pc==0x400081ec)
125      if(!m_speedup_vblank)
125      if(!eolith_vblank)
126126         m_maincpu->eat_cycles(500);
127127
128128   return (m_screen->vpos() >= 240);
trunk/src/mame/drivers/sprint2.c
r242907r242908
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]);
103101      }
104102   }
105103
trunk/src/mame/drivers/stadhero.c
r242907r242908
3535   switch (offset<<1)
3636   {
3737      case 0:
38         return m_inputs->read();
38         return ioport("INPUTS")->read();
3939
4040      case 2:
41         return m_coin->read();
41         return ioport("COIN")->read();
4242
4343      case 4:
44         return m_dsw->read();
44         return ioport("DSW")->read();
4545   }
4646
4747   logerror("CPU #0 PC %06x: warning - read unmapped memory address %06x\n",space.device().safe_pc(),0x30c000+offset);
r242907r242908
305305
306306/******************************************************************************/
307307
308GAME( 1988, stadhero, 0, stadhero, stadhero, driver_device, 0, ROT0, "Data East Corporation", "Stadium Hero (Japan)", GAME_SUPPORTS_SAVE )
308GAME( 1988, stadhero, 0, stadhero, stadhero, driver_device, 0, ROT0, "Data East Corporation", "Stadium Hero (Japan)", 0 )
trunk/src/mame/drivers/vegaeo.c
r242907r242908
1616#include "machine/at28c16.h"
1717#include "sound/qs1000.h"
1818#include "includes/eolith.h"
19#include "includes/eolithsp.h"
1920
2021
2122class vegaeo_state : public eolith_state
r242907r242908
2627
2728   UINT32 *m_vega_vram;
2829   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
3536   DECLARE_READ8_MEMBER(qs1000_p1_r);
37
3638   DECLARE_WRITE8_MEMBER(qs1000_p1_w);
3739   DECLARE_WRITE8_MEMBER(qs1000_p2_w);
3840   DECLARE_WRITE8_MEMBER(qs1000_p3_w);
39
4041   DECLARE_DRIVER_INIT(vegaeo);
4142   DECLARE_VIDEO_START(vega);
42
4343   UINT32 screen_update_vega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
4444};
4545
r242907r242908
6262   // ...x .... - ?
6363   // ..x. .... - /IRQ clear
6464
65   qs1000_device *qs1000 = machine().device<qs1000_device>("qs1000");
66
6567   membank("qs1000:bank")->set_entry(data & 0x07);
6668
6769   if (!BIT(data, 5))
68      m_qs1000->set_irq(CLEAR_LINE);
70      qs1000->set_irq(CLEAR_LINE);
6971}
7072
7173WRITE32_MEMBER(vegaeo_state::vega_vram_w)
r242907r242908
113115
114116READ32_MEMBER(vegaeo_state::vegaeo_custom_read)
115117{
116   speedup_read();
118   eolith_speedup_read(space);
117119   return ioport("SYSTEM")->read();
118120}
119121
120122WRITE32_MEMBER(vegaeo_state::soundlatch_w)
121123{
124   qs1000_device *qs1000 = space.machine().device<qs1000_device>("qs1000");
125
122126   soundlatch_byte_w(space, 0, data);
123   m_qs1000->set_irq(ASSERT_LINE);
127   qs1000->set_irq(ASSERT_LINE);
124128
125129   machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(100));
126130}
r242907r242908
176180VIDEO_START_MEMBER(vegaeo_state,vega)
177181{
178182   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));
181183}
182184
183185UINT32 vegaeo_state::screen_update_vega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r242907r242908
326328   machine().device("qs1000:cpu")->memory().space(AS_IO).install_read_bank(0x0100, 0xffff, "bank");
327329   membank("qs1000:bank")->configure_entries(0, 8, memregion("qs1000:cpu")->base()+0x100, 0x10000);
328330
329   init_speedup();
331   init_eolith_speedup(machine());
330332}
331333
332GAME( 2002, crazywar, 0, vega, crazywar, vegaeo_state, vegaeo, ROT0, "Eolith", "Crazy War", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
334GAME( 2002, crazywar, 0, vega, crazywar, vegaeo_state, vegaeo, ROT0, "Eolith", "Crazy War", GAME_IMPERFECT_SOUND )
trunk/src/mame/drivers/xyonix.c
r242907r242908
2525#include "includes/xyonix.h"
2626
2727
28void xyonix_state::machine_start()
28WRITE8_MEMBER(xyonix_state::xyonix_irqack_w)
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{
3830   m_maincpu->set_input_line(0, CLEAR_LINE);
3931}
4032
r242907r242908
7971}
8072
8173
82READ8_MEMBER(xyonix_state::io_r)
74READ8_MEMBER(xyonix_state::xyonix_io_r)
8375{
8476   int regPC = space.device().safe_pc();
8577
r242907r242908
130122   return 0xff;
131123}
132124
133WRITE8_MEMBER(xyonix_state::io_w)
125WRITE8_MEMBER(xyonix_state::xyonix_io_w)
134126{
135127   //logerror ("xyonix_port_e0_w %02x - PC = %04x\n", data, space.device().safe_pc());
136128   m_e0_data = data;
r242907r242908
141133static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, xyonix_state )
142134   AM_RANGE(0x0000, 0xbfff) AM_ROM
143135   AM_RANGE(0xc000, 0xdfff) AM_RAM
144   AM_RANGE(0xe000, 0xffff) AM_RAM_WRITE(vidram_w) AM_SHARE("vidram")
136   AM_RANGE(0xe000, 0xffff) AM_RAM_WRITE(xyonix_vidram_w) AM_SHARE("vidram")
145137ADDRESS_MAP_END
146138
147139static ADDRESS_MAP_START( port_map, AS_IO, 8, xyonix_state )
r242907r242908
149141   AM_RANGE(0x20, 0x20) AM_READNOP AM_DEVWRITE("sn1", sn76496_device, write)   /* SN76496 ready signal */
150142   AM_RANGE(0x21, 0x21) AM_READNOP AM_DEVWRITE("sn2", sn76496_device, write)
151143   AM_RANGE(0x40, 0x40) AM_WRITENOP        /* NMI ack? */
152   AM_RANGE(0x50, 0x50) AM_WRITE(irqack_w)
144   AM_RANGE(0x50, 0x50) AM_WRITE(xyonix_irqack_w)
153145   AM_RANGE(0x60, 0x61) AM_WRITENOP        /* mc6845 */
154   AM_RANGE(0xe0, 0xe0) AM_READWRITE(io_r, io_w)
146   AM_RANGE(0xe0, 0xe0) AM_READWRITE(xyonix_io_r, xyonix_io_w)
155147ADDRESS_MAP_END
156148
157149/* Inputs Ports **************************************************************/
r242907r242908
234226   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
235227   MCFG_SCREEN_SIZE(80*4, 32*8)
236228   MCFG_SCREEN_VISIBLE_AREA(0, 80*4-1, 0, 28*8-1)
237   MCFG_SCREEN_UPDATE_DRIVER(xyonix_state, screen_update)
229   MCFG_SCREEN_UPDATE_DRIVER(xyonix_state, screen_update_xyonix)
238230   MCFG_SCREEN_PALETTE("palette")
239231
240232   MCFG_GFXDECODE_ADD("gfxdecode", "palette", xyonix)
r242907r242908
267259
268260/* GAME drivers **************************************************************/
269261
270GAME( 1989, xyonix, 0, xyonix, xyonix, driver_device, 0, ROT0, "Philko", "Xyonix", GAME_SUPPORTS_SAVE )
262GAME( 1989, xyonix, 0, xyonix, xyonix, driver_device, 0, ROT0, "Philko", "Xyonix", 0 )
trunk/src/mame/includes/eolith.h
r242907r242908
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"),
1513         m_in0(*this, "IN0"),
1614         m_eepromoutport(*this, "EEPROMOUT"),
1715         m_penx1port(*this, "PEN_X_P1"),
1816         m_peny1port(*this, "PEN_Y_P1"),
1917         m_penx2port(*this, "PEN_X_P2"),
2018         m_peny2port(*this, "PEN_Y_P2"),
21         m_sndbank(*this, "sound_bank")
19         m_sndbank(*this, "sound_bank"),
20         m_screen(*this, "screen"),
21         m_palette(*this, "palette")
2222      { }
2323
24   int m_coin_counter_bit;
25   int m_buffer;
26   UINT32 *m_vram;
2427
28   UINT8 m_sound_data;
29   UINT8 m_data_to_qs1000;
30
2531   required_device<cpu_device> m_maincpu;
2632   optional_device<i8032_device> m_soundcpu;
2733   optional_device<qs1000_device> m_qs1000;
28   required_device<screen_device> m_screen;
29   required_device<palette_device> m_palette;
30   
3134   optional_ioport m_in0; // klondkp doesn't have it
3235   optional_ioport m_eepromoutport;
3336   optional_ioport m_penx1port;
3437   optional_ioport m_peny1port;
3538   optional_ioport m_penx2port;
3639   optional_ioport m_peny2port;
37   
3840   optional_memory_bank m_sndbank;
39   
40   int m_coin_counter_bit;
41   int m_buffer;
42   UINT32 *m_vram;
41   required_device<screen_device> m_screen;
42   required_device<palette_device> m_palette;
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
5744   DECLARE_READ32_MEMBER(eolith_custom_r);
5845   DECLARE_WRITE32_MEMBER(systemcontrol_w);
5946   DECLARE_WRITE32_MEMBER(sound_w);
r242907r242908
6148   DECLARE_READ32_MEMBER(hidctch3_pen2_r);
6249   DECLARE_WRITE32_MEMBER(eolith_vram_w);
6350   DECLARE_READ32_MEMBER(eolith_vram_r);
51   DECLARE_CUSTOM_INPUT_MEMBER(eolith_speedup_getvblank);
52   DECLARE_CUSTOM_INPUT_MEMBER(stealsee_speedup_getvblank);
53
6454   DECLARE_READ8_MEMBER(sound_cmd_r);
6555   DECLARE_WRITE8_MEMBER(sound_p1_w);
56
6657   DECLARE_READ8_MEMBER(qs1000_p1_r);
6758   DECLARE_WRITE8_MEMBER(qs1000_p1_w);
68   DECLARE_WRITE8_MEMBER(soundcpu_to_qs1000);
69   
7059   DECLARE_DRIVER_INIT(eolith);
7160   DECLARE_DRIVER_INIT(landbrk);
7261   DECLARE_DRIVER_INIT(hidctch3);
7362   DECLARE_DRIVER_INIT(hidctch2);
7463   DECLARE_DRIVER_INIT(hidnc2k);
7564   DECLARE_DRIVER_INIT(landbrka);
76   
7765   DECLARE_MACHINE_RESET(eolith);
7866   DECLARE_VIDEO_START(eolith);
79   
8067   UINT32 screen_update_eolith(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
81   
8268   TIMER_DEVICE_CALLBACK_MEMBER(eolith_speedup);
69   DECLARE_WRITE8_MEMBER(soundcpu_to_qs1000);
8370};
trunk/src/mame/includes/eolithsp.h
r0r242908
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
r242907r242908
1010      m_audiocpu(*this, "audiocpu"),
1111      m_tilegen1(*this, "tilegen1"),
1212      m_spritegen(*this, "spritegen"),
13      m_gfxdecode(*this, "gfxdecode"),
1413      m_spriteram(*this, "spriteram"),
1514      m_pf1_data(*this, "pf1_data"),
16      m_inputs(*this, "INPUTS"),
17      m_coin(*this, "COIN"),
18      m_dsw(*this, "DSW") { }
15      m_gfxdecode(*this, "gfxdecode") { }
1916
2017   required_device<cpu_device> m_maincpu;
2118   required_device<cpu_device> m_audiocpu;
2219   required_device<deco_bac06_device> m_tilegen1;
2320   required_device<deco_mxc06_device> m_spritegen;
24   required_device<gfxdecode_device> m_gfxdecode;
25   
2621   required_shared_ptr<UINT16> m_spriteram;
2722   required_shared_ptr<UINT16> m_pf1_data;
28   
29   required_ioport m_inputs;
30   required_ioport m_coin;
31   required_ioport m_dsw;
23   required_device<gfxdecode_device> m_gfxdecode;
3224
3325   tilemap_t *m_pf1_tilemap;
34   
26   int m_flipscreen;
3527   DECLARE_READ16_MEMBER(stadhero_control_r);
3628   DECLARE_WRITE16_MEMBER(stadhero_control_w);
3729   DECLARE_WRITE16_MEMBER(stadhero_pf1_data_w);
38   DECLARE_WRITE_LINE_MEMBER(irqhandler);
39   
40   virtual void video_start();
41   
4230   TILE_GET_INFO_MEMBER(get_pf1_tile_info);
31   virtual void video_start();
4332   UINT32 screen_update_stadhero(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
33   DECLARE_WRITE_LINE_MEMBER(irqhandler);
4434};
trunk/src/mame/includes/vaportra.h
r242907r242908
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
2635   /* devices */
2736   required_device<cpu_device> m_maincpu;
2837   required_device<cpu_device> m_audiocpu;
r242907r242908
3140   required_device<deco_mxc06_device> m_spritegen;
3241   required_device<buffered_spriteram16_device> m_spriteram;
3342   required_device<palette_device> m_palette;
34
3543   required_shared_ptr<UINT16> m_generic_paletteram_16;
3644   required_shared_ptr<UINT16> m_generic_paletteram2_16;
3745
38   /* misc */
39   UINT16    m_priority[2];
40
4146   DECLARE_WRITE16_MEMBER(vaportra_sound_w);
4247   DECLARE_READ16_MEMBER(vaportra_control_r);
4348   DECLARE_READ8_MEMBER(vaportra_soundlatch_r);
4449   DECLARE_WRITE16_MEMBER(vaportra_priority_w);
4550   DECLARE_WRITE16_MEMBER(vaportra_palette_24bit_rg_w);
4651   DECLARE_WRITE16_MEMBER(vaportra_palette_24bit_b_w);
47   
4852   DECLARE_DRIVER_INIT(vaportra);
4953   virtual void machine_start();
5054   virtual void machine_reset();
51   
5255   UINT32 screen_update_vaportra(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5356   void update_24bitcol( int offset );
54   
5557   DECO16IC_BANK_CB_MEMBER(bank_callback);
5658};
trunk/src/mame/includes/xyonix.h
r242907r242908
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"),
67      m_maincpu(*this, "maincpu"),
7      m_gfxdecode(*this, "gfxdecode"),
8      m_vidram(*this, "vidram") { }
8      m_gfxdecode(*this, "gfxdecode") { }
99
10   required_device<cpu_device> m_maincpu;
11   required_device<gfxdecode_device> m_gfxdecode;
12   
1310   required_shared_ptr<UINT8> m_vidram;
14   
1511   tilemap_t *m_tilemap;
1612
1713   int m_e0_data;
1814   int m_credits;
1915   int m_coins;
2016   int m_prev_coin;
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();
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);
2822   virtual void video_start();
29   TILE_GET_INFO_MEMBER(get_tile_info);
3023   DECLARE_PALETTE_INIT(xyonix);
31   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
32   
24   UINT32 screen_update_xyonix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3325   void handle_coins(int coin);
26   required_device<cpu_device> m_maincpu;
27   required_device<gfxdecode_device> m_gfxdecode;
3428};
trunk/src/mame/video/eolith.c
r242907r242908
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));
3836}
3937
4038UINT32 eolith_state::screen_update_eolith(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
4139{
42   for (int y = 0; y < 240; y++)
40   int y;
41
42   for (y = 0; y < 240; y++)
4343   {
44      int x;
4445      UINT32 *src = &m_vram[(m_buffer ? 0 : 0x10000) | (y * (336 / 2))];
4546      UINT16 *dest = &bitmap.pix16(y);
4647
47      for (int x = 0; x < 320; x += 2)
48      for (x = 0; x < 320; x += 2)
4849      {
4950         dest[0] = (*src >> 16) & 0x7fff;
5051         dest[1] = (*src >>  0) & 0x7fff;
trunk/src/mame/video/stadhero.c
r242907r242908
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
2325   flip_screen_set(m_tilegen1->get_flip_state());
2426
2527   m_tilegen1->set_bppmultmask(0x8, 0x7);
r242907r242908
5456
5557void stadhero_state::video_start()
5658{
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);
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);
5860   m_pf1_tilemap->set_transparent_pen(0);
5961}
6062
trunk/src/mame/video/xyonix.c
r242907r242908
3131}
3232
3333
34TILE_GET_INFO_MEMBER(xyonix_state::get_tile_info)
34TILE_GET_INFO_MEMBER(xyonix_state::get_xyonix_tile_info)
3535{
3636   int tileno;
3737   int attr = m_vidram[tile_index+0x1000+1];
r242907r242908
4141   SET_TILE_INFO_MEMBER(0,tileno,attr >> 4,0);
4242}
4343
44WRITE8_MEMBER(xyonix_state::vidram_w)
44WRITE8_MEMBER(xyonix_state::xyonix_vidram_w)
4545{
4646   m_vidram[offset] = data;
4747   m_tilemap->mark_tile_dirty((offset-1)&0x0fff);
r242907r242908
4949
5050void xyonix_state::video_start()
5151{
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);
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);
5353}
5454
55UINT32 xyonix_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
55UINT32 xyonix_state::screen_update_xyonix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
5656{
5757   m_tilemap->draw(screen, bitmap, cliprect, 0, 0);
5858   return 0;
trunk/src/osd/sdl/input.c
r242907r242908
14161416   }
14171417
14181418   // get Sixaxis special mode info
1419   sixaxis_mode = downcast<sdl_options &>(machine().options()).sixaxis();
1419   sixaxis_mode = options().sixaxis();
14201420
14211421   // register the joysticks
14221422   sdlinput_register_joysticks(machine());
r242907r242908
20862086      {
20872087         // configurable UI mode switch
20882088         case IPT_UI_TOGGLE_UI:
2089            uimode = downcast<sdl_options &>(machine().options()).ui_mode_key();
2089            uimode = options().ui_mode_key();
20902090            if(!strcmp(uimode,"auto"))
20912091            {
20922092               #if defined(__APPLE__) && defined(__MACH__)
trunk/src/osd/sdl/osdsdl.h
r242907r242908
66#include "watchdog.h"
77#include "clifront.h"
88#include "modules/lib/osdobj_common.h"
9#include "video.h"
910
1011//============================================================
1112//  System dependent defines
r242907r242908
224225
225226private:
226227   virtual void osd_exit();
227    sdl_options &m_options;
228228
229   watchdog *m_watchdog;
229   void extract_window_config(int index, sdl_window_config *conf);
230230
231};
231   // FIXME: remove machine usage
232   void extract_video_config(running_machine &machine);
232233
233234
235    sdl_options &m_options;
234236
235//============================================================
236//  sound.c
237//============================================================
237   watchdog *m_watchdog;
238238
239void sdlaudio_init(running_machine &machine);
239};
240240
241241//============================================================
242242//  sdlwork.c
trunk/src/osd/sdl/sdlmain.c
r242907r242908
589589   // call our parent
590590   osd_common_t::init(machine);
591591
592   sdl_options &options = downcast<sdl_options &>(machine.options());
593592   const char *stemp;
594593
595594   // determine if we are benchmarking, and adjust options appropriately
596   int bench = options.bench();
595   int bench = options().bench();
597596   astring error_string;
598597   if (bench > 0)
599598   {
600      options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM, error_string);
601      options.set_value(OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM, error_string);
602      options.set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM, error_string);
603      options.set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM, error_string);
599      options().set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM, error_string);
600      options().set_value(OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM, error_string);
601      options().set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM, error_string);
602      options().set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM, error_string);
604603      assert(!error_string);
605604   }
606605
607606   // Some driver options - must be before audio init!
608   stemp = options.audio_driver();
607   stemp = options().audio_driver();
609608   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
610609   {
611610      osd_printf_verbose("Setting SDL audiodriver '%s' ...\n", stemp);
612611      osd_setenv(SDLENV_AUDIODRIVER, stemp, 1);
613612   }
614613
615   stemp = options.video_driver();
614   stemp = options().video_driver();
616615   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
617616   {
618617      osd_printf_verbose("Setting SDL videodriver '%s' ...\n", stemp);
r242907r242908
620619   }
621620
622621#if (SDLMAME_SDL2)
623      stemp = options.render_driver();
622      stemp = options().render_driver();
624623      if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
625624      {
626625         osd_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp);
r242907r242908
635634#if USE_OPENGL
636635   /* FIXME: move lib loading code from drawogl.c here */
637636
638   stemp = options.gl_lib();
637   stemp = options().gl_lib();
639638   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
640639   {
641640      osd_setenv("SDL_VIDEO_GL_DRIVER", stemp, 1);
r242907r242908
644643#endif
645644
646645   /* get number of processors */
647   stemp = options.numprocessors();
646   stemp = options().numprocessors();
648647
649648   osd_num_processors = 0;
650649
r242907r242908
685684
686685   osd_common_t::init_subsystems();
687686
688   if (options.oslog())
687   if (options().oslog())
689688      machine.add_logerror_callback(output_oslog);
690689
691690   /* now setup watchdog */
692691
693   int watchdog_timeout = options.watchdog();
692   int watchdog_timeout = options().watchdog();
694693
695694   if (watchdog_timeout != 0)
696695   {
r242907r242908
10371036   if (!font)
10381037   {
10391038      osd_printf_verbose("Searching font %s in -%s\n", name.cstr(), OPTION_FONTPATH);
1040      emu_file file(machine().options().font_path(), OPEN_FLAG_READ);
1039      emu_file file(options().font_path(), OPEN_FLAG_READ);
10411040      if (file.open(name) == FILERR_NONE)
10421041      {
10431042         astring full_name = file.fullpath();
trunk/src/osd/sdl/video.c
r242907r242908
8585
8686static void check_osd_inputs(running_machine &machine);
8787
88static void extract_video_config(running_machine &machine);
89static void extract_window_config(running_machine &machine, int index, sdl_window_config *conf);
9088static float get_aspect(const char *defdata, const char *data, int report_error);
9189static void get_resolution(const char *defdata, const char *data, sdl_window_config *config, int report_error);
9290
r242907r242908
106104   init_monitors();
107105
108106   // we need the beam width in a float, contrary to what the core does.
109   video_config.beamwidth = machine().options().beam();
107   video_config.beamwidth = options().beam();
110108
111109   // initialize the window system so we can make windows
112110   if (!window_init())
113111      return false;
114112
115113   // create the windows
116   sdl_options &options = downcast<sdl_options &>(machine().options());
117114   for (index = 0; index < video_config.numscreens; index++)
118115   {
119116      sdl_window_config conf;
120117      memset(&conf, 0, sizeof(conf));
121      extract_window_config(machine(), index, &conf);
122      if (sdlwindow_video_window_create(machine(), index, pick_monitor(options, index), &conf))
118      extract_window_config(index, &conf);
119      if (sdlwindow_video_window_create(machine(), index, pick_monitor(options(), index), &conf))
123120         return false;
124121   }
125122
r242907r242908
615612//  extract_window_config
616613//============================================================
617614
618static void extract_window_config(running_machine &machine, int index, sdl_window_config *conf)
615void sdl_osd_interface::extract_window_config(int index, sdl_window_config *conf)
619616{
620   sdl_options &options = downcast<sdl_options &>(machine.options());
621617   // per-window options: extract the data
622   get_resolution(options.resolution(), options.resolution(index), conf, TRUE);
618   get_resolution(options().resolution(), options().resolution(index), conf, TRUE);
623619}
624620
625621//============================================================
626622//  extract_video_config
627623//============================================================
628624
629static void extract_video_config(running_machine &machine)
625void sdl_osd_interface::extract_video_config(running_machine &machine)
630626{
631627   const char *stemp;
632   sdl_options &options = downcast<sdl_options &>(machine.options());
633628
634   video_config.perftest    = options.video_fps();
629   video_config.perftest    = options().video_fps();
635630
636631   // global options: extract the data
637   video_config.windowed      = options.window();
638   video_config.keepaspect    = options.keep_aspect();
639   video_config.numscreens    = options.numscreens();
640   video_config.fullstretch   = options.uneven_stretch();
632   video_config.windowed      = options().window();
633   video_config.keepaspect    = options().keep_aspect();
634   video_config.numscreens    = options().numscreens();
635   video_config.fullstretch   = options().uneven_stretch();
641636   #ifdef SDLMAME_X11
642   video_config.restrictonemonitor = !options.use_all_heads();
637   video_config.restrictonemonitor = !options().use_all_heads();
643638   #endif
644639
645640
r242907r242908
650645   video_config.novideo = 0;
651646
652647   // d3d options: extract the data
653   stemp = options.video();
648   stemp = options().video();
654649   if (strcmp(stemp, "auto") == 0)
655650   {
656651#ifdef SDLMAME_MACOSX
r242907r242908
666661      video_config.mode = VIDEO_MODE_SOFT;
667662      video_config.novideo = 1;
668663
669      if (options.seconds_to_run() == 0)
664      if (options().seconds_to_run() == 0)
670665         osd_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n");
671666   }
672667   else if (USE_OPENGL && (strcmp(stemp, SDLOPTVAL_OPENGL) == 0))
r242907r242908
681676      video_config.mode = VIDEO_MODE_SOFT;
682677   }
683678
684   video_config.switchres     = options.switch_res();
685   video_config.centerh       = options.centerh();
686   video_config.centerv       = options.centerv();
687   video_config.waitvsync     = options.wait_vsync();
688   video_config.syncrefresh   = options.sync_refresh();
679   video_config.switchres     = options().switch_res();
680   video_config.centerh       = options().centerh();
681   video_config.centerv       = options().centerv();
682   video_config.waitvsync     = options().wait_vsync();
683   video_config.syncrefresh   = options().sync_refresh();
689684   if (!video_config.waitvsync && video_config.syncrefresh)
690685   {
691686      osd_printf_warning("-syncrefresh specified without -waitsync. Reverting to -nosyncrefresh\n");
r242907r242908
693688   }
694689
695690   #if (USE_OPENGL || SDLMAME_SDL2)
696      video_config.filter        = options.filter();
691      video_config.filter        = options().filter();
697692   #endif
698693
699694   #if (USE_OPENGL)
700      video_config.prescale      = options.prescale();
695      video_config.prescale      = options().prescale();
701696      if (video_config.prescale < 1 || video_config.prescale > 3)
702697      {
703698         osd_printf_warning("Invalid prescale option, reverting to '1'\n");
704699         video_config.prescale = 1;
705700      }
706701      // default to working video please
707      video_config.forcepow2texture = options.gl_force_pow2_texture();
708      video_config.allowtexturerect = !(options.gl_no_texture_rect());
709      video_config.vbo         = options.gl_vbo();
710      video_config.pbo         = options.gl_pbo();
711      video_config.glsl        = options.gl_glsl();
702      video_config.forcepow2texture = options().gl_force_pow2_texture();
703      video_config.allowtexturerect = !(options().gl_no_texture_rect());
704      video_config.vbo         = options().gl_vbo();
705      video_config.pbo         = options().gl_pbo();
706      video_config.glsl        = options().gl_glsl();
712707      if ( video_config.glsl )
713708      {
714709         int i;
715710
716         video_config.glsl_filter = options.glsl_filter();
711         video_config.glsl_filter = options().glsl_filter();
717712
718713         video_config.glsl_shader_mamebm_num=0;
719714
720715         for(i=0; i<GLSL_SHADER_MAX; i++)
721716         {
722            stemp = options.shader_mame(i);
717            stemp = options().shader_mame(i);
723718            if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
724719            {
725720               video_config.glsl_shader_mamebm[i] = (char *) malloc(strlen(stemp)+1);
r242907r242908
734729
735730         for(i=0; i<GLSL_SHADER_MAX; i++)
736731         {
737            stemp = options.shader_screen(i);
732            stemp = options().shader_screen(i);
738733            if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
739734            {
740735               video_config.glsl_shader_scrn[i] = (char *) malloc(strlen(stemp)+1);
r242907r242908
777772   }
778773#endif
779774   // yuv settings ...
780   stemp = options.scale_mode();
775   stemp = options().scale_mode();
781776   video_config.scale_mode = drawsdl_scale_mode(stemp);
782777   if (video_config.scale_mode < 0)
783778   {
trunk/src/osd/sdl/window.c
r242907r242908
222222{
223223   osd_printf_verbose("Enter sdlwindow_init\n");
224224   // determine if we are using multithreading or not
225   multithreading_enabled = downcast<sdl_options &>(machine().options()).multithreading();
225   multithreading_enabled = options().multithreading();
226226
227227   // get the main thread ID before anything else
228228   main_threadid = SDL_ThreadID();


Previous 199869 Revisions Next


© 1997-2024 The MAME Team