Skip to content

Commit 797c290

Browse files
authored
Merge pull request #17 from JeroenoBoy/main
feat(DOOM): Make it run DOOM
2 parents 36cda20 + 4c5c332 commit 797c290

165 files changed

Lines changed: 61896 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DOOM/LICENSE.TXT

Lines changed: 340 additions & 0 deletions
Large diffs are not rendered by default.

DOOM/README.TXT

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
Here it is, at long last. The DOOM source code is released for your
3+
non-profit use. You still need real DOOM data to work with this code.
4+
If you don't actually own a real copy of one of the DOOMs, you should
5+
still be able to find them at software stores.
6+
7+
Many thanks to Bernd Kreimeier for taking the time to clean up the
8+
project and make sure that it actually works. Projects tends to rot if
9+
you leave it alone for a few years, and it takes effort for someone to
10+
deal with it again.
11+
12+
The bad news: this code only compiles and runs on linux. We couldn't
13+
release the dos code because of a copyrighted sound library we used
14+
(wow, was that a mistake -- I write my own sound code now), and I
15+
honestly don't even know what happened to the port that microsoft did
16+
to windows.
17+
18+
Still, the code is quite portable, and it should be straightforward to
19+
bring it up on just about any platform.
20+
21+
I wrote this code a long, long time ago, and there are plenty of things
22+
that seem downright silly in retrospect (using polar coordinates for
23+
clipping comes to mind), but overall it should still be a usefull base
24+
to experiment and build on.
25+
26+
The basic rendering concept -- horizontal and vertical lines of constant
27+
Z with fixed light shading per band was dead-on, but the implementation
28+
could be improved dramatically from the original code if it were
29+
revisited. The way the rendering proceded from walls to floors to
30+
sprites could be collapsed into a single front-to-back walk of the bsp
31+
tree to collect information, then draw all the contents of a subsector
32+
on the way back up the tree. It requires treating floors and ceilings
33+
as polygons, rather than just the gaps between walls, and it requires
34+
clipping sprite billboards into subsector fragments, but it would be
35+
The Right Thing.
36+
37+
The movement and line of sight checking against the lines is one of the
38+
bigger misses that I look back on. It is messy code that had some
39+
failure cases, and there was a vastly simpler (and faster) solution
40+
sitting in front of my face. I used the BSP tree for rendering things,
41+
but I didn't realize at the time that it could also be used for
42+
environment testing. Replacing the line of sight test with a bsp line
43+
clip would be pretty easy. Sweeping volumes for movement gets a bit
44+
tougher, and touches on many of the challenges faced in quake / quake2
45+
with edge bevels on polyhedrons.
46+
47+
Some project ideas:
48+
49+
Port it to your favorite operating system.
50+
51+
Add some rendering features -- transparency, look up / down, slopes,
52+
etc.
53+
54+
Add some game features -- weapons, jumping, ducking, flying, etc.
55+
56+
Create a packet server based internet game.
57+
58+
Create a client / server based internet game.
59+
60+
Do a 3D accelerated version. On modern hardware (fast pentium + 3DFX)
61+
you probably wouldn't even need to be clever -- you could just draw the
62+
entire level and get reasonable speed. With a touch of effort, it should
63+
easily lock at 60 fps (well, there are some issues with DOOM's 35 hz
64+
timebase...). The biggest issues would probably be the non-power of two
65+
texture sizes and the walls composed of multiple textures.
66+
67+
68+
I don't have a real good guess at how many people are going to be
69+
playing with this, but if significant projects are undertaken, it would
70+
be cool to see a level of community cooperation. I know that most early
71+
projects are going to be rough hacks done in isolation, but I would be
72+
very pleased to see a coordinated 'net release of an improved, backwards
73+
compatable version of DOOM on multiple platforms next year.
74+
75+
Have fun.
76+
77+
John Carmack
78+
12-23-97
79+
80+
Copyright (c) ZeniMax Media Inc.
81+
Licensed under the GNU General Public License 2.0.

