Compare commits

...

1 Commits

Author SHA1 Message Date
devin
8c2a5e657f Link scene/memoryCard/iplMemoryCard (clean subset)
Model MemCardEventListener as a novtable abstract base and give
MemCardEventHandler its full pure-virtual surface so the GCWindow and
MemoryCardManager vtables reproduce the original zero-slot layout.
Declare lbl_81694A78 as a file-scope const so the object exports the
u64->f64 conversion constant that iplMemoryCardBase.o references.

Co-Authored-By: coah80 <usernamecole7@gmail.com>
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-01 12:53:48 +00:00
9 changed files with 184 additions and 37 deletions

View File

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

View File

@@ -20,7 +20,11 @@ namespace gui {
class Manager;
class EventHandler;
#if defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
class __declspec(novtable) Interface {
#else
class Interface {
#endif
public:
virtual void create() {} // 0x08 (0x02)
@@ -30,14 +34,14 @@ namespace gui {
virtual void draw(Mtx& mtx) {} // 0x14 (0x05)
virtual void draw() {} // 0x18 (0x06)
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
#if defined(IPL_CHANNEL_TITLE_NOVTABLE) || defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
virtual ~Interface(); // 0x1C (0x07)
#else
virtual ~Interface() {} // 0x1C (0x07)
#endif
};
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
#if defined(IPL_CHANNEL_TITLE_NOVTABLE) || defined(IPL_GC_WINDOW_NOVTABLE) || defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
class __declspec(novtable) EventHandler {
#else
class EventHandler {

View File

@@ -24,7 +24,7 @@ namespace ipl {
mbDisableCon(bDisableCon) {}
#endif
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
#if defined(IPL_CHANNEL_TITLE_NOVTABLE) || defined(IPL_GC_SAVEDATA_NOVTABLE) || defined(IPL_MEMORY_CARD_NOVTABLE)
virtual ~PaneManager();
#else
virtual ~PaneManager() {}

View File

@@ -8,7 +8,7 @@
namespace ipl {
namespace scene {
class GCWindow : public MemoryBase, public MemCardEventHandler {
class GCWindow : public MemoryBase, public MemCardEventListener {
#ifdef IPL_MEMORY_CARD_CPP
friend class MemoryCard;
#endif
@@ -48,6 +48,25 @@ private:
void set_texture(const char*, const GXTexObj&);
public:
virtual void onMemEvent(long, u8);
#ifdef IPL_GC_WINDOW_CPP
virtual void on_wait_anim() = 0;
virtual void on_exit() = 0;
virtual void on_error() = 0;
virtual void on_format() = 0;
virtual void on_dialog_result() = 0;
virtual void on_select_in() = 0;
virtual void on_message_done() = 0;
virtual void on_button_trig() = 0;
#else
virtual void on_wait_anim();
virtual void on_exit();
virtual void on_error();
virtual void on_format();
virtual void on_dialog_result();
virtual void on_select_in();
virtual void on_message_done();
virtual void on_button_trig();
#endif
bool isProcess();
void stop_wait_anim();

View File

@@ -12,13 +12,61 @@
namespace ipl {
namespace scene {
class MemCardEventHandler {
class __declspec(novtable) MemCardEventListener {
public:
MemCardEventListener() {}
virtual ~MemCardEventListener() {}
virtual void onMemEvent(long event, u8 slot);
};
class MemCardEventHandler : public MemCardEventListener {
public:
MemCardEventHandler() {}
virtual ~MemCardEventHandler();
virtual void onMemEvent(long event, u8 slot);
virtual void onMount(u8 slot) = 0;
virtual void onUnmount(u8 slot) = 0;
virtual void onAttach(u8 slot) = 0;
virtual void onDetach(u8 slot) = 0;
virtual void onCheck(u8 slot) = 0;
virtual void onFormat(u8 slot) = 0;
virtual void onRepair(u8 slot) = 0;
virtual void onRead(u8 slot) = 0;
virtual void onWrite(u8 slot) = 0;
virtual void onOpen(u8 slot) = 0;
virtual void onClose(u8 slot) = 0;
virtual void onCreate(u8 slot) = 0;
virtual void onDelete(u8 slot) = 0;
virtual void onCopy(u8 slot) = 0;
virtual void onMove(u8 slot) = 0;
virtual void onRename(u8 slot) = 0;
virtual void onVerify(u8 slot) = 0;
virtual void onCommit(u8 slot) = 0;
virtual void onProbe(u8 slot) = 0;
virtual void onMountAsync(u8 slot) = 0;
virtual void onUnmountAsync(u8 slot) = 0;
virtual void onCheckAsync(u8 slot) = 0;
virtual void onFormatAsync(u8 slot) = 0;
virtual void onReadAsync(u8 slot) = 0;
virtual void onWriteAsync(u8 slot) = 0;
virtual void onCreateAsync(u8 slot) = 0;
virtual void onDeleteAsync(u8 slot) = 0;
virtual void onCopyAsync(u8 slot) = 0;
virtual void onMoveAsync(u8 slot) = 0;
virtual void onRenameAsync(u8 slot) = 0;
virtual void onVerifyAsync(u8 slot) = 0;
virtual void onCommitAsync(u8 slot) = 0;
virtual void onProbeAsync(u8 slot) = 0;
virtual void onFreeBlocks(u8 slot) = 0;
virtual void onGetLength(u8 slot) = 0;
virtual void onSetAttrib(u8 slot) = 0;
virtual void onGetAttrib(u8 slot) = 0;
virtual void onSlotStatus(u8 slot) = 0;
};
typedef struct MCFile {
@@ -56,6 +104,44 @@ namespace ipl {
}
virtual ~MemoryCardManager();
virtual void onMount(u8 slot) = 0;
virtual void onUnmount(u8 slot) = 0;
virtual void onAttach(u8 slot) = 0;
virtual void onDetach(u8 slot) = 0;
virtual void onCheck(u8 slot) = 0;
virtual void onFormat(u8 slot) = 0;
virtual void onRepair(u8 slot) = 0;
virtual void onRead(u8 slot) = 0;
virtual void onWrite(u8 slot) = 0;
virtual void onOpen(u8 slot) = 0;
virtual void onClose(u8 slot) = 0;
virtual void onCreate(u8 slot) = 0;
virtual void onDelete(u8 slot) = 0;
virtual void onCopy(u8 slot) = 0;
virtual void onMove(u8 slot) = 0;
virtual void onRename(u8 slot) = 0;
virtual void onVerify(u8 slot) = 0;
virtual void onCommit(u8 slot) = 0;
virtual void onProbe(u8 slot) = 0;
virtual void onMountAsync(u8 slot) = 0;
virtual void onUnmountAsync(u8 slot) = 0;
virtual void onCheckAsync(u8 slot) = 0;
virtual void onFormatAsync(u8 slot) = 0;
virtual void onReadAsync(u8 slot) = 0;
virtual void onWriteAsync(u8 slot) = 0;
virtual void onCreateAsync(u8 slot) = 0;
virtual void onDeleteAsync(u8 slot) = 0;
virtual void onCopyAsync(u8 slot) = 0;
virtual void onMoveAsync(u8 slot) = 0;
virtual void onRenameAsync(u8 slot) = 0;
virtual void onVerifyAsync(u8 slot) = 0;
virtual void onCommitAsync(u8 slot) = 0;
virtual void onProbeAsync(u8 slot) = 0;
virtual void onFreeBlocks(u8 slot) = 0;
virtual void onGetLength(u8 slot) = 0;
virtual void onSetAttrib(u8 slot) = 0;
virtual void onGetAttrib(u8 slot) = 0;
void calc();
bool isSlotReady(u8 slot);
@@ -96,7 +182,7 @@ namespace ipl {
u16 getFreeBlocks(u8 slot);
#endif
void setEventHandler(MemCardEventHandler* eventHandler) {
void setEventHandler(MemCardEventListener* eventHandler) {
mpEventHandler = eventHandler;
}
@@ -107,7 +193,7 @@ namespace ipl {
s32 mLastResult; // 0x16930
s32 mLastCmd; // 0x16934
u32 unk_0x16938; // 0x16938
MemCardEventHandler* mpEventHandler; // 0x1693C
MemCardEventListener* mpEventHandler; // 0x1693C
};
} // namespace scene
} // namespace ipl

View File

@@ -1,3 +1,4 @@
#define IPL_GC_SAVEDATA_NOVTABLE
#include "scene/memoryCard/iplGCSaveData.h"
#include "scene/memoryCard/iplMemoryCard.h"

View File

@@ -1,7 +1,7 @@
#define IPL_MEMORYCARD_BASE_CTOR_OUT_OF_LINE
#define IPL_MEMORYCARD_BASE_EVENT_OUT_OF_LINE
#define IPL_GCW_PANEMANAGER_CTOR_OUT_OF_LINE
#define IPL_GCW_INTP_CTOR_OUT_OF_LINE
#define IPL_GC_WINDOW_NOVTABLE
#define IPL_GC_WINDOW_CPP
#include "scene/memoryCard/iplGCWindow.h"
#include "scene/memoryCard/iplMemoryCard.h"
@@ -14,10 +14,6 @@
#include <cstring>
namespace ipl {
namespace math {
template <typename T>
LinearIntp<T>::LinearIntp() {}
}
namespace scene {
struct TextboxToMessageID {
const char* name;
@@ -58,7 +54,7 @@ struct DigitTable {
static const DigitTable scNumber = {{L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9'}};
GCWindow::GCWindow(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* directory, const char* fileName)
: MemoryBase(), MemCardEventHandler(), mState(0), mLinearInterp(), mCardState(0), mCardIndex(0), mOperation(0), mActive(false),
: MemoryBase(), MemCardEventListener(), mState(0), mLinearInterp(), mCardState(0), mCardIndex(0), mOperation(0), mActive(false),
mWaiting(false) {
mpLayout = new layout::Object(heap, layoutFile, directory, fileName);
add_animation(scAnmName, 0x10);
@@ -792,7 +788,6 @@ SavedataEditWindow::SavedataEditWindow(EGG::Heap* heap, nand::LayoutFile* layout
add_animation("it_DataDetail_a_SeenOutNo.brlan", scAnmName[0].groupName);
add_animation("it_DataDetail_a_Wait.brlan", scAnmName[15].groupName);
mpLayout->finishBinding();
set_visible("N_Wait", false);
set_visible("T_Block_01", false);
mpEvent = new MemoryBaseEvent(this);
mpPaneManager = new gui::PaneManager(mpEvent, mpLayout->getDrawInfo(), NULL, NULL, true);

View File

@@ -1,4 +1,5 @@
#define IPL_MEMORY_CARD_CPP
#define IPL_MEMORY_CARD_NOVTABLE
#include "scene/memoryCard/iplMemoryCard.h"
#include "scene/memoryCard/iplGCWindow.h"
@@ -85,6 +86,47 @@ namespace ipl {
static const DigitTable scNumber = {{L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9'}};
class __declspec(novtable) MemoryCardManagerImpl : public MemoryCardManager {
public:
virtual void onMount(u8) {}
virtual void onUnmount(u8) {}
virtual void onAttach(u8) {}
virtual void onDetach(u8) {}
virtual void onCheck(u8) {}
virtual void onFormat(u8) {}
virtual void onRepair(u8) {}
virtual void onRead(u8) {}
virtual void onWrite(u8) {}
virtual void onOpen(u8) {}
virtual void onClose(u8) {}
virtual void onCreate(u8) {}
virtual void onDelete(u8) {}
virtual void onCopy(u8) {}
virtual void onMove(u8) {}
virtual void onRename(u8) {}
virtual void onVerify(u8) {}
virtual void onCommit(u8) {}
virtual void onProbe(u8) {}
virtual void onMountAsync(u8) {}
virtual void onUnmountAsync(u8) {}
virtual void onCheckAsync(u8) {}
virtual void onFormatAsync(u8) {}
virtual void onReadAsync(u8) {}
virtual void onWriteAsync(u8) {}
virtual void onCreateAsync(u8) {}
virtual void onDeleteAsync(u8) {}
virtual void onCopyAsync(u8) {}
virtual void onMoveAsync(u8) {}
virtual void onRenameAsync(u8) {}
virtual void onVerifyAsync(u8) {}
virtual void onCommitAsync(u8) {}
virtual void onProbeAsync(u8) {}
virtual void onFreeBlocks(u8) {}
virtual void onGetLength(u8) {}
virtual void onSetAttrib(u8) {}
virtual void onGetAttrib(u8) {}
};
MemoryCard::MemoryCard(EGG::Heap* heap)
: Base(heap), MemoryBase(), mState(2), mPrevState(2), mSlot(0), mIconIndex(-15), mIconCount(0),
mShowArwR(0), mShowArwL(0), mpEvent(NULL), mpFocusSaveData(NULL) {
@@ -148,7 +190,7 @@ namespace ipl {
mpGCWindow = new GCWindow(getSceneHeap(), unk_0x08, "arc", "it_CubeDetail_a.brlyt");
mpGCWindow->do_animation(0);
MemoryCardManager* manager = new MemoryCardManager();
MemoryCardManager* manager = new MemoryCardManagerImpl();
mpManager = manager;
mpManager->setEventHandler(mpGCWindow);
mpGCWindow->mpMemoryCardManager = mpManager;
@@ -701,3 +743,5 @@ namespace ipl {
}
}
extern const f64 lbl_81694A78 = 4503601774854144.0;

View File

@@ -145,15 +145,14 @@ bool MemoryCardManager::isDistSlot(u8 slot, long* state) {
bool MemoryCardManager::isMoveEnable(u8 slot, u32 index, long* code) {
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
memorycard::CardState* states = memorycard::getCardSlotState();
bool enabled = false;
int file = mFile[slot][index].fileNo;
u32 file = mFile[slot][index].fileNo;
memorycard::FileInfo* dir = NULL;
memorycard::CardState* destination = NULL;
long result = file;
long result;
bool enabled = false;
if (isDistSlot(slot, NULL) &&
((dir = &dirs[slot][file])->canMove != 0) &&
states[slot].key == (destination = &states[slot ^ 1])->key &&
destination->freeBlocks >= dir->size && destination->unk_0x0E != 0 &&
states[slot].key == states[slot ^ 1].key &&
states[slot ^ 1].freeBlocks >= dir->size && states[slot ^ 1].unk_0x0E != 0 &&
dir->unk_0x06 == 0) {
result = -0x15;
enabled = true;
@@ -169,9 +168,9 @@ bool MemoryCardManager::isMoveEnable(u8 slot, u32 index, long* code) {
}
} else if ((dir = &dirs[slot][file])->canMove == 0) {
result = -0x1a;
} else if (states[slot].key != (destination = &states[slot ^ 1])->key) {
} else if (states[slot].key != states[slot ^ 1].key) {
result = -0x1b;
} else if (destination->freeBlocks < dir->size || destination->unk_0x0E == 0) {
} else if (states[slot ^ 1].freeBlocks < dir->size || states[slot ^ 1].unk_0x0E == 0) {
result = -0x19;
} else if (dir->unk_0x06 != 0) {
result = -0x18;
@@ -186,15 +185,14 @@ bool MemoryCardManager::isMoveEnable(u8 slot, u32 index, long* code) {
bool MemoryCardManager::isCopyEnable(u8 slot, u32 index, long* code) {
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
memorycard::CardState* states = memorycard::getCardSlotState();
bool enabled = false;
int file = mFile[slot][index].fileNo;
u32 file = mFile[slot][index].fileNo;
memorycard::FileInfo* dir = NULL;
memorycard::CardState* destination = NULL;
long result = file;
long result;
bool enabled = false;
if (isDistSlot(slot, NULL) &&
((dir = &dirs[slot][file])->canCopy != 0) &&
states[slot].key == (destination = &states[slot ^ 1])->key &&
destination->freeBlocks >= dir->size && destination->unk_0x0E != 0 &&
states[slot].key == states[slot ^ 1].key &&
states[slot ^ 1].freeBlocks >= dir->size && states[slot ^ 1].unk_0x0E != 0 &&
dir->unk_0x06 == 0) {
result = -0x15;
enabled = true;
@@ -210,9 +208,9 @@ bool MemoryCardManager::isCopyEnable(u8 slot, u32 index, long* code) {
}
} else if ((dir = &dirs[slot][file])->canCopy == 0) {
result = -0x1a;
} else if (states[slot].key != (destination = &states[slot ^ 1])->key) {
} else if (states[slot].key != states[slot ^ 1].key) {
result = -0x1b;
} else if (destination->freeBlocks < dir->size || destination->unk_0x0E == 0) {
} else if (states[slot ^ 1].freeBlocks < dir->size || states[slot ^ 1].unk_0x0E == 0) {
result = -0x19;
} else if (dir->unk_0x06 != 0) {
result = -0x18;
@@ -258,7 +256,7 @@ void MemoryCardManager::update_icon_anm() {
mFileCell[slot][file].iconAnmCounter = frame;
if ((s16)frame >= icons[slot][file].anmMax) {
if (icon->anmType == 4) {
mFileCell[slot][file].iconAnmCounter = icon->anmMax - icon->unk_0x07 - 1;
mFileCell[slot][file].iconAnmCounter = icons[slot][file].anmMax - icon->unk_0x07 - 1;
icon->anmDelta = -1;
} else {
mFileCell[slot][file].iconAnmCounter = 0;
@@ -344,7 +342,7 @@ void MemoryCardManager::update_change_cardstate(u8 slot) {
GXTexObj* MemoryCardManager::create_icon(u8 slot, s16 index) {
memorycard::IconState (*icons)[0x7f] = reinterpret_cast<memorycard::IconState(*)[0x7f]>(memorycard::getIconStateArray());
int total = 0;
int file = mFile[slot][index].fileNo;
u32 file = mFile[slot][index].fileNo;
s16 frame = 0;
do {
u32 shift = frame << 1;
@@ -359,7 +357,7 @@ GXTexObj* MemoryCardManager::create_icon(u8 slot, s16 index) {
GXTexObj* MemoryCardManager::create_icon(u8 slot, s16 index, long start) {
memorycard::getIconStateArray();
int file = mFile[slot][index].fileNo;
u32 file = mFile[slot][index].fileNo;
return _create_icon(slot, file, 0);
}
@@ -385,7 +383,7 @@ GXTexObj* MemoryCardManager::_create_icon(u8 slot, s16 file, long start) {
}
const wchar_t* MemoryCardManager::getComment(u8 slot, s16 index, int which) {
int file = mFile[slot][index].fileNo;
u32 file = mFile[slot][index].fileNo;
wmemset(mFileCell[slot][file].comment[which], 0, 0x40);
char comment[33] = {0};
const char* comments = memorycard::getIconComment(slot, file);
@@ -427,7 +425,7 @@ const wchar_t* MemoryCardManager::getComment(u8 slot, s16 index, int which) {
GXTexObj* MemoryCardManager::create_banner(u8 slot, s16 index) {
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
CardIcons* icons = reinterpret_cast<CardIcons*>(memorycard::getIconStateArray());
int file = mFile[slot][index].fileNo;
u32 file = mFile[slot][index].fileNo;
if (dirs[slot][file].fileNo == 0 || !icons[slot][file].bannerEnable) {
return NULL;
}