forked from keendreams/keen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kd_def.h
367 lines (277 loc) · 8.97 KB
/
kd_def.h
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
/* Keen Dreams (SDL2/Steam Port) Source Code
* Copyright (C) 2014 Javier M. Chavez
* Copyright (C) 2015 David Gow <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// KD_DEF.H
#include "id_heads.h"
#include "soft.h"
#include "sl_file.h"
#define FRILLS 1 // Cut out frills for 360K - MIKE MAYNARD
/*
=============================================================================
GLOBAL CONSTANTS
=============================================================================
*/
#define CREDITS 1
#define MAXACTORS MAXSPRITES
#define ACCGRAVITY 3
#define SPDMAXY 80
#define BLOCKSIZE (8*PIXGLOBAL) // for positioning starting actors
//
// movement scrolling edges
//
#define SCROLLEAST (TILEGLOBAL*11)
#define SCROLLWEST (TILEGLOBAL*9)
#define SCROLLSOUTH (TILEGLOBAL*8)
#define SCROLLNORTH (TILEGLOBAL*4)
#define CLIPMOVE 24 // speed to push out of a solid wall
#define GAMELEVELS 17
/*
=============================================================================
TYPES
=============================================================================
*/
typedef enum {notdone,resetgame,levelcomplete,warptolevel,died,victorious}
exittype;
typedef enum {nothing,keenobj,powerobj,doorobj,
bonusobj,broccoobj,tomatobj,carrotobj,celeryobj,asparobj,grapeobj,
taterobj,cartobj,frenchyobj,melonobj,turnipobj,cauliobj,brusselobj,
mushroomobj,squashobj,apelobj,peapodobj,peabrainobj,boobusobj,
shotobj,inertobj} classtype;
typedef struct
{
int16_t leftshapenum,rightshapenum;
enum {step,slide,think,stepthink,slidethink} progress;
boolean skippable;
boolean pushtofloor;
int16_t tictime;
int16_t xmove;
int16_t ymove;
void (*think) ();
void (*contact) ();
void (*react) ();
void *nextstate;
} statetype;
typedef struct
{
uint16_t worldx,worldy;
boolean leveldone[GAMELEVELS];
int32_t score,nextextra;
int16_t flowerpowers;
int16_t boobusbombs,bombsthislevel;
int16_t keys;
int16_t mapon;
int16_t lives;
int16_t difficulty;
} gametype;
typedef struct objstruct
{
classtype obclass;
enum {no,yes,allways,removable} active;
boolean needtoreact,needtoclip;
uint16_t nothink;
uint16_t x,y;
int16_t xdir,ydir;
int16_t xmove,ymove;
int16_t xspeed,yspeed;
int16_t ticcount,ticadjust;
statetype *state;
int16_t shapenum;
uint16_t left,top,right,bottom; // hit rectangle
uint16_t midx;
uint16_t tileleft,tiletop,tileright,tilebottom; // hit rect in tiles
uint16_t tilemidx;
int16_t hitnorth,hiteast,hitsouth,hitwest; // wall numbers contacted
int16_t temp1,temp2,temp3,temp4;
void *sprite;
struct objstruct *next,*prev;
} objtype;
PACKED_notypedef(BitMapHeader)
{
uint16_t w,h,x,y;
unsigned char d,trans,comp,pad;
};
PACKED_notypedef(BitMap) {
uint16_t Width;
uint16_t Height;
uint16_t Depth;
uint16_t BytesPerRow;
char far *Planes[8];
};
PACKED_notypedef(Shape) {
memptr Data;
uint32_t size;
uint16_t BPR;
struct BitMapHeader bmHdr;
};
PACKED(BufferedIO) {
int handle; // handle of file
memptr buffer; // pointer to buffer
word offset; // offset into buffer
word status; // read/write status
} BufferedIO;
/*
=============================================================================
KD_MAIN.C DEFINITIONS
=============================================================================
*/
extern char str[80],str2[20];
extern boolean singlestep,jumpcheat,godmode,tedlevel;
extern unsigned tedlevelnum;
void DebugMemory (void);
void TestSprites(void);
int DebugKeys (void);
void StartupId (void);
void ShutdownId (void);
void Quit (char *error);
void InitGame (void);
int main (int argc, char **argv);
/*
=============================================================================
KD_DEMO.C DEFINITIONS
=============================================================================
*/
void Finale (void);
void GameOver (void);
void DemoLoop (void);
void StatusWindow (void);
void NewGame (void);
void TEDDeath (void);
boolean LoadGame (int file);
boolean SaveGame (int file);
void ResetGame (void);
/*
=============================================================================
KD_PLAY.C DEFINITIONS
=============================================================================
*/
extern gametype gamestate;
extern exittype playstate;
extern boolean button0held,button1held;
extern unsigned originxtilemax,originytilemax;
extern objtype *new,*check,*player,*scoreobj;
extern ControlInfo c;
extern objtype dummyobj;
extern char *levelnames[21];
void CheckKeys (void);
void CalcInactivate (void);
void InitObjArray (void);
void GetNewObj (boolean usedummy);
void RemoveObj (objtype *gone);
void ScanInfoPlane (void);
void PatchWorldMap (void);
void MarkTileGraphics (void);
void FadeAndUnhook (void);
void SetupGameLevel (boolean loadnow);
void ScrollScreen (void);
void MoveObjVert (objtype *ob, int ymove);
void MoveObjHoriz (objtype *ob, int xmove);
void GivePoints (unsigned points);
void ClipToEnds (objtype *ob);
void ClipToEastWalls (objtype *ob);
void ClipToWestWalls (objtype *ob);
void ClipToWalls (objtype *ob);
void ClipToSprite (objtype *push, objtype *solid, boolean squish);
void ClipToSpriteSide (objtype *push, objtype *solid);
int DoActor (objtype *ob,int tics);
void StateMachine (objtype *ob);
void NewState (objtype *ob,statetype *state);
void PlayLoop (void);
void GameLoop (void);
/*
=============================================================================
KD_KEEN.C DEFINITIONS
=============================================================================
*/
void CalcSingleGravity (void);
void ProjectileThink (objtype *ob);
void VelocityThink (objtype *ob);
void DrawReact (objtype *ob);
void SpawnScore (void);
void FixScoreBox (void);
void SpawnWorldKeen (int tilex, int tiley);
void SpawnKeen (int tilex, int tiley, int dir);
void KillKeen (void);
extern int singlegravity;
extern unsigned bounceangle[8][8];
extern statetype s_keendie1;
/*
=============================================================================
KD_ACT1.C DEFINITIONS
=============================================================================
*/
void WalkReact (objtype *ob);
void DoGravity (objtype *ob);
void AccelerateX (objtype *ob,int dir,int max);
void FrictionX (objtype *ob);
void ProjectileThink (objtype *ob);
void VelocityThink (objtype *ob);
void DrawReact (objtype *ob);
void DrawReact2 (objtype *ob);
void DrawReact3 (objtype *ob);
void ChangeState (objtype *ob, statetype *state);
void ChangeToFlower (objtype *ob);
void SpawnBonus (int tilex, int tiley, int type);
void SpawnDoor (int tilex, int tiley);
void SpawnBrocco (int tilex, int tiley);
void SpawnTomat (int tilex, int tiley);
void SpawnCarrot (int tilex, int tiley);
void SpawnAspar (int tilex, int tiley);
void SpawnGrape (int tilex, int tiley);
extern statetype s_doorraise;
extern statetype s_bonus;
extern statetype s_bonusrise;
extern statetype s_broccosmash3;
extern statetype s_broccosmash4;
extern statetype s_grapefall;
/*
=============================================================================
KD_ACT2.C DEFINITIONS
=============================================================================
*/
void SpawnTater (int tilex, int tiley);
void SpawnCart (int tilex, int tiley);
void SpawnFrenchy (int tilex, int tiley);
void SpawnMelon (int tilex, int tiley,int dir);
void SpawnSquasher (int tilex, int tiley);
void SpawnApel (int tilex, int tiley);
void SpawnPeaPod (int tilex, int tiley);
void SpawnPeaBrain (int tilex, int tiley);
void SpawnBoobus (int tilex, int tiley);
extern statetype s_taterattack2;
extern statetype s_squasherjump2;
extern statetype s_boobusdie;
extern statetype s_deathwait1;
extern statetype s_deathwait2;
extern statetype s_deathwait3;
extern statetype s_deathboom1;
extern statetype s_deathboom2;
/////////////////////////////////////////////////////////////////////////////
//
// GELIB.C DEFINITIONS
//
/////////////////////////////////////////////////////////////////////////////
void FreeShape(struct Shape *shape);
int UnpackEGAShapeToScreen(struct Shape *SHP,int startx,int starty);
long Verify(char *filename);
memptr InitBufferedIO(int handle, BufferedIO *bio);
void FreeBufferedIO(BufferedIO *bio);
byte bio_readch(BufferedIO *bio);
void bio_fillbuffer(BufferedIO *bio);
void SwapLong(uint32_t *Var);
void SwapWord(uint16_t *Var);
void MoveGfxDst(short x, short y);