OpenTyrian: merged upstream changes
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
OpenTyrian Classic Development Team
|
||||
The OpenTyrian Development Team
|
||||
================================================================================
|
||||
|
||||
Carl W. Reinke <mindless2112\100gmail\056com> (Mindless)
|
||||
Yuri K. Schlesner <yuriks.br@gmail.com> (yuriks)
|
||||
Yuri K. Schlesner <yuriks@yuriks.net> (yuriks)
|
||||
Casey A. McCann <syntaxglitch@gmail.com> (syntaxglitch)
|
||||
|
||||
== Contributors ================================================================
|
||||
@@ -24,8 +24,9 @@ Jan "heftig" Steffens clean-up patches
|
||||
Jason Emery
|
||||
* Tyrian source code
|
||||
|
||||
MAME and DOSBox
|
||||
* FM emulator code
|
||||
DOSBox
|
||||
* FM Sythesis emulator code
|
||||
|
||||
AdPlug
|
||||
* Loudness player
|
||||
* Loudness player code
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
OpenTyrian Classic
|
||||
OpenTyrian
|
||||
================================================================================
|
||||
|
||||
OpenTyrian is an open-source port of the DOS game Tyrian.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -428,4 +428,3 @@ int JE_playRunSkipDump( Uint8 *incomingBuffer, unsigned int IncomingBufferLength
|
||||
return(0);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -25,4 +25,3 @@ void JE_playAnim( const char *animfile, JE_byte startingframe, JE_byte speed );
|
||||
|
||||
#endif /* ANIMLIB_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "backgrnd.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "mtrand.h"
|
||||
#include "varz.h"
|
||||
#include "video.h"
|
||||
|
||||
@@ -465,4 +466,62 @@ void blur_filter( SDL_Surface *dst, SDL_Surface *src )
|
||||
}
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
/* Background Starfield */
|
||||
typedef struct
|
||||
{
|
||||
Uint8 color;
|
||||
JE_word position; // relies on overflow wrap-around
|
||||
int speed;
|
||||
} StarfieldStar;
|
||||
|
||||
#define MAX_STARS 100
|
||||
#define STARFIELD_HUE 0x90
|
||||
static StarfieldStar starfield_stars[MAX_STARS];
|
||||
int starfield_speed;
|
||||
|
||||
void initialize_starfield( void )
|
||||
{
|
||||
for (int i = MAX_STARS-1; i >= 0; --i)
|
||||
{
|
||||
starfield_stars[i].position = mt_rand() % 320 + mt_rand() % 200 * VGAScreen->pitch;
|
||||
starfield_stars[i].speed = mt_rand() % 3 + 2;
|
||||
starfield_stars[i].color = mt_rand() % 16 + STARFIELD_HUE;
|
||||
}
|
||||
}
|
||||
|
||||
void update_and_draw_starfield( SDL_Surface* surface, int move_speed )
|
||||
{
|
||||
Uint8* p = (Uint8*)surface->pixels;
|
||||
|
||||
for (int i = MAX_STARS-1; i >= 0; --i)
|
||||
{
|
||||
StarfieldStar* star = &starfield_stars[i];
|
||||
|
||||
star->position += (star->speed + move_speed) * surface->pitch;
|
||||
|
||||
if (star->position < 177 * surface->pitch)
|
||||
{
|
||||
if (p[star->position] == 0)
|
||||
{
|
||||
p[star->position] = star->color;
|
||||
}
|
||||
|
||||
// If star is bright enough, draw surrounding pixels
|
||||
if (star->color - 4 >= STARFIELD_HUE)
|
||||
{
|
||||
if (p[star->position + 1] == 0)
|
||||
p[star->position + 1] = star->color - 4;
|
||||
|
||||
if (star->position > 0 && p[star->position - 1] == 0)
|
||||
p[star->position - 1] = star->color - 4;
|
||||
|
||||
if (p[star->position + surface->pitch] == 0)
|
||||
p[star->position + surface->pitch] = star->color - 4;
|
||||
|
||||
if (star->position >= surface->pitch && p[star->position - surface->pitch] == 0)
|
||||
p[star->position - surface->pitch] = star->color - 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -34,6 +34,8 @@ extern JE_byte map1YDelay, map1YDelayMax, map2YDelay, map2YDelayMax;
|
||||
extern JE_boolean anySmoothies; // if yes, I want one :D
|
||||
extern JE_byte smoothie_data[9];
|
||||
|
||||
extern int starfield_speed;
|
||||
|
||||
void JE_darkenBackground( JE_word neat );
|
||||
|
||||
void blit_background_row( SDL_Surface *surface, int x, int y, Uint8 **map );
|
||||
@@ -54,6 +56,8 @@ void blur_filter( SDL_Surface *dst, SDL_Surface *src );
|
||||
/*smoothies #5 is used for 3*/
|
||||
/*smoothies #9 is a vertical flip*/
|
||||
|
||||
void initialize_starfield( void );
|
||||
void update_and_draw_starfield( SDL_Surface* surface, int move_speed );
|
||||
|
||||
#endif /* BACKGRND_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -138,14 +138,8 @@ const JE_EditorItemAvailType initialItemAvail =
|
||||
JE_boolean smoothies[9] = /* [1..9] */
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
|
||||
JE_byte starShowVGASpecialCode;
|
||||
|
||||
/* Stars */
|
||||
StarDatType starDat[MAX_STARS]; /* [1..Maxstars] */
|
||||
JE_word starY;
|
||||
|
||||
|
||||
/* CubeData */
|
||||
JE_word lastCubeMax, cubeMax;
|
||||
JE_word cubeList[4]; /* [1..4] */
|
||||
@@ -326,19 +320,6 @@ bool save_opentyrian_config( void )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void JE_setupStars( void )
|
||||
{
|
||||
int z;
|
||||
|
||||
for (z = MAX_STARS; z--; )
|
||||
{
|
||||
starDat[z].sLoc = (mt_rand() % 320) + (mt_rand() % 200) * VGAScreen->pitch;
|
||||
starDat[z].sMov = ((mt_rand() % 3) + 2) * VGAScreen->pitch;
|
||||
starDat[z].sC = (mt_rand() % 16) + (9 * 16);
|
||||
}
|
||||
}
|
||||
|
||||
static void playeritems_to_pitems( JE_PItemsType pItems, PlayerItems *items, JE_byte initial_episode_num )
|
||||
{
|
||||
pItems[0] = items->weapon[FRONT_WEAPON].id;
|
||||
@@ -403,7 +384,7 @@ void JE_saveGame( JE_byte slot, const char *name )
|
||||
temp = episodeNum - 1;
|
||||
if (temp < 1)
|
||||
{
|
||||
temp = 4; /* JE: {Episodemax is 4 for completion purposes} */
|
||||
temp = EPISODE_AVAILABLE; /* JE: {Episodemax is 4 for completion purposes} */
|
||||
}
|
||||
saveFiles[slot-1].episode = temp;
|
||||
}
|
||||
@@ -430,8 +411,6 @@ void JE_saveGame( JE_byte slot, const char *name )
|
||||
|
||||
void JE_loadGame( JE_byte slot )
|
||||
{
|
||||
JE_byte temp5;
|
||||
|
||||
superTyrian = false;
|
||||
onePlayerAction = false;
|
||||
twoPlayerMode = false;
|
||||
@@ -489,22 +468,22 @@ void JE_loadGame( JE_byte slot )
|
||||
player[twoPlayerMode ? port : 0].items.weapon[port].power = saveFiles[slot-1].power[port];
|
||||
}
|
||||
|
||||
temp5 = saveFiles[slot-1].episode;
|
||||
int episode = saveFiles[slot-1].episode;
|
||||
|
||||
memcpy(&levelName, &saveFiles[slot-1].levelName, sizeof(levelName));
|
||||
|
||||
if (strcmp(levelName, "Completed") == 0)
|
||||
{
|
||||
if (temp5 == 4)
|
||||
if (episode == EPISODE_AVAILABLE)
|
||||
{
|
||||
temp5 = 1;
|
||||
} else if (temp5 < 4) {
|
||||
temp5++;
|
||||
episode = 1;
|
||||
} else if (episode < EPISODE_AVAILABLE) {
|
||||
episode++;
|
||||
}
|
||||
/* Increment 1-3 to 2-4. Episode 4 goes to 1. Episode 5 stands still. */
|
||||
/* Increment episode. Episode EPISODE_AVAILABLE goes to 1. */
|
||||
}
|
||||
|
||||
JE_initEpisode(temp5);
|
||||
JE_initEpisode(episode);
|
||||
saveLevel = mainLevel;
|
||||
memcpy(&lastLevelName, &levelName, sizeof(levelName));
|
||||
}
|
||||
@@ -1050,4 +1029,3 @@ void JE_saveConfiguration( void )
|
||||
#endif
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -28,8 +28,6 @@
|
||||
|
||||
#define SAVE_FILES_NUM (11 * 2)
|
||||
|
||||
#define MAX_STARS 100
|
||||
|
||||
/* These are necessary because the size of the structure has changed from the original, but we
|
||||
need to know the original sizes in order to find things in TYRIAN.SAV */
|
||||
#define SAVE_FILES_SIZE 2398
|
||||
@@ -74,13 +72,6 @@ typedef struct
|
||||
typedef JE_SaveFileType JE_SaveFilesType[SAVE_FILES_NUM]; /* [1..savefilesnum] */
|
||||
typedef JE_byte JE_SaveGameTemp[SAVE_FILES_SIZE + 4 + 100]; /* [1..sizeof(savefilestype) + 4 + 100] */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
JE_byte sC;
|
||||
JE_word sLoc;
|
||||
JE_word sMov;
|
||||
} StarDatType;
|
||||
|
||||
extern const JE_byte cryptKey[10];
|
||||
extern const JE_KeySettingType defaultKeySettings;
|
||||
extern const char defaultHighScoreNames[34][23];
|
||||
@@ -88,8 +79,6 @@ extern const char defaultTeamNames[22][25];
|
||||
extern const JE_EditorItemAvailType initialItemAvail;
|
||||
extern JE_boolean smoothies[9];
|
||||
extern JE_byte starShowVGASpecialCode;
|
||||
extern StarDatType starDat[MAX_STARS];
|
||||
extern JE_word starY;
|
||||
extern JE_word lastCubeMax, cubeMax;
|
||||
extern JE_word cubeList[4];
|
||||
extern JE_boolean gameHasRepeated;
|
||||
@@ -158,8 +147,6 @@ const char *get_user_directory( void );
|
||||
void JE_loadConfiguration( void );
|
||||
void JE_saveConfiguration( void );
|
||||
|
||||
void JE_setupStars( void );
|
||||
|
||||
void JE_saveGame( JE_byte slot, const char *name );
|
||||
void JE_loadGame( JE_byte slot );
|
||||
|
||||
@@ -171,4 +158,3 @@ void save_json( cJSON *root, const char *filename );
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -25,4 +25,3 @@ void JE_destructGame( void );
|
||||
|
||||
#endif /* DESTRUCT_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -89,4 +89,3 @@ void JE_loadExtraShapes( void )
|
||||
}
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -34,4 +34,3 @@ void JE_loadExtraShapes( void );
|
||||
|
||||
#endif /* EDITSHIP_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/* MAIN Weapons Data */
|
||||
JE_WeaponPortType weaponPort;
|
||||
JE_WeaponType weapons;
|
||||
JE_WeaponType weapons[WEAP_NUM + 1]; /* [0..weapnum] */
|
||||
|
||||
/* Items */
|
||||
JE_PowerType powerSys;
|
||||
@@ -96,6 +96,12 @@ void JE_loadItemDat( void )
|
||||
efread(&weapons[i].shipblastfilter, sizeof(JE_byte), 1, f);
|
||||
}
|
||||
|
||||
#ifdef TYRIAN2000
|
||||
if (episodeNum <= 3) fseek(f, 0x252A4, SEEK_SET);
|
||||
if (episodeNum == 4) fseek(f, 0xC1F5E, SEEK_SET);
|
||||
if (episodeNum == 5) fseek(f, 0x5C5B8, SEEK_SET);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < PORT_NUM + 1; ++i)
|
||||
{
|
||||
fseek(f, 1, SEEK_CUR); /* skip string length */
|
||||
@@ -111,7 +117,15 @@ void JE_loadItemDat( void )
|
||||
efread(&weaponPort[i].poweruse, sizeof(JE_word), 1, f);
|
||||
}
|
||||
|
||||
for (int i = 0; i < SPECIAL_NUM + 1; ++i)
|
||||
int specials_count = SPECIAL_NUM;
|
||||
#ifdef TYRIAN2000
|
||||
if (episodeNum <= 3) fseek(f, 0x2662E, SEEK_SET);
|
||||
if (episodeNum == 4) fseek(f, 0xC32E8, SEEK_SET);
|
||||
if (episodeNum == 5) fseek(f, 0x5D942, SEEK_SET);
|
||||
if (episodeNum >= 4) specials_count = SPECIAL_NUM + 8; /*this ugly hack will need a fix*/
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < specials_count + 1; ++i)
|
||||
{
|
||||
fseek(f, 1, SEEK_CUR); /* skip string length */
|
||||
efread(&special[i].name, 1, 30, f);
|
||||
@@ -121,7 +135,13 @@ void JE_loadItemDat( void )
|
||||
efread(&special[i].stype, sizeof(JE_byte), 1, f);
|
||||
efread(&special[i].wpn, sizeof(JE_word), 1, f);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TYRIAN2000
|
||||
if (episodeNum <= 3) fseek(f, 0x26E21, SEEK_SET);
|
||||
if (episodeNum == 4) fseek(f, 0xC3ADB, SEEK_SET);
|
||||
if (episodeNum == 5) fseek(f, 0x5E135, SEEK_SET);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < POWER_NUM + 1; ++i)
|
||||
{
|
||||
fseek(f, 1, SEEK_CUR); /* skip string length */
|
||||
@@ -132,6 +152,12 @@ void JE_loadItemDat( void )
|
||||
efread(&powerSys[i].speed, sizeof(JE_byte), 1, f);
|
||||
efread(&powerSys[i].cost, sizeof(JE_word), 1, f);
|
||||
}
|
||||
|
||||
#ifdef TYRIAN2000
|
||||
if (episodeNum <= 3) fseek(f, 0x26F24, SEEK_SET);
|
||||
if (episodeNum == 4) fseek(f, 0xC3BDE, SEEK_SET);
|
||||
if (episodeNum == 5) fseek(f, 0x5E238, SEEK_SET);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < SHIP_NUM + 1; ++i)
|
||||
{
|
||||
@@ -146,6 +172,12 @@ void JE_loadItemDat( void )
|
||||
efread(&ships[i].cost, sizeof(JE_word), 1, f);
|
||||
efread(&ships[i].bigshipgraphic, sizeof(JE_byte), 1, f);
|
||||
}
|
||||
|
||||
#ifdef TYRIAN2000
|
||||
if (episodeNum <= 3) fseek(f, 0x2722F, SEEK_SET);
|
||||
if (episodeNum == 4) fseek(f, 0xC3EE9, SEEK_SET);
|
||||
if (episodeNum == 5) fseek(f, 0x5E543, SEEK_SET);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < OPTION_NUM + 1; ++i)
|
||||
{
|
||||
@@ -166,7 +198,13 @@ void JE_loadItemDat( void )
|
||||
efread(&options[i].stop, 1, 1, f); /* override sizeof(JE_boolean) */
|
||||
efread(&options[i].icongr, sizeof(JE_byte), 1, f);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TYRIAN2000
|
||||
if (episodeNum <= 3) fseek(f, 0x27EF3, SEEK_SET);
|
||||
if (episodeNum == 4) fseek(f, 0xC4BAD, SEEK_SET);
|
||||
if (episodeNum == 5) fseek(f, 0x5F207, SEEK_SET);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < SHIELD_NUM + 1; ++i)
|
||||
{
|
||||
fseek(f, 1, SEEK_CUR); /* skip string length */
|
||||
@@ -264,4 +302,3 @@ unsigned int JE_findNextEpisode( void )
|
||||
return newEpisode;
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -28,6 +28,11 @@
|
||||
|
||||
#define FIRST_LEVEL 1
|
||||
#define EPISODE_MAX 5
|
||||
#ifdef TYRIAN2000
|
||||
#define EPISODE_AVAILABLE 5
|
||||
#else
|
||||
#define EPISODE_AVAILABLE 4
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -46,7 +51,7 @@ typedef struct
|
||||
JE_byte sound;
|
||||
JE_byte trail;
|
||||
JE_byte shipblastfilter;
|
||||
} JE_WeaponType[WEAP_NUM + 1]; /* [0..weapnum] */
|
||||
} JE_WeaponType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -147,7 +152,7 @@ typedef struct
|
||||
} JE_EnemyDatType[ENEMY_NUM + 1]; /* [0..enemynum] */
|
||||
|
||||
extern JE_WeaponPortType weaponPort;
|
||||
extern JE_WeaponType weapons;
|
||||
extern JE_WeaponType weapons[WEAP_NUM + 1]; /* [0..weapnum] */
|
||||
extern JE_PowerType powerSys;
|
||||
extern JE_ShipType ships;
|
||||
extern JE_OptionType options[OPTION_NUM + 1]; /* [0..optionnum] */
|
||||
@@ -170,4 +175,3 @@ void JE_scanForEpisodes( void );
|
||||
|
||||
#endif /* EPISODES_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "SDL.h"
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
const char *custom_data_dir = ".";
|
||||
|
||||
@@ -76,11 +78,9 @@ FILE *dir_fopen( const char *dir, const char *file, const char *mode )
|
||||
// warn when dir_fopen fails
|
||||
FILE *dir_fopen_warn( const char *dir, const char *file, const char *mode )
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
FILE *f = dir_fopen(dir, file, mode);
|
||||
|
||||
if (!f)
|
||||
if (f == NULL)
|
||||
fprintf(stderr, "warning: failed to open '%s': %s\n", file, strerror(errno));
|
||||
|
||||
return f;
|
||||
@@ -89,14 +89,12 @@ FILE *dir_fopen_warn( const char *dir, const char *file, const char *mode )
|
||||
// die when dir_fopen fails
|
||||
FILE *dir_fopen_die( const char *dir, const char *file, const char *mode )
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
FILE *f = dir_fopen(dir, file, mode);
|
||||
|
||||
if (f == NULL)
|
||||
{
|
||||
fprintf(stderr, "error: failed to open '%s': %s\n", file, strerror(errno));
|
||||
fprintf(stderr, "error: One or more of the required Tyrian 2.1 data files could not be found.\n"
|
||||
fprintf(stderr, "error: One or more of the required Tyrian " TYRIAN_VERSION " data files could not be found.\n"
|
||||
" Please read the README file.\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -188,5 +186,3 @@ size_t efwrite( void *buffer, size_t size, size_t num, FILE *stream )
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -50,4 +50,3 @@ size_t efwrite( void *buffer, size_t size, size_t num, FILE *stream );
|
||||
|
||||
#endif // FILE_H
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include "fmopl.h"
|
||||
#include "fm_synth.h"
|
||||
#include "loudness.h"
|
||||
#include "opentyr.h"
|
||||
|
||||
const unsigned char op_table[9] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12};
|
||||
|
||||
#define opl 0
|
||||
|
||||
void opl_update( OPLSAMPLE *buf, int samples )
|
||||
{
|
||||
YM3812UpdateOne(opl, buf, samples);
|
||||
}
|
||||
|
||||
void opl_init( void )
|
||||
{
|
||||
YM3812Init(1, 3579545, 11025 * OUTPUT_QUALITY);
|
||||
}
|
||||
|
||||
void opl_deinit( void )
|
||||
{
|
||||
YM3812Shutdown();
|
||||
}
|
||||
|
||||
void opl_reset( void )
|
||||
{
|
||||
YM3812ResetChip(opl);
|
||||
}
|
||||
|
||||
void opl_write(int reg, int val)
|
||||
{
|
||||
YM3812Write(opl, 0, reg);
|
||||
YM3812Write(opl, 1, val);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef FM_SYNTH_H
|
||||
#define FM_SYNTH_H
|
||||
|
||||
#include "fmopl.h"
|
||||
#include "opentyr.h"
|
||||
|
||||
extern const unsigned char op_table[9]; /* the 9 operators as expected by the OPL2 */
|
||||
|
||||
void opl_update( OPLSAMPLE *buf, int samples );
|
||||
void opl_init( void );
|
||||
void opl_deinit( void );
|
||||
void opl_reset( void );
|
||||
void opl_write( int, int );
|
||||
|
||||
#endif /* FM_SYNTH_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,253 +0,0 @@
|
||||
#ifndef __FMOPL_H_
|
||||
#define __FMOPL_H_
|
||||
|
||||
/* --- select emulation chips --- */
|
||||
#define BUILD_YM3812 1 /* (HAS_YM3812) */
|
||||
#define BUILD_YM3526 (HAS_YM3526)
|
||||
#define BUILD_Y8950 (HAS_Y8950)
|
||||
|
||||
/* select output bits size of output : 8 or 16 */
|
||||
#define OPL_SAMPLE_BITS 16
|
||||
|
||||
/* compiler dependence */
|
||||
#ifndef OSD_CPU_H
|
||||
#define OSD_CPU_H
|
||||
typedef unsigned char UINT8; /* unsigned 8bit */
|
||||
typedef unsigned short UINT16; /* unsigned 16bit */
|
||||
typedef unsigned int UINT32; /* unsigned 32bit */
|
||||
typedef signed char INT8; /* signed 8bit */
|
||||
typedef signed short INT16; /* signed 16bit */
|
||||
typedef signed int INT32; /* signed 32bit */
|
||||
#endif
|
||||
|
||||
#if (OPL_SAMPLE_BITS==16)
|
||||
typedef INT16 OPLSAMPLE;
|
||||
#endif
|
||||
#if (OPL_SAMPLE_BITS==8)
|
||||
typedef INT8 OPLSAMPLE;
|
||||
#endif
|
||||
|
||||
|
||||
typedef void (*OPL_TIMERHANDLER)(int channel,double interval_Sec);
|
||||
typedef void (*OPL_IRQHANDLER)(int param,int irq);
|
||||
typedef void (*OPL_UPDATEHANDLER)(int param,int min_interval_us);
|
||||
typedef void (*OPL_PORTHANDLER_W)(int param,unsigned char data);
|
||||
typedef unsigned char (*OPL_PORTHANDLER_R)(int param);
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
UINT32 ar; /* attack rate: AR<<2 */
|
||||
UINT32 dr; /* decay rate: DR<<2 */
|
||||
UINT32 rr; /* release rate:RR<<2 */
|
||||
UINT8 KSR; /* key scale rate */
|
||||
UINT8 ksl; /* keyscale level */
|
||||
UINT8 ksr; /* key scale rate: kcode>>KSR */
|
||||
UINT8 mul; /* multiple: mul_tab[ML] */
|
||||
|
||||
/* Phase Generator */
|
||||
UINT32 Cnt; /* frequency counter */
|
||||
UINT32 Incr; /* frequency counter step */
|
||||
UINT8 FB; /* feedback shift value */
|
||||
INT32 *connect1; /* slot1 output pointer */
|
||||
INT32 op1_out[2]; /* slot1 output for feedback */
|
||||
UINT8 CON; /* connection (algorithm) type */
|
||||
|
||||
/* Envelope Generator */
|
||||
UINT8 eg_type; /* percussive/non-percussive mode */
|
||||
UINT8 state; /* phase type */
|
||||
UINT32 TL; /* total level: TL << 2 */
|
||||
INT32 TLL; /* adjusted now TL */
|
||||
INT32 volume; /* envelope counter */
|
||||
UINT32 sl; /* sustain level: sl_tab[SL] */
|
||||
UINT8 eg_sh_ar; /* (attack state) */
|
||||
UINT8 eg_sel_ar; /* (attack state) */
|
||||
UINT8 eg_sh_dr; /* (decay state) */
|
||||
UINT8 eg_sel_dr; /* (decay state) */
|
||||
UINT8 eg_sh_rr; /* (release state) */
|
||||
UINT8 eg_sel_rr; /* (release state) */
|
||||
UINT32 key; /* 0 = KEY OFF, >0 = KEY ON */
|
||||
|
||||
/* LFO */
|
||||
UINT32 AMmask; /* LFO Amplitude Modulation enable mask */
|
||||
UINT8 vib; /* LFO Phase Modulation enable flag (active high)*/
|
||||
|
||||
/* waveform select */
|
||||
unsigned int wavetable;
|
||||
} OPL_SLOT;
|
||||
|
||||
typedef struct{
|
||||
OPL_SLOT SLOT[2];
|
||||
/* phase generator state */
|
||||
UINT32 block_fnum; /* block+fnum */
|
||||
UINT32 fc; /* Freq. Increment base */
|
||||
UINT32 ksl_base; /* KeyScaleLevel Base step */
|
||||
UINT8 kcode; /* key code (for key scaling) */
|
||||
} OPL_CH;
|
||||
|
||||
/* OPL state */
|
||||
typedef struct fm_opl_f {
|
||||
/* FM channel slots */
|
||||
OPL_CH P_CH[9]; /* OPL/OPL2 chips have 9 channels*/
|
||||
|
||||
UINT32 eg_cnt; /* global envelope generator counter */
|
||||
UINT32 eg_timer; /* global envelope generator counter works at frequency = chipclock/72 */
|
||||
UINT32 eg_timer_add; /* step of eg_timer */
|
||||
UINT32 eg_timer_overflow; /* envelope generator timer overlfows every 1 sample (on real chip) */
|
||||
|
||||
UINT8 rhythm; /* Rhythm mode */
|
||||
|
||||
UINT32 fn_tab[1024]; /* fnumber->increment counter */
|
||||
|
||||
/* LFO */
|
||||
UINT8 lfo_am_depth;
|
||||
UINT8 lfo_pm_depth_range;
|
||||
UINT32 lfo_am_cnt;
|
||||
UINT32 lfo_am_inc;
|
||||
UINT32 lfo_pm_cnt;
|
||||
UINT32 lfo_pm_inc;
|
||||
|
||||
UINT32 noise_rng; /* 23 bit noise shift register */
|
||||
UINT32 noise_p; /* current noise 'phase' */
|
||||
UINT32 noise_f; /* current noise period */
|
||||
|
||||
UINT8 wavesel; /* waveform select enable flag */
|
||||
|
||||
int T[2]; /* timer counters */
|
||||
int TC[2];
|
||||
UINT8 st[2]; /* timer enable */
|
||||
|
||||
#if BUILD_Y8950
|
||||
/* Delta-T ADPCM unit (Y8950) */
|
||||
|
||||
YM_DELTAT *deltat;
|
||||
|
||||
/* Keyboard and I/O ports interface */
|
||||
UINT8 portDirection;
|
||||
UINT8 portLatch;
|
||||
OPL_PORTHANDLER_R porthandler_r;
|
||||
OPL_PORTHANDLER_W porthandler_w;
|
||||
int port_param;
|
||||
OPL_PORTHANDLER_R keyboardhandler_r;
|
||||
OPL_PORTHANDLER_W keyboardhandler_w;
|
||||
int keyboard_param;
|
||||
#endif
|
||||
|
||||
/* external event callback handlers */
|
||||
OPL_TIMERHANDLER TimerHandler; /* TIMER handler */
|
||||
int TimerParam; /* TIMER parameter */
|
||||
OPL_IRQHANDLER IRQHandler; /* IRQ handler */
|
||||
int IRQParam; /* IRQ parameter */
|
||||
OPL_UPDATEHANDLER UpdateHandler;/* stream update handler */
|
||||
int UpdateParam; /* stream update parameter */
|
||||
|
||||
UINT8 type; /* chip type */
|
||||
UINT8 address; /* address register */
|
||||
UINT8 status; /* status flag */
|
||||
UINT8 statusmask; /* status mask */
|
||||
UINT8 mode; /* Reg.08 : CSM,notesel,etc. */
|
||||
|
||||
int clock; /* master clock (Hz) */
|
||||
int rate; /* sampling rate (Hz) */
|
||||
double freqbase; /* frequency base */
|
||||
double TimerBase; /* Timer base time (==sampling time)*/
|
||||
} FM_OPL;
|
||||
|
||||
|
||||
|
||||
#if BUILD_YM3812
|
||||
|
||||
int YM3812Init(int num, int clock, int rate);
|
||||
void YM3812Shutdown(void);
|
||||
void YM3812ResetChip(int which);
|
||||
int YM3812Write(int which, int a, int v);
|
||||
unsigned char YM3812Read(int which, int a);
|
||||
int YM3812TimerOver(int which, int c);
|
||||
void YM3812UpdateOne(int which, OPLSAMPLE *buffer, int length);
|
||||
|
||||
void YM3812SetTimerHandler(int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
|
||||
void YM3812SetIRQHandler(int which, OPL_IRQHANDLER IRQHandler, int param);
|
||||
void YM3812SetUpdateHandler(int which, OPL_UPDATEHANDLER UpdateHandler, int param);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if BUILD_YM3526
|
||||
|
||||
/*
|
||||
** Initialize YM3526 emulator(s).
|
||||
**
|
||||
** 'num' is the number of virtual YM3526's to allocate
|
||||
** 'clock' is the chip clock in Hz
|
||||
** 'rate' is sampling rate
|
||||
*/
|
||||
int YM3526Init(int num, int clock, int rate);
|
||||
/* shutdown the YM3526 emulators*/
|
||||
void YM3526Shutdown(void);
|
||||
void YM3526ResetChip(int which);
|
||||
int YM3526Write(int which, int a, int v);
|
||||
unsigned char YM3526Read(int which, int a);
|
||||
int YM3526TimerOver(int which, int c);
|
||||
/*
|
||||
** Generate samples for one of the YM3526's
|
||||
**
|
||||
** 'which' is the virtual YM3526 number
|
||||
** '*buffer' is the output buffer pointer
|
||||
** 'length' is the number of samples that should be generated
|
||||
*/
|
||||
void YM3526UpdateOne(int which, INT16 *buffer, int length);
|
||||
|
||||
void YM3526SetTimerHandler(int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
|
||||
void YM3526SetIRQHandler(int which, OPL_IRQHANDLER IRQHandler, int param);
|
||||
void YM3526SetUpdateHandler(int which, OPL_UPDATEHANDLER UpdateHandler, int param);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if BUILD_Y8950
|
||||
|
||||
#include "ymdeltat.h"
|
||||
|
||||
/* Y8950 port handlers */
|
||||
void Y8950SetPortHandler(int which, OPL_PORTHANDLER_W PortHandler_w, OPL_PORTHANDLER_R PortHandler_r, int param);
|
||||
void Y8950SetKeyboardHandler(int which, OPL_PORTHANDLER_W KeyboardHandler_w, OPL_PORTHANDLER_R KeyboardHandler_r, int param);
|
||||
void Y8950SetDeltaTMemory(int which, void * deltat_mem_ptr, int deltat_mem_size );
|
||||
|
||||
int Y8950Init (int num, int clock, int rate);
|
||||
void Y8950Shutdown (void);
|
||||
void Y8950ResetChip (int which);
|
||||
int Y8950Write (int which, int a, int v);
|
||||
unsigned char Y8950Read (int which, int a);
|
||||
int Y8950TimerOver (int which, int c);
|
||||
void Y8950UpdateOne (int which, INT16 *buffer, int length);
|
||||
|
||||
void Y8950SetTimerHandler (int which, OPL_TIMERHANDLER TimerHandler, int channelOffset);
|
||||
void Y8950SetIRQHandler (int which, OPL_IRQHANDLER IRQHandler, int param);
|
||||
void Y8950SetUpdateHandler (int which, OPL_UPDATEHANDLER UpdateHandler, int param);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int limit( int val, int max, int min );
|
||||
void OPL_STATUS_SET(FM_OPL *OPL,int flag);
|
||||
void OPL_STATUS_RESET(FM_OPL *OPL,int flag);
|
||||
void OPL_STATUSMASK_SET(FM_OPL *OPL,int flag);
|
||||
void advance_lfo(FM_OPL *OPL);
|
||||
void advance(FM_OPL *OPL);
|
||||
signed int op_calc(UINT32 phase, unsigned int env, signed int pm, unsigned int wave_tab);
|
||||
signed int op_calc1(UINT32 phase, unsigned int env, signed int pm, unsigned int wave_tab);
|
||||
void OPL_CALC_CH( OPL_CH *CH );
|
||||
void OPL_CALC_RH( OPL_CH *CH, unsigned int noise );
|
||||
void FM_KEYON(OPL_SLOT *SLOT, UINT32 key_set);
|
||||
void FM_KEYOFF(OPL_SLOT *SLOT, UINT32 key_clr);
|
||||
void CALC_FCSLOT(OPL_CH *CH,OPL_SLOT *SLOT);
|
||||
void set_mul(FM_OPL *OPL,int slot,int v);
|
||||
void set_ksl_tl(FM_OPL *OPL,int slot,int v);
|
||||
void set_ar_dr(FM_OPL *OPL,int slot,int v);
|
||||
void set_sl_rr(FM_OPL *OPL,int slot,int v);
|
||||
void CSMKeyControll(OPL_CH *CH);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -20,10 +20,39 @@
|
||||
#include "fonthand.h"
|
||||
#include "sprite.h"
|
||||
|
||||
// like JE_dString() if (black == false && shadow_dist == 2 && hue == 15)
|
||||
// like JE_textShade() with PART_SHADE if (black == true && shadow_dist == 1)
|
||||
// like JE_outTextAndDarken() if (black == false && shadow_dist == 1)
|
||||
// like JE_outTextAdjust() with shadow if (black == false && shadow_dist == 2)
|
||||
/**
|
||||
* \file font.c
|
||||
* \brief Text drawing routines.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Draws text in a color specified by hue and value and with a drop
|
||||
* shadow.
|
||||
*
|
||||
* A '~' in the text is not drawn but instead toggles highlighting which
|
||||
* increases \c value by 4.
|
||||
*
|
||||
* \li like JE_dString() if (black == false && shadow_dist == 2 && hue == 15)
|
||||
* \li like JE_textShade() with PART_SHADE if (black == true && shadow_dist == 1)
|
||||
* \li like JE_outTextAndDarken() if (black == false && shadow_dist == 1)
|
||||
* \li like JE_outTextAdjust() with shadow if (black == false && shadow_dist == 2)
|
||||
*
|
||||
* @param surface destination surface
|
||||
* @param x initial x-position in pixels; which direction(s) the text is drawn
|
||||
* from this position depends on the alignment
|
||||
* @param y initial upper y-position in pixels
|
||||
* @param text text to be drawn
|
||||
* @param font style/size of text
|
||||
* @param alignment left_aligned, centered, or right_aligned
|
||||
* @param hue hue component of text color
|
||||
* @param value value component of text color
|
||||
* @param black if true the shadow is drawn as solid black, if false the shadow
|
||||
* is drawn by darkening the pixels of the destination surface
|
||||
* @param shadow_dist distance in pixels that the shadow will be drawn away from
|
||||
* the text. (This is added to both the x and y positions, so a value of
|
||||
* 1 causes the shadow to be drawn 1 pixel right and 1 pixel lower than
|
||||
* the text.)
|
||||
*/
|
||||
void draw_font_hv_shadow( SDL_Surface *surface, int x, int y, const char *text, Font font, FontAlignment alignment, Uint8 hue, Sint8 value, bool black, int shadow_dist )
|
||||
{
|
||||
draw_font_dark(surface, x + shadow_dist, y + shadow_dist, text, font, alignment, black);
|
||||
@@ -31,7 +60,32 @@ void draw_font_hv_shadow( SDL_Surface *surface, int x, int y, const char *text,
|
||||
draw_font_hv(surface, x, y, text, font, alignment, hue, value);
|
||||
}
|
||||
|
||||
// like JE_textShade() with FULL_SHADE if (black == true && shadow_dist == 1)
|
||||
/**
|
||||
* \brief Draws text in a color specified by hue and value and with a
|
||||
* surrounding shadow.
|
||||
*
|
||||
* A '~' in the text is not drawn but instead toggles highlighting which
|
||||
* increases \c value by 4.
|
||||
*
|
||||
* \li like JE_textShade() with FULL_SHADE if (black == true && shadow_dist == 1)
|
||||
*
|
||||
* @param surface destination surface
|
||||
* @param x initial x-position in pixels; which direction(s) the text is drawn
|
||||
* from this position depends on the alignment
|
||||
* @param y initial upper y-position in pixels
|
||||
* @param text text to be drawn
|
||||
* @param font style/size of text
|
||||
* @param alignment left_aligned, centered, or right_aligned
|
||||
* @param hue hue component of text color
|
||||
* @param value value component of text color
|
||||
* @param black if true the shadow is drawn as solid black, if false the shadow
|
||||
* is drawn by darkening the pixels of the destination surface
|
||||
* @param shadow_dist distance in pixels that the shadows will be drawn away
|
||||
* from the text. (This distance is separately added to and subtracted
|
||||
* from the x position and y position, resulting in four shadows -- one
|
||||
* in each cardinal direction. If this shadow distance is small enough,
|
||||
* this produces a shadow that outlines the text.)
|
||||
*/
|
||||
void draw_font_hv_full_shadow( SDL_Surface *surface, int x, int y, const char *text, Font font, FontAlignment alignment, Uint8 hue, Sint8 value, bool black, int shadow_dist )
|
||||
{
|
||||
draw_font_dark(surface, x, y - shadow_dist, text, font, alignment, black);
|
||||
@@ -42,8 +96,25 @@ void draw_font_hv_full_shadow( SDL_Surface *surface, int x, int y, const char *t
|
||||
draw_font_hv(surface, x, y, text, font, alignment, hue, value);
|
||||
}
|
||||
|
||||
// like JE_outText() with (brightness >= 0)
|
||||
// like JE_outTextAdjust() without shadow
|
||||
/**
|
||||
* \brief Draws text in a color specified by hue and value.
|
||||
*
|
||||
* A '~' in the text is not drawn but instead toggles highlighting which
|
||||
* increases \c value by 4.
|
||||
*
|
||||
* \li like JE_outText() with (brightness >= 0)
|
||||
* \li like JE_outTextAdjust() without shadow
|
||||
*
|
||||
* @param surface destination surface
|
||||
* @param x initial x-position in pixels; which direction(s) the text is drawn
|
||||
* from this position depends on the alignment
|
||||
* @param y initial upper y-position in pixels
|
||||
* @param text text to be drawn
|
||||
* @param font style/size of text
|
||||
* @param alignment left_aligned, centered, or right_aligned
|
||||
* @param hue hue component of text color
|
||||
* @param value value component of text color
|
||||
*/
|
||||
void draw_font_hv( SDL_Surface *surface, int x, int y, const char *text, Font font, FontAlignment alignment, Uint8 hue, Sint8 value )
|
||||
{
|
||||
switch (alignment)
|
||||
@@ -90,7 +161,23 @@ void draw_font_hv( SDL_Surface *surface, int x, int y, const char *text, Font fo
|
||||
}
|
||||
}
|
||||
|
||||
// like JE_outTextModify()
|
||||
/**
|
||||
* \brief Draws blended text in a color specified by hue and value.
|
||||
*
|
||||
* Corresponds to blit_sprite_hv_blend()
|
||||
*
|
||||
* \li like JE_outTextModify()
|
||||
*
|
||||
* @param surface destination surface
|
||||
* @param x initial x-position in pixels; which direction(s) the text is drawn
|
||||
* from this position depends on the alignment
|
||||
* @param y initial upper y-position in pixels
|
||||
* @param text text to be drawn
|
||||
* @param font style/size of text
|
||||
* @param alignment left_aligned, centered, or right_aligned
|
||||
* @param hue hue component of text color
|
||||
* @param value value component of text color
|
||||
*/
|
||||
void draw_font_hv_blend( SDL_Surface *surface, int x, int y, const char *text, Font font, FontAlignment alignment, Uint8 hue, Sint8 value )
|
||||
{
|
||||
switch (alignment)
|
||||
@@ -130,7 +217,23 @@ void draw_font_hv_blend( SDL_Surface *surface, int x, int y, const char *text, F
|
||||
}
|
||||
}
|
||||
|
||||
// like JE_outText() with (brightness < 0) if (black == true)
|
||||
/**
|
||||
* \brief Draws darkened text.
|
||||
*
|
||||
* Corresponds to blit_sprite_dark()
|
||||
*
|
||||
* \li like JE_outText() with (brightness < 0) if (black == true)
|
||||
*
|
||||
* @param surface destination surface
|
||||
* @param x initial x-position in pixels; which direction(s) the text is drawn
|
||||
* from this position depends on the alignment
|
||||
* @param y initial upper y-position in pixels
|
||||
* @param text text to be drawn
|
||||
* @param font style/size of text
|
||||
* @param alignment left_aligned, centered, or right_aligned
|
||||
* @param black if true text is drawn as solid black, if false text is drawn by
|
||||
* darkening the pixels of the destination surface
|
||||
*/
|
||||
void draw_font_dark( SDL_Surface *surface, int x, int y, const char *text, Font font, FontAlignment alignment, bool black )
|
||||
{
|
||||
switch (alignment)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -330,4 +330,3 @@ void JE_outTextGlow( SDL_Surface * screen, int x, int y, const char *s )
|
||||
textGlowBrightness = 6;
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -57,4 +57,3 @@ void JE_outTextGlow( SDL_Surface * screen, int x, int y, const char *s );
|
||||
|
||||
#endif /* FONTHAND_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -16,6 +16,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include "backgrnd.h"
|
||||
#include "config.h"
|
||||
#include "file.h"
|
||||
#include "fonthand.h"
|
||||
@@ -33,6 +34,7 @@
|
||||
#include "pcxmast.h"
|
||||
#include "picload.h"
|
||||
#include "player.h"
|
||||
#include "shots.h"
|
||||
#include "sprite.h"
|
||||
#include "tyrian2.h"
|
||||
#include "varz.h"
|
||||
@@ -66,7 +68,7 @@ static JE_MenuChoiceType menuChoices;
|
||||
static JE_integer col, colC;
|
||||
static JE_byte lastCurSel;
|
||||
static JE_integer curMenu;
|
||||
static JE_byte curSel[MAX_MENU]; /* [1..maxmenu] */
|
||||
static JE_byte curSel[MENU_MAX]; /* [1..maxmenu] */
|
||||
static JE_byte curItemType, curItem, cursor;
|
||||
static JE_boolean leftPower, rightPower, rightPowerAfford;
|
||||
static JE_byte currentCube;
|
||||
@@ -83,7 +85,7 @@ static PlayerItems old_items[2]; // TODO: should not be global if possible
|
||||
static struct cube_struct cube[4];
|
||||
|
||||
static const JE_MenuChoiceType menuChoicesDefault = { 7, 9, 8, 0, 0, 13, (SAVE_FILES_NUM / 2) + 2, 0, 0, 6, 4, 6, 7, 5 };
|
||||
static const JE_byte menuEsc[MAX_MENU] = { 0, 1, 1, 1, 2, 3, 3, 1, 8, 0, 0, 11, 3, 0 };
|
||||
static const JE_byte menuEsc[MENU_MAX] = { 0, 1, 1, 1, 2, 3, 3, 1, 8, 0, 0, 11, 3, 0 };
|
||||
static const JE_byte itemAvailMap[7] = { 1, 2, 3, 9, 4, 6, 7 };
|
||||
static const JE_word planetX[21] = { 200, 150, 240, 300, 270, 280, 320, 260, 220, 150, 160, 210, 80, 240, 220, 180, 310, 330, 150, 240, 200 };
|
||||
static const JE_word planetY[21] = { 40, 90, 90, 80, 170, 30, 50, 130, 120, 150, 220, 200, 80, 50, 160, 10, 55, 55, 90, 90, 40 };
|
||||
@@ -171,10 +173,8 @@ void JE_itemScreen( void )
|
||||
cursor = 1;
|
||||
curItem = 0;
|
||||
|
||||
for (int x = 0; x < MAX_MENU; x++)
|
||||
{
|
||||
curSel[x] = 2;
|
||||
}
|
||||
for (unsigned int i = 0; i < COUNTOF(curSel); ++i)
|
||||
curSel[i] = 2;
|
||||
|
||||
curMenu = 0;
|
||||
|
||||
@@ -546,7 +546,7 @@ void JE_itemScreen( void )
|
||||
temp_cost = 0;
|
||||
}
|
||||
|
||||
temp4 = (temp_cost > player[0].cash) ? 4 : 0; // can player afford current weapon at all
|
||||
int afford_shade = (temp_cost > player[0].cash) ? 4 : 0; // can player afford current weapon at all
|
||||
|
||||
temp = itemAvail[itemAvailMap[curSel[1]-2]-1][tempW-1]; /* Item ID */
|
||||
switch (curSel[1]-1)
|
||||
@@ -599,7 +599,7 @@ void JE_itemScreen( void )
|
||||
{
|
||||
strcpy(tempStr, miscText[13]);
|
||||
}
|
||||
JE_textShade(VGAScreen, 185, tempY, tempStr, temp2 / 16, temp2 % 16 -8-temp4, DARKEN);
|
||||
JE_textShade(VGAScreen, 185, tempY, tempStr, temp2 / 16, temp2 % 16 - 8 - afford_shade, DARKEN);
|
||||
|
||||
/* Draw icon if not DONE. NOTE: None is a normal item with a blank icon. */
|
||||
if (tempW < menuChoices[curMenu]-1)
|
||||
@@ -616,7 +616,7 @@ void JE_itemScreen( void )
|
||||
char buf[20];
|
||||
|
||||
snprintf(buf, sizeof buf, "Cost: %d", temp_cost);
|
||||
JE_textShade(VGAScreen, 187, tempY+10, buf, temp2 / 16, temp2 % 16 - 8 - temp4, DARKEN);
|
||||
JE_textShade(VGAScreen, 187, tempY+10, buf, temp2 / 16, temp2 % 16 - 8 - afford_shade, DARKEN);
|
||||
}
|
||||
}
|
||||
} /* /weapon upgrade */
|
||||
@@ -673,8 +673,8 @@ void JE_itemScreen( void )
|
||||
/* Changing the volume? */
|
||||
if ((curMenu == 2) || (curMenu == 11))
|
||||
{
|
||||
JE_barDrawShadow(VGAScreen, 225, 70, 1, 16, tyrMusicVolume / 12, 3, 13);
|
||||
JE_barDrawShadow(VGAScreen, 225, 86, 1, 16, fxVolume / 12, 3, 13);
|
||||
JE_barDrawShadow(VGAScreen, 225, 70, 1, music_disabled ? 12 : 16, tyrMusicVolume / 12, 3, 13);
|
||||
JE_barDrawShadow(VGAScreen, 225, 86, 1, samples_disabled ? 12 : 16, fxVolume / 12, 3, 13);
|
||||
}
|
||||
|
||||
/* 7 is data cubes menu, 8 is reading a data cube, "firstmenu9" refers to menu 8 because of reindexing */
|
||||
@@ -1132,34 +1132,34 @@ void JE_itemScreen( void )
|
||||
|
||||
if ((mouseY > 20) && (mouseX > 170) && (mouseX < 308) && (curMenu != 8))
|
||||
{
|
||||
const JE_byte mouseSelectionY[MAX_MENU] = { 16, 16, 16, 16, 26, 12, 11, 28, 0, 16, 16, 16, 8, 16 };
|
||||
const JE_byte mouseSelectionY[MENU_MAX] = { 16, 16, 16, 16, 26, 12, 11, 28, 0, 16, 16, 16, 8, 16 };
|
||||
|
||||
tempI = (mouseY - 38) / mouseSelectionY[curMenu]+2;
|
||||
int selection = (mouseY - 38) / mouseSelectionY[curMenu]+2;
|
||||
|
||||
if (curMenu == 9)
|
||||
{
|
||||
if (tempI > 5)
|
||||
tempI--;
|
||||
if (tempI > 3)
|
||||
tempI--;
|
||||
if (selection > 5)
|
||||
selection--;
|
||||
if (selection > 3)
|
||||
selection--;
|
||||
}
|
||||
|
||||
if (curMenu == 0)
|
||||
{
|
||||
if (tempI > 7)
|
||||
tempI = 7;
|
||||
if (selection > 7)
|
||||
selection = 7;
|
||||
}
|
||||
|
||||
// is play next level screen?
|
||||
if (curMenu == 3)
|
||||
{
|
||||
if (tempI == menuChoices[curMenu] + 1)
|
||||
tempI = menuChoices[curMenu];
|
||||
if (selection == menuChoices[curMenu] + 1)
|
||||
selection = menuChoices[curMenu];
|
||||
}
|
||||
|
||||
if (tempI <= menuChoices[curMenu])
|
||||
if (selection <= menuChoices[curMenu])
|
||||
{
|
||||
if ((curMenu == 4) && (tempI == menuChoices[4]))
|
||||
if ((curMenu == 4) && (selection == menuChoices[4]))
|
||||
{
|
||||
player[0].cash = JE_cashLeft();
|
||||
curMenu = 1;
|
||||
@@ -1168,13 +1168,13 @@ void JE_itemScreen( void )
|
||||
else
|
||||
{
|
||||
JE_playSampleNum(S_CLICK);
|
||||
if (curSel[curMenu] == tempI)
|
||||
if (curSel[curMenu] == selection)
|
||||
{
|
||||
JE_menuFunction(curSel[curMenu]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((curMenu == 5) && (JE_getCost(curSel[1], itemAvail[itemAvailMap[curSel[2]-1]][tempI-1]) > player[0].cash))
|
||||
if ((curMenu == 4) && (JE_getCost(curSel[1], itemAvail[itemAvailMap[curSel[2]-1]][selection-2]) > player[0].cash))
|
||||
{
|
||||
JE_playSampleNum(S_CLINK);
|
||||
}
|
||||
@@ -1183,7 +1183,7 @@ void JE_itemScreen( void )
|
||||
if (curSel[1] == 4)
|
||||
player[0].weapon_mode = 1;
|
||||
|
||||
curSel[curMenu] = tempI;
|
||||
curSel[curMenu] = selection;
|
||||
}
|
||||
|
||||
// in front or rear weapon upgrade screen?
|
||||
@@ -1584,6 +1584,7 @@ void JE_itemScreen( void )
|
||||
|
||||
} while (!(quit || gameLoaded || jumpSection));
|
||||
|
||||
#ifdef WITH_NETWORK
|
||||
if (!quit && isNetworkGame)
|
||||
{
|
||||
JE_barShade(VGAScreen, 3, 3, 316, 196);
|
||||
@@ -1624,6 +1625,7 @@ void JE_itemScreen( void )
|
||||
SDL_Delay(16);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gameLoaded)
|
||||
fade_black(10);
|
||||
@@ -2250,7 +2252,7 @@ void JE_initWeaponView( void )
|
||||
memset(shotRepeat, 1, sizeof(shotRepeat));
|
||||
memset(shotMultiPos, 0, sizeof(shotMultiPos));
|
||||
|
||||
JE_setupStars();
|
||||
initialize_starfield();
|
||||
}
|
||||
|
||||
void JE_computeDots( void )
|
||||
@@ -2329,26 +2331,28 @@ void JE_drawMainMenuHelpText( void )
|
||||
{
|
||||
int help[16] = { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 24, 11 };
|
||||
memcpy(tempStr, mainMenuHelp[help[curSel[curMenu] - 2]], sizeof(tempStr));
|
||||
} else if (curMenu < 3 || curMenu == 9 || curMenu > 10) {
|
||||
memcpy(tempStr, mainMenuHelp[(menuHelp[curMenu][temp])-1], sizeof(tempStr));
|
||||
} else {
|
||||
if (curMenu == 5 && curSel[5] == 10)
|
||||
{
|
||||
memcpy(tempStr, mainMenuHelp[25-1], sizeof(tempStr));
|
||||
}
|
||||
else if (leftPower || rightPower)
|
||||
{
|
||||
memcpy(tempStr, mainMenuHelp[24-1], sizeof(tempStr));
|
||||
}
|
||||
else if ( (temp == menuChoices[curMenu] - 1) || ( (curMenu == 7) && (cubeMax == 0) ) )
|
||||
{
|
||||
memcpy(tempStr, mainMenuHelp[12-1], sizeof(tempStr));
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(tempStr, mainMenuHelp[17 + curMenu - 3], sizeof(tempStr));
|
||||
}
|
||||
}
|
||||
else if (curMenu < 3 || curMenu == 9 || curMenu > 10)
|
||||
{
|
||||
memcpy(tempStr, mainMenuHelp[(menuHelp[curMenu][temp])-1], sizeof(tempStr));
|
||||
}
|
||||
else if (curMenu == 5 && curSel[5] == 10)
|
||||
{
|
||||
memcpy(tempStr, mainMenuHelp[25-1], sizeof(tempStr));
|
||||
}
|
||||
else if (leftPower || rightPower)
|
||||
{
|
||||
memcpy(tempStr, mainMenuHelp[24-1], sizeof(tempStr));
|
||||
}
|
||||
else if ( (temp == menuChoices[curMenu] - 1) || ( (curMenu == 7) && (cubeMax == 0) ) )
|
||||
{
|
||||
memcpy(tempStr, mainMenuHelp[12-1], sizeof(tempStr));
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(tempStr, mainMenuHelp[17 + curMenu - 3], sizeof(tempStr));
|
||||
}
|
||||
|
||||
JE_textShade(VGAScreen, 10, 187, tempStr, 14, 1, DARKEN);
|
||||
}
|
||||
|
||||
@@ -2453,6 +2457,7 @@ JE_boolean JE_quitRequest( void )
|
||||
|
||||
JE_playSampleNum(quit_selected ? S_SPRING : S_CLICK);
|
||||
|
||||
#ifdef WITH_NETWORK
|
||||
if (isNetworkGame && quit_selected)
|
||||
{
|
||||
network_prepare(PACKET_QUIT);
|
||||
@@ -2460,6 +2465,7 @@ JE_boolean JE_quitRequest( void )
|
||||
|
||||
network_tyrian_halt(0, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return quit_selected;
|
||||
}
|
||||
@@ -2730,8 +2736,6 @@ void JE_menuFunction( JE_byte select )
|
||||
|
||||
if (lastkey_sym != SDLK_ESCAPE && // reserved for menu
|
||||
lastkey_sym != SDLK_F11 && // reserved for gamma
|
||||
lastkey_sym != SDLK_s && // reserved for sample mute
|
||||
lastkey_sym != SDLK_m && // reserved for music mute
|
||||
lastkey_sym != SDLK_p) // reserved for pause
|
||||
{
|
||||
JE_playSampleNum(S_CLICK);
|
||||
@@ -3150,40 +3154,12 @@ void JE_weaponSimUpdate( void )
|
||||
|
||||
void JE_weaponViewFrame( void )
|
||||
{
|
||||
Uint8 *s; /* screen pointer, 8-bit specific */
|
||||
int i;
|
||||
|
||||
fill_rectangle_xy(VGAScreen, 8, 8, 143, 182, 0);
|
||||
|
||||
/* JE: (* Port Configuration Display *)
|
||||
(* drawportconfigbuttons;*/
|
||||
|
||||
/*===========================STARS==========================*/
|
||||
/*DRAWSTARS*/
|
||||
|
||||
for (i = MAX_STARS; i--;)
|
||||
{
|
||||
s = (Uint8 *)VGAScreen->pixels;
|
||||
|
||||
starDat[i].sLoc += starDat[i].sMov + VGAScreen->pitch;
|
||||
|
||||
if (starDat[i].sLoc < 177 * VGAScreen->pitch)
|
||||
{
|
||||
if (*(s + starDat[i].sLoc) == 0)
|
||||
*(s + starDat[i].sLoc) = starDat[i].sC;
|
||||
if (starDat[i].sC - 4 >= 9 * 16)
|
||||
{
|
||||
if (*(s + starDat[i].sLoc + 1) == 0)
|
||||
*(s + starDat[i].sLoc + 1) = starDat[i].sC - 4;
|
||||
if (starDat[i].sLoc > 0 && *(s + starDat[i].sLoc - 1) == 0)
|
||||
*(s + starDat[i].sLoc - 1) = starDat[i].sC - 4;
|
||||
if (*(s + starDat[i].sLoc + VGAScreen->pitch) == 0)
|
||||
*(s + starDat[i].sLoc + VGAScreen->pitch) = starDat[i].sC - 4;
|
||||
if (starDat[i].sLoc >= VGAScreen->pitch && *(s + starDat[i].sLoc - VGAScreen->pitch) == 0)
|
||||
*(s + starDat[i].sLoc - VGAScreen->pitch) = starDat[i].sC - 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
update_and_draw_starfield(VGAScreen, 1);
|
||||
|
||||
mouseX = player[0].x;
|
||||
mouseY = player[0].y;
|
||||
@@ -3201,7 +3177,7 @@ void JE_weaponViewFrame( void )
|
||||
item_power = player[0].items.weapon[i].power - 1,
|
||||
item_mode = (i == REAR_WEAPON) ? player[0].weapon_mode - 1 : 0;
|
||||
|
||||
JE_initPlayerShot(item, i, player[0].x, player[0].y, mouseX, mouseY, weaponPort[item].op[item_mode][item_power], 1);
|
||||
b = player_shot_create(item, i, player[0].x, player[0].y, mouseX, mouseY, weaponPort[item].op[item_mode][item_power], 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3217,7 +3193,7 @@ void JE_weaponViewFrame( void )
|
||||
const int x = player[0].sidekick[LEFT_SIDEKICK].x,
|
||||
y = player[0].sidekick[LEFT_SIDEKICK].y;
|
||||
|
||||
JE_initPlayerShot(options[item].wport, SHOT_LEFT_SIDEKICK, x, y, mouseX, mouseY, options[item].wpnum, 1);
|
||||
b = player_shot_create(options[item].wport, SHOT_LEFT_SIDEKICK, x, y, mouseX, mouseY, options[item].wpnum, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3244,87 +3220,11 @@ void JE_weaponViewFrame( void )
|
||||
const int x = player[0].sidekick[RIGHT_SIDEKICK].x,
|
||||
y = player[0].sidekick[RIGHT_SIDEKICK].y;
|
||||
|
||||
JE_initPlayerShot(options[item].wport, SHOT_RIGHT_SIDEKICK, x, y, mouseX, mouseY, options[item].wpnum, 1);
|
||||
b = player_shot_create(options[item].wport, SHOT_RIGHT_SIDEKICK, x, y, mouseX, mouseY, options[item].wpnum, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Player Shot Images */
|
||||
for (int z = 0; z < MAX_PWEAPON; z++)
|
||||
{
|
||||
if (shotAvail[z] != 0)
|
||||
{
|
||||
shotAvail[z]--;
|
||||
if (z != MAX_PWEAPON - 1)
|
||||
{
|
||||
playerShotData[z].shotXM += playerShotData[z].shotXC;
|
||||
|
||||
if (playerShotData[z].shotXM <= 100)
|
||||
playerShotData[z].shotX += playerShotData[z].shotXM;
|
||||
|
||||
playerShotData[z].shotYM += playerShotData[z].shotYC;
|
||||
playerShotData[z].shotY += playerShotData[z].shotYM;
|
||||
|
||||
if (playerShotData[z].shotYM > 100)
|
||||
{
|
||||
playerShotData[z].shotY -= 120;
|
||||
playerShotData[z].shotY += player[0].delta_y_shot_move;
|
||||
}
|
||||
|
||||
if (playerShotData[z].shotComplicated != 0)
|
||||
{
|
||||
playerShotData[z].shotDevX += playerShotData[z].shotDirX;
|
||||
playerShotData[z].shotX += playerShotData[z].shotDevX;
|
||||
|
||||
if (abs(playerShotData[z].shotDevX) == playerShotData[z].shotCirSizeX)
|
||||
playerShotData[z].shotDirX = -playerShotData[z].shotDirX;
|
||||
|
||||
playerShotData[z].shotDevY += playerShotData[z].shotDirY;
|
||||
playerShotData[z].shotY += playerShotData[z].shotDevY;
|
||||
|
||||
if (abs(playerShotData[z].shotDevY) == playerShotData[z].shotCirSizeY)
|
||||
playerShotData[z].shotDirY = -playerShotData[z].shotDirY;
|
||||
/*Double Speed Circle Shots - add a second copy of above loop*/
|
||||
}
|
||||
|
||||
int tempShotX = playerShotData[z].shotX;
|
||||
int tempShotY = playerShotData[z].shotY;
|
||||
|
||||
if (playerShotData[z].shotX < 0 || playerShotData[z].shotX > 140 ||
|
||||
playerShotData[z].shotY < 0 || playerShotData[z].shotY > 170)
|
||||
{
|
||||
shotAvail[z] = 0;
|
||||
goto draw_player_shot_loop_end;
|
||||
}
|
||||
|
||||
/* if (playerShotData[z].shotTrail != 255)
|
||||
{
|
||||
if (playerShotData[z].shotTrail == 98)
|
||||
{
|
||||
JE_setupExplosion(playerShotData[z].shotX - playerShotData[z].shotXM, playerShotData[z].shotY - playerShotData[z].shotYM, playerShotData[z].shotTrail);
|
||||
} else {
|
||||
JE_setupExplosion(playerShotData[z].shotX, playerShotData[z].shotY, playerShotData[z].shotTrail);
|
||||
}
|
||||
}*/
|
||||
|
||||
tempW = playerShotData[z].shotGr + playerShotData[z].shotAni;
|
||||
if (++playerShotData[z].shotAni == playerShotData[z].shotAniMax)
|
||||
playerShotData[z].shotAni = 0;
|
||||
|
||||
if (tempW < 6000)
|
||||
{
|
||||
if (tempW > 1000)
|
||||
tempW = tempW % 1000;
|
||||
if (tempW > 500)
|
||||
blit_sprite2(VGAScreen, tempShotX+1, tempShotY, shapesW2, tempW - 500);
|
||||
else
|
||||
blit_sprite2(VGAScreen, tempShotX+1, tempShotY, shapesC1, tempW);
|
||||
}
|
||||
}
|
||||
|
||||
draw_player_shot_loop_end:
|
||||
;
|
||||
}
|
||||
}
|
||||
simulate_player_shots();
|
||||
|
||||
blit_sprite(VGAScreenSeg, 0, 0, OPTION_SHAPES, 12); // upgrade interface
|
||||
|
||||
@@ -3371,4 +3271,3 @@ draw_player_shot_loop_end:
|
||||
//JE_waitFrameCount(); TODO: didn't do anything?
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "helptext.h"
|
||||
#include "opentyr.h"
|
||||
|
||||
typedef JE_byte JE_MenuChoiceType[MAX_MENU];
|
||||
typedef JE_byte JE_MenuChoiceType[MENU_MAX];
|
||||
|
||||
JE_longint JE_cashLeft( void );
|
||||
void JE_itemScreen( void );
|
||||
@@ -56,4 +56,3 @@ void JE_weaponViewFrame( void );
|
||||
|
||||
#endif // GAME_MENU_H
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const JE_byte menuHelp[MAX_MENU][11] = /* [1..maxmenu, 1..11] */
|
||||
const JE_byte menuHelp[MENU_MAX][11] = /* [1..maxmenu, 1..11] */
|
||||
{
|
||||
{ 1, 34, 2, 3, 4, 5, 0, 0, 0, 0, 0 },
|
||||
{ 6, 7, 8, 9, 10, 11, 11, 12, 0, 0, 0 },
|
||||
@@ -52,29 +52,29 @@ JE_byte helpBoxColor = 12;
|
||||
JE_byte helpBoxBrightness = 1;
|
||||
JE_byte helpBoxShadeType = FULL_SHADE;
|
||||
|
||||
char helpTxt[MAX_HELP_MESSAGE][231]; /* [1..maxhelpmessage] of string [230]; */
|
||||
char pName[21][16]; /* [1..21] of string [15] */
|
||||
char miscText[68][42]; /* [1..68] of string [41] */
|
||||
char miscTextB[5][11]; /* [1..5] of string [10] */
|
||||
char keyName[8][18]; /* [1..8] of string [17] */
|
||||
char menuText[7][21]; /* [1..7] of string [20] */
|
||||
char outputs[9][31]; /* [1..9] of string [30] */
|
||||
char topicName[6][21]; /* [1..6] of string [20] */
|
||||
char mainMenuHelp[34][66];
|
||||
char inGameText[6][21]; /* [1..6] of string [20] */
|
||||
char detailLevel[6][13]; /* [1..6] of string [12] */
|
||||
char gameSpeedText[5][13]; /* [1..5] of string [12] */
|
||||
char inputDevices[3][13]; /* [1..3] of string [12] */
|
||||
char networkText[4][22]; /* [1..4] of string [20] */
|
||||
char difficultyNameB[11][21]; /* [0..9] of string [20] */
|
||||
char joyButtonNames[5][21]; /* [1..5] of string [20] */
|
||||
char superShips[11][26]; /* [0..10] of string [25] */
|
||||
char specialName[9][10]; /* [1..9] of string [9] */
|
||||
char destructHelp[25][22];
|
||||
char weaponNames[17][17]; /* [1..17] of string [16] */
|
||||
char destructModeName[DESTRUCT_MODES][13]; /* [1..destructmodes] of string [12] */
|
||||
char shipInfo[13][2][256];
|
||||
char menuInt[MAX_MENU + 1][11][18]; /* [0..maxmenu, 1..11] of string [17] */
|
||||
char helpTxt[39][231]; /* [1..39] of string [230] */
|
||||
char pName[21][16]; /* [1..21] of string [15] */
|
||||
char miscText[HELPTEXT_MISCTEXT_COUNT][42]; /* [1..68] of string [41] */
|
||||
char miscTextB[HELPTEXT_MISCTEXTB_COUNT][HELPTEXT_MISCTEXTB_SIZE]; /* [1..5] of string [10] */
|
||||
char keyName[8][18]; /* [1..8] of string [17] */
|
||||
char menuText[7][HELPTEXT_MENUTEXT_SIZE]; /* [1..7] of string [20] */
|
||||
char outputs[9][31]; /* [1..9] of string [30] */
|
||||
char topicName[6][21]; /* [1..6] of string [20] */
|
||||
char mainMenuHelp[HELPTEXT_MAINMENUHELP_COUNT][66]; /* [1..34] of string [65] */
|
||||
char inGameText[6][21]; /* [1..6] of string [20] */
|
||||
char detailLevel[6][13]; /* [1..6] of string [12] */
|
||||
char gameSpeedText[5][13]; /* [1..5] of string [12] */
|
||||
char inputDevices[3][13]; /* [1..3] of string [12] */
|
||||
char networkText[HELPTEXT_NETWORKTEXT_COUNT][HELPTEXT_NETWORKTEXT_SIZE]; /* [1..4] of string [20] */
|
||||
char difficultyNameB[11][21]; /* [0..9] of string [20] */
|
||||
char joyButtonNames[5][21]; /* [1..5] of string [20] */
|
||||
char superShips[HELPTEXT_SUPERSHIPS_COUNT][26]; /* [0..10] of string [25] */
|
||||
char specialName[HELPTEXT_SPECIALNAME_COUNT][10]; /* [1..9] of string [9] */
|
||||
char destructHelp[25][22]; /* [1..25] of string [21] */
|
||||
char weaponNames[17][17]; /* [1..17] of string [16] */
|
||||
char destructModeName[DESTRUCT_MODES][13]; /* [1..destructmodes] of string [12] */
|
||||
char shipInfo[HELPTEXT_SHIPINFO_COUNT][2][256]; /* [1..13, 1..2] of string */
|
||||
char menuInt[MENU_MAX+1][11][18]; /* [0..14, 1..11] of string [17] */
|
||||
|
||||
|
||||
void decrypt_pascal_string( char *s, int len )
|
||||
@@ -174,210 +174,217 @@ void JE_HBox( SDL_Surface *screen, int x, int y, unsigned int messagenum, unsig
|
||||
|
||||
void JE_loadHelpText( void )
|
||||
{
|
||||
#ifdef TYRIAN2000
|
||||
const unsigned int menuInt_entries[MENU_MAX + 1] = { -1, 7, 9, 9, -1, -1, 11, -1, -1, -1, 7, 4, 6, 7, 5 };
|
||||
#else
|
||||
const unsigned int menuInt_entries[MENU_MAX + 1] = { -1, 7, 9, 8, -1, -1, 11, -1, -1, -1, 6, 4, 6, 7, 5 };
|
||||
#endif
|
||||
|
||||
FILE *f = dir_fopen_die(data_dir(), "tyrian.hdt", "rb");
|
||||
efread(&episode1DataLoc, sizeof(JE_longint), 1, f);
|
||||
|
||||
/*Online Help*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < MAX_HELP_MESSAGE; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(helpTxt); ++i)
|
||||
read_encrypted_pascal_string(helpTxt[i], sizeof(helpTxt[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Planet names*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 21; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(pName); ++i)
|
||||
read_encrypted_pascal_string(pName[i], sizeof(pName[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Miscellaneous text*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 68; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(miscText); ++i)
|
||||
read_encrypted_pascal_string(miscText[i], sizeof(miscText[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Little Miscellaneous text*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(miscTextB); ++i)
|
||||
read_encrypted_pascal_string(miscTextB[i], sizeof(miscTextB[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Key names*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 11; ++i)
|
||||
for (unsigned int i = 0; i < menuInt_entries[6]; ++i)
|
||||
read_encrypted_pascal_string(menuInt[6][i], sizeof(menuInt[6][i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Main Menu*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 7; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(menuText); ++i)
|
||||
read_encrypted_pascal_string(menuText[i], sizeof(menuText[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Event text*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 9; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(outputs); ++i)
|
||||
read_encrypted_pascal_string(outputs[i], sizeof(outputs[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Help topics*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 6; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(topicName); ++i)
|
||||
read_encrypted_pascal_string(topicName[i], sizeof(topicName[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Main Menu Help*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 34; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(mainMenuHelp); ++i)
|
||||
read_encrypted_pascal_string(mainMenuHelp[i], sizeof(mainMenuHelp[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Menu 1 - Main*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 7; ++i)
|
||||
for (unsigned int i = 0; i < menuInt_entries[1]; ++i)
|
||||
read_encrypted_pascal_string(menuInt[1][i], sizeof(menuInt[1][i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Menu 2 - Items*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 9; ++i)
|
||||
for (unsigned int i = 0; i < menuInt_entries[2]; ++i)
|
||||
read_encrypted_pascal_string(menuInt[2][i], sizeof(menuInt[2][i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Menu 3 - Options*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 8; ++i)
|
||||
for (unsigned int i = 0; i < menuInt_entries[3]; ++i)
|
||||
read_encrypted_pascal_string(menuInt[3][i], sizeof(menuInt[3][i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*InGame Menu*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 6; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(inGameText); ++i)
|
||||
read_encrypted_pascal_string(inGameText[i], sizeof(inGameText[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Detail Level*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 6; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(detailLevel); ++i)
|
||||
read_encrypted_pascal_string(detailLevel[i], sizeof(detailLevel[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Game speed text*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(gameSpeedText); ++i)
|
||||
read_encrypted_pascal_string(gameSpeedText[i], sizeof(gameSpeedText[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
// episode names
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i <= 5; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(episode_name); ++i)
|
||||
read_encrypted_pascal_string(episode_name[i], sizeof(episode_name[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
// difficulty names
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i <= 6; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(difficulty_name); ++i)
|
||||
read_encrypted_pascal_string(difficulty_name[i], sizeof(difficulty_name[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
// gameplay mode names
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i <= 4; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(gameplay_name); ++i)
|
||||
read_encrypted_pascal_string(gameplay_name[i], sizeof(gameplay_name[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Menu 10 - 2Player Main*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 6; ++i)
|
||||
for (unsigned int i = 0; i < menuInt_entries[10]; ++i)
|
||||
read_encrypted_pascal_string(menuInt[10][i], sizeof(menuInt[10][i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Input Devices*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(inputDevices); ++i)
|
||||
read_encrypted_pascal_string(inputDevices[i], sizeof(inputDevices[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Network text*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(networkText); ++i)
|
||||
read_encrypted_pascal_string(networkText[i], sizeof(networkText[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Menu 11 - 2Player Network*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (unsigned int i = 0; i < menuInt_entries[11]; ++i)
|
||||
read_encrypted_pascal_string(menuInt[11][i], sizeof(menuInt[11][i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*HighScore Difficulty Names*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i <= 10; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(difficultyNameB); ++i)
|
||||
read_encrypted_pascal_string(difficultyNameB[i], sizeof(difficultyNameB[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Menu 12 - Network Options*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 6; ++i)
|
||||
for (unsigned int i = 0; i < menuInt_entries[12]; ++i)
|
||||
read_encrypted_pascal_string(menuInt[12][i], sizeof(menuInt[12][i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Menu 13 - Joystick*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 7; ++i)
|
||||
for (unsigned int i = 0; i < menuInt_entries[13]; ++i)
|
||||
read_encrypted_pascal_string(menuInt[13][i], sizeof(menuInt[13][i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Joystick Button Assignments*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(joyButtonNames); ++i)
|
||||
read_encrypted_pascal_string(joyButtonNames[i], sizeof(joyButtonNames[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*SuperShips - For Super Arcade Mode*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i <= 10; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(superShips); ++i)
|
||||
read_encrypted_pascal_string(superShips[i], sizeof(superShips[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*SuperShips - For Super Arcade Mode*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 9; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(specialName); ++i)
|
||||
read_encrypted_pascal_string(specialName[i], sizeof(specialName[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Secret DESTRUCT game*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 25; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(destructHelp); ++i)
|
||||
read_encrypted_pascal_string(destructHelp[i], sizeof(destructHelp[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Secret DESTRUCT weapons*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 17; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(weaponNames); ++i)
|
||||
read_encrypted_pascal_string(weaponNames[i], sizeof(weaponNames[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*Secret DESTRUCT modes*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < DESTRUCT_MODES; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(destructModeName); ++i)
|
||||
read_encrypted_pascal_string(destructModeName[i], sizeof(destructModeName[i]), f);
|
||||
skip_pascal_string(f);
|
||||
|
||||
/*NEW: Ship Info*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 13; ++i)
|
||||
for (unsigned int i = 0; i < COUNTOF(shipInfo); ++i)
|
||||
{
|
||||
read_encrypted_pascal_string(shipInfo[i][0], sizeof(shipInfo[i][0]), f);
|
||||
read_encrypted_pascal_string(shipInfo[i][1], sizeof(shipInfo[i][1]), f);
|
||||
}
|
||||
skip_pascal_string(f);
|
||||
|
||||
|
||||
#ifndef TYRIAN2000
|
||||
/*Menu 12 - Network Options*/
|
||||
skip_pascal_string(f);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
for (unsigned int i = 0; i < menuInt_entries[14]; ++i)
|
||||
read_encrypted_pascal_string(menuInt[14][i], sizeof(menuInt[14][i]), f);
|
||||
|
||||
#endif
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -21,38 +21,66 @@
|
||||
|
||||
#include "opentyr.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_HELP_MESSAGE 39
|
||||
#define MAX_MENU 14
|
||||
#define MENU_MAX 14
|
||||
|
||||
#define DESTRUCT_MODES 5
|
||||
|
||||
extern const JE_byte menuHelp[MENU_MAX][11]; /* [1..14, 1..11] */
|
||||
|
||||
extern JE_byte verticalHeight;
|
||||
extern JE_byte helpBoxColor, helpBoxBrightness, helpBoxShadeType;
|
||||
extern char helpTxt[MAX_HELP_MESSAGE][231];
|
||||
extern char pName[21][16]; /* [1..21] of string [15] */
|
||||
extern char miscText[68][42]; /* [1..68] of string [41] */
|
||||
extern char miscTextB[5][11]; /* [1..5] of string [10] */
|
||||
extern char keyName[8][18]; /* [1..8] of string [17] */
|
||||
extern char menuText[7][21]; /* [1..7] of string [20] */
|
||||
extern char outputs[9][31]; /* [1..9] of string [30] */
|
||||
extern char topicName[6][21]; /* [1..6] of string [20] */
|
||||
extern char mainMenuHelp[34][66];
|
||||
extern char inGameText[6][21]; /* [1..6] of string [20] */
|
||||
extern char detailLevel[6][13]; /* [1..6] of string [12] */
|
||||
extern char gameSpeedText[5][13]; /* [1..5] of string [12] */
|
||||
extern char inputDevices[3][13]; /* [1..3] of string [12] */
|
||||
extern char networkText[4][22]; /* [1..4] of string [20] */
|
||||
extern char difficultyNameB[11][21]; /* [0..9] of string [20] */
|
||||
extern char joyButtonNames[5][21]; /* [1..5] of string [20] */
|
||||
extern char superShips[11][26]; /* [0..10] of string [25] */
|
||||
extern char specialName[9][10]; /* [1..9] of string [9] */
|
||||
|
||||
#ifdef TYRIAN2000
|
||||
#define HELPTEXT_MISCTEXT_COUNT 72
|
||||
#define HELPTEXT_MISCTEXTB_COUNT 8
|
||||
#define HELPTEXT_MISCTEXTB_SIZE 12
|
||||
#define HELPTEXT_MENUTEXT_SIZE 29
|
||||
#define HELPTEXT_MAINMENUHELP_COUNT 37
|
||||
#define HELPTEXT_NETWORKTEXT_COUNT 5
|
||||
#define HELPTEXT_NETWORKTEXT_SIZE 33
|
||||
#define HELPTEXT_SUPERSHIPS_COUNT 13
|
||||
#define HELPTEXT_SPECIALNAME_COUNT 11
|
||||
#define HELPTEXT_SHIPINFO_COUNT 20
|
||||
#define HELPTEXT_MENUINT3_COUNT 9
|
||||
#define HELPTEXT_MENUINT12_COUNT 7
|
||||
#else
|
||||
#define HELPTEXT_MISCTEXT_COUNT 68
|
||||
#define HELPTEXT_MISCTEXTB_COUNT 5
|
||||
#define HELPTEXT_MISCTEXTB_SIZE 11
|
||||
#define HELPTEXT_MENUTEXT_SIZE 21
|
||||
#define HELPTEXT_MAINMENUHELP_COUNT 34
|
||||
#define HELPTEXT_NETWORKTEXT_COUNT 4
|
||||
#define HELPTEXT_NETWORKTEXT_SIZE 22
|
||||
#define HELPTEXT_SUPERSHIPS_COUNT 11
|
||||
#define HELPTEXT_SPECIALNAME_COUNT 9
|
||||
#define HELPTEXT_SHIPINFO_COUNT 13
|
||||
#endif
|
||||
|
||||
extern char helpTxt[39][231];
|
||||
extern char pName[21][16];
|
||||
extern char miscText[HELPTEXT_MISCTEXT_COUNT][42];
|
||||
extern char miscTextB[HELPTEXT_MISCTEXTB_COUNT][HELPTEXT_MISCTEXTB_SIZE];
|
||||
extern char keyName[8][18];
|
||||
extern char menuText[7][HELPTEXT_MENUTEXT_SIZE];
|
||||
extern char outputs[9][31];
|
||||
extern char topicName[6][21];
|
||||
extern char mainMenuHelp[HELPTEXT_MAINMENUHELP_COUNT][66];
|
||||
extern char inGameText[6][21];
|
||||
extern char detailLevel[6][13];
|
||||
extern char gameSpeedText[5][13];
|
||||
extern char inputDevices[3][13];
|
||||
extern char networkText[HELPTEXT_NETWORKTEXT_COUNT][HELPTEXT_NETWORKTEXT_SIZE];
|
||||
extern char difficultyNameB[11][21];
|
||||
extern char joyButtonNames[5][21];
|
||||
extern char superShips[HELPTEXT_SUPERSHIPS_COUNT][26];
|
||||
extern char specialName[HELPTEXT_SPECIALNAME_COUNT][10];
|
||||
extern char destructHelp[25][22];
|
||||
extern char weaponNames[17][17]; /* [1..17] of string [16] */
|
||||
extern char destructModeName[DESTRUCT_MODES][13]; /* [1..destructmodes] of string [12] */
|
||||
extern char shipInfo[13][2][256];
|
||||
extern char menuInt[MAX_MENU+1][11][18]; /* [0..maxmenu, 1..11] of string [17] */
|
||||
extern const JE_byte menuHelp[MAX_MENU][11]; /* [1..maxmenu, 1..11] */
|
||||
extern char weaponNames[17][17];
|
||||
extern char destructModeName[DESTRUCT_MODES][13];
|
||||
extern char shipInfo[HELPTEXT_SHIPINFO_COUNT][2][256];
|
||||
extern char menuInt[MENU_MAX+1][11][18];
|
||||
|
||||
void read_encrypted_pascal_string( char *s, int size, FILE *f );
|
||||
void skip_pascal_string( FILE *f );
|
||||
@@ -63,4 +91,3 @@ void JE_loadHelpText( void );
|
||||
|
||||
#endif /* HELPTEXT_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define HG_REVISION_H
|
||||
|
||||
#ifndef HG_REV
|
||||
#define HG_REV "8e4c1be1b53f default"
|
||||
#define HG_REV "0a06d5af473c default"
|
||||
#endif
|
||||
|
||||
#endif // HG_REVISION_H
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "video.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
int joystick_axis_threshold( int j, int value );
|
||||
int check_assigned( SDL_Joystick *joystick_handle, const Joystick_assignment assignment[2] );
|
||||
@@ -656,4 +658,3 @@ bool joystick_assignment_cmp( const Joystick_assignment *a, const Joystick_assig
|
||||
return false;
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -95,4 +95,3 @@ bool joystick_assignment_cmp( const Joystick_assignment *, const Joystick_assign
|
||||
|
||||
#endif /* JOYSTICK_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "vga_palette.h"
|
||||
#include "video.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void jukebox( void )
|
||||
{
|
||||
bool trigger_quit = false, // true when user wants to quit
|
||||
@@ -217,4 +219,3 @@ void jukebox( void )
|
||||
set_volume(tyrMusicVolume, fxVolume);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -25,4 +25,3 @@ void jukebox( void );
|
||||
|
||||
#endif /* JUKEBOX_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "video_scale.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
JE_boolean ESCPressed;
|
||||
@@ -38,15 +39,13 @@ Uint16 lastmouse_x, lastmouse_y;
|
||||
JE_boolean mouse_pressed[3] = {false, false, false};
|
||||
Uint16 mouse_x, mouse_y;
|
||||
|
||||
int numkeys;
|
||||
Uint8 *keysactive;
|
||||
Uint8 keysactive[SDLK_LAST];
|
||||
|
||||
#ifdef NDEBUG
|
||||
bool input_grab_enabled = true,
|
||||
bool input_grab_enabled = true;
|
||||
#else
|
||||
bool input_grab_enabled = false,
|
||||
bool input_grab_enabled = false;
|
||||
#endif
|
||||
input_grabbed = false;
|
||||
|
||||
|
||||
void flush_events_buffer( void )
|
||||
@@ -65,8 +64,10 @@ void wait_input( JE_boolean keyboard, JE_boolean mouse, JE_boolean joystick )
|
||||
push_joysticks_as_keyboard();
|
||||
service_SDL_events(false);
|
||||
|
||||
#ifdef WITH_NETWORK
|
||||
if (isNetworkGame)
|
||||
network_check();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,14 +80,15 @@ void wait_noinput( JE_boolean keyboard, JE_boolean mouse, JE_boolean joystick )
|
||||
poll_joysticks();
|
||||
service_SDL_events(false);
|
||||
|
||||
#ifdef WITH_NETWORK
|
||||
if (isNetworkGame)
|
||||
network_check();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void init_keyboard( void )
|
||||
{
|
||||
keysactive = SDL_GetKeyState(&numkeys);
|
||||
#ifndef ANDROID
|
||||
SDL_EnableKeyRepeat(500, 60);
|
||||
#endif
|
||||
@@ -97,17 +99,17 @@ void init_keyboard( void )
|
||||
SDL_EnableUNICODE(1);
|
||||
}
|
||||
|
||||
void input_grab( void )
|
||||
void input_grab( bool enable )
|
||||
{
|
||||
#if defined(TARGET_GP2X) || defined(TARGET_DINGUX) || defined(ANDROID)
|
||||
input_grabbed = true;
|
||||
#else
|
||||
input_grabbed = input_grab_enabled || fullscreen_enabled;
|
||||
enable = true;
|
||||
#endif
|
||||
|
||||
SDL_ShowCursor(input_grabbed ? SDL_DISABLE : SDL_ENABLE);
|
||||
input_grab_enabled = enable || fullscreen_enabled;
|
||||
|
||||
SDL_ShowCursor(input_grab_enabled ? SDL_DISABLE : SDL_ENABLE);
|
||||
#ifdef NDEBUG
|
||||
SDL_WM_GrabInput(input_grabbed ? SDL_GRAB_ON : SDL_GRAB_OFF);
|
||||
SDL_WM_GrabInput(input_grab_enabled ? SDL_GRAB_ON : SDL_GRAB_OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -121,7 +123,7 @@ JE_word JE_mousePosition( JE_word *mouseX, JE_word *mouseY )
|
||||
|
||||
void set_mouse_position( int x, int y )
|
||||
{
|
||||
if (input_grabbed)
|
||||
if (input_grab_enabled)
|
||||
{
|
||||
SDL_WarpMouse(x * scalers[scaler].width / vga_width, y * scalers[scaler].height / vga_height);
|
||||
mouse_x = x;
|
||||
@@ -144,6 +146,11 @@ void service_SDL_events( JE_boolean clear_new )
|
||||
{
|
||||
switch (ev.type)
|
||||
{
|
||||
case SDL_ACTIVEEVENT:
|
||||
if (ev.active.state == SDL_APPINPUTFOCUS && !ev.active.gain)
|
||||
input_grab(false);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
mouse_x = ev.motion.x * vga_width / scalers[scaler].width;
|
||||
mouse_y = ev.motion.y * vga_height / scalers[scaler].height;
|
||||
@@ -170,8 +177,7 @@ void service_SDL_events( JE_boolean clear_new )
|
||||
/* <ctrl><f10> toggle input grab */
|
||||
if (ev.key.keysym.sym == SDLK_F10)
|
||||
{
|
||||
input_grab_enabled = !input_grab_enabled;
|
||||
input_grab();
|
||||
input_grab(!input_grab_enabled);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -193,18 +199,19 @@ void service_SDL_events( JE_boolean clear_new )
|
||||
/* <alt><tab> disable input grab and fullscreen */
|
||||
if (ev.key.keysym.sym == SDLK_TAB)
|
||||
{
|
||||
input_grab_enabled = false;
|
||||
input_grab();
|
||||
|
||||
if (!init_scaler(scaler, false) && // try windowed
|
||||
!init_any_scaler(false) && // try any scaler windowed
|
||||
!init_scaler(scaler, fullscreen_enabled)) // revert on fail
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
input_grab(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
keysactive[ev.key.keysym.sym] = 1;
|
||||
|
||||
newkey = true;
|
||||
lastkey_sym = ev.key.keysym.sym;
|
||||
@@ -213,15 +220,16 @@ void service_SDL_events( JE_boolean clear_new )
|
||||
keydown = true;
|
||||
return;
|
||||
case SDL_KEYUP:
|
||||
keysactive[ev.key.keysym.sym] = 0;
|
||||
keydown = false;
|
||||
return;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
if (!input_grabbed)
|
||||
if (!input_grab_enabled)
|
||||
{
|
||||
input_grab_enabled = !input_grab_enabled;
|
||||
input_grab();
|
||||
input_grab(true);
|
||||
break;
|
||||
}
|
||||
// intentional fall-though
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
if (ev.type == SDL_MOUSEBUTTONDOWN)
|
||||
{
|
||||
@@ -258,4 +266,3 @@ void JE_clearKeyboard( void )
|
||||
// /!\ Doesn't seems important. I think. D:
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -35,16 +35,15 @@ extern Uint8 lastmouse_but;
|
||||
extern Uint16 lastmouse_x, lastmouse_y;
|
||||
extern JE_boolean mouse_pressed[3];
|
||||
extern Uint16 mouse_x, mouse_y;
|
||||
extern int numkeys;
|
||||
extern Uint8 *keysactive;
|
||||
extern Uint8 keysactive[SDLK_LAST];
|
||||
|
||||
extern bool input_grab_enabled, input_grabbed;
|
||||
extern bool input_grab_enabled;
|
||||
|
||||
void flush_events_buffer( void );
|
||||
void wait_input( JE_boolean keyboard, JE_boolean mouse, JE_boolean joystick );
|
||||
void wait_noinput( JE_boolean keyboard, JE_boolean mouse, JE_boolean joystick );
|
||||
void init_keyboard( void );
|
||||
void input_grab( void );
|
||||
void input_grab( bool enable );
|
||||
JE_word JE_mousePosition( JE_word *mouseX, JE_word *mouseY );
|
||||
void set_mouse_position( int x, int y );
|
||||
|
||||
@@ -66,4 +65,3 @@ void JE_clearKeyboard( void );
|
||||
|
||||
#endif /* KEYBOARD_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -17,13 +17,14 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include "file.h"
|
||||
#include "fm_synth.h"
|
||||
#include "lds_play.h"
|
||||
#include "loudness.h"
|
||||
#include "opentyr.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
const unsigned char op_table[9] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12};
|
||||
|
||||
/* A substantial amount of this code has been copied and adapted from adplug.
|
||||
Thanks, guys! Adplug is awesome! :D */
|
||||
|
||||
@@ -207,7 +208,7 @@ void lds_rewind( void )
|
||||
memset(fmchip, 0, sizeof(fmchip));
|
||||
|
||||
/* OPL2 init */
|
||||
opl_reset(); /* Reset OPL chip */
|
||||
opl_init(); /* Reset OPL chip */
|
||||
opl_write(1, 0x20);
|
||||
opl_write(8, 0);
|
||||
opl_write(0xbd, regbd);
|
||||
@@ -765,4 +766,3 @@ void lds_playsound(int inst_number, int channel_number, int tunehigh)
|
||||
c->nextvol = c->glideto = c->finetune = c->vibcount = c->arp_pos = c->arp_count = 0;
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "opentyr.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
extern bool playing, songlooped;
|
||||
|
||||
int lds_update( void );
|
||||
@@ -70,4 +72,3 @@ void lds_setregs_adv(unsigned char reg, unsigned char mask, unsigned char val);
|
||||
|
||||
#endif /* LDS_PLAY_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -17,7 +17,6 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include "file.h"
|
||||
#include "fm_synth.h"
|
||||
#include "lds_play.h"
|
||||
#include "loudness.h"
|
||||
#include "nortsong.h"
|
||||
@@ -61,7 +60,7 @@ bool init_audio( void )
|
||||
ask.freq = freq;
|
||||
ask.format = (BYTES_PER_SAMPLE == 2) ? AUDIO_S16SYS : AUDIO_S8;
|
||||
ask.channels = 1;
|
||||
ask.samples = 512;
|
||||
ask.samples = 2048;
|
||||
ask.callback = audio_cb;
|
||||
|
||||
printf("\trequested %d Hz, %d channels, %d samples\n", ask.freq, ask.channels, ask.samples);
|
||||
@@ -186,8 +185,6 @@ void deinit_audio( void )
|
||||
channel_len[i] = 0;
|
||||
}
|
||||
|
||||
opl_deinit();
|
||||
|
||||
lds_free();
|
||||
}
|
||||
|
||||
@@ -200,7 +197,7 @@ void load_music( void )
|
||||
|
||||
efread(&song_count, sizeof(song_count), 1, music_file);
|
||||
|
||||
song_offset = malloc((song_count + 1) * sizeof(song_offset));
|
||||
song_offset = malloc((song_count + 1) * sizeof(*song_offset));
|
||||
|
||||
efread(song_offset, 4, song_count, music_file);
|
||||
song_offset[song_count] = ftell_eof(music_file);
|
||||
@@ -252,7 +249,7 @@ void stop_song( void )
|
||||
|
||||
void fade_song( void )
|
||||
{
|
||||
printf("TODO: %s\n", __FUNCTION__);
|
||||
/* STUB: we have no implementation of this to port */
|
||||
}
|
||||
|
||||
void set_volume( unsigned int music, unsigned int sample )
|
||||
@@ -290,4 +287,3 @@ void JE_multiSamplePlay(JE_byte *buffer, JE_word size, JE_byte chan, JE_byte vol
|
||||
SDL_UnlockAudio();
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -19,8 +19,8 @@
|
||||
#ifndef LOUDNESS_H
|
||||
#define LOUDNESS_H
|
||||
|
||||
#include "fmopl.h"
|
||||
#include "opentyr.h"
|
||||
#include "opl.h"
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
#endif
|
||||
|
||||
#define SAMPLE_SCALING OUTPUT_QUALITY
|
||||
#define SAMPLE_TYPE OPLSAMPLE
|
||||
#define BYTES_PER_SAMPLE (OPL_SAMPLE_BITS / 8)
|
||||
#define SAMPLE_TYPE Bit16s
|
||||
#define BYTES_PER_SAMPLE 2
|
||||
|
||||
extern float music_volume, sample_volume;
|
||||
|
||||
@@ -57,4 +57,3 @@ void JE_multiSamplePlay(JE_byte *buffer, JE_word size, JE_byte chan, JE_byte vol
|
||||
|
||||
#endif /* LOUDNESS_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -39,4 +39,3 @@ void JE_analyzeLevel( void )
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -32,4 +32,3 @@ void JE_analyzeLevel( void );
|
||||
|
||||
#endif /* LVLLIB_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -171,4 +171,3 @@ TYPE 5: Shape Files
|
||||
M 1 2 3 4 episode
|
||||
*/
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -21,9 +21,19 @@
|
||||
|
||||
#include "opentyr.h"
|
||||
|
||||
|
||||
#define EVENT_MAXIMUM 2500
|
||||
|
||||
#ifdef TYRIAN2000
|
||||
#define WEAP_NUM 818
|
||||
#define PORT_NUM 60
|
||||
#define ARMOR_NUM 4
|
||||
#define POWER_NUM 6
|
||||
#define ENGINE_NUM 6
|
||||
#define OPTION_NUM 37
|
||||
#define SHIP_NUM 18
|
||||
#define SHIELD_NUM 11
|
||||
#define SPECIAL_NUM 46
|
||||
#else
|
||||
#define WEAP_NUM 780
|
||||
#define PORT_NUM 42
|
||||
#define ARMOR_NUM 4
|
||||
@@ -33,6 +43,7 @@
|
||||
#define SHIP_NUM 13
|
||||
#define SHIELD_NUM 10
|
||||
#define SPECIAL_NUM 46
|
||||
#endif
|
||||
|
||||
#define ENEMY_NUM 850
|
||||
|
||||
@@ -46,4 +57,3 @@ extern const JE_char shapeFile[34]; /* [1..34] */
|
||||
|
||||
#endif /* LVLMAST_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* vim: set noet:
|
||||
*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
/*
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2008 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -91,4 +91,3 @@ void JE_playerCollide( Player *this_player, JE_byte playerNum );
|
||||
|
||||
#endif /* MAININT_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -29,10 +29,10 @@
|
||||
#include "sprite.h"
|
||||
#include "video.h"
|
||||
|
||||
char episode_name[6][31], difficulty_name[7][21], gameplay_name[5][26];
|
||||
char episode_name[6][31], difficulty_name[7][21], gameplay_name[GAMEPLAY_NAME_COUNT][26];
|
||||
|
||||
bool
|
||||
select_menuitem_by_touch(JE_byte menu_top, JE_byte menu_spacing, JE_shortint menu_item_count, JE_shortint *current_item)
|
||||
select_menuitem_by_touch(int menu_top, int menu_spacing, int menu_item_count, int *current_item)
|
||||
{
|
||||
if (!mousedown)
|
||||
return false;
|
||||
@@ -56,16 +56,16 @@ bool select_gameplay( void )
|
||||
JE_loadPic(VGAScreen, 2, false);
|
||||
JE_dString(VGAScreen, JE_fontCenter(gameplay_name[0], FONT_SHAPES), 20, gameplay_name[0], FONT_SHAPES);
|
||||
|
||||
const JE_byte menu_top = 30, menu_spacing = 24;
|
||||
JE_shortint gameplay = 1,
|
||||
gameplay_max = 4;
|
||||
int menu_top = 30, menu_spacing = 24;
|
||||
int gameplay = 1,
|
||||
gameplay_max = GAMEPLAY_NAME_COUNT - 1;
|
||||
|
||||
bool fade_in = true;
|
||||
for (; ; )
|
||||
{
|
||||
for (int i = 1; i <= gameplay_max; i++)
|
||||
{
|
||||
JE_outTextAdjust(VGAScreen, JE_fontCenter(gameplay_name[i], SMALL_FONT_SHAPES), i * menu_spacing + menu_top, gameplay_name[i], 15, - 4 + (i == gameplay ? 2 : 0) - (i == 4 ? 4 : 0), SMALL_FONT_SHAPES, true);
|
||||
JE_outTextAdjust(VGAScreen, JE_fontCenter(gameplay_name[i], SMALL_FONT_SHAPES), i * menu_spacing + menu_top, gameplay_name[i], 15, -4 + (i == gameplay ? 2 : 0) - (i == (GAMEPLAY_NAME_COUNT - 1) ? 4 : 0), SMALL_FONT_SHAPES, true);
|
||||
}
|
||||
JE_showVGA();
|
||||
|
||||
@@ -87,8 +87,7 @@ bool select_gameplay( void )
|
||||
{
|
||||
case SDLK_UP:
|
||||
case SDLK_LCTRL:
|
||||
gameplay--;
|
||||
if (gameplay < 1)
|
||||
if (--gameplay < 1)
|
||||
{
|
||||
gameplay = gameplay_max;
|
||||
}
|
||||
@@ -96,8 +95,7 @@ bool select_gameplay( void )
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
case SDLK_LALT:
|
||||
gameplay++;
|
||||
if (gameplay > gameplay_max)
|
||||
if (++gameplay > gameplay_max)
|
||||
{
|
||||
gameplay = 1;
|
||||
}
|
||||
@@ -106,7 +104,7 @@ bool select_gameplay( void )
|
||||
|
||||
case SDLK_RETURN:
|
||||
case SDLK_SPACE:
|
||||
if (gameplay == 4)
|
||||
if (gameplay == GAMEPLAY_NAME_COUNT - 1)
|
||||
{
|
||||
JE_playSampleNum(S_SPRING);
|
||||
/* TODO: NETWORK */
|
||||
@@ -117,7 +115,7 @@ bool select_gameplay( void )
|
||||
fade_black(10);
|
||||
|
||||
onePlayerAction = (gameplay == 2);
|
||||
twoPlayerMode = (gameplay == 3);
|
||||
twoPlayerMode = (gameplay == GAMEPLAY_NAME_COUNT - 2);
|
||||
return true;
|
||||
|
||||
case SDLK_ESCAPE:
|
||||
@@ -139,9 +137,8 @@ bool select_episode( void )
|
||||
JE_loadPic(VGAScreen, 2, false);
|
||||
JE_dString(VGAScreen, JE_fontCenter(episode_name[0], FONT_SHAPES), 20, episode_name[0], FONT_SHAPES);
|
||||
|
||||
const JE_byte menu_top = 20, menu_spacing = 30;
|
||||
JE_shortint episode = 1,
|
||||
episode_max = EPISODE_MAX - 1;
|
||||
const int menu_top = 20, menu_spacing = 30;
|
||||
int episode = 1, episode_max = EPISODE_AVAILABLE;
|
||||
|
||||
bool fade_in = true;
|
||||
for (; ; )
|
||||
@@ -220,9 +217,9 @@ bool select_difficulty( void )
|
||||
JE_loadPic(VGAScreen, 2, false);
|
||||
JE_dString(VGAScreen, JE_fontCenter(difficulty_name[0], FONT_SHAPES), 20, difficulty_name[0], FONT_SHAPES);
|
||||
|
||||
const JE_byte menu_top = 30, menu_spacing = 24;
|
||||
const int menu_top = 30, menu_spacing = 24;
|
||||
difficultyLevel = 2;
|
||||
JE_shortint difficulty_max = 3;
|
||||
int difficulty_max = 3;
|
||||
|
||||
bool fade_in = true;
|
||||
for (; ; )
|
||||
@@ -242,8 +239,12 @@ bool select_difficulty( void )
|
||||
JE_word temp = 0;
|
||||
JE_textMenuWait(&temp, false);
|
||||
|
||||
if (select_menuitem_by_touch(menu_top, menu_spacing, difficulty_max, &difficultyLevel))
|
||||
int difficultyLevel_ = difficultyLevel; // Need to pass an int, difficultyLevel is short int
|
||||
if (select_menuitem_by_touch(menu_top, menu_spacing, difficulty_max, &difficultyLevel_))
|
||||
{
|
||||
difficultyLevel = difficultyLevel_;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (SDL_GetModState() & KMOD_SHIFT)
|
||||
{
|
||||
@@ -307,4 +308,3 @@ bool select_difficulty( void )
|
||||
}
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -21,13 +21,17 @@
|
||||
|
||||
#include "opentyr.h"
|
||||
|
||||
extern char episode_name[6][31], difficulty_name[7][21], gameplay_name[5][26];
|
||||
#ifdef TYRIAN2000
|
||||
#define GAMEPLAY_NAME_COUNT 6
|
||||
#else
|
||||
#define GAMEPLAY_NAME_COUNT 5
|
||||
#endif
|
||||
extern char episode_name[6][31], difficulty_name[7][21], gameplay_name[GAMEPLAY_NAME_COUNT][26];
|
||||
|
||||
bool select_gameplay( void );
|
||||
bool select_episode( void );
|
||||
bool select_difficulty( void );
|
||||
bool select_menuitem_by_touch(JE_byte menu_top, JE_byte menu_spacing, JE_shortint menu_item_count, JE_shortint *current_item);
|
||||
bool select_menuitem_by_touch(int menu_top, int menu_spacing, int menu_item_count, int *current_item);
|
||||
|
||||
#endif /* MENUS_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -115,4 +115,3 @@ void JE_mouseReplace( void )
|
||||
JE_drawShapeTypeOne(lastMouseX, lastMouseY, mouseGrabShape);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -41,4 +41,3 @@ void JE_mouseReplace( void );
|
||||
|
||||
#endif /* MOUSE_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -105,4 +105,3 @@ float mt_rand_lt1( void )
|
||||
return ((float)mt_rand() / ((float)MT_RAND_MAX + 1.0f));
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -28,4 +28,3 @@ float mt_rand_lt1( void );
|
||||
|
||||
#endif /* MTRAND_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -114,4 +114,3 @@ const char musicTitle[MUSIC_NUM][48] =
|
||||
|
||||
JE_boolean musicFade;
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -39,4 +39,3 @@ extern JE_boolean musicFade;
|
||||
|
||||
#endif /* MUSMAST_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -30,9 +30,6 @@
|
||||
#include "varz.h"
|
||||
#include "video.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_net.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/* HERE BE DRAGONS!
|
||||
@@ -66,27 +63,29 @@ static char empty_string[] = "";
|
||||
char *network_player_name = empty_string,
|
||||
*network_opponent_name = empty_string;
|
||||
|
||||
UDPsocket socket;
|
||||
IPaddress ip;
|
||||
#ifdef WITH_NETWORK
|
||||
static UDPsocket socket;
|
||||
static IPaddress ip;
|
||||
|
||||
UDPpacket *packet_out_temp, *packet_temp;
|
||||
UDPpacket *packet_out_temp;
|
||||
static UDPpacket *packet_temp;
|
||||
|
||||
UDPpacket *packet_in[NET_PACKET_QUEUE] = { NULL },
|
||||
*packet_out[NET_PACKET_QUEUE] = { NULL };
|
||||
|
||||
Uint16 last_out_sync = 0, queue_in_sync = 0, queue_out_sync = 0, last_ack_sync = 0;
|
||||
Uint32 last_in_tick = 0, last_out_tick = 0;
|
||||
static Uint16 last_out_sync = 0, queue_in_sync = 0, queue_out_sync = 0, last_ack_sync = 0;
|
||||
static Uint32 last_in_tick = 0, last_out_tick = 0;
|
||||
|
||||
UDPpacket *packet_state_in[NET_PACKET_QUEUE] = { NULL },
|
||||
*packet_state_in_xor[NET_PACKET_QUEUE] = { NULL },
|
||||
*packet_state_out[NET_PACKET_QUEUE] = { NULL };
|
||||
UDPpacket *packet_state_in[NET_PACKET_QUEUE] = { NULL };
|
||||
static UDPpacket *packet_state_in_xor[NET_PACKET_QUEUE] = { NULL };
|
||||
UDPpacket *packet_state_out[NET_PACKET_QUEUE] = { NULL };
|
||||
|
||||
Uint16 last_state_in_sync = 0, last_state_out_sync = 0;
|
||||
Uint32 last_state_in_tick = 0;
|
||||
static Uint16 last_state_in_sync = 0, last_state_out_sync = 0;
|
||||
static Uint32 last_state_in_tick = 0;
|
||||
|
||||
bool net_initialized = false;
|
||||
static bool net_initialized = false;
|
||||
static bool connected = false, quit = false;
|
||||
|
||||
#endif
|
||||
|
||||
uint thisPlayerNum = 0; /* Player number on this PC (1 or 2) */
|
||||
|
||||
@@ -98,6 +97,41 @@ JE_boolean moveOk;
|
||||
JE_boolean pauseRequest, skipLevelRequest, helpRequest, nortShipRequest;
|
||||
JE_boolean yourInGameMenuRequest, inGameMenuRequest;
|
||||
|
||||
#ifdef WITH_NETWORK
|
||||
static void packet_copy( UDPpacket *dst, UDPpacket *src )
|
||||
{
|
||||
void *temp = dst->data;
|
||||
memcpy(dst, src, sizeof(*dst));
|
||||
dst->data = temp;
|
||||
memcpy(dst->data, src->data, src->len);
|
||||
}
|
||||
|
||||
static void packets_shift_up( UDPpacket **packet, int max_packets )
|
||||
{
|
||||
if (packet[0])
|
||||
{
|
||||
SDLNet_FreePacket(packet[0]);
|
||||
}
|
||||
for (int i = 0; i < max_packets - 1; i++)
|
||||
{
|
||||
packet[i] = packet[i + 1];
|
||||
}
|
||||
packet[max_packets - 1] = NULL;
|
||||
}
|
||||
|
||||
static void packets_shift_down( UDPpacket **packet, int max_packets )
|
||||
{
|
||||
if (packet[max_packets - 1])
|
||||
{
|
||||
SDLNet_FreePacket(packet[max_packets - 1]);
|
||||
}
|
||||
for (int i = max_packets - 1; i > 0; i--)
|
||||
{
|
||||
packet[i] = packet[i - 1];
|
||||
}
|
||||
packet[0] = NULL;
|
||||
}
|
||||
|
||||
// prepare new packet for sending
|
||||
void network_prepare( Uint16 type )
|
||||
{
|
||||
@@ -105,6 +139,20 @@ void network_prepare( Uint16 type )
|
||||
SDLNet_Write16(last_out_sync, &packet_out_temp->data[2]);
|
||||
}
|
||||
|
||||
// send packet but don't expect acknoledgment of delivery
|
||||
static bool network_send_no_ack( int len )
|
||||
{
|
||||
packet_out_temp->len = len;
|
||||
|
||||
if (!SDLNet_UDP_Send(socket, 0, packet_out_temp))
|
||||
{
|
||||
printf("SDLNet_UDP_Send: %s\n", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// send packet and place it in queue to be acknowledged
|
||||
bool network_send( int len )
|
||||
{
|
||||
@@ -129,18 +177,20 @@ bool network_send( int len )
|
||||
return temp;
|
||||
}
|
||||
|
||||
// send packet but don't expect acknoledgment of delivery
|
||||
bool network_send_no_ack( int len )
|
||||
// send acknowledgement packet
|
||||
static int network_acknowledge( Uint16 sync )
|
||||
{
|
||||
packet_out_temp->len = len;
|
||||
SDLNet_Write16(PACKET_ACKNOWLEDGE, &packet_out_temp->data[0]);
|
||||
SDLNet_Write16(sync, &packet_out_temp->data[2]);
|
||||
network_send_no_ack(4);
|
||||
|
||||
if (!SDLNet_UDP_Send(socket, 0, packet_out_temp))
|
||||
{
|
||||
printf("SDLNet_UDP_Send: %s\n", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
// activity lately?
|
||||
static bool network_is_alive( void )
|
||||
{
|
||||
return (SDL_GetTicks() - last_in_tick < NET_TIME_OUT || SDL_GetTicks() - last_state_in_tick < NET_TIME_OUT);
|
||||
}
|
||||
|
||||
// poll for new packets received, check that connection is alive, resend queued packets if necessary
|
||||
@@ -337,16 +387,6 @@ int network_check( void )
|
||||
return 0;
|
||||
}
|
||||
|
||||
// send acknowledgement packet
|
||||
int network_acknowledge( Uint16 sync )
|
||||
{
|
||||
SDLNet_Write16(PACKET_ACKNOWLEDGE, &packet_out_temp->data[0]);
|
||||
SDLNet_Write16(sync, &packet_out_temp->data[2]);
|
||||
network_send_no_ack(4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// discard working packet, now processing next packet in queue
|
||||
bool network_update( void )
|
||||
{
|
||||
@@ -368,12 +408,6 @@ bool network_is_sync( void )
|
||||
return (queue_out_sync - last_ack_sync == 1);
|
||||
}
|
||||
|
||||
// activity lately?
|
||||
bool network_is_alive( void )
|
||||
{
|
||||
return (SDL_GetTicks() - last_in_tick < NET_TIME_OUT || SDL_GetTicks() - last_state_in_tick < NET_TIME_OUT);
|
||||
}
|
||||
|
||||
|
||||
// prepare new state for sending
|
||||
void network_state_prepare( void )
|
||||
@@ -741,40 +775,7 @@ int network_init( void )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void packet_copy( UDPpacket *dst, UDPpacket *src )
|
||||
{
|
||||
void *temp = dst->data;
|
||||
memcpy(dst, src, sizeof(*dst));
|
||||
dst->data = temp;
|
||||
memcpy(dst->data, src->data, src->len);
|
||||
}
|
||||
|
||||
void packets_shift_up( UDPpacket **packet, int max_packets )
|
||||
{
|
||||
if (packet[0])
|
||||
{
|
||||
SDLNet_FreePacket(packet[0]);
|
||||
}
|
||||
for (int i = 0; i < max_packets - 1; i++)
|
||||
{
|
||||
packet[i] = packet[i + 1];
|
||||
}
|
||||
packet[max_packets - 1] = NULL;
|
||||
}
|
||||
|
||||
void packets_shift_down( UDPpacket **packet, int max_packets )
|
||||
{
|
||||
if (packet[max_packets - 1])
|
||||
{
|
||||
SDLNet_FreePacket(packet[max_packets - 1]);
|
||||
}
|
||||
for (int i = max_packets - 1; i > 0; i--)
|
||||
{
|
||||
packet[i] = packet[i - 1];
|
||||
}
|
||||
packet[0] = NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void JE_clearSpecialRequests( void )
|
||||
{
|
||||
@@ -785,4 +786,3 @@ void JE_clearSpecialRequests( void )
|
||||
nortShipRequest = false;
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -22,7 +22,9 @@
|
||||
#include "opentyr.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_net.h"
|
||||
#ifdef WITH_NETWORK
|
||||
# include "SDL_net.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define PACKET_ACKNOWLEDGE 0x00 //
|
||||
@@ -50,28 +52,26 @@ extern char *network_opponent_host;
|
||||
extern Uint16 network_player_port, network_opponent_port;
|
||||
extern char *network_player_name, *network_opponent_name;
|
||||
|
||||
#ifdef WITH_NETWORK
|
||||
extern UDPpacket *packet_out_temp;
|
||||
extern UDPpacket *packet_in[], *packet_out[],
|
||||
*packet_state_in[], *packet_state_out[];
|
||||
#endif
|
||||
|
||||
extern uint thisPlayerNum;
|
||||
extern JE_boolean haltGame;
|
||||
extern JE_boolean moveOk;
|
||||
extern JE_boolean pauseRequest, skipLevelRequest, helpRequest, nortShipRequest;
|
||||
extern JE_boolean yourInGameMenuRequest, inGameMenuRequest;
|
||||
extern JE_boolean portConfigChange, portConfigDone;
|
||||
|
||||
|
||||
#ifdef WITH_NETWORK
|
||||
void network_prepare( Uint16 type );
|
||||
bool network_send( int len );
|
||||
bool network_send_no_ack( int len );
|
||||
|
||||
int network_check( void );
|
||||
int network_acknowledge( Uint16 sync );
|
||||
bool network_update( void );
|
||||
|
||||
bool network_is_sync( void );
|
||||
bool network_is_alive( void );
|
||||
|
||||
void network_state_prepare( void );
|
||||
int network_state_send( void );
|
||||
@@ -84,17 +84,18 @@ void network_tyrian_halt( unsigned int err, bool attempt_sync );
|
||||
|
||||
int network_init( void );
|
||||
|
||||
void packet_copy( UDPpacket *dst, UDPpacket *src );
|
||||
void packets_shift_up( UDPpacket **packet, int max_packets );
|
||||
void packets_shift_down( UDPpacket **packet, int max_packets );
|
||||
|
||||
void JE_clearSpecialRequests( void );
|
||||
|
||||
#define NETWORK_KEEP_ALIVE() \
|
||||
if (isNetworkGame) \
|
||||
network_check();
|
||||
|
||||
#else
|
||||
|
||||
#define NETWORK_KEEP_ALIVE()
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* NETWORK_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -117,7 +117,7 @@ void JE_loadSndFile( const char *effects_sndfile, const char *voices_sndfile )
|
||||
efread(&sndPos[0][x], sizeof(sndPos[0][x]), 1, fi);
|
||||
}
|
||||
fseek(fi, 0, SEEK_END);
|
||||
sndPos[1][sndNum] = ftell(fi); /* Store file size */
|
||||
sndPos[0][sndNum] = ftell(fi); /* Store file size */
|
||||
|
||||
for (z = 0; z < sndNum; z++)
|
||||
{
|
||||
@@ -222,4 +222,3 @@ void JE_changeVolume( JE_word *music, int music_delta, JE_word *sample, int samp
|
||||
set_volume(*music, *sample);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -62,4 +62,3 @@ void JE_playSampleNum( JE_byte samplenum );
|
||||
|
||||
#endif /* NORTSONG_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -85,4 +85,3 @@ void JE_wipeKey( void )
|
||||
// /!\ Doesn't seems to affect anything.
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -33,4 +33,3 @@ void JE_wipeKey( void );
|
||||
|
||||
#endif /* NORTVARS_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -52,39 +52,11 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
const char *opentyrian_str = "OpenTyrian",
|
||||
*opentyrian_version = "Classic (" HG_REV ")";
|
||||
const char *opentyrian_menu_items[] =
|
||||
{
|
||||
"About OpenTyrian",
|
||||
#ifndef ANDROID
|
||||
"Toggle Fullscreen",
|
||||
#endif
|
||||
"Scaler: None",
|
||||
"Jukebox",
|
||||
#ifdef ANDROID
|
||||
"Play Destruct",
|
||||
#endif
|
||||
"Return to Main Menu"
|
||||
};
|
||||
|
||||
#ifndef ANDROID
|
||||
enum {
|
||||
menu_item_scaler = 2,
|
||||
menu_item_jukebox = 3
|
||||
};
|
||||
#else
|
||||
enum {
|
||||
menu_item_scaler = 1,
|
||||
menu_item_jukebox = 2,
|
||||
menu_item_destruct = 3
|
||||
};
|
||||
#endif
|
||||
*opentyrian_version = HG_REV;
|
||||
|
||||
/* zero-terminated strncpy */
|
||||
char *strnztcpy( char *to, const char *from, size_t count )
|
||||
@@ -95,13 +67,39 @@ char *strnztcpy( char *to, const char *from, size_t count )
|
||||
|
||||
void opentyrian_menu( void )
|
||||
{
|
||||
const JE_byte menu_top = 36, menu_spacing = 20;
|
||||
JE_shortint sel = 0;
|
||||
const int maxSel = COUNTOF(opentyrian_menu_items) - 1;
|
||||
bool quit = false, fade_in = true;
|
||||
|
||||
uint temp_scaler = scaler;
|
||||
typedef enum
|
||||
{
|
||||
MENU_ABOUT = 0,
|
||||
MENU_FULLSCREEN,
|
||||
MENU_SCALER,
|
||||
// MENU_DESTRUCT,
|
||||
MENU_JUKEBOX,
|
||||
MENU_RETURN,
|
||||
MenuOptions_MAX
|
||||
} MenuOptions;
|
||||
|
||||
static const char *menu_items[] =
|
||||
{
|
||||
"About OpenTyrian",
|
||||
"Toggle Fullscreen",
|
||||
"Scaler: None",
|
||||
// "Play Destruct",
|
||||
"Jukebox",
|
||||
"Return to Main Menu",
|
||||
};
|
||||
bool menu_items_disabled[] =
|
||||
{
|
||||
false,
|
||||
!can_init_any_scaler(false) || !can_init_any_scaler(true),
|
||||
false,
|
||||
// false,
|
||||
false,
|
||||
false,
|
||||
};
|
||||
|
||||
assert(COUNTOF(menu_items) == MenuOptions_MAX);
|
||||
assert(COUNTOF(menu_items_disabled) == MenuOptions_MAX);
|
||||
|
||||
fade_black(10);
|
||||
JE_loadPic(VGAScreen, 13, false);
|
||||
|
||||
@@ -113,25 +111,29 @@ void opentyrian_menu( void )
|
||||
|
||||
play_song(36); // A Field for Mag
|
||||
|
||||
MenuOptions sel = 0;
|
||||
int menu_top = 32, menu_spacing = 16;
|
||||
|
||||
uint temp_scaler = scaler;
|
||||
|
||||
bool fade_in = true, quit = false;
|
||||
do
|
||||
{
|
||||
memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
|
||||
|
||||
for (int i = 0; i <= maxSel; i++)
|
||||
for (MenuOptions i = 0; i < MenuOptions_MAX; i++)
|
||||
{
|
||||
const char *text = opentyrian_menu_items[i];
|
||||
const char *text = menu_items[i];
|
||||
char buffer[100];
|
||||
|
||||
if (i == menu_item_scaler) /* Scaler */
|
||||
if (i == MENU_SCALER)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "Scaler: %s", scalers[temp_scaler].name);
|
||||
text = buffer;
|
||||
}
|
||||
|
||||
// Destruct is not adapted for touch input, so we show it only if keyboard is used:
|
||||
if (i == menu_item_destruct && (mousedown || lastkey_sym == SDLK_ESCAPE))
|
||||
continue;
|
||||
draw_font_hv_shadow(VGAScreen, VGAScreen->w / 2, (i != maxSel) ? i * menu_spacing + menu_top : 118, text, normal_font, centered, 15, (i != sel) ? -4 : -2, false, 2);
|
||||
int y = i != MENU_RETURN ? i * 16 + 32 : 118;
|
||||
draw_font_hv(VGAScreen, VGAScreen->w / 2, y, text, normal_font, centered, 15, menu_items_disabled[i] ? -8 : i != sel ? -4 : -2);
|
||||
}
|
||||
|
||||
JE_showVGA();
|
||||
@@ -146,132 +148,139 @@ void opentyrian_menu( void )
|
||||
tempW = 0;
|
||||
JE_textMenuWait(&tempW, false);
|
||||
|
||||
if (select_menuitem_by_touch(menu_top, menu_spacing, maxSel, &sel))
|
||||
int sel_ = sel; // We need to pass int there, and sel is enum (yes that's also int, but compiler gives warning)
|
||||
if (select_menuitem_by_touch(menu_top, menu_spacing, MenuOptions_MAX, &sel_))
|
||||
{
|
||||
sel = sel_;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (newkey)
|
||||
{
|
||||
switch (lastkey_sym)
|
||||
{
|
||||
case SDLK_UP:
|
||||
case SDLK_LCTRL:
|
||||
sel--;
|
||||
if (sel < 0)
|
||||
{
|
||||
sel = maxSel;
|
||||
}
|
||||
JE_playSampleNum(S_CURSOR);
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
case SDLK_LALT:
|
||||
sel++;
|
||||
if (sel > maxSel)
|
||||
{
|
||||
case SDLK_UP:
|
||||
case SDLK_LCTRL:
|
||||
do
|
||||
{
|
||||
if (sel-- == 0)
|
||||
sel = MenuOptions_MAX - 1;
|
||||
}
|
||||
while (menu_items_disabled[sel]);
|
||||
|
||||
JE_playSampleNum(S_CURSOR);
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
case SDLK_LALT:
|
||||
do
|
||||
{
|
||||
if (++sel >= MenuOptions_MAX)
|
||||
sel = 0;
|
||||
}
|
||||
while (menu_items_disabled[sel]);
|
||||
|
||||
JE_playSampleNum(S_CURSOR);
|
||||
break;
|
||||
|
||||
case SDLK_LEFT:
|
||||
if (sel == MENU_SCALER)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (temp_scaler == 0)
|
||||
temp_scaler = scalers_count;
|
||||
temp_scaler--;
|
||||
}
|
||||
while (!can_init_scaler(temp_scaler, fullscreen_enabled));
|
||||
|
||||
JE_playSampleNum(S_CURSOR);
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
if (sel == menu_item_scaler)
|
||||
}
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
if (sel == MENU_SCALER)
|
||||
{
|
||||
do
|
||||
{
|
||||
do
|
||||
temp_scaler++;
|
||||
if (temp_scaler == scalers_count)
|
||||
temp_scaler = 0;
|
||||
}
|
||||
while (!can_init_scaler(temp_scaler, fullscreen_enabled));
|
||||
|
||||
JE_playSampleNum(S_CURSOR);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDLK_RETURN:
|
||||
case SDLK_SPACE:
|
||||
switch (sel)
|
||||
{
|
||||
case MENU_ABOUT:
|
||||
JE_playSampleNum(S_SELECT);
|
||||
|
||||
scroller_sine(about_text);
|
||||
|
||||
memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
|
||||
JE_showVGA();
|
||||
fade_in = true;
|
||||
break;
|
||||
|
||||
case MENU_FULLSCREEN:
|
||||
JE_playSampleNum(S_SELECT);
|
||||
|
||||
if (!init_scaler(scaler, !fullscreen_enabled) && // try new fullscreen state
|
||||
!init_any_scaler(!fullscreen_enabled) && // try any scaler in new fullscreen state
|
||||
!init_scaler(scaler, fullscreen_enabled)) // revert on fail
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
set_palette(colors, 0, 255); // for switching between 8 bpp scalers
|
||||
break;
|
||||
|
||||
case MENU_SCALER:
|
||||
JE_playSampleNum(S_SELECT);
|
||||
|
||||
if (scaler != temp_scaler)
|
||||
{
|
||||
if (!init_scaler(temp_scaler, fullscreen_enabled) && // try new scaler
|
||||
!init_scaler(temp_scaler, !fullscreen_enabled) && // try other fullscreen state
|
||||
!init_scaler(scaler, fullscreen_enabled)) // revert on fail
|
||||
{
|
||||
if (temp_scaler == 0)
|
||||
temp_scaler = scalers_count;
|
||||
temp_scaler--;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
while (!can_init_scaler(temp_scaler, fullscreen_enabled));
|
||||
JE_playSampleNum(S_CURSOR);
|
||||
set_palette(colors, 0, 255); // for switching between 8 bpp scalers
|
||||
}
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
#ifdef ANDROID
|
||||
case SDLK_RETURN:
|
||||
#endif
|
||||
if (sel == menu_item_scaler)
|
||||
{
|
||||
do
|
||||
{
|
||||
temp_scaler++;
|
||||
if (temp_scaler == scalers_count)
|
||||
temp_scaler = 0;
|
||||
}
|
||||
while (!can_init_scaler(temp_scaler, fullscreen_enabled));
|
||||
JE_playSampleNum(S_CURSOR);
|
||||
}
|
||||
#ifndef ANDROID
|
||||
|
||||
case MENU_JUKEBOX:
|
||||
JE_playSampleNum(S_SELECT);
|
||||
|
||||
fade_black(10);
|
||||
jukebox();
|
||||
|
||||
memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
|
||||
JE_showVGA();
|
||||
fade_in = true;
|
||||
break;
|
||||
case SDLK_RETURN:
|
||||
#endif
|
||||
case SDLK_SPACE:
|
||||
switch (sel)
|
||||
{
|
||||
case 0: /* About */
|
||||
JE_playSampleNum(S_SELECT);
|
||||
|
||||
scroller_sine(about_text);
|
||||
|
||||
memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
|
||||
JE_showVGA();
|
||||
fade_in = true;
|
||||
break;
|
||||
#ifndef ANDROID
|
||||
case 1: /* Fullscreen */
|
||||
JE_playSampleNum(S_SELECT);
|
||||
|
||||
if (!init_scaler(scaler, !fullscreen_enabled) && // try new fullscreen state
|
||||
!init_any_scaler(!fullscreen_enabled) && // try any scaler in new fullscreen state
|
||||
!init_scaler(scaler, fullscreen_enabled)) // revert on fail
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
set_palette(colors, 0, 255); // for switching between 8 bpp scalers
|
||||
break;
|
||||
#endif
|
||||
case menu_item_scaler: /* Scaler */
|
||||
JE_playSampleNum(S_SELECT);
|
||||
|
||||
if (scaler != temp_scaler)
|
||||
{
|
||||
if (!init_scaler(temp_scaler, fullscreen_enabled) && // try new scaler
|
||||
!init_scaler(temp_scaler, !fullscreen_enabled) && // try other fullscreen state
|
||||
!init_scaler(scaler, fullscreen_enabled)) // revert on fail
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
set_palette(colors, 0, 255); // for switching between 8 bpp scalers
|
||||
}
|
||||
break;
|
||||
case menu_item_jukebox: /* Jukebox */
|
||||
JE_playSampleNum(S_SELECT);
|
||||
|
||||
fade_black(10);
|
||||
jukebox();
|
||||
|
||||
memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
|
||||
JE_showVGA();
|
||||
fade_in = true;
|
||||
break;
|
||||
#ifdef ANDROID
|
||||
case menu_item_destruct: /* Destruct */
|
||||
JE_playSampleNum(S_SELECT);
|
||||
loadDestruct = true;
|
||||
fade_black(10);
|
||||
quit = true;
|
||||
break;
|
||||
#endif
|
||||
default: /* Return to main menu */
|
||||
quit = true;
|
||||
JE_playSampleNum(S_SPRING);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SDLK_ESCAPE:
|
||||
|
||||
case MENU_RETURN:
|
||||
quit = true;
|
||||
JE_playSampleNum(S_SPRING);
|
||||
break;
|
||||
default:
|
||||
|
||||
case MenuOptions_MAX:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDLK_ESCAPE:
|
||||
quit = true;
|
||||
JE_playSampleNum(S_SPRING);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (!quit);
|
||||
@@ -279,15 +288,11 @@ void opentyrian_menu( void )
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
#ifdef ANDROID
|
||||
__android_log_print(ANDROID_LOG_INFO, "OpenTyrian", "SDL_main() called" );
|
||||
#endif
|
||||
|
||||
mt_srand(time(NULL));
|
||||
|
||||
printf("\nWelcome to... >> %s %s <<\n\n", opentyrian_str, opentyrian_version);
|
||||
|
||||
printf("Copyright (C) 2007-2009 The OpenTyrian Development Team\n\n");
|
||||
printf("Copyright (C) 2007-2013 The OpenTyrian Development Team\n\n");
|
||||
|
||||
printf("This program comes with ABSOLUTELY NO WARRANTY.\n");
|
||||
printf("This is free software, and you are welcome to redistribute it\n");
|
||||
@@ -361,10 +366,15 @@ int main( int argc, char *argv[] )
|
||||
|
||||
if (isNetworkGame)
|
||||
{
|
||||
#ifdef WITH_NETWORK
|
||||
if (network_init())
|
||||
{
|
||||
network_tyrian_halt(3, false);
|
||||
}
|
||||
#else
|
||||
fprintf(stderr, "OpenTyrian was compiled without networking support.");
|
||||
JE_tyrianHalt(5);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef NDEBUG
|
||||
@@ -396,4 +406,3 @@ int main( int argc, char *argv[] )
|
||||
return 0;
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -50,6 +50,12 @@ typedef bool JE_boolean;
|
||||
typedef char JE_char;
|
||||
typedef float JE_real;
|
||||
|
||||
#ifdef TYRIAN2000
|
||||
#define TYRIAN_VERSION "2000"
|
||||
#else
|
||||
#define TYRIAN_VERSION "2.1"
|
||||
#endif
|
||||
|
||||
char *strnztcpy( char *to, const char *from, size_t count );
|
||||
|
||||
extern const char *opentyrian_str, *opentyrian_version;
|
||||
@@ -58,4 +64,3 @@ void opentyrian_menu( void );
|
||||
|
||||
#endif /* OPENTYR_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
1464
project/jni/application/opentyrian/src/opl.c
Normal file
1464
project/jni/application/opentyrian/src/opl.c
Normal file
File diff suppressed because it is too large
Load Diff
202
project/jni/application/opentyrian/src/opl.h
Normal file
202
project/jni/application/opentyrian/src/opl.h
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (C) 2002-2010 The DOSBox Team
|
||||
* OPL2/OPL3 emulation library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef OPL_H
|
||||
#define OPL_H
|
||||
/*
|
||||
* Originally based on ADLIBEMU.C, an AdLib/OPL2 emulation library by Ken Silverman
|
||||
* Copyright (C) 1998-2001 Ken Silverman
|
||||
* Ken Silverman's official web site: "http://www.advsys.net/ken"
|
||||
*/
|
||||
|
||||
|
||||
#define fltype double
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
typedef uintptr_t Bitu;
|
||||
typedef intptr_t Bits;
|
||||
typedef uint32_t Bit32u;
|
||||
typedef int32_t Bit32s;
|
||||
typedef uint16_t Bit16u;
|
||||
typedef int16_t Bit16s;
|
||||
typedef uint8_t Bit8u;
|
||||
typedef int8_t Bit8s;
|
||||
|
||||
|
||||
/*
|
||||
define attribution that inlines/forces inlining of a function (optional)
|
||||
*/
|
||||
#define OPL_INLINE inline
|
||||
|
||||
|
||||
#undef NUM_CHANNELS
|
||||
#if defined(OPLTYPE_IS_OPL3)
|
||||
#define NUM_CHANNELS 18
|
||||
#else
|
||||
#define NUM_CHANNELS 9
|
||||
#endif
|
||||
|
||||
#define MAXOPERATORS (NUM_CHANNELS*2)
|
||||
|
||||
|
||||
#define FL05 ((fltype)0.5)
|
||||
#define FL2 ((fltype)2.0)
|
||||
#define PI ((fltype)3.1415926535897932384626433832795)
|
||||
|
||||
|
||||
#define FIXEDPT 0x10000 // fixed-point calculations using 16+16
|
||||
#define FIXEDPT_LFO 0x1000000 // fixed-point calculations using 8+24
|
||||
|
||||
#define WAVEPREC 1024 // waveform precision (10 bits)
|
||||
|
||||
#define INTFREQU ((fltype)(14318180.0 / 288.0)) // clocking of the chip
|
||||
|
||||
|
||||
#define OF_TYPE_ATT 0
|
||||
#define OF_TYPE_DEC 1
|
||||
#define OF_TYPE_REL 2
|
||||
#define OF_TYPE_SUS 3
|
||||
#define OF_TYPE_SUS_NOKEEP 4
|
||||
#define OF_TYPE_OFF 5
|
||||
|
||||
#define ARC_CONTROL 0x00
|
||||
#define ARC_TVS_KSR_MUL 0x20
|
||||
#define ARC_KSL_OUTLEV 0x40
|
||||
#define ARC_ATTR_DECR 0x60
|
||||
#define ARC_SUSL_RELR 0x80
|
||||
#define ARC_FREQ_NUM 0xa0
|
||||
#define ARC_KON_BNUM 0xb0
|
||||
#define ARC_PERC_MODE 0xbd
|
||||
#define ARC_FEEDBACK 0xc0
|
||||
#define ARC_WAVE_SEL 0xe0
|
||||
|
||||
#define ARC_SECONDSET 0x100 // second operator set for OPL3
|
||||
|
||||
|
||||
#define OP_ACT_OFF 0x00
|
||||
#define OP_ACT_NORMAL 0x01 // regular channel activated (bitmasked)
|
||||
#define OP_ACT_PERC 0x02 // percussion channel activated (bitmasked)
|
||||
|
||||
#define BLOCKBUF_SIZE 512
|
||||
|
||||
|
||||
// vibrato constants
|
||||
#define VIBTAB_SIZE 8
|
||||
#define VIBFAC 70/50000 // no braces, integer mul/div
|
||||
|
||||
// tremolo constants and table
|
||||
#define TREMTAB_SIZE 53
|
||||
#define TREM_FREQ ((fltype)(3.7)) // tremolo at 3.7hz
|
||||
|
||||
|
||||
/* operator struct definition
|
||||
For OPL2 all 9 channels consist of two operators each, carrier and modulator.
|
||||
Channel x has operators x as modulator and operators (9+x) as carrier.
|
||||
For OPL3 all 18 channels consist either of two operators (2op mode) or four
|
||||
operators (4op mode) which is determined through register4 of the second
|
||||
adlib register set.
|
||||
Only the channels 0,1,2 (first set) and 9,10,11 (second set) can act as
|
||||
4op channels. The two additional operators for a channel y come from the
|
||||
2op channel y+3 so the operatorss y, (9+y), y+3, (9+y)+3 make up a 4op
|
||||
channel.
|
||||
*/
|
||||
typedef struct operator_struct {
|
||||
Bit32s cval, lastcval; // current output/last output (used for feedback)
|
||||
Bit32u tcount, wfpos, tinc; // time (position in waveform) and time increment
|
||||
fltype amp, step_amp; // and amplification (envelope)
|
||||
fltype vol; // volume
|
||||
fltype sustain_level; // sustain level
|
||||
Bit32s mfbi; // feedback amount
|
||||
fltype a0, a1, a2, a3; // attack rate function coefficients
|
||||
fltype decaymul, releasemul; // decay/release rate functions
|
||||
Bit32u op_state; // current state of operator (attack/decay/sustain/release/off)
|
||||
Bit32u toff;
|
||||
Bit32s freq_high; // highest three bits of the frequency, used for vibrato calculations
|
||||
Bit16s* cur_wform; // start of selected waveform
|
||||
Bit32u cur_wmask; // mask for selected waveform
|
||||
Bit32u act_state; // activity state (regular, percussion)
|
||||
bool sus_keep; // keep sustain level when decay finished
|
||||
bool vibrato,tremolo; // vibrato/tremolo enable bits
|
||||
|
||||
// variables used to provide non-continuous envelopes
|
||||
Bit32u generator_pos; // for non-standard sample rates we need to determine how many samples have passed
|
||||
Bits cur_env_step; // current (standardized) sample position
|
||||
Bits env_step_a,env_step_d,env_step_r; // number of std samples of one step (for attack/decay/release mode)
|
||||
Bit8u step_skip_pos_a; // position of 8-cyclic step skipping (always 2^x to check against mask)
|
||||
Bits env_step_skip_a; // bitmask that determines if a step is skipped (respective bit is zero then)
|
||||
|
||||
#if defined(OPLTYPE_IS_OPL3)
|
||||
bool is_4op,is_4op_attached; // base of a 4op channel/part of a 4op channel
|
||||
Bit32s left_pan,right_pan; // opl3 stereo panning amount
|
||||
#endif
|
||||
} op_type;
|
||||
|
||||
// per-chip variables
|
||||
Bitu chip_num;
|
||||
op_type op[MAXOPERATORS];
|
||||
|
||||
Bits int_samplerate;
|
||||
|
||||
Bit8u status;
|
||||
Bit32u opl_index;
|
||||
#if defined(OPLTYPE_IS_OPL3)
|
||||
Bit8u adlibreg[512]; // adlib register set (including second set)
|
||||
Bit8u wave_sel[44]; // waveform selection
|
||||
#else
|
||||
Bit8u adlibreg[256]; // adlib register set
|
||||
Bit8u wave_sel[22]; // waveform selection
|
||||
#endif
|
||||
|
||||
|
||||
// vibrato/tremolo increment/counter
|
||||
Bit32u vibtab_pos;
|
||||
Bit32u vibtab_add;
|
||||
Bit32u tremtab_pos;
|
||||
Bit32u tremtab_add;
|
||||
|
||||
|
||||
// enable an operator
|
||||
void enable_operator(Bitu regbase, op_type* op_pt, Bit32u act_type);
|
||||
|
||||
// functions to change parameters of an operator
|
||||
void change_frequency(Bitu chanbase, Bitu regbase, op_type* op_pt);
|
||||
|
||||
void change_attackrate(Bitu regbase, op_type* op_pt);
|
||||
void change_decayrate(Bitu regbase, op_type* op_pt);
|
||||
void change_releaserate(Bitu regbase, op_type* op_pt);
|
||||
void change_sustainlevel(Bitu regbase, op_type* op_pt);
|
||||
void change_waveform(Bitu regbase, op_type* op_pt);
|
||||
void change_keepsustain(Bitu regbase, op_type* op_pt);
|
||||
void change_vibrato(Bitu regbase, op_type* op_pt);
|
||||
void change_feedback(Bitu chanbase, op_type* op_pt);
|
||||
|
||||
// general functions
|
||||
void adlib_init(Bit32u samplerate);
|
||||
void adlib_write(Bitu idx, Bit8u val);
|
||||
void adlib_getsample(Bit16s* sndptr, Bits numsamples);
|
||||
|
||||
Bitu adlib_reg_read(Bitu port);
|
||||
void adlib_write_index(Bitu port, Bit8u val);
|
||||
|
||||
#endif /* OPL_H */
|
||||
|
||||
#define opl_init() adlib_init(OUTPUT_QUALITY * 11025)
|
||||
#define opl_write(reg, val) adlib_write(reg, val)
|
||||
#define opl_update(buf, num) adlib_getsample(buf, num)
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -26,7 +26,13 @@
|
||||
|
||||
static Uint32 rgb_to_yuv( int r, int g, int b );
|
||||
|
||||
Palette palettes[23];
|
||||
#ifdef TYRIAN2000
|
||||
#define PALETTE_COUNT 24
|
||||
#else
|
||||
#define PALETTE_COUNT 23
|
||||
#endif
|
||||
|
||||
Palette palettes[PALETTE_COUNT];
|
||||
int palette_count;
|
||||
|
||||
static Palette palette;
|
||||
@@ -39,7 +45,7 @@ void JE_loadPals( void )
|
||||
FILE *f = dir_fopen_die(data_dir(), "palette.dat", "rb");
|
||||
|
||||
palette_count = ftell_eof(f) / (256 * 3);
|
||||
assert(palette_count == 23); // game assumes 23 palettes
|
||||
assert(palette_count == PALETTE_COUNT);
|
||||
|
||||
for (int p = 0; p < palette_count; ++p)
|
||||
{
|
||||
@@ -211,4 +217,3 @@ static Uint32 rgb_to_yuv( int r, int g, int b )
|
||||
return (y << 16) + (u << 8) + v;
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -49,4 +49,3 @@ void fade_white( int steps );
|
||||
|
||||
#endif /* PALETTE_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -65,7 +65,8 @@ void JE_paramCheck( int argc, char *argv[] )
|
||||
|
||||
{ 0, 0, NULL, false}
|
||||
};
|
||||
Option option = { 0, NULL, 0 };
|
||||
|
||||
Option option;
|
||||
|
||||
for (; ; )
|
||||
{
|
||||
@@ -263,4 +264,3 @@ void JE_paramCheck( int argc, char *argv[] )
|
||||
}
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -27,4 +27,3 @@ void JE_paramCheck( int argc, char *argv[] );
|
||||
|
||||
#endif /* PARAMS_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -64,4 +64,3 @@ void JE_loadPCX( const char *file ) // this is only meant to load tshp2.pcx
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -25,4 +25,3 @@ void JE_loadPCX( const char *file );
|
||||
|
||||
#endif /* PCXLOAD_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -46,4 +46,3 @@ const JE_byte facepal[12] = /* [1..12] */
|
||||
|
||||
JE_pcxpostype pcxpos;
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -33,4 +33,3 @@ extern JE_pcxpostype pcxpos;
|
||||
|
||||
#endif /* PCXMAST_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -84,4 +84,3 @@ void JE_loadPic(SDL_Surface *screen, JE_byte PCXnumber, JE_boolean storepal )
|
||||
set_palette(colors, 0, 255);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -25,4 +25,3 @@ void JE_loadPic(SDL_Surface *screen, JE_byte PCXnumber, JE_boolean storepal );
|
||||
|
||||
#endif /* PICLOAD_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -32,6 +32,8 @@
|
||||
#include "vga256d.h"
|
||||
#include "video.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
const struct about_text_type about_text[] =
|
||||
{
|
||||
{0x30, "----- ~OpenTyrian~ -----"},
|
||||
@@ -54,9 +56,9 @@ const struct about_text_type about_text[] =
|
||||
{0x0e, "the game and reporting bugs."},
|
||||
{0x00, ""},
|
||||
{0x00, ""},
|
||||
{0x05, "Thanks to ~MAME~ and ~DOSBox~"},
|
||||
{0x05, "for the FM emulator and"},
|
||||
{0x05, "~AdPlug~ for the Loudness code."},
|
||||
{0x05, "Thanks to ~DOSBox~ for the"},
|
||||
{0x05, "FM-Synthesis emulator and"},
|
||||
{0x05, "~AdPlug~ for the Loudness player."},
|
||||
{0x00, ""},
|
||||
{0x00, ""},
|
||||
{0x32, "And special thanks to ~Jason Emery~"},
|
||||
@@ -154,7 +156,7 @@ void scroller_sine( const struct about_text_type text[] )
|
||||
for (int i = 0; i < MAX_COINS/2; i++)
|
||||
{
|
||||
struct coin_type *coin = &coins[i];
|
||||
blit_sprite2(VGAScreen, coin->x, coin->y, eShapes5, coin_defs[coin->type].shape_num + coin->cur_frame);
|
||||
blit_sprite2(VGAScreen, coin->x, coin->y, eShapes[4], coin_defs[coin->type].shape_num + coin->cur_frame);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +212,7 @@ void scroller_sine( const struct about_text_type text[] )
|
||||
for (int i = MAX_COINS/2; i < MAX_COINS; i++)
|
||||
{
|
||||
struct coin_type *coin = &coins[i];
|
||||
blit_sprite2(VGAScreen, coin->x, coin->y, eShapes5, coin_defs[coin->type].shape_num + coin->cur_frame);
|
||||
blit_sprite2(VGAScreen, coin->x, coin->y, eShapes[4], coin_defs[coin->type].shape_num + coin->cur_frame);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +291,7 @@ void scroller_sine( const struct about_text_type text[] )
|
||||
}
|
||||
beer[i].y += beer[i].vy;
|
||||
|
||||
blit_sprite2x2(VGAScreen, beer[i].x, beer[i].y, eShapes5, BEER_SHAPE);
|
||||
blit_sprite2x2(VGAScreen, beer[i].x, beer[i].y, eShapes[4], BEER_SHAPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,4 +312,3 @@ void scroller_sine( const struct about_text_type text[] )
|
||||
fade_black(10);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -30,4 +30,3 @@ void scroller_sine( const struct about_text_type text[] );
|
||||
|
||||
#endif /* SCROLLER_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -58,7 +58,7 @@ void JE_textMenuWait( JE_word *waitTime, JE_boolean doGamma )
|
||||
lastkey_sym = SDLK_RETURN;
|
||||
}
|
||||
|
||||
if (has_mouse && input_grabbed)
|
||||
if (has_mouse && input_grab_enabled)
|
||||
{
|
||||
#ifdef MENU_SELECT_BY_MOUSE_MOVE
|
||||
/* Whacky hack which changes menu selecton based on
|
||||
@@ -101,4 +101,3 @@ void JE_textMenuWait( JE_word *waitTime, JE_boolean doGamma )
|
||||
} while (!(inputDetected || *waitTime == 1 || haltGame));
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -25,4 +25,3 @@ void JE_textMenuWait( JE_word *waitTime, JE_boolean doGamma );
|
||||
|
||||
#endif /* SETUP_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
499
project/jni/application/opentyrian/src/shots.c
Normal file
499
project/jni/application/opentyrian/src/shots.c
Normal file
@@ -0,0 +1,499 @@
|
||||
/*
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2013 The OpenTyrian Development Team
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include "player.h"
|
||||
#include "shots.h"
|
||||
#include "sprite.h"
|
||||
#include "video.h"
|
||||
#include "varz.h"
|
||||
|
||||
// I'm pretty sure the last extra entry is never used.
|
||||
PlayerShotDataType playerShotData[MAX_PWEAPON + 1]; /* [1..MaxPWeapon+1] */
|
||||
JE_byte shotAvail[MAX_PWEAPON]; /* [1..MaxPWeapon] */ /*0:Avail 1-255:Duration left*/
|
||||
|
||||
void simulate_player_shots( void )
|
||||
{
|
||||
/* Player Shot Images */
|
||||
for (int z = 0; z < MAX_PWEAPON; z++)
|
||||
{
|
||||
if (shotAvail[z] != 0)
|
||||
{
|
||||
shotAvail[z]--;
|
||||
if (z != MAX_PWEAPON - 1)
|
||||
{
|
||||
PlayerShotDataType* shot = &playerShotData[z];
|
||||
|
||||
shot->shotXM += shot->shotXC;
|
||||
|
||||
if (shot->shotXM <= 100)
|
||||
shot->shotX += shot->shotXM;
|
||||
|
||||
shot->shotYM += shot->shotYC;
|
||||
shot->shotY += shot->shotYM;
|
||||
|
||||
if (shot->shotYM > 100)
|
||||
{
|
||||
shot->shotY -= 120;
|
||||
shot->shotY += player[0].delta_y_shot_move;
|
||||
}
|
||||
|
||||
if (shot->shotComplicated != 0)
|
||||
{
|
||||
shot->shotDevX += shot->shotDirX;
|
||||
shot->shotX += shot->shotDevX;
|
||||
|
||||
if (abs(shot->shotDevX) == shot->shotCirSizeX)
|
||||
shot->shotDirX = -shot->shotDirX;
|
||||
|
||||
shot->shotDevY += shot->shotDirY;
|
||||
shot->shotY += shot->shotDevY;
|
||||
|
||||
if (abs(shot->shotDevY) == shot->shotCirSizeY)
|
||||
shot->shotDirY = -shot->shotDirY;
|
||||
/*Double Speed Circle Shots - add a second copy of above loop*/
|
||||
}
|
||||
|
||||
int tempShotX = shot->shotX;
|
||||
int tempShotY = shot->shotY;
|
||||
|
||||
if (shot->shotX < 0 || shot->shotX > 140 ||
|
||||
shot->shotY < 0 || shot->shotY > 170)
|
||||
{
|
||||
shotAvail[z] = 0;
|
||||
goto draw_player_shot_loop_end;
|
||||
}
|
||||
|
||||
/* if (shot->shotTrail != 255)
|
||||
{
|
||||
if (shot->shotTrail == 98)
|
||||
{
|
||||
JE_setupExplosion(shot->shotX - shot->shotXM, shot->shotY - shot->shotYM, shot->shotTrail);
|
||||
} else {
|
||||
JE_setupExplosion(shot->shotX, shot->shotY, shot->shotTrail);
|
||||
}
|
||||
}*/
|
||||
|
||||
JE_word anim_frame = shot->shotGr + shot->shotAni;
|
||||
if (++shot->shotAni == shot->shotAniMax)
|
||||
shot->shotAni = 0;
|
||||
|
||||
if (anim_frame < 6000)
|
||||
{
|
||||
if (anim_frame > 1000)
|
||||
anim_frame = anim_frame % 1000;
|
||||
if (anim_frame > 500)
|
||||
blit_sprite2(VGAScreen, tempShotX+1, tempShotY, shapesW2, anim_frame - 500);
|
||||
else
|
||||
blit_sprite2(VGAScreen, tempShotX+1, tempShotY, shapesC1, anim_frame);
|
||||
}
|
||||
}
|
||||
|
||||
draw_player_shot_loop_end:
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const JE_word linkMultiGr[17] /* [0..16] */ =
|
||||
{77,221,183,301,1,282,164,202,58,201,163,281,39,300,182,220,77};
|
||||
static const JE_word linkSonicGr[17] /* [0..16] */ =
|
||||
{85,242,131,303,47,284,150,223,66,224,149,283,9,302,130,243,85};
|
||||
static const JE_word linkMult2Gr[17] /* [0..16] */ =
|
||||
{78,299,295,297,2,278,276,280,59,279,275,277,40,296,294,298,78};
|
||||
|
||||
void player_shot_set_direction( JE_integer shot_id, uint weapon_id, JE_real direction )
|
||||
{
|
||||
PlayerShotDataType* shot = &playerShotData[shot_id];
|
||||
|
||||
shot->shotXM = -roundf(sinf(direction) * shot->shotYM);
|
||||
shot->shotYM = -roundf(cosf(direction) * shot->shotYM);
|
||||
|
||||
// Some weapons have sprites for each direction, use those.
|
||||
int rounded_dir;
|
||||
|
||||
switch (weapon_id)
|
||||
{
|
||||
case 27:
|
||||
case 32:
|
||||
case 10:
|
||||
rounded_dir = roundf(direction * (16 / (2 * M_PI))); /*16 directions*/
|
||||
shot->shotGr = linkMultiGr[rounded_dir];
|
||||
break;
|
||||
case 28:
|
||||
case 33:
|
||||
case 11:
|
||||
rounded_dir = roundf(direction * (16 / (2 * M_PI))); /*16 directions*/
|
||||
shot->shotGr = linkSonicGr[rounded_dir];
|
||||
break;
|
||||
case 30:
|
||||
case 35:
|
||||
case 14:
|
||||
if (direction > M_PI_2 && direction < M_PI + M_PI_2)
|
||||
{
|
||||
shot->shotYC = 1;
|
||||
}
|
||||
break;
|
||||
case 38:
|
||||
case 22:
|
||||
rounded_dir = roundf(direction * (16 / (2 * M_PI))); /*16 directions*/
|
||||
shot->shotGr = linkMult2Gr[rounded_dir];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool player_shot_move_and_draw(
|
||||
int shot_id, bool* out_is_special,
|
||||
int* out_shotx, int* out_shoty,
|
||||
JE_integer* out_shot_damage, JE_byte* out_blast_filter,
|
||||
JE_byte* out_chain, JE_byte* out_playerNum,
|
||||
JE_word* out_special_radiusw, JE_word* out_special_radiush )
|
||||
{
|
||||
PlayerShotDataType* shot = &playerShotData[shot_id];
|
||||
|
||||
shotAvail[shot_id]--;
|
||||
if (shot_id != MAX_PWEAPON - 1)
|
||||
{
|
||||
shot->shotXM += shot->shotXC;
|
||||
shot->shotX += shot->shotXM;
|
||||
JE_integer tmp_shotXM = shot->shotXM;
|
||||
|
||||
if (shot->shotXM > 100)
|
||||
{
|
||||
if (shot->shotXM == 101)
|
||||
{
|
||||
shot->shotX -= 101;
|
||||
shot->shotX += player[shot->playerNumber-1].delta_x_shot_move;
|
||||
shot->shotY += player[shot->playerNumber-1].delta_y_shot_move;
|
||||
}
|
||||
else
|
||||
{
|
||||
shot->shotX -= 120;
|
||||
shot->shotX += player[shot->playerNumber-1].delta_x_shot_move;
|
||||
}
|
||||
}
|
||||
|
||||
shot->shotYM += shot->shotYC;
|
||||
shot->shotY += shot->shotYM;
|
||||
|
||||
if (shot->shotYM > 100)
|
||||
{
|
||||
shot->shotY -= 120;
|
||||
shot->shotY += player[shot->playerNumber-1].delta_y_shot_move;
|
||||
}
|
||||
|
||||
if (shot->shotComplicated != 0)
|
||||
{
|
||||
shot->shotDevX += shot->shotDirX;
|
||||
shot->shotX += shot->shotDevX;
|
||||
|
||||
if (abs(shot->shotDevX) == shot->shotCirSizeX)
|
||||
shot->shotDirX = -shot->shotDirX;
|
||||
|
||||
shot->shotDevY += shot->shotDirY;
|
||||
shot->shotY += shot->shotDevY;
|
||||
|
||||
if (abs(shot->shotDevY) == shot->shotCirSizeY)
|
||||
shot->shotDirY = -shot->shotDirY;
|
||||
|
||||
/*Double Speed Circle Shots - add a second copy of above loop*/
|
||||
}
|
||||
|
||||
*out_shotx = shot->shotX;
|
||||
*out_shoty = shot->shotY;
|
||||
|
||||
if (shot->shotX < -34 || shot->shotX > 290 ||
|
||||
shot->shotY < -15 || shot->shotY > 190)
|
||||
{
|
||||
shotAvail[shot_id] = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (shot->shotTrail != 255)
|
||||
{
|
||||
if (shot->shotTrail == 98)
|
||||
JE_setupExplosion(shot->shotX - shot->shotXM, shot->shotY - shot->shotYM, 0, shot->shotTrail, false, false);
|
||||
else
|
||||
JE_setupExplosion(shot->shotX, shot->shotY, 0, shot->shotTrail, false, false);
|
||||
}
|
||||
|
||||
if (shot->aimAtEnemy != 0)
|
||||
{
|
||||
if (--shot->aimDelay == 0)
|
||||
{
|
||||
shot->aimDelay = shot->aimDelayMax;
|
||||
|
||||
if (enemyAvail[shot->aimAtEnemy - 1] != 1)
|
||||
{
|
||||
if (shot->shotX < enemy[shot->aimAtEnemy - 1].ex)
|
||||
shot->shotXM++;
|
||||
else
|
||||
shot->shotXM--;
|
||||
|
||||
if (shot->shotY < enemy[shot->aimAtEnemy - 1].ey)
|
||||
shot->shotYM++;
|
||||
else
|
||||
shot->shotYM--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shot->shotXM > 0)
|
||||
shot->shotXM++;
|
||||
else
|
||||
shot->shotXM--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JE_word sprite_frame = shot->shotGr + shot->shotAni;
|
||||
if (++shot->shotAni == shot->shotAniMax)
|
||||
shot->shotAni = 0;
|
||||
|
||||
*out_shot_damage = shot->shotDmg;
|
||||
*out_blast_filter = shot->shotBlastFilter;
|
||||
*out_chain = shot->chainReaction;
|
||||
*out_playerNum = shot->playerNumber;
|
||||
|
||||
*out_is_special = sprite_frame > 60000;
|
||||
|
||||
if (*out_is_special)
|
||||
{
|
||||
blit_sprite_blend(VGAScreen, *out_shotx+1, *out_shoty, OPTION_SHAPES, sprite_frame - 60001);
|
||||
|
||||
*out_special_radiusw = sprite(OPTION_SHAPES, sprite_frame - 60001)->width / 2;
|
||||
*out_special_radiush = sprite(OPTION_SHAPES, sprite_frame - 60001)->height / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sprite_frame > 1000)
|
||||
{
|
||||
JE_doSP(*out_shotx+1 + 6, *out_shoty + 6, 5, 3, (sprite_frame / 1000) << 4);
|
||||
sprite_frame = sprite_frame % 1000;
|
||||
}
|
||||
if (sprite_frame > 500)
|
||||
{
|
||||
if (background2 && *out_shoty + shadowYDist < 190 && tmp_shotXM < 100)
|
||||
blit_sprite2_darken(VGAScreen, *out_shotx+1, *out_shoty + shadowYDist, shapesW2, sprite_frame - 500);
|
||||
blit_sprite2(VGAScreen, *out_shotx+1, *out_shoty, shapesW2, sprite_frame - 500);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (background2 && *out_shoty + shadowYDist < 190 && tmp_shotXM < 100)
|
||||
blit_sprite2_darken(VGAScreen, *out_shotx+1, *out_shoty + shadowYDist, shapesC1, sprite_frame);
|
||||
blit_sprite2(VGAScreen, *out_shotx+1, *out_shoty, shapesC1, sprite_frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
JE_integer player_shot_create( JE_word portNum, uint bay_i, JE_word PX, JE_word PY, JE_word mouseX, JE_word mouseY, JE_word wpNum, JE_byte playerNum )
|
||||
{
|
||||
static const JE_byte soundChannel[11] /* [1..11] */ = {0, 2, 4, 4, 2, 2, 5, 5, 1, 4, 1};
|
||||
|
||||
// Bounds check
|
||||
if (portNum > PORT_NUM || wpNum <= 0 || wpNum > WEAP_NUM)
|
||||
return MAX_PWEAPON;
|
||||
|
||||
const JE_WeaponType* weapon = &weapons[wpNum];
|
||||
|
||||
if (power < weaponPort[portNum].poweruse)
|
||||
return MAX_PWEAPON;
|
||||
power -= weaponPort[portNum].poweruse;
|
||||
|
||||
if (weapon->sound > 0)
|
||||
soundQueue[soundChannel[bay_i]] = weapon->sound;
|
||||
|
||||
int shot_id = MAX_PWEAPON;
|
||||
/*Rot*/
|
||||
for (int multi_i = 1; multi_i <= weapon->multi; multi_i++)
|
||||
{
|
||||
for (shot_id = 0; shot_id < MAX_PWEAPON; shot_id++)
|
||||
if (shotAvail[shot_id] == 0)
|
||||
break;
|
||||
if (shot_id == MAX_PWEAPON)
|
||||
return MAX_PWEAPON;
|
||||
|
||||
if (shotMultiPos[bay_i] == weapon->max || shotMultiPos[bay_i] > 8)
|
||||
shotMultiPos[bay_i] = 1;
|
||||
else
|
||||
shotMultiPos[bay_i]++;
|
||||
|
||||
PlayerShotDataType* shot = &playerShotData[shot_id];
|
||||
shot->chainReaction = 0;
|
||||
|
||||
shot->playerNumber = playerNum;
|
||||
|
||||
shot->shotAni = 0;
|
||||
|
||||
shot->shotComplicated = weapon->circlesize != 0;
|
||||
|
||||
if (weapon->circlesize == 0)
|
||||
{
|
||||
shot->shotDevX = 0;
|
||||
shot->shotDirX = 0;
|
||||
shot->shotDevY = 0;
|
||||
shot->shotDirY = 0;
|
||||
shot->shotCirSizeX = 0;
|
||||
shot->shotCirSizeY = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
JE_byte circsize = weapon->circlesize;
|
||||
|
||||
if (circsize > 19)
|
||||
{
|
||||
JE_byte circsize_mod20 = circsize % 20;
|
||||
shot->shotCirSizeX = circsize_mod20;
|
||||
shot->shotDevX = circsize_mod20 >> 1;
|
||||
|
||||
circsize = circsize / 20;
|
||||
shot->shotCirSizeY = circsize;
|
||||
shot->shotDevY = circsize >> 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
shot->shotCirSizeX = circsize;
|
||||
shot->shotCirSizeY = circsize;
|
||||
shot->shotDevX = circsize >> 1;
|
||||
shot->shotDevY = circsize >> 1;
|
||||
}
|
||||
shot->shotDirX = 1;
|
||||
shot->shotDirY = -1;
|
||||
}
|
||||
|
||||
shot->shotTrail = weapon->trail;
|
||||
|
||||
if (weapon->attack[shotMultiPos[bay_i]-1] > 99 && weapon->attack[shotMultiPos[bay_i]-1] < 250)
|
||||
{
|
||||
shot->chainReaction = weapon->attack[shotMultiPos[bay_i]-1] - 100;
|
||||
shot->shotDmg = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
shot->shotDmg = weapon->attack[shotMultiPos[bay_i]-1];
|
||||
}
|
||||
|
||||
shot->shotBlastFilter = weapon->shipblastfilter;
|
||||
|
||||
JE_integer tmp_by = weapon->by[shotMultiPos[bay_i]-1];
|
||||
|
||||
/*Note: Only front selection used for player shots...*/
|
||||
|
||||
shot->shotX = PX + weapon->bx[shotMultiPos[bay_i]-1];
|
||||
|
||||
shot->shotY = PY + tmp_by;
|
||||
shot->shotYC = -weapon->acceleration;
|
||||
shot->shotXC = weapon->accelerationx;
|
||||
|
||||
shot->shotXM = weapon->sx[shotMultiPos[bay_i]-1];
|
||||
|
||||
// Not sure what this field does exactly.
|
||||
JE_byte del = weapon->del[shotMultiPos[bay_i]-1];
|
||||
|
||||
if (del == 121)
|
||||
{
|
||||
shot->shotTrail = 0;
|
||||
del = 255;
|
||||
}
|
||||
|
||||
shot->shotGr = weapon->sg[shotMultiPos[bay_i]-1];
|
||||
if (shot->shotGr == 0)
|
||||
shotAvail[shot_id] = 0;
|
||||
else
|
||||
shotAvail[shot_id] = del;
|
||||
|
||||
if (del > 100 && del < 120)
|
||||
shot->shotAniMax = (del - 100 + 1);
|
||||
else
|
||||
shot->shotAniMax = weapon->weapani + 1;
|
||||
|
||||
if (del == 99 || del == 98)
|
||||
{
|
||||
tmp_by = PX - mouseX;
|
||||
if (tmp_by < -5)
|
||||
tmp_by = -5;
|
||||
else if (tmp_by > 5)
|
||||
tmp_by = 5;
|
||||
shot->shotXM += tmp_by;
|
||||
}
|
||||
|
||||
if (del == 99 || del == 100)
|
||||
{
|
||||
tmp_by = PY - mouseY - weapon->sy[shotMultiPos[bay_i]-1];
|
||||
if (tmp_by < -4)
|
||||
tmp_by = -4;
|
||||
else if (tmp_by > 4)
|
||||
tmp_by = 4;
|
||||
shot->shotYM = tmp_by;
|
||||
}
|
||||
else if (weapon->sy[shotMultiPos[bay_i]-1] == 98)
|
||||
{
|
||||
shot->shotYM = 0;
|
||||
shot->shotYC = -1;
|
||||
}
|
||||
else if (weapon->sy[shotMultiPos[bay_i]-1] > 100)
|
||||
{
|
||||
shot->shotYM = weapon->sy[shotMultiPos[bay_i]-1];
|
||||
shot->shotY -= player[shot->playerNumber-1].delta_y_shot_move;
|
||||
}
|
||||
else
|
||||
{
|
||||
shot->shotYM = -weapon->sy[shotMultiPos[bay_i]-1];
|
||||
}
|
||||
|
||||
if (weapon->sx[shotMultiPos[bay_i]-1] > 100)
|
||||
{
|
||||
shot->shotXM = weapon->sx[shotMultiPos[bay_i]-1];
|
||||
shot->shotX -= player[shot->playerNumber-1].delta_x_shot_move;
|
||||
if (shot->shotXM == 101)
|
||||
shot->shotY -= player[shot->playerNumber-1].delta_y_shot_move;
|
||||
}
|
||||
|
||||
|
||||
if (weapon->aim > 5) /*Guided Shot*/
|
||||
{
|
||||
uint best_dist = 65000;
|
||||
JE_byte closest_enemy = 0;
|
||||
/*Find Closest Enemy*/
|
||||
for (x = 0; x < 100; x++)
|
||||
{
|
||||
if (enemyAvail[x] != 1 && !enemy[x].scoreitem)
|
||||
{
|
||||
y = abs(enemy[x].ex - shot->shotX) + abs(enemy[x].ey - shot->shotY);
|
||||
if (y < best_dist)
|
||||
{
|
||||
best_dist = y;
|
||||
closest_enemy = x + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
shot->aimAtEnemy = closest_enemy;
|
||||
shot->aimDelay = 5;
|
||||
shot->aimDelayMax = weapon->aim - 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
shot->aimAtEnemy = 0;
|
||||
}
|
||||
|
||||
shotRepeat[bay_i] = weapon->shotrepeat;
|
||||
}
|
||||
|
||||
return shot_id;
|
||||
}
|
||||
58
project/jni/application/opentyrian/src/shots.h
Normal file
58
project/jni/application/opentyrian/src/shots.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2013 The OpenTyrian Development Team
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef SHOTS_H
|
||||
#define SHOTS_H
|
||||
#include "opentyr.h"
|
||||
|
||||
typedef struct {
|
||||
JE_integer shotX, shotY, shotXM, shotYM, shotXC, shotYC;
|
||||
JE_boolean shotComplicated;
|
||||
JE_integer shotDevX, shotDirX, shotDevY, shotDirY, shotCirSizeX, shotCirSizeY;
|
||||
JE_byte shotTrail;
|
||||
JE_word shotGr, shotAni, shotAniMax;
|
||||
Uint8 shotDmg;
|
||||
JE_byte shotBlastFilter, chainReaction, playerNumber, aimAtEnemy, aimDelay, aimDelayMax;
|
||||
} PlayerShotDataType;
|
||||
|
||||
#define MAX_PWEAPON 81 /* 81*/
|
||||
extern PlayerShotDataType playerShotData[MAX_PWEAPON + 1];
|
||||
extern JE_byte shotAvail[MAX_PWEAPON];
|
||||
|
||||
/** Used in the shop to show weapon previews. */
|
||||
void simulate_player_shots( void );
|
||||
|
||||
/** Points shot movement in the specified direction. Used for the turret gun. */
|
||||
void player_shot_set_direction( JE_integer shot_id, uint weapon_id, JE_real direction );
|
||||
|
||||
/** Moves and draws a shot. Does \b not collide it with enemies.
|
||||
* \return False if the shot went offscreen, true otherwise.
|
||||
*/
|
||||
bool player_shot_move_and_draw(
|
||||
int shot_id, bool* out_is_special,
|
||||
int* out_shotx, int* out_shoty,
|
||||
JE_integer* out_shot_damage, JE_byte* out_blast_filter,
|
||||
JE_byte* out_chain, JE_byte* out_playerNum,
|
||||
JE_word* out_special_radiusw, JE_word* out_special_radiush );
|
||||
|
||||
/** Creates a player shot. */
|
||||
JE_integer player_shot_create( JE_word portnum, uint shot_i, JE_word px, JE_word py,
|
||||
JE_word mousex, JE_word mousey,
|
||||
JE_word wpnum, JE_byte playernum );
|
||||
|
||||
#endif // SHOTS_H
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -39,6 +39,8 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "SDL_endian.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Construct buffer with the passed array and size */
|
||||
void SZ_Init(sizebuf_t * sz, Uint8 * buf, unsigned int size)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -75,4 +75,3 @@ const JE_byte windowTextSamples[9] = /* [1..9] */
|
||||
V_ENEMIES
|
||||
};
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -73,4 +73,3 @@ extern const JE_byte windowTextSamples[9];
|
||||
|
||||
#endif /* SNDMAST_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -22,10 +22,11 @@
|
||||
#include "video.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
Sprite_array sprite_table[SPRITE_TABLES_MAX];
|
||||
|
||||
Sprite2_array eShapes1, eShapes2, eShapes3, eShapes4, eShapes5, eShapes6;
|
||||
Sprite2_array eShapes[6];
|
||||
Sprite2_array shapesC1, shapes6, shapes9, shapesW2;
|
||||
|
||||
void load_sprites_file( unsigned int table, const char *filename )
|
||||
@@ -48,6 +49,8 @@ void load_sprites( unsigned int table, FILE *f )
|
||||
|
||||
sprite_table[table].count = temp;
|
||||
|
||||
assert(sprite_table[table].count <= SPRITES_PER_TABLE_MAX);
|
||||
|
||||
for (unsigned int i = 0; i < sprite_table[table].count; ++i)
|
||||
{
|
||||
Sprite * const cur_sprite = sprite(table, i);
|
||||
@@ -665,7 +668,11 @@ void blit_sprite2x2_darken( SDL_Surface *surface, int x, int y, Sprite2_array sp
|
||||
|
||||
void JE_loadMainShapeTables( const char *shpfile )
|
||||
{
|
||||
#ifdef TYRIAN2000
|
||||
const int SHP_NUM = 13;
|
||||
#else
|
||||
const int SHP_NUM = 12;
|
||||
#endif
|
||||
|
||||
FILE *f = dir_fopen_die(data_dir(), shpfile, "rb");
|
||||
|
||||
@@ -673,14 +680,14 @@ void JE_loadMainShapeTables( const char *shpfile )
|
||||
JE_longint shpPos[SHP_NUM + 1]; // +1 for storing file length
|
||||
|
||||
efread(&shpNumb, sizeof(JE_word), 1, f);
|
||||
assert(shpNumb + 1u <= COUNTOF(shpPos));
|
||||
assert(shpNumb + 1u == COUNTOF(shpPos));
|
||||
|
||||
for (int i = 0; i < shpNumb; i++)
|
||||
{
|
||||
for (unsigned int i = 0; i < shpNumb; ++i)
|
||||
efread(&shpPos[i], sizeof(JE_longint), 1, f);
|
||||
}
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
shpPos[shpNumb] = ftell(f);
|
||||
for (unsigned int i = shpNumb; i < COUNTOF(shpPos); ++i)
|
||||
shpPos[i] = ftell(f);
|
||||
|
||||
int i;
|
||||
// fonts, interface, option sprites
|
||||
@@ -701,13 +708,13 @@ void JE_loadMainShapeTables( const char *shpfile )
|
||||
i++;
|
||||
|
||||
// power-up sprites
|
||||
eShapes6.size = shpPos[i + 1] - shpPos[i];
|
||||
JE_loadCompShapesB(&eShapes6, f);
|
||||
eShapes[5].size = shpPos[i + 1] - shpPos[i];
|
||||
JE_loadCompShapesB(&eShapes[5], f);
|
||||
i++;
|
||||
|
||||
// coins, datacubes, etc sprites
|
||||
eShapes5.size = shpPos[i + 1] - shpPos[i];
|
||||
JE_loadCompShapesB(&eShapes5, f);
|
||||
eShapes[4].size = shpPos[i + 1] - shpPos[i];
|
||||
JE_loadCompShapesB(&eShapes[4], f);
|
||||
i++;
|
||||
|
||||
// more player shot sprites
|
||||
@@ -724,9 +731,7 @@ void free_main_shape_tables( void )
|
||||
|
||||
free_sprite2s(&shapesC1);
|
||||
free_sprite2s(&shapes9);
|
||||
free_sprite2s(&eShapes6);
|
||||
free_sprite2s(&eShapes5);
|
||||
free_sprite2s(&eShapes[5]);
|
||||
free_sprite2s(&eShapes[4]);
|
||||
free_sprite2s(&shapesW2);
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "SDL.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define FONT_SHAPES 0
|
||||
#define SMALL_FONT_SHAPES 1
|
||||
@@ -34,7 +35,11 @@
|
||||
#define EXTRA_SHAPES 7 /*Used for Ending pics*/
|
||||
|
||||
#define SPRITE_TABLES_MAX 8
|
||||
#ifdef TYRIAN2000
|
||||
#define SPRITES_PER_TABLE_MAX 152
|
||||
#else
|
||||
#define SPRITES_PER_TABLE_MAX 151
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -91,7 +96,7 @@ typedef struct
|
||||
}
|
||||
Sprite2_array;
|
||||
|
||||
extern Sprite2_array eShapes1, eShapes2, eShapes3, eShapes4, eShapes5, eShapes6;
|
||||
extern Sprite2_array eShapes[6];
|
||||
extern Sprite2_array shapesC1, shapes6, shapes9, shapesW2;
|
||||
|
||||
void JE_loadCompShapes( Sprite2_array *, JE_char s );
|
||||
@@ -112,4 +117,3 @@ void free_main_shape_tables( void );
|
||||
|
||||
#endif // SPRITE_H
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -429,4 +429,3 @@ void JE_newStar( void )
|
||||
}
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -30,4 +30,3 @@ void JE_newStar( void );
|
||||
|
||||
#endif /* STARLIB_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -39,11 +39,11 @@ extern boss_bar_t boss_bar[2];
|
||||
extern char tempStr[31];
|
||||
extern JE_byte itemAvail[9][10], itemAvailMax[9];
|
||||
|
||||
void JE_createNewEventEnemy( JE_byte enemytypeofs, JE_word enemyoffset );
|
||||
void JE_createNewEventEnemy( JE_byte enemytypeofs, JE_word enemyoffset, Sint16 uniqueShapeTableI );
|
||||
|
||||
void JE_doNetwork( void );
|
||||
|
||||
uint JE_makeEnemy( struct JE_SingleEnemyType *enemy );
|
||||
uint JE_makeEnemy( struct JE_SingleEnemyType *enemy, Uint16 eDatI, Sint16 uniqueShapeTableI );
|
||||
|
||||
void JE_eventJump( JE_word jump );
|
||||
|
||||
@@ -51,7 +51,7 @@ void JE_whoa( void );
|
||||
|
||||
void JE_barX ( JE_word x1, JE_word y1, JE_word x2, JE_word y2, JE_byte col );
|
||||
|
||||
void JE_newEnemy( int enemyOffset );
|
||||
Sint16 JE_newEnemy( int enemyOffset, Uint16 eDatI, Sint16 uniqueShapeTableI );
|
||||
void JE_drawEnemy( int enemyOffset );
|
||||
void JE_starShowVGA( void );
|
||||
|
||||
@@ -61,11 +61,10 @@ bool JE_titleScreen( JE_boolean animate );
|
||||
void JE_readTextSync( void );
|
||||
void JE_displayText( void );
|
||||
|
||||
JE_boolean JE_searchFor( JE_byte PLType );
|
||||
bool JE_searchFor( JE_byte PLType, JE_byte* out_index );
|
||||
void JE_eventSystem( void );
|
||||
|
||||
void draw_boss_bar( void );
|
||||
|
||||
#endif /* TYRIAN2_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "nortsong.h"
|
||||
#include "nortvars.h"
|
||||
#include "opentyr.h"
|
||||
#include "shots.h"
|
||||
#include "sprite.h"
|
||||
#include "varz.h"
|
||||
#include "vga256d.h"
|
||||
@@ -98,13 +99,6 @@ const JE_word chargeGunWeapons[38] /* [1..38] */ =
|
||||
0,0,0,0,0,0,0,0,476,458,464,482,0,488,470,0,0,0,0,0,494,500,0,528,0,558,
|
||||
458,458,458,458,458,458,458,458,458,458,458,458
|
||||
};
|
||||
const JE_word linkMultiGr[17] /* [0..16] */ =
|
||||
{77,221,183,301,1,282,164,202,58,201,163,281,39,300,182,220,77};
|
||||
const JE_word linkSonicGr[17] /* [0..16] */ =
|
||||
{85,242,131,303,47,284,150,223,66,224,149,283,9,302,130,243,85};
|
||||
const JE_word linkMult2Gr[17] /* [0..16] */ =
|
||||
{78,299,295,297,2,278,276,280,59,279,275,277,40,296,294,298,78};
|
||||
|
||||
const JE_byte randomEnemyLaunchSounds[3] /* [1..3] */ = {13,6,26};
|
||||
|
||||
/* YKS: Twiddle cheat sheet:
|
||||
@@ -259,12 +253,11 @@ JE_boolean moveTyrianLogoUp;
|
||||
JE_boolean skipStarShowVGA;
|
||||
|
||||
/*EnemyData*/
|
||||
JE_EnemyType enemy;
|
||||
JE_EnemyAvailType enemyAvail;
|
||||
JE_MultiEnemyType enemy;
|
||||
JE_EnemyAvailType enemyAvail; /* values: 0: used, 1: free, 2: secret pick-up */
|
||||
JE_word enemyOffset;
|
||||
JE_word enemyOnScreen;
|
||||
JE_byte enemyShapeTables[6]; /* [1..6] */
|
||||
JE_boolean uniqueEnemy;
|
||||
JE_word superEnemy254Jump;
|
||||
|
||||
/*EnemyShotData*/
|
||||
@@ -284,14 +277,9 @@ JE_boolean spraySpecial;
|
||||
JE_byte doIced;
|
||||
JE_boolean infiniteShot;
|
||||
|
||||
PlayerShotDataType playerShotData[MAX_PWEAPON + 1]; /* [1..MaxPWeapon+1] */
|
||||
|
||||
JE_byte chain;
|
||||
|
||||
/*PlayerData*/
|
||||
JE_boolean allPlayersGone; /*Both players dead and finished exploding*/
|
||||
|
||||
JE_byte shotAvail[MAX_PWEAPON]; /* [1..MaxPWeapon] */ /*0:Avail 1-255:Duration left*/
|
||||
const uint shadowYDist = 10;
|
||||
|
||||
JE_real optionSatelliteRotate;
|
||||
@@ -317,18 +305,14 @@ superpixel_type superpixels[MAX_SUPERPIXELS]; /* [0..MaxSP] */
|
||||
unsigned int last_superpixel;
|
||||
|
||||
/*Temporary Numbers*/
|
||||
JE_integer tempI, tempI2, tempI3, tempI4;
|
||||
JE_longint tempL;
|
||||
|
||||
JE_byte temp, temp2, temp3, temp4, temp5, tempPos;
|
||||
JE_word tempX, tempY, tempX2, tempY2;
|
||||
JE_word tempW, tempW2;
|
||||
JE_byte temp, temp2, temp3;
|
||||
JE_word tempX, tempY;
|
||||
JE_word tempW;
|
||||
|
||||
JE_boolean doNotSaveBackup;
|
||||
|
||||
JE_word x, y;
|
||||
JE_integer b;
|
||||
JE_byte playerNum;
|
||||
|
||||
JE_byte **BKwrap1to, **BKwrap2to, **BKwrap3to,
|
||||
**BKwrap1, **BKwrap2, **BKwrap3;
|
||||
@@ -517,217 +501,6 @@ void JE_tyrianHalt( JE_byte code )
|
||||
exit(code);
|
||||
}
|
||||
|
||||
void JE_initPlayerShot( JE_word portNum, uint shot_i, JE_word PX, JE_word PY, JE_word mouseX, JE_word mouseY, JE_word wpNum, JE_byte playerNum )
|
||||
{
|
||||
const JE_byte soundChannel[11] /* [1..11] */ = {0, 2, 4, 4, 2, 2, 5, 5, 1, 4, 1};
|
||||
|
||||
if (portNum <= PORT_NUM)
|
||||
{
|
||||
if (wpNum > 0 && wpNum <= WEAP_NUM)
|
||||
{
|
||||
if (power >= weaponPort[portNum].poweruse)
|
||||
{
|
||||
power -= weaponPort[portNum].poweruse;
|
||||
|
||||
if (weapons[wpNum].sound > 0)
|
||||
{
|
||||
soundQueue[soundChannel[shot_i]] = weapons[wpNum].sound;
|
||||
}
|
||||
|
||||
/*Rot*/
|
||||
for (tempW = 1; tempW <= weapons[wpNum].multi; tempW++)
|
||||
{
|
||||
|
||||
for (b = 0; b < MAX_PWEAPON; b++)
|
||||
{
|
||||
if (shotAvail[b] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (b == MAX_PWEAPON)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (shotMultiPos[shot_i] == weapons[wpNum].max || shotMultiPos[shot_i] > 8)
|
||||
{
|
||||
shotMultiPos[shot_i] = 1;
|
||||
} else {
|
||||
shotMultiPos[shot_i]++;
|
||||
}
|
||||
|
||||
playerShotData[b].chainReaction = 0;
|
||||
|
||||
playerShotData[b].playerNumber = playerNum;
|
||||
|
||||
playerShotData[b].shotAni = 0;
|
||||
|
||||
playerShotData[b].shotComplicated = weapons[wpNum].circlesize != 0;
|
||||
|
||||
if (weapons[wpNum].circlesize == 0)
|
||||
{
|
||||
playerShotData[b].shotDevX = 0;
|
||||
playerShotData[b].shotDirX = 0;
|
||||
playerShotData[b].shotDevY = 0;
|
||||
playerShotData[b].shotDirY = 0;
|
||||
playerShotData[b].shotCirSizeX = 0;
|
||||
playerShotData[b].shotCirSizeY = 0;
|
||||
} else {
|
||||
temp2 = weapons[wpNum].circlesize;
|
||||
|
||||
if (temp2 > 19)
|
||||
{
|
||||
temp3 = temp2 % 20;
|
||||
playerShotData[b].shotCirSizeX = temp3;
|
||||
playerShotData[b].shotDevX = temp3 >> 1;
|
||||
|
||||
temp2 = temp2 / 20;
|
||||
playerShotData[b].shotCirSizeY = temp2;
|
||||
playerShotData[b].shotDevY = temp2 >> 1;
|
||||
} else {
|
||||
playerShotData[b].shotCirSizeX = temp2;
|
||||
playerShotData[b].shotCirSizeY = temp2;
|
||||
playerShotData[b].shotDevX = temp2 >> 1;
|
||||
playerShotData[b].shotDevY = temp2 >> 1;
|
||||
}
|
||||
playerShotData[b].shotDirX = 1;
|
||||
playerShotData[b].shotDirY = -1;
|
||||
}
|
||||
|
||||
playerShotData[b].shotTrail = weapons[wpNum].trail;
|
||||
|
||||
if (weapons[wpNum].attack[shotMultiPos[shot_i]-1] > 99 && weapons[wpNum].attack[shotMultiPos[shot_i]-1] < 250)
|
||||
{
|
||||
playerShotData[b].chainReaction = weapons[wpNum].attack[shotMultiPos[shot_i]-1] - 100;
|
||||
playerShotData[b].shotDmg = 1;
|
||||
} else {
|
||||
playerShotData[b].shotDmg = weapons[wpNum].attack[shotMultiPos[shot_i]-1];
|
||||
}
|
||||
|
||||
playerShotData[b].shotBlastFilter = weapons[wpNum].shipblastfilter;
|
||||
|
||||
tempI = weapons[wpNum].by[shotMultiPos[shot_i]-1];
|
||||
|
||||
/*Note: Only front selection used for player shots...*/
|
||||
|
||||
playerShotData[b].shotX = PX + weapons[wpNum].bx[shotMultiPos[shot_i]-1];
|
||||
|
||||
playerShotData[b].shotY = PY + tempI;
|
||||
playerShotData[b].shotYC = -weapons[wpNum].acceleration;
|
||||
playerShotData[b].shotXC = weapons[wpNum].accelerationx;
|
||||
|
||||
playerShotData[b].shotXM = weapons[wpNum].sx[shotMultiPos[shot_i]-1];
|
||||
|
||||
temp2 = weapons[wpNum].del[shotMultiPos[shot_i]-1];
|
||||
|
||||
if (temp2 == 121)
|
||||
{
|
||||
playerShotData[b].shotTrail = 0;
|
||||
temp2 = 255;
|
||||
}
|
||||
|
||||
playerShotData[b].shotGr = weapons[wpNum].sg[shotMultiPos[shot_i]-1];
|
||||
if (playerShotData[b].shotGr == 0)
|
||||
{
|
||||
shotAvail[b] = 0;
|
||||
} else {
|
||||
shotAvail[b] = temp2;
|
||||
}
|
||||
if (temp2 > 100 && temp2 < 120)
|
||||
{
|
||||
playerShotData[b].shotAniMax = (temp2 - 100 + 1);
|
||||
} else {
|
||||
playerShotData[b].shotAniMax = weapons[wpNum].weapani + 1;
|
||||
}
|
||||
|
||||
if (temp2 == 99 || temp2 == 98)
|
||||
{
|
||||
tempI = PX - mouseX;
|
||||
if (tempI < -5)
|
||||
{
|
||||
tempI = -5;
|
||||
}
|
||||
if (tempI > 5)
|
||||
{
|
||||
tempI = 5;
|
||||
}
|
||||
playerShotData[b].shotXM += tempI;
|
||||
}
|
||||
|
||||
|
||||
if (temp2 == 99 || temp2 == 100)
|
||||
{
|
||||
tempI = PY - mouseY - weapons[wpNum].sy[shotMultiPos[shot_i]-1];
|
||||
if (tempI < -4)
|
||||
{
|
||||
tempI = -4;
|
||||
}
|
||||
if (tempI > 4)
|
||||
{
|
||||
tempI = 4;
|
||||
}
|
||||
playerShotData[b].shotYM = tempI;
|
||||
} else {
|
||||
if (weapons[wpNum].sy[shotMultiPos[shot_i]-1] == 98)
|
||||
{
|
||||
playerShotData[b].shotYM = 0;
|
||||
playerShotData[b].shotYC = -1;
|
||||
} else {
|
||||
if (weapons[wpNum].sy[shotMultiPos[shot_i]-1] > 100)
|
||||
{
|
||||
playerShotData[b].shotYM = weapons[wpNum].sy[shotMultiPos[shot_i]-1];
|
||||
playerShotData[b].shotY -= player[playerShotData[b].playerNumber-1].delta_y_shot_move;
|
||||
} else {
|
||||
playerShotData[b].shotYM = -weapons[wpNum].sy[shotMultiPos[shot_i]-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (weapons[wpNum].sx[shotMultiPos[shot_i]-1] > 100)
|
||||
{
|
||||
playerShotData[b].shotXM = weapons[wpNum].sx[shotMultiPos[shot_i]-1];
|
||||
playerShotData[b].shotX -= player[playerShotData[b].playerNumber-1].delta_x_shot_move;
|
||||
if (playerShotData[b].shotXM == 101)
|
||||
{
|
||||
playerShotData[b].shotY -= player[playerShotData[b].playerNumber-1].delta_y_shot_move;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (weapons[wpNum].aim > 5) /*Guided Shot*/
|
||||
{
|
||||
uint best_dist = 65000;
|
||||
temp3 = 0;
|
||||
/*Find Closest Enemy*/
|
||||
for (x = 0; x < 100; x++)
|
||||
{
|
||||
if (enemyAvail[x] != 1 && !enemy[x].scoreitem)
|
||||
{
|
||||
y = abs(enemy[x].ex - playerShotData[b].shotX) + abs(enemy[x].ey - playerShotData[b].shotY);
|
||||
if (y < best_dist)
|
||||
{
|
||||
best_dist = y;
|
||||
temp3 = x + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
playerShotData[b].aimAtEnemy = temp3;
|
||||
playerShotData[b].aimDelay = 5;
|
||||
playerShotData[b].aimDelayMax = weapons[wpNum].aim - 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerShotData[b].aimAtEnemy = 0;
|
||||
}
|
||||
|
||||
shotRepeat[shot_i] = weapons[wpNum].shotrepeat;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JE_specialComplete( JE_byte playerNum, JE_byte specialType )
|
||||
{
|
||||
nextSpecialWait = 0;
|
||||
@@ -736,9 +509,9 @@ void JE_specialComplete( JE_byte playerNum, JE_byte specialType )
|
||||
/*Weapon*/
|
||||
case 1:
|
||||
if (playerNum == 1)
|
||||
JE_initPlayerShot(0, SHOT_SPECIAL2, player[0].x, player[0].y, mouseX, mouseY, special[specialType].wpn, playerNum);
|
||||
b = player_shot_create(0, SHOT_SPECIAL2, player[0].x, player[0].y, mouseX, mouseY, special[specialType].wpn, playerNum);
|
||||
else
|
||||
JE_initPlayerShot(0, SHOT_SPECIAL2, player[1].x, player[1].y, mouseX, mouseY, special[specialType].wpn, playerNum);
|
||||
b = player_shot_create(0, SHOT_SPECIAL2, player[1].x, player[1].y, mouseX, mouseY, special[specialType].wpn, playerNum);
|
||||
|
||||
shotRepeat[SHOT_SPECIAL] = shotRepeat[SHOT_SPECIAL2];
|
||||
break;
|
||||
@@ -859,7 +632,7 @@ void JE_specialComplete( JE_byte playerNum, JE_byte specialType )
|
||||
if (superArcadeMode > 0 && superArcadeMode <= SA)
|
||||
{
|
||||
shotRepeat[SHOT_SPECIAL] = 250;
|
||||
JE_initPlayerShot(0, SHOT_SPECIAL2, player[0].x, player[0].y, mouseX, mouseY, 707, 1);
|
||||
b = player_shot_create(0, SHOT_SPECIAL2, player[0].x, player[0].y, mouseX, mouseY, 707, 1);
|
||||
player[0].invulnerable_ticks = 100;
|
||||
}
|
||||
break;
|
||||
@@ -1036,21 +809,21 @@ void JE_doSpecialShot( JE_byte playerNum, uint *armor, uint *shield )
|
||||
|
||||
if ((signed)(mt_rand() % 6) < specialWeaponFreq)
|
||||
{
|
||||
b = 0;
|
||||
b = MAX_PWEAPON;
|
||||
|
||||
if (linkToPlayer)
|
||||
{
|
||||
if (shotRepeat[SHOT_SPECIAL] == 0)
|
||||
{
|
||||
JE_initPlayerShot(0, SHOT_SPECIAL, player[0].x, player[0].y, mouseX, mouseY, specialWeaponWpn, playerNum);
|
||||
b = player_shot_create(0, SHOT_SPECIAL, player[0].x, player[0].y, mouseX, mouseY, specialWeaponWpn, playerNum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JE_initPlayerShot(0, SHOT_SPECIAL, mt_rand() % 280, mt_rand() % 180, mouseX, mouseY, specialWeaponWpn, playerNum);
|
||||
b = player_shot_create(0, SHOT_SPECIAL, mt_rand() % 280, mt_rand() % 180, mouseX, mouseY, specialWeaponWpn, playerNum);
|
||||
}
|
||||
|
||||
if (spraySpecial && b > 0)
|
||||
if (spraySpecial && b != MAX_PWEAPON)
|
||||
{
|
||||
playerShotData[b].shotXM = (mt_rand() % 5) - 2;
|
||||
playerShotData[b].shotYM = (mt_rand() % 5) - 2;
|
||||
@@ -1409,4 +1182,3 @@ void JE_drawSP( void )
|
||||
}
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -42,7 +42,6 @@ enum
|
||||
SA_ARCADE = 255
|
||||
};
|
||||
|
||||
#define MAX_PWEAPON 81 /* 81*/
|
||||
#define ENEMY_SHOT_MAX 60 /* 60*/
|
||||
|
||||
#define CURRENT_KEY_SPEED 1 /*Keyboard/Joystick movement rate*/
|
||||
@@ -168,7 +167,6 @@ struct JE_MegaDataType3
|
||||
JE_byte tempdat3;
|
||||
};
|
||||
|
||||
typedef JE_MultiEnemyType JE_EnemyType;
|
||||
typedef JE_byte JE_EnemyAvailType[100]; /* [1..100] */
|
||||
|
||||
typedef struct {
|
||||
@@ -184,16 +182,6 @@ typedef struct {
|
||||
JE_byte fill[12];
|
||||
} EnemyShotType;
|
||||
|
||||
typedef struct {
|
||||
JE_integer shotX, shotY, shotXM, shotYM, shotXC, shotYC;
|
||||
JE_boolean shotComplicated;
|
||||
JE_integer shotDevX, shotDirX, shotDevY, shotDirY, shotCirSizeX, shotCirSizeY;
|
||||
JE_byte shotTrail;
|
||||
JE_word shotGr, shotAni, shotAniMax;
|
||||
Uint8 shotDmg;
|
||||
JE_byte shotBlastFilter, chainReaction, playerNumber, aimAtEnemy, aimDelay, aimDelayMax;
|
||||
} PlayerShotDataType;
|
||||
|
||||
typedef struct {
|
||||
unsigned int ttl;
|
||||
signed int x, y;
|
||||
@@ -228,9 +216,6 @@ extern const JE_word PGR[21];
|
||||
extern const JE_byte PAni[21];
|
||||
extern const JE_word linkGunWeapons[38];
|
||||
extern const JE_word chargeGunWeapons[38];
|
||||
extern const JE_word linkMultiGr[17];
|
||||
extern const JE_word linkSonicGr[17];
|
||||
extern const JE_word linkMult2Gr[17];
|
||||
extern const JE_byte randomEnemyLaunchSounds[3];
|
||||
extern const JE_byte keyboardCombos[26][8];
|
||||
extern const JE_byte shipCombosB[21];
|
||||
@@ -293,12 +278,11 @@ extern JE_word mapOrigin, mapPNum;
|
||||
extern JE_byte mapPlanet[5], mapSection[5];
|
||||
extern JE_boolean moveTyrianLogoUp;
|
||||
extern JE_boolean skipStarShowVGA;
|
||||
extern JE_EnemyType enemy;
|
||||
extern JE_MultiEnemyType enemy;
|
||||
extern JE_EnemyAvailType enemyAvail;
|
||||
extern JE_word enemyOffset;
|
||||
extern JE_word enemyOnScreen;
|
||||
extern JE_byte enemyShapeTables[6];
|
||||
extern JE_boolean uniqueEnemy;
|
||||
extern JE_word superEnemy254Jump;
|
||||
extern explosion_type explosions[MAX_EXPLOSIONS];
|
||||
extern JE_integer explosionFollowAmountX, explosionFollowAmountY;
|
||||
@@ -315,10 +299,7 @@ extern JE_byte nextSpecialWait;
|
||||
extern JE_boolean spraySpecial;
|
||||
extern JE_byte doIced;
|
||||
extern JE_boolean infiniteShot;
|
||||
extern PlayerShotDataType playerShotData[MAX_PWEAPON + 1];
|
||||
extern JE_byte chain;
|
||||
extern JE_boolean allPlayersGone;
|
||||
extern JE_byte shotAvail[MAX_PWEAPON];
|
||||
extern const uint shadowYDist;
|
||||
extern JE_real optionSatelliteRotate;
|
||||
extern JE_integer optionAttachmentMove;
|
||||
@@ -328,15 +309,12 @@ extern JE_word neat;
|
||||
extern rep_explosion_type rep_explosions[MAX_REPEATING_EXPLOSIONS];
|
||||
extern superpixel_type superpixels[MAX_SUPERPIXELS];
|
||||
extern unsigned int last_superpixel;
|
||||
extern JE_integer tempI, tempI2, tempI3, tempI4;
|
||||
extern JE_longint tempL;
|
||||
extern JE_byte temp, temp2, temp3, temp4, temp5, tempPos;
|
||||
extern JE_word tempX, tempY, tempX2, tempY2;
|
||||
extern JE_word tempW, tempW2;
|
||||
extern JE_byte temp, temp2, temp3;
|
||||
extern JE_word tempX, tempY;
|
||||
extern JE_word tempW;
|
||||
extern JE_boolean doNotSaveBackup;
|
||||
extern JE_word x, y;
|
||||
extern JE_integer b;
|
||||
extern JE_byte playerNum;
|
||||
extern JE_byte **BKwrap1to, **BKwrap2to, **BKwrap3to, **BKwrap1, **BKwrap2, **BKwrap3;
|
||||
extern JE_shortint specialWeaponFilter, specialWeaponFreq;
|
||||
extern JE_word specialWeaponWpn;
|
||||
@@ -356,9 +334,6 @@ JE_word JE_SGr( JE_word ship, Sprite2_array **ptr );
|
||||
void JE_drawOptions( void );
|
||||
|
||||
void JE_tyrianHalt( JE_byte code ); /* This ends the game */
|
||||
void JE_initPlayerShot( JE_word portnum, uint shot_i, JE_word px, JE_word py,
|
||||
JE_word mousex, JE_word mousey,
|
||||
JE_word wpnum, JE_byte playernum );
|
||||
void JE_specialComplete( JE_byte playernum, JE_byte specialType );
|
||||
void JE_doSpecialShot( JE_byte playernum, uint *armor, uint *shield );
|
||||
|
||||
@@ -382,4 +357,3 @@ void JE_drawOptionLevel( void );
|
||||
|
||||
#endif /* VARZ_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -157,4 +157,3 @@ void draw_segmented_gauge( SDL_Surface *surface, int x, int y, Uint8 color, uint
|
||||
fill_rectangle_hw(surface, x, y, segment_width, segment_height, color + (12 * partial_segment / segment_value));
|
||||
}
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OpenTyrian Classic: A modern cross-platform port of Tyrian
|
||||
* OpenTyrian: A modern cross-platform port of Tyrian
|
||||
* Copyright (C) 2007-2009 The OpenTyrian Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -40,4 +40,3 @@ void draw_segmented_gauge( SDL_Surface *surface, int x, int y, Uint8 color, uint
|
||||
|
||||
#endif /* VGA256D_H */
|
||||
|
||||
// kate: tab-width 4; vim: set noet:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user