Exemple #1
0
def main():
    parser = argparse.ArgumentParser(description='Decompiles a ColChkInfoInit')
    parser.add_argument('address',
                        help='VRAM or VROM address of a ColChkInfoInit',
                        type=HexParse)
    parser.add_argument('type',
                        help="Type: ColChkInfoInit or ColChkInfoInit2",
                        choices=['ColChkInfoInit', 'ColChkInfoInit2'])
    args = parser.parse_args()

    file_path, file_offset = resolve_symbol(args.address)

    with open(file_path, 'rb') as f:
        filedata = f.read()

    if args.type == "ColChkInfoInit":
        info = list(
            struct.unpack(">Bx2hB", filedata[file_offset:file_offset + 7]))
        NameMass(info)
        output = "// colChkInfoInit\nstatic CollisionCheckInfoInit D_{0:08X} = {{ ".format(
            args.address) + ", ".join(map(str, info)) + "};"
    else:
        info = list(
            struct.unpack(">Bx3hB", filedata[file_offset:file_offset + 9]))
        NameMass(info)
        output = "// sColChkInfoInit\nstatic CollisionCheckInfoInit2 D_{0:08X} = {{ ".format(
            args.address) + ", ".join(map(str, info)) + "};"

    print(output)
Exemple #2
0
def GetColliderInit(address, type, num):
    TYPE_DICT = {
        'ColliderJntSphInit': (GetJntSph, 'Shape', T_DEFAULT),
        'ColliderCylinderInit': (GetCylinder, 'Shape', T_DEFAULT),
        'ColliderTrisInit': (GetTris, 'Shape', T_DEFAULT),
        'ColliderQuadInit': (GetQuad, 'Shape', T_DEFAULT),
        'ColliderSphereInit': (GetSphere, 'Shape', T_DEFAULT),
        'ColliderJntSphElementInit': (GetJntSphElements, 'Item'),
        'ColliderTrisElementInit': (GetTrisElements, 'Item')
    }

    update = [(k, v[0]) for k, v in TYPE_DICT.items() if v[1] == 'Shape']
    for i in update:
        for j in (TType1, T_ACTOR):
            TYPE_DICT[i[0] + j] = (i[1], 'Shape', j)

    fileResult = resolve_symbol(address)

    print(hex(fileResult[1]), "in", fileResult[0].split(os.sep)[-1])

    selectedType = TYPE_DICT[type]
    arg2 = None
    if selectedType[1] == 'Shape':
        arg2 = selectedType[2]
    elif num > 0:
        arg2 = num
    else:
        return ("ItemInit type must specify number of elements")

    ovlFile = open(fileResult[0], "rb")
    ovlData = bytearray(ovlFile.read())
    ovlFile.close()

    return selectedType[0](address, ovlData, fileResult[1], arg2)
Exemple #3
0
def get_damage_bytes(address):
    file_name, file_offset = resolve_symbol(address)
    print(hex(file_offset), "in", file_name.split(os.sep)[-1], "\n")

    with open(file_name, "rb") as ovl_file:
        ovl_data = bytearray(ovl_file.read())

    damage_data = ovl_data[file_offset:file_offset + 0x20]

    damage_table = make_table('D_' + format(address, 'X'), damage_data)

    return damage_table
Exemple #4
0
def main():
    parser = argparse.ArgumentParser(
        description="Disassembles MM event scripts")
    parser.add_argument('address',
                        help="VRAM or ROM address to disassemble at",
                        type=hex_parse)
    args = parser.parse_args()

    file_result = resolve_symbol(args.address)

    if file_result[0] is None:
        print("Invalid address")
        return

    print(hex(file_result[1]), "in", file_result[0].split(os.sep)[-1])

    with open(file_result[0], "rb") as data_file:
        disassemble_unk_script(data_file, file_result[1])
Exemple #5
0
def main():
    parser = argparse.ArgumentParser(description='Decompiles an InitChain')
    parser.add_argument('address',
                        help='VRAM or VROM address of an InitChain',
                        type=HexParse)
    parser.add_argument('--offsets',
                        action="store_true",
                        help='Use offsets as variable names.')
    args = parser.parse_args()

    file_path, file_offset = resolve_symbol(args.address)

    with open(file_path, 'rb') as f:
        filedata = f.read()

    print('static InitChainEntry sInitChain[] = {')

    actor_variable_names = get_actor_var_names()

    while True:
        entry = struct.unpack('>I', filedata[file_offset:file_offset + 4])[0]
        file_offset += 4

        cont = entry >> 31
        t = (entry >> 27) & 0xF
        offset = ((entry) >> 16) & 0x7FF
        value = (entry) & 0xFFFF
        if value >= 0x8000 and not ICHAIN_MACROS[t].startswith('ICHAIN_U'):
            value -= 0x10000

        var_name = '{0:X}'.format(offset)

        if args.offsets:
            var_name = "unk" + var_name
        elif var_name in actor_variable_names:
            var_name = actor_variable_names[var_name]

        print('    {0}({1}, {2}, {3}),'.format(
            ICHAIN_MACROS[t], var_name, value,
            ('ICHAIN_CONTINUE' if cont == 1 else 'ICHAIN_STOP')))
        if cont == 0:
            break
    print('};')