Fix a major bug with the QoL fixes+minor tweaks

This commit is contained in:
Colton Rushton 2021-02-17 17:08:43 -04:00
parent 527267199b
commit 85827a0abc
8 changed files with 31 additions and 111 deletions

View File

@ -912,13 +912,8 @@ $(BUILD_DIR)/include/level_headers.h: levels/level_headers.h.in
$(BUILD_DIR)/assets/mario_anim_data.c: $(wildcard assets/anims/*.inc.c)
$(PYTHON) tools/mario_anims_converter.py > $@
ifneq ($(QOL_FIXES),1)
$(BUILD_DIR)/assets/demo_data.c: assets/demo_data.json $(wildcard assets/demos/*.bin)
$(PYTHON) tools/demo_data_converter.py assets/demo_data.json $(VERSION_CFLAGS) > $@
else
$(BUILD_DIR)/assets/demo_data.c: assets/qol_demo_data.json $(wildcard assets/demos/*.bin)
$(PYTHON) tools/demo_data_converter.py assets/qol_demo_data.json $(VERSION_CFLAGS) > $@
endif
# Source code
$(BUILD_DIR)/levels/%/leveldata.o: OPT_FLAGS := -g

View File

@ -1,41 +0,0 @@
/*
* This file defines the demo data. It's parsed by tools/demo_data_converter.py.
*
* The "table" array declares the order of the demos and will be generated
* as pairs of (offset, size).
* Each item has a "demofile" property, which must reference a demofile
* in the "demofiles" array.
* "ifdef" is an optional array property which can be used to specify
* requirement of SM64 version.
* "extraSize" is an optional property which will be added to the size of the
* demofile.
*
* The "demofiles" array declares the inclusion order of the demofiles.
* A file with the ".bin" extension with the "name" property as basename
* should exist in the assets/demos/ directory.
* "ifdef" is an optional array property which can be used to specify
* requirement of SM64 version.
*/
{
"table": [
{"demofile":"bitdw", "ifdef":["VERSION_US"]},
{"demofile":"wf"},
{"demofile":"ccm"},
{"demofile":"bbh"},
{"demofile":"jrb"},
{"demofile":"hmc"},
{"demofile":"pss"},
{"demofile":"unused_fixed"}
],
"demofiles": [
{"name":"bbh"},
{"name":"ccm"},
{"name":"hmc"},
{"name":"jrb"},
{"name":"wf"},
{"name":"pss"},
{"name":"unused_fixed"},
{"name":"bitdw", "ifdef":["VERSION_US"]}
]
}

View File

@ -769,49 +769,6 @@ f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec) {
return current;
}
#ifdef QOL_FIXES
/**
* Return the value 'current' after it tries to approach target, going up at
* most 'inc' and going down at most 'dec'.
*/
s64 approach_s64(s64 current, s64 target, s64 inc, s64 dec) {
//! If target is close to the max or min s64, then it's possible to overflow
// past it without stopping.
if (current < target) {
current += inc;
if (current > target) {
current = target;
}
} else {
current -= dec;
if (current < target) {
current = target;
}
}
return current;
}
/**
* Return the value 'current' after it tries to approach target, going up at
* most 'inc' and going down at most 'dec'.
*/
f64 approach_f64(f64 current, f64 target, f64 inc, f64 dec) {
if (current < target) {
current += inc;
if (current > target) {
current = target;
}
} else {
current -= dec;
if (current < target) {
current = target;
}
}
return current;
}
#endif
/**
* 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).

View File

@ -74,10 +74,6 @@ void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw);
s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec);
f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec);
#ifdef QOL_FIXES
s64 approach_s64(s64 current, s64 target, s64 inc, s64 dec);
f64 approach_f64(f64 current, f64 target, f64 inc, f64 dec);
#endif
s16 atan2s(f32 y, f32 x);
f32 atan2f(f32 a, f32 b);
void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c);

View File

@ -1625,10 +1625,9 @@ s32 update_boss_fight_camera(struct Camera *c, Vec3f focus, Vec3f pos) {
pos[1] = 300.f - (nx * pos[0] + nz * pos[2] + oo) / ny;
switch (gCurrLevelArea) {
case AREA_BOB:
#ifndef QOL_FIXES
pos[1] += 125.f;
//! fall through, makes the BoB boss fight camera move up twice as high as it should
#ifdef QOL_FIXES
break;
#endif
case AREA_WF:
pos[1] += 125.f;
@ -2128,7 +2127,11 @@ s16 update_default_camera(struct Camera *c) {
if (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) {
//! In Mario mode, the camera is zoomed out further than in Lakitu mode (1400 vs 1200)
if (set_cam_angle(0) == CAM_ANGLE_MARIO) {
#ifndef QOL_FIXES
zoomDist = gCameraZoomDist + 1050;
#else
zoomDist = gCameraZoomDist + 850;
#endif
} else {
zoomDist = gCameraZoomDist + 400;
}
@ -2954,22 +2957,28 @@ void update_lakitu(struct Camera *c) {
s16 newYaw;
UNUSED u8 unused1[8];
#ifndef QOL_FIXES
if (gCameraMovementFlags & CAM_MOVE_PAUSE_SCREEN) {
} else {
#else
if (!(gCameraMovementFlags & CAM_MOVE_PAUSE_SCREEN)) {
#endif
#ifndef QOL_FIXES
if (c->cutscene) {
#ifndef QOL_FIXES
}
if (TRUE) {
#endif
#endif
newYaw = next_lakitu_state(newPos, newFoc, c->pos, c->focus, sOldPosition, sOldFocus,
c->nextYaw);
set_or_approach_s16_symmetric(&c->yaw, newYaw, sYawSpeed);
sStatusFlags &= ~CAM_FLAG_UNUSED_CUTSCENE_ACTIVE;
#ifndef QOL_FIXES
} else {
//! dead code, moved to next_lakitu_state()
vec3f_copy(newPos, c->pos);
vec3f_copy(newFoc, c->focus);
}
#endif
// Update old state
vec3f_copy(sOldPosition, newPos);
@ -7111,7 +7120,7 @@ void copy_spline_segment(struct CutsceneSplinePoint dst[], struct CutsceneSpline
#ifndef QOL_FIXES
} while ((src[j].index != -1) && (src[j].index != -1)); //! same comparison performed twice
#else
} while ((src[j].index != -1));
} while (src[j].index != -1);
#endif
} while (j > 16);

View File

@ -17,6 +17,7 @@
#ifdef BETTERCAMERA
#include "bettercamera.h"
#endif
void play_flip_sounds(struct MarioState *m, s16 frame1, s16 frame2, s16 frame3) {
s32 animFrame = m->marioObj->header.gfx.unk38.animFrame;
if (animFrame == frame1 || animFrame == frame2 || animFrame == frame3) {

View File

@ -814,14 +814,8 @@ void tilt_body_walking(struct MarioState *m, s16 startYaw) {
if (val00 < 0) {
val00 = 0;
}
#ifndef QOL_FIXES
val0C->torsoAngle[2] = approach_s32(val0C->torsoAngle[2], val02, 0x400, 0x400);
val0C->torsoAngle[0] = approach_s32(val0C->torsoAngle[0], val00, 0x400, 0x400);
#else
val0C->torsoAngle[2] = approach_s64(val0C->torsoAngle[2], val02, 0x400, 0x400);
val0C->torsoAngle[0] = approach_s64(val0C->torsoAngle[0], val00, 0x400, 0x400);
#endif
#ifndef QOL_FIXES
;
#endif
@ -860,13 +854,8 @@ void tilt_body_ground_shell(struct MarioState *m, s16 startYaw) {
val02 = 0;
}
#ifndef QOL_FIXES
val0C->torsoAngle[2] = approach_s32(val0C->torsoAngle[2], val04, 0x200, 0x200);
val0C->torsoAngle[0] = approach_s32(val0C->torsoAngle[0], val02, 0x200, 0x200);
#else
val0C->torsoAngle[2] = approach_s64(val0C->torsoAngle[2], val04, 0x200, 0x200);
val0C->torsoAngle[0] = approach_s64(val0C->torsoAngle[0], val02, 0x200, 0x200);
#endif
val0C->headAngle[2] = -val0C->torsoAngle[2];
marioObj->header.gfx.angle[2] = val0C->torsoAngle[2];
@ -901,9 +890,9 @@ s32 act_walking(struct MarioState *m) {
#ifdef QOL_FIXES
if (analog_stick_held_back(m)) {
if (m->forwardVel >= 16.0f){
if (m->forwardVel >= 16.0f) {
return set_mario_action(m, ACT_TURNING_AROUND, 0);
} else if ((m->forwardVel) < 10.0f && (m->forwardVel > 0.0f)){
} else if ((m->forwardVel) < 10.0f && (m->forwardVel > 0.0f)) {
m->faceAngle[1] = m->intendedYaw;
return set_mario_action(m, ACT_TURNING_AROUND, 0);
}
@ -1180,7 +1169,11 @@ s32 act_braking(struct MarioState *m) {
}
s32 act_decelerating(struct MarioState *m) {
#ifndef QOL_FIXES
s32 val0C;
#else
s64 val0C;
#endif
s16 slopeClass = mario_get_floor_class(m);
if (!(m->input & INPUT_FIRST_PERSON)) {
@ -1230,7 +1223,11 @@ s32 act_decelerating(struct MarioState *m) {
m->particleFlags |= PARTICLE_DUST;
} else {
// (Speed Crash) Crashes if speed exceeds 2^17.
#ifndef QOL_FIXES
if ((val0C = (s32)(m->forwardVel / 4.0f * 0x10000)) < 0x1000) {
#else
if ((val0C = (s64)(m->forwardVel / 4.0f * 0x10000)) < 0x1000) {
#endif
val0C = 0x1000;
}

View File

@ -67,6 +67,12 @@ void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollision
&& (-rx * obj2->velX - rz * obj2->velZ) / (rx * rx + rz * rz) != NAN) {
projectedV1 = (rx * obj1->velX + rz * obj1->velZ) / (rx * rx + rz * rz);
projectedV2 = (-rx * obj2->velX - rz * obj2->velZ) / (rx * rx + rz * rz);
} else if ((rx * obj1->velX + rz * obj1->velZ) / (rx * rx + rz * rz) == NAN) {
projectedV1 = 0.0f;
projectedV2 = (-rx * obj2->velX - rz * obj2->velZ) / (rx * rx + rz * rz);
} else if ((-rx * obj2->velX - rz * obj2->velZ) / (rx * rx + rz * rz) == NAN) {
projectedV1 = (rx * obj1->velX + rz * obj1->velZ) / (rx * rx + rz * rz);
projectedV2 = 0.0f;
} else {
projectedV1 = 0.0f;
projectedV2 = 0.0f;