#include "X.h"
#define NEED_EVENTS
#include "Xproto.h"
#include "misc.h"
#include "window.h"
#include "windowstr.h"
#include "dix.h"
#include <dos.h>
#include "scrnintstr.h"
#include "gcstruct.h"
#include "servermd.h"
#include "pixmap.h"
#include "pixmapst.h"
#include "ega.h"

Bool
egaClose(index, pScreen)
int index;
ScreenPtr pScreen;
{
    if (egapriv.fb) {
	(*vga_conf.close)();
	egapriv.fb = 0;
    }
    if (pScreen == 0)
	return FALSE;
    pScreen->devPrivate = 0;
    return TRUE;
}

egaSaveScreen(pScr, on)
ScreenPtr pScr;
int on;
{

	outp(0x3c4, 1);
	if (on == SCREEN_SAVER_OFF)
		outp(0x3c5, inp(0x3c5) & ~0x20);
	else
		outp(0x3c5, inp(0x3c5) | 0x20);
	return TRUE;
}

void
egaQueryBestSize(kind, pWidth, pHeight)
int kind;
unsigned short *pWidth, *pHeight;
{
	unsigned width, test;

	switch (kind) {
	    case CursorShape:
		*pWidth = 16;
		*pHeight = 16;
		break;
	    case TileShape:
	    case StippleShape:
		width = *pWidth;
		if (width > 0) {
			/* Find the smallest power of two greater than
			 * width. */
			test = 1;
			while (test < width)
				test <<= 1;
			*pWidth = test;
		}
		break;
	}
}

void
egaWakeupHandler(index, a, mask, c)
int index;
pointer a, c;
unsigned long mask;
{
}
