home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / C / TEMPLATE / MCURSOR.C < prev    next >
Text File  |  1993-12-01  |  3KB  |  85 lines

  1. //***************************************************************************
  2. // MCURSOR demonstrates the interaction between the mouse graphics cursor
  3. // screen mask and cursor mask in 640 by 480 16-color VGA graphics mode.
  4. //***************************************************************************
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <conio.h>
  9. #include <graph.h>
  10. #include <dos.h>
  11.  
  12. union REGS inregs, outregs;
  13. struct SREGS segregs;
  14.  
  15. unsigned int mask[] = {
  16.      0x0000,           // 0000000000000000  Screen Mask
  17.      0x8001,           // 1000000000000001
  18.      0xC003,           // 1100000000000011
  19.      0xE007,           // 1110000000000111
  20.      0xF00F,           // 1111000000001111
  21.      0xF81F,           // 1111100000011111
  22.      0xFC3F,           // 1111110000111111
  23.      0xFE7F,           // 1111111001111111
  24.      0xFC3F,           // 1111110000111111
  25.      0xF81F,           // 1111100000011111
  26.      0xF00F,           // 1111000000001111
  27.      0xE007,           // 1110000000000111
  28.      0xC003,           // 1100000000000011
  29.      0x8001,           // 1000000000000001
  30.      0x0000,           // 0000000000000000
  31.      0xFFFF,           // 1111111111111111
  32.  
  33.      0x0000,           // 0000000000000000  Cursor Mask
  34.      0x3FFC,           // 0011111111111100
  35.      0x1FF8,           // 0001111111111000
  36.      0x0FF0,           // 0000111111110000
  37.      0x07E0,           // 0000011111100000
  38.      0x03C0,           // 0000001111000000
  39.      0x0180,           // 0000000110000000
  40.      0x0000,           // 0000000000000000
  41.      0x0180,           // 0000000110000000
  42.      0x03C0,           // 0000001111000000
  43.      0x07E0,           // 0000011111100000
  44.      0x0FF0,           // 0000111111110000
  45.      0x1FF8,           // 0001111111111000
  46.      0x3FFC,           // 0011111111111100
  47.      0x0000,           // 0000000000000000
  48.      0x0000            // 0000000000000000
  49. };
  50.  
  51. char fillmask[] = { 0xF0, 0xF0, 0xF0, 0xF0, 0x0F, 0x0F, 0x0F, 0x0F };
  52.  
  53. void main (void)
  54. {
  55.      // Switch to 640 x 480 16-color graphics
  56.      if (!_setvideomode(_VRES16COLOR)) {
  57.            printf("VGA graphics not supported\n");
  58.            exit;
  59.      }
  60.  
  61.      // Clear the screen
  62.      _setcolor(3);
  63.      _rectangle(_GFILLINTERIOR, 0, 0, 639, 479);
  64.      _setfillmask(fillmask);
  65.      _setcolor(4);
  66.      _floodfill(0, 0, 7);
  67.  
  68.      // Define the graphics cursor
  69.      inregs.x.ax = 9;
  70.      inregs.x.bx = 0;
  71.      inregs.x.cx = 0;
  72.      inregs.x.dx = (int) mask;
  73.      segread(&segregs);
  74.      segregs.es = segregs.ds;
  75.      int86x(0x33, &inregs, &outregs, &segregs);
  76.  
  77.      // Display the graphics cursor
  78.      inregs.x.ax = 1;
  79.      int86x(0x33, &inregs, &outregs, &segregs);
  80.  
  81.      // Wait for a keypress and exit
  82.      getch();
  83.      _setvideomode(_TEXTC80);
  84. }
  85.