User File #36618019721021517

Upload All User Files

#36618019721021517 - (GBA) Mario Golf: Advance Tour script v1.

MGAT_Basic.lua
544 downloads
Uploaded 1/27/2017 2:02 AM by FatRatKnight (see all 245)
It's a script I was using when TASing on VBA, already converted for BizHawk.
Oh, and sorry about all those hexadecimal numbers. It's actually my preference, and if you refuse to get used to it, I'll upload a new script that reads things in decimal instead.
  • Top-left: X, Y, and elevation of ball and pin (hex); Distance left to pin (hex); Direction being aimed (hex)
  • Bottom-left: RNG (Hex; Should really remain in hexadecimal)
  • Bottom-right: Maximum power (dec); power (dec); impact timing (dec)
It's a fairly basic script. But it had what I wanted. Reading distance to pin should help in knowing just how close you got.
local R1u, R1s= memory.read_u8    , memory.read_s8
local R2u, R2s= memory.read_u16_le, memory.read_s16_le
local R4u, R4s= memory.read_u32_le, memory.read_s32_le

--*****************************************************************************
local function FetchAddrDomainGBA(a,method)
--*****************************************************************************
--I am furious at the design away from the bus. It used to exist! Why remove?
--I do not want to code in removing offsets to pointers every time I read one.
--This function was made because I insist on full pointers. Has only what I know.

    if     (a >= 0x02000000) and (a < (0x02000000+memory.getmemorydomainsize("EWRAM"))) then
        return a-0x02000000, "EWRAM"
    elseif (a >= 0x03000000) and (a < (0x03000000+memory.getmemorydomainsize("IWRAM"))) then
        return a-0x03000000, "IWRAM"
    elseif (a >= 0x08000000) and (a < (0x08000000+memory.getmemorydomainsize("ROM"))) then
        return a-0x08000000, "ROM"
    else
        error("Unknown address " .. a,2)
    end
end

local function R1U(a) return R1u(FetchAddrDomainGBA(a)) end
local function R1S(a) return R1s(FetchAddrDomainGBA(a)) end
local function R2U(a) return R2u(FetchAddrDomainGBA(a)) end
local function R2S(a) return R2s(FetchAddrDomainGBA(a)) end
local function R4U(a) return R4u(FetchAddrDomainGBA(a)) end
local function R4S(a) return R4s(FetchAddrDomainGBA(a)) end

--*****************************************************************************
local function DistCalc(x1,y1 , x2,y2)
--*****************************************************************************
--Calculates distance between two points

    local x= x2-x1; x= x*x
    local y= y2-y1; y= y*y
    return math.sqrt(x+y)
end

--local ZZ= 0
--*****************************************************************************
local function BasicHUD()
--*****************************************************************************
--Has my general stuff.

    gui.pixelText(  0,  0,string.format("%8X",R4S(0x02030740)))  --X
    gui.pixelText(  0,  7,string.format("%8X",R4S(0x02030748)))  --Y
    gui.pixelText(  0, 14,string.format("%8X",R4S(0x02030744)))  --Height

    gui.pixelText( 36,  0,string.format("%8X",R4S(0x020312F8)))  --X
    gui.pixelText( 36,  7,string.format("%8X",R4S(0x02031300)))  --Y
    gui.pixelText( 36, 14,string.format("%8X",R4S(0x020312FC)))  --Height

    local d= DistCalc(R4S(0x02030740),R4S(0x02030748),
                      R4S(0x020312F8),R4S(0x02031300))
    gui.pixelText( 72,  0,string.format("%8X",math.floor(d)))

    gui.pixelText(  0, 28,string.format("%4X",R2U(0x03007C68)))  --Aim
    gui.pixelText(140,140,string.format("%4d",R1S(0x03007CA8)))  --Pow
    gui.pixelText(160,140,string.format("%4d",R1S(0x03007C70)))  --Imp
    gui.pixelText(140,133,string.format("%4d",R1S(0x02031338)))  --Max

    gui.pixelText(  0,154,string.format("%8X",R4S(0x03001214)))  --RNG

--    gui.pixelText( 80, ZZ,"Text test.#")
--    ZZ= (ZZ+1)%156
end
event.onframeend(BasicHUD)