/* ISU WHEEL OF FORTUNE project */

#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <mem.h>
#include <dos.h>

#define VGA256 0x13
#define TEXT 0x03

char far *videoBuffer = (char far *) 0xA0000000L;

void setMode (int mode)
{ asm { mov ax, mode
int 0x10 } }

void putPixel (int x, int y, int color)
{ videoBuffer [((y<<8) + (y<<6)) + x] = (unsigned char) color; }

void colorScr (int color)
{ _fmemset (videoBuffer, color, 64000L); }

void Line (int x1, int y1, int x2, int y2, int color);

void Oval(int x0, int y0, int a, int b, int color);

 
int main ()
{
clrscr ();
setMode (TEXT);

int numplayers, go=1;
char *playername[3] = {" ", " ", " "};
int player1[3] = {0,0,0}, player2[3] = {0,0,0}, player3[3]= {0,0,0};
printf("\n\n\n\t\t\tWHEEL OF FORTUNE\n\n\n\t\t\tAlfa Vertion 1.1");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\nAll letters and phrases have to been in capital letters.");
printf("\nAny ties go to the lower number player.\nHit any key to continue, when weighting.");
getch();

while (go != 0)
{
clrscr();
printf("\n\n\nHow many players do you want. (1 - 3)? ");
scanf("%d", &numplayers);
numplayers -= 1;
fflush(stdin);
if (numplayers == 0)
{
printf("\nENTER in you name player1.\n");
gets(playername[0]);
playername[1] = " ";
playername[2] = " ";
printf("\nLets start the game!");
getch();
go = 0;
}
else if (numplayers == 1)
{
printf("\nENTER in you name player1.\n");
gets(playername[0]);
printf("\nENTER in you name player2.\n");
gets(playername[1]);
playername[2] = " ";

printf("\nLets start the game!");
getch();
go = 0;
}
else if (numplayers == 2)
{
printf("\nENTER in you name player1.\n");
gets(playername[0]);
printf("\nENTER in you name player2.\n");
gets(playername[1]);
printf("\nENTER in you name player3.\n");
gets(playername[2]);

printf("\nLets start the game!");
getch();
go = 0;
}
else
{
printf("That is incorrect!");
getch();
go = 1;
}

}
fflush(stdin);
randomize();
int strt;
strt = random(numplayers);

clrscr();
printf("\n%s starts.", playername[strt]);
getch();
int what,spin;
char *phrase1[5][15] = {"DESK TOP COMPUTER","MANUFACTURED GOODS","AUTOMOBILE","TRANSFORMATION","COLOURS OF THE RAINBOW"};
char phrase2[] = {"BACK SEAT OF A CAR"};
char phrase3[] = {"GAME SHOW HOST"};
char *answer1[sizeof(phrase1)][sizeof(phrase1)] = {" "," "," "," "," "," "};
char answer2[sizeof(phrase2)] = {" "};
"};
char answer3[sizeof(phrase3)] = {" "};

int goes1=1,flag=0,flag2=0,numletters=0,goes2=1,goes3=1,test=1;

printf("\n%d\n%d",sizeof(phrase1),sizeof(answer1));
/* phrase 1 */
while (goes1 != 0)
{
for (int a=0; a<sizeof(phrase1); a++)
{
if (*answer1[0][a] == *phrase1[0][a])
{
flag += 1;
}
else
{
if (*phrase1[0][a] == 'A' || *phrase1[0][a] == 'E' || *phrase1[0][a] == 'I' || *phrase1[0][a] == 'O' || *phrase1[0][a] == 'U')
{
if (*answer1[0][a] != 'A' || *answer1[0][a] != 'E' || *answer1[0][a] != 'I' || *answer1[0][a] != 'O' || *answer1[0][a] != 'U')
{
if (*answer1[0][a] == ' ')
{
flag2 += 1;
}
}
}
else
{
numletters += 1;
flag2 = 0;
break;
}
}
}
if (flag2 > 0)
{
clrscr();
printf("\nThere are only vowels left.");
getch();
}
if (flag == sizeof(phrase1))
{
clrscr();
printf("\n\n\n");
printf("\nCongradgulations, You won!");
if (player1[strt] < 250)
{
player1[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player1[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player1[strt]);
getch();
}
printf("\nOn to Round Two.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player1[strt] = 0;
}
else if (numplayers == 2)
{
player1[strt] = 0;
player1[strt2] = 0;
}
goes1 = 0;
}

clrscr();
printf("\n%s's turn.", playername[strt]);
printf("\nYour score is %d.", player1[strt]);
printf("\n%s",answer1);
printf("\nTHING(S)");
printf("\n\nPress:\n1. Spin\n2. Buy a Vowel ($ 250)\n3. Solve\n4. Exit");
printf("\n\nEnter in a number. ");
scanf("%d", &what);
fflush(stdin);
if (what == 1)
{
randomize();
printf ("\n");
clrscr();
int amount,strength;
char bankrupt[] = "BANKRUPT";
char jackpot[] = "JACKPOT";
go = 1;
while (go != 0)
{
clrscr();
printf("\nPower 5 - 10.");
printf("\nHow much power would you like to spin the wheel? ");
scanf("%d", &strength);
fflush(stdin);
if (strength < 5 || strength > 10)
{
printf("\nThat is incorrect.");
getch();
}
else
{
go = 0;
}
}
strength *= 2;
clrscr();
for (int a=0; a<strength; a++)
{
amount = random (22) * 50;
if (amount == 0)
{
printf("%s\n", bankrupt);
}
else if (amount == 1050)
{
printf("Lose a Turn\n");
}
else if (amount == 1000)
{
printf("%s\n", jackpot);
}
else
{
printf("%d\n", amount);
}
}
getch();
if (amount == 0)
{
printf("\nBANKRUPT.");
player1[strt] = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
getch();
}
else if (amount == 1050)
{
printf("\nLOSE A TURN.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
getch();
}
else
{
clrscr();
char letter;
printf ("%s, your score is %d.", playername[strt], player1[strt]);
printf ("\nAmount to be won, $ %d.", amount);
printf ("\n%s", answer1);
printf("\n\nENTER in a letter. ");
scanf("%c", &letter);
fflush(stdin);
int num=0,flag=0;
for(int a=0; a<sizeof(phrase1); a++)
{
if (letter == 'A' || letter == 'E' || letter == 'I' || letter == 'O' || letter == 'U')
{
printf("\nThat is a Vowel.");
amount = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
else if (letter == *answer1[0][a])
{
printf("\nThat letter has already been used.");
amount = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
else if (letter == *phrase1[0][a])
{
num+=1;
*answer1[0][a] = letter;
}
else
{
flag+=1;
}
}
if (flag == sizeof(phrase1))
{
printf("\nSorry, no %c's", letter);
amount = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
}
if (num >= 1)
{
if (num == 1)
{
printf("\nThere is %d %c.", num, letter);
player1[strt] += amount;
}
else if (num > 1)
{
printf("\nThere are %d %c's.", num, letter);
player1[strt] += amount*num;
}
}
printf("\n%s", answer1);
getch();
flag=0;
for(a=0; a<sizeof(phrase1); a++)
{
if(*phrase1[0][a] == *answer1[0][a])
{
flag += 1;
}
}
if (flag == sizeof(phrase1))
{
printf("\n\n\n");
if (player1[strt] < 250)
{
player1[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player1[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player1[strt]);
getch();
}
printf("\nOn to Round Two.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player1[strt] = 0;
}
else if (numplayers == 2)
{
player1[strt] = 0;
player1[strt2] = 0;
}
goes1 = 0;
}

}

}
else if (what == 2)
{
if (player1[strt] < 250)
{
printf("\nYou do not have enough money.");
getch();
}
else if (player1[strt] >= 250)
{
player1[strt] -= 250;
clrscr();
char vowel;
printf("\n%s, your score is %d.", playername[strt], player1[strt]);
printf("\n%s", answer1);
printf("\n\nENTER in a vowel. ");
scanf("%c", &vowel);
fflush(stdin);
int num=0,flag=0;
if (vowel == 'A' || vowel == 'E' || vowel == 'I' || vowel == 'O' || vowel == 'U')
{
for (int a=0; a<sizeof(phrase1); a++)
{
if (vowel == *answer1[0][a])
{
printf("\nThat vowel has already been used.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
else if (vowel == *phrase1[0][a])
{
*answer1[0][a] = vowel;
num+=1;
}
else
{
flag+=1;
}
}
}
else
{
printf("\nThat is not a vowel.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
}
if (num > 0)
{
if (num == 1)
{
printf("\nThere is %d %c.", num, vowel);
}
else if (num > 1)
{
printf("\nThere are %d %c's.", num, vowel);
}
}
if (flag >= sizeof(phrase1))
{
printf("\nSorry, no %c's.", vowel);
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
}
printf("\n%s ", answer1);
getch();
flag=0;
for(int a=0; a<sizeof(phrase1); a++)
{
if(*phrase1[0][a] == *answer1[0][a])
{
flag += 1;
}
}
if (flag == sizeof(phrase1))
{
printf("\n\n\n");
if (player1[strt] < 250)
{
player1[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player1[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player1[strt]);
getch();
}
printf("\nOn to Round Two.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player1[strt] = 0;
}
else if (numplayers == 2)
{
player1[strt] = 0;
player1[strt2] = 0;
}
goes1 = 0;
}

}
}
else if (what == 3)
{
clrscr();
char solve1[18] = {" "};
printf("\nThis puzzle is worth %d.", player1[strt]);
printf("\n%s", answer1);
int flag=0;
for (int a=0; a<sizeof(phrase1); a++)
{
if (*answer1[0][a] == *phrase1[0][a])
{
flag+=1;
}
}
if (flag == sizeof(phrase1))
{
printf("\n%s", answer1);
printf("\nThat is correct. You win!");
getch();
printf("\n\n\n");
if (player1[strt] < 250)
{
player1[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player1[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player1[strt]);
getch();
}
printf("\nOn to Round Two.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player1[strt] = 0;
}
else if (numplayers == 2)
{
player1[strt] = 0;
player1[strt2] = 0;
}
goes1 = 0;
}
fflush(stdin);
printf("\nENTER in the whole puzzle.\n");
gets(solve1);
fflush(stdin);
flag=0;
for (a=0; a<sizeof(phrase1); a++)
{
if (solve1[a] == *phrase1[0][a])
{
flag+=1;
}
else
{
printf("\nSorry that is incorrect.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
}
if (flag == sizeof(phrase1))
{
printf("\nThat is correct. You win!");
getch();
printf("\n\n\n");
if (player1[strt] < 250)
{
player1[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player1[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player1[strt]);
getch();
}
printf("\nOn to Round Two.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player1[strt] = 0;
}
else if (numplayers == 2)
{
player1[strt] = 0;
player1[strt2] = 0;
}
goes1 = 0;
}

}
else
{
char quit,y,Y,n,N;
printf("\nDo you really want to quit?\n(if No it sets scores to zero)\n(hit enter to continue) ");
scanf("%c", &quit);
fflush(stdin);
if (quit == 'Y' || quit == 'y')
{
printf("\nBye Bye!");
getch();
test=0;
goes1 = 0; goes2 = 0; goes3 = 0;
}
else if (quit == 'N' || quit == 'n')
{
printf("\nStarting over again!");
player1[0] = 0;
player1[1] = 0;
player1[2] = 0;
getch();
go = 1;
}
else
{
printf("\nBack to main menu.");
getch();
}
}

}

/* phrase 2 */

while (goes2 != 0)
{
for (int a=0; a<sizeof(phrase2); a++)
{
if (answer2[a] == phrase2[a])
{
flag += 1;
}
else
{
if (phrase2[a] == 'A' || phrase2[a] == 'E' || phrase2[a] == 'I' || phrase2[a] == 'O' || phrase2[a] == 'U')
{
if (answer2[a] != 'A' || answer2[a] != 'E' || answer2[a] != 'I' || answer2[a] != 'O' || answer2[a] != 'U')
{
if (answer2[a] == ' ')
{
flag2 += 1;
}
}
}
else
{
numletters += 1;
flag2 = 0;
break;
}
}
}
if (flag2 > 0)
{
clrscr();
printf("\nThere are only vowels left.");
getch();
}
if (flag == sizeof(phrase2))
{
clrscr();
printf("\n\n\n");
printf("\nCongradgulations, You won!");
if (player2[strt] < 250)
{
player2[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player2[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player2[strt]);
getch();
}
printf("\nTo the Final Round.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player2[strt] = 0;
}
else if (numplayers == 2)
{
player2[strt] = 0;
player2[strt2] = 0;
}
goes2 = 0;
}

clrscr();
printf("\n%s's turn.", playername[strt]);
printf("\nYour score is %d.", player2[strt]);
printf("\n%s",answer2);
printf("\nPHRASE");
printf("\n\n1. Spin\n2. Buy a Vowel\n3. Solve\n4. Exit");
printf("\n\nEnter in a number. ");
scanf("%d", &what);
fflush(stdin);
if (what == 1)
{
randomize();
printf ("\n");
clrscr();
int amount,strength;
char bankrupt[] = "BANKRUPT";
char jackpot[] = "JACKPOT";
go = 1;
while (go != 0)
{
clrscr();
printf("\nPower 5 - 10.");
printf("\nHow much power would you like to spin the wheel? ");
scanf("%d", &strength);
fflush(stdin);
if (strength < 5 || strength > 10)
{
printf("\nThat is incorrect.");
getch();
}
else
{
go = 0;
}
}
strength *= 2;
clrscr();
for (int a=0; a<strength; a++)
{
amount = random (22) * 50;
if (amount == 0)
{
printf("%s\n", bankrupt);
}
else if (amount == 1050)
{
printf("Lose a Turn\n");
}
else if (amount == 1000)
{
printf("%s\n", jackpot);
}
else
{
printf("%d\n", amount);
}
}
getch();
if (amount == 0)
{
printf("\nBANKRUPT.");
player2[strt] = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
getch();
}
else if (amount == 1050)
{
printf("\nLOSE A TURN.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
getch();
}
else
{
clrscr();
char letter;
printf ("%s, your score is %d.", playername[strt], player2[strt]);
printf ("\nAmount to be won, $ %d.", amount);
printf ("\n%s", answer2);
printf("\n\nENTER in a letter. ");
scanf("%c", &letter);
fflush(stdin);
int num=0,flag=0;
for(int a=0; a<sizeof(phrase2); a++)
{
if (letter == 'A' || letter == 'E' || letter == 'I' || letter == 'O' || letter == 'U')
{
printf("\nThat is a Vowel.");
amount = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
else if (letter == answer2[a])
{
printf("\nThat letter has already been used.");
amount = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
else if (letter == phrase2[a])
{
num+=1;
answer2[a] = letter;
}
else
{
flag+=1;
}
}
if (flag == sizeof(phrase2))
{
printf("\nSorry, no %c's", letter);
amount = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
}
if (num >= 1)
{
if (num == 1)
{
printf("\nThere is %d %c.", num, letter);
player2[strt] += amount;
}
else if (num > 1)
{
printf("\nThere are %d %c's.", num, letter);
player2[strt] += amount*num;
}
}
printf("\n%s", answer2);
getch();
flag=0;
for(a=0; a<sizeof(phrase2); a++)
{
if(phrase2[a] == answer2[a])
{
flag += 1;
}
}
if (flag == sizeof(phrase2))
{
printf("\n\n\n");
if (player2[strt] < 250)
{
player2[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player2[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player2[strt]);
getch();
}
printf("\nTo the Final Round.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player2[strt] = 0;
}
else if (numplayers == 2)
{
player2[strt] = 0;
player2[strt2] = 0;
}
goes2 = 0;
}

}

}
else if (what == 2)
{
if (player2[strt] < 250)
{
printf("\nYou do not have enough money.");
getch();
}
else if (player2[strt] >= 250)
{
player2[strt] -= 250;
clrscr();
char vowel;
printf("\n%s, your score is %d.", playername[strt], player2[strt]);
printf("\n%s", answer2);
printf("\n\nENTER in a vowel. ");
scanf("%c", &vowel);
fflush(stdin);
int num=0,flag=0;
if (vowel == 'A' || vowel == 'E' || vowel == 'I' || vowel == 'O' || vowel == 'U')
{
for (int a=0; a<sizeof(phrase2); a++)
{
if (vowel == answer2[a])
{
printf("\nThat vowel has already been used.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
else if (vowel == phrase2[a])
{
answer2[a] = vowel;
num+=1;
}
else
{
flag+=1;
}
}
}
else
{
printf("\nThat is not a vowel.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
}
if (num > 0)
{
if (num == 1)
{
printf("\nThere is %d %c.", num, vowel);
}
else if (num > 1)
{
printf("\nThere are %d %c's.", num, vowel);
}
}
if (flag >= sizeof(phrase2))
{
printf("\nSorry, no %c's.", vowel);
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
}
printf("\n%s ", answer2);
getch();
flag=0;
for(int a=0; a<sizeof(phrase2); a++)
{
if(phrase2[a] == answer2[a])
{
flag += 1;
}
}
if (flag == sizeof(phrase2))
{
printf("\n\n\n");
if (player2[strt] < 250)
{
player2[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player2[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player2[strt]);
getch();
}
printf("\nTo the Final Round.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player2[strt] = 0;
}
else if (numplayers == 2)
{
player2[strt] = 0;
player2[strt2] = 0;
}
goes2 = 0;
}

}
}
else if (what == 3)
{
clrscr();
char solve2[sizeof(answer2)] = {" "};
printf("\nThis puzzle is worth %d.", player2[strt]);
printf("\n%s", answer2);
int flag=0;
for (int a=0; a<sizeof(phrase2); a++)
{
if (answer2[a] == phrase2[a])
{
flag+=1;
}
}
if (flag == sizeof(phrase2))
{
printf("\n%s", answer2);
printf("\nThat is correct. You win!");
getch();
printf("\n\n\n");
if (player2[strt] < 250)
{
player2[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player2[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player2[strt]);
getch();
}
printf("\nTo the Final Round.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player2[strt] = 0;
}
else if (numplayers == 2)
{
player2[strt] = 0;
player2[strt2] = 0;
}
goes2 = 0;
}
fflush(stdin);
printf("\nENTER in the whole puzzle.\n");
gets(solve2);
fflush(stdin);
flag=0;
for (a=0; a<sizeof(phrase2); a++)
{
if (solve2[a] == phrase2[a])
{
flag+=1;
}
else
{
printf("\nSorry that is incorrect.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
}
if (flag == sizeof(phrase2))
{
printf("\nThat is correct. You win!");
getch();
printf("\n\n\n");
if (player2[strt] < 250)
{
player2[strt] = 250;
printf("\n%s gets $ %d.", playername[strt], player2[strt]);
getch();
}
else
{
printf("\n%s score is $ %d.", playername[strt], player2[strt]);
getch();
}
printf("\nTo the Final Round.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player2[strt] = 0;
}
else if (numplayers == 2)
{
player2[strt] = 0;
player2[strt2] = 0;
}
goes2 = 0;
}

}
else
{
char quit,y,Y,n,N;
printf("\nDo you really want to quit?\n(if No it sets scores to zero)\n(hit enter to continue) ");
scanf("%c", &quit);
fflush(stdin);
if (quit == 'Y' || quit == 'y')
{
printf("\nBye Bye!");
getch();
test=0;
goes2 = 0;goes3 = 0;
}
else if (quit == 'N' || quit == 'n')
{
printf("\nStarting over again!");
player2[0] = 0;
player2[1] = 0;
player2[2] = 0;
getch();
go = 1;
}
else
{
printf("\nBack to main menu.");
getch();
}
}

}

/* phrase 3 */

while (goes3 != 0)
{
for (int a=0; a<sizeof(phrase3); a++)
{
if (answer3[a] == phrase3[a])
{
flag += 1;
}
else
{
if (phrase3[a] == 'A' || phrase3[a] == 'E' || phrase3[a] == 'I' || phrase3[a] == 'O' || phrase3[a] == 'U')
{
if (answer3[a] != 'A' || answer3[a] != 'E' || answer3[a] != 'I' || answer3[a] != 'O' || answer3[a] != 'U')
{
if (answer3[a] == ' ')
{
flag2 += 1;
}
}
}
else
{
numletters += 1;
flag2 = 0;
break;
}
}
}
if (flag2 > 0)
{
clrscr();
printf("\nThere are only vowels left.");
getch();
}
if (flag == sizeof(phrase3))
{
clrscr();
printf("\n\n\n");
printf("\nCongradgulations, You won!");
if (player3[strt] < 250)
{
player3[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player3[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player3[strt]);
getch();
}
printf("\nThanks for playing.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player3[strt] = 0;
}
else if (numplayers == 2)
{
player3[strt] = 0;
player3[strt2] = 0;
}
goes3=0;
test=1;
getch();
}

clrscr();
printf("\n%s's turn.", playername[strt]);
printf("\nYour score is %d.", player3[strt]);
printf("\n%s",answer3);
printf("\nPERSON");
printf("\n\n1. Spin\n2. Buy a Vowel\n3. Solve\n4. Exit");
printf("\n\nEnter in a number. ");
scanf("%d", &what);
fflush(stdin);
if (what == 1)
{
randomize();
printf ("\n");
clrscr();
int amount,strength;
char bankrupt[] = "BANKRUPT";
char jackpot[] = "JACKPOT";
go = 1;
while (go != 0)
{
clrscr();
printf("\nPower 5 - 10.");
printf("\nHow much power would you like to spin the wheel? ");
scanf("%d", &strength);
fflush(stdin);
if (strength < 5 || strength > 10)
{
printf("\nThat is incorrect.");
getch();
}
else
{
go = 0;
}
}
strength *= 2;
clrscr();
for (int a=0; a<strength; a++)
{
amount = random (22) * 50;
if (amount == 0)
{
printf("%s\n", bankrupt);
}
else if (amount == 1050)
{
printf("Lose a Turn\n");
}
else if (amount == 1000)
{
printf("%s\n", jackpot);
}
else
{
printf("%d\n", amount);
}
}
getch();
if (amount == 0)
{
printf("\nBANKRUPT.");
player3[strt] = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
getch();
}
else if (amount == 1050)
{
printf("\nLOSE A TURN.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
getch();
}
else
{
clrscr();
char letter;
printf ("%s, your score is %d.", playername[strt], player3[strt]);
printf ("\nAmount to be won, $ %d.", amount);
printf ("\n%s", answer3);
printf("\n\nENTER in a letter. ");
scanf("%c", &letter);
fflush(stdin);
int num=0,flag=0;
for(int a=0; a<sizeof(phrase3); a++)
{
if (letter == 'A' || letter == 'E' || letter == 'I' || letter == 'O' || letter == 'U')
{
printf("\nThat is a Vowel.");
amount = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
else if (letter == answer3[a])
{
printf("\nThat letter has already been used.");
amount = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
else if (letter == phrase3[a])
{
num+=1;
answer3[a] = letter;
}
else
{
flag+=1;
}
}
if (flag == sizeof(phrase3))
{
printf("\nSorry, no %c's", letter);
amount = 0;
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
}
if (num >= 1)
{
if (num == 1)
{
printf("\nThere is %d %c.", num, letter);
player3[strt] += amount;
}
else if (num > 1)
{
printf("\nThere are %d %c's.", num, letter);
player3[strt] += amount*num;
}
}
printf("\n%s", answer3);
getch();
flag=0;
for(a=0; a<sizeof(phrase3); a++)
{
if(phrase3[a] == answer3[a])
{
flag += 1;
}
}
if (flag == sizeof(phrase3))
{
printf("\n\n\n");
if (player3[strt] < 250)
{
player3[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player3[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player3[strt]);
getch();
}
printf("\nThanks for playing.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player3[strt] = 0;
}
else if (numplayers == 2)
{
player3[strt] = 0;
player3[strt2] = 0;
}
goes3=0;
test=1;
getch();
}

}

}
else if (what == 2)
{
if (player3[strt] < 250)
{
printf("\nYou do not have enough money.");
getch();
}
else if (player3[strt] >= 250)
{
player3[strt] -= 250;
clrscr();
char vowel;
printf("\n%s, your score is %d.", playername[strt], player3[strt]);
printf("\n%s", answer3);
printf("\n\nENTER in a vowel. ");
scanf("%c", &vowel);
fflush(stdin);
int num=0,flag=0;
if (vowel == 'A' || vowel == 'E' || vowel == 'I' || vowel == 'O' || vowel == 'U')
{
for (int a=0; a<sizeof(phrase3); a++)
{
if (vowel == answer3[a])
{
printf("\nThat vowel has already been used.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
else if (vowel == phrase3[a])
{
answer3[a] = vowel;
num+=1;
}
else
{
flag+=1;
}
}
}
else
{
printf("\nThat is not a vowel.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
}
if (num > 0)
{
if (num == 1)
{
printf("\nThere is %d %c.", num, vowel);
}
else if (num > 1)
{
printf("\nThere are %d %c's.", num, vowel);
}
}
if (flag >= sizeof(phrase3))
{
printf("\nSorry, no %c's.", vowel);
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
}
printf("\n%s ", answer3);
getch();
flag=0;
for(int a=0; a<sizeof(phrase3); a++)
{
if(phrase3[a] == answer3[a])
{
flag += 1;
}
}
if (flag == sizeof(phrase3))
{
printf("\n\n\n");
if (player3[strt] < 250)
{
player3[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player3[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player3[strt]);
getch();
}
printf("\nThanks for playing.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player3[strt] = 0;
}
else if (numplayers == 2)
{
player3[strt] = 0;
player3[strt2] = 0;
}
goes3=0;
test=1;
getch();
}

}
}
else if (what == 3)
{
clrscr();
char solve3[sizeof(answer3)] = {" "};
printf("\nThis puzzle is worth %d.", player3[strt]);
printf("\n%s", answer3);
int flag=0;
for (int a=0; a<sizeof(phrase3); a++)
{
if (answer3[a] == phrase3[a])
{
flag+=1;
}
}
if (flag == sizeof(phrase3))
{
printf("\n%s", answer3);
printf("\nThat is correct. You win!");
getch();
printf("\n\n\n");
if (player3[strt] < 250)
{
player3[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player3[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player3[strt]);
getch();
}
printf("\nThanks for playing.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player3[strt] = 0;
}
else if (numplayers == 2)
{
player3[strt] = 0;
player3[strt2] = 0;
}
goes3=0;
test=1;
getch();
}
fflush(stdin);
printf("\nENTER in the whole puzzle.\n");
gets(solve3);
fflush(stdin);
flag=0;
for (a=0; a<sizeof(phrase3); a++)
{
if (solve3[a] == phrase3[a])
{
flag+=1;
}
else
{
printf("\nSorry that is incorrect.");
getch();
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
break;
}
}
if (flag == sizeof(phrase3))
{
printf("\nThat is correct. You win!");
getch();
printf("\n\n\n");
if (player3[strt] < 250)
{
player3[strt] = 250;
printf("\n%s, you get $ %d.", playername[strt], player3[strt]);
getch();
}
else
{
printf("\n%s, you get $ %d.", playername[strt], player3[strt]);
getch();
}
printf("\nThanks for playing.");
if (strt == 2)
strt = 0;
else if (numplayers == 0)
strt = 0;
else if (numplayers == 1)
{
if (strt == 1)
strt = 0;
else
strt += 1;
}
else
strt += 1;
int strt2 = strt;
if (strt2 == 2)
strt2 = 0;
else if (numplayers == 0)
strt2 = 0;
else if (numplayers == 1)
{
if (strt2 == 1)
strt2 = 0;
else
strt2 += 1;
}
else
strt2 += 1;
if (numplayers == 1)
{
player3[strt] = 0;
}
else if (numplayers == 2)
{
player3[strt] = 0;
player3[strt2] = 0;
}
goes3=0;
test=1;
getch();
}

}
else
{
char quit,y,Y,n,N;
printf("\nDo you really want to quit?\n(if No it sets scores to zero)\n(hit enter to continue) ");
scanf("%c", &quit);
fflush(stdin);
if (quit == 'Y' || quit == 'y')
{
printf("\nBye Bye!");
getch();
test=0;
goes3=0;
}
else if (quit == 'N' || quit == 'n')
{
printf("\nStarting over again!");
player3[0] = 0;
player3[1] = 0;
player3[2] = 0;
getch();
go = 1;
}
else
{
printf("\nBack to main menu.");
getch();
}
}

}

 
if (test != 0)
{
clrscr();
int scores[3];
scores[0]=player1[0]+player2[0]+player3[0];
scores[1]=player1[1]+player2[1]+player3[1];
scores[2]=player1[2]+player2[2]+player3[2];
numplayers += 1;

printf("\n\nTotal scores.");
if (numplayers == 1)
{
printf("\n\n%s score is %d, %d, %d, total is %d.", playername[0], player1[0], player2[0], player3[0], scores[0]);
}
else if (numplayers == 2)
{
printf("\n\n%s score is %d, %d, %d, total is %d.", playername[0], player1[0], player2[0], player3[0], scores[0]);
printf("\n%s score is %d, %d, %d, total is %d.", playername[1], player1[1], player2[1], player3[1], scores[1]);
}
else if (numplayers == 3)
{
printf("\n\n%s score is %d, %d, %d, total is %d.", playername[0], player1[0], player2[0], player3[0], scores[0]);
printf("\n%s score is %d, %d, %d, total is %d.", playername[1], player1[1], player2[1], player3[1], scores[1]);
printf("\n%s score is %d, %d, %d, total is %d.", playername[2], player1[2], player2[2], player3[2], scores[2]);
}
else
printf("\nYou got something wrong!.");
getch();
int num;
if (scores[0] >= scores[1] && scores[0] >= scores[2])
{
printf("\n\n%s is going on to the bonus round.", playername[0]);
num=1;
}
else if (scores[1] > scores[0] && scores[1] >= scores[2])
{
printf("\n\n%s is going on to the bonus round.",playername[1]);
num=2;
}
else if (scores[2] > scores[0] && scores[2] > scores[1])
{
printf("\n\n%s is going on to the bonus round.",playername[2]);
num=3;
}
else
printf("\nYou got something wrong!.");

getch();
clrscr();
printf("\n\nBONUS ROUND\n\nTHING");
char bonus[] = {"ELAVATOR"};
char solveb[sizeof(bonus)] = {" "};
int flag=0;
char letter;
letter = 'R';
for(int a=0; a<sizeof(bonus); a++)
{
if (letter == bonus[a])
{
solveb[a] = letter;
}
else
{
flag+=1;
}
}
letter = 'S';
for(a=0; a<sizeof(bonus); a++)
{
if (letter == bonus[a])
{
solveb[a] = letter;
}
else
{
flag+=1;
}
}
letter = 'T';
for(a=0; a<sizeof(bonus); a++)
{
if (letter == bonus[a])
{
solveb[a] = letter;
}
else
{
flag+=1;
}
}
letter = 'L';
for(a=0; a<sizeof(bonus); a++)
{
if (letter == bonus[a])
{
solveb[a] = letter;
}
else
{
flag+=1;
}
}
letter = 'N';
for(a=0; a<sizeof(bonus); a++)
{
if (letter == bonus[a])
{
solveb[a] = letter;
}
else
{
flag+=1;
}
}
letter = 'E';
for(a=0; a<sizeof(bonus); a++)
{
if (letter == bonus[a])
{
solveb[a] = letter;
}
else
{
flag+=1;
}
}
printf("\nThe letters picked are R, S, T, L, N, E.");
printf("\nThe puzzle is %s", solveb);
printf("\nThe size of the puzzle is %d.",sizeof(bonus));
printf("\nENTER in the whole puzzle.\n");
gets(solveb);
fflush(stdin);
flag=0;
for (a=0; a<sizeof(bonus); a++)
{
if (solveb[a] == bonus[a])
{
flag+=1;
}
else
{
printf("\nSorry that is incorrect.");
printf("\nThe correct puzzle is %s.\n",bonus);
if (num == 1)
printf("\n%s final score is %d.",playername[0], scores[0]);
else if (num == 2)
printf("\n%s final score is %d.",playername[1], scores[1]);
else if (num == 3)
printf("\n%s final score is %d.",playername[2], scores[2]);
getch();
break;
}
}
if (flag == sizeof(bonus))
{
printf("\nThat is correct. You win!");
getch();
printf("\n\n\n");
if (num == 1)
{
scores[0] += 25000;
printf("\n%s final score is %d.",playername[0], scores[0]);
}
else if (num == 2)
{
scores[1] += 25000;
printf("\n%s final score is %d.",playername[1], scores[1]);
}
else if (num == 3)
{
scores[2] += 25000;
printf("\n%s final score is %d.",playername[2], scores[2]);
}

}
test=0;
printf("\nThanks for playing.\nBye Bye!");
getch();
}

setMode (TEXT);
closegraph ();

return 0;
}

 
void Line (int x1, int y1, int x2, int y2, int color)
{
int dx, dy, xInc, yInc, error=0, i;
unsigned char far *vBptr = videoBuffer;

vBptr = vBptr + ((unsigned int) y1<<6) +
((unsigned int) y1<<8) +
(unsigned int) x1;

dx = x2 - x1;
dy = y2 - y1;

if (dx>=0)
{
xInc = 1;
}
else
{
xInc = -1;
dx = -dx;
}

if (dy>=0)
{
yInc = 320;
}
else
{
yInc = -320;
dy = -dy;
}

if (dx>dy)
{
for (i=0; i<=dx; i++)
{
*vBptr = color;
error += dy;
if (error>dx)
{
error -= dx;
vBptr += yInc;
}
vBptr += xInc;
}
}
else
{
for (i=0; i<=dy; i++)
{
*vBptr = color;
error += dx;
if (error>0)
{
error -= dy;
vBptr += xInc;
}
vBptr += yInc;
}
}
}

void Oval(int x0, int y0, int a, int b, int color)
{
int x, y; // midpoint algorithm is a
long aSquared, twoAsquared; // variation on Bresenham
long bSquared, twoBsquared;
long d, dx, dy;

x = 0;
y = b;
aSquared = a * a;
twoAsquared = 2 * aSquared;
bSquared = b * b;
twoBsquared = 2 * bSquared;
// initial excess distance d
d = bSquared - aSquared * b + aSquared / 4L;

dx = 0; // initial run and rise
dy = twoAsquared * b; // magnitudes dx and dy

while (dx < dy) { // slow slope > -1

putPixel(x0+x, y0+y, color);
putPixel(x0+x, y0-y, color);
putPixel(x0-x, y0+y, color);
putPixel(x0-x, y0-y, color);

if (d > 0) { // midpoint is outside
--y; // go down one line
dy -= twoAsquared;
d -= dy;
++x;
dx += twoBsquared;
d += bSquared + dx;
}
else {
++x; // midpoint is inside
dx += twoBsquared;
d += bSquared + dx;
}
}

// reset d for fast slope
d += (3L * (aSquared - bSquared) / 2L - (dx + dy)) / 2L;

while (y >= 0) { // fast slope < -1
putPixel(x0+x, y0+y, color);
putPixel(x0+x, y0-y, color);
putPixel(x0-x, y0+y, color);
putPixel(x0-x, y0-y, color);

if (d < 0) { // midpoint is outside
++x;
dx += twoBsquared;
d += dx;
}
--y; // midpoint is inside
dy -= twoAsquared;
d += aSquared - dy;
}
}