Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions alias_db.txt
Original file line number Diff line number Diff line change
Expand Up @@ -739,3 +739,16 @@ R_2_5_4180 = g_profile_DEMO_MESSAGE
R_2_5_72e0 = g_profile_LETTER_WINDOW
R_2_5_1a7f8 = g_profile_DUMMY_ACTOR
R_2_5_27460 = g_profile_LASTACTOR_STAGE
R_3_1_70 = __register_global_object
R_3_1_780 = getPlrNo__8dActor_cFv
R_3_1_2700 = finalUpdate__12dBaseActor_cFv
R_3_1_2710 = GetActorType__12dBaseActor_cFv
R_3_1_2720 = funsuiMoveX__8dActor_cFv
R_3_1_2730 = setCarryFall__8dActor_cFP8dActor_ci
R_3_1_2740 = isSpinLiftUpEnable__8dActor_cFv
R_3_1_2750 = vf68__8dActor_cFP9dBg_ctr_c
R_3_1_2760 = isFunsui__5dEn_cCFv
R_3_1_2770 = endFunsui__5dEn_cFv
R_3_1_2780 = beginFunsui__5dEn_cFv
R_3_1_2790 = calcBoyonScale__5dEn_cFv
R_3_1_33e0 = isQuakeDamage__5dEn_cFv
170 changes: 170 additions & 0 deletions include/game/bases/d_a_en_snake_block.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#pragma once
#include <game/bases/d_enemy.hpp>
#include <game/bases/d_bg_ctr.hpp>
#include <game/bases/d_heap_allocator.hpp>
#include <game/mLib/m_3d/anm_mat_clr.hpp>
#include <game/mLib/m_3d/mdl.hpp>

#define MAX_SNAKE_BLOCK_COUNT 20

