Ejemplo n.º 1
0
    filename = sys.argv[1]
    output_folder = sys.argv[2]

    input_file.init(os.path.join(conf.path, filename), 0)

    output_item = ""
    output_item += ".include \"source/macros_asm.s\"\n\n"
    output_item += "@ all unknown\n"

    output_item += "@ method, parameter, target\n"
    i = 0
    while i < 7:
        # http://www.serebii.net/diamondpearl/evolution.shtml
        # 16 by #281
        method = input_file.ReadHWord(0 + i * 6)
        param = input_file.ReadHWord(2 + i * 6)
        target = input_file.ReadHWord(4 + i * 6)

        if method == 0:
            output_item += ".hword " + "Evo_NoEvo" + ", " + str(
                param) + ", " + str(target) + "\n"
        elif method == 1:  # 42, 113, 172
            output_item += ".hword " + "Evo_HighFriendship" + ", " + str(
                param) + ", " + GetPokemonName(target) + "\n"
        elif method == 2:  # 133
            output_item += ".hword " + "Evo_HighFriendshipAtDaytime" + ", " + str(
                param) + ", " + GetPokemonName(target) + "\n"
        elif method == 3:  # 133
            output_item += ".hword " + "Evo_HighFriendshipAtNighttime" + ", " + str(
                param) + ", " + GetPokemonName(target) + "\n"
    output_trainers += ".include \"source/macros_asm.s\"\n\n"
    if format == 1:
        output_trainers += "@ Pkmn, Move1, Move2, Move3, Move4, EVs, Nature, Item, ?, ?\n"
    elif format == 3:
        output_trainers += "@ BTrainer\n"
    else:
        output_trainers += "@ ?, ?, Level, ?, Pkmn, ?, ?\n"

    if format == 0:  # normal trainer pkmn
        i = 0
        while i < (input_file.GetFileSize() / 8):
            unknown1 = input_file.ReadByte(0 + i * 8)
            unknown2 = input_file.ReadByte(1 + i * 8)
            level = input_file.ReadByte(2 + i * 8)
            unknown3 = input_file.ReadByte(3 + i * 8)
            species = input_file.ReadHWord(4 + i * 8)
            unknown4 = input_file.ReadByte(6 + i * 8)
            unknown5 = input_file.ReadByte(7 + i * 8)

            output_trainers += "trainerpoke " + str(unknown1) + ", " + str(
                unknown2) + ", " + str(
                    level) + ", " + str(unknown3) + ", " + str(
                        GetPokemonName(species)) + ", " + str(
                            unknown4) + ", " + str(unknown5) + "\n"
            i += 1
    elif format == 1:  # battle tower pkmn
        species = input_file.ReadHWord(0)
        move1 = input_file.ReadHWord(2)
        move2 = input_file.ReadHWord(4)
        move3 = input_file.ReadHWord(6)
        move4 = input_file.ReadHWord(8)
Ejemplo n.º 3
0
    conf = configuration.Config()

    filename = sys.argv[1]
    output_folder = sys.argv[2]

    input_file.init(os.path.join(conf.path, filename), 0)

    output_trainers = ""
    output_trainers += ".include \"source/macros_asm.s\"\n\n"
    output_trainers += "@ Flag, Class, Battletype, #Pkmn, item1, item2, item3, item4, ai, Battletype2, ?, ?, ?\n"

    flag = input_file.ReadByte(0)
    class_ = input_file.ReadByte(1)
    battletype = input_file.ReadByte(2)
    numpokemon = input_file.ReadByte(3)
    item1 = input_file.ReadHWord(4)
    item2 = input_file.ReadHWord(6)
    item3 = input_file.ReadHWord(8)
    item4 = input_file.ReadHWord(10)
    ai = input_file.ReadWord(12)
    battletype2 = input_file.ReadByte(16)
    unknown1 = input_file.ReadByte(17)
    unknown2 = input_file.ReadByte(18)
    unknown3 = input_file.ReadByte(19)

    output_trainers += "trainer " + str(flag) + ", " + str(
        class_) + ", " + str(battletype) + ", " + str(numpokemon) + ", " + str(
            item1) + ", " + str(item2) + ", " + str(item3) + ", " + str(
                item4) + ", " + str(ai) + ", " + str(battletype2) + ", " + str(
                    unknown1) + ", " + str(unknown2) + ", " + str(unknown3)
