User File #6741742267906297

Upload All User Files

#6741742267906297 - My display script for SNES Brandish

Brandish.lua
Game: Brandish ( SNES, see all files )
793 downloads
Uploaded 5/22/2013 2:21 PM by FatRatKnight (see all 245)
Just shows a few stats I like.
Arm Strength - Level, exp, and exp to allocate
Knowledge - The same
Magic Endurance - Here too
Luck - Current, maximum, and hidden timer that changes it
Clock - Just the internal timer
Gold held - Why not?
RNG - Immediate value and count of rolls from default state
HP - Current and maximum
MP - Current, maximum, and counter for next MP
List of creature info - Flags of unknown meaning, X-pos, Y-pos, HP
local R1u , R1s= memory.readbyte  , memory.readsbyte
local R2u , R2s= memory.readword  , memory.readsword
local R4u , R4s= memory.readdword , memory.readsdword

local shade= 0x40000000  -- 75% opacity black

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

--*****************************************************************************
local function GuiTextRight(x,y,str,c1,c2)
--*****************************************************************************
    str= tostring(str)
    x= x - (#str)*8
    gui.text(x,y,str,c1,c2)
end

--#############################################################################
--#############################################################################

--*****************************************************************************
local function Roll(r)
--*****************************************************************************
    return bit.band(0xFFFF,
        r*2 + bit.parity(bit.extract(r,14),bit.extract(r,0))
    )
end

local rng, c= 0x7F28, 0
--*****************************************************************************
local function CountRNG()
--*****************************************************************************
    local r= R2u(0x7E0221)
    local i= 0
    while rng ~= r do
        if i >= 32767 then c= -1; rng= r; return end
        rng= Roll(rng)
        i=i+1
    end
    c= (c+i)%32767
end


local MonsStr= "%2X %2d %2d %3d"
--*****************************************************************************
local function ListMons(ResX)
--*****************************************************************************
    gui.right_gap(8*(#MonsStr))

    for i= 0, 31 do
        local addr= 0x7E053F + 0x5E*i
        gui.text(ResX, 14*i, string.format(MonsStr,
            R1u(addr+0x49),
            R1u(addr+0x40),
            R1u(addr+0x41),
            R1u(addr+0x4A)
        ))
    end
end

--*****************************************************************************
local function Clock(x,y)
--*****************************************************************************
    gui.text(x,y,string.format("%2d:%2d:%2d.%2d",
        R2u(0x7E1DFD),
        R2u(0x7E1DFF),
        R2u(0x7E1E01),
        R2u(0x7E1E03)
    ))
end

--*****************************************************************************
local function StatAndExp(x,y,addr,str)
--*****************************************************************************
    GuiTextRight(x,y,R1u(addr),0xFFFFFF,shade)
    gui.text(x,y,string.format(".%2d",R1u(addr+1)),0xC0C0C0,shade)

    local Growth= R2u(addr+0x17FA)
    if Growth ~= 0 then
        GuiTextRight(x+24,y+16, "+" .. Growth, 0x00FFFF,shade)
    else
        gui.text(x,y+16,str,0xFFFF00,shade)
    end
end

--*****************************************************************************
local function StatAndMax(x,y,addr)
--*****************************************************************************
    GuiTextRight(x,y,R1u(addr),0xFFFFFF,shade)
    gui.text(x,y,string.format("/%3d",R1u(addr+1)),0xC0C0C0,shade)
end

--#############################################################################
--#############################################################################

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

    local ResX, ResY= gui.resolution()
    local ScX, ScY= ResX/256, ResY/224

    ListMons(ResX)

    Clock(260,0)
    StatAndMax(   88*ScX,200*ScY,0x7E0589) -- HP
    StatAndMax(  220*ScX,200*ScY,0x7E058B) -- MP

    StatAndMax(  200,  0,0x7E058D) -- Luck
    local clr= 0xFFFF00
    if R2s(0x7E1D9B) > 0 then clr= 0x00FF00 end
    GuiTextRight(232, 16,R2u(0x7E1D99),clr,shade)

    StatAndExp(   32,  0,0x7E058F,"Arm") -- Arm Strength   0x7E1D89
    StatAndExp(   88,  0,0x7E0591,"Kno") -- Knowledge
    StatAndExp(  140,  0,0x7E0593,"MgE") -- Magic Endurance
    StatAndExp(  200*ScX,  0,0x7E0595,"Lvl") -- Level


    GuiTextRight(236*ScX,192*ScY,R2u(0x7E1D97),0xC0FFC0,shade) -- MP recovery

    GuiTextRight(256*ScX   ,  0,R4u(0x7E43C2),0xFFFF00,shade) -- Gold on hand
    GuiTextRight(256*ScX   , 16,HexStr(R4u(0x7E021F)),0xFFFFFF,shade) -- RNG

    CountRNG()
    GuiTextRight(256*ScX-24, 32,c,0xFFFFFF,shade)
end
gui.repaint()