home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / contrib / libgrx / src / pschar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-06  |  3.5 KB  |  115 lines

  1. /**
  2.  ** PSCHAR.C
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "p8514a.h"
  25.  
  26. static int bg_mixtable[] = {
  27.     BSS_BKGDCOL | MIX_SRC,          /* C_SET */
  28.     BSS_BKGDCOL | MIX_XOR,          /* C_XOR */
  29.     BSS_BKGDCOL | MIX_OR,          /* C_OR  */
  30.     BSS_BKGDCOL | MIX_AND          /* C_AND */
  31. };
  32.  
  33. void _GrPSDrawChar(long a,int w,int h,char far *bpt,int fg,int bg)
  34. {
  35.     if((w <= 0) || (h <= 0)) return;
  36.     if(CURC->gc_onscreen) {
  37.         int fgop = C_OPER(fg);
  38.         int bgop = C_OPER(bg);
  39.         int xpos = COORD_X(a);
  40.         int ypos = COORD_Y(a);
  41.         int words = (w + 15) >> 4;
  42.         int fontw = (w + 7) >> 3;
  43.  
  44.         if(((_GrPIDrawTable[fgop] ^ (fg &= C_SIGNIF)) |
  45.         (_GrPIDrawTable[bgop] ^ (bg &= C_SIGNIF))) == 0) return;
  46.         WaitQueue(5);
  47.         outpw(MAJ_AXIS_PCNT,(w - 1));
  48.         outpw(MULTIFUNC_CNTL,(MIN_AXIS_PCNT | (h - 1)));
  49.         outpw(MULTIFUNC_CNTL,(PIX_CNTL | MIXSEL_EXPPC));
  50.         outpw(FRGD_MIX,_GrPIMixTable[fgop]);
  51.         outpw(BKGD_MIX,bg_mixtable[bgop]);
  52.         WaitQueue(5);
  53.         outpw(FRGD_COLOR,fg);
  54.         outpw(BKGD_COLOR,bg);
  55.         outpw(CUR_X,xpos);
  56.         outpw(CUR_Y,ypos);
  57.         outpw(CMD,(CMD_RECT | INC_X | INC_Y | PCDATA | _16BIT | BYTSEQ | DRAW | PLANAR | WRTDATA));
  58.         WaitQueue(8);
  59. #ifdef __TURBOC__
  60. #define _HAVE_INLINE_
  61.         asm .286
  62.         asm cld;
  63.         asm push    ds;
  64.         asm lds    si,DWORD PTR bpt;
  65.         asm mov    dx,PIX_TRANS;
  66.       VertLoop:
  67.         asm push    si;
  68.         asm mov    cx,WORD PTR words;
  69.         asm rep    outsw;
  70.         asm pop    si;
  71.         asm add    si,WORD PTR fontw;
  72.         asm dec    WORD PTR h;
  73.         asm jne    VertLoop;
  74.         asm pop    ds;
  75. #endif
  76. #ifdef __GNUC__
  77. #define _HAVE_INLINE_
  78.         asm volatile("                                            \n\
  79.         cld                              \n\
  80.         movl    %0,%%edi      /* address */              \n\
  81.         movl    %1,%%edx      /* PIXEL TRANSFER reg */          \n\
  82.         movl    %3,%%ebx      /* font pattern wdt (bytes) */  \n\
  83.         movl    %4,%%eax      /* height */              \n\
  84.           L_VertLoop:                          \n\
  85.         movl    %2,%%ecx      /* words to transfer */          \n\
  86.         movl    %%edi,%%esi                      \n\
  87.         addl    %%ebx,%%edi                      \n\
  88.         rep                              \n\
  89.         outsw                              \n\
  90.         decl    %%eax                          \n\
  91.         jne    L_VertLoop                    "
  92.         : /* nothong */
  93.         : "g" (bpt),   "g" (PIX_TRANS),
  94.           "g" (words), "g" (fontw), "g" (h)
  95.         : "di", "si", "dx", "cx", "bx", "ax"
  96.         );
  97. #endif
  98. #ifndef _HAVE_INLINE_
  99.         while(--h >= 0) {
  100.         unsigned short far *fbits;
  101.         int count;
  102.         fbits = (unsigned short far *)bpt;
  103.         count = bytes;
  104.         while(--count >= 0) outpw(PIX_TRANS,*fbits++);
  105.         bpt += fontw;
  106.         }
  107. #endif
  108.         WaitQueue(1);
  109.         outpw(MULTIFUNC_CNTL,(PIX_CNTL | 0));
  110.         return;
  111.     }
  112.     _GrP8DrawChar(a,w,h,bpt,fg,bg);
  113. }
  114.  
  115.