Post subject: FBA input display project
Experienced player (590)
Joined: 1/11/2007
Posts: 103
One of the difficulties in adding input display is that there are so many different input setups. Different games have different numbers of buttons and players. The buttons have different names. Some have analog controls. Some modules (unique setups) cover many games, some just one. If you want to add input display to an uncovered game, you just need to add a module to the list by defining the input abbreviations and where on screen you want them shown. Find the unabbreviated names under "Input" > "Map game inputs..." Then come up with sensible text symbols for each of them, and place them somewhere on screen that doesn't cover important stuff. Follow the examples given for formatting and syntax. You don't have to use x,dx,y,dy for positioning or loops for multiple players, but they make it easier to do tweaks later. Share your added modules here. This information needs to be collected for all games sooner or later, and at some point input display can be internalized into FBA. The script in the FBArr-004 archive can be split into the active part and the module list for easier reading. Make sure the list is named "modules.lua" in this case. input display.lua
--FBA-rr input display script (preliminary)
--This script must be reloaded when you change games.

local c={        --colors:
on1 =0xffff00ff, --pressed: yellow inside
on2 =0x000000ff, --pressed: black border
off1=0x00000000, --unpressed: clear inside
off2=0x00000033  --unpressed: mostly-clear black border
}

inp={}
dofile("modules.lua","r")

local function inputsmatch(table1,table2) --check if all keys of table1 are also keys of table2
	local checklist={}
	for k,v in pairs(table1) do
		checklist[k]=false
		for l,u in pairs(table2) do
			if k==l then
				checklist[k]=true
				break
			end
		end
	end
	for k,v in pairs(checklist) do
		if v==false then
			return false
		end
	end
	return true
end

local module
for k,v in pairs(inp) do --find out which module is the correct one
	if inputsmatch(v,joypad.get(1)) then
		module=k
		break
	end
end

local function inpdisplay(m)
	if not module then
		gui.text(0,0,"I don't know how to display this game's input.\nPlease add a module for it!")
	else
		for k,v in pairs(joypad.get(1)) do
			if m[k] then --display only defined inputs
				local color1,color2=c.on1,c.on2
				if m[k][4] then --analog
					gui.text(m[k][2]+m[k][4],m[k][3]+m[k][5],v,color1,color2) --display the value
				else --digital
					if v==0 then color1,color2=c.off1,c.off2 end --button not pressed
				end
				gui.text(m[k][2],m[k][3],m[k][1],color1,color2)
			end
		end
	end
end

gui.register(function()
	inpdisplay(inp[module])
end)
modules.lua
--Define below input abbreviations and on-screen positions for each module.
--You may add new modules and comment out any inputs you never want displayed.

local x,dx,y,dy,i
--------------------------------------------------------------------------------
--Capcom 6-button fighters
x,dx=0x8,0x128
y,dy=0xd0,0
i={}
for n=0,1 do
	i["P"..(n+1).." Coin"]        ={"C", x+dx*n+0x00,y+dy*n+0x0}
	i["P"..(n+1).." Start"]       ={"S", x+dx*n+0x00,y+dy*n+0x8}
	i["P"..(n+1).." Up"]          ={"^", x+dx*n+0x18,y+dy*n+0x0}
	i["P"..(n+1).." Down"]        ={"v", x+dx*n+0x18,y+dy*n+0x8}
	i["P"..(n+1).." Left"]        ={"<", x+dx*n+0x10,y+dy*n+0x4}
	i["P"..(n+1).." Right"]       ={">", x+dx*n+0x20,y+dy*n+0x4}
	i["P"..(n+1).." Weak Punch"]  ={"LP",x+dx*n+0x30,y+dy*n+0x0}
	i["P"..(n+1).." Medium Punch"]={"MP",x+dx*n+0x38,y+dy*n+0x0}
	i["P"..(n+1).." Strong Punch"]={"HP",x+dx*n+0x40,y+dy*n+0x0}
	i["P"..(n+1).." Weak Kick"]   ={"LK",x+dx*n+0x30,y+dy*n+0x8}
	i["P"..(n+1).." Medium Kick"] ={"MK",x+dx*n+0x38,y+dy*n+0x8}
	i["P"..(n+1).." Strong Kick"] ={"HK",x+dx*n+0x40,y+dy*n+0x8}
end
table.insert(inp,i)

