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

Graphics/!MakeGIF/!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/!MakeGIF/!RunImage
Read OK:
File size: 37CB bytes
Load address: 0000
Exec address: 0000
File contents
   10REM >!RunImage
   20REMLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOGLOG
   30REM Creates GIF file from sprite or Clear file                 (RISCWARE)
   40REM Version date : Thu,21 Jun 1990.20:10:33
   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 dum% 1024,Palette%(256)
  120DIM Table% 50*1024:REM Required space for decompression tables
  130Headsize%=4096:DIM Head% Headsize%:REM Buffer for file header
  140Progneed%=90*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,"MakeGIF 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 GIF file to create
  800  PROChour_on:REM Hourglass on
  810  PROCmake_GIF(type%,Input$,Output$,error$):REM Create GIF file
  820  PROChour_off:REM Hourglass off
  830  IFerror$<>"" THEN
  840   SYS "OS_File",6,Output$:REM Kill outputfile
  850   PROCerror(-1,error$):REM Report error
  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 GIF 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
 1000 WHEN &CCF00 : REM Other MakeGIF asks to kill module
 1010  poll!12=poll!8:SYS WSendMsg%,19,poll,poll!4:REM Hands off !
 1020ENDCASE
 1030ENDPROC
 1040
 1050DEFPROCmouseclick
 1060but%=poll!8:win%=poll!12:ico%=poll!16:REM Buttons/window/icon
 1070CASE win% OF
 1080 WHEN -2 : REM Click on iconbar
 1090  IFico%=Iiconbar% THEN IF(but%AND7)=2 THEN PROCiconbar_menu
 1100 WHEN win_file% : REM Click on save file window
 1110  IFico%=0 THEN
 1120   CASE but% AND &7F OF
 1130    WHEN 16,64 : REM Drag,calculate drag box and create it
 1140     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
 1150     !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%
 1160     SYS WDragB%,,block:REM Create drag box
 1170   ENDCASE
 1180  ENDIF
 1190ENDCASE
 1200ENDPROC
 1210
 1220DEFPROCdragdrop
 1230SYS WGetPI%,,block:REM Get pointer position
 1240dropwin%=block!12:dropico%=block!16:REM Window/icon where box dropped
 1250filename$=FNstring(SAVfn%):REM Filename for save
 1260block!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
 1270SYS WSendMsg%,17,block,dropwin%,dropico%:REM Send DataSave
 1280DataSaveRef%=block!8:REM Remember myref for DataSave
 1290PROCclose_window(win_file%):REM Close save file window
 1300ENDPROC
 1310 
 1320DEFPROCmake_GIF(type%,InFile$,OutFile$,RETURN error$)
 1330REM Creates GIF file OutFile$ from :
 1340REM (type%=&FF9) first sprite in sprite file
 1350REM (type%=&690) image in Clear file
 1360REM Returns error in error$ if error occured, else ""
 1370LOCAL ERROR
 1380ON ERROR LOCAL error$=REPORT$+" (code "+STR$ERL+")":PROCclosef:ENDPROC
 1390error$="":In=0:Out=0:REM No errors (yet), files both closed
 1400In=OPENIN(InFile$):REM Open input file
 1410CASE type% OF
 1420 WHEN &FF9 : REM Sprite file
 1430  SYS "OS_GBPB",4,In,Head%+4,Headsize%:REM Read sprite file header
 1440  spr%=Head%+Head%!8:REM Start of first sprite
 1450  sprname$="":ptr%=spr%+4:WHILE (?ptr%<>0) AND (LENsprname$<12):sprname$+=CHR$(?ptr%):ptr%+=1:ENDWHILE:REM Sprite's name
 1460  wordw%=spr%!16+1:height%=spr%!20+1:REM Width in words, height in rows
 1470  firstb%=spr%!24:lastb%=spr%!28:REM First/last bit used in border words
 1480  image%=spr%+spr%!32:REM Pointer to image data
 1490  mode%=spr%!40:palette%=spr%+44:REM Sprite's mode, pointer to palette
 1500  colbits%=2^FNmode_var(mode%,9):REM Bits per pixel
 1510  colours%=2^colbits%:REM Number of colours
 1520  width%=(wordw%*32-(31-lastb%)-firstb%) DIV colbits%:REM Width in pixels
 1530  IFimage%<=palette% THEN
 1540   REM Sprite has no palette : use default palette
 1550   CASE colours% OF
 1560    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
 1570    WHEN 16 : Palette%()=0,&F00000,&F000,&F0F000,&F0,&F000F0,&F0F0,&F0F0F0,0,&F00000,&F000,&F0F000,&F0,&F000F0,&F0F0,&F0F0F0
 1580    WHEN 4 : Palette%()=0,&F00000,&F0F000,&F0F0F0
 1590    WHEN 2 : Palette%()=0,&F0F0F0
 1600   ENDCASE
 1610  ELSE REM Read sprite's own palette
 1620   IFcolours%<=16 THEN
 1630    REM All palette entries present
 1640    FOR c%=0 TO colours%-1:Palette%(c%)=FNpaltorgb(palette%!(c%*8)):NEXT
 1650   ELSE REM Only 64 palette entries present, deduce all from first 16
 1660    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
 1670   ENDIF
 1680  ENDIF
 1690  raswidth%=FNmode_var(mode%,11)+1:REM 'Raster' width
 1700  rasheight%=FNmode_var(mode%,12)+1:REM 'Raster' height%
 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. GIF does not support these !":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  raswidth%=width%:rasheight%=height%:REM No actual 'raster size'
 1810  dataptr%=ptr%-Head%:REM Offset to image data
 1820ENDCASE
 1830Out=OPENOUT(OutFile$):REM Open output GIF file
 1840PROCouts("GIF87a"):REM GIF signature
 1850PROCoutd(raswidth%):REM Raster width in pixels
 1860PROCoutd(rasheight%):REM Raster height in pixels
 1870PROCoutb((1<<7)+((colbits%-1)<<4)+colbits%-1):REM Flags + colbits
 1880PROCoutb(0):REM Background colour index
 1890PROCoutb(0):REM Reserved
 1900FOR colour%=0 TO colours%-1:p%=Palette%(colour%):r%=p%>>16:g%=(p%>>8)AND&FF:b%=p%AND&FF:PROCoutb(r%):PROCoutb(g%):PROCoutb(b%):NEXT:REM Palette
 1910PROCouts(","):REM Image separator character
 1920PROCoutd(0):PROCoutd(0):REM Left/right offsets of image in raster
 1930PROCoutd(width%):PROCoutd(height%):REM Width and height of image
 1940PROCoutb((0<<7)+(0<<6)+colbits%-1):REM Flags + colbits
 1950REM Now prepare compression by machinecode routines
 1960PROCvar("iptr",dataptr%)::REM Offset to image data
 1970PROCvar("ifha",In):PROCvar("ofha",Out):REM File handles of input/output
 1980PROCvar("tabb",Table%):REM Free space for compression tables etc.
 1990PROCvar("inbf",Input%):PROCvar("outb",Output%):REM Input and output buffer
 2000PROCvar("outs",Outputsize%):PROCvar("insz",Inputsize%):REM Buffer sizes
 2010PROCvar("bits",colbits%):REM Bits per pixel
 2020PROCvar("widt",width%):PROCvar("heig",height%):REM Image width and height
 2030IFtype%=&FF9 THEN PROCvar("left",firstb%):PROCvar("righ",lastb%):PROCvar("word",wordw%):REM Extra info for sprite input
 2040PROCvar("type",type%):REM Set image type
 2050PROCvar("blsi",254):REM Maximum size of count-byte blocks
 2060IFcolbits%=1 THEN PROCoutb(2) ELSE PROCoutb(colbits%):REM Output codesize
 2070SYS "MakeGIF_Compress":REM GIF compression
 2080PROCouts(";"):REM GIF terminator character
 2090PROCouts("Zeridajh MakeGIF"):REM Maker's stamp
 2100CLOSE#In:REM Close input sprite file
 2110CLOSE#Out:REM Close GIF file
 2120SYS "OS_CLI","SetType "+OutFile$+" 695":REM Filetype as GIF file
 2130ENDPROC
 2140 
 2150DEFPROCclosef
 2160REM Closes files on error
 2170IFIn>0 THEN CLOSE#In
 2180IFOut>0 THEN CLOSE#Out
 2190ENDPROC
 2200 
 2210DEFPROCouts(out$)
 2220REM Outputs string to outfile
 2230LOCAL c%
 2240FOR c%=1 TO LENout$:BPUT#Out,ASCMID$(out$,c%):NEXT
 2250ENDPROC
 2260 
 2270DEFPROCoutd(out%)
 2280REM Outputs double-byte to outfile
 2290BPUT#Out,out%:BPUT#Out,out%>>8
 2300ENDPROC
 2310 
 2320DEFPROCoutb(out%)
 2330REM Outputs byte to outfile
 2340BPUT#Out,out%
 2350ENDPROC
 2360 
 2370DEFFNmode_var(mode%,var%)
 2380REM Returns mode variable
 2390LOCAL val%
 2400SYS "OS_ReadModeVariable",mode%,var% TO ,,val%
 2410=val%
 2420 
 2430DEFFNstring(addr%)
 2440REM Returns CTRL-char terminated string at addr%
 2450LOCAL _%,_c%,_$
 2460_%=-1:REPEAT _%+=1:UNTIL addr%?_%<32
 2470_c%=addr%?_%:addr%?_%=13:_$=$addr%:addr%?_%=_c%
 2480=_$
 2490 
 2500DEFPROCmouse(RETURN x%,RETURN y%,RETURN but%)
 2510REM Returns x,y and button state of mouse
 2520MOUSE x%,y%,but%
 2530ENDPROC
 2540 
 2550DEFPROChour_on
 2560REM Turns hourglass on after 1 sec
 2570SYS "Hourglass_On"
 2580ENDPROC
 2590 
 2600DEFPROChour_off
 2610REM Turns hourglass off
 2620SYS "Hourglass_Off"
 2630ENDPROC
 2640 
 2650DEFFNOSvar(name$)
 2660REM Attempts to return OS-var's string value
 2670LOCAL _r$,_l%
 2680_r$=STRING$(100," "):SYS "XOS_ReadVarVal",name$,_r$,LEN_r$,0,3 TO ,_r$,_l%
 2690=LEFT$(_r$,_l%)
 2700 
 2710DEFFNpaltorgb(pal%)
 2720REM Returns &RRGGBB from sprite palette entry
 2730=(pal%>>>24)+((pal%>>>8)AND&FF00)+((pal%<<8)AND&FF0000)
 2740 
 2750DEFPROCiconbar_menu
 2760REM Pops up menu for iconbar icon
 2770PROCmouse(x%,y%,_%):x%-=64:REM Get coordinates via mouse
 2780$menu="MakeGIF":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
 2790menu!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
 2800SYS WCreateM%,,menu,x%,y%:REM Create iconbar menu
 2810ENDPROC
 2820 
 2830DEFPROCopen_window(handle%,info)
 2840REM Opens window with handle handle%
 2850REM If info<>0 then info is ready at info, else get info
 2860LOCAL b%,px%,py%,_%,xs%,ys%
 2870IFinfo<>0 THEN
 2880 FOR b%=0 TO 31 STEP 4:block!b%=info!b%:NEXT
 2890ELSE !block=handle%:SYS WGetWS%,,block
 2900 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%
 2910ENDIF
 2920SYS WOpenW%,,block
 2930ENDPROC
 2940 
 2950DEFPROCclose_window(handle%)
 2960REM Closes window with handle handle%
 2970!block=handle%:SYS WCloseW%,,block
 2980ENDPROC
 2990 
 3000DEFFNpoll(mask%)
 3010REM Returns poll reason code, masking with mask%, data at poll
 3020LOCAL reasoncode
 3030SYS WPoll%,mask%,poll TO reasoncode
 3040=reasoncode
 3050 
 3060DEFPROCinitialise
 3070REM Initialises program
 3080applname$="MakeGIF":REM Name of application
 3090SYS "Wimp_Initialise",200,&4B534154,applname$ TO version,TaskHandle%
 3100IFversion<200 THEN ERROR 1,"I cannot work with WIMP pre-2.00"
 3110W%=FNswi_to_nr("Wimp_Initialise"):REM Base SWI number
 3120WCreateW%=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
 3130tf%=7:tb%=2:wf%=7:wb%=0:si%=1:so%=3:REM Window/menu colours
 3140!block=-1:block!4=0:block!8=0:block!12=68:block!16=68:block!20=&27003002:$(block+24)="!makegif":SYS WCreateI%,,block TO Iiconbar%:REM Iconbar icon
 3150REM Load templates
 3160SYS "Wimp_OpenTemplate",,"<MakeGIF$Dir>.Templates"
 3170ic=icondata:ie=icondend:REM Indirected icon data workspace
 3180$dum%="save":SYS WLoadT%,,window1,ic,ie,-1,dum%,0 TO ,,ic
 3190SYS WCreateW%,,window1 TO win_file%
 3200SAVfn%=FNiconaddr(win_file%,1)
 3210$dum%="info":SYS WLoadT%,,window2,ic,ie,-1,dum%,0 TO ,,ic
 3220SYS WCreateW%,,window2 TO win_info%
 3230SYS "Wimp_CloseTemplate"
 3240REM Initialise variables
 3250Output$="":Input$="":DataLoadRef%=FALSE:DataSaveRef%=-1:REM Init globals
 3260ENDPROC
 3270 
 3280DEFFNiconaddr(win%,ico%)
 3290REM Returns indirected icon's data address
 3300!block=win%:block!4=ico%:SYS WGetIS%,,block:REM Get icon info
 3310=block!28
 3320 
 3330DEFFNswi_to_nr(swi$)
 3340REM Returns SWI number of SWI call swi$
 3350LOCAL swinr%
 3360SYS "XOS_SWINumberFromString",,swi$ TO swinr%
 3370=swinr%
 3380 
 3390DEFPROCerror(errnr,errmsg$)
 3400REM Handles errors
 3410LOCAL but%,opt%
 3420IFerrnr=-1 THEN errnr=1:opt%=1 ELSE opt%=3
 3430!err=errnr:$(err+4)=errmsg$
 3440SYS WReport%,err,opt%,applname$ TO ,but%
 3450IFbut%<>1 THEN PROCdie
 3460ENDPROC
 3470 
 3480DEFPROCfinish
 3490REM Tidies up
 3500REM Send message to ask if module can be killed
 3510!block=20:block!12=0:block!16=&CCF00:SYS WSendMsg%,18,block,0:kill=FALSE:REPEAT listen%=FNpoll(0):kill=kill OR ((listen%=19)AND(poll!16=&CCF00)AND(poll!12=0)):UNTIL listen%=0:IFkill THEN SYS "OS_Module",4,"MakeGIF"
 3520SYS "Wimp_CloseDown",TaskHandle%,&4B534154
 3530ENDPROC
 3540 
 3550DEFPROCdie
 3560REM Tidies up and exits
 3570PROCfinish
 3580SYS "OS_Exit"
 3590ENDPROC
 3600 
 3610DEFPROCvar(varname$,value%)
 3620REM Writes module variable
 3630$dum%=varname$:SYS "MakeGIF_SetVariable",!dum%,value%
 3640ENDPROC
 3650 
 3660DEFFNvar(varname$)
 3670REM Reads module variable
 3680LOCAL value%
 3690$dum%=varname$:SYS "MakeGIF_ReadVariable",!dum% TO value%

