User File #24001228629169337

Upload All User Files

#24001228629169337 - GBC Azure Dreams - VBA script to read up items

ADreams.lua
Game: Azure Dreams ( GBC, see all files )
704 downloads
Uploaded 7/8/2015 9:13 PM by FatRatKnight (see all 245)
Exhibit #7. Something about Azure Dreams, now. Contains a bit of information about the RAM map, in particular, where the items are located and the RNG information. Incomplete item listing, but it has a structure to let you know what it doesn't know.
I recall using this to perfect my game, in that I pick up ridiculous amounts of stat-boosting seeds and such. If anyone plans to TAS the GBC version rather than the PSX one, I happen to have a little information on the RNG already. Take it!
local R1u= memory.readbyte
local R2u= memory.readword

--*****************************************************************************
local function HexStr(v)
--*****************************************************************************
    return string.upper(string.format("%x",v))
end
--*****************************************************************************
local function GuiTextRight(x,y,str)
--*****************************************************************************
    x= x - string.len(str)*4
    gui.text(x,y,str)
end

local keys, lastkeys= input.get(), input.get()  --So we have some default state
--*****************************************************************************
local function UpdateKeys()  lastkeys= keys; keys= input.get()  end
local function Press(k)      return keys[k] and not lastkeys[k] end
--*****************************************************************************


local items= {
[0x00]= {name="void"},
[0x20]= {name="Check"},
[0x24]= {name="Paisley"},
[0x25]= {name="Swirly"},
[0x27]= {name="Triangle"},
[0x28]= {name="Wave"},
[0x29]= {name="Floral"},
[0x2B]= {name="Cutesy"},
[0x2C]= {name="Star"},
[0x2D]= {name="Apostrophe"},
[0x2E]= {name="Splotchy"},
[0x30]= {name="Polka Pot"},
[0x31]= {name="Camouflage"},
[0x32]= {name="Eyeball"},
[0x35]= {name="Jagged"},
[0x38]= {name="Zebra"},
--[0x3D]= {name="Frily?"},
[0x41]= {name="tw1",
    [0x00]= "TrollArm"},
[0x42]= {name="tw2",
    [0x00]= "Tomahawk"},
[0x43]= {name="tw3",
    [0x00]= "Hammer"},
[0x45]= {name="leash",
    [0x00]= "ElfRein"},
[0x46]= {name="wing",
    [0x00]= "Feather"},
[0x48]= {name="oil",
    [0x00]= "Blue Oil",
    [0x01]= "Red Oil"},
[0x49]= {name="sand",
    [0x00]= "PaleSand",
    [0x01]= "BlueSand",
    [0x02]= "Red Sand"},
[0x4A]= {name="spec",
    [0x00]= "StarSpec",
    [0x01]= "TrueSpec"},
[0x4B]= {name="eye",
    [0x00]= "GoldEye",
    [0x01]= "MonstEye",
    [0x02]= "TrapEye",
    [0x03]= "ExitEye"},
[0x4C]= {name="bell",
    [0x00]= "TameBell",
    [0x01]= "EvilBell"},
[0x4D]= {name="ray",
    [0x00]= "Fire Ray",
    [0x01]= "WaterRay",
    [0x02]= "Wind Ray",
    [0x03]= "AlcheRay",
    [0x04]= "Hex-Ray",
    [0x05]= "ViviRay"},
[0x4E]= {name="gem",
    [0x00]= "WindGem",
    [0x01]= "WaterGem",
    [0x02]= "FireGem"},
[0x4F]= {name="seed",
    [0x00]= "Tovaseed",
    [0x01]= "Larseed",
    [0x02]= "Windseed",
    [0x03]= "Seaseed",
    [0x04]= "Lumiseed",
    [0x05]= "Alacseed",
    [0x06]= "Mazaseed",
    [0x07]= "Fortseed",
    [0x08]= "Feroseed"},
[0x50]= {name="fruit",
    [0x00]= "Burnseed",
    [0x01]= "Olimseed",
    [0x02]= "Halfseed",
    [0x03]= "Dubseed",
    [0x04]= "Zoneseed",
    [0x05]= "Ovaseed",
    [0x06]= "Leveseed",
    [0x07]= "Lioseed",
    [0x08]= "Levaseed",
    [0x09]= "Tumaseed",
    [0x0A]= "Big Vit",
    [0x0B]= "Vit Seed"},
[0x51]= {name="herb",
    [0x00]= "Eyegrass",
    [0x01]= "Dormint",
    [0x03]= "Sapleaf",
    [0x04]= "Paralyn",
    [0x06]= "Fortia",
    [0x08]= "Heal-All",
    [0x09]= "Wakesage",
    [0x0A]= "Rouse",
    [0x0C]= "Mediherb"},
[0x52]= {name="orb",
    [0x00]= "SealOrb",
    [0x02]= "WeakOrb",
    [0x03]= "SleepOrb",
--    [0x04]= "FlameOrb",
    [0x05]= "BlindOrb",
    [0x06]= "ReviOrb",
    [0x07]= "RefraOrb",
    [0x08]= "HydrOrb",
    [0x09]= "VenomOrb",
    [0x0B]= "FireOrb",
    [0x0C]= "IgniOrb",
    [0x0D]= "FlameOrb"},
[0x53]= {name="shield",
    [0x06]= "Crusader",
    [0x07]= "Florent",
    [0x09]= "SkinDeep",
    [0x0A]= "Oak Leaf"},
[0x54]= {name="wand",
    [0x00]= "SealWand",
    [0x01]= "GalvWand",
    [0x02]= "IceWand",
    [0x03]= "RoseWand",
    [0x04]= "GoldWand",
    [0x05]= "ParaWand",
    [0x08]= "Crook"},
[0x55]= {name="sword",
    [0x07]= "Damascus",
    [0x08]= "Ironsong",
    [0x09]= "Bronzino",
    [0x0A]= "Inca Sun"},
[0x58]= {name="coin",
    [0x00]= "Penny"},
[0xA0]= {name="trap",
    [0x00]= "Elevator"}
}
--18
--21
--62
local FavTable= {
    Tovaseed= true,
    Alacseed= true,
    Fortseed= true,
    Feroseed= true,
    Mediherb= true,
    Mazaseed= true,
    GoldWand= true,
    ["Big Vit"]= true,
    ["Vit Seed"]= true
}

