Import blues from aacda169

This commit is contained in:
Gregory Montoir 2022-03-13 06:43:11 +08:00
parent 9d70ca5872
commit b0274d5ce2
12 changed files with 58 additions and 24 deletions

View File

@ -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:

View File

@ -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

View File

@ -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
};

View File

@ -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) {

View File

@ -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);

View File

@ -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

View File

@ -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
};

23
main.c
View File

@ -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)

View File

@ -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
};

View File

@ -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 */

9
util.c
View File

@ -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;
}

3
util.h
View File

@ -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, ...);