diff -Nru base0108s/src/core.mak mame0108s/src/core.mak --- base0108s/src/core.mak 2006-08-18 03:53:13.000000000 +1200 +++ mame0108s/src/core.mak 2006-08-25 18:16:33.000000000 +1200 @@ -73,6 +73,7 @@ $(OBJ)/sndhrdw/generic.o \ $(OBJ)/vidhrdw/generic.o \ $(OBJ)/vidhrdw/vector.o \ + $(OBJ)/inpview.o \ ifdef X86_MIPS3_DRC COREOBJS += $(OBJ)/x86drc.o diff -Nru base0108s/src/inptport.c mame0108s/src/inptport.c --- base0108s/src/inptport.c 2006-08-08 04:54:43.000000000 +1200 +++ mame0108s/src/inptport.c 2006-08-26 10:42:58.000000000 +1200 @@ -2688,3 +2688,30 @@ portinfo->change_notify = cbinfo; } + +int input_port_used(int type,int player) +{ + int portnum, bitnum; + + /* loop over all input ports */ + for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) + { + input_port_info *portinfo = &port_info[portnum]; + input_bit_info *info; + unsigned long portvalue; + + for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->port; bitnum++, info++) + { + portvalue = portinfo->playback; + + if(info->port->type == type && info->port->player == player) + { + if((info->port->type == type) && (portvalue & info->port->mask) != (info->port->default_value & info->port->mask)) + return 1; + else + return 0; + } + } + } + return 0; +} diff -Nru base0108s/src/inptport.h mame0108s/src/inptport.h --- base0108s/src/inptport.h 2006-08-11 05:24:37.000000000 +1200 +++ mame0108s/src/inptport.h 2006-08-25 20:45:19.000000000 +1200 @@ -720,4 +720,6 @@ UINT32 readinputportbytag(const char *tag); UINT32 readinputportbytag_safe(const char *tag, UINT32 defvalue); +int input_port_used(int, int); + #endif /* __INPTPORT_H__ */ diff -Nru base0108s/src/inpview.c mame0108s/src/inpview.c --- base0108s/src/inpview.c 1970-01-01 13:00:00.000000000 +1300 +++ mame0108s/src/inpview.c 2006-08-26 10:56:43.000000000 +1200 @@ -0,0 +1,180 @@ +// Input viewer module for MAME +// Complete re-write started Aug 23, 2006 + +#include +#include "ui.h" +#include "uitext.h" +#include "inptport.h" +#include "render.h" +#include "inpview.h" + +#define CHAR_WIDTH (1.0f / 80.0f) +#define INPUT_TYPES 3 +#define BGCOL MAKE_ARGB(0x80, 0x80, 0x00, 0x00) + +struct input_type_definition inptype[INPUT_TYPES] = +{ + { + "standard", + 1, + { + {"1P", IPT_START1, 1, 50, 0, 0}, + {"2P", IPT_START2, 1, 53, 0, 0}, + {"3P", IPT_START3, 1, 56, 0, 0}, + {"4P", IPT_START4, 1, 59, 0, 0}, + {"5P", IPT_START5, 1, 62, 0, 0}, + {"6P", IPT_START6, 1, 65, 0, 0}, + {"7P", IPT_START7, 1, 68, 0, 0}, + {"8P", IPT_START8, 1, 71, 0, 0}, + {"1", IPT_BUTTON1, 1, 20, 0, 1}, + {"2", IPT_BUTTON2, 1, 22, 0, 1}, + {"3", IPT_BUTTON3, 1, 24, 0, 1}, + {"4", IPT_BUTTON4, 1, 26, 0, 1}, + {"5", IPT_BUTTON5, 1, 28, 0, 1}, + {"6", IPT_BUTTON6, 1, 30, 0, 1}, + {"7", IPT_BUTTON7, 1, 32, 0, 1}, + {"8", IPT_BUTTON8, 1, 34, 0, 1}, + {"9", IPT_BUTTON9, 1, 36, 0, 1}, + {"0", IPT_BUTTON10, 1, 38, 0, 1}, + {"L", IPT_JOYSTICK_LEFT, 1, 10, 0, 1}, + {"R", IPT_JOYSTICK_RIGHT, 1, 12, 0, 1}, + {"U", IPT_JOYSTICK_UP, 1, 14, 0, 1}, + {"D", IPT_JOYSTICK_DOWN, 1, 16, 0, 1}, + {"NULL", -1, 0,0,0} + } + }, + { + "mahjong", + 2, + { + {"1P", IPT_START1, 1, 50, 0, 0}, + {"2P", IPT_START2, 1, 53, 0, 0}, + {"3P", IPT_START3, 1, 56, 0, 0}, + {"4P", IPT_START4, 1, 59, 0, 0}, + {"5P", IPT_START5, 1, 62, 0, 0}, + {"6P", IPT_START6, 1, 65, 0, 0}, + {"7P", IPT_START7, 1, 68, 0, 0}, + {"8P", IPT_START8, 1, 71, 0, 0}, + {"A", IPT_MAHJONG_A, 1, 10, 0, 1}, + {"B", IPT_MAHJONG_B, 1, 12, 0, 1}, + {"C", IPT_MAHJONG_C, 1, 14, 0, 1}, + {"D", IPT_MAHJONG_D, 1, 16, 0, 1}, + {"E", IPT_MAHJONG_E, 1, 18, 0, 1}, + {"F", IPT_MAHJONG_F, 1, 20, 0, 1}, + {"G", IPT_MAHJONG_G, 1, 22, 0, 1}, + {"H", IPT_MAHJONG_H, 1, 24, 0, 1}, + {"I", IPT_MAHJONG_I, 1, 26, 0, 1}, + {"J", IPT_MAHJONG_J, 1, 28, 0, 1}, + {"K", IPT_MAHJONG_K, 1, 30, 0, 1}, + {"L", IPT_MAHJONG_L, 1, 32, 0, 1}, + {"M", IPT_MAHJONG_M, 1, 34, 0, 1}, + {"N", IPT_MAHJONG_N, 1, 36, 0, 1}, + {"O", IPT_MAHJONG_O, 1, 38, 0, 1}, + {"P", IPT_MAHJONG_P, 1, 40, 0, 1}, + {"Q", IPT_MAHJONG_Q, 1, 42, 0, 1}, + {"REACH", IPT_MAHJONG_REACH, 2, 14, 0, 1}, + {"CHI", IPT_MAHJONG_CHI, 2, 26, 0, 1}, + {"PON", IPT_MAHJONG_PON, 2, 34, 0, 1}, + {"KAN", IPT_MAHJONG_KAN, 2, 42, 0, 1}, + {"RON", IPT_MAHJONG_RON, 2, 50, 0, 1}, + {"BET", IPT_MAHJONG_BET, 2, 58, 0, 1}, + {"NULL", -1, 0,0,0} + } + }, + { + "dualstick", + 1, + { + {"1P", IPT_START1, 1, 50, 0, 0}, + {"2P", IPT_START2, 1, 53, 0, 0}, + {"3P", IPT_START3, 1, 56, 0, 0}, + {"4P", IPT_START4, 1, 59, 0, 0}, + {"5P", IPT_START5, 1, 62, 0, 0}, + {"6P", IPT_START6, 1, 65, 0, 0}, + {"7P", IPT_START7, 1, 68, 0, 0}, + {"8P", IPT_START8, 1, 71, 0, 0}, + {"1", IPT_BUTTON1, 1, 30, 0, 1}, + {"2", IPT_BUTTON2, 1, 32, 0, 1}, + {"3", IPT_BUTTON3, 1, 34, 0, 1}, + {"4", IPT_BUTTON4, 1, 36, 0, 1}, + {"5", IPT_BUTTON5, 1, 38, 0, 1}, + {"6", IPT_BUTTON6, 1, 40, 0, 1}, + {"7", IPT_BUTTON7, 1, 42, 0, 1}, + {"8", IPT_BUTTON8, 1, 44, 0, 1}, + {"9", IPT_BUTTON9, 1, 46, 0, 1}, + {"0", IPT_BUTTON10, 1, 48, 0, 1}, + {"L", IPT_JOYSTICKLEFT_LEFT, 1, 6, 0, 1}, + {"R", IPT_JOYSTICKLEFT_RIGHT, 1, 8, 0, 1}, + {"U", IPT_JOYSTICKLEFT_UP, 1, 10, 0, 1}, + {"D", IPT_JOYSTICKLEFT_DOWN, 1, 12, 0, 1}, + {"L", IPT_JOYSTICKRIGHT_LEFT, 1, 18, 0, 1}, + {"R", IPT_JOYSTICKRIGHT_RIGHT, 1, 20, 0, 1}, + {"U", IPT_JOYSTICKRIGHT_UP, 1, 22, 0, 1}, + {"D", IPT_JOYSTICKRIGHT_DOWN, 1, 24, 0, 1}, + {"NULL", -1, 0,0,0} + } + } +}; + +int player; +int layout; + +void render_input() +{ + int port = 0; + char txt[6]; + float height = ui_get_line_height(); + + if(player < 1 || player > 8) + return; // invalid player + + render_ui_add_rect(0.0f,1.0f-(float)(inptype[layout].lines*height),1.0f,1.0f,BGCOL,PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); + while(inptype[layout].inp[port].port != -1) + { + strcpy(txt,inptype[layout].inp[port].text); + + // convert LRUD to arrows ... one day MAME will actually be able to use arrows. +/* if(strcmp(txt,"_L") == 0) + strcpy(txt,""); + if(strcmp(txt,"_R") == 0) + strcpy(txt,"Å"); + if(strcmp(txt,"_U") == 0) + strcpy(txt,"É"); + if(strcmp(txt,"_D") == 0) + strcpy(txt,"æ"); +*/ + if(inptype[layout].inp[port].playerspecific == 0) + { + if(input_port_used(inptype[layout].inp[port].port,0) != 0) + 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,ARGB_WHITE,0,NULL,NULL); + } + else + { + if(input_port_used(inptype[layout].inp[port].port,player-1) != 0) + 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,ARGB_WHITE,0,NULL,NULL); + } + port++; + } +} + +void inpview_set_data(int ply, const char* lay) +{ + player = ply; + layout = 0; + while(layout < INPUT_TYPES) + { + if(strcmp(inptype[layout].name,lay) == 0) + { + printf("INPVIEW: using layout type '%s'\n",lay); + return; + } + layout++; + } + printf("INPVIEW: invalid type specified, standard layout in use\n"); + layout = 0; +} + +int inpview_get_player() +{ + return player; +} diff -Nru base0108s/src/inpview.h mame0108s/src/inpview.h --- base0108s/src/inpview.h 1970-01-01 13:00:00.000000000 +1300 +++ mame0108s/src/inpview.h 2006-08-26 00:23:25.000000000 +1200 @@ -0,0 +1,22 @@ +// Input viewer header + +struct inputs +{ + char text[6]; // character(s) to display + int port; // port to check + int line; // line to display on + int x; // location on line to display at + char isanalogue; // non-zero if the input is analogue + char playerspecific; // is a player specific port (if 0, then player should be 0 too) +}; + +struct input_type_definition +{ + char name[13]; // NULL-terminated string to identify different type using a possible -inplayout option + int lines; // number of lines to use for this type + struct inputs inp[64]; // list of displayed buttons, and the inputs they correspond to (64 max) +}; + +void render_input(void); +void inpview_set_data(int,const char*); +int inpview_get_player(void); diff -Nru base0108s/src/ui.c mame0108s/src/ui.c --- base0108s/src/ui.c 2006-08-20 12:28:27.000000000 +1200 +++ mame0108s/src/ui.c 2006-08-25 21:54:33.000000000 +1200 @@ -31,7 +31,7 @@ #include #include - +#include "inpview.h" /*************************************************************************** CONSTANTS @@ -373,6 +373,10 @@ /* let MESS display its stuff */ mess_ui_update(); #endif + + // Input viewer + if(Machine->playback_file && inpview_get_player() != 0) + render_input(); } diff -Nru base0108s/src/windows/config.c mame0108s/src/windows/config.c --- base0108s/src/windows/config.c 2006-08-20 12:28:27.000000000 +1200 +++ mame0108s/src/windows/config.c 2006-08-25 21:42:33.000000000 +1200 @@ -31,7 +31,7 @@ #include "debug/debugcon.h" #endif - +#include "inpview.h" //============================================================ // EXTERNALS @@ -162,6 +162,8 @@ { NULL, NULL, OPTION_HEADER, "MISC OPTIONS" }, { "bios", "default", 0, "select the system BIOS to use" }, { "cheat;c", "0", OPTION_BOOLEAN, "enable cheat subsystem" }, + { "inpview;iv", "0", 0, "enable input viewer" }, + { "inplayout;il", "standard", 0, "set input viewer layout type" }, // state/playback options { NULL, NULL, OPTION_HEADER, "STATE/PLAYBACK OPTIONS" }, @@ -691,6 +693,8 @@ options.cheat = options_get_bool("cheat", TRUE); options.skip_gameinfo = options_get_bool("skip_gameinfo", TRUE); + inpview_set_data(options_get_int("inpview", TRUE),options_get_string("inplayout",TRUE)); + #ifdef MESS win_mess_extract_options(); #endif /* MESS */