TUGIF.BIN BASIC Listing for Commodore C64 TUGIF.BIN convert Commodore C64 graphics files to gif graphic files. Reverse character are listed as [c] with c as the reverse character. Example: reverse "s" is listed as [s]. The exception is reverse "]" is listed as [right] for cursor right. ----------------------------------------------------------------------------- 10 goto2015 15 poke55,254:poke56,31:clr:sys52410:gosub990 20 clr:ee$="":f$="":t=8192:v=53248:e=56576:m$=chr$(13):q$=chr$(34):f=255 22 pokee,7:sys58784:print"[:][3][q]" 24 print"[q]with disk containing file to be" 25 print"[q]converted to gif format in drive," 27 print"[q]enter device number (enter 0 to exit)." 30 print:print" 8[1]":inputdr:ifdr=.then67 32 ifdr<8ordr>30thengosub142:goto24 35 poke2,35:poke184,8:poke185,8:poke186,dr 37 poke183,1:poke187,2:poke188,.:sys65472 40 ifpeek(783)and1thenclose8:print"[3][q][r]?device";dr;"[=] not present":goto24 42 close8 43 print"[3][q]" 44 print"[q]with destination disk in drive to which" 45 print"[q]converted file is to be sent, enter" 47 print"[q]device number (enter 0 to exit)." 50 print:print" 8[1]":inputdw:ifdw=.then67 52 ifdw<8ordw>30thengosub142:goto44 55 print"[q]":poke186,dw:sys51667 57 ifpeek(2)=fthenprint"[3][q][r]?device";dw;"[=] not present":goto44 58 ifpeek(2)=.then62 59 print"[q]press return.":gosub990:goto43 62 print"[q]press return to continue." 63 print"[q]press r to reenter device number." 64 geta$:ifa$=m$then68 65 ifa$="r"then43 66 goto64 67 poke56,160:poke55,.:end 68 open8,dr,0,"$":print"[3][q]loading directory..." 70 poke21000,dr:poke21001,dw:sys50842:ifpeek(2)then75 72 print"[q][q]no files on disk[q]":goto24 75 sys51650 80 sys51624:gosub200 100 sys52385 136 geta$:ifa$<"8"anda$>"0"then144 137 ifa$="8"thengosub400:goto145 138 ifa$="9"then20 140 goto136 142 print"[3][q][r]illegal device number":return 144 gosub300 145 ifb$="p"then80 146 ifb$="s"then20 147 open8,dr,8,ee$:sys50329 148 pokev+17,59:pokev+24,120:pokee,6 149 ifa$="1"then175 150 ifa$="2"thenpoke50470,53:goto159 151 ifa$="3"thenpoke50470,75:goto159 152 ifa$="4"thenpoke50470,53:goto157 153 ifa$="5"thenpoke50470,75:goto157 154 ifa$="6"thenpoke50470,53:goto157 155 ifa$="7"then166 156 poke50470,53:pokev+22,24:sys51548:goto160 157 pokev+22,24:sys50447:ifa$="6"thensys50818:goto160 158 sys50616:goto160 159 sys50447 160 close8 162 getb$:ifb$="e"thenpokev+32,peek(v+32)+1andf:goto162 163 ifb$="g"then185 164 ifb$="a"then197 165 goto162 166 sys52946:poke781,191:sys50372 167 poke780,84:poke781,191:sys50374:sys52426:close8:poke2,. 168 getb$:ifb$="e"thenpokev+32,peek(v+32)+1andf:goto168 169 ifb$="g"then185 170 ifb$="a"then197 171 ifb$="[=]"thensys52975 172 ifb$="[right]"thensys52983 174 goto168 175 sys50640:close8 177 getb$:ifb$="e"thenpokev+32,peek(v+32)+1andf:sys50401 178 p=peek(23552) 179 ifb$="f"thenpoke781,p+16and240orpand15:sys50372:sys50401 180 ifb$="b"thenpoke781,p+1and15orpand240:sys50372:sys50401 181 ifb$="g"then185 182 ifb$="a"then197 183 goto177 185 open8,dw,1,f$:sys49320 186 ifa$="1"ora$="2"ora$="3"ora$="7"thengosub600:goto188 187 gosub650 188 sys49830:ifpeek(49828)thensys49908:goto190 189 sys49152 190 sys53220:sys51930:ifpeek(2)=fthengosub990:goto198 192 ifpeek(2)then198 193 geta$:ifa$=m$then20 194 ifa$="s"thenprint"[3][q]validating...":open1,dw,15,"v0":close1:goto198 195 goto193 197 pokee,7:sys58784 198 sys51198:ifpeek(780)=13thensys50895:goto75 199 goto20 200 print:print"[q][q]file chosen: ";q$;:printee$;q$;"[q]":return 300 sys51624:gosub200:onval(a$)gosub800,810,820,830,840,850,860 318 print"[q][q][q][q]" 319 print"gif file will be 320 x 200 x 16. 320 print"[q][q]press i for interlaced gif." 325 print"[q]press n for non-interlaced gif." 330 print"[q]press p for previous menu." 335 getb$:ifb$="p"thenreturn 340 ifb$="i"thenpoke49828,64:goto350 345 ifb$="n"thenpoke49828,0:goto350 347 goto335 350 f$=ee$:print"[3]" 351 b$=left$(ee$,2):ifb$="dd"orb$="jj"orb$="gg"thenf$=mid$(ee$,3):goto354 352 ifasc(ee$)=129thenf$=mid$(ee$,2):goto354 353 b$=right$(ee$,4):ifb$=".rle"orb$="mpic"thenf$=left$(ee$,len(ee$)-4) 354 f$=left$(f$,12)+".gif" 355 print"[s][q][q][q][q][q][q][q][q][q]? ";f$:sys53108 361 open8,dw,8,f$:close8:open8,dw,15 362 input#8,a,b$,j,j:close8 363 ifa<>62thenprint"[3][q][r]file exists.":f$=ee$:goto351 364 ifa$<>"7"then368 365 sys53195:print"0[1]" 366 inputd:ifd<0ord>33then365 367 poke150,d 368 print"[3][q]when you press return, the selected" 369 print"[q]graphics file will be read into memory" 370 print"[q]and displayed. when the display is" 371 ifa$="7"then550 372 print"[q]complete, you may step though exterior" 373 ifa$="1"then500 375 print"[q]colors by pressing e. when you are" 380 print"[q]ready to form the gif file, press g." 382 print"[q]you may abort the process by pressing a." 385 ifa$<>"1"anda$<>"7"thenprint"[q][q][q]" 387 print"[q][q]press return to proceed." 390 print"[q]press s to start over." 392 getb$:ifb$=m$orb$="s"thenreturn 395 goto392 400 sys51624:gosub200 405 print"examining file...[q]":el=len(ee$):eu$="mpic" 408 e1$=left$(ee$,2):e2$=right$(ee$,4):open8,dr,8,ee$:sys51397:close8 415 p=peek(155)+256*peek(156):e1=asc(e1$):eu=peek(150) 417 ev=peek(139):ew=peek(140):ex=peek(141):ey=peek(142):ez=peek(143) 420 ev$="very likely"+m$:ep$="probably"+m$:ej$="[q]compressed doodle." 425 ef$="graphics format is ":ed$="[q]standard doodle." 430 eg$="[q]compressed koala.":er$="[q]rle.":es$="[q]standard koala." 435 ea$="[q]advanced art studio.":et$="[q]geopaint." 440 ifeu=.thenprintef$;ev$;et$:a$="7":goto318 442 if(p=36orp=37)andew=.thenprintef$;ev$;ed$:a$="2":goto318 445 if(p=40orp=41)andex=.ande1=129thenprintef$;ev$;es$:a$="4":goto318 450 ifp<36and(ev=.orew=.)ande1$="jj"thenprintef$;ev$;ej$:a$="3":goto318 455 ifp<36and(ev=.orew=.)thenprintef$;ep$;ej$:a$="3":goto318 460 ifp<40and(ex=.orey=.)ande1$="gg"thenprintef$;ev$;eg$:a$="5":goto318 465 ifp<40and(ex=.orey=.)thenprintef$;ep$;eg$:a$="5":goto318 470 if(p=40orp=41)andex=.ande2$=eu$andel=16thenprintef$;ev$;ea$:a$="6":goto318 475 ifez=.ande2$=".rle"thenprintef$;ev$;er$:a$="1":goto318 480 ifez=.thenprintef$;ep$;er$:a$="1":goto318 482 if(p=40orp=41)andex=.thengosub700:goto319 483 print"file does not seem to be in one of the" 484 print"[q]supported graphics formats. press p":print"[q]for previous menu." 487 getb$:ifb$="p"thenreturn 488 goto487 500 print"[q]colors by pressing e, foreground colors" 510 print"[q]by pressing f, and background colors" 520 print"[q]by pressing b. when you are":goto380 550 print"[q]complete, you may scroll the image" 560 print"[q]horizontally by using cursor left/right." 570 print"and you may step through exterior":goto375 600 poke49948,129:poke49949,192:poke49235,129:poke49236,192 610 poke50032,129:poke50033,192:poke50162,129:poke50163,192:return 650 poke49948,86:poke49949,196:poke49235,86:poke49236,196 660 poke50032,86:poke50033,196:poke50162,86:poke50163,196:return 700 print"the file seems to be in either of two" 710 print"[q]multicolor formats. the deciding data" 720 print"[q]are at the end of the file, and will" 730 print"[q]be used to convert the file correctly.[q]":return 800 print"rle (.rle extension) format[q][q][q][q]":return 810 print"standard doodle (dd prefix) format[q][q][q][q]":return 820 print"compressed doodle (jj prefix) format[q][q][q][q]":return 830 print"standard koala ([r]A[2] prefix) format[q][q][q][q]":return 840 print"compressed koala (gg prefix) format[q][q][q][q]":return 850 print"advanced art studio (mpic suffix) format[q][q][q]":return 860 print"geopaint (non-geos file) format[q][q][q][q]":return 990 geta$:ifa$=chr$(13)thenreturn 995 goto990 2015 poke56,99:clr:print"[3][.][q]one moment please..." 2020 p=peek(45)+256*peek(46)-1 2025 ifpeek(p)thenp=p-1:goto2025 2030 fori=.to22:ready:poke40000+i,y:next 2035 poke53,254:poke54,207:poke251,209:poke252,231 2040 poke254,p/256:poke253,pand255:sys40000 2045 p=p-6567:pokep-2,.:pokep-1,.:poke251,pand255:poke252,p/256 2050 poke45,peek(251):poke46,peek(252) 2055 poke2054,48:goto15 2060 data160,0,177,253,145,53,152,208 2065 data4,198,54,198,254,136,230,251 2070 data208,240,230,252,208,236,96