mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 06:24:30 +00:00
z_collision_check.c (#73)
* func_8005B280 ok * func_8005B65C OK * split out func_8005BD50 * func_8005B7C0 OK * func_8005B7F4 OK * func_8005B824 OK * func_8005B860 ok * improve sanity * func_8005B6B0 ok, ColliderInit_Actor structs added * func_8005B884 ok * func_8005BBF8 ok, split out func_8005BF50 * split more stuff out of func_8005C050.s * func_8005C050 OK * func_8005BA30 fakish OK, func_8005BAD8 real OK * func_8005BB48 OK, func_8005BA84 almost decomp'd, but type issues * func_8005BB10 Ok * func_8005BF50 OK * func_8005BE50 OK * func_8005BD50 OK * func_8005BCC8 Ok * func_8005BC28 * func_8005BB8C func_8005BBB0 func_8005BBD4 Ok * save my work commit * func_8005C2BC fake OK * func_8005C5B0 ok * func_8005C608 ok * func_8005C6C0 ok * func_8005C6F8 ok * func_8005C730 ok * func_8005C774 func_8005C798 func_8005C7BC OK * func_8005C7E0 ok, func_8005C810 split * func_8005C810 OK * func_8005C8C8 ok * func_8005C964 OK * func_8005CA88 ok * func_8005CBAC ok * func_8005C124 func_8005C1AC func_8005C234 func_8005CC98 OK * func_8005CD34 func_8005CDD0 Ok * func_8005CE6C ok * func_8005CEC4 ok * func_8005CEDC ok * func_8005CF90 Ok * standardize type names/vars more * func_8005D3BC ok * func_8005D40C OK, z64.h CollisionCheckContext * func_8005D4B4 func_8005D4C8 ok * partial data section migration * improve function documentation, OT->OC * Actor_CollisionCheck_SetOC ok * Actor_CollisionCheck_SetAT Actor_CollisionCheck_SetAC Ok * func_8005BA84 ok * func_800611A0 ok * func_80061274 ok * clean up func_80061274 * func_8006139C ok * func_8005E9C0 and dependencies OK * minor cleanup to func_8005E9C0 * func_8005EC6C OK! * func_8005E81C ok * func_8005E604 ok * func_8005E2EC func_8005E4F8 OK * func_8005DE9C OK func_8005D8AC disassembled * func_8006146C func_8006268C ok * func_8005EEE0 ok * func_8005F17C * func_8005F39C ok * func_8005F5B0 decompiled, not matching * func_8005F7D0 decomp, func_8005D218 and func_8005D324 OK * func_8005FA30 ok, split more functions * func_8005FC04 ok * func_8005FDCC k * func_8005FF90 OK OK OK * func_80060204 dead * func_800604B0 ok * func_80060704 func_80060994 ok, func_80060C2C somewhat disassembled. AT to AC matrix doneish * func_800635D0 ok, func_80062ECC not so much * OcLine oks * D_8011DF28 functions disassembled * D_8011DF5C functions OK * setAT_SAC. setAC_SAC, setOC_SAC OK * func_80061C98 decompiled, func_80061BF4, func_80061C18 OK * func_800617D4 ok, func_800614A4 disassembled * CollisionCheck_OC D_8011DFAC functions OK * func_80062530 ok * CollisionCheck_generalLineOcCheck subfunctions OK * func_800622E4 ok * after a long fought battle, func_80061F64 has fallen. * func_800628A4 disassembled * func_800627A0 func_8006285C OK * ActorCollider_Cylinder_Update, func_80062718, func_80062734 ok * func_80062CD4 decompiled, import EffShield/EffSpark types from MM * various SubActor98 struct functions OK * func_8005D4DC func_8005D62C ok * .data section migrated, more OKs, fix NON_MATCHINGs to use effect structs * func_80060C2C ok * minor code tweaks * func_80061C98 ok somehow * Attempt to fix some unknowns, move types out of z64actor, add set3 ColliderInit types * Apply changes * formatting * tweak a couple function names * krim changes, func naming * missed some things * function renames * Implement GenColliderInit.py utility * Implement pr changes, GenColliderInit.py, DamageTable.py, z_collision_btltbls.c fully matching * func_800614A4 ok * Implement Roman's fixes, name Collider unknowns, rename COLTYPE -> COLSHAPE and define new COLTYPE * collisionCheckCtx -> colChkCtx, fix small things
This commit is contained in:
parent
f9bdb1d58a
commit
aa91a7ee32
873 changed files with 6121 additions and 10660 deletions
22
tools/overlayhelpers/DamageTable.py
Normal file
22
tools/overlayhelpers/DamageTable.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
import struct
|
||||
|
||||
ROM_ADDR = 0xB94CC0
|
||||
COUNT = 23
|
||||
|
||||
rom = open("../../baserom.z64", "rb")
|
||||
rom.seek(ROM_ADDR)
|
||||
data = bytearray(rom.read(0x20 * COUNT))
|
||||
rom.close()
|
||||
|
||||
valFormat = "0x{:02X}"
|
||||
sfmt = ""
|
||||
for i in range(4):
|
||||
sfmt += valFormat + ", "
|
||||
|
||||
for i in range(3):
|
||||
sfmt += sfmt
|
||||
|
||||
sfmt = "{{ {{ " + sfmt + "}} }},"
|
||||
for i in range(COUNT):
|
||||
line = struct.unpack_from(">32B", data, i * 0x20)
|
||||
print(sfmt.format(*line))
|
203
tools/overlayhelpers/GenColliderInit.py
Normal file
203
tools/overlayhelpers/GenColliderInit.py
Normal file
|
@ -0,0 +1,203 @@
|
|||
import struct
|
||||
|
||||
T_DEFAULT = ''
|
||||
T_SET3 = '_Set3'
|
||||
T_ACTOR = '_Actor'
|
||||
|
||||
TYPE_ENUM = [
|
||||
"COLTYPE_UNK0",
|
||||
"COLTYPE_UNK1",
|
||||
"COLTYPE_UNK2",
|
||||
"COLTYPE_UNK3",
|
||||
"COLTYPE_UNK4",
|
||||
"COLTYPE_UNK5",
|
||||
"COLTYPE_UNK6",
|
||||
"COLTYPE_UNK7",
|
||||
"COLTYPE_UNK8",
|
||||
"COLTYPE_METAL_SHIELD",
|
||||
"COLTYPE_UNK10",
|
||||
"COLTYPE_WOODEN_SHIELD",
|
||||
"COLTYPE_UNK12",
|
||||
"COLTYPE_UNK13" ]
|
||||
|
||||
SHAPE_ENUM = [
|
||||
"COLSHAPE_JNTSPH",
|
||||
"COLSHAPE_CYLINDER",
|
||||
"COLSHAPE_TRIS",
|
||||
"COLSHAPE_QUAD" ]
|
||||
|
||||
sf_ColliderInit = ">BBBBBB"
|
||||
sf_ColliderInit_Set3 = ">BBBBB"
|
||||
sf_ColliderInit_Actor = ">IBBBB"
|
||||
sf_ColliderBodyInit = ">B3xIBB2xIBB2xBBB"
|
||||
sf_JntSph = ">II"
|
||||
sf_JntSphItem = ">Bx5h"
|
||||
sf_Cylinder16 = ">6h"
|
||||
sf_Tris = ">II"
|
||||
sf_TrisItem = ">9f"
|
||||
sf_Quad = ">12f"
|
||||
|
||||
f_ColliderInit = "{{ {0}, 0x{1:02X}, 0x{2:02X}, 0x{3:02X}, 0x{4:02X}, {5} }}"
|
||||
f_ColliderInit_Set3 = "{{ {0}, 0x{1:02X}, 0x{2:02X}, 0x{3:02X}, {4} }}"
|
||||
f_ColliderInit_Actor = "{{ {0}, 0x{1:02X}, 0x{2:02X}, 0x{3:02X}, {4} }}"
|
||||
f_ColliderBodyInit = "{{ 0x{0:02X}, {{ 0x{1:08X}, 0x{2:02X}, 0x{3:02X} }}, {{ 0x{4:08X}, 0x{5:02X}, 0x{6:02X} }}, 0x{7:02X} 0x{8:02X} 0x{9:02X} }}"
|
||||
f_JntSph = "{{ {0}, D_{1:08X} }}"
|
||||
f_JntSphItem = "{{ {0}, {{ {{ {1}, {2}, {3} }}, {4} }}, {5} }}"
|
||||
f_Cylinder16 = "{{ {0}, {1}, {2}, {{ {3}, {4}, {5} }} }}"
|
||||
f_Tris = "{{ {0}, D_{1:08X} }}"
|
||||
f_TrisItem = "{{ {{ {0}f, {1}f, {2}f }}, {{ {3}f, {4}f, {5}f }}, {{ {6}f, {7}f, {8}f }} }}"
|
||||
f_Quad = "{{ {{ {0}f, {1}f, {2}f }}, {{ {3}f, {4}f, {5}f }}, {{ {6}f, {7}f, {8}f }}, {{ {9}f, {10}f, {11}f }} }}"
|
||||
|
||||
def GetColliderFormat(type):
|
||||
if type == T_DEFAULT:
|
||||
return (sf_ColliderInit, f_ColliderInit)
|
||||
if type == T_SET3:
|
||||
return (sf_ColliderInit_Set3, f_ColliderInit_Set3)
|
||||
if type == T_ACTOR:
|
||||
return (sf_ColliderInit_Actor, f_ColliderInit_Actor)
|
||||
return None
|
||||
|
||||
def GetColliderStr(data, off, type):
|
||||
cf = GetColliderFormat(type)
|
||||
cBase = list(struct.unpack_from(cf[0], data, off))
|
||||
if type == T_ACTOR:
|
||||
if cBase[0] == 0:
|
||||
cBase[0] = 'NULL'
|
||||
else:
|
||||
cBase[0] = '0x{0:08X}'.format(cBase[0])
|
||||
else:
|
||||
if cBase[0] < 14:
|
||||
cBase[0] = TYPE_ENUM[cBase[0]]
|
||||
else:
|
||||
cBase[0] = '0x{0:02X}'.format(cBase[0])
|
||||
|
||||
i = 4
|
||||
if type == T_DEFAULT:
|
||||
i = 5
|
||||
|
||||
if cBase[i] < 4:
|
||||
cBase[i] = SHAPE_ENUM[cBase[i]]
|
||||
else:
|
||||
cBase[i] = '0x{0:02X}'.format(cBase[i])
|
||||
|
||||
return cf[1].format(*cBase);
|
||||
|
||||
def GetItems(data, off, count, structf, fmt, size):
|
||||
result = ''
|
||||
for i in range(count):
|
||||
ioff = (i * size)
|
||||
cBody = struct.unpack_from(sf_ColliderBodyInit, data, off + ioff)
|
||||
cItem = struct.unpack_from(structf, data, off + 0x18 + ioff)
|
||||
result += '''
|
||||
{{
|
||||
{0},
|
||||
{1},
|
||||
}},'''.format(f_ColliderBodyInit.format(*cBody), fmt.format(*cItem))
|
||||
return result
|
||||
|
||||
def GetJntSphItems(data, off, count):
|
||||
items = GetItems(data, off, count, sf_JntSphItem, f_JntSphItem, 0x0C)
|
||||
print('''
|
||||
ColliderJntSphItemInit jntsphItemsInit[{0}] = {{{1}
|
||||
}};
|
||||
'''.format(count, items))
|
||||
|
||||
def GetJntSph(data, off, type):
|
||||
sBase = GetColliderStr(data, off, type)
|
||||
cJntSph = struct.unpack_from(sf_JntSph, data, off + 8)
|
||||
|
||||
print('''
|
||||
ColliderJntSphInit{0} jntsphInit =
|
||||
{{
|
||||
{1},
|
||||
{2},
|
||||
}};
|
||||
'''.format(type, sBase, f_JntSph.format(*cJntSph)))
|
||||
|
||||
|
||||
def GetTrisItems(data, off, count):
|
||||
items = GetItems(data, off, count, sf_TrisItem, f_TrisItem, 0x24)
|
||||
print('''
|
||||
ColliderTrisItemInit trisItemsInit[{0}] = {{{1}
|
||||
}};
|
||||
'''.format(count, items))
|
||||
|
||||
|
||||
def GetCylinder(data, off, type):
|
||||
sBase = GetColliderStr(data, off, type)
|
||||
cBody = struct.unpack_from(sf_ColliderBodyInit, data, off + 0x08)
|
||||
cCyl16 = struct.unpack_from(sf_Cylinder16, data, off + 0x20)
|
||||
|
||||
print('''
|
||||
ColliderCylinderInit{0} cylinderInit =
|
||||
{{
|
||||
{1},
|
||||
{2},
|
||||
{3},
|
||||
}};
|
||||
'''.format(type, sBase, f_ColliderBodyInit.format(*cBody),f_Cylinder16.format(*cCyl16)))
|
||||
|
||||
def GetTris(data, off, type):
|
||||
sBase = GetColliderStr(data, off, type)
|
||||
cTris = struct.unpack_from(sf_Tris, data, off + 8)
|
||||
|
||||
print('''
|
||||
ColliderTrisInit{0} trisInit =
|
||||
{{
|
||||
{1},
|
||||
{2},
|
||||
}};
|
||||
'''.format(type, sBase, f_Tris.format(*cTris)))
|
||||
|
||||
def GetQuad(data, off, type):
|
||||
sBase = GetColliderStr(data, off, type)
|
||||
cBody = struct.unpack_from(sf_ColliderBodyInit, data, off + 0x08)
|
||||
cQuad = struct.unpack_from(sf_Quad, data, off + 0x20)
|
||||
print(cQuad)
|
||||
print('''
|
||||
ColliderQuadInit{0} quadInit =
|
||||
{{
|
||||
{1},
|
||||
{2},
|
||||
{3},
|
||||
}};
|
||||
'''.format(type, sBase, f_ColliderBodyInit.format(*cBody), f_Quad.format(*cQuad)))
|
||||
|
||||
TYPE_DICT = {
|
||||
'ColliderJntSphInit' : (GetCylinder, 'Shape', T_DEFAULT),
|
||||
'ColliderCylinderInit' : (GetJntSph, 'Shape', T_DEFAULT),
|
||||
'ColliderTrisInit': (GetTris, 'Shape', T_DEFAULT),
|
||||
'ColliderQuadInit': (GetQuad, 'Shape', T_DEFAULT),
|
||||
'ColliderJntSphItemInit' : (GetJntSphItems, 'Item'),
|
||||
'ColliderTrisItemInit' : (GetTrisItems, 'Item')
|
||||
}
|
||||
|
||||
update = [(k, v[0]) for k,v in TYPE_DICT.items() if v[1] == 'Shape']
|
||||
for i in update:
|
||||
for j in (T_SET3, T_ACTOR):
|
||||
TYPE_DICT[i[0] + j] = (i[1], 'Shape', j)
|
||||
|
||||
#ovlName = 'ovl_Obj_Comb'
|
||||
#address = 0x000780
|
||||
#inputType = 'ColliderJntSphItemInit'
|
||||
|
||||
#ovlName = 'ovl_En_Boom'
|
||||
#address = 0x0007D0
|
||||
#inputType = 'ColliderQuadInit'
|
||||
|
||||
ovlName = input("Overlay Name (baserom): ")
|
||||
ovlFile = open("../../baserom/" + ovlName, "rb")
|
||||
ovlData = bytearray(ovlFile.read())
|
||||
ovlFile.close()
|
||||
|
||||
address = int(input("Address: 0x"), 16)
|
||||
inputType = input("Type (e.g. ColliderQuadInit): ")
|
||||
|
||||
selectedType = TYPE_DICT[inputType]
|
||||
arg2 = None
|
||||
if selectedType[1] == 'Shape':
|
||||
arg2 = selectedType[2]
|
||||
else:
|
||||
arg2 = int(input("Number of items: "))
|
||||
|
||||
selectedType[0](ovlData, address, arg2)
|
|
@ -1,69 +0,0 @@
|
|||
import struct
|
||||
|
||||
ovlName = input("Overlay Name: ")
|
||||
|
||||
ovlFile = open("../../baserom/" + ovlName, "rb")
|
||||
ovlData = bytearray(ovlFile.read())
|
||||
ovlFile.close()
|
||||
|
||||
address = int(input("Address: 0x"), 16)
|
||||
|
||||
v0 = str(hex(struct.unpack_from(">B", ovlData, address + 0)[0]))
|
||||
v1 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 1)[0]))
|
||||
v2 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 2)[0]))
|
||||
v3 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 3)[0]))
|
||||
|
||||
v4 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 4)[0]))
|
||||
v5 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 5)[0]))
|
||||
v6 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 6)[0]))
|
||||
v7 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 7)[0]))
|
||||
|
||||
v8 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 8)[0]))
|
||||
v9 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 9)[0]))
|
||||
v10 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 10)[0]))
|
||||
v11 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 11)[0]))
|
||||
|
||||
v12 = str(hex(struct.unpack_from(">I", ovlData, offset = address + 12)[0]))
|
||||
|
||||
v13 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 16)[0]))
|
||||
v14 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 17)[0]))
|
||||
v15 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 18)[0]))
|
||||
v16 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 19)[0]))
|
||||
|
||||
v17 = str(hex(struct.unpack_from(">I", ovlData, offset = address + 20)[0]))
|
||||
|
||||
v18 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 24)[0]))
|
||||
v19 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 25)[0]))
|
||||
v20 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 26)[0]))
|
||||
v21 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 27)[0]))
|
||||
|
||||
v22 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 28)[0]))
|
||||
v23 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 29)[0]))
|
||||
v24 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 30)[0]))
|
||||
v25 = str(hex(struct.unpack_from(">B", ovlData, offset = address + 31)[0]))
|
||||
|
||||
v26 = str(hex(struct.unpack_from(">H", ovlData, offset = address + 32)[0]))
|
||||
v27 = str(hex(struct.unpack_from(">H", ovlData, offset = address + 34)[0]))
|
||||
|
||||
v28 = str(hex(struct.unpack_from(">L", ovlData, offset = address + 36)[0]))
|
||||
|
||||
|
||||
print(
|
||||
'''
|
||||
static ColliderCylinderInit cylinderInitData =
|
||||
{
|
||||
%s, %s, %s, %s,
|
||||
%s, %s, %s, %s,
|
||||
%s, %s, %s, %s,
|
||||
%s,
|
||||
%s, %s, %s, %s,
|
||||
%s,
|
||||
%s, %s, %s, %s,
|
||||
%s, %s, %s, %s,
|
||||
%s,
|
||||
%s,
|
||||
%s,
|
||||
};
|
||||
'''
|
||||
% (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue