jchvr@ihlpg.ATT.COM (Schipaanboord) (06/18/88)
I have written a TSR that comes up beatifully provided that you are either
in textmode or in graphics on a CGa monitor. However when i pop up while
in graphics on my EGA equipped system then all works well execpt that when
I return from my TSR the screen is blank. If the program I was running before
the TSR interuppted it has a repaint possibility then this will restore it
nicely, but most graphics programs do not bother.
QUESTION what do I need to do in order to restore the graphics on a EGA screen
See below on everything I do and that DOES work for CGA type graphics:
I use pushscreen() tosave the state and try with popscreen() to restore it.
In between I use all kinds of standard DOS int10 functions to set textmodes
move cursors etc.
As soon as I solve this problem I will be able to post the TSr with sources
to the world, without this bug soved I do not feel like it. I have also
noticed that other professional TSR's have this problem, but it must be
solvable I hope.
#include "va.h"
#if MSDOS & LATTICE
#define CDCGA 0 /* color graphics card */
#define CDMONO 1 /* monochrome text card */
/* getboard: Determine which type of display board is attached.
Current known types include:
CDMONO Monochrome graphics adapter
CDCGA Color Graphics Adapter
CDEGA Extended graphics Adapter
*/
/* getboard: Detect the current display adapter
if MONO set to MONO
CGA set to CGA
EGA set to CGA
*/
int boardSEG; /* Segment of screen memory */
static int mode; /* mode of screen image */
static int xcursor; /* xcoord. of cursor */
static int ycursor; /* ycoord. of cursor */
static int page; /* display page nr */
static int curch; /* cursor h value */
static int curcl; /* cursor l value */
static byte screen[16384]; /* old screen */
static byte lowmem[30]; /* 0000:0449h 30 bytes video stuff */
int getboard()
{ union REGS rg;
int type; /* board type to return */
type = CDCGA;
int86(0x11, &rg, &rg);
if ((((rg.x.ax >> 4) & 3) == 3))
type = CDMONO;
switch (type) {
case CDCGA:
boardSEG = 0xb800;
break;
case CDMONO:
boardSEG = 0xb000;
break;
}
}/*getboard*/
getpage()
{ union REGS rg;
rg.h.ah = 0xf;
int86(0x10,&rg,&rg); /* get current display page and mode */
page = rg.h.bh;
mode = rg.h.al;
}/*getpage*/
putpage()
{ union REGS rg;
/* check mode only if diff then set */
rg.h.ah = 0xf;
int86(0x10,&rg,&rg);
if (rg.h.al == mode) {
/* nothing */
} else {
rg.h.ah = 0;
rg.h.al = mode;
int86(0x10,&rg,&rg); /* set mode */
}
/* set display page if different */
rg.h.ah = 0xf;
int86(0x10,&rg,&rg);
if (rg.h.bh == page) {
/* nothing */
} else {
rg.h.ah = 0x5;
rg.h.al = page;
int86(0x10,&rg,&rg); /* set active page */
}
}/*putpage*/
putcursor()
{ union REGS rg;
rg.h.ah = 0x1;
rg.h.ch = curch;
rg.h.cl = curcl;
int86(0x10,&rg,&rg); /* set cursor size */
rg.h.ah = 0x2;
rg.h.bh = page;
rg.h.dh = ycursor;
rg.h.dl = xcursor;
int86(0x10,&rg,&rg); /* set cursor position */
}/*putcursor*/
getcursor()
{ union REGS rg;
rg.h.ah = 0x3;
rg.h.bh = page;
int86(0x10,&rg,&rg); /* get cursor position and size */
curch = rg.h.ch;
curcl = rg.h.cl;
xcursor = rg.h.dl;
ycursor = rg.h.dh;
}/*getcursor*/
/* getlowmem*/
getlowmem()
{
peek(0,0x449,lowmem,30);
}/*getlowmem*/
/* putlowmem */
putlowmem()
{
poke(0,0x449,lowmem,30);
}/*putlowmem*/
/* copy current screen into screen[] */
pushscreen()
{/* struct SREGS segregs; */
getlowmem();
getboard();
/* segread(&segregs); */
/* movedata(boardSEG,0,segregs.ds,screen,16384); */
peek(boardSEG,0,screen,16384);
getpage(); /* get display page and mode */
getcursor();
}/*getscreen*/
/* fill current screen with contents of screen[] */
popscreen()
{/* struct SREGS segregs; */
putpage(); /* put display page and mode */
putcursor();
/* segread(&segregs); */
/* movedata(segregs.ds,screen,boardSEG,0,16384); */
poke(boardSEG,0,screen,16384);
putlowmem();
}/*putscreen*/
#endif