Xref: gmd.de rec.games.int-fiction:897 rec.arts.int-fiction:723
Newsgroups: rec.games.int-fiction,rec.arts.int-fiction
Path:
gmd.de!ira.uka.de!sol.ctr.columbia.edu!usc!zaphod.mps.ohio-state.edu!uwm.edu!u
x1.cso.uiuc.edu!news.cso.uiuc.edu!s.psych.uiuc.edu!amead
From: amead@s.psych.uiuc.edu (Alan Mead)
Subject: missing OASYS source
Message-ID: <Bxx4K2.Hpv@news.cso.uiuc.edu>
Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
Organization: UIUC Department of Psychology
Date: Wed, 18 Nov 1992 15:33:37 GMT
Lines: 641

The adventure game definition system OASYS was recently posted to, I
believe, comp.sys.ibm.pc.binaries and has been mentioned here.  I
emailed the author (Russell Wallace) and mentioned that there was a
file missing and he sent me the below.

I tried OASYS and found it more confusing and the interface less
comfortable than TADS but I was impressed by the quality of it and that
Russell had released source (ie, to the compiler and interpreter).  It
comes with a sample game.  I'll upload a complete package, if there is
interest to, say, archive.umich.edu?

Oh yes, please note that I don't know much C++ and HAVE NOT tested the
below file (files?).

-alan mead

From RWALLACE@vax1.tcd.ie Wed Nov 18 06:36:16 1992

// C++ library header file by Russell Wallace

#ifndef __STDIO_H
#include        <stdio.h>
#endif
#ifndef __STRING_H
#include        <string.h>
#endif
#ifndef __CTYPE_H
#include        <ctype.h>
#endif
#ifndef __STDLIB_H
#include        <stdlib.h>
#endif

#define pdebug(v,f)     printf (#v " = %" #f " in " __FILE__ "
%d\n",v,__LINE__)
#define ddebug(v,f)     debug (#v " = %" #f " in " __FILE__ " %d",v,__LINE__)
#define foff(s,f)       ((char *)&((s *)0)->f - (char *)0)
#define vfoff(s,f)      ((char *)((s *)0)->f - (char *)0)

const BEEP = 7;
const REPORTSPACE = 2;
const REPORTPAGELENGTH = 60;

enum
{
        FALSE,
        TRUE
};

#define seg(p)  *((unsigned *)&(p) + 1)
#define off(p)  *((unsigned *)&(p))

enum
{
        KC_UP = 18432,
        KC_DOWN = 20480,
        KC_HOME = 18176,
        KC_END = 20224,
        KC_PGUP = 18688,
        KC_PGDN = 20736,
        KC_ESC = 27,
        KC_LEFT = 19200,
        KC_RIGHT = 19712,
        KC_BS = 8,
        KC_HLINE = 196,
        KC_F1 = 0x3b00,
        KC_F2 = 0x3c00,
        KC_F3 = 0x3d00,
        KC_F4 = 0x3e00,
        KC_F5 = 0x3f00,
        KC_F6 = 0x4000,
        KC_F7 = 0x4100,
        KC_F8 = 0x4200,
        KC_F9 = 0x4300,
        KC_F10 = 0x4400,
        KC_DEL = 21248,
        KC_INS = 20992,
};

const KC_HELP = KC_F10;

enum
{
        K_UP = 1,
        K_DOWN = 2,
        K_PGUP = 4,
        K_PGDN = 8,
        K_HOME = 16,
        K_END = 32,
        K_ESC = 64,
        K_LEFT = 128,
        K_RIGHT = 256,
        K_F1 = 512,
        K_F5 = 1024,
        K_DEL = 2048,
        K_INS = 4096,
        K_F2 = 8192,
        K_F3 = 16384,
        K_F4 = 32768,
};

const signed char BYTEBLANK = -127;
const short SHORTBLANK = -10000;
const INTBLANK = SHORTBLANK;
const long LONGBLANK = -1000000000L;
const double DOUBLEBLANK = -2e10;

struct slist
{
        slist *next;

        void operator+= (slist *n) { n->next = next; next = n; };
        len ();
        void free ();
};

