home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 328_02 / wgoto.c < prev    next >
C/C++ Source or Header  |  1991-03-17  |  2KB  |  95 lines

  1.  
  2. /*! wgoto
  3.  *
  4.  *
  5.  *    position the cursor, hide and restore the cursor
  6.  *
  7.  *
  8.  * use : valid positions are 0  <= row <= winymax
  9.  *             and 0t <= col <= winxmax
  10.  *
  11.  * calling with -1 produces no movement
  12.  * this is used internally to move the cursor in other routines
  13.  *
  14.  *        if row = -1 and col = nn, will set to col nn on current row
  15.  *                           (allows horizontal movement)
  16.  *        if col = -1 and row = nn, will set to row nn at current col
  17.  *                     (allows vertical alignment)
  18.  *
  19.  *
  20.  */
  21. #include  "wscreen.h"
  22. #include  "wsys.h"
  23.  
  24.  
  25. #include <dos.h>
  26.  
  27.  
  28. void wgoto(int col, int row)
  29.     {
  30.     PSEUDOREGS
  31.  
  32.  
  33.     int page;
  34.     int rowabs, colabs;
  35.  
  36.  
  37.  
  38.  
  39.  
  40.     /* calls with -1 mean use current row or col
  41.      */
  42.     if ( row == -1 )
  43.         {
  44.         row = w0-> winy;
  45.         }
  46.  
  47.     if  ( col == -1)
  48.         {
  49.         col = w0-> winx;
  50.         }
  51.  
  52.  
  53.  
  54.     /* is request out of current window ? */
  55.     if (  col > w0-> winxmax
  56.        || row > w0-> winymax
  57.        || row < 0
  58.        || col < 0            )
  59.         {
  60.         return;
  61.         }
  62.  
  63.     /* use new co-ords
  64.      */
  65.     w0-> winy     = row;
  66.     w0-> winx     = col;
  67.  
  68.  
  69.  
  70.  
  71.     if (wmode == 'T' && ( (w0-> winflag) & WFL_CURSOR ) )
  72.         {
  73.  
  74.         /* NOTE that using TurboC's pseudoregs
  75.          * means all far * calculations have to
  76.          * be done before loading regs.
  77.          */
  78.  
  79.         page = w0-> winpage;
  80.         rowabs = row + w0-> wintop;
  81.         colabs = col + w0-> winleft;
  82.  
  83.         _DH = rowabs;
  84.         _DL = colabs;
  85.         _BH = page;  /* video page taken from active window */
  86.         _AH = 2;  /* function to set cursor */
  87.         INTERRUPT(0x10);
  88.  
  89.         }
  90.  
  91.     return;
  92.  
  93.  
  94.     }    /*end of wgoto routine */
  95.