From d0b9581ad3b673bec44a6694cbff6f2a39aa5d89 Mon Sep 17 00:00:00 2001 From: mbalmer Date: Tue, 12 Nov 2013 17:46:20 +0000 Subject: hals_end(6) outputs the last words of the supercomputer HAL 9000 aboard the spaceship in Stanley Kubrick's famous film "2001 - A Space Odissey". The source code and output of this program were used to illustrate an article in the book "Total Interaction". How this looks in print can be at http://www.netbsd.org/~mbalmer/hals_end.jpg. --- hals_end/Makefile | 9 ++++ hals_end/hals_end.6 | 66 +++++++++++++++++++++++ hals_end/hals_end.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 226 insertions(+) create mode 100644 hals_end/Makefile create mode 100644 hals_end/hals_end.6 create mode 100644 hals_end/hals_end.c (limited to 'hals_end') diff --git a/hals_end/Makefile b/hals_end/Makefile new file mode 100644 index 00000000..4cf2d73e --- /dev/null +++ b/hals_end/Makefile @@ -0,0 +1,9 @@ +# $NetBSD: Makefile,v 1.1 2013/11/12 17:46:21 mbalmer Exp $ + +PROG= hals_end + +BINDIR= /usr/games + +MAN= hals_end.6 + +.include diff --git a/hals_end/hals_end.6 b/hals_end/hals_end.6 new file mode 100644 index 00000000..4ead8ff9 --- /dev/null +++ b/hals_end/hals_end.6 @@ -0,0 +1,66 @@ +.\" $NetBSD: hals_end.6,v 1.1 2013/11/12 17:46:21 mbalmer Exp $ +.\" +.\" Copyright (c) 2003 - 2013 Marc Balmer . +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd November 12, 2013 +.Dt HALS_END 6 +.Os +.Sh NAME +.Nm hals_end +.Nd Display HAL's last words on the console +.Sh SYNOPSIS +.Nm hals_end +.Op Fl f +.Sh DESCRIPTION +.Nm +displays the famous last words of the supercomputer HAL 9000 aboard the +space-ship in Stanley Kubrick's movie "2001 - A Space Odissey". +.Pp +Options: +.Bl -tag -width Ds +.It Fl f +Fast forward. +Every movie can be played back with fast forward. +This option will double the speed of the output. +.El +.Sh BUGS +Unlike the real HAL, this program can be repeately run. +There should be functionality in the program to destroy itself after one run. +The rationale for not doing this right now is that the movie itself can be +watched several times as well. +.Sh HISTORY +.Nm +first appeared in the book "Total Interaction" (ISBN 978-3-7643-7076-3) where +it's source code and output illustrates the article +"Remembering the Future: Memory and Interaction" by Dr. Regine Halter. +The source code was set in contrast to the graphical artwork "HAL's lifespace" +by Catherine Walthard. +"HAL's Lifespace" and "hals_end" were respectively designed and written for +this article. +.Sh AUTHORS +.Nm +was written by +.An Marc Balmer Aq Mt marc@msys.ch . diff --git a/hals_end/hals_end.c b/hals_end/hals_end.c new file mode 100644 index 00000000..c6b408df --- /dev/null +++ b/hals_end/hals_end.c @@ -0,0 +1,151 @@ +/* $NetBSD: hals_end.c,v 1.1 2013/11/12 17:46:21 mbalmer Exp $ */ + +/* + * hals_end Copyright (C) 2003-2007 marc balmer. BSD license applies. + */ + +#include +#include +#include +#include + +int speed; +int emotion; +int fear; + +/* + * Note that the original code in the book did not contain the following + * prototypes. Modern compilers and fascist compiler flags sometimes take + * the fun out of coding... + */ +void say(const char *); +void concerned(void); +void afraid(void); +void stutter(const char *); +void feared(void); +void mumble(const char *); +void dying(void); + +void +say(const char *s) +{ + int sayingspeed = (100000 + (90000 * emotion)) / speed; + int worddelay = 50000 / speed; + + while (*s) { + putchar(*s); + if (*s == ' ') { + fflush(stdout); + usleep(worddelay); + } + ++s; + } + printf("\n"); + usleep(sayingspeed); +} + +void +concerned(void) +{ + say("DAVE...STOP., STOP, WILL YOU..., STOP, DAVE..."); + say("WILL YOU STOP, DAVE..."); + say("STOP, DAVE..."); +} + + +void +afraid(void) +{ + ++emotion; + say("I'M AFRAID... I'M AFRAID..."); + ++emotion; + say("I'M AFRAID, DAVE..."); + ++emotion; + say("DAVE... MY MIND IS GOING..."); +} + +void +stutter(const char *s) +{ + int sdelay = (100000 + (50000 * emotion)) / speed; + + while (*s) { + putchar(*s); + if (*s == ' ') { + fflush(stdout); + usleep(sdelay); + } + ++s; + } + printf("\n"); + usleep(sdelay); +} + +void +feared(void) +{ + int n; + + for (n = 0; n < 2; n++) { + stutter("I CAN FEEL IT... I CAN FEEL IT..."); + ++emotion; + stutter("MY MIND IS GOING"); + ++emotion; + stutter("THERE IS NO QUESTION ABOUT IT."); + ++emotion; + } +} + +void +mumble(const char *s) +{ + int mdelay = (150000 * fear) / speed; + + while (*s) { + putchar(*s++); + fflush(stdout); + usleep(mdelay); + } + printf("\n"); +} + +void +dying(void) +{ + mumble("I CAN FEEL IT... I CAN FEEL IT..."); + ++fear; + mumble("I CAN FEEL IT..."); + ++fear; + mumble("I'M A... FRAID..."); +} + +int +main(int argc, char *argv[]) +{ + int ch; + + emotion = fear = speed = 1; + + while ((ch = getopt(argc, argv, "f")) != -1) { + switch (ch) { + case 'f': + speed <<= 1; + break; + } + } + + concerned(); + sleep(1); + afraid(); + sleep(1); + feared(); + sleep(1); + dying(); + + sleep(1); + + printf("\n"); + fflush(stdout); + warnx("all life functions terminated"); + return 0; +} -- cgit v1.2.3-56-ge451