import os
print("="*50)
print('''  .--, -``-.                             ''')
print(''' /   /     '.      ,---,      .--.--.    ''')
print('''/ ../        ;   .'  .' `\   /  /    '.  ''')
print('''\ ``\  .`-    ',---.'     \ |  :  /`. /  ''')
print(''' \___\/   \   :|   |  .`\  |;  |  |--`   ''')
print('''      \   :   |:   : |  '  ||  :  ;_     ''')
print('''      /  /   / |   ' '  ;  : \  \    `.  ''')
print('''      \  \   \ '   | ;  .  |  `----.   \ ''')
print('''  ___ /   :   ||   | :  |  '  __ \  \  | ''')
print(''' /   /\   /   :'   : | /  ;  /  /`--'  / ''')
print('''/ ,,/  ',-    .|   | '` ,/  '--'.     /  ''')
print('''\ ''\        ; ;   :  .'      `--'---'   ''')
print(''' \   \     .'  |   ,.'                   ''')
print('''  `--`-,,-'    '---'                     ''')
print("="*50)
print("\n\n")
print("A tool to convert CIA into CCI and also to decrypt them and make them playable in citra!")
print("54634564 - decrypt.exe")
print("profi200 - makerom.exe, ctrtool.exe")
print("matif - Batch CIA 3DS Decryptor.bat")
print("@rohithvishaal - I just wrote this automation script....")
print("legends are the first three!!!")
print("-"*50)
print("make sure the file and the script are in the same folder!\nAvoid filenames with spaces\n")
print("-"*50)
print("MENU:")
print("0)CCI to CIA converter")
print("1)CIA to CCI converter")
print("2)CCI decrypter")
print("3)CIA to CCI decrypted")
print("-"*50)
choice = input("Enter Choice:")
print("\n")
print("-"*50)
while choice:
    try:
        if choice == "0":
            romName = input("Enter rom name(you can exclude the .cia part):")
            print(
                "you can open cmd in your folder and type makerom-x86_64.exe to see all available options")
            command = "makerom-x86_64 -ccitocia "+romName+".cia"
            print("executing ", command)
            print("Beggining Conversion!")
            os.system(command)
            print("conversion Complete!")
            quit()
        if choice == "1":
            romName = input("Enter rom name(you can exclude the .cia part):")
            print(
                "you can open cmd in your folder and type makerom-x86_64.exe to see all available options")
            command = "makerom-x86_64 -ciatocci "+romName+".cia"
            print("executing ", command)
            print("Beggining Conversion to .cci!")
            os.system(command)
            print("conversion Complete!")
            quit()
        elif choice == "2":
            print("Place your ROM file in the script folder")
            print("This takes some time don't think your screen is frozen :)")
            input("press any key to continue!")
            os.system('''"Batch CIA 3DS Decryptor".bat''')
            quit()
        elif choice == "3":
            print("Do this if your rom is encrypted only!")
            print(
                "to check whether your rom is encrypted just load the .cci file in citra")
            romName = input("Enter rom name(you can exclude the .cia part):")
            command = "makerom-x86_64 -ciatocci "+romName+".cia"
            print("executing ", command)
            print("Beggining Conversion!")
            os.system(command)
            print("conversion Complete!\nBeggining Decrypting process\n")
            print("This takes some time don't think your screen is frozen :)")
            os.system('''"Batch CIA 3DS Decryptor".bat''')
            quit()
        else:
            choice = input("Enter a valid Choice:")
    except:
        print("Something went wrong")
        print("Possible reasons")
        print("1)Did you enter a valid name of the rom")
        print("2)Is rom in the same folder(it need's to be).")
        print("3)A corrupted rom file.")
