Link CARDBios, Block, Unlock (from Prime)

ily primers

Co-Authored-By: Phillip Stephens <antidote.crk@gmail.com>
This commit is contained in:
HeartPiece 2023-02-10 20:59:00 +11:00
parent 5073bea397
commit e2a793a1c1
10 changed files with 1034 additions and 3227 deletions

View File

@ -75,7 +75,7 @@ include obj_files.mk
O_FILES := $(JSYSTEM) $(DOLPHIN) $(PLUGPROJECT) $(SYS) $(UTILITY)
ifeq ($(EPILOGUE_PROCESS),1)
E_FILES := $(AR_UNSCHEDULED) $(DSP_UNSCHEDULED) $(DVD_UNSCHEDULED) $(OS_UNSCHEDULED) $(PAD_UNSCHEDULED) $(SI_UNSCHEDULED) $(GBA_UNSCHEDULED)
E_FILES := $(AR_UNSCHEDULED) $(CARD_UNSCHEDULED) $(DSP_UNSCHEDULED) $(DVD_UNSCHEDULED) $(OS_UNSCHEDULED) $(PAD_UNSCHEDULED) $(SI_UNSCHEDULED) $(GBA_UNSCHEDULED)
endif
DEPENDS := $($(filter *.o,O_FILES):.o=.d)
DEPENDS += $($(filter *.o,E_FILES):.o=.d)

View File

