*** empty log message ***

svn path=/trunk/; revision=1403
This commit is contained in:
Jason Filby 2000-10-14 22:40:18 +00:00
parent e9b7a9a972
commit d17678ebd0
7 changed files with 335 additions and 936 deletions

View file

@ -1,9 +1,9 @@
/*
* entry.c
*
* $Revision: 1.8 $
* $Author: phreak $
* $Date: 2000/07/07 00:59:41 $
* $Revision: 1.9 $
* $Author: jfilby $
* $Date: 2000/10/14 22:40:17 $
*
*/
@ -44,9 +44,10 @@ BOOL VGADDIBitBlt(SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask,
CLIPOBJ *Clip, XLATEOBJ *ColorTranslation,
RECTL *DestRect, POINTL *SourcePoint, POINTL *MaskPoint,
BRUSHOBJ *Brush, POINTL *BrushPoint, ROP4 rop4);
BOOL VGADDICopyBits(SURFOBJ *Dest, SURFOBJ *Source,
CLIPOBJ *Clip, XLATEOBJ *ColorTranslation,
PRECTL DestRect, PPOINTL SourcePoint);
VOID VGADDIMovePointer(PSURFOBJ pso, LONG x, LONG y, PRECTL prcl);
ULONG VGADDISetPointerShape(PSURFOBJ pso, PSURFOBJ psoMask, PSURFOBJ psoColor, PXLATEOBJ pxlo,
LONG xHot, LONG yHot, LONG x, LONG y,
PRECTL prcl, ULONG fl);
DRVFN FuncList[] =
{
@ -61,7 +62,8 @@ DRVFN FuncList[] =
{INDEX_DrvLineTo, (PFN) VGADDILineTo},
{INDEX_DrvPaint, (PFN) VGADDIPaint},
{INDEX_DrvBitBlt, (PFN) VGADDIBitBlt},
// {INDEX_DrvCopyBits, (PFN) VGADDICopyBits},
{INDEX_DrvMovePointer, (PFN) VGADDIMovePointer},
{INDEX_DrvSetPointerShape, (PFN) VGADDISetPointerShape},
#if 0
/* Optional Display driver functions */
@ -71,7 +73,6 @@ DRVFN FuncList[] =
{INDEX_DrvFillPath, (PFN) VGADDIFillPath},
{INDEX_DrvGetTrueTypeFile, (PFN) VGADDIGetTrueTypeFile},
{INDEX_DrvLoadFontFile, (PFN) VGADDILoadFontFile},
{INDEX_DrvMovePointer, (PFN) VGADDIMovePointer},
{INDEX_DrvQueryFont, (PFN) VGADDIQueryFont},
{INDEX_DrvQueryFontCaps, (PFN) VGADDIQueryFontCaps},
{INDEX_DrvQueryFontData, (PFN) VGADDIQueryFontData},
@ -83,7 +84,6 @@ DRVFN FuncList[] =
{INDEX_DrvResetPDEV, (PFN) VGADDIResetPDEV},
{INDEX_DrvSetPalette, (PFN) VGADDISetPalette},
{INDEX_DrvSetPixelFormat, (PFN) VGADDISetPixelFormat},
{INDEX_DrvSetPointerShape, (PFN) VGADDISetPointerShape},
{INDEX_DrvStretchBlt, (PFN) VGADDIStretchBlt},
{INDEX_DrvStrokePath, (PFN) VGADDIStrokePath},
{INDEX_DrvSwapBuffers, (PFN) VGADDISwapBuffers},
@ -196,7 +196,7 @@ DHPDEV VGADDIEnablePDEV(IN DEVMODEW *DM,
VOID VGADDICompletePDEV(IN DHPDEV PDev,
IN HDEV Dev)
{
((PPDEV) PDev)->GDIDevHandle = Dev;
((PPDEV) PDev)->GDIDevHandle = Dev; // Handle to the DC
}
@ -210,11 +210,11 @@ VOID VGADDIAssertMode(IN DHPDEV DPev,
{
// Reenable our graphics mode
/* if (!InitPointer(ppdev))
if (!InitPointer(ppdev))
{
// Failed to set pointer
return FALSE;
} POINTER CODE CURRENTLY UNIMPLEMENTED... */
// Failed to set pointer
return FALSE;
}
if (!InitVGA(ppdev, FALSE))
{
@ -353,6 +353,7 @@ HSURF VGADDIEnableSurface(IN DHPDEV PDev)
goto error_done;
}
// dhsurf is of type DEVSURF, which is the drivers specialized surface type
dhsurf = (DHSURF)EngAllocMem(0, sizeof(DEVSURF), ALLOC_TAG);
if (dhsurf == (DHSURF) 0)
{
@ -374,10 +375,10 @@ HSURF VGADDIEnableSurface(IN DHPDEV PDev)
pdsurf->StartBmp = ppdev->fbScreen;
/* pdsurf->Conv = &ConvertBuffer[0]; */
/* if (!bInitPointer(ppdev)) {
DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n"));
if (!InitPointer(ppdev)) {
DbgPrint("DrvEnablePDEV failed bInitPointer\n");
goto error_clean;
} POINTER CODE UNIMPLEMENTED */
}
/* if (!SetUpBanking(pdsurf, ppdev)) {
DISPDBG((0, "DrvEnablePDEV failed SetUpBanking\n"));

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.11 2000/10/07 13:41:55 dwelch Exp $
# $Id: makefile,v 1.12 2000/10/14 22:40:17 jfilby Exp $
#
# Makefile for ReactOS vgaddi.dll
#
@ -20,7 +20,8 @@ endif
all: $(DLLTARGET)
MAIN_OBJECTS = main/enable.o
OTHER_OBJECTS = objects/screen.o objects/lineto.o objects/paint.o objects/bitblt.o objects/copybits.o vgavideo/vgavideo.o
OTHER_OBJECTS = objects/screen.o objects/pointer.o objects/lineto.o objects/paint.o objects/bitblt.o \
vgavideo/vgavideo.o
RESOURCE_OBJECTS = $(TARGET).coff
OBJECTS = $(MAIN_OBJECTS) $(OTHER_OBJECTS) $(RESOURCE_OBJECTS)

View file

@ -33,20 +33,9 @@ BOOL GDItoVGA(
if(ColorTranslation == NULL)
{
DPRINT("GDItoVGA: No color translation\n");
// No color translation necessary, we assume BPP = 1
BltToVGA(DestRect->left, DestRect->top, dx, dy, Source->pvBits, Source->lDelta);
for(j=SourcePoint->y; j<SourcePoint->y+dy; j++)
{
initial = GDIpos;
for(i=SourcePoint->x; i<SourcePoint->x+dx; i++)
{
vgaPutPixel(i+alterx, j+altery, *GDIpos);
GDIpos+=BPP;
}
GDIpos = initial + Source->lDelta;
}
} else {
// Perform color translation
for(j=SourcePoint->y; j<SourcePoint->y+dy; j++)
@ -72,32 +61,28 @@ BOOL VGAtoGDI(
LONG i, j, dx, dy, RGBulong, BPP;
BYTE *GDIpos, *initial, idxColor;
// Used by the temporary DFB
PDEVSURF TargetSurf;
DEVSURF DestDevSurf;
PSURFOBJ TargetBitmapSurf;
HBITMAP hTargetBitmap;
SIZEL InterSize;
POINTL ZeroPoint;
// FIXME: Optimize to retrieve entire bytes at a time (see /display/vgavideo/vgavideo.c:vgaGetByte)
BPP = bytesPerPixel(Dest->iBitmapFormat);
DPRINT("VGAtoGDI: BPP: %u\n", BPP);
GDIpos = Dest->pvBits +
(DestRect->top * Dest->lDelta) + (DestRect->left * BPP);
GDIpos = Dest->pvBits + (DestRect->top * Dest->lDelta) + (DestRect->left * BPP);
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
if(ColorTranslation == NULL)
{
DPRINT("VGAtoGDI: No color translation\n");
// No color translation necessary, we assume BPP = 1
for(j=SourcePoint->y; j<SourcePoint->y+dy; j++)
{
initial = GDIpos;
for(i=SourcePoint->x; i<SourcePoint->x+dx; i++)
{
*GDIpos = vgaGetPixel(i, j);
GDIpos++;
}
GDIpos = initial + Dest->lDelta;
}
// 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);
} else {
// Color translation
for(j=SourcePoint->y; j<SourcePoint->y+dy; j++)
@ -193,9 +178,10 @@ BOOL VGADDIBitBlt(SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask,
{
RECT_ENUM RectEnum;
BOOL EnumMore;
PFN_VGABlt BltOperation;
DPRINT("VGADDIBitBlt: Dest->pvScan0: %08x\n", Dest->pvScan0);
// Determine the bltbit operation
if((Source->iType == STYPE_BITMAP) && (Dest->iType == STYPE_DEVICE))
@ -224,7 +210,7 @@ DPRINT("VGA2DFB\n");
BltOperation = VGAtoDFB;
} else
{
DPRINT("VGA:bitblt.c: Can't handle requested BitBlt operation\n");
DPRINT("VGA:bitblt.c: Can't handle requested BitBlt operation (source:%u dest:%u)\n", Source->iType, Dest->iType);
// Cannot handle given surfaces for VGA BitBlt
return FALSE;
}

View file

@ -1,859 +0,0 @@
#include <ddk/winddi.h>
#include "../../../../ntoskrnl/include/internal/i386/io.h"
#include "../vgaddi.h"
#include "../vgavideo/vgavideo.h"
// FIXME: There's a lot of redundancy in here -- break into functions
// FIXME: All functions involving the screen use terribly slow vgaPutPixel -- use something better
VOID Screen2Screen(PDEVSURF PDSurf, RECTL *DestRect, POINTL *SourcePoint,
ULONG iCopyDir)
{
ULONG i, j, spx, spy;
spy = SourcePoint->y;
// FIXME: Right now assumes top->down and left->right
for (j=DestRect->top; j<DestRect->bottom; j++)
{
spx = SourcePoint->x;
for(i=DestRect->left; i<DestRect->right; i++)
{
vgaPutPixel(spx, spy, vgaGetPixel(i, j));
spx++;
}
spy++;
}
}
VOID CopyRect4BPP(PDEVSURF DestSurf, PDEVSURF SourceSurf, RECTL *DestRect,
POINTL *SourcePoint)
{
ULONG i, j, Width, spy;
spy = SourcePoint->y;
Width = DestRect->right - DestRect->left;
for (j=DestRect->top; j<DestRect->bottom; j++)
{
RtlCopyMemory(DestSurf->StartBmp+DestSurf->NextScan*j+DestRect->left,
SourceSurf->StartBmp+SourceSurf->NextScan*j+SourcePoint->x,
Width);
spy++;
}
}
VOID DFB2DIB(PDEVSURF DestSurf, PDEVSURF SourceSurf, RECTL *DestRect,
POINTL *SourcePoint)
{
CopyRect4BPP(DestSurf, SourceSurf, DestRect, SourcePoint);
}
VOID DFB2DFB(PDEVSURF DestSurf, PDEVSURF SourceSurf, RECTL *DestRect,
POINTL *SourcePoint)
{
CopyRect4BPP(DestSurf, SourceSurf, DestRect, SourcePoint);
}
#define DFB_TARGET 0
#define VGA_TARGET 1
VOID DIB2VGA(PDEVSURF DestSurf, PDEVSURF SourceSurf,
RECTL *DestRect, POINTL *SourcePoint, UCHAR *ConversionTables,
BOOL DFBorVGAtarget)
{
ULONG i, j, spx, spy;
BYTE c;
spy = SourcePoint->y;
for (j=DestRect->top; j<DestRect->bottom; j++)
{
spx = SourcePoint->x;
for(i=DestRect->left; i<DestRect->right; i++)
{
if(DFBorVGAtarget == DFB_TARGET)
{
c = vgaGetPixel(spx, spy);
RtlCopyMemory(DestSurf->StartBmp+j*DestSurf->NextScan+i, c, 1);
} else
{
RtlCopyMemory(c, SourceSurf->StartBmp+j*SourceSurf->NextScan+i, 1);
vgaPutPixel(spx, spy, c);
}
spx++;
}
spy++;
}
}
VOID DFB2VGA(DEVSURF *DestSurf, DEVSURF *SourceSurf, RECTL *DestRect,
POINTL *SourcePoint)
{
DIB2VGA(DestSurf, SourceSurf, DestRect, SourcePoint, NULL, VGA_TARGET);
}
VOID VGA2DIB(DEVSURF *DestSurf, ULONG xSource, ULONG ySource,
PVOID DestScan0, ULONG left, ULONG top, ULONG width,
ULONG height, ULONG lDelta, ULONG Format, ULONG *Conversion)
{
ULONG i, j, spx, spy, right = left + width, bottom = top + height;
BYTE c;
spy = ySource;
for (j=top; j<bottom; j++)
{
spx = xSource;
for(i=left; i<right; i++)
{
c = vgaGetPixel(spx, spy);
RtlCopyMemory(DestSurf->StartBmp+j*DestSurf->NextScan+i, c, 1);
spx++;
}
spy++;
}
}
BOOL VGADDICopyBits(SURFOBJ *Dest, SURFOBJ *Source,
CLIPOBJ *Clip, XLATEOBJ *ColorTranslation,
PRECTL DestRect, PPOINTL SourcePoint)
{
PDEVSURF pdsurf; // Pointer to a device surface
LONG lDelta; // Delta to next scan of destination
PVOID pjDstScan0; // Pointer to scan 0 of destination DIB
ULONG *pulXlate; // Pointer to color xlate vector
BOOL EnumMore; // Clip continuation flag
ULONG ircl; // Clip enumeration rectangle index
RECT_ENUM cben; // Clip enumerator
RECTL TempRect;
PRECTL PRect;
POINTL TempPoint;
DEVSURF TempDSurf;
PDEVSURF SurfDest; // Pointer for target
PDEVSURF SurfSource; // Pointer for source if present
INT iCopyDir;
RECT_ENUM RectEnum; // Clip enumerator
BYTE jClipping;
UCHAR *pucDIB4ToVGAConvTables;
ULONG ulWidth;
ULONG ulNumSlices;
ULONG ulRight;
ULONG x;
// If translation is XO_TRIVIAL then no translation is required
if(ColorTranslation && (ColorTranslation->flXlate & XO_TRIVIAL))
{
ColorTranslation = NULL;
}
// If the destination is a device managed bitmap give it to VGADDIBitBlt
if(ColorTranslation &&
((Dest->iType == STYPE_DEVICE) || (Dest->iType == STYPE_DEVBITMAP)))
{
return(VGADDIBitBlt(Dest, Source, (SURFOBJ *)NULL,
Clip, ColorTranslation,
DestRect, SourcePoint,
(POINTL *)NULL, (BRUSHOBJ *)NULL, (POINTL *)NULL,
0x0000CCCC));
}
if ((Dest->iType == STYPE_DEVICE) && (Source->iType == STYPE_DEVICE)) {
SurfDest = (PDEVSURF) Dest->dhsurf;
SurfSource = (PDEVSURF) Source->dhsurf;
if (Clip == (CLIPOBJ *) NULL)
{
jClipping = DC_TRIVIAL;
}
else
{
jClipping = Clip->iDComplexity;
}
if (SourcePoint->y >= DestRect->top) {
if (SourcePoint->x >= DestRect->left) {
iCopyDir = CD_RIGHTDOWN;
} else {
iCopyDir = CD_LEFTDOWN;
}
} else {
if (SourcePoint->x >= DestRect->left) {
iCopyDir = CD_RIGHTUP;
} else {
iCopyDir = CD_LEFTUP;
}
}
switch(jClipping) {
case DC_TRIVIAL:
Screen2Screen(SurfDest, DestRect, SourcePoint, iCopyDir);
break;
case DC_RECT:
if (!VGADDIIntersectRect(&TempRect, DestRect,
&Clip->rclBounds))
{
return TRUE;
}
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
Screen2Screen(SurfDest, &TempRect, &TempPoint, iCopyDir);
break;
case DC_COMPLEX:
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES,
iCopyDir, ENUM_RECT_LIMIT);
do {
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG)sizeof(RectEnum),
(PVOID)&RectEnum);
PRect = RectEnum.arcl;
for (ircl = 0; ircl < RectEnum.c; ircl++, PRect++) {
VGADDIIntersectRect(PRect, PRect, DestRect);
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + PRect->left -
DestRect->left;
TempPoint.y = SourcePoint->y + PRect->top -
DestRect->top;
Screen2Screen(SurfDest, PRect, &TempPoint, iCopyDir);
}
} while(EnumMore);
break;
}
return TRUE;
}
// Device managed to standard bitmap
if ((Source->iType == STYPE_DEVBITMAP) && (Dest->iType == STYPE_BITMAP))
{
switch(Dest->iBitmapFormat)
{
case BMF_4BPP:
if (ColorTranslation == NULL)
{
// Make just enough of a fake DEVSURF for the dest so that
// the DFB to DIB code can work
TempDSurf.NextScan = Dest->lDelta;
TempDSurf.StartBmp = Dest->pvScan0;
if ((Clip == NULL) || (Clip->iDComplexity == DC_TRIVIAL))
{
ulWidth = DestRect->right - DestRect->left;
if (ulWidth <= MAX_SCAN_WIDTH)
{
DFB2DIB(&TempDSurf, (PDEVSURF) Source->dhsurf,
DestRect, SourcePoint);
} else {
TempRect.left = DestRect->left;
TempRect.right = DestRect->right;
TempRect.top = DestRect->top;
TempRect.bottom = DestRect->bottom;
// cut rect into slices MAX_SCAN_WIDTH wide
ulRight = TempRect.right; // save right edge
TempRect.right = TempRect.left+MAX_SCAN_WIDTH;
ulNumSlices = (ulWidth+MAX_SCAN_WIDTH-1) / MAX_SCAN_WIDTH;
for (x=0; x<ulNumSlices-1; x++)
{
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DFB2DIB(&TempDSurf, (PDEVSURF) Source->dhsurf,
&TempRect, &TempPoint);
TempRect.left = TempRect.right;
TempRect.right += MAX_SCAN_WIDTH;
}
TempRect.right = ulRight;
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DFB2DIB(&TempDSurf, (PDEVSURF) Source->dhsurf,
&TempRect, &TempPoint);
}
}
else if (Clip->iDComplexity == DC_RECT)
{
if (VGADDIIntersectRect(&TempRect, DestRect, &Clip->rclBounds))
{
ulWidth = TempRect.right - TempRect.left;
if (ulWidth <= MAX_SCAN_WIDTH)
{
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DFB2DIB(&TempDSurf, (PDEVSURF) Source->dhsurf,
&TempRect, &TempPoint);
} else {
// cut rect into slices MAX_SCAN_WIDTH wide
ulRight = TempRect.right; // save right edge
TempRect.right = TempRect.left+MAX_SCAN_WIDTH;
ulNumSlices = (ulWidth+MAX_SCAN_WIDTH-1) / MAX_SCAN_WIDTH;
for (x=0; x<ulNumSlices-1; x++)
{
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DFB2DIB(&TempDSurf, (PDEVSURF) Source->dhsurf,
&TempRect, &TempPoint);
TempRect.left = TempRect.right;
TempRect.right += MAX_SCAN_WIDTH;
}
TempRect.right = ulRight;
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DFB2DIB(&TempDSurf, (PDEVSURF) Source->dhsurf,
&TempRect, &TempPoint);
}
}
return(TRUE);
} else {
// DC_COMPLEX:
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES,
CD_ANY, ENUM_RECT_LIMIT);
do {
EnumMore = CLIPOBJ_bEnum(Clip,(ULONG) sizeof(RectEnum),
(PVOID) &RectEnum);
PRect = RectEnum.arcl;
for (ircl = 0; ircl < RectEnum.c; ircl++, PRect++)
{
VGADDIIntersectRect(PRect,PRect,DestRect);
ulWidth = PRect->right - PRect->left;
if (ulWidth <= MAX_SCAN_WIDTH)
{
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + PRect->left - DestRect->left;
TempPoint.y = SourcePoint->y + PRect->top - DestRect->top;
DFB2DIB(&TempDSurf, (PDEVSURF) Source->dhsurf,
&TempRect, &TempPoint);
} else {
// cut rect into slices MAX_SCAN_WIDTH wide
ulRight = PRect->right; // save right edge
PRect->right = PRect->left+MAX_SCAN_WIDTH;
ulNumSlices = (ulWidth+MAX_SCAN_WIDTH-1) / MAX_SCAN_WIDTH;
for (x=0; x<ulNumSlices-1; x++)
{
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + PRect->left - DestRect->left;
TempPoint.y = SourcePoint->y + PRect->top - DestRect->top;
DFB2DIB(&TempDSurf, (PDEVSURF) Source->dhsurf,
PRect, &TempPoint);
PRect->left = PRect->right;
PRect->right += MAX_SCAN_WIDTH;
}
PRect->right = ulRight;
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + PRect->left - DestRect->left;
TempPoint.y = SourcePoint->y + PRect->top - DestRect->top;
DFB2DIB(&TempDSurf, (PDEVSURF) Source->dhsurf,
PRect, &TempPoint);
}
}
} while(EnumMore);
}
return(TRUE);
}
break;
}
}
// Device managed to device managed
if ((Source->iType == STYPE_DEVBITMAP) && (Dest->iType == STYPE_DEVBITMAP)) {
if (Source==Dest)
{
TempRect.top = SourcePoint->y;
TempRect.left = SourcePoint->x;
TempRect.bottom = SourcePoint->y + (DestRect->bottom - DestRect->top);
TempRect.right = SourcePoint->x + (DestRect->right - DestRect->left);
if (DestRect->top >= SourcePoint->y)
{
if (VGADDIIntersectRect(&TempRect,&TempRect,DestRect))
{
return(VGADDIBitBlt(Dest, Source, (SURFOBJ *)NULL,
Clip, ColorTranslation,
DestRect, SourcePoint,
(POINTL *)NULL, (BRUSHOBJ *)NULL,
(POINTL *)NULL, 0x0000CCCC));
}
}
}
if (ColorTranslation == NULL)
{
if ((Clip == NULL) || (Clip->iDComplexity == DC_TRIVIAL))
{
DFB2DFB((PDEVSURF) Dest->dhsurf, (PDEVSURF) Source->dhsurf,
DestRect, SourcePoint);
} else if (Clip->iDComplexity == DC_RECT)
{
if (VGADDIIntersectRect(&TempRect, DestRect, &Clip->rclBounds))
{
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DFB2DFB((PDEVSURF) Dest->dhsurf, (PDEVSURF) Source->dhsurf,
&TempRect, &TempPoint);
}
return(TRUE);
} else {
// DC_COMPLEX:
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES,
CD_ANY, ENUM_RECT_LIMIT);
do {
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG)sizeof(RectEnum), (PVOID)&RectEnum);
PRect = RectEnum.arcl;
for (ircl = 0; ircl < RectEnum.c; ircl++, PRect++)
{
VGADDIIntersectRect(PRect,PRect,DestRect);
TempPoint.x = SourcePoint->x + PRect->left - DestRect->left;
TempPoint.y = SourcePoint->y + PRect->top - DestRect->top;
DFB2DFB((PDEVSURF)Dest->dhsurf, (PDEVSURF)Source->dhsurf,
PRect, &TempPoint);
}
} while(EnumMore);
}
return(TRUE);
}
}
// Device managed to screen
if((Source->iType == STYPE_DEVBITMAP) && (Dest->iType == STYPE_DEVICE))
{
if(ColorTranslation == NULL)
{
if ((Clip == NULL) || (Clip->iDComplexity == DC_TRIVIAL))
{
DFB2VGA((PDEVSURF) Dest->dhsurf, (PDEVSURF) Source->dhsurf, DestRect,
SourcePoint);
} else if (Clip->iDComplexity == DC_RECT)
{
if (VGADDIIntersectRect(&TempRect, DestRect, &Clip->rclBounds))
{
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DFB2VGA((PDEVSURF) Dest->dhsurf, (PDEVSURF) Source->dhsurf,
&TempRect, &TempPoint);
}
return(TRUE);
} else {
// DC_COMPLEX:
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_ANY, ENUM_RECT_LIMIT);
do {
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG)sizeof(RectEnum), (PVOID)&RectEnum);
PRect = RectEnum.arcl;
for (ircl = 0; ircl < RectEnum.c; ircl++, PRect++)
{
VGADDIIntersectRect(PRect,PRect,DestRect);
TempPoint.x = SourcePoint->x + PRect->left - DestRect->left;
TempPoint.y = SourcePoint->y + PRect->top - DestRect->top;
DFB2VGA((PDEVSURF)Dest->dhsurf, (PDEVSURF)Source->dhsurf,
PRect, &TempPoint);
}
} while(EnumMore);
}
return(TRUE);
}
}
// Standard bitmap to device managed
if ((Source->iType == STYPE_BITMAP) && (Dest->iType == STYPE_DEVBITMAP))
{
switch(Source->iBitmapFormat)
{
case BMF_4BPP:
if (ColorTranslation == NULL)
{
pucDIB4ToVGAConvTables =
((PDEVSURF) Dest->dhsurf)->ppdev->
pucDIB4ToVGAConvTables;
// Make just enough of a fake DEVSURF for the source so that
// the DIB to DFB code can work
TempDSurf.NextScan = Source->lDelta;
TempDSurf.StartBmp = Source->pvScan0;
// Clip as needed
if ((Clip == NULL) || (Clip->iDComplexity == DC_TRIVIAL))
{
ulWidth = DestRect->right - DestRect->left;
if (ulWidth <= MAX_SCAN_WIDTH)
{
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf, DestRect,
SourcePoint, pucDIB4ToVGAConvTables, DFB_TARGET);
} else {
TempRect.left = DestRect->left;
TempRect.right = DestRect->right;
TempRect.top = DestRect->top;
TempRect.bottom = DestRect->bottom;
// cut rect into slices MAX_SCAN_WIDTH wide
ulRight = TempRect.right; // save right edge
TempRect.right = TempRect.left+MAX_SCAN_WIDTH;
ulNumSlices = (ulWidth+MAX_SCAN_WIDTH-1) / MAX_SCAN_WIDTH;
for (x=0; x<ulNumSlices-1; x++)
{
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf,
&TempRect, &TempPoint, pucDIB4ToVGAConvTables, DFB_TARGET);
TempRect.left = TempRect.right;
TempRect.right += MAX_SCAN_WIDTH;
}
TempRect.right = ulRight;
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf,
&TempRect, &TempPoint, pucDIB4ToVGAConvTables, DFB_TARGET);
}
}
else if (Clip->iDComplexity == DC_RECT)
{
if (VGADDIIntersectRect(&TempRect, DestRect, &Clip->rclBounds))
{
ulWidth = TempRect.right - TempRect.left;
if (ulWidth <= MAX_SCAN_WIDTH)
{
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf,
&TempRect, &TempPoint, pucDIB4ToVGAConvTables, DFB_TARGET);
} else {
// cut rect into slices MAX_SCAN_WIDTH wide
ulRight = TempRect.right; // save right edge
TempRect.right = TempRect.left+MAX_SCAN_WIDTH;
ulNumSlices = (ulWidth+MAX_SCAN_WIDTH-1) / MAX_SCAN_WIDTH;
for (x=0; x<ulNumSlices-1; x++)
{
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf,
&TempRect, &TempPoint, pucDIB4ToVGAConvTables, DFB_TARGET);
TempRect.left = TempRect.right;
TempRect.right += MAX_SCAN_WIDTH;
}
TempRect.right = ulRight;
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf,
&TempRect, &TempPoint, pucDIB4ToVGAConvTables, DFB_TARGET);
}
}
return(TRUE);
} else {
// DC_COMPLEX:
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES,
CD_ANY, ENUM_RECT_LIMIT);
do {
EnumMore = CLIPOBJ_bEnum(Clip,(ULONG) sizeof(RectEnum),
(PVOID) &RectEnum);
PRect = RectEnum.arcl;
for (ircl = 0; ircl < RectEnum.c; ircl++, PRect++)
{
VGADDIIntersectRect(PRect,PRect,DestRect);
ulWidth = PRect->right - PRect->left;
if (ulWidth <= MAX_SCAN_WIDTH)
{
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + PRect->left - DestRect->left;
TempPoint.y = SourcePoint->y + PRect->top - DestRect->top;
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf,
PRect, &TempPoint, pucDIB4ToVGAConvTables, DFB_TARGET);
} else {
// cut rect into slices MAX_SCAN_WIDTH wide
ulRight = PRect->right; // save right edge
PRect->right = PRect->left+MAX_SCAN_WIDTH;
ulNumSlices = (ulWidth+MAX_SCAN_WIDTH-1) / MAX_SCAN_WIDTH;
for (x=0; x<ulNumSlices-1; x++)
{
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + PRect->left - DestRect->left;
TempPoint.y = SourcePoint->y + PRect->top - DestRect->top;
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf,
PRect, &TempPoint, pucDIB4ToVGAConvTables, DFB_TARGET);
PRect->left = PRect->right;
PRect->right += MAX_SCAN_WIDTH;
}
PRect->right = ulRight;
// Adjust the source point for clipping too
TempPoint.x = SourcePoint->x + PRect->left - DestRect->left;
TempPoint.y = SourcePoint->y + PRect->top - DestRect->top;
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf,
PRect, &TempPoint, pucDIB4ToVGAConvTables, DFB_TARGET);
}
}
} while(EnumMore);
}
return(TRUE);
}
break;
case BMF_1BPP:
case BMF_8BPP:
return(VGADDIBitBlt(Dest, Source, (SURFOBJ *)NULL,
Clip, ColorTranslation,
DestRect, SourcePoint,
(POINTL *)NULL, (BRUSHOBJ *)NULL, (POINTL *)NULL,
0x0000CCCC));
}
}
// Standard bitmap to screen
if ((Source->iType == STYPE_BITMAP) && (Dest->iType == STYPE_DEVICE))
{
switch(Source->iBitmapFormat)
{
case BMF_4BPP:
if (ColorTranslation == NULL)
{
pucDIB4ToVGAConvTables =
((PDEVSURF) Dest->dhsurf)->ppdev->
pucDIB4ToVGAConvTables;
// Make just enough of a fake DEVSURF for the source so that
// the DIB to VGA code can work
TempDSurf.NextScan = Source->lDelta;
TempDSurf.StartBmp = Source->pvScan0;
// Clip as needed
if ((Clip == NULL) || (Clip->iDComplexity == DC_TRIVIAL))
{
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf, DestRect,
SourcePoint, pucDIB4ToVGAConvTables, VGA_TARGET);
} else if (Clip->iDComplexity == DC_RECT)
{
if (VGADDIIntersectRect(&TempRect, DestRect, &Clip->rclBounds))
{
TempPoint.x = SourcePoint->x + TempRect.left - DestRect->left;
TempPoint.y = SourcePoint->y + TempRect.top - DestRect->top;
DIB2VGA((PDEVSURF) Dest->dhsurf, &TempDSurf,
&TempRect, &TempPoint, pucDIB4ToVGAConvTables, VGA_TARGET);
}
return(TRUE);
} else {
// DC_COMPLEX:
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES,
CD_ANY, ENUM_RECT_LIMIT);
do {
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG)sizeof(RectEnum), (PVOID)&RectEnum);
PRect = RectEnum.arcl;
for (ircl = 0; ircl < RectEnum.c; ircl++, PRect++)
{
VGADDIIntersectRect(PRect,PRect,DestRect);
TempPoint.x = SourcePoint->x + PRect->left - DestRect->left;
TempPoint.y = SourcePoint->y + PRect->top - DestRect->top;
DIB2VGA((PDEVSURF) Dest->dhsurf,
&TempDSurf, PRect, &TempPoint,
pucDIB4ToVGAConvTables, VGA_TARGET);
}
} while(EnumMore);
}
return(TRUE);
}
break;
case BMF_1BPP:
case BMF_8BPP:
return(VGADDIBitBlt(Dest, Source, (SURFOBJ *)NULL,
Clip, ColorTranslation,
DestRect, SourcePoint,
(POINTL *)NULL, (BRUSHOBJ *)NULL, (POINTL *)NULL,
0x0000CCCC));
case BMF_8RLE:
case BMF_4RLE:
// return(RleBlt(Dest, Source, Clip, ColorTranslation, DestRect, SourcePoint));
}
}
// Screen to standard bitmap
if ((Source->iType == STYPE_DEVICE) && (Dest->iType == STYPE_BITMAP))
{
if (Dest->iBitmapFormat == BMF_4BPP)
{
// pdsurf = (PDEVSURF) Source->dhsurf;
// Get the data for the destination DIB
lDelta = Dest->lDelta;
pjDstScan0 = (PBYTE) Dest->pvScan0;
// Setup for any color translation which may be needed !!! Is any needed at all?
if (ColorTranslation == NULL)
{
pulXlate = NULL;
}
else
{
if (ColorTranslation->flXlate & XO_TABLE)
{
pulXlate = ColorTranslation->pulXlate;
} else {
pulXlate = (PULONG) NULL;
}
}
if (Clip != (CLIPOBJ *) NULL)
{
switch(Clip->iDComplexity)
{
case DC_TRIVIAL:
EnumMore = FALSE;
cben.c = 1;
cben.arcl[0] = *DestRect;
break;
case DC_RECT:
EnumMore = FALSE;
cben.c = 1;
cben.arcl[0] = Clip->rclBounds;
break;
case DC_COMPLEX:
EnumMore = TRUE;
cben.c = 0;
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_ANY, ENUM_RECT_LIMIT);
break;
}
}
else
{
EnumMore = FALSE;
cben.c = 1;
cben.arcl[0] = *DestRect; // Use the target for clipping
}
// Call the VGA conversion routine, adjusted for each rectangle
do
{
LONG xSrc;
LONG ySrc;
RECTL *PRect;
if (EnumMore)
EnumMore = CLIPOBJ_bEnum(Clip,(ULONG) sizeof(cben), (PVOID) &cben);
for (ircl = 0; ircl < cben.c; ircl++)
{
PRect = &cben.arcl[ircl];
xSrc = SourcePoint->x + PRect->left - DestRect->left;
ySrc = SourcePoint->y + PRect->top - DestRect->top;
VGAtoGDI(Dest, Source, NULL, ColorTranslation, DestRect, SourcePoint);
/* VGA2DIB(pdsurf, xSrc, ySrc, pjDstScan0,
PRect->left, PRect->top, PRect->right - PRect->left,
PRect->bottom - PRect->top,
lDelta, Dest->iBitmapFormat, pulXlate); */
}
} while (EnumMore);
return(TRUE);
}
}
// If unsupported
return(SimCopyBits(Dest, Source, Clip, ColorTranslation, DestRect, SourcePoint));
}
BOOL SimCopyBits(SURFOBJ *Dest, SURFOBJ *Source,
CLIPOBJ *Clip, XLATEOBJ *ColorTranslation,
PRECTL DestRect, PPOINTL SourcePoint)
{
HBITMAP hbmTmp;
SURFOBJ *psoTmp;
RECTL rclTmp;
SIZEL sizlTmp;
BOOL bReturn = FALSE;
POINTL ptl00 = {0,0};
rclTmp.top = rclTmp.left = 0;
rclTmp.right = sizlTmp.cx = DestRect->right - DestRect->left;
rclTmp.bottom = sizlTmp.cy = DestRect->bottom - DestRect->top;
// Create bitmap in our compatible format
hbmTmp = EngCreateBitmap(sizlTmp, sizlTmp.cx * 1, BMF_4BPP, 0, NULL); // FIXME: Replace *1 with *BPP?
if (hbmTmp)
{
if ((psoTmp = EngLockSurface((HSURF)hbmTmp)) != NULL)
{
if (((Source->iType == STYPE_BITMAP) && (Dest->iType == STYPE_DEVICE)) ||
((Source->iType == STYPE_BITMAP) && (Dest->iType == STYPE_DEVBITMAP)))
{
// DIB to VGA or DIB to DFB
if (EngCopyBits(psoTmp, Source, NULL, ColorTranslation, &rclTmp, SourcePoint))
{
bReturn = VGADDICopyBits(Dest, psoTmp, Clip, NULL, DestRect, &ptl00);
}
}
else if (((Source->iType == STYPE_DEVICE) && (Dest->iType == STYPE_BITMAP)) ||
((Source->iType == STYPE_DEVBITMAP) && (Dest->iType == STYPE_BITMAP)))
{
// VGA to DIB or DFB to DIB
if (VGADDICopyBits(psoTmp, Source, NULL, NULL, &rclTmp, SourcePoint))
{
bReturn = EngCopyBits(Dest, psoTmp, Clip, ColorTranslation, DestRect, &ptl00);
}
}
else if (((Source->iType == STYPE_DEVICE) || (Source->iType == STYPE_DEVBITMAP)) &&
((Dest->iType == STYPE_DEVICE) || (Dest->iType == STYPE_DEVBITMAP)))
{
// VGA or DFB to VGA or DFB
if (VGADDICopyBits(psoTmp, Source, NULL, NULL, &rclTmp, SourcePoint))
{
bReturn = VGADDICopyBits(Dest, psoTmp, Clip, ColorTranslation, DestRect, &ptl00);
}
}
EngUnlockSurface(psoTmp);
}
EngDeleteSurface((HSURF)hbmTmp);
}
return(bReturn);
}

