• Please review our updated Terms and Rules here

Help with C

ChickenMan

Experienced Member
Joined
Apr 11, 2011
Messages
91
Location
Victoria, Australia
I found a nice Adventure Game on an Excalibur 64 (and Aussie computer running CP/M 2.2) disk called "The Twilight Zone". It came compete with its C source code as well. However playing the game, it cant be completed due to an error found. The C code can be fixed but I have no idea what version of C was used to compile it. Near the start of the code it says

/* Compile by: c -k -f -s500 -w60 tz */

and right at the end it has

#include "stdlib.c"

Does anyone recognise this version of C that would allow me to re-compile to a working game?
Many thanks for any help :)
Alan


The start of the source code

/* TWILIGHT ZONE GAME

From 810717 (original assembler version) to 830125 in Z80 assembler.

831025 rr begin conversion to C 0.10
831028 rr convert some more 0.11
831028 rr more yet 0.12
831101 rr dictionary in room file 0.13
831104 rr add terminal file stuff 0.14
831106 rr simplify 0.15
831107 rr simplify 0.16
831108 rr misc fixup 0.17
831109 rr more misc fixup 0.18
831112 jd fixup to message routines 0.19
831114 rr further fixups, add save, load 0.20
*/

#define VRS 0
#define RLS 20

/* Compile by: c -k -f -s500 -w60 tz */

int rc, cnt, i;
char buffer[ 25000 ]; /* buffer for reading file */
char *p, *room[ 256 ]; /* buffer pointer, rooms */
char *wlk_msg[ 24 ]; /* points to walker messages */
char inp_buf[ 34 ]; /* input buffer */
int inp_cnt = 0; /* input buffer pointer */

char trmbuf[ 128 ]; /* storage for terminal file */

int width, height, defint, uselst, yfirst, method, addx, addy;
char *inistr, *clrscn, *clreos, *clreol, *curoff, *curon,
*curbeg, *curmid, *curend, *hiint, *loint, *revvid, *norvid,
*inslin, *dellin;

/* Dictionary: words should be strung together, separated by spaces.
Only the unique part should be included. Contained in first line
of TZ.R. Every word including the last one must be followed by spaces.
Incidentally, all lines of TZ.R should be terminated only by
line feeds. */

char *dic_ptr;

/* Controls used in messages are:
* clear screen
^ position cursor to message line (causes CEOL)
\ carriage return/line feed (causes CEOL)
| position cursor to user input line (HEIGHT-2)
_ include answer here (e.g. _4____)
*/

/* The following pieces of information must be saved */

int rm_num = 0; /* room number */
int seed; /* random seed */
int wtchct = 0; /* tv watch count */
int beerct = 0; /* drink beer count */
int cratct = 0; /* open crate count */
int pushct = 0; /* push button count */
int pushfl = 0; /* push button error flag */
int answer[ 5 ] = { 0, 1, 2, 3, 4 }; /* digits of answer */

struct walker {
int inrm; /* in room flag */
int rsel; /* room pointer */
int dsel; /* description selector */
int locn[ 8 ]; /* rooms walker appears at */
};

/* Woman walker descriptor */

struct walker woman = {
0, 0, 0,
4, 52, 64, 94, 109, 185, 201, 248 };

/* Man walker descriptor */

struct walker man = {
0, 0, 0,
3, 49, 97, 105, 111, 144, 166, 175 };
 
Looks like a variation on BDS C which uses STDLIB*.C and has -k and -w switches. It does not look like it would compile with the version of BDS C that was released to the public domain in 2002. The good news is there were only a few C compilers running on CP/M in 1983.
 
Please bear with me...

I have a Public Domain disk, 'C' User Group 36, complete copy as issued 198?

This includes the following files:

TZ.C size 26112 (Twilight Zone)
TZ.COM 56832
TZ.DOC 3328
TZ.R 23680

The .DOC file may well answer the questions. I need to extract the files from the CP/M format disk, which I will do tomorrow, and advise further.

The other files on the disk do not give any immed hints.

I seem to remember that I tried to do something with this prog a LONG time ago, that will be on another disk somewhere.

I never had BDS C, I was prob trying to compile it with Eco C which would have been from a similar era.

Geoff
 
Thanks guys, so looks like BDS C may be the goer. I found ver 1.6 at http://www.z80.eu/c-compiler.html. It has stdlib1.c, stdlib2.c & stdlib3.c but no stdlib.c. Could the needed stdlib.c just be the other 3 files joined into one?

Oh, all the files I've attached, should have done in first post. The DOC file is of no use, it just tells you about playing the game and even then not very helpful really. There was no Terminal.com as mentioned but the Terminal.sys is setup for an ADM3a Terminal (as per the Excalibur 64 and my Microbee 128 ).

Thanks, Alan

View attachment twilight_zone.zip
 
As far as I can tell, the compiler options don't match up with BDS C.

The other thing is that this is clearly a compile-and-go setup, as it doesn't appear to support a linker, so library files must be compiled with the program itself.
 
STW C/80 uses stdlib.c and the pattern of including it at the end of your source file.

BTW if the last line of your source does not include cr/lf, according to C/80 it doesn't exist. That one bit me hard.
 
With GeoffB17 reference to the game being on a CUG disk (thanks), I remembered I have the C UG CDROM somewhere. A frantic search found it and on disk 136 there it was :) and the complete Game and source together with the Terminal program. This is also a much more up-to-date version (1986) as well and now can be compiled for CP/M, MS-DOS and TOS and lists compilers as C/80, Aztec, & Alcyon. So C/80 confirmed as the compiler for CP/M and Aztec for MS-DOS. So now to play the new version of the game to see if the problem has been fixed or not. Have been unable to locate the C/80 compiler also, does anyone know where to find it in case I need to re-compile :) Thanks everyone for your help, Alan

The start of the code is now

/* HEADER: CUG136.20;
TITLE: TZ;
VERSION: 0.29;
DATE: 3/12/1986;
DESCRIPTION: "Twilight Zone Adventure Game (part 1)";
KEYWORDS: game,adventure;
SYSTEM: CP/M,MS-DOS,TOS;
FILENAME: TZ1.C;
AUTHORS: R. Rodman;
COMPILERS: C/80,Aztec,Alcyon;
*/

/* TWILIGHT ZONE GAME

TZ1.C - First half

From 810717 (original assembler version) to 830125 in Z80 assembler.

831025 rr begin conversion to C 0.10
831101 rr dictionary in room file 0.13
831104 rr add terminal file stuff 0.14
850412 rr mods for ibm 0.21
850429 rr for unbuf,use open returns int; for buf,use fopen returns FILE (Aztec) 0.24
850430 rr try allocating buffer for Aztec 0.25
850521 rr try to fix messed-up message 0.27
860228 rr fix \n for cp/m 0.28
860311 rr split into two parts 0.29 add type to fopen
860312 rr st stuff

Version number is currently not displayed anywhere

NOTE: The alloc() function does not work on the Atari ST. To simplify
our lives, I don't use it.

The IBM switch is only known to work with the AZTEC compiler.
*/
 
Hello,

Just to confirm, the CUG disk that I have - which also includes the TERMINAL system (prog, source, etc) also has two small .C files marked as extensions for C/80 (one is called RANDOM, the other PORTIO) so this ties up with the idea that C/80 is the compiler required. I'd never heard of C/80 before, so I didn't see the significance of this before.
 
Back
Top