home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / gbmos2pm.zip / gbmvfsa / gbmvfsa.c next >
C/C++ Source or Header  |  1999-01-02  |  24KB  |  1,362 lines

  1. /*
  2.  
  3. gbmvfsa.c - GBM View Full Screen Animation
  4.  
  5. */
  6.  
  7. /*...sincludes:0:*/
  8. #define INCL_BASE
  9. #include <os2.h>
  10. #include <stdio.h>
  11. #include <ctype.h>
  12. #include <stdlib.h>
  13. #include <stdarg.h>
  14. #include <string.h>
  15. #include <malloc.h>
  16. #include <memory.h>
  17. #include <io.h>
  18. #include <fcntl.h>
  19. #include <sys/types.h>
  20. #include <sys/stat.h>
  21. #include "gbm.h"
  22. /*...e*/
  23.  
  24. static char progname[] = "gbmvfsa";
  25.  
  26. /*...sfatal:0:*/
  27. static void fatal(const char *fmt, ...)
  28.     {
  29.     va_list    vars;
  30.     char s[256+1];
  31.  
  32.     va_start(vars, fmt);
  33.     vsprintf(s, fmt, vars);
  34.     va_end(vars);
  35.     fprintf(stderr, "%s: %s\n", progname, s);
  36.     exit(1);
  37.     }
  38. /*...e*/
  39. /*...susage:0:*/
  40. static void usage(void)
  41.     {
  42.     int ft, n_ft;
  43.  
  44.     fprintf(stderr, "usage: %s [-l] [-p] [-s] [-t] [-P] [-b border] n1 n2 n3 fspec{,opt}\n", progname);
  45.     fprintf(stderr, "flags: -l             loop indefinately\n");
  46.     fprintf(stderr, "       -p             set palette only once, assume same\n");
  47.     fprintf(stderr, "       -s             single step the frames\n");
  48.     fprintf(stderr, "       -t             annotate each frame with its title\n");
  49.     fprintf(stderr, "       -P             display palette bar\n");
  50.     fprintf(stderr, "       -b border      set border colour index (default 0)\n");
  51.     fprintf(stderr, "       n1 n2 n3       for ( f=n1; f<n2; f+=n3 )\n");
  52.     fprintf(stderr, "       fspec            printf(fspec, f);\n");
  53.     fprintf(stderr, "                      filespecs are of the form fn.ext\n");
  54.     fprintf(stderr, "                      ext's are used to deduce desired bitmap file formats\n");
  55.  
  56.     gbm_init();
  57.     gbm_query_n_filetypes(&n_ft);
  58.     for ( ft = 0; ft < n_ft; ft++ )
  59.         {
  60.         GBMFT gbmft;
  61.  
  62.         gbm_query_filetype(ft, &gbmft);
  63.         fprintf(stderr, "                      %s when ext in [%s]\n",
  64.             gbmft.short_name, gbmft.extensions);
  65.         }
  66.     gbm_deinit();
  67.  
  68.     fprintf(stderr, "       opt's          bitmap format specific options\n");
  69.     fprintf(stderr, "   eg: %s 0 100 1 frame%%03d.bmp\n", progname);
  70.  
  71.     exit(1);
  72.     }
  73. /*...e*/
  74. /*...sget_opt_value:0:*/
  75. static int get_opt_value(const char *s, const char *name)
  76.     {
  77.     int v;
  78.  
  79.     if ( s == NULL )
  80.         fatal("missing %s argument", name);
  81.     if ( !isdigit(s[0]) )
  82.         fatal("bad %s argument", name);
  83.     if ( s[0] == '0' && tolower(s[1]) == 'x' )
  84.         sscanf(s + 2, "%x", &v);
  85.     else
  86.         v = atoi(s);
  87.  
  88.     return v;
  89.     }
  90. /*...e*/
  91. /*...sget_opt_value_pos:0:*/
  92. static int get_opt_value_pos(const char *s, const char *name)
  93.     {
  94.     int n;
  95.  
  96.     if ( (n = get_opt_value(s, name)) < 0 )
  97.         fatal("%s should not be negative", name);
  98.     return n;
  99.     }
  100. /*...e*/
  101. /*...smain:0:*/
  102. #define    SCN_W 320
  103. #define    SCN_H 200
  104. static byte data[SCN_W*SCN_H];
  105. /*...sread_bitmap_header:0:*/
  106. static BOOLEAN read_bitmap_header(
  107.     const char *fn, const char *opt,
  108.     GBM *gbm, GBMRGB gbmrgb[]
  109.     )
  110.     {
  111.     int ft, fd;
  112.  
  113.     if ( gbm_guess_filetype(fn, &ft) != GBM_ERR_OK )
  114.         return FALSE;
  115.  
  116.     if ( (fd = gbm_io_open(fn, O_RDONLY|O_BINARY)) == -1 )
  117.         return FALSE;
  118.  
  119.     if ( gbm_read_header(fn, fd, ft, gbm, opt) != GBM_ERR_OK )
  120.         {
  121.         gbm_io_close(fd);
  122.         return FALSE;
  123.         }
  124.  
  125.     if ( gbm->bpp != 8 || gbm->w > SCN_W || gbm->h > SCN_H )
  126.         {
  127.         gbm_io_close(fd);
  128.         return FALSE;
  129.         }
  130.  
  131.     if ( gbm_read_palette(fd, ft, gbm, gbmrgb) != GBM_ERR_OK )
  132.         {
  133.         gbm_io_close(fd);
  134.         return FALSE;
  135.         }
  136.  
  137.     gbm_io_close(fd);
  138.     return TRUE;
  139.     }
  140. /*...e*/
  141. /*...sread_bitmap:0:*/
  142. static BOOLEAN read_bitmap(
  143.     const char *fn, const char *opt,
  144.     GBM *gbm, GBMRGB gbmrgb[]
  145.     )
  146.     {
  147.     int ft, fd;
  148.  
  149.     if ( gbm_guess_filetype(fn, &ft) != GBM_ERR_OK )
  150.         return FALSE;
  151.  
  152.     if ( (fd = gbm_io_open(fn, O_RDONLY|O_BINARY)) == -1 )
  153.         return FALSE;
  154.  
  155.     if ( gbm_read_header(fn, fd, ft, gbm, opt) != GBM_ERR_OK )
  156.         {
  157.         gbm_io_close(fd);
  158.         return FALSE;
  159.         }
  160.  
  161.     if ( gbm->bpp != 8 || gbm->w > SCN_W || gbm->h > SCN_H )
  162.         {
  163.         gbm_io_close(fd);
  164.         return FALSE;
  165.         }
  166.  
  167.     if ( gbm_read_palette(fd, ft, gbm, gbmrgb) != GBM_ERR_OK )
  168.         {
  169.         gbm_io_close(fd);
  170.         return FALSE;
  171.         }
  172.  
  173.     if ( gbm_read_data(fd, ft, gbm, data) != GBM_ERR_OK )
  174.         {
  175.         gbm_io_close(fd);
  176.         return FALSE;
  177.         }
  178.  
  179.     gbm_io_close(fd);
  180.     return TRUE;
  181.     }
  182. /*...e*/
  183. /*...sscn:0:*/
  184. static VIOMODEINFO vmiOld;
  185. static BYTE *ptr;
  186.  
  187. /*...sscn_border:0:*/
  188. static void scn_border(byte border)
  189.     {
  190.     VIOOVERSCAN vioos;
  191.  
  192.     vioos.cb = sizeof(VIOOVERSCAN);
  193.     vioos.type = 1; /* Apparently no #define for this */
  194.     vioos.color = border;
  195.     VioSetState(&vioos, (HVIO) 0);
  196.     }
  197. /*...e*/
  198. /*...sscn_palette:0:*/
  199. static void scn_palette(BYTE *palette, int first, int num)
  200.     {
  201.     BYTE *buf = (BYTE *) palette;
  202.     BYTE *_Seg16 buf1616 = (BYTE *_Seg16) buf;
  203.     VIOCOLORREG viocreg;
  204.     viocreg.cb = sizeof(VIOCOLORREG);
  205.     viocreg.type = 3; /* Apparently no #define for this */
  206.     viocreg.firstcolorreg = first;
  207.     viocreg.numcolorregs = num;
  208.  
  209.     /* Note: viocreg.colorregaddr should be of type CHAR *_Seg16
  210.        But it isn't! Hence if I say viocreg.colorregaddr = buf,
  211.        then the correct thunking will not be applied! */
  212.     memcpy(&viocreg.colorregaddr, (const void *) &buf1616, 4);
  213.  
  214.     VioSetState(&viocreg, (HVIO) 0);
  215.     }
  216. /*...e*/
  217. /*...sscn_putimage:0:*/
  218. /*
  219. We are being asked to transfer a w*h image to a SCN_W*SCN_H screen.
  220. If image is smaller than screen, then we will centralise it.
  221. */
  222.  
  223. static void scn_putimage(int w, int h, const unsigned char *data)
  224.     {
  225.     int stride = ((w+3)&~3);
  226.     int xi = (SCN_W-w)/2;
  227.     int yi = (SCN_H-h)/2;
  228.     int y;
  229.     unsigned char *scn = ptr + ((yi*SCN_W) + xi);
  230.     data += (h-1) * stride;
  231.     for ( y = 0; y < h; y++, data -= stride, scn += SCN_W )
  232.         memcpy(scn, data, w);
  233.         /* Note: memcpy expands inline to REP MOVSD under OS/2
  234.            using C-Set++, which is about as fast as you can get */
  235.     }
  236. /*...e*/
  237. /*...sscn_init:0:*/
  238. static void scn_init(void)
  239.     {
  240.     VIOMODEINFO vmi;
  241.     VIOPHYSBUF phys;
  242.     unsigned char *_Seg16 ptr1616;
  243.     unsigned char status;
  244.  
  245.     vmi.cb     = 12;
  246.     vmi.fbType = 3;
  247.     vmi.color  = 8;
  248.     vmi.col    = 40;
  249.     vmi.row    = 25;
  250.     vmi.hres   = SCN_W;
  251.     vmi.vres   = SCN_H;
  252.     VioGetMode(&vmiOld, (HVIO) 0);
  253.     if ( VioSetMode(&vmi, (HVIO) 0) )
  254.         fatal("can't enter 320x200 at 8bpp graphics mode");
  255.     phys.cb = 0x10000;
  256.     phys.pBuf = (PBYTE) 0xa0000;
  257.     if ( VioGetPhysBuf(&phys, 0) )
  258.         fatal("can't get access to physical graphics screen");
  259.     ptr1616 = (unsigned char *_Seg16) ( phys.asel[0] << 16 );
  260.     ptr = (unsigned char *) ptr1616;
  261.     VioScrLock(VP_WAIT, &status, (HVIO) 0);
  262.  
  263.     /* Set all palette entrys to black */
  264.     {
  265.     static BYTE palette[0x100][3];
  266.     memset(palette, 0, sizeof(palette));
  267.     scn_palette((BYTE *) palette, 0, 0x100);
  268.     }
  269.  
  270.     /* Set screen to colour 0, which will get set to black */
  271.     memset(ptr, 0, SCN_W*SCN_H);
  272.     }
  273. /*...e*/
  274. /*...sscn_term:0:*/
  275. static void scn_term(void)
  276.     {
  277.     VioScrUnLock((HVIO) 0);
  278.     VioSetMode(&vmiOld, (HVIO) 0);
  279.     }
  280. /*...e*/
  281. /*...e*/
  282. /*...ssetpal:0:*/
  283. static void setpal(const GBMRGB gbmrgb[])
  284.     {
  285.     BYTE palette[0x100][3];
  286.     int i;
  287.     for ( i = 0; i < 0x100; i++ )
  288.         {
  289.         palette[i][0] = (gbmrgb[i].r>>2);
  290.         palette[i][1] = (gbmrgb[i].g>>2);
  291.         palette[i][2] = (gbmrgb[i].b>>2);
  292.         }
  293.     scn_palette((BYTE *) palette, 0, 0x100);
  294.     }
  295. /*...e*/
  296. /*...stitle:0:*/
  297. static char font[][8][8] =
  298.     {
  299.     0,0,0,0,0,0,0,0,
  300.     0,0,0,0,0,0,0,0,
  301.     0,0,0,0,0,0,0,0,
  302.     0,0,0,0,0,0,0,0,
  303.     0,0,0,0,0,0,0,0,
  304.     0,0,0,0,0,0,0,0,
  305.     0,0,0,0,0,0,0,0,
  306.     0,0,0,0,0,0,0,0,
  307.  
  308.     0,0,0,0,0,0,0,0,
  309.     0,0,0,1,0,0,0,0,
  310.     0,0,0,1,0,0,0,0,
  311.     0,0,0,1,0,0,0,0,
  312.     0,0,0,1,0,0,0,0,
  313.     0,0,0,0,0,0,0,0,
  314.     0,0,0,1,0,0,0,0,
  315.     0,0,0,0,0,0,0,0,
  316.  
  317.     0,0,0,0,0,0,0,0,
  318.     0,0,1,0,0,1,0,0,
  319.     0,0,1,0,0,1,0,0,
  320.     0,0,0,0,0,0,0,0,
  321.     0,0,0,0,0,0,0,0,
  322.     0,0,0,0,0,0,0,0,
  323.     0,0,0,0,0,0,0,0,
  324.     0,0,0,0,0,0,0,0,
  325.  
  326.     0,0,0,0,0,0,0,0,
  327.     0,0,1,0,0,1,0,0,
  328.     0,1,1,1,1,1,1,0,
  329.     0,0,1,0,0,1,0,0,
  330.     0,0,1,0,0,1,0,0,
  331.     0,1,1,1,1,1,1,0,
  332.     0,0,1,0,0,1,0,0,
  333.     0,0,0,0,0,0,0,0,
  334.  
  335.     0,0,0,0,0,0,0,0,
  336.     0,0,0,0,1,0,0,0,
  337.     0,0,1,1,1,1,1,0,
  338.     0,0,1,0,1,0,0,0,
  339.     0,0,1,1,1,1,1,0,
  340.     0,0,0,0,1,0,1,0,
  341.     0,0,1,1,1,1,1,0,
  342.     0,0,0,0,1,0,0,0,
  343.  
  344.     0,0,0,0,0,0,0,0,
  345.     0,1,1,0,0,0,1,0,
  346.     0,1,1,0,0,1,0,0,
  347.     0,0,0,0,1,0,0,0,
  348.     0,0,0,1,0,0,0,0,
  349.     0,0,1,0,0,1,1,0,
  350.     0,1,0,0,0,1,1,0,
  351.     0,0,0,0,0,0,0,0,
  352.  
  353.     0,0,0,0,0,0,0,0,
  354.     0,0,0,1,0,0,0,0,
  355.     0,0,1,0,1,0,0,0,
  356.     0,0,0,1,0,0,0,0,
  357.     0,0,1,0,1,0,1,0,
  358.     0,1,0,0,0,1,0,0,
  359.     0,0,1,1,1,0,1,0,
  360.     0,0,0,0,0,0,0,0,
  361.  
  362.     0,0,0,0,0,0,0,0,
  363.     0,0,0,0,1,0,0,0,
  364.     0,0,0,1,0,0,0,0,
  365.     0,0,0,0,0,0,0,0,
  366.     0,0,0,0,0,0,0,0,
  367.     0,0,0,0,0,0,0,0,
  368.     0,0,0,0,0,0,0,0,
  369.     0,0,0,0,0,0,0,0,
  370.  
  371.     0,0,0,0,0,0,0,0,
  372.     0,0,0,0,0,1,0,0,
  373.     0,0,0,0,1,0,0,0,
  374.     0,0,0,0,1,0,0,0,
  375.     0,0,0,0,1,0,0,0,
  376.     0,0,0,0,1,0,0,0,
  377.     0,0,0,0,0,1,0,0,
  378.     0,0,0,0,0,0,0,0,
  379.  
  380.     0,0,0,0,0,0,0,0,
  381.     0,0,1,0,0,0,0,0,
  382.     0,0,0,1,0,0,0,0,
  383.     0,0,0,1,0,0,0,0,
  384.     0,0,0,1,0,0,0,0,
  385.     0,0,0,1,0,0,0,0,
  386.     0,0,1,0,0,0,0,0,
  387.     0,0,0,0,0,0,0,0,
  388.  
  389.     0,0,0,0,0,0,0,0,
  390.     0,0,0,0,0,0,0,0,
  391.     0,0,0,1,0,1,0,0,
  392.     0,0,0,0,1,0,0,0,
  393.     0,0,1,1,1,1,1,0,
  394.     0,0,0,0,1,0,0,0,
  395.     0,0,0,1,0,1,0,0,
  396.     0,0,0,0,0,0,0,0,
  397.  
  398.     0,0,0,0,0,0,0,0,
  399.     0,0,0,0,0,0,0,0,
  400.     0,0,0,0,1,0,0,0,
  401.     0,0,0,0,1,0,0,0,
  402.     0,0,1,1,1,1,1,0,
  403.     0,0,0,0,1,0,0,0,
  404.     0,0,0,0,1,0,0,0,
  405.     0,0,0,0,0,0,0,0,
  406.  
  407.     0,0,0,0,0,0,0,0,
  408.     0,0,0,0,0,0,0,0,
  409.     0,0,0,0,0,0,0,0,
  410.     0,0,0,0,0,0,0,0,
  411.     0,0,0,0,0,0,0,0,
  412.     0,0,0,0,1,0,0,0,
  413.     0,0,0,0,1,0,0,0,
  414.     0,0,0,1,0,0,0,0,
  415.  
  416.     0,0,0,0,0,0,0,0,
  417.     0,0,0,0,0,0,0,0,
  418.     0,0,0,0,0,0,0,0,
  419.     0,0,0,0,0,0,0,0,
  420.     0,0,1,1,1,1,1,0,
  421.     0,0,0,0,0,0,0,0,
  422.     0,0,0,0,0,0,0,0,
  423.     0,0,0,0,0,0,0,0,
  424.  
  425.     0,0,0,0,0,0,0,0,
  426.     0,0,0,0,0,0,0,0,
  427.     0,0,0,0,0,0,0,0,
  428.     0,0,0,0,0,0,0,0,
  429.     0,0,0,0,0,0,0,0,
  430.     0,0,0,1,1,0,0,0,
  431.     0,0,0,1,1,0,0,0,
  432.     0,0,0,0,0,0,0,0,
  433.  
  434.     0,0,0,0,0,0,0,0,
  435.     0,0,0,0,0,0,0,0,
  436.     0,0,0,0,0,0,1,0,
  437.     0,0,0,0,0,1,0,0,
  438.     0,0,0,0,1,0,0,0,
  439.     0,0,0,1,0,0,0,0,
  440.     0,0,1,0,0,0,0,0,
  441.     0,0,0,0,0,0,0,0,
  442.  
  443.     0,0,0,0,0,0,0,0,
  444.     0,0,1,1,1,1,0,0,
  445.     0,1,0,0,0,1,1,0,
  446.     0,1,0,0,1,0,1,0,
  447.     0,1,0,1,0,0,1,0,
  448.     0,1,1,0,0,0,1,0,
  449.     0,0,1,1,1,1,0,0,
  450.     0,0,0,0,0,0,0,0,
  451.  
  452.     0,0,0,0,0,0,0,0,
  453.     0,0,0,1,1,0,0,0,
  454.     0,0,1,0,1,0,0,0,
  455.     0,0,0,0,1,0,0,0,
  456.     0,0,0,0,1,0,0,0,
  457.     0,0,0,0,1,0,0,0,
  458.     0,0,1,1,1,1,1,0,
  459.     0,0,0,0,0,0,0,0,
  460.  
  461.     0,0,0,0,0,0,0,0,
  462.     0,0,1,1,1,1,0,0,
  463.     0,1,0,0,0,0,1,0,
  464.     0,0,0,0,0,0,1,0,
  465.     0,0,1,1,1,1,0,0,
  466.     0,1,0,0,0,0,0,0,
  467.     0,1,1,1,1,1,1,0,
  468.     0,0,0,0,0,0,0,0,
  469.  
  470.     0,0,0,0,0,0,0,0,
  471.     0,0,1,1,1,1,0,0,
  472.     0,1,0,0,0,0,1,0,
  473.     0,0,0,0,1,1,0,0,
  474.     0,0,0,0,0,0,1,0,
  475.     0,1,0,0,0,0,1,0,
  476.     0,0,1,1,1,1,0,0,
  477.     0,0,0,0,0,0,0,0,
  478.  
  479.     0,0,0,0,0,0,0,0,
  480.     0,0,0,0,1,0,0,0,
  481.     0,0,0,1,1,0,0,0,
  482.     0,0,1,0,1,0,0,0,
  483.     0,1,0,0,1,0,0,0,
  484.     0,1,1,1,1,1,1,0,
  485.     0,0,0,0,1,0,0,0,
  486.     0,0,0,0,0,0,0,0,
  487.  
  488.     0,0,0,0,0,0,0,0,
  489.     0,1,1,1,1,1,1,0,
  490.     0,1,0,0,0,0,0,0,
  491.     0,1,1,1,1,1,0,0,
  492.     0,0,0,0,0,0,1,0,
  493.     0,1,0,0,0,0,1,0,
  494.     0,0,1,1,1,1,0,0,
  495.     0,0,0,0,0,0,0,0,
  496.  
  497.     0,0,0,0,0,0,0,0,
  498.     0,0,1,1,1,1,0,0,
  499.     0,1,0,0,0,0,0,0,
  500.     0,1,1,1,1,1,0,0,
  501.     0,1,0,0,0,0,1,0,
  502.     0,1,0,0,0,0,1,0,
  503.     0,0,1,1,1,1,0,0,
  504.     0,0,0,0,0,0,0,0,
  505.  
  506.     0,0,0,0,0,0,0,0,
  507.     0,1,1,1,1,1,1,0,
  508.     0,0,0,0,0,0,1,0,
  509.     0,0,0,0,0,1,0,0,
  510.     0,0,0,0,1,0,0,0,
  511.     0,0,0,1,0,0,0,0,
  512.     0,0,0,1,0,0,0,0,
  513.     0,0,0,0,0,0,0,0,
  514.  
  515.     0,0,0,0,0,0,0,0,
  516.     0,0,1,1,1,1,0,0,
  517.     0,1,0,0,0,0,1,0,
  518.     0,0,1,1,1,1,0,0,
  519.     0,1,0,0,0,0,1,0,
  520.     0,1,0,0,0,0,1,0,
  521.     0,0,1,1,1,1,0,0,
  522.     0,0,0,0,0,0,0,0,
  523.  
  524.     0,0,0,0,0,0,0,0,
  525.     0,0,1,1,1,1,0,0,
  526.     0,1,0,0,0,0,1,0,
  527.     0,1,0,0,0,0,1,0,
  528.     0,0,1,1,1,1,1,0,
  529.     0,0,0,0,0,0,1,0,
  530.     0,0,1,1,1,1,0,0,
  531.     0,0,0,0,0,0,0,0,
  532.  
  533.     0,0,0,0,0,0,0,0,
  534.     0,0,0,0,0,0,0,0,
  535.     0,0,0,0,0,0,0,0,
  536.     0,0,0,1,0,0,0,0,
  537.     0,0,0,0,0,0,0,0,
  538.     0,0,0,0,0,0,0,0,
  539.     0,0,0,1,0,0,0,0,
  540.     0,0,0,0,0,0,0,0,
  541.  
  542.     0,0,0,0,0,0,0,0,
  543.     0,0,0,0,0,0,0,0,
  544.     0,0,0,1,0,0,0,0,
  545.     0,0,0,0,0,0,0,0,
  546.     0,0,0,0,0,0,0,0,
  547.     0,0,0,1,0,0,0,0,
  548.     0,0,0,1,0,0,0,0,
  549.     0,0,1,0,0,0,0,0,
  550.  
  551.     0,0,0,0,0,0,0,0,
  552.     0,0,0,0,0,0,0,0,
  553.     0,0,0,0,0,1,0,0,
  554.     0,0,0,0,1,0,0,0,
  555.     0,0,0,1,0,0,0,0,
  556.     0,0,0,0,1,0,0,0,
  557.     0,0,0,0,0,1,0,0,
  558.     0,0,0,0,0,0,0,0,
  559.  
  560.     0,0,0,0,0,0,0,0,
  561.     0,0,0,0,0,0,0,0,
  562.     0,0,0,0,0,0,0,0,
  563.     0,0,1,1,1,1,1,0,
  564.     0,0,0,0,0,0,0,0,
  565.     0,0,1,1,1,1,1,0,
  566.     0,0,0,0,0,0,0,0,
  567.     0,0,0,0,0,0,0,0,
  568.  
  569.     0,0,0,0,0,0,0,0,
  570.     0,0,0,0,0,0,0,0,
  571.     0,0,0,1,0,0,0,0,
  572.     0,0,0,0,1,0,0,0,
  573.     0,0,0,0,0,1,0,0,
  574.     0,0,0,0,1,0,0,0,
  575.     0,0,0,1,0,0,0,0,
  576.     0,0,0,0,0,0,0,0,
  577.  
  578.     0,0,0,0,0,0,0,0,
  579.     0,0,1,1,1,1,0,0,
  580.     0,1,0,0,0,0,1,0,
  581.     0,0,0,0,0,1,0,0,
  582.     0,0,0,0,1,0,0,0,
  583.     0,0,0,0,0,0,0,0,
  584.     0,0,0,0,1,0,0,0,
  585.     0,0,0,0,0,0,0,0,
  586.  
  587.     0,0,0,0,0,0,0,0,
  588.     0,0,1,1,1,1,0,0,
  589.     0,1,0,0,1,0,1,0,
  590.     0,1,0,1,0,1,1,0,
  591.     0,1,0,1,1,1,1,0,
  592.     0,1,0,0,0,0,0,0,
  593.     0,0,1,1,1,1,0,0,
  594.     0,0,0,0,0,0,0,0,
  595.  
  596.     0,0,0,0,0,0,0,0,
  597.     0,0,1,1,1,1,0,0,
  598.     0,1,0,0,0,0,1,0,
  599.     0,1,0,0,0,0,1,0,
  600.     0,1,1,1,1,1,1,0,
  601.     0,1,0,0,0,0,1,0,
  602.     0,1,0,0,0,0,1,0,
  603.     0,0,0,0,0,0,0,0,
  604.  
  605.     0,0,0,0,0,0,0,0,
  606.     0,1,1,1,1,1,0,0,
  607.     0,1,0,0,0,0,1,0,
  608.     0,1,1,1,1,1,0,0,
  609.     0,1,0,0,0,0,1,0,
  610.     0,1,0,0,0,0,1,0,
  611.     0,1,1,1,1,1,0,0,
  612.     0,0,0,0,0,0,0,0,
  613.  
  614.     0,0,0,0,0,0,0,0,
  615.     0,0,1,1,1,1,0,0,
  616.     0,1,0,0,0,0,1,0,
  617.     0,1,0,0,0,0,0,0,
  618.     0,1,0,0,0,0,0,0,
  619.     0,1,0,0,0,0,1,0,
  620.     0,0,1,1,1,1,0,0,
  621.     0,0,0,0,0,0,0,0,
  622.  
  623.     0,0,0,0,0,0,0,0,
  624.     0,1,1,1,1,0,0,0,
  625.     0,1,0,0,0,1,0,0,
  626.     0,1,0,0,0,0,1,0,
  627.     0,1,0,0,0,0,1,0,
  628.     0,1,0,0,0,1,0,0,
  629.     0,1,1,1,1,0,0,0,
  630.     0,0,0,0,0,0,0,0,
  631.  
  632.     0,0,0,0,0,0,0,0,
  633.     0,1,1,1,1,1,1,0,
  634.     0,1,0,0,0,0,0,0,
  635.     0,1,1,1,1,1,0,0,
  636.     0,1,0,0,0,0,0,0,
  637.     0,1,0,0,0,0,0,0,
  638.     0,1,1,1,1,1,1,0,
  639.     0,0,0,0,0,0,0,0,
  640.  
  641.     0,0,0,0,0,0,0,0,
  642.     0,1,1,1,1,1,1,0,
  643.     0,1,0,0,0,0,0,0,
  644.     0,1,1,1,1,1,0,0,
  645.     0,1,0,0,0,0,0,0,
  646.     0,1,0,0,0,0,0,0,
  647.     0,1,0,0,0,0,0,0,
  648.     0,0,0,0,0,0,0,0,
  649.  
  650.     0,0,0,0,0,0,0,0,
  651.     0,0,1,1,1,1,0,0,
  652.     0,1,0,0,0,0,1,0,
  653.     0,1,0,0,0,0,0,0,
  654.     0,1,0,0,1,1,1,0,
  655.     0,1,0,0,0,0,1,0,
  656.     0,0,1,1,1,1,0,0,
  657.     0,0,0,0,0,0,0,0,
  658.  
  659.     0,0,0,0,0,0,0,0,
  660.     0,1,0,0,0,0,1,0,
  661.     0,1,0,0,0,0,1,0,
  662.     0,1,1,1,1,1,1,0,
  663.     0,1,0,0,0,0,1,0,
  664.     0,1,0,0,0,0,1,0,
  665.     0,1,0,0,0,0,1,0,
  666.     0,0,0,0,0,0,0,0,
  667.  
  668.     0,0,0,0,0,0,0,0,
  669.     0,0,1,1,1,1,1,0,
  670.     0,0,0,0,1,0,0,0,
  671.     0,0,0,0,1,0,0,0,
  672.     0,0,0,0,1,0,0,0,
  673.     0,0,0,0,1,0,0,0,
  674.     0,0,1,1,1,1,1,0,
  675.     0,0,0,0,0,0,0,0,
  676.  
  677.     0,0,0,0,0,0,0,0,
  678.     0,0,0,0,0,0,1,0,
  679.     0,0,0,0,0,0,1,0,
  680.     0,0,0,0,0,0,1,0,
  681.     0,1,0,0,0,0,1,0,
  682.     0,1,0,0,0,0,1,0,
  683.     0,0,1,1,1,1,0,0,
  684.     0,0,0,0,0,0,0,0,
  685.  
  686.     0,0,0,0,0,0,0,0,
  687.     0,1,0,0,0,1,0,0,
  688.     0,1,0,0,1,0,0,0,
  689.     0,1,1,1,0,0,0,0,
  690.     0,1,0,0,1,0,0,0,
  691.     0,1,0,0,0,1,0,0,
  692.     0,1,0,0,0,0,1,0,
  693.     0,0,0,0,0,0,0,0,
  694.  
  695.     0,0,0,0,0,0,0,0,
  696.     0,1,0,0,0,0,0,0,
  697.     0,1,0,0,0,0,0,0,
  698.     0,1,0,0,0,0,0,0,
  699.     0,1,0,0,0,0,0,0,
  700.     0,1,0,0,0,0,0,0,
  701.     0,1,1,1,1,1,1,0,
  702.     0,0,0,0,0,0,0,0,
  703.  
  704.     0,0,0,0,0,0,0,0,
  705.     0,1,0,0,0,0,1,0,
  706.     0,1,1,0,0,1,1,0,
  707.     0,1,0,1,1,0,1,0,
  708.     0,1,0,0,0,0,1,0,
  709.     0,1,0,0,0,0,1,0,
  710.     0,1,0,0,0,0,1,0,
  711.     0,0,0,0,0,0,0,0,
  712.  
  713.     0,0,0,0,0,0,0,0,
  714.     0,1,0,0,0,0,1,0,
  715.     0,1,1,0,0,0,1,0,
  716.     0,1,0,1,0,0,1,0,
  717.     0,1,0,0,1,0,1,0,
  718.     0,1,0,0,0,1,1,0,
  719.     0,1,0,0,0,0,1,0,
  720.     0,0,0,0,0,0,0,0,
  721.  
  722.     0,0,0,0,0,0,0,0,
  723.     0,0,1,1,1,1,0,0,
  724.     0,1,0,0,0,0,1,0,
  725.     0,1,0,0,0,0,1,0,
  726.     0,1,0,0,0,0,1,0,
  727.     0,1,0,0,0,0,1,0,
  728.     0,0,1,1,1,1,0,0,
  729.     0,0,0,0,0,0,0,0,
  730.  
  731.     0,0,0,0,0,0,0,0,
  732.     0,1,1,1,1,1,0,0,
  733.     0,1,0,0,0,0,1,0,
  734.     0,1,0,0,0,0,1,0,
  735.     0,1,1,1,1,1,0,0,
  736.     0,1,0,0,0,0,0,0,
  737.     0,1,0,0,0,0,0,0,
  738.     0,0,0,0,0,0,0,0,
  739.  
  740.     0,0,0,0,0,0,0,0,
  741.     0,0,1,1,1,1,0,0,
  742.     0,1,0,0,0,0,1,0,
  743.     0,1,0,0,0,0,1,0,
  744.     0,1,0,1,0,0,1,0,
  745.     0,1,0,0,1,0,1,0,
  746.     0,0,1,1,1,1,0,0,
  747.     0,0,0,0,0,0,0,0,
  748.  
  749.     0,0,0,0,0,0,0,0,
  750.     0,1,1,1,1,1,0,0,
  751.     0,1,0,0,0,0,1,0,
  752.     0,1,0,0,0,0,1,0,
  753.     0,1,1,1,1,1,0,0,
  754.     0,1,0,0,0,1,0,0,
  755.     0,1,0,0,0,0,1,0,
  756.     0,0,0,0,0,0,0,0,
  757.  
  758.     0,0,0,0,0,0,0,0,
  759.     0,0,1,1,1,1,0,0,
  760.     0,1,0,0,0,0,0,0,
  761.     0,0,1,1,1,1,0,0,
  762.     0,0,0,0,0,0,1,0,
  763.     0,1,0,0,0,0,1,0,
  764.     0,0,1,1,1,1,0,0,
  765.     0,0,0,0,0,0,0,0,
  766.  
  767.     0,0,0,0,0,0,0,0,
  768.     0,1,1,1,1,1,1,0,
  769.     0,0,0,1,0,0,0,0,
  770.     0,0,0,1,0,0,0,0,
  771.     0,0,0,1,0,0,0,0,
  772.     0,0,0,1,0,0,0,0,
  773.     0,0,0,1,0,0,0,0,
  774.     0,0,0,0,0,0,0,0,
  775.  
  776.     0,0,0,0,0,0,0,0,
  777.     0,1,0,0,0,0,1,0,
  778.     0,1,0,0,0,0,1,0,
  779.     0,1,0,0,0,0,1,0,
  780.     0,1,0,0,0,0,1,0,
  781.     0,1,0,0,0,0,1,0,
  782.     0,0,1,1,1,1,0,0,
  783.     0,0,0,0,0,0,0,0,
  784.  
  785.     0,0,0,0,0,0,0,0,
  786.     0,1,0,0,0,0,1,0,
  787.     0,1,0,0,0,0,1,0,
  788.     0,1,0,0,0,0,1,0,
  789.     0,1,0,0,0,0,1,0,
  790.     0,0,1,0,0,1,0,0,
  791.     0,0,0,1,1,0,0,0,
  792.     0,0,0,0,0,0,0,0,
  793.  
  794.     0,0,0,0,0,0,0,0,
  795.     0,1,0,0,0,0,1,0,
  796.     0,1,0,0,0,0,1,0,
  797.     0,1,0,0,0,0,1,0,
  798.     0,1,0,0,0,0,1,0,
  799.     0,1,0,1,1,0,1,0,
  800.     0,0,1,0,0,1,0,0,
  801.     0,0,0,0,0,0,0,0,
  802.  
  803.     0,0,0,0,0,0,0,0,
  804.     0,1,0,0,0,0,1,0,
  805.     0,0,1,0,0,1,0,0,
  806.     0,0,0,1,1,0,0,0,
  807.     0,0,0,1,1,0,0,0,
  808.     0,0,1,0,0,1,0,0,
  809.     0,1,0,0,0,0,1,0,
  810.     0,0,0,0,0,0,0,0,
  811.  
  812.     0,0,0,0,0,0,0,0,
  813.     1,0,0,0,0,0,1,0,
  814.     0,1,0,0,0,1,0,0,
  815.     0,0,1,0,1,0,0,0,
  816.     0,0,0,1,0,0,0,0,
  817.     0,0,0,1,0,0,0,0,
  818.     0,0,0,1,0,0,0,0,
  819.     0,0,0,0,0,0,0,0,
  820.  
  821.     0,0,0,0,0,0,0,0,
  822.     0,1,1,1,1,1,1,0,
  823.     0,0,0,0,0,1,0,0,
  824.     0,0,0,0,1,0,0,0,
  825.     0,0,0,1,0,0,0,0,
  826.     0,0,1,0,0,0,0,0,
  827.     0,1,1,1,1,1,1,0,
  828.     0,0,0,0,0,0,0,0,
  829.  
  830.     0,0,0,0,0,0,0,0,
  831.     0,0,0,0,1,1,1,0,
  832.     0,0,0,0,1,0,0,0,
  833.     0,0,0,0,1,0,0,0,
  834.     0,0,0,0,1,0,0,0,
  835.     0,0,0,0,1,0,0,0,
  836.     0,0,0,0,1,1,1,0,
  837.     0,0,0,0,0,0,0,0,
  838.  
  839.     0,0,0,0,0,0,0,0,
  840.     0,0,0,0,0,0,0,0,
  841.     0,1,0,0,0,0,0,0,
  842.     0,0,1,0,0,0,0,0,
  843.     0,0,0,1,0,0,0,0,
  844.     0,0,0,0,1,0,0,0,
  845.     0,0,0,0,0,1,0,0,
  846.     0,0,0,0,0,0,0,0,
  847.  
  848.     0,0,0,0,0,0,0,0,
  849.     0,1,1,1,0,0,0,0,
  850.     0,0,0,1,0,0,0,0,
  851.     0,0,0,1,0,0,0,0,
  852.     0,0,0,1,0,0,0,0,
  853.     0,0,0,1,0,0,0,0,
  854.     0,1,1,1,0,0,0,0,
  855.     0,0,0,0,0,0,0,0,
  856.  
  857.     0,0,0,0,0,0,0,0,
  858.     0,0,0,1,0,0,0,0,
  859.     0,0,1,1,1,0,0,0,
  860.     0,1,0,1,0,1,0,0,
  861.     0,0,0,1,0,0,0,0,
  862.     0,0,0,1,0,0,0,0,
  863.     0,0,0,1,0,0,0,0,
  864.     0,0,0,0,0,0,0,0,
  865.  
  866.     0,0,0,0,0,0,0,0,
  867.     0,0,0,0,0,0,0,0,
  868.     0,0,0,0,0,0,0,0,
  869.     0,0,0,0,0,0,0,0,
  870.     0,0,0,0,0,0,0,0,
  871.     0,0,0,0,0,0,0,0,
  872.     0,0,0,0,0,0,0,0,
  873.     1,1,1,1,1,1,1,1,
  874.  
  875.     0,0,0,0,0,0,0,0,
  876.     0,0,0,1,1,1,0,0,
  877.     0,0,1,0,0,0,1,0,
  878.     0,1,1,1,1,0,0,0,
  879.     0,0,1,0,0,0,0,0,
  880.     0,0,1,0,0,0,0,0,
  881.     0,1,1,1,1,1,1,0,
  882.     0,0,0,0,0,0,0,0,
  883.  
  884.     0,0,0,0,0,0,0,0,
  885.     0,0,0,0,0,0,0,0,
  886.     0,0,1,1,1,0,0,0,
  887.     0,0,0,0,0,1,0,0,
  888.     0,0,1,1,1,1,0,0,
  889.     0,1,0,0,0,1,0,0,
  890.     0,0,1,1,1,1,0,0,
  891.     0,0,0,0,0,0,0,0,
  892.  
  893.     0,0,0,0,0,0,0,0,
  894.     0,0,1,0,0,0,0,0,
  895.     0,0,1,0,0,0,0,0,
  896.     0,0,1,1,1,1,0,0,
  897.     0,0,1,0,0,0,1,0,
  898.     0,0,1,0,0,0,1,0,
  899.     0,0,1,1,1,1,0,0,
  900.     0,0,0,0,0,0,0,0,
  901.  
  902.     0,0,0,0,0,0,0,0,
  903.     0,0,0,0,0,0,0,0,
  904.     0,0,0,1,1,1,0,0,
  905.     0,0,1,0,0,0,0,0,
  906.     0,0,1,0,0,0,0,0,
  907.     0,0,1,0,0,0,0,0,
  908.     0,0,0,1,1,1,0,0,
  909.     0,0,0,0,0,0,0,0,
  910.  
  911.     0,0,0,0,0,0,0,0,
  912.     0,0,0,0,0,1,0,0,
  913.     0,0,0,0,0,1,0,0,
  914.     0,0,1,1,1,1,0,0,
  915.     0,1,0,0,0,1,0,0,
  916.     0,1,0,0,0,1,0,0,
  917.     0,0,1,1,1,1,0,0,
  918.     0,0,0,0,0,0,0,0,
  919.  
  920.     0,0,0,0,0,0,0,0,
  921.     0,0,0,0,0,0,0,0,
  922.     0,0,1,1,1,0,0,0,
  923.     0,1,0,0,0,1,0,0,
  924.     0,1,1,1,1,0,0,0,
  925.     0,1,0,0,0,0,0,0,
  926.     0,0,1,1,1,1,0,0,
  927.     0,0,0,0,0,0,0,0,
  928.  
  929.     0,0,0,0,0,0,0,0,
  930.     0,0,0,0,1,1,0,0,
  931.     0,0,0,1,0,0,0,0,
  932.     0,0,0,1,1,0,0,0,
  933.     0,0,0,1,0,0,0,0,
  934.     0,0,0,1,0,0,0,0,
  935.     0,0,0,1,0,0,0,0,
  936.     0,0,0,0,0,0,0,0,
  937.  
  938.     0,0,0,0,0,0,0,0,
  939.     0,0,0,0,0,0,0,0,
  940.     0,0,1,1,1,1,0,0,
  941.     0,1,0,0,0,1,0,0,
  942.     0,1,0,0,0,1,0,0,
  943.     0,0,1,1,1,1,0,0,
  944.     0,0,0,0,0,1,0,0,
  945.     0,0,1,1,1,0,0,0,
  946.  
  947.     0,0,0,0,0,0,0,0,
  948.     0,1,0,0,0,0,0,0,
  949.     0,1,0,0,0,0,0,0,
  950.     0,1,1,1,1,0,0,0,
  951.     0,1,0,0,0,1,0,0,
  952.     0,1,0,0,0,1,0,0,
  953.     0,1,0,0,0,1,0,0,
  954.     0,0,0,0,0,0,0,0,
  955.  
  956.     0,0,0,0,0,0,0,0,
  957.     0,0,0,1,0,0,0,0,
  958.     0,0,0,0,0,0,0,0,
  959.     0,0,1,1,0,0,0,0,
  960.     0,0,0,1,0,0,0,0,
  961.     0,0,0,1,0,0,0,0,
  962.     0,0,1,1,1,0,0,0,
  963.     0,0,0,0,0,0,0,0,
  964.  
  965.     0,0,0,0,0,0,0,0,
  966.     0,0,0,0,0,1,0,0,
  967.     0,0,0,0,0,0,0,0,
  968.     0,0,0,0,0,1,0,0,
  969.     0,0,0,0,0,1,0,0,
  970.     0,0,0,0,0,1,0,0,
  971.     0,0,1,0,0,1,0,0,
  972.     0,0,0,1,1,0,0,0,
  973.  
  974.     0,0,0,0,0,0,0,0,
  975.     0,0,1,0,0,0,0,0,
  976.     0,0,1,0,1,0,0,0,
  977.     0,0,1,1,0,0,0,0,
  978.     0,0,1,1,0,0,0,0,
  979.     0,0,1,0,1,0,0,0,
  980.     0,0,1,0,0,1,0,0,
  981.     0,0,0,0,0,0,0,0,
  982.  
  983.     0,0,0,0,0,0,0,0,
  984.     0,0,0,1,0,0,0,0,
  985.     0,0,0,1,0,0,0,0,
  986.     0,0,0,1,0,0,0,0,
  987.     0,0,0,1,0,0,0,0,
  988.     0,0,0,1,0,0,0,0,
  989.     0,0,0,0,1,1,0,0,
  990.     0,0,0,0,0,0,0,0,
  991.  
  992.     0,0,0,0,0,0,0,0,
  993.     0,0,0,0,0,0,0,0,
  994.     0,1,1,0,1,0,0,0,
  995.     0,1,0,1,0,1,0,0,
  996.     0,1,0,1,0,1,0,0,
  997.     0,1,0,1,0,1,0,0,
  998.     0,1,0,1,0,1,0,0,
  999.     0,0,0,0,0,0,0,0,
  1000.  
  1001.     0,0,0,0,0,0,0,0,
  1002.     0,0,0,0,0,0,0,0,
  1003.     0,1,1,1,1,0,0,0,
  1004.     0,1,0,0,0,1,0,0,
  1005.     0,1,0,0,0,1,0,0,
  1006.     0,1,0,0,0,1,0,0,
  1007.     0,1,0,0,0,1,0,0,
  1008.     0,0,0,0,0,0,0,0,
  1009.  
  1010.     0,0,0,0,0,0,0,0,
  1011.     0,0,0,0,0,0,0,0,
  1012.     0,0,1,1,1,0,0,0,
  1013.     0,1,0,0,0,1,0,0,
  1014.     0,1,0,0,0,1,0,0,
  1015.     0,1,0,0,0,1,0,0,
  1016.     0,0,1,1,1,0,0,0,
  1017.     0,0,0,0,0,0,0,0,
  1018.  
  1019.     0,0,0,0,0,0,0,0,
  1020.     0,0,0,0,0,0,0,0,
  1021.     0,1,1,1,1,0,0,0,
  1022.     0,1,0,0,0,1,0,0,
  1023.     0,1,0,0,0,1,0,0,
  1024.     0,1,1,1,1,0,0,0,
  1025.     0,1,0,0,0,0,0,0,
  1026.     0,1,0,0,0,0,0,0,
  1027.  
  1028.     0,0,0,0,0,0,0,0,
  1029.     0,0,0,0,0,0,0,0,
  1030.     0,0,1,1,1,1,0,0,
  1031.     0,1,0,0,0,1,0,0,
  1032.     0,1,0,0,0,1,0,0,
  1033.     0,0,1,1,1,1,0,0,
  1034.     0,0,0,0,0,1,0,0,
  1035.     0,0,0,0,0,1,1,0,
  1036.  
  1037.     0,0,0,0,0,0,0,0,
  1038.     0,0,0,0,0,0,0,0,
  1039.     0,0,0,1,1,1,0,0,
  1040.     0,0,1,0,0,0,0,0,
  1041.     0,0,1,0,0,0,0,0,
  1042.     0,0,1,0,0,0,0,0,
  1043.     0,0,1,0,0,0,0,0,
  1044.     0,0,0,0,0,0,0,0,
  1045.  
  1046.     0,0,0,0,0,0,0,0,
  1047.     0,0,0,0,0,0,0,0,
  1048.     0,0,1,1,1,0,0,0,
  1049.     0,1,0,0,0,0,0,0,
  1050.     0,0,1,1,1,0,0,0,
  1051.     0,0,0,0,0,1,0,0,
  1052.     0,1,1,1,1,0,0,0,
  1053.     0,0,0,0,0,0,0,0,
  1054.  
  1055.     0,0,0,0,0,0,0,0,
  1056.     0,0,0,1,0,0,0,0,
  1057.     0,0,1,1,1,0,0,0,
  1058.     0,0,0,1,0,0,0,0,
  1059.     0,0,0,1,0,0,0,0,
  1060.     0,0,0,1,0,0,0,0,
  1061.     0,0,0,0,1,1,0,0,
  1062.     0,0,0,0,0,0,0,0,
  1063.  
  1064.     0,0,0,0,0,0,0,0,
  1065.     0,0,0,0,0,0,0,0,
  1066.     0,1,0,0,0,1,0,0,
  1067.     0,1,0,0,0,1,0,0,
  1068.     0,1,0,0,0,1,0,0,
  1069.     0,1,0,0,0,1,0,0,
  1070.     0,0,1,1,1,0,0,0,
  1071.     0,0,0,0,0,0,0,0,
  1072.  
  1073.     0,0,0,0,0,0,0,0,
  1074.     0,0,0,0,0,0,0,0,
  1075.     0,1,0,0,0,1,0,0,
  1076.     0,1,0,0,0,1,0,0,
  1077.     0,0,1,0,1,0,0,0,
  1078.     0,0,1,0,1,0,0,0,
  1079.     0,0,0,1,0,0,0,0,
  1080.     0,0,0,0,0,0,0,0,
  1081.  
  1082.     0,0,0,0,0,0,0,0,
  1083.     0,0,0,0,0,0,0,0,
  1084.     0,1,0,0,0,1,0,0,
  1085.     0,1,0,1,0,1,0,0,
  1086.     0,1,0,1,0,1,0,0,
  1087.     0,1,0,1,0,1,0,0,
  1088.     0,0,1,0,1,0,0,0,
  1089.     0,0,0,0,0,0,0,0,
  1090.  
  1091.     0,0,0,0,0,0,0,0,
  1092.     0,0,0,0,0,0,0,0,
  1093.     0,1,0,0,0,1,0,0,
  1094.     0,0,1,0,1,0,0,0,
  1095.     0,0,0,1,0,0,0,0,
  1096.     0,0,1,0,1,0,0,0,
  1097.     0,1,0,0,0,1,0,0,
  1098.     0,0,0,0,0,0,0,0,
  1099.  
  1100.     0,0,0,0,0,0,0,0,
  1101.     0,0,0,0,0,0,0,0,
  1102.     0,1,0,0,0,1,0,0,
  1103.     0,1,0,0,0,1,0,0,
  1104.     0,1,0,0,0,1,0,0,
  1105.     0,0,1,1,1,1,0,0,
  1106.     0,0,0,0,0,1,0,0,
  1107.     0,0,1,1,1,0,0,0,
  1108.  
  1109.     0,0,0,0,0,0,0,0,
  1110.     0,0,0,0,0,0,0,0,
  1111.     0,1,1,1,1,1,0,0,
  1112.     0,0,0,0,1,0,0,0,
  1113.     0,0,0,1,0,0,0,0,
  1114.     0,0,1,0,0,0,0,0,
  1115.     0,1,1,1,1,1,0,0,
  1116.     0,0,0,0,0,0,0,0,
  1117.  
  1118.     0,0,0,0,0,0,0,0,
  1119.     0,0,0,0,1,1,0,0,
  1120.     0,0,0,1,0,0,0,0,
  1121.     0,0,0,1,0,0,0,0,
  1122.     0,0,1,0,0,0,0,0,
  1123.     0,0,0,1,0,0,0,0,
  1124.     0,0,0,0,1,1,0,0,
  1125.     0,0,0,0,0,0,0,0,
  1126.  
  1127.     0,0,0,0,0,0,0,0,
  1128.     0,0,0,0,1,0,0,0,
  1129.     0,0,0,0,1,0,0,0,
  1130.     0,0,0,0,1,0,0,0,
  1131.     0,0,0,0,1,0,0,0,
  1132.     0,0,0,0,1,0,0,0,
  1133.     0,0,0,0,1,0,0,0,
  1134.     0,0,0,0,0,0,0,0,
  1135.  
  1136.     0,0,0,0,0,0,0,0,
  1137.     0,0,1,1,0,0,0,0,
  1138.     0,0,0,0,1,0,0,0,
  1139.     0,0,0,0,1,0,0,0,
  1140.     0,0,0,0,0,1,0,0,
  1141.     0,0,0,0,1,0,0,0,
  1142.     0,0,1,1,0,0,0,0,
  1143.     0,0,0,0,0,0,0,0,
  1144.  
  1145.     0,0,0,0,0,0,0,0,
  1146.     0,0,1,1,0,0,1,0,
  1147.     0,1,0,0,1,1,0,0,
  1148.     0,0,0,0,0,0,0,0,
  1149.     0,0,0,0,0,0,0,0,
  1150.     0,0,0,0,0,0,0,0,
  1151.     0,0,0,0,0,0,0,0,
  1152.     0,0,0,0,0,0,0,0,
  1153.  
  1154.     0,0,0,0,0,0,0,0,
  1155.     0,0,0,0,0,0,0,0,
  1156.     0,0,0,0,1,0,0,0,
  1157.     0,0,0,1,0,1,0,0,
  1158.     0,0,1,0,0,0,1,0,
  1159.     0,0,1,0,0,0,1,0,
  1160.     0,0,1,1,1,1,1,0,
  1161.     0,0,0,0,0,0,0,0,
  1162.     };
  1163.  
  1164. static void plot_character(int x, int y, char c)
  1165.     {
  1166.     int i, j;
  1167.     if ( c < ' ' || c > 127 )
  1168.         return;
  1169.     for ( j = 0; j < 8; j++ )
  1170.         for ( i = 0; i < 8; i++ )
  1171.             if ( font[c-' '][j][i] )
  1172.                 ptr[(y+j)*SCN_W+(x+i)] = 0;
  1173.             else
  1174.                 ptr[(y+j)*SCN_W+(x+i)] = 0xff;
  1175.     }
  1176.  
  1177. static void plot_string(int x, int y, char *s)
  1178.     {
  1179.     while ( x+8 <= SCN_W && *s != '\0' )
  1180.         {
  1181.         plot_character(x, y, *s++);
  1182.         x += 8;
  1183.         }
  1184.     }
  1185. /*...e*/
  1186.  
  1187. int main(int argc, char *argv[])
  1188.     {
  1189.     char fn[500+1], *opt;
  1190.     BOOLEAN    loop = FALSE, onepal = FALSE, quit = FALSE, sstep = FALSE;
  1191.     BOOLEAN title = FALSE, palbar = FALSE;
  1192.     int i, f, first, last, step, w, h, border = 0;
  1193.     char fn_f[500+1];
  1194.     GBM gbm; GBMRGB gbmrgb[0x100];
  1195.  
  1196. /*...sparse any options:8:*/
  1197. for ( i = 1; i < argc; i++ )
  1198.     {
  1199.     if ( argv[i][0] != '-' )
  1200.         break;
  1201.     switch ( argv[i][1] )
  1202.         {
  1203.         case 'l':    loop   = TRUE;    break;
  1204.         case 'p':    onepal = TRUE;    break;
  1205.         case 's':    sstep  = TRUE;    break;
  1206.         case 't':    title  = TRUE;    break;
  1207.         case 'P':    palbar = TRUE;    break;
  1208.         case 'b':
  1209.             if ( ++i == argc ) usage();
  1210.             border = get_opt_value_pos(argv[i], "border");
  1211.             if ( border > 255 )
  1212.                 fatal("border should be in the range 0 to 255");
  1213.             break;
  1214.         default:    usage();    break;
  1215.         }
  1216.     }
  1217. /*...e*/
  1218. /*...sframes and filenames:8:*/
  1219. if ( i == argc )
  1220.     usage();
  1221. sscanf(argv[i++], "%d", &first);
  1222.  
  1223. if ( i == argc )
  1224.     usage();
  1225. sscanf(argv[i++], "%d", &last);
  1226.  
  1227. if ( i == argc )
  1228.     usage();
  1229. sscanf(argv[i++], "%d", &step);
  1230.  
  1231. if ( i == argc )
  1232.     usage();
  1233. strcpy(fn, argv[i++]);
  1234.  
  1235. if ( (opt = strchr(fn, ',')) != NULL )
  1236.     *opt++ = '\0';
  1237. else
  1238.     opt = "";
  1239. /*...e*/
  1240.  
  1241.     if ( first == last )
  1242.         exit(0);
  1243.  
  1244.     gbm_init();
  1245.  
  1246.     sprintf(fn_f, fn, first);
  1247.     if ( !read_bitmap_header(fn_f, opt, &gbm, gbmrgb) )
  1248.         fatal("can't read header of first bitmap %s", fn_f);
  1249.     if ( gbm.bpp != 8 )
  1250.         fatal("%s is not 8bpp", fn_f);
  1251.     if ( gbm.w > SCN_W || gbm.h > SCN_H )
  1252.         fatal("%s is %dx%d, largest allowed is %dx%d",
  1253.             fn_f, gbm.w, gbm.h, SCN_W, SCN_H);
  1254.     w = gbm.w; h = gbm.h;
  1255.  
  1256.     scn_init();
  1257.     scn_border(border);
  1258.     memset(ptr, border, SCN_W*SCN_H);
  1259.  
  1260.     if ( onepal )
  1261.         setpal(gbmrgb);
  1262.  
  1263.     do
  1264.         for ( f = first; !quit && f < last; f += step )
  1265.             {
  1266.             sprintf(fn_f, fn, f);
  1267.             if ( !read_bitmap(fn_f, opt, &gbm, gbmrgb) )
  1268.                 {
  1269.                 scn_term();
  1270.                 fatal("can't load %s", fn_f);
  1271.                 }
  1272.             if ( gbm.w != w || gbm.h != h )
  1273.                 {
  1274.                 scn_term();
  1275.                 fatal("%s is %dx%d, previous ones were %dx%d",
  1276.                     fn_f, gbm.w, gbm.h, w, h);
  1277.                 }
  1278.             if ( !onepal )
  1279.                 setpal(gbmrgb);
  1280.             scn_putimage(w, h, data);
  1281.  
  1282.             if ( title )
  1283.                 plot_string(0, SCN_H-8, fn_f);
  1284.  
  1285.             if ( palbar )
  1286.                 {
  1287.                 int i, j;
  1288.                 for ( j = 0; j < 5; j++ )
  1289.                     for ( i = 0; i < 0x100; i++ )
  1290.                         ptr[(SCN_H-10-j)*SCN_W+i] = (byte) i;
  1291.                 }
  1292.  
  1293. /*...shandle keyboard interaction:24:*/
  1294. {
  1295. KBDKEYINFO kki;
  1296. BOOLEAN process_char;
  1297.  
  1298. kki.chChar = '\0';
  1299.  
  1300. if ( sstep )
  1301.     {
  1302.     do
  1303.         KbdCharIn(&kki, IO_WAIT, (HKBD) 0);
  1304.     while (    kki.chScan == '\0' || kki.chChar == '\0' );
  1305.     process_char = TRUE;
  1306.     }
  1307. else
  1308.     process_char = ( KbdCharIn(&kki, IO_NOWAIT, (HKBD) 0) == 0 &&
  1309.              kki.chScan != '\0' && kki.chChar != '\0' );
  1310.  
  1311. if ( process_char )
  1312.     {
  1313.     if ( isdigit(kki.chChar) )
  1314.         {
  1315.         f = last - first;
  1316.         f = (f * (kki.chChar-'0'))/10;
  1317.         f = (f / step) * step;
  1318.         f += first;
  1319.         f -= step;
  1320.         }
  1321.     else
  1322.         switch ( kki.chChar )
  1323.             {
  1324.             case '-':
  1325.                 if ( f > first )
  1326.                     f -= 2 * step;
  1327.                 else
  1328.                     f = -step;
  1329.                 break;
  1330.             case 's': case 'S':
  1331.                 sstep = TRUE;
  1332.                 break;
  1333.             case 'g': case 'G':
  1334.                 sstep = FALSE;
  1335.                 break;
  1336.             case 't': case 'T':
  1337.                 title = !title;
  1338.                 f -= step;
  1339.                 break;
  1340.             case 'p': case 'P':
  1341.                 palbar = !palbar;
  1342.                 f -= step;
  1343.                 break;
  1344.             case 'q': case 'Q':
  1345.             case 'x': case 'X':
  1346.             case 0x1b: /* Escape */
  1347.                 quit = TRUE;
  1348.                 break;
  1349.             }
  1350.     }
  1351. }
  1352. /*...e*/
  1353.             }
  1354.     while ( loop && !quit );
  1355.  
  1356.     scn_term();
  1357.     gbm_deinit();
  1358.  
  1359.     return 0;
  1360.     }
  1361. /*...e*/
  1362.