local itemaddr= 0xD191
--*****************************************************************************
local function PaintItemList()
--*****************************************************************************
    local y= 0
    for i= 0, 39 do
        local addr= itemaddr+7*i
        local type= R1u(addr+2)
        if (R1u(addr+6) ~= 0) and (type ~= 0) and (type ~= 0xA0) then
            if items[type] then
                local id= R1u(addr+3)
                if items[type][id] then
                    local color= -0x00000001
                    if FavTable[items[type][id]] then color= 0x00FFFFFF end
                    gui.text(1,y,items[type][id],color)
                else
                    gui.text( 1,y,items[type].name,0x00FF00FF)
                    GuiTextRight(50,y,HexStr(id))
                end
            else
                gui.text( 1,y,"???",-0x0000FF01)
                GuiTextRight(40,y,HexStr(type))
                GuiTextRight(50,y,HexStr(R1u(addr+3)))
            end
            GuiTextRight(60,y,HexStr(R1u(addr+4)))
            y=y+8
        end
    end
end

--*****************************************************************************
local function ItemStuff(index)
--*****************************************************************************
    local y= index*8
    GuiTextRight(16,y,HexStr(R1u(0xD197+index*7)))
    GuiTextRight(32,y,R1u(0xD191+index*7))
    GuiTextRight(48,y,R1u(0xD192+index*7))
    GuiTextRight(64,y,HexStr(R1u(0xD193+index*7)))
    GuiTextRight(80,y,HexStr(R1u(0xD194+index*7)))
    GuiTextRight(96,y,HexStr(R1u(0xD195+index*7)))
    GuiTextRight(112,y,HexStr(R1u(0xD196+index*7)))
--    GuiTextRight(128,y,string.format("%x",0xD191+index*7))
end

--*****************************************************************************
local function Roll(r)   return (r*  23 + 2345)%4567 end
local function Unroll(r) return (r*1390 + 1288)%4567 end
--*****************************************************************************

local function NullFN() end
--*****************************************************************************
local function StuffScanner()
--*****************************************************************************
    local Trap, Triggered= 0, 0
    local items= 0
    for i= 0, 39 do
        local addr= 0xD191 + i*7

        local a= R1u(addr+6)  -- Identification?
        if     a == 255 then Trap= Trap+1
        elseif a == 115 then Trap= Trap+1; Triggered= Triggered+1
        elseif a == 117 then NullFN() -- Elevator
        elseif a == 0 then NullFN()
        else   items= items+1
        end
    end
    GuiTextRight(140,0,Triggered .. "/" .. Trap)
    GuiTextRight(140,8,items)
end

--*****************************************************************************
local function Fn()
--*****************************************************************************
    for i= 0,16 do
        ItemStuff(i)
    end
end

local MaxRNG= 0
local MinRNG= 65535
local SeenRNGs= {n= 0}
--*****************************************************************************
local function RNGmax()
--*****************************************************************************
    NewRNG= R2u(0xC83A)
    if not SeenRNGs[NewRNG] then
        SeenRNGs[NewRNG]= true
        SeenRNGs.n= SeenRNGs.n+1
        print(string.format("%4d",NewRNG))
    end
    MaxRNG= math.max(MaxRNG,NewRNG)
    MinRNG= math.min(MinRNG,NewRNG)
    GuiTextRight(120,110,MaxRNG)
    GuiTextRight(120,100,MinRNG)
    GuiTextRight(120,130,SeenRNGs.n)
end

local CheatRNG= 4566
--*****************************************************************************
local function SetRNG()
--*****************************************************************************
    CheatRNG= (CheatRNG%4566)+1
    memory.writeword(0xC83A,CheatRNG)
end

local Found= 0
--*****************************************************************************
local function FindRNG(x)
--*****************************************************************************
    if x == R2u(0xC83A) then Found= movie.framecount() end
end

while true do
    UpdateKeys()
--    Fn()
    StuffScanner()
    PaintItemList()
--    RNGmax()
--    if Press("Z") then SetRNG() end
    GuiTextRight(120,120,R2u(0xC83A))
--    FindRNG(62)
--    GuiTextRight(120,130,Found)
    emu.frameadvance()
end