home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / FSGFX.ZIP / MYMOUSE.C < prev    next >
C/C++ Source or Header  |  1990-03-06  |  3KB  |  160 lines

  1. /* mymouse.c */
  2. /* library of mouse routines for full screen OS/2 */
  3.  
  4.  
  5. #include <stdio.h>
  6. #include <myproc.h>
  7. #include "mygraph.h"
  8. #include "mymouse.h"
  9.  
  10. extern parameterid;
  11. static int MouseWaitForEventFlag = 1;
  12. static int MouseNoWaitForEventFlag = 0;
  13.  
  14. struct _MOUEVENTINFO MouEvent;
  15.  
  16. long showcursor = 1;
  17. long showcursor2;
  18. int mousex = 0;
  19. int mousey = 0;
  20. int mouseminx = 0;
  21. int mouseminy = 0;
  22. int mousemaxx = 639;
  23. int mousemaxy = 348;
  24. int MouseDeviceStatus = 0x0100;
  25.  
  26. int mousethreadid;
  27. unsigned MouHandle;    /* mouse logical handle */
  28.  
  29. void msinittext(void)
  30. {
  31.     doscall(MouOpen(0L, &MouHandle)); 
  32.     doscall(MouDrawPtr(MouHandle));
  33. }
  34.  
  35. void msstatustext(void)
  36. {
  37.      doscall(MouReadEventQue(&MouEvent, &MouseWaitForEventFlag, MouHandle)); 
  38. }
  39.  
  40. static char cursor[16][9] = 
  41.         {    { 1,0,0,0,0,0,0,0,0 },
  42.             { 1,1,0,0,0,0,0,0,0 },
  43.             { 1,1,1,0,0,0,0,0,0 },
  44.             { 1,1,1,1,0,0,0,0,0 },
  45.             { 1,1,1,1,1,0,0,0,0 },
  46.             { 1,1,1,1,1,1,0,0,0 },
  47.             { 1,1,1,1,1,1,1,0,0 },
  48.             { 1,1,1,1,1,1,1,1,0 },
  49.             { 1,1,1,1,1,1,1,1,1 },
  50.             { 1,1,1,1,1,1,0,0,0 },
  51.             { 1,1,0,0,0,1,1,0,0 },
  52.             { 1,0,0,0,0,1,1,0,0 },
  53.             { 0,0,0,0,0,0,1,1,0 },
  54.             { 0,0,0,0,0,0,1,1,0 },
  55.             { 0,0,0,0,0,0,0,1,1 },
  56.             { 0,0,0,0,0,0,0,1,1 } };
  57. static char cursormask[16][9];
  58.  
  59. void maintaincursor()
  60. {
  61.     int x,y;
  62.     int spot;
  63.     int oldmousex;
  64.     int oldmousey;
  65.     unsigned char uchar;
  66.     start:
  67.  
  68.     MouEvent.col = 320;
  69.     MouEvent.row = 175;
  70.     oldmousex = MouEvent.col;
  71.     oldmousey = MouEvent.row;
  72.  
  73.  
  74.         for(y = 0; y<16; y++)
  75.         {
  76.             for(x = 8; x>=0; x--)
  77.             {
  78.  
  79.                 spot = (80 * (MouEvent.row+y)) + ((MouEvent.col+x)/8);
  80.                 uchar = 0x80 >> ((MouEvent.col+x) % 8 ); 
  81.                 if(*(pchscreen+spot) & uchar)
  82.                     cursormask[y][x] = 1;
  83.                 else
  84.                     cursormask[y][x] = 0; 
  85.                 if(cursor[y][x])
  86.                      *(pchscreen+spot) =  *(pchscreen+spot) | uchar; 
  87.             }
  88.         }
  89.         oldmousex = MouEvent.col;
  90.         oldmousey = MouEvent.row;
  91.  
  92.     while(  1 )
  93.     {
  94.     g_doscall(MouReadEventQue(&MouEvent, &MouseWaitForEventFlag, MouHandle));
  95.         if(MouEvent.col < mouseminx)
  96.             MouEvent.col = mouseminx;
  97.         if(MouEvent.col > mousemaxx)
  98.             MouEvent.col = mousemaxx;
  99.         if(MouEvent.row < mouseminy)
  100.             MouEvent.row = mouseminy;
  101.         if(MouEvent.row < mouseminx)
  102.             MouEvent.row = mouseminy;
  103.  
  104.         for(y = 0; y<16; y++)
  105.         {
  106.             for(x = 8; x>=0; x--)
  107.             {
  108.                 if(cursormask[y][x])
  109.                 {
  110.                     spot = (80 * (oldmousey+y)) + ((oldmousex+x)/8);
  111.                     uchar = 0x80 >> ((oldmousex+x) % 8 ); 
  112.                     *(pchscreen+spot) = *(pchscreen+spot) | uchar;
  113.                 }
  114.                 else
  115.                 {
  116.                     spot = (80 * (oldmousey+y)) + ((oldmousex+x)/8);
  117.                     uchar = 0x80 >> ((oldmousex+x) % 8 ); 
  118.                     uchar = uchar ^ 0xff;
  119.                     *(pchscreen+spot) = *(pchscreen+spot) & uchar;
  120.                 }
  121.             }
  122.         }
  123.  
  124.         for(y = 0; y<16; y++)
  125.         {
  126.             for(x = 8; x>=0; x--)
  127.             {
  128.  
  129.                 spot = (80 * (MouEvent.row+y)) + ((MouEvent.col+x)/8);
  130.                 uchar = 0x80 >> ((MouEvent.col+x) % 8 ); 
  131.                 if(*(pchscreen+spot) & uchar)
  132.                     cursormask[y][x] = 1;
  133.                 else
  134.                     cursormask[y][x] = 0; 
  135.                 if(cursor[y][x])
  136.                      *(pchscreen+spot) =  *(pchscreen+spot) | uchar; 
  137.             }
  138.         }
  139.         oldmousex = MouEvent.col;
  140.         oldmousey = MouEvent.row;
  141.     }
  142. }
  143.  
  144. msinitgrph()
  145. {
  146.     spawnthread(&mousethreadid,maintaincursor);
  147.     g_doscall(DosSetPrty(2,3,31,mousethreadid));
  148. }
  149.  
  150. int mshidecur(void)
  151. {
  152.     ;
  153. }
  154.  
  155. int msshowcur(void)
  156. {
  157.     ;
  158. }
  159.  
  160.