Attempt to decompile pakWriteFile

This commit is contained in:
Ryan Dwyer committed 2021-09-21 22:29:35 +10:00
1 parent b602a01091
commit 35b445f3d1
11 files changed
+541 -359

No files matched your search

+2 -2
View File
@@ -3540,10 +3540,10 @@ u8 func1018_safe_switch[] = {
unset_object_flag2(OBJ_FLIGHTPLANS, OBJFLAG2_INVISIBLE)
unset_object_flag(OBJ_FLIGHTPLANS, OBJFLAG_UNCOLLECTABLE)
set_object_flag(OBJ_FLIGHTPLANS, OBJFLAG_COLLECTABLE)
set_object_flag2(OBJ_FLIGHTPLANS, OBJFLAG2_00001000)
set_object_flag2(OBJ_FLIGHTPLANS, OBJFLAG2_PICKUPWITHOUTLOS)
// 0x32 = a shield
set_object_flag2(0x34, OBJFLAG2_00001000)
set_object_flag2(0x34, OBJFLAG2_PICKUPWITHOUTLOS)
unset_object_flag(0x34, OBJFLAG_UNCOLLECTABLE)
// 0x32 = invalid object
+2 -2
View File
@@ -1336,8 +1336,8 @@ u8 func1009_weaponscache[] = {
unset_object_flag2(OBJ_CMP150_1, OBJFLAG2_INVISIBLE)
unset_object_flag(OBJ_CMP150_2, OBJFLAG_UNCOLLECTABLE)
unset_object_flag2(OBJ_CMP150_2, OBJFLAG2_INVISIBLE)
set_object_flag2(OBJ_CMP150_1, OBJFLAG2_00001000)
set_object_flag2(OBJ_CMP150_2, OBJFLAG2_00001000)
set_object_flag2(OBJ_CMP150_1, OBJFLAG2_PICKUPWITHOUTLOS)
set_object_flag2(OBJ_CMP150_2, OBJFLAG2_PICKUPWITHOUTLOS)
set_ailist(CHR_SELF, GAILIST_IDLE)
label(0x2f)
+1 -1
View File
@@ -2467,7 +2467,7 @@ glabel var7f1b8ea8
// if (sp3c) {
// dprint();
//
// if ((obj->flags2 & OBJFLAG2_00001000) == 0
// if ((obj->flags2 & OBJFLAG2_PICKUPWITHOUTLOS) == 0
// && !func0002dcd0(&chrprop->pos, chrprop->rooms, &prop->pos, prop->rooms, 0x22)) {
// sp3c = false;
// }
+2 -2
View File
@@ -655,7 +655,7 @@ glabel var7f1b1f44nc
/* f1627e4: 10400008 */ beqz $v0,.NB0f162808
/* f1627e8: 3c057f1b */ lui $a1,0x7f1b
/* f1627ec: 24a51e20 */ addiu $a1,$a1,0x1e20
/* f1627f0: 0c00581b */ jal joy000150e8
/* f1627f0: 0c00581b */ jal joyGetLock
/* f1627f4: 240402f8 */ addiu $a0,$zero,0x2f8
/* f1627f8: 3c11800a */ lui $s1,0x800a
/* f1627fc: 2631e6c0 */ addiu $s1,$s1,-6464
@@ -8571,7 +8571,7 @@ glabel lvTick
/* f166774: 14400004 */ bnez $v0,.NB0f166788
/* f166778: 24040cce */ addiu $a0,$zero,0xcce
/* f16677c: 3c057f1b */ lui $a1,0x7f1b
/* f166780: 0c005834 */ jal joy00015144
/* f166780: 0c005834 */ jal joyReleaseLock
/* f166784: 24a51e98 */ addiu $a1,$a1,0x1e98
.NB0f166788:
/* f166788: 8e8204b4 */ lw $v0,0x4b4($s4)
+478 -299
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -62653,7 +62653,7 @@ s32 objTestForPickup(struct prop *prop)
}
if (pickup
&& (obj->flags2 & OBJFLAG2_00001000) == 0
&& (obj->flags2 & OBJFLAG2_PICKUPWITHOUTLOS) == 0
&& !usebigrange
&& hasLineOfSight(&playerprop->pos, playerprop->rooms, &prop->pos, prop->rooms, 0x22, 0x1c) == 0) {
pickup = false;
+1 -1
View File
@@ -2843,7 +2843,7 @@
#define OBJFLAG2_00000200 0x00000200 // Editor: "Mines"
#define OBJFLAG2_LINKEDTOSAFE 0x00000400 // Applied to safe door and item
#define OBJFLAG2_INTERACTCHECKLOS 0x00000800 // Check line of sight when attempting to interact with object
#define OBJFLAG2_00001000 0x00001000 // Investigation CMP150s, Air Base safe item and shield
#define OBJFLAG2_PICKUPWITHOUTLOS 0x00001000 // Object can be picked up without having line of sight
#define OBJFLAG2_00002000 0x00002000 // Ruins commhub - used as a "shown message" flag
#define OBJFLAG2_IMMUNETOGUNFIRE 0x00004000
#define OBJFLAG2_SHOOTTHROUGH 0x00008000
+13 -13
View File
@@ -4,10 +4,10 @@
#include "data.h"
#include "types.h"
u32 pakGetAlignment(s8 device);
u32 pakGetBlockSize(s8 device);
u32 pakAlign(s8 device, u32 size);
s32 pakGetAlignedFileLenByBodyLen(s8 device, s32 bodylen);
u32 pak0f116684(u32 filelen);
u32 pakGetBodyLenByFileLen(u32 filelen);
u32 pakGenerateSerial(s8 device);
bool pakIsConnected(s8 device);
s32 pak0f1167b0(s8 device, u32 filetype, u32 *buffer1024);
@@ -32,7 +32,7 @@ s32 pak0f116df0(s8 device, struct pakdata **arg1);
s32 pakDeleteGameNote2(s8 device, u16 company_code, u32 game_code, char *game_name, char *ext_name);
s32 pakDeleteFile2(s8 device, s32 fileid);
s32 pakGetUnk264(s8 device);
u32 pak0f11706c(s8 device);
u32 pakGetMaxFileSize(s8 device);
s32 pakGetBodyLenByType(s8 device, u32 filetype);
void pak0f117150(s8 device, u8 *ptr);
void pak0f1171b4(s8 device, s32 arg1, s32 arg2);
@@ -49,7 +49,7 @@ s32 pakInitPak(OSMesgQueue *mq, OSPfs *pfs, s32 channel, s32 *arg3);
s32 pakInitPak(OSMesgQueue *mq, OSPfs *pfs, s32 channel);
#endif
s32 pakReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, u32 address, u32 len, u8 *buffer);
s32 _pakReadWriteBlock(OSPfs *pfs, s32 file_no, u8 flag, u32 address, u32 len, u8 *buffer);
s32 pak0f117c0c(s32 arg0, s32 *arg1, s32 *arg2);
s32 pakFreeBlocks(OSPfs *pfs, s32 *bytes_not_used);
s32 pakFileState(OSPfs *pfs, s32 file_no, OSPfsState *note);
@@ -57,15 +57,15 @@ s32 pakAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name
u32 pakDeleteGameNote3(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name);
s32 pakFindNote(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name, s32 *file_no);
s32 pak0f117ec0(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, u32 numbytes);
s32 pakGetUnk2a8(s8 device);
u32 pakGetNoteLen(s8 device);
s32 pakGetNumPages(s8 device);
u32 pakGetNumBytes(s8 device);
s32 pak0f118000(s8 device);
s32 pak0f11807c(s8 device);
s32 pak0f118148(s8 device);
s32 pak0f118230(s8 device, s32 arg1);
s32 pak0f118230(s8 device, u8 *olddata);
s32 pak0f118334(s8 device, s32 numpages);
void pak0f1185e0(s8 device, s32 arg1, s32 param_3);
u32 pak0f118674(s8 arg0, u32 arg1, u32 arg2);
u32 pak0f118674(s8 device, u32 filetype, u8 *olddata);
void pakInitAll(void);
void pakCalculateChecksum(u8 *arg0, u8 *arg1, u16 *arg2);
s32 pak0f118bc8(s8 device, s32 fileid, u8 *body, s32 arg3);
@@ -75,7 +75,7 @@ u32 pak0f119298(s8 device);
void pak0f119340(u32 arg0);
s32 pakFindFile(s8 device, u32 fileid, struct pakfileheader *header);
#if VERSION >= VERSION_NTSC_FINAL
bool pak0f119478(u32 arg0, u32 arg1, u32 *arg2);
bool pakWriteBlankFile(u32 device, u32 offset, struct pakfileheader *header);
#endif
bool pakRepairAsBlank(s8 device, u32 *arg1, struct pakfileheader *header);
u32 pak0f11970c(void);
@@ -86,19 +86,19 @@ u32 pak0f11a1d0(void);
void pak0f11a2e4(void);
void pak0f11a32c(s8 device, u8 arg1, u32 line, char *file);
void pakInit(s8 arg0);
s32 pak0f11a504(s8 device, OSPfs *pfs, s32 file_no, u8 flag, u32 address, u32 len, u8 *buffer);
s32 pakReadWriteBlock(s8 device, OSPfs *pfs, s32 file_no, u8 flag, u32 address, u32 len, u8 *buffer);
s32 pak0f11a574(s8 device);
u32 pak0f11a7dc(void);
u32 pak0f11a8f4(void);
u32 pak0f11ac7c(void);
void pakWipe(s8 device, u32 start, u32 end);
void pakSaveHeaderToCache(s8 device, s32 alignmult, struct pakfileheader *header);
bool pakRetrieveHeaderFromCache(s8 device, s32 alignmult, struct pakfileheader *header);
void pakSaveHeaderToCache(s8 device, s32 blocknum, struct pakfileheader *header);
bool pakRetrieveHeaderFromCache(s8 device, s32 blocknum, struct pakfileheader *header);
s32 pakScrub(s8 device);
bool pak0f11b75c(s8 device, u32 *arg1);
s32 pak0f11b86c(s32 device, u32 uVar2, u8 *data, struct pakfileheader *header, s32 arg3);
u32 pak0f11bbd8(void);
s32 pak0f11bc54(s8 device, s32 arg1, s32 filetype, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8);
s32 pakWriteFile(s8 device, u32 offset, s32 filetype, u8 *newdata, s32 bodylen, s32 *outfileid, u8 *olddata, u32 fileid, u32 arg8);
bool pakRepair(s8 device);
bool pakHandleResult(s32 result, s8 device, u32 arg2, u32 arg3);
void pak0f11c54c(void);
+4 -4
View File
@@ -40,11 +40,11 @@ u16 joyGetButtonsPressedThisFrame(s8 contpadnum, u16 mask);
s32 joy000150c4(void);
#if VERSION >= VERSION_NTSC_1_0
void joy000150e8(void);
void joy00015144(void);
void joyGetLock(void);
void joyReleaseLock(void);
#else
void joy000150e8(s32 line, char *file);
void joy00015144(s32 line, char *file);
void joyGetLock(s32 line, char *file);
void joyReleaseLock(s32 line, char *file);
#endif
void joyReset(void);
+21 -18
View File
@@ -5026,7 +5026,7 @@ struct pakdata {
};
struct pakheadercache {
s32 alignmult;
s32 blocknum;
u8 payload[0x20];
};
@@ -5038,7 +5038,7 @@ struct pak {
/*0x010*/ u32 unk010;
/*0x014*/ u8 unk014;
/*0x018*/ struct pakdata pakdata;
/*0x25c*/ u32 unk25c;
/*0x25c*/ u32 nextfileid;
/*0x260*/ u32 serial;
/*0x264*/ u32 unk264;
/*0x268*/ u32 unk268;
@@ -5055,9 +5055,9 @@ struct pak {
/*0x294*/ u32 unk294;
/*0x298*/ u32 unk298;
/*0x29c*/ s32 noteindex;
/*0x2a0*/ u32 notelen;
/*0x2a4*/ u32 unk2a4;
/*0x2a8*/ u32 unk2a8;
/*0x2a0*/ u32 numbytes;
/*0x2a4*/ u32 numblocks;
/*0x2a8*/ u32 numpages;
/*0x2ac*/ u32 unk2ac;
/*0x2b0*/ u32 unk2b0;
/*0x2b4*/ f32 unk2b4;
@@ -6685,19 +6685,22 @@ struct pakthing {
};
struct pakfileheader {
u16 headersum1; // checksum from filetype to end of header
u16 headersum2;
u16 bodysum1;
u16 bodysum2;
u32 filetype : 9; // PAKFILETYPE constant
u32 bodylen : 11; // not aligned
u32 filelen : 12; // aligned to 0x10
u32 deviceserial : 13;
u32 fileid : 7;
u32 unk0c_21 : 9;
u32 occupied : 1;
u32 unk0c_30 : 1; // always 1?
u32 version : 1; // always 0?
union {
struct {
u16 headersum[2]; // checksum from filetype to end of header
u16 bodysum[2];
u32 filetype : 9; // PAKFILETYPE constant
u32 bodylen : 11; // not aligned
u32 filelen : 12; // aligned to 0x10
u32 deviceserial : 13;
u32 fileid : 7;
u32 unk0c_21 : 9;
u32 occupied : 1;
u32 writecompleted : 1; // 0 while writing data, then updated to 1 afterwards
u32 version : 1; // 0, but can be set to 1 using -forceversion argument
};
u8 bytes[16];
};
};
struct var80067e6c {
+16 -16
View File
@@ -98,7 +98,7 @@ u32 var8005eef0 = 1;
void joy00013900(void)
{
if (var8005eef0) {
joy000150e8();
joyGetLock();
var8005eef0 = false;
}
}
@@ -106,7 +106,7 @@ void joy00013900(void)
void joy00013938(void)
{
if (!var8005eef0) {
joy00015144();
joyReleaseLock();
var8005eef0 = true;
}
}
@@ -235,13 +235,13 @@ void joyCheckPfs(s32 arg0)
var8005eee8++;
if (arg0) {
joy000150e8();
joyGetLock();
}
osPfsIsPlug(&var80099e78, &bitpattern);
if (arg0) {
joy00015144();
joyReleaseLock();
}
bitpattern |= 0x10;
@@ -596,20 +596,20 @@ void joyDebugJoy(void)
if (joy000150c4() && var8005eec0 && joyGetNumSamples() <= 0) {
#if VERSION >= VERSION_NTSC_FINAL
joy000150e8();
joyGetLock();
joy00014238();
joy00015144();
joyReleaseLock();
joyConsumeSamples(&g_JoyData[0]);
#elif VERSION >= VERSION_NTSC_1_0
joy000150e8();
joy00015144();
joyGetLock();
joyReleaseLock();
joyConsumeSamples(&g_JoyData[0]);
joy00014238();
#else
joy000150e8(500, "joy.c");
joyGetLock(500, "joy.c");
joy00014238();
func0001509cnb();
joy00015144(507, "joy.c");
joyReleaseLock(507, "joy.c");
joyConsumeSamples(&g_JoyData[0]);
#endif
}
@@ -1238,7 +1238,7 @@ s32 joy000150c4(void)
return var8005eebc ? false : true;
}
void joy000150e8(
void joyGetLock(
#if VERSION >= VERSION_NTSC_1_0
void
#else
@@ -1256,7 +1256,7 @@ void joy000150e8(
var8005eebc++;
}
void joy00015144(
void joyReleaseLock(
#if VERSION >= VERSION_NTSC_1_0
void
#else
@@ -1347,7 +1347,7 @@ void joy000153c4(s8 device, s32 arg1)
if (device != SAVEDEVICE_GAMEPAK) {
if (g_Paks[device].unk000 != 2 && g_Paks[device].unk000 != 3) {
if (arg1) {
joy000150e8();
joyGetLock();
}
if (osMotorProbe(&var80099e78, PFS(device), device) == 0) {
@@ -1357,7 +1357,7 @@ void joy000153c4(s8 device, s32 arg1)
}
if (arg1) {
joy00015144();
joyReleaseLock();
}
if (g_Paks[device].unk004 != 6 && g_Paks[device].unk004 != 7) {
@@ -1407,7 +1407,7 @@ glabel joy000153c4
/* 16324: 2404041e */ addiu $a0,$zero,0x41e
/* 16328: 3c057005 */ lui $a1,0x7005
/* 1632c: 24a55958 */ addiu $a1,$a1,0x5958
/* 16330: 0c00581b */ jal joy000150e8
/* 16330: 0c00581b */ jal joyGetLock
/* 16334: afa60024 */ sw $a2,0x24($sp)
/* 16338: 8fa60024 */ lw $a2,0x24($sp)
.NB0001633c:
@@ -1493,7 +1493,7 @@ glabel joy000153c4
/* 16454: 3c057005 */ lui $a1,0x7005
/* 16458: 51000004 */ beqzl $t0,.NB0001646c
/* 1645c: 8fa3001c */ lw $v1,0x1c($sp)
/* 16460: 0c005834 */ jal joy00015144
/* 16460: 0c005834 */ jal joyReleaseLock
/* 16464: 24a55960 */ addiu $a1,$a1,0x5960
/* 16468: 8fa3001c */ lw $v1,0x1c($sp)
.NB0001646c: