1
/* -------------------------------------------------------------------------
2
Gravity Wars v1.1, (C) Sami Niemi 1995, 1996
4
NOTES: [960824] [RELEASE NOTES 961101]
6
The game started as a bunch of fun routines that made the ship fly.
7
Later on I added collition control, and after P�r got involved with
8
the graphics I just couldn't stop... So, the structure of the game is
9
just terrible, with lots of unecessary variables , flags that
10
are used as variables etc.. I should've written the program in c++, and
11
for X! Svgalib just contains too many bugs..
13
I'd be fun to see this game ported to different operating systems, though
14
the structure of the game might make it hard, especially since I used
17
You're free to modify the code and the graphics as long as you write
18
that the original code was written by Sami Niemi, and the original
19
graphics were drawn by P�r Johannesson (If you're using any parts of
20
the original graphics)
22
I'd love to hear from any changes that you've made to the game!
28
http://www.kuai.se/~sniemi
29
http://www.efd.lth.se/~e96sn
34
getbox(x,y,*ptr) Gets the original graphics based on the block[]&level[]
35
getbox2(x,y,*ptr Gets the graphics directly from the screen
39
BUGS (i.e. I don't have the time to fix'em):
41
- consoleswitching takes away the splitscreen (real easy to fix)
43
------------------------------------------------------------------------- */
48
/*--------------------------------------------------------------------- main */
49
int main(int n_args, char *arg[]) {
62
char firstlevel[20]="levels/level01";
67
if (readlink(arg[0],buf,128)==-1)
72
if (buf[n--]=='/') break;
74
strcpy(gamename,"./");
80
gamenamelen=strlen(gamename);
88
} while ( (strncmp(arg[1],codes[n],6)) && (n<99));
92
delay_len=atoi(arg[2]);
94
if ((arg[1][0]<'0') || (arg[1][0]>'9')) {
95
printf("\nUsage: %s [code-to-a-given-level] [beam-adjustment]\n"
96
"(Sure you've got the right code?)\n\n",arg[0]);
100
delay_len=atoi(arg[1]);
106
strcpy(firstlevel,nextlevel);
109
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
111
"-----------------------------------------------------------------------------\n"
112
" G R A V I T Y W A R S\n\n"
116
" A Gravity Force clone for the Linux operating system\n"
119
" Coding by Sami Niemi\n\n"
121
" Graphics by P�r Johannesson\n"
123
"-----------------------------------------------------------------------------\n"
132
mouse_init("/dev/mouse", MOUSE_MICROSOFT, MOUSE_DEFAULTSAMPLERATE);
133
scans=keyboard_getstate();
148
getbox(old_x, old_y, shipback[0]);
149
putbox(old_x, old_y, shipback[0]);
157
win_y=(sy[0] >> STEP)-232;
167
y=(sy[0] >> STEP)-240;
173
gl_setdisplaystart(0,y);
176
putstamp(272,y+184,68,69,70);
179
for(pal_n=0; pal_n<=1024; pal_n+=16) {
180
for (pal_m=0; pal_m<=767; pal_m++)
181
p1[pal_m]=(((long)pal[pal_m])*pal_n)>>10;
188
for(pal_n=0; pal_n<=1024; pal_n+=16) {
189
for (pal_m=0; pal_m<=767; pal_m++)
190
p1[pal_m]=(((long)palB[pal_m])*pal_n)>>10;
199
killstamp(272,y+184);
206
/*------ The End --------*/
209
for(n=0; n<=4095; n++) {
210
tmpscore[n]=score[n];
211
score[n]=highscore[n];
214
tmp_long=Dec2BCD[ShipScore];
216
putdigit(1375,tmp_long>>16);
217
putdigit(1383,(tmp_long>>12)&15);
218
putdigit(1391,(tmp_long>>8)&15);
219
putdigit(1399,(tmp_long>>4)&15);
220
putdigit(1407,tmp_long&15);
222
if (ShipScore>HighScore) {
225
strcpy(filename,gamename);
226
strcpy(&filename[gamenamelen],"data/hscore.gw");
227
if ( ( fileptr=fopen(filename,"w") )!=NULL) {
228
fprintf(fileptr,"%d\n",ShipScore);
232
printf("Can't write the HighScore!!!!");
237
tmp_long=Dec2BCD[HighScore];
239
putdigit(1474,tmp_long>>16);
240
putdigit(1482,(tmp_long>>12)&15);
241
putdigit(1490,(tmp_long>>8)&15);
242
putdigit(1498,(tmp_long>>4)&15);
243
putdigit(1506,tmp_long&15);
245
putscoreOnly(0,win_y);
247
putstamp(272,win_y+192,54,60,61);
249
killstamp(272,win_y+192);
250
if (*(scans+SCANCODE_ESCAPE))
253
for(n=0; n<=4095; n++) {
254
score[n]=tmpscore[n];
258
for(pal_n=1024; pal_n>=0; pal_n-=16) {
259
for (pal_m=0; pal_m<=767; pal_m++)
260
p1[pal_m]=(((long)pal[pal_m])*pal_n)>>10;
267
for(pal_n=1024; pal_n>=0; pal_n-=16) {
268
for (pal_m=0; pal_m<=767; pal_m++)
269
p1[pal_m]=(((long)palB[pal_m])*pal_n)>>10;
276
strcpy(nextlevel,firstlevel);