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

 
Output of file : 162.C contained in archive : LSPD05-2.ZIP
/* Light Speed Reference Example Program */
/* Demonstrate the image manipulation routines */
#include "lspeed.h"

/* Memory allocation */
#include
#include

/* Global variables */
char far *heli1, far *heli2, far *heli3, far *heli4;

main()
{
/* Variables */
int loop, xloc, yloc;
unsigned char image;
unsigned int key;

/* Set graphics, install the font */
set320x200();
registerstandardfont();

/* Write a 'wait' message */
ega_writetext(10, 10, LS_YELLOW, LS_BLACK, STANDARD_FONT,
"Please wait, loading data...");

/* Allocate data for the images */
heli1=farmalloc(ega_imagesize(0,0,46,40));
heli2=farmalloc(ega_imagesize(0,0,46,40));
heli3=farmalloc(ega_imagesize(0,0,46,40));
heli4=farmalloc(ega_imagesize(0,0,46,40));

/* Check for any that didn't allocate */
if (heli1==NULL || heli2==NULL || heli3==NULL || heli4==NULL)
{
/* De-allocate all images */
farfree(heli1); farfree(heli2);
farfree(heli3); farfree(heli4);
set80x25();
printf("Did not have enough memory to load data!\n");
exit(1);
}

/* Load into the hidden page */
ega_setapage(2);
if (ega_restore_area_byte("heli.img",0,0,187,37,0,2)==-2)
{
farfree(heli1); farfree(heli2);
farfree(heli3); farfree(heli4);
set80x25();
printf("Could not find 'HELI.IMG' image file...\n");
exit(1);
}

/* Save the images */
ega_getimage( 0, 0, 46, 40, heli1);
ega_getimage( 47, 0, 93, 40, heli2);
ega_getimage( 94, 0,140, 40, heli3);
ega_getimage(141, 0,187, 40, heli4);

/* Clear all pages, initialize mouse */
set320x200();

/* Write instructions */
ega_writetext(0, 0, LS_WHITE, LS_BLACK, STANDARD_FONT,
"Use cursor keys to control, Esc to stop");

/* Variables setup */
image=0;
xloc=150;
yloc=75;

/* Loop */
loop:
if (kbhit())
key=getxch(); /* Key available */
else
key=0; /* No key */

/* ESC aborts */
if (key==0x011B)
{
set80x25();
farfree(heli1); farfree(heli2);
farfree(heli3); farfree(heli4);
set80x25();
exit(0);
}

/* Test for directions */
switch (key)
{
case 0x4800 : /* UP */
yloc--; yloc--;
if (yloc<10)
yloc=10;
break;
case 0x4900 : /* UP-RIGHT */
yloc--; yloc--;
if (yloc<10)
yloc=10;
xloc++; xloc++;
if (xloc>272)
xloc=272;
break;
case 0x4700 : /* UP-LEFT */
yloc--; yloc--;
if (yloc<10)
yloc=10;
xloc--; xloc--;
if (xloc<0)
xloc=0;
break;
case 0x5000 : /* DOWN */
yloc++; yloc++;
if (yloc>161)
yloc=161;
break;
case 0x5100 : /* DOWN-RIGHT */
yloc++; yloc++;
if (yloc>161)
yloc=161;
xloc++; xloc++;
if (xloc>272)
xloc=272;
break;
case 0x4F00 : /* DOWN-LEFT */
yloc++; yloc++;
if (yloc>161)
yloc=161;
xloc--; xloc--;
if (xloc<0)
xloc=0;
break;
case 0x4D00 : /* RIGHT */
xloc++; xloc++;
if (xloc>272)
xloc=272;
break;
case 0x4B00 : /* LEFT */
xloc--; xloc--;
if (xloc<0)
xloc=0;
break;
}

/* Update image */
image++;

/* Draw correct image */
if (image<7)
ega_putimage(heli1, xloc, yloc);
else if (image<14)
ega_putimage(heli2, xloc, yloc);
else if (image<21)
ega_putimage(heli3, xloc, yloc);
else if (image<28)
ega_putimage(heli4, xloc, yloc);
else
image=0; /* Out of range - reset */

/* Repeat cycle */
goto loop;
}


  3 Responses to “Category : C Source Code
Archive   : LSPD05-2.ZIP
Filename : 162.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/