� >!RunImage
K��������������������������������������������������������������������
K� Creates GIF file from sprite or Clear file                 (RISCWARE)
(-� Version date : Thu,21 Jun 1990.20:10:33
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� dum% 1024,Palette%(256)
x>� Table% 50*1024:� Required space for decompression tables
�=Headsize%=4096:� Head% Headsize%:� Buffer for file header
�GProgneed%=90*1024:� Memory needed for program+vars, without buffers
�"Total%=�-�:� Total memory free
�5Buffree%=Total%-Progneed%:� Free for file buffers
�=�Buffree%<20*1024 � � 1,"MakeGIF 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
E  Output$=�string(poll+44):� Read path-name of GIF file to create
   �hour_on:� Hourglass on
*>  �make_GIF(type%,Input$,Output$,error$):� Create GIF file
4  �hour_off:� Hourglass off
>  �error$<>"" �
H/   ș "OS_File",6,Output$:� Kill outputfile
R'   �error(-1,error$):� Report error
\  �
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 �
�7   � Sprite or Clear file, prepare to make GIF 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%=�
�3 � &CCF00 : � Other MakeGIF asks to kill module
�>  poll!12=poll!8:ș WSendMsg%,19,poll,poll!4:� Hands off !
��
�

��mouseclick
$?but%=poll!8:win%=poll!12:ico%=poll!16:� Buttons/window/icon
.
Ȏ win% �
8 � -2 : � Click on iconbar
B3  �ico%=Iiconbar% � �(but%�7)=2 � �iconbar_menu
L. � win_file% : � Click on save file window
V  �ico%=0 �
`   Ȏ but% � &7F �
j9    � 16,64 : � Drag,calculate drag box and create it
tz     ScrW%=�mode_var(�,11)<<�mode_var(�,4):ScrH%=�mode_var(�,12)<<�mode_var(�,5):� Screen width and height in OS-units
~�     !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%
�,     ș 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
�
 
(/��make_GIF(type%,InFile$,OutFile$,� error$)
2&� Creates GIF file OutFile$ from :
<.� (type%=&FF9) first sprite in sprite file
F&� (type%=&690) image in Clear file
P7� Returns error in error$ if error occured, else ""
Z� �
d.� � � error$=�$+" (code "+Þ+")":�closef:�
n=error$="":In=0:Out=0:� No errors (yet), files both closed
x#In=�(InFile$):� Open input file
�Ȏ type% �
� � &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
6"    � 2 : Palette%()=0,&F0F0F0
@   �
J#  � � Read sprite's own palette
T   �colours%<=16 �
^%    � All palette entries present
hE    � c%=0 � colours%-1:Palette%(c%)=�paltorgb(palette%!(c%*8)):�
rD   � � Only 64 palette entries present, deduce all from first 16
|�    � 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):�
�   �
�  �
�6  raswidth%=�mode_var(mode%,11)+1:� 'Raster' width
�9  rasheight%=�mode_var(mode%,12)+1:� 'Raster' height%
�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
�a  �colbits%>8 � error$="I cannot handle pure RGB Clear files. GIF does not support these !":�
�,  colours%=2^colbits%:� Colours in image
�b  � c%=0 � colours%-1:Palette%(c%)=((?ptr%)<<16)+((ptr%?1)<<8)+ptr%?2:ptr%+=3:�:� Read palette
C  raswidth%=width%:rasheight%=height%:� No actual 'raster size'
0  dataptr%=ptr%-Head%:� Offset to image data
�
&*Out=�(OutFile$):� Open output GIF file
0#�outs("GIF87a"):� GIF signature
:-�outd(raswidth%):� Raster width in pixels
D/�outd(rasheight%):� Raster height in pixels
N@�outb((1<<7)+((colbits%-1)<<4)+colbits%-1):� Flags + colbits
X&�outb(0):� Background colour index
b�outb(0):� Reserved
l~� colour%=0 � colours%-1:p%=Palette%(colour%):r%=p%>>16:g%=(p%>>8)�&FF:b%=p%�&FF:�outb(r%):�outb(g%):�outb(b%):�:� Palette
v*�outs(","):� Image separator character
�=�outd(0):�outd(0):� Left/right offsets of image in raster
�<�outd(width%):�outd(height%):� Width and height of image
�5�outb((0<<7)+(0<<6)+colbits%-1):� Flags + colbits
�5� Now prepare compression by machinecode routines
�1�var("iptr",dataptr%)::� Offset to image data
�C�var("ifha",In):�var("ofha",Out):� File handles of input/output
�@�var("tabb",Table%):� Free space for compression tables etc.
�F�var("inbf",Input%):�var("outb",Output%):� Input and output buffer
�C�var("outs",Outputsize%):�var("insz",Inputsize%):� Buffer sizes
�*�var("bits",colbits%):� Bits per pixel
�E�var("widt",width%):�var("heig",height%):� Image width and height
�l�type%=&FF9 � �var("left",firstb%):�var("righ",lastb%):�var("word",wordw%):� Extra info for sprite input
�'�var("type",type%):� Set image type
8�var("blsi",254):� Maximum size of count-byte blocks
>�colbits%=1 � �outb(2) � �outb(colbits%):� Output codesize
+ș "MakeGIF_Compress":� GIF compression
 )�outs(";"):� GIF terminator character
*-�outs("Zeridajh MakeGIF"):� Maker's stamp
4"�#In:� Close input sprite file
>�#Out:� Close GIF file
HAș "OS_CLI","SetType "+OutFile$+" 695":� Filetype as GIF file
R�
\ 
f��closef
p� Closes files on error
z�In>0 � �#In
��Out>0 � �#Out
��
� 
���outs(out$)
�� Outputs string to outfile
�� c%
�%� c%=1 � �out$:�#Out,��out$,c%):�
��
� 
���outd(out%)
�$� Outputs double-byte to outfile
��#Out,out%:�#Out,out%>>8
��
	 
	��outb(out%)
	� Outputs byte to outfile
	$�#Out,out%
	.�
	8 
	Bݤmode_var(mode%,var%)
	L� Returns mode variable
	V
� val%
	`0ș "OS_ReadModeVariable",mode%,var% � ,,val%
	j	=val%
	t 
	~ݤ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
$� Turns hourglass on after 1 sec

ș "Hourglass_On"
�
 
(��hour_off
2� Turns hourglass off
<ș "Hourglass_Off"
F�
P 
ZݤOSvar(name$)
d.� Attempts to return OS-var's string value
n
� _r$,_l%
xC_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
�s$menu="MakeGIF":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
��
 
��open_window(handle%,info)
&� Opens window with handle handle%
":� If info<>0 then info is ready at info, else get info
,� b%,px%,py%,_%,xs%,ys%
6�info<>0 �
@' � b%=0 � 31 � 4:block!b%=info!b%:�
J&� !block=handle%:ș WGetWS%,,block
T� �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%
^�
hș WOpenW%,,block
r�
| 
���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
�� Initialises program
-applname$="MakeGIF":� Name of application
Fș "Wimp_Initialise",200,&4B534154,applname$ � version,TaskHandle%
9�version<200 � � 1,"I cannot work with WIMP pre-2.00"
&6W%=�swi_to_nr("Wimp_Initialise"):� Base SWI number
0�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
:=tf%=7:tb%=2:wf%=7:wb%=0:si%=1:so%=3:� Window/menu colours
D�!block=-1:block!4=0:block!8=0:block!12=68:block!16=68:block!20=&27003002:$(block+24)="!makegif":ș WCreateI%,,block � Iiconbar%:� Iconbar icon
N� Load templates
X5ș "Wimp_OpenTemplate",,"<MakeGIF$Dir>.Templates"
b<ic=icondata:ie=icondend:� Indirected icon data workspace
l;$dum%="save":ș WLoadT%,,window1,ic,ie,-1,dum%,0 � ,,ic
v%ș 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
��
� 
�ݤiconaddr(win%,ico%)
�,� Returns indirected icon's data address
�>!block=win%:block!4=ico%:ș WGetIS%,,block:� Get icon info
�
=block!28
� 

ݤswi_to_nr(swi$)

)� Returns SWI number of SWI call swi$

� swinr%

 /ș "XOS_SWINumberFromString",,swi$ � swinr%

*=swinr%

4 

>��error(errnr,errmsg$)

H� Handles errors

R� but%,opt%

\'�errnr=-1 � errnr=1:opt%=1 � opt%=3

f!err=errnr:$(err+4)=errmsg$

p*ș WReport%,err,opt%,applname$ � ,but%

z�but%<>1 � �die

��

� 

���finish

�� Tidies up

�1� Send message to ask if module can be killed

��!block=20:block!12=0:block!16=&CCF00:ș WSendMsg%,18,block,0:kill=�:� listen%=�poll(0):kill=kill � ((listen%=19)�(poll!16=&CCF00)�(poll!12=0)):� listen%=0:�kill � ș "OS_Module",4,"MakeGIF"

�-ș "Wimp_CloseDown",TaskHandle%,&4B534154

��

� 

�	��die

�� Tidies up and exits

��finish

�ș "OS_Exit"
�
 
��var(varname$,value%)
$� Writes module variable
.8$dum%=varname$:ș "MakeGIF_SetVariable",!dum%,value%
8�
B 
Lݤvar(varname$)
V� Reads module variable
`� value%
j;$dum%=varname$:ș "MakeGIF_ReadVariable",!dum% � value%
�
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 47 49 46 20 66 69 6c  | Creates GIF fil|
00000070  65 20 66 72 6f 6d 20 73  70 72 69 74 65 20 6f 72  |e from sprite or|
00000080  20 43 6c 65 61 72 20 66  69 6c 65 20 20 20 20 20  | 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 30  |1 Jun 1990.20:10|
000000d0  3a 33 33 0d 00 32 1e f4  20 a9 20 31 39 39 30 20  |:33..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 1d de 20 64  75 6d 25 20 31 30 32 34  |6..n.. dum% 1024|
000001f0  2c 50 61 6c 65 74 74 65  25 28 32 35 36 29 0d 00  |,Palette%(256)..|
00000200  78 3e de 20 54 61 62 6c  65 25 20 35 30 2a 31 30  |x>. Table% 50*10|
00000210  32 34 3a f4 20 52 65 71  75 69 72 65 64 20 73 70  |24:. Required sp|
00000220  61 63 65 20 66 6f 72 20  64 65 63 6f 6d 70 72 65  |ace for decompre|
00000230  73 73 69 6f 6e 20 74 61  62 6c 65 73 0d 00 82 3d  |ssion tables...=|
00000240  48 65 61 64 73 69 7a 65  25 3d 34 30 39 36 3a de  |Headsize%=4096:.|
00000250  20 48 65 61 64 25 20 48  65 61 64 73 69 7a 65 25  | Head% Headsize%|
00000260  3a f4 20 42 75 66 66 65  72 20 66 6f 72 20 66 69  |:. Buffer for fi|
00000270  6c 65 20 68 65 61 64 65  72 0d 00 8c 47 50 72 6f  |le header...GPro|
00000280  67 6e 65 65 64 25 3d 39  30 2a 31 30 32 34 3a f4  |gneed%=90*1024:.|
00000290  20 4d 65 6d 6f 72 79 20  6e 65 65 64 65 64 20 66  | Memory needed f|
000002a0  6f 72 20 70 72 6f 67 72  61 6d 2b 76 61 72 73 2c  |or program+vars,|
000002b0  20 77 69 74 68 6f 75 74  20 62 75 66 66 65 72 73  | without buffers|
000002c0  0d 00 96 22 54 6f 74 61  6c 25 3d 93 2d 90 3a f4  |..."Total%=.-.:.|
000002d0  20 54 6f 74 61 6c 20 6d  65 6d 6f 72 79 20 66 72  | Total memory fr|
000002e0  65 65 0d 00 a0 35 42 75  66 66 72 65 65 25 3d 54  |ee...5Buffree%=T|
000002f0  6f 74 61 6c 25 2d 50 72  6f 67 6e 65 65 64 25 3a  |otal%-Progneed%:|
00000300  f4 20 46 72 65 65 20 66  6f 72 20 66 69 6c 65 20  |. Free for file |
00000310  62 75 66 66 65 72 73 0d  00 aa 3d e7 42 75 66 66  |buffers...=.Buff|
00000320  72 65 65 25 3c 32 30 2a  31 30 32 34 20 8c 20 85  |ree%<20*1024 . .|
00000330  20 31 2c 22 4d 61 6b 65  47 49 46 20 63 61 6e 6e  | 1,"MakeGIF cann|
00000340  6f 74 20 73 74 61 72 74  75 70 20 70 72 6f 70 65  |ot startup prope|
00000350  72 6c 79 22 0d 00 b4 2e  68 61 6c 76 65 25 3d 28  |rly"....halve%=(|
00000360  42 75 66 66 72 65 65 25  81 32 29 80 ac 33 3a f4  |Buffree%.2)..3:.|
00000370  20 41 6c 69 67 6e 65 64  20 68 61 6c 66 20 73 69  | Aligned half si|
00000380  7a 65 0d 00 be 41 4f 75  74 70 75 74 73 69 7a 65  |ze...AOutputsize|
00000390  25 3d 68 61 6c 76 65 25  3a de 20 4f 75 74 70 75  |%=halve%:. Outpu|
000003a0  74 25 20 4f 75 74 70 75  74 73 69 7a 65 25 3a f4  |t% Outputsize%:.|
000003b0  20 4f 75 74 70 75 74 20  66 69 6c 65 20 62 75 66  | Output file buf|
000003c0  66 65 72 0d 00 c8 3d 49  6e 70 75 74 73 69 7a 65  |fer...=Inputsize|
000003d0  25 3d 68 61 6c 76 65 25  3a de 20 49 6e 70 75 74  |%=halve%:. Input|
000003e0  25 20 49 6e 70 75 74 73  69 7a 65 25 3a f4 20 49  |% Inputsize%:. I|
000003f0  6e 70 75 74 20 66 69 6c  65 20 62 75 66 66 65 72  |nput file buffer|
00000400  0d 00 d2 28 f2 69 6e 69  74 69 61 6c 69 73 65 3a  |...(.initialise:|
00000410  f4 20 49 6e 69 74 69 61  6c 69 73 65 20 61 70 70  |. Initialise app|
00000420  6c 69 63 61 74 69 6f 6e  0d 00 dc 25 ee 20 85 20  |lication...%. . |
00000430  f2 65 72 72 6f 72 28 9f  2c f6 24 2b 22 20 28 63  |.error(.,.$+" (c|
00000440  6f 64 65 20 22 2b c3 9e  2b 22 29 22 29 0d 00 e6  |ode "+..+")")...|
00000450  17 f5 20 f4 20 50 6f 6c  6c 20 61 6e 64 20 61 63  |.. . Poll and ac|
00000460  74 69 6f 6e 0d 00 f0 11  c8 8e 20 a4 70 6f 6c 6c  |tion...... .poll|
00000470  28 30 29 20 ca 0d 00 fa  30 20 c9 20 30 20 3a 20  |(0) ....0 . 0 : |
00000480  f2 6e 75 6c 6c 3a f4 20  4e 6f 74 68 69 6e 67 20  |.null:. Nothing |
00000490  74 6f 20 64 6f 2c 20 70  65 72 66 6f 72 6d 20 63  |to do, perform c|
000004a0  68 65 63 6b 73 0d 01 04  2a 20 c9 20 31 20 3a 20  |hecks...* . 1 : |
000004b0  f2 72 65 64 72 61 77 3a  f4 20 52 65 64 72 61 77  |.redraw:. Redraw|
000004c0  20 77 69 6e 64 6f 77 20  72 65 71 75 65 73 74 0d  | window request.|
000004d0  01 0e 26 20 c9 20 32 20  3a 20 f2 6f 70 65 6e 3a  |..& . 2 : .open:|
000004e0  f4 20 4f 70 65 6e 20 77  69 6e 64 6f 77 20 72 65  |. Open window re|
000004f0  71 75 65 73 74 0d 01 18  28 20 c9 20 33 20 3a 20  |quest...( . 3 : |
00000500  f2 63 6c 6f 73 65 3a f4  20 43 6c 6f 73 65 20 77  |.close:. Close w|
00000510  69 6e 64 6f 77 20 72 65  71 75 65 73 74 0d 01 22  |indow request.."|
00000520  26 20 c9 20 36 20 3a 20  f2 6d 6f 75 73 65 63 6c  |& . 6 : .mousecl|
00000530  69 63 6b 3a f4 20 4d 6f  75 73 65 20 63 6c 69 63  |ick:. Mouse clic|
00000540  6b 65 64 0d 01 2c 3f 20  c9 20 37 20 3a 20 f2 64  |ked..,? . 7 : .d|
00000550  72 61 67 64 72 6f 70 3a  f4 20 55 73 65 72 20 68  |ragdrop:. User h|
00000560  61 73 20 64 72 6f 70 70  65 64 20 64 72 61 67 20  |as dropped drag |
00000570  62 6f 78 20 6f 66 20 66  69 6c 65 20 77 69 6e 64  |box of file wind|
00000580  6f 77 0d 01 36 1d 20 c9  20 38 20 3a 20 f2 6b 65  |ow..6. . 8 : .ke|
00000590  79 3a f4 20 4b 65 79 20  70 72 65 73 73 65 64 0d  |y:. Key pressed.|
000005a0  01 40 31 20 c9 20 39 20  3a 20 f2 6d 65 6e 75 73  |.@1 . 9 : .menus|
000005b0  65 6c 65 63 74 3a f4 20  4d 65 6e 75 20 73 65 6c  |elect:. Menu sel|
000005c0  65 63 74 69 6f 6e 20 66  72 6f 6d 20 75 73 65 72  |ection from user|
000005d0  0d 01 4a 2b 20 c9 20 31  37 2c 31 38 20 3a 20 f2  |..J+ . 17,18 : .|
000005e0  6d 65 73 73 61 67 65 3a  f4 20 4d 65 73 73 61 67  |message:. Messag|
000005f0  65 20 66 72 6f 6d 20 57  49 4d 50 0d 01 54 05 cb  |e from WIMP..T..|
00000600  0d 01 5e 07 fd 20 a3 0d  01 68 05 20 0d 01 72 10  |..^.. ...h. ..r.|
00000610  dd f2 6d 65 6e 75 73 65  6c 65 63 74 0d 01 7c 27  |..menuselect..|'|
00000620  73 65 6c 65 63 74 65 64  25 3d 70 6f 6c 6c 21 30  |selected%=poll!0|
00000630  3a f4 20 57 68 61 74 20  73 65 6c 65 63 74 69 6f  |:. What selectio|
00000640  6e 20 3f 0d 01 86 35 e7  73 65 6c 65 63 74 65 64  |n ?...5.selected|
00000650  25 3d 31 20 8c 20 f2 64  69 65 3a f4 20 51 75 69  |%=1 . .die:. Qui|
00000660  74 20 69 63 6f 6e 2c 20  74 69 64 79 20 75 70 20  |t icon, tidy up |
00000670  61 6e 64 20 65 78 69 74  0d 01 90 05 e1 0d 01 9a  |and exit........|
00000680  04 0d 01 a4 0b dd f2 63  6c 6f 73 65 0d 01 ae 28  |.......close...(|
00000690  f2 63 6c 6f 73 65 5f 77  69 6e 64 6f 77 28 70 6f  |.close_window(po|
000006a0  6c 6c 21 30 29 3a f4 20  43 6c 6f 73 65 20 77 69  |ll!0):. Close wi|
000006b0  6e 64 6f 77 0d 01 b8 05  e1 0d 01 c2 04 0d 01 cc  |ndow............|
000006c0  0a dd f2 6f 70 65 6e 0d  01 d6 26 f2 6f 70 65 6e  |...open...&.open|
000006d0  5f 77 69 6e 64 6f 77 28  30 2c 70 6f 6c 6c 29 3a  |_window(0,poll):|
000006e0  f4 20 4f 70 65 6e 20 77  69 6e 64 6f 77 0d 01 e0  |. Open window...|
000006f0  05 e1 0d 01 ea 04 0d 01  f4 0a dd f2 6e 75 6c 6c  |............null|
00000700  0d 01 fe 13 e7 44 61 74  61 4c 6f 61 64 52 65 66  |.....DataLoadRef|
00000710  25 20 8c 0d 02 08 3e 20  44 61 74 61 4c 6f 61 64  |% ....> DataLoad|
00000720  52 65 66 25 3d a3 3a c8  99 20 22 4f 53 5f 46 69  |Ref%=.:.. "OS_Fi|
00000730  6c 65 22 2c 36 2c 4f 75  74 70 75 74 24 3a f4 20  |le",6,Output$:. |
00000740  44 65 6c 65 74 65 20 66  69 6c 65 20 73 61 76 65  |Delete file save|
00000750  64 0d 02 12 43 20 f2 65  72 72 6f 72 28 2d 31 2c  |d...C .error(-1,|
00000760  22 42 61 64 20 64 61 74  61 20 74 72 61 6e 73 66  |"Bad data transf|
00000770  65 72 2c 20 72 65 63 65  69 76 65 72 20 64 65 61  |er, receiver dea|
00000780  64 22 29 3a f4 20 4e 6f  20 44 61 74 61 4c 6f 61  |d"):. No DataLoa|
00000790  64 41 63 6b 0d 02 1c 05  cd 0d 02 26 05 e1 0d 02  |dAck.......&....|
000007a0  30 04 0d 02 3a 09 dd f2  6b 65 79 0d 02 44 45 77  |0...:...key..DEw|
000007b0  69 6e 25 3d 70 6f 6c 6c  21 30 3a 69 63 6f 25 3d  |in%=poll!0:ico%=|
000007c0  70 6f 6c 6c 21 34 3a 63  68 61 72 25 3d 70 6f 6c  |poll!4:char%=pol|
000007d0  6c 21 32 34 3a f4 20 57  69 6e 64 6f 77 2c 20 69  |l!24:. Window, i|
000007e0  63 6f 6e 2c 20 6b 65 79  20 70 72 65 73 73 65 64  |con, key pressed|
000007f0  0d 02 4e 22 e7 28 77 69  6e 25 3d 77 69 6e 5f 66  |..N".(win%=win_f|
00000800  69 6c 65 25 29 20 80 20  28 69 63 6f 25 3d 31 29  |ile%) . (ico%=1)|
00000810  20 8c 0d 02 58 0f 20 c8  8e 20 63 68 61 72 25 20  | ...X. .. char% |
00000820  ca 0d 02 62 1d 20 20 c9  20 31 33 20 3a 20 f4 20  |...b.  . 13 : . |
00000830  52 65 74 75 72 6e 20 70  72 65 73 73 65 64 0d 02  |Return pressed..|
00000840  6c 43 20 20 20 f2 65 72  72 6f 72 28 2d 31 2c 22  |lC   .error(-1,"|
00000850  50 6c 65 61 73 65 20 64  72 61 67 20 74 68 65 20  |Please drag the |
00000860  66 69 6c 65 20 69 63 6f  6e 20 74 6f 20 61 20 64  |file icon to a d|
00000870  69 72 65 63 74 6f 72 79  20 76 69 65 77 65 72 22  |irectory viewer"|
00000880  29 0d 02 76 1d 20 20 c9  20 32 37 20 3a 20 f4 20  |)..v.  . 27 : . |
00000890  45 73 63 61 70 65 20 70  72 65 73 73 65 64 0d 02  |Escape pressed..|
000008a0  80 1f 20 20 20 f2 63 6c  6f 73 65 5f 77 69 6e 64  |..   .close_wind|
000008b0  6f 77 28 77 69 6e 5f 66  69 6c 65 25 29 0d 02 8a  |ow(win_file%)...|
000008c0  06 20 cb 0d 02 94 05 cd  0d 02 9e 05 e1 0d 02 a8  |. ..............|
000008d0  04 0d 02 b2 0d dd f2 6d  65 73 73 61 67 65 0d 02  |.......message..|
000008e0  bc 2d f4 20 49 67 6e 6f  72 65 20 6d 65 73 73 61  |.-. Ignore messa|
000008f0  67 65 73 20 6f 72 69 67  69 6e 61 74 69 6e 67 20  |ges originating |
00000900  66 72 6f 6d 20 6d 79 73  65 6c 66 0d 02 c6 36 e7  |from myself...6.|
00000910  28 70 6f 6c 6c 21 34 29  3d 54 61 73 6b 48 61 6e  |(poll!4)=TaskHan|
00000920  64 6c 65 25 20 8c 20 6d  73 67 6e 72 25 3d 2d 31  |dle% . msgnr%=-1|
00000930  20 8b 20 6d 73 67 6e 72  25 3d 70 6f 6c 6c 21 31  | . msgnr%=poll!1|
00000940  36 0d 02 d0 0f c8 8e 20  6d 73 67 6e 72 25 20 ca  |6...... msgnr% .|
00000950  0d 02 da 19 20 c9 20 2d  31 20 3a 20 f4 20 44 6f  |.... . -1 : . Do|
00000960  6e 27 74 20 72 65 61 63  74 0d 02 e4 2b 20 c9 20  |n't react...+ . |
00000970  30 20 3a 20 f2 64 69 65  3a f4 20 52 65 71 75 65  |0 : .die:. Reque|
00000980  73 74 20 74 6f 20 74 65  72 6d 69 6e 61 74 65 20  |st to terminate |
00000990  74 61 73 6b 0d 02 ee 2e  20 c9 20 31 20 3a 20 f4  |task.... . 1 : .|
000009a0  20 44 61 74 61 53 61 76  65 2c 20 74 72 61 6e 73  | DataSave, trans|
000009b0  66 65 72 20 76 69 61 20  73 63 72 61 70 20 66 69  |fer via scrap fi|
000009c0  6c 65 0d 02 f8 37 20 20  73 63 72 61 70 24 3d a4  |le...7  scrap$=.|
000009d0  4f 53 76 61 72 28 22 57  69 6d 70 24 53 63 72 61  |OSvar("Wimp$Scra|
000009e0  70 22 29 3a f4 20 52 65  61 64 20 73 63 72 61 70  |p"):. Read scrap|
000009f0  20 66 69 6c 65 6e 61 6d  65 0d 03 02 d2 20 20 e7  | filename....  .|
00000a00  73 63 72 61 70 24 3c 3e  22 22 20 8c 20 70 6f 6c  |scrap$<>"" . pol|
00000a10  6c 21 31 32 3d 70 6f 6c  6c 21 38 3a 70 6f 6c 6c  |l!12=poll!8:poll|
00000a20  21 31 36 3d 32 3a 70 6f  6c 6c 21 33 36 3d 2d 31  |!16=2:poll!36=-1|
00000a30  3a 24 28 70 6f 6c 6c 2b  34 34 29 3d 73 63 72 61  |:$(poll+44)=scra|
00000a40  70 24 2b bd 30 3a 70 6f  6c 6c 21 30 3d 34 34 2b  |p$+.0:poll!0=44+|
00000a50  28 a9 73 63 72 61 70 24  2b 31 2b 33 29 80 ac 33  |(.scrap$+1+3)..3|
00000a60  3a c8 99 20 57 53 65 6e  64 4d 73 67 25 2c 31 38  |:.. WSendMsg%,18|
00000a70  2c 70 6f 6c 6c 2c 70 6f  6c 6c 21 34 20 8b 20 f2  |,poll,poll!4 . .|
00000a80  65 72 72 6f 72 28 2d 31  2c 22 57 69 6d 70 24 53  |error(-1,"Wimp$S|
00000a90  63 72 61 70 20 6e 6f 74  20 64 65 66 69 6e 65 64  |crap not defined|
00000aa0  22 29 3a f4 20 53 65 6e  64 20 44 61 74 61 53 61  |"):. Send DataSa|
00000ab0  76 65 41 63 6b 20 69 66  20 73 63 72 61 70 20 66  |veAck if scrap f|
00000ac0  69 6c 65 20 64 65 66 69  6e 65 64 0d 03 0c 23 20  |ile defined...# |
00000ad0  c9 20 32 20 3a 20 f4 20  44 61 74 61 53 61 76 65  |. 2 : . DataSave|
00000ae0  41 63 6b 2c 20 73 61 76  65 20 66 69 6c 65 0d 03  |Ack, save file..|
00000af0  16 45 20 20 4f 75 74 70  75 74 24 3d a4 73 74 72  |.E  Output$=.str|
00000b00  69 6e 67 28 70 6f 6c 6c  2b 34 34 29 3a f4 20 52  |ing(poll+44):. R|
00000b10  65 61 64 20 70 61 74 68  2d 6e 61 6d 65 20 6f 66  |ead path-name of|
00000b20  20 47 49 46 20 66 69 6c  65 20 74 6f 20 63 72 65  | GIF file to cre|
00000b30  61 74 65 0d 03 20 1d 20  20 f2 68 6f 75 72 5f 6f  |ate.. .  .hour_o|
00000b40  6e 3a f4 20 48 6f 75 72  67 6c 61 73 73 20 6f 6e  |n:. Hourglass on|
00000b50  0d 03 2a 3e 20 20 f2 6d  61 6b 65 5f 47 49 46 28  |..*>  .make_GIF(|
00000b60  74 79 70 65 25 2c 49 6e  70 75 74 24 2c 4f 75 74  |type%,Input$,Out|
00000b70  70 75 74 24 2c 65 72 72  6f 72 24 29 3a f4 20 43  |put$,error$):. C|
00000b80  72 65 61 74 65 20 47 49  46 20 66 69 6c 65 0d 03  |reate GIF file..|
00000b90  34 1f 20 20 f2 68 6f 75  72 5f 6f 66 66 3a f4 20  |4.  .hour_off:. |
00000ba0  48 6f 75 72 67 6c 61 73  73 20 6f 66 66 0d 03 3e  |Hourglass off..>|
00000bb0  13 20 20 e7 65 72 72 6f  72 24 3c 3e 22 22 20 8c  |.  .error$<>"" .|
00000bc0  0d 03 48 2f 20 20 20 c8  99 20 22 4f 53 5f 46 69  |..H/   .. "OS_Fi|
00000bd0  6c 65 22 2c 36 2c 4f 75  74 70 75 74 24 3a f4 20  |le",6,Output$:. |
00000be0  4b 69 6c 6c 20 6f 75 74  70 75 74 66 69 6c 65 0d  |Kill outputfile.|
00000bf0  03 52 27 20 20 20 f2 65  72 72 6f 72 28 2d 31 2c  |.R'   .error(-1,|
00000c00  65 72 72 6f 72 24 29 3a  f4 20 52 65 70 6f 72 74  |error$):. Report|
00000c10  20 65 72 72 6f 72 0d 03  5c 07 20 20 cd 0d 03 66  | error..\.  ...f|
00000c20  3e 20 20 70 6f 6c 6c 21  31 32 3d 70 6f 6c 6c 21  |>  poll!12=poll!|
00000c30  38 3a 70 6f 6c 6c 21 31  36 3d 33 3a f4 20 41 6d  |8:poll!16=3:. Am|
00000c40  65 6e 64 20 64 61 74 61  20 62 6c 6f 63 6b 20 66  |end data block f|
00000c50  6f 72 20 44 61 74 61 4c  6f 61 64 0d 03 70 31 20  |or DataLoad..p1 |
00000c60  20 c8 99 20 57 53 65 6e  64 4d 73 67 25 2c 31 38  | .. WSendMsg%,18|
00000c70  2c 70 6f 6c 6c 2c 70 6f  6c 6c 21 34 3a f4 20 53  |,poll,poll!4:. S|
00000c80  65 6e 64 20 44 61 74 61  4c 6f 61 64 0d 03 7a 3f  |end DataLoad..z?|
00000c90  20 20 44 61 74 61 4c 6f  61 64 52 65 66 25 3d 70  |  DataLoadRef%=p|
00000ca0  6f 6c 6c 21 38 3a f4 20  41 77 61 69 74 20 61 20  |oll!8:. Await a |
00000cb0  44 61 74 61 4c 6f 61 64  41 63 6b 2c 20 72 65 6d  |DataLoadAck, rem|
00000cc0  65 6d 62 65 72 20 6d 79  72 65 66 0d 03 84 34 20  |ember myref...4 |
00000cd0  c9 20 33 20 3a 20 f4 20  44 61 74 61 4c 6f 61 64  |. 3 : . DataLoad|
00000ce0  2c 20 63 68 65 63 6b 20  69 66 20 73 70 72 69 74  |, check if sprit|
00000cf0  65 20 6f 72 20 43 6c 65  61 72 20 66 69 6c 65 0d  |e or Clear file.|
00000d00  03 8e 1e 20 20 74 79 70  65 25 3d 70 6f 6c 6c 21  |...  type%=poll!|
00000d10  34 30 3a f4 20 46 69 6c  65 74 79 70 65 0d 03 98  |40:. Filetype...|
00000d20  20 20 20 e7 74 79 70 65  25 3d 26 46 46 39 20 84  |   .type%=&FF9 .|
00000d30  20 74 79 70 65 25 3d 26  36 39 30 20 8c 0d 03 a2  | type%=&690 ....|
00000d40  37 20 20 20 f4 20 53 70  72 69 74 65 20 6f 72 20  |7   . Sprite or |
00000d50  43 6c 65 61 72 20 66 69  6c 65 2c 20 70 72 65 70  |Clear file, prep|
00000d60  61 72 65 20 74 6f 20 6d  61 6b 65 20 47 49 46 20  |are to make GIF |
00000d70  66 69 6c 65 0d 03 ac 29  20 20 20 49 6e 70 75 74  |file...)   Input|
00000d80  24 3d a4 73 74 72 69 6e  67 28 70 6f 6c 6c 2b 34  |$=.string(poll+4|
00000d90  34 29 3a f4 20 46 69 6c  65 6e 61 6d 65 0d 03 b6  |4):. Filename...|
00000da0  38 20 20 20 f2 6f 70 65  6e 5f 77 69 6e 64 6f 77  |8   .open_window|
00000db0  28 77 69 6e 5f 66 69 6c  65 25 2c 30 29 3a f4 20  |(win_file%,0):. |
00000dc0  4f 70 65 6e 20 73 61 76  65 20 66 69 6c 65 20 77  |Open save file w|
00000dd0  69 6e 64 6f 77 0d 03 c0  49 20 20 20 70 6f 6c 6c  |indow...I   poll|
00000de0  21 31 32 3d 70 6f 6c 6c  21 38 3a 70 6f 6c 6c 21  |!12=poll!8:poll!|
00000df0  31 36 3d 34 3a c8 99 20  57 53 65 6e 64 4d 73 67  |16=4:.. WSendMsg|
00000e00  25 2c 31 37 2c 70 6f 6c  6c 2c 70 6f 6c 6c 21 34  |%,17,poll,poll!4|
00000e10  3a f4 20 44 61 74 61 4c  6f 61 64 41 63 6b 0d 03  |:. DataLoadAck..|
00000e20  ca 07 20 20 cd 0d 03 d4  29 20 c9 20 34 20 3a 20  |..  ....) . 4 : |
00000e30  f4 20 44 61 74 61 4c 6f  61 64 41 63 6b 2c 20 63  |. DataLoadAck, c|
00000e40  68 65 63 6b 20 6f 72 20  69 67 6e 6f 72 65 0d 03  |heck or ignore..|
00000e50  de 3c 20 20 e7 44 61 74  61 4c 6f 61 64 52 65 66  |.<  .DataLoadRef|
00000e60  25 20 8c 20 e7 70 6f 6c  6c 21 31 32 3d 44 61 74  |% . .poll!12=Dat|
00000e70  61 4c 6f 61 64 52 65 66  25 20 8c 20 44 61 74 61  |aLoadRef% . Data|
00000e80  4c 6f 61 64 52 65 66 25  3d a3 0d 03 e8 33 20 c9  |LoadRef%=....3 .|
00000e90  20 26 43 43 46 30 30 20  3a 20 f4 20 4f 74 68 65  | &CCF00 : . Othe|
00000ea0  72 20 4d 61 6b 65 47 49  46 20 61 73 6b 73 20 74  |r MakeGIF asks t|
00000eb0  6f 20 6b 69 6c 6c 20 6d  6f 64 75 6c 65 0d 03 f2  |o kill module...|
00000ec0  3e 20 20 70 6f 6c 6c 21  31 32 3d 70 6f 6c 6c 21  |>  poll!12=poll!|
00000ed0  38 3a c8 99 20 57 53 65  6e 64 4d 73 67 25 2c 31  |8:.. WSendMsg%,1|
00000ee0  39 2c 70 6f 6c 6c 2c 70  6f 6c 6c 21 34 3a f4 20  |9,poll,poll!4:. |
00000ef0  48 61 6e 64 73 20 6f 66  66 20 21 0d 03 fc 05 cb  |Hands off !.....|
00000f00  0d 04 06 05 e1 0d 04 10  04 0d 04 1a 10 dd f2 6d  |...............m|
00000f10  6f 75 73 65 63 6c 69 63  6b 0d 04 24 3f 62 75 74  |ouseclick..$?but|
00000f20  25 3d 70 6f 6c 6c 21 38  3a 77 69 6e 25 3d 70 6f  |%=poll!8:win%=po|
00000f30  6c 6c 21 31 32 3a 69 63  6f 25 3d 70 6f 6c 6c 21  |ll!12:ico%=poll!|
00000f40  31 36 3a f4 20 42 75 74  74 6f 6e 73 2f 77 69 6e  |16:. Buttons/win|
00000f50  64 6f 77 2f 69 63 6f 6e  0d 04 2e 0d c8 8e 20 77  |dow/icon...... w|
00000f60  69 6e 25 20 ca 0d 04 38  1e 20 c9 20 2d 32 20 3a  |in% ...8. . -2 :|
00000f70  20 f4 20 43 6c 69 63 6b  20 6f 6e 20 69 63 6f 6e  | . Click on icon|
00000f80  62 61 72 0d 04 42 33 20  20 e7 69 63 6f 25 3d 49  |bar..B3  .ico%=I|
00000f90  69 63 6f 6e 62 61 72 25  20 8c 20 e7 28 62 75 74  |iconbar% . .(but|
00000fa0  25 80 37 29 3d 32 20 8c  20 f2 69 63 6f 6e 62 61  |%.7)=2 . .iconba|
00000fb0  72 5f 6d 65 6e 75 0d 04  4c 2e 20 c9 20 77 69 6e  |r_menu..L. . win|
00000fc0  5f 66 69 6c 65 25 20 3a  20 f4 20 43 6c 69 63 6b  |_file% : . Click|
00000fd0  20 6f 6e 20 73 61 76 65  20 66 69 6c 65 20 77 69  | on save file wi|
00000fe0  6e 64 6f 77 0d 04 56 0f  20 20 e7 69 63 6f 25 3d  |ndow..V.  .ico%=|
00000ff0  30 20 8c 0d 04 60 16 20  20 20 c8 8e 20 62 75 74  |0 ...`.   .. but|
00001000  25 20 80 20 26 37 46 20  ca 0d 04 6a 39 20 20 20  |% . &7F ...j9   |
00001010  20 c9 20 31 36 2c 36 34  20 3a 20 f4 20 44 72 61  | . 16,64 : . Dra|
00001020  67 2c 63 61 6c 63 75 6c  61 74 65 20 64 72 61 67  |g,calculate drag|
00001030  20 62 6f 78 20 61 6e 64  20 63 72 65 61 74 65 20  | box and create |
00001040  69 74 0d 04 74 7a 20 20  20 20 20 53 63 72 57 25  |it..tz     ScrW%|
00001050  3d a4 6d 6f 64 65 5f 76  61 72 28 eb 2c 31 31 29  |=.mode_var(.,11)|
00001060  3c 3c a4 6d 6f 64 65 5f  76 61 72 28 eb 2c 34 29  |<<.mode_var(.,4)|
00001070  3a 53 63 72 48 25 3d a4  6d 6f 64 65 5f 76 61 72  |:ScrH%=.mode_var|
00001080  28 eb 2c 31 32 29 3c 3c  a4 6d 6f 64 65 5f 76 61  |(.,12)<<.mode_va|
00001090  72 28 eb 2c 35 29 3a f4  20 53 63 72 65 65 6e 20  |r(.,5):. Screen |
000010a0  77 69 64 74 68 20 61 6e  64 20 68 65 69 67 68 74  |width and height|
000010b0  20 69 6e 20 4f 53 2d 75  6e 69 74 73 0d 04 7e e7  | in OS-units..~.|
000010c0  20 20 20 20 20 21 62 6c  6f 63 6b 3d 77 69 6e 25  |     !block=win%|
000010d0  3a c8 99 20 57 47 65 74  57 53 25 2c 2c 62 6c 6f  |:.. WGetWS%,,blo|
000010e0  63 6b 3a 78 25 3d 62 6c  6f 63 6b 21 34 3a 79 25  |ck:x%=block!4:y%|
000010f0  3d 62 6c 6f 63 6b 21 38  3a 62 6c 6f 63 6b 21 34  |=block!8:block!4|
00001100  3d 69 63 6f 25 3a c8 99  20 57 47 65 74 49 53 25  |=ico%:.. WGetIS%|
00001110  2c 2c 62 6c 6f 63 6b 3a  21 62 6c 6f 63 6b 3d 77  |,,block:!block=w|
00001120  69 6e 25 3a 62 6c 6f 63  6b 21 34 3d 35 3a 62 6c  |in%:block!4=5:bl|
00001130  6f 63 6b 21 38 2b 3d 78  25 3a 62 6c 6f 63 6b 21  |ock!8+=x%:block!|
00001140  31 32 2b 3d 79 25 3a 62  6c 6f 63 6b 21 31 36 3d  |12+=y%:block!16=|
00001150  62 6c 6f 63 6b 21 38 2b  36 38 3a 62 6c 6f 63 6b  |block!8+68:block|
00001160  21 32 30 3d 62 6c 6f 63  6b 21 31 32 2b 36 38 3a  |!20=block!12+68:|
00001170  62 6c 6f 63 6b 21 32 34  3d 30 3a 62 6c 6f 63 6b  |block!24=0:block|
00001180  21 32 38 3d 30 3a 62 6c  6f 63 6b 21 33 32 3d 53  |!28=0:block!32=S|
00001190  63 72 57 25 3a 62 6c 6f  63 6b 21 33 36 3d 53 63  |crW%:block!36=Sc|
000011a0  72 48 25 0d 04 88 2c 20  20 20 20 20 c8 99 20 57  |rH%...,     .. W|
000011b0  44 72 61 67 42 25 2c 2c  62 6c 6f 63 6b 3a f4 20  |DragB%,,block:. |
000011c0  43 72 65 61 74 65 20 64  72 61 67 20 62 6f 78 0d  |Create drag box.|
000011d0  04 92 08 20 20 20 cb 0d  04 9c 07 20 20 cd 0d 04  |...   .....  ...|
000011e0  a6 05 cb 0d 04 b0 05 e1  0d 04 ba 04 0d 04 c4 0e  |................|
000011f0  dd f2 64 72 61 67 64 72  6f 70 0d 04 ce 2c c8 99  |..dragdrop...,..|
00001200  20 57 47 65 74 50 49 25  2c 2c 62 6c 6f 63 6b 3a  | WGetPI%,,block:|
00001210  f4 20 47 65 74 20 70 6f  69 6e 74 65 72 20 70 6f  |. Get pointer po|
00001220  73 69 74 69 6f 6e 0d 04  d8 47 64 72 6f 70 77 69  |sition...Gdropwi|
00001230  6e 25 3d 62 6c 6f 63 6b  21 31 32 3a 64 72 6f 70  |n%=block!12:drop|
00001240  69 63 6f 25 3d 62 6c 6f  63 6b 21 31 36 3a f4 20  |ico%=block!16:. |
00001250  57 69 6e 64 6f 77 2f 69  63 6f 6e 20 77 68 65 72  |Window/icon wher|
00001260  65 20 62 6f 78 20 64 72  6f 70 70 65 64 0d 04 e2  |e box dropped...|
00001270  31 66 69 6c 65 6e 61 6d  65 24 3d a4 73 74 72 69  |1filename$=.stri|
00001280  6e 67 28 53 41 56 66 6e  25 29 3a f4 20 46 69 6c  |ng(SAVfn%):. Fil|
00001290  65 6e 61 6d 65 20 66 6f  72 20 73 61 76 65 0d 04  |ename for save..|
000012a0  ec ad 62 6c 6f 63 6b 21  32 30 3d 62 6c 6f 63 6b  |..block!20=block|
000012b0  21 31 32 3a 62 6c 6f 63  6b 21 32 34 3d 62 6c 6f  |!12:block!24=blo|
000012c0  63 6b 21 31 36 3a 62 6c  6f 63 6b 21 32 38 3d 62  |ck!16:block!28=b|
000012d0  6c 6f 63 6b 21 30 3a 62  6c 6f 63 6b 21 33 32 3d  |lock!0:block!32=|
000012e0  62 6c 6f 63 6b 21 34 3a  62 6c 6f 63 6b 21 31 32  |block!4:block!12|
000012f0  3d 30 3a 62 6c 6f 63 6b  21 31 36 3d 31 3a 62 6c  |=0:block!16=1:bl|
00001300  6f 63 6b 21 33 36 3d 30  3a 62 6c 6f 63 6b 21 34  |ock!36=0:block!4|
00001310  30 3d 26 46 46 39 3a 24  28 62 6c 6f 63 6b 2b 34  |0=&FF9:$(block+4|
00001320  34 29 3d 66 69 6c 65 6e  61 6d 65 24 2b bd 30 3a  |4)=filename$+.0:|
00001330  21 62 6c 6f 63 6b 3d 28  34 34 2b a9 66 69 6c 65  |!block=(44+.file|
00001340  6e 61 6d 65 24 2b 34 29  80 ac 33 0d 04 f6 3b c8  |name$+4)..3...;.|
00001350  99 20 57 53 65 6e 64 4d  73 67 25 2c 31 37 2c 62  |. WSendMsg%,17,b|
00001360  6c 6f 63 6b 2c 64 72 6f  70 77 69 6e 25 2c 64 72  |lock,dropwin%,dr|
00001370  6f 70 69 63 6f 25 3a f4  20 53 65 6e 64 20 44 61  |opico%:. Send Da|
00001380  74 61 53 61 76 65 0d 05  00 36 44 61 74 61 53 61  |taSave...6DataSa|
00001390  76 65 52 65 66 25 3d 62  6c 6f 63 6b 21 38 3a f4  |veRef%=block!8:.|
000013a0  20 52 65 6d 65 6d 62 65  72 20 6d 79 72 65 66 20  | Remember myref |
000013b0  66 6f 72 20 44 61 74 61  53 61 76 65 0d 05 0a 35  |for DataSave...5|
000013c0  f2 63 6c 6f 73 65 5f 77  69 6e 64 6f 77 28 77 69  |.close_window(wi|
000013d0  6e 5f 66 69 6c 65 25 29  3a f4 20 43 6c 6f 73 65  |n_file%):. Close|
000013e0  20 73 61 76 65 20 66 69  6c 65 20 77 69 6e 64 6f  | save file windo|
000013f0  77 0d 05 14 05 e1 0d 05  1e 05 20 0d 05 28 2f dd  |w......... ..(/.|
00001400  f2 6d 61 6b 65 5f 47 49  46 28 74 79 70 65 25 2c  |.make_GIF(type%,|
00001410  49 6e 46 69 6c 65 24 2c  4f 75 74 46 69 6c 65 24  |InFile$,OutFile$|
00001420  2c f8 20 65 72 72 6f 72  24 29 0d 05 32 26 f4 20  |,. error$)..2&. |
00001430  43 72 65 61 74 65 73 20  47 49 46 20 66 69 6c 65  |Creates GIF file|
00001440  20 4f 75 74 46 69 6c 65  24 20 66 72 6f 6d 20 3a  | OutFile$ from :|
00001450  0d 05 3c 2e f4 20 28 74  79 70 65 25 3d 26 46 46  |..<.. (type%=&FF|
00001460  39 29 20 66 69 72 73 74  20 73 70 72 69 74 65 20  |9) first sprite |
00001470  69 6e 20 73 70 72 69 74  65 20 66 69 6c 65 0d 05  |in sprite file..|
00001480  46 26 f4 20 28 74 79 70  65 25 3d 26 36 39 30 29  |F&. (type%=&690)|
00001490  20 69 6d 61 67 65 20 69  6e 20 43 6c 65 61 72 20  | image in Clear |
000014a0  66 69 6c 65 0d 05 50 37  f4 20 52 65 74 75 72 6e  |file..P7. Return|
000014b0  73 20 65 72 72 6f 72 20  69 6e 20 65 72 72 6f 72  |s error in error|
000014c0  24 20 69 66 20 65 72 72  6f 72 20 6f 63 63 75 72  |$ if error occur|
000014d0  65 64 2c 20 65 6c 73 65  20 22 22 0d 05 5a 07 ea  |ed, else ""..Z..|
000014e0  20 85 0d 05 64 2e ee 20  85 20 ea 20 65 72 72 6f  | ...d.. . . erro|
000014f0  72 24 3d f6 24 2b 22 20  28 63 6f 64 65 20 22 2b  |r$=.$+" (code "+|
00001500  c3 9e 2b 22 29 22 3a f2  63 6c 6f 73 65 66 3a e1  |..+")":.closef:.|
00001510  0d 05 6e 3d 65 72 72 6f  72 24 3d 22 22 3a 49 6e  |..n=error$="":In|
00001520  3d 30 3a 4f 75 74 3d 30  3a f4 20 4e 6f 20 65 72  |=0:Out=0:. No er|
00001530  72 6f 72 73 20 28 79 65  74 29 2c 20 66 69 6c 65  |rors (yet), file|
00001540  73 20 62 6f 74 68 20 63  6c 6f 73 65 64 0d 05 78  |s both closed..x|
00001550  23 49 6e 3d 8e 28 49 6e  46 69 6c 65 24 29 3a f4  |#In=.(InFile$):.|
00001560  20 4f 70 65 6e 20 69 6e  70 75 74 20 66 69 6c 65  | Open input file|
00001570  0d 05 82 0e c8 8e 20 74  79 70 65 25 20 ca 0d 05  |...... type% ...|
00001580  8c 1b 20 c9 20 26 46 46  39 20 3a 20 f4 20 53 70  |.. . &FF9 : . Sp|
00001590  72 69 74 65 20 66 69 6c  65 0d 05 96 43 20 20 c8  |rite file...C  .|
000015a0  99 20 22 4f 53 5f 47 42  50 42 22 2c 34 2c 49 6e  |. "OS_GBPB",4,In|
000015b0  2c 48 65 61 64 25 2b 34  2c 48 65 61 64 73 69 7a  |,Head%+4,Headsiz|
000015c0  65 25 3a f4 20 52 65 61  64 20 73 70 72 69 74 65  |e%:. Read sprite|
000015d0  20 66 69 6c 65 20 68 65  61 64 65 72 0d 05 a0 30  | file header...0|
000015e0  20 20 73 70 72 25 3d 48  65 61 64 25 2b 48 65 61  |  spr%=Head%+Hea|
000015f0  64 25 21 38 3a f4 20 53  74 61 72 74 20 6f 66 20  |d%!8:. Start of |
00001600  66 69 72 73 74 20 73 70  72 69 74 65 0d 05 aa 69  |first sprite...i|
00001610  20 20 73 70 72 6e 61 6d  65 24 3d 22 22 3a 70 74  |  sprname$="":pt|
00001620  72 25 3d 73 70 72 25 2b  34 3a c8 95 20 28 3f 70  |r%=spr%+4:.. (?p|
00001630  74 72 25 3c 3e 30 29 20  80 20 28 a9 73 70 72 6e  |tr%<>0) . (.sprn|
00001640  61 6d 65 24 3c 31 32 29  3a 73 70 72 6e 61 6d 65  |ame$<12):sprname|
00001650  24 2b 3d bd 28 3f 70 74  72 25 29 3a 70 74 72 25  |$+=.(?ptr%):ptr%|
00001660  2b 3d 31 3a ce 3a f4 20  53 70 72 69 74 65 27 73  |+=1:.:. Sprite's|
00001670  20 6e 61 6d 65 0d 05 b4  49 20 20 77 6f 72 64 77  | name...I  wordw|
00001680  25 3d 73 70 72 25 21 31  36 2b 31 3a 68 65 69 67  |%=spr%!16+1:heig|
00001690  68 74 25 3d 73 70 72 25  21 32 30 2b 31 3a f4 20  |ht%=spr%!20+1:. |
000016a0  57 69 64 74 68 20 69 6e  20 77 6f 72 64 73 2c 20  |Width in words, |
000016b0  68 65 69 67 68 74 20 69  6e 20 72 6f 77 73 0d 05  |height in rows..|
000016c0  be 4a 20 20 66 69 72 73  74 62 25 3d 73 70 72 25  |.J  firstb%=spr%|
000016d0  21 32 34 3a 6c 61 73 74  62 25 3d 73 70 72 25 21  |!24:lastb%=spr%!|
000016e0  32 38 3a f4 20 46 69 72  73 74 2f 6c 61 73 74 20  |28:. First/last |
000016f0  62 69 74 20 75 73 65 64  20 69 6e 20 62 6f 72 64  |bit used in bord|
00001700  65 72 20 77 6f 72 64 73  0d 05 c8 31 20 20 69 6d  |er words...1  im|
00001710  61 67 65 25 3d 73 70 72  25 2b 73 70 72 25 21 33  |age%=spr%+spr%!3|
00001720  32 3a f4 20 50 6f 69 6e  74 65 72 20 74 6f 20 69  |2:. Pointer to i|
00001730  6d 61 67 65 20 64 61 74  61 0d 05 d2 48 20 20 6d  |mage data...H  m|
00001740  6f 64 65 25 3d 73 70 72  25 21 34 30 3a 70 61 6c  |ode%=spr%!40:pal|
00001750  65 74 74 65 25 3d 73 70  72 25 2b 34 34 3a f4 20  |ette%=spr%+44:. |
00001760  53 70 72 69 74 65 27 73  20 6d 6f 64 65 2c 20 70  |Sprite's mode, p|
00001770  6f 69 6e 74 65 72 20 74  6f 20 70 61 6c 65 74 74  |ointer to palett|
00001780  65 0d 05 dc 34 20 20 63  6f 6c 62 69 74 73 25 3d  |e...4  colbits%=|
00001790  32 5e a4 6d 6f 64 65 5f  76 61 72 28 6d 6f 64 65  |2^.mode_var(mode|
000017a0  25 2c 39 29 3a f4 20 42  69 74 73 20 70 65 72 20  |%,9):. Bits per |
000017b0  70 69 78 65 6c 0d 05 e6  2d 20 20 63 6f 6c 6f 75  |pixel...-  colou|
000017c0  72 73 25 3d 32 5e 63 6f  6c 62 69 74 73 25 3a f4  |rs%=2^colbits%:.|
000017d0  20 4e 75 6d 62 65 72 20  6f 66 20 63 6f 6c 6f 75  | Number of colou|
000017e0  72 73 0d 05 f0 49 20 20  77 69 64 74 68 25 3d 28  |rs...I  width%=(|
000017f0  77 6f 72 64 77 25 2a 33  32 2d 28 33 31 2d 6c 61  |wordw%*32-(31-la|
00001800  73 74 62 25 29 2d 66 69  72 73 74 62 25 29 20 81  |stb%)-firstb%) .|
00001810  20 63 6f 6c 62 69 74 73  25 3a f4 20 57 69 64 74  | colbits%:. Widt|
00001820  68 20 69 6e 20 70 69 78  65 6c 73 0d 05 fa 19 20  |h in pixels.... |
00001830  20 e7 69 6d 61 67 65 25  3c 3d 70 61 6c 65 74 74  | .image%<=palett|
00001840  65 25 20 8c 0d 06 04 34  20 20 20 f4 20 53 70 72  |e% ....4   . Spr|
00001850  69 74 65 20 68 61 73 20  6e 6f 20 70 61 6c 65 74  |ite has no palet|
00001860  74 65 20 3a 20 75 73 65  20 64 65 66 61 75 6c 74  |te : use default|
00001870  20 70 61 6c 65 74 74 65  0d 06 0e 14 20 20 20 c8  | palette....   .|
00001880  8e 20 63 6f 6c 6f 75 72  73 25 20 ca 0d 06 18 c8  |. colours% .....|
00001890  20 20 20 20 c9 20 32 35  36 20 3a 20 e3 20 63 25  |    . 256 : . c%|
000018a0  3d 30 20 b8 20 32 35 35  3a 72 25 3d 28 28 63 25  |=0 . 255:r%=((c%|
000018b0  80 25 30 30 30 31 30 30  30 30 29 3e 3e 31 29 2b  |.%00010000)>>1)+|
000018c0  28 63 25 80 25 30 30 30  30 30 31 30 30 29 2b 28  |(c%.%00000100)+(|
000018d0  63 25 80 25 31 31 29 3a  67 25 3d 28 28 63 25 80  |c%.%11):g%=((c%.|
000018e0  25 30 31 31 30 30 30 30  30 29 3e 3e 33 29 2b 28  |%01100000)>>3)+(|
000018f0  63 25 80 25 31 31 29 3a  62 25 3d 28 28 63 25 80  |c%.%11):b%=((c%.|
00001900  25 31 30 30 30 30 30 30  30 29 3e 3e 34 29 2b 28  |%10000000)>>4)+(|
00001910  28 63 25 80 25 30 30 30  30 31 30 30 30 29 3e 3e  |(c%.%00001000)>>|
00001920  31 29 2b 28 63 25 80 25  31 31 29 3a 50 61 6c 65  |1)+(c%.%11):Pale|
00001930  74 74 65 25 28 63 25 29  3d 28 72 25 3c 3c 32 30  |tte%(c%)=(r%<<20|
00001940  29 2b 28 67 25 3c 3c 31  32 29 2b 28 62 25 3c 3c  |)+(g%<<12)+(b%<<|
00001950  34 29 3a ed 0d 06 22 7d  20 20 20 20 c9 20 31 36  |4):..."}    . 16|
00001960  20 3a 20 50 61 6c 65 74  74 65 25 28 29 3d 30 2c  | : Palette%()=0,|
00001970  26 46 30 30 30 30 30 2c  26 46 30 30 30 2c 26 46  |&F00000,&F000,&F|
00001980  30 46 30 30 30 2c 26 46  30 2c 26 46 30 30 30 46  |0F000,&F0,&F000F|
00001990  30 2c 26 46 30 46 30 2c  26 46 30 46 30 46 30 2c  |0,&F0F0,&F0F0F0,|
000019a0  30 2c 26 46 30 30 30 30  30 2c 26 46 30 30 30 2c  |0,&F00000,&F000,|
000019b0  26 46 30 46 30 30 30 2c  26 46 30 2c 26 46 30 30  |&F0F000,&F0,&F00|
000019c0  30 46 30 2c 26 46 30 46  30 2c 26 46 30 46 30 46  |0F0,&F0F0,&F0F0F|
000019d0  30 0d 06 2c 32 20 20 20  20 c9 20 34 20 3a 20 50  |0..,2    . 4 : P|
000019e0  61 6c 65 74 74 65 25 28  29 3d 30 2c 26 46 30 30  |alette%()=0,&F00|
000019f0  30 30 30 2c 26 46 30 46  30 30 30 2c 26 46 30 46  |000,&F0F000,&F0F|
00001a00  30 46 30 0d 06 36 22 20  20 20 20 c9 20 32 20 3a  |0F0..6"    . 2 :|
00001a10  20 50 61 6c 65 74 74 65  25 28 29 3d 30 2c 26 46  | Palette%()=0,&F|
00001a20  30 46 30 46 30 0d 06 40  08 20 20 20 cb 0d 06 4a  |0F0F0..@.   ...J|
00001a30  23 20 20 cc 20 f4 20 52  65 61 64 20 73 70 72 69  |#  . . Read spri|
00001a40  74 65 27 73 20 6f 77 6e  20 70 61 6c 65 74 74 65  |te's own palette|
00001a50  0d 06 54 16 20 20 20 e7  63 6f 6c 6f 75 72 73 25  |..T.   .colours%|
00001a60  3c 3d 31 36 20 8c 0d 06  5e 25 20 20 20 20 f4 20  |<=16 ...^%    . |
00001a70  41 6c 6c 20 70 61 6c 65  74 74 65 20 65 6e 74 72  |All palette entr|
00001a80  69 65 73 20 70 72 65 73  65 6e 74 0d 06 68 45 20  |ies present..hE |
00001a90  20 20 20 e3 20 63 25 3d  30 20 b8 20 63 6f 6c 6f  |   . c%=0 . colo|
00001aa0  75 72 73 25 2d 31 3a 50  61 6c 65 74 74 65 25 28  |urs%-1: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  0d 06 72 44 20 20 20 cc  20 f4 20 4f 6e 6c 79 20  |..rD   . . Only |
00001ae0  36 34 20 70 61 6c 65 74  74 65 20 65 6e 74 72 69  |64 palette entri|
00001af0  65 73 20 70 72 65 73 65  6e 74 2c 20 64 65 64 75  |es present, dedu|
00001b00  63 65 20 61 6c 6c 20 66  72 6f 6d 20 66 69 72 73  |ce all from firs|
00001b10  74 20 31 36 0d 06 7c 90  20 20 20 20 e3 20 63 25  |t 16..|.    . c%|
00001b20  3d 30 20 b8 20 31 35 3a  50 61 6c 65 74 74 65 25  |=0 . 15:Palette%|
00001b30  28 63 25 29 3d a4 70 61  6c 74 6f 72 67 62 28 70  |(c%)=.paltorgb(p|
00001b40  61 6c 65 74 74 65 25 21  28 63 25 2a 38 29 29 3a  |alette%!(c%*8)):|
00001b50  ed 3a e3 20 63 25 3d 31  36 20 b8 20 32 35 35 3a  |.:. c%=16 . 255:|
00001b60  50 61 6c 65 74 74 65 25  28 63 25 29 3d 50 61 6c  |Palette%(c%)=Pal|
00001b70  65 74 74 65 25 28 63 25  80 31 35 29 2b 28 63 25  |ette%(c%.15)+(c%|
00001b80  80 26 38 30 29 2b 28 28  63 25 80 26 36 30 29 3c  |.&80)+((c%.&60)<|
00001b90  3c 39 29 2b 28 28 63 25  80 26 31 30 29 3c 3c 31  |<9)+((c%.&10)<<1|
00001ba0  39 29 3a ed 0d 06 86 08  20 20 20 cd 0d 06 90 07  |9):.....   .....|
00001bb0  20 20 cd 0d 06 9a 36 20  20 72 61 73 77 69 64 74  |  ....6  raswidt|
00001bc0  68 25 3d a4 6d 6f 64 65  5f 76 61 72 28 6d 6f 64  |h%=.mode_var(mod|
00001bd0  65 25 2c 31 31 29 2b 31  3a f4 20 27 52 61 73 74  |e%,11)+1:. 'Rast|
00001be0  65 72 27 20 77 69 64 74  68 0d 06 a4 39 20 20 72  |er' width...9  r|
00001bf0  61 73 68 65 69 67 68 74  25 3d a4 6d 6f 64 65 5f  |asheight%=.mode_|
00001c00  76 61 72 28 6d 6f 64 65  25 2c 31 32 29 2b 31 3a  |var(mode%,12)+1:|
00001c10  f4 20 27 52 61 73 74 65  72 27 20 68 65 69 67 68  |. 'Raster' heigh|
00001c20  74 25 0d 06 ae 34 20 20  64 61 74 61 70 74 72 25  |t%...4  dataptr%|
00001c30  3d 69 6d 61 67 65 25 2d  48 65 61 64 25 2d 34 3a  |=image%-Head%-4:|
00001c40  f4 20 4f 66 66 73 65 74  20 74 6f 20 69 6d 61 67  |. Offset to imag|
00001c50  65 20 64 61 74 61 0d 06  b8 1a 20 c9 20 26 36 39  |e data.... . &69|
00001c60  30 20 3a 20 f4 20 43 6c  65 61 72 20 66 69 6c 65  |0 : . Clear file|
00001c70  0d 06 c2 40 20 20 c8 99  20 22 4f 53 5f 47 42 50  |...@  .. "OS_GBP|
00001c80  42 22 2c 34 2c 49 6e 2c  48 65 61 64 25 2c 48 65  |B",4,In,Head%,He|
00001c90  61 64 73 69 7a 65 25 3a  f4 20 52 65 61 64 20 43  |adsize%:. Read C|
00001ca0  6c 65 61 72 20 66 69 6c  65 20 68 65 61 64 65 72  |lear file header|
00001cb0  0d 06 cc 70 20 20 70 74  72 25 3d 48 65 61 64 25  |...p  ptr%=Head%|
00001cc0  3a 6d 61 6b 65 72 24 3d  22 22 3a c8 95 20 3f 70  |:maker$="":.. ?p|
00001cd0  74 72 25 3e 3d 97 22 20  22 3a 6d 61 6b 65 72 24  |tr%>=." ":maker$|
00001ce0  2b 3d bd 28 3f 70 74 72  25 29 3a 70 74 72 25 2b  |+=.(?ptr%):ptr%+|
00001cf0  3d 31 3a ce 3a 76 65 72  73 69 6f 6e 25 3d 70 74  |=1:.:version%=pt|
00001d00  72 25 21 31 3a 70 74 72  25 2b 3d 35 3a f4 20 4d  |r%!1:ptr%+=5:. M|
00001d10  61 6b 65 72 20 61 6e 64  20 76 65 72 73 69 6f 6e  |aker and version|
00001d20  0d 06 d6 a5 20 20 e7 6d  61 6b 65 72 24 3d 22 54  |....  .maker$="T|
00001d30  72 61 6e 73 6c 61 74 6f  72 22 20 8c 20 e7 76 65  |ranslator" . .ve|
00001d40  72 73 69 6f 6e 25 3d 36  30 30 20 8b 20 65 72 72  |rsion%=600 . err|
00001d50  6f 72 24 3d 22 49 20 63  61 6e 6e 6f 74 20 68 61  |or$="I cannot ha|
00001d60  6e 64 6c 65 20 74 68 69  73 20 43 6c 65 61 72 20  |ndle this Clear |
00001d70  66 69 6c 65 20 66 72 6f  6d 20 27 22 2b 6d 61 6b  |file from '"+mak|
00001d80  65 72 24 2b 22 27 20 76  65 72 73 69 6f 6e 20 22  |er$+"' version "|
00001d90  2b c3 28 76 65 72 73 69  6f 6e 25 81 31 30 30 29  |+.(version%.100)|
00001da0  2b 22 2e 22 2b c2 22 30  22 2b c3 28 76 65 72 73  |+"."+."0"+.(vers|
00001db0  69 6f 6e 25 83 31 30 30  29 2c 32 29 2b 22 20 21  |ion%.100),2)+" !|
00001dc0  21 21 22 3a e1 0d 06 e0  47 20 20 77 69 64 74 68  |!!":....G  width|
00001dd0  25 3d 21 70 74 72 25 3a  68 65 69 67 68 74 25 3d  |%=!ptr%:height%=|
00001de0  70 74 72 25 21 34 3a 63  6f 6c 62 69 74 73 25 3d  |ptr%!4:colbits%=|
00001df0  70 74 72 25 21 38 3a 70  74 72 25 2b 3d 31 32 3a  |ptr%!8:ptr%+=12:|
00001e00  f4 20 52 65 73 6f 6c 75  74 69 6f 6e 0d 06 ea 61  |. Resolution...a|
00001e10  20 20 e7 63 6f 6c 62 69  74 73 25 3e 38 20 8c 20  |  .colbits%>8 . |
00001e20  65 72 72 6f 72 24 3d 22  49 20 63 61 6e 6e 6f 74  |error$="I cannot|
00001e30  20 68 61 6e 64 6c 65 20  70 75 72 65 20 52 47 42  | handle pure RGB|
00001e40  20 43 6c 65 61 72 20 66  69 6c 65 73 2e 20 47 49  | Clear files. GI|
00001e50  46 20 64 6f 65 73 20 6e  6f 74 20 73 75 70 70 6f  |F does not suppo|
00001e60  72 74 20 74 68 65 73 65  20 21 22 3a e1 0d 06 f4  |rt these !":....|
00001e70  2c 20 20 63 6f 6c 6f 75  72 73 25 3d 32 5e 63 6f  |,  colours%=2^co|
00001e80  6c 62 69 74 73 25 3a f4  20 43 6f 6c 6f 75 72 73  |lbits%:. Colours|
00001e90  20 69 6e 20 69 6d 61 67  65 0d 06 fe 62 20 20 e3  | in image...b  .|
00001ea0  20 63 25 3d 30 20 b8 20  63 6f 6c 6f 75 72 73 25  | c%=0 . colours%|
00001eb0  2d 31 3a 50 61 6c 65 74  74 65 25 28 63 25 29 3d  |-1:Palette%(c%)=|
00001ec0  28 28 3f 70 74 72 25 29  3c 3c 31 36 29 2b 28 28  |((?ptr%)<<16)+((|
00001ed0  70 74 72 25 3f 31 29 3c  3c 38 29 2b 70 74 72 25  |ptr%?1)<<8)+ptr%|
00001ee0  3f 32 3a 70 74 72 25 2b  3d 33 3a ed 3a f4 20 52  |?2:ptr%+=3:.:. R|
00001ef0  65 61 64 20 70 61 6c 65  74 74 65 0d 07 08 43 20  |ead palette...C |
00001f00  20 72 61 73 77 69 64 74  68 25 3d 77 69 64 74 68  | raswidth%=width|
00001f10  25 3a 72 61 73 68 65 69  67 68 74 25 3d 68 65 69  |%:rasheight%=hei|
00001f20  67 68 74 25 3a f4 20 4e  6f 20 61 63 74 75 61 6c  |ght%:. No actual|
00001f30  20 27 72 61 73 74 65 72  20 73 69 7a 65 27 0d 07  | 'raster size'..|
00001f40  12 30 20 20 64 61 74 61  70 74 72 25 3d 70 74 72  |.0  dataptr%=ptr|
00001f50  25 2d 48 65 61 64 25 3a  f4 20 4f 66 66 73 65 74  |%-Head%:. Offset|
00001f60  20 74 6f 20 69 6d 61 67  65 20 64 61 74 61 0d 07  | to image data..|
00001f70  1c 05 cb 0d 07 26 2a 4f  75 74 3d ae 28 4f 75 74  |.....&*Out=.(Out|
00001f80  46 69 6c 65 24 29 3a f4  20 4f 70 65 6e 20 6f 75  |File$):. Open ou|
00001f90  74 70 75 74 20 47 49 46  20 66 69 6c 65 0d 07 30  |tput GIF file..0|
00001fa0  23 f2 6f 75 74 73 28 22  47 49 46 38 37 61 22 29  |#.outs("GIF87a")|
00001fb0  3a f4 20 47 49 46 20 73  69 67 6e 61 74 75 72 65  |:. GIF signature|
00001fc0  0d 07 3a 2d f2 6f 75 74  64 28 72 61 73 77 69 64  |..:-.outd(raswid|
00001fd0  74 68 25 29 3a f4 20 52  61 73 74 65 72 20 77 69  |th%):. Raster wi|
00001fe0  64 74 68 20 69 6e 20 70  69 78 65 6c 73 0d 07 44  |dth in pixels..D|
00001ff0  2f f2 6f 75 74 64 28 72  61 73 68 65 69 67 68 74  |/.outd(rasheight|
00002000  25 29 3a f4 20 52 61 73  74 65 72 20 68 65 69 67  |%):. Raster heig|
00002010  68 74 20 69 6e 20 70 69  78 65 6c 73 0d 07 4e 40  |ht in pixels..N@|
00002020  f2 6f 75 74 62 28 28 31  3c 3c 37 29 2b 28 28 63  |.outb((1<<7)+((c|
00002030  6f 6c 62 69 74 73 25 2d  31 29 3c 3c 34 29 2b 63  |olbits%-1)<<4)+c|
00002040  6f 6c 62 69 74 73 25 2d  31 29 3a f4 20 46 6c 61  |olbits%-1):. Fla|
00002050  67 73 20 2b 20 63 6f 6c  62 69 74 73 0d 07 58 26  |gs + colbits..X&|
00002060  f2 6f 75 74 62 28 30 29  3a f4 20 42 61 63 6b 67  |.outb(0):. Backg|
00002070  72 6f 75 6e 64 20 63 6f  6c 6f 75 72 20 69 6e 64  |round colour ind|
00002080  65 78 0d 07 62 17 f2 6f  75 74 62 28 30 29 3a f4  |ex..b..outb(0):.|
00002090  20 52 65 73 65 72 76 65  64 0d 07 6c 7e e3 20 63  | Reserved..l~. c|
000020a0  6f 6c 6f 75 72 25 3d 30  20 b8 20 63 6f 6c 6f 75  |olour%=0 . colou|
000020b0  72 73 25 2d 31 3a 70 25  3d 50 61 6c 65 74 74 65  |rs%-1:p%=Palette|
000020c0  25 28 63 6f 6c 6f 75 72  25 29 3a 72 25 3d 70 25  |%(colour%):r%=p%|
000020d0  3e 3e 31 36 3a 67 25 3d  28 70 25 3e 3e 38 29 80  |>>16:g%=(p%>>8).|
000020e0  26 46 46 3a 62 25 3d 70  25 80 26 46 46 3a f2 6f  |&FF:b%=p%.&FF:.o|
000020f0  75 74 62 28 72 25 29 3a  f2 6f 75 74 62 28 67 25  |utb(r%):.outb(g%|
00002100  29 3a f2 6f 75 74 62 28  62 25 29 3a ed 3a f4 20  |):.outb(b%):.:. |
00002110  50 61 6c 65 74 74 65 0d  07 76 2a f2 6f 75 74 73  |Palette..v*.outs|
00002120  28 22 2c 22 29 3a f4 20  49 6d 61 67 65 20 73 65  |(","):. Image se|
00002130  70 61 72 61 74 6f 72 20  63 68 61 72 61 63 74 65  |parator characte|
00002140  72 0d 07 80 3d f2 6f 75  74 64 28 30 29 3a f2 6f  |r...=.outd(0):.o|
00002150  75 74 64 28 30 29 3a f4  20 4c 65 66 74 2f 72 69  |utd(0):. Left/ri|
00002160  67 68 74 20 6f 66 66 73  65 74 73 20 6f 66 20 69  |ght offsets of i|
00002170  6d 61 67 65 20 69 6e 20  72 61 73 74 65 72 0d 07  |mage in raster..|
00002180  8a 3c f2 6f 75 74 64 28  77 69 64 74 68 25 29 3a  |.<.outd(width%):|
00002190  f2 6f 75 74 64 28 68 65  69 67 68 74 25 29 3a f4  |.outd(height%):.|
000021a0  20 57 69 64 74 68 20 61  6e 64 20 68 65 69 67 68  | Width and heigh|
000021b0  74 20 6f 66 20 69 6d 61  67 65 0d 07 94 35 f2 6f  |t of image...5.o|
000021c0  75 74 62 28 28 30 3c 3c  37 29 2b 28 30 3c 3c 36  |utb((0<<7)+(0<<6|
000021d0  29 2b 63 6f 6c 62 69 74  73 25 2d 31 29 3a f4 20  |)+colbits%-1):. |
000021e0  46 6c 61 67 73 20 2b 20  63 6f 6c 62 69 74 73 0d  |Flags + colbits.|
000021f0  07 9e 35 f4 20 4e 6f 77  20 70 72 65 70 61 72 65  |..5. Now prepare|
00002200  20 63 6f 6d 70 72 65 73  73 69 6f 6e 20 62 79 20  | compression by |
00002210  6d 61 63 68 69 6e 65 63  6f 64 65 20 72 6f 75 74  |machinecode rout|
00002220  69 6e 65 73 0d 07 a8 31  f2 76 61 72 28 22 69 70  |ines...1.var("ip|
00002230  74 72 22 2c 64 61 74 61  70 74 72 25 29 3a 3a f4  |tr",dataptr%)::.|
00002240  20 4f 66 66 73 65 74 20  74 6f 20 69 6d 61 67 65  | Offset to image|
00002250  20 64 61 74 61 0d 07 b2  43 f2 76 61 72 28 22 69  | data...C.var("i|
00002260  66 68 61 22 2c 49 6e 29  3a f2 76 61 72 28 22 6f  |fha",In):.var("o|
00002270  66 68 61 22 2c 4f 75 74  29 3a f4 20 46 69 6c 65  |fha",Out):. File|
00002280  20 68 61 6e 64 6c 65 73  20 6f 66 20 69 6e 70 75  | handles of inpu|
00002290  74 2f 6f 75 74 70 75 74  0d 07 bc 40 f2 76 61 72  |t/output...@.var|
000022a0  28 22 74 61 62 62 22 2c  54 61 62 6c 65 25 29 3a  |("tabb",Table%):|
000022b0  f4 20 46 72 65 65 20 73  70 61 63 65 20 66 6f 72  |. Free space for|
000022c0  20 63 6f 6d 70 72 65 73  73 69 6f 6e 20 74 61 62  | compression tab|
000022d0  6c 65 73 20 65 74 63 2e  0d 07 c6 46 f2 76 61 72  |les etc....F.var|
000022e0  28 22 69 6e 62 66 22 2c  49 6e 70 75 74 25 29 3a  |("inbf",Input%):|
000022f0  f2 76 61 72 28 22 6f 75  74 62 22 2c 4f 75 74 70  |.var("outb",Outp|
00002300  75 74 25 29 3a f4 20 49  6e 70 75 74 20 61 6e 64  |ut%):. Input and|
00002310  20 6f 75 74 70 75 74 20  62 75 66 66 65 72 0d 07  | output buffer..|
00002320  d0 43 f2 76 61 72 28 22  6f 75 74 73 22 2c 4f 75  |.C.var("outs",Ou|
00002330  74 70 75 74 73 69 7a 65  25 29 3a f2 76 61 72 28  |tputsize%):.var(|
00002340  22 69 6e 73 7a 22 2c 49  6e 70 75 74 73 69 7a 65  |"insz",Inputsize|
00002350  25 29 3a f4 20 42 75 66  66 65 72 20 73 69 7a 65  |%):. Buffer size|
00002360  73 0d 07 da 2a f2 76 61  72 28 22 62 69 74 73 22  |s...*.var("bits"|
00002370  2c 63 6f 6c 62 69 74 73  25 29 3a f4 20 42 69 74  |,colbits%):. Bit|
00002380  73 20 70 65 72 20 70 69  78 65 6c 0d 07 e4 45 f2  |s per pixel...E.|
00002390  76 61 72 28 22 77 69 64  74 22 2c 77 69 64 74 68  |var("widt",width|
000023a0  25 29 3a f2 76 61 72 28  22 68 65 69 67 22 2c 68  |%):.var("heig",h|
000023b0  65 69 67 68 74 25 29 3a  f4 20 49 6d 61 67 65 20  |eight%):. Image |
000023c0  77 69 64 74 68 20 61 6e  64 20 68 65 69 67 68 74  |width and height|
000023d0  0d 07 ee 6c e7 74 79 70  65 25 3d 26 46 46 39 20  |...l.type%=&FF9 |
000023e0  8c 20 f2 76 61 72 28 22  6c 65 66 74 22 2c 66 69  |. .var("left",fi|
000023f0  72 73 74 62 25 29 3a f2  76 61 72 28 22 72 69 67  |rstb%):.var("rig|
00002400  68 22 2c 6c 61 73 74 62  25 29 3a f2 76 61 72 28  |h",lastb%):.var(|
00002410  22 77 6f 72 64 22 2c 77  6f 72 64 77 25 29 3a f4  |"word",wordw%):.|
00002420  20 45 78 74 72 61 20 69  6e 66 6f 20 66 6f 72 20  | Extra info for |
00002430  73 70 72 69 74 65 20 69  6e 70 75 74 0d 07 f8 27  |sprite input...'|
00002440  f2 76 61 72 28 22 74 79  70 65 22 2c 74 79 70 65  |.var("type",type|
00002450  25 29 3a f4 20 53 65 74  20 69 6d 61 67 65 20 74  |%):. Set image t|
00002460  79 70 65 0d 08 02 38 f2  76 61 72 28 22 62 6c 73  |ype...8.var("bls|
00002470  69 22 2c 32 35 34 29 3a  f4 20 4d 61 78 69 6d 75  |i",254):. Maximu|
00002480  6d 20 73 69 7a 65 20 6f  66 20 63 6f 75 6e 74 2d  |m size of count-|
00002490  62 79 74 65 20 62 6c 6f  63 6b 73 0d 08 0c 3e e7  |byte blocks...>.|
000024a0  63 6f 6c 62 69 74 73 25  3d 31 20 8c 20 f2 6f 75  |colbits%=1 . .ou|
000024b0  74 62 28 32 29 20 8b 20  f2 6f 75 74 62 28 63 6f  |tb(2) . .outb(co|
000024c0  6c 62 69 74 73 25 29 3a  f4 20 4f 75 74 70 75 74  |lbits%):. Output|
000024d0  20 63 6f 64 65 73 69 7a  65 0d 08 16 2b c8 99 20  | codesize...+.. |
000024e0  22 4d 61 6b 65 47 49 46  5f 43 6f 6d 70 72 65 73  |"MakeGIF_Compres|
000024f0  73 22 3a f4 20 47 49 46  20 63 6f 6d 70 72 65 73  |s":. GIF compres|
00002500  73 69 6f 6e 0d 08 20 29  f2 6f 75 74 73 28 22 3b  |sion.. ).outs(";|
00002510  22 29 3a f4 20 47 49 46  20 74 65 72 6d 69 6e 61  |"):. GIF termina|
00002520  74 6f 72 20 63 68 61 72  61 63 74 65 72 0d 08 2a  |tor character..*|
00002530  2d f2 6f 75 74 73 28 22  5a 65 72 69 64 61 6a 68  |-.outs("Zeridajh|
00002540  20 4d 61 6b 65 47 49 46  22 29 3a f4 20 4d 61 6b  | MakeGIF"):. Mak|
00002550  65 72 27 73 20 73 74 61  6d 70 0d 08 34 22 d9 23  |er's stamp..4".#|
00002560  49 6e 3a f4 20 43 6c 6f  73 65 20 69 6e 70 75 74  |In:. Close input|
00002570  20 73 70 72 69 74 65 20  66 69 6c 65 0d 08 3e 1a  | sprite file..>.|
00002580  d9 23 4f 75 74 3a f4 20  43 6c 6f 73 65 20 47 49  |.#Out:. Close GI|
00002590  46 20 66 69 6c 65 0d 08  48 41 c8 99 20 22 4f 53  |F file..HA.. "OS|
000025a0  5f 43 4c 49 22 2c 22 53  65 74 54 79 70 65 20 22  |_CLI","SetType "|
000025b0  2b 4f 75 74 46 69 6c 65  24 2b 22 20 36 39 35 22  |+OutFile$+" 695"|
000025c0  3a f4 20 46 69 6c 65 74  79 70 65 20 61 73 20 47  |:. Filetype as G|
000025d0  49 46 20 66 69 6c 65 0d  08 52 05 e1 0d 08 5c 05  |IF file..R....\.|
000025e0  20 0d 08 66 0c dd f2 63  6c 6f 73 65 66 0d 08 70  | ..f...closef..p|
000025f0  1b f4 20 43 6c 6f 73 65  73 20 66 69 6c 65 73 20  |.. Closes files |
00002600  6f 6e 20 65 72 72 6f 72  0d 08 7a 10 e7 49 6e 3e  |on error..z..In>|
00002610  30 20 8c 20 d9 23 49 6e  0d 08 84 12 e7 4f 75 74  |0 . .#In.....Out|
00002620  3e 30 20 8c 20 d9 23 4f  75 74 0d 08 8e 05 e1 0d  |>0 . .#Out......|
00002630  08 98 05 20 0d 08 a2 10  dd f2 6f 75 74 73 28 6f  |... ......outs(o|
00002640  75 74 24 29 0d 08 ac 1f  f4 20 4f 75 74 70 75 74  |ut$)..... Output|
00002650  73 20 73 74 72 69 6e 67  20 74 6f 20 6f 75 74 66  |s string to outf|
00002660  69 6c 65 0d 08 b6 08 ea  20 63 25 0d 08 c0 25 e3  |ile..... c%...%.|
00002670  20 63 25 3d 31 20 b8 20  a9 6f 75 74 24 3a d5 23  | c%=1 . .out$:.#|
00002680  4f 75 74 2c 97 c1 6f 75  74 24 2c 63 25 29 3a ed  |Out,..out$,c%):.|
00002690  0d 08 ca 05 e1 0d 08 d4  05 20 0d 08 de 10 dd f2  |......... ......|
000026a0  6f 75 74 64 28 6f 75 74  25 29 0d 08 e8 24 f4 20  |outd(out%)...$. |
000026b0  4f 75 74 70 75 74 73 20  64 6f 75 62 6c 65 2d 62  |Outputs double-b|
000026c0  79 74 65 20 74 6f 20 6f  75 74 66 69 6c 65 0d 08  |yte to outfile..|
000026d0  f2 1c d5 23 4f 75 74 2c  6f 75 74 25 3a d5 23 4f  |...#Out,out%:.#O|
000026e0  75 74 2c 6f 75 74 25 3e  3e 38 0d 08 fc 05 e1 0d  |ut,out%>>8......|
000026f0  09 06 05 20 0d 09 10 10  dd f2 6f 75 74 62 28 6f  |... ......outb(o|
00002700  75 74 25 29 0d 09 1a 1d  f4 20 4f 75 74 70 75 74  |ut%)..... Output|
00002710  73 20 62 79 74 65 20 74  6f 20 6f 75 74 66 69 6c  |s byte to outfil|
00002720  65 0d 09 24 0e d5 23 4f  75 74 2c 6f 75 74 25 0d  |e..$..#Out,out%.|
00002730  09 2e 05 e1 0d 09 38 05  20 0d 09 42 1a dd a4 6d  |......8. ..B...m|
00002740  6f 64 65 5f 76 61 72 28  6d 6f 64 65 25 2c 76 61  |ode_var(mode%,va|
00002750  72 25 29 0d 09 4c 1b f4  20 52 65 74 75 72 6e 73  |r%)..L.. Returns|
00002760  20 6d 6f 64 65 20 76 61  72 69 61 62 6c 65 0d 09  | mode variable..|
00002770  56 0a ea 20 76 61 6c 25  0d 09 60 30 c8 99 20 22  |V.. val%..`0.. "|
00002780  4f 53 5f 52 65 61 64 4d  6f 64 65 56 61 72 69 61  |OS_ReadModeVaria|
00002790  62 6c 65 22 2c 6d 6f 64  65 25 2c 76 61 72 25 20  |ble",mode%,var% |
000027a0  b8 20 2c 2c 76 61 6c 25  0d 09 6a 09 3d 76 61 6c  |. ,,val%..j.=val|
000027b0  25 0d 09 74 05 20 0d 09  7e 13 dd a4 73 74 72 69  |%..t. ..~...stri|
000027c0  6e 67 28 61 64 64 72 25  29 0d 09 88 32 f4 20 52  |ng(addr%)...2. R|
000027d0  65 74 75 72 6e 73 20 43  54 52 4c 2d 63 68 61 72  |eturns CTRL-char|
000027e0  20 74 65 72 6d 69 6e 61  74 65 64 20 73 74 72 69  | terminated stri|
000027f0  6e 67 20 61 74 20 61 64  64 72 25 0d 09 92 0f ea  |ng at addr%.....|
00002800  20 5f 25 2c 5f 63 25 2c  5f 24 0d 09 9c 1f 5f 25  | _%,_c%,_$...._%|
00002810  3d 2d 31 3a f5 20 5f 25  2b 3d 31 3a fd 20 61 64  |=-1:. _%+=1:. ad|
00002820  64 72 25 3f 5f 25 3c 33  32 0d 09 a6 33 5f 63 25  |dr%?_%<32...3_c%|
00002830  3d 61 64 64 72 25 3f 5f  25 3a 61 64 64 72 25 3f  |=addr%?_%:addr%?|
00002840  5f 25 3d 31 33 3a 5f 24  3d 24 61 64 64 72 25 3a  |_%=13:_$=$addr%:|
00002850  61 64 64 72 25 3f 5f 25  3d 5f 63 25 0d 09 b0 07  |addr%?_%=_c%....|
00002860  3d 5f 24 0d 09 ba 05 20  0d 09 c4 1d dd f2 6d 6f  |=_$.... ......mo|
00002870  75 73 65 28 f8 20 78 25  2c f8 20 79 25 2c f8 20  |use(. x%,. y%,. |
00002880  62 75 74 25 29 0d 09 ce  2b f4 20 52 65 74 75 72  |but%)...+. Retur|
00002890  6e 73 20 78 2c 79 20 61  6e 64 20 62 75 74 74 6f  |ns x,y and butto|
000028a0  6e 20 73 74 61 74 65 20  6f 66 20 6d 6f 75 73 65  |n state of mouse|
000028b0  0d 09 d8 11 c8 97 20 78  25 2c 79 25 2c 62 75 74  |...... x%,y%,but|
000028c0  25 0d 09 e2 05 e1 0d 09  ec 05 20 0d 09 f6 0d dd  |%......... .....|
000028d0  f2 68 6f 75 72 5f 6f 6e  0d 0a 00 24 f4 20 54 75  |.hour_on...$. Tu|
000028e0  72 6e 73 20 68 6f 75 72  67 6c 61 73 73 20 6f 6e  |rns hourglass on|
000028f0  20 61 66 74 65 72 20 31  20 73 65 63 0d 0a 0a 15  | after 1 sec....|
00002900  c8 99 20 22 48 6f 75 72  67 6c 61 73 73 5f 4f 6e  |.. "Hourglass_On|
00002910  22 0d 0a 14 05 e1 0d 0a  1e 05 20 0d 0a 28 0e dd  |"......... ..(..|
00002920  f2 68 6f 75 72 5f 6f 66  66 0d 0a 32 19 f4 20 54  |.hour_off..2.. T|
00002930  75 72 6e 73 20 68 6f 75  72 67 6c 61 73 73 20 6f  |urns hourglass o|
00002940  66 66 0d 0a 3c 16 c8 99  20 22 48 6f 75 72 67 6c  |ff..<... "Hourgl|
00002950  61 73 73 5f 4f 66 66 22  0d 0a 46 05 e1 0d 0a 50  |ass_Off"..F....P|
00002960  05 20 0d 0a 5a 12 dd a4  4f 53 76 61 72 28 6e 61  |. ..Z...OSvar(na|
00002970  6d 65 24 29 0d 0a 64 2e  f4 20 41 74 74 65 6d 70  |me$)..d.. Attemp|
00002980  74 73 20 74 6f 20 72 65  74 75 72 6e 20 4f 53 2d  |ts to return OS-|
00002990  76 61 72 27 73 20 73 74  72 69 6e 67 20 76 61 6c  |var's string val|
000029a0  75 65 0d 0a 6e 0d ea 20  5f 72 24 2c 5f 6c 25 0d  |ue..n.. _r$,_l%.|
000029b0  0a 78 43 5f 72 24 3d c4  31 30 30 2c 22 20 22 29  |.xC_r$=.100," ")|
000029c0  3a c8 99 20 22 58 4f 53  5f 52 65 61 64 56 61 72  |:.. "XOS_ReadVar|
000029d0  56 61 6c 22 2c 6e 61 6d  65 24 2c 5f 72 24 2c a9  |Val",name$,_r$,.|
000029e0  5f 72 24 2c 30 2c 33 20  b8 20 2c 5f 72 24 2c 5f  |_r$,0,3 . ,_r$,_|
000029f0  6c 25 0d 0a 82 0e 3d c0  5f 72 24 2c 5f 6c 25 29  |l%....=._r$,_l%)|
00002a00  0d 0a 8c 05 20 0d 0a 96  14 dd a4 70 61 6c 74 6f  |.... ......palto|
00002a10  72 67 62 28 70 61 6c 25  29 0d 0a a0 2f f4 20 52  |rgb(pal%).../. R|
00002a20  65 74 75 72 6e 73 20 26  52 52 47 47 42 42 20 66  |eturns &RRGGBB f|
00002a30  72 6f 6d 20 73 70 72 69  74 65 20 70 61 6c 65 74  |rom sprite palet|
00002a40  74 65 20 65 6e 74 72 79  0d 0a aa 37 3d 28 70 61  |te entry...7=(pa|
00002a50  6c 25 3e 3e 3e 32 34 29  2b 28 28 70 61 6c 25 3e  |l%>>>24)+((pal%>|
00002a60  3e 3e 38 29 80 26 46 46  30 30 29 2b 28 28 70 61  |>>8).&FF00)+((pa|
00002a70  6c 25 3c 3c 38 29 80 26  46 46 30 30 30 30 29 0d  |l%<<8).&FF0000).|
00002a80  0a b4 05 20 0d 0a be 12  dd f2 69 63 6f 6e 62 61  |... ......iconba|
00002a90  72 5f 6d 65 6e 75 0d 0a  c8 23 f4 20 50 6f 70 73  |r_menu...#. Pops|
00002aa0  20 75 70 20 6d 65 6e 75  20 66 6f 72 20 69 63 6f  | up menu for ico|
00002ab0  6e 62 61 72 20 69 63 6f  6e 0d 0a d2 37 f2 6d 6f  |nbar icon...7.mo|
00002ac0  75 73 65 28 78 25 2c 79  25 2c 5f 25 29 3a 78 25  |use(x%,y%,_%):x%|
00002ad0  2d 3d 36 34 3a f4 20 47  65 74 20 63 6f 6f 72 64  |-=64:. Get coord|
00002ae0  69 6e 61 74 65 73 20 76  69 61 20 6d 6f 75 73 65  |inates via mouse|
00002af0  0d 0a dc 73 24 6d 65 6e  75 3d 22 4d 61 6b 65 47  |...s$menu="MakeG|
00002b00  49 46 22 3a 6d 65 6e 75  3f 31 32 3d 74 66 25 3a  |IF":menu?12=tf%:|
00002b10  6d 65 6e 75 3f 31 33 3d  74 62 25 3a 6d 65 6e 75  |menu?13=tb%:menu|
00002b20  3f 31 34 3d 77 66 25 3a  6d 65 6e 75 3f 31 35 3d  |?14=wf%:menu?15=|
00002b30  77 62 25 3a 6d 65 6e 75  21 31 36 3d 35 2a 31 36  |wb%:menu!16=5*16|
00002b40  3a 6d 65 6e 75 21 32 30  3d 34 30 3a 6d 65 6e 75  |:menu!20=40:menu|
00002b50  21 32 34 3d 30 3a f4 20  4d 65 6e 75 20 68 65 61  |!24=0:. Menu hea|
00002b60  64 65 72 0d 0a e6 97 6d  65 6e 75 21 32 38 3d 30  |der....menu!28=0|
00002b70  3a 6d 65 6e 75 21 33 32  3d 77 69 6e 5f 69 6e 66  |:menu!32=win_inf|
00002b80  6f 25 3a 6d 65 6e 75 21  33 36 3d 28 77 62 25 3c  |o%:menu!36=(wb%<|
00002b90  3c 32 38 29 2b 28 77 66  25 3c 3c 32 34 29 2b 28  |<28)+(wf%<<24)+(|
00002ba0  31 35 3c 3c 31 32 29 2b  31 3a 24 28 6d 65 6e 75  |15<<12)+1:$(menu|
00002bb0  2b 34 30 29 3d 22 49 6e  66 6f 22 2b bd 30 3a 6d  |+40)="Info"+.0:m|
00002bc0  65 6e 75 21 35 32 3d 26  38 30 3a 6d 65 6e 75 21  |enu!52=&80:menu!|
00002bd0  35 36 3d 2d 31 3a 6d 65  6e 75 21 36 30 3d 6d 65  |56=-1:menu!60=me|
00002be0  6e 75 21 33 36 3a 24 28  6d 65 6e 75 2b 36 34 29  |nu!36:$(menu+64)|
00002bf0  3d 22 51 75 69 74 22 2b  bd 30 0d 0a f0 32 c8 99  |="Quit"+.0...2..|
00002c00  20 57 43 72 65 61 74 65  4d 25 2c 2c 6d 65 6e 75  | WCreateM%,,menu|
00002c10  2c 78 25 2c 79 25 3a f4  20 43 72 65 61 74 65 20  |,x%,y%:. Create |
00002c20  69 63 6f 6e 62 61 72 20  6d 65 6e 75 0d 0a fa 05  |iconbar menu....|
00002c30  e1 0d 0b 04 05 20 0d 0b  0e 1f dd f2 6f 70 65 6e  |..... ......open|
00002c40  5f 77 69 6e 64 6f 77 28  68 61 6e 64 6c 65 25 2c  |_window(handle%,|
00002c50  69 6e 66 6f 29 0d 0b 18  26 f4 20 4f 70 65 6e 73  |info)...&. Opens|
00002c60  20 77 69 6e 64 6f 77 20  77 69 74 68 20 68 61 6e  | window with han|
00002c70  64 6c 65 20 68 61 6e 64  6c 65 25 0d 0b 22 3a f4  |dle handle%..":.|
00002c80  20 49 66 20 69 6e 66 6f  3c 3e 30 20 74 68 65 6e  | If info<>0 then|
00002c90  20 69 6e 66 6f 20 69 73  20 72 65 61 64 79 20 61  | info is ready a|
00002ca0  74 20 69 6e 66 6f 2c 20  65 6c 73 65 20 67 65 74  |t info, else get|
00002cb0  20 69 6e 66 6f 0d 0b 2c  1b ea 20 62 25 2c 70 78  | info..,.. b%,px|
00002cc0  25 2c 70 79 25 2c 5f 25  2c 78 73 25 2c 79 73 25  |%,py%,_%,xs%,ys%|
00002cd0  0d 0b 36 0e e7 69 6e 66  6f 3c 3e 30 20 8c 0d 0b  |..6..info<>0 ...|
00002ce0  40 27 20 e3 20 62 25 3d  30 20 b8 20 33 31 20 88  |@' . b%=0 . 31 .|
00002cf0  20 34 3a 62 6c 6f 63 6b  21 62 25 3d 69 6e 66 6f  | 4:block!b%=info|
00002d00  21 62 25 3a ed 0d 0b 4a  26 cc 20 21 62 6c 6f 63  |!b%:...J&. !bloc|
00002d10  6b 3d 68 61 6e 64 6c 65  25 3a c8 99 20 57 47 65  |k=handle%:.. WGe|
00002d20  74 57 53 25 2c 2c 62 6c  6f 63 6b 0d 0b 54 8d 20  |tWS%,,block..T. |
00002d30  f2 6d 6f 75 73 65 28 70  78 25 2c 70 79 25 2c 5f  |.mouse(px%,py%,_|
00002d40  25 29 3a 78 73 25 3d 62  6c 6f 63 6b 21 31 32 2d  |%):xs%=block!12-|
00002d50  62 6c 6f 63 6b 21 34 3a  79 73 25 3d 62 6c 6f 63  |block!4:ys%=bloc|
00002d60  6b 21 31 36 2d 62 6c 6f  63 6b 21 38 3a 62 6c 6f  |k!16-block!8:blo|
00002d70  63 6b 21 34 3d 70 78 25  2d 36 34 3a 62 6c 6f 63  |ck!4=px%-64:bloc|
00002d80  6b 21 38 3d 70 79 25 2d  79 73 25 2b 31 36 3a 62  |k!8=py%-ys%+16:b|
00002d90  6c 6f 63 6b 21 31 32 3d  62 6c 6f 63 6b 21 34 2b  |lock!12=block!4+|
00002da0  78 73 25 3a 62 6c 6f 63  6b 21 31 36 3d 62 6c 6f  |xs%:block!16=blo|
00002db0  63 6b 21 38 2b 79 73 25  0d 0b 5e 05 cd 0d 0b 68  |ck!8+ys%..^....h|
00002dc0  15 c8 99 20 57 4f 70 65  6e 57 25 2c 2c 62 6c 6f  |... WOpenW%,,blo|
00002dd0  63 6b 0d 0b 72 05 e1 0d  0b 7c 05 20 0d 0b 86 1b  |ck..r....|. ....|
00002de0  dd f2 63 6c 6f 73 65 5f  77 69 6e 64 6f 77 28 68  |..close_window(h|
00002df0  61 6e 64 6c 65 25 29 0d  0b 90 27 f4 20 43 6c 6f  |andle%)...'. Clo|
00002e00  73 65 73 20 77 69 6e 64  6f 77 20 77 69 74 68 20  |ses window with |
00002e10  68 61 6e 64 6c 65 20 68  61 6e 64 6c 65 25 0d 0b  |handle handle%..|
00002e20  9a 25 21 62 6c 6f 63 6b  3d 68 61 6e 64 6c 65 25  |.%!block=handle%|
00002e30  3a c8 99 20 57 43 6c 6f  73 65 57 25 2c 2c 62 6c  |:.. WCloseW%,,bl|
00002e40  6f 63 6b 0d 0b a4 05 e1  0d 0b ae 05 20 0d 0b b8  |ock......... ...|
00002e50  11 dd a4 70 6f 6c 6c 28  6d 61 73 6b 25 29 0d 0b  |...poll(mask%)..|
00002e60  c2 40 f4 20 52 65 74 75  72 6e 73 20 70 6f 6c 6c  |.@. Returns poll|
00002e70  20 72 65 61 73 6f 6e 20  63 6f 64 65 2c 20 6d 61  | reason code, ma|
00002e80  73 6b 69 6e 67 20 77 69  74 68 20 6d 61 73 6b 25  |sking with mask%|
00002e90  2c 20 64 61 74 61 20 61  74 20 70 6f 6c 6c 0d 0b  |, data at poll..|
00002ea0  cc 10 ea 20 72 65 61 73  6f 6e 63 6f 64 65 0d 0b  |... reasoncode..|
00002eb0  d6 25 c8 99 20 57 50 6f  6c 6c 25 2c 6d 61 73 6b  |.%.. WPoll%,mask|
00002ec0  25 2c 70 6f 6c 6c 20 b8  20 72 65 61 73 6f 6e 63  |%,poll . reasonc|
00002ed0  6f 64 65 0d 0b e0 0f 3d  72 65 61 73 6f 6e 63 6f  |ode....=reasonco|
00002ee0  64 65 0d 0b ea 05 20 0d  0b f4 10 dd f2 69 6e 69  |de.... ......ini|
00002ef0  74 69 61 6c 69 73 65 0d  0b fe 19 f4 20 49 6e 69  |tialise..... Ini|
00002f00  74 69 61 6c 69 73 65 73  20 70 72 6f 67 72 61 6d  |tialises program|
00002f10  0d 0c 08 2d 61 70 70 6c  6e 61 6d 65 24 3d 22 4d  |...-applname$="M|
00002f20  61 6b 65 47 49 46 22 3a  f4 20 4e 61 6d 65 20 6f  |akeGIF":. Name o|
00002f30  66 20 61 70 70 6c 69 63  61 74 69 6f 6e 0d 0c 12  |f application...|
00002f40  46 c8 99 20 22 57 69 6d  70 5f 49 6e 69 74 69 61  |F.. "Wimp_Initia|
00002f50  6c 69 73 65 22 2c 32 30  30 2c 26 34 42 35 33 34  |lise",200,&4B534|
00002f60  31 35 34 2c 61 70 70 6c  6e 61 6d 65 24 20 b8 20  |154,applname$ . |
00002f70  76 65 72 73 69 6f 6e 2c  54 61 73 6b 48 61 6e 64  |version,TaskHand|
00002f80  6c 65 25 0d 0c 1c 39 e7  76 65 72 73 69 6f 6e 3c  |le%...9.version<|
00002f90  32 30 30 20 8c 20 85 20  31 2c 22 49 20 63 61 6e  |200 . . 1,"I can|
00002fa0  6e 6f 74 20 77 6f 72 6b  20 77 69 74 68 20 57 49  |not work with WI|
00002fb0  4d 50 20 70 72 65 2d 32  2e 30 30 22 0d 0c 26 36  |MP pre-2.00"..&6|
00002fc0  57 25 3d a4 73 77 69 5f  74 6f 5f 6e 72 28 22 57  |W%=.swi_to_nr("W|
00002fd0  69 6d 70 5f 49 6e 69 74  69 61 6c 69 73 65 22 29  |imp_Initialise")|
00002fe0  3a f4 20 42 61 73 65 20  53 57 49 20 6e 75 6d 62  |:. Base SWI numb|
00002ff0  65 72 0d 0c 30 bd 57 43  72 65 61 74 65 57 25 3d  |er..0.WCreateW%=|
00003000  57 25 2b 31 3a 57 43 72  65 61 74 65 49 25 3d 57  |W%+1:WCreateI%=W|
00003010  25 2b 32 3a 57 4f 70 65  6e 57 25 3d 57 25 2b 35  |%+2:WOpenW%=W%+5|
00003020  3a 57 43 6c 6f 73 65 57  25 3d 57 25 2b 36 3a 57  |:WCloseW%=W%+6:W|
00003030  50 6f 6c 6c 25 3d 57 25  2b 37 3a 57 47 65 74 57  |Poll%=W%+7:WGetW|
00003040  53 25 3d 57 25 2b 31 31  3a 57 47 65 74 49 53 25  |S%=W%+11:WGetIS%|
00003050  3d 57 25 2b 31 34 3a 57  47 65 74 50 49 25 3d 57  |=W%+14:WGetPI%=W|
00003060  25 2b 31 35 3a 57 44 72  61 67 42 25 3d 57 25 2b  |%+15:WDragB%=W%+|
00003070  31 36 3a 57 43 72 65 61  74 65 4d 25 3d 57 25 2b  |16:WCreateM%=W%+|
00003080  32 30 3a 57 4c 6f 61 64  54 25 3d 57 25 2b 32 37  |20:WLoadT%=W%+27|
00003090  3a 57 52 65 70 6f 72 74  25 3d 57 25 2b 33 31 3a  |:WReport%=W%+31:|
000030a0  57 53 65 6e 64 4d 73 67  25 3d 57 25 2b 33 39 0d  |WSendMsg%=W%+39.|
000030b0  0c 3a 3d 74 66 25 3d 37  3a 74 62 25 3d 32 3a 77  |.:=tf%=7:tb%=2:w|
000030c0  66 25 3d 37 3a 77 62 25  3d 30 3a 73 69 25 3d 31  |f%=7:wb%=0:si%=1|
000030d0  3a 73 6f 25 3d 33 3a f4  20 57 69 6e 64 6f 77 2f  |:so%=3:. Window/|
000030e0  6d 65 6e 75 20 63 6f 6c  6f 75 72 73 0d 0c 44 92  |menu colours..D.|
000030f0  21 62 6c 6f 63 6b 3d 2d  31 3a 62 6c 6f 63 6b 21  |!block=-1:block!|
00003100  34 3d 30 3a 62 6c 6f 63  6b 21 38 3d 30 3a 62 6c  |4=0:block!8=0:bl|
00003110  6f 63 6b 21 31 32 3d 36  38 3a 62 6c 6f 63 6b 21  |ock!12=68:block!|
00003120  31 36 3d 36 38 3a 62 6c  6f 63 6b 21 32 30 3d 26  |16=68:block!20=&|
00003130  32 37 30 30 33 30 30 32  3a 24 28 62 6c 6f 63 6b  |27003002:$(block|
00003140  2b 32 34 29 3d 22 21 6d  61 6b 65 67 69 66 22 3a  |+24)="!makegif":|
00003150  c8 99 20 57 43 72 65 61  74 65 49 25 2c 2c 62 6c  |.. WCreateI%,,bl|
00003160  6f 63 6b 20 b8 20 49 69  63 6f 6e 62 61 72 25 3a  |ock . Iiconbar%:|
00003170  f4 20 49 63 6f 6e 62 61  72 20 69 63 6f 6e 0d 0c  |. Iconbar icon..|
00003180  4e 14 f4 20 4c 6f 61 64  20 74 65 6d 70 6c 61 74  |N.. Load templat|
00003190  65 73 0d 0c 58 35 c8 99  20 22 57 69 6d 70 5f 4f  |es..X5.. "Wimp_O|
000031a0  70 65 6e 54 65 6d 70 6c  61 74 65 22 2c 2c 22 3c  |penTemplate",,"<|
000031b0  4d 61 6b 65 47 49 46 24  44 69 72 3e 2e 54 65 6d  |MakeGIF$Dir>.Tem|
000031c0  70 6c 61 74 65 73 22 0d  0c 62 3c 69 63 3d 69 63  |plates"..b<ic=ic|
000031d0  6f 6e 64 61 74 61 3a 69  65 3d 69 63 6f 6e 64 65  |ondata:ie=iconde|
000031e0  6e 64 3a f4 20 49 6e 64  69 72 65 63 74 65 64 20  |nd:. Indirected |
000031f0  69 63 6f 6e 20 64 61 74  61 20 77 6f 72 6b 73 70  |icon data worksp|
00003200  61 63 65 0d 0c 6c 3b 24  64 75 6d 25 3d 22 73 61  |ace..l;$dum%="sa|
00003210  76 65 22 3a c8 99 20 57  4c 6f 61 64 54 25 2c 2c  |ve":.. WLoadT%,,|
00003220  77 69 6e 64 6f 77 31 2c  69 63 2c 69 65 2c 2d 31  |window1,ic,ie,-1|
00003230  2c 64 75 6d 25 2c 30 20  b8 20 2c 2c 69 63 0d 0c  |,dum%,0 . ,,ic..|
00003240  76 25 c8 99 20 57 43 72  65 61 74 65 57 25 2c 2c  |v%.. WCreateW%,,|
00003250  77 69 6e 64 6f 77 31 20  b8 20 77 69 6e 5f 66 69  |window1 . win_fi|
00003260  6c 65 25 0d 0c 80 21 53  41 56 66 6e 25 3d a4 69  |le%...!SAVfn%=.i|
00003270  63 6f 6e 61 64 64 72 28  77 69 6e 5f 66 69 6c 65  |conaddr(win_file|
00003280  25 2c 31 29 0d 0c 8a 3b  24 64 75 6d 25 3d 22 69  |%,1)...;$dum%="i|
00003290  6e 66 6f 22 3a c8 99 20  57 4c 6f 61 64 54 25 2c  |nfo":.. WLoadT%,|
000032a0  2c 77 69 6e 64 6f 77 32  2c 69 63 2c 69 65 2c 2d  |,window2,ic,ie,-|
000032b0  31 2c 64 75 6d 25 2c 30  20 b8 20 2c 2c 69 63 0d  |1,dum%,0 . ,,ic.|
000032c0  0c 94 25 c8 99 20 57 43  72 65 61 74 65 57 25 2c  |..%.. WCreateW%,|
000032d0  2c 77 69 6e 64 6f 77 32  20 b8 20 77 69 6e 5f 69  |,window2 . win_i|
000032e0  6e 66 6f 25 0d 0c 9e 1b  c8 99 20 22 57 69 6d 70  |nfo%...... "Wimp|
000032f0  5f 43 6c 6f 73 65 54 65  6d 70 6c 61 74 65 22 0d  |_CloseTemplate".|
00003300  0c a8 1a f4 20 49 6e 69  74 69 61 6c 69 73 65 20  |.... Initialise |
00003310  76 61 72 69 61 62 6c 65  73 0d 0c b2 46 4f 75 74  |variables...FOut|
00003320  70 75 74 24 3d 22 22 3a  49 6e 70 75 74 24 3d 22  |put$="":Input$="|
00003330  22 3a 44 61 74 61 4c 6f  61 64 52 65 66 25 3d a3  |":DataLoadRef%=.|
00003340  3a 44 61 74 61 53 61 76  65 52 65 66 25 3d 2d 31  |:DataSaveRef%=-1|
00003350  3a f4 20 49 6e 69 74 20  67 6c 6f 62 61 6c 73 0d  |:. Init globals.|
00003360  0c bc 05 e1 0d 0c c6 05  20 0d 0c d0 19 dd a4 69  |........ ......i|
00003370  63 6f 6e 61 64 64 72 28  77 69 6e 25 2c 69 63 6f  |conaddr(win%,ico|
00003380  25 29 0d 0c da 2c f4 20  52 65 74 75 72 6e 73 20  |%)...,. Returns |
00003390  69 6e 64 69 72 65 63 74  65 64 20 69 63 6f 6e 27  |indirected icon'|
000033a0  73 20 64 61 74 61 20 61  64 64 72 65 73 73 0d 0c  |s data address..|
000033b0  e4 3e 21 62 6c 6f 63 6b  3d 77 69 6e 25 3a 62 6c  |.>!block=win%:bl|
000033c0  6f 63 6b 21 34 3d 69 63  6f 25 3a c8 99 20 57 47  |ock!4=ico%:.. WG|
000033d0  65 74 49 53 25 2c 2c 62  6c 6f 63 6b 3a f4 20 47  |etIS%,,block:. G|
000033e0  65 74 20 69 63 6f 6e 20  69 6e 66 6f 0d 0c ee 0d  |et icon info....|
000033f0  3d 62 6c 6f 63 6b 21 32  38 0d 0c f8 05 20 0d 0d  |=block!28.... ..|
00003400  02 15 dd a4 73 77 69 5f  74 6f 5f 6e 72 28 73 77  |....swi_to_nr(sw|
00003410  69 24 29 0d 0d 0c 29 f4  20 52 65 74 75 72 6e 73  |i$)...). Returns|
00003420  20 53 57 49 20 6e 75 6d  62 65 72 20 6f 66 20 53  | SWI number of S|
00003430  57 49 20 63 61 6c 6c 20  73 77 69 24 0d 0d 16 0c  |WI call swi$....|
00003440  ea 20 73 77 69 6e 72 25  0d 0d 20 2f c8 99 20 22  |. swinr%.. /.. "|
00003450  58 4f 53 5f 53 57 49 4e  75 6d 62 65 72 46 72 6f  |XOS_SWINumberFro|
00003460  6d 53 74 72 69 6e 67 22  2c 2c 73 77 69 24 20 b8  |mString",,swi$ .|
00003470  20 73 77 69 6e 72 25 0d  0d 2a 0b 3d 73 77 69 6e  | swinr%..*.=swin|
00003480  72 25 0d 0d 34 05 20 0d  0d 3e 1a dd f2 65 72 72  |r%..4. ..>...err|
00003490  6f 72 28 65 72 72 6e 72  2c 65 72 72 6d 73 67 24  |or(errnr,errmsg$|
000034a0  29 0d 0d 48 14 f4 20 48  61 6e 64 6c 65 73 20 65  |)..H.. Handles e|
000034b0  72 72 6f 72 73 0d 0d 52  0f ea 20 62 75 74 25 2c  |rrors..R.. but%,|
000034c0  6f 70 74 25 0d 0d 5c 27  e7 65 72 72 6e 72 3d 2d  |opt%..\'.errnr=-|
000034d0  31 20 8c 20 65 72 72 6e  72 3d 31 3a 6f 70 74 25  |1 . errnr=1:opt%|
000034e0  3d 31 20 8b 20 6f 70 74  25 3d 33 0d 0d 66 1f 21  |=1 . opt%=3..f.!|
000034f0  65 72 72 3d 65 72 72 6e  72 3a 24 28 65 72 72 2b  |err=errnr:$(err+|
00003500  34 29 3d 65 72 72 6d 73  67 24 0d 0d 70 2a c8 99  |4)=errmsg$..p*..|
00003510  20 57 52 65 70 6f 72 74  25 2c 65 72 72 2c 6f 70  | WReport%,err,op|
00003520  74 25 2c 61 70 70 6c 6e  61 6d 65 24 20 b8 20 2c  |t%,applname$ . ,|
00003530  62 75 74 25 0d 0d 7a 13  e7 62 75 74 25 3c 3e 31  |but%..z..but%<>1|
00003540  20 8c 20 f2 64 69 65 0d  0d 84 05 e1 0d 0d 8e 05  | . .die.........|
00003550  20 0d 0d 98 0c dd f2 66  69 6e 69 73 68 0d 0d a2  | ......finish...|
00003560  0f f4 20 54 69 64 69 65  73 20 75 70 0d 0d ac 31  |.. Tidies up...1|
00003570  f4 20 53 65 6e 64 20 6d  65 73 73 61 67 65 20 74  |. Send message t|
00003580  6f 20 61 73 6b 20 69 66  20 6d 6f 64 75 6c 65 20  |o ask if module |
00003590  63 61 6e 20 62 65 20 6b  69 6c 6c 65 64 0d 0d b6  |can be killed...|
000035a0  c1 21 62 6c 6f 63 6b 3d  32 30 3a 62 6c 6f 63 6b  |.!block=20:block|
000035b0  21 31 32 3d 30 3a 62 6c  6f 63 6b 21 31 36 3d 26  |!12=0:block!16=&|
000035c0  43 43 46 30 30 3a c8 99  20 57 53 65 6e 64 4d 73  |CCF00:.. WSendMs|
000035d0  67 25 2c 31 38 2c 62 6c  6f 63 6b 2c 30 3a 6b 69  |g%,18,block,0:ki|
000035e0  6c 6c 3d a3 3a f5 20 6c  69 73 74 65 6e 25 3d a4  |ll=.:. listen%=.|
000035f0  70 6f 6c 6c 28 30 29 3a  6b 69 6c 6c 3d 6b 69 6c  |poll(0):kill=kil|
00003600  6c 20 84 20 28 28 6c 69  73 74 65 6e 25 3d 31 39  |l . ((listen%=19|
00003610  29 80 28 70 6f 6c 6c 21  31 36 3d 26 43 43 46 30  |).(poll!16=&CCF0|
00003620  30 29 80 28 70 6f 6c 6c  21 31 32 3d 30 29 29 3a  |0).(poll!12=0)):|
00003630  fd 20 6c 69 73 74 65 6e  25 3d 30 3a e7 6b 69 6c  |. listen%=0:.kil|
00003640  6c 20 8c 20 c8 99 20 22  4f 53 5f 4d 6f 64 75 6c  |l . .. "OS_Modul|
00003650  65 22 2c 34 2c 22 4d 61  6b 65 47 49 46 22 0d 0d  |e",4,"MakeGIF"..|
00003660  c0 2d c8 99 20 22 57 69  6d 70 5f 43 6c 6f 73 65  |.-.. "Wimp_Close|
00003670  44 6f 77 6e 22 2c 54 61  73 6b 48 61 6e 64 6c 65  |Down",TaskHandle|
00003680  25 2c 26 34 42 35 33 34  31 35 34 0d 0d ca 05 e1  |%,&4B534154.....|
00003690  0d 0d d4 05 20 0d 0d de  09 dd f2 64 69 65 0d 0d  |.... ......die..|
000036a0  e8 19 f4 20 54 69 64 69  65 73 20 75 70 20 61 6e  |... Tidies up an|
000036b0  64 20 65 78 69 74 73 0d  0d f2 0b f2 66 69 6e 69  |d exits.....fini|
000036c0  73 68 0d 0d fc 10 c8 99  20 22 4f 53 5f 45 78 69  |sh...... "OS_Exi|
000036d0  74 22 0d 0e 06 05 e1 0d  0e 10 05 20 0d 0e 1a 1a  |t"......... ....|
000036e0  dd f2 76 61 72 28 76 61  72 6e 61 6d 65 24 2c 76  |..var(varname$,v|
000036f0  61 6c 75 65 25 29 0d 0e  24 1c f4 20 57 72 69 74  |alue%)..$.. Writ|
00003700  65 73 20 6d 6f 64 75 6c  65 20 76 61 72 69 61 62  |es module variab|
00003710  6c 65 0d 0e 2e 38 24 64  75 6d 25 3d 76 61 72 6e  |le...8$dum%=varn|
00003720  61 6d 65 24 3a c8 99 20  22 4d 61 6b 65 47 49 46  |ame$:.. "MakeGIF|
00003730  5f 53 65 74 56 61 72 69  61 62 6c 65 22 2c 21 64  |_SetVariable",!d|
00003740  75 6d 25 2c 76 61 6c 75  65 25 0d 0e 38 05 e1 0d  |um%,value%..8...|
00003750  0e 42 05 20 0d 0e 4c 13  dd a4 76 61 72 28 76 61  |.B. ..L...var(va|
00003760  72 6e 61 6d 65 24 29 0d  0e 56 1b f4 20 52 65 61  |rname$)..V.. Rea|
00003770  64 73 20 6d 6f 64 75 6c  65 20 76 61 72 69 61 62  |ds module variab|
00003780  6c 65 0d 0e 60 0c ea 20  76 61 6c 75 65 25 0d 0e  |le..`.. value%..|
00003790  6a 3b 24 64 75 6d 25 3d  76 61 72 6e 61 6d 65 24  |j;$dum%=varname$|
000037a0  3a c8 99 20 22 4d 61 6b  65 47 49 46 5f 52 65 61  |:.. "MakeGIF_Rea|
000037b0  64 56 61 72 69 61 62 6c  65 22 2c 21 64 75 6d 25  |dVariable",!dum%|
000037c0  20 b8 20 76 61 6c 75 65  25 0d ff                 | . value%..|
000037cb