home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff285.lzh / MSizer / MSizer.c < prev    next >
C/C++ Source or Header  |  1989-11-28  |  16KB  |  691 lines

  1. /*
  2.     Keeping to tradition, the Khaled Mardam-Bey philosophy, this program
  3.     is completely undocumented so as to give you prime experience in
  4.     learning how to debug source code.
  5.  
  6.       The program also contains many redundant bits and pieces so as to
  7.     make your learning experience that much more profoundly educational
  8.     and exceptional.
  9.  
  10.     This is how NOT to write a program.
  11.  
  12.     Got it ? Okay, great, now YOU can start teaching others by coding in
  13.     exactly the same way.
  14.  
  15.     There's something very deep in that last sentence, can't quite
  16.     pinpoint it though, hmmm...
  17.  
  18.     compile with  cc Msizer.c
  19.                   ln Msizer.o -lc
  20.  
  21.     Warning - It won't bite unless you try to compile it.
  22.               Linking is okay though... <grin>
  23.  
  24.    This source is totally PD.
  25.  
  26.    written by Khaled Mardam-Bey, 14th October 1989.
  27. */
  28.  
  29. #include <exec/lists.h>
  30. #include <exec/interrupts.h>
  31. #include <exec/ports.h>
  32. #include <exec/libraries.h>
  33. #include <exec/io.h>
  34. #include <exec/execbase.h>
  35. #include <exec/types.h>
  36. #include <exec/devices.h>
  37. #include <exec/memory.h>
  38. #include <exec/exec.h>
  39. #include <exec/ports.h>
  40. #include <exec/tasks.h>
  41. #include <libraries/dos.h>
  42. #include <libraries/dosextens.h>
  43. #include <devices/timer.h>
  44. #include <devices/trackdisk.h>
  45. #include <devices/input.h>
  46. #include <devices/inputevent.h>
  47. #include <intuition/intuition.h>
  48. #include <intuition/intuitionbase.h>
  49. #include <ctype.h>
  50. #include <stdio.h>
  51. #include <functions.h>
  52. #include <graphics/gfxbase.h>
  53.  
  54.   /* Key Definitions */
  55. #define QKEY         0x45
  56. #define CONTROL      0x63
  57. #define THRESHX      16
  58. #define THRESHY      8
  59. #define MINX         40
  60. #define MINY         24
  61.  
  62.   /* input events */
  63. #define QUIT         0x1
  64. #define FINISHUP     0x2
  65. #define MOVEIT       0x4
  66. #define DOWINDOW     0x8
  67.  
  68. #define DELAY    1000000L
  69.  
  70. char PortName[] = "PePeTe";
  71. char WrittenBy[] = "Khaled Mardam-Bey 1989";
  72.  
  73. SHORT i,j,k,l;
  74. SHORT nomore = 0, NoGo = 0;
  75. SHORT corner = 0;
  76. SHORT dx,dy,ff,xx,yy,oo;
  77. SHORT DoIT = 0, there = 0;
  78. SHORT LastX,LastY;
  79. SHORT x,y,ox,oy,fx,fy;
  80. SHORT event;
  81. SHORT lastcode = 0;
  82. long  sec = 0,micro = 0;
  83. SHORT rbuttonisdown = 0, lbuttonisdown = 0;
  84. SHORT ww, wh, te, le, sw, sh;
  85.  
  86. struct Library *OpenLibrary();
  87. struct ViewPort *ViewPortAddress();
  88.  
  89. struct MsgPort       *inputPort = NULL;
  90. struct IOStdReq      *inputReq = NULL;
  91. struct MsgPort       *TimerPort = NULL;
  92. struct Screen        *s, *Screen = NULL;
  93. struct IntuitionBase *IntuitionBase = NULL;
  94. struct GfxBase       *GfxBase = NULL;
  95. struct Window        *window;
  96. struct RastPort      *rp;
  97. struct Layer_Info    *li;
  98. struct LayersBase    *LayersBase = NULL;
  99.  
  100. void move(x,y) SHORT x,y; { Move(rp, (long) x, (long) y); }
  101. void draw(x,y) SHORT x,y; { Draw(rp, (long) x, (long) y); }
  102. void plot(x,y) SHORT x,y; { WritePixel(rp, (long) x, (long) y); }
  103.  
  104. struct timerequest Timer_Req;
  105. long   TimerSig,tdevice = 1;
  106.  
  107. struct InputEvent phoney;
  108. struct HotInfo
  109.   {
  110.   struct Task *hotTask;
  111.   long  hotSig;
  112.   } hotStuff;
  113.  
  114. long signum = -1;
  115.  
  116. struct Interrupt handlerStuff;
  117. struct defPort
  118. {
  119.   struct MsgPort mp;
  120. };
  121.  
  122. struct defPort *defPortPtr;
  123. char defPortName[] = "WiNnYpO";
  124. SHORT updating = 0;
  125.  
  126. void HandlerInterface()
  127. {
  128. #asm
  129.   movem.l a4,-(sp)
  130.   jsr _geta4#
  131.   movem.l   A0/A1,-(sp)
  132.   jsr       _myhandler
  133.   addq.l    #8,A7
  134.   movem.l (sp)+,a4
  135. #endasm
  136. }
  137.  
  138. struct InputEvent *myhandler(ev1, hotStuff)
  139. struct InputEvent *ev1;
  140. struct HotInfo *hotStuff;
  141. {
  142.   struct InputEvent *ev, *last;
  143.   SHORT removeit;
  144.   SHORT evcode,evqual;
  145.  
  146.   event = 0;
  147.   for (ev=ev1,last = NULL; ev; ev=ev->ie_NextEvent)
  148.   {
  149.     evcode = ev->ie_Code;
  150.     evqual = ev->ie_Qualifier;
  151.     removeit = 0;
  152.  
  153.     if ((ev->ie_Class != IECLASS_TIMER))
  154.     {
  155.       if (ev->ie_Class == IECLASS_RAWKEY)
  156.       {
  157.         if ((evcode >= 0x80) && (evcode == (lastcode | 0x80))) {
  158.           DoIT = 0;
  159.           event |= FINISHUP;
  160.           removeit = 1;
  161.           lastcode = 0; }
  162.         else {
  163.           lastcode = 0;
  164.           removeit = 0;
  165.         }
  166.  
  167.        if (evcode == CONTROL)
  168.        {
  169.          lastcode = evcode;
  170.          removeit = 1;
  171.          DoIT = 1;
  172.        }
  173.        else
  174.        if (evcode == QKEY) {
  175.          if (DoIT) DoIT = 2;
  176.          lastcode = evcode;
  177.          removeit = 1;
  178.        }
  179.        else DoIT = 0;
  180.       }
  181.     }
  182.  
  183.     if (ev->ie_Class == IECLASS_RAWMOUSE)
  184.     {
  185.       if (evcode == (IECODE_LBUTTON | 0x80)) {
  186.         lbuttonisdown = 0;
  187.         if (DoIT) event |= DOWINDOW;
  188.         else event |= FINISHUP;
  189.       }
  190.       else {
  191.         if (evcode == IECODE_LBUTTON) {
  192.           if (DoIT == 2) event |= QUIT;
  193.           if ((lbuttonisdown == 0) && (DoIT == 1)) removeit = 1;
  194.           lbuttonisdown = 1;
  195.         }
  196.  
  197.         if ((lbuttonisdown) && (DoIT)) {
  198.           event |= MOVEIT;
  199.         }
  200.       }
  201.     }
  202.  
  203.     if (removeit)
  204.       if (last == NULL)
  205.         ev1 = ev->ie_NextEvent;
  206.       else
  207.         last->ie_NextEvent = ev->ie_NextEvent;
  208.     else
  209.       last = ev;
  210.   }
  211.  
  212.   if (event)
  213.     Signal(hotStuff->hotTask,hotStuff->hotSig);
  214.   return(ev1);
  215. }
  216.  
  217. main()
  218. {
  219.   struct IntuiMessage *Msg;
  220.   long                class;
  221.  
  222.   IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0L);
  223.   if (!IntuitionBase) exit(0L);
  224.  
  225.   GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L);
  226.   if (!GfxBase) exit(0L);
  227.  
  228.   LayersBase = (struct LayersBase *) OpenLibrary("layers.library",0L);
  229.   if (!LayersBase) exit(0L);
  230.  
  231.   defPortPtr = (struct defPort *) FindPort(defPortName);
  232.   if (defPortPtr == NULL)
  233.   {
  234.     if ((defPortPtr = (struct defPort *) AllocMem((long)sizeof(struct defPort),MEMF_PUBLIC | MEMF_CLEAR)) == NULL)
  235.       exit(10);
  236.   }
  237.   else
  238.     updating = 1;
  239.  
  240.   if (updating)
  241.     Uninstall();
  242.  
  243.   defPortPtr->mp.mp_Node.ln_Pri = 0;
  244.   defPortPtr->mp.mp_Node.ln_Type = NT_MSGPORT;
  245.   NewList(&(defPortPtr->mp.mp_MsgList));
  246.   defPortPtr->mp.mp_Node.ln_Name = (char *) &(defPortName);
  247.  
  248.   AddPort(defPortPtr);
  249.  
  250.   if((signum = AllocSignal((long)-1)) == -1)
  251.     Uninstall();
  252.  
  253.   hotStuff.hotSig = 1 << signum;
  254.   hotStuff.hotTask = FindTask(NULL);
  255.  
  256.   if(!(inputPort = CreatePort(PortName,0)))
  257.     Uninstall();
  258.   if(!(inputReq = CreateStdIO(inputPort)))
  259.     Uninstall();
  260.  
  261.   handlerStuff.is_Data = (APTR)&hotStuff;
  262.   handlerStuff.is_Code = HandlerInterface;
  263.   handlerStuff.is_Node.ln_Pri = 55;
  264.   handlerStuff.is_Node.ln_Name = "PoOpHaNy";
  265.  
  266.   if(OpenDevice("input.device",0L,inputReq,0L) != 0)
  267.     Uninstall();
  268.  
  269.   inputReq->io_Command = IND_ADDHANDLER;
  270.   inputReq->io_Data = (APTR)&handlerStuff;
  271.  
  272.   DoIO(inputReq);
  273.  
  274.   if ((TimerPort = CreatePort("TimPodle", 0L)) == NULL)
  275.     Uninstall();
  276.  
  277.   if ((tdevice = OpenDevice(TIMERNAME, UNIT_VBLANK, &Timer_Req, 0L)) != 0)
  278.     Uninstall();
  279.   Timer_Req.tr_node.io_Message.mn_ReplyPort = TimerPort;
  280.   Timer_Req.tr_node.io_Command = TR_ADDREQUEST;
  281.   Timer_Req.tr_node.io_Flags = 0;
  282.   Timer_Req.tr_node.io_Error = 0;
  283.  
  284.   TimerSig = (1L << TimerPort->mp_SigBit);
  285.  
  286.   QueTimer();
  287.  
  288.   (void)SetTaskPri(FindTask(NULL), 20L);
  289.  
  290.   for (;;)
  291.   {
  292.     Wait(hotStuff.hotSig | TimerSig);
  293.  
  294.     if (Msg = (struct IntuiMessage *)GetMsg(TimerPort))
  295.       if (Msg) QueTimer();
  296.  
  297.     if (breakcheck()) Uninstall();
  298.     breakreset();
  299.  
  300.     if (event & QUIT) Uninstall();
  301.  
  302.     if (event & FINISHUP) {
  303.       FiniUpi();
  304.       corner = 0;
  305.       nomore = 0;
  306.     }
  307.  
  308.     if (event & DOWINDOW) MoveThatWindow();
  309.  
  310.     if (event & MOVEIT) {
  311.       if (nomore == 0) CheckPP();
  312.       else if (corner != 0) ElBorders();
  313.     }
  314.   event = 0;
  315.   }
  316. }
  317.  
  318. FiniUpi()
  319. {
  320.   if (there) {
  321.     xx = LastX + dx; yy = LastY + dy;
  322.     DoEm();
  323.     UnlockLayers(li);
  324.     there = 0;
  325.   }
  326. }
  327.  
  328. QueTimer()
  329. {
  330.   Timer_Req.tr_time.tv_secs = 0;
  331.   Timer_Req.tr_time.tv_micro = DELAY;
  332.   SendIO(&Timer_Req.tr_node);
  333. }
  334.  
  335. ElBorders()
  336. {
  337.   if ((LastX != s->MouseX) || (LastY != s->MouseY)) {
  338.     xx = LastX + dx;
  339.     yy = LastY + dy;
  340.     DoEm();
  341.     xx = s->MouseX + dx;
  342.     yy = s->MouseY + dy;
  343.     DoEm();
  344.   }
  345.  
  346.   there = 1;
  347.   LastX = s->MouseX;
  348.   LastY = s->MouseY;
  349. }
  350.  
  351. DoEm()
  352. {
  353.   if (corner == 1) do1();
  354.   else if (corner == 2) do2();
  355.   else if (corner == 3) do3();
  356.   else if (corner == 4) do4();
  357. }
  358.  
  359. do1()
  360. {
  361.   while (xx < 0) xx = xx + 1;
  362.   while (yy < 0) yy = yy + 1;
  363.  
  364.   while ((le+ww) > s->Width) ww = ww -1;
  365.   while ((te+wh) > s->Height) wh = wh - 1;
  366.  
  367.   if (xx > (le+ww-MINX)) xx = (le+ww-MINX);
  368.   if (yy > (te+wh-MINY)) yy = (te+wh-MINY);
  369.  
  370.   move( (SHORT) xx, (SHORT) yy);
  371.   draw( (SHORT) (le+ww-1), (SHORT) yy);
  372.   draw( (SHORT) (le+ww-1), (SHORT) (te+wh-1));
  373.   draw( (SHORT) xx, (SHORT) (te+wh-1));
  374.   draw( (SHORT) xx, (SHORT) yy);
  375. }
  376.  
  377. do2()
  378. {
  379.   while (xx > s->Width) xx = xx - 1;
  380.   while (xx < 0) xx = xx + 1;
  381.   while (yy < 0) yy = yy + 1;
  382.   while (yy > s->Height) yy = yy - 1;
  383.  
  384.   while ((te+wh) > s->Height) wh = wh - 1;
  385.  
  386.   if (xx < (le+MINX)) xx = le+MINX;
  387.   if (yy > (te+wh-MINY)) yy = (te+wh-MINY);
  388.  
  389.   move( (SHORT) xx-1, (SHORT) yy);
  390.   draw( (SHORT) le, (SHORT) yy);
  391.   draw( (SHORT) le, (SHORT) (te+wh-1));
  392.   draw( (SHORT) xx-1, (SHORT) (te+wh-1));
  393.   draw( (SHORT) xx-1, (SHORT) yy);
  394. }
  395.  
  396. do3()
  397. {
  398.   while (xx < 0) xx = xx + 1;
  399.   while (xx > s->Width) xx = xx - 1;
  400.   while (yy < 0) yy = yy + 1;
  401.   while (yy > s->Height) yy = yy - 1;
  402.  
  403.   while ((le+ww) > s->Width) ww = ww -1;
  404.  
  405.   if (xx > (le+ww-MINX)) xx = (le+ww-MINX);
  406.   if (yy < (te+MINY)) yy = (te+MINY);
  407.  
  408.   move( (SHORT) xx, (SHORT) yy-1);
  409.   draw( (SHORT) (le+ww-1), (SHORT) yy-1);
  410.   draw( (SHORT) (le+ww-1), (SHORT) te);
  411.   draw( (SHORT) xx, (SHORT) te);
  412.   draw( (SHORT) xx, (SHORT) yy-1);
  413. }
  414.  
  415. do4()
  416. {
  417.   while (xx < 0) xx = xx + 1;
  418.   while (xx > s->Width) xx = xx - 1;
  419.   while (yy < 0) yy = yy + 1;
  420.   while (yy > s->Height) yy = yy - 1;
  421.  
  422.   if (xx < (le+MINX)) xx = (le+MINX);
  423.   if (yy < (te+MINY)) yy = (te+MINY);
  424.  
  425.   move( (SHORT) xx-1, (SHORT) yy-1);
  426.   draw( (SHORT) xx-1, (SHORT) te);
  427.   draw( (SHORT) le, (SHORT) te);
  428.   draw( (SHORT) le, (SHORT) yy-1);
  429.   draw( (SHORT) xx-1, (SHORT) yy-1);
  430. }
  431.  
  432. CheckPP()
  433. {
  434.   window = IntuitionBase->ActiveWindow;
  435.  
  436.   if (window != NULL) {
  437.     le = window->LeftEdge;    te = window->TopEdge;
  438.     ww = window->Width;       wh = window->Height;
  439.  
  440.     s = window->WScreen;
  441.     sw = s->Width;
  442.     sh = s->Height;
  443.  
  444.     rp=&(s->RastPort);
  445.  
  446.     SetAPen(rp,1L);
  447.     SetBPen(rp,2L);
  448.     SetDrMd(rp, COMPLEMENT | JAM1);
  449.  
  450.     LastX = ox = x = s->MouseX;
  451.     LastY = oy = y = s->MouseY;
  452.  
  453.     corner = 0;
  454.  
  455.     if ((y >= te) && (y < (te + THRESHY)))  {                    /* top edge */
  456.       if ((x >= le) && (x < (le + THRESHX)))                     /* left */
  457.       { corner = 1;
  458.         dx = le - x;
  459.         dy = te - y;
  460.       }
  461.       else
  462.       if ((x <= (le + ww)) && (x > (le + ww - THRESHX)))         /* right */
  463.       { corner = 2;
  464.         dx = (le+ww) - x;
  465.         dy = te - y;
  466.       }
  467.     }
  468.     else
  469.     if ((y <= (te + wh)) && (y > (te + wh - THRESHY)))  {        /* bottom edge */
  470.       if ((x >= le) && (x < (le + THRESHX)))                     /* left */
  471.       { corner = 3;
  472.         dx = le - x;
  473.         dy = (te+wh) - y;
  474.       }
  475.       else
  476.       if ((x <= (le + ww)) && (x > (le + ww - THRESHX)))         /* right */
  477.       { corner = 4;
  478.         dx = (le+ww) - x;
  479.         dy = (te+wh) - y;
  480.       }
  481.     }
  482.  
  483.     if (corner != 0) {
  484.       LastX = x = s->MouseX;
  485.       LastY = y = s->MouseY;
  486.       li = &(s->LayerInfo);
  487.       LockLayers(li);
  488.       ox = xx = LastX + dx;
  489.       oy = yy = LastY + dy;
  490.       DoEm();
  491.       nomore = 1;
  492.       there = 1;
  493.     }
  494.     else nomore = 0;
  495.   }
  496. }
  497.  
  498. MoveThatWindow()
  499. {
  500.   Forbid();
  501.   Disable();
  502.  
  503.   FiniUpi();
  504.  
  505.   fx = xx;
  506.   fy = yy;
  507.  
  508.   xx = fx - ox; if (xx < 0) xx = xx * -1;
  509.   yy = fy - oy; if (yy < 0) yy = yy * -1;
  510.  
  511.   if (corner == 1) {
  512.     if ((fx >= ox) && (fy >= oy)) {
  513.       while (xx > (le+ww-MINX)) xx = xx - 1;
  514.       while (yy > (te+wh-MINY)) yy = yy - 1;
  515.       SizeWindow(window, (-1L * xx), (-1L * yy));
  516.       MoveWindow(window, (1L * xx), (1L * yy));
  517.     }
  518.     else
  519.     if ((fx <= ox) && (fy <= oy)) {
  520.       while ((le-xx) < 0) xx = xx - 1;
  521.       while ((te-yy) < 0) yy = yy - 1;
  522.       MoveWindow(window, (-1L * xx), (-1L * yy));
  523.       SizeWindow(window, (1L * xx), (1L * yy));
  524.     }
  525.     else
  526.     if ((fx >= ox) && (fy <= oy)) {
  527.       while (xx > (le+ww-MINX)) xx = xx - 1;
  528.       while ((te-yy) < 0) yy = yy - 1;
  529.       SizeWindow(window, (-1L * xx), 0L);
  530.       MoveWindow(window, (1L * xx), (-1L * yy));
  531.       SizeWindow(window, 0L, (1L * yy));
  532.     }
  533.     else
  534.     if ((fx <= ox) && (fy >= oy)) {
  535.       while (yy > (te+wh-MINY)) yy = yy - 1;
  536.       while ((le-xx) < 0) xx = xx - 1;
  537.       SizeWindow(window, 0L, (-1L * yy));
  538.       MoveWindow(window, (-1L * xx), (1L * yy));
  539.       SizeWindow(window, (1L * xx), 0L);
  540.     }
  541.   }
  542.   else
  543.   if (corner == 2) {
  544.     if ((fx >= ox) && (fy >= oy)) {
  545.       while (yy > (te+wh-MINY)) yy = yy - 1;
  546.       while ((xx+le+ww) > s->Width) xx = xx - 1;
  547.       SizeWindow(window, (1L * xx), (-1L * yy));
  548.       MoveWindow(window, 0L, (1L * yy));
  549.     }
  550.     else
  551.     if ((fx <= ox) && (fy <= oy)) {
  552.       while ((te-yy) < 0) yy = yy - 1;
  553.       MoveWindow(window, 0L , (-1L * yy));
  554.       SizeWindow(window, (-1L * xx), (1L * yy));
  555.     }
  556.     else
  557.     if ((fx >= ox) && (fy <= oy)) {
  558.       while ((le+ww+xx) > s->Width) xx = xx - 1;
  559.       while ((te-yy) < 0) yy = yy - 1;
  560.       MoveWindow(window, 0L, (-1L * yy));
  561.       SizeWindow(window, (1L * xx), (1L * yy));
  562.     }
  563.     else
  564.     if ((fx <= ox) && (fy >= oy)) {
  565.       while (yy > (te+wh-MINY)) yy = yy - 1;
  566.       SizeWindow(window, (-1L * xx), (-1L * yy));
  567.       MoveWindow(window, 0L, (1L * yy));
  568.     }
  569.   }
  570.   else
  571.   if (corner == 3) {
  572.     if ((fx >= ox) && (fy >= oy)) {
  573.       while (xx > (le+ww-MINX)) xx = xx - 1;
  574.       while ((te+yy+wh) > s->Height) yy = yy - 1;
  575.       SizeWindow(window, (-1L * xx), (1L * yy));
  576.       MoveWindow(window, (1L * xx), 0L);
  577.     }
  578.     else
  579.     if ((fx <= ox) && (fy <= oy)) {
  580.       while ((le-xx) < 0) xx = xx - 1;
  581.       while ((te+wh-yy) < MINY) yy = yy - 1;
  582.       MoveWindow(window, (-1L * xx), 0L);
  583.       SizeWindow(window, (1L * xx), (-1L * yy));
  584.     }
  585.     else
  586.     if ((fx >= ox) && (fy <= oy)) {
  587.       while ((te+wh-yy) < MINY) yy = yy - 1;
  588.       while (xx > (le+ww-MINX)) xx = xx - 1;
  589.       SizeWindow(window, (-1L * xx), (-1L * yy));
  590.       MoveWindow(window, (1L * xx), 0L);
  591.     }
  592.     else
  593.     if ((fx <= ox) && (fy >= oy)) {
  594.       while ((le-xx) < 0) xx = xx - 1;
  595.       while ((te+yy+wh) > s->Height) yy = yy - 1;
  596.       MoveWindow(window, (-1L * xx), 0L);
  597.       SizeWindow(window, (1L * xx), (1L * yy));
  598.     }
  599.   }
  600.   else
  601.   if (corner == 4) {
  602.     if ((fx >= ox) && (fy >= oy)) {
  603.       while ((te+yy+wh) > s->Height) yy = yy - 1;
  604.       while ((xx+le+ww) > s->Width) xx = xx - 1;
  605.       SizeWindow(window, (1L * xx), (1L * yy));
  606.     }
  607.     else
  608.     if ((fx <= ox) && (fy <= oy)) {
  609.       while (xx > (le+ww-MINX)) xx = xx - 1;
  610.       while ((te+wh-yy) < MINY) yy = yy - 1;
  611.       SizeWindow(window, (-1L * xx), (-1L * yy));
  612.     }
  613.     else
  614.     if ((fx >= ox) && (fy <= oy)) {
  615.       while ((le+ww+xx) > s->Width) xx = xx - 1;
  616.       while ((te+wh-yy) < MINY) yy = yy - 1;
  617.       SizeWindow(window, (1L * xx), (-1L * yy));
  618.     }
  619.     else
  620.     if ((fx <= ox) && (fy >= oy)) {
  621.       while (xx > (le+ww-MINX)) xx = xx - 1;
  622.       while ((te+yy+wh) > s->Height) yy = yy - 1;
  623.       SizeWindow(window, (-1L * xx), (1L * yy));
  624.     }
  625.   }
  626.   Enable();
  627.   Permit();
  628.   nomore = corner = 0;
  629. }
  630.  
  631. breakcheck()
  632. {
  633.    if (SetSignal(0L,0L) & SIGBREAKF_CTRL_C)
  634.       return (1);
  635.    else
  636.       return (0);
  637. }
  638.  
  639. breakreset()
  640. {
  641.    SetSignal(0L, SIGBREAKF_CTRL_C);
  642. }
  643.  
  644. Chk_Abort()
  645. {
  646.   return(0);
  647. }
  648.  
  649. Uninstall()
  650. {
  651.   if (!updating)
  652.     {
  653.     if (inputReq)
  654.       {
  655.       inputReq->io_Command = IND_REMHANDLER;
  656.       inputReq->io_Data = (APTR)&handlerStuff;
  657.       DoIO(inputReq);
  658.  
  659.       CloseDevice(inputReq);
  660.       DeleteStdIO(inputReq);
  661.       }
  662.  
  663.     if (inputPort)    DeletePort(inputPort);
  664.     if (signum > -1)  FreeSignal(signum);
  665.  
  666.     if (tdevice == 0)
  667.       {
  668.       AbortIO(&Timer_Req.tr_node);
  669.       CloseDevice(&Timer_Req);
  670.       }
  671.  
  672.     if (TimerPort)
  673.       DeletePort(TimerPort);
  674.  
  675.     if (defPortPtr)
  676.       {
  677.       if (defPortPtr->mp.mp_Node.ln_Name)
  678.         RemPort(defPortPtr);
  679.       FreeMem(defPortPtr,(long)sizeof(struct defPort));
  680.       }
  681.     }
  682.  
  683.   if (LayersBase)
  684.     CloseLibrary(LayersBase);
  685.   if (GfxBase)
  686.     CloseLibrary(GfxBase);
  687.   if (IntuitionBase)
  688.     CloseLibrary(IntuitionBase);
  689.   exit(0L);
  690. }
  691.