Compare commits
5 Commits
cleanup/pf
...
cleanup/ca
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9646c0c892 | ||
|
|
486c20c623 | ||
|
|
6adb0dc52e | ||
|
|
c9f64372cf | ||
|
|
9f4a70db74 |
@@ -53,9 +53,9 @@ Progress
|
||||
<!-- progress:start -->
|
||||
| Decompiled | Matched | Linked | Data |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| 99.38% | 87.96% | 62.33% | 92.07% |
|
||||
| 99.38% | 87.97% | 62.33% | 92.07% |
|
||||
|
||||
units 919/1027 complete, functions 12224/12563 matched.
|
||||
units 919/1027 complete, functions 12225/12563 matched.
|
||||
|
||||
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
|
||||
<!-- progress:end -->
|
||||
|
||||
@@ -4399,31 +4399,31 @@ getCardSlotState__Q23ipl10memorycardFv = .text:0x813D2024; // type:function size
|
||||
getCardLastSrcSlot__Q23ipl10memorycardFv = .text:0x813D202C; // type:function size:0x10
|
||||
getCardLastSendCmd__Q23ipl10memorycardFv = .text:0x813D203C; // type:function size:0x10
|
||||
getCardLastCMDFCmdResult__Q23ipl10memorycardFv = .text:0x813D204C; // type:function size:0x10
|
||||
CardSequence_813D205C = .text:0x813D205C; // type:function size:0x44
|
||||
sendCardUnmountCmd = .text:0x813D205C; // type:function size:0x44
|
||||
sendCardFormatCmd__Q23ipl10memorycardFUc = .text:0x813D20A0; // type:function size:0x50
|
||||
sendCardCopyCmd__Q23ipl10memorycardFUcs = .text:0x813D20F0; // type:function size:0x54
|
||||
sendCardMoveCmd__Q23ipl10memorycardFUcs = .text:0x813D2144; // type:function size:0x54
|
||||
sendCardDeleteCmd__Q23ipl10memorycardFUcs = .text:0x813D2198; // type:function size:0x54
|
||||
sendCardThreadStopCmd__Q23ipl10memorycardFv = .text:0x813D21EC; // type:function size:0x40
|
||||
CardSequence_813D222C = .text:0x813D222C; // type:function size:0x110
|
||||
CardSequence_813D233C = .text:0x813D233C; // type:function size:0x9C
|
||||
pollCardSlot = .text:0x813D222C; // type:function size:0x110
|
||||
mapCardErrorCode = .text:0x813D233C; // type:function size:0x9C
|
||||
probeCard__Q23ipl10memorycardFv = .text:0x813D23D8; // type:function size:0x288
|
||||
initCardThread__Q23ipl10memorycardFv = .text:0x813D2660; // type:function size:0x29C
|
||||
shutdownCardThread__Q23ipl10memorycardFv = .text:0x813D28FC; // type:function size:0x148
|
||||
getIconStateArray__Q23ipl10memorycardFv = .text:0x813D2A44; // type:function size:0x10
|
||||
getIconComment__Q23ipl10memorycardFUcs = .text:0x813D2A54; // type:function size:0x20
|
||||
CardSequence_813D2A74 = .text:0x813D2A74; // type:function size:0xCC
|
||||
CardSequence_813D2B40 = .text:0x813D2B40; // type:function size:0x14C
|
||||
CardSequence_813D2C8C = .text:0x813D2C8C; // type:function size:0x4B4
|
||||
CardSequence_813D3140 = .text:0x813D3140; // type:function size:0xCC
|
||||
CardSequence_813D320C = .text:0x813D320C; // type:function size:0x9C
|
||||
CardSequence_813D32A8 = .text:0x813D32A8; // type:function size:0xD8
|
||||
CardSequence_813D3380 = .text:0x813D3380; // type:function size:0x58
|
||||
CardSequence_813D33D8 = .text:0x813D33D8; // type:function size:0x4C
|
||||
CardSequence_813D3424 = .text:0x813D3424; // type:function size:0x800
|
||||
CardSequence_813D3C24 = .text:0x813D3C24; // type:function size:0x14
|
||||
CardSequence_813D3C38 = .text:0x813D3C38; // type:function size:0xDC
|
||||
CardSequence_813D3D14 = .text:0x813D3D14; // type:function size:0x980
|
||||
clearCardFileEntry = .text:0x813D2A74; // type:function size:0xCC
|
||||
refreshCardSlotInfo = .text:0x813D2B40; // type:function size:0x14C
|
||||
cardThreadMain = .text:0x813D2C8C; // type:function size:0x4B4
|
||||
markAllCardFilesDirty = .text:0x813D3140; // type:function size:0xCC
|
||||
handleCardMountResult = .text:0x813D320C; // type:function size:0x9C
|
||||
reportCardThreadError = .text:0x813D32A8; // type:function size:0xD8
|
||||
sendCardSlotState = .text:0x813D3380; // type:function size:0x58
|
||||
clearAllCardFileEntries = .text:0x813D33D8; // type:function size:0x4C
|
||||
loadCardFileIcons = .text:0x813D3424; // type:function size:0x800
|
||||
clearCardWritePending = .text:0x813D3C24; // type:function size:0x14
|
||||
checkCardFileDuplicate = .text:0x813D3C38; // type:function size:0xDC
|
||||
runCardMoveOrCopy = .text:0x813D3D14; // type:function size:0x980
|
||||
IPLContestInitialize = .text:0x813D4694; // type:function size:0xBC
|
||||
IPLContestStart = .text:0x813D4750; // type:function size:0x14
|
||||
IPLContestProcess = .text:0x813D4764; // type:function size:0x6E8
|
||||
@@ -6804,14 +6804,14 @@ VmStringSplice = .text:0x8144FDD8; // type:function size:0x1E4
|
||||
VmStringSplit = .text:0x8144FFBC; // type:function size:0x378
|
||||
VmStringToLowerCase = .text:0x81450334; // type:function size:0xB4
|
||||
VmStringToUpperCase = .text:0x814503E8; // type:function size:0xB4
|
||||
CHANSVm_8145049C = .text:0x8145049C; // type:function size:0x6BC
|
||||
CHANSVmFormatString = .text:0x8145049C; // type:function size:0x6BC
|
||||
VmStringFormat = .text:0x81450B58; // type:function size:0x4C
|
||||
VmGetStrFromObjHdr = .text:0x81450BA4; // type:function size:0x24
|
||||
VmGetIntFromObjHdr = .text:0x81450BC8; // type:function size:0x24
|
||||
VmBlobInitValue = .text:0x81450BEC; // type:function size:0x20 scope:local
|
||||
VmBlobCreateDirect = .text:0x81450C0C; // type:function size:0xAC scope:local
|
||||
VmBlobGetDataBufferDirect = .text:0x81450CB8; // type:function size:0x5C scope:local
|
||||
CHANSVm_81450D14 = .text:0x81450D14; // type:function size:0xB8
|
||||
CHANSVmBlobResolveOffset = .text:0x81450D14; // type:function size:0xB8
|
||||
VmBlobCtor = .text:0x81450DCC; // type:function size:0xA8 scope:local
|
||||
VmBlobDtor = .text:0x81450E74; // type:function size:0x28 scope:local
|
||||
VmBlobGetOffset = .text:0x81450E9C; // type:function size:0x68
|
||||
@@ -6820,8 +6820,8 @@ VmBlobSkip = .text:0x81450FC8; // type:function size:0xF0
|
||||
VmBlobGetLength = .text:0x814510B8; // type:function size:0x68
|
||||
VmBlobSetLength = .text:0x81451120; // type:function size:0xF8
|
||||
VmBlobFill = .text:0x81451218; // type:function size:0xFC
|
||||
CHANSVm_81451314 = .text:0x81451314; // type:function size:0x34
|
||||
CHANSVm_81451348 = .text:0x81451348; // type:function size:0x50
|
||||
CHANSVmBlobGetCount = .text:0x81451314; // type:function size:0x34
|
||||
CHANSVmBlobHasSpace = .text:0x81451348; // type:function size:0x50
|
||||
VmBlobGetString = .text:0x81451398; // type:function size:0xC8
|
||||
VmBlobSetString = .text:0x81451460; // type:function size:0x12C
|
||||
VmBlobGetWString = .text:0x8145158C; // type:function size:0xE0
|
||||
@@ -6857,7 +6857,7 @@ VmBlobSetS32 = .text:0x814532E4; // type:function size:0xD8
|
||||
VmBlobSetS64 = .text:0x814533BC; // type:function size:0xE4
|
||||
vmBlobParsePackFormatString = .text:0x814534A0; // type:function size:0x1D0
|
||||
VmBlobPackCommon = .text:0x81453670; // type:function size:0xA70 scope:local
|
||||
CHANSVm_814540E0 = .text:0x814540E0; // type:function size:0x6C
|
||||
CHANSVmMakeU64 = .text:0x814540E0; // type:function size:0x6C
|
||||
VmBlobCreate = .text:0x8145414C; // type:function size:0x8
|
||||
VmBlobPack = .text:0x81454154; // type:function size:0x8
|
||||
VmBlobUnpack = .text:0x8145415C; // type:function size:0x814
|
||||
@@ -6875,7 +6875,7 @@ CHANSVmGetFreeExeSize = .text:0x81455198; // type:function size:0x28
|
||||
CHANSVmAddExe = .text:0x814551C0; // type:function size:0x3F8
|
||||
VmOffsU32ToPtr = .text:0x814555B8; // type:function size:0x18 scope:local
|
||||
CHANSConvertModuleOfsToPtr = .text:0x814555D0; // type:function size:0x84
|
||||
CHANSVm_81455654 = .text:0x81455654; // type:function size:0x8C
|
||||
CHANSVmLookupScopedObject = .text:0x81455654; // type:function size:0x8C
|
||||
VmPushFuncReturnInfo = .text:0x814556E0; // type:function size:0x1AC scope:local
|
||||
VmReturnWithValue = .text:0x8145588C; // type:function size:0x1D4 scope:local
|
||||
CHANSVmLinkModules = .text:0x81455A60; // type:function size:0x2F4
|
||||
@@ -14198,7 +14198,7 @@ ca_ppki = .rodata:0x8162DBB8; // type:object size:0x400 noreloc
|
||||
ms_dpki = .rodata:0x8162DFB8; // type:object size:0x240 noreloc
|
||||
ms_ppki = .rodata:0x8162E1F8; // type:object size:0x240 noreloc
|
||||
@1272 = .rodata:0x8162E438; // type:object size:0x278 scope:local data:4byte
|
||||
pf_valid_fn_char = .rodata:0x8162E6B0; // type:object size:0x60 noreloc
|
||||
pf_valid_fn_char = .rodata:0x8162E6B0; // type:object size:0x60 scope:local noreloc
|
||||
fat_special_values = .rodata:0x8162E710; // type:object size:0x3C
|
||||
cp932_to_unicode = .rodata:0x8162E750; // type:object size:0x4272 data:2byte
|
||||
fa_nand_func = .rodata:0x816329C8; // type:object size:0x20
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <private/vf/PrFILE2/pf_types.h>
|
||||
|
||||
// clang-format off
|
||||
const pf_u8 pf_valid_fn_char[96] = {
|
||||
const pf_u8 pf_valid_fn_char_8162E6B0[96] = {
|
||||
1, 3, 0, 3, 3, 3, 3, 3, 3, 3, 0, 1, 1, 3, 3, 0,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 1, 0, 1, 0, 0,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
|
||||
@@ -1282,11 +1282,13 @@ s32 PFFAT_GetSectorSpecified(PFFAT_FFD* file, u32 fileSectorIndex,
|
||||
|
||||
error = PFFAT_GetSector(file, fileSectorIndex, clusterIndex != 0, 0,
|
||||
sector);
|
||||
if (error != 0) {
|
||||
goto done;
|
||||
switch (error) {
|
||||
case 0:
|
||||
error = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
error = 0;
|
||||
done:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ typedef struct PF_PATH_VOLUME_SET {
|
||||
} PF_PATH_VOLUME_SET;
|
||||
|
||||
extern PF_PATH_VOLUME_SET pf_vol_set;
|
||||
extern const pf_u8 pf_valid_fn_char[96];
|
||||
extern const pf_u8 pf_valid_fn_char_8162E6B0[96];
|
||||
extern void PFSTR_SetCodeMode(PF_STR*, pf_u32);
|
||||
extern pf_u32 PFSTR_GetCodeMode(PF_STR*);
|
||||
extern pf_s8* PFSTR_GetStrPos(PF_STR*, pf_u32);
|
||||
@@ -75,9 +75,9 @@ extern pf_u32 PFPATH_CheckExtShortNameSignature(PF_STR*);
|
||||
extern pf_u32 PFPATH_CheckExtShortName(PF_STR*, pf_u32, pf_bool);
|
||||
extern void PFCODE_Divide_Width(pf_s32, pf_s16*, pf_s16*);
|
||||
|
||||
#define VALID_PATH_CHAR(x, b) ((pf_u8)(x) >= 0x80 || ((pf_u8)(x) >= ' ' && (pf_valid_fn_char[(pf_u8)(x) - ' '] & b)))
|
||||
#define VALID_PATH_CHAR(x, b) ((pf_u8)(x) >= 0x80 || ((pf_u8)(x) >= ' ' && (pf_valid_fn_char_8162E6B0[(pf_u8)(x) - ' '] & b)))
|
||||
#define VALID_PATH_WCHAR(x, b) \
|
||||
((x) >= 0x80 || (pf_u8)(x) >= ' ' && ((pf_u8)(x) & 0xFF00) == 0 && (pf_valid_fn_char[(pf_u8)((x & 0x00FF) - ' ')] & b))
|
||||
((x) >= 0x80 || (pf_u8)(x) >= ' ' && ((pf_u8)(x) & 0xFF00) == 0 && (pf_valid_fn_char_8162E6B0[(pf_u8)((x & 0x00FF) - ' ')] & b))
|
||||
|
||||
pf_s32 PFPATH_DoSplitPath(PF_STR* p_path, PF_STR* p_dir_path, PF_STR* p_filename, pf_u32 wildcard) {
|
||||
pf_s8* p;
|
||||
|
||||
@@ -3400,7 +3400,7 @@ VmMethodDefine(String, ToUpperCase) {
|
||||
return vmFalse;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVm_8145049C(CHANSVm* vm, CHANSVmObjHdr* obj, u32 arg) {
|
||||
CHANSVmObjHdr* CHANSVmFormatString(CHANSVm* vm, CHANSVmObjHdr* obj, u32 arg) {
|
||||
u8 pad0[8];
|
||||
u8 tempBuf[16];
|
||||
u8 fmtBufData[32];
|
||||
@@ -3745,7 +3745,7 @@ null_return:
|
||||
VmMethodDefine(String, Format) {
|
||||
u32 result;
|
||||
if (VmParentObj != vmNull && VmParentObj->type == CHANS_VM_TYPE_CLASS_REF) {
|
||||
result = (u32)CHANSVm_8145049C(VmInst, VmReturnObj, 0);
|
||||
result = (u32)CHANSVmFormatString(VmInst, VmReturnObj, 0);
|
||||
return result != 0;
|
||||
}
|
||||
return 0;
|
||||
@@ -3775,10 +3775,10 @@ int VmGetIntFromObjHdr(CHANSVmObjHdr* object) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 CHANSVm_81451314(BlobHeader* blob, CHANSVmObjHdr* ptr, u32 limit);
|
||||
BOOL CHANSVm_81451348(BlobHeader* blob, s64 size);
|
||||
u32 CHANSVmBlobGetCount(BlobHeader* blob, CHANSVmObjHdr* ptr, u32 limit);
|
||||
BOOL CHANSVmBlobHasSpace(BlobHeader* blob, s64 size);
|
||||
CHANSVmObjHdr* CHANSVmNewBlobObject(CHANSVm* VmInst, CHANSVmObjHdr* obj, u32 size, void* src, u32 count);
|
||||
static u64 CHANSVm_814540E0(u32 upper, u32 lower);
|
||||
static u64 CHANSVmMakeU64(u32 upper, u32 lower);
|
||||
|
||||
static void VmBlobInitValue(BlobHeader* blob, u32 size) {
|
||||
if (blob != vmNull) {
|
||||
@@ -3834,7 +3834,7 @@ static u8* VmBlobGetDataBufferDirect(CHANSVmObjHdr* obj) {
|
||||
return vmNull;
|
||||
}
|
||||
|
||||
BOOL CHANSVm_81450D14(BlobHeader* blob, s64 val, u32* out) {
|
||||
BOOL CHANSVmBlobResolveOffset(BlobHeader* blob, s64 val, u32* out) {
|
||||
s64 pos;
|
||||
|
||||
if (blob == vmNull) {
|
||||
@@ -3901,7 +3901,7 @@ VmMethodDefine(Blob, Seek) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (CHANSVm_81450D14(blob, val->value.int_v, &tmp)) {
|
||||
if (CHANSVmBlobResolveOffset(blob, val->value.int_v, &tmp)) {
|
||||
blob->offset = tmp;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -3988,9 +3988,9 @@ VmMethodDefine(Blob, Fill) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
count = blob != vmNull ? CHANSVm_81451314(blob, fill, blob->offset) : 0;
|
||||
count = blob != vmNull ? CHANSVmBlobGetCount(blob, fill, blob->offset) : 0;
|
||||
|
||||
if (CHANSVm_81451348(blob, count)) {
|
||||
if (CHANSVmBlobHasSpace(blob, count)) {
|
||||
memset(blob->pData + blob->offset, (u8)val->value.int_v, count);
|
||||
blob->offset += count;
|
||||
return 1;
|
||||
@@ -3999,7 +3999,7 @@ VmMethodDefine(Blob, Fill) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 CHANSVm_81451314(BlobHeader* blob, CHANSVmObjHdr* ptr, u32 limit) {
|
||||
u32 CHANSVmBlobGetCount(BlobHeader* blob, CHANSVmObjHdr* ptr, u32 limit) {
|
||||
if (ptr != vmNull) {
|
||||
return *(u32*)((u8*)ptr + 4);
|
||||
}
|
||||
@@ -4013,7 +4013,7 @@ u32 CHANSVm_81451314(BlobHeader* blob, CHANSVmObjHdr* ptr, u32 limit) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL CHANSVm_81451348(BlobHeader* blob, s64 size) {
|
||||
BOOL CHANSVmBlobHasSpace(BlobHeader* blob, s64 size) {
|
||||
u32 curOff = blob->offset;
|
||||
return size >= 0 && (s64)(blob->size - curOff) >= size;
|
||||
}
|
||||
@@ -4028,7 +4028,7 @@ VmMethodDefine(Blob, GetString) {
|
||||
}
|
||||
|
||||
size = (u32)arg->value.int_v;
|
||||
if (CHANSVm_81451348(blob, size)) {
|
||||
if (CHANSVmBlobHasSpace(blob, size)) {
|
||||
CHANSVmErr err = CHANSVmSetU16StringFromU8(VmInst, VmReturnObj, (char*)(blob->pData + blob->offset), size);
|
||||
blob->offset += size;
|
||||
return err == CHANS_VM_OK;
|
||||
@@ -4058,7 +4058,7 @@ VmMethodDefine(Blob, SetString) {
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANSVm_81451348(blob, size)) {
|
||||
if (CHANSVmBlobHasSpace(blob, size)) {
|
||||
memset(blob->pData + blob->offset, 0, size);
|
||||
CHANSVmStrCpyToU8FromU16(blob->pData + blob->offset, strData, charCount);
|
||||
blob->offset += size;
|
||||
@@ -4076,7 +4076,7 @@ VmMethodDefine(Blob, GetWString) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (CHANSVm_81451348(blob, VM_STR_LENGTH(arg->value.int_v))) {
|
||||
if (CHANSVmBlobHasSpace(blob, VM_STR_LENGTH(arg->value.int_v))) {
|
||||
CHANSVmErr err = CHANSVmSetU16String(VmInst, VmReturnObj, (wchar_t*)(blob->pData + blob->offset), (u32)arg->value.int_v << 1);
|
||||
u32 oldOffset = blob->offset;
|
||||
u64 length = VM_STR_LENGTH(arg->value.int_v);
|
||||
@@ -4113,7 +4113,7 @@ VmMethodDefine(Blob, SetWString) {
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANSVm_81451348(blob, size)) {
|
||||
if (CHANSVmBlobHasSpace(blob, size)) {
|
||||
memcpy(blob->pData + blob->offset, strData, strLen);
|
||||
if (strLen < size) {
|
||||
memset(blob->pData + blob->offset + strLen, 0, size - strLen);
|
||||
@@ -4184,8 +4184,8 @@ VmMethodDefine(Blob, CopyRangeFrom) {
|
||||
srcOff = 0;
|
||||
destOff = 0;
|
||||
|
||||
if (CHANSVm_81450D14(destBlob, destOffObj->value.int_v, &destOff) != 0 && CHANSVm_81450D14(srcBlob, srcOffObj->value.int_v, &srcOff) != 0) {
|
||||
count = CHANSVm_81451314(srcBlob, countObj, srcOff);
|
||||
if (CHANSVmBlobResolveOffset(destBlob, destOffObj->value.int_v, &destOff) != 0 && CHANSVmBlobResolveOffset(srcBlob, srcOffObj->value.int_v, &srcOff) != 0) {
|
||||
count = CHANSVmBlobGetCount(srcBlob, countObj, srcOff);
|
||||
{
|
||||
u32 destinationOffset = destOff;
|
||||
okFlag = (s64)count >= 0 && (s64)(destBlob->size - destinationOffset) >= (s64)count;
|
||||
@@ -4213,9 +4213,9 @@ VmMethodDefine(Blob, GetBlob) {
|
||||
if (blob == vmNull)
|
||||
return 0;
|
||||
|
||||
count = blob != vmNull ? CHANSVm_81451314(blob, arg, blob->offset) : 0;
|
||||
count = blob != vmNull ? CHANSVmBlobGetCount(blob, arg, blob->offset) : 0;
|
||||
|
||||
if (CHANSVm_81451348(blob, count)) {
|
||||
if (CHANSVmBlobHasSpace(blob, count)) {
|
||||
if (CHANSVmNewBlobObject(VmInst, VmReturnObj, count, blob->offset + blob->pData, count) != vmNull) {
|
||||
blob->offset += count;
|
||||
return 1;
|
||||
@@ -4262,7 +4262,7 @@ VmMethodDefine(Blob, SetBlob) {
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANSVm_81451348(destBlob, logicalSize)) {
|
||||
if (CHANSVmBlobHasSpace(destBlob, logicalSize)) {
|
||||
memmove(destBlob->pData + *(u32*)&destBlob->offset, srcBlob->pData + srcBlob->offset, copySize);
|
||||
if (copySize < logicalSize) {
|
||||
memset(destBlob->offset + destBlob->pData + copySize, 0, logicalSize - copySize);
|
||||
@@ -4284,9 +4284,9 @@ VmMethodDefine(Blob, GetHexString) {
|
||||
return vmFalse;
|
||||
}
|
||||
|
||||
count = blob != vmNull ? CHANSVm_81451314(blob, arg, blob->offset) : 0;
|
||||
count = blob != vmNull ? CHANSVmBlobGetCount(blob, arg, blob->offset) : 0;
|
||||
|
||||
if (CHANSVm_81451348(blob, count) && CHANSVmNewObject(VmInst, vmFalse, VmReturnObj, CHANS_VM_OBJ_TYPE_STRING, count * 4) != vmNull) {
|
||||
if (CHANSVmBlobHasSpace(blob, count) && CHANSVmNewObject(VmInst, vmFalse, VmReturnObj, CHANS_VM_OBJ_TYPE_STRING, count * 4) != vmNull) {
|
||||
wchar_t* dest = (wchar_t*)VmGetStrFromObjHdr(VmReturnObj);
|
||||
u8* src = blob->pData;
|
||||
u32 offset = blob->offset;
|
||||
@@ -4352,8 +4352,8 @@ VmMethodDefine(Blob, CalcRangeSHA1Digest) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (CHANSVm_81450D14(blob, arg0->value.int_v, &offset) != 0) {
|
||||
size = CHANSVm_81451314(blob, arg1, offset);
|
||||
if (CHANSVmBlobResolveOffset(blob, arg0->value.int_v, &offset) != 0) {
|
||||
size = CHANSVmBlobGetCount(blob, arg1, offset);
|
||||
|
||||
{
|
||||
u32 off = offset;
|
||||
@@ -4417,8 +4417,8 @@ VmMethodDefine(Blob, CalcRangeMD5Digest) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (CHANSVm_81450D14(blob, arg0->value.int_v, &offset) != 0) {
|
||||
size = CHANSVm_81451314(blob, arg1, offset);
|
||||
if (CHANSVmBlobResolveOffset(blob, arg0->value.int_v, &offset) != 0) {
|
||||
size = CHANSVmBlobGetCount(blob, arg1, offset);
|
||||
|
||||
{
|
||||
u32 off = offset;
|
||||
@@ -4464,8 +4464,8 @@ VmMethodDefine(Blob, CalcRangeCRC16) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (CHANSVm_81450D14(blob, arg0->value.int_v, &offset) != 0) {
|
||||
size = CHANSVm_81451314(blob, arg1, offset);
|
||||
if (CHANSVmBlobResolveOffset(blob, arg0->value.int_v, &offset) != 0) {
|
||||
size = CHANSVmBlobGetCount(blob, arg1, offset);
|
||||
{
|
||||
u32 off = offset;
|
||||
if (((s64)size >= 0LL && (s64)(blob->size - off) >= (s64)size) != vmFalse) {
|
||||
@@ -4500,8 +4500,8 @@ VmMethodDefine(Blob, CalcRangeCRC32) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (CHANSVm_81450D14(blob, arg0->value.int_v, &offset) != 0) {
|
||||
size = CHANSVm_81451314(blob, arg1, offset);
|
||||
if (CHANSVmBlobResolveOffset(blob, arg0->value.int_v, &offset) != 0) {
|
||||
size = CHANSVmBlobGetCount(blob, arg1, offset);
|
||||
{
|
||||
u32 off = offset;
|
||||
|
||||
@@ -4573,8 +4573,8 @@ VmMethodDefine(Blob, CalcRangeHMAC) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (CHANSVm_81450D14(blob, arg0->value.int_v, &offset) != 0) {
|
||||
size = CHANSVm_81451314(blob, arg1, offset);
|
||||
if (CHANSVmBlobResolveOffset(blob, arg0->value.int_v, &offset) != 0) {
|
||||
size = CHANSVmBlobGetCount(blob, arg1, offset);
|
||||
off = offset;
|
||||
if (((s64)size >= 0LL && (s64)(blob->size - off) >= (s64)size) != vmFalse) {
|
||||
NETHMACContext ctx;
|
||||
@@ -5202,7 +5202,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
copySize = paramValue;
|
||||
}
|
||||
|
||||
if (copySize < 0 || !CHANSVm_81451348(parentBlob, copySize)) {
|
||||
if (copySize < 0 || !CHANSVmBlobHasSpace(parentBlob, copySize)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -5220,7 +5220,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if (paramValue < 0 || !CHANSVm_81451348(parentBlob, paramValue)) {
|
||||
if (paramValue < 0 || !CHANSVmBlobHasSpace(parentBlob, paramValue)) {
|
||||
goto error;
|
||||
}
|
||||
if (paramValue > 0) {
|
||||
@@ -5247,7 +5247,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!CHANSVm_81451348(parentBlob, elemSize * count)) {
|
||||
if (!CHANSVmBlobHasSpace(parentBlob, elemSize * count)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -5342,7 +5342,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
*(u64*)packBuf = CHANSVm_814540E0(packBuf[0], packBuf[1]);
|
||||
*(u64*)packBuf = CHANSVmMakeU64(packBuf[0], packBuf[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -5379,7 +5379,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!CHANSVm_81451348(parentBlob, elemSize * count)) {
|
||||
if (!CHANSVmBlobHasSpace(parentBlob, elemSize * count)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -5424,7 +5424,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
}
|
||||
|
||||
bufSize = (count + 1) / 2;
|
||||
if (!CHANSVm_81451348(parentBlob, bufSize)) {
|
||||
if (!CHANSVmBlobHasSpace(parentBlob, bufSize)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -5472,7 +5472,7 @@ error:
|
||||
return vmFalse;
|
||||
}
|
||||
|
||||
static u64 CHANSVm_814540E0(u32 upper, u32 lower) {
|
||||
static u64 CHANSVmMakeU64(u32 upper, u32 lower) {
|
||||
// Read U64 and byte-swap
|
||||
u64 x = (u64)upper << 32 | lower;
|
||||
return x >> 56 & 0x00000000000000ffULL | x >> 40 & 0x000000000000ff00ULL | x >> 24 & 0x0000000000ff0000ULL | x >> 8 & 0x00000000ff000000ULL |
|
||||
@@ -5648,7 +5648,7 @@ VmMethodDefine(Blob, Unpack) {
|
||||
} else {
|
||||
count = outVal;
|
||||
}
|
||||
if (count < 0 || !CHANSVm_81451348(srcBlob, count)) {
|
||||
if (count < 0 || !CHANSVmBlobHasSpace(srcBlob, count)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -5663,7 +5663,7 @@ VmMethodDefine(Blob, Unpack) {
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if (outVal < 0 || !CHANSVm_81451348(srcBlob, outVal)) {
|
||||
if (outVal < 0 || !CHANSVmBlobHasSpace(srcBlob, outVal)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -5682,7 +5682,7 @@ VmMethodDefine(Blob, Unpack) {
|
||||
} else {
|
||||
count = outVal;
|
||||
}
|
||||
if (count < 0 || !CHANSVm_81451348(srcBlob, outSize * count)) {
|
||||
if (count < 0 || !CHANSVmBlobHasSpace(srcBlob, outSize * count)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -5710,7 +5710,7 @@ VmMethodDefine(Blob, Unpack) {
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
unpackBuf.value = CHANSVm_814540E0(unpackBuf.words[0], unpackBuf.words[1]);
|
||||
unpackBuf.value = CHANSVmMakeU64(unpackBuf.words[0], unpackBuf.words[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -5794,7 +5794,7 @@ VmMethodDefine(Blob, Unpack) {
|
||||
}
|
||||
count = (srcBlob->size - srcBlob->offset) / outSize;
|
||||
}
|
||||
if ((s32)count < 0 || !CHANSVm_81451348(srcBlob, outSize * count)) {
|
||||
if ((s32)count < 0 || !CHANSVmBlobHasSpace(srcBlob, outSize * count)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -5845,7 +5845,7 @@ VmMethodDefine(Blob, Unpack) {
|
||||
}
|
||||
|
||||
bufSize = (s32)(count + 1) / 2;
|
||||
if (!CHANSVm_81451348(srcBlob, bufSize)) {
|
||||
if (!CHANSVmBlobHasSpace(srcBlob, bufSize)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -6466,7 +6466,7 @@ void CHANSConvertModuleOfsToPtr(CHANSVmModule* ptr) {
|
||||
VmOffsU32ToPtr((void**)&ptr->pLineTbl, ptr);
|
||||
}
|
||||
|
||||
static CHANSVmObjHdr* CHANSVm_81455654(CHANSVm* vm, s32 id) {
|
||||
static CHANSVmObjHdr* CHANSVmLookupScopedObject(CHANSVm* vm, s32 id) {
|
||||
CHANSVmObjHdr* data = vmNull;
|
||||
CHANSVmPrivate* pVm = (CHANSVmPrivate*)vm;
|
||||
CHANSVmExecutionCtx* ctx = pVm->pActiveCtx;
|
||||
@@ -6755,7 +6755,7 @@ static CHANSVmErr VmReturnWithValue(CHANSVm* vm, u32 val) {
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < pVm->pActiveCtx->pDbg->moduleCount; i++) {
|
||||
if (CHANSVmDeleteObject(vm, CHANSVm_81455654(vm, i)) != CHANS_VM_OK) {
|
||||
if (CHANSVmDeleteObject(vm, CHANSVmLookupScopedObject(vm, i)) != CHANS_VM_OK) {
|
||||
return CHANS_VM_ERR_RETURN;
|
||||
}
|
||||
}
|
||||
@@ -6873,7 +6873,7 @@ CHANSVmErr CHANSVmLinkModules(CHANSVm* vm, vmS32 unk0) {
|
||||
CHANSVmObjHdr* obj;
|
||||
if (idx >= module->moduleCount) {
|
||||
goto pass3_idx_err;
|
||||
} else if (obj = CHANSVm_81455654(vm, idx), obj == vmNull) {
|
||||
} else if (obj = CHANSVmLookupScopedObject(vm, idx), obj == vmNull) {
|
||||
goto pass3_obj_err;
|
||||
} else if (obj->type == CHANS_VM_OBJ_TYPE_BLANK) {
|
||||
goto pass3_success;
|
||||
@@ -7818,7 +7818,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
result = CHANS_VM_ERR_GET_PROPERTY_NAME;
|
||||
arrayIdx = 0;
|
||||
imm16Val = VM_READ_BE_U16(operandBuf, 0);
|
||||
foundObj = CHANSVm_81455654(vm, imm16Val);
|
||||
foundObj = CHANSVmLookupScopedObject(vm, imm16Val);
|
||||
accumulator = &pVm->accumulator;
|
||||
if (foundObj != vmNull && accumulator->type == CHANS_VM_OBJ_TYPE_INTEGER &&
|
||||
(computedAddr = accumulator->value.data.len, (u64)accumulator->value.int_v <= ~1U)) {
|
||||
@@ -7954,7 +7954,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
if (operandBuf == vmNull) {
|
||||
return CHANS_VM_ERR_CODE_RANGE;
|
||||
}
|
||||
foundObj = CHANSVm_81455654(vm, (VM_READ_BE_U16(operandBuf, 0)) & 0x1FFF);
|
||||
foundObj = CHANSVmLookupScopedObject(vm, (VM_READ_BE_U16(operandBuf, 0)) & 0x1FFF);
|
||||
result = VmDeleteCommon(vm, foundObj);
|
||||
break;
|
||||
}
|
||||
@@ -7982,12 +7982,12 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
imm16Val = (opcodeVal << 8 | operandBuf[1]) & 0x1FFF;
|
||||
switch (opcodeVal & CHANS_VM_OP_SYMBOL_STORE) {
|
||||
case 0: {
|
||||
foundObj = CHANSVm_81455654(vm, imm16Val);
|
||||
foundObj = CHANSVmLookupScopedObject(vm, imm16Val);
|
||||
result = VmStore(vm, &pVm->accumulator, foundObj);
|
||||
break;
|
||||
}
|
||||
case CHANS_VM_OP_SYMBOL_STORE: {
|
||||
foundObj = CHANSVm_81455654(vm, imm16Val);
|
||||
foundObj = CHANSVmLookupScopedObject(vm, imm16Val);
|
||||
result = VmStore(vm, foundObj, &pVm->accumulator);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ struct CardThreadState {
|
||||
|
||||
MEMAllocator sAllocator_;
|
||||
static CardThreadState* sThread;
|
||||
extern "C" void* CardSequence_813D2C8C();
|
||||
extern "C" void* cardThreadMain();
|
||||
static char sCardSlotName[3] = "AB";
|
||||
|
||||
FileInfo* getCardDirState() {
|
||||
@@ -68,7 +68,7 @@ long getCardLastCMDFCmdResult() {
|
||||
return sThread->completionResult;
|
||||
}
|
||||
|
||||
extern "C" s32 CardSequence_813D205C(u8 slot) {
|
||||
extern "C" s32 sendCardUnmountCmd(u8 slot) {
|
||||
sThread->sourceSlot = slot;
|
||||
sThread->lastCommand = 9;
|
||||
sThread->lastResult = -21;
|
||||
@@ -114,12 +114,12 @@ void sendCardDeleteCmd(u8 slot, s16 fileNo) {
|
||||
}
|
||||
|
||||
void sendCardThreadStopCmd() NO_INLINE {
|
||||
CardSequence_813D205C(0);
|
||||
CardSequence_813D205C(1);
|
||||
sendCardUnmountCmd(0);
|
||||
sendCardUnmountCmd(1);
|
||||
OSSendMessage(&sThread->requests, (OSMessage)0xB, 0);
|
||||
}
|
||||
|
||||
extern "C" void CardSequence_813D222C(u8 slot) {
|
||||
extern "C" void pollCardSlot(u8 slot) {
|
||||
s32 result;
|
||||
|
||||
if (sThread->valid == 1) {
|
||||
@@ -139,7 +139,7 @@ extern "C" void CardSequence_813D222C(u8 slot) {
|
||||
}
|
||||
}
|
||||
if (result == 0) {
|
||||
if (sThread->slots[slot].state > 2 && CardSequence_813D205C(slot)) {
|
||||
if (sThread->slots[slot].state > 2 && sendCardUnmountCmd(slot)) {
|
||||
sThread->slots[slot].changed = 0;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ done:
|
||||
return;
|
||||
}
|
||||
|
||||
extern "C" s32 CardSequence_813D233C(s32 result) {
|
||||
extern "C" s32 mapCardErrorCode(s32 result) {
|
||||
switch (result) {
|
||||
case 0:
|
||||
return 0;
|
||||
@@ -186,8 +186,8 @@ extern "C" s32 CardSequence_813D233C(s32 result) {
|
||||
void probeCard() {
|
||||
OSMessage message;
|
||||
|
||||
CardSequence_813D222C(0);
|
||||
CardSequence_813D222C(1);
|
||||
pollCardSlot(0);
|
||||
pollCardSlot(1);
|
||||
while (OSReceiveMessage(&sThread->responses, &message, 0)) {
|
||||
s16 slot = (s16)(((u32)message >> 16) & 1);
|
||||
s8 command = (u8)(u32)message;
|
||||
@@ -251,9 +251,9 @@ checkCommand:
|
||||
break;
|
||||
}
|
||||
|
||||
sThread->lastResult = CardSequence_813D233C((s8)(((u32)message << 16) >> 24));
|
||||
sThread->lastResult = mapCardErrorCode((s8)(((u32)message << 16) >> 24));
|
||||
if ((s8)(u8)(u32)message != 0 && (s8)(u8)(u32)message != 9) {
|
||||
sThread->completionResult = CardSequence_813D233C((s8)(((u32)message << 16) >> 24));
|
||||
sThread->completionResult = mapCardErrorCode((s8)(((u32)message << 16) >> 24));
|
||||
if (sThread->sourceSlot != (s16)(((u32)message >> 16) & 1)) {
|
||||
sThread->destinationFileNo = (u32)message >> 24;
|
||||
}
|
||||
@@ -302,7 +302,7 @@ void initCardThread() {
|
||||
|
||||
OSInitMessageQueue(&sThread->responses, sThread->responseMessages, 0x10);
|
||||
OSInitMessageQueue(&sThread->requests, sThread->requestMessages, 0x10);
|
||||
OSCreateThread(&sThread->thread, (void* (*)(void*))CardSequence_813D2C8C, 0,
|
||||
OSCreateThread(&sThread->thread, (void* (*)(void*))cardThreadMain, 0,
|
||||
sThread->stack + sizeof(sThread->stack), 0x8000, 0x11, 0);
|
||||
OSResumeThread(&sThread->thread);
|
||||
OSSendMessage(&sThread->requests, (OSMessage)10, 0);
|
||||
@@ -348,7 +348,7 @@ const char* getIconComment(u8 slot, s16 index) {
|
||||
return sThread->comments[slot][index];
|
||||
}
|
||||
|
||||
extern "C" void CardSequence_813D2A74(s32 slot, s32 index) {
|
||||
extern "C" void clearCardFileEntry(s32 slot, s32 index) {
|
||||
BOOL interrupts = OSDisableInterrupts();
|
||||
sThread->files[slot][index].fileNo = 0;
|
||||
sThread->files[slot][index].size = 0;
|
||||
@@ -360,7 +360,7 @@ extern "C" void CardSequence_813D2A74(s32 slot, s32 index) {
|
||||
OSRestoreInterrupts(interrupts);
|
||||
}
|
||||
|
||||
extern "C" void CardSequence_813D2B40(s32 slot) {
|
||||
extern "C" void refreshCardSlotInfo(s32 slot) {
|
||||
u16 memSize;
|
||||
u32 sectorSize;
|
||||
s32 freeBytes;
|
||||
@@ -391,12 +391,12 @@ extern "C" void CardSequence_813D2B40(s32 slot) {
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" s32 CardSequence_813D320C(s32 slot, s32 result);
|
||||
extern "C" s32 CardSequence_813D32A8(s32 slot, s32 state, s32 result);
|
||||
extern "C" void CardSequence_813D3380(s32 slot, s32 state, s32 fileNo);
|
||||
extern "C" void CardSequence_813D33D8(s32 slot);
|
||||
extern "C" s32 CardSequence_813D3424(s32 slot, s32 fileNo, CARDDir* dir);
|
||||
extern "C" void CardSequence_813D3D14(s32 slot, s16 fileNo, s32 command);
|
||||
extern "C" s32 handleCardMountResult(s32 slot, s32 result);
|
||||
extern "C" s32 reportCardThreadError(s32 slot, s32 state, s32 result);
|
||||
extern "C" void sendCardSlotState(s32 slot, s32 state, s32 fileNo);
|
||||
extern "C" void clearAllCardFileEntries(s32 slot);
|
||||
extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir);
|
||||
extern "C" void runCardMoveOrCopy(s32 slot, s16 fileNo, s32 command);
|
||||
|
||||
static inline void sendValidityResponse(u32 command, u32 valid) {
|
||||
union {
|
||||
@@ -408,7 +408,7 @@ static inline void sendValidityResponse(u32 command, u32 valid) {
|
||||
OSSendMessage(&sThread->responses, (OSMessage)reply.value, 1);
|
||||
}
|
||||
|
||||
extern "C" void* CardSequence_813D2C8C() {
|
||||
extern "C" void* cardThreadMain() {
|
||||
struct CardThreadLocals {
|
||||
u8 compareName[6];
|
||||
u32 message;
|
||||
@@ -455,7 +455,7 @@ loopStart:
|
||||
command = (local.message >> 14) & 4;
|
||||
result = CARDMount(slot, sThread->mountBuffers[command / 4], 0);
|
||||
if (result < 0) {
|
||||
result = CardSequence_813D320C(slot, result);
|
||||
result = handleCardMountResult(slot, result);
|
||||
if (result != 0) {
|
||||
goto mountContinue;
|
||||
}
|
||||
@@ -467,11 +467,11 @@ loopStart:
|
||||
}
|
||||
|
||||
mountContinue:
|
||||
CardSequence_813D33D8(slot);
|
||||
clearAllCardFileEntries(slot);
|
||||
for (file = 0; file < 0x7F; ++file) {
|
||||
result = __CARDGetStatusEx(slot, (s16)file, &local.mountDir);
|
||||
if (result < 0) {
|
||||
result = CardSequence_813D320C(slot, result);
|
||||
result = handleCardMountResult(slot, result);
|
||||
if (result != 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -496,16 +496,16 @@ loopStart:
|
||||
goto mountError;
|
||||
}
|
||||
} else {
|
||||
result = CardSequence_813D3424(slot, (s16)file, &local.mountDir);
|
||||
result = loadCardFileIcons(slot, (s16)file, &local.mountDir);
|
||||
if (result < 0) {
|
||||
goto mountError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CardSequence_813D2B40(slot);
|
||||
refreshCardSlotInfo(slot);
|
||||
sThread->mounted[command / 4] = 1;
|
||||
CardSequence_813D3380(slot, 0, 0);
|
||||
sendCardSlotState(slot, 0, 0);
|
||||
OSReport("Slot %c\n", sCardSlotName[slot]);
|
||||
for (listingFile = 0; listingFile < 0x7F; ++listingFile) {
|
||||
if (__CARDGetStatusEx(slot, (u16)listingFile, &local.listingDir) == 0) {
|
||||
@@ -519,30 +519,30 @@ loopStart:
|
||||
|
||||
mountError:
|
||||
OSReport("MountError\n");
|
||||
CardSequence_813D32A8(slot, 0, result);
|
||||
reportCardThreadError(slot, 0, result);
|
||||
break;
|
||||
}
|
||||
case 9:
|
||||
CardSequence_813D32A8((local.message >> 16) & 1, 9, -3);
|
||||
reportCardThreadError((local.message >> 16) & 1, 9, -3);
|
||||
break;
|
||||
case 1: {
|
||||
slot = (local.message >> 16) & 1;
|
||||
result = CARDFormat(slot);
|
||||
if (result < 0) {
|
||||
CardSequence_813D32A8(slot, 1, result);
|
||||
reportCardThreadError(slot, 1, result);
|
||||
} else {
|
||||
sThread->mounted[slot] = 1;
|
||||
CardSequence_813D2B40(slot);
|
||||
CardSequence_813D3380(slot, 1, 0);
|
||||
refreshCardSlotInfo(slot);
|
||||
sendCardSlotState(slot, 1, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
CardSequence_813D3D14((local.message >> 16) & 1,
|
||||
runCardMoveOrCopy((local.message >> 16) & 1,
|
||||
(s16)(u8)(local.message >> 24), (s8)command);
|
||||
break;
|
||||
case 3:
|
||||
CardSequence_813D3D14((local.message >> 16) & 1,
|
||||
runCardMoveOrCopy((local.message >> 16) & 1,
|
||||
(s16)(u8)(local.message >> 24), (s8)command);
|
||||
break;
|
||||
case 4: {
|
||||
@@ -550,11 +550,11 @@ loopStart:
|
||||
fileNo = (s16)(local.message >> 24);
|
||||
result = CARDFastDelete(slot, fileNo);
|
||||
if (result < 0) {
|
||||
CardSequence_813D32A8(slot, 4, result);
|
||||
reportCardThreadError(slot, 4, result);
|
||||
} else {
|
||||
CardSequence_813D2A74(slot, fileNo);
|
||||
CardSequence_813D2B40(slot);
|
||||
CardSequence_813D3380(slot, 4, (u8)fileNo);
|
||||
clearCardFileEntry(slot, fileNo);
|
||||
refreshCardSlotInfo(slot);
|
||||
sendCardSlotState(slot, 4, (u8)fileNo);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -581,7 +581,7 @@ loopStart:
|
||||
++outerSlot;
|
||||
|
||||
} while (outerSlot < 2);
|
||||
CardSequence_813D3380(0, 0xC, 0);
|
||||
sendCardSlotState(0, 0xC, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -593,9 +593,9 @@ loopCheck:
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" s32 CardSequence_813D3C38(s32 slot, s16 fileNo);
|
||||
extern "C" s32 checkCardFileDuplicate(s32 slot, s16 fileNo);
|
||||
|
||||
extern "C" void CardSequence_813D3140() {
|
||||
extern "C" void markAllCardFilesDirty() {
|
||||
u32 slot = 0;
|
||||
s32 fileNo;
|
||||
|
||||
@@ -607,7 +607,7 @@ extern "C" void CardSequence_813D3140() {
|
||||
sThread->files[slot][fileNo].unk_0x06 = 0;
|
||||
if (sThread->mounted[slot] != 0 &&
|
||||
sThread->mounted[slot ^ 1] != 0 &&
|
||||
CardSequence_813D3C38((u8)slot, (s16)fileNo) < 0) {
|
||||
checkCardFileDuplicate((u8)slot, (s16)fileNo) < 0) {
|
||||
sThread->files[slot][fileNo].unk_0x06 = flagValue;
|
||||
}
|
||||
++fileNo;
|
||||
@@ -618,7 +618,7 @@ extern "C" void CardSequence_813D3140() {
|
||||
} while ((s32)slot < 2);
|
||||
}
|
||||
|
||||
extern "C" s32 CardSequence_813D320C(s32 slot, s32 result) {
|
||||
extern "C" s32 handleCardMountResult(s32 slot, s32 result) {
|
||||
if (result == -5) {
|
||||
goto reportError;
|
||||
}
|
||||
@@ -640,32 +640,32 @@ repairedCard:
|
||||
{
|
||||
result = CARDCheck(slot);
|
||||
if (result < 0) {
|
||||
return CardSequence_813D32A8(slot, 0, result);
|
||||
return reportCardThreadError(slot, 0, result);
|
||||
}
|
||||
OSReport("CardThread:Broken Card Repaired\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
reportError:
|
||||
return CardSequence_813D32A8(slot, 0, result);
|
||||
return reportCardThreadError(slot, 0, result);
|
||||
}
|
||||
|
||||
extern "C" s32 CardSequence_813D32A8(s32 slot, s32 state, s32 result) {
|
||||
extern "C" s32 reportCardThreadError(s32 slot, s32 state, s32 result) {
|
||||
if (result != -7 && result != -27 && result != -8 && result != -9 &&
|
||||
(CardSequence_813D33D8(slot), result != -6) && result != -13) {
|
||||
(clearAllCardFileEntries(slot), result != -6) && result != -13) {
|
||||
OSReport("DEBUG: UnmountCard %d \n", slot);
|
||||
CARDUnmount(slot);
|
||||
sThread->mounted[slot & 0xFF] = 0;
|
||||
}
|
||||
OSReport("DEBUG: CardThread error %d %d\n", state, result);
|
||||
CardSequence_813D3140();
|
||||
markAllCardFilesDirty();
|
||||
OSSendMessage(&sThread->responses,
|
||||
(OSMessage)(((slot & 1) << 16) | ((result & 0xFF) << 8) | (state & 0xFF)), 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void CardSequence_813D3380(s32 slot, s32 state, s32 fileNo) {
|
||||
CardSequence_813D3140();
|
||||
extern "C" void sendCardSlotState(s32 slot, s32 state, s32 fileNo) {
|
||||
markAllCardFilesDirty();
|
||||
OSMessageQueue* queue = &sThread->responses;
|
||||
union CardThreadMessage {
|
||||
u32 value;
|
||||
@@ -683,15 +683,15 @@ extern "C" void CardSequence_813D3380(s32 slot, s32 state, s32 fileNo) {
|
||||
OSSendMessage(queue, (OSMessage)message.value, 1);
|
||||
}
|
||||
|
||||
extern "C" void CardSequence_813D33D8(s32 slot) {
|
||||
extern "C" void clearAllCardFileEntries(s32 slot) {
|
||||
s32 file = 0;
|
||||
do {
|
||||
CardSequence_813D2A74(slot, (s16)file);
|
||||
clearCardFileEntry(slot, (s16)file);
|
||||
file = file + 1;
|
||||
} while (file < 0x7F);
|
||||
}
|
||||
|
||||
extern "C" s32 CardSequence_813D3424(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
struct CardSequenceFileData {
|
||||
s32 commentSectorSize;
|
||||
s32 sectorSize;
|
||||
@@ -922,11 +922,11 @@ closeFileSuccess:
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void CardSequence_813D3C24(s32, s32) {
|
||||
extern "C" void clearCardWritePending(s32, s32) {
|
||||
sThread->writePending = 0;
|
||||
}
|
||||
|
||||
extern "C" s32 CardSequence_813D3C38(s32 slot, s16 fileNo) {
|
||||
extern "C" s32 checkCardFileDuplicate(s32 slot, s16 fileNo) {
|
||||
CARDDir sourceDir;
|
||||
CARDDir otherDir;
|
||||
s32 result = __CARDGetStatusEx(slot, fileNo, &sourceDir);
|
||||
@@ -950,7 +950,7 @@ extern "C" s32 CardSequence_813D3C38(s32 slot, s16 fileNo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void CardSequence_813D3D14(s32 slot, s16 fileNo, s32 command) {
|
||||
extern "C" void runCardMoveOrCopy(s32 slot, s16 fileNo, s32 command) {
|
||||
CARDDir createStatus;
|
||||
CARDDir checkedStatus;
|
||||
CARDDir ioStatus;
|
||||
@@ -970,10 +970,10 @@ extern "C" void CardSequence_813D3D14(s32 slot, s16 fileNo, s32 command) {
|
||||
s32 statusResult;
|
||||
s32 stage;
|
||||
|
||||
result = CardSequence_813D3C38(slot, fileNo);
|
||||
result = checkCardFileDuplicate(slot, fileNo);
|
||||
|
||||
if (result < 0) {
|
||||
CardSequence_813D32A8(slot, command, result);
|
||||
reportCardThreadError(slot, command, result);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@@ -999,7 +999,7 @@ sectorSizeCheck:
|
||||
goto sectorSizeDone;
|
||||
}
|
||||
sectorSizeError:
|
||||
CardSequence_813D32A8(slot, command, sectorError);
|
||||
reportCardThreadError(slot, command, sectorError);
|
||||
goto finish;
|
||||
sectorSizeDone:
|
||||
;
|
||||
@@ -1023,7 +1023,7 @@ sectorSizeDone:
|
||||
result = CARDGetResultCode(slot);
|
||||
}
|
||||
if (result < 0) {
|
||||
CardSequence_813D32A8(slot, command, result);
|
||||
reportCardThreadError(slot, command, result);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@@ -1056,7 +1056,7 @@ createDone:
|
||||
;
|
||||
}
|
||||
if (destinationFileNo < 0) {
|
||||
CardSequence_813D32A8(destinationSlot, command, destinationFileNo);
|
||||
reportCardThreadError(destinationSlot, command, destinationFileNo);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@@ -1099,7 +1099,7 @@ createDone:
|
||||
sThread->writePending = 1;
|
||||
ioResult = CARDWriteAsync(&sThread->destinationFile,
|
||||
sThread->transferBuffer, size, offset,
|
||||
CardSequence_813D3C24);
|
||||
clearCardWritePending);
|
||||
if (ioResult < 0) {
|
||||
goto copyIoFailure;
|
||||
}
|
||||
@@ -1176,7 +1176,7 @@ copyIoDone:
|
||||
}
|
||||
} else {
|
||||
metadataCopied = TRUE;
|
||||
result = CardSequence_813D3424(destinationSlot, destinationFileNo,
|
||||
result = loadCardFileIcons(destinationSlot, destinationFileNo,
|
||||
&sourceStatus);
|
||||
if (result < 0) {
|
||||
OSReport("Can't read icon for move dstfile\n");
|
||||
@@ -1214,7 +1214,7 @@ copyIoDone:
|
||||
s32 setResult = result;
|
||||
if (result == -3) {
|
||||
CARDFastDelete(slot, fileNo);
|
||||
CardSequence_813D2A74(slot, fileNo);
|
||||
clearCardFileEntry(slot, fileNo);
|
||||
} else {
|
||||
s32 restoreResult = __CARDSetStatusEx(slot, fileNo, &moveStatus);
|
||||
if (restoreResult < 0) {
|
||||
@@ -1227,13 +1227,13 @@ copyIoDone:
|
||||
stage = 3;
|
||||
result = CARDFastDelete(slot, fileNo);
|
||||
if (result >= 0) {
|
||||
CardSequence_813D2A74(slot, fileNo);
|
||||
clearCardFileEntry(slot, fileNo);
|
||||
stage = 4;
|
||||
result = __CARDGetStatusEx(destinationSlot,
|
||||
destinationFileNo, &moveStatus);
|
||||
if (result >= 0) {
|
||||
stage = 5;
|
||||
if ((result = CardSequence_813D3424(
|
||||
if ((result = loadCardFileIcons(
|
||||
destinationSlot, destinationFileNo, &moveStatus)) < 0) {
|
||||
goto moveStatusError;
|
||||
}
|
||||
@@ -1270,10 +1270,10 @@ moveStatusDone:
|
||||
}
|
||||
|
||||
if (result >= 0) {
|
||||
CardSequence_813D2B40(slot);
|
||||
CardSequence_813D2B40(destinationSlot);
|
||||
CardSequence_813D3380(slot, 0, fileNo & 0xFF);
|
||||
CardSequence_813D3380(destinationSlot, command, destinationFileNo & 0xFF);
|
||||
refreshCardSlotInfo(slot);
|
||||
refreshCardSlotInfo(destinationSlot);
|
||||
sendCardSlotState(slot, 0, fileNo & 0xFF);
|
||||
sendCardSlotState(destinationSlot, command, destinationFileNo & 0xFF);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@@ -1281,7 +1281,7 @@ cleanup:
|
||||
destinationSlot = slot ^ 1;
|
||||
result = CARDGetResultCode(destinationSlot);
|
||||
if (result < 0) {
|
||||
CardSequence_813D32A8(destinationSlot, command, result);
|
||||
reportCardThreadError(destinationSlot, command, result);
|
||||
} else {
|
||||
if (temporaryCreated && !metadataCopied) {
|
||||
CARDFastDelete(destinationSlot, destinationFileNo);
|
||||
@@ -1289,18 +1289,18 @@ cleanup:
|
||||
if (metadataCopied) {
|
||||
if (__CARDGetStatusEx(destinationSlot, destinationFileNo,
|
||||
&createStatus) == 0) {
|
||||
CardSequence_813D3424(destinationSlot, destinationFileNo, &createStatus);
|
||||
loadCardFileIcons(destinationSlot, destinationFileNo, &createStatus);
|
||||
}
|
||||
}
|
||||
CardSequence_813D2B40(destinationSlot);
|
||||
CardSequence_813D3380(destinationSlot, 0, fileNo & 0xFF);
|
||||
refreshCardSlotInfo(destinationSlot);
|
||||
sendCardSlotState(destinationSlot, 0, fileNo & 0xFF);
|
||||
}
|
||||
result = CARDGetResultCode(slot);
|
||||
if (result < 0) {
|
||||
CardSequence_813D32A8(slot, command, result);
|
||||
reportCardThreadError(slot, command, result);
|
||||
} else {
|
||||
CardSequence_813D2B40(slot);
|
||||
CardSequence_813D3380(slot, 0, fileNo & 0xFF);
|
||||
refreshCardSlotInfo(slot);
|
||||
sendCardSlotState(slot, 0, fileNo & 0xFF);
|
||||
}
|
||||
|
||||
finish:
|
||||
|
||||
Reference in New Issue
Block a user