home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d120 / backgammon.lha / BackGammon / backscn.c < prev    next >
C/C++ Source or Header  |  1987-12-28  |  16KB  |  727 lines

  1. /********************************************************************/
  2. /*                                                                  */
  3. /*  Hoser BackGammon version 1.0                                    */
  4. /*                                                                  */
  5. /*      Robert Pfister                                              */
  6. /*                                                                  */
  7. /*      Rfd#3 Box 2340                home:(207)-873-3520           */
  8. /*      Waterville, Maine 04901                                     */
  9. /*                                                                  */
  10. /*      Pfister_rob%dneast@dec.decwrl                               */
  11. /*                                                                  */
  12. /*                                                                  */
  13. /*  Copyright  June,1987 all rights reserved.                       */
  14. /*                                                                  */
  15. /*  This program will play a game of backgammon at the novice level */
  16. /*                                                                  */
  17. /*  The code is in 4 parts...                                       */
  18. /*                                                                  */
  19. /*       1) back.c     - main driver                                */
  20. /*   /   2) eval.c     - evaluation of moves                        */
  21. /* \/    3) backscn.c  - screen stuff..                             */
  22. /*       4) backmenu.c - menu stuff, help text, and ``decoder''     */
  23. /*                                                                  */
  24. /* this was compiled under Manx 3.20a, using long integers          */
  25. /*                                                                  */
  26. /********************************************************************/
  27.  
  28. extern int Uside,Cside;
  29.  
  30. #include <stdio.h>
  31. #include <exec/types.h>
  32. #include <graphics/gfxmacros.h>
  33. #include <graphics/rastport.h>
  34. #include <intuition/intuition.h>
  35. #include <intuition/intuitionbase.h>
  36. #include <functions.h>
  37.  
  38. #undef  NULL
  39. #define NULL ((void *) 0)
  40. #define NL 0
  41.  
  42. /* color index's */
  43. #define tm1       0L
  44. #define tm2       1L
  45. #define back      2L
  46. #define spike1    3L
  47. #define spike2    4L
  48. #define peice1    5L
  49. #define peice2    6L
  50. #define dice      7L
  51.  
  52. /* now define those colors */
  53. #define backc    0x0F0L
  54. #define spike1c  0xFF0L
  55. #define spike2c  0xF00L
  56. #define peice1c  0x000L
  57. #define peice2c  0x00FL
  58. #define dicec    0xFFFL
  59. #define tm1c     0x606L
  60. #define tm2c     0xDDDL
  61.  
  62. static UWORD colors[8];
  63.  
  64. /* describe the playing field */
  65. #define maxX   637L
  66. #define minX     3L
  67. #define maxY   189L
  68. #define minY    25L
  69. #define PerSpike 6L
  70. #define MyTitle "Hoser BackGammon     Copyright June 1987     Robert Pfister"
  71.  
  72.        struct  GfxBase         *GfxBase;
  73.        struct  IntuitionBase   *IntuitionBase;
  74. static struct  RastPort        *rp;
  75. static struct  ViewPort        *vp;
  76. static struct  Window          *w;
  77. static struct  Screen          *screen;
  78.  
  79. extern struct Menu *MyMenu;  /* get the menu somewhere else */
  80.  
  81. struct  NewScreen       ns = {
  82.     0L,0L,640L,200L,3L,
  83.     0,1,HIRES,
  84.     CUSTOMSCREEN,NULL,
  85.     (UBYTE *)MyTitle,
  86.     NULL,NULL };
  87.  
  88. struct  NewWindow       nw = {
  89.     0L,10L,640L,190L,0L,1L,
  90.     CLOSEWINDOW|MOUSEBUTTONS|MENUPICK,
  91.     SMART_REFRESH|ACTIVATE|WINDOWDRAG|WINDOWDEPTH,
  92.     NULL,NULL,
  93.     (UBYTE *)"BackGammon anyone?",
  94.     NULL,NULL,
  95.     0L,0L,640L,200L,CUSTOMSCREEN };
  96.  
  97. struct  NewWindow       crnw = {
  98.     20L,20L,600L,170L,0L,1L,
  99.     CLOSEWINDOW|MOUSEBUTTONS|MENUPICK,
  100.     WINDOWCLOSE|SMART_REFRESH|ACTIVATE|WINDOWDRAG|WINDOWDEPTH,
  101.     NULL,NULL,
  102.     (UBYTE *)"BackGammon credits",
  103.     NULL,NULL,
  104.     0L,0L,640L,200L,CUSTOMSCREEN };
  105.  
  106. static UWORD AreaBuf[1000];
  107. static PLANEPTR TBuf;
  108. static struct TmpRas TRas;
  109. static struct AreaInfo AInfo;
  110.  
  111. Gsetup()
  112. {
  113.  
  114. long  x,size;
  115. int   i;
  116.  
  117.     GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L);
  118.     if (GfxBase == NULL) Gerror("no graphics lib");
  119.     IntuitionBase =
  120.         (struct IntuitionBase *)OpenLibrary("intuition.library",0L);
  121.     if (IntuitionBase == NULL) {
  122.         CloseLibrary(GfxBase);
  123.         Gerror("no intuition");
  124.         }
  125.  
  126.     screen = (struct Screen *)OpenScreen(&ns);
  127.     if (screen == NULL) {
  128.         CloseLibrary(IntuitionBase);
  129.         CloseLibrary(GfxBase);
  130.         Gerror("no screen");
  131.         }
  132.  
  133.     nw.Screen = screen;
  134.     w         = (struct Window *)OpenWindow(&nw);
  135.     if (w == NULL) {
  136.         CloseScreen(screen);
  137.             CloseLibrary(IntuitionBase);
  138.         CloseLibrary(GfxBase);
  139.         Gerror("no window");
  140.         }
  141.  
  142.     vp = &screen->ViewPort;
  143.     rp = w->RPort;
  144.  
  145.     /* intialize temporary area space */
  146.     InitArea(&AInfo,AreaBuf,200L);
  147.     rp->AreaInfo=&AInfo;
  148.     TBuf=(PLANEPTR)AllocRaster(640L,200L);
  149.     if (TBuf==NULL)
  150.         {
  151.         ClearMenuStrip(w);  /* do this to avoid nasty's */
  152.         CloseWindow(w);
  153.         CloseScreen(screen);
  154.         CloseLibrary(IntuitionBase);
  155.         CloseLibrary(GfxBase);
  156.         Gerror("no raster");
  157.         }
  158.  
  159.     SetMenuStrip(w,MyMenu);
  160.  
  161.     size=RASSIZE(640L,200L);
  162.     rp->TmpRas=(struct TmpRas *)InitTmpRas(&TRas,TBuf,size);
  163.  
  164.     /* load in the colors */
  165.     colors[back]  =backc;
  166.     colors[spike1]=spike1c;
  167.     colors[spike2]=spike2c;
  168.     colors[peice1]=peice1c;
  169.     colors[peice2]=peice2c;
  170.     colors[tm1]   =tm1c;
  171.     colors[tm2]   =tm2c;
  172.     colors[dice]  =dicec;
  173.  
  174.     for (i=0;i<8;i++)
  175.        {
  176.         SetRGB4(vp,(long) i,(long)((colors[i] >>8) & 0xF),
  177.                             (long)((colors[i] >>4) & 0xF),
  178.                             (long)((colors[i]    ) & 0xF));
  179.         }
  180.  
  181.     SetDrMd(rp,JAM1);
  182.  
  183.     SetAPen(rp,back);
  184.     RectFill(rp,minX,minY,maxX,maxY);
  185.  
  186.     for (i=1;i<=24;i++)
  187.        {
  188.          PutSpike(i,0);
  189.          }
  190.  
  191.     x=((maxX+minX)/2);
  192.     SetAPen(rp,tm1);
  193.     RectFill(rp,(long)(x-2),minY,(long)(x+2),maxY);
  194.     Move(rp,4L,(long)minY-6);
  195.     SetAPen(rp,peice1);
  196.     Text(rp,(char *)"Number of Moves Evaluated",25L);
  197.     }
  198.  
  199.  
  200.  
  201. int l1,l2,r1,r2;  /* saved dice positions */
  202.  
  203. /* swap the dice positions on the screen */
  204. SwapDice()
  205. {
  206.  int di[4];
  207.  int sr1,sr2;
  208.  
  209.  di[0]=l1;
  210.  di[1]=l2;
  211.  
  212.  sr1  =r1;
  213.  sr2  =r2;
  214.  
  215.  Uside=-Uside;
  216.  Cside=-Cside;
  217.   
  218.  ShowDice(di,Cside);
  219.  
  220.  di[0]=sr1;
  221.  di[1]=sr2;
  222.  
  223.  ShowDice(di,Uside);
  224.  }
  225.  
  226.  
  227. /* put dice on the screen */
  228.  
  229. ShowDice(d,c)
  230. int  d[4],c;
  231. {
  232.  int y,x1,x2;
  233.  char Line[6];
  234.  y =(maxY+minY)/2;
  235.  
  236.  if (c==Cside)
  237.     {
  238.     l1=d[0];
  239.     l2=d[1];
  240.     x1=40+(maxX+minX)/2; 
  241.     x2=30+x1;
  242.      }
  243.   else
  244.     {
  245.      r1=d[0];
  246.      r2=d[1];
  247.      x1=-40+(maxX+minX)/2;
  248.      x2=-30+x1;
  249.      }
  250.  
  251.  /* cover up dice with dice color */
  252.  
  253.  SetAPen(rp,dice);
  254.  RectFill(rp,(long) x2-12,(long) y-4,(long) x2+12,(long) y+4);
  255.  RectFill(rp,(long) x1-12,(long) y-4,(long) x1+12,(long) y+4);
  256.  
  257.  if ( (d[0]!=0) && (d[1]!=0))
  258.     {
  259.      /* put in the numbers for the left and right die */
  260.  
  261.      if (c==Uside) SetAPen(rp,peice1);
  262.               else SetAPen(rp,peice2);
  263.  
  264.      Move(rp,(long) x2,(long) y+3);
  265.      Line[0]='0'+d[0];
  266.      Line[1]='\0';
  267.      Text(rp,Line,1L);
  268.  
  269.      Move(rp,(long) x1,(long) y+3);
  270.      Line[0]='0'+d[1];
  271.      Line[1]='\0';
  272.      Text(rp,Line,1L);
  273.      }
  274.  }
  275.  
  276.  
  277. i2s(n1,Line)
  278. int n1;
  279. char Line[6];
  280. {
  281.  int i,n;
  282.  
  283.  n=n1;
  284.  
  285.  for(i=0;i<=4;i++) Line[i]=' ';
  286.  Line[5]='/0';
  287.  Line[4]='0';
  288.  
  289.  /* convert into a string */
  290.  for(i=4;(i>=0)&&(n>0);i--)
  291.   {
  292.    Line[i]=(n % 10) + '0';
  293.    n/=10;
  294.    }
  295. }
  296.  
  297.  
  298. PutMoveNumber(Number)
  299. int Number;
  300. {
  301.  char Line[6];
  302.  long x,y;
  303.  
  304.  y= minY-6;
  305.  x= 210;
  306.  
  307.  SetAPen(rp,tm1);
  308.  RectFill(rp,x,(long) y-6,(long) x+40,(long) y+4);
  309.  i2s(Number,Line);
  310.  SetAPen(rp,dice);
  311.  Move(rp,x,y);
  312.  Text(rp,Line,5L);
  313. }
  314.  
  315. static struct IntuiMessage *message;
  316.  
  317. /* return any interesting input from the mouse...note that the window
  318.    close is automatic  */
  319.  
  320. Whats_up(x)
  321. int  *x;
  322.   {
  323.    unsigned long Class;
  324.    unsigned short Code;
  325.    char  code;
  326.    int   xm,ym;
  327.  
  328.         for (;;)
  329.           {
  330.            Wait(1L<< w->UserPort->mp_SigBit);
  331.            message=(struct IntuiMessage *) GetMsg(w->UserPort);
  332.            Code =message->Code;
  333.            Class=message->Class;
  334.            ReplyMsg(message);
  335.  
  336.            if (Class==MENUPICK)
  337.               {
  338.                if (Code!=MENUNULL)
  339.                    {
  340.                     *x=(MENUNUM(Code)*100)+(ITEMNUM(Code)*10)+SUBNUM(Code);
  341.                     return('C');
  342.                    }
  343.                return(' '); /* aint nothing, better reset */
  344.                } 
  345.  
  346.            /* check if mouse pressed..... */
  347.            if ((Class==MOUSEBUTTONS)&&
  348.                (Code==SELECTDOWN))
  349.               {
  350.                 xm=(w->MouseX);
  351.                 ym=(w->MouseY);
  352.                 *x=decode(xm,ym);
  353.                 if (*x==-1)  return('D');
  354.                         else return('P');
  355.                 }
  356.             }    /* end for ever */
  357.     }  /* end main */
  358.  
  359. finit()
  360. {
  361.   FreeRaster(TBuf,640L,200L);
  362.   CloseWindow(w);
  363.   CloseScreen(screen);
  364.   CloseLibrary(IntuitionBase);
  365.   CloseLibrary(GfxBase);
  366.  }
  367.  
  368. /* return the 'spike' number given the screen point relative to upper left
  369.    corner of the window */
  370.  
  371. decode(x,y)
  372. int x,y;
  373. {
  374.  int peice,mid,midy,height,disp;
  375.      mid=(minX+maxX)/2;
  376.      if (x>mid) disp=8;
  377.            else disp=0;
  378.  
  379.      height=(maxY-minY)/2.5;
  380.      midy=(minY+maxY)/2;
  381.  
  382.      /* check if dice 'clicked'...indicates unusual end of turn */
  383.      if ((y>midy-5)&&(y<midy+5)&&(x<mid-28)&&(x>mid-82)) return(-1);
  384.  
  385.      /* check if 'bar' selected */
  386.      if ( (x>(mid-10)) && (x<(mid+10))
  387.           && (y>height) && (y<(maxY-height))    ) peice=0;
  388.  
  389.         else peice= 1+(12*(x+disp))/(maxX-minX);
  390.  
  391.      if ( y < (maxY+minY)/2) peice=25-peice;
  392.      return(peice);
  393.  }
  394.  
  395. static int ErrSet=FALSE;
  396.  
  397. DoMenuStrip(errmsg)
  398. char errmsg[];
  399. {
  400.  ErrSet=TRUE;
  401.  SetWindowTitles(w,-1L,errmsg);
  402.  }
  403.  
  404. UnDoMenuStrip()
  405. {
  406.  if (ErrSet==TRUE)
  407.     {
  408.      SetWindowTitles(w,-1L,MyTitle);
  409.      ErrSet=FALSE;
  410.      }
  411. }
  412.  
  413. /* put up a plain old requestor given 3 strings
  414.            name...the question/statement of the requestor
  415.            yes....the positive response
  416.            no.....the negative response
  417.  
  418.     this returns 'true' for the yes, 'false' for the no  */
  419.  
  420. static struct IntuiText RB = {tm1   ,tm2   ,JAM2, 50, 10,NL,(UBYTE *)"   ",NL};
  421. static struct IntuiText RY = {spike2,spike1,JAM1,  8,  3,NL,(UBYTE *)"Yes",NL};
  422. static struct IntuiText RN = {spike2,spike1,JAM1,  8,  3,NL,(UBYTE *)"No ",NL};
  423.  
  424. requestor(name,yes,no)
  425. char name[],yes[],no[];
  426. {
  427.   RB.IText=(UBYTE *)name;
  428.   RY.IText=(UBYTE *)yes;
  429.   RN.IText=(UBYTE *)no;
  430.   return(AutoRequest(w,&RB,&RY,&RN,NULL,NULL,300L,90L));
  431.  
  432.   }
  433.  
  434.  
  435. Gerror(msg)
  436. char *msg;
  437.     {
  438.     if (msg) {
  439.         puts("ERROR: ");
  440.         puts(msg);
  441.         puts("\n");
  442.         }
  443.     if (msg) exit(-1);
  444.     else     exit(0);
  445.     }
  446.  
  447.  
  448. PutSpike(spk,peices)
  449. int spk,peices;
  450.   {
  451.    long color,x,y,x1,y1,x2,y2,x3;
  452.    int disp,n,i,sign;
  453.    char line[10];
  454.  
  455.   /* pick color of the peices */
  456.    if (peices<0) color=peice1;
  457.             else color=peice2;
  458.  
  459.    /* plot the ones on the 'bar' */
  460.    x1=-20+(minX+maxX)/2;
  461.    x2=x1+40;
  462.    y1=(maxY+minY)/2;
  463.    if (spk==0)
  464.        {
  465.        SetAPen(rp,back);
  466.        RectFill(rp,x1,y1,x2,(long)(y1+20));
  467.        x=((maxX+minX)/2);
  468.        SetAPen(rp,tm1);
  469.        RectFill(rp,(long)(x-2),y1,(long)(x+2),maxY);
  470.        if (peices>0)
  471.              {
  472.              PutPeice((long)(x1+20),(long)(y1+10),color);
  473.              line[0]=('0'+peices);
  474.              line[1]='\0';
  475.              Move(rp,(long)(x1+18),(long)(y1+12));
  476.              SetAPen(rp,dice);
  477.              Text(rp,line,1L);
  478.              }
  479.        return(0);
  480.        }
  481.  
  482.    if (spk==25)
  483.        {
  484.        SetAPen(rp,back);
  485.        RectFill(rp,x1,(long)(y1-20),x2,y1);
  486.        SetAPen(rp,tm1);
  487.        x=((maxX+minX)/2);
  488.        RectFill(rp,(long)(x-2),minY,(long)(x+2),y1);
  489.        if (peices<0)
  490.              {
  491.              PutPeice((long)(x1+20),(long)(y1-10),color);
  492.              line[0]=('0'-peices);
  493.              line[1]='\0';
  494.              Move(rp,(long)(x1+18),(long)(y1-8));
  495.              SetAPen(rp,dice);
  496.              Text(rp,line,1L);
  497.              }
  498.        return(0);
  499.        }
  500.  
  501.  
  502.    n=(maxX-minX)/ 12;
  503.    y=(maxY-minY)/ 2.5;
  504.  
  505.    x=spk;
  506.    if (x>12) x=25-x;
  507.    if (x>6)  disp=8;
  508.         else disp=0;
  509.  
  510.    x1=(x*n)    -(n/2)+minX+disp;
  511.    x2=(x*n)          +minX+disp;
  512.    x3=((x-1)*n)      +minX+disp;
  513.  
  514.    /* box in the area around the spike with background color...*/
  515.  
  516.    SetAPen(rp,(long)back);
  517.  
  518.    if (spk<13)
  519.       {
  520.         sign=-1;
  521.         y1=maxY-y;
  522.         y2=maxY;
  523.         RectFill(rp,x3,y1,x2,y2);
  524.     }
  525.      else
  526.        {
  527.         sign=1;
  528.         y1=minY+y;
  529.         y2=minY;
  530.         RectFill(rp,x3,y2,x2,y1);
  531.        }
  532.  
  533.  
  534.    /* color in spike */
  535.    if (spk%2 ==1) SetAPen(rp,(long)spike1);
  536.              else SetAPen(rp,(long)spike2);
  537.  
  538.    AreaMove(rp,x1,y1);
  539.    AreaDraw(rp,x2,y2);
  540.    AreaDraw(rp,x3,y2);
  541.    AreaDraw(rp,x1,y1);
  542.    AreaEnd(rp);
  543.  
  544.    if (peices<0) peices=-peices;
  545.    /* go through number of peices, up to "PerSpike" */
  546.    for(i=0;(i<peices)&&(i<PerSpike);i++)
  547.       {
  548.        y=(y2+(sign*( (i*10)+6 )));
  549.        PutPeice(x1,y,color);
  550.        }
  551.  
  552.   /* put some fancy numbers on it if >PerSpike peices */
  553.  
  554.    if (peices>=PerSpike)
  555.        {
  556.          line[0]=('0'+peices);
  557.          line[1]='\0';
  558.          if (spk<13)  y2=y2-3;
  559.                 else  y2=y2+9;
  560.          Move(rp,x1,y2);
  561.          SetAPen(rp,dice);
  562.          Text(rp,line,1L);
  563.         }
  564.  
  565.    }  /* end of PutSpike */
  566.  
  567. BlinkPeice(board,pos)
  568. int board[26],pos;
  569. {
  570.  int part,n,x1,y,disp,sign,i;
  571.  
  572.  PutSpike(pos,board[pos]);
  573.  
  574.  if (board[pos]==0) return(0); /* Dont bother if nothing there */
  575.  
  576.  part=(maxX-minX)/ 12;
  577.  
  578.  n=board[pos];
  579.  
  580.  if (n<0) n=0-n;
  581.  
  582.  if (n>PerSpike) n=PerSpike;
  583.  
  584.  if (pos<13)
  585.           {
  586.            i=pos;
  587.            sign=+1;
  588.            y=maxY-(n*10)+4;
  589.            }
  590.        else
  591.           {
  592.            i=25-pos;
  593.            y=minY+(n*10)-4;
  594.            }
  595.  
  596.  if (i>6)  disp=8;
  597.       else disp=0;
  598.  
  599.  /* this is the x-coord */
  600.  
  601.   x1=(i*part) - (part/2)+minX+disp;
  602.  
  603.  /* if the bar, do something different */
  604.  
  605.   if (pos==0)
  606.       {
  607.        y=((maxY+minY)/2)+10;
  608.        x1=((maxX+minX)/2);
  609.        }
  610.  
  611.    if (pos==25)
  612.        {
  613.        y=((maxY+minY)/2)-10;
  614.        x1=((maxX+minX)/2);
  615.        }
  616.  
  617.    if (board[pos]<0) n=peice1;
  618.                else  n=peice2;
  619.  
  620.    for(i=1;i<=5;i++)
  621.     {
  622.      Delay(1);
  623.      PutPeice(x1,y,dice);
  624.      Delay(1);
  625.      PutPeice(x1,y,n);
  626.      }
  627.  
  628. }
  629.  
  630. static WORD shapeX[9]={15,15,4,-4,-15,-15,-4,4,15};
  631. static WORD shapeY[9]={-2,2,4,4,2,-2,-4,-4,-2};
  632.  
  633. PutPeice(x,y,color)
  634. long x,y,color;
  635.   {
  636.    int i;
  637.    long x1,y1;
  638.    SetAPen(rp,color);
  639.    AreaMove(rp,(long)(x+shapeX[0]),(long)(y+shapeY[0]));
  640.  
  641.    for (i=1;i<=8;i++)
  642.      {
  643.      x1=x+shapeX[i];
  644.      y1=y+shapeY[i];
  645.      AreaDraw(rp,x1,y1);
  646.      }
  647.    AreaEnd(rp);
  648.   }
  649.  
  650. TextScreen(stuff,num)
  651.  
  652. char *stuff[];
  653. int num;
  654.  
  655.  
  656. {
  657.    int i;
  658.  
  659.    unsigned long Class;
  660.    unsigned short Code;
  661.  
  662.    struct  IOStdReq    *re ,*wr;
  663.    struct  MsgPort     *rep,*wrp;
  664.    struct  RastPort    *crp;
  665.    struct  Window      *crw;
  666.  
  667.    crnw.Screen=screen;
  668.    crnw.Title=(UBYTE *) stuff[0];
  669.  
  670.    crw         = (struct Window *)OpenWindow(&crnw);
  671.  
  672.    if (crw != NULL)
  673.        {
  674.         crp=w->RPort;
  675.  
  676.         rep=CreatePort("my.con.read",0);
  677.         re=CreateStdIO(rep);
  678.  
  679.         wrp=CreatePort("my.con.write",0);
  680.         wr=CreateStdIO(wrp);
  681.  
  682.         wr->io_Data=(APTR) crw;
  683.         wr->io_Length=sizeof(*crw);
  684.  
  685.         if (OpenDevice("console.device",0,wr,0)==0)
  686.            {
  687.             re->io_Device = wr->io_Device;
  688.             re->io_Unit   = wr->io_Unit;
  689.  
  690.            /* loop through all the stuff and put it to the open'd console */
  691.  
  692.               for (i=1;i<=num; i++) 
  693.                 {
  694.                  wr->io_Command=CMD_WRITE;
  695.                  wr->io_Data   =(UBYTE *) stuff[i];
  696.                  wr->io_Length =-1;
  697.  
  698.                  DoIO(wr);
  699.                  }
  700.  
  701.             /* close the console up */
  702.  
  703.                DeleteStdIO(re);
  704.                DeletePort(rep);
  705.  
  706.                DeleteStdIO(wr);
  707.                DeletePort(wrp);
  708.  
  709.            }/* end-if console created */
  710.   
  711.            for (;;)
  712.              {
  713.               Wait(1L<< crw->UserPort->mp_SigBit);
  714.               message=(struct IntuiMessage *) GetMsg(crw->UserPort);
  715.               Code =message->Code;
  716.               Class=message->Class;
  717.               ReplyMsg(message);
  718.               if (Class==CLOSEWINDOW) break;
  719.               }
  720.  
  721.          CloseWindow(crw);
  722.  
  723.       }  /* end-if window opened */
  724.  
  725.      return;
  726. }
  727.