Compare commits

...

1 Commits

15 changed files with 795 additions and 455 deletions

View File

@@ -52,10 +52,10 @@ namespace ipl {
class Button {
public:
Button(nw4r::lyt::Pane* pane) : unk_0x04(0), mPane(pane) {}
Button(nw4r::lyt::Pane* pane) : mHoverCount(0), mPane(pane) {}
virtual ~Button();
u32 unk_0x04; // 0x04
u32 mHoverCount; // 0x04
nw4r::lyt::Pane* mPane; // 0x08
nw4r::ut::Link mLink; // 0x0C
};
@@ -63,8 +63,8 @@ namespace ipl {
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) {}
: mHoverCount(0), mName(name), mCurrentAnm(NULL), mAnm1(anm1), mAnm2(anm2), mAnm3(anm3),
mAnimationState(0), mLastCmd(0), mpBalloon(NULL) {}
virtual ~AnmButton();
void calc();
@@ -72,14 +72,14 @@ namespace ipl {
void setBalloon(TextBalloon* balloon);
int unk_0x04; // 0x04
int mHoverCount; // 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
u32 mAnimationState; // 0x24
int mLastCmd; // 0x28
TextBalloon* mpBalloon; // 0x2C
};
@@ -92,7 +92,7 @@ namespace ipl {
#ifdef IPL_MEMORYCARD_BASE_CTOR_OUT_OF_LINE
MemoryBase();
#else
MemoryBase() : mpLayout(NULL), unk_0x08(NULL) {
MemoryBase() : mpLayout(NULL), mpLayoutFile(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));
@@ -136,7 +136,7 @@ namespace ipl {
protected:
layout::Object* mpLayout; // 0x04
nand::LayoutFile* unk_0x08; // 0x08
nand::LayoutFile* mpLayoutFile; // 0x08
gui::PaneManager* mpPaneManager; // 0x0C
nw4r::ut::List mAnmList; // 0x10
nw4r::ut::List mButtonList; // 0x1C

View File

@@ -72,7 +72,7 @@ namespace ipl {
typedef struct MCFile {
u32 fileNo; // 0x00
u32 reserved; // 0x04
u32 unk_0x08; // 0x08
u32 sortKeyHigh; // 0x08
s32 sortKey; // 0x0C
} MCFile; // 0x10
@@ -99,8 +99,8 @@ namespace ipl {
mLastCmd = 0;
__CARDSetDiskID(NULL);
memorycard::initCardThread();
sort_file_array(0);
sort_file_array(1);
sort_file_array(CARD_CHAN_0);
sort_file_array(CARD_CHAN_1);
}
virtual ~MemoryCardManager();
@@ -188,13 +188,13 @@ namespace ipl {
private:
GXTexObj* initBannerTexture(u8 slot, s32 file, void* data) {
GXInitTexObj(&mFileCell[slot][file].banner, data, 0x60, 0x20,
GXInitTexObj(&mFileCell[slot][file].banner, data, CARD_BANNER_WIDTH, CARD_BANNER_HEIGHT,
GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
return &mFileCell[slot][file].banner;
}
void initBannerTextureCI(u8 slot, s32 file, void* data) {
GXInitTexObjCI(&mFileCell[slot][file].banner, data, 0x60, 0x20,
GXInitTexObjCI(&mFileCell[slot][file].banner, data, CARD_BANNER_WIDTH, CARD_BANNER_HEIGHT,
GX_TF_C8, GX_CLAMP, GX_CLAMP, GX_FALSE, GX_TLUT0);
}
@@ -204,8 +204,8 @@ namespace ipl {
}
u32 reserved; // 0x00004
MCFile mFile[2][0x7F]; // 0x00008
MCFileCell mFileCell[2][0x7F]; // 0x00FE8
MCFile mFile[2][CARD_MAX_FILE]; // 0x00008
MCFileCell mFileCell[2][CARD_MAX_FILE]; // 0x00FE8
s32 mLastResult; // 0x16930
s32 mLastCmd; // 0x16934
u32 mReservedResult; // 0x16938

View File

@@ -13,7 +13,7 @@ namespace memorycard {
struct CardThreadState {
CardState slots[2];
FileInfo files[2][127];
FileInfo files[2][CARD_MAX_FILE];
void* mountBuffers[2];
s32 mounted[2];
OSMessageQueue responses;
@@ -26,9 +26,9 @@ struct CardThreadState {
CARDFileInfo sourceFile;
CARDFileInfo destinationFile;
void* transferBuffer;
IconState icons[2][127];
u8* images[2][127];
char* comments[2][127];
IconState icons[2][CARD_MAX_FILE];
u8* images[2][CARD_MAX_FILE];
char* comments[2][CARD_MAX_FILE];
u8 commentBuffer[0x400] ATTRIBUTE_ALIGN(32);
u8* imageReadBuffer;
s32 lastCommand;
@@ -150,31 +150,31 @@ done:
extern "C" s32 mapCardErrorCode(s32 result) {
switch (result) {
case 0:
case CARD_RESULT_READY:
return 0;
case -2:
case CARD_RESULT_WRONGDEVICE:
return -28;
case -3:
case CARD_RESULT_NOCARD:
return -28;
case -4:
case CARD_RESULT_NOFILE:
return -28;
case -5:
case CARD_RESULT_IOERROR:
return -28;
case -6:
case CARD_RESULT_BROKEN:
return -28;
case -7:
case CARD_RESULT_EXIST:
return -24;
case -8:
case CARD_RESULT_NOENT:
return -25;
case -9:
case CARD_RESULT_INSSPACE:
return -25;
case -10:
case CARD_RESULT_NOPERM:
return -28;
case -11:
case CARD_RESULT_LIMIT:
return -28;
case -12:
case CARD_RESULT_NAMETOOLONG:
return -28;
case -13:
case CARD_RESULT_ENCODING:
return -28;
case -27:
return -27;
@@ -212,34 +212,34 @@ checkCommand:
switch ((s8)(((u32)message << 16) >> 24)) {
case -27:
case -7:
case 0:
case CARD_RESULT_EXIST:
case CARD_RESULT_READY:
OSReport("ready or exit\n");
sThread->slots[slot].state = 4;
break;
case -9:
case -8:
case CARD_RESULT_INSSPACE:
case CARD_RESULT_NOENT:
OSReport("Card hasn't enough space\n");
sThread->slots[slot].state = 4;
break;
case -2:
case CARD_RESULT_WRONGDEVICE:
OSReport("Wrong Device\n");
sThread->slots[slot].state = 5;
break;
case -6:
case CARD_RESULT_BROKEN:
OSReport("Broken Card\n");
sThread->slots[slot].state = 6;
break;
case -13:
case CARD_RESULT_ENCODING:
OSReport("Other Language\n");
sThread->slots[slot].state = 8;
break;
case -3:
case CARD_RESULT_NOCARD:
OSReport("Detach Card\n");
sThread->slots[slot].state = 0;
@@ -281,23 +281,23 @@ void initCardThread() {
MEMInitAllocatorForExpHeap(&sAllocator_, handle, 32);
sAllocator_.heapParam2 = (u32)memory;
OSReport("HEAP CREATE: %p %d\n", memory, size);
sThread = (CardThreadState*)MEMAllocFromAllocator(&sAllocator_, sizeof(CardThreadState));
sThread = static_cast<CardThreadState*>(MEMAllocFromAllocator(&sAllocator_, sizeof(CardThreadState)));
memset(sThread, 0, sizeof(CardThreadState));
sThread->images[0][0] = (u8*)MEMAllocFromAllocator(&sAllocator_, 0x594C00);
sThread->comments[0][0] = (char*)MEMAllocFromAllocator(&sAllocator_, 0x3F80);
sThread->imageReadBuffer = (u8*)MEMAllocFromAllocator(&sAllocator_, 0x5A00);
sThread->images[0][0] = static_cast<u8*>(MEMAllocFromAllocator(&sAllocator_, 0x594C00));
sThread->comments[0][0] = static_cast<char*>(MEMAllocFromAllocator(&sAllocator_, 0x3F80));
sThread->imageReadBuffer = static_cast<u8*>(MEMAllocFromAllocator(&sAllocator_, 0x5A00));
sThread->transferBuffer = MEMAllocFromAllocator(&sAllocator_, 0x40000);
sThread->mountBuffers[0] = MEMAllocFromAllocator(&sAllocator_, 0xA000);
sThread->mountBuffers[1] = MEMAllocFromAllocator(&sAllocator_, 0xA000);
sThread->mountBuffers[0] = MEMAllocFromAllocator(&sAllocator_, CARD_WORKAREA_SIZE);
sThread->mountBuffers[1] = MEMAllocFromAllocator(&sAllocator_, CARD_WORKAREA_SIZE);
}
for (index = 0; index < 127; index++) {
for (index = 0; index < CARD_MAX_FILE; index++) {
sThread->images[0][index] = sThread->images[0][0] + index * 0x5A00;
sThread->comments[0][index] = sThread->comments[0][0] + index * 0x40;
sThread->comments[0][index] = sThread->comments[0][0] + index * CARD_COMMENT_SIZE;
}
for (index = 0; index < 127; index++) {
sThread->images[1][index] = sThread->images[0][0] + (index + 127) * 0x5A00;
sThread->comments[1][index] = sThread->comments[0][0] + (index + 127) * 0x40;
for (index = 0; index < CARD_MAX_FILE; index++) {
sThread->images[1][index] = sThread->images[0][0] + (index + CARD_MAX_FILE) * 0x5A00;
sThread->comments[1][index] = sThread->comments[0][0] + (index + CARD_MAX_FILE) * CARD_COMMENT_SIZE;
}
OSInitMessageQueue(&sThread->responses, sThread->responseMessages, 0x10);
@@ -329,7 +329,7 @@ BOOL shutdownCardThread() {
MEMFreeToAllocator(&sAllocator_, sThread->comments[0][0]);
MEMFreeToAllocator(&sAllocator_, sThread);
sThread = 0;
MEMDestroyExpHeap((MEMHeapHandle)sAllocator_.heap);
MEMDestroyExpHeap(static_cast<MEMHeapHandle>(sAllocator_.heap));
System::createMem1AppHeap()->free((void*)sAllocator_.heapParam2);
System::destroyMem1AppHeap();
OSReport("HEAP DESTROY\n");
@@ -366,21 +366,21 @@ extern "C" void refreshCardSlotInfo(s32 slot) {
s32 freeBytes;
s32 freeFiles;
s32 result = CARDGetMemSize(slot, &memSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
OSReport("Get Memsize Error-%d: %d: %d\n", slot, result, memSize);
}
result = CARDGetSectorSize(slot, &sectorSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
OSReport("Get Sector Error- %d: %d\n", result, sectorSize);
}
result = CARDFreeBlocks(slot, &freeBytes, &freeFiles);
if (result < 0) {
if (result < CARD_RESULT_READY) {
OSReport("Get FreeBlocks Error- %d %d\n", result, freeBytes);
}
if (CARDGetResultCode(slot) >= 0) {
if (CARDGetResultCode(slot) >= CARD_RESULT_READY) {
BOOL interrupts = OSDisableInterrupts();
sThread->slots[slot].unk_0x0C = ((u32)memSize << 17) / sectorSize - 5;
sThread->slots[slot].unk_0x0C = ((u32)memSize << 17) / sectorSize - CARD_NUM_SYSTEM_BLOCK;
sThread->slots[slot].key = sectorSize;
sThread->slots[slot].unk_0x0E = freeFiles;
sThread->slots[slot].freeBlocks = freeBytes / sectorSize;
@@ -405,7 +405,7 @@ static inline void sendValidityResponse(u32 command, u32 valid) {
} reply;
reply.value = command;
reply.fields.valid = valid;
OSSendMessage(&sThread->responses, (OSMessage)reply.value, 1);
OSSendMessage(&sThread->responses, (OSMessage)reply.value, OS_MESSAGE_BLOCK);
}
extern "C" void* cardThreadMain(void*) {
@@ -434,7 +434,7 @@ extern "C" void* cardThreadMain(void*) {
sThread->mounted[1] = 0;
goto loopCheck;
loopStart:
OSReceiveMessage(&sThread->requests, (OSMessage*)&local.message, 1);
OSReceiveMessage(&sThread->requests, (OSMessage*)&local.message, OS_MESSAGE_BLOCK);
OSReport("CARD THREAD: Message received %d\n", (s8)(u8)local.message);
if (validState != TRUE) {
goto loopCheck;
@@ -454,25 +454,25 @@ loopStart:
slot = (local.message >> 16) & 1;
command = (local.message >> 14) & 4;
result = CARDMount(slot, sThread->mountBuffers[command / 4], 0);
if (result < 0) {
if (result < CARD_RESULT_READY) {
result = handleCardMountResult(slot, result);
if (result != 0) {
if (result != CARD_RESULT_READY) {
goto mountContinue;
}
break;
}
result = CARDCheck(slot);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto mountError;
}
mountContinue:
clearAllCardFileEntries(slot);
for (file = 0; file < 0x7F; ++file) {
for (file = 0; file < CARD_MAX_FILE; ++file) {
result = __CARDGetStatusEx(slot, (s16)file, &local.mountDir);
if (result < 0) {
if (result < CARD_RESULT_READY) {
result = handleCardMountResult(slot, result);
if (result != 0) {
if (result != CARD_RESULT_READY) {
continue;
}
goto loopCheck;
@@ -492,12 +492,12 @@ loopStart:
}
if (brokenFile) {
result = CARDFastDelete(slot, (s16)file);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto mountError;
}
} else {
result = loadCardFileIcons(slot, (s16)file, &local.mountDir);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto mountError;
}
}
@@ -507,10 +507,10 @@ loopStart:
sThread->mounted[command / 4] = 1;
sendCardSlotState(slot, 0, 0);
OSReport("Slot %c\n", sCardSlotName[slot]);
for (listingFile = 0; listingFile < 0x7F; ++listingFile) {
if (__CARDGetStatusEx(slot, (u16)listingFile, &local.listingDir) == 0) {
memcpy(local.fileName, local.listingDir.fileName, 0x20);
local.fileName[0x20] = 0;
for (listingFile = 0; listingFile < CARD_MAX_FILE; ++listingFile) {
if (__CARDGetStatusEx(slot, (u16)listingFile, &local.listingDir) == CARD_RESULT_READY) {
memcpy(local.fileName, local.listingDir.fileName, CARD_FILENAME_MAX);
local.fileName[CARD_FILENAME_MAX] = 0;
OSReport("%d - %s: %d blocks\n", (u16)listingFile, local.fileName,
local.listingDir.length);
}
@@ -523,12 +523,12 @@ loopStart:
break;
}
case 9:
reportCardThreadError((local.message >> 16) & 1, 9, -3);
reportCardThreadError((local.message >> 16) & 1, 9, CARD_RESULT_NOCARD);
break;
case 1: {
slot = (local.message >> 16) & 1;
result = CARDFormat(slot);
if (result < 0) {
if (result < CARD_RESULT_READY) {
reportCardThreadError(slot, 1, result);
} else {
sThread->mounted[slot] = 1;
@@ -549,7 +549,7 @@ loopStart:
slot = (local.message >> 16) & 1;
fileNo = (s16)(local.message >> 24);
result = CARDFastDelete(slot, fileNo);
if (result < 0) {
if (result < CARD_RESULT_READY) {
reportCardThreadError(slot, 4, result);
} else {
clearCardFileEntry(slot, fileNo);
@@ -564,13 +564,13 @@ loopStart:
do {
if (sThread->mounted[outerSlot] != 0) {
freeBlocks = 0;
for (freeFile = 0; freeFile < 0x7F; ++freeFile) {
for (freeFile = 0; freeFile < CARD_MAX_FILE; ++freeFile) {
result = __CARDGetStatusEx(outerSlot, freeFile, &local.freeDir);
if (result < 0 && result != -4) {
if (result < CARD_RESULT_READY && result != CARD_RESULT_NOFILE) {
freeBlocks = -1;
break;
}
if (result == 0 &&
if (result == CARD_RESULT_READY &&
memcmp(local.freeDir.gameName, (void*)0x80000000, 4) == 0 &&
memcmp(local.freeDir.company, (void*)0x80000004, 2) == 0) {
freeBlocks += local.freeDir.length;
@@ -612,26 +612,26 @@ extern "C" void markAllCardFilesDirty() {
}
++fileNo;
} while (fileNo < 0x7F);
} while (fileNo < CARD_MAX_FILE);
++slot;
} while ((s32)slot < 2);
}
extern "C" s32 handleCardMountResult(s32 slot, s32 result) {
if (result == -5) {
if (result == CARD_RESULT_IOERROR) {
goto reportError;
}
if (result >= -5) {
if (result >= CARD_RESULT_IOERROR) {
goto positiveResult;
}
if (result >= -6) {
if (result >= CARD_RESULT_BROKEN) {
goto repairedCard;
}
goto reportError;
positiveResult:
if (result < -3) {
if (result < CARD_RESULT_NOCARD) {
return 1;
}
goto reportError;
@@ -639,7 +639,7 @@ positiveResult:
repairedCard:
{
result = CARDCheck(slot);
if (result < 0) {
if (result < CARD_RESULT_READY) {
return reportCardThreadError(slot, 0, result);
}
OSReport("CardThread:Broken Card Repaired\n");
@@ -651,8 +651,8 @@ reportError:
}
extern "C" s32 reportCardThreadError(s32 slot, s32 state, s32 result) {
if (result != -7 && result != -27 && result != -8 && result != -9 &&
(clearAllCardFileEntries(slot), result != -6) && result != -13) {
if (result != CARD_RESULT_EXIST && result != -27 && result != CARD_RESULT_NOENT && result != CARD_RESULT_INSSPACE &&
(clearAllCardFileEntries(slot), result != CARD_RESULT_BROKEN) && result != CARD_RESULT_ENCODING) {
OSReport("DEBUG: UnmountCard %d \n", slot);
CARDUnmount(slot);
sThread->mounted[slot & 0xFF] = 0;
@@ -660,7 +660,7 @@ extern "C" s32 reportCardThreadError(s32 slot, s32 state, s32 result) {
OSReport("DEBUG: CardThread error %d %d\n", state, result);
markAllCardFilesDirty();
OSSendMessage(&sThread->responses,
(OSMessage)(((slot & 1) << 16) | ((result & 0xFF) << 8) | (state & 0xFF)), 1);
(OSMessage)(((slot & 1) << 16) | ((result & 0xFF) << 8) | (state & 0xFF)), OS_MESSAGE_BLOCK);
return 0;
}
@@ -680,7 +680,7 @@ extern "C" void sendCardSlotState(s32 slot, s32 state, s32 fileNo) {
message.value = (u32)fileNo << 24;
message.fields.slot = slot;
message.fields.state = state;
OSSendMessage(queue, (OSMessage)message.value, 1);
OSSendMessage(queue, (OSMessage)message.value, OS_MESSAGE_BLOCK);
}
extern "C" void clearAllCardFileEntries(s32 slot) {
@@ -688,7 +688,7 @@ extern "C" void clearAllCardFileEntries(s32 slot) {
do {
clearCardFileEntry(slot, (s16)file);
file = file + 1;
} while (file < 0x7F);
} while (file < CARD_MAX_FILE);
}
extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
@@ -701,21 +701,21 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
u32 iconAddressBase;
s32 result;
result = CARDFastOpen(slot, fileNo, &local.fileInfo);
if (result < 0) {
if (result < CARD_RESULT_READY) {
return result;
}
s32 bannerImageSize = 0;
u8 format = dir->bannerFormat & 3;
u8 format = dir->bannerFormat & CARD_STAT_BANNER_MASK;
u32 iconAddress = dir->iconAddr;
iconAddressBase = iconAddress & 0xFFFFFE00;
iconAddressOffset = iconAddress - iconAddressBase;
switch (format) {
case 1: {
case CARD_STAT_BANNER_C8: {
bannerImageSize = 0xE00;
sThread->icons[slot][fileNo].bannerEnable = 1;
sThread->icons[slot][fileNo].bannerType = 9;
sThread->icons[slot][fileNo].bannerType = GX_TF_C8;
sThread->icons[slot][fileNo].bannerOffset =
(s32)sThread->images[slot][fileNo] -
(s32)&sThread->icons[slot][fileNo];
@@ -725,10 +725,10 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
sThread->icons[slot][fileNo].bannerTlutOffset + 0x200;
break;
}
case 2: {
case CARD_STAT_BANNER_RGB5A3: {
bannerImageSize = 0x1800;
sThread->icons[slot][fileNo].bannerEnable = 1;
sThread->icons[slot][fileNo].bannerType = 5;
sThread->icons[slot][fileNo].bannerType = GX_TF_RGB5A3;
sThread->icons[slot][fileNo].bannerOffset =
(s32)sThread->images[slot][fileNo] -
(s32)&sThread->icons[slot][fileNo];
@@ -754,9 +754,9 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
sThread->icons[slot][fileNo].anmMax = 0;
sThread->icons[slot][fileNo].anmFrameBits = dir->iconSpeed;
sThread->icons[slot][fileNo].unk_0x06 =
(dir->iconSpeed & 3) << 2;
for (icon = 0; icon < 8; ++icon) {
s32 iconSpeed = (dir->iconSpeed >> shift) & 3;
(dir->iconSpeed & CARD_STAT_SPEED_MASK) << 2;
for (icon = 0; icon < CARD_ICON_MAX; ++icon) {
s32 iconSpeed = (dir->iconSpeed >> shift) & CARD_STAT_SPEED_MASK;
if (iconSpeed != 0) {
sThread->icons[slot][fileNo].anmMax =
sThread->icons[slot][fileNo].anmMax + (iconSpeed << 2);
@@ -769,31 +769,31 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
shift = shift + 2;
}
sThread->icons[slot][fileNo].unk_0x07 =
((u16)dir->iconSpeed >> 0xC) & 0xC;
(dir->iconSpeed >> 0xC) & 0xC;
iconSpeedDone:
if ((dir->iconSpeed & 3) == 0 || (dir->iconFormat & 3) == 0) {
if ((dir->iconSpeed & CARD_STAT_SPEED_MASK) == 0 || (dir->iconFormat & CARD_STAT_ICON_MASK) == 0) {
iconImageSize = 0;
sThread->icons[slot][fileNo].unk_0x01 = 0;
} else {
BOOL hasTlut = FALSE;
iconCount = 0;
shift = 0;
for (icon = 0; icon < 8; ++icon) {
if (((dir->iconSpeed >> shift) & 3) != 0) {
s32 iconFormat = (dir->iconFormat >> shift) & 3;
for (icon = 0; icon < CARD_ICON_MAX; ++icon) {
if (((dir->iconSpeed >> shift) & CARD_STAT_SPEED_MASK) != 0) {
s32 iconFormat = (dir->iconFormat >> shift) & CARD_STAT_ICON_MASK;
s32 paletteSize;
switch (iconFormat) {
case 1:
case CARD_STAT_ICON_C8:
paletteSize = 0x400;
hasTlut = TRUE;
sThread->icons[slot][fileNo].iconFmt[iconCount] = 9;
sThread->icons[slot][fileNo].iconFmt[iconCount] = GX_TF_C8;
break;
case 2:
case CARD_STAT_ICON_RGB5A3:
paletteSize = 0x800;
sThread->icons[slot][fileNo].iconFmt[iconCount] = 5;
sThread->icons[slot][fileNo].iconFmt[iconCount] = GX_TF_RGB5A3;
break;
case 0: {
case CARD_STAT_ICON_NONE: {
paletteSize = 0;
u8* iconPalette =
&sThread->icons[slot][fileNo].iconFmt[iconCount];
@@ -833,7 +833,7 @@ iconSpeedDone:
s32 totalImageSize = iconImageSize + bannerImageSize;
u32 transferSize = (totalImageSize + iconAddressOffset + 0x1FF) & 0xFFFFFE00;
result = CARDGetSectorSize(slot, (u32*)&local.sectorSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
result = 0;
sThread->icons[slot][fileNo].bannerEnable = 0;
sThread->icons[slot][fileNo].unk_0x01 = 0;
@@ -850,18 +850,18 @@ iconSpeedDone:
} else if (totalImageSize > 0) {
result = CARDRead(&local.fileInfo, sThread->imageReadBuffer,
transferSize, iconAddressBase);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto closeFile;
}
memcpy(sThread->images[slot][fileNo],
(u8*)sThread->imageReadBuffer + iconAddressOffset,
sThread->imageReadBuffer + iconAddressOffset,
totalImageSize);
DCStoreRange(sThread->images[slot][fileNo], transferSize);
result = 0;
}
}
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto closeFile;
}
@@ -870,7 +870,7 @@ iconSpeedDone:
s32 commentDataOffset = iconAddress - iconAddressBase;
s32 imageSize = ((iconAddress + 0x23F) & 0xFFFFFE00) - iconAddressBase;
result = CARDGetSectorSize(slot, (u32*)&local.commentSectorSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto clearComment;
}
{
@@ -886,22 +886,22 @@ iconSpeedDone:
}
result = CARDRead(&local.fileInfo, sThread->commentBuffer, imageSize,
iconAddressBase);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto clearComment;
}
memset(sThread->comments[slot][fileNo], 0, 0x40);
memset(sThread->comments[slot][fileNo], 0, CARD_COMMENT_SIZE);
memcpy(sThread->comments[slot][fileNo],
sThread->commentBuffer + commentDataOffset, 0x40);
sThread->commentBuffer + commentDataOffset, CARD_COMMENT_SIZE);
result = 0;
goto commentDone;
}
}
clearComment:
memset(sThread->comments[slot][fileNo], 0, 0x40);
memset(sThread->comments[slot][fileNo], 0, CARD_COMMENT_SIZE);
commentDone:
if (result >= 0) {
if (result >= CARD_RESULT_READY) {
goto closeFileSuccess;
}
closeFile:
@@ -909,7 +909,7 @@ closeFile:
closeFileSuccess:
result = CARDClose(&local.fileInfo);
if (result < 0) {
if (result < CARD_RESULT_READY) {
return result;
}
@@ -929,23 +929,23 @@ extern "C" s32 checkCardFileDuplicate(s32 slot, s16 fileNo) {
CARDDir sourceDir;
CARDDir otherDir;
s32 result = __CARDGetStatusEx(slot, fileNo, &sourceDir);
if (result < 0) {
if (result < CARD_RESULT_READY) {
return result;
}
s32 file = 0;
do {
s32 otherResult = __CARDGetStatusEx(slot ^ 1, file, &otherDir);
if (otherResult < 0 && otherResult != -4) {
if (otherResult < CARD_RESULT_READY && otherResult != CARD_RESULT_NOFILE) {
return otherResult;
}
if (otherResult == 0 && memcmp(sourceDir.gameName, otherDir.gameName, 4) == 0 &&
if (otherResult == CARD_RESULT_READY && memcmp(sourceDir.gameName, otherDir.gameName, 4) == 0 &&
memcmp(sourceDir.company, otherDir.company, 2) == 0 &&
memcmp(sourceDir.fileName, otherDir.fileName, 0x20) == 0) {
return -7;
memcmp(sourceDir.fileName, otherDir.fileName, CARD_FILENAME_MAX) == 0) {
return CARD_RESULT_EXIST;
}
file = file + 1;
} while (file < 0x7F);
} while (file < CARD_MAX_FILE);
return 0;
}
@@ -962,16 +962,16 @@ static inline s16 createCardTemporaryFile(s32 destinationSlot, const CARDDir& so
sprintf(sThread->temporaryFileName, "Broken File%03d", attempt);
result = CARDCreate(destinationSlot, sThread->temporaryFileName,
fileSize, &sThread->destinationFile);
if (result < 0 && result != -7) {
if (result < CARD_RESULT_READY && result != CARD_RESULT_EXIST) {
OSReport("Can't Create temp File with Error.");
return (s16)result;
}
++attempt;
} while (result != 0 && attempt < 0x80);
} while (result != CARD_RESULT_READY && attempt < 0x80);
if (attempt < 0x80) {
destinationFileNo = sThread->destinationFile.fileNo;
} else {
destinationFileNo = -0x80;
destinationFileNo = CARD_RESULT_FATAL_ERROR;
}
return destinationFileNo;
}
@@ -1008,19 +1008,19 @@ extern "C" void runCardMoveOrCopy(u8 slot, s16 fileNo, s32 command) {
result = checkCardFileDuplicate(slot, fileNo);
if (result < 0) {
if (result < CARD_RESULT_READY) {
reportCardThreadError(slot, command, result);
goto finish;
}
commonSectorSize = 0;
result = CARDGetSectorSize(0, &sourceSectorSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
sectorError = result;
goto sectorSizeCheck;
}
result = CARDGetSectorSize(1, &destinationSectorSize);
if (result < 0) {
if (result < CARD_RESULT_READY) {
sectorError = result;
goto sectorSizeCheck;
}
@@ -1031,7 +1031,7 @@ extern "C" void runCardMoveOrCopy(u8 slot, s16 fileNo, s32 command) {
sectorError = 0;
}
sectorSizeCheck:
if (sectorError >= 0) {
if (sectorError >= CARD_RESULT_READY) {
goto sectorSizeDone;
}
sectorSizeError:
@@ -1043,30 +1043,30 @@ sectorSizeDone:
{
s32 permissionResult = 0;
statusResult = __CARDGetStatusEx(slot, fileNo, &checkedStatus);
if (statusResult >= 0) {
if (statusResult >= CARD_RESULT_READY) {
switch (command) {
case 2:
if (checkedStatus.permission & 8) {
permissionResult = -10;
if (checkedStatus.permission & CARD_ATTR_NO_COPY) {
permissionResult = CARD_RESULT_NOPERM;
}
break;
case 3:
if (checkedStatus.permission & 0x10) {
permissionResult = -10;
if (checkedStatus.permission & CARD_ATTR_NO_MOVE) {
permissionResult = CARD_RESULT_NOPERM;
}
break;
}
} else {
permissionResult = CARDGetResultCode(slot);
}
if (permissionResult < 0) {
if (permissionResult < CARD_RESULT_READY) {
reportCardThreadError(slot, command, permissionResult);
goto finish;
}
}
result = __CARDGetStatusEx(slot, fileNo, &createStatus);
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto cleanup;
}
@@ -1084,18 +1084,18 @@ sectorSizeDone:
u32 sectorSize;
ioResult = __CARDGetStatusEx(slot, fileNo, &ioStatus);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
stage = 1;
ioResult = CARDGetSectorSize(slot, &sectorSize);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
maxBlocks = 0x40000 / sectorSize;
stage = 2;
ioResult = CARDFastOpen(slot, fileNo, &sThread->sourceFile);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
block = 0;
@@ -1106,14 +1106,14 @@ sectorSizeDone:
size = blocks * sectorSize;
ioResult = CARDRead(&sThread->sourceFile,
sThread->transferBuffer, size, offset);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
sThread->writePending = 1;
ioResult = CARDWriteAsync(&sThread->destinationFile,
sThread->transferBuffer, size, offset,
clearCardWritePending);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
while (sThread->writePending != 0) {
@@ -1125,12 +1125,12 @@ sectorSizeDone:
}
stage = 4;
ioResult = CARDClose(&sThread->sourceFile);
if (ioResult < 0) {
if (ioResult < CARD_RESULT_READY) {
goto copyIoFailure;
}
stage = 5;
ioResult = CARDClose(&sThread->destinationFile);
if (ioResult >= 0) {
if (ioResult >= CARD_RESULT_READY) {
result = 0;
goto copyIoDone;
}
@@ -1162,38 +1162,38 @@ copyIoDone:
;
}
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto cleanup;
}
if (command == 2) {
copyResult = __CARDGetStatusEx(slot, fileNo, &sourceStatus);
if (copyResult < 0) {
if (copyResult < CARD_RESULT_READY) {
OSReport("Can't get status for src file\n");
} else {
++sourceStatus.copyTimes;
copyResult = __CARDSetStatusEx(slot, fileNo, &sourceStatus);
if (copyResult < 0) {
if (copyResult < CARD_RESULT_READY) {
OSReport("Can't set status for src file %d\n", copyResult);
} else {
oldTime = sourceStatus.time;
sourceStatus.time = (u32)(OSGetTime() / (*(u32*)0x800000F8 >> 2));
copyResult = __CARDSetStatusEx(destinationSlot, destinationFileNo,
&sourceStatus);
if (copyResult < 0) {
if (copyResult < CARD_RESULT_READY) {
OSReport("Can't set status for dst file (src file copyTimes--)\n");
if (copyResult != -3) {
if (copyResult != CARD_RESULT_NOCARD) {
--sourceStatus.copyTimes;
}
sourceStatus.time = oldTime;
s32 restoreResult = __CARDSetStatusEx(slot, fileNo, &sourceStatus);
if (restoreResult < 0) {
if (restoreResult < CARD_RESULT_READY) {
OSReport("Can't set status for src file(src file copyTimes--)\n");
}
} else {
metadataCopied = TRUE;
copyResult = loadCardFileIcons(destinationSlot, destinationFileNo,
&sourceStatus);
if (copyResult < 0) {
if (copyResult < CARD_RESULT_READY) {
OSReport("Can't read icon for move dstfile\n");
} else {
copyResult = 0;
@@ -1202,38 +1202,38 @@ copyIoDone:
}
}
result = copyResult;
if (result < 0) {
if (result < CARD_RESULT_READY) {
goto cleanup;
}
} else if (command == 3) {
renameAttempt = 0;
moveStage = 0;
moveResult = __CARDGetStatusEx(slot, fileNo, &moveStatus);
if (moveResult >= 0) {
if (moveResult >= CARD_RESULT_READY) {
++moveStage;
renamedStatus = moveStatus;
memset(renamedStatus.company, 0, 2);
memset(renamedStatus.gameName, 0, 4);
do {
memset(renamedStatus.fileName, 0, 0x20);
memset(renamedStatus.fileName, 0, CARD_FILENAME_MAX);
sprintf((char*)renamedStatus.fileName, "Broken File%03d", renameAttempt);
moveResult = __CARDSetStatusEx(slot, fileNo, &renamedStatus);
if (moveResult < 0 && moveResult != -7) {
if (moveResult < CARD_RESULT_READY && moveResult != CARD_RESULT_EXIST) {
goto moveStatusError;
}
++renameAttempt;
} while (moveResult != 0 && renameAttempt < 0x80);
} while (moveResult != CARD_RESULT_READY && renameAttempt < 0x80);
moveStage = 2;
moveResult = __CARDSetStatusEx(destinationSlot, destinationFileNo,
&moveStatus);
if (moveResult < 0) {
if (moveResult < CARD_RESULT_READY) {
s32 setResult = moveResult;
if (moveResult == -3) {
if (moveResult == CARD_RESULT_NOCARD) {
CARDFastDelete(slot, fileNo);
clearCardFileEntry(slot, fileNo);
} else {
s32 restoreResult = __CARDSetStatusEx(slot, fileNo, &moveStatus);
if (restoreResult < 0) {
if (restoreResult < CARD_RESULT_READY) {
OSReport("Can't repair src file - carddir\n");
}
}
@@ -1242,12 +1242,12 @@ copyIoDone:
metadataCopied = TRUE;
moveStage = 3;
moveResult = CARDFastDelete(slot, fileNo);
if (moveResult >= 0) {
if (moveResult >= CARD_RESULT_READY) {
clearCardFileEntry(slot, fileNo);
moveStage = 4;
moveResult = __CARDGetStatusEx(destinationSlot,
destinationFileNo, &moveStatus);
if (moveResult >= 0) {
if (moveResult >= CARD_RESULT_READY) {
moveStage = 5;
if ((moveResult = loadCardFileIcons(
destinationSlot, destinationFileNo, &moveStatus)) < 0) {
@@ -1281,7 +1281,7 @@ moveStatusError:
break;
}
moveStatusDone:
if (moveResult < 0) {
if (moveResult < CARD_RESULT_READY) {
goto cleanup;
}
}
@@ -1295,7 +1295,7 @@ moveStatusDone:
cleanup:
destinationSlot = slot ^ 1;
result = CARDGetResultCode(destinationSlot);
if (result < 0) {
if (result < CARD_RESULT_READY) {
reportCardThreadError(destinationSlot, command, result);
} else {
if (temporaryCreated && !metadataCopied) {
@@ -1303,7 +1303,7 @@ cleanup:
}
if (metadataCopied) {
if (__CARDGetStatusEx(destinationSlot, destinationFileNo,
&createStatus) == 0) {
&createStatus) == CARD_RESULT_READY) {
loadCardFileIcons(destinationSlot, destinationFileNo, &createStatus);
}
}
@@ -1311,7 +1311,7 @@ cleanup:
sendCardSlotState(destinationSlot, 0, fileNo & 0xFF);
}
result = CARDGetResultCode(slot);
if (result < 0) {
if (result < CARD_RESULT_READY) {
reportCardThreadError(slot, command, result);
} else {
refreshCardSlotInfo(slot);

View File

@@ -49,9 +49,9 @@ namespace ipl {
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))
if (static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->getManager()->isIconValidate(mSlot, mIndex) &&
static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->getManager()->create_icon(mSlot, mIndex) != NULL) {
material->SetTexture(0, *static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))
->getManager()
->create_icon(mSlot, mIndex));
} else {
@@ -80,12 +80,12 @@ namespace ipl {
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))
if (button->mHoverCount == 0) {
if (System::getScene(SCENE_MEMORY_CARD) != NULL) {
if (static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))
->getManager()
->isIconValidate(mSlot, mIndex)) {
mpBalloon->init(static_cast<MemoryCard*>(System::getScene(0xE))
mpBalloon->init(static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))
->getManager()
->getComment(mSlot, mIndex, 0),
0);
@@ -100,25 +100,25 @@ namespace ipl {
}
button->onCmdRecv(1);
}
button->unk_0x04++;
button->mHoverCount++;
}
}
void GCSaveData::onLeft(const char* paneName) {
AnmButton* button = get_anmbutton(paneName);
if (button != NULL) {
if (button->unk_0x04 == 1) {
if (button->mHoverCount == 1) {
button->onCmdRecv(2);
}
button->unk_0x04--;
button->mHoverCount--;
}
}
void GCSaveData::onTrig(const char* paneName) {
if (static_cast<MemoryCard*>(System::getScene(0xE)) != NULL &&
static_cast<MemoryCard*>(System::getScene(0xE))->getManager()->isIconValidate(mSlot, mIndex) &&
if (System::getScene(SCENE_MEMORY_CARD) != NULL &&
static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->getManager()->isIconValidate(mSlot, mIndex) &&
get_anmbutton(paneName) != NULL) {
static_cast<MemoryCard*>(System::getScene(0xE))->onFocus(this);
static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->onFocus(this);
}
}

View File

@@ -80,7 +80,7 @@ GCWindow::GCWindow(EGG::Heap* heap, nand::LayoutFile* layoutFile, const char* di
}
MemoryBase::MemoryBase() : mpLayout(NULL), unk_0x08(NULL) {
MemoryBase::MemoryBase() : mpLayout(NULL), mpLayoutFile(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));
@@ -143,7 +143,7 @@ void GCWindow::calc() {
mpPaneManager->calc();
void* button = NULL;
while ((button = nw4r::ut::List_GetNext(&mAnmButtonList, button)) != NULL) {
((MemoryBase::AnmButton*)button)->calc();
static_cast<MemoryBase::AnmButton*>(button)->calc();
}
switch (mState) {
case 0:
@@ -246,7 +246,7 @@ void GCWindow::draw() {
}
void GCWindow::destroy() {
((MemoryCard*)System::getScene(0xe))->onRelease();
static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->onRelease();
for (int i = 0; i < 3; i++) {
clear_button(scButtonName[i]);
}
@@ -260,24 +260,24 @@ void GCWindow::destroy() {
void GCWindow::onPoint(const char* name, controller::Interface* controller) {
MemoryBase::AnmButton* button = get_anmbutton(name);
if (button != NULL) {
if (button->unk_0x04 == 0) {
if (button->mHoverCount == 0) {
button->onCmdRecv(1);
snd::sSystem.startSE("WIPL_SE_BT_TARGETTING");
if (controller != NULL) {
controller->rumble(0);
}
}
button->unk_0x04++;
button->mHoverCount++;
}
}
void GCWindow::onLeft(const char* name) {
MemoryBase::AnmButton* button = get_anmbutton(name);
if (button != NULL) {
if (button->unk_0x04 == 1) {
if (button->mHoverCount == 1) {
button->onCmdRecv(2);
}
button->unk_0x04--;
button->mHoverCount--;
}
}
@@ -302,7 +302,7 @@ void GCWindow::onTrig(const char* name) {
void GCWindow::on_wait() {
for (int i = 0; i < 2; i++) {
if (mFlags0[i] != 0) {
((MemoryCard*)System::getScene(0xe))->onFocus(NULL);
static_cast<MemoryCard*>(System::getScene(SCENE_MEMORY_CARD))->onFocus(NULL);
System::getDialog()->callBtn2(i == 0 ? 0xec : 0xed, 0x142, 0x141, true);
mFlags0[i] = 0;
mCardState = i;
@@ -820,7 +820,7 @@ void SavedataEditWindow::calc() {
mpPaneManager->calc();
void* button = NULL;
while ((button = nw4r::ut::List_GetNext(&mAnmButtonList, button)) != NULL) {
((MemoryBase::AnmButton*)button)->calc();
static_cast<MemoryBase::AnmButton*>(button)->calc();
}
switch (mState) {
case 0:

View File

@@ -128,7 +128,7 @@ namespace ipl {
};
MemoryCard::MemoryCard(EGG::Heap* heap)
: Base(heap), MemoryBase(), mState(2), mPrevState(2), mSlot(0), mIconIndex(-15), mIconCount(0),
: Base(heap), MemoryBase(), mState(2), mPrevState(2), mSlot(SLOT_A), mIconIndex(-15), mIconCount(0),
mShowArwR(0), mShowArwL(0), mpEvent(NULL), mpFocusSaveData(NULL) {
System::getMem2App()->dump();
nw4r::ut::List_Init(&mSaveDataList, offsetof(GCSaveData, mLink));
@@ -138,7 +138,7 @@ namespace ipl {
void MemoryCard::prepare() {
System::getBS2Manager()->abort();
unk_0x08 = System::getNandManager()->readLayoutAsync(getSceneHeap(), "gcMem.ash");
mpLayoutFile = System::getNandManager()->readLayoutAsync(getSceneHeap(), "gcMem.ash");
mBalloonLayoutFile = System::getNandManager()->readLayoutAsync(getSceneHeap(), "balloon.ash");
}
@@ -153,10 +153,10 @@ namespace ipl {
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");
mpLayout = new layout::Object(getSceneHeap(), mpLayoutFile, "arc", "it_ObjCubeEdit_a.brlyt");
add_animation(scAnmName, 0x1B);
get_animation(7)->mAnim->setAnmType(1);
get_animation(10)->mAnim->setAnmType(1);
get_animation(7)->mAnim->setAnmType(ANIM_TYPE_BACKWARD);
get_animation(10)->mAnim->setAnmType(ANIM_TYPE_BACKWARD);
mpLayout->finishBinding();
do_animation(0);
do_animation(1);
@@ -187,7 +187,7 @@ namespace ipl {
set_textbox(scTextboxToMessageID[i].paneName, scTextboxToMessageID[i].messageId);
}
mpGCWindow = new GCWindow(getSceneHeap(), unk_0x08, "arc", "it_CubeDetail_a.brlyt");
mpGCWindow = new GCWindow(getSceneHeap(), mpLayoutFile, "arc", "it_CubeDetail_a.brlyt");
mpGCWindow->do_animation(0);
MemoryCardManager* manager = new MemoryCardManagerImpl();
@@ -198,9 +198,9 @@ namespace ipl {
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));
PSMTXMultVec(pane->GetGlobalMtx(), position, position);
GCSaveData* saveData =
new GCSaveData(getSceneHeap(), unk_0x08, "arc", "it_ObjCubeEdit_b.brlyt", position);
new GCSaveData(getSceneHeap(), mpLayoutFile, "arc", "it_ObjCubeEdit_b.brlyt", position);
saveData->set_visible("N_Data_00", false);
nw4r::ut::List_Append(&mSaveDataList, saveData);
if (i >= 0xF && i < 0x1E) {
@@ -345,9 +345,9 @@ namespace ipl {
}
controller::Interface* controller = System::getYoungController();
if (controller != NULL) {
if (controller->down(0x30001000)) {
if (controller->down(controller::BTN_NEXT_LEFT)) {
start_scroll_l();
} else if (controller->down(0x06000010)) {
} else if (controller->down(controller::BTN_NEXT_RIGHT)) {
start_scroll_r();
}
}
@@ -466,19 +466,19 @@ namespace ipl {
}
void MemoryCard::start_errormessage_fadein() {
if (mpManager->isSlotWrongDevice(mSlot) != 0) {
if (mpManager->isSlotWrongDevice(mSlot)) {
mSlotState[mSlot] = 3;
set_textbox("T_Error_00", mSlot == 0 ? 0xE8 : 0xE9);
set_textbox("T_Error_00", mSlot == SLOT_A ? 0xE8 : 0xE9);
} else {
mSlotState[mSlot] = 2;
set_textbox("T_Error_00", mSlot == 0 ? 0xE6 : 0xE7);
set_textbox("T_Error_00", mSlot == SLOT_A ? 0xE6 : 0xE7);
}
set_visible("T_Error_00", true);
do_animation(0x19);
}
int MemoryCard::update_slot() {
if (mSlotState[mSlot] != 1 && mpManager->isSlotReady(mSlot) != 0) {
if (mSlotState[mSlot] != 1 && mpManager->isSlotReady(mSlot)) {
for (u16 i = 0xF; i < 0x1E; i++) {
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
}
@@ -490,7 +490,7 @@ namespace ipl {
mState = 0xB;
return true;
}
if (mSlotState[mSlot] != 2 && mpManager->isSlotNoCard(mSlot) != 0) {
if (mSlotState[mSlot] != 2 && mpManager->isSlotNoCard(mSlot)) {
for (u16 i = 0xF; i < 0x1E; i++) {
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
}
@@ -501,7 +501,7 @@ namespace ipl {
mState = 0xC;
return true;
}
if ((mSlotState[mSlot] != 3 && mpManager->isSlotWrongDevice(mSlot) != 0) || mSlotState[mSlot] == 0) {
if ((mSlotState[mSlot] != 3 && mpManager->isSlotWrongDevice(mSlot)) || mSlotState[mSlot] == 0) {
for (u16 i = 0xF; i < 0x1E; i++) {
static_cast<GCSaveData*>(nw4r::ut::List_GetNth(&mSaveDataList, i))->init();
}
@@ -579,7 +579,7 @@ namespace ipl {
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));
PSMTXMultVec(pane->GetGlobalMtx(), position, position);
saveData->setTranslate(position);
saveData->init();
}
@@ -642,28 +642,28 @@ namespace ipl {
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)) {
if (button->mHoverCount == 0 &&
(strcmp(paneName, scTriggerPaneName[2]) != 0 || mSlot != SLOT_A) &&
(strcmp(paneName, scTriggerPaneName[3]) != 0 || mSlot != SLOT_B)) {
button->onCmdRecv(1);
snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING");
if (controller != NULL) {
controller->rumble(0);
}
}
button->unk_0x04++;
button->mHoverCount++;
}
}
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)) {
if (button->mHoverCount == 1 &&
(strcmp(paneName, scTriggerPaneName[2]) != 0 || mSlot != SLOT_A) &&
(strcmp(paneName, scTriggerPaneName[3]) != 0 || mSlot != SLOT_B)) {
button->onCmdRecv(2);
}
button->unk_0x04--;
button->mHoverCount--;
}
}
@@ -676,7 +676,7 @@ namespace ipl {
do_animation(0xF);
start_scroll_l();
} else if (strcmp(paneName, scTriggerPaneName[2]) == 0) {
if (mSlot == 1) {
if (mSlot == SLOT_B) {
do_animation(0xB);
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {
@@ -689,7 +689,7 @@ namespace ipl {
mState = 5;
}
} else if (strcmp(paneName, scTriggerPaneName[3]) == 0) {
if (mSlot == 0) {
if (mSlot == SLOT_A) {
do_animation(8);
GCSaveData* saveData = NULL;
while ((saveData = static_cast<GCSaveData*>(nw4r::ut::List_GetNext(&mSaveDataList, saveData))) != NULL) {

View File

@@ -25,7 +25,7 @@ void MemoryBaseEvent::onEvent(u32 componentID, u32 event, void* data) {
mpBase->onMove(name);
break;
case ::gui::EventHandler::ON_TRIG:
if (static_cast<controller::Interface*>(data)->downTrg(0x100800)) {
if (static_cast<controller::Interface*>(data)->downTrg(controller::BTN_INTERACT)) {
mpBase->onTrig(name);
}
break;
@@ -53,10 +53,10 @@ void MemoryBase::clear_button(const char* paneName) {
AnmButton* button = get_anmbutton(paneName);
nw4r::lyt::Pane* pane = mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName(paneName, true);
mpPaneManager->initPane(pane);
if (button->unk_0x04 >= 1) {
if (button->mHoverCount >= 1) {
button->onCmdRecv(2);
}
button->unk_0x04 = 0;
button->mHoverCount = 0;
}
MemoryBase::Button* MemoryBase::get_button(const char* paneName) {
@@ -102,9 +102,9 @@ void MemoryBase::do_animation(int index) {
void MemoryBase::do_animation(int index, bool flag) {
Anm* animation = static_cast<Anm*>(nw4r::ut::List_GetNth(&mAnmList, index));
if (flag) {
animation->mAnim->setAnmType(1);
animation->mAnim->setAnmType(ANIM_TYPE_BACKWARD);
} else {
animation->mAnim->setAnmType(0);
animation->mAnim->setAnmType(ANIM_TYPE_FORWARD);
}
animation->mAnim->play();
mpLayout->calc();
@@ -165,21 +165,21 @@ SettingButton* MemoryBase::get_setting_button() {
}
void MemoryBase::change_button_text_close() {
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(2, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(3, 0xFC);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(1, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_HIDE_BTN, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SET_TEXT, 0xFC);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SHOW_BTN, 0);
}
void MemoryBase::change_button_text_return() {
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(2, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(3, 0x13B);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(1, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_HIDE_BTN, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SET_TEXT, 0x13B);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SHOW_BTN, 0);
}
void MemoryBase::change_button_text_ok() {
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(2, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(3, 0x2E);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(1, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_HIDE_BTN, 0);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SET_TEXT, 0x2E);
static_cast<SettingButton*>(System::getScene(SCENE_SETTING_BUTTON))->reserve(SettingButton::CMD_SHOW_BTN, 0);
}
void MemoryBase::show_button_return() {
@@ -207,38 +207,38 @@ void MemoryBase::AnmButton::onCmdRecv(int command) {
if (mLastCmd == 3) {
mCurrentAnm = mAnm3;
mCurrentAnm->mAnim->play();
unk_0x24 = 3;
mAnimationState = 3;
}
switch (unk_0x24) {
switch (mAnimationState) {
case 0:
if (command == 1) {
mCurrentAnm = mAnm1;
mCurrentAnm->mAnim->play();
unk_0x24 = 1;
mAnimationState = 1;
} else if (command == 2) {
mCurrentAnm = mAnm2;
mCurrentAnm->mAnim->play();
unk_0x24 = 2;
mAnimationState = 2;
}
break;
case 1:
if (command == 4) {
if (mLastCmd == 1) mLastCmd = 0;
if (mpBalloon != NULL) mpBalloon->fadein();
unk_0x24 = 0;
mAnimationState = 0;
}
break;
case 2:
if (command == 4) {
if (mLastCmd == 2) mLastCmd = 0;
if (mpBalloon != NULL) mpBalloon->fadeout();
unk_0x24 = 0;
mAnimationState = 0;
}
break;
case 3:
if (command == 4) {
if (mLastCmd == 3) mLastCmd = 0;
unk_0x24 = 0;
mAnimationState = 0;
}
break;
}

View File

@@ -34,8 +34,8 @@ extern "C" int compareMemoryCardSortEntries(const void* first, const void* secon
namespace ipl {
namespace scene {
typedef memorycard::FileInfo CardDirectory[0x7f];
typedef memorycard::IconState CardIcons[0x7f];
typedef memorycard::FileInfo CardDirectory[CARD_MAX_FILE];
typedef memorycard::IconState CardIcons[CARD_MAX_FILE];
void MemoryCardManager::calc() {
memorycard::probeCard();
@@ -82,18 +82,18 @@ long MemoryCardManager::isSlotWrongDevice(u8 slot) {
void MemoryCardManager::sort_file_array(u8 slot) {
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
for (long file = 0; file < 0x7f; file++) {
for (long file = 0; file < CARD_MAX_FILE; file++) {
if (dirs[slot][file].fileNo != 0) {
mFile[slot][file].fileNo = file;
mFile[slot][file].sortKey = dirs[slot][file].key;
mFile[slot][file].unk_0x08 = 0;
mFile[slot][file].sortKeyHigh = 0;
} else {
mFile[slot][file].fileNo = file;
mFile[slot][file].sortKey = -1 - file;
mFile[slot][file].unk_0x08 = 0;
mFile[slot][file].sortKeyHigh = 0;
}
}
qsort(mFile[slot], 0x7f, sizeof(MCFile), compareMemoryCardSortEntries);
qsort(mFile[slot], CARD_MAX_FILE, sizeof(MCFile), compareMemoryCardSortEntries);
}
void MemoryCardManager::sendCardCmdMove(u8 slot, s16 index) {
@@ -223,11 +223,11 @@ bool MemoryCardManager::isCopyEnable(u8 slot, u32 index, long* code) {
bool MemoryCardManager::isIconValidate(u8 slot, s16 index) {
u32 cardSlot = slot;
if (cardSlot > 1 || index < 0 || index >= 0x7f) {
if (cardSlot > 1 || index < 0 || index >= CARD_MAX_FILE) {
return false;
}
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
if (mFile[cardSlot][index].fileNo >= 0x7f) {
if (mFile[cardSlot][index].fileNo >= CARD_MAX_FILE) {
return false;
}
return dirs[cardSlot][mFile[cardSlot][index].fileNo].fileNo != 0;
@@ -244,9 +244,9 @@ void MemoryCardManager::update_icon_anm() {
int slot = 0;
do {
int index = 0;
for (int remaining = 0x7f; remaining > 0; remaining--, index++) {
for (int remaining = CARD_MAX_FILE; remaining > 0; remaining--, index++) {
u32 file = mFile[slot][index].fileNo;
if (file < 0x7f && dirs[slot][file].fileNo != 0) {
if (file < CARD_MAX_FILE && dirs[slot][file].fileNo != 0) {
memorycard::IconState* icon = icons[slot] + file;
s8 delta = icon->anmDelta;
s16 currentFrame = mFileCell[slot][file].iconAnmCounter;
@@ -290,21 +290,21 @@ void MemoryCardManager::update_file_array(u8 slot) {
}
if (mLastResult == 0) {
switch (mLastCmd) {
case 3:
case Move:
mpEventHandler->onMemEvent(2, slot);
mLastCmd = 6;
mLastCmd = MoveComplete;
break;
case 2:
case Copy:
mpEventHandler->onMemEvent(1, slot);
mLastCmd = 5;
mLastCmd = CopyComplete;
break;
case 4:
case Delete:
mpEventHandler->onMemEvent(3, slot);
mLastCmd = 7;
mLastCmd = DeleteComplete;
break;
case 1:
case Format:
mpEventHandler->onMemEvent(4, slot);
mLastCmd = 8;
mLastCmd = FormatComplete;
break;
}
}
@@ -327,10 +327,10 @@ void MemoryCardManager::update_change_cardstate(u8 slot) {
slot == memorycard::getCardLastSrcSlot()) {
mpEventHandler->onMemEvent(5, slot);
states[slot].changed = 0;
for (int file = 0; file < 0x7f; file++) {
for (int file = 0; file < CARD_MAX_FILE; file++) {
mFile[slot][file].fileNo = -1;
mFile[slot][file].sortKey = -1;
mFile[slot][file].unk_0x08 = 0;
mFile[slot][file].sortKeyHigh = 0;
mFileCell[slot][file].iconAnmCounter = 0;
wmemset(mFileCell[slot][file].comment[0], 0, 0x40);
}
@@ -342,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());
memorycard::IconState (*icons)[CARD_MAX_FILE] = reinterpret_cast<memorycard::IconState(*)[CARD_MAX_FILE]>(memorycard::getIconStateArray());
int total = 0;
s16 frame = 0;
u32 file = mFile[slot][index].fileNo;
@@ -369,10 +369,10 @@ GXTexObj* MemoryCardManager::_create_icon(u8 slot, s16 file, long start) {
CardIcons* icons = reinterpret_cast<CardIcons*>(memorycard::getIconStateArray());
memorycard::IconState* icon = &icons[slot][file];
if ((int)icon->iconFmt[start] == GX_TF_RGB5A3) {
GXInitTexObj(&mFileCell[slot][file].icon, reinterpret_cast<u8*>(icon) + icon->iconOffset[start], 0x20, 0x20, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
GXInitTexObj(&mFileCell[slot][file].icon, reinterpret_cast<u8*>(icon) + icon->iconOffset[start], CARD_ICON_WIDTH, CARD_ICON_HEIGHT, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
GXLoadTexObj(&mFileCell[slot][file].icon, GX_TEXMAP0);
} else if ((int)icon->iconFmt[start] == GX_TF_C8) {
GXInitTexObjCI(&mFileCell[slot][file].icon, reinterpret_cast<u8*>(icon) + icon->iconOffset[start], 0x20, 0x20, GX_TF_C8, GX_CLAMP, GX_CLAMP, GX_FALSE, GX_TLUT0);
GXInitTexObjCI(&mFileCell[slot][file].icon, reinterpret_cast<u8*>(icon) + icon->iconOffset[start], CARD_ICON_WIDTH, CARD_ICON_HEIGHT, GX_TF_C8, GX_CLAMP, GX_CLAMP, GX_FALSE, GX_TLUT0);
GXInitTlutObj(&mFileCell[slot][file].iconTlut, reinterpret_cast<u8*>(icon) + icons[slot][file].iconTlutOffset, GX_TL_RGB5A3, 0x100);
GXLoadTlut(&mFileCell[slot][file].iconTlut, GX_TLUT0);
GXLoadTexObj(&mFileCell[slot][file].icon, GX_TEXMAP0);
@@ -398,7 +398,7 @@ const wchar_t* MemoryCardManager::getComment(u8 slot, s16 index, int which) {
const char* comments = memorycard::getIconComment(slot, file);
memcpy(comment, comments + which * 0x20, 0x20);
const u8* encoded = trimCardComment(comment);
if (SCGetLanguage() == 0) {
if (SCGetLanguage() == SC_LANG_JAPANESE) {
utility::CharacterCode::shiftJISToUTF16(mFileCell[slot][file].comment[which], encoded, 0x20);
for (int pos = 0x1f;
mFileCell[slot][file].comment[which][pos] == 0x20 ||

View File

@@ -806,7 +806,7 @@ namespace ipl {
}
if (System::getDialog()->getLastResult() != -1) {
if (mpSDChannelSelect->getWorker()->get_async_result() == 0) {
if (mpSDChannelSelect->getWorker()->get_async_result() == NandSDWorker::RESULT_OK) {
mNandTitleCount = mTitleListState.mSecondaryCount;
mTitleNameCount = mTitleListState.mNameCount;
} else {
@@ -958,7 +958,7 @@ namespace ipl {
void SDMemory::onDialogState13() {
if (!mpSDChannelSelect->getWorker()->is_working()) {
s32 result = mpSDChannelSelect->getWorker()->get_async_result();
if (result == 0) {
if (result == NandSDWorker::RESULT_OK) {
ESTitleId titleId = mTitleIds[mCurrentTitle];
if (iplSDMemory_containsTitleId(this, titleId,
mNandTitleIds, mNandTitleCount)) {
@@ -967,7 +967,7 @@ namespace ipl {
mDialogState = 13;
}
} else {
if (result > 0) {
if (result > NandSDWorker::RESULT_OK) {
System::getDialog()->terminate();
mDialogState = 20;
mErrorCode = 2;
@@ -1028,12 +1028,12 @@ namespace ipl {
if (!mpSDChannelSelect->getWorker()->is_working()) {
s32 result = mpSDChannelSelect->getWorker()->get_async_result();
if (result == 0) {
if (result == NandSDWorker::RESULT_OK) {
mDialogState = 15;
} else {
System::getDialog()->terminate();
mDialogState = 20;
if (result == -7) {
if (result == NandSDWorker::RESULT_OUT_OF_SPACE) {
mErrorCode = 2;
mMessageId = 0xB5;
} else {
@@ -1069,7 +1069,7 @@ namespace ipl {
const ESTitleId* titleEntry = &mTitleIds[mCurrentTitle];
System::getChannelManager()->unloadBanner(*titleEntry);
if (mpSDChannelSelect->getWorker()->get_async_result() == 0) {
if (mpSDChannelSelect->getWorker()->get_async_result() == NandSDWorker::RESULT_OK) {
mCurrentTitle++;
if (mTitleCount > mCurrentTitle) {
ESTitleId nextTitleId = mTitleIds[mCurrentTitle];
@@ -1114,7 +1114,7 @@ namespace ipl {
void SDMemory::onDialogState19() {
if (!mpSDChannelSelect->getWorker()->is_working()) {
if (mpSDChannelSelect->getWorker()->get_async_result() == 0) {
if (mpSDChannelSelect->getWorker()->get_async_result() == NandSDWorker::RESULT_OK) {
mDialogState = 13;
} else {
System::getDialog()->terminate();

View File

@@ -285,10 +285,10 @@ FaderSceneCommand SDChannelTitle::calcFadein() {
}
if (!mpFade->isPlaying()) {
iplSDChannelTitle_playBannerIntro(this);
SDButton* button = static_cast<SDButton*>(System::getScene(0x24));
SDButton* button = static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON));
button->setEventHandler(mpButtonEventHandler);
button->animation(13);
button->animation(14);
button->animation(SDButton::IDANIM_ARROW_LEFT_APPEAR);
button->animation(SDButton::IDANIM_ARROW_RIGHT_APPEAR);
mState = 1;
return FADER_SCN_NEXT;
} else {
@@ -311,7 +311,7 @@ FaderSceneCommand SDChannelTitle::calcNormal() {
case 15: iplSDChannelTitle_updateCopyStart(this); break;
case 16: iplSDChannelTitle_updateAfterClearTmp(this); break;
case 17: SCSetTmpTitleID(mTitleId); SCFlushAsync(NULL); mState = 18; break;
case 18: if (SCCheckStatus() != 1) { mState = 21; } break;
case 18: if (SCCheckStatus() != SC_STATUS_BUSY) { mState = 21; } break;
case 19: iplSDChannelTitle_startCopyProgress(this); break;
case 20: iplSDChannelTitle_updateCopyPrepare(this); break;
case 23: iplSDChannelTitle_updateMemoryCalc(this); break;
@@ -339,33 +339,33 @@ FaderSceneCommand SDChannelTitle::calcNormal() {
}
void SDChannelTitle::initCalcFadeout() {
SDButton* button = static_cast<SDButton*>(System::getScene(0x24));
SDButton* button = static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON));
if (mState == 5 || mState == 7 || mState == 31) {
System::getFader()->fadeOut();
snd::getSystem()->stopAllSound(20);
OSReport("sound stopped\n");
} else if (mState == 6) {
button->animation(15);
button->animation(16);
button->animation(SDButton::IDANIM_ARROW_LEFT_DISAPPEAR);
button->animation(SDButton::IDANIM_ARROW_RIGHT_DISAPPEAR);
}
button->setEventHandler(NULL);
}
FaderSceneCommand SDChannelTitle::calcFadeout() {
if (mState == 5) {
if (!mWpadStopTick && WPADGetStatus() == 0) {
if (!mWpadStopTick && WPADGetStatus() == WPAD_LIB_STATUS_0) {
mWpadStopTick = OSGetTick();
}
if (System::getFader()->getStatus() == EGG::Fader::PREPARE_IN && System::isReceiveScheduleStopped() &&
(!System::getNwc24Manager() || System::getNwc24Manager()->isReceivingIdle())) {
OSReport("NWC24 Scheduler stopped.\n");
NandSDWorker* worker = mpChannelSelect->getWorker();
if (mNextScene == 17) {
if (mNextScene == SCENE_UNLOCKED_TITLE) {
if (!nandwall::checkNandCapacityAppBootable()) {
OSReport("Nand full! OSRebootSystem.\n");
iplSDChannelTitle_rebootSystem(this);
}
while (WPADGetStatus() != 0 || System::getBS2Manager()->getIPLState() != bs2::IPL_STATE_8 ||
while (WPADGetStatus() != WPAD_LIB_STATUS_0 || System::getBS2Manager()->getIPLState() != bs2::IPL_STATE_8 ||
!System::getSaveData()->isFinished(mpSaveFile) ||
(mScriptEnabled && mScriptState != 4) || (worker && worker->is_working())) {
snd::getSystem()->calc();
@@ -374,7 +374,7 @@ FaderSceneCommand SDChannelTitle::calcFadeout() {
if (mScriptEnabled == 1) {
iplSDChannelTitle_updateScript(this);
}
if (WPADGetStatus() != 0) {
if (WPADGetStatus() != WPAD_LIB_STATUS_0) {
OSReport("wait for WPAD\n");
}
if (System::getBS2Manager()->getIPLState() != bs2::IPL_STATE_8) {
@@ -537,7 +537,7 @@ extern "C" void iplSDChannelTitle_createBannerLayout(SDChannelTitle* scene) {
scene->mpIconLayout->destroyHeap();
scene->mpIconLayout = NULL;
}
if (scene->mpBannerFiles[scene->mLoadedIndex] && scene->mpBannerFiles[scene->mLoadedIndex]->checkData() == 1) {
if (scene->mpBannerFiles[scene->mLoadedIndex] && scene->mpBannerFiles[scene->mLoadedIndex]->checkData() == nand::RESULT_SUCCESS) {
scene->mpBannerLayout = layout::Object::create(scene->mpBannerHeap, 0x40000,
scene->mpBannerFiles[scene->mLoadedIndex], "arc", "banner.brlyt");
iplSDChannelObj_applyLanguageGroups(scene->mpBannerLayout);
@@ -574,7 +574,7 @@ extern "C" void iplSDChannelTitle_createIconLayout(SDChannelTitle* scene) {
}
extern "C" void iplSDChannelTitle_updateIdleState(SDChannelTitle* scene) {
SDButton* button = static_cast<SDButton*>(System::getScene(0x24));
SDButton* button = static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON));
if (button && button->isActive()) {
button->update();
}
@@ -586,11 +586,11 @@ extern "C" void iplSDChannelTitle_updateIdleState(SDChannelTitle* scene) {
controller::Interface* controller = System::getMasterController();
int page;
int index;
if (controller->down(0x30001000)) {
if (controller->down(controller::BTN_NEXT_LEFT)) {
scene->mpChannelSelect->findAdjacentChannel(1, &page, &index);
iplSDChannelTitle_setPageAndIndex(scene, page, index);
snd::getSystem()->startSE("WSD_SELECT");
} else if (controller->down(0x6000010)) {
} else if (controller->down(controller::BTN_NEXT_RIGHT)) {
scene->mpChannelSelect->findAdjacentChannel(0, &page, &index);
iplSDChannelTitle_setPageAndIndex(scene, page, index);
snd::getSystem()->startSE("WSD_SELECT");
@@ -648,11 +648,11 @@ extern "C" void iplSDChannelTitle_updateChangeWait(SDChannelTitle* scene) {
}
extern "C" void iplSDChannelTitle_updateParentalResult(SDChannelTitle* scene) {
ParentalDialog* parental = static_cast<ParentalDialog*>(System::getScene(0x1b));
ParentalDialog* parental = static_cast<ParentalDialog*>(System::getScene(SCENE_PARENTAL_DIALOG));
if (!parental && !System::getReservedScene()) {
if (scene->mParentalResult == 1) {
if (scene->mNextScene == 0x12) {
scene->reserveAllSceneDestruction(0x12, reinterpret_cast<void*>(1));
if (scene->mNextScene == SCENE_SETTING) {
scene->reserveAllSceneDestruction(SCENE_SETTING, reinterpret_cast<void*>(1));
scene->mState = 7;
} else if (scene->mbCopiedTitle) {
scene->mState = 25;
@@ -663,8 +663,8 @@ extern "C" void iplSDChannelTitle_updateParentalResult(SDChannelTitle* scene) {
scene->mState = 29;
} else {
scene->mpButtonAnimations[1][0]->play();
static_cast<SDButton*>(System::getScene(0x24))->animation(13);
static_cast<SDButton*>(System::getScene(0x24))->animation(14);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_APPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_APPEAR);
for (int button = 0; button < 2; ++button) {
scene->mHoverCounts[button] = 0;
scene->mpPaneManager->initPane(scene->mpLayout->FindPaneByName(sButtonNames[button]));
@@ -698,8 +698,8 @@ extern "C" void iplSDChannelTitle_updateDialogResult(SDChannelTitle* scene) {
if (scene->mbCopiedTitle) {
scene->mState = 29;
} else {
static_cast<SDButton*>(System::getScene(0x24))->animation(13);
static_cast<SDButton*>(System::getScene(0x24))->animation(14);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_APPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_APPEAR);
scene->mpButtonAnimations[1][0]->play();
for (int button = 0; button < 2; ++button) {
scene->mHoverCounts[button] = 0;
@@ -714,7 +714,7 @@ extern "C" void iplSDChannelTitle_updateDialogResult(SDChannelTitle* scene) {
if (iplSDChannelTitle_isParentalEnabled()) {
iplSDChannelTitle_openParentalDialog(scene, reinterpret_cast<void*>(1));
} else {
scene->reserveAllSceneDestruction(0x12, reinterpret_cast<void*>(1));
scene->reserveAllSceneDestruction(SCENE_SETTING, reinterpret_cast<void*>(1));
scene->mState = 7;
}
break;
@@ -755,8 +755,8 @@ extern "C" void iplSDChannelTitle_updateCopyPrepare(SDChannelTitle* scene) {
}
{
int result = scene->mpChannelSelect->getWorker()->get_async_result();
if (result == 0 || result == -6) {
if (scene->mpChannelSelect->isCurrentTitleUsageEnough(reinterpret_cast<const s32*>(&scene->mTitleRange))) {
if (result == NandSDWorker::RESULT_OK || result == NandSDWorker::RESULT_ALREADY_EXISTS) {
if (scene->mpChannelSelect->isCurrentTitleUsageEnough(&scene->mTitleRange.mByteSize)) {
scene->mState = 15;
} else {
SDMemory::TitleRange sdRange;
@@ -778,7 +778,7 @@ extern "C" void iplSDChannelTitle_updateCopyPrepare(SDChannelTitle* scene) {
} else if (static_cast<u32>(result + 15) <= 1) {
scene->mState = 26;
scene->mErrorMessage = 0xaf;
} else if (result == -16) {
} else if (result == NandSDWorker::RESULT_VERSION_ERR) {
scene->mState = 26;
scene->mErrorMessage = 199;
} else {
@@ -802,7 +802,7 @@ extern "C" void iplSDChannelTitle_updateMemoryCalc(SDChannelTitle* scene) {
}
switch (static_cast<s32>(scene->mMemory.mErrorCode)) {
case 4:
scene->reserveAllSceneDestruction(0x15, reinterpret_cast<void*>(2));
scene->reserveAllSceneDestruction(SCENE_SETTING_BG, reinterpret_cast<void*>(2));
scene->mState = 31;
return;
case 1:
@@ -878,7 +878,7 @@ extern "C" void iplSDChannelTitle_updateCopyProgress(SDChannelTitle* scene) {
scene->mpProgressLayout->getAnim(2)->initAnmFrame(NandSDWorker::getCompletionPct());
if (!scene->mpChannelSelect->getWorker()->is_working()) {
int result = scene->mpChannelSelect->getWorker()->get_async_result();
if (result == 0 || result == -6) {
if (result == NandSDWorker::RESULT_OK || result == NandSDWorker::RESULT_ALREADY_EXISTS) {
System::getChannelManager()->loadTmpMetaHeader(scene->mTitleId);
scene->mpProgressLayout->getAnim(3)->stop();
snd::getSystem()->stopSE(scene->mpCopySound, 0);
@@ -890,9 +890,9 @@ extern "C" void iplSDChannelTitle_updateCopyProgress(SDChannelTitle* scene) {
SCSetTmpTitleID(0);
SCFlushAsync(NULL);
scene->mState = 26;
if (result == -15) {
if (result == NandSDWorker::RESULT_NOT_TRANSFERRABLE) {
scene->mErrorMessage = 0xaf;
} else if (result == -16) {
} else if (result == NandSDWorker::RESULT_VERSION_ERR) {
scene->mErrorMessage = 199;
} else {
scene->mErrorMessage = 0xae;
@@ -910,7 +910,7 @@ extern "C" void iplSDChannelTitle_showCopyError(SDChannelTitle* scene) {
}
extern "C" void iplSDChannelTitle_updateCopyErrorDialog(SDChannelTitle* scene) {
if (SCCheckStatus() != 1 && System::getDialog()->getLastResult() != -1) {
if (SCCheckStatus() != SC_STATUS_BUSY && System::getDialog()->getLastResult() != -1) {
scene->mState = 29;
}
}
@@ -928,8 +928,8 @@ extern "C" void iplSDChannelTitle_finishProgressHide(SDChannelTitle* scene) {
scene->mpButtonAnimations[6][5]->play();
scene->mpButtonAnimations[1][0]->initAnmFrame();
scene->mpButtonAnimations[1][0]->play();
static_cast<SDButton*>(System::getScene(0x24))->animation(13);
static_cast<SDButton*>(System::getScene(0x24))->animation(14);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_APPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_APPEAR);
System::startReceiveSchedule();
scene->mState = 30;
}
@@ -987,7 +987,7 @@ extern "C" void iplSDChannelTitle_updateTmdReady(SDChannelTitle* scene) {
scene->mMakerCode = scene->mpTmd->head.groupId;
if (!iplSDChannelTitle_isNetworkAllowed(scene, scene->mpTmd, scene->mTitleId)) {
iplSDChannelTitle_confirmLeaveToSettings(scene, false);
scene->mNextScene = 18;
scene->mNextScene = SCENE_SETTING;
} else if (iplSDChannelTitle_passesParentalCheck(scene, scene->mpTmd)) {
iplSDChannelTitle_prepareSceneExit(scene, scene->mNextScene);
if (scene->mbCopiedTitle) {
@@ -1105,7 +1105,7 @@ extern "C" void iplSDChannelTitle_updateScriptLoad(SDChannelTitle* scene) {
if (!scene->mpScriptFile->isFinished()) {
return;
}
if (scene->mpScriptFile->checkData() != 1 && scene->mpScriptFile->checkData() != 0) {
if (scene->mpScriptFile->checkData() != nand::RESULT_SUCCESS && scene->mpScriptFile->checkData() != nand::RESULT_NONE) {
scene->mScriptFrame = 0;
scene->mbScriptFailed = true;
scene->mScriptState = 0;
@@ -1164,7 +1164,7 @@ extern "C" void iplSDChannelTitle_playBannerIntro(SDChannelTitle* scene) {
}
extern "C" void iplSDChannelTitle_startBannerSound(SDChannelTitle* scene) {
if (scene->mpSoundFiles[scene->mLoadedIndex] && scene->mpSoundFiles[scene->mLoadedIndex]->checkData() == 1) {
if (scene->mpSoundFiles[scene->mLoadedIndex] && scene->mpSoundFiles[scene->mLoadedIndex]->checkData() == nand::RESULT_SUCCESS) {
void* sound = scene->mpSoundFiles[scene->mLoadedIndex]->getBuffer();
u32 size = System::getChannelManager()->getSoundSize(scene->mTitleId);
snd::getSystem()->startBannerSound(sound, size, false);
@@ -1244,11 +1244,11 @@ extern "C" BOOL iplSDChannelTitle_isParentalEnabled() {
extern "C" void iplSDChannelTitle_openParentalDialog(SDChannelTitle* scene, void* arguments) {
System::getHomeButtonMenu()->enable();
scene->mbResetAcceptable = true;
if (static_cast<SDButton*>(System::getScene(0x24))->isLeftArrowVisible()) {
static_cast<SDButton*>(System::getScene(0x24))->animation(15);
static_cast<SDButton*>(System::getScene(0x24))->animation(16);
if (static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->isLeftArrowVisible()) {
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_DISAPPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_DISAPPEAR);
}
scene->createChildScene(0x1b, scene, NULL, arguments);
scene->createChildScene(SCENE_PARENTAL_DIALOG, scene, NULL, arguments);
scene->mParentalResult = 0;
scene->mState = 11;
}
@@ -1283,8 +1283,8 @@ extern "C" void iplSDChannelTitle_beginLaunch(SDChannelTitle* scene, SDChannelOb
extern "C" void iplSDChannelTitle_cleanupAndLeave(SDChannelTitle* scene) {
scene->mParentalResult = 0;
scene->mbStartAnimation = false;
static_cast<SDButton*>(System::getScene(0x24))->animation(15);
static_cast<SDButton*>(System::getScene(0x24))->animation(16);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_DISAPPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_DISAPPEAR);
if (scene->mpBannerFiles[scene->mLoadedIndex]) {
delete scene->mpBannerFiles[scene->mLoadedIndex];
}
@@ -1299,12 +1299,12 @@ extern "C" void iplSDChannelTitle_cleanupAndLeave(SDChannelTitle* scene) {
scene->mpSoundFiles[scene->mLoadedIndex] = NULL;
int page;
int index;
bool hasTitle = System::getChannelManager()->hasChannel(scene->mTitleId, &page, &index) != 0;
bool hasTitle = System::getChannelManager()->hasChannel(scene->mTitleId, &page, &index);
bool hasTemporaryTitle = false;
if (scene->mTitleId == SCGetTmpTitleID() && System::getChannelManager()->isLoadedTmp()) {
hasTemporaryTitle = true;
}
scene->mNextScene = 17;
scene->mNextScene = SCENE_UNLOCKED_TITLE;
scene->mbTmdReady = false;
scene->mMakerCode = 0;
scene->mbResetAcceptable = false;
@@ -1324,12 +1324,12 @@ extern "C" void iplSDChannelTitle_cleanupAndLeave(SDChannelTitle* scene) {
extern "C" void iplSDChannelTitle_confirmLeaveToSettings(SDChannelTitle* scene, bool settings) {
if (settings) {
scene->reserveAllSceneDestruction(0x12, reinterpret_cast<void*>(1));
scene->reserveAllSceneDestruction(SCENE_SETTING, reinterpret_cast<void*>(1));
scene->mState = 7;
} else {
if (static_cast<SDButton*>(System::getScene(0x24))->isLeftArrowVisible()) {
static_cast<SDButton*>(System::getScene(0x24))->animation(15);
static_cast<SDButton*>(System::getScene(0x24))->animation(16);
if (static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->isLeftArrowVisible()) {
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_LEFT_DISAPPEAR);
static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON))->animation(SDButton::IDANIM_ARROW_RIGHT_DISAPPEAR);
}
System::getDialog()->callBtn2(0x143, 0x146, 0x25, false);
scene->mState = 12;
@@ -1345,7 +1345,7 @@ extern "C" void iplSDChannelTitle_prepareSceneExit(SDChannelTitle* scene, int ne
controller->cancelRumbling();
}
}
if (nextScene == 17) {
if (nextScene == SCENE_UNLOCKED_TITLE) {
System::getHomeButtonMenu()->disable();
scene->mbResetAcceptable = false;
}
@@ -1469,11 +1469,11 @@ extern "C" BOOL iplSDChannelTitle_passesParentalCheck(SDChannelTitle* scene, EST
void SDTitlePaneEventHandler::onEvent(u32 component, u32 event, void* data) {
SDTitlePaneEventHandler* handler = this;
const controller::Interface* controller = static_cast<const controller::Interface*>(data);
controller::Interface* controller = static_cast<controller::Interface*>(data);
const char* paneName = handler->getPane(component)->GetName();
switch (event) {
case ::gui::EventHandler::ON_TRIG: {
if (handler->mpScene->mState == 1 && controller->downTrg(0x100800)) {
if (handler->mpScene->mState == 1 && controller->downTrg(controller::BTN_INTERACT)) {
if (strcmp(paneName, sButtonNames[0]) == 0) {
handler->mpScene->mpButtonAnimations[2][2]->play();
snd::getSystem()->startSE("WIPL_SE_BT_PUSH");
@@ -1500,7 +1500,7 @@ void SDTitlePaneEventHandler::onEvent(u32 component, u32 event, void* data) {
if (handler->mpScene->mHoverCounts[button] <= 1) {
handler->mpScene->mpButtonAnimations[button][1]->play();
snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING");
const_cast<controller::Interface*>(controller)->rumble(0);
controller->rumble(0);
break;
}
}
@@ -1531,21 +1531,21 @@ void SDTitleButtonEventHandler::onEventDerived(u32 component, u32 event, const c
SDTitleButtonEventHandler* handler = this;
const char* name = handler->getPane(component)->GetName();
switch (event) {
case 0:
if (handler->mpScene->mState == 1 && controller->downTrg(0x100800)) {
SDButton* button = static_cast<SDButton*>(System::getScene(0x24));
case ::gui::EventHandler::ON_TRIG:
if (handler->mpScene->mState == 1 && controller->downTrg(controller::BTN_INTERACT)) {
SDButton* button = static_cast<SDButton*>(System::getScene(SCENE_SD_BUTTON));
if (strcmp(name, SDButton::getButtonName(SDButton::BTN_ARROW_LEFT)) == 0) {
int page;
int index;
handler->mpScene->mpChannelSelect->findAdjacentChannel(1, &page, &index);
button->animation(7);
button->animation(SDButton::IDANIM_ARROW_LEFT_CLICK);
iplSDChannelTitle_setPageAndIndex(handler->mpScene, page, index);
snd::getSystem()->startSE("WSD_SELECT");
} else if (strcmp(name, SDButton::getButtonName(SDButton::BTN_ARROW_RIGHT)) == 0) {
int page;
int index;
handler->mpScene->mpChannelSelect->findAdjacentChannel(0, &page, &index);
button->animation(8);
button->animation(SDButton::IDANIM_ARROW_RIGHT_CLICK);
iplSDChannelTitle_setPageAndIndex(handler->mpScene, page, index);
snd::getSystem()->startSE("WSD_SELECT");
}

View File

@@ -109,7 +109,7 @@ namespace ipl {
System::getProjectionRect(&proj16x9);
System::getProjectionRect4x3(&proj4x3);
if (mbUse16x9X == 0) {
if (!mbUse16x9X) {
mBalloonPos.x *= proj4x3.GetWidth() / proj16x9.GetWidth();
}
}
@@ -122,7 +122,7 @@ namespace ipl {
System::getProjectionRect(&proj16x9);
System::getProjectionRect4x3(&proj4x3);
if (mbUse16x9X == 0) {
if (!mbUse16x9X) {
mBalloonPos.x *= proj4x3.GetWidth() / proj16x9.GetWidth();
}
@@ -192,7 +192,7 @@ namespace ipl {
}
}
if (mbUse16x9X == 0) {
if (!mbUse16x9X) {
alignmentOffset *= proj4x3.GetWidth() / proj16x9.GetWidth();
}

View File

@@ -130,7 +130,7 @@ BOOL TVRCInit(void* pRsrc) {
return FALSE;
}
if (ARCInitHandle(pRsrc, &_database) == FALSE) {
if (!ARCInitHandle(pRsrc, &_database)) {
_lastError = 4;
return FALSE;
}
@@ -154,10 +154,10 @@ BOOL TVRCSetModelType(int makerID, int typeNo, void* pFileData, int length) {
ARCFileInfo file;
if (_isInitialized == FALSE || _database.archiveStartAddr == NULL) {
if (!_isInitialized || _database.archiveStartAddr == NULL) {
return FALSE;
}
if (((ARCHeader*)_database.archiveStartAddr)->magic != ARC_MAGIC) {
if (static_cast<ARCHeader*>(_database.archiveStartAddr)->magic != ARC_MAGIC) {
return FALSE;
}
if (makerID == _makerID && typeNo == _typeNo) {
@@ -177,7 +177,7 @@ BOOL TVRCSetModelType(int makerID, int typeNo, void* pFileData, int length) {
}
ARCCloseDir(&dir);
if (ARCFastOpen(&_database, dirEntry.entryNum, &file) == FALSE) {
if (!ARCFastOpen(&_database, dirEntry.entryNum, &file)) {
_lastError = 6;
return FALSE;
}
@@ -188,7 +188,7 @@ BOOL TVRCSetModelType(int makerID, int typeNo, void* pFileData, int length) {
}
memcpy(pFileData, ARCGetStartAddrInMem(&file), fileLen);
_tvrcFile = (_FileData*)pFileData;
_tvrcFile = static_cast<_FileData*>(pFileData);
_makerID = makerID;
_typeNo = typeNo;
_database.archiveStartAddr = NULL;
@@ -478,13 +478,13 @@ void LibTVRC::__FTVRCLoop0Handler(OSAlarm* alarm, OSContext* ctx) {
namespace LibTVRC {
void __FTVRCLoop1Handler(OSAlarm *alarm, OSContext *ctx) {
if (_ctCombo != 0 && _isActive != 0) {
if (_ctCombo != 0 && _isActive) {
if (_func1state == -1) {
_unitStartTime = OSGetTime();
_func1state = 0;
}
if (_isLastOnOff != 0) {
if (_isLastOnOff) {
_unitLastTime = OSGetTime();
if (_func1state == 0) {
@@ -494,7 +494,7 @@ namespace LibTVRC {
return;
}
BOOL active = (int)(_unitLastTime - _unitStartTime) < (int)(*(u32*)&_tickT * _ctCombo);
BOOL active = (int)(_unitLastTime - _unitStartTime) < (int)(_tickT * _ctCombo);
WPADSetSensorBarPower(FALSE);
_func1state = 0;
if (active) {
@@ -504,7 +504,7 @@ namespace LibTVRC {
}
} else {
WPADSetSensorBarPower(FALSE);
OSSetAlarm(&_alarm, *(u32*)&_tickT * _ctCombo, __FTVRCLoop0Handler);
OSSetAlarm(&_alarm, _tickT * _ctCombo, __FTVRCLoop0Handler);
}
}
}

View File

@@ -232,14 +232,14 @@ namespace ipl {
int Manager::getNumValidChannel() const {
const ChannelSlot* q;
int dens = 12;
int dens = MAX_CHANNEL_INDEX;
const ChannelPage* p;
int slot;
int count = 0;
int page;
u8 flag;
s32 val;
for (page = 0; page < 4; page++) {
for (page = 0; page < MAX_CHANNEL_PAGE; page++) {
p = (const ChannelPage*)((const u8*)this + page * 0xc0);
for (slot = 0; slot < dens; slot++) {
q = &p->slots[slot];
@@ -471,14 +471,14 @@ namespace ipl {
checkSpecialTitles(titleIds, titleCount);
checkTmpTitle(titleIds, titleCount);
ESTitleId unk[MAX_CHANNEL_TOTAL] = {0};
ESTitleId prioritizedTitleIds[MAX_CHANNEL_TOTAL] = {0};
makePriorTitleIDList(unk, titleIds, titleCount);
integrateTitleIDList(unk, titleIds, titleCount);
makePriorTitleIDList(prioritizedTitleIds, titleIds, titleCount);
integrateTitleIDList(prioritizedTitleIds, titleIds, titleCount);
delete[] titleIds;
return doUpdateChanInfos(unk);
return doUpdateChanInfos(prioritizedTitleIds);
}
void Manager::deleteInvalidTitle(ESTitleId* titleIds, u32 titleCount) {
@@ -925,7 +925,7 @@ namespace ipl {
}
int Manager::getAvailableInList(const ESTitleId* titleIds, u32 titleCount) {
int dens = 12;
int dens = MAX_CHANNEL_INDEX;
u32 i;
for (i = 0; i < titleCount; i++) {
if (titleIds[i] == 0) {

View File

@@ -12,11 +12,11 @@ enum {
enum {
ODH_ERROR_SUCCESS = 0,
ODH_ERROR_80000001 = 0x80000001,
ODH_ERROR_80000002 = 0x80000002,
ODH_ERROR_80000003 = 0x80000003,
ODH_ERROR_80000004 = 0x80000004,
ODH_ERROR_80000005 = 0x80000005,
ODH_ERROR_INVALID_DIMENSIONS = 0x80000001,
ODH_ERROR_INVALID_QUALITY = 0x80000002,
ODH_ERROR_INVALID_BITSTREAM = 0x80000003,
ODH_ERROR_OUTPUT_FULL = 0x80000004,
ODH_ERROR_INVALID_HEADER = 0x80000005,
};
struct SArDeconvTbl {
@@ -41,7 +41,7 @@ struct SArCDJ_OdhMaster {
u16 width;
u16 height;
u8 quality;
u8 field5;
u8 reservedAlignment;
u16 blocksWide;
u16 blocksHigh;
u16 blockX;
@@ -52,9 +52,9 @@ struct SArCDJ_OdhMaster {
u32 bitCount;
u32 outputPos;
u32 remaining;
u32 field20;
u32 field24;
u32 field28;
u32 lumaDCPredictor;
u32 cbDCPredictor;
u32 crDCPredictor;
u8* workBuffer;
u32 dcCoefficients[64];
u32 coefficients[64];
@@ -591,19 +591,19 @@ s32 CArGBAOdh::decompressGbaOdh(u8* src, int srcSize, u8* dest, int destSize, u8
}
s32 result = cdj_d_initializeDecompressOdh(&master, work, src);
if (result != 0) {
if (result != ODH_ERROR_SUCCESS) {
OSReport("decompressGbaOdh : INITIALIZE ERROR %08x\n", result);
return 0;
}
result = cdj_d_decompressLoop(&master, srcSize, workSize);
if (result != 0) {
if (result != ODH_ERROR_SUCCESS) {
OSReport("decompressGbaOdh : DECOMPRESSING ERROR %08x\n", result);
return 0;
}
result = cdj_d_colorDeconv(&master, dest, format);
if (result != 0) {
if (result != ODH_ERROR_SUCCESS) {
OSReport("decompressGbaOdh : COLOR DECONVERSION ERROR %08x\n", result);
return 0;
}
@@ -631,7 +631,7 @@ s32 CArGBAOdh::compressGbaOdh(u8* src, u8* dest, int width, int height, int qual
}
result = cdj_c_compressLoop(&master);
int retry = 1;
while (result == ODH_ERROR_80000004) {
while (result == ODH_ERROR_OUTPUT_FULL) {
OSReport("compressGbaOdh : COMPRESS OVER AND RETRY %d q=%d, %08x\n", retry++, master.quality, result);
quality -= 5;
if (quality > 0) {
@@ -654,10 +654,10 @@ s32 CArGBAOdh::cdj_c_initializeCompressOdh(SArCDJ_OdhMaster* master, u16* dimens
u32 quantizationScale;
s32 result;
if ((((*dimensions == 0) || (0x7FF < *dimensions)) || (dimensions[1] == 0)) || (0x7FF < dimensions[1])) {
result = ODH_ERROR_80000001;
if (*dimensions == 0 || 0x7FF < *dimensions || dimensions[1] == 0 || 0x7FF < dimensions[1]) {
result = ODH_ERROR_INVALID_DIMENSIONS;
} else if (requestedQuality > 0x64) {
result = ODH_ERROR_80000002;
result = ODH_ERROR_INVALID_QUALITY;
} else {
master->workBuffer = workBuffer;
master->data = outputBuffer;
@@ -668,8 +668,8 @@ s32 CArGBAOdh::cdj_c_initializeCompressOdh(SArCDJ_OdhMaster* master, u16* dimens
master->blocksWide = (s32)dimensionMinusOne / 8 + 1;
dimensionMinusOne = dimensions[1] - 1;
master->blocksHigh = (s32)dimensionMinusOne / 8 + 1;
master->luminanceRequest.predictors[0] = &master->field20;
master->luminanceRequest.predictors[1] = &master->field20;
master->luminanceRequest.predictors[0] = &master->lumaDCPredictor;
master->luminanceRequest.predictors[1] = &master->lumaDCPredictor;
master->luminanceRequest.dcTable = (u32*)gArDC_L_Table;
master->luminanceRequest.acTable = (u32*)gArDC_L_Table;
master->luminanceRequest.bitstream = outputBuffer;
@@ -677,8 +677,8 @@ s32 CArGBAOdh::cdj_c_initializeCompressOdh(SArCDJ_OdhMaster* master, u16* dimens
master->luminanceRequest.bitBuffer = &master->bitBuffer;
master->luminanceRequest.bitCount = &master->bitCount;
master->luminanceRequest.bytesConsumed = outputCapacity;
master->chrominanceRequest.predictors[0] = &master->field24;
master->chrominanceRequest.predictors[1] = &master->field28;
master->chrominanceRequest.predictors[0] = &master->cbDCPredictor;
master->chrominanceRequest.predictors[1] = &master->crDCPredictor;
master->chrominanceRequest.dcTable = (u32*)gArDC_C_Table;
master->chrominanceRequest.acTable = (u32*)gArDC_L_Table;
master->chrominanceRequest.bitstream = outputBuffer;
@@ -691,7 +691,7 @@ s32 CArGBAOdh::cdj_c_initializeCompressOdh(SArCDJ_OdhMaster* master, u16* dimens
quality = 1;
}
if (quality < 0x32) {
quantizationScale = 5000U / (u32)quality;
quantizationScale = 5000U / quality;
} else {
quantizationScale = 200 - (quality << 1);
}
@@ -702,9 +702,9 @@ s32 CArGBAOdh::cdj_c_initializeCompressOdh(SArCDJ_OdhMaster* master, u16* dimens
master->bitCount = 0x20;
master->outputPos = outputCapacity;
master->remaining = outputCapacity - 0x10;
master->field20 = 0;
master->field24 = 0;
master->field28 = 0;
master->lumaDCPredictor = 0;
master->cbDCPredictor = 0;
master->crDCPredictor = 0;
result = 0;
}
@@ -720,7 +720,7 @@ s32 CArGBAOdh::cdj_c_compressLoop(SArCDJ_OdhMaster* master) {
int columnOffset = (u32)master->blockX << 3;
workOffset = blocksWide * rowOffset + columnOffset;
u32 stride = (u32)master->blocksWide << 3;
fdct_fast(master->coefficients, (u8*)((u32)master->workBuffer + workOffset), stride,
fdct_fast(master->coefficients, master->workBuffer + workOffset, stride,
master->quantizationTables);
for (int i = 0; i < 0x40; i++) {
u8 index = odh_zigzag_order[i];
@@ -728,8 +728,8 @@ s32 CArGBAOdh::cdj_c_compressLoop(SArCDJ_OdhMaster* master) {
}
master->coefficients[0] = 0x40004000;
statusOrOffset = huffmanCoder((u16*)master->dcCoefficients - 1, &master->luminanceRequest);
if (statusOrOffset == ODH_ERROR_80000004) {
statusOrOffset = ODH_ERROR_80000004;
if (statusOrOffset == ODH_ERROR_OUTPUT_FULL) {
statusOrOffset = ODH_ERROR_OUTPUT_FULL;
goto done;
}
int nextBlocksWide = master->blocksWide;
@@ -738,14 +738,14 @@ s32 CArGBAOdh::cdj_c_compressLoop(SArCDJ_OdhMaster* master) {
statusOrOffset = blocksHigh * rowStride;
workOffset = workOffset + statusOrOffset;
u32 nextStride = (u32)nextBlocksWide << 3;
fdct_fast(master->coefficients, (u8*)((u32)master->workBuffer + workOffset), nextStride,
fdct_fast(master->coefficients, master->workBuffer + workOffset, nextStride,
master->quantizationTables + 64);
for (int i = 0; i < 0x40; i++) {
u8 index = odh_zigzag_order[i];
master->dcCoefficients[index] = master->coefficients[i] & 0xFFFF;
}
workOffset += (u32)master->blocksHigh * ((u32)master->blocksWide << 6);
fdct_fast(master->coefficients, (u8*)((u32)master->workBuffer + workOffset),
fdct_fast(master->coefficients, master->workBuffer + workOffset,
(u32)master->blocksWide << 3, master->quantizationTables + 64);
for (int i = 0; i < 0x40; i++) {
u8 index = odh_zigzag_order[i];
@@ -754,8 +754,8 @@ s32 CArGBAOdh::cdj_c_compressLoop(SArCDJ_OdhMaster* master) {
}
master->coefficients[0] = 0x40004000;
statusOrOffset = huffmanCoder((u16*)master->dcCoefficients, &master->chrominanceRequest);
if (statusOrOffset == ODH_ERROR_80000004) {
statusOrOffset = ODH_ERROR_80000004;
if (statusOrOffset == ODH_ERROR_OUTPUT_FULL) {
statusOrOffset = ODH_ERROR_OUTPUT_FULL;
goto done;
}
int nextBlockX = master->blockX + 1;
@@ -766,8 +766,8 @@ s32 CArGBAOdh::cdj_c_compressLoop(SArCDJ_OdhMaster* master) {
}
} while (master->blockY < master->blocksHigh);
statusOrOffset = cdj_c_flashBuffer(master);
if (statusOrOffset == ODH_ERROR_80000004) {
statusOrOffset = ODH_ERROR_80000004;
if (statusOrOffset == ODH_ERROR_OUTPUT_FULL) {
statusOrOffset = ODH_ERROR_OUTPUT_FULL;
} else {
cdj_c_makeHeader(master, master->outputPos - master->remaining);
statusOrOffset = master->outputPos - master->remaining;
@@ -782,7 +782,7 @@ s32 CArGBAOdh::cdj_c_flashBuffer(SArCDJ_OdhMaster* master) {
while (master->bitCount <= 0x18) {
if (master->remaining == 0) {
return ODH_ERROR_80000004;
return ODH_ERROR_OUTPUT_FULL;
}
master->data[master->outputPos - master->remaining] = master->bitBuffer >> 24;
@@ -869,11 +869,11 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
workPlane = master->workBuffer;
cbPlane = workPlane + (u32)paddedDimensions[0] * (u32)paddedDimensions[1];
crPlane = cbPlane + (u32)paddedDimensions[0] * (u32)paddedDimensions[1];
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
sourceStride = (width & 0xFFFC) << 3;
} else {
sourceStride = (width & 0xFFF8) << 2;
if (format == 1) {
if (format == ODH_FORMAT_RGBA8) {
sourceStride = (width & 0xFFFC) << 4;
}
}
@@ -892,7 +892,7 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
void CArGBAOdh::LineConv11(u8* source, u8* lumaOutput, u8* cbOutput, u8* crOutput, u16 width, u16 height,
const long* conversionTable, int format) {
u32 planeSize = (u32)width * (u32)height;
const s32* table = (const s32*)conversionTable;
const s32* table = conversionTable;
u32 pixelIndex = 0;
for (int i = 0; i < width; i++) {
@@ -900,14 +900,14 @@ void CArGBAOdh::LineConv11(u8* source, u8* lumaOutput, u8* cbOutput, u8* crOutpu
s32 green;
s32 blue;
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
u8* pixelSource = source + (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
u16 pixel = pixelSource[1];
pixel |= (u16)pixelSource[0] << 8;
red = (pixel >> 11) & 0x1F;
green = (pixel >> 6) & 0x1F;
blue = pixel & 0x1F;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
int blueOrPixelOffset = (pixelIndex & 0xFFFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
u8* pixel = source + blueOrPixelOffset;
red = pixel[1] >> 3;
@@ -1101,8 +1101,8 @@ s32 CArGBAOdh::huffmanCoder(u16* coefficientInput, SArCDJ_HuffmanRequest* reques
code = request->dcTable[bitCount];
magnitude = (difference & ((1 << bitCount) - 1)) | ((code & 0xFFFFFF) << bitCount);
code = (s32)code >> 24;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_80000004) {
return ODH_ERROR_80000004;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_OUTPUT_FULL) {
return ODH_ERROR_OUTPUT_FULL;
}
while (true) {
@@ -1132,8 +1132,8 @@ s32 CArGBAOdh::huffmanCoder(u16* coefficientInput, SArCDJ_HuffmanRequest* reques
code = request->acTable[bitCount];
magnitude = (runLength & ((1 << bitCount) - 1)) | ((code & 0xFFFFFF) << bitCount);
code = (s32)code >> 24;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_80000004) {
return ODH_ERROR_80000004;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_OUTPUT_FULL) {
return ODH_ERROR_OUTPUT_FULL;
}
if (value < 0) {
@@ -1153,15 +1153,15 @@ s32 CArGBAOdh::huffmanCoder(u16* coefficientInput, SArCDJ_HuffmanRequest* reques
code = request->dcTable[bitCount];
magnitude = (value & ((1 << bitCount) - 1)) | ((code & 0xFFFFFF) << bitCount);
code = (s32)code >> 24;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_80000004) {
return ODH_ERROR_80000004;
if (EmitBit(magnitude, code + bitCount, request) == ODH_ERROR_OUTPUT_FULL) {
return ODH_ERROR_OUTPUT_FULL;
}
}
if (runLength != 0) {
code = request->acTable[7];
if (EmitBit(code & 0xFFFFFF, (s32)code >> 24, request) == ODH_ERROR_80000004) {
return ODH_ERROR_80000004;
if (EmitBit(code & 0xFFFFFF, (s32)code >> 24, request) == ODH_ERROR_OUTPUT_FULL) {
return ODH_ERROR_OUTPUT_FULL;
}
}
@@ -1181,7 +1181,7 @@ s32 CArGBAOdh::EmitBit(long bits, long bitCount, SArCDJ_HuffmanRequest* request)
while (*request->bitCount <= 0x18) {
if (*request->remaining == 0) {
return ODH_ERROR_80000004;
return ODH_ERROR_OUTPUT_FULL;
}
*this->outputCursor = (u8)(*request->bitBuffer >> 0x18);
@@ -1204,9 +1204,9 @@ s32 CArGBAOdh::cdj_d_initializeDecompressOdh(SArCDJ_OdhMaster* master, u8* workB
s32 result;
u32 width;
if (!(((sourceData[0] == 'A') && (sourceData[1] == 'J')) &&
((sourceData[2] == 'P') && (sourceData[3] == 'G')))) {
return ODH_ERROR_80000005;
if (sourceData[0] != 'A' || sourceData[1] != 'J' ||
sourceData[2] != 'P' || sourceData[3] != 'G') {
return ODH_ERROR_INVALID_HEADER;
}
const u32* headerWords = (const u32*)sourceData;
@@ -1222,11 +1222,11 @@ s32 CArGBAOdh::cdj_d_initializeDecompressOdh(SArCDJ_OdhMaster* master, u8* workB
headerQuality = headerWords[1];
master->quality = (u8)(headerQuality >> 0x18);
if (((width == 0) || (0x7FF < width)) ||
((height == 0) || (0x7FF < height))) {
result = ODH_ERROR_80000001;
if (width == 0 || 0x7FF < width ||
height == 0 || 0x7FF < height) {
result = ODH_ERROR_INVALID_DIMENSIONS;
} else if ((headerQuality >> 0x18) > 0x64) {
result = ODH_ERROR_80000002;
result = ODH_ERROR_INVALID_QUALITY;
} else {
master->workBuffer = workBuffer;
sourceData += 0x10;
@@ -1237,16 +1237,16 @@ s32 CArGBAOdh::cdj_d_initializeDecompressOdh(SArCDJ_OdhMaster* master, u8* workB
master->blockX = 0;
master->blockY = 0;
master->bitCount = 0;
master->field20 = 0;
master->field24 = 0;
master->field28 = 0;
master->luminanceRequest.predictors[0] = &master->field20;
master->luminanceRequest.predictors[1] = &master->field20;
master->lumaDCPredictor = 0;
master->cbDCPredictor = 0;
master->crDCPredictor = 0;
master->luminanceRequest.predictors[0] = &master->lumaDCPredictor;
master->luminanceRequest.predictors[1] = &master->lumaDCPredictor;
master->luminanceRequest.bitstream = sourceData;
master->luminanceRequest.bitCount = &master->bitCount;
master->luminanceRequest.bytesConsumed = 0x10;
master->chrominanceRequest.predictors[0] = &master->field24;
master->chrominanceRequest.predictors[1] = &master->field28;
master->chrominanceRequest.predictors[0] = &master->cbDCPredictor;
master->chrominanceRequest.predictors[1] = &master->crDCPredictor;
master->chrominanceRequest.bitstream = sourceData;
master->chrominanceRequest.bitCount = &master->bitCount;
master->chrominanceRequest.bytesConsumed = 0x10;
@@ -1290,7 +1290,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
master->chrominanceRequest.bitstream = master->luminanceRequest.bitstream;
master->chrominanceRequest.bytesConsumed = master->luminanceRequest.bytesConsumed;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1307,7 +1307,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
rowStride);
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 1, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1327,7 +1327,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 2, sourceLimit);
master->luminanceRequest.bitstream = master->chrominanceRequest.bitstream;
master->luminanceRequest.bytesConsumed = master->chrominanceRequest.bytesConsumed;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1347,7 +1347,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
else if ((xSampling == 2U) && (master->ySampling == 1U)) {
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1366,7 +1366,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
master->chrominanceRequest.bitstream = master->luminanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1381,7 +1381,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
(u8*)((u32)planeOffset + (u32)master->workBuffer) + 8, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 1, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1400,7 +1400,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 2, sourceLimit);
master->luminanceRequest.bitstream = master->chrominanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1420,7 +1420,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
else if ((xSampling == 1U) && (master->ySampling == 2U)) {
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1438,7 +1438,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
master->chrominanceRequest.bitstream = master->luminanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1454,7 +1454,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
,rowStride);
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 1, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1473,7 +1473,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 2, sourceLimit);
master->luminanceRequest.bitstream = master->chrominanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1493,7 +1493,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
else if ((xSampling == 2U) && (master->ySampling == 2U)) {
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1511,7 +1511,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1528,7 +1528,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1547,7 +1547,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->luminanceRequest, (u16**)hufftreePtr.tables, 0, sourceLimit);
master->chrominanceRequest.bitstream = master->luminanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1562,7 +1562,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
(u8*)((u32)requiredBlockEnd + (u32)master->workBuffer) + 8, ((u32)blockWidth << 4));
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 1, sourceLimit);
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1581,7 +1581,7 @@ s32 CArGBAOdh::cdj_d_decompressLoop(SArCDJ_OdhMaster* master, int srcSize, int w
statusOrOffset = huffmanDecoder
(master->dcCoefficients, &master->chrominanceRequest, (u16**)(hufftreePtr.tables + 2), 2, sourceLimit);
master->luminanceRequest.bitstream = master->chrominanceRequest.bitstream;
if (statusOrOffset != 0) return statusOrOffset;
if (statusOrOffset != ODH_ERROR_SUCCESS) return statusOrOffset;
statusOrOffset = 0;
for (naturalIndex = 0; naturalIndex < 0x40; naturalIndex++) {
coefficientIndex = odh_natural_order[naturalIndex];
@@ -1646,11 +1646,11 @@ s32 CArGBAOdh::cdj_d_colorDeconv(SArCDJ_OdhMaster* master, u8* destination, int
s32 lineStride;
s32 format = outputFormat;
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
lineStride = (width & 0xFFFC) << 3;
} else {
lineStride = (width & 0xFFF8) << 2;
if (format == 1) {
if (format == ODH_FORMAT_RGBA8) {
lineStride = (width & 0xFFFC) << 4;
}
}
@@ -1730,12 +1730,12 @@ void CArGBAOdh::LineDeconv11(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
pixelOutput = dest + (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
*pixelOutput = (u8)(redValue >> 8);
pixelOutput[1] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
pixelOutput = dest + (pixelIndex & 0x0FFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
*pixelOutput = 0xFF;
pixelOutput[1] = (u8)redValue;
@@ -1786,13 +1786,13 @@ void CArGBAOdh::LineDeconv21(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
offset = (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset] = (u8)(redValue >> 8);
pixelOutput = dest + offset;
pixelOutput[1] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
offset = (pixelIndex & 0x0FFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
dest[offset] = 0xFF;
pixelOutput = dest + offset;
@@ -1812,11 +1812,11 @@ void CArGBAOdh::LineDeconv21(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
pixelOutput[2] = (u8)(redValue >> 8);
pixelOutput[3] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
pixelOutput[2] = 0xFF;
pixelOutput[3] = (u8)redValue;
pixelOutput[0x22] = (u8)greenValue;
@@ -1852,12 +1852,12 @@ void CArGBAOdh::LineDeconv12(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
offset = (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset] = (u8)(redValue >> 8);
dest[offset + 1] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
offset = (pixelIndex & 0x0FFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
dest[offset] = 0xFF;
dest[offset + 1] = (u8)redValue;
@@ -1875,11 +1875,11 @@ void CArGBAOdh::LineDeconv12(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset + 8] = (u8)(redValue >> 8);
dest[offset + 9] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
dest[offset + 8] = 0xFF;
dest[offset + 9] = (u8)redValue;
dest[offset + 0x28] = (u8)greenValue;
@@ -1918,12 +1918,12 @@ void CArGBAOdh::LineDeconv22(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
offset = (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset] = (u8)(redValue >> 8);
dest[offset + 1] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
offset = (pixelIndex & 0x0FFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
dest[offset] = 0xFF;
dest[offset + 1] = (u8)redValue;
@@ -1941,11 +1941,11 @@ void CArGBAOdh::LineDeconv22(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset + 2] = (u8)(redValue >> 8);
dest[offset + 3] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
dest[offset + 2] = 0xFF;
dest[offset + 3] = (u8)redValue;
dest[offset + 0x22] = (u8)greenValue;
@@ -1964,11 +1964,11 @@ void CArGBAOdh::LineDeconv22(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset + 8] = (u8)(redValue >> 8);
dest[offset + 9] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
dest[offset + 8] = 0xFF;
dest[offset + 9] = (u8)redValue;
dest[offset + 0x28] = (u8)greenValue;
@@ -1985,11 +1985,11 @@ void CArGBAOdh::LineDeconv22(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
greenValue = ScaleLimit((u32)lumaValue + (table->cbGreen[cbValue] + table->crGreen[crValue] >> 16));
blueValue = ScaleLimit((u32)lumaValue + table->blue[cbValue]);
if (format == 0) {
if (format == ODH_FORMAT_RGB565) {
redValue = ((redValue & 0xF8) << 8 | (greenValue & 0xFC) << 3) | (blueValue >> 3);
dest[offset + 10] = (u8)(redValue >> 8);
dest[offset + 11] = (u8)redValue;
} else if (format == 1) {
} else if (format == ODH_FORMAT_RGBA8) {
dest[offset + 10] = 0xFF;
dest[offset + 11] = (u8)redValue;
dest[offset + 0x2a] = (u8)greenValue;
@@ -2026,7 +2026,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
sourceCursor = request->bitstream;
u32 bitOffset = *request->bitCount;
if ((u32)(bytesConsumed + 4) > sourceLimit) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
} else {
maximumBitLength = 0xB;
bitBuffer = ((u32)*sourceCursor << 0x18) | ((u32)sourceCursor[1] << 0x10) | ((u32)sourceCursor[2] << 8) | sourceCursor[3];
@@ -2056,7 +2056,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
}
}
if (bitIndex > maxHuffmanBits) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
} else {
if (valueCategory > 0) {
bitCountAndMask = (1 << (valueCategory)) - 1;
@@ -2070,7 +2070,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
u32** predictors = request->predictors;
u32* predictor = predictors[component >> 1];
bitCountAndMask = bitOffset + bitIndex + valueCategory;
tableIndex = (u32)(bitCountAndMask >> 3);
tableIndex = (bitCountAndMask >> 3);
decodedSymbol = 1;
bitIndex = (int)bitBuffer + *predictor;
*coefficientOutput = bitIndex;
@@ -2082,7 +2082,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
}
do {
if ((u32)(bytesConsumed + 4) > sourceLimit) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
goto finishDecode;
}
bitIndex = 1;
@@ -2109,12 +2109,12 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
bitIndex++;
}
if (bitIndex > 6) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
goto finishDecode;
}
if (valueCategory == 7) {
bitCountAndMask += bitIndex;
tableIndex = (u32)(bitCountAndMask >> 3);
tableIndex = (bitCountAndMask >> 3);
while (bitCountAndMask >= 8) {
sourceCursor++;
bytesConsumed++;
@@ -2123,10 +2123,10 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
break;
}
if (valueCategory > 0) {
tableIndex = (u32)(u32)(1 << (valueCategory)) - 1 &
(u32)(bitBuffer >> ((0x20 - bitIndex) - valueCategory));
tableIndex = (u32)(1 << (valueCategory)) - 1 &
(bitBuffer >> ((0x20 - bitIndex) - valueCategory));
if ((tableIndex & (u32)(1 << (valueCategory - 1))) == 0) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
goto finishDecode;
}
} else {
@@ -2137,14 +2137,14 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
decodedSymbol++;
}
bitCountAndMask = bitCountAndMask + bitIndex + valueCategory;
tableIndex = (u32)(bitCountAndMask >> 3);
tableIndex = (bitCountAndMask >> 3);
while (bitCountAndMask >= 8) {
sourceCursor++;
bytesConsumed++;
bitCountAndMask -= 8;
}
if ((u32)(bytesConsumed + 4) > sourceLimit) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
goto finishDecode;
}
maximumBitLength = 0xB;
@@ -2174,7 +2174,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
}
}
if (bitIndex > maxHuffmanBits) {
decodeResult = 0x80000003;
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
goto finishDecode;
}
if (valueCategory > 0) {
@@ -2188,7 +2188,7 @@ s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* req
}
bitCountAndMask = bitCountAndMask + bitIndex + valueCategory;
coefficientOutput[decodedSymbol] = bitBuffer;
tableIndex = (u32)(bitCountAndMask >> 3);
tableIndex = (bitCountAndMask >> 3);
decodedSymbol = decodedSymbol + 1;
while (bitCountAndMask >= 8) {
sourceCursor++;

View File

@@ -0,0 +1,340 @@
# rx40 expression cleanup
Base `d220c7accbcacca7207d851fdd1f27fa353a08c2`, branch `agent/w1005/rx40`.
This round preserves every object byte and all existing objdiff measurements.
The matching-round requirement to gain exact functions does not apply.
Baseline rebuilt before edits. Saved all 1027 source-object SHA256 hashes,
the full objdiff report, and all twelve owned objects under `/tmp/rx40-cleanup`.
## Trials
KEEP requires whole-object byte equality. REVERT restores the source and rebuilds it.
- 1. constants, iplGCSaveData scene identifiers, 9 replacements. KEEP.
- 2. constants, iplGCWindow scene identifiers, 2 replacements. KEEP.
- 3. constants, MemoryBase button masks, animation modes, and setting commands, 12 replacements. REVERT: src/scene/memoryCard/iplMemoryCardBase: .text.
- 4. constants, MemoryCard page button masks and animation modes, 4 replacements. REVERT: src/scene/memoryCard/iplMemoryCard: .text.
- 5. constants, MemoryCardManager SDK file limits, texture formats, dimensions, and language, 14 replacements. KEEP.
- 6. constants, SDChannelTitle scene identifiers, WPAD status, button masks, and SDButton animations, 48 replacements. REVERT: compiler failure, see trial-6.build.txt.
- 7. constants, ODH pixel formats, 24 replacements. KEEP.
- 8. constants, MemoryBase button masks, animation modes, and setting commands with header-verified values, 12 replacements. KEEP.
- 9. constants, MemoryCard page button masks and animation modes with header-verified values, 4 replacements. KEEP.
- 10. constants, SDChannelTitle scene identifiers, WPAD status, button masks, and SDButton animations with header-verified values, 48 replacements. KEEP.
- 11. constants, card SDK results and permission flags, 100 replacements. KEEP.
- 12. casts, GCWindow casts from list void pointers, 2 replacements. KEEP.
- 13. casts, MemoryCard VEC3 conversion operators, 2 replacements. KEEP.
- 14. conditions, MemoryCard boolean readiness calls, 4 replacements. KEEP.
- 15. conditions, TVRC boolean ARC results and initialization flag, 3 replacements. KEEP.
- 16. casts, TVRC cast from file data void pointer, 1 replacements. KEEP.
- 17. conditions, TextBalloon aspect-ratio flags, 3 replacements. KEEP.
- 18. conditions, TextBalloon direct fade-in state condition, 1 replacements. REVERT: src/scene/textBalloon/iplBalloon: .rela.text, .strtab, .symtab, .text.
- 19. conditions, SDChannelTitle channel availability boolean, 1 replacements. KEEP.
- 20. constants, SDChannelTitle remaining scene and event constants, 3 replacements. KEEP.
- 21. casts, SDMemory construct colors through existing GXColor constructor, 6 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .rela.text, .strtab, .symtab, .text.
- 22. casts, ODH already unsigned quality and bit values, 7 replacements. KEEP.
- 23. casts, ODH conversion table already const signed long pointer, 1 replacements. KEEP.
- 24. names, ODH DC predictor fields, 18 replacements. KEEP.
- 25. names, SaveDataManager prioritized title list, 4 replacements. KEEP.
- 26. members, SaveDataManager channel type through existing member, 1 replacements. REVERT: src/system/iplSaveDataManager: .strtab, .text.
- 27. names, MemoryBase hover counts, animation state, and layout file, 34 replacements. KEEP.
- 28. casts, CardSequence redundant icon buffer and speed casts, 2 replacements. KEEP.
- 29. casts, CardSequence casts from allocator void pointers, 5 replacements. KEEP.
- 30. constants, CardSequence blocking queue flags, 4 replacements. KEEP.
- 31. constants, CardSequence banner and icon formats, 16 replacements. KEEP.
- 32. constants, SDChannelTitle exit scene identifiers, 3 replacements. KEEP.
- 33. constants, ODH error codes and success comparisons, 27 replacements. KEEP.
- 34. conditions, TVRC loop boolean flags, 2 replacements. KEEP.
- 35. constants, SaveDataManager channel index limit, 2 replacements. KEEP.
- 36. members, SaveDataManager checksum bytes from the data member, 2 replacements. REVERT: src/system/iplSaveDataManager: .rela.text, .symtab, .text.
- 37. constants, CardSequence SDK file counts and buffer sizes, 26 replacements. KEEP.
- 38. constants, MemoryCard slot enum values, 9 replacements. KEEP.
- 39. conditions, MemoryBase existing child-wait predicate, 1 replacements. REVERT: src/scene/memoryCard/iplMemoryCardBase: .strtab.
- 40. casts, TVRC tick word already u32, 2 replacements. KEEP.
- 41. casts, TVRC archive header from void pointer, 1 replacements. KEEP.
- 42. casts, SDChannelTitle mutable callback controller avoids const cast, 2 replacements. KEEP.
- 43. members, SDChannelTitle usage pointer through first member, 1 replacements. KEEP.
- 44. constants, SDChannelTitle worker results and NAND file readiness, 12 replacements. KEEP.
- 45. constants, SDMemory NAND worker result codes, 7 replacements. KEEP.
- 46. conditions, SDMemory scroller boolean result, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .text.
- 47. casts, ODH direct work-buffer pointer arithmetic, 5 replacements. REVERT: src/system/odh: .text.
- 48. conditions, ODH dimension validation grouping, 2 replacements. KEEP.
- 49. conditions, ODH direct header validation, 1 replacements. KEEP.
- 50. names, ODH named error reasons, 34 replacements. KEEP.
- 51. members, SaveDataManager valid-channel scan through declared channel entries, 6 replacements. REVERT: src/system/iplSaveDataManager: .rela.text, .symtab, .text.
- 52. names, MCFile high word of the comparator sort key, 4 replacements. KEEP.
- 53. constants, MemoryCardManager SDK banner dimensions, file counts, and slot identifiers, 6 replacements. KEEP.
- 54. constants, CardSequence remaining success and storage constants, 7 replacements. KEEP.
- 55. constants, MemoryCardManager existing CardCommand enum in completion dispatch, 8 replacements. KEEP.
- 56. constants, SaveDataManager channel page count, 1 replacements. KEEP.
- 57. conditions, ODH header comparison spacing, 0 replacements. KEEP.
- 58. casts, ODH isolate direct buffer arithmetic at baseline line 723, 1 replacements. KEEP.
- 59. casts, ODH isolate direct buffer arithmetic at baseline line 741, 1 replacements. KEEP.
- 60. casts, ODH isolate direct buffer arithmetic at baseline line 748, 1 replacements. KEEP.
- 61. casts, ODH isolate direct buffer arithmetic at baseline line 1381, 1 replacements. REVERT: src/system/odh: .text.
- 62. casts, ODH isolate direct buffer arithmetic at baseline line 1562, 1 replacements. REVERT: src/system/odh: .text.
- 63. casts, SDMemory isolate GXColor conversion at baseline line 1349, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .strtab.
- 64. casts, SDMemory isolate GXColor conversion at baseline line 1351, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .rela.text, .strtab, .symtab, .text.
- 65. casts, SDMemory isolate GXColor conversion at baseline line 1352, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .rela.text, .strtab, .symtab, .text.
- 66. casts, SDMemory isolate GXColor conversion at baseline line 1356, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .strtab.
- 67. casts, SDMemory isolate GXColor conversion at baseline line 1358, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .rela.text, .strtab, .symtab, .text.
- 68. casts, SDMemory isolate GXColor conversion at baseline line 1359, 1 replacements. REVERT: src/scene/sdChannelMemory/iplSDMemory: .rela.text, .strtab, .symtab, .text.
- 69. casts, GCSaveData null test without downcast, 1 replacements. KEEP.
- 70. casts, GCWindow explicit checked-base casts, 2 replacements. KEEP.
- 71. conditions, MemoryBase direct button command range, 1 replacements. REVERT: src/scene/memoryCard/iplMemoryCardBase: .rela.text, .strtab, .symtab, .text.
- 72. conditions, SDChannelTitle explicit transfer error alternatives, 1 replacements. REVERT: src/scene/sdChannelTitle/iplSDChannelTitle: .strtab.
## Results
Cleaned 12 translation units and two owned headers. Every retained edit preserved
whole-object bytes, including symbol and string tables. Of 72 trials, 51 were
retained and 21 were reverted. Trial 57 only adjusted the spacing of trial 49.
| Category | Retained count |
| --- | ---: |
| Numeric literals replaced with existing named constants | 350 |
| Cast sites simplified or made explicit | 31 |
| Conditions simplified | 16 |
| Pointer access replaced with the existing member | 1 |
| Declarations given descriptive names | 15 |
| Name occurrences changed, including declarations | 94 |
The trial journal counts text replacements. A replacement can contain two
constants or casts. The constant total above counts individual numeric literals;
cast totals count replacement sites. The 15 declarations are four MemoryBase
members, one MCFile member, four ODH members, five ODH error enumerators, and
one SaveDataManager local array.
| File | Constants | Cast sites | Conditions | Member access | Name occurrences |
| --- | ---: | ---: | ---: | ---: | ---: |
| `include/scene/memoryCard/iplMemoryCardBase.h` | 0 | 0 | 0 | 0 | 8 |
| `include/scene/memoryCard/iplMemoryCardManager.h` | 8 | 0 | 0 | 0 | 1 |
| `src/scene/cardSequence/iplCardSequence.cpp` | 153 | 7 | 0 | 0 | 0 |
| `src/scene/memoryCard/iplGCSaveData.cpp` | 9 | 1 | 0 | 0 | 4 |
| `src/scene/memoryCard/iplGCWindow.cpp` | 2 | 4 | 0 | 0 | 5 |
| `src/scene/memoryCard/iplMemoryCard.cpp` | 13 | 2 | 4 | 0 | 8 |
| `src/scene/memoryCard/iplMemoryCardBase.cpp` | 12 | 0 | 0 | 0 | 9 |
| `src/scene/memoryCard/iplMemoryCardManager.cpp` | 24 | 0 | 0 | 0 | 3 |
| `src/scene/sdChannelMemory/iplSDMemory.cpp` | 7 | 0 | 0 | 0 | 0 |
| `src/scene/sdChannelTitle/iplSDChannelTitle.cpp` | 68 | 2 | 1 | 1 | 0 |
| `src/scene/textBalloon/iplBalloon.cpp` | 0 | 0 | 3 | 0 | 0 |
| `src/system/TVRC.cpp` | 0 | 4 | 5 | 0 | 0 |
| `src/system/iplSaveDataManager.cpp` | 3 | 0 | 0 | 0 | 4 |
| `src/system/odh.cpp` | 51 | 11 | 3 | 0 | 52 |
## Rejected edits and scope limits
Trials 3 and 4 initially used the wrong animation enum value. The build caught
the changed instructions; trials 8 and 9 used the verified `ANIM_TYPE_BACKWARD`
value and passed. Trial 6 used an unavailable WPAD name; trial 10 used the
header's `WPAD_LIB_STATUS_0`. These three failures were mapping mistakes, not
proof that the expressions were load-bearing.
The other rejected cleanup candidates changed object bytes:
- `TextBalloon::calc`: replacing the fade-in switch with an if changed code,
relocations, and symbol/string tables.
- `SDMemory::drawTransferTitles`: constructing each of the six GXColor values
through its constructor changed code or `.strtab`. All six were isolated
after the grouped trial failed; none was retained.
- `savedata::Manager::getAvailableInList` and `getNumValidChannel`: direct
`mData.chanInfo` accesses changed instructions or relocations. The original
offset expressions remain.
- `savedata::Manager::initManagerTask`: deriving the checksum address from `mData`
changed instructions and relocations. The original address expression remains.
- `MemoryBase::is_fadein_enable`: using the existing child-wait predicate changed
only `.strtab`, which still fails the whole-object requirement.
- `SDMemory::calc`: removing `== TRUE` from the scroller result changed `.text`.
- `CArGBAOdh::cdj_d_decompressLoop`: both integer-to-pointer work-buffer
simplifications changed `.text`. The three corresponding compressor sites
passed when tested individually and were retained.
- `MemoryBase::AnmButton::onCmdRecv`: replacing the unsigned command-range test
with direct bounds changed code, relocations, and symbol/string tables.
- `iplSDChannelTitle_updateCopyPrepare`: spelling out the two transfer errors
changed only `.strtab`; the unsigned range expression remains.
Remaining `unk_` member names are declared outside the assigned headers:
`FileInfo`, `CardState`, and `IconState` in `include/iplMemoryCardLib.h`, and
`Scroller::unk_0x3C` in `include/utility/iplScroller.h`. Their declarations and
uses remain unchanged. Unused reserved fields remain reserved. The save-data
`padding` array is cleared as serialized reserved storage, with no demonstrated
alternate meaning. The SDMemory double-to-float-to-integer conversions retain
an intermediate rounding step, so they are not redundant casts.
No source comments, assembly, declarations' order, or statement order were added
or rearranged. No configuration, symbol bounds, or other worker files changed.
## Final verification
The baseline was rebuilt from `d220c7accbcacca7207d851fdd1f27fa353a08c2`
before editing. The final non-quick gate used that same base. After its clean
build, a separate report generation and SHA256 comparison established:
- All 1027 source ELF objects equal the saved baseline bytes, including every
translation unit that includes the renamed headers.
- The complete objdiff JSON equals the saved baseline JSON, across all units,
functions, sections, and link measures.
- All 12 owned string pools are identical to their target pools.
- Instruction-exact functions: 408/416 -> 408/416.
- Objdiff matched code bytes: 95204/106872 -> 95204/106872.
- Objdiff matched data bytes: 19800/19800 -> 19800/19800.
- Full 4.3U build and `build/43U/ok` pass.
- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
- Zero regressions, forbidden additions, readability warnings, or whitespace
errors from `git diff --check`.
Reproduce the full gate from this worktree:
```sh
python3 /mnt/drive2/projects/wii-ipl-workers/_restore0928-tools/gate.py \
src/scene/cardSequence/iplCardSequence \
src/scene/memoryCard/iplGCSaveData src/scene/memoryCard/iplGCWindow \
src/scene/memoryCard/iplMemoryCard src/scene/memoryCard/iplMemoryCardBase \
src/scene/memoryCard/iplMemoryCardManager \
src/scene/sdChannelMemory/iplSDMemory src/scene/sdChannelTitle/iplSDChannelTitle \
src/scene/textBalloon/iplBalloon src/system/TVRC \
src/system/iplSaveDataManager src/system/odh \
--base d220c7accbcacca7207d851fdd1f27fa353a08c2
```
The exact baseline/report/hash snapshots and per-trial build output are in
`/tmp/rx40-cleanup`; this log preserves the measurements and rejected trials.
## Existing non-matching functions
These eight functions are unchanged by this cleanup. They are not new
regressions or targets for code-generation changes in this round. Counts below
are source/target instructions from `ctxdiff.py`; equal instruction counts do
not establish a match.
| Function | Objdiff percent | Instructions | Existing difference |
| --- | ---: | --- | --- |
| `LineConv11__9CArGBAOdhFPUcPUcPUcPUcUsUsPCli` | 98.08219 | 146/146 | 12 differing instructions; register use and scheduling |
| `huffmanDecoder__9CArGBAOdhFPUlP21SArCDJ_HuffmanRequestPPUsiUl` | 95.57189 | 306/306 | 171 differing instructions; register use and addressing |
| `_create_icon__Q33ipl5scene17MemoryCardManagerFUcsl` | 87.55 | 100/100 | 37 differing instructions; register use and address calculations |
| `cardThreadMain` | 97.9402 | 301/301 | 78 differing instructions; register use |
| `loadCardFileIcons` | 91.33984 | 509/512 | Instruction count and register use |
| `iplSDChannelTitle_flushSaveBeforeExit` | 98.5946 | 37/37 | 6 differing instructions; register use |
| `create__Q33ipl5scene8SDMemoryFPQ23EGG4HeapPQ33ipl4nand10LayoutFilePQ33ipl5scene15SDChannelSelect` | 99.15884 | 1064/1064 | 175 differing instructions; register use and addressing |
| `drawTransferTitles__Q33ipl5scene8SDMemoryFv` | 93.456764 | 438/451 | Instruction count and register use |
## Full gate output
```text
full build: ok
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
[src/scene/cardSequence/iplCardSequence] pool: IDENTICAL
[src/scene/cardSequence/iplCardSequence] objdiff: code 6600/9852 data 1496/1496 functions 28/30 fuzzy 97.9480 linked code 0
[src/scene/cardSequence/iplCardSequence] instruction-exact functions: 28/30
[src/scene/cardSequence/iplCardSequence] section .bss size 16 match 100.0
[src/scene/cardSequence/iplCardSequence] section .data size 1464 match 100.0
[src/scene/cardSequence/iplCardSequence] section .sbss size 8 match 100.0
[src/scene/cardSequence/iplCardSequence] section .sdata size 8 match 100.0
[src/scene/cardSequence/iplCardSequence] section .text size 9852 match 97.94803
[src/scene/cardSequence/iplCardSequence] below 100: cardThreadMain 97.9402
[src/scene/cardSequence/iplCardSequence] below 100: loadCardFileIcons 91.33984
[src/scene/cardSequence/iplCardSequence] baseline: code 6600/9852 data 1496 functions 28 fuzzy 97.9480
[src/scene/memoryCard/iplGCSaveData] pool: IDENTICAL
[src/scene/memoryCard/iplGCSaveData] objdiff: code 2008/2008 data 392/392 functions 12/12 fuzzy 100.0000 linked code 2008
[src/scene/memoryCard/iplGCSaveData] instruction-exact functions: 12/12
[src/scene/memoryCard/iplGCSaveData] section .data size 336 match 100.0
[src/scene/memoryCard/iplGCSaveData] section .rodata size 40 match 100.0
[src/scene/memoryCard/iplGCSaveData] section .sdata size 16 match 100.0
[src/scene/memoryCard/iplGCSaveData] section .text size 2008 match 100.0
[src/scene/memoryCard/iplGCSaveData] baseline: code 2008/2008 data 392 functions 12 fuzzy 100.0000
[src/scene/memoryCard/iplGCWindow] pool: IDENTICAL
[src/scene/memoryCard/iplGCWindow] objdiff: code 9964/9964 data 2032/2032 functions 48/48 fuzzy 100.0000 linked code 9964
[src/scene/memoryCard/iplGCWindow] instruction-exact functions: 48/48
[src/scene/memoryCard/iplGCWindow] section .data size 1784 match 100.0
[src/scene/memoryCard/iplGCWindow] section .rodata size 176 match 100.0
[src/scene/memoryCard/iplGCWindow] section .sdata size 48 match 100.0
[src/scene/memoryCard/iplGCWindow] section .sdata2 size 24 match 100.0
[src/scene/memoryCard/iplGCWindow] section .text size 9964 match 100.0
[src/scene/memoryCard/iplGCWindow] baseline: code 9964/9964 data 2032 functions 48 fuzzy 100.0000
[src/scene/memoryCard/iplMemoryCard] pool: IDENTICAL
[src/scene/memoryCard/iplMemoryCard] objdiff: code 9264/9264 data 2656/2656 functions 41/41 fuzzy 100.0000 linked code 9264
[src/scene/memoryCard/iplMemoryCard] instruction-exact functions: 41/41
[src/scene/memoryCard/iplMemoryCard] section .data size 2320 match 100.0
[src/scene/memoryCard/iplMemoryCard] section .rodata size 280 match 100.0
[src/scene/memoryCard/iplMemoryCard] section .sdata size 40 match 100.0
[src/scene/memoryCard/iplMemoryCard] section .sdata2 size 16 match 100.0
[src/scene/memoryCard/iplMemoryCard] section .text size 9264 match 100.0
[src/scene/memoryCard/iplMemoryCard] baseline: code 9264/9264 data 2656 functions 41 fuzzy 100.0000
[src/scene/memoryCard/iplMemoryCardBase] pool: IDENTICAL
[src/scene/memoryCard/iplMemoryCardBase] objdiff: code 3640/3640 data 160/160 functions 34/34 fuzzy 100.0000 linked code 3640
[src/scene/memoryCard/iplMemoryCardBase] instruction-exact functions: 34/34
[src/scene/memoryCard/iplMemoryCardBase] section .data size 144 match 100.0
[src/scene/memoryCard/iplMemoryCardBase] section .sdata2 size 16 match 100.0
[src/scene/memoryCard/iplMemoryCardBase] section .text size 3640 match 100.0
[src/scene/memoryCard/iplMemoryCardBase] baseline: code 3640/3640 data 160 functions 34 fuzzy 100.0000
[src/scene/memoryCard/iplMemoryCardManager] pool: IDENTICAL
[src/scene/memoryCard/iplMemoryCardManager] objdiff: code 4996/5396 data None/None functions 25/26 fuzzy 99.0771 linked code 0
[src/scene/memoryCard/iplMemoryCardManager] instruction-exact functions: 25/26
[src/scene/memoryCard/iplMemoryCardManager] section .text size 5396 match 99.077095
[src/scene/memoryCard/iplMemoryCardManager] below 100: _create_icon__Q33ipl5scene17MemoryCardManagerFUcsl 87.55
[src/scene/memoryCard/iplMemoryCardManager] baseline: code 4996/5396 data None functions 25 fuzzy 99.0771
[src/scene/sdChannelMemory/iplSDMemory] pool: IDENTICAL
[src/scene/sdChannelMemory/iplSDMemory] objdiff: code 14812/20872 data 3344/3344 functions 64/66 fuzzy 99.2629 linked code 0
[src/scene/sdChannelMemory/iplSDMemory] instruction-exact functions: 64/66
[src/scene/sdChannelMemory/iplSDMemory] section .data size 3144 match 100.0
[src/scene/sdChannelMemory/iplSDMemory] section .sdata size 152 match 100.0
[src/scene/sdChannelMemory/iplSDMemory] section .sdata2 size 48 match 100.0
[src/scene/sdChannelMemory/iplSDMemory] section .text size 20872 match 99.26294
[src/scene/sdChannelMemory/iplSDMemory] below 100: create__Q33ipl5scene8SDMemoryFPQ23EGG4HeapPQ33ipl4nand10LayoutFilePQ33ipl5scene15SDChannelSelect 99.15884
[src/scene/sdChannelMemory/iplSDMemory] below 100: drawTransferTitles__Q33ipl5scene8SDMemoryFv 93.456764
[src/scene/sdChannelMemory/iplSDMemory] baseline: code 14812/20872 data 3344 functions 64 fuzzy 99.2629
[src/scene/sdChannelTitle/iplSDChannelTitle] pool: IDENTICAL
[src/scene/sdChannelTitle/iplSDChannelTitle] objdiff: code 18476/18624 data 1976/1976 functions 68/69 fuzzy 99.9888 linked code 0
[src/scene/sdChannelTitle/iplSDChannelTitle] instruction-exact functions: 68/69
[src/scene/sdChannelTitle/iplSDChannelTitle] section .data size 1696 match 100.0
[src/scene/sdChannelTitle/iplSDChannelTitle] section .rodata size 48 match 100.0
[src/scene/sdChannelTitle/iplSDChannelTitle] section .sdata size 192 match 100.0
[src/scene/sdChannelTitle/iplSDChannelTitle] section .sdata2 size 40 match 100.0
[src/scene/sdChannelTitle/iplSDChannelTitle] section .text size 18624 match 99.98883
[src/scene/sdChannelTitle/iplSDChannelTitle] below 100: iplSDChannelTitle_flushSaveBeforeExit 98.5946
[src/scene/sdChannelTitle/iplSDChannelTitle] baseline: code 18476/18624 data 1976 functions 68 fuzzy 99.9888
[src/scene/textBalloon/iplBalloon] pool: IDENTICAL
[src/scene/textBalloon/iplBalloon] objdiff: code 3084/3084 data 136/136 functions 18/18 fuzzy 100.0000 linked code 3084
[src/scene/textBalloon/iplBalloon] instruction-exact functions: 18/18
[src/scene/textBalloon/iplBalloon] section .data size 80 match 100.0
[src/scene/textBalloon/iplBalloon] section .sdata size 24 match 100.0
[src/scene/textBalloon/iplBalloon] section .sdata2 size 32 match 100.0
[src/scene/textBalloon/iplBalloon] section .text size 3084 match 100.0
[src/scene/textBalloon/iplBalloon] baseline: code 3084/3084 data 136 functions 18 fuzzy 100.0000
[src/system/TVRC] pool: IDENTICAL
[src/system/TVRC] objdiff: code 2312/2312 data 280/280 functions 9/9 fuzzy 100.0000 linked code 2312
[src/system/TVRC] instruction-exact functions: 9/9
[src/system/TVRC] section .bss size 96 match 100.0
[src/system/TVRC] section .sbss size 120 match 100.0
[src/system/TVRC] section .sdata size 32 match 100.0
[src/system/TVRC] section .sdata2 size 32 match 100.0
[src/system/TVRC] section .text size 2312 match 100.0
[src/system/TVRC] baseline: code 2312/2312 data 280 functions 9 fuzzy 100.0000
[src/system/iplSaveDataManager] pool: IDENTICAL
[src/system/iplSaveDataManager] objdiff: code 7172/7172 data 968/968 functions 35/35 fuzzy 100.0000 linked code 7172
[src/system/iplSaveDataManager] instruction-exact functions: 35/35
[src/system/iplSaveDataManager] section .data size 184 match 100.0
[src/system/iplSaveDataManager] section .rodata size 768 match 100.0
[src/system/iplSaveDataManager] section .sdata size 16 match 100.0
[src/system/iplSaveDataManager] section .text size 7172 match 100.0
[src/system/iplSaveDataManager] baseline: code 7172/7172 data 968 functions 35 fuzzy 100.0000
[src/system/odh] pool: IDENTICAL
[src/system/odh] objdiff: code 12876/14684 data 6360/6360 functions 26/28 fuzzy 99.5546 linked code 0
[src/system/odh] instruction-exact functions: 26/28
[src/system/odh] section .data size 464 match 100.0
[src/system/odh] section .rodata size 5856 match 100.0
[src/system/odh] section .sdata2 size 40 match 100.0
[src/system/odh] section .text size 14684 match 99.55462
[src/system/odh] below 100: LineConv11__9CArGBAOdhFPUcPUcPUcPUcUsUsPCli 98.08219
[src/system/odh] below 100: huffmanDecoder__9CArGBAOdhFPUlP21SArCDJ_HuffmanRequestPPUsiUl 95.57189
[src/system/odh] baseline: code 12876/14684 data 6360 functions 26 fuzzy 99.5546
regressions vs baseline: 0
global matched_code_percent: 93.96723 -> 93.96723
global fuzzy_match_percent: 99.81488 -> 99.81488
global complete_code_percent: 80.08451 -> 80.08451
global matched_data_percent: 99.99410 -> 99.99410
forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
GATE PASS
```