home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / m / m242 / 1.ddi / SOURCE.ZIP / DOSCHAR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-16  |  2.1 KB  |  64 lines

  1. struct intregs{
  2.     unsigned ds;    /* data segment register */
  3.     unsigned es;    /* extra segment */
  4.     unsigned si;    /* source index */
  5.     unsigned di;    /* destination index */
  6.     unsigned ah;    /* high byte of ax register */
  7.     unsigned al;    /* low byte of ax register */
  8.     unsigned bh;    /* set up other general registers as his and lows  */
  9.     unsigned bl;
  10.     unsigned ch;
  11.     unsigned cl;
  12.     unsigned dh;
  13.     unsigned dl;
  14. };
  15.   
  16. doschar(charac) /* print a character to the line printer */
  17.                 /* goes to the standard printing device  */
  18. char charac;    /* the character to be printed */
  19. {
  20.     extern unsigned filhandl;
  21.     extern int plot_port;          /* comm port for the plotter */
  22.     extern int p_filesw;
  23.     struct intregs regs; /* registers for gdosint    */
  24.     int ret_code; /* return code for gdosint */
  25.     unsigned actual;
  26.     extern int hpgl_on;
  27.     int i;
  28.   
  29.     if (p_filesw == 1){
  30.         i = writefil(filhandl,1,&charac,&actual);
  31.         return(i);
  32.     }
  33.     if (hpgl_on){
  34.         asysend(plot_port,charac);   /* use asysend to go thru Int 14h */
  35.         return(0);
  36.     }
  37.     else{
  38.   
  39. /* use interrupt 17H for ROM BIOS printer controller services */
  40.   
  41.         regs.dh=0;
  42.         regs.dl= 0;          /* default is 0 - for LPT1                */
  43.                        /* may be changed to 1 - LPT2 | 2 - LPT3  */
  44.         regs.es=regs.ds=0;   /* default value - no changes to register */
  45.         regs.ah=0;           /* initialize to  0                       */
  46.         regs.al  = charac;      /* put the character in the al register   */
  47.         gdosint(0x17,®s,®s);
  48.         return(0);
  49.   
  50. /* we do not check for printer errors, but for a given printer you */
  51. /* may be using the return code errors are in the AH register and  */
  52. /* each bit of the byte is as follows :                            */
  53. /*  return(regs.ah)           */
  54. /*  bit 7 -  printer not busy */
  55. /*  bit 6 -  acknowledge      */
  56. /*  bit 5 -  out of paper     */
  57. /*  bit 4 -  printer selected */
  58. /*  bit 3 -  I/O error        */
  59. /*  bit 2 -  unused           */
  60. /*  bit 1 -  unused           */
  61.   
  62.     }
  63. }
  64.