Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 21 additions & 45 deletions src/ending/ceremony_and_credits.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ s16 sCutsceneSplineSegment;
s16 D_80287B1E;
s8 D_80287B20;

void vec3f_set_dupe(Vec3f dest, f32 arg1, f32 arg2, f32 arg3) {
dest[0] = arg1;
dest[1] = arg2;
dest[2] = arg3;
}

void vec3s_set_dupe(Vec3s dest, s16 arg1, s16 arg2, s16 arg3) {
dest[0] = arg1;
dest[1] = arg2;
dest[2] = arg3;
}

void vec3f_clear(Vec3f arg0) {
arg0[0] = arg0[1] = arg0[2] = 0.0f;
}
Expand All @@ -69,18 +57,6 @@ void vec3s_clear(Vec3s arg0) {
arg0[0] = arg0[1] = arg0[2] = 0;
}

void vec3f_copy_return_dupe(Vec3f dest, Vec3f src) {
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
}

void vec3s_copy_dupe(Vec3s dest, Vec3s src) {
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
}

void func_80282040(void) {
}

Expand All @@ -90,7 +66,7 @@ void func_80282048(void) {
UNUSED void rotate_y_vec3f(Vec3f dest, Vec3f src, s16 angle) {
Vec3f sp2C;

vec3f_copy_return_dupe(sp2C, src);
vec3f_copy(sp2C, src);
dest[0] = (sp2C[2] * sins(angle)) + (sp2C[0] * coss(angle));
dest[1] = sp2C[1];
dest[2] = (sp2C[2] * coss(angle)) - (sp2C[0] * sins(angle));
Expand All @@ -99,7 +75,7 @@ UNUSED void rotate_y_vec3f(Vec3f dest, Vec3f src, s16 angle) {
UNUSED void rotate_x_vec3f(Vec3f dest, Vec3f src, s16 angle) {
Vec3f sp2C;

vec3f_copy_return_dupe(sp2C, src);
vec3f_copy(sp2C, src);
dest[2] = (sp2C[2] * coss(angle)) - (sp2C[1] * sins(angle));
dest[1] = (sp2C[2] * sins(angle)) + (sp2C[1] * coss(angle));
dest[0] = sp2C[0];
Expand Down Expand Up @@ -234,7 +210,7 @@ UNUSED void aborting_cinematic_function(Vec3f arg0, Vec3f arg1, Vec3f arg2, Vec3
Vec3f sp30;

// What's up with this? Why do we copy arg1 to an unused local variable?
vec3f_copy_return_dupe(sp3C, arg1);
vec3f_copy(sp3C, arg1);
sp30[2] = -((arg2[2] * coss(arg3[0])) - (arg2[1] * sins(arg3[0])));
sp30[1] = (arg2[2] * sins(arg3[0])) + (arg2[1] * coss(arg3[0]));
sp30[0] = arg2[0];
Expand Down Expand Up @@ -427,8 +403,8 @@ void func_80282F44(s32 arg0, CinematicCamera* arg1, Camera* camera) {
Vec3f pos;
Vec3f lookat;

vec3f_set_dupe(pos, camera->pos[0], camera->pos[1], camera->pos[2]);
vec3f_set_dupe(lookat, camera->lookAt[0], camera->lookAt[1], camera->lookAt[2]);
vec3f_set(pos, camera->pos[0], camera->pos[1], camera->pos[2]);
vec3f_set(lookat, camera->lookAt[0], camera->lookAt[1], camera->lookAt[2]);
if ((arg0 == 0) || (arg0 == 1)) {
if ((arg1->unk48[0] != 0) || (arg1->unk48[1] != 0)) {
calculate_distance_angle_y_and_angle_y_to_xz(pos, lookat, &distance, &angleCam[0], &angleCam[1]);
Expand Down Expand Up @@ -533,10 +509,10 @@ void init_cinematic_camera(void) {
camera->cutscene = 0;
D_802856C4 = (s32) D_800DC5E4;
vec3f_clear(camera->lookAt);
vec3f_set_dupe(camera->pos, 0.0f, 0.0f, 500.0f);
vec3f_set(camera->pos, 0.0f, 0.0f, 500.0f);
vec3f_clear(camera->unk30);
vec3f_set_dupe(camera->unk24, 0.0f, 0.0f, 500.0f);
vec3f_set_dupe(camera->unk3C, 0.0f, 1.0f, 0.0f);
vec3f_set(camera->unk24, 0.0f, 0.0f, 500.0f);
vec3f_set(camera->unk3C, 0.0f, 1.0f, 0.0f);
camera->unk18 = 0.0f;
vec3s_clear(camera->unk48);
vec3s_clear(camera->unk4E);
Expand Down Expand Up @@ -588,13 +564,13 @@ s32 func_80283648(Camera* camera) {
CinematicCamera* cinematicCamera = &D_802876E0;

cinematic_stub();
vec3f_copy_return_dupe(pos, camera->pos);
vec3f_copy_return_dupe(lookAt, camera->lookAt);
vec3f_copy_return_dupe(up, camera->up);
vec3f_copy(pos, camera->pos);
vec3f_copy(lookAt, camera->lookAt);
vec3f_copy(up, camera->up);
cinematicCamera->cutscene = func_8028336C(cinematicCamera, camera);
if (cinematicCamera->cutscene != 0) {
vec3f_copy_return_dupe(cinematicCamera->lookAt, camera->pos);
vec3f_copy_return_dupe(cinematicCamera->pos, camera->lookAt);
vec3f_copy(cinematicCamera->lookAt, camera->pos);
vec3f_copy(cinematicCamera->pos, camera->lookAt);
play_cutscene(cinematicCamera);
calculate_distance_angle_y_and_angle_y_to_xz(cinematicCamera->lookAt, cinematicCamera->pos, &distance,
&angleYToXZ, &angleY);
Expand Down Expand Up @@ -624,8 +600,8 @@ s32 func_80283648(Camera* camera) {
camera->up[0] = sins(var_f2) * coss(angleY);
camera->up[1] = coss(var_f2);
camera->up[2] = -sins(var_f2) * sins(angleY);
vec3f_copy_return_dupe(camera->pos, cinematicCamera->lookAt);
vec3f_copy_return_dupe(camera->lookAt, cinematicCamera->pos);
vec3f_copy(camera->pos, cinematicCamera->lookAt);
vec3f_copy(camera->lookAt, cinematicCamera->pos);
if ((gGamestate == CREDITS_SEQUENCE) && (gIsMirrorMode != 0)) {
camera->pos[0] = -camera->pos[0];
camera->lookAt[0] = -camera->lookAt[0];
Expand All @@ -634,9 +610,9 @@ s32 func_80283648(Camera* camera) {
func_80282F44(0, cinematicCamera, camera);
func_80282F44(1, cinematicCamera, camera);
func_80283100(cinematicCamera, gCameraZoom);
vec3f_copy_return_dupe(cinematicCamera->unk30, camera->pos);
vec3f_copy_return_dupe(cinematicCamera->unk24, camera->lookAt);
vec3f_copy_return_dupe(cinematicCamera->unk3C, camera->up);
vec3f_copy(cinematicCamera->unk30, camera->pos);
vec3f_copy(cinematicCamera->unk24, camera->lookAt);
vec3f_copy(cinematicCamera->unk3C, camera->up);
return D_802876D8;
}

Expand Down Expand Up @@ -943,7 +919,7 @@ void func_80283EA0(CinematicCamera* camera) {
}

void copy_player_two_in_camera(CinematicCamera* camera) {
vec3f_copy_return_dupe(camera->pos, gPlayerTwo->pos);
vec3f_copy(camera->pos, gPlayerTwo->pos);
}

void lerp_player_two_in_camera(CinematicCamera* camera) {
Expand All @@ -959,7 +935,7 @@ void func_80283F6C(CinematicCamera* camera) {
}

void copy_player_three_in_camera(CinematicCamera* camera) {
vec3f_copy_return_dupe(camera->pos, gPlayerThree->pos);
vec3f_copy(camera->pos, gPlayerThree->pos);
}

void lerp_player_three_in_camera(CinematicCamera* camera) {
Expand Down Expand Up @@ -1006,7 +982,7 @@ void func_80284184(CinematicCamera* camera) {

void func_802841E8(CinematicCamera* camera) {
func_80282E58(camera, (struct struct_80282C40*) D_80285940, 0);
vec3f_set_dupe(camera->pos, -3202.0f, 90.0f, -478.0f);
vec3f_set(camera->pos, -3202.0f, 90.0f, -478.0f);
}

void func_8028422C(CinematicCamera* camera) {
Expand Down
4 changes: 0 additions & 4 deletions src/ending/ceremony_and_credits.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,8 @@ typedef CameraEvent CutsceneShot;

void init_cinematic_camera(void);
s32 func_80283648(Camera*);
void vec3f_set_dupe(Vec3f, f32, f32, f32);
void vec3s_set_dupe(Vec3s, s16, s16, s16);
void vec3f_clear(Vec3f);
void vec3s_clear(Vec3s);
void vec3f_copy_return_dupe(Vec3f, Vec3f);
void vec3s_copy_dupe(Vec3s, Vec3s);
void func_80282040(void);
void func_80282048(void);
void rotate_y_vec3f(Vec3f, Vec3f, s16);
Expand Down
41 changes: 24 additions & 17 deletions src/ending/podium_ceremony_actors.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "code_80281C40.h"
#include "math_util.h"
#include <string.h>
#include <stdint.h>
#include "port/interpolation/FrameInterpolation.h"

#include "src/port/Game.h"
Expand Down Expand Up @@ -137,35 +138,40 @@ void clear_D_802874D8_actors() {
}

u16 random_u16_credits(void) {
u16 temp1, temp2;
if (CVarGetInteger("gModernPRNG", false) == false)
{
u16 temp1, temp2;

if (sRandomSeed16 == 22026) {
sRandomSeed16 = 0;
}
if (sRandomSeed16 == 22026) {
sRandomSeed16 = 0;
}

temp1 = (sRandomSeed16 & 0x00FF) << 8;
temp1 = temp1 ^ sRandomSeed16;
temp1 = (sRandomSeed16 & 0x00FF) << 8;
temp1 = temp1 ^ sRandomSeed16;

sRandomSeed16 = ((temp1 & 0x00FF) << 8) + ((temp1 & 0xFF00) >> 8);
sRandomSeed16 = ((temp1 & 0x00FF) << 8) + ((temp1 & 0xFF00) >> 8);

temp1 = ((temp1 & 0x00FF) << 1) ^ sRandomSeed16;
temp2 = (temp1 >> 1) ^ 0xFF80;
temp1 = ((temp1 & 0x00FF) << 1) ^ sRandomSeed16;
temp2 = (temp1 >> 1) ^ 0xFF80;

if ((temp1 & 1) == 0) {
if (temp2 == 43605) {
sRandomSeed16 = 0;
if ((temp1 & 1) == 0) {
if (temp2 == 43605) {
sRandomSeed16 = 0;
} else {
sRandomSeed16 = temp2 ^ 0x1FF4;
}
} else {
sRandomSeed16 = temp2 ^ 0x1FF4;
sRandomSeed16 = temp2 ^ 0x8180;
}
} else {
sRandomSeed16 = temp2 ^ 0x8180;

return sRandomSeed16;
}

return sRandomSeed16;
return random_u16();
}

f32 random_float_between_0_and_1(void) {
return random_u16_credits() / 65536.0f;
return random_u16_credits() / (f32) UINT16_MAX;
}

f32 random_who_knows(f32 arg0) {
Expand Down Expand Up @@ -309,6 +315,7 @@ void unused_80280FA8(UNUSED CeremonyActor* actor) {
}

void balloons_and_fireworks_init(void) {
sRandomSeed16 = 0;
D_802874D8.actorTimer = 0;
sPodiumActorList = (CeremonyActor*) get_next_available_memory_addr(sizeof(CeremonyActor) * 200);
bzero(sPodiumActorList, (sizeof(CeremonyActor) * 200));
Expand Down
6 changes: 0 additions & 6 deletions src/math_util_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ UNUSED s32 func_80040EA4(s32* arg0, s32 arg1) {
return phi_v1;
}

void vec3f_copy(Vec3f dest, Vec3f arg1) {
dest[0] = arg1[0];
dest[1] = arg1[1];
dest[2] = arg1[2];
}

s32 f32_step_up_towards(f32* value, f32 target, f32 step) {
s32 targetReached = 0;

Expand Down
5 changes: 5 additions & 0 deletions src/port/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
// #include <Fast3D/gfx_rendering_api.h>
#include <SDL2/SDL.h>

#include <stdlib.h>
#include <time.h>

#include <utility>

#ifdef __SWITCH__
Expand Down Expand Up @@ -121,6 +124,8 @@ GameEngine::GameEngine() {
}
}

srand(time(NULL));

this->context = Ship::Context::CreateUninitializedInstance("Spaghetti Kart", "spaghettify", "spaghettify.cfg.json");

this->context->InitConfiguration(); // without this line InitConsoleVariables fails at Config::Reload()
Expand Down
2 changes: 2 additions & 0 deletions src/port/ui/PortMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ void PortMenu::AddEnhancements() {
.CVar("gShowSpaghettiVersion")
.Options(CheckboxOptions().Tooltip("Show the Spaghetti Kart version on the Mario Kart menu").DefaultValue(true));

AddWidget(path, "Use modern PRNG", WIDGET_CVAR_CHECKBOX).CVar("gModernPRNG");

AddRulesets();

path = { "Enhancements", "Cheats", SECTION_COLUMN_1 };
Expand Down
4 changes: 2 additions & 2 deletions src/racing/actors.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ void cleanup_red_and_green_shells(struct ShellActor* shell) {

// Sets introductory values for a new actor (ex. Banana).
void actor_init(struct Actor* actor, Vec3f startingPos, Vec3s startingRot, Vec3f startingVelocity, s16 actorType) {
vec3f_copy_return(actor->pos, startingPos);
vec3f_copy(actor->pos, startingPos);
vec3s_copy(actor->rot, startingRot);
vec3f_copy_return(actor->velocity, startingVelocity);
vec3f_copy(actor->velocity, startingVelocity);
actor->type = actorType;
actor->flags = -0x8000;
actor->unk_04 = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/racing/actors_extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ void copy_collision(Collision* src, Collision* dest) {
dest->surfaceDistance[1] = src->surfaceDistance[1];
dest->surfaceDistance[2] = src->surfaceDistance[2];

vec3f_copy_return(dest->unk48, src->unk48);
vec3f_copy_return(dest->unk54, src->unk54);
vec3f_copy_return(dest->orientationVector, src->orientationVector);
vec3f_copy(dest->unk48, src->unk48);
vec3f_copy(dest->unk54, src->unk54);
vec3f_copy(dest->orientationVector, src->orientationVector);
}

void triple_shell_actor_collide_with_player(struct ShellActor* shell, s32 shellType) {
Expand Down
Loading
Loading