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
8 + $(EMUOBJ)/inpview.o \
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
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" },
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
33 /***************************************************************************
36 /* register callbacks for when we load configurations */
37 config_register("input", input_port_load, input_port_save);
39 + /* INPVIEW: initialise -inpview and -inplayout options */
40 + inpview_set_data(options_get_int(mame_options(),"inpview"),options_get_string(mame_options(),"inplayout"));
42 /* open playback and record files if specified */
43 setup_playback(machine);
44 setup_record(machine);
45 @@ -3599,3 +3603,30 @@
50 +int input_port_used(int type,int player)
52 + int portnum, bitnum;
54 + /* loop over all input ports */
55 + for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++)
57 + input_port_info *portinfo = &port_info[portnum];
58 + input_bit_info *info;
59 + unsigned long portvalue;
61 + for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->port; bitnum++, info++)
63 + portvalue = portinfo->playback;
65 + if(info->port->type == type && info->port->player == player)
67 + if((info->port->type == type) && (portvalue & info->port->mask) != (info->port->default_value & info->port->mask))
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
80 UINT32 readinputportbytag(const char *tag);
81 UINT32 readinputportbytag_safe(const char *tag, UINT32 defvalue);
83 +int input_port_used(int, int);
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
90 +// Input viewer module for MAME
91 +// Complete re-write started Aug 23, 2006
96 +#include "inptport.h"
100 +#define CHAR_WIDTH (1.0f / 80.0f)
101 +#define INPUT_TYPES 5
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)
112 +#define BGCOL MAKE_ARGB(0x80, 0x80, 0x00, 0x00)
114 +// uncomment if you plan to use MAME's built-in font
115 +//#define OLD_UI_FONT 1
118 +#define DIR_LEFT 0x2190
119 +#define DIR_UP 0x2191
120 +#define DIR_RIGHT 0x2192
121 +#define DIR_DOWN 0x2193
123 +#define DIR_LEFT 'L'
125 +#define DIR_RIGHT 'R'
126 +#define DIR_DOWN 'D'
129 +struct input_type_definition inptype[INPUT_TYPES] =
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}
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}
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}
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}
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}
276 + float height = ui_get_line_height();
278 + if(player < 1 || player > 8)
279 + return; // invalid player
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)
284 + strcpy(txt,inptype[layout].inp[port].text);
286 + if(inptype[layout].inp[port].playerspecific == 0)
288 + if(input_port_used(inptype[layout].inp[port].port,0) != 0)
290 + int ch = convert_txt(txt);
291 + int col = inptype[layout].inp[port].colour;
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);
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);
300 + if(input_port_used(inptype[layout].inp[port].port,player-1) != 0)
302 + int ch = convert_txt(txt);
303 + int col = inptype[layout].inp[port].colour;
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);
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);
314 +void inpview_set_data(int ply, const char* lay)
318 + while(layout < INPUT_TYPES)
320 + if(strcmp(inptype[layout].name,lay) == 0)
322 + printf("INPVIEW: using layout type '%s'\n",lay);
327 + printf("INPVIEW: invalid type specified, standard layout in use\n");
331 +int inpview_get_player()
336 +unsigned int convert_txt(char* txt)
338 + if(strcmp(txt,"_L") == 0)
340 + if(strcmp(txt,"_R") == 0)
342 + if(strcmp(txt,"_U") == 0)
344 + if(strcmp(txt,"_D") == 0)
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
352 +// Input viewer header
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;
365 +struct input_type_definition
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)
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
384 +#include "inpview.h"
386 /***************************************************************************
389 /* let MESS display its stuff */
394 + if(Machine->playback_file && inpview_get_player() != 0)