Home » Archimedes archive » Micro User » MU 1990-11.adf » PD-Stuff » Graphics/!MakeTIFF/!RunImage

Graphics/!MakeTIFF/!RunImage

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 » Archimedes archive » Micro User » MU 1990-11.adf » PD-Stuff
Filename: Graphics/!MakeTIFF/!RunImage
Read OK:
File size: 4407 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM >!RunImage
   20REMLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOG
   30REM Creates TIFF file from sprite or Clear file                (RISCWARE)
   40REM Version date : Thu,21 Jun 1990.20:13:08
   50REM LEN 1990 Zeridajh software
   60REM by John Kortink
   70REMLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOG
   80ON ERROR PRINT'"Error"''"'";REPORT$;"' (code ";ERL;")"'':END
   90DIM menu 2048,window1 2048,window2 2048
  100DIM icondata 2048,icondend 0,poll 256,block 256,err 256
  110DIM Code% 2048,RowBf% 8192,RevMap% 256
  120DIM dum% 256,Palette%(256)
  130Headsize%=4096:DIM Head% Headsize%:REM Buffer for file header
  140Progneed%=60*1024:REM Memory needed for program+vars, without buffers
  150Total%=HIMEM-PAGE:REM Total memory free
  160Buffree%=Total%-Progneed%:REM Free for file buffers
  170IFBuffree%<20*1024 THEN ERROR 1,"MakeTIFF cannot startup properly"
  180halve%=(Buffree%DIV2)ANDNOT3:REM Aligned half size
  190Outputsize%=halve%:DIM Output% Outputsize%:REM Output file buffer
  200Inputsize%=halve%:DIM Input% Inputsize%:REM Input file buffer
  210PROCinitialise:REM Initialise application
  220ON ERROR PROCerror(ERR,REPORT$+" (code "+STR$ERL+")")
  230REPEAT REM Poll and action
  240CASE FNpoll(0) OF
  250 WHEN 0 : PROCnull:REM Nothing to do, perform checks
  260 WHEN 1 : PROCredraw:REM Redraw window request
  270 WHEN 2 : PROCopen:REM Open window request
  280 WHEN 3 : PROCclose:REM Close window request
  290 WHEN 6 : PROCmouseclick:REM Mouse clicked
  300 WHEN 7 : PROCdragdrop:REM User has dropped drag box of file window
  310 WHEN 8 : PROCkey:REM Key pressed
  320 WHEN 9 : PROCmenuselect:REM Menu selection from user
  330 WHEN 17,18 : PROCmessage:REM Message from WIMP
  340ENDCASE
  350UNTIL FALSE
  360 
  370DEFPROCmenuselect
  380selected%=poll!0:REM What selection ?
  390IFselected%=1 THEN PROCdie:REM Quit icon, tidy up and exit
  400ENDPROC
  410
  420DEFPROCclose
  430PROCclose_window(poll!0):REM Close window
  440ENDPROC
  450
  460DEFPROCopen
  470PROCopen_window(0,poll):REM Open window
  480ENDPROC
  490
  500DEFPROCnull
  510IFDataLoadRef% THEN
  520 DataLoadRef%=FALSE:SYS "OS_File",6,Output$:REM Delete file saved
  530 PROCerror(-1,"Bad data transfer, receiver dead"):REM No DataLoadAck
  540ENDIF
  550ENDPROC
  560
  570DEFPROCkey
  580win%=poll!0:ico%=poll!4:char%=poll!24:REM Window, icon, key pressed
  590IF(win%=win_file%) AND (ico%=1) THEN
  600 CASE char% OF
  610  WHEN 13 : REM Return pressed
  620   PROCerror(-1,"Please drag the file icon to a directory viewer")
  630  WHEN 27 : REM Escape pressed
  640   PROCclose_window(win_file%)
  650 ENDCASE
  660ENDIF
  670ENDPROC
  680
  690DEFPROCmessage
  700REM Ignore messages originating from myself
  710IF(poll!4)=TaskHandle% THEN msgnr%=-1 ELSE msgnr%=poll!16
  720CASE msgnr% OF
  730 WHEN -1 : REM Don't react
  740 WHEN 0 : PROCdie:REM Request to terminate task
  750 WHEN 1 : REM DataSave, transfer via scrap file
  760  scrap$=FNOSvar("Wimp$Scrap"):REM Read scrap filename
  770  IFscrap$<>"" THEN poll!12=poll!8:poll!16=2:poll!36=-1:$(poll+44)=scrap$+CHR$0:poll!0=44+(LENscrap$+1+3)ANDNOT3:SYS WSendMsg%,18,poll,poll!4 ELSE PROCerror(-1,"Wimp$Scrap not defined"):REM Send DataSaveAck if scrap file defined
  780 WHEN 2 : REM DataSaveAck, save file
  790  Output$=FNstring(poll+44):REM Read path-name of TIFF file to create
  800  PROChour_on:REM Hourglass on
  810  PROCmake_TIFF(type%,Input$,Output$,error$):REM Create TIFF file
  820  PROChour_off:REM Hourglass off
  830  IFerror$<>"" THEN
  840   PROCerror(-1,error$):REM Report error
  850   SYS "OS_File",6,Output$:REM Kill outputfile
  860  ENDIF
  870  poll!12=poll!8:poll!16=3:REM Amend data block for DataLoad
  880  SYS WSendMsg%,18,poll,poll!4:REM Send DataLoad
  890  DataLoadRef%=poll!8:REM Await a DataLoadAck, remember myref
  900 WHEN 3 : REM DataLoad, check if sprite or Clear file
  910  type%=poll!40:REM Filetype
  920  IFtype%=&FF9 OR type%=&690 THEN
  930   REM Sprite or Clear file, prepare to make TIFF file
  940   Input$=FNstring(poll+44):REM Filename
  950   PROCopen_window(win_file%,0):REM Open save file window
  960   poll!12=poll!8:poll!16=4:SYS WSendMsg%,17,poll,poll!4:REM DataLoadAck
  970  ENDIF
  980 WHEN 4 : REM DataLoadAck, check or ignore
  990  IFDataLoadRef% THEN IFpoll!12=DataLoadRef% THEN DataLoadRef%=FALSE
 1000ENDCASE
 1010ENDPROC
 1020
 1030DEFPROCmouseclick
 1040but%=poll!8:win%=poll!12:ico%=poll!16:REM Buttons/window/icon
 1050CASE win% OF
 1060 WHEN -2 : REM Click on iconbar
 1070  IFico%=Iiconbar% THEN IF(but%AND7)=2 THEN PROCiconbar_menu
 1080 WHEN win_file% : REM Click on save file window
 1090  IFico%=0 THEN
 1100   CASE but% AND &7F OF
 1110    WHEN 16,64 : REM Drag,calculate drag box and create it
 1120     ScrW%=FNmode_var(MODE,11)<<FNmode_var(MODE,4):ScrH%=FNmode_var(MODE,12)<<FNmode_var(MODE,5):REM Screen width and height in OS-units
 1130     !block=win%:SYS WGetWS%,,block:x%=block!4:y%=block!8:block!4=ico%:SYS WGetIS%,,block:!block=win%:block!4=5:block!8+=x%:block!12+=y%:block!16=block!8+68:block!20=block!12+68:block!24=0:block!28=0:block!32=ScrW%:block!36=ScrH%
 1140     SYS WDragB%,,block:REM Create drag box
 1150   ENDCASE
 1160  ENDIF
 1170ENDCASE
 1180ENDPROC
 1190
 1200DEFPROCdragdrop
 1210SYS WGetPI%,,block:REM Get pointer position
 1220dropwin%=block!12:dropico%=block!16:REM Window/icon where box dropped
 1230filename$=FNstring(SAVfn%):REM Filename for save
 1240block!20=block!12:block!24=block!16:block!28=block!0:block!32=block!4:block!12=0:block!16=1:block!36=0:block!40=&FF9:$(block+44)=filename$+CHR$0:!block=(44+LENfilename$+4)ANDNOT3
 1250SYS WSendMsg%,17,block,dropwin%,dropico%:REM Send DataSave
 1260DataSaveRef%=block!8:REM Remember myref for DataSave
 1270PROCclose_window(win_file%):REM Close save file window
 1280ENDPROC
 1290 
 1300DEFPROCmake_TIFF(type%,InFile$,OutFile$,RETURN error$)
 1310REM Creates TIFF file OutFile$ from :
 1320REM (type%=&FF9) first sprite in sprite file
 1330REM (type%=&690) image in Clear file
 1340REM Returns error in error$ if error occured, else ""
 1350LOCAL ERROR
 1360ON ERROR LOCAL:error$=REPORT$+" (code "+STR$ERL+")":PROCclosef:ENDPROC
 1370error$="":In=0:Out=0:REM No errors (yet), files both closed
 1380In=OPENIN(InFile$):REM Open input file
 1390CASE type% OF
 1400 WHEN &FF9 : REM Sprite file
 1410  SYS "OS_GBPB",4,In,Head%+4,Headsize%:REM Read sprite file header
 1420  spr%=Head%+Head%!8:REM Start of first sprite
 1430  sprname$="":ptr%=spr%+4:WHILE (?ptr%<>0) AND (LENsprname$<12):sprname$+=CHR$(?ptr%):ptr%+=1:ENDWHILE:REM Sprite's name
 1440  wordw%=spr%!16+1:height%=spr%!20+1:REM Width in words, height in rows
 1450  firstb%=spr%!24:lastb%=spr%!28:REM First/last bit used in border words
 1460  image%=spr%+spr%!32:REM Pointer to image data
 1470  mode%=spr%!40:palette%=spr%+44:REM Sprite's mode, pointer to palette
 1480  colbits%=2^FNmode_var(mode%,9):REM Bits per pixel
 1490  colours%=2^colbits%:REM Number of colours
 1500  width%=(wordw%*32-(31-lastb%)-firstb%) DIV colbits%:REM Width in pixels
 1510  IFimage%<=palette% THEN
 1520   REM Sprite has no palette : use default palette
 1530   CASE colours% OF
 1540    WHEN 256 : FOR c%=0 TO 255:r%=((c%AND%00010000)>>1)+(c%AND%00000100)+(c%AND%11):g%=((c%AND%01100000)>>3)+(c%AND%11):b%=((c%AND%10000000)>>4)+((c%AND%00001000)>>1)+(c%AND%11):Palette%(c%)=(r%<<20)+(g%<<12)+(b%<<4):NEXT
 1550    WHEN 16 : Palette%()=0,&F00000,&F000,&F0F000,&F0,&F000F0,&F0F0,&F0F0F0,0,&F00000,&F000,&F0F000,&F0,&F000F0,&F0F0,&F0F0F0
 1560    WHEN 4 : Palette%()=0,&F00000,&F0F000,&F0F0F0
 1570    WHEN 2 : Palette%()=0,&F0F0F0
 1580   ENDCASE
 1590  ELSE REM Read sprite's own palette
 1600   IFcolours%<=16 THEN
 1610    REM All palette entries present
 1620    FOR c%=0 TO colours%-1:Palette%(c%)=FNpaltorgb(palette%!(c%*8)):NEXT
 1630   ELSE REM Only 64 palette entries present, deduce all from first 16
 1640    FOR c%=0 TO 15:Palette%(c%)=FNpaltorgb(palette%!(c%*8)):NEXT:FOR c%=16 TO 255:Palette%(c%)=Palette%(c%AND15)+(c%AND&80)+((c%AND&60)<<9)+((c%AND&10)<<19):NEXT
 1650   ENDIF
 1660  ENDIF
 1670  xeig%=FNmode_var(mode%,4):yeig%=FNmode_var(mode%,5):REM X/Yeig factors
 1680  resdivx%=2^xeig%:resdivy%=2^yeig%:REM Divisors for X/YResolution
 1690  ResolutionFacs=TRUE:REM Factors supplied
 1700  rowbytes%=wordw%*4:REM Bytes per row
 1710  dataptr%=image%-Head%-4:REM Offset to image data
 1720 WHEN &690 : REM Clear file
 1730  SYS "OS_GBPB",4,In,Head%,Headsize%:REM Read Clear file header
 1740  ptr%=Head%:maker$="":WHILE ?ptr%>=ASC" ":maker$+=CHR$(?ptr%):ptr%+=1:ENDWHILE:version%=ptr%!1:ptr%+=5:REM Maker and version
 1750  IFmaker$="Translator" THEN IFversion%=600 ELSE error$="I cannot handle this Clear file from '"+maker$+"' version "+STR$(version%DIV100)+"."+RIGHT$("0"+STR$(version%MOD100),2)+" !!!":ENDPROC
 1760  width%=!ptr%:height%=ptr%!4:colbits%=ptr%!8:ptr%+=12:REM Resolution
 1770  IFcolbits%>8 THEN error$="I cannot handle pure RGB Clear files.":ENDPROC
 1780  colours%=2^colbits%:REM Colours in image
 1790  FOR c%=0 TO colours%-1:Palette%(c%)=((?ptr%)<<16)+((ptr%?1)<<8)+ptr%?2:ptr%+=3:NEXT:REM Read palette
 1800  ResolutionFacs=FALSE:REM Factors unknown
 1810  dataptr%=ptr%-Head%:REM Offset to image data
 1820  rowbytes%=width%:REM Bytes per row
 1830ENDCASE
 1840bytew%=(width%*colbits%+7)DIV8:REM Bytes per row
 1850rowsperstrip%=8192 DIV bytew%:REM Make strips about 8K in size
 1860IFrowsperstrip%>height% THEN rowsperstrip%=height%:REM Height is maximum
 1870strips%=(height%+rowsperstrip%-1) DIV rowsperstrip%:REM Number of strips
 1880striplen%=rowsperstrip%*bytew%:REM Strip length
 1890PTR#In=dataptr%:REM To start of image data
 1900Out=OPENOUT(OutFile$):REM Open output TIFF file
 1910PROCouts("II"):REM Low-to-high byte order TIFF file
 1920PROCoutd(42):REM TIFF version number
 1930PROCoutw(8):REM Offset to Image File Directory (IFD)
 1940IFResolutionFacs THEN entries%=13 ELSE entries%=10:REM IFD entries
 1950PROCoutd(entries%):REM Number of IFD entries
 1960iptr%=12*entries%+4+PTR#Out:REM Initialise info block pointer
 1970PROCoutIFD(256,4,1,width%):REM Image width in pixels
 1980PROCoutIFD(257,4,1,height%):REM Image height in pixels
 1990PROCoutIFD(258,3,1,colbits%):REM Bits per sample
 2000PROCoutIFD(259,3,1,1):REM Compression (none at present)
 2010PROCoutIFD(262,3,1,3):REM Photometric interpretation (Palette colour)
 2020PROCoutIFD(266,3,1,1):REM Fillorder (high bits first, it's 'recommended'!)
 2030PROCoutIFD(273,4,strips%,-1):REM Strip offsets
 2040PROCoutIFD(277,3,1,1):REM Samples per pixel
 2050PROCoutIFD(278,4,1,rowsperstrip%):REM Rows per strip
 2060REM X resolution, Y resolution, resolution unit (inch)
 2070IFResolutionFacs THEN PROCoutIFD(282,5,1,-1):PROCoutIFD(283,5,1,-1):PROCoutIFD(296,3,1,2)
 2080PROCoutIFD(320,3,3*colours%,-1):REM Colour map
 2090PROCoutw(0):REM No next IFD
 2100REM Arrived at info blocks, write data
 2110FOR s%=1 TO strips%:PROCoutw(FNiptr(striplen%)):NEXT:REM Strip offsets
 2120IFResolutionFacs THEN PROCoutw(180):PROCoutw(resdivx%):PROCoutw(180):PROCoutw(resdivy%):REM 180 OS units per inch
 2130FOR rgb%=16 TO 0 STEP -8:FOR c%=0 TO colours%-1:v%=(Palette%(c%)>>>rgb%)AND&FF:PROCoutd(v%<<8):NEXT:NEXT:REM Output colour map
 2140!bits=colbits%:!type=type%:REM Machinecode info
 2150IFtype%=&FF9 THEN !left=firstb%:!words=wordw%:CALL make_map ELSE !width=width%:REM More specific machinecode info
 2160FOR r%=1 TO height%
 2170SYS "OS_GBPB",4,In,RowBf%,rowbytes%:REM Read row
 2180CALL convert:REM Convert row data for TIFF
 2190SYS "OS_GBPB",2,Out,RowBf%,bytew%:REM Write row
 2200NEXT
 2210CLOSE#In:REM Close input file
 2220CLOSE#Out:REM Close TIFF file
 2230SYS "OS_CLI","SetType "+OutFile$+" FF0":REM Filetype as TIFF file
 2240ENDPROC
 2250 
 2260DEFPROCclosef
 2270REM Closes files on error
 2280IFIn>0 THEN CLOSE#In
 2290IFOut>0 THEN CLOSE#Out
 2300ENDPROC
 2310 
 2320DEFFNiptr(room%)
 2330REM Returns file pointer to block of room% bytes
 2340iptr%+=room%:=iptr%-room%
 2350 
 2360DEFPROCoutIFD(tag%,type%,length%,value%)
 2370REM Outputs IFD entry to outfile
 2380LOCAL bytes%
 2390bytes%=VAL(MID$("11248",type%,1)):REM Bytes per type
 2400IFvalue%=-1 THEN value%=FNiptr(bytes%*length%):REM Pointer to block
 2410PROCoutd(tag%):REM Tag
 2420PROCoutd(type%):REM Field type
 2430PROCoutw(length%):REM Field count
 2440PROCoutw(value%):REM Value (offset or value)
 2450ENDPROC
 2460 
 2470DEFPROCouts(out$)
 2480REM Outputs string to outfile
 2490LOCAL c%
 2500FOR c%=1 TO LENout$:BPUT#Out,ASCMID$(out$,c%):NEXT
 2510ENDPROC
 2520 
 2530DEFPROCoutw(out%)
 2540REM Outputs word to outfile
 2550BPUT#Out,out%:BPUT#Out,out%>>>8:BPUT#Out,out%>>>16:BPUT#Out,out%>>>24
 2560ENDPROC
 2570 
 2580DEFPROCoutd(out%)
 2590REM Outputs double-byte to outfile
 2600BPUT#Out,out%:BPUT#Out,out%>>8
 2610ENDPROC
 2620 
 2630DEFPROCoutb(out%)
 2640REM Outputs byte to outfile
 2650BPUT#Out,out%
 2660ENDPROC
 2670 
 2680DEFFNmode_var(mode%,var%)
 2690REM Returns mode variable
 2700LOCAL val%
 2710SYS "OS_ReadModeVariable",mode%,var% TO ,,val%
 2720=val%
 2730 
 2740DEFFNstring(addr%)
 2750REM Returns CTRL-char terminated string at addr%
 2760LOCAL _%,_c%,_$
 2770_%=-1:REPEAT _%+=1:UNTIL addr%?_%<32
 2780_c%=addr%?_%:addr%?_%=13:_$=$addr%:addr%?_%=_c%
 2790=_$
 2800 
 2810DEFPROCmouse(RETURN x%,RETURN y%,RETURN but%)
 2820REM Returns x,y and button state of mouse
 2830MOUSE x%,y%,but%
 2840ENDPROC
 2850 
 2860DEFPROChour_on
 2870REM Turns hourglass on after 1 sec
 2880SYS "Hourglass_On"
 2890ENDPROC
 2900 
 2910DEFPROChour_off
 2920REM Turns hourglass off
 2930SYS "Hourglass_Off"
 2940ENDPROC
 2950 
 2960DEFFNOSvar(name$)
 2970REM Attempts to return OS-var's string value
 2980LOCAL _r$,_l%
 2990_r$=STRING$(100," "):SYS "XOS_ReadVarVal",name$,_r$,LEN_r$,0,3 TO ,_r$,_l%
 3000=LEFT$(_r$,_l%)
 3010 
 3020DEFFNpaltorgb(pal%)
 3030REM Returns &RRGGBB from sprite palette entry
 3040=(pal%>>>24)+((pal%>>>8)AND&FF00)+((pal%<<8)AND&FF0000)
 3050 
 3060DEFPROCiconbar_menu
 3070REM Pops up menu for iconbar icon
 3080PROCmouse(x%,y%,_%):x%-=64:REM Get coordinates via mouse
 3090$menu="MakeTIFF":menu?12=tf%:menu?13=tb%:menu?14=wf%:menu?15=wb%:menu!16=5*16:menu!20=40:menu!24=0:REM Menu header
 3100menu!28=0:menu!32=win_info%:menu!36=(wb%<<28)+(wf%<<24)+(15<<12)+1:$(menu+40)="Info"+CHR$0:menu!52=&80:menu!56=-1:menu!60=menu!36:$(menu+64)="Quit"+CHR$0
 3110SYS WCreateM%,,menu,x%,y%:REM Create iconbar menu
 3120ENDPROC
 3130 
 3140DEFPROCopen_window(handle%,info)
 3150REM Opens window with handle handle%
 3160REM If info<>0 then info is ready at info, else get info
 3170LOCAL b%,px%,py%,_%,xs%,ys%
 3180IFinfo<>0 THEN
 3190 FOR b%=0 TO 31 STEP 4:block!b%=info!b%:NEXT
 3200ELSE !block=handle%:SYS WGetWS%,,block
 3210 PROCmouse(px%,py%,_%):xs%=block!12-block!4:ys%=block!16-block!8:block!4=px%-64:block!8=py%-ys%+16:block!12=block!4+xs%:block!16=block!8+ys%
 3220ENDIF
 3230SYS WOpenW%,,block
 3240ENDPROC
 3250 
 3260DEFPROCclose_window(handle%)
 3270REM Closes window with handle handle%
 3280!block=handle%:SYS WCloseW%,,block
 3290ENDPROC
 3300 
 3310DEFFNpoll(mask%)
 3320REM Returns poll reason code, masking with mask%, data at poll
 3330LOCAL reasoncode
 3340SYS WPoll%,mask%,poll TO reasoncode
 3350=reasoncode
 3360 
 3370DEFPROCinitialise
 3380REM Initialises program
 3390applname$="MakeTIFF":REM Name of application
 3400SYS "Wimp_Initialise",200,&4B534154,applname$ TO version,TaskHandle%
 3410IFversion<200 THEN ERROR 1,"I cannot work with WIMP pre-2.00"
 3420W%=FNswi_to_nr("Wimp_Initialise"):REM Base SWI number
 3430WCreateW%=W%+1:WCreateI%=W%+2:WOpenW%=W%+5:WCloseW%=W%+6:WPoll%=W%+7:WGetWS%=W%+11:WGetIS%=W%+14:WGetPI%=W%+15:WDragB%=W%+16:WCreateM%=W%+20:WLoadT%=W%+27:WReport%=W%+31:WSendMsg%=W%+39
 3440tf%=7:tb%=2:wf%=7:wb%=0:si%=1:so%=3:REM Window/menu colours
 3450!block=-1:block!4=0:block!8=0:block!12=68:block!16=68:block!20=&27003002:$(block+24)="!maketiff":SYS WCreateI%,,block TO Iiconbar%:REM Iconbar icon
 3460REM Load templates
 3470SYS "Wimp_OpenTemplate",,"<MakeTIFF$Dir>.Templates"
 3480ic=icondata:ie=icondend:REM Indirected icon data workspace
 3490$dum%="save":SYS WLoadT%,,window1,ic,ie,-1,dum%,0 TO ,,ic
 3500SYS WCreateW%,,window1 TO win_file%
 3510SAVfn%=FNiconaddr(win_file%,1)
 3520$dum%="info":SYS WLoadT%,,window2,ic,ie,-1,dum%,0 TO ,,ic
 3530SYS WCreateW%,,window2 TO win_info%
 3540SYS "Wimp_CloseTemplate"
 3550REM Initialise variables
 3560Output$="":Input$="":DataLoadRef%=FALSE:DataSaveRef%=-1:REM Init globals
 3570PROCmcode
 3580ENDPROC
 3590 
 3600DEFFNiconaddr(win%,ico%)
 3610REM Returns indirected icon's data address
 3620!block=win%:block!4=ico%:SYS WGetIS%,,block:REM Get icon info
 3630=block!28
 3640 
 3650DEFPROCmcode
 3660REM Creates machinecode
 3670FOR N=0 TO 2 STEP 2:P%=Code%
 3680[OPTN
 3690.type  EQUD 0:\ Image type (&FF9=sprite, &690=Clear)
 3700.width EQUD 0:\ Width of row in pixels
 3710.left  EQUD 0:\ (Sprite) Left bit wastage
 3720.words EQUD 0:\ (Sprite) Words per row
 3730.bits  EQUD 0:\ Bits per pixel
 3740.row   EQUD RowBf%:\ Row buffer
 3750.map   EQUD RevMap%:\ Conversion map
 3760 
 3770.convert \ Converts row of pixels for TIFF
 3780 \ Sprite - Left-aligns sprite row & reverses pixel order in bytes
 3790 \ Clear  - Packs byte-values & reverses pixel order in bytes
 3800 STMFD r13!,{r14}:\ Save link
 3810 LDR r10,map:\ Pixel reversal map
 3820 LDR r0,type:CMP r0,#&690:BNE conv_spr:\ Sprite or Clear ?
 3830 LDR r6,bits:CMP r6,#8:BEQ conv_exit:\ No conversion needed
 3840 LDR r7,width:LDR r8,row:\ Pixels on row and location
 3850 MOV r3,r8:\ Destination
 3860.bld_prep MOV r5,#0:MOV r4,#8:\ Accumulator / bit shift
 3870.bld_byte SUBS r7,r7,#1:BLE bld_done:\ Pixel values left ?
 3880 LDRB r0,[r8],#1:\ Get pixel value
 3890 SUBS r4,r4,r6:ORR r5,r5,r0,LSL r4:BGT bld_byte:\ Next pixel
 3900 STRB r5,[r3],#1:B bld_prep:\ Next byte
 3910.bld_done CMP r4,#8:STRLTB r5,[r3],#1:\ Last bits
 3920.conv_exit LDMFD r13!,{pc}^:\ Return
 3930.conv_spr LDR r9,left:\ Bit offset to first pixel
 3940 LDR r7,words:LDR r8,row:\ Row length and location
 3950 RSB r6,r9,#32:\ Opposite bitshift
 3960 LDR r0,[r8]:MOV r0,r0,LSR r9:\ Get first bits
 3970.lef_al SUBS r7,r7,#1:LDRGT r1,[r8,#4]:MOVLE r1,#0:\ Get next word
 3980 ORR r2,r0,r1,LSL r6:\ Build word
 3990 AND r4,r2,#&FF:LDRB r3,[r10,r4]:\ Reverse bits in low byte
 4000 MOV r4,r2,LSR#8:AND r4,r4,#&FF:LDRB r4,[r10,r4]:ORR r3,r3,r4,LSL#8
 4010 MOV r4,r2,LSR#16:AND r4,r4,#&FF:LDRB r4,[r10,r4]:ORR r3,r3,r4,LSL#16
 4020 MOV r4,r2,LSR#24:LDRB r4,[r10,r4]:ORR r3,r3,r4,LSL#24:\ High byte
 4030 STR r3,[r8],#4:\ Write word
 4040 MOV r0,r1,LSR r9:BGT lef_al:\ Next word
 4050 LDMFD r13!,{pc}^:\ Return
 4060 
 4070.make_map \ Makes map to convert pixel order within bytes (fillorder=1)
 4080 STMFD r13!,{r14}:\ Save link
 4090 LDR r2,map:MOV r0,#255:\ Map start, first byte value
 4100 LDR r3,bits:\ Bits per pixel
 4110.mak_t CMP r3,#1:BEQ mak_t1:CMP r3,#2:BEQ mak_t2:CMP r3,#4:BEQ mak_t4
 4120.mak_t8 MOV r1,r0:B mak_turn
 4130.mak_t4 AND r4,r0,#15:MOV r1,r0,LSR#4:ORR r1,r1,r4,LSL#4:B mak_turn
 4140.mak_t2 AND r4,r0,#3:AND r5,r0,#3<<2:AND r6,r0,#3<<4:MOV r1,r0,LSR#6:ORR r1,r1,r6,LSR#2:ORR r1,r1,r5,LSL#2:ORR r1,r1,r4,LSL#6:B mak_turn
 4150.mak_t1 MOV r4,r0:MOV r5,#8:MOV r1,#0
 4160.mak_t1r MOVS r4,r4,LSR#1:ADC r1,r1,r1:SUBS r5,r5,#1:BNE mak_t1r
 4170.mak_turn STRB r1,[r2,r0]:SUBS r0,r0,#1:BPL mak_t:\ Next byte value
 4180 LDMFD r13!,{pc}^:\ Return
 4190 
 4200]NEXT
 4210ENDPROC
 4220 
 4230DEFFNswi_to_nr(swi$)
 4240REM Returns SWI number of SWI call swi$
 4250LOCAL swinr%
 4260SYS "XOS_SWINumberFromString",,swi$ TO swinr%
 4270=swinr%
 4280 
 4290DEFPROCerror(errnr,errmsg$)
 4300REM Handles errors
 4310LOCAL but%,opt%
 4320IFerrnr=-1 THEN errnr=1:opt%=1 ELSE opt%=3
 4330!err=errnr:$(err+4)=errmsg$
 4340SYS WReport%,err,opt%,applname$ TO ,but%
 4350IFbut%<>1 THEN PROCdie
 4360ENDPROC
 4370 
 4380DEFPROCfinish
 4390REM Tidies up
 4400SYS "Wimp_CloseDown",TaskHandle%,&4B534154
 4410ENDPROC
 4420 
 4430DEFPROCdie
 4440REM Tidies up and exits
 4450PROCfinish
 4460SYS "OS_Exit"
 4470ENDPROC

� >!RunImage
K��������������������������������������������������������������������
K� Creates TIFF file from sprite or Clear file                (RISCWARE)
(-� Version date : Thu,21 Jun 1990.20:13:08
2� � 1990 Zeridajh software
<� by John Kortink
FK��������������������������������������������������������������������
P.� � �'"Error"''"'";�$;"' (code ";�;")"'':�
Z)� menu 2048,window1 2048,window2 2048
d9� icondata 2048,icondend 0,poll 256,block 256,err 256
n(� Code% 2048,RowBf% 8192,RevMap% 256
x� dum% 256,Palette%(256)
�=Headsize%=4096:� Head% Headsize%:� Buffer for file header
�GProgneed%=60*1024:� Memory needed for program+vars, without buffers
�"Total%=�-�:� Total memory free
�5Buffree%=Total%-Progneed%:� Free for file buffers
�>�Buffree%<20*1024 � � 1,"MakeTIFF cannot startup properly"
�.halve%=(Buffree%�2)��3:� Aligned half size
�AOutputsize%=halve%:� Output% Outputsize%:� Output file buffer
�=Inputsize%=halve%:� Input% Inputsize%:� Input file buffer
�(�initialise:� Initialise application
�%� � �error(�,�$+" (code "+Þ+")")
�� � Poll and action
�Ȏ �poll(0) �
�0 � 0 : �null:� Nothing to do, perform checks
* � 1 : �redraw:� Redraw window request
& � 2 : �open:� Open window request
( � 3 : �close:� Close window request
"& � 6 : �mouseclick:� Mouse clicked
,? � 7 : �dragdrop:� User has dropped drag box of file window
6 � 8 : �key:� Key pressed
@1 � 9 : �menuselect:� Menu selection from user
J+ � 17,18 : �message:� Message from WIMP
T�
^� �
h 
r��menuselect
|'selected%=poll!0:� What selection ?
�5�selected%=1 � �die:� Quit icon, tidy up and exit
��
�
���close
�(�close_window(poll!0):� Close window
��
�
�
��open
�&�open_window(0,poll):� Open window
��
�
�
��null
��DataLoadRef% �
> DataLoadRef%=�:ș "OS_File",6,Output$:� Delete file saved
C �error(-1,"Bad data transfer, receiver dead"):� No DataLoadAck
�
&�
0
:	��key
DEwin%=poll!0:ico%=poll!4:char%=poll!24:� Window, icon, key pressed
N"�(win%=win_file%) � (ico%=1) �
X Ȏ char% �
b  � 13 : � Return pressed
lC   �error(-1,"Please drag the file icon to a directory viewer")
v  � 27 : � Escape pressed
�   �close_window(win_file%)
� �
��
��
�
�
��message
�-� Ignore messages originating from myself
�6�(poll!4)=TaskHandle% � msgnr%=-1 � msgnr%=poll!16
�Ȏ msgnr% �
� � -1 : � Don't react
�+ � 0 : �die:� Request to terminate task
�. � 1 : � DataSave, transfer via scrap file
�7  scrap$=�OSvar("Wimp$Scrap"):� Read scrap filename
�  �scrap$<>"" � poll!12=poll!8:poll!16=2:poll!36=-1:$(poll+44)=scrap$+�0:poll!0=44+(�scrap$+1+3)��3:ș WSendMsg%,18,poll,poll!4 � �error(-1,"Wimp$Scrap not defined"):� Send DataSaveAck if scrap file defined
# � 2 : � DataSaveAck, save file
F  Output$=�string(poll+44):� Read path-name of TIFF file to create
   �hour_on:� Hourglass on
*@  �make_TIFF(type%,Input$,Output$,error$):� Create TIFF file
4  �hour_off:� Hourglass off
>  �error$<>"" �
H'   �error(-1,error$):� Report error
R/   ș "OS_File",6,Output$:� Kill outputfile
\  �
f>  poll!12=poll!8:poll!16=3:� Amend data block for DataLoad
p1  ș WSendMsg%,18,poll,poll!4:� Send DataLoad
z?  DataLoadRef%=poll!8:� Await a DataLoadAck, remember myref
�4 � 3 : � DataLoad, check if sprite or Clear file
�  type%=poll!40:� Filetype
�   �type%=&FF9 � type%=&690 �
�8   � Sprite or Clear file, prepare to make TIFF file
�)   Input$=�string(poll+44):� Filename
�8   �open_window(win_file%,0):� Open save file window
�I   poll!12=poll!8:poll!16=4:ș WSendMsg%,17,poll,poll!4:� DataLoadAck
�  �
�) � 4 : � DataLoadAck, check or ignore
�<  �DataLoadRef% � �poll!12=DataLoadRef% � DataLoadRef%=�
��
��
�
��mouseclick
?but%=poll!8:win%=poll!12:ico%=poll!16:� Buttons/window/icon

Ȏ win% �
$ � -2 : � Click on iconbar
.3  �ico%=Iiconbar% � �(but%�7)=2 � �iconbar_menu
8. � win_file% : � Click on save file window
B  �ico%=0 �
L   Ȏ but% � &7F �
V9    � 16,64 : � Drag,calculate drag box and create it
`z     ScrW%=�mode_var(�,11)<<�mode_var(�,4):ScrH%=�mode_var(�,12)<<�mode_var(�,5):� Screen width and height in OS-units
j�     !block=win%:ș WGetWS%,,block:x%=block!4:y%=block!8:block!4=ico%:ș WGetIS%,,block:!block=win%:block!4=5:block!8+=x%:block!12+=y%:block!16=block!8+68:block!20=block!12+68:block!24=0:block!28=0:block!32=ScrW%:block!36=ScrH%
t,     ș WDragB%,,block:� Create drag box
~   �
�  �
��
��
�
���dragdrop
�,ș WGetPI%,,block:� Get pointer position
�Gdropwin%=block!12:dropico%=block!16:� Window/icon where box dropped
�1filename$=�string(SAVfn%):� Filename for save
حblock!20=block!12:block!24=block!16:block!28=block!0:block!32=block!4:block!12=0:block!16=1:block!36=0:block!40=&FF9:$(block+44)=filename$+�0:!block=(44+�filename$+4)��3
�;ș WSendMsg%,17,block,dropwin%,dropico%:� Send DataSave
�6DataSaveRef%=block!8:� Remember myref for DataSave
�5�close_window(win_file%):� Close save file window
�

 
0��make_TIFF(type%,InFile$,OutFile$,� error$)
'� Creates TIFF file OutFile$ from :
(.� (type%=&FF9) first sprite in sprite file
2&� (type%=&690) image in Clear file
<7� Returns error in error$ if error occured, else ""
F� �
P.� � �:error$=�$+" (code "+Þ+")":�closef:�
Z=error$="":In=0:Out=0:� No errors (yet), files both closed
d#In=�(InFile$):� Open input file
nȎ type% �
x � &FF9 : � Sprite file
�C  ș "OS_GBPB",4,In,Head%+4,Headsize%:� Read sprite file header
�0  spr%=Head%+Head%!8:� Start of first sprite
�i  sprname$="":ptr%=spr%+4:ȕ (?ptr%<>0) � (�sprname$<12):sprname$+=�(?ptr%):ptr%+=1:�:� Sprite's name
�I  wordw%=spr%!16+1:height%=spr%!20+1:� Width in words, height in rows
�J  firstb%=spr%!24:lastb%=spr%!28:� First/last bit used in border words
�1  image%=spr%+spr%!32:� Pointer to image data
�H  mode%=spr%!40:palette%=spr%+44:� Sprite's mode, pointer to palette
�4  colbits%=2^�mode_var(mode%,9):� Bits per pixel
�-  colours%=2^colbits%:� Number of colours
�I  width%=(wordw%*32-(31-lastb%)-firstb%) � colbits%:� Width in pixels
�  �image%<=palette% �
�4   � Sprite has no palette : use default palette
�   Ȏ colours% �
�    � 256 : � c%=0 � 255:r%=((c%�%00010000)>>1)+(c%�%00000100)+(c%�%11):g%=((c%�%01100000)>>3)+(c%�%11):b%=((c%�%10000000)>>4)+((c%�%00001000)>>1)+(c%�%11):Palette%(c%)=(r%<<20)+(g%<<12)+(b%<<4):�
}    � 16 : Palette%()=0,&F00000,&F000,&F0F000,&F0,&F000F0,&F0F0,&F0F0F0,0,&F00000,&F000,&F0F000,&F0,&F000F0,&F0F0,&F0F0F0
2    � 4 : Palette%()=0,&F00000,&F0F000,&F0F0F0
""    � 2 : Palette%()=0,&F0F0F0
,   �
6#  � � Read sprite's own palette
@   �colours%<=16 �
J%    � All palette entries present
TE    � c%=0 � colours%-1:Palette%(c%)=�paltorgb(palette%!(c%*8)):�
^D   � � Only 64 palette entries present, deduce all from first 16
h�    � c%=0 � 15:Palette%(c%)=�paltorgb(palette%!(c%*8)):�:� c%=16 � 255:Palette%(c%)=Palette%(c%�15)+(c%�&80)+((c%�&60)<<9)+((c%�&10)<<19):�
r   �
|  �
�H  xeig%=�mode_var(mode%,4):yeig%=�mode_var(mode%,5):� X/Yeig factors
�D  resdivx%=2^xeig%:resdivy%=2^yeig%:� Divisors for X/YResolution
�)  ResolutionFacs=�:� Factors supplied
�(  rowbytes%=wordw%*4:� Bytes per row
�4  dataptr%=image%-Head%-4:� Offset to image data
� � &690 : � Clear file
�@  ș "OS_GBPB",4,In,Head%,Headsize%:� Read Clear file header
�p  ptr%=Head%:maker$="":ȕ ?ptr%>=�" ":maker$+=�(?ptr%):ptr%+=1:�:version%=ptr%!1:ptr%+=5:� Maker and version
֥  �maker$="Translator" � �version%=600 � error$="I cannot handle this Clear file from '"+maker$+"' version "+�(version%�100)+"."+�"0"+�(version%�100),2)+" !!!":�
�G  width%=!ptr%:height%=ptr%!4:colbits%=ptr%!8:ptr%+=12:� Resolution
�D  �colbits%>8 � error$="I cannot handle pure RGB Clear files.":�
�,  colours%=2^colbits%:� Colours in image
�b  � c%=0 � colours%-1:Palette%(c%)=((?ptr%)<<16)+((ptr%?1)<<8)+ptr%?2:ptr%+=3:�:� Read palette
(  ResolutionFacs=�:� Factors unknown
0  dataptr%=ptr%-Head%:� Offset to image data
&  rowbytes%=width%:� Bytes per row
&�
00bytew%=(width%*colbits%+7)�8:� Bytes per row
:>rowsperstrip%=8192 � bytew%:� Make strips about 8K in size
DF�rowsperstrip%>height% � rowsperstrip%=height%:� Height is maximum
NHstrips%=(height%+rowsperstrip%-1) � rowsperstrip%:� Number of strips
X1striplen%=rowsperstrip%*bytew%:� Strip length
b*�#In=dataptr%:� To start of image data
l+Out=�(OutFile$):� Open output TIFF file
v2�outs("II"):� Low-to-high byte order TIFF file
�#�outd(42):� TIFF version number
�3�outw(8):� Offset to Image File Directory (IFD)
�=�ResolutionFacs � entries%=13 � entries%=10:� IFD entries
�+�outd(entries%):� Number of IFD entries
�=iptr%=12*entries%+4+�#Out:� Initialise info block pointer
�3�outIFD(256,4,1,width%):� Image width in pixels
�5�outIFD(257,4,1,height%):� Image height in pixels
�/�outIFD(258,3,1,colbits%):� Bits per sample
�6�outIFD(259,3,1,1):� Compression (none at present)
�D�outIFD(262,3,1,3):� Photometric interpretation (Palette colour)
�I�outIFD(266,3,1,1):� Fillorder (high bits first, it's 'recommended'!)
�-�outIFD(273,4,strips%,-1):� Strip offsets
�*�outIFD(277,3,1,1):� Samples per pixel
3�outIFD(278,4,1,rowsperstrip%):� Rows per strip
8� X resolution, Y resolution, resolution unit (inch)
P�ResolutionFacs � �outIFD(282,5,1,-1):�outIFD(283,5,1,-1):�outIFD(296,3,1,2)
 -�outIFD(320,3,3*colours%,-1):� Colour map
*�outw(0):� No next IFD
4(� Arrived at info blocks, write data
>>� s%=1 � strips%:�outw(�iptr(striplen%)):�:� Strip offsets
Hc�ResolutionFacs � �outw(180):�outw(resdivx%):�outw(180):�outw(resdivy%):� 180 OS units per inch
Rl� rgb%=16 � 0 � -8:� c%=0 � colours%-1:v%=(Palette%(c%)>>>rgb%)�&FF:�outd(v%<<8):�:�:� Output colour map
\1!bits=colbits%:!type=type%:� Machinecode info
fi�type%=&FF9 � !left=firstb%:!words=wordw%:� make_map � !width=width%:� More specific machinecode info
p� r%=1 � height%
z1ș "OS_GBPB",4,In,RowBf%,rowbytes%:� Read row
�)� convert:� Convert row data for TIFF
�0ș "OS_GBPB",2,Out,RowBf%,bytew%:� Write row
��
��#In:� Close input file
��#Out:� Close TIFF file
�Bș "OS_CLI","SetType "+OutFile$+" FF0":� Filetype as TIFF file
��
� 
���closef
�� Closes files on error
��In>0 � �#In
��Out>0 � �#Out
��
	 
	ݤiptr(room%)
	2� Returns file pointer to block of room% bytes
	$iptr%+=room%:=iptr%-room%
	. 
	8'��outIFD(tag%,type%,length%,value%)
	B"� Outputs IFD entry to outfile
	L� bytes%
	V0bytes%=�(�"11248",type%,1)):� Bytes per type
	`@�value%=-1 � value%=�iptr(bytes%*length%):� Pointer to block
	j�outd(tag%):� Tag
	t�outd(type%):� Field type
	~ �outw(length%):� Field count
	�+�outw(value%):� Value (offset or value)
	��
	� 
	���outs(out$)
	�� Outputs string to outfile
	�� c%
	�%� c%=1 � �out$:�#Out,��out$,c%):�
	��
	� 
	���outw(out%)
	�� Outputs word to outfile
	�=�#Out,out%:�#Out,out%>>>8:�#Out,out%>>>16:�#Out,out%>>>24
�

 
��outd(out%)
$� Outputs double-byte to outfile
(�#Out,out%:�#Out,out%>>8
2�
< 
F��outb(out%)
P� Outputs byte to outfile
Z�#Out,out%
d�
n 
xݤmode_var(mode%,var%)
�� Returns mode variable
�
� val%
�0ș "OS_ReadModeVariable",mode%,var% � ,,val%
�	=val%
� 
�ݤstring(addr%)
�2� Returns CTRL-char terminated string at addr%
�� _%,_c%,_$
�_%=-1:� _%+=1:� addr%?_%<32
�3_c%=addr%?_%:addr%?_%=13:_$=$addr%:addr%?_%=_c%
�=_$
� 
���mouse(� x%,� y%,� but%)
+� Returns x,y and button state of mouse
ȗ x%,y%,but%
�
" 
,
��hour_on
6$� Turns hourglass on after 1 sec
@ș "Hourglass_On"
J�
T 
^��hour_off
h� Turns hourglass off
rș "Hourglass_Off"
|�
� 
�ݤOSvar(name$)
�.� Attempts to return OS-var's string value
�
� _r$,_l%
�C_r$=�100," "):ș "XOS_ReadVarVal",name$,_r$,�_r$,0,3 � ,_r$,_l%
�=�_r$,_l%)
� 
�ݤpaltorgb(pal%)
�/� Returns &RRGGBB from sprite palette entry
�7=(pal%>>>24)+((pal%>>>8)�&FF00)+((pal%<<8)�&FF0000)
� 
���iconbar_menu
�#� Pops up menu for iconbar icon
7�mouse(x%,y%,_%):x%-=64:� Get coordinates via mouse
t$menu="MakeTIFF":menu?12=tf%:menu?13=tb%:menu?14=wf%:menu?15=wb%:menu!16=5*16:menu!20=40:menu!24=0:� Menu header
�menu!28=0:menu!32=win_info%:menu!36=(wb%<<28)+(wf%<<24)+(15<<12)+1:$(menu+40)="Info"+�0:menu!52=&80:menu!56=-1:menu!60=menu!36:$(menu+64)="Quit"+�0
&2ș WCreateM%,,menu,x%,y%:� Create iconbar menu
0�
: 
D��open_window(handle%,info)
N&� Opens window with handle handle%
X:� If info<>0 then info is ready at info, else get info
b� b%,px%,py%,_%,xs%,ys%
l�info<>0 �
v' � b%=0 � 31 � 4:block!b%=info!b%:�
�&� !block=handle%:ș WGetWS%,,block
�� �mouse(px%,py%,_%):xs%=block!12-block!4:ys%=block!16-block!8:block!4=px%-64:block!8=py%-ys%+16:block!12=block!4+xs%:block!16=block!8+ys%
��
�ș WOpenW%,,block
��
� 
���close_window(handle%)
�'� Closes window with handle handle%
�%!block=handle%:ș WCloseW%,,block
��
� 
�ݤpoll(mask%)
�@� Returns poll reason code, masking with mask%, data at poll

� reasoncode

%ș WPoll%,mask%,poll � reasoncode

=reasoncode

  

*��initialise

4� Initialises program

>.applname$="MakeTIFF":� Name of application

HFș "Wimp_Initialise",200,&4B534154,applname$ � version,TaskHandle%

R9�version<200 � � 1,"I cannot work with WIMP pre-2.00"

\6W%=�swi_to_nr("Wimp_Initialise"):� Base SWI number

f�WCreateW%=W%+1:WCreateI%=W%+2:WOpenW%=W%+5:WCloseW%=W%+6:WPoll%=W%+7:WGetWS%=W%+11:WGetIS%=W%+14:WGetPI%=W%+15:WDragB%=W%+16:WCreateM%=W%+20:WLoadT%=W%+27:WReport%=W%+31:WSendMsg%=W%+39

p=tf%=7:tb%=2:wf%=7:wb%=0:si%=1:so%=3:� Window/menu colours

z�!block=-1:block!4=0:block!8=0:block!12=68:block!16=68:block!20=&27003002:$(block+24)="!maketiff":ș WCreateI%,,block � Iiconbar%:� Iconbar icon

�� Load templates

�6ș "Wimp_OpenTemplate",,"<MakeTIFF$Dir>.Templates"

�<ic=icondata:ie=icondend:� Indirected icon data workspace

�;$dum%="save":ș WLoadT%,,window1,ic,ie,-1,dum%,0 � ,,ic

�%ș WCreateW%,,window1 � win_file%

�!SAVfn%=�iconaddr(win_file%,1)

�;$dum%="info":ș WLoadT%,,window2,ic,ie,-1,dum%,0 � ,,ic

�%ș WCreateW%,,window2 � win_info%

�ș "Wimp_CloseTemplate"

�� Initialise variables

�FOutput$="":Input$="":DataLoadRef%=�:DataSaveRef%=-1:� Init globals

�
�mcode

��
 
ݤiconaddr(win%,ico%)
,� Returns indirected icon's data address
$>!block=win%:block!4=ico%:ș WGetIS%,,block:� Get icon info
.
=block!28
8 
B��mcode
L� Creates machinecode
V� N=0 � 2 � 2:P%=Code%
`	[OPTN
j8.type  EQUD 0:\ Image type (&FF9=sprite, &690=Clear)
t*.width EQUD 0:\ Width of row in pixels
~-.left  EQUD 0:\ (Sprite) Left bit wastage
�*.words EQUD 0:\ (Sprite) Words per row
�".bits  EQUD 0:\ Bits per pixel
�#.row   EQUD RowBf%:\ Row buffer
�(.map   EQUD RevMap%:\ Conversion map
� 
�..convert \ Converts row of pixels for TIFF
�F \ Sprite - Left-aligns sprite row & reverses pixel order in bytes
�A \ Clear  - Packs byte-values & reverses pixel order in bytes
�! STMFD r13!,{r14}:\ Save link
�% LDR r10,map:\ Pixel reversal map
�> LDR r0,type:CMP r0,#&690:BNE conv_spr:\ Sprite or Clear ?
�? LDR r6,bits:CMP r6,#8:BEQ conv_exit:\ No conversion needed
9 LDR r7,width:LDR r8,row:\ Pixels on row and location

 MOV r3,r8:\ Destination
;.bld_prep MOV r5,#0:MOV r4,#8:\ Accumulator / bit shift
>.bld_byte SUBS r7,r7,#1:BLE bld_done:\ Pixel values left ?
(& LDRB r0,[r8],#1:\ Get pixel value
2? SUBS r4,r4,r6:�R r5,r5,r0,LSL r4:BGT bld_byte:\ Next pixel
<+ STRB r5,[r3],#1:B bld_prep:\ Next byte
F5.bld_done CMP r4,#8:STRLTB r5,[r3],#1:\ Last bits
P(.conv_exit LDMFD r13!,{pc}^:\ Return
Z5.conv_spr LDR r9,left:\ Bit offset to first pixel
d6 LDR r7,words:LDR r8,row:\ Row length and location
n& RSB r6,r9,#32:\ Opposite bitshift
x2 LDR r0,[r8]:MOV r0,r0,LSR r9:\ Get first bits
�F.lef_al SUBS r7,r7,#1:LDRGT r1,[r8,#4]:MOVLE r1,#0:\ Get next word
�$ �R r2,r0,r1,LSL r6:\ Build word
�= � r4,r2,#&FF:LDRB r3,[r10,r4]:\ Reverse bits in low byte
�D MOV r4,r2,LSR#8:� r4,r4,#&FF:LDRB r4,[r10,r4]:�R r3,r3,r4,LSL#8
�F MOV r4,r2,LSR#16:� r4,r4,#&FF:LDRB r4,[r10,r4]:�R r3,r3,r4,LSL#16
�E MOV r4,r2,LSR#24:LDRB r4,[r10,r4]:�R r3,r3,r4,LSL#24:\ High byte
�  STR r3,[r8],#4:\ Write word
�, MOV r0,r1,LSR r9:BGT lef_al:\ Next word
� LDMFD r13!,{pc}^:\ Return
� 
�K.make_map \ Makes map to convert pixel order within bytes (fillorder=1)
�! STMFD r13!,{r14}:\ Save link
�9 LDR r2,map:MOV r0,#255:\ Map start, first byte value
! LDR r3,bits:\ Bits per pixel
I.mak_t CMP r3,#1:BEQ mak_t1:CMP r3,#2:BEQ mak_t2:CMP r3,#4:BEQ mak_t4
 .mak_t8 MOV r1,r0:B mak_turn
"D.mak_t4 � r4,r0,#15:MOV r1,r0,LSR#4:�R r1,r1,r4,LSL#4:B mak_turn
,�.mak_t2 � r4,r0,#3:� r5,r0,#3<<2:� r6,r0,#3<<4:MOV r1,r0,LSR#6:�R r1,r1,r6,LSR#2:�R r1,r1,r5,LSL#2:�R r1,r1,r4,LSL#6:B mak_turn
6).mak_t1 MOV r4,r0:MOV r5,#8:MOV r1,#0
@D.mak_t1r MOVS r4,r4,LSR#1:ADC r1,r1,r1:SUBS r5,r5,#1:BNE mak_t1r
JG.mak_turn STRB r1,[r2,r0]:SUBS r0,r0,#1:BPL mak_t:\ Next byte value
T LDMFD r13!,{pc}^:\ Return
^ 
h]�
r�
| 
�ݤswi_to_nr(swi$)
�)� Returns SWI number of SWI call swi$
�� swinr%
�/ș "XOS_SWINumberFromString",,swi$ � swinr%
�=swinr%
� 
���error(errnr,errmsg$)
�� Handles errors
�� but%,opt%
�'�errnr=-1 � errnr=1:opt%=1 � opt%=3
�!err=errnr:$(err+4)=errmsg$
�*ș WReport%,err,opt%,applname$ � ,but%
��but%<>1 � �die
�
 
��finish
&� Tidies up
0-ș "Wimp_CloseDown",TaskHandle%,&4B534154
:�
D 
N	��die
X� Tidies up and exits
b�finish
lș "OS_Exit"
v�
�
00000000  0d 00 0a 10 f4 20 3e 21  52 75 6e 49 6d 61 67 65  |..... >!RunImage|
00000010  0d 00 14 4b f4 ab ab ab  ab ab ab ab ab ab ab ab  |...K............|
00000020  ab ab ab ab ab ab ab ab  ab ab ab ab ab ab ab ab  |................|
*
00000050  ab ab ab ab ab ab ab ab  ab ab ab 0d 00 1e 4b f4  |..............K.|
00000060  20 43 72 65 61 74 65 73  20 54 49 46 46 20 66 69  | Creates TIFF fi|
00000070  6c 65 20 66 72 6f 6d 20  73 70 72 69 74 65 20 6f  |le from sprite o|
00000080  72 20 43 6c 65 61 72 20  66 69 6c 65 20 20 20 20  |r Clear file    |
00000090  20 20 20 20 20 20 20 20  20 20 20 20 28 52 49 53  |            (RIS|
000000a0  43 57 41 52 45 29 0d 00  28 2d f4 20 56 65 72 73  |CWARE)..(-. Vers|
000000b0  69 6f 6e 20 64 61 74 65  20 3a 20 54 68 75 2c 32  |ion date : Thu,2|
000000c0  31 20 4a 75 6e 20 31 39  39 30 2e 32 30 3a 31 33  |1 Jun 1990.20:13|
000000d0  3a 30 38 0d 00 32 1e f4  20 a9 20 31 39 39 30 20  |:08..2.. . 1990 |
000000e0  5a 65 72 69 64 61 6a 68  20 73 6f 66 74 77 61 72  |Zeridajh softwar|
000000f0  65 0d 00 3c 15 f4 20 62  79 20 4a 6f 68 6e 20 4b  |e..<.. by John K|
00000100  6f 72 74 69 6e 6b 0d 00  46 4b f4 ab ab ab ab ab  |ortink..FK......|
00000110  ab ab ab ab ab ab ab ab  ab ab ab ab ab ab ab ab  |................|
*
00000150  ab 0d 00 50 2e ee 20 85  20 f1 27 22 45 72 72 6f  |...P.. . .'"Erro|
00000160  72 22 27 27 22 27 22 3b  f6 24 3b 22 27 20 28 63  |r"''"'";.$;"' (c|
00000170  6f 64 65 20 22 3b 9e 3b  22 29 22 27 27 3a e0 0d  |ode ";.;")"'':..|
00000180  00 5a 29 de 20 6d 65 6e  75 20 32 30 34 38 2c 77  |.Z). menu 2048,w|
00000190  69 6e 64 6f 77 31 20 32  30 34 38 2c 77 69 6e 64  |indow1 2048,wind|
000001a0  6f 77 32 20 32 30 34 38  0d 00 64 39 de 20 69 63  |ow2 2048..d9. ic|
000001b0  6f 6e 64 61 74 61 20 32  30 34 38 2c 69 63 6f 6e  |ondata 2048,icon|
000001c0  64 65 6e 64 20 30 2c 70  6f 6c 6c 20 32 35 36 2c  |dend 0,poll 256,|
000001d0  62 6c 6f 63 6b 20 32 35  36 2c 65 72 72 20 32 35  |block 256,err 25|
000001e0  36 0d 00 6e 28 de 20 43  6f 64 65 25 20 32 30 34  |6..n(. Code% 204|
000001f0  38 2c 52 6f 77 42 66 25  20 38 31 39 32 2c 52 65  |8,RowBf% 8192,Re|
00000200  76 4d 61 70 25 20 32 35  36 0d 00 78 1c de 20 64  |vMap% 256..x.. d|
00000210  75 6d 25 20 32 35 36 2c  50 61 6c 65 74 74 65 25  |um% 256,Palette%|
00000220  28 32 35 36 29 0d 00 82  3d 48 65 61 64 73 69 7a  |(256)...=Headsiz|
00000230  65 25 3d 34 30 39 36 3a  de 20 48 65 61 64 25 20  |e%=4096:. Head% |
00000240  48 65 61 64 73 69 7a 65  25 3a f4 20 42 75 66 66  |Headsize%:. Buff|
00000250  65 72 20 66 6f 72 20 66  69 6c 65 20 68 65 61 64  |er for file head|
00000260  65 72 0d 00 8c 47 50 72  6f 67 6e 65 65 64 25 3d  |er...GProgneed%=|
00000270  36 30 2a 31 30 32 34 3a  f4 20 4d 65 6d 6f 72 79  |60*1024:. Memory|
00000280  20 6e 65 65 64 65 64 20  66 6f 72 20 70 72 6f 67  | needed for prog|
00000290  72 61 6d 2b 76 61 72 73  2c 20 77 69 74 68 6f 75  |ram+vars, withou|
000002a0  74 20 62 75 66 66 65 72  73 0d 00 96 22 54 6f 74  |t buffers..."Tot|
000002b0  61 6c 25 3d 93 2d 90 3a  f4 20 54 6f 74 61 6c 20  |al%=.-.:. Total |
000002c0  6d 65 6d 6f 72 79 20 66  72 65 65 0d 00 a0 35 42  |memory free...5B|
000002d0  75 66 66 72 65 65 25 3d  54 6f 74 61 6c 25 2d 50  |uffree%=Total%-P|
000002e0  72 6f 67 6e 65 65 64 25  3a f4 20 46 72 65 65 20  |rogneed%:. Free |
000002f0  66 6f 72 20 66 69 6c 65  20 62 75 66 66 65 72 73  |for file buffers|
00000300  0d 00 aa 3e e7 42 75 66  66 72 65 65 25 3c 32 30  |...>.Buffree%<20|
00000310  2a 31 30 32 34 20 8c 20  85 20 31 2c 22 4d 61 6b  |*1024 . . 1,"Mak|
00000320  65 54 49 46 46 20 63 61  6e 6e 6f 74 20 73 74 61  |eTIFF cannot sta|
00000330  72 74 75 70 20 70 72 6f  70 65 72 6c 79 22 0d 00  |rtup properly"..|
00000340  b4 2e 68 61 6c 76 65 25  3d 28 42 75 66 66 72 65  |..halve%=(Buffre|
00000350  65 25 81 32 29 80 ac 33  3a f4 20 41 6c 69 67 6e  |e%.2)..3:. Align|
00000360  65 64 20 68 61 6c 66 20  73 69 7a 65 0d 00 be 41  |ed half size...A|
00000370  4f 75 74 70 75 74 73 69  7a 65 25 3d 68 61 6c 76  |Outputsize%=halv|
00000380  65 25 3a de 20 4f 75 74  70 75 74 25 20 4f 75 74  |e%:. Output% Out|
00000390  70 75 74 73 69 7a 65 25  3a f4 20 4f 75 74 70 75  |putsize%:. Outpu|
000003a0  74 20 66 69 6c 65 20 62  75 66 66 65 72 0d 00 c8  |t file buffer...|
000003b0  3d 49 6e 70 75 74 73 69  7a 65 25 3d 68 61 6c 76  |=Inputsize%=halv|
000003c0  65 25 3a de 20 49 6e 70  75 74 25 20 49 6e 70 75  |e%:. Input% Inpu|
000003d0  74 73 69 7a 65 25 3a f4  20 49 6e 70 75 74 20 66  |tsize%:. Input f|
000003e0  69 6c 65 20 62 75 66 66  65 72 0d 00 d2 28 f2 69  |ile buffer...(.i|
000003f0  6e 69 74 69 61 6c 69 73  65 3a f4 20 49 6e 69 74  |nitialise:. Init|
00000400  69 61 6c 69 73 65 20 61  70 70 6c 69 63 61 74 69  |ialise applicati|
00000410  6f 6e 0d 00 dc 25 ee 20  85 20 f2 65 72 72 6f 72  |on...%. . .error|
00000420  28 9f 2c f6 24 2b 22 20  28 63 6f 64 65 20 22 2b  |(.,.$+" (code "+|
00000430  c3 9e 2b 22 29 22 29 0d  00 e6 17 f5 20 f4 20 50  |..+")")..... . P|
00000440  6f 6c 6c 20 61 6e 64 20  61 63 74 69 6f 6e 0d 00  |oll and action..|
00000450  f0 11 c8 8e 20 a4 70 6f  6c 6c 28 30 29 20 ca 0d  |.... .poll(0) ..|
00000460  00 fa 30 20 c9 20 30 20  3a 20 f2 6e 75 6c 6c 3a  |..0 . 0 : .null:|
00000470  f4 20 4e 6f 74 68 69 6e  67 20 74 6f 20 64 6f 2c  |. Nothing to do,|
00000480  20 70 65 72 66 6f 72 6d  20 63 68 65 63 6b 73 0d  | perform checks.|
00000490  01 04 2a 20 c9 20 31 20  3a 20 f2 72 65 64 72 61  |..* . 1 : .redra|
000004a0  77 3a f4 20 52 65 64 72  61 77 20 77 69 6e 64 6f  |w:. Redraw windo|
000004b0  77 20 72 65 71 75 65 73  74 0d 01 0e 26 20 c9 20  |w request...& . |
000004c0  32 20 3a 20 f2 6f 70 65  6e 3a f4 20 4f 70 65 6e  |2 : .open:. Open|
000004d0  20 77 69 6e 64 6f 77 20  72 65 71 75 65 73 74 0d  | window request.|
000004e0  01 18 28 20 c9 20 33 20  3a 20 f2 63 6c 6f 73 65  |..( . 3 : .close|
000004f0  3a f4 20 43 6c 6f 73 65  20 77 69 6e 64 6f 77 20  |:. Close window |
00000500  72 65 71 75 65 73 74 0d  01 22 26 20 c9 20 36 20  |request.."& . 6 |
00000510  3a 20 f2 6d 6f 75 73 65  63 6c 69 63 6b 3a f4 20  |: .mouseclick:. |
00000520  4d 6f 75 73 65 20 63 6c  69 63 6b 65 64 0d 01 2c  |Mouse clicked..,|
00000530  3f 20 c9 20 37 20 3a 20  f2 64 72 61 67 64 72 6f  |? . 7 : .dragdro|
00000540  70 3a f4 20 55 73 65 72  20 68 61 73 20 64 72 6f  |p:. User has dro|
00000550  70 70 65 64 20 64 72 61  67 20 62 6f 78 20 6f 66  |pped drag box of|
00000560  20 66 69 6c 65 20 77 69  6e 64 6f 77 0d 01 36 1d  | file window..6.|
00000570  20 c9 20 38 20 3a 20 f2  6b 65 79 3a f4 20 4b 65  | . 8 : .key:. Ke|
00000580  79 20 70 72 65 73 73 65  64 0d 01 40 31 20 c9 20  |y pressed..@1 . |
00000590  39 20 3a 20 f2 6d 65 6e  75 73 65 6c 65 63 74 3a  |9 : .menuselect:|
000005a0  f4 20 4d 65 6e 75 20 73  65 6c 65 63 74 69 6f 6e  |. Menu selection|
000005b0  20 66 72 6f 6d 20 75 73  65 72 0d 01 4a 2b 20 c9  | from user..J+ .|
000005c0  20 31 37 2c 31 38 20 3a  20 f2 6d 65 73 73 61 67  | 17,18 : .messag|
000005d0  65 3a f4 20 4d 65 73 73  61 67 65 20 66 72 6f 6d  |e:. Message from|
000005e0  20 57 49 4d 50 0d 01 54  05 cb 0d 01 5e 07 fd 20  | WIMP..T....^.. |
000005f0  a3 0d 01 68 05 20 0d 01  72 10 dd f2 6d 65 6e 75  |...h. ..r...menu|
00000600  73 65 6c 65 63 74 0d 01  7c 27 73 65 6c 65 63 74  |select..|'select|
00000610  65 64 25 3d 70 6f 6c 6c  21 30 3a f4 20 57 68 61  |ed%=poll!0:. Wha|
00000620  74 20 73 65 6c 65 63 74  69 6f 6e 20 3f 0d 01 86  |t selection ?...|
00000630  35 e7 73 65 6c 65 63 74  65 64 25 3d 31 20 8c 20  |5.selected%=1 . |
00000640  f2 64 69 65 3a f4 20 51  75 69 74 20 69 63 6f 6e  |.die:. Quit icon|
00000650  2c 20 74 69 64 79 20 75  70 20 61 6e 64 20 65 78  |, tidy up and ex|
00000660  69 74 0d 01 90 05 e1 0d  01 9a 04 0d 01 a4 0b dd  |it..............|
00000670  f2 63 6c 6f 73 65 0d 01  ae 28 f2 63 6c 6f 73 65  |.close...(.close|
00000680  5f 77 69 6e 64 6f 77 28  70 6f 6c 6c 21 30 29 3a  |_window(poll!0):|
00000690  f4 20 43 6c 6f 73 65 20  77 69 6e 64 6f 77 0d 01  |. Close window..|
000006a0  b8 05 e1 0d 01 c2 04 0d  01 cc 0a dd f2 6f 70 65  |.............ope|
000006b0  6e 0d 01 d6 26 f2 6f 70  65 6e 5f 77 69 6e 64 6f  |n...&.open_windo|
000006c0  77 28 30 2c 70 6f 6c 6c  29 3a f4 20 4f 70 65 6e  |w(0,poll):. Open|
000006d0  20 77 69 6e 64 6f 77 0d  01 e0 05 e1 0d 01 ea 04  | window.........|
000006e0  0d 01 f4 0a dd f2 6e 75  6c 6c 0d 01 fe 13 e7 44  |......null.....D|
000006f0  61 74 61 4c 6f 61 64 52  65 66 25 20 8c 0d 02 08  |ataLoadRef% ....|
00000700  3e 20 44 61 74 61 4c 6f  61 64 52 65 66 25 3d a3  |> DataLoadRef%=.|
00000710  3a c8 99 20 22 4f 53 5f  46 69 6c 65 22 2c 36 2c  |:.. "OS_File",6,|
00000720  4f 75 74 70 75 74 24 3a  f4 20 44 65 6c 65 74 65  |Output$:. Delete|
00000730  20 66 69 6c 65 20 73 61  76 65 64 0d 02 12 43 20  | file saved...C |
00000740  f2 65 72 72 6f 72 28 2d  31 2c 22 42 61 64 20 64  |.error(-1,"Bad d|
00000750  61 74 61 20 74 72 61 6e  73 66 65 72 2c 20 72 65  |ata transfer, re|
00000760  63 65 69 76 65 72 20 64  65 61 64 22 29 3a f4 20  |ceiver dead"):. |
00000770  4e 6f 20 44 61 74 61 4c  6f 61 64 41 63 6b 0d 02  |No DataLoadAck..|
00000780  1c 05 cd 0d 02 26 05 e1  0d 02 30 04 0d 02 3a 09  |.....&....0...:.|
00000790  dd f2 6b 65 79 0d 02 44  45 77 69 6e 25 3d 70 6f  |..key..DEwin%=po|
000007a0  6c 6c 21 30 3a 69 63 6f  25 3d 70 6f 6c 6c 21 34  |ll!0:ico%=poll!4|
000007b0  3a 63 68 61 72 25 3d 70  6f 6c 6c 21 32 34 3a f4  |:char%=poll!24:.|
000007c0  20 57 69 6e 64 6f 77 2c  20 69 63 6f 6e 2c 20 6b  | Window, icon, k|
000007d0  65 79 20 70 72 65 73 73  65 64 0d 02 4e 22 e7 28  |ey pressed..N".(|
000007e0  77 69 6e 25 3d 77 69 6e  5f 66 69 6c 65 25 29 20  |win%=win_file%) |
000007f0  80 20 28 69 63 6f 25 3d  31 29 20 8c 0d 02 58 0f  |. (ico%=1) ...X.|
00000800  20 c8 8e 20 63 68 61 72  25 20 ca 0d 02 62 1d 20  | .. char% ...b. |
00000810  20 c9 20 31 33 20 3a 20  f4 20 52 65 74 75 72 6e  | . 13 : . Return|
00000820  20 70 72 65 73 73 65 64  0d 02 6c 43 20 20 20 f2  | pressed..lC   .|
00000830  65 72 72 6f 72 28 2d 31  2c 22 50 6c 65 61 73 65  |error(-1,"Please|
00000840  20 64 72 61 67 20 74 68  65 20 66 69 6c 65 20 69  | drag the file i|
00000850  63 6f 6e 20 74 6f 20 61  20 64 69 72 65 63 74 6f  |con to a directo|
00000860  72 79 20 76 69 65 77 65  72 22 29 0d 02 76 1d 20  |ry viewer")..v. |
00000870  20 c9 20 32 37 20 3a 20  f4 20 45 73 63 61 70 65  | . 27 : . Escape|
00000880  20 70 72 65 73 73 65 64  0d 02 80 1f 20 20 20 f2  | pressed....   .|
00000890  63 6c 6f 73 65 5f 77 69  6e 64 6f 77 28 77 69 6e  |close_window(win|
000008a0  5f 66 69 6c 65 25 29 0d  02 8a 06 20 cb 0d 02 94  |_file%).... ....|
000008b0  05 cd 0d 02 9e 05 e1 0d  02 a8 04 0d 02 b2 0d dd  |................|
000008c0  f2 6d 65 73 73 61 67 65  0d 02 bc 2d f4 20 49 67  |.message...-. Ig|
000008d0  6e 6f 72 65 20 6d 65 73  73 61 67 65 73 20 6f 72  |nore messages or|
000008e0  69 67 69 6e 61 74 69 6e  67 20 66 72 6f 6d 20 6d  |iginating from m|
000008f0  79 73 65 6c 66 0d 02 c6  36 e7 28 70 6f 6c 6c 21  |yself...6.(poll!|
00000900  34 29 3d 54 61 73 6b 48  61 6e 64 6c 65 25 20 8c  |4)=TaskHandle% .|
00000910  20 6d 73 67 6e 72 25 3d  2d 31 20 8b 20 6d 73 67  | msgnr%=-1 . msg|
00000920  6e 72 25 3d 70 6f 6c 6c  21 31 36 0d 02 d0 0f c8  |nr%=poll!16.....|
00000930  8e 20 6d 73 67 6e 72 25  20 ca 0d 02 da 19 20 c9  |. msgnr% ..... .|
00000940  20 2d 31 20 3a 20 f4 20  44 6f 6e 27 74 20 72 65  | -1 : . Don't re|
00000950  61 63 74 0d 02 e4 2b 20  c9 20 30 20 3a 20 f2 64  |act...+ . 0 : .d|
00000960  69 65 3a f4 20 52 65 71  75 65 73 74 20 74 6f 20  |ie:. Request to |
00000970  74 65 72 6d 69 6e 61 74  65 20 74 61 73 6b 0d 02  |terminate task..|
00000980  ee 2e 20 c9 20 31 20 3a  20 f4 20 44 61 74 61 53  |.. . 1 : . DataS|
00000990  61 76 65 2c 20 74 72 61  6e 73 66 65 72 20 76 69  |ave, transfer vi|
000009a0  61 20 73 63 72 61 70 20  66 69 6c 65 0d 02 f8 37  |a scrap file...7|
000009b0  20 20 73 63 72 61 70 24  3d a4 4f 53 76 61 72 28  |  scrap$=.OSvar(|
000009c0  22 57 69 6d 70 24 53 63  72 61 70 22 29 3a f4 20  |"Wimp$Scrap"):. |
000009d0  52 65 61 64 20 73 63 72  61 70 20 66 69 6c 65 6e  |Read scrap filen|
000009e0  61 6d 65 0d 03 02 d2 20  20 e7 73 63 72 61 70 24  |ame....  .scrap$|
000009f0  3c 3e 22 22 20 8c 20 70  6f 6c 6c 21 31 32 3d 70  |<>"" . poll!12=p|
00000a00  6f 6c 6c 21 38 3a 70 6f  6c 6c 21 31 36 3d 32 3a  |oll!8:poll!16=2:|
00000a10  70 6f 6c 6c 21 33 36 3d  2d 31 3a 24 28 70 6f 6c  |poll!36=-1:$(pol|
00000a20  6c 2b 34 34 29 3d 73 63  72 61 70 24 2b bd 30 3a  |l+44)=scrap$+.0:|
00000a30  70 6f 6c 6c 21 30 3d 34  34 2b 28 a9 73 63 72 61  |poll!0=44+(.scra|
00000a40  70 24 2b 31 2b 33 29 80  ac 33 3a c8 99 20 57 53  |p$+1+3)..3:.. WS|
00000a50  65 6e 64 4d 73 67 25 2c  31 38 2c 70 6f 6c 6c 2c  |endMsg%,18,poll,|
00000a60  70 6f 6c 6c 21 34 20 8b  20 f2 65 72 72 6f 72 28  |poll!4 . .error(|
00000a70  2d 31 2c 22 57 69 6d 70  24 53 63 72 61 70 20 6e  |-1,"Wimp$Scrap n|
00000a80  6f 74 20 64 65 66 69 6e  65 64 22 29 3a f4 20 53  |ot defined"):. S|
00000a90  65 6e 64 20 44 61 74 61  53 61 76 65 41 63 6b 20  |end DataSaveAck |
00000aa0  69 66 20 73 63 72 61 70  20 66 69 6c 65 20 64 65  |if scrap file de|
00000ab0  66 69 6e 65 64 0d 03 0c  23 20 c9 20 32 20 3a 20  |fined...# . 2 : |
00000ac0  f4 20 44 61 74 61 53 61  76 65 41 63 6b 2c 20 73  |. DataSaveAck, s|
00000ad0  61 76 65 20 66 69 6c 65  0d 03 16 46 20 20 4f 75  |ave file...F  Ou|
00000ae0  74 70 75 74 24 3d a4 73  74 72 69 6e 67 28 70 6f  |tput$=.string(po|
00000af0  6c 6c 2b 34 34 29 3a f4  20 52 65 61 64 20 70 61  |ll+44):. Read pa|
00000b00  74 68 2d 6e 61 6d 65 20  6f 66 20 54 49 46 46 20  |th-name of TIFF |
00000b10  66 69 6c 65 20 74 6f 20  63 72 65 61 74 65 0d 03  |file to create..|
00000b20  20 1d 20 20 f2 68 6f 75  72 5f 6f 6e 3a f4 20 48  | .  .hour_on:. H|
00000b30  6f 75 72 67 6c 61 73 73  20 6f 6e 0d 03 2a 40 20  |ourglass on..*@ |
00000b40  20 f2 6d 61 6b 65 5f 54  49 46 46 28 74 79 70 65  | .make_TIFF(type|
00000b50  25 2c 49 6e 70 75 74 24  2c 4f 75 74 70 75 74 24  |%,Input$,Output$|
00000b60  2c 65 72 72 6f 72 24 29  3a f4 20 43 72 65 61 74  |,error$):. Creat|
00000b70  65 20 54 49 46 46 20 66  69 6c 65 0d 03 34 1f 20  |e TIFF file..4. |
00000b80  20 f2 68 6f 75 72 5f 6f  66 66 3a f4 20 48 6f 75  | .hour_off:. Hou|
00000b90  72 67 6c 61 73 73 20 6f  66 66 0d 03 3e 13 20 20  |rglass off..>.  |
00000ba0  e7 65 72 72 6f 72 24 3c  3e 22 22 20 8c 0d 03 48  |.error$<>"" ...H|
00000bb0  27 20 20 20 f2 65 72 72  6f 72 28 2d 31 2c 65 72  |'   .error(-1,er|
00000bc0  72 6f 72 24 29 3a f4 20  52 65 70 6f 72 74 20 65  |ror$):. Report e|
00000bd0  72 72 6f 72 0d 03 52 2f  20 20 20 c8 99 20 22 4f  |rror..R/   .. "O|
00000be0  53 5f 46 69 6c 65 22 2c  36 2c 4f 75 74 70 75 74  |S_File",6,Output|
00000bf0  24 3a f4 20 4b 69 6c 6c  20 6f 75 74 70 75 74 66  |$:. Kill outputf|
00000c00  69 6c 65 0d 03 5c 07 20  20 cd 0d 03 66 3e 20 20  |ile..\.  ...f>  |
00000c10  70 6f 6c 6c 21 31 32 3d  70 6f 6c 6c 21 38 3a 70  |poll!12=poll!8:p|
00000c20  6f 6c 6c 21 31 36 3d 33  3a f4 20 41 6d 65 6e 64  |oll!16=3:. Amend|
00000c30  20 64 61 74 61 20 62 6c  6f 63 6b 20 66 6f 72 20  | data block for |
00000c40  44 61 74 61 4c 6f 61 64  0d 03 70 31 20 20 c8 99  |DataLoad..p1  ..|
00000c50  20 57 53 65 6e 64 4d 73  67 25 2c 31 38 2c 70 6f  | WSendMsg%,18,po|
00000c60  6c 6c 2c 70 6f 6c 6c 21  34 3a f4 20 53 65 6e 64  |ll,poll!4:. Send|
00000c70  20 44 61 74 61 4c 6f 61  64 0d 03 7a 3f 20 20 44  | DataLoad..z?  D|
00000c80  61 74 61 4c 6f 61 64 52  65 66 25 3d 70 6f 6c 6c  |ataLoadRef%=poll|
00000c90  21 38 3a f4 20 41 77 61  69 74 20 61 20 44 61 74  |!8:. Await a Dat|
00000ca0  61 4c 6f 61 64 41 63 6b  2c 20 72 65 6d 65 6d 62  |aLoadAck, rememb|
00000cb0  65 72 20 6d 79 72 65 66  0d 03 84 34 20 c9 20 33  |er myref...4 . 3|
00000cc0  20 3a 20 f4 20 44 61 74  61 4c 6f 61 64 2c 20 63  | : . DataLoad, c|
00000cd0  68 65 63 6b 20 69 66 20  73 70 72 69 74 65 20 6f  |heck if sprite o|
00000ce0  72 20 43 6c 65 61 72 20  66 69 6c 65 0d 03 8e 1e  |r Clear file....|
00000cf0  20 20 74 79 70 65 25 3d  70 6f 6c 6c 21 34 30 3a  |  type%=poll!40:|
00000d00  f4 20 46 69 6c 65 74 79  70 65 0d 03 98 20 20 20  |. Filetype...   |
00000d10  e7 74 79 70 65 25 3d 26  46 46 39 20 84 20 74 79  |.type%=&FF9 . ty|
00000d20  70 65 25 3d 26 36 39 30  20 8c 0d 03 a2 38 20 20  |pe%=&690 ....8  |
00000d30  20 f4 20 53 70 72 69 74  65 20 6f 72 20 43 6c 65  | . Sprite or Cle|
00000d40  61 72 20 66 69 6c 65 2c  20 70 72 65 70 61 72 65  |ar file, prepare|
00000d50  20 74 6f 20 6d 61 6b 65  20 54 49 46 46 20 66 69  | to make TIFF fi|
00000d60  6c 65 0d 03 ac 29 20 20  20 49 6e 70 75 74 24 3d  |le...)   Input$=|
00000d70  a4 73 74 72 69 6e 67 28  70 6f 6c 6c 2b 34 34 29  |.string(poll+44)|
00000d80  3a f4 20 46 69 6c 65 6e  61 6d 65 0d 03 b6 38 20  |:. Filename...8 |
00000d90  20 20 f2 6f 70 65 6e 5f  77 69 6e 64 6f 77 28 77  |  .open_window(w|
00000da0  69 6e 5f 66 69 6c 65 25  2c 30 29 3a f4 20 4f 70  |in_file%,0):. Op|
00000db0  65 6e 20 73 61 76 65 20  66 69 6c 65 20 77 69 6e  |en save file win|
00000dc0  64 6f 77 0d 03 c0 49 20  20 20 70 6f 6c 6c 21 31  |dow...I   poll!1|
00000dd0  32 3d 70 6f 6c 6c 21 38  3a 70 6f 6c 6c 21 31 36  |2=poll!8:poll!16|
00000de0  3d 34 3a c8 99 20 57 53  65 6e 64 4d 73 67 25 2c  |=4:.. WSendMsg%,|
00000df0  31 37 2c 70 6f 6c 6c 2c  70 6f 6c 6c 21 34 3a f4  |17,poll,poll!4:.|
00000e00  20 44 61 74 61 4c 6f 61  64 41 63 6b 0d 03 ca 07  | DataLoadAck....|
00000e10  20 20 cd 0d 03 d4 29 20  c9 20 34 20 3a 20 f4 20  |  ....) . 4 : . |
00000e20  44 61 74 61 4c 6f 61 64  41 63 6b 2c 20 63 68 65  |DataLoadAck, che|
00000e30  63 6b 20 6f 72 20 69 67  6e 6f 72 65 0d 03 de 3c  |ck or ignore...<|
00000e40  20 20 e7 44 61 74 61 4c  6f 61 64 52 65 66 25 20  |  .DataLoadRef% |
00000e50  8c 20 e7 70 6f 6c 6c 21  31 32 3d 44 61 74 61 4c  |. .poll!12=DataL|
00000e60  6f 61 64 52 65 66 25 20  8c 20 44 61 74 61 4c 6f  |oadRef% . DataLo|
00000e70  61 64 52 65 66 25 3d a3  0d 03 e8 05 cb 0d 03 f2  |adRef%=.........|
00000e80  05 e1 0d 03 fc 04 0d 04  06 10 dd f2 6d 6f 75 73  |............mous|
00000e90  65 63 6c 69 63 6b 0d 04  10 3f 62 75 74 25 3d 70  |eclick...?but%=p|
00000ea0  6f 6c 6c 21 38 3a 77 69  6e 25 3d 70 6f 6c 6c 21  |oll!8:win%=poll!|
00000eb0  31 32 3a 69 63 6f 25 3d  70 6f 6c 6c 21 31 36 3a  |12:ico%=poll!16:|
00000ec0  f4 20 42 75 74 74 6f 6e  73 2f 77 69 6e 64 6f 77  |. Buttons/window|
00000ed0  2f 69 63 6f 6e 0d 04 1a  0d c8 8e 20 77 69 6e 25  |/icon...... win%|
00000ee0  20 ca 0d 04 24 1e 20 c9  20 2d 32 20 3a 20 f4 20  | ...$. . -2 : . |
00000ef0  43 6c 69 63 6b 20 6f 6e  20 69 63 6f 6e 62 61 72  |Click on iconbar|
00000f00  0d 04 2e 33 20 20 e7 69  63 6f 25 3d 49 69 63 6f  |...3  .ico%=Iico|
00000f10  6e 62 61 72 25 20 8c 20  e7 28 62 75 74 25 80 37  |nbar% . .(but%.7|
00000f20  29 3d 32 20 8c 20 f2 69  63 6f 6e 62 61 72 5f 6d  |)=2 . .iconbar_m|
00000f30  65 6e 75 0d 04 38 2e 20  c9 20 77 69 6e 5f 66 69  |enu..8. . win_fi|
00000f40  6c 65 25 20 3a 20 f4 20  43 6c 69 63 6b 20 6f 6e  |le% : . Click on|
00000f50  20 73 61 76 65 20 66 69  6c 65 20 77 69 6e 64 6f  | save file windo|
00000f60  77 0d 04 42 0f 20 20 e7  69 63 6f 25 3d 30 20 8c  |w..B.  .ico%=0 .|
00000f70  0d 04 4c 16 20 20 20 c8  8e 20 62 75 74 25 20 80  |..L.   .. but% .|
00000f80  20 26 37 46 20 ca 0d 04  56 39 20 20 20 20 c9 20  | &7F ...V9    . |
00000f90  31 36 2c 36 34 20 3a 20  f4 20 44 72 61 67 2c 63  |16,64 : . Drag,c|
00000fa0  61 6c 63 75 6c 61 74 65  20 64 72 61 67 20 62 6f  |alculate drag bo|
00000fb0  78 20 61 6e 64 20 63 72  65 61 74 65 20 69 74 0d  |x and create it.|
00000fc0  04 60 7a 20 20 20 20 20  53 63 72 57 25 3d a4 6d  |.`z     ScrW%=.m|
00000fd0  6f 64 65 5f 76 61 72 28  eb 2c 31 31 29 3c 3c a4  |ode_var(.,11)<<.|
00000fe0  6d 6f 64 65 5f 76 61 72  28 eb 2c 34 29 3a 53 63  |mode_var(.,4):Sc|
00000ff0  72 48 25 3d a4 6d 6f 64  65 5f 76 61 72 28 eb 2c  |rH%=.mode_var(.,|
00001000  31 32 29 3c 3c a4 6d 6f  64 65 5f 76 61 72 28 eb  |12)<<.mode_var(.|
00001010  2c 35 29 3a f4 20 53 63  72 65 65 6e 20 77 69 64  |,5):. Screen wid|
00001020  74 68 20 61 6e 64 20 68  65 69 67 68 74 20 69 6e  |th and height in|
00001030  20 4f 53 2d 75 6e 69 74  73 0d 04 6a e7 20 20 20  | OS-units..j.   |
00001040  20 20 21 62 6c 6f 63 6b  3d 77 69 6e 25 3a c8 99  |  !block=win%:..|
00001050  20 57 47 65 74 57 53 25  2c 2c 62 6c 6f 63 6b 3a  | WGetWS%,,block:|
00001060  78 25 3d 62 6c 6f 63 6b  21 34 3a 79 25 3d 62 6c  |x%=block!4:y%=bl|
00001070  6f 63 6b 21 38 3a 62 6c  6f 63 6b 21 34 3d 69 63  |ock!8:block!4=ic|
00001080  6f 25 3a c8 99 20 57 47  65 74 49 53 25 2c 2c 62  |o%:.. WGetIS%,,b|
00001090  6c 6f 63 6b 3a 21 62 6c  6f 63 6b 3d 77 69 6e 25  |lock:!block=win%|
000010a0  3a 62 6c 6f 63 6b 21 34  3d 35 3a 62 6c 6f 63 6b  |:block!4=5:block|
000010b0  21 38 2b 3d 78 25 3a 62  6c 6f 63 6b 21 31 32 2b  |!8+=x%:block!12+|
000010c0  3d 79 25 3a 62 6c 6f 63  6b 21 31 36 3d 62 6c 6f  |=y%:block!16=blo|
000010d0  63 6b 21 38 2b 36 38 3a  62 6c 6f 63 6b 21 32 30  |ck!8+68:block!20|
000010e0  3d 62 6c 6f 63 6b 21 31  32 2b 36 38 3a 62 6c 6f  |=block!12+68:blo|
000010f0  63 6b 21 32 34 3d 30 3a  62 6c 6f 63 6b 21 32 38  |ck!24=0:block!28|
00001100  3d 30 3a 62 6c 6f 63 6b  21 33 32 3d 53 63 72 57  |=0:block!32=ScrW|
00001110  25 3a 62 6c 6f 63 6b 21  33 36 3d 53 63 72 48 25  |%:block!36=ScrH%|
00001120  0d 04 74 2c 20 20 20 20  20 c8 99 20 57 44 72 61  |..t,     .. WDra|
00001130  67 42 25 2c 2c 62 6c 6f  63 6b 3a f4 20 43 72 65  |gB%,,block:. Cre|
00001140  61 74 65 20 64 72 61 67  20 62 6f 78 0d 04 7e 08  |ate drag box..~.|
00001150  20 20 20 cb 0d 04 88 07  20 20 cd 0d 04 92 05 cb  |   .....  ......|
00001160  0d 04 9c 05 e1 0d 04 a6  04 0d 04 b0 0e dd f2 64  |...............d|
00001170  72 61 67 64 72 6f 70 0d  04 ba 2c c8 99 20 57 47  |ragdrop...,.. WG|
00001180  65 74 50 49 25 2c 2c 62  6c 6f 63 6b 3a f4 20 47  |etPI%,,block:. G|
00001190  65 74 20 70 6f 69 6e 74  65 72 20 70 6f 73 69 74  |et pointer posit|
000011a0  69 6f 6e 0d 04 c4 47 64  72 6f 70 77 69 6e 25 3d  |ion...Gdropwin%=|
000011b0  62 6c 6f 63 6b 21 31 32  3a 64 72 6f 70 69 63 6f  |block!12:dropico|
000011c0  25 3d 62 6c 6f 63 6b 21  31 36 3a f4 20 57 69 6e  |%=block!16:. Win|
000011d0  64 6f 77 2f 69 63 6f 6e  20 77 68 65 72 65 20 62  |dow/icon where b|
000011e0  6f 78 20 64 72 6f 70 70  65 64 0d 04 ce 31 66 69  |ox dropped...1fi|
000011f0  6c 65 6e 61 6d 65 24 3d  a4 73 74 72 69 6e 67 28  |lename$=.string(|
00001200  53 41 56 66 6e 25 29 3a  f4 20 46 69 6c 65 6e 61  |SAVfn%):. Filena|
00001210  6d 65 20 66 6f 72 20 73  61 76 65 0d 04 d8 ad 62  |me for save....b|
00001220  6c 6f 63 6b 21 32 30 3d  62 6c 6f 63 6b 21 31 32  |lock!20=block!12|
00001230  3a 62 6c 6f 63 6b 21 32  34 3d 62 6c 6f 63 6b 21  |:block!24=block!|
00001240  31 36 3a 62 6c 6f 63 6b  21 32 38 3d 62 6c 6f 63  |16:block!28=bloc|
00001250  6b 21 30 3a 62 6c 6f 63  6b 21 33 32 3d 62 6c 6f  |k!0:block!32=blo|
00001260  63 6b 21 34 3a 62 6c 6f  63 6b 21 31 32 3d 30 3a  |ck!4:block!12=0:|
00001270  62 6c 6f 63 6b 21 31 36  3d 31 3a 62 6c 6f 63 6b  |block!16=1:block|
00001280  21 33 36 3d 30 3a 62 6c  6f 63 6b 21 34 30 3d 26  |!36=0:block!40=&|
00001290  46 46 39 3a 24 28 62 6c  6f 63 6b 2b 34 34 29 3d  |FF9:$(block+44)=|
000012a0  66 69 6c 65 6e 61 6d 65  24 2b bd 30 3a 21 62 6c  |filename$+.0:!bl|
000012b0  6f 63 6b 3d 28 34 34 2b  a9 66 69 6c 65 6e 61 6d  |ock=(44+.filenam|
000012c0  65 24 2b 34 29 80 ac 33  0d 04 e2 3b c8 99 20 57  |e$+4)..3...;.. W|
000012d0  53 65 6e 64 4d 73 67 25  2c 31 37 2c 62 6c 6f 63  |SendMsg%,17,bloc|
000012e0  6b 2c 64 72 6f 70 77 69  6e 25 2c 64 72 6f 70 69  |k,dropwin%,dropi|
000012f0  63 6f 25 3a f4 20 53 65  6e 64 20 44 61 74 61 53  |co%:. Send DataS|
00001300  61 76 65 0d 04 ec 36 44  61 74 61 53 61 76 65 52  |ave...6DataSaveR|
00001310  65 66 25 3d 62 6c 6f 63  6b 21 38 3a f4 20 52 65  |ef%=block!8:. Re|
00001320  6d 65 6d 62 65 72 20 6d  79 72 65 66 20 66 6f 72  |member myref for|
00001330  20 44 61 74 61 53 61 76  65 0d 04 f6 35 f2 63 6c  | DataSave...5.cl|
00001340  6f 73 65 5f 77 69 6e 64  6f 77 28 77 69 6e 5f 66  |ose_window(win_f|
00001350  69 6c 65 25 29 3a f4 20  43 6c 6f 73 65 20 73 61  |ile%):. Close sa|
00001360  76 65 20 66 69 6c 65 20  77 69 6e 64 6f 77 0d 05  |ve file window..|
00001370  00 05 e1 0d 05 0a 05 20  0d 05 14 30 dd f2 6d 61  |....... ...0..ma|
00001380  6b 65 5f 54 49 46 46 28  74 79 70 65 25 2c 49 6e  |ke_TIFF(type%,In|
00001390  46 69 6c 65 24 2c 4f 75  74 46 69 6c 65 24 2c f8  |File$,OutFile$,.|
000013a0  20 65 72 72 6f 72 24 29  0d 05 1e 27 f4 20 43 72  | error$)...'. Cr|
000013b0  65 61 74 65 73 20 54 49  46 46 20 66 69 6c 65 20  |eates TIFF file |
000013c0  4f 75 74 46 69 6c 65 24  20 66 72 6f 6d 20 3a 0d  |OutFile$ from :.|
000013d0  05 28 2e f4 20 28 74 79  70 65 25 3d 26 46 46 39  |.(.. (type%=&FF9|
000013e0  29 20 66 69 72 73 74 20  73 70 72 69 74 65 20 69  |) first sprite i|
000013f0  6e 20 73 70 72 69 74 65  20 66 69 6c 65 0d 05 32  |n sprite file..2|
00001400  26 f4 20 28 74 79 70 65  25 3d 26 36 39 30 29 20  |&. (type%=&690) |
00001410  69 6d 61 67 65 20 69 6e  20 43 6c 65 61 72 20 66  |image in Clear f|
00001420  69 6c 65 0d 05 3c 37 f4  20 52 65 74 75 72 6e 73  |ile..<7. Returns|
00001430  20 65 72 72 6f 72 20 69  6e 20 65 72 72 6f 72 24  | error in error$|
00001440  20 69 66 20 65 72 72 6f  72 20 6f 63 63 75 72 65  | if error occure|
00001450  64 2c 20 65 6c 73 65 20  22 22 0d 05 46 07 ea 20  |d, else ""..F.. |
00001460  85 0d 05 50 2e ee 20 85  20 ea 3a 65 72 72 6f 72  |...P.. . .:error|
00001470  24 3d f6 24 2b 22 20 28  63 6f 64 65 20 22 2b c3  |$=.$+" (code "+.|
00001480  9e 2b 22 29 22 3a f2 63  6c 6f 73 65 66 3a e1 0d  |.+")":.closef:..|
00001490  05 5a 3d 65 72 72 6f 72  24 3d 22 22 3a 49 6e 3d  |.Z=error$="":In=|
000014a0  30 3a 4f 75 74 3d 30 3a  f4 20 4e 6f 20 65 72 72  |0:Out=0:. No err|
000014b0  6f 72 73 20 28 79 65 74  29 2c 20 66 69 6c 65 73  |ors (yet), files|
000014c0  20 62 6f 74 68 20 63 6c  6f 73 65 64 0d 05 64 23  | both closed..d#|
000014d0  49 6e 3d 8e 28 49 6e 46  69 6c 65 24 29 3a f4 20  |In=.(InFile$):. |
000014e0  4f 70 65 6e 20 69 6e 70  75 74 20 66 69 6c 65 0d  |Open input file.|
000014f0  05 6e 0e c8 8e 20 74 79  70 65 25 20 ca 0d 05 78  |.n... type% ...x|
00001500  1b 20 c9 20 26 46 46 39  20 3a 20 f4 20 53 70 72  |. . &FF9 : . Spr|
00001510  69 74 65 20 66 69 6c 65  0d 05 82 43 20 20 c8 99  |ite file...C  ..|
00001520  20 22 4f 53 5f 47 42 50  42 22 2c 34 2c 49 6e 2c  | "OS_GBPB",4,In,|
00001530  48 65 61 64 25 2b 34 2c  48 65 61 64 73 69 7a 65  |Head%+4,Headsize|
00001540  25 3a f4 20 52 65 61 64  20 73 70 72 69 74 65 20  |%:. Read sprite |
00001550  66 69 6c 65 20 68 65 61  64 65 72 0d 05 8c 30 20  |file header...0 |
00001560  20 73 70 72 25 3d 48 65  61 64 25 2b 48 65 61 64  | spr%=Head%+Head|
00001570  25 21 38 3a f4 20 53 74  61 72 74 20 6f 66 20 66  |%!8:. Start of f|
00001580  69 72 73 74 20 73 70 72  69 74 65 0d 05 96 69 20  |irst sprite...i |
00001590  20 73 70 72 6e 61 6d 65  24 3d 22 22 3a 70 74 72  | sprname$="":ptr|
000015a0  25 3d 73 70 72 25 2b 34  3a c8 95 20 28 3f 70 74  |%=spr%+4:.. (?pt|
000015b0  72 25 3c 3e 30 29 20 80  20 28 a9 73 70 72 6e 61  |r%<>0) . (.sprna|
000015c0  6d 65 24 3c 31 32 29 3a  73 70 72 6e 61 6d 65 24  |me$<12):sprname$|
000015d0  2b 3d bd 28 3f 70 74 72  25 29 3a 70 74 72 25 2b  |+=.(?ptr%):ptr%+|
000015e0  3d 31 3a ce 3a f4 20 53  70 72 69 74 65 27 73 20  |=1:.:. Sprite's |
000015f0  6e 61 6d 65 0d 05 a0 49  20 20 77 6f 72 64 77 25  |name...I  wordw%|
00001600  3d 73 70 72 25 21 31 36  2b 31 3a 68 65 69 67 68  |=spr%!16+1:heigh|
00001610  74 25 3d 73 70 72 25 21  32 30 2b 31 3a f4 20 57  |t%=spr%!20+1:. W|
00001620  69 64 74 68 20 69 6e 20  77 6f 72 64 73 2c 20 68  |idth in words, h|
00001630  65 69 67 68 74 20 69 6e  20 72 6f 77 73 0d 05 aa  |eight in rows...|
00001640  4a 20 20 66 69 72 73 74  62 25 3d 73 70 72 25 21  |J  firstb%=spr%!|
00001650  32 34 3a 6c 61 73 74 62  25 3d 73 70 72 25 21 32  |24:lastb%=spr%!2|
00001660  38 3a f4 20 46 69 72 73  74 2f 6c 61 73 74 20 62  |8:. First/last b|
00001670  69 74 20 75 73 65 64 20  69 6e 20 62 6f 72 64 65  |it used in borde|
00001680  72 20 77 6f 72 64 73 0d  05 b4 31 20 20 69 6d 61  |r words...1  ima|
00001690  67 65 25 3d 73 70 72 25  2b 73 70 72 25 21 33 32  |ge%=spr%+spr%!32|
000016a0  3a f4 20 50 6f 69 6e 74  65 72 20 74 6f 20 69 6d  |:. Pointer to im|
000016b0  61 67 65 20 64 61 74 61  0d 05 be 48 20 20 6d 6f  |age data...H  mo|
000016c0  64 65 25 3d 73 70 72 25  21 34 30 3a 70 61 6c 65  |de%=spr%!40:pale|
000016d0  74 74 65 25 3d 73 70 72  25 2b 34 34 3a f4 20 53  |tte%=spr%+44:. S|
000016e0  70 72 69 74 65 27 73 20  6d 6f 64 65 2c 20 70 6f  |prite's mode, po|
000016f0  69 6e 74 65 72 20 74 6f  20 70 61 6c 65 74 74 65  |inter to palette|
00001700  0d 05 c8 34 20 20 63 6f  6c 62 69 74 73 25 3d 32  |...4  colbits%=2|
00001710  5e a4 6d 6f 64 65 5f 76  61 72 28 6d 6f 64 65 25  |^.mode_var(mode%|
00001720  2c 39 29 3a f4 20 42 69  74 73 20 70 65 72 20 70  |,9):. Bits per p|
00001730  69 78 65 6c 0d 05 d2 2d  20 20 63 6f 6c 6f 75 72  |ixel...-  colour|
00001740  73 25 3d 32 5e 63 6f 6c  62 69 74 73 25 3a f4 20  |s%=2^colbits%:. |
00001750  4e 75 6d 62 65 72 20 6f  66 20 63 6f 6c 6f 75 72  |Number of colour|
00001760  73 0d 05 dc 49 20 20 77  69 64 74 68 25 3d 28 77  |s...I  width%=(w|
00001770  6f 72 64 77 25 2a 33 32  2d 28 33 31 2d 6c 61 73  |ordw%*32-(31-las|
00001780  74 62 25 29 2d 66 69 72  73 74 62 25 29 20 81 20  |tb%)-firstb%) . |
00001790  63 6f 6c 62 69 74 73 25  3a f4 20 57 69 64 74 68  |colbits%:. Width|
000017a0  20 69 6e 20 70 69 78 65  6c 73 0d 05 e6 19 20 20  | in pixels....  |
000017b0  e7 69 6d 61 67 65 25 3c  3d 70 61 6c 65 74 74 65  |.image%<=palette|
000017c0  25 20 8c 0d 05 f0 34 20  20 20 f4 20 53 70 72 69  |% ....4   . Spri|
000017d0  74 65 20 68 61 73 20 6e  6f 20 70 61 6c 65 74 74  |te has no palett|
000017e0  65 20 3a 20 75 73 65 20  64 65 66 61 75 6c 74 20  |e : use default |
000017f0  70 61 6c 65 74 74 65 0d  05 fa 14 20 20 20 c8 8e  |palette....   ..|
00001800  20 63 6f 6c 6f 75 72 73  25 20 ca 0d 06 04 c8 20  | colours% ..... |
00001810  20 20 20 c9 20 32 35 36  20 3a 20 e3 20 63 25 3d  |   . 256 : . c%=|
00001820  30 20 b8 20 32 35 35 3a  72 25 3d 28 28 63 25 80  |0 . 255:r%=((c%.|
00001830  25 30 30 30 31 30 30 30  30 29 3e 3e 31 29 2b 28  |%00010000)>>1)+(|
00001840  63 25 80 25 30 30 30 30  30 31 30 30 29 2b 28 63  |c%.%00000100)+(c|
00001850  25 80 25 31 31 29 3a 67  25 3d 28 28 63 25 80 25  |%.%11):g%=((c%.%|
00001860  30 31 31 30 30 30 30 30  29 3e 3e 33 29 2b 28 63  |01100000)>>3)+(c|
00001870  25 80 25 31 31 29 3a 62  25 3d 28 28 63 25 80 25  |%.%11):b%=((c%.%|
00001880  31 30 30 30 30 30 30 30  29 3e 3e 34 29 2b 28 28  |10000000)>>4)+((|
00001890  63 25 80 25 30 30 30 30  31 30 30 30 29 3e 3e 31  |c%.%00001000)>>1|
000018a0  29 2b 28 63 25 80 25 31  31 29 3a 50 61 6c 65 74  |)+(c%.%11):Palet|
000018b0  74 65 25 28 63 25 29 3d  28 72 25 3c 3c 32 30 29  |te%(c%)=(r%<<20)|
000018c0  2b 28 67 25 3c 3c 31 32  29 2b 28 62 25 3c 3c 34  |+(g%<<12)+(b%<<4|
000018d0  29 3a ed 0d 06 0e 7d 20  20 20 20 c9 20 31 36 20  |):....}    . 16 |
000018e0  3a 20 50 61 6c 65 74 74  65 25 28 29 3d 30 2c 26  |: Palette%()=0,&|
000018f0  46 30 30 30 30 30 2c 26  46 30 30 30 2c 26 46 30  |F00000,&F000,&F0|
00001900  46 30 30 30 2c 26 46 30  2c 26 46 30 30 30 46 30  |F000,&F0,&F000F0|
00001910  2c 26 46 30 46 30 2c 26  46 30 46 30 46 30 2c 30  |,&F0F0,&F0F0F0,0|
00001920  2c 26 46 30 30 30 30 30  2c 26 46 30 30 30 2c 26  |,&F00000,&F000,&|
00001930  46 30 46 30 30 30 2c 26  46 30 2c 26 46 30 30 30  |F0F000,&F0,&F000|
00001940  46 30 2c 26 46 30 46 30  2c 26 46 30 46 30 46 30  |F0,&F0F0,&F0F0F0|
00001950  0d 06 18 32 20 20 20 20  c9 20 34 20 3a 20 50 61  |...2    . 4 : Pa|
00001960  6c 65 74 74 65 25 28 29  3d 30 2c 26 46 30 30 30  |lette%()=0,&F000|
00001970  30 30 2c 26 46 30 46 30  30 30 2c 26 46 30 46 30  |00,&F0F000,&F0F0|
00001980  46 30 0d 06 22 22 20 20  20 20 c9 20 32 20 3a 20  |F0..""    . 2 : |
00001990  50 61 6c 65 74 74 65 25  28 29 3d 30 2c 26 46 30  |Palette%()=0,&F0|
000019a0  46 30 46 30 0d 06 2c 08  20 20 20 cb 0d 06 36 23  |F0F0..,.   ...6#|
000019b0  20 20 cc 20 f4 20 52 65  61 64 20 73 70 72 69 74  |  . . Read sprit|
000019c0  65 27 73 20 6f 77 6e 20  70 61 6c 65 74 74 65 0d  |e's own palette.|
000019d0  06 40 16 20 20 20 e7 63  6f 6c 6f 75 72 73 25 3c  |.@.   .colours%<|
000019e0  3d 31 36 20 8c 0d 06 4a  25 20 20 20 20 f4 20 41  |=16 ...J%    . A|
000019f0  6c 6c 20 70 61 6c 65 74  74 65 20 65 6e 74 72 69  |ll palette entri|
00001a00  65 73 20 70 72 65 73 65  6e 74 0d 06 54 45 20 20  |es present..TE  |
00001a10  20 20 e3 20 63 25 3d 30  20 b8 20 63 6f 6c 6f 75  |  . c%=0 . colou|
00001a20  72 73 25 2d 31 3a 50 61  6c 65 74 74 65 25 28 63  |rs%-1:Palette%(c|
00001a30  25 29 3d a4 70 61 6c 74  6f 72 67 62 28 70 61 6c  |%)=.paltorgb(pal|
00001a40  65 74 74 65 25 21 28 63  25 2a 38 29 29 3a ed 0d  |ette%!(c%*8)):..|
00001a50  06 5e 44 20 20 20 cc 20  f4 20 4f 6e 6c 79 20 36  |.^D   . . Only 6|
00001a60  34 20 70 61 6c 65 74 74  65 20 65 6e 74 72 69 65  |4 palette entrie|
00001a70  73 20 70 72 65 73 65 6e  74 2c 20 64 65 64 75 63  |s present, deduc|
00001a80  65 20 61 6c 6c 20 66 72  6f 6d 20 66 69 72 73 74  |e all from first|
00001a90  20 31 36 0d 06 68 90 20  20 20 20 e3 20 63 25 3d  | 16..h.    . c%=|
00001aa0  30 20 b8 20 31 35 3a 50  61 6c 65 74 74 65 25 28  |0 . 15:Palette%(|
00001ab0  63 25 29 3d a4 70 61 6c  74 6f 72 67 62 28 70 61  |c%)=.paltorgb(pa|
00001ac0  6c 65 74 74 65 25 21 28  63 25 2a 38 29 29 3a ed  |lette%!(c%*8)):.|
00001ad0  3a e3 20 63 25 3d 31 36  20 b8 20 32 35 35 3a 50  |:. c%=16 . 255:P|
00001ae0  61 6c 65 74 74 65 25 28  63 25 29 3d 50 61 6c 65  |alette%(c%)=Pale|
00001af0  74 74 65 25 28 63 25 80  31 35 29 2b 28 63 25 80  |tte%(c%.15)+(c%.|
00001b00  26 38 30 29 2b 28 28 63  25 80 26 36 30 29 3c 3c  |&80)+((c%.&60)<<|
00001b10  39 29 2b 28 28 63 25 80  26 31 30 29 3c 3c 31 39  |9)+((c%.&10)<<19|
00001b20  29 3a ed 0d 06 72 08 20  20 20 cd 0d 06 7c 07 20  |):...r.   ...|. |
00001b30  20 cd 0d 06 86 48 20 20  78 65 69 67 25 3d a4 6d  | ....H  xeig%=.m|
00001b40  6f 64 65 5f 76 61 72 28  6d 6f 64 65 25 2c 34 29  |ode_var(mode%,4)|
00001b50  3a 79 65 69 67 25 3d a4  6d 6f 64 65 5f 76 61 72  |:yeig%=.mode_var|
00001b60  28 6d 6f 64 65 25 2c 35  29 3a f4 20 58 2f 59 65  |(mode%,5):. X/Ye|
00001b70  69 67 20 66 61 63 74 6f  72 73 0d 06 90 44 20 20  |ig factors...D  |
00001b80  72 65 73 64 69 76 78 25  3d 32 5e 78 65 69 67 25  |resdivx%=2^xeig%|
00001b90  3a 72 65 73 64 69 76 79  25 3d 32 5e 79 65 69 67  |:resdivy%=2^yeig|
00001ba0  25 3a f4 20 44 69 76 69  73 6f 72 73 20 66 6f 72  |%:. Divisors for|
00001bb0  20 58 2f 59 52 65 73 6f  6c 75 74 69 6f 6e 0d 06  | X/YResolution..|
00001bc0  9a 29 20 20 52 65 73 6f  6c 75 74 69 6f 6e 46 61  |.)  ResolutionFa|
00001bd0  63 73 3d b9 3a f4 20 46  61 63 74 6f 72 73 20 73  |cs=.:. Factors s|
00001be0  75 70 70 6c 69 65 64 0d  06 a4 28 20 20 72 6f 77  |upplied...(  row|
00001bf0  62 79 74 65 73 25 3d 77  6f 72 64 77 25 2a 34 3a  |bytes%=wordw%*4:|
00001c00  f4 20 42 79 74 65 73 20  70 65 72 20 72 6f 77 0d  |. Bytes per row.|
00001c10  06 ae 34 20 20 64 61 74  61 70 74 72 25 3d 69 6d  |..4  dataptr%=im|
00001c20  61 67 65 25 2d 48 65 61  64 25 2d 34 3a f4 20 4f  |age%-Head%-4:. O|
00001c30  66 66 73 65 74 20 74 6f  20 69 6d 61 67 65 20 64  |ffset to image d|
00001c40  61 74 61 0d 06 b8 1a 20  c9 20 26 36 39 30 20 3a  |ata.... . &690 :|
00001c50  20 f4 20 43 6c 65 61 72  20 66 69 6c 65 0d 06 c2  | . Clear file...|
00001c60  40 20 20 c8 99 20 22 4f  53 5f 47 42 50 42 22 2c  |@  .. "OS_GBPB",|
00001c70  34 2c 49 6e 2c 48 65 61  64 25 2c 48 65 61 64 73  |4,In,Head%,Heads|
00001c80  69 7a 65 25 3a f4 20 52  65 61 64 20 43 6c 65 61  |ize%:. Read Clea|
00001c90  72 20 66 69 6c 65 20 68  65 61 64 65 72 0d 06 cc  |r file header...|
00001ca0  70 20 20 70 74 72 25 3d  48 65 61 64 25 3a 6d 61  |p  ptr%=Head%:ma|
00001cb0  6b 65 72 24 3d 22 22 3a  c8 95 20 3f 70 74 72 25  |ker$="":.. ?ptr%|
00001cc0  3e 3d 97 22 20 22 3a 6d  61 6b 65 72 24 2b 3d bd  |>=." ":maker$+=.|
00001cd0  28 3f 70 74 72 25 29 3a  70 74 72 25 2b 3d 31 3a  |(?ptr%):ptr%+=1:|
00001ce0  ce 3a 76 65 72 73 69 6f  6e 25 3d 70 74 72 25 21  |.:version%=ptr%!|
00001cf0  31 3a 70 74 72 25 2b 3d  35 3a f4 20 4d 61 6b 65  |1:ptr%+=5:. Make|
00001d00  72 20 61 6e 64 20 76 65  72 73 69 6f 6e 0d 06 d6  |r and version...|
00001d10  a5 20 20 e7 6d 61 6b 65  72 24 3d 22 54 72 61 6e  |.  .maker$="Tran|
00001d20  73 6c 61 74 6f 72 22 20  8c 20 e7 76 65 72 73 69  |slator" . .versi|
00001d30  6f 6e 25 3d 36 30 30 20  8b 20 65 72 72 6f 72 24  |on%=600 . error$|
00001d40  3d 22 49 20 63 61 6e 6e  6f 74 20 68 61 6e 64 6c  |="I cannot handl|
00001d50  65 20 74 68 69 73 20 43  6c 65 61 72 20 66 69 6c  |e this Clear fil|
00001d60  65 20 66 72 6f 6d 20 27  22 2b 6d 61 6b 65 72 24  |e from '"+maker$|
00001d70  2b 22 27 20 76 65 72 73  69 6f 6e 20 22 2b c3 28  |+"' version "+.(|
00001d80  76 65 72 73 69 6f 6e 25  81 31 30 30 29 2b 22 2e  |version%.100)+".|
00001d90  22 2b c2 22 30 22 2b c3  28 76 65 72 73 69 6f 6e  |"+."0"+.(version|
00001da0  25 83 31 30 30 29 2c 32  29 2b 22 20 21 21 21 22  |%.100),2)+" !!!"|
00001db0  3a e1 0d 06 e0 47 20 20  77 69 64 74 68 25 3d 21  |:....G  width%=!|
00001dc0  70 74 72 25 3a 68 65 69  67 68 74 25 3d 70 74 72  |ptr%:height%=ptr|
00001dd0  25 21 34 3a 63 6f 6c 62  69 74 73 25 3d 70 74 72  |%!4:colbits%=ptr|
00001de0  25 21 38 3a 70 74 72 25  2b 3d 31 32 3a f4 20 52  |%!8:ptr%+=12:. R|
00001df0  65 73 6f 6c 75 74 69 6f  6e 0d 06 ea 44 20 20 e7  |esolution...D  .|
00001e00  63 6f 6c 62 69 74 73 25  3e 38 20 8c 20 65 72 72  |colbits%>8 . err|
00001e10  6f 72 24 3d 22 49 20 63  61 6e 6e 6f 74 20 68 61  |or$="I cannot ha|
00001e20  6e 64 6c 65 20 70 75 72  65 20 52 47 42 20 43 6c  |ndle pure RGB Cl|
00001e30  65 61 72 20 66 69 6c 65  73 2e 22 3a e1 0d 06 f4  |ear files.":....|
00001e40  2c 20 20 63 6f 6c 6f 75  72 73 25 3d 32 5e 63 6f  |,  colours%=2^co|
00001e50  6c 62 69 74 73 25 3a f4  20 43 6f 6c 6f 75 72 73  |lbits%:. Colours|
00001e60  20 69 6e 20 69 6d 61 67  65 0d 06 fe 62 20 20 e3  | in image...b  .|
00001e70  20 63 25 3d 30 20 b8 20  63 6f 6c 6f 75 72 73 25  | c%=0 . colours%|
00001e80  2d 31 3a 50 61 6c 65 74  74 65 25 28 63 25 29 3d  |-1:Palette%(c%)=|
00001e90  28 28 3f 70 74 72 25 29  3c 3c 31 36 29 2b 28 28  |((?ptr%)<<16)+((|
00001ea0  70 74 72 25 3f 31 29 3c  3c 38 29 2b 70 74 72 25  |ptr%?1)<<8)+ptr%|
00001eb0  3f 32 3a 70 74 72 25 2b  3d 33 3a ed 3a f4 20 52  |?2:ptr%+=3:.:. R|
00001ec0  65 61 64 20 70 61 6c 65  74 74 65 0d 07 08 28 20  |ead palette...( |
00001ed0  20 52 65 73 6f 6c 75 74  69 6f 6e 46 61 63 73 3d  | ResolutionFacs=|
00001ee0  a3 3a f4 20 46 61 63 74  6f 72 73 20 75 6e 6b 6e  |.:. Factors unkn|
00001ef0  6f 77 6e 0d 07 12 30 20  20 64 61 74 61 70 74 72  |own...0  dataptr|
00001f00  25 3d 70 74 72 25 2d 48  65 61 64 25 3a f4 20 4f  |%=ptr%-Head%:. O|
00001f10  66 66 73 65 74 20 74 6f  20 69 6d 61 67 65 20 64  |ffset to image d|
00001f20  61 74 61 0d 07 1c 26 20  20 72 6f 77 62 79 74 65  |ata...&  rowbyte|
00001f30  73 25 3d 77 69 64 74 68  25 3a f4 20 42 79 74 65  |s%=width%:. Byte|
00001f40  73 20 70 65 72 20 72 6f  77 0d 07 26 05 cb 0d 07  |s per row..&....|
00001f50  30 30 62 79 74 65 77 25  3d 28 77 69 64 74 68 25  |00bytew%=(width%|
00001f60  2a 63 6f 6c 62 69 74 73  25 2b 37 29 81 38 3a f4  |*colbits%+7).8:.|
00001f70  20 42 79 74 65 73 20 70  65 72 20 72 6f 77 0d 07  | Bytes per row..|
00001f80  3a 3e 72 6f 77 73 70 65  72 73 74 72 69 70 25 3d  |:>rowsperstrip%=|
00001f90  38 31 39 32 20 81 20 62  79 74 65 77 25 3a f4 20  |8192 . bytew%:. |
00001fa0  4d 61 6b 65 20 73 74 72  69 70 73 20 61 62 6f 75  |Make strips abou|
00001fb0  74 20 38 4b 20 69 6e 20  73 69 7a 65 0d 07 44 46  |t 8K in size..DF|
00001fc0  e7 72 6f 77 73 70 65 72  73 74 72 69 70 25 3e 68  |.rowsperstrip%>h|
00001fd0  65 69 67 68 74 25 20 8c  20 72 6f 77 73 70 65 72  |eight% . rowsper|
00001fe0  73 74 72 69 70 25 3d 68  65 69 67 68 74 25 3a f4  |strip%=height%:.|
00001ff0  20 48 65 69 67 68 74 20  69 73 20 6d 61 78 69 6d  | Height is maxim|
00002000  75 6d 0d 07 4e 48 73 74  72 69 70 73 25 3d 28 68  |um..NHstrips%=(h|
00002010  65 69 67 68 74 25 2b 72  6f 77 73 70 65 72 73 74  |eight%+rowsperst|
00002020  72 69 70 25 2d 31 29 20  81 20 72 6f 77 73 70 65  |rip%-1) . rowspe|
00002030  72 73 74 72 69 70 25 3a  f4 20 4e 75 6d 62 65 72  |rstrip%:. Number|
00002040  20 6f 66 20 73 74 72 69  70 73 0d 07 58 31 73 74  | of strips..X1st|
00002050  72 69 70 6c 65 6e 25 3d  72 6f 77 73 70 65 72 73  |riplen%=rowspers|
00002060  74 72 69 70 25 2a 62 79  74 65 77 25 3a f4 20 53  |trip%*bytew%:. S|
00002070  74 72 69 70 20 6c 65 6e  67 74 68 0d 07 62 2a cf  |trip length..b*.|
00002080  23 49 6e 3d 64 61 74 61  70 74 72 25 3a f4 20 54  |#In=dataptr%:. T|
00002090  6f 20 73 74 61 72 74 20  6f 66 20 69 6d 61 67 65  |o start of image|
000020a0  20 64 61 74 61 0d 07 6c  2b 4f 75 74 3d ae 28 4f  | data..l+Out=.(O|
000020b0  75 74 46 69 6c 65 24 29  3a f4 20 4f 70 65 6e 20  |utFile$):. Open |
000020c0  6f 75 74 70 75 74 20 54  49 46 46 20 66 69 6c 65  |output TIFF file|
000020d0  0d 07 76 32 f2 6f 75 74  73 28 22 49 49 22 29 3a  |..v2.outs("II"):|
000020e0  f4 20 4c 6f 77 2d 74 6f  2d 68 69 67 68 20 62 79  |. Low-to-high by|
000020f0  74 65 20 6f 72 64 65 72  20 54 49 46 46 20 66 69  |te order TIFF fi|
00002100  6c 65 0d 07 80 23 f2 6f  75 74 64 28 34 32 29 3a  |le...#.outd(42):|
00002110  f4 20 54 49 46 46 20 76  65 72 73 69 6f 6e 20 6e  |. TIFF version n|
00002120  75 6d 62 65 72 0d 07 8a  33 f2 6f 75 74 77 28 38  |umber...3.outw(8|
00002130  29 3a f4 20 4f 66 66 73  65 74 20 74 6f 20 49 6d  |):. Offset to Im|
00002140  61 67 65 20 46 69 6c 65  20 44 69 72 65 63 74 6f  |age File Directo|
00002150  72 79 20 28 49 46 44 29  0d 07 94 3d e7 52 65 73  |ry (IFD)...=.Res|
00002160  6f 6c 75 74 69 6f 6e 46  61 63 73 20 8c 20 65 6e  |olutionFacs . en|
00002170  74 72 69 65 73 25 3d 31  33 20 8b 20 65 6e 74 72  |tries%=13 . entr|
00002180  69 65 73 25 3d 31 30 3a  f4 20 49 46 44 20 65 6e  |ies%=10:. IFD en|
00002190  74 72 69 65 73 0d 07 9e  2b f2 6f 75 74 64 28 65  |tries...+.outd(e|
000021a0  6e 74 72 69 65 73 25 29  3a f4 20 4e 75 6d 62 65  |ntries%):. Numbe|
000021b0  72 20 6f 66 20 49 46 44  20 65 6e 74 72 69 65 73  |r of IFD entries|
000021c0  0d 07 a8 3d 69 70 74 72  25 3d 31 32 2a 65 6e 74  |...=iptr%=12*ent|
000021d0  72 69 65 73 25 2b 34 2b  8f 23 4f 75 74 3a f4 20  |ries%+4+.#Out:. |
000021e0  49 6e 69 74 69 61 6c 69  73 65 20 69 6e 66 6f 20  |Initialise info |
000021f0  62 6c 6f 63 6b 20 70 6f  69 6e 74 65 72 0d 07 b2  |block pointer...|
00002200  33 f2 6f 75 74 49 46 44  28 32 35 36 2c 34 2c 31  |3.outIFD(256,4,1|
00002210  2c 77 69 64 74 68 25 29  3a f4 20 49 6d 61 67 65  |,width%):. Image|
00002220  20 77 69 64 74 68 20 69  6e 20 70 69 78 65 6c 73  | width in pixels|
00002230  0d 07 bc 35 f2 6f 75 74  49 46 44 28 32 35 37 2c  |...5.outIFD(257,|
00002240  34 2c 31 2c 68 65 69 67  68 74 25 29 3a f4 20 49  |4,1,height%):. I|
00002250  6d 61 67 65 20 68 65 69  67 68 74 20 69 6e 20 70  |mage height in p|
00002260  69 78 65 6c 73 0d 07 c6  2f f2 6f 75 74 49 46 44  |ixels.../.outIFD|
00002270  28 32 35 38 2c 33 2c 31  2c 63 6f 6c 62 69 74 73  |(258,3,1,colbits|
00002280  25 29 3a f4 20 42 69 74  73 20 70 65 72 20 73 61  |%):. Bits per sa|
00002290  6d 70 6c 65 0d 07 d0 36  f2 6f 75 74 49 46 44 28  |mple...6.outIFD(|
000022a0  32 35 39 2c 33 2c 31 2c  31 29 3a f4 20 43 6f 6d  |259,3,1,1):. Com|
000022b0  70 72 65 73 73 69 6f 6e  20 28 6e 6f 6e 65 20 61  |pression (none a|
000022c0  74 20 70 72 65 73 65 6e  74 29 0d 07 da 44 f2 6f  |t present)...D.o|
000022d0  75 74 49 46 44 28 32 36  32 2c 33 2c 31 2c 33 29  |utIFD(262,3,1,3)|
000022e0  3a f4 20 50 68 6f 74 6f  6d 65 74 72 69 63 20 69  |:. Photometric i|
000022f0  6e 74 65 72 70 72 65 74  61 74 69 6f 6e 20 28 50  |nterpretation (P|
00002300  61 6c 65 74 74 65 20 63  6f 6c 6f 75 72 29 0d 07  |alette colour)..|
00002310  e4 49 f2 6f 75 74 49 46  44 28 32 36 36 2c 33 2c  |.I.outIFD(266,3,|
00002320  31 2c 31 29 3a f4 20 46  69 6c 6c 6f 72 64 65 72  |1,1):. Fillorder|
00002330  20 28 68 69 67 68 20 62  69 74 73 20 66 69 72 73  | (high bits firs|
00002340  74 2c 20 69 74 27 73 20  27 72 65 63 6f 6d 6d 65  |t, it's 'recomme|
00002350  6e 64 65 64 27 21 29 0d  07 ee 2d f2 6f 75 74 49  |nded'!)...-.outI|
00002360  46 44 28 32 37 33 2c 34  2c 73 74 72 69 70 73 25  |FD(273,4,strips%|
00002370  2c 2d 31 29 3a f4 20 53  74 72 69 70 20 6f 66 66  |,-1):. Strip off|
00002380  73 65 74 73 0d 07 f8 2a  f2 6f 75 74 49 46 44 28  |sets...*.outIFD(|
00002390  32 37 37 2c 33 2c 31 2c  31 29 3a f4 20 53 61 6d  |277,3,1,1):. Sam|
000023a0  70 6c 65 73 20 70 65 72  20 70 69 78 65 6c 0d 08  |ples per pixel..|
000023b0  02 33 f2 6f 75 74 49 46  44 28 32 37 38 2c 34 2c  |.3.outIFD(278,4,|
000023c0  31 2c 72 6f 77 73 70 65  72 73 74 72 69 70 25 29  |1,rowsperstrip%)|
000023d0  3a f4 20 52 6f 77 73 20  70 65 72 20 73 74 72 69  |:. Rows per stri|
000023e0  70 0d 08 0c 38 f4 20 58  20 72 65 73 6f 6c 75 74  |p...8. X resolut|
000023f0  69 6f 6e 2c 20 59 20 72  65 73 6f 6c 75 74 69 6f  |ion, Y resolutio|
00002400  6e 2c 20 72 65 73 6f 6c  75 74 69 6f 6e 20 75 6e  |n, resolution un|
00002410  69 74 20 28 69 6e 63 68  29 0d 08 16 50 e7 52 65  |it (inch)...P.Re|
00002420  73 6f 6c 75 74 69 6f 6e  46 61 63 73 20 8c 20 f2  |solutionFacs . .|
00002430  6f 75 74 49 46 44 28 32  38 32 2c 35 2c 31 2c 2d  |outIFD(282,5,1,-|
00002440  31 29 3a f2 6f 75 74 49  46 44 28 32 38 33 2c 35  |1):.outIFD(283,5|
00002450  2c 31 2c 2d 31 29 3a f2  6f 75 74 49 46 44 28 32  |,1,-1):.outIFD(2|
00002460  39 36 2c 33 2c 31 2c 32  29 0d 08 20 2d f2 6f 75  |96,3,1,2).. -.ou|
00002470  74 49 46 44 28 33 32 30  2c 33 2c 33 2a 63 6f 6c  |tIFD(320,3,3*col|
00002480  6f 75 72 73 25 2c 2d 31  29 3a f4 20 43 6f 6c 6f  |ours%,-1):. Colo|
00002490  75 72 20 6d 61 70 0d 08  2a 1a f2 6f 75 74 77 28  |ur map..*..outw(|
000024a0  30 29 3a f4 20 4e 6f 20  6e 65 78 74 20 49 46 44  |0):. No next IFD|
000024b0  0d 08 34 28 f4 20 41 72  72 69 76 65 64 20 61 74  |..4(. Arrived at|
000024c0  20 69 6e 66 6f 20 62 6c  6f 63 6b 73 2c 20 77 72  | info blocks, wr|
000024d0  69 74 65 20 64 61 74 61  0d 08 3e 3e e3 20 73 25  |ite data..>>. s%|
000024e0  3d 31 20 b8 20 73 74 72  69 70 73 25 3a f2 6f 75  |=1 . strips%:.ou|
000024f0  74 77 28 a4 69 70 74 72  28 73 74 72 69 70 6c 65  |tw(.iptr(striple|
00002500  6e 25 29 29 3a ed 3a f4  20 53 74 72 69 70 20 6f  |n%)):.:. Strip o|
00002510  66 66 73 65 74 73 0d 08  48 63 e7 52 65 73 6f 6c  |ffsets..Hc.Resol|
00002520  75 74 69 6f 6e 46 61 63  73 20 8c 20 f2 6f 75 74  |utionFacs . .out|
00002530  77 28 31 38 30 29 3a f2  6f 75 74 77 28 72 65 73  |w(180):.outw(res|
00002540  64 69 76 78 25 29 3a f2  6f 75 74 77 28 31 38 30  |divx%):.outw(180|
00002550  29 3a f2 6f 75 74 77 28  72 65 73 64 69 76 79 25  |):.outw(resdivy%|
00002560  29 3a f4 20 31 38 30 20  4f 53 20 75 6e 69 74 73  |):. 180 OS units|
00002570  20 70 65 72 20 69 6e 63  68 0d 08 52 6c e3 20 72  | per inch..Rl. r|
00002580  67 62 25 3d 31 36 20 b8  20 30 20 88 20 2d 38 3a  |gb%=16 . 0 . -8:|
00002590  e3 20 63 25 3d 30 20 b8  20 63 6f 6c 6f 75 72 73  |. c%=0 . colours|
000025a0  25 2d 31 3a 76 25 3d 28  50 61 6c 65 74 74 65 25  |%-1:v%=(Palette%|
000025b0  28 63 25 29 3e 3e 3e 72  67 62 25 29 80 26 46 46  |(c%)>>>rgb%).&FF|
000025c0  3a f2 6f 75 74 64 28 76  25 3c 3c 38 29 3a ed 3a  |:.outd(v%<<8):.:|
000025d0  ed 3a f4 20 4f 75 74 70  75 74 20 63 6f 6c 6f 75  |.:. Output colou|
000025e0  72 20 6d 61 70 0d 08 5c  31 21 62 69 74 73 3d 63  |r map..\1!bits=c|
000025f0  6f 6c 62 69 74 73 25 3a  21 74 79 70 65 3d 74 79  |olbits%:!type=ty|
00002600  70 65 25 3a f4 20 4d 61  63 68 69 6e 65 63 6f 64  |pe%:. Machinecod|
00002610  65 20 69 6e 66 6f 0d 08  66 69 e7 74 79 70 65 25  |e info..fi.type%|
00002620  3d 26 46 46 39 20 8c 20  21 6c 65 66 74 3d 66 69  |=&FF9 . !left=fi|
00002630  72 73 74 62 25 3a 21 77  6f 72 64 73 3d 77 6f 72  |rstb%:!words=wor|
00002640  64 77 25 3a d6 20 6d 61  6b 65 5f 6d 61 70 20 8b  |dw%:. make_map .|
00002650  20 21 77 69 64 74 68 3d  77 69 64 74 68 25 3a f4  | !width=width%:.|
00002660  20 4d 6f 72 65 20 73 70  65 63 69 66 69 63 20 6d  | More specific m|
00002670  61 63 68 69 6e 65 63 6f  64 65 20 69 6e 66 6f 0d  |achinecode info.|
00002680  08 70 14 e3 20 72 25 3d  31 20 b8 20 68 65 69 67  |.p.. r%=1 . heig|
00002690  68 74 25 0d 08 7a 31 c8  99 20 22 4f 53 5f 47 42  |ht%..z1.. "OS_GB|
000026a0  50 42 22 2c 34 2c 49 6e  2c 52 6f 77 42 66 25 2c  |PB",4,In,RowBf%,|
000026b0  72 6f 77 62 79 74 65 73  25 3a f4 20 52 65 61 64  |rowbytes%:. Read|
000026c0  20 72 6f 77 0d 08 84 29  d6 20 63 6f 6e 76 65 72  | row...). conver|
000026d0  74 3a f4 20 43 6f 6e 76  65 72 74 20 72 6f 77 20  |t:. Convert row |
000026e0  64 61 74 61 20 66 6f 72  20 54 49 46 46 0d 08 8e  |data for TIFF...|
000026f0  30 c8 99 20 22 4f 53 5f  47 42 50 42 22 2c 32 2c  |0.. "OS_GBPB",2,|
00002700  4f 75 74 2c 52 6f 77 42  66 25 2c 62 79 74 65 77  |Out,RowBf%,bytew|
00002710  25 3a f4 20 57 72 69 74  65 20 72 6f 77 0d 08 98  |%:. Write row...|
00002720  05 ed 0d 08 a2 1b d9 23  49 6e 3a f4 20 43 6c 6f  |.......#In:. Clo|
00002730  73 65 20 69 6e 70 75 74  20 66 69 6c 65 0d 08 ac  |se input file...|
00002740  1b d9 23 4f 75 74 3a f4  20 43 6c 6f 73 65 20 54  |..#Out:. Close T|
00002750  49 46 46 20 66 69 6c 65  0d 08 b6 42 c8 99 20 22  |IFF file...B.. "|
00002760  4f 53 5f 43 4c 49 22 2c  22 53 65 74 54 79 70 65  |OS_CLI","SetType|
00002770  20 22 2b 4f 75 74 46 69  6c 65 24 2b 22 20 46 46  | "+OutFile$+" FF|
00002780  30 22 3a f4 20 46 69 6c  65 74 79 70 65 20 61 73  |0":. Filetype as|
00002790  20 54 49 46 46 20 66 69  6c 65 0d 08 c0 05 e1 0d  | TIFF file......|
000027a0  08 ca 05 20 0d 08 d4 0c  dd f2 63 6c 6f 73 65 66  |... ......closef|
000027b0  0d 08 de 1b f4 20 43 6c  6f 73 65 73 20 66 69 6c  |..... Closes fil|
000027c0  65 73 20 6f 6e 20 65 72  72 6f 72 0d 08 e8 10 e7  |es on error.....|
000027d0  49 6e 3e 30 20 8c 20 d9  23 49 6e 0d 08 f2 12 e7  |In>0 . .#In.....|
000027e0  4f 75 74 3e 30 20 8c 20  d9 23 4f 75 74 0d 08 fc  |Out>0 . .#Out...|
000027f0  05 e1 0d 09 06 05 20 0d  09 10 11 dd a4 69 70 74  |...... ......ipt|
00002800  72 28 72 6f 6f 6d 25 29  0d 09 1a 32 f4 20 52 65  |r(room%)...2. Re|
00002810  74 75 72 6e 73 20 66 69  6c 65 20 70 6f 69 6e 74  |turns file point|
00002820  65 72 20 74 6f 20 62 6c  6f 63 6b 20 6f 66 20 72  |er to block of r|
00002830  6f 6f 6d 25 20 62 79 74  65 73 0d 09 24 1d 69 70  |oom% bytes..$.ip|
00002840  74 72 25 2b 3d 72 6f 6f  6d 25 3a 3d 69 70 74 72  |tr%+=room%:=iptr|
00002850  25 2d 72 6f 6f 6d 25 0d  09 2e 05 20 0d 09 38 27  |%-room%.... ..8'|
00002860  dd f2 6f 75 74 49 46 44  28 74 61 67 25 2c 74 79  |..outIFD(tag%,ty|
00002870  70 65 25 2c 6c 65 6e 67  74 68 25 2c 76 61 6c 75  |pe%,length%,valu|
00002880  65 25 29 0d 09 42 22 f4  20 4f 75 74 70 75 74 73  |e%)..B". Outputs|
00002890  20 49 46 44 20 65 6e 74  72 79 20 74 6f 20 6f 75  | IFD entry to ou|
000028a0  74 66 69 6c 65 0d 09 4c  0c ea 20 62 79 74 65 73  |tfile..L.. bytes|
000028b0  25 0d 09 56 30 62 79 74  65 73 25 3d bb 28 c1 22  |%..V0bytes%=.(."|
000028c0  31 31 32 34 38 22 2c 74  79 70 65 25 2c 31 29 29  |11248",type%,1))|
000028d0  3a f4 20 42 79 74 65 73  20 70 65 72 20 74 79 70  |:. Bytes per typ|
000028e0  65 0d 09 60 40 e7 76 61  6c 75 65 25 3d 2d 31 20  |e..`@.value%=-1 |
000028f0  8c 20 76 61 6c 75 65 25  3d a4 69 70 74 72 28 62  |. value%=.iptr(b|
00002900  79 74 65 73 25 2a 6c 65  6e 67 74 68 25 29 3a f4  |ytes%*length%):.|
00002910  20 50 6f 69 6e 74 65 72  20 74 6f 20 62 6c 6f 63  | Pointer to bloc|
00002920  6b 0d 09 6a 15 f2 6f 75  74 64 28 74 61 67 25 29  |k..j..outd(tag%)|
00002930  3a f4 20 54 61 67 0d 09  74 1d f2 6f 75 74 64 28  |:. Tag..t..outd(|
00002940  74 79 70 65 25 29 3a f4  20 46 69 65 6c 64 20 74  |type%):. Field t|
00002950  79 70 65 0d 09 7e 20 f2  6f 75 74 77 28 6c 65 6e  |ype..~ .outw(len|
00002960  67 74 68 25 29 3a f4 20  46 69 65 6c 64 20 63 6f  |gth%):. Field co|
00002970  75 6e 74 0d 09 88 2b f2  6f 75 74 77 28 76 61 6c  |unt...+.outw(val|
00002980  75 65 25 29 3a f4 20 56  61 6c 75 65 20 28 6f 66  |ue%):. Value (of|
00002990  66 73 65 74 20 6f 72 20  76 61 6c 75 65 29 0d 09  |fset or value)..|
000029a0  92 05 e1 0d 09 9c 05 20  0d 09 a6 10 dd f2 6f 75  |....... ......ou|
000029b0  74 73 28 6f 75 74 24 29  0d 09 b0 1f f4 20 4f 75  |ts(out$)..... Ou|
000029c0  74 70 75 74 73 20 73 74  72 69 6e 67 20 74 6f 20  |tputs string to |
000029d0  6f 75 74 66 69 6c 65 0d  09 ba 08 ea 20 63 25 0d  |outfile..... c%.|
000029e0  09 c4 25 e3 20 63 25 3d  31 20 b8 20 a9 6f 75 74  |..%. c%=1 . .out|
000029f0  24 3a d5 23 4f 75 74 2c  97 c1 6f 75 74 24 2c 63  |$:.#Out,..out$,c|
00002a00  25 29 3a ed 0d 09 ce 05  e1 0d 09 d8 05 20 0d 09  |%):.......... ..|
00002a10  e2 10 dd f2 6f 75 74 77  28 6f 75 74 25 29 0d 09  |....outw(out%)..|
00002a20  ec 1d f4 20 4f 75 74 70  75 74 73 20 77 6f 72 64  |... Outputs word|
00002a30  20 74 6f 20 6f 75 74 66  69 6c 65 0d 09 f6 3d d5  | to outfile...=.|
00002a40  23 4f 75 74 2c 6f 75 74  25 3a d5 23 4f 75 74 2c  |#Out,out%:.#Out,|
00002a50  6f 75 74 25 3e 3e 3e 38  3a d5 23 4f 75 74 2c 6f  |out%>>>8:.#Out,o|
00002a60  75 74 25 3e 3e 3e 31 36  3a d5 23 4f 75 74 2c 6f  |ut%>>>16:.#Out,o|
00002a70  75 74 25 3e 3e 3e 32 34  0d 0a 00 05 e1 0d 0a 0a  |ut%>>>24........|
00002a80  05 20 0d 0a 14 10 dd f2  6f 75 74 64 28 6f 75 74  |. ......outd(out|
00002a90  25 29 0d 0a 1e 24 f4 20  4f 75 74 70 75 74 73 20  |%)...$. Outputs |
00002aa0  64 6f 75 62 6c 65 2d 62  79 74 65 20 74 6f 20 6f  |double-byte to o|
00002ab0  75 74 66 69 6c 65 0d 0a  28 1c d5 23 4f 75 74 2c  |utfile..(..#Out,|
00002ac0  6f 75 74 25 3a d5 23 4f  75 74 2c 6f 75 74 25 3e  |out%:.#Out,out%>|
00002ad0  3e 38 0d 0a 32 05 e1 0d  0a 3c 05 20 0d 0a 46 10  |>8..2....<. ..F.|
00002ae0  dd f2 6f 75 74 62 28 6f  75 74 25 29 0d 0a 50 1d  |..outb(out%)..P.|
00002af0  f4 20 4f 75 74 70 75 74  73 20 62 79 74 65 20 74  |. Outputs byte t|
00002b00  6f 20 6f 75 74 66 69 6c  65 0d 0a 5a 0e d5 23 4f  |o outfile..Z..#O|
00002b10  75 74 2c 6f 75 74 25 0d  0a 64 05 e1 0d 0a 6e 05  |ut,out%..d....n.|
00002b20  20 0d 0a 78 1a dd a4 6d  6f 64 65 5f 76 61 72 28  | ..x...mode_var(|
00002b30  6d 6f 64 65 25 2c 76 61  72 25 29 0d 0a 82 1b f4  |mode%,var%).....|
00002b40  20 52 65 74 75 72 6e 73  20 6d 6f 64 65 20 76 61  | Returns mode va|
00002b50  72 69 61 62 6c 65 0d 0a  8c 0a ea 20 76 61 6c 25  |riable..... val%|
00002b60  0d 0a 96 30 c8 99 20 22  4f 53 5f 52 65 61 64 4d  |...0.. "OS_ReadM|
00002b70  6f 64 65 56 61 72 69 61  62 6c 65 22 2c 6d 6f 64  |odeVariable",mod|
00002b80  65 25 2c 76 61 72 25 20  b8 20 2c 2c 76 61 6c 25  |e%,var% . ,,val%|
00002b90  0d 0a a0 09 3d 76 61 6c  25 0d 0a aa 05 20 0d 0a  |....=val%.... ..|
00002ba0  b4 13 dd a4 73 74 72 69  6e 67 28 61 64 64 72 25  |....string(addr%|
00002bb0  29 0d 0a be 32 f4 20 52  65 74 75 72 6e 73 20 43  |)...2. Returns C|
00002bc0  54 52 4c 2d 63 68 61 72  20 74 65 72 6d 69 6e 61  |TRL-char termina|
00002bd0  74 65 64 20 73 74 72 69  6e 67 20 61 74 20 61 64  |ted string at ad|
00002be0  64 72 25 0d 0a c8 0f ea  20 5f 25 2c 5f 63 25 2c  |dr%..... _%,_c%,|
00002bf0  5f 24 0d 0a d2 1f 5f 25  3d 2d 31 3a f5 20 5f 25  |_$...._%=-1:. _%|
00002c00  2b 3d 31 3a fd 20 61 64  64 72 25 3f 5f 25 3c 33  |+=1:. addr%?_%<3|
00002c10  32 0d 0a dc 33 5f 63 25  3d 61 64 64 72 25 3f 5f  |2...3_c%=addr%?_|
00002c20  25 3a 61 64 64 72 25 3f  5f 25 3d 31 33 3a 5f 24  |%:addr%?_%=13:_$|
00002c30  3d 24 61 64 64 72 25 3a  61 64 64 72 25 3f 5f 25  |=$addr%:addr%?_%|
00002c40  3d 5f 63 25 0d 0a e6 07  3d 5f 24 0d 0a f0 05 20  |=_c%....=_$.... |
00002c50  0d 0a fa 1d dd f2 6d 6f  75 73 65 28 f8 20 78 25  |......mouse(. x%|
00002c60  2c f8 20 79 25 2c f8 20  62 75 74 25 29 0d 0b 04  |,. y%,. but%)...|
00002c70  2b f4 20 52 65 74 75 72  6e 73 20 78 2c 79 20 61  |+. Returns x,y a|
00002c80  6e 64 20 62 75 74 74 6f  6e 20 73 74 61 74 65 20  |nd button state |
00002c90  6f 66 20 6d 6f 75 73 65  0d 0b 0e 11 c8 97 20 78  |of mouse...... x|
00002ca0  25 2c 79 25 2c 62 75 74  25 0d 0b 18 05 e1 0d 0b  |%,y%,but%.......|
00002cb0  22 05 20 0d 0b 2c 0d dd  f2 68 6f 75 72 5f 6f 6e  |". ..,...hour_on|
00002cc0  0d 0b 36 24 f4 20 54 75  72 6e 73 20 68 6f 75 72  |..6$. Turns hour|
00002cd0  67 6c 61 73 73 20 6f 6e  20 61 66 74 65 72 20 31  |glass on after 1|
00002ce0  20 73 65 63 0d 0b 40 15  c8 99 20 22 48 6f 75 72  | sec..@... "Hour|
00002cf0  67 6c 61 73 73 5f 4f 6e  22 0d 0b 4a 05 e1 0d 0b  |glass_On"..J....|
00002d00  54 05 20 0d 0b 5e 0e dd  f2 68 6f 75 72 5f 6f 66  |T. ..^...hour_of|
00002d10  66 0d 0b 68 19 f4 20 54  75 72 6e 73 20 68 6f 75  |f..h.. Turns hou|
00002d20  72 67 6c 61 73 73 20 6f  66 66 0d 0b 72 16 c8 99  |rglass off..r...|
00002d30  20 22 48 6f 75 72 67 6c  61 73 73 5f 4f 66 66 22  | "Hourglass_Off"|
00002d40  0d 0b 7c 05 e1 0d 0b 86  05 20 0d 0b 90 12 dd a4  |..|...... ......|
00002d50  4f 53 76 61 72 28 6e 61  6d 65 24 29 0d 0b 9a 2e  |OSvar(name$)....|
00002d60  f4 20 41 74 74 65 6d 70  74 73 20 74 6f 20 72 65  |. Attempts to re|
00002d70  74 75 72 6e 20 4f 53 2d  76 61 72 27 73 20 73 74  |turn OS-var's st|
00002d80  72 69 6e 67 20 76 61 6c  75 65 0d 0b a4 0d ea 20  |ring value..... |
00002d90  5f 72 24 2c 5f 6c 25 0d  0b ae 43 5f 72 24 3d c4  |_r$,_l%...C_r$=.|
00002da0  31 30 30 2c 22 20 22 29  3a c8 99 20 22 58 4f 53  |100," "):.. "XOS|
00002db0  5f 52 65 61 64 56 61 72  56 61 6c 22 2c 6e 61 6d  |_ReadVarVal",nam|
00002dc0  65 24 2c 5f 72 24 2c a9  5f 72 24 2c 30 2c 33 20  |e$,_r$,._r$,0,3 |
00002dd0  b8 20 2c 5f 72 24 2c 5f  6c 25 0d 0b b8 0e 3d c0  |. ,_r$,_l%....=.|
00002de0  5f 72 24 2c 5f 6c 25 29  0d 0b c2 05 20 0d 0b cc  |_r$,_l%).... ...|
00002df0  14 dd a4 70 61 6c 74 6f  72 67 62 28 70 61 6c 25  |...paltorgb(pal%|
00002e00  29 0d 0b d6 2f f4 20 52  65 74 75 72 6e 73 20 26  |).../. Returns &|
00002e10  52 52 47 47 42 42 20 66  72 6f 6d 20 73 70 72 69  |RRGGBB from spri|
00002e20  74 65 20 70 61 6c 65 74  74 65 20 65 6e 74 72 79  |te palette entry|
00002e30  0d 0b e0 37 3d 28 70 61  6c 25 3e 3e 3e 32 34 29  |...7=(pal%>>>24)|
00002e40  2b 28 28 70 61 6c 25 3e  3e 3e 38 29 80 26 46 46  |+((pal%>>>8).&FF|
00002e50  30 30 29 2b 28 28 70 61  6c 25 3c 3c 38 29 80 26  |00)+((pal%<<8).&|
00002e60  46 46 30 30 30 30 29 0d  0b ea 05 20 0d 0b f4 12  |FF0000).... ....|
00002e70  dd f2 69 63 6f 6e 62 61  72 5f 6d 65 6e 75 0d 0b  |..iconbar_menu..|
00002e80  fe 23 f4 20 50 6f 70 73  20 75 70 20 6d 65 6e 75  |.#. Pops up menu|
00002e90  20 66 6f 72 20 69 63 6f  6e 62 61 72 20 69 63 6f  | for iconbar ico|
00002ea0  6e 0d 0c 08 37 f2 6d 6f  75 73 65 28 78 25 2c 79  |n...7.mouse(x%,y|
00002eb0  25 2c 5f 25 29 3a 78 25  2d 3d 36 34 3a f4 20 47  |%,_%):x%-=64:. G|
00002ec0  65 74 20 63 6f 6f 72 64  69 6e 61 74 65 73 20 76  |et coordinates v|
00002ed0  69 61 20 6d 6f 75 73 65  0d 0c 12 74 24 6d 65 6e  |ia mouse...t$men|
00002ee0  75 3d 22 4d 61 6b 65 54  49 46 46 22 3a 6d 65 6e  |u="MakeTIFF":men|
00002ef0  75 3f 31 32 3d 74 66 25  3a 6d 65 6e 75 3f 31 33  |u?12=tf%:menu?13|
00002f00  3d 74 62 25 3a 6d 65 6e  75 3f 31 34 3d 77 66 25  |=tb%:menu?14=wf%|
00002f10  3a 6d 65 6e 75 3f 31 35  3d 77 62 25 3a 6d 65 6e  |:menu?15=wb%:men|
00002f20  75 21 31 36 3d 35 2a 31  36 3a 6d 65 6e 75 21 32  |u!16=5*16:menu!2|
00002f30  30 3d 34 30 3a 6d 65 6e  75 21 32 34 3d 30 3a f4  |0=40:menu!24=0:.|
00002f40  20 4d 65 6e 75 20 68 65  61 64 65 72 0d 0c 1c 97  | Menu header....|
00002f50  6d 65 6e 75 21 32 38 3d  30 3a 6d 65 6e 75 21 33  |menu!28=0:menu!3|
00002f60  32 3d 77 69 6e 5f 69 6e  66 6f 25 3a 6d 65 6e 75  |2=win_info%:menu|
00002f70  21 33 36 3d 28 77 62 25  3c 3c 32 38 29 2b 28 77  |!36=(wb%<<28)+(w|
00002f80  66 25 3c 3c 32 34 29 2b  28 31 35 3c 3c 31 32 29  |f%<<24)+(15<<12)|
00002f90  2b 31 3a 24 28 6d 65 6e  75 2b 34 30 29 3d 22 49  |+1:$(menu+40)="I|
00002fa0  6e 66 6f 22 2b bd 30 3a  6d 65 6e 75 21 35 32 3d  |nfo"+.0:menu!52=|
00002fb0  26 38 30 3a 6d 65 6e 75  21 35 36 3d 2d 31 3a 6d  |&80:menu!56=-1:m|
00002fc0  65 6e 75 21 36 30 3d 6d  65 6e 75 21 33 36 3a 24  |enu!60=menu!36:$|
00002fd0  28 6d 65 6e 75 2b 36 34  29 3d 22 51 75 69 74 22  |(menu+64)="Quit"|
00002fe0  2b bd 30 0d 0c 26 32 c8  99 20 57 43 72 65 61 74  |+.0..&2.. WCreat|
00002ff0  65 4d 25 2c 2c 6d 65 6e  75 2c 78 25 2c 79 25 3a  |eM%,,menu,x%,y%:|
00003000  f4 20 43 72 65 61 74 65  20 69 63 6f 6e 62 61 72  |. Create iconbar|
00003010  20 6d 65 6e 75 0d 0c 30  05 e1 0d 0c 3a 05 20 0d  | menu..0....:. .|
00003020  0c 44 1f dd f2 6f 70 65  6e 5f 77 69 6e 64 6f 77  |.D...open_window|
00003030  28 68 61 6e 64 6c 65 25  2c 69 6e 66 6f 29 0d 0c  |(handle%,info)..|
00003040  4e 26 f4 20 4f 70 65 6e  73 20 77 69 6e 64 6f 77  |N&. Opens window|
00003050  20 77 69 74 68 20 68 61  6e 64 6c 65 20 68 61 6e  | with handle han|
00003060  64 6c 65 25 0d 0c 58 3a  f4 20 49 66 20 69 6e 66  |dle%..X:. If inf|
00003070  6f 3c 3e 30 20 74 68 65  6e 20 69 6e 66 6f 20 69  |o<>0 then info i|
00003080  73 20 72 65 61 64 79 20  61 74 20 69 6e 66 6f 2c  |s ready at info,|
00003090  20 65 6c 73 65 20 67 65  74 20 69 6e 66 6f 0d 0c  | else get info..|
000030a0  62 1b ea 20 62 25 2c 70  78 25 2c 70 79 25 2c 5f  |b.. b%,px%,py%,_|
000030b0  25 2c 78 73 25 2c 79 73  25 0d 0c 6c 0e e7 69 6e  |%,xs%,ys%..l..in|
000030c0  66 6f 3c 3e 30 20 8c 0d  0c 76 27 20 e3 20 62 25  |fo<>0 ...v' . b%|
000030d0  3d 30 20 b8 20 33 31 20  88 20 34 3a 62 6c 6f 63  |=0 . 31 . 4:bloc|
000030e0  6b 21 62 25 3d 69 6e 66  6f 21 62 25 3a ed 0d 0c  |k!b%=info!b%:...|
000030f0  80 26 cc 20 21 62 6c 6f  63 6b 3d 68 61 6e 64 6c  |.&. !block=handl|
00003100  65 25 3a c8 99 20 57 47  65 74 57 53 25 2c 2c 62  |e%:.. WGetWS%,,b|
00003110  6c 6f 63 6b 0d 0c 8a 8d  20 f2 6d 6f 75 73 65 28  |lock.... .mouse(|
00003120  70 78 25 2c 70 79 25 2c  5f 25 29 3a 78 73 25 3d  |px%,py%,_%):xs%=|
00003130  62 6c 6f 63 6b 21 31 32  2d 62 6c 6f 63 6b 21 34  |block!12-block!4|
00003140  3a 79 73 25 3d 62 6c 6f  63 6b 21 31 36 2d 62 6c  |:ys%=block!16-bl|
00003150  6f 63 6b 21 38 3a 62 6c  6f 63 6b 21 34 3d 70 78  |ock!8:block!4=px|
00003160  25 2d 36 34 3a 62 6c 6f  63 6b 21 38 3d 70 79 25  |%-64:block!8=py%|
00003170  2d 79 73 25 2b 31 36 3a  62 6c 6f 63 6b 21 31 32  |-ys%+16:block!12|
00003180  3d 62 6c 6f 63 6b 21 34  2b 78 73 25 3a 62 6c 6f  |=block!4+xs%:blo|
00003190  63 6b 21 31 36 3d 62 6c  6f 63 6b 21 38 2b 79 73  |ck!16=block!8+ys|
000031a0  25 0d 0c 94 05 cd 0d 0c  9e 15 c8 99 20 57 4f 70  |%........... WOp|
000031b0  65 6e 57 25 2c 2c 62 6c  6f 63 6b 0d 0c a8 05 e1  |enW%,,block.....|
000031c0  0d 0c b2 05 20 0d 0c bc  1b dd f2 63 6c 6f 73 65  |.... ......close|
000031d0  5f 77 69 6e 64 6f 77 28  68 61 6e 64 6c 65 25 29  |_window(handle%)|
000031e0  0d 0c c6 27 f4 20 43 6c  6f 73 65 73 20 77 69 6e  |...'. Closes win|
000031f0  64 6f 77 20 77 69 74 68  20 68 61 6e 64 6c 65 20  |dow with handle |
00003200  68 61 6e 64 6c 65 25 0d  0c d0 25 21 62 6c 6f 63  |handle%...%!bloc|
00003210  6b 3d 68 61 6e 64 6c 65  25 3a c8 99 20 57 43 6c  |k=handle%:.. WCl|
00003220  6f 73 65 57 25 2c 2c 62  6c 6f 63 6b 0d 0c da 05  |oseW%,,block....|
00003230  e1 0d 0c e4 05 20 0d 0c  ee 11 dd a4 70 6f 6c 6c  |..... ......poll|
00003240  28 6d 61 73 6b 25 29 0d  0c f8 40 f4 20 52 65 74  |(mask%)...@. Ret|
00003250  75 72 6e 73 20 70 6f 6c  6c 20 72 65 61 73 6f 6e  |urns poll reason|
00003260  20 63 6f 64 65 2c 20 6d  61 73 6b 69 6e 67 20 77  | code, masking w|
00003270  69 74 68 20 6d 61 73 6b  25 2c 20 64 61 74 61 20  |ith mask%, data |
00003280  61 74 20 70 6f 6c 6c 0d  0d 02 10 ea 20 72 65 61  |at poll..... rea|
00003290  73 6f 6e 63 6f 64 65 0d  0d 0c 25 c8 99 20 57 50  |soncode...%.. WP|
000032a0  6f 6c 6c 25 2c 6d 61 73  6b 25 2c 70 6f 6c 6c 20  |oll%,mask%,poll |
000032b0  b8 20 72 65 61 73 6f 6e  63 6f 64 65 0d 0d 16 0f  |. reasoncode....|
000032c0  3d 72 65 61 73 6f 6e 63  6f 64 65 0d 0d 20 05 20  |=reasoncode.. . |
000032d0  0d 0d 2a 10 dd f2 69 6e  69 74 69 61 6c 69 73 65  |..*...initialise|
000032e0  0d 0d 34 19 f4 20 49 6e  69 74 69 61 6c 69 73 65  |..4.. Initialise|
000032f0  73 20 70 72 6f 67 72 61  6d 0d 0d 3e 2e 61 70 70  |s program..>.app|
00003300  6c 6e 61 6d 65 24 3d 22  4d 61 6b 65 54 49 46 46  |lname$="MakeTIFF|
00003310  22 3a f4 20 4e 61 6d 65  20 6f 66 20 61 70 70 6c  |":. Name of appl|
00003320  69 63 61 74 69 6f 6e 0d  0d 48 46 c8 99 20 22 57  |ication..HF.. "W|
00003330  69 6d 70 5f 49 6e 69 74  69 61 6c 69 73 65 22 2c  |imp_Initialise",|
00003340  32 30 30 2c 26 34 42 35  33 34 31 35 34 2c 61 70  |200,&4B534154,ap|
00003350  70 6c 6e 61 6d 65 24 20  b8 20 76 65 72 73 69 6f  |plname$ . versio|
00003360  6e 2c 54 61 73 6b 48 61  6e 64 6c 65 25 0d 0d 52  |n,TaskHandle%..R|
00003370  39 e7 76 65 72 73 69 6f  6e 3c 32 30 30 20 8c 20  |9.version<200 . |
00003380  85 20 31 2c 22 49 20 63  61 6e 6e 6f 74 20 77 6f  |. 1,"I cannot wo|
00003390  72 6b 20 77 69 74 68 20  57 49 4d 50 20 70 72 65  |rk with WIMP pre|
000033a0  2d 32 2e 30 30 22 0d 0d  5c 36 57 25 3d a4 73 77  |-2.00"..\6W%=.sw|
000033b0  69 5f 74 6f 5f 6e 72 28  22 57 69 6d 70 5f 49 6e  |i_to_nr("Wimp_In|
000033c0  69 74 69 61 6c 69 73 65  22 29 3a f4 20 42 61 73  |itialise"):. Bas|
000033d0  65 20 53 57 49 20 6e 75  6d 62 65 72 0d 0d 66 bd  |e SWI number..f.|
000033e0  57 43 72 65 61 74 65 57  25 3d 57 25 2b 31 3a 57  |WCreateW%=W%+1:W|
000033f0  43 72 65 61 74 65 49 25  3d 57 25 2b 32 3a 57 4f  |CreateI%=W%+2:WO|
00003400  70 65 6e 57 25 3d 57 25  2b 35 3a 57 43 6c 6f 73  |penW%=W%+5:WClos|
00003410  65 57 25 3d 57 25 2b 36  3a 57 50 6f 6c 6c 25 3d  |eW%=W%+6:WPoll%=|
00003420  57 25 2b 37 3a 57 47 65  74 57 53 25 3d 57 25 2b  |W%+7:WGetWS%=W%+|
00003430  31 31 3a 57 47 65 74 49  53 25 3d 57 25 2b 31 34  |11:WGetIS%=W%+14|
00003440  3a 57 47 65 74 50 49 25  3d 57 25 2b 31 35 3a 57  |:WGetPI%=W%+15:W|
00003450  44 72 61 67 42 25 3d 57  25 2b 31 36 3a 57 43 72  |DragB%=W%+16:WCr|
00003460  65 61 74 65 4d 25 3d 57  25 2b 32 30 3a 57 4c 6f  |eateM%=W%+20:WLo|
00003470  61 64 54 25 3d 57 25 2b  32 37 3a 57 52 65 70 6f  |adT%=W%+27:WRepo|
00003480  72 74 25 3d 57 25 2b 33  31 3a 57 53 65 6e 64 4d  |rt%=W%+31:WSendM|
00003490  73 67 25 3d 57 25 2b 33  39 0d 0d 70 3d 74 66 25  |sg%=W%+39..p=tf%|
000034a0  3d 37 3a 74 62 25 3d 32  3a 77 66 25 3d 37 3a 77  |=7:tb%=2:wf%=7:w|
000034b0  62 25 3d 30 3a 73 69 25  3d 31 3a 73 6f 25 3d 33  |b%=0:si%=1:so%=3|
000034c0  3a f4 20 57 69 6e 64 6f  77 2f 6d 65 6e 75 20 63  |:. Window/menu c|
000034d0  6f 6c 6f 75 72 73 0d 0d  7a 93 21 62 6c 6f 63 6b  |olours..z.!block|
000034e0  3d 2d 31 3a 62 6c 6f 63  6b 21 34 3d 30 3a 62 6c  |=-1:block!4=0:bl|
000034f0  6f 63 6b 21 38 3d 30 3a  62 6c 6f 63 6b 21 31 32  |ock!8=0:block!12|
00003500  3d 36 38 3a 62 6c 6f 63  6b 21 31 36 3d 36 38 3a  |=68:block!16=68:|
00003510  62 6c 6f 63 6b 21 32 30  3d 26 32 37 30 30 33 30  |block!20=&270030|
00003520  30 32 3a 24 28 62 6c 6f  63 6b 2b 32 34 29 3d 22  |02:$(block+24)="|
00003530  21 6d 61 6b 65 74 69 66  66 22 3a c8 99 20 57 43  |!maketiff":.. WC|
00003540  72 65 61 74 65 49 25 2c  2c 62 6c 6f 63 6b 20 b8  |reateI%,,block .|
00003550  20 49 69 63 6f 6e 62 61  72 25 3a f4 20 49 63 6f  | Iiconbar%:. Ico|
00003560  6e 62 61 72 20 69 63 6f  6e 0d 0d 84 14 f4 20 4c  |nbar icon..... L|
00003570  6f 61 64 20 74 65 6d 70  6c 61 74 65 73 0d 0d 8e  |oad templates...|
00003580  36 c8 99 20 22 57 69 6d  70 5f 4f 70 65 6e 54 65  |6.. "Wimp_OpenTe|
00003590  6d 70 6c 61 74 65 22 2c  2c 22 3c 4d 61 6b 65 54  |mplate",,"<MakeT|
000035a0  49 46 46 24 44 69 72 3e  2e 54 65 6d 70 6c 61 74  |IFF$Dir>.Templat|
000035b0  65 73 22 0d 0d 98 3c 69  63 3d 69 63 6f 6e 64 61  |es"...<ic=iconda|
000035c0  74 61 3a 69 65 3d 69 63  6f 6e 64 65 6e 64 3a f4  |ta:ie=icondend:.|
000035d0  20 49 6e 64 69 72 65 63  74 65 64 20 69 63 6f 6e  | Indirected icon|
000035e0  20 64 61 74 61 20 77 6f  72 6b 73 70 61 63 65 0d  | data workspace.|
000035f0  0d a2 3b 24 64 75 6d 25  3d 22 73 61 76 65 22 3a  |..;$dum%="save":|
00003600  c8 99 20 57 4c 6f 61 64  54 25 2c 2c 77 69 6e 64  |.. WLoadT%,,wind|
00003610  6f 77 31 2c 69 63 2c 69  65 2c 2d 31 2c 64 75 6d  |ow1,ic,ie,-1,dum|
00003620  25 2c 30 20 b8 20 2c 2c  69 63 0d 0d ac 25 c8 99  |%,0 . ,,ic...%..|
00003630  20 57 43 72 65 61 74 65  57 25 2c 2c 77 69 6e 64  | WCreateW%,,wind|
00003640  6f 77 31 20 b8 20 77 69  6e 5f 66 69 6c 65 25 0d  |ow1 . win_file%.|
00003650  0d b6 21 53 41 56 66 6e  25 3d a4 69 63 6f 6e 61  |..!SAVfn%=.icona|
00003660  64 64 72 28 77 69 6e 5f  66 69 6c 65 25 2c 31 29  |ddr(win_file%,1)|
00003670  0d 0d c0 3b 24 64 75 6d  25 3d 22 69 6e 66 6f 22  |...;$dum%="info"|
00003680  3a c8 99 20 57 4c 6f 61  64 54 25 2c 2c 77 69 6e  |:.. WLoadT%,,win|
00003690  64 6f 77 32 2c 69 63 2c  69 65 2c 2d 31 2c 64 75  |dow2,ic,ie,-1,du|
000036a0  6d 25 2c 30 20 b8 20 2c  2c 69 63 0d 0d ca 25 c8  |m%,0 . ,,ic...%.|
000036b0  99 20 57 43 72 65 61 74  65 57 25 2c 2c 77 69 6e  |. WCreateW%,,win|
000036c0  64 6f 77 32 20 b8 20 77  69 6e 5f 69 6e 66 6f 25  |dow2 . win_info%|
000036d0  0d 0d d4 1b c8 99 20 22  57 69 6d 70 5f 43 6c 6f  |...... "Wimp_Clo|
000036e0  73 65 54 65 6d 70 6c 61  74 65 22 0d 0d de 1a f4  |seTemplate".....|
000036f0  20 49 6e 69 74 69 61 6c  69 73 65 20 76 61 72 69  | Initialise vari|
00003700  61 62 6c 65 73 0d 0d e8  46 4f 75 74 70 75 74 24  |ables...FOutput$|
00003710  3d 22 22 3a 49 6e 70 75  74 24 3d 22 22 3a 44 61  |="":Input$="":Da|
00003720  74 61 4c 6f 61 64 52 65  66 25 3d a3 3a 44 61 74  |taLoadRef%=.:Dat|
00003730  61 53 61 76 65 52 65 66  25 3d 2d 31 3a f4 20 49  |aSaveRef%=-1:. I|
00003740  6e 69 74 20 67 6c 6f 62  61 6c 73 0d 0d f2 0a f2  |nit globals.....|
00003750  6d 63 6f 64 65 0d 0d fc  05 e1 0d 0e 06 05 20 0d  |mcode......... .|
00003760  0e 10 19 dd a4 69 63 6f  6e 61 64 64 72 28 77 69  |.....iconaddr(wi|
00003770  6e 25 2c 69 63 6f 25 29  0d 0e 1a 2c f4 20 52 65  |n%,ico%)...,. Re|
00003780  74 75 72 6e 73 20 69 6e  64 69 72 65 63 74 65 64  |turns indirected|
00003790  20 69 63 6f 6e 27 73 20  64 61 74 61 20 61 64 64  | icon's data add|
000037a0  72 65 73 73 0d 0e 24 3e  21 62 6c 6f 63 6b 3d 77  |ress..$>!block=w|
000037b0  69 6e 25 3a 62 6c 6f 63  6b 21 34 3d 69 63 6f 25  |in%:block!4=ico%|
000037c0  3a c8 99 20 57 47 65 74  49 53 25 2c 2c 62 6c 6f  |:.. WGetIS%,,blo|
000037d0  63 6b 3a f4 20 47 65 74  20 69 63 6f 6e 20 69 6e  |ck:. Get icon in|
000037e0  66 6f 0d 0e 2e 0d 3d 62  6c 6f 63 6b 21 32 38 0d  |fo....=block!28.|
000037f0  0e 38 05 20 0d 0e 42 0b  dd f2 6d 63 6f 64 65 0d  |.8. ..B...mcode.|
00003800  0e 4c 19 f4 20 43 72 65  61 74 65 73 20 6d 61 63  |.L.. Creates mac|
00003810  68 69 6e 65 63 6f 64 65  0d 0e 56 1a e3 20 4e 3d  |hinecode..V.. N=|
00003820  30 20 b8 20 32 20 88 20  32 3a 50 25 3d 43 6f 64  |0 . 2 . 2:P%=Cod|
00003830  65 25 0d 0e 60 09 5b 4f  50 54 4e 0d 0e 6a 38 2e  |e%..`.[OPTN..j8.|
00003840  74 79 70 65 20 20 45 51  55 44 20 30 3a 5c 20 49  |type  EQUD 0:\ I|
00003850  6d 61 67 65 20 74 79 70  65 20 28 26 46 46 39 3d  |mage type (&FF9=|
00003860  73 70 72 69 74 65 2c 20  26 36 39 30 3d 43 6c 65  |sprite, &690=Cle|
00003870  61 72 29 0d 0e 74 2a 2e  77 69 64 74 68 20 45 51  |ar)..t*.width EQ|
00003880  55 44 20 30 3a 5c 20 57  69 64 74 68 20 6f 66 20  |UD 0:\ Width of |
00003890  72 6f 77 20 69 6e 20 70  69 78 65 6c 73 0d 0e 7e  |row in pixels..~|
000038a0  2d 2e 6c 65 66 74 20 20  45 51 55 44 20 30 3a 5c  |-.left  EQUD 0:\|
000038b0  20 28 53 70 72 69 74 65  29 20 4c 65 66 74 20 62  | (Sprite) Left b|
000038c0  69 74 20 77 61 73 74 61  67 65 0d 0e 88 2a 2e 77  |it wastage...*.w|
000038d0  6f 72 64 73 20 45 51 55  44 20 30 3a 5c 20 28 53  |ords EQUD 0:\ (S|
000038e0  70 72 69 74 65 29 20 57  6f 72 64 73 20 70 65 72  |prite) Words per|
000038f0  20 72 6f 77 0d 0e 92 22  2e 62 69 74 73 20 20 45  | row...".bits  E|
00003900  51 55 44 20 30 3a 5c 20  42 69 74 73 20 70 65 72  |QUD 0:\ Bits per|
00003910  20 70 69 78 65 6c 0d 0e  9c 23 2e 72 6f 77 20 20  | pixel...#.row  |
00003920  20 45 51 55 44 20 52 6f  77 42 66 25 3a 5c 20 52  | EQUD RowBf%:\ R|
00003930  6f 77 20 62 75 66 66 65  72 0d 0e a6 28 2e 6d 61  |ow buffer...(.ma|
00003940  70 20 20 20 45 51 55 44  20 52 65 76 4d 61 70 25  |p   EQUD RevMap%|
00003950  3a 5c 20 43 6f 6e 76 65  72 73 69 6f 6e 20 6d 61  |:\ Conversion ma|
00003960  70 0d 0e b0 05 20 0d 0e  ba 2e 2e 63 6f 6e 76 65  |p.... .....conve|
00003970  72 74 20 5c 20 43 6f 6e  76 65 72 74 73 20 72 6f  |rt \ Converts ro|
00003980  77 20 6f 66 20 70 69 78  65 6c 73 20 66 6f 72 20  |w of pixels for |
00003990  54 49 46 46 0d 0e c4 46  20 5c 20 53 70 72 69 74  |TIFF...F \ Sprit|
000039a0  65 20 2d 20 4c 65 66 74  2d 61 6c 69 67 6e 73 20  |e - Left-aligns |
000039b0  73 70 72 69 74 65 20 72  6f 77 20 26 20 72 65 76  |sprite row & rev|
000039c0  65 72 73 65 73 20 70 69  78 65 6c 20 6f 72 64 65  |erses pixel orde|
000039d0  72 20 69 6e 20 62 79 74  65 73 0d 0e ce 41 20 5c  |r in bytes...A \|
000039e0  20 43 6c 65 61 72 20 20  2d 20 50 61 63 6b 73 20  | Clear  - Packs |
000039f0  62 79 74 65 2d 76 61 6c  75 65 73 20 26 20 72 65  |byte-values & re|
00003a00  76 65 72 73 65 73 20 70  69 78 65 6c 20 6f 72 64  |verses pixel ord|
00003a10  65 72 20 69 6e 20 62 79  74 65 73 0d 0e d8 21 20  |er in bytes...! |
00003a20  53 54 4d 46 44 20 72 31  33 21 2c 7b 72 31 34 7d  |STMFD r13!,{r14}|
00003a30  3a 5c 20 53 61 76 65 20  6c 69 6e 6b 0d 0e e2 25  |:\ Save link...%|
00003a40  20 4c 44 52 20 72 31 30  2c 6d 61 70 3a 5c 20 50  | LDR r10,map:\ P|
00003a50  69 78 65 6c 20 72 65 76  65 72 73 61 6c 20 6d 61  |ixel reversal ma|
00003a60  70 0d 0e ec 3e 20 4c 44  52 20 72 30 2c 74 79 70  |p...> LDR r0,typ|
00003a70  65 3a 43 4d 50 20 72 30  2c 23 26 36 39 30 3a 42  |e:CMP r0,#&690:B|
00003a80  4e 45 20 63 6f 6e 76 5f  73 70 72 3a 5c 20 53 70  |NE conv_spr:\ Sp|
00003a90  72 69 74 65 20 6f 72 20  43 6c 65 61 72 20 3f 0d  |rite or Clear ?.|
00003aa0  0e f6 3f 20 4c 44 52 20  72 36 2c 62 69 74 73 3a  |..? LDR r6,bits:|
00003ab0  43 4d 50 20 72 36 2c 23  38 3a 42 45 51 20 63 6f  |CMP r6,#8:BEQ co|
00003ac0  6e 76 5f 65 78 69 74 3a  5c 20 4e 6f 20 63 6f 6e  |nv_exit:\ No con|
00003ad0  76 65 72 73 69 6f 6e 20  6e 65 65 64 65 64 0d 0f  |version needed..|
00003ae0  00 39 20 4c 44 52 20 72  37 2c 77 69 64 74 68 3a  |.9 LDR r7,width:|
00003af0  4c 44 52 20 72 38 2c 72  6f 77 3a 5c 20 50 69 78  |LDR r8,row:\ Pix|
00003b00  65 6c 73 20 6f 6e 20 72  6f 77 20 61 6e 64 20 6c  |els on row and l|
00003b10  6f 63 61 74 69 6f 6e 0d  0f 0a 1c 20 4d 4f 56 20  |ocation.... MOV |
00003b20  72 33 2c 72 38 3a 5c 20  44 65 73 74 69 6e 61 74  |r3,r8:\ Destinat|
00003b30  69 6f 6e 0d 0f 14 3b 2e  62 6c 64 5f 70 72 65 70  |ion...;.bld_prep|
00003b40  20 4d 4f 56 20 72 35 2c  23 30 3a 4d 4f 56 20 72  | MOV r5,#0:MOV r|
00003b50  34 2c 23 38 3a 5c 20 41  63 63 75 6d 75 6c 61 74  |4,#8:\ Accumulat|
00003b60  6f 72 20 2f 20 62 69 74  20 73 68 69 66 74 0d 0f  |or / bit shift..|
00003b70  1e 3e 2e 62 6c 64 5f 62  79 74 65 20 53 55 42 53  |.>.bld_byte SUBS|
00003b80  20 72 37 2c 72 37 2c 23  31 3a 42 4c 45 20 62 6c  | r7,r7,#1:BLE bl|
00003b90  64 5f 64 6f 6e 65 3a 5c  20 50 69 78 65 6c 20 76  |d_done:\ Pixel v|
00003ba0  61 6c 75 65 73 20 6c 65  66 74 20 3f 0d 0f 28 26  |alues left ?..(&|
00003bb0  20 4c 44 52 42 20 72 30  2c 5b 72 38 5d 2c 23 31  | LDRB r0,[r8],#1|
00003bc0  3a 5c 20 47 65 74 20 70  69 78 65 6c 20 76 61 6c  |:\ Get pixel val|
00003bd0  75 65 0d 0f 32 3f 20 53  55 42 53 20 72 34 2c 72  |ue..2? SUBS r4,r|
00003be0  34 2c 72 36 3a 84 52 20  72 35 2c 72 35 2c 72 30  |4,r6:.R r5,r5,r0|
00003bf0  2c 4c 53 4c 20 72 34 3a  42 47 54 20 62 6c 64 5f  |,LSL r4:BGT bld_|
00003c00  62 79 74 65 3a 5c 20 4e  65 78 74 20 70 69 78 65  |byte:\ Next pixe|
00003c10  6c 0d 0f 3c 2b 20 53 54  52 42 20 72 35 2c 5b 72  |l..<+ STRB r5,[r|
00003c20  33 5d 2c 23 31 3a 42 20  62 6c 64 5f 70 72 65 70  |3],#1:B bld_prep|
00003c30  3a 5c 20 4e 65 78 74 20  62 79 74 65 0d 0f 46 35  |:\ Next byte..F5|
00003c40  2e 62 6c 64 5f 64 6f 6e  65 20 43 4d 50 20 72 34  |.bld_done CMP r4|
00003c50  2c 23 38 3a 53 54 52 4c  54 42 20 72 35 2c 5b 72  |,#8:STRLTB r5,[r|
00003c60  33 5d 2c 23 31 3a 5c 20  4c 61 73 74 20 62 69 74  |3],#1:\ Last bit|
00003c70  73 0d 0f 50 28 2e 63 6f  6e 76 5f 65 78 69 74 20  |s..P(.conv_exit |
00003c80  4c 44 4d 46 44 20 72 31  33 21 2c 7b 70 63 7d 5e  |LDMFD r13!,{pc}^|
00003c90  3a 5c 20 52 65 74 75 72  6e 0d 0f 5a 35 2e 63 6f  |:\ Return..Z5.co|
00003ca0  6e 76 5f 73 70 72 20 4c  44 52 20 72 39 2c 6c 65  |nv_spr LDR r9,le|
00003cb0  66 74 3a 5c 20 42 69 74  20 6f 66 66 73 65 74 20  |ft:\ Bit offset |
00003cc0  74 6f 20 66 69 72 73 74  20 70 69 78 65 6c 0d 0f  |to first pixel..|
00003cd0  64 36 20 4c 44 52 20 72  37 2c 77 6f 72 64 73 3a  |d6 LDR r7,words:|
00003ce0  4c 44 52 20 72 38 2c 72  6f 77 3a 5c 20 52 6f 77  |LDR r8,row:\ Row|
00003cf0  20 6c 65 6e 67 74 68 20  61 6e 64 20 6c 6f 63 61  | length and loca|
00003d00  74 69 6f 6e 0d 0f 6e 26  20 52 53 42 20 72 36 2c  |tion..n& RSB r6,|
00003d10  72 39 2c 23 33 32 3a 5c  20 4f 70 70 6f 73 69 74  |r9,#32:\ Opposit|
00003d20  65 20 62 69 74 73 68 69  66 74 0d 0f 78 32 20 4c  |e bitshift..x2 L|
00003d30  44 52 20 72 30 2c 5b 72  38 5d 3a 4d 4f 56 20 72  |DR r0,[r8]:MOV r|
00003d40  30 2c 72 30 2c 4c 53 52  20 72 39 3a 5c 20 47 65  |0,r0,LSR r9:\ Ge|
00003d50  74 20 66 69 72 73 74 20  62 69 74 73 0d 0f 82 46  |t first bits...F|
00003d60  2e 6c 65 66 5f 61 6c 20  53 55 42 53 20 72 37 2c  |.lef_al SUBS r7,|
00003d70  72 37 2c 23 31 3a 4c 44  52 47 54 20 72 31 2c 5b  |r7,#1:LDRGT r1,[|
00003d80  72 38 2c 23 34 5d 3a 4d  4f 56 4c 45 20 72 31 2c  |r8,#4]:MOVLE r1,|
00003d90  23 30 3a 5c 20 47 65 74  20 6e 65 78 74 20 77 6f  |#0:\ Get next wo|
00003da0  72 64 0d 0f 8c 24 20 84  52 20 72 32 2c 72 30 2c  |rd...$ .R r2,r0,|
00003db0  72 31 2c 4c 53 4c 20 72  36 3a 5c 20 42 75 69 6c  |r1,LSL r6:\ Buil|
00003dc0  64 20 77 6f 72 64 0d 0f  96 3d 20 80 20 72 34 2c  |d word...= . r4,|
00003dd0  72 32 2c 23 26 46 46 3a  4c 44 52 42 20 72 33 2c  |r2,#&FF:LDRB r3,|
00003de0  5b 72 31 30 2c 72 34 5d  3a 5c 20 52 65 76 65 72  |[r10,r4]:\ Rever|
00003df0  73 65 20 62 69 74 73 20  69 6e 20 6c 6f 77 20 62  |se bits in low b|
00003e00  79 74 65 0d 0f a0 44 20  4d 4f 56 20 72 34 2c 72  |yte...D MOV r4,r|
00003e10  32 2c 4c 53 52 23 38 3a  80 20 72 34 2c 72 34 2c  |2,LSR#8:. r4,r4,|
00003e20  23 26 46 46 3a 4c 44 52  42 20 72 34 2c 5b 72 31  |#&FF:LDRB r4,[r1|
00003e30  30 2c 72 34 5d 3a 84 52  20 72 33 2c 72 33 2c 72  |0,r4]:.R r3,r3,r|
00003e40  34 2c 4c 53 4c 23 38 0d  0f aa 46 20 4d 4f 56 20  |4,LSL#8...F MOV |
00003e50  72 34 2c 72 32 2c 4c 53  52 23 31 36 3a 80 20 72  |r4,r2,LSR#16:. r|
00003e60  34 2c 72 34 2c 23 26 46  46 3a 4c 44 52 42 20 72  |4,r4,#&FF:LDRB r|
00003e70  34 2c 5b 72 31 30 2c 72  34 5d 3a 84 52 20 72 33  |4,[r10,r4]:.R r3|
00003e80  2c 72 33 2c 72 34 2c 4c  53 4c 23 31 36 0d 0f b4  |,r3,r4,LSL#16...|
00003e90  45 20 4d 4f 56 20 72 34  2c 72 32 2c 4c 53 52 23  |E MOV r4,r2,LSR#|
00003ea0  32 34 3a 4c 44 52 42 20  72 34 2c 5b 72 31 30 2c  |24:LDRB r4,[r10,|
00003eb0  72 34 5d 3a 84 52 20 72  33 2c 72 33 2c 72 34 2c  |r4]:.R r3,r3,r4,|
00003ec0  4c 53 4c 23 32 34 3a 5c  20 48 69 67 68 20 62 79  |LSL#24:\ High by|
00003ed0  74 65 0d 0f be 20 20 53  54 52 20 72 33 2c 5b 72  |te...  STR r3,[r|
00003ee0  38 5d 2c 23 34 3a 5c 20  57 72 69 74 65 20 77 6f  |8],#4:\ Write wo|
00003ef0  72 64 0d 0f c8 2c 20 4d  4f 56 20 72 30 2c 72 31  |rd..., MOV r0,r1|
00003f00  2c 4c 53 52 20 72 39 3a  42 47 54 20 6c 65 66 5f  |,LSR r9:BGT lef_|
00003f10  61 6c 3a 5c 20 4e 65 78  74 20 77 6f 72 64 0d 0f  |al:\ Next word..|
00003f20  d2 1e 20 4c 44 4d 46 44  20 72 31 33 21 2c 7b 70  |.. LDMFD r13!,{p|
00003f30  63 7d 5e 3a 5c 20 52 65  74 75 72 6e 0d 0f dc 05  |c}^:\ Return....|
00003f40  20 0d 0f e6 4b 2e 6d 61  6b 65 5f 6d 61 70 20 5c  | ...K.make_map \|
00003f50  20 4d 61 6b 65 73 20 6d  61 70 20 74 6f 20 63 6f  | Makes map to co|
00003f60  6e 76 65 72 74 20 70 69  78 65 6c 20 6f 72 64 65  |nvert pixel orde|
00003f70  72 20 77 69 74 68 69 6e  20 62 79 74 65 73 20 28  |r within bytes (|
00003f80  66 69 6c 6c 6f 72 64 65  72 3d 31 29 0d 0f f0 21  |fillorder=1)...!|
00003f90  20 53 54 4d 46 44 20 72  31 33 21 2c 7b 72 31 34  | STMFD r13!,{r14|
00003fa0  7d 3a 5c 20 53 61 76 65  20 6c 69 6e 6b 0d 0f fa  |}:\ Save link...|
00003fb0  39 20 4c 44 52 20 72 32  2c 6d 61 70 3a 4d 4f 56  |9 LDR r2,map:MOV|
00003fc0  20 72 30 2c 23 32 35 35  3a 5c 20 4d 61 70 20 73  | r0,#255:\ Map s|
00003fd0  74 61 72 74 2c 20 66 69  72 73 74 20 62 79 74 65  |tart, first byte|
00003fe0  20 76 61 6c 75 65 0d 10  04 21 20 4c 44 52 20 72  | value...! LDR r|
00003ff0  33 2c 62 69 74 73 3a 5c  20 42 69 74 73 20 70 65  |3,bits:\ Bits pe|
00004000  72 20 70 69 78 65 6c 0d  10 0e 49 2e 6d 61 6b 5f  |r pixel...I.mak_|
00004010  74 20 43 4d 50 20 72 33  2c 23 31 3a 42 45 51 20  |t CMP r3,#1:BEQ |
00004020  6d 61 6b 5f 74 31 3a 43  4d 50 20 72 33 2c 23 32  |mak_t1:CMP r3,#2|
00004030  3a 42 45 51 20 6d 61 6b  5f 74 32 3a 43 4d 50 20  |:BEQ mak_t2:CMP |
00004040  72 33 2c 23 34 3a 42 45  51 20 6d 61 6b 5f 74 34  |r3,#4:BEQ mak_t4|
00004050  0d 10 18 20 2e 6d 61 6b  5f 74 38 20 4d 4f 56 20  |... .mak_t8 MOV |
00004060  72 31 2c 72 30 3a 42 20  6d 61 6b 5f 74 75 72 6e  |r1,r0:B mak_turn|
00004070  0d 10 22 44 2e 6d 61 6b  5f 74 34 20 80 20 72 34  |.."D.mak_t4 . r4|
00004080  2c 72 30 2c 23 31 35 3a  4d 4f 56 20 72 31 2c 72  |,r0,#15:MOV r1,r|
00004090  30 2c 4c 53 52 23 34 3a  84 52 20 72 31 2c 72 31  |0,LSR#4:.R r1,r1|
000040a0  2c 72 34 2c 4c 53 4c 23  34 3a 42 20 6d 61 6b 5f  |,r4,LSL#4:B mak_|
000040b0  74 75 72 6e 0d 10 2c 83  2e 6d 61 6b 5f 74 32 20  |turn..,..mak_t2 |
000040c0  80 20 72 34 2c 72 30 2c  23 33 3a 80 20 72 35 2c  |. r4,r0,#3:. r5,|
000040d0  72 30 2c 23 33 3c 3c 32  3a 80 20 72 36 2c 72 30  |r0,#3<<2:. r6,r0|
000040e0  2c 23 33 3c 3c 34 3a 4d  4f 56 20 72 31 2c 72 30  |,#3<<4:MOV r1,r0|
000040f0  2c 4c 53 52 23 36 3a 84  52 20 72 31 2c 72 31 2c  |,LSR#6:.R r1,r1,|
00004100  72 36 2c 4c 53 52 23 32  3a 84 52 20 72 31 2c 72  |r6,LSR#2:.R r1,r|
00004110  31 2c 72 35 2c 4c 53 4c  23 32 3a 84 52 20 72 31  |1,r5,LSL#2:.R r1|
00004120  2c 72 31 2c 72 34 2c 4c  53 4c 23 36 3a 42 20 6d  |,r1,r4,LSL#6:B m|
00004130  61 6b 5f 74 75 72 6e 0d  10 36 29 2e 6d 61 6b 5f  |ak_turn..6).mak_|
00004140  74 31 20 4d 4f 56 20 72  34 2c 72 30 3a 4d 4f 56  |t1 MOV r4,r0:MOV|
00004150  20 72 35 2c 23 38 3a 4d  4f 56 20 72 31 2c 23 30  | r5,#8:MOV r1,#0|
00004160  0d 10 40 44 2e 6d 61 6b  5f 74 31 72 20 4d 4f 56  |..@D.mak_t1r MOV|
00004170  53 20 72 34 2c 72 34 2c  4c 53 52 23 31 3a 41 44  |S r4,r4,LSR#1:AD|
00004180  43 20 72 31 2c 72 31 2c  72 31 3a 53 55 42 53 20  |C r1,r1,r1:SUBS |
00004190  72 35 2c 72 35 2c 23 31  3a 42 4e 45 20 6d 61 6b  |r5,r5,#1:BNE mak|
000041a0  5f 74 31 72 0d 10 4a 47  2e 6d 61 6b 5f 74 75 72  |_t1r..JG.mak_tur|
000041b0  6e 20 53 54 52 42 20 72  31 2c 5b 72 32 2c 72 30  |n STRB r1,[r2,r0|
000041c0  5d 3a 53 55 42 53 20 72  30 2c 72 30 2c 23 31 3a  |]:SUBS r0,r0,#1:|
000041d0  42 50 4c 20 6d 61 6b 5f  74 3a 5c 20 4e 65 78 74  |BPL mak_t:\ Next|
000041e0  20 62 79 74 65 20 76 61  6c 75 65 0d 10 54 1e 20  | byte value..T. |
000041f0  4c 44 4d 46 44 20 72 31  33 21 2c 7b 70 63 7d 5e  |LDMFD r13!,{pc}^|
00004200  3a 5c 20 52 65 74 75 72  6e 0d 10 5e 05 20 0d 10  |:\ Return..^. ..|
00004210  68 06 5d ed 0d 10 72 05  e1 0d 10 7c 05 20 0d 10  |h.]...r....|. ..|
00004220  86 15 dd a4 73 77 69 5f  74 6f 5f 6e 72 28 73 77  |....swi_to_nr(sw|
00004230  69 24 29 0d 10 90 29 f4  20 52 65 74 75 72 6e 73  |i$)...). Returns|
00004240  20 53 57 49 20 6e 75 6d  62 65 72 20 6f 66 20 53  | SWI number of S|
00004250  57 49 20 63 61 6c 6c 20  73 77 69 24 0d 10 9a 0c  |WI call swi$....|
00004260  ea 20 73 77 69 6e 72 25  0d 10 a4 2f c8 99 20 22  |. swinr%.../.. "|
00004270  58 4f 53 5f 53 57 49 4e  75 6d 62 65 72 46 72 6f  |XOS_SWINumberFro|
00004280  6d 53 74 72 69 6e 67 22  2c 2c 73 77 69 24 20 b8  |mString",,swi$ .|
00004290  20 73 77 69 6e 72 25 0d  10 ae 0b 3d 73 77 69 6e  | swinr%....=swin|
000042a0  72 25 0d 10 b8 05 20 0d  10 c2 1a dd f2 65 72 72  |r%.... ......err|
000042b0  6f 72 28 65 72 72 6e 72  2c 65 72 72 6d 73 67 24  |or(errnr,errmsg$|
000042c0  29 0d 10 cc 14 f4 20 48  61 6e 64 6c 65 73 20 65  |)..... Handles e|
000042d0  72 72 6f 72 73 0d 10 d6  0f ea 20 62 75 74 25 2c  |rrors..... but%,|
000042e0  6f 70 74 25 0d 10 e0 27  e7 65 72 72 6e 72 3d 2d  |opt%...'.errnr=-|
000042f0  31 20 8c 20 65 72 72 6e  72 3d 31 3a 6f 70 74 25  |1 . errnr=1:opt%|
00004300  3d 31 20 8b 20 6f 70 74  25 3d 33 0d 10 ea 1f 21  |=1 . opt%=3....!|
00004310  65 72 72 3d 65 72 72 6e  72 3a 24 28 65 72 72 2b  |err=errnr:$(err+|
00004320  34 29 3d 65 72 72 6d 73  67 24 0d 10 f4 2a c8 99  |4)=errmsg$...*..|
00004330  20 57 52 65 70 6f 72 74  25 2c 65 72 72 2c 6f 70  | WReport%,err,op|
00004340  74 25 2c 61 70 70 6c 6e  61 6d 65 24 20 b8 20 2c  |t%,applname$ . ,|
00004350  62 75 74 25 0d 10 fe 13  e7 62 75 74 25 3c 3e 31  |but%.....but%<>1|
00004360  20 8c 20 f2 64 69 65 0d  11 08 05 e1 0d 11 12 05  | . .die.........|
00004370  20 0d 11 1c 0c dd f2 66  69 6e 69 73 68 0d 11 26  | ......finish..&|
00004380  0f f4 20 54 69 64 69 65  73 20 75 70 0d 11 30 2d  |.. Tidies up..0-|
00004390  c8 99 20 22 57 69 6d 70  5f 43 6c 6f 73 65 44 6f  |.. "Wimp_CloseDo|
000043a0  77 6e 22 2c 54 61 73 6b  48 61 6e 64 6c 65 25 2c  |wn",TaskHandle%,|
000043b0  26 34 42 35 33 34 31 35  34 0d 11 3a 05 e1 0d 11  |&4B534154..:....|
000043c0  44 05 20 0d 11 4e 09 dd  f2 64 69 65 0d 11 58 19  |D. ..N...die..X.|
000043d0  f4 20 54 69 64 69 65 73  20 75 70 20 61 6e 64 20  |. Tidies up and |
000043e0  65 78 69 74 73 0d 11 62  0b f2 66 69 6e 69 73 68  |exits..b..finish|
000043f0  0d 11 6c 10 c8 99 20 22  4f 53 5f 45 78 69 74 22  |..l... "OS_Exit"|
00004400  0d 11 76 05 e1 0d ff                              |..v....|
00004407