From ea3d8f2721a8e5c5d75a101e16ae72f61f0b6da3 Mon Sep 17 00:00:00 2001 From: BlankPixel Date: Sun, 10 May 2020 23:42:29 -0700 Subject: [PATCH 01/22] Fix incorrect arguments for newcam_clamp(), min and max were swapped; Simplified newcam_change_setting() with clamp function. Also added a nice sound effect when closing the camera menu. --- src/game/bettercamera.inc.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/game/bettercamera.inc.h b/src/game/bettercamera.inc.h index d1fb29c0..6c9592b8 100644 --- a/src/game/bettercamera.inc.h +++ b/src/game/bettercamera.inc.h @@ -145,7 +145,8 @@ void newcam_init(struct Camera *c, u8 dv) newcam_intendedmode = newcam_mode; newcam_modeflags = newcam_mode; } -static f32 newcam_clamp(f32 value, f32 max, f32 min) + +static u8 newcam_clamp(u8 value, u8 min, u8 max) { if (value > max) value = max; @@ -153,6 +154,7 @@ static f32 newcam_clamp(f32 value, f32 max, f32 min) value = min; return value; } + ///These are the default settings for Puppycam. You may change them to change how they'll be set for first timers. void newcam_init_settings(void) { @@ -702,12 +704,10 @@ void newcam_change_setting(u8 toggle) newcam_mouse ^= 1; break; case 2: - if (newcam_sensitivityX > 10 && newcam_sensitivityX < 250) - newcam_sensitivityX += toggle; + newcam_sensitivityX = newcam_clamp(newcam_sensitivityX + toggle, 10, 250); break; case 3: - if (newcam_sensitivityY > 10 && newcam_sensitivityY < 250) - newcam_sensitivityY += toggle; + newcam_sensitivityY = newcam_clamp(newcam_sensitivityY + toggle, 10, 250); break; case 4: newcam_invertX ^= 1; @@ -716,12 +716,10 @@ void newcam_change_setting(u8 toggle) newcam_invertY ^= 1; break; case 6: - if (newcam_aggression > 0 && newcam_aggression < 100) - newcam_aggression += toggle; + newcam_aggression = newcam_clamp(newcam_aggression + toggle, 0, 100); break; case 7: - if (newcam_panlevel > 0 && newcam_panlevel < 100) - newcam_panlevel += toggle; + newcam_panlevel = newcam_clamp(newcam_panlevel + toggle, 0, 100); break; } } @@ -825,13 +823,18 @@ void newcam_check_pause_buttons() { if (gPlayer1Controller->buttonPressed & R_TRIG) { - #ifndef nosound - play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs); - #endif if (newcam_option_open == 0) + { + #ifndef nosound + play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs); + #endif newcam_option_open = 1; + } else { + #ifndef nosound + play_sound(SOUND_MENU_MARIO_CASTLE_WARP2, gDefaultSoundArgs); + #endif newcam_option_open = 0; newcam_save_settings(); } @@ -847,7 +850,7 @@ void newcam_check_pause_buttons() switch (newcam_option_index) { case 0: newcam_option_index++; newcam_option_timer += 10; break; - default: newcam_option_timer += 5; break; + default: newcam_option_timer += 3; break; } #ifndef nosound play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs); @@ -875,7 +878,7 @@ void newcam_check_pause_buttons() switch (newcam_option_index) { case 0: newcam_option_index++; newcam_option_timer += 10; break; - default: newcam_option_timer += 5; break; + default: newcam_option_timer += 3; break; } #ifndef nosound play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs); From 708e3fd68478fce990008279aa92dd5d8ca202ca Mon Sep 17 00:00:00 2001 From: Hyenadae Date: Mon, 11 May 2020 06:58:33 -0400 Subject: [PATCH 02/22] WIP In-Game Exit via pause+save menus w/ Localizations --- include/text_strings.h.in | 12 +++++++-- src/game/ingame_menu.c | 42 +++++++++++++++++++++++------- src/game/level_update.c | 43 +++++++++++++++++++++---------- src/game/mario_actions_cutscene.c | 20 +++++++++++--- 4 files changed, 90 insertions(+), 27 deletions(-) diff --git a/include/text_strings.h.in b/include/text_strings.h.in index 63a8e77e..030f3959 100644 --- a/include/text_strings.h.in +++ b/include/text_strings.h.in @@ -10,11 +10,11 @@ #define NC_CAMC _("Camera Centre Aggression") #define NC_CAMP _("Camera Pan Level") #define NC_ENABLED _("Enabled") -#define NC_DISABLED _("Disabled") +#define NC_DISABLED _("Disabled") #define NC_BUTTON _("[R]: Options") #define NC_BUTTON2 _("[R]: Return") #define NC_OPTION _("OPTIONS") -#define NC_HIGHLIGHT _("O") +#define NC_HIGHLIGHT _("O") #define NC_ANALOGUE _("Analogue Camera") #define NC_MOUSE _("Mouse Look") @@ -105,6 +105,7 @@ #define TEXT_COURSE _("コース") #define TEXT_MYSCORE _("マイスコア") #define TEXT_CONTINUE _("つづけて マリオする?") +#define TEXT_EXIT_GAME _("ゲームをしゅうりょうする?") #define TEXT_EXIT_COURSE _("コースからでる?") #define TEXT_CAMERA_ANGLE_R _("Rボタンのカメラきりかえ") @@ -122,6 +123,7 @@ // Save Options #define TEXT_SAVE_AND_CONTINUE _("セーブしてつづける?") #define TEXT_SAVE_AND_QUIT _("セーブしておわる?") +#define TEXT_SAVE_EXIT_GAME _("ゲームをやめる?") #define TEXT_CONTINUE_WITHOUT_SAVING _("セーブしないでつづける?") /** @@ -204,6 +206,7 @@ #define TEXT_MYSCORE _("MYSCORE") #define TEXT_CONTINUE _("CONTINUE") #define TEXT_EXIT_COURSE _("EXIT COURSE") +#define TEXT_EXIT_GAME _("EXIT GAME") #ifndef VERSION_EU // "R" text is different in EU #define TEXT_CAMERA_ANGLE_R _("SET CAMERA ANGLE WITH R") #endif @@ -222,6 +225,7 @@ // Save Options #define TEXT_SAVE_AND_CONTINUE _("SAVE & CONTINUE") #define TEXT_SAVE_AND_QUIT _("SAVE & QUIT") +#define TEXT_SAVE_EXIT_GAME _("SAVE & EXIT GAME") #define TEXT_CONTINUE_WITHOUT_SAVING _("CONTINUE, DON'T SAVE") /** @@ -348,12 +352,14 @@ #define TEXT_MY_SCORE_FR _("MON SCORE") #define TEXT_CONTINUE_FR _("CONTINUER") #define TEXT_EXIT_COURSE_FR _("QUITTER NIVEAU") +#define TEXT_EXIT_GAME_FR _("QUITTER JEU") #define TEXT_CAMERA_ANGLE_R_FR _("RÉGLAGE CAMÉRA AVEC [R]") // German #define TEXT_COURSE_DE _("KURS") #define TEXT_MY_SCORE_DE _("LEISTUNG") #define TEXT_CONTINUE_DE _("WEITER") #define TEXT_EXIT_COURSE_DE _("KURS VERLASSEN") +#define TEXT_EXIT_GAME_DE _("SPIEL VERLASSEN") #define TEXT_CAMERA_ANGLE_R_DE _("KAMERA MIT [R] VERSTELLEN") // Camera Options @@ -376,10 +382,12 @@ // French #define TEXT_SAVE_AND_CONTINUE_FR _("SAUVEGARDER & CONTINUER") #define TEXT_SAVE_AND_QUIT_FR _("SAUVEGARDER & QUITTER") +#define TEXT_SAVE_EXIT_GAME_FR _("SAUVEGARDER & QUITTER JEU") #define TEXT_CONTINUE_WITHOUT_SAVING_FR _("CONTINUER SANS SAUVEGARDER") // German #define TEXT_SAVE_AND_CONTINUE_DE _("SPEICHERN & WEITER") #define TEXT_SAVE_AND_QUIT_DE _("SPEICHERN & ENDE") +#define TEXT_SAVE_EXIT_GAME_DE _("SPEICHERN & SPIEL VERLASSEN") #define TEXT_CONTINUE_WITHOUT_SAVING_DE _("WEITER OHNE ZU SPEICHERN") /** diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index 227062c1..bfcbf42b 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -2387,6 +2387,13 @@ void render_pause_course_options(s16 x, s16 y, s8 *index, s16 yIndex) { { TEXT_EXIT_COURSE_FR }, { TEXT_EXIT_COURSE_DE } }; + + u8 textExitGame[][22] ={ + { TEXT_EXIT_GAME }, + { TEXT_EXIT_GAME_FR }, + { TEXT_EXIT_GAME_DE } + }; + u8 textCameraAngleR[][24] = { { TEXT_CAMERA_ANGLE_R }, { TEXT_CAMERA_ANGLE_R_FR }, @@ -2394,23 +2401,27 @@ void render_pause_course_options(s16 x, s16 y, s8 *index, s16 yIndex) { }; #define textContinue textContinue[gInGameLanguage] #define textExitCourse textExitCourse[gInGameLanguage] +#define textExitGame textExitGame[gInGameLanguage] #define textCameraAngleR textCameraAngleR[gInGameLanguage] #else u8 textContinue[] = { TEXT_CONTINUE }; u8 textExitCourse[] = { TEXT_EXIT_COURSE }; + u8 textExitGame[] = { TEXT_EXIT_GAME }; u8 textCameraAngleR[] = { TEXT_CAMERA_ANGLE_R }; #endif - handle_menu_scrolling(MENU_SCROLL_VERTICAL, index, 1, 3); + handle_menu_scrolling(MENU_SCROLL_VERTICAL, index, 1, 4); // Index max raised to 4 from 3 gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); print_generic_string(x + 10, y - 2, textContinue); print_generic_string(x + 10, y - 17, textExitCourse); + print_generic_string(x + 10, y - 33, textExitGame); - if (index[0] != 3) { - print_generic_string(x + 10, y - 33, textCameraAngleR); + + if (index[0] != 4) { + print_generic_string(x + 10, y - 48, textCameraAngleR); gSPDisplayList(gDisplayListHead++, dl_ia_text_end); create_dl_translation_matrix(MENU_MTX_PUSH, x - X_VAL8, (y - ((index[0] - 1) * yIndex)) - Y_VAL8, 0); @@ -2420,8 +2431,8 @@ void render_pause_course_options(s16 x, s16 y, s8 *index, s16 yIndex) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); } - if (index[0] == 3) { - render_pause_camera_options(x - 42, y - 42, &gDialogCameraAngleIndex, 110); + if (index[0] == 4) { + render_pause_camera_options(x - 42, y - 57, &gDialogCameraAngleIndex, 110); } } @@ -2662,7 +2673,7 @@ s16 render_pause_courses_and_castle(void) { gDialogBoxState = DIALOG_STATE_OPENING; gMenuMode = -1; - if (gDialogLineNum == 2) { + if (gDialogLineNum == 2 || gDialogLineNum == 3) { num = gDialogLineNum; } else { num = 1; @@ -2949,11 +2960,13 @@ void render_course_complete_lvl_info_and_hud_str(void) { #if defined(VERSION_JP) || defined(VERSION_SH) #define TXT_SAVECONT_Y 2 #define TXT_SAVEQUIT_Y 18 -#define TXT_CONTNOSAVE_Y 38 +#define TXT_SAVE_EXIT_GAME_Y 38 +#define TXT_CONTNOSAVE_Y 54 #else #define TXT_SAVECONT_Y 0 #define TXT_SAVEQUIT_Y 20 -#define TXT_CONTNOSAVE_Y 40 +#define TXT_SAVE_EXIT_GAME_Y 40 +#define TXT_CONTNOSAVE_Y 60 #endif #ifdef VERSION_EU @@ -2975,28 +2988,39 @@ void render_save_confirmation(s16 x, s16 y, s8 *index, s16 sp6e) { TEXT_SAVE_AND_QUIT_FR }, { TEXT_SAVE_AND_QUIT_DE } }; + + u8 textSaveExitGame[][26] = { // New function to exit game + { TEXT_SAVE_EXIT_GAME }, + { TEXT_SAVE_EXIT_GAME_FR }, + { TEXT_SAVE_EXIT_GAME_DE } + }; + u8 textContinueWithoutSaveArr[][27] = { { TEXT_CONTINUE_WITHOUT_SAVING }, { TEXT_CONTINUE_WITHOUT_SAVING_FR }, { TEXT_CONTINUE_WITHOUT_SAVING_DE } }; + #define textSaveAndContinue textSaveAndContinueArr[gInGameLanguage] #define textSaveAndQuit textSaveAndQuitArr[gInGameLanguage] +#define textSaveExitGame textSaveExitGame[gInGameLanguage] #define textContinueWithoutSave textContinueWithoutSaveArr[gInGameLanguage] s16 xOffset = get_str_x_pos_from_center(160, textContinueWithoutSaveArr[gInGameLanguage], 12.0f); #else u8 textSaveAndContinue[] = { TEXT_SAVE_AND_CONTINUE }; u8 textSaveAndQuit[] = { TEXT_SAVE_AND_QUIT }; + u8 textSaveExitGame[] = { TEXT_SAVE_EXIT_GAME }; u8 textContinueWithoutSave[] = { TEXT_CONTINUE_WITHOUT_SAVING }; #endif - handle_menu_scrolling(MENU_SCROLL_VERTICAL, index, 1, 3); + handle_menu_scrolling(MENU_SCROLL_VERTICAL, index, 1, 4); // Increased to '4' to handle Exit Game gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha); print_generic_string(TXT_SAVEOPTIONS_X, y + TXT_SAVECONT_Y, textSaveAndContinue); print_generic_string(TXT_SAVEOPTIONS_X, y - TXT_SAVEQUIT_Y, textSaveAndQuit); + print_generic_string(TXT_SAVEOPTIONS_X, y - TXT_SAVE_EXIT_GAME_Y, textSaveExitGame); print_generic_string(TXT_SAVEOPTIONS_X, y - TXT_CONTNOSAVE_Y, textContinueWithoutSave); gSPDisplayList(gDisplayListHead++, dl_ia_text_end); diff --git a/src/game/level_update.c b/src/game/level_update.c index f278811e..b2450c0b 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1,4 +1,5 @@ #include +#include #include "sm64.h" #include "seq_ids.h" @@ -27,6 +28,9 @@ #include "level_table.h" #include "course_table.h" #include "thread6.h" +#include "../../include/libc/stdlib.h" +#include "../pc/configfile.h" +#define CONFIG_FILE "sm64config.txt" #define PLAY_MODE_NORMAL 0 #define PLAY_MODE_PAUSED 2 @@ -1013,23 +1017,36 @@ s32 play_mode_normal(void) { s32 play_mode_paused(void) { if (gPauseScreenMode == 0) { set_menu_mode(RENDER_PAUSE_SCREEN); - } else if (gPauseScreenMode == 1) { + } else if (gPauseScreenMode == 1) { raise_background_noise(1); gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN; set_play_mode(PLAY_MODE_NORMAL); - } else { - // Exit level - - if (gDebugLevelSelect) { - fade_into_special_warp(-9, 1); - } else { - initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0); - fade_into_special_warp(0, 0); - gSavedCourseNum = COURSE_NONE; - } - - gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN; } + // Exit level + else if (gPauseScreenMode == 2) { + + if (gDebugLevelSelect) { + fade_into_special_warp(-9, 1); + } + + else { + initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0); + fade_into_special_warp(0, 0); + gSavedCourseNum = COURSE_NONE; + } + + } // end of gPauseScreenMode == 2 for "EXIT COURSE" option + + if (gPauseScreenMode == 3) { // We should only be getting "int 3" to here + initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0); + fade_into_special_warp(0, 0); + + //configfile_save(CONFIG_FILE); + exit(0); // Appears to automatically save config on exit! + } + + gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN; + // } return 0; } diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 97ae8e1d..cf623f91 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -1,4 +1,5 @@ #include +#include #include "prevent_bss_reordering.h" #include "sm64.h" #include "gfx_dimensions.h" @@ -27,9 +28,12 @@ #include "level_table.h" #include "dialog_ids.h" #include "thread6.h" +#include "../../include/libc/stdlib.h" +#include "../pc/configfile.h" +#define CONFIG_FILE "sm64config.txt" // TODO: put this elsewhere -enum SaveOption { SAVE_OPT_SAVE_AND_CONTINUE = 1, SAVE_OPT_SAVE_AND_QUIT, SAVE_OPT_CONTINUE_DONT_SAVE }; +enum SaveOption { SAVE_OPT_SAVE_AND_CONTINUE = 1, SAVE_OPT_SAVE_AND_QUIT, SAVE_OPT_SAVE_EXIT_GAME, SAVE_OPT_CONTINUE_DONT_SAVE }; static struct Object *sIntroWarpPipeObj; static struct Object *sEndPeachObj; @@ -254,16 +258,26 @@ void handle_save_menu(struct MarioState *m) { // mario_finished_animation(m) ? (not my file, not my problem) if (is_anim_past_end(m) && gSaveOptSelectIndex != 0) { // save and continue / save and quit - if (gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_CONTINUE || gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_QUIT) { + if (gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_CONTINUE || gSaveOptSelectIndex == SAVE_OPT_SAVE_EXIT_GAME || gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_QUIT) { save_file_do_save(gCurrSaveFileNum - 1); if (gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_QUIT) { fade_into_special_warp(-2, 0); // reset game } + + if (gSaveOptSelectIndex == SAVE_OPT_SAVE_EXIT_GAME) { + //configfile_save(CONFIG_FILE); //Redundant, save_file implies save_config? Save config file before fully exiting + //initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0); + fade_into_special_warp(0, 0); + + //fade_into_special_warp(-2, 0); // do the reset game thing + exit(0); // exit after saving game + } + } // not quitting - if (gSaveOptSelectIndex != SAVE_OPT_SAVE_AND_QUIT) { + if (gSaveOptSelectIndex != SAVE_OPT_SAVE_EXIT_GAME) { disable_time_stop(); m->faceAngle[1] += 0x8000; // figure out what dialog to show, if we should From cc4f619c2b70d8aa7905cd59d78f042ad7df0c9d Mon Sep 17 00:00:00 2001 From: vanfanel Date: Mon, 11 May 2020 13:37:48 +0200 Subject: [PATCH 03/22] Hide mouse cursor when in fullscreen mode. --- src/pc/gfx/gfx_sdl2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index 80a539a0..a794c6d3 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -130,9 +130,11 @@ static void gfx_sdl_init(void) { if (configFullscreen) { wnd = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, sdl_displaymode.w, sdl_displaymode.h, window_flags); + SDL_ShowCursor(SDL_DISABLE); } else { wnd = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT, window_flags); + SDL_ShowCursor(SDL_ENABLE); } SDL_GL_CreateContext(wnd); From 0f269048091d764ff068562e580150c049cb28ca Mon Sep 17 00:00:00 2001 From: Hyenadae Date: Mon, 11 May 2020 23:28:12 -0400 Subject: [PATCH 04/22] Added script to prep Raspbian / RPi and compile SDL2 / SM64 --- pisetup.sh | 395 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 395 insertions(+) create mode 100755 pisetup.sh diff --git a/pisetup.sh b/pisetup.sh new file mode 100755 index 00000000..cfd97320 --- /dev/null +++ b/pisetup.sh @@ -0,0 +1,395 @@ +#!/bin/bash +clear +echo "This script will assist with compiling Super Mario 64 on Raspbian 10" +echo "Note that accelerated OpenGL (vc4_drm) is required for maximum performance" +echo "Checking Raspberry Pi model..." +lowmem=0 +pi=0 +pimodel=$(uname -m 2>/dev/null || echo unknown) +pitype=$(tr -d '\0' < /sys/firmware/devicetree/base/model) + +if [[ $pimodel =~ "armv6" ]] +then + echo "" + echo "Raspberry Pi Model 1/0(W) detected (LOWMEM)" + echo "Warning: Additional steps may be required to safely compile and maximize performance" + pi=1; + lowmem=1; + exp=1; +fi + +if [[ $pimodel =~ "armv7" ]] +then + echo + echo "Raspberry Pi Model 2/3 detected (32bit)" + pi=2; + lowmem=0; +fi + +if [[ $pimodel =~ "aarch64" && $pitype =~ "4" ]] +then + echo + echo "Raspberry Pi Model 4 detected" + echo "Audio errors reported" + echo "Fixing audio config, reboot after compilation completes to activate" + sudo sed -i 's/load-module module-udev-detect/load-module module-udev-detect tsched=0/' /etc/pulse/default.pa + #load-module module-udev-detect tsched=0 + pi=4; + lowmem=0; + exp=1; +fi + + +if [[ $exp == 1 ]] +then + echo "" + echo "Notice: Due to detected Pi version, compilation and execution of Super Mario 64 (RPi) is experimental." + echo "Further steps may be required and software / driver compatibility is not guaranteed." + read -p "Continue setup & compilation (Y/N): " exp + + if [[ $exp =~ "Y" ]] + then + echo "" + else + exit + fi + + echo "Please report any problems encountered to https://github.com/sm64pc/sm64pc issue tracker." + echo "" + sleep 7 +fi + +#////////////////////////////////////////////////////////////////////////////////////////////////////////// +#////////////////////////////////////////////////////////////////////////////////////////////////////////// +clear +echo "Super Mario 64 RPi Initial Setup" + +if [[ $pi != 4 ]] +then #Dumb idea, but quick hack. We CANNOT enable VC4 for Pi4. + +inxinf=$(inxi -Gx) +echo "Checking for pre-enabled VC4 acceleration (inxi -Gx)" + +if [[ $inxinf =~ "not found" ]] +then +echo "Error: inxi not installed. Installing..." +sudo apt-get update +sudo apt-get install inxi +inxi=$(inxi -Gx) + + if [[ $inxinf =~ "not found" ]] + then + echo "Warning: Setup will not continue unless inxi is installed" + echo "Please ensure your Pi is in a state to download and install packages" + sleep 3 + exit + fi +fi + +if [[ $inxinf =~ "vc4_drm" ]] +then +echo "Success: VC4 OpenGL acceleration found!" +echo "" +sleep 4 + + else + echo "" + echo "OpenGL driver not found. opening Raspi-Config..." + echo "Please enable raspi-config -> ADV Opt -> OpenGL -> Enable FullKMS Renderer" + echo "" + sleep 5 + sudo raspi-config + vc4add=$(cat /boot/config.txt | grep -e "dtoverlay=vc4-kms-v3d") + + if [[ $vc4add =~ "vc4" ]] + then + echo "OGL driver now enabled on reboot" + fi +fi + +if [[ $lowmem == 1 ]] +then +fixmem=$(cat /boot/cmdline.txt | grep cma=128M) + + if [[ $fixmem =~ "cma=128M" ]] + then + echo "" + echo "Notice: Low-RAM RasPi model detected, BUT fixes already applied." + echo "Continuing setup." + + else + echo "" + echo "Warning: VC4 enabled, but your Rasp Pi has 512MB or less RAM" + echo "To ensure VC4_DRM and game compilation is succesful, video memory will be reduced" + echo "gpu_mem=48M (config.txt) | cma=128M (cmdline.txt) will be written to /boot " + echo "" + read -p "Fix mem? (Y/N): " fixmem + + if [[ $fixmem =~ "Y" ]] + then + sudo sh -c "echo 'gpu_mem=48' >> /boot/config.txt" + sudo sh -c "echo 'cma=128M' >> /boot/cmdline.txt" + sync + echo "Wrote configuration changes to SD card." + sleep 2 + else + echo "" + echo "Warning: Compilation freezes & errors are likely to occur on your Pi" + echo "" + sleep 3 + fi + fi +fi + +if [[ $fixmem =~ "Y" || $vc4add =~ "vc4" ]] +then +clear +echo "System configuration has changed!" +read -p "Reboot to enable changes? (Y/N): " fixstart + if [[ $fixstart =~ "Y" ]] + then + echo "" + echo "Rebooting RasPi!" + sudo reboot + fi +fi +fi #This should never run on a Pi 4 + +#-------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- +clear +echo "Beginning installation" +echo "" +echo "Step 1. Installing latest dependencies" +echo "Allow installation & checking of Super Mario 64 compile dependencies?" +read -p "Install? (Y/N): " instdep + +if [[ $instdep =~ "Y" ]] +then +echo "" +sudo apt-get update +sudo apt install build-essential git python3 libaudiofile-dev libglew-dev libsdl2-dev +sync +else +echo "" +echo "Super Mario 64 dependencies not installed." +echo "Please manually install if Raspbian is modified from stock" +echo "" +sleep 3 +fi + +#-------------------------------------------------------------------------------------- +#------------------------------------------------------------------------------------- +clear +echo "Optional: Compile SDL2 with 'KMSDRM' for enhanced performance?" +echo "KMSDRM allows Super Mario 64 to be run without GUI/Desktop enabled on boot." +echo "" +echo "Warning: Compile could take up to an hour on older Raspberry Pi models" +read -p "Proceed? (Y/N): " sdlcomp + +if [[ $sdlcomp =~ "Y" ]] +then +echo "" +echo "Installing dependencies for SDL2 compilation" + +sudo sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list" +sudo apt build-dep libsdl2 +sudo apt install libdrm-dev libgbm-dev +sync + +echo "" +echo "Creating folder src in HOME directory for compile" +echo "" + +mkdir $HOME/src +cd $HOME/src +mkdir $HOME/src/sdl2 +cd $HOME/src/sdl2 +sleep 2 + +echo "Downloading SDL2 from libsdl.org and unzipping to HOME/src/sdl2/SDL2" +wget https://www.libsdl.org/release/SDL2-2.0.10.tar.gz +sync +tar xzf ./SDL2*.gz +sync +cd ./SDL2* + +echo "Configuring SDL2 library to enable KMSDRM (Xorg free rendering)" +./configure --enable-video-kmsdrm +echo "Compiling modified SDL2 and installing." +make +sudo make install +fi + +#---------------------------------------------------------------------- +#--------------------------------------------------------------------- +sleep 2 +clear +echo "Super Mario 64 RPi preparation & downloader" +echo "" +echo "Checking in current directory and" +echo "checking in "$HOME"/src/sm64pi/sm64pc/ for existing Super Mario 64 PC files" +echo "" +sm64dircur=$(ls ./Makefile) +sm64dir=$(ls $HOME/src/sm64pi/sm64pc/Makefile) + +if [[ $sm64dircur =~ "Makefile" ]] #If current directory has a makefile +then +sm64dir=$sm64dircur +curdir=1; #If current directory has a Makefile or is git zip +fi + +if [[ $sm64dir =~ "Makefile" ]]; +then + echo "Existing Super Mario 64 PC port files found!" + echo "Redownload files (fresh compile)?" + read -p "Redownload? (Y/N): " sm64git + + if [[ $sm64git =~ "N" ]] # Do NOT redownload, USE current directory for compile + then + sm64dir=1; # Don't redownload files , use current directory (has sm64 files) + curdir=1 + fi + +else #Do a fresh compile in HOME/src/sm64pi/sm64pc/ + sm64dir=0; + curdir=0; +fi + +#------------------------------------------------------------------------------ +#------------------------------------------------------------------------------ + +if [[ $sm64git =~ "Y" || $sm64dir == 0 || $curdir == 0 ]] #If user wants to redownload or NOT git-zip execution +then +echo "Step 2. Super Mario 64 PC-Port will now be downloaded from github" +echo "Current folder will NOT be compiled." +read -p "Proceed? (Y/N): " gitins + +if [[ $gitins =~ "Y" ]] +then +echo "" +echo "Creating directory "$HOME"/src/sm64pi" +mkdir $HOME/src/ +cd $HOME/src/ +mkdir $HOME/src/sm64pi +cd $HOME/src/sm64pi + +echo "" +echo "Downloading latest Super Mario 64 PC-port code" +git clone https://github.com/sm64pc/sm64pc +cd $HOME/src/sm64pi/sm64pc/ +echo "Download complete" +echo "" +sleep 2 +fi #End of downloader +fi +sleep 2 + +#------------------------------------------------------------------- +#------------------------------------------------------------------ +clear +echo "Super Mario 64 RPi compilation" +echo "" +echo "Step 3. Compiling Super Mario 64 for the Raspberry Pi" +echo "" +echo "Warning: Super Mario 64 assets are required in order to compile" +echo "Assets will be extracted from $HOME/src/sm64pi/sm64pc/baserom.(us/eu/jp).z64 " + +if [[ $curdir == 1 ]] +then +sm64z64=$(find ./* | grep baserom) #See if current directory is prepped +else +sm64z64=$(find $HOME/src/sm64pi/sm64pc/* | grep baserom) #see if fresh compile directory is prepped +fi + +if [[ $sm64z64 =~ "baserom" ]] +then +echo "" +echo "Super Mario 64 assets found in compilation directory" +echo "Continuing with compilation" + +else +echo "" +echo "Please satisfy this requirement before continuing." +echo "Exiting Super Mario 64 RasPi setup and compilation script." +echo "Note: Re-run script once baserom(s) are inserted into" + +if [[ $curdir == 1 ]] +then +echo $PWD +else +echo $HOME/src/sm64pi/sm64pc/ +fi + +sleep 5 +exit + +fi + +#------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- +sleep 3 +clear +echo "" + +if [[ $curdir != 1 ]] # If we're not compiling from a git zip / random directory +then +cd $HOME/src/sm64pi/sm64pc/ +fi + +echo "Beginning Super Mario 64 RasPi compilation!" +echo "" +echo "Warning: Compilation may take up to an hour on weaker hardware" +echo "At least 300MB of free storage AND RAM is recommended" +echo "" +make clean +sync +make TARGET_RPI=1 +sync + + +#--------------------------------------------------------------------------- +#-------------------------------------------------------------------------- + +if [[ $curdir == 1 ]] +then +sm64done=$(find ./build/*/* | grep .arm) +else +sm64done=$(find $HOME/src/sm64pi/sm64pc/build/*/* | grep .arm) +fi + +echo "" +if [[ $sm64done =~ ".arm" ]] +then +echo "Super Mario 64 RasPi compilation successful!" +echo "You may find it in" + +if [[ $curdir == 1 ]] +then +$sm64loc=$(ls ./build/*pc/*.arm) +else +$sm64loc=$(ls $HOME/src/sm64pi/sm64pc/build/*pc/*.arm) +fi + +echo $sm64loc + +echo "" +echo "Execute compiled Super Mario 64 RasPi?" +read -p "Run game (Y/N): " sm64run + +if [[ $sm64run =~ "Y" ]] +then +cd +chmod +x $sm64loc +bash $sm64loc +sleep 1 +fi + +else +echo "Cannot find compiled sm64*.arm binary..." +echo "Please note of any errors during compilation process and report them to" +echo "https://github.com/sm64pc/sm64pc" +sleep 5 +fi + +exit From 9791e95ae748a88cb3defec7150b42e410c37901 Mon Sep 17 00:00:00 2001 From: uwabami Date: Tue, 12 May 2020 09:26:16 +0200 Subject: [PATCH 05/22] adding option to disable draw distance --- Makefile | 8 ++++++++ src/engine/behavior_script.c | 4 ++++ src/engine/surface_load.c | 4 ++++ src/game/behaviors/butterfly.inc.c | 3 ++- src/game/behaviors/chain_chomp.inc.c | 8 ++++++++ src/game/behaviors/coin.inc.c | 6 ++++++ src/game/behaviors/fish.inc.c | 4 ++++ src/game/behaviors/goomba.inc.c | 4 ++++ src/game/behaviors/heave_ho.inc.c | 4 ++++ src/game/behaviors/king_bobomb.inc.c | 4 ++++ src/game/behaviors/pokey.inc.c | 6 ++++++ src/game/behaviors/snufit.inc.c | 4 ++++ src/game/behaviors/triplet_butterfly.inc.c | 4 ++++ src/game/behaviors/water_bomb_cannon.inc.c | 8 ++++++++ src/game/behaviors/whirlpool.inc.c | 4 ++++ 15 files changed, 74 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d4bd2846..efeb63e4 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,8 @@ COMPILER ?= ido # Disable better camera by default BETTERCAMERA ?= 0 +# Disable no drawing distance by default +NODRAWINGDISTANCE ?= 0 # Build for Emscripten/WebGL TARGET_WEB ?= 0 @@ -449,6 +451,12 @@ CC_CHECK += -DBETTERCAMERA CFLAGS += -DBETTERCAMERA endif +# Check for no drawing distance option +ifeq ($(NODRAWINGDISTANCE),1) +CC_CHECK += -DNODRAWINGDISTANCE +CFLAGS += -DNODRAWINGDISTANCE +endif + ASFLAGS := -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) ifeq ($(TARGET_WEB),1) diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index edd52478..feb6fefd 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -987,11 +987,15 @@ void cur_obj_update(void) { } else if ((objFlags & OBJ_FLAG_COMPUTE_DIST_TO_MARIO) && gCurrentObject->collisionData == NULL) { if (!(objFlags & OBJ_FLAG_ACTIVE_FROM_AFAR)) { // If the object has a render distance, check if it should be shown. +#ifndef NODRAWINGDISTANCE if (distanceFromMario > gCurrentObject->oDrawingDistance) { // Out of render distance, hide the object. gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; gCurrentObject->activeFlags |= ACTIVE_FLAG_FAR_AWAY; } else if (gCurrentObject->oHeldState == HELD_FREE) { +#else + if (distanceFromMario <= gCurrentObject->oDrawingDistance && gCurrentObject->oHeldState == HELD_FREE) { +#endif // In render distance (and not being held), show the object. gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; gCurrentObject->activeFlags &= ~ACTIVE_FLAG_FAR_AWAY; diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index 363f9afb..498fae0d 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -789,9 +789,13 @@ void load_object_collision_model(void) { } } +#ifndef NODRAWINGDISTANCE if (marioDist < gCurrentObject->oDrawingDistance) { +#endif gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; +#ifndef NODRAWINGDISTANCE } else { gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; } +#endif } diff --git a/src/game/behaviors/butterfly.inc.c b/src/game/behaviors/butterfly.inc.c index d435d8d8..9296ed50 100644 --- a/src/game/behaviors/butterfly.inc.c +++ b/src/game/behaviors/butterfly.inc.c @@ -107,6 +107,7 @@ void bhv_butterfly_loop(void) { butterfly_act_return_home(); break; } - +#ifndef NODRAWINGDISTANCE set_object_visibility(o, 3000); +#endif } diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c index a77c5d5f..9b9c3423 100644 --- a/src/game/behaviors/chain_chomp.inc.c +++ b/src/game/behaviors/chain_chomp.inc.c @@ -53,7 +53,9 @@ static void chain_chomp_act_uninitialized(void) { struct ChainSegment *segments; s32 i; +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 3000.0f) { +#endif segments = mem_pool_alloc(gObjectMemoryPool, 5 * sizeof(struct ChainSegment)); if (segments != NULL) { // Each segment represents the offset of a chain part to the pivot. @@ -81,7 +83,9 @@ static void chain_chomp_act_uninitialized(void) { cur_obj_unhide(); } } +#ifndef NODRAWINGDISTANCE } +#endif } /** @@ -359,10 +363,12 @@ static void chain_chomp_act_move(void) { f32 maxDistToPivot; // Unload chain if mario is far enough +#ifndef NODRAWINGDISTANCE if (o->oChainChompReleaseStatus == CHAIN_CHOMP_NOT_RELEASED && o->oDistanceToMario > 4000.0f) { o->oAction = CHAIN_CHOMP_ACT_UNLOAD_CHAIN; o->oForwardVel = o->oVelY = 0.0f; } else { +#endif cur_obj_update_floor_and_walls(); switch (o->oChainChompReleaseStatus) { @@ -446,7 +452,9 @@ static void chain_chomp_act_move(void) { o->oGravity = -4.0f; o->oChainChompTargetPitch = -0x3000; } +#ifndef NODRAWINGDISTANCE } +#endif } /** diff --git a/src/game/behaviors/coin.inc.c b/src/game/behaviors/coin.inc.c index 913c5834..05619b96 100644 --- a/src/game/behaviors/coin.inc.c +++ b/src/game/behaviors/coin.inc.c @@ -184,17 +184,23 @@ void bhv_coin_formation_loop(void) { s32 bitIndex; switch (o->oAction) { case 0: +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 2000.0f) { +#endif for (bitIndex = 0; bitIndex < 8; bitIndex++) { if (!(o->oCoinUnkF4 & (1 << bitIndex))) spawn_coin_in_formation(bitIndex, o->oBehParams2ndByte); } o->oAction++; +#ifndef NODRAWINGDISTANCE } +#endif break; case 1: +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario > 2100.0f) o->oAction++; +#endif break; case 2: o->oAction = 0; diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c index 839ab8d6..f652ef47 100644 --- a/src/game/behaviors/fish.inc.c +++ b/src/game/behaviors/fish.inc.c @@ -42,7 +42,9 @@ void fish_act_spawn(void) { * If the current level is Secret Aquarium, ignore this requirement. * Fish moves at random with a max-range of 700.0f. */ +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < minDistToMario || gCurrLevelNum == LEVEL_SA) { +#endif for (i = 0; i < schoolQuantity; i++) { fishObject = spawn_object(o, model, bhvFish); fishObject->oBehParams2ndByte = o->oBehParams2ndByte; @@ -50,7 +52,9 @@ void fish_act_spawn(void) { obj_translate_xyz_random(fishObject, 700.0f); } o->oAction = FISH_ACT_ACTIVE; +#ifndef NODRAWINGDISTANCE } +#endif } /** diff --git a/src/game/behaviors/goomba.inc.c b/src/game/behaviors/goomba.inc.c index 2dab2fec..bf47dda1 100644 --- a/src/game/behaviors/goomba.inc.c +++ b/src/game/behaviors/goomba.inc.c @@ -78,7 +78,9 @@ void bhv_goomba_triplet_spawner_update(void) { // If mario is close enough and the goombas aren't currently loaded, then // spawn them if (o->oAction == GOOMBA_TRIPLET_SPAWNER_ACT_UNLOADED) { +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 3000.0f) { +#endif // The spawner is capable of spawning more than 3 goombas, but this // is not used in the game dAngle = @@ -98,11 +100,13 @@ void bhv_goomba_triplet_spawner_update(void) { } o->oAction += 1; +#ifndef NODRAWINGDISTANCE } } else if (o->oDistanceToMario > 4000.0f) { // If mario is too far away, enter the unloaded action. The goombas // will detect this and unload themselves o->oAction = GOOMBA_TRIPLET_SPAWNER_ACT_UNLOADED; +#endif } } diff --git a/src/game/behaviors/heave_ho.inc.c b/src/game/behaviors/heave_ho.inc.c index 662bb0bd..2f9da864 100644 --- a/src/game/behaviors/heave_ho.inc.c +++ b/src/game/behaviors/heave_ho.inc.c @@ -73,14 +73,18 @@ void heave_ho_act_3(void) { void heave_ho_act_0(void) { cur_obj_set_pos_to_home(); +#ifndef NODRAWINGDISTANCE if (find_water_level(o->oPosX, o->oPosZ) < o->oPosY && o->oDistanceToMario < 4000.0f) { +#endif cur_obj_become_tangible(); cur_obj_unhide(); o->oAction = 1; +#ifndef NODRAWINGDISTANCE } else { cur_obj_become_intangible(); cur_obj_hide(); } +#endif } void (*sHeaveHoActions[])(void) = { heave_ho_act_0, heave_ho_act_1, heave_ho_act_2, heave_ho_act_3 }; diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c index 63a75755..af1cb0a6 100644 --- a/src/game/behaviors/king_bobomb.inc.c +++ b/src/game/behaviors/king_bobomb.inc.c @@ -295,10 +295,14 @@ void king_bobomb_move(void) { cur_obj_move_using_fvel_and_gravity(); cur_obj_call_action_function(sKingBobombActions); exec_anim_sound_state(sKingBobombSoundStates); +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 5000.0f) +#endif cur_obj_enable_rendering(); +#ifndef NODRAWINGDISTANCE else cur_obj_disable_rendering(); +#endif } void bhv_king_bobomb_loop(void) { diff --git a/src/game/behaviors/pokey.inc.c b/src/game/behaviors/pokey.inc.c index df5d11f5..cfcc92c2 100644 --- a/src/game/behaviors/pokey.inc.c +++ b/src/game/behaviors/pokey.inc.c @@ -151,7 +151,9 @@ static void pokey_act_uninitialized(void) { s32 i; s16 partModel; +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 2000.0f) { +#endif partModel = MODEL_POKEY_HEAD; for (i = 0; i < 5; i++) { @@ -170,7 +172,9 @@ static void pokey_act_uninitialized(void) { o->oPokeyNumAliveBodyParts = 5; o->oPokeyBottomBodyPartSize = 1.0f; o->oAction = POKEY_ACT_WANDER; +#ifndef NODRAWINGDISTANCE } +#endif } /** @@ -185,9 +189,11 @@ static void pokey_act_wander(void) { if (o->oPokeyNumAliveBodyParts == 0) { obj_mark_for_deletion(o); +#ifndef NODRAWINGDISTANCE } else if (o->oDistanceToMario > 2500.0f) { o->oAction = POKEY_ACT_UNLOAD_PARTS; o->oForwardVel = 0.0f; +#endif } else { treat_far_home_as_mario(1000.0f); cur_obj_update_floor_and_walls(); diff --git a/src/game/behaviors/snufit.inc.c b/src/game/behaviors/snufit.inc.c index f3a0c9ef..76e78c09 100644 --- a/src/game/behaviors/snufit.inc.c +++ b/src/game/behaviors/snufit.inc.c @@ -180,7 +180,11 @@ void bhv_snufit_loop(void) { void bhv_snufit_balls_loop(void) { // If far from Mario or in a different room, despawn. if ((o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) +#ifndef NODRAWINGDISTANCE || (o->oTimer != 0 && o->oDistanceToMario > 1500.0f)) { +#else + || (o->oTimer != 0)) { +#endif obj_mark_for_deletion(o); } diff --git a/src/game/behaviors/triplet_butterfly.inc.c b/src/game/behaviors/triplet_butterfly.inc.c index 1c2b9265..3d16a9d2 100644 --- a/src/game/behaviors/triplet_butterfly.inc.c +++ b/src/game/behaviors/triplet_butterfly.inc.c @@ -54,9 +54,11 @@ static void triplet_butterfly_act_init(void) { } static void triplet_butterfly_act_wander(void) { +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario > 1500.0f) { obj_mark_for_deletion(o); } else { +#endif approach_f32_ptr(&o->oTripletButterflySpeed, 8.0f, 0.5f); if (o->oTimer < 60) { o->oTripletButterflyTargetYaw = cur_obj_angle_to_home(); @@ -82,7 +84,9 @@ static void triplet_butterfly_act_wander(void) { obj_move_pitch_approach(o->oTripletButterflyTargetPitch, 400); cur_obj_rotate_yaw_toward(o->oTripletButterflyTargetYaw, random_linear_offset(400, 800)); +#ifndef NODRAWINGDISTANCE } +#endif } static void triplet_butterfly_act_activate(void) { diff --git a/src/game/behaviors/water_bomb_cannon.inc.c b/src/game/behaviors/water_bomb_cannon.inc.c index 8e9ba33b..fb82e43c 100644 --- a/src/game/behaviors/water_bomb_cannon.inc.c +++ b/src/game/behaviors/water_bomb_cannon.inc.c @@ -38,19 +38,27 @@ void bhv_bubble_cannon_barrel_loop(void) { } void water_bomb_cannon_act_0(void) { +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 2000.0f) { +#endif spawn_object(o, MODEL_CANNON_BARREL, bhvCannonBarrelBubbles); cur_obj_unhide(); o->oAction = 1; o->oMoveAnglePitch = o->oWaterCannonUnkFC = 0x1C00; +#ifndef NODRAWINGDISTANCE } +#endif } void water_bomb_cannon_act_1(void) { +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario > 2500.0f) { o->oAction = 2; } else if (o->oBehParams2ndByte == 0) { +#else + if (o->oBehParams2ndByte == 0) { +#endif if (o->oWaterCannonUnkF4 != 0) { o->oWaterCannonUnkF4 -= 1; } else { diff --git a/src/game/behaviors/whirlpool.inc.c b/src/game/behaviors/whirlpool.inc.c index 405e0518..5aebebd2 100644 --- a/src/game/behaviors/whirlpool.inc.c +++ b/src/game/behaviors/whirlpool.inc.c @@ -35,7 +35,9 @@ void whirpool_orient_graph(void) { } void bhv_whirlpool_loop(void) { +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 5000.0f) { +#endif o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; // not sure if actually an array @@ -52,10 +54,12 @@ void bhv_whirlpool_loop(void) { whirpool_orient_graph(); o->oFaceAngleYaw += 0x1F40; +#ifndef NODRAWINGDISTANCE } else { o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; gEnvFxBubbleConfig[ENVFX_STATE_PARTICLECOUNT] = 0; } +#endif cur_obj_play_sound_1(SOUND_ENV_WATER); From feb9d900f710fd4a5039d29d2f41ee0147e6171e Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Tue, 12 May 2020 16:08:34 +0200 Subject: [PATCH 06/22] extend cross compilation support --- Makefile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d4bd2846..5e5d3881 100644 --- a/Makefile +++ b/Makefile @@ -424,14 +424,15 @@ else LD := $(CC) endif -CPP := cpp -P -OBJDUMP := objdump -OBJCOPY := objcopy +CPP := $(CROSS)cpp -P +OBJDUMP := $(CROSS)objdump +OBJCOPY := $(CROSS)objcopy PYTHON := python3 +SDLCONFIG := $(CROSS)sdl2-config ifeq ($(WINDOWS_BUILD),1) -CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(CROSS)sdl2-config --cflags` -CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(CROSS)sdl2-config --cflags` +CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` +CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(SDLCONFIG) --cflags` else ifeq ($(TARGET_WEB),1) CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2 @@ -439,8 +440,8 @@ CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fn # Linux / Other builds below else -CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(CROSS)sdl2-config --cflags` -CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(CROSS)sdl2-config --cflags` +CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` +CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(SDLCONFIG) --cflags` endif # Check for better camera option @@ -456,14 +457,14 @@ LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base ht else ifeq ($(WINDOWS_BUILD),1) -LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(CROSS)sdl2-config --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static +LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static else # Linux / Other builds below ifeq ($(TARGET_RPI),1) -LDFLAGS := $(OPT_FLAGS) -lm -lGLESv2 `$(CROSS)sdl2-config --libs` -no-pie +LDFLAGS := $(OPT_FLAGS) -lm -lGLESv2 `$(SDLCONFIG) --libs` -no-pie else -LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -lm -lGL `$(CROSS)sdl2-config --libs` -no-pie -lpthread +LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -lm -lGL `$(SDLCONFIG) --libs` -no-pie -lpthread endif endif endif #Added for Pi ifeq From d4f52d7695b20f6dae916ca0f1e75028206ca775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Wed, 13 May 2020 03:52:34 -0300 Subject: [PATCH 07/22] Add nodrawdistance.patch --- enhancements/no_draw_distance/README.md | 10 + .../no_draw_distance/nodrawdistance.patch | 406 ++++++++++++++++++ 2 files changed, 416 insertions(+) create mode 100644 enhancements/no_draw_distance/README.md create mode 100644 enhancements/no_draw_distance/nodrawdistance.patch diff --git a/enhancements/no_draw_distance/README.md b/enhancements/no_draw_distance/README.md new file mode 100644 index 00000000..dd890383 --- /dev/null +++ b/enhancements/no_draw_distance/README.md @@ -0,0 +1,10 @@ +# No Draw Distances + +This is a work-in-progress by [wabberz](https://github.com/wabberz) that disables the drawing distance for most objects and enemies. + +**This will crash some levels in the 32-bit version**. + +[Related Push Request](https://github.com/sm64pc/sm64pc/pull/75). + +For instructions on how to apply patches, please refer to [the Wiki](https://github.com/sm64pc/sm64pc/wiki/Patches). + diff --git a/enhancements/no_draw_distance/nodrawdistance.patch b/enhancements/no_draw_distance/nodrawdistance.patch new file mode 100644 index 00000000..b986b1a6 --- /dev/null +++ b/enhancements/no_draw_distance/nodrawdistance.patch @@ -0,0 +1,406 @@ +From c98a263cf40520bf0d131eb2d1a2f90240787c98 Mon Sep 17 00:00:00 2001 +From: uwabami +Date: Tue, 12 May 2020 09:26:16 +0200 +Subject: [PATCH] adding option to disable draw distance + +--- + Makefile | 8 ++++++++ + src/engine/behavior_script.c | 4 ++++ + src/engine/surface_load.c | 4 ++++ + src/game/behaviors/butterfly.inc.c | 3 ++- + src/game/behaviors/chain_chomp.inc.c | 8 ++++++++ + src/game/behaviors/coin.inc.c | 6 ++++++ + src/game/behaviors/fish.inc.c | 4 ++++ + src/game/behaviors/goomba.inc.c | 4 ++++ + src/game/behaviors/heave_ho.inc.c | 4 ++++ + src/game/behaviors/king_bobomb.inc.c | 4 ++++ + src/game/behaviors/pokey.inc.c | 6 ++++++ + src/game/behaviors/snufit.inc.c | 4 ++++ + src/game/behaviors/triplet_butterfly.inc.c | 4 ++++ + src/game/behaviors/water_bomb_cannon.inc.c | 8 ++++++++ + src/game/behaviors/whirlpool.inc.c | 4 ++++ + 15 files changed, 74 insertions(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index d4bd284..efeb63e 100644 +--- a/Makefile ++++ b/Makefile +@@ -27,6 +27,8 @@ COMPILER ?= ido + + # Disable better camera by default + BETTERCAMERA ?= 0 ++# Disable no drawing distance by default ++NODRAWINGDISTANCE ?= 0 + + # Build for Emscripten/WebGL + TARGET_WEB ?= 0 +@@ -449,6 +451,12 @@ CC_CHECK += -DBETTERCAMERA + CFLAGS += -DBETTERCAMERA + endif + ++# Check for no drawing distance option ++ifeq ($(NODRAWINGDISTANCE),1) ++CC_CHECK += -DNODRAWINGDISTANCE ++CFLAGS += -DNODRAWINGDISTANCE ++endif ++ + ASFLAGS := -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) + + ifeq ($(TARGET_WEB),1) +diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c +index edd5247..feb6fef 100644 +--- a/src/engine/behavior_script.c ++++ b/src/engine/behavior_script.c +@@ -987,11 +987,15 @@ void cur_obj_update(void) { + } else if ((objFlags & OBJ_FLAG_COMPUTE_DIST_TO_MARIO) && gCurrentObject->collisionData == NULL) { + if (!(objFlags & OBJ_FLAG_ACTIVE_FROM_AFAR)) { + // If the object has a render distance, check if it should be shown. ++#ifndef NODRAWINGDISTANCE + if (distanceFromMario > gCurrentObject->oDrawingDistance) { + // Out of render distance, hide the object. + gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; + gCurrentObject->activeFlags |= ACTIVE_FLAG_FAR_AWAY; + } else if (gCurrentObject->oHeldState == HELD_FREE) { ++#else ++ if (distanceFromMario <= gCurrentObject->oDrawingDistance && gCurrentObject->oHeldState == HELD_FREE) { ++#endif + // In render distance (and not being held), show the object. + gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; + gCurrentObject->activeFlags &= ~ACTIVE_FLAG_FAR_AWAY; +diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c +index 363f9af..498fae0 100644 +--- a/src/engine/surface_load.c ++++ b/src/engine/surface_load.c +@@ -789,9 +789,13 @@ void load_object_collision_model(void) { + } + } + ++#ifndef NODRAWINGDISTANCE + if (marioDist < gCurrentObject->oDrawingDistance) { ++#endif + gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; ++#ifndef NODRAWINGDISTANCE + } else { + gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; + } ++#endif + } +diff --git a/src/game/behaviors/butterfly.inc.c b/src/game/behaviors/butterfly.inc.c +index d435d8d..9296ed5 100644 +--- a/src/game/behaviors/butterfly.inc.c ++++ b/src/game/behaviors/butterfly.inc.c +@@ -107,6 +107,7 @@ void bhv_butterfly_loop(void) { + butterfly_act_return_home(); + break; + } +- ++#ifndef NODRAWINGDISTANCE + set_object_visibility(o, 3000); ++#endif + } +diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c +index a77c5d5..9b9c342 100644 +--- a/src/game/behaviors/chain_chomp.inc.c ++++ b/src/game/behaviors/chain_chomp.inc.c +@@ -53,7 +53,9 @@ static void chain_chomp_act_uninitialized(void) { + struct ChainSegment *segments; + s32 i; + ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario < 3000.0f) { ++#endif + segments = mem_pool_alloc(gObjectMemoryPool, 5 * sizeof(struct ChainSegment)); + if (segments != NULL) { + // Each segment represents the offset of a chain part to the pivot. +@@ -81,7 +83,9 @@ static void chain_chomp_act_uninitialized(void) { + cur_obj_unhide(); + } + } ++#ifndef NODRAWINGDISTANCE + } ++#endif + } + + /** +@@ -359,10 +363,12 @@ static void chain_chomp_act_move(void) { + f32 maxDistToPivot; + + // Unload chain if mario is far enough ++#ifndef NODRAWINGDISTANCE + if (o->oChainChompReleaseStatus == CHAIN_CHOMP_NOT_RELEASED && o->oDistanceToMario > 4000.0f) { + o->oAction = CHAIN_CHOMP_ACT_UNLOAD_CHAIN; + o->oForwardVel = o->oVelY = 0.0f; + } else { ++#endif + cur_obj_update_floor_and_walls(); + + switch (o->oChainChompReleaseStatus) { +@@ -446,7 +452,9 @@ static void chain_chomp_act_move(void) { + o->oGravity = -4.0f; + o->oChainChompTargetPitch = -0x3000; + } ++#ifndef NODRAWINGDISTANCE + } ++#endif + } + + /** +diff --git a/src/game/behaviors/coin.inc.c b/src/game/behaviors/coin.inc.c +index 913c583..05619b9 100644 +--- a/src/game/behaviors/coin.inc.c ++++ b/src/game/behaviors/coin.inc.c +@@ -184,17 +184,23 @@ void bhv_coin_formation_loop(void) { + s32 bitIndex; + switch (o->oAction) { + case 0: ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario < 2000.0f) { ++#endif + for (bitIndex = 0; bitIndex < 8; bitIndex++) { + if (!(o->oCoinUnkF4 & (1 << bitIndex))) + spawn_coin_in_formation(bitIndex, o->oBehParams2ndByte); + } + o->oAction++; ++#ifndef NODRAWINGDISTANCE + } ++#endif + break; + case 1: ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario > 2100.0f) + o->oAction++; ++#endif + break; + case 2: + o->oAction = 0; +diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c +index 839ab8d..f652ef4 100644 +--- a/src/game/behaviors/fish.inc.c ++++ b/src/game/behaviors/fish.inc.c +@@ -42,7 +42,9 @@ void fish_act_spawn(void) { + * If the current level is Secret Aquarium, ignore this requirement. + * Fish moves at random with a max-range of 700.0f. + */ ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario < minDistToMario || gCurrLevelNum == LEVEL_SA) { ++#endif + for (i = 0; i < schoolQuantity; i++) { + fishObject = spawn_object(o, model, bhvFish); + fishObject->oBehParams2ndByte = o->oBehParams2ndByte; +@@ -50,7 +52,9 @@ void fish_act_spawn(void) { + obj_translate_xyz_random(fishObject, 700.0f); + } + o->oAction = FISH_ACT_ACTIVE; ++#ifndef NODRAWINGDISTANCE + } ++#endif + } + + /** +diff --git a/src/game/behaviors/goomba.inc.c b/src/game/behaviors/goomba.inc.c +index 2dab2fe..bf47dda 100644 +--- a/src/game/behaviors/goomba.inc.c ++++ b/src/game/behaviors/goomba.inc.c +@@ -78,7 +78,9 @@ void bhv_goomba_triplet_spawner_update(void) { + // If mario is close enough and the goombas aren't currently loaded, then + // spawn them + if (o->oAction == GOOMBA_TRIPLET_SPAWNER_ACT_UNLOADED) { ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario < 3000.0f) { ++#endif + // The spawner is capable of spawning more than 3 goombas, but this + // is not used in the game + dAngle = +@@ -98,11 +100,13 @@ void bhv_goomba_triplet_spawner_update(void) { + } + + o->oAction += 1; ++#ifndef NODRAWINGDISTANCE + } + } else if (o->oDistanceToMario > 4000.0f) { + // If mario is too far away, enter the unloaded action. The goombas + // will detect this and unload themselves + o->oAction = GOOMBA_TRIPLET_SPAWNER_ACT_UNLOADED; ++#endif + } + } + +diff --git a/src/game/behaviors/heave_ho.inc.c b/src/game/behaviors/heave_ho.inc.c +index 662bb0b..2f9da86 100644 +--- a/src/game/behaviors/heave_ho.inc.c ++++ b/src/game/behaviors/heave_ho.inc.c +@@ -73,14 +73,18 @@ void heave_ho_act_3(void) { + + void heave_ho_act_0(void) { + cur_obj_set_pos_to_home(); ++#ifndef NODRAWINGDISTANCE + if (find_water_level(o->oPosX, o->oPosZ) < o->oPosY && o->oDistanceToMario < 4000.0f) { ++#endif + cur_obj_become_tangible(); + cur_obj_unhide(); + o->oAction = 1; ++#ifndef NODRAWINGDISTANCE + } else { + cur_obj_become_intangible(); + cur_obj_hide(); + } ++#endif + } + + void (*sHeaveHoActions[])(void) = { heave_ho_act_0, heave_ho_act_1, heave_ho_act_2, heave_ho_act_3 }; +diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c +index 63a7575..af1cb0a 100644 +--- a/src/game/behaviors/king_bobomb.inc.c ++++ b/src/game/behaviors/king_bobomb.inc.c +@@ -295,10 +295,14 @@ void king_bobomb_move(void) { + cur_obj_move_using_fvel_and_gravity(); + cur_obj_call_action_function(sKingBobombActions); + exec_anim_sound_state(sKingBobombSoundStates); ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario < 5000.0f) ++#endif + cur_obj_enable_rendering(); ++#ifndef NODRAWINGDISTANCE + else + cur_obj_disable_rendering(); ++#endif + } + + void bhv_king_bobomb_loop(void) { +diff --git a/src/game/behaviors/pokey.inc.c b/src/game/behaviors/pokey.inc.c +index df5d11f..cfcc92c 100644 +--- a/src/game/behaviors/pokey.inc.c ++++ b/src/game/behaviors/pokey.inc.c +@@ -151,7 +151,9 @@ static void pokey_act_uninitialized(void) { + s32 i; + s16 partModel; + ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario < 2000.0f) { ++#endif + partModel = MODEL_POKEY_HEAD; + + for (i = 0; i < 5; i++) { +@@ -170,7 +172,9 @@ static void pokey_act_uninitialized(void) { + o->oPokeyNumAliveBodyParts = 5; + o->oPokeyBottomBodyPartSize = 1.0f; + o->oAction = POKEY_ACT_WANDER; ++#ifndef NODRAWINGDISTANCE + } ++#endif + } + + /** +@@ -185,9 +189,11 @@ static void pokey_act_wander(void) { + + if (o->oPokeyNumAliveBodyParts == 0) { + obj_mark_for_deletion(o); ++#ifndef NODRAWINGDISTANCE + } else if (o->oDistanceToMario > 2500.0f) { + o->oAction = POKEY_ACT_UNLOAD_PARTS; + o->oForwardVel = 0.0f; ++#endif + } else { + treat_far_home_as_mario(1000.0f); + cur_obj_update_floor_and_walls(); +diff --git a/src/game/behaviors/snufit.inc.c b/src/game/behaviors/snufit.inc.c +index f3a0c9e..76e78c0 100644 +--- a/src/game/behaviors/snufit.inc.c ++++ b/src/game/behaviors/snufit.inc.c +@@ -180,7 +180,11 @@ void bhv_snufit_loop(void) { + void bhv_snufit_balls_loop(void) { + // If far from Mario or in a different room, despawn. + if ((o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) ++#ifndef NODRAWINGDISTANCE + || (o->oTimer != 0 && o->oDistanceToMario > 1500.0f)) { ++#else ++ || (o->oTimer != 0)) { ++#endif + obj_mark_for_deletion(o); + } + +diff --git a/src/game/behaviors/triplet_butterfly.inc.c b/src/game/behaviors/triplet_butterfly.inc.c +index 1c2b926..3d16a9d 100644 +--- a/src/game/behaviors/triplet_butterfly.inc.c ++++ b/src/game/behaviors/triplet_butterfly.inc.c +@@ -54,9 +54,11 @@ static void triplet_butterfly_act_init(void) { + } + + static void triplet_butterfly_act_wander(void) { ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario > 1500.0f) { + obj_mark_for_deletion(o); + } else { ++#endif + approach_f32_ptr(&o->oTripletButterflySpeed, 8.0f, 0.5f); + if (o->oTimer < 60) { + o->oTripletButterflyTargetYaw = cur_obj_angle_to_home(); +@@ -82,7 +84,9 @@ static void triplet_butterfly_act_wander(void) { + + obj_move_pitch_approach(o->oTripletButterflyTargetPitch, 400); + cur_obj_rotate_yaw_toward(o->oTripletButterflyTargetYaw, random_linear_offset(400, 800)); ++#ifndef NODRAWINGDISTANCE + } ++#endif + } + + static void triplet_butterfly_act_activate(void) { +diff --git a/src/game/behaviors/water_bomb_cannon.inc.c b/src/game/behaviors/water_bomb_cannon.inc.c +index 8e9ba33..fb82e43 100644 +--- a/src/game/behaviors/water_bomb_cannon.inc.c ++++ b/src/game/behaviors/water_bomb_cannon.inc.c +@@ -38,19 +38,27 @@ void bhv_bubble_cannon_barrel_loop(void) { + } + + void water_bomb_cannon_act_0(void) { ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario < 2000.0f) { ++#endif + spawn_object(o, MODEL_CANNON_BARREL, bhvCannonBarrelBubbles); + cur_obj_unhide(); + + o->oAction = 1; + o->oMoveAnglePitch = o->oWaterCannonUnkFC = 0x1C00; ++#ifndef NODRAWINGDISTANCE + } ++#endif + } + + void water_bomb_cannon_act_1(void) { ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario > 2500.0f) { + o->oAction = 2; + } else if (o->oBehParams2ndByte == 0) { ++#else ++ if (o->oBehParams2ndByte == 0) { ++#endif + if (o->oWaterCannonUnkF4 != 0) { + o->oWaterCannonUnkF4 -= 1; + } else { +diff --git a/src/game/behaviors/whirlpool.inc.c b/src/game/behaviors/whirlpool.inc.c +index 405e051..5aebebd 100644 +--- a/src/game/behaviors/whirlpool.inc.c ++++ b/src/game/behaviors/whirlpool.inc.c +@@ -35,7 +35,9 @@ void whirpool_orient_graph(void) { + } + + void bhv_whirlpool_loop(void) { ++#ifndef NODRAWINGDISTANCE + if (o->oDistanceToMario < 5000.0f) { ++#endif + o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; + + // not sure if actually an array +@@ -52,10 +54,12 @@ void bhv_whirlpool_loop(void) { + whirpool_orient_graph(); + + o->oFaceAngleYaw += 0x1F40; ++#ifndef NODRAWINGDISTANCE + } else { + o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; + gEnvFxBubbleConfig[ENVFX_STATE_PARTICLECOUNT] = 0; + } ++#endif + + cur_obj_play_sound_1(SOUND_ENV_WATER); + From 0209a83621db232bb6f38eb19f0c8511789104fe Mon Sep 17 00:00:00 2001 From: uwabami Date: Wed, 13 May 2020 09:25:45 +0200 Subject: [PATCH 08/22] Increase GFX_POOL_SIZE to fix overflow in 32bit version - thanks fgsfds --- src/game/display.h | 2 +- src/game/game_init.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/display.h b/src/game/display.h index 0c427111..877c4f0b 100644 --- a/src/game/display.h +++ b/src/game/display.h @@ -3,7 +3,7 @@ #include "types.h" -#define GFX_POOL_SIZE 6400 +#define GFX_POOL_SIZE 64000 extern u16 frameBufferIndex; extern u32 gGlobalTimer; diff --git a/src/game/game_init.h b/src/game/game_init.h index 68db7426..019bad4d 100644 --- a/src/game/game_init.h +++ b/src/game/game_init.h @@ -51,7 +51,7 @@ extern struct MarioAnimation gDemo; extern u8 gMarioAnims[]; extern u8 gDemoInputs[]; -#define GFX_POOL_SIZE 6400 +#define GFX_POOL_SIZE 64000 struct GfxPool { Gfx buffer[GFX_POOL_SIZE]; From 8c311a62f0bab78872d55955f4675b959be97a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= Date: Wed, 13 May 2020 11:25:22 -0300 Subject: [PATCH 09/22] Fix some overflow issues As found out by @fgsfdsfgs, increase the GFX pool size as to eliminate current overflow-related crashes. --- src/game/display.h | 2 +- src/game/game_init.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/display.h b/src/game/display.h index 0c427111..877c4f0b 100644 --- a/src/game/display.h +++ b/src/game/display.h @@ -3,7 +3,7 @@ #include "types.h" -#define GFX_POOL_SIZE 6400 +#define GFX_POOL_SIZE 64000 extern u16 frameBufferIndex; extern u32 gGlobalTimer; diff --git a/src/game/game_init.h b/src/game/game_init.h index 68db7426..019bad4d 100644 --- a/src/game/game_init.h +++ b/src/game/game_init.h @@ -51,7 +51,7 @@ extern struct MarioAnimation gDemo; extern u8 gMarioAnims[]; extern u8 gDemoInputs[]; -#define GFX_POOL_SIZE 6400 +#define GFX_POOL_SIZE 64000 struct GfxPool { Gfx buffer[GFX_POOL_SIZE]; From 933daaaf7536670e9632d92a56df0614fa79ecf8 Mon Sep 17 00:00:00 2001 From: Hy! <3067205+Hyenadae@users.noreply.github.com> Date: Wed, 13 May 2020 11:35:22 -0300 Subject: [PATCH 10/22] Update to pisetup.sh Fixed current-directory asset placement hints and some minor text changes --- pisetup.sh | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/pisetup.sh b/pisetup.sh index cfd97320..5b34c233 100755 --- a/pisetup.sh +++ b/pisetup.sh @@ -1,4 +1,8 @@ #!/bin/bash +# Super Mario 64 PC on Raspberry Pi +# Find latest updates and code on https://www.github.com/sm64pc/sm64pc +# ToDo: Test on more Pi models with fresh Raspbian and allow existing src folders to be updated. +# clear echo "This script will assist with compiling Super Mario 64 on Raspbian 10" echo "Note that accelerated OpenGL (vc4_drm) is required for maximum performance" @@ -65,7 +69,8 @@ clear echo "Super Mario 64 RPi Initial Setup" if [[ $pi != 4 ]] -then #Dumb idea, but quick hack. We CANNOT enable VC4 for Pi4. +then #Dumb idea, but quick hack. + #We CANNOT enable VC4 for Pi4 as it uses VC6 inxinf=$(inxi -Gx) echo "Checking for pre-enabled VC4 acceleration (inxi -Gx)" @@ -119,24 +124,24 @@ fixmem=$(cat /boot/cmdline.txt | grep cma=128M) else echo "" - echo "Warning: VC4 enabled, but your Rasp Pi has 512MB or less RAM" + echo "Warning: VC4 enabled, but your RasPi has 512MB or less RAM" echo "To ensure VC4_DRM and game compilation is succesful, video memory will be reduced" echo "gpu_mem=48M (config.txt) | cma=128M (cmdline.txt) will be written to /boot " echo "" read -p "Fix mem? (Y/N): " fixmem - if [[ $fixmem =~ "Y" ]] - then - sudo sh -c "echo 'gpu_mem=48' >> /boot/config.txt" - sudo sh -c "echo 'cma=128M' >> /boot/cmdline.txt" - sync - echo "Wrote configuration changes to SD card." - sleep 2 - else - echo "" - echo "Warning: Compilation freezes & errors are likely to occur on your Pi" - echo "" - sleep 3 + if [[ $fixmem =~ "Y" ]] + then + sudo sh -c "echo 'gpu_mem=48' >> /boot/config.txt" + sudo sh -c "echo 'cma=128M' >> /boot/cmdline.txt" + sync + echo "Wrote configuration changes to SD card." + sleep 2 + else + echo "" + echo "Warning: Compilation freezes & errors are likely to occur on your Pi" + echo "" + sleep 3 fi fi fi @@ -149,11 +154,12 @@ read -p "Reboot to enable changes? (Y/N): " fixstart if [[ $fixstart =~ "Y" ]] then echo "" - echo "Rebooting RasPi!" + echo "Rebooting RasPi in 4 seconds! Press Control-C to cancel." + sleep 4 sudo reboot fi -fi -fi #This should never run on a Pi 4 + fi +fi # "Should never run on a Pi 4" part ends here #-------------------------------------------------------------------------------- #------------------------------------------------------------------------------- @@ -182,7 +188,7 @@ fi #------------------------------------------------------------------------------------- clear echo "Optional: Compile SDL2 with 'KMSDRM' for enhanced performance?" -echo "KMSDRM allows Super Mario 64 to be run without GUI/Desktop enabled on boot." +echo "KMSDRM allows Super Mario 64 to be run without GUI/Desktop (Xorg) enabled on boot" echo "" echo "Warning: Compile could take up to an hour on older Raspberry Pi models" read -p "Proceed? (Y/N): " sdlcomp @@ -293,7 +299,12 @@ echo "" echo "Step 3. Compiling Super Mario 64 for the Raspberry Pi" echo "" echo "Warning: Super Mario 64 assets are required in order to compile" +if [[ $curdir ==1 ]] +then +echo "Assets will be extracted from "$PWD" " +else echo "Assets will be extracted from $HOME/src/sm64pi/sm64pc/baserom.(us/eu/jp).z64 " +fi if [[ $curdir == 1 ]] then @@ -312,12 +323,15 @@ else echo "" echo "Please satisfy this requirement before continuing." echo "Exiting Super Mario 64 RasPi setup and compilation script." +echo "" echo "Note: Re-run script once baserom(s) are inserted into" if [[ $curdir == 1 ]] then echo $PWD +echo "" else +echo "" echo $HOME/src/sm64pi/sm64pc/ fi From 82e872d5dae133c220b3662ca419d43201f910a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Wed, 13 May 2020 13:23:52 -0300 Subject: [PATCH 11/22] Show the console on Windows setting `WINDOWS_CONSOLE=1` --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 5e5d3881..9edf6b8b 100644 --- a/Makefile +++ b/Makefile @@ -458,6 +458,9 @@ else ifeq ($(WINDOWS_BUILD),1) LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static +ifeq ($(WINDOWS_CONSOLE),1) +LDFLAGS += -mconsole +endif else # Linux / Other builds below From ec810d4222b0b7e3643f7290f9efe824a28975b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Wed, 13 May 2020 21:18:22 -0300 Subject: [PATCH 12/22] Fix black edge caused by UB Seems to affect certain targets such as `aarch64`. This fix originally by @Emill. --- include/gfx_dimensions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/gfx_dimensions.h b/include/gfx_dimensions.h index dfc0394d..5dc8f6b8 100644 --- a/include/gfx_dimensions.h +++ b/include/gfx_dimensions.h @@ -6,8 +6,8 @@ #include "pc/gfx/gfx_pc.h" #define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (SCREEN_WIDTH / 2 - SCREEN_HEIGHT / 2 * gfx_current_dimensions.aspect_ratio + (v)) #define GFX_DIMENSIONS_FROM_RIGHT_EDGE(v) (SCREEN_WIDTH / 2 + SCREEN_HEIGHT / 2 * gfx_current_dimensions.aspect_ratio - (v)) -#define GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(v) floorf(GFX_DIMENSIONS_FROM_LEFT_EDGE(v)) -#define GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(v) ceilf(GFX_DIMENSIONS_FROM_RIGHT_EDGE(v)) +#define GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(v) ((int)floorf(GFX_DIMENSIONS_FROM_LEFT_EDGE(v))) +#define GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(v) ((int)ceilf(GFX_DIMENSIONS_FROM_RIGHT_EDGE(v))) #define GFX_DIMENSIONS_ASPECT_RATIO (gfx_current_dimensions.aspect_ratio) #else #define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (v) From bbd3cb5abedf17777bd2a19c69fa27f85d9ef6bc Mon Sep 17 00:00:00 2001 From: uwabami Date: Thu, 14 May 2020 16:11:59 +0200 Subject: [PATCH 13/22] fix bugged Heave-Ho in Wet-Dry World --- src/game/behaviors/heave_ho.inc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/behaviors/heave_ho.inc.c b/src/game/behaviors/heave_ho.inc.c index 2f9da864..2cbd1f0e 100644 --- a/src/game/behaviors/heave_ho.inc.c +++ b/src/game/behaviors/heave_ho.inc.c @@ -72,19 +72,19 @@ void heave_ho_act_3(void) { } void heave_ho_act_0(void) { - cur_obj_set_pos_to_home(); #ifndef NODRAWINGDISTANCE if (find_water_level(o->oPosX, o->oPosZ) < o->oPosY && o->oDistanceToMario < 4000.0f) { +#else + if (find_water_level(o->oPosX, o->oPosZ) < (o->oPosY - 50.0f)) { #endif + cur_obj_set_pos_to_home(); cur_obj_become_tangible(); cur_obj_unhide(); o->oAction = 1; -#ifndef NODRAWINGDISTANCE } else { cur_obj_become_intangible(); cur_obj_hide(); } -#endif } void (*sHeaveHoActions[])(void) = { heave_ho_act_0, heave_ho_act_1, heave_ho_act_2, heave_ho_act_3 }; From 010ee50f10620156792f46b9b067eb3759f2a0ed Mon Sep 17 00:00:00 2001 From: uwabami Date: Thu, 14 May 2020 16:24:00 +0200 Subject: [PATCH 14/22] fix Lakitu's cloud not appearing from a distance --- src/game/behaviors/enemy_lakitu.inc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/game/behaviors/enemy_lakitu.inc.c b/src/game/behaviors/enemy_lakitu.inc.c index 056c3f13..cacd732f 100644 --- a/src/game/behaviors/enemy_lakitu.inc.c +++ b/src/game/behaviors/enemy_lakitu.inc.c @@ -24,12 +24,16 @@ static struct ObjectHitbox sEnemyLakituHitbox = { * Wait for mario to approach, then spawn the cloud and become visible. */ static void enemy_lakitu_act_uninitialized(void) { +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 2000.0f) { +#endif spawn_object_relative_with_scale(CLOUD_BP_LAKITU_CLOUD, 0, 0, 0, 2.0f, o, MODEL_MIST, bhvCloud); cur_obj_unhide(); o->oAction = ENEMY_LAKITU_ACT_MAIN; +#ifndef NODRAWINGDISTANCE } +#endif } /** From 5492d2ee74456e384c0c2e85125ba73077998b8b Mon Sep 17 00:00:00 2001 From: uwabami Date: Thu, 14 May 2020 17:07:14 +0200 Subject: [PATCH 15/22] fix Fwoosh in Tall, Tall Mountain --- src/game/behaviors/butterfly.inc.c | 1 + src/game/behaviors/cloud.inc.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/game/behaviors/butterfly.inc.c b/src/game/behaviors/butterfly.inc.c index 9296ed50..8c0e7145 100644 --- a/src/game/behaviors/butterfly.inc.c +++ b/src/game/behaviors/butterfly.inc.c @@ -107,6 +107,7 @@ void bhv_butterfly_loop(void) { butterfly_act_return_home(); break; } + #ifndef NODRAWINGDISTANCE set_object_visibility(o, 3000); #endif diff --git a/src/game/behaviors/cloud.inc.c b/src/game/behaviors/cloud.inc.c index e5cb9bed..fa82e3f4 100644 --- a/src/game/behaviors/cloud.inc.c +++ b/src/game/behaviors/cloud.inc.c @@ -47,10 +47,14 @@ static void cloud_act_spawn_parts(void) { * Wait for mario to approach, then unhide and enter the spawn parts action. */ static void cloud_act_fwoosh_hidden(void) { +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 2000.0f) { +#endif cur_obj_unhide(); o->oAction = CLOUD_ACT_SPAWN_PARTS; +#ifndef NODRAWINGDISTANCE } +#endif } /** @@ -58,9 +62,11 @@ static void cloud_act_fwoosh_hidden(void) { * long enough, blow wind at him. */ static void cloud_fwoosh_update(void) { +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario > 2500.0f) { o->oAction = CLOUD_ACT_UNLOAD; } else { +#endif if (o->oCloudBlowing) { o->header.gfx.scale[0] += o->oCloudGrowSpeed; @@ -95,7 +101,9 @@ static void cloud_fwoosh_update(void) { } cur_obj_scale(o->header.gfx.scale[0]); +#ifndef NODRAWINGDISTANCE } +#endif } /** From 5072b85ed67c0afe355e4f2267e2ac830cf22ba5 Mon Sep 17 00:00:00 2001 From: uwabami Date: Thu, 14 May 2020 18:47:12 +0200 Subject: [PATCH 16/22] several fixes and improvements --- src/game/behaviors/bub.inc.c | 4 ++++ src/game/behaviors/butterfly.inc.c | 2 -- src/game/behaviors/fire_spitter.inc.c | 4 ++++ src/game/behaviors/lll_floating_wood_piece.inc.c | 6 ++++++ src/game/behaviors/lll_rotating_hex_flame.inc.c | 4 ++++ src/game/obj_behaviors.c | 4 ++++ 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/game/behaviors/bub.inc.c b/src/game/behaviors/bub.inc.c index e8e63096..7bf71690 100644 --- a/src/game/behaviors/bub.inc.c +++ b/src/game/behaviors/bub.inc.c @@ -8,11 +8,15 @@ void bub_spawner_act_0(void) { s32 i; s32 sp18 = o->oBirdChirpChirpUnkF4; +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 1500.0f) { +#endif for (i = 0; i < sp18; i++) spawn_object(o, MODEL_BUB, bhvBub); o->oAction = 1; +#ifndef NODRAWINGDISTANCE } +#endif } void bub_spawner_act_1(void) { diff --git a/src/game/behaviors/butterfly.inc.c b/src/game/behaviors/butterfly.inc.c index 8c0e7145..d435d8d8 100644 --- a/src/game/behaviors/butterfly.inc.c +++ b/src/game/behaviors/butterfly.inc.c @@ -108,7 +108,5 @@ void bhv_butterfly_loop(void) { break; } -#ifndef NODRAWINGDISTANCE set_object_visibility(o, 3000); -#endif } diff --git a/src/game/behaviors/fire_spitter.inc.c b/src/game/behaviors/fire_spitter.inc.c index d64bcf7e..a703b03d 100644 --- a/src/game/behaviors/fire_spitter.inc.c +++ b/src/game/behaviors/fire_spitter.inc.c @@ -1,10 +1,14 @@ static void fire_spitter_act_idle(void) { approach_f32_ptr(&o->header.gfx.scale[0], 0.2f, 0.002f); +#ifndef NODRAWINGDISTANCE if (o->oTimer > 150 && o->oDistanceToMario < 800.0f && !(o->oMoveFlags & 0x00000078)) { +#endif o->oAction = FIRE_SPITTER_ACT_SPIT_FIRE; o->oFireSpitterScaleVel = 0.05f; +#ifndef NODRAWINGDISTANCE } +#endif } static void fire_spitter_act_spit_fire(void) { diff --git a/src/game/behaviors/lll_floating_wood_piece.inc.c b/src/game/behaviors/lll_floating_wood_piece.inc.c index a484471c..fad31f3f 100644 --- a/src/game/behaviors/lll_floating_wood_piece.inc.c +++ b/src/game/behaviors/lll_floating_wood_piece.inc.c @@ -14,18 +14,24 @@ void bhv_lll_floating_wood_bridge_loop(void) { s32 i; switch (o->oAction) { case 0: +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 2500.0f) { +#endif for (i = 1; i < 4; i++) { sp3C = spawn_object_relative(0, (i - 2) * 300, 0, 0, o, MODEL_LLL_WOOD_BRIDGE, bhvLllWoodPiece); sp3C->oLllWoodPieceUnkF4 = i * 4096; } o->oAction = 1; +#ifndef NODRAWINGDISTANCE } +#endif break; case 1: +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario > 2600.0f) o->oAction = 2; +#endif break; case 2: o->oAction = 0; diff --git a/src/game/behaviors/lll_rotating_hex_flame.inc.c b/src/game/behaviors/lll_rotating_hex_flame.inc.c index efabfca8..fc707330 100644 --- a/src/game/behaviors/lll_rotating_hex_flame.inc.c +++ b/src/game/behaviors/lll_rotating_hex_flame.inc.c @@ -30,7 +30,9 @@ void fire_bar_spawn_flames(s16 a0) { } void fire_bar_act_0(void) { +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario < 3000.0f) +#endif o->oAction = 1; } @@ -45,8 +47,10 @@ void fire_bar_act_1(void) { void fire_bar_act_2(void) { o->oAngleVelYaw = -0x100; o->oMoveAngleYaw += o->oAngleVelYaw; +#ifndef NODRAWINGDISTANCE if (o->oDistanceToMario > 3200.0f) o->oAction = 3; +#endif } void fire_bar_act_3(void) { diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index 0e2c7c86..68cebe5d 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -527,11 +527,15 @@ void set_object_visibility(struct Object *obj, s32 dist) { f32 objY = obj->oPosY; f32 objZ = obj->oPosZ; +#ifndef NODRAWINGDISTANCE if (is_point_within_radius_of_mario(objX, objY, objZ, dist) == TRUE) { +#endif obj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; +#ifndef NODRAWINGDISTANCE } else { obj->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; } +#endif } /** From 8866110ee5972dea46cbe36f992ba0da96fd7d81 Mon Sep 17 00:00:00 2001 From: uwabami Date: Thu, 14 May 2020 19:08:30 +0200 Subject: [PATCH 17/22] fix Fire Spitter --- src/game/behaviors/fire_spitter.inc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/game/behaviors/fire_spitter.inc.c b/src/game/behaviors/fire_spitter.inc.c index a703b03d..d64bcf7e 100644 --- a/src/game/behaviors/fire_spitter.inc.c +++ b/src/game/behaviors/fire_spitter.inc.c @@ -1,14 +1,10 @@ static void fire_spitter_act_idle(void) { approach_f32_ptr(&o->header.gfx.scale[0], 0.2f, 0.002f); -#ifndef NODRAWINGDISTANCE if (o->oTimer > 150 && o->oDistanceToMario < 800.0f && !(o->oMoveFlags & 0x00000078)) { -#endif o->oAction = FIRE_SPITTER_ACT_SPIT_FIRE; o->oFireSpitterScaleVel = 0.05f; -#ifndef NODRAWINGDISTANCE } -#endif } static void fire_spitter_act_spit_fire(void) { From 46dc8cc563845d1231847cd63a5c2db49d3a12a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Thu, 14 May 2020 14:47:59 -0300 Subject: [PATCH 18/22] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fc8e1320..92b4f75c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ Run `./extract-assets.py --clean && make clean` or `make distclean` to remove RO * Variable aspect ratio and resolution. The game can now correctly render at basically any window size. * Native xinput controller support. On Linux, DualShock 4 has been confirmed to work plug-and-play. * Analog camera control and mouse look. (Activate with `make BETTERCAMERA=1`.) + * An option to disable drawing distances. (Activate with `make NODRAWINGDISTANCES=1`.) + * In-game control binding, currently available on the `testing` branch. ## Building For building instructions, please refer to the [wiki](https://github.com/sm64pc/sm64pc/wiki). From 00d165b396ff588a6a2370470cd4cdf2e494189b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Thu, 14 May 2020 14:49:05 -0300 Subject: [PATCH 19/22] Typo fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92b4f75c..d28d5de0 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Run `./extract-assets.py --clean && make clean` or `make distclean` to remove RO * Variable aspect ratio and resolution. The game can now correctly render at basically any window size. * Native xinput controller support. On Linux, DualShock 4 has been confirmed to work plug-and-play. * Analog camera control and mouse look. (Activate with `make BETTERCAMERA=1`.) - * An option to disable drawing distances. (Activate with `make NODRAWINGDISTANCES=1`.) + * An option to disable drawing distances. (Activate with `make NODRAWINGDISTANCE=1`.) * In-game control binding, currently available on the `testing` branch. ## Building From 943590bdebb99c00719bfba96fd00d7241cf67ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= Date: Thu, 14 May 2020 14:57:47 -0300 Subject: [PATCH 20/22] Remove patch as functionality has been merged --- enhancements/no_draw_distance/README.md | 10 - .../no_draw_distance/nodrawdistance.patch | 406 ------------------ 2 files changed, 416 deletions(-) delete mode 100644 enhancements/no_draw_distance/README.md delete mode 100644 enhancements/no_draw_distance/nodrawdistance.patch diff --git a/enhancements/no_draw_distance/README.md b/enhancements/no_draw_distance/README.md deleted file mode 100644 index dd890383..00000000 --- a/enhancements/no_draw_distance/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# No Draw Distances - -This is a work-in-progress by [wabberz](https://github.com/wabberz) that disables the drawing distance for most objects and enemies. - -**This will crash some levels in the 32-bit version**. - -[Related Push Request](https://github.com/sm64pc/sm64pc/pull/75). - -For instructions on how to apply patches, please refer to [the Wiki](https://github.com/sm64pc/sm64pc/wiki/Patches). - diff --git a/enhancements/no_draw_distance/nodrawdistance.patch b/enhancements/no_draw_distance/nodrawdistance.patch deleted file mode 100644 index b986b1a6..00000000 --- a/enhancements/no_draw_distance/nodrawdistance.patch +++ /dev/null @@ -1,406 +0,0 @@ -From c98a263cf40520bf0d131eb2d1a2f90240787c98 Mon Sep 17 00:00:00 2001 -From: uwabami -Date: Tue, 12 May 2020 09:26:16 +0200 -Subject: [PATCH] adding option to disable draw distance - ---- - Makefile | 8 ++++++++ - src/engine/behavior_script.c | 4 ++++ - src/engine/surface_load.c | 4 ++++ - src/game/behaviors/butterfly.inc.c | 3 ++- - src/game/behaviors/chain_chomp.inc.c | 8 ++++++++ - src/game/behaviors/coin.inc.c | 6 ++++++ - src/game/behaviors/fish.inc.c | 4 ++++ - src/game/behaviors/goomba.inc.c | 4 ++++ - src/game/behaviors/heave_ho.inc.c | 4 ++++ - src/game/behaviors/king_bobomb.inc.c | 4 ++++ - src/game/behaviors/pokey.inc.c | 6 ++++++ - src/game/behaviors/snufit.inc.c | 4 ++++ - src/game/behaviors/triplet_butterfly.inc.c | 4 ++++ - src/game/behaviors/water_bomb_cannon.inc.c | 8 ++++++++ - src/game/behaviors/whirlpool.inc.c | 4 ++++ - 15 files changed, 74 insertions(+), 1 deletion(-) - -diff --git a/Makefile b/Makefile -index d4bd284..efeb63e 100644 ---- a/Makefile -+++ b/Makefile -@@ -27,6 +27,8 @@ COMPILER ?= ido - - # Disable better camera by default - BETTERCAMERA ?= 0 -+# Disable no drawing distance by default -+NODRAWINGDISTANCE ?= 0 - - # Build for Emscripten/WebGL - TARGET_WEB ?= 0 -@@ -449,6 +451,12 @@ CC_CHECK += -DBETTERCAMERA - CFLAGS += -DBETTERCAMERA - endif - -+# Check for no drawing distance option -+ifeq ($(NODRAWINGDISTANCE),1) -+CC_CHECK += -DNODRAWINGDISTANCE -+CFLAGS += -DNODRAWINGDISTANCE -+endif -+ - ASFLAGS := -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) - - ifeq ($(TARGET_WEB),1) -diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c -index edd5247..feb6fef 100644 ---- a/src/engine/behavior_script.c -+++ b/src/engine/behavior_script.c -@@ -987,11 +987,15 @@ void cur_obj_update(void) { - } else if ((objFlags & OBJ_FLAG_COMPUTE_DIST_TO_MARIO) && gCurrentObject->collisionData == NULL) { - if (!(objFlags & OBJ_FLAG_ACTIVE_FROM_AFAR)) { - // If the object has a render distance, check if it should be shown. -+#ifndef NODRAWINGDISTANCE - if (distanceFromMario > gCurrentObject->oDrawingDistance) { - // Out of render distance, hide the object. - gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; - gCurrentObject->activeFlags |= ACTIVE_FLAG_FAR_AWAY; - } else if (gCurrentObject->oHeldState == HELD_FREE) { -+#else -+ if (distanceFromMario <= gCurrentObject->oDrawingDistance && gCurrentObject->oHeldState == HELD_FREE) { -+#endif - // In render distance (and not being held), show the object. - gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; - gCurrentObject->activeFlags &= ~ACTIVE_FLAG_FAR_AWAY; -diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c -index 363f9af..498fae0 100644 ---- a/src/engine/surface_load.c -+++ b/src/engine/surface_load.c -@@ -789,9 +789,13 @@ void load_object_collision_model(void) { - } - } - -+#ifndef NODRAWINGDISTANCE - if (marioDist < gCurrentObject->oDrawingDistance) { -+#endif - gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; -+#ifndef NODRAWINGDISTANCE - } else { - gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; - } -+#endif - } -diff --git a/src/game/behaviors/butterfly.inc.c b/src/game/behaviors/butterfly.inc.c -index d435d8d..9296ed5 100644 ---- a/src/game/behaviors/butterfly.inc.c -+++ b/src/game/behaviors/butterfly.inc.c -@@ -107,6 +107,7 @@ void bhv_butterfly_loop(void) { - butterfly_act_return_home(); - break; - } -- -+#ifndef NODRAWINGDISTANCE - set_object_visibility(o, 3000); -+#endif - } -diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c -index a77c5d5..9b9c342 100644 ---- a/src/game/behaviors/chain_chomp.inc.c -+++ b/src/game/behaviors/chain_chomp.inc.c -@@ -53,7 +53,9 @@ static void chain_chomp_act_uninitialized(void) { - struct ChainSegment *segments; - s32 i; - -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 3000.0f) { -+#endif - segments = mem_pool_alloc(gObjectMemoryPool, 5 * sizeof(struct ChainSegment)); - if (segments != NULL) { - // Each segment represents the offset of a chain part to the pivot. -@@ -81,7 +83,9 @@ static void chain_chomp_act_uninitialized(void) { - cur_obj_unhide(); - } - } -+#ifndef NODRAWINGDISTANCE - } -+#endif - } - - /** -@@ -359,10 +363,12 @@ static void chain_chomp_act_move(void) { - f32 maxDistToPivot; - - // Unload chain if mario is far enough -+#ifndef NODRAWINGDISTANCE - if (o->oChainChompReleaseStatus == CHAIN_CHOMP_NOT_RELEASED && o->oDistanceToMario > 4000.0f) { - o->oAction = CHAIN_CHOMP_ACT_UNLOAD_CHAIN; - o->oForwardVel = o->oVelY = 0.0f; - } else { -+#endif - cur_obj_update_floor_and_walls(); - - switch (o->oChainChompReleaseStatus) { -@@ -446,7 +452,9 @@ static void chain_chomp_act_move(void) { - o->oGravity = -4.0f; - o->oChainChompTargetPitch = -0x3000; - } -+#ifndef NODRAWINGDISTANCE - } -+#endif - } - - /** -diff --git a/src/game/behaviors/coin.inc.c b/src/game/behaviors/coin.inc.c -index 913c583..05619b9 100644 ---- a/src/game/behaviors/coin.inc.c -+++ b/src/game/behaviors/coin.inc.c -@@ -184,17 +184,23 @@ void bhv_coin_formation_loop(void) { - s32 bitIndex; - switch (o->oAction) { - case 0: -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 2000.0f) { -+#endif - for (bitIndex = 0; bitIndex < 8; bitIndex++) { - if (!(o->oCoinUnkF4 & (1 << bitIndex))) - spawn_coin_in_formation(bitIndex, o->oBehParams2ndByte); - } - o->oAction++; -+#ifndef NODRAWINGDISTANCE - } -+#endif - break; - case 1: -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario > 2100.0f) - o->oAction++; -+#endif - break; - case 2: - o->oAction = 0; -diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c -index 839ab8d..f652ef4 100644 ---- a/src/game/behaviors/fish.inc.c -+++ b/src/game/behaviors/fish.inc.c -@@ -42,7 +42,9 @@ void fish_act_spawn(void) { - * If the current level is Secret Aquarium, ignore this requirement. - * Fish moves at random with a max-range of 700.0f. - */ -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < minDistToMario || gCurrLevelNum == LEVEL_SA) { -+#endif - for (i = 0; i < schoolQuantity; i++) { - fishObject = spawn_object(o, model, bhvFish); - fishObject->oBehParams2ndByte = o->oBehParams2ndByte; -@@ -50,7 +52,9 @@ void fish_act_spawn(void) { - obj_translate_xyz_random(fishObject, 700.0f); - } - o->oAction = FISH_ACT_ACTIVE; -+#ifndef NODRAWINGDISTANCE - } -+#endif - } - - /** -diff --git a/src/game/behaviors/goomba.inc.c b/src/game/behaviors/goomba.inc.c -index 2dab2fe..bf47dda 100644 ---- a/src/game/behaviors/goomba.inc.c -+++ b/src/game/behaviors/goomba.inc.c -@@ -78,7 +78,9 @@ void bhv_goomba_triplet_spawner_update(void) { - // If mario is close enough and the goombas aren't currently loaded, then - // spawn them - if (o->oAction == GOOMBA_TRIPLET_SPAWNER_ACT_UNLOADED) { -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 3000.0f) { -+#endif - // The spawner is capable of spawning more than 3 goombas, but this - // is not used in the game - dAngle = -@@ -98,11 +100,13 @@ void bhv_goomba_triplet_spawner_update(void) { - } - - o->oAction += 1; -+#ifndef NODRAWINGDISTANCE - } - } else if (o->oDistanceToMario > 4000.0f) { - // If mario is too far away, enter the unloaded action. The goombas - // will detect this and unload themselves - o->oAction = GOOMBA_TRIPLET_SPAWNER_ACT_UNLOADED; -+#endif - } - } - -diff --git a/src/game/behaviors/heave_ho.inc.c b/src/game/behaviors/heave_ho.inc.c -index 662bb0b..2f9da86 100644 ---- a/src/game/behaviors/heave_ho.inc.c -+++ b/src/game/behaviors/heave_ho.inc.c -@@ -73,14 +73,18 @@ void heave_ho_act_3(void) { - - void heave_ho_act_0(void) { - cur_obj_set_pos_to_home(); -+#ifndef NODRAWINGDISTANCE - if (find_water_level(o->oPosX, o->oPosZ) < o->oPosY && o->oDistanceToMario < 4000.0f) { -+#endif - cur_obj_become_tangible(); - cur_obj_unhide(); - o->oAction = 1; -+#ifndef NODRAWINGDISTANCE - } else { - cur_obj_become_intangible(); - cur_obj_hide(); - } -+#endif - } - - void (*sHeaveHoActions[])(void) = { heave_ho_act_0, heave_ho_act_1, heave_ho_act_2, heave_ho_act_3 }; -diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c -index 63a7575..af1cb0a 100644 ---- a/src/game/behaviors/king_bobomb.inc.c -+++ b/src/game/behaviors/king_bobomb.inc.c -@@ -295,10 +295,14 @@ void king_bobomb_move(void) { - cur_obj_move_using_fvel_and_gravity(); - cur_obj_call_action_function(sKingBobombActions); - exec_anim_sound_state(sKingBobombSoundStates); -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 5000.0f) -+#endif - cur_obj_enable_rendering(); -+#ifndef NODRAWINGDISTANCE - else - cur_obj_disable_rendering(); -+#endif - } - - void bhv_king_bobomb_loop(void) { -diff --git a/src/game/behaviors/pokey.inc.c b/src/game/behaviors/pokey.inc.c -index df5d11f..cfcc92c 100644 ---- a/src/game/behaviors/pokey.inc.c -+++ b/src/game/behaviors/pokey.inc.c -@@ -151,7 +151,9 @@ static void pokey_act_uninitialized(void) { - s32 i; - s16 partModel; - -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 2000.0f) { -+#endif - partModel = MODEL_POKEY_HEAD; - - for (i = 0; i < 5; i++) { -@@ -170,7 +172,9 @@ static void pokey_act_uninitialized(void) { - o->oPokeyNumAliveBodyParts = 5; - o->oPokeyBottomBodyPartSize = 1.0f; - o->oAction = POKEY_ACT_WANDER; -+#ifndef NODRAWINGDISTANCE - } -+#endif - } - - /** -@@ -185,9 +189,11 @@ static void pokey_act_wander(void) { - - if (o->oPokeyNumAliveBodyParts == 0) { - obj_mark_for_deletion(o); -+#ifndef NODRAWINGDISTANCE - } else if (o->oDistanceToMario > 2500.0f) { - o->oAction = POKEY_ACT_UNLOAD_PARTS; - o->oForwardVel = 0.0f; -+#endif - } else { - treat_far_home_as_mario(1000.0f); - cur_obj_update_floor_and_walls(); -diff --git a/src/game/behaviors/snufit.inc.c b/src/game/behaviors/snufit.inc.c -index f3a0c9e..76e78c0 100644 ---- a/src/game/behaviors/snufit.inc.c -+++ b/src/game/behaviors/snufit.inc.c -@@ -180,7 +180,11 @@ void bhv_snufit_loop(void) { - void bhv_snufit_balls_loop(void) { - // If far from Mario or in a different room, despawn. - if ((o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) -+#ifndef NODRAWINGDISTANCE - || (o->oTimer != 0 && o->oDistanceToMario > 1500.0f)) { -+#else -+ || (o->oTimer != 0)) { -+#endif - obj_mark_for_deletion(o); - } - -diff --git a/src/game/behaviors/triplet_butterfly.inc.c b/src/game/behaviors/triplet_butterfly.inc.c -index 1c2b926..3d16a9d 100644 ---- a/src/game/behaviors/triplet_butterfly.inc.c -+++ b/src/game/behaviors/triplet_butterfly.inc.c -@@ -54,9 +54,11 @@ static void triplet_butterfly_act_init(void) { - } - - static void triplet_butterfly_act_wander(void) { -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario > 1500.0f) { - obj_mark_for_deletion(o); - } else { -+#endif - approach_f32_ptr(&o->oTripletButterflySpeed, 8.0f, 0.5f); - if (o->oTimer < 60) { - o->oTripletButterflyTargetYaw = cur_obj_angle_to_home(); -@@ -82,7 +84,9 @@ static void triplet_butterfly_act_wander(void) { - - obj_move_pitch_approach(o->oTripletButterflyTargetPitch, 400); - cur_obj_rotate_yaw_toward(o->oTripletButterflyTargetYaw, random_linear_offset(400, 800)); -+#ifndef NODRAWINGDISTANCE - } -+#endif - } - - static void triplet_butterfly_act_activate(void) { -diff --git a/src/game/behaviors/water_bomb_cannon.inc.c b/src/game/behaviors/water_bomb_cannon.inc.c -index 8e9ba33..fb82e43 100644 ---- a/src/game/behaviors/water_bomb_cannon.inc.c -+++ b/src/game/behaviors/water_bomb_cannon.inc.c -@@ -38,19 +38,27 @@ void bhv_bubble_cannon_barrel_loop(void) { - } - - void water_bomb_cannon_act_0(void) { -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 2000.0f) { -+#endif - spawn_object(o, MODEL_CANNON_BARREL, bhvCannonBarrelBubbles); - cur_obj_unhide(); - - o->oAction = 1; - o->oMoveAnglePitch = o->oWaterCannonUnkFC = 0x1C00; -+#ifndef NODRAWINGDISTANCE - } -+#endif - } - - void water_bomb_cannon_act_1(void) { -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario > 2500.0f) { - o->oAction = 2; - } else if (o->oBehParams2ndByte == 0) { -+#else -+ if (o->oBehParams2ndByte == 0) { -+#endif - if (o->oWaterCannonUnkF4 != 0) { - o->oWaterCannonUnkF4 -= 1; - } else { -diff --git a/src/game/behaviors/whirlpool.inc.c b/src/game/behaviors/whirlpool.inc.c -index 405e051..5aebebd 100644 ---- a/src/game/behaviors/whirlpool.inc.c -+++ b/src/game/behaviors/whirlpool.inc.c -@@ -35,7 +35,9 @@ void whirpool_orient_graph(void) { - } - - void bhv_whirlpool_loop(void) { -+#ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 5000.0f) { -+#endif - o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; - - // not sure if actually an array -@@ -52,10 +54,12 @@ void bhv_whirlpool_loop(void) { - whirpool_orient_graph(); - - o->oFaceAngleYaw += 0x1F40; -+#ifndef NODRAWINGDISTANCE - } else { - o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; - gEnvFxBubbleConfig[ENVFX_STATE_PARTICLECOUNT] = 0; - } -+#endif - - cur_obj_play_sound_1(SOUND_ENV_WATER); - From c9d0230122b9fcbb2f7f7773d6735257cffa9b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Thu, 14 May 2020 15:25:11 -0300 Subject: [PATCH 21/22] Add --skip-intro mention --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d28d5de0..4a633108 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Run `./extract-assets.py --clean && make clean` or `make distclean` to remove RO * Analog camera control and mouse look. (Activate with `make BETTERCAMERA=1`.) * An option to disable drawing distances. (Activate with `make NODRAWINGDISTANCE=1`.) * In-game control binding, currently available on the `testing` branch. + * Skip introductory Peach & Lakitu cutscenes with a `--skip-intro` CLI option, currently available on `testing` and `skip-intro` branches. ## Building For building instructions, please refer to the [wiki](https://github.com/sm64pc/sm64pc/wiki). From c9cbdbe769d0399bb79c13d8554dfae54df7b8fc Mon Sep 17 00:00:00 2001 From: fgsfds Date: Fri, 15 May 2020 01:22:50 +0300 Subject: [PATCH 22/22] fix cursor on Mario head screen (fixes #28) gDPSetScissor fix originally by Emil --- src/goddard/renderer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/goddard/renderer.c b/src/goddard/renderer.c index b5b7fafb..06928dc7 100644 --- a/src/goddard/renderer.c +++ b/src/goddard/renderer.c @@ -22,6 +22,7 @@ #include "gd_math.h" #include "shape_helper.h" +#include "config.h" #include "gfx_dimensions.h" #define MAX_GD_DLS 1000 @@ -2326,7 +2327,7 @@ void start_view_dl(struct ObjView *view) { uly = lry - 1.0f; } - gDPSetScissor(next_gfx(), G_SC_NON_INTERLACE, ulx, uly, lrx, lry); + // gDPSetScissor(next_gfx(), G_SC_NON_INTERLACE, ulx, uly, lrx, lry); // N64 only gSPClearGeometryMode(next_gfx(), 0xFFFFFFFF); gSPSetGeometryMode(next_gfx(), G_LIGHTING | G_CULL_BACK | G_SHADING_SMOOTH | G_SHADE); if (view->flags & VIEW_ALLOC_ZBUF) { @@ -2985,9 +2986,9 @@ void update_cursor(void) { reset_dlnum_indices(sHandShape->gdDls[gGdFrameBuf]); if (gGdCtrl.btnApressed) { - gd_put_sprite((u16 *) gd_texture_hand_closed, sHandView->upperLeft.x, sHandView->upperLeft.y, 0x20, 0x20); + gd_put_sprite((u16 *) gd_texture_hand_closed, GFX_DIMENSIONS_FROM_LEFT_EDGE(sHandView->upperLeft.x), sHandView->upperLeft.y, 0x20, 0x20); } else { - gd_put_sprite((u16 *) gd_texture_hand_open, sHandView->upperLeft.x, sHandView->upperLeft.y, 0x20, 0x20); + gd_put_sprite((u16 *) gd_texture_hand_open, GFX_DIMENSIONS_FROM_LEFT_EDGE(sHandView->upperLeft.x), sHandView->upperLeft.y, 0x20, 0x20); } gd_enddlsplist_parent();