Skip to content
Draft
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
6 changes: 4 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,19 +795,20 @@ def MatchingFor(*versions):
Object(NonMatching, "MarioUtil/EffectUtil.cpp"),
Object(NonMatching, "MarioUtil/ModelUtil.cpp"),
Object(NonMatching, "MarioUtil/RumbleMgr.cpp"),
Object(NonMatching, "MarioUtil/RumbleData.cpp"),
Object(Matching, "MarioUtil/RumbleData.cpp"),
Object(Matching, "MarioUtil/RumbleType.cpp"),
Object(NonMatching, "MarioUtil/PacketUtil.cpp"),
Object(Matching, "MarioUtil/GDUtil.cpp"),
Object(Matching, "MarioUtil/TexUtil.cpp"),
Object(Matching, "MarioUtil/MapUtil.cpp"),
Object(NonMatching, "MarioUtil/ToolData.cpp"),
Object(Matching, "MarioUtil/ToolData.cpp"),
],
},
{
"lib": "M3DUtil",
"mw_version": "GC/1.2.5",
"cflags": [*cflags_system, "-inline deferred"],
"progress_category": "game",
"objects": [
Object(NonMatching, "M3DUtil/M3UJoint.cpp"),
Object(NonMatching, "M3DUtil/M3UModel.cpp"),
Expand All @@ -826,6 +827,7 @@ def MatchingFor(*versions):
"lib": "System",
"mw_version": "GC/1.2.5",
"cflags": cflags_system,
"progress_category": "game",
"objects": [
Object(Matching, "System/BaseParam.cpp"),
Object(NonMatching, "System/EmitterViewObj.cpp"),
Expand Down
46 changes: 46 additions & 0 deletions include/GC2D/MovieRumble.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef GC2D_MOVIE_RUMBLE_HPP
#define GC2D_MOVIE_RUMBLE_HPP

#include <dolphin/types.h>
#include <System/THPRender.hpp>
#include <MarioUtil/RumbleType.hpp>
#include <MarioUtil/ToolData.hpp>

class TMovieRumble : public JDrama::TViewObj {
public:
TMovieRumble(const TTHPRender* thpRender);
virtual ~TMovieRumble();
void init(const char* subtitleName);
virtual void perform(u32 flags, JDrama::TGraphics* graphics);
void checkRumbleOff();

public:
const TTHPRender* thpRenderer;
Koga::ToolData* toolData; // this is supposedly the only usage of tooldata
// in the entire game lmao
s32 entryIndex;
s32 startFrame;
s32 endFrame;
s32 rumbleTypeIndex;
bool isRumbleActive;

private:
inline void updateRumbleState(Koga::ToolData* toolData, s32 entryIndex)
{
const char* rumbleTypeString;
s32 theEntryIndex = entryIndex;
bool isDataValid = (toolData != nullptr) && (theEntryIndex >= 0);

if (isDataValid && toolData->isIndexValid(theEntryIndex)) {
// get this rumble entry's data, and update this instance
toolData->GetValue(theEntryIndex, "start_frame", startFrame);
toolData->GetValue(theEntryIndex, "end_frame", endFrame);
toolData->GetValue(theEntryIndex, "type", rumbleTypeString);
rumbleTypeIndex = RumbleType::getIndex((char*)rumbleTypeString);
} else {
rumbleTypeIndex = -1;
}
}
};

#endif // GC2D_MOVIE_RUMBLE_HPP
84 changes: 59 additions & 25 deletions include/MarioUtil/RumbleMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,57 @@
#define MARIO_UTIL_RUMBLE_MGR_HPP

#include <dolphin/mtx.h>
#include <dolphin/pad.h>
#include <JSystem/JGeometry.hpp>

class RumbleBase {
public:
void init();
void stop();
void update(f32, bool);
};
#define MAX_RUMBLE_ID (25)
#define MAX_RUMBLE_CHANNELS (32)

class RumbleChannelDataMgr {
public:
void init();
void getChannelDataTbl(int);
struct RumbleChannelData {
int* point;
float* frame;
float* power;
};

extern const RumbleChannelData channelDataTbl[];
extern int channelNum;

// RumbleMgr

class RumbleChannelMgr {
public:
RumbleChannelMgr();
void init(RumbleChannelDataMgr*);
void reset();
void repeat();
void start(int, int, f32*);
void start(int, int, Vec*);
void update();
f32 update();

public:
/* 0x00 */ f32 mElapsedTime; /* inferred */
/* 0x04 */ f32 mCurrentIntensity; /* inferred */
/* 0x08 */ s32 mChannelID; /* inferred */
/* 0x0C */ s32 mLoopCount; /* inferred */
/* 0x10 */ f32* mExternalDampenPtr; /* inferred */
/* 0x14 */ Vec* mPositionalSourcePtr; /* inferred */
/* 0x18 */ const RumbleChannelData* rumbleData; /* inferred */
/* 0x1C */ void* unk20; /* inferred */
};

class RumbleControllerMgr {
public:
RumbleControllerMgr();
void init();
void reset();
void start(int, int, f32*);
void start(int, int, Vec*);
void stop();
void stop(int);
void start(int channelId, int loopCount, float* externalDampenPtr);
void start(int channelId, int loopCount, Vec* positionalSourcePtr);
void stop(int channelId);
void channelMgrIsAllFree();
void updateMotorCount();
void update();
f32 update();

public:
f32 currentPower; // 0x00
RumbleChannelMgr* channels; // 0x04
RumbleChannelMgr* unk8; // 0x08
u32 unkC; // 0x0C
u16 motorTime; // 0x10
bool unk12; // 0x12
u8 padding_13; // 0x13
};

class RumbleMgr;
Expand Down Expand Up @@ -66,8 +80,28 @@ class RumbleMgr {
void setActive(bool);
void startPause();
void finishPause();
void changePause();
void changeMode();

public:
struct RumbleControllerState {
f32 m_currentIntensityL; // 0x00
f32 m_currentIntensityR; // 0x04
s32 m_controllerIndex; // 0x08
};

f32 m_masterIntensityL; // 0x00
f32 m_masterIntensityR; // 0x04
bool m_isInitialized; // 0x08
bool m_flags; // 0x09
bool unkA; // 0x0A
bool unkB; // 0x0B
RumbleControllerState* m_controllerStates[4]; // 0x0C
RumbleControllerMgr* m_controllerManagers[4]; // 0x1C
const RumbleChannelData** m_rumbleOutput; // 0x2C

public:
static u32 mMotorCountLimit;
static u16 mMotorTimerPeriod;
static f32 mPowerThreshold;
};

#endif
1 change: 1 addition & 0 deletions include/MarioUtil/RumbleType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define MARIO_UTIL_RUMBLE_TYPE_HPP

class RumbleType {
public:
float foo;
static int getIndex(char* strIn);
};
Expand Down
117 changes: 117 additions & 0 deletions include/MarioUtil/ToolData.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#ifndef MARIO_UTIL_TOOL_DATA_HPP
#define MARIO_UTIL_TOOL_DATA_HPP
#include <types.h>

namespace Koga {
/**
* @brief ToolData is a class that reads BCSV data. Usage is as follows:
* Create a ToolData instance, fetch the BCSV data from disk and attach it.
* One can then call GetValue to retrieve data from the file.
*
* The structures and parsing logic are based off the Mario Galaxy decomp's
* handling of JMap files
*/
class ToolData {
public:
ToolData();
virtual ~ToolData(); // if not explicitly defined its not generated ok
BOOL Attach(const void* bcsvFileData);
// returns TRUE if the value was found, otherwise FALSE
BOOL GetValue(int entryIndex, const char* key, long& pValueOut) const;
// returns TRUE if the value was found, otherwise FALSE
BOOL GetValue(int entryIndex, const char* key,
const char*& pValueOut) const;

inline bool dataExists() const { return !!mData; }

inline bool isIndexValid(s32 entryIndex)
{
return entryIndex < mData->mNumEntries;
}

// JMAP value types, ignored in sunshine
#define JMAP_VALUE_TYPE_LONG 0
#define JMAP_VALUE_TYPE_STRING 1
#define JMAP_VALUE_TYPE_FLOAT 2
#define JMAP_VALUE_TYPE_LONG_2 3
#define JMAP_VALUE_TYPE_SHORT 4
#define JMAP_VALUE_TYPE_BYTE 5
#define JMAP_VALUE_TYPE_STRING_PTR 6
#define JMAP_VALUE_TYPE_NULL 7

struct JMapItem {
u32 mHash; // 0x0
u32 mMask; // 0x4
u16 mOffsData; // 0x8
u8 mShift; // 0xA
u8 mType; // 0xB
};

struct JMapData {
s32 mNumEntries; // 0x0
s32 mNumFields; // 0x4
s32 mDataOffset; // 0x8
u32 mEntrySize; // 0xC
const JMapItem mItems[]; // 0x10
};

private:
inline u32 hashString(const char* key) const
{
u32 stringHash = 0;
char current_char;

while ((current_char = *key) != 0) {
key++;
stringHash = (current_char + (stringHash << 8)) % 0x1FFFFD9;
}
return stringHash;
}

inline s32 searchItemInfo(const char* pKey) const
{
s32 nFields = mData->mNumFields;
u32 hash = hashString(pKey);

for (int i = 0; i < nFields; ++i) {
if (hash == mData->mItems[i].mHash) {
return i;
}
}

return -1;
}

inline const char* getEntryAddress(const JMapData* pData,
const s32 dataOffset,
const int entryIndex) const
{
return reinterpret_cast<const char*>(pData) + dataOffset
+ entryIndex * pData->mEntrySize;
}

inline BOOL getValue(const int entryIndex, const int itemIndex,
s32* pValueOut) const
{
const JMapItem* item = &mData->mItems[itemIndex];
const char* valuePtr
= getEntryAddress(mData, mData->mDataOffset, entryIndex)
+ item->mOffsData;
*pValueOut = *reinterpret_cast<const s32*>(valuePtr);
return TRUE;
}

inline BOOL getValue(const int entryIndex, const int itemIndex,
const char** pValueOut) const
{
const JMapItem* item = &mData->mItems[itemIndex];
*pValueOut = getEntryAddress(mData, mData->mDataOffset, entryIndex)
+ item->mOffsData;
return TRUE;
}

public:
const JMapData* mData;
};
} // namespace Koga
#endif
7 changes: 5 additions & 2 deletions include/System/THPRender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@

class TTHPRender : public JDrama::TViewObj {
public:
virtual void perform(u32, JDrama::TGraphics*); /* override */
void perform(u32, JDrama::TGraphics*); /* override */
TTHPRender(const char* name);
~TTHPRender();

inline s32 getFrameNumber() const { return frameNumber; }

/* 0x10 */ u32 x;
/* 0x14 */ u32 y;
/* 0x18 */ u32 polyW;
/* 0x1c */ u32 polyH;
/* 0x20 */ u32 frameNumber;
/* 0x20 */ s32 frameNumber;
};

#endif // SYSTEM_THP_RENDER_HPP
Loading
Loading