struct slisthead
{
        slist *next,*last;

        slisthead () { next = 0; last = (slist *)this; };
        void operator+= (slist *);
        void free () { ((slist *)this)->free (); };
        len () { return next->len (); };
};

struct dlist
{
        dlist *next,*prev;

        dlist () { next = prev = this; };
        void operator+= (dlist *);
        void concat (dlist *);
        void remove ();
        void free ();
        void init () { next = prev = this; };
        len ();
};

struct treenode
{
        treenode *left,*right;
        void *data;

        treenode (void *);
        ~treenode ();
        size ();
};

struct tree
{
        int (_cdecl *fcmp)(void *,void *);
        treenode *t;

        void *operator+= (void *);
        void *operator[] (void *);
        void free () { if (t) { delete t; t = 0; } };
        size () { return t->size (); };
};

struct ftreenode
{
        ftreenode *left,*right;
        void *data;

        ftreenode (void *);
        ~ftreenode ();
        size () { return ((treenode *)this)->size (); };
};

struct ftree
{
        int (_cdecl *fcmp)(void *,void *);
        ftreenode *t;

        void *operator+= (void *);
        void *operator[] (void *data) { return (*((tree *)this))[data]; };
        ~ftree () { if (t) { delete t; t = 0; } };
        size () { return t->size (); };
};

struct ptreenode
{
        ptreenode *left,*right;
        void *data;

        ptreenode (void *);
        ~ptreenode ();
};

struct ptree
{
        ptreenode *t;

        operator+= (void *);
        void free () { if (t) { delete t; t = 0; } };
};

struct Date
{
        unsigned day:5;
        unsigned month:4;
        unsigned year:7;

        isvalid () { return *((unsigned short *)this); };
        operator< (Date d)
                        { return *((unsigned short *)this) < *((unsigned short
*)&d); };
        operator> (Date d)
                        { return *((unsigned short *)this) > *((unsigned short
*)&d); };
        operator!= (Date d)
                        { return *((unsigned short *)this) != *((unsigned
short *)&d); };
        operator== (Date d)
                        { return *((unsigned short *)this) == *((unsigned
short *)&d); };
        operator<= (Date d)
                        { return *((unsigned short *)this) <= *((unsigned
short *)&d); };
        operator>= (Date d)
                        { return *((unsigned short *)this) >= *((unsigned
short *)&d); };
        void settoday ();
};

extern Date PAST;
extern Date FUTURE;

#define IPAST           {01,01,80}
#define IFUTURE {31,12,99}

struct Time
{
        unsigned sec:5;
        unsigned min:6;
        unsigned hour:5;

        isvalid () { return (hour<=23) && (min<=59) && (sec<=59); };
        operator!= (Time t)
                { return *((unsigned short *)this) != *((unsigned short *)&t);
};
        operator== (Time t)
                { return *((unsigned short *)this) == *((unsigned short *)&t);
};
        operator< (Time t)
                { return *((unsigned short *)this) < *((unsigned short *)&t);
};
        operator> (Time t)
                { return *((unsigned short *)this) > *((unsigned short *)&t);
};
        operator<= (Time t)
                { return *((unsigned short *)this) <= *((unsigned short *)&t);
};
        operator>= (Time t)
                { return *((unsigned short *)this) >= *((unsigned short *)&t);
};
        void setnow ();
};

extern Time TPAST;
extern Time TFUTURE;

#define ITPAST  {00,00,00}
#define ITFUTURE        {23,59,59}

struct execmenuitem
{
        char *text;
        execmenuitem *submenu;
        void(*function)();
        char needpassword;
};

struct Window
{
        int *prevdata;
        Window *ancestor;
        int x,y,lx,ly;
        int width,height;
        int originx,originy;

        void savewin ();
        Window (int,int,int,int);
        Window (char *,int = 20,int = 1);
        Window (int,int = 20,int = 1);
        ~Window ();
        void clear ();
        void select ();
        static void init ();
};

struct Help
{
        static help_texts;
        static char *help_text[6];

        Help (char *s) { help_text[help_texts++] = s; };
        ~Help () { help_texts--; };
};

struct Heading
{
        static int headings;
        static char *heading[10];

