home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_1.3 / Read-Me1.3 / Printer1.3 / Driver.Examples / src / epsonQ / dospecial.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-01  |  3.9 KB  |  191 lines

  1. /*
  2.     DoSpecial for EpsonQ driver.
  3.     David Berezowski - March/88.
  4. */
  5.  
  6. #include "exec/types.h"
  7. #include "../printer/printer.h"
  8. #include "../printer/prtbase.h"
  9.  
  10. DoSpecial(command, outputBuffer, vline, currentVMI, crlfFlag, Parms)
  11. char outputBuffer[];
  12. UWORD *command;
  13. BYTE *vline;
  14. BYTE *currentVMI;
  15. BYTE *crlfFlag;
  16. UBYTE Parms[];
  17. {
  18.     extern struct PrinterData *PD;
  19.  
  20.     int x = 0, y = 0;
  21.     /*
  22.         00-01    \0335        italics off
  23.         02-04    \033-\000    underline off
  24.         05-06    \033F        boldface off
  25.         07-08    \033P        elite off
  26.         09-09    \022        condensed fine off
  27.         10-12    \033W\000    enlarge off
  28.         13-14    \033H        double strike off
  29.         15-17    \033x\000    NLQ off
  30.         18-19    \033T        normalize the line
  31.         20-22    \033R\000    US char set
  32.         23-25    \033p0        proportional off
  33.         26-27    \0332        6 lpi
  34.         28-28    \015        carriage-return
  35.     */
  36.     static char initThisPrinter[29] =
  37. "\0335\033-\376\033F\033P\022\033W\376\033H\033x\376\033T\033R\376\033p0\0332\015";
  38.     static char initMarg[] = "\375\033lL\033QR\375";
  39.     static BYTE ISOcolorTable[] = {0, 5, 6, 4, 3, 1, 2, 0};
  40.  
  41.     if (*command == aRIN) { /* initialize */
  42.         while(x < 29) {
  43.             if ((outputBuffer[x] = initThisPrinter[x]) == -2) {
  44.                 outputBuffer[x] = 0;
  45.             }
  46.             x++;
  47.         }
  48.  
  49.         if (PD->pd_Preferences.PrintQuality == LETTER) {
  50.             outputBuffer[17] = 1;
  51.         }
  52.  
  53.         *currentVMI = 30; /* assume 1/6 line spacing */
  54.         if (PD->pd_Preferences.PrintSpacing == EIGHT_LPI) {
  55.             outputBuffer[27] = '0';
  56.             *currentVMI = 22;
  57.         }
  58.  
  59.         if (PD->pd_Preferences.PrintPitch == ELITE) {
  60.             outputBuffer[8] = 'M';
  61.         }
  62.         else if (PD->pd_Preferences.PrintPitch == FINE) {
  63.             outputBuffer[9] = 15;
  64.         }
  65.  
  66.         Parms[0] = PD->pd_Preferences.PrintLeftMargin;
  67.         Parms[1] = PD->pd_Preferences.PrintRightMargin;
  68.         *command=aSLRM;
  69.     }
  70.  
  71.     if (*command == aCAM) { /* cancel margins */
  72.         y = PD->pd_Preferences.PaperSize == W_TRACTOR ? 136 : 80;
  73.         if (PD->pd_Preferences.PrintPitch == PICA) {
  74.             Parms[1] = (10 * y) / 10;
  75.         }
  76.         else if (PD->pd_Preferences.PrintPitch == ELITE) {
  77.             Parms[1] = (12 * y) / 10;
  78.         }
  79.         else { /* fine */
  80.             Parms[1] = (17 * y) / 10;
  81.         }
  82.         Parms[0] = 1;
  83.         y = 0;
  84.         *command = aSLRM;
  85.     }
  86.  
  87.     if (*command == aSLRM) { /* set left&right margins */
  88.         PD->pd_PWaitEnabled = 253; /* wait after this character */
  89.         if (Parms[0] == 0) {
  90.             initMarg[3] = 0;
  91.         }
  92.         else {
  93.             initMarg[3] = Parms[0] - 1;
  94.         }
  95.         initMarg[6] = Parms[1];
  96.         while (y < 8) {
  97.             outputBuffer[x++] = initMarg[y++];
  98.         }
  99.         return(x);
  100.     }
  101.  
  102.     if (*command == aPLU) { /* partial line up */
  103.         if (*vline == 0) {
  104.             *vline = 1;
  105.             *command = aSUS2;
  106.             return(0);
  107.         }
  108.         if (*vline < 0) {
  109.             *vline = 0;
  110.             *command = aSUS3;
  111.             return(0);
  112.         }
  113.         return(-1);
  114.     }
  115.  
  116.     if (*command == aPLD) { /* partial line down */
  117.         if (*vline == 0) {
  118.             *vline = -1;
  119.             *command = aSUS4;
  120.             return(0);
  121.         }
  122.         if (*vline > 0) {
  123.             *vline = 0;
  124.             *command = aSUS1;
  125.             return(0);
  126.         }
  127.         return(-1);
  128.     }
  129.  
  130.     if (*command == aSUS0) { /* normalize the line */
  131.         *vline = 0;
  132.     }
  133.  
  134.     if (*command == aSUS1) { /* superscript off */
  135.         *vline = 0;
  136.     }
  137.  
  138.     if (*command == aSUS2) { /* superscript on */
  139.         *vline = 1;
  140.     }
  141.  
  142.     if (*command == aSUS3) { /* subscript off */
  143.         *vline = 0;
  144.     }
  145.  
  146.     if (*command == aSUS4) { /* subscript on */
  147.         *vline = -1;
  148.     }
  149.  
  150.     if (*command == aVERP0) { /* 8 LPI */
  151.         *currentVMI = 22;
  152.     }
  153.  
  154.     if (*command == aVERP1) { /* 6 LPI */
  155.         *currentVMI = 30;
  156.     }
  157.  
  158.     if (*command == aSFC) { /* set foreground/background color */
  159.         if (Parms[0] == 39) {
  160.             Parms[0] = 30; /* set default (black) */
  161.         }
  162.         if (Parms[0] > 37) {
  163.             return(0); /* ni or background color change */
  164.         }
  165.         outputBuffer[x++] = 27;
  166.         outputBuffer[x++] = 'r';
  167.         outputBuffer[x++] = ISOcolorTable[Parms[0] - 30];
  168.         return(x);
  169.     }
  170.  
  171.     if (*command == aSLPP) { /* set form length */
  172.         outputBuffer[x++] = 27;
  173.         outputBuffer[x++] = 'C';
  174.         outputBuffer[x++] = Parms[0];
  175.         return(x);
  176.     }
  177.  
  178.     if (*command == aPERF) { /* perf skip n */
  179.         outputBuffer[x++] = 27;
  180.         outputBuffer[x++] = 'N';
  181.         outputBuffer[x++] = Parms[0];
  182.         return(x);
  183.     }
  184.  
  185.     if (*command == aRIS) { /* reset */
  186.         PD->pd_PWaitEnabled = 253;
  187.     }
  188.  
  189.     return(0);
  190. }
  191.