home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / www / f1 / archives / tpc.lha / TPCruncher.AMOS / TPCruncher.amosSourceCode
AMOS Source Code  |  1992-09-02  |  8KB  |  265 lines

  1. Rem TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  2. Rem T          TECHNOPHOBIA           T
  3. Rem T            CRUNCHER             T
  4. Rem T              MADE               T  
  5. Rem T               BY                T
  6. Rem T   JOHN DILLON AND STEPHEN ORR   T  
  7. Rem TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  8.  
  9. Screen Open 0,640,256,8,Hires
  10. Flash Off : Curs Off : Cls 1 : Paper 1 : Ink 1,1
  11. Palette $0,$6F,$77,$EEE,$F00,$DD,$AA,$FF3
  12. Limit Mouse 128,42 To 639+128,255+42
  13.  
  14. Gr Writing 0
  15. Get Rom Fonts 
  16.  
  17. HLIGHT=3
  18. MID=6
  19. SHADE=2
  20. SHINE=5
  21. OLINE=0
  22. Global HLIGHT,MID,SHADE,SHINE,OLINE
  23.  
  24. BUTTONS=5
  25. _TEXT$=""
  26. Dim BUT(BUTTONS,4)
  27. Dim BUT$(BUTTONS)
  28. Global BUT(),BUT$(),_TEXT$
  29.  
  30. Reserve Zone BUTTONS
  31.  
  32. _MAIN
  33. End 
  34.  
  35. Procedure _MAIN
  36.    _BOX[16,8,624,248]
  37.    _BOX[32,16,608,40]
  38.    _BUTTON[32,216,608,240,"EXIT PROGRAM",1]
  39.    _BOX[32,48,608,208]
  40.    _BUTTON[48,152,592,176,"CRUNCH",2]
  41.    _BUTTON[48,176,592,200,"DECRUNCH",3]
  42.    _DRAWTEXT[0,30,640,"TECHNOPHOBIA CRUNCHER ACCESSORY",1,1,"C"]
  43.    _DRAWTEXT[0,64,640,"This cruncher is basically an interface to",1,1,"C"]
  44.    _DRAWTEXT[0,72,640,"the DMS program. It was created by John",1,1,"C"]
  45.    _DRAWTEXT[0,80,640,"Dillon and Stephen Orr.",1,1,"C"]
  46.    _DRAWTEXT[0,96,640,"Click on CRUNCH to crunch a disk, or",1,1,"C"]
  47.    _DRAWTEXT[0,104,640,"DECRUNCH to decrunch one. Simple really!",1,1,"C"]
  48.    Do 
  49.       If Mouse Key=1 and Mouse Zone>0
  50.          _BUTTONCLICK[Mouse Zone]
  51.          If Mouse Zone=1
  52.             Fade 4
  53.             Wait 50
  54.             Screen Close 0
  55.             End 
  56.          End If 
  57.          If Mouse Zone=2
  58.             _CRUNCH
  59.          End If 
  60.          If Mouse Zone=3
  61.             _DECRUNCH
  62.          End If 
  63.       End If 
  64.    Loop 
  65. End Proc
  66. Procedure _DECRUNCH
  67.    _BOX[32,48,608,208]
  68.    _BUTTON[32,216,608,240,"EXIT DECRUNCH SCREEN",1]
  69.    _BOX[32,16,608,40]
  70.    _DRAWTEXT[0,30,640,"TECHNOPHOBIA CRUNCH ACCESSORY - DECRUNCH SCREEN",1,1,"C"]
  71.    _BUTTON[48,176,592,200,"SELECT FILE",2]
  72.    _DRAWTEXT[0,64,640,"When you click on SELECT FILE below, a file",1,1,"C"]
  73.    _DRAWTEXT[0,72,640,"requester will appear. Select the DMS file you",1,1,"C"]
  74.    _DRAWTEXT[0,80,640,"wish to decrunch, then just follow the prompts",1,1,"C"]
  75.    _DRAWTEXT[0,88,640,"that will appear once the information has been",1,1,"C"]
  76.    _DRAWTEXT[0,96,640,"copied to the RAM disk.",1,1,"C"]
  77.    Do 
  78.       MZ=Mouse Zone
  79.       If Mouse Key=1
  80.          If MZ>0
  81.             _BUTTONCLICK[MZ]
  82.             If MZ=1
  83.                _MAIN
  84.             End If 
  85.             If MZ=2
  86.                F$=Fsel$("*.DMS","","Please select a DMS file","or click on Cancel to exit")
  87.                Exec "NewShell"
  88.                Exec "Copy SYS:C/Copy RAM:"
  89.                Exec "Copy SYS:C/DMS RAM:"
  90.                Exec "Copy "+F$+" RAM:DMSFile.DMS"
  91.                _DRAWTEXT[0,112,640,"Please put a blank disk into DF0: (the internal drive)",1,1,"C"]
  92.                _DRAWTEXT[0,120,640,"and click on DECRUNCH FILE below.",1,1,"C"]
  93.                _BUTTON[48,176,592,200,"DECRUNCH FILE",2]
  94.                Do 
  95.                   MZ=Mouse Zone
  96.                   If Mouse Key=1
  97.                      If MZ=1
  98.                         _MAIN
  99.                      End If 
  100.                      If MZ=2
  101.                         _BUTTONCLICK[MZ]
  102.                         _DRAWTEXT[0,136,640,"Decrunching... please wait, this may take some time.",1,1,"C"]
  103.                         Exec "RAM:DMS Write RAM:DMSFile.DMS to DF0:"
  104.                         Exec "EndCLI"
  105.                         Kill "RAM:DMSFile.DMS"
  106.                         Kill "RAM:DMS"
  107.                         Kill "RAM:Copy"
  108.                         _DRAWTEXT[0,152,640,"Decrunching Completed.",1,1,"C"]
  109.                         _DRAWTEXT[0,160,640,"Now returning to main menu.",1,1,"C"]
  110.                         _MAIN
  111.                      End If 
  112.                   End If 
  113.                Loop 
  114.             End If 
  115.          End If 
  116.       End If 
  117.    Loop 
  118. End Proc
  119. Procedure _CRUNCH
  120.    _BOX[32,48,608,208]
  121.    _BUTTON[32,216,608,240,"EXIT CRUNCH SCREEN",1]
  122.    _BOX[32,16,608,40]
  123.    _DRAWTEXT[0,30,640,"TECHNOPHOBIA CRUNCH ACCESSORY - CRUNCH SCREEN",1,1,"C"]
  124.    _BUTTON[48,176,592,200,"BEGIN CRUNCHING",2]
  125.    _DRAWTEXT[0,64,640,"Please put the disk that you want to crunch into DF0:,",1,1,"C"]
  126.    _DRAWTEXT[0,72,640,"then click on the BEGIN CRUNCHING button below this",1,1,"C"]
  127.    _DRAWTEXT[0,80,640,"text.",1,1,"C"]
  128.    Do 
  129.       MZ=Mouse Zone
  130.       If Mouse Key=1
  131.          If MZ>0
  132.             _BUTTONCLICK[MZ]
  133.             If MZ=1
  134.                _MAIN
  135.             End If 
  136.             If MZ=2
  137.                Exec "NewShell"
  138.                Exec "Copy SYS:C/Copy RAM:"
  139.                Exec "Copy SYS:C/DMS RAM:"
  140.                _DRAWTEXT[0,96,640,"Crunching started. Please wait... this'll take a while!",1,1,"C"]
  141.                Exec "RAM:DMS READ RAM:DMSFile.DMS FROM DF0:"
  142.                _DRAWTEXT[0,112,640,"Crunching completed. Now it's time to select a location",1,1,"C"]
  143.                _DRAWTEXT[0,120,640,"for your crunched file.",1,1,"C"]
  144.                F$=Fsel$("","","Please select a location for your DMS file","to be copied to")
  145.                Exec "RAM:Copy RAM:DMSFile.DMS "+F$
  146.                Exec "EndCLI"
  147.                Kill "RAM:DMS"
  148.                Kill "RAM:Copy"
  149.                Kill "RAM:DMSFile.DMS"
  150.                _DRAWTEXT[0,136,640,"All done, returning to main menu.",1,1,"C"]
  151.                _MAIN
  152.             End If 
  153.          End If 
  154.       End If 
  155.    Loop 
  156. End Proc
  157. Procedure _BUTTON[X1,Y1,X2,Y2,_TEXT$,_ZONE]
  158.  
  159.    Rem *** Draw The Button
  160.    Ink OLINE
  161.    Bar X1,Y1 To X2,Y2
  162.  
  163.    Ink MID
  164.    Bar X1+2,Y1+1 To X2-2,Y2-1
  165.  
  166.    Ink SHADE
  167.    Polyline X1+2,Y2-1 To X2-2,Y2-1 To X2-2,Y1+1
  168.    Draw X2-3,Y1+1 To X2-3,Y2-1
  169.  
  170.    Ink SHINE
  171.    Polyline X2-3,Y1+1 To X1+2,Y1+1 To X1+2,Y2-1
  172.    Draw X1+3,Y1+1 To X1+3,Y2-2
  173.  
  174.    Ink HLIGHT
  175.    Draw X1+4,Y1+2 To X1+5,Y1+2
  176.  
  177.    Rem *** Work Out Position Of Text And Draw It
  178.    Y=Y1+((Y2-Y1)/2)+3
  179.    _DRAWTEXT[X1,Y,X2-X1,_TEXT$,1,HLIGHT,"C"]
  180.  
  181.    Rem *** Set The Zone And Put Values Into Array For Later Use 
  182.    Set Zone _ZONE,X1,Y1 To X2,Y2
  183.    BUT(_ZONE,1)=X1
  184.    BUT(_ZONE,2)=Y1
  185.    BUT(_ZONE,3)=X2
  186.    BUT(_ZONE,4)=Y2
  187.    BUT$(_ZONE)=_TEXT$
  188.  
  189. End Proc
  190. Procedure _BUTTONCLICK[MZ]
  191.  
  192.    Rem *** Set Up Information For Button Drawing
  193.    X1=BUT(MZ,1) : Y1=BUT(MZ,2)
  194.    X2=BUT(MZ,3) : Y2=BUT(MZ,4)
  195.    _TEXT$=BUT$(MZ)
  196.  
  197.    Rem *** Actually Draw The Button 
  198.    Ink SHADE
  199.    Bar X1+2,Y1+1 To X2-2,Y2-1
  200.  
  201.    Ink MID
  202.    Polyline X1+2,Y2-1 To X2-2,Y2-1 To X2-2,Y1+1
  203.    Draw X2-3,Y1+1 To X2-3,Y2-1
  204.  
  205.    Ink OLINE
  206.    Polyline X2-3,Y1+1 To X1+2,Y1+1 To X1+2,Y2-1
  207.    Draw X1+3,Y1+1 To X1+3,Y2-2
  208.  
  209.    Rem *** Work Out The Position Of The Text And Draw It
  210.    Y=Y1+((Y2-Y1)/2)+4
  211.    _DRAWTEXT[X1,Y,X2-X1,_TEXT$,1,HLIGHT,"C"]
  212.  
  213.    Rem *** Short Delay Before Redrawing 
  214.    Repeat : Until Mouse Key=0
  215.  
  216.    Rem *** Redraw Button In Normal Mode 
  217.    Ink OLINE
  218.    Bar X1,Y1 To X2,Y2
  219.  
  220.    Ink MID
  221.    Bar X1+2,Y1+1 To X2-2,Y2-1
  222.  
  223.    Ink SHADE
  224.    Polyline X1+2,Y2-1 To X2-2,Y2-1 To X2-2,Y1+1
  225.    Draw X2-3,Y1+1 To X2-3,Y2-1
  226.  
  227.    Ink SHINE
  228.    Polyline X2-3,Y1+1 To X1+2,Y1+1 To X1+2,Y2-1
  229.    Draw X1+3,Y1+1 To X1+3,Y2-2
  230.  
  231.    Ink HLIGHT
  232.    Draw X1+4,Y1+2 To X1+5,Y1+2
  233.  
  234.    Rem *** Draw The Text In It's Original Position
  235.    _DRAWTEXT[X1,Y-1,X2-X1,_TEXT$,1,HLIGHT,"C"]
  236.  
  237. End Proc
  238. Procedure _BOX[X1,Y1,X2,Y2]
  239.    Ink OLINE : Bar X1,Y1 To X2,Y2
  240.    Ink MID : Bar X1+2,Y1+1 To X2-2,Y2-1
  241.    Ink SHADE
  242.    Polyline X1+2,Y2-1 To X2-2,Y2-1 To X2-2,Y1+1
  243.    Draw X2-3,Y1+1 To X2-3,Y2-1
  244.    Ink SHINE
  245.    Polyline X2-3,Y1+1 To X1+2,Y1+1 To X1+2,Y2-1
  246.    Draw X1+3,Y1+1 To X1+3,Y2-2
  247.    Ink HLIGHT
  248.    Draw X1+4,Y1+2 To X1+5,Y1+2
  249. End Proc
  250. Procedure _DRAWTEXT[X,Y,WIDTH,_TEXT$,FONT,CLR,TYPE$]
  251.    Gr Writing 0
  252.    Ink 3
  253.    Set Font FONT
  254.    CENTRD=(X+(WIDTH/2))-(Text Length(_TEXT$))/2
  255.    RIGHT=(X+WIDTH)-Text Length(_TEXT$)
  256.    If Upper$(TYPE$)="C"
  257.       Text CENTRD,Y,_TEXT$
  258.    End If 
  259.    If Upper$(TYPE$)="L"
  260.       Text X,Y,_TEXT$
  261.    End If 
  262.    If Upper$(TYPE$)="R"
  263.       Text RIGHT,Y,_TEXT$
  264.    End If 
  265. End Proc