Indentation corrected, minor fixes

svn path=/trunk/; revision=1754
This commit is contained in:
Jason Filby 2001-03-31 15:40:34 +00:00
parent 14c634ca97
commit 389375c4ee
10 changed files with 837 additions and 743 deletions

View file

@ -1,9 +1,9 @@
/*
* entry.c
*
* $Revision: 1.10 $
* $Revision: 1.11 $
* $Author: jfilby $
* $Date: 2000/11/16 21:45:54 $
* $Date: 2001/03/31 15:40:33 $
*
*/
@ -164,11 +164,10 @@ DHPDEV VGADDIEnablePDEV(IN DEVMODEW *DM,
PDev = EngAllocMem(FL_ZERO_MEMORY, sizeof(PDEV), ALLOC_TAG);
if (PDev == NULL)
{
EngDebugPrint(DBG_PREFIX, "EngAllocMem failed for PDEV\n", 0);
return NULL;
}
{
EngDebugPrint(DBG_PREFIX, "EngAllocMem failed for PDEV\n", 0);
return NULL;
}
PDev->KMDriver = Driver;
DPRINT( "PDev: %x, Driver: %x\n", PDev, PDev->KMDriver );
PDev->xyCursor.x = 320;
@ -180,8 +179,7 @@ DHPDEV VGADDIEnablePDEV(IN DEVMODEW *DM,
// FIXME: fill out DevCaps
// FIXME: full out DevInfo
devinfoVGA.hpalDefault = EngCreatePalette(PAL_INDEXED, 16,
(PULONG)(VGApalette.PaletteEntry), 0, 0, 0);
devinfoVGA.hpalDefault = EngCreatePalette(PAL_INDEXED, 16, (PULONG)(VGApalette.PaletteEntry), 0, 0, 0);
*DI = devinfoVGA;
@ -211,27 +209,21 @@ VOID VGADDIAssertMode(IN DHPDEV DPev,
// Reenable our graphics mode
if (!InitPointer(ppdev))
{
// Failed to set pointer
return FALSE;
}
{
// Failed to set pointer
return FALSE;
}
if (!InitVGA(ppdev, FALSE))
{
// Failed to initialize the VGA
return FALSE;
}
if (!InitVGA(ppdev, FALSE))
{
// Failed to initialize the VGA
return FALSE;
}
} else {
// Go back to last known mode
DPRINT( "ppdev: %x, KMDriver: %x", ppdev, ppdev->KMDriver );
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_RESET_DEVICE,
NULL,
0,
NULL,
0,
&returnedDataLength))
if (EngDeviceIoControl(ppdev->KMDriver, IOCTL_VIDEO_RESET_DEVICE, NULL, 0, NULL, 0, &returnedDataLength))
{
// Failed to go back to mode
return FALSE;
@ -253,7 +245,7 @@ VOID VGADDIDisablePDEV(IN DHPDEV PDev)
if (ppdev->pucDIB4ToVGAConvBuffer != NULL)
{
EngFreeMem(ppdev->pucDIB4ToVGAConvBuffer);
}
}
DPRINT( "Freeing PDEV\n" );
EngFreeMem(PDev);
}
@ -269,11 +261,11 @@ VOID VGADDIDisableSurface(IN DHPDEV PDev)
CHECKPOINT;
if (pdsurf->BankInfo != NULL) {
EngFreeMem(pdsurf->BankInfo);
}
}
CHECKPOINT;
if (pdsurf->BankInfo2RW != NULL) {
EngFreeMem(pdsurf->BankInfo2RW);
}
}
CHECKPOINT;
if (pdsurf->BankBufferPlane0 != NULL) {
EngFreeMem(pdsurf->BankBufferPlane0);
@ -281,7 +273,7 @@ VOID VGADDIDisableSurface(IN DHPDEV PDev)
CHECKPOINT;
if (ppdev->pPointerAttributes != NULL) {
EngFreeMem(ppdev->pPointerAttributes);
}
}
CHECKPOINT;
// free any pending saved screen bit blocks
pSSB = pdsurf->ssbList;

View file

@ -1,65 +1,65 @@
#include "../vgaddi.h"
GDIINFO gaulCap = {
GDI_DRIVER_VERSION,
DT_RASDISPLAY, // ulTechnology
0, // ulHorzSize
0, // ulVertSize
0, // ulHorzRes (filled in at initialization)
0, // ulVertRes (filled in at initialization)
4, // cBitsPixel
1, // cPlanes
16, // ulNumColors
0, // flRaster (DDI reserved field)
GDI_DRIVER_VERSION,
DT_RASDISPLAY, // ulTechnology
0, // ulHorzSize
0, // ulVertSize
0, // ulHorzRes (filled in at initialization)
0, // ulVertRes (filled in at initialization)
4, // cBitsPixel
1, // cPlanes
16, // ulNumColors
0, // flRaster (DDI reserved field)
0, // ulLogPixelsX (filled in at initialization)
0, // ulLogPixelsY (filled in at initialization)
0, // ulLogPixelsX (filled in at initialization)
0, // ulLogPixelsY (filled in at initialization)
TC_RA_ABLE | TC_SCROLLBLT, // flTextCaps
TC_RA_ABLE | TC_SCROLLBLT, // flTextCaps
6, // ulDACRed
6, // ulDACGree
6, // ulDACBlue
6, // ulDACRed
6, // ulDACGree
6, // ulDACBlue
0x0024, // ulAspectX (one-to-one aspect ratio)
0x0024, // ulAspectY
0x0033, // ulAspectXY
0x0024, // ulAspectX (one-to-one aspect ratio)
0x0024, // ulAspectY
0x0033, // ulAspectXY
1, // xStyleStep
1, // yStyleSte;
3, // denStyleStep
1, // xStyleStep
1, // yStyleSte;
3, // denStyleStep
{ 0, 0 }, // ptlPhysOffset
{ 0, 0 }, // szlPhysSize
{ 0, 0 }, // ptlPhysOffset
{ 0, 0 }, // szlPhysSize
0, // ulNumPalReg (win3.1 16 color drivers say 0 too)
0, // ulNumPalReg (win3.1 16 color drivers say 0 too)
// These fields are for halftone initialization.
{ // ciDevice, ColorInfo
{ 6700, 3300, 0 }, // Red
{ 2100, 7100, 0 }, // Green
{ 1400, 800, 0 }, // Blue
{ 1750, 3950, 0 }, // Cyan
{ 4050, 2050, 0 }, // Magenta
{ 4400, 5200, 0 }, // Yellow
{ 3127, 3290, 0 }, // AlignmentWhite
20000, // RedGamma
20000, // GreenGamma
20000, // BlueGamma
0, 0, 0, 0, 0, 0
},
{ // ciDevice, ColorInfo
{ 6700, 3300, 0 }, // Red
{ 2100, 7100, 0 }, // Green
{ 1400, 800, 0 }, // Blue
{ 1750, 3950, 0 }, // Cyan
{ 4050, 2050, 0 }, // Magenta
{ 4400, 5200, 0 }, // Yellow
{ 3127, 3290, 0 }, // AlignmentWhite
20000, // RedGamma
20000, // GreenGamma
20000, // BlueGamma
0, 0, 0, 0, 0, 0
},
0, // ulDevicePelsDPI
PRIMARY_ORDER_CBA, // ulPrimaryOrder
HT_PATSIZE_4x4_M, // ulHTPatternSize
HT_FORMAT_4BPP_IRGB, // ulHTOutputFormat
HT_FLAG_ADDITIVE_PRIMS, // flHTFlags
0, // ulDevicePelsDPI
PRIMARY_ORDER_CBA, // ulPrimaryOrder
HT_PATSIZE_4x4_M, // ulHTPatternSize
HT_FORMAT_4BPP_IRGB, // ulHTOutputFormat
HT_FLAG_ADDITIVE_PRIMS, // flHTFlags
0, // ulVRefresh
8, // ulBltAlignment
0, // ulPanningHorzRes
0, // ulPanningVertRes
0, // ulVRefresh
8, // ulBltAlignment
0, // ulPanningHorzRes
0, // ulPanningVertRes
};
// Palette for VGA
@ -77,23 +77,23 @@ const VGALOGPALETTE VGApalette =
0x400, // driver version
16, // num entries
{
{ 0, 0, 0, 0 }, // 0
{ 0x80,0, 0, 0 }, // 1
{ 0, 0x80,0, 0 }, // 2
{ 0x80,0x80,0, 0 }, // 3
{ 0, 0, 0x80,0 }, // 4
{ 0x80,0, 0x80,0 }, // 5
{ 0, 0x80,0x80,0 }, // 6
{ 0x80,0x80,0x80,0 }, // 7
{ 0, 0, 0, 0 }, // 0
{ 0x80,0, 0, 0 }, // 1
{ 0, 0x80,0, 0 }, // 2
{ 0x80,0x80,0, 0 }, // 3
{ 0, 0, 0x80,0 }, // 4
{ 0x80,0, 0x80,0 }, // 5
{ 0, 0x80,0x80,0 }, // 6
{ 0x80,0x80,0x80,0 }, // 7
{ 0xC0,0xC0,0xC0,0 }, // 8
{ 0xFF,0, 0, 0 }, // 9
{ 0, 0xFF,0, 0 }, // 10
{ 0xFF,0xFF,0, 0 }, // 11
{ 0, 0, 0xFF,0 }, // 12
{ 0xFF,0, 0xFF,0 }, // 13
{ 0, 0xFF,0xFF,0 }, // 14
{ 0xFF,0xFF,0xFF,0 } // 15
{ 0xC0,0xC0,0xC0,0 }, // 8
{ 0xFF,0, 0, 0 }, // 9
{ 0, 0xFF,0, 0 }, // 10
{ 0xFF,0xFF,0, 0 }, // 11
{ 0, 0, 0xFF,0 }, // 12
{ 0xFF,0, 0xFF,0 }, // 13
{ 0, 0xFF,0xFF,0 }, // 14
{ 0xFF,0xFF,0xFF,0 } // 15
}
};
@ -108,16 +108,16 @@ const VGALOGPALETTE VGApalette =
DEVINFO devinfoVGA =
{
(GCAPS_OPAQUERECT | GCAPS_HORIZSTRIKE | GCAPS_ALTERNATEFILL | GCAPS_MONO_DITHER | GCAPS_COLOR_DITHER |
GCAPS_WINDINGFILL | GCAPS_DITHERONREALIZE
), // Graphics capabilities
(GCAPS_OPAQUERECT | GCAPS_HORIZSTRIKE | GCAPS_ALTERNATEFILL | GCAPS_MONO_DITHER | GCAPS_COLOR_DITHER |
GCAPS_WINDINGFILL | GCAPS_DITHERONREALIZE
), // Graphics capabilities
SYSTM_LOGFONT, // Default font description
HELVE_LOGFONT, // ANSI variable font description
COURI_LOGFONT, // ANSI fixed font description
0, // Count of device fonts
BMF_4BPP, // preferred DIB format
8, // Width of color dither
8, // Height of color dither
0 // Default palette to use for this device
SYSTM_LOGFONT, // Default font description
HELVE_LOGFONT, // ANSI variable font description
COURI_LOGFONT, // ANSI fixed font description
0, // Count of device fonts
BMF_4BPP, // preferred DIB format
8, // Width of color dither
8, // Height of color dither
0 // Default palette to use for this device
};

