Compress location data into a single byte.

This commit is contained in:
Anna Rose 2019-12-11 19:23:28 -05:00
parent ea8b0360bc
commit c86589ec6a
3 changed files with 42 additions and 35 deletions

View File

@ -6,14 +6,33 @@ function init_debug()
debug_res = false debug_res = false
debug_map = false debug_map = false
debug_sfx = false debug_sfx = false
debug_mod_buffer = false debug_savedata = false
end end
function debug_f(mode) function debug_f(mode)
if (band(mode, 0x1)) debug_res = not debug_res if band(mode, 0x1) ~= 0 then
if (band(mode, 0x2)) debug_map = not debug_map debug_res = true
if (band(mode, 0x4)) debug_sfx = not debug_sfx else
if (band(mode, 0x8)) debuf_mod_buffer = not debug_mod_buffer 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 end
function teleport(x, y) function teleport(x, y)
@ -21,21 +40,10 @@ function teleport(x, y)
end end
function debug_print() function debug_print()
if debug_res then if (debug_res) debug_print_res()
debug_print_res() if (debug_map) debug_print_map()
end if (debug_sfx) debug_print_sfx()
if (debug_savedata) debug_print_savedata()
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
end end
function debug_print_res() function debug_print_res()
@ -47,8 +55,8 @@ function debug_print_res()
end end
function debug_print_sfx() function debug_print_sfx()
clip(64, 0, 8, 8) clip(120, 0, 8, 8)
print(stat(24), 64, 0, 15) print(stat(24), 120, 0, 15)
clip() clip()
end end
@ -59,11 +67,6 @@ function debug_print_map()
clip() clip()
end end
function debug_print_mod_buffer() function debug_print_savedata()
clip(0, 0, 16, 128) print(tostr(dget(0), 1), 16, 122, 15)
rectfill(0,0,16,128,0)
for k,v in pairs(mod_buffer) do
print(k .. ": " .. tostr(v))
end
clip()
end end

View File

@ -5,8 +5,7 @@ function init_menu()
end end
function menu_input() function menu_input()
-- todo: implement an actual menu menu_mode = false -- todo: implement an actual menu
menu_mode = false
end end
function draw_menu() function draw_menu()

View File

@ -5,16 +5,21 @@ function init_savegame()
end end
function load_game() function load_game()
player_x = dget(0) local pos = dget"0"
player_y = dget(1) player_x = flr(pos)
player_y = shl(pos, 16)
end end
function save_game() function save_game()
dset(0, player_x) -- store location in 1 byte by packing Y position into the nominal
dset(1, player_y) -- fraction section.
local pos = bor(player_x, lshr(player_y, 16))
dset(0, pos)
end end
-- delete the save data -- delete the save data
function clear_save() function clear_save()
memset(0x5e00, 0, 256) memset(0x5e00, 0, 256)
init_world""
init_player""
end end