TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: KARL CASAVANT
from: KURT KUZBA
date: 1998-05-13 06:41:00
subject: Mode12h.CPP 4/4

 /*_|_|   MODE12H.CPP   PUBLIC DOMAIN   ( part 4 of 4 )
 _|_|_|   Simple demonstration of pixel manipulation
 _|_|_|   in 640x480x16 video mode 12h.
 _|_|_|   Kurt Kuzba   (5/13/1998)*/
// begin main program
typedef struct {
   int y, x;
} LineEnd;
int rnd(int l, int h)
{
   return ( rand() % (h - l + 1) ) + l;
}
void test(Mode12h &V)
{
   LineEnd xy[20] = {
      {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
      {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
      {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, };
   int loop, c, xd[2], yd[2], change;
   xd[0] = rnd(2, 4);
   xd[1] = rnd(2, 4);
   yd[0] = rnd(2, 4);
   xd[1] = rnd(2, 4);
   change = c = 0;
   while(!kbhit())
   {
      if((change = ((change + 1) & 255)) == 0)
         c = rnd(0, 15);
      for(loop = 0; loop < 2; loop++)
      {
         xy[loop + 18] = xy[loop + 16];
         xy[loop + 16] = xy[loop + 14];
         xy[loop + 14] = xy[loop + 12];
         xy[loop + 12] = xy[loop + 10];
         xy[loop + 10] = xy[loop + 8];
         xy[loop + 8] = xy[loop + 6];
         xy[loop + 6] = xy[loop + 4];
         xy[loop + 4] = xy[loop + 2];
         xy[loop + 2] = xy[loop];
         if(xy[loop].x < 1)
            xd[loop] = rnd(3, 7);
         if(xy[loop].x > 478)
            xd[loop] = -rnd(3, 7);
         if(xy[loop].y < 1)
            yd[loop] =  rnd(3, 7);
         if(xy[loop].y > 638)
            yd[loop] = -rnd(3, 7);
         xy[loop].x += xd[loop];
         xy[loop].y += yd[loop];
      }
      V.Line(xy[18].y, xy[18].x, xy[19].y, xy[19].x, c);
      V.Line(xy[16].y, xy[16].x, xy[17].y, xy[17].x, 1);
      V.Line(xy[14].y, xy[14].x, xy[15].y, xy[15].x, 1);
      V.Line(xy[12].y, xy[12].x, xy[13].y, xy[13].x, 9);
      V.Line(xy[10].y, xy[10].x, xy[11].y, xy[11].x, 9);
      V.Line(xy[8].y, xy[8].x, xy[9].y, xy[9].x, 3);
      V.Line(xy[6].y, xy[6].x, xy[7].y, xy[7].x, 3);
      V.Line(xy[4].y, xy[4].x, xy[5].y, xy[5].x, 11);
      V.Line(xy[2].y, xy[2].x, xy[3].y, xy[3].x, 11);
      V.Line(xy[0].y, xy[0].x, xy[1].y, xy[1].x, 15);
   }
   getch();
}
int main(void)
{
   Mode12h *Vid = new Mode12h;
   srand((unsigned)time(NULL));
   test(*Vid);
   delete Vid;
   getch();
   return 0;
}
 /*_|_|   end   MODE12H.CPP   PUBLIC DOMAIN   ( part 4 of 4 )*/
> ] If they could reason there would be no argument.............
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.