dos vga patch
Ove Kaaven
ovek at arcticnet.no
Mon Nov 5 21:31:54 CST 2001
Depends on the previous patch...
Log:
Added a few default palette entries for the VGA/MCGA 256-color mode.
Made the VGA mode set go through RunInThread, so that the VGA graphics
window gets owned by the right thread.
Index: msdos/vga.c
===================================================================
RCS file: /home/wine/wine/msdos/vga.c,v
retrieving revision 1.7
diff -u -r1.7 vga.c
--- msdos/vga.c 2001/06/19 18:14:08 1.7
+++ msdos/vga.c 2001/11/06 02:00:24
@@ -11,6 +11,7 @@
#include "winuser.h"
#include "wincon.h"
#include "miscemu.h"
+#include "callback.h"
#include "vga.h"
#include "ddraw.h"
#include "services.h"
@@ -31,6 +32,27 @@
typedef HWND WINAPI (*CreateWindowExAProc)(DWORD,LPCSTR,LPCSTR,DWORD,INT,INT, INT,INT,HWND,HMENU,HINSTANCE,LPVOID);
static CreateWindowExAProc pCreateWindowExA;
+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 */
+};
+
static void VGA_DeinstallTimer(void)
{
if (poll_timer) {
@@ -60,10 +82,17 @@
/*** GRAPHICS MODE ***/
-int VGA_SetMode(unsigned Xres,unsigned Yres,unsigned Depth)
+typedef struct {
+ unsigned Xres, Yres, Depth;
+ int ret;
+} ModeSet;
+
+static void WINAPI VGA_DoSetMode(ULONG_PTR arg)
{
LRESULT res;
HWND hwnd;
+ ModeSet *par = (ModeSet *)arg;
+ par->ret=1;
if (lpddraw) VGA_Exit();
if (!lpddraw) {
@@ -73,7 +102,7 @@
if (hmod) pDirectDrawCreate = (DirectDrawCreateProc)GetProcAddress( hmod, "DirectDrawCreate" );
if (!pDirectDrawCreate) {
ERR("Can't lookup DirectDrawCreate from ddraw.dll.\n");
- return 1;
+ return;
}
}
if (!pCreateWindowExA)
@@ -81,20 +110,20 @@
HMODULE hmod = LoadLibraryA( "user32.dll" );
if (!hmod) {
ERR("Can't load user32.dll.\n");
- return 1;
+ return;
}
if (hmod) pCreateWindowExA = (CreateWindowExAProc)GetProcAddress( hmod, "CreateWindowExA" );
if (!pCreateWindowExA) {
ERR("Can't lookup CreateWindowExA from user32.dll.\n");
- return 1;
+ return;
}
}
res = pDirectDrawCreate(NULL,&lpddraw,NULL);
if (!lpddraw) {
ERR("DirectDraw is not available (res = %lx)\n",res);
- return 1;
+ return;
}
- hwnd = pCreateWindowExA(0,"STATIC","WINEDOS VGA",WS_POPUP|WS_BORDER|WS_CAPTION|WS_SYSMENU,0,0,Xres,Yres,0,0,0,NULL);
+ hwnd = pCreateWindowExA(0,"STATIC","WINEDOS VGA",WS_POPUP|WS_BORDER|WS_CAPTION|WS_SYSMENU,0,0,par->Xres,par->Yres,0,0,0,NULL);
if (!hwnd) {
ERR("Failed to create user window.\n");
}
@@ -102,16 +131,24 @@
ERR("Could not set cooperative level to exclusive (%lx)\n",res);
}
- if ((res=IDirectDraw_SetDisplayMode(lpddraw,Xres,Yres,Depth))) {
- ERR("DirectDraw does not support requested display mode (%dx%dx%d), res = %lx!\n",Xres,Yres,Depth,res);
+ 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);
IDirectDraw_Release(lpddraw);
lpddraw=NULL;
- return 1;
+ return;
}
+
res=IDirectDraw_CreatePalette(lpddraw,DDPCAPS_8BIT,NULL,&lpddpal,NULL);
- if (res) {
+ if (res) {
ERR("Could not create palette (res = %lx)\n",res);
- }
+ 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);
+ }
+
memset(&sdesc,0,sizeof(sdesc));
sdesc.dwSize=sizeof(sdesc);
sdesc.dwFlags = DDSD_CAPS;
@@ -120,15 +157,26 @@
ERR("DirectDraw surface is not available\n");
IDirectDraw_Release(lpddraw);
lpddraw=NULL;
- return 1;
+ return;
}
- FIXME("no default palette entries\n");
IDirectDrawSurface_SetPalette(lpddsurf,lpddpal);
vga_refresh=0;
/* poll every 20ms (50fps should provide adequate responsiveness) */
VGA_InstallTimer(20);
}
- return 0;
+ par->ret=0;
+ return;
+}
+
+int VGA_SetMode(unsigned Xres,unsigned Yres,unsigned Depth)
+{
+ ModeSet par;
+ par.Xres = Xres;
+ par.Yres = Yres;
+ par.Depth = Depth;
+ if (Dosvm.RunInThread) Dosvm.RunInThread(VGA_DoSetMode, (ULONG_PTR)&par);
+ else VGA_DoSetMode((ULONG_PTR)&par);
+ return par.ret;
}
int VGA_GetMode(unsigned*Height,unsigned*Width,unsigned*Depth)
@@ -141,17 +189,23 @@
return 0;
}
+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;
+}
+
void VGA_Exit(void)
{
if (lpddraw) {
- VGA_DeinstallTimer();
- IDirectDrawSurface_SetPalette(lpddsurf,NULL);
- IDirectDrawSurface_Release(lpddsurf);
- lpddsurf=NULL;
- IDirectDrawPalette_Release(lpddpal);
- lpddpal=NULL;
- IDirectDraw_Release(lpddraw);
- lpddraw=NULL;
+ if (Dosvm.RunInThread) Dosvm.RunInThread(VGA_DoExit, 0);
+ else VGA_DoExit(0);
}
}
@@ -224,7 +278,8 @@
void VGA_SetCursorPos(unsigned X,unsigned Y)
{
COORD pos;
-
+
+ if (!poll_timer) VGA_SetAlphaMode(80, 25);
pos.X = X;
pos.Y = Y;
SetConsoleCursorPosition(VGA_AlphaConsole(),pos);
More information about the wine-patches
mailing list