Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed 32, 64 bit builds of both linuxxdoom and sndserv for those disappointed by lack of OOTB support #21

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# DOOM (Fixed)

I was excited to discover that the original DOOM source code was open on GitHub. Unfortunately, when I tried to clone and build it for myself, it did not work OOTB. This fork/repo contains a collection of fixes that I had to apply to get it working on my computer. The goal is that others will stumble across this repo and be able to build the source code for themselves without error.

## Requirements

_Note_: Provided commands were tested on Linux Mint Victoria 21.2.

- Linux
- Git (`sudo apt install git`)
- xserver-xephyr (`sudo apt-get install xserver-xephyr`)

### 64-bit

- libc6-dev (`sudo apt-get install libc6-dev`)
- libx11-dev (`sudo apt-get install libx11-dev`)
- libxext-dev (`sudo apt-get install libxext-dev`)

### 32-bit

- libc6-dev:i386 (`sudo apt-get install libc6-dev:i386`)
- libx11-dev:i386 (`sudo apt-get install libx11-dev:i386`)
- libxext-dev:i386 (`sudo apt-get install libxext-dev:i386`)

## Build and Run

```bash
$ git clone https://github.com/lunkums/DOOM_fixed.git # clone the repo
$ cd DOOM_fixed/linuxdoom-1.10 # navigate to the linuxdoom-1.10 folder
$ make # 64-bit build
$ make x86 # 32-bit build
$ cd linux/ # navigate to the output directory
$ curl -O https://distro.ibiblio.org/slitaz/sources/packages/d/doom1.wad # download the shareware wad
...
# in a separate terminal, run:
$ Xephyr :2 -ac -screen 320x200x8 # start an X server with Xephyr
...
# back in the first terminal, run:
$ DISPLAY=:2 # set the `DISPLAY` environment variable to be `:2`
$ ./linuxxdoom # LGTM
```

### Sound

See the [sndserv README](./sndserv/README.md) for instructions on setting up the game's sound.

### Music

