home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1995-01-03 | 15.7 KB | 548 lines |
- ' **************************************************************************
- ' * *
- ' * Image Compressor v1.0 *
- ' * *
- ' * *
- ' * Copyright � 1994 Sixth Sense *
- ' * *
- ' * *
- ' * Written by Andrew Smith *
- ' * *
- ' * Exclusive to Amoszine *
- ' * *
- ' * This program was written to replace the IFF Compactor that is supplied *
- ' * with Easy AMOS and AMOS Professional. This package was written mainly *
- ' * due to the fact that the one supplied didn't do what I wanted it to do.*
- ' * *
- ' **************************************************************************
-
- ' Set Accessory
-
- PICINMEM=False : PCKED=False
- Global PICINMEM,PCKED
-
- _INIT
- Repeat
- D=Dialog(1)
- If D=2 Then _LOAD_IFF
- If D=3 Then _LOAD_ABK
- If D=4 Then _LOAD_SABK
- If D=5 Then _LOAD_PPABK
- If D=6 and PICINMEM=False
- _ERROR["You must load an image first"]
- Else If D=6 and PICINMEM
- _PACK_SCREEN[1]
- End If
- If D=7 and PICINMEM=False
- _ERROR["You must load an image first"]
- Else If D=7 and PICINMEM
- _PACK_SCREEN[2]
- End If
- If D=8 and PICINMEM=False
- _ERROR["You must load an image first"]
- Else If D=8 and PICINMEM
- _SAVE_IFF
- End If
- If D=9 and PICINMEM=False
- _ERROR["You must load an image first"]
- Else If D=9 and PCKED=False
- _ERROR["You must pack the image before saving!"]
- Else If D=9 and PICINMEM
- _SAVE_ABK
- End If
- If D=10 and PICINMEM=False
- _ERROR["You must load an image first"]
- Else If D=10 and PCKED=False
- _ERROR["You must pack the image before saving!"]
- Else If D=10 and PICINMEM
- _SAVE_SABK
- End If
- If D=11 and PICINMEM=False
- _ERROR["You must load an image first"]
- Else If D=11 and PCKED=False
- _ERROR["You must pack the image before saving!"]
- Else If D=11 and PICINMEM
- _SAVE_PPABK
- End If
- If D=12 Then _ABOUT
- Multi Wait
- Until D=1 or D=13
- Dialog Close
- Erase All
- End
-
- Procedure _INIT
- Resource Screen Open 0,640,190,0
- Cls 0
- A$="BAse 200,0;"
- A$=A$+"BOx 0,0,1,260,190;"
- A$=A$+"BU 1,0,0,24,10,0,0,1;[UNpack 0,0,22;][UNpack 0,0,23; BR 0;]"
- A$=A$+"KY 197,0;"
- A$=A$+"LIne 24,0,28,260; PR 30,1,'Image Compressor v1.0b',7;"
- A$=A$+"BU 2,10,14,240,16,0,0,1;[LIne 0,0,88,240; PR 50,4,'Load an IFF image',2;][LIne 10,14,91,250; PR 60,19,'Load an IFF image',2; BR 0;]"
- A$=A$+"KY 208,0;"
- A$=A$+"BU 3,10,29,240,16,0,0,1;[LIne 0,0,88,240; PR 50,4,'Load an ABK image',2;][LIne 10,29,91,250; PR 60,34,'Load an ABK image',2; BR 0;]"
- A$=A$+"KY 209,0;"
- A$=A$+"BU 4,10,44,240,16,0,0,1;[LIne 0,0,88,240; PR 20,4,'Load a squashed ABK image',2;][LIne 10,44,91,250; PR 30,49,'Load a squashed ABK image',2; BR 0;]"
- A$=A$+"KY 210,0;"
- A$=A$+"BU 5,10,59,240,16,0,0,1;[LIne 0,0,88,240; PR 16,4,'Load PowerPacked ABK image',2;][LIne 10,59,91,250; PR 26,64,'Load PowerPacked ABK image',2; BR 0;]"
- A$=A$+"KY 211,0;"
- A$=A$+"BU 6,10,74,240,16,0,0,1;[LIne 0,0,88,240; PR 65,4,'Pack as screen',2;][LIne 10,74,91,250; PR 75,79,'Pack as screen',2; BR 0;]"
- A$=A$+"KY 212,0;"
- A$=A$+"BU 7,10,89,240,16,0,0,1;[LIne 0,0,88,240; PR 65,4,'Pack as bitmap',2;][LIne 10,89,91,250; PR 75,94,'Pack as bitmap',2; BR 0;]"
- A$=A$+"KY 213,0;"
- A$=A$+"BU 8,10,104,240,16,0,0,1;[LIne 0,0,88,240; PR 65,4,'Save IFF image',2;][LIne 10,104,91,250; PR 75,109,'Save IFF image',2; BR 0;]"
- A$=A$+"KY 214,0;"
- A$=A$+"BU 9,10,119,240,16,0,0,1;[LIne 0,0,88,240; PR 65,4,'Save ABK image',2;][LIne 10,119,91,250; PR 75,124,'Save ABK image',2; BR 0;]"
- A$=A$+"KY 215,0;"
- A$=A$+"BU 10,10,134,240,16,0,0,1;[LIne 0,0,88,240; PR 30,4,'Save squashed ABK image',2;][LIne 10,134,91,250; PR 40,139,'Save squashed ABK image',2; BR 0;]"
- A$=A$+"KY 216,0;"
- A$=A$+"BU 11,10,149,240,16,0,0,1;[LIne 0,0,88,240; PR 15,4,'Save Powerpacked ABK image',2;][LIne 10,149,91,250; PR 25,154,'Save Powerpacked ABK image',2; BR 0;]"
- A$=A$+"KY 217,0;"
- A$=A$+"BOx 8,166,79,250,187;"
- A$=A$+"BU 12,16,168,64,16,0,0,1;[UNpack 0,0,13; PR 10,4,'About',2;][UNpack 16,168,14; PR 26,173,'About',2; BR 0;]"
- A$=A$+"BU 13,180,168,64,16,0,0,1;[UNpack 0,0,13; PR 12,4,'Quit',2;][UNpack 180,168,14; PR 192,173,'Quit',2; BR 0;]"
- A$=A$+"BU 14,24,0,260,10,0,0,1;[][SM;]"
- A$=A$+"EXit;"
- Dialog Open 1,A$
- R=Dialog Run(1)
- _WB_POINTER
- End Proc
- Procedure _LOAD_IFF
- F$=Fsel$("","","Load an IFF image","")
- If F$="" Then Pop Proc
- If Not Exist(F$)
- _ERROR["File does not exist!"]
- Pop Proc
- End If
- Trap Load Iff F$,1
- If Errtrap<>0
- _ERROR["File is not an IFF image!"]
- Pop Proc
- End If
- _INFO[SW,SH,SC,F$]
- Screen To Back 1
- End Proc
- Procedure _LOAD_ABK
- F$=Fsel$("","","Load an ABK image","")
- If F$="" Then Pop Proc
- If Not Exist(F$)
- _ERROR["File does not exist!"]
- Pop Proc
- End If
- Trap Load F$,15
- If Errtrap<>0
- _ERROR["File is not a packed picture!"]
- Pop Proc
- End If
- Trap Unpack 15 To 1
- If Errtrap<>0
- _ERROR["Not a packed bitmap!"]
- Pop Proc
- End If
- _INFO[SW,SH,SC,F$]
- Screen To Back 1
- End Proc
- Procedure _LOAD_SABK
- F$=Fsel$("","","Load a Squashed ABK image","")
- If F$="" Then Pop Proc
- If Not Exist(F$)
- _ERROR["File does not exist!"]
- Pop Proc
- End If
- Open In 1,F$
- SIZEOFFILE=Lof(1)
- Close 1
- Reserve As Work 15,SIZEOFFILE*3
- Bload F$,Start(15)
- HEADER=Leek(Start(15))
- If HEADER<>$48C09809
- _ERROR["File is not a squashed bank!"]
- Pop Proc
- End If
- L= Extension_5_00E4(Start(15),SIZEOFFILE)
- Bank Shrink 15 To L
- Trap Unpack 15 To 1
- If Errtrap<>0
- _ERROR["Not a squashed bitmap!"]
- Pop Proc
- End If
- _INFO[SW,SH,SC,F$]
- Screen To Back 1
- End Proc
- Procedure _LOAD_PPABK
- F$=Fsel$("","","Load a PowerPacked ABK image","")
- If F$="" Then Pop Proc
- If Not Exist(F$)
- _ERROR["File does not exist!"]
- Pop Proc
- End If
- Trap Extension_5_0120 F$,15
- If Errtrap<>0
- _ERROR["File is not a PowerPacked picture bank!"]
- Pop Proc
- End If
- Trap Unpack 15 To 1
- If Errtrap<>0
- _ERROR["Error unpacking! File is possibly corrupt"]
- Pop Proc
- End If
- _INFO[SW,SH,SC,F$]
- Screen To Back 1
- End Proc
- Procedure _INFO[SW,SH,SC,F$]
- PICINMEM=True : PCKED=False
- Dialog Freeze 1
- Resource Screen Open 2,640,45,0
- A$=A$+"BOx 0,0,1,640,45; SIze 640,45; SAve 1;"
- A$=A$+"LIne 0,0,28,640; PR 10,1,'Image Statistics',2;"
- A$=A$+"BU 1,0,0,640,10,0,0,1;[][SM;]"
- A$=A$+"PR 10,16,'Filename',2; LIne 80,15,44,630;"
- A$=A$+"PR 10,28,'Size',2; LIne 80,27,44,160;"
- A$=A$+"PR 170,28,'Colours',2; LIne 250,27,44,290;"
- A$=A$+"BU 2,560,26,64,16,0,0,1;[UNpack 0,0,13; PR 7,4,'Cancel',2;][UNpack 560,26,14; PR 567,31,'Cancel',2; BR 0;]"
- A$=A$+"KY 196,0;"
- A$=A$+"EXit;"
- Dialog Open 2,A$
- R=Dialog Run(2)
- Screen 1
- SW=Screen Width
- SH=Screen Height
- SC=Screen Colour
- Screen 2
- SW$=Str$(SW) : SH$=Mid$(Str$(SH),2,5) : SC$=Str$(SC)
- RES$=SW$+"x"+SH$
- Ink 7
- Text 84,22,F$
- Text 76,34,RES$
- Text 246,34,SC$
- X=0 : Y=0
- Repeat
- X$=Inkey$
- S=Scancode
- If S=76
- Add Y,-2
- If Y<0 : Y=0 : End If
- End If
- If S=77
- Add Y,2
- If Y>(Screen Height/2)-1 : Y=(Screen Height/2)-1 : End If
- End If
- If S=79
- Add X,-2
- If X<0 : X=0 : End If
- End If
- If Screen Width>320
- If S=78
- Add X,2
- If X>(Screen Width/2)-1 : X=(Screen Width/2)-1 : End If
- End If
- End If
- Screen Offset 1,X,Y
- Wait Vbl
- D=Dialog(2)
- Until D=2
- Dialog Close 2
- Screen Close 2
- Dialog Unfreeze 1
- End Proc
- Procedure _PACK_SCREEN[TYPE]
- Dialog Freeze 1
- Screen To Front 1
- _ABOUT_SCREEN
- Screen 1
- Gr Writing 3
- SX=0 : SY=0 : EX=Screen Width-1 : EY=Screen Height-1
- _UPDATE_GROWBOX[EX-SX,EY-SY]
- Limit Mouse
- X=0 : Y=0
- Repeat
- D=Dialog(2)
- X$=Inkey$
- S=Scancode
- If S=76
- Add Y,-2
- If Y<0 : Y=0 : End If
- End If
- If Screen Height>256
- If S=77
- Add Y,2
- If Y>(Screen Height/2)-1 : Y=(Screen Height/2)-1 : End If
- End If
- End If
- If S=79
- Add X,-2
- If X<0 : X=0 : End If
- End If
- If Screen Width>320
- If S=78
- Add X,2
- If X>(Screen Width/2)-1 : X=(Screen Width/2)-1 : End If
- End If
- End If
- Screen Offset 1,X,Y
- Wait Vbl
- If Mouse Key=1
- SX=X Screen(X Mouse)
- SY=Y Screen(Y Mouse)
- If SX>EX : SX=EX : End If
- If SY>EY : SY=EY : End If
- _UPDATE_GROWBOX[EX-SX,EY-SY]
- End If
- If Mouse Key=2
- EX=X Screen(X Mouse)
- EY=Y Screen(Y Mouse)
- If EX>Screen Width
- EX=Screen Width
- End If
- If EY>Screen Height
- EY=Screen Height
- End If
- If EX<SX : EX=SX : End If
- If EY<SY : EY=SY : End If
- _UPDATE_GROWBOX[EX-SX,EY-SY]
- End If
- Box SX,SY To EX,EY
- Wait Vbl
- Box SX,SY To EX,EY
- Until D>1
- Dialog Close 2
- Screen Close 2
- If D=2
- Screen Display 1,,,EX+1,EY-SY+1
- Wait Vbl
- _WAIT["Packing image into memory bank"]
- If TYPE=1
- Spack 1 To 15,SX,SY,EX+1,EY+1
- Else If TYPE=2
- Pack 1 To 15,SX,SY,EX+1,EY+1
- End If
- Dialog Close 2
- Dialog Unfreeze 1
- Screen Close 2
- PCKED=True
- Else
- PCKED=False
- End If
- Screen To Back 1
- Dialog Unfreeze 1
- Screen 0
- End Proc
- Procedure _ERROR[MESSAGE$]
- Screen 0
- Dialog Freeze 1
- A$=A$+"BAse 130,60; SIze 390,57; SAve 1;"
- A$=A$+"BOx 0,0,1,390,57;"
- A$=A$+"LIne 0,0,28,390; PR 10,1,'Image Request',0;"
- A$=A$+"BOx 8,15,79,380,31;"
- A$=A$+"PR 0VA CentreX,19,0VA,7;"
- A$=A$+"BU 1,165,36,64,16,0,0,1;[UNpack 0,0,13; PR 3,4,'Cancel',2;][UNpack 165,36,14; PR 168,41,'Cancel',2; BR 0;]"
- A$=A$+"KY 68 128 +,0;"
- A$=A$+"EXit;"
- Dialog Open 2,A$
- Vdialog$(2,0)=MESSAGE$
- R=Dialog Run(2)
- Repeat
- D=Dialog(2)
- Until D=1
- Dialog Close 2
- Dialog Unfreeze 1
- End Proc
- Procedure _WAIT[MESSAGE$]
- Dialog Freeze 1
- Resource Screen Open 2,640,40,0
- Cls 0
- A$=A$+"BAse 130,0; SIze 390,40;"
- A$=A$+"BOx 0,0,1,390,40;"
- A$=A$+"LIne 0,0,28,390; PR 10,1,'IC Message',0;"
- A$=A$+"BOx 8,15,79,380,31;"
- A$=A$+"PR 0VA CentreX,19,0VA,7;"
- A$=A$+"EXit;"
- Dialog Open 2,A$
- Vdialog$(2,0)=MESSAGE$
- R=Dialog Run(2)
- Wait Vbl
- End Proc
- Procedure _CHOICE[MESSAGE$]
- Screen To Front 0
- Screen 0
- A$=A$+"BAse 130,60; SIze 390,57; SAve 1;"
- A$=A$+"BOx 0,0,1,390,57;"
- A$=A$+"LIne 0,0,28,390; PR 10,1,'Image Request',0;"
- A$=A$+"BOx 8,15,79,380,31;"
- A$=A$+"PR 0VA CentreX,19,0VA,7;"
- A$=A$+"BU 1,10,36,64,16,0,0,1;[UNpack 0,0,13; PR 8,4,'Okay',2;][UNpack 10,36,14; PR 18,41,'Okay',2; BR 0;]"
- A$=A$+"KY 128 24+,0;"
- A$=A$+"BU 2,316,36,64,16,0,0,1;[UNpack 0,0,13; PR 5,4,'Cancel',2;][UNpack 316,36,14; PR 321,41,'Cancel',2; BR 0;]"
- A$=A$+"KY 128 51+,0;"
- A$=A$+"EXit;"
- Dialog Open 2,A$
- Vdialog$(2,0)=MESSAGE$
- R=Dialog Run(2)
- Repeat
- D=Dialog(2)
- Until D<>0
- Dialog Close 2
- Screen To Back 0
- End Proc[D]
- Procedure _SAVE_IFF
- Dialog Freeze 1
- Screen To Front 1
- F$=Fsel$("","","Save Image","Enter name for IFF image")
- If F$=""
- Screen To Back 1
- Dialog Unfreeze 1
- Pop Proc
- End If
- If Exist(F$)
- _CHOICE["File already exists, Overwrite?"]
- D=Param
- If D=2
- Screen To Back 1
- Dialog Unfreeze 1
- Pop Proc
- End If
- End If
- Screen 1
- Save Iff F$
- Screen To Back 1
- Dialog Unfreeze 1
- End Proc
- Procedure _SAVE_ABK
- Dialog Freeze 1
- Screen To Front 1
- F$=Fsel$("","","Save image","Enter name for ABK image")
- If F$=""
- Screen To Back 1
- Dialog Unfreeze 1
- Pop Proc
- End If
- If Exist(F$)
- _CHOICE["File already exists, Overwrite?"]
- D=Param
- If D=2
- Screen To Back 1
- Dialog Unfreeze 1
- Pop Proc
- End If
- End If
- Save F$,15
- Screen To Back 1
- Dialog Unfreeze 1
- End Proc
- Procedure _SAVE_SABK
- Dialog Freeze 1
- Screen To Front 1
- F$=Fsel$("","","Save image","Enter name for ABK image")
- If F$=""
- Screen To Back 1
- Dialog Unfreeze 1
- Pop Proc
- End If
- If Exist(F$)
- _CHOICE["File already exists, Overwrite?"]
- D=Param
- If D=2
- Screen To Back 1
- Dialog Unfreeze 1
- Pop Proc
- End If
- End If
- _WAIT["Please wait, squashing image..."]
- L= Extension_5_00CE(Start(15),Length(15),1,4095,18)
- Bsave F$,Start(15) To Start(15)+L
- Screen To Back 1
- Dialog Unfreeze 1
- Dialog Close 2
- Screen Close 2
- End Proc
- Procedure _SAVE_PPABK
- Dialog Freeze 1
- Screen To Front 1
- F$=Fsel$("","","Save image","Enter name for Powerpacked ABK image")
- If F$=""
- Screen To Back 1
- Dialog Unfreeze 1
- Pop Proc
- End If
- If Exist(F$)
- _CHOICE["File already exists, Overwrite?"]
- D=Param
- If D=2
- Screen To Back 1
- Dialog Unfreeze 1
- Pop Proc
- End If
- End If
- _WAIT["Please wait, Powerpacking image..."]
- Extension_5_0106 F$,15,4
- Dialog Close 2
- Dialog Unfreeze 1
- Screen Close 2
- Screen To Back 1
- End Proc
- Procedure _ABOUT
- Screen 0
- Dialog Freeze 1
- A$=A$+"BAse 70,20; SIze 500,130; SAve 1;"
- A$=A$+"BOx 0,0,1,500,130;"
- A$=A$+"PO 95,20,'Image Compressor v1.0b � 1994 Sixth Sense',0,3;"
- A$=A$+"LIne 0,10,10,503;"
- A$=A$+"LIne 0,30,10,503;"
- A$=A$+"PRint 150,50,'Programmed by A. N. Smith',2;"
- A$=A$+"PR 130,65,'This version is Public Domain',7;"
- A$=A$+"BU 1,220,110,64,16,0,0,1;"
- A$=A$+"[UN 0,0,13; PR 5,4,'Cancel',2;][UN 220,110,14; PR 225,115,'Cancel',2; BR 0;]"
- A$=A$+"EXit;"
- Dialog Open 2,A$
- R=Dialog Run(2)
- F$=Str$(Fast Free) : C$=Str$(Chip Free)
- Text 220,107,'Chip Memory : '+C$
- Text 220,117,'Fast Memory : '+F$
- Repeat
- BUTTON=Dialog(2)
- Until BUTTON=1
- Dialog Close 2
- Dialog Unfreeze 1
- End Proc
- Procedure _ABOUT_SCREEN
- Resource Screen Open 2,640,35,0
- A$=A$+"BOx 0,0,1,640,35; SIze 640,35; SAve 1;"
- A$=A$+"LIne 0,0,28,640; PR 10,1,'Pack Image',2;"
- A$=A$+"BU 1,0,0,640,10,0,0,1;[][SM;]"
- A$=A$+"PR 10,15,'Size',2; LIne 80,14,44,160;"
- A$=A$+"PR 170,15,'Box size',2; LIne 250,14,44,330;"
- A$=A$+"PR 350,15,'Colours',2; LIne 430,14,44,480;"
- A$=A$+"BU 2,488,14,64,16,0,0,1;[UNpack 0,0,13; PR 9,4,'Pack',2;][UNpack 488,14,14; PR 491,19,'Pack',2; BR 0;]"
- A$=A$+"BU 3,560,14,64,16,0,0,1;[UNpack 0,0,13; PR 7,4,'Cancel',2;][UNpack 560,14,14; PR 567,19,'Cancel',2; BR 0;]"
- A$=A$+"KY 196,0;"
- A$=A$+"EXit;"
- Dialog Open 2,A$
- R=Dialog Run(2)
- Screen 1
- SW=Screen Width
- SH=Screen Height
- SC=Screen Colour
- Screen 2
- SW$=Str$(SW) : SH$=Mid$(Str$(SH),2,5) : SC$=Str$(SC)
- RES$=SW$+"x"+SH$
- Ink 7
- Text 76,21,RES$
- Text 420,21,SC$
- X=0 : Y=0
- End Proc
- Procedure _UPDATE_GROWBOX[EX,EY]
- Screen 2
- Gr Writing 1
- Ink 7,2
- EX$=Str$(EX) : EY$=Mid$(Str$(EY),2,5)
- SIZE$=EX$+"x"+EY$
- SIZE$=Mid$(SIZE$,2,8)
- Text 250,21," "
- Text 250,21,SIZE$
- Gr Writing 0
- Screen 1
- End Proc
- Procedure _WB_POINTER
- Colour 17,$FFF : Colour 18,$F40 : Colour 19,$0
- End Proc