Skip to content

Commit 3838c10

Browse files
committed
some makefile refactoring to allow incremental builds
1 parent b830552 commit 3838c10

30 files changed

+240
-56
lines changed

build/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ fi
485485
cd ..
486486

487487
echo make -f build/Makefile $CORES "$@" all
488-
make -f build/Makefile $CORES "$@" all
488+
USE_PRECOMPILED=yep make -f build/Makefile $CORES "$@" all
489489

490490
if [ $? -eq 0 ]
491491
then

data/gfx.tgz

-13.9 KB
Binary file not shown.

src/Makefile

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
include ../build/Makefile.template
2-
# CFLAGS+=-O0
2+
3+
#
4+
# For incremental builds, this is a lot faster
5+
#
6+
ifeq ($(origin USE_PRECOMPILED),undefined)
7+
CFLAGS+=-O0
8+
endif
39

410
NAME=gorget
511
BUILD_DIR=../.o
@@ -41,14 +47,28 @@ PRECOMPILED_H_OBJ := $(PRECOMPILED_H).gch
4147
%.hpp.gch: $(PRECOMPILED_H)
4248
$(CC) $(CFLAGS) -c -o $@ $<
4349

44-
$(foreach x,$(ASM_SOURCES),\
50+
#
51+
# Precompiled headers are good for the initial build, but after that it
52+
# is faster to use dependancies
53+
#
54+
ifeq ($(origin USE_PRECOMPILED),undefined)
55+
56+
$(foreach x,$(CPP_SOURCES),\
4557
$(eval $(BUILD_DIR)/$(call obj_name,$x): $x ;\
4658
$(CC) $(CFLAGS) $(DEP_FLAGS) -c -o $$@ $$<))
4759

60+
else
61+
4862
$(foreach x,$(CPP_SOURCES),\
4963
$(eval $(BUILD_DIR)/$(call obj_name,$x): $x | $(PRECOMPILED_H_OBJ) ;\
5064
$(CC) -include $(PRECOMPILED_H) $(CFLAGS) $(DEP_FLAGS) -c -o $$@ $$<))
5165

66+
endif
67+
68+
$(foreach x,$(ASM_SOURCES),\
69+
$(eval $(BUILD_DIR)/$(call obj_name,$x): $x ;\
70+
$(CC) $(CFLAGS) $(DEP_FLAGS) -c -o $$@ $$<))
71+
5272
# use file list instead of wildcard for link command so we don't accidentally
5373
# link with old object files for removed source files
5474
$(TARGET_GAME): $(OBJ_FILES)

src/callstack.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Copyright Neil McGill, goblinhack@gmail.com
3+
//
4+
5+
#include "my_callstack.hpp"
6+
7+
#define __MAIN__
8+
9+
#ifdef USE_THREADS
10+
#ifdef __MAIN__
11+
thread_local struct callframe callframes[ MAXCALLFRAME ];
12+
thread_local unsigned char g_callframes_depth;
13+
#else
14+
extern thread_local struct callframe callframes[ MAXCALLFRAME ];
15+
extern thread_local unsigned char g_callframes_depth;
16+
extern thread_local unsigned char g_callframes_indent;
17+
#endif
18+
#else
19+
#ifdef __MAIN__
20+
struct callframe callframes[ MAXCALLFRAME ];
21+
unsigned char g_callframes_depth;
22+
unsigned char g_callframes_indent;
23+
#else
24+
extern struct callframe callframes[ MAXCALLFRAME ];
25+
extern unsigned char g_callframes_depth;
26+
extern unsigned char g_callframes_indent;
27+
#endif
28+
#endif

src/gfx_64x64.cpp

+52
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,58 @@ void gfx_init_64x64(void)
8888
"dungeon_wall.IS_JOIN_BL",
8989
"dungeon_wall.IS_JOIN_BR",
9090
// ##############################################################################
91+
"dungeon_door.IS_JOIN_TL2",
92+
"dungeon_door.IS_JOIN_T_3",
93+
"dungeon_door.IS_JOIN_TR2",
94+
"dungeon_door.IS_JOIN_TOP",
95+
"dungeon_door.IS_JOIN_X4_180",
96+
"dungeon_door.IS_JOIN_X4_270",
97+
"dungeon_door.IS_JOIN_X2_270",
98+
"dungeon_door.IS_JOIN_X2",
99+
"dungeon_door.IS_JOIN_X1_180",
100+
"dungeon_door.IS_JOIN_X1",
101+
"dungeon_door.IS_JOIN_X",
102+
"",
103+
// ##############################################################################
104+
"dungeon_door.IS_JOIN_T270_3",
105+
"dungeon_door.IS_JOIN_BLOCK",
106+
"dungeon_door.IS_JOIN_T90_3",
107+
"dungeon_door.IS_JOIN_VERT",
108+
"dungeon_door.IS_JOIN_X4_90",
109+
"dungeon_door.IS_JOIN_X4",
110+
"dungeon_door.IS_JOIN_X2_180",
111+
"dungeon_door.IS_JOIN_X2_90",
112+
"dungeon_door.IS_JOIN_X1_90",
113+
"dungeon_door.IS_JOIN_X1_270",
114+
"dungeon_door.IS_JOIN_X3_180",
115+
"dungeon_door.IS_JOIN_X3",
116+
// ##############################################################################
117+
"dungeon_door.IS_JOIN_BL2",
118+
"dungeon_door.IS_JOIN_T180_3",
119+
"dungeon_door.IS_JOIN_BR2",
120+
"dungeon_door.IS_JOIN_BOT",
121+
"dungeon_door.IS_JOIN_T_1",
122+
"dungeon_door.IS_JOIN_T_2",
123+
"dungeon_door.IS_JOIN_T270_2",
124+
"dungeon_door.IS_JOIN_T90_1",
125+
"dungeon_door.IS_JOIN_T",
126+
"dungeon_door.IS_JOIN_T90",
127+
"dungeon_door.IS_JOIN_TL",
128+
"dungeon_door.IS_JOIN_TR",
129+
// ##############################################################################
130+
"dungeon_door.IS_JOIN_LEFT",
131+
"dungeon_door.IS_JOIN_HORIZ",
132+
"dungeon_door.IS_JOIN_RIGHT",
133+
"dungeon_door.IS_JOIN_NODE",
134+
"dungeon_door.IS_JOIN_T180_2",
135+
"dungeon_door.IS_JOIN_T180_1",
136+
"dungeon_door.IS_JOIN_T270_1",
137+
"dungeon_door.IS_JOIN_T90_2",
138+
"dungeon_door.IS_JOIN_T270",
139+
"dungeon_door.IS_JOIN_T180",
140+
"dungeon_door.IS_JOIN_BL",
141+
"dungeon_door.IS_JOIN_BR",
142+
// ##############################################################################
91143
};
92144
const std::vector< std::string > arr(tiles);
93145
tile_load_arr("data/gfx/tiles_64x64.tga", "tiles_64x64", 64, 64, arr);

