Advertisement
Guest User

Ef9345DisplayEditorX2_tortueformat_201704051936.sdlbas

a guest
Apr 5th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SdlBasic 24.23 KB | None | 0 0
  1. zoommode=2:debug=1
  2.  
  3. '- to do:
  4. '-  1: keep testing inverse - saved pictures are different from the opened ones, they shouldn’t be - try to use new arrays created
  5. '-  2: implement copy, swap and data-invert setet/seteg
  6. '-  3: test and fix bugs
  7.  
  8. '-------------------------------------------------------------------------------
  9. '- defining some variables and arrays
  10.  
  11. chcur=90:ikcur=0:ppcur=7:ivcur=0:xzmcur=0:yzmcur=0
  12. debug=debug mod 2:mbutprs=0
  13. dim paleta$[16]
  14. dim z$[512]:for i=0 to 511:z$[i]="55aa55aa55aa55aa55aa":next
  15. dim setetg[8192]
  16. dim mapch[40,40],mapat[40,40],mapik[40,40],mappp[40,40],mapiv[40,40],mapxz[40,40],mapyz[40,40],mapfl[40,40]
  17. buttonmode1=0
  18.  
  19. '-------------------------------------------------------------------------------
  20. '- functions and routines
  21.  
  22. function hexvl(a$)
  23.   e=asc(ucase$(a$))
  24.   hexvl=abs(((e>=48 and e<=57)*(e-48))+((e>=65 and e<=70)*(e-55)))
  25.   end function
  26.  
  27. function bytefromhexdump(a$,byteadr)
  28.   i=(byteadr*2)+1:m1$=mid$(a$,i,1):m2$=mid$(a$,i+1,1)
  29.   tmpr=(hexvl(m1$)*16)+hexvl(m2$):bytefromhexdump=tmpr
  30.   end function
  31.  
  32. sub bindispzoom(xqq,yqq,v,i,p,xcs,ycs)
  33.   ink(p)
  34.   bar((xqq*xcs)*zoommode,(yqq*ycs)*zoommode,((xqq*xcs)+(xcs*8)-1)*zoommode,((yqq*ycs)+ycs-1)*zoommode)
  35.   ink(i)
  36.   for zqq=0 to 7:ik=p:z2=7-zqq
  37.     bar(((xqq+zqq)*xcs)*zoommode+1,(yqq*ycs)*zoommode+1,(((xqq+zqq)*xcs)+2)*zoommode,((yqq*ycs)+2)*zoommode)
  38.     next
  39.   for zqq=0 to 7:ik=p:z2=7-zqq
  40.     if bitwiseand(v,2^z2)<>0 then
  41.       bar(((xqq+zqq)*xcs)*zoommode+1,(yqq*ycs)*zoommode+1,(((xqq+zqq)*xcs)+xcs-2)*zoommode,((yqq*ycs)+ycs-2)*zoommode)
  42.       end if
  43.     next
  44.   end sub
  45.  
  46. sub hexdumpplot(x,y,a$,i,p)
  47.   for e=0 to (len(a$)/2)-1:v=bytefromhexdump(a$,e)
  48.     for z=0 to 7:ik=p:z2=7-z
  49.       if bitwiseand(v,2^z2)<>0 then:ik=i:end if
  50.       ink(ik):bar((x+z)*zoommode,(y+e)*zoommode,(x+z)*zoommode+1,(y+e)*zoommode+1):next:next
  51.  end sub
  52.  
  53. sub hexdumpplotctxstgi(xt,yt,cht,i,p,iv)
  54.   ch=cht:x=xt*8:y=yt*10
  55.   for e=0 to 9
  56.     v=setetg[ch*10+e]
  57.     if bitwiseand(iv,1)<>0 then:v=255-v:end if
  58.     for z=0 to 7:ik=p:z2=7-z  
  59.       if bitwiseand(v,2^z2)<>0 then:ik=i:end if
  60.       ink(ik):bar((x+z)*zoommode,(y+e)*zoommode,(x+z)*zoommode+1,(y+e)*zoommode+1):next:next
  61.  end sub
  62.  
  63. sub printsblo(xlt,ylt,oft,a$)
  64.   xl=xlt:yl=ylt:alen=len(a$)
  65.   for iz=1 to alen
  66.     hx$=z$[ (asc(mid$(a$,iz,1))+oft)mod 256 ]
  67.     hexdumpplot(xl*8,yl*10,hx$,pen,paper):xl=xl+1
  68.     if xl>((displaywidth\8)-1) then:xl=0:yl=yl+1:end if:next
  69.   end sub
  70.  
  71. sub printsbloctxstgi(xlt,ylt,oft,a$,iv2)
  72.   xl=xlt:yl=ylt:alen=len(a$)
  73.   for iz=1 to alen
  74.     hexdumpplotctxstgi(xl*8,yl*10,asc(mid$(a$,iz,1))+oft,pen,paper,iv2)
  75.     xl=xl+1
  76.     if xl>((displaywidth\8)-1) then:xl=0:yl=yl+1:end if:next
  77.   end sub
  78.  
  79. sub refreshchrpalette(ikt,ppt)
  80.   ik=ikt:pp=ppt
  81.   for y=0 to 7:for x=0 to 15:c=x+(y*16)
  82.     hexdumpplotctxstgi(x+52,y+1,c,paleta$[ik mod 8],paleta$[8],ivcur)
  83.     next:next
  84.   for y=10 to 15:for x=0 to 15:c=x+(y*16)
  85.     hexdumpplotctxstgi(x+52,y-1,c,paleta$[ik mod 8],paleta$[8],ivcur)
  86.     next:next
  87.   for y=16 to 23:for x=0 to 15:c=x+(y*16)
  88.     hexdumpplotctxstgi(x+52,y-1,c,paleta$[ik mod 8],paleta$[pp mod 8],0)
  89.     next:next
  90.   for y=26 to 31:for x=0 to 15:c=x+(y*16)
  91.     hexdumpplotctxstgi(x+52,y-3,c,paleta$[ik mod 8],paleta$[pp mod 8],0)
  92.     next:next
  93.   end sub
  94.  
  95. sub refreshdispedit()
  96.   pplast=0
  97.   for y=0 to 24:for x=0 to 39
  98.     if bitwiseand(mapat[x,y],128)<>0 then
  99.       pplast=(int(mapat[x,y]/16))mod 8  
  100.       end if
  101.     ivtx=0
  102.     if (bitwiseand(mapat[x,y],192))/64=1 then
  103.       ivtx=1
  104.       end if
  105.     hexdumpplotctxstgi(x+1,y+1,mapch[x,y]+(bitwiseand(mapat[x,y],128)*2),paleta$[mapat[x,y]mod 8],paleta$[pplast],ivtx)    
  106.     next:next
  107.   end sub
  108.  
  109. function posloc(pmou,poff,pws,pcsz,pzo):
  110.   return ( (pws*10)+(int(((pmou/pzo)-(poff*pcsz))/pcsz)) ) mod pws
  111.   end function
  112.  
  113. function posexs(pmou,poff,pws,pcsz,pzo):
  114.   vlou=1
  115.   if (pmou<((poff*pcsz)*pzo)) or (pmou>(((poff+pws)*pcsz))*pzo) then
  116.     vlou=0:end if
  117.   return vlou
  118.   end function
  119.  
  120. sub refreshikppcur()
  121.   ink(0x808080)
  122.   bar((43*8)*zoommode,(1*10)*zoommode,(51*8)*zoommode,(1*10+1)*zoommode)
  123.   bar((43*8)*zoommode,(1*10+8)*zoommode,(51*8)*zoommode,(1*10+9)*zoommode)
  124.   bar((43*8)*zoommode,(2*10)*zoommode,(51*8)*zoommode,(2*10+1)*zoommode)
  125.   bar((43*8)*zoommode,(2*10+8)*zoommode,(51*8)*zoommode,(2*10+9)*zoommode)
  126.   ink(0xC0C0C0)
  127.   bar(((43+ikcur)*8)*zoommode,(1*10)*zoommode,((44+ikcur)*8-1)*zoommode,(1*10+1)*zoommode)
  128.   bar(((43+ikcur)*8)*zoommode,(1*10+8)*zoommode,((44+ikcur)*8-1)*zoommode,(1*10+9)*zoommode)
  129.   bar(((43+ppcur)*8)*zoommode,(2*10)*zoommode,((44+ppcur)*8-1)*zoommode,(2*10+1)*zoommode)
  130.   bar(((43+ppcur)*8)*zoommode,(2*10+8)*zoommode,((44+ppcur)*8-1)*zoommode,(2*10+9)*zoommode)
  131.   end sub
  132.  
  133. sub refreshchcur(xmt,ymt)
  134.   ink(0x808080)
  135.   bar((51*8)*zoommode,(0*10)*zoommode,(69*8)*zoommode,(0*10+9)*zoommode)
  136.   bar((51*8)*zoommode,(29*10)*zoommode,(69*8)*zoommode,(29*10+9)*zoommode)
  137.   bar((51*8)*zoommode,(0*10)*zoommode,(51*8+7)*zoommode,(29*10+9)*zoommode)
  138.   bar((68*8)*zoommode,(0*10)*zoommode,(68*8+7)*zoommode,(29*10+9)*zoommode)
  139.   ink(0xC0C0C0)
  140.   bar((xmt*8)*zoommode,(0*10+8)*zoommode,(xmt*8+7)*zoommode,(0*10+9)*zoommode)
  141.   bar((xmt*8)*zoommode,(29*10+0)*zoommode,(xmt*8+7)*zoommode,(29*10+1)*zoommode)
  142.   bar((51*8+6)*zoommode,(ymt*10)*zoommode,(51*8+7)*zoommode,(ymt*10+9)*zoommode)
  143.   bar((68*8)*zoommode,(ymt*10)*zoommode,(68*8+1)*zoommode,(ymt*10+9)*zoommode)
  144.   end sub
  145.  
  146. '-------------------------------------------------------------------------------
  147. '- arrays
  148.  
  149. paleta$[00]="0x000000":paleta$[01]="0xFF0000":paleta$[02]="0x00FF00":paleta$[03]="0xFFFF00"
  150. paleta$[04]="0x0000FF":paleta$[05]="0xFF00FF":paleta$[06]="0x00FFFF":paleta$[07]="0xFFFFFF"
  151. paleta$[08]="0x808080":paleta$[09]="0x808080":paleta$[10]="0x808080":paleta$[11]="0x808080"
  152. paleta$[12]="0x808080":paleta$[13]="0x808080":paleta$[14]="0x808080":paleta$[15]="0x808080"
  153.  
  154. z$[  0]="00384440201000100000":z$[  1]="0010280038447c440000":z$[  2]="0008103c2030203c0000":z$[  3]="000814103810243c0000"
  155. z$[  4]="001028344c444c340000":z$[  5]="00384440404044381020":z$[  6]="0028003c2030203c0000":z$[  7]="0020180038447c440000"
  156. z$[  8]="00201800444444380000":z$[  9]="0010083c2030203c0000":z$[ 10]="003c50505850503c0000":z$[ 11]="0008143c2030203c0000"
  157. z$[ 12]="000010207f2010000000":z$[ 13]="00102800301010380000":z$[ 14]="00000804fe0408000000":z$[ 15]="10101010101054381000"
  158. z$[ 16]="00182418000000000000":z$[ 17]="0010107c1010007c0000":z$[ 18]="00081038447c40380000":z$[ 19]="00280038447c40380000"
  159. z$[ 20]="00280030101010380000":z$[ 21]="00000038404040381020":z$[ 22]="0010280044444c340000":z$[ 23]="002010344c444c340000"
  160. z$[ 24]="000010007c0010000000":z$[ 25]="00201038447c40380000":z$[ 26]="0000003c525e503e0000":z$[ 27]="00102838447c40380000"
  161. z$[ 28]="0040c040444c143e0400":z$[ 29]="0040c0404c5204081e00":z$[ 30]="00e0204024cc143e0400":z$[ 31]="00102800384444380000"
  162. z$[ 32]="00000000000000000000":z$[ 33]="00101010101000100000":z$[ 34]="00282828000000000000":z$[ 35]="0028287c287c28280000"
  163. z$[ 36]="00103850381454381000":z$[ 37]="0060640810204c0c0000":z$[ 38]="00205050205448340000":z$[ 39]="00101020000000000000"
  164. z$[ 40]="00081020202010080000":z$[ 41]="00201008080810200000":z$[ 42]="00105438103854100000":z$[ 43]="000010107c1010000000"
  165. z$[ 44]="00000000000020204000":z$[ 45]="00000000003c00000000":z$[ 46]="00000000000000200000":z$[ 47]="01020204081020204080"
  166. z$[ 48]="00102844444428100000":z$[ 49]="00103010101010100000":z$[ 50]="003844041820407c0000":z$[ 51]="007c0408180444380000"
  167. z$[ 52]="00081828487c08080000":z$[ 53]="007c4078040444380000":z$[ 54]="00182040784444380000":z$[ 55]="007c0408102020200000"
  168. z$[ 56]="00384444384444380000":z$[ 57]="003844443c0404380000":z$[ 58]="00000020000000200000":z$[ 59]="00000020000020204000"
  169. z$[ 60]="00040810201008040000":z$[ 61]="0000007c007c00000000":z$[ 62]="00402010081020400000":z$[ 63]="00384404081000100000"
  170. z$[ 64]="0038445c545c40380000":z$[ 65]="00384444447c44440000":z$[ 66]="00784444784444780000":z$[ 67]="00384440404044380000"
  171. z$[ 68]="00784444444444780000":z$[ 69]="007c40407040407c0000":z$[ 70]="007c4040704040400000":z$[ 71]="00384440404c443c0000"
  172. z$[ 72]="004444447c4444440000":z$[ 73]="00381010101010380000":z$[ 74]="001c0808080848300000":z$[ 75]="00444850605048440000"
  173. z$[ 76]="004040404040407c0000":z$[ 77]="00446c54444444440000":z$[ 78]="00444464544c44440000":z$[ 79]="00384444444444380000"
  174. z$[ 80]="00784444784040400000":z$[ 81]="00384444445448340000":z$[ 82]="00784444785048440000":z$[ 83]="00384440380444380000"
  175. z$[ 84]="007c1010101010100000":z$[ 85]="00444444444444380000":z$[ 86]="00444444282810100000":z$[ 87]="00444444545454280000"
  176. z$[ 88]="00444428102844440000":z$[ 89]="00444428101010100000":z$[ 90]="007c04081020407c0000":z$[ 91]="001c10101010101c0000"
  177. z$[ 92]="80404020100804040201":z$[ 93]="00380808080808380000":z$[ 94]="00103854101010101000":z$[ 95]="000000000000000000ff"
  178. z$[ 96]="00000000ff0000000000":z$[ 97]="000000344c444c340000":z$[ 98]="00404078444444780000":z$[ 99]="00000038404040380000"
  179. z$[100]="0004043c4444443c0000":z$[101]="00000038447c40380000":z$[102]="00182420702020200000":z$[103]="0000003c44443c042418"
  180. z$[104]="00404058644444440000":z$[105]="00100030101010380000":z$[106]="00080018080808084830":z$[107]="00202024283028240000"
  181. z$[108]="00301010101010380000":z$[109]="00000068545454540000":z$[110]="00000058644444440000":z$[111]="00000038444444380000"
  182. z$[112]="00000078444444784040":z$[113]="0000003c4444443c0404":z$[114]="00000058644040400000":z$[115]="00000038403804780000"
  183. z$[116]="00202038202020180000":z$[117]="0000004444444c340000":z$[118]="00000044442828100000":z$[119]="00000044445454280000"
  184. z$[120]="00000044281028440000":z$[121]="00000044444c34044438":z$[122]="0000007c0810207c0000":z$[123]="80808080808080808080"
  185. z$[124]="10101010101010101010":z$[125]="01010101010101010101":z$[126]="ff000000000000000000":z$[127]="ffffffffffffffffffff"
  186.  
  187. z$[128+128]="00000000000000000000":z$[129+128]="70700000000000000000":z$[130+128]="07070000000000000000":z$[131+128]="77770000000000000000"
  188. z$[132+128]="00000070707000000000":z$[133+128]="70700070707000000000":z$[134+128]="07070070707000000000":z$[135+128]="77770070707000000000"
  189. z$[136+128]="00000007070700000000":z$[137+128]="70700007070700000000":z$[138+128]="07070007070700000000":z$[139+128]="77770007070700000000"
  190. z$[140+128]="00000077777700000000":z$[141+128]="70700077777700000000":z$[142+128]="07070077777700000000":z$[143+128]="77770077777700000000"
  191. z$[144+128]="00000000000000707000":z$[145+128]="70700000000000707000":z$[146+128]="07070000000000707000":z$[147+128]="77770000000000707000"
  192. z$[148+128]="00000070707000707000":z$[149+128]="70700070707000707000":z$[150+128]="07070070707000707000":z$[151+128]="77770070707000707000"
  193. z$[152+128]="00000007070700707000":z$[153+128]="70700007070700707000":z$[154+128]="07070007070700707000":z$[155+128]="77770007070700707000"
  194. z$[156+128]="00000077777700707000":z$[157+128]="70700077777700707000":z$[158+128]="07070077777700707000":z$[159+128]="77770077777700707000"
  195. z$[160+128]="00000000000000070700":z$[161+128]="70700000000000070700":z$[162+128]="07070000000000070700":z$[163+128]="77770000000000070700"
  196. z$[164+128]="00000070707000070700":z$[165+128]="70700070707000070700":z$[166+128]="07070070707000070700":z$[167+128]="77770070707000070700"
  197. z$[168+128]="00000007070700070700":z$[169+128]="70700007070700070700":z$[170+128]="07070007070700070700":z$[171+128]="77770007070700070700"
  198. z$[172+128]="00000077777700070700":z$[173+128]="70700077777700070700":z$[174+128]="07070077777700070700":z$[175+128]="77770077777700070700"
  199. z$[176+128]="00000000000000777700":z$[177+128]="70700000000000777700":z$[178+128]="07070000000000777700":z$[179+128]="77770000000000777700"
  200. z$[180+128]="00000070707000777700":z$[181+128]="70700070707000777700":z$[182+128]="07070070707000777700":z$[183+128]="77770070707000777700"
  201. z$[184+128]="00000007070700777700":z$[185+128]="70700007070700777700":z$[186+128]="07070007070700777700":z$[187+128]="77770007070700777700"
  202. z$[188+128]="00000077777700777700":z$[189+128]="70700077777700777700":z$[190+128]="07070077777700777700":z$[191+128]="77770077777700777700"
  203. z$[192+128]="00000000000000000000":z$[193+128]="f0f0f000000000000000":z$[194+128]="0f0f0f00000000000000":z$[195+128]="ffffff00000000000000"
  204. z$[196+128]="000000f0f0f0f0000000":z$[197+128]="f0f0f0f0f0f0f0000000":z$[198+128]="0f0f0ff0f0f0f0000000":z$[199+128]="fffffff0f0f0f0000000"
  205. z$[200+128]="0000000f0f0f0f000000":z$[201+128]="f0f0f00f0f0f0f000000":z$[202+128]="0f0f0f0f0f0f0f000000":z$[203+128]="ffffff0f0f0f0f000000"
  206. z$[204+128]="000000ffffffff000000":z$[205+128]="f0f0f0ffffffff000000":z$[206+128]="0f0f0fffffffff000000":z$[207+128]="ffffffffffffff000000"
  207. z$[208+128]="00000000000000f0f0f0":z$[209+128]="f0f0f000000000f0f0f0":z$[210+128]="0f0f0f00000000f0f0f0":z$[211+128]="ffffff00000000f0f0f0"
  208. z$[212+128]="000000f0f0f0f0f0f0f0":z$[213+128]="f0f0f0f0f0f0f0f0f0f0":z$[214+128]="0f0f0ff0f0f0f0f0f0f0":z$[215+128]="fffffff0f0f0f0f0f0f0"
  209. z$[216+128]="0000000f0f0f0ff0f0f0":z$[217+128]="f0f0f00f0f0f0ff0f0f0":z$[218+128]="0f0f0f0f0f0f0ff0f0f0":z$[219+128]="ffffff0f0f0f0ff0f0f0"
  210. z$[220+128]="000000fffffffff0f0f0":z$[221+128]="f0f0f0fffffffff0f0f0":z$[222+128]="0f0f0ffffffffff0f0f0":z$[223+128]="fffffffffffffff0f0f0"
  211. z$[224+128]="000000000000000f0f0f":z$[225+128]="f0f0f0000000000f0f0f":z$[226+128]="0f0f0f000000000f0f0f":z$[227+128]="ffffff000000000f0f0f"
  212. z$[228+128]="000000f0f0f0f00f0f0f":z$[229+128]="f0f0f0f0f0f0f00f0f0f":z$[230+128]="0f0f0ff0f0f0f00f0f0f":z$[231+128]="fffffff0f0f0f00f0f0f"
  213. z$[232+128]="0000000f0f0f0f0f0f0f":z$[233+128]="f0f0f00f0f0f0f0f0f0f":z$[234+128]="0f0f0f0f0f0f0f0f0f0f":z$[235+128]="ffffff0f0f0f0f0f0f0f"
  214. z$[236+128]="000000ffffffff0f0f0f":z$[237+128]="f0f0f0ffffffff0f0f0f":z$[238+128]="0f0f0fffffffff0f0f0f":z$[239+128]="ffffffffffffff0f0f0f"
  215. z$[240+128]="00000000000000ffffff":z$[241+128]="f0f0f000000000ffffff":z$[242+128]="0f0f0f00000000ffffff":z$[243+128]="ffffff00000000ffffff"
  216. z$[244+128]="000000f0f0f0f0ffffff":z$[245+128]="f0f0f0f0f0f0f0ffffff":z$[246+128]="0f0f0ff0f0f0f0ffffff":z$[247+128]="fffffff0f0f0f0ffffff"
  217. z$[248+128]="0000000f0f0f0fffffff":z$[249+128]="f0f0f00f0f0f0fffffff":z$[250+128]="0f0f0f0f0f0f0fffffff":z$[251+128]="ffffff0f0f0f0fffffff"
  218. z$[252+128]="000000ffffffffffffff":z$[253+128]="f0f0f0ffffffffffffff":z$[254+128]="0f0f0fffffffffffffff":z$[255+128]="ffffffffffffffffffff"
  219. z$[511]=    "55FF7FFF7FFF7FFF7FFF"
  220.  
  221. '-------------------------------------------------------------------------------
  222.  
  223. '- converting setet/seteg strings to binary data
  224. for ee=0 to 511
  225.   for e=0 to (len(z$[ee])/2)-1:v=bytefromhexdump(z$[ee],e)
  226.     setetg[ee*10+e]=v
  227.     next
  228.   next
  229.  
  230. '- opening display
  231. xed=552:yed=280+20:wndwd=1
  232. setdisplay(xed*zoommode,(yed+(debug*40))*zoommode,32,wndwd):paper(paleta$[8]):ink(paleta$[0]):pen(paleta$[0]):cls
  233. setcaption("EF9345 display editor")
  234.  
  235. '- drawing stuff
  236. for y=0 to 1:for c=0 to 15
  237.   paper(paleta$[c]):pen(paleta$[c]):ink(paleta$[c])
  238.   bar((336+8+c*8)*zoommode,(11+y*10)*zoommode,(344+8+c*8)*zoommode,(18+y*10)*zoommode)
  239.   next:next
  240.  
  241. '- draw zoomed setetg
  242. for y=0 to 9
  243.   bindispzoom(43,8+y,setetg[chcur*10+y],0xffffff,0x808080,8,8)
  244.   next
  245.  
  246. '- cleaning display
  247. for y=0 to 24:for x=0 to 39
  248.   mapch[x,y]=511
  249.   mapat[x,y]=0x17
  250.   next:next
  251. '- generating random stuff (temporary)
  252. 'for y=0 to 24:for x=0 to 39
  253. '  chrd=rnd(127)+256:ikrd=int(rnd(79)/10):pprd=int(rnd(79)/10)
  254. '  mapch[x,y]=chrd
  255. '  mapat[x,y]=pprd*16+ikrd
  256. '  next:next
  257.  
  258. '-------------------------------------------------------------------------------
  259. '- buttons
  260.  
  261. paper(paleta$[7]):pen(paleta$[0])
  262. printsblo(1,27,0,"open")
  263. printsblo(6,27,0,"save")
  264. printsblo(34,27,0,"refresh")
  265. printsblo(47,3,0,"swap")
  266.  
  267. printsblo(47,15,0,"copy")
  268. printsblo(47,17,0,"swap")
  269.  
  270. paper(0x808080):pen(paleta$[0]):printsblo(45,19,0,"flip")
  271. paper(paleta$[7]):pen(paleta$[0]):printsblo(49,19,0,"xy")
  272.  
  273. paper(paleta$[7]):pen(paleta$[0]):printsblo(47,5,0," ")
  274. paper(0x808080):pen(paleta$[0]):printsblo(48,5,0,"inv")
  275.  
  276. '-----
  277. 'if debug<>0 then:
  278. '  paper(paleta$[7]):pen(paleta$[0]):printsblo(44,16,0," ")
  279. '  paper(0x808080):pen(paleta$[0]):printsblo(45,16,0,"x2")
  280. '  paper(paleta$[7]):pen(paleta$[0]):printsblo(48,16,0," ")
  281. '  paper(0x808080):pen(paleta$[0]):printsblo(49,16,0,"y2")
  282. '  end if
  283. '-----
  284.  
  285. paper(paleta$[ppcur]):pen(paleta$[ikcur])
  286.  
  287. refreshdispedit()
  288. refreshchrpalette(ikcur,ppcur)
  289. refreshikppcur()
  290. refreshchcur(60,1)  '-???? <-fix!!!!! :D
  291.  
  292. '-------------------------------------------------------------------------------
  293.  
  294. do
  295.   xmou=xmouse:ymou=ymouse
  296.   xmou2=int((xmou/zoommode)/8)
  297.   ymou2=int((ymou/zoommode)/10)
  298.   ymou3=int((ymou/zoommode)/8)
  299.  
  300.   if bmouse<>0 then:
  301.  
  302.   '- ink
  303.   if xmou2>=43 and xmou2<=50 and ymou2=1 then
  304.     ikcur=((xmou2-43)mod 8)
  305.     refreshchrpalette(ikcur,ppcur)
  306.     refreshikppcur()
  307.     end if
  308.  
  309.   '- paper
  310.   if xmou2>=43 and xmou2<=50 and ymou2=2 then
  311.     ppcur=((xmou2-43)mod 8)
  312.     refreshchrpalette(ikcur,ppcur)
  313.     refreshikppcur()
  314.     end if
  315.  
  316.   '- swap ink/paper
  317.   if xmou2>=47 and xmou2<=50 and ymou2=3 and mbutprs=0 then
  318.     mbutprs=1
  319.     swp=ikcur:ikcur=ppcur:ppcur=swp
  320.     refreshchrpalette(ikcur,ppcur)
  321.     refreshikppcur()
  322.     end if
  323.  
  324.   '- putchr
  325.   if  xmou2>=1 and xmou2<=40 and ymou2>=1 and ymou2<=25 then
  326.     ivcurb2=ivcur
  327.     if chcur>=256 then  '-blocks+seteg characters
  328.       ivcurb2=0
  329.     else                '- text+setet characters
  330.       '- do nothing yet! :D
  331.       end if
  332.     hexdumpplotctxstgi(xmou2,ymou2,chcur,paleta$[ikcur],paleta$[ppcur],ivcurb2)
  333.     mapch[xmou2-1,ymou2-1]=chcur
  334.     mapat[xmou2-1,ymou2-1]=(ppcur mod 8)*16+(ikcur mod 8)
  335.     if chcur<=255 then
  336.       mapat[xmou2-1,ymou2-1]=ivcurb2*64+(ikcur mod 8)
  337.       end if
  338.     end if
  339.  
  340.   '- getchr
  341.   if xmou2>=52 and xmou2<=67 and ymou2>=1 and ymou2<=28 and buttonmode1=0 then
  342.     refreshchcur(xmou2,ymou2)
  343.     chcur=(((xmou2-52)+(ymou2-1)*16)mod 512)
  344.     if chcur>127 then:chcur=chcur+32:end if
  345.     if chcur>383 then:chcur=chcur+32:end if
  346.     setetgeditc=0xffffff
  347.     if bitwiseand (chcur,128)=0 then '- replace this soon
  348.       setetgeditc=0x000000
  349.       end if
  350.     for y=0 to 9
  351.       bindispzoom(43,8+y,setetg[chcur*10+y],setetgeditc,0x808080,8,8)
  352.       next
  353.     end if
  354.  
  355.  
  356.  
  357.   '- copy setet/seteg button
  358.   if xmou2>=47 and xmou2<=50 and ymou2=15 and mbutprs=0 then
  359.     paper(paleta$[6]):pen(paleta$[0]):printsblo(47,15,0,"copy")
  360.     mbutprs=1
  361.     buttonmode1=1
  362.     end if
  363.  
  364.   '- copying setet/seteg
  365.   if xmou2>=52 and xmou2<=67 and ymou2>=1 and ymou2<=28 and buttonmode1=1 then
  366.     buttonmode1=0
  367.     chcuro=chcur
  368.     chcur=(((xmou2-52)+(ymou2-1)*16)mod 512)
  369.     if chcur>127 then:chcur=chcur+32:end if
  370.     if chcur>383 then:chcur=chcur+32:end if
  371.     if bitwiseand(chcur,128)<>0 then:
  372.       for y=0 to 9
  373.         setetg[chcur*10+y]=setetg[chcuro*10+y]
  374.         next
  375.       end if
  376.     refreshchrpalette(ikcur,ppcur)
  377.     refreshdispedit()
  378.     paper(paleta$[7]):pen(paleta$[0]):printsblo(47,15,0,"copy")
  379.     end if
  380.  
  381.  
  382.   '- swap setet/seteg button
  383.   if xmou2>=47 and xmou2<=50 and ymou2=17 and mbutprs=0 then
  384.     paper(paleta$[6]):pen(paleta$[0]):printsblo(47,17,0,"swap")
  385.     mbutprs=1
  386.     buttonmode1=2
  387.     end if
  388.  
  389.   '- swapping setet/seteg
  390.   if xmou2>=52 and xmou2<=67 and ymou2>=1 and ymou2<=28 and buttonmode1=2 then
  391.     buttonmode1=0
  392.     chcuro=chcur
  393.     chcur=(((xmou2-52)+(ymou2-1)*16)mod 512)
  394.     if chcur>127 then:chcur=chcur+32:end if
  395.     if chcur>383 then:chcur=chcur+32:end if
  396.     if bitwiseand(chcur,128)<>0 and bitwiseand(chcuro,128)<>0 then:
  397.       for y=0 to 9
  398.         swp=setetg[chcur*10+y]:setetg[chcur*10+y]=setetg[chcuro*10+y]:setetg[chcuro*10+y]=swp
  399.         next
  400.       end if
  401.     refreshchrpalette(ikcur,ppcur)
  402.     refreshdispedit()
  403.     paper(paleta$[7]):pen(paleta$[0]):printsblo(47,17,0,"swap")
  404.     end if
  405.  
  406.  
  407.   '- flip x - not working - i wonder why
  408.   if xmou2=49 and ymou2=19 and mbutprs=0 then:
  409.     mbutprs=1
  410.     chcur=(((xmou2-52)+(ymou2-1)*16)mod 512)
  411.     if chcur>127 then:chcur=chcur+32:end if
  412.     if chcur>383 then:chcur=chcur+32:end if
  413.     if bitwiseand(chcur,128)<>0 then:
  414.       for y=0 to 9
  415.         swp1=0
  416.         swp2=setetg[chcur*10+y]
  417.         for x=0 to 7
  418.           swp1=swp1*2
  419.           swp1=swp1+(swp2 mod 2)
  420.           swp2=int(swp2/2)
  421.           next
  422.         setetg[chcur*10+y]=swp1
  423.         next
  424.       end if
  425.     refreshchrpalette(ikcur,ppcur)
  426.     refreshdispedit()
  427.     end if
  428.  
  429.   '- flip y - not working - i wonder why
  430.   if xmou2=50 and ymou2=19 and mbutprs=0 then:
  431.     mbutprs=1
  432.     chcur=(((xmou2-52)+(ymou2-1)*16)mod 512)
  433.     if chcur>127 then:chcur=chcur+32:end if
  434.     if chcur>383 then:chcur=chcur+32:end if
  435.     if bitwiseand(chcur,128)<>0 then:
  436.       for y=0 to 4
  437.         swp=setetg[(chcur*10)+y]:setetg[(chcur*10)+y]=setetg[(chcur*10)+9-y]:setetg[(chcur*10)+9-y]=swp
  438.         next
  439.       end if
  440.     refreshchrpalette(ikcur,ppcur)
  441.     refreshdispedit()
  442.     end if
  443.  
  444.  
  445.  
  446.  
  447.  
  448.   '- inverse
  449.   if xmou2=47 and ymou2=5 and mbutprs=0 then
  450.     ivcur=1-ivcur
  451.     mbutprs=1
  452.     if ivcur=1 then
  453.       paper(paleta$[7]):pen(paleta$[0]):printsblo(47,5,0,"x")
  454.     else
  455.       paper(paleta$[7]):pen(paleta$[0]):printsblo(47,5,0," ")
  456.       end if
  457.     refreshchrpalette(ikcur,ppcur)
  458.     end if
  459.  
  460.   '- refresh display
  461.   if xmou2>=34 and xmou2<=40 and ymou2=27 then
  462.     refreshdispedit()
  463.     end if
  464.  
  465.   'setet/seteg - important
  466.   if xmou2>=43 and xmou2<=52 and ymou3>=8 and ymou3<=17 and mbutprs=0 then
  467.     if (chcur>=160 and chcur<=255) or (chcur>=256+160 and chcur<=511) then:
  468.       setetg[chcur*10+(ymou3-8)]=bitwisexor(setetg[chcur*10+(ymou3-8)],2^(50-xmou2))
  469.       bindispzoom(43,8+(ymou3-8),setetg[chcur*10+(ymou3-8)],0xffffff,0x808080,8,8)
  470.       refreshchrpalette(ikcur,ppcur)
  471.       mbutprs=1
  472.       end if:end if
  473.  
  474.   '- open file
  475.   if xmou2>=1 and xmou2<=4 and ymou2=27 then
  476.     shell("a=\"$(zenity --title \"open file...\" --file-selection ~/)\"; cp \"$a\" ./dummy.bin")
  477.     open "dummy.bin" for input as #1
  478.       for y=160 to 255:for x=0 to 9
  479.         setetg[y*10+x]=readbyte(1)
  480.         next:next
  481.       for y=160 to 255:for x=0 to 9
  482.         setetg[2560+y*10+x]=readbyte(1)
  483.         next:next
  484.       for y=0 to 24:for x=0 to 39
  485.         mapch[x,y]=readbyte(1)
  486.         mapat[x,y]=readbyte(1)
  487.         next:next
  488.       refreshdispedit()
  489.       refreshchrpalette(ikcur,ppcur)
  490.       refreshikppcur()
  491.       refreshchcur(60,1)  '-???? <-fix!!!!! :D
  492.       close #1
  493.     end if
  494.  
  495.   '- save file
  496.   if xmou2>=6 and xmou2<=9 and ymou2=27 then
  497.     refreshdispedit()
  498.     open "dummy.bin" for output as #1
  499.       for y=160 to 255:for x=0 to 9
  500.         writebyte(1,setetg[y*10+x])
  501.         next:next
  502.       for y=160 to 255:for x=0 to 9
  503.         writebyte(1,setetg[2560+y*10+x])
  504.         next:next
  505.       for y=0 to 24:for x=0 to 39
  506.         writebyte(1,mapch[x,y])
  507.         writebyte(1,bitwiseor(mapat[x,y], (int(mapch[x,y]/256))*128  )  )
  508.         next:next
  509.       close #1
  510.     shell("a=\"$(zenity --title \"save file...\" --save --confirm-overwrite --file-selection ./)\"; cp ./dummy.bin \"$a\"")
  511.     end if
  512.  
  513.   end if
  514.  
  515.   if bmouse=0 then:
  516.     mbutprs=0
  517.     end if
  518.  
  519.   '- debugging info
  520.   if debug=1 then:
  521.     paper(0x808080):pen(paleta$[0])
  522.     printsblo(1,28,0,right$("000"+str$(xmou2),3)  )
  523.     printsblo(1,29,0,right$("000"+str$(ymou2),3)  )
  524.     printsblo(6,28,0,right$("000"+str$(posloc(xmou,1,40,8,zoommode)),3)  )
  525.     printsblo(6,29,0,right$("000"+str$(posexs(xmou,1,40,8,zoommode)),3)  )
  526.     printsblo(10,28,0,right$("000"+str$(posloc(ymou,1,25,10,zoommode)),3)  )
  527.     printsblo(10,29,0,right$("000"+str$(posexs(ymou,1,25,10,zoommode)),3)  )
  528.     printsblo(16,28,0,right$("000"+str$(posloc(xmou,52,16,8,zoommode)),3)  )
  529.     printsblo(16,29,0,right$("000"+str$(posexs(xmou,52,16,8,zoommode)),3)  )
  530.     printsblo(20,28,0,right$("000"+str$(posloc(ymou,1,28,10,zoommode)),3)  )
  531.     printsblo(20,29,0,right$("000"+str$(posexs(ymou,1,28,10,zoommode)),3)  )
  532.     uuq1=posloc(ymou,1,32,10,zoommode)
  533.     uuq2=uuq1
  534.     if uuq1>7 then:uuq2=uuq2+2:end if
  535.     if uuq1>21 then:uuq2=uuq2+2:end if
  536.     printsblo(20,30,0,right$("000"+str$(uuq2),3) )
  537.     chq1=uuq2*16+posloc(xmou,52,16,8,zoommode)
  538.     printsblo(20,31,0,right$("000"+str$(chq1),3) )
  539.     printsblo(26,28,0,right$("000"+str$(posloc(xmou,43,8,8,zoommode)),3)  )
  540.     printsblo(26,29,0,right$("000"+str$(posexs(xmou,43,8,8,zoommode)),3)  )
  541.     printsblo(30,28,0,right$("000"+str$(posloc(ymou,8,10,8,zoommode)),3)  )
  542.     printsblo(30,29,0,right$("000"+str$(posexs(ymou,8,10,8,zoommode)),3)  )
  543.     end if
  544.  
  545.   waitvbl
  546.   loop
  547.  
  548. waitkey
  549.  
  550. '-------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement