forked from libretro/beetle-saturn-libretro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.common
More file actions
310 lines (277 loc) · 11.5 KB
/
Makefile.common
File metadata and controls
310 lines (277 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
SOURCES_CXX :=
SOURCES_C :=
DEPS_DIR := $(CORE_DIR)/deps
LIBRETRO_COMM_DIR := $(CORE_DIR)/libretro-common
MEDNAFEN_DIR := $(CORE_DIR)/mednafen
CORE_EMU_DIR := $(MEDNAFEN_DIR)/ss
CDROM_DIR := $(MEDNAFEN_DIR)/cdrom
ZLIB_INCFLAGS := -I$(DEPS_DIR)/zlib
INCFLAGS := -I$(CORE_DIR) -I$(MEDNAFEN_DIR) -I$(MEDNAFEN_DIR)/include -I$(MEDNAFEN_DIR)/intl -I$(MEDNAFEN_DIR)/hw_sound -I$(MEDNAFEN_DIR)/hw_cpu -I$(MEDNAFEN_DIR)/hw_misc -I$(LIBRETRO_COMM_DIR)/include
ZLIB_SOURCES_C := $(DEPS_DIR)/zlib/adler32.c \
$(DEPS_DIR)/zlib/crc32.c \
$(DEPS_DIR)/zlib/inffast.c \
$(DEPS_DIR)/zlib/inflate.c \
$(DEPS_DIR)/zlib/inftrees.c
ifeq ($(NEED_THREADING), 1)
FLAGS += -DWANT_THREADING -DHAVE_THREADS
endif
ifeq ($(NEED_DEINTERLACER), 1)
FLAGS += -DNEED_DEINTERLACER
endif
ifeq ($(NEED_BPP), 32)
FLAGS += -DWANT_32BPP
endif
ifeq ($(NO_COMPUTED_GOTO), 1)
FLAGS += -DNO_COMPUTED_GOTO
endif
ifeq ($(NEED_CD), 1)
FLAGS += -DNEED_CD
endif
ifeq ($(HAVE_CHD), 1)
FLAGS += -DHAVE_CHD -D_7ZIP_ST -DZSTD_DISABLE_ASM
ifeq ($(SYSTEM_LIBCHDR), 1)
INCFLAGS += $(shell pkg-config --cflags libchdr)
LIBS += $(shell pkg-config --libs libchdr)
else
INCFLAGS += -I$(DEPS_DIR)/crypto \
-I$(DEPS_DIR)/lzma/C \
-I$(DEPS_DIR)/libchdr \
-I$(DEPS_DIR)/libchdr/include \
-I$(DEPS_DIR)/libchdr/include/libchdr \
-I$(DEPS_DIR)/zstd/lib
endif
endif
ifeq ($(NEED_TREMOR), 1)
FLAGS += -DNEED_TREMOR
endif
SOURCES_CXX += \
$(CORE_EMU_DIR)/sound_glue.cpp \
$(CORE_EMU_DIR)/ss.cpp
# sound.cpp -> sound.c + sound_glue.cpp. The orchestration half
# (SOUND_* public ABI, the SOUND_Update 32.32 fixed-point cycle
# loop, the SCSP IBuffer ring, the setjmp recovery point) moves
# to C; the C++ class instances (SS_SCSP SCSP, M68K SoundCPU),
# the eight M68K bus callbacks they need, and scsp.inc stay in
# the new sound_glue.cpp. The two halves exchange state through
# sound_internal.h: a handful of extern "C" SoundGlue_* wrappers
# around the M68K / SS_SCSP class methods sound.c needs, and four
# extern symbols (SOUND_next_scsp_time, SOUND_jbuf, IBuffer,
# SOUND_IBufferCount) owned by sound.c that the glue side reads /
# writes during the bus-callback and RunSCSP paths.
# scu_dsp_{gen,mvi,jmp,misc}.cpp -> .c. Phase-5a detemplated the
# four helper functions in scu_dsp_common.inc (DSP_TestCond,
# DSP_InstrPre, DSP_DecodeInstruction, the DSPS::IsRunning member)
# to FORCE_INLINE C-callable forms with const args. Phase 5b/5c/5d
# monomorphized the four instruction-handler templates:
# - JMPInstr <looped, cond> -> 130 named functions
# - MVIInstr <looped, dest, cond> -> 2080 named functions
# - GeneralInstr <l, alu, x, y, d1> -> 5376 named functions
# - MiscInstr <looped, op> -> 8 named functions
# Each scu_dsp_*tab.inc table file regenerated with the new
# underscored names; the hand-dedup pattern in gentab.inc and
# jmptab.inc / mvitab.inc (cond&0x40==0 collapse, alu NOP collapse,
# x_op 0/1 collapse) preserved slot-by-slot so the function-pointer
# tables stay byte-identical pre/post. DMAInstr stays embedded in
# scu.inc (ss.cpp's TU) since the body still uses BBusRW_DB and
# ABus_Write_DB32 C++ templates from the bus-access layer.
# The STATE_MASK_* enum was hoisted out of `struct DSPS` to file
# scope so the same `STATE_MASK_EXECUTE` spelling compiles in
# both C and C++.
# db.cpp -> db.c. Dead std:: helpers (DB_GetInternalDB,
# DB_GetHHDescriptions, FDIDToString) were removed in an earlier
# commit, leaving only POD tables and lookup functions.
#
# smpc.cpp -> smpc.c. The class-method calls (CPU[X].SetActive,
# CPU[X].SetNMI) and the namespace calls (VDP2::Update, VDP2::Reset,
# VDP2::GetGunXTranslation, VDP2::SetExtLatch) now route through
# extern "C" proxies in ss.cpp and vdp2.cpp respectively.
#
# cdb.cpp -> cdb.c. The BufferCDDA template took a runtime parameter
# (two callsites, both at 75 Hz so cost is unmeasurable). FileInfoS
# member methods fad()/size() became free FileInfoS_fad/size()
# INLINE helpers. Five functions with C++ default arguments
# (StartSeek / MakeBaseStatus / MakeReport / CDStatusResults /
# SeekStart2) had ~100 callsites filled in with explicit defaults.
# FilterS::MODE_SEL_X enum hoisted to file scope. All cdb-internal,
# no public-ABI changes.
#
# vdp2.cpp -> vdp2.c. The `namespace VDP2 { ... }` wrap was lifted
# and the 19 public entry points renamed to VDP2_* (matching the
# extern "C" proxy convention used in earlier commits, which are
# now redundant and removed). The RW<T,IsWrite> template
# monomorphized into RW_R16 / RW_W8 / RW_W16. Three auto&
# references converted to __typeof__()* pointers. Two
# CPU[i].SetExtHaltDMAKludgeFromVDP2 callsites routed through a
# new SH7095_SetExtHaltDMAKludge proxy in ss.cpp.
# vdp2_render.cpp -> vdp2_render.c. Five C++ idioms removed in
# the lead-up to the rename:
# - TileFetcher<bool> struct template with templated Fetch method
# replaced by two named POD structs (TileFetcher_Rot,
# TileFetcher_NonRot) plus 10 free INLINE functions selected
# by ##-paste dispatch macros (TF_ROT_FETCH, TF_NR_FETCH).
# - MakeNBGRBGPix<...> templated INLINE function replaced by a
# do-while macro (MAKE_NBGRBG_PIX) that writes through an
# output-lvalue arg.
# - The four `auto&` references in SetupRotVars and the two
# T_DrawRBG body macros became explicit struct pointers
# (struct RotVars*, struct TileFetcher_Rot*) with `->`
# field access.
# - C++11 `alignas(N)` -> `__attribute__((aligned(N)))` on the
# LB.lc backing array, the SPSC ring-buffer atomic counters,
# and the ProducerState / ConsumerState struct decls.
# - `static constexpr` -> `static const` for the InitOverlay
# sprite-type LUTs and `#define` for the BurstBuf size / mask
# scalars used as array bounds.
# Cross-language atomics already brokered via the language-neutral
# vdp2_atomic_u32 + VDP2_ATOMIC_* macros set up in earlier phases.
SOURCES_C += $(CORE_EMU_DIR)/db.c \
$(CORE_EMU_DIR)/smpc.c \
$(CORE_EMU_DIR)/cdb.c \
$(CORE_EMU_DIR)/vdp2.c \
$(CORE_EMU_DIR)/vdp2_render.c \
$(CORE_EMU_DIR)/scu_dsp_gen.c \
$(CORE_EMU_DIR)/scu_dsp_mvi.c \
$(CORE_EMU_DIR)/scu_dsp_jmp.c \
$(CORE_EMU_DIR)/scu_dsp_misc.c \
$(CORE_EMU_DIR)/sound.c \
$(CORE_EMU_DIR)/ss_state.c \
$(CORE_EMU_DIR)/ss_init.c
# The cartridge subsystem, converted from C++ to C. CartInfo was
# already a plain struct of function pointers (C-style polymorphism),
# so the conversion was mechanical -- monomorphizing the small memory-
# access templates and trimming C++-only includes.
# The VDP1 subsystem, converted from C++ to C. The class-with-methods
# rasterizer state (GourauderTheTerrible, VileTex, EdgeStepper) became
# plain structs + free functions; the PlotPixel / DrawLine template
# engine became MDFN_FORCE_INLINE functions taking the former template
# parameters as const args, with per-table thin wrapper functions
# generated by nested macros so each LineFuncTab slot still resolves to
# a distinct, fully constant-folded function -- matching the codegen of
# the original C++ template instantiations.
SOURCES_C += \
$(CORE_EMU_DIR)/vdp1.c \
$(CORE_EMU_DIR)/vdp1_line.c \
$(CORE_EMU_DIR)/vdp1_sprite.c \
$(CORE_EMU_DIR)/vdp1_poly.c
SOURCES_C += $(CORE_EMU_DIR)/ak93c45.c
SOURCES_C += $(CORE_EMU_DIR)/stvio.c
SOURCES_C += \
$(CORE_EMU_DIR)/cart.c \
$(CORE_EMU_DIR)/cart/backup.c \
$(CORE_EMU_DIR)/cart/cs1ram.c \
$(CORE_EMU_DIR)/cart/bootrom.c \
$(CORE_EMU_DIR)/cart/extram.c \
$(CORE_EMU_DIR)/cart/rom.c \
$(CORE_EMU_DIR)/cart/stv.c \
$(CORE_EMU_DIR)/cart/ar4mp.c
# CRC helpers used by the ST-V port (game DB fingerprinting + EEPROM seed).
SOURCES_C += $(MEDNAFEN_DIR)/hash/crc.c
# The Saturn input-device hierarchy, converted from the C++ class
# hierarchy in input/*.{cpp,h} to a single C translation unit.
SOURCES_C += $(CORE_EMU_DIR)/smpc_iodevice.c
SOURCES_CXX += $(MEDNAFEN_DIR)/hw_cpu/m68k/m68k.cpp
ifeq ($(M68K_SPLIT_SWITCH), 1)
FLAGS += -DM68K_SPLIT_SWITCH
SOURCES_CXX += $(MEDNAFEN_DIR)/hw_cpu/m68k/m68k_instr_split0.cpp \
$(MEDNAFEN_DIR)/hw_cpu/m68k/m68k_instr_split1.cpp
endif
ifeq ($(NEED_TREMOR), 1)
SOURCES_C += $(wildcard $(MEDNAFEN_DIR)/tremor/*.c)
endif
SOURCES_C += $(CDROM_DIR)/edc_crc32.c \
$(CDROM_DIR)/galois.c \
$(CDROM_DIR)/recover-raw.c \
$(CDROM_DIR)/l-ec.c \
$(CDROM_DIR)/lec.c \
$(CDROM_DIR)/CDUtility.c \
$(CDROM_DIR)/audioreader.c \
$(CDROM_DIR)/CDAccess.c \
$(CDROM_DIR)/CDAccess_CCD.c \
$(CDROM_DIR)/CDAccess_Image.c \
$(CDROM_DIR)/cdromif.c
ifeq ($(HAVE_CHD), 1)
ifneq ($(SYSTEM_LIBCHDR), 1)
LZMA_DIR := $(DEPS_DIR)/lzma/src
LIBCHDR_DIR := $(DEPS_DIR)/libchdr/src
INCFLAGS += -I$(DEPS_DIR)/lzma/include
SOURCES_C += \
$(DEPS_DIR)/crypto/md5.c \
$(DEPS_DIR)/crypto/sha1.c \
$(LZMA_DIR)/Alloc.c \
$(LZMA_DIR)/Bra86.c \
$(LZMA_DIR)/BraIA64.c \
$(LZMA_DIR)/CpuArch.c \
$(LZMA_DIR)/Delta.c \
$(LZMA_DIR)/LzFind.c \
$(LZMA_DIR)/Lzma86Dec.c \
$(LZMA_DIR)/LzmaDec.c \
$(LZMA_DIR)/LzmaEnc.c \
$(LIBCHDR_DIR)/libchdr_bitstream.c \
$(LIBCHDR_DIR)/libchdr_cdrom.c \
$(LIBCHDR_DIR)/libchdr_chd.c \
$(LIBCHDR_DIR)/libchdr_flac.c \
$(LIBCHDR_DIR)/libchdr_huffman.c \
$(DEPS_DIR)/zstd/lib/common/entropy_common.c \
$(DEPS_DIR)/zstd/lib/common/error_private.c \
$(DEPS_DIR)/zstd/lib/common/fse_decompress.c \
$(DEPS_DIR)/zstd/lib/common/zstd_common.c \
$(DEPS_DIR)/zstd/lib/common/xxhash.c \
$(DEPS_DIR)/zstd/lib/decompress/huf_decompress.c \
$(DEPS_DIR)/zstd/lib/decompress/zstd_ddict.c \
$(DEPS_DIR)/zstd/lib/decompress/zstd_decompress.c \
$(DEPS_DIR)/zstd/lib/decompress/zstd_decompress_block.c
endif
SOURCES_C += $(CDROM_DIR)/CDAccess_CHD.c
endif
SOURCES_C += $(MEDNAFEN_DIR)/state.c
# All top-level C++ TUs have been converted to C
# (disc.cpp -> disc.c, input.cpp -> input.c, libretro.cpp ->
# libretro.c). The remaining C++ in this build lives in
# mednafen/ss/ and mednafen/hw_cpu/m68k/.
# Deinterlacer.cpp / surface.cpp were dropped; the surface header is
# now header-only (PSX-style, with the MDFN_PixelFormat class removed)
# and the deinterlacer is C, not C++. See mednafen/video/{surface.h,
# Deinterlacer.h, Deinterlacer.c}.
SOURCES_C += $(MEDNAFEN_DIR)/cdstream.c \
$(MEDNAFEN_DIR)/general.c \
$(MEDNAFEN_DIR)/mempatcher.c \
$(MEDNAFEN_DIR)/settings.c \
$(CORE_DIR)/disc.c \
$(CORE_DIR)/input.c \
$(CORE_DIR)/libretro.c \
$(CORE_DIR)/libretro_settings.c \
$(MEDNAFEN_DIR)/video/Deinterlacer.c \
$(MEDNAFEN_DIR)/hash/md5.c \
$(MEDNAFEN_DIR)/hash/sha256.c
ifeq ($(HAVE_CHD), 1)
ifneq ($(SYSTEM_LIBCHDR), 1)
ifeq ($(SYSTEM_ZLIB), 1)
INCFLAGS += $(shell pkg-config --cflags zlib)
LIBS += $(shell pkg-config --libs zlib)
else
INCFLAGS += $(ZLIB_INCFLAGS)
SOURCES_C += $(ZLIB_SOURCES_C)
endif
endif
endif
ifneq ($(STATIC_LINKING), 1)
SOURCES_C += $(LIBRETRO_COMM_DIR)/streams/file_stream.c \
$(LIBRETRO_COMM_DIR)/streams/file_stream_transforms.c \
$(LIBRETRO_COMM_DIR)/file/file_path.c \
$(LIBRETRO_COMM_DIR)/file/retro_dirent.c \
$(LIBRETRO_COMM_DIR)/lists/dir_list.c \
$(LIBRETRO_COMM_DIR)/lists/string_list.c \
$(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.c \
$(LIBRETRO_COMM_DIR)/compat/compat_posix_string.c \
$(LIBRETRO_COMM_DIR)/compat/compat_strl.c \
$(LIBRETRO_COMM_DIR)/compat/compat_strcasestr.c \
$(LIBRETRO_COMM_DIR)/compat/fopen_utf8.c \
$(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \
$(LIBRETRO_COMM_DIR)/memmap/memalign.c \
$(LIBRETRO_COMM_DIR)/string/stdstring.c \
$(LIBRETRO_COMM_DIR)/time/rtime.c
endif
ifeq ($(NEED_THREADING), 1)
SOURCES_C += $(LIBRETRO_COMM_DIR)/rthreads/rthreads.c \
$(LIBRETRO_COMM_DIR)/rthreads/rsemaphore.c
endif