home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
D!Zone (Collector's Edition)
/
D_ZONE_CD.ISO
/
programs
/
editors
/
dmps_13a
/
dmps.c
next >
Wrap
C/C++ Source or Header
|
1994-12-06
|
24KB
|
769 lines
/*
DMPS: The Doom PostScript Map Generator, Version SWB 1.3a
---------------------------------------------------------
Original program for Unix and copyright (c) James Bonfield, March 3, 1994.
Modified for PC by Gerhard Karnik, March 29, 1994.
Extensive modifications & enhancements by Steve W Brewer, May 2, 1994.
Description
-----------
This program produces PostScript maps of Doom levels, extracted from the WAD
file.
Thick lines represent solid walls on the map.
Black circles represent objects. The letters inside represent what kind of
object it is.
White circles with arrows represent the enemy. The direction of the arrow is
the direction the creature is initially facing.
Grey lines represent secret areas.
Usage
-----
DMPS [options]
/D Enable debugging.
/W wadfile[.WAD] Wadfile to read from. (Default: DOOM.WAD)
/L level Level to draw. (Default: E1M1)
/S1 Draw things present at skills 1 & 2.
/S3 Draw things present at skill 3.
/S4 Draw things present at skills 4 & 5.
/MUL Draw things present in multiple player mode.
/NO Don't draw objects.
/NM Don't draw monsters.
/NS Don't draw player start positions.
/? Display command line options.
The PostScript will then be displayed to stdout.
Compiled using Borland C++ 3.1 using 'bcc -mh'
*/
#define L_MOD_JB "March 3, 1994"
#define L_MOD_GK "March 29, 1994"
#define L_MOD_SWB "May 2, 1994"
#define VERSION "SWB 1.3a"
#define LI_IMPASS 0x01 /* Linedef attribute bits */
#define LI_SECRET 0x20
#define TH_SKILL1 0x01 /* Thing type bits */
#define TH_SKILL2 0x01
#define TH_SKILL3 0x02
#define TH_SKILL4 0x04
#define TH_MULTI 0x10
#define PAPER_X (72 * 8.5) /* Paper width */
#define PAPER_Y (72 * 11 ) /* Paper height */
#define PAPER_BORDER (72 * 0.5) /* Paper margin */
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <share.h>
#include <fcntl.h>
#include <dos.h>
#include <alloc.h>
unsigned nread; /* throw away variable for _dos_read() */
typedef long int4;
typedef short int2;
struct wad_header {
int4 magic;
int4 dir_size;
int4 dir_off;
};
struct directory {
int4 start;
int4 length;
char name[8];
};
typedef
struct linedef_ {
int2 from_vertex;
int2 to_vertex;
int2 attrib;
int2 type;
int2 trigger;
int2 sidedef1;
int2 sidedef2;
}
linedef;
typedef
struct vertex_ {
int2 x;
int2 y;
}
vertex;
typedef
struct sidedef_ {
int2 x;
int2 y;
char wall_above[8];
char wall_below[8];
char wall_part[8];
int2 sector;
}
sidedef;
typedef
struct ssector_ {
int2 num;
int2 seg;
}
ssector;
typedef
struct sector_ {
int2 bot_pos;
int2 top_pos;
char bot_texture[8];
char top_texture[8];
int2 brightness;
int2 special;
int2 trigger;
}
sector;
typedef
struct thing_ {
int2 x;
int2 y;
int2 angle;
int2 type;
int2 attrib;
}
thing;
typedef int2 blockmap;
struct directory *open_wad(char *file, int *fd, long *size);
long get_index(struct directory *d, long size, char *name, long st);
linedef *read_linedefs(int fd, struct directory *d, long size, long start, long *num);
vertex *read_vertexes(int fd, struct directory *d, long size, long start, long *num);
blockmap *read_blockmap(int fd, struct directory *d, long size, long start, long *num);
sidedef *read_sidedefs(int fd, struct directory *d, long size, long start, long *num);
sector *read_sectors (int fd, struct directory *d, long size, long start, long *num);
thing *read_things (int fd, struct directory *d, long size, long start, long *num);
void doit(int fd, struct directory *dir, long size, char *wadfile, char *lev_name,
long objs, long mons, long strt, long lev1, long lev3, long lev4, long mult);
void dump_dir(struct directory *d, long size) {
int i;
for(i=0; i<size; i++) {
printf("Item=%5d, Start=%8ld, Len=%8ld, Name=%.8s\n", i, d[i].start, d[i].length, d[i].name);
}
}
int main(int argc, char **argv) {
struct directory *d;
int fd;
long size, c;
long objs = 1, mons = 1, strt = 1, lev1 = 0, lev3 = 0, lev4 = 0, mult = 0, dump = 0, help = 0;
char *level = "E1M1";
char *wadfile = "doom.wad";
int i;
for(i=1; i<=argc; i++) {
if(!strcmpi(argv[i], "/D") || !strcmpi(argv[i], "-D")) dump = 1;
if(!strcmpi(argv[i], "/W") || !strcmpi(argv[i], "-W")) wadfile = argv[(i++)+1];
if(!strcmpi(argv[i], "/L") || !strcmpi(argv[i], "-L")) level = strupr(argv[(i++)+1]);
if(!strcmpi(argv[i], "/S1") || !strcmpi(argv[i], "-S1")) lev1 = 1;
if(!strcmpi(argv[i], "/S3") || !strcmpi(argv[i], "-S3")) lev3 = 1;
if(!strcmpi(argv[i], "/S4") || !strcmpi(argv[i], "-S4")) lev4 = 1;
if(!strcmpi(argv[i], "/MUL") || !strcmpi(argv[i], "-MUL")) mult = 1;
if(!strcmpi(argv[i], "/NO") || !strcmpi(argv[i], "-NO")) objs = 0;
if(!strcmpi(argv[i], "/NM") || !strcmpi(argv[i], "-NM")) mons = 0;
if(!strcmpi(argv[i], "/NS") || !strcmpi(argv[i], "-NS")) strt = 0;
if(!strcmpi(argv[i], "/?") || !strcmpi(argv[i], "-?")) help = 1;
}
/*if (NULL == strchr(wadfile, 46)) strcat(wadfile, ".WAD");*/
if (help) {
fprintf(stderr, "\nDMPS: The Doom PostScript Map Generator, Version %s\n", VERSION);
fprintf(stderr, "---------------------------------------------------------\n");
fprintf(stderr, "Produces PostScript map of Doom level on stdout.\n\n");
fprintf(stderr, "DMPS [options]\n");
fprintf(stderr, "\n");
fprintf(stderr, " /W wadfile.WAD Wadfile to read from. (Default: DOOM.WAD)\n");
fprintf(stderr, " /L level Level to draw. (Default: E1M1)\n");
fprintf(stderr, " /S1 Draw things present at skills 1 & 2.\n");
fprintf(stderr, " /S3 Draw things present at skill 3.\n");
fprintf(stderr, " /S4 Draw things present at skills 4 & 5.\n");
fprintf(stderr, " /MUL Draw things present in multi-player mode.\n");
fprintf(stderr, " /NO Don't draw objects.\n");
fprintf(stderr, " /NM Don't draw monsters.\n");
fprintf(stderr, " /NS Don't draw player start positions.\n");
fprintf(stderr, " /? Display command-line options.\n\n");
fprintf(stderr, "Original program for Unix and copyright (c) James Bonfield, %s.\n", L_MOD_JB);
fprintf(stderr, "Modified for PC by Gerhard Karnik, %s.\n", L_MOD_GK);
fprintf(stderr, "Extensive modifications & enhancements by Steve W Brewer, %s.\n", L_MOD_SWB);
return 1;
}
if (NULL == (d = open_wad(wadfile, &fd, &size))) {
fprintf(stderr, "Type DMPS /? for help.\n");
return 1;
}
if(dump) {
dump_dir(d, size);
return 0;
}
doit(fd, d, size, wadfile, level, objs, mons, strt, lev1, lev3, lev4, mult);
return 0;
}
void doit(int fd, struct directory *dir, long size, char *wadfile, char *lev_name,
long objs, long mons, long strt, long lev1, long lev3, long lev4, long mult) {
linedef *linedefs;
vertex *vertexes;
blockmap *blocks;
sidedef *sidedefs;
sector *sectors;
thing *things;
long numline, numvert, numblock, numside, numsect, numthing;
long lev_index;
long xorigin, yorigin, xsize, ysize;
int2 sector;
double xscale, yscale, xscalelnd, yscalelnd, xscaleprt, yscaleprt;
long landscape = 0;
long found = 0;
long i, j;
char nametag[2];
/* find level index */
lev_index = get_index(dir, size, lev_name, 0);
if(lev_index == -1) {
fprintf(stderr, "Unknown level: %s\n", lev_name);
exit(1);
}