1998-11-01 13:51:47 +01:00
|
|
|
|
/*
|
|
|
|
|
* VGA hardware emulation
|
|
|
|
|
*
|
|
|
|
|
* Copyright 1998 Ove K<EFBFBD>ven (with some help from Marcus Meissner)
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "winbase.h"
|
2001-06-19 20:14:08 +02:00
|
|
|
|
#include "wingdi.h"
|
|
|
|
|
#include "winuser.h"
|
2000-02-03 01:46:29 +01:00
|
|
|
|
#include "wincon.h"
|
1998-11-01 13:51:47 +01:00
|
|
|
|
#include "miscemu.h"
|
2001-12-04 20:54:44 +01:00
|
|
|
|
#include "dosexe.h"
|
1998-11-01 13:51:47 +01:00
|
|
|
|
#include "vga.h"
|
|
|
|
|
#include "ddraw.h"
|
2000-02-03 01:46:29 +01:00
|
|
|
|
#include "services.h"
|
1999-06-26 21:09:08 +02:00
|
|
|
|
#include "debugtools.h"
|
1998-11-01 13:51:47 +01:00
|
|
|
|
|
2000-11-28 00:54:25 +01:00
|
|
|
|
DEFAULT_DEBUG_CHANNEL(ddraw);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
|
1998-11-01 13:51:47 +01:00
|
|
|
|
static IDirectDraw *lpddraw = NULL;
|
|
|
|
|
static IDirectDrawSurface *lpddsurf;
|
|
|
|
|
static IDirectDrawPalette *lpddpal;
|
|
|
|
|
static DDSURFACEDESC sdesc;
|
2000-02-03 01:46:29 +01:00
|
|
|
|
static LONG vga_polling,vga_refresh;
|
|
|
|
|
static HANDLE poll_timer;
|
|
|
|
|
|
2001-01-05 04:44:40 +01:00
|
|
|
|
typedef HRESULT WINAPI (*DirectDrawCreateProc)(LPGUID,LPDIRECTDRAW *,LPUNKNOWN);
|
|
|
|
|
static DirectDrawCreateProc pDirectDrawCreate;
|
2000-03-17 17:58:10 +01:00
|
|
|
|
|
2001-11-07 21:54:08 +01:00
|
|
|
|
static PALETTEENTRY vga_def_palette[256]={
|
|
|
|
|
/* red green blue */
|
|
|
|
|
{0x00, 0x00, 0x00}, /* 0 - Black */
|
|
|
|
|
{0x00, 0x00, 0x80}, /* 1 - Blue */
|
|
|
|
|
{0x00, 0x80, 0x00}, /* 2 - Green */
|
|
|
|
|
{0x00, 0x80, 0x80}, /* 3 - Cyan */
|
|
|
|
|
{0x80, 0x00, 0x00}, /* 4 - Red */
|
|
|
|
|
{0x80, 0x00, 0x80}, /* 5 - Magenta */
|
|
|
|
|
{0x80, 0x80, 0x00}, /* 6 - Brown */
|
|
|
|
|
{0xC0, 0xC0, 0xC0}, /* 7 - Light gray */
|
|
|
|
|
{0x80, 0x80, 0x80}, /* 8 - Dark gray */
|
|
|
|
|
{0x00, 0x00, 0xFF}, /* 9 - Light blue */
|
|
|
|
|
{0x00, 0xFF, 0x00}, /* A - Light green */
|
|
|
|
|
{0x00, 0xFF, 0xFF}, /* B - Light cyan */
|
|
|
|
|
{0xFF, 0x00, 0x00}, /* C - Light red */
|
|
|
|
|
{0xFF, 0x00, 0xFF}, /* D - Light magenta */
|
|
|
|
|
{0xFF, 0xFF, 0x00}, /* E - Yellow */
|
|
|
|
|
{0xFF, 0xFF, 0xFF}, /* F - White */
|
|
|
|
|
{0,0,0} /* FIXME: a series of continuous rainbow hues should follow */
|
|
|
|
|
};
|
|
|
|
|
|
2000-02-03 01:46:29 +01:00
|
|
|
|
static void VGA_DeinstallTimer(void)
|
|
|
|
|
{
|
|
|
|
|
if (poll_timer) {
|
|
|
|
|
SERVICE_Delete( poll_timer );
|
|
|
|
|
poll_timer = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void VGA_InstallTimer(unsigned Rate)
|
|
|
|
|
{
|
|
|
|
|
VGA_DeinstallTimer();
|
|
|
|
|
if (!poll_timer)
|
|
|
|
|
poll_timer = SERVICE_AddTimer( Rate, VGA_Poll, 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HANDLE VGA_AlphaConsole(void)
|
|
|
|
|
{
|
|
|
|
|
/* this assumes that no Win32 redirection has taken place, but then again,
|
|
|
|
|
* only 16-bit apps are likely to use this part of Wine... */
|
|
|
|
|
return GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-23 23:14:11 +02:00
|
|
|
|
char*VGA_AlphaBuffer(void)
|
|
|
|
|
{
|
|
|
|
|
return DOSMEM_MapDosToLinear(0xb8000);
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-03 01:46:29 +01:00
|
|
|
|
/*** GRAPHICS MODE ***/
|
1998-11-01 13:51:47 +01:00
|
|
|
|
|
2001-11-07 21:54:08 +01:00
|
|
|
|
typedef struct {
|
|
|
|
|
unsigned Xres, Yres, Depth;
|
|
|
|
|
int ret;
|
|
|
|
|
} ModeSet;
|
|
|
|
|
|
|
|
|
|
static void WINAPI VGA_DoSetMode(ULONG_PTR arg)
|
1998-11-01 13:51:47 +01:00
|
|
|
|
{
|
2001-06-19 20:14:08 +02:00
|
|
|
|
LRESULT res;
|
|
|
|
|
HWND hwnd;
|
2001-11-07 21:54:08 +01:00
|
|
|
|
ModeSet *par = (ModeSet *)arg;
|
|
|
|
|
par->ret=1;
|
2001-06-19 20:14:08 +02:00
|
|
|
|
|
1998-11-01 13:51:47 +01:00
|
|
|
|
if (lpddraw) VGA_Exit();
|
|
|
|
|
if (!lpddraw) {
|
2000-03-17 17:58:10 +01:00
|
|
|
|
if (!pDirectDrawCreate)
|
|
|
|
|
{
|
|
|
|
|
HMODULE hmod = LoadLibraryA( "ddraw.dll" );
|
2001-01-05 04:44:40 +01:00
|
|
|
|
if (hmod) pDirectDrawCreate = (DirectDrawCreateProc)GetProcAddress( hmod, "DirectDrawCreate" );
|
2001-06-19 20:14:08 +02:00
|
|
|
|
if (!pDirectDrawCreate) {
|
|
|
|
|
ERR("Can't lookup DirectDrawCreate from ddraw.dll.\n");
|
2001-11-07 21:54:08 +01:00
|
|
|
|
return;
|
2001-06-19 20:14:08 +02:00
|
|
|
|
}
|
2000-03-17 17:58:10 +01:00
|
|
|
|
}
|
2001-06-19 20:14:08 +02:00
|
|
|
|
res = pDirectDrawCreate(NULL,&lpddraw,NULL);
|
1998-11-01 13:51:47 +01:00
|
|
|
|
if (!lpddraw) {
|
2001-06-19 20:14:08 +02:00
|
|
|
|
ERR("DirectDraw is not available (res = %lx)\n",res);
|
2001-11-07 21:54:08 +01:00
|
|
|
|
return;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
2001-12-04 20:54:44 +01:00
|
|
|
|
hwnd = CreateWindowExA(0,"STATIC","WINEDOS VGA",WS_POPUP|WS_BORDER|WS_CAPTION|WS_SYSMENU,0,0,par->Xres,par->Yres,0,0,0,NULL);
|
2001-06-19 20:14:08 +02:00
|
|
|
|
if (!hwnd) {
|
|
|
|
|
ERR("Failed to create user window.\n");
|
|
|
|
|
}
|
|
|
|
|
if ((res=IDirectDraw_SetCooperativeLevel(lpddraw,hwnd,DDSCL_FULLSCREEN|DDSCL_EXCLUSIVE))) {
|
|
|
|
|
ERR("Could not set cooperative level to exclusive (%lx)\n",res);
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-07 21:54:08 +01:00
|
|
|
|
if ((res=IDirectDraw_SetDisplayMode(lpddraw,par->Xres,par->Yres,par->Depth))) {
|
|
|
|
|
ERR("DirectDraw does not support requested display mode (%dx%dx%d), res = %lx!\n",par->Xres,par->Yres,par->Depth,res);
|
1999-03-27 17:49:55 +01:00
|
|
|
|
IDirectDraw_Release(lpddraw);
|
1998-11-01 13:51:47 +01:00
|
|
|
|
lpddraw=NULL;
|
2001-11-07 21:54:08 +01:00
|
|
|
|
return;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
2001-11-07 21:54:08 +01:00
|
|
|
|
|
2001-06-19 20:14:08 +02:00
|
|
|
|
res=IDirectDraw_CreatePalette(lpddraw,DDPCAPS_8BIT,NULL,&lpddpal,NULL);
|
2001-11-07 21:54:08 +01:00
|
|
|
|
if (res) {
|
2001-06-19 20:14:08 +02:00
|
|
|
|
ERR("Could not create palette (res = %lx)\n",res);
|
2001-11-07 21:54:08 +01:00
|
|
|
|
IDirectDraw_Release(lpddraw);
|
|
|
|
|
lpddraw=NULL;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((res=IDirectDrawPalette_SetEntries(lpddpal,0,0,256,vga_def_palette))) {
|
|
|
|
|
ERR("Could not set default palette entries (res = %lx)\n", res);
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-01 13:51:47 +01:00
|
|
|
|
memset(&sdesc,0,sizeof(sdesc));
|
|
|
|
|
sdesc.dwSize=sizeof(sdesc);
|
1999-01-17 17:55:11 +01:00
|
|
|
|
sdesc.dwFlags = DDSD_CAPS;
|
|
|
|
|
sdesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
1999-03-27 17:49:55 +01:00
|
|
|
|
if (IDirectDraw_CreateSurface(lpddraw,&sdesc,&lpddsurf,NULL)||(!lpddsurf)) {
|
1999-06-26 21:09:08 +02:00
|
|
|
|
ERR("DirectDraw surface is not available\n");
|
1999-03-27 17:49:55 +01:00
|
|
|
|
IDirectDraw_Release(lpddraw);
|
1998-11-01 13:51:47 +01:00
|
|
|
|
lpddraw=NULL;
|
2001-11-07 21:54:08 +01:00
|
|
|
|
return;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
2000-05-23 23:14:11 +02:00
|
|
|
|
IDirectDrawSurface_SetPalette(lpddsurf,lpddpal);
|
1998-11-08 16:06:31 +01:00
|
|
|
|
vga_refresh=0;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
/* poll every 20ms (50fps should provide adequate responsiveness) */
|
2000-05-10 06:43:32 +02:00
|
|
|
|
VGA_InstallTimer(20);
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
2001-11-07 21:54:08 +01:00
|
|
|
|
par->ret=0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int VGA_SetMode(unsigned Xres,unsigned Yres,unsigned Depth)
|
|
|
|
|
{
|
|
|
|
|
ModeSet par;
|
|
|
|
|
par.Xres = Xres;
|
|
|
|
|
par.Yres = Yres;
|
|
|
|
|
par.Depth = Depth;
|
2001-12-04 20:54:44 +01:00
|
|
|
|
MZ_RunInThread(VGA_DoSetMode, (ULONG_PTR)&par);
|
2001-11-07 21:54:08 +01:00
|
|
|
|
return par.ret;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int VGA_GetMode(unsigned*Height,unsigned*Width,unsigned*Depth)
|
|
|
|
|
{
|
|
|
|
|
if (!lpddraw) return 1;
|
|
|
|
|
if (!lpddsurf) return 1;
|
|
|
|
|
if (Height) *Height=sdesc.dwHeight;
|
|
|
|
|
if (Width) *Width=sdesc.dwWidth;
|
2001-01-04 23:44:55 +01:00
|
|
|
|
if (Depth) *Depth=sdesc.ddpfPixelFormat.u1.dwRGBBitCount;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-07 21:54:08 +01:00
|
|
|
|
static void WINAPI VGA_DoExit(ULONG_PTR arg)
|
|
|
|
|
{
|
|
|
|
|
VGA_DeinstallTimer();
|
|
|
|
|
IDirectDrawSurface_SetPalette(lpddsurf,NULL);
|
|
|
|
|
IDirectDrawSurface_Release(lpddsurf);
|
|
|
|
|
lpddsurf=NULL;
|
|
|
|
|
IDirectDrawPalette_Release(lpddpal);
|
|
|
|
|
lpddpal=NULL;
|
|
|
|
|
IDirectDraw_Release(lpddraw);
|
|
|
|
|
lpddraw=NULL;
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-01 13:51:47 +01:00
|
|
|
|
void VGA_Exit(void)
|
|
|
|
|
{
|
2001-12-04 20:54:44 +01:00
|
|
|
|
if (lpddraw) MZ_RunInThread(VGA_DoExit, 0);
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VGA_SetPalette(PALETTEENTRY*pal,int start,int len)
|
|
|
|
|
{
|
|
|
|
|
if (!lpddraw) return;
|
1999-03-27 17:49:55 +01:00
|
|
|
|
IDirectDrawPalette_SetEntries(lpddpal,0,start,len,pal);
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VGA_SetQuadPalette(RGBQUAD*color,int start,int len)
|
|
|
|
|
{
|
|
|
|
|
PALETTEENTRY pal[256];
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
if (!lpddraw) return;
|
|
|
|
|
for (c=0; c<len; c++) {
|
|
|
|
|
pal[c].peRed =color[c].rgbRed;
|
|
|
|
|
pal[c].peGreen=color[c].rgbGreen;
|
|
|
|
|
pal[c].peBlue =color[c].rgbBlue;
|
|
|
|
|
pal[c].peFlags=0;
|
|
|
|
|
}
|
1999-03-27 17:49:55 +01:00
|
|
|
|
IDirectDrawPalette_SetEntries(lpddpal,0,start,len,pal);
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LPSTR VGA_Lock(unsigned*Pitch,unsigned*Height,unsigned*Width,unsigned*Depth)
|
|
|
|
|
{
|
|
|
|
|
if (!lpddraw) return NULL;
|
|
|
|
|
if (!lpddsurf) return NULL;
|
1999-03-27 17:49:55 +01:00
|
|
|
|
if (IDirectDrawSurface_Lock(lpddsurf,NULL,&sdesc,0,0)) {
|
1999-06-26 21:09:08 +02:00
|
|
|
|
ERR("could not lock surface!\n");
|
1998-11-01 13:51:47 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
|
if (Pitch) *Pitch=sdesc.u1.lPitch;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
if (Height) *Height=sdesc.dwHeight;
|
|
|
|
|
if (Width) *Width=sdesc.dwWidth;
|
2001-01-04 23:44:55 +01:00
|
|
|
|
if (Depth) *Depth=sdesc.ddpfPixelFormat.u1.dwRGBBitCount;
|
|
|
|
|
return sdesc.lpSurface;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VGA_Unlock(void)
|
|
|
|
|
{
|
2001-01-04 23:44:55 +01:00
|
|
|
|
IDirectDrawSurface_Unlock(lpddsurf,sdesc.lpSurface);
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-02-03 01:46:29 +01:00
|
|
|
|
/*** TEXT MODE ***/
|
|
|
|
|
|
|
|
|
|
int VGA_SetAlphaMode(unsigned Xres,unsigned Yres)
|
|
|
|
|
{
|
|
|
|
|
COORD siz;
|
|
|
|
|
|
|
|
|
|
if (lpddraw) VGA_Exit();
|
|
|
|
|
|
|
|
|
|
/* the xterm is slow, so refresh only every 200ms (5fps) */
|
2000-05-10 06:43:32 +02:00
|
|
|
|
VGA_InstallTimer(200);
|
2000-02-03 01:46:29 +01:00
|
|
|
|
|
2000-05-03 19:48:21 +02:00
|
|
|
|
siz.X = Xres;
|
|
|
|
|
siz.Y = Yres;
|
2000-02-03 01:46:29 +01:00
|
|
|
|
SetConsoleScreenBufferSize(VGA_AlphaConsole(),siz);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VGA_GetAlphaMode(unsigned*Xres,unsigned*Yres)
|
|
|
|
|
{
|
|
|
|
|
CONSOLE_SCREEN_BUFFER_INFO info;
|
|
|
|
|
GetConsoleScreenBufferInfo(VGA_AlphaConsole(),&info);
|
2000-05-03 19:48:21 +02:00
|
|
|
|
if (Xres) *Xres=info.dwSize.X;
|
|
|
|
|
if (Yres) *Yres=info.dwSize.Y;
|
2000-02-03 01:46:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VGA_SetCursorPos(unsigned X,unsigned Y)
|
|
|
|
|
{
|
|
|
|
|
COORD pos;
|
2001-11-07 21:54:08 +01:00
|
|
|
|
|
|
|
|
|
if (!poll_timer) VGA_SetAlphaMode(80, 25);
|
2000-05-03 19:48:21 +02:00
|
|
|
|
pos.X = X;
|
|
|
|
|
pos.Y = Y;
|
2000-02-03 01:46:29 +01:00
|
|
|
|
SetConsoleCursorPosition(VGA_AlphaConsole(),pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VGA_GetCursorPos(unsigned*X,unsigned*Y)
|
|
|
|
|
{
|
|
|
|
|
CONSOLE_SCREEN_BUFFER_INFO info;
|
|
|
|
|
GetConsoleScreenBufferInfo(VGA_AlphaConsole(),&info);
|
2000-05-03 19:48:21 +02:00
|
|
|
|
if (X) *X=info.dwCursorPosition.X;
|
|
|
|
|
if (Y) *Y=info.dwCursorPosition.Y;
|
2000-02-03 01:46:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2000-05-23 23:14:11 +02:00
|
|
|
|
void VGA_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count)
|
|
|
|
|
{
|
|
|
|
|
unsigned XR, YR;
|
|
|
|
|
char*dat;
|
|
|
|
|
|
|
|
|
|
VGA_GetAlphaMode(&XR, &YR);
|
|
|
|
|
dat = VGA_AlphaBuffer() + ((XR*Y + X) * 2);
|
|
|
|
|
/* FIXME: also call WriteConsoleOutputA, for better responsiveness */
|
|
|
|
|
while (count--) {
|
|
|
|
|
*dat++ = ch;
|
|
|
|
|
if (attr>=0) *dat = attr;
|
|
|
|
|
dat++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-03 01:46:29 +01:00
|
|
|
|
/*** CONTROL ***/
|
|
|
|
|
|
|
|
|
|
void CALLBACK VGA_Poll( ULONG_PTR arg )
|
1998-11-01 13:51:47 +01:00
|
|
|
|
{
|
|
|
|
|
char *dat;
|
2000-11-01 04:11:12 +01:00
|
|
|
|
unsigned int Pitch,Height,Width,Y,X;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
char *surf;
|
|
|
|
|
|
2000-02-03 01:46:29 +01:00
|
|
|
|
if (!InterlockedExchangeAdd(&vga_polling, 1)) {
|
1998-11-01 13:51:47 +01:00
|
|
|
|
/* FIXME: optimize by doing this only if the data has actually changed
|
|
|
|
|
* (in a way similar to DIBSection, perhaps) */
|
2000-02-03 01:46:29 +01:00
|
|
|
|
if (lpddraw) {
|
|
|
|
|
/* graphics mode */
|
|
|
|
|
surf = VGA_Lock(&Pitch,&Height,&Width,NULL);
|
|
|
|
|
if (!surf) return;
|
|
|
|
|
dat = DOSMEM_MapDosToLinear(0xa0000);
|
|
|
|
|
/* copy from virtual VGA frame buffer to DirectDraw surface */
|
|
|
|
|
for (Y=0; Y<Height; Y++,surf+=Pitch,dat+=Width) {
|
|
|
|
|
memcpy(surf,dat,Width);
|
|
|
|
|
/*for (X=0; X<Width; X++) if (dat[X]) TRACE(ddraw,"data(%d) at (%d,%d)\n",dat[X],X,Y);*/
|
|
|
|
|
}
|
|
|
|
|
VGA_Unlock();
|
|
|
|
|
} else {
|
|
|
|
|
/* text mode */
|
|
|
|
|
CHAR_INFO ch[80];
|
|
|
|
|
COORD siz, off;
|
|
|
|
|
SMALL_RECT dest;
|
|
|
|
|
HANDLE con = VGA_AlphaConsole();
|
|
|
|
|
|
|
|
|
|
VGA_GetAlphaMode(&Width,&Height);
|
2000-05-23 23:14:11 +02:00
|
|
|
|
dat = VGA_AlphaBuffer();
|
2000-05-03 19:48:21 +02:00
|
|
|
|
siz.X = 80; siz.Y = 1;
|
|
|
|
|
off.X = 0; off.Y = 0;
|
2000-02-03 01:46:29 +01:00
|
|
|
|
/* copy from virtual VGA frame buffer to console */
|
|
|
|
|
for (Y=0; Y<Height; Y++) {
|
|
|
|
|
dest.Top=Y; dest.Bottom=Y;
|
|
|
|
|
for (X=0; X<Width; X++) {
|
|
|
|
|
ch[X].Char.AsciiChar = *dat++;
|
2000-10-12 22:41:29 +02:00
|
|
|
|
/* WriteConsoleOutputA doesn't like "dead" chars */
|
|
|
|
|
if (ch[X].Char.AsciiChar == '\0')
|
|
|
|
|
ch[X].Char.AsciiChar = ' ';
|
2000-02-03 01:46:29 +01:00
|
|
|
|
ch[X].Attributes = *dat++;
|
|
|
|
|
}
|
|
|
|
|
dest.Left=0; dest.Right=Width+1;
|
2001-12-04 20:54:44 +01:00
|
|
|
|
WriteConsoleOutputA(con, ch, siz, off, &dest);
|
2000-02-03 01:46:29 +01:00
|
|
|
|
}
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
1998-11-08 16:06:31 +01:00
|
|
|
|
vga_refresh=1;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
2000-02-03 01:46:29 +01:00
|
|
|
|
InterlockedDecrement(&vga_polling);
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static BYTE palreg,palcnt;
|
|
|
|
|
static PALETTEENTRY paldat;
|
|
|
|
|
|
|
|
|
|
void VGA_ioport_out( WORD port, BYTE val )
|
|
|
|
|
{
|
|
|
|
|
switch (port) {
|
|
|
|
|
case 0x3c8:
|
|
|
|
|
palreg=val; palcnt=0; break;
|
|
|
|
|
case 0x3c9:
|
|
|
|
|
((BYTE*)&paldat)[palcnt++]=val << 2;
|
|
|
|
|
if (palcnt==3) {
|
1999-03-14 13:23:17 +01:00
|
|
|
|
VGA_SetPalette(&paldat,palreg++,1);
|
|
|
|
|
palcnt=0;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
1998-11-08 16:06:31 +01:00
|
|
|
|
break;
|
1998-11-01 13:51:47 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
1998-11-08 16:06:31 +01:00
|
|
|
|
|
|
|
|
|
BYTE VGA_ioport_in( WORD port )
|
|
|
|
|
{
|
|
|
|
|
BYTE ret;
|
|
|
|
|
|
|
|
|
|
switch (port) {
|
|
|
|
|
case 0x3da:
|
|
|
|
|
/* since we don't (yet?) serve DOS VM requests while VGA_Poll is running,
|
|
|
|
|
we need to fake the occurrence of the vertical refresh */
|
2000-02-03 01:46:29 +01:00
|
|
|
|
ret=vga_refresh?0x00:0x08;
|
|
|
|
|
vga_refresh=0;
|
1998-11-08 16:06:31 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ret=0xff;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2000-02-03 01:46:29 +01:00
|
|
|
|
|
|
|
|
|
void VGA_Clean(void)
|
|
|
|
|
{
|
|
|
|
|
VGA_Exit();
|
|
|
|
|
VGA_DeinstallTimer();
|
|
|
|
|
}
|