Compress location data into a single byte.
This commit is contained in:
parent
ea8b0360bc
commit
c86589ec6a
61
debug.lua
61
debug.lua
|
@ -6,14 +6,33 @@ function init_debug()
|
|||
debug_res = false
|
||||
debug_map = false
|
||||
debug_sfx = false
|
||||
debug_mod_buffer = false
|
||||
debug_savedata = false
|
||||
end
|
||||
|
||||
function debug_f(mode)
|
||||
if (band(mode, 0x1)) debug_res = not debug_res
|
||||
if (band(mode, 0x2)) debug_map = not debug_map
|
||||
if (band(mode, 0x4)) debug_sfx = not debug_sfx
|
||||
if (band(mode, 0x8)) debuf_mod_buffer = not debug_mod_buffer
|
||||
if band(mode, 0x1) ~= 0 then
|
||||
debug_res = true
|
||||
else
|
||||
debug_res = false
|
||||
end
|
||||
|
||||
if band(mode, 0x2) ~= 0 then
|
||||
debug_map = true
|
||||
else
|
||||
debug_map = false
|
||||
end
|
||||
|
||||
if band(mode, 0x4) ~= 0 then
|
||||
debug_sfx = true
|
||||
else
|
||||
debug_sfx = false
|
||||
end
|
||||
|
||||
if band(mode, 0x8) ~= 0 then
|
||||
debug_savedata = true
|
||||
else
|
||||
debug_savedata = false
|
||||
end
|
||||
end
|
||||
|
||||
function teleport(x, y)
|
||||
|
@ -21,21 +40,10 @@ function teleport(x, y)
|
|||
end
|
||||
|
||||
function debug_print()
|
||||
if debug_res then
|
||||
debug_print_res()
|
||||
end
|
||||
|
||||
if debug_map then
|
||||
debug_print_map()
|
||||
end
|
||||
|
||||
if debug_sfx then
|
||||
debug_print_sfx()
|
||||
end
|
||||
|
||||
if debug_mod_buffer then
|
||||
debug_print_mod_buffer()
|
||||
end
|
||||
if (debug_res) debug_print_res()
|
||||
if (debug_map) debug_print_map()
|
||||
if (debug_sfx) debug_print_sfx()
|
||||
if (debug_savedata) debug_print_savedata()
|
||||
end
|
||||
|
||||
function debug_print_res()
|
||||
|
@ -47,8 +55,8 @@ function debug_print_res()
|
|||
end
|
||||
|
||||
function debug_print_sfx()
|
||||
clip(64, 0, 8, 8)
|
||||
print(stat(24), 64, 0, 15)
|
||||
clip(120, 0, 8, 8)
|
||||
print(stat(24), 120, 0, 15)
|
||||
clip()
|
||||
end
|
||||
|
||||
|
@ -59,11 +67,6 @@ function debug_print_map()
|
|||
clip()
|
||||
end
|
||||
|
||||
function debug_print_mod_buffer()
|
||||
clip(0, 0, 16, 128)
|
||||
rectfill(0,0,16,128,0)
|
||||
for k,v in pairs(mod_buffer) do
|
||||
print(k .. ": " .. tostr(v))
|
||||
end
|
||||
clip()
|
||||
function debug_print_savedata()
|
||||
print(tostr(dget(0), 1), 16, 122, 15)
|
||||
end
|
||||
|
|
3
menu.lua
3
menu.lua
|
@ -5,8 +5,7 @@ function init_menu()
|
|||
end
|
||||
|
||||
function menu_input()
|
||||
-- todo: implement an actual menu
|
||||
menu_mode = false
|
||||
menu_mode = false -- todo: implement an actual menu
|
||||
end
|
||||
|
||||
function draw_menu()
|
||||
|
|
13
savegame.lua
13
savegame.lua
|
@ -5,16 +5,21 @@ function init_savegame()
|
|||
end
|
||||
|
||||
function load_game()
|
||||
player_x = dget(0)
|
||||
player_y = dget(1)
|
||||
local pos = dget"0"
|
||||
player_x = flr(pos)
|
||||
player_y = shl(pos, 16)
|
||||
end
|
||||
|
||||
function save_game()
|
||||
dset(0, player_x)
|
||||
dset(1, player_y)
|
||||
-- store location in 1 byte by packing Y position into the nominal
|
||||
-- fraction section.
|
||||
local pos = bor(player_x, lshr(player_y, 16))
|
||||
dset(0, pos)
|
||||
end
|
||||
|
||||
-- delete the save data
|
||||
function clear_save()
|
||||
memset(0x5e00, 0, 256)
|
||||
init_world""
|
||||
init_player""
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user