/// @brief A snake block which travels along a rail.
/// @paramtable
/// @statetable
/// @ingroup bases
class daEnSnakeBlock_c : public dEn_c {
public:
class dBlock_c {
public:
dBlock_c() : mpOwner(nullptr), m_1b4(0) {}
virtual ~dBlock_c() { mBgCtr.release(); }

void createMdl(mAllocator_c *allocator);
void doDelete();

void calcAnm();
void setAnmClr(const char *name);

void draw(const mVec3_c &offset);

void initBgCtr(daEnSnakeBlock_c *parent, mVec3_c &blockPos, bool icy);
void calcBgCtr();

void setFallCollapse();
void calcCollapse1(s8 *travelInfo);

mVec3_c getPos() const { return mPos; }
void setPos(mVec3_c pos) { mPos = pos; }
void releaseBgCtr() {
if (mBgCtr.m_dc) {
mBgCtr.release();
}
}
void updatePos() {
mPos += mSpeed;
}

static dBg_ctr_c::CallbackF callBackF;
static dBg_ctr_c::CallbackH callBackH;
static dBg_ctr_c::CallbackW callBackW;

nw4r::g3d::ResFile mResFile;
m3d::mdl_c mModel;
m3d::anmMatClr_c mAnmClr;
nw4r::g3d::ResAnmTexSrt mResTexSrt;
m3d::anmTexSrt_c mAnmTexSrt;

mVec3_c mPos;
mVec3_c mSpeed;
mVec3_c mLastPos;

dBg_ctr_c mBgCtr;
int mTravelInfoIdx;
daEnSnakeBlock_c *mpOwner;

short m_1b4;
};

class dCtrlBlock_c : public dBlock_c {
public:
/// @brief The possible speed modes of a snake block.
enum SnakeSpeed_e {
SNAKE_SPEED_SLOW,
SNAKE_SPEED_MEDIUM,
SNAKE_SPEED_FAST,
SNAKE_SPEED_COUNT
};

dCtrlBlock_c() {}
virtual ~dCtrlBlock_c() { mBgCtr.release(); }

/// @brief Move this block in the direction of the current travel info.
/// @param travelInfo Travel info array, used to determine the direction of movement.
/// @return Whether the block is ready for the next move.
bool moveBlock(s8 *travelInfo);
/// @brief Start the move to the next position.
/// @param travelInfo Travel info array, used to determine the direction of movement.
/// @return Whether the block has reached the end of the travel info.
bool nextTravelMove(s8 *travelInfo);

SnakeSpeed_e mSnakeSpeed;
};

enum TravelDir_e {
TRAVEL_DIR_NONE,
TRAVEL_DIR_UP,
TRAVEL_DIR_DOWN,
TRAVEL_DIR_LEFT,
TRAVEL_DIR_RIGHT,
TRAVEL_DIR_COUNT
};

daEnSnakeBlock_c() : mpTravelInfo(nullptr), mTravelInfoIdx(0), mShakeTimer(0) {}
virtual ~daEnSnakeBlock_c() {}

virtual int create();
virtual int doDelete();
virtual int execute();
virtual int draw();
virtual void deleteReady();

void initBlock();
void initBlockPath();

void calcAnm();
void createMdl();
void deleteBlock();

void setStopState();

void calcBgCtr();
void initTravelInfo();

void setBlockPos();
void setActorPos();

bool chkCollapseDelete(); ///< Returns if the Tail is below the screen edge (meaning the collapse has ended, and the actor can be deleted)
bool chkOffScreen(); ///< Returns if the Snake Block is far past the right edge of the screen (used to delete it)

dCtrlBlock_c &getHeadBlock() { return mCtrlBlock[0]; }
dCtrlBlock_c &getTailBlock() { return mCtrlBlock[1]; }

dHeapAllocator_c mAllocator;

dCtrlBlock_c mCtrlBlock[2]; ///< The head and tail blocks.
dBlock_c mBlocks[MAX_SNAKE_BLOCK_COUNT]; ///< The blocks between the head and tail. Only the first mBlockCount of these are used.

int mBlockCount; ///< The number of blocks between the head and tail.
s8 *mpTravelInfo; ///< Values are of type TravelDir_e.
int mTravelInfoIdx; ///< The current index into mpTravelInfo.
short mShakeTimer; ///< Counts frames for the shake animation.

sStateID_c *mpStopState; ///< The state to transition to when the snake block stops.
int mSnakeType; ///< Used for custom snake types
int mCollapseTimer;
int mCreateAnmBlockIdx;
int mCreateAnmBlockNum;
u8 mPad[4];

ACTOR_PARAM_CONFIG(BlockCount, 0, 4); ///< The number of blocks between the head and tail.
ACTOR_PARAM_CONFIG(RailID, 4, 4); ///< The ID of the rail that the snake block travels along.
ACTOR_PARAM_CONFIG(SnakeSpeed, 8, 2); ///< The snake's speed. See dCtrlBlock_c::SnakeSpeed_e.
ACTOR_PARAM_CONFIG(RailStartIdx, 12, 8); ///< The index of the rail points that the snake block starts at.
ACTOR_PARAM_CONFIG(SnakeType, 20, 1); ///< [Has no effect in-game, but might have been intended for ice / no ice variants]
ACTOR_PARAM_CONFIG(StopMode, 28, 4); ///< Determines how the snake block behaves after terminating.

static const float sc_FallAccel;
static const float sc_FallMaxSpeed;
static const float sc_SnakeSpeeds[3];
static const float sc_SnakeSpeeds2[3];
static const mVec2_c sc_TravelDirs[5];
static const int scSnakeSoundID;
static int g_SnakeNum; ///< Global counter for the active snake blocks.

STATE_FUNC_DECLARE(daEnSnakeBlock_c, Wait); ///< Waiting for a player to land on the block to start moving.
STATE_FUNC_DECLARE(daEnSnakeBlock_c, Move); ///< Moving along the rail.
STATE_FUNC_DECLARE(daEnSnakeBlock_c, Shake); ///< Shaking before collapsing.
STATE_FUNC_DECLARE(daEnSnakeBlock_c, Stop); ///< Stopped at the end of the rail.
STATE_FUNC_DECLARE(daEnSnakeBlock_c, Collapse1); ///< Collapse mode 1: Blocks fall through last node.
STATE_FUNC_DECLARE(daEnSnakeBlock_c, Collapse2); ///< Collapse mode 2: Blocks fall after another, with an 8-frame delay between each.
STATE_FUNC_DECLARE(daEnSnakeBlock_c, Collapse3); ///< Collapse mode 3: Blocks fall all at once.
};
37 changes: 37 additions & 0 deletions include/game/bases/d_bg_ctr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <game/bases/d_actor.hpp>

