Decompile bgunTickGunLoad

This commit is contained in:
Ryan Dwyer 2022-07-10 21:36:13 +10:00
parent 3b78245d9c
commit c94f0e196a
11 changed files with 346 additions and 616 deletions

View File

@ -114,7 +114,7 @@ The decomp project wraps all decompiled piracy checks in `#if PIRACYCHECKS` stat
---
### tagsAllocatePtrs
### tagsReset
**When Called:** When loading a normal stage (eg. CI Training).
@ -122,13 +122,13 @@ The decomp project wraps all decompiled piracy checks in `#if PIRACYCHECKS` stat
**Payload:** Copies 4KB from a random location in ROM to a random location in RAM.
### bgun0f09e144
### bgunTickGunLoad
**When Called:** Unknown.
**When Called:** When equipping any weapon.
**What It Checks:** Checksums `tagsReset` to make sure it hasn't been modified.
**Payload:** Corrupts `tagsReset` by writing 28 bytes of 0xff.
**Payload:** Corrupts `tagsReset` by writing 7 bytes of 0xff.
---

File diff suppressed because it is too large Load Diff

View File

@ -151,8 +151,8 @@ void bgunReset(void)
g_Vars.currentplayer->gunctrl.handfilenum = 0;
g_Vars.currentplayer->gunctrl.unk15a0 = 0;
g_Vars.currentplayer->gunctrl.unk15a4 = 0;
g_Vars.currentplayer->gunctrl.unk15b0 = 0;
g_Vars.currentplayer->gunctrl.unk15b1 = 0;
g_Vars.currentplayer->gunctrl.masterloadstate = 0;
g_Vars.currentplayer->gunctrl.gunloadstate = 0;
g_Vars.currentplayer->gunctrl.gunmemtype = 0;
g_Vars.currentplayer->gunctrl.gunmemnew = -1;
g_Vars.currentplayer->gunctrl.gunmemowner = GUNMEMOWNER_CHRBODY;

View File

@ -2018,7 +2018,7 @@ glabel var7f1acd60
/* f0adf50: 8fa40148 */ lw $a0,0x148($sp)
/* f0adf54: 0c005746 */ jal mtx4Copy
/* f0adf58: 27a500ec */ addiu $a1,$sp,0xec
/* f0adf5c: 0fc27aef */ jal bgun0f09ebbc
/* f0adf5c: 0fc27aef */ jal bgunGetCartModeldef
/* f0adf60: 00000000 */ nop
/* f0adf64: 10400004 */ beqz $v0,.L0f0adf78
/* f0adf68: 00402025 */ or $a0,$v0,$zero
@ -2849,7 +2849,7 @@ glabel var7f1acd60
/* f0adf50: 8fa40148 */ lw $a0,0x148($sp)
/* f0adf54: 0c005746 */ jal mtx4Copy
/* f0adf58: 27a500ec */ addiu $a1,$sp,0xec
/* f0adf5c: 0fc27aef */ jal bgun0f09ebbc
/* f0adf5c: 0fc27aef */ jal bgunGetCartModeldef
/* f0adf60: 00000000 */ nop
/* f0adf64: 10400004 */ beqz $v0,.L0f0adf78
/* f0adf68: 00402025 */ or $a0,$v0,$zero

View File

@ -3214,7 +3214,7 @@ void texLoadFromDisplayList(Gfx *gdl, struct texturething *arg1, s32 arg2)
while (bytes[0] != (u8)G_ENDDL) {
// Look for GBI sequence: fd...... abcd....
if (bytes[0] == G_SETTIMG && bytes[4] == 0xab && bytes[5] == 0xcd) {
texLoad((u32 *)((s32)bytes + 4), arg1, arg2);
texLoad((s32 *)((s32)bytes + 4), arg1, arg2);
}
bytes += 8;
@ -3701,11 +3701,11 @@ void texLoadFromConfigs(struct textureconfig *configs, s32 numconfigs, struct te
}
}
void texLoadFromTextureNum(u32 arg0, struct texturething *arg1)
void texLoadFromTextureNum(u32 texturenum, struct texturething *arg1)
{
u32 sp1c = arg0;
s32 texturenumcopy = texturenum;
texLoad(&sp1c, arg1, 1);
texLoad(&texturenumcopy, arg1, 1);
}
s32 func0f173510(s32 arg0, s32 arg1, s32 arg3)

View File

