The thinking here is that we simplify life by going pure ANSI/POSIX.
This is a text game. If it ever runs on anything but Unix again it's
almost certain to be on something like WSL that supplies a
POSIX-conformant text console.
# Makefile for the open-source release of adventure 2.5
-OBJS=main.o init.o actions1.o actions2.o score.o misc.o datime.o
+OBJS=main.o init.o actions1.o actions2.o score.o misc.o
SOURCES=$(OBJS:.o=.c) COPYING NEWS README advent.text control
.c.o:
+++ /dev/null
-#ifdef AMIGA
-#define _TIME_
-#include "exec/types.h"
-#include "intuition/intuition.h"
-
-#define INTUITIONREV 1
-
-struct IntuitionBase *IntuitionBase = NULL;
-
-fDATIME(X,Y)int *X, *Y; {
-static int GOTX = 0, GOTY;
- if(GOTX == 0) {
- IntuitionBase = (struct IntuitionBase *)
- OpenLibrary("intuition.library", INTUITIONREV);
- if (IntuitionBase == NULL) {
- printf("Can't open library.\n");
- exit(FALSE);
- }
- CurrentTime(&GOTX, &GOTY);
- CloseLibrary(IntuitionBase);
- }
- GOTY += 654321;
- if(GOTY >= 1000000) {GOTX += 1; GOTY -= 1000000;}
- *X = GOTX;
- *Y = GOTY;
-}
-#endif
-
-#ifdef __MSDOS__
-#define _TIME_
-#include "time.h"
-
-fDATIME(long *X,long *Y) {
- time(X); time(Y);
- *Y /= 2;
- /* it would be even better if the two numbers were totally
- * unrelated, like if 'time' returned 64 bits of data */
-}
-#endif
-
-#ifndef _TIME_
-#include "sys/time.h"
-
-void fDATIME(long *X, long *Y) {
- struct timeval now;
- gettimeofday(&now, 0);
- *X = now.tv_sec;
- *Y = now.tv_usec;
-}
-#endif
static void quick_array(long*, long);
static bool quick_init(void) {
-#ifdef AMIGA
- f = fopen("ram:adventure.data", READ_MODE);
-#else
extern char *getenv();
char *adv = getenv("ADVENTURE");
f = NULL;
if(adv)f = fopen(adv,READ_MODE);
-#endif
if(f == NULL)f = fopen("adventure.data",READ_MODE);
if(f == NULL)return(FALSE);
init_reading = TRUE;
#include "main.h"
#include "misc.h"
-#ifdef __MSDOS__
-#include "alloc.h"
-#endif
#define TRUE (0==0)
#define FALSE (0!=0)
goto L20;
L15: if(!OPENED){
-#ifdef AMIGA
- OPENED=fopen("ram:adventure.text","r" /* NOT binary */);
- if(!OPENED)
-#endif
OPENED=fopen("adventure.text","r" /* NOT binary */);
if(!OPENED){printf("Can't read adventure.text!\n"); exit(FALSE);}
}
-#ifdef __MSDOS__ /* define fopen modes for binary files */
+#include <time.h>
+
+/* b is not needed for POSIX but harmless */
#define READ_MODE "rb"
#define WRITE_MODE "wb"
-#else
-#define READ_MODE "r"
-#define WRITE_MODE "w"
-#endif
extern void fSPEAK(long);
#define SPEAK(N) fSPEAK(N)
#define MPINIT() fMPINIT()
extern void fSAVEIO(long,long,long*);
#define SAVEIO(OP,IN,ARR) fSAVEIO(OP,IN,ARR)
-extern void fDATIME(long*,long*);
-#define DATIME(D,T) fDATIME(&D,&T)
+#define DATIME(D,T) do {struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); D=ts.tv_sec, T=ts.tv_nsec;} while (0)
extern long fIABS(long);
#define IABS(N) fIABS(N)
extern long fMOD(long,long);