ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (07/02/86)
[ Congratulations. Your system does not have the line eating bug. ]
Here's a 3d version of the stars program I posted earlier. You'll
have to find yourself a red and blue gel somewhere. If you have an old set
of red/blue or red/green glasses for comic books, posters, etc., they'll
work great.
Remember, this is only a crock.
Schwab
^^^^^^^^^^^^^^^^^^^ Fire particle beam here ^^^^^^^^^^^^^^^^^^^^^^
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# 3d.readme
# 3dstars.c
# rnd.s
# This archive created: Wed Jul 2 00:47:08 1986
# By: Leo 'Bols Ewhac' Schwab ()
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f '3d.readme'
then
echo shar: "will not over-write existing file '3d.readme'"
else
cat << \SHAR_EOF > '3d.readme'
How to make this beastie:
1> cc 3dstars.c
1> as rnd.s
1> ln 3dstars.o rnd.o -lc -o 3dstars
SYNOPSIS
3dstars [magic] [warpfactor]
DESCRIPTION
3DSTARS is similar to the STARS program. MAGIC is a magic number
that controls the field of view. The smaller the number, the wider the
field of view. Default is 128.
WARPFACTOR controls how fast the stars come at you. Default is 3.
To watch this thing work, find yourself a red and blue gel.
Selection of the blue gel is rather critical since you have to choose a
shade that will shut off all red light. Usually, the deeper the blue, the
better (not too deep, or you won't be able to see through it).
Now, put the red gel over your left eye and the blue over your
right. You should turn your monitor contrast way up, or darken the room, or
both. Pick a distance from the screen you like.
--------
This is written for the Manx compiler. Conversion to Lattice should
be trivial, but I don't want to do it (I've finally decided that I hate
Lattice. I'm really not kidding this time).
The code is heavily uncommented, so if you don't know what's
happening, mail me and I'll try to help.
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
________ ___
\ /___--__ Leo L. Schwab
___ ___ /\ ---##\ ihnp4!ptsfa!well!ewhac
/ X \_____ | __ _---)) ..or..
/ /_\-- -----+==____\ // \ _ well ---\
___ ( o---+------------------O/ \/ \ dual ----> !unicom!ewhac
\ / ___ \_ (`o ) hplabs -/ ("AE-wack")
____ \___/ \_/
Recumbent Bikes: "Work FOR? I don't work FOR
The _O_n_l_y Way To Fly! anybody! I'm just having fun."
SHAR_EOF
fi
if test -f '3dstars.c'
then
echo shar: "will not over-write existing file '3dstars.c'"
else
cat << \SHAR_EOF > '3dstars.c'
/* :ts=8 bk=0
* 3dstars.c: Spacing out taken a step further
* by Leo L. Schwab 8607.1
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#define NSTARS 32
extern void *OpenLibrary(), *OpenScreen(), *OpenWindow(), *GetMsg();
extern short rnd();
long *IntuitionBase, *GfxBase;
struct NewScreen scrdef = {
0, 0, 320, 200,
4, /* # planes */
-1, -1,
NULL,
CUSTOMSCREEN,
NULL, NULL, NULL, NULL
};
struct NewWindow windef = {
0, 0, 320, 200,
-1, -1,
CLOSEWINDOW,
WINDOWCLOSE,
NULL, NULL, NULL, NULL, NULL,
0, 0, 0, 0,
CUSTOMSCREEN
};
struct Window *win;
struct Screen *scr;
struct RastPort *rp;
short x[NSTARS], y[NSTARS], z[NSTARS];
short xlo[NSTARS], xro[NSTARS], yo[NSTARS];
main (ac, av)
char *av[];
int ac;
{
long xls, xrs, ys;
long *msg;
short magic, inc;
register short i, fz;
if (ac > 1)
magic = atoi (av[1]);
else
magic = 128;
if (ac > 2)
inc = atoi (av[2]);
else
inc = 3;
openstuff ();
rnd (-5286);
SetRast (rp, 0L);
for (i=0, xls=1; i<8; i++, xls += 2) {
SetRGB4 (&(scr -> ViewPort), (long) i, xls, 0L, 0L);
SetRGB4 (&(scr -> ViewPort), (long) i+8, 0L, 0L, xls);
}
for (i=0; i<NSTARS; i++)
mkpoint (i);
FOREVER {
for (i=0; i<NSTARS; i++) {
if ((z[i] -= inc) <= 0)
mkpoint (i);
fz = z[i];
xls = (x[i] - (fz >> 4)) * magic / fz + 160;
xrs = (x[i] + (fz >> 4)) * magic / fz + 160;
ys = y[i] * magic / fz + 100;
SetAPen (rp, 0L);
WritePixel (rp, (long) xlo[i], (long) yo[i]);
WritePixel (rp, (long) xro[i], (long) yo[i]);
if (xls < 0 || xls > 319 || xrs < 0 || xrs > 319 ||
ys < 0 || ys > 199)
mkpoint (i);
else {
SetAPen (rp, (long) (256-fz >> 5));
WritePixel (rp, xls, ys);
SetAPen (rp, (long) 8+(256-fz >> 5));
WritePixel (rp, xrs, ys);
xlo[i] = xls; xro[i] = xrs; yo[i] = ys;
}
}
if (msg = GetMsg (win -> UserPort)) {
ReplyMsg (msg);
break;
}
}
closestuff ();
}
mkpoint (i)
register short i;
{
x[i] = rnd (256) - 128;
y[i] = rnd (150) - 75;
z[i] = 255;
}
openstuff ()
{
if (!(IntuitionBase = OpenLibrary ("intuition.library", 0L))) {
printf ("Intuition open failed.\n");
die ();
}
if (!(GfxBase = OpenLibrary ("graphics.library", 0L))) {
printf ("graphics open failed.\n");
die ();
}
if (!(scr = OpenScreen (&scrdef))) {
printf ("Can't open screen.\n");
die ();
}
windef.Screen = scr;
if (!(win = OpenWindow (&windef))) {
printf ("Window painted shut.\n");
die ();
}
rp = &(scr -> RastPort);
}
closestuff ()
{
if (win) CloseWindow (win);
if (scr) CloseScreen (scr);
if (GfxBase) CloseLibrary (GfxBase);
if (IntuitionBase) CloseLibrary (IntuitionBase);
}
die ()
{
closestuff ();
exit (-1);
}
SHAR_EOF
fi
if test -f 'rnd.s'
then
echo shar: "will not over-write existing file 'rnd.s'"
else
cat << \SHAR_EOF > 'rnd.s'
*\
* :ts=8
* Yet Another random number generator. By Leo Schwab.
* Based on an idea posted on the USENET (Thanks, Sam Dicker!)
* For the Manx assembler.
*
* Calling convention:
* short rnd (range);
* short range;
*
* 8606.30
*/
public _rnd
_rnd lea rndseed,a0 Get address of seed
move.w 4(sp),d1 Get range argument
tst.w d1
ble.s setseed Go reset seed
move.l (a0),d0 Get seed
ADD.L D0,D0
BHI.S over
EORI.L #$1D872B41,D0
over
move.l d0,(a0) Save new seed
andi.l #$ffff,d0 Coerce into word
divu d1,d0 Divide by range
swap d0 and get remainder (modulus)
rts
setseed neg.w d1 Probably don't need this
move.l d1,(a0)
rts
dseg
rndseed dc.l 0
cseg
SHAR_EOF
fi
exit 0
# End of shell archive