View file

@ -14,16 +14,15 @@
typedef BOOL (*PFN_VGABlt)(SURFOBJ *, SURFOBJ *, SURFOBJ *, XLATEOBJ *,
RECTL *, POINTL *);
BOOL GDItoVGA(
BOOL DIBtoVGA(
SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask, XLATEOBJ *ColorTranslation,
RECTL *DestRect, POINTL *SourcePoint)
{
LONG i, j, dx, dy, alterx, altery, idxColor, RGBulong = 0, BPP;
LONG i, j, dx, dy, alterx, altery, idxColor, RGBulong = 0;
BYTE *GDIpos, *initial;
BPP = bytesPerPixel(Source->iBitmapFormat);
GDIpos = Source->pvBits +
SourcePoint->y * Source->lDelta + SourcePoint->x;
GDIpos = Source->pvBits /* +
SourcePoint->y * Source->lDelta + (SourcePoint->x >> 1) */ ;
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
@ -31,12 +30,16 @@ BOOL GDItoVGA(
alterx = abs(SourcePoint->x - DestRect->left);
altery = abs(SourcePoint->y - DestRect->top);
// FIXME: ColorTranslation will never be null. We must always map the colors (see PCGPE's bmp.txt)
if(ColorTranslation == NULL)
{
// No color translation necessary, we assume BPP = 1
BltToVGA(DestRect->left, DestRect->top, dx, dy, Source->pvBits, Source->lDelta);
DIB_BltToVGA(DestRect->left, DestRect->top, dx, dy, Source->pvBits, Source->lDelta);
} else {
// Perform color translation
for(j=SourcePoint->y; j<SourcePoint->y+dy; j++)
{
@ -46,19 +49,18 @@ BOOL GDItoVGA(
{
idxColor = XLATEOBJ_iXlate(ColorTranslation, *GDIpos);
vgaPutPixel(i+alterx, j+altery, idxColor);
GDIpos+=BPP;
GDIpos+=1;
}
GDIpos = initial + Source->lDelta;
}
}
DPRINT("GDItoVGA: Done\n");
}
BOOL VGAtoGDI(
BOOL VGAtoDIB(
SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask, XLATEOBJ *ColorTranslation,
RECTL *DestRect, POINTL *SourcePoint)
{
LONG i, j, dx, dy, RGBulong, BPP;
LONG i, j, dx, dy, RGBulong;
BYTE *GDIpos, *initial, idxColor;
// Used by the temporary DFB
@ -71,8 +73,7 @@ BOOL VGAtoGDI(
// FIXME: Optimize to retrieve entire bytes at a time (see /display/vgavideo/vgavideo.c:vgaGetByte)
BPP = bytesPerPixel(Dest->iBitmapFormat);
GDIpos = Dest->pvBits + (DestRect->top * Dest->lDelta) + (DestRect->left * BPP);
GDIpos = Dest->pvBits /* + (DestRect->top * Dest->lDelta) + (DestRect->left >> 1) */ ;
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
@ -81,7 +82,8 @@ BOOL VGAtoGDI(
// Prepare a Dest Dev Target and copy from the DFB to the DIB
DestDevSurf.NextScan = Dest->lDelta;
DestDevSurf.StartBmp = Dest->pvScan0;
BltFromVGA(SourcePoint->x, SourcePoint->y, dx, dy, Dest->pvBits, Dest->lDelta);
DIB_BltFromVGA(SourcePoint->x, SourcePoint->y, dx, dy, Dest->pvBits, Dest->lDelta);
} else {
// Color translation
@ -91,12 +93,11 @@ BOOL VGAtoGDI(
for(i=SourcePoint->x; i<SourcePoint->x+dx; i++)
{
*GDIpos = XLATEOBJ_iXlate(ColorTranslation, vgaGetPixel(i, j));
GDIpos+=BPP;
GDIpos+=1;
}
GDIpos = initial + Dest->lDelta;
}
}
DPRINT("VGAtoGDI: Done\n");
}
BOOL DFBtoVGA(
@ -186,13 +187,13 @@ DPRINT("VGADDIBitBlt: Dest->pvScan0: %08x\n", Dest->pvScan0);
if((Source->iType == STYPE_BITMAP) && (Dest->iType == STYPE_DEVICE))
{
DPRINT("GDI2VGA\n");
BltOperation = GDItoVGA;
DPRINT("DIB2VGA\n");
BltOperation = DIBtoVGA;
} else
if((Source->iType == STYPE_DEVICE) && (Dest->iType == STYPE_BITMAP))
{
DPRINT("VGA2GDI\n");
BltOperation = VGAtoGDI;
DPRINT("VGA2DIB\n");
BltOperation = VGAtoDIB;
} else
if((Source->iType == STYPE_DEVICE) && (Dest->iType == STYPE_DEVICE))
{

View file

@ -1,23 +1,23 @@
typedef struct _BRUSHINST
{
// We need to removed ajC0-3 when color pattern code is complete!!!
//
BYTE ajC0[8]; // Color bits for plane 0
BYTE ajC1[8]; // Color bits for plane 1
BYTE ajC2[8]; // Color bits for plane 2
BYTE ajC3[8]; // Color bits for plane 3
// We need to removed ajC0-3 when color pattern code is complete!!!
//
BYTE ajC0[8]; // Color bits for plane 0
BYTE ajC1[8]; // Color bits for plane 1
BYTE ajC2[8]; // Color bits for plane 2
BYTE ajC3[8]; // Color bits for plane 3
BYTE ajPattern[32]; // Color bits for the mask
USHORT usStyle; // Brush style
BYTE fjAccel; // Accelerator flags
BYTE jFgColor; // Current foreground color
BYTE jBkColor; // Current background color
BYTE RealWidth; //
BYTE YShiftValue; //
BYTE jOldBrushRealized; //
DWORD Width; // Width of brush
DWORD Height;
BYTE *pPattern; //Pointer to realized mono pattern
BYTE ajPattern[32]; // Color bits for the mask
USHORT usStyle; // Brush style
BYTE fjAccel; // Accelerator flags
BYTE jFgColor; // Current foreground color
BYTE jBkColor; // Current background color
BYTE RealWidth; //
BYTE YShiftValue; //
BYTE jOldBrushRealized; //
DWORD Width; // Width of brush
DWORD Height;
BYTE *pPattern; //Pointer to realized mono pattern
} BRUSHINST;
#define BRI_SOLID 0

View file

@ -15,8 +15,6 @@ BOOL VGADDILineTo(SURFOBJ *Surface, CLIPOBJ *Clip, BRUSHOBJ *Brush,
LONG deltax, deltay;
iSolidColor = Brush->iSolidColor; // FIXME: Brush Realization...
DbgPrint("Drawing with color %08x ", iSolidColor);
DbgPrint("%u.%u to %u.%u\n", x1, y1, x2, y2);
// FIXME: Implement clipping

View file

@ -5,63 +5,63 @@
BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor)
{
int x = Dimensions.left;
int y = Dimensions.top;
int w = Dimensions.right - Dimensions.left;
int h = Dimensions.bottom - Dimensions.top;
unsigned char *vp, *vpX;
volatile unsigned char dummy;
int byte_per_line;
int i;
int x = Dimensions.left;
int y = Dimensions.top;
int w = Dimensions.right - Dimensions.left;
int h = Dimensions.bottom - Dimensions.top;
unsigned char *vp, *vpX;
volatile unsigned char dummy;
int byte_per_line;
int i;
ASSIGNVP4(x, y, vpX)
get_masks(x, w);
byte_per_line = SCREEN_X >> 3;
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); /* write mode 2 */
saved_GC_mode = READ_PORT_UCHAR((PUCHAR)GRA_D);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x02);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03); /* replace */
saved_GC_fun = READ_PORT_UCHAR((PUCHAR)GRA_D);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x00);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08); /* bit mask */
saved_GC_mask = READ_PORT_UCHAR((PUCHAR)GRA_D);
if (leftMask) {
WRITE_PORT_UCHAR((PUCHAR)GRA_D, leftMask); /* bit mask */
/* write to video */
vp = vpX;
for (i=h; i>0; i--) {
dummy = *vp; *vp = iColor;
vp += byte_per_line;
}
vpX++;
}
if (byteCounter) {
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xff); /* bit mask */
/* write to video */
vp = vpX;
for (i=h; i>0; i--) {
memset(vp, iColor, byteCounter);
vp += byte_per_line;
}
vpX += byteCounter;
}
if (rightMask) {
WRITE_PORT_UCHAR((PUCHAR)GRA_D, rightMask); /* bit mask */
/* write to video */
vp = vpX;
for (i=h; i>0; i--) {
dummy = *vp; *vp = iColor;
vp += byte_per_line;
}
}
/* reset GC register */
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_mask);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_fun);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_mode);
ASSIGNVP4(x, y, vpX)
get_masks(x, w);
byte_per_line = SCREEN_X >> 3;
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); /* write mode 2 */
saved_GC_mode = READ_PORT_UCHAR((PUCHAR)GRA_D);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x02);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03); /* replace */
saved_GC_fun = READ_PORT_UCHAR((PUCHAR)GRA_D);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x00);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08); /* bit mask */
saved_GC_mask = READ_PORT_UCHAR((PUCHAR)GRA_D);
if (leftMask) {
WRITE_PORT_UCHAR((PUCHAR)GRA_D, leftMask); /* bit mask */
/* write to video */
vp = vpX;
for (i=h; i>0; i--) {
dummy = *vp; *vp = iColor;
vp += byte_per_line;
}
vpX++;
}
if (byteCounter) {
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xff); /* bit mask */
/* write to video */
vp = vpX;
for (i=h; i>0; i--) {
memset(vp, iColor, byteCounter);
vp += byte_per_line;
}
vpX += byteCounter;
}
if (rightMask) {
WRITE_PORT_UCHAR((PUCHAR)GRA_D, rightMask); /* bit mask */
/* write to video */
vp = vpX;
for (i=h; i>0; i--) {
dummy = *vp; *vp = iColor;
vp += byte_per_line;
}
}
/* reset GC register */
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_mask);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_fun);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_mode);
return TRUE;
return TRUE;
}
BOOL VGADDIPaintRgn(SURFOBJ *Surface, CLIPOBJ *ClipRegion, ULONG iColor, MIX Mix,
@ -146,7 +146,7 @@ BOOL VGADDIPaint(IN SURFOBJ *Surface, IN CLIPOBJ *ClipRegion,
case R2_WHITE:
case R2_BLACK:
// FIXME: The Paint region belongs HERE
// FIXME: The Paint region belongs HERE
case R2_NOP:
return(TRUE);

View file

@ -8,114 +8,114 @@ void vgaShowCursor(PPDEV ppdev);
BOOL InitPointer(PPDEV ppdev)
{
ULONG CursorWidth = 16, CursorHeight = 16;
ULONG CursorWidth = 16, CursorHeight = 16;
// Determine the size of the pointer attributes
ppdev->PointerAttributes = sizeof(VIDEO_POINTER_ATTRIBUTES) +
(CursorWidth * CursorHeight) * 2; // space for two cursors (data and mask); we assume 4bpp.. but use 8bpp for speed
// Determine the size of the pointer attributes
ppdev->PointerAttributes = sizeof(VIDEO_POINTER_ATTRIBUTES) +
(CursorWidth * CursorHeight) * 2; // space for two cursors (data and mask); we assume 4bpp.. but use 8bpp for speed
// Allocate memory for pointer attributes
ppdev->pPointerAttributes = EngAllocMem(0, ppdev->PointerAttributes, ALLOC_TAG);
// Allocate memory for pointer attributes
ppdev->pPointerAttributes = EngAllocMem(0, ppdev->PointerAttributes, ALLOC_TAG);
ppdev->pPointerAttributes->Flags = 0; // FIXME: Do this right
ppdev->pPointerAttributes->Width = CursorWidth;
ppdev->pPointerAttributes->Height = CursorHeight;
ppdev->pPointerAttributes->WidthInBytes = CursorWidth;
ppdev->pPointerAttributes->Enable = 0;
ppdev->pPointerAttributes->Column = 0;
ppdev->pPointerAttributes->Row = 0;
ppdev->pPointerAttributes->Flags = 0; // FIXME: Do this right
ppdev->pPointerAttributes->Width = CursorWidth;
ppdev->pPointerAttributes->Height = CursorHeight;
ppdev->pPointerAttributes->WidthInBytes = CursorWidth;
ppdev->pPointerAttributes->Enable = 0;
ppdev->pPointerAttributes->Column = 0;
ppdev->pPointerAttributes->Row = 0;
// Allocate memory for the pixels behind the cursor
behindCursor = EngAllocMem(0, ppdev->pPointerAttributes->WidthInBytes * ppdev->pPointerAttributes->Height, ALLOC_TAG);
// Allocate memory for the pixels behind the cursor
behindCursor = EngAllocMem(0, ppdev->pPointerAttributes->WidthInBytes * ppdev->pPointerAttributes->Height, ALLOC_TAG);
return TRUE;
return TRUE;
}
VOID VGADDIMovePointer(PSURFOBJ pso, LONG x, LONG y, PRECTL prcl)
{
PPDEV ppdev = (PPDEV)pso->dhpdev;
PPDEV ppdev = (PPDEV)pso->dhpdev;
if(x == -1)
{
// x == -1 and y == -1 indicates we must hide the cursor
vgaHideCursor(ppdev);
return;
}
if(x == -1)
{
// x == -1 and y == -1 indicates we must hide the cursor
vgaHideCursor(ppdev);
return;
}
ppdev->xyCursor.x = x;
ppdev->xyCursor.y = y;
ppdev->xyCursor.x = x;
ppdev->xyCursor.y = y;
vgaShowCursor(ppdev);
vgaShowCursor(ppdev);
// Give feedback on the new cursor rectangle
// if (prcl != NULL) ComputePointerRect(ppdev, prcl);
// Give feedback on the new cursor rectangle
// if (prcl != NULL) ComputePointerRect(ppdev, prcl);
}
ULONG VGADDISetPointerShape(PSURFOBJ pso, PSURFOBJ psoMask, PSURFOBJ psoColor, PXLATEOBJ pxlo,
LONG xHot, LONG yHot, LONG x, LONG y,
PRECTL prcl, ULONG fl)
{
PPDEV ppdev = (PPDEV)pso->dhpdev;
ULONG cursorBytes = ppdev->pPointerAttributes->WidthInBytes * ppdev->pPointerAttributes->Height;
PPDEV ppdev = (PPDEV)pso->dhpdev;
ULONG cursorBytes = ppdev->pPointerAttributes->WidthInBytes * ppdev->pPointerAttributes->Height;
// Hide the cursor (if it's there -- FIXME?)
if(ppdev->pPointerAttributes->Enable != 0) vgaHideCursor(ppdev);
// Hide the cursor (if it's there -- FIXME?)
if(ppdev->pPointerAttributes->Enable != 0) vgaHideCursor(ppdev);
// Copy the mask and color bitmaps into the PPDEV
RtlCopyMemory(ppdev->pPointerAttributes->Pixels, psoMask->pvBits, cursorBytes);
if(psoColor != NULL) RtlCopyMemory(ppdev->pPointerAttributes->Pixels + cursorBytes, psoColor->pvBits, cursorBytes);
// Copy the mask and color bitmaps into the PPDEV
RtlCopyMemory(ppdev->pPointerAttributes->Pixels, psoMask->pvBits, cursorBytes);
if(psoColor != NULL) RtlCopyMemory(ppdev->pPointerAttributes->Pixels + cursorBytes, psoColor->pvBits, cursorBytes);
// Set the new cursor position
ppdev->xyCursor.x = x;
ppdev->xyCursor.y = y;
// Set the new cursor position
ppdev->xyCursor.x = x;
ppdev->xyCursor.y = y;
// Show the cursor
vgaShowCursor(ppdev);
// Show the cursor
vgaShowCursor(ppdev);
}
void vgaHideCursor(PPDEV ppdev)
{
ULONG i, j, cx, cy, bitpos;
ULONG i, j, cx, cy, bitpos;
// Display what was behind cursor
BltToVGA(oldx, oldx, oldy,
ppdev->pPointerAttributes->Width-1,
ppdev->pPointerAttributes->Height-1,
behindCursor);
// Display what was behind cursor
DFB_BltToVGA(oldx, oldx, oldy,
ppdev->pPointerAttributes->Width-1,
ppdev->pPointerAttributes->Height-1,
behindCursor);
oldx = ppdev->xyCursor.x;
oldy = ppdev->xyCursor.y;
oldx = ppdev->xyCursor.x;
oldy = ppdev->xyCursor.y;
ppdev->pPointerAttributes->Enable = 0;
ppdev->pPointerAttributes->Enable = 0;
}
void vgaShowCursor(PPDEV ppdev)
{
ULONG i, j, cx, cy, bitpos;
ULONG i, j, cx, cy, bitpos;
if(ppdev->pPointerAttributes->Enable != 0) vgaHideCursor(ppdev);
if(ppdev->pPointerAttributes->Enable != 0) vgaHideCursor(ppdev);
// Capture pixels behind the cursor
cx = ppdev->xyCursor.x;
cy = ppdev->xyCursor.y;
bitpos = 0;
for (j=0; j<ppdev->pPointerAttributes->Height; j++)
{
cx = ppdev->xyCursor.x;
for (i=0; i<ppdev->pPointerAttributes->Width; i++)
{
behindCursor[bitpos] = vgaGetPixel(cx, cy);
bitpos++;
cx++;
}
cy++;
}
// Capture pixels behind the cursor
cx = ppdev->xyCursor.x;
cy = ppdev->xyCursor.y;
bitpos = 0;
for (j=0; j<ppdev->pPointerAttributes->Height; j++)
{
cx = ppdev->xyCursor.x;
for (i=0; i<ppdev->pPointerAttributes->Width; i++)
{
behindCursor[bitpos] = vgaGetPixel(cx, cy);
bitpos++;
cx++;
}
cy++;
}
// Display the cursor
BltToVGA(ppdev->xyCursor.x, ppdev->xyCursor.x, ppdev->xyCursor.y,
ppdev->pPointerAttributes->Width-1,
ppdev->pPointerAttributes->Height-1,
ppdev->pPointerAttributes->Pixels);
// Display the cursor
DIB_BltToVGA(ppdev->xyCursor.x, ppdev->xyCursor.x, ppdev->xyCursor.y,
ppdev->pPointerAttributes->Width-1,
ppdev->pPointerAttributes->Height-1,
ppdev->pPointerAttributes->Pixels);
ppdev->pPointerAttributes->Enable = 1;
ppdev->pPointerAttributes->Enable = 1;
}

View file

@ -6,145 +6,143 @@ static WORD PaletteBuffer[] = {
};
static BYTE ColorBuffer[] = {
16, // 16 entries
0, 0,
0, // start with 0
0x00, 0x00, 0x00, 0x00, // black
0x2A, 0x00, 0x15, 0x00, // red
0x00, 0x2A, 0x15, 0x00, // green
0x2A, 0x2A, 0x15, 0x00, // brown
0x00, 0x00, 0x2A, 0x00, // blue
0x2A, 0x15, 0x2A, 0x00, // magenta
0x15, 0x2A, 0x2A, 0x00, // cyan
0x21, 0x22, 0x23, 0x00, // dark gray
0x30, 0x31, 0x32, 0x00, // light gray
0x3F, 0x00, 0x00, 0x00, // bright red
0x00, 0x3F, 0x00, 0x00, // bright green
0x3F, 0x3F, 0x00, 0x00, // bright yellow
0x00, 0x00, 0x3F, 0x00, // bright blue
0x3F, 0x00, 0x3F, 0x00, // bright magenta
0x00, 0x3F, 0x3F, 0x00, // bright cyan
0x3F, 0x3F, 0x3F, 0x00 // bright white
16, // 16 entries
0, 0,
0, // start with 0
0x00, 0x00, 0x00, 0x00, // black
0x2A, 0x00, 0x15, 0x00, // red
0x00, 0x2A, 0x15, 0x00, // green
0x2A, 0x2A, 0x15, 0x00, // brown
0x00, 0x00, 0x2A, 0x00, // blue
0x2A, 0x15, 0x2A, 0x00, // magenta
0x15, 0x2A, 0x2A, 0x00, // cyan
0x21, 0x22, 0x23, 0x00, // dark gray
0x30, 0x31, 0x32, 0x00, // light gray
0x3F, 0x00, 0x00, 0x00, // bright red
0x00, 0x3F, 0x00, 0x00, // bright green
0x3F, 0x3F, 0x00, 0x00, // bright yellow
0x00, 0x00, 0x3F, 0x00, // bright blue
0x3F, 0x00, 0x3F, 0x00, // bright magenta
0x00, 0x3F, 0x3F, 0x00, // bright cyan
0x3F, 0x3F, 0x3F, 0x00 // bright white
};
DWORD getAvailableModes(HANDLE Driver,
PVIDEO_MODE_INFORMATION *modeInformation,
DWORD *ModeSize)
{
ULONG Temp;
VIDEO_NUM_MODES modes;
PVIDEO_MODE_INFORMATION VideoTemp;
ULONG Temp;
VIDEO_NUM_MODES modes;
PVIDEO_MODE_INFORMATION VideoTemp;
// get number of modes supported
if (EngDeviceIoControl(Driver,
IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES,
NULL,
0,
&modes,
sizeof(VIDEO_NUM_MODES),
&Temp))
{
// get modes failed
return(0);
}
// get number of modes supported
if (EngDeviceIoControl(Driver,
IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES,
NULL,
0,
&modes,
sizeof(VIDEO_NUM_MODES),
&Temp))
{
// get modes failed
return(0);
}
*ModeSize = modes.ModeInformationLength;
*ModeSize = modes.ModeInformationLength;
// allocate buffer for the mini-port to write the modes in
*modeInformation = (PVIDEO_MODE_INFORMATION)
EngAllocMem(0, modes.NumModes *
modes.ModeInformationLength, ALLOC_TAG);
// allocate buffer for the mini-port to write the modes in
*modeInformation = (PVIDEO_MODE_INFORMATION)
EngAllocMem(0, modes.NumModes *
modes.ModeInformationLength, ALLOC_TAG);
if (*modeInformation == (PVIDEO_MODE_INFORMATION) NULL)
{
// couldn't allocate buffer
return 0;
}
if (*modeInformation == (PVIDEO_MODE_INFORMATION) NULL)
{
// couldn't allocate buffer
return 0;
}
// Ask the mini-port to fill in the available modes.
if (EngDeviceIoControl(Driver,
IOCTL_VIDEO_QUERY_AVAIL_MODES,
NULL,
0,
*modeInformation,
modes.NumModes * modes.ModeInformationLength,
&Temp))
{
// failed to query modes
EngFreeMem(*modeInformation);
*modeInformation = (PVIDEO_MODE_INFORMATION) NULL;
// Ask the mini-port to fill in the available modes.
if (EngDeviceIoControl(Driver,
IOCTL_VIDEO_QUERY_AVAIL_MODES,
NULL,
0,
*modeInformation,
modes.NumModes * modes.ModeInformationLength,
&Temp))
{
// failed to query modes
EngFreeMem(*modeInformation);
*modeInformation = (PVIDEO_MODE_INFORMATION) NULL;
return(0);
}
return(0);
}
// Which modes supported by miniport driver are also suppoted by us, the
// display driver
// Which modes supported by miniport driver are also suppoted by us, the
// display driver
Temp = modes.NumModes;
VideoTemp = *modeInformation;
Temp = modes.NumModes;
VideoTemp = *modeInformation;
// Reject mode if it's not 4 planes or not graphic or not 1 bits per pel
while (Temp--)
{
if ((VideoTemp->NumberOfPlanes != 4 ) ||
!(VideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) ||
(VideoTemp->BitsPerPlane != 1) ||
BROKEN_RASTERS(VideoTemp->ScreenStride,
VideoTemp->VisScreenHeight))
// Reject mode if it's not 4 planes or not graphic or not 1 bits per pel
while (Temp--)
{
if ((VideoTemp->NumberOfPlanes != 4 ) ||
!(VideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) ||
(VideoTemp->BitsPerPlane != 1) ||
BROKEN_RASTERS(VideoTemp->ScreenStride, VideoTemp->VisScreenHeight))
{
VideoTemp->Length = 0;
}
{
VideoTemp->Length = 0;
}
VideoTemp = (PVIDEO_MODE_INFORMATION)
(((PUCHAR)VideoTemp) + modes.ModeInformationLength);
}
VideoTemp = (PVIDEO_MODE_INFORMATION)(((PUCHAR)VideoTemp) + modes.ModeInformationLength);
}
return modes.NumModes;
return modes.NumModes;
}
BOOL InitVGA(PPDEV ppdev, BOOL bFirst)
{
UINT ReturnedDataLength;
VIDEO_MEMORY VideoMemory;
VIDEO_MEMORY_INFORMATION VideoMemoryInfo;
UINT ReturnedDataLength;
VIDEO_MEMORY VideoMemory;
VIDEO_MEMORY_INFORMATION VideoMemoryInfo;
char* vidmem;
char* vidmem;
ppdev->ModeNum = 12;
ppdev->ModeNum = 12;
// Set the mode that was requested
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_CURRENT_MODE,
&ppdev->ModeNum,
sizeof(VIDEO_MODE),
// Set the mode that was requested
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_CURRENT_MODE,
&ppdev->ModeNum,
sizeof(VIDEO_MODE),
NULL,
0,
&ReturnedDataLength)) {
return(FALSE);
}
// set up internal palette
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_PALETTE_REGISTERS,
(PVOID) PaletteBuffer,
sizeof (PaletteBuffer),
NULL,
0,
&ReturnedDataLength)) {
return(FALSE);
}
// set up the DAC
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_COLOR_REGISTERS,
(PVOID) ColorBuffer,
sizeof (ColorBuffer),
NULL,
0,
&ReturnedDataLength)) {
return(FALSE);
}
// set up internal palette
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_PALETTE_REGISTERS,
(PVOID) PaletteBuffer,
sizeof (PaletteBuffer),
NULL,
0,
&ReturnedDataLength)) {
return(FALSE);
}
// set up the DAC
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_COLOR_REGISTERS,
(PVOID) ColorBuffer,
sizeof (ColorBuffer),
NULL,
0,
&ReturnedDataLength)) {
return(FALSE);
}
return(FALSE);
}
/*
@ -168,5 +166,5 @@ gotta fix this up.. it prevents drawing to vidmem right now
ppdev->fbScreen = VideoMemoryInfo.FrameBufferBase;
}
*/
return TRUE;
return TRUE;
}

