Initial commit.

This commit is contained in:
Andrew Plotkin
2023-11-16 18:19:54 -05:00
commit b642da811e
796 changed files with 433816 additions and 0 deletions

8
unix/--notes Normal file
View File

@@ -0,0 +1,8 @@
UNIX DIP -- to do
------------------------------------------------------------------------
verify
[] needs to check data section, as well as code section
[] avoid the printf (scrolls screen)
save/restore
[] define a "cancel" key

151
unix/block.c Normal file
View File

@@ -0,0 +1,151 @@
#include <stdio.h>
#include <ctype.h>
#include <tam.h> /* contains AT&T 7300 window support */
#include <sys/signal.h>
#include <sys/termio.h>
/* #include "zipdefs.h" */
#include <wind.h>
#include <sys/window.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
extern open();
extern read();
extern fstat();
extern ioctl();
#define THEN
int wfd, /* file descriptor for graphics window */
ttyfd, /* file descriptor for stdio */
ttysav1, ttysav2; /* storage of startup tty conditions */
main()
{
char c, md_getc();
unsigned short data, xloc, yloc;
ttyfd = md_ttyini(); /* setup stdio window */
wfd = md_setup(); /* create a graphics window */
while ((c = md_getc()) != 'q') {
data = (c << 8) | c;
c = md_getc();
yloc = c - '0'; if (yloc > 9) THEN yloc = 0; /* row */
c = md_getc();
xloc = c - '0'; if (xloc > 9) THEN xloc = 0; /* col */
md_showblock(data, yloc, xloc);
}
md_ttyres(ttyfd); /* clean up */
}
#define ORIGIN 0
#define X_CELL 9 /* PC 7300 standard char size */
#define Y_CELL 12
md_showblock(pattern, y, x)
unsigned short pattern, y, x;
{
unsigned short i, bitmap[3*32]; /* 6 bytes x 32 rows */
struct urdata ur;
int err;
for (i=0; i<3*32; i++)
bitmap[i] = pattern;
ur.ur_srcbase = bitmap; ur.ur_srcwidth = 4; /* bytes */
ur.ur_dstbase = 0; /* window */ ur.ur_dstwidth = 0;
ur.ur_srcx = ORIGIN; ur.ur_srcy = ORIGIN;
ur.ur_dstx = X_CELL * 4 * x; ur.ur_dsty = Y_CELL * 2 * y;
ur.ur_width = X_CELL * 4; ur.ur_height = Y_CELL * 2; /* pixels */
ur.ur_srcop = SRCSRC; ur.ur_dstop = DSTSRC;
ur.ur_pattern = 0;
err = ioctl(wfd, WIOCSELECT); /* switch to graphics window */
err = ioctl(wfd, WIOCRASTOP, &ur);
err = ioctl(ttyfd, WIOCSELECT); /* switch back to text window */
}
char md_getc() /* read a key */
{
unsigned char c;
int err;
do
err = read(ttyfd, &c, 1); /* use the text window */
while (err <= 0);
return (c);
}
int md_setup() /* create a window, return descriptor */
{
int fd, wn, err;
struct stat wstat;
struct uwdata uw;
fd = open("/dev/window", O_RDWR | O_CREAT);
/* err = fstat(fd, &wstat); */
/* wn = wstat.st_rdev; */ /* window "number", not needed */
err = ioctl(fd, WIOCGETD, &uw);
uw.uw_x = 16; /* initial position & size */
uw.uw_y = 16;
uw.uw_width = 512;
uw.uw_height = 64;
uw.uw_uflags = BORDRESIZE; /* make it resizable */
err = ioctl(fd, WIOCSETD, &uw); /* set size & display window */
err = ioctl(ttyfd, WIOCSELECT); /* switch back to text window */
return (fd);
}
int md_ttyini()
{ /* This routine performs Unix tty magic. It sets the input buffer
length to 0, and turns off canonization and echo.
*/
struct termio ttyinfo;
int fd, err;
fd = fileno(stdin); /* get the stdin file descriptor */
err = ioctl(fd, TCGETA, &ttyinfo);
if (err == -1) THEN
printf("\nIOCTL(TCGETA) failed");
ttysav1 = ttyinfo.c_lflag;
ttysav2 = ttyinfo.c_cc[VMIN];
ttyinfo.c_lflag &= ~ICANON;
ttyinfo.c_lflag &= ~ECHO;
ttyinfo.c_cc[VMIN] = 0;
err = ioctl(fd, TCSETA, &ttyinfo);
if (err == -1) THEN
printf("\nIOCTL(TCSETA) failed");
return (fd);
}
md_ttyres(fd)
int fd;
{ /* This undoes the above magic.
*/
struct termio ttyinfo;
int err;
err = ioctl(fd, TCGETA, &ttyinfo);
ttyinfo.c_lflag = ttysav1;
ttyinfo.c_cc[VMIN] = ttysav2;
err = ioctl(fd, TCSETA, &ttyinfo);
/* close(fd); */
}

92
unix/dip.block Normal file
View File

@@ -0,0 +1,92 @@
unsigned short *altscreen; /* alternate screen for AT&T PC */
/*------------------------------*/
/* md_screen_update */
/*------------------------------*/
/* A DIP icon is drawn by repeated calls to ms_drawblock. To improve
speed on machines with complex and slow screen access, ms_drawblock
draws to a full-size alternate screen bitmap, instead of directly
to the real screen.
When the icon is complete, this routine is called to display the
changed portion of the alternate screen all at once.
*/
md_screen_update(locx, locy, width, height)
unsigned short locx, locy, width, height;
{
struct urdata ur;
/* It seems that ur_srcwidth and ur_dstwidth, if used, must always be
in multiples of two bytes. A value of one causes an "address fault"
hardware crash.
*/
ur.ur_srcbase = altscreen;
ur.ur_srcwidth = SCRNX2 * 2; /* in bytes */
ur.ur_dstbase = 0;
/* ur.ur_dstwidth = 0; */ /* [not needed for real screen] */
ur.ur_srcx = locx * GBLEN * 2; /* in pixels */
ur.ur_srcy = locy * GBLEN;
ur.ur_dstx = ur.ur_srcx; /* [same as for alternate screen] */
ur.ur_dsty = ur.ur_srcy;
ur.ur_width = width * GBLEN * 2; /* in pixels */
ur.ur_height = height * GBLEN;
ur.ur_srcop = SRCSRC;
ur.ur_dstop = DSTSRC;
ur.ur_pattern = 0;
ioctl(ttyfd, WIOCRASTOP, &ur); /* use our window */
}
/*------------------------------*/
/* md_drawblock */
/*------------------------------*/
/* Draw the block in dblock[].
[ If masking is active, use the mask in mblock[]. Wherever a mask bit is
1, the screen shows through unchanged. Elsewhere the block is displayed.
The second function below is used in several other DIPs, and here. ]
Straight-forward masking function: S' = (S AND M) OR (B AND ~M)
Equivalent, non-obvious masking function: S' = ((S XOR B) AND M) XOR B
*/
md_drawblock(locx, locy)
unsigned short locx, locy; /* display coordinates */
{
int i;
unsigned short *altptr; /* pointer into alternate screen */
/* AT&T PC graphics require two transformations on each byte displayed,
(1) reverse the bits, and (2) expand the byte to a short. The latter
is needed because of an even byte restriction in the screen raster
call, and incidentally helps to fill out the 80+ column display. For
speed, a transformation lookup table is used.
*/
#if ETRAP
if ((locx >= SCRNX2) || (locy >= SCRNY2)) THEN
fatal("md_drawblock position out of range");
#endif
altptr = altscreen + (locy * SCRNX2 * 2) + (locx * 2);
for (i=0; i<GBLEN; i++) {
if (maskflag) THEN {
*altptr ^= rev_table[dblock[i]];
*altptr &= rev_table[mblock[i]];
*altptr ^= rev_table[dblock[i]];
}
else
*altptr = rev_table[dblock[i]];
altptr += (SCRNX2 * 2);
}
}

3035
unix/dip.c Normal file

File diff suppressed because it is too large Load Diff

33
unix/dip.call Normal file
View File

@@ -0,0 +1,33 @@
#define MAXARGS 4
#define XMAXARGS 16
ZIPINT argcount;
/* The OPCALL instruction (for DIP) has a special format:
OPCALL, MODEBYTE1, ..., MODEBYTEn, ARG1, ..., ARGn
There can be up to 4 mode bytes and up to 16 arguments. Each mode
byte contains 4 argument specifiers, which are defined the same way as
those for "normal" extops.
Note that the argument specifier for "no more args" occurs only if
there are less than 16 arguments. [Since the maximum number of locals
is 15, this ought to be the maximum number of arguments too, right?]
*/
argcount = 0; /* init arg count */
for (jx = 1; jx <= 4; jx++) {
adrmode = nxtbyt(); /* get a mode byte */
for (ix = 1; ix <= 4; ix++) {
temp = adrmode & 3; /* extract two mode bits */
if (temp == 3) THEN
goto nomore; /* last arg, exit both loops */
PUSH(temp); /* save two mode bits */
argcount++;
adrmode >>= 2; /* next two mode bits */
}
}
nomore: argblk[0] = argcount;
for (ix = 1; ix <= argcount; ix++) /* decode args in order */
argblk[ix] = getarg(POP()); /* get arg and store */

328
unix/dip.init Normal file
View File

@@ -0,0 +1,328 @@
ZIPINT ibase; /* word ptr to image file */
/************************************************************************
* *
* M A I N P R O G R A M A N D I N I T S *
* *
************************************************************************/
main(argc,argv)
int argc; char **argv;
{
char *datname, *init();
md_setup(); /* do machine dependent inits */
if (datname = init(argc,argv)) THEN /* get command line stuff */
gamfile = datname;
sysini(); /* do system initialization */
memini(); /* setup memory, preload, and paging */
zipini(); /* setup zip header info and table pointers */
do { /* main loop */
#if _DEBUG
if (debug) THEN debugger();
else
#endif
nxtins();
}
while (quit == 0); /* (not optimal speedwise, but structured) */
z_exit();
}
char *init(argc,argv)
int argc;
char **argv;
{ /* Init processes command line parameters, figures the dat file name to use,
and sets up the debugger if requested */
char *prog, *s, *datfile = 0, *ext = ".dat";
short i, locmem = 0;
#if _DEBUG
char str[10], *tstr;
int op;
FILE *opchnfp;
#endif
prog = argv[0];
while (--argc) {
if ((*++argv)[0] == '-') {
for (s = &((*argv)[1]); *s; s++) {
switch (lc(*s)) {
#if _DEBUG
case 'd': { /* turn on debugger */
debug = ON | VERBOSE;
for (i = 0; i <= 255; i++) {
ins_tbl[i].brkflg = 0;
ins_tbl[i].opstr = opstrs[0];
}
opchnfp = fopen("ops.dat", "r");
while (fscanf(opchnfp, "%s %d", str, &op) != EOF) {
i = 0;
tstr = str;
while (*tstr)
opstrs[op][i++] = *tstr++;
ins_tbl[op].opstr = opstrs[op];
}
fclose(opchnfp);
break;
}
#endif
case 'k': { /* max dataspace request, in K */
s++;
while (*s) {
locmem *= 10; /* make a decimal number */
locmem += *s - '0'; /* asciify string */
s++; /* advance pointer */
}
s--; /* back up one */
break;
}
case 'g': { /* game file to use */
datfile = (s+1);
while (*(s+1)) s++; /* skip rest of arg */
break;
}
default : printf("\nUnknown switch: %c\n", lc(*s)); break;
} /* end of switch */
} /* end of for loop */
} /* end of if loop */
} /* end of while loop */
if (locmem) THEN
memreq = locmem << 1; /* convert k to blocks */
else memreq = 0; /* otherwise use default */
if (datfile == 0) THEN {
s = prog; /* get program name */
i = 0;
while (*s)
gamfbuf[i++] = *s++;
s = ext;
while (*s)
gamfbuf[i++] = *s++; /* add on ".dat" */
datfile = gamfbuf;
}
return(datfile);
}
sysini()
{ /* Sysini opens the data file, saves away the name as the default save
name, and determines total available memory.
*/
char *d, *s, *ext = ".sav";
int memavail;
if ((gamechn = open(gamfile, RDONLY)) < 0) THEN {
printf("Failed to open game file -- %s", gamfile);
fatal("Sysini");
}
s = gamfile;
d = savfile;
while (*s != PERIOD)
*d++ = *s++; /* copy game file name */
s = ext;
while (*d++ = *s++); /* add .SAV extension */
memavail = md_alloc(-1) >> CVTBLK; /* blocks available */
memavail &= ~BIT16; /* make sure it's unsigned */
/* adjust memreq so it doesn't exceed memory available */
if (memreq > memavail) THEN /* user wanted too much, limit it */
memreq = memavail;
if (!memreq) THEN /* default, ask for memavail */
memreq = memavail;
/* [find a better place for these inits?] */
endbuf = outbuf + scrwid(); /* determine output buffer width */
p_endbuf = p_outbuf + PIPEWIDTH; /* and pipe width */
}
memini()
{ /* This routine compares memreq with ENDLOD and PLENTH (for combined
game/picture files). It determines how much dataspace to allocate,
and does so. It determines how much data to preload, and does so.
It initializes paging in the space remaining.
*/
ZIPINT maxlod,
iendld, /* word ptr to image endlod (relative to ibase) */
ilenth; /* length of image file (in words) */
short i;
char buffer[BLKSIZ], /* temp space for a block */
*md_alloc();
/* Read the first game block into a temporary buffer, then the first
picture block. We temporarily set dataspace to point to this buffer,
so that the GTV macros work.
*/
dataspace = buffer;
getblk(0, buffer) /* get first game block */
ibase = GTVWRD(PLENTH) + IFUDGE; /* picture file starts here */
bsplit(ibase);
getblk(zblk, buffer) /* get first picture block */
/* (IENDLD) may be set incorrectly to zero in some test programs.
It could be reconstructed by adding up IHEAD + 2(IBSETS) + 2(IICONS).
In other words, must preload through the two tables which get
patched later.
>>> Careful, may cross a block boundary? <<<
*/
iendld = GTVWRD(zoff + IENDLD);
ilenth = GTVWRD(zoff + ILENTH);
/* To simplify virtual memory management, the entire code file is always
preloaded. The picture file (generally much bigger) is preloaded
entirely if it fits, or through iendld otherwise.
*/
endlod = ibase + iendld; /* total preload, in words */
if (endlod & 0xFF) THEN
endlod += BLKSIZ/2; /* round up to next block */
endlod >>= CVTBLK-1; /* convert to blocks */
maxlod = ibase + ilenth; /* total length, in words */
if (maxlod & 0xFF) THEN
maxlod += BLKSIZ/2; /* round up to next block */
maxlod >>= CVTBLK-1; /* convert to blocks */
/* Note that our paging scheme normally requires a minimum of 2 pages in
the chain, one for the current code page (always locked), and a second
for roving pointers.
Exceptions: When all pages are preloaded, paging is never called and
no chain at all is required. In the freak case where only one page is
not preloaded, the "chain" also needs only one page. Thus, an array
of exactly MAXBLKS paging structures is the most ever required.
*/
if (memreq < endlod + 2) THEN
fatal("Insufficient memory for preload");
if (memreq >= maxlod) THEN { /* mucho memory, take advantage */
endlod = maxlod; /* hack endlod to force total preload */
memreq = maxlod; /* reduce memreq to max needed */
}
/* Allocate all needed memory, re-init dataspace, and load preload */
if ((dataspace = md_alloc(memreq * BLKSIZ)) == NULL) THEN {
printf("Unable to allocate %d", memreq, "blocks");
fatal("Memory allocation error");
}
getpre(0, endlod); /* read in preload data */
/* Currently, an array of blkdescs and a pagemap are declared statically
[0..255]. Should allocate space dynamically for [endlod..memreq-1] only
(number of physical buffers), and a pagemap array for [0..maxlod-1] only
(number of actual pages).
IDEA: call getpre(endlod, memreq) to "prime" the page buffers, and
mark each pagedesc and pagemap appropriately.
*/
if (endlod < maxlod) THEN { /* if total preload, just skip */
for (i = 0; i < MAXBLKS; i++)
pagemap[i] = NOT_IN_CORE; /* no paged pages in core, yet */
for (i = endlod; i < memreq; i++) {
pagedesc[i].next = &pagedesc[i+1]; /* setup pointer chain */
pagedesc[i].prev = &pagedesc[i-1];
pagedesc[i].loc = ((char *)(dataspace + (i * BLKSIZ)));
pagedesc[i].vpage = NO_PAGE;
}
i = memreq - 1;
pagedesc[i].next = &pagedesc[endlod]; /* make the list circular */
pagedesc[endlod].prev = &pagedesc[i]; /* excluding pre and extra */
mru = &pagedesc[i]; /* init mru to last page */
}
}
zipini()
{ /* ZIPINI initializes the ZIL world's link to the interpreter. Pointers
to global tables are setup. Interpreter capabilities are setup also.
(EZIP -- set interpreter id and version)
*/
int i;
char *ptr;
if (GTVBYT(PVERS1) != ZMVERS) THEN /* check z-machine */
fatal("Wrong Z-Machine version");
if (GTVBYT(PVERS2) & 1) THEN /* check for byte swapped file */
fatal("Byte swapped game file");
zorkid = GTVWRD(PZRKID); /* get game id */
glotab = GTVWRD(PGLOTB) << 1; /* get globals base, make byte ptr */
/* Impure code, for save/restore purposes, is ONLY in the code file.
The picture tables need only be patched once at startup, below.
*/
purbot = GTVWRD(PPURBT) << 1; /* get purbot base, make byte ptr */
if (purbot & BYTEBITS) THEN
purbot += BLKSIZ; /* round up to next block */
purbot >>= CVTBLK; /* convert to blocks */
/* Calculate the values (but wait until restart() to set them) for the
first four DIP globals, using the Picture File header data, which was
already preloaded.
*/
nbsets = GTVBYT((ibase << 1) + IBSETS);
nicons = GTVBYT((ibase << 1) + IICONS);
btable = ibase + (IHEAD/2); /* bset table, word ptr */
itable = btable + nbsets; /* icon table, word ptr */
/* Patch (relativize) all entries in the two Picture File tables. */
ptr = (btable << 1) + dataspace;
for (i=0; i<nbsets; i++) {
PTAWRD(ptr, GTAWRD(ptr) + ibase);
ptr += 2;
}
ptr = (itable << 1) + dataspace;
for (i=0; i<nicons; i++) {
PTAWRD(ptr, GTAWRD(ptr) + ibase);
ptr += 2;
}
mtime(); /* set up random seeds */
restart(ZFALSE); /* continue ... */
}
restart(midgame)
int midgame; /* FALSE if called from zipini() */
{
/* Restart (also called by ZIPINI) reloads preload code, saves any flags
that would be wiped out by the reload, and jumps to the game entry
point. (EZIP add in appropriate low memory settings.)
*/
if (midgame) THEN /* reload preload, jim */
getpre(0, endlod);
/* Initialize the first four DIP globals (Picture File info) */
putvar(16, nbsets);
putvar(17, btable);
putvar(18, nicons);
putvar(19, itable);
cls();
locate(25,1);
zsp = zstack + LSTACK; /* setup stack pointers */
ssp = sstack + STKLEN;
zlocs = zsp - zstack; /* make a locals pointer */
zlocs--; /* to next stack slot */
bsplit(GTVWRD(PSTART)); /* get starting address (word ptr) */
zpc1 = zblk;
zpc2 = zoff + 1; /* but always start on next ODD byte */
newzpc()
}

