From fe114133ff18ea4cd42cf61726fbd08c04f854fb Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Sun, 30 Jun 2024 20:55:47 -0400 Subject: [PATCH] Fix headless compilation and do some formatting --- Makefile | 6 ++++ actors/burn_smoke/model.inc.c | 6 ++-- actors/koopa/model.inc.c | 6 ++-- src/game/bettercamera.inc.h | 40 +++++++++++----------- src/game/ingame_menu.c | 16 ++++----- src/game/mario_actions_cutscene.c | 4 +-- src/menu/file_select.c | 6 ++-- src/pc/controller/controller_entry_point.c | 4 +-- src/pc/controller/controller_mouse.c | 38 ++++++++------------ src/pc/djui/djui_panel_mod_menu.c | 1 + src/pc/gfx/gfx_sdl2.c | 4 +-- src/pc/lua/utils/smlua_misc_utils.c | 1 + src/pc/platform.c | 6 ++-- 13 files changed, 68 insertions(+), 70 deletions(-) diff --git a/Makefile b/Makefile index 49d95ee3..5488b98c 100644 --- a/Makefile +++ b/Makefile @@ -753,6 +753,12 @@ else ifeq ($(findstring SDL,$(WINDOW_API)),SDL) endif endif +ifeq ($(WINDOW_API),DUMMY) + ifeq ($(WINDOWS_BUILD),1) + BACKEND_LDFLAGS += -lole32 -luuid -lshlwapi + endif +endif + ifneq (,$(findstring SDL2,$(AUDIO_API)$(WINDOW_API)$(CONTROLLER_API))) SDL2_USED := 1 endif diff --git a/actors/burn_smoke/model.inc.c b/actors/burn_smoke/model.inc.c index 938cb920..d63d9120 100644 --- a/actors/burn_smoke/model.inc.c +++ b/actors/burn_smoke/model.inc.c @@ -41,11 +41,11 @@ const Gfx burn_smoke_seg4_dl_04022048[] = { // 0x04022070 - 0x040220C8 const Gfx burn_smoke_seg4_dl_04022070[] = { gsSPDisplayList(burn_smoke_seg4_dl_04022000), - #ifdef TEXTURE_FIX +#ifdef TEXTURE_FIX gsDPLoadTextureBlock(burn_smoke_seg4_texture_04021800, G_IM_FMT_IA, G_IM_SIZ_16b, 32, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 5, 5, G_TX_NOLOD, G_TX_NOLOD), - #else +#else gsDPLoadTextureBlock(burn_smoke_seg4_texture_04021800, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 5, 5, G_TX_NOLOD, G_TX_NOLOD), - #endif +#endif gsSPDisplayList(burn_smoke_seg4_dl_04022028), gsSPDisplayList(burn_smoke_seg4_dl_04022048), gsSPEndDisplayList(), diff --git a/actors/koopa/model.inc.c b/actors/koopa/model.inc.c index 2320b51d..c34dca19 100644 --- a/actors/koopa/model.inc.c +++ b/actors/koopa/model.inc.c @@ -1036,13 +1036,13 @@ const Gfx koopa_seg6_dl_0600C498[] = { gsSPVertex(koopa_seg6_vertex_0600B560, 9, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP1Triangle( 6, 7, 8, 0x0), - #ifdef TEXTURE_FIX +#ifdef TEXTURE_FIX gsSPLight(&koopa_seg6_lights_06002630.l, 1), gsSPLight(&koopa_seg6_lights_06002630.a, 2), - #else +#else gsSPLight((u8*)koopa_seg6_texture_06002648 + 0x20, 1), //! this malformed light results in a gsSPLight((u8*)koopa_seg6_texture_06002648 + 0x18, 2), //! koopa appearing to wear pink shorts. - #endif +#endif gsSPVertex(koopa_seg6_vertex_0600B5F0, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 6, 7, 0, 0x0, 8, 5, 9, 0x0), diff --git a/src/game/bettercamera.inc.h b/src/game/bettercamera.inc.h index ac5c4526..03b3963c 100644 --- a/src/game/bettercamera.inc.h +++ b/src/game/bettercamera.inc.h @@ -290,18 +290,18 @@ static void newcam_rotate_button(void) { if ((newcam_modeflags & NC_FLAG_8D || newcam_modeflags & NC_FLAG_4D) && newcam_modeflags & NC_FLAG_XTURN) { //8 directional camera rotation input for buttons. if ((gPlayer1Controller->buttonPressed & L_CBUTTONS) && newcam_analogue == 0) { - #ifndef nosound +#ifndef nosound play_sound(SOUND_MENU_CAMERA_TURN, gGlobalSoundSource); - #endif +#endif if (newcam_modeflags & NC_FLAG_8D) newcam_yaw_target = newcam_yaw_target+(ivrt(0)*0x2000); else newcam_yaw_target = newcam_yaw_target+(ivrt(0)*0x4000); newcam_centering = 1; } else if ((gPlayer1Controller->buttonPressed & R_CBUTTONS) && newcam_analogue == 0) { - #ifndef nosound +#ifndef nosound play_sound(SOUND_MENU_CAMERA_TURN, gGlobalSoundSource); - #endif +#endif if (newcam_modeflags & NC_FLAG_8D) newcam_yaw_target = newcam_yaw_target-(ivrt(0)*0x2000); else @@ -315,11 +315,11 @@ static void newcam_rotate_button(void) { } else if ((gPlayer1Controller->buttonDown & R_CBUTTONS) && newcam_analogue == 0) { newcam_yaw_acc = newcam_adjust_value(newcam_yaw_acc, accel, 100); } else if (!newcam_analogue) { - #ifdef noaccel +#ifdef noaccel newcam_yaw_acc = 0; - #else +#else newcam_yaw_acc -= (newcam_yaw_acc*((f32)newcam_degrade/100)); - #endif +#endif } } @@ -328,11 +328,11 @@ static void newcam_rotate_button(void) { } else if (gPlayer1Controller->buttonDown & D_CBUTTONS && newcam_modeflags & NC_FLAG_YTURN && newcam_analogue == 0) { newcam_tilt_acc = newcam_adjust_value(newcam_tilt_acc, -accel, -100); } else if (!newcam_analogue) { - #ifdef noaccel +#ifdef noaccel newcam_tilt_acc = 0; - #else +#else newcam_tilt_acc -= (newcam_tilt_acc*((f32)newcam_degrade/100)); - #endif +#endif } newcam_framessincec[0] ++; @@ -341,9 +341,9 @@ static void newcam_rotate_button(void) { if (newcam_framessincec[0] < 6) { newcam_yaw_target = newcam_yaw+(ivrt(0)*0x3000); newcam_centering = 1; - #ifndef nosound +#ifndef nosound play_sound(SOUND_MENU_CAMERA_TURN, gGlobalSoundSource); - #endif +#endif } newcam_framessincec[0] = 0; } @@ -351,9 +351,9 @@ static void newcam_rotate_button(void) { if (newcam_framessincec[1] < 6) { newcam_yaw_target = newcam_yaw-(ivrt(0)*0x3000); newcam_centering = 1; - #ifndef nosound +#ifndef nosound play_sound(SOUND_MENU_CAMERA_TURN, gGlobalSoundSource); - #endif +#endif } newcam_framessincec[1] = 0; } @@ -370,9 +370,9 @@ static void newcam_rotate_button(void) { if (newcam_cstick_down == 0) { newcam_cstick_down = 1; newcam_centering = 1; - #ifndef nosound +#ifndef nosound play_sound(SOUND_MENU_CAMERA_TURN, gGlobalSoundSource); - #endif +#endif if (newcam_stick2[0] > 20) { if (newcam_modeflags & NC_FLAG_8D) newcam_yaw_target = newcam_yaw_target+(ivrt(0)*0x2000); @@ -424,9 +424,9 @@ static void newcam_zoom_button(void) { newcam_centering = 1; } else if (gPlayer1Controller->buttonPressed & R_TRIG && newcam_modeflags & NC_FLAG_XTURN) { //Each time the player presses R, but NOT L the camera zooms out more, until it hits the limit and resets back to close view. - #ifndef nosound +#ifndef nosound play_sound(SOUND_MENU_CLICK_CHANGE_VIEW, gGlobalSoundSource); - #endif +#endif if (newcam_distance_target == newcam_distance_values[0]) newcam_distance_target = newcam_distance_values[1]; @@ -796,7 +796,7 @@ void newcam_loop(struct Camera *c) { newcam_fade_target_closeup(); //Just some visual information on the values of the camera. utilises ifdef because it's better at runtime. - #ifdef NEWCAM_DEBUG +#ifdef NEWCAM_DEBUG newcam_diagnostics(); - #endif // NEWCAM_DEBUG +#endif // NEWCAM_DEBUG } diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index a8a5373b..a559852e 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -2107,15 +2107,15 @@ void render_dialog_entries(void) { if (gLastDialogPageStrPos == -1 && gLastDialogResponse == 1) { render_dialog_triangle_choice(); } - #ifdef VERSION_EU - #undef BORDER_HEIGHT - #define BORDER_HEIGHT 8 - #endif +#ifdef VERSION_EU +#undef BORDER_HEIGHT +#define BORDER_HEIGHT 8 +#endif gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 2, 2, SCREEN_WIDTH - BORDER_HEIGHT/2, SCREEN_HEIGHT - BORDER_HEIGHT/2); - #ifdef VERSION_EU - #undef BORDER_HEIGHT - #define BORDER_HEIGHT 1 - #endif +#ifdef VERSION_EU +#undef BORDER_HEIGHT +#define BORDER_HEIGHT 1 +#endif if (gLastDialogPageStrPos != -1 && gDialogBoxState == DIALOG_STATE_VERTICAL) { render_dialog_string_color(dialog->linesPerBox); } diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 060b78c0..07134069 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -2064,9 +2064,9 @@ static void intro_cutscene_jump_out_of_pipe(struct MarioState *m) { play_character_sound_if_no_flag(m, CHAR_SOUND_YAHOO, MARIO_MARIO_SOUND_PLAYED); #else play_character_sound_if_no_flag(m, CHAR_SOUND_YAHOO, MARIO_MARIO_SOUND_PLAYED); - #ifndef VERSION_JP +#ifndef VERSION_JP play_sound_if_no_flag(m, SOUND_ACTION_HIT_3, MARIO_ACTION_SOUND_PLAYED); - #endif +#endif #endif set_character_animation(m, CHAR_ANIM_SINGLE_JUMP); diff --git a/src/menu/file_select.c b/src/menu/file_select.c index e24c9fbc..6caef0ed 100644 --- a/src/menu/file_select.c +++ b/src/menu/file_select.c @@ -2542,13 +2542,13 @@ void print_sound_mode_menu_strings(void) { } else { gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, sTextBaseAlpha); } - #ifndef VERSION_JP +#ifndef VERSION_JP // Mode names are centered correctly on US and Shindou textX = get_str_x_pos_from_center(mode * 74 + 87, textSoundModes[mode], 10.0f); print_generic_string(textX, 87, textSoundModes[mode]); - #else +#else print_generic_string(mode * 74 + 67, 87, textSoundModes[mode]); - #endif +#endif } #endif diff --git a/src/pc/controller/controller_entry_point.c b/src/pc/controller/controller_entry_point.c index 4fb2da76..b45abe86 100644 --- a/src/pc/controller/controller_entry_point.c +++ b/src/pc/controller/controller_entry_point.c @@ -13,9 +13,9 @@ // moved these from sdl controller implementations static struct ControllerAPI *controller_implementations[] = { - #if defined(CAPI_SDL2) || defined(CAPI_SDL1) +#if defined(CAPI_SDL2) || defined(CAPI_SDL1) &controller_sdl, - #endif +#endif &controller_keyboard, }; diff --git a/src/pc/controller/controller_mouse.c b/src/pc/controller/controller_mouse.c index b1f21a68..708970e0 100644 --- a/src/pc/controller/controller_mouse.c +++ b/src/pc/controller/controller_mouse.c @@ -1,16 +1,14 @@ #include "controller_mouse.h" #ifdef WAPI_DXGI - #define WIN32_LEAN_AND_MEAN - #include - extern HWND gfx_dxgi_get_h_wnd(void); - static bool mouse_relative_prev_cursor_state; - +#define WIN32_LEAN_AND_MEAN +#include +extern HWND gfx_dxgi_get_h_wnd(void); +static bool mouse_relative_prev_cursor_state; #elif defined(CAPI_SDL1) - #include - +#include #elif defined(CAPI_SDL2) - #include +#include #endif bool mouse_init_ok; @@ -39,10 +37,8 @@ void controller_mouse_read_window(void) { mouse_window_x = p.x; mouse_window_y = p.y; } - #elif defined(CAPI_SDL1) || defined(CAPI_SDL2) mouse_window_buttons = SDL_GetMouseState(&mouse_window_x, &mouse_window_y); - #endif } @@ -81,7 +77,7 @@ void controller_mouse_enter_relative(void) { if (!mouse_relative_enabled) { mouse_relative_enabled = true; - #if defined(WAPI_DXGI) +#if defined(WAPI_DXGI) CURSORINFO ci; ci.cbSize = sizeof(CURSORINFO); if (GetCursorInfo(&ci)) { @@ -91,14 +87,11 @@ void controller_mouse_enter_relative(void) { } ShowCursor(FALSE); - - #elif defined(CAPI_SDL1) +#elif defined(CAPI_SDL1) SDL_WM_GrabInput(SDL_GRAB_ON); - - #elif defined(CAPI_SDL2) +#elif defined(CAPI_SDL2) SDL_SetRelativeMouseMode(SDL_TRUE); - - #endif +#endif } } @@ -106,16 +99,13 @@ void controller_mouse_leave_relative(void) { if (mouse_relative_enabled) { mouse_relative_enabled = false; - #if defined(WAPI_DXGI) +#if defined(WAPI_DXGI) ShowCursor(mouse_relative_prev_cursor_state); - - #elif defined(CAPI_SDL1) +#elif defined(CAPI_SDL1) SDL_WM_GrabInput(SDL_GRAB_OFF); - - #elif defined(CAPI_SDL2) +#elif defined(CAPI_SDL2) SDL_SetRelativeMouseMode(SDL_FALSE); - - #endif +#endif } } diff --git a/src/pc/djui/djui_panel_mod_menu.c b/src/pc/djui/djui_panel_mod_menu.c index 2e399189..abd18d06 100644 --- a/src/pc/djui/djui_panel_mod_menu.c +++ b/src/pc/djui/djui_panel_mod_menu.c @@ -1,3 +1,4 @@ +#include #include "djui.h" #include "djui_panel.h" #include "djui_panel_menu.h" diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index 92619d2b..0b448b3d 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -130,11 +130,11 @@ static void gfx_sdl_init(const char *window_title) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - #ifdef USE_GLES +#ifdef USE_GLES SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); // These attributes allow for hardware acceleration on RPis. SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); - #endif +#endif int xpos = (configWindow.x == WAPI_WIN_CENTERPOS) ? SDL_WINDOWPOS_CENTERED : configWindow.x; int ypos = (configWindow.y == WAPI_WIN_CENTERPOS) ? SDL_WINDOWPOS_CENTERED : configWindow.y; diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index ca9c4459..473ef7b3 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -1,3 +1,4 @@ +#include #include "sm64.h" #include "types.h" diff --git a/src/pc/platform.c b/src/pc/platform.c index 0e83ec46..b0a02212 100644 --- a/src/pc/platform.c +++ b/src/pc/platform.c @@ -6,9 +6,9 @@ #include #ifdef _WIN32 - #include - #include - #include +#include +#include +#include #endif #include "cliopts.h"