fragment21

This commit is contained in:
Kelebek1
2024-10-18 04:21:28 +01:00
parent 5c689ff118
commit 9541ed7b51
12 changed files with 2674 additions and 114 deletions

View File

@@ -418,14 +418,17 @@ typedef struct unk_D_86002F34_alt24 {
typedef void* (*func_unk_D_800ABE10)(s32, s32);
#define unk_D_86002F34_018_GFX_TYPE_1 1 // 8-bit per texel
#define unk_D_86002F34_018_GFX_TYPE_2 2 // 16-bit per texel
#define unk_D_86002F34_018_GFX_TYPE_3 3 // 32-bit per texel
typedef struct unk_D_86002F34_018 {
/* 0x00 */ u8 unk_00;
/* 0x01 */ u8 unk_01;
/* 0x02 */ u8 unk_02;
/* 0x03 */ u8 unk_03;
/* 0x04 */ s16 unk_04;
/* 0x06 */ s16 unk_06;
/* 0x08 */ u8* unk_08;
/* 0x01 */ u8 type;
/* 0x02 */ s16 width;
/* 0x04 */ s16 height;
/* 0x06 */ s16 num_texels;
/* 0x08 */ u8* texture;
} unk_D_86002F34_018; // size = 0xC
typedef struct unk_D_86002F34_01C {

View File

@@ -24,3 +24,9 @@ D_03042E00 = 0x03042E00;
D_0303ED80 = 0x0303ED80;
D_0303F580 = 0x0303F580;
D_0303F180 = 0x0303F180;
D_030451A0 = 0x030451A0;
D_03046AA0 = 0x03046AA0;
D_03045E20 = 0x03045E20;
D_03049020 = 0x03049020;
D_030483A0 = 0x030483A0;
D_03047720 = 0x03047720;

View File

@@ -31,18 +31,18 @@ void func_80018C40(unk_D_86002F34* arg0, arg1_func_80010CA8 arg1) {
for (i = 0; i < arg0->unk_24; i++, var_s2++) {
if (var_s2->unk_00 == 0) {
if (var_s2->unk_01 == 2) {
u16* var_s1 = var_s2->unk_08;
if (var_s2->type == unk_D_86002F34_018_GFX_TYPE_2) {
u16* var_s1 = var_s2->texture;
for (j = 0; j < var_s2->unk_06; j++) {
for (j = 0; j < var_s2->num_texels; j++) {
var_s1[j] = func_80010CA8(var_s1[j], arg1);
}
}
if (var_s2->unk_01 == 3) {
u32* var_s1 = var_s2->unk_08;
if (var_s2->type == unk_D_86002F34_018_GFX_TYPE_3) {
u32* var_s1 = var_s2->texture;
for (j = 0; j < var_s2->unk_06; j++) {
for (j = 0; j < var_s2->num_texels; j++) {
var_s1[j] = func_80010E20(var_s1[j], arg1);
}
}

View File

@@ -385,7 +385,7 @@ static u32 D_86B0C4E0[] = {
};
static unk_D_86002F34_018 D_86B0CCE0 = {
0x03, 0x02, 0x00, 0x20, 0x0020, 0x0400, D_86B0C4E0,
0x03, unk_D_86002F34_018_GFX_TYPE_2, 32, 32, 0x0400, D_86B0C4E0,
};
static Gfx D_86B0CCF0[] = {
@@ -534,7 +534,7 @@ static u32 D_86B0CFE0[] = {
0x29EB3A71, 0x4B357439, 0x6BF7532F, 0x532B4AA9, 0x3A273229, 0x326F3AB3, 0x2A2B195D, 0x1919299D,
};
static unk_D_86002F34_018 D_86B0D7E0 = {
0x00, 0x02, 0x00, 0x20, 0x0020, 0x0400, D_86B0CFE0,
0x00, unk_D_86002F34_018_GFX_TYPE_2, 32, 32, 0x0400, D_86B0CFE0,
};
static Gfx D_86B0D7F0[] = {
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_MIRROR | G_TX_WRAP, 5, G_TX_NOLOD,

View File

@@ -915,90 +915,80 @@ static u32 D_86C0B1F8[] = {
static unk_D_86002F34_018 D_86C0B9F8[] = {
{
0x00,
0x02,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_2,
32,
64,
2048,
D_86C049F8,
},
{
0x00,
0x02,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_2,
32,
64,
2048,
D_86C059F8,
},
{
0x00,
0x02,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_2,
32,
64,
2048,
D_86C069F8,
},
{
0x00,
0x02,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_2,
32,
32,
1024,
D_86C079F8,
},
{
0x00,
0x03,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_3,
32,
32,
1024,
D_86C081F8,
},
{
0x00,
0x02,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_2,
32,
32,
1024,
D_86C091F8,
},
{
0x00,
0x02,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_2,
32,
32,
1024,
D_86C099F8,
},
{
0x00,
0x02,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_2,
32,
32,
1024,
D_86C0A1F8,
},
{
0x00,
0x02,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_2,
32,
32,
1024,
D_86C0A9F8,
},
{
0x00,
0x02,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_2,
32,
32,
1024,
D_86C0B1F8,

View File

@@ -155,27 +155,24 @@ static u32 D_86E035B0[] = {
static unk_D_86002F34_018 D_86E03DB0[3] = {
{
0x04,
0x01,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_1,
32,
32,
1024,
D_86E02FB0,
},
{
0x00,
0x02,
0x00,
0x04,
unk_D_86002F34_018_GFX_TYPE_2,
4,
64,
256,
D_86E033B0,
},
{
0x00,
0x02,
0x00,
0x20,
unk_D_86002F34_018_GFX_TYPE_2,
32,
32,
1024,
D_86E035B0,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
#ifndef _FRAGMENT21_H_
#define _FRAGMENT21_H_
#include "global.h"
#include "src/fragments/3/fragment3.h"
void func_86F00020(s16 arg0, s16 arg1);
void func_86F00188(s16 arg0, s16 arg1);
void func_86F001CC(unk_func_8790002C* arg0, s32 arg1);
void func_86F002F4(void);
void func_86F0035C(unk_func_8790002C* arg0);
void func_86F00370(void);
void func_86F003FC(unk_func_8790002C* arg0, s32 arg1);
void func_86F00450(unk_func_8790002C* arg0, f32 arg1);
void func_86F0048C(unk_func_8790002C* arg0, s32 arg1);
void func_86F0050C(unk_func_8790002C* arg0);
void func_86F00778(unk_func_8790002C* arg0);
void func_86F00920(unk_func_8790002C* arg0);
void func_86F00D04(void);
void func_86F00E34(unk_func_8790002C* a0, s32 arg1);
void func_86F00F00(void);
void func_86F00F68(unk_func_8790002C* arg0, unk_func_8790002C* arg1);
void func_86F01014(void);
void func_86F010B4(unk_func_8790002C* a0, s32 arg1);
void func_86F01180(void);
void func_86F011E8(unk_func_8790002C* arg0);
void func_86F012B8(void);
void func_86F0132C(void);
void func_86F013B8(void);
void func_86F01488(void);
void func_86F014B8(void);
s32 func_86F014F8(void);
void func_86F0164C(void);
s32 func_86F016D8(void);
void func_86F0174C(void);
void func_86F018E4(void);
void func_86F01904(void);
void func_86F01C40(void);
void func_86F01D78(void);
void func_86F01EB4(void);
void func_86F01EF4(s32 arg0);
void func_86F01F58(s32 arg0);
void func_86F02004(void);
void func_86F0204C(void);
void func_86F02230(void);
void func_86F02320(void);
s32 func_86F02520(s32 arg0, UNUSED s32 arg1);
#endif // _FRAGMENT21_H_

View File

@@ -49,7 +49,7 @@ typedef struct unk_func_8790002C {
/* 0x234 */ s16 unk_234;
/* 0x236 */ s16 unk_236;
/* 0x238 */ s16 unk_238;
/* 0x23A */ char unk23A[0x2];
/* 0x23A */ s16 unk_23A;
/* 0x23A */ s16 unk_23C;
/* 0x23E */ s16 unk_23E;
/* 0x240 */ s16 unk_240;
@@ -98,7 +98,7 @@ typedef struct unk_func_8790002C {
/* 0x2AA */ s16 unk_2AA;
/* 0x2AC */ s16 unk_2AC;
/* 0x2AE */ s16 unk_2AE;
/* 0x2B0 */ char unk2B0[0x2];
/* 0x2B0 */ s16 unk_2B0;
/* 0x2B2 */ s16 unk_2B2;
} unk_func_8790002C; // size = 0x2B4

View File

@@ -486,6 +486,9 @@ void func_81407B04(unk_D_8140E720* arg0);
unk_D_8140E720* func_81407B3C(void);
unk_D_8140E720* func_81407B5C(u8 arg0);
void func_81407D48(f32 arg0, Vec3f arg1, Vec3s arg2, func_unk_D_8140E720_008 arg3, unk_D_8140E728_01C* arg4, s16 arg5);
void func_81407E30(f32 arg0, Vec3f arg1, Vec3s arg2, func_unk_D_8140E720_008 arg3, unk_D_8140E728_01C* arg4, s16 arg5, s16 arg6);
void func_81407F24(unk_D_86002F58_004_000* arg0, func_unk_D_8140E720_008 arg1, unk_D_8140E728_01C* arg2, s16 arg3, s16 arg4);
void func_81407FC8(unk_D_86002F58_004_000* arg0, func_unk_D_8140E720_008 arg1, unk_D_8140E728_01C* arg2, s16 arg3, s16 arg4, s16 arg5);
s32 func_81408078(void);
s32 func_814080EC(void);
void func_8140810C(unk_D_8140E720* arg0);

View File

@@ -35,6 +35,7 @@ def dump(offset):
OUT_DATA = {}
DONE_DECOMP = set()
TO_DECOMP = []
REPLACE_OFFSETS = {}
def get_type(f, offset, cmd, args, out):
curr_args = []
@@ -68,6 +69,9 @@ def dump(offset):
if (cmd == 0x00 or cmd == 0x03) and arg["name"] == "unk_04":
TO_DECOMP.append(find_sym.find(f"0x{v:X}", "v")["rom"])
REPLACE_OFFSETS[offset + arg["offset"]] = v
out += f"D_{v:08X}" + ", "
elif "*" in arg["type"]:
@@ -82,9 +86,7 @@ def dump(offset):
OUT_DATA[t].append(v)
case "Vtx":
if cmd == 0x17:
out += f"D_{v:08X}" + ", "
else:
if cmd != 0x17:
print(hex(v))
print(curr_args)
exit()
@@ -97,15 +99,19 @@ def dump(offset):
OUT_DATA[t].append(v)
out += f"D_{v:08X}" + ", "
REPLACE_OFFSETS[offset + arg["offset"]] = v
else:
out += f"NULL" + ", "
REPLACE_OFFSETS[offset + arg["offset"]] = 0
elif make_hex:
if v == 0:
out += f"NULL" + ", "
elif v in FUNCS:
REPLACE_OFFSETS[offset + arg["offset"]] = 0
if v in FUNCS:
out += f"{FUNCS[v]}" + ", "
OUT_FUNCS[cmd].add(FUNCS[v])
REPLACE_OFFSETS[offset + arg["offset"]] = v
else:
out += f"0x{v:08X}" + ", "
else:
@@ -140,20 +146,23 @@ def dump(offset):
#print(f"Processing script at 0x{offset:X}")
f.seek(offset, 0)
start = offset
out = f""
while True:
cmd = unpack_from(">B", f.read(1), 0)[0]
#out += f" 0x{word:08X},\n"
#print(f"depth {DEPTH} offset 0x{offset:X} cmd 0x{cmd:02X} size 0x{COMMANDS[cmd]['size']:X}")
#print(f"command 0x{cmd:X} --", COMMANDS[cmd])
out += f" ANIMATION_SCRIPT_CMD_{cmd:02X}"
out += "("
#out += f" ANIMATION_SCRIPT_CMD_{cmd:02X}"
#out += "("
#print(hex(offset), hex(cmd))
out = get_type(f, offset, cmd, COMMANDS[cmd]["args"][1:], out)
if out[-2:] == ", ":
out = out[:-2]
out += "),\n"
_ = get_type(f, offset, cmd, COMMANDS[cmd]["args"][1:], out)
#if out[-2:] == ", ":
# out = out[:-2]
#out += "),\n"
if cmd == 0x01 or cmd == 0x04:
break;
@@ -161,11 +170,32 @@ def dump(offset):
offset += COMMANDS[cmd]["size"]
f.seek(offset, 0)
out = out[:-1]
end = offset
#out = out[:-1]
f.seek(start, 0)
end += 4
out = f""
while start < end:
word = unpack_from(">I", f.read(4), 0)[0]
if start in REPLACE_OFFSETS:
v = REPLACE_OFFSETS[start]
if v == 0:
out += f" NULL,\n"
elif v in FUNCS:
out += f" {FUNCS[v]},\n"
else:
out += f" D_{v:08X},\n"
else:
out += f" 0x{word:08X},\n"
start += 4
#print()
out_struct = f"static u32 D_{out_info['ram']:X}[] = " + "{\n"
TO_OUTPUT.append([out_struct, out + "\n};\n"])
TO_OUTPUT.append([out_struct, out + "};\n"])
for cmd in OUT_FUNCS:
funcs = sorted(list(OUT_FUNCS[cmd]))
@@ -218,8 +248,42 @@ def dump(offset):
dump_type = f"unk_D_86002F34_018[{c}]" if c > 0 else f"unk_D_86002F34_018"
d = data2c.dump(find_sym.find(f"0x{v:X}", "v")["rom"], dump_type)
out = f"unk_D_86002F34_018 D_{v:08X}" + (f"[{c}]" if c > 0 else "") + f" = {d}"
out = data2c.dump(find_sym.find(f"0x{v:X}", "v")["rom"], dump_type)
split = out.split(",")
for i,arg in enumerate(split):
arg = arg.strip()
is_valid = False
try:
addr = int(arg, 16)
if addr >= 0x80000000:
is_valid = True
except Exception:
pass;
if is_valid:
tex_type_str = split[i-4].strip()
tex_type = int(tex_type_str, 16)
match tex_type:
case 2:
new_tex_type = "unk_D_86002F34_018_GFX_TYPE_2"
size = (int(split[i-1].strip(), 10) * 2) // 4
case 3:
new_tex_type = "unk_D_86002F34_018_GFX_TYPE_3"
size = (int(split[i-1].strip(), 10) * 4) // 4
case _:
print(f"Inknown tex type {tex_type}")
exit()
tex = data2c.dump(find_sym.find(f"0x{addr:X}", "v")["rom"], f"u32[{size}]")
FINAL_OUT_DATA.append([addr, f"u32[{size}]", tex])
pos = out.rfind(tex_type_str, 0, out.find(arg))
out = out[:pos] + new_tex_type + out[pos+4:]
out = out.replace(arg, f"D_{addr:08X}")
FINAL_OUT_DATA.append([v, dump_type, out])
case _:
@@ -234,7 +298,11 @@ def dump(offset):
FINAL_OUT_DATA.append([v, type, out])
FINAL_OUT_DATA.sort(key=lambda x: x[0])
FINAL_DONE = set()
for v, type, out in FINAL_OUT_DATA:
if v in FINAL_DONE:
continue
FINAL_DONE.add(v)
is_array = "[" in type or type == "Gfx" or type == "Vtx"
if "[" in type:

View File

@@ -1096,10 +1096,10 @@
subsegments:
- [0x185A10, textbin, fragments/21/fragment21_header]
- [0x185A30, c, fragments/21/fragment21]
- [0x1880A0, data, fragments/21/fragment21_data]
- [0x190B90, rodata, fragments/21/fragment21_rodata]
- [0x1880A0, .data, fragments/21/fragment21]
- [0x190B90, .rodata, fragments/21/fragment21]
- {vram: 0x86F0B1F0, type: bss, name: fragments/21/fragment21_bss}
- {vram: 0x86F0B1F0, type: .bss, name: fragments/21/fragment21}
- name: fragment21_relocs
type: code