summaryrefslogtreecommitdiff
path: root/src/engine/objects/TrashBin.cpp
diff options
context:
space:
mode:
authorMegaMech <7255464+MegaMech@users.noreply.github.com>2024-12-30 20:39:14 -0700
committerMegaMech <7255464+MegaMech@users.noreply.github.com>2024-12-30 20:39:14 -0700
commit41fb92b7b989290947d8f39c442219afe12d0215 (patch)
treeabc168e4d9e1a7d225744a531e1819c7c0229234 /src/engine/objects/TrashBin.cpp
parent135b51ea719c6107663d9f54cc3e8cb7404dbda3 (diff)
Impl trashbin
Diffstat (limited to 'src/engine/objects/TrashBin.cpp')
-rw-r--r--src/engine/objects/TrashBin.cpp132
1 files changed, 119 insertions, 13 deletions
diff --git a/src/engine/objects/TrashBin.cpp b/src/engine/objects/TrashBin.cpp
index 8a090be5d..43d43b1fc 100644
--- a/src/engine/objects/TrashBin.cpp
+++ b/src/engine/objects/TrashBin.cpp
@@ -1,7 +1,11 @@
+#include <libultraship.h>
+#include <libultra/gbi.h>
#include "TrashBin.h"
#include "World.h"
+#include "port/Game.h"
extern "C" {
+#include "main.h"
#include "code_800029B0.h"
#include "render_objects.h"
#include "update_objects.h"
@@ -16,27 +20,29 @@ extern "C" {
#define DEGREES_FLOAT_TO_SHORT(Degrees) ((s16)((Degrees) * (0x8000 / 180.0f)))
-OTrashBin::OTrashBin(const FVector& pos, const FRotation& rotation, f32 scale) {
+OTrashBin::OTrashBin(const FVector& pos, const FRotation& rotation, f32 scale, OTrashBin::Behaviour bhv) {
_pos = pos;
_rot = rotation;
_scale = scale;
+ _bhv = bhv;
- // if (gIsMirrorMode != 0) {
- // gObjectList[objectIndex].pos[0] = 1765.0f;
- // gObjectList[objectIndex].pos[2] = 195.0f;
- // gObjectList[objectIndex].orientation[1] = (s16) rotation.y;
- // } else {
- // gObjectList[objectIndex].pos[0] = -1765.0f;
- // gObjectList[objectIndex].pos[2] = 70.0f;
- // }
+ init_object(indexObjectList1[1], 0);
+ if (GetCourse() != GetBansheeBoardwalk()) {
+ _drawBin = true;
+ }
}
void OTrashBin::Tick() {
s32 objectIndex = indexObjectList1[1];
OTrashBin::func_8007E00C(objectIndex);
- if (gModeSelection != TIME_TRIALS) {
- func_8007DDC0(objectIndex);
+
+ switch(_bhv) {
+ case STATIC:
+ break;
+ case MUNCHING:
+ func_8007DDC0(objectIndex);
+ break;
}
}
@@ -51,11 +57,22 @@ void OTrashBin::Draw(s32 cameraId) {
if (object->state >= 2) {
func_80043220(object->pos, object->orientation, object->sizeScaling, object->model);
}
+
+ if (_drawBin) {
+ Mat4 mtx;
+ Vec3f Pos = { _pos.x + 63, _pos.y + 12, _pos.z + 25 };
+ Vec3s Rot = { 0, 0x4000, 0 };
+ mtxf_pos_rotation_xyz(mtx, Pos, Rot);
+ //mtxf_scale(mtx, 1.0f);
+ if (render_set_position(mtx, 0) != 0) {
+ gSPDisplayList(gDisplayListHead++, BinMod);
+ }
+ }
}
}
void OTrashBin::init_bb_trash_bin(s32 objectIndex) {
- gObjectList[objectIndex].sizeScaling = _scale;
+ gObjectList[objectIndex].sizeScaling = 1.0f;
gObjectList[objectIndex].model = (Gfx*)d_course_banshee_boardwalk_dl_trash_bin;
gObjectList[objectIndex].unk_04C = 0;
gObjectList[objectIndex].unk_084[7] = 0;
@@ -64,7 +81,15 @@ void OTrashBin::init_bb_trash_bin(s32 objectIndex) {
gObjectList[objectIndex].orientation[1] = DEGREES_FLOAT_TO_SHORT(_rot.yaw);
gObjectList[objectIndex].orientation[2] = DEGREES_FLOAT_TO_SHORT(_rot.roll);
gObjectList[objectIndex].pos[0] = _pos.x;
- gObjectList[objectIndex].pos[1] = _pos.y;
+ if (_drawBin) {
+ // Position the lid on-top of the box.
+ // This might not be the best fix, but this allows the box to be placed on a surface
+ // when spawned at 0,0,0
+ gObjectList[objectIndex].pos[0] = _pos.y + 32.0f;
+ } else {
+ // Stock implementation for banshee boardwalk
+ gObjectList[objectIndex].pos[1] = _pos.y;
+ }
gObjectList[objectIndex].pos[2] = _pos.z;
set_obj_velocity(objectIndex, 0.0f, 0.0f, 0.0f);
gObjectList[objectIndex].type = 0;
@@ -123,3 +148,84 @@ void OTrashBin::func_8007E00C(s32 objectIndex) {
break;
}
}
+
+Gfx OTrashBin::BinMod[] =
+{
+ gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
+ gsDPTileSync(),
+ gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, 5, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 5, G_TX_NOLOD),
+ gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, 0x007C, 0x007C),
+ gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gTexture651B20),
+ gsDPTileSync(),
+ gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD),
+ gsDPLoadSync(),
+ gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 1023, 256),
+ gsSPVertex(BinVtx, 20, 0),
+ gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0),
+ gsSP2Triangles(4, 5, 6, 0, 4, 6, 7, 0),
+ gsSP2Triangles(8, 9, 10, 0, 8, 10, 11, 0),
+ gsSP2Triangles(12, 13, 14, 0, 12, 14, 15, 0),
+ gsSP2Triangles(16, 17, 18, 0, 16, 18, 19, 0),
+ gsSPVertex(BinVtx2, 20, 0),
+ gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0),
+ gsSP2Triangles(4, 5, 6, 0, 4, 6, 7, 0),
+ gsSP2Triangles(8, 9, 10, 0, 8, 10, 11, 0),
+ gsSP2Triangles(12, 13, 14, 0, 12, 14, 15, 0),
+ gsSP2Triangles(16, 17, 18, 0, 16, 18, 19, 0),
+ gsDPPipeSync(),
+ gsDPSetCombineLERP(0, 0, 0, SHADE, 0, 0, 0, ENVIRONMENT, 0, 0, 0, SHADE, 0, 0, 0, ENVIRONMENT),
+ gsSPTexture(65535, 65535, 0, 0, 0),
+ gsSPEndDisplayList(),
+};
+
+
+
+
+
+
+
+Vtx OTrashBin::BinVtx[20] = {
+ {{ {25, -13, 62}, 0, {0, -2303}, {255, 255, 255, 0} }},
+ {{ {-25, -13, 62}, 0, {1280, -2303}, {255, 255, 255, 0} }},
+ {{ {-25, -13, -63}, 0, {1280, 896}, {255, 255, 255, 0} }},
+ {{ {25, -13, -63}, 0, {0, 895}, {255, 255, 255, 0} }},
+ {{ {25, -13, -63}, 0, {0, 1113}, {255, 255, 255, 0} }},
+ {{ {25, 20, -63}, 0, {0, 256}, {255, 255, 255, 0} }},
+ {{ {25, 20, 62}, 0, {3199, 256}, {255, 255, 255, 0} }},
+ {{ {25, -13, 62}, 0, {3199, 1113}, {255, 255, 255, 0} }},
+ {{ {-25, -13, -63}, 0, {0, 1113}, {255, 255, 255, 0} }},
+ {{ {-25, 20, -63}, 0, {0, 255}, {255, 255, 255, 0} }},
+ {{ {25, 20, -63}, 0, {1280, 255}, {255, 255, 255, 0} }},
+ {{ {25, -13, -63}, 0, {1280, 1113}, {255, 255, 255, 0} }},
+ {{ {-25, -13, 62}, 0, {0, 1113}, {255, 255, 255, 0} }},
+ {{ {-25, 20, 62}, 0, {0, 255}, {255, 255, 255, 0} }},
+ {{ {-25, 20, -63}, 0, {3200, 255}, {255, 255, 255, 0} }},
+ {{ {-25, -13, -63}, 0, {3200, 1113}, {255, 255, 255, 0} }},
+ {{ {25, -13, 62}, 0, {0, 1113}, {255, 255, 255, 0} }},
+ {{ {25, 20, 62}, 0, {0, 256}, {255, 255, 255, 0} }},
+ {{ {-25, 20, 62}, 0, {1279, 256}, {255, 255, 255, 0} }},
+ {{ {-25, -13, 62}, 0, {1279, 1113}, {255, 255, 255, 0} }},
+};
+
+Vtx OTrashBin::BinVtx2[20] = {
+ {{ {19, -8, 52}, 0, {3199, 1113}, {255, 255, 255, 0} }},
+ {{ {25, 20, 62}, 0, {3199, 256}, {255, 255, 255, 0} }},
+ {{ {25, 20, -63}, 0, {0, 256}, {255, 255, 255, 0} }},
+ {{ {19, -8, -52}, 0, {0, 1113}, {255, 255, 255, 0} }},
+ {{ {19, -8, -52}, 0, {1280, 1113}, {255, 255, 255, 0} }},
+ {{ {25, 20, -63}, 0, {1280, 255}, {255, 255, 255, 0} }},
+ {{ {-25, 20, -63}, 0, {0, 255}, {255, 255, 255, 0} }},
+ {{ {-19, -8, -52}, 0, {0, 1113}, {255, 255, 255, 0} }},
+ {{ {-19, -8, 52}, 0, {1279, 1113}, {255, 255, 255, 0} }},
+ {{ {-25, 20, 62}, 0, {1279, 256}, {255, 255, 255, 0} }},
+ {{ {25, 20, 62}, 0, {0, 256}, {255, 255, 255, 0} }},
+ {{ {19, -8, 52}, 0, {0, 1113}, {255, 255, 255, 0} }},
+ {{ {19, -8, -52}, 0, {0, 895}, {255, 255, 255, 0} }},
+ {{ {-19, -8, -52}, 0, {1280, 896}, {255, 255, 255, 0} }},
+ {{ {-19, -8, 52}, 0, {1280, -2303}, {255, 255, 255, 0} }},
+ {{ {19, -8, 52}, 0, {0, -2303}, {255, 255, 255, 0} }},
+ {{ {-19, -8, -52}, 0, {3200, 1113}, {255, 255, 255, 0} }},
+ {{ {-25, 20, -63}, 0, {3200, 255}, {255, 255, 255, 0} }},
+ {{ {-25, 20, 62}, 0, {0, 255}, {255, 255, 255, 0} }},
+ {{ {-19, -8, 52}, 0, {0, 1113}, {255, 255, 255, 0} }},
+};