d_a_obj_tower_gearD101 with one regswap

This commit is contained in:
robojumper 2024-11-14 16:51:38 +01:00
parent cbb409cf6c
commit 53c9b7062e
7 changed files with 268 additions and 32 deletions

View File

@ -17,3 +17,6 @@ REL/global_destructor_chain.c:
REL/d/a/obj/d_a_obj_tower_gearD101.cpp:
.text start:0x000000F0 end:0x00000F28
.ctors start:0x00000000 end:0x00000004
.rodata start:0x00000000 end:0x00000028
.data start:0x00000000 end:0x000001F4
.bss start:0x00000008 end:0x00000048

View File

@ -8,21 +8,21 @@ __dt__32sFState_c<19dAcOTowerGearD101_c>Fv = .text:0x00000220; // type:function
__dt__35sFStateFct_c<19dAcOTowerGearD101_c>Fv = .text:0x00000280; // type:function size:0x6C
__dt__88sStateMgr_c<19dAcOTowerGearD101_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000002F0; // type:function size:0xA0
__dt__58sFStateMgr_c<19dAcOTowerGearD101_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000390; // type:function size:0xA4
fn_505_440 = .text:0x00000440; // type:function size:0x58
fn_505_4A0 = .text:0x000004A0; // type:function size:0xC8
fn_505_570 = .text:0x00000570; // type:function size:0x1B0
__dt__28dAcOTowerGearD101_callback_cFv = .text:0x00000440; // type:function size:0x58
createHeap__19dAcOTowerGearD101_cFv = .text:0x000004A0; // type:function size:0xC8
actorCreate__19dAcOTowerGearD101_cFv = .text:0x00000570; // type:function size:0x1B0
changeState__88sStateMgr_c<19dAcOTowerGearD101_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000720; // type:function size:0x10
fn_505_730 = .text:0x00000730; // type:function size:0x54
fn_505_790 = .text:0x00000790; // type:function size:0x8
fn_505_7A0 = .text:0x000007A0; // type:function size:0x30
actorPostCreate__19dAcOTowerGearD101_cFv = .text:0x00000730; // type:function size:0x54
doDelete__19dAcOTowerGearD101_cFv = .text:0x00000790; // type:function size:0x8
actorExecute__19dAcOTowerGearD101_cFv = .text:0x000007A0; // type:function size:0x30
executeState__88sStateMgr_c<19dAcOTowerGearD101_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000007D0; // type:function size:0x10
fn_505_7E0 = .text:0x000007E0; // type:function size:0x28
draw__19dAcOTowerGearD101_cFv = .text:0x000007E0; // type:function size:0x28
initializeState_Wait__19dAcOTowerGearD101_cFv = .text:0x00000810; // type:function size:0x4
executeState_Wait__19dAcOTowerGearD101_cFv = .text:0x00000820; // type:function size:0xDC
finalizeState_Wait__19dAcOTowerGearD101_cFv = .text:0x00000900; // type:function size:0x4
fn_505_910 = .text:0x00000910; // type:function size:0x78
fn_505_990 = .text:0x00000990; // type:function size:0xAC
fn_505_A40 = .text:0x00000A40; // type:function size:0x24
timingB__28dAcOTowerGearD101_callback_cFUlPQ34nw4r3g3d13WorldMtxManipQ34nw4r3g3d6ResMdl = .text:0x00000910; // type:function size:0x78
initTransform__19dAcOTowerGearD101_cFv = .text:0x00000990; // type:function size:0xAC
playVisualEffect__19dAcOTowerGearD101_cFv = .text:0x00000A40; // type:function size:0x24
__dt__19dAcOTowerGearD101_cFv = .text:0x00000A70; // type:function size:0xE8
getStateID__88sStateMgr_c<19dAcOTowerGearD101_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000B60; // type:function size:0x10
build__35sFStateFct_c<19dAcOTowerGearD101_c>FRC12sStateIDIf_c = .text:0x00000B70; // type:function size:0x60
@ -45,20 +45,20 @@ isSameName__34sFStateID_c<19dAcOTowerGearD101_c>CFPCc = .text:0x00000EA0; // typ
_ctors = .ctors:0x00000000; // type:label scope:global
_dtors = .dtors:0x00000000; // type:label scope:global
__destroy_global_chain_reference = .dtors:0x00000000; // type:object size:0x4 scope:global
lbl_505_rodata_0 = .rodata:0x00000000; // type:object size:0x1C data:float
lbl_505_rodata_1C = .rodata:0x0000001C; // type:object size:0x4 data:float
lbl_505_rodata_20 = .rodata:0x00000020; // type:object size:0x8 data:double
lbl_505_rodata_0 = .rodata:0x00000000; // type:object size:0x1C scope:local data:float
lbl_505_rodata_1C = .rodata:0x0000001C; // type:object size:0x4 scope:local data:float
lbl_505_rodata_20 = .rodata:0x00000020; // type:object size:0x8 scope:local data:double
g_profile_OBJ_TOWER_GEAR_D101 = .data:0x00000000; // type:object size:0x10 data:4byte
lbl_505_data_10 = .data:0x00000010; // type:object size:0x10
lbl_505_data_20 = .data:0x00000020; // type:object size:0x8
lbl_505_data_28 = .data:0x00000028; // type:object size:0x28
lbl_505_data_50 = .data:0x00000050; // type:object size:0x80
lbl_505_data_D0 = .data:0x000000D0; // type:object size:0x30
lbl_505_data_100 = .data:0x00000100; // type:object size:0x30
lbl_505_data_130 = .data:0x00000130; // type:object size:0x18
lbl_505_data_148 = .data:0x00000148; // type:object size:0x18
lbl_505_data_160 = .data:0x00000160; // type:object size:0x60
lbl_505_data_1C0 = .data:0x000001C0; // type:object size:0x34
lbl_505_data_10 = .data:0x00000010; // type:object size:0x10 scope:local
lbl_505_data_20 = .data:0x00000020; // type:object size:0x8 scope:local
lbl_505_data_28 = .data:0x00000028; // type:object size:0x28 scope:local
__vt__19dAcOTowerGearD101_c = .data:0x00000050; // type:object size:0x80
__vt__58sFStateMgr_c<19dAcOTowerGearD101_c,20sStateMethodUsr_FI_c> = .data:0x000000D0; // type:object size:0x30
__vt__88sStateMgr_c<19dAcOTowerGearD101_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x00000100; // type:object size:0x30
__vt__35sFStateFct_c<19dAcOTowerGearD101_c> = .data:0x00000130; // type:object size:0x14
__vt__32sFState_c<19dAcOTowerGearD101_c> = .data:0x00000148; // type:object size:0x18
__vt__28dAcOTowerGearD101_callback_c = .data:0x00000160; // type:object size:0x18
__vt__34sFStateID_c<19dAcOTowerGearD101_c> = .data:0x000001C0; // type:object size:0x34
__global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global
lbl_505_bss_8 = .bss:0x00000008; // type:object size:0x10
lbl_505_bss_18 = .bss:0x00000018; // type:object size:0x30 data:4byte
lbl_505_bss_8 = .bss:0x00000008; // type:object size:0x10 scope:local
StateID_Wait__19dAcOTowerGearD101_c = .bss:0x00000018; // type:object size:0x30 data:4byte

