* Super Star Trek Classic (v1.1)
* Retro Star Trek Game
* C Port Copyright (C) 1996 <Chris Nystrom>
+ *
+ * Rather hacked for Fuzix by Alan Cox 2018
*
* This program is free software; you can redistribute it and/or modify
* in any way that you wish. _Star Trek_ is a trademark of Paramount
#include <string.h>
#include <math.h>
#include <time.h>
+#include <unistd.h>
#ifndef FALSE
#define FALSE 0
#define TRUE ! FALSE
#endif
+#ifndef TREK_DIR
+#define TREK_DIR "/usr/lib/trek/"
+#endif
+
/* Standard Line Length */
#define MAXLEN 255
/* Function Declarations */
-void intro(void);
-void new_game(void);
-void initialize(void);
-void new_quadrant(void);
-void course_control(void);
-void complete_maneuver(void);
-void exceed_quadrant_limits(void);
-void maneuver_energy(void);
-void short_range_scan(void);
-void long_range_scan(void);
-void phaser_control(void);
-void photon_torpedoes(void);
-void torpedo_hit(void);
-void damage_control(void);
-void shield_control(void);
-void library_computer(void);
-void galactic_record(void);
-void status_report(void);
-void torpedo_data(void);
-void nav_data(void);
-void dirdist_calc(void);
-void galaxy_map(void);
-void end_of_time(void);
-void resign_commision(void);
-void won_game(void);
-void end_of_game(void);
-void klingons_move(void);
-void klingons_shoot(void);
-void repair_damage(void);
-void find_empty_place(void);
-void insert_in_quadrant(void);
-void get_device_name(void);
-void string_compare(void);
-void quadrant_name(void);
-int function_d(int i);
-int function_r(void);
-void mid_str(char *a, char *b, int x, int y);
-int cint(double d);
-void compute_vector(void);
-void sub1(void);
-void sub2(void);
-void showfile(char *filename);
-double rnd(void);
+static void intro(void);
+static void new_game(void);
+static void initialize(void);
+static void new_quadrant(void);
+static void course_control(void);
+static void complete_maneuver(void);
+static void exceed_quadrant_limits(void);
+static void maneuver_energy(void);
+static void short_range_scan(void);
+static void long_range_scan(void);
+static void phaser_control(void);
+static void photon_torpedoes(void);
+static void torpedo_hit(void);
+static void damage_control(void);
+static void shield_control(void);
+static void library_computer(void);
+static void galactic_record(void);
+static void status_report(void);
+static void torpedo_data(void);
+static void nav_data(void);
+static void dirdist_calc(void);
+static void galaxy_map(void);
+static void end_of_time(void);
+static void resign_commision(void);
+static void won_game(void);
+static void end_of_game(void);
+static void klingons_move(void);
+static void klingons_shoot(void);
+static void repair_damage(void);
+static void find_empty_place(void);
+static void insert_in_quadrant(void);
+static void get_device_name(void);
+static void string_compare(void);
+static void quadrant_name(void);
+static int function_d(int i);
+static void mid_str(char *a, char *b, int x, int y);
+static int cint(double d);
+static void compute_vector(void);
+static void sub1(void);
+static void sub2(void);
+static void showfile(char *filename);
+static double rnd(void);
/* Global Variables */
-int b3; /* Starbases in Quadrant */
-int b4, b5; /* Starbase Location in sector */
-int b9; /* Total Starbases */
+static int b3; /* Starbases in Quadrant */
+static int b4, b5; /* Starbase Location in sector */
+static int b9; /* Total Starbases */
/* @@@ int c[2][10] = *//* Used for location and movement */
-int c[3][10] = /* modified to match MS BASIC array indicies */
+static int c[3][10] = /* modified to match MS BASIC array indicies */
{
{0},
{0, 0, -1, -1, -1, 0, 1, 1, 1, 0},
{1, 1, 1, 0, -1, -1, -1, 0, 1, 1}
};
-int d0; /* Docked flag */
-int d1; /* Damage Repair Flag */
-int e; /* Current Energy */
-int e0 = 3000; /* Starting Energy */
-int g[9][9]; /* Galaxy */
-int g5; /* Quadrant name flag */
-int k[4][4]; /* Klingon Data */
-int k3; /* Klingons in Quadrant */
-int k7; /* Klingons at start */
-int k9; /* Total Klingons left */
-int n; /* Number of secors to travel */
-int p; /* Photon Torpedoes left */
-int p0 = 10; /* Photon Torpedo capacity */
-int q1, q2; /* Quadrant Position of Enterprise */
-int r1, r2; /* Temporary Location Corrdinates */
-int s; /* Current shield value */
-int s3; /* Stars in quadrant */
-int s8; /* Quadrant locating index */
-int s9 = 200; /* Klingon Power */
-int t0; /* Starting Stardate */
-int t9; /* End of time */
-int z[9][9]; /* Cumulative Record of Galaxy */
-int z3; /* string_compare return value */
-int z1, z2; /* Temporary Sector Coordinates */
-int z4, z5; /* Temporary quadrant coordinates */
-
-double a, c1; /* Used by Library Computer */
-double d[9]; /* Damage Array */
-double d4; /* Used for computing damage repair time */
-double s1, s2; /* Current Sector Position of Enterprise */
-double t; /* Current Stardate */
-double w1; /* Warp Factor */
-double x, y, x1, x2; /* Navigational coordinates */
-
-char sA[4]; /* An Object in a Sector */
-char *sC; /* Condition */
-char sQ[194]; /* Visual Display of Quadrant */
-
-string sG2; /* Used to pass string results */
-
-FILE *stream;
+static int d0; /* Docked flag */
+static int d1; /* Damage Repair Flag */
+static int e; /* Current Energy */
+static int e0 = 3000; /* Starting Energy */
+static int g[9][9]; /* Galaxy */
+static int g5; /* Quadrant name flag */
+static int k[4][4]; /* Klingon Data */
+static int k3; /* Klingons in Quadrant */
+static int k7; /* Klingons at start */
+static int k9; /* Total Klingons left */
+static int n; /* Number of secors to travel */
+static int p; /* Photon Torpedoes left */
+static int p0 = 10; /* Photon Torpedo capacity */
+static int q1, q2; /* Quadrant Position of Enterprise */
+static int r1, r2; /* Temporary Location Corrdinates */
+static int s; /* Current shield value */
+static int s3; /* Stars in quadrant */
+static int s8; /* Quadrant locating index */
+static int t0; /* Starting Stardate */
+static int t9; /* End of time */
+static int z[9][9]; /* Cumulative Record of Galaxy */
+static int z3; /* string_compare return value */
+static int z1, z2; /* Temporary Sector Coordinates */
+static int z4, z5; /* Temporary quadrant coordinates */
+
+static double a, c1; /* Used by Library Computer */
+static double d[9]; /* Damage Array */
+static double d4; /* Used for computing damage repair time */
+static double s1, s2; /* Current Sector Position of Enterprise */
+static double t; /* Current Stardate */
+static double w1; /* Warp Factor */
+static double x, y, x1, x2; /* Navigational coordinates */
+
+static char sA[4]; /* An Object in a Sector */
+static char *sC; /* Condition */
+static char sQ[194]; /* Visual Display of Quadrant */
+
+static string sG2; /* Used to pass string results */
/*
/* Main Program */
-int main(void)
+int main(int argc, char *argv[])
{
+ chdir(TREK_DIR);
intro();
new_game();
static const char *intro_1 = " *************************************";
static const char *intro_2 = " * *";
-void intro(void)
+
+static void intro(void)
{
string sTemp;
t = (get_rand(20) + 20) * 100;
}
-void new_game(void)
+static void new_game(void)
{
string sTemp;
}
}
-void initialize(void)
+static void initialize(void)
{
int i, j;
char sX[2] = "";
getchar();
}
-void new_quadrant(void)
+static void new_quadrant(void)
{
int i;
}
}
-void course_control(void)
+static void course_control(void)
{
register int i;
/* @@@ int c2, c3, q4, q5; */
complete_maneuver();
}
-void complete_maneuver(void)
+static void complete_maneuver(void)
{
double t8;
short_range_scan();
}
-void exceed_quadrant_limits(void)
+static void exceed_quadrant_limits(void)
{
int x5 = 0; /* Outside galaxy flag */
new_quadrant();
}
-void maneuver_energy(void)
+static void maneuver_energy(void)
{
e = e - n - 10;
static const char *srs_1 = "------------------------";
-void short_range_scan(void)
+static void short_range_scan(void)
{
register int i, j;
static const char *lrs_1 = "--------------------\n";
-void long_range_scan(void)
+static void long_range_scan(void)
{
register int i, j;
printf("%s\n", lrs_1);
}
-void phaser_control(void)
+static void phaser_control(void)
{
register int i;
int iEnergy;
klingons_shoot();
}
-void photon_torpedoes(void)
+static void photon_torpedoes(void)
{
/* @@@ int c2, c3, x3, y3, x5; */
int x3, y3;
klingons_shoot();
}
-void torpedo_hit(void)
+static void torpedo_hit(void)
{
int i, x3, y3;
z[q1][q2] = g[q1][q2];
}
-void damage_control(void)
+static void damage_control(void)
{
int a1;
double d3 = 0.0;
printf("\n");
}
-void shield_control(void)
+static void shield_control(void)
{
int i;
string sTemp;
" 'Shields now at %d units per your command.'\n\n", s);
}
-void library_computer(void)
+static void library_computer(void)
{
string sTemp;
static const char *gr_1 = " ----- ----- ----- ----- ----- ----- ----- -----\n";
-void galactic_record(void)
+static void galactic_record(void)
{
int i, j;
static const char *str_s = "s";
-void status_report(void)
+static void status_report(void)
{
const char *plural = str_s + 1;
}
}
-void torpedo_data(void)
+static void torpedo_data(void)
{
int i;
const char *plural = str_s + 1;
}
}
-void nav_data(void)
+static void nav_data(void)
{
if (b3 <= 0) {
puts("Mr. Spock reports,\n"
compute_vector();
}
-void dirdist_calc(void)
+static void dirdist_calc(void)
{
string sTemp;
static const char *gm_1 = " ----- ----- ----- ----- ----- ----- ----- -----\n";
-void galaxy_map(void)
+static void galaxy_map(void)
{
int i, j, j0;
}
-void compute_vector(void)
+static void compute_vector(void)
{
x = x - a;
a = c1 - w1;
static const char *dist_1 = " DISTANCE = %4.2f\n\n";
static const char *f42 = "%4.2f\n";
-void sub1(void)
+static void sub1(void)
{
x = fabs(x);
a = fabs(a);
printf(dist_1, (x > a) ? x : a);
}
-void sub2(void)
+static void sub2(void)
{
x = fabs(x);
a = fabs(a);
printf(dist_1, (x > a) ? x : a);
}
-void ship_destroyed(void)
+static void ship_destroyed(void)
{
puts("The Enterprise has been destroyed. "
"The Federation will be conquered.\n");
end_of_time();
}
-void end_of_time(void)
+static void end_of_time(void)
{
printf("It is stardate %d.\n\n", (int) t);
resign_commision();
}
-void resign_commision(void)
+static void resign_commision(void)
{
printf("There were %d Klingon Battlecruisers left at the"
" end of your mission.\n\n", k9);
end_of_game();
}
-void won_game(void)
+static void won_game(void)
{
puts("Congratulations, Captain! The last Klingon Battle Cruiser\n"
"menacing the Federation has been destoyed.\n");
end_of_game();
}
-void end_of_game(void)
+static void end_of_game(void)
{
string sTemp;
exit(0);
}
-void klingons_move(void)
+static void klingons_move(void)
{
int i;
static const char *dcr_1 = "Damage Control report:";
-void klingons_shoot(void)
+static void klingons_shoot(void)
{
int h, i;
}
}
-void repair_damage(void)
+static void repair_damage(void)
{
int i;
double d6; /* Repair Factor */
/* Misc Functions and Subroutines */
-void find_empty_place(void)
+static void find_empty_place(void)
{
/* @@@ while (z3 == 0) this is a nasty one. */
do {
z3 = 0;
}
-void insert_in_quadrant(void)
+static void insert_in_quadrant(void)
{
int i, j = 0;
"Library-Computer"
};
-void get_device_name(void)
+static void get_device_name(void)
{
if (r1 < 0 || r1 > 8)
r1 = 0;
return;
}
-void string_compare(void)
+static void string_compare(void)
{
int i;
char sB[4];
"Betelgeuse", "Aldebaran", "Regulus", "Arcturus", "Spica"
};
-void quadrant_name(void)
+static void quadrant_name(void)
{
static char *sect_name[] = { "", " I", " II", " III", " IV" };
return;
}
-int function_d(int i)
+static int function_d(int i)
{
int j;
}
-void mid_str(char *a, char *b, int x, int y)
+static void mid_str(char *a, char *b, int x, int y)
{
--x;
y += x;
/* Round off floating point numbers instead of truncating */
-int cint(double d)
+static int cint(double d)
{
int i;
return (i);
}
-void showfile(char *filename)
+static void showfile(char *filename)
{
FILE *fp;
line lBuffer;
fclose(fp);
}
-double rnd(void)
+static double rnd(void)
{
double d;