Before Greedo
shot first...
Before a troubled young Darth Vader
braided his hair...
Before
midiclorians offered to explain the inexplicably perfect and perfectly inexplicable...
And before
Jar Jar Binks burped and farted away the last remnants of dear Obi-Wan's "
more civilized age"...
...I created something, of which I was very,
very proud at the time. Remarkably, I came across that creation, somewhat randomly, as I was recently throwing away some old floppy disks.
Twenty years ago, it was 1994. I was 15 years old, just learning to program (mostly on my own), and I created a "trivia game" based around
Star Wars. 1,700 lines of
Turbo Pascal. And I made every mistake in the book:
Of course I'm embarrassed by all of that! But then, I take a look at what the program did do, and wow -- it's still at least a little bit fun today :-)
Welcome to
swline.pas. Almost unbelievably, I was able to compile it tonight on an Ubuntu 14.04 LTS 64-bit Linux desktop, using
fpc, after three very
minor changes:
- Running fromdos to remove the trailing ^M endemic of many DOS-era text files
- Replacing the (80MHz) CPU clock based sleep function with Delay()
- Running iconv to convert the embedded 437 code page ASCII art to UTF-8
Here's a short screen cast of the game in action :-)
Would you look at that!
- 8-bit color!
- Hand drawn ANSI art!
- Scrolling text of the iconic Star Wars, Empire Strikes Back, and Return of the Jedi logos!
- Random stars and galaxies drawn on the splash screen!
- No graphic interface framework (a la Newt or Ncurses) -- just a whole 'bunch of GotoXY().
- An option for sound (which, unfortunately, doesn't seem to work -- I'm sure it was just 8-bits of bleeps and bloops).
- 300 hand typed quotes (and answers) spanning all 3 movies!
- An Easter Egg, and a Cheat Code!
- Timers!
- User input!
- And an option at the very end to start all over again!
You can't make this stuff up :-)
But watching a video is boring... Why don't you try it for yourself!?!
I thought this would be a perfect use case for a
Docker. Just a little Docker image, based on Ubuntu, which includes a statically built
swline.pas, and set to run that one binary (and
only that one binary when launched. As simple as it gets, Makefile and Dockerfile.
$ cat Makefile
all:
fpc -k--static swline.pas
$ cat Dockerfile
FROM ubuntu
MAINTAINER Dustin Kirkland
ADD swline /swline
ENTRYPOINT /swline
I've pushed a
Docker image containing the game to the Docker Hub registry.
Quick note... You're going to want a terminal that's 25 characters high, and 160 characters wide (sounds weird, yes, I know -- the ANSI art characters are double byte wide and do some weird things to smaller terminals, and my interest in debugging this is pretty much non-existant -- send a patch!). I launched gnome-terminal, pressed ctrl-- to shrink the font size, on my laptop.
On an Ubuntu 14.04 LTS machine:
$ sudo apt-get install docker.io
$ sudo docker pull kirkland/swline:v1
$ sudo docker run -t -i kirkland/swline:v1
Of course you can find, build, run, and modify the original (horrible!) source code in
Launchpad and
Github.
Now how about that for a throwback Tuesday ;-)
May the Source be with you! Always!
Dustin
p.s. Is this the only gem I found on those 17 floppy disks? Nope :-) Not by a long shot.