1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-11-04 13:09:03 -08:00
mm/Lua/lib/addrs/addrs.lua

55 lines
1.4 KiB
Lua
Raw Normal View History

2015-05-10 15:01:51 -07:00
local basics = require "addrs.basics"
local versions = require "addrs.versions"
local same = {
["O JP10"] = "O US10",
["O JP11"] = "O US11",
["O JP12"] = "O US12",
--["O JPGC MQ"] = "O USGC", -- maybe?
}
rawset(_G, 'Actor', function() end)
2015-05-10 15:01:51 -07:00
return function(hash)
local version = versions[hash] or VERSION_OVERRIDE
if version == nil then
2015-11-27 08:48:47 -08:00
error('unknown rom')
2015-05-10 15:01:51 -07:00
return
end
local v = version:sub(1, 2)
local rv = same[version] or version
local b = basics[rv]
local function AL(a, s) return A(b.link + a, s) end
local function AG(a, s)
2015-05-10 15:01:51 -07:00
if rv == 'M JP10' or rv == 'M JP11' then
if a >= 0x17000 then -- approximate
a = a - 0x20
end
end
return A(b.global + a, s)
end
local function AA(a, s)
2015-05-15 20:20:37 -07:00
if rv == 'O EUDB MQ' then
if a >= 0x130 then -- approximate
a = a + 0x10
end
end
return A(b.actor + a, s)
end
2015-05-10 15:01:51 -07:00
2015-05-10 15:17:26 -07:00
local subdir = version:sub(1, 1)
local rvs = rv:sub(3)
rawset(_G, 'AL', AL)
rawset(_G, 'AG', AG)
rawset(_G, 'AA', AA)
2015-05-10 15:17:26 -07:00
local addrs = require("addrs."..subdir.."."..rvs)
2015-05-10 15:01:51 -07:00
addrs.version = version
addrs.oot = v == "O "
addrs.mm = v == "M "
2015-05-10 15:17:26 -07:00
local common = require("addrs."..subdir..".common")
2015-05-10 15:01:51 -07:00
return setmetatable(addrs, {__index=common})
end