Posted: . At: 4:49 PM. This was 2 years ago. Post ID: 15688
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


I found the Sun OS 4.14 source code.


Sun OS Source code archive

I have found an archive with the Sun OS 4.14 source code. This is very nice. I am uploading this as it might be very useful to someone.

Download it here: securitronlinux.com/arma3/sunos-414-source.tar.gz.

This is a sample from the source code, this is the bin/env.c file.

bin/env.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef lint
static	char sccsid[] = "@(#)env.c 1.1 94/10/31 SMI"; /* from S5R2 1.4 */
#endif
 
/*
 *	env [ - ] [ name=value ]... [command arg...]
 *	set environment, then execute command (or print environment)
 *	- says start fresh, otherwise merge with inherited environment
 */
#include <stdio.h>
 
#define NENV	100
char	**newenv;
char	*nullp = NULL;
 
int	nenv_size=NENV;
extern	char **environ;
extern	errno;
extern	char *sys_errlist[];
char	*nvmatch(), *strchr();
void	exit();
 
main(argc, argv, envp)
register char **argv, **envp;
{
 
	argc--;
	argv++;
	if (argc && strcmp(*argv, "-") == 0) {
		envp = &nullp;
		argc--;
		argv++;
	}
 
	if ((newenv = (char **)malloc(sizeof(char *) * NENV)) == NULL)
	{
		perror("unable to allocate memory for new environment");
		exit(1);
	}
 
	for (; *envp != NULL; envp++)
		if (strchr(*envp, '=') != NULL)
			addname(*envp);
	while (*argv != NULL && strchr(*argv, '=') != NULL)
		addname(*argv++);
 
	if (*argv == NULL)
		print(0); /* doesn't return */
	else {
		environ = newenv;
		(void) execvp(*argv, argv);
		(void) fputs(sys_errlist[errno], stderr);
		(void) fputs(": ", stderr);
		(void) fputs(*argv, stderr);
		(void) putc('\n', stderr);
		exit(1);
	}
	/* NOTREACHED */
}

Very interesting source code, this is very old but worth uploading, it might be very interesting to a fan of old operating systems. The games/trek folder contains a Star Trek game! That is very cool.

Here is a section of the source code for this game.

games/trek/help.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef lint
static	char sccsid[] = "@(#)help.c 1.1 94/10/31 SMI"; /* from UCB 4.2 05/09/83 */
#endif
 
# include	"trek.h"
 
/*
**  call starbase for help
**
**	First, the closest starbase is selected.  If there is a
**	a starbase in your own quadrant, you are in good shape.
**	This distance takes quadrant distances into account only.
**
**	A magic number is computed based on the distance which acts
**	as the probability that you will be rematerialized.  You
**	get three tries.
**
**	When it is determined that you should be able to be remater-
**	ialized (i.e., when the probability thing mentioned above
**	comes up positive), you are put into that quadrant (anywhere).
**	Then, we try to see if there is a spot adjacent to the star-
**	base.  If not, you can't be rematerialized!!!  Otherwise,
**	it drops you there.  It only tries five times to find a spot
**	to drop you.  After that, it's your problem.
*/
 
char	*Cntvect[3] =
{"first", "second", "third"};
 
help()
{
	register int		i;
	double			dist, x;
	register int		dx, dy;
	int			j, l;
 
	/* check to see if calling for help is reasonable ... */
	if (Ship.cond == DOCKED)
		return (printf("Uhura: But Captain, we're already docked\n"));
 
	/* or possible */
	if (damaged(SSRADIO))
		return (out(SSRADIO));
	if (Now.bases <= 0)
		return (printf("Uhura: I'm not getting any response from starbase\n"));
 
	/* tut tut, there goes the score */
	Game.helps += 1;
 
	/* find the closest base */
	dist = 1e50;
	if (Quad[Ship.quadx][Ship.quady].bases <= 0)
	{
		/* there isn't one in this quadrant */
		for (i = 0; i < Now.bases; i++)
		{
			/* compute distance */
			dx = Now.base[i].x - Ship.quadx;
			dy = Now.base[i].y - Ship.quady;
			x = dx * dx + dy * dy;
			x = sqrt(x);
 
			/* see if better than what we already have */
			if (x < dist)
			{
				dist = x;
				l = i;
			}
		}

The game is called Star Trek and this is the version 6 source code. C version by Eric P. Allman 5/76 (U.C. Berkeley) with help from Jeff Poskanzer and Pete Rubinstein. Written 31/10/1994.

Here is another code sample.

games/trek/destruct.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef lint
static	char sccsid[] = "@(#)destruct.c 1.1 94/10/31 SMI"; /* from UCB 4.3 05/27/83 */
#endif
 
# include	"trek.h"
 
/*
**  Self Destruct Sequence
**
**	The computer starts up the self destruct sequence.  Obviously,
**	if the computer is out nothing can happen.  You get a countdown
**	and a request for password.  This must match the password that
**	you entered at the start of the game.
**
**	You get to destroy things when you blow up; hence, it is
**	possible to win the game by destructing if you take the last
**	Klingon with you.
**
**	By the way, the \032 in the message is a ^Z, which is because
**	the terminal in my office is an ADM-3, which uses that char-
**	acter to clear the screen.  I also stick in a \014 (form feed)
**	because that clears some other screens.
**
**	Uses trace flag 41
*/
 
destruct()
{
	char		checkpass[15];
	register int	i, j;
	double		zap;
 
	if (damaged(COMPUTER))
		return (out(COMPUTER));
	printf("\n --- WORKING ---\n");
	sleep(3);
	/* output the count 10 9 8 7 6 */
	for (i = 10; i > 5; i--)
	{
		for (j = 10;  j > i; j--)
			printf("   ");
		printf("%d\n", i);
		sleep(1);
	}
	/* check for password on new line only */
	skiptonl(0);
	getstrpar("Enter password verification", checkpass, 14, 0);
	sleep(2);
	if (!sequal(checkpass, Game.passwd))
		return (printf("Self destruct sequence aborted\n"));
	printf("Password verified; self destruct sequence continues:\n");
	sleep(2);
	/* output count 5 4 3 2 1 0 */
	for (i = 5; i >= 0; i--)
	{
		sleep(1);
		for (j = 5; j > i; j--)
			printf("   ");
		printf("%d\n", i);
	}
	sleep(2);
	printf("\032\014***** %s destroyed *****\n", Ship.shipname);
	Game.killed = 1;
	/* let's see what we can blow up!!!! */
	zap = 20.0 * Ship.energy;
	Game.deaths += Ship.crew;
	for (i = 0; i < Etc.nkling; )
	{
		if (Etc.klingon[i].power * Etc.klingon[i].dist <= zap)
			killk(Etc.klingon[i].x, Etc.klingon[i].y);
		else
			i++;
	}
	/* if we didn't kill the last Klingon (detected by killk), */
	/* then we lose.... */
	lose(L_DSTRCT);
}

This is the section of the source code to do with the Self Destruct sequence on Starships.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.