class dBg_ctr_c {
public:
dActor_c *mpActor;
u8 mPad1[0x9c];
mVec2_c m_a0;
mVec2_c m_ac;
u8 mPad2[0xc];
short *m_bc;
u8 mPad4[0x8];
int m_c8;
int m_cc;
u32 mFlags;
int m_d4;
u8 mpPad5[0x4];
bool m_dc;
u8 mpPad6[0x3];
bool m_e0;
u8 m_e1;
u8 m_e2;

typedef void CallbackF(dActor_c *self, dActor_c *other);
typedef void CallbackH(dActor_c *self, dActor_c *other);
typedef void CallbackW(dActor_c *self, dActor_c *other, u8);

dBg_ctr_c();
~dBg_ctr_c();

void entry();
void release();
void set(dActor_c*, float, float, float, float, CallbackF *, CallbackH *, CallbackW *, u8, u8, mVec3_c *);
void setOfs(float, float, float, float, mVec3_c *);
void calc();
};
6 changes: 3 additions & 3 deletions include/game/bases/d_cd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ class dCd_c {
static void deleteInstance();

dCdFile_c *getFileP(int idx) {
dCdFile_c *course = &mFiles[idx];
if (course->mpAreas != nullptr) {
return course;
dCdFile_c *file = &mFiles[idx];
if (file->mpAreas != nullptr) {
return file;
}
return nullptr;
}
Expand Down
3 changes: 2 additions & 1 deletion include/game/mLib/m_3d/anm_mat_clr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace m3d {
class anmMatClr_c : public banm_c {
public:
anmMatClr_c() : mpChildren(nullptr) {}
virtual ~anmMatClr_c();
virtual void remove();
virtual void play();
Expand Down Expand Up @@ -38,6 +39,6 @@ namespace m3d {
void setFrmCtrlDefault(nw4r::g3d::ResAnmClr &anmClr, m3d::playMode_e playMode);
};

child_c *children;
child_c *mpChildren;
};
}
3 changes: 2 additions & 1 deletion include/game/mLib/m_3d/anm_tex_pat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace m3d {
class anmTexPat_c : public banm_c {
public:
anmTexPat_c() : mpChildren(nullptr) {}
virtual ~anmTexPat_c();
virtual void remove();
virtual void play();
Expand Down Expand Up @@ -38,6 +39,6 @@ namespace m3d {
void setFrmCtrlDefault(nw4r::g3d::ResAnmTexPat &anmTexPat, m3d::playMode_e playMode);
};

child_c *children;
child_c *mpChildren;
};
}
3 changes: 2 additions & 1 deletion include/game/mLib/m_3d/anm_tex_srt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace m3d {
class anmTexSrt_c : public banm_c {
public:
anmTexSrt_c() : mpChildren(nullptr) {}
virtual ~anmTexSrt_c();
virtual void remove();
virtual void play();
Expand Down Expand Up @@ -38,6 +39,6 @@ namespace m3d {
void setFrmCtrlDefault(nw4r::g3d::ResAnmTexSrt &anmTexSrt, m3d::playMode_e playMode);
};

child_c *children;
child_c *mpChildren;
};
}
7 changes: 7 additions & 0 deletions prepare_objdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ def get_dtk(tag: str) -> str:
'.sdata2': 'bss',
}

# Step 0: Verify that the built binaries match by running progress.py silently
ret_code = subprocess.run(['python', 'progress.py', '--verify-bin'], stdout=subprocess.DEVNULL).returncode

if ret_code != 0:
print_err('Verification of binaries failed. Did you forget to add "nonMatching": true to the slice?')
sys.exit()

# Step 1: Get DTK, load slices and symbols
dtk_path = get_dtk('v1.8.0')

Expand Down
13 changes: 11 additions & 2 deletions slices/d_enemiesNP.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"meta": {
"fileName": "d_enemiesNP.rel",
"type": "REL",
"defaultCompilerFlags": "-sdata 0 -sdata2 0 -proc gekko -fp hard -O4,p -char signed -rtti off -enum int -Cpp_exceptions off -ipa file -enc SJIS",
"defaultCompilerFlags": "-sdata 0 -sdata2 0 -proc gekko -fp hard -O4,p -inline noauto -char signed -rtti off -enum int -Cpp_exceptions off -ipa file -enc SJIS",
"moduleNum": 3,
"baseAddr": "809A2D90",
"sections": {
Expand Down Expand Up @@ -30,10 +30,19 @@
"slices": [
{
"source": "runtime/rel_init.cpp",
"compilerFlags": "",
"memoryRanges": {
".text": "0x0-0x70"
}
},
{
"source": "d_enemiesNP/bases/d_a_en_snake_block.cpp",
"memoryRanges": {
".text": "0x103a50-0x106960",
".ctors": "0x228-0x22c",
".rodata": "0x72a0-0x7310",
".data": "0x33680-0x33b90",
".bss": "0x9f30-0xa178"
}
}
]
}
Loading
Loading