mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
Merged New Inventory Project into main branch
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1871 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+242
-245
@@ -16,7 +16,7 @@
|
||||
// SetClippingRegionAndImageWidth( uiPitch, 15, 15, 30, 30 );
|
||||
//
|
||||
// LineDraw( TRUE, 10, 10, 200, 200, colour, pImageData);
|
||||
// OR
|
||||
// OR
|
||||
// RectangleDraw( TRUE, 10, 10, 200, 200, colour, pImageData);
|
||||
|
||||
//**************************************************************************
|
||||
@@ -32,14 +32,14 @@ int giClipYMin=0;
|
||||
int giClipYMax=0;
|
||||
|
||||
void DrawHorizontalRun(UINT8 **ScreenPtr, int XAdvance, int RunLength,
|
||||
int Color, int ScreenWidth);
|
||||
int Color, int ScreenWidth);
|
||||
void DrawVerticalRun(UINT8 **ScreenPtr, int XAdvance, int RunLength,
|
||||
int Color, int ScreenWidth);
|
||||
int Color, int ScreenWidth);
|
||||
|
||||
void DrawHorizontalRun8(UINT8 **ScreenPtr, int XAdvance,
|
||||
int RunLength, int Color, int ScreenWidth);
|
||||
int RunLength, int Color, int ScreenWidth);
|
||||
void DrawVerticalRun8(UINT8 **ScreenPtr, int XAdvance,
|
||||
int RunLength, int Color, int ScreenWidth);
|
||||
int RunLength, int Color, int ScreenWidth);
|
||||
|
||||
|
||||
void SetClippingRegionAndImageWidth(
|
||||
@@ -88,7 +88,7 @@ BOOL Clipt( FLOAT denom, FLOAT num, FLOAT *tE, FLOAT *tL )
|
||||
|
||||
BOOL ClipPoint( int x, int y )
|
||||
{
|
||||
return( x <= giClipXMax && x >= giClipXMin &&
|
||||
return( x <= giClipXMax && x >= giClipXMin &&
|
||||
y <= giClipYMax && y >= giClipYMin );
|
||||
}
|
||||
|
||||
@@ -225,128 +225,128 @@ void LineDraw( BOOL fClip, int XStart, int YStart, int XEnd, int YEnd, short Col
|
||||
return;
|
||||
}
|
||||
|
||||
/* Determine whether the line is X or Y major, and handle accordingly */
|
||||
if (XDelta >= YDelta)
|
||||
{
|
||||
/* X major line */
|
||||
/* Minimum # of pixels in a run in this line */
|
||||
WholeStep = XDelta / YDelta;
|
||||
/* Determine whether the line is X or Y major, and handle accordingly */
|
||||
if (XDelta >= YDelta)
|
||||
{
|
||||
/* X major line */
|
||||
/* Minimum # of pixels in a run in this line */
|
||||
WholeStep = XDelta / YDelta;
|
||||
|
||||
/* Error term adjust each time Y steps by 1; used to tell when one
|
||||
extra pixel should be drawn as part of a run, to account for
|
||||
fractional steps along the X axis per 1-pixel steps along Y */
|
||||
AdjUp = (XDelta % YDelta) * 2;
|
||||
/* Error term adjust each time Y steps by 1; used to tell when one
|
||||
extra pixel should be drawn as part of a run, to account for
|
||||
fractional steps along the X axis per 1-pixel steps along Y */
|
||||
AdjUp = (XDelta % YDelta) * 2;
|
||||
|
||||
/* Error term adjust when the error term turns over, used to factor
|
||||
out the X step made at that time */
|
||||
AdjDown = YDelta * 2;
|
||||
/* Error term adjust when the error term turns over, used to factor
|
||||
out the X step made at that time */
|
||||
AdjDown = YDelta * 2;
|
||||
|
||||
/* Initial error term; reflects an initial step of 0.5 along the Y
|
||||
axis */
|
||||
ErrorTerm = (XDelta % YDelta) - (YDelta * 2);
|
||||
/* Initial error term; reflects an initial step of 0.5 along the Y
|
||||
axis */
|
||||
ErrorTerm = (XDelta % YDelta) - (YDelta * 2);
|
||||
|
||||
/* The initial and last runs are partial, because Y advances only 0.5
|
||||
for these runs, rather than 1. Divide one full run, plus the
|
||||
initial pixel, between the initial and last runs */
|
||||
InitialPixelCount = (WholeStep / 2) + 1;
|
||||
FinalPixelCount = InitialPixelCount;
|
||||
/* The initial and last runs are partial, because Y advances only 0.5
|
||||
for these runs, rather than 1. Divide one full run, plus the
|
||||
initial pixel, between the initial and last runs */
|
||||
InitialPixelCount = (WholeStep / 2) + 1;
|
||||
FinalPixelCount = InitialPixelCount;
|
||||
|
||||
/* If the basic run length is even and there's no fractional
|
||||
advance, we have one pixel that could go to either the initial
|
||||
or last partial run, which we'll arbitrarily allocate to the
|
||||
last run */
|
||||
if ((AdjUp == 0) && ((WholeStep & 0x01) == 0))
|
||||
{
|
||||
InitialPixelCount--;
|
||||
}
|
||||
/* If there're an odd number of pixels per run, we have 1 pixel that can't
|
||||
be allocated to either the initial or last partial run, so we'll add 0.5
|
||||
to error term so this pixel will be handled by the normal full-run loop */
|
||||
if ((WholeStep & 0x01) != 0)
|
||||
{
|
||||
ErrorTerm += YDelta;
|
||||
}
|
||||
/* Draw the first, partial run of pixels */
|
||||
DrawHorizontalRun(&ScreenPtr, XAdvance, InitialPixelCount, Color, ScreenWidth);
|
||||
/* Draw all full runs */
|
||||
for (i=0; i<(YDelta-1); i++)
|
||||
{
|
||||
RunLength = WholeStep; /* run is at least this long */
|
||||
/* Advance the error term and add an extra pixel if the error
|
||||
term so indicates */
|
||||
if ((ErrorTerm += AdjUp) > 0)
|
||||
{
|
||||
RunLength++;
|
||||
ErrorTerm -= AdjDown; /* reset the error term */
|
||||
}
|
||||
/* Draw this scan line's run */
|
||||
DrawHorizontalRun(&ScreenPtr, XAdvance, RunLength, Color, ScreenWidth);
|
||||
}
|
||||
/* Draw the final run of pixels */
|
||||
DrawHorizontalRun(&ScreenPtr, XAdvance, FinalPixelCount, Color, ScreenWidth);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Y major line */
|
||||
/* If the basic run length is even and there's no fractional
|
||||
advance, we have one pixel that could go to either the initial
|
||||
or last partial run, which we'll arbitrarily allocate to the
|
||||
last run */
|
||||
if ((AdjUp == 0) && ((WholeStep & 0x01) == 0))
|
||||
{
|
||||
InitialPixelCount--;
|
||||
}
|
||||
/* If there're an odd number of pixels per run, we have 1 pixel that can't
|
||||
be allocated to either the initial or last partial run, so we'll add 0.5
|
||||
to error term so this pixel will be handled by the normal full-run loop */
|
||||
if ((WholeStep & 0x01) != 0)
|
||||
{
|
||||
ErrorTerm += YDelta;
|
||||
}
|
||||
/* Draw the first, partial run of pixels */
|
||||
DrawHorizontalRun(&ScreenPtr, XAdvance, InitialPixelCount, Color, ScreenWidth);
|
||||
/* Draw all full runs */
|
||||
for (i=0; i<(YDelta-1); i++)
|
||||
{
|
||||
RunLength = WholeStep; /* run is at least this long */
|
||||
/* Advance the error term and add an extra pixel if the error
|
||||
term so indicates */
|
||||
if ((ErrorTerm += AdjUp) > 0)
|
||||
{
|
||||
RunLength++;
|
||||
ErrorTerm -= AdjDown; /* reset the error term */
|
||||
}
|
||||
/* Draw this scan line's run */
|
||||
DrawHorizontalRun(&ScreenPtr, XAdvance, RunLength, Color, ScreenWidth);
|
||||
}
|
||||
/* Draw the final run of pixels */
|
||||
DrawHorizontalRun(&ScreenPtr, XAdvance, FinalPixelCount, Color, ScreenWidth);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Y major line */
|
||||
|
||||
/* Minimum # of pixels in a run in this line */
|
||||
WholeStep = YDelta / XDelta;
|
||||
/* Minimum # of pixels in a run in this line */
|
||||
WholeStep = YDelta / XDelta;
|
||||
|
||||
/* Error term adjust each time X steps by 1; used to tell when 1 extra
|
||||
pixel should be drawn as part of a run, to account for
|
||||
fractional steps along the Y axis per 1-pixel steps along X */
|
||||
AdjUp = (YDelta % XDelta) * 2;
|
||||
/* Error term adjust each time X steps by 1; used to tell when 1 extra
|
||||
pixel should be drawn as part of a run, to account for
|
||||
fractional steps along the Y axis per 1-pixel steps along X */
|
||||
AdjUp = (YDelta % XDelta) * 2;
|
||||
|
||||
/* Error term adjust when the error term turns over, used to factor
|
||||
out the Y step made at that time */
|
||||
AdjDown = XDelta * 2;
|
||||
/* Error term adjust when the error term turns over, used to factor
|
||||
out the Y step made at that time */
|
||||
AdjDown = XDelta * 2;
|
||||
|
||||
/* Initial error term; reflects initial step of 0.5 along the X axis */
|
||||
ErrorTerm = (YDelta % XDelta) - (XDelta * 2);
|
||||
/* Initial error term; reflects initial step of 0.5 along the X axis */
|
||||
ErrorTerm = (YDelta % XDelta) - (XDelta * 2);
|
||||
|
||||
/* The initial and last runs are partial, because X advances only 0.5
|
||||
for these runs, rather than 1. Divide one full run, plus the
|
||||
initial pixel, between the initial and last runs */
|
||||
InitialPixelCount = (WholeStep / 2) + 1;
|
||||
FinalPixelCount = InitialPixelCount;
|
||||
/* The initial and last runs are partial, because X advances only 0.5
|
||||
for these runs, rather than 1. Divide one full run, plus the
|
||||
initial pixel, between the initial and last runs */
|
||||
InitialPixelCount = (WholeStep / 2) + 1;
|
||||
FinalPixelCount = InitialPixelCount;
|
||||
|
||||
/* If the basic run length is even and there's no fractional advance, we
|
||||
have 1 pixel that could go to either the initial or last partial run,
|
||||
which we'll arbitrarily allocate to the last run */
|
||||
if ((AdjUp == 0) && ((WholeStep & 0x01) == 0))
|
||||
{
|
||||
InitialPixelCount--;
|
||||
}
|
||||
/* If there are an odd number of pixels per run, we have one pixel
|
||||
that can't be allocated to either the initial or last partial
|
||||
run, so we'll add 0.5 to the error term so this pixel will be
|
||||
handled by the normal full-run loop */
|
||||
if ((WholeStep & 0x01) != 0)
|
||||
{
|
||||
ErrorTerm += XDelta;
|
||||
}
|
||||
/* Draw the first, partial run of pixels */
|
||||
DrawVerticalRun(&ScreenPtr, XAdvance, InitialPixelCount, Color, ScreenWidth);
|
||||
/* If the basic run length is even and there's no fractional advance, we
|
||||
have 1 pixel that could go to either the initial or last partial run,
|
||||
which we'll arbitrarily allocate to the last run */
|
||||
if ((AdjUp == 0) && ((WholeStep & 0x01) == 0))
|
||||
{
|
||||
InitialPixelCount--;
|
||||
}
|
||||
/* If there are an odd number of pixels per run, we have one pixel
|
||||
that can't be allocated to either the initial or last partial
|
||||
run, so we'll add 0.5 to the error term so this pixel will be
|
||||
handled by the normal full-run loop */
|
||||
if ((WholeStep & 0x01) != 0)
|
||||
{
|
||||
ErrorTerm += XDelta;
|
||||
}
|
||||
/* Draw the first, partial run of pixels */
|
||||
DrawVerticalRun(&ScreenPtr, XAdvance, InitialPixelCount, Color, ScreenWidth);
|
||||
|
||||
/* Draw all full runs */
|
||||
for (i=0; i<(XDelta-1); i++)
|
||||
{
|
||||
RunLength = WholeStep; /* run is at least this long */
|
||||
/* Advance the error term and add an extra pixel if the error
|
||||
term so indicates */
|
||||
if ((ErrorTerm += AdjUp) > 0)
|
||||
{
|
||||
RunLength++;
|
||||
ErrorTerm -= AdjDown; /* reset the error term */
|
||||
}
|
||||
/* Draw this scan line's run */
|
||||
DrawVerticalRun(&ScreenPtr, XAdvance, RunLength, Color, ScreenWidth);
|
||||
}
|
||||
/* Draw the final run of pixels */
|
||||
DrawVerticalRun(&ScreenPtr, XAdvance, FinalPixelCount, Color, ScreenWidth);
|
||||
return;
|
||||
}
|
||||
/* Draw all full runs */
|
||||
for (i=0; i<(XDelta-1); i++)
|
||||
{
|
||||
RunLength = WholeStep; /* run is at least this long */
|
||||
/* Advance the error term and add an extra pixel if the error
|
||||
term so indicates */
|
||||
if ((ErrorTerm += AdjUp) > 0)
|
||||
{
|
||||
RunLength++;
|
||||
ErrorTerm -= AdjDown; /* reset the error term */
|
||||
}
|
||||
/* Draw this scan line's run */
|
||||
DrawVerticalRun(&ScreenPtr, XAdvance, RunLength, Color, ScreenWidth);
|
||||
}
|
||||
/* Draw the final run of pixels */
|
||||
DrawVerticalRun(&ScreenPtr, XAdvance, FinalPixelCount, Color, ScreenWidth);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Draws a pixel in the specified color
|
||||
@@ -369,9 +369,9 @@ void PixelDraw( BOOLEAN fClip, INT32 xp, INT32 yp, INT16 sColor, UINT8 *pScreen
|
||||
}
|
||||
|
||||
/* Draws a horizontal run of pixels, then advances the bitmap pointer to
|
||||
the first pixel of the next run. */
|
||||
the first pixel of the next run. */
|
||||
void DrawHorizontalRun(UINT8 **ScreenPtr, int XAdvance,
|
||||
int RunLength, int Color, int ScreenWidth)
|
||||
int RunLength, int Color, int ScreenWidth)
|
||||
{
|
||||
int i;
|
||||
UINT8 *WorkingScreenPtr = *ScreenPtr;
|
||||
@@ -390,9 +390,9 @@ void DrawHorizontalRun(UINT8 **ScreenPtr, int XAdvance,
|
||||
}
|
||||
|
||||
/* Draws a vertical run of pixels, then advances the bitmap pointer to
|
||||
the first pixel of the next run. */
|
||||
the first pixel of the next run. */
|
||||
void DrawVerticalRun(UINT8 **ScreenPtr, int XAdvance,
|
||||
int RunLength, int Color, int ScreenWidth)
|
||||
int RunLength, int Color, int ScreenWidth)
|
||||
{
|
||||
int i;
|
||||
UINT8 *WorkingScreenPtr = *ScreenPtr;
|
||||
@@ -414,10 +414,10 @@ void DrawVerticalRun(UINT8 **ScreenPtr, int XAdvance,
|
||||
/* Draws a rectangle between the specified endpoints in color Color. */
|
||||
void RectangleDraw( BOOL fClip, int XStart, int YStart, int XEnd, int YEnd, short Color, UINT8 *ScreenPtr)
|
||||
{
|
||||
LineDraw( fClip, XStart, YStart, XEnd, YStart, Color, ScreenPtr);
|
||||
LineDraw( fClip, XStart, YEnd, XEnd, YEnd, Color, ScreenPtr);
|
||||
LineDraw( fClip, XStart, YStart, XStart, YEnd, Color, ScreenPtr);
|
||||
LineDraw( fClip, XEnd, YStart, XEnd, YEnd, Color, ScreenPtr);
|
||||
LineDraw( fClip, XStart, YStart, XEnd, YStart, Color, ScreenPtr);
|
||||
LineDraw( fClip, XStart, YEnd, XEnd, YEnd, Color, ScreenPtr);
|
||||
LineDraw( fClip, XStart, YStart, XStart, YEnd, Color, ScreenPtr);
|
||||
LineDraw( fClip, XEnd, YStart, XEnd, YEnd, Color, ScreenPtr);
|
||||
}
|
||||
|
||||
/***********************************************************************************
|
||||
@@ -431,10 +431,10 @@ void RectangleDraw( BOOL fClip, int XStart, int YStart, int XEnd, int YEnd, shor
|
||||
/* Draws a rectangle between the specified endpoints in color Color. */
|
||||
void RectangleDraw8( BOOL fClip, int XStart, int YStart, int XEnd, int YEnd, short Color, UINT8 *ScreenPtr)
|
||||
{
|
||||
LineDraw8( fClip, XStart, YStart, XEnd, YStart, Color, ScreenPtr);
|
||||
LineDraw8( fClip, XStart, YEnd, XEnd, YEnd, Color, ScreenPtr);
|
||||
LineDraw8( fClip, XStart, YStart, XStart, YEnd, Color, ScreenPtr);
|
||||
LineDraw8( fClip, XEnd, YStart, XEnd, YEnd, Color, ScreenPtr);
|
||||
LineDraw8( fClip, XStart, YStart, XEnd, YStart, Color, ScreenPtr);
|
||||
LineDraw8( fClip, XStart, YEnd, XEnd, YEnd, Color, ScreenPtr);
|
||||
LineDraw8( fClip, XStart, YStart, XStart, YEnd, Color, ScreenPtr);
|
||||
LineDraw8( fClip, XEnd, YStart, XEnd, YEnd, Color, ScreenPtr);
|
||||
}
|
||||
|
||||
/* Draws a line between the specified endpoints in color Color. */
|
||||
@@ -443,7 +443,6 @@ void LineDraw8( BOOL fClip, int XStart, int YStart, int XEnd, int YEnd, short Co
|
||||
int Temp, AdjUp, AdjDown, ErrorTerm, XAdvance, XDelta, YDelta;
|
||||
int WholeStep, InitialPixelCount, FinalPixelCount, i, RunLength;
|
||||
int ScreenWidth = giImageWidth;
|
||||
UINT8 col2 = Color>>8;
|
||||
UINT8 col1 = Color & 0x00FF;
|
||||
|
||||
if ( fClip )
|
||||
@@ -513,139 +512,138 @@ void LineDraw8( BOOL fClip, int XStart, int YStart, int XEnd, int YEnd, short Co
|
||||
return;
|
||||
}
|
||||
|
||||
/* Determine whether the line is X or Y major, and handle accordingly */
|
||||
if (XDelta >= YDelta)
|
||||
{
|
||||
/* X major line */
|
||||
/* Minimum # of pixels in a run in this line */
|
||||
WholeStep = XDelta / YDelta;
|
||||
/* Determine whether the line is X or Y major, and handle accordingly */
|
||||
if (XDelta >= YDelta)
|
||||
{
|
||||
/* X major line */
|
||||
/* Minimum # of pixels in a run in this line */
|
||||
WholeStep = XDelta / YDelta;
|
||||
|
||||
/* Error term adjust each time Y steps by 1; used to tell when one
|
||||
extra pixel should be drawn as part of a run, to account for
|
||||
fractional steps along the X axis per 1-pixel steps along Y */
|
||||
AdjUp = (XDelta % YDelta) * 2;
|
||||
/* Error term adjust each time Y steps by 1; used to tell when one
|
||||
extra pixel should be drawn as part of a run, to account for
|
||||
fractional steps along the X axis per 1-pixel steps along Y */
|
||||
AdjUp = (XDelta % YDelta) * 2;
|
||||
|
||||
/* Error term adjust when the error term turns over, used to factor
|
||||
out the X step made at that time */
|
||||
AdjDown = YDelta * 2;
|
||||
/* Error term adjust when the error term turns over, used to factor
|
||||
out the X step made at that time */
|
||||
AdjDown = YDelta * 2;
|
||||
|
||||
/* Initial error term; reflects an initial step of 0.5 along the Y
|
||||
axis */
|
||||
ErrorTerm = (XDelta % YDelta) - (YDelta * 2);
|
||||
/* Initial error term; reflects an initial step of 0.5 along the Y
|
||||
axis */
|
||||
ErrorTerm = (XDelta % YDelta) - (YDelta * 2);
|
||||
|
||||
/* The initial and last runs are partial, because Y advances only 0.5
|
||||
for these runs, rather than 1. Divide one full run, plus the
|
||||
initial pixel, between the initial and last runs */
|
||||
InitialPixelCount = (WholeStep / 2) + 1;
|
||||
FinalPixelCount = InitialPixelCount;
|
||||
/* The initial and last runs are partial, because Y advances only 0.5
|
||||
for these runs, rather than 1. Divide one full run, plus the
|
||||
initial pixel, between the initial and last runs */
|
||||
InitialPixelCount = (WholeStep / 2) + 1;
|
||||
FinalPixelCount = InitialPixelCount;
|
||||
|
||||
/* If the basic run length is even and there's no fractional
|
||||
advance, we have one pixel that could go to either the initial
|
||||
or last partial run, which we'll arbitrarily allocate to the
|
||||
last run */
|
||||
if ((AdjUp == 0) && ((WholeStep & 0x01) == 0))
|
||||
{
|
||||
InitialPixelCount--;
|
||||
}
|
||||
/* If there're an odd number of pixels per run, we have 1 pixel that can't
|
||||
be allocated to either the initial or last partial run, so we'll add 0.5
|
||||
to error term so this pixel will be handled by the normal full-run loop */
|
||||
if ((WholeStep & 0x01) != 0)
|
||||
{
|
||||
ErrorTerm += YDelta;
|
||||
}
|
||||
/* Draw the first, partial run of pixels */
|
||||
DrawHorizontalRun8(&ScreenPtr, XAdvance, InitialPixelCount, Color, ScreenWidth);
|
||||
/* Draw all full runs */
|
||||
for (i=0; i<(YDelta-1); i++)
|
||||
{
|
||||
RunLength = WholeStep; /* run is at least this long */
|
||||
/* Advance the error term and add an extra pixel if the error
|
||||
term so indicates */
|
||||
if ((ErrorTerm += AdjUp) > 0)
|
||||
{
|
||||
RunLength++;
|
||||
ErrorTerm -= AdjDown; /* reset the error term */
|
||||
}
|
||||
/* Draw this scan line's run */
|
||||
DrawHorizontalRun8(&ScreenPtr, XAdvance, RunLength, Color, ScreenWidth);
|
||||
}
|
||||
/* Draw the final run of pixels */
|
||||
DrawHorizontalRun8(&ScreenPtr, XAdvance, FinalPixelCount, Color, ScreenWidth);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Y major line */
|
||||
/* If the basic run length is even and there's no fractional
|
||||
advance, we have one pixel that could go to either the initial
|
||||
or last partial run, which we'll arbitrarily allocate to the
|
||||
last run */
|
||||
if ((AdjUp == 0) && ((WholeStep & 0x01) == 0))
|
||||
{
|
||||
InitialPixelCount--;
|
||||
}
|
||||
/* If there're an odd number of pixels per run, we have 1 pixel that can't
|
||||
be allocated to either the initial or last partial run, so we'll add 0.5
|
||||
to error term so this pixel will be handled by the normal full-run loop */
|
||||
if ((WholeStep & 0x01) != 0)
|
||||
{
|
||||
ErrorTerm += YDelta;
|
||||
}
|
||||
/* Draw the first, partial run of pixels */
|
||||
DrawHorizontalRun8(&ScreenPtr, XAdvance, InitialPixelCount, Color, ScreenWidth);
|
||||
/* Draw all full runs */
|
||||
for (i=0; i<(YDelta-1); i++)
|
||||
{
|
||||
RunLength = WholeStep; /* run is at least this long */
|
||||
/* Advance the error term and add an extra pixel if the error
|
||||
term so indicates */
|
||||
if ((ErrorTerm += AdjUp) > 0)
|
||||
{
|
||||
RunLength++;
|
||||
ErrorTerm -= AdjDown; /* reset the error term */
|
||||
}
|
||||
/* Draw this scan line's run */
|
||||
DrawHorizontalRun8(&ScreenPtr, XAdvance, RunLength, Color, ScreenWidth);
|
||||
}
|
||||
/* Draw the final run of pixels */
|
||||
DrawHorizontalRun8(&ScreenPtr, XAdvance, FinalPixelCount, Color, ScreenWidth);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Y major line */
|
||||
|
||||
/* Minimum # of pixels in a run in this line */
|
||||
WholeStep = YDelta / XDelta;
|
||||
/* Minimum # of pixels in a run in this line */
|
||||
WholeStep = YDelta / XDelta;
|
||||
|
||||
/* Error term adjust each time X steps by 1; used to tell when 1 extra
|
||||
pixel should be drawn as part of a run, to account for
|
||||
fractional steps along the Y axis per 1-pixel steps along X */
|
||||
AdjUp = (YDelta % XDelta) * 2;
|
||||
/* Error term adjust each time X steps by 1; used to tell when 1 extra
|
||||
pixel should be drawn as part of a run, to account for
|
||||
fractional steps along the Y axis per 1-pixel steps along X */
|
||||
AdjUp = (YDelta % XDelta) * 2;
|
||||
|
||||
/* Error term adjust when the error term turns over, used to factor
|
||||
out the Y step made at that time */
|
||||
AdjDown = XDelta * 2;
|
||||
/* Error term adjust when the error term turns over, used to factor
|
||||
out the Y step made at that time */
|
||||
AdjDown = XDelta * 2;
|
||||
|
||||
/* Initial error term; reflects initial step of 0.5 along the X axis */
|
||||
ErrorTerm = (YDelta % XDelta) - (XDelta * 2);
|
||||
/* Initial error term; reflects initial step of 0.5 along the X axis */
|
||||
ErrorTerm = (YDelta % XDelta) - (XDelta * 2);
|
||||
|
||||
/* The initial and last runs are partial, because X advances only 0.5
|
||||
for these runs, rather than 1. Divide one full run, plus the
|
||||
initial pixel, between the initial and last runs */
|
||||
InitialPixelCount = (WholeStep / 2) + 1;
|
||||
FinalPixelCount = InitialPixelCount;
|
||||
/* The initial and last runs are partial, because X advances only 0.5
|
||||
for these runs, rather than 1. Divide one full run, plus the
|
||||
initial pixel, between the initial and last runs */
|
||||
InitialPixelCount = (WholeStep / 2) + 1;
|
||||
FinalPixelCount = InitialPixelCount;
|
||||
|
||||
/* If the basic run length is even and there's no fractional advance, we
|
||||
have 1 pixel that could go to either the initial or last partial run,
|
||||
which we'll arbitrarily allocate to the last run */
|
||||
if ((AdjUp == 0) && ((WholeStep & 0x01) == 0))
|
||||
{
|
||||
InitialPixelCount--;
|
||||
}
|
||||
/* If there are an odd number of pixels per run, we have one pixel
|
||||
that can't be allocated to either the initial or last partial
|
||||
run, so we'll add 0.5 to the error term so this pixel will be
|
||||
handled by the normal full-run loop */
|
||||
if ((WholeStep & 0x01) != 0)
|
||||
{
|
||||
ErrorTerm += XDelta;
|
||||
}
|
||||
/* Draw the first, partial run of pixels */
|
||||
DrawVerticalRun8(&ScreenPtr, XAdvance, InitialPixelCount, Color, ScreenWidth);
|
||||
/* If the basic run length is even and there's no fractional advance, we
|
||||
have 1 pixel that could go to either the initial or last partial run,
|
||||
which we'll arbitrarily allocate to the last run */
|
||||
if ((AdjUp == 0) && ((WholeStep & 0x01) == 0))
|
||||
{
|
||||
InitialPixelCount--;
|
||||
}
|
||||
/* If there are an odd number of pixels per run, we have one pixel
|
||||
that can't be allocated to either the initial or last partial
|
||||
run, so we'll add 0.5 to the error term so this pixel will be
|
||||
handled by the normal full-run loop */
|
||||
if ((WholeStep & 0x01) != 0)
|
||||
{
|
||||
ErrorTerm += XDelta;
|
||||
}
|
||||
/* Draw the first, partial run of pixels */
|
||||
DrawVerticalRun8(&ScreenPtr, XAdvance, InitialPixelCount, Color, ScreenWidth);
|
||||
|
||||
/* Draw all full runs */
|
||||
for (i=0; i<(XDelta-1); i++)
|
||||
{
|
||||
RunLength = WholeStep; /* run is at least this long */
|
||||
/* Advance the error term and add an extra pixel if the error
|
||||
term so indicates */
|
||||
if ((ErrorTerm += AdjUp) > 0)
|
||||
{
|
||||
RunLength++;
|
||||
ErrorTerm -= AdjDown; /* reset the error term */
|
||||
}
|
||||
/* Draw this scan line's run */
|
||||
DrawVerticalRun8(&ScreenPtr, XAdvance, RunLength, Color, ScreenWidth);
|
||||
}
|
||||
/* Draw the final run of pixels */
|
||||
DrawVerticalRun8(&ScreenPtr, XAdvance, FinalPixelCount, Color, ScreenWidth);
|
||||
return;
|
||||
}
|
||||
/* Draw all full runs */
|
||||
for (i=0; i<(XDelta-1); i++)
|
||||
{
|
||||
RunLength = WholeStep; /* run is at least this long */
|
||||
/* Advance the error term and add an extra pixel if the error
|
||||
term so indicates */
|
||||
if ((ErrorTerm += AdjUp) > 0)
|
||||
{
|
||||
RunLength++;
|
||||
ErrorTerm -= AdjDown; /* reset the error term */
|
||||
}
|
||||
/* Draw this scan line's run */
|
||||
DrawVerticalRun8(&ScreenPtr, XAdvance, RunLength, Color, ScreenWidth);
|
||||
}
|
||||
/* Draw the final run of pixels */
|
||||
DrawVerticalRun8(&ScreenPtr, XAdvance, FinalPixelCount, Color, ScreenWidth);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Draws a horizontal run of pixels, then advances the bitmap pointer to
|
||||
the first pixel of the next run. */
|
||||
the first pixel of the next run. */
|
||||
void DrawHorizontalRun8(UINT8 **ScreenPtr, int XAdvance,
|
||||
int RunLength, int Color, int ScreenWidth)
|
||||
int RunLength, int Color, int ScreenWidth)
|
||||
{
|
||||
int i;
|
||||
UINT8 *WorkingScreenPtr = *ScreenPtr;
|
||||
UINT8 col2 = Color>>8;
|
||||
UINT8 col1 = Color & 0x00FF;
|
||||
|
||||
for (i=0; i<RunLength; i++)
|
||||
@@ -659,13 +657,12 @@ void DrawHorizontalRun8(UINT8 **ScreenPtr, int XAdvance,
|
||||
}
|
||||
|
||||
/* Draws a vertical run of pixels, then advances the bitmap pointer to
|
||||
the first pixel of the next run. */
|
||||
the first pixel of the next run. */
|
||||
void DrawVerticalRun8(UINT8 **ScreenPtr, int XAdvance,
|
||||
int RunLength, int Color, int ScreenWidth)
|
||||
int RunLength, int Color, int ScreenWidth)
|
||||
{
|
||||
int i;
|
||||
UINT8 *WorkingScreenPtr = *ScreenPtr;
|
||||
UINT8 col2 = Color>>8;
|
||||
UINT8 col1 = Color & 0x00FF;
|
||||
|
||||
for (i=0; i<RunLength; i++)
|
||||
|
||||
Reference in New Issue
Block a user