From 3be104e0efc91762c375b5f15bae08f8fd6afb05 Mon Sep 17 00:00:00 2001 From: Ove Kaaven Date: Tue, 23 May 2000 21:14:11 +0000 Subject: [PATCH] Improved DirectDrawPalette handling (set it on init, not every time it changes). Added VGA_WriteChars() function. --- graphics/vga.c | 29 ++++++++++++++++++++++++++--- include/vga.h | 1 + 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/graphics/vga.c b/graphics/vga.c index dedc0c880da..89aae227acf 100644 --- a/graphics/vga.c +++ b/graphics/vga.c @@ -47,6 +47,11 @@ HANDLE VGA_AlphaConsole(void) return GetStdHandle(STD_OUTPUT_HANDLE); } +char*VGA_AlphaBuffer(void) +{ + return DOSMEM_MapDosToLinear(0xb8000); +} + /*** GRAPHICS MODE ***/ int VGA_SetMode(unsigned Xres,unsigned Yres,unsigned Depth) @@ -80,6 +85,8 @@ int VGA_SetMode(unsigned Xres,unsigned Yres,unsigned Depth) lpddraw=NULL; return 1; } + FIXME("no default palette entries\n"); + IDirectDrawSurface_SetPalette(lpddsurf,lpddpal); vga_refresh=0; /* poll every 20ms (50fps should provide adequate responsiveness) */ VGA_InstallTimer(20); @@ -101,8 +108,11 @@ 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; } @@ -112,7 +122,6 @@ void VGA_SetPalette(PALETTEENTRY*pal,int start,int len) { if (!lpddraw) return; IDirectDrawPalette_SetEntries(lpddpal,0,start,len,pal); - IDirectDrawSurface_SetPalette(lpddsurf,lpddpal); } void VGA_SetQuadPalette(RGBQUAD*color,int start,int len) @@ -128,7 +137,6 @@ void VGA_SetQuadPalette(RGBQUAD*color,int start,int len) pal[c].peFlags=0; } IDirectDrawPalette_SetEntries(lpddpal,0,start,len,pal); - IDirectDrawSurface_SetPalette(lpddsurf,lpddpal); } LPSTR VGA_Lock(unsigned*Pitch,unsigned*Height,unsigned*Width,unsigned*Depth) @@ -193,6 +201,21 @@ void VGA_GetCursorPos(unsigned*X,unsigned*Y) if (Y) *Y=info.dwCursorPosition.Y; } +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++; + } +} + /*** CONTROL ***/ void CALLBACK VGA_Poll( ULONG_PTR arg ) @@ -224,7 +247,7 @@ void CALLBACK VGA_Poll( ULONG_PTR arg ) HANDLE con = VGA_AlphaConsole(); VGA_GetAlphaMode(&Width,&Height); - dat = DOSMEM_MapDosToLinear(0xb8000); + dat = VGA_AlphaBuffer(); siz.X = 80; siz.Y = 1; off.X = 0; off.Y = 0; /* copy from virtual VGA frame buffer to console */ diff --git a/include/vga.h b/include/vga.h index 3e5f92b9c4b..57800d2df60 100644 --- a/include/vga.h +++ b/include/vga.h @@ -25,6 +25,7 @@ int VGA_SetAlphaMode(unsigned Xres,unsigned Yres); void VGA_GetAlphaMode(unsigned*Xres,unsigned*Yres); void VGA_SetCursorPos(unsigned X,unsigned Y); void VGA_GetCursorPos(unsigned*X,unsigned*Y); +void VGA_WriteChars(unsigned X,unsigned Y,unsigned ch,int attr,int count); /* control */ void CALLBACK VGA_Poll(ULONG_PTR arg);