User File #13538527443458224

Upload All User Files

#13538527443458224 - Basic lua script for SNES F-Zero (for lsnes) (Re-upload)

LazyFZa.lua
Game: F-Zero ( see all files )
1160 downloads
Uploaded 3/24/2014 4:38 PM by FatRatKnight (see all 245)
It's a glorified memory watch script. Though at least it'll tell how much of your speed is being applied to each axis depending on which direction your momentum is headed.
What will I work on next? I have no clue. I'm rather chaotically analyzing games at the moment. ... It's something, I guess.
Oh, and whoops. Last file mixed up on-screen positions of the X and Y positions with the X and Y velocities.
local R1u,R1s= memory.readbyte, memory.readsbyte
local R2u,R2s= memory.readword, memory.readsword

local function HexStr(v) return string.format("%4X",v) end

local AngleTbl= { --X speeds of first 90 degrees, but I plan to use reflection
[0]=128,128,128,127, 127,126,126,125, 124,122,121,120, 118,117,115,113,
    111,109,106,104, 102, 99, 96, 93,  91, 87, 84, 81,  78, 75, 71, 68,
     64, 60, 57, 53,  49, 45, 41, 37,  33, 29, 25, 21,  17, 13,  8,  4,
      0
}

--*****************************************************************************
local function YourSpeed()
--*****************************************************************************

    local MomentumDirection= R1u(0x7E0BE1) --High byte of momentum

    local Quadrant= math.floor(MomentumDirection/0x30)
    local Angle= MomentumDirection%0x30

    local X,Y= AngleTbl[Angle],AngleTbl[0x30-Angle]

    if bit.band(Quadrant  ,1) ~= 0 then   X,Y= Y,X   end  -- Flip
    local Xclr, Yclr= math.max(0,X*0x000002-1),math.max(0,Y*0x000002-1)

    if bit.band(Quadrant  ,2) ~= 0 then  -- Lower half
        Yclr= math.max(0,Y*0x020000-0x010000)
        Y= -Y
    end

    if bit.band(Quadrant+1,2) == 0 then  -- Left half
        Xclr= math.max(0,X*0x020000-0x010000)
        X= -X
    end
    Xclr, Yclr= Xclr+0x00FF00, Yclr+0x00FF00 -- Mix in some green

    gui.text(0,  0,string.format("%+4d",X),Xclr,0)
    gui.text(0, 16,string.format("%+4d",Y),Yclr,0)

    local vel= R2s(0x7E0B50)*0x10000 + R2u(0x7E0B60) -- X velocity
    local sign= "+"
    if vel < 0 then vel= -vel; sign= "-" end
    gui.text( 48,  0,string.format("%s%2X",sign,math.floor(vel/0x10000)),Xclr,0)
    gui.text( 72,  0,HexStr(vel%0x10000),0xC0C0C0,0)

    vel= R2s(0x7E0B30)*0x10000 + R2u(0x7E0B40) -- Y velocity
    sign= "+"
    if vel < 0 then vel= -vel; sign= "-" end
    gui.text( 48, 16,string.format("%s%2X",sign,math.floor(vel/0x10000)),Yclr,0)
    gui.text( 72, 16,HexStr(vel%0x10000),0xC0C0C0,0)

    gui.text( 56, 32,HexStr(R2u(0x7E0B20)),0xFFFFFF,0) -- General speed

    gui.text(112, 16,HexStr(R2u(0x7E0B70)),0x00FFFFFF,0x20000000) -- Y-Pos
    gui.text(144, 16,HexStr(R2u(0x7E0B80)),0x00C0C0C0,0x20000000)
    gui.text(112,  0,HexStr(R2u(0x7E0B90)),0x00FFFFFF,0x20000000) -- X-Pos
    gui.text(144,  0,HexStr(R2u(0x7E0BA0)),0x00C0C0C0,0x20000000)

    gui.text( 16, 32,string.format("%2X",R1u(0x7E0BE0))    ,0xC0C0C0,0)
    gui.text(  0, 32,string.format("%2X",MomentumDirection),0x00FF00,0)
    gui.text( 16, 48,string.format("%2X",R1u(0x7E0BD0)),0xC0C0C0,0)
    gui.text(  0, 48,string.format("%2X",R1u(0x7E0BD1)),0x00FFFF,0) -- Facing
    gui.text(  0, 64,HexStr(R2u(0x7E0C10)),0xFFFFFF,0)  -- Turning momentum

    gui.text(472,  0,string.format("%5d",R2u(0x7E0D00)),0xFFFFFF,0)--Checkpoint
end

local OldPaint= on_paint or function() end
--*****************************************************************************
local function BasicHUD()
--*****************************************************************************
    OldPaint()

    YourSpeed()
end
on_paint= BasicHUD


--[[
7E0B00 ?
7E0B10 - Buttons
7E0B20 - Speed
7E0B30 - Y velocity
7E0B40 - Y sub-velocity
7E0B50 - X velocity
7E0B60 - X sub-velocity
7E0B70 - Y position
7E0B80 - Y sub-position
7E0B90 - X position
7E0BA0 - X sub-position
7E0BB0 ?
7E0BC0 ?
7E0BD0 - Facing
7E0BE0 - Momentum
7E0BF0 ?
7E0C00 ?
7E0C10 - Turning speed
7E0C20 -
7E0C30 -
7E0C40 -
7E0C50 -
7E0C60 -
7E0C70 -
7E0C80 -
7E0C90 -
7E0CA0 -
7E0CB0 -
7E0CC0 -
7E0CD0 -
7E0CE0 -
7E0CF0 -
7E0D00 - Checkpoints passed
]]--