1 /* Keen Dreams Source Code
\r
2 * Copyright (C) 2014 Javier M. Chavez
\r
4 * This program is free software; you can redistribute it and/or modify
\r
5 * it under the terms of the GNU General Public License as published by
\r
6 * the Free Software Foundation; either version 2 of the License, or
\r
7 * (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License along
\r
15 * with this program; if not, write to the Free Software Foundation, Inc.,
\r
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
21 #include "ID_HEADS.H"
\r
24 #include "SL_FILE.H"
\r
26 #define FRILLS 0 // Cut out frills for 360K - MIKE MAYNARD
\r
30 =============================================================================
\r
34 =============================================================================
\r
39 #define MAXACTORS MAXSPRITES
\r
41 #define ACCGRAVITY 3
\r
44 #define BLOCKSIZE (8*PIXGLOBAL) // for positioning starting actors
\r
47 // movement scrolling edges
\r
49 #define SCROLLEAST (TILEGLOBAL*11)
\r
50 #define SCROLLWEST (TILEGLOBAL*9)
\r
51 #define SCROLLSOUTH (TILEGLOBAL*8)
\r
52 #define SCROLLNORTH (TILEGLOBAL*4)
\r
54 #define CLIPMOVE 24 // speed to push out of a solid wall
\r
56 #define GAMELEVELS 17
\r
59 =============================================================================
\r
63 =============================================================================
\r
66 typedef enum {notdone,resetgame,levelcomplete,warptolevel,died,victorious}
\r
69 typedef enum {nothing,keenobj,powerobj,doorobj,
\r
70 bonusobj,broccoobj,tomatobj,carrotobj,celeryobj,asparobj,grapeobj,
\r
71 taterobj,cartobj,frenchyobj,melonobj,turnipobj,cauliobj,brusselobj,
\r
72 mushroomobj,squashobj,apelobj,peapodobj,peabrainobj,boobusobj,
\r
73 shotobj,inertobj} classtype;
\r
77 int leftshapenum,rightshapenum;
\r
78 enum {step,slide,think,stepthink,slidethink} progress;
\r
81 boolean pushtofloor;
\r
94 unsigned worldx,worldy;
\r
95 boolean leveldone[GAMELEVELS];
\r
96 long score,nextextra;
\r
98 int boobusbombs,bombsthislevel;
\r
106 typedef struct objstruct
\r
109 enum {no,yes,allways,removable} active;
\r
110 boolean needtoreact,needtoclip;
\r
118 int ticcount,ticadjust;
\r
123 unsigned left,top,right,bottom; // hit rectangle
\r
125 unsigned tileleft,tiletop,tileright,tilebottom; // hit rect in tiles
\r
128 int hitnorth,hiteast,hitsouth,hitwest; // wall numbers contacted
\r
130 int temp1,temp2,temp3,temp4;
\r
134 struct objstruct *next,*prev;
\r
138 struct BitMapHeader {
\r
139 unsigned int w,h,x,y;
\r
140 unsigned char d,trans,comp,pad;
\r
144 unsigned int Width;
\r
145 unsigned int Height;
\r
146 unsigned int Depth;
\r
147 unsigned int BytesPerRow;
\r
148 char far *Planes[8];
\r
155 struct BitMapHeader bmHdr;
\r
159 int handle; // handle of file
\r
160 memptr buffer; // pointer to buffer
\r
161 word offset; // offset into buffer
\r
162 word status; // read/write status
\r
168 =============================================================================
\r
170 KD_MAIN.C DEFINITIONS
\r
172 =============================================================================
\r
175 extern char str[80],str2[20];
\r
176 extern boolean singlestep,jumpcheat,godmode,tedlevel;
\r
177 extern unsigned tedlevelnum;
\r
179 void DebugMemory (void);
\r
180 void TestSprites(void);
\r
181 int DebugKeys (void);
\r
182 void StartupId (void);
\r
183 void ShutdownId (void);
\r
184 void Quit (char *error);
\r
185 void InitGame (void);
\r
190 =============================================================================
\r
192 KD_DEMO.C DEFINITIONS
\r
194 =============================================================================
\r
197 void Finale (void);
\r
198 void GameOver (void);
\r
199 void DemoLoop (void);
\r
200 void StatusWindow (void);
\r
201 void NewGame (void);
\r
202 void TEDDeath (void);
\r
204 boolean LoadGame (int file);
\r
205 boolean SaveGame (int file);
\r
206 void ResetGame (void);
\r
209 =============================================================================
\r
211 KD_PLAY.C DEFINITIONS
\r
213 =============================================================================
\r
216 extern gametype gamestate;
\r
217 extern exittype playstate;
\r
218 extern boolean button0held,button1held;
\r
219 extern unsigned originxtilemax,originytilemax;
\r
220 extern objtype *new,*check,*player,*scoreobj;
\r
222 extern ControlInfo c;
\r
224 extern objtype dummyobj;
\r
226 extern char *levelnames[21];
\r
228 void CheckKeys (void);
\r
229 void CalcInactivate (void);
\r
230 void InitObjArray (void);
\r
231 void GetNewObj (boolean usedummy);
\r
232 void RemoveObj (objtype *gone);
\r
233 void ScanInfoPlane (void);
\r
234 void PatchWorldMap (void);
\r
235 void MarkTileGraphics (void);
\r
236 void FadeAndUnhook (void);
\r
237 void SetupGameLevel (boolean loadnow);
\r
238 void ScrollScreen (void);
\r
239 void MoveObjVert (objtype *ob, int ymove);
\r
240 void MoveObjHoriz (objtype *ob, int xmove);
\r
241 void GivePoints (unsigned points);
\r
242 void ClipToEnds (objtype *ob);
\r
243 void ClipToEastWalls (objtype *ob);
\r
244 void ClipToWestWalls (objtype *ob);
\r
245 void ClipToWalls (objtype *ob);
\r
246 void ClipToSprite (objtype *push, objtype *solid, boolean squish);
\r
247 void ClipToSpriteSide (objtype *push, objtype *solid);
\r
248 int DoActor (objtype *ob,int tics);
\r
249 void StateMachine (objtype *ob);
\r
250 void NewState (objtype *ob,statetype *state);
\r
251 void PlayLoop (void);
\r
252 void GameLoop (void);
\r
255 =============================================================================
\r
257 KD_KEEN.C DEFINITIONS
\r
259 =============================================================================
\r
262 void CalcSingleGravity (void);
\r
264 void ProjectileThink (objtype *ob);
\r
265 void VelocityThink (objtype *ob);
\r
266 void DrawReact (objtype *ob);
\r
268 void SpawnScore (void);
\r
269 void FixScoreBox (void);
\r
270 void SpawnWorldKeen (int tilex, int tiley);
\r
271 void SpawnKeen (int tilex, int tiley, int dir);
\r
273 void KillKeen (void);
\r
275 extern int singlegravity;
\r
276 extern unsigned bounceangle[8][8];
\r
278 extern statetype s_keendie1;
\r
281 =============================================================================
\r
283 KD_ACT1.C DEFINITIONS
\r
285 =============================================================================
\r
288 void WalkReact (objtype *ob);
\r
290 void DoGravity (objtype *ob);
\r
291 void AccelerateX (objtype *ob,int dir,int max);
\r
292 void FrictionX (objtype *ob);
\r
294 void ProjectileThink (objtype *ob);
\r
295 void VelocityThink (objtype *ob);
\r
296 void DrawReact (objtype *ob);
\r
297 void DrawReact2 (objtype *ob);
\r
298 void DrawReact3 (objtype *ob);
\r
299 void ChangeState (objtype *ob, statetype *state);
\r
301 void ChangeToFlower (objtype *ob);
\r
303 void SpawnBonus (int tilex, int tiley, int type);
\r
304 void SpawnDoor (int tilex, int tiley);
\r
305 void SpawnBrocco (int tilex, int tiley);
\r
306 void SpawnTomat (int tilex, int tiley);
\r
307 void SpawnCarrot (int tilex, int tiley);
\r
308 void SpawnAspar (int tilex, int tiley);
\r
309 void SpawnGrape (int tilex, int tiley);
\r
311 extern statetype s_doorraise;
\r
313 extern statetype s_bonus;
\r
314 extern statetype s_bonusrise;
\r
316 extern statetype s_broccosmash3;
\r
317 extern statetype s_broccosmash4;
\r
319 extern statetype s_grapefall;
\r
322 =============================================================================
\r
324 KD_ACT2.C DEFINITIONS
\r
326 =============================================================================
\r
329 void SpawnTater (int tilex, int tiley);
\r
330 void SpawnCart (int tilex, int tiley);
\r
331 void SpawnFrenchy (int tilex, int tiley);
\r
332 void SpawnMelon (int tilex, int tiley,int dir);
\r
333 void SpawnSquasher (int tilex, int tiley);
\r
334 void SpawnApel (int tilex, int tiley);
\r
335 void SpawnPeaPod (int tilex, int tiley);
\r
336 void SpawnPeaBrain (int tilex, int tiley);
\r
337 void SpawnBoobus (int tilex, int tiley);
\r
339 extern statetype s_taterattack2;
\r
340 extern statetype s_squasherjump2;
\r
341 extern statetype s_boobusdie;
\r
343 extern statetype s_deathwait1;
\r
344 extern statetype s_deathwait2;
\r
345 extern statetype s_deathwait3;
\r
346 extern statetype s_deathboom1;
\r
347 extern statetype s_deathboom2;
\r
350 /////////////////////////////////////////////////////////////////////////////
\r
352 // GELIB.C DEFINITIONS
\r
354 /////////////////////////////////////////////////////////////////////////////
\r
356 void FreeShape(struct Shape *shape);
\r
357 int UnpackEGAShapeToScreen(struct Shape *SHP,int startx,int starty);
\r
359 long Verify(char *filename);
\r
360 memptr InitBufferedIO(int handle, BufferedIO *bio);
\r
361 void FreeBufferedIO(BufferedIO *bio);
\r
362 byte bio_readch(BufferedIO *bio);
\r
363 void bio_fillbuffer(BufferedIO *bio);
\r
364 void SwapLong(long far *Var);
\r
365 void SwapWord(unsigned int far *Var);
\r
366 void MoveGfxDst(short x, short y);