home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
401-425
/
apd410
/
packer.amos
/
packer.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1992-05-17
|
14KB
|
533 lines
' STORM SUPER CRUNCHER v1.1
'
' SIMPLE ONE LINE INSTRUCTIONS TO PRODUCE AN EFFECTIVE ICON SYSTEM!
' FEEL FREE TO EXAMINE THE CODE BUT IF YOU WISH TO ADD FURTHER STUFF
' FOR A PD RELEASE THEN GET IN TOUCH WITH ME FIRST.
' I HOPE THE REMS MAKE IT EASIER TO READ!...BETTER CLARITY AT LEAST!
' NOTE TO CODERS IN AMOS - USE A BIT OF PRESENTATION! FOR GODS SAKE! -
' CAN YOU MAKE IT BETTER
' WHY DOES THE CRUNCHER NOT HAVE A FACILITY TO RECORD THE ORIGINAL SIZE
' ON THE CRUNCHED FILES?!.THIS WOULD MAKE DECRUNCHING MUCH EASIER.
' BUT IF YOU WANT TO DECRUNCH A FILE MAKE SURE YOU KNOW ITS ORIGINAL SIZE!
' BEFORE ATTEMPTING IT!.
' DONT BLAME ME IF IT CRASHES BLAME AMOS!
' FRANCIOS SHOULD PUT A "TAG" ON EACH CRUNCHED FILE.WHERE THE TAG WOULD
' BE THE ORIGINAL LENGTH NUMBER,BUT UNTIL THEN RIGHT DOWN THE OLD SIZE OF YOUR
' FILES!.
' ANY BUGS,REPORTS AND CRITISMS WRITE TO EJBER OZKAN :-
' 222 TUNNEL AVE
' GREENWICH
' LONDON
' ENGLAND
' SE10 OPL
Dir$="DF0:"
Dim EF$(6)
Global EF$(),DEF,Z,LTH,CFS,A$,CFLASH$
Global VSLOW,SLOW,NORM,FAST,VFAST,DA$
CFLASH$="-Z00"
MAIN
PPACKER
End
Procedure MAIN
Screen Open 0,640,256,8,Hires
Curs Off : Flash Off : Pen 2 : Paper 0 : Ink 2 : Cls 0 : Home
Screen Display 0,140,40,640,256
Limit Mouse X Hard(0),Y Hard(0) To X Hard(1000),Y Hard(100)
Change Mouse 4
End Proc
Procedure PPACKER
' /\/\/\/\/\/\/\/\/\/\/\/\
' \/SETUP/ROUTINES!/1992\/
' /\/\/\/\/\/\/\/\/\/\/\/\
VSLOW=4095 : SLOW=2048 : NORM=1024 : FAST=512 : VFAST=256 : COML=0
EF$(1)="VSLOW" : EF$(2)="SLOW " : EF$(3)="NORM " : EF$(4)="FAST " : EF$(5)="VFAST"
DEF=1 : CFS=0
Reserve Zone 15
RGB=0
For I=1 To 7
Colour I,I*256+512
Next I
Colour 2,$DDD
Locate 1,1 : Print Border$(Zone$("LOAD FILE TO PACK",1),1)
Locate 20,1 : Print Border$(Zone$("SAVE PACKED FILE",2),1)
Locate 38,1 : Print Border$(" ",1)
'
Locate 1,4 : Print Border$("COLOUR FLASH 00",1)
Locate 18,4 : Print Border$(Zone$("+",3),1)
Locate 21,4 : Print Border$(Zone$("-",4),1)
'
Locate 24,4 : Print Border$("EFFICIENT VSLOW",1)
Locate 43,4 : Print Border$(Zone$("+",5),1)
Locate 46,4 : Print Border$(Zone$("-",6),1)
Pen 4 : Locate 49,4 : Print Border$(Zone$("STORM AMOS CRUNCHER v1.1 1992 ",8),1)
'
Pen 2
Locate 1,7 : Print Border$("FILE SIZE: ",1)
Locate 21,7 : Print Border$("NEW SIZE: ",1)
Locate 41,7 : Print Border$("SECONDS: ",1)
Locate 57,7 : Print Border$("GAINED: ",1)
Locate 75,7 : Print Border$(Zone$("QUIT",10),1)
'
Locate 1,10 : Print Border$(Zone$("LOAD AND UNCRUNCH",11),1)
Locate 20,10 : Print Border$(Zone$("SAVE DECRUNCHED FILE",12),1)
'
Locate 42,10 : Print Border$("CHIP: FAST: TOT: ",1)
'
Locate 1,13 : Print Border$(Zone$("CRUNCH COMPILED AMOS FILES",14),1)
'
Locate 29,13 : Print Border$(Zone$("ENTER CLI - ESC",15),1)
'
' /\/\/\/\/\/\/\
' \/\MAIN/LOOP\/
' /\/\/\/\/\/\/\
Do
ZA=Mouse Zone
If ZA=1 and Mouse Key=1 Then Gosub LPACK
If ZA=2 and Mouse Key=1 Then Gosub SACK
If ZA=3 and Mouse Key=1 Then Gosub C0L1
If ZA=4 and Mouse Key=1 Then Gosub C0L2
If ZA=5 and Mouse Key=1 Then Gosub CHEFF
If ZA=6 and Mouse Key=1 Then Gosub CHEFF2
If ZA=8 and Mouse Key=1 Then Gosub BOM
If ZA=10 and Mouse Key=1 Then Gosub QUIT
If ZA=11 and Mouse Key=1 Then Gosub LUACK
If ZA=12 and Mouse Key=1 Then Gosub SUACK
If ZA=14 and Mouse Key=1 Then Gosub DEBRE
If ZA=15 and Mouse Key=1 Then Gosub CLI
If Key State(69)=True Then Gosub CLI
Gosub MEM
Wait 3
Loop
'
'
'
DROOP:
Locate 40,1 : Print "FREE DF0:";Dfree
If Exist("df1:")=True Then Dir$="df1:" : Locate 62,1 : Print "FREE DF1:";Dfree : Dir$="df0:"
Return
'
' /\/\/\/\/\/\/\/
' \/MEM/CONTROL/\
' /\/\/\/\/\/\/\/
'
CLI:
If COML=0 Then Amos To Back : COML=1 : Return
If COML=1 Then Amos To Front : COML=0 : Return
Return
'
'
MEM:
Locate 47,10 : Print Chip Free;
Locate 60,10 : Print Free+Fast Free;
Locate 72,10 : Print Free+Fast Free+Chip Free;
Return
'
QUIT:
REQ[" DO YOU REALLY WANT TO QUIT"," THE CRUNCHER?!"," YES"," NO!"]
If Z=2 Then Return
If Z=1 Then Reset Zone : End
Return
' /\/\/\/\/\/
' \/ABOUT?!/\
' /\/\/\/\/\/
BOM:
Zoom 0,390,30,480,40 To 0,0,120,640,250
Flash 4,"(100,4)(700,4)(d00,4)(700,4)(100,4)"
Locate 32,13 : Print Border$(Zone$("CLICK ME!",9),1)
Repeat
ZA=Mouse Zone
Until ZA=9 and Mouse Key=1
Reset Zone 9
Cls 0,0,92 To 640,250
Flash Off
'
Locate 1,13 : Print Border$(Zone$("CRUNCH COMPILED AMOS FILES",14),1)
Locate 29,13 : Print Border$(Zone$("ENTER CLI - ESC",15),1)
Return
' /\/\/\/\/\/\/\/\/\/\/\/\
' \/THE/PACKING/ROUTINE!\/
' /\/\/\/\/\/\/\/\/\/\/\/\
LPACK:
If Length(12)=>1 Then REQ[" ARE YOU SURE YOU WANT TO"," LOAD AND CRUNCH NEW FILE?","CONTINUE"," CANCEL"]
If Z=2 Then Return
If Length(12)=>1 Then Erase 12
Locate 38,1 : Print Border$(" ",1)
Gosub DROOP
A$=Fsel$("","","CHOOSE A FILE TO LOAD")
If A$="" Then Return
Locate 1,7 : Print Border$("FILE SIZE: ",1)
Locate 21,7 : Print Border$("NEW SIZE: ",1)
Locate 41,7 : Print Border$("SECONDS: ",1)
Locate 57,7 : Print Border$("GAINED: ",1)
Open In 1,A$
LTH=Lof(1)
Locate 11,7 : Print LTH;
Close 1
Reserve As Work 12,LTH
STA=Start(12)
LTH2=Length(12)
BNE=Len(A$)
If BNE=>31 Then AB$=Mid$(A$,1,31) : AB$=Upper$(AB$) : Else AB$=A$ : AB$=Upper$(AB$)
Locate 40,1 : Print "LOADING:"+AB$
Bload A$,STA
Locate 38,1 : Print Border$(" ",1)
BNE=Len(AB$)
If BNE=>24 Then AB$=Mid$(A$,1,24) : AB$=Upper$(AB$) : Else AB$=AB$ : AB$=Upper$(AB$)
Locate 40,1 : Print "CRUNCHING FILE:"+AB$
Timer=0 : TEMP2=DEF
Gosub MEM
If DEF=<0 and DEF=>6 Then DEF=VFAST
If DEF=5 Then DEF=VFAST
If DEF=4 Then DEF=FAST
If DEF=3 Then DEF=NORM
If DEF=2 Then DEF=SLOW
If DEF=1 Then DEF=VSLOW
JEF= Extension_5_00CE(STA,LTH2,0,DEF,CFS)
Locate 38,1 : Print Border$(" ",1)
Locate 49,7 : Print Timer/50
Gosub MEM
If JEF=>0 Then Locate 40,1 : Print "FINISHED CRUNCHING FILE" : Gosub JOBS : Return
If JEF=0 Then Locate 40,1 : Print "TERMINATED WITH CONTROL-C" : DEF=TEMP2 : Erase 12 : Return
If JEF<0 Then Locate 40,1 : Print "LONGER THAN ORIGINAL!" : DEF=TEMP2 : Erase 12 : Return
Return
' /\/\/\/\/\/\/\/\/\
' \/SAVING ROUTINE\/
' /\/\/\/\/\/\/\/\/\
SACK:
On Error Goto NO_USE
If Start(12)=<0 Then Return
JEFSS:
If Z=1 Then Return
Gosub DROOP
A$=Fsel$("","","SAVE FILE AS")
If A$="" Then Return
Locate 38,1 : Print Border$(" ",1)
BNE=Len(A$)
If BNE=>32 Then AB$=Mid$(A$,1,32) : AB$=Upper$(AB$) : Else AB$=A$ : AB$=Upper$(AB$)
Locate 40,1 : Print "SAVING:"+AB$
Bsave A$,Start(12) To Start(12)+TEMP
Locate 38,1 : Print Border$(" ",1)
Return
' /\/\/\/\/\/\/\/\/\/\/\/\
' \/DECRUNCHING/ROUTINE!\/
' /\/\/\/\/\/\/\/\/\/\/\/\
LUACK:
If Length(12)=>1 Then REQ[" ARE YOU SURE YOU WANT TO"," DECRUNCH NEW FILE?","CONTINUE"," CANCEL"]
If Z=2 Then Return
If Length(12)=>1 Then Erase 12
Gosub DROOP
A$=Fsel$("","","LOAD FILE TO DECRUNCH")
If A$="" Then Return
Open In 1,A$
LTH4=Lof(1)
Locate 11,7 : Print LTH4;
Close 1
' /\/\/\/\/\/\/\/\/\
' \/KEYBOARD\INPUT\/
' /\/\/\/\/\/\/\/\/\
JESA:
Clear Key
Locate 41,1 : Print "PRESS [X] WHEN SIZE IS REACHED"
Locate 40,13 : Print Border$("ENTER DECRUNCHED SIZE: ",1)
XP=62
C$="" : DER$=""
JESD:
Locate XP,13
C$=Input$(1)
DAFT=Asc(C$)
If DAFT=120 Then Goto FREDY
If DAFT=<47 Then Goto JESD
If DAFT=>58 Then Goto JESD
DER$=DER$+C$
Print C$;
Add XP,1
If XP=>69 Then Goto FREDY
Goto JESD
'
FREDY:
JHOO=Val(DER$)
Locate 30,7 : Print JHOO
Cls 0,250,93 To 640,130
Locate 29,13 : Print Border$(Zone$("ENTER CLI - ESC",15),1)
If JHOO<LTH4 Then Locate 40,1 : Print "SIZE IS SMALLER THAN FILE!" : Goto JESA
REQ[" ARE YOU SURE ABOUT THE SIZE?"," WRONG SIZE COULD CRASH SYSTEM!","CONTINUE"," STOP!"]
If Z=2 Then Goto JESA
Reserve As Work 12,JHOO
STA=Start(12)
BNE=Len(A$)
If BNE=>31 Then AB$=Mid$(A$,1,31) : AB$=Upper$(AB$) : Else AB$=A$ : AB$=Upper$(AB$)
Locate 40,1 : Print "LOADING:"+AB$
Bload A$,STA
Locate 38,1 : Print Border$(" ",1)
BNE=Len(AB$)
If BNE=>21 Then AB$=Mid$(A$,1,21) : AB$=Upper$(AB$) : Else AB$=A$ : AB$=Upper$(AB$)
Locate 40,1 : Print "DECRUNCHING FILE:"+AB$
Timer=0
Gosub MEM
LU= Extension_5_00E4(STA,LTH4)
Locate 38,1 : Print Border$(" ",1)
Locate 49,7 : Print Timer/50
Locate 40,1 : Print "DONE!"
Gosub MEM
Return
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
' \/SAVING\DECRUNCHED/ROUTINE/
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\
SUACK:
On Error Goto NO_USE2
If Start(12)=<0 Then Return
JENM:
If Z=1 Then Return
Gosub DROOP
A$=Fsel$("","","SAVE DECRUNCHED FILE AS")
If A$="" Then Return
Locate 38,1 : Print Border$(" ",1)
BNE=Len(A$)
If BNE=>32 Then AB$=Mid$(A$,1,32) : AB$=Upper$(AB$) : Else AB$=A$ : AB$=Upper$(AB$)
Locate 40,1 : Print "SAVING:"+AB$
Bsave A$,Start(12) To Start(12)+JHOO
Locate 38,1 : Print Border$(" ",1)
Return
' /\/\/\/\/\
' \/ERROR!\/
' /\/\/\/\/\
NO_USE:
REQ[" YOU MUST FIRST LOAD A FILE!"," YOU CANT SAVE NOTHING!","CONTINUE",""]
Resume JEFSS
'
NO_USE2:
REQ[" YOU MUST FIRST LOAD A FILE!"," YOU CANT SAVE NOTHING!","CONTINUE",""]
Resume JENM
'
JOBS:
Locate 30,7 : Print JEF;
GNA=LTH2-JEF
Locate 63,7 : Print GNA;
TEMP=JEF
DEF=TEMP2
Locate 36,4 : Print EF$(DEF);
Return
'
'
'
DEBRE:
Locate 38,1 : Print Border$(" ",1)
Gosub DROOP
A$=Fsel$("","","CHOOSE A FILE TO LOAD")
If A$="" Then Return
Locate 1,7 : Print Border$("FILE SIZE: ",1)
Locate 21,7 : Print Border$("NEW SIZE: ",1)
Locate 41,7 : Print Border$("SECONDS: ",1)
Locate 57,7 : Print Border$("GAINED: ",1)
Open In 1,A$
LTH=Lof(1)
Locate 11,7 : Print LTH;
Close 1
Gosub DROOP
DA$=Fsel$("","","CHOOSE A NEW FILENAME")
If DA$="" Then Return
_SQUASH_A_PROG[A$,DA$,0]
BNE=Len(A$)
If BNE=>32 Then AB$=Mid$(A$,1,32) : AB$=Upper$(AB$) : Else AB$=A$ : AB$=Upper$(AB$)
Locate 1,41 : Print "CRUNCHED:"+AB$
Return
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
' \/\ROUTINES/FOR/CHANGING\COLOURS\AND\SPEED!/\/
' /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
C0L1:
If CFS=>31 Then Return
Add CFS,1
Locate 13,4 : Print CFS
Return
'
C0L2:
If CFS=<0 Then Return
Add CFS,-1
Locate 13,4 : Print CFS
Return
'
CHEFF:
If DEF=>5 Then Return
Add DEF,1
Locate 36,4 : Print EF$(DEF);
Return
'
CHEFF2:
If DEF=<1 Then Return
Add DEF,-1
Locate 36,4 : Print EF$(DEF);
Return
End Proc
Procedure REQ[T1$,T2$,B1$,B2$]
Shared Z
Screen Open 7,640,60,4,Hires
Screen Display 7,130,133,,
Limit Mouse 215,133 To 350,183
Show
Flash Off
Paper 0 : Cls : Curs Off
Palette $0,$FFF,$0,$FFF
Reserve Zone 2
If Len(T1$)>33 Then T1$=Left$(T1$,33)
If Len(T2$)>33 Then T2$=Left$(T2$,33)
If Len(B1$)>8 Then B1$=Left$(B1$,8)
If Len(B2$)>8 Then B2$=Left$(B2$,8)
Ink 1 : Bar 170,0 To 470,52
Ink 3 : Bar 171,1 To 470,59
Ink 2 : Bar 171,1 To 468,58
Ink 0 : Box 180,10 To 458,30
Ink 3 : Draw 180,30 To 458,30
Ink 3 : Draw 458,30 To 458,10
If Len(B1$)>0
Ink 3 : Box 200,37 To 270,52
Ink 0 : Draw 200,52 To 270,52
Ink 0 : Draw 270,52 To 270,37
End If
If Len(B2$)>0
Ink 3 : Box 360,37 To 430,52
Ink 0 : Draw 360,52 To 430,52
Ink 0 : Draw 430,52 To 430,37
End If
Ink 1,2
Text 184,19,T1$
Text 184,27,T2$
Text 204,47,B1$
Text 364,47,B2$
If Len(B1$)>0 Then Set Zone 1,200,37 To 270,52
If Len(B2$)>0 Then Set Zone 2,360,37 To 430,52
Do
Z=Mouse Zone
If Z=1 and Mouse Key=1 Then Ink 0 : Box 200,37 To 270,52 : Ink 3 : Draw 200,52 To 270,52 : Ink 3 : Draw 270,52 To 270,37 : Wait 10 : Screen Close 7 : Screen 0 : Limit Mouse : Pop Proc
If Z=2 and Mouse Key=1 Then Ink 0 : Box 360,37 To 430,52 : Ink 3 : Draw 360,52 To 430,52 : Ink 3 : Draw 430,52 To 430,37 : Wait 10 : Screen Close 7 : Screen 0 : Limit Mouse : Pop Proc
Loop
End Proc
Procedure P0INTER
'
'pointer grabber!
'
Screen Open 0,640,256,4,Hires
Cls 0 : Flash Off
Ink 2
Draw 1,1 To 16,1
Draw 16,1 To 10,4
Draw 10,4 To 16,10
Draw 16,10 To 10,10
Draw 10,10 To 6,6
Draw 6,6 To 1,7
Draw 1,7 To 1,1
Ink 1
Paint 2,2
Get Bob 0,1,1,1 To 16,11
Change Mouse 4
End
End Proc
'
'From AMOS COMPILER V1.0
' By Francios !
'Slight mod by ejber!
'
Procedure _SQUASH_A_PROG[S$,D$,FIRST]
'
'
Open In 1,S$
Open Out 2,D$
'
HEAD1$=Input$(1,12)
NHUNK=Leek(Varptr(HEAD1$)+8)
HEAD2$=Input$(1,4*(2+NHUNK))
'
Print #2,HEAD1$;
Print #2,HEAD2$;
'
For H=0 To NHUNK-1
FLAG=True : If FIRST<>0 and H=0 and NHUNK>1 : FLAG=0 : End If
Gosub SQHUNK
Exit If BRK
Loke Varptr(HEAD2$)+4*(2+H),HH
Next
'
If BRK=0
Pof(2)=12
Print #2,HEAD2$;
LPROG=Lof(2)
Close
Else
Close
Kill D$
LPROG=0
End If
Goto SQEND
'
SQERROR:
Kill D$
KK: LPROG=-1
Goto SQEND
'
SQHUNK:
H$=Input$(1,8) : Pof(1)=Pof(1)-8
HH=Leek(Varptr(H$)) and $C0000000
LP=Leek(Varptr(H$)+4) : HH=HH or LP : Rol.l 2,LP
Add LP,8+4
F=0
'
'Erase 8
Reserve As Work 8,LP+16
'
OLDPOF=Pof(1)
'
_ONCE_AGAIN:
AP=Start(8) : P=0
Repeat
L=2048 : If P+L>LP : L=LP-P : End If
LA$=Input$(1,L)
Copy Varptr(LA$),Varptr(LA$)+L To AP
Add P,L : Add AP,L
Until P>=LP
'
AP=Start(8)
'
If FLAG<>0 and F=0
If Leek(AP)<>$78566467
'
Gosub MEM
'
CFLASH$="-Z"+Str$(CFS)
Locate 24,4 : Print Border$("EFFICIENT FAST ",1) : DEF=4
L= Extension_5_00CE(AP+8,LP-12,-1,512,CFS)
' L=Squash(AP+8,LP-12,-1,512,17)
If L=-1
Pof(1)=OLDPOF : F=-1 : Goto _ONCE_AGAIN
End If
If L=-2 : BRK=-1 : Goto _ABORT : End If
'
LH=(L+3) and $FFFFFFFC
Copy AP+8,AP+8+LH To AP+8+12
Loke AP+8,$78566467 : Loke AP+12,LP : Loke AP+16,L
Add LH,12 : Loke AP+4,LH/4
HH=(HH and $C0000000) or(LH/4)
Loke AP+8+LH,$3F2
LP=8+LH+4
End If
End If
'
LA$=Space$(2048) : P=0
Repeat
L=2048 : If P+L>LP : L=LP-P : End If
Copy AP,AP+L To Varptr(LA$)
Print #2,Left$(LA$,L);
Add P,L : Add AP,L
Until P>=LP
'
_ABORT:
Locate 41,1 : Print "CRUNCHING ABORTED!"
Erase 8
Return
'
'
MEM:
Locate 47,10 : Print Chip Free;
Locate 60,10 : Print Free+Fast Free;
Locate 72,10 : Print Free+Fast Free+Chip Free;
Return
SQEND:
End Proc[LPROG]