home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / screen / scrn02 / vcursor.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-03-19  |  2.0 KB  |  81 lines

  1. /*    TITLE    vcursor.c                    
  2. *    AUTHOR    Tim Spencer - Compuserve [73657,1400]
  3. *    DATE    March 13, 1987
  4. */
  5.  
  6.  
  7.  
  8. #include "dos.h"
  9. #include "video.h"
  10.  
  11. void vid_set_cur(row,col)    /* set cursor position */
  12.  int row ;            /* new row number */
  13.  int col ;            /* new column number */
  14.  {
  15.    union REGS inregs , outregs ;
  16.  
  17.    inregs.h.dh = (char)row ;
  18.    inregs.h.dl = (char)col ;
  19.    inregs.x.bx = 0 ;
  20.    inregs.h.ah = V_SET_CUR;
  21.    int86(VID_INT,&inregs,&outregs) ;
  22.  }
  23.  
  24. void vid_get_cur(prow,pcol)    /* get current cursor position */
  25.  int *prow ;            /* store row number here */
  26.  int *pcol ;            /* store column number here */
  27.  {
  28.    union REGS inregs , outregs ;
  29.    
  30.    inregs.x.bx = 0 ;
  31.    inregs.h.ah = V_GET_CUR;
  32.    int86(VID_INT,&inregs,&outregs) ;
  33.    *prow = outregs.h.dh ;
  34.    *pcol = outregs.h.dl ;
  35.  }
  36.  
  37. void vid_cur_rt(num)        /* move cursor right num positions */
  38. int num;
  39. {
  40.     int row, col;
  41.  
  42.     vid_get_cur(&row,&col);
  43.     vid_set_cur(row,col+num);
  44. }
  45.  
  46. /* 
  47. *   vid_cur_switch - turns the blinking cursor on/off. Can also be used
  48. *   to change cursor shape by changing the top and bottom values before
  49. *   sending the interrupt.
  50. */
  51.  
  52. void vid_cur_switch(flag)  /* turns cursor on/off            */
  53.  int flag;          /* flag=0 is off, flag>0 is on    */    
  54.  {
  55.  
  56.     union REGS inregs, outregs;    /* defined in dos.h    */
  57.     int top;            /* top of cursor    */
  58.     int bottom;            /* bottom of cursor    */
  59.     int cols;            /* columns on display    */
  60.  
  61.     if (vid_state(&cols) == MONO_MODE) {  /* is display mono?        */
  62.     top = 12;              /* yes - mono cursor shape    */
  63.     bottom = 13;
  64.     }
  65.     else {            
  66.     top = 6;            /* no - color cursor shape    */
  67.     bottom = 7;
  68.     }
  69.  
  70.     inregs.h.ch = (char)top;        /* put top into ch register    */
  71.     inregs.h.cl = (char)bottom;    /* put bottom into cl register  */
  72.     inregs.h.ah = V_CUR_TYPE;    /* set cursor size signal    */
  73.  
  74.     if (!flag)            /* clear cursor if flag = 0    */
  75.     inregs.x.cx = 0x2000;
  76.     
  77.     int86(VID_INT, &inregs, &outregs);   /* send interrupt      */ 
  78.  
  79. }
  80.  
  81.