View File

@ -966,7 +966,7 @@ fn_80029910 = .text:0x80029910; // type:function size:0x4
fn_80029920 = .text:0x80029920; // type:function size:0x54
fn_80029980 = .text:0x80029980; // type:function size:0x64
fn_800299F0 = .text:0x800299F0; // type:function size:0x20
fn_80029A10 = .text:0x80029A10; // type:function size:0x54
fn_80029A10__13EffectsStructFUsP7mVec3_cP7mAng3_cPvPvPv = .text:0x80029A10; // type:function size:0x54
fn_80029A70 = .text:0x80029A70; // type:function size:0x64
fn_80029AE0 = .text:0x80029AE0; // type:function size:0x20
fn_80029B00 = .text:0x80029B00; // type:function size:0xD8
@ -43822,7 +43822,64 @@ PARTICLE_RESOURCE_ID_MAPPING_555_ = .sdata2:0x8057A806; // type:object size:0x2
PARTICLE_RESOURCE_ID_MAPPING_556_ = .sdata2:0x8057A808; // type:object size:0x2 data:2byte
PARTICLE_RESOURCE_ID_MAPPING_557_ = .sdata2:0x8057A80A; // type:object size:0x2 data:2byte
PARTICLE_RESOURCE_ID_MAPPING_558_ = .sdata2:0x8057A80C; // type:object size:0x2 data:2byte
PARTICLE_RESOURCE_ID_MAPPING_559_ = .sdata2:0x8057A80E; // type:object size:0x74 data:2byte
PARTICLE_RESOURCE_ID_MAPPING_559_ = .sdata2:0x8057A80E; // type:object size:0x2 data:2byte
lbl_8057A810 = .sdata2:0x8057A810; // type:object size:0x2
lbl_8057A812 = .sdata2:0x8057A812; // type:object size:0x2
lbl_8057A814 = .sdata2:0x8057A814; // type:object size:0x2
lbl_8057A816 = .sdata2:0x8057A816; // type:object size:0x2
lbl_8057A818 = .sdata2:0x8057A818; // type:object size:0x2
lbl_8057A81A = .sdata2:0x8057A81A; // type:object size:0x2
lbl_8057A81C = .sdata2:0x8057A81C; // type:object size:0x2
lbl_8057A81E = .sdata2:0x8057A81E; // type:object size:0x2
lbl_8057A820 = .sdata2:0x8057A820; // type:object size:0x2
lbl_8057A822 = .sdata2:0x8057A822; // type:object size:0x2
lbl_8057A824 = .sdata2:0x8057A824; // type:object size:0x2
lbl_8057A826 = .sdata2:0x8057A826; // type:object size:0x2
PARTICLE_RESOURCE_ID_MAPPING_585_ = .sdata2:0x8057A828; // type:object size:0x2 data:2byte
lbl_8057A82A = .sdata2:0x8057A82A; // type:object size:0x2
lbl_8057A82C = .sdata2:0x8057A82C; // type:object size:0x2
lbl_8057A82E = .sdata2:0x8057A82E; // type:object size:0x2
lbl_8057A830 = .sdata2:0x8057A830; // type:object size:0x2
lbl_8057A832 = .sdata2:0x8057A832; // type:object size:0x2
lbl_8057A834 = .sdata2:0x8057A834; // type:object size:0x2
lbl_8057A836 = .sdata2:0x8057A836; // type:object size:0x2
lbl_8057A838 = .sdata2:0x8057A838; // type:object size:0x2
lbl_8057A83A = .sdata2:0x8057A83A; // type:object size:0x2
lbl_8057A83C = .sdata2:0x8057A83C; // type:object size:0x2
lbl_8057A83E = .sdata2:0x8057A83E; // type:object size:0x2
lbl_8057A840 = .sdata2:0x8057A840; // type:object size:0x2
lbl_8057A842 = .sdata2:0x8057A842; // type:object size:0x2
lbl_8057A844 = .sdata2:0x8057A844; // type:object size:0x2
lbl_8057A846 = .sdata2:0x8057A846; // type:object size:0x2
lbl_8057A848 = .sdata2:0x8057A848; // type:object size:0x2
lbl_8057A84A = .sdata2:0x8057A84A; // type:object size:0x2
lbl_8057A84C = .sdata2:0x8057A84C; // type:object size:0x2
lbl_8057A84E = .sdata2:0x8057A84E; // type:object size:0x2
lbl_8057A850 = .sdata2:0x8057A850; // type:object size:0x2
lbl_8057A852 = .sdata2:0x8057A852; // type:object size:0x2
lbl_8057A854 = .sdata2:0x8057A854; // type:object size:0x2
lbl_8057A856 = .sdata2:0x8057A856; // type:object size:0x2
lbl_8057A858 = .sdata2:0x8057A858; // type:object size:0x2
lbl_8057A85A = .sdata2:0x8057A85A; // type:object size:0x2
lbl_8057A85C = .sdata2:0x8057A85C; // type:object size:0x2
lbl_8057A85E = .sdata2:0x8057A85E; // type:object size:0x2
lbl_8057A860 = .sdata2:0x8057A860; // type:object size:0x2
lbl_8057A862 = .sdata2:0x8057A862; // type:object size:0x2
lbl_8057A864 = .sdata2:0x8057A864; // type:object size:0x2
lbl_8057A866 = .sdata2:0x8057A866; // type:object size:0x2
lbl_8057A868 = .sdata2:0x8057A868; // type:object size:0x2
lbl_8057A86A = .sdata2:0x8057A86A; // type:object size:0x2
lbl_8057A86C = .sdata2:0x8057A86C; // type:object size:0x2
lbl_8057A86E = .sdata2:0x8057A86E; // type:object size:0x2
lbl_8057A870 = .sdata2:0x8057A870; // type:object size:0x2
lbl_8057A872 = .sdata2:0x8057A872; // type:object size:0x2
lbl_8057A874 = .sdata2:0x8057A874; // type:object size:0x2
lbl_8057A876 = .sdata2:0x8057A876; // type:object size:0x2
lbl_8057A878 = .sdata2:0x8057A878; // type:object size:0x2
lbl_8057A87A = .sdata2:0x8057A87A; // type:object size:0x2
lbl_8057A87C = .sdata2:0x8057A87C; // type:object size:0x2
lbl_8057A87E = .sdata2:0x8057A87E; // type:object size:0x2
lbl_8057A880 = .sdata2:0x8057A880; // type:object size:0x2
PARTICLE_RESOURCE_ID_MAPPING_617_ = .sdata2:0x8057A882; // type:object size:0x6 data:2byte
PARTICLE_RESOURCE_ID_MAPPING_620_ = .sdata2:0x8057A888; // type:object size:0x2 data:2byte
PARTICLE_RESOURCE_ID_MAPPING_621_ = .sdata2:0x8057A88A; // type:object size:0x2 data:2byte

