home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sniff16.zip / TESTAPP / WRMTHRD.C < prev    next >
C/C++ Source or Header  |  1993-03-12  |  21KB  |  636 lines

  1. /*=========================================================================\
  2.  *                                                                         *
  3.  *       FILE: wrmthrd.c                                                   *
  4.  *                                                                         *
  5.  *       DESCRIPTION:                                                      *
  6.  *                                                                         *
  7.  *                                                                         *
  8.  *      Created 1991  IBM Corp.                                            *
  9.  *                                                                         *
  10.  *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is        *
  11.  *      sample code created by IBM Corporation. This sample code is not    *
  12.  *      part of any standard or IBM product and is provided to you solely  *
  13.  *      for  the purpose of assisting you in the development of your       *    *
  14.  *      applications.  The code is provided "AS IS", without               *
  15.  *      warranty of any kind.  IBM shall not be liable for any damages     *
  16.  *      arising out of your use of the sample code, even if they have been *
  17.  *      advised of the possibility of   such damages.                      *                               *
  18.  *                                                                         *
  19.  *-------------------------------------------------------------------------*
  20.  *--------------------------------------------------------------
  21.  *
  22.  *  This source file contains the following functions:
  23.  *
  24.  *
  25.  *  move_worm_up
  26.  *  move_worm_down
  27.  *  move_worm_right
  28.  *  move_worm_left
  29.  *  move_worm_zigup
  30.  *
  31.  *
  32.  *
  33. \*==============================================================*/
  34.  
  35. /*--------------------------------------------------------------*\
  36.  *  Include files, macros, defined constants, and externs
  37. \*--------------------------------------------------------------*/
  38.  
  39. #define  INCL_DOS
  40. #define  INCL_VIO
  41. #define  INCL_KBD
  42. #define  INCL_MOU
  43. #define  INCL_DOSPROCESS
  44. #define  INCL_DOSSEMAPHORES
  45.  
  46. #include <os2.h>
  47. #include <stdio.h>
  48. #include <string.h>
  49. #include <stddef.h>
  50. #include <string.h>
  51. #include <stdlib.h>
  52. #include "worms.h"
  53. #include "wrmthrd.h"
  54. /*--------------------------------------------------------------*\
  55.  *  Global variables  and definitions for this file
  56. \*--------------------------------------------------------------*/
  57. CHAR *pszLeftWorm   =      "<<<------->";
  58. CHAR *pszRightWorm  =      "<------->>>";
  59. CHAR *pszBlank      =      "               ";
  60. CHAR achUpWorm[10]  =      {'^','^','|','|','|','v'};
  61. CHAR achDownWorm[10]=      {'^','^','|','|','|','v'};
  62. SHORT asWidths   [] =      {2,4,8,16};
  63. SHORT asHorizWidths  [] =  {HOR_WIDTH / 2, HOR_WIDTH /8,HOR_WIDTH,HOR_WIDTH / 3};
  64. SHORT asVertHeights  [] =  {HEIGHT / 4,HEIGHT / 8, HEIGHT / 2, HEIGHT  };
  65. SHORT sDirection = 0;
  66. SHORT sVertHeight = 0;
  67. SHORT sRefresh = 1;
  68. #define DEBUG              0
  69. #define MAX_LEN_WORM       48
  70. #define FILE_NAME          "TEST.???"
  71.  
  72. /*--------------------------------------------------------------*\
  73.  *  Entry point declarations
  74. \*--------------------------------------------------------------*/
  75.  
  76. VOID move_worm_up( USHORT *pusCurrentRow,USHORT *pusCurrentCol,
  77.                      PBYTE  pbAttribute,
  78.                      SHORT *psCurrentDirection,
  79.                      LONG  tidWorm);
  80. VOID move_worm_down( USHORT *pusCurrentRow,USHORT *pusCurrentCol,
  81.                      PBYTE  pbAttribute,
  82.                      SHORT *psCurrentDirection,
  83.                      LONG  tidWorm);
  84. VOID move_worm_right( USHORT *pusCurrentRow,USHORT *pusCurrentCol,
  85.                      PBYTE  pbAttribute,
  86.                      SHORT *psCurrentDirection,
  87.                      LONG  tidWorm);
  88. VOID move_worm_left( USHORT *pusCurrentRow,USHORT *pusCurrentCol,
  89.                      PBYTE  pbAttribute,
  90.                      SHORT *psCurrentDirection,
  91.                      LONG  tidWorm);
  92. VOID move_worm_zigup(USHORT *pusCurrentRow,USHORT *pusCurrentCol,
  93.                       PBYTE pbAttribute,
  94.                       SHORT *psCurrentDirection,
  95.                       LONG tidWorm);
  96. /****************************************************************\
  97.  *  Routine Name:wrmthrd()
  98.  *--------------------------------------------------------------
  99.  *
  100.  *  Name:
  101.  *
  102.  *  Purpose: This routine allows each thread to draw to the screen.
  103.  *           Each thread will stay in this loop, until the thread
  104.  *           dies, or is terminated. Each thread may draw to the
  105.  *           unless the semaphore is set by thread one or indicating
  106.  *           that one of the parent threads wants control of the
  107.  *           screeen.
  108.  *
  109.  *  Returns: There is no return value. The thread terminates.
  110.  *
  111. \****************************************************************/
  112. VOID
  113. WormThread(PVOID pvMessage)
  114. {
  115.  
  116.      PTHREAD_DATA pThreadData;
  117.      SHORT  sDummy;
  118.      SHORT  asDirection [] = { UP,RIGHT,LEFT,DOWN};
  119.  
  120.  
  121.  
  122.      srand(sDummy);
  123.      pThreadData =  (PTHREAD_DATA) pvMessage;
  124.      /*
  125.       *start the worm  off
  126.       */
  127.      if(sDirection == ( sizeof(asDirection) / sizeof(SHORT) ) )
  128.      {
  129.           sDirection = 0;
  130.      }
  131.      pThreadData->sCurrentDirection = asDirection[sDirection++];
  132.      do
  133.      {
  134.           switch(pThreadData->sCurrentDirection)
  135.           {
  136.           case UP:
  137.                move_worm_up( &pThreadData->usCurrentRow,&pThreadData->usCurrentCol,
  138.                              &pThreadData->bAttribute,
  139.                              &pThreadData->sCurrentDirection,
  140.                               pThreadData->tidWorm);
  141.                break;
  142.           case DOWN:
  143.                move_worm_down( &pThreadData->usCurrentRow,&pThreadData->usCurrentCol,
  144.                                &pThreadData->bAttribute,
  145.                                &pThreadData->sCurrentDirection,
  146.                                 pThreadData->tidWorm);
  147.                break;
  148.  
  149.           case LEFT:
  150.                move_worm_left( &pThreadData->usCurrentRow,&pThreadData->usCurrentCol,
  151.                                &pThreadData->bAttribute,
  152.                                &pThreadData->sCurrentDirection,
  153.                                 pThreadData->tidWorm );
  154.                break;
  155.           case RIGHT:
  156.                move_worm_right( &pThreadData->usCurrentRow,&pThreadData->usCurrentCol,
  157.                                 &pThreadData->bAttribute,
  158.                                 &pThreadData->sCurrentDirection,
  159.                                  pThreadData->tidWorm );
  160.                break;
  161.           case ZIG_UP:
  162.                move_worm_zigup( &pThreadData->usCurrentRow,&pThreadData->usCurrentCol,
  163.                              &pThreadData->bAttribute,
  164.                              &pThreadData->sCurrentDirection,
  165.                               pThreadData->tidWorm );
  166.                break;
  167.           default:
  168.                pThreadData->usCurrentRow = ( LAST_ROW - FIRST_ROW ) /2;
  169.                pThreadData->usCurrentCol = ( LAST_COL - FIRST_COL ) /2;
  170.                if(sDirection == ( sizeof(asDirection) / sizeof(SHORT) ) )
  171.                {
  172.                     sDirection = 0;
  173.                }
  174.                pThreadData->sCurrentDirection = asDirection[sDirection++];
  175.                break;
  176.           }
  177.           DosSleep(PAUSE_TIME);
  178.           /*
  179.            *if set,then the thread that services the console,or the
  180.            *thread that services the mouse queue wants control of
  181.            *the screen
  182.            */
  183.           DosPostEventSem(hevDrawOk);
  184.           DosWaitEventSem(hevDrawSem,SEM_INDEFINITE_WAIT);
  185.  
  186.         }while(pThreadData->fActive);
  187.  
  188.      pThreadData->tidWorm = 0;
  189.      /*
  190.       *if the process is to exit
  191.       *post the semaphore on the way out
  192.       */
  193.       if(fQuit)
  194.       {
  195.           DosPostEventSem(hevDrawOk);
  196.       }
  197.  
  198.     /*
  199.      *should alway be called
  200.      *to free any runtime resources this thread
  201.      *might be using
  202.      */
  203.     _endthread();
  204.  
  205. }/*WormThread*/
  206. /****************************************************************\
  207.  *
  208.  *--------------------------------------------------------------
  209.  *
  210.  *  Name:move_worm_down()
  211.  *
  212.  *  Purpose: Draw the worm down the screen vertically and set up to go to
  213.  *           another direction.
  214.  *  Returns: VOID
  215.  *
  216. \****************************************************************/
  217. VOID move_worm_down(USHORT *pusCurrentRow,USHORT *pusCurrentCol,PBYTE pbAttribute,
  218.                       SHORT *psCurrentDirection,
  219.                       LONG  tidWorm )
  220.  
  221. {
  222.  
  223.      USHORT sRow;
  224.      SHORT  sPos = 0;
  225.      SHORT  sStartRow;
  226.      CHAR  achCell[2];
  227.      BYTE  bAttribute;
  228.      USHORT  usCount;
  229.      BOOL  fOnce = TRUE;
  230.      BYTE  bBackGround = WM_BACKGROUND;
  231.  
  232.      if(sVertHeight  == (sizeof(asVertHeights) / sizeof(SHORT ) ) )
  233.      {
  234.           sVertHeight = 0;
  235.      }
  236.      if(*pusCurrentRow <= FIRST_ROW || *pusCurrentRow >= LAST_ROW )
  237.      {
  238.           *pusCurrentRow = ( LAST_ROW - asVertHeights[sVertHeight++]) ;
  239.      }
  240.  
  241.      if(*pusCurrentRow < FIRST_ROW || *pusCurrentRow > LAST_ROW )
  242.      {
  243.           *pusCurrentRow = (FIRST_ROW + 1);
  244.      }
  245.      sStartRow = *pusCurrentRow;
  246.      usCount = sizeof(achCell);
  247.      bAttribute = *pbAttribute;
  248.      for(sRow = (*pusCurrentRow + WIDTH); *pusCurrentRow < LAST_ROW && fDraw; (*pusCurrentRow)++ )
  249.      {
  250.           /*
  251.            *read the current attribute
  252.            *on the screen
  253.            *if another worm
  254.            */
  255.           VioReadCellStr(achCell,&usCount,*pusCurrentRow,*pusCurrentCol,hvio);
  256.           if(!fSilent)
  257.           {
  258.                if(achCell[0] != ' ' && fOnce )
  259.                {
  260.                     DosBeep(600,175);
  261.                     DosBeep(1200,175);
  262.                     bAttribute = 0x4F;
  263.                     fOnce = FALSE;
  264.                }
  265.           }
  266.           VioWrtCharStrAtt( &achDownWorm[sPos],1,
  267.                             *pusCurrentRow,*pusCurrentCol,&bAttribute,
  268.                             hvio );
  269.           DosSleep(PAUSE_TIME);
  270.           if(!achUpWorm[sPos++] )
  271.           {
  272.                 for(; sStartRow <= (*pusCurrentRow ) && fDraw;sStartRow++)
  273.                 {
  274.                     VioWrtCharStrAtt( &pszBlank[0],1,
  275.                                       sStartRow,*pusCurrentCol,&bBackGround,
  276.                                       hvio );
  277.                 }
  278.                 sPos = 0;
  279.           }
  280.  
  281.      }
  282.      /*
  283.       *clean off any tail we
  284.       *left behind
  285.       */
  286.      if(sPos)
  287.      {
  288.           for(; sStartRow <= (*pusCurrentRow ) ;sStartRow++)
  289.           {
  290.               VioWrtCharStrAtt( &pszBlank[sPos],1,
  291.                                 sStartRow,*pusCurrentCol,&bBackGround,
  292.                                 hvio );
  293.           }
  294.      }
  295.  
  296.     /*
  297.      *if we stopped drawing
  298.      *come back to the same spot
  299.      */
  300.     if(fDraw)
  301.     {
  302.          *psCurrentDirection = (rand() % MAX_DIRECTIONS);
  303.          *pusCurrentRow = (rand() % HEIGHT);
  304.          *pusCurrentCol = ( (rand() % HOR_WIDTH) /  asWidths[rand() %  4] + 1);
  305.     }
  306.  
  307. }
  308. /****************************************************************\
  309.  *
  310.  *--------------------------------------------------------------
  311.  *
  312.  *  Name:move_worm_up()
  313.  *
  314.  *  Purpose:Redraw the worm moving vertically up the screen.
  315.  *          Draw until the bottom of the screen or fDraw flag has
  316.  *          been reset.
  317.  *
  318.  *  Returns: VOID
  319.  *
  320. \****************************************************************/
  321. VOID move_worm_up(USHORT *pusCurrentRow,USHORT *pusCurrentCol,PBYTE pbAttribute,
  322.                       SHORT *psCurrentDirection,
  323.                       LONG tidWorm )
  324.  
  325. {
  326.  
  327.      USHORT sRow;
  328.      SHORT  sPos;
  329.      SHORT  sStartRow;
  330.      BYTE  bBackGround = WM_BACKGROUND;
  331.      static SHORT sVertHeight = 0;
  332.  
  333.      if(sVertHeight  == (sizeof(asVertHeights) / sizeof(SHORT ) ) )
  334.      {
  335.           sVertHeight = 0;
  336.      }
  337.      if(*pusCurrentRow <= FIRST_ROW || *pusCurrentRow >= LAST_ROW )
  338.      {
  339.           *pusCurrentRow = ( LAST_ROW - asVertHeights[sVertHeight]) ;
  340.      }
  341.      sStartRow = *pusCurrentRow;
  342.      for(sRow = (*pusCurrentRow - WIDTH),sPos = 0;
  343.                             (*pusCurrentRow > FIRST_ROW )&& fDraw;
  344.                             (*pusCurrentRow)--)
  345.      {
  346.           /*
  347.            *read the current attribute
  348.            *on the screen
  349.            *if another worm beep
  350.            */
  351.           VioWrtCharStrAtt( &achUpWorm[sPos],1,
  352.                             *pusCurrentRow,*pusCurrentCol,pbAttribute,
  353.                             hvio );
  354.           DosSleep(PAUSE_TIME);
  355.           if(!achUpWorm[sPos++] )
  356.           {
  357.                 for(; sStartRow >= (*pusCurrentRow ) && fDraw;sStartRow--)
  358.                 {
  359.                     VioWrtCharStrAtt( &pszBlank[0],1,
  360.                                       sStartRow,*pusCurrentCol,&bBackGround,
  361.                                       hvio );
  362.                 }
  363.                 sPos = 0;
  364.           }
  365.  
  366.  
  367.      }
  368.      /*
  369.       *clean up any head on the screen
  370.       */
  371.     if(sPos)
  372.     {
  373.           for(; sStartRow >= (*pusCurrentRow ) ;sStartRow--)
  374.           {
  375.               VioWrtCharStrAtt( &pszBlank[0],1,
  376.                                 sStartRow,*pusCurrentCol,&bBackGround,
  377.                                 hvio );
  378.           }
  379.     }
  380.  
  381.     /*
  382.      *if we stopped drawing
  383.      *come back to the same spot
  384.      */
  385.     if(fDraw)
  386.     {
  387.          *psCurrentDirection = ( rand() % MAX_DIRECTIONS);
  388.          *pusCurrentRow = ( (rand() % HEIGHT)  );
  389.          *pusCurrentCol = ( (rand() % HOR_WIDTH)/  asWidths[rand() %  4] + 1) ;
  390.     }
  391. }
  392.  
  393.  
  394. /****************************************************************\
  395.  *
  396.  *--------------------------------------------------------------
  397.  *
  398.  *  Name:move_worm_right()
  399.  *
  400.  *  Purpose:Move the worm to the right side of the screen and wrap
  401.  *          around.
  402.  *
  403.  *  Returns: VOID
  404.  *
  405. \****************************************************************/
  406. VOID move_worm_right(USHORT *pusCurrentRow,USHORT *pusCurrentCol,PBYTE pbAttribute,
  407.                       SHORT *psCurrentDirection,
  408.                       LONG  tidWorm )
  409.  
  410. {
  411.      SHORT sCol;
  412.      USHORT usSize;
  413.      BYTE  bAttribute;
  414.      BOOL  fOnce = TRUE;
  415.      static SHORT sHorizWidth = 0;
  416.      BYTE  bBackGround = WM_BACKGROUND;
  417.      USHORT usOldRow,usOldCol;
  418.      CHAR  achCell[ MAX_LEN_WORM ];
  419.      USHORT usCount;
  420.  
  421.  
  422.      if(*pusCurrentRow < FIRST_ROW || *pusCurrentRow > LAST_ROW )
  423.      {
  424.           *pusCurrentRow = (FIRST_ROW + 1);
  425.      }
  426.      if(sHorizWidth == (sizeof(asHorizWidths) / sizeof(SHORT ) ) )
  427.      {
  428.           sHorizWidth = 0;
  429.      }
  430.  
  431.      usSize = sizeof(achCell);
  432.      bAttribute = *pbAttribute;
  433.  
  434.      usOldRow = *pusCurrentRow;
  435.      usOldCol = *pusCurrentCol;
  436.      usCount = strlen(pszRightWorm);
  437.      VioReadCellStr(achCell,&usCount,usOldRow,usOldCol,hvio);
  438.      for(sCol = (*pusCurrentCol + asHorizWidths[sHorizWidth++]);
  439.                       (*pusCurrentCol) <= sCol && fDraw;
  440.                            (*pusCurrentCol)++ )
  441.      {
  442.           /*
  443.            *read the current attribute
  444.            *on the screen
  445.            *if another worm
  446.            */
  447.           VioReadCellStr(achCell,&usSize,*pusCurrentRow,*pusCurrentCol,hvio);
  448.           if(!fSilent)
  449.           {
  450.                if(achCell[0] != ' ' && fOnce )
  451.                {
  452.                     DosBeep(600,175);
  453.                     DosBeep(1200,175);
  454.                     bAttribute = 0x4F;
  455.                     fOnce = FALSE;
  456.                }
  457.           }
  458.  
  459.           VioWrtCharStrAtt( pszRightWorm,strlen(pszRightWorm),
  460.                             *pusCurrentRow,*pusCurrentCol,&bAttribute,
  461.                             hvio );
  462.           /*
  463.            *erase the last one
  464.            *by setting the background
  465.            *color
  466.            */
  467.           DosSleep(PAUSE_TIME);
  468.           VioWrtCharStrAtt( pszBlank,strlen(pszRightWorm),
  469.                        *pusCurrentRow,(*pusCurrentCol),&bBackGround,
  470.                        hvio );
  471.  
  472.  
  473.     }
  474.  
  475.     /*
  476.      *if we stopped drawing
  477.      *come back to the same spot
  478.      */
  479.     if(fDraw)
  480.     {
  481.          VioWrtCellStr(achCell,usCount,usOldRow,usOldCol,hvio);
  482.          *psCurrentDirection = (rand() %  MAX_DIRECTIONS);
  483.          *pusCurrentCol = ( (rand() % HOR_WIDTH) + 1/  asWidths[rand() %  4] + 1);
  484.          *pusCurrentRow = ( (rand() % HEIGHT) );
  485.     }
  486.  
  487. }
  488.  
  489.  
  490. /****************************************************************\
  491.  *
  492.  *--------------------------------------------------------------
  493.  *
  494.  *  Name:move_worm_zigup
  495.  *
  496.  *  Purpose:Draw the worm in a diagonal direction moving upwards.
  497.  *
  498.  *  Returns:
  499.  *          VOID
  500. \****************************************************************/
  501. VOID move_worm_zigup(USHORT *pusCurrentRow,USHORT *pusCurrentCol,
  502.                       PBYTE pbAttribute,
  503.                       SHORT *psCurrentDirection,
  504.                       LONG tidWorm )
  505. {
  506.  
  507.      USHORT sRow;
  508.      SHORT  sPos;
  509.      SHORT  sStartRow,sStartCol;
  510.      BYTE  bBackGround = WM_BACKGROUND;
  511.  
  512.      sStartRow = *pusCurrentRow;
  513.      sStartCol = *pusCurrentCol;
  514.      for(sRow = (*pusCurrentRow - WIDTH),sPos = 0;
  515.                             (*pusCurrentRow > FIRST_ROW + 1) && fDraw;
  516.                             (*pusCurrentRow) -=2,(*pusCurrentCol)++ )
  517.      {
  518.           VioWrtCharStrAtt( &achUpWorm[sPos],1,
  519.                             *pusCurrentRow,*pusCurrentCol,pbAttribute,
  520.                             hvio );
  521.           DosSleep(PAUSE_TIME);
  522.           if(!achUpWorm[sPos++] )
  523.           {
  524.                 for(; sStartRow >= (*pusCurrentRow )&& fDraw;sStartRow -=2 ,sStartCol++ )
  525.                 {
  526.                     VioWrtCharStrAtt( &pszBlank[0],1,
  527.                                       sStartRow,sStartCol,&bBackGround,
  528.                                       hvio );
  529.                 }
  530.                 sPos = 0;
  531.           }
  532.  
  533.  
  534.      }
  535.      /*
  536.       *clean up any head on the screen
  537.       */
  538.     if(sPos)
  539.     {
  540.           for(; sStartRow >= (*pusCurrentRow );sStartRow -=2 )
  541.           {
  542.               VioWrtCharStrAtt( &pszBlank[0],1,
  543.                                 sStartRow,sStartCol++,&bBackGround,
  544.                                 hvio );
  545.           }
  546.     }
  547.  
  548.     /*
  549.      *if we stopped drawing
  550.      *come back to the same spot
  551.      */
  552.     if(fDraw)
  553.     {
  554.          *psCurrentDirection = ( rand() % MAX_DIRECTIONS);
  555.          *pusCurrentCol = ( (rand() % HOR_WIDTH)/  asWidths[rand() %  4] + 1);
  556.          *pusCurrentRow = ( (rand() % HEIGHT) );
  557.     }
  558.  
  559. }
  560.  
  561.  
  562. /****************************************************************\
  563.  *
  564.  *--------------------------------------------------------------
  565.  *
  566.  *  Name:move_worm_left()
  567.  *
  568.  *  Purpose:Move the worm to the left side of the screen.
  569.  *
  570.  *  Returns: VOID
  571.  *
  572. \****************************************************************/
  573. VOID move_worm_left(USHORT *pusCurrentRow,USHORT *pusCurrentCol,
  574.                       PBYTE pbAttribute,
  575.                       SHORT *psCurrentDirection,
  576.                       LONG  tidWorm )
  577.  
  578. {
  579.  
  580.      USHORT sCol;
  581.      static SHORT sHorizWidth = 0;
  582.      BYTE  bBackGround = WM_BACKGROUND;
  583.  
  584.  
  585.      if(sHorizWidth == (sizeof(asHorizWidths) / sizeof(SHORT ) ) )
  586.      {
  587.           sHorizWidth = 0;
  588.      }
  589.  
  590.      if(*pusCurrentRow < FIRST_ROW || *pusCurrentRow > LAST_ROW )
  591.      {
  592.           *pusCurrentRow = (LAST_ROW - 1);
  593.      }
  594.     sCol = rand()  % WIDTH;
  595.     if( sCol > *pusCurrentCol)
  596.     {
  597.           sCol = sCol - *pusCurrentCol;
  598.     }
  599.     for( ;((*pusCurrentCol) >  sCol) && fDraw; (*pusCurrentCol)--)
  600.     {
  601.          /*
  602.           *read the current attribute
  603.           *on the screen
  604.           *if another worm
  605.           */
  606.  
  607.          VioWrtCharStrAtt( pszLeftWorm,strlen(pszLeftWorm),
  608.                            *pusCurrentRow,*pusCurrentCol,pbAttribute,
  609.                            hvio );
  610.  
  611.          DosSleep(PAUSE_TIME);
  612.          if(!fDraw)
  613.          {
  614.                break;
  615.          }
  616.          VioWrtCharStrAtt( pszBlank,strlen(pszLeftWorm),
  617.                            *pusCurrentRow,(*pusCurrentCol),&bBackGround,
  618.                             hvio );
  619.  
  620.     }
  621.     /*
  622.      *if we stopped drawing
  623.      *come back to the same spot
  624.      */
  625.     if(fDraw)
  626.     {
  627.           *psCurrentDirection = (rand() %  MAX_DIRECTIONS);
  628.           *pusCurrentRow = ( (rand() % HEIGHT) );
  629.           *pusCurrentCol = ( (rand() % HOR_WIDTH)/  asWidths[rand() %  4]  + 1);
  630.     }
  631. }
  632.  
  633. /*--------------------------------------------------------------*\
  634.  *  End of file : wrmthrd.c
  635. \*--------------------------------------------------------------*/
  636.