summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-08-30 22:40:32 +0200
committerTreeki <treeki@gmail.com>2012-08-30 22:40:32 +0200
commit8d0328b0531a5470b9716e7ac8395f2d6f7e341a (patch)
tree842cae41d073be54deafdbf08552ea4a2ea64215
parent2b5bc0f0397e50b7cad585196e403c99d27b6207 (diff)
downloadkamek-8d0328b0531a5470b9716e7ac8395f2d6f7e341a.tar.gz
kamek-8d0328b0531a5470b9716e7ac8395f2d6f7e341a.zip
bone piece thing
-rw-r--r--NewerProjectKP.yaml1
-rw-r--r--bonepiece.yaml16
-rw-r--r--src/bonepiece.cpp104
3 files changed, 121 insertions, 0 deletions
diff --git a/NewerProjectKP.yaml b/NewerProjectKP.yaml
index f099f40..59c03fd 100644
--- a/NewerProjectKP.yaml
+++ b/NewerProjectKP.yaml
@@ -3,6 +3,7 @@ code_address: 0x808D9000
modules:
- processed/prolog.yaml
- processed/magicplatform.yaml
+ - processed/bonepiece.yaml
- processed/bugfixes.yaml
- processed/koopatlas.yaml
- processed/levelnames.yaml
diff --git a/bonepiece.yaml b/bonepiece.yaml
new file mode 100644
index 0000000..885b461
--- /dev/null
+++ b/bonepiece.yaml
@@ -0,0 +1,16 @@
+---
+# replaces WM_BOSS_IGGY
+source_files: [../src/bonepiece.cpp]
+hooks:
+ - name: BuildBonePiece
+ type: add_func_pointer
+ src_addr_pal: 0x80986B48
+ target_func: 'daBonePiece_c::build(void)'
+
+ - name: UpdateBonePieceSpriteInfo
+ type: patch
+ addr_pal: 0x8030A610
+ # -ID- ---- -X Offs- -Y Offs- -RectX1- -RectY1- -RectX2- -RectY2- -1C- -1E- -20- -22- Flag ----
+ # Orig 02EB 0000 00000000 00000000 00000000 00000000 00000000 00000000 0000 0000 0000 0000 0000 0000
+ data: '0289 0000 00000000 00000000 00000000 00000000 00000100 00000100 0000 0000 0000 0000 0002 0000'
+
diff --git a/src/bonepiece.cpp b/src/bonepiece.cpp
new file mode 100644
index 0000000..57e862e
--- /dev/null
+++ b/src/bonepiece.cpp
@@ -0,0 +1,104 @@
+#include <game.h>
+
+class daBonePiece_c : public dStageActor_c {
+ public:
+ static daBonePiece_c *build();
+
+ int onCreate();
+ int onExecute();
+ int onDraw();
+ int onDelete();
+
+ StandOnTopCollider collider;
+
+ nw4r::g3d::ResFile resFile;
+ mHeapAllocator_c allocator;
+ m3d::mdl_c model;
+};
+
+/*****************************************************************************/
+// Glue Code
+daBonePiece_c *daBonePiece_c::build() {
+ void *buffer = AllocFromGameHeap1(sizeof(daBonePiece_c));
+ daBonePiece_c *c = new(buffer) daBonePiece_c;
+ return c;
+}
+
+int daBonePiece_c::onCreate() {
+ // load the model
+ allocator.link(-1, GameHeaps[0], 0, 0x20);
+
+ resFile.data = getResource("lift_torokko", "g3d/t00.brres");
+
+ static char thing[] = "lift_torokko?";
+ thing[0xC] = 'A' + (settings & 3);
+
+ nw4r::g3d::ResMdl resmdl = resFile.GetResMdl(thing);
+ model.setup(resmdl, &allocator, 0, 1, 0);
+ SetupTextures_MapObj(&model, 0);
+
+ allocator.unlink();
+
+ // if rotation is off, do nothing else
+ if ((settings >> 28) & 1) {
+ // OK, figure out the rotation
+ u8 sourceRotation = (settings >> 24) & 0xF;
+
+ // 0 is up. -0x4000 is right, 0x4000 is left ...
+ s16 rotation;
+
+ // We'll flip it later.
+ // Thus: 0..7 rotates left (in increments of 0x800),
+ // 8..15 rotates right (in increments of 0x800 too).
+ // To specify facing up, well.. just use 0.
+
+ if (sourceRotation < 8)
+ rotation = (sourceRotation * 0x800) - 0x4000;
+ else
+ rotation = (sourceRotation * 0x800) - 0x3800;
+
+ rotation = -rotation;
+
+ rot.z = rotation;
+ }
+
+ collider.init(this,
+ /*xOffset=*/0.0f, /*yOffset=*/0.0f,
+ /*topYOffset=*/0,
+ /*rightSize=*/16.0f, /*leftSize=*/-16.0f,
+ /*rotation=*/rot.z, /*_45=*/1
+ );
+
+ collider._47 = 0xA;
+ collider.flags = 0x80180 | 0xC00;
+
+ collider.addToList();
+
+ return true;
+}
+
+int daBonePiece_c::onDelete() {
+ return true;
+}
+
+int daBonePiece_c::onExecute() {
+ matrix.translation(pos.x, pos.y - 8.0f, pos.z);
+ matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z);
+
+ model.setDrawMatrix(matrix);
+ model.setScale(&scale);
+ model.calcWorld(false);
+
+ collider.update();
+
+ return true;
+}
+
+int daBonePiece_c::onDraw() {
+ model.scheduleForDrawing();
+
+ return true;
+}
+
+
+