File: memory.c

package info (click to toggle)
gravitywars 1.102-34
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,468 kB
  • ctags: 553
  • sloc: ansic: 3,938; makefile: 52; sh: 52
file content (344 lines) | stat: -rw-r--r-- 9,087 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
/* GravityWars 1.1,  (C) Sami Niemi -95 */

#include "includes.h"

#define SIZE 1.5  /* Sinus Table Size */

FILE *fileptr;

char gamename[128];
int gamenamelen;

char buffer[320*33]; /* The Gfx is save on a 320*x screen, with lines
			between the objects.. -> only 9 objects per line */


/* The Buffer for the Ships and The Backgrounds (2 ships supported!) */

uchar ship[4][32][32*32];  /* 32 frames of ships 32*32 */
/*    ship[0][..][..]=Ship#1
          [1]        =Ship#2
          [2]        =Thrust#1
          [3]        =Thrust#2
*/

uchar shipremo[2][32*32]; /* Not only ships */
uchar shipback[2][32*32]; /* Not only ships */
uchar shipbackM[32*32];
uchar shipmix[32*32];

uchar block[216+N_DESTROYEABLE][32*32]; /* Allocate Mem for the Gfx blocks */
uchar level[20*45];                     /* Level Gfx Map */
uchar objects[20*45+80];                /* Level Object Map */ 
                                        /* +80 to avoid too long lines */
uchar backgnd[32*32*4];

uchar actionback[N_ACTION][32*32];
uchar actionmix[32*32];

uchar tmpmix[32*32];

uchar bulletback[N_BULLETS+1][9];

uchar bulletgfx[9]= { 
                     12,13,12,
		     13,14,13,
		     12,13,12
		   };

uchar score[256*16];
uchar scoreback[256*16];
uchar digits[88*6];
uchar numbers[880]; /* old was 800 ?? */
uchar highscore[4096];
uchar levelcode[4096];
uchar tmpscore[4096];
uchar fonts[1820];

/*uchar LEVEL[128],AUTHOR[128],COMMENT[128],*/
uchar nextlevel[128];


short n_cexcept,n_anim; /* Number of these.. */
 
long SIN[32]={  399*SIZE,  783*SIZE, 1137*SIZE, 1448*SIZE,
		  1702*SIZE, 1892*SIZE, 2008*SIZE, 2048*SIZE,  
	       2008*SIZE, 1892*SIZE, 1702*SIZE, 1448*SIZE,
		  1137*SIZE,  783*SIZE,  399*SIZE, 0*SIZE,           
	       -399*SIZE, -783*SIZE,-1137*SIZE,-1448*SIZE,
		  -1702*SIZE,-1892*SIZE,-2008*SIZE,-2048*SIZE,        
	      -2008*SIZE,-1892*SIZE,-1702*SIZE,-1448*SIZE,
		  -1137*SIZE, -783*SIZE, -399*SIZE, 0*SIZE};

long bigsin[256];	       

uchar hole[2][1024]={
                    {
 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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0
 			
		    }
		  };

struct excepttype {
  uchar type;
  short x,y;
} c_except[N_CEXCEPT];

struct animtype {
  short x,y,start,stop,frame,speed;
} anim[N_ANIM+1];

struct actiontype {
  short x,y,start,stop,frame,state,speed,delay;
} action[N_ACTION+1];

uchar pal[768],palB[768],realpal[768],realpal2[768];

struct bullettype {
  long x,y,ang,xs,ys,dis,type;
  unsigned char active;
} bullet[N_BULLETS+1];

struct wipetype {    /* Stores a block 2 B destryed in vertical blank. */ 
  int x,y,active;
} wipe;

/* sx/sy=coord, sa=angle
   sV=Velocity(x,y, gravity),
   sA=Acceleration
   sf=Flags 

*/

/* Original Ship Coordinates for the level */
long Lsx[2],Lsy[2];

/* s=  Ship X/Y
   os= Old Ship X/Y
   a=  Angle
   V=  Velocity
   A=  Acceleration
   f=  flags (explosion state [0-5], etc.)
*/
long sx[2],sy[2],osx[2],osy[2],sa[2],sVx[2],sVy[2],sVg[2],sA[2],sf[2];
long gravity,lift_thrust,medium,friction;


/* sf=[0-5] Explotion State */


uchar *vga_ptr; 
uchar *scans;

short angX[32],angY[32];
short loadtime[2]={0,0};
short win_y;
short anim_frame;
short col_frame;

uchar ship_flag=0; /* 0=STILL 
		      1=WATER
		      2=??
		      */
uchar g_flag=0;

uchar ScoreChange=0;

short thrust_len=0;
short watercount=0;
short num_of_collisions=0;
short MaxNorm,MaxFall;            /* Max speeds */
uchar fueling; /* A flag for fueling on/off */

long  ShipScore=0;
long  HighScore=23456;
short ShipFuel; 
short ShipTime; 
short ShipLife=3;
short NumKeys;
short stop_x,stop_y;
short levelnum;

short old_x,old_y;

short BaseFuel,BaseTime,BaseLife;

long  delay_len=0;

long  Dec2BCD[100000];

uchar ending,escape=FALSE;

uchar p0[768],p1[768],p2[768],p3[768];
uchar p2B[768];

/* The easy way... */
char codes[100][6]={
 "jkfobt",
 "evfyvb",
 "tirtxq",
 "cqaryo",
 "vhhhcv",
 "alficj",
 "dgeigb",
 "lzjcvh",
 "uxxuqy",
 "knhsvl",
 "nxxvfb",
 "gijkrq",
 "merxjm",
 "gdlgae",
 "gkrnem",
 "zumypr",
 "zxaiht",
 "yvzqvi",
 "ebmsjo",
 "wpandf",
 "cezocq",
 "fdnhlu",
 "cmscen",
 "kkqyca",
 "oyppms",
 "uqytec",
 "jlfyvt",
 "sxfmbl",
 "zmvqmy",
 "qbwhqk",
 "ckaafg",
 "dquiop",
 "bioivq",
 "twepoq",
 "pgrloj",
 "yqvasa",
 "hvqbgg",
 "sjpgsm",
 "ynicez",
 "vtfohv",
 "yfnvfg",
 "wodorj",
 "xjtmsn",
 "asakxh",
 "jsargj",
 "mgoccw",
 "iakloe",
 "xnpszh",
 "fzchmz",
 "ovrrmz",
 "abgrdk",
 "nnkzya",
 "dxotpp",
 "cwreed",
 "duywln",
 "wmqcdt",
 "osgyrg",
 "yxgosv",
 "eusvby",
 "aesybg",
 "nzsdbx",
 "yppgpi",
 "ppfvex",
 "skumhv",
 "khbfhc",
 "lvbfae",
 "czvtfm",
 "buchpi",
 "gisawb",
 "xhizop",
 "dbmhgn",
 "lkmjdt",
 "xeoznf",
 "jupdwm",
 "euvmvj",
 "eykqfs",
 "dtcref",
 "lblbdz",
 "gmvyqt",
 "kupfhk",
 "qnjadq",
 "ujjwcn",
 "dnpoqu",
 "pxgmxw",
 "ghtxoa",
 "ieprgs",
 "hadtwg",
 "ibvzpm",
 "thlavi",
 "ydrrbf",
 "tjjicp",
 "blpgen",
 "mnoimf",
 "wgohik",
 "rgniyo",
 "nrzyab",
 "pdpgjt",
 "twijgx",
 "qcfhln",
 "tevimt"
 };