Last active
April 13, 2023 10:58
-
-
Save slashinfty/6e7bd635e2dad49b7bacb96773fdfe4c to your computer and use it in GitHub Desktop.
Create a "piano roll" of inputs on BizHawk screen to right of GB game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ScriptInfo = {"Input Piano Roll","by dadinfinitum","v0.2","28th Jul 2019",} | |
local inputobj = {[0]="Up","Down","Left","Right","Start","Select","B","A"} | |
local display = {Up="U",Down="D",Left="L",Right="R",Start="S",Select="s",B="B",A="A"} | |
function text(x,y,text,color) | |
gui.drawText(x,y,text,color,0x00000000,9,"Arial") | |
end | |
function progress(perc) | |
gui.drawRectangle(170,30,10,100,0xFFFFFFFF) | |
gui.drawRectangle(171,30,8,perc,0xFFFFFFFF,0xFFFFFFFF) | |
end | |
function outline(pos) | |
local height = 10 | |
nextframe = movie.getinput(emu.framecount()+1) --get first future frame | |
if nextframe[tostring(inputobj[pos])] == true then height = height + 5 end --account for vertical spacing | |
local q = 0 | |
while q < 12 do | |
local futureframe = movie.getinput(emu.framecount()+1+q) | |
if futureframe[tostring(inputobj[pos])] == true then | |
height = height + 10 --increase height | |
else break end --stop checking if an input isn't pressed | |
q = q + 1 | |
end | |
local wadj = 0 --adjust width | |
local xadj = 0 --adjust x position to start | |
if pos > 1 and pos < 7 and pos ~= 3 then wadj = -1 end | |
if pos == 5 then xadj = -1 end | |
if pos == 6 then xadj = -2 end | |
if pos == 7 then | |
wadj = 2 | |
xadj = -3 | |
end | |
if pos > 2 then xadj = xadj - 1 end | |
gui.drawRectangle(190+xadj+8*pos,5,8+wadj,height,0xFF595959,0xFF292929) --draw outline | |
end | |
event.onexit(function() | |
client.SetGameExtraPadding(0,0,0,0) | |
end) | |
event.onloadstate(function() | |
end) | |
console.clear() | |
for i=1,table.getn(ScriptInfo),1 do | |
print(ScriptInfo[i]) | |
end | |
while true do | |
client.SetGameExtraPadding(0,0,96,0) --create space to right of game | |
local framecolor = 0xFFFFFFFF --white | |
if emu.islagged() then framecolor = 0xFFFF1500 end --red if lag | |
text(161,5,emu.framecount(),framecolor) --write frame count | |
local activeframe = movie.getinput(emu.framecount()) --get current frame | |
local m = 0 | |
while m < 8 do | |
local inputcolor = 0xFF595959 --show all input buttons in dark gray | |
if activeframe[tostring(inputobj[m])] == true then | |
inputcolor = 0xFFFFFFFF --make active buttons white | |
outline(m) --draw outline around continuous inputs | |
end | |
local moveleft = 0 | |
if m > 2 then moveleft = 1 end | |
if m > 5 then moveleft = moveleft + 2 end | |
text(189-moveleft+8*m,5,display[inputobj[m]],inputcolor) --write input buttons | |
m = m + 1 | |
end | |
local n = 0 | |
while n < 12 do | |
local futureframe = movie.getinput(emu.framecount()+n+1) --get future frame | |
local p = 0 | |
while p < 8 do | |
if futureframe[tostring(inputobj[p])] == true then | |
local moveleft = 0 | |
if p > 2 then moveleft = 1 end | |
if p > 5 then moveleft = moveleft + 2 end | |
text(189-moveleft+8*p,20+10*n,display[inputobj[p]],0xFF595959) --write input buttons if pressed in dark gray | |
end | |
p = p + 1 | |
end | |
n = n + 1 | |
end | |
progress(math.floor((emu.framecount()/movie.length())*100)) | |
emu.frameadvance() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Easy 720 encode with this script: screen size 4x, capture osd, ffmpeg with ffv1.