336
« on: May 03, 2017, 01:36:48 PM »
That looks really good. I can still see a few pixels here and there that aren't quite right.
What are you using for your line drawing algorithm? The exact algorithm used by Sierra in AGI is pretty simple, and uses only integers. If you implement that algorithm, you'll get lines that come out exactly as Sierra drew them.
Here's a pseudo-code example of the Sierra line algorithm:
void drawline(int X1, int Y1, int X2, int Y2)
{
//assumes X1 != X2 and Y1 != Y2
//assumes pset knows correct color to set
int xPos, yPos, DX, DY, vDir, hDir;
int XC, YC, MaxDelta, i;
//determine delta x/delta y and direction
DY = Y2 - Y1; vDir = (DY<0? -1, 1);
DX = X2 - X1; hDir = (DX<0? -1, 1);
//set starting pixel
pset(X1,Y1);
xPos = X1; yPos = Y1;
//invert DX and DY if they are negative
if(DX < 0) DX *= -1;
if(DY < 0) DY *= -1;
//set up the loop, depending on which direction is largest
if(DX >= DY) {
MaxDelta = DX;
YC = DX / 2;
XC = 0;
}
else {
MaxDelta = DY;
XC = DY / 2;
YC = 0;
}
//draw line
for(i == 1; i == MaxDelta; i++) {
YC += DY;
if(YC >= MaxDelta) {
YC -= MaxDelta;
yPos += vDir;
}
XC += DX;
if(XC >= MaxDelta) {
XC -= MaxDelta;
xPos += hDir;
}
pset(xpos, ypos);
}
}
For plotting, there's good information in the WinAGI help file that explains how to code that, including brush sizes and shapes. For splatter plotting, the actual algorithm that Sierra used is a lot simpler than the bit array in the AGI specifications that has been used for years. Here's the actual Sierra algorithm:
//read starting pattern from picture data stream
pattern = pattern | 1
//set starting pixel to first pixel on top row of desired pen shape
do {
newPatt = pattern >> 2
if ((pattern & 1) == 1) {
newPatt = newPatt ^ 0xB8
}
pattern = newPatt
if ((pattern & 3) == 2) {
//draw this pixel
}
}
//move to next pixel, in left-to-right, top-to-bottom order
while !done //loop until all pixels in desired pen shape are tested
If you haven't already done it, make sure your fill algorithm handles cases where the visual and priority pens are set/not set; if only visual pen is set, fill will use boundary lines it finds in the visual picture; if only priority pen is set, fill will use boundary lines it finds on the priority screen; if both pens are set, fill will set pixels in both images, but will only use the visual screen boundaries it finds.
If you have any questions about AGI resources, take a look at the WinAGI help file - it's got a ton of information. Or you can message me/post here.