home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / thx / source / utils / mice.cpp < prev    next >
C/C++ Source or Header  |  1995-03-21  |  4KB  |  227 lines

  1. #include <iostream.h>
  2.  
  3. // ---- utility to build mouse mask source code from character strings
  4. char *cn =
  5.     "\x7\x7"
  6.     "                "
  7.     "                "
  8.     "  xxxxxxxxxxxx  "
  9.     "  xx        xx  "
  10.     "  x x      x x  "
  11.     "  x  x    x  x  "
  12.     "  x   x  x   x  "
  13.     "  x    xx    x  "
  14.     "  x    xx    x  "
  15.     "  x   x  x   x  "
  16.     "  x  x    x  x  "
  17.     "  x x      x x  "
  18.     "  xx        xx  "
  19.     "  xxxxxxxxxxxx  "
  20.     "                "
  21.     "                ";
  22.  
  23. char *ul =
  24.     "\0\0"
  25.     "xxxxxxxxxxxxx   "
  26.     "x          x    "
  27.     "x         x     "
  28.     "x        x      "
  29.     "x         x     "
  30.     "x          x    "
  31.     "x           x   "
  32.     "x            x  "
  33.     "x             x "
  34.     "x  x           x"
  35.     "x x x         x "
  36.     "xx   x       x  "
  37.     "x     x     x   "
  38.     "       x   x    "
  39.     "        x x     "
  40.     "         x      ";
  41.  
  42. char *ll =
  43.     "\0\xf"
  44.     "         x      "
  45.     "        x x     "
  46.     "       x   x    "
  47.     "x     x     x   "
  48.     "xx   x       x  "
  49.     "x x x         x "
  50.     "x  x           x"
  51.     "x             x "
  52.     "x            x  "
  53.     "x           x   "
  54.     "x          x    "
  55.     "x         x     "
  56.     "x        x      "
  57.     "x         x     "
  58.     "x          x    "
  59.     "xxxxxxxxxxxxx   ";
  60.  
  61. char *lr =
  62.     "\xf\xf"
  63.     "      x         "
  64.     "     x x        "
  65.     "    x   x       "
  66.     "   x     x     x"
  67.     "  x       x   xx"
  68.     " x         x x x"
  69.     "x           x  x"
  70.     " x             x"
  71.     "  x            x"
  72.     "   x           x"
  73.     "    x          x"
  74.     "     x         x"
  75.     "      x        x"
  76.     "     x         x"
  77.     "    x          x"
  78.     "   xxxxxxxxxxxxx";
  79.  
  80. char *ur =
  81.     "\xf\0"
  82.     "   xxxxxxxxxxxxx"
  83.     "    x          x"
  84.     "     x         x"
  85.     "      x        x"
  86.     "     x         x"
  87.     "    x          x"
  88.     "   x           x"
  89.     "  x            x"
  90.     " x             x"
  91.     "x           x  x"
  92.     " x         x x x"
  93.     "  x       x   xx"
  94.     "   x     x     x"
  95.     "    x   x       "
  96.     "     x x        "
  97.     "      x         ";
  98.  
  99. char *lf =
  100.     "\0\x7" 
  101.     "       xx       "
  102.     "      x x       "
  103.     "     x  x       "
  104.     "    x   xxxxxxxx"
  105.     "   x           x"
  106.     "  x            x"
  107.     " x             x"
  108.     "x              x"
  109.     "x              x"
  110.     " x             x"
  111.     "  x            x"
  112.     "   x           x"
  113.     "    x   xxxxxxxx"
  114.     "     x  x       "
  115.     "      x x       "
  116.     "       xx       ";
  117. char *rt =
  118.     "\xf\x7"
  119.     "       xx       "
  120.     "       x x      "
  121.     "       x  x     "
  122.     "xxxxxxxx   x    "
  123.     "x           x   "
  124.     "x            x  "
  125.     "x             x "
  126.     "x              x"
  127.     "x              x"
  128.     "x             x "
  129.     "x            x  "
  130.     "x           x   "
  131.     "xxxxxxxx   x    "
  132.     "       x  x     "
  133.     "       x x      "
  134.     "       xx       ";
  135. char *up =
  136.     "\x7\0"
  137.     "       xx       "
  138.     "      x  x      "
  139.     "     x    x     "
  140.     "    x      x    "
  141.     "   x        x   "
  142.     "  x          x  "
  143.     " x            x "
  144.     "xxxx        xxxx"
  145.     "   x        x   "
  146.     "   x        x   "
  147.     "   x        x   "
  148.     "   x        x   "
  149.     "   x        x   "
  150.     "   x        x   "
  151.     "   x        x   "
  152.     "   xxxxxxxxxx   ";
  153. char *dn =
  154.     "\x7\xf"
  155.     "   xxxxxxxxxx   "
  156.     "   x        x   "
  157.     "   x        x   "
  158.     "   x        x   "
  159.     "   x        x   "
  160.     "   x        x   "
  161.     "   x        x   "
  162.     "   x        x   "
  163.     "xxxx        xxxx"
  164.     " x            x "
  165.     "  x          x  "
  166.     "   x        x   "
  167.     "    x      x    "
  168.     "     x    x     "
  169.     "      x  x      "
  170.     "       xx       " ;
  171.  
  172. static short int mask[16];
  173.  
  174. static short int cvt(char *cp)
  175. {
  176.     short int rtn = 0;
  177.     short int msk = 0x8000;
  178.     for (int i = 0; i < 16; i++)    {
  179.         if (*(cp+i) != ' ')
  180.             rtn |= msk;
  181.         msk = (msk >> 1) & 0x7fff;
  182.     }
  183.     return rtn;
  184. }
  185.  
  186. static void opint(int i, int msk)
  187. {
  188.     if ((i % 4) == 0)
  189.         cout << "\n\t";
  190.     cout << "0x";
  191.     cout.width(4);
  192.     cout.fill('0');
  193.     cout << hex << (msk & 0xffff);
  194.     if (i < 15)
  195.         cout << ',';
  196. }
  197.  
  198. static void op(char *cp, char *arname)
  199. {
  200.     for (int i = 0; i < 16; i++)
  201.         mask[i] = cvt(cp+2+i*16);
  202.  
  203.     cout << "\nshort int " << arname << "[] = {";
  204.     cout << "\n\t" << dec << (int)*cp << ',' << (int)*(cp+1) << ',';
  205.     for (i = 0; i < 16; i++)
  206.         opint(i, ~mask[i]);
  207.     cout << ',';
  208.     for (i = 0; i < 16; i++)
  209.         opint(i, mask[i]);
  210.  
  211.     cout << "\n};";
  212. }
  213.  
  214. int main()
  215. {
  216.     op(cn, "CENTERCURSOR");
  217.     op(ul, "UPPERLEFTARROWCURSOR");
  218.     op(ur, "UPPERRIGHTARROWCURSOR");
  219.     op(ll, "LOWERLEFTARROWCURSOR");
  220.     op(lr, "LOWERRIGHTARROWCURSOR");
  221.     op(lf, "LEFTARROWCURSOR");
  222.     op(rt, "RIGHTARROWCURSOR");
  223.     op(up, "UPARROWCURSOR");
  224.     op(dn, "DOWNARROWCURSOR");
  225.     return 0;
  226. }
  227.