mirror of https://github.com/sean-m/zork
Intial fork commit. Emscripten build is working but need better handling for user input.
parent
a463c206cb
commit
13cddd2b16
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C++ Launch",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "zork",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceRoot}",
|
||||
"environment": [],
|
||||
"externalConsole": true,
|
||||
"linux": {
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"osx": {
|
||||
"MIMode": "lldb"
|
||||
},
|
||||
"windows": {
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "C++ Attach",
|
||||
"type": "cppdbg",
|
||||
"request": "attach",
|
||||
"program": "zork",
|
||||
"processId": "${command.pickProcess}",
|
||||
"linux": {
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"osx": {
|
||||
"MIMode": "lldb"
|
||||
},
|
||||
"windows": {
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "0.1.0",
|
||||
"command": "make",
|
||||
"isShellCommand": true,
|
||||
"args": ["dungeon"],
|
||||
"showOutput": "always",
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "native",
|
||||
"args": ["dungeon"]
|
||||
},
|
||||
{
|
||||
"taskName": "js",
|
||||
"args": ["dungeon-js"]
|
||||
},
|
||||
{
|
||||
"taskName": "clean",
|
||||
"args": ["clean"]
|
||||
}
|
||||
]
|
||||
}
|
27
Makefile
27
Makefile
|
@ -1,10 +1,10 @@
|
|||
# Makefile for dungeon
|
||||
|
||||
# Where to install the program
|
||||
BINDIR = /usr/games
|
||||
BINDIR = /usr/local/games/bin
|
||||
|
||||
# Where to install the data file
|
||||
LIBDIR = /usr/games/lib
|
||||
LIBDIR = /usr/local/games/lib
|
||||
|
||||
# The dungeon program provides a ``more'' facility which tries to
|
||||
# figure out how many rows the terminal has. Several mechanisms are
|
||||
|
@ -15,9 +15,9 @@ LIBDIR = /usr/games/lib
|
|||
# more option 1: use the termcap routines. On some systems the LIBS
|
||||
# variable may need to be set to -lcurses. On some it may need to
|
||||
# be /usr/lib/termcap.o. These options are commented out below.
|
||||
LIBS = -ltermcap
|
||||
#LIBS = -ltermcap
|
||||
TERMFLAG =
|
||||
# LIBS = -lcurses
|
||||
#LIBS = -lcurses
|
||||
# LIBS = /usr/lib/termcap.o
|
||||
|
||||
# more option 2: use the terminfo routines. On some systems the LIBS
|
||||
|
@ -27,8 +27,8 @@ TERMFLAG =
|
|||
# TERMFLAG = -DMORE_TERMINFO
|
||||
|
||||
# more option 3: assume all terminals have 24 rows
|
||||
# LIBS =
|
||||
# TERMFLAG = -DMORE_24
|
||||
LIBS =
|
||||
TERMFLAG = -DMORE_24
|
||||
|
||||
# more option 4: don't use the more facility at all
|
||||
# LIBS =
|
||||
|
@ -48,6 +48,7 @@ CFLAGS = -g #-static
|
|||
# to not be used and should be uncommented.
|
||||
# CFLAGS= -O -Dconst=
|
||||
|
||||
|
||||
##################################################################
|
||||
|
||||
# Source files
|
||||
|
@ -62,21 +63,31 @@ OBJS = actors.o ballop.o clockr.o demons.o dgame.o dinit.o dmain.o\
|
|||
dverb2.o gdt.o lightp.o local.o nobjs.o np.o np1.o np2.o np3.o\
|
||||
nrooms.o objcts.o rooms.o sobjs.o supp.o sverbs.o verbs.o villns.o
|
||||
|
||||
dungeon-js: CC = emcc
|
||||
dungeon-js: CFLAGS += -DTEXTFILE=/gdata/dtextc.dat
|
||||
|
||||
dungeon: $(OBJS) dtextc.dat
|
||||
$(CC) $(CFLAGS) -o zork $(OBJS) $(LIBS)
|
||||
|
||||
dungeon-js: $(OBJS) dtextc.dat
|
||||
mkdir gdata/
|
||||
cp dtextc.dat gdata/dtextc.dat
|
||||
$(CC) $(CFLAGS) -o zork.html $(OBJS) $(LIBS) --preload-file gdata/dtextc.dat
|
||||
|
||||
install: zork dtextc.dat
|
||||
mkdir -p $(BINDIR)
|
||||
mkdir -p $(LIBDIR)
|
||||
cp zork $(BINDIR)
|
||||
cp dtextc.dat $(LIBDIR)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) zork core dsave.dat *~
|
||||
rm -f $(OBJS) zork core dsave.dat *.html *~
|
||||
|
||||
dtextc.dat:
|
||||
cat dtextc.uu1 dtextc.uu2 dtextc.uu3 dtextc.uu4 | uudecode
|
||||
|
||||
dinit.o: dinit.c funcs.h vars.h
|
||||
$(CC) $(CFLAGS) $(GDTFLAG) -DTEXTFILE=\"$(LIBDIR)/dtextc.dat\" -c dinit.c
|
||||
$(CC) $(CFLAGS) $(GDTFLAG) -c dinit.c
|
||||
|
||||
dgame.o: dgame.c funcs.h vars.h
|
||||
$(CC) $(CFLAGS) $(GDTFLAG) -c dgame.c
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
# Zork 1
|
||||
This is a fork of the Zork public domain source code which has gone through
|
||||
several source conversions chronicled below. I'm hoping to get a working
|
||||
javascript port so that kids can enjoy this even on a Chromebook. There are
|
||||
several similar projects out there, notably the Internet Archive has many classic
|
||||
games running in the browser via MAME or Dosbox emulating the host environment for
|
||||
natively compiled binaries but this is a C source to Javascript port so the game
|
||||
may run natively in the browser. Wish me luck.
|
||||
|
||||
```
|
||||
Welcome to Dungeon. This version created 11-MAR-91.
|
||||
You are in an open field west of a big white house with a boarded
|
||||
|
|
55
dinit.c
55
dinit.c
|
@ -6,10 +6,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __AMOS__
|
||||
#include <amos.h>
|
||||
#endif
|
||||
|
||||
#include "funcs.h"
|
||||
#include "vars.h"
|
||||
|
||||
|
@ -20,21 +16,22 @@ extern void srand P((unsigned int));
|
|||
FILE *dbfile;
|
||||
|
||||
#ifndef TEXTFILE
|
||||
#ifdef __AMOS__
|
||||
#define TEXTFILE "lib:dtextc.dat"
|
||||
#else /* ! __AMOS__ */
|
||||
#ifdef unix
|
||||
#define TEXTFILE "/usr/games/lib/dunlib/dtextc.dat"
|
||||
#else /* ! unix */
|
||||
I need a definition for TEXTFILE
|
||||
#define TEXTFILE "/usr/local/games/lib/dtextc.dat"
|
||||
#endif /* ! unix */
|
||||
#endif /* ! __AMOS__ */
|
||||
#endif /* ! TEXTFILE */
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#define TEXTFILE "gdata/dtextc.dat"
|
||||
#endif /* ! __EMSCRIPTEN__ */
|
||||
|
||||
#endif // TEXTFILE
|
||||
|
||||
|
||||
#ifndef LOCALTEXTFILE
|
||||
#define LOCALTEXTFILE "dtextc.dat"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Read a single two byte integer from the index file */
|
||||
|
||||
#define rdint(indxfile) \
|
||||
|
@ -51,7 +48,7 @@ FILE *indxfile;
|
|||
integer ch; /* Local variable for rdint */
|
||||
|
||||
while (c-- != 0)
|
||||
*pi++ = rdint(indxfile);
|
||||
*pi++ = rdint(indxfile);
|
||||
}
|
||||
|
||||
/* Read a partial array of integers. These are stored as index,value
|
||||
|
@ -66,20 +63,20 @@ FILE *indxfile;
|
|||
integer ch; /* Local variable for rdint */
|
||||
|
||||
while (1) {
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (c < 255) {
|
||||
i = getc(indxfile);
|
||||
if (i == 255)
|
||||
return;
|
||||
}
|
||||
else {
|
||||
i = rdint(indxfile);
|
||||
if (i == -1)
|
||||
return;
|
||||
}
|
||||
if (c < 255) {
|
||||
i = getc(indxfile);
|
||||
if (i == 255)
|
||||
return;
|
||||
}
|
||||
else {
|
||||
i = rdint(indxfile);
|
||||
if (i == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
pi[i] = rdint(indxfile);
|
||||
pi[i] = rdint(indxfile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +88,7 @@ logical *pf;
|
|||
FILE *indxfile;
|
||||
{
|
||||
while (c-- != 0)
|
||||
*pf++ = getc(indxfile);
|
||||
*pf++ = getc(indxfile);
|
||||
}
|
||||
|
||||
logical init_()
|
||||
|
@ -112,7 +109,7 @@ logical init_()
|
|||
/* FIRST CHECK FOR PROTECTION VIOLATION */
|
||||
|
||||
if (protected()) {
|
||||
goto L10000;
|
||||
goto L10000;
|
||||
}
|
||||
/* !PROTECTION VIOLATION? */
|
||||
more_output("There appears before you a threatening figure clad all over");
|
||||
|
@ -460,6 +457,6 @@ L1975:
|
|||
more_output(" INITIALIZATION FAILURE");
|
||||
more_output("");
|
||||
more_output("The darkness becomes all encompassing, and your vision fails.");
|
||||
return ret_val;
|
||||
|
||||
//return ret_val;
|
||||
return 0;
|
||||
} /* init_ */
|
||||
|
|
6
local.c
6
local.c
|
@ -2,10 +2,6 @@
|
|||
|
||||
#include "funcs.h"
|
||||
|
||||
#ifdef __AMOS__
|
||||
#include <moncal.h>
|
||||
#endif
|
||||
|
||||
/* This function should return TRUE_ if it's OK for people to play the
|
||||
* game, FALSE_ otherwise. If you have a working <time.h> library,
|
||||
* you can define NONBUSINESS to disallow play Monday to Friday, 9-5
|
||||
|
@ -70,7 +66,7 @@ logical wizard()
|
|||
return TRUE_;
|
||||
#else
|
||||
#ifdef unix
|
||||
if (getuid() == 0 || getuid() == WIZARDID)
|
||||
//if (getuid() == 0 || getuid() == WIZARDID)
|
||||
return TRUE_;
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue