1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-11-14 15:09:02 -08:00

add a gameshark writer

This commit is contained in:
Connor Olding 2016-12-28 03:11:22 -08:00
parent af042efba1
commit 793a454b38
2 changed files with 28 additions and 2 deletions

2
TODO
View file

@ -16,8 +16,6 @@ directive aliases, are these right?
add basic command-line interface (patch.lua)
add a gameshark writer
improve writer performance (just copypaste what you did in patch.lua)
allow generation of shared object files (zelda overlays specifically)

View file

@ -82,4 +82,32 @@ function writers.make_tester()
end
end
function writers.make_gameshark()
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]
a = a and ("%02X"):format(a)
b = b and ("%02X"):format(b)
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
return writers