diff --git a/port/include/video.h b/port/include/video.h index 9031cc49d..81738a76e 100644 --- a/port/include/video.h +++ b/port/include/video.h @@ -19,7 +19,6 @@ s32 videoGetNativeHeight(void); s32 videoGetWidth(void); s32 videoGetHeight(void); f32 videoGetAspect(void); -f32 videoGetPlayerFovY(void); s32 videoCreateFramebuffer(u32 w, u32 h); void videoSetFramebuffer(s32 target); diff --git a/port/src/input.c b/port/src/input.c index fcc842fe3..38bc1f005 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -130,8 +130,6 @@ static const char *vkJoyNames[] = { static char vkNames[VK_TOTAL_COUNT][64]; -f32 crosshairSway = 1.f; - void inputSetDefaultKeyBinds(void) { // TODO: make VK constants for all these @@ -461,8 +459,6 @@ s32 inputInit(void) inputLoadBinds(); - crosshairSway = configGetFloat("Input.CrosshairSway", 1.f); - return connectedMask; } diff --git a/port/src/main.c b/port/src/main.c index 4791dcb95..9121b45eb 100644 --- a/port/src/main.c +++ b/port/src/main.c @@ -6,6 +6,7 @@ #include "lib/main.h" #include "bss.h" +#include "data.h" #include "video.h" #include "audio.h" @@ -59,6 +60,13 @@ static void cleanup(void) // TODO: actually shut down all subsystems } +static void gameLoadConfig(void) +{ + osMemSize = configGetInt("Game.MemorySize", 16) * 1024 * 1024; + g_PlayerCrosshairSway = configGetFloat("Game.CrosshairSway", g_PlayerCrosshairSway); + g_PlayerDefaultFovY = configGetFloat("Game.FovY", g_PlayerDefaultFovY); +} + int main(int argc, const char **argv) { sysInitTicks(); @@ -69,12 +77,12 @@ int main(int argc, const char **argv) audioInit(); romdataInit(); + gameLoadConfig(); + atexit(cleanup); bootCreateSched(); - osMemSize = configGetInt("Game.MemorySize", 16) * 1024 * 1024; - g_OsMemSize = osGetMemSize(); g_MempHeapSize = g_OsMemSize; diff --git a/port/src/video.c b/port/src/video.c index 6bf019229..17674ac80 100644 --- a/port/src/video.c +++ b/port/src/video.c @@ -21,8 +21,6 @@ static u32 frames = 0; static u32 framesPerSec = 0; static f64 startTime, endTime, fpsTime; -static f32 playerFovY = 60.f; - s32 videoInit(void) { wmAPI = &gfx_sdl; @@ -30,8 +28,6 @@ s32 videoInit(void) gfx_current_native_viewport.width = 320; gfx_current_native_viewport.height = 240; - playerFovY = configGetFloat("Video.FovY", 60.f); - const s32 w = configGetInt("Video.DefaultWidth", 640); const s32 h = configGetInt("Video.DefaultHeight", 480); const bool fs = configGetInt("Video.DefaultFullscreen", false); @@ -138,11 +134,6 @@ f32 videoGetAspect(void) return gfx_current_dimensions.aspect_ratio; } -f32 videoGetPlayerFovY(void) -{ - return playerFovY; -} - s32 videoCreateFramebuffer(u32 w, u32 h) { return gfx_create_framebuffer(w, h); diff --git a/src/game/bondgun.c b/src/game/bondgun.c index d46672ffa..a61a2c087 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -7496,12 +7496,12 @@ void bgunCreateFx(struct hand *hand, s32 handnum, struct weaponfunc *funcdef, s3 static inline f32 bgunGetFovOffsetZ(void) { - return (videoGetPlayerFovY() - 60.f) / 3.f; + return (g_PlayerDefaultFovY - 60.f) / 3.f; } static inline f32 bgunGetFovOffsetY(void) { - return (videoGetPlayerFovY() - 60.f) / (2.75f * 4.f); + return (g_PlayerDefaultFovY - 60.f) / (2.75f * 4.f); } #endif diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 1673d6edb..d36db1da1 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1653,7 +1653,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i #ifdef PLATFORM_N64 zoomfov = 60; #else - zoomfov = videoGetPlayerFovY(); + zoomfov = g_PlayerDefaultFovY; #endif // FarSight in secondary function @@ -1668,8 +1668,8 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i eraserfov = 60; } #else - if (eraserfov > videoGetPlayerFovY()) { - eraserfov = videoGetPlayerFovY(); + if (eraserfov > g_PlayerDefaultFovY) { + eraserfov = g_PlayerDefaultFovY; } #endif @@ -1711,7 +1711,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } #else if (zoomfov <= 0) { - zoomfov = videoGetPlayerFovY(); + zoomfov = g_PlayerDefaultFovY; } #endif @@ -1999,8 +1999,8 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i xscale = 1.f; yscale = 1.f; } - x = g_Vars.currentplayer->speedtheta * 0.3f * crosshairSway * xscale + g_Vars.currentplayer->gunextraaimx; - y = -g_Vars.currentplayer->speedverta * 0.1f * crosshairSway * yscale + g_Vars.currentplayer->gunextraaimy; + x = g_Vars.currentplayer->speedtheta * 0.3f * g_PlayerCrosshairSway * xscale + g_Vars.currentplayer->gunextraaimx; + y = -g_Vars.currentplayer->speedverta * 0.1f * g_PlayerCrosshairSway * yscale + g_Vars.currentplayer->gunextraaimy; #endif bgunSwivelWithDamp(x, y, PAL ? 0.955f : 0.963f); diff --git a/src/game/player.c b/src/game/player.c index e5028c148..5ff3d32a1 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -202,6 +202,11 @@ s16 g_DeathAnimations[] = { s32 g_NumDeathAnimations = 0; +#ifndef PLATFORM_N64 +f32 g_PlayerDefaultFovY = 60.f; +f32 g_PlayerCrosshairSway = 1.f; +#endif + /** * Choose which location to spawn into from the given pads. Write the position * and rooms to the dstpos and dstrooms pointers and return the angle that the @@ -2070,8 +2075,8 @@ void playerTweenFovY(f32 targetfovy) f32 speed = 15.0f / 30.0f; #ifndef PLATFORM_N64 - if (videoGetPlayerFovY() > 60.0f) { // adjust zoom speed depending on non-default fov setting (higher fov == faster zoom) - speed /= videoGetPlayerFovY() / 60.0f; + if (g_PlayerDefaultFovY > 60.0f) { // adjust zoom speed depending on non-default fov setting (higher fov == faster zoom) + speed /= g_PlayerDefaultFovY / 60.0f; } #endif @@ -2696,7 +2701,7 @@ Gfx *playerRenderHealthBar(Gfx *gdl) #ifdef PLATFORM_N64 mtx00016ae4(&matrix, 0, 370, 0, 0, 0, 0, 0, 0, -1); #else - f32 fovsc = 60.f / videoGetPlayerFovY(); + f32 fovsc = 60.f / g_PlayerDefaultFovY; if (fovsc > 1.01f) { fovsc *= 1.1f; } @@ -3150,7 +3155,7 @@ void playerConfigureVi(void) #ifdef PLATFORM_N64 playermgrSetFovY(60); #else - playermgrSetFovY(videoGetPlayerFovY()); + playermgrSetFovY(g_PlayerDefaultFovY); #endif playermgrSetAspectRatio(ratio); playermgrSetViewSize(playerGetViewportWidth(), playerGetViewportHeight()); @@ -3161,7 +3166,7 @@ void playerConfigureVi(void) #ifdef PLATFORM_N64 viSetFovAspectAndSize(60, ratio, playerGetViewportWidth(), playerGetViewportHeight()); #else - viSetFovAspectAndSize(videoGetPlayerFovY(), ratio, playerGetViewportWidth(), playerGetViewportHeight()); + viSetFovAspectAndSize(g_PlayerDefaultFovY, ratio, playerGetViewportWidth(), playerGetViewportHeight()); #endif viSetViewPosition(playerGetViewportLeft(), playerGetViewportTop()); @@ -3228,7 +3233,7 @@ void playerTick(bool arg0) #ifdef PLATFORM_N64 playermgrSetFovY(60); #else - playermgrSetFovY(videoGetPlayerFovY()); + playermgrSetFovY(g_PlayerDefaultFovY); #endif playermgrSetAspectRatio(aspectratio); playermgrSetViewSize(playerGetViewportWidth(), playerGetViewportHeight()); @@ -3238,7 +3243,7 @@ void playerTick(bool arg0) #ifdef PLATFORM_N64 viSetFovAspectAndSize(60, aspectratio, playerGetViewportWidth(), playerGetViewportHeight()); #else - viSetFovAspectAndSize(videoGetPlayerFovY(), aspectratio, playerGetViewportWidth(), playerGetViewportHeight()); + viSetFovAspectAndSize(g_PlayerDefaultFovY, aspectratio, playerGetViewportWidth(), playerGetViewportHeight()); #endif viSetViewPosition(playerGetViewportLeft(), playerGetViewportTop()); viSetSize(playerGetFbWidth(), playerGetFbHeight()); diff --git a/src/include/data.h b/src/include/data.h index df3ee8ed1..157c32120 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -528,5 +528,9 @@ extern struct menudialogdef g_HtDetailsMenuDialog; extern struct menudialogdef g_HtFailedMenuDialog; extern struct menudialogdef g_HtCompletedMenuDialog; extern struct menudialogdef g_HangarListMenuDialog; +#ifndef PLATFORM_N64 +extern f32 g_PlayerCrosshairSway; +extern f32 g_PlayerDefaultFovY; +#endif #endif diff --git a/src/include/game/bondmove.h b/src/include/game/bondmove.h index beb4f75c5..7733b613f 100644 --- a/src/include/game/bondmove.h +++ b/src/include/game/bondmove.h @@ -4,10 +4,6 @@ #include "data.h" #include "types.h" -#ifndef PLATFORM_N64 -extern f32 crosshairSway; -#endif - void bmoveSetControlDef(u32 controldef); void bmoveSetAutoMoveCentreEnabled(bool enabled); void bmoveSetAutoAimY(bool enabled);