Home » Personal collection » Acorn hard disk » apps » web » !ChangeFSI/ChangeFSI
!ChangeFSI/ChangeFSI
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Personal collection » Acorn hard disk » apps » web |
Filename: | !ChangeFSI/ChangeFSI |
Read OK: | ✔ |
File size: | 28885 bytes |
Load address: | 0000 |
Exec address: | 0000 |
Duplicates
There are 3 duplicate copies of this file in the archive:
- Personal collection » Acorn ADFS disks » Greaseweazled » adfs_1.6M_Apps2.adf » !ChangeFSI/ChangeFSI
- Personal collection » Acorn hard disk » apps » ImagePrcss » !ChangeFSI/ChangeFSI
- Personal collection » Acorn hard disk » apps » web » !ChangeFSI/ChangeFSI
- Personal collection » Acorn hard disk » zipped_disks » 2000_apps_2 » apps2/!ChangeFSI/ChangeFSI
File contents
10REM > ChangeFSI 140areanumber%=0 150SYS"OS_GetEnv" TO A$ 160task%=INSTR(A$," -wimp"):IFtask% THEN 170DIM z%(1),p%(3),s%(3),m$(30) 180A%=OPENIN"<ChangeFSI$Dir>.Messages" 190B%=-1:REPEAT B%+=1:m$(B%)=GET$#A%:UNTILEOF#A%:CLOSE#A% 200startfile%=RIGHT$(A$,6)<>"-wimp " 210DIM taskid%4:$taskid%="TASK" 220SYS "Wimp_Initialise",200,!taskid%,m$(20) TO version% 230IF version%>=350 THEN 240SYS"OS_Memory",8+(2<<8) TO ,r1,r2:vramsize%=r1*r2 250IF vramsize%>0 vram%=TRUE ELSEvram%=FALSE 260ELSE 270vram%=FALSE 280ENDIF 290Wimp = (1<<18) + (3<<6) 300CreateW = Wimp+1:OpenW = Wimp+5 :CloseW = Wimp+6:RedrawW = Wimp+8 310UpdateW = Wimp+9:GetR% = Wimp+10:GetW = Wimp+11:SetI = Wimp+13 320GetI = Wimp+14:GetP = Wimp+15:Drag = Wimp+16:CrMenu = Wimp+20 330DcMenu = Wimp+21 340SYS "OS_SWINumberFromString",,"Wimp_PollIdle" TO Poll% 350SYS "OS_SWINumberFromString",,"XOS_SpriteOp" TO spopx% 360SYS "OS_SWINumberFromString",,"OS_SpriteOp" TO spop% 370SYS "OS_SWINumberFromString",,"OS_ReadMonotonicTime" TO Time% 380SYS "OS_SWINumberFromString",,"ColourTrans_ReturnColourNumber" TO ctran% 390SYS "OS_SWINumberFromString",,"Wimp_SetCaretPosition" TO Caretpos% 400SYS "OS_SWINumberFromString",,"Wimp_GetCaretPosition" TO Getcaret% 410SYS "XOS_SWINumberFromString",,"DragASprite_Start" TO dstart%;f%:IFf%AND 1 dstart%=0 420SYS "XOS_SWINumberFromString",,"JPEG_PlotScaled" TO jpegpaint%;f%:IFf%AND 1 jpegpaint%=0 430SYS "OS_Byte",161,&1C TO ,,f%:IF(f%AND2)=0 dstart%=0 440nextlocation%=HIMEM 450SYS "Wimp_SlotSize",-1,-1 TO originalslot% 460PROClocale_initialise 480IF version%>=300 THEN 490DIM q% 255,ifactors% 15,factors% 15,pixtrans% 255,paltemp% 1023,buffer% 255,idata% 1023 500ELSE 510DIM z% 1699,q% 255,ifactors% 15,factors% 15,pixtrans% 255,paltemp% 1023,buffer% 255,idata% 2399 520eidata%=idata%+2400 530ENDIF 550scrap%=FALSE:sprite%=FALSE:sar%=FALSE:saved%=TRUE:z$=STRING$(12,CHR$13) 570SYS "OS_Byte",161,&8C TO ,,f% 580IFf% AND 1 THEN 590SYS"Wimp_OpenTemplate",,"<ChangeFSI$Dir>.3dTemplate" 600ELSE 610SYS"Wimp_OpenTemplate",,"<ChangeFSI$Dir>.Templates" 620ENDIF 640LOCAL ERROR 650ON ERROR SYS"Wimp_CloseTemplate":ERROR 0,REPORT$+" (code "+STR$ERL+")" 670IFversion%>=300 THEN 690name=q% 700$name="*":here%=0:largest_tem%=0 710SYS "Wimp_LoadTemplate", ,0,,,,name,0 TO ,size%,,,,,here% 720WHILE here% 730IF largest_tem%<size% largest_tem%=size% 740$name="*" 750SYS "Wimp_LoadTemplate", ,0,,,,name,here% TO ,size%,,,,,here% 760ENDWHILE 770DIM z% largest_tem% 780ENDIF 800PROCdotemplate("Info") 810SYS CreateW,,z% TO infow%:$!(z%+88+7*32+20)=m$(21) 830PROCdotemplate("Processing") 840SYS CreateW,,z% TO proc% 850p%(0)=!(z%+88+8*32+20):p%(1)=!(z%+88+9*32+20):p%(2)=!(z%+88+10*32+20):p%(3)=!(z%+88+12*32+20) 870PROCdotemplate("Output") 880SYS CreateW,,z% TO output%:admode%=!(z%+88+20*32+20):adspcl%=!(z%+88+19*32+20):oldmode%=!(z%+88+34*32+20) 900PROCdotemplate("Scaling") 910SYS CreateW,,z% TO scalew%:adscale%=!(z%+88+1*32+20) 920s%(0)=!(z%+88+10*32+20):s%(1)=!(z%+88+11*32+20):s%(2)=!(z%+88+12*32+20):s%(3)=!(z%+88+13*32+20) 940PROCdotemplate("Save") 950SYS CreateW,,z% TO save%:adsave%=!(z%+88+1*32+20):adsavesprite%=!(z%+88+0*32+20) 970PROCdotemplate("Sprite") 980SYS CreateW,,z% TO sinfo%:adsname%=!(z%+88+5*32+20):adsbytes%=!(z%+88+8*32+20) 990adsx%=!(z%+88+7*32+20):adsy%=!(z%+88+9*32+20):adsm%=!(z%+88+6*32+20) 1010PROCdotemplate("Source") 1020SYS CreateW,,z% TO srcinfo%:adsrc%=!(z%+88+0*32+20) 1040PROCdotemplate("Range") 1050SYS CreateW,,z% TO raninfo%:adran%=!(z%+88+0*32+20) 1070PROCdotemplate("Zoom") 1080SYS CreateW,,z% TO zoom%:z%(0)=!(z%+88+4*32+20):z%(1)=!(z%+88+5*32+20) 1100PROCdotemplate("JPEGOutput") 1110SYS CreateW,,z% TO jpego%:adjpegq%=!(z%+88+5*32+20) 1130PROCdotemplate("Pic") 1140SYS CreateW,,z% TO pic%:adtitle%=z%!72 1160RESTORE ERROR 1170SYS"Wimp_CloseTemplate" 1180!q%=-1:q%!4=0:q%!8=0:q%!12=68:q%!16=68:q%!20=%11000000000010 1190$(q%+24)="!"+m$(20):SYS"Wimp_CreateIcon",,q% TO iconbar% 1200A%=OPENIN"<ChangeFSI$Dir>.Choices":IFA%=0 THEN 1210fast%=FALSE:dest%=1:statescale%=%10000000100:stateproc%=0:stateoutput%=&4052008:statejpeg%=&2 1220$p%(0)="":$p%(1)="2"+decimal_point$+"2":$p%(2)="24":$p%(3)="4":$adspcl%="" 1230$admode%="28":$s%(0)="1":$s%(1)="4":$s%(2)="1":$s%(3)="4" 1240$adjpegq%="75":$oldmode%="" 1250ELSE 1260INPUT#A%,fast%,dest%,statescale%,stateproc%,stateoutput%,statejpeg%,$adjpegq%,$oldmode% 1270INPUT#A%,$p%(0),$p%(1),$p%(2),$p%(3),$admode%,$adspcl% 1280$p%(1)=FNlocale_convert($p%(1),".",decimal_point$) 1290INPUT#A%,$s%(0),$s%(1),$s%(2),$s%(3) 1300CLOSE#A% 1310ENDIF 1320q%!12=1<<21 1330!q%=scalew%:FORI%=0TO9:IFstatescale%>>I%AND1 q%!8=1<<21 ELSEq%!8=0 1340q%!4=I%:SYS SetI,,q%:NEXT 1350FORI%=10TO13:IFstatescale%>>I%AND1 q%!8=1<<21 ELSEq%!8=0 1360q%!4=I%+6:SYS SetI,,q%:NEXT 1370!q%=proc%:FORI%=0TO7:IFstateproc%>>I%AND1 q%!8=1<<21 ELSEq%!8=0 1380q%!4=I%:SYS SetI,,q%:NEXT 1390!q%=output%:FORI%=0TO26:IFstateoutput%>>I%AND1 q%!8=1<<21 ELSEq%!8=0 1400q%!4=I%:SYS SetI,,q%:NEXT 1410!q%=jpego%:FORI%=0TO3:IFstatejpeg%>>I%AND1 q%!8=1<<21 ELSEq%!8=0 1420q%!4=I%:SYS SetI,,q%:NEXT 1430IFstateoutput%>>17AND1 q%!8=1<<22 ELSEq%!8=0 1440!q%=output%:q%!12=1<<22:q%!4=7:SYS SetI,,q%:q%!4=8:SYS SetI,,q%:q%!4=13:SYS SetI,,q%:q%!4=14:SYS SetI,,q% 1450PROCshowscaletofit:$z%(0)="1":$z%(1)="1" 1460SYS "OS_UpdateMEMC" TO oldmemc 1470jpegsave%=FALSE 1480ON ERROR SYS"OS_UpdateMEMC",oldmemc,&700:PROCerrorbox:SYS CrMenu,,-1 1490SYS Drag,,-1 1500IFNOTsprite% SYS "Wimp_SlotSize",originalslot%,-1 1510F$="":IFstartfile% startfile%=FALSE:F$=MID$(A$,INSTR(A$,"-wimp")+6):PROCcallFSI 1520REPEAT 1530SYS Poll%,1,q% TO A% 1540CASE A% OF 1550WHEN 1 :IFsprite% PROCredraw_window(!q%) 1560WHEN 2 :PROCopen_window(!q%,q%!4,q%!8,q%!12,q%!16,q%!20,q%!24,q%!28) 1570WHEN 3 :SYS &400c3,,q%:nextlocation%=HIMEM:PROCremovearea 1580SYS "Wimp_SlotSize",originalslot%,-1:saved%=TRUE:sprite%=FALSE 1590WHEN 6 :PROCcheckmouse(!q%,q%!4,q%!8,q%!12,q%!16,q%!20) 1600WHEN 7 :SYS GetP,,q%:dw%=q%!12:di%=q%!16:IFdstart% SYS"DragASprite_Stop" 1610q%!12=0:q%!16=1:q%!20=dw%:q%!24=di%:q%!28=!q%:q%!32=q%!4:q%!36=!sar%+3 1620IFjpegsave% THENq%!40=&c85 ELSEq%!40=&ff9 1630temp$=FNZS(adsave%):foo%=INSTR(temp$,"."):WHILEfoo% 1640temp$=MID$(temp$,foo%+1):foo%=INSTR(temp$,".") 1650ENDWHILE 1660$(q%+44)=temp$+CHR$0:!q%=44+(LENtemp$+1+3ANDNOT3) 1670SYS "Wimp_SendMessage",17,q%,dw%,di%:myref%=q%!8 1680WHEN 8 :PROCkey(!q%,q%!4,q%!24) 1690WHEN 9 :PROCmenuselect(q%) 1700WHEN 17,18:PROCreceive(q%) 1710ENDCASE 1720UNTIL FALSE 1730ELSE 1740Q%=HIMEM 1750END=&4000000 1760ON ERROR ON ERROR OFF:OSCLI"Set ChangeFSI$ReturnCode "+REPORT$+" (code "+STR$ERL+")":PROCremovearea:CLEAR:END=Q%:END 1770foo%=0:A%=FNChangeFSI(A$,-1,-1,0,-1,-1,foo%,TRUE) 1780PROCremovearea:*unset ChangeFSI$ReturnCode 1790CLEAR:END=Q% 1800ENDIF 1810END 1830DEF PROCdotemplate(a$) 1840LOCAL A% 1850IFversion%>300 THEN 1860SYS "Wimp_LoadTemplate",,0,,,,a$+z$,0 TO ,,indsize% 1870DIM A% indsize% 1880SYS"Wimp_LoadTemplate",,z%,A%,A%+indsize%,-1,a$+z$,0 1890ELSE 1900SYS"Wimp_LoadTemplate",,z%,idata%,eidata%,-1,a$+z$,0 TO ,,idata% 1910ENDIF 1920ENDPROC 1940DEF PROClocale_initialise 1950LOCAL p% 1960LOCAL ERROR 1970ON ERROR LOCAL decimal_point$=".":ENDPROC 1980SYS "Territory_ReadSymbols",-1,0 TO p% 1990decimal_point$=CHR$?p% 2000ENDPROC 2020DEF FNlocale_convert(n$,f$,t$) 2030IF f$=t$ THEN=n$ 2040LOCAL i% 2050i%=INSTR(n$,f$) 2060IF i%<>0 THEN=LEFT$(n$,i%-1)+t$+MID$(n$,i%+1) 2070=n$ 2090DEF PROCreceive(q%) 2100CASE q%!16 OF 2110WHEN 0:PROCremovearea:SYS "Wimp_CloseDown":END 2120WHEN 1:IFq%!20<>save% THEN 2130!q%=60:q%!12=q%!8:q%!16=2:q%!36=-1:$(q%+44)="<Wimp$Scrap>"+CHR$0 2140SYS"Wimp_SendMessage",17,q%,q%!4:scrap%=q%!8 2150ENDIF 2160WHEN 2:IFjpegsave% THEN 2170SYS"OS_File",10,FNZS(q%+44),&c85,,sar%,sar%+jpegsize% 2180ELSE 2190SYSspop%,&10C,sar%,FNZS(q%+44) 2200ENDIF 2210$adsave%=FNZS(q%+44) 2220q%!12=q%!8:q%!16=3:SYS "Wimp_SendMessage",18,q%,q%!4 2230IF q%!36<>-1 saved%=TRUE 2240SYS CrMenu,,-1 2250WHEN 3:F$=FNZS(q%+44):IFscrap% scrap%=scrap%=q%!12 2260q%!12=q%!8:q%!16=4:SYS"Wimp_SendMessage",17,q%,q%!4 2270PROCcallFSI 2280WHEN 5:CASE q%!40 OF 2290WHEN &ff0,&c85 2300q%!12=q%!8:q%!16=4:SYS"Wimp_SendMessage",17,q%,q%!4 2310F$=FNZS(q%+44):PROCcallFSI 2320ENDCASE 2330WHEN 8:IFsaved%ORNOTsprite% ENDPROC 2340!buffer%=ERR:$(buffer%+4)=m$(2)+F$+m$(3)+CHR$0 2350SYS"Wimp_ReportError",buffer%,%10111,m$(20) TO ,A% 2360q%!12=q%!8:IFA%<>1 SYS"Wimp_SendMessage",19,q%,0 2370WHEN9,&400C1:IFsprite% PROCgetmodeinfo:SYS&400d1,pic%,0,-32767,32767,0 2380PROCshowscaletofit 2390WHEN 10:SYS"XOS_ReadVarVal","ChangeFSI$Dir",paltemp%,256,0,3 TO,,bootlen% 2400paltemp%?bootlen%=13 2410BPUT#q%!20,"Run "+$paltemp% 2420ENDCASE 2430ENDPROC 2450DEF PROCcallFSI 2460IF FNcheckvalues THENENDPROC 2470A$=FNdeducemode:A%=47 2480jpegsave%=FALSE:IFdest%=0 THEN 2490jpegsave%=TRUE:A$="JPEG":IFFNgeticonstate(jpego%,2) A$="JPEGMONO" 2500A$+=$adjpegq% 2510ELSE 2520IFFNgeticonstate(output%,15) THEN 2530A$+=$adspcl% 2540ELSE 2550IFFNgeticonstate(output%,16) THEN 2560IFFNgeticonstate(output%,5)ORFNgeticonstate(output%,11) A$+="R" 2570ELSE 2580SYS53,VALA$,3 TO,,A% 2590IFA%=63 THEN 2600IFFNgeticonstate(output%,6) A$="27t" 2610IFFNgeticonstate(output%,12) A$="12t" 2620ELSE 2630IFA%=255 A$+="d" 2640ENDIF 2650ENDIF 2660ENDIF 2670ENDIF 2680A$="garbage "+F$+" <ChangeFSI$Dir>.Foo "+A$ 2690PROCChangeFSISuffix 2700info$="":range$=m$(19):cputime%=0 2710IFsprite% !q%=pic%:SYS &400c3,,q%:saved%=TRUE:sprite%=FALSE 2720nextlocation%=HIMEM 2730SYS "Wimp_SlotSize",originalslot%,-1:PROCremovearea 2740IFfast% SYS "OS_UpdateMEMC",&300,&700 TO oldmemc 2750A%=FNChangeFSI(A$,-1,-1,nextlocation%,0,0,sar%,0) 2760IFfast% SYS "OS_UpdateMEMC",oldmemc,&700 2770IFscrap% scrap%=FALSE:SYS"OS_File",6,F$ 2780IFA%<2 AND sar%<>0 THEN 2790$adsx%=STR$xsp%:$adsy%=STR$ysp%:IFjpegsave% THEN 2800$adsm%="JPEG":$adsname%="JPEG" 2810$adsbytes%=STR$jpegsize% 2820x=xsp%*2:y=ysp%*2 2830SYS&35,-1,4 TO,,nx:SYS&35,-1,5 TO,,ny 2840!ifactors%=1:ifactors%!4=1:ifactors%!8=nx:ifactors%!12=ny 2850$adsavesprite%="file_c85" 2860IF LEFT$(F$,7)="<Wimp$S" F$="JPEGImage" 2870ELSE 2880SYS spopx%,&10d,sar%,pixtrans%,255,1 2890n$=FNZS(pixtrans%):SYS spopx%,&128,sar%,n$ TO,,,x,y,,m 2900$adsm%=STR$m:$adsname%=n$ 2910$adsbytes%=STR$sar%!12 2920SYS&35,m,4 TO,,nx:x=x<<nx 2930SYS&35,m,5 TO,,ny:y=y<<ny:PROCgetmodeinfo 2940$adsavesprite%="file_ff9" 2950IF LEFT$(F$,7)="<Wimp$S" F$="SpriteFile" 2960ENDIF 2970!q%=save%:q%!4=0:q%!8=0:q%!12=0:SYS SetI,,q% 2980$adran%=range$:$adsrc%=info$+m$(0)+STR$(cputime%DIV100)+decimal_point$+RIGHT$("0"+STR$(cputime%MOD100),2)+m$(1) 2990saved%=FALSE:sprite%=TRUE 3030A%=LENF$:WHILEMID$("."+F$,A%,1)<>".":A%-=1:ENDWHILE 3040$adsave%=MID$("."+F$,A%+1) 3060pic%=FNcreate_window(x,y,F$) 3070PROCpopup(pic%,-1) 3080ENDIF 3090ENDPROC 3110DEF FNcheckvalues 3120LOCAL e,error$,flag% 3140IF dest%=0 AND VAL$adjpegq%>100 THEN 3150e=1:error$=m$(22)+m$(25)+m$(23)+m$(27)+m$(24) 3160ENDIF 3180IF LEFT$($admode%,1)<"A" AND dest%=1 THEN 3190SYS &35,VAL$admode%,0 TO ;flag% 3210IF LEN$admode%=0 flag%=2 3220IF VAL$admode%>127 AND VAL$admode%<256 flag%=2 3230IF (flag%AND2)>0 THEN 3240e=2:error$=m$(22)+m$(26)+m$(23)+m$(13)+m$(24) 3250ENDIF 3260ENDIF 3270IF e THEN 3280SYS Drag,,-1:!buffer%=e:$(buffer%+4)=error$+CHR$0 3290SYS "Wimp_ReportError",buffer%,%01,m$(20) TO ,A% 3300IFA%=2 PROCremovearea:SYS "Wimp_CloseDown":END 3310ENDIF 3320=e 3340DEF PROCChangeFSISuffix 3350safe%=TRUE 3360IFFNgeticonstate(scalew%,1) A$+=" "+STR$tofitx+": "+STR$tofity+":":safe%=FALSE 3370IFFNgeticonstate(scalew%,5) A$+=" 1:2":safe%=FALSE 3380IFFNgeticonstate(scalew%,4) A$+=" 1:2 1:1":safe%=FALSE 3390IFFNgeticonstate(scalew%,3) A$+=" 1:1 1:2":safe%=FALSE 3400IFFNgeticonstate(scalew%,9) THEN 3410safe%=FALSE 3420IFVAL$s%(0) A$+=" "+$s%(0) ELSEA$+=" 1" 3430A$+=":"+$s%(1) 3440IFVAL$s%(2) A$+=" "+$s%(2) ELSEA$+=" 1" 3450A$+=":"+$s%(3) 3460ENDIF 3470IFFNgeticonstate(scalew%,0) A$+=" -nosize" 3480IFFNgeticonstate(scalew%,18) A$+=" -noscale" 3490IFFNgeticonstate(scalew%,19) A$+=" -lock" 3500IFFNgeticonstate(scalew%,6) THEN 3510safe%=FALSE:IFFNgeticonstate(scalew%,16) A$+=" -rotate" ELSEA$+=" -rotate-" 3520ENDIF 3530IFFNgeticonstate(scalew%,7) A$+=" -hflip":safe%=FALSE 3540IFFNgeticonstate(scalew%,8) A$+=" -vflip":safe%=FALSE 3550IFFNgeticonstate(proc%,0) A$+=" -range":safe%=FALSE 3560IFFNgeticonstate(proc%,1) A$+=" -equal":safe%=FALSE 3570IFFNgeticonstate(proc%,2) A$+=" -nodither" 3580IFFNgeticonstate(proc%,3) A$+=" -invert":safe%=FALSE 3590IFFNgeticonstate(proc%,4) A$+=" -brighten" 3600IFFNgeticonstate(proc%,5) A$+=" -black"+$p%(0) 3610IFFNgeticonstate(proc%,6) A$+=" -gamma"+FNlocale_convert($p%(1),decimal_point$,"."):safe%=FALSE 3620IFFNgeticonstate(proc%,7) A$+=" -sharpen"+$p%(2):safe%=FALSE 3630IFFNgeticonstate(proc%,11) A$+=" -smooth"+$p%(3) 3640ENDPROC 3660DEF PROCcheckandfinish 3670IFsaved% ORNOTsprite% PROCremovearea:SYS "Wimp_CloseDown":END 3680!buffer%=ERR:$(buffer%+4)=m$(2)+F$+m$(3)+CHR$0 3690SYS "Wimp_ReportError",buffer%,%10111,m$(20) TO ,A% 3700IFA%=1 PROCremovearea:SYS "Wimp_CloseDown":END 3710ENDPROC 3730DEF PROCkey(handle%,icon%,key%) 3740IFkey%=&1b SYS CrMenu,,-1:ENDPROC 3750CASE handle% OF 3760WHEN zoom%:CASE key% OF 3770WHEN 13:PROCdozoom(icon%-4,0):IFicon%=4 SYS &400d2,zoom%,5,,,-1,LEN$z%(0) 3780IFicon%=5 SYS CrMenu,,-1 3790ENDPROC 3800WHEN &18e,&18f:PROCdozoom(icon%-4,0) 3810SYS &400d2,zoom%,icon%EOR1,,,-1,LEN$z%(icon%EOR5):ENDPROC 3820ENDCASE 3830WHEN save% 3840IFkey%=13 PROCsavesprite:ENDPROC 3850WHEN output% 3860IF icon%=34 AND FNgeticonstate(output%, 24) THEN$admode% = $oldmode%:!q%=output%:q%!4=20:q%!8=0:q%!12=0:SYS SetI,,q% 3870PROCshowscaletofit 3880IFkey%=13 SYS CrMenu,,-1:ENDPROC 3890IFkey%=&18e THEN 3900CASE icon% OF 3910WHEN 19:icon%=34:key%=oldmode% 3920WHEN 34:icon%=22:key%=adjpegq% 3930WHEN 22:icon%=19:key%=adspcl% 3940ENDCASE 3950ENDIF 3960IFkey%=&18f THEN 3970CASE icon% OF 3980WHEN 22:icon%=34:key%=oldmode% 3990WHEN 34:icon%=19:key%=adspcl% 4000WHEN 19:icon%=22:key%=adjpegq% 4010ENDCASE 4020ENDIF 4030IFkey%>1024 SYS &400d2,output%,icon%,,,-1,LEN$key%:ENDPROC 4040WHEN proc%:CASE key% OF 4050WHEN &18e,13:icon%+=1:IFicon%>10 icon%=8:IFkey%=13 SYS CrMenu,,-1:ENDPROC 4060SYS &400d2,proc%,icon%,,,-1,LEN$p%(icon%-8):ENDPROC 4070WHEN &18f:icon%-=1:IFicon%<8 icon%=10 4080SYS &400d2,proc%,icon%,,,-1,LEN$p%(icon%-8):ENDPROC 4090ENDCASE 4100WHEN scalew%:CASE key% OF 4110WHEN &18e,13:icon%+=1:IFicon%>13 icon%=10:IFkey%=13 SYS CrMenu,,-1:ENDPROC 4120SYS &400d2,scalew%,icon%,,,-1,LEN$s%(icon%-10):ENDPROC 4130WHEN &18f:icon%-=1:IFicon%<10 icon%=13 4140SYS &400d2,scalew%,icon%,,,-1,LEN$s%(icon%-10):ENDPROC 4150ENDCASE 4160ENDCASE 4170SYS "Wimp_ProcessKey",key% 4180ENDPROC 4200DEF PROCsavesprite 4210IF F$=$adsave% THEN 4220SYS Drag,,-1:!buffer%=3:$(buffer%+4)=m$(28)+CHR$0 4230SYS "Wimp_ReportError",buffer%,%11,m$(20) TO ,A% 4240IFA%=2 THEN 4250SYS CrMenu,,-1 4260ENDPROC 4270ENDIF 4280ENDIF 4290IFjpegsave% THEN 4300SYS"OS_File",10,$adsave%,&c85,,sar%,sar%+jpegsize% 4310ELSE 4320SYS spop%,&10C,sar%,$adsave% 4330ENDIF 4340SYS CrMenu,,-1 4350ENDPROC 4370DEF PROCcheckmouse(mousex%,mousey%,b%,handle%,icon%,ob%) 4380LOCAL moved%:moved%=FALSE 4390IFb%AND2 THEN 4400CASE handle% OF 4410WHEN pic%:PROCdomenu(pic%,m$(4)+">sinfo%,"+m$(5)+">srcinfo%,"+m$(6)+">raninfo%,"+m$(7)+">zoom%,"+m$(8)+">save%,"+m$(9),m$(20)) 4420WHEN -2:PROCdomenu(101,m$(10)+">infow%,"+m$(11)+">scalew%,"+m$(12)+">proc%,"+m$(13)+">output%:dest%,"+m$(27)+">jpego%:1-dest%,"+m$(9)+","+m$(14)+":fast%AND1,"+m$(15)+","+m$(16),m$(20)) 4430ENDCASE 4440rmenuhandle%=handle% 4450ENDIF 4460IFb%AND4 THEN 4470CASE handle% OF 4480WHEN zoom%:CASE icon% OF 4490WHEN 0:PROCdozoom(0,1) 4500WHEN 1:PROCdozoom(0,-1) 4510WHEN 2:PROCdozoom(1,1) 4520WHEN 3:PROCdozoom(1,-1) 4530ENDCASE 4540ENDCASE 4550ENDIF 4560IFb%AND1 THEN 4570CASE handle% OF 4580WHEN zoom%:CASE icon% OF 4590WHEN 0:PROCdozoom(0,-1) 4600WHEN 1:PROCdozoom(0,1) 4610WHEN 2:PROCdozoom(1,-1) 4620WHEN 3:PROCdozoom(1,1) 4630ENDCASE 4640ENDCASE 4650ENDIF 4660IFb%AND5 THEN 4670CASE handle% OF 4680WHEN output%:IF dest%=0 dest%=1:PROCdomenu(101,m$(10)+">infow%,"+m$(11)+">scalew%,"+m$(12)+">proc%,"+m$(13)+">output%:dest%,"+m$(27)+">jpego%:1-dest%,"+m$(9)+","+m$(14)+":fast%AND1,"+m$(15)+","+m$(16),m$(20)):SYS Getcaret%,,q%:moved%=TRUE 4690CASE icon% OF 4700WHEN 3,4,5,6:PROCkillcurrent(STR$(22+icon%)):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4710WHEN 7:PROCkillcurrent("S16,90,90"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4720WHEN 8:PROCkillcurrent("S32,90,90"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4730WHEN 9:PROCkillcurrent("0"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4740WHEN 10:PROCkillcurrent("8"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4750WHEN 11:PROCkillcurrent("12"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4760WHEN 12:PROCkillcurrent("15"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4770WHEN 13:PROCkillcurrent("S16,90,45"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4780WHEN 14:PROCkillcurrent("S32,90,45"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4790WHEN 15:PROCkillcurrent(FNdeducemode):SYS SetI,,q%:SYS Caretpos%,output%,19,,,-1,LEN($adspcl%):!q%=output%:q%!4=7:q%!8=0:q%!12=1<<22:SYS SetI,,q%:q%!4=8:SYS SetI,,q%:q%!4=13:SYS SetI,,q%:q%!4=14:SYS SetI,,q% 4800WHEN 16:PROCkillcurrent(FNdeducemode):!q%=output%:q%!4=7:q%!8=0:q%!12=1<<22:SYS SetI,,q%:q%!4=8:SYS SetI,,q%:q%!4=13:SYS SetI,,q%:q%!4=14:SYS SetI,,q% 4810WHEN 17:PROCkillcurrent(FNdeducemode):!q%=output%:q%!4=7:q%!8=1<<22:q%!12=1<<22:SYS SetI,,q%:q%!4=8:SYS SetI,,q%:q%!4=13:SYS SetI,,q%:q%!4=14:SYS SetI,,q% 4820IF LEFT$($admode%,1) = "S" THEN 4830IF RIGHT$($admode%,2) = "45" THEN 4840PROCkillcurrent("15"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4850ELSE 4860PROCkillcurrent("28"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:q%!4=24:SYS SetI,,q% 4870ENDIF 4880ENDIF 4890WHEN 18:!q%=output%:q%!4=24:q%!8=0:q%!12=1<<21:SYS SetI,,q% 4900WHEN 24:!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:SYS SetI,,q%:PROCkillcurrent(FNdeducemode):SYS Caretpos%,output%,34,,,-1,LEN($oldmode%) 4910WHEN 34:IF moved% SYS Caretpos%,output%,q%!4,q%!8,q%!12,q%!16,q%!20 4920WHEN 19:IF moved% SYS Caretpos%,output%,q%!4,q%!8,q%!12,q%!16,q%!20 4930ENDCASE 4940IFFNgeticonstate(output%,18) $admode%=FNdeducemode 4950!q%=output%:q%!4=20:q%!8=0:q%!12=0:SYS SetI,,q% 4960PROCshowscaletofit 4970WHEN save%:CASE icon% OF 4980WHEN 2:PROCsavesprite 4990ENDCASE 5000WHEN -2:IFsprite% PROCgetw(pic%):PROCopen_window(pic%,x0%,y0%,x1%,y1%,scx%,scy%,-1) 5010WHEN jpego%:IF dest%=1 THEN 5020SYS Getcaret%,,q% 5030dest%=0:PROCdomenu(101,m$(10)+">infow%,"+m$(11)+">scalew%,"+m$(12)+">proc%,"+m$(13)+">output%:dest%,"+m$(27)+">jpego%:1-dest%,"+m$(9)+","+m$(14)+":fast%AND1,"+m$(15)+","+m$(16),m$(20)) 5040IF icon%=5 SYS Caretpos%,jpego%,q%!4,q%!8,q%!12,q%!16,q%!20 5050ENDIF 5060CASE icon% OF 5070WHEN 3:IF b%AND4 THEN$adjpegq%=STR$(VAL$adjpegq%-1) ELSE$adjpegq%=STR$(VAL$adjpegq%+1) 5080IF VAL$adjpegq%<0 $adjpegq%="0" 5090IF VAL$adjpegq%>100 $adjpegq%="100" 5100!q%=jpego%:q%!4=5:q%!8=0:q%!12=0:SYS SetI,,q% 5110SYS Caretpos%,jpego%,5,,,-1,LEN$adjpegq% 5120WHEN 4:IF b%AND4 THEN$adjpegq%=STR$(VAL$adjpegq%+1) ELSE$adjpegq%=STR$(VAL$adjpegq%-1) 5130IF VAL$adjpegq%<0 $adjpegq%="0" 5140IF VAL$adjpegq%>100 $adjpegq%="100" 5150!q%=jpego%:q%!4=5:q%!8=0:q%!12=0:SYS SetI,,q% 5160SYS Caretpos%,jpego%,5,,,-1,LEN$adjpegq% 5170WHEN 5 5180ENDCASE 5190ENDCASE 5200ENDIF 5210IFb%AND&50 THEN 5220CASE handle% OF 5230WHEN save%:CASE icon% OF 5240WHEN 0:PROCgetw(save%) 5250!q%=save%:q%!4=0:SYS GetI,,q% 5260!q%=save%:q%!4=5:q%!8+=bx%:q%!12+=by%:q%!16+=bx%:q%!20+=by% 5270q%!24=0:q%!28=0:q%!32=&7FFFFFFF:q%!36=&7FFFFFFF 5280t$="file_ff9":IFjpegsave% t$="file_c85" 5290IFdstart% SYS dstart%,%11000101,1,t$,q%+8,q%+24 ELSESYS "Wimp_DragBox",,q% 5300ENDCASE 5310ENDCASE 5320ENDIF 5330ENDPROC 5350DEF PROCdozoom(s%,a%) 5360IFs%=0 THEN 5370$z%(0)=STR$(VAL$z%(0)+a%):IF$z%(0)="0" $z%(0)="1" 5380ELSE 5390$z%(1)=STR$(VAL$z%(1)+a%):IF$z%(1)="0" $z%(1)="1" 5400ENDIF 5410!q%=zoom%:q%!4=4+s%:q%!8=0:q%!12=0:SYS SetI,,q% 5420!q%=pic%:SYS GetW,,q%:f%=q%!28:SYS &400c3,,q% 5430pic%=FNcreate_window(x,y,F$) 5440PROCpopup(pic%,f%) 5450ENDPROC 5470DEF PROCdomenu(handle%,menu$,menutitle$) 5480menuhandle%=handle% 5490menuptr%=buffer%:indirect%=idata% 5500i%=0 5510menuptr%!20=44 5520$menuptr%=menutitle$ 5530menuptr%?12=7:menuptr%?13=2:menuptr%?14=7:menuptr%?15=0 5540menuptr%!16=200:menuptr%!24=0 5550menuptr%+=28 5560REPEAT i1%=i%+1:i%=INSTR(menu$+",",",",i1%) 5570item$=MID$(menu$,i1%,i%-i1%):PROCmenuitem(item$):UNTIL item$="" 5580menuptr%!-24=(menuptr%!-24)OR&80 5590IFhandle%=101 SYS CrMenu,,buffer%,mousex%-64,96+9*44 ELSESYS CrMenu,,buffer%,mousex%-32,mousey%+16 5600ENDPROC 5620DEF PROCmenuitem(text$) 5630IF text$="" ENDPROC 5640flg%=0:submenu%=-1:I%=INSTR(text$,":"):IFI%THEN 5650flg%=EVALMID$(text$,I%+1):text$=LEFT$(text$,I%-1) 5660ENDIF 5670I%=INSTR(text$,">"):IFI%THEN 5680submenu%=EVALMID$(text$,I%+1):text$=LEFT$(text$,I%-1) 5690ENDIF 5700menuptr%!0=flg% 5710menuptr%!4=submenu% 5720IF(text$=m$(9)AND(F$="" OR F$="SpriteFile" OR F$="JPEGImage")) OR (text$=m$(14)ANDvram%) THEN 5730menuptr%!8=&07400021 5740ELSE 5750menuptr%!8=&07000021 5760ENDIF 5770IFLENtext$*16+8>buffer%!16 buffer%!16=LENtext$*16+8 5780IFLENtext$>12 THEN 5790menuptr%!8=menuptr%!8 OR 256:menuptr%!20=LENtext$+1:menuptr%!16=0 5800menuptr%!12=indirect%:$indirect%=text$:indirect%+=LENtext$+2 5810ELSE 5820$(menuptr%+12)=text$ 5830ENDIF 5840menuptr%+=24 5850ENDPROC 5870DEF PROCmenuselect(menus%) 5880SYS GetP,,paltemp%:adjust%=paltemp%!8 AND 1 5890SYS DcMenu,,buffer%,menus%,STRING$(200," ")TO,,,a$ 5900IF a$="" THENENDPROC 5910CASE menuhandle% OF 5920WHEN pic% 5930CASE a$ OF 5940WHEN m$(9):PROCcallFSI 5950ENDCASE 5960WHEN 101 5970CASE a$ OF 5980WHEN m$(14):fast%=NOTfast% 5990WHEN m$(27):dest%=0 6000WHEN m$(13):dest%=1 6010WHEN m$(9):PROCcallFSI 6020WHEN m$(15) 6030statescale%=0:FORI%=0TO9:statescale%+=FNgeticonstate(scalew%,I%)<<I%:NEXT 6040FORI%=10TO13:statescale%+=FNgeticonstate(scalew%,I%+6)<<I%:NEXT 6050stateproc%=0:FORI%=0TO7:stateproc%+=FNgeticonstate(proc%,I%)<<I%:NEXT 6060stateoutput%=0:FORI%=0TO26:stateoutput%+=FNgeticonstate(output%,I%)<<I%:NEXT 6070statejpeg%=0:FORI%=0TO3:statejpeg%+=FNgeticonstate(jpego%,I%)<<I%:NEXT 6080A%=OPENOUT"<ChangeFSI$Dir>.Choices" 6090PRINT#A%,fast%,dest%,statescale%,stateproc%,stateoutput%,statejpeg%,$adjpegq%,$oldmode% 6100PRINT#A%,$p%(0),FNlocale_convert($p%(1),decimal_point$,"."),$p%(2),$p%(3),$admode%,$adspcl% 6110PRINT#A%,$s%(0),$s%(1),$s%(2),$s%(3) 6120CLOSE#A% 6130WHEN m$(16):PROCcheckandfinish 6140ENDCASE 6150ENDCASE 6160IFadjust% PROCcheckmouse(0,0,2,rmenuhandle%,0,0) 6170ENDPROC 6190DEF FNcreate_window(x,y,title$) 6200x=x*VAL$z%(0)DIVVAL$z%(1):y=y*VAL$z%(0)DIVVAL$z%(1) 6210!z%=0:z%!4=-y:z%!8=x:z%!12=0 6220z%!40=0:z%!44=-y:z%!48=x:z%!52=0 6230IFx<128 OR y<128 z%?35=0 ELSEz%?35=255 6240$adtitle%="":SYS CreateW,,z% TO handle% 6250$adtitle%=title$ 6260=handle% 6280DEF PROCpopup(handle%,f%) 6290SYS "OS_ReadModeVariable",-1,4 TO ,,modexshift% 6300SYS "OS_ReadModeVariable",-1,5 TO ,,modeyshift% 6310SYS "OS_ReadModeVariable",-1,11 TO ,,rightscr% 6320SYS "OS_ReadModeVariable",-1,12 TO ,,topscr% 6330rightscr%=rightscr%<<modexshift%:topscr%=topscr%<<modeyshift% 6340PROCgetw(handle%) 6350xo%=rightscr%/2-(x0%+x1%)/2:yo%=topscr%/2-(y0%+y1%)/2 6360PROCopen_window(handle%,x0%+xo%,y0%+yo%,x1%+xo%,y1%+yo%,scx%,scy%,f%) 6370ENDPROC 6390DEF PROCopen_window(handle%,x0%,y0%,x1%,y1%,scx%,scy%,bhandle%) 6400IFhandle%=-1THENENDPROC 6410q%!0=handle%:q%!28=bhandle% 6420q%!4=x0%:q%!8=y0%:q%!12=x1%:q%!16=y1% 6430q%!20=scx%:q%!24=scy% 6440SYS OpenW,,q% 6450ENDPROC 6470DEF PROCgetw(handle%) 6480!q%=handle%:SYS GetW,,q% 6490PROCinfo(q%+4):bhandle%=q%!28:flags%=q%!32 6500ENDPROC 6520DEF PROCinfo(q%) 6530x0%=!q%:y0%=q%!4:x1%=q%!8:y1%=q%!12:scx%=q%!16:scy%=q%!20 6540bx%=x0%-scx%:by%=y1%-scy% 6550ENDPROC 6570DEF PROCredraw_window(handle%) 6580IF handle%=pic% THEN 6590!factors%=!ifactors%*VAL$z%(0):factors%!4=ifactors%!4*VAL$z%(0) 6600factors%!8=ifactors%!8*VAL$z%(1):factors%!12=ifactors%!12*VAL$z%(1) 6610PROCreduce(!factors%,factors%!8):PROCreduce(factors%!4,factors%!12) 6620!q%=handle% 6630SYS RedrawW,,q% TO more% 6640PROCinfo(q%+4):by%=by%-INT(y*VAL$z%(0)DIVVAL$z%(1)) 6650WHILE more% 6660IFjpegsave% THEN 6670IFjpegpaint% SYS jpegpaint%,sar%,bx%,by%,factors%,jpegsize%,1 TO;V%:IF(V%AND1)=0 ELSECLG 6680ELSE 6690SYS spopx%,&134,sar%,n$,bx%,by%,,factors%,spx% 6700ENDIF 6710SYS GetR%,0,q% TO more% 6720ENDWHILE 6730ENDIF 6740ENDPROC 6760DEF FNgeticonstate(handle%,icon%) 6770!q%=handle%:q%!4=icon%:SYS GetI,,q% 6780=q%!24>>21 AND 1 6800DEF PROCgetmodeinfo 6810IFjpegsave% THEN 6820SYS&35,-1,4 TO,,nx:SYS&35,-1,5 TO,,ny 6830!ifactors%=1:ifactors%!4=1:ifactors%!8=nx:ifactors%!12=ny 6840ENDPROC 6850ENDIF 6860SYS"XWimp_ReadPixTrans",&100,sar%,n$,,,,ifactors%,pixtrans% 6870SYS spopx%,&118,sar%,n$ TO ,,sptr% 6880IF sptr%!32=44 THEN 6890palptr%=0 6900ELSE 6910FOR grab%=0 TO 2048-8 STEP 8:paltemp%!(grab%>>1)=sptr%!(grab%+44):NEXT 6920palptr%=paltemp% 6930ENDIF 6940FORQ%=0TO255:pixtrans%?Q%=Q%:NEXT 6950IFsptr%!32=44+2048 THEN 6960FORQ%=0TO255:SYSctran%,palptr%!(Q%<<2)TOpixtrans%?Q%:NEXT 6970ELSE 6980SYS "ColourTrans_SelectTable",m,palptr%,-1,-1,pixtrans% 6990ENDIF 7000spx%=-1:FORQ%=0TO255:IFpixtrans%?Q%<>Q% spx%=pixtrans% 7010NEXT 7020ENDPROC 7040DEF FNdeducemode 7050LOCAL m,x,y 7060IFFNgeticonstate(output%,21) THEN 7070IFFNgeticonstate(output%,17) THEN="JPEG8" ELSE="JPEG24" 7080ELSE 7090IFFNgeticonstate(output%,18) THEN 7100SYS &6,135 TO ,,m 7120SYS&35,-1,9 TO,,m 7130IFm>3 THEN 7140SYS&35,-1,4 TO,,x:SYS&35,-1,5 TO,,y 7150x=180/(2^x):y=180/(2^y) 7160="S"+STR$(2^m)+","+STR$x+","+STR$y 7170ELSE 7180=STR$MODE 7190ENDIF 7200ELSE 7210IF FNgeticonstate(output%,24) THEN 7220=$oldmode% 7230ELSE 7240=$admode% 7250ENDIF 7260ENDIF 7270ENDIF 7290DEF PROCshowscaletofit 7300LOCAL m,x,y 7310$admode%=FNdeducemode 7320CASE ?admode% OF 7330WHEN ASC"S" 7340IFVALMID$($admode%,5)>VALMID$($admode%,8) x=6 ELSEx=0 7350IFVALMID$($admode%,2)>16 x+=5 ELSEx+=4 7360SYS&35,-1,11 TO,,tofitx:SYS&35,-1,12 TO,,tofity 7370WHEN ASC"J" 7380SYS&35,-1,11 TO,,tofitx:SYS&35,-1,12 TO,,tofity 7400x=12 7410OTHERWISE 7420m=VAL$admode% 7430SYS&35,m,11 TO,,tofitx:SYS&35,m,12 TO,,tofity 7440SYS&35,m,4 TO,,x:SYS&35,m,5 TO,,y:IFy>x x=6 ELSEx=0 7450SYS&35,m,9 TO,,y:x+=y 7460ENDCASE 7470tofitx+=1:tofity+=1:$adscale%=m$(17)+STR$tofitx+m$(18)+STR$tofity 7480q%!12=1<<21:!q%=output%:FORI%=0TO11:IFI%=x q%!8=1<<21 ELSEq%!8=0 7490q%!4=I%+3:SYS SetI,,q%:NEXT:IFx=12 q%!8=0:q%!4=24:SYS SetI,,q% 7500ENDPROC 7520DEF PROCkillcurrent(m$) 7530q%!12=1<<21:!q%=output%:q%!8=0 7540q%!4=20:SYS SetI,,q% 7550$admode%=m$ 7570ENDPROC 7590DEFFNZS(I%)LOCALA$:REPEATA$+=CHR$?I%:I%+=1:UNTIL?I%<14:=A$ 7610DEF PROCerrorbox 7620SYS Drag,,-1:!buffer%=ERR:$(buffer%+4)=REPORT$+" (code "+STR$ERL+")"+CHR$0 7630SYS "Wimp_ReportError",buffer%,%11,m$(20) TO ,A% 7640IFA%=2 PROCremovearea:SYS "Wimp_CloseDown":END 7650ENDPROC 7880DEF FNChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,RETURN ram%,fast%) 7890LOCAL A$(),r%(),g%(),b%(),rpal%(),gpal%(),bpal%(),table%(),cl%(),xl%(),xl2%() 7900LOCAL xp%(),rm%(),rm1%(),rm2%(),vals%(),nl%(),A%(),B%(),new%(),st%(),jpq%(),m 7910WHILELEFT$(A$,1)<>" "ANDLENA$<>0 A$=MID$(A$,2):ENDWHILE 7920WHILELEFT$(A$,1)=" " A$=MID$(A$,2):ENDWHILE 7930WHILERIGHT$(A$,1)=" " A$=LEFT$(A$):ENDWHILE 7940IFFNuc(LEFT$(A$,5))="-QUIT" THEN 7950A$=MID$(A$,7):WHILELEFT$(A$,1)<>" "ANDLENA$<>0 A$=MID$(A$,2):ENDWHILE 7960WHILELEFT$(A$,1)=" " A$=MID$(A$,2):ENDWHILE 7970ENDIF 7980DIM A$(100):ARG%=0:B%=INSTR(A$," ") 7990WHILE B%<>0 8000ARG%+=1:A$(ARG%)=LEFT$(A$,B%-1):A$=MID$(A$,B%+1) 8010WHILE LEFT$(A$,1)=" ":A$=MID$(A$,2):ENDWHILE 8020B%=INSTR(A$," ") 8030ENDWHILE 8040IFA$<>"" ARG%+=1:A$(ARG%)=A$ 8050invert%=FALSE:range%=FALSE:sharpen%=FALSE:info%=FALSE:cache%=FALSE:cacheareanumber%=0:dither%=TRUE:black%=FALSE 8060hist%=FALSE:equal%=FALSE:vflip%=FALSE:hflip%=FALSE:scale%=TRUE:scaleo%=TRUE:scrapf%=FALSE 8070gamma=1:rotate%=FALSE:max%=20000000:bright%=15:lock%=FALSE 8080rwt=.299:gwt=.587:bwt=.114 8090IFARG%<3 THEN 8100PRINT"ChangeFSI interactive input (read FSIinfo for command line details)" 8110INPUT"Source file: "s$,"Destination file: "f$,"Output mode: "m$ 8120INPUT"(X)Scale (e.g. 2:1): "xs$:INPUT"Y Scale: "ys$ 8130INPUT"Info on input picture?"a$:IFFNuc(LEFT$(a$,1))="Y" info%=TRUE 8140INPUT"Invert picture colours?"a$:IFFNuc(LEFT$(a$,1))="Y" invert%=TRUE 8150INPUT"Compute histogram of input?"a$:IFFNuc(LEFT$(a$,1))="Y" hist%=TRUE 8160INPUT"Apply histogram equalisation?"a$:IFFNuc(LEFT$(a$,1))="Y" equal%=TRUE 8170INPUT"Expand input dynamic range?"a$:IFFNuc(LEFT$(a$,1))="Y" range%=TRUE:equal%=FALSE 8180INPUT"Sharpen picture by (e.g. 12 for harsh, 24 for soft) "a$ 8190IFa$<>"" sharpen%=VALa$ 8200INPUT"Rotate?"a$:IFFNuc(LEFT$(a$,1))="Y" rotate%=1 8210scale%=FALSE:scaleo%=FALSE:fast%=FALSE 8220ELSE 8230REPEAT A%=ARG% 8240IFFNuc(A$(ARG%))="-INFO" info%=TRUE:A$(ARG%)="":ARG%-=1 8250IFFNuc(A$(ARG%))="-HIST" hist%=TRUE:A$(ARG%)="":ARG%-=1 8260IFFNuc(A$(ARG%))="-LOCK" lock%=TRUE:A$(ARG%)="":ARG%-=1 8270IFFNuc(A$(ARG%))="-EQUAL" equal%=TRUE:range%=FALSE:A$(ARG%)="":ARG%-=1 8280IFFNuc(A$(ARG%))="-RANGE" range%=TRUE:equal%=FALSE:A$(ARG%)="":ARG%-=1 8290IFFNuc(A$(ARG%))="-INVERT" invert%=TRUE:A$(ARG%)="":ARG%-=1 8300IFFNuc(A$(ARG%))="-NOSCALE" scale%=FALSE:scaleo%=FALSE:A$(ARG%)="":ARG%-=1 8310IFFNuc(A$(ARG%))="-NOSIZE" scale%=FALSE:A$(ARG%)="":ARG%-=1 8320IFFNuc(A$(ARG%))="-NODITHER" dither%=FALSE:A$(ARG%)="":ARG%-=1 8330IFFNuc(A$(ARG%))="-BRIGHTEN" bright%=16:A$(ARG%)="":ARG%-=1 8340IFFNuc(A$(ARG%))="-ROTATE" rotate%=1:A$(ARG%)="":ARG%-=1 8350IFFNuc(A$(ARG%))="-ROTATE-" rotate%=-1:A$(ARG%)="":ARG%-=1 8360IFFNuc(A$(ARG%))="-VFLIP" vflip%=TRUE:A$(ARG%)="":ARG%-=1 8370IFFNuc(A$(ARG%))="-HFLIP" hflip%=TRUE:A$(ARG%)="":ARG%-=1 8380IFFNuc(A$(ARG%))="-NOMODE" fast%=FALSE:A$(ARG%)="":ARG%-=1 8390IFFNuc(LEFT$(A$(ARG%),6))="-BLACK" THEN 8400black%=32:IFLENA$(ARG%)>6 black%=VALMID$(A$(ARG%),7):IFblack%>128 black%=128 8410A$(ARG%)="":ARG%-=1 8420ENDIF 8430IFFNuc(LEFT$(A$(ARG%),6))="-GAMMA" THEN 8440gamma=2.2:IFLENA$(ARG%)>6 gamma=VALMID$(A$(ARG%),7) 8450A$(ARG%)="":ARG%-=1 8460ENDIF 8470IFFNuc(LEFT$(A$(ARG%),8))="-SHARPEN" THEN 8480sharpen%=24:IFLENA$(ARG%)>8 sharpen%=VALMID$(A$(ARG%),9) 8490A$(ARG%)="":ARG%-=1 8500ENDIF 8510IFFNuc(LEFT$(A$(ARG%),7))="-SMOOTH" THEN 8520sharpen%=-1:IFLENA$(ARG%)>7 sharpen%=-VALMID$(A$(ARG%),8) 8530A$(ARG%)="":ARG%-=1:IFsharpen%<-23 sharpen%=-23 8540ENDIF 8550IFFNuc(LEFT$(A$(ARG%),4))="-RED" rwt=VALMID$(A$(ARG%),5):A$(ARG%)="":ARG%-=1 8560IFFNuc(LEFT$(A$(ARG%),6))="-GREEN" gwt=VALMID$(A$(ARG%),7):A$(ARG%)="":ARG%-=1 8570IFFNuc(LEFT$(A$(ARG%),5))="-BLUE" bwt=VALMID$(A$(ARG%),6):A$(ARG%)="":ARG%-=1 8580IFFNuc(LEFT$(A$(ARG%),4))="-MAX" THEN 8590max%=VALMID$(A$(ARG%),5):IFINSTR(A$(ARG%),"K")ORINSTR(A$(ARG%),"k") max%=max%*1024 8600A$(ARG%)="":ARG%-=1 8610ENDIF 8620UNTILA%=ARG% 8630s$=A$(1):f$=A$(2):m$=A$(3):xs$=A$(4):ys$=A$(5) 8640ENDIF 8650IFokinfo% ELSEinfo%=FALSE 8660IFworkspace%>=0 THEN 8670flex%=FALSE 8680ELSE 8690IFworklimit%=0 THENflex%=FALSE ELSEflex%=TRUE:nextlocation%=worklimit% 8700ENDIF 8710pnm$=FNuc(m$):CASE LEFT$(pnm$+",",3) OF 8720WHEN"AIM":m=-1:m$="" 8730WHEN"P1,","P4,":m=-2:m$="":spm=18 8740WHEN"P2,","P5,":m=-2:m$="T":spm=20 8750WHEN"P3,","P6,":m=-4:pnm$=LEFT$(pnm$,2):p6bits=8:I%=VALMID$(m$,4):m$="" 8760IFI%>0IFI%<8 p6bits=I% 8770WHEN"P15":m=-3:m$="" 8780WHEN"C15":m=-5:m$="" 8790WHEN"IRL":m=-4:m$="":p6bits=8 8800WHEN"S16":m=-6:m$="" 8810WHEN"S24":m=-7:m$="":p6bits=8 8820WHEN"S32":m=-8:m$="":p6bits=8 8830WHEN"JPE":m$="":p6bits=8:IFLEFT$(pnm$,8)="JPEGMONO" m=-9:jpegquality%=VALMID$(pnm$,9) ELSEm=-10:jpegquality%=VALMID$(pnm$,5) 8840OTHERWISE:m=VALm$:spm=m:m$=FNuc(RIGHT$(m$,1)):IFINSTR("CDRT",m$)=0 m$="" 8850ENDCASE 8860IFxs$="" OR LEFT$(xs$,1)="-" THEN 8870xmul%=1:xdiv%=1:ymul%=1:ydiv%=1 8880ELSE 8890IFys$="" ys$=xs$ 8900xmul%=VALxs$:xdiv%=VALMID$(xs$,INSTR(xs$,":")+1) 8910ymul%=VALys$:ydiv%=VALMID$(ys$,INSTR(ys$,":")+1) 8920ENDIF 8930flag=-1:SYS8,5,s$ TO r0,,r2:dir=r0=2 8940IFdir THEN 8950panic=TRUE:SYS8,5,s$+".raw" TO r0,,r2:IFr0=1 s$+=".raw":dir=FALSE:panic=FALSE 8960IFpanic SYS8,5,s$+".red" TO r0,,r2:IFr0=1 panic=FALSE 8970IFpanic ERROR 42,"Directory given" 8980ENDIF 8990ftype=r2>>8 AND &FFF:bits=28:F=2^bits:c%=0:cc%=0:ccc%=0:o%=0 9000IFdir THEN 9010c%=OPENIN(s$+".red"):IFc%=0 ERROR 42,"Red file "+s$+".red not found" 9020cc%=OPENIN(s$+".green"):IFcc%=0 ERROR42,"Green file "+s$+".green not found" 9030ccc%=OPENIN(s$+".blue"):IFccc%=0 ERROR42,"Blue file "+s$+".blue not found" 9040ELSE 9050c%=OPENINs$:IFc%=0 ERROR 42,"File "+s$+" not found" 9060ENDIF 9070LOCAL ERROR 9080ON ERROR LOCAL RESTORE ERROR:TRACE OFF:PROCclose:ERROR ERR,REPORT$ 9110colourindex=255 9120SYS&66f4d TO;pcd% 9130CASE ftype OF 9140WHEN &FF9:flag=0 9150IFINSTR("."+FNuc(s$),".HIP.")ORINSTR(FNuc(s$),":HIP.") THEN 9160flag=300:I%=INSTR(FNuc(s$),"HIP.") 9170MID$(s$,I%)="LOP.":cc%=OPENINs$:IFcc%=0 ERROR42,"Can't find Lop file "+s$ 9180ENDIF 9190WHEN &FF0:PTR#c%=0:S$="":FORI%=1TO4:S$+=CHR$BGET#c%:NEXT 9200IFS$="II*"+CHR$0 flag=1500:bigendian=FALSE 9210IFS$="MM"+CHR$0+"*" flag=1500:bigendian=TRUE 9220WHEN &DFA:flag=800:IFdir flag=801 9230WHEN &DE2:flag=1000 9240WHEN &CBE:flag=3800 9250WHEN &BE8:IF(pcd%AND1)=0 flag=3600 9260WHEN &7A0:flag=1200 9270WHEN &69d:flag=2000 9280WHEN &699:flag=700 9290WHEN &698:flag=100 9300WHEN &697:flag=1900 9310WHEN &691:flag=2600 9320WHEN &690:flag=2500 9330WHEN &666:flag=666 9340WHEN &601:flag=3000 9350WHEN &371:flag=3100 9360WHEN &300:flag=1300:IFdir flag=1301 9370WHEN 4:flag=900:IFdir flag=901 9380WHEN 6:flag=950 9390ENDCASE 9400IFflag=-1 THEN 9410PTR#c%=0:S$="":FORI%=1TO22:S$+=CHR$BGET#c%:NEXT 9420IFLEFT$(S$,7)="FSIfile" flag=2100 9430IFflag=-1 IFLEFT$(S$,8)="SIMPLE " flag=2800 9440IFflag=-1 IFFNuc(LEFT$(S$,8))="MERCSOFT"ORFNuc(LEFT$(S$,8))="SNAPSHOT"flag=902 9450IFflag=-1 IFFNuc(LEFT$(S$,8))="MERCSOF1" flag=903 9460IFflag=-1 IFFNuc(LEFT$(S$,13))="IRLAM YUV 411" flag=2250 9470IFflag=-1 IFLEFT$(S$,5)="Irlam" flag=2200 9480IFflag=-1 IFLEFT$(S$,2)="BM" flag=2400:riffoff%=0 9490IFflag=-1 IFLEFT$(S$,4)="RIFF" AND MID$(S$,9,8)="RDIBdata" AND MID$(S$,21,2)="BM" flag=2400:riffoff%=20 9500IFflag=-1 IFLEFT$(S$,4)="GIF8" flag=500 9510IFflag=-1 IFLEFT$(S$,5)="AV_VO" flag=600 9520IFflag=-1 IFLEFT$(S$,4)=CHR$&59+CHR$&A6+CHR$&6A+CHR$&95 flag=1100 9530IFflag=-1 IFLEFT$(S$,4)=CHR$0+CHR$1+CHR$0+CHR$8 flag=1400 9540IFflag=-1 IFLEFT$(S$,4)=CHR$0+CHR$1+CHR$0+CHR$1 flag=2900 9550IFflag=-1 IFLEFT$(S$,4)="RIX3" flag=2700 9560IFflag=-1 IFLEFT$(S$,4)="II*"+CHR$0 flag=1500:bigendian=FALSE 9570IFflag=-1 IFLEFT$(S$,4)="MM"+CHR$0+"*" flag=1500:bigendian=TRUE 9580IFflag=-1 IFLEFT$(S$,2)=CHR$&52+CHR$&CC flag=2300 9590IFflag=-1 IFLEFT$(S$,2)="P4"ORLEFT$(S$,2)="P5"ORLEFT$(S$,2)="P6" flag=3300:info$="" 9600IFflag=-1 IFLEFT$(S$,3)="P15" flag=3400 9610IFflag=-1 IFLEFT$(S$,3)="PIC" flag=3500 9620IFflag=-1 IFLEFT$(S$,3)="T-I" flag=3800 9630IFflag=-1 IFFNuc(LEFT$(S$,3))="P13" flag=3450 9640IFflag=-1 IFLEFT$(S$,4)="FORM" IFMID$(S$,9,4)="ILBM" flag=1600 9650IFflag=-1 IFLEFT$(S$,8)="ALPIAR12" flag=3900:colourindex=4095 9660IFflag=-1 IFLEFT$(S$,8)="ALPIAR16" flag=3905:colourindex=65535 9670IFflag=-1 THEN 9680IFMID$(S$,7,4)="JFIF" OR ftype=&C85 THEN 9690jpegblk%=FNdim(20):PROCcachesize(jpegblk%) 9700IFcache%<EXT#c% THEN 9710CLOSE#c%:c%=0:X%=OPENIN"Run:djpeg" 9720IFX% THEN 9730CLOSE#X%:PROCsubtask("djpeg "+s$+" <Wimp$Scrap>") 9740ELSE 9750SYS"XOS_CLI","djpeg "+s$+" <Wimp$Scrap>" TO ;V 9760IFV AND1 THEN 9770PROCsubtask("<ChangeFSI$Dir>.djpeg "+s$+" <Wimp$Scrap>") 9780ENDIF 9790ENDIF 9800c%=OPENIN"<Wimp$Scrap>":IFc%=0 THEN=100 9810scrapf%=TRUE:flag=3300:info$="JPEG (JFIF) file converted to " 9820ELSE 9830flag=3700 9840ENDIF 9850ENDIF 9860ENDIF 9870IFflag=-1 THEN 9880IFLEFT$(S$,5)="btpc " THEN 9890CLOSE#c%:c%=0:PROCsubtask("<ChangeFSI$Dir>.btpc "+s$+" <Wimp$Scrap>") 9900c%=OPENIN"<Wimp$Scrap>":IFc%=0 THEN=100 9910scrapf%=TRUE:flag=3300:info$="BTPC file converted to " 9920ENDIF 9930ENDIF 9940IFflag=-1 THEN 9950PTR#c%=&10:S$="":FORI%=1TO9:S$+=CHR$BGET#c%:NEXT 9960IFS$="MILLIPEDE" flag=200 9970ENDIF 9980IFflag=-1 THEN 9990PTR#c%=&41:S$="":FORI%=1TO8:S$+=CHR$BGET#c%:NEXT 10000IFLEFT$(S$,4)="PNTG" flag=1800:st%=&280 10010ENDIF 10020IFflag=-1 THEN 10030PTR#c%=196:S$="":FORI%=1TO8:S$+=CHR$BGET#c%:NEXT 10040IFLEFT$(S$,4)="PNTG" flag=1800:st%=&2e2 10050ENDIF 10060IFflag=-1 THEN 10070PTR#c%=522:S$="":FORI%=1TO8:S$+=CHR$BGET#c%:NEXT 10080IFS$=CHR$0+CHR$&11+CHR$2+CHR$&ff+CHR$&c+CHR$0+CHR$&ff+CHR$&fe flag=1850 10090ENDIF 10100IFflag=-1 THEN 10110PTR#c%=0:IFBGET#c%=10 THEN 10120C%=BGET#c%:IFC%<6 AND C%<>1 ANDBGET#c%=1 flag=1900 10130ENDIF 10140ENDIF 10150IFflag=-1 IFINSTR("."+FNuc(s$),".PCX.")ORINSTR(FNuc(s$),":PCX.")ORRIGHT$(s$,4)="/PCX" flag=1900 10160IFflag=-1 IFINSTR("."+FNuc(s$),".IMAGE.")ORINSTR(FNuc(s$),":IMAGE.") flag=400 10170IFflag=-1 IFFNuc(RIGHT$(s$,4))=".RAW" flag=100 10180IFflag=-1 IFFNuc(RIGHT$(s$,3))="TGA" flag=2000 10190IFflag=-1 IFFNuc(RIGHT$(s$,3))="VDA" flag=2000 10200IFflag=-1 IFINSTR("."+FNuc(s$),".PIC.")ORINSTR(FNuc(s$),":PIC.") flag=700 10210IFflag=-1 IFINSTR("."+FNuc(s$),".IMG.")ORINSTR(FNuc(s$),":IMG.")ORRIGHT$(s$,4)="/IMG" flag=1400 10220IFflag=-1 IFINSTR("."+FNuc(s$),".DSP.")ORINSTR(FNuc(s$),":DSP.")ORRIGHT$(s$,4)="/DSP" flag=1700 10230IFflag=-1 IFFNuc(RIGHT$(s$,4))="/RGB" flag=3200 10240IFflag=-1 AND(FNuc(RIGHT$(s$,4))="/PCD"ORftype=&be8)AND((pcd%AND1)=1) THEN 10250CLOSE#c%:c%=0:PROCsubtask("<ChangeFSI$Dir>.hpcdtoppm -3 -a "+s$+" <Wimp$Scrap> { > <ChangeFSI$Dir>.pcdtemp }") 10260c%=OPENIN"<Wimp$Scrap>":scrapf%=TRUE:flag=3300:info$="PhotoCD file converted to " 10270ENDIF 10280ENDIF 10290IFflag=-1 PROCclose:ERROR 42,"Sorry: format not recognised - please try again or contact your supplier" 10300step24=1:input=8:ham=0:planar%=0:bigendianbits=FALSE:r$="FN"+STR$flag 10310compression=0:hpredict%=1:striprows%=-1:cachebytes%=FALSE 10320IFxdiv%=0 AND ydiv%=0 scale%=FALSE 10330DIM r%(colourindex) 10340DIM g%(colourindex),b%(colourindex) 10350CASE flag OF 10360WHEN 0 10370quant%=4:PTR#c%=4:F%=FNW+&1C:PTR#c%=F%:st%=FNW+F%-&20:K%=FNW+F%-&20 10380sm=FNW:IFsm<256 THEN 10390SYS53,sm,3 TO ,,I% 10400CASE I% OF 10410WHEN 1:IFst%=F%+12 PROCdefpal2 ELSEPROCipal(2) 10420PTR#c%=F%-16:sx%=(FNW+1)*32:rowbytes%=sx%>>3:input=1 10430sy%=FNW+1:I%=FNW:sx%-=31-FNW 10440WHEN 3:IFst%=F%+12 PROCdefpal4 ELSEPROCipal(4) 10450PTR#c%=F%-16:sx%=(FNW+1)*16:rowbytes%=sx%>>2:input=2 10460sy%=FNW+1:I%=FNW:sx%-=(31-FNW)DIV2 10470WHEN 15:IFst%=F%+12 PROCdefpal16 ELSEPROCipal(16) 10480PTR#c%=F%-16:sx%=(FNW+1)*8:rowbytes%=sx%>>1:input=4 10490sy%=FNW+1:I%=FNW:sx%-=(31-FNW)DIV4 10500WHEN 63,255:IFst%=F%+12 THEN 10510PROCdefpal 10520ELSE 10530IFK%>st% K%=st% 10540IFK%-12-F%=2048 ORI%=255 THEN 10550PTR#c%=&38 10560FORC%=0TO255:D%=BGET#c% 10570r%(C%)=BGET#c%/255*F:g%(C%)=BGET#c%/255*F:b%(C%)=BGET#c%/255*F 10580D%=FNW:NEXT 10590ELSE 10600PROCipal63 10610ENDIF 10620ENDIF 10630PTR#c%=F%-16:sx%=(FNW+1)*4:rowbytes%=sx%:sy%=FNW+1:I%=FNW:sx%-=(31-FNW)DIV8 10640OTHERWISE ERROR42,"Not understood RISC OS sprite" 10650ENDCASE 10660r$="FN8":SYS53,sm,4 TO ,,nx:SYS53,sm,5 TO ,,ny:nx=1<<nx:ny=1<<ny 10670IFscale% xmul%=xmul%*nx/2:ymul%=ymul%*ny/2 10680info$="RISC OS sprite, mode "+STR$sm+" "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 10690ELSE 10700bpp%=sm>>>27:CASEbpp% OF 10710WHEN 1:bpp%=1:r$="FN8":IFst%=F%+12 PROCdefpal2 ELSEPROCnewropal(2) 10720WHEN 2:bpp%=2:r$="FN8":IFst%=F%+12 PROCdefpal4 ELSEPROCnewropal(4) 10730WHEN 3:bpp%=4:r$="FN8":IFst%=F%+12 PROCdefpal16 ELSEPROCnewropal(16) 10740WHEN 4:bpp%=8:r$="FN8":IFst%=F%+12 PROCdefpal ELSEPROCnewropal(256) 10750WHEN 5:bpp%=16:r$="FN16":IFst%=F%+12 ELSE 10760DIM rpal%(255),gpal%(255):step24=2 10770FORC%=0TO255 10780gpal%(C%)=(C%>>5)<<8 OR (C%AND31) 10790rpal%(C%)=((C%>>2)AND31)<<16 OR (C%AND3)<<11 10800NEXT 10810FORC%=0TO31:r%(C%)=C%/31*F:NEXT:g%()=r%():b%()=r%() 10820WHEN 6:bpp%=32:r$="FN24":IFst%=F%+12 PROCnopal ELSE 10830rbo%=0:gbo%=1:bbo%=2:step24=4 10840WHEN 8:bpp%=24:r$="FN24":IFst%=F%+12 PROCnopal ELSE 10850rbo%=0:gbo%=1:bbo%=2 10860OTHERWISE ERROR42,"Not understood new format RISC OS sprite bpp" 10870ENDCASE 10880nx=(sm>>1) AND&1fff:ny=(sm>>14) AND&1fff 10890IFscale% xdiv%=xdiv%*nx:ydiv%=ydiv%*ny:xmul%=xmul%*90:ymul%=ymul%*90 10900PTR#c%=F%-16:rowbytes%=(FNW+1)*4:sy%=FNW+1:I%=FNW:sx%=(rowbytes%*8-(31-FNW))/bpp%:input=bpp% 10910info$="New RISC OS sprite, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 10920IFbpp%=32 input=24 10930ENDIF 10940PTR#c%=st%:cache%=TRUE 10950WHEN 100 10960quant%=8:PTR#c%=0:sx%=FNHW:sy%=FNHW:PROCnopal:input=24:rowbytes%=sx%*3+2 10970rbo%=2:gbo%=2+sx%:bbo%=2+2*sx%:r$="FN24":cache%=TRUE 10980info$="QRT .raw image, "+STR$sx%+" by "+STR$sy%+" pixels, 24 bits per pixel" 10990WHEN 200 11000quant%=8:PTR#c%=5:sx%=FNHW:sy%=FNHW:sx%=(FNHW-sx%+2)/2:sy%=(FNHW-sy%+2)/2 11010PTR#c%=&1a:cadsoft%=BGET#c%:PTR#c%=&200 11020FORC%=0TO255:r%(C%)=BGET#c%/255*F:NEXT:FORC%=0TO255:g%(C%)=BGET#c%/255*F:NEXT 11030FORC%=0TO255:b%(C%)=BGET#c%/255*F:NEXT 11040PTR#c%=&600:st%=&600:cache%=TRUE:IFcadsoft%=2 THEN 11050rep%=0:r$="FN1100":plbuff%=FNdim(sx%):plbytes%=sx%:cachebytes%=TRUE 11060ELSE 11070r$="FN8":rowbytes%=sx% 11080ENDIF 11090info$="Cadsoft type "+STR$cadsoft%+" image, "+STR$sx%+" by "+STR$sy%+" pixels, 8 bits per pixel" 11100WHEN 300 11110quant%=5:PTR#c%=&2c:st%=FNW+(&38-&2c):PTR#cc%=&2c:stcc%=FNW1(cc%)+(&38-&2c) 11120PTR#c%=&1c:sx%=(FNW+1)*4:sy%=FNW+1:PTR#c%=st%:PTR#cc%=stcc% 11130DIM rpal%(255),gpal%(255):input=16:cache%=TRUE:rowbytes%=sx% 11140FORC%=0TO255 11150rpal%(C%)=C%AND7 OR (C%AND64)<<2 OR (C%AND&38)<<13 11160gpal%(C%)=(C%AND4)<<1ORC%AND16 OR ((C%AND3)<<1OR(C%AND&60)>>2)<<8 OR (C%AND8OR(C%AND128)>>3)<<16 11170NEXT 11180FORC%=0TO31:r%(C%)=C%/31*F:NEXT:g%()=r%():b%()=r%() 11190pbuff%=FNdim(sx%):IFscale% ymul%=ymul%*2 11200info$="ArVis image, "+STR$sx%+" by "+STR$sy%+" pixels, 15 bits per pixel" 11210WHEN 400 11220quant%=8:PTR#c%=0:sx%=FNbeHW:sy%=FNbeHW:X%=FNbeHW:st%=PTR#c%+X%:PTR#c%=st% 11230plbuff%=FNdim(sx%*3):plbytes%=sx%*3:rb%=plbuff%:gb%=plbuff%+1:bb%=plbuff%+2:rbo%=-1 11240PROCnopal:input=24:rep%=0:cachebytes%=TRUE:cache%=TRUE:step24=3 11250info$="RT image. run length encoded image, "+STR$sx%+" by "+STR$sy%+" pixels, 24 bits per pixel" 11260WHEN 500 11270compression=5:PTR#c%=6:GIFsx=FNHW:GIFsy=FNHW 11280GIF=BGET#c%:GIFback=BGET#c%:GIFext=BGET#c%:quant%=(GIF AND 7)+1 11290IFGIF AND &80 THEN 11300FORC%=0TO(1<<quant%)-1 11310r%(C%)=BGET#c%/255*F:g%(C%)=BGET#c%/255*F:b%(C%)=BGET#c%/255*F 11320NEXT 11330ENDIF 11340I%=BGET#c%:WHILE I%=ASC"!" 11360IF BGET#c% 11370REPEAT 11380GIFgcesz=BGET#c%:PTR#c%=PTR#c%+GIFgcesz 11410UNTIL GIFgcesz=0:I%=BGET#c% 11420ENDWHILE 11430IFI%<>ASC"," ERROR 42,"GIF file without , in right place" 11450IFGIFext<>0 AND GIFext<>49 THEN 11460IFGIFext>49 THEN 11480xdiv%=xdiv%*64:xmul%=xmul%*(GIFext+15) 11490ELSE 11500ydiv%=ydiv%*(GIFext+15):ymul%=ymul%*64 11510ENDIF 11520ENDIF 11530GIFleft=FNHW:GIFright=FNHW:sx%=FNHW:sy%=FNHW 11540IFGIFsx<sx% OR GIFsy<sy% THEN 11550IFinfo% THEN 11560PRINT"GIF file with bigger image inside:" 11570PRINT"Screen ";GIFsx"x by "GIFsy"y; image "sx%"x by "sy%"y" 11580INPUT"Continue with monitor's size [Y or y]?"A$ 11590IFA$="Y"ORA$="y" sx%=GIFsx:sy%=GIFsy 11600PRINT"Continuing with ";sx%"x by "sy%"y" 11610ENDIF 11620ENDIF 11630GIF=BGET#c%:IFGIF AND &40 flag=501:r$="FN8" 11640setcodes%=BGET#c%:clearcode%=1<<setcodes%:st%=PTR#c%:cache%=TRUE:cachebytes%=TRUE 11650DIM table%(1<<12):stk%=FNdim(1<<13):buf%=FNdim(280):plbuff%=FNdim(sx%) 11660FORI%=0TOclearcode%-1:table%(I%)=I%:NEXT 11670info$="GIF file, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(quant%) 11680WHEN 600 11690quant%=8:PTR#c%=&5c:FORC%=0TO255 11700r%(C%)=BGET#c%/255*F:g%(C%)=BGET#c%/255*F:b%(C%)=BGET#c%/255*F 11710NEXT 11720PTR#c%=&36e:sy%=FNHW:sx%=FNHW 11730st%=&380:PTR#c%=st%:rowbytes%=sx%:r$="FN8":cache%=TRUE 11740info$=".PIC image, "+STR$sx%+" by "+STR$sy%+" pixels, 8 bits per pixel" 11750WHEN 700 11760quant%=8:PTR#c%=0:a$=GET$#c%:st%=PTR#c% 11770sx%=VALa$:sy%=VAL(MID$(a$,INSTR(a$," "))) 11780PROCnopal:input=24:step24=3:rowbytes%=sx%*3:r$="FN24" 11790rbo%=0:gbo%=1:bbo%=2:cache%=TRUE 11800info$="MTV .pic image, "+STR$sx%+" by "+STR$sy%+" pixels, 24 bits per pixel" 11810WHEN 800 11820sx%=512:sy%=256:IFscale% ymul%=ymul%*2 11830plbuff%=FNdim(sx%):rep%=0:wt%=0:wtsx%=plbuff%+sx% 11840cache%=TRUE:cachebytes%=TRUE 11850FORC%=0TO255:r%(C%)=(C%AND63)/63*F:NEXT:g%()=r%():b%()=r%():quant%=6 11860info$="Watford digitiser picture, 512 by 256 pixels, 6 bits per pixel" 11870WHEN 801 11880sx%=512:sy%=256:input=24:quant%=6:IFscale% ymul%=ymul%*2 11890rep1%=0:wt1%=0:rep2%=0:wt2%=0:rep3%=0:wt3%=0 11900buff%=FNdim(sx%*3):rb%=buff%:gb%=buff%+sx%:bb%=buff%+2*sx% 11910wtsx1%=buff%+sx%:wtsx2%=buff%+2*sx%:wtsx3%=buff%+3*sx% 11920FORC%=0TO255:r%(C%)=(C%AND63)/63*F:NEXT:g%()=r%():b%()=r%() 11930info$="Triple Watford digitiser picture, 512 by 256 pixels, 18 bits per pixel" 11940WHEN 900 11950quant%=8:st%=0:PTR#c%=0:IFEXT#c%=65536 THEN 11960sx%=256:sy%=256:IFscale% ymul%=ymul%*2:xmul%=xmul%*2 11970ELSE 11980sx%=512:sy%=512 11990ENDIF 12000FORC%=0TO255:r%(C%)=C%/255*F:NEXT:g%()=r%():b%()=r%():rowbytes%=sx%:r$="FN8":cache%=TRUE 12010info$="AIM .raw image, 256 by 256 pixels, 8 bits per pixel" 12020WHEN 901 12030quant%=4:IFEXT#c%=65536 THEN 12040sx%=256:sy%=256:IFscale% ymul%=ymul%*2:xmul%=xmul%*2 12050ELSE 12060sx%=512:sy%=512 12070ENDIF 12080buff%=FNdim(sx%*3):rb%=buff%:gb%=buff%+sx%:bb%=buff%+sx%*2 12090FORC%=0TO255:r%(C%)=C%/255*F:NEXT:g%()=r%():b%()=r%() 12100input=24:info$="Hawk V9 Triple image, 256 by 256 pixels, 24 bits per pixel" 12110WHEN 902 12120quant%=4:PTR#c%=8:sx%=FNW:rowbytes%=sx%*3/2:sy%=FNW:st%=20:PTR#c%=20 12130IFscale% ymul%=ymul%*2 12140plbuff%=FNdim(sx%*3):rb%=plbuff%:gb%=plbuff%+sx%:bb%=plbuff%+sx%*2:rbo%=-1 12150FORC%=0TO255:r%(C%)=(C%AND&F)/&F*F:NEXT:g%()=r%():b%()=r%():cache%=TRUE 12160input=24:info$="Hawk V9/Snapshot Colour image, "+STR$sx%+" by "+STR$sy%+" pixels, 12 bits per pixel" 12170WHEN 903 12180quant%=5:PTR#c%=8:sx%=FNW:rowbytes%=sx%*2:sy%=FNW:st%=20:PTR#c%=20:cache%=TRUE:r$="FN16":flag=700 12190DIM rpal%(255),gpal%(255):input=16:step24=2 12200FORC%=0TO255 12210gpal%(C%)=(C%>>5)<<8 OR (C%AND31) 12220rpal%(C%)=((C%>>2)AND31)<<16 OR (C%AND3)<<11 12230NEXT 12240FORC%=0TO31:r%(C%)=C%/31*F:NEXT:g%()=r%():b%()=r%() 12250input=16:info$="Hawk V9 mk II Colour image, "+STR$sx%+" by "+STR$sy%+" pixels, 16 bits per pixel" 12260WHEN 950 12270quant%=8:PTR#c%=0:sx%=512:rowbytes%=512:sy%=512:st%=0:flag=900 12280FORC%=0TO255:r%(C%)=C%/255*F:NEXT:g%()=r%():b%()=r%():r$="FN8":cache%=TRUE 12290info$="Wild Vision V12 image, 512 by 512 pixels, 8 bits per pixel" 12300WHEN 1000 12310quant%=4:sx%=640:sy%=256:PROCdefpal:st%=FNW:r$="FN"+STR$(1000+FNW):IFscale% ymul%=ymul%*2 12330buff%=FNdim(sx%):ctable%=FNdim(st%) 12340SYS12,4,c%,ctable%,st%:st%=PTR#c% 12350pa%=ctable%:rep%=0:rep2%=0:pasx%=buff%+sx% 12360info$="ProArtisan image, 640 by 256 pixels, 8 bits per pixel" 12370WHEN 1100 12380quant%=1:PTR#c%=4:sx%=FNbeW:sy%=FNbeW:input=FNbeW:bigendianbits=TRUE 12390S%=FNbeW:S%=FNbeW 12400cache%=TRUE:IFS%=2 cachebytes%=TRUE:info$="Byte Encoded " ELSEinfo$="":r$="FN8" 12410C%=FNbeW 12420D%=FNbeW 12430CASE C% OF 12440WHEN 1,2 12450FORI%=0TOD%/3-1:r%(I%)=BGET#c%/255*F:NEXT 12460FORI%=0TOD%/3-1:g%(I%)=BGET#c%/255*F:NEXT 12470FORI%=0TOD%/3-1:b%(I%)=BGET#c%/255*F:NEXT 12480OTHERWISE 12490CASE input OF 12500WHEN 1:r%(0)=F:g%(0)=F:b%(0)=F 12510WHEN 4,8:PROCnopal 12520WHEN 24:PROCnopal 12530ENDCASE 12540ENDCASE 12550CASE input OF 12560WHEN 1:rowbytes%=(sx%+15>>4)<<1 12570WHEN 4:rowbytes%=(sx%+3>>2)<<1 12580WHEN 8:rowbytes%=(sx%+1>>1)<<1 12590WHEN 24:rowbytes%=(3*sx%+1>>1)<<1:r$="FN24":rbo%=0:gbo%=1:bbo%=2:step24=3 12600IFS%=1 bbo%=0:rbo%=2 12610OTHERWISE:ERROR 42,"Can't do this Sun pixrect" 12620ENDCASE 12630st%=D%+&20:rep%=0:IFcachebytes% plbuff%=FNdim(rowbytes%):plbytes%=rowbytes% 12640info$+="Sun image, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 12650WHEN 1200 12660quant%=8:sx%=800:sy%=800:st%=1600:PTR#c%=st%:vflip%=NOT vflip% 12670PROCnopal:r$="FN8":rowbytes%=sx%:cache%=TRUE 12680info$="TimeStep satellite image, 800 by 800 pixels, 8 bits per pixel" 12690WHEN 1300 12700quant%=8:sx%=128:sy%=256:st%=0:PTR#c%=0:IFscale% xmul%=xmul%*2 12710PROCnopal:r$="FN8":rowbytes%=sx%:cache%=TRUE 12720info$="satellite image, 128 by 256 pixels, 8 bits per pixel" 12730WHEN 1301 12740input=24:quant%=8:sx%=128:sy%=256:IFscale% xmul%=xmul%*2 12750buff%=FNdim(sx%*3):rb%=buff%:gb%=buff%+sx%:bb%=buff%+2*sx%:PROCnopal:r$="FN901" 12760info$="Triple satellite image, 128 by 256 pixels, 24 bits per pixel" 12770WHEN 1400 12780planar%=TRUE:PTR#c%=0:Z%=FNHW:IFZ%>255 THEN 12790st%=FNbeHW*2:planes%=FNbeHW:patlen%=FNbeHW 12800pw%=FNbeHW:ph%=FNbeHW:sx%=FNbeHW:sy%=FNbeHW 12810ELSE 12820st%=FNHW*2:input=FNHW:patlen%=FNHW:pw%=FNHW:ph%=FNHW:sx%=FNHW:sy%=FNHW 12830ENDIF 12840IFscale% THEN 12850xmul%=xmul%*pw%:xdiv%=xdiv%*282 12860ymul%=ymul%*ph%:ydiv%=ydiv%*282 12870ENDIF 12880rowbytes%=sx%+7>>3:pbuff%=FNdim(sx%):plbytes%=rowbytes%*planes%:buff%=FNdim(plbytes%) 12890PTR#c%=st%:vrep%=0 12900FORC%=0TO(1<<planes%)-1:r%(C%)=F-C%/((1<<planes%)-1)*F:NEXT:g%()=r%():b%()=r%() 12910info$="IMG file, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(planes%) 12920WHEN 1500 12930PTR#c%=4:dir%=FNtiff(4):PTR#c%=dir% 12940rgb=FALSE:greyunit=100:planar%=1:fillorder=1:resunit=2 12950xnum%=90:xdenom%=1:ynum%=90:ydenom%=1 12960E%=FNtiff(3):FORZ%=1TOE% 12970T%=FNtiff(3):D%=FNtiff(3):C%=FNtiff(4) 12980IFC%>1 V%=FNtiff(4) ELSEIFD%=2 PTR#c%=dir%+2+Z%*12 ELSEIFD%<4 V%=FNtiff(D%):PTR#c%=dir%+2+Z%*12 ELSEV%=FNtiff(4) 12990PRINT"Read tag ";T%" datatype "D%" count "C%" value/pointer "V% 13000CASE T% OF 13010WHEN 256:sx%=V% 13020WHEN 257:sy%=V% 13030WHEN 258:IFC%>1 THEN 13040IFD%*C%>6 THEN 13050PTR#c%=V%:quant%=FNtiff(D%) 13060input=quant%:FORI%=1TOC%-1:V%=FNtiff(D%) 13070IFV%<>quant% ERROR42,"Can't do RGB TIFF with different numbers of bits per pixel" 13080input+=V% 13090NEXT:PROCnopal 13100ELSE 13110quant%=V% AND &FF:input=quant% 13120FORI%=0TO(1<<quant%)-1:r%(I%)=I%/((1<<quant%)-1)*F:NEXT 13130g%()=r%():b%()=r%() 13140ENDIF 13150PTR#c%=dir%+2+Z%*12 13160ELSE 13170quant%=V%:input=quant% 13180FORI%=0TO(1<<quant%)-1:r%(I%)=I%/((1<<quant%)-1)*F:NEXT 13190g%()=r%():b%()=r%() 13200ENDIF 13210WHEN 259:compression=V% 13220WHEN 262:photometric=V%:IFV%=0 invert%=NOTinvert% 13230WHEN 266:fillorder=V% 13240WHEN 273:stc%=C%:stv%=V%:std%=D% 13250WHEN 277:sampperpix%=V%:input=quant%*V%:rgb=V%=3 13260WHEN 278:striprows%=V% 13270WHEN 279:stcbyte%=C%:stvbyte%=V%:stdbyte%=D% 13280WHEN 282:PTR#c%=V%:xnum%=FNtiff(4):xdenom%=FNtiff(4) 13290PTR#c%=dir%+2+Z%*12 13300WHEN 283:PTR#c%=V%:ynum%=FNtiff(4):ydenom%=FNtiff(4) 13310PTR#c%=dir%+2+Z%*12 13320WHEN 284:planar%=V%:IFplanar%=2 input=quant% 13330WHEN 290:greyunit=10^V% 13340WHEN 291:PTR#c%=V%:FORI%=0TOC%-1:r%(I%)=FNtiff(D%)/greyunit/2*F:NEXT 13350g%()=r%():b%()=r%() 13360PTR#c%=dir%+2+Z%*12 13370WHEN 296:resunit=V% 13380WHEN 317:hpredict%=V% 13390WHEN 320:PTR#c%=V%:FORI%=0TOC%/3-1:r%(I%)=FNtiff(3)/65535*F:NEXT 13400FORI%=0TOC%/3-1:g%(I%)=FNtiff(3)/65535*F:NEXT 13410FORI%=0TOC%/3-1:b%(I%)=FNtiff(3)/65535*F:NEXT 13420PTR#c%=dir%+2+Z%*12 13430OTHERWISE 13440IFinfo% PRINT"Ignoring tag ";T%" datatype "D%" count "C%" value/pointer "V% 13450ENDCASE 13460NEXT 13470DIM st%(stc%):IFstc%>1 THEN 13480PTR#c%=stv%:FORI%=0TOstc%-1:st%(I%)=FNtiff(std%):NEXT 13500ELSE 13510st%(0)=stv% 13520ENDIF 13530CASE compression OF 13540WHEN 0,1:info$="" 13550WHEN 2:info$="CCITT Group 3 compressed " 13560WHEN 5:info$="LZW compressed ":r$="FN1505" 13570IFhpredict%=2 THENinfo$+="horizontal differenced " ELSEIFhpredict%>2 info$+=" unknown predictor ("+STR$hpredict%+") " 13580setcodes%=8:clearcode%=1<<setcodes% 13590DIM table%(1<<12):stk%=FNdim(1<<13):buf%=FNdim(280) 13600FORI%=0TOclearcode%-1:table%(I%)=I%:NEXT 13610WHEN 32773:info$="PackBits compressed ":r$="FN1501" 13620WHEN 6:info$="JPEG compressed " 13630OTHERWISE info$="Compress "+STR$compression+" - unknown " 13640ENDCASE 13650info$+="TIFF file, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 13660bigendianbits=fillorder=1:PTR#c%=st%(0):stripptr=0:IFstriprows%>=sy% striprows%=-1 13670CASE input OF 13680WHEN 1:rowbytes%=sx%+7>>3 13690WHEN 2:rowbytes%=sx%+3>>2 13700WHEN 4:rowbytes%=sx%+1>>1 13710WHEN 8:rowbytes%=sx% 13720WHEN 24:rowbytes%=3*sx% 13730WHEN 32:rowbytes%=4*sx%:IFphotometric<>5 ERROR 42,"32 bpp TIFF but not CMYK" 13740OTHERWISE ERROR 42,"Can't do "+FNbits(input)+" TIFF" 13750ENDCASE 13760IFplanar%=2 rowbytes%=rowbytes%*sampperpix% 13770IFplanar%<>1 AND rgb<>0 ERROR42,"Can't do this style of TIFF yet" ELSEplanar%=FALSE 13780IF compression<2 THEN 13790cache%=TRUE:stripptr=-1:r$="FN8":IFinput=24 rbo%=0:gbo%=1:bbo%=2:step24=3:r$="FN24" 13800IFinput=32 rbo%=0:gbo%=1:bbo%=2:step24=4:r$="FN24":r%()=F-r%():g%()=F-g%():b%()=F-b%():input=24 13810ELSE 13820IFcompression=5 ORcompression=32773 THEN 13830cache%=TRUE:cachebytes%=rowbytes%*striprows% 13840plbuff%=FNdim(rowbytes%):rowstogo%=striprows% 13850IFinput=24 rb%=plbuff%:gb%=plbuff%+1:bb%=plbuff%+2:r$="FN"+STR$(VALMID$(r$,3)+10):step24=3:rbo%=-1 13860ELSE 13870buff%=FNdim(rowbytes%):rowstogo%=striprows% 13880IFinput=24 rb%=buff%:gb%=buff%+1:bb%=buff%+2:r$="FN"+STR$(VALMID$(r$,3)+10):step24=3 13890ENDIF 13900ENDIF 13910IFscale% THEN 13920S%=resunit:IFS%=2 S%=90 13930IFS%=3 S%=35 13940xdiv%=xdiv%*xnum%:xmul%=xmul%*xdenom%*S% 13950ydiv%=ydiv%*ynum%:ymul%=ymul%*ydenom%*S% 13960ENDIF 13970IFr$="FN1500" r$="FN8" 13980WHEN 1600 13990PTR#c%=12:camg=0:planar%=TRUE:REPEAT 14000S$=CHR$BGET#c%+CHR$BGET#c%+CHR$BGET#c%+CHR$BGET#c%:S%=FNbeW 14010CASE S$ OF 14020WHEN "BMHD":sx%=FNbeHW:sy%=FNbeHW:S%=FNW:planes%=BGET#c%:masking%=BGET#c%=1 14030compression=BGET#c%:S%=BGET#c%+FNHW:U%=BGET#c%:V%=BGET#c%:S%=FNW 14040IFscale% ymul%=ymul%*V%:ydiv%=ydiv%*U% 14050FORI%=0TO(1<<planes%)-1:r%(I%)=I%/((1<<planes%)-1)*F:NEXT:g%()=r%():b%()=r%() 14060WHEN "CMAP":S%=PTR#c%+S%:FORI%=0TO(1<<planes%)-1:r%(I%)=(BGET#c%>>4)/15*F 14070g%(I%)=(BGET#c%>>4)/15*F:b%(I%)=(BGET#c%>>4)/15*F:NEXT 14080PTR#c%=S%:IFinfo% PRINT"Warning: truncated IFF CMAP information to 4 bits" 14090WHEN "CAMG":camg=FNbeW:IFinfo% PRINT"Amiga viewport mode ";~camg 14100WHEN "BODY":st%=PTR#c% 14110OTHERWISE IF info% PRINT"Ignoring IFF property "S$" size ";S% 14120PTR#c%=PTR#c%+S% 14130ENDCASE 14140UNTILS$="BODY":IFcompression info$="Compressed " ELSEinfo$="" 14160ham=(camg AND &800)<>0:IFham info$+="HAM " 14170half=(camg AND &80)<>0:IFhalf info$+="half-bright " 14180IFhalf half%=1<<planes%-1:FORI%=0TOhalf%-1:r%(I%+half%)=r%(I%)/2:g%(I%+half%)=g%(I%)/2:b%(I%+half%)=b%(I%)/2:NEXT 14190info$+="IFF file, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(planes%) 14200IFmasking% info$+=" with mask (ignored)" 14210rowbytes%=(sx%+15>>4)<<1:plbytes%=rowbytes%*planes% 14220pbuff%=FNdim(sx%):r$="FN"+STR$(1600+compression):cache%=TRUE 14230IFcompression THEN 14240cachebytes%=TRUE:plbuff%=FNdim(plbytes%) 14250ELSE 14260realrowbytes%=rowbytes%:rowbytes%=plbytes%:IFmasking% rowbytes%+=realrowbytes% 14270ENDIF 14280PTR#c%=st% 14290WHEN 1700 14300sx%=640:rowbytes%=80:sy%=350:planes%=4:plbytes%=4*80:planar%=TRUE 14310buff%=FNdim(80*4):pbuff%=FNdim(640):G=F/3:H=F*2/3 14320r%()=0,0,0,0,F,F,F,H,G,G,G,G,F,F,F,F 14330g%()=0,0,F,F,0,0,F,H,G,G,F,F,G,G,F,F 14340b%()=0,F,0,F,0,F,0,H,G,F,G,F,G,F,G,F 14350masking%=FALSE:r$="FN1600":st%=16:PTR#c%=16:cache%=TRUE:realrowbytes%=80:rowbytes%=plbytes% 14360info$="PC EGA '.dsp' file, 640 by 350 pixels, 4 bits per pixel (fixed palette)" 14370WHEN 1800 14380sx%=72*8:sy%=720:quant%=1:input=1:PTR#c%=st%:plbuff%=FNdim(72) 14390cache%=TRUE:cachebytes%=TRUE 14400r%(0)=F:g%(0)=F:b%(0)=F:bigendianbits=TRUE:rowbytes%=72:r$="FN1501":rowstogo%=-1 14410IFscale% xmul%=xmul%*90:xdiv%=xdiv%*72:ymul%=ymul%*90:ydiv%=ydiv%*72 14420info$="MacPaint file, 576 by 720 bits, creator id "+RIGHT$(S$,4) 14430WHEN 1850 14440PTR#c%=552 14450done%=FALSE 14460REPEAT 14470code%=FNbeHW:CASE code% OF 14480WHEN &01:PTR#c%=PTR#c%+FNbeHW 14490WHEN &1E 14500WHEN &98 14510rowbytes%=FNbeHW:IF(rowbytes% AND&8000)=0 ERROR42,"PICT without Pixmap" 14520sy%=FNbeHW:sx%=FNbeHW:sy%=FNbeHW-sy%:sx%=FNbeHW-sx% 14530junk%=FNHW:packtype%=FNbeHW:junk%=FNW:resx%=FNbeW:resy%=FNbeW 14540IFFNbeHW<>0 CLOSE#c%:ERROR42,"ChangeFSI expected Mac PICT2 pixeltype=Chunky" 14550bpp%=FNbeHW:junk%=FNbeHW:junk%=FNbeHW 14560junk%=FNbeW:junk%=FNbeW:junk%=FNbeW 14570junk%=FNbeW:junk%=FNbeHW 14580C%=FNbeHW:FORI%=0TOC%:J%=FNbeHW:r%(J%)=FNbeHW/65535*F:g%(J%)=FNbeHW/65535*F:b%(J%)=FNbeHW/65535*F:NEXT 14590done%=TRUE 14600WHEN &9A:junk%=FNW:rowbytes%=FNbeHW:IF(rowbytes% AND&8000)=0 ERROR42,"PICT without Pixmap" 14610sy%=FNbeHW:sx%=FNbeHW:sy%=FNbeHW-sy%:sx%=FNbeHW-sx% 14620junk%=FNHW:packtype%=FNbeHW:junk%=FNW:resx%=FNbeW:resy%=FNbeW 14630IFFNbeHW<>16 CLOSE#c%:ERROR42,"ChangeFSI expected Mac PICT2 pixeltype=RGBDirect" 14640bpp%=FNbeHW:comps%=FNbeHW:junk%=FNbeHW 14650junk%=FNbeW:junk%=FNbeW 14660junk%=FNbeHW:junk%=FNbeHW 14670IFbpp%>16 PROCnopal ELSEJ%=2^(bpp%DIV3):FORI%=0TOJ%-1:r%(I%)=I%/(J%-1)*F:NEXT:g%()=r%():b%()=r%() 14680IFbpp%=32 AND comps%=3 bpp%=24:rowbytes%=3*sx% 14690done%=TRUE 14700OTHERWISE:CLOSE#c%:ERROR42,"ChangeFSI can't understand Mac PICT2 code "+STR$~code% 14710ENDCASE 14720UNTIL done% 14730junk%=FNbeHW:junk%=FNbeHW:junk%=FNbeHW:junk%=FNbeHW 14740junk%=FNbeHW:junk%=FNbeHW:junk%=FNbeHW:junk%=FNbeHW 14750junk%=FNbeHW 14760cache%=TRUE:cachebytes%=TRUE:bigendianbits=TRUE:st%=PTR#c%:rowbytes%=rowbytes%ANDNOT&8000 14770IFscale% xmul%=xmul%*90*65536:xdiv%=xdiv%*resx%:ymul%=ymul%*90*65536:ydiv%=ydiv%*resy% 14780info$="Mac PICT2, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(bpp%) 14790plbuff%=FNdim(rowbytes%):IFbpp%>8 THEN 14800rbo%=-1:rb%=plbuff%+sx%:gb%=plbuff%+sx%*2:bb%=plbuff%+sx%*3:r$="FN1851":input=24 14810IFcomps%=3 rb%=plbuff%:gb%=plbuff%+sx%:bb%=plbuff%+sx%*2 14820ENDIF 14830WHEN 1900 14840PTR#c%=1:C%=BGET#c% 14850E%=BGET#c%:IFE%<>1 ERROR 42,"ZSoft .PCX file with unknown encoding" 14860E%=BGET#c%:sx%=FNHW:sy%=FNHW:sx%=FNHW+1-sx%:sy%=FNHW+1-sy% 14870IFscale% xmul%=xmul%*90:xdiv%=xdiv%*FNHW:ymul%=ymul%*90:ydiv%=ydiv%*FNHW ELSEIFFNW 14880PTR#c%=65:planes%=BGET#c%:planar%=planes%>1:rowbytes%=FNHW:bpp%=E%*planes% 14890pcxpal=16:IFbpp%>4 AND C%=5 THEN 14900PTR#c%=EXT#c%-769:IFBGET#c%=12 pcxpal=EXT#c%-768 14910ENDIF 14920PTR#c%=pcxpal:E%=0:FORC%=0TO(1<<bpp%)*3-1:E%=E%ORBGET#c%:NEXT 14930IFinfo% PRINT".PCX palette mask established at ";~E% 14940IFE%=0 THEN 14950FORC%=0TO(1<<bpp%)-1:r%(C%)=C%/((1<<bpp%)-1)*F:NEXT:g%()=r%():b%()=r%() 14960ELSE 14970PTR#c%=pcxpal:FORC%=0TO(1<<bpp%)-1 14980r%(C%)=(BGET#c%ANDE%)/E%*F:g%(C%)=(BGET#c%ANDE%)/E%*F:b%(C%)=(BGET#c%ANDE%)/E%*F 14990NEXT 15000ENDIF 15010PROCrewind 15020plbytes%=rowbytes%*planes%:plbuff%=FNdim(plbytes%):cache%=TRUE:cachebytes%=TRUE 15030IFplanar% pbuff%=FNdim(sx%) ELSEinput=bpp%:bigendianbits=TRUE:r$="FN1100" 15040info$="ZSoft .PCX file, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(bpp%) 15050WHEN 2000 15060PTR#c%=0:L%=BGET#c%:C%=BGET#c%:I%=BGET#c%:J%=FNHW:K%=FNHW:M%=BGET#c% 15070sx%=FNW:sx%=FNHW:sy%=FNHW:B%=BGET#c%:ID%=BGET#c%:IFID%AND&10 hflip%=NOThflip% 15080IF(ID% AND&20)=0 vflip%=NOTvflip% 15090PTR#c%=PTR#c%+L%:CASE C% OF 15100WHEN 1:IFM%=&18 THEN 15110FORC%=J%TOK%-1 15120b%(C%)=BGET#c%/255*F:g%(C%)=BGET#c%/255*F:r%(C%)=BGET#c%/255*F 15130NEXT 15140ELSE 15150ENDIF 15160OTHERWISE PROCnopal 15170ENDCASE 15180st%=PTR#c% 15190CASE I% OF 15200WHEN 1,2,3:cache%=TRUE:IFB%>8 THEN 15210IFB%>16 THEN 15220input=24:bbo%=0:gbo%=1:rbo%=2:step24=B%DIV8:r$="FN24":rowbytes%=step24*sx% 15230ELSE 15240rowbytes%=sx%*2 15250DIM rpal%(255),gpal%(255):input=16:step24=2:r$="FN16" 15260FORC%=0TO255 15270gpal%(C%)=(C%>>5)<<8 OR (C%AND31)<<16 15280rpal%(C%)=(C%>>2)AND31 OR (C%AND3)<<11 15290NEXT 15300FORC%=0TO31:r%(C%)=C%/31*F:NEXT:g%()=r%():b%()=r%() 15310ENDIF 15320ELSE 15330r$="FN8":rowbytes%=sx% 15340ENDIF 15350info$="Truevision TGA image, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(B%) 15360WHEN 9,10,11:step24=B%DIV8:rowbytes%=step24*sx%:buff%=FNdim(rowbytes%) 15370IFB%>8 THEN 15380IFB%>16 THEN 15390input=24:bb%=buff%:gb%=buff%+1:rb%=buff%+2:r$="FN2002" 15400ELSE 15410DIM rpal%(255),gpal%(255):input=16:step24=2:r$="FN2001" 15420FORC%=0TO255 15430gpal%(C%)=(C%>>5)<<8 OR (C%AND31)<<16 15440rpal%(C%)=(C%>>2)AND31 OR (C%AND3)<<11 15450NEXT 15460FORC%=0TO31:r%(C%)=C%/31*F:NEXT:g%()=r%():b%()=r%() 15470ENDIF 15480ENDIF 15490info$="Truevision TGA RLE image, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(B%) 15500ENDCASE 15510WHEN 2100 15520quant%=6:sx%=512:rowbytes%=2*sx%:sy%=256:cache%=TRUE:r$="FN16" 15530DIM rpal%(255),gpal%(255):input=16:step24=2 15540FORC%=0TO255 15550gpal%(C%)=C%>>3 OR (C%AND7)<<11 15560rpal%(C%)=(C%AND7)<<8 OR (C%>>3)<<16 15570NEXT 15580FORC%=0TO31:r%(C%)=C%/31*F:NEXT:b%()=r%() 15590FORC%=0TO63:g%(C%)=C%/63*F:NEXT 15600IFscale% ymul%=ymul%*2 15610info$="Pineapple image, 512 by 256 pixels, 16 bits per pixel":PTR#c%=7 15620WHEN 2200 15630quant%=8:step24=1:PTR#c%=0:s$=GET$#c%:E%=INSTR(s$,":"):st%=PTR#c% 15640sx%=VALMID$(s$,E%+1):sy%=VALMID$(s$,E%+2+LENSTR$sx%):PROCnopal:input=24 15650rowbytes%=sx%*3:rbo%=0:gbo%=sx%:bbo%=2*sx%:cache%=TRUE:r$="FN24" 15660info$="Irlam image, "+STR$sx%+" by "+STR$sy%+" pixels, 24 bits per pixel" 15670WHEN 2250 15680PTR#c%=16:sx%=FNW:sy%=FNW:DIM rpal%(255),gpal%(255),bpal%(255),table%(255) 15690FORC%=0TO255:D%=C%OR1 15700table%(C%)=(D%-16)/219*F 15710IFD%AND128 D%-=256 15720r%(C%)=INT(D%/160*F):b%(C%)=INT(D%/126*F) 15730g%(C%)=INT(-D%/160*rwt/gwt*F):gpal%(C%)=INT(-D%/126*bwt/gwt*F) 15740NEXT 15750table%()=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 15760st%=32:PTR#c%=32:cache%=TRUE:rowbytes%=2*sx%:input=411 15770info$="Irlam YUV 4:1:1 file "+STR$sx%+" by "+STR$sy%+" pixels" 15780WHEN 2300 15790PTR#c%=6:sx%=FNHW:sy%=FNHW:D%=BGET#c%:ncolors%=BGET#c%:input=24 15800vflip%=NOTvflip%:quant%=BGET#c%:ncmap%=BGET#c%:cmaplen%=1<<BGET#c% 15810PROCnopal:back%=FNdim(4):!back%=0 15820clrfirst%=D%AND1 15830IF(D%AND2)=0 THEN 15840FORI%=0TOncolors%-1:back%?I%=BGET#c%:NEXT 15850IF(ncolors%AND1)=0 IFBGET#c% 15860ENDIF 15870IFD%AND4 alpha%=FNdim(sx%) 15880IFncmap%>0 THEN 15890FORI%=0TOcmaplen%-1:r%(I%)=FNHW/&FF00*F:NEXT 15900FORI%=0TOcmaplen%-1:g%(I%)=FNHW/&FF00*F:NEXT 15910FORI%=0TOcmaplen%-1:b%(I%)=FNHW/&FF00*F:NEXT 15920ENDIF 15930IFD%AND8 THEN 15940PTR#c%=FNHW+PTR#c%:IFPTR#c%AND1 PTR#c%=PTR#c%+1 15950ENDIF 15960st%=PTR#c%:buff%=FNdim(sx%*3):rb%=buff%:gb%=buff%+1*sx%:bb%=buff%+2*sx% 15970PROCrewind 15980info$="Utah rle image, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(ncolors%*quant%) 15990WHEN 2400 16000PTR#c%=riffoff%+&0a:st%=FNW:pal%=FNW:sx%=FNW:sy%=FNW 16010CASE pal% OF 16020WHEN 12 16030PTR#c%=riffoff%+&18:input=FNHW:compression=0 16040WHEN 40 16050PTR#c%=riffoff%+&1c:input=FNHW:compression=FNW 16060PTR#c%=riffoff%+&26:xppm=FNW:yppm=FNW 16070IF xppm<>0 AND yppm<>0 AND scale%<>0 THEN 16080xdiv%=xdiv%*xppm:xmul%=xmul%*3543 16090ydiv%=ydiv%*yppm:ymul%=ymul%*3543 16100ENDIF 16110OTHERWISE 16120ERROR 42,"Unknown .BMP variant ("+STR$pal%+")" 16130ENDCASE 16140bigendianbits=TRUE:vflip%=NOTvflip% 16150CASE input OF 16160WHEN 1:rowbytes%=sx%+7>>3 16170WHEN 4:rowbytes%=sx%+1>>1 16180WHEN 8:rowbytes%=sx% 16190WHEN 16:rowbytes%=sx%*2:r$="FN16":step24=2 16200DIM rpal%(255),gpal%(255) 16210rmask%=&7c00:gmask%=42:bmask%=-42 16220IFcompression=3 PTR#c%=riffoff%+14+pal%:rmask%=FNW:gmask%=FNW:bmask%=FNW:compression=0 16230IFrmask%=&7c00 THEN 16240FORC%=0TO255 16250gpal%(C%)=(C%>>5)<<8 OR (C%AND31)<<16 16260rpal%(C%)=(C%>>2)AND31 OR (C%AND3)<<11 16270NEXT 16280FORC%=0TO31:r%(C%)=C%/31*F:NEXT:g%()=r%():b%()=r%() 16290ENDIF 16300IFrmask%=&f800 THEN 16310FORC%=0TO255 16320gpal%(C%)=(C%>>5)<<8 OR (C%AND31)<<16 16330rpal%(C%)=(C%>>3)AND31 OR (C%AND7)<<11 16340NEXT 16350FORC%=0TO31:r%(C%)=C%/31*F:NEXT:b%()=r%() 16360FORC%=0TO63:g%(C%)=C%/63*F:NEXT 16370ENDIF 16380WHEN 24,32 16390rbo%=2:gbo%=1:bbo%=0:r$="FN24" 16400FORC%=0TO255:r%(C%)=C%/255*F:NEXT:g%()=r%():b%()=r%() 16410r$="FN24":step24=input/8:rowbytes%=sx%*step24 16420rmask%=-1:gmask%=42:bmask%=-42 16430IFcompression=3 PTR#c%=riffoff%+14+pal%:rmask%=FNW:gmask%=FNW:bmask%=FNW:compression=0 16440IFrmask%=&FF THENrbo%=0:gbo%=1:bbo%=2 16450IFgmask%=&FF THENgbo%=0:bbo%=1:rbo%=2 16460IFbmask%=&FF THENbbo%=0:gbo%=1:rbo%=2 16470input=24 16480OTHERWISE ERROR 42,".BMP file of unusual depth ("+STR$input+")" 16490ENDCASE 16500IFinput<=8 THEN 16510PTR#c%=riffoff%+14+pal%:r$="FN8" 16520FORC%=0TO2^input-1 16530b%(C%)=BGET#c%/255*F:g%(C%)=BGET#c%/255*F:r%(C%)=BGET#c%/255*F:IFBGET#c% 16540NEXT 16550ENDIF 16560CASE compression OF 16570WHEN 0:info$="Uncompressed " 16580WHEN 1:info$="RLE8 compressed ":r$="FN2401" 16590WHEN 2:info$="RLE4 compressed ":r$="FN2402" 16600OTHERWISE ERROR 42,".BMP compression type not supported ("+STR$compression+")" 16610ENDCASE 16620rowbytes%=rowbytes%+3ANDNOT3 16630IF compression<>0 cachebytes%=TRUE:plbuff%=FNdim(rowbytes%) 16640cache%=TRUE:PTR#c%=riffoff%+st% 16650info$+="Windows 3.0 .BMP image, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 16660WHEN 2500 16670PTR#c%=0:s$="":C%=BGET#c%:WHILEC%<>0 s$+=CHR$C%:C%=BGET#c%:ENDWHILE 16680s$+=" version "+STR$FNW:sx%=FNW:sy%=FNW:input=FNW:cache%=TRUE 16690info$="!Translator Clear format made by "+s$+", "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 16700IFinput>8 THEN 16710PROCnopal:input=24:step24=3:rowbytes%=3*sx%:rbo%=0:gbo%=1:bbo%=2:r$="FN24" 16720ELSE 16730FORC%=0TO2^input-1 16740r%(C%)=BGET#c%/255*F:g%(C%)=BGET#c%/255*F:b%(C%)=BGET#c%/255*F 16750NEXT 16760input=8:r$="FN8":rowbytes%=sx% 16770ENDIF 16780st%=PTR#c% 16790WHEN 2600 16800PTR#c%=0:C%=BGET#c% 16810D%=BGET#c%:CASE D% OF 16820WHEN 0:sx%=320:sy%=200:planes%=4 16830WHEN 1:sx%=640:sy%=200:planes%=2 16840WHEN 2:sx%=640:sy%=400:planes%=1 16850OTHERWISE ERROR42,"ChangeFSI knows nothing of "+STR$C%+" type Degas files" 16860ENDCASE 16870FORI%=0TO(1<<input)-1:D%=FNbeHW:r%(I%)=(D%>>8AND7)/7*F:g%(I%)=(D%>>4AND7)/7*F:b%(I%)=(D%AND7)/7*F:NEXT 16880cache%=TRUE:planar%=TRUE:masking%=FALSE:st%=34:PTR#c%=34:r$="FN1600" 16890rowbytes%=(sx%+15>>4)<<1:plbytes%=rowbytes%*planes%:pbuff%=FNdim(sx%) 16900IFC%AND128 r$="FN1601":flag=1600:cachebytes%=TRUE:plbuff%=FNdim(plbytes%) ELSErealrowbytes%=2:rowbytes%=plbytes% 16910info$="Degas file "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(planes%) 16920WHEN 2700 16930PTR#c%=4:sx%=FNHW:sy%=FNHW 16940CASE FNHW OF 16950WHEN &AF:rowbytes%=sx%:cache%=TRUE:r$="FN8":st%=&30A 16960OTHERWISE CLOSE#c%:ERROR 42,"Panic in ColoRIX reading - ChangeFSI largely ignorant of format!" 16970ENDCASE 16980FORC%=0TO2^input-1 16990r%(C%)=BGET#c%/63*F:g%(C%)=BGET#c%/63*F:b%(C%)=BGET#c%/63*F 17000NEXT 17010PTR#c%=st% 17020info$="ColoRIX file "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 17030WHEN 2800 17040PTR#c%=0:REPEAT s$=FNfits:CASE LEFT$(s$,8) OF 17050WHEN "SIMPLE ":IFMID$(s$,30,1)<>"T" ERROR42,"ChangeFSI can only read Simple FITS format" 17060WHEN "BITPIX ":input=VALMID$(s$,10) 17070WHEN "NAXIS ":IFVALMID$(s$,10)<>2 ERROR42,"ChangeFSI can only read 2d FITS images" 17080WHEN "NAXIS1 ":sx%=VALMID$(s$,10) 17090WHEN "NAXIS2 ":sy%=VALMID$(s$,10) 17100WHEN "END " 17110OTHERWISE IFinfo% PRINT"Ignoring FITS record "s$ 17120ENDCASE 17130UNTILLEFT$(s$,8)="END " 17140st%=(PTR#c%DIV2880 + 1)*2880:cache%=TRUE:PTR#c%=st% 17150CASE input OF 17160WHEN 8:r$="FN8":rowbytes%=sx%:PROCnopal 17170WHEN 16:rowbytes%=2*sx%:DIM rpal%(255),gpal%(255):step24=2:r$="FN16" 17180FORC%=0TO255 17190gpal%(C%)=C%<<8 17200rpal%(C%)=C% 17210NEXT:cheat%=0:IFinvert% cheat%=F 17220FORC%=0TO255:r%(C%)=cheat%+C%/65535*F:g%(C%)=((C%EOR&80)<<8)/65535*F:b%(C%)=cheat%:NEXT:rwt=1:gwt=1:bwt=1 17230OTHERWISE ERROR 42,"ChangeFSI can't read a FITS image with this number of bits per pixel" 17240ENDCASE 17250info$="FITS file "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 17260WHEN 2900 17270PTR#c%=4:sx%=FNbeHW:sy%=FNbeHW:PTR#c%=&42:input=FNbeHW:C%=FNbeHW 17280rowbytes%=FNbeHW:C%=FNbeW:st%=FNbeW:PTR#c%=st%:r$="FN8":PROCnopal 17290DIM rpal%(15),gpal%(15),bpal%(15) 17300rpal%()=&e6,&23,&e6,&7f,&17,&00,&a1,&45,&e6,&4a,&e6,&73,&6e,&47,&8a,0 17310gpal%()=&e6,&78,&00,&23,&a1,&73,&2e,&2e,&c8,&a6,&75,&40,&b8,&78,&55,0 17320bpal%()=&b8,&e6,&00,&a1,&17,&2e,&0c,&2e,&00,&c6,&00,&e6,&00,&00,&00,0 17330FORC%=&80TO&8F:r%(C%)=rpal%(C%-&80)/255*F:g%(C%)=gpal%(C%-&80)/255*F:b%(C%)=bpal%(C%-&80)/255*F:NEXT:cache%=TRUE 17340info$="Apollo GPR file "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 17350WHEN 3000 17360sx%=720:sy%=EXT#c%/1440:DIM rpal%(255),gpal%(255),bpal%(255),table%(255) 17380IFFALSE THEN 17390FORC%=0TO255 17400table%(C%)=(C%-16)/219*F 17410r%(C%)=(C%-128)/186*0.624*F:rpal%(C%)=(C%-128)/160*0.952*F 17420g%(C%)=-(C%-128)/186*0.64*F:gpal%(C%)=-(C%-128)/160*0.277*F 17430b%(C%)=(C%-128)/186*1.73*F:bpal%(C%)=-(C%-128)/160*1.11*F 17440NEXT 17450ELSE 17470FORC%=0TO255 17480table%(C%)=(C%-16)/219*F 17490r%(C%)=INT((C%-128)/160*F):b%(C%)=INT((C%-128)/126*F) 17500g%(C%)=INT(-(C%-128)/160*rwt/gwt*F):gpal%(C%)=INT(-(C%-128)/126*bwt/gwt*F) 17510NEXT 17520ENDIF 17530table%()=-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 17540st%=0:PTR#c%=0:cache%=TRUE:rowbytes%=1440:input=422:gamma=1 17550IFscale% ymul%=ymul%*2 17560info$="CCIR601 4:2:2 file "+STR$sx%+" by "+STR$sy%+" pixels" 17570WHEN 3100 17580quant%=8:PTR#c%=0:a$=GET$#c%:st%=PTR#c% 17590sx%=VALa$:sy%=VAL(MID$(a$,INSTR(a$," "))) 17600PROCnopal:input=24:step24=3:rowbytes%=sx%*3 17610rbo%=0:gbo%=1:bbo%=2:cache%=TRUE:flag=700:r$="FN24" 17620info$="!RayShade 'RGB' image, "+STR$sx%+" by "+STR$sy%+" pixels, 24 bits per pixel" 17630WHEN 3200 17640quant%=8:PTR#c%=0:st%=0 17650sx%=VALMID$(s$,INSTR(s$,"_")+1,1) 17660CASE sx% OF 17670WHEN 5:sx%=768:sy%=512 17680WHEN 2:sx%=3072:sy%=2048 17690WHEN 1:sx%=1536:sy%=1024 17700ENDCASE 17710PROCnopal:input=24:step24=3:rowbytes%=sx%*3 17720rbo%=0:gbo%=1:bbo%=2:cache%=TRUE:flag=700:r$="FN24" 17730info$="Kodak /RGB image, "+STR$sx%+" by "+STR$sy%+" pixels, 24 bits per pixel" 17740WHEN 3300 17750PTR#c%=0:input=VALMID$(FNGET,2) 17760s$=FNGET:sx%=VALs$:sy%=VALMID$(s$,INSTR(s$," ")):IFsy%=0 sy%=VALFNGET 17770cache%=TRUE:CASE input OF 17780WHEN 4:input=1:r$="FN8":r%(0)=F:g%()=r%():b%()=r%():bigendianbits=TRUE 17790rowbytes%=(sx%+7)DIV8 17800WHEN 5:input=8:r$="FN8":E%=VALFNGET 17810FORC%=0TOE%:r%(C%)=C%/E%*F:NEXT:g%()=r%():b%()=r%() 17820rowbytes%=sx% 17830WHEN 6:input=24:r$="FN24":E%=VALFNGET:step24=3:rbo%=0:gbo%=1:bbo%=2 17840FORC%=0TOE%:r%(C%)=C%/E%*F:NEXT:g%()=r%():b%()=r%() 17850rowbytes%=sx%*3 17860ENDCASE 17870st%=PTR#c%:flag=700 17880info$+="pbm image, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 17890DEF FNGET REPEATs$=GET$#c%:UNTILLEFT$(s$,1)<>"#":=s$ 17900WHEN 3400 17910PTR#c%=0:s$=FNGET:input=16:quant%=5 17920s$=FNGET:sx%=VALs$:sy%=VALMID$(s$,INSTR(s$," ")):s$=FNGET 17930DIM rpal%(255),gpal%(255):input=16:step24=2 17940FORC%=0TO255 17950gpal%(C%)=(C%>>5)<<8 OR (C%AND31) 17960rpal%(C%)=((C%>>2)AND31)<<16 OR (C%AND3)<<11 17970NEXT 17980cache%=TRUE:r$="FN16" 17990FORC%=0TO31:r%(C%)=C%/31*F:NEXT:g%()=r%():b%()=r%() 18000rowbytes%=sx%*2:st%=PTR#c%:flag=700 18010info$="p15 image, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 18020WHEN 3450 18030PTR#c%=0:info$=FNGET 18040ybits%=VALMID$(info$,INSTR(info$," ")):ymax%=(1<<ybits%)-1 18050ubits%=VALMID$(info$,INSTR(info$,"Y ")+1):umax%=(1<<(ubits%-1))-1 18060vbits%=VALMID$(info$,INSTR(info$,"U ")+1):vmax%=(1<<(vbits%-1))-1 18070s$=FNGET:sx%=VALs$:sy%=VALMID$(s$,INSTR(s$," ")) 18080DIM rpal%(255),gpal%(255),bpal%(255),table%(255) 18090FORC%=0TOymax%:table%(C%)=C%/ymax%*F:NEXT 18100D%=(1<<ubits%)-1 18110FORC%=0TOD%:d=C%/umax%:IFd>1 d=-(D%-C%)/umax% 18120b%(C%)=INT(d*(1-bwt)*F):gpal%(C%)=INT(-d*(1-bwt)*bwt/gwt*F) 18130NEXT 18140D%=(1<<vbits%)-1 18150FORC%=0TOD%:d=C%/vmax%:IFd>1 d=-(D%-C%)/vmax% 18160r%(C%)=INT(d*(1-rwt)*F):g%(C%)=INT(-d*(1-rwt)*rwt/gwt*F) 18170NEXT 18180rowbytes%=sx%*2:st%=PTR#c%:cache%=TRUE:r$="FN2250":input=555 18190info$+=", "+STR$sx%+" by "+STR$sy%+" pixels" 18200WHEN 3500 18210quant%=1:PTR#c%=6:E%=FNHW:sx%=FNHW:sx%=FNHW:sy%=FNHW:st%=FNHW:st%=FNW 18220rowbytes%=sx%/8+1ANDNOT1:cache%=TRUE:st%+=PTR#c%:PTR#c%=st% 18230CASE E% OF 18240WHEN 1 18250r$="FN8":input=1:r%(0)=F:g%(0)=F:b%(0)=F 18260info$="Pocketbook bitmap, "+STR$sx%+" by "+STR$sy%+" pixels, 1 bit per pixel" 18270WHEN 2 18280planar%=TRUE:planes%=2:r$="FN1600":input=8:cachebytes%=TRUE 18290r%(0)=F:r%(1)=(F/3)*2:r%(2)=F/3:r%(3)=0:g%()=r%():b%()=r%() 18300plbytes%=rowbytes%*planes%:buff%=FNdim(plbytes%*sy%):pbuff%=FNdim(sx%) 18310realrowbytes%=rowbytes%*sy% 18320info$="PocketbookII bitmap, "+STR$sx%+" by "+STR$sy%+" pixels, 2 bits per pixel" 18330OTHERWISE 18340ERROR 42,"Unknown Pocketbook PIC format" 18350ENDCASE 18360WHEN 3600 18370pcdblk%=FNdim(40):SYS&20023,"ChangeFSI$PCDindex",pcdblk%,20 TO,,Z 18380IFZ THENpcdblk%?Z=13:pcdindex%=VAL$pcdblk% ELSEpcdindex%=3 18390SYS"PhotoCD_Open",1,c%,1 TO pcdh%:SYS"PhotoCD_GetCount",pcdh% TO,Z 18400IF(Z>>pcdindex%)=0 CLOSE#c%:ERROR42,"Desired resolution unavailable" 18410SYS"PhotoCD_GetRotation",pcdh% TO,,pcdtr% 18420SYS"PhotoCD_GetSize",pcdh%,,pcdindex% TO,,,,sx%,sy% 18430pcdblk%!0=0:pcdblk%!8=sx%:pcdblk%!4=0 18440pcdblk%!16=0:pcdblk%!20=2:pcdblk%!24=1:pcdblk%!28=3 18460CASE pcdtr% OF 18470WHEN 0 18480WHEN &80000000:hflip%=NOThflip% 18490WHEN 90 18500CASE rotate% OF 18510WHEN 0:rotate%=1 18520WHEN -1:rotate%=0 18530WHEN 1:rotate%=0:vflip%=NOTvflip%:hflip%=NOThflip% 18540ENDCASE 18550WHEN &8000005A 18560CASE rotate% OF 18570WHEN 0:rotate%=1:vflip%=NOTvflip% 18580WHEN -1:rotate%=0:vflip%=NOTvflip% 18590WHEN 1:rotate%=0:hflip%=NOThflip% 18600ENDCASE 18610WHEN 180:hflip%=NOThflip%:vflip%=NOTvflip% 18620WHEN &800000B4:vflip%=NOTvflip% 18630WHEN 270 18640CASE rotate% OF 18650WHEN 0:rotate%=-1 18660WHEN 1:rotate%=0 18670WHEN -1:rotate%=0:vflip%=NOTvflip%:hflip%=NOThflip% 18680ENDCASE 18690WHEN &8000010E 18700CASE rotate% OF 18710WHEN 0:rotate%=-1:vflip%=NOTvflip% 18720WHEN 1:rotate%=0:vflip%=NOTvflip% 18730WHEN -1:rotate%=0:hflip%=NOThflip% 18740ENDCASE 18750OTHERWISE PANIC 18760ENDCASE 18780input=24:step24=3:rbo%=0:gbo%=1:bbo%=2:pcdcachesize%=32*1024 18790rowbytes%=sx%*3:PROCnopal:cache%=TRUE:pcdcache%=FNdim(pcdcachesize%) 18800info$="PhotoCD image, "+STR$sx%+" by "+STR$sy%+" pixels, 24 bits per pixel" 18810WHEN 3700 18820A%=OPENIN"<ChangeFSI$Dir>.CFSIjpeg":jpeg%=FNdim(EXT#A%) 18830SYS12,4,A%,jpeg%,EXT#A%:CLOSE#A% 18840datacache%=FNcachedim(EXT#c%):IFdatacache%=-1 datacache%=FNdim(EXT#c%) 18850PTR#c%=0:SYS12,4,c%,datacache%,EXT#c% 18860A%=datacache%:B%=jpegblk%:C%=jpegblk%+4:D%=jpegblk%+8:E%=jpegblk%+12:CALLjpeg%+8 18870B%=jpegblk%!12:jpegspace%=FNdim(B%) 18880C%=datacache%:A%=jpegspace%:D%=EXT#c% 18890CALLjpeg%:cache%=FALSE:IF!A% ERROR42,"JPEG code error: "+STR$!A% 18900sx%=A%!20:sy%=A%!24:input=8*A%?28:PROCnopal:step24=4 18910info$="JFIF image, "+STR$sx%+" by "+STR$sy%+" pixels, "+FNbits(input) 18920jpegy%=sy%:r$="FN"+STR$INT(3700+input) 18930WHEN 3800 18940PTR#c%=24:sx%=FNW:sy%=FNW 18950IFscale% ymul%=ymul%*2 18960DIM rpal%(255),gpal%(255),bpal%(255),table%(255) 18970FORC%=0TO255 18980IFC%<128 table%(C%)=C%/127*F 18990D%=C%:IFD%AND128 D%-=256 19000r%(C%)=INT(D%/160*F):b%(C%)=INT(D%/126*F) 19010g%(C%)=INT(-D%/160*rwt/gwt*F):gpal%(C%)=INT(-D%/126*bwt/gwt*F) 19020NEXT 19040PTR#c%=52:st%=FNW:PTR#c%=64:cache%=TRUE:rowbytes%=2*sx%:input=411 19050info$="Uncompressed Techno-I YUV file "+STR$sx%+" by "+STR$sy%+" pixels" 19060WHEN 3900 19070PTR#c%=8:sx%=FNW:sy%=FNW:st%=16:quant%=12:step24=6 19080FORC%=0TO4095:r%(C%)=C%/4095*F:NEXT:g%()=r%():b%()=r%() 19090input=48:rowbytes%=sx%*6:cache%=TRUE:r$="FN24":rbo%=0:gbo%=2:bbo%=4 19100info$="Ronald Alpiar format, "+STR$sx%+" by "+STR$sy%+" pixels, 36 bits per pixel" 19110WHEN 3905 19120PTR#c%=8:sx%=FNW:sy%=FNW:st%=16:quant%=16:step24=6 19130FORC%=0TO65535:r%(C%)=C%/65535*F:NEXT:g%()=r%():b%()=r%() 19140input=48:rowbytes%=sx%*6:cache%=TRUE:r$="FN24":rbo%=0:gbo%=2:bbo%=4 19150info$="Ronald Alpiar format, "+STR$sx%+" by "+STR$sy%+" pixels, 48 bits per pixel" 19160WHEN 666 19270st%=0:PTR#c%=0:sx%=160:sy%=128:input=8:cache%=TRUE:rowbytes%=sx% 19280FORC%=0TO255:r%(C%)=C%/255*F:NEXT:g%()=r%():b%()=r%():r$="FN8" 19290info$="The number of the beast, 160 by "+STR$sy%+" pixels, 8 bits per pixel" 19300ENDCASE 19310IFinfo% PRINTinfo$ 19320SYS"Hourglass_On",1:hour%=&406c4 19330IFm=-9 OR m=-10 THEN 19340SYS"XOS_CLI","rmensure CompressJPEG 0 rmload System:Modules.jcompmod" 19350SYS"XOS_CLI","rmensure CompressJPEG 0 IF ""<ChangeFSI$Dir>"" <> """" THEN rmload <ChangeFSI$Dir>.jcompmod" 19360*rmensure CompressJPEG 0 ERROR Can't find CompressJPEG module. 19370ENDIF 19380IFinvert% r%()=F-r%():g%()=F-g%():b%()=F-b%() 19390IFxdiv% PROCreduce(xmul%,xdiv%) 19400IFydiv% PROCreduce(ymul%,ydiv%) 19410CASE m OF 19420WHEN -1:x%=256:y%=256:ncol=256:IFscaleo% xdiv%=xdiv%*2:ydiv%=ydiv%*2 19430WHEN -2:x%=sx%:y%=sy%:IFspm=18 ncol=1 ELSEncol=15 19440WHEN -3,-5,-6:x%=sx%:y%=sy%:ncol=2^15-1 19450WHEN -4,-7,-8:x%=sx%:y%=sy%:ncol=2^24-1 19460WHEN -9,-10:x%=sx%:y%=sy%:ncol=2^24-1:IFm=-9 ncol=256 19470OTHERWISE 19480SYS53,m,4 TO ,,nx:SYS53,m,5 TO ,,ny:nx=1<<nx:ny=1<<ny 19490SYS53,m,11 TO ,,x%:SYS53,m,12 TO ,,y%:x%+=1:y%+=1 19500SYS53,m,3 TO ,,ncol:IFscaleo% THEN 19510IFrotate% THEN 19520xdiv%=xdiv%*ny:ydiv%=ydiv%*nx 19530IFxdiv% ymul%=ymul%*2 19540IFydiv% xmul%=xmul%*2 19550ELSE 19560xdiv%=xdiv%*nx:ydiv%=ydiv%*ny 19570IFxdiv% xmul%=xmul%*2 19580IFydiv% ymul%=ymul%*2 19590ENDIF 19600ENDIF 19610SYS&62A51,m TO r0;V:IF(V AND1)=0 THEN 19630IFr0=1 THEN 19640ncol=255:IFm$<>"D" m$="R" 19650ENDIF 19660ENDIF 19670ENDCASE 19680IFm=-6 OR m=-7 OR m=-8 THEN 19690nx=VALMID$(pnm$,5):ny=VALMID$(pnm$,INSTR(pnm$,",",5)+1) 19700IFscaleo% THEN 19710IFrotate% THEN 19720IFxdiv% ymul%=ymul%*nx 19730IFydiv% xmul%=xmul%*ny 19740ELSE 19750IFxdiv% xmul%=xmul%*nx 19760IFydiv% ymul%=ymul%*ny 19770ENDIF 19780xdiv%=xdiv%*90:ydiv%=ydiv%*90 19790ENDIF 19800ENDIF 19810IFrotate% SWAP x%,y% 19830IFxdiv%=0 xdiv%=sx% 19840IFydiv%=0 ydiv%=sy% 19850IFxs$="=" xmul%=x%:xdiv%=sx% 19860IFys$="=" ymul%=y%:ydiv%=sy% 19870IFlock% THEN 19880IFxmul%/xdiv%>ymul%/ydiv% xmul%=ymul%:xdiv%=ydiv% ELSEymul%=xmul%:ydiv%=xdiv% 19890ENDIF 19900IFncol=1 THEN 19910CASE m$ OF 19920WHEN"C":xdiv%=xdiv%*4:ydiv%=ydiv%*4 19930DIM A%(16),B%(16) 19940A%()=0,&00000001,&08000001,&08000101,&08080101,&08080103,&0C080103,&0C080303,&0C0C0303,&0C0E0303,&0C0E0703,&0E0E0703,&0E0E0707,&0E0F0707,&0E0F0F07,&0F0F0F07,&0F0F0F0F 19950B%()=0,&00000008,&01000008,&01000808,&01010808,&0101080C,&0301080C,&03010C0C,&03030C0C,&03070C0C,&03070E0C,&07070E0C,&07070E0E,&070F0E0E,&070F0F0E,&0F0F0F0E,&0F0F0F0F 19960even_gard=FNdim(17*32*4):odd_gard=FNdim(17*32*4) 19970FORI%=0TO16:FORJ%=0TO16:even_gard!(J%*32*4+I%*4)=A%(I%)ORB%(J%)<<4:NEXT:NEXT 19980FORI%=0TO16:FORJ%=0TO16:odd_gard!(I%*32*4+J%*4)=B%(I%)ORA%(J%)<<4:NEXT:NEXT 19990WHEN"T":xdiv%=xdiv%*3:ydiv%=ydiv%*3 20000DIM A%(9),B%(9) 20010A%()=0,&0001,&4001,&4041,&4043,&40C3,&60C3,&61C3,&71C3,&71C7 20020B%()=0,&0004,&1004,&1104,&1106,&1186,&3186,&31C6,&71C6,&71C7 20030even_gard=FNdim(10*16*4):odd_gard=FNdim(10*16*4) 20040FORI%=0TO9:FORJ%=0TO9:even_gard!(J%*16*4+I%*4)=A%(I%)ORB%(J%)<<3:NEXT:NEXT 20050FORI%=0TO9:FORJ%=0TO9:odd_gard!(I%*16*4+J%*4)=B%(I%)ORA%(J%)<<3:NEXT:NEXT 20060WHEN"D":xdiv%=xdiv%*2:ydiv%=ydiv%*2 20070DIM A%(4),B%(4) 20080A%()=0,&1,&21,&31,&33 20090B%()=0,&2,&12,&32,&33 20100even_gard=FNdim(5*8):odd_gard=FNdim(5*8) 20110FORI%=0TO4:FORJ%=0TO4:even_gard?(J%*8+I%)=A%(I%)ORB%(J%)<<2:NEXT:NEXT 20120FORI%=0TO4:FORJ%=0TO4:odd_gard?(I%*8+J%)=B%(I%)ORA%(J%)<<2:NEXT:NEXT 20130ENDCASE 20140ENDIF 20150REPEAT 20160PROCreduce(xmul%,xdiv%):PROCreduce(ymul%,ydiv%) 20170IFxdiv%*ydiv%*255>2^32 xdiv%=xdiv%ANDNOT1:ydiv%=ydiv%ANDNOT1:xmul%=xmul%ANDNOT1:ymul%=ymul%ANDNOT1 20180UNTILxdiv%*ydiv%*255<2^32 20190IFinfo% PRINT"Size ratios are x ";xmul%":"xdiv%" y "ymul%":"ydiv% 20200x%=sx%*xmul%/xdiv%+.9999:y%=sy%*ymul%/ydiv%+.9999:rows%=sy% 20210order%=x%*y%>sx%*sy% 20220code%=FNdim(8192):SP=13 20230IFcache% THEN 20240PROCcachesize(code%) 20250IFcachebytes% THEN 20260filesize%=EXT#c%-PTR#c%:IFcache%>filesize% cache%=filesize% 20270IFcachebytes%>0 IFcache%>cachebytes% cache%=cachebytes% 20280cacherows%=cache% 20290ELSE 20300filesize%=sy%*rowbytes%:IFcache%<rowbytes% cache%=rowbytes% 20310IFcache%>filesize% cache%=filesize% 20320cacherows%=striprows%:IFcacherows%<1 cacherows%=cache%DIVrowbytes% 20330cache%=cacherows%*rowbytes% 20340ENDIF 20350datacache%=FNcachedim(cache%):IFdatacache%=-1 datacache%=FNdim(cache%) 20360ENDIF 20370IFncol=255 IFm$<>"D" m$="R" 20380IFm$="R" OR(ncol=63 ANDm$="") THEN 20390SYS53,-1,3 TO,,J%:IFncol=255 AND MODE=m J%=ncol 20400IFncol=63 AND(m$=""ORm$="R") J%=ncol 20410IFJ%<>ncol PROCclose:ERROR42,"You must be in a "+STR$(ncol+1)+" colour mode to do this" 20420J%=ncol:IFJ%=63 J%=255 20430palette%=FNdim((J%+1)*4) 20440IFncol=255 THEN 20450SYS"ColourTrans_ReadPalette",-1,-1,palette%,256*4 20460FORI%=0TO255:palette%!(I%<<2)=palette%!(I%<<2)>>>8:NEXT 20470ELSE 20480IFncol=63 THEN 20490FORI%=0TO255 20500palette%!(I%<<2)=(I%AND7 OR (I%AND16)>>1)*17 20510palette%?(I%<<2 OR1)=(I%AND3 OR (I%AND&60)>>3)*17 20520palette%?(I%<<2 OR2)=(I%AND3 OR (I%AND8)>>1 OR (I%AND128)>>4)*17 20530NEXT 20540ELSE 20550FORI%=0TOncol:SYS"OS_ReadPalette",I%,16 TO ,,i%:palette%!(I%<<2)=i%>>>8:NEXT 20560ENDIF 20570ENDIF 20580t%=TRUE:k%=palette%+1:nk%=palette%+2 20590FORI%=0TOncol*4STEP4 20600IFpalette%?I%<>k%?I% OR palette%?I%<>nk%?I% t%=FALSE 20610NEXT 20620IFncol>16 IFt% m$="D" 20630IFncol=15 IFt% m$="T" 20640IFm$="R" THEN 20650IF sx%*xmul%/xdiv%*sy%*ymul%/ydiv%<200000 k%=3 ELSEk%=4 20660nk%=8-k% 20670t%=1<<nk% 20680mask%=t%-1 20690td2%=1<<nk%-1 20700step%=1<<(8-k%) 20710ncol%=ncol+1:IFncol%=64 ncol%=256 20720ict%=FNdim(2^(k%*3)*4-1) 20730IFcache%<8192*6 scratch%=FNdim(8192*6):scratchsz%=8192*6 ELSEscratch%=datacache%:scratchsz%=cache% 20740IFinfo% PRINT"Begin table generation with ";scratchsz%" bytes." 20750FORZ%=0TO2STEP2 20760P%=code% 20770[OPT Z% 20780.make% 20790STMFD r13!,{r14} 20800LDR r4,ict 20810MOV r2,#step%/2 20820.blueloop 20830MOV r1,#step%/2 20840.greenloop 20850MOV r0,#step%/2 20860.redloop 20880MOV r3,r0,LSR #nk% 20890MOV r14,r1,LSR #nk% 20900MOV r5,r2,LSR #nk% 20910ORR r3,r3,r14,LSL #k% 20920ORR r3,r3,r5,LSL #k%*2 20930BL devious 20940ADD r0,r0,#step%*2 20950CMP r0,#256 20960BCC redloop 20970ADD r1,r1,#step% 20980CMP r1,#256 20990BCC greenloop 21000ADD r2,r2,#step% 21010CMP r2,#256 21020BCC blueloop 21030LDMFD r13!,{pc}^ 21040.ct DCD palette% 21050.min DCD code%+8192-256*2*4 21060.ict DCD ict% 21070.fsaad DCD scratch% 21080.fsalim DCD scratch%+scratchsz% 21090.devious 21100STMFD r13!,{r0,r1,r2,r3,r4,r8,r14} 21110BIC r0,r0,#(mask%<<1)+1 21120BIC r1,r1,#mask% 21130BIC r2,r2,#mask% 21160MOV r5,#0 21170LDR r6,ct 21180MOV r9,#&ff0000 21190MOV r14,#&ff0000 21200LDR r12,min 21210.devloop 21220LDR r7,[r6,r5,LSL #2] 21230MOV r8,r7,lsr #16 21240BIC r10,r8,#mask% 21250ADD r11,r2,#t% 21260CMP r10,r2 21270BEQ blueequal 21280SUBCC r10,r2,r8 21290SUBCC r11,r11,r8 21300SUBCS r10,r8,r11 21310SUBCS r11,r8,r2 21320MUL r3,r10,r10 21330.doneblue 21340MUL r4,r11,r11 21350MOV r8,r7,lsr #8 21360AND r8,r8,#255 21370BIC r10,r8,#mask% 21380ADD r11,r1,#t% 21390CMP r10,r1 21400BEQ greenequal 21410SUBCC r10,r1,r8 21420SUBCC r11,r11,r8 21430SUBCS r10,r8,r11 21440SUBCS r11,r8,r1 21460MUL r8,r10,r10 21470ADD r8,r8,r8,LSL #2 21480ADD r3,r3,r8,LSL #1 21490.donegreen 21500MUL r8,r11,r11 21510ADD r8,r8,r8,LSL #2 21520ADD r4,r4,r8,LSL #1 21540AND r8,r7,#255 21560BIC r10,r8,#mask% 21570ADD r11,r0,#t% 21580CMP r10,r0 21590BEQ redequal0 21600SUBCC r10,r0,r8 21610SUBCC r11,r11,r8 21620SUBCS r10,r8,r11 21630SUBCS r11,r8,r0 21650MUL r7,r10,r10 21660ADD r7,r7,r7,LSL #1 21670ADD r7,r3,r7 21680STR r7,[r12,r5,LSL #2] 21690.donered0 21700MUL r7,r11,r11 21710ADD r7,r7,r7,LSL #1 21720ADD r7,r4,r7 21740CMP r7,r9 21750MOVCC r9,r7 21770ADD r7,r0,#t% 21780BIC r10,r8,#mask% 21790ADD r11,r7,#t% 21800CMP r10,r7 21810BEQ redequal1 21820SUBCC r10,r7,r8 21830SUBCC r11,r11,r8 21840SUBCS r10,r8,r11 21850SUBCS r11,r8,r7 21860MUL r7,r10,r10 21870ADD r7,r7,r7,LSL #1 21880ADD r3,r3,r7 21900.donered1 21910ADD r7,r5,#ncol% 21920STR r3,[r12,r7,LSL #2] 21930MUL r7,r11,r11 21940ADD r7,r7,r7,LSL #1 21950ADD r7,r4,r7 21970CMP r7,r14 21980MOVCC r14,r7 21990ADD r5,r5,#1 22000CMP r5,#ncol% 22010BCC devloop 22020LDMFD r13!,{r0,r1,r2,r3,r4} 22040LDR r5,fsaad 22050MOV r7,r5 22060MOV r10,#0 22070.calcnum0 22080LDMIA r12!,{r8,r11} 22090CMP r8,r9 22100STRLEB r10,[r7],#1 22110ADD r10,r10,#1 22120CMP r11,r9 22130STRLEB r10,[r7],#1 22140ADD r10,r10,#1 22150LDMIA r12!,{r8,r11} 22160CMP r8,r9 22170STRLEB r10,[r7],#1 22180ADD r10,r10,#1 22190CMP r11,r9 22200STRLEB r10,[r7],#1 22210ADD r10,r10,#1 22220CMP r10,#ncol% 22230BCC calcnum0 22240SUBS r10,r7,r5 22250SWIEQ 256+ASC"A" 22260CMP r10,#4 ;if<4 then 22270MOVCC r7,r5 ;reset list pointer 22280LDRCCB r5,[r7] ;first possible 22290LDRCCB r8,[r7,#1] ;second possible 22300ORRCC r5,r5,r8,lsl #8 22310LDRCCB r8,[r7,#2] ;third possible 22320ORRCC r5,r5,r8,lsl #16 22330ADD r5,r5,r10,lsl #24 22340BIC r10,r3,#1 22350STR r5,[r4,r10,LSL #2] 22360MOV r5,r7 22370MOV r10,#0 22380.calcnum1 22390LDMIA r12!,{r8,r11} 22400CMP r8,r14 22410STRLEB r10,[r7],#1 22420ADD r10,r10,#1 22430CMP r11,r14 22440STRLEB r10,[r7],#1 22450ADD r10,r10,#1 22460LDMIA r12!,{r8,r11} 22470CMP r8,r14 22480STRLEB r10,[r7],#1 22490ADD r10,r10,#1 22500CMP r11,r14 22510STRLEB r10,[r7],#1 22520ADD r10,r10,#1 22530CMP r10,#ncol% 22540BCC calcnum1 22550SUBS r10,r7,r5 22560SWIEQ 256+ASC"B" 22570CMP r10,#4 ;if<4 then 22580MOVCC r7,r5 22590LDRCCB r5,[r7] 22600LDRCCB r8,[r7,#1] 22610ORRCC r5,r5,r8,lsl #8 22620LDRCCB r8,[r7,#2] 22630ORRCC r5,r5,r8,lsl #16 22640ADD r5,r5,r10,lsl #24 22650ORR r10,r3,#1 22660STR r5,[r4,r10,LSL #2] 22670STR r7,fsaad 22680LDR r8,fsalim 22690CMP r7,r8 22700SWICS 256+ASC"!" 22710LDMFD r13!,{r8,pc}^ 22720.redequal0 22730STR r3,[r12,r5,LSL #2] 22740TST r8,#td2% 22750SUBNE r11,r8,r0 22760SUBEQ r11,r11,r8 22770B donered0 22780.redequal1 22790TST r8,#td2% 22800SUBNE r11,r8,r7 22810SUBEQ r11,r11,r8 22820B donered1 22830.greenequal 22840TST r8,#td2% 22850SUBNE r11,r8,r1 22860SUBEQ r11,r11,r8 22870B donegreen 22880.blueequal 22890MOV r3,#0 22900TST r8,#td2% 22910SUBNE r11,r8,r2 22920SUBEQ r11,r11,r8 22930B doneblue 22940] 22950NEXT 22960I%=TIME:CALLmake% 22970IFinfo% PRINT"Generated 'r'";k%" tables for ";ncol%" colours using ";!fsaad-scratch%" bytes, taking "TIME-I%" cS" 22980safesubict%=FNdim(!fsaad-scratch%) 22990FORI%=0TO!fsaad-scratch%+4STEP4:safesubict%!I%=scratch%!I%:NEXT 23000FORI%=0TO2^(k%*3)*4-1STEP4:IF(ict%!I%>>>24)>3 ict%!I%=ict%!I%-scratch%+safesubict% 23010NEXT 23020ENDIF 23030ENDIF 23040IFfast% IFMODE<>0 MODE0 23060CASE m OF 23070WHEN -1,-9:col=0 23080WHEN -3,-4,-5,-6,-7,-8,-10:col=2 23090OTHERWISE 23100IFm$="D" IFncol=3 m$="" 23110col=0:IFncol>15 ORm$="C" ORm$="D" ORm$="R" col=2 23120IFncol=63 OR ncol=255 IFm$="D" col=0:ncol=256 23130ENDCASE 23140IFncol=1 THEN 23150CASE m$ OF 23160WHEN"C":col=0:x%=x%+1ANDNOT1 23170WHEN"D":col=0:x%=x%+3ANDNOT3 23180WHEN"T":col=0:x%=x%+1ANDNOT1 23190ENDCASE 23200ENDIF 23210DIM cl%(x%+7,col) 23220DIM xl%(x%+7,col),xp%(sx%+7,col) 23230DIM xl2%(x%+7,col) 23240IFsharpen% THEN 23250IForder% THEN 23260DIM rm%(sx%+7,col),rm1%(sx%+7,col),rm2%(sx%+7,col) 23270ELSE 23280DIM rm%(x%+7,col),rm1%(x%+7,col),rm2%(x%+7,col) 23290ENDIF 23300ENDIF 23310IFhist%ORequal% DIM vals%(256,col) 23320DIM nl%(x%+7,col) 23330totvals%=x%*(col+1) 23340totvals2%=sx%*(col+1) 23350FORZ=0TO2STEP2:P%=code% 23360CASE ncol OF 23370WHEN 2^24-1 23380[OPT Z 23390.div255 23400] 23410FORI%=0TO2^p6bits-1 23420[OPT Z 23430EQUD I%/(2^p6bits-1)*F 23440] 23450NEXT 23460[OPT Z 23470.fs% 23480STMFD SP !,{R14} 23490LDR R1,[R9,#5*8]:LDR R1,[R1] 23500LDR R10,[R9,#4*8] 23510LDR R11,[R9,#3*8] 23520LDR R12,[R9,#2*8]:LDR R12,[R12] 23530LDR R8,[R9,#8]:LDR R8,[R8] 23540LDR R9,[R9]:LDR R9,[R9] 23550LDR R4,[R10] 23560LDR R5,[R10,#4] 23570LDR R6,[R10,#8] 23580ADR R7,div255 23590.fsloop 23600ADD R10,R10,R8 23610CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 23620SUB R0,R4,R4,LSR #p6bits:ADD R0,R0,#1<<(bits-p6bits-1):MOV R0,R0,LSR #(bits-p6bits) 23630LDR R2,[R7,R0,LSL #2]:SUB R4,R4,R2 23640CMP R5,#F:MOVCS R5,#0:MOVGE R5,#F 23650SUB R3,R5,R5,LSR #p6bits:ADD R3,R3,#1<<(bits-p6bits-1):MOV R3,R3,LSR #(bits-p6bits):ORR R0,R0,R3,LSL #8 23660LDR R2,[R7,R3,LSL #2]:SUB R5,R5,R2 23670CMP R6,#F:MOVCS R6,#0:MOVGE R6,#F 23680SUB R3,R6,R6,LSR #p6bits:ADD R3,R3,#1<<(bits-p6bits-1):MOV R3,R3,LSR #(bits-p6bits):ORR R0,R0,R3,LSL #16 23690LDR R2,[R7,R3,LSL #2]:SUB R6,R6,R2 23700STRB R0,[R12]:MOV R0,R0,LSR #8:STRB R0,[R12,#1]:MOV R0,R0,LSR #8 23710STRB R0,[R12,#2] 23720] 23730IFm=-8 THEN 23740[OPT Z 23750ADD R12,R12,R1,LSL #2 23760] 23770ELSE 23780[OPT Z 23790ADD R12,R12,R1,LSL #1:ADD R12,R12,R1 23800] 23810ENDIF 23820IFdither% THEN 23830[OPT Z 23840ADD R0,R11,#4 23850ADD R2,R4,R4,LSL #1 23860LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 23870STR R3,[R11,-R8] 23880ADD R2,R4,R4,LSL #2 23890LDR R3,[R11]:ADD R3,R3,R2,ASR #4 23900STR R3,[R11] 23910MOV R3,R4,ASR #4 23920STR R3,[R11,R8]! 23930RSB R2,R4,R4,LSL #3 23940LDR R4,[R10] 23950ADD R4,R4,R2,ASR #4 23960ADD R2,R5,R5,LSL #1 23970LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 23980STR R3,[R0,-R8] 23990MOV R3,R5,ASR #4 24000STR R3,[R0,R8] 24010ADD R2,R5,R5,LSL #2 24020LDR R3,[R0]:ADD R3,R3,R2,ASR #4 24030STR R3,[R0],#4 24040RSB R2,R5,R5,LSL #3 24050LDR R5,[R10,#4] 24060ADD R5,R5,R2,ASR #4 24070ADD R2,R6,R6,LSL #1 24080LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 24090STR R3,[R0,-R8] 24100ADD R2,R6,R6,LSL #2 24110LDR R3,[R0]:ADD R3,R3,R2,ASR #4 24120STR R3,[R0] 24130MOV R3,R6,ASR #4 24140STR R3,[R0,R8] 24150RSB R2,R6,R6,LSL #3 24160LDR R6,[R10,#8] 24170ADD R6,R6,R2,ASR #4 24180] 24190ELSE 24200[OPT Z 24210LDMIA R10,{R4,R5,R6} 24220] 24230ENDIF 24240[OPT Z 24250SUBS R9,R9,#1:BNE fsloop 24260LDMFD SP !,{PC}^ 24270] 24280WHEN 2^15-1 24290[OPT Z 24300.div31 24310] 24320FORI%=0TO31 24330[OPT Z 24340EQUD I%/31*F 24350] 24360NEXT 24370[OPT Z 24380.fs% 24390STMFD SP !,{R14} 24400LDR R1,[R9,#5*8]:LDR R1,[R1] 24410LDR R10,[R9,#4*8] 24420LDR R11,[R9,#3*8] 24430LDR R12,[R9,#2*8]:LDR R12,[R12] 24440LDR R8,[R9,#8]:LDR R8,[R8] 24450LDR R9,[R9]:LDR R9,[R9] 24460LDR R4,[R10] 24470LDR R5,[R10,#4] 24480LDR R6,[R10,#8] 24490ADR R7,div31 24500.fsloop 24510ADD R10,R10,R8 24520CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 24530SUB R0,R4,R4,LSR #5:ADD R0,R0,#1<<(bits-6):MOV R0,R0,LSR #(bits-5) 24540LDR R2,[R7,R0,LSL #2]:SUB R4,R4,R2 24550CMP R5,#F:MOVCS R5,#0:MOVGE R5,#F 24560SUB R3,R5,R5,LSR #5:ADD R3,R3,#1<<(bits-6):MOV R3,R3,LSR #(bits-5):ORR R0,R0,R3,LSL #5 24570LDR R2,[R7,R3,LSL #2]:SUB R5,R5,R2 24580CMP R6,#F:MOVCS R6,#0:MOVGE R6,#F 24590SUB R3,R6,R6,LSR #5:ADD R3,R3,#1<<(bits-6):MOV R3,R3,LSR #(bits-5):ORR R0,R0,R3,LSL #10 24600LDR R2,[R7,R3,LSL #2]:SUB R6,R6,R2 24610STRB R0,[R12]:MOV R0,R0,LSR #8:STRB R0,[R12,#1]:ADD R12,R12,R1,LSL #1 24620] 24630IFdither% THEN 24640[OPT Z 24650ADD R0,R11,#4 24660ADD R2,R4,R4,LSL #1 24670LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 24680STR R3,[R11,-R8] 24690ADD R2,R4,R4,LSL #2 24700LDR R3,[R11]:ADD R3,R3,R2,ASR #4 24710STR R3,[R11] 24720MOV R3,R4,ASR #4 24730STR R3,[R11,R8]! 24740RSB R2,R4,R4,LSL #3 24750LDR R4,[R10] 24760ADD R4,R4,R2,ASR #4 24770ADD R2,R5,R5,LSL #1 24780LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 24790STR R3,[R0,-R8] 24800MOV R3,R5,ASR #4 24810STR R3,[R0,R8] 24820ADD R2,R5,R5,LSL #2 24830LDR R3,[R0]:ADD R3,R3,R2,ASR #4 24840STR R3,[R0],#4 24850RSB R2,R5,R5,LSL #3 24860LDR R5,[R10,#4] 24870ADD R5,R5,R2,ASR #4 24880ADD R2,R6,R6,LSL #1 24890LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 24900STR R3,[R0,-R8] 24910ADD R2,R6,R6,LSL #2 24920LDR R3,[R0]:ADD R3,R3,R2,ASR #4 24930STR R3,[R0] 24940MOV R3,R6,ASR #4 24950STR R3,[R0,R8] 24960RSB R2,R6,R6,LSL #3 24970LDR R6,[R10,#8] 24980ADD R6,R6,R2,ASR #4 24990] 25000ELSE 25010[OPT Z 25020LDMIA R10,{R4,R5,R6} 25030] 25040ENDIF 25050[OPT Z 25060SUBS R9,R9,#1:BNE fsloop 25070LDMFD SP !,{PC}^ 25080] 25090WHEN 256 25100[OPT Z 25110.div255 25120] 25130FORI%=0TO255 25140[OPT Z 25150EQUD I%/255*F 25160] 25170NEXT 25180[OPT Z 25200.fs% 25210STMFD SP !,{R14} 25220LDR R10,[R9,#4*8] 25230ADR R7,div255 25240LDR R1,[R9,#5*8]:LDR R1,[R1] 25250LDR R11,[R9,#3*8] 25260LDR R12,[R9,#2*8]:LDR R12,[R12] 25270LDR R8,[R9,#8]:LDR R8,[R8] 25280LDR R9,[R9]:LDR R9,[R9] 25290LDR R4,[R10],R8 25300.fsloop 25310CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 25320SUB R0,R4,R4,LSR #8:ADD R0,R0,#1<<(bits-9):MOV R0,R0,LSR #(bits-8):STRB R0,[R12],R1 25330LDR R2,[R7,R0,LSL #2] 25340] 25350IFdither% THEN 25360[OPT Z 25370SUB R4,R4,R2 25380MOVCS R4,#0 25390ADD R2,R4,R4,LSL #1 25400LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 25410STR R3,[R11,-R8] 25420ADD R2,R4,R4,LSL #2 25430LDR R3,[R11]:ADD R3,R3,R2,ASR #4 25440STR R3,[R11] 25450MOV R3,R4,ASR #4 25460STR R3,[R11,R8]! 25470RSB R2,R4,R4,LSL #3 25480LDR R4,[R10],R8 25490ADD R4,R4,R2,ASR #4 25500] 25510ELSE 25520[OPT Z 25530LDR R4,[R10],R8 25540] 25550ENDIF 25560[OPT Z 25570SUBS R9,R9,#1:BNE fsloop 25580LDMFD SP !,{PC}^ 25590] 25600WHEN 63,255 25610div15=P%:FORI%=0TO255*4STEP4 25620[OPT Z 25630EQUD (palette%!I%AND&FF)/255*F 25640EQUD (palette%!I%>>8AND&FF)/255*F 25650EQUD (palette%!I%>>16AND&FF)/255*F 25660] 25670NEXT 25680IFm$="R" THEN 25690[OPT Z 25700.ictloc EQUD ict% 25710] 25720ENDIF 25730[OPT Z 25740EQUD div15 25750.fs% 25760STMFD SP !,{R14} 25770LDR R1,[R9,#5*8]:LDR R1,[R1] 25780LDR R10,[R9,#4*8] 25790LDR R11,[R9,#3*8] 25800LDR R12,[R9,#2*8]:LDR R12,[R12] 25810LDR R8,[R9,#8]:LDR R8,[R8] 25820LDR R9,[R9]:LDR R9,[R9] 25830LDR R4,[R10] 25840LDR R5,[R10,#4] 25850LDR R6,[R10,#8] 25860LDR R7,fs%-4 25870.fsloop 25880ADD R10,R10,R8 25890] 25900CASE m$ OF 25910WHEN"T" 25920[OPT Z 25930CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 25940MOV R0,R4,LSR #(bits-4):CMP R0,#15:MOVCS R0,#15 25950CMP R5,#F:MOVCS R5,#0:MOVGE R5,#F 25960MOV R3,R5,LSR #(bits-4):CMP R3,#15:MOVCS R3,#15:ORR R0,R0,R3,LSL #4 25970CMP R6,#F:MOVCS R6,#0:MOVGE R6,#F 25980MOV R3,R6,LSR #(bits-4):CMP R3,#15:MOVCS R3,#15:ORR R0,R0,R3,LSL #8 25990LDR R3,colmatchloc 26000LDRB R0,[R3,R0] 26010ADD R3,R0,R0,LSL #1:ADD R3,R7,R3,LSL #2 26020LDR R2,[R3],#4:SUB R4,R4,R2 26030LDMIA R3,{R2,R3}:SUB R5,R5,R2:SUB R6,R6,R3 26040] 26050WHEN"R" 26060PROCsrchdevlist 26070OTHERWISE 26080[OPT Z 26090CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 26100CMP R5,#F:MOVCS R5,#0:MOVGE R5,#F 26110CMP R6,#F:MOVCS R6,#0:MOVGE R6,#F 26120STMFD SP !,{R7,R8,R9} 26130MVN R2,#0 26140MOV R3,#&30<<23 26150.srch RSB R7,R3,#&20<<23 26160MOV R8,R6,LSR #bits-8 26170SUB R8,R8,R8,LSR #4 26180ADDS R7,R7,R8,LSL #23 26190MOVVSS R7,#&7F000000 26200MOVMI R7,#0 26210AND R7,R7,#&60000000 26220ADD R7,R7,R3 26230ADD R14,R7,R7,LSR #4 26240ADD R7,R14,R14,LSR #8 26250ADD R7,R7,R7,LSR #16 26260SUBS R8,R6,R7,LSR #31-bits 26270RSBLT R8,R8,#0 26280MOV R8,R8,LSR #bits/2 26290MUL R9,R8,R8 26300RSB R7,R3,#&20<<23 26310MOV R8,R5,LSR #bits-8 26320SUB R8,R8,R8,LSR #4 26330ADDS R7,R7,R8,LSL #23 26340MOVVSS R7,#&7F000000 26350MOVMI R7,#0 26360AND R7,R7,#&60000000 26370ADD R7,R3,R7 26380ADD R7,R7,R7,LSR #4 26390ORR R14,R14,R7,LSR #8 26400ADD R7,R7,R7,LSR #8 26410ADD R7,R7,R7,LSR #16 26420SUBS R8,R5,R7,LSR #31-bits 26430RSBLT R8,R8,#0 26440MOV R8,R8,LSR #bits/2 26450MUL R7,R8,R8 26460ADD R7,R7,R7,LSL #2 26470ADD R9,R9,R7,LSL #1 26480RSB R7,R3,#&20<<23 26490MOV R8,R4,LSR #bits-8 26500SUB R8,R8,R8,LSR #4 26510ADDS R7,R7,R8,LSL #23 26520MOVVSS R7,#&7F000000 26530MOVMI R7,#0 26540AND R7,R7,#&60000000 26550ADD R7,R3,R7 26560ADD R7,R7,R7,LSR #4 26570ORR R14,R14,R7,LSR #16 26580ADD R7,R7,R7,LSR #8 26590ADD R7,R7,R7,LSR #16 26600SUBS R8,R4,R7,LSR #31-bits 26610RSBLT R8,R8,#0 26620MOV R8,R8,LSR #bits/2 26630MUL R7,R8,R8 26640ADD R7,R7,R7,LSL #1 26650ADD R9,R9,R7 26660CMP R9,R2 26670MOVLS R2,R9 26680MOVLS R0,R14 26690SUBS R3,R3,#&10<<23 26700BGE srch 26710AND R7,R0,#&40000000 26720MOV R8,R7,LSR #23 26730AND R7,R0,#&600000 26740ORR R8,R8,R7,LSR #16 26750AND R7,R0,#&4000 26760ORR R8,R8,R7,LSR #10 26770AND R7,R0,#&20000000 26780ORR R8,R8,R7,LSR #26 26790AND R7,R0,#&3800 26800ORR R0,R8,R7,LSR #11 26810LDMFD SP !,{R7,R8,R9} 26820ADD R3,R0,R0,LSL #1:ADD R3,R7,R3,LSL #2 26830LDR R2,[R3],#4:SUB R4,R4,R2 26840LDMIA R3,{R2,R3}:SUB R5,R5,R2:SUB R6,R6,R3 26850] 26860ENDCASE 26870[OPT Z 26880STRB R0,[R12],R1 26890] 26900IFdither% THEN 26910[OPT Z 26920ADD R0,R11,#4 26930ADD R2,R4,R4,LSL #1 26940LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 26950STR R3,[R11,-R8] 26960ADD R2,R4,R4,LSL #2 26970LDR R3,[R11]:ADD R3,R3,R2,ASR #4 26980STR R3,[R11] 26990MOV R3,R4,ASR #4 27000STR R3,[R11,R8]! 27010RSB R2,R4,R4,LSL #3 27020LDR R4,[R10] 27030ADD R4,R4,R2,ASR #4 27040ADD R2,R5,R5,LSL #1 27050LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 27060STR R3,[R0,-R8] 27070MOV R3,R5,ASR #4 27080STR R3,[R0,R8] 27090ADD R2,R5,R5,LSL #2 27100LDR R3,[R0]:ADD R3,R3,R2,ASR #4 27110STR R3,[R0],#4 27120RSB R2,R5,R5,LSL #3 27130LDR R5,[R10,#4] 27140ADD R5,R5,R2,ASR #4 27150ADD R2,R6,R6,LSL #1 27160LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 27170STR R3,[R0,-R8] 27180ADD R2,R6,R6,LSL #2 27190LDR R3,[R0]:ADD R3,R3,R2,ASR #4 27200STR R3,[R0] 27210MOV R3,R6,ASR #4 27220STR R3,[R0,R8] 27230RSB R2,R6,R6,LSL #3 27240LDR R6,[R10,#8] 27250ADD R6,R6,R2,ASR #4 27260] 27270ELSE 27280[OPT Z 27290LDMIA R10,{R4,R5,R6} 27300] 27310ENDIF 27320[OPT Z 27330SUBS R9,R9,#1:BNE fsloop 27340LDMFD SP !,{PC}^ 27350] 27360WHEN 15 27370divtable=P%:CASE m$ OF 27380WHEN "D" 27390WHEN "R" 27400FORI%=0TO15*4STEP4 27410[OPT Z 27420EQUD (palette%!I%>>4AND&F)/bright%*F 27430EQUD (palette%!I%>>12AND&F)/bright%*F 27440EQUD (palette%!I%>>20AND&F)/bright%*F 27450] 27460NEXT 27470[OPT Z 27480.ictloc EQUD ict% 27490] 27500WHEN "T" 27510FORI%=0TO15 27520[OPT Z 27530EQUD I%/bright%*F 27540] 27550NEXT 27560OTHERWISE 27570FORI%=0TO7 27580[OPT Z 27590EQUD I%/(bright%DIV2)*F 27600] 27610NEXT 27620ENDCASE 27630[OPT Z 27640.fs% 27650STMFD SP !,{R14} 27660LDR R1,[R9,#5*8]:LDR R1,[R1] 27670LDR R10,[R9,#4*8] 27680LDR R11,[R9,#3*8] 27690LDR R12,[R9,#2*8]:LDR R12,[R12] 27700LDR R8,[R9,#8]:LDR R8,[R8] 27710LDR R9,[R9]:LDR R9,[R9] 27720] 27730IFm$="D" ORm$="R" THEN 27740[OPT Z 27750LDR R4,[R10] 27760LDR R5,[R10,#4] 27770LDR R6,[R10,#8] 27780] 27790ELSE 27800[OPT Z 27810LDR R4,[R10],R8 27820] 27830ENDIF 27840IFm$<>"D" THEN 27850[OPT Z 27860ADR R7,divtable 27870] 27880ENDIF 27890[OPT Z 27900.fsloop 27910] 27920CASE m$ OF 27930WHEN"R" 27940[OPT Z 27950ADD R10,R10,R8 27960] 27970PROCsrchdevlist 27980[OPT Z 27990MOV r3,r0 28000] 28010WHEN "D" 28020[OPT Z 28030ADD R10,R10,R8 28040MOV R3,#0 28050CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 28060CMP R4,#F>>1 28070SUBCS R4,R4,#F:ORRCS R3,R3,#1 28080CMP R5,#F:MOVCS R5,#0:MOVGE R5,#F 28090CMP R5,#F>>1 28100SUBCS R5,R5,#F:ORRCS R3,R3,#2 28110CMP R6,#F:MOVCS R6,#0:MOVGE R6,#F 28120CMP R6,#F>>1 28130SUBCS R6,R6,#F:ORRCS R3,R3,#4 28140] 28150WHEN "T" 28160[OPT Z 28170CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 28180RSB R3,R4,R4,LSL #4:ADD R3,R3,#F>>1:MOV R3,R3,LSR #bits 28190LDR R2,[R7,R3,LSL #2] 28200SUB R4,R4,R2 28210] 28220OTHERWISE 28230[OPT Z 28240CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 28250RSB R3,R4,R4,LSL #3:ADD R3,R3,#F>>1:MOV R3,R3,LSR #bits 28260LDR R2,[R7,R3,LSL #2] 28270SUB R4,R4,R2 28280] 28290ENDCASE 28300[OPT Z 28310MOV R2,R12,LSR #1 28320TST R12,#1 28330LDRB R0,[R2] 28340ANDEQ R0,R0,#&F0:ORREQ R0,R0,R3 28350ANDNE R0,R0,#&0F:ORRNE R0,R0,R3,LSL #4 28360STRB R0,[R2] 28370ADD R12,R12,R1 28380] 28390IFm$="D" ORm$="R" THEN 28400IFdither% THEN 28410[OPT Z 28420ADD R0,R11,#4 28430ADD R2,R4,R4,LSL #1 28440LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 28450STR R3,[R11,-R8] 28460ADD R2,R4,R4,LSL #2 28470LDR R3,[R11]:ADD R3,R3,R2,ASR #4 28480STR R3,[R11] 28490MOV R3,R4,ASR #4 28500STR R3,[R11,R8]! 28510RSB R2,R4,R4,LSL #3 28520LDR R4,[R10] 28530ADD R4,R4,R2,ASR #4 28540ADD R2,R5,R5,LSL #1 28550LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 28560STR R3,[R0,-R8] 28570MOV R3,R5,ASR #4 28580STR R3,[R0,R8] 28590ADD R2,R5,R5,LSL #2 28600LDR R3,[R0]:ADD R3,R3,R2,ASR #4 28610STR R3,[R0],#4 28620RSB R2,R5,R5,LSL #3 28630LDR R5,[R10,#4] 28640ADD R5,R5,R2,ASR #4 28650ADD R2,R6,R6,LSL #1 28660LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 28670STR R3,[R0,-R8] 28680ADD R2,R6,R6,LSL #2 28690LDR R3,[R0]:ADD R3,R3,R2,ASR #4 28700STR R3,[R0] 28710MOV R3,R6,ASR #4 28720STR R3,[R0,R8] 28730RSB R2,R6,R6,LSL #3 28740LDR R6,[R10,#8] 28750ADD R6,R6,R2,ASR #4 28760] 28770ELSE 28780[OPT Z 28790LDMIA R10,{R4,R5,R6} 28800] 28810ENDIF 28820ELSE 28830IFdither% THEN 28840[OPT Z 28850ADD R2,R4,R4,LSL #1 28860LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 28870STR R3,[R11,-R8] 28880ADD R2,R4,R4,LSL #2 28890LDR R3,[R11]:ADD R3,R3,R2,ASR #4 28900STR R3,[R11] 28910MOV R3,R4,ASR #4 28920STR R3,[R11,R8]! 28930RSB R2,R4,R4,LSL #3 28940LDR R4,[R10],R8 28950ADD R4,R4,R2,ASR #4 28960] 28970ELSE 28980[OPT Z 28990LDR R4,[R10],R8 29000] 29010ENDIF 29020ENDIF 29030[OPT Z 29040SUBS R9,R9,#1:BNE fsloop 29050LDMFD SP !,{PC}^ 29060] 29070WHEN 3 29080divtable=P%:CASE m$ OF 29090WHEN "C" 29100WHEN "R" 29110FORI%=0TO3*4STEP4 29120[OPT Z 29130EQUD (palette%!I%>>4AND&F)/bright%*F 29140EQUD (palette%!I%>>12AND&F)/bright%*F 29150EQUD (palette%!I%>>20AND&F)/bright%*F 29160] 29170NEXT 29180OTHERWISE 29190[OPT Z 29200EQUD 0 29210EQUD 1/(bright%DIV4)*F 29220EQUD 2/(bright%DIV4)*F 29230EQUD F 29240] 29250ENDCASE 29260[OPT Z 29270.fs% 29280STMFD SP !,{R14} 29290LDR R1,[R9,#5*8]:LDR R1,[R1] 29300LDR R10,[R9,#4*8] 29310LDR R11,[R9,#3*8] 29320LDR R12,[R9,#2*8] 29330LDR R12,[R12] 29340LDR R8,[R9,#8] 29350LDR R8,[R8] 29360LDR R9,[R9] 29370LDR R9,[R9] 29380] 29390IFm$="C" ORm$="R" THEN 29400[OPT Z 29410LDR R4,[R10] 29420LDR R5,[R10,#4] 29430LDR R6,[R10,#8] 29440] 29450ELSE 29460[OPT Z 29470LDR R4,[R10],R8 29480] 29490ENDIF 29500[OPT Z 29510.fsloop 29520] 29530IFm$<>"C"THEN 29540[OPT Z 29550ADR R7,divtable 29560] 29570ENDIF 29580CASE m$ OF 29590WHEN"C" 29600[OPT Z 29610ADD R10,R10,R8 29620CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 29630CMP R5,#F:MOVCS R5,#0:MOVGE R5,#F 29640CMP R6,#F:MOVCS R6,#0:MOVGE R6,#F 29650MOV R3,#0 29660CMP R4,#F>>1:ORRCS R3,R3,#1 29670CMP R5,#F>>1:ORRCS R3,R3,#2 29680CMP R6,#F>>1:ORRCS R3,R3,#4 29690CMP R3,#6:MOVEQ R3,#1:BEQ octcyan 29700BCS octwhite 29710CMP R3,#4:BEQ octblue 29720MOVCS R3,#2:BCS octmagenta 29730CMP R3,#2:BEQ octgreen 29740BCS octyellow 29750CMP R3,#0:BEQ octblack 29760.octred 29770RSB R0,R4,#F 29780CMP R5,R0 29790BLT octred1 29800CMP R5,R6 29810MOVGE R3,#3 29820MOVLT R3,#2 29830B octconvert 29840.octred1 29850CMP R0,R6 29860MOVGE R3,#0 29870MOVLT R3,#2 29880B octconvert 29890.octgreen 29900RSB R0,R5,#F 29910CMP R0,R4 29920BLT octgreen1 29930CMP R0,R6 29940MOVGE R3,#0 29950MOVLT R3,#1 29960B octconvert 29970.octgreen1 29980CMP R4,R6 29990MOVGE R3,#3 30000MOVLT R3,#1 30010B octconvert 30020.octblue 30030RSB R0,R6,#F 30040CMP R0,R4 30050BLT octblue1 30060CMP R0,R5 30070MOVGE R3,#0 30080MOVLT R3,#1 30090B octconvert 30100.octblue1 30110CMP R4,R5 30120MOVGE R3,#2 30130MOVLT R3,#1 30140B octconvert 30150.octwhite 30160CMP R4,R5 30170BLT octwhite1 30180CMP R5,R6 30190MOVGE R3,#3 30200MOVLT R3,#2 30210B octconvert 30220.octwhite1 30230CMP R4,R6 30240MOVGE R3,#3 30250MOVLT R3,#1 30260.octconvert 30270CMP R3,#1 30280.octcyan 30290SUBEQ R5,R5,#F 30300SUBEQ R6,R6,#F 30310.octmagenta 30320CMP R3,#2 30330SUBEQ R4,R4,#F 30340SUBEQ R6,R6,#F 30350.octyellow 30360CMP R3,#3 30370SUBEQ R4,R4,#F 30380SUBEQ R5,R5,#F 30390.octblack 30400MOV R2,R12,LSR #2 30410AND R7,R12,#3:MOV R7,R7,LSL #1 30420MOV R14,#3 30430LDRB R0,[R2]:BIC R0,R0,R14,LSL R7:ORR R0,R0,R3,LSL R7:STRB R0,[R2] 30440ADD R12,R12,R1 30450] 30460WHEN"R" 30470[OPT Z 30480ADD R10,R10,R8 30490CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 30500CMP R5,#F:MOVCS R5,#0:MOVGE R5,#F 30510CMP R6,#F:MOVCS R6,#0:MOVGE R6,#F 30520STMFD SP !,{R8,R9,R10} 30530MVN R2,#0 30540MOV R3,#3 30550.srch ADD R14,R3,R3,LSL #1 30560ADD R14,R7,R14,LSL #2 30570LDMIA R14,{R8,R9,R10} 30580SUBS R8,R4,R8 30590RSBMI R8,R8,#0 30600SUBS R9,R5,R9 30610RSBMI R9,R9,#0 30620SUBS R10,R6,R10 30630RSBMI R10,R10,#0 30640MOV R14,R8,LSR #bits/2 30650MUL R8,R14,R14 30660MOV R14,R9,LSR #bits/2 30670MUL R9,R14,R14 30680MOV R14,R10,LSR #bits/2 30690MUL R10,R14,R14 30700ADD R9,R9,R9,LSL #2 30710ADD R8,R8,R8,LSL #1 30720ADD R14,R8,R9,LSL #1 30730ADD R14,R14,R10 30740CMP R14,R2 30750MOVCC R2,R14 30760MOVCC R0,R3 30770SUBS R3,R3,#1 30780BPL srch 30790LDMFD SP !,{R8,R9,R10} 30800ADD R3,R0,R0,LSL #1:ADD R3,R7,R3,LSL #2 30810LDR R2,[R3],#4:SUB R4,R4,R2 30820LDMIA R3,{R2,R3}:SUB R5,R5,R2:SUB R6,R6,R3 30830MOV R3,R0 30840MOV R2,R12,LSR #2 30850AND R7,R12,#3:MOV R7,R7,LSL #1 30860MOV R14,#3 30870LDRB R0,[R2]:BIC R0,R0,R14,LSL R7:ORR R0,R0,R3,LSL R7:STRB R0,[R2] 30880ADD R12,R12,R1 30890] 30900OTHERWISE 30910[OPT Z 30920CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 30930RSB R3,R4,R4,LSL #2:ADD R3,R3,#F>>1:MOV R3,R3,LSR#bits 30940LDR R2,[R7,R3,LSL #2] 30950SUB R4,R4,R2 30960MOV R2,R12,LSR #2 30970AND R5,R12,#3:MOV R5,R5,LSL #1 30980MOV R6,#3 30990LDRB R0,[R2]:BIC R0,R0,R6,LSL R5:ORR R0,R0,R3,LSL R5:STRB R0,[R2] 31000ADD R12,R12,R1 31010] 31020ENDCASE 31030IFm$="C" ORm$="R" THEN 31040IFdither% THEN 31050[OPT Z 31060ADD R0,R11,#4 31070ADD R2,R4,R4,LSL #1 31080LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 31090STR R3,[R11,-R8] 31100ADD R2,R4,R4,LSL #2 31110LDR R3,[R11]:ADD R3,R3,R2,ASR #4 31120STR R3,[R11] 31130MOV R3,R4,ASR #4 31140STR R3,[R11,R8]! 31150RSB R2,R4,R4,LSL #3 31160LDR R4,[R10] 31170ADD R4,R4,R2,ASR #4 31180ADD R2,R5,R5,LSL #1 31190LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 31200STR R3,[R0,-R8] 31210MOV R3,R5,ASR #4 31220STR R3,[R0,R8] 31230ADD R2,R5,R5,LSL #2 31240LDR R3,[R0]:ADD R3,R3,R2,ASR #4 31250STR R3,[R0],#4 31260RSB R2,R5,R5,LSL #3 31270LDR R5,[R10,#4] 31280ADD R5,R5,R2,ASR #4 31290ADD R2,R6,R6,LSL #1 31300LDR R3,[R0,-R8]:ADD R3,R3,R2,ASR #4 31310STR R3,[R0,-R8] 31320ADD R2,R6,R6,LSL #2 31330LDR R3,[R0]:ADD R3,R3,R2,ASR #4 31340STR R3,[R0] 31350MOV R3,R6,ASR #4 31360STR R3,[R0,R8] 31370RSB R2,R6,R6,LSL #3 31380LDR R6,[R10,#8] 31390ADD R6,R6,R2,ASR #4 31400] 31410ELSE 31420[OPT Z 31430LDMIA R10,{R4,R5,R6} 31440] 31450ENDIF 31460ELSE 31470IFdither% THEN 31480[OPT Z 31490ADD R2,R4,R4,LSL #1 31500LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 31510STR R3,[R11,-R8] 31520ADD R2,R4,R4,LSL #2 31530LDR R3,[R11]:ADD R3,R3,R2,ASR #4 31540STR R3,[R11] 31550MOV R3,R4,ASR #4 31560STR R3,[R11,R8]! 31570RSB R2,R4,R4,LSL #3 31580LDR R4,[R10],R8 31590ADD R4,R4,R2,ASR #4 31600] 31610ELSE 31620[OPT Z 31630LDR R4,[R10],R8 31640] 31650ENDIF 31660ENDIF 31670[OPT Z 31680SUBS R9,R9,#1:BNE fsloop 31690LDMFD SP !,{PC}^ 31700] 31710WHEN 1 31720CASE m$ OF 31730WHEN"C" 31740[OPT Z 31750.divtable EQUD 0 31760EQUD (1-black%/256*2)/16*F 31770EQUD (2-black%/256*4)/16*F 31780EQUD (3-black%/256*5)/16*F 31790EQUD (4-black%/256*6)/16*F 31800EQUD (5-black%/256*7)/16*F 31810EQUD (6-black%/256*8)/16*F 31820EQUD (7-black%/256*8)/16*F 31830EQUD (8-black%/256*8)/16*F 31840EQUD (9-black%/256*8)/16*F 31850EQUD (10-black%/256*8)/16*F 31860EQUD (11-black%/256*7)/16*F 31870EQUD (12-black%/256*6)/16*F 31880EQUD (13-black%/256*5)/16*F 31890EQUD (14-black%/256*4)/16*F 31900EQUD (15-black%/256*2)/16*F 31910EQUD F 31920.evenrow_gard DCD even_gard 31930.oddrow_gard DCD odd_gard 31940.rowinc DCD 0 31950.fs% 31960STMFD SP !,{R14} 31970LDR R1,[R9,#5*8]:LDR R1,[R1] 31980LDR R10,[R9,#4*8] 31990LDR R11,[R9,#3*8] 32000LDR R12,[R9,#2*8] 32010LDR R12,[R12] 32020LDR R8,[R9,#8] 32030LDR R8,[R8] 32040LDR R9,[R9] 32050LDR R9,[R9] 32060LDR R4,[R10],R8 32070TEQ R8,#0 32080LDRPL R6,evenrow_gard 32090LDRMI R6,oddrow_gard 32100MOV R1,R1,LSL #1 32110LDR R7,rowinc 32120ADR R14,divtable 32130.fsloop 32140CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 32150ADD R5,R4,#F>>5 32160MOVS R5,R5,LSR #bits-4 32170LDRNE R0,[R14,R5,LSL #2] 32180SUBNE R4,R4,R0 32190] 32200IFdither% THEN 32210[OPT Z 32220ADD R2,R4,R4,LSL #1 32230LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 32240STR R3,[R11,-R8] 32250ADD R2,R4,R4,LSL #2 32260LDR R3,[R11]:ADD R3,R3,R2,ASR #4 32270STR R3,[R11] 32280MOV R3,R4,ASR #4 32290STR R3,[R11,R8]! 32300RSB R2,R4,R4,LSL #3 32310LDR R4,[R10],R8 32320ADDS R4,R4,R2,ASR #4 32330] 32340ELSE 32350[OPT Z 32360LDR R4,[R10],R8 32370] 32380ENDIF 32390[OPT Z 32400CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 32410ADD R3,R4,#F>>5 32420MOVS R3,R3,LSR #bits-4 32430LDRNE R0,[R14,R3,LSL #2] 32440SUBNE R4,R4,R0 32450ORR R5,R5,R3,LSL #5:LDR R3,[R6,R5,LSL #2] 32460MOV R2,R12,LSR #1:STRB R3,[R2],R7:MOV R3,R3,LSR #8:STRB R3,[R2],R7 32470MOV R3,R3,LSR #8:STRB R3,[R2],R7:MOV R3,R3,LSR #8:STRB R3,[R2] 32480ADD R12,R12,R1 32490] 32500IFdither% THEN 32510[OPT Z 32520ADD R2,R4,R4,LSL #1 32530LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 32540STR R3,[R11,-R8] 32550ADD R2,R4,R4,LSL #2 32560LDR R3,[R11]:ADD R3,R3,R2,ASR #4 32570STR R3,[R11] 32580MOV R3,R4,ASR #4 32590STR R3,[R11,R8]! 32600RSB R2,R4,R4,LSL #3 32610LDR R4,[R10],R8 32620ADD R4,R4,R2,ASR #4 32630] 32640ELSE 32650[OPT Z 32660LDR R4,[R10],R8 32670] 32680ENDIF 32690[OPT Z 32700SUBS R9,R9,#2:BNE fsloop 32710LDMFD SP !,{PC}^ 32720] 32730WHEN"T" 32740[OPT Z 32750.divtable EQUD 0 32760EQUD (1-black%/256*2)/9*F 32770EQUD (2-black%/256*4)/9*F 32780EQUD (3-black%/256*5)/9*F 32790EQUD (4-black%/256*6)/9*F 32800EQUD (5-black%/256*6)/9*F 32810EQUD (6-black%/256*5)/9*F 32820EQUD (7-black%/256*4)/9*F 32830EQUD (8-black%/256*2)/9*F 32840EQUD F 32850.evenrow_gard DCD even_gard 32860.oddrow_gard DCD odd_gard 32870.rowinc DCD 0 32880.fs% 32890STMFD SP !,{R14} 32900LDR R1,[R9,#5*8]:LDR R1,[R1] 32910LDR R10,[R9,#4*8] 32920LDR R11,[R9,#3*8] 32930LDR R12,[R9,#2*8] 32940LDR R12,[R12] 32950LDR R8,[R9,#8] 32960LDR R8,[R8] 32970LDR R9,[R9] 32980LDR R9,[R9] 32990LDR R4,[R10],R8 33000TEQ R8,#0 33010LDRPL R6,evenrow_gard 33020LDRMI R6,oddrow_gard 33030MOV R1,R1,LSL #1 33040LDR R7,rowinc 33050ADR R14,divtable 33060.fsloop 33070CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 33080ADD R5,R4,#F>>4 33090ADD R5,R5,R5,LSL #3 33100MOVS R5,R5,LSR #bits 33110LDRNE R0,[R14,R5,LSL #2] 33120SUBNE R4,R4,R0 33130] 33140IFdither% THEN 33150[OPT Z 33160ADD R2,R4,R4,LSL #1 33170LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 33180STR R3,[R11,-R8] 33190ADD R2,R4,R4,LSL #2 33200LDR R3,[R11]:ADD R3,R3,R2,ASR #4 33210STR R3,[R11] 33220MOV R3,R4,ASR #4 33230STR R3,[R11,R8]! 33240RSB R2,R4,R4,LSL #3 33250LDR R4,[R10],R8 33260ADDS R4,R4,R2,ASR #4 33270] 33280ELSE 33290[OPT Z 33300LDR R4,[R10],R8 33310] 33320ENDIF 33330[OPT Z 33340CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 33350ADD R3,R4,#F>>4 33360ADD R3,R3,R3,LSL #3 33370MOVS R3,R3,LSR #bits 33380LDRNE R0,[R14,R3,LSL #2] 33390SUBNE R4,R4,R0 33400ORR R5,R5,R3,LSL #4:LDR R5,[R6,R5,LSL #2] 33410MOV R2,R12,LSR #1 33420AND R3,R5,#&3F 33430STRB R3,[R2],R7 33440MOV R3,R5,LSR #6:AND R3,R3,#&3F 33450STRB R3,[R2],R7 33460MOV R3,R5,LSR #12:STRB R3,[R2] 33470ADD R12,R12,R1 33480] 33490IFdither% THEN 33500[OPT Z 33510ADD R2,R4,R4,LSL #1 33520LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 33530STR R3,[R11,-R8] 33540ADD R2,R4,R4,LSL #2 33550LDR R3,[R11]:ADD R3,R3,R2,ASR #4 33560STR R3,[R11] 33570MOV R3,R4,ASR #4 33580STR R3,[R11,R8]! 33590RSB R2,R4,R4,LSL #3 33600LDR R4,[R10],R8 33610ADD R4,R4,R2,ASR #4 33620] 33630ELSE 33640[OPT Z 33650LDR R4,[R10],R8 33660] 33670ENDIF 33680[OPT Z 33690SUBS R9,R9,#2:BNE fsloop 33700LDMFD SP !,{PC}^ 33710] 33720WHEN"D" 33730[OPT Z 33740.divtable EQUD 0 33750EQUD (1-black%/256*2)/4*F 33760EQUD (2-black%/256*4)/4*F 33770EQUD (3-black%/256*2)/4*F 33780EQUD F 33790.evenrow_gard DCD even_gard 33800.oddrow_gard DCD odd_gard 33810.rowinc DCD 0 33820.fs% 33830STMFD SP !,{R14} 33840LDR R1,[R9,#5*8]:LDR R1,[R1] 33850LDR R10,[R9,#4*8] 33860LDR R11,[R9,#3*8] 33870LDR R12,[R9,#2*8] 33880LDR R12,[R12] 33890LDR R8,[R9,#8] 33900LDR R8,[R8] 33910LDR R9,[R9] 33920LDR R9,[R9] 33930LDR R4,[R10],R8 33940TEQ R8,#0 33950LDRPL R6,evenrow_gard 33960LDRMI R6,oddrow_gard 33970MOV R1,R1,LSL #1 33980LDR R7,rowinc 33990ADR R14,divtable 34000.fsloop 34010CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 34020ADD R5,R4,#F>>3 34030MOVS R5,R5,LSR #bits-2 34040LDRNE R0,[R14,R5,LSL #2] 34050SUBNE R4,R4,R0 34060] 34070IFdither% THEN 34080[OPT Z 34090ADD R2,R4,R4,LSL #1 34100LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 34110STR R3,[R11,-R8] 34120ADD R2,R4,R4,LSL #2 34130LDR R3,[R11]:ADD R3,R3,R2,ASR #4 34140STR R3,[R11] 34150MOV R3,R4,ASR #4 34160STR R3,[R11,R8]! 34170RSB R2,R4,R4,LSL #3 34180LDR R4,[R10],R8 34190ADDS R4,R4,R2,ASR #4 34200] 34210ELSE 34220[OPT Z 34230LDR R4,[R10],R8 34240] 34250ENDIF 34260[OPT Z 34270CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 34280ADD R3,R4,#F>>3 34290MOVS R3,R3,LSR #bits-2 34300LDRNE R0,[R14,R3,LSL #2] 34310SUBNE R4,R4,R0 34320ORR R5,R5,R3,LSL #3:LDRB R5,[R6,R5] 34330MOV R2,R12,LSR #2 34340TST R12,#2 34350AND R3,R5,#&F:LDRB R0,[R2] 34360ANDEQ R0,R0,#&F0:ORREQ R0,R0,R3 34370ANDNE R0,R0,#&0F:ORRNE R0,R0,R3,LSL #4 34380STRB R0,[R2],R7 34390MOV R3,R5,LSR #4:LDRB R0,[R2] 34400ANDEQ R0,R0,#&F0:ORREQ R0,R0,R3 34410ANDNE R0,R0,#&0F:ORRNE R0,R0,R3,LSL #4 34420STRB R0,[R2] 34430ADD R12,R12,R1 34440] 34450IFdither% THEN 34460[OPT Z 34470ADD R2,R4,R4,LSL #1 34480LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 34490STR R3,[R11,-R8] 34500ADD R2,R4,R4,LSL #2 34510LDR R3,[R11]:ADD R3,R3,R2,ASR #4 34520STR R3,[R11] 34530MOV R3,R4,ASR #4 34540STR R3,[R11,R8]! 34550RSB R2,R4,R4,LSL #3 34560LDR R4,[R10],R8 34570ADD R4,R4,R2,ASR #4 34580] 34590ELSE 34600[OPT Z 34610LDR R4,[R10],R8 34620] 34630ENDIF 34640[OPT Z 34650SUBS R9,R9,#2:BNE fsloop 34660LDMFD SP !,{PC}^ 34670] 34680OTHERWISE 34690[OPT Z 34700.fs% 34710STMFD SP !,{R14} 34720LDR R1,[R9,#5*8]:LDR R1,[R1] 34730LDR R10,[R9,#4*8] 34740LDR R11,[R9,#3*8] 34750LDR R12,[R9,#2*8] 34760LDR R12,[R12] 34770LDR R8,[R9,#8] 34780LDR R8,[R8] 34790LDR R9,[R9] 34800LDR R9,[R9] 34810LDR R4,[R10],R8 34820MOV R7,#1 34830.fsloop 34840CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 34850] 34860IFblack% THEN 34870[OPT Z 34880MOV R2,R12,LSR #3 34890AND R5,R12,#7:MOV R6,#1 34900LDRB R0,[R2,#-(x%+7>>3)] 34910SUB R3,R4,#F 34920CMP R7,#0 34930ADDNE R4,R4,#black%<<(bits-8) 34940ADDEQ R3,R3,#black%<<(bits-8) 34950TST R0,R6,LSL R5 34960ADDNE R4,R4,#black%<<(bits-8) 34970ADDEQ R3,R3,#black%<<(bits-8) 34980MOVS R0,R3:RSBMI R0,R3,#0 34990CMP R4,R0 35000MOVCC R3,#0 35010MOVCS R4,R3:MOVCS R3,#1 35020MOV R7,R3 35030] 35040ELSE 35050[OPT Z 35060ADD R3,R4,#F>>1:MOV R3,R3,LSR #bits 35070SUB R4,R4,R3,LSL #bits 35080MOV R2,R12,LSR #3 35090AND R5,R12,#7:MOV R6,#1 35100] 35110ENDIF 35120[OPT Z 35130LDRB R0,[R2]:BIC R0,R0,R6,LSL R5:ORR R0,R0,R3,LSL R5 35140STRB R0,[R2] 35150ADD R12,R12,R1 35160] 35170IFdither% THEN 35180[OPT Z 35190ADD R2,R4,R4,LSL #1 35200LDR R3,[R11,-R8]:ADD R3,R3,R2,ASR #4 35210STR R3,[R11,-R8] 35220ADD R2,R4,R4,LSL #2 35230LDR R3,[R11]:ADD R3,R3,R2,ASR #4 35240STR R3,[R11] 35250MOV R3,R4,ASR #4 35260STR R3,[R11,R8]! 35270RSB R2,R4,R4,LSL #3 35280LDR R4,[R10],R8 35290ADD R4,R4,R2,ASR #4 35300] 35310ELSE 35320[OPT Z 35330LDR R4,[R10],R8 35340] 35350ENDIF 35360[OPT Z 35370SUBS R9,R9,#1:BNE fsloop 35380LDMFD SP !,{PC}^ 35390] 35400ENDCASE 35410ENDCASE 35420[OPT Z 35430.sxloc DCD sx% 35440] 35450CASE col OF 35460WHEN 0 35470IFinput<=8 THEN 35480[OPT Z 35490.mappix% 35500LDR R0,sxloc 35510LDR R1,[R9]:LDR R1,[R1] 35520LDR R2,[R9,#3*8] 35530LDR R5,[R9,#4*8] 35540MOV R8,#0 35550.mappixlp 35560LDRB R6,[R1],#step24 35570] 35580ENDIF 35590CASE input OF 35600WHEN 8 35610IFham THEN 35620[OPT Z 35630ADR R9,ltable 35640MOVS R7,R6,LSR #4:AND R6,R6,#15 35650LDREQ R10,[R2,R6,LSL #2]:MOVEQ R11,R10:MOVEQ R12,R10 35660CMP R7,#1:LDREQ R12,[R9,R6,LSL #2] 35670CMP R7,#2:LDREQ R10,[R9,R6,LSL #2] 35680CMP R7,#3:LDREQ R11,[R9,R6,LSL #2] 35690ADD R3,R10,R11 35700ADD R3,R3,R12 35710MOV R3,R3,LSR #2 35720STMIA R5!,{R3} 35730SUBS R0,R0,#1:BNE mappixlp 35740MOVS PC,R14 35750.ltable 35760] 35770FORI%=0TO15 35780[OPT Z 35790EQUD I%/15*F 35800] 35810NEXT 35820ELSE 35830IFhpredict%=2 THEN 35840[OPT Z 35850ADD R6,R6,R8 35860AND R6,R6,#255 35870MOV R8,R6 35880] 35890ENDIF 35900[OPT Z 35910LDR R7,[R2,R6,LSL #2]:STR R7,[R5],#4 35920SUBS R0,R0,#1:BNE mappixlp 35930MOVS PC,R14 35940] 35950ENDIF 35960WHEN 4 35970IFbigendianbits THEN 35980[OPT Z 35990MOV R10,R6,LSR #4 36000LDR R7,[R2,R10,LSL #2] 36010AND R10,R6,#&F 36020] 36030ELSE 36040[OPT Z 36050AND R10,R6,#&F 36060LDR R7,[R2,R10,LSL #2] 36070MOV R10,R6,LSR #4 36080] 36090ENDIF 36100[OPT Z 36110LDR R8,[R2,R10,LSL #2]:STMIA R5!,{R7,R8} 36120SUBS R0,R0,#2:BHI mappixlp 36130MOVS PC,R14 36140] 36150WHEN 2 36160IFbigendianbits THEN 36170[OPT Z 36180MOV R10,R6,LSR #6 36190LDR R7,[R2,R10,LSL #2] 36200AND R10,R6,#&30 36210LDR R8,[R2,R10,LSR #2] 36220AND R10,R6,#&C 36230LDR R9,[R2,R10] 36240AND R10,R6,#&3 36250] 36260ELSE 36270[OPT Z 36280AND R10,R6,#&3 36290LDR R7,[R2,R10,LSL #2] 36300AND R10,R6,#&C 36310LDR R8,[R2,R10] 36320AND R10,R6,#&30 36330LDR R9,[R2,R10,LSR #2] 36340MOV R10,R6,LSR #6 36350] 36360ENDIF 36370[OPT Z 36380LDR R10,[R2,R10,LSL #2]:STMIA R5!,{R7,R8,R9,R10} 36390SUBS R0,R0,#4:BHI mappixlp 36400MOVS PC,R14 36410] 36420WHEN 1 36430IFbigendianbits THEN 36440[OPT Z 36450AND R10,R6,#&80 36460LDR R7,[R2,R10,LSR #5] 36470AND R10,R6,#&40 36480LDR R8,[R2,R10,LSR #4] 36490AND R10,R6,#&20 36500LDR R9,[R2,R10,LSR #3] 36510AND R10,R6,#&10 36520LDR R10,[R2,R10,LSR #2]:STMIA R5!,{R7,R8,R9,R10} 36530AND R10,R6,#&8 36540LDR R7,[R2,R10,LSR #1] 36550AND R10,R6,#&4 36560LDR R8,[R2,R10] 36570AND R10,R6,#&2 36580LDR R9,[R2,R10,LSL #1] 36590AND R10,R6,#&1 36600] 36610ELSE 36620[OPT Z 36630AND R10,R6,#&1 36640LDR R7,[R2,R10,LSL #2] 36650AND R10,R6,#&2 36660LDR R8,[R2,R10,LSL #1] 36670AND R10,R6,#&4 36680LDR R9,[R2,R10] 36690AND R10,R6,#&8 36700LDR R10,[R2,R10,LSR #1]:STMIA R5!,{R7,R8,R9,R10} 36710AND R10,R6,#&10 36720LDR R7,[R2,R10,LSR #2] 36730AND R10,R6,#&20 36740LDR R8,[R2,R10,LSR #3] 36750AND R10,R6,#&40 36760LDR R9,[R2,R10,LSR #4] 36770MOV R10,R6,LSR #7 36780] 36790ENDIF 36800[OPT Z 36810LDR R10,[R2,R10,LSL #2]:STMIA R5!,{R7,R8,R9,R10} 36820SUBS R0,R0,#8:BHI mappixlp 36830MOVS PC,R14 36840] 36850WHEN 16 36860[OPT Z 36870.mappix% 36880LDR R0,sxloc 36890LDR R1,[R9]:LDR R1,[R1] 36900LDR R2,[R9,#8]:LDR R2,[R2] 36910LDR R3,[R9,#4*8] 36920LDR R4,[R9,#3*8] 36930LDR R5,[R9,#2*8] 36940LDR R6,[R9,#5*8] 36950LDR R7,[R9,#6*8] 36960LDR R8,[R9,#7*8] 36970CMP R1,R2 36980ADDEQ R2,R2,#1 36990.mappixlp 37000LDRB R9,[R1],#step24:LDRB R10,[R2],#step24 37010LDR R9,[R6,R9,LSL #2]:LDR R10,[R7,R10,LSL #2]:ORR R9,R9,R10 37020AND R10,R9,#255:LDR R10,[R3,R10,LSL #2] 37030MOV R11,R9,LSR #8:AND R11,R11,#255:LDR R11,[R4,R11,LSL #2] 37040MOV R12,R9,LSR #16:LDR R12,[R5,R12,LSL #2] 37050ADD R10,R10,R11:ADD R10,R10,R12:STMIA R8!,{R10} 37060SUBS R0,R0,#1:BNE mappixlp 37070MOVS PC,R14 37080] 37090WHEN 24 37100[OPT Z 37110.mappix% 37120LDR R0,sxloc 37130LDR R1,[R9,#2*8]:LDR R1,[R1] 37140LDR R2,[R9,#8]:LDR R2,[R2] 37150LDR R3,[R9]:LDR R3,[R3] 37160LDR R4,[R9,#5*8] 37170LDR R5,[R9,#4*8] 37180LDR R6,[R9,#3*8] 37190LDR R7,[R9,#6*8] 37200STMFD SP !,{R14} 37210MOV r11,#0:MOV R12,#0:MOV R14,#0 37220.mappixlp 37230LDRB R8,[R1],#step24:LDRB R9,[R2],#step24:LDRB R10,[R3],#step24 37240] 37250IFhpredict%=2 THEN 37260[OPT Z 37270ADD r8,r8,r11 37280AND r8,r8,#255 37290MOV r11,r8 37300ADD r9,r9,r12 37310AND r9,r9,#255 37320MOV r12,r9 37330ADD r10,r10,r14 37340AND r10,r10,#255 37350MOV r14,r10 37360] 37370ENDIF 37380[OPT Z 37390LDR R8,[R4,R8,LSL #2]:LDR R9,[R5,R9,LSL #2]:LDR R10,[R6,R10,LSL #2] 37400ADD R8,R8,R9:ADD R8,R8,R10:STR R8,[R7],#4 37410SUBS R0,R0,#1:BNE mappixlp 37420LDMFD SP !,{PC}^ 37430] 37440WHEN 48 37450[OPT Z 37460.mappix% 37470LDR R0,sxloc 37480LDR R1,[R9,#2*8]:LDR R1,[R1] 37490LDR R2,[R9,#8]:LDR R2,[R2] 37500LDR R3,[R9]:LDR R3,[R3] 37510LDR R4,[R9,#5*8] 37520LDR R5,[R9,#4*8] 37530LDR R6,[R9,#3*8] 37540LDR R7,[R9,#6*8] 37550STMFD SP !,{R14} 37560MOV r11,#colourindex AND 255:ADD r11,r11,#colourindex AND &ff00 37570.mappixlp 37580LDR R8,[R1],#step24:LDR R9,[R2],#step24:LDR R10,[R3],#step24 37590AND r8,r8,r11:AND r9,r9,r11:AND r10,r10,r11 37600LDR R8,[R4,R8,LSL #2]:LDR R9,[R5,R9,LSL #2]:LDR R10,[R6,R10,LSL #2] 37610ADD R8,R8,R9:ADD R8,R8,R10:STR R8,[R7],#4 37620SUBS R0,R0,#1:BNE mappixlp 37630LDMFD SP !,{PC}^ 37640] 37650WHEN 411 37660[OPT Z 37670.mappix% 37680LDR R0,sxloc 37690LDR R1,[R9]:LDR R1,[R1] 37700LDR R4,[R9,#1*8] 37710LDR R7,[R9,#8*8] 37720.mappixlp 37730LDRB R8,[R1],#2 37740LDR R8,[R4,R8,LSL #2]:CMP R8,#F:MOVCS R8,#F:STR R8,[R7],#4 37750SUBS R0,R0,#1:BNE mappixlp 37760MOVS PC,R14 37770] 37780WHEN 422 37790[OPT Z 37800.mappix% 37810LDR R0,sxloc 37820LDR R1,[R9]:LDR R1,[R1] 37830ADD R1,R1,#1 37840LDR R4,[R9,#1*8] 37850LDR R7,[R9,#8*8] 37860.mappixlp 37870LDRB R8,[R1],#2 37880LDR R8,[R4,R8,LSL #2]:CMP R8,#F:MOVCS R8,#F:STR R8,[R7],#4 37890SUBS R0,R0,#1:BNE mappixlp 37900MOVS PC,R14 37910] 37920WHEN 555 37930[OPT Z 37940.mappix% 37950LDR R0,sxloc 37960LDR R1,[R9]:LDR R1,[R1] 37970ADD R1,R1,#1 37980LDR R4,[R9,#1*8] 37990LDR R7,[R9,#8*8] 38000.mappixlp 38010LDRB R8,[R1],#2 38020AND R8,R8,#ymax% 38030LDR R8,[R4,R8,LSL #2]:CMP R8,#F:MOVCS R8,#F:STR R8,[R7],#4 38040SUBS R0,R0,#1:BNE mappixlp 38050MOVS PC,R14 38060] 38070ENDCASE 38080IFxmul%=2 AND xdiv%=1 THEN 38090[OPT Z 38110.xsample% 38120LDR R0,[R9]:LDR R0,[R0] 38130LDR R1,[R9,#8] 38140LDR R2,[R9,#2*8] 38150SUBS R0,R0,#2 38160BEQ xdonediv 38170BMI xdonediv 38180.xsamplelp 38190LDMIA R1,{R5,R6} 38200ADD R6,R6,R5 38210MOV R6,R6,LSR #1 38220STMIA R2!,{R5,R6} 38230ADD R1,R1,#4 38240SUBS R0,R0,#2:BGT xsamplelp 38250.xdonediv 38260LDMIA R1,{R5} 38270MOV R6,R5 38280STMIA R2!,{R5,R6} 38290MOVS PC,R14 38300] 38310ELSE 38320[OPT Z 38340.xsample% 38350LDR R0,[R9]:LDR R0,[R0] 38360LDR R1,[R9,#8] 38370LDR R2,[R9,#2*8] 38380LDR R3,[R9,#3*8]:LDR R3,[R3] 38390LDR R4,[R9,#4*8]:LDR R4,[R4] 38400MOV R11,R4 38410.xsamplelp 38420LDMIA R1,{R5} 38430SUBS R11,R11,#1:MOVEQ R11,R4:ADDEQ R1,R1,#4 38440SUBS R12,R3,#1 38450BEQ xdonediv 38460.xdivlp 38470CMP R12,R11 38480BCC xdivlp2 38490LDMIA R1!,{R8}:MLA R5,R8,R11,R5 38500SUBS R12,R12,R11:MOV R11,R4 38510BNE xdivlp 38520B xdonediv 38530.xdivlp2 38540LDMIA R1,{R8} 38550SUBS R11,R11,#1:MOVEQ R11,R4:ADDEQ R1,R1,#4 38560ADD R5,R5,R8 38570SUBS R12,R12,#1:BNE xdivlp 38580.xdonediv 38590STMIA R2!,{R5} 38600SUBS R0,R0,#1:BPL xsamplelp 38610MOVS PC,R14 38620] 38630ENDIF 38640WHEN 2 38650IFinput<=8 THEN 38660[OPT Z 38670.mappix% 38680LDR R0,sxloc 38690LDR R1,[R9]:LDR R1,[R1] 38700LDR R2,[R9,#3*8] 38710LDR R3,[R9,#2*8] 38720LDR R4,[R9,#8] 38730LDR R5,[R9,#4*8] 38740MOV R10,#0 38750.mappixlp 38760LDRB R6,[R1],#step24 38770] 38780ENDIF 38790CASE input OF 38800WHEN 8 38810IFham THEN 38820[OPT Z 38830ADR R9,ltable 38840MOVS R7,R6,LSR #4:AND R6,R6,#15 38850LDREQ R10,[R2,R6,LSL #2]:LDREQ R11,[R3,R6,LSL #2]:LDREQ R12,[R4,R6,LSL #2] 38860CMP R7,#1:LDREQ R12,[R9,R6,LSL #2] 38870CMP R7,#2:LDREQ R10,[R9,R6,LSL #2] 38880CMP R7,#3:LDREQ R11,[R9,R6,LSL #2] 38890STMIA R5!,{R10,R11,R12} 38900SUBS R0,R0,#1:BNE mappixlp 38910MOVS PC,R14 38920.ltable 38930] 38940FORI%=0TO15 38950[OPT Z 38960EQUD I%/15*F 38970] 38980NEXT 38990ELSE 39000IFhpredict%=2 THEN 39010[OPT Z 39020ADD R6,R6,R10 39030AND R6,R6,#255 39040MOV R10,R6 39050] 39060ENDIF 39070[OPT Z 39080LDR R7,[R2,R6,LSL #2]:LDR R8,[R3,R6,LSL #2]:LDR R9,[R4,R6,LSL #2] 39090STMIA R5!,{R7,R8,R9} 39100SUBS R0,R0,#1:BNE mappixlp 39110MOVS PC,R14 39120] 39130ENDIF 39140WHEN 4 39150IFbigendianbits THEN 39160[OPT Z 39170MOV R10,R6,LSR #4 39180LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 39190STMIA R5!,{R7,R8,R9} 39200AND R10,R6,#&F 39210] 39220ELSE 39230[OPT Z 39240AND R10,R6,#&F 39250LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 39260STMIA R5!,{R7,R8,R9} 39270MOV R10,R6,LSR #4 39280] 39290ENDIF 39300[OPT Z 39310LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 39320STMIA R5!,{R7,R8,R9} 39330SUBS R0,R0,#2:BHI mappixlp 39340MOVS PC,R14 39350] 39360WHEN 2 39370IFbigendianbits THEN 39380[OPT Z 39390MOV R10,R6,LSR #6 39400LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 39410STMIA R5!,{R7,R8,R9} 39420AND R10,R6,#&30 39430LDR R7,[R2,R10,LSR #2]:LDR R8,[R3,R10,LSR #2]:LDR R9,[R4,R10,LSR #2] 39440STMIA R5!,{R7,R8,R9} 39450AND R10,R6,#&C 39460LDR R7,[R2,R10]:LDR R8,[R3,R10]:LDR R9,[R4,R10] 39470STMIA R5!,{R7,R8,R9} 39480AND R10,R6,#&3 39490] 39500ELSE 39510[OPT Z 39520AND R10,R6,#&3 39530LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 39540STMIA R5!,{R7,R8,R9} 39550AND R10,R6,#&C 39560LDR R7,[R2,R10]:LDR R8,[R3,R10]:LDR R9,[R4,R10] 39570STMIA R5!,{R7,R8,R9} 39580AND R10,R6,#&30 39590LDR R7,[R2,R10,LSR #2]:LDR R8,[R3,R10,LSR #2]:LDR R9,[R4,R10,LSR #2] 39600STMIA R5!,{R7,R8,R9} 39610MOV R10,R6,LSR #6 39620] 39630ENDIF 39640[OPT Z 39650LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 39660STMIA R5!,{R7,R8,R9} 39670SUBS R0,R0,#4:BHI mappixlp 39680MOVS PC,R14 39690] 39700WHEN 1 39710IFbigendianbits THEN 39720[OPT Z 39730AND R10,R6,#&80 39740LDR R7,[R2,R10,LSR #5]:LDR R8,[R3,R10,LSR #5]:LDR R9,[R4,R10,LSR #5] 39750STMIA R5!,{R7,R8,R9} 39760AND R10,R6,#&40 39770LDR R7,[R2,R10,LSR #4]:LDR R8,[R3,R10,LSR #4]:LDR R9,[R4,R10,LSR #4] 39780STMIA R5!,{R7,R8,R9} 39790AND R10,R6,#&20 39800LDR R7,[R2,R10,LSR #3]:LDR R8,[R3,R10,LSR #3]:LDR R9,[R4,R10,LSR #3] 39810STMIA R5!,{R7,R8,R9} 39820AND R10,R6,#&10 39830LDR R7,[R2,R10,LSR #2]:LDR R8,[R3,R10,LSR #2]:LDR R9,[R4,R10,LSR #2] 39840STMIA R5!,{R7,R8,R9} 39850AND R10,R6,#&8 39860LDR R7,[R2,R10,LSR #1]:LDR R8,[R3,R10,LSR #1]:LDR R9,[R4,R10,LSR #1] 39870STMIA R5!,{R7,R8,R9} 39880AND R10,R6,#&4 39890LDR R7,[R2,R10]:LDR R8,[R3,R10]:LDR R9,[R4,R10] 39900STMIA R5!,{R7,R8,R9} 39910AND R10,R6,#&2 39920LDR R7,[R2,R10,LSL #1]:LDR R8,[R3,R10,LSL #1]:LDR R9,[R4,R10,LSL #1] 39930STMIA R5!,{R7,R8,R9} 39940AND R10,R6,#&1 39950] 39960ELSE 39970[OPT Z 39980AND R10,R6,#&1 39990LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 40000STMIA R5!,{R7,R8,R9} 40010AND R10,R6,#&2 40020LDR R7,[R2,R10,LSL #1]:LDR R8,[R3,R10,LSL #1]:LDR R9,[R4,R10,LSL #1] 40030STMIA R5!,{R7,R8,R9} 40040AND R10,R6,#&4 40050LDR R7,[R2,R10]:LDR R8,[R3,R10]:LDR R9,[R4,R10] 40060STMIA R5!,{R7,R8,R9} 40070AND R10,R6,#&8 40080LDR R7,[R2,R10,LSR #1]:LDR R8,[R3,R10,LSR #1]:LDR R9,[R4,R10,LSR #1] 40090STMIA R5!,{R7,R8,R9} 40100AND R10,R6,#&10 40110LDR R7,[R2,R10,LSR #2]:LDR R8,[R3,R10,LSR #2]:LDR R9,[R4,R10,LSR #2] 40120STMIA R5!,{R7,R8,R9} 40130AND R10,R6,#&20 40140LDR R7,[R2,R10,LSR #3]:LDR R8,[R3,R10,LSR #3]:LDR R9,[R4,R10,LSR #3] 40150STMIA R5!,{R7,R8,R9} 40160AND R10,R6,#&40 40170LDR R7,[R2,R10,LSR #4]:LDR R8,[R3,R10,LSR #4]:LDR R9,[R4,R10,LSR #4] 40180STMIA R5!,{R7,R8,R9} 40190MOV R10,R6,LSR #7 40200] 40210ENDIF 40220[OPT Z 40230LDR R7,[R2,R10,LSL #2]:LDR R8,[R3,R10,LSL #2]:LDR R9,[R4,R10,LSL #2] 40240STMIA R5!,{R7,R8,R9} 40250SUBS R0,R0,#8:BHI mappixlp 40260MOVS PC,R14 40270] 40280WHEN 16 40290[OPT Z 40300.mappix% 40310LDR R0,sxloc 40320LDR R1,[R9]:LDR R1,[R1] 40330LDR R2,[R9,#8]:LDR R2,[R2] 40340LDR R3,[R9,#4*8] 40350LDR R4,[R9,#3*8] 40360LDR R5,[R9,#2*8] 40370LDR R6,[R9,#5*8] 40380LDR R7,[R9,#6*8] 40390LDR R8,[R9,#7*8] 40400CMP R1,R2 40410ADDEQ R2,R2,#1 40420.mappixlp 40430LDRB R9,[R1],#step24:LDRB R10,[R2],#step24 40440LDR R9,[R6,R9,LSL #2]:LDR R10,[R7,R10,LSL #2]:ORR R9,R9,R10 40450AND R10,R9,#255:LDR R10,[R3,R10,LSL #2] 40460MOV R11,R9,LSR #8:AND R11,R11,#255:LDR R11,[R4,R11,LSL #2] 40470MOV R12,R9,LSR #16:LDR R12,[R5,R12,LSL #2] 40480STMIA R8!,{R10,R11,R12} 40490SUBS R0,R0,#1:BNE mappixlp 40500MOVS PC,R14 40510] 40520WHEN 24 40530[OPT Z 40540.mappix% 40550LDR R0,sxloc 40560LDR R1,[R9,#2*8]:LDR R1,[R1] 40570LDR R2,[R9,#8]:LDR R2,[R2] 40580LDR R3,[R9]:LDR R3,[R3] 40590LDR R4,[R9,#5*8] 40600LDR R5,[R9,#4*8] 40610LDR R6,[R9,#3*8] 40620LDR R7,[R9,#6*8] 40630STMFD SP !,{R14} 40640MOV r11,#0:MOV R12,#0:MOV R14,#0 40650.mappixlp 40660LDRB R8,[R1],#step24:LDRB R9,[R2],#step24:LDRB R10,[R3],#step24 40670] 40680IFhpredict%=2 THEN 40690[OPT Z 40700ADD r8,r8,r11 40710AND r8,r8,#255 40720MOV r11,r8 40730ADD r9,r9,r12 40740AND r9,r9,#255 40750MOV r12,r9 40760ADD r10,r10,r14 40770AND r10,r10,#255 40780MOV r14,r10 40790] 40800ENDIF 40810[OPT Z 40820LDR R8,[R4,R8,LSL #2]:LDR R9,[R5,R9,LSL #2]:LDR R10,[R6,R10,LSL #2] 40830STMIA R7!,{R8,R9,R10} 40840SUBS R0,R0,#1:BNE mappixlp 40850LDMFD SP !,{PC}^ 40860] 40870WHEN 48 40880[OPT Z 40890.mappix% 40900LDR R0,sxloc 40910LDR R1,[R9,#2*8]:LDR R1,[R1] 40920LDR R2,[R9,#8]:LDR R2,[R2] 40930LDR R3,[R9]:LDR R3,[R3] 40940LDR R4,[R9,#5*8] 40950LDR R5,[R9,#4*8] 40960LDR R6,[R9,#3*8] 40970LDR R7,[R9,#6*8] 40980STMFD SP !,{R14} 40990MOV r11,#colourindex AND 255:ADD r11,r11,#colourindex AND &ff00 41000.mappixlp 41010LDR R8,[R1],#step24:LDR R9,[R2],#step24:LDR R10,[R3],#step24 41020AND r8,r8,r11:AND r9,r9,r11:AND r10,r10,r11 41030LDR R8,[R4,R8,LSL #2]:LDR R9,[R5,R9,LSL #2]:LDR R10,[R6,R10,LSL #2] 41040STMIA R7!,{R8,R9,R10} 41050SUBS R0,R0,#1:BNE mappixlp 41060LDMFD SP !,{PC}^ 41070] 41080WHEN 411 41100[OPT Z 41110.mappix% 41120LDR R0,sxloc 41130LDR R1,[R9]:LDR R1,[R1] 41140LDR R2,[R9,#1*8] 41150LDR R3,[R9,#2*8] 41160LDR R5,[R9,#4*8] 41170LDR R6,[R9,#5*8] 41180LDR R7,[R9,#6*8] 41190LDR R9,[R9,#8*8] 41200STMFD SP !,{R14} 41210.mappixlp 41220LDMIA R1!,{R4,R10} 41230AND R8,R4,#&C000 41240MOV R8,R8,LSR #8 41250AND R14,R4,#&C0000000 41260ORR R8,R8,R14,LSR #16+8+2 41270AND R14,R10,#&C000 41280ORR R8,R8,R14,LSR #8+4 41290ORR R8,R8,R10,LSR #16+8+6 41300AND R11,R4,#&3000 41310MOV R11,R11,LSR #6 41320AND R14,R4,#&30000000 41330ORR R11,R11,R14,LSR #16+6+2 41340AND R14,R10,#&3000 41350ORR R11,R11,R14,LSR #6+4 41360AND R14,R10,#&30000000 41370ORR R11,R11,R14,LSR #16+6+6 41390AND R12,R4,#&FF 41400LDR R12,[R2,R12,LSL #2] 41410LDR R14,[R7,R11,LSL #2]:ADDS R14,R14,R12 41420MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41430LDR R14,[R6,R8,LSL #2]:ADD R14,R14,R12 41440LDR R12,[R5,R11,LSL #2]:ADDS R14,R14,R12 41450MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41460AND R12,R4,#&FF 41470LDR R12,[R2,R12,LSL #2] 41480LDR R14,[R3,R8,LSL #2]:ADDS R14,R12,R14 41490MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41510MOV R4,R4,LSR #16 41520AND R12,R4,#&FF 41530LDR R12,[R2,R12,LSL #2] 41540LDR R14,[R7,R11,LSL #2]:ADDS R14,R14,R12 41550MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41560LDR R14,[R6,R8,LSL #2]:ADD R14,R14,R12 41570LDR R12,[R5,R11,LSL #2]:ADDS R14,R14,R12 41580MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41590AND R12,R4,#&FF 41600LDR R12,[R2,R12,LSL #2] 41610LDR R14,[R3,R8,LSL #2]:ADDS R14,R12,R14 41620MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41640AND R12,R10,#&FF 41650LDR R12,[R2,R12,LSL #2] 41660LDR R14,[R7,R11,LSL #2]:ADDS R14,R14,R12 41670MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41680LDR R14,[R6,R8,LSL #2]:ADD R14,R14,R12 41690LDR R12,[R5,R11,LSL #2]:ADDS R14,R14,R12 41700MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41710AND R12,R10,#&FF 41720LDR R12,[R2,R12,LSL #2] 41730LDR R14,[R3,R8,LSL #2]:ADDS R14,R12,R14 41740MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41760MOV R10,R10,LSR #16 41770AND R12,R10,#&FF 41780LDR R12,[R2,R12,LSL #2] 41790LDR R14,[R7,R11,LSL #2]:ADDS R14,R14,R12 41800MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41810LDR R14,[R6,R8,LSL #2]:ADD R14,R14,R12 41820LDR R12,[R5,R11,LSL #2]:ADDS R14,R14,R12 41830MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41840AND R12,R10,#&FF 41850LDR R12,[R2,R12,LSL #2] 41860LDR R14,[R3,R8,LSL #2]:ADDS R14,R12,R14 41870MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 41890SUBS R0,R0,#4:BNE mappixlp 41900LDMFD SP !,{PC}^ 41910] 41920WHEN 423 41930[OPT Z 41940.mappix% 41950LDR R0,sxloc 41960LDR R1,[R9]:LDR R1,[R1] 41970LDR R2,[R9,#1*8] 41980LDR R3,[R9,#2*8] 41990LDR R4,[R9,#3*8] 42000LDR R5,[R9,#4*8] 42010LDR R6,[R9,#5*8] 42020LDR R7,[R9,#6*8] 42030LDR R8,[R9,#7*8] 42040LDR R9,[R9,#8*8] 42050STMFD SP !,{R14} 42060.mappixlp 42070LDR R10,[R1],#4 42080AND R11,R10,#&FF00 42090LDR R11,[R2,R11,LSR #6] 42100AND R12,R10,#&FF:LDR R12,[R7,R12,LSL #2]:ADD R14,R12,R11 42110AND R12,R10,#&FF0000:LDR R12,[R8,R12,LSR #14]:ADDS R14,R14,R12 42120MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42130AND R12,R10,#&FF:LDR R12,[R5,R12,LSL #2]:ADD R14,R12,R11 42140AND R12,R10,#&FF0000:LDR R12,[R6,R12,LSR #14]:ADDS R14,R14,R12 42150MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42160AND R12,R10,#&FF:LDR R12,[R3,R12,LSL #2]:ADD R14,R12,R11 42170AND R12,R10,#&FF0000:LDR R12,[R4,R12,LSR #14]:ADDS R14,R14,R12 42180MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42190AND R11,R10,#&FF000000 42200LDR R11,[R2,R11,LSR #22] 42210AND R12,R10,#&FF:LDR R12,[R7,R12,LSL #2]:ADD R14,R12,R11 42220AND R12,R10,#&FF0000:LDR R12,[R8,R12,LSR #14]:ADDS R14,R14,R12 42230MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42240AND R12,R10,#&FF:LDR R12,[R5,R12,LSL #2]:ADD R14,R12,R11 42250AND R12,R10,#&FF0000:LDR R12,[R6,R12,LSR #14]:ADDS R14,R14,R12 42260MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42270AND R12,R10,#&FF:LDR R12,[R3,R12,LSL #2]:ADD R14,R12,R11 42280AND R12,R10,#&FF0000:LDR R12,[R4,R12,LSR #14]:ADDS R14,R14,R12 42290MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42300SUBS R0,R0,#2:BNE mappixlp 42310LDMFD SP !,{PC}^ 42320] 42330WHEN 422 42340[OPT Z 42350.mappix% 42360LDR R0,sxloc 42370LDR R1,[R9]:LDR R1,[R1] 42380LDR R2,[R9,#1*8] 42390LDR R3,[R9,#2*8] 42400LDR R5,[R9,#4*8] 42410LDR R6,[R9,#5*8] 42420LDR R7,[R9,#6*8] 42430LDR R9,[R9,#8*8] 42440STMFD SP !,{R14} 42450.mappixlp 42460LDR R10,[R1],#4 42470AND R11,R10,#&FF00 42480LDR R11,[R2,R11,LSR #6] 42490AND R12,R10,#&FF0000:LDR R12,[R7,R12,LSR #14]:ADDS R14,R12,R11 42500MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42510AND R12,R10,#&FF:LDR R12,[R5,R12,LSL #2]:ADD R14,R12,R11 42520AND R12,R10,#&FF0000:LDR R12,[R6,R12,LSR #14]:ADDS R14,R14,R12 42530MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42540AND R12,R10,#&FF:LDR R12,[R3,R12,LSL #2]:ADDS R14,R12,R11 42550MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42560AND R11,R10,#&FF000000 42570LDR R11,[R2,R11,LSR #22] 42580AND R12,R10,#&FF0000:LDR R12,[R7,R12,LSR #14]:ADDS R14,R12,R11 42590MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42600AND R12,R10,#&FF:LDR R12,[R5,R12,LSL #2]:ADD R14,R12,R11 42610AND R12,R10,#&FF0000:LDR R12,[R6,R12,LSR #14]:ADDS R14,R14,R12 42620MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42630AND R12,R10,#&FF:LDR R12,[R3,R12,LSL #2]:ADDS R14,R12,R11 42640MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42650SUBS R0,R0,#2:BNE mappixlp 42660LDMFD SP !,{PC}^ 42670] 42680WHEN 555 42700[OPT Z 42710.mappix% 42720LDR R0,sxloc 42730LDR R1,[R9]:LDR R1,[R1] 42740LDR R2,[R9,#1*8] 42750LDR R3,[R9,#2*8] 42760LDR R5,[R9,#4*8] 42770LDR R6,[R9,#5*8] 42780LDR R7,[R9,#6*8] 42790LDR R9,[R9,#8*8] 42800STMFD SP !,{R14} 42810.mappixlp 42820LDR R10,[R1],#2 42830AND R11,R10,#ymax% 42840LDR R11,[R2,R11,LSL #2] 42850AND R8,R10,#((1<<vbits%)-1)<<(ybits%+ubits%) 42860AND R10,R10,#((1<<ubits%)-1)<<ybits% 42880LDR R12,[R7,R8,LSR #ybits%+ubits%-2]:ADDS R14,R12,R11 42890MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42900LDR R12,[R5,R8,LSR #ybits%+ubits%-2]:ADD R14,R12,R11 42910LDR R12,[R6,R10,LSR #ybits%-2]:ADDS R14,R14,R12 42920MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42930LDR R12,[R3,R10,LSR #ybits%-2]:ADDS R14,R12,R11 42940MOVMI R14,#0:CMP R14,#F:MOVCS R14,#F:STR R14,[R9],#4 42950SUBS R0,R0,#1:BNE mappixlp 42960LDMFD SP !,{PC}^ 42970] 42980ENDCASE 42990IFxmul%=2 AND xdiv%=1 THEN 43000[OPT Z 43020.xsample% 43030LDR R0,[R9]:LDR R0,[R0] 43040LDR R1,[R9,#8] 43050LDR R2,[R9,#2*8] 43060SUBS R0,R0,#2 43070BEQ xdonediv 43080BMI xdonediv 43090.xsamplelp 43100LDMIA R1,{R5,R6,R7,R8,R9,R10} 43110ADD R8,R8,R5 43120MOV R8,R8,LSR #1 43130ADD R9,R9,R6 43140MOV R9,R9,LSR #1 43150ADD R10,R10,R7 43160MOV R10,R10,LSR #1 43170STMIA R2!,{R5,R6,R7,R8,R9,R10} 43180ADD R1,R1,#12 43190SUBS R0,R0,#2:BGT xsamplelp 43200.xdonediv 43210LDMIA R1,{R5,R6,R7} 43220MOV R8,R5 43230MOV R9,R6 43240MOV R10,R7 43250STMIA R2!,{R5,R6,R7,R8,R9,R10} 43260MOVS PC,R14 43270] 43280ELSE 43290[OPT Z 43310.xsample% 43320LDR R0,[R9]:LDR R0,[R0] 43330LDR R1,[R9,#8] 43340LDR R2,[R9,#2*8] 43350LDR R3,[R9,#3*8]:LDR R3,[R3] 43360LDR R4,[R9,#4*8]:LDR R4,[R4] 43370MOV R11,R4 43380.xsamplelp 43390LDMIA R1,{R5,R6,R7} 43400SUBS R11,R11,#1:MOVEQ R11,R4:ADDEQ R1,R1,#12 43410SUBS R12,R3,#1 43420BEQ xdonediv 43430.xdivlp 43440CMP R12,R11 43450BCC xdivlp2 43460LDMIA R1!,{R8,R9,R10}:MLA R5,R8,R11,R5:MLA R6,R9,R11,R6:MLA R7,R10,R11,R7 43470SUBS R12,R12,R11:MOV R11,R4 43480BNE xdivlp 43490B xdonediv 43500.xdivlp2 43510LDMIA R1,{R8,R9,R10} 43520SUBS R11,R11,#1:MOVEQ R11,R4:ADDEQ R1,R1,#12 43530ADD R5,R5,R8:ADD R6,R6,R9:ADD R7,R7,R10 43540SUBS R12,R12,#1:BNE xdivlp 43550.xdonediv 43560STMIA R2!,{R5,R6,R7} 43570SUBS R0,R0,#1:BPL xsamplelp 43580MOVS PC,R14 43590] 43600ENDIF 43610ENDCASE 43620IFcompression=5 THEN 43630[OPT Z 43650.firstcode DCD 0 43660.oldcode DCD 0 43670.codesize DCD setcodes%+1 43680.stack DCD stk% 43690.sp DCD stk% 43700.maxcode DCD clearcode%+2 43710.maxcodesize DCD 2*clearcode% 43720.LZWdecode% 43730LDR R2,firstcode:LDR R3,oldcode:LDR R4,stack:LDR R5,codesize 43740LDR R6,sp:LDR R7,maxcode:LDR R8,maxcodesize 43750LDR R10,[R9]:LDR R10,[R10] 43760LDR R11,[R9,#8]:LDR R11,[R11] 43770LDR R12,[R9,#24] 43780STMFD SP !,{R14} 43790.lzwloop 43800CMP R6,R4 43810BHI lzwunstack 43820.lzwengine 43830BL getcode 43840CMP R0,#clearcode% 43850BEQ lzwclear 43870MOV R1,R0 43880CMP R0,R7 43890STRCSB R2,[R6],#1 43900MOVCS R0,R3 43910CMP R0,#clearcode% 43920BCC lzwdonepush 43930.lzwpushtable 43940LDR R14,[R12,R0,LSL #2] 43950STRB R14,[R6],#1 43960MOV R0,R14,LSR #16 43970CMP R0,#clearcode% 43980BCS lzwpushtable 43990.lzwdonepush 44000LDR R2,[R12,R0,LSL #2] 44010BIC R2,R2,#&FF0000 44020BIC R2,R2,#&FF000000 44030STRB R2,[R6],#1 44040CMP R7,#4096 44050BCS lzwnocode 44060ORR R0,R2,R3,LSL #16 44070STR R0,[R12,R7,LSL #2] 44080ADD R7,R7,#1 44090CMP R7,R8 44100BCC lzwnocode 44110CMP R8,#4096 44120ADDCC R5,R5,#1 44130MOVCC R8,R8,LSL #1 44140] 44150IFflag=1500 THEN 44160[OPT Z 44170ORRCC R8,R8,#1 44180] 44190ENDIF 44200[OPT Z 44210.lzwnocode 44220MOV R3,R1 44230CMP R6,R4 44240BLS lzwengine 44250.lzwunstack 44260LDRB R0,[R6,#-1]! 44270.lzwloopend 44280STRB R0,[R11],#1 44290SUBS R10,R10,#1 44300BNE lzwloop 44310STR R2,firstcode:STR R3,oldcode:STR R5,codesize 44320STR R6,sp:STR R7,maxcode:STR R8,maxcodesize 44330LDMFD SP !,{PC}^ 44340.lzwclear 44350MOV R0,#0 44360MOV R3,R12 44370.lzwdefaulttable 44380STR R0,[R3],#4 44390ADD R0,R0,#1:CMP R0,#clearcode% 44400BCC lzwdefaulttable 44410MOV R5,#setcodes%+1 44420MOV R7,#clearcode% 44430MOV R8,R7,LSL #1 44440] 44450IFflag=1500 THEN 44460[OPT Z 44470SUB R8,R8,#1 44480] 44490ENDIF 44500[OPT Z 44510ADD R7,R7,#2 44520BL getcode 44530MOV R2,R0 44540MOV R3,R0 44550MOV R6,R4 44560B lzwloopend 44580.curbit DCD 0 44590.lastbit DCD 0 44600.buf DCD buf% 44610.getcode 44620STMFD SP !,{R6,R7,R8} 44630ADR R6,curbit 44640LDMIA R6,{R6,R7,R8} 44650ADD R1,R5,R6 44660CMP R1,R7 44670BCS needmoredata 44680.simplecode 44690ADD R7,R8,R6,LSR #3 44700BIC R7,R7,#3 44710LDMIA R7,{R0,R7} 44720] 44730IFflag=1500 THEN 44740[OPT Z 44750EOR R1,R0,R0,ROR #16 44760BIC R1,R1,#&FF0000 44770MOV R0,R0,ROR #8 44780EOR R0,R0,R1,LSR #8 44790EOR R1,R7,R7,ROR #16 44800BIC R1,R1,#&FF0000 44810MOV R7,R7,ROR #8 44820EOR R7,R7,R1,LSR #8 44830ANDS R1,R6,#31:MOVNE R0,R0,LSL R1:RSBNE R1,R1,#32:ORRNE R0,R0,R7,LSR R1 44840RSB R1,R5,#32 44850MOV R0,R0,LSR R1 44860] 44870ELSE 44880[OPT Z 44890ANDS R1,R6,#31:MOVNE R0,R0,LSR R1:RSBNE R1,R1,#32:ORRNE R0,R0,R7,LSL R1 44900MVN R1,#0:BIC R0,R0,R1,LSL R5 44910] 44920ENDIF 44930[OPT Z 44940ADD R6,R6,R5 44950STR R6,curbit 44960LDMFD SP !,{R6,R7,R8} 44970MOV PC,R14 44980.needmoredata 44990STMFD SP !,{R2,R3,R4,R14} 45000MOV R3,R7,LSR #3 45010SUB R0,R3,#2 45020LDRB R0,[R8,R0] 45030STRB R0,[R8] 45040SUB R0,R3,#1 45050LDRB R0,[R8,R0] 45060STRB R0,[R8,#1] 45070LDR R1,[R9,#16] 45080LDR R1,[R1] 45090] 45100IFflag=1500 THEN 45110[OPT Z 45120MOV R0,#256 45130MOV R3,#256 45140] 45150ELSE 45160[OPT Z 45170BL bytefromcache% 45180MOVS R3,R0 45190BEQ simplecode1 45200] 45210ENDIF 45220[OPT Z 45230SUB R6,R6,R7 45240ADD R6,R6,#16 45250ADD R0,R0,#2 45260MOV R7,R0,LSL #3 45270STR R7,lastbit 45280ADD R2,R8,#2 45290BL multibytefromcache% 45300.simplecode1 45310LDMFD SP !,{R2,R3,R4,R14} 45320B simplecode 45330] 45340ENDIF 45350IFrange% THEN 45360[OPT Z 45380.maxmin% 45390LDR R0,[R9]:LDR R0,[R0] 45400LDR R1,[R9,#8] 45410LDR R2,min 45420LDR R3,max 45430.maxminlp 45440LDR R4,[R1],#4 45450CMP R4,R3:MOVCS R3,R4 45460CMP R4,R2:MOVCC R2,R4 45470SUBS R0,R0,#1:BNE maxminlp 45480STR R2,min 45490STR R3,max 45500MOVS PC,R14 45510.min DCD F 45520.max DCD 0 45530] 45540ENDIF 45550IFsharpen% THEN 45560sharp=(col+1)*4:IFsharpen%>0 THEN 45570IF sharpen%<>8 sharpmul%=F/(sharpen%-8) 45580ELSE 45590sharpmul%=F/(8-sharpen%) 45600ENDIF 45610[OPT Z 45630.sharp% 45640LDR R0,[R9]:LDR R0,[R0] 45650LDR R1,[R9,#8] 45660LDR R2,[R9,#16] 45670LDR R3,[R9,#24] 45680LDR R4,[R9,#32] 45690] 45700CASE sharpen% OF 45710WHEN -8 45720WHEN 8,9,12,16,24 45730OTHERWISE 45740[OPT Z 45750MOV R8,#sharpmul% AND &FF 45760ORR R8,R8,#sharpmul% AND &FF00 45770MOV R9,#(sharpmul% >> 16) AND &FF 45780ORR R9,R9,#(sharpmul% >> 16) AND &FF00 45790] 45800ENDCASE 45810[OPT Z 45820.sharplp 45830LDR R5,[R1,#-sharp] 45840LDR R6,[R1,#sharp]:ADD R5,R5,R6 45850LDR R6,[R1],#4:ADD R5,R5,R6 45860LDR R6,[R3,#-sharp]:ADD R5,R5,R6 45870LDR R6,[R3,#sharp]:ADD R5,R5,R6 45880LDR R6,[R3],#4:ADD R5,R5,R6 45890LDR R6,[R2,#-sharp]:ADD R5,R5,R6 45900LDR R6,[R2,#sharp]:ADD R5,R5,R6 45910LDR R6,[R2],#4 45920MOV R6,R6,LSR #1 45930MOV R7,#ABSsharpen% 45940MUL R7,R6,R7 45950] 45960IFsharpen%>0 THEN 45970[OPT Z 45980SUBS R5,R7,R5,LSR #1 45990MOVCC R5,#0 46000] 46010ELSE 46020[OPT Z 46030ADD R5,R7,R5,LSR #1 46040] 46050ENDIF 46060CASE sharpen% OF 46070WHEN 8,9 46080[OPT Z 46090MOV R6,R5,LSL #1 46100] 46110WHEN 10 46120[OPT Z 46130MOV R6,R5 46140] 46150WHEN 12 46160[OPT Z 46170MOV R6,R5,LSR #1 46180] 46190WHEN 16 46200[OPT Z 46210MOV R6,R5,LSR #2 46220] 46230WHEN -8,24 46240[OPT Z 46250MOV R6,R5,LSR #3 46260] 46270OTHERWISE 46280[OPT Z 46290MOV R6,R5,LSR #16 46300EOR R5,R5,R6,LSL #16 46310MUL R7,R8,R5 46320MUL R5,R9,R5 46330MUL R10,R6,R8 46340MUL R6,R9,R6 46350ADDS R10,R5,R10 46360ADDCS R6,R6,#&10000 46370ADDS R7,R7,R10,LSL #16 46380ADC R6,R6,R10,LSR #16 46390MOV R6,R6,LSL #(32-27) 46400ORRS R6,R6,R7,LSR #27 46410ADDCS R6,R6,#1 46420] 46430ENDCASE 46440IFsharpen%>0 THEN 46450[OPT Z 46460CMP R6,#F:MOVCS R6,#F 46470] 46480ENDIF 46490[OPT Z 46500STR R6,[R4],#4 46510SUBS R0,R0,#1 46520BNE sharplp 46530MOVS PC,R14 46540] 46550ENDIF 46560IFhist%ORequal% THEN 46570[OPT Z 46590.histo% 46600LDR R0,[R9]:LDR R0,[R0] 46610LDR R1,[R9,#8] 46620LDR R2,[R9,#16] 46630.histlp 46640LDR R3,[R2],#4:CMP R3,#F:MOVCS R3,#F 46650MOV R3,R3,LSR #bits-8 46660] 46670IFcol=2 THEN 46680[OPT Z 46690ADD R3,R3,R3,LSL #1 46700LDR R4,[R1,R3,LSL #2]:ADD R4,R4,#1:STR R4,[R1,R3,LSL #2] 46710LDR R3,[R2],#4:CMP R3,#F:MOVCS R3,#F 46720MOV R3,R3,LSR #bits-8 46730ADD R3,R3,R3,LSL #1:ADD R3,R3,#1 46740LDR R4,[R1,R3,LSL #2]:ADD R4,R4,#1:STR R4,[R1,R3,LSL #2] 46750LDR R3,[R2],#4:CMP R3,#F:MOVCS R3,#F 46760MOV R3,R3,LSR #bits-8 46770ADD R3,R3,R3,LSL #1:ADD R3,R3,#2 46780] 46790ENDIF 46800[OPT Z 46810LDR R4,[R1,R3,LSL #2]:ADD R4,R4,#1:STR R4,[R1,R3,LSL #2] 46820SUBS R0,R0,#1 46830BNE histlp 46840MOVS PC,R14 46850] 46860ENDIF 46870IFequal% THEN 46880[OPT Z 46900.histequal% 46910LDR R0,[R9]:LDR R0,[R0] 46920LDR R1,[R9,#8] 46930LDR R2,[R9,#16] 46940.equallp 46950LDR R3,[R2]:CMP R3,#F:MOVCS R3,#F 46960MOV R3,R3,LSR #bits-8 46970] 46980IFcol=2 THEN 46990[OPT Z 47000LDR R3,[R2]:CMP R3,#F:MOVCS R3,#F 47010MOV R3,R3,LSR #bits-8 47020ADD R3,R3,R3,LSL #1 47030LDR R4,[R1,R3,LSL #2]:STR R4,[R2],#4 47040LDR R3,[R2]:CMP R3,#F:MOVCS R3,#F 47050MOV R3,R3,LSR #bits-8 47060ADD R3,R3,R3,LSL #1:ADD R3,R3,#1 47070LDR R4,[R1,R3,LSL #2]:STR R4,[R2],#4 47080LDR R3,[R2]:CMP R3,#F:MOVCS R3,#F 47090MOV R3,R3,LSR #bits-8 47100ADD R3,R3,R3,LSL #1:ADD R3,R3,#2 47110] 47120ENDIF 47130[OPT Z 47140LDR R4,[R1,R3,LSL #2]:STR R4,[R2],#4 47150SUBS R0,R0,#1 47160BNE equallp 47170MOVS PC,R14 47180] 47190ENDIF 47200CASE r$ OF 47210WHEN "FN800","FN801","FN1000","FN1001" 47220[OPT Z 47250.rlexpand% 47260LDR R0,[R9] 47270LDR R1,[R0] 47280LDR R2,[R9,#8]:LDR R2,[R2] 47290LDR R3,[R9,#16] 47300LDR R4,[R3] 47310CMP R4,#1:MOVLTS PC,R14 47320LDR R5,[R9,#24]:LDR R5,[R5] 47330.rle 47340STRB R2,[R1],#1 47350SUB R4,R4,#1 47360CMP R1,R5 47370TEQNE R4,#0 47380BNE rle 47390.rlexit 47400STR R1,[R0] 47410STR R4,[R3] 47420MOVS PC,R14 47430] 47440WHEN "FN902" 47450[OPT Z 47460.unpack% 47470LDR R0,[R9] 47480LDR R0,[R0] 47490LDR R1,plbuff 47500ADD R2,R0,#768 47510.unpackloop 47520LDR R3,[R0],#4 47530MOV R5,#0 47540.bitloop 47550MOV R6,R3,LSR R5 47560AND R6,R6,#15 47570ADD R5,R5,#4 47580MOV R7,R3,LSR R5 47590AND R7,R7,#15 47600ADD R5,R5,#4 47610STRB R7,[R1],#1 47620STRB R6,[R1],#1 47630CMP R5,#32 47640BNE bitloop 47650CMP R2,R0 47660BNE unpackloop 47670MOV PC,R14 47680.plbuff EQUD plbuff% 47690] 47700WHEN "FN1601","FN1501","FN1850","FN1851" 47710[OPT Z 47730.readiff% 47740MOV R1,#c% 47750LDR R8,[R9]:LDR R8,[R8] 47760LDR R7,[R9,#8]:LDR R7,[R7]:ADD R7,R7,R8 47770STMFD SP !,{R14} 47780] 47790IFr$="FN1850" OR r$="FN1851" THEN 47800[OPT Z 47810BL bytefromcache% 47820] 47830IFsy%>250 THEN 47840[OPT Z 47850BL bytefromcache% 47860] 47870ENDIF 47880ENDIF 47890[OPT Z 47900.rle 47910BL bytefromcache% 47920CMP R0,#128 47930BCC rle1 47940RSB R2,R0,#256 47950BL bytefromcache% 47960.rle0 STRB R0,[R8],#1 47970SUBS R2,R2,#1 47980BPL rle0 47990B rle2 48000.rle1 48010ADD R3,R0,#1 48020MOV R2,R8 48030ADD R8,R8,R3 48040BL multibytefromcache% 48050.rle2 48060CMP R8,R7 48070BCC rle 48080LDMFD SP !,{R14} 48090MOVS PC,R14 48100] 48110WHEN "FN1900","FN1100","FN400" 48120[OPT Z 48140.readline% 48150LDR R2,[R9]:LDR R2,[R2] 48160LDR R3,[R9,#8] 48170LDR R0,[R3] 48180LDR R4,[R9,#16] 48190LDR R5,[R4] 48200LDR R6,[R9,#24]:LDR R6,[R6]:ADD R6,R6,R2 48210STMFD SP !,{R14} 48220.rle 48230CMP R5,#1 48240BGE rle1 48250BL bytefromcache% 48260MOV R5,#1 48270] 48280IFflag=1900 THEN 48290[OPT Z 48300CMP R0,#192 48310ANDCS R5,R0,#63:BLCS bytefromcache% 48320] 48330ENDIF 48340IFflag=1100 THEN 48350[OPT Z 48360CMP R0,#128 48370BNE rle1 48380BL bytefromcache% 48390TEQ R0,#0 48400MOVEQ R0,#128 48410BEQ rle1 48420ADD R5,R0,#1 48430BL bytefromcache% 48440] 48450ENDIF 48460IFflag=400 THEN 48470[OPT Z 48480MOV R1,R0 48490BL bytefromcache% 48500ORR R1,R1,R0,LSL #8 48510BL bytefromcache% 48520ORR R1,R1,R0,LSL #16 48530BL bytefromcache% 48540ADD R5,R0,#1 48550MOV R0,R1 48560] 48570ENDIF 48580IFflag=200 THEN 48590[OPT Z 48600ADD R5,R0,#1 48610BL bytefromcache% 48620] 48630ENDIF 48640[OPT Z 48650.rle1 48660STRB R0,[R2],#1 48670] 48680IFflag=400 THEN 48690[OPT Z 48700MOV R1,R0,LSR #8 48710STRB R1,[R2],#1 48720MOV R1,R0,LSR #16 48730STRB R1,[R2],#1 48740] 48750ENDIF 48760[OPT Z 48770SUB R5,R5,#1 48780TEQ R2,R6 48790BNE rle 48800.rlexit 48810STR R0,[R3]:STR R5,[R4] 48820LDMFD SP !,{PC}^ 48830] 48840WHEN "FN2401" 48850[OPT Z 48860.bm_rle8 48870MOV R1,#c% 48880LDR R8,[R9]:LDR R8,[R8] 48890LDR R7,[R9,#8]:LDR R7,[R7]:ADD R7,R7,R8 48900STMFD SP !,{R14} 48910.rle 48920BL bytefromcache% 48930TEQ r0,#0 48940BEQ rlecopy 48960MOV r4,r0 48970BL bytefromcache% 48980.rle1 48990STRB r0,[r8],#1 49000SUBS r4,r4,#1 49010BGT rle1 49020B rle 49030.rlecopy 49050BL bytefromcache% 49060CMP r0,#3 49070BLT rlespecial 49080MOV r4,r0 49090.rle2 49110BL bytefromcache% 49120STRB r0,[r8],#1 49130BL bytefromcache% 49140SUBS r4,r4,#1 49150STRGTB r0,[r8],#1 49160SUBGTS r4,r4,#1 49170BGT rle2 49180B rle 49190.rlespecial 49300LDMFD SP !,{R14} 49310MOVS PC,R14 49320] 49330WHEN "FN2402" 49340[OPT Z 49350.bm_rle4 49360MOV R1,#c% 49370LDR R8,[R9]:LDR R8,[R8] 49380LDR R7,[R9,#8]:LDR R7,[R7]:ADD R7,R7,R8 49390STMFD SP !,{R14} 49400MOV r2,#0 49410MOV r3,#0 49420.rle 49430BL bytefromcache% 49440TEQ r0,#0 49450BEQ rlecopy 49470MOV r4,r0 49480BL bytefromcache% 49490.rle1 49500BL bmrle4_insert 49510CMP r3,#8 49520MOVGE r5,r2,LSR#24 49530STRGEB r5,[r8],#1 49540MOVGE r2,r2,LSL#8 49550SUBGE r3,r3,#8 49560CMP r4,#0 49570BGT rle1 49580B rle 49590.rlecopy 49610BL bytefromcache% 49620CMP r0,#3 49630BLT rlespecial 49640MOV r4,r0 49650.rle2 49670BL bytefromcache% 49680BL bmrle4_insert 49690BL bytefromcache% 49700CMP r4,#0 49710BLGT bmrle4_insert 49720B rle4 49730.rle3 49740MOV r5,r2,LSR#24 49750STRB r5,[r8],#1 49760MOV r2,r2,LSL#8 49770SUB r3,r3,#8 49780.rle4 49790CMP r3,#8 49800BGE rle3 49810CMP r4,#0 49820BGT rle2 49830B rle 49840.rlespecial 49940CMP r3,#0 49950MOVGT r5,r2,LSR#24 49960STRGTB r5,[r8],#1 49980LDMFD SP !,{R14} 49990MOVS PC,R14 50000.bmrle4_insert 50010RSB r5,r3,#32 50020MOV r2,r2,LSR r5 50030MOV r2,r2,LSL r5 50040SUB r5,r5,#8 50050ORR r2,r2,r0,LSL r5 50060SUBS r4,r4,#2 50070ADDMI r3,r3,#4 50080ADDPL r3,r3,#8 50090MOVS PC,R14 50100] 50110ENDCASE 50120IFcachebytes% THEN 50130[OPT Z 50140.bytefromcache% 50150STMFD SP !,{R1,R2} 50160LDR R1,incacheptr 50170LDR R2,numlefttogo 50180LDRB R0,[R1],#1 50190SUBS R2,R2,#1 50200STRNE R1,incacheptr 50210STRNE R2,numlefttogo 50220LDMFD SP !,{R1,R2} 50230MOVNE PC,R14 50240STMFD SP !,{R0,R1,R2,R3,R4} 50250LDR R2,valdatacache 50260STR R2,incacheptr 50270LDR R3,valcache 50280STR R3,numlefttogo 50290MOV R0,#4 50300MOV R1,#c% 50310SWI "OS_GBPB" 50320LDMFD SP !,{R0,R1,R2,R3,R4} 50330MOV PC,R14 50340.valdatacache DCD datacache% 50350.valcache DCD cache% 50360.incacheptr DCD datacache% 50370.numlefttogo DCD cache% 50380.multibytefromcache% 50390CMP R3,#0 50400MOVEQ PC,R14 50410STMFD SP !,{R0,R14} 50420.multibytefromcachel 50430BL bytefromcache% 50440STRB R0,[R2],#1 50450SUBS R3,R3,#1 50460BNE multibytefromcachel 50470LDMFD SP !,{R0,R14} 50480MOV PC,R14 50490] 50500ENDIF 50510IFplanar%<0 THEN 50520C%=7:IFflag=2600 C%=15 50530[OPT Z 50540.plancnv% 50550LDR R0,sxloc 50560LDR R1,[R9]:LDR R1,[R1] 50570LDR R3,[R9,#8]:LDR R3,[R3] 50580LDR R4,[R9,#16]:LDR R4,[R4] 50590] 50600IFflag=3500 THEN 50610[OPT Z 50620MOV R9,#0 50630] 50640ELSE 50650[OPT Z 50660MOV R9,#C% 50670] 50680ENDIF 50690[OPT Z 50700.planelp 50710MOV R7,#0 50720MOV R5,R3 50730] 50740FORN%=1TOplanes% 50750[OPT Z 50760LDR R6,[R5],R4 50770] 50780IFflag=2600 THEN 50790[OPT Z 50800MOV R6,R6,LSL #8 50810BIC R6,R6,#&FF000000 50820ORR R6,R6,R6,LSR #16 50830] 50840ENDIF 50850IFflag=3500 THEN 50860[OPT Z 50870MOV R6,R6,LSR R9 50880ANDS R6,R6,#1 50890ORR R7,R7,R6,LSL #(planes%-N%) 50900ORRNE R7,R7,#(planes%-1) 50910] 50920ELSE 50930[OPT Z 50940MOV R6,R6,LSR R9 50950AND R6,R6,#1 50960ORR R7,R7,R6,LSL #(N%-1) 50970] 50980ENDIF 50990NEXT 51000[OPT Z 51010STRB R7,[R1],#1 51020] 51030IFflag=3500 THEN 51040[OPT Z 51050ADD R9,R9,#1 51060CMP R9,#C%+1 51070MOVEQ R9,#0 51080] 51090ELSE 51100[OPT Z 51110SUBS R9,R9,#1:MOVMI R9,#C% 51120] 51130ENDIF 51140CASE flag OF 51150WHEN 2600 51160[OPT Z 51170MOVMI R3,R5 51180] 51190WHEN 3500 51200[OPT Z 51210ADDEQ R3,R3,#1 51220] 51230OTHERWISE 51240[OPT Z 51250ADDMI R3,R3,#1 51260] 51270ENDCASE 51280[OPT Z 51290SUBS R0,R0,#1:BNE planelp 51300MOVS PC,R14 51310] 51320ENDIF 51330NEXT 51340cputime%=TIME 51350IFcache% THEN 51360IFflag=3600 THEN 51370pcdblk%!12=cacherows%:PROCrefillpcd:IFcache%>=filesize% rowstogo%=-1 51380ELSE 51390IFstriprows%>0ANDcompression>1 THEN 51410SYS12,4,c%,datacache%,cache% 51420IFcachebytes% !incacheptr=datacache%:!numlefttogo=cache% 51430ELSE 51440PROCrefill:IFcache%>=filesize% rowstogo%=-1 51450ENDIF 51460ENDIF 51470ENDIF 51480sizeshft%=0:CASE ncol OF 51490WHEN 2^24-1:size%=1 51500WHEN 2^15-1:size%=1 51510WHEN 63,255,256:size%=1 51520WHEN 15:size%=2:sizeshft%=1 51530WHEN 3:size%=4:sizeshft%=2 51540WHEN 1:size%=8:sizeshft%=3:IFm$="C" size%=2:sizeshft%=1 51550IFm$="D" size%=4:sizeshft%=2 51560IFm$="T" size%=2:sizeshft%=1 51570ENDCASE 51590CASE flag OF 51600WHEN 501:IFinfo% PRINT"Reading interlaced GIF" 51610sz%=sx%*sy%:plbuff%=FNdim(sz%+100) 51620FORY%=0TOsy%-1STEP8:X%=plbuff%+Y%*sx%:CALL LZWdecode%,table%(0),c%,X%,sx%:NEXT 51630FORY%=4TOsy%-1STEP8:X%=plbuff%+Y%*sx%:CALL LZWdecode%,table%(0),c%,X%,sx%:NEXT 51640FORY%=2TOsy%-1STEP4:X%=plbuff%+Y%*sx%:CALL LZWdecode%,table%(0),c%,X%,sx%:NEXT 51650FORY%=1TOsy%-1STEP2:X%=plbuff%+Y%*sx%:CALL LZWdecode%,table%(0),c%,X%,sx%:NEXT 51660datacache%=plbuff%:buff%=plbuff%:rowbytes%=sx%:rowstogo%=-1 51670ENDCASE 51680IFgamma<>1 AND gamma<>0 THEN 51690k=1/gamma:FORC%=0TOcolourindex 51700IFr%(C%) r%(C%)=((r%(C%)/F)^k)*F 51710IFg%(C%) g%(C%)=((g%(C%)/F)^k)*F 51720IFb%(C%) b%(C%)=((b%(C%)/F)^k)*F 51730NEXT 51740ENDIF 51750rmax=F:gmax=F:bmax=F 51760IFcol=0 THEN 51770IFinput<9 THEN 51780FORC%=0TO255:r%(C%)=r%(C%)*rwt+g%(C%)*gwt+b%(C%)*bwt:NEXT 51790ELSE 51800IFinput<400 THEN 51810rmax=F*rwt:gmax=F*gwt:bmax=F*bwt 51820FORC%=0TOcolourindex:r%(C%)=r%(C%)*rwt:g%(C%)=g%(C%)*gwt:b%(C%)=b%(C%)*bwt:NEXT 51830ENDIF 51840ENDIF 51850ENDIF 51860IFNOTorder% PROCadjustpalette(1/ydiv%/xdiv%,0) 51880IFrange% THEN 51890IFinfo% PRINT"Scanning data to compute parameters for '-range'" 51900IForder% THEN 51910Y%=0:REPEAT SYShour%,Y%*100DIVsy% 51920W%=EVAL(r$+"(xp%())"):CALLmaxmin%,xp%(1,0),totvals2%:Y%+=1 51930UNTILY%=sy% OR!min<255 AND!max+255>=F 51940ELSE 51950Y%=0:ysamp%=1:REPEAT SYShour%,Y%*100DIVy% 51960PROCscaledpixelrow(cl%()):CALLmaxmin%,cl%(1,0),totvals%:Y%+=1 51970UNTILY%=y% OR !min<255 AND !max+255>=F 51980ENDIF 51990IF!max+255>=F AND!min<255 range%=FALSE:range$="No point in '-range' on this image" 52000IFrange% PROCadjustpalette(F/(!max-!min),!min/ydiv%/xdiv%):range$="Input image maximum "+STR$(!max/F*100)+"% minimum "+STR$(!min/F*100)+"%" 52010PROCrewind:IFinfo% PRINTrange$ 52020ENDIF 52030IFhist% ORequal% THEN 52040IFequal% IFinfo% PRINT"Scanning data to compute parameters for '-equal'" 52050IForder% THEN 52060FORyr%=0TOsy%-1:SYShour%,yr%*100DIVsy% 52070W%=EVAL(r$+"(xp%())"):CALLhisto%,xp%(1,0),vals%(0,0),sx% 52080NEXT 52090ELSE 52100ysamp%=1:FORyr%=0TOy%-1:SYShour%,yr%*100DIVy% 52110PROCscaledpixelrow(cl%()):CALLhisto%,cl%(1,0),vals%(0,0),x% 52120NEXT 52130ENDIF 52140IFinfo% PRINT"Done. Now processing the picture" 52150ENDIF 52160IFinput<400 THEN 52170FORC%=0TOcolourindex 52180IFr%(C%)<0 r%(C%)=0 52190IFg%(C%)<0 g%(C%)=0 52200IFb%(C%)<0 b%(C%)=0 52210IFr%(C%)>rmax r%(C%)=rmax 52220IFg%(C%)>gmax g%(C%)=gmax 52230IFb%(C%)>bmax b%(C%)=bmax 52240NEXT 52250ENDIF 52260IFhist% THEN 52270M%=0:ZM%=-1:FORC%=0TOcol 52280FORZ%=0TO256:IFvals%(Z%,C%)>M% M%=vals%(Z%,C%):ZM%=Z% 52290NEXT:NEXT 52300IFZM%=-1 OR okinfo%=0 THEN=100 52310IF col>0 THEN 52320MODE66:ht=500 52330IFMODE<>66 MODE16:ht=400 52340LINE0,6,2000,6 52350ELSE 52360MODE18:ht=400:LINE0,6,1024,6 52370ENDIF 52380M=M%/(ht*2-8):FORC%=0TOcol:CASE C% OF 52390WHEN 0:GCOL1 52400WHEN 1:GCOL2 52410WHEN 2:GCOL4 52420ENDCASE 52430IF col>0 THEN 52440FORZ%=0TO256:IFvals%(Z%,C%) X%=Z%*3+C%<<1:LINEX%,8,X%,vals%(Z%,C%)/M+8 52450NEXT 52460ELSE 52470FORZ%=0TO256:IFvals%(Z%,C%) X%=Z%<<2:RECTANGLE FILLX%,8,2,vals%(Z%,C%)/M 52480NEXT 52490ENDIF 52500NEXT 52510PROCclose:SYS"Hourglass_Off" 52520=100 52530ENDIF 52540IFm>=0 oname$="p"+STR$m+m$ ELSEoname$=m$ 52550IFm=-6 ORm=-7 ORm=-8 oname$=pnm$ 52560IFrange% oname$+="r" 52570IFequal% oname$+="e" 52580IFsharpen% oname$+="s"+STR$sharpen% 52590IFblack% oname$+="b"+STR$black% 52600IFgamma<>1 A%=@%:@%=&1020100:oname$+="g"+STR$gamma:@%=A% 52610IFbright%=16 oname$+="b" 52620xsp%=x%:ysp%=y%:IFrotate% SWAP xsp%,ysp% 52630IF rotate% OR hflip% OR vflip% IFm=-9 OR m=-10 THENm-=2 52640IFm=-9ORm=-10 THEN 52650DIM jpq%(20) 52660jpq%()=60,75,90,105,120,135,150,160,170,180,190,205,215,235,255,280,320,380,500,750,850 52670ENDIF 52680CASE m OF 52690WHEN -1:xwords%=xsp%:sz%=xwords%*ysp%:Y%=ysp% 52700PROCgetoutput(sz%,0,xwords%,Y%):base%=ram% 52710WHEN -3,-5:xwords%=xsp%*2:sz%=xwords%*ysp%:Y%=ysp% 52720PROCgetoutput(sz%,0,xwords%,Y%):base%=ram% 52730WHEN -4:xwords%=xsp%*3:sz%=xwords%*ysp%:Y%=ysp% 52740PROCgetoutput(sz%,0,xwords%,Y%):base%=ram% 52750WHEN -6:xwords%=xsp%*2+3ANDNOT3:sz%=xwords%*ysp%:Y%=ysp% 52760A%=Y%:PROCgetoutput(sz%,64,xwords%,Y%) 52770ram%!4=0:ram%!8=16:ram%!12=16:SYS&2e,&109,ram% 52780SYS&2e,&10f,ram%,oname$,0,xsp%*2,Y%,28 52790base%=ram%+ram%!8:base%!(5*4)=A%-1:!base%=!base%-Y%*xwords%+A%*xwords% 52800ram%!12=ram%!12-Y%*xwords%+A%*xwords% 52810base%!(10*4)=5<<27 OR nx<<1 OR ny<<14 OR 1:base%+=base%!(8*4) 52820WHEN -7:xwords%=xsp%*3+3ANDNOT3:sz%=xwords%*ysp%:Y%=ysp% 52830A%=Y%:PROCgetoutput(sz%,64,xwords%,Y%) 52840ram%!4=0:ram%!8=16:ram%!12=16:SYS&2e,&109,ram% 52850SYS&2e,&10f,ram%,oname$,0,xsp%*3,Y%,28 52860base%=ram%+ram%!8:base%!(5*4)=A%-1:!base%=!base%-Y%*xwords%+A%*xwords% 52870ram%!12=ram%!12-Y%*xwords%+A%*xwords% 52880base%!(10*4)=panic<<27 OR nx<<1 OR ny<<14 OR 1:base%+=base%!(8*4) 52890no magic number yet for new format 24bpp sprites 52900WHEN -8:xwords%=xsp%*4:sz%=xwords%*ysp%:Y%=ysp% 52910A%=Y%:PROCgetoutput(sz%,64,xwords%,Y%) 52920ram%!4=0:ram%!8=16:ram%!12=16:SYS&2e,&109,ram% 52930SYS&2e,&10f,ram%,oname$,0,xsp%*4,Y%,28 52940base%=ram%+ram%!8:base%!(5*4)=A%-1:!base%=!base%-Y%*xwords%+A%*xwords% 52950ram%!12=ram%!12-Y%*xwords%+A%*xwords% 52960base%!(10*4)=6<<27 OR nx<<1 OR ny<<14 OR 1:base%+=base%!(8*4) 52970WHEN -9:xwords%=xsp%+3ANDNOT3:sz%=(xsp%+7ANDNOT7)*(ysp%+7ANDNOT7):Y%=ysp% 52980sz%=sz%*jpq%(jpegquality%DIV5)/588+1024 52990jpegwrk%=FNdim((xsp%+7ANDNOT7)*9+20000) 53000base%=FNdim(xwords%) 53010PROCgetoutputjp(sz%) 53020!ram%=xsp%:ram%!4=ysp%:ram%!8=jpegquality%:ram%!12=1:ram%!16=90:ram%!20=90 53030SYS"CompressJPEG_Start",ram%,sz%,ram%,jpegwrk%,(xsp%+7ANDNOT7)*9+20000 TO jpegtag% 53040WHEN -10:xwords%=xsp%*3+3ANDNOT3:sz%=(xsp%+15ANDNOT15)*(ysp%+15ANDNOT15)*12/8:Y%=ysp% 53050sz%=sz%*jpq%(jpegquality%DIV5)/588+1024 53060jpegwrk%=FNdim((xsp%+15ANDNOT15)*30+20000) 53070base%=FNdim(xwords%) 53080PROCgetoutputjp(sz%) 53090!ram%=xsp%:ram%!4=ysp%:ram%!8=jpegquality%:ram%!12=3:ram%!16=90:ram%!20=90 53100SYS"CompressJPEG_Start",ram%,sz%,ram%,jpegwrk%,(xsp%+15ANDNOT15)*30+20000 TO jpegtag% 53110WHEN -11:xwords%=xsp%:sz%=xwords%*ysp%+20000:Y%=ysp% 53120jpegwrk%=FNdim((xsp%+7ANDNOT7)*9+20000) 53130PROCgetoutput(sz%,0,xwords%,Y%):base%=ram%+20000 53140WHEN -12:xwords%=xsp%*3:sz%=xwords%*ysp%+20000:Y%=ysp% 53150jpegwrk%=FNdim((xsp%+15ANDNOT15)*30+20000) 53160PROCgetoutput(sz%,0,xwords%,Y%):base%=ram%+20000 53170OTHERWISE:xwords%=xsp%/size%+3.9999ANDNOT3:sz%=xwords%*ysp%:X%=xsp%:Y%=ysp% 53180IFncol=1 THEN 53190CASE m$ OF 53200WHEN"C":!rowinc=xwords%:xwords%=xwords%*4:sz%=xwords%*ysp%:X%=xsp%*4:Y%=ysp%*4 53210WHEN"T":!rowinc=xwords%:xwords%=xwords%*3:sz%=xwords%*ysp%:X%=xsp%*4:Y%=ysp%*3 53220WHEN"D":!rowinc=xwords%:xwords%=xwords%*2:sz%=xwords%*ysp%:X%=xsp%*2:Y%=ysp%*2 53230ENDCASE 53240ENDIF 53250A%=Y%:PROCgetoutput(sz%,2048+64,xwords%,Y%) 53260ram%!4=0:ram%!8=16:ram%!12=16:SYS&2e,&109,ram% 53270SYS&2e,&10f,ram%,oname$,(ncol<63)AND1,X%,Y%,spm 53280base%=ram%+ram%!8:base%!(5*4)=A%-1:!base%=!base%-Y%*xwords%+A%*xwords% 53290ram%!12=ram%!12-Y%*xwords%+A%*xwords% 53300pal%=base%+11*4:base%+=base%!(8*4) 53310CASE ncol OF 53320WHEN 256 53330!(pal%-8)+=2048:!(pal%-12)+=2048:base%+=2048:!(ram%+12)+=2048:!(pal%-44)+=2048 53340FORZ%=0TO255:B%=Z%ORZ%<<8ORZ%<<16:B%=B%<<8 53350pal%!(Z%*8)=B%:pal%!(Z%*8+4)=B%:NEXT 53360WHEN 255 53370!(pal%-8)+=2048:!(pal%-12)+=2048:base%+=2048:!(ram%+12)+=2048:!(pal%-44)+=2048 53380FORZ%=0TO255:B%=palette%!(Z%<<2)<<8 53390pal%!(Z%*8)=B%:pal%!(Z%*8+4)=B%:NEXT 53400WHEN 15 53410CASE m$ OF 53420WHEN "R" 53430FORZ%=0TO15:PROCcol(Z%,palette%!(Z%<<2)AND&F0F0F0):NEXT 53440WHEN "D" 53450FORZ%=0TO7:A%=0:IFZ%AND1 A%+=&F0 53460IFZ%AND2 A%+=&F000 53470IFZ%AND4 A%+=&F00000 53480PROCcol(Z%,A%):NEXT 53490WHEN "T" 53500FORZ%=0TO15:A%=Z%<<4:PROCcol(Z%,A%ORA%<<8ORA%<<16):NEXT 53510OTHERWISE 53520FORZ%=0TO15:A%=(Z%AND7)/7*15+.2<<4:PROCcol(Z%,A%ORA%<<8ORA%<<16):NEXT 53530ENDCASE 53540WHEN 3 53550CASEm$ OF 53560WHEN "C" 53570PROCcol(0,0):PROCcol(1,&F0F000):PROCcol(2,&F000F0):PROCcol(3,&F0F0) 53580WHEN "R" 53590FORZ%=0TO3:PROCcol(Z%,palette%!(Z%<<2)AND&F0F0F0):NEXT 53600OTHERWISE 53610FORZ%=0TO3:A%=Z%*5<<4:PROCcol(Z%,A%ORA%<<8ORA%<<16):NEXT 53620ENDCASE 53630WHEN 1:PROCcol(0,0):PROCcol(1,&F0F0F0) 53640ENDCASE 53650ENDCASE 53670IFflex% THEN 53690ELSE 53700IFworkspace%<0 THEN 53710P%=END:[OPT 0:STR r13,P%+16:MOVS Pc,r14:]:CALLEND 53720END=END+32*1024+HIMEM-!(END+16) 53730ELSE 53750ENDIF 53760ENDIF 53770IFbase%*size%>2^32 ERROR 42,"base%*size% product too large" 53780LOCAL ERROR 53790ON ERROR LOCAL:RESTORE ERROR:PROCSave:ERROR ERR,REPORT$+" internal ("+STR$ERL+")" 53800SYS"Hourglass_LEDs",3 53810ysamp%=1:nl%()=0:step%=4*(col+1) 53820addr%=base%<<sizeshft%:rowstep%=xwords%*size%:colstep%=1:dist%=xsp%-1 53830IFm=-3ORm=-5ORm=-6 dist%=dist%*2 53840IFm=-4ORm=-7ORm=-10ORm=-12 dist%=dist%*3 53850IFm=-8 dist%=dist%*4 53860IFrotate% THEN 53870odist%=dist%:SWAP colstep%,rowstep%:SWAP hflip%,vflip% 53880IFrotate%=1 THEN 53890addr%+=(ysp%-1)*colstep%:colstep%=-colstep%:dist%=(ysp%-1)*colstep% 53900ELSE 53910addr%+=dist%:rowstep%=-rowstep%:dist%=(ysp%-1)*colstep% 53920ENDIF 53930IFm=-3ORm=-5ORm=-6 colstep%=colstep%/2:rowstep%=rowstep%*2 53940IFm=-4ORm=-7ORm=-10ORm=-12 colstep%=colstep%/3:rowstep%=rowstep%*3 53950IFm=-8 colstep%=colstep%/4:rowstep%=rowstep%*4 53960ENDIF 53970IFhflip% THEN 53980addr%+=dist%:dist%=-dist%:colstep%=-colstep% 53990ENDIF 54000IFvflip% THEN 54010IFrotate% THEN 54020addr%+=odist%*rotate%:rowstep%=-rowstep% 54030ELSE 54040addr%+=(ysp%-1)*rowstep%:rowstep%=-rowstep% 54050ENDIF 54060ENDIF 54070outlim%=((base%+xwords%*Y%)<<sizeshft%)-1:oddcolstep%=-colstep%:oddstep%=-step% 54080IForder% PROCadjustpalette(1/ydiv%/xdiv%,0) 54090IFm=-9ORm=-10 THEN 54100SYS "OS_SWINumberFromString",,"CompressJPEG_WriteLine" TO wl% 54110IFsy%=y% AND sx%=x% AND range%=FALSE AND sharpen%=FALSE AND equal%=FALSE THEN 54120IFdither% THEN 54130FORyr%=0 TO y%-1:SYShour%,yr%*100DIVy% 54140W%=EVAL(r$+"(cl%())"):cl%()=cl%()+nl%():nl%()=0:B%=x% 54150IFyr%AND1 THEN 54160CALLfs%,colstep%,cl%(1,0),nl%(1,0),addr%,step%,B% 54170ELSE 54180A%=addr%+dist%:CALLfs%,oddcolstep%,cl%(x%,0),nl%(x%,0),A%,oddstep%,B% 54190ENDIF 54200SYSwl%,jpegtag%,addr% 54210NEXT 54220ELSE 54230I%=step%:FORyr%=0TOy%-1:SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 54240W%=EVAL(r$+"(cl%())"):B%=x%:CALLfs%,colstep%,cl%(1,0),I%,addr%,I%,B% 54250SYSwl%,jpegtag%,addr% 54260NEXT 54270ENDIF 54280ELSE 54290IFequal% THEN 54300PROCrewind:Havg%=SUM(vals%())/256/(col+1):DIM new%(256,col) 54310FORB%=0TOcol:R%=0:Hint%=0:FORZ%=0TO256:L%=R%:Hint%+=vals%(Z%,B%) 54320WHILEHint%>Havg%:Hint%-=Havg%:R%+=1:ENDWHILE 54330new%(Z%,B%)=(L%+R%)/2*F/256 54340NEXT:NEXT 54350ENDIF 54360IFsharpen% THEN 54370IForder% THEN 54380yread%=sy%-1:W%=EVAL(r$+"(rm1%())"):IFequal% PROCfit2(rm1%()) 54390FORB%=0TOcol:rm1%(0,B%)=rm1%(1,B%):rm1%(sx%+1,B%)=rm1%(sx%,B%):NEXT 54400ELSE 54410yread%=y%-1:PROCscaledpixelrow(rm1%()):IFequal% PROCfit(rm1%()) 54420FORB%=0TOcol:rm1%(0,B%)=rm1%(1,B%):rm1%(x%+1,B%)=rm1%(x%,B%):NEXT 54430ENDIF 54440rm2%()=rm1%() 54450ENDIF 54460IForder% THEN 54470FORyr%=0 TO y%-1 54480SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 54490IFsy%=y% THEN 54500PROCsharppixelrow(cl%()) 54510ELSE 54520ysamp%-=1:IFysamp%=0 PROCsharppixelrow(xl%()):ysamp%=ymul% 54530IFydiv%=1 THEN 54540cl%()=xl%() 54550ELSE 54560IFysamp%>=ydiv% THEN 54570ysamp%-=ydiv%:cl%()=xl%()*ydiv% 54580ELSE 54590cl%()=xl%()*ysamp%:Y%=ydiv%-ysamp%:ysamp%=0 54600REPEAT 54610IFysamp%=0 PROCsharppixelrow(xl%()):ysamp%=ymul% 54620IFysamp%>Y% THEN 54630ysamp%-=Y%:xl2%()=xl%()*Y%:cl%()=cl%()+xl2%():Y%=0 54640ELSE 54650Y%-=ysamp%:xl2%()=xl%()*ysamp%:cl%()=cl%()+xl2%():ysamp%=0 54660ENDIF 54670UNTIL Y%=0 54680ENDIF 54690ysamp%+=1 54700ENDIF 54710ENDIF 54720cl%()=cl%()+nl%():nl%()=0:B%=x%:A%=addr%+dist% 54730IFyr%AND1 THEN 54740CALLfs%,colstep%,cl%(1,0),nl%(1,0),addr%,step%,B% 54750ELSE 54760CALLfs%,oddcolstep%,cl%(x%,0),nl%(x%,0),A%,oddstep%,B% 54770ENDIF 54780SYSwl%,jpegtag%,addr% 54790NEXT 54800ELSE 54810FORyr%=0 TO y%-1 54820SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 54830IFsharpen% THEN 54840IFyread% yread%-=1:PROCscaledpixelrow(rm%()):IFequal% PROCfit(rm%()) 54850FORB%=0TOcol:rm%(0,B%)=rm%(1,B%):rm%(x%+1,B%)=rm%(x%,B%):NEXT 54860CALL sharp%,cl%(1,0),rm%(1,0),rm1%(1,0),rm2%(1,0),totvals% 54870SWAP rm2%(),rm1%():rm1%()=rm%() 54880ELSE 54890PROCscaledpixelrow(cl%()):IFequal% PROCfit(cl%()) 54900ENDIF 54910cl%()=cl%()+nl%():nl%()=0:B%=x%:A%=addr%+dist% 54920IFyr%AND1 THEN 54930CALLfs%,colstep%,cl%(1,0),nl%(1,0),addr%,step%,B% 54940ELSE 54950CALLfs%,oddcolstep%,cl%(x%,0),nl%(x%,0),A%,oddstep%,B% 54960ENDIF 54970SYSwl%,jpegtag%,addr% 54980NEXT 54990ENDIF 55000ENDIF 55010SYS"CompressJPEG_Finish",jpegtag% TO jpegsize% 55020ELSE 55030IFsy%=y% AND sx%=x% AND range%=FALSE AND sharpen%=FALSE AND equal%=FALSE THEN 55040IFdither% THEN 55050FORyr%=0 TO y%-1:SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 55060W%=EVAL(r$+"(cl%())"):cl%()=cl%()+nl%():nl%()=0:B%=x%:A%=addr%:addr%+=rowstep% 55070IFyr%AND1 THEN 55080CALLfs%,colstep%,cl%(1,0),nl%(1,0),A%,step%,B% 55090ELSE 55100A%+=dist%:CALLfs%,oddcolstep%,cl%(x%,0),nl%(x%,0),A%,oddstep%,B% 55110ENDIF 55120NEXT 55130ELSE 55140I%=step%:FORyr%=0TOy%-1:SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 55150W%=EVAL(r$+"(cl%())"):B%=x%:A%=addr%:addr%+=rowstep%:CALLfs%,colstep%,cl%(1,0),I%,A%,I%,B% 55160NEXT 55170ENDIF 55180ELSE 55190IFequal% THEN 55200PROCrewind:Havg%=SUM(vals%())/256/(col+1):DIM new%(256,col) 55210FORB%=0TOcol:R%=0:Hint%=0:FORZ%=0TO256:L%=R%:Hint%+=vals%(Z%,B%) 55220WHILEHint%>Havg%:Hint%-=Havg%:R%+=1:ENDWHILE 55230new%(Z%,B%)=(L%+R%)/2*F/256 55240NEXT:NEXT 55250ENDIF 55260IFsharpen% THEN 55270IForder% THEN 55280yread%=sy%-1:W%=EVAL(r$+"(rm1%())"):IFequal% PROCfit2(rm1%()) 55290FORB%=0TOcol:rm1%(0,B%)=rm1%(1,B%):rm1%(sx%+1,B%)=rm1%(sx%,B%):NEXT 55300ELSE 55310yread%=y%-1:PROCscaledpixelrow(rm1%()):IFequal% PROCfit(rm1%()) 55320FORB%=0TOcol:rm1%(0,B%)=rm1%(1,B%):rm1%(x%+1,B%)=rm1%(x%,B%):NEXT 55330ENDIF 55340rm2%()=rm1%() 55350ENDIF 55360IForder% THEN 55370FORyr%=0 TO y%-1 55380SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 55390IFsy%=y% THEN 55400PROCsharppixelrow(cl%()) 55410ELSE 55420ysamp%-=1:IFysamp%=0 PROCsharppixelrow(xl%()):ysamp%=ymul% 55430IFydiv%=1 THEN 55440cl%()=xl%() 55450ELSE 55460IFysamp%>=ydiv% THEN 55470ysamp%-=ydiv%:cl%()=xl%()*ydiv% 55480ELSE 55490cl%()=xl%()*ysamp%:Y%=ydiv%-ysamp%:ysamp%=0 55500REPEAT 55510IFysamp%=0 PROCsharppixelrow(xl%()):ysamp%=ymul% 55520IFysamp%>Y% THEN 55530ysamp%-=Y%:xl2%()=xl%()*Y%:cl%()=cl%()+xl2%():Y%=0 55540ELSE 55550Y%-=ysamp%:xl2%()=xl%()*ysamp%:cl%()=cl%()+xl2%():ysamp%=0 55560ENDIF 55570UNTIL Y%=0 55580ENDIF 55590ysamp%+=1 55600ENDIF 55610ENDIF 55620cl%()=cl%()+nl%():nl%()=0:B%=x%:A%=addr%:addr%+=rowstep% 55630IFyr%AND1 THEN 55640CALLfs%,colstep%,cl%(1,0),nl%(1,0),A%,step%,B% 55650ELSE 55660A%+=dist%:CALLfs%,oddcolstep%,cl%(x%,0),nl%(x%,0),A%,oddstep%,B% 55670ENDIF 55680NEXT 55690ELSE 55700FORyr%=0 TO y%-1 55710SYShour%,yr%*100DIVy%:IFaddr%>outlim% PROCflushoutput 55720IFsharpen% THEN 55730IFyread% yread%-=1:PROCscaledpixelrow(rm%()):IFequal% PROCfit(rm%()) 55740FORB%=0TOcol:rm%(0,B%)=rm%(1,B%):rm%(x%+1,B%)=rm%(x%,B%):NEXT 55750CALL sharp%,cl%(1,0),rm%(1,0),rm1%(1,0),rm2%(1,0),totvals% 55760SWAP rm2%(),rm1%():rm1%()=rm%() 55770ELSE 55780PROCscaledpixelrow(cl%()):IFequal% PROCfit(cl%()) 55790ENDIF 55800cl%()=cl%()+nl%():nl%()=0:B%=x%:A%=addr%:addr%+=rowstep% 55810IFyr%AND1 THEN 55820CALLfs%,colstep%,cl%(1,0),nl%(1,0),A%,step%,B% 55830ELSE 55840A%+=dist%:CALLfs%,oddcolstep%,cl%(x%,0),nl%(x%,0),A%,oddstep%,B% 55850ENDIF 55860NEXT 55870ENDIF 55880ENDIF 55890IFm=-11ORm=-12 THEN 55900SYS "OS_SWINumberFromString",,"CompressJPEG_WriteLine" TO wl% 55910IFm=-11 THEN 55920!ram%=xsp%:ram%!4=ysp%:ram%!8=jpegquality%:ram%!12=1:ram%!16=90:ram%!20=90 55930SYS"CompressJPEG_Start",ram%,sz%,ram%,jpegwrk%,(xsp%+7ANDNOT7)*9+20000 TO jpegtag% 55940ELSE 55950!ram%=xsp%:ram%!4=ysp%:ram%!8=jpegquality%:ram%!12=3:ram%!16=90:ram%!20=90 55960SYS"CompressJPEG_Start",ram%,sz%,ram%,jpegwrk%,(xsp%+15ANDNOT15)*30+20000 TO jpegtag% 55970ENDIF 55980addr%=ram%+20000 55990FORyr%=0TOysp%-1 56000SYShour%,yr%*100DIVysp%:SYSwl%,jpegtag%,addr%:addr%+=xwords% 56010NEXT 56020SYS"CompressJPEG_Finish",jpegtag% TO jpegsize% 56030ENDIF 56040ENDIF 56050cputime%=TIME-cputime% 56060PROCSave 56070=0 56080DEF PROCsrchdevlist 56090[OPT Z 56120CMP R4,#F:MOVCS R4,#0:MOVGE R4,#F 56130MOV R0,R4,LSR #(bits-k%):CMP R0,#1<<k%:MOVCS R0,#(1<<k%)-1 56140CMP R5,#F:MOVCS R5,#0:MOVGE R5,#F 56150MOV R3,R5,LSR #(bits-k%):CMP R3,#1<<k%:MOVCS R3,#(1<<k%)-1:ORR R0,R0,R3,LSL #k% 56160CMP R6,#F:MOVCS R6,#0:MOVGE R6,#F 56170MOV R3,R6,LSR #(bits-k%):CMP R3,#1<<k%:MOVCS R3,#(1<<k%)-1:ORR R0,R0,R3,LSL #k%*2 56200STMFD SP !,{R8,R9,R10,R11} 56210LDR r3,ictloc 56220LDR r2,[r3,r0,LSL #2] 56240MOV r14,r2,lsr #24 56250CMP r14,#4 56260ADDCC r2,r3,r0,lsl #2 56270BICCS r2,r2,#&ff000000 56280LDRB r0,[r2],#1 56290SUBS r14,r14,#1 56300BEQ gotit 56320ADD r3,r0,r0,lsl #1 56330ADD r3,r7,r3,lsl #2 56340LDMIA r3,{r8,r9,r10} 56350SUBS r8,r8,r4 56360RSBMI r8,r8,#0 56370MOV r8,r8,lsr #bits/2 56380SUBS r9,r9,r5 56390RSBMI r9,r9,#0 56400MOV r9,r9,lsr #bits/2 56410SUBS r10,r10,r6 56420RSBMI r10,r10,#0 56430MOV r10,r10,lsr #bits/2 56440MUL r3,r8,r8 56450MUL r11,r9,r9 56460ADD r11,r11,r11,LSL #2 56470ADD r3,r3,r3,LSL #1 56480ADD r3,r3,r11,LSL #1 56490MLA r11,r10,r10,r3 56510.srchlist 56520LDRB r3,[r2],#1 56530ADD R8,R3,R3,LSL #1 56540ADD R8,R7,R8,LSL #2 56550LDMIA R8,{R8,R9,R10} 56560SUBS R9,R5,R9 56570RSBMI R9,R9,#0 56580MOV R3,R9,LSR #bits/2 56590MUL R9,R3,R3 56600ADD r9,r9,r9,LSL #2 56610CMP R11,R9,LSL #1 56620BCC srchquick 56630SUBS R8,R4,R8 56640RSBMI R8,R8,#0 56650MOV R3,R8,LSR #bits/2 56660MUL R8,r3,r3 56670ADD r8,r8,r8,LSL #1 56680ADD r8,r8,r9,LSL #1 56690SUBS R10,R6,R10 56700RSBMI R10,R10,#0 56710MOV R3,R10,LSR #bits/2 56720MLA R10,R3,R3,R8 56730CMP R10,R11 56740MOVCC R11,R10 56750LDRCCB R0,[r2,#-1] 56760.srchquick 56770SUBS R14,R14,#1 56780BNE srchlist 56790.gotit 56800ADD R3,R0,R0,LSL #1:ADD R3,R7,R3,LSL #2 56810LDMIA R3,{R8,R9,R10} 56820SUB R4,R4,R8:SUB R5,R5,R9:SUB R6,R6,R10 56830LDMFD r13!,{R8,R9,R10,R11} 56840] 56850ENDPROC 56860DEF PROCgetoutput(A%,E%,B%,RETURN C%) 56870IFA%>max% AND rotate%=FALSE AND vflip%=FALSE THEN 56880C%=max%DIVB%+1:A%=xwords%*C%+E%:first%=TRUE:o%=OPENOUTf$ 56890ELSE 56900A%+=E% 56910ENDIF 56920IFspritearea%<0 THEN 56930ram%=FNcreatearea(A%):IFram%=-1 ram%=FNdim(A%) 56940ELSE 56950ram%=spritearea% 56960ENDIF 56970!ram%=A% 56980ENDPROC 57000DEF PROCgetoutputjp(RETURN A%) 57020IFspritearea%<0 THEN 57030ram%=FNcreateareajp(A%):IFram%=-1 ram%=FNdimjp(A%) 57040ELSE 57050ram%=spritearea% 57060ENDIF 57070!ram%=A% 57090ENDPROC 57110DEF FNcreatearea(size%) 57120LOCAL ERROR 57130areanumber%=0 57140ON ERROR LOCAL:=-1 57150SYS &20066,0,-1,size%,-1,%10000000,size%,0,0,"ChangeFSI sprite" TO ,areanumber%,,areabase%;V% 57160IFV%AND1 THENareanumber%=0:=-1 57220SYS "OS_ReadDynamicArea",areanumber% TO ,areasize% 57230IF areasize%<size% PROCremovearea:ERROR 42,"Couldn't create area" 57240=areabase% 57260DEF FNcreateareajp(RETURN size%) 57270LOCAL ERROR 57280areanumber%=0 57290ON ERROR LOCAL:=-1 57300SYS &20066,0,-1,size%,-1,%10000000,size%,0,0,"ChangeFSI JPEG" TO ,areanumber%,,areabase%;V% 57310IFV%AND1 THENareanumber%=0:=-1 57320SYS "OS_ReadDynamicArea",areanumber% TO ,areasize%:size%=areasize% 57330=areabase% 57350DEF PROCremovearea 57360IFareanumber% SYS "OS_DynamicArea",1,areanumber%:areanumber%=0 57370ENDPROC 57390DEF FNcachedim(size%) 57400LOCAL ERROR 57410cacheareanumber%=0 57420ON ERROR LOCAL:=-1 57430SYS &20066,0,-1,size%,-1,%10000000,size%,0,0,"ChangeFSI cache" TO ,cacheareanumber%,,cacheareabase%;V% 57440IFV%AND1 THENcacheareanumber%=0:=-1 57450SYS "OS_ReadDynamicArea",cacheareanumber% TO ,cacheareasize% 57460IF cacheareasize%<size% PROCremovecachearea:ERROR 42,"Couldn't create area" 57470=cacheareabase% 57490DEF PROCremovecachearea 57500IFcacheareanumber% SYS "OS_DynamicArea",1,cacheareanumber%:cacheareanumber%=0 57510ENDPROC 57530DEF PROCflushoutput 57540IFspritearea%<0 ANDoksave% THEN 57550A%=base%:IFfirst% A%=ram%+4:first%=FALSE 57560SYS12,2,o%,A%,addr%DIVsize%-A% 57570ENDIF 57580addr%=base%*size% 57590ENDPROC 57600DEF PROCclose 57610IFc% IFflag=3600 SYS"PhotoCD_Close",pcdh%,1 57620IFc% CLOSE#c%:c%=0:IFscrapf% scrapf%=FALSE:OSCLI"Remove <Wimp$Scrap>" 57630IFcc% CLOSE#cc%:cc%=0 57640IFccc% CLOSE#ccc%:ccc%=0 57650PROCremovecachearea 57660ENDPROC 57670DEF PROCSave 57680PROCclose 57690CASE m OF 57700WHEN -1:IFspritearea%<0 ANDoksave% THEN 57710IFo% PROCflushoutput ELSESYS"OS_File",10,f$,&004,,ram%,ram%+sz% 57720ENDIF 57730WHEN -2:o%=OPENOUTf$:BPUT#o%,pnm$ 57740CASE pnm$ OF 57750WHEN "P1" 57760BPUT#o%,"# "+f$+".pbm (options "+oname$+")" 57770BPUT#o%,STR$xsp%+" "+STR$ysp% 57780FORY%=0TOysp%-1:B%=base%+Y%*xwords% 57790FORX%=0TOxsp%-1:IFB%?(X%>>3)AND(1<<(X%AND7)) BPUT#o%,"1"; ELSEBPUT#o%,"0"; 57800NEXT 57810BPUT#o%,"" 57820NEXT 57830WHEN "P4" 57840BPUT#o%,"# "+f$+".pbm (options "+oname$+") binary encoded" 57850BPUT#o%,STR$xsp%+" "+STR$ysp% 57860FORX%=0TO255:code%?X%=X%<<7 OR X%<<5AND&40 OR X%<<3AND&20 OR X%<<1AND&10 OR X%>>1AND8 OR X%>>3AND4 ORX%>>5AND2 ORX%>>7:NEXT 57870FORY%=0TOysp%-1:B%=base%+Y%*xwords% 57880FORX%=0TOxsp%-1STEP8:BPUT#o%,code%?(B%?(X%>>3)):NEXT 57890NEXT 57900WHEN "P2" 57910BPUT#o%,"# "+f$+".pgm (options "+oname$+")" 57920BPUT#o%,STR$xsp%+" "+STR$ysp% 57930BPUT#o%,"15" 57940FORY%=0TOysp%-1:B%=base%+Y%*xwords% 57950FORX%=0TOxsp%-1:C%=B%?(X%>>1):IFX%AND1 C%=C%>>4 ELSEC%=C%AND15 57960BPUT#o%," "+STR$C%; 57970NEXT 57980BPUT#o%,"" 57990NEXT 58000WHEN "P5" 58010BPUT#o%,"# "+f$+".pgm (options "+oname$+") binary encoded" 58020BPUT#o%,STR$xsp%+" "+STR$ysp% 58030BPUT#o%,"15" 58040FORY%=0TOysp%-1:B%=base%+Y%*xwords% 58050FORX%=0TOxsp%-1:C%=B%?(X%>>1):IFX%AND1 C%=C%>>4 ELSEC%=C%AND15 58060BPUT#o%,C% 58070NEXT 58080NEXT 58090ENDCASE 58100CLOSE#o%:o%=0 58110IFpnm$="P2"ORpnm$="P1" OSCLI"Settype "+f$+" &FFF" 58120WHEN -3:o%=OPENOUTf$:BPUT#o%,pnm$ 58130BPUT#o%,"# "+f$+".pcm (options "+oname$+") binary encoded 15bpp (5bits r,g,b)" 58140BPUT#o%,STR$xsp%+" "+STR$ysp% 58150BPUT#o%,"31" 58160SYS12,2,o%,ram%,xsp%*ysp%*2 58170CLOSE#o%:o%=0 58180WHEN -4:o%=OPENOUTf$:IFpnm$="IRLAM"THEN 58190BPUT#o%,"Irlam 24: "+STR$xsp%+" "+STR$ysp% 58200FORY%=0TOysp%-1:B%=ram%+Y%*xwords% 58210FORX%=0TOxsp%*3-1STEP3:BPUT#o%,B%?X%:NEXT 58220B%+=1:FORX%=0TOxsp%*3-1STEP3:BPUT#o%,B%?X%:NEXT 58230B%+=1:FORX%=0TOxsp%*3-1STEP3:BPUT#o%,B%?X%:NEXT 58240NEXT 58250ELSE 58260BPUT#o%,pnm$ 58270IFpnm$="P6" THEN 58280BPUT#o%,"# "+f$+".ppm (options "+oname$+") binary encoded 24bpp r,g,b" 58290ELSE 58300BPUT#o%,"# "+f$+".ppm (options "+oname$+") "+STR$(p6bits*3)+"bpp r,g,b" 58310ENDIF 58320BPUT#o%,STR$xsp%+" "+STR$ysp% 58330BPUT#o%,STR$(2^p6bits-1) 58340IFpnm$="P6" THEN 58350SYS12,2,o%,ram%,xsp%*ysp%*3 58360ELSE 58370FORY%=0TOysp%-1:B%=ram%+Y%*xwords% 58380FORX%=0TOxsp%-1:C%=B%!(X%*3):BPUT#o%," "+STR$(C%AND255)+" "+STR$((C%>>8)AND&FF)+" "+STR$((C%>>16)AND255); 58390NEXT 58400BPUT#o%,"" 58410NEXT 58420ENDIF 58430ENDIF 58440CLOSE#o%:o%=0 58450IFpnm$="P3" OSCLI"Settype "+f$+" &FFF" 58460WHEN -5:o%=OPENOUTf$:BPUT#o%,pnm$ 58470BPUT#o%,"# "+f$+".pcm (options "+oname$+") binary encoded 15bpp (5bits y,u,v)" 58480BPUT#o%,STR$xsp%+" "+STR$ysp% 58490BPUT#o%,"31 27 21" 58500SYS12,2,o%,ram%,xsp%*ysp%*2 58510CLOSE#o%:o%=0 58520WHEN -9,-10,-11,-12 58530IFspritearea%<0 ANDoksave% SYS8,10,f$,&c85,,ram%,ram%+jpegsize% 58540OTHERWISE 58550IFncol=1ANDm$="T" THEN 58560FORX%=(xsp%*4-1)DIV8*8+6TO6STEP-8 58570SYS&2e,&12e,ram%,oname$,X% 58580SYS&2e,&12e,ram%,oname$,X% 58590NEXT 58600ENDIF 58610IFspritearea%<0 ANDoksave% THEN 58620IFo% PROCflushoutput ELSESYS&2e,&10c,ram%,f$ 58630ENDIF 58640ENDCASE 58650IFo% CLOSE#o%:o%=0:OSCLI"settype "+f$+" &ff9":PROCremovearea 58660SYS"Hourglass_Off" 58670ENDPROC 58680DEFPROCdefpal 58690FORC%=0TO255 58700r%(C%)=(C%AND7 OR (C%AND16)>>1)/15*F 58710g%(C%)=(C%AND3 OR (C%AND&60)>>3)/15*F 58720b%(C%)=(C%AND3 OR (C%AND8)>>1 OR (C%AND128)>>4)/15*F 58730NEXT 58740ENDPROC 58750DEFPROCdefpal2 58760r%(0)=F:g%(0)=F:b%(0)=F 58770ENDPROC 58780DEFPROCdefpal4 58790r%()=15,10,5,0:FORC%=0TO3:r%(C%)=r%(C%)/15*F:NEXT 58800g%()=r%():b%()=r%() 58810ENDPROC 58820DEFPROCdefpal16 58830r%()=15,13,11,9,7,5,3,0,0,14, 0,13,14,5,15, 0 58840g%()=15,13,11,9,7,5,3,0,4,14,12, 0,14,8,11,10 58850b%()=15,13,11,9,7,5,3,0,9, 0, 0, 0,11,0, 0,15 58860FORC%=0TO15:r%(C%)=r%(C%)/15*F:g%(C%)=g%(C%)/15*F:b%(C%)=b%(C%)/15*F:NEXT 58870ENDPROC 58880DEFPROCipal63 58890PTR#c%=&38:DIM rpal%(15),gpal%(15),bpal%(15) 58900FORC%=0TO15:D%=BGET#c% 58910rpal%(C%)=BGET#c%>>4 AND 7 58920gpal%(C%)=BGET#c%>>4 AND 3 58930bpal%(C%)=BGET#c%>>4 AND 7 58940D%=FNW:NEXT 58950FORC%=0TO255 58960r%(C%)=(rpal%(C%AND15)OR(C%AND16)>>1)/15*F 58970g%(C%)=(gpal%(C%AND15)OR(C%AND&60)>>3)/15*F 58980b%(C%)=(bpal%(C%AND15)OR(C%AND128)>>4)/15*F 58990NEXT 59000ENDPROC 59010DEFPROCipal(D%) 59020PTR#c%=&38 59030FORC%=0TOD%-1:D%=BGET#c% 59040r%(C%)=(BGET#c%>>4)/15*F 59050g%(C%)=(BGET#c%>>4)/15*F 59060b%(C%)=(BGET#c%>>4)/15*F 59070D%=FNW:NEXT 59080ENDPROC 59090DEF PROCnewropal(D%) 59100PTR#c%=&38 59110FORC%=0TOD%-1:D%=FNW 59120r%(C%)=(D%AND255)/255*F 59130g%(C%)=(D%>>8AND255)/255*F 59140b%(C%)=(D%>>16AND255)/255*F 59150D%=FNW:NEXT 59160ENDPROC 59170DEF PROCnopal 59180FORC%=0TO255:r%(C%)=C%/255*F:NEXT:g%()=r%():b%()=r%() 59190ENDPROC 59200DEF PROCcol(A%,B%) 59210B%=B%<<8ORB%<<4OR&10:pal%!(A%*8)=B%:pal%!(A%*8+4)=B% 59220ENDPROC 59230DEF FNbits(A%) 59240IFA%=1 THEN="1 bit per pixel" ELSE=STR$A%+" bits per pixel" 59250DEF FNfits 59260LOCALZ%,s$ 59270FORZ%=1TO80:s$+=CHR$BGET#c%:NEXT 59280=s$ 59290DEF FNuc(a$) 59300LOCALZ%,z$,b$ 59310FORZ%=1TOLENa$ 59320z$=MID$(a$,Z%,1) 59330IFz$>="a"IFz$<="z" z$=CHR$(ASCz$-32) 59340b$+=z$:NEXT 59350=b$ 59360DEF FNdim(A%) 59370LOCAL B% 59380IFflex% THEN 59390B%=nextlocation%:A%=A%+3ANDNOT3:nextlocation%+=A% 59400SYS"Wimp_SlotSize",-1,-1 TO currentslot% 59410IFcurrentslot%+&8000<nextlocation% THEN 59420SYS "Wimp_SlotSize",nextlocation%-&8000,-1 TO currentslot% 59430IFcurrentslot%+&8000<nextlocation% ERROR 42,"Can't get enough memory to process image" 59440ENDIF 59450ELSE 59460IFworkspace%<0 THEN 59470DIM B% A% 59480ELSE 59490B%=workspace%:workspace%+=A%+3ANDNOT3:IFworkspace%>worklimit% ERROR42,"Not enough workspace" 59500ENDIF 59510ENDIF 59520=B% 59530DEF FNdimjp(RETURN A%) 59540LOCAL B% 59550IFflex% THEN 59560B%=nextlocation%:A%=A%+3ANDNOT3:nextlocation%+=A% 59570SYS"Wimp_SlotSize",-1,-1 TO currentslot% 59580IFcurrentslot%+&8000<nextlocation% THEN 59590SYS "Wimp_SlotSize",nextlocation%-&8000,-1 TO currentslot% 59600IFcurrentslot%+&8000<nextlocation% A%=currentslot%+&8000-B% 59610ENDIF 59620ELSE 59630IFworkspace%<0 THEN 59640DIM B% A% 59650ELSE 59660B%=workspace%:workspace%+=A%+3ANDNOT3:IFworkspace%>worklimit% ERROR42,"Not enough workspace" 59670ENDIF 59680ENDIF 59690=B% 59710DEF FNW=FNW1(c%) 59720DEF FNW1(c%)=BGET#c% OR BGET#c%<<8 OR BGET#c%<<16 OR BGET#c%<<24 59740DEF FNHW=BGET#c% OR BGET#c%<<8 59760DEF FNbeHW=BGET#c%<<8 OR BGET#c% 59780DEF FNbeW=BGET#c%<<24 OR BGET#c%<<16 OR BGET#c%<<8 OR BGET#c% 59800DEF FNtiff(T%) 59810CASE T% OF 59820WHEN 1,7:=BGET#c% 59830WHEN 2:LOCALs$,t$:REPEATs$+=t$:t$=CHR$BGET#c%:UNTILt$=CHR$0:=s$ 59840WHEN 3:IFbigendian THEN=BGET#c%<<8 OR BGET#c% ELSE=BGET#c% OR BGET#c%<<8 59850WHEN 4,9:IFbigendian THEN=FNbeW ELSE=FNW1(c%) 59860WHEN 6:=(BGET#c%<<24)>>24 59870WHEN 8:=(FNtiff(3)<<16)>>16 59880ENDCASE 59890ERROR 42,"Silly TIFF tag:"+STR$T% 59900DEF PROCnextstrip 59910rowstogo%=striprows% 59920stripptr+=1:PTR#c%=st%(stripptr) 59930IFcompression=5 THEN 59940!firstcode=0:!oldcode=0:!codesize=setcodes%+1:!stack=stk%:!sp=stk% 59950!maxcode=clearcode%+2:!maxcodesize=2*clearcode%:!curbit=0:!lastbit=0 59960ENDIF 59970IFcompression=5 OR compression=32773 THEN 59980!incacheptr=datacache%:!numlefttogo=cache% 59990SYS12,4,c%,datacache%,cache% 60000ENDIF 60010ENDPROC 60020DEF PROCwatford(wtsx%,RETURN rep%,RETURN wt%,X%,c%) 60030CALLrlexpand%,wtsx%,rep%,wt%,X% 60040REPEAT C%=BGET#c%:CASE C%>>6 OF 60050WHEN 0:?X%=C%:X%+=1:wt%=C% 60060WHEN 1:wt%-=1:rep%=C%AND63:CALLrlexpand%,wtsx%,rep%,wt%,X% 60070WHEN 2:rep%=C%AND63:CALLrlexpand%,wtsx%,rep%,wt%,X% 60080WHEN 3:wt%+=1:rep%=C%AND63:CALLrlexpand%,wtsx%,rep%,wt%,X% 60090ENDCASE 60100UNTILX%=wtsx% 60110ENDPROC 60120DEF PROCwatfordcache(wtsx%,RETURN rep%,RETURN wt%,X%) 60130CALLrlexpand%,wtsx%,rep%,wt%,X% 60140REPEAT C%=USRbytefromcache%:CASE C%>>6 OF 60150WHEN 0:?X%=C%:X%+=1:wt%=C% 60160WHEN 1:wt%-=1:rep%=C%AND63:CALLrlexpand%,wtsx%,rep%,wt%,X% 60170WHEN 2:rep%=C%AND63:CALLrlexpand%,wtsx%,rep%,wt%,X% 60180WHEN 3:wt%+=1:rep%=C%AND63:CALLrlexpand%,wtsx%,rep%,wt%,X% 60190ENDCASE 60200UNTILX%=wtsx% 60210ENDPROC 60220DEF PROCreduce(RETURN A%,RETURN B%) 60230LOCAL C%,D%:C%=A%:D%=B% 60240REPEAT IFC%<D% SWAP C%,D% 60250C%=C%MODD% 60260UNTILC%=0 60270A%=A%DIVD%:B%=B%DIVD% 60280ENDPROC 60290DEF PROCreadpixelrow(z%()) 60300IFrows% THEN 60310rows%-=1:IFsx%=x% THEN 60320W%=EVAL(r$+"(z%())") 60330ELSE 60340W%=EVAL(r$+"(xp%())"):CALLxsample%,xmul%,xdiv%,z%(1,0),xp%(1,0),x% 60350ENDIF 60360ELSE 60370z%()=0 60380ENDIF 60390ENDPROC 60400DEF PROCsharppixelrow(z%()) 60410IFrows% THEN 60420rows%-=1:IFsx%=x% THEN 60430IFsharpen% PROCsharp(z%()) ELSEW%=EVAL(r$+"(z%())"):IFequal% PROCfit2(z%()) 60440ELSE 60450IFsharpen% PROCsharp(xp%()) ELSEW%=EVAL(r$+"(xp%())"):IFequal% PROCfit2(xp%()) 60460CALLxsample%,xmul%,xdiv%,z%(1,0),xp%(1,0),x% 60470ENDIF 60480ELSE 60490z%()=0 60500ENDIF 60510ENDPROC 60520DEF PROCsharp(z%()) 60530yread%-=1:IFyread% W%=EVAL(r$+"(rm%())"):IFequal% PROCfit2(rm%()) 60540FORB%=0TOcol:rm%(0,B%)=rm%(1,B%):rm%(sx%+1,B%)=rm%(sx%,B%):NEXT 60550CALL sharp%,z%(1,0),rm%(1,0),rm1%(1,0),rm2%(1,0),totvals2% 60560SWAP rm2%(),rm1%():rm1%()=rm%() 60570ENDPROC 60580DEF PROCscaledpixelrow(z%()) 60590IFsy%=y% THEN 60600PROCreadpixelrow(z%()) 60610ELSE 60620ysamp%-=1:IFysamp%=0 PROCreadpixelrow(xl%()):ysamp%=ymul% 60630IFydiv%=1 THEN 60640z%()=xl%() 60650ELSE 60660IFysamp%>=ydiv% THEN 60670ysamp%-=ydiv%:z%()=xl%()*ydiv% 60680ELSE 60690LOCALY%:z%()=xl%()*ysamp%:Y%=ydiv%-ysamp%:ysamp%=0 60700REPEAT 60710IFysamp%=0 PROCreadpixelrow(xl%()):ysamp%=ymul% 60720IFysamp%>Y% THEN 60730ysamp%-=Y%:xl2%()=xl%()*Y%:z%()=z%()+xl2%():Y%=0 60740ELSE 60750Y%-=ysamp%:xl2%()=xl%()*ysamp%:z%()=z%()+xl2%():ysamp%=0 60760ENDIF 60770UNTIL Y%=0 60780ENDIF 60790ysamp%+=1 60800ENDIF 60810ENDIF 60820ENDPROC 60830DEF PROCfit(z%()) 60840CALLhistequal%,z%(1,0),new%(0,0),x% 60850ENDPROC 60860DEF PROCfit2(z%()) 60870CALLhistequal%,z%(1,0),new%(0,0),sx% 60880ENDPROC 60890DEF PROCadjustpalette(mul,sub) 60900IFmul=1 AND sub=0 ENDPROC 60910FORC%=0TOcolourindex 60920r%(C%)=(r%(C%)-sub)*mul+1:g%(C%)=(g%(C%)-sub)*mul+1:b%(C%)=(b%(C%)-sub)*mul+1 60930NEXT 60940IFham THEN 60950FORC%=0TO15*4STEP4:ltable!C%=(ltable!C%-sub)*mul+1:NEXT 60960ENDIF 60970IFinput>400 THEN 60980FORC%=0TOcolourindex 60990rpal%(C%)=(rpal%(C%)-sub)*mul+1:gpal%(C%)=(gpal%(C%)-sub)*mul+1 61000bpal%(C%)=(bpal%(C%)-sub)*mul+1:table%(C%)=(table%(C%)-sub)*mul+1 61010NEXT 61020ENDIF 61030ENDPROC 61040DEF PROCcachesize(A%) 61050SYS&20023,"ChangeFSI$Cache",A%,-1 TO,,Z 61060IFZ<>0 THEN 61070SYS35,"ChangeFSI$Cache",A%,20 TO,,Z:A%?Z=13:cache%=VAL$A% 61080IFINSTR($A%,"K")ORINSTR($A%,"k") cache%=cache%*1024 61090ELSE 61100cache%=128*1024 61110ENDIF 61120ENDPROC 61130DEF PROCrefill 61140IFstriprows%>0 PROCnextstrip 61150SYS12,4,c%,datacache%,cache%:rowstogo%=cacherows%:buff%=datacache% 61160IFinput=24ORinput=48 IFrbo%>=0 rb%=buff%+rbo%:gb%=buff%+gbo%:bb%=buff%+bbo% 61170ENDPROC 61180DEF PROCrefillpcd 61190IFpcdblk%!4>=sy% ENDPROC 61200IFpcdblk%!12>=sy% pcdblk%!12=sy% 61220SYS"PhotoCD_GetBlock",pcdh%,,pcdblk%,datacache%,pcdindex%,,,pcdcache%,pcdcachesize% 61230rowstogo%=cacherows%:buff%=datacache%:pcdblk%!4+=cacherows%:pcdblk%!12+=cacherows% 61240rb%=buff%+rbo%:gb%=buff%+gbo%:bb%=buff%+bbo% 61250ENDPROC 61270DEF FN8(z%()) 61280CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),buff%:buff%+=rowbytes% 61290rowstogo%-=1:IFrowstogo%=0 PROCrefill 61300=TRUE 61320DEF FN16(z%()) 61330CALLmappix%,z%(1,0),rpal%(0),gpal%(0),r%(0),g%(0),b%(0),buff%,buff% 61340buff%+=rowbytes%:rowstogo%-=1:IFrowstogo%=0 PROCrefill 61350=TRUE 61370DEF FN24(z%()) 61380CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 61390rb%+=rowbytes%:gb%+=rowbytes%:bb%+=rowbytes% 61400rowstogo%-=1:IFrowstogo%=0 PROCrefill 61410=TRUE 61430DEF FN300(z%()) 61440SYS12,4,cc%,pbuff%,sx%:CALLmappix%,z%(1,0),rpal%(0),gpal%(0),r%(0),g%(0),b%(0),pbuff%,buff% 61450buff%+=rowbytes%:rowstogo%-=1:IFrowstogo%=0 PROCrefill 61460=TRUE 61480DEF FN400(z%()) 61490CALLreadline%,plbytes%,rep%,pix%,plbuff% 61500CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 61510=TRUE 61530DEF FN500(z%()) 61540CALL LZWdecode%,table%(0),c%,plbuff%,sx% 61550CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),plbuff% 61560=TRUE 61580DEF FN800(z%()) 61590PROCwatfordcache(wtsx%,rep%,wt%,plbuff%) 61600CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),plbuff% 61610=TRUE 61630DEF FN801(z%()) 61640PROCwatford(wtsx1%,rep1%,wt1%,buff%,c%) 61650PROCwatford(wtsx2%,rep2%,wt2%,wtsx1%,cc%) 61660PROCwatford(wtsx3%,rep3%,wt3%,wtsx2%,ccc%) 61670CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 61680=TRUE 61700DEF FN901(z%()) 61710SYS12,4,c%,rb%,sx%:SYS12,4,cc%,gb%,sx%:SYS12,4,ccc%,bb%,sx% 61720CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 61730=TRUE 61750DEF FN902(z%()) 61760CALLunpack%,buff%:CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 61770buff%+=rowbytes%:rowstogo%-=1:IFrowstogo%=0 PROCrefill 61780=TRUE 61800DEF FN1000(z%()) 61810X%=buff%:IFrep%>0 C%=?pa%:CALLrlexpand%,pasx%,rep%,C%,X%:pa%+=1 61820IFrep2%>0 C%=?pa%:CALLrlexpand%,pasx%,rep2%,C%,X%:pa%+=1 61830REPEAT C%=BGET#c%:IFC%=0 THEN 61840rep%=BGET#c%:C%=?pa%:CALLrlexpand%,pasx%,rep%,C%,X%:IFrep%=0 pa%+=1 61850ELSE 61860rep2%=C%AND15:rep%=C%>>4:IFrep% C%=?pa%:CALLrlexpand%,pasx%,rep%,C%,X%:IFrep%=0 pa%+=1 61870IFX%<pasx% IFrep2% C%=?pa%:CALLrlexpand%,pasx%,rep2%,C%,X%:IFrep2%=0 pa%+=1 61880ENDIF 61890UNTILX%=pasx% 61900CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),buff% 61910=TRUE 61930DEF FN1001(z%()) 61940X%=buff%:IFrep%>0 C%=?pa%:CALLrlexpand%,pasx%,rep%,C%,X%:pa%+=1 61950REPEAT rep%=BGET#c%:C%=?pa%:CALLrlexpand%,pasx%,rep%,C%,X%:IFrep%=0 pa%+=1 61960UNTILX%=pasx%:CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),buff% 61970=TRUE 61990DEF FN1100(z%()) 62000CALLreadline%,plbytes%,rep%,pix%,plbuff% 62010CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),plbuff% 62020=TRUE 62040DEF FN1400(z%()) 62050IFvrep% THEN 62060vrep%-=1 62070ELSE 62080G%=buff%:FORX%=1TOplanes%:G%+=rowbytes%:F%=G%-rowbytes% 62090REPEAT C%=BGET#c%:IFC%=0 THEN 62100C%=BGET#c%:IFC%=0 THEN 62110C%=BGET#c%:vrep%=BGET#c%-1 62120ELSE 62130D%=F%:SYS12,4,c%,F%,patlen%:F%+=patlen% 62140IFC%>1 FORN%=2TOC%:FORE%=0TOpatlen%-1:F%?E%=D%?E%:NEXT:F%+=patlen%:NEXT 62150ENDIF 62160ELSE 62170IFC%=128 THEN 62180C%=BGET#c%:SYS12,4,c%,F%,C%:F%+=C% 62190ELSE 62200?F%=(C%AND&80)<>0:FORE%=F%+1TOF%+(C%AND&7F):?E%=?F%:NEXT:F%+=C%AND&7F 62210ENDIF 62220ENDIF:UNTILF%>=G%:NEXT 62230CALLplancnv%,rowbytes%,buff%,pbuff% 62240ENDIF 62250CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),pbuff% 62260=TRUE 62280DEF FN1501(z%()) 62290CALLreadiff%,rowbytes%,plbuff%:rowstogo%-=1:IFrowstogo%=0 PROCnextstrip 62300CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),plbuff% 62310=TRUE 62330DEF FN1505(z%()) 62340CALL LZWdecode%,table%(0),c%,plbuff%,rowbytes% 62350rowstogo%-=1:IFrowstogo%=0 PROCnextstrip 62360CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),plbuff% 62370=TRUE 62390DEF FN1515(z%()) 62400CALL LZWdecode%,table%(0),c%,plbuff%,rowbytes% 62410rowstogo%-=1:IFrowstogo%=0 PROCnextstrip 62420CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 62430=TRUE 62450DEF FN1600(z%()) 62460CALLplancnv%,realrowbytes%,buff%,pbuff%:buff%+=rowbytes% 62470CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),pbuff% 62480rowstogo%-=1:IFrowstogo%=0 PROCrefill 62490=TRUE 62510DEF FN1601(z%()) 62520FORX%=0TOplanes%-1:F%=plbuff%+X%*rowbytes%:CALLreadiff%,rowbytes%,F%:NEXT 62530IFmasking% CALLreadiff%,rowbytes%,pbuff% 62540CALLplancnv%,rowbytes%,plbuff%,pbuff% 62550CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),pbuff% 62560=TRUE 62580DEF FN1850(z%()) 62590CALLreadiff%,rowbytes%,plbuff% 62600CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),plbuff% 62610=TRUE 62630DEF FN1851(z%()) 62640CALLreadiff%,rowbytes%,plbuff% 62650CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 62660=TRUE 62680DEF FN1900(z%()) 62690CALLreadline%,plbytes%,rep%,pix%,plbuff% 62700CALLplancnv%,rowbytes%,plbuff%,pbuff% 62710CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),pbuff% 62720=TRUE 62740DEF FN2000(z%()) 62750X%=buff%:REPEAT 62760C%=BGET#c%:IFC%<128 THEN 62770C%+=1:SYS12,4,c%,X%,C%:X%+=C% 62780ELSE 62790F%=X%:?F%=BGET#c%:FORC%=C%TO128STEP-1:?X%=?F%:X%+=1:NEXT 62800ENDIF 62810UNTILX%=buff%+rowbytes% 62820CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),buff% 62830=TRUE 62850DEF FN2001(z%()) 62860X%=buff%:REPEAT 62870C%=BGET#c%:IFC%<128 THEN 62880C%=(C%+1)*2:SYS12,4,c%,X%,C%:X%+=C% 62890ELSE 62900F%=X%:SYS12,4,c%,X%,2:FORC%=C%TO128STEP-1:!X%=!F%:X%+=2:NEXT 62910ENDIF 62920UNTILX%=buff%+rowbytes% 62930CALLmappix%,z%(1,0),rpal%(0),gpal%(0),r%(0),g%(0),b%(0),buff%,buff% 62940=TRUE 62960DEF FN2002(z%()) 62970X%=buff%:REPEAT 62980C%=BGET#c%:IFC%<128 THEN 62990C%=(C%+1)*step24:SYS12,4,c%,X%,C%:X%+=C% 63000ELSE 63010F%=X%:SYS12,4,c%,X%,step24:FORC%=C%TO128STEP-1:!X%=!F%:X%+=step24:NEXT 63020ENDIF 63030UNTILX%=buff%+rowbytes% 63040CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 63050=TRUE 63070DEF FN2250(z%()) 63080CALLmappix%,z%(1,0),rpal%(0),r%(0),gpal%(0),g%(0),bpal%(0),b%(0),table%(0),buff% 63090buff%+=rowbytes%:rowstogo%-=1:IFrowstogo%=0 PROCrefill 63100=TRUE 63120DEF FN2300(z%()) 63130IFclrfirst% FORX%=0TOsx%-1:rb%?X%=?back%:gb%?X%=back%?1:bb%?X%=back%?2:NEXT 63140IFvrep% THEN 63150vrep%-=1 63160ELSE 63170LOCAL ERROR 63180ON ERROR LOCAL vrep%=-1:CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb%:=TRUE 63190E%=FALSE:REPEAT C%=BGET#c%:D%=BGET#c%:IFC%AND&40 D%=FNHW 63200CASE C%AND&3f OF 63210WHEN 1:E%=TRUE:vrep%=D%-1:IFvrep%<0 vrep%=FALSE 63220WHEN 2:ccol%=back%?D%:cbuf%=rb%+sx%*D%:IFD%=255 cbuf%=alpha% 63230WHEN 3:FORX%=0TOD%-1:cbuf%?X%=ccol%:NEXT:cbuf%+=D% 63240WHEN 5:SYS12,4,c%,cbuf%,D%+1:cbuf%+=D%+1:IFD%+1AND1 IFBGET#c% 63250WHEN 6:C%=FNHW:FORX%=0TOD%:cbuf%?X%=C%:NEXT:cbuf%+=D%+1 63260ENDCASE 63270UNTILE% 63280ENDIF 63290CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 63300=TRUE 63320DEF FN2401(z%()) 63330CALLbm_rle8,rowbytes%,plbuff% 63340CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),plbuff% 63350=TRUE 63370DEF FN2402(z%()) 63380CALLbm_rle4,rowbytes%,plbuff% 63390CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),plbuff% 63400=TRUE 63420DEF FN3000(z%()) 63430CALLmappix%,z%(1,0),rpal%(0),r%(0),gpal%(0),g%(0),bpal%(0),b%(0),table%(0),buff% 63440buff%+=rowbytes%:rowstogo%-=1:IFrowstogo%=0 PROCrefill 63450=TRUE 63460DEF FN3500(z%()) 63470=TRUE 63480DEF FN3600(z%()) 63490CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 63500rb%+=rowbytes%:gb%+=rowbytes%:bb%+=rowbytes% 63510rowstogo%-=1:IFrowstogo%=0 PROCrefillpcd 63520=TRUE 63530DEF FN3708(z%()) 63540A%=jpegspace%:jpegy%-=1:B%=jpegy%:rb%=USR(jpeg%+4) 63550CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb% 63560=TRUE 63570DEF FN3724(z%()) 63580A%=jpegspace%:jpegy%-=1:B%=jpegy%:rb%=USR(jpeg%+4):gb%=rb%+1:bb%=rb%+2 63590CALLmappix%,z%(1,0),r%(0),g%(0),b%(0),rb%,gb%,bb% 63600=TRUE 63610DEF PROCrewind 63620rows%=sy%:CASE flag OF 63630WHEN 0:PTR#c%=st% 63640WHEN 100:PTR#c%=4 63650WHEN 200:PTR#c%=st%:rep%=0 63660WHEN 300:PTR#c%=st%:PTR#cc%=stcc% 63670WHEN 400:PTR#c%=st%:rep%=0 63680WHEN 500:FORI%=0TOclearcode%-1:table%(I%)=I%:NEXT:PTR#c%=st% 63690!firstcode=0:!oldcode=0:!codesize=setcodes%+1:!stack=stk%:!sp=stk% 63700!maxcode=clearcode%+2:!maxcodesize=2*clearcode%:!curbit=0:!lastbit=0 63710WHEN 501:buff%=datacache% 63720WHEN 600:PTR#c%=&380 63730WHEN 700:PTR#c%=st% 63740WHEN 800:PTR#c%=0:rep%=0:wt%=0 63750WHEN 801:PTR#c%=0:PTR#cc%=0:PTR#ccc%=0:rep1%=0:wt1%=0:rep2%=0:wt2%=0:rep3%=0:wt3%=0 63760WHEN 900:PTR#c%=0 63770WHEN 901:PTR#c%=0:PTR#cc%=0:PTR#ccc%=0 63780WHEN 902:PTR#c%=st% 63790WHEN 1000:PTR#c%=st%:pa%=ctable%:rep%=0:rep2%=0 63800WHEN 1100:PTR#c%=st%:rep%=0 63810WHEN 1200:PTR#c%=1600 63820WHEN 1300:PTR#c%=0 63830WHEN 1301:PTR#c%=0:PTR#cc%=0:PTR#ccc%=0 63840WHEN 1400:PTR#c%=st%:vrep%=0 63850WHEN 1500:PTR#c%=st%(0):rowstogo%=striprows%:stripptr=0 63860IFcompression=5 THEN 63870!firstcode=0:!oldcode=0:!codesize=setcodes%+1:!stack=stk%:!sp=stk% 63880!maxcode=clearcode%+2:!maxcodesize=2*clearcode%:!curbit=0:!lastbit=0 63890ENDIF 63900WHEN 1600:PTR#c%=st% 63910WHEN 1700:PTR#c%=16 63920WHEN 1800,1850:PTR#c%=st% 63930WHEN 1900:PTR#c%=128:rep%=-1 63940WHEN 2000:PTR#c%=st% 63950WHEN 2100:PTR#c%=7 63960WHEN 2200:PTR#c%=st% 63970WHEN 2250:PTR#c%=st% 63980WHEN 2300:PTR#c%=st%:vrep%=0 63990WHEN 2400:PTR#c%=st% 64000WHEN 2500:PTR#c%=st% 64010WHEN 2600:PTR#c%=st% 64020WHEN 2700:PTR#c%=st% 64030WHEN 2800:PTR#c%=st% 64040WHEN 2900:PTR#c%=st% 64050WHEN 3000:PTR#c%=0 64060WHEN 3600:pcdblk%!4=0 64070WHEN 3700:jpegy%=sy% 64080WHEN 3900,3905:PTR#c%=st% 64090ENDCASE 64100IFcache% THEN 64110IFflag=3600 THEN 64120pcdblk%!12=cacherows%:PROCrefillpcd:IFcache%>=filesize% rowstogo%=-1 64130ELSE 64140IFcache%<filesize% SYS12,4,c%,datacache%,cache%:rowstogo%=cacherows% 64150ENDIF 64160buff%=datacache% 64170IFcachebytes% !incacheptr=datacache%:!numlefttogo=cache% 64180IFinput=24ORinput=48 IFrbo%>=0 rb%=buff%+rbo%:gb%=buff%+gbo%:bb%=buff%+bbo% 64190ENDIF 64200IFflag=1500 IFcompression=5 rowstogo%=striprows% 64210ENDPROC 64230DEF PROCAssemble_Shell 64240FORI%=0TO2STEP2 64250P%=code% 64260[ OPT I% 64270.Shell_Call 64280MOV R9,R0 64290MOV R0,#0:MOV R1,#0:MOV R2,#0:MOV R3,#2:MOV R4,#0:MOV R5,#0:MOV R6,#0:MOV R7,#0 64300SWI "OS_SetEnv" 64310STMFD R13!,{R0-R7, R12} 64320MOV R0,#0:MOV R1,#0:MOV R2,#0:MOV R3,#0 64330SWI "OS_Control" 64340STMFD R13!,{R0-R3} 64350MOV R0,#&10:MOV R1,#0:MOV R2,#0 64360SWI "XOS_ChangeEnvironment" 64370STMFD R13!,{R1,R2} 64380LDR R3,[R14,#28] 64390LDR R3,[R8,R3] 64400STMFD R13!,{R3,R9,R14} 64410SUB R9,R13,#1024 64420MOV R5,R9 64430ADR R6,Shell_Job:ADR R4,Shell_Job_End 64440.Shell_Copy 64450LDR R2,[R6],#4 64460STR R2,[R5],#4 64470CMP R6,R4 64480BCC Shell_Copy 64490MOV PC,R9 64500.Shell_Job 64510LDR R2,[R3,#-4]! 64520STR R2,[R9,#-4]! 64530CMP R3,#&8000 64540BHI Shell_Job 64550STMFD R13!,{R9} 64560ADR R0,Shell_Exit 64570MOV R1,R9:MOV R2,#0:MOV R3,#2:MOV R4,#0:MOV R5,#0:MOV R6,#0:MOV R7,#0 64580SWI "OS_SetEnv" 64590ADR R0,Shell_Error 64600ADR R1,Shell_Buffer 64610MOV R2,#0:MOV R3,#0 64620SWI "OS_Control" 64630MOV R0,#&10 64640ADR R1,Shell_UpCall 64650MVN R2,#0 64660SWI "XOS_ChangeEnvironment" 64670STR R13,Shell_Job_End 64680LDR R0,[R13,#4*2] 64690ADD R0,R0,R9 64700SUB R0,R0,#&8000 64710SWI "OS_CLI" 64720.Shell_Exit 64730MOV r0, #0 64740.Shell_Common 64750STR r0, Shell_ErrorWord 64760LDR R13,Shell_Job_End 64770LDMFD R13!,{R8,R9,R10,R14} 64780LDMFD R13!,{R1-R2} 64790MOV R0,#&10 64800SWI "OS_ChangeEnvironment" 64810LDMFD R13!,{R0-R3} 64820SWI "OS_Control" 64830LDMFD R13!,{R0-R7, R12} 64840SWI "OS_SetEnv" 64850MOV R1,#&8000 64860.Shell_Restore 64870LDR R2,[R8],#4 64880STR R2,[R1],#4 64890CMP R1,R9 64900BCC Shell_Restore 64910LDR R0,Shell_ErrorWord 64920TEQ R0,#0 64930BICEQS PC,R14,#&10000000 64940ORRNES PC,R14,#&10000000 64950.Shell_UpCall 64960MOV PC,R14 64970.Shell_Error 64980ADR r0, Shell_Buffer + 4 64990B Shell_Common 65000.Shell_Buffer 65010EQUD 0 65020EQUD &12345678 65030EQUS STRING$(128,CHR$13) 65040EQUS STRING$(128,CHR$13) 65050.Shell_ErrorWord 65060EQUD 0 65070.Shell_Job_End 65080EQUD 0 65090] 65100NEXT 65110A%=Shell_Job_End+4 65120ENDPROC 65140DEF PROCsubtask(a$) 65150IF task% THEN 65160SYS"Wimp_StartTask",a$ 65170ELSE 65190DIM code% 1024 65200PROCAssemble_Shell 65210$A%=a$:CALLShell_Call 65220ENDIF 65230ENDPROC
� > ChangeFSI �areanumber%=0 �ș"OS_GetEnv" � A$ � task%=�A$," -wimp"):�task% � �� z%(1),p%(3),s%(3),m$(30) �"A%=�"<ChangeFSI$Dir>.Messages" �(B%=-1:� B%+=1:m$(B%)=�#A%:��#A%:�#A% �startfile%=�A$,6)<>"-wimp " �� taskid%4:$taskid%="TASK" �7ș "Wimp_Initialise",200,!taskid%,m$(20) � version% �� version%>=350 � �3ș"OS_Memory",8+(2<<8) � ,r1,r2:vramsize%=r1*r2 �"� vramsize%>0 vram%=� �vram%=� � vram%=� � "Wimp = (1<<18) + (3<<6) ,HCreateW = Wimp+1:OpenW = Wimp+5 :CloseW = Wimp+6:RedrawW = Wimp+8 6IUpdateW = Wimp+9:GetR% = Wimp+10:GetW = Wimp+11:SetI = Wimp+13 @IGetI = Wimp+14:GetP = Wimp+15:Drag = Wimp+16:CrMenu = Wimp+20 JDcMenu = Wimp+21 T8ș "OS_SWINumberFromString",,"Wimp_PollIdle" � Poll% ^8ș "OS_SWINumberFromString",,"XOS_SpriteOp" � spopx% h6ș "OS_SWINumberFromString",,"OS_SpriteOp" � spop% r?ș "OS_SWINumberFromString",,"OS_ReadMonotonicTime" � Time% |Jș "OS_SWINumberFromString",,"ColourTrans_ReturnColourNumber" � ctran% �Dș "OS_SWINumberFromString",,"Wimp_SetCaretPosition" � Caretpos% �Dș "OS_SWINumberFromString",,"Wimp_GetCaretPosition" � Getcaret% �Sș "XOS_SWINumberFromString",,"DragASprite_Start" � dstart%;f%:�f%� 1 dstart%=0 �Wș "XOS_SWINumberFromString",,"JPEG_PlotScaled" � jpegpaint%;f%:�f%� 1 jpegpaint%=0 �3ș "OS_Byte",161,&1C � ,,f%:�(f%�2)=0 dstart%=0 �nextlocation%=� �,ș "Wimp_SlotSize",-1,-1 � originalslot% ��locale_initialise �� version%>=300 � �Y� q% 255,ifactors% 15,factors% 15,pixtrans% 255,paltemp% 1023,buffer% 255,idata% 1023 �� �a� z% 1699,q% 255,ifactors% 15,factors% 15,pixtrans% 255,paltemp% 1023,buffer% 255,idata% 2399 eidata%=idata%+2400 � &2scrap%=�:sprite%=�:sar%=�:saved%=�:z$=�12,�13) :ș "OS_Byte",161,&8C � ,,f% D �f% � 1 � N7ș"Wimp_OpenTemplate",,"<ChangeFSI$Dir>.3dTemplate" X� b6ș"Wimp_OpenTemplate",,"<ChangeFSI$Dir>.Templates" l� �� � �6� � ș"Wimp_CloseTemplate":� 0,�$+" (code "+Þ+")" ��version%>=300 � �name=q% �$$name="*":here%=0:largest_tem%=0 �;ș "Wimp_LoadTemplate", ,0,,,,name,0 � ,size%,,,,,here% �ȕ here% �+� largest_tem%<size% largest_tem%=size% � $name="*" �?ș "Wimp_LoadTemplate", ,0,,,,name,here% � ,size%,,,,,here% �� � z% largest_tem% � �dotemplate("Info") *4ș CreateW,,z% � infow%:$!(z%+88+7*32+20)=m$(21) >�dotemplate("Processing") Hș CreateW,,z% � proc% Rap%(0)=!(z%+88+8*32+20):p%(1)=!(z%+88+9*32+20):p%(2)=!(z%+88+10*32+20):p%(3)=!(z%+88+12*32+20) f�dotemplate("Output") pkș CreateW,,z% � output%:admode%=!(z%+88+20*32+20):adspcl%=!(z%+88+19*32+20):oldmode%=!(z%+88+34*32+20) ��dotemplate("Scaling") �6ș CreateW,,z% � scalew%:adscale%=!(z%+88+1*32+20) �cs%(0)=!(z%+88+10*32+20):s%(1)=!(z%+88+11*32+20):s%(2)=!(z%+88+12*32+20):s%(3)=!(z%+88+13*32+20) ��dotemplate("Save") �Rș CreateW,,z% � save%:adsave%=!(z%+88+1*32+20):adsavesprite%=!(z%+88+0*32+20) ��dotemplate("Sprite") �Pș CreateW,,z% � sinfo%:adsname%=!(z%+88+5*32+20):adsbytes%=!(z%+88+8*32+20) �Hadsx%=!(z%+88+7*32+20):adsy%=!(z%+88+9*32+20):adsm%=!(z%+88+6*32+20) ��dotemplate("Source") �5ș CreateW,,z% � srcinfo%:adsrc%=!(z%+88+0*32+20) �dotemplate("Range") 5ș CreateW,,z% � raninfo%:adran%=!(z%+88+0*32+20) .�dotemplate("Zoom") 8Hș CreateW,,z% � zoom%:z%(0)=!(z%+88+4*32+20):z%(1)=!(z%+88+5*32+20) L�dotemplate("JPEGOutput") V5ș CreateW,,z% � jpego%:adjpegq%=!(z%+88+5*32+20) j�dotemplate("Pic") t(ș CreateW,,z% � pic%:adtitle%=z%!72 �� � �ș"Wimp_CloseTemplate" �@!q%=-1:q%!4=0:q%!8=0:q%!12=68:q%!16=68:q%!20=%11000000000010 �:$(q%+24)="!"+m$(20):ș"Wimp_CreateIcon",,q% � iconbar% �)A%=�"<ChangeFSI$Dir>.Choices":�A%=0 � �]fast%=�:dest%=1:statescale%=%10000000100:stateproc%=0:stateoutput%=&4052008:statejpeg%=&2 �N$p%(0)="":$p%(1)="2"+decimal_point$+"2":$p%(2)="24":$p%(3)="4":$adspcl%="" �=$admode%="28":$s%(0)="1":$s%(1)="4":$s%(2)="1":$s%(3)="4" �$adjpegq%="75":$oldmode%="" �� �W�#A%,fast%,dest%,statescale%,stateproc%,stateoutput%,statejpeg%,$adjpegq%,$oldmode% �6�#A%,$p%(0),$p%(1),$p%(2),$p%(3),$admode%,$adspcl% 5$p%(1)=�locale_convert($p%(1),".",decimal_point$) $�#A%,$s%(0),$s%(1),$s%(2),$s%(3) �#A% � (q%!12=1<<21 2=!q%=scalew%:�I%=0�9:�statescale%>>I%�1 q%!8=1<<21 �q%!8=0 <q%!4=I%:ș SetI,,q%:� F3�I%=10�13:�statescale%>>I%�1 q%!8=1<<21 �q%!8=0 Pq%!4=I%+6:ș SetI,,q%:� Z:!q%=proc%:�I%=0�7:�stateproc%>>I%�1 q%!8=1<<21 �q%!8=0 dq%!4=I%:ș SetI,,q%:� n?!q%=output%:�I%=0�26:�stateoutput%>>I%�1 q%!8=1<<21 �q%!8=0 xq%!4=I%:ș SetI,,q%:� �;!q%=jpego%:�I%=0�3:�statejpeg%>>I%�1 q%!8=1<<21 �q%!8=0 �q%!4=I%:ș SetI,,q%:� �*�stateoutput%>>17�1 q%!8=1<<22 �q%!8=0 �i!q%=output%:q%!12=1<<22:q%!4=7:ș SetI,,q%:q%!4=8:ș SetI,,q%:q%!4=13:ș SetI,,q%:q%!4=14:ș SetI,,q% �)�showscaletofit:$z%(0)="1":$z%(1)="1" � ș "OS_UpdateMEMC" � oldmemc �jpegsave%=� �>� � ș"OS_UpdateMEMC",oldmemc,&700:�errorbox:ș CrMenu,,-1 �ș Drag,,-1 �1�sprite% ș "Wimp_SlotSize",originalslot%,-1 �BF$="":�startfile% startfile%=�:F$=�A$,�A$,"-wimp")+6):�callFSI �� �ș Poll%,1,q% � A% Ȏ A% � %� 1 :�sprite% �redraw_window(!q%) B� 2 :�open_window(!q%,q%!4,q%!8,q%!12,q%!16,q%!20,q%!24,q%!28) "2� 3 :ș &400c3,,q%:nextlocation%=�:�removearea ,:ș "Wimp_SlotSize",originalslot%,-1:saved%=�:sprite%=� 65� 6 :�checkmouse(!q%,q%!4,q%!8,q%!12,q%!16,q%!20) @F� 7 :ș GetP,,q%:dw%=q%!12:di%=q%!16:�dstart% ș"DragASprite_Stop" JJq%!12=0:q%!16=1:q%!20=dw%:q%!24=di%:q%!28=!q%:q%!32=q%!4:q%!36=!sar%+3 T&�jpegsave% �q%!40=&c85 �q%!40=&ff9 ^.temp$=�ZS(adsave%):foo%=�temp$,"."):ȕfoo% h)temp$=�temp$,foo%+1):foo%=�temp$,".") r� |,$(q%+44)=temp$+�0:!q%=44+(�temp$+1+3��3) �3ș "Wimp_SendMessage",17,q%,dw%,di%:myref%=q%!8 �� 8 :�key(!q%,q%!4,q%!24) �� 9 :�menuselect(q%) �� 17,18:�receive(q%) �� �� � �� �Q%=� ��=&4000000 �S� � � � �:�"Set ChangeFSI$ReturnCode "+�$+" (code "+Þ+")":�removearea:�:�=Q%:� �1foo%=0:A%=�ChangeFSI(A$,-1,-1,0,-1,-1,foo%,�) �+�removearea:*unset ChangeFSI$ReturnCode � �:�=Q% � � &� �dotemplate(a$) 0� A% :�version%>300 � D5ș "Wimp_LoadTemplate",,0,,,,a$+z$,0 � ,,indsize% N� A% indsize% X7ș"Wimp_LoadTemplate",,z%,A%,A%+indsize%,-1,a$+z$,0 b� lBș"Wimp_LoadTemplate",,z%,idata%,eidata%,-1,a$+z$,0 � ,,idata% v� �� �� �locale_initialise �� p% �� � �� � � decimal_point$=".":� �(ș "Territory_ReadSymbols",-1,0 � p% �decimal_point$=�?p% �� �� �locale_convert(n$,f$,t$) �� f$=t$ �=n$ �� i% i%=�n$,f$) $� i%<>0 �=�n$,i%-1)+t$+�n$,i%+1) =n$ *� �receive(q%) 4Ȏ q%!16 � >)� 0:�removearea:ș "Wimp_CloseDown":� H� 1:�q%!20<>save% � RA!q%=60:q%!12=q%!8:q%!16=2:q%!36=-1:$(q%+44)="<Wimp$Scrap>"+�0 \/ș"Wimp_SendMessage",17,q%,q%!4:scrap%=q%!8 f� p� 2:�jpegsave% � z7ș"OS_File",10,�ZS(q%+44),&c85,,sar%,sar%+jpegsize% �� � șspop%,&10C,sar%,�ZS(q%+44) �� �$adsave%=�ZS(q%+44) �7q%!12=q%!8:q%!16=3:ș "Wimp_SendMessage",18,q%,q%!4 �� q%!36<>-1 saved%=� �ș CrMenu,,-1 �1� 3:F$=�ZS(q%+44):�scrap% scrap%=scrap%=q%!12 �6q%!12=q%!8:q%!16=4:ș"Wimp_SendMessage",17,q%,q%!4 ��callFSI �� 5:Ȏ q%!40 � �� &ff0,&c85 �6q%!12=q%!8:q%!16=4:ș"Wimp_SendMessage",17,q%,q%!4 F$=�ZS(q%+44):�callFSI � � 8:�saved%��sprite% � $-!buffer%=�:$(buffer%+4)=m$(2)+F$+m$(3)+�0 .4ș"Wimp_ReportError",buffer%,%10111,m$(20) � ,A% 82q%!12=q%!8:�A%<>1 ș"Wimp_SendMessage",19,q%,0 BB�9,&400C1:�sprite% �getmodeinfo:ș&400d1,pic%,0,-32767,32767,0 L�showscaletofit VH� 10:ș"XOS_ReadVarVal","ChangeFSI$Dir",paltemp%,256,0,3 �,,bootlen% `paltemp%?bootlen%=13 j�#q%!20,"Run "+$paltemp% t� ~� �� �callFSI �� �checkvalues �� �A$=�deducemode:A%=47 �jpegsave%=�:�dest%=0 � �@jpegsave%=�:A$="JPEG":�geticonstate(jpego%,2) A$="JPEGMONO" �A$+=$adjpegq% �� � �geticonstate(output%,15) � �A$+=$adspcl% �� � �geticonstate(output%,16) � ?�geticonstate(output%,5)��geticonstate(output%,11) A$+="R" � ș53,�A$,3 �,,A% �A%=63 � (&�geticonstate(output%,6) A$="27t" 2'�geticonstate(output%,12) A$="12t" <� F�A%=255 A$+="d" P� Z� d� n� x/A$="garbage "+F$+" <ChangeFSI$Dir>.Foo "+A$ ��ChangeFSISuffix �%info$="":range$=m$(19):cputime%=0 �6�sprite% !q%=pic%:ș &400c3,,q%:saved%=�:sprite%=� �nextlocation%=� �3ș "Wimp_SlotSize",originalslot%,-1:�removearea �1�fast% ș "OS_UpdateMEMC",&300,&700 � oldmemc �4A%=�ChangeFSI(A$,-1,-1,nextlocation%,0,0,sar%,0) �*�fast% ș "OS_UpdateMEMC",oldmemc,&700 �%�scrap% scrap%=�:ș"OS_File",6,F$ ��A%<2 � sar%<>0 � �*$adsx%=�xsp%:$adsy%=�ysp%:�jpegsave% � �"$adsm%="JPEG":$adsname%="JPEG" �$adsbytes%=�jpegsize% x=xsp%*2:y=ysp%*2 %ș&35,-1,4 �,,nx:ș&35,-1,5 �,,ny =!ifactors%=1:ifactors%!4=1:ifactors%!8=nx:ifactors%!12=ny "$adsavesprite%="file_c85" ,%� �F$,7)="<Wimp$S" F$="JPEGImage" 6� @'ș spopx%,&10d,sar%,pixtrans%,255,1 J7n$=�ZS(pixtrans%):ș spopx%,&128,sar%,n$ �,,,x,y,,m T$adsm%=�m:$adsname%=n$ ^$adsbytes%=�sar%!12 hș&35,m,4 �,,nx:x=x<<nx r(ș&35,m,5 �,,ny:y=y<<ny:�getmodeinfo |$adsavesprite%="file_ff9" �&� �F$,7)="<Wimp$S" F$="SpriteFile" �� �/!q%=save%:q%!4=0:q%!8=0:q%!12=0:ș SetI,,q% �c$adran%=range$:$adsrc%=info$+m$(0)+�(cputime%�100)+decimal_point$+�"0"+�(cputime%�100),2)+m$(1) �saved%=�:sprite%=� �'A%=�F$:ȕ�"."+F$,A%,1)<>".":A%-=1:� �$adsave%=�"."+F$,A%+1) �pic%=�create_window(x,y,F$) ��popup(pic%,-1) � � &� �checkvalues 0� e,error$,flag% D � dest%=0 � �$adjpegq%>100 � N1e=1:error$=m$(22)+m$(25)+m$(23)+m$(27)+m$(24) X� l"� �$admode%,1)<"A" � dest%=1 � vș &35,�$admode%,0 � ;flag% �� �$admode%=0 flag%=2 �+� �$admode%>127 � �$admode%<256 flag%=2 �� (flag%�2)>0 � �1e=2:error$=m$(22)+m$(26)+m$(23)+m$(13)+m$(24) �� �� � � e � �1ș Drag,,-1:!buffer%=e:$(buffer%+4)=error$+�0 �2ș "Wimp_ReportError",buffer%,%01,m$(20) � ,A% �+�A%=2 �removearea:ș "Wimp_CloseDown":� �� �=e � �ChangeFSISuffix safe%=� F�geticonstate(scalew%,1) A$+=" "+�tofitx+": "+�tofity+":":safe%=� *0�geticonstate(scalew%,5) A$+=" 1:2":safe%=� 44�geticonstate(scalew%,4) A$+=" 1:2 1:1":safe%=� >4�geticonstate(scalew%,3) A$+=" 1:1 1:2":safe%=� H�geticonstate(scalew%,9) � Rsafe%=� \%�$s%(0) A$+=" "+$s%(0) �A$+=" 1" fA$+=":"+$s%(1) p%�$s%(2) A$+=" "+$s%(2) �A$+=" 1" zA$+=":"+$s%(3) �� �,�geticonstate(scalew%,0) A$+=" -nosize" �.�geticonstate(scalew%,18) A$+=" -noscale" �+�geticonstate(scalew%,19) A$+=" -lock" ��geticonstate(scalew%,6) � �Fsafe%=�:�geticonstate(scalew%,16) A$+=" -rotate" �A$+=" -rotate-" �� �3�geticonstate(scalew%,7) A$+=" -hflip":safe%=� �3�geticonstate(scalew%,8) A$+=" -vflip":safe%=� �1�geticonstate(proc%,0) A$+=" -range":safe%=� �1�geticonstate(proc%,1) A$+=" -equal":safe%=� �,�geticonstate(proc%,2) A$+=" -nodither" �2�geticonstate(proc%,3) A$+=" -invert":safe%=� ,�geticonstate(proc%,4) A$+=" -brighten" 0�geticonstate(proc%,5) A$+=" -black"+$p%(0) \�geticonstate(proc%,6) A$+=" -gamma"+�locale_convert($p%(1),decimal_point$,"."):safe%=� $:�geticonstate(proc%,7) A$+=" -sharpen"+$p%(2):safe%=� .2�geticonstate(proc%,11) A$+=" -smooth"+$p%(3) 8� L� �checkandfinish V7�saved% ��sprite% �removearea:ș "Wimp_CloseDown":� `-!buffer%=�:$(buffer%+4)=m$(2)+F$+m$(3)+�0 j5ș "Wimp_ReportError",buffer%,%10111,m$(20) � ,A% t+�A%=1 �removearea:ș "Wimp_CloseDown":� ~� �� �key(handle%,icon%,key%) ��key%=&1b ș CrMenu,,-1:� �Ȏ handle% � �� zoom%:Ȏ key% � �C� 13:�dozoom(icon%-4,0):�icon%=4 ș &400d2,zoom%,5,,,-1,�$z%(0) ��icon%=5 ș CrMenu,,-1 �� �"� &18e,&18f:�dozoom(icon%-4,0) �0ș &400d2,zoom%,icon%�1,,,-1,�$z%(icon%�5):� �� �� save% �key%=13 �savesprite:� � output% p� icon%=34 � �geticonstate(output%, 24) �$admode% = $oldmode%:!q%=output%:q%!4=20:q%!8=0:q%!12=0:ș SetI,,q% �showscaletofit (�key%=13 ș CrMenu,,-1:� 2�key%=&18e � <Ȏ icon% � F� 19:icon%=34:key%=oldmode% P� 34:icon%=22:key%=adjpegq% Z� 22:icon%=19:key%=adspcl% d� n� x�key%=&18f � �Ȏ icon% � �� 22:icon%=34:key%=oldmode% �� 34:icon%=19:key%=adspcl% �� 19:icon%=22:key%=adjpegq% �� �� �4�key%>1024 ș &400d2,output%,icon%,,,-1,�$key%:� �� proc%:Ȏ key% � �A� &18e,13:icon%+=1:�icon%>10 icon%=8:�key%=13 ș CrMenu,,-1:� �.ș &400d2,proc%,icon%,,,-1,�$p%(icon%-8):� �%� &18f:icon%-=1:�icon%<8 icon%=10 �.ș &400d2,proc%,icon%,,,-1,�$p%(icon%-8):� �� � scalew%:Ȏ key% � B� &18e,13:icon%+=1:�icon%>13 icon%=10:�key%=13 ș CrMenu,,-1:� 1ș &400d2,scalew%,icon%,,,-1,�$s%(icon%-10):� "&� &18f:icon%-=1:�icon%<10 icon%=13 ,1ș &400d2,scalew%,icon%,,,-1,�$s%(icon%-10):� 6� @� Jș "Wimp_ProcessKey",key% T� h� �savesprite r� F$=$adsave% � |1ș Drag,,-1:!buffer%=3:$(buffer%+4)=m$(28)+�0 �2ș "Wimp_ReportError",buffer%,%11,m$(20) � ,A% ��A%=2 � �ș CrMenu,,-1 �� �� �� ��jpegsave% � �5ș"OS_File",10,$adsave%,&c85,,sar%,sar%+jpegsize% �� �ș spop%,&10C,sar%,$adsave% �� �ș CrMenu,,-1 �� 7� �checkmouse(mousex%,mousey%,b%,handle%,icon%,ob%) � moved%:moved%=� &�b%�2 � 0Ȏ handle% � :|� pic%:�domenu(pic%,m$(4)+">sinfo%,"+m$(5)+">srcinfo%,"+m$(6)+">raninfo%,"+m$(7)+">zoom%,"+m$(8)+">save%,"+m$(9),m$(20)) D�� -2:�domenu(101,m$(10)+">infow%,"+m$(11)+">scalew%,"+m$(12)+">proc%,"+m$(13)+">output%:dest%,"+m$(27)+">jpego%:1-dest%,"+m$(9)+","+m$(14)+":fast%AND1,"+m$(15)+","+m$(16),m$(20)) N� Xrmenuhandle%=handle% b� l�b%�4 � vȎ handle% � �� zoom%:Ȏ icon% � �� 0:�dozoom(0,1) �� 1:�dozoom(0,-1) �� 2:�dozoom(1,1) �� 3:�dozoom(1,-1) �� �� �� ��b%�1 � �Ȏ handle% � �� zoom%:Ȏ icon% � �� 0:�dozoom(0,-1) �� 1:�dozoom(0,1) � 2:�dozoom(1,-1) � 3:�dozoom(1,1) � � *� 4�b%�5 � >Ȏ handle% � H�� output%:� dest%=0 dest%=1:�domenu(101,m$(10)+">infow%,"+m$(11)+">scalew%,"+m$(12)+">proc%,"+m$(13)+">output%:dest%,"+m$(27)+">jpego%:1-dest%,"+m$(9)+","+m$(14)+":fast%AND1,"+m$(15)+","+m$(16),m$(20)):ș Getcaret%,,q%:moved%=� RȎ icon% � \n� 3,4,5,6:�killcurrent(�(22+icon%)):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% fh� 7:�killcurrent("S16,90,90"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% ph� 8:�killcurrent("S32,90,90"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% z`� 9:�killcurrent("0"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% �a� 10:�killcurrent("8"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% �b� 11:�killcurrent("12"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% �b� 12:�killcurrent("15"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% �i� 13:�killcurrent("S16,90,45"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% �i� 14:�killcurrent("S32,90,45"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% ��� 15:�killcurrent(�deducemode):ș SetI,,q%:ș Caretpos%,output%,19,,,-1,�($adspcl%):!q%=output%:q%!4=7:q%!8=0:q%!12=1<<22:ș SetI,,q%:q%!4=8:ș SetI,,q%:q%!4=13:ș SetI,,q%:q%!4=14:ș SetI,,q% ��� 16:�killcurrent(�deducemode):!q%=output%:q%!4=7:q%!8=0:q%!12=1<<22:ș SetI,,q%:q%!4=8:ș SetI,,q%:q%!4=13:ș SetI,,q%:q%!4=14:ș SetI,,q% ʓ� 17:�killcurrent(�deducemode):!q%=output%:q%!4=7:q%!8=1<<22:q%!12=1<<22:ș SetI,,q%:q%!4=8:ș SetI,,q%:q%!4=13:ș SetI,,q%:q%!4=14:ș SetI,,q% �� �$admode%,1) = "S" � �� �$admode%,2) = "45" � �]�killcurrent("15"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% �� �]�killcurrent("28"):!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:q%!4=24:ș SetI,,q% � � ;� 18:!q%=output%:q%!4=24:q%!8=0:q%!12=1<<21:ș SetI,,q% $� 24:!q%=output%:q%!4=18:q%!8=0:q%!12=1<<21:ș SetI,,q%:�killcurrent(�deducemode):ș Caretpos%,output%,34,,,-1,�($oldmode%) .B� 34:� moved% ș Caretpos%,output%,q%!4,q%!8,q%!12,q%!16,q%!20 8B� 19:� moved% ș Caretpos%,output%,q%!4,q%!8,q%!12,q%!16,q%!20 B� L3�geticonstate(output%,18) $admode%=�deducemode V2!q%=output%:q%!4=20:q%!8=0:q%!12=0:ș SetI,,q% `�showscaletofit j� save%:Ȏ icon% � t� 2:�savesprite ~� �M� -2:�sprite% �getw(pic%):�open_window(pic%,x0%,y0%,x1%,y1%,scx%,scy%,-1) �� jpego%:� dest%=1 � �ș Getcaret%,,q% ��dest%=0:�domenu(101,m$(10)+">infow%,"+m$(11)+">scalew%,"+m$(12)+">proc%,"+m$(13)+">output%:dest%,"+m$(27)+">jpego%:1-dest%,"+m$(9)+","+m$(14)+":fast%AND1,"+m$(15)+","+m$(16),m$(20)) �=� icon%=5 ș Caretpos%,jpego%,q%!4,q%!8,q%!12,q%!16,q%!20 �� �Ȏ icon% � �D� 3:� b%�4 �$adjpegq%=�(�$adjpegq%-1) �$adjpegq%=�(�$adjpegq%+1) � � �$adjpegq%<0 $adjpegq%="0" �$� �$adjpegq%>100 $adjpegq%="100" �0!q%=jpego%:q%!4=5:q%!8=0:q%!12=0:ș SetI,,q% �)ș Caretpos%,jpego%,5,,,-1,�$adjpegq% D� 4:� b%�4 �$adjpegq%=�(�$adjpegq%+1) �$adjpegq%=�(�$adjpegq%-1) � �$adjpegq%<0 $adjpegq%="0" $� �$adjpegq%>100 $adjpegq%="100" 0!q%=jpego%:q%!4=5:q%!8=0:q%!12=0:ș SetI,,q% ()ș Caretpos%,jpego%,5,,,-1,�$adjpegq% 2� 5 <� F� P� Z �b%�&50 � dȎ handle% � n� save%:Ȏ icon% � x� 0:�getw(save%) � !q%=save%:q%!4=0:ș GetI,,q% �?!q%=save%:q%!4=5:q%!8+=bx%:q%!12+=by%:q%!16+=bx%:q%!20+=by% �3q%!24=0:q%!28=0:q%!32=&7FFFFFFF:q%!36=&7FFFFFFF �*t$="file_ff9":�jpegsave% t$="file_c85" �H�dstart% ș dstart%,%11000101,1,t$,q%+8,q%+24 �ș "Wimp_DragBox",,q% �� �� �� �� �� �dozoom(s%,a%) ��s%=0 � �/$z%(0)=�(�$z%(0)+a%):�$z%(0)="0" $z%(0)="1" � /$z%(1)=�(�$z%(1)+a%):�$z%(1)="0" $z%(1)="1" � "2!q%=zoom%:q%!4=4+s%:q%!8=0:q%!12=0:ș SetI,,q% ,/!q%=pic%:ș GetW,,q%:f%=q%!28:ș &400c3,,q% 6pic%=�create_window(x,y,F$) @�popup(pic%,f%) J� ^'� �domenu(handle%,menu$,menutitle$) hmenuhandle%=handle% r%menuptr%=buffer%:indirect%=idata% |i%=0 �menuptr%!20=44 �$menuptr%=menutitle$ �;menuptr%?12=7:menuptr%?13=2:menuptr%?14=7:menuptr%?15=0 �!menuptr%!16=200:menuptr%!24=0 �menuptr%+=28 �%� i1%=i%+1:i%=�menu$+",",",",i1%) �8item$=�menu$,i1%,i%-i1%):�menuitem(item$):� item$="" �#menuptr%!-24=(menuptr%!-24)�&80 �`�handle%=101 ș CrMenu,,buffer%,mousex%-64,96+9*44 �ș CrMenu,,buffer%,mousex%-32,mousey%+16 �� �� �menuitem(text$) �� text$="" � *flg%=0:submenu%=-1:I%=�text$,":"):�I%� )flg%=��text$,I%+1):text$=�text$,I%-1) � &I%=�text$,">"):�I%� 0-submenu%=��text$,I%+1):text$=�text$,I%-1) :� Dmenuptr%!0=flg% Nmenuptr%!4=submenu% XV�(text$=m$(9)�(F$="" � F$="SpriteFile" � F$="JPEGImage")) � (text$=m$(14)�vram%) � bmenuptr%!8=&07400021 l� vmenuptr%!8=&07000021 �� �2�text$*16+8>buffer%!16 buffer%!16=�text$*16+8 ��text$>12 � �Bmenuptr%!8=menuptr%!8 � 256:menuptr%!20=�text$+1:menuptr%!16=0 �>menuptr%!12=indirect%:$indirect%=text$:indirect%+=�text$+2 �� �$(menuptr%+12)=text$ �� �menuptr%+=24 �� �� �menuselect(menus%) �,ș GetP,,paltemp%:adjust%=paltemp%!8 � 1 -ș DcMenu,,buffer%,menus%,�200," ")�,,,a$ � a$="" �� Ȏ menuhandle% � � pic% *Ȏ a$ � 4� m$(9):�callFSI >� H � 101 RȎ a$ � \� m$(14):fast%=�fast% f� m$(27):dest%=0 p� m$(13):dest%=1 z� m$(9):�callFSI �� m$(15) �Fstatescale%=0:�I%=0�9:statescale%+=�geticonstate(scalew%,I%)<<I%:� �<�I%=10�13:statescale%+=�geticonstate(scalew%,I%+6)<<I%:� �Bstateproc%=0:�I%=0�7:stateproc%+=�geticonstate(proc%,I%)<<I%:� �Istateoutput%=0:�I%=0�26:stateoutput%+=�geticonstate(output%,I%)<<I%:� �Cstatejpeg%=0:�I%=0�3:statejpeg%+=�geticonstate(jpego%,I%)<<I%:� �!A%=�"<ChangeFSI$Dir>.Choices" �W�#A%,fast%,dest%,statescale%,stateproc%,stateoutput%,statejpeg%,$adjpegq%,$oldmode% �Z�#A%,$p%(0),�locale_convert($p%(1),decimal_point$,"."),$p%(2),$p%(3),$admode%,$adspcl% �$�#A%,$s%(0),$s%(1),$s%(2),$s%(3) ��#A% �� m$(16):�checkandfinish �� � 0�adjust% �checkmouse(0,0,2,rmenuhandle%,0,0) � . � �create_window(x,y,title$) 8+x=x*�$z%(0)��$z%(1):y=y*�$z%(0)��$z%(1) B !z%=0:z%!4=-y:z%!8=x:z%!12=0 L$z%!40=0:z%!44=-y:z%!48=x:z%!52=0 V%�x<128 � y<128 z%?35=0 �z%?35=255 `)$adtitle%="":ș CreateW,,z% � handle% j$adtitle%=title$ t=handle% �� �popup(handle%,f%) �1ș "OS_ReadModeVariable",-1,4 � ,,modexshift% �1ș "OS_ReadModeVariable",-1,5 � ,,modeyshift% �0ș "OS_ReadModeVariable",-1,11 � ,,rightscr% �.ș "OS_ReadModeVariable",-1,12 � ,,topscr% �Arightscr%=rightscr%<<modexshift%:topscr%=topscr%<<modeyshift% ��getw(handle%) �9xo%=rightscr%/2-(x0%+x1%)/2:yo%=topscr%/2-(y0%+y1%)/2 �F�open_window(handle%,x0%+xo%,y0%+yo%,x1%+xo%,y1%+yo%,scx%,scy%,f%) �� �>� �open_window(handle%,x0%,y0%,x1%,y1%,scx%,scy%,bhandle%) �handle%=-1�� q%!0=handle%:q%!28=bhandle% )q%!4=x0%:q%!8=y0%:q%!12=x1%:q%!16=y1% q%!20=scx%:q%!24=scy% (ș OpenW,,q% 2� F� �getw(handle%) P!q%=handle%:ș GetW,,q% Z+�info(q%+4):bhandle%=q%!28:flags%=q%!32 d� x� �info(q%) �=x0%=!q%:y0%=q%!4:x1%=q%!8:y1%=q%!12:scx%=q%!16:scy%=q%!20 �bx%=x0%-scx%:by%=y1%-scy% �� �� �redraw_window(handle%) �� handle%=pic% � �?!factors%=!ifactors%*�$z%(0):factors%!4=ifactors%!4*�$z%(0) �Cfactors%!8=ifactors%!8*�$z%(1):factors%!12=ifactors%!12*�$z%(1) �A�reduce(!factors%,factors%!8):�reduce(factors%!4,factors%!12) �!q%=handle% �ș RedrawW,,q% � more% �,�info(q%+4):by%=by%-�(y*�$z%(0)��$z%(1)) �ȕ more% �jpegsave% � Q�jpegpaint% ș jpegpaint%,sar%,bx%,by%,factors%,jpegsize%,1 �;V%:�(V%�1)=0 �� � "1ș spopx%,&134,sar%,n$,bx%,by%,,factors%,spx% ,� 6ș GetR%,0,q% � more% @� J� T� h"� �geticonstate(handle%,icon%) r&!q%=handle%:q%!4=icon%:ș GetI,,q% |=q%!24>>21 � 1 �� �getmodeinfo ��jpegsave% � �%ș&35,-1,4 �,,nx:ș&35,-1,5 �,,ny �=!ifactors%=1:ifactors%!4=1:ifactors%!8=nx:ifactors%!12=ny �� �� �>ș"XWimp_ReadPixTrans",&100,sar%,n$,,,,ifactors%,pixtrans% �$ș spopx%,&118,sar%,n$ � ,,sptr% �� sptr%!32=44 � � palptr%=0 �� �A� grab%=0 � 2048-8 � 8:paltemp%!(grab%>>1)=sptr%!(grab%+44):� palptr%=paltemp% � �Q%=0�255:pixtrans%?Q%=Q%:� &�sptr%!32=44+2048 � 05�Q%=0�255:șctran%,palptr%!(Q%<<2)�pixtrans%?Q%:� :� D:ș "ColourTrans_SelectTable",m,palptr%,-1,-1,pixtrans% N� X6spx%=-1:�Q%=0�255:�pixtrans%?Q%<>Q% spx%=pixtrans% b� l� �� �deducemode �� m,x,y � �geticonstate(output%,21) � �3�geticonstate(output%,17) �="JPEG8" �="JPEG24" �� � �geticonstate(output%,18) � �ș &6,135 � ,,m �ș&35,-1,9 �,,m � �m>3 � �#ș&35,-1,4 �,,x:ș&35,-1,5 �,,y �x=180/(2^x):y=180/(2^y) �="S"+�(2^m)+","+�x+","+�y � =�� � � *!� �geticonstate(output%,24) � 4=$oldmode% >� H =$admode% R� \� f� z� �showscaletofit �� m,x,y �$admode%=�deducemode �Ȏ ?admode% � � � �"S" �)�$admode%,5)>��$admode%,8) x=6 �x=0 � �$admode%,2)>16 x+=5 �x+=4 �/ș&35,-1,11 �,,tofitx:ș&35,-1,12 �,,tofity � � �"J" �/ș&35,-1,11 �,,tofitx:ș&35,-1,12 �,,tofity �x=12 � �m=�$admode% -ș&35,m,11 �,,tofitx:ș&35,m,12 �,,tofity /ș&35,m,4 �,,x:ș&35,m,5 �,,y:�y>x x=6 �x=0 ș&35,m,9 �,,y:x+=y $� .?tofitx+=1:tofity+=1:$adscale%=m$(17)+�tofitx+m$(18)+�tofity 8=q%!12=1<<21:!q%=output%:�I%=0�11:�I%=x q%!8=1<<21 �q%!8=0 B<q%!4=I%+3:ș SetI,,q%:�:�x=12 q%!8=0:q%!4=24:ș SetI,,q% L� `� �killcurrent(m$) j"q%!12=1<<21:!q%=output%:q%!8=0 tq%!4=20:ș SetI,,q% ~$admode%=m$ �� �+ݤZS(I%)�A$:�A$+=�?I%:I%+=1:�?I%<14:=A$ �� �errorbox �>ș Drag,,-1:!buffer%=�:$(buffer%+4)=�$+" (code "+Þ+")"+�0 �2ș "Wimp_ReportError",buffer%,%11,m$(20) � ,A% �+�A%=2 �removearea:ș "Wimp_CloseDown":� �� �S� �ChangeFSI(A$,spritearea%,workspace%,worklimit%,oksave%,okinfo%,� ram%,fast%) �M� A$(),r%(),g%(),b%(),rpal%(),gpal%(),bpal%(),table%(),cl%(),xl%(),xl2%() �M� xp%(),rm%(),rm1%(),rm2%(),vals%(),nl%(),A%(),B%(),new%(),st%(),jpq%(),m �$ȕ�A$,1)<>" "��A$<>0 A$=�A$,2):� �ȕ�A$,1)=" " A$=�A$,2):� �ȕ�A$,1)=" " A$=�A$):� �uc(�A$,5))="-QUIT" � .A$=�A$,7):ȕ�A$,1)<>" "��A$<>0 A$=�A$,2):� ȕ�A$,1)=" " A$=�A$,2):� "� , � A$(100):ARG%=0:B%=�A$," ") 6ȕ B%<>0 @+ARG%+=1:A$(ARG%)=�A$,B%-1):A$=�A$,B%+1) Jȕ �A$,1)=" ":A$=�A$,2):� TB%=�A$," ") ^� h�A$<>"" ARG%+=1:A$(ARG%)=A$ rXinvert%=�:range%=�:sharpen%=�:info%=�:cache%=�:cacheareanumber%=0:dither%=�:black%=� |Chist%=�:equal%=�:vflip%=�:hflip%=�:scale%=�:scaleo%=�:scrapf%=� �6gamma=1:rotate%=�:max%=20000000:bright%=15:lock%=� �rwt=.299:gwt=.587:bwt=.114 � �ARG%<3 � �J�"ChangeFSI interactive input (read FSIinfo for command line details)" �?�"Source file: "s$,"Destination file: "f$,"Output mode: "m$ �/�"(X)Scale (e.g. 2:1): "xs$:�"Y Scale: "ys$ �8�"Info on input picture?"a$:�uc(�a$,1))="Y" info%=� �;�"Invert picture colours?"a$:�uc(�a$,1))="Y" invert%=� �=�"Compute histogram of input?"a$:�uc(�a$,1))="Y" hist%=� �@�"Apply histogram equalisation?"a$:�uc(�a$,1))="Y" equal%=� �G�"Expand input dynamic range?"a$:�uc(�a$,1))="Y" range%=�:equal%=� �=�"Sharpen picture by (e.g. 12 for harsh, 24 for soft) "a$ ��a$<>"" sharpen%=�a$ +�"Rotate?"a$:�uc(�a$,1))="Y" rotate%=1 scale%=�:scaleo%=�:fast%=� � & � A%=ARG% 06�uc(A$(ARG%))="-INFO" info%=�:A$(ARG%)="":ARG%-=1 :6�uc(A$(ARG%))="-HIST" hist%=�:A$(ARG%)="":ARG%-=1 D6�uc(A$(ARG%))="-LOCK" lock%=�:A$(ARG%)="":ARG%-=1 NA�uc(A$(ARG%))="-EQUAL" equal%=�:range%=�:A$(ARG%)="":ARG%-=1 XA�uc(A$(ARG%))="-RANGE" range%=�:equal%=�:A$(ARG%)="":ARG%-=1 b:�uc(A$(ARG%))="-INVERT" invert%=�:A$(ARG%)="":ARG%-=1 lD�uc(A$(ARG%))="-NOSCALE" scale%=�:scaleo%=�:A$(ARG%)="":ARG%-=1 v9�uc(A$(ARG%))="-NOSIZE" scale%=�:A$(ARG%)="":ARG%-=1 �<�uc(A$(ARG%))="-NODITHER" dither%=�:A$(ARG%)="":ARG%-=1 �=�uc(A$(ARG%))="-BRIGHTEN" bright%=16:A$(ARG%)="":ARG%-=1 �:�uc(A$(ARG%))="-ROTATE" rotate%=1:A$(ARG%)="":ARG%-=1 �<�uc(A$(ARG%))="-ROTATE-" rotate%=-1:A$(ARG%)="":ARG%-=1 �8�uc(A$(ARG%))="-VFLIP" vflip%=�:A$(ARG%)="":ARG%-=1 �8�uc(A$(ARG%))="-HFLIP" hflip%=�:A$(ARG%)="":ARG%-=1 �8�uc(A$(ARG%))="-NOMODE" fast%=�:A$(ARG%)="":ARG%-=1 �!�uc(�A$(ARG%),6))="-BLACK" � �Fblack%=32:�A$(ARG%)>6 black%=��A$(ARG%),7):�black%>128 black%=128 �A$(ARG%)="":ARG%-=1 �� �!�uc(�A$(ARG%),6))="-GAMMA" � �.gamma=2.2:�A$(ARG%)>6 gamma=��A$(ARG%),7) !A$(ARG%)="":ARG%-=1 !� !#�uc(�A$(ARG%),8))="-SHARPEN" � ! 3sharpen%=24:�A$(ARG%)>8 sharpen%=��A$(ARG%),9) !*A$(ARG%)="":ARG%-=1 !4� !>"�uc(�A$(ARG%),7))="-SMOOTH" � !H4sharpen%=-1:�A$(ARG%)>7 sharpen%=-��A$(ARG%),8) !R2A$(ARG%)="":ARG%-=1:�sharpen%<-23 sharpen%=-23 !\� !fC�uc(�A$(ARG%),4))="-RED" rwt=��A$(ARG%),5):A$(ARG%)="":ARG%-=1 !pE�uc(�A$(ARG%),6))="-GREEN" gwt=��A$(ARG%),7):A$(ARG%)="":ARG%-=1 !zD�uc(�A$(ARG%),5))="-BLUE" bwt=��A$(ARG%),6):A$(ARG%)="":ARG%-=1 !��uc(�A$(ARG%),4))="-MAX" � !�Dmax%=��A$(ARG%),5):�A$(ARG%),"K")��A$(ARG%),"k") max%=max%*1024 !�A$(ARG%)="":ARG%-=1 !�� !��A%=ARG% !�2s$=A$(1):f$=A$(2):m$=A$(3):xs$=A$(4):ys$=A$(5) !�� !��okinfo% �info%=� !��workspace%>=0 � !�flex%=� !�� !�<�worklimit%=0 �flex%=� �flex%=�:nextlocation%=worklimit% !�� ""pnm$=�uc(m$):Ȏ �pnm$+",",3) � "�"AIM":m=-1:m$="" ""�"P1,","P4,":m=-2:m$="":spm=18 "$#�"P2,","P5,":m=-2:m$="T":spm=20 ".=�"P3,","P6,":m=-4:pnm$=�pnm$,2):p6bits=8:I%=��m$,4):m$="" "8�I%>0�I%<8 p6bits=I% "B�"P15":m=-3:m$="" "L�"C15":m=-5:m$="" "V�"IRL":m=-4:m$="":p6bits=8 "`�"S16":m=-6:m$="" "j�"S24":m=-7:m$="":p6bits=8 "t�"S32":m=-8:m$="":p6bits=8 "~h�"JPE":m$="":p6bits=8:�pnm$,8)="JPEGMONO" m=-9:jpegquality%=��pnm$,9) �m=-10:jpegquality%=��pnm$,5) "�5:m=�m$:spm=m:m$=�uc(�m$,1)):�"CDRT",m$)=0 m$="" "�� "��xs$="" � �xs$,1)="-" � "�#xmul%=1:xdiv%=1:ymul%=1:ydiv%=1 "�� "��ys$="" ys$=xs$ "�'xmul%=�xs$:xdiv%=��xs$,�xs$,":")+1) "�'ymul%=�ys$:ydiv%=��ys$,�ys$,":")+1) "�� "�&flag=-1:ș8,5,s$ � r0,,r2:dir=r0=2 "� �dir � "�Cpanic=�:ș8,5,s$+".raw" � r0,,r2:�r0=1 s$+=".raw":dir=�:panic=� # 1�panic ș8,5,s$+".red" � r0,,r2:�r0=1 panic=� # !�panic � 42,"Directory given" #� #>ftype=r2>>8 � &FFF:bits=28:F=2^bits:c%=0:cc%=0:ccc%=0:o%=0 #( �dir � #2>c%=�(s$+".red"):�c%=0 � 42,"Red file "+s$+".red not found" #<Ecc%=�(s$+".green"):�cc%=0 �42,"Green file "+s$+".green not found" #FDccc%=�(s$+".blue"):�ccc%=0 �42,"Blue file "+s$+".blue not found" #P� #Z-c%=�s$:�c%=0 � 42,"File "+s$+" not found" #d� #n� � #x� � � � �:� �:�close:� �,�$ #�colourindex=255 #�ș&66f4d �;pcd% #�Ȏ ftype � #�� &FF9:flag=0 #�.�"."+�uc(s$),".HIP.")���uc(s$),":HIP.") � #� flag=300:I%=��uc(s$),"HIP.") #�?�s$,I%)="LOP.":cc%=�s$:�cc%=0 �42,"Can't find Lop file "+s$ #�� #�+� &FF0:�#c%=0:S$="":�I%=1�4:S$+=��#c%:� #�&�S$="II*"+�0 flag=1500:bigendian=� #�)�S$="MM"+�0+"*" flag=1500:bigendian=� $!� &DFA:flag=800:�dir flag=801 $� &DE2:flag=1000 $� &CBE:flag=3800 $" � &BE8:�(pcd%�1)=0 flag=3600 $,� &7A0:flag=1200 $6� &69d:flag=2000 $@� &699:flag=700 $J� &698:flag=100 $T� &697:flag=1900 $^� &691:flag=2600 $h� &690:flag=2500 $r� &666:flag=666 $|� &601:flag=3000 $�� &371:flag=3100 $�#� &300:flag=1300:�dir flag=1301 $�� 4:flag=900:�dir flag=901 $�� 6:flag=950 $�� $��flag=-1 � $�%�#c%=0:S$="":�I%=1�22:S$+=��#c%:� $��S$,7)="FSIfile" flag=2100 $�)�flag=-1 �S$,8)="SIMPLE " flag=2800 $�C�flag=-1 �uc(�S$,8))="MERCSOFT"��uc(�S$,8))="SNAPSHOT"flag=902 $�-�flag=-1 �uc(�S$,8))="MERCSOF1" flag=903 $�4�flag=-1 �uc(�S$,13))="IRLAM YUV 411" flag=2250 $�&�flag=-1 �S$,5)="Irlam" flag=2200 %.�flag=-1 �S$,2)="BM" flag=2400:riffoff%=0 %X�flag=-1 �S$,4)="RIFF" � �S$,9,8)="RDIBdata" � �S$,21,2)="BM" flag=2400:riffoff%=20 %$�flag=-1 �S$,4)="GIF8" flag=500 %&%�flag=-1 �S$,5)="AV_VO" flag=600 %02�flag=-1 �S$,4)=�&59+�&A6+�&6A+�&95 flag=1100 %:*�flag=-1 �S$,4)=�0+�1+�0+�8 flag=1400 %D*�flag=-1 �S$,4)=�0+�1+�0+�1 flag=2900 %N%�flag=-1 �S$,4)="RIX3" flag=2700 %X3�flag=-1 �S$,4)="II*"+�0 flag=1500:bigendian=� %b6�flag=-1 �S$,4)="MM"+�0+"*" flag=1500:bigendian=� %l(�flag=-1 �S$,2)=�&52+�&CC flag=2300 %vD�flag=-1 �S$,2)="P4"��S$,2)="P5"��S$,2)="P6" flag=3300:info$="" %�$�flag=-1 �S$,3)="P15" flag=3400 %�$�flag=-1 �S$,3)="PIC" flag=3500 %�$�flag=-1 �S$,3)="T-I" flag=3800 %�)�flag=-1 �uc(�S$,3))="P13" flag=3450 %�6�flag=-1 �S$,4)="FORM" �S$,9,4)="ILBM" flag=1600 %�:�flag=-1 �S$,8)="ALPIAR12" flag=3900:colourindex=4095 %�;�flag=-1 �S$,8)="ALPIAR16" flag=3905:colourindex=65535 %��flag=-1 � %�#�S$,7,4)="JFIF" � ftype=&C85 � %�*jpegblk%=�dim(20):�cachesize(jpegblk%) %��cache%<�#c% � %��#c%:c%=0:X%=�"Run:djpeg" %� �X% � &.�#X%:�subtask("djpeg "+s$+" <Wimp$Scrap>") &� &0ș"XOS_CLI","djpeg "+s$+" <Wimp$Scrap>" � ;V & �V �1 � &*9�subtask("<ChangeFSI$Dir>.djpeg "+s$+" <Wimp$Scrap>") &4� &>� &H"c%=�"<Wimp$Scrap>":�c%=0 �=100 &R>scrapf%=�:flag=3300:info$="JPEG (JFIF) file converted to " &\� &f flag=3700 &p� &z� &�� &��flag=-1 � &��S$,5)="btpc " � &�B�#c%:c%=0:�subtask("<ChangeFSI$Dir>.btpc "+s$+" <Wimp$Scrap>") &�"c%=�"<Wimp$Scrap>":�c%=0 �=100 &�7scrapf%=�:flag=3300:info$="BTPC file converted to " &�� &�� &��flag=-1 � &�&�#c%=&10:S$="":�I%=1�9:S$+=��#c%:� &��S$="MILLIPEDE" flag=200 &�� &��flag=-1 � '&�#c%=&41:S$="":�I%=1�8:S$+=��#c%:� '%�S$,4)="PNTG" flag=1800:st%=&280 '� '$�flag=-1 � '.&�#c%=196:S$="":�I%=1�8:S$+=��#c%:� '8%�S$,4)="PNTG" flag=1800:st%=&2e2 'B� 'L�flag=-1 � 'V&�#c%=522:S$="":�I%=1�8:S$+=��#c%:� '`2�S$=�0+�&11+�2+�&ff+�&c+�0+�&ff+�&fe flag=1850 'j� 't�flag=-1 � '~�#c%=0:�#c%=10 � '�+C%=�#c%:�C%<6 � C%<>1 ��#c%=1 flag=1900 '�� '�� '�M�flag=-1 �"."+�uc(s$),".PCX.")���uc(s$),":PCX.")��s$,4)="/PCX" flag=1900 '�B�flag=-1 �"."+�uc(s$),".IMAGE.")���uc(s$),":IMAGE.") flag=400 '�)�flag=-1 �uc(�s$,4))=".RAW" flag=100 '�)�flag=-1 �uc(�s$,3))="TGA" flag=2000 '�)�flag=-1 �uc(�s$,3))="VDA" flag=2000 '�>�flag=-1 �"."+�uc(s$),".PIC.")���uc(s$),":PIC.") flag=700 '�M�flag=-1 �"."+�uc(s$),".IMG.")���uc(s$),":IMG.")��s$,4)="/IMG" flag=1400 '�M�flag=-1 �"."+�uc(s$),".DSP.")���uc(s$),":DSP.")��s$,4)="/DSP" flag=1700 '�*�flag=-1 �uc(�s$,4))="/RGB" flag=3200 ( <�flag=-1 �(�uc(�s$,4))="/PCD"�ftype=&be8)�((pcd%�1)=1) � ( k�#c%:c%=0:�subtask("<ChangeFSI$Dir>.hpcdtoppm -3 -a "+s$+" <Wimp$Scrap> { > <ChangeFSI$Dir>.pcdtemp }") (Mc%=�"<Wimp$Scrap>":scrapf%=�:flag=3300:info$="PhotoCD file converted to " (� ((� (2c�flag=-1 �close:� 42,"Sorry: format not recognised - please try again or contact your supplier" (<Bstep24=1:input=8:ham=0:planar%=0:bigendianbits=�:r$="FN"+�flag (F9compression=0:hpredict%=1:striprows%=-1:cachebytes%=� (P�xdiv%=0 � ydiv%=0 scale%=� (Z� r%(colourindex) (d%� g%(colourindex),b%(colourindex) (n Ȏ flag � (x� 0 (�@quant%=4:�#c%=4:F%=�W+&1C:�#c%=F%:st%=�W+F%-&20:K%=�W+F%-&20 (�sm=�W:�sm<256 � (�ș53,sm,3 � ,,I% (�Ȏ I% � (�%� 1:�st%=F%+12 �defpal2 ��ipal(2) (�5�#c%=F%-16:sx%=(�W+1)*32:rowbytes%=sx%>>3:input=1 (�sy%=�W+1:I%=�W:sx%-=31-�W (�%� 3:�st%=F%+12 �defpal4 ��ipal(4) (�5�#c%=F%-16:sx%=(�W+1)*16:rowbytes%=sx%>>2:input=2 (�!sy%=�W+1:I%=�W:sx%-=(31-�W)�2 (�(� 15:�st%=F%+12 �defpal16 ��ipal(16) (�4�#c%=F%-16:sx%=(�W+1)*8:rowbytes%=sx%>>1:input=4 (�!sy%=�W+1:I%=�W:sx%-=(31-�W)�4 )� 63,255:�st%=F%+12 � )�defpal )� )"�K%>st% K%=st% ),�K%-12-F%=2048 �I%=255 � )6�#c%=&38 )@�C%=0�255:D%=�#c% )J9r%(C%)=�#c%/255*F:g%(C%)=�#c%/255*F:b%(C%)=�#c%/255*F )TD%=�W:� )^� )h�ipal63 )r� )|� )�G�#c%=F%-16:sx%=(�W+1)*4:rowbytes%=sx%:sy%=�W+1:I%=�W:sx%-=(31-�W)�8 )�) �42,"Not understood RISC OS sprite" )�� )�@r$="FN8":ș53,sm,4 � ,,nx:ș53,sm,5 � ,,ny:nx=1<<nx:ny=1<<ny )�-�scale% xmul%=xmul%*nx/2:ymul%=ymul%*ny/2 )�Sinfo$="RISC OS sprite, mode "+�sm+" "+�sx%+" by "+�sy%+" pixels, "+�bits(input) )�� )�bpp%=sm>>>27:Ȏbpp% � )�9� 1:bpp%=1:r$="FN8":�st%=F%+12 �defpal2 ��newropal(2) )�9� 2:bpp%=2:r$="FN8":�st%=F%+12 �defpal4 ��newropal(4) )�;� 3:bpp%=4:r$="FN8":�st%=F%+12 �defpal16 ��newropal(16) )�:� 4:bpp%=8:r$="FN8":�st%=F%+12 �defpal ��newropal(256) )�&� 5:bpp%=16:r$="FN16":�st%=F%+12 � *$� rpal%(255),gpal%(255):step24=2 * �C%=0�255 *"gpal%(C%)=(C%>>5)<<8 � (C%�31) *&+rpal%(C%)=((C%>>2)�31)<<16 � (C%�3)<<11 *0� *:1�C%=0�31:r%(C%)=C%/31*F:�:g%()=r%():b%()=r%() *D-� 6:bpp%=32:r$="FN24":�st%=F%+12 �nopal � *N!rbo%=0:gbo%=1:bbo%=2:step24=4 *X-� 8:bpp%=24:r$="FN24":�st%=F%+12 �nopal � *brbo%=0:gbo%=1:bbo%=2 *l8 �42,"Not understood new format RISC OS sprite bpp" *v� *�(nx=(sm>>1) �&1fff:ny=(sm>>14) �&1fff *�G�scale% xdiv%=xdiv%*nx:ydiv%=ydiv%*ny:xmul%=xmul%*90:ymul%=ymul%*90 *�Z�#c%=F%-16:rowbytes%=(�W+1)*4:sy%=�W+1:I%=�W:sx%=(rowbytes%*8-(31-�W))/bpp%:input=bpp% *�Jinfo$="New RISC OS sprite, "+�sx%+" by "+�sy%+" pixels, "+�bits(input) *��bpp%=32 input=24 *�� *��#c%=st%:cache%=� *� � 100 *�Equant%=8:�#c%=0:sx%=�HW:sy%=�HW:�nopal:input=24:rowbytes%=sx%*3+2 *�5rbo%=2:gbo%=2+sx%:bbo%=2+2*sx%:r$="FN24":cache%=� *�Jinfo$="QRT .raw image, "+�sx%+" by "+�sy%+" pixels, 24 bits per pixel" *� � 200 *�Gquant%=8:�#c%=5:sx%=�HW:sy%=�HW:sx%=(�HW-sx%+2)/2:sy%=(�HW-sy%+2)/2 +$�#c%=&1a:cadsoft%=�#c%:�#c%=&200 +?�C%=0�255:r%(C%)=�#c%/255*F:�:�C%=0�255:g%(C%)=�#c%/255*F:� +!�C%=0�255:b%(C%)=�#c%/255*F:� + -�#c%=&600:st%=&600:cache%=�:�cadsoft%=2 � +*Crep%=0:r$="FN1100":plbuff%=�dim(sx%):plbytes%=sx%:cachebytes%=� +4� +>r$="FN8":rowbytes%=sx% +H� +R[info$="Cadsoft type "+�cadsoft%+" image, "+�sx%+" by "+�sy%+" pixels, 8 bits per pixel" +\ � 300 +fIquant%=5:�#c%=&2c:st%=�W+(&38-&2c):�#cc%=&2c:stcc%=�W1(cc%)+(&38-&2c) +p7�#c%=&1c:sx%=(�W+1)*4:sy%=�W+1:�#c%=st%:�#cc%=stcc% +z;� rpal%(255),gpal%(255):input=16:cache%=�:rowbytes%=sx% +� �C%=0�255 +�.rpal%(C%)=C%�7 � (C%�64)<<2 � (C%�&38)<<13 +�Sgpal%(C%)=(C%�4)<<1�C%�16 � ((C%�3)<<1�(C%�&60)>>2)<<8 � (C%�8�(C%�128)>>3)<<16 +�� +�1�C%=0�31:r%(C%)=C%/31*F:�:g%()=r%():b%()=r%() +�*pbuff%=�dim(sx%):�scale% ymul%=ymul%*2 +�Ginfo$="ArVis image, "+�sx%+" by "+�sy%+" pixels, 15 bits per pixel" +� � 400 +�Equant%=8:�#c%=0:sx%=�beHW:sy%=�beHW:X%=�beHW:st%=�#c%+X%:�#c%=st% +�Vplbuff%=�dim(sx%*3):plbytes%=sx%*3:rb%=plbuff%:gb%=plbuff%+1:bb%=plbuff%+2:rbo%=-1 +�:�nopal:input=24:rep%=0:cachebytes%=�:cache%=�:step24=3 +�^info$="RT image. run length encoded image, "+�sx%+" by "+�sy%+" pixels, 24 bits per pixel" +� � 500 ,,compression=5:�#c%=6:GIFsx=�HW:GIFsy=�HW ,8GIF=�#c%:GIFback=�#c%:GIFext=�#c%:quant%=(GIF � 7)+1 ,�GIF � &80 � ,$�C%=0�(1<<quant%)-1 ,.9r%(C%)=�#c%/255*F:g%(C%)=�#c%/255*F:b%(C%)=�#c%/255*F ,8� ,B� ,LI%=�#c%:ȕ I%=�"!" ,` � �#c% ,j� ,t$GIFgcesz=�#c%:�#c%=�#c%+GIFgcesz ,�� GIFgcesz=0:I%=�#c% ,�� ,�6�I%<>�"," � 42,"GIF file without , in right place" ,��GIFext<>0 � GIFext<>49 � ,��GIFext>49 � ,�*xdiv%=xdiv%*64:xmul%=xmul%*(GIFext+15) ,�� ,�*ydiv%=ydiv%*(GIFext+15):ymul%=ymul%*64 ,�� - � - ,GIFleft=�HW:GIFright=�HW:sx%=�HW:sy%=�HW -�GIFsx<sx% � GIFsy<sy% � -�info% � -()�"GIF file with bigger image inside:" -2;�"Screen ";GIFsx"x by "GIFsy"y; image "sx%"x by "sy%"y" -</�"Continue with monitor's size [Y or y]?"A$ -F&�A$="Y"�A$="y" sx%=GIFsx:sy%=GIFsy -P(�"Continuing with ";sx%"x by "sy%"y" -Z� -d� -n)GIF=�#c%:�GIF � &40 flag=501:r$="FN8" -xJsetcodes%=�#c%:clearcode%=1<<setcodes%:st%=�#c%:cache%=�:cachebytes%=� -�E� table%(1<<12):stk%=�dim(1<<13):buf%=�dim(280):plbuff%=�dim(sx%) -�&�I%=0�clearcode%-1:table%(I%)=I%:� -�Ainfo$="GIF file, "+�sx%+" by "+�sy%+" pixels, "+�bits(quant%) -� � 600 -�quant%=8:�#c%=&5c:�C%=0�255 -�9r%(C%)=�#c%/255*F:g%(C%)=�#c%/255*F:b%(C%)=�#c%/255*F -�� -��#c%=&36e:sy%=�HW:sx%=�HW -�5st%=&380:�#c%=st%:rowbytes%=sx%:r$="FN8":cache%=� -�Einfo$=".PIC image, "+�sx%+" by "+�sy%+" pixels, 8 bits per pixel" -� � 700 -�$quant%=8:�#c%=0:a$=�#c%:st%=�#c% -� sx%=�a$:sy%=�(�a$,�a$," "))) .6�nopal:input=24:step24=3:rowbytes%=sx%*3:r$="FN24" .!rbo%=0:gbo%=1:bbo%=2:cache%=� .Jinfo$="MTV .pic image, "+�sx%+" by "+�sy%+" pixels, 24 bits per pixel" ." � 800 .,)sx%=512:sy%=256:�scale% ymul%=ymul%*2 .64plbuff%=�dim(sx%):rep%=0:wt%=0:wtsx%=plbuff%+sx% .@cache%=�:cachebytes%=� .J@�C%=0�255:r%(C%)=(C%�63)/63*F:�:g%()=r%():b%()=r%():quant%=6 .TJinfo$="Watford digitiser picture, 512 by 256 pixels, 6 bits per pixel" .^ � 801 .h;sx%=512:sy%=256:input=24:quant%=6:�scale% ymul%=ymul%*2 .r0rep1%=0:wt1%=0:rep2%=0:wt2%=0:rep3%=0:wt3%=0 .|=buff%=�dim(sx%*3):rb%=buff%:gb%=buff%+sx%:bb%=buff%+2*sx% .�:wtsx1%=buff%+sx%:wtsx2%=buff%+2*sx%:wtsx3%=buff%+3*sx% .�7�C%=0�255:r%(C%)=(C%�63)/63*F:�:g%()=r%():b%()=r%() .�Rinfo$="Triple Watford digitiser picture, 512 by 256 pixels, 18 bits per pixel" .� � 900 .�'quant%=8:st%=0:�#c%=0:�#c%=65536 � .�7sx%=256:sy%=256:�scale% ymul%=ymul%*2:xmul%=xmul%*2 .�� .�sx%=512:sy%=512 .�� .�S�C%=0�255:r%(C%)=C%/255*F:�:g%()=r%():b%()=r%():rowbytes%=sx%:r$="FN8":cache%=� .�?info$="AIM .raw image, 256 by 256 pixels, 8 bits per pixel" .� � 901 .�quant%=4:�#c%=65536 � /7sx%=256:sy%=256:�scale% ymul%=ymul%*2:xmul%=xmul%*2 /� /sx%=512:sy%=512 /&� /0=buff%=�dim(sx%*3):rb%=buff%:gb%=buff%+sx%:bb%=buff%+sx%*2 /:3�C%=0�255:r%(C%)=C%/255*F:�:g%()=r%():b%()=r%() /DOinput=24:info$="Hawk V9 Triple image, 256 by 256 pixels, 24 bits per pixel" /N � 902 /XBquant%=4:�#c%=8:sx%=�W:rowbytes%=sx%*3/2:sy%=�W:st%=20:�#c%=20 /b�scale% ymul%=ymul%*2 /lMplbuff%=�dim(sx%*3):rb%=plbuff%:gb%=plbuff%+sx%:bb%=plbuff%+sx%*2:rbo%=-1 /v@�C%=0�255:r%(C%)=(C%�&F)/&F*F:�:g%()=r%():b%()=r%():cache%=� /�binput=24:info$="Hawk V9/Snapshot Colour image, "+�sx%+" by "+�sy%+" pixels, 12 bits per pixel" /� � 903 /�\quant%=5:�#c%=8:sx%=�W:rowbytes%=sx%*2:sy%=�W:st%=20:�#c%=20:cache%=�:r$="FN16":flag=700 /�-� rpal%(255),gpal%(255):input=16:step24=2 /� �C%=0�255 /�"gpal%(C%)=(C%>>5)<<8 � (C%�31) /�+rpal%(C%)=((C%>>2)�31)<<16 � (C%�3)<<11 /�� /�1�C%=0�31:r%(C%)=C%/31*F:�:g%()=r%():b%()=r%() /�_input=16:info$="Hawk V9 mk II Colour image, "+�sx%+" by "+�sy%+" pixels, 16 bits per pixel" /� � 950 /�@quant%=8:�#c%=0:sx%=512:rowbytes%=512:sy%=512:st%=0:flag=900 /�E�C%=0�255:r%(C%)=C%/255*F:�:g%()=r%():b%()=r%():r$="FN8":cache%=� 0Finfo$="Wild Vision V12 image, 512 by 512 pixels, 8 bits per pixel" 0 � 1000 0Tquant%=4:sx%=640:sy%=256:�defpal:st%=�W:r$="FN"+�(1000+�W):�scale% ymul%=ymul%*2 0*%buff%=�dim(sx%):ctable%=�dim(st%) 04"ș12,4,c%,ctable%,st%:st%=�#c% 0>.pa%=ctable%:rep%=0:rep2%=0:pasx%=buff%+sx% 0HAinfo$="ProArtisan image, 640 by 256 pixels, 8 bits per pixel" 0R � 1100 0\@quant%=1:�#c%=4:sx%=�beW:sy%=�beW:input=�beW:bigendianbits=� 0fS%=�beW:S%=�beW 0pIcache%=�:�S%=2 cachebytes%=�:info$="Byte Encoded " �info$="":r$="FN8" 0zC%=�beW 0�D%=�beW 0�Ȏ C% � 0� � 1,2 0�$�I%=0�D%/3-1:r%(I%)=�#c%/255*F:� 0�$�I%=0�D%/3-1:g%(I%)=�#c%/255*F:� 0�$�I%=0�D%/3-1:b%(I%)=�#c%/255*F:� 0� 0�Ȏ input � 0�� 1:r%(0)=F:g%(0)=F:b%(0)=F 0�� 4,8:�nopal 0�� 24:�nopal 0�� 0�� 1Ȏ input � 1 � 1:rowbytes%=(sx%+15>>4)<<1 1� 4:rowbytes%=(sx%+3>>2)<<1 1$� 8:rowbytes%=(sx%+1>>1)<<1 1.J� 24:rowbytes%=(3*sx%+1>>1)<<1:r$="FN24":rbo%=0:gbo%=1:bbo%=2:step24=3 18�S%=1 bbo%=0:rbo%=2 1B&:� 42,"Can't do this Sun pixrect" 1L� 1VMst%=D%+&20:rep%=0:�cachebytes% plbuff%=�dim(rowbytes%):plbytes%=rowbytes% 1`Binfo$+="Sun image, "+�sx%+" by "+�sy%+" pixels, "+�bits(input) 1j � 1200 1t>quant%=8:sx%=800:sy%=800:st%=1600:�#c%=st%:vflip%=� vflip% 1~*�nopal:r$="FN8":rowbytes%=sx%:cache%=� 1�Iinfo$="TimeStep satellite image, 800 by 800 pixels, 8 bits per pixel" 1� � 1300 1�?quant%=8:sx%=128:sy%=256:st%=0:�#c%=0:�scale% xmul%=xmul%*2 1�*�nopal:r$="FN8":rowbytes%=sx%:cache%=� 1�@info$="satellite image, 128 by 256 pixels, 8 bits per pixel" 1� � 1301 1�;input=24:quant%=8:sx%=128:sy%=256:�scale% xmul%=xmul%*2 1�Obuff%=�dim(sx%*3):rb%=buff%:gb%=buff%+sx%:bb%=buff%+2*sx%:�nopal:r$="FN901" 1�Hinfo$="Triple satellite image, 128 by 256 pixels, 24 bits per pixel" 1� � 1400 1�%planar%=�:�#c%=0:Z%=�HW:�Z%>255 � 1�+st%=�beHW*2:planes%=�beHW:patlen%=�beHW 2 +pw%=�beHW:ph%=�beHW:sx%=�beHW:sy%=�beHW 2 � 2Cst%=�HW*2:input=�HW:patlen%=�HW:pw%=�HW:ph%=�HW:sx%=�HW:sy%=�HW 2� 2( �scale% � 22#xmul%=xmul%*pw%:xdiv%=xdiv%*282 2<#ymul%=ymul%*ph%:ydiv%=ydiv%*282 2F� 2PWrowbytes%=sx%+7>>3:pbuff%=�dim(sx%):plbytes%=rowbytes%*planes%:buff%=�dim(plbytes%) 2Z�#c%=st%:vrep%=0 2dM�C%=0�(1<<planes%)-1:r%(C%)=F-C%/((1<<planes%)-1)*F:�:g%()=r%():b%()=r%() 2nBinfo$="IMG file, "+�sx%+" by "+�sy%+" pixels, "+�bits(planes%) 2x � 1500 2�"�#c%=4:dir%=�tiff(4):�#c%=dir% 2�6rgb=�:greyunit=100:planar%=1:fillorder=1:resunit=2 2�)xnum%=90:xdenom%=1:ynum%=90:ydenom%=1 2�E%=�tiff(3):�Z%=1�E% 2�'T%=�tiff(3):D%=�tiff(3):C%=�tiff(4) 2�a�C%>1 V%=�tiff(4) ��D%=2 �#c%=dir%+2+Z%*12 ��D%<4 V%=�tiff(D%):�#c%=dir%+2+Z%*12 �V%=�tiff(4) 2�?�"Read tag ";T%" datatype "D%" count "C%" value/pointer "V% 2�Ȏ T% � 2�� 256:sx%=V% 2�� 257:sy%=V% 2�� 258:�C%>1 � 2��D%*C%>6 � 2��#c%=V%:quant%=�tiff(D%) 3(input=quant%:�I%=1�C%-1:V%=�tiff(D%) 3P�V%<>quant% �42,"Can't do RGB TIFF with different numbers of bits per pixel" 3 input+=V% 3"�:�nopal 3,� 36 quant%=V% � &FF:input=quant% 3@5�I%=0�(1<<quant%)-1:r%(I%)=I%/((1<<quant%)-1)*F:� 3Jg%()=r%():b%()=r%() 3T� 3^�#c%=dir%+2+Z%*12 3h� 3rquant%=V%:input=quant% 3|5�I%=0�(1<<quant%)-1:r%(I%)=I%/((1<<quant%)-1)*F:� 3�g%()=r%():b%()=r%() 3�� 3�� 259:compression=V% 3�/� 262:photometric=V%:�V%=0 invert%=�invert% 3�� 266:fillorder=V% 3�!� 273:stc%=C%:stv%=V%:std%=D% 3�1� 277:sampperpix%=V%:input=quant%*V%:rgb=V%=3 3�� 278:striprows%=V% 3�-� 279:stcbyte%=C%:stvbyte%=V%:stdbyte%=D% 3�1� 282:�#c%=V%:xnum%=�tiff(4):xdenom%=�tiff(4) 3��#c%=dir%+2+Z%*12 3�1� 283:�#c%=V%:ynum%=�tiff(4):ydenom%=�tiff(4) 3��#c%=dir%+2+Z%*12 4,� 284:planar%=V%:�planar%=2 input=quant% 4� 290:greyunit=10^V% 4<� 291:�#c%=V%:�I%=0�C%-1:r%(I%)=�tiff(D%)/greyunit/2*F:� 4&g%()=r%():b%()=r%() 40�#c%=dir%+2+Z%*12 4:� 296:resunit=V% 4D� 317:hpredict%=V% 4N8� 320:�#c%=V%:�I%=0�C%/3-1:r%(I%)=�tiff(3)/65535*F:� 4X*�I%=0�C%/3-1:g%(I%)=�tiff(3)/65535*F:� 4b*�I%=0�C%/3-1:b%(I%)=�tiff(3)/65535*F:� 4l�#c%=dir%+2+Z%*12 4v 4�J�info% �"Ignoring tag ";T%" datatype "D%" count "C%" value/pointer "V% 4�� 4�� 4�� st%(stc%):�stc%>1 � 4�0�#c%=stv%:�I%=0�stc%-1:st%(I%)=�tiff(std%):� 4�� 4�st%(0)=stv% 4�� 4�Ȏ compression � 4�� 0,1:info$="" 4�)� 2:info$="CCITT Group 3 compressed " 4�+� 5:info$="LZW compressed ":r$="FN1505" 5n�hpredict%=2 �info$+="horizontal differenced " ��hpredict%>2 info$+=" unknown predictor ("+�hpredict%+") " 5'setcodes%=8:clearcode%=1<<setcodes% 53� table%(1<<12):stk%=�dim(1<<13):buf%=�dim(280) 5 &�I%=0�clearcode%-1:table%(I%)=I%:� 5*4� 32773:info$="PackBits compressed ":r$="FN1501" 54 � 6:info$="JPEG compressed " 5>2 info$="Compress "+�compression+" - unknown " 5H� 5RBinfo$+="TIFF file, "+�sx%+" by "+�sy%+" pixels, "+�bits(input) 5\Sbigendianbits=fillorder=1:�#c%=st%(0):stripptr=0:�striprows%>=sy% striprows%=-1 5fȎ input � 5p� 1:rowbytes%=sx%+7>>3 5z� 2:rowbytes%=sx%+3>>2 5�� 4:rowbytes%=sx%+1>>1 5�� 8:rowbytes%=sx% 5�� 24:rowbytes%=3*sx% 5�H� 32:rowbytes%=4*sx%:�photometric<>5 � 42,"32 bpp TIFF but not CMYK" 5�+ � 42,"Can't do "+�bits(input)+" TIFF" 5�� 5�.�planar%=2 rowbytes%=rowbytes%*sampperpix% 5�I�planar%<>1 � rgb<>0 �42,"Can't do this style of TIFF yet" �planar%=� 5�� compression<2 � 5�Scache%=�:stripptr=-1:r$="FN8":�input=24 rbo%=0:gbo%=1:bbo%=2:step24=3:r$="FN24" 5�b�input=32 rbo%=0:gbo%=1:bbo%=2:step24=4:r$="FN24":r%()=F-r%():g%()=F-g%():b%()=F-b%():input=24 5�� 5�'�compression=5 �compression=32773 � 6-cache%=�:cachebytes%=rowbytes%*striprows% 60plbuff%=�dim(rowbytes%):rowstogo%=striprows% 6\�input=24 rb%=plbuff%:gb%=plbuff%+1:bb%=plbuff%+2:r$="FN"+�(��r$,3)+10):step24=3:rbo%=-1 6$� 6..buff%=�dim(rowbytes%):rowstogo%=striprows% 68N�input=24 rb%=buff%:gb%=buff%+1:bb%=buff%+2:r$="FN"+�(��r$,3)+10):step24=3 6B� 6L� 6V �scale% � 6`S%=resunit:�S%=2 S%=90 6j�S%=3 S%=35 6t,xdiv%=xdiv%*xnum%:xmul%=xmul%*xdenom%*S% 6~,ydiv%=ydiv%*ynum%:ymul%=ymul%*ydenom%*S% 6�� 6��r$="FN1500" r$="FN8" 6� � 1600 6��#c%=12:camg=0:planar%=�:� 6�&S$=��#c%+��#c%+��#c%+��#c%:S%=�beW 6�Ȏ S$ � 6�C� "BMHD":sx%=�beHW:sy%=�beHW:S%=�W:planes%=�#c%:masking%=�#c%=1 6�6compression=�#c%:S%=�#c%+�HW:U%=�#c%:V%=�#c%:S%=�W 6�)�scale% ymul%=ymul%*V%:ydiv%=ydiv%*U% 6�K�I%=0�(1<<planes%)-1:r%(I%)=I%/((1<<planes%)-1)*F:�:g%()=r%():b%()=r%() 6�B� "CMAP":S%=�#c%+S%:�I%=0�(1<<planes%)-1:r%(I%)=(�#c%>>4)/15*F 6�1g%(I%)=(�#c%>>4)/15*F:b%(I%)=(�#c%>>4)/15*F:� 7 G�#c%=S%:�info% �"Warning: truncated IFF CMAP information to 4 bits" 7 ;� "CAMG":camg=�beW:�info% �"Amiga viewport mode ";~camg 7� "BODY":st%=�#c% 74 � info% �"Ignoring IFF property "S$" size ";S% 7(�#c%=�#c%+S% 72� 7<9�S$="BODY":�compression info$="Compressed " �info$="" 7P+ham=(camg � &800)<>0:�ham info$+="HAM " 7Z4half=(camg � &80)<>0:�half info$+="half-bright " 7dn�half half%=1<<planes%-1:�I%=0�half%-1:r%(I%+half%)=r%(I%)/2:g%(I%+half%)=g%(I%)/2:b%(I%+half%)=b%(I%)/2:� 7nCinfo$+="IFF file, "+�sx%+" by "+�sy%+" pixels, "+�bits(planes%) 7x+�masking% info$+=" with mask (ignored)" 7�7rowbytes%=(sx%+15>>4)<<1:plbytes%=rowbytes%*planes% 7�9pbuff%=�dim(sx%):r$="FN"+�(1600+compression):cache%=� 7��compression � 7�(cachebytes%=�:plbuff%=�dim(plbytes%) 7�� 7�Qrealrowbytes%=rowbytes%:rowbytes%=plbytes%:�masking% rowbytes%+=realrowbytes% 7�� 7��#c%=st% 7� � 1700 7�Bsx%=640:rowbytes%=80:sy%=350:planes%=4:plbytes%=4*80:planar%=� 7�3buff%=�dim(80*4):pbuff%=�dim(640):G=F/3:H=F*2/3 7�(r%()=0,0,0,0,F,F,F,H,G,G,G,G,F,F,F,F 7�(g%()=0,0,F,F,0,0,F,H,G,G,F,F,G,G,F,F 8(b%()=0,F,0,F,0,F,0,H,G,F,G,F,G,F,G,F 8Vmasking%=�:r$="FN1600":st%=16:�#c%=16:cache%=�:realrowbytes%=80:rowbytes%=plbytes% 8Sinfo$="PC EGA '.dsp' file, 640 by 350 pixels, 4 bits per pixel (fixed palette)" 8" � 1800 8,?sx%=72*8:sy%=720:quant%=1:input=1:�#c%=st%:plbuff%=�dim(72) 86cache%=�:cachebytes%=� 8@Qr%(0)=F:g%(0)=F:b%(0)=F:bigendianbits=�:rowbytes%=72:r$="FN1501":rowstogo%=-1 8JG�scale% xmul%=xmul%*90:xdiv%=xdiv%*72:ymul%=ymul%*90:ydiv%=ydiv%*72 8T>info$="MacPaint file, 576 by 720 bits, creator id "+�S$,4) 8^ � 1850 8h�#c%=552 8rdone%=� 8|� 8�code%=�beHW:Ȏ code% � 8�� &01:�#c%=�#c%+�beHW 8� � &1E 8� � &98 8�Crowbytes%=�beHW:�(rowbytes% �&8000)=0 �42,"PICT without Pixmap" 8�3sy%=�beHW:sx%=�beHW:sy%=�beHW-sy%:sx%=�beHW-sx% 8�<junk%=�HW:packtype%=�beHW:junk%=�W:resx%=�beW:resy%=�beW 8�F�beHW<>0 �#c%:�42,"ChangeFSI expected Mac PICT2 pixeltype=Chunky" 8�&bpp%=�beHW:junk%=�beHW:junk%=�beHW 8�$junk%=�beW:junk%=�beW:junk%=�beW 8�junk%=�beW:junk%=�beHW 8�_C%=�beHW:�I%=0�C%:J%=�beHW:r%(J%)=�beHW/65535*F:g%(J%)=�beHW/65535*F:b%(J%)=�beHW/65535*F:� 8�done%=� 9R� &9A:junk%=�W:rowbytes%=�beHW:�(rowbytes% �&8000)=0 �42,"PICT without Pixmap" 93sy%=�beHW:sx%=�beHW:sy%=�beHW-sy%:sx%=�beHW-sx% 9<junk%=�HW:packtype%=�beHW:junk%=�W:resx%=�beW:resy%=�beW 9&J�beHW<>16 �#c%:�42,"ChangeFSI expected Mac PICT2 pixeltype=RGBDirect" 90'bpp%=�beHW:comps%=�beHW:junk%=�beHW 9:junk%=�beW:junk%=�beW 9Djunk%=�beHW:junk%=�beHW 9NV�bpp%>16 �nopal �J%=2^(bpp%�3):�I%=0�J%-1:r%(I%)=I%/(J%-1)*F:�:g%()=r%():b%()=r%() 9X/�bpp%=32 � comps%=3 bpp%=24:rowbytes%=3*sx% 9bdone%=� 9lC:�#c%:�42,"ChangeFSI can't understand Mac PICT2 code "+�~code% 9v� 9�� done% 9�3junk%=�beHW:junk%=�beHW:junk%=�beHW:junk%=�beHW 9�3junk%=�beHW:junk%=�beHW:junk%=�beHW:junk%=�beHW 9�junk%=�beHW 9�Ncache%=�:cachebytes%=�:bigendianbits=�:st%=�#c%:rowbytes%=rowbytes%��&8000 9�Y�scale% xmul%=xmul%*90*65536:xdiv%=xdiv%*resx%:ymul%=ymul%*90*65536:ydiv%=ydiv%*resy% 9�@info$="Mac PICT2, "+�sx%+" by "+�sy%+" pixels, "+�bits(bpp%) 9�%plbuff%=�dim(rowbytes%):�bpp%>8 � 9�Trbo%=-1:rb%=plbuff%+sx%:gb%=plbuff%+sx%*2:bb%=plbuff%+sx%*3:r$="FN1851":input=24 9�;�comps%=3 rb%=plbuff%:gb%=plbuff%+sx%:bb%=plbuff%+sx%*2 9�� 9� � 1900 9��#c%=1:C%=�#c% :?E%=�#c%:�E%<>1 � 42,"ZSoft .PCX file with unknown encoding" :7E%=�#c%:sx%=�HW:sy%=�HW:sx%=�HW+1-sx%:sy%=�HW+1-sy% :N�scale% xmul%=xmul%*90:xdiv%=xdiv%*�HW:ymul%=ymul%*90:ydiv%=ydiv%*�HW ��W : H�#c%=65:planes%=�#c%:planar%=planes%>1:rowbytes%=�HW:bpp%=E%*planes% :*pcxpal=16:�bpp%>4 � C%=5 � :4*�#c%=�#c%-769:�#c%=12 pcxpal=�#c%-768 :>� :H5�#c%=pcxpal:E%=0:�C%=0�(1<<bpp%)*3-1:E%=E%��#c%:� :R3�info% �".PCX palette mask established at ";~E% :\�E%=0 � :fE�C%=0�(1<<bpp%)-1:r%(C%)=C%/((1<<bpp%)-1)*F:�:g%()=r%():b%()=r%() :p� :z!�#c%=pcxpal:�C%=0�(1<<bpp%)-1 :�Er%(C%)=(�#c%�E%)/E%*F:g%(C%)=(�#c%�E%)/E%*F:b%(C%)=(�#c%�E%)/E%*F :�� :�� :��rewind :�Lplbytes%=rowbytes%*planes%:plbuff%=�dim(plbytes%):cache%=�:cachebytes%=� :�E�planar% pbuff%=�dim(sx%) �input=bpp%:bigendianbits=�:r$="FN1100" :�Finfo$="ZSoft .PCX file, "+�sx%+" by "+�sy%+" pixels, "+�bits(bpp%) :� � 2000 :�8�#c%=0:L%=�#c%:C%=�#c%:I%=�#c%:J%=�HW:K%=�HW:M%=�#c% :�Csx%=�W:sx%=�HW:sy%=�HW:B%=�#c%:ID%=�#c%:�ID%�&10 hflip%=�hflip% :� �(ID% �&20)=0 vflip%=�vflip% :��#c%=�#c%+L%:Ȏ C% � :�� 1:�M%=&18 � ;�C%=J%�K%-1 ;9b%(C%)=�#c%/255*F:g%(C%)=�#c%/255*F:r%(C%)=�#c%/255*F ;� ;$� ;.� ;8 �nopal ;B� ;Lst%=�#c% ;VȎ I% � ;`� 1,2,3:cache%=�:�B%>8 � ;j�B%>16 � ;tLinput=24:bbo%=0:gbo%=1:rbo%=2:step24=B%�8:r$="FN24":rowbytes%=step24*sx% ;~� ;�rowbytes%=sx%*2 ;�7� rpal%(255),gpal%(255):input=16:step24=2:r$="FN16" ;� �C%=0�255 ;�&gpal%(C%)=(C%>>5)<<8 � (C%�31)<<16 ;�%rpal%(C%)=(C%>>2)�31 � (C%�3)<<11 ;�� ;�1�C%=0�31:r%(C%)=C%/31*F:�:g%()=r%():b%()=r%() ;�� ;�� ;�r$="FN8":rowbytes%=sx% ;�� ;�Iinfo$="Truevision TGA image, "+�sx%+" by "+�sy%+" pixels, "+�bits(B%) <