diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2025-01-13 21:15:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-13 21:15:16 -0700 |
| commit | 04d56d6ba0705776149358608a27db8ab23e9449 (patch) | |
| tree | ee699599021dde72fb4a2b8eb34792be53ec5ecd /src/engine/objects | |
| parent | 389f0f495131928cd620afee41095aff6683c8e9 (diff) | |
Fixes as per Sonic (#154)
* Fix imGUI game reset button
* Fix course select cursor sound oob
* Fix cloud rendering
* Fix centering of tt race data cannot be saved by ghost
* Impl chain chomp & bats
* Fix retry crash
* DebugMode On Skips intro logo menu
* rename
Diffstat (limited to 'src/engine/objects')
| -rw-r--r-- | src/engine/objects/Bat.cpp | 256 | ||||
| -rw-r--r-- | src/engine/objects/Bat.h | 59 | ||||
| -rw-r--r-- | src/engine/objects/ChainChomp.cpp | 125 | ||||
| -rw-r--r-- | src/engine/objects/ChainChomp.h | 47 |
4 files changed, 487 insertions, 0 deletions
diff --git a/src/engine/objects/Bat.cpp b/src/engine/objects/Bat.cpp new file mode 100644 index 000000000..f32ef2d41 --- /dev/null +++ b/src/engine/objects/Bat.cpp @@ -0,0 +1,256 @@ +#include "Bat.h" +#include "World.h" +#include "CoreMath.h" + +extern "C" { +#include "render_objects.h" +#include "update_objects.h" +#include "assets/banshee_boardwalk_data.h" +#include "assets/common_data.h" +#include "math_util.h" +#include "math_util_2.h" +#include "code_80086E70.h" +#include "code_80057C60.h" +#include "code_800029B0.h" +} + +const char* sBoardwalkTexList[] = { gTextureBat1, gTextureBat2, gTextureBat3, gTextureBat4 }; + +size_t OBat::_count = 0; + +OBat::OBat(const FVector& pos, const FRotation& rot) { + s32 objectId = indexObjectList1[0]; + init_texture_object(objectId, (uint8_t*)d_course_banshee_boardwalk_bat_tlut, sBoardwalkTexList, 0x20U, + (u16) 0x00000040); + gObjectList[objectId].orientation[0] = rot.pitch; + gObjectList[objectId].orientation[1] = rot.roll; + gObjectList[objectId].orientation[2] = rot.yaw; // 0x8000 + + _count++; +} + +void OBat::Tick() { + s32 var_s2; + s32 temp_s0; + Object* object; + + if (D_8018CFC8 != 0) { + D_8018CFC8 -= 1; + } + if (D_8018D000 != 0) { + D_8018D000 -= 1; + } + temp_s0 = indexObjectList1[0]; + func_80072E54(temp_s0, 0, 3, 1, 0, -1); + func_80073514(temp_s0); + object = &gObjectList[temp_s0]; + func_80073CB0(temp_s0, &object->primAlpha, -0x00001000, 0x00001000, 0x00000400, 0, -1); + object->orientation[2] = object->primAlpha + 0x8000; + if ((D_8018CFB0 != 0) || (D_8018CFC8 != 0)) { + D_8018CFD8 = 0; + for (var_s2 = 0; var_s2 < 40; var_s2++) { + temp_s0 = gObjectParticle2[var_s2]; + if (temp_s0 == -1) { + continue; + } + + object = &gObjectList[temp_s0]; + if (object->state == 0) { + continue; + } + + OBat::func_8007D8D4(temp_s0, 1); + OBat::func_8007DAF8(temp_s0, 1); + OBat::func_8007D794(temp_s0); + if (object->state == 0) { + delete_object_wrapper(&gObjectParticle2[var_s2]); + } + D_8018CFD8 += 1; + } + if (D_8018CFD8 != 0) { + D_8018CFC8 = 0x012C; + } + } + if ((D_8018CFE8 != 0) || (D_8018D000 != 0)) { + D_8018D010 = 0; + for (var_s2 = 0; var_s2 < 30; var_s2++) { + temp_s0 = gObjectParticle3[var_s2]; + if (temp_s0 == -1) { + continue; + } + + object = &gObjectList[temp_s0]; + if (object->state == 0) { + continue; + } + + OBat::func_8007D8D4(temp_s0, 2); + OBat::func_8007DAF8(temp_s0, 2); + OBat::func_8007D794(temp_s0); + if (object->state == 0) { + delete_object_wrapper(&gObjectParticle3[var_s2]); + } + D_8018D010 += 1; + } + if (D_8018D010 != 0) { + D_8018D000 = 0x012C; + } + } +} + +void OBat::Draw(s32 cameraId) { + s32 var_s2; + s32 objectIndex; + Camera* temp_s7; + + objectIndex = indexObjectList1[0]; + temp_s7 = &camera1[cameraId]; + OBat::func_80046F60((u8*)gObjectList[objectIndex].activeTLUT, (u8*)gObjectList[objectIndex].activeTexture, 0x00000020, 0x00000040, + 5); + D_80183E80[0] = gObjectList[objectIndex].orientation[0]; + D_80183E80[2] = gObjectList[objectIndex].orientation[2]; + if ((D_8018CFB0 != 0) || (D_8018CFC8 != 0)) { + for (var_s2 = 0; var_s2 < 40; var_s2++) { + objectIndex = gObjectParticle2[var_s2]; + if (objectIndex == -1) { + continue; + } + + if ((gObjectList[objectIndex].state >= 2) && (gMatrixHudCount < 0x2EF)) { + D_80183E80[1] = + func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], temp_s7->pos); + func_800431B0(gObjectList[objectIndex].pos, D_80183E80, gObjectList[objectIndex].sizeScaling, + (Vtx*)D_0D0062B0); + } + } + } + if ((D_8018CFE8 != 0) || (D_8018D000 != 0)) { + for (var_s2 = 0; var_s2 < 30; var_s2++) { + objectIndex = gObjectParticle3[var_s2]; + if (objectIndex == -1) { + continue; + } + + if ((gObjectList[objectIndex].state >= 2) && (gMatrixHudCount < 0x2EF)) { + D_80183E80[1] = + func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], temp_s7->pos); + func_800431B0(gObjectList[objectIndex].pos, D_80183E80, gObjectList[objectIndex].sizeScaling, + (Vtx*)D_0D0062B0); + } + } + } + gSPTexture(gDisplayListHead++, 0x0001, 0x0001, 0, G_TX_RENDERTILE, G_OFF); +} + +void OBat::func_80046F60(u8* tlut, u8* arg1, s32 arg2, s32 arg3, s32 arg4) { + gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D007D78); + gDPLoadTLUT_pal256(gDisplayListHead++, tlut); + rsp_load_texture_mask(arg1, arg2, arg3, arg4); +} + +void OBat::func_8007D8AC(s32 arg0) { + object_next_state(arg0); + func_80086E70(arg0); +} + +s32 OBat::func_8007D804(s32 objectIndex) { + s32 loopIndex; + s32 someCount; + + someCount = 0; + for (loopIndex = 0; loopIndex < gPlayerCountSelection1; loopIndex++) { + if (is_object_visible_on_camera(objectIndex, &camera1[loopIndex], 0x4000U) != 0) { + someCount += 1; + } + } + return someCount; +} + +void OBat::func_8007D8D4(s32 objectIndex, s32 arg1) { + switch (gObjectList[objectIndex].state) { + case 1: + OBat::func_8007D8AC(objectIndex); + break; + case 2: + if (OBat::func_8007D804(objectIndex) == 0) { + func_80072428(objectIndex); + } + if (arg1 == 1) { + if (gIsMirrorMode != 0) { + if (gObjectList[objectIndex].pos[0] >= 2540.0) { + func_80072428(objectIndex); + } + } else if (gObjectList[objectIndex].pos[0] <= -2540.0) { + func_80072428(objectIndex); + } + } else if (gIsMirrorMode != 0) { + if (gObjectList[objectIndex].pos[0] >= 2150.0) { + func_80072428(objectIndex); + } + } else { + if (gObjectList[objectIndex].pos[0] <= -2150.0) { + func_80072428(objectIndex); + } + } + break; + case 0: + break; + } +} + +void OBat::func_8007DA74(s32 objectIndex) { + UNUSED s32 pad; + if ((gObjectList[objectIndex].unk_0AE != 0) && (gObjectList[objectIndex].unk_0AE == 1)) { + if (func_80087060(objectIndex, 0x0000001E) != 0) { + gObjectList[objectIndex].unk_0C6 = 0U; + } + } + gObjectList[objectIndex].direction_angle[0] = + func_800417B4(gObjectList[objectIndex].direction_angle[0], gObjectList[objectIndex].unk_0C6); + func_80087844(objectIndex); + object_calculate_new_pos_offset(objectIndex); +} + +void OBat::func_8007DA4C(s32 objectIndex) { + func_8008781C(objectIndex); + object_calculate_new_pos_offset(objectIndex); +} + +void OBat::func_8007DAF8(s32 objectIndex, s32 arg1) { + switch (arg1) { + case 1: + OBat::func_8007DA74(objectIndex); + return; + case 2: + OBat::func_8007DA4C(objectIndex); + return; + } +} + +void OBat::func_80089A04(s32 objectIndex, f32 arg1, f32 arg2) { + Player* player; + s32 var_s1; + + player = gPlayerOne; + if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { + for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++) { + if ((gObjectList[objectIndex].state != 0) && !(player->effects & (BOO_EFFECT | STAR_EFFECT)) && + (has_collided_with_player(objectIndex, player) != 0)) { + func_8008933C(player, objectIndex, arg1, arg2 * 1.1); + if (is_obj_flag_status_active(objectIndex, 0x04000000) != 0) { + func_80072180(); + } + } + } + } +} + +void OBat::func_8007D794(s32 objectIndex) { + if (gCCSelection == CC_50) { + OBat::func_80089A04(objectIndex, 0.5f, 0.2f); + } else if (gCCSelection == CC_100) { + OBat::func_80089A04(objectIndex, 0.4f, 0.15f); + } else { + OBat::func_80089A04(objectIndex, 0.25f, 0.1f); + } +} diff --git a/src/engine/objects/Bat.h b/src/engine/objects/Bat.h new file mode 100644 index 000000000..39a9e65d8 --- /dev/null +++ b/src/engine/objects/Bat.h @@ -0,0 +1,59 @@ +#pragma once + +#include <libultraship.h> +#include <vector> +#include "Object.h" + +#include "World.h" +#include "CoreMath.h" + +extern "C" { +#include "macros.h" +#include "main.h" +#include "vehicles.h" +#include "waypoints.h" +#include "common_structs.h" +#include "objects.h" +#include "camera.h" +#include "some_data.h" +} + +/** + * OBat + * + * FRotation does not appear to do anything. + * Could not find where origin_pos was at. + * So pos does not work either + * + */ +class OBat : public OObject { +public: + explicit OBat(const FVector& pos, const FRotation& rot); + + ~OBat() { + _count--; + } + + static size_t GetCount() { + return _count; + } + + virtual void Tick() override; + virtual void Draw(s32 cameraId) override; + void func_80046F60(u8* tlut, u8* arg1, s32 arg2, s32 arg3, s32 arg4); + + void func_8007D8AC(s32 arg0); + s32 func_8007D804(s32 objectIndex); + void func_8007D8D4(s32 objectIndex, s32 arg1); + void func_8007DA74(s32 objectIndex); + void func_8007DAF8(s32 objectIndex, s32 arg1); + void func_80089A04(s32 objectIndex, f32 arg1, f32 arg2); + void func_8007D794(s32 objectIndex); + void func_8007DA4C(s32 objectIndex); + + +private: + FVector _pos; + static size_t _count; + size_t _idx; +}; diff --git a/src/engine/objects/ChainChomp.cpp b/src/engine/objects/ChainChomp.cpp new file mode 100644 index 000000000..1008aab52 --- /dev/null +++ b/src/engine/objects/ChainChomp.cpp @@ -0,0 +1,125 @@ +#include "ChainChomp.h" +#include "World.h" + +extern "C" { +#include "render_objects.h" +#include "update_objects.h" +#include "assets/rainbow_road_data.h" +#include "assets/common_data.h" +#include "math_util.h" +#include "math_util_2.h" +#include "code_80086E70.h" +#include "code_80057C60.h" +#include "code_80005FD0.h" +#include "external.h" +} + +size_t OChainChomp::_count = 0; + +OChainChomp::OChainChomp() { + _idx = _count; + init_object(indexObjectList2[_count], 0); + + + _count++; +} + +void OChainChomp::Tick() { + s32 objectIndex; + Object* object; + + objectIndex = indexObjectList2[_idx]; + object = &gObjectList[objectIndex]; + if (object->state != 0) { + OChainChomp::func_800859C8(objectIndex, _idx); + vec3f_copy(object->unk_01C, object->offset); + // This should be spawn pos or follow path + func_8000D940(object->offset, &object->unk_084[8], object->unk_034, object->surfaceHeight, 0); + object->direction_angle[1] = get_angle_between_two_vectors(object->unk_01C, object->offset); + object_calculate_new_pos_offset(objectIndex); + func_80089CBC(objectIndex, 30.0f); + } +} + +void OChainChomp::Draw(s32 cameraId) { + s32 objectIndex; + + objectIndex = indexObjectList2[_idx]; + func_8008A1D0(objectIndex, cameraId, 0x000005DC, 0x000009C4); + if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) { + func_80055AB8(objectIndex, cameraId); + } +} + +void OChainChomp::func_80055AB8(s32 objectIndex, s32 cameraId) { + Camera* camera; + + camera = &camera1[cameraId]; + if (gObjectList[objectIndex].state >= 2) { + if (is_obj_flag_status_active(objectIndex, 0x00100000) != 0) { + D_80183E40[0] = gObjectList[objectIndex].pos[0]; + D_80183E40[1] = gObjectList[objectIndex].pos[1] + 16.0; + D_80183E40[2] = gObjectList[objectIndex].pos[2]; + D_80183E80[0] = 0; + D_80183E80[1] = + func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], camera->pos); + D_80183E80[2] = 0x8000; + func_800468E0(D_80183E40, D_80183E80, 0.54f, (u8*)d_course_rainbow_road_sphere, (Vtx*)D_0D0062B0, 0x00000020, + 0x00000040, 0x00000020, 0x00000040, 5); + } else { + rsp_set_matrix_transformation(gObjectList[objectIndex].pos, gObjectList[objectIndex].direction_angle, + gObjectList[objectIndex].sizeScaling); + gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D0077D0); + render_animated_model((Armature*) gObjectList[objectIndex].model, + (Animation**) gObjectList[objectIndex].vertex, 0, + (s16) gObjectList[objectIndex].textureListIndex); + } + } +} + +void OChainChomp::func_80085878(s32 objectIndex, s32 arg1) { + TrackWaypoint* temp_v0; + Object* object; + + object = &gObjectList[objectIndex]; + object->unk_0D8 = 1; + object->model = (Gfx*) d_rainbow_road_unk4; + object->vertex = (Vtx*) d_rainbow_road_unk3; + object->sizeScaling = 0.03f; + object->boundingBoxSize = 0x000A; + set_object_flag(objectIndex, 0x04000200); + object->unk_084[8] = (arg1 * 0x12C) + 0x1F4; + set_obj_origin_pos(objectIndex, 0.0f, -15.0f, 0.0f); + temp_v0 = &D_80164490[(u16) object->unk_084[8]]; + set_obj_origin_offset(objectIndex, temp_v0->posX, temp_v0->posY, temp_v0->posZ); + set_obj_direction_angle(objectIndex, 0U, 0U, 0U); + object->unk_034 = 4.0f; + object->type = get_animation_length(d_rainbow_road_unk3, 0); + object_next_state(objectIndex); +} + + +void OChainChomp::func_800859C8(s32 objectIndex, s32 arg1) { + Object* object; + + object = &gObjectList[objectIndex]; + switch (object->state) { /* irregular */ + case 0: + break; + case 1: + OChainChomp::func_80085878(objectIndex, arg1); + break; + case 2: + func_80072E54(objectIndex, 0, (s32) object->type, 1, 0, -1); + break; + } + if (D_8018D40C == 0) { + func_800C98B8(object->pos, object->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x57)); + } + func_80074344(objectIndex, &object->surfaceHeight, -0.8f, 0.8f, 0.03f, 0, -1); +} + + + + + diff --git a/src/engine/objects/ChainChomp.h b/src/engine/objects/ChainChomp.h new file mode 100644 index 000000000..e1eb35347 --- /dev/null +++ b/src/engine/objects/ChainChomp.h @@ -0,0 +1,47 @@ +#pragma once + +#include <libultraship.h> +#include <vector> +#include "Object.h" + +#include "World.h" + +extern "C" { +#include "macros.h" +#include "main.h" +#include "vehicles.h" +#include "waypoints.h" +#include "common_structs.h" +#include "objects.h" +#include "camera.h" +#include "some_data.h" +} + +/** + * Animation crash for custom courses + */ +class OChainChomp : public OObject { +public: + explicit OChainChomp(); + + + ~OChainChomp() { + _count--; + } + + static size_t GetCount() { + return _count; + } + + virtual void Tick() override; + virtual void Draw(s32 cameraId) override; + void func_80055AB8(s32 objectIndex, s32 cameraId); + + void func_80085878(s32 objectIndex, s32 arg1); + void func_800859C8(s32 objectIndex, s32 arg1); + +private: + FVector _pos; + static size_t _count; + size_t _idx; +}; |
