Biorhythm is a C port of BIORHYTH.BAS Copyright 1979 by Phil Feldman and Tom Rugg from Tandy BASIC.
The theory of biorhythms suggests our life is governed by three cycles. A 23 day physical cycle, 28 day emotional cycle and a 33 day intellectual cycle.
The cycles can be plotted using a sine wave. Critical days occur when the cycle reaches zero. Theory suggests you are more accident-prone on critical days for your physical or emotional cycle.
Because C and BASIC handle strings so differently I opted not to bother with string routines. I ran into trouble when testing the date output strings in julian2Date. The problem was I didn't know if I had typed something wrong or translated something incorrectly.
I don't really follow the computations for playing with Julian dates and with a recent compiler playing with dates isn't too bad. I found some algorithms online that appeared to be easier to implement on Julian Day Calculations (Gregorian Calendar) at http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html.
TRS80CHR.DAT should be in the same directory as the executable or in your path.
I did a bit of a rewrite that should be portable. It avoids extended characters. It should compile without difficulty on any ANSI C compiler.
Unfortunately, there is no portable way to determine if the screen has been cleared and the cursor moved to the top of the screen. Most of the operating systems that I have come across have terminals that accept ANSI escape sequences; however, Microsoft Windows and DOS do not accept them as control sequences by default. You can get around this by installing ANSI.SYS in your CONFIG.SYS or calling ANSI.COM, NANSI.COM or the like.
DOS's COMMAND.COM and Window's CMD.EXE both have "CLS" as a builtin command and the system call should take a negligible amount of time on even emulated hardware. Using C's system function has the virtue of telling us if it failed. So I opted to make the system call and issue the ANSI escape sequence if it fails.
If you are using Linux, BSD or another UNIX-like OS you can redirect "stderr" if it bothers you, or just edit "cls.c". Or you can create an executable file, "CLS", in your path to clear the screen.
The Makefile is currently configured for OS X and should work without modifications for Linux or BSD. I've included a Makefile for Solaris as well which requires gmake (GNU make).
To install on Linux, OS X or BSD:
unzip biorhythm-04.zip cd biorhythm make sudo make install
To install on Solaris:
unzip biorhythm-04.zip cd biorhythm gmake -f Makefile.solaris sudo gmake -f Makefile.solaris install
Optionally, for *NIX:
cat >~/bin/CLS <<EOF #!/usr/bin/env bash #CLS - Clears terminal screen and returns the cursor # to the HOME position. clear EOF chmod u+x ~/bin/CLS
I've included an html version of the man page:biorhythm.6.html for convenience.
The file, biorhythm-04.zip, includes precompiled versions for OS X 10.8.5, win32 and win64 versions compiled with Pelles C, and, in the dos subdirectory, a DOS version compiled using MIX Power C. The DOS version required a slight modification because the file name was too long.
I've actually tested this on OS X, Linux, Minix, DOSBox, Windows 2000, Windows 98SE, NetBSD.
biorhythm-04.zip | Multiplatform - Source code with OS X, DOS, Win32 and Win64 executables. |
biorhythm-03.tar.bz2 | Multiplatform. |
BIORHTYH.ZIP | DOS only - Emulates Tandy graphic characters. |