mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 09:00:27 +00:00
[BOOTVID] Code style fixes; Replace some 'do-while' loops by 'for' loops when it makes the code simpler.
+ Fix a potential bug in BitBlt() "4bpp blitting" in case Top == Bottom (i.e. Height == 0).
This commit is contained in:
parent
1d2b0fbcd1
commit
4f76cffb59
2 changed files with 98 additions and 154 deletions
|
@ -66,42 +66,33 @@ VGA_COLOR VidpVga8To16BitTransform[16] =
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS *********************************************************/
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
USHORT
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
|
USHORT
|
||||||
VidpBuildColor(IN UCHAR Color)
|
VidpBuildColor(IN UCHAR Color)
|
||||||
{
|
{
|
||||||
UCHAR Red, Green, Blue;
|
UCHAR Red, Green, Blue;
|
||||||
|
|
||||||
//
|
/* Extract color components */
|
||||||
// Extract color components
|
|
||||||
//
|
|
||||||
Red = VidpVga8To16BitTransform[Color].Red;
|
Red = VidpVga8To16BitTransform[Color].Red;
|
||||||
Green = VidpVga8To16BitTransform[Color].Green;
|
Green = VidpVga8To16BitTransform[Color].Green;
|
||||||
Blue = VidpVga8To16BitTransform[Color].Blue;
|
Blue = VidpVga8To16BitTransform[Color].Blue;
|
||||||
|
|
||||||
//
|
/* Build the 16-bit color mask */
|
||||||
// Build the 16-bit color mask
|
|
||||||
//
|
|
||||||
return ((Red & 0x1F) << 11) | ((Green & 0x1F) << 6) | ((Blue & 0x1F));
|
return ((Red & 0x1F) << 11) | ((Green & 0x1F) << 6) | ((Blue & 0x1F));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
|
VOID
|
||||||
VidpSetPixel(IN ULONG Left,
|
VidpSetPixel(IN ULONG Left,
|
||||||
IN ULONG Top,
|
IN ULONG Top,
|
||||||
IN UCHAR Color)
|
IN UCHAR Color)
|
||||||
{
|
{
|
||||||
PUSHORT PixelPosition;
|
PUSHORT PixelPosition;
|
||||||
|
|
||||||
//
|
/* Calculate the pixel position */
|
||||||
// Calculate the pixel position
|
|
||||||
//
|
|
||||||
PixelPosition = &VgaArmBase[Left + (Top * SCREEN_WIDTH)];
|
PixelPosition = &VgaArmBase[Left + (Top * SCREEN_WIDTH)];
|
||||||
|
|
||||||
//
|
/* Set our color */
|
||||||
// Set our color
|
|
||||||
//
|
|
||||||
WRITE_REGISTER_USHORT(PixelPosition, VidpBuildColor(Color));
|
WRITE_REGISTER_USHORT(PixelPosition, VidpBuildColor(Color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +102,7 @@ DisplayCharacter(IN CHAR Character,
|
||||||
IN ULONG Left,
|
IN ULONG Left,
|
||||||
IN ULONG Top,
|
IN ULONG Top,
|
||||||
IN ULONG TextColor,
|
IN ULONG TextColor,
|
||||||
IN ULONG BackTextColor)
|
IN ULONG BackColor)
|
||||||
{
|
{
|
||||||
PUCHAR FontChar;
|
PUCHAR FontChar;
|
||||||
ULONG i, j, XOffset;
|
ULONG i, j, XOffset;
|
||||||
|
@ -120,13 +111,11 @@ DisplayCharacter(IN CHAR Character,
|
||||||
FontChar = &FontData[Character * BOOTCHAR_HEIGHT - Top];
|
FontChar = &FontData[Character * BOOTCHAR_HEIGHT - Top];
|
||||||
|
|
||||||
/* Loop each pixel height */
|
/* Loop each pixel height */
|
||||||
i = BOOTCHAR_HEIGHT;
|
for (i = BOOTCHAR_HEIGHT; i > 0; --i)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
/* Loop each pixel width */
|
/* Loop each pixel width */
|
||||||
j = 128;
|
|
||||||
XOffset = Left;
|
XOffset = Left;
|
||||||
do
|
for (j = (1 << 7); j > 0; j >>= 1)
|
||||||
{
|
{
|
||||||
/* Check if we should draw this pixel */
|
/* Check if we should draw this pixel */
|
||||||
if (FontChar[Top] & (UCHAR)j)
|
if (FontChar[Top] & (UCHAR)j)
|
||||||
|
@ -134,20 +123,22 @@ DisplayCharacter(IN CHAR Character,
|
||||||
/* We do, use the given Text Color */
|
/* We do, use the given Text Color */
|
||||||
VidpSetPixel(XOffset, Top, (UCHAR)TextColor);
|
VidpSetPixel(XOffset, Top, (UCHAR)TextColor);
|
||||||
}
|
}
|
||||||
else if (BackTextColor < 16)
|
else if (BackColor < 16)
|
||||||
{
|
{
|
||||||
/* This is a background pixel. We're drawing it unless it's */
|
/*
|
||||||
/* transparent. */
|
* This is a background pixel. We're drawing it
|
||||||
VidpSetPixel(XOffset, Top, (UCHAR)BackTextColor);
|
* unless it's transparent.
|
||||||
|
*/
|
||||||
|
VidpSetPixel(XOffset, Top, (UCHAR)BackColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increase X Offset */
|
/* Increase X Offset */
|
||||||
XOffset++;
|
XOffset++;
|
||||||
} while (j >>= 1);
|
}
|
||||||
|
|
||||||
/* Move to the next Y ordinate */
|
/* Move to the next Y ordinate */
|
||||||
Top++;
|
Top++;
|
||||||
} while (--i);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -162,12 +153,8 @@ VgaScroll(IN ULONG Scroll)
|
||||||
SourceOffset = &VgaArmBase[(VidpScrollRegion[1] * (SCREEN_WIDTH / 8)) + (VidpScrollRegion[0] >> 3)];
|
SourceOffset = &VgaArmBase[(VidpScrollRegion[1] * (SCREEN_WIDTH / 8)) + (VidpScrollRegion[0] >> 3)];
|
||||||
DestOffset = &SourceOffset[Scroll * (SCREEN_WIDTH / 8)];
|
DestOffset = &SourceOffset[Scroll * (SCREEN_WIDTH / 8)];
|
||||||
|
|
||||||
/* Save top and check if it's above the bottom */
|
|
||||||
Top = VidpScrollRegion[1];
|
|
||||||
if (Top > VidpScrollRegion[3]) return;
|
|
||||||
|
|
||||||
/* Start loop */
|
/* Start loop */
|
||||||
do
|
for (Top = VidpScrollRegion[1]; Top <= VidpScrollRegion[3]; ++Top)
|
||||||
{
|
{
|
||||||
/* Set number of bytes to loop and start offset */
|
/* Set number of bytes to loop and start offset */
|
||||||
Offset = VidpScrollRegion[0] >> 3;
|
Offset = VidpScrollRegion[0] >> 3;
|
||||||
|
@ -198,12 +185,7 @@ VgaScroll(IN ULONG Scroll)
|
||||||
/* Move to the next line */
|
/* Move to the next line */
|
||||||
SourceOffset += (SCREEN_WIDTH / 8);
|
SourceOffset += (SCREEN_WIDTH / 8);
|
||||||
DestOffset += (SCREEN_WIDTH / 8);
|
DestOffset += (SCREEN_WIDTH / 8);
|
||||||
|
}
|
||||||
/* Increase top */
|
|
||||||
Top++;
|
|
||||||
|
|
||||||
/* Make sure we don't go past the scroll region */
|
|
||||||
} while (Top <= VidpScrollRegion[3]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -216,15 +198,14 @@ PreserveRow(IN ULONG CurrentTop,
|
||||||
ULONG Count;
|
ULONG Count;
|
||||||
|
|
||||||
/* Check which way we're preserving */
|
/* Check which way we're preserving */
|
||||||
|
/* Calculate the position in memory for the row */
|
||||||
if (Direction)
|
if (Direction)
|
||||||
{
|
{
|
||||||
/* Calculate the position in memory for the row */
|
|
||||||
Position1 = &VgaArmBase[CurrentTop * (SCREEN_WIDTH / 8)];
|
Position1 = &VgaArmBase[CurrentTop * (SCREEN_WIDTH / 8)];
|
||||||
Position2 = &VgaArmBase[SCREEN_HEIGHT * (SCREEN_WIDTH / 8)];
|
Position2 = &VgaArmBase[SCREEN_HEIGHT * (SCREEN_WIDTH / 8)];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Calculate the position in memory for the row */
|
|
||||||
Position1 = &VgaArmBase[SCREEN_HEIGHT * (SCREEN_WIDTH / 8)];
|
Position1 = &VgaArmBase[SCREEN_HEIGHT * (SCREEN_WIDTH / 8)];
|
||||||
Position2 = &VgaArmBase[CurrentTop * (SCREEN_WIDTH / 8)];
|
Position2 = &VgaArmBase[CurrentTop * (SCREEN_WIDTH / 8)];
|
||||||
}
|
}
|
||||||
|
@ -427,7 +408,7 @@ VidDisplayString(IN PUCHAR String)
|
||||||
ULONG TopDelta = BOOTCHAR_HEIGHT + 1;
|
ULONG TopDelta = BOOTCHAR_HEIGHT + 1;
|
||||||
|
|
||||||
/* Start looping the string */
|
/* Start looping the string */
|
||||||
while (*String)
|
for (; *String; ++String)
|
||||||
{
|
{
|
||||||
/* Treat new-line separately */
|
/* Treat new-line separately */
|
||||||
if (*String == '\n')
|
if (*String == '\n')
|
||||||
|
@ -495,9 +476,6 @@ VidDisplayString(IN PUCHAR String)
|
||||||
VidpCurrentX = VidpScrollRegion[0];
|
VidpCurrentX = VidpScrollRegion[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the next character */
|
|
||||||
String++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,13 @@ static UCHAR lMaskTable[8] =
|
||||||
static UCHAR rMaskTable[8] =
|
static UCHAR rMaskTable[8] =
|
||||||
{
|
{
|
||||||
(1 << 7),
|
(1 << 7),
|
||||||
(1 << 7)+ (1 << 6),
|
(1 << 7) + (1 << 6),
|
||||||
(1 << 7)+ (1 << 6) + (1 << 5),
|
(1 << 7) + (1 << 6) + (1 << 5),
|
||||||
(1 << 7)+ (1 << 6) + (1 << 5) + (1 << 4),
|
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4),
|
||||||
(1 << 7)+ (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3),
|
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3),
|
||||||
(1 << 7)+ (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2),
|
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2),
|
||||||
(1 << 7)+ (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2) + (1 << 1),
|
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2) + (1 << 1),
|
||||||
(1 << 7)+ (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2) + (1 << 1) +
|
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2) + (1 << 1) + (1 << 0),
|
||||||
(1 << 0),
|
|
||||||
};
|
};
|
||||||
UCHAR PixelMask[8] =
|
UCHAR PixelMask[8] =
|
||||||
{
|
{
|
||||||
|
@ -96,15 +95,14 @@ SetPixel(IN ULONG Left,
|
||||||
{
|
{
|
||||||
PUCHAR PixelPosition;
|
PUCHAR PixelPosition;
|
||||||
|
|
||||||
/* Calculate the pixel position. */
|
/* Calculate the pixel position */
|
||||||
PixelPosition = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)));
|
PixelPosition = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)));
|
||||||
|
|
||||||
/* Select the bitmask register and write the mask */
|
/* Select the bitmask register and write the mask */
|
||||||
__outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, (PixelMask[Left & 7] << 8) | IND_BIT_MASK);
|
__outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, (PixelMask[Left & 7] << 8) | IND_BIT_MASK);
|
||||||
|
|
||||||
/* Read the current pixel value and add our color */
|
/* Read the current pixel value and add our color */
|
||||||
WRITE_REGISTER_UCHAR(PixelPosition,
|
WRITE_REGISTER_UCHAR(PixelPosition, READ_REGISTER_UCHAR(PixelPosition) & Color);
|
||||||
READ_REGISTER_UCHAR(PixelPosition) & Color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SET_PIXELS(_PixelPtr, _PixelMask, _TextColor) \
|
#define SET_PIXELS(_PixelPtr, _PixelMask, _TextColor) \
|
||||||
|
@ -152,13 +150,12 @@ DisplayCharacter(IN CHAR Character,
|
||||||
PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)));
|
PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)));
|
||||||
|
|
||||||
/* Loop all pixel rows */
|
/* Loop all pixel rows */
|
||||||
Height = BOOTCHAR_HEIGHT;
|
for (Height = BOOTCHAR_HEIGHT; Height > 0; --Height)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
SET_PIXELS(PixelPtr, *FontChar >> Shift, TextColor);
|
SET_PIXELS(PixelPtr, *FontChar >> Shift, TextColor);
|
||||||
PixelPtr += (SCREEN_WIDTH / 8);
|
PixelPtr += (SCREEN_WIDTH / 8);
|
||||||
FontChar += FONT_PTR_DELTA;
|
FontChar += FONT_PTR_DELTA;
|
||||||
} while (--Height);
|
}
|
||||||
|
|
||||||
/* Check if we need to update neighbor bytes */
|
/* Check if we need to update neighbor bytes */
|
||||||
if (Shift)
|
if (Shift)
|
||||||
|
@ -171,13 +168,12 @@ DisplayCharacter(IN CHAR Character,
|
||||||
PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)) + 1);
|
PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)) + 1);
|
||||||
|
|
||||||
/* Loop all pixel rows */
|
/* Loop all pixel rows */
|
||||||
Height = BOOTCHAR_HEIGHT;
|
for (Height = BOOTCHAR_HEIGHT; Height > 0; --Height)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
SET_PIXELS(PixelPtr, *FontChar << Shift, TextColor);
|
SET_PIXELS(PixelPtr, *FontChar << Shift, TextColor);
|
||||||
PixelPtr += (SCREEN_WIDTH / 8);
|
PixelPtr += (SCREEN_WIDTH / 8);
|
||||||
FontChar += FONT_PTR_DELTA;
|
FontChar += FONT_PTR_DELTA;
|
||||||
} while (--Height);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the background color is transparent */
|
/* Check if the background color is transparent */
|
||||||
|
@ -195,13 +191,12 @@ DisplayCharacter(IN CHAR Character,
|
||||||
PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)));
|
PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)));
|
||||||
|
|
||||||
/* Loop all pixel rows */
|
/* Loop all pixel rows */
|
||||||
Height = BOOTCHAR_HEIGHT;
|
for (Height = BOOTCHAR_HEIGHT; Height > 0; --Height)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
SET_PIXELS(PixelPtr, ~*FontChar >> Shift, BackColor);
|
SET_PIXELS(PixelPtr, ~*FontChar >> Shift, BackColor);
|
||||||
PixelPtr += (SCREEN_WIDTH / 8);
|
PixelPtr += (SCREEN_WIDTH / 8);
|
||||||
FontChar += FONT_PTR_DELTA;
|
FontChar += FONT_PTR_DELTA;
|
||||||
} while (--Height);
|
}
|
||||||
|
|
||||||
/* Check if we need to update neighbor bytes */
|
/* Check if we need to update neighbor bytes */
|
||||||
if (Shift)
|
if (Shift)
|
||||||
|
@ -214,13 +209,12 @@ DisplayCharacter(IN CHAR Character,
|
||||||
PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)) + 1);
|
PixelPtr = (PUCHAR)(VgaBase + (Left >> 3) + (Top * (SCREEN_WIDTH / 8)) + 1);
|
||||||
|
|
||||||
/* Loop all pixel rows */
|
/* Loop all pixel rows */
|
||||||
Height = BOOTCHAR_HEIGHT;
|
for (Height = BOOTCHAR_HEIGHT; Height > 0; --Height)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
SET_PIXELS(PixelPtr, ~*FontChar << Shift, BackColor);
|
SET_PIXELS(PixelPtr, ~*FontChar << Shift, BackColor);
|
||||||
PixelPtr += (SCREEN_WIDTH / 8);
|
PixelPtr += (SCREEN_WIDTH / 8);
|
||||||
FontChar += FONT_PTR_DELTA;
|
FontChar += FONT_PTR_DELTA;
|
||||||
} while (--Height);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,15 +226,11 @@ DisplayStringXY(IN PUCHAR String,
|
||||||
IN ULONG TextColor,
|
IN ULONG TextColor,
|
||||||
IN ULONG BackColor)
|
IN ULONG BackColor)
|
||||||
{
|
{
|
||||||
/* Loop every character */
|
/* Loop every character and adjust the position */
|
||||||
while (*String)
|
for (; *String; ++String, Left += 8)
|
||||||
{
|
{
|
||||||
/* Display a character */
|
/* Display a character */
|
||||||
DisplayCharacter(*String, Left, Top, TextColor, BackColor);
|
DisplayCharacter(*String, Left, Top, TextColor, BackColor);
|
||||||
|
|
||||||
/* Move to next character and next position */
|
|
||||||
String++;
|
|
||||||
Left += 8;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,15 +364,14 @@ PreserveRow(IN ULONG CurrentTop,
|
||||||
ReadWriteMode(1);
|
ReadWriteMode(1);
|
||||||
|
|
||||||
/* Check which way we're preserving */
|
/* Check which way we're preserving */
|
||||||
|
/* Calculate the position in memory for the row */
|
||||||
if (Direction)
|
if (Direction)
|
||||||
{
|
{
|
||||||
/* Calculate the position in memory for the row */
|
|
||||||
Position1 = (PUCHAR)(VgaBase + CurrentTop * (SCREEN_WIDTH / 8));
|
Position1 = (PUCHAR)(VgaBase + CurrentTop * (SCREEN_WIDTH / 8));
|
||||||
Position2 = (PUCHAR)(VgaBase + SCREEN_HEIGHT * (SCREEN_WIDTH / 8));
|
Position2 = (PUCHAR)(VgaBase + SCREEN_HEIGHT * (SCREEN_WIDTH / 8));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Calculate the position in memory for the row */
|
|
||||||
Position1 = (PUCHAR)(VgaBase + SCREEN_HEIGHT * (SCREEN_WIDTH / 8));
|
Position1 = (PUCHAR)(VgaBase + SCREEN_HEIGHT * (SCREEN_WIDTH / 8));
|
||||||
Position2 = (PUCHAR)(VgaBase + CurrentTop * (SCREEN_WIDTH / 8));
|
Position2 = (PUCHAR)(VgaBase + CurrentTop * (SCREEN_WIDTH / 8));
|
||||||
}
|
}
|
||||||
|
@ -448,8 +437,7 @@ BitBlt(IN ULONG Left,
|
||||||
__outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, 7);
|
__outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, 7);
|
||||||
|
|
||||||
/* 4bpp blitting */
|
/* 4bpp blitting */
|
||||||
dy = Top;
|
for (dy = Top; dy < Bottom; ++dy)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
sx = 0;
|
sx = 0;
|
||||||
do
|
do
|
||||||
|
@ -467,8 +455,7 @@ BitBlt(IN ULONG Left,
|
||||||
sx++;
|
sx++;
|
||||||
} while (dx < Right);
|
} while (dx < Right);
|
||||||
offset += Delta;
|
offset += Delta;
|
||||||
dy++;
|
}
|
||||||
} while (dy < Bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
|
@ -536,8 +523,7 @@ RleBitBlt(IN ULONG Left,
|
||||||
if (RleValue > 1)
|
if (RleValue > 1)
|
||||||
{
|
{
|
||||||
/* Set loop variables */
|
/* Set loop variables */
|
||||||
i = (RleValue - 2) / 2 + 1;
|
for (i = (RleValue - 2) / 2 + 1; i > 0; --i)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
/* Set the pixels */
|
/* Set the pixels */
|
||||||
SetPixel(x, YDelta, (UCHAR)Color);
|
SetPixel(x, YDelta, (UCHAR)Color);
|
||||||
|
@ -547,7 +533,7 @@ RleBitBlt(IN ULONG Left,
|
||||||
|
|
||||||
/* Decrease pixel value */
|
/* Decrease pixel value */
|
||||||
RleValue -= 2;
|
RleValue -= 2;
|
||||||
} while (--i);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if there is any value at all */
|
/* Check if there is any value at all */
|
||||||
|
@ -623,8 +609,7 @@ RleBitBlt(IN ULONG Left,
|
||||||
if (RleValue > 1)
|
if (RleValue > 1)
|
||||||
{
|
{
|
||||||
/* Set loop variables */
|
/* Set loop variables */
|
||||||
j = (RleValue - 2) / 2 + 1;
|
for (j = (RleValue - 2) / 2 + 1; j > 0; --j)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
/* Get the new value */
|
/* Get the new value */
|
||||||
NewRleValue = *Buffer;
|
NewRleValue = *Buffer;
|
||||||
|
@ -644,7 +629,7 @@ RleBitBlt(IN ULONG Left,
|
||||||
|
|
||||||
/* Decrease pixel value */
|
/* Decrease pixel value */
|
||||||
RleValue -= 2;
|
RleValue -= 2;
|
||||||
} while (--j);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if there is any value at all */
|
/* Check if there is any value at all */
|
||||||
|
@ -776,7 +761,7 @@ VidDisplayString(IN PUCHAR String)
|
||||||
ULONG TopDelta = BOOTCHAR_HEIGHT + 1;
|
ULONG TopDelta = BOOTCHAR_HEIGHT + 1;
|
||||||
|
|
||||||
/* Start looping the string */
|
/* Start looping the string */
|
||||||
while (*String)
|
for (; *String; ++String)
|
||||||
{
|
{
|
||||||
/* Treat new-line separately */
|
/* Treat new-line separately */
|
||||||
if (*String == '\n')
|
if (*String == '\n')
|
||||||
|
@ -844,9 +829,6 @@ VidDisplayString(IN PUCHAR String)
|
||||||
curr_x = ScrollRegion[0];
|
curr_x = ScrollRegion[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the next character */
|
|
||||||
String++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -954,9 +936,6 @@ VidScreenToBufferBlt(IN PUCHAR Buffer,
|
||||||
/* Calculate total distance to copy on X */
|
/* Calculate total distance to copy on X */
|
||||||
XDistance = Left + Width - 1;
|
XDistance = Left + Width - 1;
|
||||||
|
|
||||||
/* Start at plane 0 */
|
|
||||||
Plane = 0;
|
|
||||||
|
|
||||||
/* Calculate the 8-byte left and right deltas */
|
/* Calculate the 8-byte left and right deltas */
|
||||||
LeftDelta = Left & 7;
|
LeftDelta = Left & 7;
|
||||||
RightDelta = 8 - LeftDelta;
|
RightDelta = 8 - LeftDelta;
|
||||||
|
@ -969,7 +948,7 @@ VidScreenToBufferBlt(IN PUCHAR Buffer,
|
||||||
XDistance >>= 3;
|
XDistance >>= 3;
|
||||||
|
|
||||||
/* Loop the 4 planes */
|
/* Loop the 4 planes */
|
||||||
do
|
for (Plane = 0; Plane < 4; ++Plane)
|
||||||
{
|
{
|
||||||
/* Set the current pixel position and reset buffer loop variable */
|
/* Set the current pixel position and reset buffer loop variable */
|
||||||
PixelPosition = (PUCHAR)(VgaBase + PixelOffset);
|
PixelPosition = (PUCHAR)(VgaBase + PixelOffset);
|
||||||
|
@ -981,12 +960,8 @@ VidScreenToBufferBlt(IN PUCHAR Buffer,
|
||||||
/* Set the current plane */
|
/* Set the current plane */
|
||||||
__outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, (Plane << 8) | IND_READ_MAP);
|
__outpw(VGA_BASE_IO_PORT + GRAPH_ADDRESS_PORT, (Plane << 8) | IND_READ_MAP);
|
||||||
|
|
||||||
/* Make sure we have a height */
|
/* Start the outer Y height loop */
|
||||||
if (Height > 0)
|
for (y = Height; y > 0; --y)
|
||||||
{
|
|
||||||
/* Start the outer Y loop */
|
|
||||||
y = Height;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
/* Read the current value */
|
/* Read the current value */
|
||||||
m = (PULONG)i;
|
m = (PULONG)i;
|
||||||
|
@ -998,9 +973,8 @@ VidScreenToBufferBlt(IN PUCHAR Buffer,
|
||||||
/* Check if we're still within bounds */
|
/* Check if we're still within bounds */
|
||||||
if (Left <= XDistance)
|
if (Left <= XDistance)
|
||||||
{
|
{
|
||||||
/* Start X Inner loop */
|
/* Start the X inner loop */
|
||||||
x = (XDistance - Left) + 1;
|
for (x = (XDistance - Left) + 1; x > 0; --x)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
/* Read the current value */
|
/* Read the current value */
|
||||||
Value2 = READ_REGISTER_UCHAR(k);
|
Value2 = READ_REGISTER_UCHAR(k);
|
||||||
|
@ -1024,15 +998,14 @@ VidScreenToBufferBlt(IN PUCHAR Buffer,
|
||||||
|
|
||||||
/* Write new value */
|
/* Write new value */
|
||||||
Value = Value2;
|
Value = Value2;
|
||||||
} while (--x);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update pixel position */
|
/* Update pixel position */
|
||||||
PixelPosition += (SCREEN_WIDTH / 8);
|
PixelPosition += (SCREEN_WIDTH / 8);
|
||||||
i += Delta;
|
i += Delta;
|
||||||
} while (--y);
|
|
||||||
}
|
}
|
||||||
} while (++Plane < 4);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1080,19 +1053,18 @@ VidSolidColorFill(IN ULONG Left,
|
||||||
if (Top <= Bottom)
|
if (Top <= Bottom)
|
||||||
{
|
{
|
||||||
/* Start looping each line */
|
/* Start looping each line */
|
||||||
i = (Bottom - Top) + 1;
|
for (i = (Bottom - Top) + 1; i > 0; --i)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
/* Read the previous value and add our color */
|
/* Read the previous value and add our color */
|
||||||
WRITE_REGISTER_UCHAR(Offset, READ_REGISTER_UCHAR(Offset) & Color);
|
WRITE_REGISTER_UCHAR(Offset, READ_REGISTER_UCHAR(Offset) & Color);
|
||||||
|
|
||||||
/* Move to the next line */
|
/* Move to the next line */
|
||||||
Offset += (SCREEN_WIDTH / 8);
|
Offset += (SCREEN_WIDTH / 8);
|
||||||
} while (--i);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we have a delta */
|
/* Check if we have a delta */
|
||||||
if (Distance)
|
if (Distance > 0)
|
||||||
{
|
{
|
||||||
/* Calculate new pixel position */
|
/* Calculate new pixel position */
|
||||||
Offset = (PUCHAR)(VgaBase + (Top * (SCREEN_WIDTH / 8)) + RightOffset);
|
Offset = (PUCHAR)(VgaBase + (Top * (SCREEN_WIDTH / 8)) + RightOffset);
|
||||||
|
@ -1105,20 +1077,18 @@ VidSolidColorFill(IN ULONG Left,
|
||||||
if (Top <= Bottom)
|
if (Top <= Bottom)
|
||||||
{
|
{
|
||||||
/* Start looping each line */
|
/* Start looping each line */
|
||||||
i = (Bottom - Top) + 1;
|
for (i = (Bottom - Top) + 1; i > 0; --i)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
/* Read the previous value and add our color */
|
/* Read the previous value and add our color */
|
||||||
WRITE_REGISTER_UCHAR(Offset,
|
WRITE_REGISTER_UCHAR(Offset, READ_REGISTER_UCHAR(Offset) & Color);
|
||||||
READ_REGISTER_UCHAR(Offset) & Color);
|
|
||||||
|
|
||||||
/* Move to the next line */
|
/* Move to the next line */
|
||||||
Offset += (SCREEN_WIDTH / 8);
|
Offset += (SCREEN_WIDTH / 8);
|
||||||
} while (--i);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we still have a delta */
|
/* Check if we still have a delta */
|
||||||
if (Distance)
|
if (Distance > 0)
|
||||||
{
|
{
|
||||||
/* Calculate new pixel position */
|
/* Calculate new pixel position */
|
||||||
Offset = (PUCHAR)(VgaBase + (Top * (SCREEN_WIDTH / 8)) + LeftOffset + 1);
|
Offset = (PUCHAR)(VgaBase + (Top * (SCREEN_WIDTH / 8)) + LeftOffset + 1);
|
||||||
|
@ -1130,22 +1100,18 @@ VidSolidColorFill(IN ULONG Left,
|
||||||
if (Top <= Bottom)
|
if (Top <= Bottom)
|
||||||
{
|
{
|
||||||
/* Start looping each line */
|
/* Start looping each line */
|
||||||
i = (Bottom - Top) + 1;
|
for (i = (Bottom - Top) + 1; i > 0; --i)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
/* Loop the shift delta */
|
/* Loop the shift delta */
|
||||||
if (Distance > 0)
|
for (j = Distance; j > 0; Offset++, --j)
|
||||||
{
|
|
||||||
for (j = Distance; j; Offset++, j--)
|
|
||||||
{
|
{
|
||||||
/* Write the color */
|
/* Write the color */
|
||||||
WRITE_REGISTER_UCHAR(Offset, Color);
|
WRITE_REGISTER_UCHAR(Offset, Color);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Update position in memory */
|
/* Update position in memory */
|
||||||
Offset += ((SCREEN_WIDTH / 8) - Distance);
|
Offset += ((SCREEN_WIDTH / 8) - Distance);
|
||||||
} while (--i);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue