Skip to content

Commit

Permalink
save 300 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Niko committed Feb 21, 2025
1 parent 6ddafd4 commit 1653671
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
6 changes: 3 additions & 3 deletions decompile/General/233/233_20_CS_LoadBoss.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ void DECOMP_CS_LoadBoss(struct BossCutsceneData* bcd)
if (bcd->vrmFile != 0)
{
// CTR vram file (body and head)
LOAD_AppendQueue(sdata->ptrBigfileCdPos_2, LT_VRAM, bcd->vrmFile+index, 0, 0);
DECOMP_LOAD_AppendQueue(sdata->ptrBigfileCdPos_2, LT_VRAM, bcd->vrmFile+index, 0, 0);
}
#endif

// skip null check
//if (bcd->bodyFile != 0)
{
// CTR Model File (body)
LOAD_AppendQueue(sdata->ptrBigfileCdPos_2, LT_DRAM, bcd->bodyFile+index, ptrDestination, 0);
DECOMP_LOAD_AppendQueue(sdata->ptrBigfileCdPos_2, LT_DRAM, bcd->bodyFile+index, ptrDestination, 0);
}

// CTR Model File (head)
LOAD_AppendQueue(sdata->ptrBigfileCdPos_2, LT_DRAM, bcd->headFile+index, 0, DECOMP_CS_LoadBossCallback);
DECOMP_LOAD_AppendQueue(sdata->ptrBigfileCdPos_2, LT_DRAM, bcd->headFile+index, 0, DECOMP_CS_LoadBossCallback);
}
6 changes: 5 additions & 1 deletion decompile/General/LOAD/LOAD_21_ReadFile.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include <common.h>

void* DECOMP_LOAD_ReadFile(struct BigHeader* bigfile, /*u_int loadType,*/ int subfileIndex, void *ptrDst, void * callback)
// same hack as AppendQueue, see notes there
#define DECOMP_LOAD_ReadFile(a,b,c,d) DECOMP_LOAD_ReadFile_ex(b,c,d)

void* DECOMP_LOAD_ReadFile_ex(/*struct BigHeader* bigfile, u_int loadType,*/ int subfileIndex, void *ptrDst, void * callback)
{
// param1 is the Pointer to CD position of BIGFILE

Expand All @@ -11,6 +14,7 @@ void* DECOMP_LOAD_ReadFile(struct BigHeader* bigfile, /*u_int loadType,*/ int su
DECOMP_CDSYS_SetMode_StreamData();

// get size and offset of subfile
struct BigHeader* bigfile = sdata->ptrBigfile1;
struct BigEntry* entry = BIG_GETENTRY(bigfile);
int eSize = entry[subfileIndex].size;
int eOffs = entry[subfileIndex].offset;
Expand Down
10 changes: 8 additions & 2 deletions decompile/General/LOAD/LOAD_34_AppendQueue.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include <common.h>

void DECOMP_LOAD_AppendQueue(int bigfile, int type, int fileIndex, void* destinationPtr, void (*callback)(struct LoadQueueSlot*))
// This is a wonderful hack that removes an unused parameter,
// which saves bytes everywhere, without needing to alter the game code,
// We need the 'bigfile' parameter to stay in the C code, just to keep
// the front-end looking similar to ghidra, for easy comparison purposes
#define DECOMP_LOAD_AppendQueue(a,b,c,d,e) DECOMP_LOAD_AppendQueue_ex(b,c,d,e)

void DECOMP_LOAD_AppendQueue_ex(/*int bigfile,*/ int type, int fileIndex, void* destinationPtr, void (*callback)(struct LoadQueueSlot*))
{
struct LoadQueueSlot* lqs;

Expand All @@ -10,7 +16,7 @@ void DECOMP_LOAD_AppendQueue(int bigfile, int type, int fileIndex, void* destina
#endif

lqs = &sdata->queueSlots[sdata->queueLength];
lqs->ptrBigfileCdPos = (struct BigHeader*)bigfile;
//lqs->ptrBigfileCdPos = (struct BigHeader*)bigfile;
lqs->flags = 0;
lqs->type = type;
lqs->subfileIndex = fileIndex;
Expand Down
20 changes: 18 additions & 2 deletions include/decomp_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,13 @@ void DECOMP_LOAD_Callback_Overlay_231(void);
void DECOMP_LOAD_Callback_Overlay_232(void);
void DECOMP_LOAD_Callback_Overlay_233(void);
void DECOMP_LOAD_ReadFileASyncCallback(CdlIntrResult result, uint8_t* unk);
void* DECOMP_LOAD_ReadFile(struct BigHeader* bigfile, /*u_int loadType,*/ int subfileIndex, void* destination, /*int *size,*/ void * callback);

// same hack as AppendQueue, see notes there
#define DECOMP_LOAD_ReadFile(a,b,c,d) DECOMP_LOAD_ReadFile_ex(b,c,d)
void* DECOMP_LOAD_ReadFile_ex(/*struct BigHeader* bigfile, u_int loadType,*/ int subfileIndex, void *ptrDst, void * callback);
// void* DECOMP_LOAD_ReadFile(struct BigHeader* bigfile, /*u_int loadType,*/ int subfileIndex, void* destination, /*int *size,*/ void * callback);


void* DECOMP_LOAD_VramFile(void* bigfilePtr, int subfileIndex /*, int* ptrDestination, int* size, int callbackOrFlags*/);
//void* DECOMP_LOAD_DramFile(void* bigfilePtr, int subfileIndex, int* ptrDestination, /*int* size,*/ int callbackOrFlags);
void* DECOMP_LOAD_ReadDirectory(char* filename);
Expand All @@ -296,7 +302,17 @@ int DECOMP_LOAD_HowlSectorChainEnd(void);
void DECOMP_LOAD_InitCD(void);
void DECOMP_LOAD_RunPtrMap(int origin, int* patchArr, int numPtrs); //1st param might be `struct Level*`, 2nd param might be `char*`
void DECOMP_LOAD_LangFile(int bigfilePtr, int lang);
void DECOMP_LOAD_AppendQueue(int bigfile, int type, int fileIndex, void* destinationPtr, void (*callback)(struct LoadQueueSlot*));


// This is a wonderful hack that removes an unused parameter,
// which saves bytes everywhere, without needing to alter the game code,
// We need the 'bigfile' parameter to stay in the C code, just to keep
// the front-end looking similar to ghidra, for easy comparison purposes
#define DECOMP_LOAD_AppendQueue(a,b,c,d,e) DECOMP_LOAD_AppendQueue_ex(b,c,d,e)
void DECOMP_LOAD_AppendQueue_ex(/*int bigfile,*/ int type, int fileIndex, void* destinationPtr, void (*callback)(struct LoadQueueSlot*));
// void DECOMP_LOAD_AppendQueue(int bigfile, int type, int fileIndex, void* destinationPtr, void (*callback)(struct LoadQueueSlot*));


void DECOMP_LOAD_NextQueuedFile(void);

void DECOMP_MainDB_OTMem(struct OTMem* otMem, u_int size);
Expand Down

0 comments on commit 1653671

Please sign in to comment.