        Heading (char *s);
        ~Heading ();
};

vfind (void *,void *,int,int,int (_cdecl *)(const void *,const void *));
void filecopy (int,int,long,void *);
void fsort (int,int,long,int,int,int);
vsearch (long,long *,int);
long ffind (void *,int,long,long,int,int);
vfind (void *,void *,int,int);
void qsort (void *,unsigned,int,unsigned,unsigned);
void pack (char *,unsigned char *,int);
void unpack (unsigned char *,char *,int);
in (int,unsigned char *,int);
void pt (unsigned char *,int);
void ptat (int,int,unsigned char *,int);
ed (int,int,int&,unsigned,int&,int,void (*)(int,int),
                int (*)(int,int,int,int,int&),void (*)(int,int),void
(*)(int,int));
_cdecl bytepcmp (const void *,const void *);
char **findargs (int,char **);
char *article (char *);
char *defext (char *,char *,int = FALSE);
char *getfilename (char *);
char *makestr (int,int);
char *strdup (char *,int);
char *strdup (char *,char *);
char *strdup (char *);
char *strhold (char *);
checkkey (int,int);
Create (char *);
Date atodate (char *);
Date gettoday ();
_cdecl Datepcmp (const void *,const void *);
decdigits (long);
double scandouble (char *,int);
_cdecl doublepcmp (const void *,const void *);
ed (char *,int,int,int = 0);
enoughmem ();
FILE *Fopen (char *,char *);
getkey ();
getpassword (char *);
in (char *,int,int = 0);
in (Date *,int);
in (double *,int,int,int);
in (Time *,int);
in (void *,int,int,int,int,int,int);
inchar (char *,char *,int);
inyn (char *,int);
inyn (int *,int);
isuline (char *);
isuline (char *,int);
isblank (char *,int);
long scanlong (char *,int);
long fsearch (void *,int,int,long,int,int (_cdecl *)(const void *,const void
*));
_cdecl longpcmp (const void *,const void *);
menu (char **,int,int,int,int);
msgyn (char *,int = 0);
Open (char *);
_cdecl ptrcmp (void *,void *);
rstrlen (char *);
_cdecl shortpcmp (const void *,const void *);
_cdecl strpcmp (const void *,const void *);
sure (char *);
Time atotime (char *);
Time getnow ();
_cdecl Timepcmp (const void *,const void *);
unsigned char hexchar2byte (int);
unsigned char hexchars2byte (int,int);
unsigned hexchars2int (int,int,int,int);
void at (int,int);
void beep ();
void blank (void *,int,int,int);
void border (int,int,int,int);
void centrerev (char *,int);
void changeattr (int,int);
void Chsize (int,long);
void clr (int,int,int,int);
void debug (char * ...);
void Unlink (char *);
void ed (char *,int,int,int,int,int);
void execmenu (execmenuitem *,int,int,int,int,char *);
void filecopy (int,int,long);
void pt (FILE *,Date);
void pt (FILE *,double,int,int);
void pt (FILE *,long,int,int = 0);
void pt (FILE *,short,int,int = 0);
void pt (FILE *,signed char,int,int = 0);
void pt (FILE *,Time);
void pt (FILE *,char *,int);
void ptchars (FILE *,int,int);
void pt (FILE *,char *);
void locate (int,int);
void movefile (int,long,long);
void perr (char * ...);
void pt (char *);
void pt (char *,int);
void pt (Date);
void pt (double,int,int);
void pt (int);
void pt (int,char *,int,int);
void pt (Time);
void ptat (int,int,char *);
void ptat (int,int,void *,int,int,int,int);
void ptchar (int);
void ptchars (int,int);
void ptyn (int);
void Read (int,void *,unsigned);
void Read (int,long,void *,unsigned);
void Rename (char *,char *);
void rvoff ();
void rvon ();
void scrolldown (int,int,int,int,int = 1);
void scrollup (int,int,int,int,int = 1);
void setstr (char *,int,int);
void fsort (int,int,long,int,int (_cdecl *)(const void *,const void *));
void spt (char *,Date);
void spt (char *,double,int,int);
void spt (char *,Time);
void snpt (char *,Date);
void snpt (char *,double,int,int);
void snpt (char *,int,int);
void snpt (char *,long,int);
void snpt (char *,short,int);
void snpt (char *,signed char,int);
void snpt (char *,Time);
void snpt (char *,char *);
char *strcpy (char *,char *,int);
char *strcat (char *,char *,int);
char *strcat (char *,Date);
char *strcat (char *,Time);
char *strcat (char *,int,char);
char *strtrim (char *);
void tempmsg (char *,int = 0);
void unblank (void *,int,int,int);
void Write (int,void *,unsigned);
void Write (int,long,void *,unsigned);
yn ();
void ptpagebuf (char *,int,int,int,FILE *);
char *strcat (char *,long,int,int = 0);
char *strcat (char *,short,int,int = 0);
char *strcat (char *,signed char,int,int = 0);
char *strcat (char *,double,int,int);
long fsearch (signed char,int,int,long,int);
long fsearch (short,int,int,long,int);
long fsearch (long,int,int,long,int);
long fsearch (double,int,int,long,int);
long fsearch (char *,int,int,long,int,int);
long fsearch (Date,int,int,long,int);
long fsearch (Time,int,int,long,int);
in (int,char *,int,int = 0);
char *uniqstr (tree&,char *);
long getrecs (int);
void reportend ();
void reportcheckline ();
void reportnewline ();
void reportpt (signed char,int,int = 0);
void reportpt (short,int,int = 0);
void reportpt (long,int,int = 0);
void reportpt (double,int,int);
void reportpt (char *,int);
void reportpt (Date);
void reportpt (Time);
void reportptspace (int);
FILE& operator<< (FILE&,char);
FILE& operator<< (FILE&,int);
FILE& operator<< (FILE&,long);
FILE& operator<< (FILE&,double);
FILE& operator<< (FILE&,char *);
void Fgets (FILE *,char *);
long ffind (void *,int,int,long,int,int,int (_cdecl *)(const void *,const void
*));
long fsearch (void *,int,int,long,int,int,int (_cdecl *)(const void *,const
void *));
void pt (long,int,int = 0);
void pt (short,int,int = 0);
void pt (signed char,int,int = 0);
void spt (char *,long,int,int = 0);
void spt (char *,short,int,int = 0);
void spt (char *,signed char,int,int = 0);
in (signed char *,int,int,int);
in (short *,int,int,int);
in (long *,int,int,int);
void *lfind (void *,void *,size_t *,int,int (_cdecl *)(const void *,const void
*));
vsearch (void *,void *,int,int,int (_cdecl *)(const void *,const void *));
void randomize ();
OpenCreate (char *);
void showfile (int,char *,int);