--------------------------------------------------------------------------------
--NeoGeo
x,dx=0x8,0xd0
y,dy=0xc8,0
i={}
for n=0,1 do
	i["P"..(n+1).." Coin"]    ={"C",x+dx*n+0x04,y+dy*n+0x0}
	i["P"..(n+1).." Start"]   ={"S",x+dx*n+0x00,y+dy*n+0x8}
	i["P"..(n+1).." Select"]  ={"s",x+dx*n+0x08,y+dy*n+0x8}
	i["P"..(n+1).." Up"]      ={"^",x+dx*n+0x20,y+dy*n+0x0}
	i["P"..(n+1).." Down"]    ={"v",x+dx*n+0x20,y+dy*n+0x8}
	i["P"..(n+1).." Left"]    ={"<",x+dx*n+0x18,y+dy*n+0x4}
	i["P"..(n+1).." Right"]   ={">",x+dx*n+0x28,y+dy*n+0x4}
	i["P"..(n+1).." Button A"]={"A",x+dx*n+0x38,y+dy*n+0x4}
	i["P"..(n+1).." Button B"]={"B",x+dx*n+0x40,y+dy*n+0x4}
	i["P"..(n+1).." Button C"]={"C",x+dx*n+0x48,y+dy*n+0x4}
	i["P"..(n+1).." Button D"]={"D",x+dx*n+0x50,y+dy*n+0x4}
end
table.insert(inp,i)

--------------------------------------------------------------------------------
--PGM
x,dx=0x10,0x70
y,dy=0xc0,0
i={}
for n=0,3 do
	i["P"..(n+1).." Coin"]    ={"C",x+dx*n+0x00,y+dy*n+0x0}
	i["P"..(n+1).." Start"]   ={"S",x+dx*n+0x00,y+dy*n+0x8}
	i["P"..(n+1).." Up"]      ={"^",x+dx*n+0x14,y+dy*n+0x0}
	i["P"..(n+1).." Down"]    ={"v",x+dx*n+0x14,y+dy*n+0x8}
	i["P"..(n+1).." Left"]    ={"<",x+dx*n+0x0c,y+dy*n+0x4}
	i["P"..(n+1).." Right"]   ={">",x+dx*n+0x1c,y+dy*n+0x4}
	i["P"..(n+1).." Button 1"]={"1",x+dx*n+0x2c,y+dy*n+0x4}
	i["P"..(n+1).." Button 2"]={"2",x+dx*n+0x34,y+dy*n+0x4}
	i["P"..(n+1).." Button 3"]={"3",x+dx*n+0x3c,y+dy*n+0x4}
	i["P"..(n+1).." Button 4"]={"4",x+dx*n+0x44,y+dy*n+0x4}
end
table.insert(inp,i)

--------------------------------------------------------------------------------
--TMNT games (Konami)
x,dx=0x10,0x48
y,dy=0x20,0
i={}
for n=0,3 do
	i["Coin "..(n+1)]       ={"C",x+dx*n+0x00,y+dy*n+0x4}
	i["P"..(n+1).." Up"]    ={"^",x+dx*n+0x14,y+dy*n+0x0}
	i["P"..(n+1).." Down"]  ={"v",x+dx*n+0x14,y+dy*n+0x8}
	i["P"..(n+1).." Left"]  ={"<",x+dx*n+0x0c,y+dy*n+0x4}
	i["P"..(n+1).." Right"] ={">",x+dx*n+0x1c,y+dy*n+0x4}
	i["P"..(n+1).." Fire 1"]={"1",x+dx*n+0x2c,y+dy*n+0x4}
	i["P"..(n+1).." Fire 2"]={"2",x+dx*n+0x34,y+dy*n+0x4}
end
table.insert(inp,i)

--------------------------------------------------------------------------------
--After Burner II (Sega)
x,dx=0x80,0x10
y,dy=0xc8,0
i={
	["Coin 1"]    ={"C1", x+0x00,y+0x00},
	["Coin 2"]    ={"C2", x+0x00,y+0x08},
	["Start 1"]   ={"S1", x+0x00,y+0x10},
	["Left/Right"]={"L/R",x+0x10,y+0x00,dx,dy},
	["Up/Down"]   ={"U/D",x+0x10,y+0x08,dx,dy},
	["Throttle"]  ={"T",  x+0x10,y+0x10,dx,dy},
	["Vulcan"]    ={"V",  x+0x30,y+0x04},
	["Missile"]   ={"M",  x+0x30,y+0x0c}
}
table.insert(inp,i)

