1. This forum is in read-only mode.

[TUTORIAL] Citra 3DS

Discussion in 'Tutorials' started by Prectorian, Jun 16, 2017.

Thread Status:
Not open for further replies.
  1. Prectorian

    Prectorian . Staff Member

    For those of you wanting to play 3DS games on your PC, you'll need to download Citra Emulator and at present requires the use of decrypted 3DS rom. Presently the only way to decrypt a 3DS rom requires a 3DS handheld and flashcart. Maybe/hopefully in future it will run regular 3DS rom (non-decypted), and far as I've heard someone is trying to making an offline 3DS rom decypting tool for PC. That said, 3DS rom available in this site are for the handheld, hence don't expect it to run on Citra.

    Official Homepage for Latest Download Links : https://citra-emu.org/

    From experience, not all present Citra updates enable gamepad/game controller configuration through the main interface, but according to the dev team it will be a fixture in future. As such for updates that don't, you'll need to manually implement it.

    Method for MS Windows PC (Source: https://community.citra-emu.org/t/temporary-controller-configurations-for-citra/1061):
    1. Open File Explorer
    2. Go to : This PC > Local Disk (C: ) > Users > Your Name > AppData > Roaming > Citra > config (or you can always type : C:\Users\Your Name\AppData\Roaming\Citra\config
    3. Open qt-config.ini
    4. Look for [Controls], block it, and replace with this;
    Code:
    [Controls]
    button_a="engine:sdl,joystick:0,button:1"
    button_b="engine:sdl,joystick:0,button:0"
    button_x="engine:sdl,joystick:0,button:3"
    button_y="engine:sdl,joystick:0,button:2"
    button_up="engine:sdl,joystick:0,hat:0,direction:up"
    button_down="engine:sdl,joystick:0,hat:0,direction:down"
    button_left="engine:sdl,joystick:0,hat:0,direction:left"
    button_right="engine:sdl,joystick:0,hat:0,direction:right"
    button_l="engine:sdl,joystick:0,button:4"
    button_r="engine:sdl,joystick:0,button:5"
    button_start="engine:sdl,joystick:0,button:7"
    button_select="engine:sdl,joystick:0,button:6"
    button_zl="engine:keyboard,code:49"
    button_zr="engine:keyboard,code:50"
    button_home="engine:keyboard,code:66"
    circle_pad="axis_x:0,engine:sdl,joystick:0,axis_y:1"
    c_stick="axis_x:3,engine:sdl,joystick:0,axis_y:4"
    The above should work for most gamepad brands. For PS4 controller, there's a tool called 'DS4Windows', and a tool called 'x360ce' for X360 controller as well as other gamepad brand, which you might need to also download and install if doing the above hasn't help. They can easily be found using search engine.

    That said don't expect the emulator to run as smoothly as the handheld, expect glitches and issues, and not all game will run until such a time the dev team adds it into their compatibility list.

    Note:
    Don't even bother sending me PM for technical assistance or ask for decrypted rom. I mean it. I won't be of much help. Also I'm not a member of the dev team, so direct your complains about the emulator to their site. And I can't help much with emulators, nor do I plan to constantly maintain this topic. Feel free to add/share useful information or updates, and discuss solutions to known issues for this emulator which is still in on-going development.
     
    Last edited: Jun 18, 2017
    Jhon 591 likes this.
  2. Prectorian

    Prectorian . Staff Member

  3. Prectorian

    Prectorian . Staff Member

    Compatible games for Citra;

    To find out how each game fair when run on Citra, see : https://citra-emu.org/game/
    Of cause, the list isn't complete. But it's always better than nothing.
     
    Last edited: Jun 22, 2017
  4. Prectorian

    Prectorian . Staff Member

  5. Prectorian

    Prectorian . Staff Member

    An offline 3DS rom decypting tool is now available courtesy of TomMueller for Windows.

    You no longer need to own a 3DS handheld to have a 3DS rom decrypted for use on Citra emulator. However do note that not all .3DS format rom will work as Citra is still in early development stage, and even if it do load, it might crash/glitch. Also not all version of Citra can load the rom for some unknown reason. I'm also hearing that Citra can now load 3DS rom in .CIA format without needing to decrypt it, because it's already decrypted?!

    Disclamer : I do not have anything to do with the development of this tool.

    Steps as instructed by the creator;

    1. download tool & extract : CLICK HERE
    2. prepare a 3DS rom (.3ds) for decryption
    3. place the rom in the 'encrypted' folder
    4. run 'decrypt-all.cmd' (no need to choose admin rights or do anything else, just wait until it says done)
    5. run 'NDSTokyoTrim3.exe'
    6. click 'scan folder' and locate the 'decrypted' folder, click OK
    7. click 'trim' button
    8. done
    9. load decrypted rom on Citra

    Note : steps 5-8 isn't necessary.

    In the event, the rom after decryption fails to load, you might want to try a different version of Citra or replace 'XORpad_generator.py' found inside the 'scripts' folder in the tool as suggested by b3243035. Simply copy the below script code to Notepad and save it with the name mentioned. Do make a backup of the original file and save it somewhere before replacing it!

    Code:
    from Crypto.Cipher import AES
    from Crypto.Util import Counter
    import struct
    
    rol = lambda val, r_bits, max_bits: \
        (val << r_bits%max_bits) & (2**max_bits-1) | \
        ((val & (2**max_bits-1)) >> (max_bits-(r_bits%max_bits)))
    
    def to_bytes(num):
        numstr = ''
        tmp = num
        while len(numstr) < 16:
            numstr += chr(tmp & 0xFF)
            tmp >>= 8
        return numstr[::-1]
    
    with open("ncchinfo.bin", 'rb') as n:
        ncch_info = struct.unpack('<LLLL', n.read(0x10))
        if ncch_info[0] == 0xFFFFFFFF:
            for entry in xrange(0, ncch_info[2]):
                entry_counter = struct.unpack('>QQ', n.read(0x10))
                entry_keyy = struct.unpack('>QQ', n.read(0x10))
                entry_sizemb = struct.unpack('<I', n.read(0x4))
                entry_sizebytes = struct.unpack('<I', n.read(0x4))
                entry_9xcrypto = struct.unpack('<I', n.read(0x4))
                entry_7xcrypto = struct.unpack('<I', n.read(0x4))
                entry_titleid = struct.unpack('<Q', n.read(0x8))
                entry_filename = n.read(0x70)
                filename = str(entry_filename).strip('\x00\\/*?:"<>|]')
                if ((entry_9xcrypto[0] & 0x01) and (entry_7xcrypto[0] == 0x00)):
                    NormalKey = 0x00 # 0-key encrypted rom
                else:
                    if entry_7xcrypto[0] == 0x00: KeyX = 0xB98E95CECA3E4D171F76A94DE934C053 # Key 0x2C - Original Key
                    if entry_7xcrypto[0] == 0x01: KeyX = 0xCEE7D8AB30C00DAE850EF5E382AC5AF3 # Key 0x25 - 7.x Key
                    if entry_7xcrypto[0] == 0x0A: KeyX = 0x82E9C9BEBFB8BDB875ECC0A07D474374 # Key 0x18 - New3DS Key 9.3
                    if entry_7xcrypto[0] == 0x0B: KeyX = 0x45AD04953992C7C893724A9A7BCE6182 # Key 0x1B - New3DS Key 9.6
                    KeyY = long(str("%016X%016X") % (entry_keyy[::]), 16)
                    Const = 0x1FF9E9AAC5FE0408024591DC5D52768A # 3DS AES Constant
                    NormalKey = rol((rol(KeyX, 2, 128) ^ KeyY) + Const, 87, 128)
                CounterIV = long(str("%016X%016X") % (entry_counter[::]), 16)
                ctr = Counter.new(128, initial_value=CounterIV)
                ctrmode = AES.new(to_bytes(NormalKey), AES.MODE_CTR, counter = ctr)
                with open("./xorpad/" + filename, 'w+b') as x:
                        SizeM = (entry_sizebytes[0] / (1024*1024))
                        SizeB = (entry_sizebytes[0] % (1024*1024))
                        if (SizeM > 0):
                            for i in xrange(SizeM):
                                x.write(ctrmode.decrypt(b'\x00' * (1024*1024)))
                                print ("Entry: %02d - Creating - %4d / %4d mb - '%s'\n") % (entry, i + 1, SizeM + 1, filename),
                        if (SizeB > 0):
                            x.write(ctrmode.decrypt(b'\x00' * (SizeB)))
                        print ("Entry: %02d - Creating - %4d / %4d mb - '%s'\n") % (entry, SizeM + 1, SizeM + 1, filename),
        else:
            print "Invalid NCCHINFO.BIN?"
    
    Screen Shots:
    [​IMG]
    If you try to run an encrypted 3DS rom, it won't load.

    [​IMG]
    You'll see this screen when decryption is completed.

    [​IMG]
    This is the trimmer screen before trimming.

    [​IMG]
    This is the trimmer screen after trimming.

    [​IMG]
    Decrypted rom run on Citra (trimmed and untrimmed).
     
    Last edited: Jun 22, 2017
  6. Loonylion

    Loonylion Administrator Staff Member

    you need python to use that
     
  7. Prectorian

    Prectorian . Staff Member

    Not sure, but I don't recall installing python on my PC prior to testing.
     
  8. Loonylion

    Loonylion Administrator Staff Member

    .py files need the python interpreter
     
  9. Prectorian

    Prectorian . Staff Member

    Ah yes, seems so. In that case, no harm installing python before using the tool.
    Anyone needing it can google search it and download/install for free.

    Edit:

    Scratch that. There's a portable python copy provided inside the tool. I just realized it's present. So no need to install a separate python software.
     
    Last edited: Jun 18, 2017
  10. Prectorian

    Prectorian . Staff Member

    Using Cheat Code/GameShark/Action Replay on Citra;

    Unfortunately not all copies/versions/updates/releases of Citra has the ability added. You'll just have to look for a copy/version that does. That said, the option can be found under the 'emulation' tab in the emulator's main interface below 'configure'. If you can't find it at the location I mentioned, then your copy hasn't the ability. You'll need to load the rom before getting access to the cheat editor interface.

    Anyway, you could find such cheat codes pre-made online through searching using you favourite search engine/browser. Alternatively you can try finding/making it yourself using 'Cheat Engine' : http://www.cheatengine.org/aboutce.php if you have the necessary knowledge/capability. The tool is open source/free, with tutorial on how to use it provided in their website. Last but not least, you should read this too before starting : https://community.citra-emu.org/t/using-gameshark-codes-with-citra-and-cheat-engine/267
     
  11. Prectorian

    Prectorian . Staff Member

    Here's another version of 3DS encrypt - decrypt tool.

    It's made by b2071988 for Windows. The difference with TomMueller's tool is that this tool by b2071988 can be use to encrypt a decrypted rom for use with flashcards, and do the opposite for use on Citra. While Tom's is only to decrypt an encrypted rom. As with Tom's tool, base on my personal trial (which can be wrong), it doesn't run on latest Citra. Again, I'm not part of the development team. So don't ask me for technical support.

    Download link : CLICK HERE

    Steps:
    1. download and extract tool
    2. place rom to encrypt/decrypt in the same folder as the tool
    3. run '3ds_decrypt_v2.bat' to decrypt the rom to run on Citra -or- '3ds_encrypt_v2.bat' to encrypt the rom to run on flashcart
    4. wait until prompted to press any key
    5. done (use the same rom as it is overwritten automatically)

    This requires python present in your PC, as such make sure you have it installed for free from its official website. Should the tool not run due to 'syntax error', here's the steps to resolve it as directed by the tool developer.

    Code:
    1. Open System Properties (type it in the start menu, or use the keyboard shortcut Win+Pause)
    2. Switch to the Advanced tab
    3. Click Environment Variables
    4. Select PATH in the System variables section
    5. Click Edit
    6. Add python's path to the end of the list (the paths are separated by semicolons). For example:
    
    C:\Windows;C:\Windows\System32;C:\Python27
    PS: I hope TomMueller and b2071988 don't mind me sharing their incredible tools here. A huge thank you to them both for making the tools. :)

    Note: TomMueller's tool can be found in page 1 reply no. #14.
     
    Last edited: Jun 22, 2017
    Dark Infernape likes this.
  12. Prectorian

    Prectorian . Staff Member

    Adding to the cheat code use in Citra;

    You might need to create the "cheats" folder in the %appdata%\Citra directory, in order to make the cheats saved.

    Note:
    1. It's not an official feature (at present) so not all Citra copies found on the internet has it.
    2. Cheats which requires pressing button combination to activate might not work or causes glitch

    Here's a nice site to find 3DS cheat codes to use for Citra / flash cards : http://www.fort42.com/
     
    Last edited: Jun 22, 2017
  13. Sahel123

    Sahel123 Guest

    I am hearing that Citra has abandoned the Action Replay and Gameshark cheats facility for now due to serious bugs.They plan on implementing them much later in the future. I guess until then we will have to stick with older versions of Citra, preferably the old Bleeding Edge's.
     
  14. Prectorian

    Prectorian . Staff Member

    It's quite true, I've read it in their forum posts, hence they are presently missing from the newer/current versions until they address those bugs.
     
  15. Sahel123

    Sahel123 Guest

    The Cheat Engine you mentioned is great. It is a little dangerous to run an app which can change Hex values of applications, but under the right hands, one can easily change values. Having been using it for several weeks now, I find games easy to hack.

    Most Gateshark cheats for Super Mario 3D Land do not work. Thanks to the Cheat Engine, I was able to easily change the amount of Mario's lives. However, I would like to mention that one should only downloads Cheat Engine V6.6. Any version higher than that is currently a hoax, even on their official website. I caught a malware variant when trying to download the latest version; do not fall for the same mistake.
     
  16. Prectorian

    Prectorian . Staff Member

  17. Sahel123

    Sahel123 Guest

    The 2017 Citra Progress Report has been out for a while (since May 3, 2017), but if anyone would still like to see it and congratulate the Citra team for their strenuous work, visit here
     
  18. Prectorian

    Prectorian . Staff Member

    Info:

    Ever Quest (decrypted) now load on Citra, but still not playable.
     
    Last edited: Jun 30, 2017
  19. Prectorian

    Prectorian . Staff Member

  20. Jhon 591

    Jhon 591 Well-Known Member

    Got a felling 40? sometime maybe soon, Then I see what other branches to merge into my build.
    https://github.com/Jhno591/citra/commits/master

    Game fixes are older from lemon tweaks branch, but dose fix Hhyrule warriors crash
    -------
    Latest was though
    https://github.com/citra-emu/citra-bleeding-edge/tree/bleeding_edge

    But no release yet, maybe one fail fix for it is released
    https://github.com/citra-emu/citra-bleeding-edge/commit/914db40da9503dd719c05a8d5b13ca28245b28a2
     
    Last edited: Jul 9, 2017
    Prectorian likes this.
Thread Status:
Not open for further replies.