Code review feedback, debug mode

This commit is contained in:
Kistaro Windrider 2022-12-31 23:54:27 -08:00
parent a2212c342f
commit 8a192f87a2
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -26,6 +26,13 @@ function music_off()
menuitem(3, "music: off", music_on) menuitem(3, "music: off", music_on)
end end
function gsv(s)
local ret=split(s,"\n")
for i,v in ipairs(ret) do
ret[i] = type(v) == "string" and split(v,"`") or {v} end
return ret
end
mnames={} mnames={}
function names(root) function names(root)
local n=mnames[root] local n=mnames[root]
@ -1728,13 +1735,6 @@ end
-->8 -->8
--hint system --hint system
function gsv(s)
local ret=split(s,"\n")
for i,v in ipairs(ret) do
ret[i] = type(v) == "string" and split(v,"`") or {v} end
return ret
end
function rot13(s) function rot13(s)
local sord = pack(ord(s,1,#s)) local sord = pack(ord(s,1,#s))
for i,c in ipairs(sord) do for i,c in ipairs(sord) do
@ -1758,21 +1758,29 @@ function hints:init()
for rec in all(h) do for rec in all(h) do
rec[4]=rot13(rec[4]) rec[4]=rot13(rec[4])
local lh = self[rec[1]] local lh = self[rec[1]]
if not lh then if lh then
lh = {rec}
self[rec[1]] = lh
else
add(lh,rec) add(lh,rec)
else
self[rec[1]] = {rec}
end end
end end
menuitem(1,"get hint",function() level.hintlevel+=1 end) menuitem(1,"get hint",function() level.hintlevel+=1 end)
menuitem(2,"hide hints",function() level.hintlevel=0 end) menuitem(2,"hide hints",function() level.hintlevel=0 end)
-- debug mode: enable mouse
poke(0x5f2d,1)
end end
hintflicker={7,10,9,8,8,9,10,7} hintflicker={7,10,9,8,8,9,10,7}
function hints:draw2() function hints:draw2()
pal() pal()
local c=hintflicker[t()%1*#hintflicker\1+1] local c=hintflicker[t()%1*#hintflicker\1+1]
-- debug mode: mouse coord display
if stat(34) != 0 then
local mousex, mousey = stat(32), stat(33)
print("x ("..mousex..", "..mousey..")",mousex,mousey,c)
end
for i,h in ipairs(self[level.ix]) do for i,h in ipairs(self[level.ix]) do
if (i > level.hintlevel) return if (i > level.hintlevel) return
local _,x,y,txt=unpack(h) local _,x,y,txt=unpack(h)