Skip to content

Commit 1681d16

Browse files
Add simple unrolled asm-scalars to support mode y heretic style + plus add linux build for easier testing and development
1 parent d74acd9 commit 1681d16

Some content is hidden

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

50 files changed

+1236
-437
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.vscode
2-
build
2+
build_dos
3+
build_linux

Makefile

Lines changed: 83 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,105 @@
1-
#CC := /home/gerben/djgpp/i586-pc-msdosdjgpp/bin/gcc
2-
#CFLAGS := -O2 -march=i386 -fomit-frame-pointer -Wno-attributes -Wpedantic -DAPPVER_EXEDEF=DM19F2
31
CC := gcc
4-
CFLAGS := -O2 -m32 -fomit-frame-pointer -Wno-attributes -Wpedantic -Wno-unused-result -DAPPVER_EXEDEF=DM19F2
5-
6-
DBGFLAGS := -g
2+
CXX := g++
3+
DBGFLAGS := -g -DRANGECHECK -fsanitize=address -fsanitize=undefined
4+
#EXTRAFLAGS = $(DBGFLAGS)
5+
EXTRAFLAGS = -O2 -fomit-frame-pointer
6+
CFLAGS := -m32 -Wno-attributes -Wno-unused-result -DAPPVER_EXEDEF=DM19F2 -fno-pic -no-pie $(EXTRAFLAGS)
77
COBJFLAGS := $(CFLAGS) -c
88
AS := nasm
99

