gists/gs/gs.lua
2019-03-11 06:50:27 +01:00

32 lines
880 B
Lua

package.path = package.path..";./?/init.lua"
local lips = require "lips"
function make_gameshark_writer()
local buff = {}
local max = -1
return function(pos, b)
if pos then
pos = pos % 0x80000000
buff[pos] = b
if pos > max then
max = pos
end
elseif max >= 0 then
for i=0, max, 2 do
local a = buff[i+0]
local b = buff[i+1]
if a and b then
print(('81%06X %s'):format(i, a..b))
elseif a then
print(('80%06X 00%s'):format(i, a))
elseif b then
print(('80%06X 00%s'):format(i + 1, b))
end
end
end
end
end
local gs = make_gameshark_writer()
lips('test.asm', gs, {unsafe=true, offset=0x80000000})
gs()