From a8363446190d9cc0c712749d0e3610c8485fdfb3 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 15 Dec 2023 13:59:59 +0100 Subject: [PATCH] added basic support for native Boulder Dash game engine code --- src/Makefile | 16 ++++++++++--- src/engines.h | 6 +++++ src/files.c | 2 ++ src/game_bd/Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++ src/game_bd/bd_main.c | 27 ++++++++++++++++++++++ src/game_bd/export.h | 42 ++++++++++++++++++++++++++++++++++ src/game_bd/game_bd.h | 19 ++++++++++++++++ src/game_bd/main_bd.h | 38 +++++++++++++++++++++++++++++++ src/main.h | 4 +++- 9 files changed, 203 insertions(+), 4 deletions(-) create mode 100644 src/game_bd/Makefile create mode 100644 src/game_bd/bd_main.c create mode 100644 src/game_bd/export.h create mode 100644 src/game_bd/game_bd.h create mode 100644 src/game_bd/main_bd.h diff --git a/src/Makefile b/src/Makefile index b7289d01..6674b5ae 100644 --- a/src/Makefile +++ b/src/Makefile @@ -235,6 +235,9 @@ SOURCE_HASH_STRING ?= $(shell test -d ../.git && test `git ls-files -m | wc -l` LIBGAME_DIR = libgame LIBGAME = $(LIBGAME_DIR)/libgame.a +GAME_BD_DIR = game_bd +GAME_BD = $(GAME_BD_DIR)/game_bd.a + GAME_EM_DIR = game_em GAME_EM = $(GAME_EM_DIR)/game_em.a @@ -244,7 +247,7 @@ GAME_SP = $(GAME_SP_DIR)/game_sp.a GAME_MM_DIR = game_mm GAME_MM = $(GAME_MM_DIR)/game_mm.a -RNDLIBS = $(LIBGAME) $(GAME_EM) $(GAME_SP) $(GAME_MM) +RNDLIBS = $(LIBGAME) $(GAME_BD) $(GAME_EM) $(GAME_SP) $(GAME_MM) AUTOCONF = conf_gfx.h conf_snd.h conf_mus.h ICONBASE = windows_icon @@ -262,7 +265,7 @@ GRAPHICS_DIR = ../graphics # build targets # ----------------------------------------------------------------------------- -all: $(AUTOCONF) libgame_dir game_em_dir game_sp_dir game_mm_dir $(PROGNAME) graphics_dir +all: $(AUTOCONF) libgame_dir game_bd_dir game_em_dir game_sp_dir game_mm_dir $(PROGNAME) graphics_dir $(PROGNAME): $(RNDLIBS) $(TIMESTAMP_FILE) $(COMMIT_HASH_FILE) $(OBJS) $(ICON) $(CC) $(OBJS) $(ICON) $(RNDLIBS) $(LDFLAGS) -o $(PROGNAME) @@ -278,6 +281,11 @@ libgame_dir: $(LIBGAME): @$(MAKE) -C $(LIBGAME_DIR) +game_bd_dir: + @$(MAKE) -C $(GAME_BD_DIR) +$(GAME_BD): + @$(MAKE) -C $(GAME_BD_DIR) + game_em_dir: @$(MAKE) -C $(GAME_EM_DIR) $(GAME_EM): @@ -342,6 +350,7 @@ graphics_dir: clean-obj: $(MAKE) -C $(LIBGAME_DIR) clean + $(MAKE) -C $(GAME_BD_DIR) clean $(MAKE) -C $(GAME_EM_DIR) clean $(MAKE) -C $(GAME_SP_DIR) clean $(MAKE) -C $(GAME_MM_DIR) clean @@ -386,10 +395,11 @@ valgrind: # ----------------------------------------------------------------------------- tags: - $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch] $(GAME_SP_DIR)/*.[ch] $(GAME_MM_DIR)/*.[ch] + $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_BD_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch] $(GAME_SP_DIR)/*.[ch] $(GAME_MM_DIR)/*.[ch] depend: $(MAKE) -C $(LIBGAME_DIR) depend + $(MAKE) -C $(GAME_BD_DIR) depend $(MAKE) -C $(GAME_EM_DIR) depend $(MAKE) -C $(GAME_SP_DIR) depend $(MAKE) -C $(GAME_MM_DIR) depend diff --git a/src/engines.h b/src/engines.h index f2f9fe2f..0aad9629 100644 --- a/src/engines.h +++ b/src/engines.h @@ -14,6 +14,7 @@ #include "libgame/libgame.h" +#include "game_bd/export.h" #include "game_em/export.h" #include "game_sp/export.h" #include "game_mm/export.h" @@ -21,6 +22,11 @@ #include "game.h" +// ============================================================================ +// functions and definitions exported from main program to game_bd +// ============================================================================ + + // ============================================================================ // functions and definitions exported from main program to game_em // ============================================================================ diff --git a/src/files.c b/src/files.c index 097deead..3480ed74 100644 --- a/src/files.c +++ b/src/files.c @@ -1771,10 +1771,12 @@ static void setLevelInfoToDefaults_Level(struct LevelInfo *level) setConfigToDefaultsFromConfigList(chunk_config_INFO); *level = li; // copy temporary buffer back to level data + setLevelInfoToDefaults_BD(); setLevelInfoToDefaults_EM(); setLevelInfoToDefaults_SP(); setLevelInfoToDefaults_MM(); + level->native_bd_level = &native_bd_level; level->native_em_level = &native_em_level; level->native_sp_level = &native_sp_level; level->native_mm_level = &native_mm_level; diff --git a/src/game_bd/Makefile b/src/game_bd/Makefile new file mode 100644 index 00000000..d25283af --- /dev/null +++ b/src/game_bd/Makefile @@ -0,0 +1,53 @@ +# ============================================================================= +# Rocks'n'Diamonds - McDuffin Strikes Back! +# ----------------------------------------------------------------------------- +# (c) 1995-2023 by Artsoft Entertainment +# Holger Schemel +# info@artsoft.org +# https://www.artsoft.org/ +# ----------------------------------------------------------------------------- +# The native Boulder Dash game engine is based on: +# - GDash by Czirkos Zoltan (2010) +# ----------------------------------------------------------------------------- +# src/game_bd/Makefile +# ============================================================================= + +# ----------------------------------------------------------------------------- +# configuration +# ----------------------------------------------------------------------------- + +SRCS = bd_main.c + +OBJS = bd_main.o + +GAME_BD = game_bd.a + + +# ----------------------------------------------------------------------------- +# build targets +# ----------------------------------------------------------------------------- + +all: $(GAME_BD) + +$(GAME_BD): $(OBJS) + $(AR) cr $(GAME_BD) $(OBJS) + $(RANLIB) $(GAME_BD) + +.c.o: + $(CC) $(PROFILING) $(CFLAGS) -c $*.c + +clean: + $(RM) $(OBJS) + $(RM) $(GAME_BD) + + +# ----------------------------------------------------------------------------- +# development only +# ----------------------------------------------------------------------------- + +depend: + for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend + +ifeq (.depend,$(wildcard .depend)) +include .depend +endif diff --git a/src/game_bd/bd_main.c b/src/game_bd/bd_main.c new file mode 100644 index 00000000..430d44ca --- /dev/null +++ b/src/game_bd/bd_main.c @@ -0,0 +1,27 @@ +// ============================================================================ +// Mirror Magic -- McDuffin's Revenge +// ---------------------------------------------------------------------------- +// (c) 1995-2023 by Artsoft Entertainment +// Holger Schemel +// info@artsoft.org +// https://www.artsoft.org/ +// ---------------------------------------------------------------------------- +// bd_main.c +// ============================================================================ + +#include "main_bd.h" + + +struct GameInfo_BD game_bd; +struct LevelInfo_BD native_bd_level; +struct EngineSnapshotInfo_BD engine_snapshot_bd; + + +// ============================================================================ +// level file functions +// ============================================================================ + +void setLevelInfoToDefaults_BD(void) +{ + // ... +} diff --git a/src/game_bd/export.h b/src/game_bd/export.h new file mode 100644 index 00000000..54a85d5a --- /dev/null +++ b/src/game_bd/export.h @@ -0,0 +1,42 @@ +#ifndef GAME_BD_EXPORT_H +#define GAME_BD_EXPORT_H + +// ============================================================================ +// functions and definitions exported from game_bd to main program +// ============================================================================ + +// ---------------------------------------------------------------------------- +// constant definitions +// ---------------------------------------------------------------------------- + +// ... + + +// ---------------------------------------------------------------------------- +// data structure definitions +// ---------------------------------------------------------------------------- + +struct GameInfo_BD +{ +}; + +struct LevelInfo_BD +{ +}; + +struct EngineSnapshotInfo_BD +{ +}; + + +// ---------------------------------------------------------------------------- +// exported functions +// ---------------------------------------------------------------------------- + +extern struct GameInfo_BD game_bd; +extern struct LevelInfo_BD native_bd_level; +extern struct EngineSnapshotInfo_BD engine_snapshot_bd; + +void setLevelInfoToDefaults_BD(void); + +#endif // GAME_BD_EXPORT_H diff --git a/src/game_bd/game_bd.h b/src/game_bd/game_bd.h new file mode 100644 index 00000000..d897e381 --- /dev/null +++ b/src/game_bd/game_bd.h @@ -0,0 +1,19 @@ +// ============================================================================ +// Mirror Magic -- McDuffin's Revenge +// ---------------------------------------------------------------------------- +// (c) 1995-2023 by Artsoft Entertainment +// Holger Schemel +// info@artsoft.org +// https://www.artsoft.org/ +// ---------------------------------------------------------------------------- +// game_bd.h +// ============================================================================ + +#ifndef GAME_BD_H +#define GAME_BD_H + +#define GAME_BD_VERSION_1_0_0 + +#include "export.h" + +#endif // GAME_BD_H diff --git a/src/game_bd/main_bd.h b/src/game_bd/main_bd.h new file mode 100644 index 00000000..7d8ffced --- /dev/null +++ b/src/game_bd/main_bd.h @@ -0,0 +1,38 @@ +#ifndef MAIN_BD_H +#define MAIN_BD_H + +// ============================================================================ +// external functions and definitions imported from main program to game_bd +// ============================================================================ + +#include "../engines.h" + + +// ============================================================================ +// functions and definitions that are exported from game_bd to main program +// ============================================================================ + +#include "export.h" + + +// ============================================================================ +// internal functions and definitions that are not exported to main program +// ============================================================================ + +// ---------------------------------------------------------------------------- +// constant definitions +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +// data structure definitions +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +// exported variables +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +// exported functions +// ---------------------------------------------------------------------------- + +#endif // MAIN_BD_H diff --git a/src/main.h b/src/main.h index 6f5b29c7..91c9e81a 100644 --- a/src/main.h +++ b/src/main.h @@ -2731,11 +2731,12 @@ enum // values for game engine type identifier #define GAME_ENGINE_TYPE_UNKNOWN LEVEL_FILE_TYPE_UNKNOWN #define GAME_ENGINE_TYPE_RND LEVEL_FILE_TYPE_RND +#define GAME_ENGINE_TYPE_BD LEVEL_FILE_TYPE_BD #define GAME_ENGINE_TYPE_EM LEVEL_FILE_TYPE_EM #define GAME_ENGINE_TYPE_SP LEVEL_FILE_TYPE_SP #define GAME_ENGINE_TYPE_MM LEVEL_FILE_TYPE_MM -#define NUM_ENGINE_TYPES 4 +#define NUM_ENGINE_TYPES 5 // values for automatically playing tapes #define AUTOPLAY_NONE 0 @@ -3237,6 +3238,7 @@ struct LevelInfo int game_engine_type; // level stored in native format for the alternative native game engines + struct LevelInfo_BD *native_bd_level; struct LevelInfo_EM *native_em_level; struct LevelInfo_SP *native_sp_level; struct LevelInfo_MM *native_mm_level; -- 2.34.1