Previous 199869 Revisions Next

r34257 Thursday 8th January, 2015 at 08:36:33 UTC by Olivier Galibert
Merge pull request #96 from RealComboman/patch-1

added outputs so artwork can display current gear settings
[src/emu/ui]devctrl.h mainmenu.c mainmenu.h tapectrl.c tapectrl.h
[src/osd/sdl]sdl.mak

trunk/src/emu/ui/devctrl.h
r242768r242769
22
33    ui/devctrl.h
44
5    Device specific control (base class for tapectrl)
5    Device specific control menu
6    This source provides a base class for any device which need a specific
7    submenu and which can occur multiple times in the same driver (at the
8    moment, cassette tapes and barcode readers, in future possibly other like
9    printers)
10    The base class contains calls to get the total number of devices of
11    the same kind connected to the driver, and shortcuts to switch current
12    device to next one or previous one attached. This allows, for instance,
13    users to pass from a device to another one by simply pressing left/right
14    and the menu is rebuilt accordingly, without the need of a preliminary
15    submenu listing available devices of the same kind.
616
717    Copyright Nicola Salmoria and the MAME Team.
818    Visit http://mamedev.org for licensing and usage restrictions.
r242768r242769
2737   int current_index();
2838   void previous();
2939   void next();
40   astring current_display_name();
3041
3142private:
3243   // device iterator
r242768r242769
104115   }
105116}
106117
118
119//-------------------------------------------------
120//  current_display_name
121//-------------------------------------------------
122
123template<class _DeviceType>
124astring ui_menu_device_control<_DeviceType>::current_display_name()
125{
126   astring display_name;
127   display_name.cpy(current_device()->device().name());
128   if (count() > 1)
129   {
130      astring temp;
131      temp.printf(" %d", current_index() + 1);
132      display_name.cat(temp);
133   }
134   return display_name;
135}
136
107137#endif /* __UI_DEVCTRL_H__ */
trunk/src/emu/ui/mainmenu.c
r242768r242769
8484      /* add tape control menu */
8585      cassette_device_iterator cassiter(machine().root_device());
8686      if (cassiter.first() != NULL)
87         item_append("Tape Control", NULL, 0, (void *)MESS_MENU_TAPE_CONTROL);
87         item_append("Tape Control", NULL, 0, (void *)TAPE_CONTROL);
8888   }
8989
9090   if (machine().ioport().has_bioses())
r242768r242769
184184         ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_manager(machine(), container)));
185185         break;
186186
187      case MESS_MENU_TAPE_CONTROL:
188         ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_mess_tape_control(machine(), container, NULL)));
187      case TAPE_CONTROL:
188         ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_tape_control(machine(), container, NULL)));
189189         break;
190190
191191      case SLOT_DEVICES:
trunk/src/emu/ui/mainmenu.h
r242768r242769
3535      GAME_INFO,
3636      IMAGE_MENU_IMAGE_INFO,
3737      IMAGE_MENU_FILE_MANAGER,
38      MESS_MENU_TAPE_CONTROL,
38      TAPE_CONTROL,
3939      SLOT_DEVICES,
4040      NETWORK_DEVICES,
4141      KEYBOARD_MODE,
trunk/src/emu/ui/tapectrl.c
r242768r242769
22
33    ui/tapectrl.c
44
5    MESS's tape control
5    Tape control
66
77    Copyright Nicola Salmoria and the MAME Team.
88    Visit http://mamedev.org for licensing and usage restrictions.
r242768r242769
1212#include "emu.h"
1313#include "ui/tapectrl.h"
1414
15
16
1715/***************************************************************************
1816    CONSTANTS
1917***************************************************************************/
r242768r242769
2321#define TAPECMD_PLAY            ((void *) 0x0002)
2422#define TAPECMD_RECORD          ((void *) 0x0003)
2523#define TAPECMD_REWIND          ((void *) 0x0004)
26#define TAPECMD_FAST_FORWARD        ((void *) 0x0005)
24#define TAPECMD_FAST_FORWARD    ((void *) 0x0005)
2725#define TAPECMD_SLIDER          ((void *) 0x0006)
2826#define TAPECMD_SELECT          ((void *) 0x0007)
2927
r242768r242769
3634//  ctor
3735//-------------------------------------------------
3836
39ui_menu_mess_tape_control::ui_menu_mess_tape_control(running_machine &machine, render_container *container, cassette_image_device *device)
37ui_menu_tape_control::ui_menu_tape_control(running_machine &machine, render_container *container, cassette_image_device *device)
4038   : ui_menu_device_control<cassette_image_device>(machine, container, device)
4139{
4240}
r242768r242769
4644//  dtor
4745//-------------------------------------------------
4846
49ui_menu_mess_tape_control::~ui_menu_mess_tape_control()
47ui_menu_tape_control::~ui_menu_tape_control()
5048{
5149}
5250
r242768r242769
5553//  populate - populates the main tape control menu
5654//-------------------------------------------------
5755
58void ui_menu_mess_tape_control::populate()
56void ui_menu_tape_control::populate()
5957{
60   astring timepos;
61   cassette_state state;
6258   UINT32 flags = 0;
6359
6460   if (count() > 1)
6561   {
66      int index = current_index();
67
68      if( index == (count()-1) )
62      if (current_index() == (count() - 1))
6963         flags |= MENU_FLAG_LEFT_ARROW;
7064      else
7165         flags |= MENU_FLAG_RIGHT_ARROW;
7266   }
7367
74   if ((current_device() != NULL) && (current_device()->exists()))
75   {
76      double t0, t1;
77      UINT32 tapeflags = 0;
68   if (current_device())
69   {     
70      // name of tape
71      item_append(current_display_name().cstr(), current_device()->exists() ? current_device()->filename() : "No Tape Image loaded", flags, TAPECMD_SELECT);
7872
79      t0 = current_device()->get_position();
80      t1 = current_device()->get_length();
81
82      if (t1 > 0)
73      if (current_device()->exists())
8374      {
84         if (t0 > 0)
85            tapeflags |= MENU_FLAG_LEFT_ARROW;
86         if (t0 < t1)
87            tapeflags |= MENU_FLAG_RIGHT_ARROW;
75         astring timepos;
76         cassette_state state;
77         double t0 = current_device()->get_position();
78         double t1 = current_device()->get_length();
79         UINT32 tapeflags = 0;
80         
81         // state
82         if (t1 > 0)
83         {
84            if (t0 > 0)
85               tapeflags |= MENU_FLAG_LEFT_ARROW;
86            if (t0 < t1)
87               tapeflags |= MENU_FLAG_RIGHT_ARROW;
88         }
89         
90         get_time_string(timepos, current_device(), NULL, NULL);
91         state = current_device()->get_state();
92         item_append(
93                  (state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED
94                  ?   "stopped"
95                  :   ((state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY
96                      ? ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "playing" : "(playing)")
97                      : ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "recording" : "(recording)")
98                      ),
99                  timepos,
100                  tapeflags,
101                  TAPECMD_SLIDER);
102         
103         // pause or stop
104         item_append("Pause/Stop", NULL, 0, TAPECMD_STOP);
105         
106         // play
107         item_append("Play", NULL, 0, TAPECMD_PLAY);
108         
109         // record
110         item_append("Record", NULL, 0, TAPECMD_RECORD);
111         
112         // rewind
113         item_append("Rewind", NULL, 0, TAPECMD_REWIND);
114         
115         // fast forward
116         item_append("Fast Forward", NULL, 0, TAPECMD_FAST_FORWARD);
88117      }
89
90      // name of tape
91      item_append(current_device()->device().name(), current_device()->filename(), flags, TAPECMD_SELECT);
92
93      // state
94      get_time_string(timepos, current_device(), NULL, NULL);
95      state = current_device()->get_state();
96      item_append(
97         (state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED
98            ?   "stopped"
99            :   ((state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY
100               ? ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "playing" : "(playing)")
101               : ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "recording" : "(recording)")
102               ),
103         timepos,
104         tapeflags,
105         TAPECMD_SLIDER);
106
107      // pause or stop
108      item_append("Pause/Stop", NULL, 0, TAPECMD_STOP);
109
110      // play
111      item_append("Play", NULL, 0, TAPECMD_PLAY);
112
113      // record
114      item_append("Record", NULL, 0, TAPECMD_RECORD);
115
116      // rewind
117      item_append("Rewind", NULL, 0, TAPECMD_REWIND);
118
119      // fast forward
120      item_append("Fast Forward", NULL, 0, TAPECMD_FAST_FORWARD);
121118   }
122   else
123   {
124      // no tape loaded in this cassette device (but there could be more than one!)
125      if (count() > 1)
126         item_append("No Tape Image loaded", "", flags, TAPECMD_SELECT);
127      else
128         item_append("No Tape Image loaded", NULL, 0, NULL);
129   }
130119}
131120
132121
r242768r242769
134123//  handle - main tape control menu
135124//-------------------------------------------------
136125
137void ui_menu_mess_tape_control::handle()
126void ui_menu_tape_control::handle()
138127{
139128   // rebuild the menu - we have to do this so that the counter updates
140129   reset(UI_MENU_RESET_REMEMBER_POSITION);
r242768r242769
147136      switch(event->iptkey)
148137      {
149138         case IPT_UI_LEFT:
150            if (event->itemref==TAPECMD_SLIDER)
139            if (event->itemref == TAPECMD_SLIDER)
151140               current_device()->seek(-1, SEEK_CUR);
152            else if (event->itemref==TAPECMD_SELECT)
141            else if (event->itemref == TAPECMD_SELECT)
153142               previous();
154143            break;
155144
156145         case IPT_UI_RIGHT:
157            if (event->itemref==TAPECMD_SLIDER)
146            if (event->itemref == TAPECMD_SLIDER)
158147               current_device()->seek(+1, SEEK_CUR);
159            else if (event->itemref==TAPECMD_SELECT)
148            else if (event->itemref == TAPECMD_SELECT)
160149               next();
161150            break;
162151
163152         case IPT_UI_SELECT:
164            {
165               if (event->itemref==TAPECMD_STOP)
166                  current_device()->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
167               else if (event->itemref==TAPECMD_PLAY)
168                  current_device()->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
169               else if (event->itemref==TAPECMD_RECORD)
170                  current_device()->change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE);
171               else if (event->itemref==TAPECMD_REWIND)
172                  current_device()->seek(-30, SEEK_CUR);
173               else if (event->itemref==TAPECMD_FAST_FORWARD)
174                  current_device()->seek(30, SEEK_CUR);
175               else if (event->itemref==TAPECMD_SLIDER)
176                  current_device()->seek(0, SEEK_SET);
177            }
153            if (event->itemref == TAPECMD_STOP)
154               current_device()->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
155            else if (event->itemref == TAPECMD_PLAY)
156               current_device()->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
157            else if (event->itemref == TAPECMD_RECORD)
158               current_device()->change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE);
159            else if (event->itemref == TAPECMD_REWIND)
160               current_device()->seek(-30, SEEK_CUR);
161            else if (event->itemref == TAPECMD_FAST_FORWARD)
162               current_device()->seek(30, SEEK_CUR);
163            else if (event->itemref == TAPECMD_SLIDER)
164               current_device()->seek(0, SEEK_SET);
178165            break;
179166      }
180167   }
r242768r242769
186173//  representation of the time
187174//-------------------------------------------------
188175
189void ui_menu_mess_tape_control::get_time_string(astring &dest, cassette_image_device *cassette, int *curpos, int *endpos)
176void ui_menu_tape_control::get_time_string(astring &dest, cassette_image_device *cassette, int *curpos, int *endpos)
190177{
191178   double t0, t1;
192179
trunk/src/emu/ui/tapectrl.h
r242768r242769
22
33    ui/tapectrl.h
44
5    MESS's tape control
5    Tape control
66
77    Copyright Nicola Salmoria and the MAME Team.
88    Visit http://mamedev.org for licensing and usage restrictions.
r242768r242769
1717#include "imagedev/cassette.h"
1818#include "ui/devctrl.h"
1919
20class ui_menu_mess_tape_control : public ui_menu_device_control<cassette_image_device> {
20class ui_menu_tape_control : public ui_menu_device_control<cassette_image_device> {
2121public:
22   ui_menu_mess_tape_control(running_machine &machine, render_container *container, cassette_image_device *device);
23   virtual ~ui_menu_mess_tape_control();
22   ui_menu_tape_control(running_machine &machine, render_container *container, cassette_image_device *device);
23   virtual ~ui_menu_tape_control();
2424   virtual void populate();
2525   virtual void handle();
2626
trunk/src/osd/sdl/sdl.mak
r242768r242769
657657endif
658658
659659ifeq ($(SDL_LIBVER),sdl2)
660LIBS += -lSDL2 -lImm32 -lversion -lole32 -loleaut32 -static
661BASELIBS += -lImm32 -lversion -lole32 -loleaut32 -static
660LIBS += -lSDL2 -limm32 -lversion -lole32 -loleaut32 -lws2_32 -static
661BASELIBS += -limm32 -lversion -lole32 -loleaut32 -lws2_32 -static
662662else
663663LIBS += -lSDL -static
664664endif


Previous 199869 Revisions Next


© 1997-2024 The MAME Team