diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..d37de28e9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,32 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# Top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# Matches all C source files +[*.c] +indent_style = tab +tab_width = 2 +charset = utf-8 +trim_trailing_whitespace = true + +# Matches all header files +[*.h] +indent_style = tab +tab_width = 2 +charset = utf-8 +trim_trailing_whitespace = true + +# Matches Makefiles +[Makefile] +indent_style = tab + +# Matches Markdown files +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/port/fast3d/gfx_sdl2.cpp b/port/fast3d/gfx_sdl2.cpp index c6b67eebb..043a7e2f2 100644 --- a/port/fast3d/gfx_sdl2.cpp +++ b/port/fast3d/gfx_sdl2.cpp @@ -83,7 +83,6 @@ static void gfx_sdl_init(const struct GfxWindowInitSettings *set) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); if (sysArgCheck("--debug-gl")) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); } @@ -100,7 +99,8 @@ static void gfx_sdl_init(const struct GfxWindowInitSettings *set) { fullscreen_flag = SDL_WINDOW_FULLSCREEN; } - Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL; + // we will unhide the window once the GL context is successfully created + Uint32 flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL; // if fullscreen was requested, start the window in fullscreen right away if (set->fullscreen) { @@ -119,11 +119,6 @@ static void gfx_sdl_init(const struct GfxWindowInitSettings *set) { } #endif - wnd = SDL_CreateWindow(set->title, posX, posY, window_width, window_height, flags); - if (!wnd) { - sysFatalError("Could not open SDL window:\n%s", SDL_GetError()); - } - // ideally we need 3.0 compat // if that doesn't work, try 3.2 core in case we're on mac, 2.1 compat as a last resort static u32 glver[][3] = { @@ -152,32 +147,42 @@ static void gfx_sdl_init(const struct GfxWindowInitSettings *set) { ctx = NULL; u32 vmin = 0, vmaj = 0, vprof = SDL_GL_CONTEXT_PROFILE_COMPATIBILITY; const char *vprofstr = ""; - for (u32 i = verstart; i < verend; ++i) { + for (u32 i = verstart; i < verend && !ctx; ++i) { vmaj = glver[i][0]; vmin = glver[i][1]; vprof = glver[i][2]; - vprofstr = (glver[i][2] == SDL_GL_CONTEXT_PROFILE_CORE ? "core" : - (glver[i][2] == SDL_GL_CONTEXT_PROFILE_ES ? "es" : "")); + vprofstr = (vprof == SDL_GL_CONTEXT_PROFILE_CORE ? "core" : + (vprof == SDL_GL_CONTEXT_PROFILE_ES ? "es" : "")); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, vmaj); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, vmin); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, glver[i][2]); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, vprof); + + wnd = SDL_CreateWindow(set->title, posX, posY, window_width, window_height, flags); + if (!wnd) { + sysLogPrintf(LOG_WARNING, "SDL: could not open SDL window for GL%d.%d%s:\n%s", vmaj, vmin, vprofstr, SDL_GetError()); + continue; + } + ctx = SDL_GL_CreateContext(wnd); if (!ctx) { - sysLogPrintf(LOG_WARNING, "GL: could not create GL%d.%d%s context: %s", vmaj, vmin, vprofstr, SDL_GetError()); - } else { - break; + sysLogPrintf(LOG_WARNING, "SDL: could not create GL%d.%d%s context: %s", vmaj, vmin, vprofstr, SDL_GetError()); + SDL_DestroyWindow(wnd); + wnd = nullptr; } } - if (!ctx) { - sysFatalError("Could not create an OpenGL context of any supported version.\nSDL error: %s", SDL_GetError()); + if (!wnd || !ctx) { + sysFatalError("Could not open SDL window with an OpenGL context of any supported version:\n%s", SDL_GetError()); } else { - sysLogPrintf(LOG_NOTE, "GL: created GL%d.%d%s context", vmaj, vmin, vprofstr); + sysLogPrintf(LOG_NOTE, "SDL: created GL%d.%d%s context", vmaj, vmin, vprofstr); } SDL_GL_MakeCurrent(wnd, ctx); SDL_GL_SetSwapInterval(1); + SDL_ShowWindow(wnd); + qpc_freq = SDL_GetPerformanceFrequency(); } diff --git a/port/src/input.c b/port/src/input.c index 6a68b4b73..407a30a11 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -820,8 +820,12 @@ static inline void inputUpdateMouse(void) mouseWheel = 0; + s32 mdx = 0; + s32 mdy = 0; + SDL_GetRelativeMouseState(&mdx, &mdy); if (mouseLocked) { - SDL_GetRelativeMouseState(&mouseDX, &mouseDY); + mouseDX = mdx; + mouseDY = mdy; } else { mouseDX = mx - mouseX; mouseDY = my - mouseY; diff --git a/port/src/optionsmenu.c b/port/src/optionsmenu.c index 2b845ebe0..91353705b 100644 --- a/port/src/optionsmenu.c +++ b/port/src/optionsmenu.c @@ -9,6 +9,7 @@ #include "game/mainmenu.h" #include "game/menu.h" #include "game/gamefile.h" +#include "game/player.h" #include "video.h" #include "input.h" #include "config.h" @@ -169,15 +170,17 @@ static MenuItemHandlerResult menuhandlerMouseSpeedX(s32 operation, struct menuit if (x < 0.f) { data->slider.value = 0; } else if (x > 10.f) { - data->slider.value = 100; + data->slider.value = 1000; } else { - data->slider.value = x * 10.f + 0.5f; + data->slider.value = x * 100.f + 0.5f; } break; case MENUOP_SET: inputMouseGetSpeed(&x, &y); - inputMouseSetSpeed((f32)data->slider.value / 10.f, y); + inputMouseSetSpeed((f32)data->slider.value / 100.f, y); break; + case MENUOP_GETSLIDERLABEL: + sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f); } return 0; @@ -193,15 +196,17 @@ static MenuItemHandlerResult menuhandlerMouseSpeedY(s32 operation, struct menuit if (y < 0.f) { data->slider.value = 0; } else if (y > 10.f) { - data->slider.value = 100; + data->slider.value = 1000; } else { - data->slider.value = y * 10.f + 0.5f; + data->slider.value = y * 100.f + 0.5f; } break; case MENUOP_SET: inputMouseGetSpeed(&x, &y); - inputMouseSetSpeed(x, (f32)data->slider.value / 10.f); + inputMouseSetSpeed(x, (f32)data->slider.value / 100.f); break; + case MENUOP_GETSLIDERLABEL: + sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f); } return 0; @@ -214,14 +219,16 @@ static MenuItemHandlerResult menuhandlerMouseAimSpeedX(s32 operation, struct men if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx < 0.f) { data->slider.value = 0; } else if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx > 10.f) { - data->slider.value = 100; + data->slider.value = 1000; } else { - data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx * 10.f + 0.5f; + data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx * 100.f + 0.5f; } break; case MENUOP_SET: - g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx = (f32)data->slider.value / 10.f; + g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx = (f32)data->slider.value / 100.f; break; + case MENUOP_GETSLIDERLABEL: + sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f); } return 0; @@ -234,14 +241,16 @@ static MenuItemHandlerResult menuhandlerMouseAimSpeedY(s32 operation, struct men if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy < 0.f) { data->slider.value = 0; } else if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy > 10.f) { - data->slider.value = 100; + data->slider.value = 1000; } else { - data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy * 10.f + 0.5f; + data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy * 100.f + 0.5f; } break; case MENUOP_SET: - g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy = (f32)data->slider.value / 10.f; + g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy = (f32)data->slider.value / 100.f; break; + case MENUOP_GETSLIDERLABEL: + sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f); } return 0; @@ -254,14 +263,16 @@ static MenuItemHandlerResult menuhandlerRadialMenuSpeed(s32 operation, struct me if (g_PlayerExtCfg[0].radialmenuspeed < 0.f) { data->slider.value = 0; } else if (g_PlayerExtCfg[0].radialmenuspeed > 10.f) { - data->slider.value = 100; + data->slider.value = 1000; } else { - data->slider.value = g_PlayerExtCfg[0].radialmenuspeed * 10.f + 0.5f; + data->slider.value = g_PlayerExtCfg[0].radialmenuspeed * 100.f + 0.5f; } break; case MENUOP_SET: - g_PlayerExtCfg[0].radialmenuspeed = (f32)data->slider.value / 10.f; + g_PlayerExtCfg[0].radialmenuspeed = (f32)data->slider.value / 100.f; break; + case MENUOP_GETSLIDERLABEL: + sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f); } return 0; @@ -313,7 +324,7 @@ struct menuitem g_ExtendedMouseMenuItems[] = { 0, MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE, (uintptr_t)"Mouse Speed X", - 100, + 1000, menuhandlerMouseSpeedX, }, { @@ -321,7 +332,7 @@ struct menuitem g_ExtendedMouseMenuItems[] = { 0, MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE, (uintptr_t)"Mouse Speed Y", - 100, + 1000, menuhandlerMouseSpeedY, }, { @@ -329,7 +340,7 @@ struct menuitem g_ExtendedMouseMenuItems[] = { 0, MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE, (uintptr_t)"Crosshair Speed X", - 100, + 1000, menuhandlerMouseAimSpeedX, }, { @@ -337,7 +348,7 @@ struct menuitem g_ExtendedMouseMenuItems[] = { 0, MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE, (uintptr_t)"Crosshair Speed Y", - 100, + 1000, menuhandlerMouseAimSpeedY, }, { @@ -345,7 +356,7 @@ struct menuitem g_ExtendedMouseMenuItems[] = { 0, MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE, (uintptr_t)"Radial Menu Speed", - 100, + 1000, menuhandlerRadialMenuSpeed, }, { @@ -990,6 +1001,7 @@ static MenuItemHandlerResult menuhandlerFieldOfView(s32 operation, struct menuit g_PlayerExtCfg[g_ExtMenuPlayer].fovy = data->slider.value; if (g_PlayerExtCfg[g_ExtMenuPlayer].fovzoom) { g_PlayerExtCfg[g_ExtMenuPlayer].fovzoommult = g_PlayerExtCfg[g_ExtMenuPlayer].fovy / 60.f; + playerClampGunZoomFovY(g_ExtMenuPlayer); } } break; diff --git a/port/src/pdmain.c b/port/src/pdmain.c index f6581551f..c17e6b444 100644 --- a/port/src/pdmain.c +++ b/port/src/pdmain.c @@ -228,6 +228,8 @@ void mainInit(void) joyInit(); joyReset(); + var8005d9b0 = rmonIsDisabled(); + g_Is4Mb = (osGetMemSize() <= 0x400000); g_VmShowStats = 0; diff --git a/port/src/preprocess/filebg.c b/port/src/preprocess/filebg.c index 6ff407310..56b750e4a 100644 --- a/port/src/preprocess/filebg.c +++ b/port/src/preprocess/filebg.c @@ -224,7 +224,7 @@ static void convertPrimaryLights(u8 *dst, u32 *dstpos, u8 *src, u32 *srcpos, u32 } *srcpos += sizeof(*n64_lights) * num_lights; - *dstpos += sizeof(*host_lights) * num_lights; + *dstpos += ALIGN(sizeof(*host_lights) * num_lights, 4); } #define BLOCK_LEAF 0 diff --git a/port/src/system.c b/port/src/system.c index f732af311..bea07ab46 100644 --- a/port/src/system.c +++ b/port/src/system.c @@ -41,7 +41,7 @@ __attribute__((dllexport)) u32 AmdPowerXpressRequestHighPerformance = 1; // but if it doesn't we'll have to use __builtin_ia32_pause() or something #include #define DO_YIELD() _mm_pause() -#elif defined(PLATFORM_ARM) +#elif defined(PLATFORM_ARM) && (defined(PLATFORM_64BIT) || PLATFORM_ARM == 7 || PLATFORM_ARM == 8) // same as YieldProcessor() on ARM Windows #define DO_YIELD() __asm__ volatile("dmb ishst\n\tyield":::"memory") #else diff --git a/src/game/bondmove.c b/src/game/bondmove.c index bd0428a34..3d69918b8 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -2402,8 +2402,10 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i #ifndef PLATFORM_N64 if (allowmcross) { // joystick is inactive, move crosshair using the mouse - const f32 xscale = PLAYER_EXTCFG().mouseaimspeedx * 320.f / (f32)videoGetWidth(); - const f32 yscale = PLAYER_EXTCFG().mouseaimspeedy * 240.f / (f32)videoGetHeight(); + const f32 xcoeff = 320.f / 1080.f; + const f32 ycoeff = 240.f / 1080.f; + const f32 xscale = (PLAYER_EXTCFG().mouseaimspeedx * xcoeff) / g_Vars.currentplayer->aspect; + const f32 yscale = PLAYER_EXTCFG().mouseaimspeedy * ycoeff; f32 x = g_Vars.currentplayer->swivelpos[0] + movedata.freelookdx * xscale; f32 y = g_Vars.currentplayer->swivelpos[1] + movedata.freelookdy * yscale; x = (x < -1.f) ? -1.f : ((x > 1.f) ? 1.f : x); diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index fbd4ed95e..4f6dedf6b 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -5952,7 +5952,7 @@ bool aiSetTarget(void) */ bool aiIfPresetsTargetIsNotMyTarget(void) { - s32 mypresetchrstarget; + s32 mypresetchrstarget = -1; u8 *cmd = g_Vars.ailist + g_Vars.aioffset; if (g_Vars.chrdata->chrpreset1 != -1) { diff --git a/src/game/credits.c b/src/game/credits.c index e47cca554..f95fbdf96 100644 --- a/src/game/credits.c +++ b/src/game/credits.c @@ -24,6 +24,9 @@ #include "lib/vi.h" #include "data.h" #include "types.h" +#ifndef PLATFORM_N64 +#include "input.h" +#endif /** * Credits @@ -1876,11 +1879,22 @@ Gfx *creditsDraw(Gfx *gdl) } } - // Exit the alternative title if a button is pressed (other than L or R) +#ifdef PLATFORM_N64 #if VERSION >= VERSION_NTSC_1_0 + // Exit the alternative title if a button is pressed (other than L or R) if (g_CreditsUsingAltTitle && joyGetButtonsPressedThisFrame(0, 0xffcf)) #else if (g_CreditsUsingAltTitle && joyGetButtons(0, 0xffff)) +#endif +#else +#if VERSION >= VERSION_NTSC_1_0 + // Exit to CI if a button is pressed (other than L or R), for the port + if (joyGetButtonsPressedThisFrame(0, 0xffcf) || + inputKeyJustPressed(VK_ESCAPE)) +#else + if (joyGetButtons(0, 0xffff) || + inputKeyJustPressed(VK_ESCAPE)) +#endif #endif { g_TitleNextStage = STAGE_CITRAINING; diff --git a/src/game/filemgr.c b/src/game/filemgr.c index 389f793ad..2246542db 100644 --- a/src/game/filemgr.c +++ b/src/game/filemgr.c @@ -913,7 +913,7 @@ const char var7f1b31ec[] = "Multiplayer %d was using that file...\n"; * * Return true if it worked, otherwise false. */ -bool filemgrSaveOrLoad(struct fileguid *guid, s32 fileop, u32 playernum) +bool filemgrSaveOrLoad(struct fileguid *guid, s32 fileop, uintptr_t playernum) { s32 device; diff --git a/src/game/gamefile.c b/src/game/gamefile.c index a8a3f8dd6..6718302dd 100644 --- a/src/game/gamefile.c +++ b/src/game/gamefile.c @@ -578,7 +578,7 @@ void gamefileGetOverview(char *arg0, char *name, u8 *stage, u8 *difficulty, u32 { struct savebuffer buffer; - func0f0d5484(&buffer, arg0, 15); + savebufferWriteData(&buffer, arg0, 15); savebufferReadString(&buffer, name, false); *stage = savebufferReadBits(&buffer, 5); diff --git a/src/game/gfxmemory.c b/src/game/gfxmemory.c index 0b34f71d3..2f44f0206 100644 --- a/src/game/gfxmemory.c +++ b/src/game/gfxmemory.c @@ -36,6 +36,15 @@ * marker for the end of the second element's allocation. */ +/** + * On 64-bit platforms the Gfx struct is twice as large. +*/ +#ifdef PLATFORM_64BIT +#define GFX_SIZE_MULTIPLIER 2 +#else +#define GFX_SIZE_MULTIPLIER 1 +#endif + u8 *g_GfxBuffers[NUM_GFXTASKS + 1]; u32 var800aa58c; u8 *g_VtxBuffers[NUM_GFXTASKS + 1]; @@ -44,15 +53,15 @@ u8 g_GfxActiveBufferIndex; u32 g_GfxRequestedDisplayList; u32 g_GfxSizesByPlayerCount[] = { - 0x00010000, - 0x00018000, - 0x00020000, - 0x00028000, + 0x00010000 * GFX_SIZE_MULTIPLIER, + 0x00018000 * GFX_SIZE_MULTIPLIER, + 0x00020000 * GFX_SIZE_MULTIPLIER, + 0x00028000 * GFX_SIZE_MULTIPLIER, #ifndef PLATFORM_N64 - 0x00030000, - 0x00038000, - 0x00040000, - 0x00048000, + 0x00030000 * GFX_SIZE_MULTIPLIER, + 0x00038000 * GFX_SIZE_MULTIPLIER, + 0x00040000 * GFX_SIZE_MULTIPLIER, + 0x00048000 * GFX_SIZE_MULTIPLIER, #endif }; @@ -106,12 +115,16 @@ void gfxReset(void) // ******** Original Amount required = %dK ber buffer\n // ******** Extra Amount required = %dK ber buffer\n // ******** Total of %dK (Double Buffered)\n +<<<<<<< HEAD g_GfxSizesByPlayerCount[PLAYERCOUNT() - 1] = gfx + gfxtra; #ifndef PLATFORM_N64 if (PLAYERCOUNT() > MAX_LOCAL_PLAYERS) { g_GfxSizesByPlayerCount[PLAYERCOUNT() - 1] *= MAX_PLAYERS / MAX_LOCAL_PLAYERS; } #endif +======= + g_GfxSizesByPlayerCount[PLAYERCOUNT() - 1] = (gfx + gfxtra) * GFX_SIZE_MULTIPLIER; +>>>>>>> 49cd478622e3fefdd5c60fbd314ef8185d0cbf9d } if (argFindByPrefix(1, "-mvtx")) { diff --git a/src/game/menu.c b/src/game/menu.c index c1552bb59..32f4a91f0 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -4537,7 +4537,7 @@ void dialogTick(struct menudialog *dialog, struct menuinputs *inputs, u32 tickfl if ((dialog->focuseditem->flags & MENUITEMFLAG_00010000) == 0) { #ifndef PLATFORM_N64 - if (g_MenuUsingMouse) { + if (g_MenuUsingMouse && !dialog->dimmed) { dstscroll = dialog->dstscroll - inputs->mousescroll * LINEHEIGHT; } else #endif diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index 035e0bf71..9449cfe8b 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -3650,7 +3650,7 @@ void mpplayerfileGetOverview(char *arg0, char *name, u32 *playtime) { struct savebuffer buffer; - func0f0d5484(&buffer, arg0, 15); + savebufferWriteData(&buffer, arg0, 15); savebufferReadString(&buffer, name, 0); *playtime = savebufferReadBits(&buffer, 28); @@ -4018,7 +4018,7 @@ void mpsetupfileGetOverview(char *arg0, char *filename, u16 *numsims, u16 *stage { struct savebuffer buffer; - func0f0d5484(&buffer, arg0, 15); + savebufferWriteData(&buffer, arg0, 15); savebufferReadString(&buffer, filename, 0); diff --git a/src/game/player.c b/src/game/player.c index 9b8646793..e43993eb2 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -2123,6 +2123,22 @@ f32 playerGetCutsceneBlurFrac(void) return g_CutsceneBlurFrac; } +void playerClampGunZoomFovY(s32 playernum) +{ + struct player *player = g_Vars.players[playernum]; + if (!player) { + return; + } + + for (s32 index = 0; index < ARRAYCOUNT(player->gunzoomfovs); ++index) { + if (player->gunzoomfovs[index] < ADJUST_ZOOM_FOV(2)) { + player->gunzoomfovs[index] = ADJUST_ZOOM_FOV(2); + } else if (player->gunzoomfovs[index] > ADJUST_ZOOM_FOV(60)) { + player->gunzoomfovs[index] = ADJUST_ZOOM_FOV(60); + } + } +} + void playerSetZoomFovY(f32 fovy, f32 timemax) { g_Vars.currentplayer->zoomintime = 0; @@ -3133,6 +3149,9 @@ void playerAutoWalk(s16 aimpad, u8 walkspeed, u8 turnspeed, u8 lookup, u8 dist) { playerSetTickMode(TICKMODE_AUTOWALK); + // Prevents momentum from being preserved. Fixes potential softlock during The Duel. + g_Vars.currentplayer->resetheadpos = true; + g_Vars.currentplayer->autocontrol_aimpad = aimpad; g_Vars.currentplayer->autocontrol_walkspeed = walkspeed; g_Vars.currentplayer->autocontrol_turnspeed = turnspeed; diff --git a/src/game/savebuffer.c b/src/game/savebuffer.c index 48255d723..f9d4705fd 100644 --- a/src/game/savebuffer.c +++ b/src/game/savebuffer.c @@ -459,7 +459,7 @@ void savebufferClear(struct savebuffer *buffer) } } -void func0f0d5484(struct savebuffer *buffer, u8 *data, u8 len) +void savebufferWriteData(struct savebuffer *buffer, u8 *data, u8 len) { s32 i; @@ -536,7 +536,7 @@ void func0f0d564c(u8 *data, char *dst, bool addlinebreak) { struct savebuffer buffer; - func0f0d5484(&buffer, data, 10); + savebufferWriteData(&buffer, data, 10); savebufferReadString(&buffer, dst, addlinebreak); } @@ -547,7 +547,7 @@ void func0f0d5690(u8 *dst, char *src) bool done = false; s32 i; - func0f0d5484(&buffer, dst, 10); + savebufferWriteData(&buffer, dst, 10); for (i = 0; i < 10; i++) { if (!done) { diff --git a/src/include/game/filemgr.h b/src/include/game/filemgr.h index 80695df9d..389299af2 100644 --- a/src/include/game/filemgr.h +++ b/src/include/game/filemgr.h @@ -25,7 +25,7 @@ void filemgrEraseCorruptFile(void); char *filemgrMenuTextInsertOriginalPak(struct menuitem *item); void filemgrRetrySave(s32 arg0); bool filemgrAttemptOperation(s32 device, bool closeonsuccess); -bool filemgrSaveOrLoad(struct fileguid *guid, s32 fileop, u32 playernum); +bool filemgrSaveOrLoad(struct fileguid *guid, s32 fileop, uintptr_t playernum); void filemgrDeleteCurrentFile(void); void func0f1097d0(s32 device); void filemgrSaveGameToDevice(s32 device); diff --git a/src/include/game/player.h b/src/include/game/player.h index 5783f579c..9b0a92f8f 100644 --- a/src/include/game/player.h +++ b/src/include/game/player.h @@ -21,6 +21,7 @@ void playerStartCutscene(s16 anim_id); void playerReorientForCutsceneStop(s32 tweenduration60); void playerTickCutscene(bool arg0); f32 playerGetCutsceneBlurFrac(void); +void playerClampGunZoomFovY(s32 playernum); void playerSetZoomFovY(f32 fovy, f32 timemax); f32 playerGetZoomFovY(void); void playerTweenFovY(f32 targetfovy); diff --git a/src/include/game/savebuffer.h b/src/include/game/savebuffer.h index 3975a51c0..9529248ce 100644 --- a/src/include/game/savebuffer.h +++ b/src/include/game/savebuffer.h @@ -15,7 +15,7 @@ void savebufferOr(struct savebuffer *buffer, u32 arg1, s32 arg2); void savebufferWriteBits(struct savebuffer *buffer, u32 value, s32 numbits, u8 *dst); u32 savebufferReadBits(struct savebuffer *buffer, s32 offset); void savebufferClear(struct savebuffer *buffer); -void func0f0d5484(struct savebuffer *buffer, u8 *data, u8 len); +void savebufferWriteData(struct savebuffer *buffer, u8 *data, u8 len); void func0f0d54c4(struct savebuffer *buffer); void savebufferReadString(struct savebuffer *buffer, char *dst, bool addlinebreak); void func0f0d55a4(struct savebuffer *buffer, char *src); diff --git a/src/include/types.h b/src/include/types.h index f91ca5862..6d0b5ea50 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -3822,7 +3822,7 @@ struct menudata_filemgr { /*0xe42*/ u8 fileop; union { void *unke44; - s32 mpplayernum; + intptr_t mpplayernum; }; /*0xe48*/ u32 fileid; /*0xe4c*/ u32 deviceserial; diff --git a/src/lib/mema.c b/src/lib/mema.c index d0676ccff..62adbd6ed 100644 --- a/src/lib/mema.c +++ b/src/lib/mema.c @@ -39,7 +39,7 @@ struct memaspace { uintptr_t addr; - u64 size; + uintptr_t size; }; /** @@ -56,7 +56,7 @@ struct memaheap { }; uintptr_t g_MemaHeapStart; -u64 g_MemaHeapSize; +uintptr_t g_MemaHeapSize; struct memaheap g_MemaHeap; #if VERSION == VERSION_PAL_BETA @@ -125,7 +125,7 @@ struct memaspace *memaMakeSlot(struct memaheap *heap) { struct memaspace *curr = &heap->spaces[0]; struct memaspace *best; - u32 min; + uintptr_t min; s32 i; // Do 124 passes over the list. This ensures the list is in order by the @@ -162,7 +162,7 @@ struct memaspace *memaMakeSlot(struct memaheap *heap) // Find the smallest run of free space and use that instead. // The caller will overwrite it with its own free allocation, causing the // original run of free space to be unusable until the mema heap is reset. - min = 0xffffffff; + min = (uintptr_t)-1; best = curr; while (curr <= &heap->spaces[MAX_SPACES - 1]) { @@ -193,7 +193,7 @@ void _memaFree(uintptr_t addr, u64 size) } // If we reached the end of the spaces list, go backwards instead - if (curr->addr == -1) { + if (curr->addr == (uintptr_t)-1) { curr = &g_MemaHeap.spaces[index]; while (curr->size != 0) { @@ -235,10 +235,10 @@ void memaReset(void *heapaddr, u64 heapsize) g_MemaHeap.start.addr = 0; g_MemaHeap.start.size = 0; - g_MemaHeap.end1.addr = 0xffffffff; + g_MemaHeap.end1.addr = (uintptr_t)-1; g_MemaHeap.end1.size = 0; - g_MemaHeap.end2.addr = 0xffffffff; - g_MemaHeap.end2.size = 0xffffffff; + g_MemaHeap.end2.addr = (uintptr_t)-1; + g_MemaHeap.end2.size = (uintptr_t)-1; for (space = &g_MemaHeap.spaces[0]; space <= &g_MemaHeap.spaces[MAX_SPACES - 1]; space++) { space->addr = 0; @@ -411,7 +411,7 @@ void *memaAlloc(u64 size) if (1); curr = &g_MemaHeap.spaces[0]; - bestdiff = 0xffffffff; + bestdiff = (uintptr_t)-1; best = NULL; // Iterate up to the first 16 spaces, looking for the @@ -421,7 +421,7 @@ void *memaAlloc(u64 size) continue; } - if (curr->addr == 0xffffffff) { + if (curr->addr == (uintptr_t)-1) { // Reached the end break; } @@ -446,13 +446,13 @@ void *memaAlloc(u64 size) if (best == NULL) { // Keep iterating until we find a space that is big enough to fit. - // The last space is marked as size 0xffffffff which prevents this loop + // The last space is marked as size -1 which prevents this loop // from iterating past the end of the spaces array. while (curr->size < size) { curr++; } - if (curr->addr == 0xffffffff) { + if (curr->addr == (uintptr_t)-1) { // There was no space, so attempt to free up some space // by doing several defrag passes for (i = 0; i < 8; i++) { @@ -465,7 +465,7 @@ void *memaAlloc(u64 size) curr++; } - if (curr->addr == 0xffffffff) { + if (curr->addr == (uintptr_t)-1) { return NULL; } } @@ -491,7 +491,7 @@ uintptr_t memaGrow(uintptr_t addr, u64 amount) { struct memaspace *curr = &g_MemaHeap.spaces[0]; - while (curr->addr != -1) { + while (curr->addr != (uintptr_t)-1) { if (curr->addr == addr && curr->size >= amount) { goto found; } @@ -535,7 +535,7 @@ u64 memaGetLongestFree(void) curr = &g_MemaHeap.spaces[0]; - while (curr->addr != -1) { + while (curr->addr != (uintptr_t)-1) { if (curr->size > biggest) { biggest = curr->size; }