home *** CD-ROM | disk | FTP | other *** search
- /**
- ** PHFILLP.C
- **
- ** Copyright (C) 1992, Csaba Biegl
- ** 820 Stirrup Dr, Nashville, TN, 37221
- ** csaba@vuse.vanderbilt.edu
- **
- ** This file is distributed under the terms listed in the document
- ** "copying.cb", available from the author at the address above.
- ** A copy of "copying.cb" should accompany this file; if not, a copy
- ** should be available from where this file was obtained. This file
- ** may not be distributed without a verbatim copy of "copying.cb".
- ** You should also have received a copy of the GNU General Public
- ** License along with this program (it is in the file "copying");
- ** if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
- ** Cambridge, MA 02139, USA.
- **
- ** This program 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.
- **/
-
- #include "p16.h"
- #include "memcopy.h"
- #include "worddraw.h"
-
- #define FGONLY 1
-
- void _GrPHFillPattern(int x,int y,int width,GrPattern *p)
- {
- pixptr dst;
-
- if(width <= 0) return;
- x += CURC->gc_xoffset;
- y += CURC->gc_yoffset;
- dst = (pixptr)(CURC->gc_baseaddr + (y * CURC->gc_lineoffset) + (x << 1));
- _ClrDir();
- if(p->gp_ispixmap) {
- int pattwdt = p->gp_pxp_width;
- int optype = C_OPER(p->gp_pxp_oper);
- int cpysize = x % pattwdt;
- pixptr srcline = (pixptr)(p->gp_pxp_source.gc_baseaddr +
- ((y % p->gp_pxp_height) * p->gp_pxp_source.gc_lineoffset));
- pixptr srcptr = srcline + cpysize;
-
- cpysize = pattwdt - cpysize;
- _SaveDS();
- while(width > 0) {
- if(cpysize > width) cpysize = width;
- switch(optype) {
- case C_XOR: _RowCpyXorW(X,dst,srcptr,cpysize); break;
- case C_OR: _RowCpyOrW(O,dst,srcptr,cpysize); break;
- case C_AND: _RowCpyAndW(A,dst,srcptr,cpysize); break;
- default: _RowCpyW(C,dst,srcptr,cpysize); break;
- }
- width -= cpysize;
- dst += cpysize;
- srcptr = srcline;
- cpysize = pattwdt;
- }
- _RestoreDS();
- }
- else {
- int bits = p->gp_bmp_data[y % p->gp_bmp_height];
- int fgc = p->gp_bmp_fgcolor;
- int bgc = p->gp_bmp_bgcolor;
- int fgop = C_OPER(fgc);
- int bgop = C_OPER(bgc);
- int drawfg = _GrPHDrawTable[fgop] ^ (fgc &= C_SIGNIF);
- int drawbg = _GrPHDrawTable[bgop] ^ (bgc &= C_SIGNIF);
-
- x &= 7;
- bits = (bits << x) | ((bits & 0xff) >> (8 - x));
- if(drawfg && drawbg && (fgop == bgop)) {
- switch(fgop) {
- case C_XOR: _PatternXor(dst,bits,width,fgc,bgc); return;
- case C_OR: _PatternOr(dst,bits,width,fgc,bgc); return;
- case C_AND: _PatternAnd(dst,bits,width,fgc,bgc); return;
- default: _PatternSet(dst,bits,width,fgc,bgc); return;
- }
- }
- if(drawfg) switch(fgop) {
- case C_XOR: _PattFGCXor(dst,bits,width,fgc); break;
- case C_OR: _PattFGCOr(dst,bits,width,fgc); break;
- case C_AND: _PattFGCAnd(dst,bits,width,fgc); break;
- default: _PattFGCSet(dst,bits,width,fgc); break;
- }
- if(drawbg) switch(bgop) {
- case C_XOR: _PattBGCXor(dst,bits,width,bgc); break;
- case C_OR: _PattBGCOr(dst,bits,width,bgc); break;
- case C_AND: _PattBGCAnd(dst,bits,width,bgc); break;
- default: _PattBGCSet(dst,bits,width,bgc); break;
- }
- }
- }
-