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