]> Pileus Git - ~andy/sunrise/blob - games-emulation/sdlmame/files/0.120a/inpview.patch
games-emulation/sdlmame: Removed version information from patches names.
[~andy/sunrise] / games-emulation / sdlmame / files / 0.120a / inpview.patch
1 diff -Nru base0120/src/emu/emu.mak w0120/src/emu/emu.mak
2 --- base0120/src/emu/emu.mak    2007-10-15 19:58:53.000000000 +1300
3 +++ w0120/src/emu/emu.mak       2007-10-16 01:00:34.000000000 +1300
4 @@ -75,6 +75,7 @@
5         $(EMUOBJ)/uitext.o \
6         $(EMUOBJ)/validity.o \
7         $(EMUOBJ)/video.o \
8 +       $(EMUOBJ)/inpview.o \
9  
10  ifdef PROFILER
11  EMUOBJS += \
12 diff -Nru base0120/src/emu/emuopts.c w0120/src/emu/emuopts.c
13 --- base0120/src/emu/emuopts.c  2007-09-11 18:16:58.000000000 +1200
14 +++ w0120/src/emu/emuopts.c     2007-10-16 00:58:01.000000000 +1300
15 @@ -156,6 +156,8 @@
16         { "bios",                        "default",   0,                 "select the system BIOS to use" },
17         { "cheat;c",                     "0",         OPTION_BOOLEAN,    "enable cheat subsystem" },
18         { "skip_gameinfo",               "0",         OPTION_BOOLEAN,    "skip displaying the information screen at startup" },
19 +       { "inpview;iv",                      "0",         0,                 "enable input viewer" },
20 +       { "inplayout;il",                "standard",  0,                 "set input viewer layout type" },
21  
22         { NULL }
23  };
24 diff -Nru base0120/src/emu/inptport.c w0120/src/emu/inptport.c
25 --- base0120/src/emu/inptport.c 2007-09-29 15:57:09.000000000 +1200
26 +++ w0120/src/emu/inptport.c    2007-10-16 00:58:01.000000000 +1300
27 @@ -106,6 +106,7 @@
28  #include "inputx.h"
29  #endif
30  
31 +#include "inpview.h"
32  
33  /***************************************************************************
34      CONSTANTS
35 @@ -1140,6 +1141,9 @@
36         /* register callbacks for when we load configurations */
37         config_register("input", input_port_load, input_port_save);
38  
39 +       /* INPVIEW: initialise -inpview and -inplayout options */
40 +       inpview_set_data(options_get_int(mame_options(),"inpview"),options_get_string(mame_options(),"inplayout"));
41 +
42         /* open playback and record files if specified */
43         setup_playback(machine);
44         setup_record(machine);
45 @@ -3599,3 +3603,30 @@
46                                 break;
47                         }
48  }
49 +
50 +int input_port_used(int type,int player)
51 +{
52 +       int portnum, bitnum;
53 +
54 +       /* loop over all input ports */
55 +       for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++)
56 +       {
57 +               input_port_info *portinfo = &port_info[portnum];
58 +               input_bit_info *info;
59 +               unsigned long portvalue;
60 +
61 +               for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->port; bitnum++, info++)
62 +               {
63 +                       portvalue = portinfo->playback;
64 +
65 +                       if(info->port->type == type && info->port->player == player)
66 +                       {
67 +                               if((info->port->type == type) && (portvalue & info->port->mask) != (info->port->default_value & info->port->mask))
68 +                                       return 1;
69 +                               else
70 +                                       return 0;
71 +                       }
72 +               }
73 +       }
74 +       return 0;
75 +}
76 diff -Nru base0120/src/emu/inptport.h w0120/src/emu/inptport.h
77 --- base0120/src/emu/inptport.h 2007-09-29 15:57:09.000000000 +1200
78 +++ w0120/src/emu/inptport.h    2007-10-16 00:58:01.000000000 +1300
79 @@ -899,4 +899,6 @@
80  UINT32 readinputportbytag(const char *tag);
81  UINT32 readinputportbytag_safe(const char *tag, UINT32 defvalue);
82  
83 +int input_port_used(int, int);
84 +
85  #endif /* __INPTPORT_H__ */
86 diff -Nru base0120/src/emu/inpview.c w0120/src/emu/inpview.c
87 --- base0120/src/emu/inpview.c  1970-01-01 13:00:00.000000000 +1300
88 +++ w0120/src/emu/inpview.c     2007-10-16 00:58:01.000000000 +1300
89 @@ -0,0 +1,258 @@
90 +// Input viewer module for MAME
91 +// Complete re-write started Aug 23, 2006
92 +
93 +#include <stdio.h>
94 +#include "ui.h"
95 +#include "uitext.h"
96 +#include "inptport.h"
97 +#include "render.h"
98 +#include "inpview.h"
99 +
100 +#define CHAR_WIDTH  (1.0f / 80.0f)
101 +#define INPUT_TYPES 5
102 +
103 +#define COL_RED     MAKE_ARGB(0xff, 0xff, 0x00, 0x00)
104 +#define COL_BLUE    MAKE_ARGB(0xff, 0x00, 0x00, 0xff)
105 +#define COL_GREEN   MAKE_ARGB(0xff, 0x00, 0xff, 0x00)
106 +#define COL_YELLOW  MAKE_ARGB(0xff, 0xff, 0xff, 0x00)
107 +#define COL_ORANGE  MAKE_ARGB(0xff, 0xff, 0x80, 0x00)
108 +#define COL_BLACK   MAKE_ARGB(0xff, 0x00, 0x00, 0x00)
109 +#define COL_GRAY    MAKE_ARGB(0xff, 0x80, 0x80, 0x80)
110 +#define COL_WHITE   MAKE_ARGB(0xff, 0xff, 0xff, 0xff)
111 +
112 +#define BGCOL       MAKE_ARGB(0x80, 0x80, 0x00, 0x00)
113 +
114 +// uncomment if you plan to use MAME's built-in font
115 +//#define OLD_UI_FONT 1
116 +
117 +#ifndef OLD_UI_FONT
118 +#define DIR_LEFT   0x2190
119 +#define DIR_UP     0x2191
120 +#define DIR_RIGHT  0x2192
121 +#define DIR_DOWN   0x2193
122 +#else
123 +#define DIR_LEFT   'L'
124 +#define DIR_UP     'U'
125 +#define DIR_RIGHT  'R'
126 +#define DIR_DOWN   'D'
127 +#endif
128 +
129 +struct input_type_definition inptype[INPUT_TYPES] = 
130 +{
131 +       {
132 +               "standard",
133 +               1,
134 +               {
135 +                       {"1P", IPT_START1, 1, 50, 0, 0, COL_WHITE},
136 +                       {"2P", IPT_START2, 1, 53, 0, 0, COL_WHITE},
137 +                       {"3P", IPT_START3, 1, 56, 0, 0, COL_WHITE},
138 +                       {"4P", IPT_START4, 1, 59, 0, 0, COL_WHITE},
139 +                       {"5P", IPT_START5, 1, 62, 0, 0, COL_WHITE},
140 +                       {"6P", IPT_START6, 1, 65, 0, 0, COL_WHITE},
141 +                       {"7P", IPT_START7, 1, 68, 0, 0, COL_WHITE},
142 +                       {"8P", IPT_START8, 1, 71, 0, 0, COL_WHITE},
143 +                       {"1",  IPT_BUTTON1, 1, 20, 0, 1, COL_WHITE},
144 +                       {"2",  IPT_BUTTON2, 1, 22, 0, 1, COL_WHITE},
145 +                       {"3",  IPT_BUTTON3, 1, 24, 0, 1, COL_WHITE},
146 +                       {"4",  IPT_BUTTON4, 1, 26, 0, 1, COL_WHITE},
147 +                       {"5",  IPT_BUTTON5, 1, 28, 0, 1, COL_WHITE},
148 +                       {"6",  IPT_BUTTON6, 1, 30, 0, 1, COL_WHITE},
149 +                       {"7",  IPT_BUTTON7, 1, 32, 0, 1, COL_WHITE},
150 +                       {"8",  IPT_BUTTON8, 1, 34, 0, 1, COL_WHITE},
151 +                       {"9",  IPT_BUTTON9, 1, 36, 0, 1, COL_WHITE},
152 +                       {"0",  IPT_BUTTON10, 1, 38, 0, 1, COL_WHITE},
153 +                       {"_L",  IPT_JOYSTICK_LEFT, 1, 10, 0, 1, COL_WHITE},
154 +                       {"_R",  IPT_JOYSTICK_RIGHT, 1, 12, 0, 1, COL_WHITE},
155 +                       {"_U",  IPT_JOYSTICK_UP, 1, 14, 0, 1, COL_WHITE},
156 +                       {"_D",  IPT_JOYSTICK_DOWN, 1, 16, 0, 1, COL_WHITE},
157 +                       {"NULL", -1, 0,0,0,0,0}
158 +               }
159 +       },
160 +       {
161 +               "mahjong",
162 +               2,
163 +               {
164 +                       {"1P", IPT_START1, 1, 50, 0, 0, COL_WHITE},
165 +                       {"2P", IPT_START2, 1, 53, 0, 0, COL_WHITE},
166 +                       {"3P", IPT_START3, 1, 56, 0, 0, COL_WHITE},
167 +                       {"4P", IPT_START4, 1, 59, 0, 0, COL_WHITE},
168 +                       {"5P", IPT_START5, 1, 62, 0, 0, COL_WHITE},
169 +                       {"6P", IPT_START6, 1, 65, 0, 0, COL_WHITE},
170 +                       {"7P", IPT_START7, 1, 68, 0, 0, COL_WHITE},
171 +                       {"8P", IPT_START8, 1, 71, 0, 0, COL_WHITE},
172 +                       {"A",  IPT_MAHJONG_A, 1, 10, 0, 1, COL_WHITE},
173 +                       {"B",  IPT_MAHJONG_B, 1, 12, 0, 1, COL_WHITE},
174 +                       {"C",  IPT_MAHJONG_C, 1, 14, 0, 1, COL_WHITE},
175 +                       {"D",  IPT_MAHJONG_D, 1, 16, 0, 1, COL_WHITE},
176 +                       {"E",  IPT_MAHJONG_E, 1, 18, 0, 1, COL_WHITE},
177 +                       {"F",  IPT_MAHJONG_F, 1, 20, 0, 1, COL_WHITE},
178 +                       {"G",  IPT_MAHJONG_G, 1, 22, 0, 1, COL_WHITE},
179 +                       {"H",  IPT_MAHJONG_H, 1, 24, 0, 1, COL_WHITE},
180 +                       {"I",  IPT_MAHJONG_I, 1, 26, 0, 1, COL_WHITE},
181 +                       {"J",  IPT_MAHJONG_J, 1, 28, 0, 1, COL_WHITE},
182 +                       {"K",  IPT_MAHJONG_K, 1, 30, 0, 1, COL_WHITE},
183 +                       {"L",  IPT_MAHJONG_L, 1, 32, 0, 1, COL_WHITE},
184 +                       {"M",  IPT_MAHJONG_M, 1, 34, 0, 1, COL_WHITE},
185 +                       {"N",  IPT_MAHJONG_N, 1, 36, 0, 1, COL_WHITE},
186 +                       {"O",  IPT_MAHJONG_O, 1, 38, 0, 1, COL_WHITE},
187 +                       {"P",  IPT_MAHJONG_P, 1, 40, 0, 1, COL_WHITE},
188 +                       {"Q",  IPT_MAHJONG_Q, 1, 42, 0, 1, COL_WHITE},
189 +                       {"REACH",  IPT_MAHJONG_REACH, 2, 14, 0, 1, COL_WHITE},
190 +                       {"CHI",  IPT_MAHJONG_CHI, 2, 26, 0, 1, COL_WHITE},
191 +                       {"PON",  IPT_MAHJONG_PON, 2, 34, 0, 1, COL_WHITE},
192 +                       {"KAN",  IPT_MAHJONG_KAN, 2, 42, 0, 1, COL_WHITE},
193 +                       {"RON",  IPT_MAHJONG_RON, 2, 50, 0, 1, COL_WHITE},
194 +                       {"BET",  IPT_MAHJONG_BET, 2, 58, 0, 1, COL_WHITE},
195 +                       {"NULL", -1, 0,0,0,0,0}
196 +               }
197 +       },
198 +       {
199 +               "dualstick",
200 +               1,
201 +               {
202 +                       {"1P", IPT_START1, 1, 50, 0, 0, COL_WHITE},
203 +                       {"2P", IPT_START2, 1, 53, 0, 0, COL_WHITE},
204 +                       {"3P", IPT_START3, 1, 56, 0, 0, COL_WHITE},
205 +                       {"4P", IPT_START4, 1, 59, 0, 0, COL_WHITE},
206 +                       {"5P", IPT_START5, 1, 62, 0, 0, COL_WHITE},
207 +                       {"6P", IPT_START6, 1, 65, 0, 0, COL_WHITE},
208 +                       {"7P", IPT_START7, 1, 68, 0, 0, COL_WHITE},
209 +                       {"8P", IPT_START8, 1, 71, 0, 0, COL_WHITE},
210 +                       {"1",  IPT_BUTTON1, 1, 30, 0, 1, COL_WHITE},
211 +                       {"2",  IPT_BUTTON2, 1, 32, 0, 1, COL_WHITE},
212 +                       {"3",  IPT_BUTTON3, 1, 34, 0, 1, COL_WHITE},
213 +                       {"4",  IPT_BUTTON4, 1, 36, 0, 1, COL_WHITE},
214 +                       {"5",  IPT_BUTTON5, 1, 38, 0, 1, COL_WHITE},
215 +                       {"6",  IPT_BUTTON6, 1, 40, 0, 1, COL_WHITE},
216 +                       {"7",  IPT_BUTTON7, 1, 42, 0, 1, COL_WHITE},
217 +                       {"8",  IPT_BUTTON8, 1, 44, 0, 1, COL_WHITE},
218 +                       {"9",  IPT_BUTTON9, 1, 46, 0, 1, COL_WHITE},
219 +                       {"0",  IPT_BUTTON10, 1, 48, 0, 1, COL_WHITE},
220 +                       {"_L",  IPT_JOYSTICKLEFT_LEFT,   1, 6, 0, 1, COL_WHITE},
221 +                       {"_R",  IPT_JOYSTICKLEFT_RIGHT,  1, 8, 0, 1, COL_WHITE},
222 +                       {"_U",  IPT_JOYSTICKLEFT_UP,     1, 10, 0, 1, COL_WHITE},
223 +                       {"_D",  IPT_JOYSTICKLEFT_DOWN,   1, 12, 0, 1, COL_WHITE},
224 +                       {"_L",  IPT_JOYSTICKRIGHT_LEFT,  1, 18, 0, 1, COL_WHITE},
225 +                       {"_R",  IPT_JOYSTICKRIGHT_RIGHT, 1, 20, 0, 1, COL_WHITE},
226 +                       {"_U",  IPT_JOYSTICKRIGHT_UP,    1, 22, 0, 1, COL_WHITE},
227 +                       {"_D",  IPT_JOYSTICKRIGHT_DOWN,  1, 24, 0, 1, COL_WHITE},
228 +                       {"NULL", -1, 0,0,0,0,0}
229 +               }
230 +       },
231 +       {
232 +               "neogeo",
233 +               2,
234 +               {
235 +                       {"1P", IPT_START1, 2, 53, 0, 0, COL_YELLOW},
236 +                       {"2P", IPT_START2, 1, 53, 0, 0, COL_YELLOW},
237 +                       {"A",  IPT_BUTTON1, 1, 26, 0, 1, COL_RED},
238 +                       {"B",  IPT_BUTTON2, 2, 29, 0, 1, COL_YELLOW},
239 +                       {"C",  IPT_BUTTON3, 2, 32, 0, 1, COL_GREEN},
240 +                       {"D",  IPT_BUTTON4, 1, 35, 0, 1, COL_BLUE},
241 +                       {"_L",  IPT_JOYSTICK_LEFT, 1, 15, 0, 1, COL_WHITE},
242 +                       {"_R",  IPT_JOYSTICK_RIGHT, 1, 19, 0, 1, COL_WHITE},
243 +                       {"_U",  IPT_JOYSTICK_UP, 2, 17, 0, 1, COL_WHITE},
244 +                       {"_D",  IPT_JOYSTICK_DOWN, 1, 17, 0, 1, COL_WHITE},
245 +                       {"NULL", -1, 0,0,0,0,0}
246 +               }
247 +       },
248 +       {
249 +               "6button",
250 +               2,
251 +               {
252 +                       {"1P", IPT_START1, 2, 53, 0, 0, COL_YELLOW},
253 +                       {"2P", IPT_START2, 1, 53, 0, 0, COL_YELLOW},
254 +                       {"1",  IPT_BUTTON1, 2, 30, 0, 1, COL_WHITE},
255 +                       {"2",  IPT_BUTTON2, 2, 33, 0, 1, COL_WHITE},
256 +                       {"3",  IPT_BUTTON3, 2, 36, 0, 1, COL_WHITE},
257 +                       {"4",  IPT_BUTTON4, 1, 30, 0, 1, COL_WHITE},
258 +                       {"5",  IPT_BUTTON5, 1, 33, 0, 1, COL_WHITE},
259 +                       {"6",  IPT_BUTTON6, 1, 36, 0, 1, COL_WHITE},
260 +                       {"_L",  IPT_JOYSTICK_LEFT, 1, 15, 0, 1, COL_WHITE},
261 +                       {"_R",  IPT_JOYSTICK_RIGHT, 1, 19, 0, 1, COL_WHITE},
262 +                       {"_U",  IPT_JOYSTICK_UP, 2, 17, 0, 1, COL_WHITE},
263 +                       {"_D",  IPT_JOYSTICK_DOWN, 1, 17, 0, 1, COL_WHITE},
264 +                       {"NULL", -1, 0,0,0,0,0}
265 +               }
266 +       }
267 +};
268 +
269 +int player;
270 +int layout;
271 +
272 +void render_input()
273 +{
274 +       int port = 0;
275 +       char txt[6];
276 +       float height = ui_get_line_height();
277 +
278 +       if(player < 1 || player > 8)
279 +               return;  // invalid player
280 +
281 +       render_ui_add_rect(0.0f,1.0f-(float)(inptype[layout].lines*height),1.0f,1.0f,BGCOL,PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
282 +       while(inptype[layout].inp[port].port != -1)
283 +       {
284 +               strcpy(txt,inptype[layout].inp[port].text);
285 +
286 +               if(inptype[layout].inp[port].playerspecific == 0)
287 +               {
288 +                       if(input_port_used(inptype[layout].inp[port].port,0) != 0)
289 +                       {
290 +                               int ch = convert_txt(txt);
291 +                               int col = inptype[layout].inp[port].colour;
292 +                               if(ch == 0)
293 +                                       ui_draw_text_full(txt,(float)(inptype[layout].inp[port].x * CHAR_WIDTH),1.0f - (float)(height * inptype[layout].inp[port].line),1.0f,JUSTIFY_LEFT,WRAP_NEVER,DRAW_OPAQUE,col,0,NULL,NULL);
294 +                               else
295 +                                       render_ui_add_char((float)(inptype[layout].inp[port].x * CHAR_WIDTH),1.0f - (float)(height * inptype[layout].inp[port].line),height,render_get_ui_aspect(),col,ui_get_font(),ch);
296 +                       }
297 +               }
298 +               else
299 +               {
300 +                       if(input_port_used(inptype[layout].inp[port].port,player-1) != 0)
301 +                       {
302 +                               int ch = convert_txt(txt);
303 +                               int col = inptype[layout].inp[port].colour;
304 +                               if(ch == 0)
305 +                                       ui_draw_text_full(txt,(float)(inptype[layout].inp[port].x * CHAR_WIDTH),1.0f - (float)(height * inptype[layout].inp[port].line),1.0f,JUSTIFY_LEFT,WRAP_NEVER,DRAW_OPAQUE,col,0,NULL,NULL);
306 +                               else
307 +                                       render_ui_add_char((float)(inptype[layout].inp[port].x * CHAR_WIDTH),1.0f - (float)(height * inptype[layout].inp[port].line),height,render_get_ui_aspect(),col,ui_get_font(),ch);
308 +                       }
309 +               }
310 +               port++;
311 +       }
312 +}
313 +
314 +void inpview_set_data(int ply, const char* lay)
315 +{
316 +       player = ply;
317 +       layout = 0;
318 +       while(layout < INPUT_TYPES)
319 +       {
320 +               if(strcmp(inptype[layout].name,lay) == 0)
321 +               {
322 +                       printf("INPVIEW: using layout type '%s'\n",lay);
323 +                       return;
324 +               }
325 +               layout++;
326 +       }
327 +       printf("INPVIEW: invalid type specified, standard layout in use\n");
328 +       layout = 0;
329 +}
330 +
331 +int inpview_get_player()
332 +{
333 +       return player;
334 +}
335 +
336 +unsigned int convert_txt(char* txt)
337 +{
338 +               if(strcmp(txt,"_L") == 0)
339 +                       return DIR_LEFT;
340 +               if(strcmp(txt,"_R") == 0)
341 +                       return DIR_RIGHT;
342 +               if(strcmp(txt,"_U") == 0)
343 +                       return DIR_UP;
344 +               if(strcmp(txt,"_D") == 0)
345 +                       return DIR_DOWN;
346 +       return 0;
347 +}
348 diff -Nru base0120/src/emu/inpview.h w0120/src/emu/inpview.h
349 --- base0120/src/emu/inpview.h  1970-01-01 13:00:00.000000000 +1300
350 +++ w0120/src/emu/inpview.h     2007-10-16 00:58:01.000000000 +1300
351 @@ -0,0 +1,24 @@
352 +// Input viewer header
353 +
354 +struct inputs
355 +{
356 +       char text[6];  // character(s) to display
357 +       int port;  // port to check
358 +       int line;  // line to display on
359 +       int x;  // location on line to display at
360 +       char isanalogue;  // non-zero if the input is analogue
361 +       char playerspecific;  // is a player specific port (if 0, then player should be 0 too)
362 +       unsigned long colour;
363 +};
364 +
365 +struct input_type_definition
366 +{
367 +       char name[13];  // NULL-terminated string to identify different type using a possible -inplayout option
368 +       int lines;  // number of lines to use for this type
369 +       struct inputs inp[64];  // list of displayed buttons, and the inputs they correspond to (64 max)
370 +};
371 +
372 +void render_input(void);
373 +void inpview_set_data(int,const char*);
374 +int inpview_get_player(void);
375 +unsigned int convert_txt(char*);
376 diff -Nru base0120/src/emu/ui.c w0120/src/emu/ui.c
377 --- base0120/src/emu/ui.c       2007-09-07 04:42:07.000000000 +1200
378 +++ w0120/src/emu/ui.c  2007-10-16 00:58:01.000000000 +1300
379 @@ -31,7 +31,7 @@
380  #include <stdarg.h>
381  #include <math.h>
382  
383 -
384 +#include "inpview.h"
385  
386  /***************************************************************************
387      CONSTANTS
388 @@ -452,6 +452,10 @@
389         /* let MESS display its stuff */
390         mess_ui_update();
391  #endif
392 +
393 +       // Input viewer
394 +       if(Machine->playback_file && inpview_get_player() != 0)
395 +               render_input();
396  }
397  
398