Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/sdlbrt
- finp$="xfs/Xevious_Fardraut_Saga_MSX2_box_front_3.png"
- if argc>=3 then:finp$=command$(3):end if
- quant1=16 '- default is 4, more needed if the result is smaller than 4
- dim dpvl[8]
- clstr=0 '- 0..3
- xed=256:yed=192:wdwd=1
- shell("rm _t*.png")
- shell("convert "+finp$+" -crop 256x192+0+0 _t1a.png")
- 'shell("convert "+finp$+" -scale "+str$(xed*4)+"x"+str$(yed*4)+"! _t2.png")
- 'shell("convert "+finp$+" +dither -colors "+str$(quant1)+" _t4.png")
- shell("convert _t1a.png -scale "+str$(xed*4)+"x"+str$(yed*4)+"! _t2.png")
- shell("convert _t1a.png +dither -colors "+str$(quant1)+" _t4.png")
- shell("convert _t4.png +dither -posterize 4 _t5.png")
- shell("convert _t5.png +dither -colors 4 _t6.png")
- shell("convert "+finp$+" -crop 32x8+0+192 _t9a.png")
- shell("convert _t9a.png +dither -colors 4 _t9b.png")
- 'shell("convert _t2.png -quantize CMY -remap _t6.png -dither Riemersma _t3.png")
- shell("convert _t2.png -quantize CMY -remap _t9b.png -dither Riemersma _t3.png")
- shell("convert _t3.png -unique-colors -scale 400% _t4.png")
- setdisplay(xed*4,yed*4,32,wdwd):paper(8^8-1):ink(0):pen(0):cls
- loadimage("_t3.png",1):pasteicon(0,0,1)
- dim p1[16],k1[16]
- function grayscale(ct):
- cq=ct
- bq=bitwiseand(cq,255):cq=int(cq/256)
- gq=bitwiseand(cq,255):cq=int(cq/256)
- rq=bitwiseand(cq,255):cq=int(cq/256)
- return int(((rq*30)+(gq*59)+(bq*11))/100)
- end function
- for y2=0 to yed-1
- setcaption(str$(int(100*(y2/yed)))+"%")
- for x2=0 to xed-1
- for y1=0 to 3:for x1=0 to 3
- xq=y1*4+x1
- p1[xq]=point(x2*4+x1,y2*4+y1)
- next:next
- for i=0 to 15
- k1[i]=grayscale(p1[i])
- next
- for j=0 to 14:for i=0 to 14
- if k1[i]>k1[i+1] then:
- tm=k1[i]:k1[i]=k1[i+1]:k1[i+1]=tm
- tm=p1[i]:p1[i]=p1[i+1]:p1[i+1]=tm
- end if
- next:next
- if clstr=0 then:
- ink(p1[ 0]):dot(x2*4+0,y2*4+0)
- ink(p1[ 6]):dot(x2*4+1,y2*4+0)
- ink(p1[ 9]):dot(x2*4+2,y2*4+0)
- ink(p1[15]):dot(x2*4+3,y2*4+0)
- ink(p1[ 4]):dot(x2*4+0,y2*4+1)
- ink(p1[10]):dot(x2*4+1,y2*4+1)
- ink(p1[ 3]):dot(x2*4+2,y2*4+1)
- ink(p1[13]):dot(x2*4+3,y2*4+1)
- ink(p1[ 8]):dot(x2*4+0,y2*4+2)
- ink(p1[14]):dot(x2*4+1,y2*4+2)
- ink(p1[ 1]):dot(x2*4+2,y2*4+2)
- ink(p1[ 7]):dot(x2*4+3,y2*4+2)
- ink(p1[ 2]):dot(x2*4+0,y2*4+3)
- ink(p1[12]):dot(x2*4+1,y2*4+3)
- ink(p1[ 5]):dot(x2*4+2,y2*4+3)
- ink(p1[11]):dot(x2*4+3,y2*4+3)
- end if
- if clstr=1 then:
- ink(p1[ 0]):dot(x2*4+0,y2*4+0)
- ink(p1[ 4]):dot(x2*4+1,y2*4+0)
- ink(p1[ 8]):dot(x2*4+2,y2*4+0)
- ink(p1[12]):dot(x2*4+3,y2*4+0)
- ink(p1[10]):dot(x2*4+0,y2*4+1)
- ink(p1[14]):dot(x2*4+1,y2*4+1)
- ink(p1[ 2]):dot(x2*4+2,y2*4+1)
- ink(p1[ 6]):dot(x2*4+3,y2*4+1)
- ink(p1[ 1]):dot(x2*4+0,y2*4+2)
- ink(p1[ 5]):dot(x2*4+1,y2*4+2)
- ink(p1[ 9]):dot(x2*4+2,y2*4+2)
- ink(p1[13]):dot(x2*4+3,y2*4+2)
- ink(p1[11]):dot(x2*4+0,y2*4+3)
- ink(p1[15]):dot(x2*4+1,y2*4+3)
- ink(p1[ 3]):dot(x2*4+2,y2*4+3)
- ink(p1[ 7]):dot(x2*4+3,y2*4+3)
- end if
- if clstr=2 then:
- ink(p1[ 0]):dot(x2*4+0,y2*4+0)
- ink(p1[10]):dot(x2*4+1,y2*4+0)
- ink(p1[ 1]):dot(x2*4+2,y2*4+0)
- ink(p1[11]):dot(x2*4+3,y2*4+0)
- ink(p1[ 4]):dot(x2*4+0,y2*4+1)
- ink(p1[14]):dot(x2*4+1,y2*4+1)
- ink(p1[ 5]):dot(x2*4+2,y2*4+1)
- ink(p1[15]):dot(x2*4+3,y2*4+1)
- ink(p1[ 8]):dot(x2*4+0,y2*4+2)
- ink(p1[ 2]):dot(x2*4+1,y2*4+2)
- ink(p1[ 9]):dot(x2*4+2,y2*4+2)
- ink(p1[ 3]):dot(x2*4+3,y2*4+2)
- ink(p1[12]):dot(x2*4+0,y2*4+3)
- ink(p1[ 6]):dot(x2*4+1,y2*4+3)
- ink(p1[13]):dot(x2*4+2,y2*4+3)
- ink(p1[ 7]):dot(x2*4+3,y2*4+3)
- end if
- if clstr=3 then:
- ink(p1[ 0]):dot(x2*4+0,y2*4+0)
- ink(p1[12]):dot(x2*4+1,y2*4+0)
- ink(p1[ 3]):dot(x2*4+2,y2*4+0)
- ink(p1[15]):dot(x2*4+3,y2*4+0)
- ink(p1[ 8]):dot(x2*4+0,y2*4+1)
- ink(p1[ 4]):dot(x2*4+1,y2*4+1)
- ink(p1[11]):dot(x2*4+2,y2*4+1)
- ink(p1[ 7]):dot(x2*4+3,y2*4+1)
- ink(p1[ 2]):dot(x2*4+0,y2*4+2)
- ink(p1[14]):dot(x2*4+1,y2*4+2)
- ink(p1[ 1]):dot(x2*4+2,y2*4+2)
- ink(p1[13]):dot(x2*4+3,y2*4+2)
- ink(p1[10]):dot(x2*4+0,y2*4+3)
- ink(p1[ 6]):dot(x2*4+1,y2*4+3)
- ink(p1[ 9]):dot(x2*4+2,y2*4+3)
- ink(p1[ 5]):dot(x2*4+3,y2*4+3)
- end if
- x1=x2 mod 4:y1=y2 mod 4
- u=point(x2*4+x1,y2*4+y1)
- ink(u):dot(x2,y2)
- next:next
- loadimage("_t9a.png",1):pasteicon(256,0,1)
- for y2=0 to yed-1
- setcaption(str$(int(100*(y2/yed)))+"%")
- for x2=0 to xed-1
- u=point(x2,y2)
- for c2=15 to 0 step -1
- cp=point(xed+c2*8,0)
- if (u=cp) then:
- ink(0xFFFFFF)
- if bitwiseand(c2,1)<>0 then:ink(0):end if
- dot((xed*0)+x2,yed+y2)
- ink(0xFFFFFF)
- if bitwiseand(c2,2)<>0 then:ink(0):end if
- dot((xed*1)+x2,yed+y2)
- end if
- next
- next:next
- shell("rm _t*.png")
- '-wrong output, need to correct it
- open finp$+".bin" for output as #1
- for y9=0 to 191 step 8
- for x1=0 to 255 step 16
- for y8=0 to 7
- y2=y9+y8
- for x7=0 to 15 step 8
- for x0=0 to 1
- setcaption("writebyte:... "+str$(y2)+"/192")
- y=yed+y2
- for x2=0 to 7:dpvl[x2]=0:next
- for x2=0 to 7:xp=(x0*256)+x1+x2+x7
- g=bitwiseand(point(xp,y),0x00FF00)/256
- if g<128 then:dpvl[x2]=1:end if
- next
- dpvb=0
- for x2=0 to 7:dpvb=dpvb+(dpvl[x2]*(2^(7-x2))):next
- writebyte(1,dpvb)
- next:next:next:next:next
- waitvbl
- for x0=0 to 3
- setcaption("writebyte:... "+str$(x0)+"/3")
- u=point(xed+(x0*8),0)
- r=(bitwiseand(u,0xC00000)/0x400000)*0x1
- g=(bitwiseand(u,0x00C000)/0x4000)*0x04
- b=(bitwiseand(u,0x0000C0)/0x40)*0x10
- writebyte(1,bitwiseor(r,bitwiseor(g,b)))
- next
- close #1
- waitvbl
- grab(1,0,0,xed,yed):saveimage("_.bmp",1):shell("convert _.bmp "+finp$+".png && rm _.bmp" )
- setcaption("saved")
- 'shell("convert "+finp$+".png -colors 16 -compress None "+finp$+".ilbm ")
- 'shell("convert "+finp$+".png _.ppm && ppmtopi1 _.ppm > "+finp$+".pi1 && rm _.ppm")
- 'waitkey
- setcaption("closing")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement