From cabd40f8984986d52046bda4116fd40e5c385e56 Mon Sep 17 00:00:00 2001 From: J Date: Mon, 11 Dec 2023 00:49:09 +0000 Subject: [PATCH 1/5] GE Muzzle flash addition --- src/game/bondgun.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/game/bondgun.c b/src/game/bondgun.c index b63ab0d2c..c17f39bd0 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -1911,7 +1911,13 @@ void bgun0f09a6f8(struct handweaponinfo *info, s32 handnum, struct hand *hand, s if (func->flags & FUNCFLAG_NOMUZZLEFLASH) { hand->flashon = false; } else { - hand->flashon = true; + if ( func->type != INVENTORYFUNCTYPE_SHOOT_SINGLE) { + if (hand->shotstotake % 2 == 1) { + hand->flashon = true; + } + } else { + hand->flashon = true; + } } bgunStartSlide(handnum); From 5aa799718a770a2e92414ccb654be842ed8029e2 Mon Sep 17 00:00:00 2001 From: Bobby Lovell Date: Fri, 15 Dec 2023 10:17:15 -0500 Subject: [PATCH 2/5] Add support for unsigned integers. --- port/src/config.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/port/src/config.c b/port/src/config.c index b10c5e5df..5f9f7289e 100644 --- a/port/src/config.c +++ b/port/src/config.c @@ -16,6 +16,7 @@ typedef enum { CFG_NONE, CFG_S32, CFG_F32, + CFG_U32, CFG_STR } configtype; @@ -27,6 +28,7 @@ struct configentry { union { struct { f32 min_f32, max_f32; }; struct { s32 min_s32, max_s32; }; + struct { u32 min_u32, max_u32; }; u32 max_str; }; } settings[CONFIG_MAX_SETTINGS]; @@ -38,6 +40,11 @@ static inline s32 configClampInt(s32 val, s32 min, s32 max) return (val < min) ? min : ((val > max) ? max : val); } +static inline u32 configClampUInt(u32 val, u32 min, u32 max) +{ + return (val < min) ? min : ((val > max) ? max : val); +} + static inline f32 configClampFloat(f32 val, f32 min, f32 max) { return (val < min) ? min : ((val > max) ? max : val); @@ -101,6 +108,17 @@ void configRegisterInt(const char *key, s32 *var, s32 min, s32 max) } } +void configRegisterUInt(const char* key, u32* var, u32 min, u32 max) +{ + struct configentry* cfg = configFindOrAddEntry(key); + if (cfg) { + cfg->type = CFG_U32; + cfg->ptr = var; + cfg->min_u32 = min; + cfg->max_u32 = max; + } +} + void configRegisterFloat(const char *key, f32 *var, f32 min, f32 max) { struct configentry *cfg = configFindOrAddEntry(key); @@ -129,6 +147,7 @@ static void configSetFromString(const char *key, const char *val) s32 tmp_s32; f32 tmp_f32; + u32 tmp_u32; switch (cfg->type) { case CFG_S32: tmp_s32 = atoi(val); @@ -144,6 +163,13 @@ static void configSetFromString(const char *key, const char *val) } *(f32 *)cfg->ptr = tmp_f32; break; + case CFG_U32: + tmp_u32 = atoll(val); + if (cfg->min_u32 < cfg->max_u32) { + tmp_u32 = configClampUInt(tmp_u32, cfg->min_u32, cfg->max_u32); + } + *(u32*)cfg->ptr = tmp_u32; + break; case CFG_STR: strncpy(cfg->ptr, val, cfg->max_str ? cfg->max_str - 1 : 4096); break; @@ -167,6 +193,12 @@ static void configSaveEntry(struct configentry *cfg, FILE *f) } fprintf(f, "%s=%f\n", cfg->key + cfg->seclen + 1, *(f32 *)cfg->ptr); break; + case CFG_U32: + if (cfg->min_u32 < cfg->max_u32) { + *(u32*)cfg->ptr = configClampUInt(*(u32*)cfg->ptr, cfg->min_u32, cfg->max_u32); + } + fprintf(f, "%s=%u\n", cfg->key + cfg->seclen + 1, *(u32*)cfg->ptr); + break; case CFG_STR: fprintf(f, "%s=%s\n", cfg->key + cfg->seclen + 1, (char *)cfg->ptr); break; From 8c509db8888a6b4895939d35b373a4288a070475 Mon Sep 17 00:00:00 2001 From: Dominic Della Valle Date: Sat, 16 Dec 2023 07:04:52 -0500 Subject: [PATCH 3/5] port: add start window maximized flag to config --- port/fast3d/gfx_api.h | 2 +- port/fast3d/gfx_pc.cpp | 4 ++-- port/fast3d/gfx_sdl2.cpp | 8 ++++++-- port/fast3d/gfx_window_manager_api.h | 2 +- port/src/video.c | 4 +++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/port/fast3d/gfx_api.h b/port/fast3d/gfx_api.h index 1f53f0ed4..3bf8427ad 100644 --- a/port/fast3d/gfx_api.h +++ b/port/fast3d/gfx_api.h @@ -31,7 +31,7 @@ extern float gfx_current_native_aspect; // The aspect ratio of the above mode extern bool gfx_framebuffers_enabled; void gfx_init(struct GfxWindowManagerAPI* wapi, struct GfxRenderingAPI* rapi, const char* game_name, - bool start_in_fullscreen, uint32_t width, uint32_t height, + bool start_in_fullscreen, bool start_maximized, uint32_t width, uint32_t height, uint32_t posX, uint32_t posY); void gfx_destroy(void); struct GfxRenderingAPI* gfx_get_current_rendering_api(void); diff --git a/port/fast3d/gfx_pc.cpp b/port/fast3d/gfx_pc.cpp index a5c997a31..cdd0d3e3c 100644 --- a/port/fast3d/gfx_pc.cpp +++ b/port/fast3d/gfx_pc.cpp @@ -2699,10 +2699,10 @@ extern "C" void gfx_get_dimensions(uint32_t* width, uint32_t* height, int32_t* p } extern "C" void gfx_init(struct GfxWindowManagerAPI* wapi, struct GfxRenderingAPI* rapi, const char* game_name, - bool start_in_fullscreen, uint32_t width, uint32_t height, uint32_t posX, uint32_t posY) { + bool start_in_fullscreen, bool start_maximized, uint32_t width, uint32_t height, uint32_t posX, uint32_t posY) { gfx_wapi = wapi; gfx_rapi = rapi; - gfx_wapi->init(game_name, rapi->get_name(), start_in_fullscreen, width, height, posX, posY); + gfx_wapi->init(game_name, rapi->get_name(), start_in_fullscreen, start_maximized, width, height, posX, posY); gfx_rapi->init(); gfx_rapi->update_framebuffer_parameters(0, width, height, 1, false, true, true, true); gfx_current_dimensions.internal_mul = 1; diff --git a/port/fast3d/gfx_sdl2.cpp b/port/fast3d/gfx_sdl2.cpp index 07128bfcf..778232eb8 100644 --- a/port/fast3d/gfx_sdl2.cpp +++ b/port/fast3d/gfx_sdl2.cpp @@ -84,7 +84,7 @@ static void gfx_sdl_get_active_window_refresh_rate(uint32_t* refresh_rate) { *refresh_rate = mode.refresh_rate; } -static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool start_in_fullscreen, uint32_t width, +static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool start_in_fullscreen, bool start_maximized, uint32_t width, uint32_t height, int32_t posX, int32_t posY) { window_width = width; window_height = height; @@ -110,7 +110,11 @@ static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool s posY = 100; } - const Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_OPENGL; + Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_OPENGL; + if (start_maximized) { + flags |= SDL_WINDOW_MAXIMIZED; + } + wnd = SDL_CreateWindow(title, posX, posY, window_width, window_height, flags); if (!wnd) { sysFatalError("Could not open SDL window:\n%s", SDL_GetError()); diff --git a/port/fast3d/gfx_window_manager_api.h b/port/fast3d/gfx_window_manager_api.h index 71886547e..cc8893ace 100644 --- a/port/fast3d/gfx_window_manager_api.h +++ b/port/fast3d/gfx_window_manager_api.h @@ -5,7 +5,7 @@ #include struct GfxWindowManagerAPI { - void (*init)(const char* game_name, const char* gfx_api_name, bool start_in_fullscreen, uint32_t width, + void (*init)(const char* game_name, const char* gfx_api_name, bool start_in_fullscreen, bool start_maximized, uint32_t width, uint32_t height, int32_t posX, int32_t posY); void (*close)(void); void (*set_fullscreen_changed_callback)(void (*on_fullscreen_changed)(bool is_now_fullscreen)); diff --git a/port/src/video.c b/port/src/video.c index c0c2fb642..d645522bd 100644 --- a/port/src/video.c +++ b/port/src/video.c @@ -21,6 +21,7 @@ static s32 vidWidth = 640; static s32 vidHeight = 480; static s32 vidFramebuffers = true; static s32 vidFullscreen = false; +static s32 vidMaximize = false; static s32 vidVsync = 1; static s32 vidMSAA = 1; static s32 vidFramerateLimit = 0; @@ -44,7 +45,7 @@ s32 videoInit(void) gfx_framebuffers_enabled = (bool)vidFramebuffers; gfx_msaa_level = vidMSAA; - gfx_init(wmAPI, renderingAPI, "PD", vidFullscreen, vidWidth, vidHeight, 100, 100); + gfx_init(wmAPI, renderingAPI, "PD", vidFullscreen, vidMaximize, vidWidth, vidHeight, 100, 100); if (!wmAPI->set_swap_interval(vidVsync)) { vidVsync = 0; @@ -232,6 +233,7 @@ void videoFreeCachedTexture(const void *texptr) PD_CONSTRUCTOR static void videoConfigInit(void) { configRegisterInt("Video.DefaultFullscreen", &vidFullscreen, 0, 1); + configRegisterInt("Video.DefaultMaximize", &vidMaximize, 0, 1); configRegisterInt("Video.DefaultWidth", &vidWidth, 0, 32767); configRegisterInt("Video.DefaultHeight", &vidHeight, 0, 32767); configRegisterInt("Video.VSync", &vidVsync, -1, 10); From cdd7d6edacf2bfbdad9c56d40dea057fcfda3757 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 16 Dec 2023 15:08:14 +0100 Subject: [PATCH 4/5] port: use strto* when parsing config instead of ato* allows hex values --- port/src/config.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/port/src/config.c b/port/src/config.c index 5f9f7289e..b37c2e955 100644 --- a/port/src/config.c +++ b/port/src/config.c @@ -50,7 +50,6 @@ static inline f32 configClampFloat(f32 val, f32 min, f32 max) return (val < min) ? min : ((val > max) ? max : val); } - static inline struct configentry *configFindEntry(const char *key) { for (s32 i = 0; i < numSettings; ++i) { @@ -150,21 +149,21 @@ static void configSetFromString(const char *key, const char *val) u32 tmp_u32; switch (cfg->type) { case CFG_S32: - tmp_s32 = atoi(val); + tmp_s32 = strtol(val, NULL, 0); if (cfg->min_s32 < cfg->max_s32) { tmp_s32 = configClampInt(tmp_s32, cfg->min_s32, cfg->max_s32); } *(s32 *)cfg->ptr = tmp_s32; break; case CFG_F32: - tmp_f32 = atof(val); + tmp_f32 = strtof(val, NULL); if (cfg->min_f32 < cfg->max_f32) { tmp_f32 = configClampFloat(tmp_f32, cfg->min_f32, cfg->max_f32); } *(f32 *)cfg->ptr = tmp_f32; break; case CFG_U32: - tmp_u32 = atoll(val); + tmp_u32 = strtoul(val, NULL, 0); if (cfg->min_u32 < cfg->max_u32) { tmp_u32 = configClampUInt(tmp_u32, cfg->min_u32, cfg->max_u32); } @@ -197,7 +196,7 @@ static void configSaveEntry(struct configentry *cfg, FILE *f) if (cfg->min_u32 < cfg->max_u32) { *(u32*)cfg->ptr = configClampUInt(*(u32*)cfg->ptr, cfg->min_u32, cfg->max_u32); } - fprintf(f, "%s=%u\n", cfg->key + cfg->seclen + 1, *(u32*)cfg->ptr); + fprintf(f, "%s=%u\n", cfg->key + cfg->seclen + 1, *(u32 *)cfg->ptr); break; case CFG_STR: fprintf(f, "%s=%s\n", cfg->key + cfg->seclen + 1, (char *)cfg->ptr); From 28218b26c284abf94188be0b326a35b8fb18bfad Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 16 Dec 2023 15:22:23 +0100 Subject: [PATCH 5/5] port: add setting for GE muzzle flashes and disable it by default --- port/src/main.c | 1 + port/src/optionsmenu.c | 21 +++++++++++++++++++++ src/game/bondgun.c | 12 ++++++++++-- src/include/data.h | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/port/src/main.c b/port/src/main.c index 38d4da332..e8a71c479 100644 --- a/port/src/main.c +++ b/port/src/main.c @@ -155,6 +155,7 @@ PD_CONSTRUCTOR static void gameConfigInit(void) configRegisterInt("Game.TickRateDivisor", &g_TickRateDiv, 0, 10); configRegisterInt("Game.SkipIntro", &g_SkipIntro, 0, 1); configRegisterInt("Game.DisableMpDeathMusic", &g_MusicDisableMpDeath, 0, 1); + configRegisterInt("Game.GEMuzzleFlashes", &g_BgunGeMuzzleFlashes, 0, 1); for (s32 j = 0; j < MAX_PLAYERS; ++j) { const s32 i = j + 1; configRegisterFloat(strFmt("Game.Player%d.FovY", i), &g_PlayerExtCfg[j].fovy, 5.f, 175.f); diff --git a/port/src/optionsmenu.c b/port/src/optionsmenu.c index e77e95322..0c6b2a9d3 100644 --- a/port/src/optionsmenu.c +++ b/port/src/optionsmenu.c @@ -678,6 +678,19 @@ static MenuItemHandlerResult menuhandlerTexFilter2D(s32 operation, struct menuit return 0; } +static MenuItemHandlerResult menuhandlerGeMuzzleFlashes(s32 operation, struct menuitem *item, union handlerdata *data) +{ + switch (operation) { + case MENUOP_GET: + return g_BgunGeMuzzleFlashes; + case MENUOP_SET: + g_BgunGeMuzzleFlashes = data->checkbox.value; + break; + } + + return 0; +} + static MenuItemHandlerResult menuhandlerCenterHUD(s32 operation, struct menuitem *item, union handlerdata *data) { static const char *opts[] = { @@ -751,6 +764,14 @@ struct menuitem g_ExtendedVideoMenuItems[] = { 0, menuhandlerTexFilter2D, }, + { + MENUITEMTYPE_CHECKBOX, + 0, + MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"GE64-style Muzzle Flashes", + 0, + menuhandlerGeMuzzleFlashes, + }, { MENUITEMTYPE_DROPDOWN, 0, diff --git a/src/game/bondgun.c b/src/game/bondgun.c index c17f39bd0..cb891c8c9 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -190,6 +190,10 @@ char var800700bc[][10] = { { 'x','x','x' }, // "xxx" }; +#ifndef PLATFORM_N64 +s32 g_BgunGeMuzzleFlashes = false; +#endif + #if !MATCHING || VERSION >= VERSION_NTSC_1_0 void bgunRumble(s32 handnum, s32 weaponnum) { @@ -1911,13 +1915,17 @@ void bgun0f09a6f8(struct handweaponinfo *info, s32 handnum, struct hand *hand, s if (func->flags & FUNCFLAG_NOMUZZLEFLASH) { hand->flashon = false; } else { - if ( func->type != INVENTORYFUNCTYPE_SHOOT_SINGLE) { - if (hand->shotstotake % 2 == 1) { +#ifdef PLATFORM_N64 + hand->flashon = true; +#else + if (g_BgunGeMuzzleFlashes) { + if (func->type != INVENTORYFUNCTYPE_SHOOT_SINGLE && (hand->shotstotake & 1)) { hand->flashon = true; } } else { hand->flashon = true; } +#endif } bgunStartSlide(handnum); diff --git a/src/include/data.h b/src/include/data.h index 2f0afbe88..315c8bb17 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -548,6 +548,7 @@ extern s32 g_BlurFbCapTimer; extern bool g_BlurFbDirty; extern s32 g_TickRateDiv; extern s32 g_MusicDisableMpDeath; +extern s32 g_BgunGeMuzzleFlashes; #define PLAYER_EXTCFG() g_PlayerExtCfg[g_Vars.currentplayerstats->mpindex & 3] #define PLAYER_DEFAULT_FOV (PLAYER_EXTCFG().fovy)