1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-15 15:57:13 +00:00
Interlisp.maiko/src/rawcolor.c
Nick Briggs 6528ac38e3 Remove proprietary license from all files.
The code is being re-licensed under the MIT license.

	modified:   bin/fixid
	modified:   bin/launch.asm
	modified:   bin/makefile-hpux.hp9000-x
	modified:   bin/makefile-init.sgi
	modified:   bin/makefile-init.sparc
	modified:   bin/makefile-init.sparc-multi
	modified:   bin/makefile-irix.sgi-x
	modified:   bin/makefile-sunos4.sparc
	modified:   bin/makefile-sunos4.sparc%
	modified:   bin/makefile-sunos4.sparc-multi
	modified:   bin/makefile-sunos5.386-x
	modified:   bin/makefile-sunos5.i386-x
	modified:   bin/makefile-sunos5.sparc-x
	modified:   bin/makefile-tail
	modified:   bin/makeisc
	modified:   bin/makeright
	modified:   inc/Check.h
	modified:   inc/MyWindow.h
	modified:   inc/Stipple.h
	modified:   inc/XCursors.h
	modified:   inc/XKeymap.h
	modified:   inc/XVersion.h
	modified:   inc/Xdeflt.h
	modified:   inc/Xicon.h
	modified:   inc/address.h
	modified:   inc/arith.h
	modified:   inc/arith2.h
	modified:   inc/array.h
	modified:   inc/bb.h
	modified:   inc/cell.h
	modified:   inc/cell.h%
	modified:   inc/copyright
	modified:   inc/dbprint.h
	modified:   inc/debug.h
	modified:   inc/devif.h
	modified:   inc/display.h
	modified:   inc/dspdata.h
	modified:   inc/ether.h
	modified:   inc/fast_dsp.h
	modified:   inc/fp.h
	modified:   inc/gc.h
	modified:   inc/gc.h.save
	modified:   inc/gcscan.h
	modified:   inc/hdw_conf.h
	modified:   inc/ifpage.h
	modified:   inc/inlineC.h
	modified:   inc/inlnMIPS.h
	modified:   inc/inlnPS2.h
	modified:   inc/inlndos.h
	modified:   inc/iopage.h
	modified:   inc/kbdif.h
	modified:   inc/keyboard.h
	modified:   inc/keyboard.h%
	modified:   inc/keysym.h
	modified:   inc/ldeXdefs.h
	modified:   inc/lispemul.h
	modified:   inc/lispemul.h.save
	modified:   inc/lispmap.h
	modified:   inc/lldsp.h
	modified:   inc/lnk-Xdeflt.h
	modified:   inc/lnk-debug.h
	modified:   inc/lnk-fast_dsp.h
	modified:   inc/lnk-inlineC.h
	modified:   inc/lnk-lispmap.h
	modified:   inc/lnk-tosfns.h
	modified:   inc/lnk-tosret.h
	modified:   inc/locfile.h
	modified:   inc/lpdefs.h
	modified:   inc/lpglobl.h
	modified:   inc/lspglob.h
	modified:   inc/lsptypes.h
	modified:   inc/medleyfp.h
	modified:   inc/mnxdefs.h
	modified:   inc/my.h
	modified:   inc/native.h
	modified:   inc/ocr.h
	modified:   inc/osmsg.h
	modified:   inc/picture.h
	modified:   inc/pilotbbt.h
	modified:   inc/print.h
	modified:   inc/profile.h
	modified:   inc/rawrs232c.h
	modified:   inc/return.h
	modified:   inc/rs232c.h
	modified:   inc/stack.h
	modified:   inc/stream.h
	modified:   inc/stream.h%
	modified:   inc/stream.h2
	modified:   inc/sysatms.h
	modified:   inc/timeout.h
	modified:   inc/tos1defs.h
	modified:   inc/tosfns.h
	modified:   inc/tosret.h
	modified:   inc/tty.h
	modified:   inc/version.h
	modified:   inc/vmemsave.h
	modified:   inc/xbitmaps.h
	modified:   inc/xdefs.h
	modified:   src/Cldeetr.c
	modified:   src/allocmds.c
	modified:   src/arith2.c
	modified:   src/arith3.c
	modified:   src/arith4.c
	modified:   src/array.c
	modified:   src/array2.c
	modified:   src/array3.c
	modified:   src/array4.c
	modified:   src/array5.c
	modified:   src/array6.c
	modified:   src/asmbbt.c
	modified:   src/asmbitblt.c
	modified:   src/atom.c
	modified:   src/bbtSPARC.s
	modified:   src/bbtsub.c
	modified:   src/bin.c
	modified:   src/binds.c
	modified:   src/bitblt.c
	modified:   src/blt.c
	modified:   src/byteswap.c
	modified:   src/call-c.c
	modified:   src/car-cdr.c
	modified:   src/cdaudio.c
	modified:   src/cdrom.c
	modified:   src/chardev.c
	modified:   src/chatter.c
	modified:   src/codeconv.c
	modified:   src/codetbl.c
	modified:   src/colorbltfns.c
	modified:   src/common.c
	modified:   src/conspage.c
	modified:   src/cr
	modified:   src/dbgtool.c
	modified:   src/dir.c
	modified:   src/doscomm.c
	modified:   src/doskbd.c
	modified:   src/dosmouse.c
	modified:   src/draw.c
	modified:   src/dsk.c
	modified:   src/dspif.c
	modified:   src/dspsubrs.c
	modified:   src/ejlisp.c
	modified:   src/eqf.c
	modified:   src/ether.c
	modified:   src/findkey.c
	modified:   src/foreign.c
	modified:   src/fp.c
	modified:   src/fvar.c
	modified:   src/gc.c
	modified:   src/gc2.c
	modified:   src/gcarray.c
	modified:   src/gccode.c
	modified:   src/gcfinal.c
	modified:   src/gchtfind.c
	modified:   src/gcmain3.c
	modified:   src/gcoflow.c
	modified:   src/gcr.c
	modified:   src/gcrcell.c
	modified:   src/gcscan.c
	modified:   src/gvar2.c
	modified:   src/hacks.c
	modified:   src/hardrtn.c
	modified:   src/imagefile.c
	modified:   src/imagefile2.c
	modified:   src/inet.c
	modified:   src/initdsp.c
	modified:   src/initkbd.c
	modified:   src/initsout.c
	modified:   src/intcall.c
	modified:   src/kbdif.c
	modified:   src/kbdsubrs.c
	modified:   src/keyevent.c
	modified:   src/keylib.c
	modified:   src/keymaker.c
	modified:   src/keytst.c
	modified:   src/keytstno.c
	modified:   src/kprint.c
	modified:   src/launch.asm
	modified:   src/ldeboot.c
	modified:   src/ldeether.c
	modified:   src/ldsout.c
	modified:   src/lineblt8.c
	modified:   src/lisp2c.c
	modified:   src/llcolor.c
	modified:   src/llstk.c
	modified:   src/loader.c
	modified:   src/loopsops.c
	modified:   src/lowlev1.c
	modified:   src/lowlev2.c
	modified:   src/lpdual.c
	modified:   src/lpkit.c
	modified:   src/lplexyy.c
	modified:   src/lpmain.c
	modified:   src/lpread.c
	modified:   src/lpsolve.c
	modified:   src/lptran.c
	modified:   src/lpwrite.c
	modified:   src/lpytab.c
	modified:   src/lsthandl.c
	modified:   src/main.c
	modified:   src/misc7.c
	modified:   src/miscn.c
	modified:   src/mkatom.c
	modified:   src/mkcell.c
	modified:   src/mkkey.c
	modified:   src/mkvdate.c
	modified:   src/mnwevent.c
	modified:   src/mnxmeth.c
	modified:   src/mouseif.c
	modified:   src/mvs.c
	modified:   src/ocr.c
	modified:   src/ocrproc.c
	modified:   src/oether.c
	modified:   src/oldeether.c
	modified:   src/optck.c
	modified:   src/osmsg.c
	modified:   src/perrno.c
	modified:   src/picture.c
	modified:   src/rawcolor.c
	modified:   src/rawrs232c.c
	modified:   src/return.c
	modified:   src/rpc.c
	modified:   src/rplcons.c
	modified:   src/rs232c.c
	modified:   src/setsout.c
	modified:   src/shift.c
	modified:   src/socdvr.c
	modified:   src/storage.c
	modified:   src/subr.c
	modified:   src/subr0374.c
	modified:   src/sxhash.c
	modified:   src/testdsp.c
	modified:   src/testtool.c
	modified:   src/timeoday.c
	modified:   src/timeofday.c
	modified:   src/timer.c
	modified:   src/truecolor.c
	modified:   src/tstsout.c
	modified:   src/tty.c
	modified:   src/typeof.c
	modified:   src/ubf1.c
	modified:   src/ubf2.c
	modified:   src/ubf3.c
	modified:   src/ufn.c
	modified:   src/ufs.c
	modified:   src/unixcomm.c
	modified:   src/unixfork.c
	modified:   src/unwind.c
	modified:   src/uraid.c
	modified:   src/usrsubr.c
	modified:   src/uutils.c
	modified:   src/vars3.c
	modified:   src/vesafns.asm
	modified:   src/vesainit.c
	modified:   src/vgainit.c
	modified:   src/vmemsave.c
	modified:   src/xbbt.c
	modified:   src/xc.c
	modified:   src/xc.c.orig
	modified:   src/xcursor.c
	modified:   src/xinit.c
	modified:   src/xlspwin.c
	modified:   src/xmkicon.c
	modified:   src/xrdopt.c
	modified:   src/xscroll.c
	modified:   src/xwinman.c
	modified:   src/z2.c
