Replace fDATIME with ANSI/POSIX clock_gettime(). Rip out DOS/AMIGA shims.
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.
This commit is contained in:
parent
bd0487acc5
commit
23f2dbe814
6 changed files with 5 additions and 69 deletions
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
|||
# 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:
|
||||
|
|
50
datime.c
50
datime.c
|
@ -1,50 +0,0 @@
|
|||
#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
|
4
init.c
4
init.c
|
@ -641,14 +641,10 @@ static void quick_item(long*);
|
|||
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;
|
||||
|
|
3
main.c
3
main.c
|
@ -8,9 +8,6 @@
|
|||
#include "main.h"
|
||||
|
||||
#include "misc.h"
|
||||
#ifdef __MSDOS__
|
||||
#include "alloc.h"
|
||||
#endif
|
||||
|
||||
#define TRUE (0==0)
|
||||
#define FALSE (0!=0)
|
||||
|
|
4
misc.c
4
misc.c
|
@ -898,10 +898,6 @@ long I, VAL; static FILE *OPENED = NULL;
|
|||
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);}
|
||||
}
|
||||
|
|
11
misc.h
11
misc.h
|
@ -1,10 +1,8 @@
|
|||
#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)
|
||||
|
@ -70,8 +68,7 @@ extern void fMPINIT();
|
|||
#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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue