summaryrefslogtreecommitdiff
path: root/src/engine/objects
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/objects')
-rw-r--r--src/engine/objects/Flagpole.cpp85
-rw-r--r--src/engine/objects/Flagpole.h45
-rw-r--r--src/engine/objects/Hedgehog.cpp183
-rw-r--r--src/engine/objects/Hedgehog.h53
-rw-r--r--src/engine/objects/Seagull.cpp18
-rw-r--r--src/engine/objects/Seagull.h1
-rw-r--r--src/engine/objects/Snowman.cpp49
-rw-r--r--src/engine/objects/Snowman.h2
8 files changed, 432 insertions, 4 deletions
diff --git a/src/engine/objects/Flagpole.cpp b/src/engine/objects/Flagpole.cpp
new file mode 100644
index 000000000..682f74915
--- /dev/null
+++ b/src/engine/objects/Flagpole.cpp
@@ -0,0 +1,85 @@
+#include "Flagpole.h"
+#include "World.h"
+
+extern "C" {
+#include "code_800029B0.h"
+#include "render_objects.h"
+#include "update_objects.h"
+#include "assets/yoshi_valley_data.h"
+#include "assets/common_data.h"
+#include "math_util.h"
+#include "math_util_2.h"
+#include "code_80086E70.h"
+#include "code_80057C60.h"
+}
+
+size_t OFlagpole::_count = 0;
+
+OFlagpole::OFlagpole(const FVector& pos, s16 direction) {
+ _idx = _count;
+ _pos = pos;
+ _direction = direction;
+
+ init_object(indexObjectList1[_idx], 0);
+
+ _count++;
+}
+
+void OFlagpole::Tick() { // func_80083080
+ s32 objectIndex = indexObjectList1[_idx];
+
+ if (gObjectList[objectIndex].state != 0) {
+ OFlagpole::func_80083018(objectIndex);
+ OFlagpole::func_80083060(objectIndex);
+ }
+}
+
+void OFlagpole::Draw(s32 cameraId) { // func_80055228
+ s32 objectIndex = indexObjectList1[_idx];
+
+ func_8008A364(objectIndex, cameraId, 0x4000U, 0x000005DC);
+ if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
+ OFlagpole::func_80055164(objectIndex);
+ }
+}
+
+void OFlagpole::func_80055164(s32 objectIndex) { // func_80055164
+ if (gObjectList[objectIndex].state >= 2) {
+ gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D0077A0);
+ rsp_set_matrix_transformation(gObjectList[objectIndex].pos, gObjectList[objectIndex].direction_angle,
+ gObjectList[objectIndex].sizeScaling);
+ if (gIsGamePaused == 0) {
+ gObjectList[objectIndex].unk_0A2 = render_animated_model((Armature*) gObjectList[objectIndex].model,
+ (Animation**) gObjectList[objectIndex].vertex, 0,
+ gObjectList[objectIndex].unk_0A2);
+ } else {
+ render_animated_model((Armature*) gObjectList[objectIndex].model,
+ (Animation**) gObjectList[objectIndex].vertex, 0, gObjectList[objectIndex].unk_0A2);
+ }
+ }
+}
+
+void OFlagpole::func_80082F1C(s32 objectIndex) {
+ gObjectList[objectIndex].model = (Gfx*) d_course_yoshi_valley_unk5;
+ gObjectList[objectIndex].vertex = (Vtx*) d_course_yoshi_valley_unk4;
+ gObjectList[objectIndex].sizeScaling = 0.027f;
+ object_next_state(objectIndex);
+ set_obj_origin_pos(objectIndex, _pos.x * xOrientation, _pos.y, _pos.z);
+ set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
+ set_obj_direction_angle(objectIndex, 0U, _direction, 0U);
+}
+
+void OFlagpole::func_80083018(s32 objectIndex) {
+ switch (gObjectList[objectIndex].state) {
+ case 1:
+ OFlagpole::func_80082F1C(objectIndex);
+ break;
+ case 0:
+ default:
+ break;
+ }
+}
+
+void OFlagpole::func_80083060(s32 objectIndex) {
+ object_calculate_new_pos_offset(objectIndex);
+}
diff --git a/src/engine/objects/Flagpole.h b/src/engine/objects/Flagpole.h
new file mode 100644
index 000000000..5824fcf18
--- /dev/null
+++ b/src/engine/objects/Flagpole.h
@@ -0,0 +1,45 @@
+#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"
+}
+
+class OFlagpole : public OObject {
+public:
+ explicit OFlagpole(const FVector& pos, s16 direction);
+
+ ~OFlagpole() {
+ _count--;
+ }
+
+ static size_t GetCount() {
+ return _count;
+ }
+
+ virtual void Tick() override;
+ virtual void Draw(s32 cameraId) override;
+
+ void func_80055164(s32 objectIndex);
+ void func_80082F1C(s32 objectIndex);
+ void func_80083018(s32 objectIndex);
+ void func_80083060(s32 objectIndex);
+
+private:
+ FVector _pos;
+ s16 _direction;
+ static size_t _count;
+ size_t _idx;
+};
diff --git a/src/engine/objects/Hedgehog.cpp b/src/engine/objects/Hedgehog.cpp
new file mode 100644
index 000000000..133a1f38d
--- /dev/null
+++ b/src/engine/objects/Hedgehog.cpp
@@ -0,0 +1,183 @@
+#include "Hedgehog.h"
+#include "World.h"
+
+extern "C" {
+#include "render_objects.h"
+#include "update_objects.h"
+#include "assets/yoshi_valley_data.h"
+#include "assets/common_data.h"
+#include "math_util.h"
+#include "math_util_2.h"
+#include "code_80086E70.h"
+#include "code_80057C60.h"
+}
+
+size_t OHedgehog::_count = 0;
+
+OHedgehog::OHedgehog(const FVector& pos, const FVector2D& patrolPoint, s16 unk) {
+ _idx = _count;
+ _pos = pos;
+
+ s32 objectId = indexObjectList2[_idx];
+ init_object(objectId, 0);
+ gObjectList[objectId].pos[0] = gObjectList[objectId].origin_pos[0] = pos.x * xOrientation;
+ gObjectList[objectId].pos[1] = gObjectList[objectId].surfaceHeight = pos.y + 6.0;
+ gObjectList[objectId].pos[2] = gObjectList[objectId].origin_pos[2] = pos.z;
+ gObjectList[objectId].unk_0D5 = (u8)unk;
+ gObjectList[objectId].unk_09C = patrolPoint.x * xOrientation;
+ gObjectList[objectId].unk_09E = patrolPoint.z;
+
+ _count++;
+}
+
+void OHedgehog::Tick() {
+ s32 objectIndex = indexObjectList2[_idx];
+
+ OHedgehog::func_800833D0(objectIndex, _idx);
+ OHedgehog::func_80083248(objectIndex);
+ OHedgehog::func_80083474(objectIndex);
+
+ // This func clears a bit from all hedgehogs. This results in setting the height of all hedgehogs to zero.
+ // The solution is to only clear the bit from the current instance; `self` or `this`
+ //func_80072120(indexObjectList2, NUM_HEDGEHOGS);
+ clear_object_flag(objectIndex, 0x00600000); // The fix
+}
+
+void OHedgehog::Draw(s32 cameraId) {
+ s32 objectIndex = indexObjectList2[_idx];
+ u32 something = func_8008A364(objectIndex, cameraId, 0x4000U, 0x000003E8);
+
+ if (CVarGetInteger("gNoCulling", 0) == 1) {
+ something = MIN(something, 0x52211U - 1);
+ }
+ if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
+ set_object_flag(objectIndex, 0x00200000);
+ if (something < 0x2711U) {
+ set_object_flag(objectIndex, 0x00000020);
+ } else {
+ clear_object_flag(objectIndex, 0x00000020);
+ }
+ if (something < 0x57E41U) {
+ set_object_flag(objectIndex, 0x00400000);
+ }
+ if (something < 0x52211U) {
+ OHedgehog::func_800555BC(objectIndex, cameraId);
+ }
+ }
+}
+
+void OHedgehog::func_800555BC(s32 objectIndex, s32 cameraId) {
+ Camera* camera;
+
+ if (gObjectList[objectIndex].state >= 2) {
+ camera = &camera1[cameraId];
+ OHedgehog::func_8004A870(objectIndex, 0.7f);
+ gObjectList[objectIndex].orientation[1] =
+ func_800418AC(gObjectList[objectIndex].pos[0], gObjectList[objectIndex].pos[2], camera->pos);
+ draw_2d_texture_at(gObjectList[objectIndex].pos, gObjectList[objectIndex].orientation,
+ gObjectList[objectIndex].sizeScaling, (u8*) gObjectList[objectIndex].activeTLUT,
+ (u8*)gObjectList[objectIndex].activeTexture, gObjectList[objectIndex].vertex, 64, 64, 64, 32);
+ }
+}
+
+void OHedgehog::func_8004A870(s32 objectIndex, f32 arg1) {
+ Mat4 mtx;
+ Object* object;
+
+ if ((is_obj_flag_status_active(objectIndex, 0x00000020) != 0) &&
+ (is_obj_flag_status_active(objectIndex, 0x00800000) != 0)) {
+ object = &gObjectList[objectIndex];
+ D_80183E50[0] = object->pos[0];
+ D_80183E50[1] = object->surfaceHeight + 0.8;
+ D_80183E50[2] = object->pos[2];
+ set_transform_matrix(mtx, object->unk_01C, D_80183E50, 0U, arg1);
+ // convert_to_fixed_point_matrix(&gGfxPool->mtxHud[gMatrixHudCount], mtx);
+ // gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxHud[gMatrixHudCount++]),
+ // G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+
+ AddHudMatrix(mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D007B98);
+ }
+}
+
+const char* sHedgehogTexList[] = { d_course_yoshi_valley_hedgehog };
+
+void OHedgehog::func_8008311C(s32 objectIndex, s32 arg1) {
+ Object* object;
+ Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_hedgehog);
+
+ init_texture_object(objectIndex, (u8*)d_course_yoshi_valley_hedgehog_tlut, sHedgehogTexList, 0x40U, (u16) 0x00000040);
+ object = &gObjectList[objectIndex];
+ object->activeTLUT = d_course_yoshi_valley_hedgehog_tlut;
+ object->activeTexture = d_course_yoshi_valley_hedgehog;
+ object->vertex = vtx;
+ object->sizeScaling = 0.2f;
+ object->textureListIndex = 0;
+ object_next_state(objectIndex);
+ set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f);
+ set_obj_orientation(objectIndex, 0U, 0U, 0x8000U);
+ object->unk_034 = ((arg1 % 6) * 0.1) + 0.5;
+ func_80086E70(objectIndex);
+ set_object_flag(objectIndex, 0x04000600);
+ object->boundingBoxSize = 2;
+}
+
+void OHedgehog::func_80083248(s32 objectIndex) {
+ switch (gObjectList[objectIndex].unk_0AE) {
+ case 0:
+ break;
+ case 1:
+ if (func_80087A0C(objectIndex, gObjectList[objectIndex].origin_pos[0], gObjectList[objectIndex].unk_09C,
+ gObjectList[objectIndex].origin_pos[2], gObjectList[objectIndex].unk_09E) != 0) {
+ func_80086FD4(objectIndex);
+ }
+ break;
+ case 2:
+ func_800871AC(objectIndex, 0x0000003C);
+ break;
+ case 3:
+ if (func_80087A0C(objectIndex, gObjectList[objectIndex].unk_09C, gObjectList[objectIndex].origin_pos[0],
+ gObjectList[objectIndex].unk_09E, gObjectList[objectIndex].origin_pos[2]) != 0) {
+ func_80086FD4(objectIndex);
+ }
+ break;
+ case 4:
+ if (func_80087060(objectIndex, 0x0000003C) != 0) {
+ func_8008701C(objectIndex, 1);
+ }
+ break;
+ }
+ object_calculate_new_pos_offset(objectIndex);
+ if (is_obj_flag_status_active(objectIndex, 0x00200000) != 0) {
+ if (is_obj_flag_status_active(objectIndex, 0x00400000) != 0) {
+ func_8008861C(objectIndex);
+ }
+ gObjectList[objectIndex].pos[1] = gObjectList[objectIndex].surfaceHeight + 6.0;
+ }
+}
+
+void OHedgehog::func_800833D0(s32 objectIndex, s32 arg1) {
+ switch (gObjectList[objectIndex].state) {
+ case 0:
+ break;
+ case 1:
+ OHedgehog::func_8008311C(objectIndex, arg1);
+ break;
+ case 2:
+ func_80072D3C(objectIndex, 0, 1, 4, -1);
+ break;
+ }
+ if (gObjectList[objectIndex].textureListIndex == 0) {
+ Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(common_vtx_hedgehog);
+ gObjectList[objectIndex].vertex = vtx;
+ } else {
+ Vtx* vtx = (Vtx*) LOAD_ASSET_RAW(D_0D006130);
+ gObjectList[objectIndex].vertex = vtx;
+ }
+}
+
+void OHedgehog::func_80083474(s32 objectIndex) {
+ if (gObjectList[objectIndex].state >= 2) {
+ func_80089F24(objectIndex);
+ }
+}
diff --git a/src/engine/objects/Hedgehog.h b/src/engine/objects/Hedgehog.h
new file mode 100644
index 000000000..dab8cf15a
--- /dev/null
+++ b/src/engine/objects/Hedgehog.h
@@ -0,0 +1,53 @@
+#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"
+}
+
+/**
+ * @arg pos FVector xyz spawn position
+ * @arg patrolPoint FVector2D xz patrol to location. Actor automatically calculates the Y value
+ * @arg unk unknown. Likely actor type.
+ */
+class OHedgehog : public OObject {
+public:
+ explicit OHedgehog(const FVector& pos, const FVector2D& patrolPoint, s16 unk);
+
+ ~OHedgehog() {
+ _count--;
+ }
+
+ static size_t GetCount() {
+ return _count;
+ }
+
+ virtual void Tick() override;
+ virtual void Draw(s32 cameraId) override;
+
+ void func_800555BC(s32 objectIndex, s32 cameraId);
+ void func_8004A870(s32 objectIndex, f32 arg1);
+
+ void func_8008311C(s32 objectIndex, s32 arg1);
+ void func_80083248(s32 objectIndex);
+ void func_800833D0(s32 objectIndex, s32 arg1);
+ void func_80083474(s32 objectIndex);
+
+
+private:
+ FVector _pos;
+ static size_t _count;
+ size_t _idx;
+};
diff --git a/src/engine/objects/Seagull.cpp b/src/engine/objects/Seagull.cpp
index b641ab5b4..5f0b12a7e 100644
--- a/src/engine/objects/Seagull.cpp
+++ b/src/engine/objects/Seagull.cpp
@@ -124,11 +124,27 @@ void OSeagull::Draw(Camera* camera) { // render_object_seagulls
_toggle = true;
//}
//if (is_obj_flag_status_active(var_s1, VISIBLE) != 0) {
- func_800552BC(var_s1);
+ OSeagull::func_800552BC(var_s1);
//}
//}
}
+void OSeagull::func_800552BC(s32 objectIndex) {
+ if (gObjectList[objectIndex].state >= 2) {
+ rsp_set_matrix_transformation(gObjectList[objectIndex].pos, gObjectList[objectIndex].direction_angle,
+ gObjectList[objectIndex].sizeScaling);
+ gSPDisplayList(gDisplayListHead++, (Gfx*)D_0D0077D0);
+ if (gIsGamePaused == 0) {
+ gObjectList[objectIndex].unk_0A2 = render_animated_model((Armature*) gObjectList[objectIndex].model,
+ (Animation**) gObjectList[objectIndex].vertex, 0,
+ gObjectList[objectIndex].unk_0A2);
+ } else {
+ render_animated_model((Armature*) gObjectList[objectIndex].model,
+ (Animation**) gObjectList[objectIndex].vertex, 0, gObjectList[objectIndex].unk_0A2);
+ }
+ }
+}
+
void OSeagull::func_8008275C(s32 objectIndex) {
UNUSED s32 stackPadding;
switch (gObjectList[objectIndex].unk_0DD) {
diff --git a/src/engine/objects/Seagull.h b/src/engine/objects/Seagull.h
index 798d25f8d..528da0708 100644
--- a/src/engine/objects/Seagull.h
+++ b/src/engine/objects/Seagull.h
@@ -26,6 +26,7 @@ public:
virtual void Tick() override;
virtual void Draw(Camera*) override;
+ void func_800552BC(s32 objectIndex);
void func_8008275C(s32 objectIndex);
void func_8008241C(s32 objectIndex, s32 arg1);
diff --git a/src/engine/objects/Snowman.cpp b/src/engine/objects/Snowman.cpp
index 93286845f..c05f464ef 100644
--- a/src/engine/objects/Snowman.cpp
+++ b/src/engine/objects/Snowman.cpp
@@ -17,8 +17,8 @@ static const char* sSnowmanHeadList[] = { d_course_frappe_snowland_snowman_head
size_t OSnowman::_count = 0;
OSnowman::OSnowman(const FVector& pos) {
- _pos = pos;
_idx = _count;
+ _pos = pos;
s32 objectId = indexObjectList2[_idx];
init_object(objectId, 0);
@@ -106,7 +106,7 @@ void OSnowman::func_800836F0(Vec3f pos) {
if (objectIndex == NULL_OBJECT_ID) {
break;
}
- func_80083538(objectIndex, pos, i, D_8018D3BC);
+ OSnowman::func_80083538(objectIndex, pos, i, D_8018D3BC);
}
}
@@ -297,4 +297,47 @@ void OSnowman::func_80083B0C(s32 objectIndex) {
gObjectList[objectIndex].boundingBoxSize = 2;
gObjectList[objectIndex].unk_034 = 1.5f;
set_object_flag(objectIndex, 0x04000210);
-} \ No newline at end of file
+}
+
+
+void OSnowman::func_80083538(s32 objectIndex, Vec3f arg1, s32 arg2, s32 arg3) {
+ Object* object;
+
+ init_object(objectIndex, 0);
+ object = &gObjectList[objectIndex];
+ object->activeTexture = (const char*)d_course_frappe_snowland_snow;
+ object->textureList = (const char**)d_course_frappe_snowland_snow;
+ object->activeTLUT = d_course_frappe_snowland_snow_tlut;
+ object->tlutList = (u8*)d_course_frappe_snowland_snow_tlut;
+ object->sizeScaling = random_int(0x0064U);
+ object->sizeScaling = (object->sizeScaling * 0.001) + 0.05;
+ object->velocity[1] = random_int(0x0014U);
+ object->velocity[1] = (object->velocity[1] * 0.5) + 2.6;
+ object->unk_034 = random_int(0x000AU);
+ object->unk_034 = (object->unk_034 * 0.1) + 4.5;
+ object->direction_angle[1] = (arg2 << 0x10) / arg3;
+ object->origin_pos[0] = arg1[0];
+ object->origin_pos[1] = arg1[1];
+ object->origin_pos[2] = arg1[2];
+ object->primAlpha = random_int(0x4000U) + 0x1000;
+}
+
+void OSnowman::func_8008379C(s32 objectIndex) {
+ switch (gObjectList[objectIndex].state) {
+ case 0:
+ break;
+ case 1:
+ if (func_80087E08(objectIndex, gObjectList[objectIndex].velocity[1], 0.74f,
+ gObjectList[objectIndex].unk_034, gObjectList[objectIndex].direction_angle[1],
+ 0x00000064) != 0) {
+ object_next_state(objectIndex);
+ }
+ break;
+ case 2:
+ func_80086F60(objectIndex);
+ func_80072428(objectIndex);
+ break;
+ }
+ object_calculate_new_pos_offset(objectIndex);
+ gObjectList[objectIndex].orientation[2] += gObjectList[objectIndex].primAlpha;
+}
diff --git a/src/engine/objects/Snowman.h b/src/engine/objects/Snowman.h
index cd2c09244..e3e2a0138 100644
--- a/src/engine/objects/Snowman.h
+++ b/src/engine/objects/Snowman.h
@@ -43,6 +43,8 @@ public:
void func_80083BE4(s32);
void func_800836F0(Vec3f);
bool func_80073D0C(s32 objectIndex, s16* arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6);
+ void func_80083538(s32 objectIndex, Vec3f arg1, s32 arg2, s32 arg3);
+ void func_8008379C(s32 objectIndex);
private: