home *** CD-ROM | disk | FTP | other *** search
- /*
- pcdisp.c
-
- % PC device interface display functions common to all modes.
-
- 4/24/89 by Ted.
-
- OWL 1.1
- 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.
- */
-
- #include "pcpriv.h"
-
- OSTATIC void DIGPRIV pc_restoremode(_arg1(void));
- /* -------------------------------------------------------------------------- */
-
- int pc_dControl(msg, indata, outdata)
- 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)] & 0x0F);
- break;
- case DC_GETATTRBG:
- *((opixval *) outdata) = (opixval)
- (pcdata->attrmap[*((byte *)indata)] >> 4);
- break;
- case DC_SETCOLMAP:
- case DC_GETCOLMAP:
- case DC_CLAIMCOLOR:
- case DC_RELEASECOLOR:
- break;
- 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(fontreq_struct));
- break;
- case DC_READCHARATTR:
- pta = (ptarg_struct *)indata;
- memset(pta->charbuf, ' ', pta->slen);
- memset(pta->attrbuf, 0x07, pta->slen);
- break;
- case DC_CACHE:
- if (pchdata->ismouse) {
- regs.x.ax = BMOU_HIDE;
- oakint86(BIOS_MOUSEINT, ®s);
- }
- break;
- case DC_FLUSH:
- if (pchdata->ismouse) {
- regs.x.ax = BMOU_SHOW;
- oakint86(BIOS_MOUSEINT, ®s);
- }
- break;
- }
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- unsigned short DIGPRIV pc_wordcolor(color)
- 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 };
-
- switch (pc_pixbits()) {
- case 16: /* text mode */
- dblcol.bot = ' ';
- /* put color val in bgcolor slot, and invert it for fgcolor slot */
- dblcol.top = (byte)color & 0x07;
- dblcol.top = (dblcol.top ^ 0x07) | (dblcol.top << 4);
- 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(rowp, colp)
- 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()
- {
- return(0);
- }
- /* -------------------------------------------------------------------------- */
-
- void DIGPRIV pc_initmode()
- /*
- Init the display video mode.
- */
- {
- if (pcdata->oldmode != 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()
- {
- 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;
- }
- }
- /* -------------------------------------------------------------------------- */
-
-