/*_|_| VESATEST.CPP PUBLIC DOMAIN PART 2 OF 2
_|_|_| Example of using 800x600 and 640x480 VESA modes.
_|_|_| No warrantee or guarantee. Kurt Kuzba. (8/24/1997)*/
void Vesamodes::Disk(int xc, int yc, int r, int c, int hg, int wd)
{
int l, x = 0, d = (1 - r) << 1, w = (wd / hg) << 1;
while(r >= 0)
{
for(l = xc - x; l <= xc + x; l++)
{ Dot(l, yc + r, c); Dot(l, yc - r, c); }
if(d + r > 0) d -= (w * --r) - 1;
if(x > d) d += ((++x) << 1) + 1;
}
}
void Vesamodes::~Vesamodes(void)
{
_asm{
mov ax, 0x03;
int 10h;
}
}
int rnd(int m){return (int)(((long)rand()*((long)m+1)-1)/RAND_MAX);}
void Vesamodes::Line(int x, int y, int x2, int y2, int c)
{
int i, steep = 0, sx, sy, dx, dy, e, ex, ey;
dx = abs(x2 - x);
sx = ((x2 - x) > 0) ? 1 : -1;
dy = abs(y2 - y);
sy = ((y2 - y) > 0) ? 1 : -1;
if(dy > dx)
{
steep = x; x = y; y = steep; /* swap x and y */
steep = dx; dx = dy; dy = steep; /* swap dx and dy */
steep = sx; sx = sy; sy = steep; /* swap sx and sy */
steep = 1;
}
e = 2 * dy - dx;
ex = dx << 1;
ey = dy << 1;
for(i = 0; i < dx; i++)
{
if(steep)
Dot(y, x, c);
else
Dot(x, y, c);
while(e >= 0)
{
y += sy;
e -= ex;
}
x += sx;
e += ey;
}
Dot(x2, y2, c);
}
void test(Vesamodes *V, int W = 640, int H = 480)
{
while(!kbhit())
{
V->Line(rnd(W), rnd(H), rnd(W), rnd(H), rnd(255));
V->Circle(rnd(W), rnd(H), rnd(200), rnd(255));
V->Circle(rnd(W), rnd(H), rnd(200), rnd(255),
10 + rnd(100), 10 + rnd(100));
V->Circle(rnd(W), rnd(H), rnd(20), rnd(255),
10 + rnd(100), 10 + rnd(100), 1);
}
}
int main(void)
{
time_t TM = time(NULL);
srand((unsigned)TM);
cout << "Hit any key to test 800x600x256" << endl;
getch();
Vesamodes *VM = new Vesamodes (800);
test(VM, 800, 600);
delete VM;
cout << "Hit any key to test 640x480x256" << endl;
getch();
getch();
VM = new Vesamodes;
test(VM);
delete VM;
cout << "Hit any key to exit Vesatest.cpp" << endl;
getch();
getch();
return 0;
}
/*_|_| end VESATEST.CPP PUBLIC DOMAIN PART 2 OF 2 */
> ] I had moral fibre once, but I did not inhale. [ B. Clinton ]
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)
|