Ejemplo n.º 4
0
    else:
        return str(pocket)


if __name__ == "__main__":
    conf = configuration.Config()

    filename = sys.argv[1]
    output_folder = sys.argv[2]

    input_file.init(os.path.join(conf.path, filename), 0)

    output_item = ""
    output_item += ".include \"source/macros_asm.s\"\n\n"

    price = input_file.ReadHWord(0)
    battleeffect = input_file.ReadByte(2)
    gain = input_file.ReadByte(3)
    berrytag = input_file.ReadByte(4)
    flingeffect = input_file.ReadByte(5)
    flingpower = input_file.ReadByte(6)
    naturalpower = input_file.ReadByte(7)
    Unknown8 = input_file.ReadHWord(8)
    Unknown8_1 = (Unknown8 >> 0) & 0x1f
    Unknown8_2 = (Unknown8 >> 5) & 0x1
    Unknown8_3 = (Unknown8 >> 6) & 0x1
    pocket = (Unknown8 >> 8) & 0xf
    Unknown8_4 = (Unknown8 >> 11) & 0x1f
    Unknowna = input_file.ReadByte(0xa)
    Unknownb = input_file.ReadByte(0xb)
    Unknownc = input_file.ReadByte(0xc)
Ejemplo n.º 5
0
    filename = sys.argv[1]
    output_folder = sys.argv[2]

    input_file.init(os.path.join(conf.path, filename), 0)

    output_item = ""
    output_item += ".include \"source/macros_asm.s\"\n\n"
    output_item += "@ all unknown\n"

    move = 0
    level = 0
    val = 0
    i = 0
    while val != 0xffff:
        val = input_file.ReadHWord(i)
        move = val & 0x1ff
        level = val >> 9
        if val != 0xffff:
            output_item += "MoveTable " + GetMoveName(move) + ", " + str(
                level) + "\n"
        i += 2

    output_item += "\n.hword 0xffff\n\n"
    output_item += ".align 2, 0\n"

    if not os.path.exists(os.path.dirname(output_folder)):
        os.makedirs(os.path.dirname(output_folder))
    head, tail = os.path.split(filename)
    with open(os.path.join(output_folder + tail.replace(".bin", ".s")),
              'w') as out:
