Compare commits

...

1 Commits

Author SHA1 Message Date
devin
cf8a1fca82 memoryCard: link iplGCSaveData (objdiff 100% code+data)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-29 20:22:44 +00:00
9 changed files with 601 additions and 4 deletions

View File

@@ -815,7 +815,7 @@ config.libs = [
Object(NonMatching, "scene/memoryCard/iplMemoryCard.cpp"),
Object(NonMatching, "scene/memoryCard/iplMemoryCardBase.cpp"),
Object(NonMatching, "scene/memoryCard/iplMemoryCardManager.cpp"),
Object(NonMatching, "scene/memoryCard/iplGCSaveData.cpp"),
Object(Matching, "scene/memoryCard/iplGCSaveData.cpp"),
Object(NonMatching, "scene/memoryCard/iplGCWindow.cpp"),
]
),

View File

@@ -0,0 +1,68 @@
#ifndef IPL_MEMORY_CARD_LIB_H
#define IPL_MEMORY_CARD_LIB_H
#include <revolution/types.h>
namespace ipl {
namespace memorycard {
typedef struct FileInfo {
u16 fileNo; // 0x00
u16 size; // 0x02
u8 canCopy; // 0x04
u8 canMove; // 0x05
u16 unk_0x06; // 0x06
u32 key; // 0x08
} FileInfo; // 0x0C
typedef struct CardState {
vu8 unk_0x00; // 0x00
vu8 changed; // 0x01
vs16 state; // 0x02
vu16 unk_0x04; // 0x04
vu16 unk_0x06; // 0x06
vu32 key; // 0x08
vu16 unk_0x0C; // 0x0C
vu16 unk_0x0E; // 0x0E
vu16 freeBlocks; // 0x10
vu16 unk_0x12; // 0x12
} CardState; // 0x14
typedef struct IconState {
u8 bannerEnable; // 0x00
u8 unk_0x01; // 0x01
u8 unk_0x02; // 0x02
u8 bannerType; // 0x03
s8 anmDelta; // 0x04
u8 anmType; // 0x05
u8 unk_0x06; // 0x06
u8 unk_0x07; // 0x07
u8 iconFmt[8]; // 0x08
u16 anmFrameBits; // 0x10
s16 anmMax; // 0x12
u32 bannerOffset; // 0x14
u32 bannerTlutOffset; // 0x18
u32 iconOffset[8]; // 0x1C
u32 iconTlutOffset; // 0x3C
} IconState; // 0x40
void probeCard();
CardState* getCardSlotState();
FileInfo* getCardDirState();
IconState* getIconStateArray();
long getCardLastSendCmd();
long getCardLastSrcSlot();
long getCardLastCMDFCmdResult();
void sendCardFormatCmd(u8 slot);
void sendCardCopyCmd(u8 slot, s16 fileNo);
void sendCardMoveCmd(u8 slot, s16 fileNo);
void sendCardDeleteCmd(u8 slot, s16 fileNo);
const char* getIconComment(u8 slot, s16 fileNo);
void initCardThread();
bool shutdownCardThread();
} // namespace memorycard
} // namespace ipl
#endif // IPL_MEMORY_CARD_LIB_H

View File

@@ -8,15 +8,21 @@
#include <cstring>
#include "global/decomp/utils.h"
namespace ipl {
namespace gui {
class PaneComponent : public ::gui::PaneComponent {};
class PaneManager : public ::gui::PaneManager {
public:
#ifdef IPL_GCW_PANEMANAGER_CTOR_OUT_OF_LINE
PaneManager(::gui::EventHandler* event, const nw4r::lyt::DrawInfo* drawInfo, EGG::Heap* heap, EGG::Allocator* allocator, bool bDisableCon = false) NO_INLINE;
#else
PaneManager(::gui::EventHandler* event, const nw4r::lyt::DrawInfo* drawInfo, EGG::Heap* heap, EGG::Allocator* allocator, bool bDisableCon = false) :
::gui::PaneManager(event, allocator, drawInfo),
mpHeap(heap),
mbDisableCon(bDisableCon) {}
#endif
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
virtual ~PaneManager();

View File

@@ -7,6 +7,10 @@
#include "utility/iplFrameController.h"
#ifdef IPL_GCW_INTP_CTOR_OUT_OF_LINE
#include "global/decomp/utils.h"
#endif
namespace ipl {
namespace math {
template <typename T>
@@ -37,6 +41,9 @@ namespace ipl {
template <typename T>
class LinearIntp : public Interporation<T> {
public:
#ifdef IPL_GCW_INTP_CTOR_OUT_OF_LINE
LinearIntp() NO_INLINE;
#endif
#ifdef IPL_BOARD_OBJECT_INLINE_INTERPOLATION_DTORS
virtual ~LinearIntp();
#endif
@@ -50,6 +57,7 @@ namespace ipl {
T get2() const { return (((mStart * (mMaxFrame - mFrame)) + (mEnd * mFrame)) / mMaxFrame); }
};
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
template <typename T>
class __declspec(novtable) HermiteIntp : public utility::FrameController {

View File

@@ -0,0 +1,44 @@
#ifndef IPL_SCENE_GC_SAVE_DATA_H
#define IPL_SCENE_GC_SAVE_DATA_H
#include <nw4r/ut.h>
#include "scene/memoryCard/iplMemoryCardBase.h"
#include "math/iplMathTypes.h"
namespace ipl {
namespace scene {
class GCSaveData : public MemoryBase {
friend class MemoryCard;
public:
GCSaveData(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* directory, const char* fileName,
math::VEC3 translate);
virtual ~GCSaveData();
virtual void onPoint(const char* paneName, controller::Interface* controller);
virtual void onLeft(const char* paneName);
virtual void onTrig(const char* paneName);
void calc();
void draw();
void update();
void init();
void setTranslate(const nw4r::math::VEC3& translate);
const nw4r::math::VEC3* getTranslate();
void setBalloon(TextBalloon* balloon);
private:
MemoryBaseEvent* mpEvent; // 0x34
TextBalloon* mpBalloon; // 0x38
u8 mSlot; // 0x3C
s16 mIndex; // 0x3E
nw4r::ut::Link mLink; // 0x40
};
} // namespace scene
} // namespace ipl
#endif // IPL_SCENE_GC_SAVE_DATA_H

View File

@@ -3,14 +3,87 @@
#include "iplSceneHeader.h"
#include "scene/memoryCard/iplMemoryCardBase.h"
#include "scene/memoryCard/iplMemoryCardManager.h"
#include "math/iplMathTypes.h"
namespace ipl {
namespace scene {
SCENE_CLASS(MemoryCard) {
class GCSaveData;
class GCWindow;
class SavedataEditWindow;
class MemoryCard : public Base, public MemoryBase {
public:
MemoryCard(EGG::Heap * heap);
MemoryCard(EGG::Heap* heap);
virtual ~MemoryCard();
virtual BOOL isResetAcceptable() const;
virtual void prepare();
virtual void create();
virtual void calc();
virtual void draw();
virtual void onPoint(const char* paneName, controller::Interface* controller);
virtual void onLeft(const char* paneName);
virtual void onTrig(const char* paneName);
void onFocus(void* data);
void onRelease();
MemoryCardManager* getManager() { return mpManager; }
private:
u8 unk_0x54[0x7C];
enum {
SLOT_A = 0,
SLOT_B,
};
void on_fadein1st();
void on_fadein2nd();
void on_normal();
void on_scroll_r();
void on_scroll_l();
void on_change_tag1st();
void on_change_tag2nd();
void on_fadeout1st();
void on_fadeout2nd();
void on_error();
void on_insert_card();
void on_detach_card();
void start_savedata_fadein();
void start_savedata_fadeout();
void start_errormessage_fadein();
int update_slot();
void show_arw();
void show_capacity(u8 slot);
void scroll_common();
void start_scroll_r();
void start_scroll_l();
private:
s32 mState; // 0x88
s32 mPrevState; // 0x8C
u8 mSlot; // 0x90
u8 unk_0x91[3]; // 0x91
s32 mSlotState[2]; // 0x94
s16 mIconIndex; // 0x9C
s16 mIconCount; // 0x9E
u8 mShowArwR; // 0xA0
u8 mShowArwL; // 0xA1
u8 unk_0xA2[2]; // 0xA2
MemoryCardManager* mpManager; // 0xA4
MemoryBaseEvent* mpEvent; // 0xA8
nw4r::ut::List mSaveDataList; // 0xAC
nand::LayoutFile* mBalloonLayoutFile; // 0xB8
nw4r::ut::List mBalloonList; // 0xBC
GCSaveData* mpFocusSaveData; // 0xC8
GCWindow* mpGCWindow; // 0xCC
};
} // namespace scene
} // namespace ipl

View File

@@ -0,0 +1,144 @@
#ifndef IPL_SCENE_MEMORY_CARD_BASE_H
#define IPL_SCENE_MEMORY_CARD_BASE_H
#include <nw4r/ut.h>
#include "layout/iplLayout.h"
#include "layout/iplGuiManager.h"
#include "system/iplController.h"
namespace ipl {
namespace scene {
class TextBalloon;
class SettingButton;
class MemoryBase;
}
namespace nand {
class LayoutFile;
}
namespace scene {
class MemoryBaseEvent : public ::gui::EventHandler {
public:
#ifdef IPL_MEMORYCARD_BASE_EVENT_OUT_OF_LINE
MemoryBaseEvent(MemoryBase* base);
#else
MemoryBaseEvent(MemoryBase* base) : mpBase(base) {}
#endif
virtual ~MemoryBaseEvent();
virtual void onEvent(u32 componentID, u32 event, void* data);
private:
MemoryBase* mpBase; // 0x0C
};
class MemoryBase {
public:
class Anm {
public:
Anm(layout::GroupAnimator* anim) : mAnim(anim) {}
virtual ~Anm();
layout::GroupAnimator* mAnim; // 0x04
nw4r::ut::Link mLink; // 0x08
};
class Button {
public:
Button(nw4r::lyt::Pane* pane) : unk_0x04(0), mPane(pane) {}
virtual ~Button();
u32 unk_0x04; // 0x04
nw4r::lyt::Pane* mPane; // 0x08
nw4r::ut::Link mLink; // 0x0C
};
class AnmButton {
public:
AnmButton(const char* name, Anm* anm1, Anm* anm2, Anm* anm3)
: unk_0x04(0), mName(name), mCurrentAnm(NULL), mAnm1(anm1), mAnm2(anm2), mAnm3(anm3),
unk_0x24(0), mLastCmd(0), mpBalloon(NULL) {}
virtual ~AnmButton();
void calc();
void onCmdRecv(int command);
void setBalloon(TextBalloon* balloon);
int unk_0x04; // 0x04
const char* mName; // 0x08
Anm* mCurrentAnm; // 0x0C
Anm* mAnm1; // 0x10
Anm* mAnm2; // 0x14
Anm* mAnm3; // 0x18
nw4r::ut::Link mLink; // 0x1C
u32 unk_0x24; // 0x24
int mLastCmd; // 0x28
TextBalloon* mpBalloon; // 0x2C
};
struct AnmName {
const char* anmFile;
const char* groupName;
};
#ifdef IPL_MEMORYCARD_BASE_CTOR_OUT_OF_LINE
MemoryBase();
#else
MemoryBase() : mpLayout(NULL), unk_0x08(NULL) {
nw4r::ut::List_Init(&mAnmList, offsetof(Anm, mLink));
nw4r::ut::List_Init(&mButtonList, offsetof(Button, mLink));
nw4r::ut::List_Init(&mAnmButtonList, offsetof(AnmButton, mLink));
}
#endif
#ifdef IPL_MEMORYCARD_BASE_OUT_OF_LINE
virtual ~MemoryBase();
#else
virtual ~MemoryBase() {}
#endif
virtual void onPoint(const char* paneName, controller::Interface* controller);
virtual void onLeft(const char* paneName);
virtual void onMove(const char* paneName);
virtual void onTrig(const char* paneName);
virtual void add_button(const char** paneNames, int count);
virtual void add_anmbutton(const char* paneName, Anm* anm1, Anm* anm2, Anm* anm3);
virtual Button* get_button(const char* paneName);
virtual AnmButton* get_anmbutton(const char* paneName);
virtual void clear_button(const char* paneName);
virtual void add_animation(const AnmName* anmNames, int count);
virtual Anm* get_animation(int index);
virtual void do_animation(int index);
virtual void do_animation(int index, bool flag);
virtual void stop_animation(int index);
virtual bool is_animation(int index);
virtual bool is_fadein_enable();
virtual void set_visible(const char* paneName, bool flag);
void set_textbox(const char* paneName, u32 message);
void set_textbox(const char* paneName, u32 message, int x, int y);
void set_textbox(const char* paneName, const wchar_t* text, f32 x, f32 y);
void set_textbox(const char* paneName, const wchar_t* text);
SettingButton* get_setting_button();
void change_button_text_close();
void change_button_text_return();
void change_button_text_ok();
void show_button_return();
void show_button_ok();
protected:
layout::Object* mpLayout; // 0x04
nand::LayoutFile* unk_0x08; // 0x08
gui::PaneManager* mpPaneManager; // 0x0C
nw4r::ut::List mAnmList; // 0x10
nw4r::ut::List mButtonList; // 0x1C
nw4r::ut::List mAnmButtonList; // 0x28
};
} // namespace scene
} // namespace ipl
#endif // IPL_SCENE_MEMORY_CARD_BASE_H

View File

@@ -0,0 +1,107 @@
#ifndef IPL_SCENE_MEMORY_CARD_MANAGER_H
#define IPL_SCENE_MEMORY_CARD_MANAGER_H
#include <revolution/types.h>
#include <revolution/gx.h>
#include <private/card.h>
#include <wchar.h>
#include "iplMemoryCardLib.h"
namespace ipl {
namespace scene {
class MemCardEventHandler {
public:
MemCardEventHandler() {}
virtual ~MemCardEventHandler();
virtual void onMemEvent(long event, u8 slot);
};
typedef struct MCFile {
u32 fileNo; // 0x00
u32 unk_0x04; // 0x04
u32 unk_0x08; // 0x08
s32 sortKey; // 0x0C
} MCFile; // 0x10
typedef struct MCFileCell {
wchar_t comment[2][0x40]; // 0x000
s16 iconAnmCounter; // 0x100
u16 unk_0x102; // 0x102
GXTexObj icon; // 0x104
GXTexObj banner; // 0x124
GXTlutObj iconTlut; // 0x144
GXTlutObj bannerTlut; // 0x150
} MCFileCell; // 0x15C
class MemoryCardManager {
public:
MemoryCardManager() {
MCFileCell* pCell = mFileCell[0];
do {
pCell->iconAnmCounter = 0;
wmemset(pCell->comment[0], 0, 0x40);
pCell++;
} while (pCell < mFileCell[2]);
mLastResult = 0;
mLastCmd = 0;
__CARDSetDiskID(NULL);
memorycard::initCardThread();
sort_file_array(0);
sort_file_array(1);
}
virtual ~MemoryCardManager();
void calc();
bool isSlotReady(u8 slot);
bool isSlotNoCard(u8 slot);
long isSlotWrongDevice(u8 slot);
void sort_file_array(u8 slot);
void sendCardCmdMove(u8 slot, s16 index);
void sendCardCmdCopy(u8 slot, s16 index);
void sendCardCmdDelete(u8 slot, s16 index);
void sendCardCmdFormat(u8 slot);
bool isDistSlot(u8 slot, long* pState);
bool isMoveEnable(u8 slot, u32 index, long* pCode);
bool isCopyEnable(u8 slot, u32 index, long* pCode);
bool isIconValidate(u8 slot, s16 index);
bool isBannerEnable(u8 slot, s16 index);
void update_icon_anm();
void update_file_array(u8 slot);
void update_change_cardstate(u8 slot);
GXTexObj* create_icon(u8 slot, s16 index);
GXTexObj* create_icon(u8 slot, s16 index, long start);
GXTexObj* _create_icon(u8 slot, s16 fileNo, long start);
const wchar_t* getComment(u8 slot, s16 index, int which);
GXTexObj* create_banner(u8 slot, s16 index);
u16 getBlocks(u8 slot, s16 index);
u16 getFreeBlocks(u8 slot);
void setEventHandler(MemCardEventHandler* eventHandler) {
mpEventHandler = eventHandler;
}
private:
u32 unk_0x04; // 0x00004
MCFile mFile[2][0x7F]; // 0x00008
MCFileCell mFileCell[2][0x7F]; // 0x00FE8
s32 mLastResult; // 0x16930
s32 mLastCmd; // 0x16934
u32 unk_0x16938; // 0x16938
MemCardEventHandler* mpEventHandler; // 0x1693C
};
} // namespace scene
} // namespace ipl
#endif // IPL_SCENE_MEMORY_CARD_MANAGER_H

View File

@@ -0,0 +1,147 @@
#define IPL_CHANNEL_TITLE_NOVTABLE
#include "scene/memoryCard/iplGCSaveData.h"
#include "scene/memoryCard/iplMemoryCard.h"
#include "scene/textBalloon/iplBalloon.h"
#include "iplSound.h"
#include "iplSystem.h"
#undef IPL_CHANNEL_TITLE_NOVTABLE
namespace ipl {
namespace scene {
static const MemoryBase::AnmName scAnmName[] = {
{"it_ObjCubeEdit_b_SaveDataIn.brlan", "G_Data"},
{"it_ObjCubeEdit_b_SaveDataOut.brlan", "G_Data"},
{"it_ObjCubeEdit_b_SaveDataFoucusIn.brlan", "G_Data"},
{"it_ObjCubeEdit_b_SaveDataFoucusOut.brlan", "G_Data"},
{"it_ObjCubeEdit_b_SaveDataFlash.brlan", "G_DataFlash"},
};
extern "C" const char* lbl_81696CA8 = "B_Data_00";
GCSaveData::GCSaveData(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* directory, const char* fileName,
math::VEC3 translate) {
mpBalloon = NULL;
mpLayout = new layout::Object(heap, layoutFile, directory, fileName);
add_animation(scAnmName, 5);
mpLayout->finishBinding();
mpEvent = new MemoryBaseEvent(this);
mpPaneManager = new gui::PaneManager(mpEvent, mpLayout->getDrawInfo(), NULL, NULL, true);
mpPaneManager->setupScene(mpLayout);
mpPaneManager->setAllComponentTriggerTarget(false);
mpPaneManager->setTriggerTarget(mpLayout->FindPaneByName(lbl_81696CA8), true);
add_anmbutton(lbl_81696CA8, get_animation(2), get_animation(3), NULL);
setTranslate(translate);
}
void GCSaveData::calc() {
mpLayout->calc();
mpPaneManager->calc();
get_anmbutton(lbl_81696CA8)->calc();
}
void GCSaveData::draw() {
nw4r::lyt::Pane* pane = mpLayout->FindPaneByName("DataBanner_00");
nw4r::lyt::Material* material = pane->FindMaterialByName("DataBanner_00");
pane->SetVisible(true);
if (static_cast<MemoryCard*>(System::getScene(0xE))->getManager()->isIconValidate(mSlot, mIndex) &&
static_cast<MemoryCard*>(System::getScene(0xE))->getManager()->create_icon(mSlot, mIndex) != NULL) {
material->SetTexture(0, *static_cast<MemoryCard*>(System::getScene(0xE))
->getManager()
->create_icon(mSlot, mIndex));
} else {
pane->SetVisible(false);
}
if (mIndex >= 0 && mIndex < 0x7f) {
mpLayout->draw();
} else {
if (mpBalloon != NULL) {
mpBalloon->terminate();
}
}
}
void GCSaveData::update() {
if (mIndex < 0) {
return;
}
if (mIndex >= 0x7f) {
return;
}
mpPaneManager->update();
}
void GCSaveData::onPoint(const char* paneName, controller::Interface* controller) {
AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 0) {
if (System::getScene(0xE) != NULL) {
if (static_cast<MemoryCard*>(System::getScene(0xE))
->getManager()
->isIconValidate(mSlot, mIndex)) {
mpBalloon->init(static_cast<MemoryCard*>(System::getScene(0xE))
->getManager()
->getComment(mSlot, mIndex, 0),
0);
get_anmbutton(lbl_81696CA8)->setBalloon(mpBalloon);
} else {
get_anmbutton(lbl_81696CA8)->setBalloon(NULL);
}
}
snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING");
if (controller != NULL) {
controller->rumble(0);
}
button->onCmdRecv(1);
}
button->unk_0x04++;
}
}
void GCSaveData::onLeft(const char* paneName) {
AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 1) {
button->onCmdRecv(2);
}
button->unk_0x04--;
}
}
void GCSaveData::onTrig(const char* paneName) {
if (static_cast<MemoryCard*>(System::getScene(0xE)) != NULL &&
static_cast<MemoryCard*>(System::getScene(0xE))->getManager()->isIconValidate(mSlot, mIndex) &&
get_anmbutton(paneName) != NULL) {
static_cast<MemoryCard*>(System::getScene(0xE))->onFocus(this);
}
}
void GCSaveData::setTranslate(const nw4r::math::VEC3& translate) {
mpLayout->FindPaneByName("N_Data_00")->SetTranslate(translate);
}
const nw4r::math::VEC3* GCSaveData::getTranslate() {
return &mpLayout->FindPaneByName("N_Data_00")->GetTranslate();
}
void GCSaveData::init() {
clear_button(lbl_81696CA8);
if (mpBalloon != NULL) {
mpBalloon->terminate();
}
}
void GCSaveData::setBalloon(TextBalloon* balloon) {
mpBalloon = balloon;
}
GCSaveData::~GCSaveData() {}
} // namespace scene
} // namespace ipl