1010
SRC_DIR := src
11-
BUILD_DIR := build
11+
DOS_BUILD_DIR := build_dos
12+
LINUX_BUILD_DIR := build_linux
13+
14+
define get-objects-from-dir
15+
$(patsubst $(1)/%.c,$(1)/%.o,$(wildcard $(1)/*.c)) \
16+
$(patsubst $(1)/%.asm,$(1)/%.o,$(wildcard $(1)/*.asm))
17+
endef
18+
19+
define src-to-build
20+
$(patsubst %,$(1)/%,$(2))
21+
endef
22+
23+
define _depend
24+
#!/bin/sh
25+
CC=$1
26+
DIR=$2
27+
shift 2
28+
case "$DIR" in
29+
"" | ".")
30+
$CC -MM -MG -c "$@" | sed -e 's@^\(.*\).o:@\\1.d \\1.o:@g'
31+
;;
32+
*)
33+
$CC -MM -MG -c "$@" | sed -e "s@^\(.*\).o:@$DIR\/\\1.d $DIR\/\\1.o:@g"
34+
;;
35+
esac
36+
endef
37+
export depend = $(value _depend)
38+
39+
# Z_ZONE_OBJ = $(SRC_DIR)/z_zone/z_zone_asan.o
40+
Z_ZONE_OBJ = $(SRC_DIR)/z_zone/z_zone.o
41+
42+
# Find all .o files
43+
DOOM_OBJS := $(call get-objects-from-dir,$(SRC_DIR)) $(Z_ZONE_OBJ)
44+
DOS_OBJS := $(call get-objects-from-dir,$(SRC_DIR)/dos)
45+
LINUX_OBJS := $(call get-objects-from-dir,$(SRC_DIR)/linux)
1246

47+
ALL_DOS_OBJS := $(call src-to-build, $(DOS_BUILD_DIR), $(DOOM_OBJS) $(DOS_OBJS))
48+
ALL_LINUX_OBJS := $(call src-to-build, $(LINUX_BUILD_DIR), $(DOOM_OBJS) $(LINUX_OBJS))
1349

14-
# Find all .c files
15-
ASS_SRC := $(wildcard $(SRC_DIR)/ass/*.c)
16-
ALL_C_FILES := $(wildcard $(SRC_DIR)/*.c)
17-
DOS_SRC := $(SRC_DIR)/i_ibm.c
18-
LINUX_SRC := $(SRC_DIR)/i_linux.c
19-
FILTER_SRC = $(LINUX_SRC) $(DOS_SRC)
20-
SRC := $(filter-out $(FILTER_SRC), $(ALL_C_FILES))
50+
.PRECIOUS: $(DOS_BUILD_DIR)/%.d $(LINUX_BUILD_DIR)/%.d %/depend.sh
2151

22-
OBJ := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRC)) $(BUILD_DIR)/planar.o
23-
ASS_OBJ := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(ASS_SRC)) $(BUILD_DIR)/ass/a_mv_mix.o
24-
DOS_OBJ := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(DOS_SRC))
52+
%/depend.sh: Makefile | %/depend.sh.dir
53+
@echo "$$depend" > $@
54+
@chmod +x $@
2555

26-
$(BUILD_DIR)/doom.exe: $(OBJ) $(DOS_OBJ) $(ASS_OBJ)
27-
$(CC) -o $@ $^ $(CFLAGS)
56+
define make-rules
57+
$(1)/%.d: %.c $(1)/depend.sh | $(1)/%.dir
58+
@$(1)/depend.sh $(CC) $$(@D) $(CFLAGS) $$< > $$@
2859

29-
$(BUILD_DIR)/linux-doom: $(OBJ) $(LINUX_SRC)
30-
$(CC) -o $@ $^ $(CFLAGS)
60+
$(1)/%.d: %.asm | $(1)/%.dir
61+
@touch $$@
3162

32-
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)/%.dir
33-
$(CC) $(COBJFLAGS) -o $@ $<
63+
$(1)/%.o: %.c $(1)/%.d
64+
@echo "Compiling $$<"
65+
@$(CC) $(COBJFLAGS) -o $$@ $$<
3466

35-
$(BUILD_DIR)/%.s: $(SRC_DIR)/%.c | $(BUILD_DIR)/%.dir
36-
$(CC) $(COBJFLAGS) -S -o $@ $<
67+
$(1)/%.o: %.cpp | $(1)/%.dir
68+
@$(CXX) $(COBJFLAGS) -o $$@ $$<
3769

38-
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.asm | $(BUILD_DIR)/%.dir
39-
$(AS) $< -f coff -o $@
70+
$(1)/%.s: %.c $(1)/%.d
71+
@$(CC) $(COBJFLAGS) -S -o $$@ $$<
72+
73+
$(1)/%.o: %.asm $(1)/%.d | $(1)/%.dir
74+
@$(AS) $$< $(2) -o $$@
75+
endef
76+
77+
$(eval $(call make-rules, $(DOS_BUILD_DIR), -f coff))
78+
$(eval $(call make-rules, $(LINUX_BUILD_DIR), -f elf))
4079

4180
%.dir:
42-
mkdir -p $(dir $@)
81+
@mkdir -p $(dir $@)
82+
83+
# Doom targets
84+
$(DOS_BUILD_DIR)/doom.exe: $(ALL_DOS_OBJS)
85+
$(CXX) -o $@ $^ $(CFLAGS)
86+
87+
$(LINUX_BUILD_DIR)/doom: $(ALL_LINUX_OBJS)
88+
$(CXX) -o $@ $^ $(CFLAGS) -lX11
4389

44-
# phony rules
45-
.PHONY: all
46-
all: $(BUILD_DIR)/doom.exe
4790

4891
.PHONY: debug
4992
debug: $(TARGET_DEBUG)
5093

5194
.PHONY: clean
5295
clean:
53-
@rm -rf $(BUILD_DIR)
54-
@rm -rf $(DBG_PATH)
96+
@rm -rf $(DOS_BUILD_DIR)
97+
@rm -rf $(LINUX_BUILD_DIR)
98+
99+
# Include dependency files
100+
# This will include the dependency files generated by the depend.sh script
101+
# and will ensure that any change to headers will force correct rebuilding.
102+
# The wildcard function will expand to all .d files in the build directories
103+
# are present, which prevents make from trying to generate .d files that
104+
# don't exist.
105+
-include $(wildcard $(ALL_DOS_OBJS:.o=.d) $(ALL_LINUX_OBJS:.o=.d))

src/ass/common.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/compiler.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ asm \
6868

6969
#define mkdir(x) mkdir(x,0)
7070

71-
//DJGPP doesn't inline inp, outp and outpw,
72-
//but it does inline inportb, outportb and outportw
73-
#define inp(port) 0
74-
#define outp(port,data)
75-
#define outpw(port,data)
76-
77-
#define __djgpp_conventional_base 0
78-
7971
static char* strupr(char* s)
8072
{
8173
char* tmp = s;

src/ass/dmx.h renamed to src/dmx.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#ifndef _DMX_H_
2020
#define _DMX_H_
2121

22-
#include "a_tsmapi.h"
23-
2422
void MUS_PauseSong(int32_t handle);
2523
void MUS_ResumeSong(int32_t handle);
2624
void MUS_SetMasterVolume(int32_t volume);

src/doomdata.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,11 @@ typedef struct
142142
typedef struct
143143
{
144144
char name[8];
145-
boolean masked;
145+
int16_t masked;
146+
int16_t masked2;
146147
int16_t width;
147148
int16_t height;
148-
void **columndirectory; // OBSOLETE
149+
char columndirectory[4]; // OBSOLETE
149150
int16_t patchcount;
150151
mappatch_t patches[1];
151152
} maptexture_t;

src/doomdef.h

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifndef __DOOMDEF__
2222
#define __DOOMDEF__
2323

24-
#include "ass/common.h"
24+
#include "id_heads.h"
2525

2626
// VERSIONS RESTORATION
2727
// This *must* be included (near) the beginning for every compilation unit
@@ -50,7 +50,7 @@
5050
// header generated by multigen utility
5151
#include "info.h"
5252

53-
extern byte *destview, *destscreen; // PC direct to screen pointers
53+
extern byte *destview, *destscreen, *screen; // PC direct to screen pointers
5454

5555
//
5656
// most key data are simple ascii (uppercased)
@@ -780,24 +780,10 @@ void *Z_Malloc (int32_t size, int32_t tag, void *ptr);
780780
void Z_Free (void *ptr);
781781
void Z_FreeTags (int32_t lowtag, int32_t hightag);
782782
void Z_CheckHeap (void);
783-
void Z_ChangeTag2 (void *ptr, int32_t tag);
783+
void Z_ChangeTag2 (void *ptr, int32_t tag, const char* file, int line);
784784

785785

786-
typedef struct memblock_s
787-
{
788-
int32_t size; // including the header and possibly tiny fragments
789-
void **user; // NULL if a free block
790-
int32_t tag; // purgelevel
791-
int32_t id; // should be ZONEID
792-
struct memblock_s *next, *prev;
793-
} memblock_t;
794-
795-
#define Z_ChangeTag(p,t) \
796-
{ \
797-
if (( (memblock_t *)( (byte *)(p) - sizeof(memblock_t)))->id!=0x1d4a11) \
798-
I_Error("Z_CT at "__FILE__":%i",__LINE__); \
799-
Z_ChangeTag2(p,t); \
800-
};
786+
#define Z_ChangeTag(p,t) Z_ChangeTag2(p,t, __FILE__, __LINE__)
801787

802788
//-------
803789
//WADFILE

src/ass/a_al_mid.c renamed to src/dos/a_al_mid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3232

3333
#include <conio.h>
3434
#include <dos.h>
35-
#include "common.h"
35+
#include "../id_heads.h"
3636
#include "a_al_mid.h"
3737
#include "a_ll_man.h"
3838

src/ass/a_al_mid.h renamed to src/dos/a_al_mid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2121
#ifndef __AL_MIDI_H
2222
#define __AL_MIDI_H
2323

24-
#include "common.h"
24+
#include "../id_heads.h"
2525

2626
void AL_Shutdown(void);
2727
void AL_Init(void);

src/ass/a_blast.c renamed to src/dos/a_blast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3333
#include <dos.h>
3434
#include <conio.h>
3535
#include <ctype.h>
36-
#include "common.h"
36+
#include "../id_heads.h"
3737
#include "a_blast.h"
3838
#include "a_dma.h"
3939

0 commit comments

Comments
 (0)