Ejemplo n.º 6
0
 
 ##############################
 # Interprete the Trainer
 output_trainer = ""
 output_trainer += ".include \"source/macros_asm.s\"\n\n"
 output_trainer += "@ Flag, Class, Battletype, #Pkmn, item1, item2, item3, item4, ai, Battletype2, ?, ?, ?\n"
 
 flag = file_trainer.ReadByte(0)
 format = flag
 if format > 1:
     print("format of '" + str(filename_trainer) + "' is: " + str(format))
     #exit()
 class_ = file_trainer.ReadByte(1)
 battletype = file_trainer.ReadByte(2)
 numpokemon = file_trainer.ReadByte(3)
 item1 = file_trainer.ReadHWord(4)
 item2 = file_trainer.ReadHWord(6)
 item3 = file_trainer.ReadHWord(8)
 item4 = file_trainer.ReadHWord(10)
 ai = file_trainer.ReadWord(12)
 battletype2 = file_trainer.ReadByte(16)
 unknown1 = file_trainer.ReadByte(17)
 unknown2 = file_trainer.ReadByte(18)
 unknown3 = file_trainer.ReadByte(19)
 
 output_trainer += "trainer " + str(flag) + ", " + str(class_) + ", " + str(battletype) + ", " + str(numpokemon) + ", " + str(GetItemName(item1)) + ", "  + str(GetItemName(item2)) + ", "  + str(GetItemName(item3)) + ", "  + str(GetItemName(item4)) + ", "  + str(ai) + ", "  + str(battletype2) + ", "  + str(unknown1) + ", " + str(unknown2) + ", " + str(unknown3)
 
 if not os.path.exists(os.path.dirname(output_folder_trainer)):
     os.makedirs(os.path.dirname(output_folder_trainer))        
 head, tail = os.path.split(filename_trainer)
 with open(os.path.join(output_folder_trainer + tail.replace(".bin", ".s")), 'w') as out:
    filename = sys.argv[1]
    output_folder = sys.argv[2]

    input_file.init(os.path.join(conf.path, filename), 0)

    MovePerm_Size = input_file.ReadWord(0)
    Building_Size = input_file.ReadWord(4)
    MapModel_Size = input_file.ReadWord(8)
    Unknown_Size = input_file.ReadWord(12)

    output_MovePerm = ""
    output_MovePerm += ".include \"source/macros_asm.s\"\n\n"

    i = 0x10
    while i < 0x10 + MovePerm_Size:
        hword01 = input_file.ReadHWord(i + 0x00)
        hword02 = input_file.ReadHWord(i + 0x02)
        hword03 = input_file.ReadHWord(i + 0x04)
        hword04 = input_file.ReadHWord(i + 0x06)
        hword05 = input_file.ReadHWord(i + 0x08)
        hword06 = input_file.ReadHWord(i + 0x0a)
        hword07 = input_file.ReadHWord(i + 0x0c)
        hword08 = input_file.ReadHWord(i + 0x0e)
        hword09 = input_file.ReadHWord(i + 0x10)
        hword10 = input_file.ReadHWord(i + 0x12)
        hword11 = input_file.ReadHWord(i + 0x14)
        hword12 = input_file.ReadHWord(i + 0x16)
        hword13 = input_file.ReadHWord(i + 0x18)
        hword14 = input_file.ReadHWord(i + 0x1a)
        hword15 = input_file.ReadHWord(i + 0x1c)
        hword16 = input_file.ReadHWord(i + 0x1e)
        return str(type)


