Esempio n. 1
0
def main():
    args = get_parser().parse_args()
    pj64_sym_path = args.pj64sym
    compile_c = args.compile_c

    script_dir = os.path.dirname(os.path.realpath(__file__))
    run_dir = os.path.join(script_dir, '..')
    os.chdir(run_dir)

    # Target relative path
    relpath = os.path.join('.')

    # Compile code

    os.environ['PATH'] = script_dir + os.pathsep + os.environ['PATH']

    if compile_c:
        os.chdir(os.path.join(run_dir, relpath, 'c'))
        call(['make'])

    os.chdir(os.path.join(run_dir, relpath, 'src'))
    call(['armips', '-sym2', '../build/asm_symbols.txt', 'build.asm'])
    os.chdir(run_dir)

    fixup_asm_symbols(os.path.join(relpath, 'build/asm_symbols.txt'))

    # ...
    c_sym_types = parse_c_symbols(os.path.join(relpath, 'build/c_symbols.txt'))

    # ...
    symbols = parse_asm_symbols(os.path.join(relpath, 'build/asm_symbols.txt'),
                                c_sym_types)

    # Output symbols

    os.chdir(run_dir)

    # Dump symbols as JSON
    offsets = get_offsets_by_target(args.target)
    data_symbols = build_data_symbols(symbols, offsets)
    dump_json_to_file(data_symbols,
                      os.path.join(relpath, 'data/generated/symbols.json'))

    if pj64_sym_path:
        pj64_sym_path = os.path.realpath(pj64_sym_path)
        with open(pj64_sym_path, 'w') as f:
            write_pj64_symbols(f, symbols)

    update_crc(os.path.join(relpath, 'roms/patched.z64'))

    # Diff ROMs
    create_diff(
        os.path.join(relpath, 'roms/base.z64'),
        os.path.join(relpath, 'roms/patched.z64'),
        os.path.join(relpath, 'data/generated/rom_patch.txt'),
        virtual=args.virtual,
        offset=offsets.table,
    )
Esempio n. 2
0
    stream.seek(0x10)
    stream.write(bytearray(crc))

# Patch output ROM

if not diff_only:
    try:
        os.chdir(run_dir + '/patch')
        call(['flips', '--ignore-checksum', 'patch.bps', '../roms/patched.z64'])
    except Exception:
        pass

# Diff ROMs

os.chdir(run_dir)

create_diff('roms/base.z64', 'roms/patched.z64', 'data/rom_patch.txt')

# Compress ROM

os.chdir(run_dir)

if not nocompress:
    if compress32:
        compressor_path = "Compress/Compress32.exe"
    else:
        compressor_path = "Compress/Compress.exe"
    
    call([compressor_path, 'roms/patched.z64', 'Output_ROM/Better_Ocarina_of_Time.z64'])
    os.remove('Archive.bin')
Esempio n. 3
0
def main():
    args = get_parser().parse_args()
    pj64_sym_path = args.pj64sym
    compile_c = args.compile_c

    script_dir = os.path.dirname(os.path.realpath(__file__))
    run_dir = os.path.join(script_dir, '..')
    #os.chdir(run_dir)

    tools_dir = os.path.join(run_dir, 'tools')
    os.environ['PATH'] = tools_dir + os.pathsep + os.environ['PATH']

    os.chdir(run_dir)

    # Target relative path
    relpath = os.path.join('.')

    # Compile code

    os.environ['PATH'] = script_dir + os.pathsep + os.environ['PATH']

    if compile_c:
        os.chdir(os.path.join(run_dir, relpath, 'c'))
        call(['make'])

    os.chdir(os.path.join(run_dir, relpath, 'src'))
    call(['armips', '-sym2', '../build/asm_symbols.txt', 'build.asm'])
    os.chdir(run_dir)

    fixup_asm_symbols(os.path.join(relpath, 'build/asm_symbols.txt'))

    # ...
    c_sym_types = parse_c_symbols(os.path.join(relpath, 'build/c_symbols.txt'))

    # ...
    symbols = parse_asm_symbols(os.path.join(relpath, 'build/asm_symbols.txt'),
                                c_sym_types)

    # Output symbols

    os.chdir(run_dir)

    # Dump symbols as JSON
    offsets = get_offsets_by_target(args.target)
    data_symbols = build_data_symbols(symbols, offsets)
    dump_json_to_file(data_symbols,
                      os.path.join(relpath, 'data/generated/symbols.json'))

    if pj64_sym_path:
        pj64_sym_path = os.path.realpath(pj64_sym_path)
        with open(pj64_sym_path, 'w') as f:
            write_pj64_symbols(f, symbols)

    update_crc(os.path.join(relpath, 'roms/patched.z64'))

    # Patch output ROM

    try:
        os.chdir(run_dir + '/patch')
        call(
            ['flips', '--ignore-checksum', 'patch.bps', '../roms/patched.z64'])
    except Exception:
        pass

    # Diff ROMs

    os.chdir(run_dir)

    create_diff(
        os.path.join(relpath, 'roms/base.z64'),
        os.path.join(relpath, 'roms/patched.z64'),
        os.path.join(relpath, 'data/generated/rom_patch.txt'),
        virtual=args.virtual,
        offset=offsets.table,
    )

    # Compress ROM

    os.chdir(run_dir + '/Compress')

    call([
        'Compress', '../roms/patched.z64',
        '../Output_ROM/Better_Majora_Mask.z64'
    ])
    os.remove('Archive.bin')
            'address': address,
        }