785
unix/dip.ops Normal file
View File

@@ -0,0 +1,785 @@
/* We define a special type for virtual byte pointers which may exceed
64K (16 bits). These occur only in connection with icon definitions
in the DIP image file.
*/
typedef unsigned long int DIPADDR; /* 32 bits preferably */
typedef struct { /* [information supplied by each icon header] */
ZIPBYT bset; /* icon blockset */
ZIPBYT iters; /* number of iterations */
ZIPBYT width; /* icon size */
ZIPBYT height;
DIPADDR addr; /* byte ptr to icon's data */
} iconinfo;
#define GBLEN 8 /* number of bytes per DIP graphics block */
#define SCRNX1 0
#define SCRNX2 40 /* screen width in blocks */
#define SCRNY1 0
#define SCRNY2 24 /* screen height in blocks */
#define DO_NEGATE 0xFF /* inverts bits when XORed with target */
#define NO_NEGATE 0
#define NO_INPUT 0x8F /* indicates that joystick is centered */
/* format of each entry in an Active Icon Table */
#define AI_ADDR 0 /* word ptr to icon */
#define AI_LOCX 2 /* horizontal position of icon (2 bytes) */
#define AI_LOCY 4 /* vertical position of icon (2 bytes) */
#define AI_NEGATE 6 /* negate flag */
#define AI_ICUR 7 /* current iteration */
#define AI_BSET 8 /* block set id */
#define AI_ITOT 9 /* total number of iterations */
#define AI_WIDTH 10 /* width of icon */
#define AI_HEIGHT 11 /* height of icon */
#define AI_ENTRY 12 /* total length of each entry */
#define ETRAP 1 /* nonzero for "heavy duty" error trapping */
/************************************************************************
* *
* G R A P H I C S G L O B A L S *
* *
************************************************************************/
/* I N I T I A L I Z A T I O N S */
ZIPINT btable, /* blockset index table (word ptr) */
itable; /* icon index table (word ptr) */
ZIPBYT nbsets, /* number of blocksets in I-file */
nicons; /* number of icons in I-file */
ZIPBYT rev_table[256]; /* lookup table for block display */
/* C U R R E N T B L O C K */
ZIPINT bsaddr; /* base of current blockset (word ptr) */
ZIPBYT negate = 0, /* set to DO_NEGATE when highlighting active */
dblock[GBLEN], /* current block data */
maskflag = 0, /* nonzero when active */
mblock[GBLEN]; /* current mask block data */
/* W I N D O W S */
short clipx1 = SCRNX1, /* clip window coordinates (initially full) */
clipy1 = SCRNY1,
clipx2 = SCRNX2,
clipy2 = SCRNY2;
/************************************************************************
* *
* G R A P H I C S O P E R A T I O N S *
* *
************************************************************************/
/*------------------------------*/
/* op_showicon */
/*------------------------------*/
op_showicon(mode, iter) /* mode is OPSHOWI or OPSHOWN */
int mode, iter; /* iteration # is usually 1 */
{
struct iconinfo ic1, ic2; /* icon and mask info */
short locx1, locy1, /* icon display coords, before clipping */
locx2, locy2,
subx1, suby1, /* sub-icon display coords, after clipping */
subx2, suby2;
DIPADDR addr1, addr2; /* sub-icon, sub-mask row addresses */
short width, yn, /* row width, row counter */
ixoff, iyoff; /* row offset (relative to full icon) */
if (mode == OPSHOWN) THEN negate = DO_NEGATE;
else negate = NO_NEGATE;
if (argblk[0] == 4) THEN maskflag = 1; /* 4th arg means mask icon */
else maskflag = 0;
gs_iconinfo(argblk[3], &ic1); /* get icon header info */
bsaddr = gs_bsaddr(ic1.bset) /* get blockset addr (word ptr) */
if (iter > 1) THEN /* adjust base addr of icon data */
ic1.addr += (ic1.width * ic1.height) * (iter - 1);
if (maskflag) THEN {
gs_iconinfo(argblk[4], &ic2); /* get mask header info */
/* The DIP spec suggests handling unequal icon and mask sizes by clipping
extra icon blocks (and ignoring extra mask blocks). PC DIP, however,
just returns with no action taken. */
if ((ic1.width != ic2.width) || (ic1.height != ic2.height)) THEN
fatal("bad mask size in op_showicon()");
if (ic1.bset != ic2.bset) THEN /* [really an error?] */
fatal("bad mask blockset in op_showicon()");
}
locx1 = argblk[1]; locy1 = argblk[2];
locx2 = locx1 + ic1.width; locy2 = locy1 + ic1.height;
/* Compute intersection with clip region */
subx1 = locx1; suby1 = locy1;
subx2 = locx2; suby2 = locy2;
if (subx1 < clipx1) THEN subx1 = clipx1; /* clip left */
if (suby1 < clipy1) THEN suby1 = clipy1; /* clip top */
if (subx2 > clipx2) THEN subx2 = clipx2; /* clip right */
if (suby2 > clipy2) THEN suby2 = clipy2; /* clip bottom */
/* display the clipped (optionally masked) icon, looping once for each row */
ixoff = subx1 - locx1; /* clipped x offset, same for every row */
width = subx2 - subx1; /* clipped width */
for (yn=suby1; yn<suby2; yn++) {
iyoff = yn - locy1;
addr1 = ic1.addr + (ic1.width * iyoff) + ixoff;
if (maskflag) THEN
addr2 = ic2.addr + (ic2.width * iyoff) + ixoff;
showrow(addr1, addr2, width, subx1, yn);
}
}
/*------------------------------*/
/* op_copyicon */
/*------------------------------*/
#define TOO_NARROW (ic1.width + ixoff > ic2.width)
#define TOO_SHORT (ic1.height + iyoff > ic2.height)
ZIPINT op_copyicon(mode) /* return must be PUTVALed */
int mode; /* mode is OPSETI or OPSWAPI */
{
struct iconinfo ic1, ic2;
short ixoff, iyoff, row;
DIPADDR addr1, addr2;
gs_iconinfo(argblk[3], &ic1); /* get icon header info */
gs_iconinfo(argblk[4], &ic2);
ixoff = argblk[1]; /* sub-icon offset in icon2 */
iyoff = argblk[2];
if (ic1.bset != ic2.bset) THEN /* [really a fatal error?] */
fatal("blockset mismatch in op_copyicon()");
if (TOO_NARROW || TOO_SHORT) THEN { /* bad fit, return error */
return(ZFALSE);
}
for (row=0; row<ic1.height; row++) {
addr1 = ic1.addr + (ic1.width * row);
addr2 = ic2.addr + (ic2.width * (row + iyoff)) + ixoff;
if (mode == OPSETI) THEN
copyrow(addr1, addr2, ic1.width);
else
swaprow(addr1, addr2, ic1.width);
}
return(ZTRUE);
}
/*------------------------------*/
/* op_clipwind */
/*------------------------------*/
op_clipwind() /* set clip window globals */
{
register short locx1, locy1, locx2, locy2;
short temp;
locx1 = argblk[1]; locy1 = argblk[2];
locx2 = argblk[3] + 1; locy2 = argblk[4] + 1;
if (locx1 < SCRNX1) THEN locx1 = SCRNX1; /* minimum coords */
if (locy1 < SCRNY1) THEN locy1 = SCRNY1;
if (locx2 < SCRNX1) THEN locx2 = SCRNX1;
if (locy2 < SCRNY1) THEN locy2 = SCRNY1;
if (locx1 > SCRNX2) THEN locx1 = SCRNX2; /* maximum coords */
if (locy1 > SCRNY2) THEN locy1 = SCRNY2;
if (locx2 > SCRNX2) THEN locx2 = SCRNX2;
if (locy2 > SCRNY2) THEN locy2 = SCRNY2;
if (locx1 > locx2) THEN { /* exchange if necessary */
temp = locx1;
locx1 = locx2;
locx2 = temp;
}
if (locy1 > locy2) THEN { /* exchange if necessary */
temp = locy1;
locy1 = locy2;
locy2 = temp;
}
clipx1 = locx1; clipy1 = locy1; /* save the coords */
clipx2 = locx2; clipy2 = locy2;
}
/*------------------------------*/
/* op_iterinit */
/*------------------------------*/
/* The first three slots in each table entry are initialized by the game;
the remaining slots are initialized by this routine. */
op_iterinit() /* word ptr to Active Icon Table in argblk[1] */
{
struct iconinfo ic;
short count;
ZIPBYT *ptr; /* absolute ptr into Active Icon Table */
ZIPINT addr;
ptr = (argblk[1] << 1) + dataspace; /* point to table header */
count = GTABYT(ptr++); /* get number of entries in table */
PTABYT(ptr++, 1); /* set current entry to the first */
/* [ETRAP -- check that ptr (initial & final) is within impure preload] */
while (count--) { /* loop once for each table entry */
addr = GTAWRD(ptr); /* icon addr */
gs_iconinfo(addr, &ic); /* get header info for this icon */
ptr += AI_NEGATE; /* skip over addr and position slots */
PTABYT(ptr++, NO_NEGATE); /* set mode to positive */
PTABYT(ptr++, 1); /* set current iteration to the first */
PTABYT(ptr++, ic.bset); /* and store icon header info */
PTABYT(ptr++, ic.iters);
PTABYT(ptr++, ic.width);
PTABYT(ptr++, ic.height);
}
}
/*------------------------------*/
/* op_input */
/*------------------------------*/
/* ARG1, delay time, is interpreted as follows:
+int : poll the keyboard and joystick for int/60 sec. or until
input is detected
0 : poll the keyboard and joystick once, immediately
-int : pause for [-int]/60 sec.
ARG2 [optional] is a word pointer to an active icon table.
Cycle once through the table, starting with the "current" icon.
After each icon is iterated (until the last), check for input
(if requested). If it's detected, halt the cycle immediately.
The returned value is one of the following:
+int : 7-bit ascii character
-int : joystick position and state (see DIP spec for codes)
NO_INPUT : no input detected (joystick is centered)
*/
ZIPBYT op_input() /* return value needs to be PUTVALed */
{
short delay = argblk[1];
ZIPINT table = argblk[2];
ZIPBYT temp, key;
if (argblk[0] = 2) THEN { /* TABLE GIVEN, ITERATE IT */
while (iterate(table)) { /* do current entry (any more?) */
if (delay >= 0) THEN
if ((key = md_input()) != NO_INPUT) THEN /* got one, abort */
return(key);
}
} /* [fall through when iterate done] */
if (delay >= 0) THEN { /* GET KEY WITH DELAY */
while (delay > 0) {
if ((key = md_input()) != NO_INPUT) THEN /* got one, abort */
return(key);
md_delay(1); /* count down one tick */
delay--;
}
key = md_input(); /* no (more) delay, return immediately */
return(key);
}
else { /* DELAY, THEN GET KEY */
md_delay(-delay);
/* Check for input accumulated during long pause. Return the first,
if any, and throw away the remainder, if any.
*/
key = md_input();
while ((temp = md_input()) != NO_INPUT) ;
return(key);
}
}
/*------------------------------*/
/* op_clear */
/*------------------------------*/
/* Clear the screen, black if arg1 is 0, white (negative) if arg1 is -1 */
op_clear() /* [quick and dirty version] */
{
short i, x, y;
for (i=0; i<GBLEN; i++)
dblock[i] = argblk[1];
maskflag = 0;
negate = 0;
for (y=SCRNY1; y<SCRNY2; y++)
for (x=SCRNX1; x<SCRNX2; x++)
md_showblock(x, y);
}
/************************************************************************
* *
* G R A P H I C S S U B - O P E R A T I O N S *
* *
************************************************************************/
/*------------------------------*/
/* showrow */
/*------------------------------*/
/* display a single row of icon blocks, with (optional) mask */
showrow(addr1, addr2, len, dxloc, dyloc)
DIPADDR addr1, addr2; /* byte ptr to row data for icon, mask */
short len, /* row length */
dxloc, dyloc; /* screen position */
{
ZIPBYT irow[SCRNX2], /* icon row image, maximum width */
mrow[SCRNX2]; /* mask row image, maximum width */
short i;
#if ETRAP
if (len + dxloc > SCRNX2) THEN
fatal("row too wide in showrow()");
#endif
/* The block ids within a row are contiguous bytes. It's desirable to
fetch them all at once, before we start calling gs_getblk (since it
fetches paged data too).
*/
dspltb(addr1);
for (i=0; i<len; i++)
irow[i] = getbyt(); /* get icon block ids */
if (maskflag) THEN {
dspltb(addr2);
for (i=0; i<len; i++)
mrow[i] = getbyt(); /* get mask block ids */
}
for (i=0; i<len; i++) {
gs_getblk(irow[i], dblock, negate); /* get block data (optional neg) */
if (maskflag) THEN
gs_getblk(mrow[i], mblock, NO_NEGATE); /* get mask data (never neg) */
md_showblock(dxloc + i, dyloc); /* and display it */
}
}
/*------------------------------*/
/* copyrow */
/*------------------------------*/
/* Copy a single row of icon blocks to another place. */
copyrow(addr1, addr2, len)
DIPADDR addr1, addr2; /* byte ptrs to icon row data */
short len;
{
register ZIPBYT *ptr;
short i;
/* [ETRAP - check that addr2 is within impure preload] */
dspltb(addr1);
ptr = addr2 + dataspace; /* absolutize the target ptr */
/* Since the block ids within the target row are PRELOADED here, it's
not necessary to fetch and store in separate sequences.
*/
for (i=0; i<len; i++)
PTVBYT(ptr++, getbyt()); /* move the block ids */
}
/*------------------------------*/
/* swaprow */
/*------------------------------*/
/* Swap two single rows of icon blocks. */
swaprow(addr1, addr2, len)
DIPADDR addr1, addr2; /* byte ptrs to icon row data */
short len;
{
ZIPBYT temp;
register ZIPBYT *ptr1, *ptr2;
short i;
/* [ETRAP -- check that both addresses are within impure preload] */
ptr1 = addr1 + dataspace;
ptr2 = addr2 + dataspace;
/* Since the block ids within both rows are PRELOADED here, it's
not necessary to fetch and store in separate sequences.
*/
for (i=0; i<len; i++) {
temp = GTABYT(ptr2);
PTABYT(ptr2++, GTABYT(ptr1));
PTABYT(ptr1++, temp);
}
}
/*------------------------------*/
/* iterate */
/*------------------------------*/
/* Iterate the "current" entry in the given Active Icon table, and
update the table. Return zero if it was the last entry.
This routine overwrites argblk[] and calls op_showicon().
*/
int iterate(table)
ZIPINT table; /* word ptr to Active Icon Table */
{
ZIPBYT mode,
aitot, aicur, /* total & current Active Icons */
itot, icur, /* total & current iteration of current AI */
*ptr, *entr; /* absolute ptrs into the table */
/* [careful using GTABYT macro with ptr++ and ptr+n arguments] */
ptr = (table << 1) + dataspace; /* point to head of table */
aitot = GTABYT(ptr++); /* number of entries in table */
aicur = GTABYT(ptr++); /* current entry */
if (aicur > 1) THEN /* point to current entry */
entr = ptr + ((aicur - 1) * AI_ENTRY);
else entr = ptr;
argblk[3] = GTAWRD(entr + AI_ADDR); /* get icon addr */
argblk[1] = GTAWRD(entr + AI_LOCX); /* get icon position */
argblk[2] = GTAWRD(entr + AI_LOCY);
argblk[0] = 3; /* no fourth (mask) arg */
if (GTABYT(entr + AI_NEGATE)) THEN /* check negate flag */
mode = OPSHOWN
else mode = OPSHOWI;
icur = GTABYT(entr + AI_ICUR); /* get AI's current iteration */
itot = GTABYT(entr + AI_ITOT); /* get AI's total iterations */
/* Calling the top-level op_showicon() leads to a bit of unnecessary work,
since it calls gs_iconinfo() for size and blockset info. We have that
already in the AI table, but aren't using it.
*/
op_showicon(mode, icur); /* display AI's current iteration */
if (icur = itot) THEN
icur = 0; /* no more iterations */
PTABYT(entr + AI_ICUR, icur + 1); /* update AI's current iteration */
if (aicur = aitot) THEN
aicur = 0; /* no more active icons */
PTABYT(ptr - 1, aicur + 1); /* update current AI */
return(aicur); /* nonzero if any more active icons */
}
/************************************************************************
* *
* G R A P H I C S S U P P O R T *
* *
************************************************************************/
/*------------------------------*/
/* gs_iconinfo */
/*------------------------------*/
#define ICHEAD 4 /* length of icon header (bytes) */
/* pick up an icon's header information */
gs_iconinfo(headaddr, ic)
ZIPINT headaddr; /* word pointer to icon header */
struct iconinfo *ic; /* leave the header info here */
{
ZIPBYT getbyt();
ic->addr = (headaddr << 1) + ICHEAD; /* byte ptr to icon data */
bsplit(headaddr);
ic->bset = getbyt(); /* blockset */
ic->iters = getbyt(); /* number of iterations */
ic->width = getbyt(); /* icon size */
ic->height = getbyt();
}
/*------------------------------*/
/* gs_bsaddr */
/*------------------------------*/
#define BSHEAD 1 /* length of blockset header (words) */
/* Lookup address of given blockset. Note that the size of each table entry
is one word. */
ZIPINT gs_bsaddr(bset)
ZIPBYT bset;
{
ZIPINT addr; /* word ptr to table entry */
addr = btable + (bset-1); /* index into table, 1-origin */
bsplit(addr);
return(getwrd() + BSHEAD); /* get word ptr, skip header */
/* Could access the table directly, if blockset index is preloaded --
addr = btable + (bset-1); (index into table, 1-origin)
addr <<= 1; (convert to byte address)
return(GTVWRD(addr) + BSHEAD); (get word ptr, skip header)
*/
}
/*------------------------------*/
/* gs_getblk */
/*------------------------------*/
/* Get data corresponding to the given graphics block.
Uses global bsaddr, a word ptr to (base of) current blockset. */
gs_getblk(blk, buffer, neg)
ZIPBYT blk, /* block id, 1-255 */
*buffer, /* data or mask buffer ptr */
neg; /* negate flag (actually XOR pattern) */
{
short i;
ZIPINT addr;
ZIPBYT getbyt();
addr = bsaddr + (blk * GBLEN/2); /* block's address (word ptr) */
bsplit(addr);
for (i=0; i<GBLEN; i++) /* move data to buffer */
*buffer++ = getbyt() ^ neg; /* and negate it if requested */
}
/************************************************************************
* *
* U T I L I T Y R O U T I N E S *
* *
************************************************************************/
/*------------------------------*/
/* dsplit */
/*------------------------------*/
dspltb(bytaddr)
DIPADDR bytaddr;
{ /* Dspltb takes a (virtual) byte pointer, separates it into block
and byte offsets, and returns them in the zblk and zoff globals.
[In the DIP image file only, the pointer may exceed 64K.]
*/
zblk = bytaddr >> CVTBLK; /* extract block bits */
zoff = bytaddr & BYTEBITS; /* extract byte offset bits */
}
/*------------------------------*/
/* rev_byte */
/*------------------------------*/
ZIPBYT rev_byte(val) /* swap bits 1-8, 2-7, etc */
ZIPBYT val;
{
short i;
ZIPBYT newval = 0;
for (i=0; i<8; i++) {
newval >>= 1;
newval |= val & 0x80; /* transfer high bit */
val <<= 1;
}
return(newval);
}
/*------------------------------*/
/* rev_init */
/*------------------------------*/
rev_init() /* initialize the reversed-byte lookup table */
{
short i;
ZIPBYT rev_byte();
for (i=0; i<256; i++)
rev_table[i] = rev_byte(i);
}
/************************************************************************
* *
* M A C H I N E D E P E N D E N T G R A P H I C S *
* *
************************************************************************/
/*------------------------------*/
/* md_showblock */
/*------------------------------*/
#define ORIGIN 0
/* Display the block data in dblock[].
[ If masking is active, use the mask in mblock[]. Wherever a mask bit is 1,
the screen shows through unchanged. Elsewhere the block is displayed.
Straight-forward masking function: S' = (S AND M) OR (B AND ~M)
Equivalent, non-obvious masking function: S' = ((S XOR B) AND M) XOR B
The second function is used in several other DIPs, and here. ]
*/
md_showblock(locx, locy)
unsigned short locx, locy; /* display coordinates */
{
int i, err;
struct urdata ur;
ZIPBYT rev_dblock[GBLEN], /* data block */
rev_mblock[GBLEN], /* mask block */
rev_vblock[GBLEN]; /* screen (video) block */
#if ETRAP
if ((locx >= SCRNX2) || (locy >= SCRNY2) THEN
fatal("md_showblock position out of range");
#endif
/* Reverse the bits in each SHORT to be displayed, so the leftmost bit
becomes the lsb. Necessary for compatibility with PC 7300 graphics.
For more speed, use table lookup.
*/
for (i=0; i<GBLEN; i+2) {
rev_dblock[i] = rev_byte(dblock[i+1]);
rev_dblock[i+1] = rev_byte(dblock[i]);
}
ur.ur_width = GBLEN; ur.ur_height = GBLEN; /* pixels */
ur.ur_srcop = SRCSRC; ur.ur_dstop = DSTSRC;
ur.ur_pattern = 0;
if (maskflag) THEN {
for (i=0; i<GBLEN; i+2) { /* reverse mask bytes too */
rev_mblock[i] = rev_byte(mblock[i+1]);
rev_mblock[i+1] = rev_byte(mblock[i]);
}
/* Read current screen data into memory (rev_vblock[]), and apply the
masking function. Fall through to write back the result.
*/
ur.ur_srcbase = 0; /* window */ ur.ur_srcwidth = 0;
ur.ur_dstbase = rev_vblock; ur.ur_dstwidth = 1; /* in bytes */
ur.ur_srcx = locx * GBLEN; ur.ur_srcy = locy * GBLEN;
ur.ur_dstx = ORIGIN; ur.ur_dsty = ORIGIN;
err = ioctl(wfd, WIOCRASTOP, &ur); /* read screen */
for (i=0; i<GBLEN; i++) {
rev_vblock[i] ^= rev_dblock[i]);
rev_mblock[i] &= rev_vblock[i]);
rev_dblock[i] ^= rev_mblock[i]); /* leave result in rev_dblock */
}
} /* end of if (maskflag) */
/* write the data in rev_dblock[] to screen */
ur.ur_srcbase = rev_dblock; ur.ur_srcwidth = 1; /* in bytes */
ur.ur_dstbase = 0; /* window */ ur.ur_dstwidth = 0;
ur.ur_srcx = ORIGIN; ur.ur_srcy = ORIGIN;
ur.ur_dstx = locx * GBLEN; ur.ur_dsty = locy * GBLEN;
err = ioctl(ttyfd, WIOCRASTOP, &ur);
}
/*------------------------------*/
/* md_delay */
/*------------------------------*/
md_delay(ticks) /* one tick = 1/60 second */
int ticks;
{ /* This should be implemented with a system call rather than a
software loop if possible, so the timing isn't hardware dependent.
Also a sophisticated OS can give the time to somebody else.
*/
int i, j;
for (i=0; i<ticks; i++) {
j = 1000;
while (j--);
}
}
/*------------------------------*/
/* md_input */
/*------------------------------*/
ZIPBYT md_input()
{ /* Poll keyboard and joystick, if no input return immediately
with NO_INPUT.
%%% MAKE GETCHAR() RETURN IMMEDIATELY %%%
*/
ZIPBYT key;
key = getchar(); /* no echo */
key = md_joystick(key); /* check for joystick equiv */
return(key);
}
/*------------------------------*/
/* md_joystick */
/*------------------------------*/
/* This routine checks the state of the joystick and/or alternate keys
on the keyboard. If input is detected, its value is mapped into one
of the joystick interface values defined by DIP.
*/
ZIPBYT md_joystick(testchar)
ZIPBYT testchar;
{ /* For the AT&T PC the number keys are mapped 5 3 6
into joystick positions as shown to the right. 1 2
Number key 0 maps to the button. 7 4 8
*/
ZIPBYT mapchar;
switch (testchar) {
case '0': mapchar = 128+31; break; /* button */
case '1': mapchar = 128+11; break;
case '2': mapchar = 128+7; break;
case '3': mapchar = 128+14; break;
case '4': mapchar = 128+13; break;
case '5': mapchar = 128+10; break;
case '6': mapchar = 128+6; break;
case '7': mapchar = 128+9; break;
case '8': mapchar = 128+5; break;
default: mapchar = testchar; break; /* not the joystick */
return(mapchar);
}

318
unix/dipdefs.h Normal file
View File

@@ -0,0 +1,318 @@
/************************************************************************
* *
* H E A D E R F I L E F O R C D I P *
* *
************************************************************************/
#define ETRAP 1 /* nonzero for "heavy duty" error trapping */
typedef unsigned short int ZIPINT; /* FOR VIRTUAL ADDRESSES */
typedef unsigned char ZIPOBJ; /* FOR USE WITH OBJECTS (EZIP) */
typedef unsigned char ZIPBYT; /* for general unsigned bytes */
/* We define a special type for virtual byte pointers which may exceed
64K (16 bits). These occur only in connection with icon definitions
in the DIP image file.
*/
typedef unsigned long int DIPADDR; /* 32 bits preferably */
typedef struct { /* [information supplied in each icon header: ] */
ZIPBYT bset; /* icon blockset */
ZIPBYT iters; /* number of iterations */
ZIPBYT width; /* icon size */
ZIPBYT height;
DIPADDR addr; /* byte ptr to icon's data */
} iconinfo;
/***** GRAPHICS DEFINITIONS *****/
#define GBLEN 8 /* number of bytes per DIP graphics block */
#define SCRNX1 0
#define SCRNX2 40 /* screen width in blocks */
#define SCRNY1 0
#define SCRNY2 24 /* screen height in blocks */
#define DO_NEGATE 0xFF /* inverts bits when XORed with target */
#define NO_NEGATE 0
#define NO_INPUT 0x8F /* indicates that joystick is centered */
#define DELAYMAX 3000 /* for AT&T delay timing */
#define DELAYMIN 0
#define DELAYINIT 1000
#define DELAYDELTA 250
/* format of each entry in an Active Icon Table */
#define AI_ADDR 0 /* word ptr to icon */
#define AI_LOCX 2 /* horizontal position of icon (2 bytes) */
#define AI_LOCY 4 /* vertical position of icon (2 bytes) */
#define AI_NEGATE 6 /* negate flag */
#define AI_ICUR 7 /* current iteration */
#define AI_BSET 8 /* block set id */
#define AI_ITOT 9 /* total number of iterations */
#define AI_WIDTH 10 /* width of icon */
#define AI_HEIGHT 11 /* height of icon */
#define AI_ENTRY 12 /* total length of each entry */
/***** FILE HEADER STRUCTURE (PROGRAM AND IMAGE) *****/
#define PVERS1 0 /* Z-MACHINE VERSION BYTE */
#define PVERS2 1 /* MODE BYTE */
#define PZRKID 2 /* GAME ID */
#define PENDLD 4 /* END OF GAME FILE PRELOAD (WORD PTR) */
#define PSTART 6 /* EXECUTION START ADDR (WORD PTR "ODD") */
#define PPURBT 8 /* BEGINNING OF PURE CODE (WORD PTR) */
#define PGLOTB 10 /* GLOBAL TABLE (WORD PTR) */
#define PSERNM 12 /* 6 BYTE SERIAL NUMBER (DATE) */
#define PLENTH 18 /* LENGTH OF GAME FILE, IN WORDS */
#define PCHKSM 20 /* CHECKSUM OF GAME FILE, EXCLUDING HEADER */
#define PINTID 22 /* INTERPRETER ID, LETTER & NUMBER */
#define HDRSIZ 64 /* LENGTH OF HEADER, PROGRAM FILE */
#define ILENTH 0 /* length of image file, in words */
#define IENDLD 2 /* end of preload, word ptr */
#define ICHKSM 4 /* checksum of image file */
#define IBSETS 6 /* total number of blocksets in the file */
#define IICONS 7 /* total number of icons in the file */
#define IHEAD 8 /* LENGTH OF HEADER, IMAGE FILE */
#define IFUDGE 1 /* padding between code and image files, in words */
/***** GENERAL DEFINITIONS *****/
#define ZMVERS 1 /* DIP Z-MACHINE VERSION NUMBER */
#define LSTACK 512 /* VIRTUAL STACK SIZE [in words (?)] */
#define STKLEN 64 /* SYSTEM STACK SIZE [in longs (?)] */
#define BLKSIZ 512 /* SIZE OF VIRTUAL PAGES */
#define MAXBLKS 256 /* MAXIMUM GAME SIZE */
#define ZTRUE 1
#define ZFALSE 0
#define MAXARGS 16+1 /* 4 normally, 16 for OPCALL, 1 for count */
#define SCRIPTBIT 1
#define STATBIT 16
#define SPLTBIT 32
#define THEN /* if <cond> THEN <exp>; else <exp>; */
#define NULL 0
#define G_HERE 16 /* ZIL status-line globals */
#define G_SCORE 17
#define G_MOVES 18
#define G_HOURS 17
#define G_MINS 18
/***** CHAR INPUT AND STRING OUTPUT *****/
#define NULL_INPUT -1
#define Z_EOL 1
#define EOL 10 /* LINE FEED IS THE UNIX EOL */
#define ESC 27
#define FEEP "\007" /* BELL */
#define BKSPC 8 /* BACKSPACE */
#define PADCHR 5 /* PAD CHAR FOR ZSTRINGS */
#define SPACE '\040' /* INITIAL READ BREAD CHARS */
#define TAB '\011'
#define CR '\015'
#define FF '\014'
#define PERIOD '.'
#define COMMA ','
#define QMARK '?'
#define CHRS_PER_ZWORD 6
#define TOKEN_TBL_LEN 59
#define BYTEMODE 0
#define ZCHRLEN 5
#define ZCHRMSK 31
#define CSETLEN 26
#define NORMAL 0
#define REVERSE 1
/***** BUFFERING EQUATES *****/
#define IBUFSIZ 100
#define OBUFSIZ 100
#define CONSOLE 0
#define PIPE 1
#define PBUFSIZ 85
#define PIPEWIDTH 79
#define STATLEN 1 /* STATUS LINE ROWS */
#define RM 80 /* right margin */
#define LM 1 /* left margin */
/***** OBJECT AND PROPERTY DEFINITIONS *****/
#define FLAGS1 0 /* OFFSET TO FLAG WORDS */
#define FLAGS2 2
#define PARENT 4 /* PARENT OBJECT NUMBER */
#define SIBLING 5 /* SIBLING OJECT NUMBER */
#define CHILD 6 /* CHILD OBJECT NUMBER */
#define PROPS 7 /* POINTER TO PROPERTY TABLE */
#define OBJLEN 9 /* LENGTH OF AN OBJECT */
#define DPTLEN (31 * 2) /* DEFAULT PROP TABLE LENGTH, 31 ENTRIES */
#define PNUMSK 0x1F /* PROPERTY ID NUMBER MASK (LOW 5 BITS) */
#define PSZMSK 0xE0 /* PROPERTY SIZE MASK (HIGH 3 BITS) */
#define PROPSIZE 5 /* SHIFT COUNT TO ISOLATE SIZE BITS */
/***** PREDICATE AND VARIABLE DEFINITIONS *****/
#define LOCAL 16
#define EMPTY 0
#define BYTEMSK 255
#define BIT8 0x80
#define BIT16 0x8000
#define BACKWARD 128 /* bits to test */
#define JMPLNTH 64
#define PREDMSK 63
#define BIT14 0x2000 /* for testing 14 bit two's-complement */
#define COMP16 0xC000 /* for converting above to 16 bit */
#define BITS87 0xC0 /* for OPCALL decoding */
/***** PAGING DEFINITIONS *****/
#define NOT_IN_CORE 0 /* a NULL pointer */
#define NO_PAGE -1 /* avoid conflict with page 0 */
#define BLOCKBITS 0x7F
#define BYTEBITS 0x1FF
#define CVTBLK 9
#define TO_K 10
/***** FILE I/O DEFINITIONS *****/
#define PATHSIZ 64
#define RDONLY 0
#define FMODE 0644 /* NEW FILE, set most bits */
/****** DEBUGGING DEFINITIONS ******/
#define OFF 0
#define ON 1
#define STEP 2
#define SKIPC 4
#define SKIPN 8
#define VERBOSE 16
#define BRKPT 32
#define SKIPS 0xF3
#define HEX 'x'
#define DEC 'd'
/***** MACROS *****/
#define PRED(arg) ((arg) ? ppred(ZTRUE) : ppred(ZFALSE))
#define PUTV(arg) (putval(arg))
#define PUSH(arg) (*--ssp = arg)
#define POP() (*ssp++)
#define PUSHZ(arg) (*--zsp = arg)
#define POPZ() (*zsp++)
#define BYTARG(arg) ((ZIPBYT)(argblk[arg]))
#define GETLOC(var) (*(zstack + (zlocs - var)))
#define SETLOC(var, val) (*(zstack + (zlocs - var)) = val)
#define GTABYT(ptr) (*(ptr)) /* ptr may be a compound */
#define GTVBYT(off) (*(dataspace + off))
#define PTABYT(ptr,value) (*(ptr) = value)
#define PTVBYT(off,value) (*(dataspace+off) = value)
/* MOVED INTO PROGRAM SUBROUTINES:
#define GTAWRD(ptr) ((((ZIPBYT) *ptr) << 8) | (ZIPBYT) *(ptr+1))
#define GTVWRD(off) ((((ZIPBYT) *(dataspace+off)) << 8) | (ZIPBYT) *(dataspace+off+1))
#define PTAWRD(ptr,value) ((*ptr = (value >> 8)), (*(ptr+1) = (value & 255)))
#define PTVWRD(off,value) ((*(dataspace+off) = (value >> 8)), (*(dataspace+off+1) = (value & 255)))
*/
/***** OPCODES *****/
#define ONE_OP 128
#define ZERO_OP 176
#define EXT_OP 192
#define ZEROMSK 15
#define ONEMSK 15
#define TWOMSK 31
#define EXTMSK 63
#define TWOMOD1 64
#define TWOMOD2 32
#define ONEMODE 48
/* ZERO OPS */
#define OPNOOP 176
#define OPRTRU 177
#define OPRFAL 178
#define OPRSTA 179
#define OPFSTA 180
#define OPQUIT 181
#define OPCOPY 182
#define OPVERI 183
/* ONE OPS */
#define OPPUSH 128
#define OPPOP 129
#define OPVALU 130
#define OPINC 131
#define OPDEC 132
#define OPQZER 133
#define OPBCOM 134 /* "BNOT" */
#define OPJUMP 135
#define OPRETU 136
/* TWO OPS AND EXTENDED OPS */
#define OPUNDF 0 /* UNUSED */
#define OPADD 1
#define OPSUB 2
#define OPMUL 3
#define OPDIV 4
#define OPMOD 5
#define OPBAND 6
#define OPBOR 7
#define OPBXOR 8
#define OPBTST 9 /* "BITS" */
#define OPQEQU 10
#define OPQLES 11
#define OPQDLE 12
#define OPQGRT 13
#define OPQIGR 14
#define OPSET 15
#define OPGET 16
#define OPGETB 17
#define LAST_TWO_OP OPGETB
#define XQEQU EXT_OP + OPQEQU
#define OPCALL 224
#define OPPUT 225
#define OPPUTB 226
#define OPINPUT 227
#define OPSHOWI 228
#define OPSETI 229
#define OPSWAPI 230
#define OPSOUND 231
#define OPRAND 232
#define OPCLEAR 233
#define OPSHOWN 234
#define OPWIND 235
#define OPITER 236
#define OPLOAD 237
#define OPDUMP 238
#define OPREST 239
#define OPSAVE 240

205
unix/ediptst.hex Normal file
View File

@@ -0,0 +1,205 @@
HEXDUMP Version 1.0
-------------------
Dumping "ediptst.dip" in radix 16.
00000/ 01 00 28 01 01 24 06 25 01 24 00 20 38 35 30 33
00010/ 31 39 06 3F CC AC 00 00 00 00 00 00 00 00 00 00
00020/ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00030/ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00040/ 00 00 00 00 00 00 00 00 00 38 00 4C 00 58 00 6D
00050/ 00 78 00 8E 00 97 00 A3 00 AB 00 C1 00 CA 00 D8
00060/ 00 E1 00 EA 00 F3 00 FB 01 03 01 0B 01 0F 01 17
00070/ 01 01 23 01 1E 10 1D 1E 0B 0C 1C 14 1E 13 18 10
00080/ 1E 14 0E 0B 0C 19 0F 0B 17 01 12 14 0E 0C 17 0B
00090/ 01 1A 0E 01 0F 10 1D 00 01 01 13 01 1A 1C 14 19
000A0/ 1E 0B 01 0B 1E 01 0B 03 07 0B 1E 21 14 0E 10 00
000B0/ 01 01 26 01 1E 10 1D 1E 0B 14 12 1C 1E 1C 0B 0C
000C0/ 19 0F 0B 0F 17 10 1D 1D 0B 01 1A 0E 01 0F 10 0B
000D0/ 0C 19 0F 0B 1C 10 1A 10 0C 1E 01 01 11 01 1A 1C
000E0/ 14 19 1E 0B 01 0B 1E 01 0B 0A 0B 1E 01 0B 01 00
000F0/ 01 01 28 01 1E 10 1D 1E 0B 19 1E 13 0B 19 1E 13
00100/ 0D 0B 1A 1F 1E 0B 1A 1F 1E 0D 0B 01 1A 0E 01 0F
00110/ 10 0B 0C 19 0F 0B 1E 0C 0D 17 10 1D 01 01 0D 01
00120/ 1A 1C 14 19 1E 0B 01 0B 1E 01 0B 03 0A 00 01 01
00130/ 14 01 1E 10 1D 1E 0B 1E 13 10 0B 0E 0C 17 17 0B
00140/ 01 1A 0E 01 0F 10 01 01 0C 01 1A 1C 14 19 1E 0B
00150/ 01 0B 1E 01 0B 07 01 01 28 01 1E 10 1D 1E 0B 1D
00160/ 13 01 21 1A 14 0B 1D 13 01 21 19 14 0B 1D 10 1E
00170/ 14 0B 0C 19 0F 0B 1D 21 0C 1A 14 0B 01 1A 0E 01
00180/ 0F 10 01 01 0D 01 1A 1C 14 19 1E 0B 01 0B 1E 01
00190/ 0B 03 08 00 01 01 18 01 1E 10 1D 1E 0B 21 14 19
001A0/ 0F 01 21 0B 0C 19 0F 0B 0E 17 14 1A 1A 14 19 12
001B0/ 01 01 0D 01 1A 1C 14 19 1E 0B 01 0B 1E 01 0B 03
001C0/ 05 00 01 01 0E 01 1E 10 1D 1E 0B 14 1E 10 1C 0C
001D0/ 1E 14 01 19 01 01 0D 01 1A 1C 14 19 1E 0B 01 0B
001E0/ 1E 01 0B 02 01 00 01 01 0C 01 1E 10 1D 1E 0B 18
001F0/ 0C 1D 16 14 19 12 01 01 0C 01 1A 1C 14 19 1E 0B
00200/ 01 0B 1E 01 0B 09 00 08 00 00 00 00 00 00 00 00
00210/ 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 01
00220/ 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 00
00230/ 00 00 00 1E 00 02 00 00 00 00 00 00 00 00 00 1E
00240/ 00 0A 00 00 00 00 00 00 00 E0 1F 06 0D 00 00 E0
00250/ 1F 06 0D 01 00 E0 1F 06 0D 02 00 E0 1F 06 0D 03
00260/ 00 E0 1F 06 0D 04 00 E0 1F 06 0D 05 00 E0 1F 06
00270/ 0D 06 00 E0 1F 06 0D 07 00 E0 1F 06 0D 08 00 E0
00280/ 1F 06 0D 09 00 B3 01 00 00 E0 2B 05 CE 14 15 00
00290/ 0A 01 01 C7 90 00 87 00 04 90 01 E0 1B 05 E2 00
002A0/ 00 00 01 03 07 00 4A 00 0A C7 90 00 87 00 04 90
002B0/ 01 E0 1B 05 E2 01 00 00 C2 0F 55 05 26 8E 00 CA
002C0/ 8F 00 2E 77 C7 90 00 87 00 04 90 01 E0 1B 05 E2
002D0/ 02 00 00 03 2D D8 00 CA 8F 00 25 F8 C7 90 00 87
002E0/ 00 04 90 01 E0 1B 05 E2 03 00 00 C4 1F 19 8F 4E
002F0/ 00 4A 00 53 C7 90 00 87 00 04 90 01 E0 1B 05 E2
00300/ 04 00 00 C5 1F 04 D2 11 00 4A 00 0A C7 90 00 87
00310/ 00 04 90 01 E0 1B 05 E2 05 00 00 02 64 66 00 CA
00320/ 8F 00 FF FE C7 90 00 87 00 04 90 01 E0 1B 05 E2
00330/ 06 00 00 C3 4F 39 FF FD 00 CA 8F 00 FF 55 C7 90
00340/ 00 87 00 04 90 01 E0 1B 05 E2 07 00 00 C3 0F FF
00350/ 99 FF F4 00 CA 8F 00 04 D4 C7 90 00 87 00 04 90
00360/ 01 E0 1B 05 E2 08 00 00 C4 1F FF BB 03 00 CA 8F
00370/ 00 FF E9 C7 90 00 87 00 04 90 01 E0 1B 05 E2 09
00380/ 00 00 C4 0F FF 97 FF FD 00 4A 00 23 C7 90 00 87
00390/ 00 04 90 01 E0 16 FF 05 ED 01 00 00 00 C6 1F 03
003A0/ FF 4D 00 4A 00 4D C7 90 00 87 00 04 90 01 E0 16
003B0/ FF 05 ED 01 01 00 00 C7 0F 01 BC 01 4D 00 CA 8F
003C0/ 00 01 FD C7 90 00 87 00 04 90 01 E0 16 FF 05 ED
003D0/ 01 02 00 00 C8 1F 03 FF 4D 00 CA 8F 00 03 B2 C7
003E0/ 90 00 87 00 04 90 01 E0 16 FF 05 ED 01 03 00 00
003F0/ 86 01 4D 00 C7 2F 01 4D 00 00 CA 8F 00 FF FF C7
00400/ 90 00 87 00 04 90 01 E0 16 FF 05 ED 01 04 00 00
00410/ 09 92 10 49 E0 17 06 01 01 05 00 E0 17 06 16 01
00420/ 05 00 0D 0B 0A 49 E0 17 06 01 01 06 00 E0 17 06
00430/ 16 01 06 00 CB 0F 02 37 55 29 49 E0 17 06 01 01
00440/ 07 00 E0 17 06 16 01 07 00 CA 55 0B 0A 09 08 C9
00450/ E0 17 06 01 01 08 00 E0 17 06 16 01 08 00 02 0B
00460/ 0B 00 A5 00 49 E0 17 06 01 01 09 00 E0 17 06 16
00470/ 01 09 00 0F 01 00 E0 1B 06 01 02 01 00 E0 17 06
00480/ 16 02 00 00 93 01 E0 1B 06 01 02 01 00 E0 17 06
00490/ 16 02 01 00 94 01 93 01 93 01 E0 1B 06 01 02 01
004A0/ 00 E0 17 06 16 02 02 00 90 03 91 01 E0 1B 06 01
004B0/ 02 01 00 E0 17 06 16 02 03 00 90 04 90 00 B4 91
004C0/ 01 E0 1B 06 01 02 01 00 E0 17 06 16 02 04 00 B0
004D0/ E0 17 06 01 02 05 00 E0 17 06 16 02 05 00 E8 7F
004E0/ 0A 00 E0 17 06 01 02 06 00 E0 17 06 16 02 06 00
004F0/ B3 00 01 00 00 E0 2B 05 CE 16 17 00 E0 1F 06 0D
00500/ 00 00 0E 01 08 45 87 00 0B E0 2F 06 0D 01 00 87
00510/ FF F2 E0 1F 06 0D 09 00 0C 01 01 45 87 00 0B E0
00520/ 2F 06 0D 01 00 87 FF F2 E0 1F 06 0D 00 00 B3 00
00530/ 01 FF FF E0 2B 05 CE 18 19 00 E0 1F 06 0D 00 00
00540/ 0E 01 07 45 87 00 0F 70 26 01 00 E0 2F 06 0D 00
00550/ 00 87 FF EE E0 1F 06 0D 09 00 CF 4F 01 FF FF 0E
00560/ 01 07 45 87 00 17 70 26 01 00 E1 AB 24 01 00 70
00570/ 26 01 00 E2 AB 25 01 00 87 FF E6 E0 17 06 16 01
00580/ 00 00 CF 4F 01 FF FF 0E 01 07 45 87 00 10 70 24
00590/ 01 00 E0 1B 06 16 01 00 00 87 FF ED E0 17 06 16
005A0/ 01 09 00 E0 17 06 16 02 00 00 CF 4F 01 FF FF 0E
005B0/ 01 07 45 87 00 10 71 25 01 00 E0 1B 06 16 02 00
005C0/ 00 87 FF ED E0 17 06 16 02 09 00 B3 00 E0 2B 05
005D0/ CE 1A 1B 00 E0 1F 05 FA 00 00 E0 1F 06 0D 00 00
005E0/ E0 15 57 05 83 01 02 03 04 05 06 00 4A 00 30 C7
005F0/ 90 00 87 00 04 90 01 E0 1B 05 E2 01 00 00 E0 15
00600/ 55 FF 05 83 01 02 03 04 05 06 07 00 4A 00 36 C7
00610/ 90 00 87 00 04 90 01 E0 1B 05 E2 02 00 00 E0 15
00620/ 55 7F 05 83 01 02 03 04 05 06 07 08 00 4A 00 67
00630/ C7 90 00 87 00 04 90 01 E0 1B 05 E2 03 00 00 E0
00640/ 15 55 5F 05 83 01 02 03 04 05 06 07 08 09 00 4A
00650/ 00 6F C7 90 00 87 00 04 90 01 E0 1B 05 E2 04 00
00660/ 00 E0 1F 05 AD 03 00 A5 00 C8 E0 1F 05 FA 05 00
00670/ E0 1F 06 0D 05 00 E0 1F 05 AD 04 00 A5 00 48 E0
00680/ 1F 05 FA 06 00 E0 1F 06 0D 06 00 B3 01 00 00 E0
00690/ 2B 05 CE 1C 1D 00 E0 1F 06 0D 00 00 E0 15 FF 05
006A0/ C5 0A 0C 04 00 E0 1F 06 0D 01 00 E0 15 FF 05 C5
006B0/ 0B 0C 0C 00 E0 1F 06 0D 02 00 E0 15 FF 05 C5 0C
006C0/ 10 0C 00 E0 1F 06 0D 03 00 E0 14 FF 05 C5 0A 0C
006D0/ FF FC 00 E0 1F 06 0D 04 00 E0 15 FF 05 C5 0A 0C
006E0/ 14 00 E0 1F 06 0D 05 00 E0 11 FF 05 C5 0A FF FC
006F0/ 04 00 E0 1F 06 0D 06 00 E0 15 FF 05 C5 0A 24 04
00700/ 00 E0 1F 06 0D 07 00 E0 10 FF 05 C5 0A FF FC FF
00710/ FC 00 E0 1F 06 0D 08 00 E0 15 FF 05 C5 0A 24 14
00720/ 00 E0 1F 06 0D 09 00 E0 11 FF 05 C5 0A FF FC 14
00730/ 00 E0 17 06 16 01 00 00 E0 14 FF 05 C5 0A 24 FF
00740/ FC 00 E0 17 06 16 01 01 00 E9 3F FF FF E0 17 06
00750/ 16 01 02 00 50 13 0B 01 50 13 0A 00 E5 5A 06 06
00760/ 01 00 00 A5 00 49 E0 17 06 16 01 03 00 E0 17 05
00770/ B1 01 04 00 50 13 0B 01 50 13 0A 00 E6 5A 06 06
00780/ 01 00 00 A5 00 49 E0 17 06 16 01 05 00 E0 17 05
00790/ B1 01 06 00 50 13 0B 01 50 13 0A 00 E6 5A 02 02
007A0/ 01 00 00 A5 00 C9 E0 17 06 16 01 07 00 E0 17 05
007B0/ B1 01 08 00 50 13 0B 01 50 13 0A 00 E6 5A 02 02
007C0/ 01 00 00 A5 00 C9 E0 17 06 16 01 09 00 E0 17 05
007D0/ B1 02 00 00 50 13 0B 01 50 13 0A 00 E5 5A 02 02
007E0/ 01 00 00 A5 00 C9 E0 17 06 16 02 01 00 E0 17 05
007F0/ B1 02 02 00 E7 7F 01 E0 17 06 16 02 03 00 E7 7F
00800/ 02 E0 17 06 16 02 04 00 E7 7F 01 E0 17 06 16 02
00810/ 05 00 E7 7F 02 E0 17 06 16 02 06 00 50 13 0C 00
00820/ EA 5B 14 0C 00 E0 17 06 16 02 07 00 B3 00 00 E0
00830/ 2B 05 CE 1E 1F 00 E0 1F 06 0D 00 00 EB 55 02 02
00840/ 24 15 E0 1F 06 0D 01 00 E0 15 FF 05 C5 0A 0C 04
00850/ 00 E0 1F 06 0D 02 00 E0 15 FF 05 C5 0B 0C 0C 00
00860/ E0 1F 06 0D 03 00 E0 15 FF 05 C5 0C 10 0C 00 E0
00870/ 1F 06 0D 04 00 E0 14 FF 05 C5 0A 0C FF FC 00 E0
00880/ 1F 06 0D 05 00 E0 15 FF 05 C5 0A 0C 14 00 E0 1F
00890/ 06 0D 06 00 E0 11 FF 05 C5 0A FF FC 04 00 E0 1F
008A0/ 06 0D 07 00 E0 15 FF 05 C5 0A 24 04 00 E0 1F 06
008B0/ 0D 08 00 E0 10 FF 05 C5 0A FF FC FF FC 00 E0 1F
008C0/ 06 0D 09 00 E0 15 FF 05 C5 0A 24 14 00 E0 17 06
008D0/ 16 01 00 00 E0 11 FF 05 C5 0A FF FC 14 00 E0 17
008E0/ 06 16 01 01 00 E0 14 FF 05 C5 0A 24 FF FC 00 E0
008F0/ 17 06 16 01 02 00 EB 55 00 00 27 17 E0 17 06 16
00900/ 01 03 00 E0 15 FF 05 C5 0A 0C 04 00 E0 17 06 16
00910/ 01 04 00 E0 15 FF 05 C5 0B 0C 0C 00 E0 17 06 16
00920/ 01 05 00 E0 15 FF 05 C5 0C 10 0C 00 E0 17 06 16
00930/ 01 06 00 E0 14 FF 05 C5 0A 0C FF FC 00 E0 17 06
00940/ 16 01 07 00 E0 15 FF 05 C5 0A 0C 14 00 E0 17 06
00950/ 16 01 08 00 E0 11 FF 05 C5 0A FF FC 04 00 E0 17
00960/ 06 16 01 09 00 E0 15 FF 05 C5 0A 24 04 00 E0 17
00970/ 06 16 02 00 00 E0 10 FF 05 C5 0A FF FC FF FC 00
00980/ E0 17 06 16 02 01 00 E0 15 FF 05 C5 0A 24 14 00
00990/ E0 17 06 16 02 02 00 E0 11 FF 05 C5 0A FF FC 14
009A0/ 00 E0 17 06 16 02 03 00 E0 14 FF 05 C5 0A 24 FF
009B0/ FC 00 E0 17 06 16 02 04 00 B3 01 00 00 E0 2B 05
009C0/ CE 20 21 00 E0 1F 06 0D 00 00 50 13 0D 00 E1 9B
009D0/ 27 01 00 50 13 0E 00 E1 9B 27 07 00 E0 1F 06 0D
009E0/ 01 00 E2 97 27 00 02 E0 1F 06 0D 02 00 EC BF 27
009F0/ E0 1F 06 0D 03 00 E3 2F FF E2 27 01 E3 2F FF E2
00A00/ 27 01 E3 2F FF E2 27 01 E3 2F FF E2 27 01 E0 1F
00A10/ 06 0D 04 00 E2 97 27 00 01 EC BF 27 E0 1F 06 0D
00A20/ 05 00 E3 6F 00 27 01 4A 01 8F BF F8 E0 1F 06 0D
00A30/ 06 00 E3 6F 1E 27 01 4A 01 8F BF F8 E0 1F 06 0D
00A40/ 07 00 E2 97 27 00 02 EC BF 27 E0 1F 06 0D 08 00
00A50/ E3 6F 00 27 01 4A 01 8F BF F8 E0 1F 06 0D 09 00
00A60/ E3 6F 1E 27 01 4A 01 8F BF F8 E0 17 06 16 01 00
00A70/ 00 B3 01 00 00 50 13 13 01 E0 2B 05 CE 22 23 00
00A80/ E0 1F 06 0D 00 00 50 13 12 00 E4 5B 14 02 00 E0
00A90/ 1F 06 0D 01 00 50 13 0F 00 E4 5A 14 02 01 00 E0
00AA0/ 1F 06 0D 02 00 50 13 10 00 E4 5A 14 02 01 00 E0
00AB0/ 1F 06 0D 03 00 50 13 11 00 E4 5A 14 02 01 00 E0
00AC0/ 1F 06 0D 04 00 50 13 12 00 E4 5B 14 0C 00 E0 1F
00AD0/ 06 0D 05 00 50 13 0F 00 EA 5A 14 0C 01 00 E0 1F
00AE0/ 06 0D 06 00 50 13 10 00 EA 5A 14 0C 01 00 E0 1F
00AF0/ 06 0D 07 00 50 13 11 00 EA 5A 14 0C 01 00 E0 1F
00B00/ 06 0D 08 00 B3 00 0F 00 01 00 01 00 01 00 01 00
00B10/ 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00
00B20/ 01 00 01 00 00 63 01 02 0F 63 03 04 00 61 0F 00
00B30/ 00 63 05 06 00 61 00 00 00 63 07 08 00 61 00 00
00B40/ 00 63 09 0A 00 61 00 00 00 63 0B 0C 00 61 00 00
00B50/ 00 63 0D 0E 00 61 00 00 00 B3 01 00 00 4A 01 03
00B60/ C1 B2 02 00 00 00 00 E0 15 FF 05 C5 0A 0C 04 00
00B70/ E0 15 FF 05 C5 0B 0C 0C 00 E0 15 FF 05 C5 0C 10
00B80/ 0C 00 E0 2B 06 16 01 02 00 B3 03 00 00 00 00 00
00B90/ 00 70 13 01 00 E4 AB 02 03 00 B1 00 02 00 00 00
00BA0/ 00 E9 3F FF FF E4 5B 00 02 01 E4 5B 00 03 02 E0
00BB0/ 3F 05 DB 00 B3 00 01 00 00 E3 7F 00 01 4A 01 8F
00BC0/ BF F9 A8 01 02 00 00 00 00 A5 02 C8 E0 2F 05 FA
00BD0/ 01 00 E0 2F 06 0D 01 00 B3 00 03 00 00 00 00 00
00BE0/ 00 A5 03 C9 E0 2B 06 01 01 02 00 E0 2B 06 16 01
00BF0/ 02 00 B3 00 01 00 00 70 13 01 00 E4 5B 0B 06 00
00C00/ B1 00 02 00 00 00 00 70 13 01 00 E4 5B 09 06 00
00C10/ 70 13 02 00 E4 5B 0B 06 00 B1 01 00 00 70 13 01
00C20/ 00 E4 5B 06 06 00 E0 3F 05 DB 00 B3 02 00 00 00
00C30/ 00 70 13 01 00 E4 5B 04 06 00 70 13 02 00 E4 5B
00C40/ 06 06 00 E0 3F 05 DB 00 B3 00 00 E9 3F FF FF E0
00C50/ 3F 01 24 00 E0 3F 05 39 00 E0 3F 04 DD 00 E0 3F
00C60/ 01 43 00 E0 3F 02 79 00 E0 3F 02 98 00 E0 3F 02
00C70/ E6 00 E0 3F 03 46 00 E0 3F 04 17 00 B5 B1 00 00
00C80/ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

190
unix/ediptst.pichex Normal file
View File

@@ -0,0 +1,190 @@
HEXDUMP Version 1.0
-------------------
Dumping "ediptst.pic" in radix 16.
00000/ 05 CC 0B 98 3A 4F 03 14 01 85 03 DE 04 FB 00 1B
00010/ 00 1F 00 23 00 27 00 2B 00 2F 00 33 00 37 00 3B
00020/ 00 3F 00 43 00 61 00 66 00 6B 00 73 00 7F 00 BE
00030/ 00 E9 01 1D 01 51 02 01 02 02 01 02 03 04 02 01
00040/ 02 02 05 06 07 08 02 01 02 02 09 0A 0B 0C 02 01
00050/ 02 02 0D 0E 0F 10 02 01 02 02 11 12 13 14 02 01
00060/ 02 02 15 16 17 18 02 01 02 02 19 1A 1B 1C 02 01
00070/ 02 02 1D 1E 1F 20 02 01 02 02 21 22 1B 1C 02 01
00080/ 02 02 23 24 25 26 02 01 08 07 27 28 28 28 28 28
00090/ 28 29 2A 2B 2C 2D 2E 2F 2C 30 2A 31 32 2D 2E 33
000A0/ 00 30 2A 34 35 2D 2E 33 36 30 2A 37 38 2D 2E 39
000B0/ 38 30 2A 00 3A 3B 3C 3D 00 30 3E 3F 3F 3F 3F 3F
000C0/ 3F 40 02 01 03 02 41 42 41 41 43 41 02 01 03 02
000D0/ 44 45 44 44 46 44 02 02 03 02 41 42 41 41 43 41
000E0/ 44 45 44 44 46 44 02 05 02 02 01 02 03 04 05 06
000F0/ 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 03 01
00100/ 0B 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00110/ 00 01 02 00 00 00 00 00 00 00 00 00 03 04 05 00
00120/ 00 00 00 00 00 00 06 07 07 08 00 00 00 00 00 00
00130/ 09 0A 07 07 0B 0C 00 00 00 00 00 0D 07 07 07 07
00140/ 0E 00 00 00 00 0F 10 07 07 07 07 11 12 00 00 00
00150/ 13 14 14 14 14 14 14 15 00 00 00 00 00 00 00 00
00160/ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00170/ 00 00 00 00 00 00 00 00 00 00 00 00 03 01 09 09
00180/ 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 00
00190/ 00 00 00 00 00 00 03 04 05 00 00 00 00 00 06 07
001A0/ 07 08 00 00 00 00 09 0A 07 07 0B 0C 00 00 00 0D
001B0/ 07 07 07 07 0E 00 00 0F 10 07 07 07 07 11 12 00
001C0/ 13 14 14 14 14 14 14 15 00 00 00 00 00 00 00 00
001D0/ 00 00 03 01 0A 0A 00 00 00 00 00 00 00 00 00 00
001E0/ 00 00 00 00 01 02 00 00 00 00 00 00 00 00 03 04
001F0/ 05 00 00 00 00 00 00 06 07 07 08 00 00 00 00 00
00200/ 09 0A 07 07 0B 0C 00 00 00 00 0D 07 07 07 07 0E
00210/ 00 00 00 0F 10 07 07 07 07 11 12 00 00 13 14 14
00220/ 14 14 14 14 15 00 00 00 00 00 00 00 00 00 00 00
00230/ 00 00 00 00 00 00 00 00 00 00 03 01 0A 0A 2D 2D
00240/ 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D
00250/ 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2F 30 30
00260/ 30 30 30 30 31 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D
00270/ 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2F 30 30 30 30
00280/ 30 30 31 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D
00290/ 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D
002A0/ 2D 2D 03 01 0A 0A 16 17 17 17 17 17 17 17 17 17
002B0/ 16 16 16 16 16 16 16 16 16 16 16 18 19 19 19 19
002C0/ 19 19 1A 16 16 1B 1C 1D 1D 1D 1D 1E 1F 16 16 16
002D0/ 20 1D 1D 1D 1D 21 16 16 16 16 22 23 1D 1D 24 25
002E0/ 16 16 16 16 16 26 1D 1D 27 16 16 16 16 16 16 16
002F0/ 28 29 2A 16 16 16 16 16 16 16 2B 2C 16 16 16 16
00300/ 16 16 16 16 16 16 16 16 16 16 08 96 00 00 00 00
00310/ 00 00 00 00 FF C3 BD BD BD BD C3 FF FF C7 F7 F7
00320/ F7 F7 C1 FF FF C3 BD FD C3 BF 81 FF FF C3 BD F3
00330/ FD BD C3 FF FF FB F3 EB DB 81 FB FF FF 83 BF 83
00340/ FD BD C3 FF FF C3 BF 83 BD BD C3 FF FF 81 BD FD
00350/ FB F7 EF FF FF C3 BD C3 BD BD C3 FF FF C3 BD BD
00360/ C1 FD C3 FF FF FF FF FF FF FF FF FF FF C3 BD BD
00370/ 81 BD BD FF FF 83 BD BD 83 BD 83 FF FF C3 BD BF
00380/ BF BD C3 FF FF 83 BD BD BD BD 83 FF FF 81 BF BF
00390/ 83 BF 81 FF FF 81 BF BF 83 BF BF FF FF C3 BD BF
003A0/ A1 BD C3 FF FF BD BD BD 81 BD BD FF FF 83 EF EF
003B0/ EF EF 83 FF FF F1 FB FB FB BB C7 FF FF BD BD 83
003C0/ BD BD BD FF FF BF BF BF BF BF 81 FF FF BD 99 A5
003D0/ BD BD BD FF FF BD 9D AD B5 B9 BD FF FF 83 BD BD
003E0/ 83 BF BF FF FF C3 BD BD BD B5 C3 FB FF 83 BD BD
003F0/ 83 BD BD FF FF C3 BF C3 FD BD C3 FF FF 01 EF EF
00400/ EF EF EF FF FF BD BD BD BD BD C3 FF FF BD BD BD
00410/ BD DB E7 FF FF BD BD BD AD AB D7 FF FF BD DB E7
00420/ E7 DB BD FF FF BD BD BD 83 EF EF FF FF 81 FB F7
00430/ EF DF 81 FF FF FF FF EF FF EF FF FF FF FF FF FF
00440/ C3 FF FF FF C3 D9 99 BC 3C 7E 66 66 E0 E0 E7 E7
00450/ E7 67 67 67 00 00 FF FF E7 E7 E7 E7 00 00 0F 0F
00460/ CF CF CF CF 00 00 C3 C3 CF CF CF CF 00 00 FF FF
00470/ CF CF CF CF 3C 3C 0C 0C C0 C0 F0 F0 00 00 F0 F0
00480/ F3 F3 F3 F3 00 00 FF FF F3 F3 F3 F3 0F 0F C3 C3
00490/ F3 F3 F3 F3 00 00 3F 3F 3F 3F 3F 3F 00 00 FF FF
004A0/ FF FF FF FF 00 00 F9 F9 F9 F9 F9 F9 06 00 C1 E7
004B0/ E7 E7 E7 E4 00 00 FF FF FF FF FF 00 01 00 FC FE
004C0/ FF FF FF 00 FF FF 7F 3F 3F 3F 3F 07 FF FF FF FF
004D0/ FF FE FC F8 FF FF E7 C3 81 18 7C FE FF FF FF FF
004E0/ FF FF 7F 3F 00 80 FF FF FF FF FF FF 67 67 E7 E7
004F0/ E7 E7 E7 E7 E7 E7 FF FF E0 E0 E7 E7 CF CF 0F 0F
00500/ 0F 0F CF CF CF CF CF CF CF CF CF CF CF CF FF FF
00510/ CF CF CF CF FC FC FF FF 3F 3F 0F 0F F3 F3 F3 F3
00520/ F3 F3 F3 F3 3F 3F 3F 3F 3F 3F 3F 3F F9 F9 F9 F9
00530/ F9 F9 F9 F9 E0 E7 E7 E7 E7 E3 F0 F8 00 33 33 33
00540/ FF FF 00 00 03 33 33 33 F2 F0 00 00 F0 E0 C6 8F
00550/ 1F 1F 8F C7 FF 7F 3F 1F 8F C7 E3 C1 1F 8F C7 E3
00560/ F1 F8 FC FE FF FF FF FF FF FF 7F 7F E7 E7 E7 E7
00570/ E0 E0 FF FF E7 E7 E7 E7 07 07 FF FF CF CF CF CF
00580/ C0 C0 FF FF CF CF CF CF 00 00 FF FF 03 03 30 30
00590/ 3C 3C FF FF F3 F3 F0 F0 00 00 FF FF F3 F3 FF FF
005A0/ 00 00 FF FF F3 F3 C3 C3 0F 0F FF FF 1F 9F 8F C3
005B0/ E0 F8 FF FF FF FF FF FF 00 00 FC FC FF FF FF FF
005C0/ 00 00 CF CF F9 F9 F8 FC 00 00 FF FF FF FF FF 7F
005D0/ 00 00 F3 F3 FF FF FF FF 00 00 3F 3F FF FF FF FF
005E0/ 00 00 FF FF FC FE FE FE 00 00 FF FF 63 71 60 44
005F0/ 4E 0F 07 E3 98 1C 38 71 33 1F 8E C6 FE 7E 3F 1F
00600/ 9F 0F 07 63 7F 3F 1F 8F C7 E3 F1 F8 FE FE FE FE
00610/ FE FE FE FE 01 CC CC CC FC CC CC CC 86 B0 31 79
00620/ 78 FC CD CC 07 F3 99 81 F1 19 99 F1 C0 DF D8 D8
00630/ DE D8 D9 D9 43 19 18 3C 3C 7E 66 66 0E 66 66 66
00640/ 66 66 60 7C 1C CD CD CD CD CD C1 F9 00 F3 83 83
00650/ EB 8B 83 F3 07 B3 B3 F3 F3 73 73 33 00 00 3C 3C
00660/ 3C 3C 3C 3C C0 C0 CF CF CF CF CF CF 00 00 FC FC
00670/ 00 00 3C 3C 00 00 3F 3F FC FC FC FC 00 00 70 B0
00680/ B4 EC FC FC 00 00 EF FF DC 3C FC FC 03 03 F0 F0
00690/ FC FC FC FC F1 F8 FC FE FF FF FF FF E2 F3 79 38
006A0/ 1C 9E CF C7 E1 C0 8C DC 78 31 1B 8F F8 F1 63 07
006B0/ 0F 8F 87 03 FE FF FF FF FF FF FF FF 03 07 FF FF
006C0/ C0 9E B3 B3 C1 E1 FF FF 80 3B 3B 3F 00 80 FF FF
006D0/ 78 3B 3B 39 00 00 FF FF 04 31 33 E3 00 00 FF FF
006E0/ 08 E3 33 33 00 00 FF FF 00 33 33 33 03 03 FF FF
006F0/ 0F E7 33 33 3C 3C FE FF 3F 3F 3F 3F CF 0F 1F 3F
00700/ 3F 3F 3F 3F 00 00 F0 F0 00 00 3C 3C FC FC FF FF
00710/ FC FC FC FC FC FC FC FC FC FC FC FC FC D0 3C FC
00720/ FC FC FC FC E3 F1 F8 F8 F0 E3 C7 8E C6 E3 F1 78
00730/ 3C 1E 0F 07 31 78 F1 E3 47 0F 1F 8F B3 B3 B3 9E
00740/ C0 E0 FF FF 3F 37 37 33 00 00 FF FF 3C 3E 3E 3E
00750/ 3E 3F FF FF C3 C3 CB C9 0C 0E FF FF 33 33 33 E1
00760/ 00 04 FF FF 33 33 33 E3 00 00 FF FF E3 C3 67 33
00770/ 03 03 FF FF 3F 3F 3F 3F 00 00 FF FF 00 00 FC FC
00780/ 00 00 FF FF FC FC FC FC 00 00 FF FF FC FC FF FF
00790/ 00 00 FF FF FC 7D B3 E6 0C 28 FF FF FF FE FE 7E
007A0/ 7F FF FF FF 1C 38 71 23 07 8F FF FF 63 F1 F8 FC
007B0/ FE FF FF FF C7 E3 C7 0F 1F 3F FF FF 08 47 00 00
007C0/ 00 00 00 00 00 00 00 00 0F 0F 0C 0C 0C 0C 00 00
007D0/ F0 F0 30 30 30 30 0C 0C 0C 0C 0F 0F 00 00 30 30
007E0/ 30 30 F0 F0 00 00 00 00 01 03 07 01 01 01 00 00
007F0/ C0 C0 C0 C0 C0 C0 01 01 01 01 01 01 00 00 C0 C0
00800/ C0 C0 C0 C0 00 00 00 00 0F 1F 18 00 00 01 00 00
00810/ E0 F0 30 70 E0 C0 03 07 0E 1C 1F 1F 00 00 80 00
00820/ 00 00 F0 F0 00 00 00 00 0F 1F 18 00 00 03 00 00
00830/ E0 F0 30 30 30 E0 03 00 00 18 1F 0F 00 00 E0 30
00840/ 30 30 F0 E0 00 00 00 00 00 00 01 03 06 0C 00 00
00850/ 60 E0 E0 60 60 60 18 1F 1F 00 00 00 00 00 60 F0
00860/ F0 60 60 60 00 00 00 00 0F 0F 0C 0C 0C 0F 00 00
00870/ F0 F0 00 00 00 E0 00 00 00 08 0F 0F 00 00 30 30
00880/ 30 30 F0 E0 00 00 00 00 07 0C 0C 0C 0C 0F 00 00
00890/ E0 00 00 00 00 E0 0C 0C 0C 0C 0C 07 00 00 30 30
008A0/ 30 30 30 E0 00 00 00 00 0F 0F 08 00 00 00 00 00
008B0/ F0 F0 30 30 60 60 00 00 01 01 03 03 00 00 C0 C0
008C0/ 80 80 00 00 00 00 00 00 07 0C 0C 0C 0C 07 00 00
008D0/ E0 30 30 30 30 E0 00 00 07 0C 0C 0C 0C 0C 00 00
008E0/ E0 30 30 30 30 30 07 00 00 01 03 06 00 00 F0 60
008F0/ C0 80 00 00 00 00 00 00 3F 3F 30 30 30 30 00 00
00900/ FF FF 00 00 00 00 00 00 FC FC 0C 0C 0C 0C 30 30
00910/ 30 30 30 30 30 30 FF FF FF E0 E0 E0 E0 E0 F0 F8
00920/ FC 1E 0F 07 07 07 03 03 03 03 03 03 03 03 C0 C0
00930/ C0 C0 C0 C0 C0 C0 0F 1F 3F 78 F0 E0 E0 E0 0C 0C
00940/ 0C 0C 0C 0C 0C 0C E0 E0 E0 E0 E0 E0 E0 FF 07 07
00950/ 07 07 07 07 07 FF E0 E0 E0 E0 E0 E0 E0 E0 FF E0
00960/ E0 E0 E0 E0 E0 E0 FF 07 07 07 07 07 07 07 3F 3F
00970/ 3F 07 07 07 07 07 E0 E0 E0 E0 E0 FF FF FF 07 07
00980/ 07 0F 1E FC F8 F0 E0 E0 E0 F0 78 3F 1F 0F 00 00
00990/ C7 C7 C6 C6 C7 C7 00 00 E3 E3 03 03 E3 E3 00 00
009A0/ F8 F8 18 18 F8 F8 00 00 FE FE C6 C6 C6 C6 30 30
009B0/ 30 30 3F 3F 00 00 00 00 00 00 FF FF 00 00 0C 0C
009C0/ 0C 0C FC FC 00 00 AA AA AA AA AA AA AA AA AA AA
009D0/ BA FA FA BA BA BA BA BA BA BA FE FE AA AA 55 55
009E0/ 55 55 55 55 55 55 55 55 FF FF 57 57 57 FF FF D5
009F0/ D5 D5 FF FF 55 55 08 34 00 00 00 00 00 00 00 00
00A00/ 00 00 00 01 03 03 07 07 00 00 80 C0 E0 E0 F0 F0
00A10/ 0F 0F 1F 3F 3F 7F 7F FF F8 F8 FC FC FE FF FF FF
00A20/ 00 00 00 00 00 00 00 80 00 01 03 03 07 07 0F 0F
00A30/ FF FF FF FF FF FF FF FF 80 C0 C0 E0 F0 F0 F8 F8
00A40/ 00 00 00 00 00 00 00 01 1F 3F 3F 7F 7F FF FF FF
00A50/ FC FC FE FE FF FF FF FF 00 00 00 00 00 80 80 C0
00A60/ 03 03 07 07 0F 0F 1F 3F C0 E0 E0 F0 F8 F8 FC FC
00A70/ 00 00 00 00 00 01 03 03 3F 7F 7F FF FF FF FF FF
00A80/ FE FE FF FF FF FF FF FF 00 00 00 80 80 C0 C0 E0
00A90/ 07 07 0F 0F 1F 3F 3F 00 FF FF FF FF FF FF FF 00
00AA0/ E0 F0 F0 F8 FC FC FE 00 22 88 22 88 22 88 22 88
00AB0/ 00 88 22 88 22 88 22 88 00 99 26 99 26 89 26 81
00AC0/ 00 99 66 99 66 99 66 99 00 98 64 98 62 90 62 88
00AD0/ 22 89 20 88 22 88 22 88 66 99 66 99 66 19 66 99
00AE0/ 66 99 66 99 66 99 66 99 66 99 66 99 66 99 66 98
00AF0/ 62 88 42 88 22 08 22 88 26 99 26 89 26 81 22 89
00B00/ 64 98 62 98 62 88 62 88 20 88 22 88 22 88 22 88
00B10/ 66 99 66 19 66 99 26 99 66 99 66 99 66 98 64 98
00B20/ 42 88 22 08 22 88 22 88 26 89 26 81 22 89 20 88
00B30/ 62 98 62 90 62 88 42 88 66 19 66 99 26 99 26 89
00B40/ 66 99 66 98 64 98 62 98 22 08 22 88 22 88 22 88
00B50/ 26 81 22 89 20 88 22 88 62 90 62 88 42 88 22 08
00B60/ 00 55 00 55 00 55 00 55 00 54 00 54 00 54 00 54
00B70/ 00 5D 77 5D 77 5D 77 00 00 DD 77 DD 77 DD 77 00
00B80/ 00 DC 76 DC 76 DC 76 00 00 55 00 55 00 55 00 00
00B90/ 00 54 00 54 00 54 00 00 00 00 00 00 00 00 00 00

BIN
unix/ediptst.sum Normal file

Binary file not shown.

432
unix/folding.c Normal file
View File

@@ -0,0 +1,432 @@
TO DO Make combined PUTCHR routine for variable-width screen and
script output buffering, takes args in a parameter block.
/* I / O B U F F E R S */
char *chrptr, *endbuf, /* output buffer pointers */
*p_chrptr, *p_endbuf, /* pipe output buffer pointers */
p_outbuf[PBUFSIZ], /* pipe output buffer */
outbuf[OBUFSIZ], /* maximum output buffer */
inbuf[IBUFSIZ]; /* maximum input buffer */
/* F L A G S */
char scripting = 0, /* scripting flag */
scrchk = 0, /* flag to check for script bit */
slflg = 1, /* status line in place (EZIP) */
scroll = 1, /* windowed scrolling */
toplin, /* top line of screen 0 */
screen, /* current screen for output */
splitable = 0, /* ablity to support split screen */
spltflg = 0, /* screen split flag */
quit = 0; /* game op flag for quit */
/* T T Y */
int ttyfd, /* for setting up terminal i/o */
ttysav; /* storage of a startup tty condition */
int winlen = 22, /* window length */
linecnt; /* line count for MORE */
*--------------------------------------------------------------------------
* GENERALIZED OUTPUT FOLDING ROUTINE
*--------------------------------------------------------------------------
* THE QUECHR ROUTINE IS CALLED WITH A POINTER TO A STRUCTURE CONTAINING
* THE VARIABLES BELOW. THIS ARRANGEMENT ALLOWS FOR THE EXISTANCE OF MORE THAN
* ONE STRUCTURE, USEFUL IF DISPLAYED TEXT AND SCRIPTED TEXT ARE TO FOLD AT
* DIFFERENT POINTS.
* THE STRUCTURE IDENTIFIES TWO ACTION ROUTINES. THE OUTPUT FUNCTION
* DUMPS THE BUFFER WHEN IT BECOMES FULL. THE SIZE FUNCTION ALLOWS FOR THE
* HANDLING OF PROPORTIONALLY SPACED TEXT.
* THE LAST TWO VARIABLES ARE CURRENTLY IGNORED, BUT MIGHT BE USEFUL
* FOR IMPLEMENTING RECALCULATION OF THE FOLD POINTS FOR A PARAGRAPH OF TEXT,
* AS WHEN A WINDOW CHANGES SIZE.
/* data structure for queue-parameters block */
struct queparams {
char *bufptr; /* start of buffer */
WORD bufsiz; /* maximum units in buffer */
char *nxtptr; /* current position within buffer */
WORD cursiz; /* current units in buffer */
XXX sizfun; /* given a char, returns unit size */
XXX outfun; /* given bufptr & endptr, dumps buffer, adds cr */
XXX retfun; /* (unused -- this should add the cr) */
BYTE dumped; /* was buffer emptied (without cr) before full? */
BYTE autocr; /* append a cr to each buffer dump? yes */
BYTE keepsp; /* don't discard trailing space? no */
}
dque, sque;
#define qplen sizeof(struct queparams)
/************************************************************************
* *
* O U T P U T B U F F E R I N G *
* *
************************************************************************/
putchr(letter, qp)
char letter; struct queparams *qp;
{ /* Putchr takes an ASCII character and queues it for output. If it
fills the buffer, a search backwards for a space is conducted to
break the line. The end of the buffer is determined by endbuf
which should be set whenever the screen size is changed to reflect
the difference between the right and left margins.
*/
char *tailptr, *dest;
char nospace = 0;
if (chrptr != endbuf) /* any room left? */
*chrptr++ = letter; /* store the char */
else {
tailptr = endbuf;
while (*--tailptr != SPACE) { /* search backwards for a space */
if (tailptr == outbuf) { /* not a space to be found! */
letter = dumpfix(letter, CONSOLE); /* dump buffer and add crlf */
nospace = 1; /* indicate reason for loop exit */
break;
} /* end of while searching for ' ' */
}
if (*tailptr == SPACE) /* space found, rearrange buffer */
if ((tailptr == outbuf) && (nospace != 1))
letter = dumpfix(letter, CONSOLE);
else {
*tailptr = NULL; /* end the line at the space */
dumpbuf();
dest = outbuf; /* shift-left remainder of line */
while (++tailptr < endbuf) /* from space+1 to buffer start */
*dest++ = *tailptr;
chrptr = dest; /* reset the character pointer */
} /* end of rearranging of buffer */
if (letter) /* if no crlf */
*chrptr++ = letter; /* put the char in the buffer */
}
}
dumpfix(letter, caller)
int caller;
ZIPINT letter;
{ /* Dumpfix is called after putchr has searched backwards for a space
character. It prints the line and determines when a crlf should
follow.
*/
if (caller == CONSOLE)
dumpbuf(); /* print the line */
else
dmp_pbuf(); /* print the line on pipe */
if (letter == SPACE) /* print a crlf in place of a ' '*/
return(NULL); /* NULL is interpreter as crlf */
else
return(letter);
}
p_putchr(letter) /* put char to pipe (usually printer) */
ZIPINT letter;
{ /* P_putchr is a fixed width version of putchr for writing to a pipe
(for scripting). It function is the same with the exception that
p_endbuf is fixed at 79.
*/
char *tailptr, *dest;
char nospace = 0;
if (p_chrptr != p_endbuf) /* if there is room */
*p_chrptr++ = letter; /* put the char in the buffer */
else {
tailptr = p_endbuf; /* init tail to end of buffer */
while (*--tailptr != SPACE) { /* search backwards for a " " */
if (tailptr == p_outbuf) { /* not a space to be found! */
/**/ letter = dumpfix(letter, PIPE); /* dump buffer and add crlf */
nospace = 1; /* indicate reason for loop exit */
break;
} /* end of while searching for ' '*/
}
if (*tailptr == SPACE) /* space found, rearrange buffer */
if ((tailptr == p_outbuf) && (nospace != 1))
/**/ letter = dumpfix(letter, PIPE);
else {
*tailptr = NULL; /* make space into end of line */
/**/ dmp_pbuf(); /* now print the buffer */
dest = p_outbuf; /* now move remainder of line <-- */
while (++tailptr < p_endbuf) /* from space+1 to the beginning */
*dest++ = *tailptr; /* of the output buffer */
p_chrptr = dest; /* reset the character pointer */
} /* end of rearranging of buffer */
if (letter) /* if no crlf */
*p_chrptr++ = letter; /* put the char in the buffer */
} /* end of first else */
return;
}
newlin()
{ /* Newlin is called when a CRLF is desired on output of a zstring.
It flushes the buffer and resets the buffer character pointer.
*/
*chrptr = NULL; /* indicate end of line */
if (scripting)
*p_chrptr = NULL;
dumpbuf();
}
dumpbuf()
{ /* Dumpbuf flushes the existing buffer to the screen.
*/
if (scripting) {
dmp_pbuf();
p_chrptr = p_outbuf;
}
mprnt(outbuf);
chrptr = outbuf; /* reset buffer pointer */
}
dmp_pbuf()
{ /* Dmp_pbuf flushes the existing output buffer for the pipe to the
pipe.
*/
char *bufptr;
bufptr = p_outbuf; /* get another pointer */
while ((*bufptr) && (*bufptr != Z_EOL))
bufptr++; /* search for end of string */
if (*bufptr == Z_EOL) { /* drop in end char */
*bufptr = NULL;
fprintf(scrptfd, "%s", p_outbuf); /* write string */
}
else
fprintf(scrptfd, "%s\n",p_outbuf);/* with crlf if necessary */
}
mprnt(buf)
char *buf;
{ /* Mprnt prints a string assuming that Z_EOL indicates end of line
without crlf and null requests a crlf.
(EZIP. May have to be modified to support the printing of
attributes.)
*/
while ((*buf) && (*buf != Z_EOL)) /* search for line terminator */
md_putc(*buf++); /* print character */
if (*buf == NULL)
mcrlf(); /* windowed scroll on ending null */
return;
}
chkscript()
{ /* Chkscript is called when the flag scrchk has been set.
Scrchk flag is set in BOR and BAND to indicate that a possible change
in state of scripting has occurred. The flag should be set by OPDIROUT
in EZIP.
*/
ZIPINT temp;
scrchk = 0; /* reset flag */
temp = GTVWRD(PFLAGS); /* get status word */
if (scripting) { /* set according to current state */
if ((temp & SCRIPTBIT) == 0) {
fclose(scrptfd); /* close if turned off */
scripting = 0; /* and reset flag */
}
}
else
if (temp & SCRIPTBIT) {
scripting = 1; /* turn on flag and open */
p_chrptr = p_outbuf; /* reset scripting buffer */
if ((scrptfd = fopen("script", "w")) < 0)
scripting = 0; /* turn off flag if open fails */
}
return;
}
* ALLOCATE AND INITIALIZE A QUEUE PARAMETER BLOCK,
* D1 IS MAXIMUM SIZE OF BUFFER (IN BYTES), D2 IS INITIAL UNIT SIZE
* A1 POINTS TO LINE OUTPUT FUNCTION, A2 POINTS TO UNIT SIZE FUNCTION
* RETURN BLOCK POINTER IN A0
INITQP MOVE.W D1,D0
ADD.W #QPLEN,D0 * TOTAL SPACE TO ALLOCATE
EXT.L D0
BSR GETMEM * GET IT
MOVE.L A0,D0 * PARAMETERS BLOCK WILL START HERE
ADD.L #QPLEN,D0
MOVE.L D0,BUFPTR(A0) * LINE BUFFER STARTS HERE
MOVE.L D0,NXTPTR(A0) * ALSO CURRENT POINTER
MOVE.W D2,BUFSIZ(A0) * UNIT CAPACITY OF BUFFER
CLR.W CURSIZ(A0) * ALWAYS EMPTY INITIALLY
MOVE.L A1,OUTFUN(A0) * INITIALIZE LINE OUTPUT FUNCTION
MOVE.L A2,SIZFUN(A0) * INITIALIZE CHAR SIZE FUNCTION
CLR.B DUMPED(A0) * THIS ONE IS SET ONLY BY PUTLIN
RTS * RETURN THE POINTER IN A0
* QUEUE THE CHAR IN D0 FOR OUTPUT, A0 POINTS TO QUEUE-PARAMETERS BLOCK
QUECHR MOVEM.L D4/A1-A4,-(SP)
MOVE.W D0,D4
MOVE.L A0,A4
MOVE.W CURSIZ(A4),D0
CMP.W BUFSIZ(A4),D0 * BUFFER FULL YET?
BLT QCX8 * NO
*** BGT QCX0 * OVERFULL (DEQUE THE LAST CHAR AND REENTER)
CMPI.B #32,D4 * YES, BUT DID A SPACE CAUSE OVERFLOW?
BNE.B QCX1 * NO
MOVE.L NXTPTR(A4),D0 * YES, JUST PRINT THE WHOLE BUFFER
MOVE.L BUFPTR(A4),A0
MOVE.L OUTFUN(A4),A3
JSR (A3)
CLR.W CURSIZ(A4) * RESET LENGTH COUNTER
MOVE.L BUFPTR(A4),NXTPTR(A4) * RESET CURRENT CHAR POINTER
CLR.B DUMPED(A4) * STARTING A FRESH LINE
BRA.B QCX9 * EXIT, IGNORING SPACE
* FOLDING ROUTINE, SEARCH FOR MOST-RECENT SPACE ...
QCX1 MOVE.L BUFPTR(A4),A1 * BEGINNING OF BUFFER
MOVE.L NXTPTR(A4),A2 * END OF BUFFER (+1)
BRA.B QCX2A * ALLOW FOR EMPTY [DUMPED] BUFFER
QCX2 CMPI.B #32,-(A2) * SEARCH FOR SPACE BACKWARDS FROM END
BEQ.B QCX4 * FOUND ONE
QCX2A CMPA.L A1,A2 * REACHED BEGINNING OF BUFFER?
BGT QCX2 * NOT YET
* NO SPACES FOUND, DUMP WHOLE BUFFER ...
QCX3 TST.B DUMPED(A4) * BUT WAS THIS BUFFER ALREADY PARTLY EMPTIED?
BNE QCX5 * YES, CARRY EVERYTHING OVER TO NEXT LINE
MOVE.L NXTPTR(A4),A2 * OTHERWISE, OUTPUT EVERYTHING
BRA QCX5
* SPACE WAS FOUND, DUMP THE BUFFER (THROUGH SPACE) ...
QCX4 MOVE.L A2,A0 * POINTER TO THE SPACE
ADDQ.L #1,A2 * POINTER PAST THE SPACE
CMPA.L A1,A0 * DEGENERATE CASE WITH SPACE AT BUFPTR?
BEQ QCX3 * YES, OUTPUT WHOLE LINE
QCX5 MOVE.L A2,D0 * LAST CHAR TO PRINT (+1)
MOVE.L A1,A0 * START OF BUFFER
MOVE.L OUTFUN(A4),A3 * GO DUMP IT, ADDING A CR
JSR (A3)
* SHIFT ANY REMAINING CHARS TO FRONT OF BUFFER ...
CLR.W CURSIZ(A4) * ZERO THE UNIT COUNT
CLR.B DUMPED(A4) * START WITH A FRESH BUFFER
BRA QCX7
QCX6 MOVE.B (A2)+,D0
MOVE.B D0,(A1)+ * COPY NEXT CHAR TO BEGINNING OF BUF
MOVE.L SIZFUN(A4),A0 * CHAR STILL IN D0
JSR (A0)
ADD.W D0,CURSIZ(A4) * UPDATE THE UNIT COUNT
QCX7 CMPA.L NXTPTR(A4),A2 * ANY MORE CHARS AFTER SPACE?
BLT QCX6 * YES
MOVE.L A1,NXTPTR(A4) * NO, STORE NEW CURRENT POINTER HERE
* FINALLY, STORE THE NEW CHAR AND EXIT ...
QCX8 MOVE.L NXTPTR(A4),A0
MOVE.B D4,(A0)+ * STORE THE NEW CHARACTER IN BUFFER
MOVE.L A0,NXTPTR(A4) * AND UPDATE POINTER
MOVE.W D4,D0
MOVE.L SIZFUN(A4),A0
JSR (A0) * GET UNIT SIZE OF NEW CHAR
ADD.W D0,CURSIZ(A4) * AND UPDATE COUNTER
QCX9 MOVEM.L (SP)+,D4/A1-A4
RTS
*--------------------------------------------------------------------------
* MAIN OUTPUT HANDLER
*--------------------------------------------------------------------------
* !ALL! OUTPUT GENERATED BY THE GAME (AND THE USER) SHOULD BE CHANNELED
* THROUGH THE FOLLOWING TWO ROUTINES, WHICH REDIRECT IT APPROPRIATELY.
* OUTPUT A NEWLINE
PUTNEW MOVEQ #13,D0 * JUST FALL THROUGH WITH A CR
* OUTPUT THE CHAR IN D0 (TO THE REQUESTED DEVICES)
PUTCHR CMPI.B #9,D0 * TAB? (OLD ZORK BUG, DISPLAYS GARBAGE)
BNE.S PCX1
MOVEQ #32,D0 * YES, MAP TO A SPACE
PCX1 NOP * <ST ASSEMBLER>
*** STATUS LINE OUTPUT (ZIP INTERNAL FUNCTION ONLY) ...
IFEQ CZIP
TST.W VOSTAT(A6) * SPECIAL OUTPUT TO SL HANDLER?
BNE PUTSL * YES (ABORT PUTCHR)
ENDC
*** TABLE OUTPUT ...
IFEQ EZIP
TST.W VOTABL(A6) * TABLE OUTPUT?
BNE TABCHR * YES (ABORT PUTCHR PER "DIROUT" SPEC)
ENDC
MOVE.W D0,-(SP) * OTHERWISE, SAVE THE CHAR HERE
*** SCRIPT (BEFORE SCREEN, SO "OPEN" ERROR DISPLAYS IN CORRECT SEQUENCE)
TST.W WIND1(A6) * BUT ARE WE IN WINDOW 1?
BNE.S PCX2 * YES, TEMPORARILY AVOID SCRIPTING
IFEQ EZIP
TST.W VOPRNT(A6) * SCRIPTING ACTIVE?
ENDC
IFEQ CZIP
BSR TSTSCR * CHECK FOR SCRIPTING REQUEST -- ACTIVE?
ENDC
BEQ.S PCX2 * NO
MOVE.W (SP),D0 * SCRIPT THIS CHAR
BSR SCRCHR
*** SCREEN DISPLAY ...
PCX2 TST.W VOCONS(A6) * CONSOLE OUTPUT ACTIVE?
BEQ.S PCX3 * NO
MOVE.W (SP),D0 * YES, DISPLAY THE CHAR
BSR QDCHR
*** FILE OUTPUT ...
PCX3 NOP * NOT IMPLEMENTED
TST.W (SP)+ * FLUSH CHAR FROM STACK
RTS

BIN
unix/foo.dat Normal file

Binary file not shown.

5502
unix/foo.hex Normal file

File diff suppressed because it is too large Load Diff

53
unix/foo.pichex Normal file
View File

@@ -0,0 +1,53 @@
053C0/ 81 E4 0A B8
053D0/ C4 5A 2E C9 38 3A 38 E3 3A 18 3D 6D 3E 46 40 13
053E0/ 42 A8 46 49 47 FE 4A AF 4C 50 4D D9 50 DE 52 67
053F0/ 53 90 54 7D 55 7E 56 7F 57 7C 59 59 5B 06 5C 6B
05400/ 5D 54 5E 69 5F 2A 60 87 62 1C 63 51 64 56 65 6F
05410/ 67 0C 68 25 69 2E 6A FF 6B EC 6C E5 6D 2E 71 2B
05420/ 74 FC 77 65 79 7A 7A CB 7B C4 7C C9 7D 06 80 EB
05430/ 0A B8 0A BB 0B 25 0B C3 0C 61 0D 33 0F 71 10 AB
05440/ 11 15 11 7F 11 E9 12 53 12 BD 13 27 13 91 13 FB
05450/ 14 CD 15 9F 16 09 00 FB 00 FE 01 01 01 04 01 07
05460/ 01 0A 01 0D 01 10 01 13 01 16 01 19 01 1C 01 1F
05470/ 01 22 03 04 0A 86 0A 89 0A 8C 0A 8F 0A 92 0A 97
05480/ 0A 9D 0A A5 0A AA 0A B0 16 73 18 55 18 5A 18 5F
05490/ 18 63 18 67 18 6B 18 6F 18 73 18 77 18 7A 18 7D
054A0/ 18 93 18 A9 18 BF 18 D5 18 F7 19 19 19 3B 19 5D
054B0/ 19 A7 19 F1 1A 3B 1A 85 1A CF 1A D7 1B 0D 1B 42
054C0/ 1B 7A 1B F4 1B F9 1B FE 1C 03 1C 08 1C 0C 1C 3B
054D0/ 1C 5E 1C B4 1D 28 1D 90 1D AE 1D CC 1D E0 1E 16
054E0/ 1E 4C 1E 82 1E B8 1E BF 1E C6 1E D0 1E E0 1E F1
054F0/ 1F 02 1F 88 1F C2 1F CA 1F DA 1F F3 20 0C 20 20
05500/ 20 3D 20 57 20 71 20 8B 20 A5 20 CE 20 E8 21 02
05510/ 21 1C 21 36 21 4D 21 5F 21 96 21 9B 21 9E 21 A1
05520/ 22 16 22 7C 22 9F 22 C5 22 EB 23 0D 23 11 23 1B
05530/ 23 32 23 61 23 90 23 BF 23 EE 24 1D 24 8D 24 B7
05540/ 24 C8 24 D9 24 EA 24 FB 25 75 25 7D 25 85 25 AB
05550/ 25 DB 25 F9 26 85 27 11 27 3F 27 6D 27 72 27 77
05560/ 27 7C 27 81 27 84 27 87 27 8A 27 8D 28 28 28 D5
05570/ 29 82 2A 41 2A DC 2B 80 2C 1B 2C D1 2D 75 2E 2B
05580/ 2E D7 2F 97 30 14 30 91 30 C7 30 E9 31 84 31 EE
05590/ 32 58 32 C2 32 E7 33 0C 33 31 33 56 33 7B 33 A0
055A0/ 33 C5 33 EA 34 14 34 3E 34 68 34 7C 34 7F 34 82
055B0/ 35 41 36 31 36 51 36 71 36 76 36 7B 36 80 36 85
055C0/ 36 EB 02 01 02 01 16 17 02 01 01 02 18 19 02 01
055D0/ 02 01 1A 1B 02 01 01 02 1C 1D 02 01 01 01 29 00
055E0/ 02 01 01 01 2A 00 02 01 01 01 2B 00 02 01 01 01
055F0/ 2C 00 02 01 01 01 29 00 02 01 01 01 2A 00 02 01
05600/ 01 01 2B 00 02 01 01 01 2C 00 02 01 01 01 2D 00
05610/ 02 01 28 18 21 07 08 08 08 08 08 08 08 08 08 2E
05620/ 2F 08 08 08 08 08 08 2E 2F 08 08 08 08 08 08 08
05630/ 08 08 08 08 08 2E 2F 08 08 08 08 22 30 11 31 04
05640/ 11 30 32 32 32 32 11 2E 2F 0C 05 33 31 01 14 2E
05650/ 2F 0C 30 32 32 32 11 03 31 33 34 24 14 2E 2F 0C
05660/ 30 1E 35 34 33 13 36 37 11 38 39 02 38 39 11 2E
05670/ 2F 0C 33 3A 36 37 09 2E 2F 0C 38 39 39 39 11 31
05680/ 3B 3C 3A 34 09 2E 2F 0C 38 32 3D 3A 23 09 0A 0A
05690/ 0B 0A 0A 0A 0A 0A 0B 2E 2F 0C 3C 3A 36 3E 09 2E
056A0/ 2F 0C 06 38 39 39 11 36 3E 23 3C 3A 09 2E 2F 0C
056B0/ 38 39 3D 3A 3F 40 40 40 40 40 40 40 40 40 40 2F
056C0/ 2F 0C 0A 0A 0D 0E 0F 2E 2F 0C 0A 0A 0A 0A 0B 0A
056D0/ 0A 0D 0E 0E 0F 2E 2F 0C 0D 0E 10 05 2E 2F 2F 2F
056E0/ 2F 2F 2F 2F 2F 2F 2F 2F 2F 0C 24 41 42 42 11 2E
056F0/ 2F 40 40 40 40 40 40 40 40 40 40 40 40 2F 2F 0C
05700/ 33 34 14 31 31 07 08 08 08 08 08 08 08 08 08 2E

204
unix/page.c Normal file
View File

@@ -0,0 +1,204 @@
In the interest of having a general ZIP paging scheme that is faster
than the time stamping scheme used in the PDP-11 version, a linked
list LRU scheme was implemented. The LRU chain is a doubly linked
list of blkdesc structures. Each structure contains a previous and
next pointer, a char ptr to the buffer and a virtual page number for
the page currently residing in the buffer. The global variable MRU
is a pointer to the structure corresponding to the most recently used
page; consequently, mru->prev points to the LRU buffer.
The routine Getpag takes a block number and returns a char pointer
to the start of the corresponding block. It also performs all the
necessary pointer manipulation and paging to make that pointer valid.
/* P A G I N G */
short curblk = -1, /* current block (same as last zpc1) */
curpag = -1; /* last page gotten (from getpag) */
char *curblkloc, /* pointer to curblk block */
*curpagloc; /* pointer to curpag block */
struct blkdesc {
struct blkdesc *next, /* next descriptor ptr */
*prev; /* previous descriptor ptr */
char *loc; /* page pointer */
short vpage; /* page number */
}
pagedesc[MAXBLKS]; /* one descriptor for each virtual page */
struct blkdesc *mru, /* most recently used blkdesc */
*pagemap[MAXBLKS]; /* one mapping for each virtual page */
memini()
{ /* This routine compares memreq with ENDLOD and PLENTH. It
determines how much dataspace to allocate, and does so. It determines
how much data to preload, and does so. It also initializes paging.
*/
char buffer[BLKSIZ]; /* temp space for block 0 */
ZIPINT maxlod;
short i;
char *md_alloc();
/* Read the first block into a temporary buffer. We temporarily set
dataspace to point to this buffer, so that getpre() and the GTV macros
work. */
dataspace = buffer;
getpre(0, 1); /* get block 0 */
endlod = GTVWRD(PENDLD); /* get endlod pointer */
if (endlod & BYTEBITS) THEN
endlod += BLKSIZ; /* round up to next block */
endlod >>= CVTBLK; /* convert to blocks */
maxlod = GTVWRD(PLENTH); /* length of program, in words */
if (maxlod & 0xFF) THEN
maxlod += BLKSIZ/2; /* round up to next block */
maxlod >>= CVTBLK-1; /* convert to blocks */
/* Note that our paging scheme normally requires a minimum of 2 pages in
the chain, one for the current code page and a second for roving pointers.
In the freak case where only one page is not preloaded, however, the
"chain" may contain only one page too. When all pages are preloaded,
paging is never called and no chain at all is required. Thus an array
of MAXBLKS paging structures is the most ever needed.
*/
if (memreq < endlod + 2) THEN
fatal("Insufficient memory for preload");
if (memreq >= maxlod) THEN { /* mucho memory, take advantage */
endlod = maxlod; /* hack endlod to force total preload */
memreq = maxlod; /* reduce memreq to max needed */
}
if ((dataspace = md_alloc(memreq * BLKSIZ)) == NULL) THEN {
printf("Unable to allocate %d", memreq, "blocks");
fatal("Memory allocation error");
}
getpre(0, endlod); /* read in preload data */
/* Currently, an array of blkdescs and a pagemap are declared statically
[0..255]. Should allocate space dynamically for [endlod..memreq-1] only
(number of physical buffers), and a pagemap array for [0..maxlod-1] only
(number of actual pages).
IDEA: call getpre(endlod, memreq) to "prime" the page buffers, and
mark each pagedesc and pagemap appropriately.
*/
if (endlod < maxlod) THEN { /* if total preload, just skip */
for (i = 0; i < MAXBLKS; i++)
pagemap[i] = NOT_IN_CORE; /* no paged pages in core, yet */
for (i = endlod; i < memreq; i++) {
pagedesc[i].next = &pagedesc[i+1]; /* setup pointer chain */
pagedesc[i].prev = &pagedesc[i-1];
pagedesc[i].loc = ((char *)(dataspace + (i * BLKSIZ)));
pagedesc[i].vpage = NO_PAGE;
}
i = memreq - 1;
pagedesc[i].next = &pagedesc[endlod]; /* make the list circular */
pagedesc[endlod].prev = &pagedesc[i]; /* excluding pre and extra */
mru = &pagedesc[i]; /* init mru to last page */
}
}
char *getpag(blk) /* return a pointer to the requested page */
short blk;
{
/* This is the heart of the paging scheme. It manages a doubly-linked
list of block descriptors. Preloaded pages are not included in this
list so they cannot be paged out. If the page requested is preloaded,
a valid pointer is returned immediately.
Otherwise, the block is removed from the linked list, spliced into
the front of the list and made mru. There are two subroutines, unlink
and relink, that manage the linked list.
If the block is not in core, the current mru's->previous (or lru
block) buffer is used to page in the requested block. Then the
information in the corresponding block descriptors is filled to
indicate the absence of the lru and the presence of the new. The mru
pointer is then pointed at this block.
*/
struct blkdesc *lru;
short deadpage;
#if _DEBUG
if (blk >= MAXBLKS) THEN /* valid block request? */
fatal("Virtual page number out of range");
#endif
if (blk == curpag) THEN /* same page as last time */
return(curpagloc); /* return immediately */
if (blk < endlod) THEN { /* preloaded, expand the pointer */
curpag = blk;
curpagloc = dataspace + (blk << CVTBLK);
return(curpagloc);
}
if (pagemap[blk] == NOT_IN_CORE) THEN {
/* When choosing the (lru) page to discard, make sure it's not the
current code page (where the zpc is), otherwise the newzpc buffer pointer
becomes invalid! -- DBB */
lru = mru->prev; /* get oldest page */
deadpage = lru->vpage;
if (deadpage == curblk) THEN { /* but avoid using the zpc page */
lru = lru->prev; /* get next oldest page */
deadpage = lru->vpage;
}
getblk(blk, lru->loc); /* read new page over lru page */
if (deadpage != NO_PAGE) THEN /* mark old page as gone */
pagemap[deadpage] = NOT_IN_CORE;
pagemap[blk] = lru; /* update map for new page */
lru->vpage = blk; /* update desc for new page */
mru = lru; /* update mru */
}
else /* page is resident */
if (pagemap[blk] != mru) THEN { /* if already mru, do nothing */
unlinkb(blk); /* unsplice from wherever it is */
relinkb(blk); /* link it in as new mru */
}
curpag = blk; /* update page globals */
curpagloc = mru->loc;
return(curpagloc); /* return pointer */
}
unlinkb(block)
short block;
{ /* Unlink removes a block descriptor from the lru chain.
*/
struct blkdesc *t1, *t2;
t1 = pagemap[block]->prev; /* get pointer to one end */
t2 = pagemap[block]->next; /* and the other */
t1->next = t2; /* swap pointers */
t2->prev = t1;
}
relinkb(block)
short block;
{ /* Splice a block back into the lru chain (becomes the new mru).
*/
struct blkdesc *newblk, *lru;
newblk = pagemap[block]; /* pointer to the splice block */
lru = mru->prev; /* lru pointer */
newblk->next = mru; /* update new desc's prev and next */
newblk->prev = lru;
mru->prev = newblk; /* update mru and lru descs */
lru->next = newblk;
mru = newblk; /* new mru */
}

3177
unix/phg_zip.c Normal file

File diff suppressed because it is too large Load Diff

240
unix/phg_zipdefs.h Normal file
View File

@@ -0,0 +1,240 @@
/* Header file for C ZIP */
typedef unsigned char ZOBJECT; /* FOR USE WITH OBJECTS */
typedef unsigned short int ZIPINT; /* 16 INTEGERS ALL THE WAY */
#define ZMVERS 3 /* Z-MACHINE VERSION NUMBER */
#define LSTACK 512 /* STACK SIZE IN BYTES */
#define STKLEN 64 /* SYSTEM STACK LENGTH */
#define BLKSIZ 512 /* SIZE OF VIRTUAL PAGES */
#define MAXBLKS 256 /* VIRTUAL MACHINE UPPER LIMIT */
#define DATASIZ 128 /* USE 64K OF MEMORY AS DEFAULT */
#define IBUFSIZ 100
#define OBUFSIZ 100
/* OFFSETS FOR HEADER INFORMATION */
#define PVERS1 0 /* ZVERSION BYTE */
#define PVERS2 1 /* ZVERSION MODE BYTE */
#define PZRKID 2 /* ZORK ID */
#define PENDLD 4 /* ENDLOD POINTER */
#define PSTART 6 /* Z ENTRY POINT */
#define PVOCTB 8 /* POINTER TO VOCABULARY TABLE */
#define POBJTB 10 /* POINTER TO OBJECT TABLE */
#define PGLOTB 12 /* POINTER TO GLOBAL TABLE */
#define PPURBT 14 /* POINTER TO BEGINNING OF PURE CODE */
#define PFLAGS 16 /* POINTER TO FLAGS */
#define PSERNM 18 /* 6 BYTE SERIAL NUMBER (DATE) */
#define PWRDTB 24 /* POINTER TO FULL WORDS FOR PUTSTR */
#define PLENTH 26 /* LENGTH OF GAME IN WORDS */
#define PCHKSM 28 /* CHECKSUM OF BYTES FROM THE END OF THE
++ HEADER TO LENGTH */
#define HDRSIZ 64 /* LENGTH OF HEADER IN BYTES */
#define ESC 27
#define Z_EOL 1
#define EOL 10 /* LINE FEED IS THE UNIX WAY */
#define FEEP "\007" /* BELL CHAR FOR BEEPING */
#define BKSPC 8 /* BACKSPACE VALUE */
#define PADCHR 5 /* VALUE OF PAD CHAR FOR VOCAB */
#define SPACE '\040' /* INITIAL READ BREAD CHARS */
#define TAB '\011'
#define CR '\015'
#define FF '\014'
#define PERIOD '.'
#define COMMA ','
#define QMARK '?'
#define NULL 0
#define HEX 'x'
#define DEC 'd'
#define RM 80
#define LM 1
/* O P C O D E S */
/* ZERO OPS */
#define OPRTRU 176 /* RETURN TRUE */
#define OPRFAL 177 /* RETURN FALSE */
#define OPPRNI 178 /* PRINTI */
#define OPPRNR 179
#define OPNOOP 180
#define OPSAVE 181
#define OPREST 182
#define OPRSTT 183
#define OPRSTA 184
#define OPFSTA 185
#define OPQUIT 186
#define OPCRLF 187
#define OPUSL 188
#define OPVERI 189
/* ONE OPS */
#define OPQZER 128
#define OPQNEX 129
#define OPQFIR 130
#define OPLOC 131
#define OPPTSI 132
#define OPINC 133
#define OPDEC 134
#define OPPRNB 135
#define OPREMO 137
#define OPPRND 138
#define OPRETU 139
#define OPJUMP 140
#define OPPRIN 141
#define OPVALU 142
#define OPBCOM 143
/* TWO OPS AND EXTENDED OPS */
#define OPUNDF 0
#define OPQEQU 1
#define OPQLES 2
#define OPQGRT 3
#define OPQDLE 4
#define OPQIGR 5
#define OPQIN 6
#define OPBTST 7
#define OPBOR 8
#define OPBAND 9
#define OPQFSE 10
#define OPFSET 11
#define OPFCLE 12
#define OPSET 13
#define OPMOVE 14
#define OPGET 15
#define OPGETB 16
#define OPGETP 17
#define OPGTPT 18
#define OPNEXT 19
#define OPADD 20
#define OPSUB 21
#define OPMUL 22
#define OPDIV 23
#define OPMOD 24
#define LAST_TWO_OP OPMOD
#define XQEQU 193
#define OPCALL 224
#define OPPUT 225
#define OPPUTB 226
#define OPPUTP 227
#define OPREAD 228
#define OPPRNC 229
#define OPPRNN 230
#define OPRAND 231
#define OPPUSH 232
#define OPPOP 233
#define OPSPLT 234
#define OPSCRN 235
/* P R O P E R T Y D E F I N I T I O N O F F S E T S */
#define OBJLEN 9 /* LENGTH OF AN OBJECT */
#define DEF_PROP_TBL_LEN 53 /* LENGTH OF DEFAULT PROPERTY TABLE */
#define FLAGS1 0 /* OFFSET TO FLAG WORDS */
#define FLAGS2 2
#define PARENT 4 /* PARENT OBJECT NUMBER */
#define SIBLING 5 /* SIBLING OJECT NUMBER */
#define CHILD1 6 /* CHILD OBJECT NUMBER */
#define PROPS 7 /* POINTER TO PROPERTY TABLE */
#define PNUMSK 31 /* PROPERTY ID NUMBER MASK (LOW 5 BITS) */
#define PSZMSK 224 /* PROPERTY SIZE MASK (HIGH 3 BITS) */
#define PROPSIZE 5 /* SHIFT COUNT TO ISOLATE SIZE BITS */
#define MAXARGS 5 /* ZIL MAXIMUM NUMBER OF ARGS */
/* G E N E R A L E Q U A T E S */
#define SCRIPTBIT 1
#define PBUFSIZ 85
#define CONSOLE 0
#define PIPE 1
#define PIPEWIDTH 79
#define EREOL (printf("\033[K"))
#define STATLEN 1
#define BLOCK_CROSSED ((zpc2 < 0) || (zpc2 >= BLKSIZ))
#define G_HERE 16
#define G_SCORE 17
#define G_MOVES 18
#define G_HOURS 17
#define G_MINS 18
#define NORMAL 0
#define REVERSE 1
#define FMODE 0644 /* set most bits */
#define PATHSIZ 64
#define TO_K 10
#define NO_INPUT -1
#define THEN
#define NULL 0
#define RDONLY 0
#define NOT_IN_CORE 0
#define LOCAL 16
#define EMPTY 0
#define BYTEMSK 255
#define BIT16 32768
#define BACKWARD 128 /* bits to test */
#define JMPLNTH 64
#define PREDMSK 63
#define BIT14 0x2000 /* for testing 14 bit compness */
#define COMP16 0xC000 /* for converting above to 16 bit */
#define BLOCKBITS 0x7F
#define BYTEBITS 0x1FF
#define CVTBLK 9
#define BYTEMODE 0
#define ZCHRLEN 5
#define ZCHRMSK 31
#define CSETLEN 26
#define NO16TH 0xEFFF
#define ZTRUE 1
#define ZFALSE 0
#define ZQUIT -1
#define ZRESTART 1
#define ONE_OP 128
#define ZERO_OP 176
#define EXT_OP 192
#define ZEROMSK 15
#define ONEMSK 15
#define TWOMSK 31
#define EXTMSK 63
#define TWOMOD1 64
#define TWOMOD2 32
#define ONEMODE 48
#define STATBIT 16
#define SPLTBIT 32
#define OFF 0
#define ON 1
#define STEP 2
#define SKIPC 4
#define SKIPN 8
#define VERBOSE 16
#define BRKPT 32
#define SKIPS 0xF3
/* M A C R O S */
#define PRED(arg) ((arg) ? ppred(ZTRUE) : ppred(ZFALSE))
#define PUTV(arg) (putval(arg))
#define POPZ() (*zsp++)
#define PUSHZ(arg) (*--zsp = arg)
#define PUSH(arg) (*--ssp = arg)
#define POP() (*ssp++)
#define GTAWRD(offset) ((*(dataspace+offset) << 8) | (*(dataspace+offset+1) & 255))
#define GTABYT(offset) (*(dataspace + offset))
#define PTABYT(offset,value) (*(dataspace + offset) = value)
#define PTAWRD(offset,value) ((*(dataspace+offset) = (value >> 8)), (*(dataspace+offset+1) = (value & 255)))
#define GETLOC(var) (*(zstack + (zlocs - var)))
#define SETLOC(var, val) (*(zstack + (zlocs - var)) = val)
#define BYTARG(arg) ((ZOBJECT)(argblk[arg]))
#define RESET_CS tempcs = permcs
#define CHRS_PER_ZWORD 6
#define TOKEN_TBL_LEN 59
#define WORDS_LEFT (curoff <= numread)

3210
unix/zip.c Normal file

File diff suppressed because it is too large Load Diff

274
unix/zipdefs.h Normal file
View File

@@ -0,0 +1,274 @@
/************************************************************************
* *
* H E A D E R F I L E F O R C Z I P *
* *
************************************************************************/
typedef unsigned short int ZIPINT; /* FOR VIRTUAL ADDRESSES */
typedef unsigned char ZIPOBJ; /* FOR USE WITH OBJECTS (EZIP) */
typedef unsigned char ZIPBYT; /* for general unsigned bytes */
/***** HEADER INFORMATION OFFSETS *****/
#define PVERS1 0 /* ZVERSION BYTE */
#define PVERS2 1 /* ZVERSION MODE BYTE */
#define PZRKID 2 /* ZORK ID */
#define PENDLD 4 /* ENDLOD POINTER */
#define PSTART 6 /* Z ENTRY POINT */
#define PVOCTB 8 /* POINTER TO VOCABULARY TABLE */
#define POBJTB 10 /* POINTER TO OBJECT TABLE */
#define PGLOTB 12 /* POINTER TO GLOBAL TABLE */
#define PPURBT 14 /* POINTER TO BEGINNING OF PURE CODE */
#define PFLAGS 16 /* POINTER TO FLAGS */
#define PSERNM 18 /* 6 BYTE SERIAL NUMBER (DATE) */
#define PWRDTB 24 /* POINTER TO FWORD TABLE FOR PUTSTR */
#define PLENTH 26 /* LENGTH OF GAME IN WORDS */
#define PCHKSM 28 /* CHECKSUM OF ALL BYTES, EXCLUDING HEADER */
#define HDRSIZ 64 /* LENGTH OF HEADER IN BYTES */
/***** GENERAL DEFINITIONS *****/
#define ZMVERS 3 /* Z-MACHINE VERSION NUMBER */
#define LSTACK 512 /* VIRTUAL STACK SIZE [in words (?)] */
#define STKLEN 64 /* SYSTEM STACK SIZE [in longs (?)] */
#define BLKSIZ 512 /* SIZE OF VIRTUAL PAGES */
#define MAXBLKS 256 /* MAXIMUM GAME SIZE (EZIP is 512) */
#define ZTRUE 1
#define ZFALSE 0
#define MAXARGS 5 /* ZIL MAXIMUM ARGS (four plus count) */
#define SCRIPTBIT 1
#define STATBIT 16
#define SPLTBIT 32
#define THEN /* if <cond> THEN <exp>; else <exp>; */
#define NULL 0
#define G_HERE 16 /* ZIL status-line globals */
#define G_SCORE 17
#define G_MOVES 18
#define G_HOURS 17
#define G_MINS 18
/***** CHAR INPUT AND STRING OUTPUT *****/
#define NO_INPUT -1
#define Z_EOL 1
#define EOL 10 /* LINE FEED IS THE UNIX EOL */
#define ESC 27
#define FEEP "\007" /* BELL */
#define BKSPC 8 /* BACKSPACE */
#define PADCHR 5 /* PAD CHAR FOR ZSTRINGS */
#define SPACE '\040' /* INITIAL READ BREAD CHARS */
#define TAB '\011'
#define CR '\015'
#define FF '\014'
#define PERIOD '.'
#define COMMA ','
#define QMARK '?'
#define CHRS_PER_ZWORD 6
#define TOKEN_TBL_LEN 59
#define BYTEMODE 0
#define ZCHRLEN 5
#define ZCHRMSK 31
#define CSETLEN 26
#define NORMAL 0
#define REVERSE 1
/***** BUFFERING EQUATES *****/
#define IBUFSIZ 100
#define OBUFSIZ 100
#define CONSOLE 0
#define PIPE 1
#define PBUFSIZ 85
#define PIPEWIDTH 79
#define STATLEN 1 /* STATUS LINE ROWS */
#define RM 80 /* right margin */
#define LM 1 /* left margin */
/***** OBJECT AND PROPERTY DEFINITIONS *****/
#define FLAGS1 0 /* OFFSET TO FLAG WORDS */
#define FLAGS2 2
#define PARENT 4 /* PARENT OBJECT NUMBER */
#define SIBLING 5 /* SIBLING OJECT NUMBER */
#define CHILD 6 /* CHILD OBJECT NUMBER */
#define PROPS 7 /* POINTER TO PROPERTY TABLE */
#define OBJLEN 9 /* LENGTH OF AN OBJECT */
#define DPTLEN (31 * 2) /* DEFAULT PROP TABLE LENGTH, 31 ENTRIES */
#define PNUMSK 0x1F /* PROPERTY ID NUMBER MASK (LOW 5 BITS) */
#define PSZMSK 0xE0 /* PROPERTY SIZE MASK (HIGH 3 BITS) */
#define PROPSIZE 5 /* SHIFT COUNT TO ISOLATE SIZE BITS */
/***** PREDICATE AND VARIABLE DEFINITIONS *****/
#define LOCAL 16
#define EMPTY 0
#define BYTEMSK 255
#define BIT8 0x80
#define BIT16 0x8000
#define BACKWARD 128 /* bits to test */
#define JMPLNTH 64
#define PREDMSK 63
#define BIT14 0x2000 /* for testing 14 bit two's-complement */
#define COMP16 0xC000 /* for converting above to 16 bit */
/***** PAGING DEFINITIONS *****/
#define NOT_IN_CORE 0 /* a NULL pointer */
#define NO_PAGE -1 /* avoid conflict with page 0 */
#define BLOCKBITS 0x7F
#define BYTEBITS 0x1FF
#define CVTBLK 9
#define TO_K 10
/***** FILE I/O DEFINITIONS *****/
#define PATHSIZ 64
#define RDONLY 0
#define FMODE 0644 /* NEW FILE, set most bits */
/****** DEBUGGING DEFINITIONS ******/
#define OFF 0
#define ON 1
#define STEP 2
#define SKIPC 4
#define SKIPN 8
#define VERBOSE 16
#define BRKPT 32
#define SKIPS 0xF3
#define HEX 'x'
#define DEC 'd'
/***** MACROS *****/
#define PRED(arg) ((arg) ? ppred(ZTRUE) : ppred(ZFALSE))
#define PUTV(arg) (putval(arg))
#define PUSH(arg) (*--ssp = arg)
#define POP() (*ssp++)
#define PUSHZ(arg) (*--zsp = arg)
#define POPZ() (*zsp++)
#define BYTARG(arg) ((ZIPBYT)(argblk[arg]))
#define GETLOC(var) (*(zstack + (zlocs - var)))
#define SETLOC(var, val) (*(zstack + (zlocs - var)) = val)
#define GTABYT(ptr) (*(ptr)) /* ptr may be a compound */
#define GTVBYT(off) (*(dataspace + off))
#define PTABYT(ptr,value) (*(ptr) = value)
#define PTVBYT(off,value) (*(dataspace+off) = value)
/* MOVED INTO PROGRAM SUBROUTINES:
#define GTAWRD(ptr) ((((ZIPBYT) *ptr) << 8) | (ZIPBYT) *(ptr+1))
#define GTVWRD(off) ((((ZIPBYT) *(dataspace+off)) << 8) | (ZIPBYT) *(dataspace+off+1))
#define PTAWRD(ptr,value) ((*ptr = (value >> 8)), (*(ptr+1) = (value & 255)))
#define PTVWRD(off,value) ((*(dataspace+off) = (value >> 8)), (*(dataspace+off+1) = (value & 255)))
*/
/***** OPCODES *****/
#define ONE_OP 128
#define ZERO_OP 176
#define EXT_OP 192
#define ZEROMSK 15
#define ONEMSK 15
#define TWOMSK 31
#define EXTMSK 63
#define TWOMOD1 64
#define TWOMOD2 32
#define ONEMODE 48
/* ZERO OPS */
#define OPRTRU 176 /* RETURN TRUE */
#define OPRFAL 177 /* RETURN FALSE */
#define OPPRNI 178 /* PRINTI */
#define OPPRNR 179
#define OPNOOP 180
#define OPSAVE 181
#define OPREST 182
#define OPRSTT 183
#define OPRSTA 184
#define OPFSTA 185
#define OPQUIT 186
#define OPCRLF 187
#define OPUSL 188
#define OPVERI 189
/* ONE OPS */
#define OPQZER 128
#define OPQNEX 129
#define OPQFIR 130
#define OPLOC 131
#define OPPTSI 132
#define OPINC 133
#define OPDEC 134
#define OPPRNB 135
#define OPREMO 137
#define OPPRND 138
#define OPRETU 139
#define OPJUMP 140
#define OPPRIN 141
#define OPVALU 142
#define OPBCOM 143
/* TWO OPS AND EXTENDED OPS */
#define OPUNDF 0
#define OPQEQU 1
#define OPQLES 2
#define OPQGRT 3
#define OPQDLE 4
#define OPQIGR 5
#define OPQIN 6
#define OPBTST 7
#define OPBOR 8
#define OPBAND 9
#define OPQFSE 10
#define OPFSET 11
#define OPFCLE 12
#define OPSET 13
#define OPMOVE 14
#define OPGET 15
#define OPGETB 16
#define OPGETP 17
#define OPGTPT 18
#define OPNEXT 19
#define OPADD 20
#define OPSUB 21
#define OPMUL 22
#define OPDIV 23
#define OPMOD 24
#define LAST_TWO_OP OPMOD
#define XQEQU 193
#define OPCALL 224
#define OPPUT 225
#define OPPUTB 226
#define OPPUTP 227
#define OPREAD 228
#define OPPRNC 229
#define OPPRNN 230
#define OPRAND 231
#define OPPUSH 232
#define OPPOP 233
#define OPSPLT 234
#define OPSCRN 235