View file

@ -0,0 +1,121 @@
#include "../vgaddi.h"
ULONG oldx, oldy;
PUCHAR behindCursor;
void vgaHideCursor(PPDEV ppdev);
void vgaShowCursor(PPDEV ppdev);
BOOL InitPointer(PPDEV ppdev)
{
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
// 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;
// Allocate memory for the pixels behind the cursor
behindCursor = EngAllocMem(0, ppdev->pPointerAttributes->WidthInBytes * ppdev->pPointerAttributes->Height, ALLOC_TAG);
return TRUE;
}
VOID VGADDIMovePointer(PSURFOBJ pso, LONG x, LONG y, PRECTL prcl)
{
PPDEV ppdev = (PPDEV)pso->dhpdev;
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;
vgaShowCursor(ppdev);
// 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;
// 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);
// Set the new cursor position
ppdev->xyCursor.x = x;
ppdev->xyCursor.y = y;
// Show the cursor
vgaShowCursor(ppdev);
}
void vgaHideCursor(PPDEV ppdev)
{
ULONG i, j, cx, cy, bitpos;
// Display what was behind cursor
BltToVGA(oldx, oldx, oldy,
ppdev->pPointerAttributes->Width-1,
ppdev->pPointerAttributes->Height-1,
behindCursor);
oldx = ppdev->xyCursor.x;
oldy = ppdev->xyCursor.y;
ppdev->pPointerAttributes->Enable = 0;
}
void vgaShowCursor(PPDEV ppdev)
{
ULONG i, j, cx, cy, bitpos;
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++;
}
// Display the cursor
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;
}

