Category : A Collection of Games for DOS and Windows
Archive   : SPCWAR.ZIP
Filename : SWRSUBS.C

 
Output of file : SWRSUBS.C contained in archive : SPCWAR.ZIP
/*-----------------------------------------------------------
SPACEWAR

Support routines called from main SWR module
---- Dan Moore
-----------------------------------------------------------*/



#include
#include
#include
#include "swr.h"

int g_driver,g_mode,g_error;

extern graph G;
static CircX,CircY;

int Tsin[MAX_ANG+1];
int Tcos[MAX_ANG+1];

void init_tables(void)
{
int i;
for (i=0; i<=MAX_ANG; i++) {
Tcos[i]=(int)(.5+32767*cos(i*2.*PI/MAX_ANG));
Tsin[i]=(int)(.5+32767*sin(i*2.*PI/MAX_ANG));
}
}

void rotate(int *from, int *to,int npts,
int xpos, int ypos, int angle)
{
int i,j,Tx,Ty;
Tx=Tcos[angle]; Ty=Tsin[angle];
for (i=0; i *to++=Xscale(xpos+mul(from[0],Tx)-mul(from[1],Ty));
*to++=Yscale(ypos+mul(from[0],Ty)+mul(from[1],Tx));
from+=2;
}
}

void draw_p1(int p1r[][2])
{
ellipse(p1r[0][0],p1r[0][1],0,360, CircX,CircY);
line(p1r[1][0],p1r[1][1], p1r[2][0],p1r[2][1]);
line(p1r[3][0],p1r[3][1], p1r[4][0],p1r[4][1]);
line(p1r[5][0],p1r[5][1], p1r[6][0],p1r[6][1]);
line(p1r[7][0],p1r[7][1], p1r[8][0],p1r[8][1]);
}

void draw_p2(int p2r[][2])
{
moveto(p2r[0][0],p2r[0][1]);
lineto(p2r[1][0],p2r[1][1]);
lineto(p2r[2][0],p2r[2][1]);
lineto(p2r[3][0],p2r[3][1]);
lineto(p2r[4][0],p2r[4][1]);
lineto(p2r[0][0],p2r[0][1]);
}


void Init_Graph(void)
{
registerbgidriver(EGAVGA_driver);
registerbgidriver(CGA_driver);
registerbgidriver(Herc_driver);

detectgraph(&g_driver,&g_mode);


if (g_driver<0) {
printf("Must have graphics adapter !\n");
exit(1);
}
if (g_driver==CGA) g_mode=CGAC0;
initgraph(&g_driver,&g_mode,"");

g_error=graphresult();

if (g_error<0) {
printf("initgraph error: %s.\n",
grapherrormsg(g_error));
exit(1);
}

switch(g_driver) {
case CGA : G.green = CGA_LIGHTGREEN;
G.red = CGA_LIGHTRED;
G.yellow= G.pcolor= CGA_YELLOW;
break;
case EGA64 :
case EGA : G.green = EGA_LIGHTGREEN;
G.red = EGA_RED;
G.yellow = G.pcolor = EGA_YELLOW;
break;
case VGA : G.green = LIGHTGREEN;
G.red = RED;
G.yellow = YELLOW;
G.pcolor = WHITE;
break;
default : G.green = G.red =
G.yellow = G.pcolor = getmaxcolor();
}
G.black=0;

G.mx=getmaxx(); G.my=getmaxy();
G.XRatio = (unsigned)((double)G.mx*32767.0/10240.0);
G.YRatio = (unsigned)((double)G.my*32767.0/7680.0);
CircX=Xscale(96); CircY=Yscale(96);
}



  3 Responses to “Category : A Collection of Games for DOS and Windows
Archive   : SPCWAR.ZIP
Filename : SWRSUBS.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/