2020-08-11 18:39:45 -07:00

659 lines
23 KiB
C

/* $Id: rawcolor.c,v 1.3 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
static char *id = "$Id: rawcolor.c,v 1.3 2001/12/26 22:17:04 sybalsky Exp $ Copyright (C) Venue";
/************************************************************************/
/* */
/* C O L O R B I T B L T / G R A P H I C S S U P P O R T */
/* */
/* */
/* */
/************************************************************************/
/************************************************************************/
/* */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
#include <sys/types.h>
#include "lispemul.h"
#include "lspglob.h"
#include "lispmap.h"
#include "lsptypes.h"
#include "cell.h"
#include "adr68k.h"
#include "address.h"
#include "stream.h"
#include "dspdata.h"
#include "pilotbbt.h"
#include "debug.h"
#include "arith.h"
#include "bitblt.h"
#include "bbtsub.h"
#include "lldsp.h"
#define IMIN(x, y) (((x) > (y)) ? (y) : (x))
#define IMAX(x, y) (((x) > (y)) ? (x) : (y))
/*******************************/
/* A LISP Big-bitmap structure */
/*******************************/
typedef struct {
LispPTR bigbmwidth;
LispPTR bigbmheight;
LispPTR bigbmlist;
} BIGBM;
#define GetNewFragment(list, frag, type) \
frag = (type)Addr68k_from_LADDR(car(list)); \
list = cdr(list);
LispPTR SLOWBLTCHAR_index;
#define SLOWBLTCHAR_argnum 2
#define PUNT_TO_SLOWBLTCHAR \
{ \
if (SLOWBLTCHAR_index == 0xffffffff) \
SLOWBLTCHAR_index = get_package_atom("\\PUNT.SLOWBLTCHAR", 17, "INTERLISP", 9, NIL); \
if (SLOWBLTCHAR_index == 0xffffffff) { \
error("SLOWBLTCHAR install fail"); \
return; \
} \
CurrentStackPTR += (SLOWBLTCHAR_argnum - 1) * DLWORDSPER_CELL; \
ccfuncall(SLOWBLTCHAR_index, SLOWBLTCHAR_argnum, 3); \
return; \
}
/***********************************************************/
/*
C_slowbltchar
by Takeshi
June 6, 1989
*/
/***********************************************************/
/* I'll merge this macro with FGetNum later */
#define SFGetNum(ptr, place) \
{ \
if (((ptr)&SEGMASK) == S_POSITIVE) { \
(place) = ((ptr)&0xffff); \
} else if (((ptr)&SEGMASK) == S_NEGATIVE) { \
(place) = (int)((ptr) | 0xffff0000); \
} else { \
PUNT_TO_SLOWBLTCHAR; \
} \
}
/* place: native pointer
val: native value(should be smallp)
puntcase: punt descriptions */
#define FReplaceSmallp(place, val, puntcase) \
{ \
if ((0 <= (val)) && ((val) <= MAX_SMALL)) \
(LispPTR)(place) = (LispPTR)(S_POSITIVE | (val)); \
else if (MIN_SMALL <= val) \
(LispPTR)(place) = (LispPTR)(S_NEGATIVE | (0xffff & (val))); \
else { \
puntcase; \
} \
}
/* charcode should be pos. smallp */
#define charcode (args[0] & 0xffff)
#define displaystream args[1]
#define Char8Code(x) ((u_char)((x)&0xff))
#define CharSet(x) ((x) >> 8)
#define PSEUDO_BLACK 255
#define PSEUDO_WHITE 0
LispPTR *SCREENBITMAPS68k; /* Initialized in initsout.c */
LispPTR *COLORSCREEN68k; /* Initialized in initsout.c */
LispPTR COLORSCREEN_index; /* if it's 0xffffffff, not yet initialized */
/************************************************************************/
/* */
/* C _ s l o w b l t c h a r */
/* */
/* args[0] charcode */
/* args[1] displaystream */
/* */
/* */
/************************************************************************/
C_slowbltchar(LispPTR *args)
{
Stream *n_dstream;
DISPLAYDATA *n_dd;
FONTDESC *n_fontd;
CHARSETINFO *n_csinfo;
BITMAP *n_destbitmap;
int dest_bpp;
LispPTR csinfo;
int curx, cury, newx, rmargin, lmargin, xoff, yoff;
DLword cl_left, cl_right, cl_bottom, cl_top;
DLword src_w, src_h, src_x, src_y, dst_x, dst_y, w, h;
u_char forecolor, backcolor;
register int displayflg;
extern LispPTR *TOPWDS68k;
n_dstream = (Stream *)Addr68k_from_LADDR(displaystream);
n_dd = (DISPLAYDATA *)Addr68k_from_LADDR(n_dstream->IMAGEDATA);
n_fontd = (FONTDESC *)Addr68k_from_LADDR(n_dd->ddfont);
n_destbitmap = (BITMAP *)Addr68k_from_LADDR(n_dd->dddestination);
if ((n_fontd->ROTATION & 0xffff) == 0) {
if ((csinfo = *(((LispPTR *)Addr68k_from_LADDR(n_fontd->FONTCHARSETVECTOR)) +
CharSet(charcode))) == NIL)
PUNT_TO_SLOWBLTCHAR; /* CSINFO is not cached */
n_csinfo = (CHARSETINFO *)Addr68k_from_LADDR(csinfo);
SFGetNum(n_dd->ddxposition, curx);
SFGetNum(n_dd->ddyposition, cury);
SFGetNum(n_dd->ddrightmargin, rmargin);
SFGetNum(n_dd->ddleftmargin, lmargin);
SFGetNum(n_dd->ddxoffset, xoff);
SFGetNum(n_dd->ddyoffset, yoff);
cl_left = n_dd->ddclippingleft;
cl_right = n_dd->ddclippingright;
cl_bottom = n_dd->ddclippingbottom;
cl_top = n_dd->ddclippingtop;
newx = curx + *(DLword *)Addr68k_from_LADDR(n_dd->ddwidthscache + Char8Code(charcode));
if (newx > rmargin) PUNT_TO_SLOWBLTCHAR; /* do \DSPPRINTCR/LF */
/* If we care about TOPW then it's too slow to create Menu etc.
But,if we don't,it causes some error **/
{
WINDOW *window;
SCREEN *ColorScreenData;
if (COLORSCREEN_index == 0xffffffff) { /* Make sure COLOR lives? */
COLORSCREEN_index = MAKEATOM("\\COLORSCREEN");
COLORSCREEN68k = GetVALCELL68k(COLORSCREEN_index);
}
ColorScreenData = (SCREEN *)Addr68k_from_LADDR(*COLORSCREEN68k);
window = (WINDOW *)Addr68k_from_LADDR(ColorScreenData->SCTOPW);
if ((displaystream != ColorScreenData->SCTOPW) && (displaystream != window->DSP) &&
(displaystream != *TOPWDS68k) && ((fmemb(n_dd->dddestination, *SCREENBITMAPS68k)) != NIL))
PUNT_TO_SLOWBLTCHAR;
}
FReplaceSmallp(n_dd->ddxposition, newx, PUNT_TO_SLOWBLTCHAR);
/* make curx abs coord */
curx += xoff;
cury += yoff;
{
register PILOTBBT *pbt;
register BITMAP *n_destBM, *n_srcBM;
register BIGBM *n_destBIGBM;
register int destYOffset;
register int width, sourceBitOffset;
extern int ScreenLocked;
extern int displayheight;
n_srcBM = (BITMAP *)Addr68k_from_LADDR(n_csinfo->CHARSETBITMAP);
src_h = n_srcBM->bmheight;
src_w = n_srcBM->bmwidth;
src_x = *((DLword *)Addr68k_from_LADDR(n_dd->ddoffsetscache + Char8Code(charcode)));
src_y = 0;
w = *(DLword *)Addr68k_from_LADDR(n_dd->ddcharimagewidths + Char8Code(charcode));
h = src_h;
(short)dst_x = (short)curx;
(short)dst_y = (short)cury - (short)n_csinfo->CHARSETDESCENT;
{ /* clipping */
short left, right, bottom, top;
short stodx, stody;
left = (short)IMAX((short)dst_x, (short)cl_left);
right = (short)IMIN((short)dst_x + w, (short)cl_right);
bottom = (short)IMAX((short)dst_y, (short)cl_bottom);
top = (short)IMIN((short)dst_y + h, (short)cl_top);
stodx = (short)dst_x - (short)src_x;
stody = (short)dst_y - (short)src_y;
left = IMAX((short)src_x, IMAX(left - stodx, 0));
bottom = IMAX((short)src_y, IMAX(bottom - stody, 0));
right = IMIN((short)src_w, IMIN((short)(src_x + w), right - stodx));
top = IMIN((short)src_h, IMIN((short)(src_y + h), top - stody));
if ((right <= left) || (top <= bottom)) return;
w = (DLword)(right - left);
h = (DLword)(top - bottom);
dst_x = (DLword)(left + stodx);
dst_y = (DLword)(bottom + stody);
src_x = (DLword)left;
src_y = (DLword)bottom;
}
/* forground and bacground color */
if (n_dd->ddcolor == NIL_PTR) {
forecolor = PSEUDO_BLACK;
backcolor = PSEUDO_WHITE;
} else {
backcolor = 0xff & cdr(n_dd->ddcolor);
forecolor = 0xff & car(n_dd->ddcolor);
}
if (GetTypeNumber(n_dd->dddestination) == TYPE_BITMAP) { /* Bitap */
n_destBM = (BITMAP *)Addr68k_from_LADDR(n_dd->dddestination);
ScreenLocked = T;
/* xposition is shifted 3 Kludge for cursorin
in color(8bpp) ** x's meaning is different from
bitbltsub's. For now,I use this func with Kludge */
displayflg = n_new_cursorin(Addr68k_from_LADDR(n_destBM->bmbase), dst_x << 3,
/* Kludge:YCoordination upside down*/
displayheight - cury, w, h);
if (displayflg) HideCursor;
ColorizeFont8(n_srcBM, src_x, src_y, n_destBM, dst_x, dst_y, w, h, backcolor, forecolor,
n_dd->ddsourcetype, n_dd->ddoperation);
if (displayflg) ShowCursor;
ScreenLocked = NIL;
} else { /* BIGBM */
ScreenLocked = T;
n_destBIGBM = (BIGBM *)n_destbitmap;
ColorizeFont8_BIGBM(n_srcBM, src_x, src_y, n_destBIGBM, dst_x, dst_y, w, h, backcolor,
forecolor, n_dd->ddsourcetype, n_dd->ddoperation);
ScreenLocked = NIL;
} /* end if( TYPE_BITMAP ) */
}
} else {
/* ROTATE case ,do-PUNT */
PUNT_TO_SLOWBLTCHAR;
}
} /* end C_slowbltchar */
/************************************************************************/
/* */
/* C o l o r i z e d F o n t 8 */
/* */
/* Expand a 1bpp font to 8bpp colorized font bitmap, using */
/* col1 and col0 as the colors for 1 bits & 0 bits, respectively. */
/* */
/* dbm must be the output bitmap (not a bigbm), whose bpp is 8. */
/* */
/************************************************************************/
#define MAXFONTHEIGHT 48
#define MAXFONTWIDTH 48
#define BITSPERNIBBLE 4
#define BITSPERDLWORD 16
#define BPP 8
u_int ColorizedFont8CACHE[MAXFONTHEIGHT / BITSPERNIBBLE * MAXFONTWIDTH / BITSPERNIBBLE];
void ColorizeFont8(BITMAP *sBM, DLword sXOffset, DLword sYOffset, BITMAP *dBM, DLword dXOffset, DLword dYOffset, DLword width, DLword height, u_char col0, u_char col1,
LispPTR sourcetype, LispPTR operation)
{
register DLword *nbase;
register u_char *dbase;
register int i;
sYOffset = sBM->bmheight - (sYOffset + height);
dYOffset = dBM->bmheight - (dYOffset + height);
nbase = (DLword *)Addr68k_from_LADDR(sBM->bmbase) + (sBM->bmrasterwidth * sYOffset);
(DLword *)dbase = (DLword *)Addr68k_from_LADDR(dBM->bmbase) + (dBM->bmrasterwidth * dYOffset);
for (i = 0, dbase += dXOffset; /* 8bpp */
i < height; i++, nbase += sBM->bmrasterwidth, ((DLword *)dbase) += dBM->bmrasterwidth) {
lineBlt8(nbase, (int)sXOffset, dbase, (int)width, col0, col1, sourcetype, operation);
} /* for end */
} /* ColorizeFont8 end */
/************************************************************************/
/* */
/* C o l o r i z e d F o n t 8 _ B I G B M */
/* */
/* Expand a 1bpp font to 8bpp colorized font bitmap, using */
/* col1 and col0 as the colors for 1 bits & 0 bits, respectively. */
/* */
/* dbm must be the output BIGBM (not a bitmap), whose bpp is 8. */
/* */
/************************************************************************/
void ColorizeFont8_BIGBM(BITMAP *sBM, DLword sXOffset, DLword sYOffset, BIGBM *dBM, DLword dXOffset, DLword dYOffset, DLword width, DLword height, u_char col0, u_char col1,
LispPTR sourcetype, LispPTR operation)
{
register DLword *nbase;
register u_char *dbase;
register int i;
int dest_bottom, dest_bigbmheight, dest_fragtop, dest_fragbottom, dest_yoffset, dest_h;
LispPTR dest_bmlist;
BITMAP *dest_frag;
SFGetNum(dBM->bigbmheight, dest_bigbmheight);
sYOffset = sBM->bmheight - (sYOffset + height);
dYOffset = dest_bigbmheight - (dYOffset + height);
dest_bottom = dYOffset + height;
dest_bmlist = (LispPTR)dBM->bigbmlist;
GetNewFragment(dest_bmlist, dest_frag, BITMAP *);
dest_fragtop = 0;
dest_fragbottom = dest_frag->bmheight;
/* search fragment of bitmaps including the desitnation top. */
while (dest_fragbottom <= dYOffset) {
GetNewFragment(dest_bmlist, dest_frag, BITMAP *);
if (dest_frag == (BITMAP *)Addr68k_from_LADDR(NIL_PTR)) return;
dest_fragtop = dest_fragbottom;
dest_fragbottom += dest_frag->bmheight;
} /* end while */
/* y offset form bitmap top. */
dest_yoffset = dYOffset - dest_fragtop;
loop:
/* height of lineBlt8 */
if (dest_fragbottom > dest_bottom) {
/* this fragment inludes dest bottom. */
dest_h = dest_bottom - (dest_fragtop + dest_yoffset);
} else {
/* remaining fragments include dest bottom. */
dest_h = dest_fragbottom - (dest_fragtop + dest_yoffset);
} /* end if */
dbase =
(DLword *)Addr68k_from_LADDR(dest_frag->bmbase) + (dest_frag->bmrasterwidth * dest_yoffset);
nbase = (DLword *)Addr68k_from_LADDR(sBM->bmbase) + (sBM->bmrasterwidth * sYOffset);
sYOffset += (DLword)dest_h; /* next src yoffset */
for (i = 0, dbase += dXOffset; i < dest_h;
i++, nbase += sBM->bmrasterwidth, ((DLword *)dbase) += dest_frag->bmrasterwidth) {
lineBlt8(nbase, (int)sXOffset, dbase, (int)width, col0, col1, sourcetype, operation);
}
/* remaining height */
height -= dest_h;
if (height > 0) {
GetNewFragment(dest_bmlist, dest_frag, BITMAP *);
if (dest_frag != (BITMAP *)Addr68k_from_LADDR(NIL_PTR)) {
dest_fragtop = dest_fragbottom;
dest_fragbottom = dest_fragtop + dest_frag->bmheight;
dest_yoffset = 0; /* y offset must be zero. */
nbase += sBM->bmrasterwidth;
goto loop;
} /* end if(dest_frag) */
} /* end if(height) */
} /* end ColorizeFont8_BIGBM() */
/************************************************************************/
/* */
/* n e w C o l o r i z e F o n t 8 */
/* */
/* */
/* */
/************************************************************************/
void newColorizeFont8(PILOTBBT *pbt, u_char backcolor, u_char forecolor, LispPTR srctype, LispPTR ope)
{
register DLword *nbase;
register u_char *dbase;
register int i;
nbase = (DLword *)Addr68k_from_LADDR((pbt->pbtsourcehi << 16) | (pbt->pbtsourcelo));
(DLword *)dbase = (DLword *)Addr68k_from_LADDR((pbt->pbtdesthi << 16) | (pbt->pbtdestlo));
dbase += pbt->pbtdestbit;
for (i = 0; i < pbt->pbtheight;
i++, nbase += pbt->pbtsourcebpl / 16, dbase += pbt->pbtdestbpl / 8) {
lineBlt8(nbase, pbt->pbtsourcebit, dbase, pbt->pbtwidth, backcolor, forecolor, srctype, ope);
} /* for end */
}
/************************************************************************/
/* */
/* U n c o l o r i z e _ B i t m a p */
/* */
/* Uncolorize bitmap from 8bpp to 1bpp. */
/* */
/************************************************************************/
void Uncolorize_Bitmap(LispPTR args[])
{
BITMAP *s_bitmap, *d_bitmap;
register DLword *OnOff;
register u_char *s_base;
register DLword *d_base;
register int y;
int s_height, s_width, s_bitsperpixel, s_rasterwidth, d_rasterwidth;
s_bitmap = (BITMAP *)Addr68k_from_LADDR(args[0]);
d_bitmap = (BITMAP *)Addr68k_from_LADDR(args[1]);
OnOff = (DLword *)Addr68k_from_LADDR(args[2]);
s_height = s_bitmap->bmheight;
s_width = s_bitmap->bmwidth;
s_bitsperpixel = s_bitmap->bmbitperpixel;
if (s_bitsperpixel != 8) return;
s_base = (u_char *)Addr68k_from_LADDR(s_bitmap->bmbase);
d_base = (DLword *)Addr68k_from_LADDR(d_bitmap->bmbase);
s_rasterwidth = s_bitmap->bmrasterwidth;
d_rasterwidth = d_bitmap->bmrasterwidth;
for (y = 0; y < s_height; y++) {
register int x;
register DLword word;
word = 0;
for (x = 0; x < s_width; x++) {
if (OnOff[*(s_base + x)]) {
switch (x & 0xF) {
case 0: word |= 0x8000; break;
case 1: word |= 0x4000; break;
case 2: word |= 0x2000; break;
case 3: word |= 0x1000; break;
case 4: word |= 0x800; break;
case 5: word |= 0x400; break;
case 6: word |= 0x200; break;
case 7: word |= 0x100; break;
case 8: word |= 0x80; break;
case 9: word |= 0x40; break;
case 10: word |= 0x20; break;
case 11: word |= 0x10; break;
case 12: word |= 0x8; break;
case 13: word |= 0x4; break;
case 14: word |= 0x2; break;
case 15:
word |= 0x1;
break;
defaults:
break;
} /* end switch( x ) */
} /* end if( ) */
if ((x & 0xF) == 0xF) {
*(d_base++) = word;
word = 0;
} /* end if( x ) */
} /* end for( x ) */
if ((x & 0xF) != 0) *(d_base++) = word;
if (y != (s_height - 1)) { (DLword *)s_base += s_rasterwidth; } /* end if( y ) */
} /* end for( y ) */
} /* end Uncolorize_Bitmap() */
/************************************************************************/
/* */
/* C o l o r i z e _ B i t m a p */
/* */
/* Colorize bitmap from 1bpp to 8bpp. */
/* */
/************************************************************************/
extern DLword INPUT_atom, REPLACE_atom;
LispPTR Colorize_Bitmap(LispPTR args[])
{
BITMAP *s_bitmap, *d_bitmap;
int s_left, s_bottom, d_left, d_bottom, width, height, color0, color1, d_nbits;
register DLword *s_base;
register u_char *d_base;
register int i;
N_GETNUMBER(args[10], d_nbits, bad_arg);
if (d_nbits != 8) return (NIL); /* do nothing. */
s_bitmap = (BITMAP *)Addr68k_from_LADDR(args[0]);
N_GETNUMBER(args[1], s_left, bad_arg);
N_GETNUMBER(args[2], s_bottom, bad_arg);
d_bitmap = (BITMAP *)Addr68k_from_LADDR(args[3]);
N_GETNUMBER(args[4], d_left, bad_arg);
N_GETNUMBER(args[5], d_bottom, bad_arg);
N_GETNUMBER(args[6], width, bad_arg);
N_GETNUMBER(args[7], height, bad_arg);
N_GETNUMBER(args[8], color0, bad_arg);
N_GETNUMBER(args[9], color1, bad_arg);
s_base = (DLword *)Addr68k_from_LADDR(s_bitmap->bmbase) +
s_bitmap->bmrasterwidth * (s_bitmap->bmheight - (s_bottom + height));
(DLword *)d_base = (DLword *)Addr68k_from_LADDR(d_bitmap->bmbase) +
d_bitmap->bmrasterwidth * (d_bitmap->bmheight - (d_bottom + height));
for (i = 0, d_base += d_left; i < height;
i++, s_base += s_bitmap->bmrasterwidth, (DLword *)d_base += d_bitmap->bmrasterwidth) {
lineBlt8(s_base, s_left, d_base, width, (u_char)color0, (u_char)color1, INPUT_atom,
REPLACE_atom);
} /* end for(i) */
bad_arg:
return (NIL);
} /* end Colorize_Bitmap() */
/************************************************************************/
/* */
/* D r a w _ 8 B p p C o l o r L i n e */
/* */
/* Draw a line in the 8-bpp display bitmap. */
/* */
/************************************************************************/
#define op_replace =
#define op_erase &=
#define op_invert ^=
#define op_paint |=
#define draw8bpplinex(op) \
while ((x0 <= xlimit) && (y0 <= ylimit)) { \
*(base++)op color; \
++x0; \
cdl += dy; \
if (dx <= cdl) { \
cdl -= dx; \
base += yinc; \
++y0; \
} \
}
#define draw8bppliney(op) \
while ((x0 <= xlimit) && (y0 <= ylimit)) { \
*base op color; \
base += yinc; \
++y0; \
cdl += dx; \
if (dy <= cdl) { \
cdl -= dy; \
++base; \
++x0; \
} \
}
void Draw_8BppColorLine(LispPTR *args)
{
extern DLword REPLACE_atom, INVERT_atom, PAINT_atom, ERASE_atom;
extern int ScreenLocked;
register u_char color;
register u_char *base;
register short x0, y0, xlimit, ylimit, dx, dy, cdl, yinc, raster_width;
int mode, displayflg;
u_char *n_bmbase;
x0 = (short)(args[0] & 0xffff);
y0 = (short)(args[1] & 0xffff);
xlimit = (short)(args[2] & 0xffff);
ylimit = (short)(args[3] & 0xffff);
dx = (short)(args[4] & 0xffff);
dy = (short)(args[5] & 0xffff);
cdl = (short)(args[6] & 0xffff);
yinc = (short)(args[7] & 0xffff);
yinc *= 2; /* for byte addressing */
if (args[8] == PAINT_atom)
mode = 3;
else if (args[8] == INVERT_atom)
mode = 2;
else if (args[8] == ERASE_atom)
mode = 1;
else
mode = 0; /* REPLACE_atom */
n_bmbase = (u_char *)Addr68k_from_LADDR(args[9]);
raster_width = (short)(args[10] & 0xffff);
color = (u_char)(args[11] & 0xff);
if (yinc >= 0) {
displayflg = n_new_cursorin((DLword *)n_bmbase, (int)(x0 << 3), (int)y0, (int)(xlimit << 3),
(int)ylimit);
} else {
displayflg = n_new_cursorin((DLword *)n_bmbase, (int)(x0 << 3), (int)(y0 - ylimit),
(int)(xlimit << 3), (int)ylimit);
}
base = n_bmbase + y0 * (raster_width << 1) + x0;
x0 = y0 = 0;
if (displayflg) {
ScreenLocked = T;
HideCursor;
}
if (dx >= dy) { /* .draw8bpplinex */
switch (mode) {
case 0: draw8bpplinex(op_replace); break;
case 1: draw8bpplinex(op_erase); break;
case 2: draw8bpplinex(op_invert); break;
case 3: draw8bpplinex(op_paint); break;
} /* end switch */
} else { /* .draw8bppliney */
switch (mode) {
case 0: draw8bppliney(op_replace); break;
case 1: draw8bppliney(op_erase); break;
case 2: draw8bppliney(op_invert); break;
case 3: draw8bppliney(op_paint); break;
} /* end switch */
} /* end if( dx >= dy ) */
if (displayflg) {
ShowCursor;
ScreenLocked = NIL;
}
} /* end Draw_8BppColorLine */