home *** CD-ROM | disk | FTP | other *** search
- /*
- pcgfuncs.c
-
- % pc_setgfuncs
-
- OWL 1.1
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 10/19/88 ted Extracted from pcdisp.c
- 01/10/89 ted Removed redundant disp clip.
- 1/18/89 Ted changed call to PlotText for simplified interface.
- 3/02/89 Ted restored ah in bios plot calls because of clone bios bug.
- 6/15/89 Ted got rid of BLOCKCHAR plotting, used _Clear funcs instead.
- 6/17/89 Ted split pc_bgPlotText into evga_Plot-, mcga_Plot-, pc_bgPlot-.
- 7/12/89 ted Added OSTATIC's and '_func' macros.
- 7/14/89 ted Installed no-bios graphics char plotter.
- */
-
- #define DEFDEFCMAPS /* allow pcdef cmap declarations in this file */
-
- #include "pcpriv.h"
-
- OGLOBAL ocolmap_struct(2) pcdefmcmap = PC_DEF_MCMAPINIT;
- OGLOBAL ocolmap_struct(16) pcdefcmap = PC_DEF_CMAPINIT;
-
- OSTATIC dig_pPlotText_func (pc_gPlotText);
- OSTATIC dig_pDrawCursor_func (pc_gDrawCursor);
- /* -------------------------------------------------------------------------- */
-
- void DIGPRIV pc_setgfuncs(digp)
- dig_struct *digp;
- {
- digp->CloseDIG = pc_CloseDIG;
- digp->dControl = pc_dControl;
-
- digp->pPlotText = pc_gPlotText;
- digp->pDrawCursor = pc_gDrawCursor;
- digp->pClear = ram_Clear;
- digp->pScrollBoxVt = ram_ScrollBoxVt;
- digp->pScrollBoxHz = ram_ScrollBoxHz;
-
- digp->pDrawPixmap = ram_DrawPixmap;
- digp->pReadPixmap = ram_ReadPixmap;
- digp->pControl = pc_pControl;
-
- digp->vtscroll = TRUE;
- digp->hzscroll = TRUE;
- digp->textfree = FALSE;
- digp->evcheck = TRUE;
- digp->type = 0;
- digp->version = 0;
- }
- /* -------------------------------------------------------------------------- */
-
- unsigned DIGPRIV pc_attrcols(rattr)
- byte rattr;
- /*
- Return a word with foreground pixval in the low byte and background
- pixval in the high byte.
- */
- {
- union {
- struct { byte bot, top; } dblcol;
- unsigned short x;
- } splitcol;
-
- rattr = pcdata->attrmap[rattr];
-
- splitcol.dblcol.bot = rattr & 0x0F;
- splitcol.dblcol.top = rattr >> 4;
-
- return((unsigned) splitcol.x);
- }
- /* -------------------------------------------------------------------------- */
-
- static void pc_gPlotText(ptd, x, y, charbuf, rchar, rattr, slen)
- ptd_struct *ptd;
- opcoord x;
- opcoord y;
- char *charbuf;
- char rchar;
- byte rattr;
- int slen;
- /*
- Plot text/attribute buffers to screen at (x,y), clipped into ptd->relboxp.
- */
- {
- win_type win;
- opbox clipbox;
- int delta;
- int ichar;
-
- win = ptd->win;
-
- /* Clip the string so that it doesn't overlap its box anywhere */
-
- opbox_copy(&clipbox, ptd->relboxp);
- opbox_trans(&clipbox, win_GetXmin(win), win_GetYmin(win));
- x += win_GetXmin(win);
- y += win_GetYmin(win);
-
- delta = opbox_clipstring(&clipbox, &x, &y, &slen, win_GetFont(win));
- if (slen <= 0) {
- return;
- }
- if (charbuf != NULL) charbuf += delta;
-
- /* Do the nitty gritty */
-
- /* Note: these parameters put in the pcdata structure for use by */
- /* the plotchar function to save argument passing overhead: */
- /* dispaddr, nplanes, ilmask, ilsize, vbincr, vidaddr, nsame, splitcol */
-
- y -= pcdata->fontlines;
- pcdata->vidaddr = (y & pcdata->ilmask) * pcdata->ilsize +
- (y >> pc_ileave()) * pc_bwidth() +
- x * pc_pixbits() / 8;
-
- pcdata->splitcol = (*pcdata->attrcols)(rattr);
- pcdata->starty = y;
-
- for (ichar = 0; ichar < slen; ) {
-
- /* Get character and figure out repeat count */
- if (charbuf == NULL) {
- pcdata->nsame = slen;
- }
- else {
- rchar = *charbuf++;
- pcdata->nsame = 1;
- while (*charbuf == rchar) {
- if (ichar + pcdata->nsame >= slen) break;
- pcdata->nsame++;
- charbuf++;
- }
- }
- /* Compute address of character in font */
- if ((byte) rchar < 128) {
- pcdata->fontoffs = pcdata->fontoffs0 +
- ((unsigned) rchar) * pcdata->fontlines;
- pcdata->fontseg = pcdata->fontseg0;
- }
- else {
- pcdata->fontoffs = pcdata->fontoffs1 +
- ((unsigned)((byte) rchar - 128)) * pcdata->fontlines;
- pcdata->fontseg = pcdata->fontseg1;
- }
- /* Plot string of identical chars using info set up in pcdata */
- (*pcdata->plotchar)();
-
- ichar += pcdata->nsame;
- if (ichar >= slen) {
- break;
- }
- pcdata->vidaddr += pcdata->nsame * pc_pixbits(); /* /8 *(fontwidth = 8) */
- }
- }
- /* -------------------------------------------------------------------------- */
-
- static void pc_gDrawCursor(ptd, ctype)
- ptd_struct *ptd;
- cursortype ctype;
- {
- win_type win;
- opbox cursbox;
- opbox *opboxp;
-
- if (ctype != CURSOR_NONE) {
- win = ptd->win;
- dig_getcursbox(win, ctype, &cursbox);
- cursbox.xmax += 1; /* Compensate for getcursb making 7 bit box. */
- if (opbox_clipbox(ptd->relboxp, &cursbox)) {
- opboxp = ptd->relboxp;
- ptd->relboxp = &cursbox;
- ram_Clear(ptd, win_GetFgColor(win));
- ptd->relboxp = opboxp;
- }
- }
- }
- /* -------------------------------------------------------------------------- */
-
-