--------------------------------------------------------------------------------
Experienced player (590)
Joined: 1/11/2007
Posts: 103
Sort of a related thing, I made a lua script to add vertically scrolling display, as seen in training mode in some fighting games. It's for 6-button Capcom games, but it could be expanded to cover other kinds. It currently works in fba, snes9x and gens. I'd like to add pcsx when it gets better lua support. Instructions: Download the script, and the dll files for gd mentioned in the script. Put the dlls with the emulator's exe and put the image files wherever the script is. Run the game and the script and it should be working. If the images aren't found, it will resort to ghetto mode, where only text is shown. (That's bad.) Some of the buttons are from SF4, courtesy of error1. If you idle too long, the next command will clear the buffer, just like in training mode. You can disable each player with the q and w keys. (You can change those keys, the idle time, and other stuff by editing the things above the dotted line.) If you want to totally clear everything you can just reload the script. Some limitations of the current emulators:
    * The images don't show up in FBA's screenshots or AVI dumps. * When I try to dump AVI in snes9x with the script on, it crashes. * The images look messed up in gens. * If you load savestates, the buffer will not be updated to reflect the new state. That can't be fixed until all the emus get savestate.registerload.
Active player (312)
Joined: 2/28/2006
Posts: 2275
Location: Milky Way -> Earth -> Brazil
dude this is awesome... but how can we remove the fancy scrolling and leave only the button last presses at the bottom?
"Genuine self-esteem, however, consists not of causeless feelings, but of certain knowledge about yourself. It rests on the conviction that you — by your choices, effort and actions — have made yourself into the kind of person able to deal with reality. It is the conviction — based on the evidence of your own volitional functioning — that you are fundamentally able to succeed in life and, therefore, are deserving of that success." - Onkar Ghate
Bisqwit wrote:
Drama, too long, didn't read, lol.
Experienced player (590)
Joined: 1/11/2007
Posts: 103
Try setting buffersize to 1 and y to 0xc0.
mz
Emulator Coder, Player (79)
Joined: 10/26/2007
Posts: 693
Nice job. MAME/MESS have something like this too for their movie code, if I recall correctly. It also works on PCSX if you use the latest SVN revision (which is not very usable, anyway):
Dammit wrote:
The images don't show up in FBA's screenshots or AVI dumps.
That's due to most drivers using their own image buffer and drawing functions. I had to apply the Lua GUI directly to the DirectDraw surfaces, to make it work with all of them. If you need to take screenshots or AVI dumps with it, I can tell you where to add a line of code to the CPS2 driver (or any other you need).
Dammit wrote:
If you load savestates, the buffer will not be updated to reflect the new state. That can't be fixed until all the emus get savestate.registerload.
As far as I know, PCSX and FBA are the only ones missing savestate.register*. :D I should add those functions one of these days...
You're just fucking stupid, everyone hates you, sorry to tell you the truth. no one likes you, you're someone pretentious and TASes only to be on speed game, but don't have any hope, you won't get there.
Joined: 1/26/2009
Posts: 558
Location: Canada - Québec
Dammit wrote:
Instructions: Download the script, and the dll files for gd mentioned in the script. Put the dlls with the emulator's exe and put the image files wherever the script is. Run the game and the script and it should be working. If the images aren't found, it will resort to ghetto mode, where only text is shown. (That's bad.)
Can you give us directly a .zip package with all the dll, gd, and other lua script? Simple input display text works perfectly, thanks!
mz wrote:
It also works on PCSX if you use the latest SVN revision (which is not very usable, anyway)
The new ramwatch and ramsearch looks great... and I'm happy to see that the experiment about the sound are still keep going on.
Experienced player (590)
Joined: 1/11/2007
Posts: 103
mz wrote:
MAME/MESS have something like this too for their movie code, if I recall correctly.
Hm. Any more info on this?
mz wrote:
If you need to take screenshots or AVI dumps with it, I can tell you where to add a line of code to the CPS2 driver (or any other you need).
Eh, you know how much I fail at compiling. Maybe you could make the changes at your leisure.
BadPotato wrote:
Can you give us directly a .zip package with all the dll, gd, and other lua script?
I'd like to, but I can't find a reliable, fire-and-forget filehost. mz, can you put a package in the fba-rr downloads?
mz
Emulator Coder, Player (79)
Joined: 10/26/2007
Posts: 693
Dammit wrote:
mz wrote:
MAME/MESS have something like this too for their movie code, if I recall correctly.
Hm. Any more info on this?
I tried recording a movie in the newest versions of MAME and MESS and there isn't any kind of input display... I wonder if what I once saw was an unofficial version or just another completely different emulator. All I remember is that the input display was scrolling from right to left at the bottom of the screen...
Dammit wrote:
Maybe you could make the changes at your leisure.
I still need you to tell me what driver are you interested in. I won't add this to all drivers, because it's impossible to maintain for me... Also, I like printing stuff directly to the DirectDraw surface, since that way I can use higher resolutions and have more screen space. :P
Dammit wrote:
mz, can you put a package in the fba-rr downloads?
I'll give you admin access to the Google Code page so you can upload files there.
You're just fucking stupid, everyone hates you, sorry to tell you the truth. no one likes you, you're someone pretentious and TASes only to be on speed game, but don't have any hope, you won't get there.
Active player (312)
Joined: 2/28/2006
Posts: 2275
Location: Milky Way -> Earth -> Brazil
mz, in your inputdsplay script that comes with final burn , why is the input display color transparent? The comments in the lua file say it should be yellow. Also how is that color format supposed to be interpreted? CMYK? All I can get there is blue and green... all the rest is transparecy.
"Genuine self-esteem, however, consists not of causeless feelings, but of certain knowledge about yourself. It rests on the conviction that you — by your choices, effort and actions — have made yourself into the kind of person able to deal with reality. It is the conviction — based on the evidence of your own volitional functioning — that you are fundamentally able to succeed in life and, therefore, are deserving of that success." - Onkar Ghate
Bisqwit wrote:
Drama, too long, didn't read, lol.
mz
Emulator Coder, Player (79)
Joined: 10/26/2007
Posts: 693
The colors are in RGBA (red-green-blue-alpha). Red would be 0xff0000ff, for example. There are four colors in the script: on1&2 are for when the buttons are pressed and off1&2 are for when they are unpressed. Only on1 is yellow, which is the color of the font you see when you press a button (on2 is the border color). The font is transparent only when you're not pressing a button... You can try changing off1&2 if you don't like it that way. (By the way, it's not my script; Dammit wrote it.)
You're just fucking stupid, everyone hates you, sorry to tell you the truth. no one likes you, you're someone pretentious and TASes only to be on speed game, but don't have any hope, you won't get there.
Active player (312)
Joined: 2/28/2006
Posts: 2275
Location: Milky Way -> Earth -> Brazil
on1 =0xffff00ff, --pressed: yellow inside
nope, it's not yellow... it's transparency, see:
"Genuine self-esteem, however, consists not of causeless feelings, but of certain knowledge about yourself. It rests on the conviction that you — by your choices, effort and actions — have made yourself into the kind of person able to deal with reality. It is the conviction — based on the evidence of your own volitional functioning — that you are fundamentally able to succeed in life and, therefore, are deserving of that success." - Onkar Ghate
Bisqwit wrote:
Drama, too long, didn't read, lol.
mz
Emulator Coder, Player (79)
Joined: 10/26/2007
Posts: 693
Oh, that should be caused because you're using a different lua51.dll file... I forgot to put the correct one in the release archives. :D Please download this one and extract it in your FBA folder: lua51.dll.7z.
You're just fucking stupid, everyone hates you, sorry to tell you the truth. no one likes you, you're someone pretentious and TASes only to be on speed game, but don't have any hope, you won't get there.
Active player (312)
Joined: 2/28/2006
Posts: 2275
Location: Milky Way -> Earth -> Brazil
Ah yeah, now it's working fine! Thanks.
"Genuine self-esteem, however, consists not of causeless feelings, but of certain knowledge about yourself. It rests on the conviction that you — by your choices, effort and actions — have made yourself into the kind of person able to deal with reality. It is the conviction — based on the evidence of your own volitional functioning — that you are fundamentally able to succeed in life and, therefore, are deserving of that success." - Onkar Ghate
Bisqwit wrote:
Drama, too long, didn't read, lol.
Former player
Joined: 5/4/2005
Posts: 502
Location: Onett, Eagleland
Pardon me, may be a little off topic, but would someone mind explaining how you find the addresses for what button is being pressed? I see the value dx and dy but unsure what they are. I'm not too familiar with lua. But I'm trying to do something similar with a version of final burn that doesn't support lua. So I've been browsing the memory of the emulator to find the button presses but I'm unsuccessful so far. So if anyone could enlighten me how FBA actually reads button presses I'd appreciate it, thanks. EDIT: In particular, I want to know the capcom fighters values/addresses (SF2, ST, ALPHA, ETC...)
I think.....therefore I am not Barry Burton