Compare commits
1 Commits
main
...
agent/w092
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d406de3bc1 |
@@ -53,9 +53,9 @@ Progress
|
||||
<!-- progress:start -->
|
||||
| Decompiled | Matched | Linked | Data |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| 82.37% | 73.12% | 56.76% | 86.29% |
|
||||
| 82.67% | 73.43% | 56.76% | 86.31% |
|
||||
|
||||
units 748/1027 complete, functions 10669/12563 matched.
|
||||
units 748/1027 complete, functions 10710/12563 matched.
|
||||
|
||||
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
|
||||
<!-- progress:end -->
|
||||
|
||||
@@ -61,7 +61,11 @@ namespace ipl {
|
||||
const char* getIconComment(u8 slot, s16 fileNo);
|
||||
|
||||
void initCardThread();
|
||||
#ifdef IPL_MEMORY_CARD_CPP
|
||||
BOOL shutdownCardThread();
|
||||
#else
|
||||
bool shutdownCardThread();
|
||||
#endif
|
||||
} // namespace memorycard
|
||||
} // namespace ipl
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
namespace ipl {
|
||||
namespace scene {
|
||||
class GCWindow : public MemoryBase, public MemCardEventHandler {
|
||||
#ifdef IPL_MEMORY_CARD_CPP
|
||||
friend class MemoryCard;
|
||||
#endif
|
||||
public:
|
||||
GCWindow(EGG::Heap*, nand::LayoutFile*, const char*, const char*);
|
||||
virtual ~GCWindow();
|
||||
|
||||
@@ -59,6 +59,10 @@ namespace ipl {
|
||||
void start_errormessage_fadein();
|
||||
int update_slot();
|
||||
|
||||
#ifdef IPL_MEMORY_CARD_CPP
|
||||
bool can_scroll_r() const { return mIconCount > 30 && mState == 2; }
|
||||
bool can_scroll_l() const { return mIconIndex >= 0 && mState == 2; }
|
||||
#endif
|
||||
void show_arw();
|
||||
void show_capacity(u8 slot);
|
||||
|
||||
|
||||
@@ -90,7 +90,11 @@ namespace ipl {
|
||||
#else
|
||||
u16 getBlocks(u8 slot, s16 index);
|
||||
#endif
|
||||
#ifdef IPL_MEMORY_CARD_CPP
|
||||
u32 getFreeBlocks(u8 slot);
|
||||
#else
|
||||
u16 getFreeBlocks(u8 slot);
|
||||
#endif
|
||||
|
||||
void setEventHandler(MemCardEventHandler* eventHandler) {
|
||||
mpEventHandler = eventHandler;
|
||||
|
||||
706
src/scene/memoryCard/iplMemoryCard.cpp
Normal file
706
src/scene/memoryCard/iplMemoryCard.cpp
Normal file
@@ -0,0 +1,706 @@
|
||||
#define IPL_MEMORY_CARD_CPP
|
||||
#define IPL_MEMORYCARD_BASE_OUT_OF_LINE
|
||||
#define IPL_CHANNEL_TITLE_NOVTABLE
|
||||
#include "scene/memoryCard/iplMemoryCard.h"
|
||||
#undef IPL_CHANNEL_TITLE_NOVTABLE
|
||||
|
||||
#include "scene/memoryCard/iplGCWindow.h"
|
||||
#include "scene/memoryCard/iplGCSaveData.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
|
||||
#include "iplSystem.h"
|
||||
#include "scene/iplSceneCreator.h"
|
||||
#include "scene/settingSelect/iplSettingButton.h"
|
||||
#include "scene/settingSelect/iplSettingSelect.h"
|
||||
#include "scene/textBalloon/iplBalloon.h"
|
||||
#include "private/card.h"
|
||||
#include "sound/iplSound.h"
|
||||
#include "system/iplController.h"
|
||||
#include "system/iplNandManager.h"
|
||||
#include "utility/iplGraphics.h"
|
||||
|
||||
namespace ipl {
|
||||
namespace scene {
|
||||
static const char* scSavedataPaneName[] = {
|
||||
"N_Data_a_00", "N_Data_a_01", "N_Data_a_02", "N_Data_a_03", "N_Data_a_04",
|
||||
"N_Data_a_05", "N_Data_a_06", "N_Data_a_07", "N_Data_a_08", "N_Data_a_09",
|
||||
"N_Data_a_10", "N_Data_a_11", "N_Data_a_12", "N_Data_a_13", "N_Data_a_14",
|
||||
"N_Data_b_00", "N_Data_b_01", "N_Data_b_02", "N_Data_b_03", "N_Data_b_04",
|
||||
"N_Data_b_05", "N_Data_b_06", "N_Data_b_07", "N_Data_b_08", "N_Data_b_09",
|
||||
"N_Data_b_10", "N_Data_b_11", "N_Data_b_12", "N_Data_b_13", "N_Data_b_14",
|
||||
"N_Data_c_00", "N_Data_c_01", "N_Data_c_02", "N_Data_c_03", "N_Data_c_04",
|
||||
"N_Data_c_05", "N_Data_c_06", "N_Data_c_07", "N_Data_c_08", "N_Data_c_09",
|
||||
"N_Data_c_10", "N_Data_c_11", "N_Data_c_12", "N_Data_c_13", "N_Data_c_14",
|
||||
};
|
||||
|
||||
static const MemoryBase::AnmName scAnmName[] = {
|
||||
{"it_ObjCubeEdit_a_CubeSwitch.brlan", "G_Switch"},
|
||||
{"it_ObjCubeEdit_a_DataIn.brlan", "G_DataAll"},
|
||||
{"it_ObjCubeEdit_a_SelectIn.brlan", "G_SelectWii"},
|
||||
{"it_ObjCubeEdit_a_SelectIn.brlan", "G_SelectSd"},
|
||||
{"it_ObjCubeEdit_a_DataOut.brlan", "G_DataAll"},
|
||||
{"it_ObjCubeEdit_a_SelectIn.brlan", "G_Select"},
|
||||
{"it_ObjCubeEdit_a_SelectWiiFoucusIn.brlan", "G_SelectWii"},
|
||||
{"it_ObjCubeEdit_a_SelectWiiFoucusOut.brlan", "G_SelectWii"},
|
||||
{"it_ObjCubeEdit_a_SelectWiiFlash.brlan", "G_Select"},
|
||||
{"it_ObjCubeEdit_a_SelectSdIn.brlan", "G_SelectSd"},
|
||||
{"it_ObjCubeEdit_a_SelectSdOut.brlan", "G_SelectSd"},
|
||||
{"it_ObjCubeEdit_a_SelectSdFlash.brlan", "G_Select"},
|
||||
{"it_ObjCubeEdit_a_ArwL1.brlan", "G_Arw"},
|
||||
{"it_ObjCubeEdit_a_AwrR1.brlan", "G_Arw"},
|
||||
{"it_ObjCubeEdit_a_Select.brlan", "G_ArwR_Ac"},
|
||||
{"it_ObjCubeEdit_a_Select.brlan", "G_ArwL_Ac"},
|
||||
{"it_ObjCubeEdit_a_FocusOn.brlan", "G_ArwR_Focus"},
|
||||
{"it_ObjCubeEdit_a_FocusOn.brlan", "G_ArwL_Focus"},
|
||||
{"it_ObjCubeEdit_a_FocusOff.brlan", "G_ArwR_Focus"},
|
||||
{"it_ObjCubeEdit_a_FocusOff.brlan", "G_ArwL_Focus"},
|
||||
{"it_ObjCubeEdit_a_Loop.brlan", "G_ArwRoop"},
|
||||
{"it_ObjCubeEdit_a_Appear.brlan", "G_ArwR_End"},
|
||||
{"it_ObjCubeEdit_a_Appear.brlan", "G_ArwL_End"},
|
||||
{"it_ObjCubeEdit_a_Lost.brlan", "G_ArwR_End"},
|
||||
{"it_ObjCubeEdit_a_Lost.brlan", "G_ArwL_End"},
|
||||
{"it_ObjCubeEdit_a_ErrorTxtIn.brlan", "G_ErrorTxt"},
|
||||
{"it_ObjCubeEdit_a_ErrorTxtOut.brlan", "G_ErrorTxt"},
|
||||
};
|
||||
|
||||
struct TextboxMessage {
|
||||
const char* paneName;
|
||||
u32 messageId;
|
||||
};
|
||||
|
||||
static const TextboxMessage scTextboxToMessageID[] = {
|
||||
{"T_SelectWii_00", 0x13F},
|
||||
{"T_SelectWii_01", 0x13F},
|
||||
{"T_SelectSd_00", 0x140},
|
||||
{"T_SelectSd_01", 0x140},
|
||||
{"T_Error_00", 0xE6},
|
||||
};
|
||||
|
||||
static const char* scTriggerPaneName[] = {
|
||||
"B_ArwR", "B_ArwL", "B_SelectWii_00", "B_SelectSd_00",
|
||||
};
|
||||
|
||||
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) {
|
||||
System::getMem2App()->dump();
|
||||
nw4r::ut::List_Init(&mSaveDataList, offsetof(GCSaveData, mLink));
|
||||
nw4r::ut::List_Init(&mBalloonList, 0);
|
||||
}
|
||||
|
||||
MemoryBase::~MemoryBase() {}
|
||||
|
||||
void MemoryCard::prepare() {
|
||||
System::getBS2Manager()->abort();
|
||||
unk_0x08 = System::getNandManager()->readLayoutAsync(getSceneHeap(), "gcMem.ash");
|
||||
mBalloonLayoutFile = System::getNandManager()->readLayoutAsync(getSceneHeap(), "balloon.ash");
|
||||
}
|
||||
|
||||
void MemoryCard::create() {
|
||||
u32 start = OSGetTick();
|
||||
while (System::getBS2Manager()->getIPLState() != 8) {
|
||||
System::getBS2Manager()->update();
|
||||
OSReport(" ... wait for bs2 abord\n");
|
||||
VIWaitForRetrace();
|
||||
}
|
||||
u32 end = OSGetTick();
|
||||
OSReport("*** BS2 abort costs: %dms\n", OSTicksToMilliseconds(end - start));
|
||||
ES_SetUid((u64(1) << 32) | 2);
|
||||
|
||||
mpLayout = new layout::Object(getSceneHeap(), unk_0x08, "arc", "it_ObjCubeEdit_a.brlyt");
|
||||
add_animation(scAnmName, 0x1B);
|
||||
get_animation(7)->mAnim->setAnmType(1);
|
||||
get_animation(10)->mAnim->setAnmType(1);
|
||||
mpLayout->finishBinding();
|
||||
do_animation(0);
|
||||
do_animation(1);
|
||||
do_animation(0x14);
|
||||
do_animation(0x17);
|
||||
do_animation(0x18);
|
||||
mPrevState = mState;
|
||||
mState = 0;
|
||||
mpLayout->FindPaneByName("N_ArwR")->SetVisible(false);
|
||||
mpLayout->FindPaneByName("N_ArwL")->SetVisible(false);
|
||||
|
||||
mpEvent = new MemoryBaseEvent(this);
|
||||
mpPaneManager = new gui::PaneManager(mpEvent, mpLayout->getDrawInfo(), NULL, NULL, true);
|
||||
mpPaneManager->setupScene(mpLayout);
|
||||
mpPaneManager->setAllComponentTriggerTarget(false);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
nw4r::lyt::Pane* pane = mpLayout->FindPaneByName(scTriggerPaneName[i]);
|
||||
mpPaneManager->setTriggerTarget(pane, true);
|
||||
}
|
||||
|
||||
add_anmbutton(scTriggerPaneName[2], get_animation(6), get_animation(7), get_animation(8));
|
||||
add_anmbutton(scTriggerPaneName[3], get_animation(9), get_animation(10), get_animation(11));
|
||||
add_anmbutton(scTriggerPaneName[0], get_animation(16), get_animation(18), get_animation(12));
|
||||
add_anmbutton(scTriggerPaneName[1], get_animation(17), get_animation(19), get_animation(13));
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
set_textbox(scTextboxToMessageID[i].paneName, scTextboxToMessageID[i].messageId);
|
||||
}
|
||||
|
||||
mpGCWindow = new GCWindow(getSceneHeap(), unk_0x08, "arc", "it_CubeDetail_a.brlyt");
|
||||
mpGCWindow->do_animation(0);
|
||||
|
||||
MemoryCardManager* manager = new MemoryCardManager();
|
||||
mpManager = manager;
|
||||
mpManager->setEventHandler(mpGCWindow);
|
||||
mpGCWindow->mpMemoryCardManager = mpManager;
|
||||
|
||||
for (int i = 0; i < 0x2D; i++) {
|
||||
nw4r::lyt::Pane* pane = mpLayout->FindPaneByName(scSavedataPaneName[i]);
|
||||
nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f);
|
||||
PSMTXMultVec(pane->GetGlobalMtx(), reinterpret_cast<const Vec*>(&position), reinterpret_cast<Vec*>(&position));
|
||||
GCSaveData* saveData =
|
||||
new GCSaveData(getSceneHeap(), unk_0x08, "arc", "it_ObjCubeEdit_b.brlyt", position);
|
||||
saveData->set_visible("N_Data_00", false);
|
||||
nw4r::ut::List_Append(&mSaveDataList, saveData);
|
||||
if (i >= 0xF && i < 0x1E) {
|
||||
position.y -= 55.0f;
|
||||
TextBalloon* balloon =
|
||||
new TextBalloon(getSceneHeap(), mBalloonLayoutFile, "arc", "my_IplTopBalloon_a.brlyt",
|
||||
math::VEC3(position), 90.0f, 60.0f);
|
||||
nw4r::ut::List_Append(&mBalloonList, balloon);
|
||||
saveData->setBalloon(balloon);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
mSlotState[i] = 0;
|
||||
}
|
||||
set_visible("N_Capa_00", false);
|
||||
set_visible("T_Error_00", false);
|
||||
}
|
||||
|
||||
void MemoryCard::calc() {
|
||||
mpManager->calc();
|
||||
if (is_fadein_enable()) {
|
||||
mpLayout->calc();
|
||||
mpPaneManager->calc();
|
||||
s16 index = mIconIndex;
|
||||
mIconCount = 0;
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
if (mpManager->isIconValidate(mSlot, index) || index < 0) {
|
||||
mIconCount++;
|
||||
}
|
||||
saveData->mSlot = mSlot;
|
||||
saveData->mIndex = index;
|
||||
saveData->calc();
|
||||
index++;
|
||||
}
|
||||
MemoryBase::AnmButton* button = NULL;
|
||||
while ((button = static_cast<MemoryBase::AnmButton*>(nw4r::ut::List_GetNext(&mAnmButtonList, button))) != NULL) {
|
||||
button->calc();
|
||||
}
|
||||
TextBalloon* balloon = NULL;
|
||||
while ((balloon = static_cast<TextBalloon*>(nw4r::ut::List_GetNext(&mBalloonList, balloon))) != NULL) {
|
||||
balloon->calc();
|
||||
}
|
||||
switch (mState) {
|
||||
case 0:
|
||||
on_fadein1st();
|
||||
break;
|
||||
case 1:
|
||||
on_fadein2nd();
|
||||
break;
|
||||
case 2:
|
||||
on_normal();
|
||||
break;
|
||||
case 3:
|
||||
on_scroll_r();
|
||||
break;
|
||||
case 4:
|
||||
on_scroll_l();
|
||||
break;
|
||||
case 5:
|
||||
on_change_tag1st();
|
||||
break;
|
||||
case 6:
|
||||
on_change_tag2nd();
|
||||
break;
|
||||
case 7:
|
||||
on_fadeout1st();
|
||||
break;
|
||||
case 8:
|
||||
on_fadeout2nd();
|
||||
break;
|
||||
case 9:
|
||||
mpGCWindow->calc();
|
||||
show_capacity(mSlot);
|
||||
break;
|
||||
case 10:
|
||||
on_error();
|
||||
break;
|
||||
case 11:
|
||||
on_insert_card();
|
||||
break;
|
||||
case 12:
|
||||
on_detach_card();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::on_fadein1st() {
|
||||
if (!is_animation(1)) {
|
||||
do_animation(5);
|
||||
mpLayout->FindPaneByName("N_ArwR")->SetVisible(true);
|
||||
mpLayout->FindPaneByName("N_ArwL")->SetVisible(true);
|
||||
if (mpManager->isSlotReady(mSlot)) {
|
||||
mSlotState[mSlot] = 1;
|
||||
start_savedata_fadein();
|
||||
mPrevState = mState;
|
||||
mState = 1;
|
||||
} else {
|
||||
start_errormessage_fadein();
|
||||
mPrevState = mState;
|
||||
mState = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::on_fadein2nd() {
|
||||
GCSaveData* saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, NULL));
|
||||
if (!is_animation(5) && !saveData->is_animation(0)) {
|
||||
mPrevState = mState;
|
||||
mState = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::on_normal() {
|
||||
if (get_setting_button()->update()) {
|
||||
if (mPrevState == 10) {
|
||||
do_animation(0x1A);
|
||||
}
|
||||
mPrevState = mState;
|
||||
mState = 7;
|
||||
return;
|
||||
}
|
||||
show_arw();
|
||||
show_capacity(mSlot);
|
||||
if (!update_slot()) {
|
||||
mpPaneManager->update();
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->update();
|
||||
}
|
||||
mpGCWindow->calc();
|
||||
if (mIconCount <= 15) {
|
||||
bool canScroll = false;
|
||||
if (mIconIndex >= 0 && mState == 2) {
|
||||
canScroll = true;
|
||||
}
|
||||
if (canScroll) {
|
||||
start_scroll_l();
|
||||
return;
|
||||
}
|
||||
}
|
||||
controller::Interface* controller = System::getYoungController();
|
||||
if (controller != NULL) {
|
||||
if (controller->down(0x30001000)) {
|
||||
start_scroll_l();
|
||||
} else if (controller->down(0x06000010)) {
|
||||
start_scroll_r();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::on_scroll_r() {
|
||||
if (!is_animation(0xC)) {
|
||||
get_animation(0xC)->mAnim->initAnmFrame();
|
||||
mpLayout->calc();
|
||||
mState = 2;
|
||||
mIconIndex += 0xF;
|
||||
}
|
||||
scroll_common();
|
||||
}
|
||||
|
||||
void MemoryCard::on_scroll_l() {
|
||||
if (!is_animation(0xD)) {
|
||||
get_animation(0xC)->mAnim->initAnmFrame();
|
||||
mpLayout->calc();
|
||||
mState = 2;
|
||||
mIconIndex -= 0xF;
|
||||
}
|
||||
scroll_common();
|
||||
}
|
||||
|
||||
void MemoryCard::on_change_tag1st() {
|
||||
GCSaveData* first = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, NULL));
|
||||
if (!first->is_animation(1)) {
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->set_visible("N_Data_00", false);
|
||||
}
|
||||
mSlot ^= 1;
|
||||
mSlotState[mSlot] = 0;
|
||||
mIconIndex = -15;
|
||||
mPrevState = mState;
|
||||
mState = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::on_change_tag2nd() {
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
if (!saveData->is_animation(0)) {
|
||||
mState = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::on_fadeout1st() {
|
||||
if (!get_setting_button()->isPlaying()) {
|
||||
do_animation(4);
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->do_animation(1);
|
||||
}
|
||||
mState = 8;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::on_fadeout2nd() {
|
||||
if (!is_animation(4)) {
|
||||
bool shutdown = memorycard::shutdownCardThread();
|
||||
if (shutdown) {
|
||||
requestSceneDestruction();
|
||||
System::getBS2Manager()->restart();
|
||||
OSReport(" ... bs2 manager restarted\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::on_error() {
|
||||
if (!is_animation(0x19)) {
|
||||
mPrevState = mState;
|
||||
mState = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::on_insert_card() {
|
||||
if (!is_animation(0x1A)) {
|
||||
start_savedata_fadein();
|
||||
mPrevState = mState;
|
||||
mState = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::on_detach_card() {
|
||||
GCSaveData* first = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, NULL));
|
||||
if (!first->is_animation(1)) {
|
||||
start_errormessage_fadein();
|
||||
mPrevState = mState;
|
||||
mState = 10;
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->set_visible("N_Data_00", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::start_savedata_fadein() {
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->set_visible("N_Data_00", true);
|
||||
saveData->do_animation(0);
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::start_savedata_fadeout() {
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->do_animation(1);
|
||||
}
|
||||
set_visible("N_Capa_00", false);
|
||||
}
|
||||
|
||||
void MemoryCard::start_errormessage_fadein() {
|
||||
if (mpManager->isSlotWrongDevice(mSlot) != 0) {
|
||||
mSlotState[mSlot] = 3;
|
||||
set_textbox("T_Error_00", mSlot == 0 ? 0xE8 : 0xE9);
|
||||
} else {
|
||||
mSlotState[mSlot] = 2;
|
||||
set_textbox("T_Error_00", mSlot == 0 ? 0xE6 : 0xE7);
|
||||
}
|
||||
set_visible("T_Error_00", true);
|
||||
do_animation(0x19);
|
||||
}
|
||||
|
||||
int MemoryCard::update_slot() {
|
||||
if (mSlotState[mSlot] != 1 && mpManager->isSlotReady(mSlot) != 0) {
|
||||
for (u16 i = 0xF; i < 0x1E; i++) {
|
||||
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
|
||||
}
|
||||
mSlotState[mSlot] = 1;
|
||||
if (mPrevState == 10) {
|
||||
do_animation(0x1A);
|
||||
}
|
||||
mPrevState = mState;
|
||||
mState = 0xB;
|
||||
return true;
|
||||
}
|
||||
if (mSlotState[mSlot] != 2 && mpManager->isSlotNoCard(mSlot) != 0) {
|
||||
for (u16 i = 0xF; i < 0x1E; i++) {
|
||||
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
|
||||
}
|
||||
mSlotState[mSlot] = 2;
|
||||
mIconIndex = -15;
|
||||
start_savedata_fadeout();
|
||||
mPrevState = mState;
|
||||
mState = 0xC;
|
||||
return true;
|
||||
}
|
||||
if ((mSlotState[mSlot] != 3 && mpManager->isSlotWrongDevice(mSlot) != 0) || mSlotState[mSlot] == 0) {
|
||||
for (u16 i = 0xF; i < 0x1E; i++) {
|
||||
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
|
||||
}
|
||||
mSlotState[mSlot] = 3;
|
||||
start_savedata_fadeout();
|
||||
mPrevState = mState;
|
||||
mState = 0xC;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MemoryCard::show_arw() {
|
||||
if (mShowArwR == 0 && can_scroll_r()) {
|
||||
do_animation(0x15);
|
||||
do_animation(0x12);
|
||||
mShowArwR = 1;
|
||||
} else if (mShowArwR != 0 && !can_scroll_r()) {
|
||||
do_animation(0x17);
|
||||
mShowArwR = 0;
|
||||
}
|
||||
if (mShowArwL == 0 && can_scroll_l()) {
|
||||
do_animation(0x16);
|
||||
do_animation(0x13);
|
||||
mShowArwL = 1;
|
||||
} else if (mShowArwL != 0 && !can_scroll_l()) {
|
||||
do_animation(0x18);
|
||||
mShowArwL = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::show_capacity(u8 slot) {
|
||||
if (!mpManager->isSlotReady(slot)) {
|
||||
set_visible("N_Capa_00", false);
|
||||
return;
|
||||
}
|
||||
u32 freeBlocks = mpManager->getFreeBlocks(slot);
|
||||
wchar_t digits[5];
|
||||
wchar_t digitTable[10] = {L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9'};
|
||||
digits[0] = L'\0';
|
||||
digits[1] = L'\0';
|
||||
digits[2] = L'\0';
|
||||
digits[3] = L'\0';
|
||||
digits[4] = L'\0';
|
||||
wchar_t text[0x40] = L"";
|
||||
int blocks = static_cast<u16>(freeBlocks);
|
||||
digits[0] = digitTable[blocks / 1000];
|
||||
digits[1] = digitTable[blocks / 100 % 10];
|
||||
digits[2] = digitTable[blocks / 10 % 10];
|
||||
digits[3] = digitTable[blocks % 10];
|
||||
|
||||
int zeroOffset;
|
||||
for (zeroOffset = 0; zeroOffset < 3; zeroOffset++) {
|
||||
if (digits[zeroOffset] != L'0') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int blockOpenOffset = 0;
|
||||
const wchar_t* blockOpenMessage = System::getMessage(0x9C);
|
||||
const wchar_t* blankMessage = System::getMessage(0xF2);
|
||||
|
||||
while (true) {
|
||||
wchar_t chr = *blockOpenMessage++;
|
||||
text[blockOpenOffset++] = chr;
|
||||
if (chr == L'\0') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
text[--blockOpenOffset] = L' ';
|
||||
wcscpy(text + blockOpenOffset, digits + zeroOffset);
|
||||
wcscat(text, blankMessage);
|
||||
|
||||
set_textbox("T_Capa_00", text);
|
||||
set_visible("N_Capa_00", true);
|
||||
}
|
||||
|
||||
void MemoryCard::scroll_common() {
|
||||
for (u16 i = 0; i < 0x2D; i++) {
|
||||
nw4r::lyt::Pane* pane = mpLayout->FindPaneByName(scSavedataPaneName[i]);
|
||||
GCSaveData* saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i));
|
||||
nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f);
|
||||
PSMTXMultVec(pane->GetGlobalMtx(), reinterpret_cast<const Vec*>(&position), reinterpret_cast<Vec*>(&position));
|
||||
saveData->setTranslate(position);
|
||||
saveData->init();
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::start_scroll_r() {
|
||||
bool canScroll = false;
|
||||
if (mIconCount > 0x1E && mState == 2) {
|
||||
canScroll = true;
|
||||
}
|
||||
if (canScroll) {
|
||||
do_animation(0xC);
|
||||
mState = 3;
|
||||
snd::getSystem()->startSE("WSD_SELECT");
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::start_scroll_l() {
|
||||
bool canScroll = false;
|
||||
if (mIconIndex >= 0 && mState == 2) {
|
||||
canScroll = true;
|
||||
}
|
||||
if (canScroll) {
|
||||
do_animation(0xD);
|
||||
mState = 4;
|
||||
snd::getSystem()->startSE("WSD_SELECT");
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::draw() {
|
||||
if (System::onDefaultDrawLayer()) {
|
||||
utility::Graphics::setOrtho(0);
|
||||
mpLayout->draw();
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->draw();
|
||||
}
|
||||
mpLayout->draw("N_ArwR");
|
||||
mpLayout->draw("N_ArwL");
|
||||
if (mpFocusSaveData != NULL) {
|
||||
mpGCWindow->draw();
|
||||
}
|
||||
if (mState == 2) {
|
||||
TextBalloon* balloon = NULL;
|
||||
while ((balloon = static_cast<TextBalloon*>(nw4r::ut::List_GetNext(&mBalloonList, balloon))) != NULL) {
|
||||
balloon->draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::onPoint(const char* paneName, controller::Interface* controller) {
|
||||
MemoryBase::AnmButton* button = get_anmbutton(paneName);
|
||||
if (button != NULL) {
|
||||
if (button->unk_0x04 == 0 &&
|
||||
(strcmp(paneName, scTriggerPaneName[2]) != 0 || mSlot != 0) &&
|
||||
(strcmp(paneName, scTriggerPaneName[3]) != 0 || mSlot != 1)) {
|
||||
button->onCmdRecv(1);
|
||||
snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING");
|
||||
if (controller != NULL) {
|
||||
controller->rumble(0);
|
||||
}
|
||||
}
|
||||
button->unk_0x04++;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::onLeft(const char* paneName) {
|
||||
MemoryBase::AnmButton* button = get_anmbutton(paneName);
|
||||
if (button != NULL) {
|
||||
if (button->unk_0x04 == 1 &&
|
||||
(strcmp(paneName, scTriggerPaneName[2]) != 0 || mSlot != 0) &&
|
||||
(strcmp(paneName, scTriggerPaneName[3]) != 0 || mSlot != 1)) {
|
||||
button->onCmdRecv(2);
|
||||
}
|
||||
button->unk_0x04--;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::onTrig(const char* paneName) {
|
||||
if (mpFocusSaveData == NULL && get_anmbutton(paneName) != NULL) {
|
||||
if (strcmp(paneName, scTriggerPaneName[0]) == 0) {
|
||||
do_animation(0xE);
|
||||
start_scroll_r();
|
||||
} else if (strcmp(paneName, scTriggerPaneName[1]) == 0) {
|
||||
do_animation(0xF);
|
||||
start_scroll_l();
|
||||
} else if (strcmp(paneName, scTriggerPaneName[2]) == 0) {
|
||||
if (mSlot == 1) {
|
||||
do_animation(0xB);
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->do_animation(1);
|
||||
}
|
||||
if (mPrevState == 10) {
|
||||
do_animation(0x1A);
|
||||
}
|
||||
snd::getSystem()->startSE("WIPL_SE_BT_PUSH");
|
||||
mState = 5;
|
||||
}
|
||||
} else if (strcmp(paneName, scTriggerPaneName[3]) == 0) {
|
||||
if (mSlot == 0) {
|
||||
do_animation(8);
|
||||
GCSaveData* saveData = NULL;
|
||||
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
|
||||
saveData->do_animation(1);
|
||||
}
|
||||
if (mPrevState == 10) {
|
||||
do_animation(0x1A);
|
||||
}
|
||||
snd::getSystem()->startSE("WIPL_SE_BT_PUSH");
|
||||
mState = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::onFocus(void* data) {
|
||||
if (mState == 2) {
|
||||
if (data != NULL) {
|
||||
snd::getSystem()->startSE("WIPL_SE_DECIDE");
|
||||
GCSaveData* saveData = static_cast<GCSaveData*>(data);
|
||||
mpFocusSaveData = saveData;
|
||||
mpGCWindow->init(math::VEC3(*saveData->getTranslate()), mpManager,
|
||||
saveData->mSlot,
|
||||
saveData->mIndex);
|
||||
change_button_text_close();
|
||||
}
|
||||
mState = 9;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCard::onRelease() {
|
||||
if (mpFocusSaveData != NULL) {
|
||||
TextBalloon* balloon = mpFocusSaveData->mpBalloon;
|
||||
if (balloon != NULL) {
|
||||
balloon->terminate();
|
||||
}
|
||||
}
|
||||
mpFocusSaveData = NULL;
|
||||
mState = 2;
|
||||
}
|
||||
|
||||
BOOL MemoryCard::isResetAcceptable() const {
|
||||
return !mpGCWindow->isProcess();
|
||||
}
|
||||
|
||||
void MemoryBase::onMove(const char*) {}
|
||||
|
||||
MemoryCardManager::~MemoryCardManager() {}
|
||||
|
||||
MemoryCard::~MemoryCard() {}
|
||||
|
||||
}
|
||||
}
|
||||
62
tools/decomp-assist/iplMemoryCard.attempts.md
Normal file
62
tools/decomp-assist/iplMemoryCard.attempts.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# iplMemoryCard matching attempts
|
||||
|
||||
Baseline: missing source, 0/41 functions and 0/9264 exact code bytes.
|
||||
Reused the readable scene reconstruction saved in /tmp/iplMemoryCard.latest-baseline.cpp,
|
||||
replacing its local class imitations, raw field offsets and pinned double with
|
||||
existing MemoryCard, MemoryBase, GCWindow, GCSaveData and MemoryCardManager types.
|
||||
All 102 strings and the animation, pane and message tables match on the first build.
|
||||
The first build matched 38/41 functions; create matched all 520 instructions.
|
||||
|
||||
## on_fadeout2nd
|
||||
|
||||
1. Existing bool shutdownCardThread declaration produced 32/33 instructions;
|
||||
the target explicitly normalizes an integer return to bool.
|
||||
2. Guarded the return declaration as BOOL for this source. A bool local now
|
||||
emits addic/subfe., matching all 33 instructions.
|
||||
|
||||
## show_arw
|
||||
|
||||
1. Nested visibility tests followed by else-if produced 102/104 instructions;
|
||||
the compiler eliminated the second flag comparisons.
|
||||
2. Computing visibility before each flag test retained the wrong load ordering
|
||||
and 102/104 instructions.
|
||||
3. Short-circuit calls to real inline can_scroll_r/can_scroll_l members match
|
||||
the original load order, repeated flag comparisons and all 104 instructions.
|
||||
|
||||
## show_capacity
|
||||
|
||||
1. Original u16 getFreeBlocks declaration truncated the return before array
|
||||
initialization: 139/139 instructions, 58 differences, 88.431656%.
|
||||
2. Guarded u32 return declaration and explicit later u16 conversion reduced
|
||||
this to 19 differences, 94.85612%, still 139/139 instructions.
|
||||
3. Inlining the thousands expression changed no instructions.
|
||||
4. Separating freeBlocks from the converted blocks local and removing division
|
||||
temporaries changed no instructions: the remaining 19 differences involved
|
||||
decimal arithmetic scheduling and register allocation.
|
||||
5. Replaced the manual copy from a static number table with a normal local
|
||||
digitTable initializer. Decimal arithmetic now matched, but digits initialized
|
||||
before the table gave 140/139 instructions and different initialization order.
|
||||
6. Declared digits without initialization and zeroed them after digitTable.
|
||||
All 139 instructions now match. No pointer before an array is constructed.
|
||||
|
||||
## Data evidence
|
||||
|
||||
.rodata (280 bytes) and .sdata (40 bytes) match completely. Pool: 102/102,
|
||||
identical including offsets. The generated .data bytes match the original
|
||||
prefix exactly: 2252 bytes versus 2320. Original trailing 68 bytes are zero.
|
||||
At 0x870 the original MemoryCardManager vtable symbol includes 160 bytes,
|
||||
with only its destructor relocation at 0x878. The compiler generates the
|
||||
natural 12-byte manager vtable, followed by the 80-byte MemoryBase vtable
|
||||
with ordinary virtual-method relocations. These weak table relocations are
|
||||
absent in the extracted original; no artificial padding was added.
|
||||
|
||||
An experiment using the existing inline MemoryBase destructor rather than
|
||||
its explicit source definition kept its 16 instructions exact but worsened
|
||||
.data from 98.51269% to 96.70525%. Kept the explicit destructor in object order.
|
||||
|
||||
.sdata2 contains the correct first four floats (16 bytes). The original has
|
||||
an additional unreferenced eight-byte signed-integer conversion bias. No
|
||||
relocation in the original references it. Its originating discarded helper
|
||||
is unknown; no address-pinned constant or dummy conversion was added.
|
||||
|
||||
Final code: 41/41 instruction-exact functions. No open code functions.
|
||||
Reference in New Issue
Block a user