@ -606,13 +606,13 @@ LIBS = [
{
"lib": "card",
"mw_version": "1.2.5e",
"cflags": "$cflags_base",
"cflags": "$cflags_base -str noreadonly",
"host": False,
"objects": [
"Dolphin/card/CARDBios",
"Dolphin/card/CARDUnlock",
["Dolphin/card/CARDBios", True],
["Dolphin/card/CARDUnlock", True],
"Dolphin/card/CARDRdwr",
"Dolphin/card/CARDBlock",
["Dolphin/card/CARDBlock", True],
"Dolphin/card/CARDDir",
"Dolphin/card/CARDCheck",
"Dolphin/card/CARDMount",

View File

@ -22,23 +22,23 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/targsupp.c">TRK_MINNOW_DOLPHIN/targsupp.c</a> | 326 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/gx/GXDisplayList.c">gx/GXDisplayList.c</a> | 647 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/Runtime/__init_cpp_exceptions.cpp">Runtime/__init_cpp_exceptions.cpp</a> | 659 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/Runtime/global_destructor_chain.c">Runtime/global_destructor_chain.c</a> | 965 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDNet.c">card/CARDNet.c</a> | 2505 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/mtx/mtxvec.c">mtx/mtxvec.c</a> | 3122 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDDir.c">card/CARDDir.c</a> | 4548 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/mslsupp.c">TRK_MINNOW_DOLPHIN/mslsupp.c</a> | 4555 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/CircleBuffer.c">TRK_MINNOW_DOLPHIN/CircleBuffer.c</a> | 4715 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/serpoll.c">TRK_MINNOW_DOLPHIN/serpoll.c</a> | 4793 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDRdwr.c">card/CARDRdwr.c</a> | 4881 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/dsp/dsp.c">dsp/dsp.c</a> | 4915 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/ar/arq.c">ar/arq.c</a> | 4946 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/mpc_7xx_603e.c">TRK_MINNOW_DOLPHIN/mpc_7xx_603e.c</a> | 5554 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/MSL_C/mem_funcs.c">MSL_C/mem_funcs.c</a> | 5682 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/mtx/mtx44.c">mtx/mtx44.c</a> | 5987 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/MSL_C/direct_io.c">MSL_C/direct_io.c</a> | 6259 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSMemory.c">os/OSMemory.c</a> | 6385 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSReboot.c">os/OSReboot.c</a> | 6397 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDWrite.c">card/CARDWrite.c</a> | 6434 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDCreate.c">card/CARDCreate.c</a> | 6611 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSResetSW.c">os/OSResetSW.c</a> | 6856 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSError.c">os/OSError.c</a> | 6937 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/gx/GXGeometry.c">gx/GXGeometry.c</a> | 6983 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDBlock.c">card/CARDBlock.c</a> | 7163 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/thp/THPAudio.c">thp/THPAudio.c</a> | 7974 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDBlock.c">card/CARDBlock.c</a> | 3467 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDDir.c">card/CARDDir.c</a> | 4548 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/mslsupp.c">TRK_MINNOW_DOLPHIN/mslsupp.c</a> | 4555 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/CircleBuffer.c">TRK_MINNOW_DOLPHIN/CircleBuffer.c</a> | 4715 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/serpoll.c">TRK_MINNOW_DOLPHIN/serpoll.c</a> | 4793 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDRdwr.c">card/CARDRdwr.c</a> | 4881 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/dsp/dsp.c">dsp/dsp.c</a> | 4915 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/ar/arq.c">ar/arq.c</a> | 4946 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/mpc_7xx_603e.c">TRK_MINNOW_DOLPHIN/mpc_7xx_603e.c</a> | 5554 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/MSL_C/mem_funcs.c">MSL_C/mem_funcs.c</a> | 5682 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/mtx/mtx44.c">mtx/mtx44.c</a> | 5987 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/MSL_C/direct_io.c">MSL_C/direct_io.c</a> | 6259 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSMemory.c">os/OSMemory.c</a> | 6385 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSReboot.c">os/OSReboot.c</a> | 6397 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDWrite.c">card/CARDWrite.c</a> | 6434 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDCreate.c">card/CARDCreate.c</a> | 6611 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSResetSW.c">os/OSResetSW.c</a> | 6856 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSError.c">os/OSError.c</a> | 6937 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/gx/GXGeometry.c">gx/GXGeometry.c</a> | 6983 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/thp/THPAudio.c">thp/THPAudio.c</a> | 7974 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSReset.c">os/OSReset.c</a> | 8122 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSTime.c">os/OSTime.c</a> | 8247 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDRead.c">card/CARDRead.c</a> | 8271 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/os/OSMutex.c">os/OSMutex.c</a> | 8303 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDOpen.c">card/CARDOpen.c</a> | 8692 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDStat.c">card/CARDStat.c</a> | 8905 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/dolphin_trk_glue.c">TRK_MINNOW_DOLPHIN/dolphin_trk_glue.c</a> | 10320 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/exi/EXIUart.c">exi/EXIUart.c</a> | 10329 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/dolphin_trk.c">TRK_MINNOW_DOLPHIN/dolphin_trk.c</a> | 11230 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/ar/ar.c">ar/ar.c</a> | 11920 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/MSL_C/alloc.c">MSL_C/alloc.c</a> | 12018 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/support.c">TRK_MINNOW_DOLPHIN/support.c</a> | 12046 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/gx/GXTransform.c">gx/GXTransform.c</a> | 12379 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDFormat.c">card/CARDFormat.c</a> | 13901 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/dolphin_trk.c">TRK_MINNOW_DOLPHIN/dolphin_trk.c</a> | 11230 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/card/CARDUnlock.c">card/CARDUnlock.c</a> | 11441 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/ar/ar.c">ar/ar.c</a> | 11920 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/MSL_C/alloc.c">MSL_C/alloc.c</a> | 12018 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/TRK_MINNOW_DOLPHIN/support.c">TRK_MINNOW_DOLPHIN/support.c</a> | 12046 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/Dolphin/gx/GXTransform.c">gx/GXTransform.c</a> | 12379 |
### <section id="JSystem">JSystem</section>
| File | Size (bytes) | File | Size (bytes) |

View File

@ -176,7 +176,7 @@ struct CARDDirectoryBlock {
struct CARDFatBlock {
u16 checkSum; // _00
u16 checkSumInv; // _02
s16 checkCode; // _04
u16 checkCode; // _04
u16 freeBlocks; // _06
u16 lastAllocBlock; // _08
u16 allocMap[0xFFB]; // _0A
@ -192,6 +192,14 @@ struct CARDMemoryCard {
CARDFatBlock blockAllocMapBackup; // _8000
};
// Struct for use in CARDUnlock.
typedef struct CARDDecodeParameters {
u8* inputAddr; // _00
u32 inputLength; // _04
u32 aramAddr; // _08
u8* outputAddr; // _0C
} CARDDecodeParameters;
// Enum for 'permission' in CARDDir.
typedef enum { FilePermPublic = 0x2, FilePermNoCopy = 0x4, FilePermNoMove = 0x8 } CARDFilePermissions;
@ -217,7 +225,7 @@ s32 CARDCheck(s32 channel);
s32 CARDCheckExAsync(s32 channel, s32* xferBytes, CARDCallback callback);
// CARD BIOS functions.
s32 CARDFreeBlocks(s32 channel, s32* byteNoteUsed, s32* filesNotUsed);
s32 CARDFreeBlocks(s32 channel, s32* byteNotUsed, s32* filesNotUsed);
// CARD mounting functions.
BOOL CARDProbe(s32 channel);
@ -269,17 +277,20 @@ void __CARDUnlockedHandler(s32 channel, OSContext* context);
s32 __CARDEnableInterrupt(s32 channel, BOOL enable);
s32 __CARDReadStatus(s32 channel, u8* status);
s32 __CARDClearStatus(s32 channel);
s32 __CARDStart(s32 channel, CARDCallback c8callback, CARDCallback doneWriteCallback);
s32 __CARDStart(s32 channel, CARDCallback txCallback, CARDCallback exiCallback);
s32 __CARDReadSegment(s32 channel, CARDCallback callback);
s32 __CARDWritePage(s32 channel, CARDCallback callback);
s32 __CARDEraseSector(s32 channel, u32 addr, CARDCallback callback);
u16 __CARDGetFontEncode();
void __CARDSetDiskID(u8* diskID);
void __CARDSetDiskID(const DVDDiskID* diskID);
s32 __CARDGetControlBlock(s32 channel, CARDControl** card);
s32 __CARDPutControlBlock(CARDControl* card, s32 result);
s32 __CARDSync(s32 channel);
void __CARDCheckSum(void* data, int length, u16* checksum, u16* checksumInv);
CARDDir* __CARDGetDirBlock(CARDControl* card);
CARDFatBlock* __CARDGetFatBlock(CARDControl* card);
////////////////////////////////////////////
//////////// OTHER CARD DEFINES ////////////

View File

@ -8,30 +8,24 @@
extern "C" {
#endif // ifdef __cplusplus
typedef unknown EXICallback(int slotIndex);
typedef enum { EXIResultMinusOne = -1, EXIResultZero = 0, EXIResultOne = 1 } EXIResult;
void EXIInit();
EXIResult EXIImm(int slotIndex, u8* p2, int byteCount, int p4, unknown p5);
EXIResult EXIImmEx(int slotIndex, u8* p2, int byteCount, int p4);
EXIResult EXIDma(int slotIndex, unknown p2, unknown p3, unknown p4, unknown p5);
EXIResult EXISync(int slotIndex);
EXIResult EXIClearInterrupts(int slotIndex, unknown p2, unknown p3, unknown p4);
EXICallback* EXISetExiCallback(int slotIndex, EXICallback* callback);
EXIResult EXIProbe(int slotIndex);
EXIResult EXIProbeEx(int slotIndex);
EXIResult EXIAttach(int slotIndex, unknown p2);
EXIResult EXIDetach(int slotIndex);
EXIResult EXISelect(int slotIndex, unknown p2, unknown p3);
EXIResult EXIDeselect(int slotIndex);
BOOL EXIImm(s32 channel, void* buffer, s32 length, u32 type, EXICallback callback);
BOOL EXIImmEx(s32 channel, void* buffer, s32 length, u32 type);
BOOL EXIDma(s32 channel, void* buffer, s32 length, u32 type, EXICallback callback);
BOOL EXISync(s32 channel);
BOOL EXIClearInterrupts(s32 channel, BOOL clearExiBit, BOOL clearTcBit, BOOL clearExtBit);
EXICallback EXISetExiCallback(s32 channel, EXICallback callback);
BOOL EXIAttach(s32 channel, EXICallback callback);
BOOL EXIDetach(s32 channel);
BOOL EXISelect(s32 channel, u32 device, u32 frequency);
BOOL EXIDeselect(s32 channel);
// sic
void EXIIntrruptHandler(unknown p1, OSContext* context);
EXIResult EXILock(int slotIndex, unknown p2, unknown p3);
EXIResult EXIUnlock(int slotIndex);
uint EXIGetState(int slotIndex);
EXIResult EXIGetID(int slotIndex, unknown p2, u8* p3);
void EXIIntrruptHandler(__OSInterrupt interrupt, OSContext* context);
BOOL EXILock(s32 channel, u32 device, EXICallback callback);
BOOL EXIUnlock(s32 channel);
u32 EXIGetState(s32 channel);
s32 EXIGetID(s32 channel, u32 device, u32* id);
#ifdef __cplusplus
};

File diff suppressed because it is too large Load Diff

View File

@ -1,94 +1,52 @@
#include "Dolphin/card.h"
void WriteCallback(int slotIndex, int p2);
void EraseCallback(int slotIndex, int p2);
void WriteCallback(s32 channel, s32 result);
void EraseCallback(s32 channel, s32 result);
s32 __CARDUpdateFatBlock(s32 channel, CARDFatBlock* fat, CARDCallback callback);
/*
* --INFO--
* Address: 800D6E00
* Size: 000008
*/
CARDFatBlock* __CARDGetFatBlock(CARDBlock* block)
{
return block->_088;
/*
.loc_0x0:
lwz r3, 0x88(r3)
blr
*/
}
CARDFatBlock* __CARDGetFatBlock(CARDControl* card) { return card->currentFat; }
/*
* --INFO--
* Address: 800D6E08
* Size: 0000D4
*/
void WriteCallback(int slotIndex, int p2)
void WriteCallback(s32 channel, s32 result)
{
/*
.loc_0x0:
mflr r0
stw r0, 0x4(r1)
stwu r1, -0x20(r1)
stw r31, 0x1C(r1)
stw r30, 0x18(r1)
mr. r30, r4
stw r29, 0x14(r1)
addi r29, r3, 0
mulli r5, r29, 0x110
lis r3, 0x804F
addi r0, r3, 0x5AF0
add r31, r0, r5
blt- .loc_0x78
lwz r3, 0x80(r31)
lwz r0, 0x88(r31)
addi r4, r3, 0x6000
cmplw r0, r4
addis r5, r3, 0x1
subi r5, r5, 0x8000
bne- .loc_0x64
stw r5, 0x88(r31)
addi r3, r5, 0
li r5, 0x2000
bl -0xD1CC8
b .loc_0x78
CARDControl* card;
CARDCallback callback;
CARDFatBlock* fat;
CARDFatBlock* fatBack;
.loc_0x64:
stw r4, 0x88(r31)
addi r3, r4, 0
addi r4, r5, 0
li r5, 0x2000
bl -0xD1CE0
card = &__CARDBlock[channel];
.loc_0x78:
lwz r0, 0xD0(r31)
cmplwi r0, 0
bne- .loc_0x90
addi r3, r31, 0
addi r4, r30, 0
bl -0x1810
if (result >= 0) {
fat = &card->workArea->blockAllocMap;
fatBack = &card->workArea->blockAllocMapBackup;
.loc_0x90:
lwz r0, 0xD8(r31)
cmplwi r0, 0
mr r12, r0
beq- .loc_0xB8
li r0, 0
mtlr r12
stw r0, 0xD8(r31)
addi r3, r29, 0
addi r4, r30, 0
blrl
if (card->currentFat == fat) {
card->currentFat = fatBack;
memcpy(fatBack, fat, 0x2000);
} else {
card->currentFat = fat;
memcpy(fat, fatBack, 0x2000);
}
}
.loc_0xB8:
lwz r0, 0x24(r1)
lwz r31, 0x1C(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
addi r1, r1, 0x20
mtlr r0
blr
*/
if (card->apiCallback == nullptr) {
__CARDPutControlBlock(card, result);
}
callback = card->eraseCallback;
if (callback) {
card->eraseCallback = nullptr;
callback(channel, result);
}
}
/*
@ -96,67 +54,37 @@ void WriteCallback(int slotIndex, int p2)
* Address: 800D6EDC
* Size: 0000C8
*/
void EraseCallback(int slotIndex, int p2)
void EraseCallback(s32 channel, s32 result)
{
/*
.loc_0x0:
mflr r0
stw r0, 0x4(r1)
stwu r1, -0x28(r1)
stw r31, 0x24(r1)
addi r31, r3, 0
lis r3, 0x804F
stw r30, 0x20(r1)
mulli r5, r31, 0x110
stw r29, 0x1C(r1)
addi r0, r3, 0x5AF0
mr. r29, r4
add r30, r0, r5
blt- .loc_0x6C
lwz r5, 0x88(r30)
lis r3, 0x800D
lwz r0, 0x80(r30)
addi r7, r3, 0x6E08
lwz r3, 0xC(r30)
sub r0, r5, r0
rlwinm r0,r0,19,13,31
mullw r4, r3, r0
addi r6, r5, 0
addi r3, r31, 0
li r5, 0x2000
bl -0x1A0
mr. r29, r3
bge- .loc_0xAC
CARDControl* card;
CARDCallback callback;
u32 temp[2]; /* this compiler sucks */
CARDFatBlock* fat;
u32 addr;
.loc_0x6C:
lwz r0, 0xD0(r30)
cmplwi r0, 0
bne- .loc_0x84
addi r3, r30, 0
addi r4, r29, 0
bl -0x18D8
card = &__CARDBlock[channel];
if (result < 0) {
goto error;
}
.loc_0x84:
lwz r0, 0xD8(r30)
cmplwi r0, 0
mr r12, r0
beq- .loc_0xAC
li r0, 0
mtlr r12
stw r0, 0xD8(r30)
addi r3, r31, 0
addi r4, r29, 0
blrl
fat = __CARDGetFatBlock(card);
addr = ((u32)fat - (u32)card->workArea) / CARD_SYSTEM_BLOCK_SIZE * card->sectorSize;
result = __CARDWrite(channel, addr, CARD_SYSTEM_BLOCK_SIZE, fat, WriteCallback);
if (result < 0) {
goto error;
}
.loc_0xAC:
lwz r0, 0x2C(r1)
lwz r31, 0x24(r1)
lwz r30, 0x20(r1)
lwz r29, 0x1C(r1)
addi r1, r1, 0x28
mtlr r0
blr
*/
return;
error:
if (card->apiCallback == nullptr) {
__CARDPutControlBlock(card, result);
}
callback = card->eraseCallback;
if (callback) {
card->eraseCallback = nullptr;
callback(channel, result);
}
}
/*
@ -164,114 +92,54 @@ void EraseCallback(int slotIndex, int p2)
* Address: 800D6FA4
* Size: 000118
*/
void __CARDAllocBlock(void)
s32 __CARDAllocBlock(s32 chan, u32 cBlock, CARDCallback callback)
{
/*
.loc_0x0:
mflr r0
mulli r7, r3, 0x110
stw r0, 0x4(r1)
stwu r1, -0x20(r1)
lis r6, 0x804F
addi r0, r6, 0x5AF0
stw r31, 0x1C(r1)
add r9, r0, r7
stw r30, 0x18(r1)
lwz r0, 0x0(r9)
cmpwi r0, 0
bne- .loc_0x38
li r3, -0x3
b .loc_0x100
CARDControl* card;
CARDFatBlock* fat;
u16 iBlock;
u16 startBlock;
u16 prevBlock;
u16 count;
.loc_0x38:
lwz r8, 0x88(r9)
lhz r0, 0x6(r8)
cmplw r0, r4
bge- .loc_0x50
li r3, -0x9
b .loc_0x100
card = &__CARDBlock[chan];
if (!card->attached) {
return CARD_RESULT_NOCARD;
}
.loc_0x50:
sub r0, r0, r4
sth r0, 0x6(r8)
lis r6, 0x1
subi r12, r6, 0x1
lhz r11, 0x8(r8)
addi r0, r12, 0
li r30, 0
b .loc_0xE8
fat = __CARDGetFatBlock(card);
if (fat->freeBlocks < cBlock) {
return CARD_RESULT_INSSPACE;
}
.loc_0x70:
lhz r10, 0x10(r9)
addi r30, r30, 0x1
rlwinm r6,r30,0,16,31
subi r7, r10, 0x5
cmpw r7, r6
bge- .loc_0x90
li r3, -0x6
b .loc_0x100
fat->freeBlocks -= cBlock;
startBlock = 0xFFFF;
iBlock = fat->lastAllocBlock;
count = 0;
while (0 < cBlock) {
if (card->cBlock - 5 < ++count) {
return CARD_RESULT_BROKEN;
}
.loc_0x90:
addi r11, r11, 0x1
rlwinm r6,r11,0,16,31
cmplwi r6, 0x5
blt- .loc_0xA8
cmplw r6, r10
blt- .loc_0xAC
iBlock++;
if (!CARDIsValidBlockNo(card, iBlock)) {
iBlock = 5;
}
.loc_0xA8:
li r11, 0x5
if (((u16*)fat)[iBlock] == 0x0000u) {
if (startBlock == 0xFFFF) {
startBlock = iBlock;
} else {
((u16*)fat)[prevBlock] = iBlock;
}
prevBlock = iBlock;
((u16*)fat)[iBlock] = 0xFFFF;
--cBlock;
}
}
fat->lastAllocBlock = iBlock;
card->startBlock = startBlock;
.loc_0xAC:
rlwinm r6,r11,1,15,30
add r7, r8, r6
lhz r6, 0x0(r7)
cmplwi r6, 0
bne- .loc_0xE8
rlwinm r6,r12,0,16,31
cmplwi r6, 0xFFFF
bne- .loc_0xD4
mr r12, r11
b .loc_0xDC
.loc_0xD4:
rlwinm r6,r31,1,15,30
sthx r11, r8, r6
.loc_0xDC:
sth r0, 0x0(r7)
addi r31, r11, 0
subi r4, r4, 0x1
.loc_0xE8:
cmplwi r4, 0
bne+ .loc_0x70
sth r11, 0x8(r8)
mr r4, r8
sth r12, 0xBE(r9)
bl .loc_0x118
.loc_0x100:
lwz r0, 0x24(r1)
lwz r31, 0x1C(r1)
lwz r30, 0x18(r1)
addi r1, r1, 0x20
mtlr r0
blr
.loc_0x118:
*/
}
/*
* --INFO--
* Address: ........
* Size: 00009C
*/
// void __CARDFreeBlock(int slotIndex, CARDFatBlock* fatBlock, CARDBlockD8Callback* d8Callback)
void __CARDFreeBlock(void)
{
// UNUSED FUNCTION
return __CARDUpdateFatBlock(chan, fat, callback);
}
/*
@ -279,61 +147,15 @@ void __CARDFreeBlock(void)
* Address: 800D70BC
* Size: 0000AC
*/
void __CARDUpdateFatBlock(int slotIndex, CARDFatBlock* fatBlock, CARDBlockD8Callback* d8Callback)
s32 __CARDUpdateFatBlock(s32 channel, CARDFatBlock* fat, CARDCallback callback)
{
fatBlock->updateCounter++;
// __CARDFreeBlock(slotIndex, fatBlock, d8Callback);
// TODO: The rest of the func may go in __CARDFreeBlock?:
CARDBlock* block = &__CARDBlock[slotIndex];
__CARDCheckSum(&fatBlock->updateCounter, 0x1FFC, &fatBlock->checksum1, &fatBlock->checksum2);
DCStoreRange(&fatBlock, 0x2000);
block->_0D8 = d8Callback;
__CARDEraseSector(slotIndex, ((int)fatBlock - (int)block->_080) >> 0xD, EraseCallback);
CARDControl* card;
/*
.loc_0x0:
mflr r0
stw r0, 0x4(r1)
stwu r1, -0x28(r1)
stw r31, 0x24(r1)
stw r30, 0x20(r1)
addi r30, r5, 0
stw r29, 0x1C(r1)
addi r29, r4, 0
addi r5, r29, 0
stw r28, 0x18(r1)
addi r28, r3, 0
addi r6, r29, 0x2
lhz r3, 0x4(r4)
mulli r4, r28, 0x110
addi r0, r3, 0x1
lis r3, 0x804F
sth r0, 0x4(r29)
addi r0, r3, 0x5AF0
add r31, r0, r4
addi r3, r29, 0x4
li r4, 0x1FFC
bl 0x2BC
addi r3, r29, 0
li r4, 0x2000
bl 0x1562C
stw r30, 0xD8(r31)
lis r3, 0x800D
addi r5, r3, 0x6EDC
lwz r0, 0x80(r31)
mr r3, r28
lwz r4, 0xC(r31)
sub r0, r29, r0
rlwinm r0,r0,19,13,31
mullw r4, r4, r0
bl -0x1D44
lwz r0, 0x2C(r1)
lwz r31, 0x24(r1)
lwz r30, 0x20(r1)
lwz r29, 0x1C(r1)
lwz r28, 0x18(r1)
addi r1, r1, 0x28
mtlr r0
blr
*/
card = &__CARDBlock[channel];
++fat->checkCode;
__CARDCheckSum(&fat->checkCode, 0x1FFC, &fat->checkSum, &fat->checkSumInv);
DCStoreRange(fat, 0x2000);
card->eraseCallback = callback;
return __CARDEraseSector(channel, (((u32)fat - (u32)card->workArea) / CARD_SYSTEM_BLOCK_SIZE) * card->sectorSize, EraseCallback);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
CARD_FILES:=\
$(BUILD_DIR)/asm/Dolphin/card/CARDBios.o\
$(BUILD_DIR)/asm/Dolphin/card/CARDUnlock.o\
$(BUILD_DIR)/src/Dolphin/card/CARDBios.o\
$(BUILD_DIR)/src/Dolphin/card/CARDUnlock.o\
$(BUILD_DIR)/asm/Dolphin/card/CARDRdwr.o\
$(BUILD_DIR)/asm/Dolphin/card/CARDBlock.o\
$(BUILD_DIR)/src/Dolphin/card/CARDBlock.o\
$(BUILD_DIR)/asm/Dolphin/card/CARDDir.o\
$(BUILD_DIR)/asm/Dolphin/card/CARDCheck.o\
$(BUILD_DIR)/asm/Dolphin/card/CARDMount.o\
@ -14,12 +14,18 @@ CARD_FILES:=\
$(BUILD_DIR)/asm/Dolphin/card/CARDStat.o\
$(BUILD_DIR)/asm/Dolphin/card/CARDNet.o\
$(CARD_FILES): CFLAGS += -common off
CARD_UNSCHEDULED:=\
$(EPILOGUE_DIR)/src/Dolphin/card/CARDBios.o\
$(EPILOGUE_DIR)/src/Dolphin/card/CARDUnlock.o\
$(EPILOGUE_DIR)/src/Dolphin/card/CARDBlock.o\
$(CARD_FILES): CFLAGS += -common off -str noreadonly
$(CARD_UNSCHEDULED): CFLAGS += -common off -str noreadonly
$(CARD_FILES): MWCC_VERSION := 1.2.5
DEPENDS += $(CARD_FILES:.o=.d)
$(BUILD_DIR)/src/Dolphin/card/card.a: $(CARD_FILES)
$(BUILD_DIR)/src/Dolphin/card/card.a: $(CARD_FILES) $(CARD_UNSCHEDULED)
@echo Linking... $@
$(QUIET) mkdir -p $(dir $@)
@echo $(CARD_FILES) > build/CARD_ofiles

View File

@ -413,3 +413,9 @@ You have 2106 out of 10000 Pokos and 65 out of 201 treasures.",2023-02-09 17:23:
You have 2108 out of 10000 Pokos and 65 out of 201 treasures.",2023-02-10 17:20:40.077904
2123,987700,0.21230121882437097,65,233439,0.3274700640802631,"
You have 2123 out of 10000 Pokos and 65 out of 201 treasures.",2023-02-10 18:06:14.749861
2133,992488,0.2133303756895437,66,234107,0.32840713973088537,"
You have 2133 out of 10000 Pokos and 66 out of 201 treasures.",2023-02-10 19:42:02.361518
2135,993360,0.21351780776691015,66,234107,0.32840713973088537,"
You have 2135 out of 10000 Pokos and 66 out of 201 treasures.",2023-02-10 20:19:08.932554
2145,998064,0.21452890924848333,66,234463,0.3289065393291212,"
You have 2145 out of 10000 Pokos and 66 out of 201 treasures.",2023-02-10 20:54:10.658806

1 code_count_in_pokos code_completion_in_bytes code_completion_in_percentage data_count_in_treasures data_completion_in_bytes data_completion_in_percentage sentence created_at
413
414
415
416
417
418
419
420
421