Post subject: Super Metroid's flickering HUD
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
In some emulators, mostly SNES9x 1.43, the HDMA effects (which control the HUD display) are occasionally one line too soon or too late, resulting in screens like this. That's what the Fix_HUD function is for. It should only be used in those parts of the recorded video that contain actual gameplay. To see where they begin despite fade-in or fade-out effects, set the brightness with the SetGamma function. The AviSynth script would then look like this:
AVISource(...)

SetGamma(10)  # disable when done
Replace(1000,   2000, Fix_Hud)  # Space Colony
Replace(3000, 100000, Fix_Hud)  # Zebes

# ...




function Fix_HUD(clip c, bool "HUD", bool "Main")  {
        # clears the first line of the screen's HUD and main playing area
        # optional parameters control which parts are cleared
        HUD  = default(HUD , true)
        Main = default(Main, true)
        c
        p1 = Crop(0,  0, 0, 31)
        p2 = Crop(0, 31, 0,  0)
        p1 = (HUD )  ?  p1.Crop(0, 1, 0, 0).AddBorders(0, 1, 0, 0)  :  p1
        p2 = (Main)  ?  p2.Crop(0, 1, 0, 0).AddBorders(0, 1, 0, 0)  :  p2
        StackVertical(p1, p2)
}


function Replace(clip c, int i, int j, clip d)  {
        Assert(i >= 0, "Replace: parameter i is negative")
        Assert(j >= 0, "Replace: parameter j is negative")
        p1 = c.Trim(0    , -i)
        p2 = d.Trim(i    ,  j)
        p3 = c.Trim(j + 1,  0)
        p1 = (i == 0)  ?  c.Trim(0, -1).DeleteFrame(0)  :  p1
        p3 = (j == 0)  ?  c.Trim(0, -1).DeleteFrame(0)  :  p3
        p1 + p2 + p3
        return (c.HasAudio)  ?  last.AudioDub(c)  :  last
}


function SetGamma(clip c, float Gamma)  {c.Levels(0, Gamma, 255, 0, 255, true)}
Site Admin, Skilled player (1236)
Joined: 4/17/2010
Posts: 11264
Location: RU
Post the resulting gif?
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
source, result and difference (1.4 MB) Note that with perfect emulation, the HUD would only go as far as the bottom white dotted line of the mini-map.
Player (36)
Joined: 9/11/2004
Posts: 2623
I was pretty sure that they made a version of the emulator to correct this.
Build a man a fire, warm him for a day, Set a man on fire, warm him for the rest of his life.
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
That's not what people are using, though. It still happens in current encodes.