home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 337.lha / SlowDown / SlowDown.Mod < prev    next >
Text File  |  1990-01-24  |  5KB  |  159 lines

  1. MODULE SlowDown;
  2.  
  3. (*======================================================================*)
  4. (*                             Slow Down!                               *)
  5. (*======================================================================*)
  6. (*         © Copyright 1989 Robert Salesas, All Rights Reserved         *)
  7. (*        Re-Distribute as you wish but DO NOT alter the contents       *)
  8. (*            of this file.  Moral Rights remain my property.           *)
  9. (*======================================================================*)
  10. (*      Version: 1.00           Author : Robert Salesas                 *)
  11. (*      Date   : 24-Dec-89      Changes: Original                       *)
  12. (*======================================================================*)
  13.  
  14. (*
  15.     This program was written to slow down the Amiga.
  16.     The original purpose of this program was to permit
  17.     mentally handicapped users to play games that multi-task
  18.     properly.
  19.  
  20.     If you use the -N (No Window) flag, a CTRL-C will stop the program once
  21.     it has been started.
  22.     You can use the break command to send it a CTRL-C.
  23. *)
  24.  
  25. FROM SYSTEM           IMPORT  ADR, STRPTR;
  26. FROM RunTime          IMPORT  WBMsg, CurrentProcess;
  27. FROM CmdLineUtils     IMPORT  argc, argv;
  28. FROM Conversions      IMPORT  ConvStrToNum;
  29. FROM Tasks            IMPORT  SetTaskPri;
  30. FROM DOSProcess       IMPORT  Delay;
  31. FROM Ports            IMPORT  GetMsg, ReplyMsg;
  32. FROM Intuition        IMPORT  WindowPtr, ScreenPtr, GadgetPtr,
  33.                               IDCMPFlags, IDCMPFlagSet, IntuiMessagePtr,
  34.                               CloseWindow;
  35. FROM ReqWinUtils      IMPORT  StartReqWinGList, StartReqWin,
  36.                               AddBoolText, IntCombo,
  37.                               AddIntCombo, HandleIntCombo;
  38. FROM EasyGadgets      IMPORT  listFailed, DisposeList, currentList;
  39. FROM FindWB           IMPORT  FirstWBScreen;
  40. FROM Pens             IMPORT  Move;
  41. FROM Text             IMPORT  Text;
  42. FROM Puts             IMPORT  PutString;
  43. FROM TrapCtrlC        IMPORT  On;
  44.  
  45. VAR
  46.   Wp          :  WindowPtr;
  47.   Sp          :  ScreenPtr;
  48.   Gad,
  49.   GList       :  GadgetPtr;
  50.   GadID       :  CARDINAL;
  51.   Msg         :  IntuiMessagePtr;
  52.   PrioCombo   :  IntCombo;
  53.   SlowCombo   :  IntCombo;
  54.   Temp        :  LONGINT;
  55.   Prio,
  56.   Slow,
  57.   OldPri      :  INTEGER;
  58.   Par1,
  59.   Par2, Par3  :  STRPTR;
  60.  
  61.  
  62.   PROCEDURE BusyWait(DelayCount : CARDINAL);
  63.   VAR
  64.     L1,
  65.     Counter  :  CARDINAL;
  66.   BEGIN
  67.     INC(DelayCount);
  68.     Counter := 0;
  69.     REPEAT
  70.       FOR L1 := 0 TO 2000 DO
  71.       END;
  72.       INC(Counter);
  73.     UNTIL (Counter = DelayCount);
  74.   END BusyWait;
  75.  
  76. BEGIN
  77.   Prio := 0;  Slow := 0;
  78.   IF (WBMsg = NIL) THEN
  79.     IF (argc = 1) OR (argc > 4) THEN
  80.       PutString("Slow Down! - © Copyright 1989 Robert Salesas");
  81.       PutString("");
  82.       PutString("USAGE:  SlowDown  PRIORITY  SPEED    -N");
  83.       PutString("                  (-9..20)  (0..99)  (No Window)");
  84.       RETURN
  85.     ELSE
  86.       Par1 := argv[1];  Par2 := argv[2];  Par3 := argv[3];
  87.       IF ConvStrToNum(Par1^, Temp, 10, TRUE) THEN
  88.         IF (Temp >= -9) AND (Temp <= 20) THEN
  89.           Prio := INTEGER(Temp);
  90.         END;
  91.       END;
  92.       IF (argc > 2) AND ConvStrToNum(Par2^, Temp, 10, TRUE) THEN
  93.         IF (Temp >= 0) AND (Temp <= 99) THEN
  94.           Slow := INTEGER(Temp);
  95.         END;
  96.       END;
  97.       IF (argc = 4) AND ((Par3^[0] = "-") AND (Par3^[1] = "N")) THEN
  98.         On;
  99.         LOOP
  100.           BusyWait(Slow);
  101.           Delay(2);
  102.         END;
  103.       END;
  104.     END;
  105.   END;
  106.   
  107.   OldPri := SetTaskPri(CurrentProcess, Prio);
  108.   
  109.   StartReqWinGList;
  110.   WITH PrioCombo DO
  111.     MaxDigs := 2;
  112.     Value := Prio;
  113.     MinVal := -9;
  114.     MaxVal := 20;
  115.   END;
  116.   AddIntCombo(20, 16, 160, "Task Priority", ADR(PrioCombo));
  117.   WITH SlowCombo DO
  118.     MaxDigs := 2;
  119.     Value := Slow;
  120.     MinVal := 0;
  121.     MaxVal := 99;
  122.   END;
  123.   AddIntCombo(20, 28, 160, "Slow Down Delay", ADR(SlowCombo));
  124.   AddBoolText(86, 42, 60, "Quit");
  125.   IF NOT listFailed THEN
  126.     GList := currentList;
  127.     Sp := FirstWBScreen();
  128.     IF (Sp # NIL) THEN
  129.       Wp := StartReqWin(Sp, 230, 74, "Slow Down!", IDCMPFlagSet{MouseButtons, GadgetUp, GadgetDown}, GList);
  130.       IF (Wp # NIL) THEN
  131.         Move(Wp^.RPort, 32, 68);  Text(Wp^.RPort, ADR("© 1989 Robert Salesas"), 21);
  132.         LOOP
  133.           Msg := GetMsg(Wp^.UserPort);
  134.           IF (Msg # NIL) THEN
  135.             IF NOT (MouseButtons IN Msg^.Class) THEN
  136.               Gad:= Msg^.IAddress;  GadID := Gad^.GadgetID;
  137.               ReplyMsg(Msg);
  138.               IF (GadID = 0) THEN
  139.                 HandleIntCombo(Wp, Gad);
  140.                 OldPri := SetTaskPri(CurrentProcess, PrioCombo.Value);
  141.               ELSIF (GadID = 1) THEN
  142.                 HandleIntCombo(Wp, Gad);
  143.               ELSIF (GadID = 2) THEN
  144.                 EXIT;
  145.               END;
  146.             ELSE
  147.               ReplyMsg(Msg);
  148.             END;
  149.           ELSE
  150.             BusyWait(SlowCombo.Value);
  151.             Delay(2);
  152.           END;
  153.         END;
  154.         CloseWindow(Wp);
  155.       END;
  156.     END;
  157.     DisposeList(GList);
  158.   END;
  159. END SlowDown.