home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / pcw_c.zip / CURSOR.C < prev    next >
Text File  |  1990-04-26  |  2KB  |  82 lines

  1. /**********************************************************/
  2. /* File Id.                  Cursor.C                     */
  3. /* Author.                   Stan Milam.                  */
  4. /* Date Written.             04/05/89.                    */
  5. /*                                                        */
  6. /*           (c) Copyright 1989-90 by Stan Milam          */
  7. /*                                                        */
  8. /* Comments: Routines that affect the cursor.             */
  9. /**********************************************************/
  10.  
  11. #include <dos.h>
  12. #include <string.h>
  13. #include "pcwproto.h"
  14.  
  15. #ifndef NULL
  16. #define NULL 0
  17. #endif
  18.  
  19. static union REGS regs;
  20. static int cols, mode, apage;
  21.  
  22. void set_cursor_size(int tline, int bline) {
  23.  
  24.     if (!ispcwinit()) pcwinit(AUTOEXIT);
  25.     memset(®s, '\0', sizeof(union REGS));
  26.     if (tline == 0 && bline == 0) tline = 0x10;
  27.     regs.x.ax = 0x0100;
  28.     regs.h.ch = (char) tline;
  29.     regs.h.cl = (char) bline;
  30.     int86(0x10,®s,®s);
  31. }
  32.  
  33. void get_cursor_size(int *tline, int *bline) {
  34.  
  35.     if (!ispcwinit()) pcwinit(AUTOEXIT);
  36.     vgetmode(&cols, &mode, &apage);
  37.     memset(®s, '\0', sizeof(union REGS));
  38.     regs.x.ax = 0x0300;
  39.     regs.h.bh = (char) apage;
  40.     int86(0x10, ®s, ®s);
  41.     *tline = (int) regs.h.ch;
  42.     *bline = (int) regs.h.cl;
  43. }
  44.  
  45. void set_cursor_pos(int row, int col) {
  46.  
  47.     if (!ispcwinit()) pcwinit(AUTOEXIT);
  48.     row--; col--;
  49.     vgetmode(&cols, &mode, &apage);
  50.     memset(®s, '\0', sizeof(union REGS));
  51.     regs.x.ax = 0x0200;
  52.     regs.h.bh = (char) apage;
  53.     regs.h.dh = (char) row;
  54.     regs.h.dl = (char) col;
  55.     int86(0x10,®s, ®s);
  56. }
  57.  
  58. void get_cursor_pos(int *row, int *col) {
  59.  
  60.     if (!ispcwinit()) pcwinit(AUTOEXIT);
  61.     vgetmode(&cols, &mode, &apage);
  62.     memset(®s, '\0', sizeof(union REGS));
  63.     regs.x.ax = 0x0300;
  64.     regs.h.bh = (char) apage;
  65.     int86(0x10, ®s, ®s);
  66.     *row = (int) ++regs.h.dh;
  67.     *col = (int) ++regs.h.dl;
  68. }
  69.  
  70. int vgetchr(void) {
  71.  
  72.    int row, col;
  73.  
  74.    if (!ispcwinit()) pcwinit(AUTOEXIT);
  75.    get_cursor_pos(&row, &col);
  76.    memset(®s, '\0', sizeof(union REGS));
  77.    regs.h.ah = 8;
  78.    regs.h.bh = (char) getpage();
  79.    int86(0x10,®s,®s);
  80.    return((int) regs.h.al);
  81. }
  82.