extern videopage;
extern foreground;
extern background;
extern fieldch;
extern edstri;
extern Window screen;
extern Window *curwin;
extern Date_maxday[];
extern colors[];
extern long maxval[];
extern editmode;

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b)        ((a)<(b)?(a):(b))

inline char *truefalse (int x) { return x ? "TRUE" : "FALSE"; }
inline char *addptr (void *p,int offset) { return ((char *)p)+offset; }
inline char *strcap (char *s) { *s = toupper (*s); return s; }
inline char *strchop (char *s,int n) { s[strlen (s)-n] = 0; return s; }
inline void pt (int n,int l) { pt ((short)n,l); }
inline void ptchars (int x,int y,int n,int c) { at (x,y); ptchars (n,c); }
inline void ptchar (int x,int y,int c) { at (x,y); ptchar (c); }
inline void ptyn (int x,int y,int n) { at (x,y); ptyn (n); }

inline void unblank (signed char& x) { if (x == BYTEBLANK) x = 0; }
inline void unblank (short& x) { if (x == SHORTBLANK) x = 0; }
inline void unblank (long& x) { if (x == LONGBLANK) x = 0; }
inline void unblank (double& x) { if (x == DOUBLEBLANK) x = 0; }
inline void unblank (char *x) { if (isuline (x)) strset (x,' '); }
inline void unblank (char *x,int n) { if (isuline (x,n)) memset (x,' ',n); }

