Category : C Source Code
Archive   : LSPD05-2.ZIP
Filename : 037.C

 
Output of file : 037.C contained in archive : LSPD05-2.ZIP
/* Light Speed Reference Example Program */
/* Line drawing */
#include "lspeed.h"
#include
#include

main()
{
/* Variables */
int lines[4][32], left_x_inc, right_x_inc, up_y_inc, down_y_inc;
unsigned char curline;

/* Set the graphics mode, register font */
set640x350();
registernicefont();

/* Seed the random numbers, set variables */
randomize();
left_x_inc=-2;
right_x_inc=2;
up_y_inc=2;
down_y_inc=2;

/* Print the press a key message */
ega_writetext(220, 335, LS_YELLOW, LS_BLUE, NICE_FONT,
" Press a key to stop... ");

/* Set up some lines */
lines[0][0] = 320;
lines[1][0] = 170;
lines[2][0] = 320;
lines[3][0] = 170;
for (curline=1; curline<32; curline++)
{
lines[0][curline] = lines[0][curline-1]+left_x_inc;
lines[1][curline] = lines[1][curline-1]+up_y_inc;
lines[2][curline] = lines[2][curline-1]+right_x_inc;
lines[3][curline] = lines[3][curline-1]+down_y_inc;
}

/* Draw the lines */
for (curline=0; curline<32; curline++)
ega_putline(lines[0][curline], lines[1][curline],
lines[2][curline], lines[3][curline], curline);
curline=31;

/* While there is no key... */
while (!kbhit())
{
curline++;

/* Erase the last line */
ega_putline(lines[0][curline&31], lines[1][curline&31],
lines[2][curline&31], lines[3][curline&31], 0);

/* Increment the first point */
lines[0][curline&31] = lines[0][(curline-1)&31]+left_x_inc;
if (lines[0][curline&31]<0) /* Out of range? */
{
left_x_inc=random(11)+3;
lines[0][curline&31]=0;
}
if (lines[0][curline&31]>639) /* Out of range? */
{
left_x_inc=-10+random(11)-3;
lines[0][curline&31]=639;
}

/* Increment the second point */
lines[1][curline&31] = lines[1][(curline-1)&31]+up_y_inc;
if (lines[1][curline&31]<0) /* Out of range? */
{
up_y_inc=random(11)+3;
lines[1][curline&31]=0;
}
if (lines[1][curline&31]>334) /* Out of range? */
{
up_y_inc=-10+random(11)-3;
lines[1][curline&31]=334;
}

/* Increment the third point */
lines[2][curline&31] = lines[2][(curline-1)&31]+right_x_inc;
if (lines[2][curline&31]<0) /* Out of range? */
{
right_x_inc=random(11)+3;
lines[2][curline&31]=0;
}
if (lines[2][curline&31]>639) /* Out of range? */
{
right_x_inc=-10+random(11)-3;
lines[2][curline&31]=639;
}

/* Increment the last point */
lines[3][curline&31] = lines[3][(curline-1)&31]+down_y_inc;
if (lines[3][curline&31]<0) /* Out of range? */
{
down_y_inc=random(11)+3;
lines[3][curline&31]=0;
}

if (lines[3][curline&31]>334) /* Out of range? */
{
down_y_inc=-10+random(11)-3;
lines[3][curline&31]=334;
}

/* Draw the newly updated line */
ega_putline(lines[0][curline&31], lines[1][curline&31],
lines[2][curline&31], lines[3][curline&31], curline);

/* Small microprocessor delay */
delay(5);
}

/* Exit the program */
getxch();
set80x25();
}



  3 Responses to “Category : C Source Code
Archive   : LSPD05-2.ZIP
Filename : 037.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/