Unfortunately, Linux DOOM does not support music due to a licensing issue with the [DMX](https://doomwiki.org/wiki/DMX) sound library used in the original release. Reimplementing it is out of the scope of this fork.

## Additional Info

- [Linux DOOM FAQ](https://hexadecimal.uoregon.edu/~stevev/Linux-DOOM-FAQ.html)
- [How To Compile Vanilla Doom (Linux Doom)](https://www.youtube.com/watch?v=9JgQfQHHhTw)
9 changes: 7 additions & 2 deletions linuxdoom-1.10/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,18 @@ OBJS= \
$(O)/info.o \
$(O)/sounds.o

all: $(O)/linuxxdoom
TARGET := $(O)/linuxxdoom

all: $(TARGET)

x86: CFLAGS += -m32
x86: $(TARGET)

clean:
rm -f *.o *~ *.flc
rm -f linux/*

$(O)/linuxxdoom: $(OBJS) $(O)/i_main.o
$(TARGET): $(OBJS) $(O)/i_main.o
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(O)/i_main.o \
-o $(O)/linuxxdoom $(LIBS)

Expand Down
7 changes: 4 additions & 3 deletions linuxdoom-1.10/i_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
static const char
rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $";

#include <errno.h>

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
Expand Down Expand Up @@ -62,7 +64,7 @@ rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $";
#ifdef SNDSERV
// Separate sound server process.
FILE* sndserver=0;
char* sndserver_filename = "./sndserver ";
char* sndserver_filename = "sndserver";
#elif SNDINTR

// Update all 30 millisecs, approx. 30fps synchronized.
Expand Down Expand Up @@ -163,7 +165,6 @@ myioctl
int* arg )
{
int rc;
extern int errno;

rc = ioctl(fd, command, arg);
if (rc < 0)
Expand Down Expand Up @@ -745,7 +746,7 @@ I_InitSound()
getenv("DOOMWADDIR"),
sndserver_filename);
else
sprintf(buffer, "%s", sndserver_filename);
sprintf(buffer, "./%s", sndserver_filename);

// start sound process
if ( !access(buffer, X_OK) )
Expand Down
4 changes: 2 additions & 2 deletions linuxdoom-1.10/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int XShmGetEventBase( Display* dpy ); // problems with g++?
#include <sys/socket.h>

#include <netinet/in.h>
#include <errnos.h>
#include <errno.h>
#include <signal.h>

#include "doomstat.h"
Expand Down Expand Up @@ -666,7 +666,6 @@ void grabsharedmemory(int size)
id = shmget((key_t)key, size, IPC_CREAT|0777);
if (id==-1)
{
extern int errno;
fprintf(stderr, "errno=%d\n", errno);
I_Error("Could not get any shared memory");
}
Expand Down Expand Up @@ -817,6 +816,7 @@ void I_InitGraphics(void)
attribmask,
&attribs );

XInstallColormap( X_display, X_cmap );
XDefineCursor(X_display, X_mainWindow,
createnullcursor( X_display, X_mainWindow ) );

Expand Down
2 changes: 2 additions & 0 deletions linuxdoom-1.10/linux/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
28 changes: 14 additions & 14 deletions linuxdoom-1.10/m_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ typedef struct
{
char* name;
int* location;
int defaultvalue;
void* defaultvalue;
int scantranslate; // PC scan code hack
int untranslated; // lousy hack
} default_t;
Expand Down Expand Up @@ -254,15 +254,15 @@ default_t defaults[] =

// UNIX hack, to be removed.
#ifdef SNDSERV
{"sndserver", (int *) &sndserver_filename, (int) "sndserver"},
{"sndserver", (int *) &sndserver_filename, (void*) "sndserver"},
{"mb_used", &mb_used, 2},
#endif

#endif

#ifdef LINUX
{"mousedev", (int*)&mousedev, (int)"/dev/ttyS0"},
{"mousetype", (int*)&mousetype, (int)"microsoft"},
{"mousedev", (int*)&mousedev, (void*)"/dev/ttyS0"},
{"mousetype", (int*)&mousetype, (void*)"microsoft"},
#endif

{"use_mouse",&usemouse, 1},
Expand All @@ -285,16 +285,16 @@ default_t defaults[] =

{"usegamma",&usegamma, 0},

{"chatmacro0", (int *) &chat_macros[0], (int) HUSTR_CHATMACRO0 },
{"chatmacro1", (int *) &chat_macros[1], (int) HUSTR_CHATMACRO1 },
{"chatmacro2", (int *) &chat_macros[2], (int) HUSTR_CHATMACRO2 },
{"chatmacro3", (int *) &chat_macros[3], (int) HUSTR_CHATMACRO3 },
{"chatmacro4", (int *) &chat_macros[4], (int) HUSTR_CHATMACRO4 },
{"chatmacro5", (int *) &chat_macros[5], (int) HUSTR_CHATMACRO5 },
{"chatmacro6", (int *) &chat_macros[6], (int) HUSTR_CHATMACRO6 },
{"chatmacro7", (int *) &chat_macros[7], (int) HUSTR_CHATMACRO7 },
{"chatmacro8", (int *) &chat_macros[8], (int) HUSTR_CHATMACRO8 },
{"chatmacro9", (int *) &chat_macros[9], (int) HUSTR_CHATMACRO9 }
{"chatmacro0", (int *) &chat_macros[0], (void*) HUSTR_CHATMACRO0 },
{"chatmacro1", (int *) &chat_macros[1], (void*) HUSTR_CHATMACRO1 },
{"chatmacro2", (int *) &chat_macros[2], (void*) HUSTR_CHATMACRO2 },
{"chatmacro3", (int *) &chat_macros[3], (void*) HUSTR_CHATMACRO3 },
{"chatmacro4", (int *) &chat_macros[4], (void*) HUSTR_CHATMACRO4 },
{"chatmacro5", (int *) &chat_macros[5], (void*) HUSTR_CHATMACRO5 },
{"chatmacro6", (int *) &chat_macros[6], (void*) HUSTR_CHATMACRO6 },
{"chatmacro7", (int *) &chat_macros[7], (void*) HUSTR_CHATMACRO7 },
{"chatmacro8", (int *) &chat_macros[8], (void*) HUSTR_CHATMACRO8 },
{"chatmacro9", (int *) &chat_macros[9], (void*) HUSTR_CHATMACRO9 }

};

Expand Down
2 changes: 1 addition & 1 deletion linuxdoom-1.10/p_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ void P_GroupLines (void)
}

// build line tables for each sector
linebuffer = Z_Malloc (total*4, PU_LEVEL, 0);
linebuffer = Z_Malloc (total*sizeof(*linebuffer), PU_LEVEL, 0);
sector = sectors;
for (i=0 ; i<numsectors ; i++, sector++)
{
Expand Down
14 changes: 8 additions & 6 deletions linuxdoom-1.10/r_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
static const char
rcsid[] = "$Id: r_data.c,v 1.4 1997/02/03 16:47:55 b1 Exp $";

#include <stdint.h>

#include "i_system.h"
#include "z_zone.h"

Expand Down Expand Up @@ -87,7 +89,7 @@ typedef struct
boolean masked;
short width;
short height;
void **columndirectory; // OBSOLETE
int columndirectory; // OBSOLETE
short patchcount;
mappatch_t patches[1];
} maptexture_t;
Expand Down Expand Up @@ -479,10 +481,10 @@ void R_InitTextures (void)
}
numtextures = numtextures1 + numtextures2;

textures = Z_Malloc (numtextures*4, PU_STATIC, 0);
texturecolumnlump = Z_Malloc (numtextures*4, PU_STATIC, 0);
texturecolumnofs = Z_Malloc (numtextures*4, PU_STATIC, 0);
texturecomposite = Z_Malloc (numtextures*4, PU_STATIC, 0);
textures = Z_Malloc (numtextures*sizeof(*textures), PU_STATIC, 0);
texturecolumnlump = Z_Malloc (numtextures*sizeof(*texturecolumnlump), PU_STATIC, 0);
texturecolumnofs = Z_Malloc (numtextures*sizeof(*texturecolumnofs), PU_STATIC, 0);
texturecomposite = Z_Malloc (numtextures*sizeof(*texturecomposite), PU_STATIC, 0);
texturecompositesize = Z_Malloc (numtextures*4, PU_STATIC, 0);
texturewidthmask = Z_Malloc (numtextures*4, PU_STATIC, 0);
textureheight = Z_Malloc (numtextures*4, PU_STATIC, 0);
Expand Down Expand Up @@ -639,7 +641,7 @@ void R_InitColormaps (void)
lump = W_GetNumForName("COLORMAP");
length = W_LumpLength (lump) + 255;
colormaps = Z_Malloc (length, PU_STATIC, 0);
colormaps = (byte *)( ((int)colormaps + 255)&~0xff);
colormaps = (byte *)( ((intptr_t)colormaps + 255)&~0xff);
W_ReadLump (lump,colormaps);
}

Expand Down
3 changes: 2 additions & 1 deletion linuxdoom-1.10/r_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
static const char
rcsid[] = "$Id: r_draw.c,v 1.4 1997/02/03 16:47:55 b1 Exp $";

#include <stdint.h>

#include "doomdef.h"

Expand Down Expand Up @@ -461,7 +462,7 @@ void R_InitTranslationTables (void)
int i;

translationtables = Z_Malloc (256*3+255, PU_STATIC, 0);
translationtables = (byte *)(( (int)translationtables + 255 )& ~255);
translationtables = (byte *)(( (intptr_t)translationtables + 255 )& ~255);

// translate just the 16 green colors
for (i=0 ; i<256 ; i++)
Expand Down
7 changes: 6 additions & 1 deletion sndserv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ LIBS=-lm

O=linux

all: $(O)/sndserver
TARGET := $(O)/sndserver

all: $(TARGET)

x86: CFLAGS += -m32
x86: $(TARGET)

clean:
rm -f *.o *~ *.flc
Expand Down
25 changes: 25 additions & 0 deletions sndserv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# sndserv (Sound Server)

Linux DOOM plays sounds from a separate process called sndserv (sound server).

## Requirements

_Note_: Provided commands were tested on Linux Mint Victoria 21.2.

- Linux
- OSS Proxy Daemon (`sudo apt-get install osspd`)

## Build and Run

```bash
$ cd DOOM_fixed/sndserv # navigate to the `sndserv` directory
$ make # 64-bit build
$ make x86 # 32-bit build
$ cp ./linux/sndserver ../linuxdoom-1.10/linux/ # copy sndserver to the linuxdoom output directory
```

## Additional Info

- [How exactly did the linuxdoom sndserver used to work?](https://www.doomworld.com/forum/post/2544842) ([archive](https://web.archive.org/web/20231004233042/https://www.doomworld.com/forum/topic/131304-how-exactly-did-the-linuxdoom-sndserver-used-to-work/?tab=comments#comment-2544842))
- [Where is /dev/dsp or /dev/audio?](https://askubuntu.com/questions/220370/where-is-dev-dsp-or-dev-audio?rq=1) ([archive](https://web.archive.org/web/20231004233215/https://askubuntu.com/questions/220370/where-is-dev-dsp-or-dev-audio?rq=1))
- [Package: osspd (1.3.2-13.1)](https://packages.debian.org/sid/osspd) ([archive](https://web.archive.org/web/20231004234639/https://packages.debian.org/sid/osspd))
2 changes: 1 addition & 1 deletion sndserv/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

static const char rcsid[] = "$Id: linux.c,v 1.3 1997/01/26 07:45:01 b1 Exp $";

#include <errno.h>

#include <stdlib.h>
#include <stdio.h>
Expand All @@ -53,7 +54,6 @@ myioctl
int* arg )
{
int rc;
extern int errno;

rc = ioctl(fd, command, arg);
if (rc < 0)
Expand Down
2 changes: 2 additions & 0 deletions sndserv/linux/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore