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>
This commit is contained in:
Gregory Heskett
2022-11-23 15:57:44 -05:00
committed by GitHub
parent b8e22f2fbd
commit b1146308a7
17 changed files with 119 additions and 189 deletions

View File

@@ -33,7 +33,7 @@
"compilerPath": "/usr/bin/mips-linux-gnu-gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
"intelliSenseMode": "linux-gcc-x86"
}
],
"version": 4

View File

@@ -870,8 +870,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)

View File

@@ -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_ */

View File

@@ -98,12 +98,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
@@ -489,10 +483,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 --
};

View File

@@ -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 sAudioFirstBoot = 0;
@@ -1169,22 +1153,33 @@ void init_reverb_us(s32 presetId) {
#if defined(VERSION_JP) || defined(VERSION_US)
void audio_reset_session(struct AudioSessionSettings *preset, s32 presetId) {
if (sAudioFirstBoot) {
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

View File

@@ -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];
@@ -592,7 +592,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, Mat4 src, Vec3f upDir, Vec3f pos, Vec3f scale, s32 yaw) {
void mtxf_shadow(Mat4 dest, Mat4 src, Vec3f upDir, Vec3f pos, Vec3f scale, s16 yaw) {
Vec3f lateralDir;
Vec3f leftDir;
Vec3f forwardDir;
@@ -621,7 +621,7 @@ void mtxf_shadow(Mat4 dest, Mat4 src, Vec3f upDir, Vec3f pos, Vec3f scale, s32 y
* '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;
@@ -646,7 +646,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;
@@ -765,7 +765,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;
@@ -880,7 +880,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]));
@@ -888,7 +888,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));
@@ -896,7 +896,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]));
@@ -905,7 +905,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]));
@@ -913,7 +913,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]));
@@ -921,7 +921,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]));
@@ -931,7 +931,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]));
@@ -951,17 +951,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;
@@ -972,21 +972,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);
}
@@ -1067,7 +1067,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;
@@ -1084,7 +1084,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;
@@ -1097,7 +1097,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);
@@ -1107,7 +1107,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);
@@ -1117,7 +1117,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) {

View File

@@ -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, Mat4 src, 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, Mat4 src, 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,37 +557,37 @@ 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 get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx);
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))
@@ -599,10 +599,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);

View File

@@ -429,7 +429,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;

View File

@@ -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,

View File

@@ -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);

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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];

View File

@@ -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);

View File

@@ -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;
};

View File

@@ -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);