@ -282,7 +282,7 @@ void texSelect(Gfx **gdlptr, struct textureconfig *tconfig, u32 arg2, s32 arg3,
s4 = NULL;
if (tconfig->texturenum < NUM_TEXTURES) {
if ((u32)tconfig->texturenum < NUM_TEXTURES) {
texLoadFromConfigs(tconfig, 1, arg6, 0);
}

View File

@ -1377,6 +1377,7 @@
#define LOADTYPE_SETUP 4
#define LOADTYPE_PADS 5
#define LOADTYPE_MODEL 6
#define LOADTYPE_GUN 7
// These actions are assigned to chr->myaction
#define MA_NONE 0

View File

@ -68,11 +68,11 @@ void bgunFreeGunMem(void);
void bgunSetGunMemWeapon(s32 weaponnum);
void bgun0f09df9c(void);
bool bgun0f09e004(s32 newowner);
void bgun0f09e144(void);
void bgunTickIncLoad(void);
void bgunTickGunLoad(void);
void bgunTickMasterLoad(void);
void bgunTickLoad(void);
bool bgun0f09eae4(void);
struct modelfiledata *bgun0f09ebbc(void);
struct modelfiledata *bgunGetCartModeldef(void);
void bgun0f09ebcc(struct defaultobj *obj, struct coord *coord, s16 *rooms, Mtxf *matrix1, struct coord *velocity, Mtxf *matrix2, struct prop *prop, struct coord *pos);
void bgun0f09ed2c(struct defaultobj *obj, struct coord *coord, Mtxf *arg2, struct coord *velocity, Mtxf *arg4);
struct defaultobj *bgunCreateThrownProjectile2(struct chrdata *chr, struct gset *gset, struct coord *pos, s16 *rooms, Mtxf *arg4, struct coord *velocity);

View File

@ -32,7 +32,7 @@ struct texloadthing *tex0f172e8c(s32 texturenum, struct texturething *arg1);
s32 func0f172f44(struct texturething *arg0);
struct texloadthing *func0f172f54(struct texturething *arg0);
void texLoadFromDisplayList(Gfx *gdl, struct texturething *arg1, s32 arg2);
void texLoad(u32 *texturenum, struct texturething *arg1, s32 arg2);
void texLoad(s32 *texturenum, struct texturething *arg1, s32 arg2);
void texLoadFromConfigs(struct textureconfig *configs, s32 numconfigs, struct texturething *arg2, s32 arg3);
void texLoadFromTextureNum(u32 arg0, struct texturething *arg1);

View File

@ -2286,6 +2286,18 @@ struct hand {
/*0x0dd8*/ Mtxf *unk0dd8;
};
struct texturething {
struct texloadthing *unk00;
struct texloadthing *unk04;
struct texloadthing *unk08;
struct texloadthing *unk0c;
};
struct fileinfo {
u32 loadedsize;
u32 allocsize;
};
struct gunctrl {
/*0x1580*/ s8 weaponnum;
/*0x1581*/ s8 prevweaponnum; // previously drawn weapon, switched to when throwing Dragon/Laptop or when ammo depleted
@ -2303,25 +2315,21 @@ struct gunctrl {
/*0x158c*/ u8 *gunmem;
/*0x1590*/ struct modelfiledata *gunmodeldef;
/*0x1594*/ struct modelfiledata *handmodeldef;
/*0x1598*/ struct modelfiledata *unk1598;
/*0x1598*/ struct modelfiledata *cartmodeldef;
/*0x159c*/ u16 handfilenum;
/*0x15a0*/ u8 *unk15a0;
/*0x15a4*/ s32 unk15a4;
/*0x15a8*/ s32 unk15a8;
/*0x15ac*/ s32 unk15ac;
/*0x15b0*/ u8 unk15b0;
/*0x15b1*/ u8 unk15b1;
/*0x15b2*/ u16 unk15b2;
/*0x15b4*/ struct modelfiledata **unk15b4;
/*0x15b8*/ void *unk15b8;
/*0x15bc*/ void *unk15bc;
/*0x15c0*/ u32 unk15c0;
/*0x15c4*/ u32 unk15c4;
/*0x15c8*/ u32 unk15c8;
/*0x15cc*/ u32 unk15cc;
/*0x15d0*/ u32 unk15d0;
/*0x15d4*/ u32 unk15d4;
/*0x15d8*/ u32 unk15d8;
/*0x15b0*/ u8 masterloadstate;
/*0x15b1*/ u8 gunloadstate;
/*0x15b2*/ u16 loadfilenum;
/*0x15b4*/ struct modelfiledata **loadtomodeldef;
/*0x15b8*/ u32 *loadmemptr;
/*0x15bc*/ u32 *loadmemremaining;
/*0x15c0*/ struct texturething unk15c0;
/*0x15d0*/ u32 nexttexturetoload;
/*0x15d4*/ struct fileinfo fileinfo;
/*0x15dc*/ struct abmag abmag;
/*0x15e4*/ s8 ammotypes[2];
/*0x15e6*/ u8 action;
@ -3779,7 +3787,7 @@ struct menudata_training {
struct textureconfig {
union {
u32 texturenum;
s32 texturenum;
u8 *textureptr;
};
u8 width;
@ -5131,11 +5139,6 @@ struct var800aabb8 {
u16 unk00_02 : 14;
};
struct fileinfo {
u32 loadedsize;
u32 allocsize;
};
struct portalcmd {
u8 type;
u8 len;
@ -5777,8 +5780,8 @@ struct var8009dd78 {
};
struct texturepair {
u32 texturenum1;
u32 texturenum2;
s32 texturenum1;
s32 texturenum2;
};
struct collisionthing {
@ -6272,13 +6275,6 @@ struct awardmetrics {
/*0x38*/ f32 accuracyfrac;
};
struct texturething {
struct texloadthing *unk00;
struct texloadthing *unk04;
struct texloadthing *unk08;
struct texloadthing *unk0c;
};
struct texloadthing {
/*0x00*/ u16 texturenum : 12;
/*0x00*/ u16 unk00_0c : 4;

View File

@ -163,7 +163,7 @@ void piracy_patch(void)
patch(algo06, "lvReset", "lvGetSlowMotionType");
patch(algo07, "bodyAllocateEyespy", "lvReset");
patch(algo08, "chrConsiderGrenadeThrow", "bgReset");
patch(algo09, "bgun0f09e144", "tagsReset");
patch(algo09, "bgunTickGunLoad", "tagsReset");
patch(algo10, "explosionAlertChrs", "glassDestroy");
patch(algo11, "func0f0069dc", "mtxGetObfuscatedRomBase");
patch(algo12, "func0f15c920", "func0f0069dc");