1 /* 2 * OpenTyrian: A modern cross-platform port of Tyrian 3 * Copyright (C) 2007-2009 The OpenTyrian Development Team 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 #ifndef VARZ_H 20 #define VARZ_H 21 22 #include "episodes.h" 23 #include "opentyr.h" 24 #include "player.h" 25 #include "sprite.h" 26 27 #include <stdbool.h> 28 29 #define SA 7 30 31 enum 32 { 33 SA_NONE = 0, 34 SA_NORTSHIPZ = 7, 35 36 // only used for code entry 37 SA_DESTRUCT = 8, 38 SA_ENGAGE = 9, 39 40 // only used in pItems[P_SUPERARCADE] 41 SA_SUPERTYRIAN = 254, 42 SA_ARCADE = 255 43 }; 44 45 #define ENEMY_SHOT_MAX 60 /* 60*/ 46 47 #define CURRENT_KEY_SPEED 1 /*Keyboard/Joystick movement rate*/ 48 49 #define MAX_EXPLOSIONS 200 50 #define MAX_REPEATING_EXPLOSIONS 20 51 #define MAX_SUPERPIXELS 101 52 53 struct JE_SingleEnemyType 54 { 55 JE_byte fillbyte; 56 JE_integer ex, ey; /* POSITION */ 57 JE_shortint exc, eyc; /* CURRENT SPEED */ 58 JE_shortint exca, eyca; /* RANDOM ACCELERATION */ 59 JE_shortint excc, eycc; /* FIXED ACCELERATION WAITTIME */ 60 JE_shortint exccw, eyccw; 61 JE_byte armorleft; 62 JE_byte eshotwait[3], eshotmultipos[3]; /* [1..3] */ 63 JE_byte enemycycle; 64 JE_byte ani; 65 JE_word egr[20]; /* [1..20] */ 66 JE_byte size; 67 JE_byte linknum; 68 JE_byte aniactive; 69 JE_byte animax; 70 JE_byte aniwhenfire; 71 Sprite2_array *sprite2s; 72 JE_shortint exrev, eyrev; 73 JE_integer exccadd, eyccadd; 74 JE_byte exccwmax, eyccwmax; 75 void *enemydatofs; 76 JE_boolean edamaged; 77 JE_word enemytype; 78 JE_byte animin; 79 JE_word edgr; 80 JE_shortint edlevel; 81 JE_shortint edani; 82 JE_byte fill1; 83 JE_byte filter; 84 JE_integer evalue; 85 JE_integer fixedmovey; 86 JE_byte freq[3]; /* [1..3] */ 87 JE_byte launchwait; 88 JE_word launchtype; 89 JE_byte launchfreq; 90 JE_byte xaccel; 91 JE_byte yaccel; 92 JE_byte tur[3]; /* [1..3] */ 93 JE_word enemydie; /* Enemy created when this one dies */ 94 JE_boolean enemyground; 95 JE_byte explonum; 96 JE_word mapoffset; 97 JE_boolean scoreitem; 98 99 JE_boolean special; 100 JE_byte flagnum; 101 JE_boolean setto; 102 103 JE_byte iced; /*Duration*/ 104 105 JE_byte launchspecial; 106 107 JE_integer xminbounce; 108 JE_integer xmaxbounce; 109 JE_integer yminbounce; 110 JE_integer ymaxbounce; 111 JE_byte fill[3]; /* [1..3] */ 112 }; 113 114 typedef struct JE_SingleEnemyType JE_MultiEnemyType[100]; /* [1..100] */ 115 116 typedef JE_word JE_DanCShape[(24 * 28) / 2]; /* [1..(24*28) div 2] */ 117 118 typedef JE_char JE_CharString[256]; /* [1..256] */ 119 120 typedef JE_byte JE_Map1Buffer[24 * 28 * 13 * 4]; /* [1..24*28*13*4] */ 121 122 typedef JE_byte *JE_MapType[300][14]; /* [1..300, 1..14] */ 123 typedef JE_byte *JE_MapType2[600][14]; /* [1..600, 1..14] */ 124 typedef JE_byte *JE_MapType3[600][15]; /* [1..600, 1..15] */ 125 126 struct JE_EventRecType 127 { 128 JE_word eventtime; 129 JE_byte eventtype; 130 JE_integer eventdat, eventdat2; 131 JE_shortint eventdat3, eventdat5, eventdat6; 132 JE_byte eventdat4; 133 }; 134 135 struct JE_MegaDataType1 136 { 137 JE_MapType mainmap; 138 struct 139 { 140 JE_DanCShape sh; 141 } shapes[72]; /* [0..71] */ 142 JE_byte tempdat1; 143 /*JE_DanCShape filler;*/ 144 }; 145 146 struct JE_MegaDataType2 147 { 148 JE_MapType2 mainmap; 149 struct 150 { 151 JE_byte nothing[3]; /* [1..3] */ 152 JE_byte fill; 153 JE_DanCShape sh; 154 } shapes[71]; /* [0..70] */ 155 JE_byte tempdat2; 156 }; 157 158 struct JE_MegaDataType3 159 { 160 JE_MapType3 mainmap; 161 struct 162 { 163 JE_byte nothing[3]; /* [1..3] */ 164 JE_byte fill; 165 JE_DanCShape sh; 166 } shapes[70]; /* [0..69] */ 167 JE_byte tempdat3; 168 }; 169 170 typedef JE_byte JE_EnemyAvailType[100]; /* [1..100] */ 171 172 typedef struct { 173 JE_integer sx, sy; 174 JE_integer sxm, sym; 175 JE_shortint sxc, syc; 176 JE_byte tx, ty; 177 JE_word sgr; 178 JE_byte sdmg; 179 JE_byte duration; 180 JE_word animate; 181 JE_word animax; 182 JE_byte fill[12]; 183 } EnemyShotType; 184 185 typedef struct { 186 unsigned int ttl; 187 signed int x, y; 188 signed int delta_x, delta_y; 189 bool fixed_position; 190 bool follow_player; 191 unsigned int sprite; 192 } explosion_type; 193 194 typedef struct { 195 unsigned int delay; 196 unsigned int ttl; 197 unsigned int x, y; 198 bool big; 199 } rep_explosion_type; 200 201 typedef struct { 202 unsigned int x, y, z; 203 signed int delta_x, delta_y; 204 Uint8 color; 205 } superpixel_type; 206 207 extern JE_integer tempDat, tempDat2, tempDat3; 208 extern const JE_byte SANextShip[SA + 2]; 209 extern const JE_word SASpecialWeapon[SA]; 210 extern const JE_word SASpecialWeaponB[SA]; 211 extern const JE_byte SAShip[SA]; 212 extern const JE_word SAWeapon[SA][5]; 213 extern const JE_byte specialArcadeWeapon[PORT_NUM]; 214 extern const JE_byte optionSelect[16][3][2]; 215 extern const JE_word PGR[21]; 216 extern const JE_byte PAni[21]; 217 extern const JE_word linkGunWeapons[38]; 218 extern const JE_word chargeGunWeapons[38]; 219 extern const JE_byte randomEnemyLaunchSounds[3]; 220 extern const JE_byte keyboardCombos[26][8]; 221 extern const JE_byte shipCombosB[21]; 222 extern const JE_byte superTyrianSpecials[4]; 223 extern const JE_byte shipCombos[14][3]; 224 extern JE_byte SFCurrentCode[2][21]; 225 extern JE_byte SFExecuted[2]; 226 extern JE_byte lvlFileNum; 227 extern JE_word maxEvent, eventLoc; 228 extern JE_word tempBackMove, explodeMove; 229 extern JE_byte levelEnd; 230 extern JE_word levelEndFxWait; 231 extern JE_shortint levelEndWarp; 232 extern JE_boolean endLevel, reallyEndLevel, waitToEndLevel, playerEndLevel, normalBonusLevelCurrent, bonusLevelCurrent, smallEnemyAdjust, readyToEndLevel, quitRequested; 233 extern JE_byte newPL[10]; 234 extern JE_word returnLoc; 235 extern JE_boolean returnActive; 236 extern JE_word galagaShotFreq; 237 extern JE_longint galagaLife; 238 extern JE_boolean debug; 239 extern Uint32 debugTime, lastDebugTime; 240 extern JE_longint debugHistCount; 241 extern JE_real debugHist; 242 extern JE_word curLoc; 243 extern JE_boolean firstGameOver, gameLoaded, enemyStillExploding; 244 extern JE_word totalEnemy; 245 extern JE_word enemyKilled; 246 extern struct JE_MegaDataType1 megaData1; 247 extern struct JE_MegaDataType2 megaData2; 248 extern struct JE_MegaDataType3 megaData3; 249 extern JE_byte flash; 250 extern JE_shortint flashChange; 251 extern JE_byte displayTime; 252 253 extern bool play_demo, record_demo, stopped_demo; 254 extern Uint8 demo_num; 255 extern FILE *demo_file; 256 257 extern Uint8 demo_keys, next_demo_keys; 258 extern Uint16 demo_keys_wait; 259 260 extern JE_byte soundQueue[8]; 261 extern JE_boolean enemyContinualDamage; 262 extern JE_boolean enemiesActive; 263 extern JE_boolean forceEvents; 264 extern JE_boolean stopBackgrounds; 265 extern JE_byte stopBackgroundNum; 266 extern JE_byte damageRate; 267 extern JE_boolean background3x1; 268 extern JE_boolean background3x1b; 269 extern JE_boolean levelTimer; 270 extern JE_word levelTimerCountdown; 271 extern JE_word levelTimerJumpTo; 272 extern JE_boolean randomExplosions; 273 extern JE_boolean editShip1, editShip2; 274 extern JE_boolean globalFlags[10]; 275 extern JE_byte levelSong; 276 extern JE_boolean loadDestruct; 277 extern JE_word mapOrigin, mapPNum; 278 extern JE_byte mapPlanet[5], mapSection[5]; 279 extern JE_boolean moveTyrianLogoUp; 280 extern JE_boolean skipStarShowVGA; 281 extern JE_MultiEnemyType enemy; 282 extern JE_EnemyAvailType enemyAvail; 283 extern JE_word enemyOffset; 284 extern JE_word enemyOnScreen; 285 extern JE_byte enemyShapeTables[6]; 286 extern JE_word superEnemy254Jump; 287 extern explosion_type explosions[MAX_EXPLOSIONS]; 288 extern JE_integer explosionFollowAmountX, explosionFollowAmountY; 289 extern JE_boolean fireButtonHeld; 290 extern JE_boolean enemyShotAvail[ENEMY_SHOT_MAX]; 291 extern EnemyShotType enemyShot[ENEMY_SHOT_MAX]; 292 extern JE_byte zinglonDuration; 293 extern JE_byte astralDuration; 294 extern JE_word flareDuration; 295 extern JE_boolean flareStart; 296 extern JE_shortint flareColChg; 297 extern JE_byte specialWait; 298 extern JE_byte nextSpecialWait; 299 extern JE_boolean spraySpecial; 300 extern JE_byte doIced; 301 extern JE_boolean infiniteShot; 302 extern JE_boolean allPlayersGone; 303 extern const uint shadowYDist; 304 extern JE_real optionSatelliteRotate; 305 extern JE_integer optionAttachmentMove; 306 extern JE_boolean optionAttachmentLinked, optionAttachmentReturn; 307 extern JE_byte chargeWait, chargeLevel, chargeMax, chargeGr, chargeGrWait; 308 extern JE_word neat; 309 extern rep_explosion_type rep_explosions[MAX_REPEATING_EXPLOSIONS]; 310 extern superpixel_type superpixels[MAX_SUPERPIXELS]; 311 extern unsigned int last_superpixel; 312 extern JE_byte temp, temp2, temp3; 313 extern JE_word tempX, tempY; 314 extern JE_word tempW; 315 extern JE_boolean doNotSaveBackup; 316 extern JE_word x, y; 317 extern JE_integer b; 318 extern JE_byte **BKwrap1to, **BKwrap2to, **BKwrap3to, **BKwrap1, **BKwrap2, **BKwrap3; 319 extern JE_shortint specialWeaponFilter, specialWeaponFreq; 320 extern JE_word specialWeaponWpn; 321 extern JE_boolean linkToPlayer; 322 extern JE_word shipGr, shipGr2; 323 extern Sprite2_array *shipGrPtr, *shipGr2ptr; 324 325 static const int hud_sidekick_y[2][2] = 326 { 327 { 64, 82 }, // one player HUD 328 { 108, 126 }, // two player HUD 329 }; 330 331 void JE_getShipInfo( void ); 332 JE_word JE_SGr( JE_word ship, Sprite2_array **ptr ); 333 334 void JE_drawOptions( void ); 335 336 void JE_tyrianHalt( JE_byte code ); /* This ends the game */ 337 void JE_specialComplete( JE_byte playernum, JE_byte specialType ); 338 void JE_doSpecialShot( JE_byte playernum, uint *armor, uint *shield ); 339 340 void JE_wipeShieldArmorBars( void ); 341 JE_byte JE_playerDamage( JE_byte temp, Player * ); 342 343 void JE_setupExplosion( signed int x, signed int y, signed int delta_y, unsigned int type, bool fixed_position, bool follow_player ); 344 void JE_setupExplosionLarge( JE_boolean enemyground, JE_byte explonum, JE_integer x, JE_integer y ); 345 346 void JE_drawShield( void ); 347 void JE_drawArmor( void ); 348 349 JE_word JE_portConfigs( void ); 350 351 /*SuperPixels*/ 352 void JE_doSP( JE_word x, JE_word y, JE_word num, JE_byte explowidth, JE_byte color ); 353 void JE_drawSP( void ); 354 355 void JE_drawOptionLevel( void ); 356 357 358 #endif /* VARZ_H */ 359 360