src/level_display_dungeon.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ void Level::display_dungeon(void)
187187
for (auto slot = 0; slot < MAP_SLOTS; slot++) {
188188
display_dungeon_z_layer(x, y, slot, MAP_DEPTH_FLOOR, no_deco);
189189
display_dungeon_z_layer(x, y, slot, MAP_DEPTH_WALL, no_deco);
190+
display_dungeon_z_layer(x, y, slot, MAP_DEPTH_DOOR, no_deco);
190191
}
191192
}
192193
}

src/level_dungeon.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ void Level::dungeon_create_and_place()
1010
map_set(data,
1111
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
1212
"x...x...........x..............x"
13-
"x...x.xx..x.....x..xxxx..xxxx..x"
13+
"x...x=xx..x.....x..xxxx..xxxx..x"
1414
"x...x..x...x....x..xxxx..xxxx..x"
15-
"x...x..xx...x...x..xxx....xxx..x"
16-
"x.....xx........x..............x"
17-
"x......x........x..xxx....xxx..x"
18-
"xxxxxxxx........x..xxxx..xxxx..x"
19-
"x...............x..xxxx..xxxx..x"
20-
"x..xxxxxxx......x..............x"
21-
"x..x.....x..xxxxx...x.......x..x"
15+
"x===x..xx...x...x..xxx....xxx..x"
16+
"x...=.xx........x..............x"
17+
"x...=..x.====...x..xxx....xxx..x"
18+
"xxxxxxxx.=..=...x..xxxx..xxxx..x"
19+
"x........====...x..xxxx..xxxx..x"
20+
"x..xxxxx........x..............x"
21+
"x..x........xxxxx...x.......x..x"
2222
"x..x.xxx.x..x...x..x.x.....x...x"
2323
"x......x........x...x.....x....x"
2424
"xx...xxx........x........x.....x"

src/level_map.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,17 @@ void Level::map_set(LevelDatap data, const char *in)
2525

2626
switch (c) {
2727
case CHARMAP_WILDCARD : break;
28-
case CHARMAP_DUNGEON_WALL : tp = tp_find("dungeon_wall"); break;
28+
case CHARMAP_DUNGEON_WALL :
29+
tp = tp_find("dungeon_floor");
30+
::tp_set(data, point(x, y), tp);
31+
tp = tp_find("dungeon_wall");
32+
break;
33+
case CHARMAP_DUNGEON_DOOR :
34+
tp = tp_find("dungeon_floor");
35+
::tp_set(data, point(x, y), tp);
36+
tp = tp_find("dungeon_door");
37+
break;
38+
break;
2939
case CHARMAP_TREASURE : break;
3040
case CHARMAP_MONST1 : break;
3141
case CHARMAP_DUNGEON_ENTRANCE : break;

src/level_tiles.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//
44

55
#include "my_bits.hpp"
6+
#include "my_enum.hpp"
67
#include "my_enums.hpp"
78
#include "my_level.hpp"
89
#include "my_template.hpp"

src/main.cpp

+3-27
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Copyright Neil McGill, goblinhack@gmail.com
33
//
44

5-
#define __MAIN__
6-
75
#include <ctime> // do not remove
86
#include <libgen.h> // dirname
97
#include <signal.h> // dirname
@@ -14,12 +12,14 @@
1412
#include <unistd.h> // do not remove
1513

1614
#include "my_audio.hpp"
15+
#include "my_callstack.hpp"
1716
#include "my_command.hpp"
1817
#include "my_dir.hpp"
1918
#include "my_file.hpp"
2019
#include "my_font.hpp"
2120
#include "my_game.hpp"
2221
#include "my_gfx.hpp"
22+
#include "my_main.hpp"
2323
#include "my_music.hpp"
2424
#include "my_ramdisk.hpp"
2525
#include "my_random.hpp"
@@ -28,31 +28,7 @@
2828
#include "my_tp.hpp"
2929
#include "my_wid_console.hpp"
3030

31-
#include "my_callstack.hpp"
32-
33-
#ifdef USE_THREADS
34-
#ifdef __MAIN__
35-
thread_local struct callframe callframes[ MAXCALLFRAME ];
36-
thread_local unsigned char g_callframes_depth;
37-
#else
38-
extern thread_local struct callframe callframes[ MAXCALLFRAME ];
39-
extern thread_local unsigned char g_callframes_depth;
40-
extern thread_local unsigned char g_callframes_indent;
41-
#endif
42-
#else
43-
#ifdef __MAIN__
44-
struct callframe callframes[ MAXCALLFRAME ];
45-
unsigned char g_callframes_depth;
46-
unsigned char g_callframes_indent;
47-
#else
48-
extern struct callframe callframes[ MAXCALLFRAME ];
49-
extern unsigned char g_callframes_depth;
50-
extern unsigned char g_callframes_indent;
51-
#endif
52-
#endif
53-
54-
static char **ARGV;
55-
31+
static char **ARGV;
5632
static std::string original_program_name;
5733
static bool seed_manually_set {};
5834

src/my_callstack.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct callframe {
3131
// the callstack vector
3232
//
3333
#define MAXCALLFRAME 255
34+
3435
#ifdef USE_THREADS
3536
#ifdef __MAIN__
3637
thread_local struct callframe callframes[ MAXCALLFRAME ];

src/my_charmap.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ enum {
1212
CHARMAP_DUNGEON_ENTRANCE = 'S',
1313
CHARMAP_DUNGEON_EXIT = 'E',
1414
CHARMAP_DUNGEON_WALL = 'x',
15+
CHARMAP_DUNGEON_DOOR = '=',
1516
CHARMAP_EMPTY = '.',
1617
CHARMAP_KEY = 'k',
1718
CHARMAP_LEFT = '<',

src/my_depth.hpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// Copyright Neil McGill, goblinhack@gmail.com
3+
//
4+
5+
#pragma once
6+
#ifndef _MY_DEPTH_H_
7+
#define _MY_DEPTH_H_
8+
9+
enum {
10+
MAP_DEPTH_FLOOR,
11+
MAP_DEPTH_WALL,
12+
MAP_DEPTH_DOOR,
13+
MAP_DEPTH_OBJ1,
14+
MAP_DEPTH_OBJ2,
15+
MAP_DEPTH_OBJ3,
16+
MAP_DEPTH_PLAYER,
17+
};
18+
19+
#endif // _MY_DEPTH_H_

src/my_enum.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#ifndef _MY_ENUM_HPP__
77
#define _MY_ENUM_HPP__
88

9+
#include <map>
10+
#include <string>
11+
912
typedef std::map< std::string, uint32_t > enum_map;
1013

1114
/*

src/my_level_data.hpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,13 @@
99
#include <array>
1010
#include <inttypes.h>
1111

12+
#include "my_depth.hpp"
1213
#include "my_fwd.hpp"
1314
#include "my_game_defs.hpp"
1415
#include "my_point.hpp"
1516
#include "my_thing.hpp"
1617
#include "my_thing_id.hpp"
1718

18-
enum {
19-
MAP_DEPTH_FLOOR,
20-
MAP_DEPTH_WALL,
21-
MAP_DEPTH_OBJ1,
22-
MAP_DEPTH_OBJ2,
23-
MAP_DEPTH_OBJ3,
24-
MAP_DEPTH_PLAYER,
25-
};
26-
2719
//
2820
// Simple things like walls that do not change much
2921
//

src/my_main.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "my_sys.hpp"
1010

1111
#include <map>
12-
// REMOVED #include <string>
1312
#include <string> // do not remove
1413
#include <vector> // linux
1514

@@ -205,6 +204,6 @@ void CON(const char *fmt, ...) CHECK_FORMAT_STR(printf, 1, 2);
205204
void CON(const char *fmt, ...);
206205
void WARN(const char *fmt, ...) CHECK_FORMAT_STR(printf, 1, 2);
207206

208-
// REMOVED #include "my_callstack.hpp"
207+
#include "my_callstack.hpp"
209208

210209
#endif

src/my_tp.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Tp
4040
bool is_dungeon_exit {};
4141
bool is_dungeon_floor {};
4242
bool is_dungeon_wall {};
43+
bool is_dungeon_door {};
4344
bool is_key {};
4445
bool is_monst1 {};
4546
bool is_player {};

src/my_tps.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ bool tp_load_player(void);
77
bool tp_load_key(void);
88
bool tp_load_dungeon_entrance(void);
99
bool tp_load_dungeon_wall(void);
10+
bool tp_load_dungeon_door(void);
1011
bool tp_load_dungeon_floor(void);
1112
bool tp_load_dungeon_exit(void);

src/precompiled.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <vector>
3434

3535
#include "my_audio.hpp"
36+
#include "my_callstack.hpp"
3637
#include "my_command.hpp"
3738
#include "my_dir.hpp"
3839
#include "my_enum.hpp"

src/ramdisk_read.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//
44

55
#include "my_main.hpp"
6+
#include "my_ptrcheck.hpp"
67
#include "my_ramdisk.hpp"
78
#include <string.h>
89

0 commit comments

Comments
 (0)