DOOM/ipx/DOOMNET.C

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//#define DOOM2
2+
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <string.h>
6+
#include <process.h>
7+
#include <conio.h>
8+
#include <dos.h>
9+
10+
#include "doomnet.h"
11+
//#include "ipxstr.h"
12+
#include "ipx_frch.h" // FRENCH VERSION
13+
14+
doomcom_t doomcom;
15+
int vectorishooked;
16+
void interrupt (*olddoomvect) (void);
17+
18+
19+
20+
/*
21+
=============
22+
=
23+
= LaunchDOOM
24+
=
25+
These fields in doomcom should be filled in before calling:
26+
27+
short numnodes; // console is allways node 0
28+
short ticdup; // 1 = no duplication, 2-5 = dup for
29+
slow nets
30+
short extratics; // 1 = send a backup tic in every
31+
packet
32+
33+
short consoleplayer; // 0-3 = player number
34+
short numplayers; // 1-4
35+
short angleoffset; // 1 = left, 0 = center, -1 = right
36+
short drone; // 1 = drone
37+
=============
38+
*/
39+
40+
void LaunchDOOM (void)
41+
{
42+
char *newargs[99];
43+
char adrstring[10];
44+
long flatadr;
45+
46+
// prepare for DOOM
47+
doomcom.id = DOOMCOM_ID;
48+
49+
// hook the interrupt vector
50+
olddoomvect = getvect (doomcom.intnum);
51+
setvect (doomcom.intnum,(void interrupt (*)(void))MK_FP(_CS,
52+
(int)NetISR));
53+
vectorishooked = 1;
54+
55+
// build the argument list for DOOM, adding a -net &doomcom
56+
memcpy (newargs, _argv, (_argc+1)*2);
57+
newargs[_argc] = "-net";
58+
flatadr = (long)_DS*16 + (unsigned)&doomcom;
59+
sprintf (adrstring,"%lu",flatadr);
60+
newargs[_argc+1] = adrstring;
61+
newargs[_argc+2] = NULL;
62+
63+
if (!access("doom2.exe",0))
64+
spawnv (P_WAIT, "doom2", newargs);
65+
else
66+
spawnv (P_WAIT, "doom", newargs);
67+
68+
#ifdef DOOM2
69+
printf (STR_RETURNED"\n");
70+
#else
71+
printf ("Returned from DOOM\n");
72+
#endif
73+
}

DOOM/ipx/DOOMNET.H

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// doomnet.h
2+
3+
#define PEL_WRITE_ADR 0x3c8
4+
#define PEL_DATA 0x3c9
5+
6+
#define I_ColorBlack(r,g,b) {outp(PEL_WRITE_ADR,0);outp(PEL_DATA,r);outp(PEL_DATA,g);outp(PEL_DATA,b);};
7+
8+
9+
10+
#define MAXNETNODES 8 // max computers in a game
11+
#define MAXPLAYERS 4 // 4 players max + drones
12+
13+
14+
#define CMD_SEND 1
15+
#define CMD_GET 2
16+
17+
#define DOOMCOM_ID 0x12345678l
18+
19+
typedef struct
20+
{
21+
long id;
22+
short intnum; // DOOM executes an int to send commands
23+
24+
// communication between DOOM and the driver
25+
short command; // CMD_SEND or CMD_GET
26+
short remotenode; // dest for send, set by get (-1 = no packet)
27+
short datalength; // bytes in doomdata to be sent / bytes read
28+
29+
// info common to all nodes
30+
short numnodes; // console is allways node 0
31+
short ticdup; // 1 = no duplication, 2-5 = dup for slow nets
32+
short extratics; // 1 = send a backup tic in every packet
33+
short deathmatch; // 1 = deathmatch
34+
short savegame; // -1 = new game, 0-5 = load savegame
35+
short episode; // 1-3
36+
short map; // 1-9
37+
short skill; // 1-5
38+
39+
// info specific to this node
40+
short consoleplayer; // 0-3 = player number
41+
short numplayers; // 1-4
42+
short angleoffset; // 1 = left, 0 = center, -1 = right
43+
short drone; // 1 = drone
44+
45+
// packet data to be sent
46+
char data[512];
47+
} doomcom_t;
48+
49+
50+
51+
extern doomcom_t doomcom;
52+
extern void interrupt (*olddoomvect) (void);
53+
extern int vectorishooked;
54+
55+
int CheckParm (char *check);
56+
void LaunchDOOM (void);
57+
void interrupt NetISR (void);
58+

0 commit comments

Comments
 (0)