diff --git a/configure.py b/configure.py index 9313a927..72967f94 100644 --- a/configure.py +++ b/configure.py @@ -1856,10 +1856,10 @@ config.libs = [ Object(NonMatching, "fa/driver/nand_drv.c"), Object(NonMatching, "fa/driver/sd_drv.c"), Object(Matching, "fa/driver/pfd_cmn.c"), - Object(NonMatching, "fa/driver/msc_drv.c"), + Object(Matching, "fa/driver/msc_drv.c"), - Object(NonMatching, "fa/msc/puh_msc.c"), - Object(NonMatching, "fa/msc/puh_msc_cmd.c"), + Object(Matching, "fa/msc/puh_msc.c"), + Object(Matching, "fa/msc/puh_msc_cmd.c"), Object(NonMatching, "fa/msc/puh_msc_blk.c"), ] ), diff --git a/include/scene/memoryCard/iplMemoryCardBase.h b/include/scene/memoryCard/iplMemoryCardBase.h index ad319815..6d8b27b2 100644 --- a/include/scene/memoryCard/iplMemoryCardBase.h +++ b/include/scene/memoryCard/iplMemoryCardBase.h @@ -35,7 +35,11 @@ namespace ipl { MemoryBase* mpBase; // 0x0C }; +#ifdef IPL_CHANNEL_TITLE_NOVTABLE + class __declspec(novtable) MemoryBase { +#else class MemoryBase { +#endif public: class Anm { public: diff --git a/libs/RVL_SDK/src/fa/driver/msc_drv.c b/libs/RVL_SDK/src/fa/driver/msc_drv.c index 5b07f714..2b65eaf2 100644 --- a/libs/RVL_SDK/src/fa/driver/msc_drv.c +++ b/libs/RVL_SDK/src/fa/driver/msc_drv.c @@ -1,7 +1,7 @@ #include -static FAInsertCallback g_attach_func; static FAEjectCallback g_detach_func; +static FAInsertCallback g_attach_func; extern s32 uhf_msc_is_media_insert(void); diff --git a/libs/RVL_SDK/src/fa/msc/puh_msc.c b/libs/RVL_SDK/src/fa/msc/puh_msc.c index c16aef49..82dd62ba 100644 --- a/libs/RVL_SDK/src/fa/msc/puh_msc.c +++ b/libs/RVL_SDK/src/fa/msc/puh_msc.c @@ -1,9 +1,9 @@ #include -static s32 st_uhs_msc_status; -static s32 st_uhs_msc_msgid; -static s32 st_uhs_msc_tskid; s32 uhg_msc_memid_8169971C; +static s32 st_uhs_msc_tskid; +static s32 st_uhs_msc_msgid; +static s32 st_uhs_msc_status; static s32 _uhf_msc_api_send_message(UHF_MSC_PARAMETERS* parameters, u32 command); s32 usbh_msc_read10(UHF_MSC_DEVICE* device, u32 sector, u16 count, void* buffer, void* sense) { diff --git a/libs/RVL_SDK/src/fa/msc/puh_msc_blk.c b/libs/RVL_SDK/src/fa/msc/puh_msc_blk.c index df946377..1d7a2ca2 100644 --- a/libs/RVL_SDK/src/fa/msc/puh_msc_blk.c +++ b/libs/RVL_SDK/src/fa/msc/puh_msc_blk.c @@ -26,11 +26,10 @@ FAFuncTbl st_uhs_msc_blk_func = { }; static inline UHF_MSC_DEVICE* uhf_msc_blk_find_device(FADisk* disk) { - UHF_MSC_DEVICE* entry = uhg_msc_blk_device_tbl; UHF_MSC_DEVICE* device = NULL; u32 index; - for (index = 0; index < 8; entry++, index++) { - if (entry->disk == disk) { + for (index = 0; index < 8; index++) { + if (uhg_msc_blk_device_tbl[index].disk == disk) { device = &uhg_msc_blk_device_tbl[index]; break; } @@ -88,9 +87,8 @@ s32 uhf_msc_blk_mount(FADisk* disk) { } s32 uhf_msc_blk_pread(FADisk* disk, u8* buffer, u32 sector, u32 blocks, u32* completed) { - u16 transfer_blocks; - UHF_MSC_DEVICE* device; s32 error; + UHF_MSC_DEVICE* device; u32 block_size; u8* transfer_buffer; u32 transfer_limit; @@ -129,7 +127,7 @@ s32 uhf_msc_blk_pread(FADisk* disk, u8* buffer, u32 sector, u32 blocks, u32* com transfer_buffer = buffer; } do { - transfer_blocks = transfer_limit; + u16 transfer_blocks = transfer_limit; if (blocks <= transfer_limit) { transfer_blocks = blocks; } diff --git a/src/scene/memoryCard/iplGCSaveData.cpp b/src/scene/memoryCard/iplGCSaveData.cpp index 0989e3c2..78f3caa2 100644 --- a/src/scene/memoryCard/iplGCSaveData.cpp +++ b/src/scene/memoryCard/iplGCSaveData.cpp @@ -1,4 +1,3 @@ -#define IPL_CHANNEL_TITLE_NOVTABLE #include "scene/memoryCard/iplGCSaveData.h" #include "scene/memoryCard/iplMemoryCard.h" @@ -6,7 +5,6 @@ #include "iplSound.h" #include "iplSystem.h" -#undef IPL_CHANNEL_TITLE_NOVTABLE namespace ipl { namespace scene { diff --git a/src/scene/memoryCard/iplGCWindow.cpp b/src/scene/memoryCard/iplGCWindow.cpp index 9851686e..53534124 100644 --- a/src/scene/memoryCard/iplGCWindow.cpp +++ b/src/scene/memoryCard/iplGCWindow.cpp @@ -50,6 +50,13 @@ static const TextboxToMessageID scTextboxToMessageID[3] = { }; static const char* scButtonName[3] = {"B_Move_00", "B_Copy_00", "B_Del_00"}; + +struct DigitTable { + wchar_t w[10]; +}; + +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), mWaiting(false) { @@ -102,15 +109,15 @@ void GCWindow::init(const math::VEC3& translate, MemoryCardManager* manager, u8 mpPaneManager->initPane(mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName(scButtonName[i], true)); } int blocks = mpMemoryCardManager->getBlocks(cardState, cardIndex); - wchar_t digits[10] = {L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9'}; + DigitTable digitTable = scNumber; int blockCount = static_cast(blocks); wchar_t decimal[5] = {0}; int skipCount = 0; wchar_t blockText[5] = {0}; - decimal[0] = digits[blockCount / 1000]; - decimal[1] = digits[(blockCount / 100) % 10]; - decimal[2] = digits[(blockCount / 10) % 10]; - decimal[3] = digits[blockCount % 10]; + decimal[0] = digitTable.w[blockCount / 1000]; + decimal[1] = digitTable.w[(blockCount / 100) % 10]; + decimal[2] = digitTable.w[(blockCount / 10) % 10]; + decimal[3] = digitTable.w[blockCount % 10]; for (i = 0; i < 3; i++) { if (decimal[i] != L'0') { break; diff --git a/src/scene/memoryCard/iplMemoryCard.cpp b/src/scene/memoryCard/iplMemoryCard.cpp index 2338a205..01b891e2 100644 --- a/src/scene/memoryCard/iplMemoryCard.cpp +++ b/src/scene/memoryCard/iplMemoryCard.cpp @@ -1,8 +1,5 @@ #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" @@ -82,6 +79,12 @@ namespace ipl { "B_ArwR", "B_ArwL", "B_SelectWii_00", "B_SelectSd_00", }; + struct DigitTable { + wchar_t w[10]; + }; + + static const DigitTable scNumber = {{L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9'}}; + 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) { @@ -90,7 +93,6 @@ namespace ipl { nw4r::ut::List_Init(&mBalloonList, 0); } - MemoryBase::~MemoryBase() {} void MemoryCard::prepare() { System::getBS2Manager()->abort(); @@ -495,19 +497,14 @@ namespace ipl { 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'; + DigitTable digitTable = scNumber; + wchar_t digits[5] = {0}; wchar_t text[0x40] = L""; int blocks = static_cast(freeBlocks); - digits[0] = digitTable[blocks / 1000]; - digits[1] = digitTable[blocks / 100 % 10]; - digits[2] = digitTable[blocks / 10 % 10]; - digits[3] = digitTable[blocks % 10]; + digits[0] = digitTable.w[blocks / 1000]; + digits[1] = digitTable.w[blocks / 100 % 10]; + digits[2] = digitTable.w[blocks / 10 % 10]; + digits[3] = digitTable.w[blocks % 10]; int zeroOffset; for (zeroOffset = 0; zeroOffset < 3; zeroOffset++) { diff --git a/src/scene/memoryCard/iplMemoryCardManager.cpp b/src/scene/memoryCard/iplMemoryCardManager.cpp index 8155ec9e..b3bb918b 100644 --- a/src/scene/memoryCard/iplMemoryCardManager.cpp +++ b/src/scene/memoryCard/iplMemoryCardManager.cpp @@ -253,12 +253,12 @@ void MemoryCardManager::update_icon_anm() { for (int remaining = 0x7f; remaining > 0; remaining--, index++) { u32 file = mFile[slot][index].fileNo; if (file < 0x7f && dirs[slot][file].fileNo != 0) { - memorycard::IconState* icon = &icons[slot][file]; + memorycard::IconState* icon = icons[slot] + file; s32 frame = mFileCell[slot][file].iconAnmCounter + icon->anmDelta; mFileCell[slot][file].iconAnmCounter = frame; - if ((s16)frame >= icon->anmMax) { + if ((s16)frame >= icons[slot][file].anmMax) { if (icon->anmType == 4) { - mFileCell[slot][file].iconAnmCounter = icons[slot][file].anmMax - icon->unk_0x07 - 1; + mFileCell[slot][file].iconAnmCounter = icon->anmMax - icon->unk_0x07 - 1; icon->anmDelta = -1; } else { mFileCell[slot][file].iconAnmCounter = 0; @@ -342,18 +342,18 @@ void MemoryCardManager::update_change_cardstate(u8 slot) { } GXTexObj* MemoryCardManager::create_icon(u8 slot, s16 index) { - CardIcons* icons = reinterpret_cast(memorycard::getIconStateArray()); + memorycard::IconState (*icons)[0x7f] = reinterpret_cast(memorycard::getIconStateArray()); int total = 0; int file = mFile[slot][index].fileNo; s16 frame = 0; do { - u32 shift = frame; + u32 shift = frame << 1; frame++; - total += ((icons[slot][file].anmFrameBits >> ((shift & 0x1f) << 1)) & 3) * 4; + total += ((icons[slot][file].anmFrameBits >> shift) & 3) * 4; if (mFileCell[slot][file].iconAnmCounter <= total) { break; } - } while (frame < 9); + } while (frame <= 8); return _create_icon(slot, file, frame - 1); }