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 $
*
*/
@ -166,7 +166,6 @@ DHPDEV VGADDIEnablePDEV(IN DEVMODEW *DM,
if (PDev == NULL)
{
EngDebugPrint(DBG_PREFIX, "EngAllocMem failed for PDEV\n", 0);
return NULL;
}
PDev->KMDriver = Driver;
@ -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;
@ -225,13 +223,7 @@ VOID VGADDIAssertMode(IN DHPDEV DPev,
} 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;

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

@ -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

@ -78,7 +78,7 @@ void vgaHideCursor(PPDEV ppdev)
ULONG i, j, cx, cy, bitpos;
// Display what was behind cursor
BltToVGA(oldx, oldx, oldy,
DFB_BltToVGA(oldx, oldx, oldy,
ppdev->pPointerAttributes->Width-1,
ppdev->pPointerAttributes->Height-1,
behindCursor);
@ -112,7 +112,7 @@ void vgaShowCursor(PPDEV ppdev)
}
// Display the cursor
BltToVGA(ppdev->xyCursor.x, ppdev->xyCursor.x, ppdev->xyCursor.y,
DIB_BltToVGA(ppdev->xyCursor.x, ppdev->xyCursor.x, ppdev->xyCursor.y,
ppdev->pPointerAttributes->Width-1,
ppdev->pPointerAttributes->Height-1,
ppdev->pPointerAttributes->Pixels);

View file

@ -89,15 +89,13 @@ DWORD getAvailableModes(HANDLE Driver,
if ((VideoTemp->NumberOfPlanes != 4 ) ||
!(VideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) ||
(VideoTemp->BitsPerPlane != 1) ||
BROKEN_RASTERS(VideoTemp->ScreenStride,
VideoTemp->VisScreenHeight))
BROKEN_RASTERS(VideoTemp->ScreenStride, VideoTemp->VisScreenHeight))
{
VideoTemp->Length = 0;
}
VideoTemp = (PVIDEO_MODE_INFORMATION)
(((PUCHAR)VideoTemp) + modes.ModeInformationLength);
VideoTemp = (PVIDEO_MODE_INFORMATION)(((PUCHAR)VideoTemp) + modes.ModeInformationLength);
}
return modes.NumModes;
@ -109,7 +107,7 @@ BOOL InitVGA(PPDEV ppdev, BOOL bFirst)
VIDEO_MEMORY VideoMemory;
VIDEO_MEMORY_INFORMATION VideoMemoryInfo;
char* vidmem;
char* vidmem;
ppdev->ModeNum = 12;

View file

@ -68,13 +68,10 @@ typedef struct _PDEV
PUCHAR pucDIB4ToVGAConvTables; // Pointer to DIB4->VGA conversion
// Misc
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
@ -172,7 +169,6 @@ typedef struct _DEVSURF
// four planes
// 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

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>
@ -360,7 +372,95 @@ BOOL VGADDIIntersectRect(PRECTL prcDst, PRECTL prcSrc1, PRECTL prcSrc2)
return FALSE;
}
void BltFromVGA(int x, int y, int w, int h, void *b, int bw)
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;
@ -372,19 +472,21 @@ void BltFromVGA(int x, int y, int w, int h, void *b, int bw)
ASSIGNVP4(x, y, vpP)
ASSIGNMK4(x, y, maskP)
get_masks(x, w);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); /* read mode 0 */
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 */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x04); // read map select
saved_GC_rmap = READ_PORT_UCHAR((PUCHAR)GRA_D);
/* clear buffer */
// 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 */
WRITE_PORT_UCHAR((PUCHAR)GRA_D, plane); // read map select
vpY = vpP;
bpY = b;
for (j=h; j>0; j--) {
@ -434,14 +536,18 @@ void BltFromVGA(int x, int y, int w, int h, void *b, int bw)
vpY += byte_per_line;
}
}
/* reset GC register */
// 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)
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 *bp, *bpX;
unsigned char *vp, *vpX;
@ -454,20 +560,22 @@ void BltToVGA(int x, int y, int w, int h, void *b, int bw)
ASSIGNVP4(x, y, vpX)
ASSIGNMK4(x, y, mask)
byte_per_line = SCREEN_X >> 3;
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05); /* write mode 2 */
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 */
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 */
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;
dummy = *vp;
*vp = *bp;
bp += bw;
vp += byte_per_line;
}
@ -477,7 +585,8 @@ void BltToVGA(int x, int y, int w, int h, void *b, int bw)
mask = 0x80;
}
}
/* reset GC register */
// 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);