Ejemplo n.º 1
0
if __name__ == '__main__':
    base_dir = os.path.join(os.path.dirname(__file__), '..', '..', '..', '..',
                            '..')

    rom = NintendoDSRom.fromFile(
        os.path.join(base_dir, 'skyworkcopy_us_unpatched.nds'))
    patcher = Patcher(rom, get_ppmdu_config_for_rom(rom))
    assert not patcher.is_applied('ActorAndLevelLoader')

    patcher.apply('ActorAndLevelLoader')

    bin_before = rom.getFileByName('BALANCE/actor_list.bin')
    # noinspection PyTypeChecker
    # - Bug in PyCharm with bound TypeVars
    actor_list_before: ActorListBin = Sir0Handler.unwrap_obj(
        Sir0Handler.deserialize(bin_before), ActorListBin)
    # This only works with unmodified ROMs!
    assert actor_list_before.list == Pmd2XmlReader.load_default(
        'EoS_NA').script_data.level_entities
    assert len(
        Sir0Handler.deserialize(bin_before).content_pointer_offsets) == len(
            Sir0Handler.wrap_obj(actor_list_before).content_pointer_offsets)

    bin_after = Sir0Handler.serialize(Sir0Handler.wrap_obj(actor_list_before))
    # noinspection PyTypeChecker
    actor_list_after: ActorListBin = Sir0Handler.unwrap_obj(
        Sir0Handler.deserialize(bin_after), ActorListBin)

    with open('/tmp/before.bin', 'wb') as f:
        f.write(bin_before)
Ejemplo n.º 2
0
if __name__ == '__main__':
    base_dir = os.path.join(os.path.dirname(__file__), '..', '..', '..', '..',
                            '..')

    rom = NintendoDSRom.fromFile(
        os.path.join(base_dir, 'skyworkcopy_us_unpatched (Kopie).nds'))
    patcher = Patcher(rom, get_ppmdu_config_for_rom(rom))
    assert not patcher.is_applied('ActorAndLevelLoader')

    patcher.apply('ActorAndLevelLoader')

    bin_before = rom.getFileByName('BALANCE/level_list.bin')
    # noinspection PyTypeChecker
    # - Bug in PyCharm with bound TypeVars
    level_list_before: LevelListBin = Sir0Handler.unwrap_obj(
        Sir0Handler.deserialize(bin_before), LevelListBin)
    # This only works with unmodified ROMs!
    assert level_list_before.list == Pmd2XmlReader.load_default(
        'EoS_NA').script_data.level_list
    assert len(
        Sir0Handler.deserialize(bin_before).content_pointer_offsets) == len(
            Sir0Handler.wrap_obj(level_list_before).content_pointer_offsets)

    bin_after = Sir0Handler.serialize(Sir0Handler.wrap_obj(level_list_before))
    # noinspection PyTypeChecker
    level_list_after: LevelListBin = Sir0Handler.unwrap_obj(
        Sir0Handler.deserialize(bin_after), LevelListBin)

    with open('/tmp/before.bin', 'wb') as f:
        f.write(bin_before)