From 1098ea95ea1f14b75097d875f237c023a5b6e9cc Mon Sep 17 00:00:00 2001 From: Arceveti <73617174+Arceveti@users.noreply.github.com> Date: Mon, 28 Nov 2022 15:06:34 -0500 Subject: [PATCH] Merge master/2.0.5 into 2.1.0 (#536) * Imminent fixes for bugs found on master branch (#512) * The vanilla level checks define for Yoshi is inverted, causing him to require 120 stars when it is off and appear at 0 stars when it's on * The downwarp fix results in Mario levitating in midair when grabbing Bowser midair. While downwarps should still be fixed, the change should be reverted immediately until a better fix is made. * Some checks of Mario's floor class were using the wrong defines, which can lead to unexpected behavior in the event anyone wants to reorder surface types. By default the SURFACE_CLASS_SLIPPERY and SURFACE_SLIPPERY defines have the same value, which is why this mistake is hard to notice. * The firsty frames define was implemented poorly, not allowing for vanilla firsty behavior no matter what the values were set to. This has been reverted, while avoiding the UB in the original vanilla code. * Removed the ledge grab changes that fix QSLGs and change the false ledgegrab define since Arceveti wanted to in his PR * Update version to 2.0.4 (#515) * HackerSM64 2.0.5 (#517) * Bugfix: race condition with accessing cleared audio memory pools * Bugfix: skyboxes access tiles out of range when looking straight down (#518) * Vscode fixes (#516) * Revert s32 angles and remove Angle typedef usage (#529) * Fix some surface shadowing (#531) * Delete rtc.h * Remove `wait_for_audio_frames()` Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> Co-authored-by: Arceveti <73617174+Arceveti@users.noreply.github.com> Co-authored-by: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com> * Update VERSION.txt (#534) Co-authored-by: arthurtilly <32559225+arthurtilly@users.noreply.github.com> Co-authored-by: axollyon <20480418+axollyon@users.noreply.github.com> Co-authored-by: Gregory Heskett Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> Co-authored-by: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com> --- .vscode/c_cpp_properties.json | 2 +- Makefile | 8 ++ README.md | 3 +- VERSION.txt | 2 +- include/config/config_movement.h | 9 +-- include/rtc.h | 71 ----------------- include/surface_terrains.h | 2 +- include/types.h | 14 +--- src/audio/heap.c | 53 ++++++------- src/engine/math_util.c | 50 ++++++------ src/engine/math_util.h | 76 +++++++++---------- src/engine/surface_collision.c | 4 +- src/game/behaviors/boo.inc.c | 2 +- src/game/behaviors/hoot.inc.c | 4 +- .../lll_octagonal_rotating_mesh.inc.c | 8 +- src/game/behaviors/platform_on_track.inc.c | 2 +- src/game/behaviors/spawn_star.inc.c | 2 +- src/game/behaviors/yoshi.inc.c | 2 +- src/game/camera.c | 4 +- src/game/camera.h | 4 +- src/game/macro_special_objects.c | 2 +- src/game/mario.c | 24 +++--- src/game/mario_actions_airborne.c | 7 +- src/game/mario_actions_automatic.c | 2 - src/game/mario_step.c | 11 +-- src/game/skybox.c | 4 + 26 files changed, 146 insertions(+), 226 deletions(-) delete mode 100755 include/rtc.h diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 1c0a20dc..3ff5fdae 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -31,7 +31,7 @@ "compilerPath": "/usr/bin/mips-linux-gnu-gcc", "cStandard": "gnu17", "cppStandard": "gnu++14", - "intelliSenseMode": "linux-gcc-x64" + "intelliSenseMode": "linux-gcc-x86" } ], "version": 4 diff --git a/Makefile b/Makefile index 6c6e4e33..e75cb031 100644 --- a/Makefile +++ b/Makefile @@ -873,8 +873,16 @@ $(ELF): $(BUILD_DIR)/sm64_prelim.elf $(BUILD_DIR)/asm/debug/map.o $(O_FILES) $(Y $(V)$(LD) --gc-sections -L $(BUILD_DIR) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -T goddard.txt -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -L$(LIBS_DIR) -l$(ULTRALIB) -Llib $(LINK_LIBRARIES) -u sprintf -u osMapTLB -Llib/gcclib/$(LIBGCCDIR) -lgcc -lrtc # Build ROM +ifeq (n,$(findstring n,$(firstword -$(MAKEFLAGS)))) +# run with -n / --dry-run +$(ROM): + @$(PRINT) "$(BLUE)DRY RUNS ARE DISABLED$(NO_COL)\n" +else +# not running with -n / --dry-run $(ROM): $(ELF) $(call print,Building ROM:,$<,$@) +endif + ifeq ($(CONSOLE),n64) $(V)$(OBJCOPY) --pad-to=0x101000 --gap-fill=0xFF $< $@ -O binary else ifeq ($(CONSOLE),bb) diff --git a/README.md b/README.md index c399e901..0cb169fa 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This is a fork of the ultrasm64 repo by CrashOveride which includes the followin - **ArcticJaguar725**: Most audio configuration and layout changes, colored ia4 text, floombas, various bugfixes, and more - **CowQuack**: Adjustable skybox sizes, area-specific skybox function - **thecozies**: Water surface types, general maintenance, and time -- **MrComit**: General use object defines, JUMP_KICK_FIX, LEDGE_GRABS_CHECK_SLOPE_ANGLE +- **MrComit**: General use object defines, JUMP_KICK_FIX - **aglab2**: Bugfixes (particularly puppycam), refactor stuff - **someone2639**: math.s and crash screen disam, stack trace, map packing, shiftable segments 2, S2DEX engine - **Arthurtilly**: Platform Displacement 2 @@ -61,7 +61,6 @@ Thanks to Frame#5375 and AloXado320 for also helping with silhouette stuff - Toggle to disable fall damage and the fall damage sound * - Nonstop stars * - Removed course-specific camera processing * -- You can increase the number of frames that you have to perform a firsty * - Ability to set Mario's movement speed when hanging from a ceiling * - Tighter hanging controls (Mario will face the direction of the analog stick directly while hanging from a ceiling) * - reonucam3: custom camera by Reonu. This is included as a .patch file in the enhancements folder, you need to apply it if you want this camera. diff --git a/VERSION.txt b/VERSION.txt index f256be60..c2f6de90 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -v2.0.3 +v2.0.5 diff --git a/include/config/config_movement.h b/include/config/config_movement.h index dddf8f25..8f6c6542 100644 --- a/include/config/config_movement.h +++ b/include/config/config_movement.h @@ -108,20 +108,15 @@ */ #define HANGING_FIX -/** - * The last frame after hitting a wall that will be considered a firsty when wallkicking. - */ -#define FIRSTY_LAST_FRAME 1 - /** * The maximum angle the player can wall kick, in degrees. 0..90. To allow 45 degree wall kicks, you must supply `46` to allow 45 and under. */ #define WALL_KICK_DEGREES 45 /** - * This is vanilla behavior, disable it to allow ledge grabbing regardless of floor pitch. + * Makes Mario unable to ledge grab steep slopes to prevent false ledge grabs. */ -// #define LEDGE_GRABS_CHECK_SLOPE_ANGLE +// #define DONT_LEDGE_GRAB_STEEP_SLOPES /** * Disables BLJs and crushes SimpleFlips's dreams. diff --git a/include/rtc.h b/include/rtc.h deleted file mode 100755 index f6aec6a7..00000000 --- a/include/rtc.h +++ /dev/null @@ -1,71 +0,0 @@ -/*--------------------------------------------------------------------- - Copyright (C) 1997, 1998 Nintendo. - - File rtc.h - Coded by Shigeo Kimura. Oct 14, 1997. - Modified by Koji Mitsunari. Jan 22, 2001. - Comments Real Time Clock Library - ---------------------------------------------------------------------*/ -#ifndef _rtc_h_ -#define _rtc_h_ - -/*----------------------------------------------------------------------- - * Macro & constant definitions - *-----------------------------------------------------------------------*/ -/* Controller type */ -#define CONT_TYPE_RTC 0x1000 /* from os.h */ -#define RTC_WAIT 300 - -/* RTC status signed 32bits */ -#define RTC_NG_NOTHING 0x8000 -#define RTC_NG_WRITE 0x0100 -#define RTC_NG_ADDR 0x0200 -#define RTC_STATUS_BUSY 0x0080 -#define RTC_STATUS_DDOWN 0x0002 -#define RTC_STATUS_BDOWN 0x0001 - -/* RTC Error Code */ -#define CONT_ERR_RTC_BUSY 16 -#define CONT_ERR_RTC_BDOWN 17 -#define CONT_ERR_RTC_DDOWN 18 -#define CONT_ERR_RTC_BDDOWN 19 - -/* RTC bit status */ -#define RTC_EALM 0x80 -#define RTC_ALM 0x20 -#define RTC_WPB1 0x02 -#define RTC_WPB0 0x01 -#define RTC_MOD 0x04 -#define RTC_CHLD 0x02 -#define RTC_ADJ 0x01 - -#define RTC_ADDR_FLAG 0 -#define RTC_ADDR_RAM 1 -#define RTC_ADDR_TIME 2 - -typedef struct{ - u8 sec; /* second 0-59 */ - u8 min; /* minute 0-59 */ - u8 hour; /* hour 0-23 */ - u8 day; /* day 1-31 */ - u8 week; /* week 0-6(sun,mon,..,sat) */ - u8 month; /* month 1-12 */ - u16 year; /* year 1901-2099 */ -} OSRTCTime; - -/*----------------------------------------------------------------------- - * externs - *-----------------------------------------------------------------------*/ - -extern s32 osRTCInit( OSMesgQueue *mq); -extern s32 osRTCReadData( OSMesgQueue *mq, u8 *); -extern s32 osRTCWriteData( OSMesgQueue *mq, u8 *); -extern s32 osRTCGetTime( OSMesgQueue *mq, OSRTCTime *); -extern s32 osRTCSetTime( OSMesgQueue *mq, OSRTCTime *); -extern u32 osRTCGetIntervalTime(OSRTCTime *, OSRTCTime *); -extern s32 osRTCGetLaterTime(OSMesgQueue *mq, u32, OSRTCTime *); -extern s32 osRTCSetAlarm( OSMesgQueue *mq, u8, u8); -extern s32 osRTCGetAlarmStat(OSMesgQueue *mq, u8 *, u8 *, int *); -extern s32 osRTCProbe( OSMesgQueue *mq); - -#endif /* _rtc_h_ */ diff --git a/include/surface_terrains.h b/include/surface_terrains.h index 155ed250..765abacd 100644 --- a/include/surface_terrains.h +++ b/include/surface_terrains.h @@ -248,7 +248,7 @@ enum SurfaceTypes { enum SurfaceClass { SURFACE_CLASS_DEFAULT, - SURFACE_CLASS_VERY_SLIPPERY = 0x0013, + SURFACE_CLASS_VERY_SLIPPERY, SURFACE_CLASS_SLIPPERY, SURFACE_CLASS_NOT_SLIPPERY }; diff --git a/include/types.h b/include/types.h index 42614925..cd9dcd57 100644 --- a/include/types.h +++ b/include/types.h @@ -99,12 +99,6 @@ typedef s8 ObjAction8; typedef s32 ObjAction32; typedef s16 ColFlags; -// -- Angle -- -typedef s16 Angle; -typedef u16 UAngle; -typedef s32 Angle32; -typedef Angle Vec3a[3]; - // -- Collision -- typedef ROOM_DATA_TYPE RoomData; typedef COLLISION_DATA_TYPE Collision; // Collision is by default an s16, but it's best to have it match the type of COLLISION_DATA_TYPE @@ -490,10 +484,10 @@ struct MarioState { Vec3f prevPos; f32 lateralSpeed; f32 moveSpeed; - Angle movePitch; - Angle moveYaw; - Angle ceilYaw; - Angle wallYaw; + s16 movePitch; + s16 moveYaw; + s16 ceilYaw; + s16 wallYaw; // -- HackerSM64 MarioState fields end -- }; diff --git a/src/audio/heap.c b/src/audio/heap.c index 18800e8d..b7a924b4 100644 --- a/src/audio/heap.c +++ b/src/audio/heap.c @@ -969,22 +969,6 @@ s32 audio_shut_down_and_reset_step(void) { } return (gAudioResetStatus < 3); } -#else -/** - * Waits until a specified number of audio frames have been created - */ -void wait_for_audio_frames(s32 frames) { - // VC emulator stubs this function because busy loops are not supported - // Technically we can put infinite loop that _looks_ like -O0 for emu but this is cleaner - //if (gIsVC) { - return; - //} - gAudioFrameCount = 0; - // Sound thread will update gAudioFrameCount - while (gAudioFrameCount < frames) { - // spin - } -} #endif u8 sAudioIsInitialized = FALSE; @@ -1159,22 +1143,33 @@ void init_reverb_us(s32 presetId) { #if defined(VERSION_JP) || defined(VERSION_US) void audio_reset_session(struct AudioSessionSettings *preset, s32 presetId) { if (sAudioIsInitialized) { - bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS)); - persistent_pool_clear(&gSeqLoadedPool.persistent); - persistent_pool_clear(&gBankLoadedPool.persistent); - temporary_pool_clear( &gSeqLoadedPool.temporary); - temporary_pool_clear( &gBankLoadedPool.temporary); - reset_bank_and_seq_load_status(); + if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) { + gAudioLoadLock = AUDIO_LOCK_LOADING; - init_reverb_us(presetId); - bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS)); - gAudioFrameCount = 0; - if (!gIsVC) { - while (gAudioFrameCount < 1) { - // spin + if (!gIsVC) { + gAudioFrameCount = 0; + while (gAudioFrameCount < 1) { + // spin + } + } + + for (s32 i = 0; i < gMaxSimultaneousNotes; i++) { + gNotes[i].enabled = FALSE; + } + + persistent_pool_clear(&gSeqLoadedPool.persistent); + persistent_pool_clear(&gBankLoadedPool.persistent); + temporary_pool_clear( &gSeqLoadedPool.temporary); + temporary_pool_clear( &gBankLoadedPool.temporary); + reset_bank_and_seq_load_status(); + + init_reverb_us(presetId); + bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS)); + + if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) { + gAudioLoadLock = AUDIO_LOCK_NOT_LOADING; } } - bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS)); return; } #else diff --git a/src/engine/math_util.c b/src/engine/math_util.c index 8f6cb6a8..1d46a79e 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -503,7 +503,7 @@ void mtxf_rotate_xyz_and_translate_and_mul(Vec3s rot, Vec3f trans, Mat4 dest, Ma * at the position 'to'. The up-vector is assumed to be (0, 1, 0), but the 'roll' * angle allows a bank rotation of the camera. */ -void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s32 roll) { +void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll) { Vec3f colX, colY, colZ; register f32 dx = (to[0] - from[0]); register f32 dz = (to[2] - from[2]); @@ -543,7 +543,7 @@ void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s32 roll) { * 'scale' is the scale of the object. * 'angle' rotates the object while still facing the camera. */ -void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s32 angle) { +void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s16 angle) { register s32 i; register f32 sx = scale[0]; register f32 sy = scale[1]; @@ -590,7 +590,7 @@ void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s32 angle) * 'scale' is the scale of the shadow * 'yaw' is the angle which it should face */ -void mtxf_shadow(Mat4 dest, Vec3f upDir, Vec3f pos, Vec3f scale, s32 yaw) { +void mtxf_shadow(Mat4 dest, Vec3f upDir, Vec3f pos, Vec3f scale, s16 yaw) { Vec3f lateralDir; Vec3f leftDir; Vec3f forwardDir; @@ -615,7 +615,7 @@ void mtxf_shadow(Mat4 dest, Vec3f upDir, Vec3f pos, Vec3f scale, s32 yaw) { * 'yaw' is the angle which it should face * 'pos' is the object's position in the world */ -void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s32 yaw) { +void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw) { Vec3f lateralDir; Vec3f leftDir; Vec3f forwardDir; @@ -640,7 +640,7 @@ void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s32 yaw) { * 'pos' is the object's position in the world * 'radius' is the distance from each triangle vertex to the center */ -void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s32 yaw, f32 radius) { +void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) { struct Surface *floor; Vec3f point0, point1, point2; Vec3f forward; @@ -759,7 +759,7 @@ UNUSED void mtxf_mul_vec3s(Mat4 mtx, Vec3s b) { #define MATENTRY(a, b) \ ((s16 *) mtx)[a ] = (((s32) b) >> 16); \ ((s16 *) mtx)[a + 16] = (((s32) b) & 0xFFFF); -void mtxf_rotate_xy(Mtx *mtx, s32 angle) { +void mtxf_rotate_xy(Mtx *mtx, s16 angle) { register s32 i = (coss(angle) * 0x10000); register s32 j = (sins(angle) * 0x10000); register f32 *temp = (f32 *)mtx; @@ -841,7 +841,7 @@ void vec3f_get_angle(Vec3f from, Vec3f to, s16 *pitch, s16 *yaw) { } /// Finds the horizontal distance and pitch between two vectors. -void vec3f_get_lateral_dist_and_pitch(Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch) { +void vec3f_get_lateral_dist_and_pitch(Vec3f from, Vec3f to, f32 *lateralDist, s16 *pitch) { Vec3f d; vec3_diff(d, to, from); *lateralDist = sqrtf(sqr(d[0]) + sqr(d[2])); @@ -849,7 +849,7 @@ void vec3f_get_lateral_dist_and_pitch(Vec3f from, Vec3f to, f32 *lateralDist, An } /// Finds the horizontal distance and yaw between two vectors. -void vec3f_get_lateral_dist_and_yaw(Vec3f from, Vec3f to, f32 *lateralDist, Angle *yaw) { +void vec3f_get_lateral_dist_and_yaw(Vec3f from, Vec3f to, f32 *lateralDist, s16 *yaw) { register f32 dx = (to[0] - from[0]); register f32 dz = (to[2] - from[2]); *lateralDist = sqrtf(sqr(dx) + sqr(dz)); @@ -857,7 +857,7 @@ void vec3f_get_lateral_dist_and_yaw(Vec3f from, Vec3f to, f32 *lateralDist, Angl } /// Finds the horizontal distance and angles between two vectors. -void vec3f_get_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch, Angle *yaw) { +void vec3f_get_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *lateralDist, s16 *pitch, s16 *yaw) { Vec3f d; vec3_diff(d, to, from); *lateralDist = sqrtf(sqr(d[0]) + sqr(d[2])); @@ -866,7 +866,7 @@ void vec3f_get_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *lateralDist, An } /// Finds the distance and angles between two vectors. -void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, Angle *pitch, Angle *yaw) { +void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw) { Vec3f d; vec3_diff(d, to, from); register f32 xz = (sqr(d[0]) + sqr(d[2])); @@ -874,7 +874,7 @@ void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, Angle *pitch, Ang *pitch = atan2s(sqrtf(xz), d[1]); *yaw = atan2s(d[2], d[0]); } -void vec3s_get_dist_and_angle(Vec3s from, Vec3s to, s16 *dist, Angle *pitch, Angle *yaw) { +void vec3s_get_dist_and_angle(Vec3s from, Vec3s to, s16 *dist, s16 *pitch, s16 *yaw) { Vec3s d; vec3_diff(d, to, from); register f32 xz = (sqr(d[0]) + sqr(d[2])); @@ -882,7 +882,7 @@ void vec3s_get_dist_and_angle(Vec3s from, Vec3s to, s16 *dist, Angle *pitch, Ang *pitch = atan2s(sqrtf(xz), d[1]); *yaw = atan2s(d[2], d[0]); } -void vec3f_to_vec3s_get_dist_and_angle(Vec3f from, Vec3s to, f32 *dist, Angle *pitch, Angle *yaw) { +void vec3f_to_vec3s_get_dist_and_angle(Vec3f from, Vec3s to, f32 *dist, s16 *pitch, s16 *yaw) { Vec3f d; vec3_diff(d, to, from); register f32 xz = (sqr(d[0]) + sqr(d[2])); @@ -892,7 +892,7 @@ void vec3f_to_vec3s_get_dist_and_angle(Vec3f from, Vec3s to, f32 *dist, Angle *p } /// Finds the distance, horizontal distance, and angles between two vectors. -void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, f32 *lateralDist, Angle *pitch, Angle *yaw) { +void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, f32 *lateralDist, s16 *pitch, s16 *yaw) { Vec3f d; vec3_diff(d, to, from); register f32 xz = (sqr(d[0]) + sqr(d[2])); @@ -912,17 +912,17 @@ void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, to[1] = (from[1] + (dist * sins(pitch))); \ to[2] = (from[2] + (dcos * coss(yaw ))); \ } -void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, Angle32 pitch, Angle32 yaw) { +void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw) { vec3_set_dist_and_angle(from, to, dist, pitch, yaw); } -void vec3s_set_dist_and_angle(Vec3s from, Vec3s to, s16 dist, Angle32 pitch, Angle32 yaw) { +void vec3s_set_dist_and_angle(Vec3s from, Vec3s to, s16 dist, s16 pitch, s16 yaw) { vec3_set_dist_and_angle(from, to, dist, pitch, yaw); } /** * Similar to approach_s32, but converts to s16 and allows for overflow between 32767 and -32768 */ -s32 approach_angle(s32 current, s32 target, s32 inc) { +s16 approach_angle(s16 current, s16 target, s16 inc) { s32 dist = (s16)(target - current); if (dist < 0) { dist += inc; @@ -933,21 +933,21 @@ s32 approach_angle(s32 current, s32 target, s32 inc) { } return (target - dist); } -Bool32 approach_angle_bool(s16 *current, s32 target, s32 inc) { +Bool32 approach_angle_bool(s16 *current, s16 target, s16 inc) { *current = approach_angle(*current, target, inc); return (*current != target); } -s32 approach_s16(s32 current, s32 target, s32 inc, s32 dec) { +s16 approach_s16(s16 current, s16 target, s16 inc, s16 dec) { s16 dist = (target - current); if (dist >= 0) { // target >= current current = ((dist > inc) ? (current + inc) : target); } else { // target < current current = ((dist < -dec) ? (current - dec) : target); } - return (s16)current; + return current; } -Bool32 approach_s16_bool(s16 *current, s32 target, s32 inc, s32 dec) { +Bool32 approach_s16_bool(s16 *current, s16 target, s16 inc, s16 dec) { *current = approach_s16(*current, target, inc, dec); return (*current != target); } @@ -1028,7 +1028,7 @@ f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier) { * is reached. Note: Since this function takes integers as parameters, the last argument is the * reciprocal of what it would be in the previous two functions. */ -s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor) { +s16 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor) { s16 temp = *current; if (divisor == 0) { *current = target; @@ -1045,7 +1045,7 @@ s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor) { * Approaches an s16 value in the same fashion as approach_f32_asymptotic, returns the new value. * Note: last parameter is the reciprocal of what it would be in the f32 functions */ -s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor) { +s16 approach_s16_asymptotic(s16 current, s16 target, s16 divisor) { s16 temp = current; if (divisor == 0) { current = target; @@ -1058,7 +1058,7 @@ s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor) { return current; } -s32 abs_angle_diff(s16 a0, s16 a1) { +s16 abs_angle_diff(s16 a0, s16 a1) { register s16 diff = (a1 - a0); if (diff == -0x8000) return 0x7FFF; return abss(diff); @@ -1068,7 +1068,7 @@ s32 abs_angle_diff(s16 a0, s16 a1) { * Helper function for atan2s. Does a look up of the arctangent of y/x assuming * the resulting angle is in range [0, 0x2000] (1/8 of a circle). */ -static u32 atan2_lookup(f32 y, f32 x) { +static u16 atan2_lookup(f32 y, f32 x) { return x == 0 ? 0x0 : atans(y / x); @@ -1078,7 +1078,7 @@ static u32 atan2_lookup(f32 y, f32 x) { * Compute the angle from (0, 0) to (x, y) as a s16. Given that terrain is in * the xz-plane, this is commonly called with (z, x) to get a yaw angle. */ -s32 atan2s(f32 y, f32 x) { +s16 atan2s(f32 y, f32 x) { u16 ret; if (x >= 0) { if (y >= 0) { diff --git a/src/engine/math_util.h b/src/engine/math_util.h index 2ff4587d..016dc87f 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -54,12 +54,12 @@ extern f32 gSineTable[]; #define RAD_PER_DEG (M_PI / 180.0f) #define DEG_PER_RAD (180.0f / M_PI) -#define angle_to_degrees( x) (f32)(((Angle)(x) / 65536.0f) * 360.0f) -#define degrees_to_angle( x) (Angle)(((f32)(x) * 0x10000 ) / 360 ) -#define angle_to_radians( x) (f32)(((Angle)(x) * M_PI ) / 0x8000) -#define radians_to_angle( x) (Angle)(((f32)(x) / M_PI ) * 0x8000) -#define degrees_to_radians(x) (f32)( (f32)(x) * RAD_PER_DEG ) -#define radians_to_degrees(x) (f32)( (f32)(x) * DEG_PER_RAD ) +#define angle_to_degrees( x) (f32)(((s16)(x) / 65536.0f) * 360.0f) +#define degrees_to_angle( x) (s16)(((f32)(x) * 0x10000 ) / 360 ) +#define angle_to_radians( x) (f32)(((s16)(x) * M_PI ) / 0x8000) +#define radians_to_angle( x) (s16)(((f32)(x) / M_PI ) * 0x8000) +#define degrees_to_radians(x) (f32)( (f32)(x) * RAD_PER_DEG ) +#define radians_to_degrees(x) (f32)( (f32)(x) * DEG_PER_RAD ) #define signum_positive(x) ((x < 0) ? -1 : 1) @@ -538,15 +538,15 @@ void vec3f_normalize(Vec3f dest); void mtxf_copy(Mat4 dest, Mat4 src); void mtxf_identity(Mat4 mtx); void mtxf_translate(Mat4 dest, Vec3f b); -void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s32 roll); +void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll); void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f trans, Vec3s rot); void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f trans, Vec3s rot); void mtxf_rotate_zxy_and_translate_and_mul(Vec3s rot, Vec3f trans, Mat4 dest, Mat4 src); void mtxf_rotate_xyz_and_translate_and_mul(Vec3s rot, Vec3f trans, Mat4 dest, Mat4 src); -void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s32 angle); -void mtxf_shadow(Mat4 dest, Vec3f upDir, Vec3f pos, Vec3f scale, s32 yaw); -void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s32 yaw); -void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s32 yaw, f32 radius); +void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s16 angle); +void mtxf_shadow(Mat4 dest, Vec3f upDir, Vec3f pos, Vec3f scale, s16 yaw); +void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw); +void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius); void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b); void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s); void mtxf_mul_vec3s(Mat4 mtx, Vec3s b); @@ -557,36 +557,36 @@ ALWAYS_INLINE void mtxf_to_mtx(register void *dest, register void *src) { // guMtxF2L(src, dest); } -void mtxf_rotate_xy(Mtx *mtx, s32 angle); +void mtxf_rotate_xy(Mtx *mtx, s16 angle); void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); void linear_mtxf_mul_vec3f_and_translate(Mat4 m, Vec3f dst, Vec3f v); void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); -void vec2f_get_lateral_dist( Vec2f from, Vec2f to, f32 *lateralDist ); -void vec3f_get_lateral_dist( Vec3f from, Vec3f to, f32 *lateralDist ); -void vec3f_get_lateral_dist_squared( Vec3f from, Vec3f to, f32 *lateralDist ); -void vec3f_get_dist( Vec3f from, Vec3f to, f32 *dist ); -void vec3f_get_dist_squared( Vec3f from, Vec3f to, f32 *dist ); -void vec3f_get_dist_and_yaw( Vec3f from, Vec3f to, f32 *dist, Angle *yaw); -void vec3f_get_pitch( Vec3f from, Vec3f to, Angle *pitch ); -void vec3f_get_yaw( Vec3f from, Vec3f to, Angle *yaw); -void vec3f_get_angle( Vec3f from, Vec3f to, Angle *pitch, Angle *yaw); -void vec3f_get_lateral_dist_and_pitch( Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch ); -void vec3f_get_lateral_dist_and_yaw( Vec3f from, Vec3f to, f32 *lateralDist, Angle *yaw); -void vec3f_get_lateral_dist_and_angle( Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch, Angle *yaw); -void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, f32 *lateralDist, Angle *pitch, Angle *yaw); -void vec3f_get_dist_and_angle( Vec3f from, Vec3f to, f32 *dist, Angle *pitch, Angle *yaw); -void vec3s_get_dist_and_angle( Vec3s from, Vec3s to, s16 *dist, Angle *pitch, Angle *yaw); -void vec3f_to_vec3s_get_dist_and_angle( Vec3f from, Vec3s to, f32 *dist, Angle *pitch, Angle *yaw); -void vec3s_set_dist_and_angle( Vec3s from, Vec3s to, s16 dist, Angle32 pitch, Angle32 yaw); -void vec3f_set_dist_and_angle( Vec3f from, Vec3f to, f32 dist, Angle32 pitch, Angle32 yaw); +void vec2f_get_lateral_dist( Vec2f from, Vec2f to, f32 *lateralDist ); +void vec3f_get_lateral_dist( Vec3f from, Vec3f to, f32 *lateralDist ); +void vec3f_get_lateral_dist_squared( Vec3f from, Vec3f to, f32 *lateralDist ); +void vec3f_get_dist( Vec3f from, Vec3f to, f32 *dist ); +void vec3f_get_dist_squared( Vec3f from, Vec3f to, f32 *dist ); +void vec3f_get_dist_and_yaw( Vec3f from, Vec3f to, f32 *dist, s16 *yaw); +void vec3f_get_pitch( Vec3f from, Vec3f to, s16 *pitch ); +void vec3f_get_yaw( Vec3f from, Vec3f to, s16 *yaw); +void vec3f_get_angle( Vec3f from, Vec3f to, s16 *pitch, s16 *yaw); +void vec3f_get_lateral_dist_and_pitch( Vec3f from, Vec3f to, f32 *lateralDist, s16 *pitch ); +void vec3f_get_lateral_dist_and_yaw( Vec3f from, Vec3f to, f32 *lateralDist, s16 *yaw); +void vec3f_get_lateral_dist_and_angle( Vec3f from, Vec3f to, f32 *lateralDist, s16 *pitch, s16 *yaw); +void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, f32 *lateralDist, s16 *pitch, s16 *yaw); +void vec3f_get_dist_and_angle( Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw); +void vec3s_get_dist_and_angle( Vec3s from, Vec3s to, s16 *dist, s16 *pitch, s16 *yaw); +void vec3f_to_vec3s_get_dist_and_angle( Vec3f from, Vec3s to, f32 *dist, s16 *pitch, s16 *yaw); +void vec3s_set_dist_and_angle( Vec3s from, Vec3s to, s16 dist, s16 pitch, s16 yaw); +void vec3f_set_dist_and_angle( Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw); -s32 approach_angle(s32 current, s32 target, s32 inc); -s32 approach_s16(s32 current, s32 target, s32 inc, s32 dec); +s16 approach_angle(s16 current, s16 target, s16 inc); +s16 approach_s16(s16 current, s16 target, s16 inc, s16 dec); s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec); f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec); -Bool32 approach_angle_bool(s16 *current, s32 target, s32 inc); -Bool32 approach_s16_bool(s16 *current, s32 target, s32 inc, s32 dec); +Bool32 approach_angle_bool(s16 *current, s16 target, s16 inc); +Bool32 approach_s16_bool(s16 *current, s16 target, s16 inc, s16 dec); Bool32 approach_s32_bool(s32 *current, s32 target, s32 inc, s32 dec); Bool32 approach_f32_bool(f32 *current, f32 target, f32 inc, f32 dec); #define approach_s16_symmetric(current, target, inc) approach_s16((current), (target), (inc), (inc)) @@ -598,10 +598,10 @@ Bool32 approach_f32_bool(f32 *current, f32 target, f32 inc, f32 dec); s32 approach_f32_signed(f32 *current, f32 target, f32 inc); s32 approach_f32_asymptotic_bool(f32 *current, f32 target, f32 multiplier); f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier); -s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor); -s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor); -s32 abs_angle_diff(s16 a0, s16 a1); -s32 atan2s(f32 y, f32 x); +s16 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor); +s16 approach_s16_asymptotic(s16 current, s16 target, s16 divisor); +s16 abs_angle_diff(s16 a0, s16 a1); +s16 atan2s(f32 y, f32 x); f32 atan2f(f32 a, f32 b); void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c); void anim_spline_init(Vec4s *keyFrames); diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index 9b428e03..2b1e4a3c 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -459,7 +459,7 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32 height = get_surface_height_at_location(x, z, surf); // Exclude floors lower than the previous highest floor. - if (height < *pheight) continue; + if (height <= *pheight) continue; // Checks for floor interaction with a FIND_FLOOR_BUFFER unit buffer. if (bufferY < height) continue; @@ -734,7 +734,7 @@ s32 find_water_level(s32 x, s32 z) { // TODO: Allow y pos // If the location is within a water box and it is a water box. // Water is less than 50 val only, while above is gas and such. - if (loX < x && x < hiX && loZ < z && z < hiZ && val < 50) { + if (loX <= x && x <= hiX && loZ <= z && z <= hiZ && val < 50) { // Set the water height. Since this breaks, only return the first height. waterLevel = *p; break; diff --git a/src/game/behaviors/boo.inc.c b/src/game/behaviors/boo.inc.c index 316f8f27..9a638c76 100644 --- a/src/game/behaviors/boo.inc.c +++ b/src/game/behaviors/boo.inc.c @@ -178,7 +178,7 @@ static void boo_set_move_yaw_for_during_hit(s32 hurt) { } // Boo Roll -static Angle sBooHitRotations[] = { +static s16 sBooHitRotations[] = { 0x179F, 0x1620, 0x14AC, 0x1346, 0x11EB, 0x109E, 0x0B75, 0x0E28, 0x0D01, 0x0BE6, 0x0AD7, 0x09D5, diff --git a/src/game/behaviors/hoot.inc.c b/src/game/behaviors/hoot.inc.c index 0fa0ca98..942a839c 100644 --- a/src/game/behaviors/hoot.inc.c +++ b/src/game/behaviors/hoot.inc.c @@ -68,7 +68,7 @@ void hoot_free_step(s16 fastOscY, s32 speed) { void hoot_player_set_yaw(void) { #ifdef HOOT_YAW_FIX - Angle turnSpeed = gMarioState->intendedMag * 0x20; + s16 turnSpeed = gMarioState->intendedMag * 0x20; o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, gMarioState->intendedYaw, turnSpeed); #else s16 stickX = gPlayer3Controller->rawStickX; @@ -193,7 +193,7 @@ void hoot_action_loop(void) { } void hoot_turn_to_home(void) { - Angle pitchToHome, yawToHome; + s16 pitchToHome, yawToHome; vec3f_get_angle(&o->oPosVec, &o->oHomeVec, &pitchToHome, &yawToHome); o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, yawToHome, 0x140); diff --git a/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c b/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c index 5477e957..19d0e8b8 100644 --- a/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c +++ b/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c @@ -8,10 +8,10 @@ enum LLLOctagonalMeshInstructions { }; struct LllOctagonalMeshAction { - s16 instruction; - s16 time; - Angle moveAngle; - s16 forwardVel; + s16 instruction; + s16 time; + s16 moveAngle; + s16 forwardVel; }; // Path for big bullies platforms diff --git a/src/game/behaviors/platform_on_track.inc.c b/src/game/behaviors/platform_on_track.inc.c index 65a0fd8e..beb1a467 100644 --- a/src/game/behaviors/platform_on_track.inc.c +++ b/src/game/behaviors/platform_on_track.inc.c @@ -384,7 +384,7 @@ void bhv_platform_on_track_update(void) { platform_on_track_rock_ski_lift(); } else if (o->oPlatformOnTrackType == PLATFORM_ON_TRACK_TYPE_CARPET) { #ifdef CONTROLLABLE_PLATFORM_SPEED - Angle targetRoll; // Visually, this is the platform's pitch, since these platforms technically move sideways + s16 targetRoll; // Visually, this is the platform's pitch, since these platforms technically move sideways if (gMarioObject->platform == o) { if (!o->oPlatformOnTrackWasStoodOn) { o->oPlatformOnTrackOffsetY = -8.0f; diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c index f09455ba..4dd03940 100644 --- a/src/game/behaviors/spawn_star.inc.c +++ b/src/game/behaviors/spawn_star.inc.c @@ -39,7 +39,7 @@ void bhv_collect_star_loop(void) { } void bhv_star_spawn_init(void) { - Angle yaw; + s16 yaw; vec3f_get_lateral_dist_and_yaw(&o->oPosVec, &o->oHomeVec, &o->oStarSpawnDisFromHome, &yaw); o->oMoveAngleYaw = yaw; o->oVelY = (o->oHomeY - o->oPosY) / 30.0f; diff --git a/src/game/behaviors/yoshi.inc.c b/src/game/behaviors/yoshi.inc.c index 227cab22..e6d944b6 100644 --- a/src/game/behaviors/yoshi.inc.c +++ b/src/game/behaviors/yoshi.inc.c @@ -11,7 +11,7 @@ void bhv_yoshi_init(void) { o->oBuoyancy = 1.3f; o->oInteractionSubtype = INT_SUBTYPE_NPC; -#if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) +#if !defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) if (sYoshiDead == TRUE) { #else if ((save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_MIN), COURSE_NUM_TO_INDEX(COURSE_MAX)) < 120) diff --git a/src/game/camera.c b/src/game/camera.c index 21d40773..f9bf782c 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -4257,7 +4257,7 @@ s32 is_pos_in_bounds(Vec3f pos, Vec3f center, Vec3f bounds, s16 boundsYaw) { -bounds[2] < rel[2] && rel[2] < bounds[2]); } -s32 calculate_pitch(Vec3f from, Vec3f to) { +s16 calculate_pitch(Vec3f from, Vec3f to) { f32 dx = to[0] - from[0]; f32 dy = to[1] - from[1]; f32 dz = to[2] - from[2]; @@ -4266,7 +4266,7 @@ s32 calculate_pitch(Vec3f from, Vec3f to) { return pitch; } -s32 calculate_yaw(Vec3f from, Vec3f to) { +s16 calculate_yaw(Vec3f from, Vec3f to) { f32 dx = to[0] - from[0]; // UNUSED f32 dy = to[1] - from[1]; f32 dz = to[2] - from[2]; diff --git a/src/game/camera.h b/src/game/camera.h index 23872607..fcd1f59f 100644 --- a/src/game/camera.h +++ b/src/game/camera.h @@ -750,8 +750,8 @@ void random_vec3s(Vec3s dst, s16 xRange, s16 yRange, s16 zRange); s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin); s32 is_range_behind_surface(Vec3f from, Vec3f to, struct Surface *surf, s16 range, s16 surfType); void scale_along_line(Vec3f dest, Vec3f from, Vec3f to, f32 scale); -s32 calculate_pitch(Vec3f from, Vec3f to); -s32 calculate_yaw(Vec3f from, Vec3f to); +s16 calculate_pitch(Vec3f from, Vec3f to); +s16 calculate_yaw(Vec3f from, Vec3f to); void calculate_angles(Vec3f from, Vec3f to, s16 *pitch, s16 *yaw); f32 calc_abs_dist(Vec3f a, Vec3f b); f32 calc_abs_dist_squared(Vec3f a, Vec3f b); diff --git a/src/game/macro_special_objects.c b/src/game/macro_special_objects.c index a00b6c82..458ba2a1 100644 --- a/src/game/macro_special_objects.c +++ b/src/game/macro_special_objects.c @@ -78,7 +78,7 @@ UNUSED static void spawn_macro_coin_unknown(const BehaviorScript *behavior, s16 } struct LoadedMacroObject { - /*0x00*/ Angle yaw; + /*0x00*/ s16 yaw; /*0x02*/ Vec3s pos; /*0x08*/ s16 params; }; diff --git a/src/game/mario.c b/src/game/mario.c index c3e743f1..ebf3bb26 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -542,10 +542,10 @@ u32 mario_floor_is_slippery(struct MarioState *m) { } switch (mario_get_floor_class(m)) { - case SURFACE_VERY_SLIPPERY: normY = COS10; break; - case SURFACE_SLIPPERY: normY = COS20; break; - default: normY = COS38; break; - case SURFACE_NOT_SLIPPERY: normY = 0.0f; break; + case SURFACE_CLASS_VERY_SLIPPERY: normY = COS10; break; + case SURFACE_CLASS_SLIPPERY: normY = COS20; break; + default: normY = COS38; break; + case SURFACE_CLASS_NOT_SLIPPERY: normY = 0.0f; break; } return m->floor->normal.y <= normY; @@ -563,10 +563,10 @@ s32 mario_floor_is_slope(struct MarioState *m) { } switch (mario_get_floor_class(m)) { - case SURFACE_VERY_SLIPPERY: normY = COS5; break; - case SURFACE_SLIPPERY: normY = COS10; break; - default: normY = COS15; break; - case SURFACE_NOT_SLIPPERY: normY = COS20; break; + case SURFACE_CLASS_VERY_SLIPPERY: normY = COS5; break; + case SURFACE_CLASS_SLIPPERY: normY = COS10; break; + default: normY = COS15; break; + case SURFACE_CLASS_NOT_SLIPPERY: normY = COS20; break; } return m->floor->normal.y <= normY; @@ -592,10 +592,10 @@ s32 mario_floor_is_steep(struct MarioState *m) { // This does not matter in vanilla game practice. if (!mario_facing_downhill(m, FALSE)) { switch (mario_get_floor_class(m)) { - case SURFACE_VERY_SLIPPERY: normY = COS15; break; - case SURFACE_SLIPPERY: normY = COS20; break; - default: normY = COS30; break; - case SURFACE_NOT_SLIPPERY: normY = COS30; break; + case SURFACE_CLASS_VERY_SLIPPERY: normY = COS15; break; + case SURFACE_CLASS_SLIPPERY: normY = COS20; break; + default: normY = COS30; break; + case SURFACE_CLASS_NOT_SLIPPERY: normY = COS30; break; } return m->floor->normal.y <= normY; diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 7103228f..26051395 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -1273,7 +1273,7 @@ s32 act_air_hit_wall(struct MarioState *m) { mario_drop_held_object(m); } - if (++(m->actionTimer) <= FIRSTY_LAST_FRAME) { + if (++(m->actionTimer) <= 2) { if (m->input & INPUT_A_PRESSED) { m->vel[1] = 52.0f; m->faceAngle[1] += 0x8000; @@ -1299,12 +1299,9 @@ s32 act_air_hit_wall(struct MarioState *m) { return set_mario_action(m, ACT_SOFT_BONK, 0); } -#if FIRSTY_LAST_FRAME > 1 set_mario_animation(m, MARIO_ANIM_START_WALLKICK); - m->marioObj->header.gfx.angle[1] = m->wallYaw; -#endif - return FALSE; + return TRUE; } s32 act_forward_rollout(struct MarioState *m) { diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index 117e1cb4..6fd5ea36 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -565,11 +565,9 @@ s32 act_ledge_grab(struct MarioState *m) { if (m->actionTimer < 10) { m->actionTimer++; } -#ifdef LEDGE_GRABS_CHECK_SLOPE_ANGLE if (m->floor->normal.y < COS25) { return let_go_of_ledge(m); } -#endif if (m->input & (INPUT_Z_PRESSED | INPUT_OFF_FLOOR)) { return let_go_of_ledge(m); } diff --git a/src/game/mario_step.c b/src/game/mario_step.c index 2b1ceb08..eb9923fd 100644 --- a/src/game/mario_step.c +++ b/src/game/mario_step.c @@ -259,10 +259,9 @@ s32 stationary_ground_step(struct MarioState *m) { if (takeStep) { stepResult = perform_ground_step(m); } else { - // Hackersm64: this condition fixes potential downwarps - if (m->pos[1] <= m->floorHeight + 160.0f) { - m->pos[1] = m->floorHeight; - } + //! TODO - This is responsible for many stationary downwarps but is + // important for stuff like catching Bowser in midair, figure out a good way to fix + m->pos[1] = m->floorHeight; vec3f_copy(marioObj->header.gfx.pos, m->pos); vec3s_set(marioObj->header.gfx.angle, 0, m->faceAngle[1], 0); @@ -404,8 +403,10 @@ struct Surface *check_ledge_grab(struct MarioState *m, struct Surface *prevWall, if (ledgeFloor == NULL || (*ledgeFloor) == NULL || ledgePos[1] < nextPos[1] + 100.0f +#ifdef DONT_LEDGE_GRAB_STEEP_SLOPES || (*ledgeFloor)->normal.y < COS25 // H64 TODO: check if floor is actually slippery - || SURFACE_IS_UNSAFE((*ledgeFloor)->type)) { +#endif + ) { return NULL; } diff --git a/src/game/skybox.c b/src/game/skybox.c index 5b9b86f9..39df6b41 100644 --- a/src/game/skybox.c +++ b/src/game/skybox.c @@ -217,6 +217,10 @@ void draw_skybox_tile_grid(Gfx **dlist, s8 background, s8 player, s8 colorIndex) for (row = 0; row < (3 * SKYBOX_SIZE); row++) { for (col = 0; col < (3 * SKYBOX_SIZE); col++) { s32 tileIndex = sSkyBoxInfo[player].upperLeftTile + row * SKYBOX_COLS + col; + if (tileIndex >= SKYBOX_ROWS * SKYBOX_COLS) { + continue; + } + const Texture *const texture = (*(SkyboxTexture *) segmented_to_virtual(sSkyboxTextures[background]))[tileIndex]; Vtx *vertices = make_skybox_rect(tileIndex, colorIndex);