# Output symbols

os.chdir(run_dir)

data_symbols = {}
for (name, sym) in symbols.items():
    if sym['type'] == 'data':
        addr = int(sym['address'], 16)
        if 0x80400000 <= addr < 0x80410000:
            addr = addr - 0x80400000 + 0x03480000
        else:
            continue
        data_symbols[name] = '{0:08X}'.format(addr)
with open('../data/generated/symbols.json', 'w') as f:
    json.dump(data_symbols, f, indent=4, sort_keys=True)

if pj64_sym_path:
    pj64_sym_path = os.path.realpath(pj64_sym_path)
    with open(pj64_sym_path, 'w') as f:
        key = lambda pair: pair[1]['address']
        for sym_name, sym in sorted(symbols.items(), key=key):
            f.write('{0},{1},{2}\n'.format(sym['address'], sym['type'],
                                           sym_name))

# Diff ROMs
create_diff('roms/base.z64', 'roms/patched.z64',
            '../data/generated/rom_patch.txt')
Esempio n. 5
0
from rom_diff import create_diff

create_diff('../roms/base.z64', '../roms/V1a.z64', '../roms/base_to_v1a.txt')
create_diff('../roms/port.z64', '../roms/f**k', '../roms/v1a_to_port.txt')
Esempio n. 6
0
def main():
    args = get_parser().parse_args()
    pj64_sym_path = args.pj64sym
    compile_c = args.compile_c

    script_dir = os.path.dirname(os.path.realpath(__file__))
    run_dir = os.path.join(script_dir, '..')
    os.chdir(run_dir)

    # Target relative path
    relpath = os.path.join('.')

    # Compile code

    os.environ['PATH'] = script_dir + os.pathsep + os.environ['PATH']

    if compile_c:
        os.chdir(os.path.join(run_dir, relpath, 'c'))
        if args.jobs is not None:
            # Call `make` with `-j` or `-j <number>` to run multiple jobs simultaneously.
            call(['make', '--always-make'] + get_jobs_arguments(args.jobs))
        else:
            call(['make'])

    os.chdir(os.path.join(run_dir, relpath, 'src'))
    call(['armips', '-sym2', '../build/asm_symbols.txt', 'Build.asm'])
    os.chdir(run_dir)

    fixup_asm_symbols(os.path.join(relpath, 'build/asm_symbols.txt'))

    # ...
    c_sym_types = parse_c_symbols(os.path.join(relpath, 'build/c_symbols.txt'))

    # ...
    symbols = parse_asm_symbols(os.path.join(relpath, 'build/asm_symbols.txt'), c_sym_types)

    # Output symbols

    os.chdir(run_dir)

    # Create subdirectory for generated files if it doesn't exist.
    generated_path = os.path.join(relpath, 'build/generated')
    os.makedirs(generated_path, exist_ok=True)

    # Dump symbols as JSON
    offsets = get_offsets_by_target(args.target)
    data_symbols = build_data_symbols(symbols, offsets)
    dump_json_to_file(data_symbols, os.path.join(generated_path, 'symbols.json'))

    if pj64_sym_path:
        pj64_sym_path = os.path.realpath(pj64_sym_path)
        with open(pj64_sym_path, 'w') as f:
            write_pj64_symbols(f, symbols)

    update_crc(os.path.join(relpath, 'roms/patched.z64'))

    # Diff ROMs
    create_diff(
        os.path.join(relpath, 'roms/base.z64'),
        os.path.join(relpath, 'roms/patched.z64'),
        os.path.join(generated_path, 'rom_patch.bin'),
        virtual=args.virtual,
        offset=offsets.table,
    )