View file

@ -17,15 +17,15 @@ HANDLE GdiHeap;
typedef struct _RECT_ENUM
{
ULONG c;
RECTL arcl[ENUM_RECT_LIMIT];
ULONG c;
RECTL arcl[ENUM_RECT_LIMIT];
} RECT_ENUM;
// Cursor coordinates
typedef struct _XYPAIR
{
USHORT x;
USHORT y;
USHORT x;
USHORT y;
} XYPAIR;
// Cursor states
@ -37,60 +37,57 @@ typedef struct _XYPAIR
typedef struct _PDEV
{
ULONG fl; // driver flags
ULONG fl; // driver flags
// Handles
HANDLE KMDriver;
HDEV GDIDevHandle; // engine's handle to PDEV
HSURF SurfHandle; // engine's handle to surface
PVOID AssociatedSurf; // associated surface
// Handles
HANDLE KMDriver;
HDEV GDIDevHandle; // engine's handle to PDEV
HSURF SurfHandle; // engine's handle to surface
PVOID AssociatedSurf; // associated surface
// Cursor
XYPAIR xyCursor; // cursor position
POINTL ptlExtent; // cursor extent
ULONG cExtent; // effective cursor extent
ULONG flCursor; // cursor status
// Cursor
XYPAIR xyCursor; // cursor position
POINTL ptlExtent; // cursor extent
ULONG cExtent; // effective cursor extent
ULONG flCursor; // cursor status
// Pointer
PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // HW Pointer Attributes
ULONG XorMaskStartOffset; // Start offset of hardware pointer
// XOR mask relative to AND mask for
// passing to HW pointer
DWORD PointerAttributes; // Size of buffer allocated
DWORD flPreallocSSBBufferInUse; // True if preallocated saved screen
// bits buffer is in use
PUCHAR pjPreallocSSBBuffer; // Pointer to preallocated saved screen
// bits buffer, if there is one
ULONG ulPreallocSSBSize; // Size of preallocated saved screen
// bits buffer
VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
PUCHAR pucDIB4ToVGAConvBuffer; // DIB4->VGA conversion table buffer
PUCHAR pucDIB4ToVGAConvTables; // Pointer to DIB4->VGA conversion
// Pointer
PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // HW Pointer Attributes
ULONG XorMaskStartOffset; // Start offset of hardware pointer
// XOR mask relative to AND mask for
// passing to HW pointer
DWORD PointerAttributes; // Size of buffer allocated
DWORD flPreallocSSBBufferInUse; // True if preallocated saved screen
// bits buffer is in use
PUCHAR pjPreallocSSBBuffer; // Pointer to preallocated saved screen
// bits buffer, if there is one
ULONG ulPreallocSSBSize; // Size of preallocated saved screen
// bits buffer
VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
PUCHAR pucDIB4ToVGAConvBuffer; // DIB4->VGA conversion table buffer
PUCHAR pucDIB4ToVGAConvTables; // Pointer to DIB4->VGA conversion
// Misc
// Misc
ULONG ModeNum; // mode index for current VGA mode
ULONG ModeNum; // mode index for current VGA mode
SIZEL sizeSurf; // displayed size of the surface
PBYTE fbScreen; // pointer to the frame buffer
RECTL SavedBitsRight; // invisible part right of screen
RECTL SavedBitsBottom; // invisible part at the bottom of the screen
BOOL BitsSaved; // TRUE if bits are currently saved
SIZEL sizeMem; // actual size (in pixels) of video memory
LONG NumScansUsedByPointer; // # scans of offscreen memory used by
SIZEL sizeSurf; // displayed size of the surface
PBYTE fbScreen; // pointer to the frame buffer
RECTL SavedBitsRight; // invisible part right of screen
RECTL SavedBitsBottom; // invisible part at the bottom of the screen
BOOL BitsSaved; // TRUE if bits are currently saved
SIZEL sizeMem; // actual size (in pixels) of video memory
LONG NumScansUsedByPointer; // # scans of offscreen memory used by
} PDEV, *PPDEV;
typedef struct {
RECTL BankBounds; // Pixels addressable in this bank
ULONG BankOffset; // Offset of bank start from bitmap start if linearly addressable
RECTL BankBounds; // Pixels addressable in this bank
ULONG BankOffset; // Offset of bank start from bitmap start if linearly addressable
} BANK_INFO, *PBANK_INFO;
typedef enum {
JustifyTop = 0,
JustifyBottom,
JustifyTop = 0,
JustifyBottom,
} BANK_JUST;
// bank control function vector
@ -101,16 +98,16 @@ typedef VOID (*PFN_BankControl)(PVOID, ULONG, BANK_JUST);
typedef struct _SAVED_SCREEN_BITS
{
BOOL bFlags;
PBYTE pjBuffer; // pointer to save buffer start
ULONG ulSize; // size of save buffer (per plane; display memory only)
ULONG ulSaveWidthInBytes; // # of bytes across save area (including
// partial edge bytes, if any)
ULONG ulDelta; // # of bytes from end of one saved scan's saved bits to
// start of next (system memory only)
PVOID pvNextSSB; // pointer to next saved screen bits block
// for system memory blocks, saved bits start immediately
// after this structure
BOOL bFlags;
PBYTE pjBuffer; // pointer to save buffer start
ULONG ulSize; // size of save buffer (per plane; display memory only)
ULONG ulSaveWidthInBytes; // # of bytes across save area (including
// partial edge bytes, if any)
ULONG ulDelta; // # of bytes from end of one saved scan's saved bits to
// start of next (system memory only)
PVOID pvNextSSB; // pointer to next saved screen bits block
// for system memory blocks, saved bits start immediately
// after this structure
} SAVED_SCREEN_BITS, *PSAVED_SCREEN_BITS;
// DEVSURF -- definition of a surface as seen and used by the various VGA
@ -118,69 +115,68 @@ typedef struct _SAVED_SCREEN_BITS
typedef struct _DEVSURF
{
IDENT ident; // Identifier for debugging ease
ULONG flSurf; // DS_ flags as defined below
BYTE Color; // Solid color surface if DS_SOLIDBRUSH
IDENT ident; // Identifier for debugging ease
ULONG flSurf; // DS_ flags as defined below
BYTE Color; // Solid color surface if DS_SOLIDBRUSH
// If DS_SOLIDBRUSH, the following fields are undefined and not guaranteed to
// have been allocated!
BYTE Format; // BMF_*, BMF_PHYSDEVICE
BYTE jReserved1; // Reserved
BYTE jReserved2; // Reserved
PPDEV ppdev; // Pointer to associated PDEV
SIZEL sizeSurf; // Size of the surface
ULONG NextScan; // Offset from scan "n" to "n+1"
ULONG NextPlane; // Offset from plane "n" to "n+1"
PVOID Scan0; // Pointer to scan 0 of bitmap
// (actual address of start of bank, for banked VGA surface)
PVOID StartBmp; // Pointer to start of bitmap
PVOID Conv; // Pointer to DIB/Planer conversion buffer
BYTE Format; // BMF_*, BMF_PHYSDEVICE
BYTE jReserved1; // Reserved
BYTE jReserved2; // Reserved
PPDEV ppdev; // Pointer to associated PDEV
SIZEL sizeSurf; // Size of the surface
ULONG NextScan; // Offset from scan "n" to "n+1"
ULONG NextPlane; // Offset from plane "n" to "n+1"
PVOID Scan0; // Pointer to scan 0 of bitmap
// (actual address of start of bank, for banked VGA surface)
PVOID StartBmp; // Pointer to start of bitmap
PVOID Conv; // Pointer to DIB/Planer conversion buffer
// Banking variables; used only for banked VGA surfaces
PVIDEO_BANK_SELECT BankSelectInfo;
ULONG Bank2RWSkip; // Offset from one bank index to next to make two 32K banks appear to be
// one seamless 64K bank
PFN pfnBankSwitchCode;
VIDEO_BANK_TYPE BankingType;
ULONG BitmapSize; // Length of bitmap if there were no banking, in CPU addressable bytes
ULONG PtrBankScan; // Last scan line in pointer work bank
RECTL WindowClip1; // Single-window banking clip rect
RECTL WindowClip2[2]; // Double-window banking clip rects for
// windows 0 & 1
ULONG WindowBank[2]; // Current banks mapped into windows
// 0 & 1 (used in 2 window mode only)
PBANK_INFO BankInfo; // Pointer to array of bank clip info
ULONG BankInfoLength; // Length of pbiBankInfo, in entries
PBANK_INFO BankInfo2RW; // Same as above, but for 2RW window
ULONG BankInfo2RWLength; // case
PFN_BankControl pfnBankControl; // Pointer to bank control function
PFN_BankControl pfnBankControl2Window; // Pointer to double-window bank
// control function
PVOID BitmapStart; // Single-window bitmap start pointer (adjusted as
// necessary to make window map in at proper offset)
PVOID BitmapStart2Window[2]; // Double-window window 0 and 1 bitmap start
PVOID BankBufferPlane0; // Pointer to temp buffer capable of
// storing one full bank for plane 0 for 1
// R/W case; capable of storing one full
// bank height of edge bytes for all four
// planes for the 1R/1W case. Also used to
// point to text building buffer in all
// cases. This is the pointer used to
// dealloc bank working storage for all
// four planes
PVIDEO_BANK_SELECT BankSelectInfo;
ULONG Bank2RWSkip; // Offset from one bank index to next to make two 32K banks appear to be
// one seamless 64K bank
PFN pfnBankSwitchCode;
VIDEO_BANK_TYPE BankingType;
ULONG BitmapSize; // Length of bitmap if there were no banking, in CPU addressable bytes
ULONG PtrBankScan; // Last scan line in pointer work bank
RECTL WindowClip1; // Single-window banking clip rect
RECTL WindowClip2[2]; // Double-window banking clip rects for
// windows 0 & 1
ULONG WindowBank[2]; // Current banks mapped into windows
// 0 & 1 (used in 2 window mode only)
PBANK_INFO BankInfo; // Pointer to array of bank clip info
ULONG BankInfoLength; // Length of pbiBankInfo, in entries
PBANK_INFO BankInfo2RW; // Same as above, but for 2RW window
ULONG BankInfo2RWLength; // case
PFN_BankControl pfnBankControl; // Pointer to bank control function
PFN_BankControl pfnBankControl2Window; // Pointer to double-window bank
// control function
PVOID BitmapStart; // Single-window bitmap start pointer (adjusted as
// necessary to make window map in at proper offset)
PVOID BitmapStart2Window[2]; // Double-window window 0 and 1 bitmap start
PVOID BankBufferPlane0; // Pointer to temp buffer capable of
// storing one full bank for plane 0 for 1
// R/W case; capable of storing one full
// bank height of edge bytes for all four
// planes for the 1R/1W case. Also used to
// point to text building buffer in all
// cases. This is the pointer used to
// dealloc bank working storage for all
// four planes
// The following 3 pointers used by 1 R/W banked devices
// The following 3 pointers used by 1 R/W banked devices
PVOID BankBufferPlane1; // Like above, but for plane 1
PVOID BankBufferPlane2; // Like above, but for plane 2
PVOID BankBufferPlane3; // Like above, but for plane 3
ULONG TempBufferSize; // Full size of temp buffer pointed to
// by pvBankBufferPlane0
PVOID BankBufferPlane1; // Like above, but for plane 1
PVOID BankBufferPlane2; // Like above, but for plane 2
PVOID BankBufferPlane3; // Like above, but for plane 3
ULONG TempBufferSize; // Full size of temp buffer pointed to
// by pvBankBufferPlane0
ULONG ajBits[1]; // Bits will start here for device bitmaps
PSAVED_SCREEN_BITS ssbList; // Pointer to start of linked list of
ULONG ajBits[1]; // Bits will start here for device bitmaps
PSAVED_SCREEN_BITS ssbList; // Pointer to start of linked list of
// saved screen bit blocks
} DEVSURF, *PDEVSURF;
@ -208,5 +204,5 @@ BOOL InitVGA(PPDEV ppdev, BOOL bFirst); // screen.c: initialize VGA mode
#define PACKED_PELS_PER_CPU_ADDRESS 2
BOOL VGAtoGDI(
SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask, XLATEOBJ *ColorTranslation,
RECTL *DestRect, POINTL *SourcePoint);
SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask, XLATEOBJ *ColorTranslation,
RECTL *DestRect, POINTL *SourcePoint);

