1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-05-14 11:43:24 -07:00

update patch

This commit is contained in:
Connor Olding 2016-11-27 15:59:10 -08:00
parent e59f958d0b
commit 39bf48de0a

View File

@ -13,39 +13,51 @@ local function parsenum(s)
if type(s) == 'number' then if type(s) == 'number' then
return s return s
end end
if s:sub(1, 2) == '0x' then if s:sub(1, 2) == '0x' or s:sub(1, 1) == '$' then
return tonumber(s, 16) return tonumber(s, 16)
elseif s:sub(1, 1) == '0' then elseif s:sub(1, 2) == '0o' or s:sub(1, 1) == '0' then
return tonumber(s, 8) return tonumber(s, 8)
elseif s:sub(1, 2) == '0b' or s:sub(1, 1) == '%' then
return tonumber(s, 2)
else else
return tonumber(s) return tonumber(s)
end end
end end
local function make_verbose_writer() local function make_verbose_writer()
-- TODO: further optimize
local buff = {} local buff = {}
local function write(i)
local a = buff[i+0] or nil
local b = buff[i+1] or nil
local c = buff[i+2] or nil
local d = buff[i+3] or nil
if a or b or c or d then
a = a and ("%02X"):format(a) or '--'
b = b and ("%02X"):format(b) or '--'
c = c and ("%02X"):format(c) or '--'
d = d and ("%02X"):format(d) or '--'
print(('%08X %s'):format(i, a..b..c..d))
end
end
local max = -1 local max = -1
local maxp = -1
return function(pos, b) return function(pos, b)
if pos then if pos then
buff[pos] = b buff[pos] = b
if pos > max then if pos > max then
max = pos max = pos
end end
if pos < 0x80000000 and pos > maxp then
maxp = pos
end
elseif max >= 0 then elseif max >= 0 then
-- TODO: optimize. iterating 536,870,912 times to reach 0x800000000 for i=0, maxp, 4 do
-- isn't the fastest thing, as you can imagine. write(i)
for i=0, max, 4 do end
local a = buff[i+0] or nil for i=0x80000000, max, 4 do
local b = buff[i+1] or nil write(i)
local c = buff[i+2] or nil
local d = buff[i+3] or nil
if a or b or c or d then
a = a and ("%02X"):format(a) or '--'
b = b and ("%02X"):format(b) or '--'
c = c and ("%02X"):format(c) or '--'
d = d and ("%02X"):format(d) or '--'
print(('%08X %s'):format(i, a..b..c..d))
end
end end
end end
end end
@ -74,9 +86,6 @@ local function inject(args)
end end
local function write(pos, b) local function write(pos, b)
--if args.extra_rom and args.extra_ram and pos >= args.extra_ram then
-- pos = pos - args.extra_ram + args.extra_rom
--elseif pos >= offset then
if pos >= offset then if pos >= offset then
pos = pos - offset pos = pos - offset
end end
@ -143,9 +152,7 @@ ap:flag("--dump-pre", "(debug) dump statements to stdout after preprocessi
ap:flag("--dump-post", "(debug) dump statements to stdout after expanding") ap:flag("--dump-post", "(debug) dump statements to stdout after expanding")
ap:flag("--dump-asm", "(debug) dump statements to stdout after assembling") ap:flag("--dump-asm", "(debug) dump statements to stdout after assembling")
--ap:option("-s --state", "--import and --export to this file") --ap:option("-s --state", "--import and --export to this file")
-- use -D defines instead -- TODO: use -D defines instead
--ap:option("--extra-rom", "dumb stuff"):convert(parsenum)
--ap:option("--extra-ram", "dumb stuff"):convert(parsenum)
local inject_args = ap:parse() local inject_args = ap:parse()