Some small fixes

This commit is contained in:
Arceveti
2021-09-25 10:12:05 -07:00
parent a39b382db6
commit 0649427337
15 changed files with 48 additions and 99 deletions

View File

@@ -238,18 +238,8 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
case 0xc4: // layer_somethingon
case 0xc5: // layer_somethingoff
//! copt needs a ternary:
//layer->continuousNotes = (cmd == 0xc4) ? TRUE : FALSE;
{
u8 setting;
if (cmd == 0xc4) {
setting = TRUE;
} else {
setting = FALSE;
}
layer->continuousNotes = setting;
seq_channel_layer_note_decay(layer);
}
layer->continuousNotes = (cmd == 0xc4);
seq_channel_layer_note_decay(layer);
break;
case 0xc3: // layer_setshortnotedefaultplaypercentage
@@ -400,13 +390,7 @@ l1138:
}
if (layer->portamento.mode != 0) {
//! copt needs a ternary:
//usedSemitone = (layer->portamentoTargetNote < cmdSemitone) ? cmdSemitone : layer->portamentoTargetNote;
if (layer->portamentoTargetNote < cmdSemitone) {
usedSemitone = cmdSemitone;
} else {
usedSemitone = layer->portamentoTargetNote;
}
usedSemitone = (layer->portamentoTargetNote < cmdSemitone) ? cmdSemitone : layer->portamentoTargetNote;
if (instrument != NULL) {
sound = (u8) usedSemitone < instrument->normalRangeLo ? &instrument->lowNotesSound

View File

@@ -11,6 +11,7 @@
#include "game/object_helpers.h"
#include "game/macro_special_objects.h"
#include "surface_collision.h"
#include "math_util.h"
#include "game/mario.h"
#include "game/object_list_processor.h"
#include "surface_load.h"
@@ -688,10 +689,6 @@ void load_object_surfaces(TerrainData **data, TerrainData *vertexData) {
s32 surfaceType;
s32 i;
s32 numSurfaces;
#ifndef ALL_SURFACES_HAVE_FORCE
TerrainData hasForce;
#endif
s32 flags;
s32 room;
surfaceType = *(*data);
@@ -701,11 +698,10 @@ void load_object_surfaces(TerrainData **data, TerrainData *vertexData) {
(*data)++;
#ifndef ALL_SURFACES_HAVE_FORCE
hasForce = surface_has_force(surfaceType);
TerrainData hasForce = surface_has_force(surfaceType);
#endif
flags = surf_has_no_cam_collision(surfaceType);
flags |= SURFACE_FLAG_DYNAMIC;
s32 flags = surf_has_no_cam_collision(surfaceType) | SURFACE_FLAG_DYNAMIC;
// The DDD warp is initially loaded at the origin and moved to the proper
// position in paintings.c and doesn't update its room, so set it here.
@@ -764,7 +760,7 @@ static void get_optimal_coll_dist(struct Object *o) {
v[0] = *(collisionData + 0) * o->header.gfx.scale[0];
v[1] = *(collisionData + 1) * o->header.gfx.scale[1];
v[2] = *(collisionData + 2) * o->header.gfx.scale[2];
thisVertDist = ((v[0] * v[0]) + (v[1] * v[1]) + (v[2] * v[2]));
thisVertDist = (sqr(v[0]) + sqr(v[1]) + sqr(v[2]));
if (thisVertDist > maxDist) maxDist = thisVertDist;
collisionData += 3;
vertsLeft--;

View File

@@ -37,7 +37,7 @@ void bhv_bowser_key_loop(void) {
} else {
obj_set_hitbox(o, &sBowserKeyHitbox);
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
mark_obj_for_deletion(o);
obj_mark_for_deletion(o);
o->oInteractStatus = 0;
}
}

View File

@@ -26,7 +26,7 @@ void bhv_spawned_star_init(void) {
void set_sparkle_spawn_star_hitbox(void) {
obj_set_hitbox(o, &sSparkleSpawnStarHitbox);
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
mark_obj_for_deletion(o);
obj_mark_for_deletion(o);
o->oInteractStatus = 0;
}
}

View File

@@ -38,7 +38,7 @@ void bhv_collect_star_loop(void) {
o->oFaceAngleYaw += 0x800;
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
mark_obj_for_deletion(o);
obj_mark_for_deletion(o);
o->oInteractStatus = 0;
}
}
@@ -109,7 +109,7 @@ void bhv_star_spawn_loop(void) {
}
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
mark_obj_for_deletion(o);
obj_mark_for_deletion(o);
o->oInteractStatus = 0;
}
break;

View File

@@ -1307,12 +1307,10 @@ s32 update_parallel_tracking_camera(struct Camera *c, Vec3f focus, Vec3f pos) {
marioOffset[1] = marioOffset[1] * zoom;
marioOffset[2] = camOffset[2];
pathAngle[0] = pathPitch;
pathAngle[1] = pathYaw; //! No effect
// make marioOffset[2] == distance from the start of the path
marioOffset[2] = pathLength / 2 - marioOffset[2];
pathAngle[0] = pathPitch;
pathAngle[1] = pathYaw + DEGREES(180);
pathAngle[2] = 0;
@@ -1548,9 +1546,10 @@ s32 update_boss_fight_camera(struct Camera *c, Vec3f focus, Vec3f pos) {
}
}
//! Must be same line to match on -O2
// Prevent the camera from going to the ground in the outside boss fight
if (gCurrLevelNum == LEVEL_BBH) { pos[1] = 2047.f; }
if (gCurrLevelNum == LEVEL_BBH) {
pos[1] = 2047.f;
}
// Rotate from C-Button input
if (sCSideButtonYaw < 0) {
@@ -4112,8 +4111,8 @@ s16 reduce_by_dist_from_camera(s16 value, f32 maxDist, f32 posX, f32 posY, f32 p
vec3f_get_dist_and_angle(gLakituState.goalPos, pos, &dist, &pitch, &yaw);
if (dist < maxDist) {
calculate_angles(gLakituState.goalPos, gLakituState.goalFocus, &goalPitch, &goalYaw);
//! Must be same line to match on -O2
pitch -= goalPitch; yaw -= goalYaw;
pitch -= goalPitch;
yaw -= goalYaw;
dist -= 2000.f;
if (dist < 0.f) {
dist = 0.f;
@@ -11086,7 +11085,9 @@ Gfx *geo_camera_fov(s32 callContext, struct GraphNode *g, UNUSED void *context)
case CAM_FOV_APP_60:
approach_fov_60(marioState);
break;
//! No default case
default:
set_fov_45(marioState);
break;
}
}

View File

@@ -742,7 +742,7 @@ static void set_mario_y_vel_based_on_fspeed(struct MarioState *m, f32 initialVel
* Transitions for a variety of airborne actions.
*/
static u32 set_mario_action_airborne(struct MarioState *m, u32 action, u32 actionArg) {
f32 fowardVel;
f32 forwardVel;
if ((m->squishTimer != 0 || m->quicksandDepth >= 1.0f)
&& (action == ACT_DOUBLE_JUMP || action == ACT_TWIRLING)) {
@@ -822,10 +822,10 @@ static u32 set_mario_action_airborne(struct MarioState *m, u32 action, u32 actio
break;
case ACT_DIVE:
if ((fowardVel = m->forwardVel + 15.0f) > 48.0f) {
fowardVel = 48.0f;
if ((forwardVel = m->forwardVel + 15.0f) > 48.0f) {
forwardVel = 48.0f;
}
mario_set_forward_vel(m, fowardVel);
mario_set_forward_vel(m, forwardVel);
break;
case ACT_LONG_JUMP:

View File

@@ -1107,14 +1107,11 @@ s32 cur_obj_clear_interact_status_flag(s32 flag) {
* Mark an object to be unloaded at the end of the frame.
*/
void obj_mark_for_deletion(struct Object *obj) {
//! This clears all activeFlags. Since some of these flags disable behavior,
// setting it to 0 could potentially enable unexpected behavior. After an
// object is marked for deletion, it still updates on that frame (I think),
// so this is worth looking into.
#ifdef PUPPYLIGHTS
obj_disable_light(obj);
#endif
obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
obj->activeFlags &= ~(ACTIVE_FLAG_ACTIVE | ACTIVE_FLAG_INITIATED_TIME_STOP);
// obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
void cur_obj_disable(void) {

View File

@@ -638,10 +638,8 @@ void update_objects(UNUSED s32 unused) {
cycleCounts[2] = get_clock_difference(cycleCounts[0]);
update_terrain_objects();
// If Mario was touching a moving platform at the end of last frame, apply
// displacement now
//! If the platform object unloaded and a different object took its place,
// displacement could be applied incorrectly
// If Mario was touching a moving platform at the end of last frame, apply displacement now
//! If the platform object unloaded and a different object took its place, displacement could be applied incorrectly
apply_mario_platform_displacement();
// Detect which objects are intersecting

View File

@@ -1032,10 +1032,7 @@ static s32 obj_is_in_view(struct GraphNodeObject *node, Mat4 matrix) {
geo = node->sharedChild;
//! @bug The aspect ratio is not accounted for. When the fov value is 45,
// the horizontal effective fov is actually 60 degrees, so you can see objects
// visibly pop in or out at the edge of the screen.
halfFov = ((gCurGraphNodeCamFrustum->fov*aspect) / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f;
halfFov = ((gCurGraphNodeCamFrustum->fov * aspect) / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f;
hScreenEdge = -matrix[3][2] * sins(halfFov) / coss(halfFov);
// -matrix[3][2] is the depth, which gets multiplied by tan(halfFov) to get

View File

@@ -198,7 +198,7 @@ f32 get_water_level_below_shadow(struct Shadow *s, struct Surface **waterFloor)
* be dimmed based on its distance to the floor
*/
s8 init_shadow(struct Shadow *s, f32 xPos, f32 yPos, f32 zPos, s16 shadowScale, u8 overwriteSolidity) {
f32 waterLevel;
f32 waterLevel = FLOOR_LOWER_LIMIT_SHADOW;
f32 floorSteepness;
struct Surface *floor;
struct Surface *waterFloor = NULL;
@@ -216,7 +216,6 @@ s8 init_shadow(struct Shadow *s, f32 xPos, f32 yPos, f32 zPos, s16 shadowScale,
// }
if (gShadowAboveWaterOrLava) {
//! @bug Use of potentially undefined variable `waterLevel`
s->floorHeight = waterLevel;
if (waterFloor != NULL) {

View File

@@ -173,7 +173,7 @@ UNUSED static void unused_delete_leaf_nodes(struct Object *obj) {
unused_delete_leaf_nodes(children);
} else {
// No children
mark_obj_for_deletion(obj);
obj_mark_for_deletion(obj);
}
// Probably meant to be !=
@@ -352,14 +352,3 @@ struct Object *create_object(const BehaviorScript *bhvScript) {
return obj;
}
/**
* Mark an object to be unloaded at the end of the frame.
*/
void mark_obj_for_deletion(struct Object *obj) {
//! Same issue as obj_mark_for_deletion
#ifdef PUPPYLIGHTS
obj_disable_light(obj);
#endif
obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}

View File

@@ -7,6 +7,5 @@ void init_free_object_list(void);
void clear_object_lists(struct ObjectNode *objLists);
void unload_object(struct Object *obj);
struct Object *create_object(const BehaviorScript *bhvScript);
void mark_obj_for_deletion(struct Object *obj);
#endif // SPAWN_OBJECT_H

View File

@@ -2926,9 +2926,6 @@ void d_set_matrix(Mat4f *src) {
switch (sDynListCurObj->type) {
case OBJ_TYPE_NETS:
gd_copy_mat4f(src, &((struct ObjNet *) sDynListCurObj)->mat128);
//! @bug When setting an `ObjNet` matrix, the source is copied twice
//! due to a probable copy-paste line repeat error
gd_copy_mat4f(src, &((struct ObjNet *) sDynListCurObj)->mat128);
break;
case OBJ_TYPE_JOINTS:

View File

@@ -41,14 +41,9 @@ extern void *languageTable[][3];
// The current sound mode is automatically centered on US and Shindou.
s16 sSoundTextX;
//! @Bug (UB Array Access) For EU, more buttons were added than the array was extended.
//! This causes no currently known issues on console (as the other variables are not changed
//! while this is used) but can cause issues with other compilers.
#define NUM_BUTTONS MENU_BUTTON_OPTION_MAX
// Amount of main menu buttons defined in the code called by spawn_object_rel_with_rot.
// See file_select.h for the names in MenuButtonTypes.
struct Object *sMainMenuButtons[NUM_BUTTONS];
struct Object *sMainMenuButtons[MENU_BUTTON_OPTION_MAX];
// Used to defined yes/no fade colors after a file is selected in the erase menu.
// sYesNoColor[0]: YES | sYesNoColor[1]: NO
@@ -1037,22 +1032,22 @@ void return_to_main_menu(s16 prevMenuButtonID, struct Object *sourceButton) {
// Hide buttons of corresponding button menu groups
if (prevMenuButtonID == MENU_BUTTON_SCORE) {
for (buttonID = MENU_BUTTON_SCORE_MIN; buttonID < MENU_BUTTON_SCORE_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_COPY) {
for (buttonID = MENU_BUTTON_COPY_MIN; buttonID < MENU_BUTTON_COPY_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_ERASE) {
for (buttonID = MENU_BUTTON_ERASE_MIN; buttonID < MENU_BUTTON_ERASE_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_SOUND_MODE) {
for (buttonID = MENU_BUTTON_OPTION_MIN; buttonID < MENU_BUTTON_OPTION_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
}
@@ -1074,21 +1069,20 @@ void load_score_menu_from_submenu(s16 prevMenuButtonID, struct Object *sourceBut
// If the previous button is in default state
if (sMainMenuButtons[prevMenuButtonID]->oMenuButtonState == MENU_BUTTON_STATE_DEFAULT) {
// Hide buttons of corresponding button menu groups
if (prevMenuButtonID == MENU_BUTTON_SCORE) //! Not possible, this is checking if the score menu
//! was opened from the score menu!
if (prevMenuButtonID == MENU_BUTTON_SCORE) //! Not possible, this is checking if the score menu was opened from the score menu!
{
for (buttonID = MENU_BUTTON_SCORE_MIN; buttonID < MENU_BUTTON_SCORE_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_COPY) {
for (buttonID = MENU_BUTTON_COPY_MIN; buttonID < MENU_BUTTON_COPY_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_ERASE) {
for (buttonID = MENU_BUTTON_ERASE_MIN; buttonID < MENU_BUTTON_ERASE_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
// Play zoom in sound, select score menu and render it's buttons
@@ -1117,19 +1111,18 @@ void load_copy_menu_from_submenu(s16 prevMenuButtonID, struct Object *sourceButt
// Hide buttons of corresponding button menu groups
if (prevMenuButtonID == MENU_BUTTON_SCORE) {
for (buttonID = MENU_BUTTON_SCORE_MIN; buttonID < MENU_BUTTON_SCORE_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_COPY) //! Not possible, this is checking if the copy menu
//! was opened from the copy menu!
if (prevMenuButtonID == MENU_BUTTON_COPY) //! Not possible, this is checking if the copy menu was opened from the copy menu!
{
for (buttonID = MENU_BUTTON_COPY_MIN; buttonID < MENU_BUTTON_COPY_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_ERASE) {
for (buttonID = MENU_BUTTON_ERASE_MIN; buttonID < MENU_BUTTON_ERASE_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
// Play zoom in sound, select copy menu and render it's buttons
@@ -1158,19 +1151,18 @@ void load_erase_menu_from_submenu(s16 prevMenuButtonID, struct Object *sourceBut
// Hide buttons of corresponding button menu groups
if (prevMenuButtonID == MENU_BUTTON_SCORE) {
for (buttonID = MENU_BUTTON_SCORE_MIN; buttonID < MENU_BUTTON_SCORE_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_COPY) {
for (buttonID = MENU_BUTTON_COPY_MIN; buttonID < MENU_BUTTON_COPY_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
if (prevMenuButtonID == MENU_BUTTON_ERASE) //! Not possible, this is checking if the erase menu
//! was opened from the erase menu!
if (prevMenuButtonID == MENU_BUTTON_ERASE) //! Not possible, this is checking if the erase menu was opened from the erase menu!
{
for (buttonID = MENU_BUTTON_ERASE_MIN; buttonID < MENU_BUTTON_ERASE_MAX; buttonID++) {
mark_obj_for_deletion(sMainMenuButtons[buttonID]);
obj_mark_for_deletion(sMainMenuButtons[buttonID]);
}
}
// Play zoom in sound, select erase menu and render it's buttons