Tools updated

This commit is contained in:
2022-02-18 17:23:22 +01:00
parent 743fd2b8cc
commit f889faa472
4 changed files with 172 additions and 2 deletions

65
tools/fontedit.lua Normal file
View File

@@ -0,0 +1,65 @@
function init()
mode(1)
sel = 127
end
clicked=false
mx,my=0,0
function update()
color(0,7)
cls()
color(8,0)
for y=0,15 do
for x=0,15 do
print(chr(x+y*16),x+1,y+1)
end
end
poke(1200+((sel%16)+1+(flr(sel/16)+1)*40),15)
drawchar(sel,19,1)
if mousebutton(1) then
if mousex()>=1 and mousey()>=1 and mousex()<=16 and mousey()<=16 then
sel = mousex()-1+(mousey()-1)*16
elseif mousex()>=19 and mousey()>=1 and mousex()<=26 and mousey()<=8 then
if not clicked or mousex()~=mx or mousey()~=my then
clicked,mx,my=true,mousex(),mousey()
local pos = 2560+sel*8+(mousey()-1)
local bit = 1 << (7-(mousex()-19))
local value = peek(pos)
poke(pos, value ~ bit)
end
end
else
clicked = false
end
if btnp(KEY_S) then
local pos = 2560+sel*8
local string = "setchar("..sel..","..peek(pos)..","..peek(pos+1)..","..peek(pos+2)..","..peek(pos+3)..","..peek(pos+4)..","..peek(pos+5)..","..peek(pos+6)..","..peek(pos+7)..")"
toclipboard(string)
end
ink(4)
print("\143",mousex(), mousey())
end
function drawchar(char,x,y)
color(15,0)
local pos = 2560+char*8
for i=1,8 do
local val = peek(pos)
print(" ",x,y)
if val&1==1 then print("\143",x+7,y) end
if val&2==2 then print("\143",x+6,y) end
if val&4==4 then print("\143",x+5,y) end
if val&8==8 then print("\143",x+4,y) end
if val&16==16 then print("\143",x+3,y) end
if val&32==32 then print("\143",x+2,y) end
if val&64==64 then print("\143",x+1,y) end
if val&128==128 then print("\143",x,y) end
y=y+1
pos=pos+1
end
end