Skip to content
Merged
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
4 changes: 2 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def MatchingFor(*versions):
"progress_category": "game",
"objects": [
Object(Equivalent, "sysDolphin/texture.cpp"),
Object(not MatchingFor("DPIJ01_PIKIDEMO"), "sysDolphin/system.cpp"),
Object(Matching, "sysDolphin/system.cpp"),
Object(Matching, "sysDolphin/sysNew.cpp"),
Object(Matching, "sysDolphin/controllerMgr.cpp"),
Object(not MatchingFor("GPIJ01_01", "GPIJ01_02", "G98P01_PIKIDEMO", "DPIJ01_PIKIDEMO"), "sysDolphin/dgxGraphics.cpp"),
Expand Down Expand Up @@ -498,7 +498,7 @@ def MatchingFor(*versions):
Object(Equivalent, "plugPikiKando/simpleAI.cpp"),
Object(Matching, "plugPikiKando/formationMgr.cpp"),
Object(Matching, "plugPikiKando/globalShapes.cpp"),
Object(not MatchingFor("GPIJ01_01", "GPIJ01_02", "DPIJ01_PIKIDEMO"), "plugPikiKando/playerState.cpp"),
Object(Matching, "plugPikiKando/playerState.cpp"),
Object(Matching, "plugPikiKando/gameDemo.cpp"),
Object(Matching, "plugPikiKando/demoInvoker.cpp"),
Object(Matching, "plugPikiKando/demoEvent.cpp"),
Expand Down
82 changes: 51 additions & 31 deletions include/AICreature.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,40 @@ struct AState;
template <typename T>
struct StateMachine;

struct AICreature;
struct CollEvent;

/**
* @brief TODO
*
* @note Size: 0x48.
*/
struct SAIContext {
SAIContext()
{
mCollidingCreature = nullptr;
_08.set(0.0f, 0.0f, 0.0f);
mCounter = 0;
mCurrAnimId = 0;
mCurrentState = nullptr;
mCurrentItemHealth = 0.0f;
}

Creature* mCollidingCreature; // _00
Creature* mTargetCreature; // _04
Vector3f _08; // _08
int mCurrAnimId; // _14, to do with bombs
int mCounter; // _18, used by `SluiceAI`, `PikiHeadAI`, and `GoalAI`.
f32 mCurrentItemHealth; // _1C
f32 _20; // _20
f32 mMaxItemHealth; // _24
AState<AICreature>* mCurrentState; // _28
StateMachine<AICreature>* mStateMachine; // _2C
int mCurrentEventCount; // _30
int mMaxEventCount; // _34
bool mEventFlags[16]; // _38
};

/**
* @brief TODO
*
Expand All @@ -22,24 +54,24 @@ struct CollEvent;
struct AICreature : public Creature, public PaniAnimKeyListener {
AICreature(CreatureProp*);

virtual void collisionCallback(immut CollEvent&); // _A8
virtual void bounceCallback(); // _AC
virtual void refresh(Graphics&) = 0; // _EC
virtual void doKill() = 0; // _10C
virtual AState<AICreature>* getCurrState() { return mCurrentState; } // _120 (weak)
virtual void setCurrState(AState<AICreature>* state) { mCurrentState = state; } // _124 (weak)
virtual void playSound(int) { } // _128 (weak)
virtual void playEffect(int) { } // _12C (weak)
virtual void startMotion(int) { } // _130 (weak)
virtual void finishMotion() { } // _134 (weak)
virtual void finishMotion(f32) { } // _138 (weak)
virtual void startMotion(int, f32) { } // _13C (weak)
virtual immut char* getCurrentMotionName() { return "noname"; } // _140 (weak)
virtual f32 getCurrentMotionCounter() { return -123.4f; } // _144 (weak)
virtual f32 getMotionSpeed() { return -123.4f; } // _148 (weak)
virtual void setMotionSpeed(f32) { } // _14C (weak)
virtual void stopMotion() { } // _150 (weak)
virtual void animationKeyUpdated(immut PaniAnimKeyEvent&); // _154 (weak)
virtual void collisionCallback(immut CollEvent&); // _A8
virtual void bounceCallback(); // _AC
virtual void refresh(Graphics&) = 0; // _EC
virtual void doKill() = 0; // _10C
virtual AState<AICreature>* getCurrState() { return mSAICtx.mCurrentState; } // _120 (weak)
virtual void setCurrState(AState<AICreature>* state) { mSAICtx.mCurrentState = state; } // _124 (weak)
virtual void playSound(int) { } // _128 (weak)
virtual void playEffect(int) { } // _12C (weak)
virtual void startMotion(int) { } // _130 (weak)
virtual void finishMotion() { } // _134 (weak)
virtual void finishMotion(f32) { } // _138 (weak)
virtual void startMotion(int, f32) { } // _13C (weak)
virtual immut char* getCurrentMotionName() { return "noname"; } // _140 (weak)
virtual f32 getCurrentMotionCounter() { return -123.4f; } // _144 (weak)
virtual f32 getMotionSpeed() { return -123.4f; } // _148 (weak)
virtual void setMotionSpeed(f32) { } // _14C (weak)
virtual void stopMotion() { } // _150 (weak)
virtual void animationKeyUpdated(immut PaniAnimKeyEvent&); // _154 (weak)

void clearEventFlags();
void setEventFlag(int, bool);
Expand All @@ -50,19 +82,7 @@ struct AICreature : public Creature, public PaniAnimKeyListener {
// _00 = VTBL
// _00-_2B8 = Creature
// _2B8-_2BC = PaniAnimKeyListener
Creature* mCollidingCreature; // _2BC
Creature* mTargetCreature; // _2C0, 'target'?
Vector3f _2C4; // _2C4, could just be floats
int mCurrAnimId; // _2D0, to do with bombs
int mCounter; // _2D4, used to track stages of gates
f32 mCurrentItemHealth; // _2D8
f32 _2DC; // _2DC
f32 mMaxItemHealth; // _2E0
AState<AICreature>* mCurrentState; // _2E4
StateMachine<AICreature>* mStateMachine; // _2E8
int mCurrentEventCount; // _2EC
int mMaxEventCount; // _2F0
bool mEventFlags[16]; // _2F4
SAIContext mSAICtx; // _2BC
};

#endif
2 changes: 2 additions & 0 deletions include/Font.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ struct Texture;

/**
* @brief TODO
*
* @note Size: 0x1C.
*/
struct FontChar {
FontChar()
Expand Down
4 changes: 1 addition & 3 deletions include/SimpleAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "StateMachine.h"
#include "types.h"

#define C_SAI(obj) static_cast<SimpleAI*>(obj->mStateMachine)
#define C_SAI(obj) static_cast<SimpleAI*>(obj->mSAICtx.mStateMachine)

struct SAIEvent;

Expand Down Expand Up @@ -225,8 +225,6 @@ struct SimpleAI : public StateMachine<AICreature> {
void start(AICreature*, int);
void checkEvent(AICreature*);

inline SAIState* getState(int idx) { return static_cast<SAIState*>(mStates[idx]); }

// _00 = VTBL
// _00-_1C = StateMachine
};
Expand Down
6 changes: 5 additions & 1 deletion include/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,18 @@ struct Texture : public GfxObject {
virtual void makeResident() { } // _10 (weak)

u8 getAlpha(int x, int y);
u8 getRed(int x, int y);
void read(RandomAccessStream& input);
void createBuffer(int width, int height, int texFmt, void* buf);
void grabBuffer(int width, int height, bool doClear, bool useMIPmap);
void decodeData(TexImg* texImg);

// unused/inlined:
void offsetGLtoGX(int, int);
u8 getRed(int, int);
static void offsetGXtoGL(int, int, int, int);
void offsetGXtoGL(int, int);
void write(Stream*);
static void decodeS3TC(int, int, u8*, u8*);

// _00 = VTBL
u16 mTexFormat; // _04, see TexImgFormat enum
Expand Down
13 changes: 11 additions & 2 deletions include/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ enum {
WrongDisc = 5 // Non-Pikmin disc inserted
} END_ENUM_TYPE;

/**
* @brief FABRICATED - No other class we currently know of has a virtual table like this.
*/
struct System_Class_250 {
virtual void method(Graphics& gfx) = 0; // _00

// _00 = VTBL
};

/**
* @brief FABRICATED - Singly-linked list of symbolic information (See `ParseMapFile`)
*/
Expand Down Expand Up @@ -393,7 +402,7 @@ struct System : public StdSystem {
RandomAccessStream* createFile(immut char*, BOOL);

// unused/inlined:
void findAddress(u32);
immut char* findAddress(u32);
bool hasDebugInfo();
static void halt(immut char* file, int line, immut char* message);

Expand All @@ -411,7 +420,7 @@ struct System : public StdSystem {
u32 mHeapStart; // _244
u32 mHeapEnd; // _248
Graphics* mDGXGfx; // _24C, cast to DGXGraphics in DOL
u32 _250; // _250, unknown/unused - set to 0 by GameFlow::softReset.
System_Class_250* _250; // _250, a vestigial pointer related to `System::halt`
Delegate1<System, Graphics&>* mDvdErrorCallback; // _254
int mDvdErrorCode; // _258
u32 mDvdBufferSize; // _25C
Expand Down
4 changes: 2 additions & 2 deletions src/card/CARDFormat.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ s32 __CARDFormatRegionAsync(s32 chan, u16 encode, CARDCallback callback)

id = (CARDID*)card->workArea;
memset(id, 0xff, CARD_SYSTEM_BLOCK_SIZE);
viDTVStatus = __VIRegs[55];
viDTVStatus = __VIRegs[VI_DTV_STAT];

id->encode = encode;

Expand Down Expand Up @@ -148,7 +148,7 @@ s32 CARDFormatAsync(s32 channel, CARDCallback callback)

id = &card->workArea->header.id;
memset(id, 0xff, CARD_SYSTEM_BLOCK_SIZE);
viDTVStatus = __VIRegs[55];
viDTVStatus = __VIRegs[VI_DTV_STAT];

id->encode = OSGetFontEncode();

Expand Down
4 changes: 2 additions & 2 deletions src/jaudio/hvqm_play.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ int Jac_GetPicture(void* data, int* x, int* y)

if (playback_first_wait) {
*(int*)data = 0;
return TRUE;
return 1;
}

int frame = StreamGetCurrentFrame(0, 2);
Expand Down Expand Up @@ -604,7 +604,7 @@ int Jac_GetPicture(void* data, int* x, int* y)
StreamSyncStopAudio(0);
}
*(int*)data = 0;
return FALSE;
return 0;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/pad/Pad.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Dolphin/pad.h"
#include "Dolphin/hw_regs.h"
#include "Dolphin/os.h"
#include "Dolphin/vi.h"
#include <stddef.h>
Expand Down Expand Up @@ -33,7 +34,6 @@ static BOOL OnReset(BOOL f);

extern u16 __OSWirelessPadFixMode AT_ADDRESS(OS_BASE_CACHED | 0x30E0);
extern u8 GameChoice AT_ADDRESS(OS_BASE_CACHED | 0x30E3);
extern u16 DAT_CC00206C AT_ADDRESS(0xCC00206C); // Which hardware register?

static BOOL Initialized = FALSE;

Expand Down Expand Up @@ -1022,7 +1022,7 @@ void PADSetSamplingRate(u32 msec)
}
}
#if OS_BUILD_VERSION >= 20011002L
SISetXY(((DAT_CC00206C & 1) ? 2 : 1) * xy[msec].line, xy[msec].count);
SISetXY((__VIRegs[VI_CLOCK_SEL] & 1 ? 2u : 1u) * xy[msec].line, xy[msec].count);
#else
SISetXY(xy[msec].line, xy[msec].count);
#endif
Expand All @@ -1036,7 +1036,7 @@ void PADSetSamplingRate(u32 msec)

#if OS_BUILD_VERSION >= 20011002L && OS_BUILD_VERSION < 20011217L
/**
* @TODO: Documentation
* This implementation was moved to SISamplingRate.c (`SIRefreshSamplingRate`)
*/
void __PADRefreshSamplingRate(void)
{
Expand Down
2 changes: 1 addition & 1 deletion src/plugPikiColin/gameflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ void GameFlow::softReset()
PRINT("doing start load!\n");
gsys->startLoading(nullptr, true, 60);
}
gsys->_250 = 0;
gsys->_250 = nullptr;
mGameInterface = nullptr;
gsys->getHeap(SYSHEAP_Message)->inactivate();
mGameSection->init();
Expand Down
8 changes: 4 additions & 4 deletions src/plugPikiKando/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void Actor::setType(int /*unused*/, PikiShapeObject* shape, CreatureProp* props,

mPikiAnimMgr.startMotion(PaniMotionInfo(PIKIANIM_Wait, nullptr), PaniMotionInfo(PIKIANIM_Wait));

mStateMachine = ai;
mSAICtx.mStateMachine = ai;
}

/**
Expand All @@ -45,7 +45,7 @@ void Actor::setType(int /*unused*/, PikiShapeObject* shape, CreatureProp* props,
*/
void Actor::startAI(int state)
{
((SimpleAI*)mStateMachine)->start(this, state);
C_SAI(this)->start(this, state);
}

/**
Expand Down Expand Up @@ -94,8 +94,8 @@ void Actor::doAnimation()
*/
void Actor::doAI()
{
if (mStateMachine) {
mStateMachine->exec(this);
if (mSAICtx.mStateMachine) {
mSAICtx.mStateMachine->exec(this);
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/plugPikiKando/aiBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ void ActBridge::newInitWork()
mCollisionCount = 0;
_2A = 0;

if (mActionCounter) {
if (mActionCounter != 0) {
return;
}

Expand Down Expand Up @@ -543,16 +543,15 @@ int ActBridge::newExeWork()
return ACTOUT_Continue;
}

STACK_PAD_TERNARY(this, 3);

if (absF(xDist) > 0.3f * mBridge->getStageWidth()) {
STACK_PAD_STRUCT(2); // Vector3f unused(xVec); // This would be more accurate, but it makes the stack worse.
if (xDist < 0.0f) {
xVec.multiply(-1.0f);
}
zVec = zVec + xVec;
zVec.normalise();
}
mBridge->getStageDepth();
f32 unused = mBridge->getStageDepth(); // It looks like this unused result was stored in a variable in the DLL.
mPiki->setSpeed(0.5f, zVec);
return ACTOUT_Continue;
/*
Expand Down
10 changes: 5 additions & 5 deletions src/plugPikiKando/aiPut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ void ActPutBomb::initPut()
held->mVelocity.add(vel);
MsgUser msg(0);
BombItem* bomb = static_cast<BombItem*>(held);
static_cast<SimpleAI*>(bomb->mStateMachine)->procMsg(bomb, &msg);
C_SAI(bomb)->procMsg(bomb, &msg);
mAnimationFinished = false;
mState = STATE_Put;
}
Expand Down Expand Up @@ -368,10 +368,10 @@ int ActPutBomb::exeThrow()
InteractRelease release(mPiki, 1.0f);
Creature* held = mPiki->getHoldCreature();
held->stimulate(release);
held->mVelocity = throwVel;
held->mTargetVelocity = throwVel;
BombItem* bomb = static_cast<BombItem*>(held);
bomb->mCurrAnimId = 0;
held->mVelocity = throwVel;
held->mTargetVelocity = throwVel;
BombItem* bomb = static_cast<BombItem*>(held);
bomb->mSAICtx.mCurrAnimId = 0;
C_SAI(bomb)->start(bomb, BombAI::BOMB_Unk1);
bomb->disableFixPos();

Expand Down
6 changes: 3 additions & 3 deletions src/plugPikiKando/bombItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ BombItem::BombItem(CreatureProp* props, ItemShapeObject* shape, SimpleAI* ai)
{
mLifeGauge.mSnapToTargetHealth = true;
mItemShapeObject = shape;
mStateMachine = ai;
mSAICtx.mStateMachine = ai;
mLifeGauge.mRenderStyle = LifeGauge::Wheel;
}

Expand Down Expand Up @@ -142,7 +142,7 @@ void BombItem::update()
if (state != BombAI::BOMB_Die && state != BombAI::BOMB_Bomb && state != BombAI::BOMB_Mizu && mGroundTriangle
&& MapCode::getAttribute(mGroundTriangle) == ATTR_Water) {
PRINT("BOMB WATER START **********\n");
mStateMachine->transit(this, BombAI::BOMB_Mizu);
mSAICtx.mStateMachine->transit(this, BombAI::BOMB_Mizu);
}

if (state == BombAI::BOMB_Unk1 && mGroundTriangle) {
Expand All @@ -165,7 +165,7 @@ void BombItem::refresh2d(Graphics& gfx)
int state = getCurrState()->getID();

if (state == 2) {
mLifeGauge.updValue(mCurrentItemHealth, mMaxItemHealth);
mLifeGauge.updValue(mSAICtx.mCurrentItemHealth, mSAICtx.mMaxItemHealth);
mLifeGauge.mPosition = mSRT.t;
mLifeGauge.mScale = 5000.0f / gfx.mCamera->mNear;
mLifeGauge.refresh(gfx);
Expand Down
4 changes: 2 additions & 2 deletions src/plugPikiKando/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ void Creature::kill(bool)
if (ai->getCurrState()->getID() != 1) {
BombItem* bomb = static_cast<BombItem*>(held);
MsgUser msg(1);
bomb->mCurrAnimId = 1;
static_cast<SimpleAI*>(bomb->mStateMachine)->procMsg(bomb, &msg);
bomb->mSAICtx.mCurrAnimId = 1;
C_SAI(bomb)->procMsg(bomb, &msg);
}
}
}
Expand Down
Loading
Loading