if __name__ == "__main__":
    conf = configuration.Config()

    filename = sys.argv[1]
    output_folder = sys.argv[2]

    input_file.init(os.path.join(conf.path, filename), 0)

    output_trainers = ""
    output_trainers += ".include \"source/macros_asm.s\"\n\n"
    output_trainers += "@ Effect, Category, Power, Type, Accuracy, PP, EffectChance, Flag1, Priority, Flag2, ContestEffect, ContestType\n"

    effect = input_file.ReadHWord(0)
    category = input_file.ReadByte(2)
    power = input_file.ReadByte(3)
    type = input_file.ReadByte(4)
    accuracy = input_file.ReadByte(5)
    pp = input_file.ReadByte(6)
    effectchance = input_file.ReadByte(7)
    flag1 = input_file.ReadHWord(8)
    priority = input_file.ReadByte(0xa)
    flag2 = input_file.ReadByte(0xb)
    contesteffect = input_file.ReadByte(0xc)
    contesttype = input_file.ReadByte(0xd)

    output_trainers += "move " + str(effect) + ", " + GetCategoryName(
        category) + ", " + str(power) + ", " + GetTypeName(type) + ", " + str(
            accuracy) + ", " + str(pp) + ", " + str(effectchance) + ", " + str(
    output_item = ""
    output_item += ".include \"source/macros_asm.s\"\n\n"
    output_item += "@ HP, Atk, Def, Spe, SpA, SpD, Type1, Type2, CatchRate, BaseExp, EV ((EV_HP)|(EV_Atk<<2)|(EV_Def<<4)|(EV_Spe<<6)|(EV_SpA<<8)|(EV_SpD<<10)), Item1, Item2, Gender, HatchCycle, BaseHappiness, ExpRate, EggGroup1, EggGroup2, Ability1, Ability2, Flee, unknown, unknown, unknown, unknown, unknown, unknown\n"

    HP = input_file.ReadByte(0)
    Atk = input_file.ReadByte(1)
    Def = input_file.ReadByte(2)
    Spe = input_file.ReadByte(3)
    SpA = input_file.ReadByte(4)
    SpD = input_file.ReadByte(5)
    Type1 = input_file.ReadByte(6)
    Type2 = input_file.ReadByte(7)
    CatchRate = input_file.ReadByte(8)
    BaseExp = input_file.ReadByte(9)
    EV = input_file.ReadHWord(0xa)
    EV_HP = (EV >> 0) & 0x3
    EV_Atk = (EV >> 2) & 0x3
    EV_Def = (EV >> 4) & 0x3
    EV_Spe = (EV >> 6) & 0x3
    EV_SpA = (EV >> 8) & 0x3
    EV_SpD = (EV >> 10) & 0x3
    EV_String = "((" + str(EV_HP) + ")|(" + str(EV_Atk) + "<<2)|(" + str(
        EV_Def) + "<<4)|(" + str(EV_Spe) + "<<6)|(" + str(
            EV_SpA) + "<<8)|(" + str(EV_SpD) + "<<10))"
    Item1 = input_file.ReadHWord(0xc)
    Item2 = input_file.ReadHWord(0xe)
    Gender = input_file.ReadByte(0x10)
    HatchCycle = input_file.ReadByte(0x11)
    BaseHappy = input_file.ReadByte(0x12)
    ExpRate = input_file.ReadByte(0x13)
Ejemplo n.º 10
0
        elif sys.argv[i] == "-h":
            size = 2
        elif sys.argv[i] == "-b":
            size = 1
        i += 1

    input_file.init(os.path.join(conf.path, filename), 0)

    output = ""
    if size == 4:
        output = ".word "
    elif size == 2:
        output = ".hword "
    elif size == 1:
        output = ".byte "

    i = start_adr
    while i < end_adr:
        if size == 4:
            word = input_file.ReadWord(i + 0)
        elif size == 2:
            word = input_file.ReadHWord(i + 0)
        elif size == 1:
            word = input_file.ReadByte(i + 0)
        #X1 = input_file.ReadHWord(i+4)
        output += hex(word)
        i += size
        if i < end_adr: output += ", "

    print output
    i = 0
    while i < 26:
        output_encdata += ".word " + GetPokemonName(
            EncData2[i]).ljust(12) + " @ " + comments[i] + "\n"
        i += 1

    comments = ["60%", "30%", "5%", "4%", "1%"]

    offset = 4 + 12 * 8 + 26 * 4
    Rate = input_file.ReadWord(offset)
    EncData = []
    i = 0
    while i < 5:
        unk = input_file.ReadByte(offset + 4 + i * 8)
        unk2 = input_file.ReadByte(offset + 5 + i * 8)
        unk3 = input_file.ReadHWord(offset + 6 + i * 8)
        Pkmn = input_file.ReadWord(offset + 8 + i * 8)
        EncData += [(unk, unk2, unk3, Pkmn)]
        i += 1

    output_encdata += "\n"
    output_encdata += "@ Water:\n"
    output_encdata += "@ Surfing:\n"
    output_encdata += ".word " + str(Rate) + " @ Rate\n"
    i = 0
    while i < 5:
        output_encdata += "WaterEncounter " + (
            str(EncData[i][0]) + ", ").ljust(4) + (
                str(EncData[i][1]) + ", ").ljust(4) + GetPokemonName(
                    EncData[i][3]).ljust(12) + " @ " + comments[i] + "\n"
        i += 1