I believe copySpriteMask is broken. It skips transparent color in horizontal direction instead of not printing it.
Here is code, same sprite with and without mask. mask in this case is an ugly pink. You might need the magnifying glass to see what is going on, but even without magnifying glass it the distortion is visible.
Code:
WHITE=zmg.makeColor(255,255,255)
GREY=zmg.makeColor(128,128,128)
BLACK=zmg.makeColor(0,0,0)
EDIT=zmg.makeColor(251,210,128)
MASK=zmg.makeColor(255,0,255)
SCREENX,SCREENY=384,216
tiles={ -- {{{
w=17,
h=17,
dx=16,
dy=12,
[0]=
"F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81F00000000000000000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81F00000000000000000000000000000000000000000000F81FF81FF81F\z
F81F000000000000000000000000000000000000000000000000000000000000F81F\z
00000000000000000000000000000000000000000000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
F81F000000000000000000000000000000000000000000000000000000000000F81F\z
F81FF81FF81F00000000000000000000000000000000000000000000F81FF81FF81F\z
F81FF81FF81FF81FF81FF81F00000000000000000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
",
"F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81F00000000000000000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81F00000000000000000000000000000000000000000000F81FF81FF81F\z
F81F000000000000000000000000000000000000000000000000000000000000F81F\z
00000000000000000000000000000000000000000000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
0000000000000000000000000000FF80FF80FF800000000000000000000000000000\z
000000000000000000000000FF80FF80FF80FF80FF80000000000000000000000000\z
000000000000000000000000FF80FF80FF80FF80FF80000000000000000000000000\z
000000000000000000000000FF80FF80FF80FF80FF80000000000000000000000000\z
0000000000000000000000000000FF80FF80FF800000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
00000000000000000000000000000000000000000000000000000000000000000000\z
F81F000000000000000000000000000000000000000000000000000000000000F81F\z
F81FF81FF81F00000000000000000000000000000000000000000000F81FF81FF81F\z
F81FF81FF81FF81FF81FF81F00000000000000000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
",
"F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81F00000000000000000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81F00000000000000000000000000000000000000000000F81FF81FF81F\z
F81F00000000000000000000FBE4FBE4FBE4FBE4FBE400000000000000000000F81F\z
00000000000000000000FBE4FE41FE41FE41FE41FE41FBE400000000000000000000\z
0000000000000000FBE4FE41FE41FE41FE41FE41FE41FE41FBE40000000000000000\z
000000000000FBE4FE41FE41FE41FE41FE41FE41FE41FE41FE41FBE4000000000000\z
000000000000FBE4FE41FE41FE41FE41FE41FE41FE41FE41FE41FBE4000000000000\z
000000000000FBE4FE41FE41FE41FE41FE41FE41FE41FE41FE41FBE4000000000000\z
000000000000FBE4FE41FE41FE41FE41FE41FE41FE41FE41FE41FBE4000000000000\z
000000000000FBE4FE41FE41FE41FE41FE41FE41FE41FE41FE41FBE4000000000000\z
0000000000000000FBE4FE41FE41FE41FE41FE41FE41FE41FBE40000000000000000\z
00000000000000000000FBE4FE41FE41FE41FE41FE41FBE400000000000000000000\z
F81F00000000000000000000FBE4FBE4FBE4FBE4FBE400000000000000000000F81F\z
F81FF81FF81F00000000000000000000000000000000000000000000F81FF81FF81F\z
F81FF81FF81FF81FF81FF81F00000000000000000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
",
"F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81F00000000000000000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81F00000000000000000000000000000000000000000000F81FF81FF81F\z
F81F00000000000000000000FBE4FBE4FBE4FBE4FBE400000000000000000000F81F\z
00000000000000000000FBE488028802880288028802FBE400000000000000000000\z
0000000000000000FBE48802880288028802880288028802FBE40000000000000000\z
000000000000FBE4880288028802880288028802880288028802FBE4000000000000\z
000000000000FBE4880288028802880288028802880288028802FBE4000000000000\z
000000000000FBE4880288028802880288028802880288028802FBE4000000000000\z
000000000000FBE4880288028802880288028802880288028802FBE4000000000000\z
000000000000FBE4880288028802880288028802880288028802FBE4000000000000\z
0000000000000000FBE48802880288028802880288028802FBE40000000000000000\z
00000000000000000000FBE488028802880288028802FBE400000000000000000000\z
F81F00000000000000000000FBE4FBE4FBE4FBE4FBE400000000000000000000F81F\z
F81FF81FF81F00000000000000000000000000000000000000000000F81FF81FF81F\z
F81FF81FF81FF81FF81FF81F00000000000000000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
",
"F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81F000000007BEF00000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81F000000000000B2C0B2C07BEF7BEFB2C0000000000000F81FF81FF81F\z
F81F00000000B2C0B2C0B2C0B2C0B2C07BEF7BEFB2C0B2C0B2C0B2C000000000F81F\z
00007BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF0000\z
00007BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF0000\z
0000B2C07BEF7BEFB2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C00000\z
0000B2C07BEF7BEFB2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C00000\z
0000B2C07BEF7BEFB2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C00000\z
0000B2C07BEF7BEFB2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C0B2C00000\z
00007BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF0000\z
00007BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF7BEF0000\z
0000B2C0B2C0B2C0B2C0B2C0B2C0B2C07BEF7BEFB2C0B2C0B2C0B2C0B2C0B2C00000\z
F81F00000000B2C0B2C0B2C0B2C0B2C07BEF7BEFB2C0B2C0B2C0B2C000000000F81F\z
F81FF81FF81F000000000000B2C0B2C07BEF7BEFB2C0000000000000F81FF81FF81F\z
F81FF81FF81FF81FF81FF81F000000007BEF00000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
",
"F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81F00000000000000000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81F0000000000000000FD79FD79FD790000000000000000F81FF81FF81F\z
F81F00000000000000000000FD79E8E4FD79E8E4FD7900000000000000000000F81F\z
000000000000000000000000FD79FD79FD79FD79FD79000000000000000000000000\z
000000000000000000000000FD79FD79FD79FD79FD79000000000000000000000000\z
0000000000000000000000000000FD79FD79FD790000000000000000000000000000\z
00000000000000000000000000000000FD7900000000000000000000000000000000\z
00000000000000000000FD79FD79FD79FD79FD79FD79FD7900000000000000000000\z
000000000000FD79FD79FD79FD79FD79FD79FD79FD79FD79FD79FD79000000000000\z
000000000000FD79FD7900000000FD79FD79FD7900000000FD79FD79000000000000\z
000000000000000000000000FD79FD79FD79FD79FD79000000000000000000000000\z
000000000000000000000000FD79FD790000FD79FD79000000000000000000000000\z
F81F0000000000000000FD79FD79FD790000FD79FD79FD790000000000000000F81F\z
F81FF81FF81F00000000000000000000000000000000000000000000F81FF81FF81F\z
F81FF81FF81FF81FF81FF81F00000000000000000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
",
"F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81F000000007BEF00000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81F0000000000007BEFFD79FD797BEF7BEF000000000000F81FF81FF81F\z
F81F000000007BEF7BEF7BEFFD79FD79E8E4FD797BEF7BEF7BEF7BEF00000000F81F\z
00007BEF7BEF7BEF7BEF7BEFFD79FD79FD79FD79FD797BEF7BEF7BEF7BEF7BEF0000\z
00007BEF7BEF7BEF7BEF7BEF7BEFFD79FD79FD797BEF7BEF7BEF7BEF7BEF7BEF0000\z
00007BEF7BEF7BEF7BEF7BEF7BEFFD79FD797BEF7BEF7BEF7BEF7BEF7BEF7BEF0000\z
00007BEF7BEF7BEF7BEF7BEFFD79FD79FD79FD79FD797BEF7BEF7BEF7BEF7BEF0000\z
00007BEF7BEF7BEF7BEFFD79FD79FD79FD79FD79FD79FD79FD79FD797BEF7BEF0000\z
00007BEF7BEF7BEFFD79FD79FD79FD797BEF7BEF7BEF7BEF7BEFFD79FD797BEF0000\z
00007BEF7BEF7BEFFD79FD79FD79FD797BEFFD79FD79FD797BEF7BEF7BEF7BEF0000\z
00007BEF7BEF7BEFFD79FD79FD79FD79FD79FD79FD79FD79FD797BEF7BEF7BEF0000\z
00007BEF7BEF7BEFFD79FD79FD79FD79FD79FD797BEFFD79FD79FD797BEF7BEF0000\z
F81F000000007BEF7BEF7BEFFD79FD79FD797BEF7BEF7BEFFD79FD7900000000F81F\z
F81FF81FF81F0000000000007BEF7BEF7BEF7BEF7BEF000000000000F81FF81FF81F\z
F81FF81FF81FF81FF81FF81F000000007BEF00000000F81FF81FF81FF81FF81FF81F\z
F81FF81FF81FF81FF81FF81FF81FF81F0000F81FF81FF81FF81FF81FF81FF81FF81F",
} -- }}}
function drawTile(x,y,n,mask)
if nil~=mask then
zmg.copySpriteMask(x, y, tiles.w, tiles.h, mask, tiles[n])
else
zmg.copySprite(x, y, tiles.w, tiles.h, tiles[n])
end
end
zmg.drawRectFill(0,0,SCREENX,SCREENY,BLACK)
clr={WHITE,GREY,EDIT}
c=1
for y=0,SCREENY-1,3 do
zmg.drawLine(0,y,SCREENX-1,y,clr[c])
c=(c%#clr)+1
end
for x=0,SCREENX-1,3 do
zmg.drawLine(x,0,x,SCREENY-1,clr[c])
c=(c%#clr)+1
end
for i=1,#tiles do
drawTile(20,i*20,i,MASK)
drawTile(40,i*20,i)
end
zmg.fastCopy()
zmg.keyMenu()