Skip to content

Commit

Permalink
blessings of Colin Reed upon ye
Browse files Browse the repository at this point in the history
progress on cardutil, gamePrefs, memoryCard, moviePlayer, movSample, and plugPiki
  • Loading branch information
PikHacker committed Jan 15, 2025
1 parent 0a6a0f1 commit 04dd284
Show file tree
Hide file tree
Showing 21 changed files with 1,130 additions and 882 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ orig/*/*
*.o
*.map
*.MAP
*.bat

# Build files
build/
Expand Down
22 changes: 20 additions & 2 deletions include/CardUtil.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef _CARDUTIL_H
#define _CARDUTIL_H

#include "Dolphin/OS/OSThread.h"
#include "Dolphin/OS/OSMutex.h"
#include "Dolphin/card.h"
#include "types.h"

struct CARDStat;
Expand All @@ -12,11 +15,26 @@ struct CardUtilDirent {
// TODO: members
};

struct CardUtilThread {
OSThread mThread; // _00
};

struct CardUtilControl {
OSMutex mMutex; // _00
OSCond mCondition;
int mChannel;
int mCommand;
int test[1];
int mFileId;
int test2[8];
OSMutex mMutex2;
};

// Global CARD utility functions:
void CardUtilResultCode();
int CardUtilResultCode();
void CardUtilMount(s32, void*);
void CardUtilUnmount(s32);
void CardUtilIsCardBusy();
bool CardUtilIsCardBusy();
void CardUtilIdleWhileBusy();
void CardUtilErase(s32, s32);
void CardUtilOpen(s32, s32, void*);
Expand Down
2 changes: 2 additions & 0 deletions include/CinematicPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ struct CinematicPlayer {
void addScene(char*);

// TODO: members
u32 _00; // _00
u8 _04[0x2e4]; // _04
};

#endif
2 changes: 2 additions & 0 deletions include/Dolphin/card.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ void CARDInit();
// CARD checking functions.
s32 CARDCheck(s32 channel);
s32 CARDCheckExAsync(s32 channel, s32* xferBytes, CARDCallback callback);
s32 CARDCheckAsync(s32 channel, CARDCallback);

// CARD BIOS functions.
s32 CARDGetResultCode(s32 channel);
Expand All @@ -243,6 +244,7 @@ s32 CARDFormat(s32 channel);

// CARD open/close.
s32 CARDOpen(s32 channel, char* fileName, CARDFileInfo* fileInfo);
s32 CARDFastOpen(s32 channel, s32 fileNo, CARDFileInfo* fileInfo);
s32 CARDClose(CARDFileInfo* fileInfo);

// CARD create/read/write functions.
Expand Down
1 change: 1 addition & 0 deletions include/EffectMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ struct EffectMgr : public CoreNode {
// _00 = VTBL
// _00-_14 = CoreNode
zen::particleManager mPtclMgr; // _14
u8 _18[0x600]; // _18
};

extern EffectMgr* effectMgr;
Expand Down
52 changes: 31 additions & 21 deletions include/MemoryCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ struct MemoryCard : public CoreNode {
inline MemoryCard()
: CoreNode("memoryCard")
{
_3C = -1;
_34 = -1;
_38 = -1;
_40 = 0x26000;
_44 = 0;
_3C = -1;
_34 = -1;
_38 = -1;
_40 = 0x26000;
mErrorCode = 0;
}

void getOptionsOffset(int);
void getGameFileOffset(int);
void calcChecksum(void*, u32);
int getOptionsOffset(int);
int getGameFileOffset(int);
u32 calcChecksum(void*, u32);
bool hasCardFinished();
void attemptFormatCard(int);
void waitWhileBusy(int);
void getCardStatus(int);
bool attemptFormatCard(int);
int waitWhileBusy(int);
bool getCardStatus(int);
void checkUseFile();
void getMemoryCardState(bool);
int getMemoryCardState(bool);
void loadCurrentFile();
void getNewestOptionsIndex();
int getNewestOptionsIndex();
void loadOptions();
void saveOptions();
void loadCurrentGame();
Expand All @@ -57,10 +57,10 @@ struct MemoryCard : public CoreNode {
void makeDefaultFile();
void copyFile(CardQuickInfo&, CardQuickInfo&);
void delFile(CardQuickInfo&);
void doFormatCard();
int doFormatCard();
bool isCardInserted();
bool hasCardChanged();
void getOkSections();
int getOkSections();
bool isFileBroken();
void repairFile();
bool didSaveFail();
Expand All @@ -85,12 +85,22 @@ struct MemoryCard : public CoreNode {

// _00 = VTBL
// _00-_14 = CoreNode
u8 _14[0x34 - 0x14]; // _14, unknown
int _34; // _34
int _38; // _38
int _3C; // _3C
u32 _40; // _40
u32 _44; // _44, unknown
char mFilePath[32]; // _14
int _34; // _34
int _38; // _38
int _3C; // _3C
u32 _40; // _40
u32 mErrorCode; // _44
u32 _48; // _48
u32 _4C; // _4C
u32 _50; // _50
u32 _54; // _54
u32 _58; // _58
u32 _5C; // _5C
u32 _60; // _60
u32 _64; // _64
bool _68; // _68
int _6C; // _6C
};

#endif
52 changes: 50 additions & 2 deletions include/MovSampleSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@

#include "types.h"
#include "Section.h"
#include "Controller.h"
#include "jaudio/interface.h"
#include "system.h"
#include "gameflow.h"

u16 ImgW;
u16 ImgH;
OSThread playbackThread;
bool finishPlayback;

static void* playbackFunc(void*);

/**
* @brief TODO
*
* @note Size: 0x20.
*/
struct MovSampleSection : public Section {
MovSampleSection() { }

virtual void init(); // _30

// _00 = VTBL
Expand All @@ -20,14 +33,49 @@ struct MovSampleSection : public Section {
* @brief TODO
*/
struct MovSampleSetupSection : public Node {
MovSampleSetupSection()
{
mName = "MovSample section";
mControl = new Controller;
_28 = 0xa0;
_30 = 0;
gsys->setFade(1.0f, 3.0f);

static char* movieNames[6] = { "../MovieData/cntA_S.h4m", "../MovieData/cntB_S.h4m", "../MovieData/cntC_S.h4m",
"../MovieData/cntD_S.h4m", "../MovieData/sr_S.h4m", "../MovieData/srhp_S.h4m" };
int size = 0xe00000;
u8* store = new u8[size];
Jac_StreamMovieInit(movieNames[gameflow._2B0], store, size);
ImgW = 640;
ImgH = 480;
_48[0] = new u8[0x70800];
_48[1] = new u8[0x70800];
for (int i = 0; i < 2; i++) {
memset(_48[i], 0x10, ImgW * ImgH);
memset(_48[i + ImgW * ImgH], 0x10, (ImgW * 2) * (ImgH * 2) * 2);
}
OSCreateThread(&playbackThread, playbackFunc, 0, 0, 0x1000, 0x14, 1);
finishPlayback = false;
OSResumeThread(&playbackThread);
}

virtual void update(); // _10 (weak)
virtual void draw(Graphics&); // _14 (weak)

// void movieNames$localstatic0$__ct(); // work out what the hell this is later

// _00 = VTBL
// _00-_20 = Node
// TODO: members
int _20; // _20
int _24; // _24
int _28; // _28
Controller* mControl; // _2C
int _30; // _30
int _34; // _34
int _38; // _38
int _3C; // _3C
int _40; // _40
int _44; // _44
u8* _48[2]; // _48
};

// Global functions:
Expand Down
33 changes: 29 additions & 4 deletions include/MoviePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "types.h"
#include "CoreNode.h"
#include "CinematicPlayer.h"

struct Creature;
struct Graphics;
Expand All @@ -12,6 +13,11 @@ struct Vector3f;
* @brief TODO
*/
struct MovieInfo : public CoreNode {
MovieInfo()
: CoreNode("")
{
mCin = nullptr;
}

// unused/inlined:
void update();
Expand All @@ -20,7 +26,9 @@ struct MovieInfo : public CoreNode {

// _00 = VTBL
// _00-_14 = CoreNode
// TODO: members
u32 mMovieIndex; // _14
CinematicPlayer* mCin; // _18
u8 _1C[0x44]; // _1C
};

/**
Expand Down Expand Up @@ -52,9 +60,26 @@ struct MoviePlayer {
void nextFrame();
void backFrame();

u8 _00[0x124]; // _00, unknown
u8 mIsActive; // _124
u8 _125[0x174 - 0x125]; // _125, unknown
MovieInfo mInfoRoot; // _00
MovieInfo mInfoRoot2; // _60
MovieInfo mInfoRoot3; // _C0
int _120; // _120
u8 mIsActive; // _124
u8 _125; // _125
f32 _128; // _128
Vector3f _12C; // _12C
Vector3f mLookAtPos; // _138
f32 _144; // _144
f32 _148; // _148
f32 _14C; // _14C
f32 _150; // _150
f32 _154; // _154
f32 _158; // _158
f32 _15C; // _15C
f32 _160; // _160
f32 _164; // _164
f32 _168; // _168
bool _16C; // _16C
};

#endif
2 changes: 1 addition & 1 deletion include/PlayerState.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ struct PlayerState {
void getRestParts();
void lostUfoParts(u32);

inline bool is184(u32 flag) { return _184 & (1 << flag); }
inline bool hasPiki(u32 flag) { return _184 & (1 << flag); }

static int totalUfoParts;

Expand Down
15 changes: 11 additions & 4 deletions include/gameflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ enum LanguageFileType {
LANGFILE_COUNT, // 5
};

struct GameChalQuickInfo {
int mOffset; // _00
int _04; // _04
int _08; // _08
int mInfo[5]; // _0C
};

/**
* @brief TODO
*
Expand Down Expand Up @@ -266,7 +273,7 @@ struct GamePrefs : public CoreNode {

void Initialise()
{
_18 = 3;
mFlags = 3;
mBgmVol = 8;
mSfxVol = 8;
_108 = 0;
Expand All @@ -291,7 +298,7 @@ struct GamePrefs : public CoreNode {
// _00 = VTBL
// _00-_14 = CoreNode
bool mIsChanged; // _14
int _18; // _18
int mFlags; // _18
u8 mBgmVol; // _1C
u8 mSfxVol; // _1D
u8 mHasSaveGame; // _1E
Expand Down Expand Up @@ -377,7 +384,6 @@ struct GameFlow : public Node {
// _00-_20 = Node
GamePrms* mParameters; // _20
MemoryCard mMemoryCard; // _24
u8 _6C[0x94 - 0x6C]; // _6C
GamePrefs mGamePrefs; // _94
u32 mSaveGameCrc; // _1A0
PlayState mPlayState; // _1A4
Expand All @@ -386,7 +392,8 @@ struct GameFlow : public Node {
u32 _1D4; // _1D4, unknown
u32 _1D8; // _1D8, bitflag of some description
MoviePlayer* mMoviePlayer; // _1DC
u8 _1E0[0x1E8 - 0x1E0]; // _1E0, unknown
u8 _1E0; // _1E0
u32 _1E4; // _1E4
GameInterface* _1E8; // _1E8
int _1EC; // _1EC
int mGameSectionID; // _1F0, see GameSectionID enum
Expand Down
8 changes: 4 additions & 4 deletions include/jaudio/PikiDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" {

//////////// JAUDIO PIKMIN DEMO FUNCTIONS (C) ////////////
void Jac_DemoSceneInit(void); // args
void Jac_StartDemo(void); // args
void Jac_StartDemo(int); // args
void Jac_DemoSound(void); // args
void Jac_DemoFrame(void); // args
void Jac_FinishDemo(void); // args
Expand All @@ -29,9 +29,9 @@ void Jac_StartPartsFindDemo(u32 p1, int p2); // unsure on first arg
void Jac_FinishPartsFindDemo(void); // args
void Jac_StartTextDemo(void); // args
void Jac_FinishTextDemo(void); // args
void Jac_SetDemoPartsID(void); // args
void Jac_SetDemoOnyons(void); // args
void Jac_SetDemoPartsCount(void); // args
void Jac_SetDemoPartsID(int); // args
void Jac_SetDemoOnyons(int); // args
void Jac_SetDemoPartsCount(int); // args

/////////////////////////////////////////////////////////

Expand Down
5 changes: 4 additions & 1 deletion include/jaudio/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ extern "C" {
#endif // ifdef __cplusplus

//////////// JAUDIO GLOBAL INTERFACE FUNCTIONS ////////////
void Jac_OutputMode(void); // args
void Jac_OutputMode(int mode); // args
void Jac_SetBGMVolume(u8 vol);
void Jac_SetSEVolume(u8 vol);
void Jac_Gsync();
void Jac_SetProcessStatus(u32 processStat);
void Jac_StreamMovieUpdate();
void Jac_StreamMovieInit(const char* path, u8*, int);
void Jac_StreamMovieGetPicture();

#ifdef __cplusplus
};
Expand Down
Loading

0 comments on commit 04dd284

Please sign in to comment.