home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c007 / 23.ddi / CV10.SRC / BCDEMO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-10  |  5.2 KB  |  169 lines

  1. /****************************************************************************/
  2. /***                                                                      ***/
  3. /****************************************************************************/
  4.  
  5. #include <graphics.h>
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <conio.h>
  9. #include <io.h>
  10. #include <dos.h>
  11. #include <stdio.h>
  12. #include <time.h>
  13. #include <string.h>
  14.  
  15. /****************************************************************************/
  16. /***                                                                      ***/
  17. /****************************************************************************/
  18. typedef struct DotFile
  19.          {int Index;
  20.           char *FileName;
  21.          };
  22. struct DotFile DotFiles[]={   {0, "SLST"},
  23.                               {1, "SLFS"},
  24.                               {2, "SLKT"},
  25.                               {3, "SLHT"},
  26.                               {4, "SLWB"},
  27.                               {5, "SLLS"},
  28.                               {6, "SLXY"},
  29.                               {7, "SLBS"},
  30.                               {8, "SLXK"},
  31.                               {11, "SLLB"},
  32.                               {12, "SLDH"},
  33.                               {13, "SLYT"},
  34.                               {14, "SLMH"},
  35.                               {15, "SLSTF"},
  36.                               {16, "SLFSF"},
  37.                               {17, "SLKTF"},
  38.                               {18, "SLHTF"},
  39.                               {21, "SLXYF"},
  40.                               {22, "SLZYF"},
  41.                               {23, "SLLBF"},
  42.                               {24, "SLDHF"},
  43.                               {25, "SLWBF"},
  44.                               {26, "SLXKF"},
  45.                               {27, "SLHBF"},
  46.                               {28, "SLZYIF"},
  47.                              };
  48.  
  49. char  * GetDOTS(unsigned int ccode,int FileIndex, int FHandle, int Width, int Height);
  50. /****************************************************************************/
  51. /***                                                                      ***/
  52. /****************************************************************************/
  53. int quwei(unsigned int hz)
  54.   {
  55.     int number;
  56.     int tmp1,tmp2;
  57.     tmp1= (hz & 0xff) - 160;
  58.     tmp2= (hz & 0xff00)>>8;
  59.     number = tmp1*100 + tmp2-160;
  60.     return number;
  61.   }
  62.  
  63. /****************************************************************************/
  64. /***                                                                      ***/
  65. /****************************************************************************/
  66. main(int args, char *argv[])
  67. {
  68.  int Height=96,hh=120, Width=96,hw=120, Handle;
  69.  unsigned char BitValue[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
  70.  unsigned int ccode=1601,code1,code2,code;
  71.  int i,j,k,m,n,retv;
  72.  char * buf;
  73.  unsigned char hzstr[50];
  74.    /* request auto detection */
  75.    int gdriver = DETECT, gmode, errorcode;
  76.  
  77.  strcpy(hzstr,"╕▀╛½╢╚╩╕┴┐║║╫╓");
  78.  if(args>1)
  79.   {i=atoi(argv[1]);
  80.    if(i>0 && i<=87) ccode=i*100+1;
  81.     else if(i>=1601 && i<=8794)
  82.           {if((j=(i % 100))>=1 && j<=94) ccode=i;
  83.           }
  84.   }
  85.  
  86.    /* initialize graphics mode */
  87.    initgraph(&gdriver, &gmode, "");
  88.  
  89.    /* read result of initialization */
  90.    errorcode = graphresult();
  91.  
  92.    if (errorcode != grOk)  /* an error occurred */
  93.    {
  94.       printf("Graphics error: %s\n", grapherrormsg(errorcode));
  95.       printf("Press any key to halt:");
  96.       getch();
  97.       exit(1);             /* return with error code */
  98.    }
  99.  
  100.    clearviewport();
  101.    setbkcolor(7);
  102.    setcolor(1);
  103.    rectangle(0,0,getmaxx(),getmaxy());
  104.    rectangle(2,2,getmaxx()-2,getmaxy()-2);
  105.    for(i=0; i<20; i++)
  106.     {
  107.      if((Handle=open(DotFiles[i].FileName, 0))!=-1)
  108.       {
  109.  
  110.        code1=hzstr[i*2];
  111.        code2=hzstr[i*2+1];
  112.        code1=code1+(code2<<8);
  113.        code=quwei(code1);
  114.        buf=GetDOTS(code, DotFiles[i].Index, Handle,hw,hh);
  115.        close(Handle);
  116.        if(buf != (unsigned char *)0)
  117.         {for(m=0; m<hw; m++)
  118.           for(n=0; n<hh; n++)
  119.            {j=(m/8)*hh+n;
  120.             k=m % 8;
  121.             if(BitValue[k] & buf[j])
  122.              putpixel((i%5)*hw+6+m,(i/5)*hh+n,1);
  123.            }
  124.         }
  125.       }
  126.     }
  127.  getch();
  128.  
  129.  while(1)
  130.   {if((ccode % 100)>94)
  131.     ccode=((ccode / 100)+1)*100+1;
  132.    if((ccode / 100)>87) ccode=1601;
  133.    clearviewport();
  134.    setbkcolor(7);
  135.    setcolor(1);
  136.    rectangle(0,0,getmaxx(),getmaxy());
  137.    rectangle(2,2,getmaxx()-2,getmaxy()-2);
  138.    for(i=0; i<25; i++)
  139.     {
  140.      if((Handle=open(DotFiles[i].FileName, 0))!=-1)
  141.       {
  142.        buf=GetDOTS(ccode, DotFiles[i].Index, Handle,Width,Height);
  143.        close(Handle);
  144.        if(buf != (unsigned char *)0)
  145.         {for(m=0; m<Width; m++)
  146.           for(n=0; n<Height; n++)
  147.            {j=(m/8)*Height+n;
  148.             k=m % 8;
  149.             if(BitValue[k] & buf[j])
  150.              putpixel((i % 5)*Width+6+m, (i/5)*Height+n,i%8+8);
  151.            }
  152.         }
  153.       }
  154.     }
  155.    ccode++;
  156.    if(kbhit())
  157.     {
  158.      if((i=getch())==0) i=getch()<<8;
  159.      if(i==27) break;
  160.     }
  161.    else
  162.     {for(i=0; i<5000; i++) {} ; delay(1000);
  163.     }
  164.   }
  165.    /* clean up */
  166.    closegraph();
  167.    return 0;
  168. }
  169.