From 2dc6dc90e21d12186bb1a88b81fd8f74baea4fbe Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 28 Aug 2012 04:44:49 +0200 Subject: hammer suit model --- kamek_pal.x | 2 ++ poweruphax.yaml | 35 +++++++++++++++++++++ src/koopatlas/player.cpp | 3 ++ src/koopatlas/player.h | 2 ++ src/poweruphax.S | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ src/poweruphax.cpp | 65 ++++++++++++++++++++++++++++++++++++++ src/poweruphax.h | 23 ++++++++++++++ 7 files changed, 212 insertions(+) create mode 100644 src/poweruphax.h diff --git a/kamek_pal.x b/kamek_pal.x index 9443a41..c1194c9 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -2,6 +2,8 @@ SECTIONS { /* Scrolling is annoying, clown car goes here! */ + RealAcPyDtor = 0x80144820; + __ct__20daJrClownForPlayer_cFv = 0x80810480; __dt__20daJrClownForPlayer_cFv = 0x80810540; /* Beans indeed. */ diff --git a/poweruphax.yaml b/poweruphax.yaml index 08c000b..f6b6102 100644 --- a/poweruphax.yaml +++ b/poweruphax.yaml @@ -159,6 +159,10 @@ hooks: type: add_func_pointer src_addr_pal: 0x80AF1000 target_func: 'I_hammerModelName' + + - name: DisableHat99Thing + type: nop_insn + area_pal: 0x80089D48 - name: LetPlayerGetHammerItem type: branch_insn @@ -608,3 +612,34 @@ hooks: type: add_func_pointer target_func: 'ReturnNone' src_addr_pal: 0x80B81468 + + + + - name: BiggerAcPy + type: patch + addr_pal: 0x801443C8 + data: '3860 2D0C' + + - name: AcPyCtorHS + type: branch_insn + target_func: 'AcPyCtorHS' + src_addr_pal: 0x801447D4 + branch_type: b + + - name: AcPyDtorReplace + type: add_func_pointer + target_func: 'AcPyDtorHS' + src_addr_pal: 0x803257B0 + + - name: AcPySetMeUpHS + type: branch_insn + target_func: 'AcPySetMeUpHS' + src_addr_pal: 0x8014516C + branch_type: b + + - name: AcPyDrawHS + type: branch_insn + target_func: 'AcPyDrawHS' + src_addr_pal: 0x80145BE0 + branch_type: b + diff --git a/src/koopatlas/player.cpp b/src/koopatlas/player.cpp index 5531301..51470da 100644 --- a/src/koopatlas/player.cpp +++ b/src/koopatlas/player.cpp @@ -11,6 +11,8 @@ int daWMPlayer_c::onCreate() { this->modelHandler->setSRT((Vec){0.0,100.0,-100.0}, (S16Vec){0,0,0}, (Vec){2.0,2.0,2.0}); this->modelHandler->draw(); + hammerSuit.setup(this->modelHandler); + pos = (Vec){0.0f,0.0f,3000.0f}; rot = (S16Vec){0,0,0}; scale = (Vec){1.6f,1.6f,1.6f}; @@ -61,6 +63,7 @@ int daWMPlayer_c::onExecute() { int daWMPlayer_c::onDraw() { this->modelHandler->draw(); + hammerSuit.draw(); return true; } diff --git a/src/koopatlas/player.h b/src/koopatlas/player.h index 6e98e4e..6fbbf5a 100644 --- a/src/koopatlas/player.h +++ b/src/koopatlas/player.h @@ -2,6 +2,7 @@ #define __KOOPATLAS_PLAYER_H #include "koopatlas/core.h" +#include "poweruphax.h" enum PlayerAnim { wait = 0, @@ -211,6 +212,7 @@ class daWMPlayer_c : public dActor_c { float jumpOffset; mEf::es2 effect; + dHammerSuitRenderer_c hammerSuit; void startAnimation(int id, float frame, float unk, float updateRate); diff --git a/src/poweruphax.S b/src/poweruphax.S index 899b5e4..34cca4b 100644 --- a/src/poweruphax.S +++ b/src/poweruphax.S @@ -647,6 +647,88 @@ CheckExistingPowerup: +.global AcPyCtorHS +AcPyCtorHS: + stwu r1, -0x10(r1) + mflr r0 + stw r0, 0x14(r1) + stw r31, 0xC(r1) + mr r31, r3 + + bl build__21dHammerSuitRenderer_cFv + stw r3, 0x2D08(r31) + + mr r3, r31 + lwz r31, 0xC(r1) + lwz r0, 0x14(r1) + mtlr r0 + addi r1, r1, 0x10 + blr + +.global AcPyDtorHS +AcPyDtorHS: + stwu r1, -0x10(r1) + mflr r0 + stw r0, 0x14(r1) + stw r31, 0xC(r1) + stw r30, 8(r1) + + mr r31, r4 + mr r30, r3 + + cmpwi r3, 0 + beq oops + lwz r3, 0x2D08(r30) + li r4, 1 + bl __dt__21dHammerSuitRenderer_cFv +oops: + + mr r3, r30 + mr r4, r31 + bl RealAcPyDtor + + lwz r30, 8(r1) + lwz r31, 0xC(r1) + lwz r0, 0x14(r1) + mtlr r0 + addi r1, r1, 0x10 + blr + +.global AcPySetMeUpHS +AcPySetMeUpHS: + # partway in: r31 = this + lwz r3, 0x2D08(r31) + addi r4, r31, 0x2A60 + bl setup__21dHammerSuitRenderer_cFP21dPlayerModelHandler_c + + # epilogue + li r3, 1 + lwz r31, 0xC(r1) + lwz r0, 0x14(r1) + mtlr r0 + addi r1, r1, 0x10 + blr + +.global AcPyDrawHS +AcPyDrawHS: + # partway in: r31 = this + lwz r3, 0x2D08(r31) + bl draw__21dHammerSuitRenderer_cFv + + # epilogue + li r3, 1 + lwz r0, 0x14(r1) + lwz r31, 0xC(r1) + mtlr r0 + addi r1, r1, 0x10 + blr + +.extern RealAcPyDtor +.extern build__21dHammerSuitRenderer_cFv +.extern __dt__21dHammerSuitRenderer_cFv +.extern setup__21dHammerSuitRenderer_cFP21dPlayerModelHandler_c +.extern draw__21dHammerSuitRenderer_cFv + .data PowerupSounds: diff --git a/src/poweruphax.cpp b/src/poweruphax.cpp index 787e88f..91481af 100644 --- a/src/poweruphax.cpp +++ b/src/poweruphax.cpp @@ -1,5 +1,6 @@ #include #include +#include void ThwompHammer(dEn_c *thwomp, ActivePhysics *apThis, ActivePhysics *apOther) { @@ -19,3 +20,67 @@ void BooHammer(dEn_c *boo, ActivePhysics *apThis, ActivePhysics *apOther) { void UrchinHammer(dEn_c *urchin, ActivePhysics *apThis, ActivePhysics *apOther) { return; } + + +#include "poweruphax.h" + +void SetCullModeForMaterial(m3d::mdl_c *model, int materialID, GXCullMode mode); + + +dHammerSuitRenderer_c *dHammerSuitRenderer_c::build() { + return new dHammerSuitRenderer_c; +} + +dHammerSuitRenderer_c::dHammerSuitRenderer_c() { } +dHammerSuitRenderer_c::~dHammerSuitRenderer_c() { } + +void dHammerSuitRenderer_c::setup(dPlayerModelHandler_c *handler) { + victim = (dPlayerModel_c*)handler->mdlClass; + + allocator.link(-1, GameHeaps[0], 0, 0x20); + + nw4r::g3d::ResFile rf(getResource("hammerM", "g3d/suit.brres")); + + helmet.setup(rf.GetResMdl("helmet"), &allocator, 0, 1, 0); + SetupTextures_MapObj(&helmet, 0); + + shell.setup(rf.GetResMdl("shell"), &allocator, 0, 1, 0); + SetupTextures_MapObj(&shell, 0); + + allocator.unlink(); + + + victimModel = &victim->models[0].body; + nw4r::g3d::ResMdl *playerResMdl = + (nw4r::g3d::ResMdl*)(((u32)victimModel->scnObj) + 0xE8); + + //headNodeID = playerResMdl->GetResNode("player_head").GetID(); + headNodeID = playerResMdl->GetResNode("face_1").GetID(); + rootNodeID = playerResMdl->GetResNode("skl_root").GetID(); +} + +void dHammerSuitRenderer_c::draw() { + if (victim->powerup_id != 7) + return; + + // Materials: 2=hair 3=hat; Modes: BACK=visible ALL=invisible + SetCullModeForMaterial(&victim->getCurrentModel()->head, 3, GX_CULL_ALL); + + Mtx headMtx; + victimModel->getMatrixForNode(headNodeID, headMtx); + + helmet.setDrawMatrix(headMtx); + helmet.setScale(1.0f, 1.0f, 1.0f); + helmet.calcWorld(false); + + Mtx rootMtx; + victimModel->getMatrixForNode(rootNodeID, rootMtx); + + shell.setDrawMatrix(rootMtx); + shell.setScale(1.0f, 1.0f, 1.0f); + shell.calcWorld(false); + + helmet.scheduleForDrawing(); + shell.scheduleForDrawing(); +} + diff --git a/src/poweruphax.h b/src/poweruphax.h new file mode 100644 index 0000000..3736987 --- /dev/null +++ b/src/poweruphax.h @@ -0,0 +1,23 @@ +#ifndef POWERUPHAX_H +#define POWERUPHAX_H + +class dHammerSuitRenderer_c { + public: + mHeapAllocator_c allocator; + + m3d::mdl_c helmet, shell; + + m3d::mdl_c *victimModel; + u32 headNodeID, rootNodeID; + + dPlayerModel_c *victim; + + dHammerSuitRenderer_c(); + ~dHammerSuitRenderer_c(); + void setup(dPlayerModelHandler_c *handler); + void draw(); + + static dHammerSuitRenderer_c *build(); +}; + +#endif /* POWERUPHAX_H */ -- cgit v1.2.3