home *** CD-ROM | disk | FTP | other *** search
- /*
- pcdisp.c
-
- % PC device interface display functions common to all modes.
-
- 4/24/89 by Ted.
-
- OWL-PC 1.2
- Copyright (c) 1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 4/26/89 ted Moved attrmap out of info struct into pcdata.
- 8/01/89 ted Moved pc_init/restoremode from pcmode.c.
-
- 11/03/89 ted Allowed blinking text wordcolor values.
- 11/07/89 ted Changed reference to pcdata->oldmode to pc_GetMode in
- pc_initmode to facilitate curr_dmgr swapping.
-
- 1/08/90 ted Made GETATTRFG/BG msgs return all 8 bits to fix ptd_Clear
- problem, and made pc_wordcolor use all 8 bits for text mode.
-
- 2/14/90 ted Got rid of fontreq_struct. Just use fontdesc_struct.
- 3/04/90 ted Added non-functional support for DC_PV messages.
- 3/21/90 ted Added DC_HIDEMOUSE, DC_SHOWMOUSE cases to pc_dControl
- 3/28/90 jmd ansi-fied
- 6/22/90 ted added "void"s to no-parameter functions per ansii.
- 12/05/90 ted tweaked wordcolor text-mode same-color case to intensify fg.
- */
-
- #include "pcpriv.h"
-
- OSTATIC void DIGPRIV pc_restoremode(void);
-
- /* -------------------------------------------------------------------------- */
-
- int pc_dControl(dig_dcmsg msg, VOID *indata, VOID *outdata)
- {
- setattr_struct *pvs;
- ptarg_struct *pta;
- OREGS regs;
-
- switch (msg) {
- case DC_GETINFO:
- *((dispinfo_struct **)(outdata)) = &pcdata->info;
- break;
- case DC_INITMODE:
- pc_initmode();
- break;
- case DC_RESTOREMODE:
- pc_restoremode();
- break;
- case DC_SETATTRCOLS:
- pvs = (setattr_struct *)indata;
-
- pcdata->attrmap[pvs->attr] = ((byte) (pvs->fg)) & 0x0F;
- pcdata->attrmap[pvs->attr] |= ((byte) (pvs->bg)) << 4;
- break;
- case DC_GETATTRFG:
- *((opixval *) outdata) = (opixval) pcdata->attrmap[*((byte *)indata)];
- break;
- case DC_GETATTRBG:
- *((opixval *) outdata) =
- (opixval) ( (pcdata->attrmap[*((byte *)indata)] >> 4) |
- (pcdata->attrmap[*((byte *)indata)] << 4) );
- break;
- case DC_SETCOLMAP:
- case DC_GETCOLMAP:
- break;
-
- case DC_PVFINDRGB: /* indata is (findcol_struct *), outdata is (opixval *), ret is int dist or -1 for failure */
- return(-1);
- case DC_PVALLOC: /* indata is void, outdata is (opixval *), ret is TRUE/FALSE */
- case DC_PVMAKERO: /* indata is (opixval *), outdata is void, ret is void */
- case DC_PVFREE: /* indata is (opixval *), outdata is void, ret is void */
- return(FALSE);
-
- case DC_OPENFONT:
- memmove((VOID *)(ofont_type)outdata, (VOID *)&pcdata->info.def_font,
- sizeof(struct ofont_struct));
- memmove((VOID *)(&((ofont_type)outdata)->req), (VOID *)indata,
- sizeof(fontdesc_struct));
- break;
- case DC_READCHARATTR:
- pta = (ptarg_struct *)indata;
- memset(pta->charbuf, ' ', pta->slen);
- memset(pta->attrbuf, 0x07, pta->slen);
- break;
- case DC_HIDEMOUSE:
- case DC_CACHE:
- if (pchdata->ismouse) {
- regs.x.ax = BMOU_HIDE;
- oakint86(BIOS_MOUSEINT, ®s);
- }
- break;
- case DC_SHOWMOUSE:
- case DC_FLUSH:
- if (pchdata->ismouse) {
- regs.x.ax = BMOU_SHOW;
- oakint86(BIOS_MOUSEINT, ®s);
- }
- break;
- }
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- unsigned short DIGPRIV pc_wordcolor(opixval color)
- /*
- Return a 16 bit value which can be repeated to clear a region to the
- given color. (Only used for one-plane pixmaps.)
- */
- {
- unsigned short colword;
- struct { byte bot, top; } dblcol;
- static unsigned short cols4[4] = { 0x0000, 0x5555, 0xAAAA, 0xFFFF };
- byte fgnib;
-
- switch (pc_pixbits()) {
- case 16: /* text mode */
- dblcol.bot = ' ';
- /* Put color val in bg slot, and take next 4 bits for fg slot, or
- itensify bg for fg slot if next 4 are same as bg.
- (We do this so that the DOS prompt will be visible in case program
- exits w/ screen this color.)
- */
- dblcol.top = ((byte) color) << 4;
-
- fgnib = (((byte) color) >> 4) & 0x0F;
- /* Ignore blink bit; don't take intensity bit; don't take MDA underline
- fg attribute */
- if (fgnib == (((byte) color) & 0x07) && fgnib != 1) {
- fgnib |= 0x08; /* Poke in the intensity bit to guarantee visibility */
- }
- dblcol.top |= fgnib;
-
- return(*((unsigned short *)&dblcol));
- case 2:
- colword = cols4[(byte)color & 0x03];
- return(colword);
- case 1:
- if (pc_nplanes() <= 1) { /* one-plane / 2-color display mode */
- if ((byte)color & 1) {
- colword = 0xFFFF;
- }
- else {
- colword = 0x0000;
- }
- return(colword);
- }
- /* else no break; EGA/VGA clear requires the real color to write thru */
- default:
- case 8:
- dblcol.bot = (byte)color;
- dblcol.top = dblcol.bot;
- return(*((unsigned short *)&dblcol));
- }
- }
- /* -------------------------------------------------------------------------- */
-
- void DIGPRIV pc_bgetcursorpos(int *rowp, int *colp)
- {
- OREGS regs;
-
- regs.h.ah = VIDINT_GETC;
- regs.h.bh = TEXT_RPAGE;
- oakint86(BIOS_VIDINT, ®s);
-
- *colp = (int)regs.h.dl; /* get global cursor col */
- *rowp = (int)regs.h.dh; /* get global cursor row */
- }
- /* -------------------------------------------------------------------------- */
-
- unsigned pc_dDummy(void)
- {
- return(0);
- }
- /* -------------------------------------------------------------------------- */
-
- void DIGPRIV pc_initmode(void)
- /*
- Init the display video mode.
- */
- {
- if (pc_GetMode() != pcdata->info.mode) {
- pc_SetMode(pcdata->info.mode);
- }
- /* Make sure cursor gets turned off if necessary */
- switch (pcdata->info.mode) {
- case 0x00:
- case 0x01:
- case 0x02:
- case 0x03:
- case 0x07:
- case PCMODE_EGA43:
- case PCMODE_VGA50:
- pcdata->curctype = CURSOR_NONE;
- pc_bsetcursortype(CURSOR_NONE, pcdata->fontlines);
- break;
- }
- }
- /* -------------------------------------------------------------------------- */
-
- static void DIGPRIV pc_restoremode(void)
- {
- if (pcdata->oldmode != pcdata->info.mode) {
- pc_SetMode(pcdata->oldmode);
- pc_bsetcursorpos(0, 0);
- }
- else { /* If not changing modes or clearing screen, restore cursor pos */
- pc_bsetcursorpos(pcdata->oldcursx, pcdata->oldcursy);
- }
- switch (pcdata->oldmode) {
- case 0x00:
- case 0x01:
- case 0x02:
- case 0x03:
- case 0x07:
- case PCMODE_EGA43:
- case PCMODE_VGA50:
- pc_bsetcursortype(CURSOR_NORMAL,
- (opcoord)((pcdata->oldmode == 0x07) ? 14 : 8));
- break;
- }
- }
- /* -------------------------------------------------------------------------- */
-
-