Merge branch 'master' of https://gitlab.com/banjo.decomp/banjo-kazooie into document/fileprogress

This commit is contained in:
Bl00D4NGEL
2024-10-02 00:20:25 +02:00
68 changed files with 723 additions and 649 deletions

103
src/core2/ba/flap.c Normal file
View File

@@ -0,0 +1,103 @@
#include <ultra64.h>
#include "functions.h"
#include "variables.h"
/* .bss */
u8 s_active;
f32 s_flap_max_timer;
f32 s_flap_list[5];
/* .code */
/**
* @brief returns the number of nonzero flap timers in `s_flap_list`
*
* @return s32 number of active flaps
*/
s32 baflap_getCount(void) {
s32 i;
s32 cnt;
cnt = 0;
for(i = 0; i < 5; i++){
if(s_flap_list[i] != 0.0f){
cnt++;
}
}
return cnt;
}
/**
* @brief add a flap duration to the flap list
*
* @param duration duration of flap in seconds
* @return true if baflap duration was extended
* @return false if baflap does not extend duration or all timers in flap queue are occupied
*/
bool baflap_add(f32 duration) {
s32 i;
// check that timer is far enough away from any value
for(i = 0; i < 5; i++){
if(duration - 0.25 < s_flap_list[i]){
s_flap_max_timer = duration;
return FALSE;
}
}
// add to list
for(i = 0; i < 5; i++){
if (s_flap_list[i] == 0.0f) {
s_flap_list[i] = duration;
return TRUE;
}
}
s_flap_max_timer = duration;
return FALSE;
}
/**
* @brief zeros all flap timers and sets as inactive
*
*/
void baflap_reset(void) {
s32 i;
for(i = 0; i < 5; i++){
s_flap_list[i] = 0.0f;
}
s_active = s_flap_max_timer = 0.0f;
}
/**
* @brief activates or deactivates flap timers
*
* @param active false (0) or true (!0)
*/
void baflap_activate(bool active){
s_active = active;
if(!s_active){
baflap_reset();
}
}
/**
* @brief updates flap timers if active
*
*/
void baflap_update(void) {
f32 temp_f0;
s32 i;
if (s_active != 0) {
//update timers
for(i = 0; i < 5; i++){
func_80259430(&s_flap_list[i]);
}
if (s_flap_max_timer != 0.0f) {
temp_f0 = s_flap_max_timer;
s_flap_max_timer = 0.0f;
baflap_add(temp_f0);
}
}
}

View File

@@ -14,7 +14,7 @@ extern void func_802A6388(f32);
extern f32 chwadingboots_802D6E4C(Actor *);
extern void set_turbo_duration(f32);
extern f32 chtrainers_getDuration(Actor *);
extern int func_80259254(f32 vec[3], f32 x, f32 z, f32 val);
extern int ml_vec3f_point_within_horizontal_distance(f32 vec[3], f32 x, f32 z, f32 val);
extern void func_802EE354(Actor *, s32, s32, s32, f32, f32, f32, f32 arg8[3], s32, f32 arg10[2]);
extern void func_8035644C(s32);
extern void func_8035646C(s32 arg0);

View File

@@ -271,9 +271,7 @@ void baModel_setVisible(s32 arg0){
void baModel_802921D4(f32 arg0[3]){
if(player_getWaterState() == BSWATERGROUP_0_NONE){
D_8037C150.unk0 = 1;
D_8037C150.unk4[0] = arg0[0];
D_8037C150.unk4[1] = arg0[1];
D_8037C150.unk4[2] = arg0[2];
TUPLE_COPY(D_8037C150.unk4, arg0)
}
}

View File

@@ -3,8 +3,6 @@
#include "variables.h"
#include "core2/ba/physics.h"
#define _SQ3v1(v) (v[0] * v[0] + v[1] * v[1] + v[2] * v[2])
extern f32 ml_sin_deg(f32);
extern f32 ml_dotProduct_vec3f(f32[3], f32[3]);
extern void func_80256D0C(f32, f32, f32, f32, f32, f32 *, f32 *, f32 *);
@@ -118,7 +116,8 @@ void __baphysics_update_no_gravity(void){
//update velocity
ml_vec3f_diff_copy(sp24, baphysics_target_velocity, s_player_velocity);
ml_vec3f_scale(sp24, time_getDelta()*baphysics_acceleration);
if(_SQ3v1(sp24) < 0.02){
if (LENGTH_SQ_VEC3F(sp24) < 0.02) {
ml_vec3f_copy(s_player_velocity, baphysics_target_velocity);
}
else{