View file

@ -130,6 +130,34 @@ VOID vgaPreCalc()
}
}
static void
get_masks(int x, int w)
{
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;
}
VOID vgaPutPixel(INT x, INT y, UCHAR c)
{
ULONG offset;
@ -332,33 +360,128 @@ BOOL VGADDIIntersectRect(PRECTL prcDst, PRECTL prcSrc1, PRECTL prcSrc2)
return FALSE;
}
/*
BOOL bltToVga(INT x1, INT y1, INT dx, INT dy, UCHAR *bitmap)
void BltFromVGA(int x, int y, int w, int h, void *b, int bw)
{
// We use vertical stripes because we save some time by setting the mask less often
// Prototype code, to be implemented in bitblt.c
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;
ULONG offset, i;
UCHAR a, *initial;
ASSIGNVP4(x, y, vpP)
ASSIGNMK4(x, y, maskP)
get_masks(x, w);
outb(GRA_I, 0x05); /* read mode 0 */
saved_GC_mode = inb(GRA_D);
outb(GRA_D, 0x00);
outb(GRA_I, 0x04); /* read map select */
saved_GC_rmap = inb(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) {
outb(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);
for(j=x; j<x+dx; j++)
{
offset = xconv[x]+y80[y];
WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // set the mask
WRITE_PORT_UCHAR((PUCHAR)0x3cf,maskbit[x]);
initial = bitmap;
for(i=y; i<y+dy; i++)
{
a = READ_REGISTER_UCHAR(vidmem + offset);
WRITE_REGISTER_UCHAR(vidmem + offset, *bitmap);
offset+=80;
bitmap+=dx;
}
bitmap = initial + dx;
}
return TRUE;
}
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 */
outb(GRA_D, saved_GC_rmap);
outb(GRA_I, 0x05);
outb(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;
outb(GRA_I, 0x05); /* write mode 2 */
saved_GC_mode = inb(GRA_D);
outb(GRA_D, 0x02);
outb(GRA_I, 0x03); /* replace */
saved_GC_fun = inb(GRA_D);
outb(GRA_D, 0x00);
outb(GRA_I, 0x08); /* bit mask */
saved_GC_mask = inb(GRA_D);
for (i=w; i>0; i--) {
outb(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 */
outb(GRA_D, saved_GC_mask);
outb(GRA_I, 0x03);
outb(GRA_D, saved_GC_fun);
outb(GRA_I, 0x05);
outb(GRA_D, saved_GC_mode);
}
*/

View file

@ -1,3 +1,7 @@
// FIXME: Make these variables so we can also use modes like 800x600
#define SCREEN_X 640
#define SCREEN_Y 480
#define VGA_NORMAL 0
#define VGA_AND 8
#define VGA_OR 16
@ -38,3 +42,25 @@ BOOL vgaHLine(INT x, INT y, INT len, UCHAR c);
BOOL vgaVLine(INT x, INT y, INT len, UCHAR c);
INT abs(INT nm);
BOOL VGADDIIntersectRect(PRECTL prcDst, PRECTL prcSrc1, PRECTL prcSrc2);
#define SEQ_I 0x3C4 /* Sequencer Index */
#define SEQ_D 0x3C5 /* Sequencer Data Register */
#define GRA_I 0x3CE /* Graphics Controller Index */
#define GRA_D 0x3CF /* Graphics Controller Data Register */
#define LowByte(w) (*((unsigned char *)&(w) + 0))
#define HighByte(w) (*((unsigned char *)&(w) + 1))
#define ASSIGNVP4(x, y, vp) vp = vidmem /* VBUF */ + (((x) + (y)*SCREEN_X) >> 3);
#define ASSIGNMK4(x, y, mask) mask = 0x80 >> ((x) & 7);
static unsigned char saved_SEQ_mask; /* 0x02 */
static unsigned char saved_GC_eSR; /* 0x01 */
static unsigned char saved_GC_fun; /* 0x03 */
static unsigned char saved_GC_rmap; /* 0x04 */
static unsigned char saved_GC_mode; /* 0x05 */
static unsigned char saved_GC_mask; /* 0x08 */
static unsigned char leftMask;
static int byteCounter;
static unsigned char rightMask;