summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkipcode66 <egamer1010@gmail.com>2021-05-17 18:10:27 -0400
committerkipcode66 <egamer1010@gmail.com>2021-05-17 18:10:27 -0400
commitb00815edfecf4db501ad2b8ac559f5f4b484d7fa (patch)
tree0ab6f30de0c4bb7cf135ddf596a07bd506cac98a
parent39de3392c3b6f5d79d9abc50a92f711d4d24d72d (diff)
__CARDGetFileNo optimization
-rw-r--r--include/card_internal.h1
-rw-r--r--src/card.c18
2 files changed, 6 insertions, 13 deletions
diff --git a/include/card_internal.h b/include/card_internal.h
index cdd1e5a..237ac1d 100644
--- a/include/card_internal.h
+++ b/include/card_internal.h
@@ -22,5 +22,6 @@ int32_t __CARDSync(int32_t chn);
int32_t __CARDUpdateFatBlock(int32_t chn, void* fatBlock, CARDCallback callback);
void* __CARDGetDirBlock(void* card);
int32_t __CARDUpdateDir(int32_t chn, CARDCallback callback);
+int32_t __CARDAccess(void* card, void* dirBlock);
#endif // __CARD_INTERNAL_H__ \ No newline at end of file
diff --git a/src/card.c b/src/card.c
index 68d2489..616e433 100644
--- a/src/card.c
+++ b/src/card.c
@@ -72,21 +72,13 @@ int32_t __CARDGetFileNo(void* card, const char* fileName, int32_t* fileNo) {
uint32_t dirBlock = (uint32_t)(__CARDGetDirBlock(card));
int32_t i;
- for (i = 0; i < 127; i++) {
+ for (i = 0; i < 127; i++)
+ {
uint8_t* currentDirBlock = (uint8_t*)(dirBlock + (i * 0x40));
- uint8_t* gameCode = &currentDirBlock[0];
+ const char* currentFileName = (const char*)(&currentDirBlock[0x8]);
- if (gameCode[0] != 0xFF) {
- const char* currentFileName = (const char*)(&currentDirBlock[0x8]);
- if (strcmp(fileName, currentFileName) == 0) {
- if (((cardDiskGameCode[0] != 0xFF) &&
- (memcmp(&gameCode[0], &cardDiskGameCode[0], 4) != 0)) ||
- ((cardDiskGameCode[0x4] != 0xFF) &&
- (memcmp(&gameCode[0x4], &cardDiskGameCode[0x4], 2) != 0)))
- {
- continue;
- }
-
+ if (strncmp(fileName, currentFileName, 32) == 0) {
+ if (__CARDAccess(card, currentDirBlock) >= CARD_RESULT_READY) {
*fileNo = i;
break;
}