diff --git a/.gitignore b/.gitignore index e25135aa4..c883b7cbb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ build/ *.lmp *.png *.exe +*.config +*.swp diff --git a/Makefile b/Makefile index b607f0fcd..caa00c49b 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,63 @@ # # $Log:$ # + +OSFLAG:= +ifeq ($(OS),Windows_NT) + RM = del /Q /F + OSFLAG += -D WIN32 + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) + OSFLAG += -D AMD64 + endif + ifeq ($(PROCESSOR_ARCHITECTURE),x86) + OSFLAG += -D IA32 + endif +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) + OSFLAG += -D LINUX + endif + ifeq ($(UNAME_S),Darwin) + OSFLAG += -D OSX + endif + UNAME_P := $(shell uname -p) + ifeq ($(UNAME_P),x86_64) + OSFLAG += -D AMD64 + endif + ifneq ($(filter %86,$(UNAME_P)),) + OSFLAG += -D IA32 + endif + ifneq ($(filter arm%,$(UNAME_P)),) + OSFLAG += -D ARM + endif +endif + CC=gcc # gcc or g++ -RAYLIB_PATH=C:/raylib -RAYLIB_LIB=$(RAYLIB_PATH)/MinGW/i686-w64-mingw32/lib -CFLAGS=-g #-g -DNORMALUNIX -DLINUX # -DUSEASM -LDFLAGS=-I$(RAYLIB_PATH)/raylib/src -L$(RAYLIB_PATH)/MinGW/i686-w64-mingw32/lib -LIBS=-lraylib -lopengl32 -lgdi32 -lwinmm + + +RAYLIB_PATH:= +RAYLIB_INCLUDE:= +RAYLIB_LIB:= +ifeq ($(OS),Windows_NT) + RAYLIB_PATH=C:/raylib + RAYLIB_INCLUDE=$(RAYLIB_PATH)/raylib/src + RAYLIB_LIB=$(RAYLIB_PATH)/MinGW/i686-w64-mingw32/lib +else + ifeq ($(UNAME_S),Darwin) + RAYLIB_PATH=/usr/local/var/homebrew/linked/raylib + RAYLIB_INCLUDE=$(RAYLIB_PATH)/include + RAYLIB_LIB=$(RAYLIB_PATH)/lib + else + $(error unknown raylib path) + endif +endif + +CFLAGS=-g $(OSFLAG) # -DNORMALUNIX +LDFLAGS=-I$(RAYLIB_INCLUDE) -L$(RAYLIB_LIB) +LIBS=-lraylib +ifeq ($(OS),Windows_NT) + LIBS += -lopengl32 -lgdi32 -lwinmm +endif # subdirectory for objects SRC=src @@ -82,7 +133,12 @@ OBJS= \ all: $(O)/doom clean: - del *.o *.exe /s + ifeq ($(OS),Windows_NT) + -$(RM) $(O)\*.o /s + else + $(rm -f *.o) + $(rm -f $(O)/*.o) + endif $(O)/doom: $(OBJS) $(O)/i_main.o $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(O)/i_main.o \ @@ -93,4 +149,4 @@ $(O)/%.o: $(SRC)/%.c ############################################################# # -############################################################# \ No newline at end of file +############################################################# diff --git a/run.sh b/run.sh new file mode 100755 index 000000000..33394c645 --- /dev/null +++ b/run.sh @@ -0,0 +1,34 @@ +#!/bin/bash + + +wad_file="DOOM.WAD" +expected_md5="c4fe9fd920207691a9f493668e0a2083" +if [[ ! -f "$wad_file" ]];then + wget "https://archive.org/download/The_Ultimate_Doom/The_Ultimate_Doom.zip" 2>/dev/null; + downloaded_zip="The_Ultimate_Doom.zip"; + if [[ ! -f "$downloaded_zip" ]];then + echo "Could not find downloaded zip file."; + fi + unzipped_other=$(yes | unzip "$downloaded_zip" 2>/dev/null |grep -i 'inflating:' | cut -d : -f 2 | grep -v "$wad_file"); + rm -f "DOOM.EXE"; + download_md5=$(md5 -q "$wad_file"); + rm -f "$downloaded_zip"; + if [[ "$expected_md5" != "$download_md5" ]]; then + rm -f "$wad_file"; + echo "Downloaded wad file does not match expected md5 hash"; + fi +fi + +doom_exe="./build/doom"; +if [[ ! -f "$doom_exe" ]];then + yes | rm -f ./build/*.o 2>/dev/null + mkdir -p ./build + make +fi + +if [[ ! -f "$doom_exe" ]];then + echo "Could not find doom executable ${doom_exe}."; +else + ${doom_exe} -config ./doom.config +fi + diff --git a/src/am_map.c b/src/am_map.c index 999e4558d..51719facf 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -783,7 +783,7 @@ void AM_doFollowPlayer(void) // void AM_updateLightLev(void) { - static nexttic = 0; + static int nexttic = 0; //static int litelevels[] = { 0, 3, 5, 6, 6, 7, 7, 7 }; static int litelevels[] = { 0, 4, 7, 10, 12, 14, 15, 15 }; static int litelevelscnt = 0; @@ -856,9 +856,9 @@ AM_clipMline TOP =8 }; - register outcode1 = 0; - register outcode2 = 0; - register outside; + register int outcode1 = 0; + register int outcode2 = 0; + register int outside; fpoint_t tmp; int dx; @@ -989,7 +989,7 @@ AM_drawFline register int ay; register int d; - static fuck = 0; + static int fuck = 0; // For debugging only if ( fl->a.x < 0 || fl->a.x >= f_w diff --git a/src/d_main.c b/src/d_main.c index 4467d927f..d07b4a79d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -31,7 +31,7 @@ static const char rcsid[] = "$Id: d_main.c,v 1.8 1997/02/03 22:45:09 b1 Exp $"; #define FGCOLOR 8 #define R_OK 0 -#ifdef NORMALUNIX +#if defined(LINUX) || defined(OSX) #include #include #include @@ -40,7 +40,11 @@ static const char rcsid[] = "$Id: d_main.c,v 1.8 1997/02/03 22:45:09 b1 Exp $"; #include #endif +#ifdef OSX +#include +#else #include +#endif #include "doomdef.h" @@ -152,7 +156,7 @@ int eventtail; void D_PostEvent (event_t* ev) { events[eventhead] = *ev; - eventhead = (++eventhead)&(MAXEVENTS-1); + eventhead = (1+eventhead)&(MAXEVENTS-1); } @@ -169,7 +173,7 @@ void D_ProcessEvents (void) && (W_CheckNumForName("map01")<0) ) return; - for ( ; eventtail != eventhead ; eventtail = (++eventtail)&(MAXEVENTS-1) ) + for ( ; eventtail != eventhead ; eventtail = (1+eventtail)&(MAXEVENTS-1) ) { ev = &events[eventtail]; if (M_Responder (ev)) diff --git a/src/d_net.c b/src/d_net.c index 75b5436e1..16eb6d664 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -103,7 +103,7 @@ unsigned NetbufferChecksum (void) c = 0x1234567; // FIXME -endianess? -#ifdef NORMALUNIX +#if defined(LINUX) || defined(OSX) return 0; // byte order problems #endif diff --git a/src/i_net.c b/src/i_net.c index a2223964e..74004392e 100644 --- a/src/i_net.c +++ b/src/i_net.c @@ -52,18 +52,27 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $"; // For some odd reason... +#ifndef ntohl #define ntohl(x) \ ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \ (((unsigned long int)(x) & 0x0000ff00U) << 8) | \ (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \ (((unsigned long int)(x) & 0xff000000U) >> 24))) +#endif +#ifndef ntohs #define ntohs(x) \ ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \ - (((unsigned short int)(x) & 0xff00) >> 8))) \ + (((unsigned short int)(x) & 0xff00) >> 8))) +#endif +#ifndef htonl #define htonl(x) ntohl(x) +#endif + +#ifndef htons #define htons(x) ntohs(x) +#endif void NetSend (void); boolean NetListen (void); diff --git a/src/p_spec.c b/src/p_spec.c index f048afb10..ef24f51f2 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1184,7 +1184,7 @@ int EV_DoDonut(line_t* line) s2 = getNextSector(s1->lines[0],s1); for (i = 0;i < s2->linecount;i++) { - if ((!s2->lines[i]->flags & ML_TWOSIDED) || + if (!(s2->lines[i]->flags & ML_TWOSIDED) || (s2->lines[i]->backsector == s1)) continue; s3 = s2->lines[i]->backsector; diff --git a/src/tables.h b/src/tables.h index 060fe5b35..a0bcedd28 100644 --- a/src/tables.h +++ b/src/tables.h @@ -41,8 +41,10 @@ #ifdef LINUX #include #else +#ifndef PI #define PI 3.141592657 #endif +#endif #include "m_fixed.h" diff --git a/src/w_wad.c b/src/w_wad.c index c964252ec..dc2e9c062 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -28,17 +28,25 @@ rcsid[] = "$Id: w_wad.c,v 1.5 1997/02/03 16:47:57 b1 Exp $"; #include #include -#ifdef NORMALUNIX +#if defined(LINUX) || defined(OSX) #include #include #include #include -#include #include #include +#include + +#ifdef LINUX +#include +#endif + +#ifndef O_BINARY #define O_BINARY 0 #endif +#endif + #include "doomtype.h" #include "m_swap.h" #include "i_system.h" @@ -67,10 +75,12 @@ void** lumpcache; #define strcmpi strcasecmp -// void strupr (char* s) -// { -// while (*s) { *s = toupper(*s); s++; } -// } +#ifdef OSX +void strupr (char* s) +{ + while (*s) { *s = toupper(*s); s++; } +} +#endif int file_length (int handle) {