View File

@ -3,7 +3,6 @@
#include "d/a/obj/d_a_obj_base.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
class dAcOTowerD101_c : public dAcObjBase_c {
public:
@ -14,6 +13,10 @@ public:
private:
/* 0x??? */ STATE_MGR_DECLARE(dAcOTowerD101_c);
u8 field_0x___[0xC64 - 0x36C];
public:
/* 0xC64 */ f32 mGoalElevation;
/* 0xC68 */ f32 mCurrentElevation;
};
#endif

View File

@ -1,19 +1,66 @@
#ifndef D_A_OBJ_TOWER_GEARD101_H
#define D_A_OBJ_TOWER_GEARD101_H
#include "common.h"
#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_mdl.h"
#include "m/m_angle.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
#include "toBeSorted/effects_struct.h"
/**
* A callback implementation that controls the button node in the switch model.
*/
class dAcOTowerGearD101_callback_c : public m3d::callback_c {
public:
dAcOTowerGearD101_callback_c() {}
virtual ~dAcOTowerGearD101_callback_c() {}
virtual void timingB(u32, nw4r::g3d::WorldMtxManip *, nw4r::g3d::ResMdl) override;
/* 0x04 */ u32 mNodeId;
/* 0x08 */ mAng mGearRotation;
void init(u32 nodeId) {
mNodeId = nodeId;
}
};
class dAcOTowerGearD101_c : public dAcObjBase_c {
public:
dAcOTowerGearD101_c() : mStateMgr(*this, sStateID::null) {}
dAcOTowerGearD101_c()
: mStateMgr(*this, sStateID::null), field_0x3A0(mVec3_c::Zero.x, mVec3_c::Zero.y, mVec3_c::Zero.z),
field_0x3AC(mVec3_c::Zero.x, mVec3_c::Zero.y, mVec3_c::Zero.z), field_0x3B8(mAng3_c::Zero) {}
virtual ~dAcOTowerGearD101_c() {}
STATE_FUNC_DECLARE(dAcOTowerGearD101_c, Wait);
virtual bool createHeap() override;
virtual int actorCreate() override;
virtual int actorPostCreate() override;
virtual int doDelete() override;
virtual int actorExecute() override;
virtual int draw() override;
private:
/* 0x??? */ STATE_MGR_DECLARE(dAcOTowerGearD101_c);
void initTransform();
void playVisualEffect();
/* 0x330 */ nw4r::g3d::ResFile mRes;
/* 0x334 */ m3d::mdl_c mMdl;
/* 0x350 */ STATE_MGR_DECLARE(dAcOTowerGearD101_c);
/* 0x394 */ dAcOTowerGearD101_callback_c mMdlCallback;
/* 0x3A0 */ mVec3_c field_0x3A0;
/* 0x3AC */ mVec3_c field_0x3AC;
/* 0x3B8 */ mAng3_c field_0x3B8;
/* 0x3BE */ u8 field_0x3BE[2];
/* 0x3C0 */ mAng mCurrRotation;
/* 0x3C2 */ s16 mPreviousTurnSpeed;
/* 0x3C4 */ mMtx_c field_0x3C4;
/* 0x3F4 */ mVec3_c field_0x3F4;
/* 0x400 */ EffectsStruct mEffects;
};
#endif

View File

@ -3,6 +3,7 @@
#include "common.h"
#include "d/d_base.h"
#include "m/m_angle.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
@ -23,6 +24,7 @@ public:
void remove(bool);
void fn_80029929(u16 effect, mVec3_c *pos, void *, void *, void *, void *);
void fn_80029A10(u16 effect, mVec3_c *pos, mAng3_c *rot, void *, void *, void *);
void setMtx(const mMtx_c &);
bool checkField0x00() const {

View File

@ -1,9 +1,133 @@
#include "d/a/obj/d_a_obj_tower_gearD101.h"
#include "common.h"
#include "d/a/d_a_base.h"
#include "d/a/obj/d_a_obj_tower_D101.h"
#include "d/col/bg/d_bg_s_wtr_chk.h"
#include "f/f_base.h"
#include "f/f_manager.h"
#include "f/f_profile_name.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resmdl.h"
#include "toBeSorted/room_manager.h"
SPECIAL_ACTOR_PROFILE(OBJ_TOWER_GEAR_D101, dAcOTowerGearD101_c, fProfile::OBJ_TOWER_GEAR_D101, 0x17E, 0, 7);
STATE_DEFINE(dAcOTowerGearD101_c, Wait);
extern "C" void fn_80067340(mVec3_c &, nw4r::g3d::ResMdl *, const char *);
bool dAcOTowerGearD101_c::createHeap() {
const char *name = "TowerGearD101";
mRes = getOarcResFile(name);
RoomManager::bindStageResToFile(&mRes);
nw4r::g3d::ResMdl mdl = mRes.GetResMdl(name);
if (!mMdl.create(mdl, &heap_allocator, 0x120, 1, nullptr)) {
return false;
}
fn_80067340(field_0x3A0, &mdl, "model0");
position = field_0x3A0;
position.rotY(rotation.y);
return true;
}
int dAcOTowerGearD101_c::actorCreate() {
if (!initAllocatorWork1Heap(0x1000, "dAcOTowerGearD101_c::m_allocator", 0x20)) {
return FAILED;
}
nw4r::g3d::ResMdl mdl = mMdl.getResMdl();
mMdlCallback.init(mdl.GetResNode("model0").GetID());
mMdl.setCallback(&mMdlCallback);
forwardAccel = 0.0f;
forwardMaxSpeed = 0.0f;
mStateMgr.changeState(StateID_Wait);
mVec3_c s = field_0x3AC;
boundingBox.Set(
mVec3_c(s.x * -200.0f, s.y * -200.0f, s.z * -50.0f), mVec3_c(s.x * 200.0f, s.y * 200.0f, s.z * 50.0f)
);
initTransform();
if (dBgS_WtrChk::CheckPos(&position, true, 500.0f, -500.0f)) {
field_0x3F4 = mVec3_c::Zero;
field_0x3F4.y = dBgS_WtrChk::GetWaterHeight();
} else {
field_0x3F4 = mVec3_c::Zero;
}
mEffects.init(this);
return SUCCEEDED;
}
int dAcOTowerGearD101_c::actorPostCreate() {
fBase_c *ac = fManager_c::searchBaseByProfName(fProfile::OBJ_TOWER_D101, nullptr);
if (ac == nullptr) {
return NOT_READY;
}
setActorRef(static_cast<dAcOTowerD101_c *>(ac));
return SUCCEEDED;
}
int dAcOTowerGearD101_c::doDelete() {
return SUCCEEDED;
}
int dAcOTowerGearD101_c::actorExecute() {
mStateMgr.executeState();
return SUCCEEDED;
}
int dAcOTowerGearD101_c::draw() {
drawModelType1(&mMdl);
return SUCCEEDED;
}
void dAcOTowerGearD101_c::initializeState_Wait() {}
void dAcOTowerGearD101_c::executeState_Wait() {}
void dAcOTowerGearD101_c::executeState_Wait() {
dAcOTowerD101_c *tower = static_cast<dAcOTowerD101_c *>(actor_node.get());
if (tower != nullptr) {
// Regswap prevRotation, newRotation tmp
mAng prevRotation = mCurrRotation;
f32 diff = tower->mGoalElevation - tower->mCurrentElevation;
s32 scale5 = 0x50000;
mAng newRotation = diff * scale5 / 2400.0f;
if (newRotation != prevRotation) {
if (mPreviousTurnSpeed == 0) {
playSound(0xBF8);
} else {
playSoundEffect1(0xBF9);
playVisualEffect();
}
}
s32 turnSpeed = newRotation - prevRotation;
mCurrRotation = newRotation;
mPreviousTurnSpeed = turnSpeed;
mMdlCallback.mGearRotation = newRotation;
}
}
void dAcOTowerGearD101_c::finalizeState_Wait() {}
void dAcOTowerGearD101_callback_c::timingB(u32 nodeId, nw4r::g3d::WorldMtxManip *manip, nw4r::g3d::ResMdl mdl) {
if (nodeId == mNodeId) {
mMtx_c mtx1;
manip->GetMtx(mtx1);
mtx1.ZrotM(mGearRotation);
manip->SetMtx(mtx1);
}
}
void dAcOTowerGearD101_c::initTransform() {
mWorldMtx.transS(mVec3_c::Zero);
mMtx_c mtx1;
mtx1.transS(position);
mWorldMtx += mtx1;
field_0x3C4.transS(mVec3_c::Zero);
field_0x3C4.ZXYrotM(rotation.x, rotation.y, rotation.z);
mMdl.setLocalMtx(field_0x3C4);
}
extern "C" u16 PARTICLE_RESOURCE_ID_MAPPING_585_;
void dAcOTowerGearD101_c::playVisualEffect() {
mEffects.fn_80029A10(PARTICLE_RESOURCE_ID_MAPPING_585_, &field_0x3F4, &rotation, nullptr, nullptr, nullptr);
}