inline getx () { return curwin->x; }
inline gety () { return curwin->y; }

inline void ptat (int x,int y,char *s,int n) { at (x,y); pt (s,n); }
inline void ptat (int x,int y,Date dt) { at (x,y); pt (dt); }
inline void ptat (int x,int y,Time tm) { at (x,y); pt (tm); }
inline void ptat (int x,int y,signed char n,int l,int dec = 0) { at (x,y); pt
(n,l,dec); }
inline void ptat (int x,int y,short n,int l,int dec = 0) { at (x,y); pt
(n,l,dec); }
inline void ptat (int x,int y,long n,int l,int dec = 0) { at (x,y); pt
(n,l,dec); }
inline void ptat (int x,int y,int n,int l) { at (x,y); pt (n,l); }
inline void ptat (int x,int y,int n) { at (x,y); pt (n); }
inline void ptat (int x,int y,double n,int l,int dec) { at (x,y); pt
(n,l,dec); }

inline in (signed char *n,int l,int keys) { return in (n,l,0,keys); }
inline in (short *n,int l,int keys) { return in (n,l,0,keys); }
inline in (long *n,int l,int keys) { return in (n,l,0,keys); }
inline in (int *n,int l,int keys) { return in ((short *)n,l,keys); }
#include        <stdio.h>
#include        <stdlib.h>
#include        "rwlib.h"

FILE *Fopen (char *filename,char *mode)
{
        FILE *result = fopen (filename,mode);
        if (result == 0)
                perr ("ERROR - Can't open file %s in mode %s",filename,mode);
        return result;
}
#include        <stdlib.h>
#include        <stdio.h>
#include        <io.h>
#include        <fcntl.h>
#include        "rwlib.h"

Create (char *filename)
{
        int file;
        file=open (filename,O_CREAT | O_TRUNC | O_RDWR | O_BINARY,0777);
        if (file < 0)
                perr ("ERROR - Can't create file %s",filename);
        return file;
}
#include        <stdlib.h>
#include        <stdio.h>
#include        <io.h>
#include        "rwlib.h"

void Write (int file,void *data,unsigned bytes)
{
        if (write (file,data,bytes) != bytes)
                perr ("ERROR - Can't write %u bytes to file %d",bytes,file);
}
#include        <stdio.h>
#include        <stdlib.h>
#include        <stdarg.h>
#include        <dos.h>
#include        "rwlib.h"

void perr (char *format ...)
{
        va_list argptr;
        if (videopage)
        {
                int far *p;
                seg (p) = videopage;
                off (p) = 0;
                int i = 2000;
                int n = ((background << 4) | foreground) << 8;
                do
                        *p++ = n;
                while (--i != 0);
                REGS regs;
                regs.h.ah = 2;
                regs.h.dh = 0;
                regs.h.dl = 0;
                regs.h.bh = 0;
                int86 (0x10,&regs,&regs);
        }
        va_start (argptr,format);
        vfprintf (stderr,format,argptr);
        va_end (argptr);
        fputc ('\n',stderr);
        exit (1);
}
#include        <string.h>
#include        "rwlib.h"

char *defext (char *filename,char *ext,int force)
{
        int i = strlen (filename);
        while (i && filename[i]!='.' && filename[i]!='/' && filename[i]!='\\')
                i--;
        if (filename[i] == '.')
        {
                if (!force)
                        return filename;
        }
        else
                i = strlen (filename);
        static char result[64];
        memcpy (result,filename,i);
        result[i] = 0;
        strcat (result,ext);
        return result;
}
#include        <fcntl.h>
#include        <stdlib.h>
#include        <stdio.h>
#include        <io.h>
#include        "rwlib.h"

Open (char *filename)
{
        int file;
        file=open (filename,O_RDWR | O_BINARY);
        if (file < 0)
                perr ("ERROR - Can't open file %s",filename);
        return file;
}

#include        <stdlib.h>
#include        <stdio.h>
#include        <io.h>
#include        "rwlib.h"

void Read (int file,void *data,unsigned bytes)
{
        if (read (file,data,bytes) != bytes)
                perr ("ERROR - Can't read %u bytes from file %d",bytes,file);
}

