From b0274d5ce2265c6556f7e7fea9f6c72b55d34ee0 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Sun, 13 Mar 2022 06:43:11 +0800 Subject: [PATCH] Import blues from aacda169 --- Makefile | 26 +++++++++++++++++++------- README.md | 4 ---- bb/game.c | 2 +- bb/resource.c | 2 +- bb/sound.c | 1 - intern.h | 6 ++++++ ja/game.c | 2 +- main.c | 23 +++++++++++++++++++++-- p2/game.c | 2 +- p2/game.h | 2 +- util.c | 9 +++++++-- util.h | 3 --- 12 files changed, 58 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 1036f7e..89d75f3 100644 --- a/Makefile +++ b/Makefile @@ -15,17 +15,29 @@ SRCS := $(BB_SRCS) $(JA_SRCS) $(P2_SRCS) OBJS := $(SRCS:.c=.o) DEPS := $(SRCS:.c=.d) -CPPFLAGS += -Wall -Wpedantic -MMD $(SDL_CFLAGS) -I. -g +CPPFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wpedantic -MMD $(SDL_CFLAGS) -I. -g -all: blues bbja pre2 +all: blues -blues: main.o sys_sdl2.o util.o $(BB_SRCS:.c=.o) - $(CC) $(LDFLAGS) -o $@ $^ $(SDL_LIBS) $(MODPLUG_LIBS) +game_bb.o: CPPFLAGS += -fvisibility=hidden -bbja: main.o sys_sdl2.o util.o $(JA_SRCS:.c=.o) - $(CC) $(LDFLAGS) -o $@ $^ $(SDL_LIBS) $(MODPLUG_LIBS) +game_bb.o: $(BB_SRCS:.c=.o) + ld -r -o $@ $^ + objcopy --localize-hidden $@ -pre2: main.o sys_sdl2.o util.o $(P2_SRCS:.c=.o) +game_ja.o: CPPFLAGS += -fvisibility=hidden + +game_ja.o: $(JA_SRCS:.c=.o) + ld -r -o $@ $^ + objcopy --localize-hidden $@ + +game_p2.o: CPPFLAGS += -fvisibility=hidden + +game_p2.o: $(P2_SRCS:.c=.o) + ld -r -o $@ $^ + objcopy --localize-hidden $@ + +blues: main.o sys_sdl2.o util.o game_bb.o game_ja.o game_p2.o $(CC) $(LDFLAGS) -o $@ $^ $(SDL_LIBS) $(MODPLUG_LIBS) clean: diff --git a/README.md b/README.md index 5d99820..99acdc8 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,3 @@ Usage: blues [OPTIONS]... --dosscroll Enable DOS style screen scrolling --hybrid Enable fuchsia color as in Hybrid crack ``` - -## Downloads - -[blues-sdl2-win32.zip](https://www.dropbox.com/s/rybnnn4s3rmicva/blues-gh-sdl2-win32.zip?dl=0) - Win32 executable diff --git a/bb/game.c b/bb/game.c index ad780b3..b1fd306 100644 --- a/bb/game.c +++ b/bb/game.c @@ -359,7 +359,7 @@ static void game_run(const char *data_path) { res_fini(); } -struct game_t game = { +EXPORT_SYMBOL struct game_t game_bb = { "Blues Brothers", game_run }; diff --git a/bb/resource.c b/bb/resource.c index 56376ec..9d9022e 100644 --- a/bb/resource.c +++ b/bb/resource.c @@ -315,10 +315,10 @@ void load_img(const char *filename, int screen_w, int dither_pattern) { } assert(size <= 32000); load_iff(g_res.tmp, size, g_res.vga, 320, dither_pattern); - g_sys.copy_bitmap(g_res.vga, 320, 200); if (dither_pattern < 0) { g_sys.set_screen_palette(g_res.palette, 0, 16, 8); } + g_sys.copy_bitmap(g_res.vga, 320, 200); } void load_m(const char *filename) { diff --git a/bb/sound.c b/bb/sound.c index 7b4cdad..31b6801 100644 --- a/bb/sound.c +++ b/bb/sound.c @@ -151,7 +151,6 @@ void play_music(int num) { memcpy(samples[i].name, &buf[offset], 22); samples[i].name[22] = 0; samples[i].size = READ_BE_UINT16(&buf[offset + 22]) * 2; - string_lower(samples[i].name); samples_size += samples[i].size; } buf = (uint8_t *)realloc(buf, size + samples_size); diff --git a/intern.h b/intern.h index 615502f..8ff5559 100644 --- a/intern.h +++ b/intern.h @@ -66,4 +66,10 @@ struct game_t { void (*run)(const char *data_path); }; +#ifdef _WIN32 +#define EXPORT_SYMBOL __attribute__((dllexport)) +#else +#define EXPORT_SYMBOL __attribute__((visibility("default"))) +#endif + #endif diff --git a/ja/game.c b/ja/game.c index 4d478d7..ac38876 100644 --- a/ja/game.c +++ b/ja/game.c @@ -351,7 +351,7 @@ static void game_run(const char *data_path) { res_fini(); } -struct game_t game = { +EXPORT_SYMBOL struct game_t game_ja = { "Blues Brothers : Jukebox Adventure", game_run }; diff --git a/main.c b/main.c index 79aad22..444ef3f 100644 --- a/main.c +++ b/main.c @@ -28,8 +28,27 @@ static const char *USAGE = ; static struct game_t *detect_game(const char *data_path) { - extern struct game_t game; - return &game; + extern struct game_t game_bb; + extern struct game_t game_ja; + extern struct game_t game_p2; + static struct { + struct game_t *game; + const char *filename; + uint16_t size; + } games[] = { + { &game_bb, "AVTMAG.SQV", 3069 }, + { &game_ja, "JARDIN.EAT", 24876 }, + { &game_p2, "MOTIF.SQZ", 9396 }, + { 0, 0, 0 } + }; + for (int i = 0; games[i].game; ++i) { + FILE *fp = fopen_nocase(data_path, games[i].filename); + if (fp) { + fclose(fp); + return games[i].game; + } + } + return 0; } #if defined(PSP) diff --git a/p2/game.c b/p2/game.c index 63735ff..e795d80 100644 --- a/p2/game.c +++ b/p2/game.c @@ -363,7 +363,7 @@ static void game_run(const char *data_path) { res_fini(); } -struct game_t game = { +EXPORT_SYMBOL struct game_t game_p2 = { "Prehistorik 2", game_run }; diff --git a/p2/game.h b/p2/game.h index 9b1430c..452f39f 100644 --- a/p2/game.h +++ b/p2/game.h @@ -175,7 +175,7 @@ struct vars_t { uint8_t level_items_count_tbl[140]; /* bonuses and items collected in the level */ uint8_t level_items_total_count; uint8_t level_bonuses_count_tbl[80]; - uint8_t bonus_energy_counter; + int8_t bonus_energy_counter; int16_t current_platform_dx, current_platform_dy; uint16_t decor_tile0_offset; /* decor tile below the player */ diff --git a/util.c b/util.c index 276f4ff..65d3715 100644 --- a/util.c +++ b/util.c @@ -7,7 +7,7 @@ int g_debug_mask = 0; -void string_lower(char *p) { +static void string_lower(char *p) { for (; *p; ++p) { if (*p >= 'A' && *p <= 'Z') { *p += 'a' - 'A'; @@ -15,7 +15,7 @@ void string_lower(char *p) { } } -void string_upper(char *p) { +static void string_upper(char *p) { for (; *p; ++p) { if (*p >= 'a' && *p <= 'z') { *p += 'A' - 'a'; @@ -76,6 +76,11 @@ FILE *fopen_nocase(const char *path, const char *filename) { char *p = buf + strlen(path) + 1; string_upper(p); fp = fopen(buf, "rb"); + if (!fp) { + char *p = buf + strlen(path) + 1; + string_lower(p); + fp = fopen(buf, "rb"); + } } return fp; } diff --git a/util.h b/util.h index 72be42b..f5c06c7 100644 --- a/util.h +++ b/util.h @@ -14,9 +14,6 @@ extern int g_debug_mask; -extern void string_lower(char *p); -extern void string_upper(char *p); - extern void print_debug(int debug_channel, const char *msg, ...); extern void print_warning(const char *msg, ...); extern void print_error(const char *msg, ...);