home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / ft-beta.zip / freetype / lib / ttdebug.c < prev    next >
C/C++ Source or Header  |  1997-10-06  |  10KB  |  358 lines

  1. /* Simple debugging component. Temporary */
  2.  
  3. #include "ttdebug.h"
  4. #include "tttables.h"
  5. #include "ttobjs.h"
  6. #include "stdio.h"
  7. #include "string.h"
  8.  
  9.   typedef char ByteStr[2];
  10.   typedef char WordStr[4];
  11.   typedef char LongStr[8];
  12.  
  13.   static  DebugStr tempStr;
  14.  
  15.   static const char*  OpStr[256] = {
  16.             "SVTCA y",       /* Set vectors to coordinate axis y    */
  17.             "SVTCA x",       /* Set vectors to coordinate axis x    */
  18.             "SPvTCA y",      /* Set Proj. vec. to coord. axis y     */
  19.             "SPvTCA x",      /* Set Proj. vec. to coord. axis x     */
  20.             "SFvTCA y",      /* Set Free. vec. to coord. axis y     */
  21.             "SFvTCA x",      /* Set Free. vec. to coord. axis x     */
  22.             "SPvTL //",      /* Set Proj. vec. parallel to segment  */
  23.             "SPvTL +",       /* Set Proj. vec. normal to segment    */
  24.             "SFvTL //",      /* Set Free. vec. parallel to segment  */
  25.             "SFvTL +",       /* Set Free. vec. normal to segment    */
  26.             "SPvFS",         /* Set Proj. vec. from stack           */
  27.             "SFvFS",         /* Set Free. vec. from stack           */
  28.             "GPV",           /* Get projection vector               */
  29.             "GFV",           /* Get freedom vector                  */
  30.             "SFvTPv",        /* Set free. vec. to proj. vec.        */
  31.             "ISECT",         /* compute intersection                */
  32.  
  33.             "SRP0",          /* Set reference point 0               */
  34.             "SRP1",          /* Set reference point 1               */
  35.             "SRP2",          /* Set reference point 2               */
  36.             "SZP0",          /* Set Zone Pointer 0                  */
  37.             "SZP1",          /* Set Zone Pointer 1                  */
  38.             "SZP2",          /* Set Zone Pointer 2                  */
  39.             "SZPS",          /* Set all zone pointers               */
  40.             "SLOOP",         /* Set loop counter                    */
  41.             "RTG",           /* Round to Grid                       */
  42.             "RTHG",          /* Round to Half-Grid                  */
  43.             "SMD",           /* Set Minimum Distance                */
  44.             "ELSE",          /* Else                                */
  45.             "JMPR",          /* Jump Relative                       */
  46.             "SCvTCi",        /* Set CVT                             */
  47.             "SSwCi",         /*                                     */
  48.             "SSW",           /*                                     */
  49.  
  50.             "DUP",
  51.             "POP",
  52.             "CLEAR",
  53.             "SWAP",
  54.             "DEPTH",
  55.             "CINDEX",
  56.             "MINDEX",
  57.             "AlignPTS",
  58.             "INS_$28",
  59.             "UTP",
  60.             "LOOPCALL",
  61.             "CALL",
  62.             "FDEF",
  63.             "ENDF",
  64.             "MDAP[-]",
  65.             "MDAP[r]",
  66.  
  67.             "IUP[y]",
  68.             "IUP[x]",
  69.             "SHP[0]",
  70.             "SHP[1]",
  71.             "SHC[0]",
  72.             "SHC[1]",
  73.             "SHZ[0]",
  74.             "SHZ[1]",
  75.             "SHPIX",
  76.             "IP",
  77.             "MSIRP[0]",
  78.             "MSIRP[1]",
  79.             "AlignRP",
  80.             "RTDG",
  81.             "MIAP[-]",
  82.             "MIAP[r]",
  83.  
  84.             "NPushB",
  85.             "NPushW",
  86.             "WS",
  87.             "RS",
  88.             "WCvtP",
  89.             "RCvt",
  90.             "GC[0]",
  91.             "GC[1]",
  92.             "SCFS",
  93.             "MD[0]",
  94.             "MD[1]",
  95.             "MPPEM",
  96.             "MPS",
  97.             "FlipON",
  98.             "FlipOFF",
  99.             "DEBUG",
  100.  
  101.             "LT",
  102.             "LTEQ",
  103.             "GT",
  104.             "GTEQ",
  105.             "EQ",
  106.             "NEQ",
  107.             "ODD",
  108.             "EVEN",
  109.             "IF",
  110.             "EIF",
  111.             "AND",
  112.             "OR",
  113.             "NOT",
  114.             "DeltaP1",
  115.             "SDB",
  116.             "SDS",
  117.  
  118.             "ADD",
  119.             "SUB",
  120.             "DIV",
  121.             "MUL",
  122.             "ABS",
  123.             "NEG",
  124.             "FLOOR",
  125.             "CEILING",
  126.             "ROUND[G]",
  127.             "ROUND[B]",
  128.             "ROUND[W]",
  129.             "ROUND[?]",
  130.             "NROUND[G]",
  131.             "NROUND[B]",
  132.             "NROUND[W]",
  133.             "NROUND[?]",
  134.  
  135.             "WCvtF",
  136.             "DeltaP2",
  137.             "DeltaP3",
  138.             "DeltaC1",
  139.             "DeltaC2",
  140.             "DeltaC3",
  141.             "SROUND",
  142.             "S45Round",
  143.             "JROT",
  144.             "JROF",
  145.             "ROFF",
  146.             "INS_$7B",
  147.             "RUTG",
  148.             "RDTG",
  149.             "SANGW",
  150.             "AA",
  151.  
  152.             "FlipPT",
  153.             "FlipRgON",
  154.             "FlipRgOFF",
  155.             "INS_$83",
  156.             "INS_$84",
  157.             "ScanCTRL",
  158.             "SDPVTL[0]",
  159.             "SDPVTL[1]",
  160.             "GetINFO",
  161.             "IDEF",
  162.             "ROLL",
  163.             "MAX",
  164.             "MIN",
  165.             "ScanTYPE",
  166.             "IntCTRL",
  167.             "INS_$8F",
  168.  
  169.             "INS_$90",
  170.             "INS_$91",
  171.             "INS_$92",
  172.             "INS_$93",
  173.             "INS_$94",
  174.             "INS_$95",
  175.             "INS_$96",
  176.             "INS_$97",
  177.             "INS_$98",
  178.             "INS_$99",
  179.             "INS_$9A",
  180.             "INS_$9B",
  181.             "INS_$9C",
  182.             "INS_$9D",
  183.             "INS_$9E",
  184.             "INS_$9F",
  185.  
  186.             "INS_$A0",
  187.             "INS_$A1",
  188.             "INS_$A2",
  189.             "INS_$A3",
  190.             "INS_$A4",
  191.             "INS_$A5",
  192.             "INS_$A6",
  193.             "INS_$A7",
  194.             "INS_$A8",
  195.             "INS_$A9",
  196.             "INS_$AA",
  197.             "INS_$AB",
  198.             "INS_$AC",
  199.             "INS_$AD",
  200.             "INS_$AE",
  201.             "INS_$AF",
  202.  
  203.             "PushB[0]",
  204.             "PushB[1]",
  205.             "PushB[2]",
  206.             "PushB[3]",
  207.             "PushB[4]",
  208.             "PushB[5]",
  209.             "PushB[6]",
  210.             "PushB[7]",
  211.             "PushW[0]",
  212.             "PushW[1]",
  213.             "PushW[2]",
  214.             "PushW[3]",
  215.             "PushW[4]",
  216.             "PushW[5]",
  217.             "PushW[6]",
  218.             "PushW[7]",
  219.  
  220.             "MDRP[G]",
  221.             "MDRP[B]",
  222.             "MDRP[W]",
  223.             "MDRP[?]",
  224.             "MDRP[rG]",
  225.             "MDRP[rB]",
  226.             "MDRP[rW]",
  227.             "MDRP[r?]",
  228.             "MDRP[mG]",
  229.             "MDRP[mB]",
  230.             "MDRP[mW]",
  231.             "MDRP[m?]",
  232.             "MDRP[mrG]",
  233.             "MDRP[mrB]",
  234.             "MDRP[mrW]",
  235.             "MDRP[mr?]",
  236.             "MDRP[pG]",
  237.             "MDRP[pB]",
  238.  
  239.             "MDRP[pW]",
  240.             "MDRP[p?]",
  241.             "MDRP[prG]",
  242.             "MDRP[prB]",
  243.             "MDRP[prW]",
  244.             "MDRP[pr?]",
  245.             "MDRP[pmG]",
  246.             "MDRP[pmB]",
  247.             "MDRP[pmW]",
  248.             "MDRP[pm?]",
  249.             "MDRP[pmrG]",
  250.             "MDRP[pmrB]",
  251.             "MDRP[pmrW]",
  252.             "MDRP[pmr?]",
  253.  
  254.             "MIRP[G]",
  255.             "MIRP[B]",
  256.             "MIRP[W]",
  257.             "MIRP[?]",
  258.             "MIRP[rG]",
  259.             "MIRP[rB]",
  260.             "MIRP[rW]",
  261.             "MIRP[r?]",
  262.             "MIRP[mG]",
  263.             "MIRP[mB]",
  264.             "MIRP[mW]",
  265.             "MIRP[m?]",
  266.             "MIRP[mrG]",
  267.             "MIRP[mrB]",
  268.             "MIRP[mrW]",
  269.             "MIRP[mr?]",
  270.             "MIRP[pG]",
  271.             "MIRP[pB]",
  272.  
  273.             "MIRP[pW]",
  274.             "MIRP[p?]",
  275.             "MIRP[prG]",
  276.             "MIRP[prB]",
  277.             "MIRP[prW]",
  278.             "MIRP[pr?]",
  279.             "MIRP[pmG]",
  280.             "MIRP[pmB]",
  281.             "MIRP[pmW]",
  282.             "MIRP[pm?]",
  283.             "MIRP[pmrG]",
  284.             "MIRP[pmrB]",
  285.             "MIRP[pmrW]",
  286.             "MIRP[pmr?]"
  287.           };
  288.  
  289.   static const char HexStr[16] = "0123456789ABCDEF";
  290.  
  291.   DebugStr* Cur_U_Line( void* _exec )
  292.   {
  293.     char  s[32];
  294.  
  295.     Int op, i, n;
  296.  
  297.     PExecution_Context exec;
  298.  
  299.     exec = _exec;
  300.  
  301.     op = exec->code[ exec->IP ];
  302.  
  303.     sprintf( tempStr, "%04hx: %02hx  %s", exec->IP, op, OpStr[op] );
  304.  
  305.     if ( op == 0x40 )
  306.     {
  307.       n = exec->code[ exec->IP+1 ];
  308.       sprintf( s, "(%d)", n );
  309.       strncat( tempStr, s, 8 );
  310.  
  311.       if ( n > 20 ) n = 20; /* limit output */
  312.  
  313.       for ( i = 0; i < n; i++ )
  314.       {
  315.         sprintf( s, " $%02hx", exec->code[ exec->IP+i+2 ] );
  316.         strncat( tempStr, s, 8 );
  317.       }
  318.     }
  319.     else if ( op == 0x41 )
  320.     {
  321.       n = exec->code[ exec->IP+1 ];
  322.       sprintf( s, "(%d)", n );
  323.       strncat( tempStr, s, 8 );
  324.  
  325.       if (n > 20) n = 20; /* limit output */
  326.  
  327.       for ( i = 0; i < n; i++ )
  328.       {
  329.         sprintf( s, " $%02hx%02hx", exec->code[ exec->IP+i*2+2 ],
  330.                                     exec->code[ exec->IP+i*2+3 ] );
  331.         strncat( tempStr, s, 8 );
  332.       }
  333.     }
  334.     else if ( (op & 0xF8) == 0xB0 )
  335.     {
  336.       n = op-0xB0;
  337.  
  338.       for ( i=0; i <= n; i++ )
  339.       {
  340.         sprintf( s, " $%02hx", exec->code[ exec->IP+i+1 ] );
  341.         strncat( tempStr, s, 8 );
  342.       }
  343.     }
  344.     else if ( (op & 0xF8) == 0xB8 )
  345.     {
  346.       n = op-0xB8;
  347.  
  348.       for ( i = 0; i <= n; i++ )
  349.       {
  350.         sprintf( s, " $%02hx%02hx", exec->code[ exec->IP+i*2+1 ],
  351.                                   exec->code[ exec->IP+i*2+2 ] );
  352.         strncat( tempStr, s, 8 );
  353.       }
  354.     }
  355.  
  356.     return (DebugStr*)tempStr; 
  357.   }
  358.