⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 char8x8.c

📁 单片PLC,AT2581实现梯形图功能,可作为参考
💻 C
字号:
/*
 *  Released under the GNU GPL.  See http://www.gnu.org/licenses/gpl.txt
 *
 *  This program is part of TinyPLC
 *
 *  TinyPLC is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundatation; version 2 of the License.
 *
 *  TinyPLC is distributed in the hope that it will be useful, but WITHOUT
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 *  for more details.
 */
/*
 *  My thanks to my employer, Athena Controls (www.athenacontrols.com)
 *  for allowing me to open source this project.
 */
/*
 *  TinyPLC kernel
 *  Processor:   Atmel MEGA1281 or Atmel MEGA2561
 *  Compiler:    Codevision AVR C compiler, 1.24.8e
 *
 *  TinyPLC editor/compiler
 *  Processor:   PC-clone, VESA video (mode 0x105, 1024x768x256)
 *  Compiler:    DeSmet C, version 2.51 (PCC version 1.2)
 *
 *  Revision history:
 *  Programmer        Date       Comments
 *  ----------------  ---------  ---------------------------------------------
 *  William Couture   3/19/2006  Original code
 *  William Couture   9/13/2006  Modify for GPL release
 */
/* This program is a "helper" program for the TinyPLC editor/compiler.
 * It takes a character set from CHEDIT.EXE and turns it into
 * initialization statements for data within PLC.EXE
 */
typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef long DWORD;  /* unsigned would be nice, but... */

#define TRUE 1
#define FALSE 0

BYTE charset[1024];

int filein;

int rotate;
int upper;

main(argc, argv)
   WORD argc;
   BYTE *argv[];
   {
   int i, j, k, l, m, n, c;

   for (i = 1; i < argc; i++)
      {
      if (argv[i][0] == '-')
         {
         switch(toupper(argv[i][1]))
            {
            case 'R':  /* Rotate */
               rotate = TRUE;
               break;
            case 'U':
               upper = 128;
               break;
            default:
               help();  /* this does not return */
               break;
            }
         for (j = i; j < argc-1; j++)
            argv[j] = argv[j+1];
         argc--;
         i--;  /* remove this cmdline parameter */
         }
      }
   if (argc < 2)
      help();  /* does not return */
   if ((filein = open(argv[1],0)) == -1)
      help();
   if (read(filein,charset,1024) != 1024)
      help();
   close(filein);
   for (i = 0; i < 128; i++)
      {
      printf("  ");
      for (k = 0x80, j = 0; j < 8; j++, k >>= 1)
         {
         m = i * 8;
         c = 0;
         if (rotate)
            {
            for (n = 0x10, l = 0; l < 8; l++, n >>= 1)
               {
               if (charset[m+l] & k)
                  c |= n;
                }
            }
         else
            {
            c = charset[m+j];
            }
         printf(" 0x%02x",c);
         if (j != 7)
            printf(",");
         }
      if (i != 127)
         printf(", /* %3d: ",upper+i);
      else
         printf("  /* %3d: ",upper+i);
      printchar(upper+i);
      printf(" */\n");
      }
   }

BYTE *charnames[] =
   {
   "<nul>",
   "LEFT_EDGE",
   "RIGHT_EDGE",
   "VERT_BAR, BOX_TOPBAR",
   "START_NO_IN",
   "END_NO_IN",
   "START_NC_IN",
   "END_NC_IN",
   "START_NO_OUT",
   "END_NO_OUT",
   "START_NC_OUT",
   "END_NC_OUT",
   "SCROLL_UPARROW",
   "SCROLL_DOWNARROW",
   "SCROLL_BAR",
   "BRANCH_BAR",
   "START_BRANCH",
   "END_BRANCH",
   "EXPAND_BRANCH",
   "OR_VERT_T",
   "OR_VERT_BAR, BOX_SIDEBAR",
   "OR_LEFT, BOX_BOTTOM_LEFT",
   "OR_RIGHT, BOX_BOTTOM_RIGHT",
   "BOX_TOP_LEFT",
   "BOX_TOP_RIGHT",
   "OR_LEFT_T",
   "OR_RIGHT_T",
   "MOUSE_CURSOR",
   "SCROLL_BOX",
   "<blank>",
   "<blank>",
   "<blank>",
   "<spc>"
   };

printchar(c)
   BYTE c;
   {
   if (c <= ' ')
      printf("%s",charnames[c]);
   else
      printf("%c",c);
   }

help()
   {
   printf("Error: CHAR8X8 filename.ext > newname.ext\n");
   exit(1);
   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -