Skip to content

Commit

Permalink
d_a_obj_island_nusi OK (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
robojumper authored Oct 25, 2024
1 parent d466b5b commit 5995604
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 30 deletions.
3 changes: 3 additions & 0 deletions config/SOUE01/rels/d_a_obj_island_nusiNP/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ REL/global_destructor_chain.c:
REL/d/a/obj/d_a_obj_island_nusi.cpp:
.text start:0x000000F0 end:0x00000FC8
.ctors start:0x00000000 end:0x00000004
.rodata start:0x00000000 end:0x0000002C
.data start:0x00000000 end:0x00000248
.bss start:0x00000008 end:0x00000088
44 changes: 22 additions & 22 deletions config/SOUE01/rels/d_a_obj_island_nusiNP/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ __dt__29sFState_c<16dAcOislandNusi_c>Fv = .text:0x000001D0; // type:function siz
__dt__32sFStateFct_c<16dAcOislandNusi_c>Fv = .text:0x00000230; // type:function size:0x6C
__dt__85sStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000002A0; // type:function size:0xA0
__dt__55sFStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000340; // type:function size:0xA4
AcOislandNusi__initModels = .text:0x000003F0; // type:function size:0x15C
AcOislandNusi__init = .text:0x00000550; // type:function size:0x13C
createHeap__16dAcOislandNusi_cFv = .text:0x000003F0; // type:function size:0x15C
create__16dAcOislandNusi_cFv = .text:0x00000550; // type:function size:0x13C
changeState__85sStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000690; // type:function size:0x10
AcOislandNusi__destroy = .text:0x000006A0; // type:function size:0x38
AcOislandNusi__update = .text:0x000006E0; // type:function size:0x30
doDelete__16dAcOislandNusi_cFv = .text:0x000006A0; // type:function size:0x38
actorExecute__16dAcOislandNusi_cFv = .text:0x000006E0; // type:function size:0x30
executeState__85sStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000710; // type:function size:0x10
AcOislandNusi__draw = .text:0x00000720; // type:function size:0x60
draw__16dAcOislandNusi_cFv = .text:0x00000720; // type:function size:0x60
initializeState_Wait__16dAcOislandNusi_cFv = .text:0x00000780; // type:function size:0xD0
executeState_Wait__16dAcOislandNusi_cFv = .text:0x00000850; // type:function size:0x50
finalizeState_Wait__16dAcOislandNusi_cFv = .text:0x000008A0; // type:function size:0x4
initializeState_NusiFight__16dAcOislandNusi_cFv = .text:0x000008B0; // type:function size:0xD0
executeState_NusiFight__16dAcOislandNusi_cFv = .text:0x00000980; // type:function size:0x50
finalizeState_NusiFight__16dAcOislandNusi_cFv = .text:0x000009D0; // type:function size:0x4
isInLeviasFight = .text:0x000009E0; // type:function size:0x7C
isInLeviasFight__16dAcOislandNusi_cCFv = .text:0x000009E0; // type:function size:0x7C
__dt__16dAcOislandNusi_cFv = .text:0x00000A60; // type:function size:0xE4
getStateID__85sStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000B50; // type:function size:0x10
build__32sFStateFct_c<16dAcOislandNusi_c>FRC12sStateIDIf_c = .text:0x00000B60; // type:function size:0x60
Expand All @@ -44,20 +44,20 @@ isSameName__31sFStateID_c<16dAcOislandNusi_c>CFPCc = .text:0x00000F40; // type:f
_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_413_rodata_0 = .rodata:0x00000000; // type:object size:0x8 data:float
lbl_413_rodata_8 = .rodata:0x00000008; // type:object size:0x24 data:4byte
lbl_413_data_0 = .data:0x00000000; // type:object size:0x8 data:4byte
lbl_413_data_8 = .data:0x00000008; // type:object size:0x10
g_profile_OBJ_ISLAND_NUSI = .data:0x00000018; // type:object size:0x38
lbl_413_data_50 = .data:0x00000050; // type:object size:0x20
lbl_413_data_70 = .data:0x00000070; // type:object size:0x8
lbl_413_data_78 = .data:0x00000078; // type:object size:0x80
lbl_413_data_F8 = .data:0x000000F8; // type:object size:0x30
lbl_413_data_128 = .data:0x00000128; // type:object size:0x30
lbl_413_data_158 = .data:0x00000158; // type:object size:0x18
lbl_413_data_170 = .data:0x00000170; // type:object size:0xA4
lbl_413_data_214 = .data:0x00000214; // type:object size:0x34
lbl_413_rodata_0 = .rodata:0x00000000; // type:object size:0x8 scope:local data:float
lbl_413_rodata_8 = .rodata:0x00000008; // type:object size:0x24 scope:local data:4byte
lbl_413_data_0 = .data:0x00000000; // type:object size:0x8 scope:local data:4byte
lbl_413_data_8 = .data:0x00000008; // type:object size:0x10 scope:local
g_profile_OBJ_ISLAND_NUSI = .data:0x00000018; // type:object size:0x10
lbl_413_data_50 = .data:0x00000050; // type:object size:0x20 scope:local
lbl_413_data_70 = .data:0x00000070; // type:object size:0x8 scope:local
__vt__16dAcOislandNusi_c = .data:0x00000078; // type:object size:0x80
__vt__55sFStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c> = .data:0x000000F8; // type:object size:0x30
__vt__85sStateMgr_c<16dAcOislandNusi_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x00000128; // type:object size:0x30
__vt__32sFStateFct_c<16dAcOislandNusi_c> = .data:0x00000158; // type:object size:0x14
__vt__29sFState_c<16dAcOislandNusi_c> = .data:0x00000170; // type:object size:0x18
__vt__31sFStateID_c<16dAcOislandNusi_c> = .data:0x00000214; // type:object size:0x34
__global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global
lbl_413_bss_8 = .bss:0x00000008; // type:object size:0x10 data:4byte
lbl_413_bss_18 = .bss:0x00000018; // type:object size:0x40 data:4byte
lbl_413_bss_58 = .bss:0x00000058; // type:object size:0x30 data:4byte
lbl_413_bss_8 = .bss:0x00000008; // type:object size:0xC scope:local data:4byte
StateID_Wait__16dAcOislandNusi_c = .bss:0x00000018; // type:object size:0x30 data:4byte
StateID_NusiFight__16dAcOislandNusi_c = .bss:0x00000058; // type:object size:0x30 data:4byte
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]):
Rel(NonMatching, "d_a_obj_into_hole", "REL/d/a/obj/d_a_obj_into_hole.cpp"),
Rel(NonMatching, "d_a_obj_iron_stage", "REL/d/a/obj/d_a_obj_iron_stage.cpp"),
Rel(NonMatching, "d_a_obj_island_LOD", "REL/d/a/obj/d_a_obj_island_LOD.cpp"),
Rel(NonMatching, "d_a_obj_island_nusi", "REL/d/a/obj/d_a_obj_island_nusi.cpp"),
Rel(Matching, "d_a_obj_island_nusi", "REL/d/a/obj/d_a_obj_island_nusi.cpp"),
Rel(
NonMatching,
"d_a_obj_item_heart_container",
Expand Down
18 changes: 17 additions & 1 deletion include/d/a/obj/d_a_obj_island_nusi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#define D_A_OBJ_ISLAND_NUSI_H

#include "d/a/obj/d_a_obj_base.h"
#include "d/col/bg/d_bg_w.h"
#include "m/m3d/m_smdl.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"

Expand All @@ -10,11 +13,24 @@ class dAcOislandNusi_c : public dAcObjBase_c {
dAcOislandNusi_c() : mStateMgr(*this, sStateID::null) {}
virtual ~dAcOislandNusi_c() {}

virtual bool createHeap() override;
virtual int create() override;
virtual int doDelete() override;
virtual int actorExecute() override;
virtual int draw() override;

STATE_FUNC_DECLARE(dAcOislandNusi_c, Wait);
STATE_FUNC_DECLARE(dAcOislandNusi_c, NusiFight);

private:
/* 0x??? */ STATE_MGR_DECLARE(dAcOislandNusi_c);
static const f32 someFloat;

bool isInLeviasFight() const;

/* 0x330 */ m3d::smdl_c mMdls[2];
/* 0x360 */ nw4r::g3d::ResFile mRes;
/* 0x36C */ dBgW mBgW;
/* 0x57C */ STATE_MGR_DECLARE(dAcOislandNusi_c);
};

#endif
9 changes: 9 additions & 0 deletions include/nw4r/g3d/g3d_scnmdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ class ScnMdl : public ScnMdlSimple {
char UNK_0x0[0x34];
};

class CopiedVisAccess {
public:
CopiedVisAccess(ScnMdl *, u32);
void SetVisibility(bool);
private:
// TODO
char UNK_0x0[0x10];
};

public:
virtual bool SetAnmObj(AnmObj *p, AnmObjType type) override;

Expand Down
112 changes: 108 additions & 4 deletions src/REL/d/a/obj/d_a_obj_island_nusi.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,117 @@
#include "d/a/obj/d_a_obj_island_nusi.h"

#include "d/a/obj/d_a_obj_base.h"
#include "d/col/bg/d_bg_s.h"
#include "f/f_base.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resmdl.h"
#include "nw4r/g3d/g3d_resnode.h"
#include "nw4r/g3d/g3d_scnmdl.h"
#include "nw4r/g3d/g3d_scnobj.h"
#include "toBeSorted/item_story_flag_manager.h"
#include "toBeSorted/room_manager.h"

const f32 dAcOislandNusi_c::someFloat = 100000.0f;

static const char *const sMdlNames[] = {
"IslNusi",
"IslNusi_s",
};

SPECIAL_ACTOR_PROFILE(OBJ_ISLAND_NUSI, dAcOislandNusi_c, fProfile::OBJ_ISLAND_NUSI, 0x204, 0, 3);

STATE_DEFINE(dAcOislandNusi_c, Wait);
STATE_DEFINE(dAcOislandNusi_c, NusiFight);

void dAcOislandNusi_c::initializeState_Wait() {}
void dAcOislandNusi_c::executeState_Wait() {}
bool dAcOislandNusi_c::createHeap() {
mRes = getOarcResFile("IslNusi");
RoomManager::bindStageResToFile(&mRes);
RoomManager::bindSkyCmnToResFile(&mRes);
for (int i = 0; i < 2; i++) {
nw4r::g3d::ResMdl mdl = mRes.GetResMdl(sMdlNames[i]);
TRY_CREATE(mMdls[i].create(mdl, &heap_allocator, 0x160));
}

mMdls[0].setOption(0x30001, 0);

void *dzb = getOarcFile("IslNusi", "dzb/IslNusi.dzb");
void *plc = getOarcFile("IslNusi", "dat/IslNusi.plc");
updateMatrix();
for (int i = 0; i < 2; i++) {
mMdls[i].setLocalMtx(mWorldMtx);
}
TRY_CREATE(!mBgW.Set((cBgD_t *)dzb, (PLC *)plc, cBgW::MOVE_BG_e, &mWorldMtx, &mScale));
mBgW.Lock();
// TODO InitMapStuff bool vs BOOL
return (BOOL)mBgW.InitMapStuff(&heap_allocator);
}

int dAcOislandNusi_c::create() {
CREATE_ALLOCATOR(dAcOislandNusi_c);
dBgS::GetInstance()->Regist(&mBgW, this);
dBgS::GetInstance()->RegistBg(&mBgW, this);
if (isInLeviasFight()) {
mStateMgr.changeState(StateID_NusiFight);
} else {
mStateMgr.changeState(StateID_Wait);
}

mMdls[0].setPriorityDraw(0x1C, 9);
mMdls[1].setPriorityDraw(0x22, 9);
boundingBox.Set(mVec3_c(-4000.0f, -1200.0f, -2700.0f), mVec3_c(4800.0f, 3400.0f, 1700.0f));

mCullingDistance = 500000.0f;

return SUCCEEDED;
}

int dAcOislandNusi_c::doDelete() {
dBgS::GetInstance()->UnRegist(&mBgW);
return SUCCEEDED;
}

int dAcOislandNusi_c::actorExecute() {
mStateMgr.executeState();
return SUCCEEDED;
}

int dAcOislandNusi_c::draw() {
for (int i = 0; i < 2; i++) {
drawModelType1(&mMdls[i]);
}
return SUCCEEDED;
}

void dAcOislandNusi_c::initializeState_Wait() {
nw4r::g3d::ScnMdl *m = nw4r::g3d::ScnObj::DynamicCast<nw4r::g3d::ScnMdl>(mMdls[0].getG3dObject());
nw4r::g3d::ResMdl resM = mMdls[0].getResMdl();
nw4r::g3d::ResNode resNd = resM.GetResNode("pPipe1");
u32 id = resNd.GetID();
nw4r::g3d::ScnMdl::CopiedVisAccess visAccess(m, id);
visAccess.SetVisibility(true);
}
void dAcOislandNusi_c::executeState_Wait() {
if (isInLeviasFight()) {
mStateMgr.changeState(StateID_NusiFight);
}
}
void dAcOislandNusi_c::finalizeState_Wait() {}
void dAcOislandNusi_c::initializeState_NusiFight() {}
void dAcOislandNusi_c::executeState_NusiFight() {}

void dAcOislandNusi_c::initializeState_NusiFight() {
nw4r::g3d::ScnMdl *m = nw4r::g3d::ScnObj::DynamicCast<nw4r::g3d::ScnMdl>(mMdls[0].getG3dObject());
nw4r::g3d::ResMdl resM = mMdls[0].getResMdl();
nw4r::g3d::ResNode resNd = resM.GetResNode("pPipe1");
u32 id = resNd.GetID();
nw4r::g3d::ScnMdl::CopiedVisAccess visAccess(m, id);
visAccess.SetVisibility(false);
}
void dAcOislandNusi_c::executeState_NusiFight() {
if (!isInLeviasFight()) {
mStateMgr.changeState(StateID_Wait);
}
}
void dAcOislandNusi_c::finalizeState_NusiFight() {}

bool dAcOislandNusi_c::isInLeviasFight() const {
return StoryflagManager::sInstance->getCounterOrFlag(368) && !StoryflagManager::sInstance->getCounterOrFlag(200);
}
3 changes: 1 addition & 2 deletions src/d/col/bg/d_bg_s_acch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ void dBgS_Acch::GroundCheck(dBgS &bgs, bool param2) {
}
}

// UUUUUGH
if ((mFlags & ACCH_FLAG_0x4000000) && !(mFlags & GROUND_HIT)) {
if (Chk_0x4000000() && !i_ChkGroundHit()) {
SetGroundAway();
}

Expand Down

0 comments on commit 5995604

Please sign in to comment.