View file

@ -1,3 +1,15 @@
//
// The current VGA bitblt routines work just fine. However, they put the 4bpp data into 1 byte each.
// To solve the problem, whenever assigning to or retrieving data from the buffer, it must pass through
// a macro which packs it appropriately.
//
// Possible future enhancements:
// * Use putByte function for middlepix when bitbltting to the VGA
//
// PROCESS 1: Use 4bpp bitblt instead of 8bpp-bitmap/4bpp-display
//
#include <ddk/ntddk.h>
#include <ddk/ntddvid.h>
#include <ddk/winddi.h>
@ -7,154 +19,154 @@
INT abs(INT nm)
{
if(nm<0)
{
return nm * -1;
} else
{
return nm;
}
if(nm<0)
{
return nm * -1;
} else
{
return nm;
}
}
div_t div(int num, int denom)
{
div_t r;
if (num > 0 && denom < 0) {
num = -num;
denom = -denom;
}
r.quot = num / denom;
r.rem = num % denom;
if (num < 0 && denom > 0)
{
if (r.rem > 0)
{
r.quot++;
r.rem -= denom;
}
}
return r;
div_t r;
if (num > 0 && denom < 0) {
num = -num;
denom = -denom;
}
r.quot = num / denom;
r.rem = num % denom;
if (num < 0 && denom > 0)
{
if (r.rem > 0)
{
r.quot++;
r.rem -= denom;
}
}
return r;
}
int mod(int num, int denom)
{
div_t dvt = div(num, denom);
return dvt.rem;
div_t dvt = div(num, denom);
return dvt.rem;
}
BYTE bytesPerPixel(ULONG Format)
{
// This function is taken from /subsys/win32k/eng/surface.c
// FIXME: GDI bitmaps are supposed to be pixel-packed. Right now if the
// pixel size if < 1 byte we expand it to 1 byte for simplicities sake
// This function is taken from /subsys/win32k/eng/surface.c
// FIXME: GDI bitmaps are supposed to be pixel-packed. Right now if the
// pixel size if < 1 byte we expand it to 1 byte for simplicities sake
if(Format==BMF_1BPP)
{
return 1;
} else
if((Format==BMF_4BPP) || (Format==BMF_4RLE))
{
return 1;
} else
if((Format==BMF_8BPP) || (Format==BMF_8RLE))
{
return 1;
} else
if(Format==BMF_16BPP)
{
return 2;
} else
if(Format==BMF_24BPP)
{
return 3;
} else
if(Format==BMF_32BPP)
{
return 4;
}
if(Format==BMF_1BPP)
{
return 1;
} else
if((Format==BMF_4BPP) || (Format==BMF_4RLE))
{
return 1;
} else
if((Format==BMF_8BPP) || (Format==BMF_8RLE))
{
return 1;
} else
if(Format==BMF_16BPP)
{
return 2;
} else
if(Format==BMF_24BPP)
{
return 3;
} else
if(Format==BMF_32BPP)
{
return 4;
}
return 0;
return 0;
}
VOID vgaPreCalc()
{
ULONG j;
ULONG j;
startmasks[1] = 127;
startmasks[2] = 63;
startmasks[3] = 31;
startmasks[4] = 15;
startmasks[5] = 7;
startmasks[6] = 3;
startmasks[7] = 1;
startmasks[8] = 255;
startmasks[1] = 127;
startmasks[2] = 63;
startmasks[3] = 31;
startmasks[4] = 15;
startmasks[5] = 7;
startmasks[6] = 3;
startmasks[7] = 1;
startmasks[8] = 255;
endmasks[0] = 128;
endmasks[1] = 192;
endmasks[2] = 224;
endmasks[3] = 240;
endmasks[4] = 248;
endmasks[5] = 252;
endmasks[6] = 254;
endmasks[7] = 255;
endmasks[8] = 255;
endmasks[0] = 128;
endmasks[1] = 192;
endmasks[2] = 224;
endmasks[3] = 240;
endmasks[4] = 248;
endmasks[5] = 252;
endmasks[6] = 254;
endmasks[7] = 255;
endmasks[8] = 255;
for(j=0; j<80; j++)
{
maskbit[j*8] = 128;
maskbit[j*8+1] = 64;
maskbit[j*8+2] = 32;
maskbit[j*8+3] = 16;
maskbit[j*8+4] = 8;
maskbit[j*8+5] = 4;
maskbit[j*8+6] = 2;
maskbit[j*8+7] = 1;
for(j=0; j<80; j++)
{
maskbit[j*8] = 128;
maskbit[j*8+1] = 64;
maskbit[j*8+2] = 32;
maskbit[j*8+3] = 16;
maskbit[j*8+4] = 8;
maskbit[j*8+5] = 4;
maskbit[j*8+6] = 2;
maskbit[j*8+7] = 1;
bit8[j*8] = 7;
bit8[j*8+1] = 6;
bit8[j*8+2] = 5;
bit8[j*8+3] = 4;
bit8[j*8+4] = 3;
bit8[j*8+5] = 2;
bit8[j*8+6] = 1;
bit8[j*8+7] = 0;
}
for(j=0; j<480; j++)
{
y80[j] = j*80;
}
for(j=0; j<640; j++)
{
xconv[j] = j >> 3;
}
bit8[j*8] = 7;
bit8[j*8+1] = 6;
bit8[j*8+2] = 5;
bit8[j*8+3] = 4;
bit8[j*8+4] = 3;
bit8[j*8+5] = 2;
bit8[j*8+6] = 1;
bit8[j*8+7] = 0;
}
for(j=0; j<480; j++)
{
y80[j] = j*80;
}
for(j=0; j<640; j++)
{
xconv[j] = j >> 3;
}
}
void
get_masks(int x, int w)
{
register int tmp;
register int tmp;
leftMask = rightMask = 0;
byteCounter = w;
/* right margin */
tmp = (x+w) & 7;
if (tmp) {
byteCounter -= tmp;
rightMask = (unsigned char)(0xff00 >> tmp);
}
/* left margin */
tmp = x & 7;
if (tmp) {
byteCounter -= (8 - tmp);
leftMask = (0xff >> tmp);
}
/* too small ? */
if (byteCounter < 0) {
leftMask &= rightMask;
rightMask = 0;
byteCounter = 0;
}
byteCounter /= 8;
leftMask = rightMask = 0;
byteCounter = w;
/* right margin */
tmp = (x+w) & 7;
if (tmp) {
byteCounter -= tmp;
rightMask = (unsigned char)(0xff00 >> tmp);
}
/* left margin */
tmp = x & 7;
if (tmp) {
byteCounter -= (8 - tmp);
leftMask = (0xff >> tmp);
}
/* too small ? */
if (byteCounter < 0) {
leftMask &= rightMask;
rightMask = 0;
byteCounter = 0;
}
byteCounter /= 8;
}
VOID vgaPutPixel(INT x, INT y, UCHAR c)
@ -342,145 +354,242 @@ static const RECTL rclEmpty = { 0, 0, 0, 0 };
BOOL VGADDIIntersectRect(PRECTL prcDst, PRECTL prcSrc1, PRECTL prcSrc2)
{
prcDst->left = max(prcSrc1->left, prcSrc2->left);
prcDst->right = min(prcSrc1->right, prcSrc2->right);
prcDst->left = max(prcSrc1->left, prcSrc2->left);
prcDst->right = min(prcSrc1->right, prcSrc2->right);
if (prcDst->left < prcDst->right) {
if (prcDst->left < prcDst->right) {
prcDst->top = max(prcSrc1->top, prcSrc2->top);
prcDst->bottom = min(prcSrc1->bottom, prcSrc2->bottom);
if (prcDst->top < prcDst->bottom)
{
return TRUE;
if (prcDst->top < prcDst->bottom)
{
return TRUE;
}
}
*prcDst = rclEmpty;
return FALSE;
}
void DIB_BltFromVGA(int x, int y, int w, int h, void *b, int Dest_lDelta)
// DIB blt from the VGA.
// For now we just do slow reads -- pixel by pixel, packing each one into the correct 4BPP format.
{
PBYTE pb = b, opb = b;
BOOLEAN edgePixel = FALSE;
ULONG i, j;
ULONG x2 = x + w;
ULONG y2 = y + h;
BYTE b1, b2;
// Check if the width is odd
if(mod(w, 2)>0)
{
edgePixel = TRUE;
x2 -= 1;
}
for (j=y; j<y2; j++)
{
for (i=x; i<x2; i+=2)
{
b1 = vgaGetPixel(i, j);
b2 = vgaGetPixel(i+1, j);
*pb = b2 | (b1 << 4);
pb++;
}
if(edgePixel == TRUE)
{
b1 = vgaGetPixel(x2, j);
*pb = b1;
pb++;
}
opb += Dest_lDelta; // new test code
pb = opb; // new test code
}
}
void DIB_BltToVGA(int x, int y, int w, int h, void *b, int Source_lDelta)
// DIB blt to the VGA.
// For now we just do slow writes -- pixel by pixel, packing each one into the correct 4BPP format.
{
PBYTE pb = b, opb = b;
BOOLEAN edgePixel = FALSE;
ULONG i, j;
ULONG x2 = x + w;
ULONG y2 = y + h;
BYTE b1, b2;
// Check if the width is odd
if(mod(w, 2)>0)
{
edgePixel = TRUE;
x2 -= 1;
}
for (j=y; j<y2; j++)
{
for (i=x; i<x2; i+=2)
{
b1 = (*pb & 0xf0) >> 4;
b2 = *pb & 0x0f;
vgaPutPixel(i, j, b1);
vgaPutPixel(i+1, j, b2);
pb++;
}
if(edgePixel == TRUE)
{
b1 = *pb;
vgaPutPixel(x2, j, b1);
pb++;
}
opb += Source_lDelta; // new test code
pb = opb; // new test code
}
}
void DFB_BltFromVGA(int x, int y, int w, int h, void *b, int bw)
// This algorithm goes from goes from left to right, and inside that loop, top to bottom.
// It also stores each 4BPP pixel in an entire byte.
{
unsigned char *vp, *vpY, *vpP;
unsigned char data, mask, maskP;
unsigned char *bp, *bpY;
unsigned char plane_mask;
int byte_per_line = SCREEN_X >> 3;
int plane, i, j;
ASSIGNVP4(x, y, vpP)
ASSIGNMK4(x, y, maskP)
get_masks(x, w);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); // read mode 0
saved_GC_mode = READ_PORT_UCHAR((PUCHAR)GRA_D);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x00);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x04); // read map select
saved_GC_rmap = READ_PORT_UCHAR((PUCHAR)GRA_D);
// clear buffer
bp=b;
for (j=h; j>0; j--) {
memset(bp, 0, w);
bp += bw;
}
for (plane=0, plane_mask=1; plane<4; plane++, plane_mask<<=1) {
WRITE_PORT_UCHAR((PUCHAR)GRA_D, plane); // read map select
vpY = vpP;
bpY = b;
for (j=h; j>0; j--) {
vp = vpY;
bp = bpY;
if (leftMask) {
mask = maskP;
data = *vp++;
do {
if (data & mask) *bp |= plane_mask;
bp++;
mask >>= 1;
} while (mask & leftMask);
}
}
if (byteCounter) {
for (i=byteCounter; i>0; i--) {
data = *vp++;
if (data & 0x80) *bp |= plane_mask;
bp++;
if (data & 0x40) *bp |= plane_mask;
bp++;
if (data & 0x20) *bp |= plane_mask;
bp++;
if (data & 0x10) *bp |= plane_mask;
bp++;
if (data & 0x08) *bp |= plane_mask;
bp++;
if (data & 0x04) *bp |= plane_mask;
bp++;
if (data & 0x02) *bp |= plane_mask;
bp++;
if (data & 0x01) *bp |= plane_mask;
bp++;
}
}
if (rightMask) {
mask = 0x80;
data = *vp;
do {
if (data & mask) *bp |= plane_mask;
bp++;
mask >>= 1;
} while (mask & rightMask);
}
bpY += bw;
vpY += byte_per_line;
}
}
*prcDst = rclEmpty;
return FALSE;
// reset GC register
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_rmap);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_mode);
}
void BltFromVGA(int x, int y, int w, int h, void *b, int bw)
void DFB_BltToVGA(int x, int y, int w, int h, void *b, int bw)
// This algorithm goes from goes from left to right, and inside that loop, top to bottom.
// It also stores each 4BPP pixel in an entire byte.
{
unsigned char *vp, *vpY, *vpP;
unsigned char data, mask, maskP;
unsigned char *bp, *bpY;
unsigned char plane_mask;
int byte_per_line = SCREEN_X >> 3;
int plane, i, j;
unsigned char *bp, *bpX;
unsigned char *vp, *vpX;
unsigned char mask;
volatile unsigned char dummy;
int byte_per_line;
int i, j;
ASSIGNVP4(x, y, vpP)
ASSIGNMK4(x, y, maskP)
get_masks(x, w);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); /* read mode 0 */
saved_GC_mode = READ_PORT_UCHAR((PUCHAR)GRA_D);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x00);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x04); /* read map select */
saved_GC_rmap = READ_PORT_UCHAR((PUCHAR)GRA_D);
/* clear buffer */
bp=b;
for (j=h; j>0; j--) {
memset(bp, 0, w);
bp += bw;
}
for (plane=0, plane_mask=1; plane<4; plane++, plane_mask<<=1) {
WRITE_PORT_UCHAR((PUCHAR)GRA_D, plane); /* read map select */
vpY = vpP;
bpY = b;
for (j=h; j>0; j--) {
vp = vpY;
bp = bpY;
if (leftMask) {
mask = maskP;
data = *vp++;
do {
if (data & mask) *bp |= plane_mask;
bp++;
mask >>= 1;
} while (mask & leftMask);
bpX = b;
ASSIGNVP4(x, y, vpX)
ASSIGNMK4(x, y, mask)
byte_per_line = SCREEN_X >> 3;
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); // write mode 2
saved_GC_mode = READ_PORT_UCHAR((PUCHAR)GRA_D);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x02);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03); // replace
saved_GC_fun = READ_PORT_UCHAR((PUCHAR)GRA_D);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x00);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08); // bit mask
saved_GC_mask = READ_PORT_UCHAR((PUCHAR)GRA_D);
}
if (byteCounter) {
for (i=byteCounter; i>0; i--) {
data = *vp++;
if (data & 0x80) *bp |= plane_mask;
bp++;
if (data & 0x40) *bp |= plane_mask;
bp++;
if (data & 0x20) *bp |= plane_mask;
bp++;
if (data & 0x10) *bp |= plane_mask;
bp++;
if (data & 0x08) *bp |= plane_mask;
bp++;
if (data & 0x04) *bp |= plane_mask;
bp++;
if (data & 0x02) *bp |= plane_mask;
bp++;
if (data & 0x01) *bp |= plane_mask;
bp++;
}
}
if (rightMask) {
mask = 0x80;
data = *vp;
do {
if (data & mask) *bp |= plane_mask;
bp++;
mask >>= 1;
} while (mask & rightMask);
}
bpY += bw;
vpY += byte_per_line;
}
}
/* reset GC register */
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_rmap);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_mode);
}
void BltToVGA(int x, int y, int w, int h, void *b, int bw)
{
unsigned char *bp, *bpX;
unsigned char *vp, *vpX;
unsigned char mask;
volatile unsigned char dummy;
int byte_per_line;
int i, j;
bpX = b;
ASSIGNVP4(x, y, vpX)
ASSIGNMK4(x, y, mask)
byte_per_line = SCREEN_X >> 3;
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); /* write mode 2 */
saved_GC_mode = READ_PORT_UCHAR((PUCHAR)GRA_D);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x02);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03); /* replace */
saved_GC_fun = READ_PORT_UCHAR((PUCHAR)GRA_D);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x00);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08); /* bit mask */
saved_GC_mask = READ_PORT_UCHAR((PUCHAR)GRA_D);
for (i=w; i>0; i--) {
WRITE_PORT_UCHAR((PUCHAR)GRA_D, mask);
bp = bpX;
vp = vpX;
for (j=h; j>0; j--) {
dummy = *vp; *vp = *bp;
bp += bw;
vp += byte_per_line;
}
bpX++;
if ((mask >>= 1) == 0) {
vpX++;
mask = 0x80;
}
}
/* reset GC register */
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_mask);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_fun);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_mode);
for (i=w; i>0; i--) {
WRITE_PORT_UCHAR((PUCHAR)GRA_D, mask);
bp = bpX;
vp = vpX;
for (j=h; j>0; j--) {
dummy = *vp;
*vp = *bp;
bp += bw;
vp += byte_per_line;
}
bpX++;
if ((mask >>= 1) == 0) {
vpX++;
mask = 0x80;
}
}
// reset GC register
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_mask);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_fun);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, saved_GC_mode);
}