diff --git a/tools/fontedit.lua b/tools/fontedit.lua new file mode 100644 index 0000000..1fb8def --- /dev/null +++ b/tools/fontedit.lua @@ -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 \ No newline at end of file diff --git a/tools/mapedit.lua b/tools/mapedit.lua index ddb400f..f8f8eac 100644 --- a/tools/mapedit.lua +++ b/tools/mapedit.lua @@ -1,4 +1,3 @@ -ind = 22 function init() mode(2) map = {} @@ -7,7 +6,6 @@ function init() map[i] = 32 col[i] = 0x0f end - map[ind] = 65 sel_col = 0x0f sel_chr = 65 end @@ -76,10 +74,17 @@ function draw_map() map[mx+my*20] = sel_chr col[mx+my*20] = sel_col end + if mousebutton(3) then + col[mx+my*20] = sel_col + end if btn(KEY_SPACE) then sel_chr = peek(mx+my*20) sel_col = peek(300+mx+my*20) end + if btnp(KEY_UP) then for i=20,299 do map[i-20]=map[i]col[i-20]=col[i] end end + if btnp(KEY_DOWN) then for i=279,0,-1 do map[i+20]=map[i]col[i+20]=col[i] end end + if btnp(KEY_LEFT) then for i=0,298 do map[i]=map[i+1]col[i]=col[i+1] end end + if btnp(KEY_RIGHT) then for i=299,1,-1 do map[i]=map[i-1]col[i]=col[i-1] end end blink = blink - 1 if blink < 30 then @@ -88,4 +93,15 @@ function draw_map() local c = peek(300+(mx+my*20)) poke(300+(mx+my*20), c~0xff) end + + if btn(KEY_S) then + fileout("map.bin", 0, 600); + elseif btn(KEY_L) then + filein("map.bin", 0, 600); + for i=0,299 do + map[i] = peek(i) + col[i] = peek(300+i) + end + end + end diff --git a/tools/scredit.lua b/tools/scredit.lua index 7ccf015..4692c15 100644 --- a/tools/scredit.lua +++ b/tools/scredit.lua @@ -85,6 +85,11 @@ function draw_map() sel_col = peek(1200+mx+my*40) end + if btnp(KEY_UP) then for i=40,1199 do map[i-40]=map[i]col[i-40]=col[i] end end + if btnp(KEY_DOWN) then for i=1159,0,-1 do map[i+40]=map[i]col[i+40]=col[i] end end + if btnp(KEY_LEFT) then for i=0,1198 do map[i]=map[i+1]col[i]=col[i+1] end end + if btnp(KEY_RIGHT) then for i=1199,1,-1 do map[i]=map[i-1]col[i]=col[i-1] end end + blink = blink - 1 if blink < 30 then if blink==0 then blink = 60 end diff --git a/tools/spritedit.lua b/tools/spritedit.lua new file mode 100644 index 0000000..f373c72 --- /dev/null +++ b/tools/spritedit.lua @@ -0,0 +1,84 @@ +function init() + ink_color = 15 + paper_color = 0 + setchar(0,0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff) + sprite={0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03} +end + +function update() + color(15,1) + cls() + color(ink_color,paper_color) + drawbigspr(sprite,1,1) + drawspr(sprite,65) + print("AB",18,1) print("CD",18,2) + + for i=0,15 do + color(0,i) + poke(721+i,0) poke(1921+i,i<<4) + poke(761+i,0) poke(1961+i,i<<4) + end + + poke(1921+ink_color, peek(1921+ink_color)+4) + poke(1961+paper_color, peek(1961+paper_color)+4) + + if mousebutton(1) and mousex()>=1 and mousey()>=18 and mousex()<=16 and mousey()<=19 then + if mousey()==18 then + ink_color = mousex()-1 + else + paper_color = mousex()-1 + end + end + + handlesprmouse() +end + +mousepressed = false +mousepos = {x=-1,y=-1} +function handlesprmouse() + local mx,my=mousex(),mousey() + if mx>=1 and my>=1 and mx<=16 and my<=16 then + if mousebutton(1) then + if (not mousepressed or (mousepos.x ~= mx or mousepos.y ~= my)) then + mousepressed = true mousepos.x = mx mousepos.y = my + local quadrant = flr((mx-1)/8)+flr((my-1)/8)*2 + local x=(mx-1)%8 + local y=(my-1)%8 + local val = sprite[quadrant*8+y+1] + val = val ~ (1<<(7-x)) + sprite[quadrant*8+y+1] = val + end + else + mousepressed = false + end + end +end + +function drawbigspr(spr,x,y) + drawbigsprchr(spr,0,x,y) + drawbigsprchr(spr,1,x+8,y) + drawbigsprchr(spr,2,x,y+8) + drawbigsprchr(spr,3,x+8,y+8) +end + +function drawbigsprchr(spr,chr,x,y) + local pos = 1+chr*8 + for i=1,8 do + local val = spr[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 + +function drawspr(spr,chr) + for i=0,31 do poke(i+2560+chr*8,spr[i+1]) end +end \ No newline at end of file